mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-08 02:03:34 +08:00
fix: resolve stop hooks without plugin root env
This commit is contained in:
@@ -1965,7 +1965,7 @@ async function runTests() {
|
||||
passed++;
|
||||
else failed++;
|
||||
if (
|
||||
test('script references use CLAUDE_PLUGIN_ROOT variable or safe SessionStart inline resolver', () => {
|
||||
test('script references use CLAUDE_PLUGIN_ROOT variable or a safe inline resolver', () => {
|
||||
const hooksPath = path.join(__dirname, '..', '..', 'hooks', 'hooks.json');
|
||||
const hooks = JSON.parse(fs.readFileSync(hooksPath, 'utf8'));
|
||||
|
||||
@@ -1973,9 +1973,8 @@ async function runTests() {
|
||||
for (const entry of hookArray) {
|
||||
for (const hook of entry.hooks) {
|
||||
if (hook.type === 'command' && hook.command.includes('scripts/hooks/')) {
|
||||
// Check for the literal string "${CLAUDE_PLUGIN_ROOT}" in the command
|
||||
const isSessionStartInlineResolver = hook.command.startsWith('node -e') && hook.command.includes('session:start') && hook.command.includes('run-with-flags.js');
|
||||
const hasPluginRoot = hook.command.includes('${CLAUDE_PLUGIN_ROOT}') || isSessionStartInlineResolver;
|
||||
const isInlineResolver = hook.command.startsWith('node -e') && hook.command.includes('run-with-flags.js');
|
||||
const hasPluginRoot = hook.command.includes('${CLAUDE_PLUGIN_ROOT}') || isInlineResolver;
|
||||
assert.ok(hasPluginRoot, `Script paths should use CLAUDE_PLUGIN_ROOT: ${hook.command.substring(0, 80)}...`);
|
||||
}
|
||||
}
|
||||
@@ -1990,6 +1989,24 @@ async function runTests() {
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
if (
|
||||
test('Stop and SessionEnd lifecycle hooks use inline resolvers when plugin root may be unset', () => {
|
||||
const hooksPath = path.join(__dirname, '..', '..', 'hooks', 'hooks.json');
|
||||
const hooks = JSON.parse(fs.readFileSync(hooksPath, 'utf8'));
|
||||
const lifecycleHooks = [...(hooks.hooks.Stop || []), ...(hooks.hooks.SessionEnd || [])];
|
||||
|
||||
for (const entry of lifecycleHooks) {
|
||||
for (const hook of entry.hooks || []) {
|
||||
assert.ok(hook.command.startsWith('node -e "'), `Expected inline resolver for lifecycle hook: ${hook.command.substring(0, 80)}...`);
|
||||
assert.ok(hook.command.includes("const hookId='"), 'Inline lifecycle resolver should embed hook identifiers');
|
||||
assert.ok(hook.command.includes('plugins'), 'Inline lifecycle resolver should probe known plugin roots');
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
if (
|
||||
test('InsAIts hook is opt-in and scoped to high-signal tool inputs', () => {
|
||||
const hooksPath = path.join(__dirname, '..', '..', 'hooks', 'hooks.json');
|
||||
|
||||
Reference in New Issue
Block a user