diff --git a/test/hosts/codex/hooks.test.js b/test/hosts/codex/hooks.test.js index 8984ccb..0ab038f 100644 --- a/test/hosts/codex/hooks.test.js +++ b/test/hosts/codex/hooks.test.js @@ -217,9 +217,12 @@ test('the session end distills its candidate through codex exec, headless, on th await waitFor(() => !pending()['s-done']); }); -test('inside the headless run every hook answers {} and writes nothing', posix, async () => { +test('inside the headless run every hook answers {} and writes nothing', posix, async (t) => { + // Earlier hooks may still be delivering reports; this Proxy sees only the headless hooks under test. + const proxy = await fakeProxy(); + t.after(() => closeWhenSettled(proxy)); const before = proxy.requests.length; - const headless = { ...env, EVOLVER_HEADLESS: '1', HOME: join(proxy.env.HOME, 'headless-home') }; + const headless = { ...env, ...proxy.env, PATH: env.PATH, EVOLVER_HEADLESS: '1', HOME: join(proxy.env.HOME, 'headless-home') }; const payload = { ...PAYLOADS.UserPromptSubmit, session_id: 's-headless', cwd: project, prompt: PROMPT }; assert.deepEqual(await runHook('UserPromptSubmit', payload, headless), {}); assert.deepEqual(await runHook('Stop', { ...PAYLOADS.Stop, session_id: 's-headless' }, headless), {}); diff --git a/test/hosts/grok/hooks.test.js b/test/hosts/grok/hooks.test.js index cbf1fef..ed78bb6 100644 --- a/test/hosts/grok/hooks.test.js +++ b/test/hosts/grok/hooks.test.js @@ -280,9 +280,12 @@ test('the session end distills its candidate through grok -p, headless, in an em await waitFor(() => !pending()['s-done']); }); -test('inside the headless run every hook answers {} and writes nothing', posix, async () => { +test('inside the headless run every hook answers {} and writes nothing', posix, async (t) => { + // Earlier hooks may still be delivering reports to the shared Proxy. + const proxy = await fakeProxy(); + t.after(() => closeWhenSettled(proxy)); const before = proxy.requests.length; - const headless = { ...env, EVOLVER_HEADLESS: '1', HOME: join(proxy.env.HOME, 'headless-home') }; + const headless = { ...env, ...proxy.env, PATH: env.PATH, EVOLVER_HEADLESS: '1', HOME: join(proxy.env.HOME, 'headless-home') }; const base = { sessionId: 's-headless', session_id: 's-headless', cwd: project }; assert.deepEqual(await answerOf('UserPromptSubmit', { ...PAYLOADS.UserPromptSubmit, ...base, prompt: PROMPT }, headless), {}); assert.deepEqual(await answerOf('PostToolUse', { ...PAYLOADS['PostToolUse.read_file'], ...base }, headless), {}); diff --git a/test/hosts/qoder/hooks.test.js b/test/hosts/qoder/hooks.test.js index 351409d..eae7d07 100644 --- a/test/hosts/qoder/hooks.test.js +++ b/test/hosts/qoder/hooks.test.js @@ -247,9 +247,12 @@ test('the session end distills its candidate through qodercli in print mode, hea await waitFor(() => !pending()['s-done']); }); -test('inside the headless run every hook answers {} and writes nothing', posix, async () => { +test('inside the headless run every hook answers {} and writes nothing', posix, async (t) => { + // Earlier hooks may still be delivering reports to the shared Proxy. + const proxy = await fakeProxy(); + t.after(() => closeWhenSettled(proxy)); const before = proxy.requests.length; - const headless = { ...env, EVOLVER_HEADLESS: '1', HOME: join(proxy.env.HOME, 'headless-home') }; + const headless = { ...env, ...proxy.env, PATH: env.PATH, EVOLVER_HEADLESS: '1', HOME: join(proxy.env.HOME, 'headless-home') }; const payload = { ...PAYLOADS.UserPromptSubmit, session_id: 's-headless', cwd: project, prompt: PROMPT }; assert.deepEqual(await runHook('UserPromptSubmit', payload, headless), {}); assert.deepEqual(await runHook('Stop', { ...PAYLOADS.Stop, session_id: 's-headless' }, headless), {}); diff --git a/test/hosts/workbuddy/installed.test.js b/test/hosts/workbuddy/installed.test.js index 626db40..d062e04 100644 --- a/test/hosts/workbuddy/installed.test.js +++ b/test/hosts/workbuddy/installed.test.js @@ -163,14 +163,17 @@ test('an interrupted turn is reported aborted and leaves no candidate; a command assert.equal(pending()['s-kept'].turn, 1, 'the command turn neither replaced nor dropped the candidate'); }); -test('inside the headless distillation run every hook answers {} and writes nothing', posix, async () => { +test('inside the headless distillation run every hook answers {} and writes nothing', posix, async (t) => { + // Earlier hooks may still be delivering reports; this Proxy sees only the headless hooks under test. + const proxy = await fakeProxy(); + t.after(() => proxy.close()); const before = proxy.requests.length; const s = session('s-headless'); - const env = { ...hookEnv, EVOLVER_HEADLESS: '1', CODEBUDDY_PLUGIN_DATA: join(home, 'headless-data') }; + const env = { ...hookEnv, ...proxy.env, PATH: hookEnv.PATH, EVOLVER_HEADLESS: '1', CODEBUDDY_PLUGIN_DATA: join(proxy.env.HOME, 'headless-data') }; assert.deepEqual(await runHook('UserPromptSubmit', { ...PAYLOADS.UserPromptSubmit, session_id: 's-headless', transcript_path: s.transcript, prompt: PROMPT }, env), {}); assert.deepEqual(await runHook('FinalStop', { ...PAYLOADS.FinalStop, session_id: 's-headless', transcript_path: s.transcript }, env), {}); assert.equal(proxy.requests.length, before); - assert.equal(existsSync(join(home, 'headless-data')), false); + assert.equal(existsSync(join(proxy.env.HOME, 'headless-data')), false); }); test('the commands answer from the plugin data folder their script line names', posix, async () => {