Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bin/hooks/phase-tracker.js
Original file line number Diff line number Diff line change
@@ -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);
21 changes: 2 additions & 19 deletions template/.claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,15 @@
"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": [
{
"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"
}
]
Expand Down
Loading