(dir: string)
| 32 | } |
| 33 | |
| 34 | export 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 | } |
nothing calls this directly
no test coverage detected