Skip to content

fix: --llms scoped to group doubles namespace in command names#95

Open
eduwass wants to merge 1 commit intowevm:mainfrom
eduwass:fix/llms-scoped-namespace-duplication
Open

fix: --llms scoped to group doubles namespace in command names#95
eduwass wants to merge 1 commit intowevm:mainfrom
eduwass:fix/llms-scoped-namespace-duplication

Conversation

@eduwass
Copy link
Copy Markdown

@eduwass eduwass commented Mar 26, 2026

Problem

When using --llms (or --llms-full) scoped to a command group, the group segment is duplicated in command names:

$ my-cli auth --llms

Expected:

| `my-cli auth login` | Log in |
| `my-cli auth logout` | Log out |

Actual:

| `my-cli auth auth login` | Log in |
| `my-cli auth auth logout` | Log out |

This affects all output formats (md, json, yaml) for both --llms and --llms-full.

With nested groups the duplication compounds — e.g. app project deploy project deploy create instead of app project deploy create.

Cause

In Cli.ts, the scoping loop (lines 572–588) narrows scopedCommands to the sub-group and accumulates consumed tokens into prefix. The prefix is then correctly used to build scopedName (e.g. "my-cli auth"), but it's also passed to the collect helper functions (collectSkillCommands, buildManifest, buildIndexManifest), which prepend it again to each command name.

Fix

Pass an empty [] prefix to the collect helpers when scoped, since scopedName already carries the group path for display purposes. One-line change plus test updates.

Reproduction

import { Cli } from 'incur'

const cli = Cli.create('test')
const auth = Cli.create('auth', { description: 'Authentication' })
auth.command('login', { description: 'Log in', run: () => ({}) })
auth.command('logout', { description: 'Log out', run: () => ({}) })
cli.command(auth)

// Root: correct
await cli.serve(['--llms'])
// → `test auth login`, `test auth logout` ✅

// Scoped: before fix → `test auth auth login` ❌
// Scoped: after fix  → `test auth login` ✅
await cli.serve(['auth', '--llms'])

Test changes

All 815 tests pass. Updated 6 inline snapshots and 2 assertions in Cli.test.ts and e2e.test.ts that were asserting the buggy doubled-namespace behavior.

When running `cli group --llms`, the `prefix` array was passed both to
build `scopedName` (e.g. "cli group") AND to the collect helper functions
which also prepend it to each command name. This caused output like:

  `cli group group login` instead of `cli group login`

The fix passes an empty prefix to collect helpers when scoped, since
`scopedName` already carries the group path for display.

Affects --llms, --llms-full in md/json/yaml formats.
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