Skip to content

fix(cli): print per-subcommand help instead of launching the UI#974

Merged
backnotprop merged 2 commits into
mainfrom
fix/964
Jun 26, 2026
Merged

fix(cli): print per-subcommand help instead of launching the UI#974
backnotprop merged 2 commits into
mainfrom
fix/964

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Problem

plannotator review --help launches the review UI instead of printing help. Only top-level --help was handled; for a subcommand, args[0] is the command name, so the invocation fell through to the command branch. In review, parseReviewArgs(["--help"]) treats --help as a non-URL positional → prUrl undefined → local review mode → opens a browser tab.

The real sting (per the issue's follow-up): when Claude Code drives the CLI it runs --help first to probe. That opens a duplicate tab, and closing it injects a bogus "no feedback → proceed" signal into the CC session — wasteful and unpredictable in the agent-driven flow. The same class of bug affected annotate, annotate-last/last, setup-goal, archive, and sessions.

Fix

Handle --help/-h for every user-facing subcommand before any subcommand branch can run — print command-specific usage on stdout and exit 0, so a help probe never starts a server or opens a tab.

  • New helpers in apps/hook/server/cli.ts: hasHelpFlag(), isSubcommandHelpInvocation(), formatSubcommandHelp(), plus a SUBCOMMAND_HELP map and a last → annotate-last alias.
  • isTopLevelHelpInvocation now also accepts -h, and top-level help advertises plannotator <command> --help.
  • Internal bridge modes (opencode-*, copilot-*, improve-context, install-runtime) are intentionally excluded — they're not user-facing.

Testing

  • Unit tests expanded 12 → 20 (apps/hook/server/cli.test.ts): help-flag detection, per-subcommand detection (incl. flag-after-args, the last alias, all six user-facing subcommands), rejection of real invocations (review --git, PR URLs) and internal/unknown subcommands, and the rendered usage text.
  • Verified against a freshly compiled binary:
    • plannotator review --help / -h, annotate --help, sessions --help, last --help → print usage, exit 0, no browser tab.
    • Real plannotator review still launches the server (not intercepted).
    • Top-level --help / --version intact.

Fixes #964

`plannotator review --help` (and other subcommands) fell through to their
command branch because only top-level `--help` was handled. For `review`,
`--help` was parsed as a non-URL positional, dropping into local review
mode and opening a browser tab. When Claude Code probes the CLI with
`--help`, that stray tab's close injects a bogus "no feedback → proceed"
signal into the session.

Handle `--help`/`-h` for every user-facing subcommand (review, annotate,
annotate-last/last, setup-goal, archive, sessions) before any subcommand
branch can run: print command-specific usage on stdout and exit 0. Also
accept `-h` at the top level and advertise per-command help there.

Fixes #964
The top-level help advertises `plannotator <command> --help`, but
`improve-context` (the only internal hook command listed there) had no
help entry, so `improve-context --help` fell through to the hook branch
and emitted additionalContext JSON instead of usage. Add a help entry so
every advertised command responds to --help.
@backnotprop backnotprop merged commit 82acc4b into main Jun 26, 2026
13 checks passed
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.

CLI: plannotator review --help launches the UI instead of printing help

1 participant