Repository navigation
feat(cli): improve slash command discovery #3736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b33c6a1
feat(cli): improve slash command discovery
LaZzyMan 11fd64f
merge main into slash command phase3
LaZzyMan b11b29e
test(cli): update input prompt completion expectations
LaZzyMan 050f0fe
merge main branch
LaZzyMan c8331ba
fix(cli): address review feedback on slash command phase 3
LaZzyMan 1712d94
test(cli): add missing test coverage for slash completion
LaZzyMan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Qwen | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type { CommandSource, SlashCommand } from '../ui/commands/types.js'; | ||
| import { getEffectiveSupportedModes } from './commandUtils.js'; | ||
|
|
||
| export type CommandSourceGroup = { | ||
| key: 'built-in' | 'bundled-skill' | 'custom' | 'plugin' | 'mcp' | 'other'; | ||
| title: string; | ||
| order: number; | ||
| }; | ||
|
|
||
| export function getCommandSourceBadge( | ||
| command: Pick<SlashCommand, 'source' | 'sourceLabel'>, | ||
| ): string | null { | ||
| switch (command.source) { | ||
| case 'bundled-skill': | ||
| return '[Skill]'; | ||
| case 'skill-dir-command': | ||
| if (command.sourceLabel === 'User') return '[User]'; | ||
| if (command.sourceLabel === 'Project') return '[Project]'; | ||
| return '[Custom]'; | ||
| case 'plugin-command': | ||
| return command.sourceLabel?.startsWith('Extension:') | ||
| ? '[Extension]' | ||
| : '[Plugin]'; | ||
| case 'mcp-prompt': | ||
| return '[MCP]'; | ||
| case 'builtin-command': | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| export function getCommandSourceGroup( | ||
| command: Pick<SlashCommand, 'source'>, | ||
| ): CommandSourceGroup { | ||
| switch (command.source) { | ||
| case 'builtin-command': | ||
| return { key: 'built-in', title: 'Built-in Commands', order: 0 }; | ||
| case 'bundled-skill': | ||
| return { key: 'bundled-skill', title: 'Bundled Skills', order: 1 }; | ||
| case 'skill-dir-command': | ||
| return { key: 'custom', title: 'Custom Commands', order: 2 }; | ||
| case 'plugin-command': | ||
| return { key: 'plugin', title: 'Plugin Commands', order: 3 }; | ||
| case 'mcp-prompt': | ||
| return { key: 'mcp', title: 'MCP Commands', order: 4 }; | ||
| default: | ||
| return { key: 'other', title: 'Other Commands', order: 5 }; | ||
| } | ||
| } | ||
|
|
||
| export function formatSupportedModes(command: SlashCommand): string { | ||
| const modes = getEffectiveSupportedModes(command); | ||
| const hasInteractive = modes.includes('interactive'); | ||
| const hasNonInteractive = modes.includes('non_interactive'); | ||
| const hasAcp = modes.includes('acp'); | ||
|
|
||
| if (hasInteractive && hasNonInteractive && hasAcp) { | ||
| return '[all]'; | ||
| } | ||
|
|
||
| if (!hasInteractive && hasNonInteractive && hasAcp) { | ||
| return '[headless]'; | ||
| } | ||
|
|
||
| if (hasInteractive && !hasNonInteractive && !hasAcp) { | ||
| return '[interactive]'; | ||
| } | ||
|
|
||
| return modes | ||
| .map((mode) => { | ||
| switch (mode) { | ||
| case 'interactive': | ||
| return '[i]'; | ||
| case 'non_interactive': | ||
| return '[ni]'; | ||
| case 'acp': | ||
| return '[acp]'; | ||
| default: | ||
| return `[${mode}]`; | ||
| } | ||
| }) | ||
| .join(' '); | ||
| } | ||
|
|
||
| export function getCommandDisplayName( | ||
| command: Pick<SlashCommand, 'name' | 'altNames'>, | ||
| options: { | ||
| prefix?: string; | ||
| matchedAlias?: string; | ||
| includeAliases?: boolean; | ||
| } = {}, | ||
| ): string { | ||
| const prefix = options.prefix ?? ''; | ||
| const baseLabel = `${prefix}${command.name}`; | ||
|
|
||
| if (options.matchedAlias) { | ||
| return `${baseLabel} (alias: ${options.matchedAlias})`; | ||
| } | ||
|
|
||
| if (options.includeAliases === false) { | ||
| return baseLabel; | ||
| } | ||
|
|
||
| const altNames = command.altNames?.filter(Boolean); | ||
| if (!altNames || altNames.length === 0) { | ||
| return baseLabel; | ||
| } | ||
|
|
||
| return `${baseLabel} (${altNames.join(', ')})`; | ||
| } | ||
|
|
||
| export function getCommandSubcommandNames(command: SlashCommand): string[] { | ||
| return ( | ||
| command.subCommands | ||
| ?.filter((subCommand) => !subCommand.hidden) | ||
| .map((subCommand) => subCommand.name) ?? [] | ||
| ); | ||
| } | ||
|
|
||
| export function formatCommandSourceLabel( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] — DeepSeek/deepseek-v4-pro via Qwen Code /review |
||
| command: Pick<SlashCommand, 'source' | 'sourceLabel'>, | ||
| ): string { | ||
| if (command.sourceLabel) { | ||
| return command.sourceLabel; | ||
| } | ||
|
|
||
| const fallbackLabels: Record<CommandSource, string> = { | ||
| 'builtin-command': 'Built-in', | ||
| 'bundled-skill': 'Skill', | ||
| 'skill-dir-command': 'Custom', | ||
| 'plugin-command': 'Plugin', | ||
| 'mcp-prompt': 'MCP', | ||
| }; | ||
|
|
||
| return command.source ? fallbackLabels[command.source] : 'Unknown'; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical] This replaces PR #3618's
acceptsInputlogic with a simplecmd.argumentHintcheck, causing a functional regression in ACP mode.Commands with
subCommandsbut noargumentHint(e.g.,/memory) will getinput: nulland auto-submit before the user can choose a subcommand. The same applies to commands withcompletionfunctions.— deepseek-v4-pro via Qwen Code /review