From 0dd5d2442005f2ae1cf80c96e0df9e2694a7b738 Mon Sep 17 00:00:00 2001 From: Ryan Ouyang Date: Fri, 5 Jun 2026 14:36:45 -0700 Subject: [PATCH] fix: avoid duplicate group prefix in scoped --llms output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `--llms`/`--llms-full` is scoped to a command group, the prefix was applied twice — once via `scopedName` and again via `collectSkillCommands`, producing signatures like `cli auth auth login` instead of `cli auth login`. Pass an empty prefix to `collectSkillCommands` in the scoped markdown paths so command names stay relative to the already-prefixed `scopedName`, matching the unscoped and JSON/YAML manifest behavior. Co-Authored-By: Claude Opus 4.8 (1M context) --- .changeset/scoped-llms-duplicate-prefix.md | 7 +++++++ src/Cli.test.ts | 7 +++++-- src/Cli.ts | 8 ++++++-- src/e2e.test.ts | 12 ++++++------ 4 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 .changeset/scoped-llms-duplicate-prefix.md diff --git a/.changeset/scoped-llms-duplicate-prefix.md b/.changeset/scoped-llms-duplicate-prefix.md new file mode 100644 index 0000000..685c876 --- /dev/null +++ b/.changeset/scoped-llms-duplicate-prefix.md @@ -0,0 +1,7 @@ +--- +'incur': patch +--- + +Fixed `--llms` and `--llms-full` markdown output when scoped to a command group (e.g. `cli auth --llms`) to no longer duplicate the group prefix in command signatures (`cli auth auth login` → `cli auth login`). + +The scoped name already carries the prefix, so command collection now runs with an empty prefix to match the unscoped and JSON/YAML manifest output. diff --git a/src/Cli.test.ts b/src/Cli.test.ts index bd55fc6..6d6df34 100644 --- a/src/Cli.test.ts +++ b/src/Cli.test.ts @@ -1385,8 +1385,11 @@ describe('--llms', () => { cli.command('ping', { description: 'Health check', run: () => ({}) }) const { output } = await serve(cli, ['auth', '--llms']) - expect(output).toContain('test auth auth login') - expect(output).toContain('test auth auth logout') + expect(output).toContain('test auth login') + expect(output).toContain('test auth logout') + // The scoped prefix must not be duplicated in the command signature. + expect(output).not.toContain('test auth auth login') + expect(output).not.toContain('test auth auth logout') expect(output).not.toContain('ping') }) diff --git a/src/Cli.ts b/src/Cli.ts index d8efef9..11d932b 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -634,7 +634,9 @@ async function serveImpl( if (llmsFull) { if (!formatExplicit || formatFlag === 'md') { const groups = new Map() - const cmds = collectSkillCommands(scopedCommands, prefix, groups, scopedRoot) + // Command names are relative to the scope; `scopedName` already carries + // the prefix, so pass `[]` to avoid prepending it twice. + const cmds = collectSkillCommands(scopedCommands, [], groups, scopedRoot) const scopedName = prefix.length > 0 ? `${name} ${prefix.join(' ')}` : name writeln(Skill.generate(scopedName, cmds, groups)) return @@ -645,7 +647,9 @@ async function serveImpl( if (!formatExplicit || formatFlag === 'md') { const groups = new Map() - const cmds = collectSkillCommands(scopedCommands, prefix, groups, scopedRoot) + // Command names are relative to the scope; `scopedName` already carries + // the prefix, so pass `[]` to avoid prepending it twice. + const cmds = collectSkillCommands(scopedCommands, [], groups, scopedRoot) const scopedName = prefix.length > 0 ? `${name} ${prefix.join(' ')}` : name writeln(Skill.index(scopedName, cmds, scopedDescription)) return diff --git a/src/e2e.test.ts b/src/e2e.test.ts index 61bbb4d..a9432ff 100644 --- a/src/e2e.test.ts +++ b/src/e2e.test.ts @@ -1513,9 +1513,9 @@ describe('--llms', () => { | Command | Description | |---------|-------------| - | \`app auth auth login\` | Log in to the service | - | \`app auth auth logout\` | Log out of the service | - | \`app auth auth status\` | Show authentication status | + | \`app auth login\` | Log in to the service | + | \`app auth logout\` | Log out of the service | + | \`app auth status\` | Show authentication status | Run \`app auth --llms-full\` for full manifest. Run \`app auth --schema\` for argument details. " @@ -1531,9 +1531,9 @@ describe('--llms', () => { | Command | Description | |---------|-------------| - | \`app project deploy project deploy create \` | Create a deployment | - | \`app project deploy project deploy rollback \` | Rollback a deployment | - | \`app project deploy project deploy status \` | Check deployment status | + | \`app project deploy create \` | Create a deployment | + | \`app project deploy rollback \` | Rollback a deployment | + | \`app project deploy status \` | Check deployment status | Run \`app project deploy --llms-full\` for full manifest. Run \`app project deploy --schema\` for argument details. "