MCPcopy Create free account
hub / github.com/SethGammon/Citadel / main

Function main

hooks_src/post-tool-batch.js:33–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31const CITADEL_UI = process.env.CITADEL_UI === 'true';
32
33function main() {
34 let input = '';
35 process.stdin.setEncoding('utf8');
36 process.stdin.on('data', (chunk) => { input += chunk; });
37 process.stdin.on('end', () => {
38 let event = {};
39 try { event = JSON.parse(input); } catch { /* partial input ok */ }
40
41 const agentId = event.agent_id || null;
42 const agentType = event.agent_type || null;
43 const sessionId = event.session_id || null;
44
45 health.increment('post-tool-batch', 'count');
46
47 health.logTiming('post-tool-batch', 0, {
48 event: 'wave-settled',
49 agent_id: agentId,
50 agent_type: agentType,
51 session_id: sessionId,
52 });
53
54 // Scan recent post-edit telemetry to find wave-level signals
55 const signals = collectWaveSignals();
56
57 if (signals.length > 0) {
58 const contextMsg = `[post-tool-batch] wave check:\n${signals.map(s => ` ${s}`).join('\n')}`;
59
60 if (CITADEL_UI) {
61 process.stdout.write(JSON.stringify({
62 hook: 'post-tool-batch',
63 action: 'wave-check',
64 message: contextMsg,
65 timestamp: new Date().toISOString(),
66 data: { signals },
67 }));
68 } else {
69 // Inject quality signals directly into Claude's context window
70 process.stdout.write(JSON.stringify({ additionalContext: contextMsg }));
71 }
72 }
73
74 process.exit(0);
75 });
76}
77
78/**
79 * Read the last 20 hook-timing entries and surface anything from the

Callers 1

post-tool-batch.jsFile · 0.70

Calls 1

collectWaveSignalsFunction · 0.85

Tested by

no test coverage detected