notesoup 0.59.2 → 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 (62) hide show
  1. package/README.md +3 -17
  2. package/dist/plugins/claude/src/helper.js +1 -2
  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/history.d.ts +10 -11
  8. package/dist/src/history/history.js +8 -19
  9. package/dist/src/history/query.d.ts +3 -14
  10. package/dist/src/history/query.js +73 -85
  11. package/dist/src/index.d.ts +1 -1
  12. package/dist/src/index.js +1 -1
  13. package/dist/src/notes/address.js +3 -3
  14. package/dist/src/notes/store.d.ts +2 -4
  15. package/dist/src/notes/store.js +1 -2
  16. package/dist/src/tools/history.d.ts +4 -6
  17. package/dist/src/tools/history.js +69 -29
  18. package/dist/src/tools/notes.d.ts +18 -78
  19. package/dist/src/tools/notes.js +39 -50
  20. package/dist/src/tools/schema.d.ts +0 -1
  21. package/dist/src/tools/schema.js +0 -1
  22. package/dist/test/claude-history.test.js +5 -6
  23. package/dist/test/claude-mod.test.js +6 -7
  24. package/dist/test/codex-history.test.js +1 -1
  25. package/dist/test/codex-plugin.test.js +1 -2
  26. package/dist/test/dependencies.test.js +2 -2
  27. package/dist/test/dsh.test.js +2 -2
  28. package/dist/test/history-corpus.test.js +21 -36
  29. package/dist/test/history-summary-cache.test.js +3 -3
  30. package/dist/test/history.integration.test.js +53 -106
  31. package/dist/test/host-neutral.test.js +1 -1
  32. package/dist/test/note-policy.test.js +5 -5
  33. package/dist/test/notes-cwd.test.js +5 -5
  34. package/dist/test/notes-query-namespaces.test.js +2 -6
  35. package/dist/test/notes.integration.test.js +30 -35
  36. package/dist/test/notes.test.js +12 -14
  37. package/dist/test/project-namespace.test.js +3 -3
  38. package/docs/architecture.md +3 -3
  39. package/docs/claude-code-mod.md +2 -2
  40. package/docs/codex.md +1 -1
  41. package/docs/dsh.md +2 -2
  42. package/docs/history-sessions.md +8 -9
  43. package/docs/notes-library.md +3 -3
  44. package/docs/tool-results.md +12 -6
  45. package/package.json +1 -1
  46. package/plugins/claude/dist/claude/helper.js +162 -153
  47. package/plugins/claude/skills/memory/SKILL.md +6 -6
  48. package/plugins/claude/src/helper.ts +1 -2
  49. package/plugins/codex/README.md +1 -1
  50. package/plugins/codex/dist/codex/notesoup.js +161 -152
  51. package/plugins/codex/src/mcp.ts +1 -2
  52. package/plugins/dsh/tools.ts +1 -2
  53. package/plugins/pi/notes/tools.ts +2 -3
  54. package/skills/memory/SKILL.md +6 -6
  55. package/src/history/history.ts +11 -16
  56. package/src/history/query.ts +67 -99
  57. package/src/index.ts +1 -1
  58. package/src/notes/address.ts +2 -2
  59. package/src/notes/store.ts +3 -6
  60. package/src/tools/history.ts +60 -29
  61. package/src/tools/notes.ts +39 -54
  62. package/src/tools/schema.ts +0 -1
@@ -4,7 +4,8 @@ import { HISTORY_PREVIEW_CHARS, MAX_READ_WINDOW_CHARS, TOOL_OUTPUT_LIMIT } from
4
4
  import { failure, success } from "../result.js";
5
5
  import { fitsResult, resultSchema, readTextWindow, renderOutcome, renderTextWindow, TextWindowRequestSchema, TextWindowSchema } from "./result.js";
6
6
  import { historyRoles, searchQuery } from "./schema.js";
7
- import { HistoryPageSchema, CorpusCollector, corpusSelection, isMultiPage, markMultiPage, selectPage } from "../history/query.js";
7
+ import { InvalidQueryError, searchQueries } from "../text-match.js";
8
+ import { HistoryPageSchema, CorpusCollector, isMultiPage, markMultiPage, selectPage } from "../history/query.js";
8
9
  import { currentHistory, loadHistoryRepresentative, loadHistorySession, matchesSession, parseSessionSelector, resolveSession, sessionIdentity } from "../history/corpus.js";
9
10
  import { allItems, eventDocument, nestedCallSummary, toolSummary, HistoryRoleSchema, NestedCallSummarySchema, ToolSummarySchema } from "../history/history.js";
10
11
  /** One read: identity, tool summary and a flat document slice. */
@@ -35,7 +36,7 @@ function toolHeader(item) {
35
36
  }
36
37
  function renderPageItem(item) {
37
38
  const tool = toolHeader(item);
38
- const lines = tool === undefined ? [header(item)] : [header(item), tool];
39
+ const lines = [header(item) + (item.context ? " | search context" : ""), ...(tool ? [tool] : [])];
39
40
  if (item.truncated)
40
41
  lines.push(`[truncated; from offset ${item.offset_chars ?? 0}]`);
41
42
  lines.push(item.content);
@@ -44,7 +45,7 @@ function renderPageItem(item) {
44
45
  function renderFoldedRow(row) {
45
46
  const tools = Object.entries(row.tools).map(([name, count]) => `${name} ${count}`).join(", ");
46
47
  const identity = row.session === undefined ? {} : { session: row.session };
47
- const expand = `\n\t→ expand: ${JSON.stringify({ ...identity, after_seq: row.first_seq - 1, before_seq: row.last_seq + 1, roles: ["tool", "context"] })}`;
48
+ const expand = `\n\t→ expand: ${JSON.stringify({ ...identity, after: row.first_seq - 1, before: row.last_seq + 1, roles: ["tool", "context"] })}`;
48
49
  return `${row.session === undefined ? "" : `session ${row.session} | `}seqs ${row.first_seq}-${row.last_seq} | folded ${row.count} events${tools ? ` | ${tools}` : ""}${expand}`;
49
50
  }
50
51
  function renderPage(page) {
@@ -54,19 +55,20 @@ function renderPage(page) {
54
55
  const body = [...page.items.flatMap((item) => [...(item.folded_before ? [renderFoldedRow(item.folded_before)] : []), renderPageItem(item)]), ...(page.folded_after ? [renderFoldedRow(page.folded_after)] : [])].join("\n\n");
55
56
  if (isMultiPage(page)) {
56
57
  const directions = [page.has_older && "older", page.has_newer && "newer"].filter(Boolean).join("|");
57
- return (page.notice ?? "") + body + (directions ? `\n\n→ more ${directions} results: narrow with since/until, query, roles or the session pattern` : "");
58
+ return (page.notice ?? "") + body + (directions ? `\n\n→ more ${directions} results: narrow with time bounds (after/before), query, roles or the session pattern` : "");
58
59
  }
59
- const first = page.items[0];
60
- const last = page.items.at(-1);
60
+ const hits = page.items.filter(item => !item.context);
61
+ const first = hits[0];
62
+ const last = hits.at(-1);
61
63
  const cursors = [
62
- page.has_older ? `→ older: ${JSON.stringify({ ...(first.session === undefined ? {} : { session: first.session }), before_seq: first.seq })}` : "",
63
- page.has_newer ? `→ newer: ${JSON.stringify({ ...(last.session === undefined ? {} : { session: last.session }), after_seq: last.seq })}` : "",
64
+ page.has_older ? `→ older: ${JSON.stringify({ session: first.session, before: first.seq })}` : "",
65
+ page.has_newer ? `→ newer: ${JSON.stringify({ session: last.session, after: last.seq })}` : "",
64
66
  ].filter((line) => line !== "");
65
67
  return (page.notice ?? "") + (cursors.length === 0 ? body : `${body}\n\n${cursors.join(" | ")}`);
66
68
  }
67
69
  function renderRead(data) {
68
70
  const tool = toolHeader(data);
69
- const neighborhood = `neighborhood → \`history_list\`(${JSON.stringify({ ...(data.session === undefined ? {} : { session: data.session }), after_seq: Math.max(0, data.seq - 10), before_seq: data.seq + 10 })})`;
71
+ const neighborhood = `neighborhood → \`history_list\`(${JSON.stringify({ ...(data.session === undefined ? {} : { session: data.session }), after: Math.max(0, data.seq - 10), before: data.seq + 10 })})`;
70
72
  return (data.notice ?? "") + [header(data), ...(tool ? [tool] : []), neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
71
73
  }
72
74
  const plainText = (text) => text;
@@ -75,22 +77,57 @@ function pageOutcome(result) {
75
77
  if (!("pageTooLarge" in result))
76
78
  return result;
77
79
  const { count, multi } = result.pageTooLarge;
78
- const narrow = multi ? "narrow the session pattern, query, roles or `since`/`until`, or read one session/seq with `history_read`" : "narrow with `before_seq`/`after_seq` or `since`/`until`, pass `roles` to skip folding, or `history_read` one seq";
80
+ const narrow = multi ? "narrow the session pattern, query, roles or time bounds (`after`/`before`), or read one session/seq with `history_read`" : "narrow with `after`/`before`, pass `roles` to skip folding, or `history_read` one seq";
79
81
  return failure("page_too_large", `Even trimmed to their shortest, these ${count} rows${multi ? "" : " and their folded runs"} fill the ${TOOL_OUTPUT_LIMIT} a call can carry; ${narrow}.`);
80
82
  }
81
83
  /* ------------------------------------------------------------------ history_list */
84
+ const boundParameter = (description) => Type.Optional(Type.Union([Type.String(), Type.Number()], { description: `${description} Use a seq (number or digits) or ISO 8601 time (UTC without offset); wildcards take only times.` }));
82
85
  export const historyListParameters = Type.Object({
83
86
  session: Type.Optional(Type.String({ minLength: 1, description: "Whose record: a session ID or prefix (pi:, claude:, codex:, dsh: allowed). Leave it out for this one. `*` means every recent session." })),
84
- query: Type.Optional(searchQuery("Text to look for, or a list (any match). Searches what was said, tool arguments and output.")),
85
87
  roles: historyRoles(),
86
- before_seq: Type.Optional(Type.Integer({ minimum: 1, description: "Only entries before this seq." })),
87
- after_seq: Type.Optional(Type.Integer({ minimum: 0, description: "Only entries after this seq; 0 starts from the first page." })),
88
- since: Type.Optional(Type.String({ minLength: 1, description: "Only entries at or after this time (ISO 8601; UTC without an offset)." })),
89
- until: Type.Optional(Type.String({ minLength: 1, description: "Only entries before this time (ISO 8601; UTC without an offset)." })),
90
- from: Type.Optional(Type.Union([Type.Literal("newest"), Type.Literal("oldest")], { description: "Which end `limit` counts from: newest or oldest. Entries still read oldest first." })),
91
- limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: "How many entries per page; folded runs don't count." })),
88
+ query: Type.Optional(searchQuery("Text to look for, or a list (any match). Searches what was said, tool arguments and output.")),
89
+ after: boundParameter("Start strictly after this bound, paging forward; 0 starts at the oldest event."),
90
+ before: boundParameter("Stop strictly before this bound; without `after`, take the newest eligible events."),
91
+ context: Type.Optional(Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER, description: "Neighboring events on each side of a hit in its own session; requires a query." })),
92
+ limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: "How many events or hits per page; folds and search context don't count." })),
92
93
  max_chars_per_item: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_READ_WINDOW_CHARS, description: "How much of each entry to show." })),
93
94
  }, { additionalProperties: false });
95
+ const ISO_8601 = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
96
+ function parseBound(name, value) {
97
+ if (value === undefined)
98
+ return success(undefined);
99
+ if (typeof value === "number" || /^\d+$/.test(value)) {
100
+ const seq = Number(value);
101
+ if (Number.isSafeInteger(seq) && seq >= 0)
102
+ return success({ seq });
103
+ }
104
+ else if (typeof value === "string") {
105
+ const match = ISO_8601.exec(value);
106
+ const at = match ? Date.parse(match[1] ? value : `${value}Z`) : NaN;
107
+ if (!Number.isNaN(at) && new Date(value.slice(0, 10)).toISOString().startsWith(value.slice(0, 10)))
108
+ return success({ at });
109
+ }
110
+ return failure("invalid_bounds", `\`${name}\` must be a non-negative integer seq or an ISO 8601 time; got ${JSON.stringify(value)}.`);
111
+ }
112
+ function parseSelection(params) {
113
+ const after = parseBound("after", params.after);
114
+ if (!after.ok)
115
+ return after;
116
+ const before = parseBound("before", params.before);
117
+ if (!before.ok)
118
+ return before;
119
+ try {
120
+ const query = searchQueries(params.query);
121
+ if (!query.length && params.context !== undefined)
122
+ return failure("invalid_params", "`context` requires a non-empty `query`.");
123
+ return success({ after: after.data, before: before.data, query: query.length ? query : undefined, roles: params.roles, context: params.context, limit: params.limit });
124
+ }
125
+ catch (error) {
126
+ if (error instanceof InvalidQueryError)
127
+ return failure("invalid_query", error.message);
128
+ throw error;
129
+ }
130
+ }
94
131
  export const historyList = {
95
132
  name: "history_list",
96
133
  label: "History list items",
@@ -98,32 +135,35 @@ export const historyList = {
98
135
  parameters: historyListParameters,
99
136
  outputSchema: resultSchema(HistoryPageSchema),
100
137
  async execute(params, context, wrapText = plainText) {
138
+ const selection = parseSelection(params);
139
+ if (!selection.ok)
140
+ return selection;
141
+ const scoped = selection.data;
101
142
  // Charge wrapped rendering, identities, notices and recipes, not only event previews.
102
143
  const fits = (page) => fitsResult(success(page), (result) => wrapText(renderOutcome(result, renderPage)));
103
144
  const maxChars = params.max_chars_per_item ?? HISTORY_PREVIEW_CHARS;
104
145
  if (params.session === undefined)
105
- return pageOutcome(selectPage(await currentHistory(context), params, fits, maxChars));
146
+ return pageOutcome(selectPage(await currentHistory(context), scoped, fits, maxChars));
106
147
  const selector = parseSessionSelector(params.session);
107
148
  if (!selector.ok)
108
149
  return selector;
109
150
  const corpus = "corpus" in context ? context.corpus : undefined;
110
151
  if (selector.data.wildcard) {
111
- const scoped = corpusSelection(params);
112
- if (!scoped.ok)
113
- return scoped;
152
+ const { after, before, query, roles } = scoped;
153
+ if ((after && "seq" in after) || (before && "seq" in before))
154
+ return failure("invalid_bounds", "Wildcard history requires times, not seqs, for `after` and `before`.");
114
155
  if (corpus === undefined)
115
156
  return failure("unknown_session", "This host supplied no cross-session history corpus.");
116
157
  const sessions = (await corpus.sessions(selector.data.harness)).filter((session) => matchesSession(session, selector.data));
117
- const queries = Array.isArray(scoped.data.query) ? scoped.data.query : undefined;
118
- if (!queries)
119
- sessions.sort((a, b) => (scoped.data.from === "oldest" ? a.modifiedAt - b.modifiedAt : b.modifiedAt - a.modifiedAt) || sessionIdentity(a).localeCompare(sessionIdentity(b)));
120
- const representative = !queries && scoped.data.roles === undefined && scoped.data.since === undefined && scoped.data.until === undefined;
121
- const collector = new CorpusCollector(scoped.data);
158
+ if (!query)
159
+ sessions.sort((a, b) => (after ? a.modifiedAt - b.modifiedAt : b.modifiedAt - a.modifiedAt) || sessionIdentity(a).localeCompare(sessionIdentity(b)));
160
+ const representative = !query && !roles && !after && !before;
161
+ const collector = new CorpusCollector(scoped);
122
162
  let qualifying = 0;
123
163
  const notices = [];
124
164
  let unvisited = false;
125
165
  for (const [index, session] of sessions.entries()) {
126
- const result = representative ? await loadHistoryRepresentative(session) : await loadHistorySession(session, queries);
166
+ const result = representative ? await loadHistoryRepresentative(session) : await loadHistorySession(session, query);
127
167
  if (!result.ok || !result.data)
128
168
  continue;
129
169
  const added = "projection" in result.data ? collector.add(sessionIdentity(session), result.data.projection) : collector.addRepresentative(sessionIdentity(session), result.data.event);
@@ -132,7 +172,7 @@ export const historyList = {
132
172
  qualifying++;
133
173
  if (result.data.notice)
134
174
  notices.push(`session ${sessionIdentity(session)}: ${result.data.notice}`);
135
- if (!queries && qualifying >= Math.min(500, Math.max(1, params.limit ?? 20))) {
175
+ if (!query && qualifying >= Math.min(500, Math.max(1, params.limit ?? 20))) {
136
176
  unvisited = index + 1 < sessions.length;
137
177
  break;
138
178
  }
@@ -148,7 +188,7 @@ export const historyList = {
148
188
  if (!loaded.ok)
149
189
  return loaded;
150
190
  const notice = loaded.data.notice === undefined ? {} : { notice: loaded.data.notice };
151
- const result = pageOutcome(selectPage(loaded.data.projection, { ...params, session: sessionIdentity(target.data) }, (page) => fits({ ...page, ...notice }), maxChars));
191
+ const result = pageOutcome(selectPage(loaded.data.projection, { ...scoped, session: sessionIdentity(target.data) }, (page) => fits({ ...page, ...notice }), maxChars));
152
192
  return result.ok ? success({ ...result.data, ...notice }) : result;
153
193
  },
154
194
  render: (result) => renderOutcome(result, renderPage),
@@ -117,31 +117,11 @@ export declare const NotesListDataSchema: Type.TObject<{
117
117
  more: Type.TInteger;
118
118
  namespaces_unavailable: Type.TArray<Type.TString>;
119
119
  files: Type.TArray<Type.TObject<{
120
- updated_at: Type.TString;
121
- crumpled_at: Type.TOptional<Type.TString>;
122
- warnings: Type.TArray<Type.TString>;
123
- pinned: Type.TBoolean;
124
- budget: Type.TInteger;
125
- readonly: Type.TBoolean;
126
- project_root: Type.TOptional<Type.TString>;
127
- project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
128
- name: Type.TString;
129
- path: Type.TString;
130
- }>>>;
131
- address: Type.TString;
132
- project_key: Type.TOptional<Type.TString>;
133
- }>>;
134
- }>;
135
- export type NotesListData = Static<typeof NotesListDataSchema>;
136
- export declare const NotesSearchDataSchema: Type.TObject<{
137
- more: Type.TInteger;
138
- namespaces_unavailable: Type.TArray<Type.TString>;
139
- files: Type.TArray<Type.TObject<{
140
- matches: Type.TArray<Type.TObject<{
120
+ matches: Type.TOptional<Type.TArray<Type.TObject<{
141
121
  line: Type.TInteger;
142
122
  text: Type.TString;
143
123
  offset_chars: Type.TInteger;
144
- }>>;
124
+ }>>>;
145
125
  more_matches: Type.TOptional<Type.TInteger>;
146
126
  updated_at: Type.TString;
147
127
  crumpled_at: Type.TOptional<Type.TString>;
@@ -158,7 +138,8 @@ export declare const NotesSearchDataSchema: Type.TObject<{
158
138
  project_key: Type.TOptional<Type.TString>;
159
139
  }>>;
160
140
  }>;
161
- export type NotesSearchData = Static<typeof NotesSearchDataSchema>;
141
+ export type NotesListData = Static<typeof NotesListDataSchema>;
142
+ type ListedFile = Static<typeof ListedFileSchema>;
162
143
  type Snapshot<T> = Omit<NotesListData, "files"> & {
163
144
  files: T[];
164
145
  };
@@ -169,7 +150,7 @@ export declare function snapshot<T extends {
169
150
  export declare function listedFile(row: Pick<NoteRow, "address" | "meta"> & {
170
151
  body?: string;
171
152
  warnings?: string[];
172
- }, identity: NotesIdentity): NotesListData["files"][number];
153
+ }, identity: NotesIdentity): ListedFile;
173
154
  export declare const notesWriteParameters: Type.TObject<{
174
155
  cwd: Type.TOptional<Type.TString>;
175
156
  pinned: Type.TOptional<Type.TBoolean>;
@@ -316,80 +297,39 @@ export declare const notesRead: {
316
297
  readonly render: (result: Outcome<NotesReadData>) => string;
317
298
  };
318
299
  export declare const notesListParameters: Type.TObject<{
319
- glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
320
- limit: Type.TOptional<Type.TInteger>;
300
+ glob: Type.TOptional<Type.TString>;
301
+ query: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>>;
302
+ max_matches_per_file: Type.TOptional<Type.TInteger>;
321
303
  crumpled: Type.TOptional<Type.TBoolean>;
304
+ limit: Type.TOptional<Type.TInteger>;
322
305
  cwd: Type.TOptional<Type.TString>;
323
306
  }>;
324
307
  export declare function renderListData(data: Snapshot<NotesListData["files"][number] & {
325
308
  last_accessed?: string;
326
309
  }>): string;
310
+ /** A shortened match line still ends with a marker, so its own text says it was cut. */
311
+ export declare const MATCH_SHORTENED_MARKER = " [truncated]";
327
312
  export declare const notesList: {
328
313
  readonly name: "notes_list";
329
314
  readonly label: "Notes list";
330
- readonly description: "Leaf through the drawers, newest pages on top. One pass; `more` counts pages left on the pile — narrow `glob`.";
331
- readonly parameters: Type.TObject<{
332
- glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
333
- limit: Type.TOptional<Type.TInteger>;
334
- crumpled: Type.TOptional<Type.TBoolean>;
335
- cwd: Type.TOptional<Type.TString>;
336
- }>;
337
- readonly outputSchema: Type.TUnion<[Type.TObject<{
338
- more: Type.TInteger;
339
- namespaces_unavailable: Type.TArray<Type.TString>;
340
- files: Type.TArray<Type.TObject<{
341
- updated_at: Type.TString;
342
- crumpled_at: Type.TOptional<Type.TString>;
343
- warnings: Type.TArray<Type.TString>;
344
- pinned: Type.TBoolean;
345
- budget: Type.TInteger;
346
- readonly: Type.TBoolean;
347
- project_root: Type.TOptional<Type.TString>;
348
- project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
349
- name: Type.TString;
350
- path: Type.TString;
351
- }>>>;
352
- address: Type.TString;
353
- project_key: Type.TOptional<Type.TString>;
354
- }>>;
355
- }>, Type.TObject<{
356
- error: Type.TString;
357
- code: Type.TString;
358
- }>]>;
359
- readonly execute: (params: Static<typeof notesListParameters>, context: NotesToolContext) => Promise<Outcome<NotesListData>>;
360
- readonly render: (result: Outcome<NotesListData>) => string;
361
- };
362
- export declare const notesSearchParameters: Type.TObject<{
363
- query: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>>;
364
- glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
365
- limit: Type.TOptional<Type.TInteger>;
366
- max_matches_per_file: Type.TOptional<Type.TInteger>;
367
- crumpled: Type.TOptional<Type.TBoolean>;
368
- cwd: Type.TOptional<Type.TString>;
369
- }>;
370
- /** A shortened match line still ends with a marker, so its own text says it was cut. */
371
- export declare const MATCH_SHORTENED_MARKER = " [truncated]";
372
- export declare const notesSearch: {
373
- readonly name: "notes_search";
374
- readonly label: "Notes search";
375
- readonly description: "Run a finger down every page for some text, case doesn't matter. Returns the lines it hits and where they sit; no query just lists the pages. One pass; `more` counts pages left on the pile — narrow `glob`.";
315
+ readonly description: "List or search notes, newest pages on top. A query matches literal text (ignoring case) and returns hit lines and read offsets. One pass; `more` counts pages left on the pile — narrow `glob`.";
376
316
  readonly parameters: Type.TObject<{
317
+ glob: Type.TOptional<Type.TString>;
377
318
  query: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>>;
378
- glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
379
- limit: Type.TOptional<Type.TInteger>;
380
319
  max_matches_per_file: Type.TOptional<Type.TInteger>;
381
320
  crumpled: Type.TOptional<Type.TBoolean>;
321
+ limit: Type.TOptional<Type.TInteger>;
382
322
  cwd: Type.TOptional<Type.TString>;
383
323
  }>;
384
324
  readonly outputSchema: Type.TUnion<[Type.TObject<{
385
325
  more: Type.TInteger;
386
326
  namespaces_unavailable: Type.TArray<Type.TString>;
387
327
  files: Type.TArray<Type.TObject<{
388
- matches: Type.TArray<Type.TObject<{
328
+ matches: Type.TOptional<Type.TArray<Type.TObject<{
389
329
  line: Type.TInteger;
390
330
  text: Type.TString;
391
331
  offset_chars: Type.TInteger;
392
- }>>;
332
+ }>>>;
393
333
  more_matches: Type.TOptional<Type.TInteger>;
394
334
  updated_at: Type.TString;
395
335
  crumpled_at: Type.TOptional<Type.TString>;
@@ -409,7 +349,7 @@ export declare const notesSearch: {
409
349
  error: Type.TString;
410
350
  code: Type.TString;
411
351
  }>]>;
412
- readonly execute: (params: Static<typeof notesSearchParameters>, context: NotesToolContext) => Promise<Outcome<NotesSearchData>>;
413
- readonly render: (result: Outcome<NotesSearchData>) => string;
352
+ readonly execute: (params: Static<typeof notesListParameters>, context: NotesToolContext) => Promise<Outcome<NotesListData>>;
353
+ readonly render: (result: Outcome<NotesListData>) => string;
414
354
  };
415
355
  export {};
@@ -9,7 +9,7 @@ import { TOOL_OUTPUT_LIMIT } from "./output.js";
9
9
  import { failure, success } from "../result.js";
10
10
  import { InvalidQueryError, prefixFit, searchQueries } from "../text-match.js";
11
11
  import { fitsResult, resultSchema, readTextWindow, renderOutcome, renderTextWindow, structuredBytes, TextWindowRequestSchema, TextWindowSchema } from "./result.js";
12
- import { nullableString, searchQuery } from "./schema.js";
12
+ import { searchQuery } from "./schema.js";
13
13
  import { notesIdentityForCall } from "./notes-context.js";
14
14
  const ORIGIN_VALUES = [Type.Literal("user"), Type.Literal("self"), Type.Literal("external")];
15
15
  const ORIGIN = Type.Optional(Type.Union([...ORIGIN_VALUES], {
@@ -36,7 +36,7 @@ function withWarnings(text, data) {
36
36
  const CRUMPLED_PARAMETER = Type.Optional(Type.Boolean({ description: "`true` balls the page up: gone from list and search, still readable. `false` smooths it flat again." }));
37
37
  const CRUMPLED_LIST_PARAMETER = Type.Optional(Type.Boolean({ description: "Only the crumpled balls." }));
38
38
  const FILE_LIMIT_PARAMETER = Type.Optional(Type.Integer({ minimum: 1, description: "How many pages at most." }));
39
- const GLOB_PARAMETER = nullableString("Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf · `MAP.md` that page in every notebook · `**` everything · `@sessions/*/**` every session.");
39
+ const GLOB_PARAMETER = Type.Optional(Type.String({ minLength: 1, description: "Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf · `MAP.md` that page in every notebook · `**` everything · `@sessions/*/**` every session." }));
40
40
  const CWD_PARAMETER = Type.Optional(Type.String({ minLength: 1, description: "Treat this directory's project as `@project/`." }));
41
41
  const ADDRESS_PARAMETER = Type.String({ description: "Which drawer the page sits in. `plan.md` — this session's desk, cleared when it ends. `@project/` this project's shelf · `@human/` your human's file · `@self/` your own notebook · `@model/` your brain's. `@projects/<name>/`, `@sessions/<id>/`, `@agents/<name>/`, `@models/<name>/` — someone else's shelf: read only. Paper, not files: hand one to read/write/edit/bash and a real `@project` folder is born." });
42
42
  /**
@@ -148,10 +148,6 @@ const MatchSchema = Type.Object({
148
148
  text: Type.String(),
149
149
  offset_chars: Type.Integer(),
150
150
  }, { additionalProperties: false });
151
- const SearchedFileSchema = Type.Object({
152
- ...ListedFileSchema.properties,
153
- matches: Type.Array(MatchSchema), more_matches: Type.Optional(Type.Integer({ minimum: 1 })),
154
- }, { additionalProperties: false });
155
151
  export const SnapshotSchema = {
156
152
  more: Type.Integer({ description: "How many more were left out." }),
157
153
  namespaces_unavailable: Type.Array(Type.String(), { description: "Unreadable notebooks or notes." }),
@@ -176,11 +172,10 @@ export const NotesReadDataSchema = Type.Object({
176
172
  ...TextWindowSchema.properties,
177
173
  }, { additionalProperties: false });
178
174
  export const NotesListDataSchema = Type.Object({
179
- files: Type.Array(ListedFileSchema),
180
- ...SnapshotSchema,
181
- }, { additionalProperties: false });
182
- export const NotesSearchDataSchema = Type.Object({
183
- files: Type.Array(SearchedFileSchema),
175
+ files: Type.Array(Type.Object({
176
+ ...ListedFileSchema.properties,
177
+ matches: Type.Optional(Type.Array(MatchSchema)), more_matches: Type.Optional(Type.Integer({ minimum: 1 })),
178
+ }, { additionalProperties: false })),
184
179
  ...SnapshotSchema,
185
180
  }, { additionalProperties: false });
186
181
  /** Keep identities intact. Only search previews may shrink to make the first row fit. */
@@ -296,42 +291,27 @@ export const notesRead = {
296
291
  },
297
292
  render: (result) => renderOutcome(result, renderReadData),
298
293
  };
299
- export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, crumpled: CRUMPLED_LIST_PARAMETER, cwd: CWD_PARAMETER }, { additionalProperties: false });
294
+ export const notesListParameters = Type.Object({
295
+ glob: GLOB_PARAMETER,
296
+ query: Type.Optional(searchQuery()),
297
+ max_matches_per_file: Type.Optional(Type.Integer({ minimum: 1, description: "How many hit lines per note at most; requires a query." })),
298
+ crumpled: CRUMPLED_LIST_PARAMETER,
299
+ limit: FILE_LIMIT_PARAMETER,
300
+ cwd: CWD_PARAMETER,
301
+ }, { additionalProperties: false });
300
302
  export function renderListData(data) {
301
303
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
302
304
  for (const file of data.files) {
303
- lines.push(`- ${renderIdentity(file)} | ${renderPolicy(file)} | updated ${file.updated_at}${file.last_accessed === undefined ? "" : ` | accessed ${file.last_accessed}`}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
305
+ const fields = [`- ${renderIdentity(file)}`, renderPolicy(file), `updated ${file.updated_at}`];
306
+ if (file.last_accessed !== undefined)
307
+ fields.push(`accessed ${file.last_accessed}`);
308
+ if (file.crumpled_at !== undefined)
309
+ fields.push(`crumpled ${file.crumpled_at}`);
310
+ if (file.matches)
311
+ fields.push(`${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
312
+ lines.push(fields.join(" | "));
304
313
  lines.push(...file.warnings.map(warning => ` ${warning}`));
305
- }
306
- if (data.more > 0)
307
- lines.push(`${data.more} more matching notes omitted; narrow with glob`);
308
- for (const namespace of data.namespaces_unavailable)
309
- lines.push(`${namespace} could not be read`);
310
- return lines.join("\n");
311
- }
312
- export const notesList = {
313
- name: "notes_list", label: "Notes list",
314
- description: "Leaf through the drawers, newest pages on top. One pass; `more` counts pages left on the pile — narrow `glob`.",
315
- parameters: notesListParameters, outputSchema: resultSchema(NotesListDataSchema),
316
- async execute(params, context) {
317
- try {
318
- const identity = notesIdentityForCall(context, params.cwd);
319
- const { rows, status } = await createNotesStore(identity).listWithStatus({ glob: params.glob ?? undefined, crumpled: params.crumpled });
320
- return snapshot(rows.map(row => listedFile(row, identity)), params.limit, status, renderListData);
321
- }
322
- catch (error) {
323
- return failureOf(error);
324
- }
325
- },
326
- render: (result) => renderOutcome(result, renderListData),
327
- };
328
- export const notesSearchParameters = Type.Object({ query: Type.Optional(searchQuery()), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: Type.Optional(Type.Integer({ minimum: 1, description: "How many hit lines per page at most." })), crumpled: CRUMPLED_LIST_PARAMETER, cwd: CWD_PARAMETER }, { additionalProperties: false });
329
- function renderSearchData(data) {
330
- const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
331
- for (const file of data.files) {
332
- lines.push(`- ${renderIdentity(file)} | ${renderPolicy(file)} | updated ${file.updated_at} | ${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
333
- lines.push(...file.warnings.map(warning => ` ${warning}`));
334
- for (const match of file.matches)
314
+ for (const match of file.matches ?? [])
335
315
  lines.push(` line ${match.line} at offset_chars ${match.offset_chars}: ${match.text}`);
336
316
  }
337
317
  if (data.more > 0)
@@ -363,23 +343,32 @@ function fitSearchFile(file, fits) {
363
343
  const withText = (text) => ({ ...keepMatches(file, 1), matches: [{ ...first, text: `${text}${MATCH_SHORTENED_MARKER}` }] });
364
344
  return withText(prefixFit(first.text, text => fits(withText(text))));
365
345
  }
366
- export const notesSearch = {
367
- name: "notes_search", label: "Notes search",
368
- description: "Run a finger down every page for some text, case doesn't matter. Returns the lines it hits and where they sit; no query just lists the pages. One pass; `more` counts pages left on the pile — narrow `glob`.",
369
- parameters: notesSearchParameters, outputSchema: resultSchema(NotesSearchDataSchema),
346
+ export const notesList = {
347
+ name: "notes_list", label: "Notes list",
348
+ description: "List or search notes, newest pages on top. A query matches literal text (ignoring case) and returns hit lines and read offsets. One pass; `more` counts pages left on the pile — narrow `glob`.",
349
+ parameters: notesListParameters, outputSchema: resultSchema(NotesListDataSchema),
370
350
  async execute(params, context) {
371
351
  try {
352
+ const queries = searchQueries(params.query);
353
+ const { glob, crumpled, limit } = params;
354
+ if (!queries.length && params.max_matches_per_file !== undefined)
355
+ return failure("invalid_params", "`max_matches_per_file` requires a non-empty `query`.");
372
356
  const identity = notesIdentityForCall(context, params.cwd);
373
- const { rows, status } = await createNotesStore(identity).searchWithStatus(searchQueries(params.query), { glob: params.glob ?? undefined, crumpled: params.crumpled });
357
+ const store = createNotesStore(identity);
358
+ if (!queries.length) {
359
+ const { rows, status } = await store.listWithStatus({ glob, crumpled });
360
+ return snapshot(rows.map(row => listedFile(row, identity)), limit, status, renderListData);
361
+ }
362
+ const { rows, status } = await store.searchWithStatus(queries, { glob, crumpled });
374
363
  const files = rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address)).map(row => keepMatches({
375
364
  ...listedFile(row, identity),
376
365
  matches: row.matches.map(match => ({ line: match.line, text: match.text, offset_chars: match.offsetChars })),
377
366
  }, params.max_matches_per_file));
378
- return snapshot(files, params.limit, status, renderSearchData, fitSearchFile);
367
+ return snapshot(files, limit, status, renderListData, fitSearchFile);
379
368
  }
380
369
  catch (error) {
381
370
  return failureOf(error);
382
371
  }
383
372
  },
384
- render: (result) => renderOutcome(result, renderSearchData),
373
+ render: (result) => renderOutcome(result, renderListData),
385
374
  };
@@ -1,5 +1,4 @@
1
1
  import { Type, type TSchema } from "typebox";
2
- export declare const nullableString: (description?: string) => Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
3
2
  export declare const historyRoles: () => Type.TOptional<Type.TArray<Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"assistant">, Type.TLiteral<"tool">, Type.TLiteral<"context">]>>>;
4
3
  /** First parameter violation; skip false subschemas so additionalProperties can name the field. */
5
4
  export declare function paramProblem(schema: TSchema, params: unknown): string;
@@ -1,7 +1,6 @@
1
1
  import { Type } from "typebox";
2
2
  import { Errors } from "typebox/value";
3
3
  import { HistoryRoleSchema } from "../history/history.js";
4
- export const nullableString = (description) => Type.Optional(Type.Union([Type.String(), Type.Null()], description === undefined ? {} : { description }));
5
4
  export const historyRoles = () => Type.Optional(Type.Array(HistoryRoleSchema, { minItems: 1, description: "Only these voices: user, assistant, tool, context. Without roles or query, tool and context runs fold into one line." }));
6
5
  /** First parameter violation; skip false subschemas so additionalProperties can name the field. */
7
6
  export function paramProblem(schema, params) {
@@ -103,7 +103,7 @@ test("Claude dialogue paging skips tool/thinking envelopes without losing array
103
103
  compact("boundary", "last"), row("boot", "boundary", "user", bootText(1))];
104
104
  const projection = project(rows, "boot");
105
105
  assert.equal(projection.highestSeq, 10);
106
- const listed = await historyList.execute({ before_seq: 9, roles: ["user", "assistant"], limit: 3 }, projection);
106
+ const listed = await historyList.execute({ before: 9, roles: ["user", "assistant"], limit: 3 }, projection);
107
107
  assert.ok(listed.ok);
108
108
  assert.deepEqual(listed.data.items.map((item) => "seq" in item ? [item.seq, item.content] : []), [[1, "human question"], [2, "assistant answer"], [8, "human followup"]]);
109
109
  const read = await historyRead.execute({ seq: 2 }, projection);
@@ -196,7 +196,7 @@ test("Claude native compaction and reset keep pre-reset history, preserved rewri
196
196
  assert.equal(allItems(projection).find((event) => event.text === "before first reset")?.windowId, `claude:${sessionId}:0`);
197
197
  assert.equal(allItems(projection).find((event) => event.text === "after first reset")?.windowId, `claude:${sessionId}:1`);
198
198
  assert.equal(projection.highestSeq, 8);
199
- const earlier = await historyList.execute({ after_seq: 4, before_seq: 6, roles: ["assistant"] }, projection);
199
+ const earlier = await historyList.execute({ after: 4, before: 6, roles: ["assistant"] }, projection);
200
200
  assert.ok(earlier.ok);
201
201
  assert.deepEqual(earlier.data.items.map((item) => "content" in item ? item.content : ""), ["after first reset"]);
202
202
  assert.equal(projection.windows[0]?.items[0]?.seq, 1);
@@ -210,7 +210,7 @@ test("Claude reset crosses native turn_duration graph metadata with no message c
210
210
  assert.equal(projection.highestSeq, 5, "duration metadata does not allocate a message address");
211
211
  assert.equal(projection.windows.length, 2);
212
212
  assert.ok(allItems(projection).some((event) => event.text === "marker before reset"));
213
- assert.ok((await historyList.execute({ before_seq: 3 }, projection)).ok);
213
+ assert.ok((await historyList.execute({ before: 3 }, projection)).ok);
214
214
  assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
215
215
  });
216
216
  test("Claude api_error retry metadata keeps compact ancestry without allocating seq or exposing internals", async () => {
@@ -228,7 +228,7 @@ test("Claude api_error retry metadata keeps compact ancestry without allocating
228
228
  assert.deepEqual(project([...prefix, { ...rows[3], logicalParentUuid: "old" }, ...rows.slice(4)], "after"), projection, "metadata leaves all addresses and windows unchanged");
229
229
  assert.doesNotMatch(allItems(projection).map(eventDocument).join("\n"), /PRIVATE_RETRY_PAYLOAD|ECONNRESET|request_retry/);
230
230
  assert.ok((await historyList.execute({}, projection)).ok);
231
- const earlier = await historyList.execute({ before_seq: 3 }, projection);
231
+ const earlier = await historyList.execute({ before: 3 }, projection);
232
232
  assert.ok(earlier.ok);
233
233
  assert.match(JSON.stringify(earlier), /before retry|finished turn/);
234
234
  assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
@@ -324,7 +324,6 @@ test("Claude helper reports gaps on list/read and re-anchors reset state only wi
324
324
  assert.equal(excluded.ok, false);
325
325
  assert.match(excluded.text, /outside the confirmed selected history/);
326
326
  await assert.rejects(invoke("history_list", { window_id: "anything" }), /invalid history_list parameters:.*window_id/);
327
- await assert.rejects(invoke("history_list", { before_seq: "invalid" }), /invalid history_list parameters: before_seq/);
328
327
  await assert.rejects(invoke("history_read", { seq: "2" }), /invalid history_read parameters: seq/);
329
328
  await assert.rejects(dispatch({ op: "history_state", identity, history }), /cannot determine the current window ordinal/);
330
329
  // A native boundary alone cannot count the missing earlier resets. A quoted
@@ -346,7 +345,7 @@ test("Claude helper reports gaps on list/read and re-anchors reset state only wi
346
345
  rows.push(compact("next", "after"), row("next-boot", "next", "user", bootText(9)), user("latest", "next-boot", "latest"));
347
346
  writeFileSync(transcriptPath, jsonl(rows));
348
347
  history.headUuid = "latest";
349
- const earlier = await invoke("history_list", { after_seq: 5, before_seq: 7 });
348
+ const earlier = await invoke("history_list", { after: 5, before: 7 });
350
349
  assert.ok(earlier.ok);
351
350
  assert.match(earlier.text, /after anchored reset/);
352
351
  assert.doesNotMatch(earlier.text, /confirmed suffix/);
@@ -122,9 +122,9 @@ test("Claude notes survive removal of the session's worktree cwd", async (t) =>
122
122
  assert.match((await call("notes_read", { address })).result, /done/);
123
123
  }
124
124
  });
125
- test("Claude helper exposes the seven shared notes/history schemas", async () => {
125
+ test("Claude helper exposes the shared notes/history schemas", async () => {
126
126
  const schemas = await dispatch({ op: "schemas" });
127
- assert.deepEqual(schemas.map((schema) => schema.name), ["notes_write", "notes_update", "notes_read", "notes_list", "notes_search", "history_list", "history_read"]);
127
+ assert.deepEqual(schemas.map((schema) => schema.name), ["notes_write", "notes_update", "notes_read", "notes_list", "history_list", "history_read"]);
128
128
  assert.ok(schemas.every((schema) => schema.description.length > 20 && schema.inputSchema.type === "object"));
129
129
  });
130
130
  test("Claude helper delivers only shared rendered text and success", async () => {
@@ -328,7 +328,7 @@ test("Claude Mod helper runs from a standalone copied plugin directory", () => {
328
328
  }));
329
329
  const schemas = run('{"op":"schemas"}');
330
330
  assert.equal(schemas.ok, true);
331
- assert.equal(schemas.result?.length, 7);
331
+ assert.equal(schemas.result?.length, 6);
332
332
  assert.equal(run("not json").ok, false);
333
333
  }
334
334
  finally {
@@ -524,7 +524,7 @@ test("Claude Mod hook delivers the helper's shared text, and marks only a refusa
524
524
  const handlers = new Map();
525
525
  hooks.register((event, handler) => handlers.set(event, handler));
526
526
  await handlers.get("session.start")(host, { cwd: home, isInteractive: true }, async (event) => event);
527
- assert.deepEqual(registered.map((spec) => spec.name), ["empty_brain", "notes_write", "notes_update", "notes_read", "notes_list", "notes_search", "history_list", "history_read"]);
527
+ assert.deepEqual(registered.map((spec) => spec.name), ["empty_brain", "notes_write", "notes_update", "notes_read", "notes_list", "history_list", "history_read"]);
528
528
  for (const spec of registered) {
529
529
  assert.equal(spec.isDeferred, false, `${spec.name} is available from the start without tool search`);
530
530
  assert.ok(spec.description.length > 20);
@@ -586,7 +586,6 @@ test("Claude Mod clears at the shared hard point after successful settlement and
586
586
  return {};
587
587
  };
588
588
  await invoke("session.start", { cwd: home, isInteractive: true });
589
- assert.equal(registered.length, 8);
590
589
  const initial = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
591
590
  assert.equal(initial.blocks.length, 1, "below the warn point no warning joins the boot");
592
591
  assert.match(initial.blocks[0].text, /Current context window id: claude:hook-session:0/);
@@ -1732,7 +1731,7 @@ test("Claude serves every registered notes tool to subagents without leaking eve
1732
1731
  assert.match((await call("notes_read", { address: "child.md" })).result, /child body/);
1733
1732
  assert.equal((await call("notes_update", { address: "child.md", edits: [{ oldText: "child body", newText: "updated body" }] })).isError, undefined);
1734
1733
  assert.match((await call("notes_list", {})).result, /child\.md/);
1735
- assert.match((await call("notes_search", { query: "updated body" })).result, /child\.md/);
1734
+ assert.match((await call("notes_list", { query: "updated body" })).result, /child\.md/);
1736
1735
  assert.equal((await call("notes_read", { address: "absent.md" })).isError, true, "refusals retain the error discriminator in subagents");
1737
1736
  });
1738
1737
  test("Claude identity uses the documented current model and cwd, with a safe model fallback", async (t) => {
@@ -1841,7 +1840,7 @@ test("Claude history keeps classic transcript_path across startup, confirms appe
1841
1840
  // Real order: classic -> startup attachment appends -> typed session.start.
1842
1841
  await invoke("session.append", { uuid: "startup" }, { uuid: "startup", message: {} });
1843
1842
  await invoke("session.start", { cwd: home, isInteractive: true });
1844
- assert.equal(registered.length, 8);
1843
+ assert.ok(registered.some((tool) => tool.name === "history_list"));
1845
1844
  const listed = await call("history_list", { roles: ["user", "context"] });
1846
1845
  assert.equal(listed.isError, undefined, listed.result);
1847
1846
  assert.match(listed.result, /old request/);
@@ -209,7 +209,7 @@ test("two native checkpoints retain old raw history; replacement_history is not
209
209
  assert.deepEqual(second.projection.windows.map((w) => [w.windowId, w.items[0]?.seq, w.items.at(-1)?.seq]), [
210
210
  [`codex:${ROOT}:${W0}`, 2, 3], [`codex:${ROOT}:${W1}`, 4, 6], [`codex:${ROOT}:${W2}`, 7, 8],
211
211
  ]);
212
- const earlier = await historyList.execute({ after_seq: 3, before_seq: 7, roles: ["user"] }, second.projection);
212
+ const earlier = await historyList.execute({ after: 3, before: 7, roles: ["user"] }, second.projection);
213
213
  assert.ok(earlier.ok);
214
214
  assert.deepEqual(earlier.data.items.map((item) => [item.seq, item.role, item.content]), [[6, "user", "middle text"]]);
215
215
  const old = await historyRead.execute({ seq: 2 }, second.projection);