MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / parseProcsFile

Function parseProcsFile

projects/electron/src/modules/code/procs/parse.ts:50–108  ·  view source on GitHub ↗
(content: string, relativePath: string)

Source from the content-addressed store, hash-verified

48 * @returns Parsed config or error
49 */
50export function parseProcsFile(content: string, relativePath: string): ParseResult {
51 try {
52 // Parse TOML
53 const raw = parseToml(content)
54
55 // Validate with Zod
56 const parsed = ConfigFileSchema.parse(raw)
57
58 // Transform processes (snake_case -> camelCase, add id)
59 const processes: ProcessDef[] = parsed.process.map((proc) => ({
60 id: `${relativePath}::${proc.name}`,
61 name: proc.name,
62 command: proc.command,
63 workDir: proc.work_dir,
64 url: proc.url,
65 type: proc.type,
66 }))
67
68 // Transform crons (snake_case -> camelCase, add id)
69 const crons: CronDef[] = parsed.cron.map((c) => ({
70 id: `${relativePath}::${c.name}`,
71 name: c.name,
72 schedule: c.schedule,
73 type: c.type,
74 prompt: c.prompt,
75 appendSystemPrompt: c.append_system_prompt,
76 images: c.images,
77 isolation: c.isolation,
78 harness: c.harness,
79 inTaskId: c.in_task_id,
80 reuseTask: c.reuse_task,
81 }))
82
83 return { config: { relativePath, processes, crons } }
84 } catch (e) {
85 if (e instanceof z.ZodError) {
86 // Format Zod errors nicely
87 const firstIssue = e.issues[0]
88 const path = firstIssue.path.join(".")
89 return {
90 error: {
91 relativePath,
92 error: `${path}: ${firstIssue.message}`,
93 },
94 }
95 }
96
97 // TOML parse error
98 const msg = e instanceof Error ? e.message : "Invalid TOML"
99 const lineMatch = msg.match(/line (\d+)/i)
100 return {
101 error: {
102 relativePath,
103 error: msg,
104 line: lineMatch ? parseInt(lineMatch[1], 10) : undefined,
105 },
106 }
107 }

Callers 3

readRuntimeProcsFunction · 0.90
parse.test.tsFile · 0.90
parseEditableProcsFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected