Commit c5af5b277ad513425a9302195de4bc088eddf85c
1 parent
3d084808
coding.mjs: tolerate args arriving as a JSON string (harness passes Workflow args stringified)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Showing
1 changed file
with
3 additions
and
1 deletions
workflows/coding.mjs
| @@ -174,7 +174,9 @@ const ACTION_RESULT_SCHEMA = { type:'object', additionalProperties:false, | @@ -174,7 +174,9 @@ const ACTION_RESULT_SCHEMA = { type:'object', additionalProperties:false, | ||
| 174 | error:{type:'string'}, | 174 | error:{type:'string'}, |
| 175 | detail:{type:'string'} } } | 175 | detail:{type:'string'} } } |
| 176 | 176 | ||
| 177 | -const ROOT = args?.projectRoot || '.' | 177 | +// 兼容 harness 把 args 以 JSON 字符串(而非对象)传入的情况。 |
| 178 | +const ARGS = typeof args === 'string' ? (() => { try { return JSON.parse(args) } catch { return undefined } })() : args | ||
| 179 | +const ROOT = ARGS?.projectRoot || '.' | ||
| 178 | // ROOT 必须是绝对路径——相对 '.' 会绑定到子代理隐式 cwd,无保证。 | 180 | // ROOT 必须是绝对路径——相对 '.' 会绑定到子代理隐式 cwd,无保证。 |
| 179 | if (ROOT === '.' || !(/^(?:\/|[A-Za-z]:[\\/])/.test(ROOT))) { | 181 | if (ROOT === '.' || !(/^(?:\/|[A-Za-z]:[\\/])/.test(ROOT))) { |
| 180 | throw new Error(`HALT invalid-projectRoot: must be absolute, got ${JSON.stringify(ROOT)}. coding-start 必须把绝对路径传入 args.projectRoot。`) | 182 | throw new Error(`HALT invalid-projectRoot: must be absolute, got ${JSON.stringify(ROOT)}. coding-start 必须把绝对路径传入 args.projectRoot。`) |