Skip to content

fix: preserve literal -- when forwarding args in claude-use run - #23

Merged
Mearman merged 1 commit into
mainfrom
fix/run-passthrough-double-dash
Sep 17, 2026
Merged

Mearman merged 1 commit into
mainfrom
fix/run-passthrough-double-dash

Conversation

@Mearman

@Mearman Mearman commented Sep 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Commander's variadic [args...] argument on the run subcommand strips a literal -- from the forwarded argv, treating it as an end-of-options marker rather than a token to preserve. A command like claude mcp add name -- npx -y pkg reached the real claude binary as mcp add name npx -y pkg, with no -- left to shield -y, which the real binary's own Commander parser then rejected as an unknown option.
  • Add passThroughOptions() to the run subcommand so every token after the first is forwarded verbatim, -- included.
  • Extract the run subcommand's registration into its own src/runCommand.ts module, matching the register*Command pattern every other subcommand (identity, profile, rules, check, configure, doctor, shim) already uses, so this parsing behaviour is unit-testable in isolation without importing cli.ts itself (which runs the real CLI as a top-level side effect on import).

Test plan

  • pnpm test — 807/807 passing, including 3 new regression tests in src/runCommand.test.ts covering: a literal -- preserved, a flag with no -- forwarded unchanged, and an empty args list
  • pnpm typecheck
  • pnpm lint
  • Manually reproduced the bug with a minimal commander script before the fix, confirmed the fix resolves it

Commander's variadic [args...] argument on the run subcommand strips a
literal -- from the forwarded argv by default, treating it purely as
its own end-of-options marker rather than a token to pass through. A
command like `claude mcp add name -- npx -y pkg` therefore reached the
real claude binary as `mcp add name npx -y pkg`, with no -- left to
shield -y from claude's own option parser, which then rejected it as
an unknown option.

Add passThroughOptions() so every token after the first is forwarded
verbatim, -- included. Extract the run subcommand's registration into
its own runCommand.ts module, matching the register*Command pattern
every other subcommand already uses, so this parsing behaviour is
unit-testable without importing cli.ts itself, which runs the real
CLI as a top-level side effect on import.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-17T05:33:05.143034Z 61b460e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit f046c44 into main Sep 17, 2026
31 checks passed
@Mearman
Mearman deleted the fix/run-passthrough-double-dash branch September 17, 2026 05:33
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