Skip to content

fix(main): honour --agent flag when intercepting --help for schema output#130

Merged
platinummonkey merged 1 commit intomainfrom
fix/agent-flag-help-output
Feb 27, 2026
Merged

fix(main): honour --agent flag when intercepting --help for schema output#130
platinummonkey merged 1 commit intomainfrom
fix/agent-flag-help-output

Conversation

@platinummonkey
Copy link
Collaborator

Summary

pup --agent --help was outputting human-readable clap help instead of the JSON schema. The --help intercept in main_inner() fires before Cli::parse(), so the --agent CLI flag was invisible to useragent::is_agent_mode() (which only reads env vars). The fix also checks for --agent in the raw args list.

Changes

  • src/main.rs:4834 — scan raw args for --agent before Cli::parse() runs, so the agent-mode help intercept fires when --agent is present, matching FORCE_AGENT_MODE=1 pup --help behaviour

Testing

  • pup --agent --help now produces JSON schema output
  • diff <(pup --agent --help) <(FORCE_AGENT_MODE=1 pup --help) returns no differences
  • All 307 unit tests pass (cargo test)

🤖 Generated with Claude Code

…tput

The help interception in main_inner() checked useragent::is_agent_mode()
which only reads environment variables (FORCE_AGENT_MODE, CLAUDECODE, etc.).
Because Cli::parse() hasn't run yet at that point, the --agent CLI flag
was never visible, so `pup --agent --help` fell through to the normal
human-readable clap help instead of the JSON schema.

Fix: also detect --agent in the raw args list before parsing, so the
intercept fires whenever --agent is present, matching the behaviour of
FORCE_AGENT_MODE=1 pup --help.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@platinummonkey platinummonkey merged commit 4a31a49 into main Feb 27, 2026
6 checks passed
@platinummonkey platinummonkey deleted the fix/agent-flag-help-output branch February 27, 2026 16:30
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