notesoup 0.55.2 → 0.56.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/plugins/pi/budget.d.ts +4 -0
  2. package/dist/plugins/pi/budget.js +6 -1
  3. package/dist/plugins/pi/marker.d.ts +4 -2
  4. package/dist/plugins/pi/marker.js +18 -8
  5. package/dist/plugins/pi/reset/lifecycle.js +6 -0
  6. package/dist/src/history/query.d.ts +0 -2
  7. package/dist/src/history/query.js +2 -4
  8. package/dist/src/notes/store.d.ts +0 -2
  9. package/dist/src/notes/store.js +2 -2
  10. package/dist/src/tools/dream.d.ts +6 -6
  11. package/dist/src/tools/dream.js +8 -3
  12. package/dist/src/tools/notes.d.ts +18 -8
  13. package/dist/src/tools/notes.js +6 -11
  14. package/dist/test/agent-loop.test.js +44 -1
  15. package/dist/test/budget-settings.integration.test.js +18 -0
  16. package/dist/test/dream-tools.test.js +26 -7
  17. package/dist/test/marker.test.js +46 -15
  18. package/dist/test/notes-library.test.js +1 -1
  19. package/dist/test/notes.test.js +5 -4
  20. package/dist/test/pi-render.test.js +2 -2
  21. package/docs/architecture.md +1 -1
  22. package/docs/tool-results.md +2 -2
  23. package/package.json +1 -1
  24. package/playbook.md +1 -1
  25. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  26. package/plugins/claude/dist/claude/helper.js +8 -12
  27. package/plugins/claude/playbook.md +1 -1
  28. package/plugins/codex/dist/codex/notesoup.js +8 -12
  29. package/plugins/paseo/OVERVIEW.md +1 -1
  30. package/plugins/paseo/client/brain-empty-card.tsx +28 -9
  31. package/plugins/paseo/client/brain-empty-transformer.ts +5 -1
  32. package/plugins/paseo/client/markdown.tsx +14 -13
  33. package/plugins/paseo/client/notes-op-card.tsx +6 -6
  34. package/plugins/paseo/client/paper-card.tsx +20 -18
  35. package/plugins/paseo/client/paper-palette.ts +12 -9
  36. package/plugins/paseo/shared/brain-empty.ts +1 -0
  37. package/plugins/paseo/test/brain-empty.test.ts +8 -0
  38. package/plugins/pi/budget.ts +7 -1
  39. package/plugins/pi/marker.ts +18 -12
  40. package/plugins/pi/reset/lifecycle.ts +5 -0
  41. package/src/history/query.ts +2 -4
  42. package/src/notes/store.ts +3 -4
  43. package/src/tools/dream.ts +8 -3
  44. package/src/tools/notes.ts +7 -12
@@ -4,12 +4,12 @@ import type { PaperPalette } from "./paper-palette.ts";
4
4
 
5
5
  export const MONO = Platform.select({ ios: "Menlo", android: "monospace", default: "ui-monospace, Menlo, monospace" });
6
6
 
7
- function Crease({ paper }: { paper: PaperPalette }) {
7
+ function Tape({ paper }: { paper: PaperPalette }) {
8
8
  return (
9
9
  <View style={{
10
- position: "absolute", top: 0, right: 0, width: 14, height: 14,
11
- backgroundColor: paper.crease, borderBottomLeftRadius: 3,
12
- borderLeftWidth: StyleSheet.hairlineWidth, borderBottomWidth: StyleSheet.hairlineWidth, borderColor: paper.edge,
10
+ alignSelf: "flex-start", width: 76, height: 15, marginLeft: 28, marginBottom: -9, zIndex: 1,
11
+ backgroundColor: paper.tape, borderLeftWidth: 1, borderRightWidth: 1, borderColor: paper.tapeEdge,
12
+ transform: [{ rotate: "-2deg" }],
13
13
  }} />
14
14
  );
15
15
  }
@@ -21,20 +21,22 @@ export function PaperCard({ paper, compact, crumpled = false, children }: {
21
21
  children: ReactNode;
22
22
  }) {
23
23
  return (
24
- <View style={{
25
- paddingVertical: compact ? 8 : 9,
26
- paddingHorizontal: 12,
27
- gap: 6,
28
- minWidth: 0,
29
- borderRadius: 4,
30
- borderWidth: StyleSheet.hairlineWidth,
31
- borderColor: paper.edge,
32
- backgroundColor: crumpled ? paper.crumpled : paper.background,
33
- position: "relative",
34
- overflow: "hidden",
35
- }}>
36
- <Crease paper={paper} />
37
- {children}
24
+ <View style={{ paddingTop: 7 }}>
25
+ <Tape paper={paper} />
26
+ <View style={{
27
+ paddingVertical: compact ? 8 : 9,
28
+ paddingHorizontal: 12,
29
+ gap: 6,
30
+ minWidth: 0,
31
+ borderRadius: 4,
32
+ borderWidth: StyleSheet.hairlineWidth,
33
+ borderColor: paper.edge,
34
+ backgroundColor: crumpled ? paper.crumpled : paper.background,
35
+ position: "relative",
36
+ overflow: "hidden",
37
+ }}>
38
+ {children}
39
+ </View>
38
40
  </View>
39
41
  );
40
42
  }
@@ -3,25 +3,28 @@ import type { PluginTheme } from "@getpaseo/plugin";
3
3
  const LIGHT_PAPER = {
4
4
  background: "#faf7f0",
5
5
  edge: "#e2d9c8",
6
- crease: "#ede5d5",
7
6
  ink: "#26221b",
8
7
  inkMuted: "#827866",
9
8
  added: "#2b6e3c",
10
9
  removed: "#ad3e34",
11
10
  crumpled: "#efeae0",
11
+ tape: "rgba(224, 206, 148, 0.62)",
12
+ tapeEdge: "rgba(165, 145, 86, 0.16)",
12
13
  };
13
14
 
14
15
  export type PaperPalette = typeof LIGHT_PAPER;
15
16
 
16
17
  const DARK_PAPER: PaperPalette = {
17
- background: "#201d18",
18
- edge: "#383228",
19
- crease: "#2d2820",
20
- ink: "#ede6da",
21
- inkMuted: "#968c7a",
22
- added: "#84c294",
23
- removed: "#de877e",
24
- crumpled: "#171511",
18
+ // Manila tape, not orange-brown: hue held near 50°, never the 30–40° brown that reads red.
19
+ background: "#26231d",
20
+ edge: "#463f31",
21
+ ink: "#ece5d5",
22
+ inkMuted: "#a89e86",
23
+ added: "#8cbf98",
24
+ removed: "#dc8f80",
25
+ crumpled: "#1e1b16",
26
+ tape: "rgba(182, 160, 104, 0.38)",
27
+ tapeEdge: "rgba(218, 195, 134, 0.16)",
25
28
  };
26
29
 
27
30
  /** Paseo theme colors are hex (#RGB, #RRGGBB or #RRGGBBAA). */
@@ -7,6 +7,7 @@ export const brainEmptySchema = z.object({
7
7
  status: z.enum(["running", "completed", "failed"]),
8
8
  // completed: rollover_requested | rollover_already_pending
9
9
  outcome: z.string().optional(),
10
+ lastWord: z.string().optional(),
10
11
  error: z.string().optional(),
11
12
  });
12
13
  export type BrainEmpty = z.infer<typeof brainEmptySchema>;
@@ -24,6 +24,14 @@ test("a successful call is a completed divider with the rollover outcome", () =>
24
24
  assert.deepEqual(brainEmptySchema.parse(result!.items[0]!.data), { status: "completed", outcome: "rollover_requested" });
25
25
  });
26
26
 
27
+ test("a successful call carries its last word for the divider modal", () => {
28
+ const detail = jsonOut({ status: "rollover_requested" });
29
+ const result = transform({ detail: { ...detail, input: { last_word: " remember the shoe " } } });
30
+ assert.deepEqual(brainEmptySchema.parse(result!.items[0]!.data), {
31
+ status: "completed", outcome: "rollover_requested", lastWord: "remember the shoe",
32
+ });
33
+ });
34
+
27
35
  test("an in-flight call shows as running from the call alone", () => {
28
36
  const result = transform({ status: "running", detail: { type: "unknown", input: { last_word: "bye" }, output: null } });
29
37
  assert.deepEqual(brainEmptySchema.parse(result!.items[0]!.data), { status: "running" });
@@ -10,6 +10,10 @@ import { tokenBudgetGuidance } from "../../src/budget/text.js";
10
10
  import { arrangeAnchoredReminders, type AnchorDetails } from "./anchored.js";
11
11
  import { output } from "./tool-result.js";
12
12
 
13
+ export const ContextRemainingOutputSchema = Type.Object({
14
+ remaining_tokens: Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]),
15
+ }, { additionalProperties: false });
16
+
13
17
  /** Remaining tokens in the provider's active window, or null without a usable estimate. */
14
18
  function remainingTokens(ctx: Pick<ExtensionContext, "sessionManager" | "getContextUsage" | "model">): number | null {
15
19
  const usage = windowUsage(ctx);
@@ -122,10 +126,12 @@ export function registerBudget(
122
126
  label: "Get context remaining",
123
127
  description: "Check how much room your brain has left before it gets forcibly emptied. Returns null when unknown.",
124
128
  parameters: Type.Object({}, { additionalProperties: false }),
129
+ outputSchema: ContextRemainingOutputSchema,
125
130
  async execute(_id, _params, _signal, _update, ctx) {
126
131
  // Report room to the hard-reserve wipe, including the warning runway.
127
132
  const remaining = remainingTokens(ctx);
128
- return output({ remaining_tokens: remainingBudget(remaining, thresholdsFor(ctx as ExtensionContext).reserve) });
133
+ const value = { remaining_tokens: remainingBudget(remaining, thresholdsFor(ctx as ExtensionContext).reserve) };
134
+ return { ...output(value), structuredContent: value };
129
135
  },
130
136
  }));
131
137
 
@@ -1,19 +1,19 @@
1
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
1
+ import type { CustomMessageEntryDraft, ExtensionAPI, ExtensionContext, SessionBoundaryDraft } from "@earendil-works/pi-coding-agent";
2
2
  import { piSequenceCount } from "../../src/history/pi.js";
3
- import { BOOT_TYPE, MARKER_TYPE } from "./entries.js";
3
+ import { BOOT_TYPE, MARKER_TYPE, RESET_MARKER_TYPE } from "./entries.js";
4
4
  import { nextHistorySeq } from "./history.js";
5
5
  import { inspectResetTail } from "./reset/artifacts.js";
6
6
  import { markerContent } from "./text.js";
7
7
  import { currentReset } from "./window.js";
8
8
 
9
9
  /** Spacing between durable seq breadcrumbs, in projected history seq. */
10
- export const MARKER_INTERVAL = 120;
10
+ export const MARKER_INTERVAL = 100;
11
11
 
12
12
  /** Highest seq already anchored by a window boot or marker; 0 before the first. */
13
- function lastMarkerSeq(ctx: ExtensionContext): number {
13
+ function lastMarkerSeq(ctx: ExtensionContext, pending: readonly SessionBoundaryDraft[]): number {
14
14
  let last = 0;
15
15
  let nextSeq = 1;
16
- for (const entry of ctx.sessionManager.getEntries()) {
16
+ for (const entry of [...ctx.sessionManager.getEntries(), ...pending]) {
17
17
  const count = piSequenceCount(entry);
18
18
  if (count === 0) continue;
19
19
  if (entry.type === "custom_message" && (entry.customType === MARKER_TYPE || entry.customType === BOOT_TYPE)) {
@@ -29,16 +29,22 @@ function lastMarkerSeq(ctx: ExtensionContext): number {
29
29
  * model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
30
30
  * tail still awaits boot or continuation: a foreign message there would close the repair shape.
31
31
  */
32
- export function maybeSendMarker(pi: ExtensionAPI, ctx: ExtensionContext): void {
32
+ export function buildMarkerDraft(ctx: ExtensionContext, pending: readonly SessionBoundaryDraft[] = []): CustomMessageEntryDraft | undefined {
33
+ if (pending.some((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE)) return;
33
34
  const reset = currentReset(ctx);
34
35
  if (reset) {
35
36
  const tail = inspectResetTail(ctx, reset.id, reset.data.windowId);
36
37
  if (tail && (!tail.boot || !tail.continuation)) return;
37
38
  }
38
- const seq = nextHistorySeq(ctx);
39
- if (seq - lastMarkerSeq(ctx) < MARKER_INTERVAL) return;
40
- pi.sendMessage(
41
- { customType: MARKER_TYPE, content: markerContent(seq), display: false, details: { seq } },
42
- { triggerTurn: false },
43
- );
39
+ const seq = nextHistorySeq(ctx, pending);
40
+ if (seq - lastMarkerSeq(ctx, pending) < MARKER_INTERVAL) return;
41
+ return { type: "custom_message", customType: MARKER_TYPE, content: markerContent(seq), display: false, details: { seq } };
42
+ }
43
+
44
+ /** Run-start fallback; active runs append the same draft through the turn-end boundary. */
45
+ export function maybeSendMarker(pi: ExtensionAPI, ctx: ExtensionContext): void {
46
+ const draft = buildMarkerDraft(ctx);
47
+ if (!draft) return;
48
+ const { type: _type, ...message } = draft;
49
+ pi.sendMessage(message, { triggerTurn: false });
44
50
  }
@@ -4,6 +4,7 @@ import { getCurrentSystemMessage, isContextOverflow, isRecoverableLength } from
4
4
  import type { AgentBeforeSettleEvent, ExtensionAPI, ExtensionContext, SessionBoundaryDraft } from "@earendil-works/pi-coding-agent";
5
5
  import { currentReset, currentWindowId } from "../window.js";
6
6
  import { nextHistorySeq } from "../history.js";
7
+ import { buildMarkerDraft } from "../marker.js";
7
8
  import { resetBoundaryCommitted } from "./committed.js";
8
9
  import type { ResetOrigin } from "../../../src/budget/text.js";
9
10
  import { errorMessage } from "../../../src/error-message.js";
@@ -335,6 +336,10 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
335
336
  if (decision.effect === "build-boundary") return await resetBoundaryResult(entries, ctx, decision);
336
337
  if (aborted || (event.outcome === "error" && decision.state.request.phase === "none")) restoreCommandInputs();
337
338
  control = decision.state;
339
+ if (!aborted && event.outcome !== "error" && options.isEnabled()) {
340
+ const marker = buildMarkerDraft(ctx, entries);
341
+ if (marker) entries.push(marker);
342
+ }
338
343
  return entries.length > 0 ? { entries } : undefined;
339
344
  });
340
345
 
@@ -50,12 +50,10 @@ function resolveTimeBounds(params: HistorySelection): Outcome<{ sinceMs?: number
50
50
  return success({ ...(since.data === undefined ? {} : { sinceMs: since.data }), ...(until.data === undefined ? {} : { untilMs: until.data }) });
51
51
  }
52
52
 
53
- /** The params to merge into the previous call to continue toward older events. */
54
53
  export const HistoryOlderSchema = Type.Object({
55
54
  session: Type.Optional(Type.String()),
56
55
  before_seq: Type.Integer({ minimum: 1 }),
57
56
  }, { additionalProperties: false });
58
- /** The params to merge into the previous call to continue toward newer events. */
59
57
  export const HistoryNewerSchema = Type.Object({
60
58
  session: Type.Optional(Type.String()),
61
59
  after_seq: Type.Integer({ minimum: 1 }),
@@ -65,8 +63,8 @@ export const HistoryNewerSchema = Type.Object({
65
63
  export const HistoryPageSchema = Type.Object({
66
64
  notice: Type.Optional(Type.String()),
67
65
  items: Type.Array(Type.Union([HistoryPageItemSchema, HistoryFoldedRowSchema])),
68
- page_older: Type.Union([HistoryOlderSchema, Type.Null()]),
69
- page_newer: Type.Union([HistoryNewerSchema, Type.Null()]),
66
+ page_older: Type.Union([HistoryOlderSchema, Type.Null()], { description: "Args to merge into `history_list` for older events." }),
67
+ page_newer: Type.Union([HistoryNewerSchema, Type.Null()], { description: "Args to merge into `history_list` for newer events." }),
70
68
  }, { additionalProperties: false });
71
69
 
72
70
  /** One whole page payload, before it becomes an outcome. */
@@ -33,8 +33,7 @@ export type EditOptions = { origin?: Origin; crumpled?: boolean; replaceAll?: bo
33
33
  */
34
34
  export type NotesQuery = { glob?: string | null; crumpled?: boolean };
35
35
  /** A read exposes metadata and the pure body; the serialized frontmatter is never part of the body. */
36
- /** `accessedBefore` is the last access before this read, so a read never hides how long a note sat unread. */
37
- export type NoteReadResult = { meta: NoteMeta; body: string; resolvedScope: Scope; accessedBefore: number };
36
+ export type NoteReadResult = { meta: NoteMeta; body: string; resolvedScope: Scope };
38
37
  export type NoteWriteResult = { meta: NoteMeta; outcome: "created" | "overwrote" | "uncrumpled" };
39
38
  export type NoteChange =
40
39
  | { kind: "none"; before: ""; after: "" }
@@ -332,11 +331,11 @@ export function createNotesStore(input: NotesIdentity): NotesStore {
332
331
  const now = Date.now();
333
332
  const parsed = parseNote(raw, now);
334
333
  // Named notebooks, and every read during a dream, leave no access stamp.
335
- if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined)) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
334
+ if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined)) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
336
335
  // A read records its own access, exactly as a write records an edit.
337
336
  const meta: NoteMeta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
338
337
  await atomicWrite(path, serializeNote(meta, parsed.body));
339
- return { meta, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
338
+ return { meta, body: parsed.body, resolvedScope: scope };
340
339
  });
341
340
  }
342
341
 
@@ -1,11 +1,12 @@
1
1
  /** Dream operations: open one project's notes for consolidation, delete crumpled notes, close. */
2
2
  import { Type, type Static } from "typebox";
3
+ import { localIso } from "../notes/frontmatter.js";
3
4
  import { createNotesStore, noteIdentity, type NoteRow, type NotesIdentity } from "../notes/index.js";
4
5
  import { projectNamespaces } from "../notes/project-namespace.js";
5
6
  import { gitCommit } from "../dream/git.js";
6
7
  import { acquireDreamLock, dreamLockPath, releaseDreamLock, type DreamLock } from "../dream/lock.js";
7
8
  import { failure, renderOutcome, resultSchema, success, type Outcome } from "./result.js";
8
- import { failureOf, listedFile, NoteIdentitySchema, NotesListDataSchema, renderListData, snapshot } from "./notes.js";
9
+ import { failureOf, listedFile, ListedFileSchema, NoteIdentitySchema, renderListData, snapshot, SnapshotSchema } from "./notes.js";
9
10
 
10
11
  /** The one open dream per session; the host owns where it lives. */
11
12
  type DreamOpening = { project: string; lock: DreamLock; generation: number };
@@ -54,7 +55,11 @@ export const dreamBeginParameters = Type.Object({
54
55
  project: Type.Optional(Type.String({ description: "(optional, default this project) Project name, as in @projects/<name>/." })),
55
56
  }, { additionalProperties: false });
56
57
 
57
- export const DreamBeginDataSchema = Type.Object({ project: Type.String(), baseline: Type.String(), ...NotesListDataSchema.properties }, { additionalProperties: false });
58
+ export const DreamBeginDataSchema = Type.Object({
59
+ project: Type.String(), baseline: Type.String(),
60
+ files: Type.Array(Type.Object({ ...ListedFileSchema.properties, last_accessed: Type.String() }, { additionalProperties: false })),
61
+ ...SnapshotSchema,
62
+ }, { additionalProperties: false });
58
63
  export type DreamBeginData = Static<typeof DreamBeginDataSchema>;
59
64
 
60
65
  function renderBeginData(data: DreamBeginData): string {
@@ -92,7 +97,7 @@ export const dreamBegin = {
92
97
  }
93
98
  }
94
99
  rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address));
95
- const listed = snapshot(rows.map(row => listedFile(row, identity)), undefined, { namespacesUnavailable: unavailable }, renderListData);
100
+ const listed = snapshot(rows.map(row => ({ ...listedFile(row, identity), last_accessed: localIso(row.meta.lastAccessed) })), undefined, { namespacesUnavailable: unavailable }, renderListData);
96
101
  if (!listed.ok) {
97
102
  releaseOpening(state, opening);
98
103
  return listed;
@@ -44,7 +44,6 @@ export const NoteMetadataSchema = Type.Object({
44
44
  origin: Type.Union([...ORIGIN_VALUES]),
45
45
  created_at: Type.String(),
46
46
  updated_at: Type.String(),
47
- last_accessed: Type.String(),
48
47
  crumpled_at: Type.Optional(Type.String()),
49
48
  project: Type.Optional(Type.String()),
50
49
  extra: Type.Record(Type.String(), Type.Unknown()),
@@ -76,7 +75,6 @@ function noteMetadata(meta: NoteMeta): NoteMetadata {
76
75
  origin: meta.origin,
77
76
  created_at: localIso(meta.createdAt),
78
77
  updated_at: localIso(meta.updatedAt),
79
- last_accessed: localIso(meta.lastAccessed),
80
78
  ...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
81
79
  ...(typeof meta.project === "string" ? { project: meta.project } : {}),
82
80
  extra,
@@ -88,7 +86,6 @@ function renderMetadata(metadata: NoteMetadata): string {
88
86
  `origin ${metadata.origin}`,
89
87
  `created ${metadata.created_at}`,
90
88
  `updated ${metadata.updated_at}`,
91
- `accessed ${metadata.last_accessed}`,
92
89
  ...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
93
90
  ...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
94
91
  ];
@@ -118,10 +115,9 @@ export const NoteIdentitySchema = {
118
115
  ...ProjectReceiptSchema,
119
116
  };
120
117
 
121
- const ListedFileSchema = Type.Object({
118
+ export const ListedFileSchema = Type.Object({
122
119
  ...NoteIdentitySchema,
123
120
  updated_at: Type.String(),
124
- last_accessed: Type.String(),
125
121
  crumpled_at: Type.Optional(Type.String()),
126
122
  }, { additionalProperties: false });
127
123
 
@@ -136,9 +132,9 @@ const SearchedFileSchema = Type.Object({
136
132
  matches: Type.Array(MatchSchema),
137
133
  }, { additionalProperties: false });
138
134
 
139
- const SnapshotSchema = {
135
+ export const SnapshotSchema = {
140
136
  more: Type.Integer({ description: "How many more were left out." }),
141
- namespaces_unavailable: Type.Array(Type.String()),
137
+ namespaces_unavailable: Type.Array(Type.String(), { description: "Unreadable notebooks or notes." }),
142
138
  };
143
139
 
144
140
  export const NotesWriteDataSchema = Type.Object({
@@ -204,7 +200,7 @@ export function snapshot<T extends { address: string }>(
204
200
  }
205
201
 
206
202
  export function listedFile(row: Pick<NoteRow, "address" | "meta">, identity: NotesIdentity): NotesListData["files"][number] {
207
- 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 }) };
203
+ return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
208
204
  }
209
205
 
210
206
  export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN, cwd: CWD_PARAMETER }, { additionalProperties: false });
@@ -281,8 +277,7 @@ export const notesRead = {
281
277
  if (!note) return failure("not_found", `No note at ${resolved.address}.`);
282
278
  const totalChars = Array.from(note.body).length;
283
279
  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.`);
284
- // Report the access before this one: the read itself must not make a long-unread note look fresh.
285
- const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
280
+ const metadata = noteMetadata(note.meta);
286
281
  return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
287
282
  } catch (error) { return failureOf(error); }
288
283
  },
@@ -291,10 +286,10 @@ export const notesRead = {
291
286
 
292
287
  export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, crumpled: CRUMPLED_LIST_PARAMETER, cwd: CWD_PARAMETER }, { additionalProperties: false });
293
288
 
294
- export function renderListData(data: NotesListData): string {
289
+ export function renderListData(data: Snapshot<NotesListData["files"][number] & { last_accessed?: string }>): string {
295
290
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
296
291
  for (const file of data.files) {
297
- lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
292
+ lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.last_accessed === undefined ? "" : ` | accessed ${file.last_accessed}`}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
298
293
  }
299
294
  if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
300
295
  for (const namespace of data.namespaces_unavailable) lines.push(`${namespace} could not be read`);