notesoup 0.54.2 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/plugins/pi/budget.js +1 -1
  2. package/dist/plugins/pi/marker.d.ts +1 -1
  3. package/dist/plugins/pi/marker.js +11 -7
  4. package/dist/plugins/pi/notes/tools.js +5 -1
  5. package/dist/plugins/pi/render.d.ts +4 -1
  6. package/dist/plugins/pi/render.js +3 -7
  7. package/dist/plugins/pi/runtime.js +4 -2
  8. package/dist/plugins/pi/tool-result.d.ts +4 -2
  9. package/dist/plugins/pi/tool-result.js +4 -3
  10. package/dist/src/history/history.d.ts +1 -1
  11. package/dist/src/history/history.js +1 -1
  12. package/dist/src/tools/history.js +4 -7
  13. package/dist/src/tools/notes.d.ts +2 -7
  14. package/dist/src/tools/notes.js +5 -26
  15. package/dist/test/budget-settings.integration.test.js +2 -2
  16. package/dist/test/claude-history.test.js +4 -6
  17. package/dist/test/codex-history.test.js +3 -2
  18. package/dist/test/dependencies.test.js +3 -4
  19. package/dist/test/dream-tools.test.js +3 -3
  20. package/dist/test/history-corpus.test.js +1 -1
  21. package/dist/test/history.integration.test.js +9 -9
  22. package/dist/test/host-neutral.test.js +7 -9
  23. package/dist/test/marker.test.js +34 -27
  24. package/dist/test/notes.integration.test.js +8 -10
  25. package/dist/test/notes.test.js +9 -7
  26. package/dist/test/pi-render.test.js +7 -7
  27. package/dist/test/project-namespace.test.js +4 -4
  28. package/docs/tool-results.md +1 -1
  29. package/package.json +1 -1
  30. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  31. package/plugins/claude/dist/claude/helper.js +8 -29
  32. package/plugins/codex/dist/codex/notesoup.js +8 -29
  33. package/plugins/paseo/OVERVIEW.md +2 -2
  34. package/plugins/paseo/client/brain-empty-card.tsx +1 -1
  35. package/plugins/paseo/client/notes-op-card.tsx +1 -1
  36. package/plugins/paseo/client/notes-op-transformer.ts +16 -1
  37. package/plugins/paseo/client/paper-palette.ts +18 -18
  38. package/plugins/paseo/test/fixtures/claude-tool-calls.ts +1 -1
  39. package/plugins/paseo/test/notes-op.test.ts +4 -4
  40. package/plugins/paseo/test/paper-palette.test.ts +3 -3
  41. package/plugins/pi/budget.ts +1 -1
  42. package/plugins/pi/marker.ts +11 -6
  43. package/plugins/pi/notes/tools.ts +5 -1
  44. package/plugins/pi/render.ts +7 -8
  45. package/plugins/pi/runtime.ts +3 -1
  46. package/plugins/pi/tool-result.ts +9 -8
  47. package/src/history/history.ts +1 -1
  48. package/src/tools/history.ts +4 -7
  49. package/src/tools/notes.ts +5 -27
@@ -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 turnStart(captured, ctx) {
13
- return runHandlers(captured, "turn_start", { type: "turn_start" }, ctx);
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, then holds", async () => {
16
- const sessionManager = managerWithMessages(49);
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
- await turnStart(captured, ctx);
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: 50 });
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="50" />');
26
- assert.equal(nextHistorySeq(ctx), 51, "the marker occupies the seq it names");
27
- // An immediate second turn is only one seq later: no new marker.
28
- await turnStart(captured, ctx);
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 exactly one interval after the last.
31
- appendText(sessionManager, "user", "x".repeat(1));
32
- for (let i = 0; i < 48; 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 turnStart(captured, ctx);
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: 100 });
40
+ assert.deepEqual(all[1].message.details, { seq: 240 });
38
41
  });
39
42
  test("no marker before the interval", async () => {
40
- const sessionManager = managerWithMessages(48);
43
+ const sessionManager = managerWithMessages(118);
41
44
  const captured = makeExtension(sessionManager);
42
- await turnStart(captured, context(sessionManager));
45
+ await beforeAgentStart(captured, context(sessionManager));
43
46
  assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
44
- assert.equal(MARKER_INTERVAL, 50);
47
+ assert.equal(MARKER_INTERVAL, 120);
45
48
  });
46
- test("a reset tail awaiting repair closes the road to markers, then reopens it", async () => {
47
- const sessionManager = managerWithMessages(49);
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 turnStart(captured, ctx);
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 turnStart(captured, ctx);
59
+ await beforeAgentStart(captured, ctx);
57
60
  assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
58
- // Once the shape is closed, the odometer continues across the reset: seq never restarted.
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 turnStart(captured, ctx);
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: 52 });
70
+ assert.deepEqual(sent[0].message.details, { seq: 240 });
64
71
  });
65
72
  test("notesoup off silences the odometer", async () => {
66
- const sessionManager = managerWithMessages(49);
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 turnStart(captured, ctx);
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 markOnly = resultData(await call(captured, "notes_update", { address: "journal.md", crumpled: true }, ctx));
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(markOnly.diff, /^\+\s*\d+\s+crumpledAt: \d{4}-\d{2}-\d{2}T/m);
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("an over-budget mutation diff is shortened on both surfaces, and the edit still lands whole", async () => {
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, "oversized diff receipt");
487
+ assertWithinBudget(raw, "bulk edit receipt");
487
488
  const update = resultData(raw);
488
489
  assert.equal(update.change_kind, "body");
489
- assert.ok(update.diff.length > 0, "a shortened diff is still delivered, not emptied");
490
- assert.ok(update.diff.endsWith("[diff truncated; update applied]"), "a shortened diff ends with the marker line");
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, not just the ones that fit the receipt");
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();
@@ -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 noChange = resultData(await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "restored", newText: "restored" }], crumpled: false }, ctx));
343
- assert.deepEqual([noChange.change_kind, noChange.diff], ["none", ""]);
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
- assert.equal(mixed.change_kind, "body");
347
- // A body edit that also rewrites frontmatter is still a body change; the diff carries the rest.
348
- const combined = resultData(await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "changed", newText: "changed once more" }], origin: "user" }, ctx));
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(combined.diff, /origin/, "the diff still carries the frontmatter part");
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", "diff", "project_key"]);
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: undefined };
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", diff: "" }));
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", diff: "rename a.md -> @self/new.md", rename_from: "a.md" }));
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", diff: "" }));
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");
@@ -71,7 +71,7 @@ History pages carry `page_older` and `page_newer`, the exact params to merge int
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, and a refusal does not mean nothing happened. Each operation's own message says what it means: a `notes_update` whose receipt cannot fit reports that the update was already applied, so read the note before retrying, and a read that cannot deliver a single advancing character is refused rather than answered with an empty window. A receipt whose diff or search-match line cannot fit is cut to the longest prefix that does, and its own text ends with the marker: `[diff truncated; update applied]` for a diff, ` [truncated]` for a match line. 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.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.54.2",
3
+ "version": "0.55.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.54.2",
3
+ "version": "0.55.0",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"
@@ -9189,7 +9189,6 @@ var NotesWriteDataSchema = typebox_exports.Object({
9189
9189
  var NotesUpdateDataSchema = typebox_exports.Object({
9190
9190
  ...NoteIdentitySchema,
9191
9191
  change_kind: typebox_exports.Union([typebox_exports.Literal("none"), typebox_exports.Literal("body"), typebox_exports.Literal("metadata"), typebox_exports.Literal("moved")]),
9192
- diff: typebox_exports.String(),
9193
9192
  rename_from: typebox_exports.Optional(typebox_exports.String())
9194
9193
  }, { additionalProperties: false });
9195
9194
  var NotesReadDataSchema = typebox_exports.Object({
@@ -9260,24 +9259,7 @@ var notesUpdateParameters = typebox_exports.Object({
9260
9259
  cwd: CWD_PARAMETER
9261
9260
  }, { additionalProperties: false });
9262
9261
  function renderUpdateData(data) {
9263
- const head = data.rename_from === void 0 ? `${data.change_kind === "none" ? "unchanged" : "updated"} ${renderIdentity(data)}` : `moved ${data.rename_from} -> ${data.address}`;
9264
- const lines = [head];
9265
- if (data.diff.length > 0) lines.push("diff:", data.diff);
9266
- return lines.join("\n");
9267
- }
9268
- function renderUpdate(result) {
9269
- return renderOutcome(result, renderUpdateData);
9270
- }
9271
- var DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
9272
- var RECEIPT_TOO_LONG = `Saved, but the receipt is too long to hand back (${TOOL_OUTPUT_LIMIT} per call). Check the note with \`notes_read\`.`;
9273
- function boundedUpdate(data) {
9274
- if (fitsResult(success(data), renderUpdate)) return success(data);
9275
- if (data.diff === "") return failure("output_too_large", RECEIPT_TOO_LONG);
9276
- const diff = prefixFit(data.diff, (candidate) => fitsResult(success({ ...data, diff: `${candidate}
9277
- ${DIFF_SHORTENED_MARKER}` }), renderUpdate));
9278
- const result = success({ ...data, diff: `${diff}
9279
- ${DIFF_SHORTENED_MARKER}` });
9280
- return fitsResult(result, renderUpdate) ? result : failure("output_too_large", RECEIPT_TOO_LONG);
9262
+ return data.rename_from === void 0 ? `${data.change_kind === "none" ? "unchanged" : "updated"} ${renderIdentity(data)}` : `moved ${data.rename_from} -> ${data.address}`;
9281
9263
  }
9282
9264
  var notesUpdate = {
9283
9265
  name: "notes_update",
@@ -9286,21 +9268,21 @@ var notesUpdate = {
9286
9268
  parameters: notesUpdateParameters,
9287
9269
  outputSchema: resultSchema(NotesUpdateDataSchema),
9288
9270
  executionMode: "sequential",
9289
- async execute(params, context2, renderDiff = (change) => change.kind === "none" ? "" : `note ${change.kind}`) {
9271
+ async execute(params, context2, onChange) {
9290
9272
  try {
9291
9273
  const identity2 = notesIdentityForCall(context2, params.cwd);
9292
9274
  const store = createNotesStore(identity2);
9293
9275
  const renameTo = params.rename_to === "" ? void 0 : params.rename_to;
9294
9276
  const { change, moved } = await store.update(params.address, params.edits, { origin: params.origin, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
9277
+ onChange?.(change);
9295
9278
  const from = noteIdentity(identity2, params.address).address;
9296
9279
  const to = noteIdentity(identity2, renameTo ?? params.address);
9297
- const diff = renderDiff(change);
9298
- return boundedUpdate({ ...to, ...moved ? { rename_from: from } : {}, change_kind: moved ? "moved" : change.kind, diff: moved ? [`rename ${from} -> ${to.address}`, diff].filter(Boolean).join("\n") : diff });
9280
+ return success({ ...to, ...moved ? { rename_from: from } : {}, change_kind: moved ? "moved" : change.kind });
9299
9281
  } catch (error) {
9300
9282
  return failureOf(error);
9301
9283
  }
9302
9284
  },
9303
- render: renderUpdate
9285
+ render: (result) => renderOutcome(result, renderUpdateData)
9304
9286
  };
9305
9287
  var notesReadParameters = typebox_exports.Object({ address: typebox_exports.String(), ...TextWindowRequestSchema, cwd: CWD_PARAMETER }, { additionalProperties: false });
9306
9288
  function renderReadData(data) {
@@ -9732,19 +9714,16 @@ var historyRead = {
9732
9714
  projection = loaded.data.projection;
9733
9715
  identity2 = { session: sessionIdentity(target.data), ...loaded.data.notice === void 0 ? {} : { notice: loaded.data.notice } };
9734
9716
  }
9735
- const item = allItems(projection).find((event) => event.seq === params.seq);
9736
- if (item === void 0 && params.seq > projection.highestSeq) {
9717
+ if (params.seq > projection.highestSeq) {
9737
9718
  return failure("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
9738
9719
  }
9739
9720
  if (!projection.branchSeqs.has(params.seq)) {
9740
9721
  if (identity2.notice) return failure("unconfirmed_seq", `Seq ${params.seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`);
9741
9722
  return failure("not_on_branch", `Seq ${params.seq} is on another branch of this session; it can't be read from here.`);
9742
9723
  }
9724
+ const targetSeq = projection.pairedResults.get(params.seq) ?? params.seq;
9725
+ const item = allItems(projection).find((event) => event.seq === targetSeq);
9743
9726
  if (item === void 0) {
9744
- const callSeq = projection.pairedResults.get(params.seq);
9745
- if (callSeq !== void 0) {
9746
- return failure("not_an_event", `Seq ${params.seq} is a tool result, shown together with its call; read seq ${callSeq} instead.`);
9747
- }
9748
9727
  return failure("unknown_seq", `Seq ${params.seq} holds nothing to read.`);
9749
9728
  }
9750
9729
  const document = eventDocument(item);
@@ -26164,7 +26164,6 @@ var NotesWriteDataSchema = typebox_exports.Object({
26164
26164
  var NotesUpdateDataSchema = typebox_exports.Object({
26165
26165
  ...NoteIdentitySchema,
26166
26166
  change_kind: typebox_exports.Union([typebox_exports.Literal("none"), typebox_exports.Literal("body"), typebox_exports.Literal("metadata"), typebox_exports.Literal("moved")]),
26167
- diff: typebox_exports.String(),
26168
26167
  rename_from: typebox_exports.Optional(typebox_exports.String())
26169
26168
  }, { additionalProperties: false });
26170
26169
  var NotesReadDataSchema = typebox_exports.Object({
@@ -26235,24 +26234,7 @@ var notesUpdateParameters = typebox_exports.Object({
26235
26234
  cwd: CWD_PARAMETER
26236
26235
  }, { additionalProperties: false });
26237
26236
  function renderUpdateData(data) {
26238
- const head = data.rename_from === void 0 ? `${data.change_kind === "none" ? "unchanged" : "updated"} ${renderIdentity(data)}` : `moved ${data.rename_from} -> ${data.address}`;
26239
- const lines = [head];
26240
- if (data.diff.length > 0) lines.push("diff:", data.diff);
26241
- return lines.join("\n");
26242
- }
26243
- function renderUpdate(result) {
26244
- return renderOutcome(result, renderUpdateData);
26245
- }
26246
- var DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
26247
- var RECEIPT_TOO_LONG = `Saved, but the receipt is too long to hand back (${TOOL_OUTPUT_LIMIT} per call). Check the note with \`notes_read\`.`;
26248
- function boundedUpdate(data) {
26249
- if (fitsResult(success(data), renderUpdate)) return success(data);
26250
- if (data.diff === "") return failure2("output_too_large", RECEIPT_TOO_LONG);
26251
- const diff = prefixFit(data.diff, (candidate) => fitsResult(success({ ...data, diff: `${candidate}
26252
- ${DIFF_SHORTENED_MARKER}` }), renderUpdate));
26253
- const result = success({ ...data, diff: `${diff}
26254
- ${DIFF_SHORTENED_MARKER}` });
26255
- return fitsResult(result, renderUpdate) ? result : failure2("output_too_large", RECEIPT_TOO_LONG);
26237
+ return data.rename_from === void 0 ? `${data.change_kind === "none" ? "unchanged" : "updated"} ${renderIdentity(data)}` : `moved ${data.rename_from} -> ${data.address}`;
26256
26238
  }
26257
26239
  var notesUpdate = {
26258
26240
  name: "notes_update",
@@ -26261,21 +26243,21 @@ var notesUpdate = {
26261
26243
  parameters: notesUpdateParameters,
26262
26244
  outputSchema: resultSchema(NotesUpdateDataSchema),
26263
26245
  executionMode: "sequential",
26264
- async execute(params, context2, renderDiff = (change) => change.kind === "none" ? "" : `note ${change.kind}`) {
26246
+ async execute(params, context2, onChange) {
26265
26247
  try {
26266
26248
  const identity = notesIdentityForCall(context2, params.cwd);
26267
26249
  const store = createNotesStore(identity);
26268
26250
  const renameTo = params.rename_to === "" ? void 0 : params.rename_to;
26269
26251
  const { change, moved } = await store.update(params.address, params.edits, { origin: params.origin, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
26252
+ onChange?.(change);
26270
26253
  const from = noteIdentity(identity, params.address).address;
26271
26254
  const to = noteIdentity(identity, renameTo ?? params.address);
26272
- const diff = renderDiff(change);
26273
- return boundedUpdate({ ...to, ...moved ? { rename_from: from } : {}, change_kind: moved ? "moved" : change.kind, diff: moved ? [`rename ${from} -> ${to.address}`, diff].filter(Boolean).join("\n") : diff });
26255
+ return success({ ...to, ...moved ? { rename_from: from } : {}, change_kind: moved ? "moved" : change.kind });
26274
26256
  } catch (error2) {
26275
26257
  return failureOf(error2);
26276
26258
  }
26277
26259
  },
26278
- render: renderUpdate
26260
+ render: (result) => renderOutcome(result, renderUpdateData)
26279
26261
  };
26280
26262
  var notesReadParameters = typebox_exports.Object({ address: typebox_exports.String(), ...TextWindowRequestSchema, cwd: CWD_PARAMETER }, { additionalProperties: false });
26281
26263
  function renderReadData(data) {
@@ -26707,19 +26689,16 @@ var historyRead = {
26707
26689
  projection = loaded.data.projection;
26708
26690
  identity = { session: sessionIdentity(target.data), ...loaded.data.notice === void 0 ? {} : { notice: loaded.data.notice } };
26709
26691
  }
26710
- const item = allItems(projection).find((event) => event.seq === params.seq);
26711
- if (item === void 0 && params.seq > projection.highestSeq) {
26692
+ if (params.seq > projection.highestSeq) {
26712
26693
  return failure2("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
26713
26694
  }
26714
26695
  if (!projection.branchSeqs.has(params.seq)) {
26715
26696
  if (identity.notice) return failure2("unconfirmed_seq", `Seq ${params.seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`);
26716
26697
  return failure2("not_on_branch", `Seq ${params.seq} is on another branch of this session; it can't be read from here.`);
26717
26698
  }
26699
+ const targetSeq = projection.pairedResults.get(params.seq) ?? params.seq;
26700
+ const item = allItems(projection).find((event) => event.seq === targetSeq);
26718
26701
  if (item === void 0) {
26719
- const callSeq = projection.pairedResults.get(params.seq);
26720
- if (callSeq !== void 0) {
26721
- return failure2("not_an_event", `Seq ${params.seq} is a tool result, shown together with its call; read seq ${callSeq} instead.`);
26722
- }
26723
26702
  return failure2("unknown_seq", `Seq ${params.seq} holds nothing to read.`);
26724
26703
  }
26725
26704
  const document = eventDocument(item);
@@ -4,9 +4,9 @@ Displays notesoup last-word messages already present in Paseo’s timeline as ex
4
4
 
5
5
  This client-only plugin transforms existing timeline rows in place: last-word custom messages become sticky cards, and notes_read/notes_write/notes_update tool calls become paper cards with the address, state, and a content or diff preview. It accepts the bare Pi tool names and Claude's exact `mcp__notesoup__` prefix; same-named tools from other MCP servers are unchanged. It does not read session files or append messages. Other timeline items are unchanged.
6
6
 
7
- Notes cards start collapsed; update cards also show the sentence just added. The whole header row expands and collapses the body. Long content scrolls inside a bounded panel. Read text and diffs come from the existing tool-result text; writes come from the call's content argument. Live and history use the same projection without a persisted copy. Each displayed body/diff is capped at 32,000 UTF-16 units, retaining the beginning and end with a visible omission line; collapsed previews are capped at 1,000 units before layout. Expanding does not fetch more content; original tool results and notes are unchanged. Diff lines of the same color share a text run rather than one component per line.
7
+ Notes cards start collapsed; update cards also show the sentence just added. The whole header row expands and collapses the body. Long content scrolls inside a bounded panel. Read text comes from the existing tool-result text, update diffs come from Pi's `details.diff` (falling back to legacy diff text or `input.edits` on MCP hosts), and writes come from the call's content argument. Live and history use the same projection without a persisted copy. Each displayed body/diff is capped at 32,000 UTF-16 units, retaining the beginning and end with a visible omission line; collapsed previews are capped at 1,000 units before layout. Expanding does not fetch more content; original tool results and notes are unchanged. Diff lines of the same color share a text run rather than one component per line.
8
8
 
9
- Notes cards use the same rendered-text parser for Pi live events and replayed history; Claude supplies that text under the adapter's `output` field. Write previews come from the call arguments. The UI does not depend on Pi's live-only `structuredContent`. Failed calls also read the adapter's error content (string or text blocks) or transport message when no result is available.
9
+ Notes cards use the same projection for Pi live events and replayed history; Claude supplies its receipt text under the adapter's `output` field and its edits under `input.edits`. The UI does not depend on Pi's live-only `structuredContent`. Failed calls also read the adapter's error content (string or text blocks) or transport message when no result is available.
10
10
 
11
11
  `empty_brain` (including `mcp__notesoup__empty_brain`) becomes a divider for running, completed and failed calls. Pi's JSON rollover outcomes are preserved. Claude's plain acknowledgement only completes the tool call; it does not invent a Pi outcome or assert that the deferred reset has committed.
12
12
 
@@ -6,7 +6,7 @@ function label(data: BrainEmpty): string {
6
6
  if (data.status === "running") return "✂ emptying brain …";
7
7
  if (data.error !== undefined) return "✂ brain refused to empty";
8
8
  if (data.outcome === "rollover_already_pending") return "✂ already emptying";
9
- if (data.outcome === "rollover_requested") return "✂ reset requested";
9
+ if (data.outcome === "rollover_requested") return "✂ brain emptied";
10
10
  // A completed tool call (including Claude's acknowledgement) does not prove a reset committed.
11
11
  return "✂ empty_brain completed";
12
12
  }
@@ -12,7 +12,7 @@ const OP_LABEL_RUNNING: Record<NotesOp["op"], string> = { read: "reading", write
12
12
 
13
13
  /** First added line of an update diff, without its line-number prefix: the sentence the agent just wrote down. */
14
14
  function addedLine(diff: string): string | undefined {
15
- return /^\+.*/m.exec(diff)?.[0].replace(/^\+\s*\d+\s+\+\s?/, "");
15
+ return /^\+.*/m.exec(diff)?.[0].replace(/^\+(?:\s*\d+\s+\+|\s*\d+)?\s?/, "");
16
16
  }
17
17
 
18
18
  function DiffBody({ diff, paper }: { diff: string; paper: PaperPalette }) {
@@ -18,6 +18,17 @@ const OP_BY_TOOL: Record<NotesOpTool, NotesOp["op"]> = {
18
18
  notes_update: "update",
19
19
  };
20
20
 
21
+ function editsDiff(input: unknown): string | undefined {
22
+ if (!isRecord(input) || !Array.isArray(input.edits)) return undefined;
23
+ const lines: string[] = [];
24
+ for (const edit of input.edits) {
25
+ if (!isRecord(edit) || typeof edit.oldText !== "string" || typeof edit.newText !== "string" || edit.oldText === edit.newText) continue;
26
+ for (const line of edit.oldText.split("\n")) lines.push(`- ${line}`);
27
+ for (const line of edit.newText.split("\n")) lines.push(`+ ${line}`);
28
+ }
29
+ return lines.length > 0 ? lines.join("\n") : undefined;
30
+ }
31
+
21
32
  function notesOpData(item: ToolCallItem, tool: NotesOpTool): NotesOp | undefined {
22
33
  const op = OP_BY_TOOL[tool];
23
34
  if (item.detail.type !== "unknown") return undefined;
@@ -38,11 +49,15 @@ function notesOpData(item: ToolCallItem, tool: NotesOpTool): NotesOp | undefined
38
49
  const text = resultText(output);
39
50
  if (text === undefined) return data;
40
51
  if (op === "read") return { ...data, text: outputPreview(text.split("\n").slice(2).join("\n").replace(/^\n/, "")) };
52
+ const detailsDiff = isRecord(output) && isRecord(output.details) && typeof output.details.diff === "string" && output.details.diff.length > 0
53
+ ? output.details.diff
54
+ : undefined;
41
55
  const diffStart = text.indexOf("\ndiff:\n");
56
+ const rawDiff = detailsDiff ?? (diffStart >= 0 ? text.slice(diffStart + 7) : text.startsWith("unchanged ") ? undefined : editsDiff(input));
42
57
  return {
43
58
  ...data,
44
59
  ...(text.startsWith("moved ") && isRecord(input) && typeof input.rename_to === "string" ? { renamedFrom: data.address, address: input.rename_to } : {}),
45
- ...(diffStart >= 0 ? { diff: outputPreview(text.slice(diffStart + 7)) } : {}),
60
+ ...(rawDiff !== undefined ? { diff: outputPreview(rawDiff) } : {}),
46
61
  };
47
62
  }
48
63
 
@@ -1,29 +1,29 @@
1
1
  import type { PluginTheme } from "@getpaseo/plugin";
2
2
 
3
3
  const LIGHT_PAPER = {
4
- background: "#f8f3e1",
5
- edge: "#cbbd94",
6
- tape: "rgba(222, 205, 140, 0.72)",
7
- tapeEdge: "rgba(160, 140, 80, 0.18)",
8
- ink: "#33301f",
9
- inkMuted: "#867c63",
10
- added: "#357a44",
11
- removed: "#b0493e",
12
- crumpled: "#ece6d1",
4
+ background: "#faf6eb",
5
+ edge: "#dcd0b4",
6
+ tape: "rgba(224, 206, 148, 0.62)",
7
+ tapeEdge: "rgba(165, 145, 86, 0.16)",
8
+ ink: "#2c281e",
9
+ inkMuted: "#7d735d",
10
+ added: "#2f743e",
11
+ removed: "#b3463b",
12
+ crumpled: "#f1ead8",
13
13
  };
14
14
 
15
15
  export type PaperPalette = typeof LIGHT_PAPER;
16
16
 
17
17
  const DARK_PAPER: PaperPalette = {
18
- background: "#302e27",
19
- edge: "#58513e",
20
- tape: "rgba(139, 122, 70, 0.55)",
21
- tapeEdge: "rgba(194, 170, 100, 0.18)",
22
- ink: "#e8e1cc",
23
- inkMuted: "#b5aa8e",
24
- added: "#91c79a",
25
- removed: "#e69a8f",
26
- crumpled: "#292824",
18
+ background: "#26231d",
19
+ edge: "#463f31",
20
+ tape: "rgba(182, 160, 104, 0.38)",
21
+ tapeEdge: "rgba(218, 195, 134, 0.16)",
22
+ ink: "#ece5d5",
23
+ inkMuted: "#a89e86",
24
+ added: "#8cc494",
25
+ removed: "#e29488",
26
+ crumpled: "#1e1b16",
27
27
  };
28
28
 
29
29
  /** Paseo theme colors are hex (#RGB, #RRGGBB or #RRGGBBAA). */
@@ -40,7 +40,7 @@ export const claudeUpdateCompleted = {
40
40
  detail: {
41
41
  type: "unknown",
42
42
  input: { address: "a.md", edits: [{ oldText: "old", newText: "new" }] },
43
- output: { output: "updated a.md (project pi-context)\ndiff:\n- 1 - old\n+ 1 + new" },
43
+ output: { output: "updated a.md (project pi-context)" },
44
44
  },
45
45
  } as const;
46
46
 
@@ -35,10 +35,10 @@ test("write and moved update project the entire input and delivered diff", () =>
35
35
  input: { address: "a.md", content: body }, output: { content: [{ type: "text", text: "created a.md" }] },
36
36
  } });
37
37
  assert.equal(notesOpSchema.parse(write!.items[0]!.data).preview, body);
38
- const diff = "+ 1 + new\n".repeat(2000) + "[diff truncated; update applied]";
38
+ const diff = "+1 new\n".repeat(2000);
39
39
  const update = transform({ name: "notes_update", detail: { type: "unknown",
40
40
  input: { address: "a.md", rename_to: "b.md" },
41
- output: { content: [{ type: "text", text: `moved a.md -> b.md\ndiff:\n${diff}` }] },
41
+ output: { content: [{ type: "text", text: "moved a.md -> b.md" }], details: { diff } },
42
42
  } });
43
43
  assert.deepEqual(notesOpSchema.parse(update!.items[0]!.data), {
44
44
  op: "update", address: "b.md", renamedFrom: "a.md", status: "completed", diff,
@@ -110,14 +110,14 @@ test("non-notes tools, unknown shapes and missing addresses stay untouched", ()
110
110
  assert.equal(notesOpTransformer.transform({ item: { type: "user_message", text: "hi" } as never }), undefined);
111
111
  });
112
112
 
113
- test("Claude completed calls use the adapter's output text for read, write preview and update diff", () => {
113
+ test("Claude completed calls use the adapter's output text for read, write preview and input.edits for update diff", () => {
114
114
  const read = notesOpSchema.parse(transform(claudeReadCompleted)!.items[0]!.data);
115
115
  assert.deepEqual(read, { op: "read", address: "@self/foo.md", status: "completed", text: "body line one\nbody line two" });
116
116
  assert.deepEqual(notesOpSchema.parse(transform(claudeWriteCompleted)!.items[0]!.data), {
117
117
  op: "write", address: "a.md", status: "completed", preview: "the new body",
118
118
  });
119
119
  assert.deepEqual(notesOpSchema.parse(transform(claudeUpdateCompleted)!.items[0]!.data), {
120
- op: "update", address: "a.md", status: "completed", diff: "- 1 - old\n+ 1 + new",
120
+ op: "update", address: "a.md", status: "completed", diff: "- old\n+ new",
121
121
  });
122
122
  });
123
123