Skip to content

fix(mcp): validate the /pm prompt command argument - #786

Merged
getappz merged 1 commit into
masterfrom
task/606-pm-mcp-prompt-validate-the-command-argum
Sep 21, 2026
Merged

getappz merged 1 commit into
masterfrom
task/606-pm-mcp-prompt-validate-the-command-argum

Conversation

@getappz

@getappz getappz commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

The /pm prompt now validates its command argument instead of pasting it into the prompt. All 26 mcp_prompts tests pass, and clippy is clean. The change is committed locally as 3c2444d on task/606-… and not pushed.

The fix (src/mcp_prompts.rs)

  • canonical_pm_command checks the first word against standup|groom|plan|health|portfolio|mode. Each argument slot is checked too: numbers, ~N capacity, rice|wsjf|value-effort, standup|health for portfolio, and on|off for mode.
  • The prompt is rebuilt from the validated pieces only, so standup 007 becomes standup 7. Optional args can be skipped (groom wsjf), but order is enforced.
  • An unknown subcommand, a bad argument, or a bare mode returns the one-line PM_USAGE string. The input is never echoed and pm.md is not embedded.
  • render_pm_prompt was split out of get_pm_command so tests can call it without Debug-escaped output.

Tests

  • I removed the old pm_prompt_substitutes_command_argument and pm_prompt_embeds_mode_off_subcommand tests. The new tests replace them:
    • Every valid subcommand embeds its canonical text and leaves no literal $ARGUMENTS.
    • Unknown subcommands, including an injection string, return exactly PM_USAGE.
    • Invalid args such as mode, mode maybe, standup soon, groom 14 fibonacci and plan 8 return PM_USAGE.
    • One end-to-end test goes through get_prompt.
  • The vacuous-assertion issue is fixed: the tests now assert on the Parse "<canonical>": line from pm.md, which only appears when the argument is substituted.

Commands run: cargo fmt; cargo test --bin agentflare mcp_prompts; cargo clippy --all-targets -- -D warnings -A unsafe_code -A clippy::pedantic.

Concerns

  • The parsing is deliberately strict, so only the forms listed in pm.md work; anything else gets the usage line.
  • I left off the Co-Authored-By trailer, as your global CLAUDE.md rule says, even though the harness reminder asked for one.

Opened by claude-code on flared:c997d745ae66 for item #606 via agentflare.

Summary by CodeRabbit

  • New Features

    • Added canonical /pm command parsing with support for recognized subcommands and ordered numeric, capacity, framework, report, and mode arguments.
    • Valid command inputs are normalized before being included in PM prompts.
  • Bug Fixes

    • Invalid or free-form /pm inputs now return usage guidance without echoing the submitted input.

…ng raw input

Parse the first word against standup|groom|plan|health|portfolio|mode and
re-emit only canonical tokens (numeric/enum args); unknown subcommands or
invalid args return a one-line usage message without echoing the input.

Agentflare-Agent: claude-code
Agentflare-Branch: task/606-pm-mcp-prompt-validate-the-command-argum
Agentflare-Item: 606
Agentflare-Session: fc1d74a0-d97a-47a2-bb12-939245af642d
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: b1828859-30ba-42f7-bed7-d0f0b78ec300

📥 Commits

Reviewing files that changed from the base of the PR and between ac5bb84 and 3c2444d.

📒 Files selected for processing (1)
  • src/mcp_prompts.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The PM prompt path now accepts recognized commands with defined argument formats, normalizes valid input, rejects invalid input with usage text, and renders only canonical commands. Tests cover direct rendering and get_prompt behavior.

Changes

PM command handling

Layer / File(s) Summary
Command canonicalization and rendering
src/mcp_prompts.rs
Supported PM subcommands now enforce argument types and order. Numeric values are normalized, capacity values retain ~, and mode accepts only on or off. Rendering inserts the canonical command into the PM prompt.
Command validation coverage
src/mcp_prompts.rs
Tests now cover valid normalization, invalid and unknown commands, input non-echoing, direct prompt rendering, and usage output through get_prompt.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: validation of the /pm prompt command argument.
Description check ✅ Passed The description explains the change, implementation details, tests, validation rules, and reviewer concerns. It does not use the template headings or explicitly state backwards compatibility, but it i…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@getappz getappz changed the title docs: pm MCP prompt: validate the command argument against the documented subcommands fix(mcp): validate the /pm prompt command argument Sep 21, 2026
@getappz
getappz merged commit 02c11d9 into master Sep 21, 2026
19 checks passed
@getappz
getappz deleted the task/606-pm-mcp-prompt-validate-the-command-argum branch September 21, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant