The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Record Harness's own Codex hooks as reviewed (#1127)
Dee6b5332adaf64
diff --git a/cli/src/engines/__fixtures__/hook-installers.golden.json b/cli/src/engines/__fixtures__/hook-installers.golden.jsonindex e09cecf96..c002152c3 100644--- a/cli/src/engines/__fixtures__/hook-installers.golden.json+++ b/cli/src/engines/__fixtures__/hook-installers.golden.json@@ -1386,7 +1386,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1402,6 +1403,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1414,7 +1420,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1430,6 +1437,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1581,14 +1593,14 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed"],"threw": null},{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed"],"threw": null}@@ -1656,7 +1668,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1672,6 +1685,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1684,14 +1702,14 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed"],"threw": null},{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed"],"threw": null}@@ -1713,7 +1731,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1729,6 +1748,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1741,7 +1765,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1757,6 +1782,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1769,7 +1799,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1785,6 +1816,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:4:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1819,7 +1855,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1835,6 +1872,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1847,7 +1889,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1863,6 +1906,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1875,7 +1923,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1891,6 +1940,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1903,7 +1957,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1919,6 +1974,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1931,7 +1991,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1947,6 +2008,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1958,7 +2024,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -1974,6 +2041,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -1985,7 +2057,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2001,6 +2074,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2012,7 +2090,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2028,6 +2107,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2039,7 +2123,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2055,6 +2140,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn timeout 30>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn timeout 30>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2067,7 +2157,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2083,6 +2174,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2095,7 +2191,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2111,6 +2208,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2123,7 +2225,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2139,6 +2242,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2151,7 +2259,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2167,6 +2276,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2179,7 +2293,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2195,6 +2310,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2207,7 +2327,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2223,6 +2344,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2235,7 +2361,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2251,6 +2378,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2267,7 +2399,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2283,6 +2416,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "link","target": "<root>/elsewhere/real.json"@@ -2299,7 +2437,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2315,6 +2454,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2327,7 +2471,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2343,6 +2488,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2355,7 +2505,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2371,6 +2522,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2382,7 +2538,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2398,6 +2555,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "444",@@ -2488,7 +2650,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2504,6 +2667,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "644",@@ -2544,7 +2712,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/moved/codex-work/config.toml"],"threw": null},@@ -2560,6 +2729,11 @@"type": "dir","mode": "755"},+ "moved/codex-work/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/moved/codex-work/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 installIn>\"\n\n[hooks.state.\"<root>/moved/codex-work/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 installIn>\"\n"+ },"moved/codex-work/hooks.json": {"type": "file","mode": "600",@@ -2572,7 +2746,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/home/.codex/config.toml"],"threw": null},@@ -2588,6 +2763,11 @@"type": "dir","mode": "755"},+ "home/.codex/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/home/.codex/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 install>\"\n\n[hooks.state.\"<root>/home/.codex/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 install>\"\n"+ },"home/.codex/hooks.json": {"type": "file","mode": "644",@@ -2600,7 +2780,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/home/.codex/config.toml"],"threw": null},@@ -2616,6 +2797,11 @@"type": "dir","mode": "755"},+ "home/.codex/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/home/.codex/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 install>\"\n\n[hooks.state.\"<root>/home/.codex/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 install>\"\n"+ },"home/.codex/hooks.json": {"type": "file","mode": "644",@@ -2657,7 +2843,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/home/.codex/config.toml"],"threw": null},@@ -2673,6 +2860,11 @@"type": "dir","mode": "755"},+ "home/.codex/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/home/.codex/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 install>\"\n\n[hooks.state.\"<root>/home/.codex/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 install>\"\n"+ },"home/.codex/hooks.json": {"type": "file","mode": "644",@@ -2685,7 +2877,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/home/.codex/config.toml"],"threw": null},@@ -2701,6 +2894,11 @@"type": "dir","mode": "755"},+ "home/.codex/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/home/.codex/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 install>\"\n\n[hooks.state.\"<root>/home/.codex/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 install>\"\n"+ },"home/.codex/hooks.json": {"type": "file","mode": "644",@@ -2712,7 +2910,8 @@"runs": [{"logs": [- "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/home/.codex/config.toml"],"threw": null},@@ -2728,6 +2927,11 @@"type": "dir","mode": "755"},+ "home/.codex/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/home/.codex/hooks.json:session_start:0:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 install>\"\n\n[hooks.state.\"<root>/home/.codex/hooks.json:user_prompt_submit:0:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 install>\"\n"+ },"home/.codex/hooks.json": {"type": "file","mode": "644",@@ -2740,7 +2944,8 @@{"logs": ["log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",- "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"+ "log [hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed",+ "log [hooks] recorded Harness's own Codex hooks as reviewed → <root>/home/.codex/config.toml"],"threw": null},@@ -2756,6 +2961,11 @@"type": "dir","mode": "755"},+ "home/.codex/config.toml": {+ "type": "file",+ "mode": "600",+ "text": "[hooks.state.\"<root>/home/.codex/hooks.json:session_start:1:0\"]\ntrusted_hash = \"<hash SessionStart command codex 19473 install>\"\n\n[hooks.state.\"<root>/home/.codex/hooks.json:user_prompt_submit:1:0\"]\ntrusted_hash = \"<hash UserPromptSubmit command codex 19473 install>\"\n"+ },"home/.codex/hooks.json": {"type": "file","mode": "644",diff --git a/cli/src/engines/codex/hookContract.ts b/cli/src/engines/codex/hookContract.tsindex c542b6fbf..f7ee1afdf 100644--- a/cli/src/engines/codex/hookContract.ts+++ b/cli/src/engines/codex/hookContract.ts@@ -22,10 +22,28 @@ export const hooks: HookContract = {messages: {current: '[hooks] Codex SessionStart/UserPromptSubmit hooks already installed → {file}',installed: '[hooks] installed Codex SessionStart/UserPromptSubmit hooks → {file}',- after: '[hooks] Codex requires reviewing these user hooks with /hooks before normal use',+ after: '[hooks] Codex asks to review hooks it has not seen; Harness records its own as reviewed',failed: '[hooks] failed to write Codex hooks.json:',malformed: ['[hooks] Codex hooks file is invalid JSON; leaving it unchanged: {file}', '[hooks] fix the file, then restart harness login'],},+ // Codex 0.162 asks a person to review every hook it has not seen ("Hooks need review"), Harness's own+ // among them, in the first Codex pane: a fresh Mac with real Codex and Claude Code, 2026-10-09. Picked+ // "Continue without trusting", Harness's hooks never run and its Codex sessions lose their turns and+ // questions. The answer for Harness's own two is recorded as Codex records it ("Trust all"): matched+ // against `codex app-server` `hooks/list` of codex-cli 0.162.0 (engines/kit/hookReview.spec.ts). Any other+ // hook is still asked about. A Codex that hashes differently asks about these again, as before.+ reviewed: {+ file: 'config.toml',+ table: 'hooks.state',+ key: 'trusted_hash',+ events: { SessionStart: 'session_start', UserPromptSubmit: 'user_prompt_submit' },+ matcherEvents: ['SessionStart'],+ defaultTimeout: 600,+ messages: {+ recorded: "[hooks] recorded Harness's own Codex hooks as reviewed → {config}",+ skipped: "[hooks] {config} defines hooks.state in a form Harness does not edit; Codex will ask to review Harness's hooks",+ },+ },},// A delegated session (a Codex sub-agent) runs its hooks from its parent's pane, and its rollout's first// record names it a child (`source.subagent`). Registered, it would take the parent's pane and transcript,diff --git a/cli/src/engines/facets/hooks.ts b/cli/src/engines/facets/hooks.tsindex 17cf98cb8..41d75f4f4 100644--- a/cli/src/engines/facets/hooks.ts+++ b/cli/src/engines/facets/hooks.ts@@ -78,6 +78,33 @@ export interface HookSettings {/** The lines for an unreadable file that is kept. */malformed?: readonly string[]}+ /**+ * Where the engine asks a person to review a hook before it first runs, Harness's own blocks recorded as+ * reviewed, the way the engine records the answer itself (kit/hookReview.ts).+ */+ reviewed?: HookReviewRecord+}++/**+ * An engine's record of hooks a person reviewed: in its config file in the same home, a table per hook keyed+ * `<real path of the settings file>:<event>:<block>:<hook>`, holding the hash the engine computes of that hook+ * (Codex 0.162 `hooks.state`, `trusted_hash`). A hook whose hash differs from the recorded one is asked about again.+ */+export interface HookReviewRecord {+ /** The engine's config file, in the settings' home. */+ file: string+ /** The TOML table the records are sub-tables of. */+ table: string+ /** The field of a record that holds the hash. */+ key: string+ /** The engine's name for each declared event, in keys and in the hash. */+ events: Readonly<Record<string, string>>+ /** The events whose matcher is part of the hash; the engine ignores the others'. */+ matcherEvents: readonly string[]+ /** The timeout, in seconds, the engine assumes for a hook that names none. */+ defaultTimeout: number+ /** The daemon's log lines, with {config} filled in. */+ messages: { recorded: string; skipped: string }}/** A session another session delegated to, told apart by its transcript's first record. */diff --git a/cli/src/engines/hookInstallers.golden.spec.ts b/cli/src/engines/hookInstallers.golden.spec.tsindex 42ac08bf7..ad566dc79 100644--- a/cli/src/engines/hookInstallers.golden.spec.ts+++ b/cli/src/engines/hookInstallers.golden.spec.ts@@ -10,7 +10,7 @@* `RECORD_HOOK_GOLDEN=1` writes the fixture. Record it again only for a change meant to alter what lands* in an engine's settings, and say so in that change.*/-import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'+import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { dirname, join, relative } from 'node:path'import { fileURLToPath } from 'node:url'@@ -303,7 +303,18 @@ beforeAll(async () => {}// Longest first: Claude Code's command is the start of Codex's, and every command contains the folders below.commands.sort(([a], [b]) => b.length - a.length)- tokens = [...commands, [notify.HOOK_SCRIPT, '<script>'], [process.execPath, '<node>'], [root, '<root>'], [`.${process.pid}.`, '.<pid>.']]+ // Codex's review records hash a command, which names this machine's folders: each known one by its command.+ const { reviewHash } = await import('./kit/hookReview.js')+ const { hooks: codex } = await import('./codex/hookContract.js')+ const hashes: Array<[string, string]> = []+ for (const [cmd, token] of commands.filter(([, token]) => token.startsWith('<command codex'))) {+ for (const { event, matcher } of EVENTS.codex) {+ // 30: the case that finds Harness's hook current with a timeout of its own, recorded as the file has it.+ for (const timeout of [5, 30]) hashes.push([reviewHash(codex.settings.reviewed!, event, matcher, { command: cmd, timeout }), `<hash ${event} ${token.slice(1, -1)}${timeout === 5 ? '' : ` timeout ${timeout}`}>`])+ }+ }+ // The real path first: on macOS the temporary folder is reached through /var, and Codex keys by /private/var.+ tokens = [...hashes, ...commands, [notify.HOOK_SCRIPT, '<script>'], [process.execPath, '<node>'], [realpathSync(root), '<root>'], [root, '<root>'], [`.${process.pid}.`, '.<pid>.']]})afterAll(() => {diff --git a/cli/src/engines/kit/folderTrust.ts b/cli/src/engines/kit/folderTrust.tsindex 12d3bf3cd..9235252d4 100644--- a/cli/src/engines/kit/folderTrust.ts+++ b/cli/src/engines/kit/folderTrust.ts@@ -36,7 +36,7 @@ function isPlainObject(value: unknown): value is Record<string, unknown> {* `~/.codex/config.toml` as links into a repo; renaming a temporary file over the link itself would* swap it for a plain file and quietly detach the person's dotfiles.*/-function replaceConfigFile(file: string, text: string): void {+export function replaceConfigFile(file: string, text: string): void {const target = realpathSync(file)const tmp = `${target}.harness-${process.pid}.tmp`writeFileSync(tmp, text, { mode: 0o600 })diff --git a/cli/src/engines/kit/hookReview.spec.ts b/cli/src/engines/kit/hookReview.spec.tsnew file mode 100644index 000000000..ca5728cdd--- /dev/null+++ b/cli/src/engines/kit/hookReview.spec.ts@@ -0,0 +1,184 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import { existsSync, lstatSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { hooks } from '../codex/hookContract.js'+import { installHookSettings } from './hookSettings.js'+import { recordReviewed, reviewHash, reviewRecords, withReviewRecords } from './hookReview.js'++const record = hooks.settings.reviewed!+const roots: string[] = []+afterEach(() => {+ vi.restoreAllMocks()+ for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })+})+const home = (): string => {+ const root = realpathSync(mkdtempSync(join(tmpdir(), 'hook-review-')))+ roots.push(root)+ return root+}++// What `codex app-server` `hooks/list` of codex-cli 0.162.0 reported as `currentHash` for a hooks.json with+// these two blocks (2026-10-09). Harness's hash must be Codex's, or Codex asks about the hooks anyway.+const COMMAND = "'/opt/harness/runtime/node' '/home/person/.harness/cli/hook/notify.mjs' 18473 codex"+const CODEX_0_162 = {+ session_start: 'sha256:7d719f8e2849620d0d2d81085877e79793c61d8b46ee15cc6251d2e0c69a1b41',+ user_prompt_submit: 'sha256:2aeba9ad1676fa3124e519bbcbb7602380bae087ba5345ce604bb12f5bb76199',+}++describe('Harness’s own Codex hooks, recorded as reviewed', () => {+ it('hashes a hook exactly as codex-cli 0.162.0 does', () => {+ expect(reviewHash(record, 'SessionStart', 'startup|resume|clear|compact', { command: COMMAND, timeout: 5 })).toBe(CODEX_0_162.session_start)+ // Codex ignores a UserPromptSubmit matcher, so it is not part of the hash either.+ expect(reviewHash(record, 'UserPromptSubmit', 'anything', { command: COMMAND, timeout: 5 })).toBe(CODEX_0_162.user_prompt_submit)+ expect(reviewHash(record, 'UserPromptSubmit', undefined, { command: COMMAND })).not.toBe(CODEX_0_162.user_prompt_submit)+ expect(reviewHash(record, 'UserPromptSubmit', undefined, { command: COMMAND })).toBe(reviewHash(record, 'UserPromptSubmit', undefined, { command: COMMAND, timeout: 600 }))+ })++ it('keys only Harness’s blocks, at their place in the file, past the person’s own', () => {+ const settings = { hooks: {+ SessionStart: [{ matcher: 'mine', hooks: [{ type: 'command', command: 'echo theirs' }] }, { matcher: 'startup|resume|clear|compact', hooks: [{ type: 'command', command: COMMAND, timeout: 5 }] }],+ UserPromptSubmit: [{ hooks: [{ type: 'command', command: COMMAND, timeout: 5 }] }],+ Stop: [{ hooks: [{ type: 'command', command: COMMAND }] }],+ } }+ expect([...reviewRecords(record, '/home/person/.codex/hooks.json', settings)]).toEqual([+ ['/home/person/.codex/hooks.json:session_start:1:0', CODEX_0_162.session_start],+ ['/home/person/.codex/hooks.json:user_prompt_submit:0:0', CODEX_0_162.user_prompt_submit],+ ])+ })++ it('installs the hooks and records them, so Codex runs them without asking; a second start changes nothing', () => {+ const codexHome = home()+ vi.spyOn(console, 'log').mockImplementation(() => {})+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ const installed = JSON.parse(readFileSync(join(codexHome, 'hooks.json'), 'utf8'))+ const config = readFileSync(join(codexHome, 'config.toml'), 'utf8')+ for (const [key, hash] of reviewRecords(record, join(codexHome, 'hooks.json'), installed)) {+ expect(config).toContain(`[hooks.state.${JSON.stringify(key)}]\ntrusted_hash = ${JSON.stringify(hash)}\n`)+ }+ expect(lstatSync(join(codexHome, 'config.toml')).mode & 0o777).toBe(0o600)+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ expect(readFileSync(join(codexHome, 'config.toml'), 'utf8')).toBe(config)+ })++ it('records them for hooks an earlier start installed, and again when Harness’s command changes', () => {+ const codexHome = home()+ vi.spyOn(console, 'log').mockImplementation(() => {})+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ writeFileSync(join(codexHome, 'config.toml'), 'model = "gpt-6"\n')+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ const first = readFileSync(join(codexHome, 'config.toml'), 'utf8')+ expect(first.startsWith('model = "gpt-6"\n\n[hooks.state.')).toBe(true)+ // Another port: another command, so another hash, in the same tables.+ installHookSettings('codex', hooks.settings, 18999, codexHome)+ const second = readFileSync(join(codexHome, 'config.toml'), 'utf8')+ expect(second.match(/^\[hooks\.state\./gm)).toHaveLength(2)+ expect(second).not.toBe(first)+ const installed = JSON.parse(readFileSync(join(codexHome, 'hooks.json'), 'utf8'))+ for (const [, hash] of reviewRecords(record, join(codexHome, 'hooks.json'), installed)) expect(second).toContain(hash)+ })++ it('keeps what Codex wrote itself: its empty table, the person’s other records, a record already right', () => {+ const records = new Map([['/h/hooks.json:session_start:0:0', 'sha256:new']])+ const codex = '[hooks.state]\n\n[hooks.state."/h/hooks.json:stop:0:0"]\ntrusted_hash = "sha256:theirs"\n'+ expect(withReviewRecords(codex, record, records)).toBe(`${codex}\n[hooks.state."/h/hooks.json:session_start:0:0"]\ntrusted_hash = "sha256:new"\n`)+ const stale = '[hooks.state."/h/hooks.json:session_start:0:0"]\nenabled = true\ntrusted_hash = "sha256:old"\n\n[other]\nx = 1\n'+ expect(withReviewRecords(stale, record, records)).toBe(stale.replace('sha256:old', 'sha256:new'))+ expect(withReviewRecords(stale.replace('sha256:old', 'sha256:new'), record, records)).toBe('unchanged')+ const noHash = "[hooks.state.'/h/hooks.json:session_start:0:0']\nenabled = true\n"+ expect(withReviewRecords(noHash, record, records)).toBe("[hooks.state.'/h/hooks.json:session_start:0:0']\ntrusted_hash = \"sha256:new\"\nenabled = true\n")+ })++ it('reads a config’s structure past what only looks like it: strings, CRLF, comments', () => {+ const records = new Map([['/h/hooks.json:session_start:0:0', 'sha256:new']])+ const prompt = 'instructions = """\n[hooks.state."/h/hooks.json:session_start:0:0"]\ntrusted_hash = "x"\n"""\n'+ expect(withReviewRecords(prompt, record, records)).toBe(`${prompt}\n[hooks.state."/h/hooks.json:session_start:0:0"]\ntrusted_hash = "sha256:new"\n`)+ const crlf = '[hooks.state."/h/hooks.json:session_start:0:0"] # Codex\r\ntrusted_hash = "sha256:old" # was\r\n'+ expect(withReviewRecords(crlf, record, records)).toBe(crlf.replace('sha256:old', 'sha256:new'))+ })++ it('records what hooks.json holds on disk: a block of the person’s before Harness’s, another timeout', () => {+ const codexHome = home()+ vi.spyOn(console, 'log').mockImplementation(() => {})+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ const installed = JSON.parse(readFileSync(join(codexHome, 'hooks.json'), 'utf8'))+ // Harness's block first, the person's added after it, and a timeout of their own: current, so not rewritten.+ installed.hooks.UserPromptSubmit = [{ hooks: [{ ...installed.hooks.UserPromptSubmit[0].hooks[0], timeout: 30 }] }, { hooks: [{ type: 'command', command: 'echo theirs' }] }]+ writeFileSync(join(codexHome, 'hooks.json'), JSON.stringify(installed))+ rmSync(join(codexHome, 'config.toml'))+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ expect(readFileSync(join(codexHome, 'hooks.json'), 'utf8')).toBe(JSON.stringify(installed))+ const config = readFileSync(join(codexHome, 'config.toml'), 'utf8')+ const hook = installed.hooks.UserPromptSubmit[0].hooks[0]+ expect(config).toContain(`[hooks.state.${JSON.stringify(`${codexHome}/hooks.json:user_prompt_submit:0:0`)}]\ntrusted_hash = ${JSON.stringify(reviewHash(record, 'UserPromptSubmit', undefined, hook))}\n`)+ expect(config).not.toContain('user_prompt_submit:1:0')+ })++ it('records nothing for hooks that never reached the file', () => {+ const codexHome = home()+ writeFileSync(join(codexHome, 'hooks.json'), '[]\n')+ vi.spyOn(console, 'log').mockImplementation(() => {})+ recordReviewed(record, codexHome, join(codexHome, 'hooks.json'))+ expect(existsSync(join(codexHome, 'config.toml'))).toBe(false)+ })++ it('leaves a config alone that defines the table in a form an appended table could collide with', () => {+ const records = new Map([['/h/hooks.json:session_start:0:0', 'sha256:new']])+ for (const text of [+ 'hooks = { state = {} }\n',+ 'hooks.state."/h/hooks.json:session_start:0:0".trusted_hash = "x"\n',+ '[hooks]\nstate = {}\n',+ '[hooks.state]\n"/h/hooks.json:session_start:0:0" = { trusted_hash = "x" }\n',+ '[hooks.state."/h/hooks.json:session_start:0:0"]\nx = 1\n\n[hooks.state."/h/hooks.json:session_start:0:0"]\ny = 1\n',+ // Spelled with quotes, it is the same table.+ '["hooks"]\nstate = {}\n',+ '"hooks" = {}\n',+ '[hooks."state"."/h/hooks.json:session_start:0:0"]\nx = 1\n\n[hooks.state."/h/hooks.json:session_start:0:0"]\ny = 1\n',+ // A line of an array is not a header: the root key after it is still in the root table.+ 'paths = [\n["a"]\n]\nhooks = {}\n',+ '\uFEFFhooks = {}\n',+ // A record this does not read: a second key beside it would not parse.+ '[hooks.state."/h/hooks.json:session_start:0:0"]\ntrusted_hash = """sha256:old"""\n',+ ]) expect(withReviewRecords(text, record, records), text).toBe('unsafe')+ const codexHome = home()+ writeFileSync(join(codexHome, 'config.toml'), '[hooks]\nstate = {}\n')+ const log = vi.spyOn(console, 'log').mockImplementation(() => {})+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ expect(readFileSync(join(codexHome, 'config.toml'), 'utf8')).toBe('[hooks]\nstate = {}\n')+ expect(log.mock.calls.flat().join('\n')).toContain('defines hooks.state in a form Harness does not edit')+ })++ it('keys a symlinked hooks.json by its own name in CODEX_HOME, not its target, as Codex does', () => {+ const codexHome = home()+ const dotfiles = home()+ writeFileSync(join(dotfiles, 'hooks.json'), '{}\n')+ symlinkSync(join(dotfiles, 'hooks.json'), join(codexHome, 'hooks.json'))+ vi.spyOn(console, 'log').mockImplementation(() => {})+ installHookSettings('codex', hooks.settings, 18473, codexHome)+ const config = readFileSync(join(codexHome, 'config.toml'), 'utf8')+ expect(config).toContain(`[hooks.state.${JSON.stringify(`${codexHome}/hooks.json:session_start:0:0`)}]`)+ expect(config).not.toContain(dotfiles)+ })++ it('keys by the real path of a symlinked CODEX_HOME, as Codex does, and writes through a symlinked config', () => {+ const real = home()+ const link = `${real}-link`+ symlinkSync(real, link)+ roots.push(link)+ const dotfiles = home()+ writeFileSync(join(dotfiles, 'config.toml'), 'model = "gpt-6"\n')+ symlinkSync(join(dotfiles, 'config.toml'), join(real, 'config.toml'))+ vi.spyOn(console, 'log').mockImplementation(() => {})+ installHookSettings('codex', hooks.settings, 18473, link)+ expect(lstatSync(join(real, 'config.toml')).isSymbolicLink()).toBe(true)+ const config = readFileSync(join(dotfiles, 'config.toml'), 'utf8')+ expect(config).toContain(`[hooks.state.${JSON.stringify(`${real}/hooks.json:session_start:0:0`)}]`)+ expect(config).not.toContain(link)+ })++ it('never throws: an unreadable settings path is a hook Codex asks about, as before', () => {+ const error = vi.spyOn(console, 'error').mockImplementation(() => {})+ expect(() => recordReviewed(record, '/nonexistent-home', '/nonexistent-home/hooks.json')).not.toThrow()+ expect(error).toHaveBeenCalled()+ })+})diff --git a/cli/src/engines/kit/hookReview.ts b/cli/src/engines/kit/hookReview.tsnew file mode 100644index 000000000..922547713--- /dev/null+++ b/cli/src/engines/kit/hookReview.ts@@ -0,0 +1,199 @@+/**+ * Harness's own hook blocks recorded as reviewed, where the engine asks a person to review a hook before it+ * first runs (facets/hooks.ts `HookReviewRecord`): Codex 0.162 shows "Hooks need review" in the first Codex+ * pane, and a person who picks "Continue without trusting" switches Harness's hooks off without knowing it.+ *+ * The record is the engine's own, written as the engine writes it on "Trust all": a table per hook in its+ * config file, keyed by the settings file in the real path of the engine's home, the event, the block and+ * the hook, holding the hash the engine computes of the hook. The hash is the engine's: the hook normalized+ * (its matcher only where the engine honours one, a timeout always, `async`), every object's keys sorted,+ * compact JSON, sha256. It is matched against `codex app-server` `hooks/list` of codex-cli 0.162.0+ * (hookReview.spec.ts). Should an engine hash differently, it sees a changed hook and asks again, which is+ * where it was before.+ *+ * Only Harness's own blocks, never another hook in the same file. The config file is edited the way+ * folderTrust.ts edits it: through a symlink, atomically, and only where the table cannot end up defined twice.+ */+import { createHash } from 'node:crypto'+import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'+import { basename, dirname, join } from 'node:path'+import type { HookReviewRecord } from '../facets/hooks.js'+import { replaceConfigFile } from './folderTrust.js'+import { isOurs, type Settings } from './notifyHooks.js'++/** Every object's keys sorted, as the engine sorts them before it hashes. */+function sortedKeys(value: unknown): unknown {+ if (Array.isArray(value)) return value.map(sortedKeys)+ if (value && typeof value === 'object') {+ return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sortedKeys((value as Record<string, unknown>)[key])]))+ }+ return value+}++/** The engine's hash of one command hook, as `hooks/list` reports it in `currentHash`. */+export function reviewHash(record: HookReviewRecord, event: string, matcher: string | undefined, hook: { command: string; timeout?: number; async?: boolean }): string {+ const identity = {+ event_name: record.events[event],+ ...(record.matcherEvents.includes(event) && matcher !== undefined ? { matcher } : {}),+ hooks: [{ type: 'command', command: hook.command, timeout: Math.max(1, hook.timeout ?? record.defaultTimeout), async: hook.async === true }],+ }+ return `sha256:${createHash('sha256').update(JSON.stringify(sortedKeys(identity))).digest('hex')}`+}++/** The records Harness's own blocks in `settings` need: key → hash. */+export function reviewRecords(record: HookReviewRecord, settingsFile: string, settings: Settings): Map<string, string> {+ const records = new Map<string, string>()+ for (const [event, label] of Object.entries(record.events)) {+ const blocks = settings.hooks?.[event]+ if (!Array.isArray(blocks)) continue+ const blockIndex = blocks.findIndex(isOurs)+ if (blockIndex < 0) continue+ const block = blocks[blockIndex]+ const hookIndex = block.hooks.findIndex((hook) => isOurs({ hooks: [hook] }))+ const hook = block.hooks[hookIndex]+ if (hook.type !== 'command' || typeof hook.command !== 'string') continue+ // A hook edited into a shape Harness does not write is one the engine reads its own way: it asks.+ if ((hook.timeout !== undefined && typeof hook.timeout !== 'number') || (block.matcher !== undefined && typeof block.matcher !== 'string')) continue+ records.set(`${settingsFile}:${label}:${blockIndex}:${hookIndex}`, reviewHash(record, event, block.matcher, hook))+ }+ return records+}++const escape = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')+/** One key, bare or quoted: `hooks`, `"hooks"` and `'hooks'` name the same table. */+const segment = (key: string): string => `(?:${escape(key)}|"${escape(key)}"|'${escape(key)}')`+/** `hooks.state` as a header path, however its dots are spaced and its keys quoted. */+const tablePath = (table: string): string => table.split('.').map(segment).join(String.raw`[ \t]*\.[ \t]*`)+/** A key in a header: bare, or a one-line string. */+const KEY = String.raw`(?:[A-Za-z0-9_-]+|"(?:[^"\\\r\n]|\\.)*"|'[^'\r\n]*')`+const HEADER = new RegExp(String.raw`^[ \t]*\[\[?[ \t]*${KEY}(?:[ \t]*\.[ \t]*${KEY})*[ \t]*\]\]?[ \t]*(?:#.*)?\r?$`)++/**+ * The text as it is read for its structure: multi-line strings and a byte order mark blanked to spaces,+ * newlines kept, so that a line inside a string is never taken for a header or a key, and every offset still+ * points into the real text. Codex refuses a config.toml that does not parse, every setting in it lost: a+ * header appended in the wrong place would cost a person far more than a hook review.+ */+const structure = (text: string): string => text+ .replace(/^/, ' ')+ .replace(/"""[\s\S]*?"""|'''[\s\S]*?'''/g, (string) => string.replace(/[^\n]/g, ' '))++/** How many arrays and inline tables a line opens, less those it closes; its strings and comment left out. */+const opens = (line: string): number => {+ const bare = line.replace(/"(?:[^"\\]|\\.)*"|'[^']*'/g, '').replace(/#.*/, '')+ return (bare.match(/[[{]/g)?.length ?? 0) - (bare.match(/[\]}]/g)?.length ?? 0)+}++interface Line { start: number; end: number; text: string }+/** The table headers, in order: a line of an array or inline table that spans lines (`["a"]`) is a value. */+function headers(shape: string): Line[] {+ const found: Line[] = []+ let depth = 0+ let start = 0+ for (const text of shape.split('\n')) {+ if (depth === 0 && HEADER.test(text)) found.push({ start, end: start + text.length, text })+ else depth = Math.max(0, depth + opens(text))+ start += text.length + 1+ }+ return found+}++/** The key a quoted TOML key names; null for an escape JSON does not share. */+function tomlKey(quoted: string): string | null {+ if (quoted.startsWith("'")) return quoted.slice(1, -1)+ try { return JSON.parse(quoted) as string } catch { return null }+}++/**+ * The table, or the table above it, defined in a form a header appended after it could collide with: an+ * inline table, dotted keys, an array of tables, or values in the table's own body. Codex writes+ * `[hooks.state]` with nothing in it, then a header per hook.+ */+function definedOtherwise(shape: string, table: string): boolean {+ const [top, sub] = table.split('.')+ const list = headers(shape)+ const body = (i: number): string => shape.slice(list[i].end, list[i + 1]?.start ?? shape.length)+ const preamble = shape.slice(0, list[0]?.start ?? shape.length)+ if (new RegExp(String.raw`^[ \t]*${segment(top)}[ \t]*[.=]`, 'm').test(preamble)) return true+ const topHeader = new RegExp(String.raw`^[ \t]*\[[ \t]*${segment(top)}[ \t]*\]`)+ const tableHeader = new RegExp(String.raw`^[ \t]*\[[ \t]*${tablePath(table)}[ \t]*\]`)+ const arrayOfTables = new RegExp(String.raw`^[ \t]*\[\[[ \t]*${segment(top)}(?:[ \t]*\.[ \t]*${segment(sub)})?[ \t]*\]\]`)+ return list.some((line, i) => arrayOfTables.test(line.text)+ || (topHeader.test(line.text) && new RegExp(String.raw`^[ \t]*${segment(sub)}[ \t]*[.=]`, 'm').test(body(i)))+ || (tableHeader.test(line.text) && /^[ \t]*[^\s#]/m.test(body(i))))+}++/**+ * The config file's text with each record in place: an existing table's hash replaced when it differs, a+ * missing table appended. 'unsafe' when the file defines the table, or a record, in a form this could make+ * invalid; the engine then asks the person, as it would anyway.+ */+export function withReviewRecords(text: string, record: HookReviewRecord, records: Map<string, string>): string | 'unchanged' | 'unsafe' {+ if (definedOtherwise(structure(text), record.table)) return 'unsafe'+ const header = new RegExp(String.raw`^[ \t]*\[[ \t]*${tablePath(record.table)}[ \t]*\.[ \t]*("(?:[^"\\\r\n]|\\.)*"|'[^'\r\n]*')[ \t]*\]`)+ const field = new RegExp(String.raw`^([ \t]*${segment(record.key)}[ \t]*=[ \t]*)([^\n]*)$`, 'm')+ const value = /^("(?:[^"\\\r\n]|\\.)*"|'[^'\r\n]*')[ \t]*(?:#.*)?\r?$/+ let next = text+ for (const [key, hash] of records) {+ const shape = structure(next)+ const list = headers(shape)+ const found = list.flatMap((line, i) => {+ const match = header.exec(line.text)+ return match ? [{ i, key: tomlKey(match[1]) }] : []+ })+ if (found.some((one) => one.key === null)) return 'unsafe'+ const ours = found.filter((one) => one.key === key)+ if (ours.length > 1) return 'unsafe'+ if (ours.length === 1) {+ const at = list[ours[0].i].end+ const line = field.exec(shape.slice(at, list[ours[0].i + 1]?.start ?? shape.length))+ if (line) {+ // Only a one-line string is read and replaced; anything else (a multi-line string, another type) is+ // a record this does not understand, and a second key beside it would not parse.+ const from = at + line.index + line[1].length+ const quoted = value.exec(next.slice(from, at + line.index + line[0].length))+ if (!quoted) return 'unsafe'+ if (tomlKey(quoted[1]) === hash) continue+ next = next.slice(0, from) + JSON.stringify(hash) + next.slice(from + quoted[1].length)+ } else {+ next = `${next.slice(0, at)}\n${record.key} = ${JSON.stringify(hash)}${next.slice(at)}`+ }+ continue+ }+ // A TOML basic string is a JSON string, except that DEL must be escaped too.+ const table = `[${record.table}.${JSON.stringify(key).replace(/\x7f/g, '\\u007f')}]`+ next = `${next.replace(/\s*$/, '')}${next.trim() ? '\n\n' : ''}${table}\n${record.key} = ${JSON.stringify(hash)}\n`+ }+ return next === text ? 'unchanged' : next+}++/**+ * Record Harness's own blocks in the engine's settings file, as the file is on disk now, as reviewed in the+ * engine's config file: the engine keys and hashes what it reads, so an order or a timeout Harness did not+ * write itself is recorded as it is. Created when the engine has not written one yet: a new person's first+ * Codex pane is the one that asks. Never throws: a hook that is not recorded is asked about, as before.+ */+export function recordReviewed(record: HookReviewRecord, home: string, settingsFile: string): void {+ const config = join(home, record.file)+ const say = (line: string): string => line.replace('{config}', config)+ try {+ const settings = JSON.parse(readFileSync(settingsFile, 'utf8')) as Settings+ if (!settings || typeof settings !== 'object' || Array.isArray(settings) || !settings.hooks || typeof settings.hooks !== 'object') return+ // Codex keys a hook by the real path of CODEX_HOME joined with the file's name (codex-cli 0.162.0): a+ // symlinked home names its target, a symlinked hooks.json in it keeps its own name.+ const records = reviewRecords(record, join(realpathSync(dirname(settingsFile)), basename(settingsFile)), settings)+ if (records.size === 0) return+ const text = existsSync(config) ? readFileSync(config, 'utf8') : ''+ const next = withReviewRecords(text, record, records)+ if (next === 'unchanged') return+ if (next === 'unsafe') {+ console.log(say(record.messages.skipped))+ return+ }+ if (existsSync(config)) replaceConfigFile(config, next)+ else writeFileSync(config, next, { mode: 0o600 })+ console.log(say(record.messages.recorded))+ } catch (err) {+ console.error(say(record.messages.skipped), err)+ }+}diff --git a/cli/src/engines/kit/hookSettings.ts b/cli/src/engines/kit/hookSettings.tsindex 88645b1a4..eef517502 100644--- a/cli/src/engines/kit/hookSettings.ts+++ b/cli/src/engines/kit/hookSettings.ts@@ -12,6 +12,7 @@ import { homedir } from 'node:os'import { dirname, join } from 'node:path'import { env } from '../../config/env.js'import type { HookSettings } from '../facets/hooks.js'+import { recordReviewed } from './hookReview.js'import { command, HOOK_SCRIPT, isOurs, writeJsonAtomic, type Settings } from './notifyHooks.js'/** The engines whose hooks run the notify.mjs command. */@@ -70,6 +71,8 @@ export function installHookSettings(engine: HookEngine, settings: HookSettings,if (!changed) {console.log(say(messages.current))+ // Installed by an earlier start, or by a release before the engine asked: recorded now, as the file has it.+ if (settings.reviewed) recordReviewed(settings.reviewed, home, file)return}@@ -83,5 +86,7 @@ export function installHookSettings(engine: HookEngine, settings: HookSettings,console.log(say(messages.after))} catch (err) {console.error(say(messages.failed), err)+ return}+ if (settings.reviewed) recordReviewed(settings.reviewed, home, file)}