notesoup 0.52.5 → 0.52.7

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 (44) hide show
  1. package/dist/plugins/claude/src/helper.js +34 -7
  2. package/dist/plugins/claude/src/history.d.ts +7 -2
  3. package/dist/plugins/claude/src/history.js +53 -22
  4. package/dist/plugins/claude/src/text.d.ts +5 -0
  5. package/dist/plugins/claude/src/text.js +12 -0
  6. package/dist/src/history/history.js +12 -11
  7. package/dist/src/notes/store.d.ts +2 -0
  8. package/dist/src/notes/store.js +2 -2
  9. package/dist/src/tools/dream.d.ts +2 -0
  10. package/dist/src/tools/history.d.ts +5 -3
  11. package/dist/src/tools/history.js +9 -11
  12. package/dist/src/tools/notes.d.ts +7 -0
  13. package/dist/src/tools/notes.js +8 -3
  14. package/dist/test/claude-history.test.js +135 -3
  15. package/dist/test/dream-skill.test.js +5 -0
  16. package/dist/test/dream-tools.test.js +15 -0
  17. package/dist/test/history.integration.test.js +26 -1
  18. package/dist/test/notes-library.test.js +1 -1
  19. package/dist/test/notes.test.js +1 -1
  20. package/dist/test/pi-render.test.js +2 -2
  21. package/docs/claude-code-mod.md +6 -2
  22. package/docs/tool-results.md +2 -2
  23. package/package.json +1 -1
  24. package/playbook.md +24 -13
  25. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  26. package/plugins/claude/dist/claude/helper.js +105 -44
  27. package/plugins/claude/playbook.md +24 -13
  28. package/plugins/claude/skills/dream/SKILL.md +8 -0
  29. package/plugins/claude/src/helper.ts +34 -9
  30. package/plugins/claude/src/history.ts +54 -22
  31. package/plugins/claude/src/text.ts +13 -0
  32. package/plugins/paseo/OVERVIEW.md +6 -2
  33. package/plugins/paseo/client/brain-empty-card.tsx +3 -1
  34. package/plugins/paseo/client/brain-empty-transformer.ts +7 -14
  35. package/plugins/paseo/client/notes-op-transformer.ts +10 -18
  36. package/plugins/paseo/client/tool-result.ts +31 -0
  37. package/plugins/paseo/test/brain-empty.test.ts +24 -1
  38. package/plugins/paseo/test/fixtures/claude-tool-calls.ts +86 -0
  39. package/plugins/paseo/test/notes-op.test.ts +39 -1
  40. package/skills/dream/SKILL.md +8 -0
  41. package/src/history/history.ts +12 -10
  42. package/src/notes/store.ts +4 -3
  43. package/src/tools/history.ts +14 -13
  44. package/src/tools/notes.ts +8 -3
@@ -80,10 +80,9 @@ function renderRead(data: HistoryReadData): string {
80
80
 
81
81
  /* ------------------------------------------------------------------ shared bounding */
82
82
 
83
- /** Include rendering and cursors in the budget, not just row contents. */
84
- function pageFits(page: HistoryPage): boolean {
85
- return fitsResult(success(page), (result) => renderOutcome(result, renderPage));
86
- }
83
+ /** Pure host decoration, measured during selection and applied unchanged by the caller at delivery. */
84
+ export type HistoryTextWrapper = (text: string) => string;
85
+ const plainText: HistoryTextWrapper = (text) => text;
87
86
 
88
87
  // Sample known ids in the refusal message itself, never as a second listing.
89
88
  const MAX_REPORTED_WINDOWS = 5;
@@ -114,15 +113,15 @@ function badWindowId(projection: HistoryProjection, params: HistoryFilter): Outc
114
113
 
115
114
  export const historyWindowsParameters = Type.Object({}, { additionalProperties: false });
116
115
 
117
- export const historyWindows: Operation<typeof historyWindowsParameters, HistoryWindowsData, [HistoryProjection, string]> = {
116
+ export const historyWindows: Operation<typeof historyWindowsParameters, HistoryWindowsData, [HistoryProjection, string, HistoryTextWrapper?]> = {
118
117
  name: "history_windows",
119
118
  label: "History list windows",
120
119
  description: "List this session's context windows, oldest first, with seq ranges.",
121
120
  parameters: historyWindowsParameters,
122
121
  outputSchema: resultSchema(HistoryWindowsDataSchema),
123
- async execute(_params, projection, sessionId) {
122
+ async execute(_params, projection, sessionId, wrapText = plainText) {
124
123
  const data: HistoryWindowsData = { session_id: sessionId, windows: [], more: projection.windows.length };
125
- const fits = (candidate: HistoryWindowsData) => fitsResult(success(candidate), (result) => renderOutcome(result, renderWindows));
124
+ const fits = (candidate: HistoryWindowsData) => fitsResult(success(candidate), (result) => wrapText(renderOutcome(result, renderWindows)));
126
125
  for (const window of projection.windows) {
127
126
  let first: number | null = null;
128
127
  let last: number | null = null;
@@ -161,19 +160,21 @@ export const historyListParameters = Type.Object({
161
160
  max_chars_per_item: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_READ_WINDOW_CHARS, description: `(optional, default ${HISTORY_PREVIEW_CHARS}) Max preview chars per event.` })),
162
161
  }, { additionalProperties: false });
163
162
 
164
- export const historyList: Operation<typeof historyListParameters, HistoryPage, [HistoryProjection]> = {
163
+ export const historyList: Operation<typeof historyListParameters, HistoryPage, [HistoryProjection, HistoryTextWrapper?]> = {
165
164
  name: "history_list",
166
165
  label: "History list items",
167
166
  description: "Browse or search this session's events, a page at a time. Read one in full with `history_read`.",
168
167
  parameters: historyListParameters,
169
168
  outputSchema: resultSchema(HistoryPageSchema),
170
- async execute(params, projection) {
169
+ async execute(params, projection, wrapText = plainText) {
171
170
  const resolved = resolveWindowId(projection, params.window_id);
172
171
  if (!resolved.ok) return resolved.outcome;
173
172
  const scoped = { ...params, window_id: resolved.window_id };
174
173
  const badWindow = badWindowId(projection, scoped);
175
174
  if (badWindow) return badWindow;
176
- return selectPage(projection, scoped, pageFits, scoped.max_chars_per_item ?? HISTORY_PREVIEW_CHARS);
175
+ // Charge wrapped rendering and cursors, not only event previews.
176
+ const fits = (page: HistoryPage) => fitsResult(success(page), (result) => wrapText(renderOutcome(result, renderPage)));
177
+ return selectPage(projection, scoped, fits, scoped.max_chars_per_item ?? HISTORY_PREVIEW_CHARS);
177
178
  },
178
179
  render: (result) => renderOutcome(result, renderPage),
179
180
  };
@@ -182,13 +183,13 @@ export const historyList: Operation<typeof historyListParameters, HistoryPage, [
182
183
 
183
184
  export const historyReadParameters = Type.Object({ seq: Type.Integer({ minimum: 1, description: "Event seq, from `history_list`." }), ...TextWindowRequestSchema }, { additionalProperties: false });
184
185
 
185
- export const historyRead: Operation<typeof historyReadParameters, HistoryReadData, [HistoryProjection]> = {
186
+ export const historyRead: Operation<typeof historyReadParameters, HistoryReadData, [HistoryProjection, HistoryTextWrapper?]> = {
186
187
  name: "history_read",
187
188
  label: "History read item",
188
189
  description: "Read one event in full: tool arguments, output, and nested calls.",
189
190
  parameters: historyReadParameters,
190
191
  outputSchema: resultSchema(HistoryReadDataSchema),
191
- async execute(params, projection) {
192
+ async execute(params, projection, wrapText = plainText) {
192
193
  const item = allItems(projection).find((event) => event.seq === params.seq);
193
194
  // Address checks run in one order: past the end of the file, off this branch, then
194
195
  // consumed by a pairing. Only the last two can mention what is at the address.
@@ -223,7 +224,7 @@ export const historyRead: Operation<typeof historyReadParameters, HistoryReadDat
223
224
  ...nestedCallSummary(item),
224
225
  ...window,
225
226
  }),
226
- (result) => renderOutcome(result, renderRead),
227
+ (result) => wrapText(renderOutcome(result, renderRead)),
227
228
  );
228
229
  },
229
230
  render: (result) => renderOutcome(result, renderRead),
@@ -42,6 +42,7 @@ export const NoteMetadataSchema = Type.Object({
42
42
  origin: Type.Union([...ORIGIN_VALUES]),
43
43
  created_at: Type.String(),
44
44
  updated_at: Type.String(),
45
+ last_accessed: Type.String(),
45
46
  crumpled_at: Type.Optional(Type.String()),
46
47
  project: Type.Optional(Type.String()),
47
48
  extra: Type.Record(Type.String(), Type.Unknown()),
@@ -73,6 +74,7 @@ function noteMetadata(meta: NoteMeta): NoteMetadata {
73
74
  origin: meta.origin,
74
75
  created_at: localIso(meta.createdAt),
75
76
  updated_at: localIso(meta.updatedAt),
77
+ last_accessed: localIso(meta.lastAccessed),
76
78
  ...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
77
79
  ...(typeof meta.project === "string" ? { project: meta.project } : {}),
78
80
  extra,
@@ -84,6 +86,7 @@ function renderMetadata(metadata: NoteMetadata): string {
84
86
  `origin ${metadata.origin}`,
85
87
  `created ${metadata.created_at}`,
86
88
  `updated ${metadata.updated_at}`,
89
+ `accessed ${metadata.last_accessed}`,
87
90
  ...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
88
91
  ...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
89
92
  ];
@@ -110,6 +113,7 @@ const ListedFileSchema = Type.Object({
110
113
  project_key: Type.Optional(Type.String()),
111
114
  ...ProjectReceiptSchema,
112
115
  updated_at: Type.String(),
116
+ last_accessed: Type.String(),
113
117
  crumpled_at: Type.Optional(Type.String()),
114
118
  }, { additionalProperties: false });
115
119
 
@@ -197,7 +201,7 @@ export function snapshot<T extends { address: string }>(
197
201
  }
198
202
 
199
203
  export function listedFile(row: Pick<NoteRow, "address" | "meta">, identity: NotesIdentity): NotesListData["files"][number] {
200
- return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
204
+ return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), last_accessed: localIso(row.meta.lastAccessed), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
201
205
  }
202
206
 
203
207
  export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN }, { additionalProperties: false });
@@ -291,7 +295,8 @@ export const notesRead = {
291
295
  if (!note) return failure("not_found", `No note at ${resolved.address}.`);
292
296
  const totalChars = Array.from(note.body).length;
293
297
  if (params.offset_chars !== undefined && params.offset_chars > totalChars) return failure("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
294
- const metadata = noteMetadata(note.meta);
298
+ // Report the access before this one: the read itself must not make a long-unread note look fresh.
299
+ const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
295
300
  return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
296
301
  } catch (error) { return failureOf(error); }
297
302
  },
@@ -303,7 +308,7 @@ export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FI
303
308
  export function renderListData(data: NotesListData): string {
304
309
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
305
310
  for (const file of data.files) {
306
- lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
311
+ lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
307
312
  }
308
313
  if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
309
314
  for (const home of data.homes_unavailable) lines.push(`${home} could not be read`);