MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getCommands

Function getCommands

src/services/command/commands.ts:127–145  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

125 * Priority order: project > global > built-in (later sources override earlier ones)
126 */
127export async function getCommands(cwd: string): Promise<Command[]> {
128 const commands = new Map<string, Command>()
129
130 // Add built-in commands first (lowest priority)
131 const builtInCommands = await getBuiltInCommands()
132 for (const command of builtInCommands) {
133 commands.set(command.name, command)
134 }
135
136 // Scan global commands (override built-in)
137 const globalDir = path.join(getGlobalRooDirectory(), "commands")
138 await scanCommandDirectory(globalDir, "global", commands)
139
140 // Scan project commands (highest priority - override both global and built-in)
141 const projectDir = path.join(getProjectRooDirectoryForCwd(cwd), "commands")
142 await scanCommandDirectory(projectDir, "project", commands)
143
144 return Array.from(commands.values())
145}
146
147/**
148 * Get a specific command by name (optimized to avoid scanning all commands)

Callers 8

commands.spec.tsFile · 0.90
constructorMethod · 0.90
getCommandNamesFunction · 0.70
getDiscoveredCommandsFunction · 0.50
webviewMessageHandlerFunction · 0.50

Calls 6

getBuiltInCommandsFunction · 0.90
getGlobalRooDirectoryFunction · 0.90
scanCommandDirectoryFunction · 0.85
fromMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected