MCPcopy Create free account
hub / github.com/arctic-cli/interface / loadCommand

Function loadCommand

packages/arctic/src/config/config.ts:167–202  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

165
166 const COMMAND_GLOB = new Bun.Glob("{command,commands}/**/*.md")
167 async function loadCommand(dir: string) {
168 const result: Record<string, Command> = {}
169 for await (const item of COMMAND_GLOB.scan({
170 absolute: true,
171 followSymlinks: true,
172 dot: true,
173 cwd: dir,
174 })) {
175 const md = await ConfigMarkdown.parse(item)
176 if (!md.data) continue
177
178 const name = (() => {
179 const patterns = ["/.arctic/command/", "/.opencode/command/", "/.opencode/commands/", "/command/", "/commands/"]
180 const pattern = patterns.find((p) => item.includes(p))
181
182 if (pattern) {
183 const index = item.indexOf(pattern)
184 return item.slice(index + pattern.length, -3)
185 }
186 return path.basename(item, ".md")
187 })()
188
189 const config = {
190 name,
191 ...md.data,
192 template: md.content.trim(),
193 }
194 const parsed = Command.safeParse(config)
195 if (parsed.success) {
196 result[config.name] = parsed.data
197 continue
198 }
199 throw new InvalidError({ path: item }, { cause: parsed.error })
200 }
201 return result
202 }
203
204 const AGENT_GLOB = new Bun.Glob("{agent,agents}/**/*.md")
205 async function loadAgent(dir: string) {

Callers 1

config.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected