site-mariage/.claude/hooks/inject-tao.js
Corentin Joguet bff653acd6 first commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 10:30:37 +02:00

36 lines
1 KiB
JavaScript
Executable file

#!/usr/bin/env node
/**
* UserPromptSubmit hook — injects BYAN tao voice directives into every
* user prompt so Claude's response respects the register even when BYAN
* agent isn't explicitly invoked.
*
* Reads _byan/tao.md. If absent or empty, emits empty additionalContext
* (no-op). Always exits 0.
*/
const fs = require('fs');
const path = require('path');
const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
const taoPath = path.join(projectDir, '_byan', 'tao.md');
let additionalContext = '';
try {
if (fs.existsSync(taoPath)) {
const content = fs.readFileSync(taoPath, 'utf8').trim();
if (content.length > 0) {
additionalContext = `BYAN tao directives (active for this turn — follow register, signatures, forbidden vocabulary):\n\n${content}`;
}
}
} catch {
// Hook must never block prompt submission.
}
process.stdout.write(
JSON.stringify({
hookSpecificOutput: {
hookEventName: 'UserPromptSubmit',
additionalContext: additionalContext || '',
},
})
);