MCPcopy Index your code
hub / github.com/anomalyco/opencode / load

Function load

packages/opencode/src/config/command.ts:13–39  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

11const decodeInfo = Schema.decodeUnknownExit(ConfigCommandV1.Info)
12
13export async function load(dir: string) {
14 const result: Record<string, ConfigCommandV1.Info> = {}
15 for (const item of await Glob.scan("{command,commands}/**/*.md", {
16 cwd: dir,
17 absolute: true,
18 dot: true,
19 symlink: true,
20 })) {
21 const md = await ConfigMarkdown.parse(item).catch(() => undefined)
22 if (!md) continue
23
24 const name = configEntryNameFromPath(path.relative(dir, item), ["command/", "commands/"])
25
26 const config = {
27 name,
28 ...md.data,
29 template: md.content.trim(),
30 }
31 const parsed = decodeInfo(config, { errors: "all", propertyOrder: "original" })
32 if (Exit.isSuccess(parsed)) {
33 result[config.name] = parsed.value
34 continue
35 }
36 throw new InvalidError({ path: item, message: Cause.pretty(parsed.cause) }, { cause: Cause.squash(parsed.cause) })
37 }
38 return result
39}

Callers

nothing calls this directly

Calls 1

configEntryNameFromPathFunction · 0.90

Tested by

no test coverage detected