ISS-43 - Add Inline Prompt Flag for Axe Run#46
Conversation
- Register -p/--prompt StringP flag in cmd/run.go init() - Implement three-branch user message precedence: -p flag > piped stdin > default - Move user message resolution before dry-run check so dry-run reflects actual message - Update printDryRun to show '--- User Message ---' instead of '--- Stdin ---' - Show '(default)' when no prompt or stdin provided, actual message otherwise - Update resetRunCmd to clear prompt flag between tests - Add TestRun_PromptFlag with 6 table-driven cases covering all R9 requirements - Add TestRun_DryRun_PromptFlag verifying dry-run output with -p flag - Update smoke tests to use '--- User Message ---' and '(default)' labels - Update all dry-run golden files to reflect new label - Update README with -p flag in Run Flags table and User Message Precedence section - Update implementation plan 041 with all tasks checked off Closes #43
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
cmd/run.go (1)
377-385: Consider updating verbose output to reflect prompt source.The verbose output still shows
Stdin: yes/no(line 385), but now that we have a--promptflag, this could be slightly confusing. When-pis used, it might be clearer to show where the user message actually came from.That said, this is pretty minor since verbose output goes to stderr and doesn't affect piped output. Feel free to defer if you'd like to keep this change focused.
💡 Optional enhancement for verbose clarity
- stdinDisplay := "no" - if strings.TrimSpace(stdinContent) != "" { - stdinDisplay = "yes" - } + var msgSourceDisplay string + if strings.TrimSpace(promptFlag) != "" { + msgSourceDisplay = "-p flag" + } else if strings.TrimSpace(stdinContent) != "" { + msgSourceDisplay = "stdin" + } else { + msgSourceDisplay = "default" + } _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Model: %s/%s\n", provName, modelName) _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Workdir: %s\n", workdir) _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Skill: %s\n", skillDisplay) _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Files: %d file(s)\n", len(files)) - _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Stdin: %s\n", stdinDisplay) + _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Message: %s\n", msgSourceDisplay)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/run.go` around lines 377 - 385, Update the verbose output to show the actual prompt source instead of only "Stdin: yes/no": compute a promptSource string (e.g., "flag" when the --prompt/-p flag was used, "stdin" when strings.TrimSpace(stdinContent) != "" and no flag, or "none"/"files" as appropriate) and replace the current stdinDisplay usage in the fmt.Fprintf call so the line prints something like "Prompt: <promptSource>" while keeping the existing lines that print provName, modelName, workdir, skillDisplay, and files; use the existing symbols stdinContent, stdinDisplay (or replace it), provName, modelName, workdir, skillDisplay, and files to locate and update the code.cmd/smoke_test.go (1)
283-292: Consider extracting User Message section parsing into a tiny helper.The section-slicing logic is duplicated and could get brittle if message content contains
---. A shared helper would make these tests easier to maintain (and less puzzle-like at 2am).Also applies to: 371-380
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/smoke_test.go` around lines 283 - 292, The section-slicing logic around userMsgIdx/afterUserMsg/userMsgSection is duplicated and brittle; extract a small helper (e.g., extractSection(stdout string, header string) string) used by both occurrences to locate the header ("--- User Message ---"), return the section up to the next "---" or the remainder, and replace the inline slicing in the test with calls to that helper; ensure the helper trims/returns exactly the same substring semantics as the current code so existing assertions need no change.cmd/run_test.go (1)
2928-2944: Prefer testutil mock helpers over ad-hoc HTTP mocks here.This new test spins up a manual
httptestmock. Usinginternal/testutilhelpers would reduce boilerplate and align test style across the suite.As per coding guidelines "No mocks in tests when avoidable — use the real thing or testutil helpers instead".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/run_test.go` around lines 2928 - 2944, Replace the ad-hoc httptest.NewServer usage in the test (the server variable, the inline http.HandlerFunc, and receivedBody capture) with the internal/testutil HTTP mock helper used across the repo: create a testutil mock server that returns the same JSON response, sets Content-Type and status 200, and exposes a way to capture the request body (replace uses of server and receivedBody with the helper's equivalents), and ensure you call the helper's Close/Teardown in defer; keep the response payload, headers and captured request body behavior identical to preserve test assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/run_test.go`:
- Around line 2972-2974: The test currently only asserts that tc.expectedMessage
appears in receivedBody, allowing both sources to be present; add a negative
assertion for the losing source in precedence cases by extending the test case
(e.g., add tc.unexpectedMessage) and after the existing contains check add: if
tc.unexpectedMessage != "" { if strings.Contains(receivedBody,
tc.unexpectedMessage) { t.Errorf("expected request body NOT to contain %q when
precedence applies, got %q", tc.unexpectedMessage, receivedBody) } } so tests
that specify precedence fail when the losing source also appears; place this
directly after the current expectedMessage assertion in the test in
cmd/run_test.go.
---
Nitpick comments:
In `@cmd/run_test.go`:
- Around line 2928-2944: Replace the ad-hoc httptest.NewServer usage in the test
(the server variable, the inline http.HandlerFunc, and receivedBody capture)
with the internal/testutil HTTP mock helper used across the repo: create a
testutil mock server that returns the same JSON response, sets Content-Type and
status 200, and exposes a way to capture the request body (replace uses of
server and receivedBody with the helper's equivalents), and ensure you call the
helper's Close/Teardown in defer; keep the response payload, headers and
captured request body behavior identical to preserve test assertions.
In `@cmd/run.go`:
- Around line 377-385: Update the verbose output to show the actual prompt
source instead of only "Stdin: yes/no": compute a promptSource string (e.g.,
"flag" when the --prompt/-p flag was used, "stdin" when
strings.TrimSpace(stdinContent) != "" and no flag, or "none"/"files" as
appropriate) and replace the current stdinDisplay usage in the fmt.Fprintf call
so the line prints something like "Prompt: <promptSource>" while keeping the
existing lines that print provName, modelName, workdir, skillDisplay, and files;
use the existing symbols stdinContent, stdinDisplay (or replace it), provName,
modelName, workdir, skillDisplay, and files to locate and update the code.
In `@cmd/smoke_test.go`:
- Around line 283-292: The section-slicing logic around
userMsgIdx/afterUserMsg/userMsgSection is duplicated and brittle; extract a
small helper (e.g., extractSection(stdout string, header string) string) used by
both occurrences to locate the header ("--- User Message ---"), return the
section up to the next "---" or the remainder, and replace the inline slicing in
the test with calls to that helper; ensure the helper trims/returns exactly the
same substring semantics as the current code so existing assertions need no
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 764be0b6-537d-4a8a-9e45-83481ad69513
⛔ Files ignored due to path filters (2)
docs/plans/041_prompt_flag_implement.mdis excluded by!docs/**docs/plans/041_prompt_flag_spec.mdis excluded by!docs/**
📒 Files selected for processing (10)
README.mdcmd/run.gocmd/run_test.gocmd/smoke_test.gocmd/testdata/golden/dry-run/basic.txtcmd/testdata/golden/dry-run/with_files.txtcmd/testdata/golden/dry-run/with_memory.txtcmd/testdata/golden/dry-run/with_skill.txtcmd/testdata/golden/dry-run/with_subagents.txtcmd/testdata/golden/dry-run/with_tools.txt
Add negative assertions to TestRun_PromptFlag for precedence cases using unexpectedMessage field to verify losing source is absent. Update verbose output to show prompt source (flag/stdin/default) instead of the now-misleading Stdin yes/no indicator. Extract extractSection helper in smoke_test.go to deduplicate the section-slicing logic between TestSmoke_RunDryRun and TestSmoke_PipedStdinInDryRun.
Summary
Adds a new -p/--prompt flag to axe run so users can supply an inline user message. The command now resolves the user message with clear precedence: a non-empty/non-whitespace -p/--prompt value, otherwise piped stdin, otherwise a built-in default. Dry-run output and related tests/golden fixtures were updated to surface the resolved "User Message" (or "(default)") instead of the previous "Stdin" section.
Changelog
Added
-p/--promptCLI flag for theruncommand to provide inline user messages.-p/--prompt, (2) piped stdin, (3) built-in default message.TestRun_PromptFlag).TestRun_DryRun_PromptFlag).Changed
--- Stdin ---replaced by--- User Message ---, showing the resolved prompt or(default).Prompt: default/flag/stdin) instead ofStdin: yes/no.--promptflag between tests.--- User Message ---and(default)when appropriate.