@nightloom/isy 1.0.0 → 1.0.2
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 +1 -1
- package/dist/agents/claude.js +18 -7
- package/dist/agents/claude.js.map +1 -1
- package/dist/agents/codex-records.js +35 -12
- package/dist/agents/codex-records.js.map +1 -1
- package/dist/agents/index.d.ts +16 -5
- package/dist/agents/index.js +21 -6
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/kimi-cli-wire.d.ts +17 -0
- package/dist/agents/kimi-cli-wire.js +312 -0
- package/dist/agents/kimi-cli-wire.js.map +1 -0
- package/dist/agents/kimi-config.d.ts +29 -0
- package/dist/agents/kimi-config.js +193 -0
- package/dist/agents/kimi-config.js.map +1 -0
- package/dist/agents/kimi-records.d.ts +0 -6
- package/dist/agents/kimi-records.js +51 -31
- package/dist/agents/kimi-records.js.map +1 -1
- package/dist/agents/kimi-tools.d.ts +30 -0
- package/dist/agents/kimi-tools.js +100 -0
- package/dist/agents/kimi-tools.js.map +1 -0
- package/dist/agents/kimi-wire.d.ts +8 -0
- package/dist/agents/kimi-wire.js +245 -80
- package/dist/agents/kimi-wire.js.map +1 -1
- package/dist/agents/kimi.d.ts +13 -2
- package/dist/agents/kimi.js +633 -114
- package/dist/agents/kimi.js.map +1 -1
- package/dist/agents/timeline.d.ts +36 -0
- package/dist/agents/timeline.js +61 -0
- package/dist/agents/timeline.js.map +1 -0
- package/dist/agents/types.d.ts +12 -0
- package/dist/commands/analyze.d.ts +2 -0
- package/dist/commands/analyze.js +63 -6
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/check.js +11 -0
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/init.js +17 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/upload.js +8 -4
- package/dist/commands/upload.js.map +1 -1
- package/dist/detectors.js +40 -5
- package/dist/detectors.js.map +1 -1
- package/dist/hook.d.ts +12 -5
- package/dist/hook.js +73 -17
- package/dist/hook.js.map +1 -1
- package/dist/lines.d.ts +8 -0
- package/dist/lines.js +32 -0
- package/dist/lines.js.map +1 -0
- package/dist/parser.d.ts +41 -0
- package/dist/parser.js +328 -32
- package/dist/parser.js.map +1 -1
- package/dist/paths.d.ts +4 -0
- package/dist/paths.js +39 -39
- package/dist/paths.js.map +1 -1
- package/dist/redact.d.ts +10 -0
- package/dist/redact.js +49 -8
- package/dist/redact.js.map +1 -1
- package/dist/stage0.d.ts +7 -1
- package/dist/stage0.js +10 -3
- package/dist/stage0.js.map +1 -1
- package/dist/state.d.ts +6 -3
- package/dist/state.js +21 -5
- package/dist/state.js.map +1 -1
- package/dist/subagents.d.ts +49 -0
- package/dist/subagents.js +237 -0
- package/dist/subagents.js.map +1 -0
- package/dist/test/analyze.test.js +15 -11
- package/dist/test/analyze.test.js.map +1 -1
- package/dist/test/check.test.js +25 -3
- package/dist/test/check.test.js.map +1 -1
- package/dist/test/codex.test.js +43 -0
- package/dist/test/codex.test.js.map +1 -1
- package/dist/test/commit.test.js +9 -1
- package/dist/test/commit.test.js.map +1 -1
- package/dist/test/hook.test.js +66 -2
- package/dist/test/hook.test.js.map +1 -1
- package/dist/test/init.test.d.ts +1 -0
- package/dist/test/init.test.js +94 -0
- package/dist/test/init.test.js.map +1 -0
- package/dist/test/kimi-cli.test.d.ts +1 -0
- package/dist/test/kimi-cli.test.js +231 -0
- package/dist/test/kimi-cli.test.js.map +1 -0
- package/dist/test/kimi-code.test.d.ts +1 -0
- package/dist/test/kimi-code.test.js +302 -0
- package/dist/test/kimi-code.test.js.map +1 -0
- package/dist/test/kimi-config.test.d.ts +1 -0
- package/dist/test/kimi-config.test.js +224 -0
- package/dist/test/kimi-config.test.js.map +1 -0
- package/dist/test/kimi-hook.test.d.ts +1 -0
- package/dist/test/kimi-hook.test.js +163 -0
- package/dist/test/kimi-hook.test.js.map +1 -0
- package/dist/test/kimi-listing.test.d.ts +1 -0
- package/dist/test/kimi-listing.test.js +193 -0
- package/dist/test/kimi-listing.test.js.map +1 -0
- package/dist/test/kimi.test.js +52 -7
- package/dist/test/kimi.test.js.map +1 -1
- package/dist/test/parser.test.js +192 -5
- package/dist/test/parser.test.js.map +1 -1
- package/dist/test/redact.test.js +71 -7
- package/dist/test/redact.test.js.map +1 -1
- package/dist/test/stage0.test.js +74 -4
- package/dist/test/stage0.test.js.map +1 -1
- package/dist/test/subagents.test.d.ts +1 -0
- package/dist/test/subagents.test.js +272 -0
- package/dist/test/subagents.test.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/package.json +3 -2
- package/src/agents/claude.ts +17 -7
- package/src/agents/codex-records.ts +33 -12
- package/src/agents/index.ts +21 -6
- package/src/agents/kimi-cli-wire.ts +350 -0
- package/src/agents/kimi-config.ts +210 -0
- package/src/agents/kimi-records.ts +52 -29
- package/src/agents/kimi-tools.ts +128 -0
- package/src/agents/kimi-wire.ts +270 -82
- package/src/agents/kimi.ts +653 -113
- package/src/agents/timeline.ts +68 -0
- package/src/agents/types.ts +12 -0
- package/src/commands/analyze.ts +62 -6
- package/src/commands/check.ts +11 -0
- package/src/commands/init.ts +18 -2
- package/src/commands/upload.ts +8 -4
- package/src/detectors.ts +39 -5
- package/src/hook.ts +81 -24
- package/src/lines.ts +31 -0
- package/src/parser.ts +343 -31
- package/src/paths.ts +36 -33
- package/src/redact.ts +53 -10
- package/src/stage0.ts +9 -2
- package/src/state.ts +24 -5
- package/src/subagents.ts +283 -0
- package/src/types.ts +16 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { cp, mkdir, mkdtemp, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join, relative } from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import { claudeAgent } from "../agents/claude.js";
|
|
7
|
+
import { analyzeFiles, expandInputs } from "../commands/analyze.js";
|
|
8
|
+
import { onMainPath, parseLines } from "../parser.js";
|
|
9
|
+
import { runStage0 } from "../stage0.js";
|
|
10
|
+
import { sessionFingerprint, sessionLines, subagentsOf } from "../subagents.js";
|
|
11
|
+
/**
|
|
12
|
+
* Two sessions Claude Code 2.1.285 recorded against a scripted API
|
|
13
|
+
* (`fixtures/record/README.md`), with the client-context attachments
|
|
14
|
+
* shortened and every record shape left as it was written.
|
|
15
|
+
*
|
|
16
|
+
* `compacted`: a background subagent fixes a bug; the session is compacted with
|
|
17
|
+
* `/compact`, then carries on — redacted reasoning, a `CronList`, a new file, a test run.
|
|
18
|
+
* `delegated`: a foreground subagent makes the only edit; the session runs the tests.
|
|
19
|
+
*/
|
|
20
|
+
const fixtures = join(import.meta.dirname, "fixtures", "claude-2.1.285");
|
|
21
|
+
const compacted = join(fixtures, "compacted", "70a18f29-539f-40b6-b3e5-269625d413e9.jsonl");
|
|
22
|
+
const delegated = join(fixtures, "delegated", "5d529f07-bb5a-43d6-b702-63bbe03cc5c3.jsonl");
|
|
23
|
+
async function collect(lines) {
|
|
24
|
+
const out = [];
|
|
25
|
+
for await (const line of lines)
|
|
26
|
+
out.push(line);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
test("reads a subagent in right after the call that started it", async () => {
|
|
30
|
+
const lines = await collect(sessionLines(compacted));
|
|
31
|
+
const records = lines.map((line) => JSON.parse(line));
|
|
32
|
+
const call = records.findIndex((record) => JSON.stringify(record).includes('"id":"toolu_0006mockmunvr0jg"'));
|
|
33
|
+
const subagent = records.filter((record) => record.agentId === "a08798d64bcf4727b");
|
|
34
|
+
assert.ok(call > 0);
|
|
35
|
+
assert.equal(subagent.length, 22);
|
|
36
|
+
// The subagent's first record follows the call, before the call's result.
|
|
37
|
+
assert.equal(records[call + 1]?.agentId, "a08798d64bcf4727b");
|
|
38
|
+
assert.equal(records[call + 1]?.parentUuid, null);
|
|
39
|
+
for (const record of subagent) {
|
|
40
|
+
assert.equal(record.isSidechain, true);
|
|
41
|
+
assert.equal(record.parentToolUseID, "toolu_0006mockmunvr0jg");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
test("a compacted 2.1.285 session parses whole, subagent and all", async () => {
|
|
45
|
+
const session = await claudeAgent.parsedSession(compacted);
|
|
46
|
+
assert.deepEqual(session.skipped.unknownTypes, {});
|
|
47
|
+
assert.equal(session.filePath, compacted);
|
|
48
|
+
assert.equal(session.meta.claudeVersion, "2.1.285");
|
|
49
|
+
assert.equal(session.meta.sidechainRecords, 22);
|
|
50
|
+
// The subagent's Read/Edit/Bash, and the session's own calls before and after the compaction.
|
|
51
|
+
assert.deepEqual(session.toolUses.map((use) => `${use.isSidechain ? "sub:" : ""}${use.name}`), ["Read", "Agent", "sub:Read", "sub:Edit", "sub:Bash", "Write", "CronList", "Bash"]);
|
|
52
|
+
// One subagent thought out loud; everything else left its reasoning out.
|
|
53
|
+
assert.equal(session.meta.thinkingBlocks, 1);
|
|
54
|
+
assert.equal(session.meta.hiddenThinkingBlocks, 7);
|
|
55
|
+
// The first prompt is still on the main path, across the compaction boundary.
|
|
56
|
+
assert.equal(onMainPath(session, "b219284b-2f5c-48db-90ff-706971485833"), true);
|
|
57
|
+
assert.equal(onMainPath(session, "bddf298e-1f95-423e-934e-0e5356105578"), true);
|
|
58
|
+
assert.equal(onMainPath(session, "433c64bb-911f-499f-a0b4-934221394b14"), true);
|
|
59
|
+
const result = runStage0(session);
|
|
60
|
+
assert.equal(result.eligible, true);
|
|
61
|
+
assert.equal(result.knownGapReachable, true);
|
|
62
|
+
// The subagent tested its fix, and the session ran the suite after writing the README.
|
|
63
|
+
assert.deepEqual(result.candidates, []);
|
|
64
|
+
});
|
|
65
|
+
test("a session whose only edit was a subagent's is a session that edited", async () => {
|
|
66
|
+
const alone = parseLines((await collect(sessionLines(delegated))).filter((line) => !line.includes('"isSidechain":true')));
|
|
67
|
+
// Even without the subagent's records, its result says it edited a file.
|
|
68
|
+
assert.equal(alone.meta.editToolUses, 0);
|
|
69
|
+
assert.equal(alone.meta.hasFileEdits, true);
|
|
70
|
+
const session = await claudeAgent.parsedSession(delegated);
|
|
71
|
+
assert.equal(session.meta.editToolUses, 1);
|
|
72
|
+
assert.equal(session.meta.hiddenThinkingBlocks, 5);
|
|
73
|
+
const edit = session.fileEdits.get("/home/dev/cart/src/cart.js")?.[0];
|
|
74
|
+
const test = session.toolUses.find((use) => use.name === "Bash");
|
|
75
|
+
assert.ok(edit && test && edit.recordIndex < test.recordIndex, "the edit sits before the test run that checked it");
|
|
76
|
+
const result = runStage0(session);
|
|
77
|
+
assert.equal(result.eligible, true);
|
|
78
|
+
assert.equal(result.candidates.some((candidate) => candidate.category === "unverified_fix"), false);
|
|
79
|
+
assert.equal(result.knownGapReachable, false);
|
|
80
|
+
});
|
|
81
|
+
test("the upload of a session carries its subagents, masked like the rest", async () => {
|
|
82
|
+
const lines = await claudeAgent.redactedLines(delegated, {});
|
|
83
|
+
const text = lines.join("\n");
|
|
84
|
+
assert.ok(text.includes('"isSidechain":true'));
|
|
85
|
+
assert.ok(text.includes('"parentToolUseID":"toolu_0037mockmunvwkwi"'));
|
|
86
|
+
// The session ran in /home/dev/cart: the subagent's paths turn relative with the session's.
|
|
87
|
+
assert.ok(!text.includes("/home/dev/cart/src/cart.js"));
|
|
88
|
+
assert.ok(text.includes('"file_path":"src/cart.js"'));
|
|
89
|
+
});
|
|
90
|
+
async function session(records) {
|
|
91
|
+
const dir = await mkdtemp(join(tmpdir(), "isy-subagents-"));
|
|
92
|
+
const path = join(dir, "s1.jsonl");
|
|
93
|
+
await writeFile(path, records.map((record) => JSON.stringify(record)).join("\n"));
|
|
94
|
+
return { dir, path };
|
|
95
|
+
}
|
|
96
|
+
async function subagent(dir, agentId, records, meta, under = "") {
|
|
97
|
+
const home = join(dir, "s1", "subagents", under);
|
|
98
|
+
await mkdir(home, { recursive: true });
|
|
99
|
+
await writeFile(join(home, `agent-${agentId}.jsonl`), records.map((record) => JSON.stringify(record)).join("\n"));
|
|
100
|
+
if (meta)
|
|
101
|
+
await writeFile(join(home, `agent-${agentId}.meta.json`), JSON.stringify(meta));
|
|
102
|
+
}
|
|
103
|
+
const call = (uuid, parentUuid, id, extra = {}) => ({
|
|
104
|
+
type: "assistant",
|
|
105
|
+
uuid,
|
|
106
|
+
parentUuid,
|
|
107
|
+
sessionId: "s1",
|
|
108
|
+
message: { role: "assistant", content: [{ type: "tool_use", id, name: "Agent", input: { prompt: "go" } }] },
|
|
109
|
+
...extra,
|
|
110
|
+
});
|
|
111
|
+
const said = (uuid, parentUuid, text, extra = {}) => ({
|
|
112
|
+
type: "assistant",
|
|
113
|
+
uuid,
|
|
114
|
+
parentUuid,
|
|
115
|
+
sessionId: "s1",
|
|
116
|
+
message: { role: "assistant", content: [{ type: "text", text }] },
|
|
117
|
+
...extra,
|
|
118
|
+
});
|
|
119
|
+
const answered = (uuid, parentUuid, id, agentId) => ({
|
|
120
|
+
type: "user",
|
|
121
|
+
uuid,
|
|
122
|
+
parentUuid,
|
|
123
|
+
sessionId: "s1",
|
|
124
|
+
message: { role: "user", content: [{ type: "tool_result", tool_use_id: id, content: "done" }] },
|
|
125
|
+
toolUseResult: { status: "completed", agentId },
|
|
126
|
+
});
|
|
127
|
+
test("nests a subagent's own subagent after the call that started it", async () => {
|
|
128
|
+
const { dir, path } = await session([call("a", null, "toolu_outer"), answered("b", "a", "toolu_outer", "outer")]);
|
|
129
|
+
await subagent(dir, "outer", [said("o1", null, "outer starts"), call("o2", "o1", "toolu_inner"), said("o3", "o2", "outer ends")], {
|
|
130
|
+
toolUseId: "toolu_outer",
|
|
131
|
+
});
|
|
132
|
+
await subagent(dir, "inner", [said("i1", null, "inner works")], { toolUseId: "toolu_inner" });
|
|
133
|
+
const order = (await collect(sessionLines(path))).map((line) => JSON.parse(line).uuid);
|
|
134
|
+
assert.deepEqual(order, ["a", "o1", "o2", "i1", "o3", "b"]);
|
|
135
|
+
});
|
|
136
|
+
test("places a subagent without a meta file by the result that names it", async () => {
|
|
137
|
+
const { dir, path } = await session([
|
|
138
|
+
call("a", null, "toolu_1"),
|
|
139
|
+
answered("b", "a", "toolu_1", "lost"),
|
|
140
|
+
said("c", "b", "after"),
|
|
141
|
+
]);
|
|
142
|
+
await subagent(dir, "lost", [said("l1", null, "work")]);
|
|
143
|
+
const records = (await collect(sessionLines(path))).map((line) => JSON.parse(line));
|
|
144
|
+
assert.deepEqual(records.map((record) => record.uuid), ["a", "b", "l1", "c"]);
|
|
145
|
+
assert.equal(records[2]?.parentToolUseID, "toolu_1");
|
|
146
|
+
});
|
|
147
|
+
test("a subagent whose call is nowhere still counts, after the session", async () => {
|
|
148
|
+
const { dir, path } = await session([said("a", null, "hello")]);
|
|
149
|
+
await subagent(dir, "stray", [said("s1", null, "work")], { toolUseId: "toolu_elsewhere" });
|
|
150
|
+
await subagent(dir, "workflow", [said("w1", null, "step")], undefined, join("workflows", "run-1"));
|
|
151
|
+
const records = (await collect(sessionLines(path))).map((line) => JSON.parse(line));
|
|
152
|
+
assert.deepEqual(records.map((record) => record.uuid), ["a", "s1", "w1"]);
|
|
153
|
+
assert.equal(records[1]?.isSidechain, true);
|
|
154
|
+
assert.equal(records[1]?.parentToolUseID, "toolu_elsewhere");
|
|
155
|
+
assert.equal(records[2]?.isSidechain, true);
|
|
156
|
+
assert.equal(records[2]?.parentToolUseID, undefined);
|
|
157
|
+
assert.equal((await subagentsOf(path)).length, 2);
|
|
158
|
+
});
|
|
159
|
+
const at = (second) => new Date(Date.UTC(2026, 8, 30, 9, 0, second)).toISOString();
|
|
160
|
+
const use = (uuid, parentUuid, second, id, name, input) => ({
|
|
161
|
+
type: "assistant",
|
|
162
|
+
uuid,
|
|
163
|
+
parentUuid,
|
|
164
|
+
sessionId: "s1",
|
|
165
|
+
timestamp: at(second),
|
|
166
|
+
message: { role: "assistant", content: [{ type: "tool_use", id, name, input }] },
|
|
167
|
+
});
|
|
168
|
+
const result = (uuid, parentUuid, second, id, extra = {}) => ({
|
|
169
|
+
type: "user",
|
|
170
|
+
uuid,
|
|
171
|
+
parentUuid,
|
|
172
|
+
sessionId: "s1",
|
|
173
|
+
timestamp: at(second),
|
|
174
|
+
message: { role: "user", content: [{ type: "tool_result", tool_use_id: id, content: "ok" }] },
|
|
175
|
+
...extra,
|
|
176
|
+
});
|
|
177
|
+
test("a background subagent's work goes in when it happened, not in one piece after its call", async () => {
|
|
178
|
+
// The session reads a.ts, sends a subagent to run the tests in the background,
|
|
179
|
+
// then edits a.ts a minute later; the subagent runs the suite a minute after that.
|
|
180
|
+
const { dir, path } = await session([
|
|
181
|
+
use("a", null, 1, "t_read", "Read", { file_path: "/repo/src/a.ts" }),
|
|
182
|
+
result("b", "a", 2, "t_read"),
|
|
183
|
+
use("c", "b", 3, "t_agent", "Agent", { prompt: "run the tests", run_in_background: true }),
|
|
184
|
+
result("d", "c", 4, "t_agent", { toolUseResult: { status: "async_launched", agentId: "bg" } }),
|
|
185
|
+
use("e", "d", 60, "t_edit", "Edit", { file_path: "/repo/src/a.ts", old_string: "a", new_string: "b" }),
|
|
186
|
+
result("f", "e", 61, "t_edit"),
|
|
187
|
+
said("g", "f", "the tests pass", { timestamp: at(131) }),
|
|
188
|
+
]);
|
|
189
|
+
await subagent(dir, "bg", [
|
|
190
|
+
said("s1", null, "running them", { timestamp: at(5) }),
|
|
191
|
+
use("s2", "s1", 120, "t_test", "Bash", { command: "npm test" }),
|
|
192
|
+
result("s3", "s2", 125, "t_test"),
|
|
193
|
+
], { toolUseId: "t_agent", requestShape: "background" });
|
|
194
|
+
const parsed = await claudeAgent.parsedSession(path);
|
|
195
|
+
assert.deepEqual(parsed.toolUses.map((use) => `${use.isSidechain ? "sub:" : ""}${use.name}`), ["Read", "Agent", "Edit", "sub:Bash"]);
|
|
196
|
+
assert.deepEqual(parsed.records.map((record) => record.uuid), ["a", "b", "c", "d", "s1", "e", "f", "s2", "s3", "g"]);
|
|
197
|
+
// The suite ran after the edit, so the edit was checked.
|
|
198
|
+
assert.equal(runStage0(parsed).candidates.some((candidate) => candidate.category === "unverified_fix"), false);
|
|
199
|
+
});
|
|
200
|
+
test("a subagent resumed later goes in at the time of its second run", async () => {
|
|
201
|
+
const { dir, path } = await session([
|
|
202
|
+
use("a", null, 1, "t_agent", "Agent", { prompt: "fix it" }),
|
|
203
|
+
result("b", "a", 10, "t_agent", { toolUseResult: { status: "completed", agentId: "x" } }),
|
|
204
|
+
use("c", "b", 20, "t_bash", "Bash", { command: "ls" }),
|
|
205
|
+
result("d", "c", 21, "t_bash"),
|
|
206
|
+
use("e", "d", 40, "t_send", "SendMessage", { to: "x", message: "and the other one" }),
|
|
207
|
+
result("f", "e", 50, "t_send"),
|
|
208
|
+
]);
|
|
209
|
+
await subagent(dir, "x", [
|
|
210
|
+
said("x1", null, "first run", { timestamp: at(2) }),
|
|
211
|
+
said("x2", "x1", "first run done", { timestamp: at(9) }),
|
|
212
|
+
said("x3", "x2", "second run", { timestamp: at(41) }),
|
|
213
|
+
], { toolUseId: "t_agent" });
|
|
214
|
+
const order = (await collect(sessionLines(path))).map((line) => JSON.parse(line).uuid);
|
|
215
|
+
assert.deepEqual(order, ["a", "x1", "x2", "b", "c", "d", "e", "x3", "f"]);
|
|
216
|
+
});
|
|
217
|
+
test("a subagent never goes ahead of its call, whatever its clock says", async () => {
|
|
218
|
+
const { dir, path } = await session([
|
|
219
|
+
said("a", null, "start", { timestamp: at(1) }),
|
|
220
|
+
use("b", "a", 10, "t_agent", "Agent", { prompt: "go" }),
|
|
221
|
+
result("c", "b", 20, "t_agent"),
|
|
222
|
+
]);
|
|
223
|
+
await subagent(dir, "early", [said("e1", null, "stamped before the call", { timestamp: at(5) })], {
|
|
224
|
+
toolUseId: "t_agent",
|
|
225
|
+
});
|
|
226
|
+
const order = (await collect(sessionLines(path))).map((line) => JSON.parse(line).uuid);
|
|
227
|
+
assert.deepEqual(order, ["a", "b", "e1", "c"]);
|
|
228
|
+
});
|
|
229
|
+
test("a subagent whose file cannot be read leaves the session readable", async () => {
|
|
230
|
+
const { dir, path } = await session([call("a", null, "toolu_1"), said("b", "a", "after")]);
|
|
231
|
+
await subagent(dir, "gone", [said("g1", null, "work")], { toolUseId: "toolu_1" });
|
|
232
|
+
const lines = [];
|
|
233
|
+
for await (const line of sessionLines(path)) {
|
|
234
|
+
lines.push(line);
|
|
235
|
+
// Listed before the read began, gone by the time its call is reached.
|
|
236
|
+
if (lines.length === 1)
|
|
237
|
+
await rm(join(dir, "s1", "subagents", "agent-gone.jsonl"));
|
|
238
|
+
}
|
|
239
|
+
assert.deepEqual(lines.map((line) => JSON.parse(line).uuid), ["a", "b"]);
|
|
240
|
+
});
|
|
241
|
+
test("a session with no subagents reads exactly as its file", async () => {
|
|
242
|
+
const records = [said("a", null, "one"), said("b", "a", "two")];
|
|
243
|
+
const { path } = await session(records);
|
|
244
|
+
assert.deepEqual(await collect(sessionLines(path)), records.map((record) => JSON.stringify(record)));
|
|
245
|
+
});
|
|
246
|
+
test("a session's size and age include its subagents", async () => {
|
|
247
|
+
const { dir, path } = await session([call("a", null, "toolu_1")]);
|
|
248
|
+
const alone = await sessionFingerprint(path);
|
|
249
|
+
assert.equal(alone.sizeBytes, (await stat(path)).size);
|
|
250
|
+
await subagent(dir, "x", [said("x1", null, "work")], { toolUseId: "toolu_1" });
|
|
251
|
+
const whole = await sessionFingerprint(path);
|
|
252
|
+
const agent = await stat(join(dir, "s1", "subagents", "agent-x.jsonl"));
|
|
253
|
+
assert.equal(whole.sizeBytes, alone.sizeBytes + agent.size);
|
|
254
|
+
assert.ok(whole.modifiedAt.getTime() >= agent.mtime.getTime());
|
|
255
|
+
});
|
|
256
|
+
test("isy analyze counts a session once, however many subagents it had", async () => {
|
|
257
|
+
const dir = await mkdtemp(join(tmpdir(), "isy-analyze-subagents-"));
|
|
258
|
+
await cp(join(fixtures, "compacted"), dir, { recursive: true });
|
|
259
|
+
const files = await expandInputs([dir]);
|
|
260
|
+
assert.deepEqual(files, [join(dir, "70a18f29-539f-40b6-b3e5-269625d413e9.jsonl")]);
|
|
261
|
+
const [analyzed] = await analyzeFiles(files, undefined);
|
|
262
|
+
assert.equal(analyzed?.eligible, true);
|
|
263
|
+
assert.equal(analyzed?.editToolUses, 2);
|
|
264
|
+
assert.equal(analyzed?.hiddenThinkingBlocks, 7);
|
|
265
|
+
// Asked about on its own, a subagent is all there is to read.
|
|
266
|
+
const lone = join(dir, "70a18f29-539f-40b6-b3e5-269625d413e9", "subagents", "agent-a08798d64bcf4727b.jsonl");
|
|
267
|
+
assert.deepEqual(await expandInputs([lone]), [lone]);
|
|
268
|
+
// Named beside its session, it is its session's, however either was spelled.
|
|
269
|
+
const named = relative(process.cwd(), files[0]);
|
|
270
|
+
assert.deepEqual(await expandInputs([named, lone, `./${named}`]), [named]);
|
|
271
|
+
});
|
|
272
|
+
//# sourceMappingURL=subagents.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagents.test.js","sourceRoot":"","sources":["../../src/test/subagents.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhF;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,IAAI,C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EhD,8DAA8D;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,sCAAsC,EAAE,WAAW,EAAE,+BAA+B,CAAC,CAAC;IAC7G,MAAM,CAAC,SAAS,CAAC,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAErD,6EAA6E;IAC7E,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IACjD,MAAM,CAAC,SAAS,CAAC,MAAM,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -8,12 +8,16 @@ export interface TranscriptRecord {
|
|
|
8
8
|
type: string;
|
|
9
9
|
uuid?: string;
|
|
10
10
|
parentUuid?: string | null;
|
|
11
|
+
/** Set where a compaction restarted the chain: the record the boundary follows. */
|
|
12
|
+
logicalParentUuid?: string | null;
|
|
11
13
|
sessionId?: string;
|
|
12
14
|
timestamp?: string;
|
|
13
15
|
cwd?: string;
|
|
14
16
|
gitBranch?: string;
|
|
15
17
|
version?: string;
|
|
16
18
|
isSidechain?: boolean;
|
|
19
|
+
/** On a subagent's records: the `Agent` call that started it (`subagents.ts`). */
|
|
20
|
+
parentToolUseID?: string;
|
|
17
21
|
requestId?: string;
|
|
18
22
|
message?: TranscriptMessage;
|
|
19
23
|
toolUseResult?: unknown;
|
|
@@ -87,7 +91,10 @@ export interface SessionMeta {
|
|
|
87
91
|
startedAt?: string;
|
|
88
92
|
endedAt?: string;
|
|
89
93
|
assistantRecords: number;
|
|
94
|
+
/** Reasoning with text in it: what makes `known_gap` reachable. */
|
|
90
95
|
thinkingBlocks: number;
|
|
96
|
+
/** Reasoning recorded without its text — emptied `thinking`, `redacted_thinking`. */
|
|
97
|
+
hiddenThinkingBlocks: number;
|
|
91
98
|
editToolUses: number;
|
|
92
99
|
/** Touched a file by any means — see parser.ts:shellWrites. Gates analysis. */
|
|
93
100
|
hasFileEdits: boolean;
|
|
@@ -109,8 +116,17 @@ export interface ParsedSession {
|
|
|
109
116
|
export interface SessionFile {
|
|
110
117
|
sessionId: string;
|
|
111
118
|
path: string;
|
|
119
|
+
/** Size and mtime of the session as a whole, subagents included: what decides whether it grew. */
|
|
112
120
|
sizeBytes: number;
|
|
113
121
|
modifiedAt: Date;
|
|
122
|
+
/**
|
|
123
|
+
* When the session's own transcript was last written, its subagents aside —
|
|
124
|
+
* what "the newest session here" is ordered by (`paths.ts:lastActive`). A
|
|
125
|
+
* subagent sent to the background goes on writing while its session sits
|
|
126
|
+
* idle, and by `modifiedAt` an idle session outranked the one that just
|
|
127
|
+
* made a commit. Absent where the two cannot differ.
|
|
128
|
+
*/
|
|
129
|
+
activeAt?: Date;
|
|
114
130
|
}
|
|
115
131
|
/**
|
|
116
132
|
* A session found by a scan that had no working directory to start from, so the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nightloom/isy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "CLI for ISY: uploads AI coding-agent sessions so the process behind a pull request gets reviewed, not just the diff.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"test": "node --import tsx --test src/test/*.test.ts",
|
|
51
51
|
"typecheck": "tsc --noEmit",
|
|
52
52
|
"prepack": "npm run build",
|
|
53
|
-
"calibrate:corpus": "tsx src/index.ts analyze \"$HOME/.claude/projects\""
|
|
53
|
+
"calibrate:corpus": "tsx src/index.ts analyze \"$HOME/.claude/projects\"",
|
|
54
|
+
"e2e:live": "node e2e/live.mjs"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/node": "^26",
|
package/src/agents/claude.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { access } from "node:fs/promises";
|
|
2
|
-
import { withParkedAlerts } from "../alert.js";
|
|
3
|
-
import { ISY_HOOKS, installHook, installedHooks, removeHook, settingsLocation } from "../hook.js";
|
|
4
|
-
import {
|
|
2
|
+
import { parkAlert, withParkedAlerts } from "../alert.js";
|
|
3
|
+
import { ISY_HOOKS, installHook, installedHooks, removeHook, repairHooks, settingsLocation } from "../hook.js";
|
|
4
|
+
import { parseLineStream } from "../parser.js";
|
|
5
5
|
import {
|
|
6
6
|
allClaudeSessions,
|
|
7
7
|
claudeConfigDir,
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
firstCwd,
|
|
11
11
|
projectDir,
|
|
12
12
|
} from "../paths.js";
|
|
13
|
-
import {
|
|
13
|
+
import { redactLineStream } from "../redact.js";
|
|
14
|
+
import { sessionLines } from "../subagents.js";
|
|
14
15
|
import type { Agent, AgentHook, HookInput } from "./types.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -54,8 +55,11 @@ export const claudeAgent: Agent = {
|
|
|
54
55
|
return firstCwd(path);
|
|
55
56
|
},
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
// A session is its own file and its subagents' files, read as one transcript.
|
|
59
|
+
async parsedSession(path: string) {
|
|
60
|
+
const session = await parseLineStream(sessionLines(path));
|
|
61
|
+
session.filePath = path;
|
|
62
|
+
return session;
|
|
59
63
|
},
|
|
60
64
|
|
|
61
65
|
async transcriptFor(hook: HookInput | undefined, cwd: string): Promise<string | undefined> {
|
|
@@ -67,7 +71,9 @@ export const claudeAgent: Agent = {
|
|
|
67
71
|
options: { extraPatterns?: readonly string[]; cwd?: string },
|
|
68
72
|
): Promise<string[]> {
|
|
69
73
|
// Streams the file rather than loading it: real transcripts reach tens of MB.
|
|
70
|
-
|
|
74
|
+
// Subagents are spliced in on the way (`subagents.ts`), so the upload is the
|
|
75
|
+
// whole session and the server parses one transcript, as it always has.
|
|
76
|
+
const { lines } = await redactLineStream(sessionLines(path), {
|
|
71
77
|
extraPatterns: options.extraPatterns,
|
|
72
78
|
cwd: options.cwd,
|
|
73
79
|
});
|
|
@@ -77,12 +83,16 @@ export const claudeAgent: Agent = {
|
|
|
77
83
|
hooksInstalled: installedHooks,
|
|
78
84
|
installHooks: installHook,
|
|
79
85
|
removeHooks: removeHook,
|
|
86
|
+
repairHooks,
|
|
80
87
|
|
|
81
88
|
// Claude Code renders `systemMessage` from a hook's stdout for the user. At
|
|
82
89
|
// SessionStart that stdout is also the only route a line parked by unattended
|
|
83
90
|
// work has — a sweep spawned with its output going nowhere, an alert raised
|
|
84
91
|
// where another CLI had no terminal — so the backlog goes out ahead of it.
|
|
92
|
+
// The SessionEnd upload runs detached, its stdout on /dev/null (`hook.ts`),
|
|
93
|
+
// so its line is parked for the next session start instead.
|
|
85
94
|
async deliver(message: string, event?: string): Promise<void> {
|
|
95
|
+
if (event === "SessionEnd") return parkAlert(message);
|
|
86
96
|
const text = event === "SessionStart" ? await withParkedAlerts(message) : message;
|
|
87
97
|
console.log(JSON.stringify({ systemMessage: text }));
|
|
88
98
|
},
|
|
@@ -20,6 +20,8 @@ const HARNESS_CALL = /tools\.(exec_command|apply_patch)\s*\(/g;
|
|
|
20
20
|
const CMD_ARGUMENT = /^\s*\{[^}]*?(?:\bcmd|"cmd")\s*:\s*("(?:[^"\\]|\\.)*")\s*[,}]/s;
|
|
21
21
|
/** `("*** Begin Patch…")` — one string literal and nothing glued onto it. */
|
|
22
22
|
const PATCH_ARGUMENT = /^\s*("(?:[^"\\]|\\.)*")\s*[,)]/s;
|
|
23
|
+
/** `(patch)` — a bare name, which Codex 0.154 binds to the patch one line earlier. */
|
|
24
|
+
const NAME_ARGUMENT = /^\s*([A-Za-z_$][\w$]*)\s*[,)]/;
|
|
23
25
|
/** Any call into the harness, to tell a script that only looks from one that may write. */
|
|
24
26
|
const ANY_HARNESS_CALL = /tools\.([A-Za-z0-9_]+)\s*\(/g;
|
|
25
27
|
/** Harness tools that fetch or look and never touch the working tree. */
|
|
@@ -99,12 +101,11 @@ export function parseApplyPatch(patch: string): PatchEdit[] {
|
|
|
99
101
|
const closeHunk = (): void => {
|
|
100
102
|
if (!update?.open) return;
|
|
101
103
|
// A section with no `+`/`-` at all is context Codex emitted for position only.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
104
|
+
// Context lands on both sides, so such a section is old === new: kept, it
|
|
105
|
+
// changes nothing, and the same section in a later patch reads as a revert.
|
|
106
|
+
const old_string = update.open.old.join("\n");
|
|
107
|
+
const new_string = update.open.new.join("\n");
|
|
108
|
+
if (old_string !== new_string) update.hunks.push({ old_string, new_string });
|
|
108
109
|
update.open = undefined;
|
|
109
110
|
};
|
|
110
111
|
|
|
@@ -128,7 +129,9 @@ export function parseApplyPatch(patch: string): PatchEdit[] {
|
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
// A patch written on Windows ends its lines in CRLF, and a header line
|
|
133
|
+
// carrying the `\r` matches nothing: the whole patch read as no edit at all.
|
|
134
|
+
for (const line of patch.split(/\r?\n/)) {
|
|
132
135
|
const updating = /^\*\*\* (?:Update|Move) File: (.+)$/.exec(line);
|
|
133
136
|
if (updating) {
|
|
134
137
|
closeFile();
|
|
@@ -195,6 +198,22 @@ function literalText(literal: string): string | undefined {
|
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
|
|
201
|
+
/**
|
|
202
|
+
* The patch literal an `apply_patch` call passes: written in place, or through
|
|
203
|
+
* a name the script binds with `const` exactly once. `const` because nothing can
|
|
204
|
+
* reassign it between the binding and the call; a name bound twice (shadowed in
|
|
205
|
+
* a nested block) or with `let` may not hold that literal, so it stays unread.
|
|
206
|
+
*/
|
|
207
|
+
function patchLiteral(script: string, rest: string): string | undefined {
|
|
208
|
+
const literal = PATCH_ARGUMENT.exec(rest)?.[1];
|
|
209
|
+
if (literal !== undefined) return literal;
|
|
210
|
+
const name = NAME_ARGUMENT.exec(rest)?.[1];
|
|
211
|
+
if (name === undefined) return undefined;
|
|
212
|
+
const binding = new RegExp(`\\bconst\\s+${name.replace(/\$/g, "\\$")}\\s*=\\s*("(?:[^"\\\\]|\\\\.)*")\\s*;`, "g");
|
|
213
|
+
const bound = [...script.matchAll(binding)];
|
|
214
|
+
return bound.length === 1 ? bound[0]![1] : undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
198
217
|
/**
|
|
199
218
|
* Every tool call an `exec` harness script makes, in order: each
|
|
200
219
|
* `tools.exec_command` as a Bash call and each `tools.apply_patch` as the edits
|
|
@@ -202,11 +221,13 @@ function literalText(literal: string): string | undefined {
|
|
|
202
221
|
* so reading only its first command left their edits invisible to stage 0.
|
|
203
222
|
*
|
|
204
223
|
* `opaque` says a call was there whose argument is not one plain literal —
|
|
205
|
-
* `{cmd: "sed -n '" + range + "p' a.ts"}`, a
|
|
206
|
-
*
|
|
207
|
-
* left out, and the script keeps its own
|
|
224
|
+
* `{cmd: "sed -n '" + range + "p' a.ts"}`, a name bound to anything but one
|
|
225
|
+
* `const` literal, a patch that parsed to nothing. Half a command would lie to
|
|
226
|
+
* the shell detectors, so such a call is left out, and the script keeps its own
|
|
227
|
+
* name beside what was read.
|
|
208
228
|
*
|
|
209
|
-
* ponytail: literal arguments only; reading the rest
|
|
229
|
+
* ponytail: literal arguments and `const`-bound patches only; reading the rest
|
|
230
|
+
* means running the snippet.
|
|
210
231
|
*/
|
|
211
232
|
function harnessCalls(script: string): { calls: PatchEdit[]; opaque: boolean } {
|
|
212
233
|
const calls: PatchEdit[] = [];
|
|
@@ -215,7 +236,7 @@ function harnessCalls(script: string): { calls: PatchEdit[]; opaque: boolean } {
|
|
|
215
236
|
for (const match of script.matchAll(HARNESS_CALL)) {
|
|
216
237
|
const rest = script.slice(match.index + match[0].length);
|
|
217
238
|
const shell = match[1] === "exec_command";
|
|
218
|
-
const literal =
|
|
239
|
+
const literal = shell ? CMD_ARGUMENT.exec(rest)?.[1] : patchLiteral(script, rest);
|
|
219
240
|
const text = literal === undefined ? undefined : literalText(literal);
|
|
220
241
|
const read: PatchEdit[] =
|
|
221
242
|
text === undefined ? [] : shell ? [{ tool: "Bash", input: { command: text } }] : parseApplyPatch(text);
|
package/src/agents/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { claudeAgent } from "./claude.js";
|
|
2
2
|
import { codexAgent } from "./codex.js";
|
|
3
3
|
import { kimiAgent } from "./kimi.js";
|
|
4
|
+
import { lastActive } from "../paths.js";
|
|
4
5
|
import type { SessionFile } from "../types.js";
|
|
5
6
|
import type { Agent, AgentId, HookInput } from "./types.js";
|
|
6
7
|
|
|
@@ -22,14 +23,20 @@ export function isAgentId(value: string | undefined): value is AgentId {
|
|
|
22
23
|
/**
|
|
23
24
|
* Which CLI fired this hook. Codex sends the same fields Claude Code does and so
|
|
24
25
|
* cannot be told apart from it, which is why its hooks pass `--agent codex`.
|
|
25
|
-
* Older Kimi builds said so in `client_type`; 0.38 dropped the field,
|
|
26
|
-
* session ids keep their own shape (`session_<uuid>`, where Claude and
|
|
27
|
-
* a bare UUID).
|
|
28
|
-
*
|
|
26
|
+
* Older Kimi builds said so in `client_type`; Kimi Code 0.38 dropped the field,
|
|
27
|
+
* but its session ids keep their own shape (`session_<uuid>`, where Claude and
|
|
28
|
+
* Codex use a bare UUID). Kimi CLI's ids are bare UUIDs too, and what gives it
|
|
29
|
+
* away is what it leaves out: Claude Code and Codex always send
|
|
30
|
+
* `transcript_path`, and no Kimi does. A hook installed before `--agent kimi`
|
|
31
|
+
* relies on these. Claude Code is the default, which keeps every existing
|
|
32
|
+
* install working untouched.
|
|
29
33
|
*/
|
|
30
34
|
export function detectAgent(hook: HookInput | undefined, override?: string): Agent {
|
|
31
35
|
if (isAgentId(override)) return agentById(override);
|
|
32
36
|
if (hook?.client_type?.startsWith("kimi") || hook?.session_id?.startsWith("session_")) return kimiAgent;
|
|
37
|
+
if (hook?.session_id !== undefined && hook.hook_event_name !== undefined && !("transcript_path" in hook)) {
|
|
38
|
+
return kimiAgent;
|
|
39
|
+
}
|
|
33
40
|
return claudeAgent;
|
|
34
41
|
}
|
|
35
42
|
|
|
@@ -40,7 +47,15 @@ export async function presentAgents(): Promise<Agent[]> {
|
|
|
40
47
|
return present;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Newest session for this directory across every CLI installed here, by when
|
|
52
|
+
* the session itself last wrote.
|
|
53
|
+
*
|
|
54
|
+
* ponytail: a commit a subagent made, while its session waited on it, is
|
|
55
|
+
* credited by the session's own time, which that subagent does not move; a
|
|
56
|
+
* busier session in the same directory then wins. Read the subagent meta's
|
|
57
|
+
* `requestShape` and count foreground subagents' writes if that shows up.
|
|
58
|
+
*/
|
|
44
59
|
export async function newestSession(
|
|
45
60
|
cwd: string,
|
|
46
61
|
): Promise<{ agent: Agent; file: SessionFile } | undefined> {
|
|
@@ -49,7 +64,7 @@ export async function newestSession(
|
|
|
49
64
|
for (const agent of await presentAgents()) {
|
|
50
65
|
const file = (await agent.sessionsIn(cwd))[0];
|
|
51
66
|
if (!file) continue;
|
|
52
|
-
if (!best || file
|
|
67
|
+
if (!best || lastActive(file) > lastActive(best.file)) {
|
|
53
68
|
best = { agent, file };
|
|
54
69
|
}
|
|
55
70
|
}
|