Skip to content

fix: auto-select language when doc has only one variant#182

Open
mvanhorn wants to merge 1 commit intoandrewyng:mainfrom
mvanhorn:fix/49-auto-select-single-language
Open

fix: auto-select language when doc has only one variant#182
mvanhorn wants to merge 1 commit intoandrewyng:mainfrom
mvanhorn:fix/49-auto-select-single-language

Conversation

@mvanhorn
Copy link
Copy Markdown

What

When a doc entry has only one language variant, resolveDocPath() now auto-selects it instead of requiring --lang. Multi-language docs still prompt for language selection as before.

Why

The MCP tool description for chub_get already documents this behavior (server.js line 57: "Auto-selected if only one"), but it was never implemented. Most docs in the registry have only one language variant, making the common case unnecessarily verbose.

Before:

chub get stripe/api --lang python   # required even though python is the only option

After:

chub get stripe/api                 # auto-selects python (the only variant)
chub get stripe/api --lang python   # still works explicitly

Fixes #49

Testing

  • npm test - all 232 tests pass
  • chub build content/ --validate-only - 1553 docs, 7 skills validated
  • New unit test covers single-language auto-selection
  • Updated e2e test to verify auto-selection works end-to-end
  • Existing multi-language tests continue to pass (no behavior change for multi-lang docs)

Notes

  • 3 files changed, 18 insertions, 3 deletions
  • The fix is a 2-line else if branch in resolveDocPath() in cli/src/lib/registry.js
  • Backward compatible - explicit --lang still works for all entries

When a doc entry has only one language variant, resolveDocPath() now
auto-selects it instead of requiring --lang. This matches the behavior
already documented in the MCP tool description ("Auto-selected if only
one"). Multi-language docs still prompt for language selection.

Fixes andrewyng#49

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Make "chub get" version-aware for the agent environment

1 participant