mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-02-15 10:53:18 +08:00
fix: add async/timeout to hooks schema and validate in CI
- hooks.schema.json: add async (boolean) and timeout (number) properties to hookItem definition, matching fields used in hooks.json - validate-hooks.js: validate async and timeout types when present - hooks.test.js: add SessionEnd to required event types check
This commit is contained in:
@@ -25,6 +25,15 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"async": {
|
||||
"type": "boolean",
|
||||
"description": "Run hook asynchronously in background without blocking"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"description": "Timeout in seconds for async hooks"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -24,6 +24,16 @@ function validateHookEntry(hook, label) {
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
// Validate optional async and timeout fields
|
||||
if ('async' in hook && typeof hook.async !== 'boolean') {
|
||||
console.error(`ERROR: ${label} 'async' must be a boolean`);
|
||||
hasErrors = true;
|
||||
}
|
||||
if ('timeout' in hook && (typeof hook.timeout !== 'number' || hook.timeout < 0)) {
|
||||
console.error(`ERROR: ${label} 'timeout' must be a non-negative number`);
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
if (!hook.command || (typeof hook.command !== 'string' && !Array.isArray(hook.command))) {
|
||||
console.error(`ERROR: ${label} missing or invalid 'command' field`);
|
||||
hasErrors = true;
|
||||
|
||||
@@ -278,6 +278,7 @@ async function runTests() {
|
||||
assert.ok(hooks.hooks.PreToolUse, 'Should have PreToolUse hooks');
|
||||
assert.ok(hooks.hooks.PostToolUse, 'Should have PostToolUse hooks');
|
||||
assert.ok(hooks.hooks.SessionStart, 'Should have SessionStart hooks');
|
||||
assert.ok(hooks.hooks.SessionEnd, 'Should have SessionEnd hooks');
|
||||
assert.ok(hooks.hooks.Stop, 'Should have Stop hooks');
|
||||
assert.ok(hooks.hooks.PreCompact, 'Should have PreCompact hooks');
|
||||
})) passed++; else failed++;
|
||||
|
||||
Reference in New Issue
Block a user