notesoup 0.54.2 → 0.55.1
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/dist/plugins/pi/budget.js +1 -1
- package/dist/plugins/pi/marker.d.ts +1 -1
- package/dist/plugins/pi/marker.js +11 -7
- package/dist/plugins/pi/notes/tools.js +5 -1
- package/dist/plugins/pi/render.d.ts +4 -1
- package/dist/plugins/pi/render.js +3 -7
- package/dist/plugins/pi/runtime.js +5 -5
- package/dist/plugins/pi/tool-result.d.ts +4 -2
- package/dist/plugins/pi/tool-result.js +5 -4
- package/dist/src/history/claude.d.ts +1 -1
- package/dist/src/history/claude.js +11 -6
- package/dist/src/history/codex-transcript.d.ts +2 -0
- package/dist/src/history/codex-transcript.js +3 -2
- package/dist/src/history/corpus.d.ts +2 -1
- package/dist/src/history/corpus.js +5 -2
- package/dist/src/history/history.d.ts +1 -1
- package/dist/src/history/history.js +1 -1
- package/dist/src/history/local.d.ts +2 -6
- package/dist/src/history/local.js +34 -2
- package/dist/src/history/query.d.ts +4 -2
- package/dist/src/history/query.js +17 -8
- package/dist/src/tools/history.js +17 -13
- package/dist/src/tools/notes.d.ts +2 -7
- package/dist/src/tools/notes.js +5 -26
- package/dist/test/boot.integration.test.js +24 -0
- package/dist/test/budget-settings.integration.test.js +2 -2
- package/dist/test/claude-history.test.js +4 -6
- package/dist/test/codex-history.test.js +3 -2
- package/dist/test/dependencies.test.js +3 -4
- package/dist/test/dream-tools.test.js +3 -3
- package/dist/test/history-corpus.test.js +238 -14
- package/dist/test/history.integration.test.js +9 -9
- package/dist/test/host-neutral.test.js +7 -9
- package/dist/test/marker.test.js +34 -27
- package/dist/test/notes.integration.test.js +8 -10
- package/dist/test/notes.test.js +9 -7
- package/dist/test/pi-render.test.js +7 -7
- package/dist/test/project-namespace.test.js +4 -4
- package/docs/claude-code-mod.md +1 -1
- package/docs/history-sessions.md +9 -7
- package/docs/skills.md +1 -1
- package/docs/tool-results.md +3 -3
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +68 -47
- package/plugins/claude/skills/memory/SKILL.md +4 -2
- package/plugins/codex/dist/codex/notesoup.js +68 -47
- package/plugins/paseo/OVERVIEW.md +2 -2
- package/plugins/paseo/client/brain-empty-card.tsx +1 -1
- package/plugins/paseo/client/notes-op-card.tsx +1 -1
- package/plugins/paseo/client/notes-op-transformer.ts +16 -1
- package/plugins/paseo/client/paper-palette.ts +18 -18
- package/plugins/paseo/test/fixtures/claude-tool-calls.ts +1 -1
- package/plugins/paseo/test/notes-op.test.ts +4 -4
- package/plugins/paseo/test/paper-palette.test.ts +3 -3
- package/plugins/pi/budget.ts +1 -1
- package/plugins/pi/marker.ts +11 -6
- package/plugins/pi/notes/tools.ts +5 -1
- package/plugins/pi/render.ts +7 -8
- package/plugins/pi/runtime.ts +4 -3
- package/plugins/pi/tool-result.ts +10 -9
- package/skills/memory/SKILL.md +4 -2
- package/src/history/claude.ts +9 -4
- package/src/history/codex-transcript.ts +3 -2
- package/src/history/corpus.ts +9 -3
- package/src/history/history.ts +1 -1
- package/src/history/local.ts +36 -4
- package/src/history/query.ts +17 -6
- package/src/tools/history.ts +13 -12
- package/src/tools/notes.ts +5 -27
package/dist/test/marker.test.js
CHANGED
|
@@ -9,65 +9,72 @@ const env = installExtensionTestEnvironment("notesoup-marker-test");
|
|
|
9
9
|
test.beforeEach(env.beforeEach);
|
|
10
10
|
test.afterEach(env.afterEach);
|
|
11
11
|
test.after(env.dispose);
|
|
12
|
-
function
|
|
13
|
-
return runHandlers(captured, "
|
|
12
|
+
function beforeAgentStart(captured, ctx) {
|
|
13
|
+
return runHandlers(captured, "before_agent_start", { type: "before_agent_start" }, ctx);
|
|
14
14
|
}
|
|
15
|
-
test("marker stamps its own seq once the interval is reached,
|
|
16
|
-
const sessionManager = managerWithMessages(
|
|
15
|
+
test("marker stamps its own seq at run start once the interval is reached, never mid-turn", async () => {
|
|
16
|
+
const sessionManager = managerWithMessages(119);
|
|
17
17
|
const captured = makeExtension(sessionManager);
|
|
18
18
|
const ctx = context(sessionManager);
|
|
19
|
-
|
|
19
|
+
// Mid-run tool turns never inject a standalone marker message.
|
|
20
|
+
await runHandlers(captured, "turn_start", { type: "turn_start" }, ctx);
|
|
21
|
+
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
22
|
+
await beforeAgentStart(captured, ctx);
|
|
20
23
|
const sent = sentOf(captured, MARKER_TYPE);
|
|
21
24
|
assert.equal(sent.length, 1);
|
|
22
|
-
assert.deepEqual(sent[0].message.details, { seq:
|
|
25
|
+
assert.deepEqual(sent[0].message.details, { seq: 120 });
|
|
23
26
|
assert.equal(sent[0].message.display, false);
|
|
24
27
|
assert.equal(sent[0].options?.triggerTurn, false);
|
|
25
|
-
assert.equal(sent[0].message.content, '<notesoup:marker seq="
|
|
26
|
-
assert.equal(nextHistorySeq(ctx),
|
|
27
|
-
// An immediate second
|
|
28
|
-
await
|
|
28
|
+
assert.equal(sent[0].message.content, '<notesoup:marker seq="120" />');
|
|
29
|
+
assert.equal(nextHistorySeq(ctx), 121, "the marker occupies the seq it names");
|
|
30
|
+
// An immediate second run is only one seq later: no new marker.
|
|
31
|
+
await beforeAgentStart(captured, ctx);
|
|
29
32
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 1);
|
|
30
|
-
// The next marker lands
|
|
31
|
-
appendText(sessionManager, "user", "x"
|
|
32
|
-
for (let i = 0; i <
|
|
33
|
+
// The next marker lands one interval after the last.
|
|
34
|
+
appendText(sessionManager, "user", "x");
|
|
35
|
+
for (let i = 0; i < 118; i++)
|
|
33
36
|
appendText(sessionManager, "assistant", "y");
|
|
34
|
-
await
|
|
37
|
+
await beforeAgentStart(captured, ctx);
|
|
35
38
|
const all = sentOf(captured, MARKER_TYPE);
|
|
36
39
|
assert.equal(all.length, 2);
|
|
37
|
-
assert.deepEqual(all[1].message.details, { seq:
|
|
40
|
+
assert.deepEqual(all[1].message.details, { seq: 240 });
|
|
38
41
|
});
|
|
39
42
|
test("no marker before the interval", async () => {
|
|
40
|
-
const sessionManager = managerWithMessages(
|
|
43
|
+
const sessionManager = managerWithMessages(118);
|
|
41
44
|
const captured = makeExtension(sessionManager);
|
|
42
|
-
await
|
|
45
|
+
await beforeAgentStart(captured, context(sessionManager));
|
|
43
46
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
44
|
-
assert.equal(MARKER_INTERVAL,
|
|
47
|
+
assert.equal(MARKER_INTERVAL, 120);
|
|
45
48
|
});
|
|
46
|
-
test("a reset tail awaiting repair
|
|
47
|
-
const sessionManager = managerWithMessages(
|
|
49
|
+
test("a reset tail awaiting repair blocks markers, and boot anchors the new window's interval", async () => {
|
|
50
|
+
const sessionManager = managerWithMessages(119);
|
|
48
51
|
const captured = makeExtension(sessionManager);
|
|
49
52
|
const ctx = context(sessionManager);
|
|
50
53
|
// A marker with neither boot nor continuation still expects repair; stay out of its tail.
|
|
51
54
|
sessionManager.appendCustomEntry(RESET_MARKER_TYPE, { windowId: "pcw:test:w1" });
|
|
52
|
-
await
|
|
55
|
+
await beforeAgentStart(captured, ctx);
|
|
53
56
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
54
57
|
// Boot alone is still an open tail.
|
|
55
58
|
sessionManager.appendCustomMessageEntry(BOOT_TYPE, "boot", false, { windowId: "pcw:test:w1" });
|
|
56
|
-
await
|
|
59
|
+
await beforeAgentStart(captured, ctx);
|
|
57
60
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
58
|
-
// Once the
|
|
61
|
+
// Once the reset tail is closed, boot (seq 120) already anchored the window's start seq.
|
|
59
62
|
sessionManager.appendCustomMessageEntry(CONTINUATION_TYPE, "continued", false);
|
|
60
|
-
await
|
|
63
|
+
await beforeAgentStart(captured, ctx);
|
|
64
|
+
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
65
|
+
for (let i = 0; i < 118; i++)
|
|
66
|
+
appendText(sessionManager, "assistant", "y");
|
|
67
|
+
await beforeAgentStart(captured, ctx);
|
|
61
68
|
const sent = sentOf(captured, MARKER_TYPE);
|
|
62
69
|
assert.equal(sent.length, 1);
|
|
63
|
-
assert.deepEqual(sent[0].message.details, { seq:
|
|
70
|
+
assert.deepEqual(sent[0].message.details, { seq: 240 });
|
|
64
71
|
});
|
|
65
72
|
test("notesoup off silences the odometer", async () => {
|
|
66
|
-
const sessionManager = managerWithMessages(
|
|
73
|
+
const sessionManager = managerWithMessages(119);
|
|
67
74
|
const captured = makeExtension(sessionManager);
|
|
68
75
|
const ctx = context(sessionManager);
|
|
69
76
|
await runCommand(captured, "notesoup", "off", ctx);
|
|
70
|
-
await
|
|
77
|
+
await beforeAgentStart(captured, ctx);
|
|
71
78
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
72
79
|
});
|
|
73
80
|
function managerWithMessages(count) {
|
|
@@ -187,9 +187,10 @@ test("crumple lifecycle: metadata-only edits close and smooth a note without tou
|
|
|
187
187
|
await call(captured, "notes_write", { address: "journal.md", content: "log line" }, ctx);
|
|
188
188
|
const updatedBefore = (await listNotes(ctx))[0].meta.updatedAt;
|
|
189
189
|
// metadata-only: content unchanged, and the recorded time is the original one
|
|
190
|
-
const
|
|
190
|
+
const markOnlyRaw = await call(captured, "notes_update", { address: "journal.md", crumpled: true }, ctx);
|
|
191
|
+
const markOnly = resultData(markOnlyRaw);
|
|
191
192
|
assert.equal(markOnly.change_kind, "metadata");
|
|
192
|
-
assert.match(
|
|
193
|
+
assert.match(markOnlyRaw.details?.diff ?? "", /^\+\s*\d+\s+crumpledAt: \d{4}-\d{2}-\d{2}T/m);
|
|
193
194
|
assert.deepEqual(await listNotes(ctx), [], "a crumpled note leaves the live list");
|
|
194
195
|
const basket = (await listNotes(ctx, { crumpled: true }))[0];
|
|
195
196
|
assert.ok(basket.meta.crumpledAt);
|
|
@@ -476,23 +477,20 @@ test("notes_search scopes by glob; a non-matching glob is an empty page, not an
|
|
|
476
477
|
const none = resultData(await call(captured, "notes_search", { query: "needle", glob: "absent/**" }, ctx));
|
|
477
478
|
assert.deepEqual(none.files, [], "a non-matching glob is an empty page, not a refusal");
|
|
478
479
|
});
|
|
479
|
-
test("
|
|
480
|
+
test("a large mutation keeps a one-line receipt while details.diff carries the UI diff", async () => {
|
|
480
481
|
const session = manager();
|
|
481
482
|
const captured = makeExtension(session);
|
|
482
483
|
const ctx = context(session);
|
|
483
484
|
const line = `${"a".repeat(300)}\n`;
|
|
484
485
|
await call(captured, "notes_write", { address: "bulk-edit.md", content: line.repeat(1500) }, ctx);
|
|
485
486
|
const raw = await call(captured, "notes_update", { address: "bulk-edit.md", edits: [{ oldText: "a".repeat(300), newText: "b".repeat(300) }], replace_all: true }, ctx);
|
|
486
|
-
assertWithinBudget(raw, "
|
|
487
|
+
assertWithinBudget(raw, "bulk edit receipt");
|
|
487
488
|
const update = resultData(raw);
|
|
488
489
|
assert.equal(update.change_kind, "body");
|
|
489
|
-
assert.
|
|
490
|
-
assert.
|
|
491
|
-
assert.match(textOf(raw), /^updated bulk-edit\.md/, "the receipt still names the note it updated");
|
|
492
|
-
assert.ok(textOf(raw).includes("[diff truncated; update applied]"), "the model-facing text carries the same marker");
|
|
493
|
-
assert.equal(textOf(raw).includes(`+${"b".repeat(300)}`), false, "the delivered diff prefix stops inside the first change");
|
|
490
|
+
assert.equal(textOf(raw), "updated bulk-edit.md", "model-facing text is the one-line receipt without redundant diff");
|
|
491
|
+
assert.match(raw.details?.diff ?? "", new RegExp(`\\+.*?${"b".repeat(300)}`), "details.diff carries the UI diff");
|
|
494
492
|
const body = resultRead(await call(captured, "notes_read", { address: "bulk-edit.md", max_chars: 300 }, ctx)).content;
|
|
495
|
-
assert.equal(body, "b".repeat(300), "every one of the 1500 replacements was applied
|
|
493
|
+
assert.equal(body, "b".repeat(300), "every one of the 1500 replacements was applied");
|
|
496
494
|
});
|
|
497
495
|
test("oversized note metadata is named in place instead of riding along in the envelope", async () => {
|
|
498
496
|
const session = manager();
|
package/dist/test/notes.test.js
CHANGED
|
@@ -339,15 +339,17 @@ test("write and update receipts distinguish outcomes and no-op edits", async ()
|
|
|
339
339
|
assert.equal(resultData(await call(captured, "notes_write", { address: "@agents/anonymous/alias.md", content: "new body" }, ctx)).outcome, "overwrote");
|
|
340
340
|
await call(captured, "notes_update", { address: "@self/alias", crumpled: true }, ctx);
|
|
341
341
|
assert.equal(resultData(await call(captured, "notes_write", { address: "@self/alias", content: "restored" }, ctx)).outcome, "uncrumpled");
|
|
342
|
-
const
|
|
343
|
-
|
|
342
|
+
const noChangeRaw = await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "restored", newText: "restored" }], crumpled: false }, ctx);
|
|
343
|
+
const noChange = resultData(noChangeRaw);
|
|
344
|
+
assert.equal(noChange.change_kind, "none");
|
|
345
|
+
assert.equal(noChangeRaw.details, undefined);
|
|
344
346
|
const mixed = resultData(await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "restored", newText: "restored" }, { oldText: "restored", newText: "changed" }] }, ctx));
|
|
345
347
|
assert.equal(mixed.change_kind, "body");
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const combined = resultData(
|
|
348
|
+
// A body edit that also rewrites frontmatter is still a body change; details.diff carries the rest.
|
|
349
|
+
const combinedRaw = await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "changed", newText: "changed once more" }], origin: "user" }, ctx);
|
|
350
|
+
const combined = resultData(combinedRaw);
|
|
349
351
|
assert.equal(combined.change_kind, "body", "an edit that also rewrites frontmatter is a body change, not a whole file");
|
|
350
|
-
assert.match(
|
|
352
|
+
assert.match(combinedRaw.details?.diff ?? "", /origin/, "details.diff still carries the frontmatter part");
|
|
351
353
|
});
|
|
352
354
|
test("empty results distinguish hidden notes and unavailable notebooks", async () => {
|
|
353
355
|
freshRoot();
|
|
@@ -417,7 +419,7 @@ test("mutation receipts keep their existing shape outside named project notebook
|
|
|
417
419
|
const written = await call(captured, "notes_write", { address: "@project/decision", content: "body" }, ctx);
|
|
418
420
|
const updated = await call(captured, "notes_update", { address: "@project/decision", edits: [{ oldText: "body", newText: "changed" }] }, ctx);
|
|
419
421
|
assert.deepEqual(Object.keys(resultData(written)).sort(), ["address", "outcome", "project_key"]);
|
|
420
|
-
assert.deepEqual(Object.keys(resultData(updated)).sort(), ["address", "change_kind", "
|
|
422
|
+
assert.deepEqual(Object.keys(resultData(updated)).sort(), ["address", "change_kind", "project_key"]);
|
|
421
423
|
for (const [name, result] of [["notes_write", written], ["notes_update", updated]]) {
|
|
422
424
|
assert.equal(Check(captured.tools.get(name).outputSchema, result.structuredContent), true, `${name} keeps its ordinary project receipt`);
|
|
423
425
|
}
|
|
@@ -11,8 +11,8 @@ const flatTheme = {
|
|
|
11
11
|
italic: (text) => text,
|
|
12
12
|
strikethrough: (text) => `~~${text}~~`,
|
|
13
13
|
};
|
|
14
|
-
function toolResult(outcome) {
|
|
15
|
-
return { content: [{ type: "text", text: "receipt" }], structuredContent: wireResult(outcome), isError: !outcome.ok, details:
|
|
14
|
+
function toolResult(outcome, details) {
|
|
15
|
+
return { content: [{ type: "text", text: "receipt" }], structuredContent: wireResult(outcome), isError: !outcome.ok, details: details };
|
|
16
16
|
}
|
|
17
17
|
function jsonResult(value, isError = false) {
|
|
18
18
|
return { content: [{ type: "text", text: JSON.stringify(value) }], isError, details: undefined };
|
|
@@ -31,22 +31,22 @@ test("notes_write expanded: the written content follows the header", () => {
|
|
|
31
31
|
assert.equal(lines(component), "wrote plan.md · overwrote · 7 chars\n\none\ntwo");
|
|
32
32
|
});
|
|
33
33
|
test("notes_update edited: collapsed peeks at the first added line", () => {
|
|
34
|
-
const result = toolResult(success({ address: "a.md", change_kind: "body", diff: " 1 old\n-2 gone\n+2 here" })
|
|
34
|
+
const result = toolResult(success({ address: "a.md", change_kind: "body" }), { diff: " 1 old\n-2 gone\n+2 here" });
|
|
35
35
|
const component = notesUpdateRenderers.renderResult(result, { expanded: false }, flatTheme, { args: { address: "a.md" } });
|
|
36
36
|
assert.equal(lines(component), "edited a.md · + here");
|
|
37
37
|
});
|
|
38
38
|
test("notes_update crumple: the address is struck through", () => {
|
|
39
|
-
const result = toolResult(success({ address: "@self/stale.md", change_kind: "metadata"
|
|
39
|
+
const result = toolResult(success({ address: "@self/stale.md", change_kind: "metadata" }));
|
|
40
40
|
const component = notesUpdateRenderers.renderResult(result, { expanded: false }, flatTheme, { args: { address: "@self/stale.md", crumpled: true } });
|
|
41
41
|
assert.equal(lines(component), "✂ crumpled ~~@self/stale.md~~");
|
|
42
42
|
});
|
|
43
43
|
test("notes_update moved: both addresses stay on the line", () => {
|
|
44
|
-
const result = toolResult(success({ address: "@self/new.md", change_kind: "moved",
|
|
44
|
+
const result = toolResult(success({ address: "@self/new.md", change_kind: "moved", rename_from: "a.md" }));
|
|
45
45
|
const component = notesUpdateRenderers.renderResult(result, { expanded: false }, flatTheme, { args: { address: "a.md", rename_to: "@self/new.md" } });
|
|
46
46
|
assert.equal(lines(component), "renamed a.md → @self/new.md");
|
|
47
47
|
});
|
|
48
48
|
test("notes_update unchanged keeps quiet", () => {
|
|
49
|
-
const result = toolResult(success({ address: "a.md", change_kind: "none"
|
|
49
|
+
const result = toolResult(success({ address: "a.md", change_kind: "none" }));
|
|
50
50
|
const component = notesUpdateRenderers.renderResult(result, { expanded: false }, flatTheme, { args: { address: "a.md" } });
|
|
51
51
|
assert.equal(lines(component), "unchanged a.md");
|
|
52
52
|
});
|
|
@@ -115,7 +115,7 @@ test("empty_brain keeps the divider and handoff within very narrow widths", () =
|
|
|
115
115
|
});
|
|
116
116
|
test("notes_update expanded diff goes through the host's diff renderer", () => {
|
|
117
117
|
initTheme();
|
|
118
|
-
const result = toolResult(success({ address: "a.md", change_kind: "body", diff: " 1 old\n-2 gone\n+2 here" })
|
|
118
|
+
const result = toolResult(success({ address: "a.md", change_kind: "body" }), { diff: " 1 old\n-2 gone\n+2 here" });
|
|
119
119
|
const component = notesUpdateRenderers.renderResult(result, { expanded: true }, flatTheme, { args: { address: "a.md" } });
|
|
120
120
|
assert.equal(lines(component), "edited a.md · + here\n\n 1 old\n-2 gone\n+2 here");
|
|
121
121
|
});
|
|
@@ -312,10 +312,10 @@ test("named project writes, edits, crumples and both move endpoints refuse, incl
|
|
|
312
312
|
const address = "@projects/api/decision";
|
|
313
313
|
for (const result of [
|
|
314
314
|
await notesWrite.execute({ address, content: "replacement" }, toolContext(own)),
|
|
315
|
-
await notesUpdate.execute({ address, edits: [{ oldText: "body", newText: "changed" }] }, toolContext(own)
|
|
316
|
-
await notesUpdate.execute({ address, crumpled: true }, toolContext(own)
|
|
317
|
-
await notesUpdate.execute({ address, rename_to: "@project/moved" }, toolContext(own)
|
|
318
|
-
await notesUpdate.execute({ address: "@project/decision", rename_to: "@projects/api/moved" }, toolContext(own)
|
|
315
|
+
await notesUpdate.execute({ address, edits: [{ oldText: "body", newText: "changed" }] }, toolContext(own)),
|
|
316
|
+
await notesUpdate.execute({ address, crumpled: true }, toolContext(own)),
|
|
317
|
+
await notesUpdate.execute({ address, rename_to: "@project/moved" }, toolContext(own)),
|
|
318
|
+
await notesUpdate.execute({ address: "@project/decision", rename_to: "@projects/api/moved" }, toolContext(own)),
|
|
319
319
|
])
|
|
320
320
|
assert.match(refused(result), /read-only; use @project\//);
|
|
321
321
|
assert.equal(data(await notesRead.execute({ address }, toolContext(own))).text, "body");
|
package/docs/claude-code-mod.md
CHANGED
|
@@ -22,7 +22,7 @@ The notes tools also serve subagent calls, using the same session identity and s
|
|
|
22
22
|
|
|
23
23
|
`history_list` and `history_read` use the same schemas, literal search (`history_list.query`), paging, folding, pairing and text rendering as Pi. With `session` omitted they read the current main session's persisted JSONL, via the documented `classic.SessionStart.transcript_path`; no path is guessed and `$.session.messages()` is not treated as full history. The classic binding survives typed `session.start`, which fires later. Without that path, current-session history calls refuse and the boot says history is unavailable. Subagent history calls refuse rather than silently exposing the main transcript.
|
|
24
24
|
|
|
25
|
-
Explicit `session` selectors use the [local cross-harness corpus](history-sessions.md), including Pi/Claude/Codex files, without needing the current main transcript to have a head yet. Explicitly selecting the current Claude session still uses its strict live binding. Offline Claude targets
|
|
25
|
+
Explicit `session` selectors use the [local cross-harness corpus](history-sessions.md), including Pi/Claude/Codex files, without needing the current main transcript to have a head yet. Explicitly selecting the current Claude session still uses its strict live binding. Offline Claude targets prefer non-attachment graph leaves when available, then select the last remaining leaf in transcript order; no leaves still refuses. The persisted Claude decoder is shared under `src/history/claude.ts`; its plugin entry remains in `plugins/claude/src/history.ts`.
|
|
26
26
|
|
|
27
27
|
The active head comes from the main loop's successful `session.append` result UUID, including attachments and notices. On startup/resume, before such an append, the public API supplies no authoritative selected leaf: history explicitly refuses instead of assuming the last file row or `last-prompt.leafUuid` is current. The append result means the engine kept a row, but its disk write may lag; a head missing on disk is a retryable refusal, not permission to switch branches. Session end clears the binding; a new classic start rebinds it.
|
|
28
28
|
|
package/docs/history-sessions.md
CHANGED
|
@@ -17,21 +17,23 @@ Within the requested harness an exact ID wins over prefixes. Without a harness,
|
|
|
17
17
|
|
|
18
18
|
Explicit targeting always returns the canonical `session: "<harness>:<full-id>"`, even when the target happens to be the current session. Headers become `session <harness>:<id> | seq <seq> | <role>`. `page_older`, `page_newer`, folded-row `expand`, and read `neighborhood` recipes carry that same canonical selector. Copy it into subsequent `history_read` calls, including reads continued with `next_offset_chars`.
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Browse or search across sessions
|
|
21
21
|
|
|
22
|
-
Any selector containing `*`
|
|
22
|
+
Any selector containing `*` selects multiple sessions; `*` matches any string and all other characters are literal. `*` covers all available harnesses, `pi:*` restricts to Pi, and `claude:prefix*` narrows by session ID.
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
|
+
history_list({ session: "*" }) // Recent sessions, one opening prompt/topic each
|
|
25
26
|
history_list({ session: "*", query: ["deployment", "rollback"], limit: 20 })
|
|
26
27
|
history_list({ session: "codex:*", query: "migration", roles: ["tool"], since: "2026-10-01" })
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
-
|
|
30
|
+
- With a non-empty `query`, matching is literal, case-insensitive, and ORs a list of texts, as in one-session search. Local files are conservatively pre-filtered before full decoding: JSON escapes, Unicode case folding, generated event text and inherited Codex history must not lose hits. Uncertain cases use the full decoder.
|
|
31
|
+
- Without `query` (including empty strings/lists or lists containing only empty entries), return a recent-sessions overview. Sessions are considered newest-modified first, or oldest-modified first with `from: "oldest"`; loading stops once `limit` sessions (default 20) produce a representative. Apply `roles`, `since` and `until` before choosing each representative: without roles, prefer the first visible user event, falling back to the latest visible dialogue event or latest event of any role; with roles, choose the latest matching visible event. Sort the chosen representatives by event time, oldest first. There are no folded rows.
|
|
30
32
|
- `before_seq` and `after_seq` refuse with `invalid_bounds`: seqs from different sessions cannot define a common range.
|
|
31
33
|
- `history_read` refuses wildcard selectors with `invalid_session`; take a specific `session` and `seq` from a search hit instead.
|
|
32
|
-
-
|
|
34
|
+
- With a query, every role is searched, including tool arguments/output and context; `roles` can narrow this. There are no folded rows.
|
|
33
35
|
- `since` is inclusive and `until` exclusive. Time-bounded searches exclude events with no usable timestamp.
|
|
34
|
-
-
|
|
36
|
+
- Search hits are merged by event time, oldest first, with a deterministic session/seq tie-break; untimed events sort before timed events. For query searches, `limit` counts from the newest event end by default, or the oldest with `from: "oldest"`. The complete text and structured result still share the 32 KiB budget, so large previews can reduce the admitted page.
|
|
35
37
|
- Each event carries its canonical `session`. `page_older` and `page_newer` are always null. Narrow by session pattern, query, roles or time rather than trying to page across per-session seqs.
|
|
36
38
|
|
|
37
39
|
## Local discovery and limits
|
|
@@ -39,11 +41,11 @@ history_list({ session: "codex:*", query: "migration", roles: ["tool"], since: "
|
|
|
39
41
|
| Harness | Default source | Selection/decoding |
|
|
40
42
|
| --- | --- | --- |
|
|
41
43
|
| Pi | `~/.pi/agent/sessions/<workspace>/<timestamp>_<id>.jsonl` | Current session uses the native active branch. Offline current-format files follow persisted parent links from the last tree entry, preserving append seqs and inactive-branch holes. |
|
|
42
|
-
| Claude | `~/.claude/projects/<project>/<id>.jsonl` | The current session still requires its live, confirmed append head. Offline files
|
|
44
|
+
| Claude | `~/.claude/projects/<project>/<id>.jsonl` | The current session still requires its live, confirmed append head. Offline files account for logical compact links, prefer non-attachment graph leaves when available, and select the last remaining leaf in transcript order. Only that leaf's confirmed ancestors are exposed; a graph with no leaves still refuses. |
|
|
43
45
|
| Codex | `~/.codex/sessions/YYYY/MM/DD/rollout-...-<threadId>.jsonl(.zst)` | The same strict 0.160.1 rollout/lineage decoder as current-session history; compressed files need Node >=22.15. Root `session_id` is not a child thread ID. |
|
|
44
46
|
| DSH | `ctx.sessionQuery.listSessions()` / `readSession(id)` | Available inside DSH only, over its live-preferred local session corpus. Other hosts cannot discover DSH files themselves. |
|
|
45
47
|
|
|
46
|
-
Filesystem discovery does not follow directory symlinks or recurse into Claude subagent stores. Missing roots are empty. Repeated native files for one qualified ID produce one descriptor (newest modified); the current live binding wins over its on-disk descriptor. Discovery and decoding never mutate transcript bytes or modification times. Unsupported/corrupt or unreadable selected transcripts return `history_unavailable` naming the session;
|
|
48
|
+
Filesystem discovery does not follow directory symlinks or recurse into Claude subagent stores. Missing roots are empty. Repeated native files for one qualified ID produce one descriptor (newest modified); the current live binding wins over its on-disk descriptor. Discovery and decoding never mutate transcript bytes or modification times. Unsupported/corrupt or unreadable selected transcripts return `history_unavailable` naming the session for single-session list/read calls. Wildcard searches and overviews skip individual sessions that cannot load; an empty wildcard result is not proof that an event never happened. A readable Claude ancestry gap appears as an optional `notice` in cross-session page/read data and in rendered text; it stays outside event text and search/read offsets and counts against the output budget.
|
|
47
49
|
|
|
48
50
|
The default roots respect `PI_CODING_AGENT_DIR` (Pi agent directory), `CLAUDE_CONFIG_DIR` (Claude config directory), and `CODEX_HOME` (Codex home). For direct root overrides use absolute paths in `NOTESOUP_HISTORY_PI_ROOT`, `NOTESOUP_HISTORY_CLAUDE_ROOT`, and `NOTESOUP_HISTORY_CODEX_ROOT`; these name the **sessions**, **projects**, and **sessions** directories respectively, not notes storage. `NOTESOUP_HOME` only changes notes.
|
|
49
51
|
|
package/docs/skills.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Memory skill
|
|
4
4
|
|
|
5
|
-
The package provides `/skill:memory`, a short self-contained guide to the notes and history tools: note addresses and notebooks, finding and paging notes, searching and paging history, saving recovery state, and what to do when a memory tool is unavailable. It is a fallback for sessions where the boot protocol is missing or unclear and a reference on demand; normal tool calls do not require reading it. It is written independently of the boot text rather than generated from it. The Claude Code Mod ships the same guide; current-session history requires the documented main-session transcript path and a confirmed append head, while explicit `session` selectors use the local cross-harness corpus (offline Claude
|
|
5
|
+
The package provides `/skill:memory`, a short self-contained guide to the notes and history tools: note addresses and notebooks, finding and paging notes, searching and paging history, saving recovery state, and what to do when a memory tool is unavailable. It is a fallback for sessions where the boot protocol is missing or unclear and a reference on demand; normal tool calls do not require reading it. It is written independently of the boot text rather than generated from it. The Claude Code Mod ships the same guide; current-session history requires the documented main-session transcript path and a confirmed append head, while explicit `session` selectors use the local cross-harness corpus (offline Claude prefers non-attachment leaves, then the last leaf in transcript order).
|
|
6
6
|
|
|
7
7
|
## Dream
|
|
8
8
|
|
package/docs/tool-results.md
CHANGED
|
@@ -55,7 +55,7 @@ The suffix and presentation header are never part of `text`, search offsets or t
|
|
|
55
55
|
|
|
56
56
|
The native adapter allocates seqs from session append order, selects the active branch and decodes facts. Shared history pairs calls and results without allocating a second transcript. A paired execution is addressed by its call seq. Its result's raw slot is not a public event address; list/search provide the canonical seq. Unpaired results remain independently addressable. Inactive-branch addresses are not readable.
|
|
57
57
|
|
|
58
|
-
Seqs address events across the whole session, including earlier windows. With `session` omitted, list and read headers use `seq <seq> | <role>`; the boot window tree supplies per-window seq ranges for narrowing a list with `before_seq` and `after_seq`. With an explicit selector, returned events/read data carry canonical `session`, headers use `session <harness>:<id> | seq <seq> | <role>`, and all paging/expand/neighborhood recipes carry that same identity. Wildcard `history_list`
|
|
58
|
+
Seqs address events across the whole session, including earlier windows. With `session` omitted, list and read headers use `seq <seq> | <role>`; the boot window tree supplies per-window seq ranges for narrowing a list with `before_seq` and `after_seq`. With an explicit selector, returned events/read data carry canonical `session`, headers use `session <harness>:<id> | seq <seq> | <role>`, and all paging/expand/neighborhood recipes carry that same identity. Wildcard `history_list` forbids seq bounds and sets both paging recipes to null. With `query`, it returns only hits across all roles; without a non-empty query, it returns one representative event per recent session, stopping once `limit` sessions have produced an item. Individual unreadable sessions are skipped only in wildcard calls. See [cross-session history](history-sessions.md) for resolution, discovery and refusal rules.
|
|
59
59
|
|
|
60
60
|
Tool events expose `tool`, `tool_status`, and, when recorded, `output_truncated` and `full_output_path`; a truncated run is named even when the host recorded no path, and the full text path is named only when it exists. `history_read` also reports `nested_calls`; a page row does not. Full arguments and nested-call records live only in the searchable/readable document, avoiding a second structured copy on every read.
|
|
61
61
|
|
|
@@ -67,11 +67,11 @@ Pi's nested records contain child ID, name, optional arguments, status, timing a
|
|
|
67
67
|
|
|
68
68
|
One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one. History operations accept an optional pure text wrapper from the host: selection and read-window checks measure that wrapper around the shared rendering, and the caller must apply the same wrapper at delivery. Host prose stays in its plugin; no final clipping or separate query is involved.
|
|
69
69
|
|
|
70
|
-
History pages carry `page_older` and `page_newer`, the exact params to merge into the next call; `from` picks which end of a bounded range `limit` counts from, `since`/`until` narrow that range by event `created_at`, and only a call without roles or a non-empty query folds tool/context runs. Omitted queries, empty strings and empty lists all disable search filtering; empty entries in a query list are ignored. Without a query, notes search returns scoped notes with empty `matches`, not every body line. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
|
|
70
|
+
History pages carry `page_older` and `page_newer`, the exact params to merge into the next call; `from` picks which end of a bounded range `limit` counts from, `since`/`until` narrow that range by event `created_at`, and only a single-session call without roles or a non-empty query folds tool/context runs. Omitted queries, empty strings and empty lists all disable search filtering; empty entries in a query list are ignored. Without a query, notes search returns scoped notes with empty `matches`, not every body line. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
|
|
71
71
|
|
|
72
72
|
A note read reports unrecognized frontmatter under `metadata.extra`; a value too large to carry, or past the verbatim budget, is named in place as `[omitted: too large]` under its key rather than delivered in part, and the value itself stays in the note file. A rename receipt uses `address` for the destination and `rename_from` for the source; it has no duplicate `rename_to` field.
|
|
73
73
|
|
|
74
|
-
`output_too_large` is not one failure
|
|
74
|
+
`output_too_large` is not one failure. Each operation's own message says what it means: a read that cannot deliver a single advancing character is refused rather than answered with an empty window, and a search result whose first match line cannot fit is cut to the longest prefix that does and ends with ` [truncated]`. `notes_update` returns a one-line receipt; Pi attaches the rendered diff under `details.diff` for the UI rather than repeating it in model-facing text or `structuredContent`. Narrowing helps only where a parameter genuinely reduces the selection — `glob` or `query`, `roles`, `limit`, `max_chars_per_item`, a `before_seq`/`after_seq` range, or a `since`/`until` time window — and cannot help a read whose own metadata is what overflows. History pages refuse with `page_too_large` for the same reason. Nothing is ever quietly delivered short: every other omission is reported on the successful result that carries it.
|
|
75
75
|
|
|
76
76
|
## Ownership
|
|
77
77
|
|
package/package.json
CHANGED