notesoup 0.59.1 → 0.60.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 (79) hide show
  1. package/README.md +3 -17
  2. package/dist/plugins/claude/src/helper.js +3 -4
  3. package/dist/plugins/codex/src/mcp.js +1 -2
  4. package/dist/plugins/dsh/tools.js +1 -2
  5. package/dist/plugins/pi/notes/tools.d.ts +1 -1
  6. package/dist/plugins/pi/notes/tools.js +2 -3
  7. package/dist/src/history/claude.d.ts +3 -1
  8. package/dist/src/history/claude.js +40 -4
  9. package/dist/src/history/history.d.ts +10 -11
  10. package/dist/src/history/history.js +8 -19
  11. package/dist/src/history/prefilter.d.ts +1 -1
  12. package/dist/src/history/prefilter.js +14 -9
  13. package/dist/src/history/query.d.ts +3 -14
  14. package/dist/src/history/query.js +73 -85
  15. package/dist/src/index.d.ts +1 -1
  16. package/dist/src/index.js +1 -1
  17. package/dist/src/notes/address.js +3 -3
  18. package/dist/src/notes/store.d.ts +2 -4
  19. package/dist/src/notes/store.js +1 -2
  20. package/dist/src/tools/history.d.ts +4 -6
  21. package/dist/src/tools/history.js +69 -29
  22. package/dist/src/tools/notes.d.ts +18 -78
  23. package/dist/src/tools/notes.js +39 -50
  24. package/dist/src/tools/schema.d.ts +0 -1
  25. package/dist/src/tools/schema.js +0 -1
  26. package/dist/test/claude-history.test.js +27 -6
  27. package/dist/test/claude-mod.test.js +19 -8
  28. package/dist/test/codex-history.test.js +1 -1
  29. package/dist/test/codex-plugin.test.js +1 -2
  30. package/dist/test/dependencies.test.js +2 -2
  31. package/dist/test/dsh.test.js +2 -2
  32. package/dist/test/history-corpus.test.js +21 -36
  33. package/dist/test/history-prefilter.test.js +5 -0
  34. package/dist/test/history-summary-cache.test.js +3 -3
  35. package/dist/test/history.integration.test.js +53 -106
  36. package/dist/test/host-neutral.test.js +1 -1
  37. package/dist/test/note-policy.test.js +5 -5
  38. package/dist/test/notes-cwd.test.js +5 -5
  39. package/dist/test/notes-query-namespaces.test.js +2 -6
  40. package/dist/test/notes.integration.test.js +30 -35
  41. package/dist/test/notes.test.js +12 -14
  42. package/dist/test/project-namespace.test.js +3 -3
  43. package/docs/architecture.md +3 -3
  44. package/docs/claude-code-mod.md +5 -3
  45. package/docs/codex.md +1 -1
  46. package/docs/dsh.md +2 -2
  47. package/docs/history-sessions.md +9 -10
  48. package/docs/notes-library.md +3 -3
  49. package/docs/tool-results.md +12 -6
  50. package/package.json +1 -1
  51. package/plugins/claude/dist/claude/helper.js +214 -173
  52. package/plugins/claude/hooks/register.ts +8 -6
  53. package/plugins/claude/skills/memory/SKILL.md +6 -6
  54. package/plugins/claude/src/helper.ts +3 -4
  55. package/plugins/codex/README.md +1 -1
  56. package/plugins/codex/dist/codex/notesoup.js +176 -160
  57. package/plugins/codex/src/mcp.ts +1 -2
  58. package/plugins/dsh/tools.ts +1 -2
  59. package/plugins/paseo/README.md +16 -0
  60. package/plugins/paseo/client/brain-empty-card.tsx +5 -3
  61. package/plugins/paseo/client/markdown-core.tsx +189 -0
  62. package/plugins/paseo/client/markdown.tsx +38 -135
  63. package/plugins/paseo/client/notes-op-card.tsx +15 -12
  64. package/plugins/paseo/client/paper-card.tsx +1 -3
  65. package/plugins/paseo/client/sticky-card.tsx +2 -1
  66. package/plugins/paseo/client/typography.ts +24 -0
  67. package/plugins/paseo/test/markdown-core.test.ts +75 -0
  68. package/plugins/pi/notes/tools.ts +2 -3
  69. package/skills/memory/SKILL.md +6 -6
  70. package/src/history/claude.ts +31 -4
  71. package/src/history/history.ts +11 -16
  72. package/src/history/prefilter.ts +13 -9
  73. package/src/history/query.ts +67 -99
  74. package/src/index.ts +1 -1
  75. package/src/notes/address.ts +2 -2
  76. package/src/notes/store.ts +3 -6
  77. package/src/tools/history.ts +60 -29
  78. package/src/tools/notes.ts +39 -54
  79. package/src/tools/schema.ts +0 -1
@@ -49,34 +49,12 @@ test("Pi registered tools resolve another persisted session and propagate its id
49
49
  const current = resultData(await call(captured, "history_read", { session: `pi:${session.getSessionId()}`, seq: 1 }, ctx));
50
50
  assert.equal(current.session, `pi:${session.getSessionId()}`);
51
51
  });
52
- test("history_list exposes bounded paging, `from` and a literal query", () => {
52
+ test("Pi registers the shared history schemas", () => {
53
53
  const captured = makeExtension(manager());
54
- const readSchema = captured.tools.get("history_read")?.parameters;
55
- assert.ok(readSchema.properties?.seq);
56
- assert.deepEqual(readSchema.required, ["seq"]);
57
- assert.equal(readSchema.properties?.window_id, undefined, "history_read accepts no window selector");
58
54
  const listSchema = captured.tools.get("history_list").parameters;
59
- const properties = listSchema.properties;
60
- assert.equal(properties.before_seq?.minimum, 1, "bounds are positive seqs");
61
- assert.equal(properties.after_seq?.minimum, 0);
62
- assert.equal(Check(listSchema, { before_seq: 0 }), false, "before_seq:0 is refused by the schema, not answered with a silent empty page");
63
- assert.equal(Check(listSchema, { after_seq: 0 }), true);
64
- assert.equal(Check(listSchema, { after_seq: -1 }), false);
65
- assert.deepEqual(properties.from?.anyOf?.map((item) => item.const), ["newest", "oldest"]);
66
- assert.ok(properties.query);
67
- assert.deepEqual(properties.roles?.items?.anyOf?.map((item) => item.const), ["user", "assistant", "tool", "context"], "the role filter carries the four public roles");
68
- assert.ok(properties.since, "the time filter has a since param");
69
- assert.ok(properties.until, "the time filter has an until param");
70
- assert.equal(Check(listSchema, { since: "2026-10-10", until: "2026-10-10T06:00:00Z" }), true);
71
- assert.equal(Check(listSchema, { since: "" }), false, "an empty time value is refused by the schema");
72
- assert.equal(Check(listSchema, { query: "needle", from: "oldest", roles: ["tool"] }), true);
73
- assert.equal(Check(listSchema, { from: "recent" }), false);
74
- assert.equal(Check(listSchema, { query: "" }), true, "an empty literal is equivalent to an omitted query");
75
- for (const invalid of [{ roles: ["tool_call"] }, { roles: ["system"] }, { roles: [] }]) {
76
- assert.equal(Check(listSchema, invalid), false, JSON.stringify(invalid));
77
- }
78
- assert.deepEqual(Object.keys(properties).sort(), ["session", "query", "roles", "before_seq", "after_seq", "since", "until", "from", "limit", "max_chars_per_item"].sort());
79
- assert.equal(Check(listSchema, { window_id: "anything" }), false, "removed filters are refused as unknown parameters");
55
+ assert.deepEqual(listSchema, historyList.parameters);
56
+ assert.ok(Check(listSchema, { after: 0, before: "2026-10-10", query: "needle", context: 1 }));
57
+ assert.deepEqual(captured.tools.get("history_read").parameters, historyRead.parameters);
80
58
  });
81
59
  test("every history operation declares a result schema its own payload satisfies", async () => {
82
60
  const session = manager();
@@ -159,67 +137,48 @@ test("history page schema exposes plain boolean paging flags", () => {
159
137
  assert.equal("description" in field, false);
160
138
  }
161
139
  });
162
- test("history_list pages from the end `from` names and returns bounded ranges", async () => {
140
+ test("history_list pages forward with after and otherwise back from before", async () => {
163
141
  const session = manager();
164
142
  const captured = makeExtension(session);
165
143
  const ctx = context(session);
166
- for (let index = 1; index <= 5; index++)
167
- appendText(session, "user", `message-${index}`);
168
- assert.deepEqual(seqs(await call(captured, "history_list", { limit: 2 }, ctx)), [4, 5], "the default newest page is the highest seqs, ascending");
169
- assert.deepEqual(seqs(await call(captured, "history_list", { limit: 2, from: "oldest" }, ctx)), [1, 2], "from oldest takes the other end of the same selection");
170
- appendText(session, "user", "message-6");
171
- const older = page(await call(captured, "history_list", { before_seq: 5, limit: 2 }, ctx));
172
- assert.deepEqual(older.items.map((item) => item.seq), [3, 4]);
173
- assert.equal(older.has_older, true);
174
- assert.equal(older.has_newer, false);
175
- assert.deepEqual(seqs(await call(captured, "history_list", { after_seq: 5, limit: 2, from: "oldest" }, ctx)), [6]);
176
- for (let index = 7; index <= 10; index++)
144
+ for (let index = 1; index <= 7; index++)
177
145
  appendText(session, "user", `message-${index}`);
178
- assert.deepEqual(seqs(await call(captured, "history_list", { after_seq: 0, limit: 3 }, ctx)), [1, 2, 3]);
179
- assert.deepEqual(seqs(await call(captured, "history_list", { after_seq: 2, limit: 3 }, ctx)), [3, 4, 5]);
180
- assert.deepEqual(seqs(await call(captured, "history_list", { after_seq: 2, limit: 3, from: "newest" }, ctx)), [8, 9, 10]);
181
- assert.deepEqual(seqs(await call(captured, "history_list", { after_seq: 2, before_seq: 10, limit: 3 }, ctx)), [3, 4, 5]);
182
- assert.deepEqual(seqs(await call(captured, "history_list", { after_seq: 2, before_seq: 10, limit: 3, from: "newest" }, ctx)), [7, 8, 9]);
183
- assert.deepEqual(seqs(await call(captured, "history_list", { before_seq: 10, limit: 3, from: "oldest" }, ctx)), [1, 2, 3]);
184
- let forward = { after_seq: 2, before_seq: 10, limit: 3 };
185
- const forwardSeqs = [];
186
- while (true) {
187
- const result = await call(captured, "history_list", forward, ctx);
188
- const current = page(result);
189
- forwardSeqs.push(...seqs(result));
190
- if (!current.has_newer)
191
- break;
192
- const footer = /→ newer: (\{[^\n]+\})/.exec(rendered(result));
193
- assert.ok(footer);
194
- forward = { ...forward, ...JSON.parse(footer[1]) };
195
- }
196
- assert.deepEqual(forwardSeqs, [3, 4, 5, 6, 7, 8, 9]);
197
- let backward = { after_seq: 2, before_seq: 10, limit: 3, from: "newest" };
198
- const backwardPages = [];
199
- while (true) {
200
- const result = await call(captured, "history_list", backward, ctx);
201
- const current = page(result);
202
- backwardPages.unshift(seqs(result));
203
- if (!current.has_older)
204
- break;
205
- const footer = /→ older: (\{[^\n]+\})/.exec(rendered(result));
206
- assert.ok(footer);
207
- backward = { ...backward, ...JSON.parse(footer[1]) };
146
+ const list = (params) => call(captured, "history_list", params, ctx);
147
+ assert.deepEqual(seqs(await list({ limit: 2 })), [6, 7]);
148
+ assert.deepEqual(seqs(await list({ after: 0, limit: 2 })), [1, 2]);
149
+ assert.deepEqual(seqs(await list({ after: "2", limit: 2 })), [3, 4]);
150
+ const older = await list({ before: 6, limit: 2 });
151
+ assert.deepEqual(seqs(older), [4, 5]);
152
+ assert.match(rendered(older), /→ older: \{"before":4\}/);
153
+ assert.deepEqual(seqs(await list({ after: 1, before: 5 })), [2, 3, 4]);
154
+ });
155
+ test("history_list merges context across hit bounds without moving the page anchor", async () => {
156
+ const session = manager();
157
+ const captured = makeExtension(session);
158
+ const ctx = context(session);
159
+ for (const text of ["setup", "needle one", "shared reply", "needle two", "follow-up", "unrelated", "needle three"]) {
160
+ appendText(session, text.startsWith("needle") ? "user" : "assistant", text);
208
161
  }
209
- assert.deepEqual(backwardPages.flat(), [3, 4, 5, 6, 7, 8, 9]);
162
+ const result = await call(captured, "history_list", { after: 1, query: "needle", roles: ["user"], limit: 2, context: 1 }, ctx);
163
+ assert.deepEqual(page(result).items.map(item => [item.content, !!item.context]), [
164
+ ["setup", true], ["needle one", false], ["shared reply", true], ["needle two", false], ["follow-up", true],
165
+ ]);
166
+ assert.ok(Check(historyList.outputSchema, result.structuredContent));
167
+ assert.match(rendered(result), /→ newer: \{"after":4\}/);
168
+ assert.match(resultError(await call(captured, "history_list", { context: 1 }, ctx)).message, /requires a non-empty `query`/);
210
169
  });
211
170
  test("a one-row page budget admits the newest candidate first", () => {
212
171
  const windowId = "w1";
213
172
  const items = [1, 2, 3].map((seq) => ({ seq, windowId, role: "user", text: `message-${seq}`, createdAt: undefined }));
214
173
  const projection = projectHistory([{ windowId, items }], 12, new Set([1, 2, 3]));
215
- const keptSeqs = (fitsRows, from) => {
216
- const outcome = selectPage(projection, { limit: 3, ...(from === undefined ? {} : { from }) }, (candidate) => candidate.items.length <= fitsRows, 200);
174
+ const keptSeqs = (fitsRows, after) => {
175
+ const outcome = selectPage(projection, { limit: 3, after }, (candidate) => candidate.items.length <= fitsRows, 200);
217
176
  assert.equal(outcome.ok, true);
218
177
  return outcome.ok ? outcome.data.items.map((item) => item.seq) : [];
219
178
  };
220
179
  assert.deepEqual(keptSeqs(1), [3], "a budget for one row admits the newest candidate, not the oldest");
221
180
  assert.deepEqual(keptSeqs(2), [2, 3], "a truncated prefix is the newest rows, delivered in chronological order");
222
- assert.deepEqual(keptSeqs(1, "oldest"), [1], "from oldest keeps the other end when the budget is short");
181
+ assert.deepEqual(keptSeqs(1, { seq: 0 }), [1], "after keeps the forward end when the budget is short");
223
182
  });
224
183
  test("query reports budget failures while tools refuse the page", async () => {
225
184
  const projection = projectHistory([{ windowId: "w1", items: [{ seq: 1, windowId: "w1", role: "user", text: "message" }] }], 1, new Set([1]));
@@ -290,7 +249,7 @@ test("conversation paging prepares ordered folds once, including during first-ro
290
249
  ]);
291
250
  assert.deepEqual(full.data.folded_after, { first_seq: 9, last_seq: 9, count: 1, tools: {} });
292
251
  assert.equal(traversals, 1, "growing the page never re-traverses the source windows");
293
- const oldest = selectPage(projection, { limit: 1, from: "oldest" }, () => true, 1000);
252
+ const oldest = selectPage(projection, { limit: 1, after: { seq: 0 } }, () => true, 1000);
294
253
  assert.ok(oldest.ok);
295
254
  if (oldest.ok)
296
255
  assert.deepEqual(oldest.data.items[0].folded_before, { first_seq: 1, last_seq: 1, count: 1, tools: {} });
@@ -337,7 +296,7 @@ test("list shortening charges folded rows against both text and JSON budgets", a
337
296
  assert.ok(Buffer.byteLength(JSON.stringify(folded.data), "utf8") <= TOOL_OUTPUT_MAX_BYTES);
338
297
  assert.ok(Buffer.byteLength(historyList.render(folded), "utf8") <= TOOL_OUTPUT_MAX_BYTES);
339
298
  });
340
- test("since and until select a half-open time range, compose with query and paging, and refuse bad bounds", async () => {
299
+ test("after and before accept exclusive ISO 8601 times and default to UTC", async () => {
341
300
  const items = [
342
301
  { seq: 1, windowId: "w1", role: "user", text: "first needle", createdAt: "2026-10-10T00:00:00.000Z" },
343
302
  { seq: 2, windowId: "w1", role: "assistant", text: "second", createdAt: "2026-10-10T06:00:00.000Z" },
@@ -351,23 +310,11 @@ test("since and until select a half-open time range, compose with query and pagi
351
310
  assert.equal(outcome.ok, true, JSON.stringify(outcome));
352
311
  return outcome.ok ? outcome.data.items.map((item) => item.seq) : [];
353
312
  };
354
- assert.deepEqual(await selected({ roles: ["user", "assistant"], from: "oldest", since: "2026-10-10T06:00:00Z" }), [2, 3, 4], "since keeps later events and drops one with no time");
355
- assert.deepEqual(await selected({ roles: ["user", "assistant"], from: "oldest", until: "2026-10-10T12:00:00Z" }), [1, 2], "until is exclusive");
356
- assert.deepEqual(await selected({ roles: ["user", "assistant"], from: "oldest", since: "2026-10-10T06:00:00Z", until: "2026-10-10T18:00:00Z" }), [2, 3], "both bounds make a half-open range");
357
- assert.deepEqual(await selected({ query: "needle", from: "oldest", since: "2026-10-10T06:00:00Z" }), [3], "a query composes with the time range");
358
- assert.deepEqual(await selected({ roles: ["user", "assistant"], from: "oldest", since: "2026-10-10T00:00:00Z", until: "2026-10-10T18:00:00Z", after_seq: 1, before_seq: 4 }), [2, 3], "seq paging composes with the time range");
359
- assert.deepEqual(await selected({ roles: ["user", "assistant"], from: "oldest", since: "2026-10-10" }), [1, 2, 3, 4], "a date-only since is inclusive UTC midnight, not local midnight");
360
- assert.deepEqual(await selected({ roles: ["user", "assistant"], from: "oldest", until: "2026-10-10T12:00" }), [1, 2], "a time without an offset is UTC");
361
- const malformed = await historyList.execute({ since: "yesterday" }, projection);
362
- assert.equal(malformed.ok, false);
363
- if (!malformed.ok) {
364
- assert.equal(malformed.error.code, "invalid_time");
365
- assert.match(malformed.error.message, /"yesterday"/, "the refusal names the offending param and value");
366
- }
367
- const inverted = await historyList.execute({ since: "2026-10-11", until: "2026-10-10" }, projection);
368
- assert.equal(inverted.ok, false);
369
- if (!inverted.ok)
370
- assert.equal(inverted.error.code, "invalid_time");
313
+ assert.deepEqual(await selected({ after: "2026-10-10T06:00", limit: 1 }), [3]);
314
+ assert.deepEqual(await selected({ after: "2026-10-10", before: "2026-10-10T18:00Z" }), [2, 3]);
315
+ const malformed = await historyList.execute({ after: "yesterday" }, projection);
316
+ assert.ok(!malformed.ok);
317
+ assert.match(malformed.error.message, /`after`.*"yesterday"/);
371
318
  });
372
319
  test("time bounds also keep untimed events out of the folded conversation view", async () => {
373
320
  const items = [
@@ -376,7 +323,7 @@ test("time bounds also keep untimed events out of the folded conversation view",
376
323
  { seq: 3, windowId: "w1", role: "user", text: "after", createdAt: "2026-10-10T12:00:00.000Z" },
377
324
  ];
378
325
  const projection = projectHistory([{ windowId: "w1", items }], 3, new Set([1, 2, 3]));
379
- const bounded = await historyList.execute({ since: "2026-10-10T00:00:00Z" }, projection);
326
+ const bounded = await historyList.execute({ before: "2026-10-11" }, projection);
380
327
  assert.equal(bounded.ok, true);
381
328
  if (bounded.ok)
382
329
  assert.deepEqual(bounded.data.items.map((item) => `seq ${item.seq}`), ["seq 1", "seq 3"], "an untimed tool event is not folded into a bounded selection");
@@ -414,9 +361,9 @@ test("conversation view folds tools and injected messages, while explicit roles
414
361
  assert.equal(folded.count, 3, "two tool events and one injected context are folded, not the empty assistant message");
415
362
  assert.deepEqual(folded.tools, { bash: 1, read: 1 });
416
363
  assert.equal("custom_types" in folded, false);
417
- const empty = page(await call(captured, "history_list", { roles: ["context"], before_seq: 2 }, ctx));
364
+ const empty = page(await call(captured, "history_list", { roles: ["context"], before: 2 }, ctx));
418
365
  assert.deepEqual(empty.items, []);
419
- const hiddenOnly = page(await call(captured, "history_list", { after_seq: 2, before_seq: 6 }, ctx));
366
+ const hiddenOnly = page(await call(captured, "history_list", { after: 2, before: 6 }, ctx));
420
367
  assert.deepEqual(hiddenOnly.items, []);
421
368
  assert.deepEqual(hiddenOnly.folded_after, { first_seq: 3, last_seq: 4, count: 2, tools: { bash: 1, read: 1 } });
422
369
  const expanded = page(await call(captured, "history_list", { roles: ["tool"] }, ctx));
@@ -583,22 +530,22 @@ test("list renders paging and fold recipes across resets, and read renders a nei
583
530
  session.appendCustomEntry("notesoup/reset-marker", { windowId: "pcw:test:w2" });
584
531
  appendText(session, "user", "current window");
585
532
  const listed = await call(captured, "history_list", {}, ctx);
586
- assert.match(rendered(listed), /→ older: \{"before_seq":\d+\}/, "the footer prints the exact call to page older");
587
- const earlier = page(await call(captured, "history_list", { before_seq: 31, from: "oldest", limit: 30 }, ctx));
533
+ assert.match(rendered(listed), /→ older: \{"before":\d+\}/, "the footer prints the call to page older");
534
+ const earlier = page(await call(captured, "history_list", { before: 31, limit: 30 }, ctx));
588
535
  assert.deepEqual(earlier.items.map((item) => item.seq), Array.from({ length: 30 }, (_, index) => index + 1));
589
- const earlierQuery = page(await call(captured, "history_list", { query: "older window", before_seq: 31, limit: 30 }, ctx));
536
+ const earlierQuery = page(await call(captured, "history_list", { query: "older window", before: 31, limit: 30 }, ctx));
590
537
  assert.equal(earlierQuery.items.length, 30, "queries and seq bounds recover earlier windows without a separate address");
591
- const current = page(await call(captured, "history_list", { after_seq: 30 }, ctx));
538
+ const current = page(await call(captured, "history_list", { after: 30 }, ctx));
592
539
  assert.deepEqual(current.items.map((item) => [item.seq, item.content]), [[31, "current window"]], "the reset marker consumes no address");
593
540
  toolCall(session, "t1", "bash", { command: "ls" });
594
541
  toolResult(session, "t1", "bash", "done");
595
542
  appendText(session, "user", "after tools");
596
543
  const folded = await call(captured, "history_list", {}, ctx);
597
- assert.match(rendered(folded), /→ expand: \{"after_seq":\d+,"before_seq":\d+,"roles":\["tool","context"\]\}/, "a folded row prints its own expand recipe");
544
+ assert.match(rendered(folded), /→ expand: \{"after":\d+,"before":\d+,"roles":\["tool","context"\]\}/, "a folded row prints its own expand recipe");
598
545
  appendText(session, "user", "needle read target");
599
546
  const hits = page(await call(captured, "history_list", { query: "needle read target" }, ctx));
600
547
  const read = await call(captured, "history_read", { seq: hits.items[0].seq }, ctx);
601
- assert.match(rendered(read), /neighborhood → `history_list`\(\{"after_seq":\d+,"before_seq":\d+\}\)/, "a read prints the call for surrounding events");
548
+ assert.match(rendered(read), /neighborhood → `history_list`\(\{"after":\d+,"before":\d+\}\)/, "a read prints the call for surrounding events");
602
549
  });
603
550
  test("compaction summary becomes context and is folded in the default list", async () => {
604
551
  const session = manager();
@@ -628,17 +575,17 @@ test("a query covers every role, carries match offsets and treats empty queries
628
575
  const developers = page(await call(captured, "history_list", { query: "needle", roles: ["context"] }, ctx));
629
576
  assert.deepEqual(developers.items.map((item) => item.role), ["context"]);
630
577
  assert.equal("custom_type" in developers.items[0], false);
631
- const first = page(await call(captured, "history_list", { query: "needle", after_seq: 1, limit: 1, from: "oldest" }, ctx));
578
+ const first = page(await call(captured, "history_list", { query: "needle", after: 1, limit: 1 }, ctx));
632
579
  assert.deepEqual(first.items.map((item) => item.seq), [2]);
633
580
  assert.equal(first.has_newer, true);
634
- const next = page(await call(captured, "history_list", { query: "needle", after_seq: first.items.at(-1).seq, limit: 2 }, ctx));
581
+ const next = page(await call(captured, "history_list", { query: "needle", after: first.items.at(-1).seq, limit: 2 }, ctx));
635
582
  assert.deepEqual(next.items.map((item) => item.seq), [3]);
636
583
  const absent = await call(captured, "history_list", { query: "absent" }, ctx);
637
584
  assert.deepEqual(page(absent).items, []);
638
585
  assert.notEqual(rendered(absent).trim(), "", "an empty page says so instead of rendering nothing");
639
586
  for (const query of ["", [], ["", ""]]) {
640
587
  assert.deepEqual(page(await call(captured, "history_list", { query }, ctx)), page(await call(captured, "history_list", {}, ctx)), "empty queries preserve conversation folding");
641
- const filters = { roles: ["context"], after_seq: 1, before_seq: 3 };
588
+ const filters = { roles: ["context"], after: 1, before: 3 };
642
589
  assert.deepEqual(page(await call(captured, "history_list", { ...filters, query }, ctx)), page(await call(captured, "history_list", filters, ctx)), "other filters still apply");
643
590
  }
644
591
  assert.deepEqual(page(await call(captured, "history_list", { query: ["", "needle"] }, ctx)), all, "empty entries do not turn OR into match-all");
@@ -650,13 +597,13 @@ test("has_older and has_newer round-trip a session with no duplicates and no gap
650
597
  for (let seq = 1; seq <= 10; seq++)
651
598
  appendText(session, "user", `needle ${seq}`);
652
599
  const forward = [];
653
- let current = page(await call(captured, "history_list", { query: "needle", from: "oldest", limit: 3 }, ctx));
600
+ let current = page(await call(captured, "history_list", { query: "needle", after: 0, limit: 3 }, ctx));
654
601
  assert.deepEqual(current.items.map((item) => item.seq), [1, 2, 3]);
655
602
  assert.equal(current.has_older, false, "the first page in `from` oldest has nothing older");
656
603
  assert.equal(current.has_newer, true);
657
604
  forward.push(...current.items.map((item) => item.seq));
658
605
  while (current.has_newer) {
659
- const cursor = { after_seq: current.items.at(-1).seq };
606
+ const cursor = { after: current.items.at(-1).seq };
660
607
  current = page(await call(captured, "history_list", { query: "needle", ...cursor, limit: 3 }, ctx));
661
608
  forward.push(...current.items.map((item) => item.seq));
662
609
  }
@@ -667,7 +614,7 @@ test("has_older and has_newer round-trip a session with no duplicates and no gap
667
614
  assert.equal(current.has_older, true);
668
615
  backward.push(...current.items.map((item) => item.seq));
669
616
  while (current.has_older) {
670
- const cursor = { before_seq: current.items[0].seq };
617
+ const cursor = { before: current.items[0].seq };
671
618
  current = page(await call(captured, "history_list", { query: "needle", ...cursor, limit: 3 }, ctx));
672
619
  backward.push(...current.items.map((item) => item.seq));
673
620
  }
@@ -281,7 +281,7 @@ test("history paging bounds are the schema's, and a zero limit still pages one e
281
281
  assert.equal(Check(historyList.parameters, { limit: 0 }), false, "the schema refuses a zero limit");
282
282
  assert.equal(Check(historyList.parameters, { limit: 501 }), false, "the schema refuses a limit past its maximum");
283
283
  assert.equal(Check(historyList.parameters, { max_chars_per_item: 0 }), false, "the schema refuses a zero preview budget");
284
- const zero = data(await historyList.execute({ limit: 0, from: "oldest", roles: ["user"] }, projection));
284
+ const zero = data(await historyList.execute({ limit: 0, after: 0, roles: ["user"] }, projection));
285
285
  assert.equal(zero.items.length, 1, "an unvalidated zero limit still returns one row instead of none");
286
286
  const negative = data(await historyList.execute({ max_chars_per_item: -5, roles: ["user"] }, projection));
287
287
  const row = negative.items[0];
@@ -6,7 +6,7 @@ import test from "node:test";
6
6
  import { Check } from "typebox/value";
7
7
  import { createNotesStore, effectiveNotePolicy, NoteError } from "../src/notes/index.js";
8
8
  import { parseNote } from "../src/notes/frontmatter.js";
9
- import { DEFAULT_BOOT_TOOL_NAMES, loadNotesSnapshot, notesList, notesRead, notesSearch, notesToolContext, notesUpdate, notesWrite, renderBootBlock } from "../src/index.js";
9
+ import { DEFAULT_BOOT_TOOL_NAMES, loadNotesSnapshot, notesList, notesRead, notesToolContext, notesUpdate, notesWrite, renderBootBlock } from "../src/index.js";
10
10
  import { wireResult } from "../src/tools/result.js";
11
11
  function fixture(t) {
12
12
  const home = mkdtempSync(join(tmpdir(), "note-policy-"));
@@ -97,11 +97,11 @@ test("tools set policy, validate values, and visibly report effective policy and
97
97
  assert.equal(data(list).files[0].pinned, true);
98
98
  assert.match(notesList.render(list), /pinned true \| budget 2 \| readonly false/);
99
99
  assert.match(notesList.render(list), /Warning: note body is 3/);
100
- const search = await notesSearch.execute({ query: "😀", max_matches_per_file: 1 }, context);
101
- assert.equal(Check(notesSearch.outputSchema, wireResult(search)), true);
100
+ const search = await notesList.execute({ query: "😀", max_matches_per_file: 1 }, context);
101
+ assert.equal(Check(notesList.outputSchema, wireResult(search)), true);
102
102
  assert.equal(data(search).files[0].budget, 2);
103
- assert.match(notesSearch.render(search), /pinned true \| budget 2 \| readonly false/);
104
- assert.match(notesSearch.render(search), /Warning: note body is 3/);
103
+ assert.match(notesList.render(search), /pinned true \| budget 2 \| readonly false/);
104
+ assert.match(notesList.render(search), /Warning: note body is 3/);
105
105
  const overflow = await notesWrite.execute({ address: "overflow", content: "😀".repeat(3), budget: 2 }, context);
106
106
  for (const warnings of [data(overflow).warnings, data(read).warnings]) {
107
107
  assert.ok(warnings.length > 0);
@@ -6,7 +6,7 @@ import test from "node:test";
6
6
  import { Check } from "typebox/value";
7
7
  import { createNotesStore, projectKey, snapshotNotesIdentity } from "../src/notes/index.js";
8
8
  import { parseNote } from "../src/notes/frontmatter.js";
9
- import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../src/tools/notes.js";
9
+ import { notesList, notesRead, notesUpdate, notesWrite } from "../src/tools/notes.js";
10
10
  import { notesToolContext } from "../src/tools/notes-context.js";
11
11
  function fixture(t) {
12
12
  const root = mkdtempSync(join(tmpdir(), "notesoup-notes-cwd-"));
@@ -32,11 +32,11 @@ function refusal(result) {
32
32
  assert.fail("expected refusal");
33
33
  return result.error;
34
34
  }
35
- test("all five notes schemas accept one optional non-empty cwd", () => {
36
- for (const operation of [notesWrite, notesUpdate, notesRead, notesList, notesSearch]) {
35
+ test("all notes schemas accept one optional non-empty cwd", () => {
36
+ for (const operation of [notesWrite, notesUpdate, notesRead, notesList]) {
37
37
  const base = operation === notesWrite ? { address: "a", content: "x" }
38
38
  : operation === notesUpdate ? { address: "a", edits: [{ oldText: "x", newText: "y" }] }
39
- : operation === notesSearch ? { query: "x" }
39
+ : operation === notesList ? { query: "x" }
40
40
  : operation === notesRead ? { address: "a" } : {};
41
41
  assert.equal(Check(operation.parameters, { ...base, cwd: "../other" }), true, operation.name);
42
42
  assert.equal(Check(operation.parameters, { ...base, cwd: "" }), false, `${operation.name} rejects empty cwd`);
@@ -66,7 +66,7 @@ test("one relative cwd retargets every operation without changing later calls",
66
66
  const listed = data(await notesList.execute({ glob: "@project/**", cwd }, context));
67
67
  assert.deepEqual(listed.files.map(file => file.address).sort(), ["@project/other.md", "@project/renamed.md"]);
68
68
  assert.ok(listed.files.every(file => file.project_key === beta.projectKey));
69
- const searched = data(await notesSearch.execute({ query: "needle", glob: "@project/**", cwd }, context));
69
+ const searched = data(await notesList.execute({ query: "needle", glob: "@project/**", cwd }, context));
70
70
  assert.deepEqual(searched.files.map(file => file.address), ["@project/other.md"]);
71
71
  // The captured context is unchanged: omitting cwd still means alpha.
72
72
  assert.equal(data(await notesRead.execute({ address: "@project/decision" }, context)).text, "alpha needle");
@@ -29,13 +29,10 @@ async function populate(t) {
29
29
  ].sort();
30
30
  return { ...fixtureData, current, all };
31
31
  }
32
- test("default spellings stay local while explicit ** lists and searches each notebook once", async (t) => {
32
+ test("omitted glob stays local while explicit ** lists and searches each notebook once", async (t) => {
33
33
  const { notes, current, all, identity } = await populate(t);
34
34
  assert.deepEqual(addresses(await notes.list()), current);
35
- for (const glob of [null, "", "@default"]) {
36
- assert.deepEqual(addresses(await notes.list({ glob })), current);
37
- assert.deepEqual(addresses(await notes.search(["needle"], { glob })), current);
38
- }
35
+ assert.deepEqual(addresses(await notes.search(["needle"])), current);
39
36
  const rows = await notes.list({ glob: "**" });
40
37
  assert.deepEqual(addresses(rows), all);
41
38
  assert.deepEqual(addresses(await notes.list({ glob: "*" })), all);
@@ -44,7 +41,6 @@ test("default spellings stay local while explicit ** lists and searches each not
44
41
  assert.equal(new Set(rows.map(row => row.address)).size, rows.length);
45
42
  for (const row of rows)
46
43
  assert.equal((await notes.read(row.address))?.body.startsWith("needle"), true, "every result is a real readable address");
47
- assert.deepEqual(await notes.list({ glob: "@default/**" }), [], "@default is a bare selector, not an address prefix");
48
44
  assert.deepEqual(addresses(await notes.list({ glob: "@project/**" })), ["@project/shared.md"]);
49
45
  assert.deepEqual(addresses(await notes.list({ glob: "@self/**" })), ["@self/shared.md"]);
50
46
  assert.deepEqual(addresses(await notes.list({ glob: "@model/**" })), ["@model/shared.md"]);
@@ -68,7 +68,7 @@ for (const scanFails of [false, true]) {
68
68
  assert.equal(existsSync(lockPath), false);
69
69
  });
70
70
  }
71
- test("notes_list and notes_search are recent-first snapshots with narrowing hints", async () => {
71
+ test("notes_list browses and searches recent-first snapshots", async () => {
72
72
  const session = manager();
73
73
  const captured = makeExtension(session);
74
74
  const ctx = context(session);
@@ -81,13 +81,16 @@ test("notes_list and notes_search are recent-first snapshots with narrowing hint
81
81
  };
82
82
  put("old.md", base + 1);
83
83
  put("new.md", base + 3);
84
- put("@project/design.md", base + 2);
84
+ put("@project/design.md", base + 2, "design\nThe NEEDLE");
85
+ put("unrelated.md", base + 4, "not a hit");
85
86
  const listed = resultData(await call(captured, "notes_list", { limit: 2 }, ctx));
86
- assert.deepEqual(listed.files.map((file) => file.address), ["new.md", "@project/design.md"]);
87
- assert.equal(listed.more, 1);
88
- assert.deepEqual(Object.keys(listed).sort(), ["files", "more", "namespaces_unavailable"]);
89
- const searched = resultData(await call(captured, "notes_search", { query: "needle", limit: 2 }, ctx));
90
- assert.deepEqual(searched.files.map((file) => file.address), ["new.md", "@project/design.md"]);
87
+ assert.deepEqual(listed.files.map((file) => file.address), ["unrelated.md", "new.md"]);
88
+ assert.equal(listed.more, 2);
89
+ const searched = resultData(await call(captured, "notes_list", { query: "needle", limit: 2 }, ctx));
90
+ assert.deepEqual(searched.files.map((file) => [file.address, file.matches]), [
91
+ ["new.md", [{ line: 1, text: "needle", offset_chars: 0 }]],
92
+ ["@project/design.md", [{ line: 2, text: "The NEEDLE", offset_chars: 11 }]],
93
+ ]);
91
94
  assert.equal(searched.more, 1);
92
95
  const narrowed = resultData(await call(captured, "notes_list", { glob: "@project/**" }, ctx));
93
96
  assert.deepEqual(narrowed.files.map((file) => file.address), ["@project/design.md"]);
@@ -105,14 +108,9 @@ test("empty notes queries list scoped notes without fabricated matches", async (
105
108
  for (const crumpled of [false, true]) {
106
109
  const filters = { glob: "empty-query/**", crumpled, limit: 1 };
107
110
  const listed = resultData(await call(captured, "notes_list", filters, ctx));
108
- const expected = { ...listed, files: listed.files.map(file => ({ ...file, matches: [] })) };
109
- for (const query of [undefined, "", [], ["", ""]]) {
110
- assert.deepEqual(resultData(await call(captured, "notes_search", { ...filters, query }, ctx)), expected);
111
- }
111
+ assert.deepEqual(resultData(await call(captured, "notes_list", { ...filters, query: [] }, ctx)), listed);
112
112
  }
113
- const filters = { glob: "empty-query/**" };
114
- assert.deepEqual(resultData(await call(captured, "notes_search", { ...filters, query: ["", "needle"] }, ctx)), resultData(await call(captured, "notes_search", { ...filters, query: "needle" }, ctx)));
115
- assert.equal(resultError(await call(captured, "notes_search", { query: [42] }, ctx)).code, "invalid_query");
113
+ assert.match(resultError(await call(captured, "notes_list", { max_matches_per_file: 1 }, ctx)).message, /requires a non-empty `query`/);
116
114
  });
117
115
  test("notes_list reports omitted files when the wire budget truncates the snapshot", async () => {
118
116
  const session = manager();
@@ -168,8 +166,8 @@ test("notes are real files that persist across sessions and round-trip Unicode",
168
166
  const read = resultRead(rawRead);
169
167
  assert.equal(read.address, "@human/checkpoint/进度.md");
170
168
  assert.equal(read.content, "Café", "a negative offset reads the body tail in one call");
171
- const searched = resultData(await call(restoredCaptured, "notes_search", { glob: "@human/**", query: "Café" }, restoredCtx));
172
- assert.equal(searched.files[0]?.matches[0]?.line, 2);
169
+ const searched = resultData(await call(restoredCaptured, "notes_list", { glob: "@human/**", query: "Café" }, restoredCtx));
170
+ assert.equal(searched.files[0]?.matches?.[0]?.line, 2);
173
171
  const listedFiles = resultData(await call(restoredCaptured, "notes_list", { glob: "@human/checkpoint/**" }, restoredCtx));
174
172
  assert.equal(listedFiles.files.length, 1, "glob ** crosses into the checkpoint directory");
175
173
  assert.equal(listedFiles.files[0]?.address, "@human/checkpoint/进度.md");
@@ -285,7 +283,7 @@ test("an over-budget note is delivered as a bounded prefix and resumed by next_o
285
283
  await call(captured, "notes_write", { address: "@project/receipt", content: "body" }, ctx),
286
284
  await call(captured, "notes_update", { address: "@project/receipt", edits: [{ oldText: "body", newText: "changed" }] }, ctx),
287
285
  await call(captured, "notes_list", { glob: "@project/**" }, ctx),
288
- await call(captured, "notes_search", { query: "changed", glob: "@project/**" }, ctx),
286
+ await call(captured, "notes_list", { query: "changed", glob: "@project/**" }, ctx),
289
287
  await call(captured, "notes_read", { address: "@project/receipt" }, ctx),
290
288
  ]) {
291
289
  assert.equal(JSON.stringify(result).includes(root), false, "notes receipts never expose the absolute home");
@@ -305,17 +303,15 @@ test("an over-budget note search match is a marked prefix with an honest line ad
305
303
  const hugeLine = `${'p'.repeat(500)}needle ${"y".repeat(TOOL_OUTPUT_MAX_BYTES * 2)}`;
306
304
  await call(captured, "notes_write", { address: "a.md", content: "needle small" }, ctx);
307
305
  await call(captured, "notes_write", { address: "search.md", content: hugeLine }, ctx);
308
- const pages = [];
309
- const rawFound = await call(captured, "notes_search", { query: "needle", limit: 10 }, ctx);
306
+ const rawFound = await call(captured, "notes_list", { query: "needle", limit: 10 }, ctx);
310
307
  const found = resultData(rawFound);
311
308
  assert.ok(Buffer.byteLength(JSON.stringify(found), "utf8") <= TOOL_OUTPUT_MAX_BYTES, "the structured match result stays within budget");
312
309
  assert.match(textOf(rawFound), /\[truncated\]/, "the model-facing match line carries the same marker");
313
- pages.push(...found.files);
314
310
  assert.equal(found.more, 1, "the oversized result names the omitted matching file");
315
- assert.deepEqual(pages.map((file) => file.address), ["search.md"], "the snapshot keeps the most recently updated match");
316
- const oversized = pages[0];
317
- assert.equal(oversized.matches.length, 1);
318
- const match = oversized.matches[0];
311
+ assert.deepEqual(found.files.map((file) => file.address), ["search.md"], "the snapshot keeps the most recently updated match");
312
+ const matches = found.files[0].matches;
313
+ assert.equal(matches.length, 1);
314
+ const match = matches[0];
319
315
  assert.ok(match.text.endsWith(" [truncated]"), "a shortened match line ends with the ellipsis marker");
320
316
  assert.ok(hugeLine.startsWith(match.text.slice(0, -" [truncated]".length)), "the match text is a plain prefix of the line plus its marker");
321
317
  assert.equal(match.line, 1, "the informational line number survives");
@@ -340,18 +336,18 @@ for (const [label, padding, cap] of [
340
336
  ["both limits", Math.floor(TOOL_OUTPUT_MAX_BYTES / 3), 6],
341
337
  ["shortened first line", TOOL_OUTPUT_MAX_BYTES * 2, undefined],
342
338
  ]) {
343
- test(`notes_search reports dropped lines after ${label}`, async () => {
339
+ test(`notes_list reports dropped match lines after ${label}`, async () => {
344
340
  const session = manager();
345
341
  const captured = makeExtension(session);
346
342
  const ctx = context(session);
347
343
  const lines = Array.from({ length: padding > TOOL_OUTPUT_MAX_BYTES ? 3 : 8 }, (_, index) => `needle ${index}${"y".repeat(padding)}`);
348
344
  resultData(await call(captured, "notes_write", { address: "matches.md", content: lines.join("\n") }, ctx));
349
- const raw = await call(captured, "notes_search", { query: "needle", max_matches_per_file: cap }, ctx);
345
+ const raw = await call(captured, "notes_list", { query: "needle", max_matches_per_file: cap }, ctx);
350
346
  assertWithinBudget(raw, label);
351
347
  const found = resultData(raw);
352
348
  assert.equal(found.more, 0, "line omissions are separate from omitted pages");
353
349
  const [file] = found.files;
354
- assert.ok(file);
350
+ assert.ok(file?.matches);
355
351
  assert.ok(file.matches.length > 0 && file.matches.length < lines.length);
356
352
  if (cap !== undefined)
357
353
  assert.ok(file.matches.length <= cap);
@@ -361,30 +357,29 @@ for (const [label, padding, cap] of [
361
357
  assert.ok(textOf(raw).includes(`${file.more_matches} more lines`));
362
358
  });
363
359
  }
364
- test("notes_search ignores case, treats queries literally, and preserves original Unicode offsets", async () => {
360
+ test("notes_list treats queries literally and preserves original Unicode offsets", async () => {
365
361
  const session = manager();
366
362
  const captured = makeExtension(session);
367
363
  const ctx = context(session);
368
364
  await call(captured, "notes_write", { address: "case-match.md", content: "😀İ NeEdLe.* tail" }, ctx);
369
- const found = resultData(await call(captured, "notes_search", { query: ["missing", "needle.*"], glob: "case-match.md" }, ctx));
365
+ const found = resultData(await call(captured, "notes_list", { query: ["missing", "needle.*"], glob: "case-match.md" }, ctx));
370
366
  assert.equal(found.files.length, 1);
371
- assert.equal(found.files[0].matches.length, 1);
372
- assert.equal(found.files[0].more_matches, undefined);
373
367
  const hit = found.files[0];
368
+ assert.equal(hit.matches?.length, 1);
374
369
  const read = resultRead(await call(captured, "notes_read", { address: hit.address, offset_chars: hit.matches[0].offset_chars }, ctx));
375
370
  assert.equal(read.content, "NeEdLe.* tail");
376
- const absent = resultData(await call(captured, "notes_search", { query: "needle.+", glob: "case-match.md" }, ctx));
371
+ const absent = resultData(await call(captured, "notes_list", { query: "needle.+", glob: "case-match.md" }, ctx));
377
372
  assert.deepEqual(absent.files, []);
378
373
  });
379
- test("notes_search scopes by glob; a non-matching glob is an empty page, not an error", async () => {
374
+ test("notes_list scopes queries by glob", async () => {
380
375
  const session = manager();
381
376
  const captured = makeExtension(session);
382
377
  const ctx = context(session);
383
378
  await call(captured, "notes_write", { address: "deep/nested/a.md", content: "needle here" }, ctx);
384
379
  await call(captured, "notes_write", { address: "top.md", content: "needle there" }, ctx);
385
- const scoped = resultData(await call(captured, "notes_search", { query: "needle", glob: "deep/**" }, ctx));
380
+ const scoped = resultData(await call(captured, "notes_list", { query: "needle", glob: "deep/**" }, ctx));
386
381
  assert.deepEqual(scoped.files.map((file) => file.address), ["deep/nested/a.md"], "a glob scopes the search to the subtree");
387
- const none = resultData(await call(captured, "notes_search", { query: "needle", glob: "absent/**" }, ctx));
382
+ const none = resultData(await call(captured, "notes_list", { query: "needle", glob: "absent/**" }, ctx));
388
383
  assert.deepEqual(none.files, [], "a non-matching glob is an empty page, not a refusal");
389
384
  });
390
385
  test("a large mutation keeps a receipt and budget warning while details.diff carries the UI diff", async () => {