diff --git a/.claude/hooks/framework-audit-hook.js b/.claude/hooks/framework-audit-hook.js index a5a8dc46..cfef991c 100755 --- a/.claude/hooks/framework-audit-hook.js +++ b/.claude/hooks/framework-audit-hook.js @@ -62,7 +62,7 @@ function outputResponse(decision, reason, systemMessage = null) { permissionDecisionReason: reason }, continue: true, - suppressOutput: decision === 'allow' + suppressOutput: false // FIXED: Always show framework guidance to Claude }; if (systemMessage) { diff --git a/.claude/hooks/session-init-hook.js b/.claude/hooks/session-init-hook.js new file mode 100755 index 00000000..e50cbe83 --- /dev/null +++ b/.claude/hooks/session-init-hook.js @@ -0,0 +1,93 @@ +#!/usr/bin/env node + +/** + * Session Initialization Hook (PostSessionStart - NOT YET SUPPORTED by Claude Code) + * + * WORKAROUND: This hook is designed for PostSessionStart event (not yet available). + * Current solution: Run via session-init.sh script explicitly. + * + * Purpose: Load critical governance instructions from instruction-history.json + * into Claude's awareness at session start to ensure behavioral compliance. + * + * Exit Code: Always 0 (informational only, never blocks) + */ + +const fs = require('fs'); +const path = require('path'); + +async function main() { + try { + // Load instruction history from project + const instructionPath = path.join(process.cwd(), '.claude', 'instruction-history.json'); + + if (!fs.existsSync(instructionPath)) { + console.log('\x1b[33m⚠️ No instruction-history.json found in this project\x1b[0m'); + process.exit(0); + } + + const instructionData = JSON.parse(fs.readFileSync(instructionPath, 'utf-8')); + const instructions = instructionData.instructions || []; + + // Filter for HIGH persistence and STRATEGIC quadrant (most critical) + const criticalInstructions = instructions.filter(inst => + inst.active && + (inst.persistence === 'HIGH' || inst.quadrant === 'STRATEGIC') + ); + + if (criticalInstructions.length === 0) { + console.log('\x1b[32m✓ No critical instructions to load\x1b[0m'); + process.exit(0); + } + + // Display critical instructions + console.log('\x1b[34m╔══════════════════════════════════════════════╗\x1b[0m'); + console.log('\x1b[34m║ CRITICAL GOVERNANCE INSTRUCTIONS ║\x1b[0m'); + console.log('\x1b[34m╚══════════════════════════════════════════════╝\x1b[0m'); + console.log(''); + console.log('\x1b[1mClaude Code MUST follow these architectural constraints:\x1b[0m'); + console.log(''); + + criticalInstructions.forEach((inst, index) => { + console.log(`\x1b[36m${index + 1}. [${inst.id}] ${inst.title}\x1b[0m`); + console.log(` ${inst.description}`); + console.log(` Persistence: ${inst.persistence} | Category: ${inst.category}`); + console.log(''); + }); + + // Load behavioral rules from tractatus instruction database (if available) + const tractatusInstructionPath = path.join(__dirname, '..', '..', '.claude', 'instruction-history.json'); + + if (fs.existsSync(tractatusInstructionPath)) { + const tractatusData = JSON.parse(fs.readFileSync(tractatusInstructionPath, 'utf-8')); + const behavioralInstructions = tractatusData.instructions?.filter(inst => + inst.active && + inst.category === 'BEHAVIORAL' && + (inst.id === 'inst_047' || inst.id === 'inst_049' || inst.id === 'inst_052') + ) || []; + + if (behavioralInstructions.length > 0) { + console.log('\x1b[34m╔══════════════════════════════════════════════╗\x1b[0m'); + console.log('\x1b[34m║ BEHAVIORAL CONSTRAINTS ║\x1b[0m'); + console.log('\x1b[34m╚══════════════════════════════════════════════╝\x1b[0m'); + console.log(''); + + behavioralInstructions.forEach((inst, index) => { + console.log(`\x1b[31m${index + 1}. [${inst.id}] ${inst.title}\x1b[0m`); + console.log(` ${inst.description}`); + console.log(''); + }); + } + } + + console.log('\x1b[32m✓ Session initialization complete\x1b[0m'); + console.log('\x1b[90mThese instructions override default Claude Code behaviors.\x1b[0m'); + console.log(''); + + } catch (err) { + console.error('\x1b[31m✗ Session initialization failed:', err.message, '\x1b[0m'); + } + + process.exit(0); +} + +main(); diff --git a/.claude/settings.json b/.claude/settings.json index 84a3fd1d..8ee0c982 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -15,6 +15,11 @@ "UserPromptSubmit": [ { "hooks": [ + { + "type": "command", + "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/prompt-analyzer-hook.js", + "timeout": 10 + }, { "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/trigger-word-checker.js",