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

Function loadMode

packages/opencode/src/config/agent.ts:34–59  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

32}
33
34export async function loadMode(dir: string) {
35 const result: Record<string, ConfigAgentV1.Info> = {}
36 for (const item of await Glob.scan("{mode,modes}/*.md", {
37 cwd: dir,
38 absolute: true,
39 dot: true,
40 symlink: true,
41 })) {
42 const md = await ConfigMarkdown.parse(item).catch(() => undefined)
43 if (!md) continue
44
45 const config = {
46 name: configEntryNameFromPath(path.relative(dir, item), ["mode/", "modes/"]),
47 ...md.data,
48 prompt: md.content.trim(),
49 }
50 const parsed = Schema.decodeUnknownExit(ConfigAgentV1.Info)(config, { errors: "all", propertyOrder: "original" })
51 if (Exit.isSuccess(parsed)) {
52 result[config.name] = {
53 ...parsed.value,
54 mode: "primary" as const,
55 }
56 }
57 }
58 return result
59}

Callers

nothing calls this directly

Calls 1

configEntryNameFromPathFunction · 0.90

Tested by

no test coverage detected