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

Function getCommand

src/services/command/commands.ts:151–170  ·  view source on GitHub ↗
(cwd: string, name: string)

Source from the content-addressed store, hash-verified

149 * Priority order: project > global > built-in
150 */
151export async function getCommand(cwd: string, name: string): Promise<Command | undefined> {
152 // Try to find the command directly without scanning all commands
153 const projectDir = path.join(getProjectRooDirectoryForCwd(cwd), "commands")
154 const globalDir = path.join(getGlobalRooDirectory(), "commands")
155
156 // Check project directory first (highest priority)
157 const projectCommand = await tryLoadCommand(projectDir, name, "project")
158 if (projectCommand) {
159 return projectCommand
160 }
161
162 // Check global directory if not found in project
163 const globalCommand = await tryLoadCommand(globalDir, name, "global")
164 if (globalCommand) {
165 return globalCommand
166 }
167
168 // Check built-in commands if not found in project or global (lowest priority)
169 return await getBuiltInCommand(name)
170}
171
172/**
173 * Try to load a specific command from a directory (supports symlinks)

Calls 4

getGlobalRooDirectoryFunction · 0.90
getBuiltInCommandFunction · 0.90
tryLoadCommandFunction · 0.85

Tested by

no test coverage detected