feat(mastracode): add /fix-issue and /report-issue commands#13605
Conversation
Add two new built-in slash commands: - /fix-issue [number] - lists open mastracode-labeled issues or walks through cloning the repo, reproducing, fixing, and opening a PR for a specific issue - /report-issue [context] - interviews the user about their problem, checks for duplicates, drafts a well-structured issue, and creates it after user approval Both commands are wired into autocomplete, help overlay, and command dispatch. Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 079d9d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/itchy-tigers-search.md:
- Line 5: Update the changeset entry for the new slash commands (/fix-issue and
/report-issue) to be scannable and include a short usage example for each: break
the long sentence into 2–3 action-oriented bullets (what the command does, when
to use it), then add a one-line usage example for /fix-issue (e.g., "/fix-issue
--repo owner/repo --issue 123 — walks you through cloning, reproducing, fixing,
and PR") and for /report-issue (e.g., "/report-issue --repo owner/repo — guided
prompts to compose a bug report and check duplicates"); keep each sentence short
and direct per the guidelines.
In `@mastracode/src/tui/commands/fix-issue.ts`:
- Around line 22-34: Validate the issueNumber right after const issueNumber =
args[0]; and before entering the else branch: if issueNumber is present but not
a purely numeric string (e.g., !/^\d+$/.test(issueNumber)), reject early (return
or throw a user-visible error message) instead of constructing the fix-mode
prompt; update the code paths that use issueNumber (the else branch that builds
prompt) to assume a numeric ID only after this guard so non-numeric inputs are
rejected promptly.
- Around line 54-71: The shell snippets in fix-issue.ts interpolate unquoted
repoDir which breaks on paths with spaces (e.g., "Application Support"); replace
every occurrence of `${repoDir}` inside generated command blocks with
`${quotedRepoDir}` (references: variable repoDir and the template-building code
in fix-issue.ts that emits the clone/cd/git/fetch/push blocks), and ensure a
quotedRepoDir value is defined earlier (e.g., a safe wrapper around repoDir that
quotes or shell-escapes it) so all `cd`, `git clone`, and other shell commands
use the quoted form.
- Around line 108-109: The string building for the gh pr create example emits a
literal "\\n" inside the fenced code block (see the concatenated piece
containing `--body \"<description ... Reference #${issueNumber}>\"\\n`), which
corrupts the --body arg; remove the escaped backslash so a real newline is
inserted instead—e.g., change the tail from `...\"\\n' + '```\n'` to use a real
newline concatenation like `...\"' + '\n' + '```\n'` (or simply `...\"` + '\n' +
'```\n'`) in the function constructing the example string to ensure the code
block ends with an actual newline not the literal `\\n`.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.changeset/itchy-tigers-search.mdmastracode/src/tui/command-dispatch.tsmastracode/src/tui/commands/fix-issue.tsmastracode/src/tui/commands/index.tsmastracode/src/tui/commands/report-issue.tsmastracode/src/tui/components/help-overlay.tsmastracode/src/tui/setup.ts
| 'mastracode': minor | ||
| --- | ||
|
|
||
| Added /fix-issue and /report-issue slash commands. /fix-issue lets you pick an open mastracode-labeled issue and walks you through cloning the repo, reproducing the bug, fixing it, and opening a PR. /report-issue starts a guided conversation to help you file a well-structured bug report, checking for duplicates before creating. |
There was a problem hiding this comment.
Add a short usage example and make this entry scannable (potential_issue).
This is a new feature changeset, but it has no command usage example and is currently one long sentence.
✍️ Suggested changeset text
-Added /fix-issue and /report-issue slash commands. /fix-issue lets you pick an open mastracode-labeled issue and walks you through cloning the repo, reproducing the bug, fixing it, and opening a PR. /report-issue starts a guided conversation to help you file a well-structured bug report, checking for duplicates before creating.
+Added two slash commands for issue workflows.
+
+- Added `/fix-issue` to list open `mastracode` issues and guide you through reproducing, fixing, and submitting a PR.
+- Added `/report-issue` to guide bug reporting, check for duplicates, and create a new issue or comment on an existing one.
+
+**Examples**
+- `/fix-issue`
+- `/fix-issue 12345`
+- `/report-issue editor crashes after /models`As per coding guidelines “If the change is ... adding a new feature, ensure that a short code example is provided” and “Write short, direct sentences ... Use action-oriented verbs.”
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Added /fix-issue and /report-issue slash commands. /fix-issue lets you pick an open mastracode-labeled issue and walks you through cloning the repo, reproducing the bug, fixing it, and opening a PR. /report-issue starts a guided conversation to help you file a well-structured bug report, checking for duplicates before creating. | |
| Added two slash commands for issue workflows. | |
| - Added `/fix-issue` to list open `mastracode` issues and guide you through reproducing, fixing, and submitting a PR. | |
| - Added `/report-issue` to guide bug reporting, check for duplicates, and create a new issue or comment on an existing one. | |
| **Examples** | |
| - `/fix-issue` | |
| - `/fix-issue 12345` | |
| - `/report-issue editor crashes after /models` |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.changeset/itchy-tigers-search.md at line 5, Update the changeset entry for
the new slash commands (/fix-issue and /report-issue) to be scannable and
include a short usage example for each: break the long sentence into 2–3
action-oriented bullets (what the command does, when to use it), then add a
one-line usage example for /fix-issue (e.g., "/fix-issue --repo owner/repo
--issue 123 — walks you through cloning, reproducing, fixing, and PR") and for
/report-issue (e.g., "/report-issue --repo owner/repo — guided prompts to
compose a bug report and check duplicates"); keep each sentence short and direct
per the guidelines.
| const issueNumber = args[0]; | ||
| let prompt: string; | ||
|
|
||
| if (!issueNumber) { | ||
| // List mode: show open mastracode issues | ||
| prompt = | ||
| `List the open GitHub issues labeled \`mastracode\` in the mastra repo. Run:\n\n` + | ||
| '```\n' + | ||
| `gh issue list --repo mastra-ai/mastra --label mastracode --state open --limit 30 --json number,title,author,labels,createdAt\n` + | ||
| '```\n\n' + | ||
| `Present them in a clear table with issue number, title, and author. ` + | ||
| `Then ask me which issue I'd like to fix.`; | ||
| } else { |
There was a problem hiding this comment.
Validate issueNumber before entering fix mode.
/fix-issue should reject non-numeric IDs early instead of building an invalid workflow prompt.
✅ Proposed guard
- const issueNumber = args[0];
+ const issueNumber = args[0]?.trim();
+ if (issueNumber && !/^\d+$/.test(issueNumber)) {
+ ctx.showError('Issue number must be numeric. Usage: /fix-issue <number>');
+ return;
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const issueNumber = args[0]; | |
| let prompt: string; | |
| if (!issueNumber) { | |
| // List mode: show open mastracode issues | |
| prompt = | |
| `List the open GitHub issues labeled \`mastracode\` in the mastra repo. Run:\n\n` + | |
| '```\n' + | |
| `gh issue list --repo mastra-ai/mastra --label mastracode --state open --limit 30 --json number,title,author,labels,createdAt\n` + | |
| '```\n\n' + | |
| `Present them in a clear table with issue number, title, and author. ` + | |
| `Then ask me which issue I'd like to fix.`; | |
| } else { | |
| const issueNumber = args[0]?.trim(); | |
| if (issueNumber && !/^\d+$/.test(issueNumber)) { | |
| ctx.showError('Issue number must be numeric. Usage: /fix-issue <number>'); | |
| return; | |
| } | |
| let prompt: string; | |
| if (!issueNumber) { | |
| // List mode: show open mastracode issues | |
| prompt = | |
| `List the open GitHub issues labeled \`mastracode\` in the mastra repo. Run:\n\n` + | |
| ' |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@mastracode/src/tui/commands/fix-issue.ts` around lines 22 - 34, Validate the
issueNumber right after const issueNumber = args[0]; and before entering the
else branch: if issueNumber is present but not a purely numeric string (e.g.,
!/^\d+$/.test(issueNumber)), reject early (return or throw a user-visible error
message) instead of constructing the fix-mode prompt; update the code paths that
use issueNumber (the else branch that builds prompt) to assume a numeric ID only
after this guard so non-numeric inputs are rejected promptly.
| `The work directory is: \`${repoDir}\`\n\n` + | ||
| (repoExists | ||
| ? `The repo already exists. Run these commands:\n` + | ||
| '```\n' + | ||
| `cd ${repoDir}\n` + | ||
| `git fetch origin\n` + | ||
| `git checkout -B fix/issue-${issueNumber} origin/main\n` + | ||
| '```\n' | ||
| : `Clone the repo first:\n` + | ||
| '```\n' + | ||
| `git clone https://github.com/mastra-ai/mastra.git ${repoDir}\n` + | ||
| `cd ${repoDir}\n` + | ||
| `git checkout -b fix/issue-${issueNumber} origin/main\n` + | ||
| '```\n') + | ||
| `\nThen install and build:\n` + | ||
| '```\n' + | ||
| `cd ${repoDir}\n` + | ||
| `pnpm install\n` + |
There was a problem hiding this comment.
Quote repoDir in shell commands to avoid failures on paths with spaces.
On macOS, the default app data path includes Application Support; unquoted cd/git clone commands fail there.
🛠️ Proposed fix
export async function handleFixIssueCommand(ctx: SlashCommandContext, args: string[]): Promise<void> {
@@
} else {
const repoDir = getRepoDir();
+ const quotedRepoDir = `"${repoDir.replace(/"/g, '\\"')}"`;
@@
`## Stage 1: Setup\n\n` +
`The work directory is: \`${repoDir}\`\n\n` +
(repoExists
? `The repo already exists. Run these commands:\n` +
'```\n' +
- `cd ${repoDir}\n` +
+ `cd ${quotedRepoDir}\n` +
`git fetch origin\n` +
`git checkout -B fix/issue-${issueNumber} origin/main\n` +
'```\n'
: `Clone the repo first:\n` +
'```\n' +
- `git clone https://github.com/mastra-ai/mastra.git ${repoDir}\n` +
- `cd ${repoDir}\n` +
+ `git clone https://github.com/mastra-ai/mastra.git ${quotedRepoDir}\n` +
+ `cd ${quotedRepoDir}\n` +
`git checkout -b fix/issue-${issueNumber} origin/main\n` +
'```\n') +
`\nThen install and build:\n` +
'```\n' +
- `cd ${repoDir}\n` +
+ `cd ${quotedRepoDir}\n` +
`pnpm install\n` +
`pnpm build\n` +
'```\n' +
@@
`2. Push the branch:\n` +
'```\n' +
- `cd ${repoDir}\n` +
+ `cd ${quotedRepoDir}\n` +
`git push origin fix/issue-${issueNumber}\n` +
'```\n' +Also applies to: 103-104
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@mastracode/src/tui/commands/fix-issue.ts` around lines 54 - 71, The shell
snippets in fix-issue.ts interpolate unquoted repoDir which breaks on paths with
spaces (e.g., "Application Support"); replace every occurrence of `${repoDir}`
inside generated command blocks with `${quotedRepoDir}` (references: variable
repoDir and the template-building code in fix-issue.ts that emits the
clone/cd/git/fetch/push blocks), and ensure a quotedRepoDir value is defined
earlier (e.g., a safe wrapper around repoDir that quotes or shell-escapes it) so
all `cd`, `git clone`, and other shell commands use the quoted form.
| `gh pr create --repo mastra-ai/mastra --base main --head fix/issue-${issueNumber} --label mastracode --title \"fix: <concise description>\" --body \"<description of the fix, what was wrong, and how it was fixed. Reference #${issueNumber}>\"\\n` + | ||
| '```\n' + |
There was a problem hiding this comment.
Fix malformed gh pr create command text at Line 108.
The trailing \\n is emitted as literal text in the command block and can corrupt the --body argument.
🧩 Proposed fix
- `gh pr create --repo mastra-ai/mastra --base main --head fix/issue-${issueNumber} --label mastracode --title \"fix: <concise description>\" --body \"<description of the fix, what was wrong, and how it was fixed. Reference #${issueNumber}>\"\\n` +
+ `gh pr create --repo mastra-ai/mastra --base main --head fix/issue-${issueNumber} --label mastracode --title "fix: <concise description>" --body "<description of the fix, what was wrong, and how it was fixed. Reference #${issueNumber}>"\n` +📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| `gh pr create --repo mastra-ai/mastra --base main --head fix/issue-${issueNumber} --label mastracode --title \"fix: <concise description>\" --body \"<description of the fix, what was wrong, and how it was fixed. Reference #${issueNumber}>\"\\n` + | |
| '```\n' + | |
| `gh pr create --repo mastra-ai/mastra --base main --head fix/issue-${issueNumber} --label mastracode --title "fix: <concise description>" --body "<description of the fix, what was wrong, and how it was fixed. Reference #${issueNumber}">"\n` + | |
| ' |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@mastracode/src/tui/commands/fix-issue.ts` around lines 108 - 109, The string
building for the gh pr create example emits a literal "\\n" inside the fenced
code block (see the concatenated piece containing `--body \"<description ...
Reference #${issueNumber}>\"\\n`), which corrupts the --body arg; remove the
escaped backslash so a real newline is inserted instead—e.g., change the tail
from `...\"\\n' + '```\n'` to use a real newline concatenation like `...\"' +
'\n' + '```\n'` (or simply `...\"` + '\n' + '```\n'`) in the function
constructing the example string to ensure the code block ends with an actual
newline not the literal `\\n`.
Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
Document PR #13574 Harness file attachment support and PR #13605 GitHub issue reporting in the Mastra Code testing recovery map. Capture the current-source distinction that only /report-issue remains at HEAD despite the original PR title mentioning /fix-issue.\n\nVerification:\n- pnpm --filter ./packages/core exec vitest run src/agent/__tests__/agent-signals.test.ts src/agent/message-list/adapters/AIV5Adapter-file-ui-part.test.ts src/agent/message-list/prompt/attachments-to-parts.test.ts --reporter=dot --bail 1\n- pnpm --filter ./mastracode exec vitest run src/tui/__tests__/command-dispatch.test.ts src/tui/components/__tests__/help-overlay.test.ts --reporter=dot --bail 1\n\nCo-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
Document PR #13574 Harness file attachment support and PR #13605 GitHub issue reporting in the Mastra Code testing recovery map. Capture the current-source distinction that only /report-issue remains at HEAD despite the original PR title mentioning /fix-issue.\n\nVerification:\n- pnpm --filter ./packages/core exec vitest run src/agent/__tests__/agent-signals.test.ts src/agent/message-list/adapters/AIV5Adapter-file-ui-part.test.ts src/agent/message-list/prompt/attachments-to-parts.test.ts --reporter=dot --bail 1\n- pnpm --filter ./mastracode exec vitest run src/tui/__tests__/command-dispatch.test.ts src/tui/components/__tests__/help-overlay.test.ts --reporter=dot --bail 1\n\nCo-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
Adds two new built-in slash commands to mastracode:
/fix-issue [number]— without an argument, lists open issues labeledmastracode. With an issue number, it walks you through cloning the repo, setting up a branch, reproducing the bug with a failing test, implementing the fix, and opening a PR./report-issue [context]— starts a conversation to help you file a bug report. The LLM interviews you about the problem, gathers environment info, checks for duplicate issues, drafts a title and body, shows it for your approval, then creates (or comments on) the issue.Both commands are registered in autocomplete suggestions, the help overlay, and command dispatch.
Summary by CodeRabbit
Release Notes
/report-issuecommand—a guided workflow to help you file well-structured bug reports with automatic environment collection, duplicate detection, and approval before submission.