Skip to content

A self-organizing Obsidian vault that gives AI coding agents persistent memory.

fix: cross-platform hook script reliability

Brenno Ferrari13aa19cd9e64
diff --git a/.claude/scripts/charcount.sh b/.claude/scripts/charcount.sh
index fdedfa2..3ab77f7 100755
--- a/.claude/scripts/charcount.sh
+++ b/.claude/scripts/charcount.sh
@@ -7,9 +7,9 @@ set -euo pipefail
# charcount.sh review.md "Competency Name" "Current Level"
# charcount.sh review.md "Competency Name" "Next Level"
-FILE="$1"
-SECTION="$2"
-SUB="$3"
+FILE="${1:-}"
+SECTION="${2:-}"
+SUB="${3:-}"
if [ -z "$FILE" ] || [ -z "$SECTION" ]; then
echo "Usage: charcount.sh <file> \"Section Header\" [subsection]"
diff --git a/.claude/scripts/classify-message.py b/.claude/scripts/classify-message.py
index 223c461..a9c28df 100755
--- a/.claude/scripts/classify-message.py
+++ b/.claude/scripts/classify-message.py
@@ -4,40 +4,43 @@ import json
import sys
import re
+
+def _any_word_match(pattern_words: list, text: str) -> bool:
+ """Check if any phrase appears as a whole word/phrase in text (not substring)."""
+ for phrase in pattern_words:
+ if re.search(r'\b' + re.escape(phrase) + r'\b', text):
+ return True
+ return False
+
+
def classify(prompt: str) -> list[str]:
p = prompt.lower()
signals = []
- # Decision signals
- if any(w in p for w in ["decided", "decision", "we chose", "agreed to", "let's go with", "the call is", "we're going with"]):
+ if _any_word_match(["decided", "decision", "we chose", "agreed to", "let's go with", "the call is", "we're going with"], p):
signals.append("DECISION detected — consider creating a Decision Record in work/active/ and logging in work/Index.md Decisions Log")
- # Incident signals
- if any(w in p for w in ["incident", "outage", "down", "pagerduty", "severity", "p0", "p1", "p2", "sev1", "sev2", "postmortem", "rca"]):
+ if _any_word_match(["incident", "outage", "pagerduty", "severity", "p0", "p1", "p2", "sev1", "sev2", "postmortem", "rca"], p):
signals.append("INCIDENT detected — consider using /incident-capture or creating an incident note in work/incidents/")
- # 1-on-1 signals
- if any(w in p for w in ["1:1", "1-on-1", "one on one", "1on1", "catch up with", "sync with"]):
+ if _any_word_match(["1:1", "1-on-1", "one on one", "1on1", "catch up with", "sync with"], p):
signals.append("1:1 CONTENT detected — consider creating a 1-on-1 note in work/1-1/ and updating the person note in org/people/")
- # Win/achievement signals
- if any(w in p for w in ["shipped", "launched", "completed", "achieved", "won", "promoted", "kudos", "shoutout", "great feedback", "recognized"]):
+ if _any_word_match(["shipped", "launched", "completed", "achieved", "won", "promoted", "kudos", "shoutout", "great feedback", "recognized"], p):
signals.append("WIN detected — consider adding to perf/Brag Doc.md with a link to the evidence note")
- # Architecture/design signals
- if any(w in p for w in ["architecture", "system design", "rfc", "tech spec", "trade-off", "design doc", "adr"]):
+ if _any_word_match(["architecture", "system design", "rfc", "tech spec", "trade-off", "design doc", "adr"], p):
signals.append("ARCHITECTURE discussion — consider creating a reference note in reference/ or a decision record")
- # Person signals (mentions of someone by context)
- if any(w in p for w in ["told me", "said that", "feedback from", "met with", "talked to", "spoke with", "mentioned that"]):
+ if _any_word_match(["told me", "said that", "feedback from", "met with", "talked to", "spoke with", "mentioned that"], p):
signals.append("PERSON CONTEXT detected — consider updating the relevant person note in org/people/ and linking from the conversation note")
- # Project update signals
- if any(w in p for w in ["project update", "sprint", "milestone", "shipped feature", "released", "deployed"]):
+ if _any_word_match(["project update", "sprint", "milestone", "shipped feature", "released", "deployed"], p):
signals.append("PROJECT UPDATE detected — consider updating the active work note in work/active/ and checking if wins should go to brag doc")
return signals
+
def main():
try:
input_data = json.load(sys.stdin)
@@ -62,6 +65,7 @@ def main():
}
}
json.dump(output, sys.stdout)
+ sys.stdout.flush()
sys.exit(0)
diff --git a/.claude/scripts/find-python.sh b/.claude/scripts/find-python.sh
index d77c540..9174dda 100644
--- a/.claude/scripts/find-python.sh
+++ b/.claude/scripts/find-python.sh
@@ -1,7 +1,16 @@
#!/usr/bin/env bash
-# Cross-platform Python resolver: python3 (macOS) → python (Windows/miniconda)
-if python3 --version >/dev/null 2>&1; then
- exec python3 "$@"
-else
- exec python "$@"
-fi
+# Cross-platform Python resolver
+# Windows: skip python3 (Windows Store stub is unreliable), use python directly
+# macOS/Linux: prefer python3, fall back to python
+case "$(uname -s)" in
+ MINGW*|MSYS*|CYGWIN*)
+ exec python "$@"
+ ;;
+ *)
+ if command -v python3 >/dev/null 2>&1; then
+ exec python3 "$@"
+ else
+ exec python "$@"
+ fi
+ ;;
+esac
diff --git a/.claude/scripts/pre-compact.sh b/.claude/scripts/pre-compact.sh
index 9e0ef82..76eaf81 100755
--- a/.claude/scripts/pre-compact.sh
+++ b/.claude/scripts/pre-compact.sh
@@ -1,9 +1,14 @@
#!/bin/bash
set -euo pipefail
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+
INPUT=$(cat)
-TRANSCRIPT_PATH=$(echo "$INPUT" | python3 -c "import json,sys; print(json.load(sys.stdin).get('transcript_path',''))" 2>/dev/null || echo "")
-TRIGGER=$(echo "$INPUT" | python3 -c "import json,sys; print(json.load(sys.stdin).get('trigger','unknown'))" 2>/dev/null || echo "unknown")
+read -r TRANSCRIPT_PATH TRIGGER <<< "$(echo "$INPUT" | bash "$SCRIPT_DIR/find-python.sh" -c "
+import json,sys
+d=json.load(sys.stdin)
+print(d.get('transcript_path',''), d.get('trigger','unknown'))
+" 2>/dev/null || echo " unknown")"
if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then
BACKUP_DIR="${CLAUDE_PROJECT_DIR:-$(pwd)}/thinking/session-logs"
diff --git a/.claude/scripts/session-start.sh b/.claude/scripts/session-start.sh
index 253d2d5..1247e0a 100755
--- a/.claude/scripts/session-start.sh
+++ b/.claude/scripts/session-start.sh
@@ -4,7 +4,7 @@ cd "$CLAUDE_PROJECT_DIR"
# Persist vault path for the session
if [ -n "${CLAUDE_ENV_FILE:-}" ]; then
- echo "export VAULT_PATH=$CLAUDE_PROJECT_DIR" >> "$CLAUDE_ENV_FILE"
+ echo "export VAULT_PATH=\"$CLAUDE_PROJECT_DIR\"" >> "$CLAUDE_ENV_FILE"
fi
# Incremental QMD re-index (fast, non-blocking if qmd not installed)
@@ -55,4 +55,4 @@ ls work/active/*.md 2>/dev/null | sed 's|work/active/||;s|\.md$||' | head -10 ||
echo ""
echo "### Vault File Listing"
-find . -name "*.md" -not -path "./.obsidian/*" -not -path "./thinking/*" -not -path "./.claude/*" | sort
+find . -name "*.md" -not -path "./.git/*" -not -path "./.obsidian/*" -not -path "./thinking/*" -not -path "./.claude/*" | sort
diff --git a/.claude/scripts/validate-write.py b/.claude/scripts/validate-write.py
index e7df6e3..9c2372c 100755
--- a/.claude/scripts/validate-write.py
+++ b/.claude/scripts/validate-write.py
@@ -3,7 +3,6 @@
import json
import sys
import os
-import re
from pathlib import Path
def main():
@@ -42,11 +41,6 @@ def main():
if "date:" not in fm and "date :" not in fm:
warnings.append("Missing `date` in frontmatter")
- # Check for wikilinks in body
- body = parts[2]
- else:
- body = content
-
# Check for wikilinks (skip very short notes)
if len(content) > 300 and "[[" not in content:
warnings.append("No [[wikilinks]] found — every note must link to at least one other note (vault convention)")
@@ -63,6 +57,7 @@ def main():
}
}
json.dump(output, sys.stdout)
+ sys.stdout.flush()
sys.exit(0)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f064973..03b21dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## v3.2.1 — 2026-03-29
+
+### Fixed
+- `find-python.sh`: detect Windows via `uname -s` and skip `python3` entirely (Windows Store stub is unreliable — can hang, consume stdin, or cause hook timeouts)
+- `find-python.sh`: use `command -v` instead of `python3 --version` on macOS/Linux (faster, no side effects)
+- `classify-message.py`: replace substring matching (`in`) with word-boundary regex (`\b`) — fixes false positives where "markdown", "wonder", "download", etc. triggered signals
+- `classify-message.py`: remove unused `import re` (now actually used), add `sys.stdout.flush()` before exit
+- `validate-write.py`: remove unused `import re` and dead `body` variable, add `sys.stdout.flush()` before exit
+- `pre-compact.sh`: use `find-python.sh` instead of hardcoded `python3` (was bypassing the cross-platform resolver), merge two Python calls into one
+- `session-start.sh`: quote `$CLAUDE_PROJECT_DIR` in exported value (paths with spaces broke the export)
+- `session-start.sh`: exclude `.git/` from vault file listing (consistent with other exclusions)
+- `charcount.sh`: use `${1:-}`, `${2:-}`, `${3:-}` for positional args (with `set -u`, missing args crashed before reaching the friendly usage message)
+
## v3.2 — 2026-03-29
### Added