fix(hooks): keep hooks.json within Claude Code's schema

Move stable hook metadata to a validated sidecar while preserving hook commands and installer identity. Reject moved fingerprints and duplicate IDs, and validate before updating metadata. Independent local review passed at c315271624a1fd055b992f2bff889ad2a0ff8a6b; CI run 34678210149 passed. Rollback: revert this squash commit.
This commit is contained in:
zpearce-2814
2026-09-12 02:59:02 -04:00
committed by GitHub
parent c4904e3f63
commit 1ac07903ec
19 changed files with 1060 additions and 104 deletions
+4 -1
View File
@@ -19,6 +19,7 @@ const {
isAllowedOrigin,
} = require('./lib/loopback-guard');
const { normalizeAgentTools } = require('./lib/agent-tools');
const { readHooksConfig } = require('./lib/hooks-config');
const DEFAULT_HOST = '127.0.0.1';
@@ -129,7 +130,9 @@ function loadHooks(_root) {
const hooksPath = path.join(root, 'hooks', 'hooks.json');
if (!fs.existsSync(hooksPath)) return [];
try {
const data = JSON.parse(fs.readFileSync(hooksPath, 'utf8'));
// Ids and descriptions live in hooks/hooks.metadata.json so that hooks.json
// stays within the key set Claude Code's hooks schema accepts.
const data = readHooksConfig(hooksPath);
const hooks = [];
for (const [eventName, entries] of Object.entries(data.hooks || {})) {
for (const entry of entries || []) {