From 0017a72273d31929433a20eeb2e9d671ac37f6fa Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Tue, 10 Feb 2026 00:49:13 -0800 Subject: [PATCH] repro: rich logging and focused tests --- integration-tests/hooks-system.test.ts | 20 +++++++++----------- packages/core/src/hooks/hookRunner.ts | 12 ++++++++++++ packages/test-utils/src/test-rig.ts | 10 ++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/integration-tests/hooks-system.test.ts b/integration-tests/hooks-system.test.ts index ad44fac19a..649120aa1e 100644 --- a/integration-tests/hooks-system.test.ts +++ b/integration-tests/hooks-system.test.ts @@ -1888,18 +1888,13 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho expect(disabledHookLog).toBeUndefined(); }); - it('should respect disabled hooks across multiple operations', async () => { - rig.setup('should respect disabled hooks across multiple operations', { - fakeResponsesPath: join( - import.meta.dirname, - 'hooks-system.disabled-via-command.responses', - ), - }); + it.only('should respect disabled hooks across multiple operations', async () => { + // 1. First setup to get the test directory and prepare the hook scripts + rig.setup('should respect disabled hooks across multiple operations'); + console.log(`[Test] testDir: ${rig.testDir}`); - // Create two hook scripts - one that will be disabled, one that won't const activeHookScript = `const fs = require('fs'); console.log(JSON.stringify({decision: "allow", systemMessage: "Active hook executed"}));`; - const disabledHookScript = `const fs = require('fs'); console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook should not execute", reason: "This hook is disabled"}));`; @@ -1909,11 +1904,14 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho writeFileSync(activePath, activeHookScript); writeFileSync(disabledPath, disabledHookScript); + const normalizedDisabledCmd = normalizePath(`node "${disabledPath}"`); + console.log(`[Test] normalizedDisabledCmd: ${normalizedDisabledCmd}`); + rig.setup('should respect disabled hooks across multiple operations', { settings: { hooksConfig: { enabled: true, - disabled: [normalizePath(`node "${disabledPath}"`)!], // Disable the second hook, + disabled: [normalizedDisabledCmd!], // Disable the second hook, }, hooks: { BeforeTool: [ @@ -1926,7 +1924,7 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho }, { type: 'command', - command: normalizePath(`node "${disabledPath}"`), + command: normalizedDisabledCmd!, timeout: 5000, }, ], diff --git a/packages/core/src/hooks/hookRunner.ts b/packages/core/src/hooks/hookRunner.ts index d98d84faa7..5820159548 100644 --- a/packages/core/src/hooks/hookRunner.ts +++ b/packages/core/src/hooks/hookRunner.ts @@ -269,6 +269,12 @@ export class HookRunner { shellConfig.shell, ); + if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') { + console.log(`[HookRunner] shellConfig: ${JSON.stringify(shellConfig)}`); + console.log(`[HookRunner] command: ${command}`); + console.log(`[HookRunner] cwd: ${input.cwd}`); + } + // Set up environment variables const env = { ...sanitizeEnvironment(process.env, this.config.sanitizationConfig), @@ -338,6 +344,12 @@ export class HookRunner { clearTimeout(timeoutHandle); const duration = Date.now() - startTime; + if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') { + console.log(`[HookRunner] Hook closed. exitCode: ${exitCode}, duration: ${duration}ms`); + console.log(`[HookRunner] stdout: ${stdout}`); + console.log(`[HookRunner] stderr: ${stderr}`); + } + if (timedOut) { resolve({ hookConfig, diff --git a/packages/test-utils/src/test-rig.ts b/packages/test-utils/src/test-rig.ts index 273c22d5ac..91fd62722e 100644 --- a/packages/test-utils/src/test-rig.ts +++ b/packages/test-utils/src/test-rig.ts @@ -1253,6 +1253,11 @@ export class TestRig { }[] = []; for (const logData of parsedLogs) { + if (env['VERBOSE'] === 'true' || env['CI'] === 'true') { + if (logData.attributes?.['event.name']?.includes('tool')) { + console.log(`[TestRig] Found tool-related log: ${JSON.stringify(logData.attributes)}`); + } + } // Look for tool call logs if ( logData.attributes && @@ -1410,6 +1415,11 @@ export class TestRig { }[] = []; for (const logData of parsedLogs) { + if (env['VERBOSE'] === 'true' || env['CI'] === 'true') { + if (logData.attributes?.['event.name']?.includes('hook')) { + console.log(`[TestRig] Found hook-related log: ${JSON.stringify(logData.attributes)}`); + } + } // Look for tool call logs if ( logData.attributes &&