Skip to content

Commit 13490d5

Browse files
committed
fix: disable_plugin_hooks toggle, setup template references, Linux stat
- Add disable_plugin_hooks config key to vaultguard.sh (closes agenticnotetaking#23) - Fix setup skill to read hook templates instead of improvising (fixes double-execution when both plugin and project hooks exist) - Fix stat -f ambiguity on Linux in session-orient.sh (closes agenticnotetaking#16)
1 parent 2acfd5c commit 13490d5

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

hooks/scripts/session-orient.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ fi
139139

140140
# Methodology staleness check (Rule Zero)
141141
if [ -d ops/methodology ] && [ -f ops/config.yaml ]; then
142-
CONFIG_MTIME=$(stat -f %m ops/config.yaml 2>/dev/null || stat -c %Y ops/config.yaml 2>/dev/null || echo 0)
142+
CONFIG_MTIME=$(stat -c %Y ops/config.yaml 2>/dev/null || stat -f %m ops/config.yaml 2>/dev/null || echo 0)
143143
NEWEST_METH=$(ls -t ops/methodology/*.md 2>/dev/null | head -1)
144144
if [ -n "$NEWEST_METH" ]; then
145-
METH_MTIME=$(stat -f %m "$NEWEST_METH" 2>/dev/null || stat -c %Y "$NEWEST_METH" 2>/dev/null || echo 0)
145+
METH_MTIME=$(stat -c %Y "$NEWEST_METH" 2>/dev/null || stat -f %m "$NEWEST_METH" 2>/dev/null || echo 0)
146146
DAYS_STALE=$(( (CONFIG_MTIME - METH_MTIME) / 86400 ))
147147
if [ "$DAYS_STALE" -ge 30 ]; then
148148
echo "CONDITION: Methodology notes are ${DAYS_STALE}+ days behind config changes. Consider /rethink drift."

hooks/scripts/vaultguard.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ git: true
2121
session_capture: true
2222
EOF
2323
fi
24+
# Check if plugin hooks are disabled (project hooks take over)
25+
if grep -q '^disable_plugin_hooks: true' "$MARKER" 2>/dev/null; then
26+
exit 1
27+
fi
2428
exit 0
2529
fi
2630

skills/setup/SKILL.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,24 @@ For Claude Code, add to `.claude/settings.json` (using additive merge).
14161416

14171417
**Critical:** The old flat format (`"type": "command"` at the matcher level) is rejected by Claude Code. Each event must use the nested structure: `"EventName": [{ "matcher": "...", "hooks": [{ "type": "command", "command": "..." }] }]`.
14181418

1419-
Generate all four hook scripts: session-orient.sh, session-capture.sh, validate-note.sh, auto-commit.sh.
1419+
Generate all four hook scripts by reading and vocabulary-transforming the templates:
1420+
1421+
1. Read `${CLAUDE_PLUGIN_ROOT}/platforms/claude-code/hooks/session-orient.sh.template`
1422+
2. Read `${CLAUDE_PLUGIN_ROOT}/platforms/claude-code/hooks/session-capture.sh.template`
1423+
3. Read `${CLAUDE_PLUGIN_ROOT}/platforms/claude-code/hooks/write-validate.sh.template`
1424+
4. Read `${CLAUDE_PLUGIN_ROOT}/platforms/claude-code/hooks/auto-commit.sh.template`
1425+
1426+
For each template:
1427+
- Replace `{{NOTES_DIR:-notes}}` with the vocabulary-mapped notes directory
1428+
- Replace `{{INBOX_DIR:-inbox}}` with the vocabulary-mapped inbox directory
1429+
- Replace `{{OBS_THRESHOLD:-10}}` with the configured observation threshold (default 10)
1430+
- Replace `{{TENSION_THRESHOLD:-5}}` with the configured tension threshold (default 5)
1431+
- Replace `/{DOMAIN:rethink}`, `/{DOMAIN:reduce}`, `/{DOMAIN:reflect}` with vocabulary-mapped skill names
1432+
- Replace `{{DOMAIN:note}}`, `{{DOMAIN:topic_map}}` with vocabulary-mapped terms
1433+
- Remove `{{IF_SELF_SPACE}}` / `{{END_IF_SELF_SPACE}}` comment markers (keep content if self-space is active, remove block if not)
1434+
- Remove `{{IF_DISCOVERY_NUDGE}}` / `{{END_IF_DISCOVERY_NUDGE}}` comment markers (keep content if discovery nudge is active, remove block if not)
1435+
1436+
Write the transformed scripts to `.claude/hooks/`. CRITICAL: Do NOT generate hook scripts from scratch or improvise their content. The templates contain session tracking, context injection, and condition checks that must be preserved.
14201437

14211438
---
14221439

0 commit comments

Comments
 (0)