notesoup 0.54.0 → 0.54.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 +4 -2
- package/dist/plugins/claude/src/helper.d.ts +2 -1
- package/dist/plugins/claude/src/helper.js +19 -23
- package/dist/plugins/claude/src/history.d.ts +3 -14
- package/dist/plugins/claude/src/history.js +2 -298
- package/dist/plugins/claude/src/text.d.ts +0 -1
- package/dist/plugins/claude/src/text.js +0 -1
- package/dist/plugins/codex/src/history.d.ts +3 -8
- package/dist/plugins/codex/src/history.js +2 -238
- package/dist/plugins/codex/src/mcp.js +7 -7
- package/dist/plugins/codex/src/transcript.d.ts +3 -39
- package/dist/plugins/codex/src/transcript.js +2 -313
- package/dist/plugins/dsh/history.d.ts +3 -0
- package/dist/plugins/dsh/history.js +15 -0
- package/dist/plugins/dsh/tools.js +4 -5
- package/dist/plugins/pi/history-tools.d.ts +1 -1
- package/dist/plugins/pi/history-tools.js +9 -5
- package/dist/plugins/pi/history.d.ts +2 -3
- package/dist/plugins/pi/history.js +4 -147
- package/dist/src/boot/render.js +2 -4
- package/dist/src/boot/text.d.ts +3 -1
- package/dist/src/boot/text.js +11 -5
- package/dist/src/history/claude.d.ts +16 -0
- package/dist/src/history/claude.js +336 -0
- package/dist/src/history/codex-transcript.d.ts +39 -0
- package/dist/src/history/codex-transcript.js +315 -0
- package/dist/src/history/codex.d.ts +8 -0
- package/dist/src/history/codex.js +238 -0
- package/dist/src/history/corpus.d.ts +35 -0
- package/dist/src/history/corpus.js +54 -0
- package/dist/src/history/history.d.ts +4 -8
- package/dist/src/history/history.js +3 -11
- package/dist/src/history/local.d.ts +17 -0
- package/dist/src/history/local.js +101 -0
- package/dist/src/history/pi.d.ts +36 -0
- package/dist/src/history/pi.js +202 -0
- package/dist/src/history/query.d.ts +15 -5
- package/dist/src/history/query.js +42 -13
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.js +4 -3
- package/dist/src/tools/history.d.ts +7 -19
- package/dist/src/tools/history.js +80 -93
- package/dist/test/boot.integration.test.js +1 -2
- package/dist/test/claude-history.test.js +47 -34
- package/dist/test/claude-mod.test.js +7 -7
- package/dist/test/codex-history.test.js +4 -10
- package/dist/test/codex-plugin.test.js +32 -11
- package/dist/test/dependencies.test.js +3 -3
- package/dist/test/dsh.test.js +26 -4
- package/dist/test/helpers/extension.d.ts +0 -1
- package/dist/test/helpers/history-corpus.d.ts +7 -0
- package/dist/test/helpers/history-corpus.js +26 -0
- package/dist/test/history-corpus.test.d.ts +1 -0
- package/dist/test/history-corpus.test.js +307 -0
- package/dist/test/history.integration.test.js +40 -48
- package/dist/test/host-neutral.test.js +3 -18
- package/dist/test/model-facing-text.test.js +2 -0
- package/dist/test/notes.integration.test.js +1 -1
- package/dist/test/notes.test.js +1 -1
- package/docs/architecture.md +7 -5
- package/docs/claude-code-mod.md +7 -5
- package/docs/codex.md +3 -3
- package/docs/dsh.md +2 -2
- package/docs/history-sessions.md +52 -0
- package/docs/notes-library.md +1 -1
- package/docs/skills.md +1 -1
- package/docs/tool-results.md +8 -6
- package/package.json +3 -4
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1992 -1231
- package/plugins/claude/skills/memory/SKILL.md +5 -3
- package/plugins/claude/src/helper.ts +19 -23
- package/plugins/claude/src/history.ts +3 -257
- package/plugins/claude/src/text.ts +0 -1
- package/plugins/codex/dist/codex/notesoup.js +1364 -813
- package/plugins/codex/src/history.ts +3 -193
- package/plugins/codex/src/mcp.ts +7 -7
- package/plugins/codex/src/transcript.ts +3 -275
- package/plugins/dsh/history.ts +17 -0
- package/plugins/dsh/tools.ts +4 -5
- package/plugins/paseo/client/markdown.tsx +19 -39
- package/plugins/paseo/client/notes-op-card.tsx +1 -1
- package/plugins/pi/history-tools.ts +11 -5
- package/plugins/pi/history.ts +8 -157
- package/skills/memory/SKILL.md +5 -3
- package/src/boot/render.ts +2 -5
- package/src/boot/text.ts +11 -5
- package/src/history/claude.ts +286 -0
- package/src/history/codex-transcript.ts +276 -0
- package/src/history/codex.ts +193 -0
- package/src/history/corpus.ts +69 -0
- package/src/history/history.ts +5 -12
- package/src/history/local.ts +93 -0
- package/src/history/pi.ts +199 -0
- package/src/history/query.ts +45 -15
- package/src/index.ts +5 -3
- package/src/tools/history.ts +71 -101
|
@@ -8,9 +8,10 @@ import { renderBootBlock } from "../src/boot/render.js";
|
|
|
8
8
|
import { unavailableNotesSnapshot } from "../src/boot/snapshot.js";
|
|
9
9
|
import { DEFAULT_BOOT_TOOL_NAMES } from "../src/boot/text.js";
|
|
10
10
|
import { allItems, eventDocument } from "../src/history/history.js";
|
|
11
|
-
import { historyList, historyRead
|
|
11
|
+
import { historyList, historyRead } from "../src/tools/history.js";
|
|
12
12
|
import { TOOL_OUTPUT_MAX_BYTES } from "../src/tools/output.js";
|
|
13
13
|
import { dispatch } from "../plugins/claude/src/helper.js";
|
|
14
|
+
import { writePiTranscript } from "./helpers/history-corpus.js";
|
|
14
15
|
const sessionId = "synthetic-session";
|
|
15
16
|
function row(uuid, parentUuid, type, content, extra = {}) {
|
|
16
17
|
return { uuid, parentUuid, type, sessionId, timestamp: "2026-01-01T00:00:00Z", isSidechain: false,
|
|
@@ -30,6 +31,25 @@ const bootText = (ordinal, spelling = "legacy") => spelling === "legacy"
|
|
|
30
31
|
function compact(uuid, logical, metadata = {}) {
|
|
31
32
|
return row(uuid, null, "system", "Conversation compacted", { subtype: "compact_boundary", logicalParentUuid: logical, compactMetadata: metadata });
|
|
32
33
|
}
|
|
34
|
+
test("Claude helper resolves foreign history without requiring a current append head/path", async (t) => {
|
|
35
|
+
const home = mkdtempSync(join(tmpdir(), "claude-cross-harness-"));
|
|
36
|
+
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
37
|
+
const pi = join(home, "sessions");
|
|
38
|
+
await writePiTranscript(pi, "foreign-pi");
|
|
39
|
+
const identity = { home: join(home, "notes"), sessionId, cwd: home, agent: "claude", model: "claude" };
|
|
40
|
+
const options = { roots: { pi, claude: null, codex: null }, env: {} };
|
|
41
|
+
const invoke = (tool, params) => dispatch({ op: "tool", tool, params, identity }, options);
|
|
42
|
+
const read = await invoke("history_read", { session: "pi:foreign", seq: 1 });
|
|
43
|
+
assert.ok(read.ok);
|
|
44
|
+
assert.match(read.text, /^session pi:foreign-pi \| seq 1 \| user/);
|
|
45
|
+
assert.match(read.text, /foreign needle/);
|
|
46
|
+
const list = await invoke("history_list", { session: "pi:*", query: "needle" });
|
|
47
|
+
assert.ok(list.ok);
|
|
48
|
+
assert.match(list.text, /session pi:foreign-pi/);
|
|
49
|
+
const invalid = await invoke("history_read", { session: "*", seq: 1 });
|
|
50
|
+
assert.equal(invalid.ok, false);
|
|
51
|
+
assert.match(invalid.text, /invalid_session/);
|
|
52
|
+
});
|
|
33
53
|
test("Claude append and result arrival preserve call addresses and use the shared paired read", async () => {
|
|
34
54
|
const rows = [user("u", null, "run tools"), assistant("a", "u", [{ type: "thinking", thinking: "private thought" }, { type: "text", text: "working" }, call("one"), call("two")])];
|
|
35
55
|
const pending = project(rows, "a");
|
|
@@ -62,7 +82,7 @@ test("Claude dialogue paging skips tool/thinking envelopes without losing array
|
|
|
62
82
|
compact("boundary", "last"), row("boot", "boundary", "user", bootText(1))];
|
|
63
83
|
const projection = project(rows, "boot");
|
|
64
84
|
assert.equal(projection.highestSeq, 10);
|
|
65
|
-
const listed = await historyList.execute({
|
|
85
|
+
const listed = await historyList.execute({ before_seq: 9, roles: ["user", "assistant"], limit: 3 }, projection);
|
|
66
86
|
assert.ok(listed.ok);
|
|
67
87
|
assert.deepEqual(listed.data.items.map((item) => "seq" in item ? [item.seq, item.content] : []), [[1, "human question"], [2, "assistant answer"], [8, "human followup"]]);
|
|
68
88
|
const read = await historyRead.execute({ seq: 2 }, projection);
|
|
@@ -156,12 +176,10 @@ test("Claude native compaction and reset keep pre-reset history, preserved rewri
|
|
|
156
176
|
assert.equal(allItems(projection).find((event) => event.text === "before first reset")?.windowId, `claude:${sessionId}:0`);
|
|
157
177
|
assert.equal(allItems(projection).find((event) => event.text === "after first reset")?.windowId, `claude:${sessionId}:1`);
|
|
158
178
|
assert.equal(projection.highestSeq, 8);
|
|
159
|
-
const
|
|
160
|
-
assert.ok(
|
|
161
|
-
assert.deepEqual(
|
|
162
|
-
|
|
163
|
-
assert.ok(windows.ok);
|
|
164
|
-
assert.equal(windows.data.windows[0]?.first_seq, 1);
|
|
179
|
+
const earlier = await historyList.execute({ after_seq: 4, before_seq: 6, roles: ["assistant"] }, projection);
|
|
180
|
+
assert.ok(earlier.ok);
|
|
181
|
+
assert.deepEqual(earlier.data.items.map((item) => "content" in item ? item.content : ""), ["after first reset"]);
|
|
182
|
+
assert.equal(projection.windows[0]?.items[0]?.seq, 1);
|
|
165
183
|
assert.deepEqual(project(rows, "latest"), projection, "reload does not need an in-memory seq cache");
|
|
166
184
|
});
|
|
167
185
|
test("Claude reset crosses native turn_duration graph metadata with no message content", async () => {
|
|
@@ -172,9 +190,8 @@ test("Claude reset crosses native turn_duration graph metadata with no message c
|
|
|
172
190
|
assert.equal(projection.highestSeq, 5, "duration metadata does not allocate a message address");
|
|
173
191
|
assert.equal(projection.windows.length, 2);
|
|
174
192
|
assert.ok(allItems(projection).some((event) => event.text === "marker before reset"));
|
|
175
|
-
assert.ok((await historyList.execute({
|
|
193
|
+
assert.ok((await historyList.execute({ before_seq: 3 }, projection)).ok);
|
|
176
194
|
assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
|
|
177
|
-
assert.ok((await historyWindows.execute({}, projection, sessionId)).ok);
|
|
178
195
|
});
|
|
179
196
|
test("Claude api_error retry metadata keeps compact ancestry without allocating seq or exposing internals", async () => {
|
|
180
197
|
const retry = { type: "system", subtype: "api_error", uuid: "retry", parentUuid: "old", sessionId, isSidechain: false,
|
|
@@ -191,11 +208,10 @@ test("Claude api_error retry metadata keeps compact ancestry without allocating
|
|
|
191
208
|
assert.deepEqual(project([...prefix, { ...rows[3], logicalParentUuid: "old" }, ...rows.slice(4)], "after"), projection, "metadata leaves all addresses and windows unchanged");
|
|
192
209
|
assert.doesNotMatch(allItems(projection).map(eventDocument).join("\n"), /PRIVATE_RETRY_PAYLOAD|ECONNRESET|request_retry/);
|
|
193
210
|
assert.ok((await historyList.execute({}, projection)).ok);
|
|
194
|
-
const
|
|
195
|
-
assert.ok(
|
|
196
|
-
assert.match(JSON.stringify(
|
|
211
|
+
const earlier = await historyList.execute({ before_seq: 3 }, projection);
|
|
212
|
+
assert.ok(earlier.ok);
|
|
213
|
+
assert.match(JSON.stringify(earlier), /before retry|finished turn/);
|
|
197
214
|
assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
|
|
198
|
-
assert.ok((await historyWindows.execute({}, projection, sessionId)).ok);
|
|
199
215
|
assert.deepEqual(project(rows, "after"), projection, "reload preserves seq");
|
|
200
216
|
assert.deepEqual(project([...prefix, { ...retry, subtype: "future_metadata" }, ...rows.slice(3)], "after"), projection, "metadata does not depend on a subtype whitelist");
|
|
201
217
|
const withBody = project([...prefix, { ...retry, content: "visible system notice" }], "retry");
|
|
@@ -266,7 +282,7 @@ test("Claude gaps retain only confirmed suffixes, keep pairing/seqs, and disappe
|
|
|
266
282
|
assert.equal(recovered.pairedResults.get(6), 4);
|
|
267
283
|
assert.ok(!recovered.branchSeqs.has(2) && !recovered.branchSeqs.has(7), "recovery never selects either sibling");
|
|
268
284
|
});
|
|
269
|
-
test("Claude helper reports gaps on list/read
|
|
285
|
+
test("Claude helper reports gaps on list/read and re-anchors reset state only with a retained boot", async (t) => {
|
|
270
286
|
const root = mkdtempSync(join(tmpdir(), "claude-history-gap-"));
|
|
271
287
|
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
272
288
|
const transcriptPath = join(root, "transcript.jsonl");
|
|
@@ -277,7 +293,7 @@ test("Claude helper reports gaps on list/read/windows and re-anchors reset state
|
|
|
277
293
|
const history = { sessionId, transcriptPath, headUuid: "suffix" };
|
|
278
294
|
const invoke = (tool, params = {}) => dispatch({ op: "tool", tool, params, identity, history });
|
|
279
295
|
writeFileSync(transcriptPath, jsonl(rows));
|
|
280
|
-
for (const [tool, params] of [["history_list", {}], ["history_read", { seq: 2 }],
|
|
296
|
+
for (const [tool, params] of [["history_list", {}], ["history_read", { seq: 2 }],
|
|
281
297
|
["history_list", { query: "no matches" }], ["history_read", { seq: 99 }]]) {
|
|
282
298
|
const response = await invoke(tool, params);
|
|
283
299
|
assert.match(response.text, /history is incomplete: missing ancestor UUID\(s\): "missing"/);
|
|
@@ -287,8 +303,8 @@ test("Claude helper reports gaps on list/read/windows and re-anchors reset state
|
|
|
287
303
|
const excluded = await invoke("history_read", { seq: 1 });
|
|
288
304
|
assert.equal(excluded.ok, false);
|
|
289
305
|
assert.match(excluded.text, /outside the confirmed selected history/);
|
|
290
|
-
assert.
|
|
291
|
-
await assert.rejects(invoke("history_list", {
|
|
306
|
+
await assert.rejects(invoke("history_list", { window_id: "anything" }), /invalid history_list parameters:.*window_id/);
|
|
307
|
+
await assert.rejects(invoke("history_list", { before_seq: "invalid" }), /invalid history_list parameters: before_seq/);
|
|
292
308
|
await assert.rejects(invoke("history_read", { seq: "2" }), /invalid history_read parameters: seq/);
|
|
293
309
|
await assert.rejects(dispatch({ op: "history_state", identity, history }), /cannot determine the current window ordinal/);
|
|
294
310
|
// A native boundary alone cannot count the missing earlier resets. A quoted
|
|
@@ -304,21 +320,21 @@ test("Claude helper reports gaps on list/read/windows and re-anchors reset state
|
|
|
304
320
|
assert.equal(anchored.currentWindowOrdinal, 8);
|
|
305
321
|
assert.deepEqual(anchored.windows.map((window) => window.windowId), [`claude:${sessionId}:8`, `claude:${sessionId}:unknown:missing`], "unknown segments are listed separately, not inserted into the numbered timeline");
|
|
306
322
|
assert.deepEqual(await dispatch({ op: "history_state", identity, history }), { window: 8 }, "never windows.length - 1");
|
|
307
|
-
|
|
308
|
-
assert.match(
|
|
309
|
-
assert.match(
|
|
323
|
+
const anchoredRead = await invoke("history_read", { seq: 6 });
|
|
324
|
+
assert.match(anchoredRead.text, /history is incomplete/);
|
|
325
|
+
assert.match(anchoredRead.text, /seq 6 \| user\n/);
|
|
310
326
|
rows.push(compact("next", "after"), row("next-boot", "next", "user", bootText(9)), user("latest", "next-boot", "latest"));
|
|
311
327
|
writeFileSync(transcriptPath, jsonl(rows));
|
|
312
328
|
history.headUuid = "latest";
|
|
313
|
-
const
|
|
314
|
-
assert.ok(
|
|
315
|
-
assert.match(
|
|
316
|
-
assert.doesNotMatch(
|
|
329
|
+
const earlier = await invoke("history_list", { after_seq: 5, before_seq: 7 });
|
|
330
|
+
assert.ok(earlier.ok);
|
|
331
|
+
assert.match(earlier.text, /after anchored reset/);
|
|
332
|
+
assert.doesNotMatch(earlier.text, /confirmed suffix/);
|
|
317
333
|
// Restore the record as a supported message: warning disappears on the next
|
|
318
334
|
// read, without any in-memory repair state or changed existing addresses.
|
|
319
335
|
rows.push(user("missing", "prefix", "recovered ancestor"));
|
|
320
336
|
writeFileSync(transcriptPath, jsonl(rows));
|
|
321
|
-
assert.doesNotMatch((await invoke("
|
|
337
|
+
assert.doesNotMatch((await invoke("history_list")).text, /history is incomplete/);
|
|
322
338
|
assert.deepEqual(await dispatch({ op: "history_state", identity, history }), { window: 9 });
|
|
323
339
|
});
|
|
324
340
|
test("Claude gap windows sort by confirmed ordinal despite forward references, without duplicating paired output", async () => {
|
|
@@ -327,9 +343,7 @@ test("Claude gap windows sort by confirmed ordinal despite forward references, w
|
|
|
327
343
|
assistant("call", "boot8", [call("t")]), compact("boundary9", "call"),
|
|
328
344
|
row("boot9", "boundary9", "user", bootText(9)), row("result", "notice", "user", [result("t", "output")])];
|
|
329
345
|
const projection = project(rows, "result");
|
|
330
|
-
|
|
331
|
-
assert.ok(windows.ok);
|
|
332
|
-
assert.deepEqual(windows.data.windows.map((window) => window.window_id), [8, 9].map((ordinal) => `claude:${sessionId}:${ordinal}`));
|
|
346
|
+
assert.deepEqual(projection.windows.map((window) => window.windowId), [8, 9].map((ordinal) => `claude:${sessionId}:${ordinal}`));
|
|
333
347
|
assert.equal(projection.currentWindowOrdinal, 9);
|
|
334
348
|
assert.equal(projection.highestSeq, 8);
|
|
335
349
|
assert.deepEqual(allItems(projection).filter((event) => event.role === "tool").map((event) => [event.seq, event.text]), [[4, "output"]]);
|
|
@@ -374,16 +388,15 @@ test("Claude helper history tools reuse shared schemas, outcomes and text render
|
|
|
374
388
|
const identity = { home: join(root, "notes"), sessionId, cwd: root, agent: "claude", model: "claude" };
|
|
375
389
|
const history = { sessionId, transcriptPath, headUuid: "r" };
|
|
376
390
|
const projection = await readClaudeHistory(history);
|
|
377
|
-
const operations = [historyList, historyRead
|
|
391
|
+
const operations = [historyList, historyRead];
|
|
378
392
|
for (const operation of operations) {
|
|
379
393
|
const params = operation.name === "history_read" ? { seq: 3 } : {};
|
|
380
394
|
const actual = await dispatch({ op: "tool", tool: operation.name, params, identity, history });
|
|
381
395
|
const expected = operation.name === "history_read" ? { text: historyRead.render(await historyRead.execute({ seq: 3 }, projection)), ok: true }
|
|
382
|
-
:
|
|
383
|
-
: { text: historyWindows.render(await historyWindows.execute({}, projection, sessionId)), ok: true };
|
|
396
|
+
: { text: historyList.render(await historyList.execute({}, projection)), ok: true };
|
|
384
397
|
assert.deepEqual(actual, expected);
|
|
385
398
|
}
|
|
386
399
|
assert.deepEqual(await dispatch({ op: "history_state", identity, history }), { window: 0 });
|
|
387
|
-
await assert.rejects(dispatch({ op: "tool", tool: "
|
|
388
|
-
await assert.rejects(dispatch({ op: "tool", tool: "
|
|
400
|
+
await assert.rejects(dispatch({ op: "tool", tool: "history_list", params: {}, identity }), /transcript_path is unavailable/);
|
|
401
|
+
await assert.rejects(dispatch({ op: "tool", tool: "history_list", params: {}, identity, history: { ...history, sessionId: "other" } }), /different session/);
|
|
389
402
|
});
|
|
@@ -101,9 +101,9 @@ test("Claude notes survive removal of the session's worktree cwd", async (t) =>
|
|
|
101
101
|
assert.match((await call("notes_read", { address })).result, /done/);
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
-
test("Claude helper exposes the
|
|
104
|
+
test("Claude helper exposes the seven shared notes/history schemas", async () => {
|
|
105
105
|
const schemas = await dispatch({ op: "schemas" });
|
|
106
|
-
assert.deepEqual(schemas.map((schema) => schema.name), ["notes_write", "notes_update", "notes_read", "notes_list", "notes_search", "history_list", "history_read"
|
|
106
|
+
assert.deepEqual(schemas.map((schema) => schema.name), ["notes_write", "notes_update", "notes_read", "notes_list", "notes_search", "history_list", "history_read"]);
|
|
107
107
|
assert.ok(schemas.every((schema) => schema.description.length > 20 && schema.inputSchema.type === "object"));
|
|
108
108
|
});
|
|
109
109
|
test("Claude helper delivers only shared rendered text and success", async () => {
|
|
@@ -288,7 +288,7 @@ test("Claude Mod helper runs from a standalone copied plugin directory", () => {
|
|
|
288
288
|
}));
|
|
289
289
|
const schemas = run('{"op":"schemas"}');
|
|
290
290
|
assert.equal(schemas.ok, true);
|
|
291
|
-
assert.equal(schemas.result?.length,
|
|
291
|
+
assert.equal(schemas.result?.length, 7);
|
|
292
292
|
assert.equal(run("not json").ok, false);
|
|
293
293
|
}
|
|
294
294
|
finally {
|
|
@@ -484,7 +484,7 @@ test("Claude Mod hook delivers the helper's shared text, and marks only a refusa
|
|
|
484
484
|
const handlers = new Map();
|
|
485
485
|
hooks.register((event, handler) => handlers.set(event, handler));
|
|
486
486
|
await handlers.get("session.start")(host, { cwd: home, isInteractive: true }, async (event) => event);
|
|
487
|
-
assert.deepEqual(registered.map((spec) => spec.name), ["empty_brain", "notes_write", "notes_update", "notes_read", "notes_list", "notes_search", "history_list", "history_read"
|
|
487
|
+
assert.deepEqual(registered.map((spec) => spec.name), ["empty_brain", "notes_write", "notes_update", "notes_read", "notes_list", "notes_search", "history_list", "history_read"]);
|
|
488
488
|
for (const spec of registered) {
|
|
489
489
|
assert.equal(spec.isDeferred, false, `${spec.name} is available from the start without tool search`);
|
|
490
490
|
assert.ok(spec.description.length > 20);
|
|
@@ -530,7 +530,7 @@ test("Claude Mod crosses old reset thresholds without clearing and retains one f
|
|
|
530
530
|
return result;
|
|
531
531
|
};
|
|
532
532
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
533
|
-
assert.equal(registered.length,
|
|
533
|
+
assert.equal(registered.length, 8);
|
|
534
534
|
const initial = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
|
|
535
535
|
assert.equal(initial.blocks.length, 1, "below the warn point no warning joins the boot");
|
|
536
536
|
assert.match(initial.blocks[0].text, /Current context window id: claude:hook-session:0/);
|
|
@@ -1360,7 +1360,7 @@ test("Claude history keeps classic transcript_path across startup, confirms appe
|
|
|
1360
1360
|
// Real order: classic -> startup attachment appends -> typed session.start.
|
|
1361
1361
|
await invoke("session.append", { uuid: "startup" }, { uuid: "startup", message: {} });
|
|
1362
1362
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
1363
|
-
assert.equal(registered.length,
|
|
1363
|
+
assert.equal(registered.length, 8);
|
|
1364
1364
|
const listed = await call("history_list", { roles: ["user", "context"] });
|
|
1365
1365
|
assert.equal(listed.isError, undefined, listed.result);
|
|
1366
1366
|
assert.match(listed.result, /old request/);
|
|
@@ -1392,7 +1392,7 @@ test("Claude history without a documented path refuses honestly and keeps notes
|
|
|
1392
1392
|
const handlers = new Map();
|
|
1393
1393
|
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
1394
1394
|
await handlers.get("session.start")(host, { cwd: home, isInteractive: true }, async () => ({}));
|
|
1395
|
-
const history = await handlers.get("tool.call")(host, { tool: "
|
|
1395
|
+
const history = await handlers.get("tool.call")(host, { tool: "mcp__notesoup__history_list", tool_use_id: "history" }, async () => ({}));
|
|
1396
1396
|
assert.equal(history.isError, true);
|
|
1397
1397
|
assert.match(history.result, /transcript_path is unavailable/);
|
|
1398
1398
|
const notes = await handlers.get("tool.call")(host, { tool: "mcp__notesoup__notes_list", tool_use_id: "notes" }, async () => ({}));
|
|
@@ -7,7 +7,7 @@ import { test } from "node:test";
|
|
|
7
7
|
import { readCodexHistory } from "../plugins/codex/src/history.js";
|
|
8
8
|
import { readCodexTranscriptState } from "../plugins/codex/src/transcript.js";
|
|
9
9
|
import { allItems, eventDocument } from "../src/history/history.js";
|
|
10
|
-
import { historyList, historyRead
|
|
10
|
+
import { historyList, historyRead } from "../src/tools/history.js";
|
|
11
11
|
/* Producer-shaped synthetic fixtures, not captured/private transcripts.
|
|
12
12
|
* Frozen official rust-v0.160.1, d27764b82f7118f674371e6d6e76271d9d606edb:
|
|
13
13
|
* - history/src/{lib.rs,rollout_payload.rs}: flattened JSONL envelope, top-level
|
|
@@ -123,14 +123,11 @@ test("two native checkpoints retain old raw history; replacement_history is not
|
|
|
123
123
|
assert.equal(second.firstWindowId, W0);
|
|
124
124
|
assert.deepEqual(allItems(second.projection).filter((i) => i.seq <= 3), allItems(first.projection));
|
|
125
125
|
assert.doesNotMatch(allItems(second.projection).map(eventDocument).join("\n"), /COPIED CHECKPOINT TEXT/);
|
|
126
|
-
|
|
127
|
-
assert.ok(windows.ok);
|
|
128
|
-
assert.equal(windows.data.session_id, ROOT);
|
|
129
|
-
assert.deepEqual(windows.data.windows.map((w) => [w.window_id, w.first_seq, w.last_seq]), [
|
|
126
|
+
assert.deepEqual(second.projection.windows.map((w) => [w.windowId, w.items[0]?.seq, w.items.at(-1)?.seq]), [
|
|
130
127
|
[`codex:${ROOT}:${W0}`, 2, 3], [`codex:${ROOT}:${W1}`, 4, 6], [`codex:${ROOT}:${W2}`, 7, 8],
|
|
131
128
|
]);
|
|
132
|
-
const
|
|
133
|
-
assert.match(historyList.render(
|
|
129
|
+
const earlier = await historyList.execute({ after_seq: 3, before_seq: 7, roles: ["user"] }, second.projection);
|
|
130
|
+
assert.match(historyList.render(earlier), /^seq 6 \| user\nmiddle text$/);
|
|
134
131
|
const old = await historyRead.execute({ seq: 2 }, second.projection);
|
|
135
132
|
assert.match(historyRead.render(old), /old raw text/);
|
|
136
133
|
const { projection: _projection, ...facts } = second;
|
|
@@ -211,9 +208,6 @@ test("child root session_id isn't thread identity; copied inference prefix isn't
|
|
|
211
208
|
const result = await readCodexHistory({ transcriptPath: path, threadId: CHILD });
|
|
212
209
|
assert.equal(result.rootSessionId, ROOT);
|
|
213
210
|
assert.equal(result.threadId, CHILD);
|
|
214
|
-
const windows = await historyWindows.execute({}, result.projection, result.threadId);
|
|
215
|
-
assert.ok(windows.ok);
|
|
216
|
-
assert.equal(windows.data.session_id, CHILD);
|
|
217
211
|
assert.equal(result.model, "child-model");
|
|
218
212
|
assert.equal(result.currentWindowId, WC);
|
|
219
213
|
assert.doesNotMatch(allItems(result.projection).map(eventDocument).join("\n"), /INHERITED/);
|
|
@@ -11,6 +11,7 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|
|
11
11
|
import { Check } from "typebox/value";
|
|
12
12
|
import { runHook } from "../plugins/codex/src/hooks.js";
|
|
13
13
|
import { writeBinding } from "../plugins/codex/src/identity.js";
|
|
14
|
+
import { isolateHistoryRoots, writePiTranscript } from "./helpers/history-corpus.js";
|
|
14
15
|
/* Producer-shaped synthetic fixtures, not captured/private transcripts.
|
|
15
16
|
* Frozen official rust-v0.160.1, d27764b82f7118f674371e6d6e76271d9d606edb.
|
|
16
17
|
* Legacy records omit ordinals; a Compacted record names the new native window.
|
|
@@ -146,7 +147,7 @@ test("a copied plugin without src or node_modules still initializes and lists al
|
|
|
146
147
|
const client = await connect(t, data, join(copy, "dist/codex/notesoup.js"));
|
|
147
148
|
const listed = await client.listTools();
|
|
148
149
|
assert.deepEqual(listed.tools.map((tool) => tool.name).sort(), [
|
|
149
|
-
"history_list", "history_read",
|
|
150
|
+
"history_list", "history_read",
|
|
150
151
|
"notes_list", "notes_read", "notes_search", "notes_update", "notes_write",
|
|
151
152
|
]);
|
|
152
153
|
for (const tool of listed.tools) {
|
|
@@ -162,6 +163,26 @@ test("a copied plugin without src or node_modules still initializes and lists al
|
|
|
162
163
|
assert.match(refusal, /child post-compact boot/);
|
|
163
164
|
});
|
|
164
165
|
/* ---------------------------------------------------------------- MCP tools */
|
|
166
|
+
test("bundled Codex MCP reads another harness and wildcard results retain their session identity", async (t) => {
|
|
167
|
+
const f = await fixture(t);
|
|
168
|
+
const roots = isolateHistoryRoots(t, f.home);
|
|
169
|
+
await writePiTranscript(roots.pi, "foreign-pi");
|
|
170
|
+
await writeFile(f.transcript, jsonl([row("session_meta", sessionMeta()), row("response_item", message("user", "Codex needle"))]));
|
|
171
|
+
await bind(f.data, { threadId: ROOT, rootSessionId: ROOT, home: f.home, cwd: f.cwd, transcriptPath: f.transcript });
|
|
172
|
+
const client = await connect(t, f.data, CLI, f.home);
|
|
173
|
+
const read = await call(client, { name: "history_read", arguments: { session: "pi:foreign", seq: 1 }, _meta: metaFor(ROOT, ROOT) });
|
|
174
|
+
assert.equal(read.isError, undefined, textOf(read));
|
|
175
|
+
assert.equal(read.structuredContent.session, "pi:foreign-pi");
|
|
176
|
+
assert.match(textOf(read), /^session pi:foreign-pi \| seq 1 \| user/);
|
|
177
|
+
const list = await call(client, { name: "history_list", arguments: { session: "*", query: "needle" }, _meta: metaFor(ROOT, ROOT) });
|
|
178
|
+
assert.equal(list.isError, undefined, textOf(list));
|
|
179
|
+
const page = list.structuredContent;
|
|
180
|
+
assert.deepEqual(new Set(page.items.map((item) => item.session)), new Set([`codex:${ROOT}`, "pi:foreign-pi"]));
|
|
181
|
+
assert.equal(page.page_older, null);
|
|
182
|
+
assert.equal(page.page_newer, null);
|
|
183
|
+
const invalid = await call(client, { name: "history_read", arguments: { session: "*", seq: 1 }, _meta: metaFor(ROOT, ROOT) });
|
|
184
|
+
assert.equal(errorCode(invalid), "invalid_session");
|
|
185
|
+
});
|
|
165
186
|
test("notes tools use the hook thread as the session notebook and the current turn model as @model", async (t) => {
|
|
166
187
|
const f = await fixture(t);
|
|
167
188
|
await writeFile(f.transcript, jsonl([row("session_meta", sessionMeta())]));
|
|
@@ -256,12 +277,10 @@ test("history tools serve root and child native ancestry, and refuse stale nativ
|
|
|
256
277
|
await bind(f.data, { threadId: ROOT, rootSessionId: ROOT, home: f.home, cwd: f.cwd, transcriptPath: f.transcript, windowId: W1 });
|
|
257
278
|
const client = await connect(t, f.data, CLI, f.home);
|
|
258
279
|
const meta = metaFor(ROOT, ROOT, "gpt-5.1-codex", W1);
|
|
259
|
-
const windows = await call(client, { name: "history_windows", arguments: {}, _meta: meta });
|
|
260
|
-
assert.equal(windows.isError, undefined);
|
|
261
|
-
assert.equal(windows.structuredContent.session_id, ROOT);
|
|
262
|
-
assert.deepEqual(windows.structuredContent.windows.map((w) => w.window_id), [`codex:${ROOT}:${W0}`, `codex:${ROOT}:${W1}`]);
|
|
263
280
|
const page = await call(client, { name: "history_list", arguments: {}, _meta: meta });
|
|
264
|
-
assert.
|
|
281
|
+
assert.equal(page.isError, undefined);
|
|
282
|
+
assert.match(textOf(page), /seq 2 \| user\nroot before/);
|
|
283
|
+
assert.match(textOf(page), /seq 4 \| user\nroot after/);
|
|
265
284
|
const read = await call(client, { name: "history_read", arguments: { seq: 4 }, _meta: meta });
|
|
266
285
|
assert.match(textOf(read), /root after/);
|
|
267
286
|
const childPath = join(dirname(f.transcript), nativeName(CHILD));
|
|
@@ -270,10 +289,12 @@ test("history tools serve root and child native ancestry, and refuse stale nativ
|
|
|
270
289
|
row("response_item", message("user", "child task")),
|
|
271
290
|
]));
|
|
272
291
|
await bind(f.data, { threadId: CHILD, rootSessionId: ROOT, home: f.home, cwd: f.cwd, transcriptPath: childPath, agent: "worker", agentType: "worker" });
|
|
273
|
-
const
|
|
274
|
-
assert.equal(
|
|
275
|
-
|
|
276
|
-
assert.
|
|
292
|
+
const invalidFilter = await call(client, { name: "history_list", arguments: { window_id: "anything" }, _meta: meta });
|
|
293
|
+
assert.equal(errorCode(invalidFilter), "invalid_params");
|
|
294
|
+
const childHistory = await call(client, { name: "history_list", arguments: {}, _meta: metaFor(CHILD, ROOT) });
|
|
295
|
+
assert.equal(childHistory.isError, undefined);
|
|
296
|
+
assert.match(textOf(childHistory), /^seq 2 \| user\nchild task$/);
|
|
297
|
+
assert.doesNotMatch(textOf(childHistory), /root before|root after/);
|
|
277
298
|
const other = join(dirname(f.transcript), nativeName("019a0000-0000-7000-8000-000000000077"));
|
|
278
299
|
await writeFile(other, jsonl([row("session_meta", sessionMeta(CHILD, { session_id: "019a0000-0000-7000-8000-000000000088" })), row("response_item", message("user", "elsewhere"))]));
|
|
279
300
|
await bind(f.data, { threadId: CHILD, rootSessionId: ROOT, home: f.home, cwd: f.cwd, transcriptPath: other });
|
|
@@ -299,7 +320,7 @@ test("a root boot carries the native window, native reset names, and is deduped
|
|
|
299
320
|
assert.match(boot, new RegExp(`Agent name: anonymous \\(brain: gpt-5-4\\)`));
|
|
300
321
|
assert.match(boot, new RegExp(`codex:${ROOT}`));
|
|
301
322
|
assert.match(boot, new RegExp(`<notesoup:codex_window>\\nthread: ${ROOT}\\nwindow: ${W0}`));
|
|
302
|
-
// The
|
|
323
|
+
// The boot tree still labels its native current window.
|
|
303
324
|
assert.match(boot, new RegExp(`${W0} {4}← you are here`));
|
|
304
325
|
assert.match(boot, /native `new_context`/);
|
|
305
326
|
assert.match(boot, /get_context_remaining/);
|
|
@@ -211,7 +211,7 @@ test("AST guard sees every literal module edge, not import-like prose or comment
|
|
|
211
211
|
});
|
|
212
212
|
test("the core entry is host-neutral and the Pi plugin entry owns the extension", () => {
|
|
213
213
|
assert.deepEqual(Object.keys(core).sort(), [
|
|
214
|
-
"DEFAULT_BOOT_TOOL_NAMES", "NoteError", "createNotesStore", "deriveThresholds", "historyList", "historyRead",
|
|
214
|
+
"DEFAULT_BOOT_TOOL_NAMES", "NoteError", "createNotesStore", "deriveThresholds", "historyList", "historyRead",
|
|
215
215
|
"loadNotesSnapshot", "noteIdentity", "notesIdentityForCall", "notesList", "notesRead", "notesSearch", "notesToolContext", "notesUpdate", "notesWrite", "projectHistory",
|
|
216
216
|
"projectKey", "remainingBudget", "renderBootBlock", "renderProtocolBlock", "selectContinuation", "slugify",
|
|
217
217
|
"tokenBudgetGuidance", "unavailableNotesSnapshot", "warningPrompt", "WARNING_BODY",
|
|
@@ -235,8 +235,8 @@ test("the configured extension source is the executable current entry", async ()
|
|
|
235
235
|
registerTool(tool) { tools.push(tool); },
|
|
236
236
|
registerCommand(name) { commands.push(name); },
|
|
237
237
|
});
|
|
238
|
-
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "empty_brain", "get_context_remaining", "history_list", "history_read", "
|
|
239
|
-
assert.deepEqual(tools.filter((tool) => tool.exposure === "deferred").map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "history_list", "history_read"
|
|
238
|
+
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "empty_brain", "get_context_remaining", "history_list", "history_read", "notes_list", "notes_read", "notes_search", "notes_update", "notes_write"]);
|
|
239
|
+
assert.deepEqual(tools.filter((tool) => tool.exposure === "deferred").map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "history_list", "history_read"], "dream and history tools stay hidden until searched");
|
|
240
240
|
assert.deepEqual(commands.sort(), ["empty", "fresh-window", "notesoup"]);
|
|
241
241
|
});
|
|
242
242
|
test("NOTESOUP_DISABLED turns the Pi extension fully off", async () => {
|
package/dist/test/dsh.test.js
CHANGED
|
@@ -21,12 +21,34 @@ import { measureBudget } from "../plugins/dsh/budget.js";
|
|
|
21
21
|
import { COUNTDOWN_LINE, FORCED_CONTINUATIONS, NORMAL_CONTINUATIONS } from "../src/budget/text.js";
|
|
22
22
|
import { preflight } from "../plugins/dsh/engine.js";
|
|
23
23
|
import { BasicCompactionEngine } from "@deepseek-ai/dsh-compaction-basic";
|
|
24
|
+
import { isolateHistoryRoots, writePiTranscript } from "./helpers/history-corpus.js";
|
|
24
25
|
function prompt(text) { return createUserMessage({ content: [{ type: "text", text }], source: { kind: "user" } }); }
|
|
25
26
|
async function run(agent, text) { agent.followup(prompt(text)); await agent.whenIdle(); }
|
|
26
27
|
function system(request) { return typeof request.system === "string" ? request.system : request.system?.map((block) => block.text).join("\n") ?? ""; }
|
|
27
28
|
function code(expected) { return (error) => error?.code === expected; }
|
|
28
29
|
// Critical lifecycle tests exercise the actual loop, DeepSeek HTTP adapter, tool registry,
|
|
29
30
|
// token meter and SQLite query service. Only the provider is a scripted Messages server.
|
|
31
|
+
test("dsh registered tools query other DSH sessions and foreign Pi files through the same session surface", async (t) => {
|
|
32
|
+
const { ctx, create, directory } = await dshFixture(t);
|
|
33
|
+
const roots = isolateHistoryRoots(t, directory);
|
|
34
|
+
await writePiTranscript(roots.pi, "foreign-pi");
|
|
35
|
+
const reader = await create(undefined, "reader"), target = await create(undefined, "target");
|
|
36
|
+
target.session.append("user/message", prompt("DSH needle"), { surfaceOp: "append" });
|
|
37
|
+
const invoke = (name, args) => ctx.tools.execute({ name, arguments: args, agent: reader, callId: ToolCallId("cross-session"), signal: new AbortController().signal });
|
|
38
|
+
const listed = await invoke("history_list", { session: "dsh:tar", query: "needle" });
|
|
39
|
+
assert.equal(listed.isError, false, JSON.stringify(listed));
|
|
40
|
+
const page = listed.value;
|
|
41
|
+
assert.equal(page.items[0].session, "dsh:target");
|
|
42
|
+
const read = await invoke("history_read", { session: page.items[0].session, seq: page.items[0].seq });
|
|
43
|
+
assert.equal(read.isError, false);
|
|
44
|
+
assert.equal(read.value.text, "DSH needle");
|
|
45
|
+
const foreign = await invoke("history_read", { session: "pi:foreign", seq: 1 });
|
|
46
|
+
assert.equal(foreign.isError, false);
|
|
47
|
+
assert.equal(foreign.value.session, "pi:foreign-pi");
|
|
48
|
+
const across = await invoke("history_list", { session: "*", query: "needle" });
|
|
49
|
+
assert.equal(across.isError, false, JSON.stringify(across));
|
|
50
|
+
assert.deepEqual(new Set(across.value.items.map((item) => item.session)), new Set(["dsh:target", "pi:foreign-pi"]));
|
|
51
|
+
});
|
|
30
52
|
test("dsh boot freezes across note writes, rotates before the next wire request, and keeps raw history", async (t) => {
|
|
31
53
|
const { ctx, engine, create, mock } = await dshFixture(t);
|
|
32
54
|
const agent = await create();
|
|
@@ -343,10 +365,10 @@ test("dsh explicit resets survive auto:false; shared tool reads and expected err
|
|
|
343
365
|
if (!read.isError)
|
|
344
366
|
assert.equal(read.value.text, "raw");
|
|
345
367
|
}
|
|
346
|
-
const
|
|
347
|
-
assert.equal(
|
|
348
|
-
if (
|
|
349
|
-
assert.equal(
|
|
368
|
+
const invalidHistory = await call("history_list", { window_id: "missing" });
|
|
369
|
+
assert.equal(invalidHistory.isError, true);
|
|
370
|
+
if (invalidHistory.isError)
|
|
371
|
+
assert.equal(invalidHistory.error.info?.code, "INVALID_PARAMS");
|
|
350
372
|
const invalid = await call("notes_read", { address: "anything", max_chars: 0 });
|
|
351
373
|
assert.equal(invalid.isError, true);
|
|
352
374
|
if (invalid.isError)
|
|
@@ -100,7 +100,6 @@ export type ReadIdentity = {
|
|
|
100
100
|
metadata?: Record<string, unknown>;
|
|
101
101
|
address?: string;
|
|
102
102
|
seq?: number;
|
|
103
|
-
window_id?: string;
|
|
104
103
|
};
|
|
105
104
|
/** The structured data of a read outcome: the window plus whatever identity the operation adds. */
|
|
106
105
|
export type ReadOutcome<T extends object = ReadIdentity> = TextWindow & T;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TestContext } from "node:test";
|
|
2
|
+
export declare function isolateHistoryRoots(t: TestContext, home: string): {
|
|
3
|
+
pi: string;
|
|
4
|
+
claude: string;
|
|
5
|
+
codex: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function writePiTranscript(root: string, id: string, text?: string): Promise<string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Temporary discovery roots for adapter tests; never scan the operator's real transcripts. */
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
export function isolateHistoryRoots(t, home) {
|
|
5
|
+
const roots = { pi: join(home, "pi-sessions"), claude: join(home, "claude-projects"), codex: join(home, "sessions") };
|
|
6
|
+
for (const [harness, root] of Object.entries(roots)) {
|
|
7
|
+
const key = `NOTESOUP_HISTORY_${harness.toUpperCase()}_ROOT`;
|
|
8
|
+
const previous = process.env[key];
|
|
9
|
+
process.env[key] = root;
|
|
10
|
+
t.after(() => { if (previous === undefined)
|
|
11
|
+
delete process.env[key];
|
|
12
|
+
else
|
|
13
|
+
process.env[key] = previous; });
|
|
14
|
+
}
|
|
15
|
+
return roots;
|
|
16
|
+
}
|
|
17
|
+
export async function writePiTranscript(root, id, text = "foreign needle") {
|
|
18
|
+
const timestamp = "2026-10-06T01:02:03.000Z";
|
|
19
|
+
const path = join(root, "--workspace--", `2026-10-06T01-02-03_${id}.jsonl`);
|
|
20
|
+
await mkdir(dirname(path), { recursive: true });
|
|
21
|
+
await writeFile(path, [
|
|
22
|
+
{ type: "session", version: 3, id, timestamp, cwd: "/workspace" },
|
|
23
|
+
{ type: "message", id: "u", parentId: null, timestamp, message: { role: "user", content: text } },
|
|
24
|
+
].map((row) => JSON.stringify(row) + "\n").join(""));
|
|
25
|
+
return path;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|