Skip to content

Pass --ref and --skill-max-depth through to scan/install subcommands - #64

Merged
lbacik merged 2 commits into
developfrom
fix/issue-63-ref-option
Sep 29, 2026
Merged

lbacik merged 2 commits into
developfrom
fix/issue-63-ref-option

Conversation

@lbacik

@lbacik lbacik commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #63. install <https-url> --ref <sha> and scan --ref <sha> silently ignored --ref and used the remote's default branch HEAD.

The cause: --ref and --skill-max-depth are registered on the root program and on the scan/install subcommands. With Commander's default parsing, the root program took these options even when they came after the subcommand name.

Changes

  • Call program.enablePositionalOptions() so options after a subcommand name reach the subcommand. This also fixes --skill-max-depth on scan/install and --list-length on list, which had the same bug.
  • A root option placed before a subcommand (for example agent-installer --ref X install ...) now fails with an error instead of being silently ignored. The error suggests moving the flag after the subcommand name only when that subcommand accepts it. Interactive mode (agent-installer <url> --ref X) is unchanged.
  • README: explain where these options go.

Tests

The regression tests in tests/cli-json.test.ts run the real CLI against a local two-commit Git repository. url.insteadOf maps that repository to an HTTPS URL, so the tests go through the real clone/fetch path without network access. They check that:

  • install --ref records requestedRef, sets resolvedCommit to the requested commit, and installs that commit's content
  • scan --ref reports the same provenance
  • scan --ref on a local source is rejected
  • --skill-max-depth after scan is applied
  • root options before a subcommand are rejected, including --list-length, and the error never suggests a flag the subcommand does not accept

Verified locally: pnpm typecheck, pnpm test (190 passed), pnpm build, pnpm test:package.

🤖 Generated with Claude Code

lbacik and others added 2 commits September 29, 2026 21:54
Both options are registered on the root program and on the scan/install
subcommands. With Commander's default parsing the root consumed them even
when they followed the subcommand name, so `install <url> --ref <sha>`
silently cloned the default branch HEAD and recorded no requestedRef.

Enable positional options so options after a subcommand name reach the
subcommand, and reject root-level --ref/--skill-max-depth placed before a
subcommand instead of dropping them. Regression tests drive the CLI against
a local Git repository mapped to an HTTPS URL via url.insteadOf.

Fixes #63

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review feedback on the misplaced-option guard: derive the guarded
set from the root's own CLI-sourced options so --list-length is covered
too, and only suggest moving a flag after the subcommand when that
subcommand actually accepts it.

Refs #63

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lbacik
lbacik merged commit c04213a into develop Sep 29, 2026
3 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.

--ref is ignored by install/scan subcommands (always installs default branch HEAD)

1 participant