From 8c9ee1818bc3e2ade968806b3b256d181d56137f Mon Sep 17 00:00:00 2001 From: Safi Date: Sat, 2 May 2026 09:35:28 +0100 Subject: [PATCH] Fix Codex PreToolUse hook failing on Windows Replace bash-only [ -f ] file check with a cross-platform Python one-liner so the hook works on Windows where cmd.exe has no [ builtin. Co-Authored-By: Claude Sonnet 4.6 --- graphify/__main__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/graphify/__main__.py b/graphify/__main__.py index 3df4467..e2f6024 100644 --- a/graphify/__main__.py +++ b/graphify/__main__.py @@ -718,10 +718,14 @@ _CODEX_HOOK = { "hooks": [ { "type": "command", + # Use Python for the file check so the hook works on Windows + # (cmd.exe has no [ -f ] builtin; Python is always available). "command": ( - "[ -f graphify-out/graph.json ] && " - r"""echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}}' """ - "|| true" + "python3 -c \"" + "import pathlib,json,sys; " + "p=pathlib.Path('graphify-out/graph.json'); " + r"print(json.dumps({'hookSpecificOutput':{'hookEventName':'PreToolUse','additionalContext':'graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files.'}})) if p.exists() else None" + "\"" ), } ],