diff --git a/workflows/coding.mjs b/workflows/coding.mjs index f5aa7a5..3f2ee84 100644 --- a/workflows/coding.mjs +++ b/workflows/coding.mjs @@ -174,7 +174,9 @@ const ACTION_RESULT_SCHEMA = { type:'object', additionalProperties:false, error:{type:'string'}, detail:{type:'string'} } } -const ROOT = args?.projectRoot || '.' +// 兼容 harness 把 args 以 JSON 字符串(而非对象)传入的情况。 +const ARGS = typeof args === 'string' ? (() => { try { return JSON.parse(args) } catch { return undefined } })() : args +const ROOT = ARGS?.projectRoot || '.' // ROOT 必须是绝对路径——相对 '.' 会绑定到子代理隐式 cwd,无保证。 if (ROOT === '.' || !(/^(?:\/|[A-Za-z]:[\\/])/.test(ROOT))) { throw new Error(`HALT invalid-projectRoot: must be absolute, got ${JSON.stringify(ROOT)}. coding-start 必须把绝对路径传入 args.projectRoot。`)