Skip to content

ISS-43 - Add Inline Prompt Flag for Axe Run#46

Merged
jrswab merged 2 commits into
masterfrom
041-prompt-flag
Mar 22, 2026
Merged

ISS-43 - Add Inline Prompt Flag for Axe Run#46
jrswab merged 2 commits into
masterfrom
041-prompt-flag

Conversation

@jrswab

@jrswab jrswab commented Mar 21, 2026

Copy link
Copy Markdown
Owner

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/--prompt CLI flag for the run command to provide inline user messages.
  • Documentation section describing User Message Precedence: (1) non-empty -p/--prompt, (2) piped stdin, (3) built-in default message.
  • Tests for prompt flag behavior and precedence (TestRun_PromptFlag).
  • Dry-run test validating prompt flag output (TestRun_DryRun_PromptFlag).

Changed

  • User message resolution logic in cmd/run.go to implement precedence-based selection and pass the resolved user message into dry-run output.
  • Dry-run output format: --- Stdin --- replaced by --- User Message ---, showing the resolved prompt or (default).
  • Verbose debug output: reports prompt source (Prompt: default/flag/stdin) instead of Stdin: yes/no.
  • Test harness: resets the --prompt flag between tests.
  • Smoke tests and golden dry-run fixtures updated to expect --- User Message --- and (default) when appropriate.

- 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
@coderabbitai

coderabbitai Bot commented Mar 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1dbe713-ce8c-4705-bad0-c71f4d6fbb63

📥 Commits

Reviewing files that changed from the base of the PR and between 46b29f1 and eeb56a8.

📒 Files selected for processing (3)
  • cmd/run.go
  • cmd/run_test.go
  • cmd/smoke_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/run.go
  • cmd/smoke_test.go
  • cmd/run_test.go

📝 Walkthrough

Walkthrough

This PR adds a -p/--prompt flag and implements a precedence for the user message (flag → piped stdin → default). Dry-run output and tests were updated to replace the --- Stdin --- section with --- User Message --- and golden fixtures were updated accordingly.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added -p/--prompt flag docs, usage example, and a "User Message Precedence" section describing resolution order and edge cases.
Core Implementation
cmd/run.go
Added --prompt/-p flag handling; resolve userMessage with precedence (flag → stdin → default); pass userMessage into dry-run output and report Prompt: source in verbose mode; replaced --- Stdin --- with --- User Message ---.
Unit & Smoke Tests
cmd/run_test.go, cmd/smoke_test.go
Reset --prompt between tests; added TestRun_PromptFlag and TestRun_DryRun_PromptFlag; updated smoke tests and verbose assertions to expect Prompt: and --- User Message --- with (default) when appropriate.
Golden Fixtures
cmd/testdata/golden/dry-run/basic.txt, .../with_files.txt, .../with_memory.txt, .../with_skill.txt, .../with_subagents.txt, .../with_tools.txt
Updated dry-run golden outputs to replace --- Stdin --- (none) with --- User Message --- (default) across fixtures to match new output format.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🧩 A tiny flag with lots to say,
It jumps the queue and leads the way.
If silent, stdin takes the stage,
Else default whispers from its page.
Dry-run now proclaims the user’s play.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new inline prompt flag (-p/--prompt) to the axe run command, which aligns perfectly with the changeset's primary objective.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 041-prompt-flag

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 --prompt flag, this could be slightly confusing. When -p is 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 httptest mock. Using internal/testutil helpers 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

📥 Commits

Reviewing files that changed from the base of the PR and between ff20b69 and 46b29f1.

⛔ Files ignored due to path filters (2)
  • docs/plans/041_prompt_flag_implement.md is excluded by !docs/**
  • docs/plans/041_prompt_flag_spec.md is excluded by !docs/**
📒 Files selected for processing (10)
  • README.md
  • cmd/run.go
  • cmd/run_test.go
  • cmd/smoke_test.go
  • cmd/testdata/golden/dry-run/basic.txt
  • cmd/testdata/golden/dry-run/with_files.txt
  • cmd/testdata/golden/dry-run/with_memory.txt
  • cmd/testdata/golden/dry-run/with_skill.txt
  • cmd/testdata/golden/dry-run/with_subagents.txt
  • cmd/testdata/golden/dry-run/with_tools.txt

Comment thread cmd/run_test.go
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.
@jrswab jrswab merged commit 52e9d9f into master Mar 22, 2026
4 checks passed
@jrswab jrswab deleted the 041-prompt-flag branch March 22, 2026 02:11
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.

1 participant