MCPcopy
hub / github.com/DietrichGebert/ponytail / writeHookOutput

Function writeHookOutput

hooks/ponytail-runtime.js:33–59  ·  view source on GitHub ↗
(event, mode, context = '')

Source from the content-addressed store, hash-verified

31}
32
33function writeHookOutput(event, mode, context = '') {
34 if (isCopilot) {
35 // Copilot reads additionalContext on SessionStart; ignores output elsewhere.
36 process.stdout.write(JSON.stringify(
37 event === 'SessionStart' && context ? { additionalContext: context } : {}));
38 return;
39 }
40 if (isCodex) {
41 const output = { systemMessage: `PONYTAIL:${mode.toUpperCase()}` };
42 if (context) {
43 output.hookSpecificOutput = {
44 hookEventName: event,
45 additionalContext: context,
46 };
47 }
48 process.stdout.write(JSON.stringify(output));
49 return;
50 }
51 // Native Claude: SessionStart accepts raw stdout, but SubagentStart needs the
52 // hookSpecificOutput JSON form or the context is dropped.
53 if (event === 'SubagentStart') {
54 process.stdout.write(JSON.stringify(
55 { hookSpecificOutput: { hookEventName: event, additionalContext: context } }));
56 return;
57 }
58 process.stdout.write(context);
59}
60
61module.exports = {
62 clearMode,

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected