Skip to content

AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).

chore(dev): run the ruff edit hook on Windows (#565)

ladislav-urbanc26a720cfb84
diff --git a/.claude/hooks/ruff-on-edit.sh b/.claude/hooks/ruff-on-edit.sh
index 27025f5c..27b6e353 100755
--- a/.claude/hooks/ruff-on-edit.sh
+++ b/.claude/hooks/ruff-on-edit.sh
@@ -3,17 +3,42 @@
# it, so errors surface at the edit instead of in CI. Exit 2 feeds ruff's
# output back to Claude. Unused-name rules are skipped: mid-edit, an import
# often lands one edit before its use.
+#
+# Works on Windows too (Git Bash): Python decides whether the file is under
+# packages/core, since the paths there are Windows paths (C:\...) that a shell
+# glob can't compare, and the venv keeps ruff in Scripts/ruff.exe, not bin/.
set -uo pipefail
-file=$(python3 -c 'import json,sys; print(json.load(sys.stdin).get("tool_input",{}).get("file_path",""))' 2>/dev/null)
-core="$CLAUDE_PROJECT_DIR/packages/core"
-ruff="$core/.venv/bin/ruff"
+py=$(command -v python3 || command -v python) || exit 0
+# Prints packages/core and the edited file, one per line, only for a .py file
+# inside packages/core; nothing otherwise.
+paths=$("$py" -c '
+import json, os, sys
+core = os.path.join(os.environ.get("CLAUDE_PROJECT_DIR", ""), "packages", "core")
+path = json.load(sys.stdin).get("tool_input", {}).get("file_path", "")
+if not path:
+ sys.exit()
+core, path = os.path.realpath(core), os.path.realpath(path)
+try:
+ inside = os.path.commonpath([os.path.normcase(core), os.path.normcase(path)]) == os.path.normcase(core)
+except ValueError: # different drives
+ inside = False
+if inside and path.endswith(".py") and os.path.isfile(path):
+ print(core)
+ print(path)
+' 2>/dev/null) || exit 0
+[ -n "$paths" ] || exit 0
+core=$(printf '%s\n' "$paths" | sed -n 1p)
+file=$(printf '%s\n' "$paths" | sed -n 2p)
-case "$file" in
- "$core"/*.py) ;;
- *) exit 0 ;;
-esac
-[ -x "$ruff" ] && [ -f "$file" ] || exit 0
+ruff=""
+for candidate in "$core/.venv/bin/ruff" "$core/.venv/Scripts/ruff.exe"; do
+ if [ -x "$candidate" ]; then
+ ruff=$candidate
+ break
+ fi
+done
+[ -n "$ruff" ] || exit 0
if ! out=$(cd "$core" && "$ruff" check --quiet --extend-ignore F401,F841 "$file" 2>&1); then
echo "$out" >&2