Peach: Local-first video metadata scraper and media manager.
fix(tooling): 钩子输出钉住 UTF-8,该发一版了只由钩子说
longmeidao3e31d44fc1c1
diff --git a/.claude/settings.json b/.claude/settings.jsonindex d2b17f7eb..63a15fd34 100644--- a/.claude/settings.json+++ b/.claude/settings.json@@ -7,10 +7,10 @@},"hooks": {"Stop": [{"hooks": [- {"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "args": ["${CLAUDE_PROJECT_DIR}/scripts/job_status.py", "--write", "--hook-event"], "timeout": 30},- {"type": "command", "command": "uv", "args": ["run", "--no-project", "python", "${CLAUDE_PROJECT_DIR}/scripts/release_due.py", "--hook-event"], "timeout": 30}+ {"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "args": ["-X", "utf8", "${CLAUDE_PROJECT_DIR}/scripts/job_status.py", "--write", "--hook-event"], "timeout": 30},+ {"type": "command", "command": "uv", "args": ["run", "--no-project", "python", "-X", "utf8", "${CLAUDE_PROJECT_DIR}/scripts/release_due.py", "--hook-event"], "timeout": 30}]}],- "StopFailure": [{"hooks": [{"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "args": ["${CLAUDE_PROJECT_DIR}/scripts/job_status.py", "--write", "--hook-event"], "timeout": 30}]}],- "SessionEnd": [{"hooks": [{"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "args": ["${CLAUDE_PROJECT_DIR}/scripts/job_status.py", "--write", "--hook-event"], "timeout": 30}]}]+ "StopFailure": [{"hooks": [{"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "args": ["-X", "utf8", "${CLAUDE_PROJECT_DIR}/scripts/job_status.py", "--write", "--hook-event"], "timeout": 30}]}],+ "SessionEnd": [{"hooks": [{"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "args": ["-X", "utf8", "${CLAUDE_PROJECT_DIR}/scripts/job_status.py", "--write", "--hook-event"], "timeout": 30}]}]}}diff --git a/.claude/skills/peach-worktree/SKILL.md b/.claude/skills/peach-worktree/SKILL.mdindex e1f27300b..2ae150410 100644--- a/.claude/skills/peach-worktree/SKILL.md+++ b/.claude/skills/peach-worktree/SKILL.md@@ -34,9 +34,10 @@ description: 在用户说并行、工作树、暂存、提交、ready、集成它是唯一入口。`--bump auto --apply` 推版本、定版变更日志并把那一节带在输出里给人确认,确认后 `--ship --apply` 一次做完提交、推送、等 Test 转绿、打标签(ADR-0012 修订)。人只判断措辞,不记流程;停在半路就再跑一次同一条命令。- `integrate` 的输出带一个 `release` 字段(`changelog.due()`):`due` 为真就在收尾那段- 照 `why` 告诉用户该发一版了,别等他问。判据是每周一次、攒够提前、破坏性变化与安全- 修复不等周期,只数使用者看得见的条目——一百个重构提交对他们是零。+ 「该发一版了」由 `release_due.py` 的 Stop 钩子一家说,收尾那段不要跟着说第二遍:+ `integrate` 输出里的 `release`(`changelog.due()`)与它同一个判据,而钩子按 master 的 sha+ 闩住、集成后的干净主检出正好满足它那四道闸,两边都说就是一屏里两条一样的话。判据是+ 每周一次、攒够提前、破坏性变化与安全修复不等周期,只数使用者看得见的条目。CI 分片、系统覆盖与发布复用见 `docs/TESTING.md`;合并完成不机械追加全量。耗时和慢测试记录在主目录 `build/agent-verification/`。记录和锁约束统一入口,不是权限隔离;直接 Git 或篡改记录仍可绕过,不能宣称绝对防绕过。diff --git a/.codex/hooks.json b/.codex/hooks.jsonindex 685ff121a..033edd924 100644--- a/.codex/hooks.json+++ b/.codex/hooks.json@@ -1,7 +1,7 @@{"hooks": {"Stop": [{"hooks": [- {"type": "command", "command": "uv run --no-project python scripts/release_due.py --hook-event", "timeout": 30}+ {"type": "command", "command": "uv run --no-project python -X utf8 scripts/release_due.py --hook-event", "timeout": 30}]}]}}diff --git a/tests/test_job_status.py b/tests/test_job_status.pyindex f7dc66d91..116fa3c97 100644--- a/tests/test_job_status.py+++ b/tests/test_job_status.py@@ -40,6 +40,14 @@ class JobStatusTests(unittest.TestCase):}self.assertEqual(commands,{"${CLAUDE_PROJECT_DIR}/.venv/Scripts/python.exe", "uv"})+ # 每条都带 `-X utf8`:这几个脚本打的都是中文,而 Windows 上解释器的输出端+ # 默认落在 gbk,读的一端按 UTF-8 解,屏幕上就只剩命令名和数字认得出来。+ for event in settings["hooks"].values():+ for matcher in event:+ for hook in matcher["hooks"]:+ args = hook.get("args", [])+ self.assertIn("-X", args, hook)+ self.assertEqual(args[args.index("-X") + 1], "utf8", hook)result = subprocess.run([sys.executable, str(SCRIPT), "--help"],cwd=SCRIPT.parents[1],diff --git a/tests/test_release_due.py b/tests/test_release_due.pyindex 52d36fe86..75001bdc5 100644--- a/tests/test_release_due.py+++ b/tests/test_release_due.py@@ -225,6 +225,31 @@ class WiringTests(unittest.TestCase):for platform_only in (".venv/Scripts", ".venv\\Scripts", ".venv/bin"):self.assertNotIn(platform_only, line)+ def test_the_reminder_comes_out_as_utf8_whatever_the_console_codepage_is(self):+ """这句话经配置里那条命令出来必须是 UTF-8 字节。++ `uv run --no-project python` 拿的是系统解释器,它在这台 Windows 上把+ `sys.stdout.encoding` 定成 `gbk`:`systemMessage` 里的中文按 GBK 编出去,+ 读的一端按 UTF-8 解,屏幕上只有命令名和数字还认得出来,正文是一片乱码。+ 这条提醒的全部价值就在那一句话本身,读不出来等于没说。`-X utf8` 把输出端+ 钉死,和测试入口固定 `PYTHONIOENCODING` 是同一条。++ 解释器那一段照配置原样取出来跑一遍:只比对 `-X utf8` 写在不写在,认不出+ 「写了却没生效」,而这里要的正是出来的字节。+ """+ claude = self.called_by_argv(self.claude_stop_argv())+ codex = self.called_by(self.codex_stop_commands()).split()+ for argv in (claude, codex):+ script = next(i for i, part in enumerate(argv) if "release_due.py" in part)+ self.assertIn("-X", argv[:script], argv)+ self.assertEqual(argv[argv.index("-X") + 1], "utf8", argv)+ interpreter = claude[:next(i for i, part in enumerate(claude)+ if "release_due.py" in part)]+ spoken = subprocess.run([*interpreter, "-c", "print('该发下一版了')"],+ cwd=str(self.ROOT), capture_output=True, check=False)+ self.assertEqual(spoken.returncode, 0, spoken.stderr)+ self.assertEqual(spoken.stdout.strip(), "该发下一版了".encode("utf-8"))+def test_the_configured_command_runs_without_leaving_a_venv_behind(self):"""把配置里那条命令原样跑一遍,落在一个装成项目的空目录里。