diff --git a/bin/hooks/phase-tracker.js b/bin/hooks/phase-tracker.js new file mode 100644 index 0000000..86bcacc --- /dev/null +++ b/bin/hooks/phase-tracker.js @@ -0,0 +1,31 @@ +#!/usr/bin/env node + +/** + * Phase Tracker Hook + * + * Tracks current agentful phase from .agentful/state.json + * Cross-platform compatible (Windows, macOS, Linux) + */ + +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const STATE_FILE = path.join(process.cwd(), '.agentful', 'state.json'); + +try { + if (fs.existsSync(STATE_FILE)) { + const content = fs.readFileSync(STATE_FILE, 'utf8'); + const state = JSON.parse(content); + const phase = state.current_phase || 'idle'; + // Silent output - just track phase internally + // console.log(phase); + } +} catch (error) { + // Silently fail - phase tracking is optional +} + +process.exit(0); diff --git a/template/.claude/settings.json b/template/.claude/settings.json index 048fbe6..485c5f2 100644 --- a/template/.claude/settings.json +++ b/template/.claude/settings.json @@ -102,24 +102,6 @@ "description": "Protect package.json ownership metadata from accidental corruption" } ] - }, - { - "matcher": "Write|Edit|NotebookEdit", - "hooks": [ - { - "type": "command", - "command": "npx tsc --noEmit 2>&1 | head -5 || true" - } - ] - }, - { - "matcher": "Write|Edit|NotebookEdit", - "hooks": [ - { - "type": "command", - "command": "if [ \"$FILE\" = \"*.md\" ]; then existing=$(find . -name '*.md' -not -path './node_modules/*' -not -path './.git/*' | xargs grep -l \"$(basename '$FILE' | sed 's/_/ /g' | sed 's/.md$//' | head -c 30)\" 2>/dev/null | grep -v \"$FILE\" | head -1); if [ -n \"$existing\" ]; then echo \"\u26a0\ufe0f Similar doc exists: $existing - consider updating instead\"; fi; fi || true" - } - ] } ], "UserPromptSubmit": [ @@ -127,7 +109,8 @@ "hooks": [ { "type": "command", - "command": "if [ -f .agentful/state.json ]; then jq -r '.current_phase // \"idle\"' .agentful/state.json 2>/dev/null || echo 'idle'; else echo 'idle'; fi", + "command": "node bin/hooks/phase-tracker.js", + "timeout": 3, "description": "Track current agentful phase" } ]