feat(hooks): Add additionalContext support for PostToolUse hooks (#826)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Cameron
2026-02-04 18:32:16 -08:00
committed by GitHub
parent 428871b993
commit 881c2ddf53

View File

@@ -358,6 +358,21 @@ export async function executeHooksParallel(
const hook = hooks[i];
if (!result || !hook) continue;
// For exit 0, try to parse JSON for additionalContext (matching Claude Code behavior)
if (result.exitCode === HookExitCode.ALLOW && result.stdout?.trim()) {
try {
const json = JSON.parse(result.stdout.trim());
const additionalContext =
json?.hookSpecificOutput?.additionalContext ||
json?.additionalContext;
if (additionalContext) {
feedback.push(additionalContext);
}
} catch {
// Not JSON, ignore
}
}
// Format: [command]: {stderr} per spec
if (result.exitCode === HookExitCode.BLOCK) {
blocked = true;