From c5af5b277ad513425a9302195de4bc088eddf85c Mon Sep 17 00:00:00 2001 From: yanghl Date: Thu, 4 Jun 2026 17:44:00 +0800 Subject: [PATCH] coding.mjs: tolerate args arriving as a JSON string (harness passes Workflow args stringified) --- workflows/coding.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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。`) -- libgit2 0.22.2