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

Function tryResolveSymlinkedCommand

src/services/command/commands.ts:102–121  ·  view source on GitHub ↗

* Try to resolve a symlinked command file

(filePath: string)

Source from the content-addressed store, hash-verified

100 * Try to resolve a symlinked command file
101 */
102async function tryResolveSymlinkedCommand(filePath: string): Promise<string | undefined> {
103 try {
104 const lstat = await fs.lstat(filePath)
105 if (lstat.isSymbolicLink()) {
106 // Get the symlink target
107 const linkTarget = await fs.readlink(filePath)
108 // Resolve the target path (relative to the symlink location)
109 const resolvedTarget = path.resolve(path.dirname(filePath), linkTarget)
110
111 // Check if the target is a file
112 const stats = await fs.stat(resolvedTarget)
113 if (stats.isFile()) {
114 return resolvedTarget
115 }
116 }
117 } catch {
118 // Not a symlink or invalid symlink
119 }
120 return undefined
121}
122
123/**
124 * Get all available commands from built-in, global, and project directories

Callers 1

tryLoadCommandFunction · 0.85

Calls 1

statMethod · 0.80

Tested by

no test coverage detected