Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/hosts/codex/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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), {});
Expand Down
7 changes: 5 additions & 2 deletions test/hosts/grok/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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), {});
Expand Down
7 changes: 5 additions & 2 deletions test/hosts/qoder/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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), {});
Expand Down
9 changes: 6 additions & 3 deletions test/hosts/workbuddy/installed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading