* Generates a deterministic unique ID for a command suggestion. * Commands with the same name from different sources get unique IDs. * * Only prompt commands can have duplicates (from user settings, project * settings, plugins, etc). Built-in commands (local, local-jsx) are * defined once in co
(cmd: Command)
| 231 | * defined once in code and can't have duplicates. |
| 232 | */ |
| 233 | function getCommandId(cmd: Command): string { |
| 234 | const commandName = getCommandName(cmd) |
| 235 | if (cmd.type === 'prompt') { |
| 236 | // For plugin commands, include the repository to disambiguate |
| 237 | if (cmd.source === 'plugin' && cmd.pluginInfo?.repository) { |
| 238 | return `${commandName}:${cmd.source}:${cmd.pluginInfo.repository}` |
| 239 | } |
| 240 | return `${commandName}:${cmd.source}` |
| 241 | } |
| 242 | // Built-in commands include type as fallback for future-proofing |
| 243 | return `${commandName}:${cmd.type}` |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Checks if a query matches any of the command's aliases. |
no test coverage detected