@nightloom/isy 1.0.6-next.0 → 1.0.7-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/agents/codex-records.js +10 -1
- package/dist/agents/codex-records.js.map +1 -1
- package/dist/commands/commit.js +21 -1
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/upload.d.ts +1 -0
- package/dist/commands/upload.js +13 -5
- package/dist/commands/upload.js.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/parser.js +1 -0
- package/dist/parser.js.map +1 -1
- package/dist/redact.js +12 -5
- package/dist/redact.js.map +1 -1
- package/dist/subagents.js +7 -5
- package/dist/subagents.js.map +1 -1
- package/package.json +3 -2
- package/src/agents/codex-records.ts +10 -1
- package/src/commands/commit.ts +22 -1
- package/src/commands/upload.ts +13 -6
- package/src/index.ts +8 -2
- package/src/parser.ts +1 -0
- package/src/redact.ts +13 -5
- package/src/subagents.ts +7 -5
- package/dist/test/analyze.test.d.ts +0 -1
- package/dist/test/analyze.test.js +0 -412
- package/dist/test/analyze.test.js.map +0 -1
- package/dist/test/check.test.d.ts +0 -1
- package/dist/test/check.test.js +0 -215
- package/dist/test/check.test.js.map +0 -1
- package/dist/test/cli.test.d.ts +0 -1
- package/dist/test/cli.test.js +0 -142
- package/dist/test/cli.test.js.map +0 -1
- package/dist/test/codex.test.d.ts +0 -1
- package/dist/test/codex.test.js +0 -666
- package/dist/test/codex.test.js.map +0 -1
- package/dist/test/commit.test.d.ts +0 -1
- package/dist/test/commit.test.js +0 -1898
- package/dist/test/commit.test.js.map +0 -1
- package/dist/test/e2e-harness.test.d.ts +0 -1
- package/dist/test/e2e-harness.test.js +0 -53
- package/dist/test/e2e-harness.test.js.map +0 -1
- package/dist/test/git.test.d.ts +0 -1
- package/dist/test/git.test.js +0 -145
- package/dist/test/git.test.js.map +0 -1
- package/dist/test/health.test.d.ts +0 -1
- package/dist/test/health.test.js +0 -156
- package/dist/test/health.test.js.map +0 -1
- package/dist/test/hook.test.d.ts +0 -1
- package/dist/test/hook.test.js +0 -343
- package/dist/test/hook.test.js.map +0 -1
- package/dist/test/init.test.d.ts +0 -1
- package/dist/test/init.test.js +0 -162
- package/dist/test/init.test.js.map +0 -1
- package/dist/test/kimi-cli.test.d.ts +0 -1
- package/dist/test/kimi-cli.test.js +0 -231
- package/dist/test/kimi-cli.test.js.map +0 -1
- package/dist/test/kimi-code.test.d.ts +0 -1
- package/dist/test/kimi-code.test.js +0 -302
- package/dist/test/kimi-code.test.js.map +0 -1
- package/dist/test/kimi-config.test.d.ts +0 -1
- package/dist/test/kimi-config.test.js +0 -246
- package/dist/test/kimi-config.test.js.map +0 -1
- package/dist/test/kimi-hook.test.d.ts +0 -1
- package/dist/test/kimi-hook.test.js +0 -163
- package/dist/test/kimi-hook.test.js.map +0 -1
- package/dist/test/kimi-listing.test.d.ts +0 -1
- package/dist/test/kimi-listing.test.js +0 -233
- package/dist/test/kimi-listing.test.js.map +0 -1
- package/dist/test/kimi.test.d.ts +0 -1
- package/dist/test/kimi.test.js +0 -418
- package/dist/test/kimi.test.js.map +0 -1
- package/dist/test/mask-paths.test.d.ts +0 -1
- package/dist/test/mask-paths.test.js +0 -275
- package/dist/test/mask-paths.test.js.map +0 -1
- package/dist/test/notes.test.d.ts +0 -1
- package/dist/test/notes.test.js +0 -41
- package/dist/test/notes.test.js.map +0 -1
- package/dist/test/pairing.test.d.ts +0 -1
- package/dist/test/pairing.test.js +0 -138
- package/dist/test/pairing.test.js.map +0 -1
- package/dist/test/parser.test.d.ts +0 -1
- package/dist/test/parser.test.js +0 -1041
- package/dist/test/parser.test.js.map +0 -1
- package/dist/test/plan.test.d.ts +0 -1
- package/dist/test/plan.test.js +0 -35
- package/dist/test/plan.test.js.map +0 -1
- package/dist/test/redact.test.d.ts +0 -1
- package/dist/test/redact.test.js +0 -3053
- package/dist/test/redact.test.js.map +0 -1
- package/dist/test/settings.test.d.ts +0 -1
- package/dist/test/settings.test.js +0 -32
- package/dist/test/settings.test.js.map +0 -1
- package/dist/test/stage0.test.d.ts +0 -1
- package/dist/test/stage0.test.js +0 -1304
- package/dist/test/stage0.test.js.map +0 -1
- package/dist/test/subagents.test.d.ts +0 -1
- package/dist/test/subagents.test.js +0 -290
- package/dist/test/subagents.test.js.map +0 -1
- package/dist/test/sweep.test.d.ts +0 -1
- package/dist/test/sweep.test.js +0 -434
- package/dist/test/sweep.test.js.map +0 -1
- package/dist/test/update.test.d.ts +0 -1
- package/dist/test/update.test.js +0 -26
- package/dist/test/update.test.js.map +0 -1
- package/dist/test/upload.test.d.ts +0 -1
- package/dist/test/upload.test.js +0 -393
- package/dist/test/upload.test.js.map +0 -1
package/dist/test/codex.test.js
DELETED
|
@@ -1,666 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { execFile } from "node:child_process";
|
|
3
|
-
import { mkdir, mkdtemp, readFile, realpath, writeFile } from "node:fs/promises";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { after, before, beforeEach, test } from "node:test";
|
|
7
|
-
import { promisify } from "node:util";
|
|
8
|
-
import { detectAgent } from "../agents/index.js";
|
|
9
|
-
import { codexAgent, codexHooksPath, codexSessionsDir } from "../agents/codex.js";
|
|
10
|
-
import { isCodexTranscript, parseApplyPatch, toClaudeRecords } from "../agents/codex-records.js";
|
|
11
|
-
import { collectStatus, formatStatus } from "../commands/status.js";
|
|
12
|
-
import { detectAbandonedApproach } from "../detectors.js";
|
|
13
|
-
import { parseLines } from "../parser.js";
|
|
14
|
-
import { pendingAlertPath } from "../paths.js";
|
|
15
|
-
const saved = {
|
|
16
|
-
codex: process.env.CODEX_HOME,
|
|
17
|
-
isy: process.env.ISY_HOME,
|
|
18
|
-
claude: process.env.CLAUDE_CONFIG_DIR,
|
|
19
|
-
kimi: process.env.KIMI_HOME,
|
|
20
|
-
};
|
|
21
|
-
let home;
|
|
22
|
-
let isy;
|
|
23
|
-
before(async () => {
|
|
24
|
-
home = await mkdtemp(join(tmpdir(), "isy-codex-"));
|
|
25
|
-
isy = await mkdtemp(join(tmpdir(), "isy-codex-home-"));
|
|
26
|
-
process.env.CODEX_HOME = home;
|
|
27
|
-
process.env.ISY_HOME = isy;
|
|
28
|
-
// These assertions are about Codex, so pin the other CLIs somewhere that does
|
|
29
|
-
// not exist: whether this machine has them installed must not change them.
|
|
30
|
-
process.env.CLAUDE_CONFIG_DIR = join(home, "no-claude-here");
|
|
31
|
-
process.env.KIMI_HOME = join(home, "no-kimi-here");
|
|
32
|
-
});
|
|
33
|
-
after(() => {
|
|
34
|
-
if (saved.codex === undefined)
|
|
35
|
-
delete process.env.CODEX_HOME;
|
|
36
|
-
else
|
|
37
|
-
process.env.CODEX_HOME = saved.codex;
|
|
38
|
-
if (saved.isy === undefined)
|
|
39
|
-
delete process.env.ISY_HOME;
|
|
40
|
-
else
|
|
41
|
-
process.env.ISY_HOME = saved.isy;
|
|
42
|
-
if (saved.claude === undefined)
|
|
43
|
-
delete process.env.CLAUDE_CONFIG_DIR;
|
|
44
|
-
else
|
|
45
|
-
process.env.CLAUDE_CONFIG_DIR = saved.claude;
|
|
46
|
-
if (saved.kimi === undefined)
|
|
47
|
-
delete process.env.KIMI_HOME;
|
|
48
|
-
else
|
|
49
|
-
process.env.KIMI_HOME = saved.kimi;
|
|
50
|
-
});
|
|
51
|
-
const json = (value) => JSON.stringify(value);
|
|
52
|
-
const META = {
|
|
53
|
-
type: "session_meta",
|
|
54
|
-
timestamp: "2026-08-20T10:00:00Z",
|
|
55
|
-
payload: {
|
|
56
|
-
session_id: "sess-1",
|
|
57
|
-
cwd: "/repo",
|
|
58
|
-
cli_version: "0.145.0",
|
|
59
|
-
base_instructions: { text: "You are Codex." },
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
const item = (payload) => ({ type: "response_item", timestamp: "2026-08-20T10:00:01Z", payload });
|
|
63
|
-
const say = (role, text) => item({ type: "message", role, content: [{ type: role === "user" ? "input_text" : "output_text", text }] });
|
|
64
|
-
const exec = (callId, cmd) => item({ type: "function_call", name: "exec_command", call_id: callId, arguments: json({ cmd }) });
|
|
65
|
-
const execOut = (callId, output) => item({ type: "function_call_output", call_id: callId, output });
|
|
66
|
-
const patch = (callId, input) => item({ type: "custom_tool_call", name: "apply_patch", call_id: callId, input });
|
|
67
|
-
function convert(lines) {
|
|
68
|
-
return parseLines(toClaudeRecords(lines.map(json)));
|
|
69
|
-
}
|
|
70
|
-
test("recognises a Codex rollout by its session_meta line", () => {
|
|
71
|
-
assert.equal(isCodexTranscript(json(META)), true);
|
|
72
|
-
assert.equal(isCodexTranscript(json({ role: "_system_prompt" })), false);
|
|
73
|
-
assert.equal(isCodexTranscript(json({ type: "user", uuid: "a" })), false);
|
|
74
|
-
assert.equal(isCodexTranscript("not json at all"), false);
|
|
75
|
-
assert.equal(isCodexTranscript(""), false);
|
|
76
|
-
});
|
|
77
|
-
test("takes the session identity off session_meta and drops its system prompt", () => {
|
|
78
|
-
const session = convert([META, say("user", "add a flag")]);
|
|
79
|
-
assert.equal(session.sessionId, "sess-1");
|
|
80
|
-
assert.equal(session.meta.cwd, "/repo");
|
|
81
|
-
assert.equal(session.meta.claudeVersion, "0.145.0");
|
|
82
|
-
// session_meta is bookkeeping, not a turn.
|
|
83
|
-
assert.equal(session.records.length, 1);
|
|
84
|
-
assert.doesNotMatch(session.records.map((r) => json(r)).join(""), /You are Codex/);
|
|
85
|
-
});
|
|
86
|
-
test("turns a shell call and its output into a Bash tool use", () => {
|
|
87
|
-
const session = convert([
|
|
88
|
-
META,
|
|
89
|
-
say("user", "run the tests"),
|
|
90
|
-
exec("call-1", "npm test"),
|
|
91
|
-
execOut("call-1", "2 passing"),
|
|
92
|
-
]);
|
|
93
|
-
assert.equal(session.toolUses.length, 1);
|
|
94
|
-
assert.equal(session.toolUses[0]?.name, "Bash");
|
|
95
|
-
assert.equal(session.toolUses[0]?.input.command, "npm test");
|
|
96
|
-
assert.equal(session.toolUses[0]?.result?.text, "2 passing");
|
|
97
|
-
});
|
|
98
|
-
test("reads the shell command out of an exec harness script", () => {
|
|
99
|
-
const script = 'const r = await tools.exec_command({cmd:"rg -n \\"todo\\" src", workdir:"/repo"}); text(r.output);\n';
|
|
100
|
-
const session = convert([
|
|
101
|
-
META,
|
|
102
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
103
|
-
]);
|
|
104
|
-
assert.equal(session.toolUses[0]?.name, "Bash");
|
|
105
|
-
assert.equal(session.toolUses[0]?.input.command, 'rg -n "todo" src');
|
|
106
|
-
});
|
|
107
|
-
test("keeps a harness script that runs no shell command under its own name", () => {
|
|
108
|
-
const session = convert([
|
|
109
|
-
META,
|
|
110
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: "text(ALL_TOOLS.length);" }),
|
|
111
|
-
]);
|
|
112
|
-
// Still a tool use, just not one the shell detectors should ever see.
|
|
113
|
-
assert.equal(session.toolUses[0]?.name, "exec");
|
|
114
|
-
assert.equal(session.meta.editToolUses, 0);
|
|
115
|
-
});
|
|
116
|
-
test("reads every call an exec harness script makes, edits included", () => {
|
|
117
|
-
const patch = "*** Begin Patch\n*** Update File: src/cache.ts\n@@\n-const ttl = 1;\n+const ttl = 60;\n*** End Patch\n";
|
|
118
|
-
const script = [
|
|
119
|
-
'const a = await tools.exec_command({cmd:"rg -n ttl src"});',
|
|
120
|
-
`await tools.apply_patch(${JSON.stringify(patch)});`,
|
|
121
|
-
'const b = await tools.exec_command({cmd:"npm test", workdir:"/repo"});',
|
|
122
|
-
"text(b.output);",
|
|
123
|
-
].join("\n");
|
|
124
|
-
const session = convert([
|
|
125
|
-
META,
|
|
126
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
127
|
-
]);
|
|
128
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["Bash", "MultiEdit", "Bash"]);
|
|
129
|
-
assert.equal(session.toolUses[2]?.input.command, "npm test");
|
|
130
|
-
assert.equal(session.meta.editToolUses, 1);
|
|
131
|
-
const edits = [...session.fileEdits.entries()].find(([path]) => path.endsWith("src/cache.ts"))?.[1];
|
|
132
|
-
assert.equal(edits?.[0]?.newString, "const ttl = 60;");
|
|
133
|
-
assert.equal(session.meta.hasFileEdits, true);
|
|
134
|
-
});
|
|
135
|
-
test("reads a patch the script binds to a const before applying it", () => {
|
|
136
|
-
// The shape Codex 0.154 writes: the patch on one line, the call on the next.
|
|
137
|
-
const patch = "*** Begin Patch\n*** Update File: src/cache.ts\n@@\n-const ttl = 1;\n+const ttl = 60;\n*** End Patch\n";
|
|
138
|
-
const script = `const patch = ${JSON.stringify(patch)};\ntext(await tools.apply_patch(patch));\n`;
|
|
139
|
-
const session = convert([
|
|
140
|
-
META,
|
|
141
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
142
|
-
]);
|
|
143
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["MultiEdit"]);
|
|
144
|
-
assert.equal(session.meta.editToolUses, 1);
|
|
145
|
-
});
|
|
146
|
-
test("a patch section holding only context is no edit, so repeating it is no revert", () => {
|
|
147
|
-
const patch = "*** Begin Patch\n*** Update File: src/a.ts\n@@\n-const a = 1;\n+const a = 2;\n@@\n export function set() {\n*** End Patch\n";
|
|
148
|
-
const session = convert([
|
|
149
|
-
META,
|
|
150
|
-
item({ type: "custom_tool_call", name: "apply_patch", call_id: "call-1", input: patch }),
|
|
151
|
-
item({ type: "custom_tool_call", name: "apply_patch", call_id: "call-2", input: patch }),
|
|
152
|
-
]);
|
|
153
|
-
const edits = [...session.fileEdits.values()].flat();
|
|
154
|
-
assert.equal(edits.length, 2);
|
|
155
|
-
assert.ok(edits.every((edit) => edit.oldString !== edit.newString));
|
|
156
|
-
assert.deepEqual(detectAbandonedApproach(session), []);
|
|
157
|
-
});
|
|
158
|
-
test("leaves a patch name unread when the script binds it with let or twice", () => {
|
|
159
|
-
const patch = JSON.stringify("*** Begin Patch\n*** Update File: src/a.ts\n@@\n-a\n+b\n*** End Patch\n");
|
|
160
|
-
for (const script of [
|
|
161
|
-
`let patch = ${patch};\nawait tools.apply_patch(patch);`,
|
|
162
|
-
`const patch = ${patch};\n{ const patch = ${patch}; }\nawait tools.apply_patch(patch);`,
|
|
163
|
-
]) {
|
|
164
|
-
const session = convert([
|
|
165
|
-
META,
|
|
166
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
167
|
-
]);
|
|
168
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["exec"], script);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
test("keeps the harness in view when a call's argument cannot be read", () => {
|
|
172
|
-
const script = `const r = await tools.exec_command({cmd:"sed -n '" + range + "p' src/a.ts"}); text(r.output);`;
|
|
173
|
-
const session = convert([
|
|
174
|
-
META,
|
|
175
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
176
|
-
]);
|
|
177
|
-
// Half a command would lie to the shell detectors; the script stays an unknown
|
|
178
|
-
// tool instead, which still lets the session through the no-edits gate.
|
|
179
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["exec"]);
|
|
180
|
-
assert.equal(session.meta.hasFileEdits, true);
|
|
181
|
-
});
|
|
182
|
-
test("accepts the argv form older builds send", () => {
|
|
183
|
-
const session = convert([
|
|
184
|
-
META,
|
|
185
|
-
item({
|
|
186
|
-
type: "function_call",
|
|
187
|
-
name: "shell",
|
|
188
|
-
call_id: "call-1",
|
|
189
|
-
arguments: json({ command: ["bash", "-lc", "git status"] }),
|
|
190
|
-
}),
|
|
191
|
-
]);
|
|
192
|
-
assert.equal(session.toolUses[0]?.name, "Bash");
|
|
193
|
-
assert.equal(session.toolUses[0]?.input.command, "git status");
|
|
194
|
-
});
|
|
195
|
-
test("an argv that is not a shell wrapper is the whole command", () => {
|
|
196
|
-
const session = convert([
|
|
197
|
-
META,
|
|
198
|
-
item({
|
|
199
|
-
type: "function_call",
|
|
200
|
-
name: "shell",
|
|
201
|
-
call_id: "call-1",
|
|
202
|
-
arguments: json({ command: ["sed", "-n", "1,200p", "src/cache.ts"] }),
|
|
203
|
-
}),
|
|
204
|
-
]);
|
|
205
|
-
assert.equal(session.toolUses[0]?.input.command, "sed -n 1,200p src/cache.ts");
|
|
206
|
-
});
|
|
207
|
-
test("reads the quoted-key cmd out of an exec harness script", () => {
|
|
208
|
-
const script = 'const r = await tools.exec_command({"cmd":"ls -la","workdir":"/repo"}); text(r.output);';
|
|
209
|
-
const session = convert([
|
|
210
|
-
META,
|
|
211
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
212
|
-
]);
|
|
213
|
-
assert.equal(session.toolUses[0]?.name, "Bash");
|
|
214
|
-
assert.equal(session.toolUses[0]?.input.command, "ls -la");
|
|
215
|
-
});
|
|
216
|
-
test("an exec script is read call by call, patches included", () => {
|
|
217
|
-
// Codex 0.154: one harness script, several tools, the patch among them.
|
|
218
|
-
const script = [
|
|
219
|
-
'const patched = await tools.apply_patch("*** Begin Patch\\n*** Update File: src/cache.ts\\n@@\\n- return store.get(key);\\n+ return remote.fetch(key);\\n*** End Patch");',
|
|
220
|
-
"text(patched);",
|
|
221
|
-
'text(await tools.exec_command({cmd:"npm test", yield_time_ms:10000}));',
|
|
222
|
-
'text(await tools.exec_command({"cmd":"rm -rf dist"}));',
|
|
223
|
-
].join("\n");
|
|
224
|
-
const session = convert([
|
|
225
|
-
META,
|
|
226
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: script }),
|
|
227
|
-
item({
|
|
228
|
-
type: "custom_tool_call_output",
|
|
229
|
-
call_id: "call-1",
|
|
230
|
-
output: [
|
|
231
|
-
{ type: "input_text", text: "Script completed\nWall time 1.2 seconds\nOutput:\n" },
|
|
232
|
-
{ type: "input_text", text: "Done!" },
|
|
233
|
-
{ type: "input_text", text: json({ exit_code: 1, output: 'npm ERR! "exit_code":0' }) },
|
|
234
|
-
{ type: "input_text", text: json({ exit_code: 0, output: "" }) },
|
|
235
|
-
],
|
|
236
|
-
}),
|
|
237
|
-
]);
|
|
238
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["MultiEdit", "Bash", "Bash"]);
|
|
239
|
-
assert.equal(session.toolUses[1]?.input.command, "npm test");
|
|
240
|
-
assert.equal(session.toolUses[2]?.input.command, "rm -rf dist");
|
|
241
|
-
assert.equal(session.meta.editToolUses, 1);
|
|
242
|
-
assert.ok(session.fileEdits.has("src/cache.ts"));
|
|
243
|
-
// One result for the whole script, on its first command; one failing command fails it.
|
|
244
|
-
assert.equal(session.toolUses[1]?.id, "call-1");
|
|
245
|
-
assert.equal(session.toolUses[1]?.result?.isError, true);
|
|
246
|
-
assert.equal(session.toolUses[0]?.result, undefined);
|
|
247
|
-
});
|
|
248
|
-
test("an exec script whose commands all pass is not an error", () => {
|
|
249
|
-
const session = convert([
|
|
250
|
-
META,
|
|
251
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: 'text(await tools.exec_command({cmd:"ls"}));' }),
|
|
252
|
-
item({
|
|
253
|
-
type: "custom_tool_call_output",
|
|
254
|
-
call_id: "call-1",
|
|
255
|
-
output: [{ type: "input_text", text: json({ exit_code: 0, output: '{"exit_code":1}' }) }],
|
|
256
|
-
}),
|
|
257
|
-
]);
|
|
258
|
-
assert.equal(session.toolUses[0]?.result?.isError, false);
|
|
259
|
-
});
|
|
260
|
-
test("a script that outran its yield takes its exit code from the wait that finished it", () => {
|
|
261
|
-
const running = (text) => [{ type: "input_text", text }];
|
|
262
|
-
const session = convert([
|
|
263
|
-
META,
|
|
264
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: 'text(await tools.exec_command({cmd:"npm test"}));' }),
|
|
265
|
-
item({ type: "custom_tool_call_output", call_id: "call-1", output: "Script running with cell ID 5\nWall time 31.0 seconds\nOutput:\n" }),
|
|
266
|
-
item({ type: "function_call", name: "wait", call_id: "call-2", arguments: json({ cell_id: "5", yield_time_ms: 1000 }) }),
|
|
267
|
-
item({ type: "function_call_output", call_id: "call-2", output: running("Script running with cell ID 5\nWall time 30.0 seconds\nOutput:\n") }),
|
|
268
|
-
item({ type: "function_call", name: "wait", call_id: "call-3", arguments: json({ cell_id: "5", yield_time_ms: 1000 }) }),
|
|
269
|
-
item({
|
|
270
|
-
type: "function_call_output",
|
|
271
|
-
call_id: "call-3",
|
|
272
|
-
output: [
|
|
273
|
-
{ type: "input_text", text: "Script completed\nWall time 0.0 seconds\nOutput:\n" },
|
|
274
|
-
{ type: "input_text", text: json({ exit_code: 1, output: "1 failed" }) },
|
|
275
|
-
],
|
|
276
|
-
}),
|
|
277
|
-
]);
|
|
278
|
-
// The waits are how the result arrived, not tools of their own.
|
|
279
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["Bash"]);
|
|
280
|
-
assert.equal(session.toolUses[0]?.result?.isError, true);
|
|
281
|
-
assert.match(session.toolUses[0]?.result?.text ?? "", /1 failed/);
|
|
282
|
-
});
|
|
283
|
-
test("a command that outran its yield takes its exit code from the write_stdin poll that finished it", () => {
|
|
284
|
-
const output = (body) => `Script completed\nWall time 5.0 seconds\nOutput:\n\n${json(body)}`;
|
|
285
|
-
const session = convert([
|
|
286
|
-
META,
|
|
287
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: 'text(await tools.exec_command({cmd:"npm test", yield_time_ms:1000}));' }),
|
|
288
|
-
item({ type: "custom_tool_call_output", call_id: "call-1", output: output({ session_id: 20794, output: "running" }) }),
|
|
289
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-2", input: 'text(await tools.write_stdin({session_id:20794,chars:"","yield_time_ms":1000}));' }),
|
|
290
|
-
item({ type: "custom_tool_call_output", call_id: "call-2", output: output({ session_id: 20794, output: "" }) }),
|
|
291
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-3", input: 'text(await tools.write_stdin({session_id:20794,chars:""}));' }),
|
|
292
|
-
item({ type: "custom_tool_call_output", call_id: "call-3", output: output({ exit_code: 1, output: "1 failed" }) }),
|
|
293
|
-
]);
|
|
294
|
-
// The polls are how the result arrived, not tools of their own.
|
|
295
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["Bash"]);
|
|
296
|
-
assert.equal(session.toolUses[0]?.result?.isError, true);
|
|
297
|
-
assert.match(session.toolUses[0]?.result?.text ?? "", /1 failed/);
|
|
298
|
-
// A shell this rollout never started has nothing to fold into.
|
|
299
|
-
const unknown = convert([
|
|
300
|
-
META,
|
|
301
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: 'text(await tools.write_stdin({session_id:7,chars:""}));' }),
|
|
302
|
-
]);
|
|
303
|
-
assert.deepEqual(unknown.toolUses.map((use) => use.name), ["exec"]);
|
|
304
|
-
});
|
|
305
|
-
test("a wait on a cell the rollout never started stays a tool that edits nothing", () => {
|
|
306
|
-
const session = convert([
|
|
307
|
-
META,
|
|
308
|
-
item({ type: "function_call", name: "wait", call_id: "call-1", arguments: json({ cell_id: "9" }) }),
|
|
309
|
-
item({ type: "function_call_output", call_id: "call-1", output: "Script completed\nOutput:\n" }),
|
|
310
|
-
]);
|
|
311
|
-
assert.deepEqual(session.toolUses.map((use) => use.name), ["wait"]);
|
|
312
|
-
assert.equal(session.meta.hasFileEdits, false);
|
|
313
|
-
});
|
|
314
|
-
test("a script that only searches the web or looks at an image edits nothing", () => {
|
|
315
|
-
const looking = convert([
|
|
316
|
-
META,
|
|
317
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: 'text(await tools.web__run({search_query:[{q:"heleket api"}]}));' }),
|
|
318
|
-
item({
|
|
319
|
-
type: "custom_tool_call",
|
|
320
|
-
name: "exec",
|
|
321
|
-
call_id: "call-2",
|
|
322
|
-
input: 'await tools.view_image({path:"shot.png"}); await tools.image_gen__imagegen({prompt:"logo"});',
|
|
323
|
-
}),
|
|
324
|
-
]);
|
|
325
|
-
assert.deepEqual(looking.toolUses.map((use) => use.name), ["web__run", "view_image", "image_gen__imagegen"]);
|
|
326
|
-
assert.equal(looking.meta.hasFileEdits, false);
|
|
327
|
-
// Typing into a running shell can write anything, so that one still may have edited.
|
|
328
|
-
const typing = convert([
|
|
329
|
-
META,
|
|
330
|
-
item({ type: "custom_tool_call", name: "exec", call_id: "call-1", input: 'await tools.write_stdin({session_id:1, chars:"y\\n"});' }),
|
|
331
|
-
]);
|
|
332
|
-
assert.deepEqual(typing.toolUses.map((use) => use.name), ["exec"]);
|
|
333
|
-
assert.equal(typing.meta.hasFileEdits, true);
|
|
334
|
-
});
|
|
335
|
-
test("a local_shell_call carries its command under action.command", () => {
|
|
336
|
-
const session = convert([
|
|
337
|
-
META,
|
|
338
|
-
item({
|
|
339
|
-
type: "local_shell_call",
|
|
340
|
-
id: "call-1",
|
|
341
|
-
action: { type: "exec", command: ["bash", "-lc", "npm test"] },
|
|
342
|
-
status: "completed",
|
|
343
|
-
}),
|
|
344
|
-
item({ type: "function_call_output", call_id: "call-1", output: "2 passing" }),
|
|
345
|
-
]);
|
|
346
|
-
assert.equal(session.toolUses.length, 1);
|
|
347
|
-
assert.equal(session.toolUses[0]?.name, "Bash");
|
|
348
|
-
assert.equal(session.toolUses[0]?.input.command, "npm test");
|
|
349
|
-
assert.equal(session.toolUses[0]?.result?.text, "2 passing");
|
|
350
|
-
});
|
|
351
|
-
test("a non-zero exit code marks the tool result is_error", () => {
|
|
352
|
-
const session = convert([
|
|
353
|
-
META,
|
|
354
|
-
exec("call-1", "npm test"),
|
|
355
|
-
execOut("call-1", "1 failed\nProcess exited with code 1"),
|
|
356
|
-
exec("call-2", "npm test"),
|
|
357
|
-
execOut("call-2", json({ output: "2 passing", metadata: { exit_code: 0 } })),
|
|
358
|
-
exec("call-3", "npm test"),
|
|
359
|
-
execOut("call-3", json({ output: "1 failed", metadata: { exit_code: 1 } })),
|
|
360
|
-
]);
|
|
361
|
-
assert.equal(session.toolUses[0]?.result?.isError, true);
|
|
362
|
-
assert.equal(session.toolUses[1]?.result?.isError, false);
|
|
363
|
-
assert.equal(session.toolUses[2]?.result?.isError, true);
|
|
364
|
-
});
|
|
365
|
-
test("keeps reasoning Codex recorded in the clear and drops what it encrypted", () => {
|
|
366
|
-
const session = convert([
|
|
367
|
-
META,
|
|
368
|
-
item({
|
|
369
|
-
type: "reasoning",
|
|
370
|
-
summary: [{ type: "summary_text", text: "the retry path is still open" }],
|
|
371
|
-
content: null,
|
|
372
|
-
encrypted_content: "gAAAAABsecret",
|
|
373
|
-
}),
|
|
374
|
-
]);
|
|
375
|
-
assert.equal(session.meta.thinkingBlocks, 1);
|
|
376
|
-
assert.match(session.blocks[0]?.text ?? "", /retry path/);
|
|
377
|
-
assert.doesNotMatch(session.records.map((r) => json(r)).join(""), /gAAAAAB/);
|
|
378
|
-
});
|
|
379
|
-
test("a session whose reasoning was never recorded in the clear has no thinking", () => {
|
|
380
|
-
const session = convert([
|
|
381
|
-
META,
|
|
382
|
-
item({ type: "reasoning", summary: [], content: null, encrypted_content: "gAAAAABsecret" }),
|
|
383
|
-
]);
|
|
384
|
-
assert.equal(session.meta.thinkingBlocks, 0);
|
|
385
|
-
assert.equal(session.records.length, 0);
|
|
386
|
-
});
|
|
387
|
-
test("drops developer messages, which are harness context and not the user's work", () => {
|
|
388
|
-
const session = convert([META, say("developer", "## Memory\nprior runs said"), say("user", "go")]);
|
|
389
|
-
assert.equal(session.records.length, 1);
|
|
390
|
-
assert.doesNotMatch(session.records.map((r) => json(r)).join(""), /prior runs said/);
|
|
391
|
-
});
|
|
392
|
-
test("drops the context Codex sends under the user's role, and keeps what the user typed", () => {
|
|
393
|
-
// What Codex 0.14x opens a session with: AGENTS.md, the plugins it suggests
|
|
394
|
-
// and the environment, two parts to a message.
|
|
395
|
-
const parts = (...texts) => item({ type: "message", role: "user", content: texts.map((text) => ({ type: "input_text", text })) });
|
|
396
|
-
const environment = "<environment_context>\n <cwd>/home/alice/repo</cwd>\n <shell>zsh</shell>\n</environment_context>";
|
|
397
|
-
const session = convert([
|
|
398
|
-
META,
|
|
399
|
-
parts("# AGENTS.md instructions for /home/alice/repo\n\n<INSTRUCTIONS>\nUse pnpm.\n</INSTRUCTIONS>", environment),
|
|
400
|
-
parts("<recommended_plugins>\n- github\n</recommended_plugins>", environment),
|
|
401
|
-
say("user", "<user_instructions>\nAlways answer in French.\n</user_instructions>"),
|
|
402
|
-
say("user", "fix the failing test"),
|
|
403
|
-
]);
|
|
404
|
-
assert.equal(session.records.length, 1);
|
|
405
|
-
assert.equal(session.blocks[0]?.text, "fix the failing test");
|
|
406
|
-
});
|
|
407
|
-
test("an apply_patch update becomes an edit the shared parser unpacks per hunk", () => {
|
|
408
|
-
const session = convert([
|
|
409
|
-
META,
|
|
410
|
-
patch("call-1", [
|
|
411
|
-
"*** Begin Patch",
|
|
412
|
-
"*** Update File: src/cache.ts",
|
|
413
|
-
"@@",
|
|
414
|
-
" export function get(key) {",
|
|
415
|
-
"- return store.get(key);",
|
|
416
|
-
"+ return remote.fetch(key);",
|
|
417
|
-
" }",
|
|
418
|
-
"*** End Patch",
|
|
419
|
-
].join("\n")),
|
|
420
|
-
item({ type: "custom_tool_call_output", call_id: "call-1", output: [{ type: "input_text", text: "done" }] }),
|
|
421
|
-
]);
|
|
422
|
-
assert.equal(session.meta.editToolUses, 1);
|
|
423
|
-
assert.equal(session.toolUses[0]?.result?.text, "done");
|
|
424
|
-
const edits = session.fileEdits.get("src/cache.ts");
|
|
425
|
-
assert.equal(edits?.length, 1);
|
|
426
|
-
// Context lines belong to both sides, exactly as an Edit's strings do.
|
|
427
|
-
assert.equal(edits?.[0]?.oldString, "export function get(key) {\n return store.get(key);\n}");
|
|
428
|
-
assert.equal(edits?.[0]?.newString, "export function get(key) {\n return remote.fetch(key);\n}");
|
|
429
|
-
});
|
|
430
|
-
test("parseApplyPatch handles added, deleted and multi-file patches", () => {
|
|
431
|
-
const edits = parseApplyPatch([
|
|
432
|
-
"*** Begin Patch",
|
|
433
|
-
"*** Add File: src/new.ts",
|
|
434
|
-
"+export const a = 1;",
|
|
435
|
-
"+export const b = 2;",
|
|
436
|
-
"*** Update File: src/old.ts",
|
|
437
|
-
"@@",
|
|
438
|
-
"-const x = 1;",
|
|
439
|
-
"+const x = 2;",
|
|
440
|
-
"@@",
|
|
441
|
-
"-const y = 1;",
|
|
442
|
-
"+const y = 2;",
|
|
443
|
-
"*** Delete File: src/gone.ts",
|
|
444
|
-
"*** End Patch",
|
|
445
|
-
].join("\n"));
|
|
446
|
-
assert.deepEqual(edits[0], {
|
|
447
|
-
tool: "Write",
|
|
448
|
-
input: { file_path: "src/new.ts", content: "export const a = 1;\nexport const b = 2;" },
|
|
449
|
-
});
|
|
450
|
-
assert.equal(edits[1]?.tool, "MultiEdit");
|
|
451
|
-
assert.equal(edits[1]?.input.file_path, "src/old.ts");
|
|
452
|
-
assert.equal((edits[1]?.input.edits).length, 2);
|
|
453
|
-
// Nothing records what a deleted file held, so it is an edit with no diff.
|
|
454
|
-
assert.deepEqual(edits[2], { tool: "Edit", input: { file_path: "src/gone.ts" } });
|
|
455
|
-
});
|
|
456
|
-
test("parseApplyPatch reads a patch with Windows line endings", () => {
|
|
457
|
-
const edits = parseApplyPatch(["*** Begin Patch", "*** Update File: src/a.ts", "@@", "-a", "+b", "*** End Patch", ""].join("\r\n"));
|
|
458
|
-
assert.deepEqual(edits, [
|
|
459
|
-
{ tool: "MultiEdit", input: { file_path: "src/a.ts", edits: [{ old_string: "a", new_string: "b" }] } },
|
|
460
|
-
]);
|
|
461
|
-
});
|
|
462
|
-
test("one patch touching several files keeps its result on the first call", () => {
|
|
463
|
-
const session = convert([
|
|
464
|
-
META,
|
|
465
|
-
patch("call-1", [
|
|
466
|
-
"*** Begin Patch",
|
|
467
|
-
"*** Update File: src/a.ts",
|
|
468
|
-
"@@",
|
|
469
|
-
"-a",
|
|
470
|
-
"+b",
|
|
471
|
-
"*** Update File: src/b.ts",
|
|
472
|
-
"@@",
|
|
473
|
-
"-c",
|
|
474
|
-
"+d",
|
|
475
|
-
"*** End Patch",
|
|
476
|
-
].join("\n")),
|
|
477
|
-
item({ type: "custom_tool_call_output", call_id: "call-1", output: "ok" }),
|
|
478
|
-
]);
|
|
479
|
-
assert.equal(session.toolUses.length, 2);
|
|
480
|
-
assert.equal(session.toolUses[0]?.id, "call-1");
|
|
481
|
-
assert.equal(session.toolUses[1]?.id, "call-1#1");
|
|
482
|
-
assert.equal(session.toolUses[0]?.result?.text, "ok");
|
|
483
|
-
assert.ok(session.fileEdits.has("src/a.ts"));
|
|
484
|
-
assert.ok(session.fileEdits.has("src/b.ts"));
|
|
485
|
-
});
|
|
486
|
-
test("survives a malformed rollout line instead of failing the session", () => {
|
|
487
|
-
const records = toClaudeRecords([json(META), "{not json", "", json(say("user", "go"))]);
|
|
488
|
-
assert.equal(records.length, 1);
|
|
489
|
-
});
|
|
490
|
-
async function writeRollout(date, id, lines) {
|
|
491
|
-
const [year, month, day] = date.split("-");
|
|
492
|
-
const dir = join(codexSessionsDir(), year, month, day);
|
|
493
|
-
await mkdir(dir, { recursive: true });
|
|
494
|
-
const path = join(dir, `rollout-${date}T10-00-00-${id}.jsonl`);
|
|
495
|
-
await writeFile(path, `${lines.map(json).join("\n")}\n`);
|
|
496
|
-
return path;
|
|
497
|
-
}
|
|
498
|
-
const metaFor = (cwd, sessionId) => ({
|
|
499
|
-
...META,
|
|
500
|
-
payload: { ...META.payload, session_id: sessionId, cwd },
|
|
501
|
-
});
|
|
502
|
-
test("finds only the sessions recorded for this working directory", async () => {
|
|
503
|
-
const cwd = "/work/codex-project";
|
|
504
|
-
const mine = await writeRollout("2026-08-20", "019dc36a-3ce7-7163-8d38-416ea68327d4", [
|
|
505
|
-
metaFor(cwd, "sess-mine"),
|
|
506
|
-
say("user", "go"),
|
|
507
|
-
]);
|
|
508
|
-
await writeRollout("2026-08-19", "019dc36a-3ce7-7163-8d38-416ea68327d5", [
|
|
509
|
-
metaFor("/work/somewhere-else", "sess-theirs"),
|
|
510
|
-
say("user", "go"),
|
|
511
|
-
]);
|
|
512
|
-
const sessions = await codexAgent.sessionsIn(cwd);
|
|
513
|
-
assert.equal(sessions.length, 1);
|
|
514
|
-
assert.equal(sessions[0]?.path, mine);
|
|
515
|
-
// The id comes off the rollout name, which ends in the session's uuid.
|
|
516
|
-
assert.equal(sessions[0]?.sessionId, "019dc36a-3ce7-7163-8d38-416ea68327d4");
|
|
517
|
-
});
|
|
518
|
-
test("uses the transcript path Codex sends, and the newest session without one", async () => {
|
|
519
|
-
const cwd = "/work/codex-transcript";
|
|
520
|
-
const path = await writeRollout("2026-08-20", "019dc36a-3ce7-7163-8d38-416ea68327d6", [
|
|
521
|
-
metaFor(cwd, "sess-newest"),
|
|
522
|
-
say("user", "go"),
|
|
523
|
-
]);
|
|
524
|
-
assert.equal(await codexAgent.transcriptFor({ transcript_path: "/given/by/codex.jsonl" }, cwd), "/given/by/codex.jsonl");
|
|
525
|
-
assert.equal(await codexAgent.transcriptFor(undefined, cwd), path);
|
|
526
|
-
assert.equal(await codexAgent.transcriptFor(undefined, "/work/nothing-here"), undefined);
|
|
527
|
-
});
|
|
528
|
-
test("status counts Codex sessions and reads the newest one", async () => {
|
|
529
|
-
const cwd = "/work/codex-status";
|
|
530
|
-
await writeRollout("2026-08-20", "019dc36a-3ce7-7163-8d38-416ea68327d7", [
|
|
531
|
-
metaFor(cwd, "sess-status"),
|
|
532
|
-
say("user", "add retries"),
|
|
533
|
-
patch("call-1", "*** Begin Patch\n*** Update File: src/a.ts\n@@\n-a\n+b\n*** End Patch"),
|
|
534
|
-
item({ type: "custom_tool_call_output", call_id: "call-1", output: "ok" }),
|
|
535
|
-
item({ type: "reasoning", summary: [{ type: "summary_text", text: "the timeout path is still open" }] }),
|
|
536
|
-
]);
|
|
537
|
-
const report = await collectStatus(cwd);
|
|
538
|
-
const codex = report.agents.find((agent) => agent.id === "codex");
|
|
539
|
-
assert.equal(codex?.sessions, 1);
|
|
540
|
-
assert.equal(codex?.transcriptDir, codexSessionsDir());
|
|
541
|
-
assert.equal(report.latestSession?.agent, "codex");
|
|
542
|
-
assert.equal(report.latestSession?.editedFiles, 1);
|
|
543
|
-
assert.equal(report.latestSession?.thinkingBlocks, 1);
|
|
544
|
-
assert.match(formatStatus(report), /Codex CLI\s+1 session\(s\)/);
|
|
545
|
-
});
|
|
546
|
-
beforeEach(async () => {
|
|
547
|
-
await writeFile(codexHooksPath(), json({ hooks: {} }));
|
|
548
|
-
});
|
|
549
|
-
test("writes its hooks into hooks.json and takes them out again", async () => {
|
|
550
|
-
assert.equal(await codexAgent.installHooks(), "installed");
|
|
551
|
-
assert.equal(await codexAgent.installHooks(), "already-present");
|
|
552
|
-
const contents = JSON.parse(await readFile(codexHooksPath(), "utf8"));
|
|
553
|
-
assert.equal(contents.hooks.SessionStart?.[0]?.hooks[0]?.command, "npx --prefer-offline --fetch-retries=0 --fetch-timeout=2000 @nightloom/isy check --hook --agent codex");
|
|
554
|
-
// Detached, because Codex is closing the session and the hook shell must not
|
|
555
|
-
// wait; the payload goes over fd 3, because a background job's stdin is /dev/null.
|
|
556
|
-
assert.match(contents.hooks.SessionEnd?.[0]?.hooks[0]?.command ?? "", /^exec 3<&0; nohup npx --fetch-retries=0 --fetch-timeout=2000 @nightloom\/isy upload --hook --agent codex <&3 .*&$/);
|
|
557
|
-
assert.deepEqual(await codexAgent.hooksInstalled(), ["SessionStart", "SessionEnd"]);
|
|
558
|
-
assert.equal(await codexAgent.removeHooks(), "removed");
|
|
559
|
-
assert.equal(await codexAgent.removeHooks(), "absent");
|
|
560
|
-
assert.deepEqual(await codexAgent.hooksInstalled(), []);
|
|
561
|
-
});
|
|
562
|
-
test("replaces an older isy command rather than stacking a second one", async () => {
|
|
563
|
-
for (const older of [
|
|
564
|
-
"npx isy upload --hook --agent codex",
|
|
565
|
-
// Detached, but blind to the payload: it guessed the newest rollout in the cwd.
|
|
566
|
-
"nohup npx isy upload --hook --agent codex >/dev/null 2>&1 </dev/null &",
|
|
567
|
-
// Same command, back when it was reached through npx.
|
|
568
|
-
"exec 3<&0; nohup npx isy upload --hook --agent codex <&3 >/dev/null 2>&1 &",
|
|
569
|
-
// Same command, before npx was told not to wait on the registry.
|
|
570
|
-
"exec 3<&0; nohup npx @nightloom/isy upload --hook --agent codex <&3 >/dev/null 2>&1 &",
|
|
571
|
-
]) {
|
|
572
|
-
await writeFile(codexHooksPath(), json({ hooks: { SessionEnd: [{ hooks: [{ type: "command", command: older }] }] } }));
|
|
573
|
-
assert.equal(await codexAgent.installHooks(), "installed", older);
|
|
574
|
-
const contents = JSON.parse(await readFile(codexHooksPath(), "utf8"));
|
|
575
|
-
assert.equal(contents.hooks.SessionEnd.length, 1, older);
|
|
576
|
-
assert.match(contents.hooks.SessionEnd[0]?.hooks[0]?.command ?? "", /--fetch-retries=0 .*<&3 /, older);
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
test("superseding keeps the user's later groups at their approved positions", async () => {
|
|
580
|
-
// Codex keys approvals by group index, so replacing ISY's old command must
|
|
581
|
-
// not shift the group that follows it.
|
|
582
|
-
await writeFile(codexHooksPath(), json({
|
|
583
|
-
hooks: {
|
|
584
|
-
SessionEnd: [
|
|
585
|
-
{ hooks: [{ type: "command", command: "npx isy upload --hook --agent codex" }] },
|
|
586
|
-
{ matcher: "always", hooks: [{ type: "command", command: "their-hook" }] },
|
|
587
|
-
],
|
|
588
|
-
},
|
|
589
|
-
}));
|
|
590
|
-
assert.equal(await codexAgent.installHooks(), "installed");
|
|
591
|
-
const contents = JSON.parse(await readFile(codexHooksPath(), "utf8"));
|
|
592
|
-
assert.equal(contents.hooks.SessionEnd.length, 2);
|
|
593
|
-
assert.match(contents.hooks.SessionEnd[0]?.hooks[0]?.command ?? "", /<&3 /);
|
|
594
|
-
assert.equal(contents.hooks.SessionEnd[1]?.hooks[0]?.command, "their-hook");
|
|
595
|
-
});
|
|
596
|
-
test("appends after the user's own hooks, never ahead of them", async () => {
|
|
597
|
-
// Codex keys its hook trust ledger by position, so an insert ahead of an
|
|
598
|
-
// existing group would silently untrust hooks the user already approved.
|
|
599
|
-
await writeFile(codexHooksPath(), json({
|
|
600
|
-
hooks: {
|
|
601
|
-
SessionStart: [{ matcher: "startup", hooks: [{ type: "command", command: "their-hook" }] }],
|
|
602
|
-
},
|
|
603
|
-
}));
|
|
604
|
-
await codexAgent.installHooks();
|
|
605
|
-
const contents = JSON.parse(await readFile(codexHooksPath(), "utf8"));
|
|
606
|
-
assert.equal(contents.hooks.SessionStart.length, 2);
|
|
607
|
-
assert.equal(contents.hooks.SessionStart[0]?.hooks[0]?.command, "their-hook");
|
|
608
|
-
});
|
|
609
|
-
test("removing our hooks leaves the user's alone", async () => {
|
|
610
|
-
await writeFile(codexHooksPath(), json({
|
|
611
|
-
hooks: { SessionStart: [{ matcher: "startup", hooks: [{ type: "command", command: "their-hook" }] }] },
|
|
612
|
-
}));
|
|
613
|
-
await codexAgent.installHooks();
|
|
614
|
-
assert.equal(await codexAgent.removeHooks(), "removed");
|
|
615
|
-
const contents = JSON.parse(await readFile(codexHooksPath(), "utf8"));
|
|
616
|
-
assert.equal(contents.hooks.SessionStart.length, 1);
|
|
617
|
-
assert.equal(contents.hooks.SessionStart[0]?.hooks[0]?.command, "their-hook");
|
|
618
|
-
});
|
|
619
|
-
test("parks a SessionEnd line, then shows it at the next SessionStart", async () => {
|
|
620
|
-
await writeFile(pendingAlertPath(), "");
|
|
621
|
-
// Codex has no output schema for SessionEnd at all, so nothing said there can
|
|
622
|
-
// reach the user until the next session opens.
|
|
623
|
-
await codexAgent.deliver("ISY: session uploaded", "SessionEnd");
|
|
624
|
-
assert.match(await readFile(pendingAlertPath(), "utf8"), /ISY: session uploaded/);
|
|
625
|
-
const said = [];
|
|
626
|
-
const log = console.log;
|
|
627
|
-
console.log = (line) => said.push(line);
|
|
628
|
-
try {
|
|
629
|
-
await codexAgent.deliver("ISY 0.1.0 active", "SessionStart");
|
|
630
|
-
}
|
|
631
|
-
finally {
|
|
632
|
-
console.log = log;
|
|
633
|
-
}
|
|
634
|
-
const shown = JSON.parse(said[0] ?? "{}");
|
|
635
|
-
assert.match(shown.systemMessage ?? "", /session uploaded/);
|
|
636
|
-
assert.match(shown.systemMessage ?? "", /ISY 0\.1\.0 active/);
|
|
637
|
-
// Drained, so the next session does not repeat it. The takeover renames the
|
|
638
|
-
// file away, so it may simply be gone.
|
|
639
|
-
const left = await readFile(pendingAlertPath(), "utf8").catch(() => "");
|
|
640
|
-
assert.equal(left.trim(), "");
|
|
641
|
-
});
|
|
642
|
-
test("picks Codex only when told to: its payload looks exactly like Claude's", () => {
|
|
643
|
-
assert.equal(detectAgent(undefined, "codex").id, "codex");
|
|
644
|
-
assert.equal(detectAgent({ transcript_path: "/x.jsonl", session_id: "s", cwd: "/repo" }).id, "claude");
|
|
645
|
-
assert.equal(detectAgent({ transcript_path: "/x.jsonl" }, "codex").id, "codex");
|
|
646
|
-
});
|
|
647
|
-
test("a Codex session in a subdirectory names its files from the top of the repository", async () => {
|
|
648
|
-
const top = await realpath(await mkdtemp(join(tmpdir(), "isy-codex-root-")));
|
|
649
|
-
await promisify(execFile)("git", ["init", "-q"], { cwd: top });
|
|
650
|
-
const pkg = join(top, "pkg");
|
|
651
|
-
await mkdir(pkg);
|
|
652
|
-
const path = await writeRollout("2026-08-21", "019dc36a-3ce7-7163-8d38-416ea68327d6", [
|
|
653
|
-
metaFor(pkg, "sess-sub"),
|
|
654
|
-
say("user", "go"),
|
|
655
|
-
item({
|
|
656
|
-
type: "custom_tool_call",
|
|
657
|
-
name: "apply_patch",
|
|
658
|
-
call_id: "call-1",
|
|
659
|
-
input: ["*** Begin Patch", "*** Update File: src/a.ts", "@@", "-a", "+b", "*** End Patch"].join("\n"),
|
|
660
|
-
}),
|
|
661
|
-
]);
|
|
662
|
-
const session = parseLines(await codexAgent.redactedLines(path, { cwd: pkg }));
|
|
663
|
-
assert.equal(session.meta.cwd, "pkg");
|
|
664
|
-
assert.deepEqual([...session.fileEdits.keys()], ["pkg/src/a.ts"]);
|
|
665
|
-
});
|
|
666
|
-
//# sourceMappingURL=codex.test.js.map
|