feat(github-app): add command response previews - #267
Merged
Conversation
|
Related Knowledge 1 document with suggested updates is ready for review. gittensory For MaintainersView Suggested Changes@@ -319,6 +319,82 @@
Maintainers can interact with Gittensory directly in GitHub PR and issue threads by mentioning `@gittensory` with a command. These commands provide public-safe intelligence about PRs, contributors, and repository fit without exposing private scoring internals.
+### Command Response Preview API
+
+Before posting commands publicly on PR threads, maintainers can preview what Gittensory would respond using the protected `/v1/app/commands/preview` endpoint. This allows dry-running command responses to test output before comments, labels, or checks are posted to GitHub.
+
+**Access control:**
+
+- Protected endpoint requiring maintainer, owner, or operator role
+- Repository-scoped access checks: users can only preview commands for repositories they have access to
+- Operators can preview for any repository
+
+**Request:**
+
+```
+POST /v1/app/commands/preview
+```
+
+Request body:
+
+- `command` — The command to preview (e.g., "preflight", "help", "queue-summary")
+- `repoFullName` — Target repository (e.g., "entrius/allways-ui")
+- `pullNumber` — Target pull request number
+- `login` — Optional user login for context
+- `sample` — Optional sample context to simulate different scenarios:
+ - `authorLogin` — Simulate a specific PR author
+ - `authorType` — "User" or "Bot"
+ - `authorAssociation` — Simulated author association (OWNER, MEMBER, COLLABORATOR, CONTRIBUTOR, NONE)
+ - `commenterLogin` — Simulate a specific commenter
+ - `commenterAssociation` — Simulated commenter association
+ - `minerStatus` — "confirmed", "not_found", or "unavailable"
+ - `title`, `body`, `labels`, `linkedIssues` — Simulated PR metadata
+ - `permissions` — Simulated GitHub App permission map
+ - `missingPermissions` — Array of missing permissions to simulate
+
+**Response:**
+
+The API returns a `CommandPreviewResponse` with:
+
+- **Sanitized response body** — The exact comment text that would be posted to GitHub, with all forbidden terms (wallet, hotkey, payout, reward, farming, scoreability) removed
+- **Decision information:**
+ - `status` — "ready", "skipped", "missing_permission", or "private_api"
+ - `willComment`, `willLabel`, `willCheckRun` — Boolean flags indicating what Gittensory would do
+ - `skipReason` — Why the command would be skipped (if applicable)
+ - `actions` — Array of actions: "comment", "label", "check_run", "skip", or "none"
+ - `summary` — Human-readable decision summary
+- **Missing permissions diagnostics** — List of missing GitHub App permissions that would block the command, with specific remediation actions
+- **Sample context used** — Confirmation of the author, commenter, associations, miner status, PR details, and permissions used to generate the preview
+- **Sanitizer diagnostics** — Shows if any forbidden terms were detected in the response body
+
+**What can be previewed:**
+
+All `@gittensory` mention commands including:
+
+- Public commands: `help`, `preflight`, `blockers`, `duplicate-check`, `miner-context`, `next-action`, `reviewability`, `repo-fit`, `packet`
+- Maintainer-only commands: `queue-summary`, `review-now`, `needs-author`, `confirmed-miners`, `duplicate-clusters`
+- The `public-summary` command (simplified version of `help`)
+
+**What is NOT previewed:**
+
+Private API commands such as `plan-next-work`, `preflight-branch`, `prepare-pr-packet` show a simplified "private API preview only" response indicating the endpoint that would be called, with no GitHub comment, label, or check run.
+
+**Preview guarantees:**
+
+- No GitHub state is mutated: previews never post comments, create labels, update check runs, or call GitHub APIs
+- Responses are sanitized using the same public/private boundary enforcement as live commands
+- Missing GitHub App permissions are detected and reported before the preview is generated
+- Authorization checks are enforced: maintainer-only commands require maintainer associations in the sample context
+- Repo access scope is validated: users cannot preview commands for repositories they don't have access to (unless they have operator role)
+
+**Use cases:**
+
+- Test command responses before they're posted publicly on pull requests
+- Verify output text for maintainer-only digest commands before invoking them in PR threads
+- Simulate different contributor scenarios (confirmed miner vs. non-miner, maintainer vs. outside contributor) to understand how Gittensory would respond
+- Debug missing permissions or authorization issues before live invocation
+- Validate that forbidden terms are properly sanitized from responses
+
### How Commands Work
Comment `@gittensory <command>` on any PR or issue thread in an installed repository [[45]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/src/github/commands.ts#L51-L58). Commands are case-insensitive and parsed using the pattern `/(?:^|\s)@gittensory(?:\s+([a-z-]+))?/i`. If no command is specified or an unknown command is provided, the system defaults to the `help` command.✅ Accepted |
JSONbored
previously requested changes
Jun 2, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@MkDev11 please fix failing CI
Contributor
Author
@JSONbored please review the update |
JSONbored
dismissed
their stale review
June 2, 2026 16:36
@MkDev11 no current code changes requested. CI is green, the branch is clean, and the previous blocker was stale CI state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1/app/commands/previewAPI that lets maintainer/owner/operator users preview sanitized@gittensorycommand responses without posting comments, labels, or checks.Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; global coverage stays at or above 97% for lines, statements, functions, and branches (Node 22 coverage: statements 99.05%, branches 97.05%, functions 98.28%, lines 99.65%)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:mcp-packwas verified with Node 22.22.3 to match.nvmrc/CI.Safety
Notes
CONTRIBUTING.mdreserves changelog edits for release prep.apps/gittensory-ui/public/downloads/remains unstaged afternpm run ui:build.