fix(hook-validator): recognize MessageDisplay + post-session events

Clears false positives where valid CC hook events were flagged as
"Unknown hook event" (gap matrix, Batch 1).

VALID_EVENTS += MessageDisplay (CC 2.1.152), post-session (CC 2.1.169,
kebab-case, distinct from SessionEnd). 26 -> 28; recommendation string
updated to match.

knowledge/hook-events-reference.md count stays for the Batch 3 knowledge
refresh. Tests: hermetic runtime temp-fixture; 15/15 HKV green.

Ref: docs/cc-2.1.x-gap-matrix.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ter3E2JSi1Khgmuf2kady8
This commit is contained in:
Kjell Tore Guttormsen 2026-06-18 12:00:40 +02:00
commit 98ddd777fb
2 changed files with 54 additions and 3 deletions

View file

@ -27,6 +27,8 @@ const VALID_EVENTS = new Set([
'PreCompact', 'PostCompact',
'Elicitation', 'ElicitationResult',
'SessionEnd',
// CC 2.1.152 (MessageDisplay), 2.1.169 (post-session, kebab — distinct from SessionEnd)
'MessageDisplay', 'post-session',
]);
/** Valid hook handler types */
@ -134,7 +136,7 @@ async function validateHooksObject(hooks, file, findings, baseDir) {
description: `${file.relPath}: "${event}" is not a valid hook event. This hook will never fire.`,
file: file.absPath,
evidence: event,
recommendation: `Valid events: ${[...VALID_EVENTS].slice(0, 8).join(', ')}... (26 total)`,
recommendation: `Valid events: ${[...VALID_EVENTS].slice(0, 8).join(', ')}... (28 total)`,
autoFixable: false,
}));
continue;