Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,9 @@ 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')
expect(output).not.toContain('test auth auth') // no doubled namespace
expect(output).not.toContain('ping')
})
})
Expand Down Expand Up @@ -3326,7 +3327,9 @@ test('--llms scoped to group', async () => {
const { output } = await serve(cli, ['--llms-full', '--format', 'json', 'pr'])
const manifest = JSON.parse(output)
expect(manifest.commands).toHaveLength(2)
expect(manifest.commands.every((c: any) => c.name.startsWith('pr '))).toBe(true)
// When scoped to a group, command names should NOT include the group prefix
// (the scope context already establishes it)
expect(manifest.commands.map((c: any) => c.name).sort()).toEqual(['create', 'list'])
})

test('--help on root with rootCommand shows command help with subcommands', async () => {
Expand Down
14 changes: 10 additions & 4 deletions src/Cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,26 +587,32 @@ async function serveImpl(
}
}

// When scoped into a subtree, prefix has already been consumed to narrow
// scopedCommands and is captured in scopedName. Passing it again to the
// collect helpers would double the group segment in command names
// (e.g. "cli auth auth login" instead of "cli auth login").
const collectPrefix = prefix.length > 0 ? [] as string[] : prefix

if (llmsFull) {
if (!formatExplicit || formatFlag === 'md') {
const groups = new Map<string, string>()
const cmds = collectSkillCommands(scopedCommands, prefix, groups)
const cmds = collectSkillCommands(scopedCommands, collectPrefix, groups)
const scopedName = prefix.length > 0 ? `${name} ${prefix.join(' ')}` : name
writeln(Skill.generate(scopedName, cmds, groups))
return
}
writeln(Formatter.format(buildManifest(scopedCommands, prefix), formatFlag))
writeln(Formatter.format(buildManifest(scopedCommands, collectPrefix), formatFlag))
return
}

if (!formatExplicit || formatFlag === 'md') {
const groups = new Map<string, string>()
const cmds = collectSkillCommands(scopedCommands, prefix, groups)
const cmds = collectSkillCommands(scopedCommands, collectPrefix, groups)
const scopedName = prefix.length > 0 ? `${name} ${prefix.join(' ')}` : name
writeln(Skill.index(scopedName, cmds, scopedDescription))
return
}
writeln(Formatter.format(buildIndexManifest(scopedCommands, prefix), formatFlag))
writeln(Formatter.format(buildIndexManifest(scopedCommands, collectPrefix), formatFlag))
return
}

Expand Down
32 changes: 16 additions & 16 deletions src/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,9 @@ describe('--llms-full', () => {
const names = json(output).commands.map((c: any) => c.name)
expect(names).toMatchInlineSnapshot(`
[
"auth login",
"auth logout",
"auth status",
"login",
"logout",
"status",
]
`)
})
Expand All @@ -1266,9 +1266,9 @@ describe('--llms-full', () => {
const names = json(output).commands.map((c: any) => c.name)
expect(names).toMatchInlineSnapshot(`
[
"project deploy create",
"project deploy rollback",
"project deploy status",
"create",
"rollback",
"status",
]
`)
})
Expand Down Expand Up @@ -1300,15 +1300,15 @@ describe('--llms-full', () => {
'--format',
'json',
])
const deployCreate = json(output).commands.find((c: any) => c.name === 'project deploy create')
const deployCreate = json(output).commands.find((c: any) => c.name === 'create')
expect(deployCreate.examples).toMatchInlineSnapshot(`
[
{
"command": "project deploy create staging",
"command": "create staging",
"description": "Deploy staging from main",
},
{
"command": "project deploy create production --branch release --dryRun true",
"command": "create production --branch release --dryRun true",
"description": "Dry run a production deploy",
},
]
Expand Down Expand Up @@ -1495,9 +1495,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 <command> --schema\` for argument details.
"
Expand All @@ -1513,9 +1513,9 @@ describe('--llms', () => {

| Command | Description |
|---------|-------------|
| \`app project deploy project deploy create <env>\` | Create a deployment |
| \`app project deploy project deploy rollback <deployId>\` | Rollback a deployment |
| \`app project deploy project deploy status <deployId>\` | Check deployment status |
| \`app project deploy create <env>\` | Create a deployment |
| \`app project deploy rollback <deployId>\` | Rollback a deployment |
| \`app project deploy status <deployId>\` | Check deployment status |

Run \`app project deploy --llms-full\` for full manifest. Run \`app project deploy <command> --schema\` for argument details.
"
Expand Down Expand Up @@ -1941,7 +1941,7 @@ describe('env', () => {

test('--llms-full json includes schema.env', async () => {
const { output } = await serve(createApp(), ['auth', '--llms-full', '--format', 'json'])
const login = json(output).commands.find((c: any) => c.name === 'auth login')
const login = json(output).commands.find((c: any) => c.name === 'login')
expect(login.schema.env.properties).toMatchInlineSnapshot(`
{
"AUTH_HOST": {
Expand Down