MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getCommandId

Function getCommandId

src/utils/suggestions/commandSuggestions.ts:233–244  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

231 * defined once in code and can't have duplicates.
232 */
233function 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.

Callers 2

Calls 1

getCommandNameFunction · 0.50

Tested by

no test coverage detected