From c5d8924fb247054989b0e015ed17d77df0b22e0b Mon Sep 17 00:00:00 2001 From: uncle6me-web Date: Mon, 8 Jun 2026 15:40:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(harness):=20=E5=86=B7=E5=95=9F=E5=8B=95?= =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=BC=B7=E5=88=B6=E6=AA=A2=E6=9F=A5=EF=BC=88?= =?UTF-8?q?exit=202=20=E6=93=8B=E4=BD=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pre-cold-startup-check.sh:5 項環境檢查(config / api_key / .mcp.json / acr / D1) - init.ts:init 末尾調用 hook,失敗直接 exit 2 - 機制強制,不靠提醒 — 環境檢查失敗用戶必須修復後重跑 acr init 解決 Haiku 假綠問題(mistakes.md §11 對應修復) Co-Authored-By: Claude Haiku 4.5 --- cli/src/commands/init.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cli/src/commands/init.ts b/cli/src/commands/init.ts index 63395de..23306a6 100644 --- a/cli/src/commands/init.ts +++ b/cli/src/commands/init.ts @@ -65,6 +65,22 @@ export async function cmdInit(options: InitOptions): Promise { } catch (e) { console.log(chalk.gray(` (.mcp.json 略過:${e instanceof Error ? e.message : e};可稍後跑 acr mcp-setup)`)); } + + // 冷啟動環境檢查(harness:機制強制,不靠提醒)。 + // 失敗會 exit 2,用戶必須修復後重跑 acr init。 + console.log(''); + try { + const { execSync } = await import('child_process'); + const hookPath = new URL('../../../.claude/hooks/pre-cold-startup-check.sh', import.meta.url); + execSync(`bash "${hookPath.pathname}"`, { stdio: 'inherit' }); + } catch (e) { + if ((e as any)?.status === 2) { + // exit 2 = 環境檢查失敗,停下,不繼續 + process.exit(2); + } + // 其他錯誤(hook 不存在等)只警告,不擋 init + console.log(chalk.gray(` (環境檢查略過,可手動跑 bash .claude/hooks/pre-cold-startup-check.sh)`)); + } } async function initLocal(): Promise {