()
| 33 | const TELEMETRY_DIR = path.join(PROJECT_ROOT, '.planning', 'telemetry'); |
| 34 | |
| 35 | function main() { |
| 36 | let input = ''; |
| 37 | process.stdin.setEncoding('utf8'); |
| 38 | process.stdin.on('data', (chunk) => { input += chunk; }); |
| 39 | process.stdin.on('end', () => { |
| 40 | let event = {}; |
| 41 | try { event = JSON.parse(input); } catch { /* partial input ok */ } |
| 42 | |
| 43 | const filePath = event.file_path || event.path || null; |
| 44 | const changeType = event.change_type || event.type || 'modified'; |
| 45 | const sessionId = event.session_id || null; |
| 46 | |
| 47 | health.increment('file-changed', 'count'); |
| 48 | |
| 49 | const relative = filePath |
| 50 | ? path.relative(PROJECT_ROOT, filePath).replace(/\\/g, '/') |
| 51 | : null; |
| 52 | |
| 53 | health.logTiming('file-changed', 0, { |
| 54 | event: 'file-changed', |
| 55 | file: relative, |
| 56 | change_type: changeType, |
| 57 | session_id: sessionId, |
| 58 | }); |
| 59 | |
| 60 | if (!relative) { |
| 61 | process.exit(0); |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | // CLAUDE.md or rules/*.md changed → queue doc-sync review |
| 66 | const isInstructions = relative === 'CLAUDE.md' || |
| 67 | /^\.claude\/rules\/.*\.md$/.test(relative); |
| 68 | |
| 69 | if (isInstructions) { |
| 70 | queueDocSync(relative, 'file-changed'); |
| 71 | } |
| 72 | |
| 73 | // hooks_src/*.js changed → flag for reload so next session picks up changes |
| 74 | const isHookScript = /^hooks_src\/.*\.js$/.test(relative); |
| 75 | if (isHookScript) { |
| 76 | health.writeAuditLog('hook-script-changed', { |
| 77 | file: relative, |
| 78 | change_type: changeType, |
| 79 | advisory: 'Run scripts/install-hooks.js to apply hook changes', |
| 80 | severity: 'low', |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | // skills/**\/SKILL.md changed → queue skill-lint |
| 85 | const isSkillFile = /^skills\/.*\/SKILL\.md$/.test(relative); |
| 86 | if (isSkillFile) { |
| 87 | queueSkillLint(relative); |
| 88 | } |
| 89 | |
| 90 | syncRepositoryMemory(filePath, relative); |
| 91 | |
| 92 | process.exit(0); |
no test coverage detected