Why
packages/core/src/git.ts (worktreeRun, refusal classification) decides whether a refused git worktree remove requires --force by regex-matching hardcoded English prose against git's localized human-readable stderr. On this macOS host (Homebrew git 2.55.0 shipping a zh_CN translation catalog, LANG/LC_MESSAGES=zh_CN.UTF-8 inherited by the child process), git refuses with 致命错误:'…' 包含修改或未跟踪的文件,使用 --force 删除; the regex misses and clients receive forceRequired: false for a dirty worktree — wrong safety/remediation metadata. Proven by a single-variable reproduction matrix (same binary/fixture, locale flip → classification flip; LC_ALL=C and Apple git without catalog both classify correctly). Machine-readable worktree list --porcelain output is byte-identical across locales (cmp clean), making it the stable seam.
Scope
packages/core/src/git.ts — refusal classification only.
packages/core/test/project-copy.test.ts — regression coverage for tracked + untracked dirtiness.
- No change to the
force: true removal path; no gate weakened; clean-worktree removal unchanged.
Approach
Recompute forceRequired in worktreeRun from locale-stable signals only: operation === "remove" + refusal exit code 128 + dirtiness of the target worktree confirmed via porcelain output. The localized stderr prose is removed from classification entirely.
Acceptance
ProjectCopy > requires force to remove a dirty git worktree passes on a machine where the old code failed (ambient zh_CN locale), with regressions independently covering tracked-file and untracked-file dirtiness.
- Full Core suite, typecheck, and lint green on macOS.
forceRequired: true contract intact: dirty worktree still reported as requiring force; clean worktree still removes without force.
Why
packages/core/src/git.ts(worktreeRun, refusal classification) decides whether a refusedgit worktree removerequires--forceby regex-matching hardcoded English prose against git's localized human-readable stderr. On this macOS host (Homebrew git 2.55.0 shipping a zh_CN translation catalog,LANG/LC_MESSAGES=zh_CN.UTF-8inherited by the child process), git refuses with致命错误:'…' 包含修改或未跟踪的文件,使用 --force 删除; the regex misses and clients receiveforceRequired: falsefor a dirty worktree — wrong safety/remediation metadata. Proven by a single-variable reproduction matrix (same binary/fixture, locale flip → classification flip;LC_ALL=Cand Apple git without catalog both classify correctly). Machine-readableworktree list --porcelainoutput is byte-identical across locales (cmpclean), making it the stable seam.Scope
packages/core/src/git.ts— refusal classification only.packages/core/test/project-copy.test.ts— regression coverage for tracked + untracked dirtiness.force: trueremoval path; no gate weakened; clean-worktree removal unchanged.Approach
Recompute
forceRequiredinworktreeRunfrom locale-stable signals only:operation === "remove"+ refusal exit code 128 + dirtiness of the target worktree confirmed via porcelain output. The localized stderr prose is removed from classification entirely.Acceptance
ProjectCopy > requires force to remove a dirty git worktreepasses on a machine where the old code failed (ambient zh_CN locale), with regressions independently covering tracked-file and untracked-file dirtiness.forceRequired: truecontract intact: dirty worktree still reported as requiring force; clean worktree still removes without force.