Skip to content

feat(mastracode): add /fix-issue and /report-issue commands#13605

Merged
DanielSLew merged 3 commits into
mainfrom
feat/mastracode/auto-fix
Mar 1, 2026
Merged

feat(mastracode): add /fix-issue and /report-issue commands#13605
DanielSLew merged 3 commits into
mainfrom
feat/mastracode/auto-fix

Conversation

@DanielSLew

@DanielSLew DanielSLew commented Feb 27, 2026

Copy link
Copy Markdown
Member

Adds two new built-in slash commands to mastracode:

/fix-issue [number] — without an argument, lists open issues labeled mastracode. 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

  • New Features
    • Added /report-issue command—a guided workflow to help you file well-structured bug reports with automatic environment collection, duplicate detection, and approval before submission.

DanielSLew and others added 2 commits February 27, 2026 17:49
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>
@vercel

vercel Bot commented Feb 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mastra-docs Ready Ready Preview, Comment Feb 27, 2026 11:01pm
mastra-docs-1.x Building Building Preview, Comment Feb 27, 2026 11:01pm

Request Review

@changeset-bot

changeset-bot Bot commented Feb 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 079d9d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mastracode Minor

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

@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 617e73f and 079d9d4.

📒 Files selected for processing (5)
  • .changeset/itchy-tigers-search.md
  • mastracode/src/tui/command-dispatch.ts
  • mastracode/src/tui/commands/index.ts
  • mastracode/src/tui/components/help-overlay.ts
  • mastracode/src/tui/setup.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • mastracode/src/tui/setup.ts
  • .changeset/itchy-tigers-search.md

Walkthrough

Adds a new /report-issue slash command to the TUI that guides users through filing structured bug reports to GitHub. The command collects issue descriptions, checks for duplicates, drafts the issue, and creates it via the gh CLI tool after user approval.

Changes

Cohort / File(s) Summary
Changelog Entry
.changeset/itchy-tigers-search.md
Documents the addition of the new /report-issue slash command feature.
Core Command Implementation
mastracode/src/tui/command-dispatch.ts, mastracode/src/tui/commands/index.ts, mastracode/src/tui/commands/report-issue.ts
Wires up the new command handler; command-dispatch.ts adds routing logic, commands/index.ts exports the handler, and report-issue.ts implements the multi-step interactive workflow for collecting issue details, checking duplicates, drafting, and creating issues.
UI/UX Integration
mastracode/src/tui/components/help-overlay.ts, mastracode/src/tui/setup.ts
Registers the new command in help documentation and autocomplete list.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions adding both /fix-issue and /report-issue commands, but the changeset only contains implementation for /report-issue; /fix-issue is absent from all modified files. Update the title to 'feat(mastracode): add /report-issue command' to accurately reflect the actual changes in this pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/mastracode/auto-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9257d01 and 617e73f.

📒 Files selected for processing (7)
  • .changeset/itchy-tigers-search.md
  • mastracode/src/tui/command-dispatch.ts
  • mastracode/src/tui/commands/fix-issue.ts
  • mastracode/src/tui/commands/index.ts
  • mastracode/src/tui/commands/report-issue.ts
  • mastracode/src/tui/components/help-overlay.ts
  • mastracode/src/tui/setup.ts

Comment thread .changeset/itchy-tigers-search.md Outdated
'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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

Comment on lines +22 to +34
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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

Comment on lines +54 to +71
`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` +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment on lines +108 to +109
`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' +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
`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>
@DanielSLew DanielSLew merged commit 829a096 into main Mar 1, 2026
33 of 36 checks passed
@DanielSLew DanielSLew deleted the feat/mastracode/auto-fix branch March 1, 2026 18:47
wardpeet pushed a commit that referenced this pull request Mar 9, 2026
Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
TylerBarnes added a commit that referenced this pull request Jun 4, 2026
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>
TylerBarnes added a commit that referenced this pull request Jun 5, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants