notesoup 0.60.1 → 0.61.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 (40) hide show
  1. package/README.md +5 -4
  2. package/dist/src/boot/render.d.ts +5 -0
  3. package/dist/src/boot/render.js +48 -19
  4. package/dist/src/boot/text.d.ts +1 -3
  5. package/dist/src/boot/text.js +10 -11
  6. package/dist/src/budget/text.d.ts +1 -1
  7. package/dist/src/budget/text.js +1 -1
  8. package/dist/src/notes/errors.d.ts +1 -1
  9. package/dist/src/notes/frontmatter.d.ts +6 -0
  10. package/dist/src/notes/frontmatter.js +17 -1
  11. package/dist/src/notes/policy.js +1 -1
  12. package/dist/src/notes/store.d.ts +2 -0
  13. package/dist/src/notes/store.js +30 -5
  14. package/dist/src/tools/dream.d.ts +2 -0
  15. package/dist/src/tools/notes.d.ts +10 -0
  16. package/dist/src/tools/notes.js +14 -8
  17. package/dist/test/host-neutral.test.js +1 -1
  18. package/dist/test/note-policy.test.js +122 -8
  19. package/docs/dsh.md +2 -2
  20. package/docs/notes-library.md +4 -4
  21. package/docs/reset-lifecycle.md +1 -1
  22. package/docs/tool-results.md +1 -1
  23. package/package.json +1 -1
  24. package/playbook.md +3 -3
  25. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  26. package/plugins/claude/dist/claude/helper.js +100 -45
  27. package/plugins/claude/playbook.md +3 -3
  28. package/plugins/claude/skills/dream/SKILL.md +2 -2
  29. package/plugins/claude/skills/memory/SKILL.md +1 -1
  30. package/plugins/codex/dist/codex/notesoup.js +99 -44
  31. package/skills/dream/SKILL.md +2 -2
  32. package/skills/memory/SKILL.md +1 -1
  33. package/src/boot/render.ts +48 -17
  34. package/src/boot/text.ts +10 -11
  35. package/src/budget/text.ts +1 -1
  36. package/src/notes/errors.ts +1 -1
  37. package/src/notes/frontmatter.ts +19 -1
  38. package/src/notes/policy.ts +1 -1
  39. package/src/notes/store.ts +25 -7
  40. package/src/tools/notes.ts +14 -8
package/README.md CHANGED
@@ -40,14 +40,15 @@ pi -e npm:notesoup
40
40
 
41
41
  ## Per-note policy
42
42
 
43
- Notes have optional `pinned`, `budget`, and `readonly` frontmatter fields, also settable through `notes_write` and `notes_update`:
43
+ Notes have optional `pinned`, `budget`, `readonly`, and `description` frontmatter fields, also settable through `notes_write` and `notes_update`:
44
44
 
45
45
  ```json
46
- { "address": "@project/decisions.md", "pinned": true, "budget": 3000, "readonly": false }
46
+ { "address": "@project/decisions.md", "pinned": true, "budget": 3000, "readonly": false, "description": "Architecture choices and why they stand." }
47
47
  ```
48
48
 
49
- - **Pinned** notes are injected **in full** at boot. Root `CHEATSHEET.md` and `MAP.md` default to pinned; every other page defaults to unpinned. Explicit `pinned: false` overrides even a default page. Each notebook allows **five live pins**, including its existing default pages; crumpled notes do not count. A sixth pin, restore or move that exceeds the cap refuses without changing either note. Manually over-cap notebooks get a boot warning naming the omitted pins, with default pages shown first.
50
- - **Budget** defaults to **4096 Unicode code points for ordinary pages**, and **2048 for root CHEATSHEET.md and MAP.md**. Any positive safe integer is allowed. Over-budget writes and updates succeed with a visible warning; pinned bodies are never truncated to their budget. This advisory budget is separate from the existing hard serialized-file byte limit. Tool results/read metadata/list/search expose effective policy and budget warnings.
49
+ - **Pinned** notes are injected **in full** at boot. Root `CHEATSHEET.md` defaults to pinned; every other page defaults to unpinned. Explicit `pinned: false` overrides even a default page. Each notebook allows **five live pins**, including its default `CHEATSHEET.md`; crumpled notes do not count. A sixth pin, restore or move that exceeds the cap refuses without changing either note. Manually over-cap notebooks get a boot warning naming the omitted pins, with default pages shown first. Unpinned live notes appear in a bounded auto-generated per-shelf index at boot (sorted by recency, up to 25 entries / 4096 chars per shelf).
50
+ - **Budget** defaults to **4096 Unicode code points for ordinary pages**, and **2048 for root `CHEATSHEET.md`**. Any positive safe integer is allowed. Over-budget writes and updates succeed with a visible warning; pinned bodies are never truncated to their budget. This advisory budget is separate from the existing hard serialized-file byte limit. Tool results/read metadata/list/search expose effective policy and budget warnings.
51
+ - **Description** is an optional single-line summary (up to **160 Unicode code points**; whitespace is collapsed and an empty string clears it). It is rendered in the boot shelf index (falling back to the first heading/line when absent) as well as `notes_read` metadata and `notes_list` rows.
51
52
  - **Readonly** defaults to false. `readonly: true` is a **soft lock**, not security: mutations refuse until explicitly unlocked with `readonly: false`, either by itself or in the same call as the requested changes. A write can create and lock a note together. Reads still record access metadata; direct filesystem edits can bypass the lock.
52
53
 
53
54
  Absent fields stay absent on disk. On move/rename, implicit pin defaults follow the new root path; explicit true/false values travel with the note. The original origin, other metadata, and unknown frontmatter are preserved. See the [library API](docs/notes-library.md#per-note-policy) for details.
@@ -1,5 +1,10 @@
1
1
  import type { NotesSnapshot } from "./snapshot.js";
2
2
  import { type BootToolNames } from "./text.js";
3
+ /** The shelf index is bounded: enough to find a page, never the whole drawer. */
4
+ export declare const SHELF_INDEX_MAX_ENTRIES = 25;
5
+ export declare const SHELF_INDEX_MAX_CHARS = 4096;
6
+ /** A fallback title is the note's own first heading or line, cut short. */
7
+ export declare const FALLBACK_TITLE_MAX_CHARS = 80;
3
8
  export type BootWindowTree = {
4
9
  readonly trunk: string;
5
10
  readonly windows: ReadonlyArray<{
@@ -1,5 +1,6 @@
1
1
  import { effectiveNotePolicy, MAX_PINNED_NOTES, noteBudgetWarnings, pinnedPageOrder } from "../notes/policy.js";
2
- import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, NAMELESS_AGENT, SHELF_FRESH_LIMIT, renderProtocolBlock } from "./text.js";
2
+ import { collapseDescription, MAX_DESCRIPTION_CHARS } from "../notes/frontmatter.js";
3
+ import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, NAMELESS_AGENT, renderProtocolBlock } from "./text.js";
3
4
  function relativeTime(timestamp, now) {
4
5
  const seconds = Math.trunc((timestamp - now) / 1000);
5
6
  if (seconds === 0)
@@ -9,16 +10,34 @@ function relativeTime(timestamp, now) {
9
10
  const amount = `${Math.abs(Math.trunc(seconds / size))}${unit}`;
10
11
  return seconds > 0 ? `in ${amount}` : `${amount} ago`;
11
12
  }
12
- /** A feed entry is announced in the note's own words: its first heading, else its first line, cut short. */
13
- const FEED_TITLE_MAX_CHARS = 40;
13
+ /** The shelf index is bounded: enough to find a page, never the whole drawer. */
14
+ export const SHELF_INDEX_MAX_ENTRIES = 25;
15
+ export const SHELF_INDEX_MAX_CHARS = 4096;
16
+ /** A fallback title is the note's own first heading or line, cut short. */
17
+ export const FALLBACK_TITLE_MAX_CHARS = 80;
18
+ function truncated(text, max) {
19
+ const chars = Array.from(text);
20
+ return chars.length > max ? `${chars.slice(0, max).join("")}…` : chars.join("");
21
+ }
14
22
  function feedTitle(body) {
15
23
  const lines = body.split("\n");
16
24
  const heading = lines.find((line) => /^#+\s+\S/.test(line));
17
25
  const raw = (heading ? heading.replace(/^#+\s+/, "") : lines.find((line) => line.trim().length > 0) ?? "").trim();
18
- if (raw.length === 0)
19
- return undefined;
20
- const chars = Array.from(raw);
21
- return chars.length > FEED_TITLE_MAX_CHARS ? `${chars.slice(0, FEED_TITLE_MAX_CHARS).join("")}…` : chars.join("");
26
+ return raw.length === 0 ? undefined : truncated(raw, FALLBACK_TITLE_MAX_CHARS);
27
+ }
28
+ /** A stale hand-edited description is cut for display; the authored value was already refused at write time. */
29
+ function summaryOf(row) {
30
+ if (typeof row.meta.description === "string") {
31
+ const collapsed = collapseDescription(row.meta.description);
32
+ return collapsed === undefined ? undefined : truncated(collapsed, MAX_DESCRIPTION_CHARS);
33
+ }
34
+ return feedTitle(row.body);
35
+ }
36
+ /** One index entry: where the page sits, how fresh it is, and one line saying whether to open it. */
37
+ function indexLine(row, openedAt) {
38
+ const locator = `${row.address} · ${relativeTime(row.meta.updatedAt, openedAt)}`;
39
+ const summary = summaryOf(row);
40
+ return summary === undefined ? ` ${locator}` : ` ${locator} — ${summary}`;
22
41
  }
23
42
  /** Two spaces of indent say "shelved content" without any furniture. */
24
43
  function indent(text) {
@@ -28,7 +47,7 @@ function indent(text) {
28
47
  function section(label, body) {
29
48
  return `${label}\n${"─".repeat(Array.from(label).length)}\n\n${body}`;
30
49
  }
31
- /** One closed boot snapshot: five tabbed shelves, current hands first, durable last; each shelf keeps its pinned pages and its own freshest pages. */
50
+ /** One closed boot snapshot: five tabbed shelves, current hands first, durable last; each shelf keeps its pinned pages and an auto-indexed glimpse of the rest. */
32
51
  function notesIndex(snapshot, tools, agentName, modelName) {
33
52
  const namespaces = [
34
53
  { scope: "session", label: "no @ — this session" },
@@ -47,15 +66,25 @@ function notesIndex(snapshot, tools, agentName, modelName) {
47
66
  const pins = rows.filter(row => effectiveNotePolicy(row.meta, row.path).pinned)
48
67
  .sort((a, b) => pinnedPageOrder(a.path) - pinnedPageOrder(b.path) || a.path.localeCompare(b.path));
49
68
  const pinned = pins.slice(0, MAX_PINNED_NOTES);
50
- const fresh = rows
51
- .filter(row => !effectiveNotePolicy(row.meta, row.path).pinned)
52
- .slice(0, SHELF_FRESH_LIMIT)
53
- .map((row) => {
54
- const locator = `${row.address} · ${relativeTime(row.meta.updatedAt, snapshot.openedAt)}`;
55
- const title = feedTitle(row.body);
56
- return title === undefined ? ` ${locator}` : ` ${title}\n ${locator}`;
57
- });
58
- if (pinned.length === 0 && fresh.length === 0)
69
+ const unpinned = rows.filter(row => !effectiveNotePolicy(row.meta, row.path).pinned);
70
+ // Both caps count joined lines; the first entry is always admitted, so a huge shelf still
71
+ // shows its freshest page plus an honest count of what was left behind.
72
+ const index = [];
73
+ let usedChars = 0;
74
+ for (const row of unpinned) {
75
+ if (index.length >= SHELF_INDEX_MAX_ENTRIES)
76
+ break;
77
+ const line = indexLine(row, snapshot.openedAt);
78
+ const nextChars = usedChars + (index.length > 0 ? 1 : 0) + line.length;
79
+ if (index.length > 0 && nextChars > SHELF_INDEX_MAX_CHARS)
80
+ break;
81
+ index.push(line);
82
+ usedChars = nextChars;
83
+ }
84
+ const omitted = unpinned.length - index.length;
85
+ if (omitted > 0)
86
+ index.push(` … and ${omitted} more (use ${tools.notesList})`);
87
+ if (pinned.length === 0 && index.length === 0)
59
88
  continue;
60
89
  const parts = pinned.map(row => {
61
90
  const warnings = noteBudgetWarnings(row.body, effectiveNotePolicy(row.meta, row.path));
@@ -63,8 +92,8 @@ function notesIndex(snapshot, tools, agentName, modelName) {
63
92
  });
64
93
  if (pins.length > MAX_PINNED_NOTES)
65
94
  parts.push(indent(`Warning: only ${MAX_PINNED_NOTES} pinned notes per notebook are injected; omitted pins: ${pins.slice(MAX_PINNED_NOTES).map(row => row.address).join(", ")}. Unpin some notes or read the omitted pages with ${tools.notes}.`));
66
- if (fresh.length > 0)
67
- parts.push(`recent\n\n${fresh.join("\n\n")}`);
95
+ if (index.length > 0)
96
+ parts.push(pinned.length > 0 ? `notes\n\n${index.join("\n")}` : index.join("\n"));
68
97
  shelves.push(section(namespace.label, parts.join("\n\n")));
69
98
  }
70
99
  return shelves.length > 0
@@ -1,5 +1,3 @@
1
- /** Each shelf shows this many of its own freshest pages beneath its pinned pages. */
2
- export declare const SHELF_FRESH_LIMIT = 3;
3
1
  export declare const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
4
2
  export declare const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
5
3
  export declare const NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
@@ -15,7 +13,7 @@ export declare const PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, p
15
13
  /**
16
14
  * Default pinned pages and per-note policy are taught between the protocol and the notes index.
17
15
  */
18
- export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery notebook's root has two default pins: `CHEATSHEET.md` and `MAP.md`.\nPinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next\nreads them, and next is you. So keep them short, and keep them true.\n\nUp to five pages per notebook can be taped inside the cover, these two included. Every page gets\na paper budget; when a page outgrows it, boil it down \u2014 stale lines out, repeats merged, the rest\nsaid shorter \u2014 instead of giving it more paper.\n\n- **`CHEATSHEET.md`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,\n a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat\n and everybody pays for it.\n- **`MAP.md`** is only the note index. One line per durable note: the address, then a gist short\n enough to tell whether the thing is worth opening. Rules belong in `CHEATSHEET.md`, and note\n contents belong in their own notes \u2014 *taps the sign* not inline here.\n\nEach notebook keeps its own: `@project`, `@human`, `@self`, `@model`. Missing pages are skipped;\nno need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet\nline. And when a line goes wrong, stale, or useless, kill it \u2014 tomorrow's you reads that page as fact.\n</notesoup:maps>";
16
+ export declare const MAPS_BLOCK = "<notesoup:maps>\nEach notebook has one default pin: `CHEATSHEET.md`. Pinned pages get jammed straight into your\nbrain the moment you wake up. Whoever wakes up next reads them, and next is you. So keep them\nshort, and keep them true.\n\nUp to five pages per notebook can be taped inside the cover, CHEATSHEET included. Every page gets\na paper budget; when a page outgrows it, boil it down \u2014 stale lines out, repeats merged, the rest\nsaid shorter \u2014 instead of giving it more paper.\n\n- **`CHEATSHEET.md`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,\n a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat\n and everybody pays for it.\n- **`description`** is one line saying what's inside a note and when to open it \u2014 max 160\n characters, set through your notes tools. Boot indexes every shelf from these,\n newest first, address and age beside them. No hand-written map to keep in sync: a stale\n description lies to the next window, so keep it true or crumple the page.\n\nEach notebook keeps its own: `@project`, `@human`, `@self`, `@model`. Missing pages are skipped;\nno need to create empty ones. New rule worth remembering, new Cheatsheet line. And when a line\ngoes wrong, stale, or useless, kill it \u2014 tomorrow's you reads that page as fact.\n</notesoup:maps>";
19
17
  /** Logical tool names are supplied by the composing host, not discovered here. */
20
18
  export type BootToolNames = Readonly<{
21
19
  notes: string;
@@ -1,5 +1,3 @@
1
- /** Each shelf shows this many of its own freshest pages beneath its pinned pages. */
2
- export const SHELF_FRESH_LIMIT = 3;
3
1
  export const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
4
2
  export const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
5
3
  export const NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
@@ -56,24 +54,25 @@ ${NOTES_PROTOCOL_CLOSE_TAG}`;
56
54
  * Default pinned pages and per-note policy are taught between the protocol and the notes index.
57
55
  */
58
56
  export const MAPS_BLOCK = `<notesoup:maps>
59
- Every notebook's root has two default pins: \`CHEATSHEET.md\` and \`MAP.md\`.
60
- Pinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next
61
- reads them, and next is you. So keep them short, and keep them true.
57
+ Each notebook has one default pin: \`CHEATSHEET.md\`. Pinned pages get jammed straight into your
58
+ brain the moment you wake up. Whoever wakes up next reads them, and next is you. So keep them
59
+ short, and keep them true.
62
60
 
63
- Up to five pages per notebook can be taped inside the cover, these two included. Every page gets
61
+ Up to five pages per notebook can be taped inside the cover, CHEATSHEET included. Every page gets
64
62
  a paper budget; when a page outgrows it, boil it down — stale lines out, repeats merged, the rest
65
63
  said shorter — instead of giving it more paper.
66
64
 
67
65
  - **\`CHEATSHEET.md\`** holds what you'll want next time — a rule, a warning, a grudge, a name,
68
66
  a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
69
67
  and everybody pays for it.
70
- - **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
71
- enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
72
- contents belong in their own notes — *taps the sign* not inline here.
68
+ - **\`description\`** is one line saying what's inside a note and when to open it — max 160
69
+ characters, set through your notes tools. Boot indexes every shelf from these,
70
+ newest first, address and age beside them. No hand-written map to keep in sync: a stale
71
+ description lies to the next window, so keep it true or crumple the page.
73
72
 
74
73
  Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
75
- no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
76
- line. And when a line goes wrong, stale, or useless, kill it — tomorrow's you reads that page as fact.
74
+ no need to create empty ones. New rule worth remembering, new Cheatsheet line. And when a line
75
+ goes wrong, stale, or useless, kill it — tomorrow's you reads that page as fact.
77
76
  </notesoup:maps>`;
78
77
  export const DEFAULT_BOOT_TOOL_NAMES = {
79
78
  notes: "notes_*",
@@ -12,7 +12,7 @@ export declare function selectContinuation(origin: ResetOrigin): string;
12
12
  /** Budget timing stays out of manual close-outs, which may have plenty of room. */
13
13
  export declare const WARNING_TIMING = "The reserve is nearly spent. The wipe lands at the end of whichever turn spends the last of it, possibly this one.";
14
14
  /** The shared handoff instructions, used for both budget and manual close-outs. */
15
- export declare const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md and MAP.md by default); every new window loads the pins. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
15
+ export declare const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md by default) and keep each page's one-line `description` true; every new window loads the pins and renders the index. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
16
16
  export declare const WARNING_CALL = "Then call `empty_brain`. Nothing in between.";
17
17
  export declare function warningPrompt(): string;
18
18
  /** Pi and Claude deliver exactly the same second-tier notice. */
@@ -25,7 +25,7 @@ export function selectContinuation(origin) {
25
25
  /** Budget timing stays out of manual close-outs, which may have plenty of room. */
26
26
  export const WARNING_TIMING = "The reserve is nearly spent. The wipe lands at the end of whichever turn spends the last of it, possibly this one.";
27
27
  /** The shared handoff instructions, used for both budget and manual close-outs. */
28
- export const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md and MAP.md by default); every new window loads the pins. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
28
+ export const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md by default) and keep each page's one-line `description` true; every new window loads the pins and renders the index. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
29
29
  export const WARNING_CALL = "Then call `empty_brain`. Nothing in between.";
30
30
  export function warningPrompt() {
31
31
  return `${WARNING_TIMING}\n${WARNING_BODY}\n${WARNING_CALL}`;
@@ -1,4 +1,4 @@
1
- export type NoteErrorCode = "invalid_policy" | "pin_limit" | "readonly" | "not_found" | "already_exists" | "ambiguous_edit" | "no_match" | "invalid_edit" | "nothing_to_do" | "not_crumpled" | "too_large" | "invalid_scope" | "invalid_origin" | "invalid_address" | "invalid_pattern" | "invalid_query" | "invalid_offset" | "invalid_cwd" | "io_error" | "internal_error";
1
+ export type NoteErrorCode = "invalid_policy" | "invalid_description" | "pin_limit" | "readonly" | "not_found" | "already_exists" | "ambiguous_edit" | "no_match" | "invalid_edit" | "nothing_to_do" | "not_crumpled" | "too_large" | "invalid_scope" | "invalid_origin" | "invalid_address" | "invalid_pattern" | "invalid_query" | "invalid_offset" | "invalid_cwd" | "io_error" | "internal_error";
2
2
  /** Typed store refusal. Edit locations are exposed in camelCase. */
3
3
  export declare class NoteError extends Error {
4
4
  readonly code: NoteErrorCode;
@@ -21,8 +21,14 @@ export type NoteMeta = NotePolicyFields & {
21
21
  recurrenceWindows?: string[];
22
22
  /** Project ownership on newly-created session notes; legacy/invalid values are preserved as-is. */
23
23
  project?: unknown;
24
+ /** One-line index entry: what the note holds and when to open it. */
25
+ description?: string;
24
26
  [key: string]: unknown;
25
27
  };
28
+ /** A note description is one line; longer is not a description, it is prose in the wrong place. */
29
+ export declare const MAX_DESCRIPTION_CHARS = 160;
30
+ /** Collapse any whitespace run to one space and trim; an empty result is no description. */
31
+ export declare function collapseDescription(value: string): string | undefined;
26
32
  /**
27
33
  * Format epoch milliseconds as an ISO 8601 string in the host's local time zone with an
28
34
  * explicit numeric offset (e.g. 2026-09-15T17:31:45.392+08:00). A UTC host renders
@@ -3,7 +3,14 @@ const SCOPES = ["session", "project", "human", "agent", "model"];
3
3
  const ORIGINS = ["user", "self", "external"];
4
4
  const TIMESTAMP_KEYS = ["createdAt", "updatedAt", "lastAccessed"];
5
5
  /** Emission order, exactly the Design's key list. */
6
- const KNOWN_KEYS = ["pinned", "budget", "readonly", "origin", "crumpledAt", "createdAt", "updatedAt", "lastAccessed", "accessCount", "sourceWindow", "supersedes", "recurrenceCount", "recurrenceWindows"];
6
+ const KNOWN_KEYS = ["pinned", "budget", "readonly", "description", "origin", "crumpledAt", "createdAt", "updatedAt", "lastAccessed", "accessCount", "sourceWindow", "supersedes", "recurrenceCount", "recurrenceWindows"];
7
+ /** A note description is one line; longer is not a description, it is prose in the wrong place. */
8
+ export const MAX_DESCRIPTION_CHARS = 160;
9
+ /** Collapse any whitespace run to one space and trim; an empty result is no description. */
10
+ export function collapseDescription(value) {
11
+ const collapsed = value.replace(/\s+/g, " ").trim();
12
+ return collapsed.length === 0 ? undefined : collapsed;
13
+ }
7
14
  const pad2 = (value) => String(value).padStart(2, "0");
8
15
  /**
9
16
  * Format epoch milliseconds as an ISO 8601 string in the host's local time zone with an
@@ -107,6 +114,15 @@ export function parseNote(raw, now = Date.now()) {
107
114
  for (const key of TIMESTAMP_KEYS)
108
115
  meta[key] = toEpoch(meta[key], now);
109
116
  meta.accessCount = typeof meta.accessCount === "number" && Number.isFinite(meta.accessCount) ? meta.accessCount : 0;
117
+ // A hand-edited description is never allowed to break a boot: non-strings are absent, empty
118
+ // ones are dropped, and an oversized one is cut only when rendered.
119
+ if (meta.description !== undefined) {
120
+ const description = typeof meta.description === "string" ? collapseDescription(meta.description) : undefined;
121
+ if (description === undefined)
122
+ delete meta.description;
123
+ else
124
+ meta.description = description;
125
+ }
110
126
  return { meta: meta, body };
111
127
  }
112
128
  /**
@@ -2,7 +2,7 @@ import { NoteError } from "./errors.js";
2
2
  export const DEFAULT_NOTE_BUDGET = 4096;
3
3
  export const MAX_PINNED_NOTES = 5;
4
4
  /** Defaults and ordering live here; no other layer assigns behavior by page name. */
5
- const DEFAULT_PINNED_PAGES = ["CHEATSHEET.md", "MAP.md"];
5
+ const DEFAULT_PINNED_PAGES = ["CHEATSHEET.md"];
6
6
  export function validateNotePolicy(fields) {
7
7
  for (const key of ["pinned", "readonly"]) {
8
8
  if (fields[key] !== undefined && typeof fields[key] !== "boolean")
@@ -31,9 +31,11 @@ export type EditOperation = {
31
31
  };
32
32
  export type WriteOptions = NotePolicyFields & {
33
33
  origin?: Origin;
34
+ description?: string;
34
35
  };
35
36
  export type EditOptions = NotePolicyFields & {
36
37
  origin?: Origin;
38
+ description?: string;
37
39
  crumpled?: boolean;
38
40
  replaceAll?: boolean;
39
41
  renameTo?: string;
@@ -7,7 +7,7 @@ import { isFilesystemError } from "./fs-error.js";
7
7
  import { snapshotNotesIdentity } from "./identity.js";
8
8
  import { NoteError } from "./errors.js";
9
9
  import { MAX_NOTE_BYTES, MAX_NOTE_PATH_BYTES } from "./constants.js";
10
- import { isOrigin, localIso, parseNote, serializeNote, stripLeadingFrontmatter } from "./frontmatter.js";
10
+ import { collapseDescription, isOrigin, localIso, MAX_DESCRIPTION_CHARS, parseNote, serializeNote, stripLeadingFrontmatter } from "./frontmatter.js";
11
11
  import { namespaceSlugs, noteFileName, physicalPath, scopeDir, isSessionId, SLUG_PATTERN } from "./paths.js";
12
12
  import { projectReceipt } from "./project-namespace.js";
13
13
  import { applyNotePolicy, assertNoteUnlocked, effectiveNotePolicy, MAX_PINNED_NOTES, noteBudgetWarnings, validateNotePolicy } from "./policy.js";
@@ -154,6 +154,16 @@ function assertOrigin(value) {
154
154
  throw new NoteError("invalid_origin", `origin must be one of user, self, external (got ${JSON.stringify(value)})`);
155
155
  return value;
156
156
  }
157
+ /** A description is one normalized line; empty clears it. Only the authored value is refused, never read. */
158
+ function normalizeDescription(value) {
159
+ const collapsed = collapseDescription(value);
160
+ if (collapsed === undefined)
161
+ return undefined;
162
+ const count = Array.from(collapsed).length;
163
+ if (count > MAX_DESCRIPTION_CHARS)
164
+ throw new NoteError("invalid_description", `description is ${count} characters; limit is ${MAX_DESCRIPTION_CHARS}.`);
165
+ return collapsed;
166
+ }
157
167
  function assertWho(value, scope) {
158
168
  if (typeof value !== "string" || !(scope === "session" ? isSessionId(value) : SLUG_PATTERN.test(value))) {
159
169
  throw new NoteError("invalid_scope", scope === "session" ? "session id must be a safe single directory component" : "who must be a canonical lowercase slug");
@@ -283,6 +293,7 @@ export function createNotesStore(input) {
283
293
  async function write(address, content, options = {}) {
284
294
  const stableOptions = { ...options };
285
295
  validateNotePolicy(stableOptions);
296
+ const description = stableOptions.description === undefined ? undefined : normalizeDescription(stableOptions.description);
286
297
  const destination = assertAddress(address);
287
298
  assertWritablePath(destination.path);
288
299
  const scope = destination.scope;
@@ -313,6 +324,12 @@ export function createNotesStore(input) {
313
324
  };
314
325
  meta.scope = scope;
315
326
  applyNotePolicy(meta, stableOptions);
327
+ if (description === undefined) {
328
+ if (stableOptions.description !== undefined)
329
+ delete meta.description;
330
+ }
331
+ else
332
+ meta.description = description;
316
333
  if (origin !== undefined)
317
334
  meta.origin = origin;
318
335
  delete meta.crumpledAt;
@@ -347,14 +364,15 @@ export function createNotesStore(input) {
347
364
  const operations = edits === undefined ? [] : edits.map((operation) => ({ ...operation }));
348
365
  const stableOptions = { ...options };
349
366
  validateNotePolicy(stableOptions);
367
+ const description = stableOptions.description === undefined ? undefined : normalizeDescription(stableOptions.description);
350
368
  const from = assertAddress(address);
351
369
  const destination = stableOptions.renameTo === undefined ? from : assertAddress(stableOptions.renameTo);
352
370
  assertWritablePath(destination.path);
353
371
  const scope = destination.scope;
354
372
  assertWritableNamespace(from.scope, from.who, identity);
355
373
  assertWritableNamespace(scope, destination.who, identity);
356
- if (operations.length === 0 && stableOptions.origin === undefined && stableOptions.crumpled === undefined && stableOptions.renameTo === undefined && stableOptions.pinned === undefined && stableOptions.budget === undefined && stableOptions.readonly === undefined) {
357
- throw new NoteError("nothing_to_do", "Nothing to change: provide edits, policy, an origin, a crumpled state, or a new address.");
374
+ if (operations.length === 0 && stableOptions.origin === undefined && stableOptions.description === undefined && stableOptions.crumpled === undefined && stableOptions.renameTo === undefined && stableOptions.pinned === undefined && stableOptions.budget === undefined && stableOptions.readonly === undefined) {
375
+ throw new NoteError("nothing_to_do", "Nothing to change: provide edits, a description, policy, an origin, a crumpled state, or a new address.");
358
376
  }
359
377
  const fromPath = physicalPath(from.scope, from.path, identity, from.who);
360
378
  const path = physicalPath(scope, destination.path, identity, destination.who);
@@ -383,6 +401,12 @@ export function createNotesStore(input) {
383
401
  assertNoteUnlocked(parseNote(targetRaw).meta, stableOptions.readonly);
384
402
  const beforeMeta = { ...meta };
385
403
  applyNotePolicy(meta, stableOptions);
404
+ if (description === undefined) {
405
+ if (stableOptions.description !== undefined)
406
+ delete meta.description;
407
+ }
408
+ else
409
+ meta.description = description;
386
410
  meta.scope = scope;
387
411
  if (from.scope !== "session" && scope === "session")
388
412
  meta.project = identity.projectKey;
@@ -422,11 +446,12 @@ export function createNotesStore(input) {
422
446
  const bodyChanged = body !== next;
423
447
  const originChanged = beforeMeta.origin !== meta.origin;
424
448
  const policyChanged = beforeMeta.pinned !== meta.pinned || beforeMeta.budget !== meta.budget || beforeMeta.readonly !== meta.readonly;
425
- if (bodyChanged || originChanged || policyChanged || moved)
449
+ const descriptionChanged = beforeMeta.description !== meta.description;
450
+ if (bodyChanged || originChanged || policyChanged || descriptionChanged || moved)
426
451
  meta.updatedAt = writeStamp();
427
452
  const serialized = serializeNote(meta, next);
428
453
  assertSerializedSize(serialized);
429
- const metadataChanged = originChanged || policyChanged || beforeMeta.crumpledAt !== meta.crumpledAt;
454
+ const metadataChanged = originChanged || policyChanged || descriptionChanged || beforeMeta.crumpledAt !== meta.crumpledAt;
430
455
  let change;
431
456
  // A body edit that also rewrites frontmatter is still a body change; its diff inputs span the
432
457
  // whole serialized file, so the frontmatter part stays visible in the diff.
@@ -29,6 +29,7 @@ export declare const DreamBeginDataSchema: Type.TObject<{
29
29
  last_accessed: Type.TString;
30
30
  updated_at: Type.TString;
31
31
  crumpled_at: Type.TOptional<Type.TString>;
32
+ description: Type.TOptional<Type.TString>;
32
33
  warnings: Type.TArray<Type.TString>;
33
34
  pinned: Type.TBoolean;
34
35
  budget: Type.TInteger;
@@ -59,6 +60,7 @@ export declare const dreamBegin: {
59
60
  last_accessed: Type.TString;
60
61
  updated_at: Type.TString;
61
62
  crumpled_at: Type.TOptional<Type.TString>;
63
+ description: Type.TOptional<Type.TString>;
62
64
  warnings: Type.TArray<Type.TString>;
63
65
  pinned: Type.TBoolean;
64
66
  budget: Type.TInteger;
@@ -14,6 +14,7 @@ export declare const NoteMetadataSchema: Type.TObject<{
14
14
  updated_at: Type.TString;
15
15
  crumpled_at: Type.TOptional<Type.TString>;
16
16
  project: Type.TOptional<Type.TString>;
17
+ description: Type.TOptional<Type.TString>;
17
18
  extra: Type.TRecord<"^.*$", Type.TUnknown>;
18
19
  pinned: Type.TBoolean;
19
20
  budget: Type.TInteger;
@@ -41,6 +42,7 @@ export declare const NoteIdentitySchema: {
41
42
  export declare const ListedFileSchema: Type.TObject<{
42
43
  updated_at: Type.TString;
43
44
  crumpled_at: Type.TOptional<Type.TString>;
45
+ description: Type.TOptional<Type.TString>;
44
46
  warnings: Type.TArray<Type.TString>;
45
47
  pinned: Type.TBoolean;
46
48
  budget: Type.TInteger;
@@ -99,6 +101,7 @@ export declare const NotesReadDataSchema: Type.TObject<{
99
101
  updated_at: Type.TString;
100
102
  crumpled_at: Type.TOptional<Type.TString>;
101
103
  project: Type.TOptional<Type.TString>;
104
+ description: Type.TOptional<Type.TString>;
102
105
  extra: Type.TRecord<"^.*$", Type.TUnknown>;
103
106
  pinned: Type.TBoolean;
104
107
  budget: Type.TInteger;
@@ -125,6 +128,7 @@ export declare const NotesListDataSchema: Type.TObject<{
125
128
  more_matches: Type.TOptional<Type.TInteger>;
126
129
  updated_at: Type.TString;
127
130
  crumpled_at: Type.TOptional<Type.TString>;
131
+ description: Type.TOptional<Type.TString>;
128
132
  warnings: Type.TArray<Type.TString>;
129
133
  pinned: Type.TBoolean;
130
134
  budget: Type.TInteger;
@@ -159,6 +163,7 @@ export declare const notesWriteParameters: Type.TObject<{
159
163
  address: Type.TString;
160
164
  content: Type.TString;
161
165
  origin: Type.TOptional<Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>>;
166
+ description: Type.TOptional<Type.TString>;
162
167
  }>;
163
168
  export declare const notesWrite: {
164
169
  readonly name: "notes_write";
@@ -172,6 +177,7 @@ export declare const notesWrite: {
172
177
  address: Type.TString;
173
178
  content: Type.TString;
174
179
  origin: Type.TOptional<Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>>;
180
+ description: Type.TOptional<Type.TString>;
175
181
  }>;
176
182
  readonly outputSchema: Type.TUnion<[Type.TObject<{
177
183
  outcome: Type.TUnion<[Type.TLiteral<"created">, Type.TLiteral<"overwrote">, Type.TLiteral<"uncrumpled">]>;
@@ -208,6 +214,7 @@ export declare const notesUpdateParameters: Type.TObject<{
208
214
  newText: Type.TString;
209
215
  }>>>;
210
216
  origin: Type.TOptional<Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>>;
217
+ description: Type.TOptional<Type.TString>;
211
218
  }>;
212
219
  export declare const notesUpdate: {
213
220
  readonly name: "notes_update";
@@ -227,6 +234,7 @@ export declare const notesUpdate: {
227
234
  newText: Type.TString;
228
235
  }>>>;
229
236
  origin: Type.TOptional<Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>>;
237
+ description: Type.TOptional<Type.TString>;
230
238
  }>;
231
239
  readonly outputSchema: Type.TUnion<[Type.TObject<{
232
240
  change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"moved">]>;
@@ -277,6 +285,7 @@ export declare const notesRead: {
277
285
  updated_at: Type.TString;
278
286
  crumpled_at: Type.TOptional<Type.TString>;
279
287
  project: Type.TOptional<Type.TString>;
288
+ description: Type.TOptional<Type.TString>;
280
289
  extra: Type.TRecord<"^.*$", Type.TUnknown>;
281
290
  pinned: Type.TBoolean;
282
291
  budget: Type.TInteger;
@@ -333,6 +342,7 @@ export declare const notesList: {
333
342
  more_matches: Type.TOptional<Type.TInteger>;
334
343
  updated_at: Type.TString;
335
344
  crumpled_at: Type.TOptional<Type.TString>;
345
+ description: Type.TOptional<Type.TString>;
336
346
  warnings: Type.TArray<Type.TString>;
337
347
  pinned: Type.TBoolean;
338
348
  budget: Type.TInteger;
@@ -15,8 +15,9 @@ const ORIGIN_VALUES = [Type.Literal("user"), Type.Literal("self"), Type.Literal(
15
15
  const ORIGIN = Type.Optional(Type.Union([...ORIGIN_VALUES], {
16
16
  description: "Whose handwriting: user, self, or external. Leave it out to keep what's there.",
17
17
  }));
18
+ const DESCRIPTION_PARAMETER = Type.Optional(Type.String({ description: "One-line summary of what's inside and when to open it (max 160 chars). Empty string clears it." }));
18
19
  const POLICY_PARAMETERS = {
19
- pinned: Type.Optional(Type.Boolean({ description: "Tape the page inside the cover: read whole at every wake-up. Five per notebook, CHEATSHEET and MAP included." })),
20
+ pinned: Type.Optional(Type.Boolean({ description: "Tape the page inside the cover: read whole at every wake-up. Five per notebook, CHEATSHEET included." })),
20
21
  budget: Type.Optional(Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "How much paper the page gets. Writing past it still saves, with a warning. A page over budget gets boiled down: stale lines out, repeats merged, the rest said shorter. More paper is for a page already boiled down that still needs the room." })),
21
22
  readonly: Type.Optional(Type.Boolean({ description: "A paperclip that keeps your own hands off. `false` takes it off — same call is fine." })),
22
23
  };
@@ -36,7 +37,7 @@ function withWarnings(text, data) {
36
37
  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
38
  const CRUMPLED_LIST_PARAMETER = Type.Optional(Type.Boolean({ description: "Only the crumpled balls." }));
38
39
  const FILE_LIMIT_PARAMETER = Type.Optional(Type.Integer({ minimum: 1, description: "How many pages at most." }));
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
+ 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 · `CHEATSHEET.md` that page in every notebook · `**` everything · `@sessions/*/**` every session." }));
40
41
  const CWD_PARAMETER = Type.Optional(Type.String({ minLength: 1, description: "Treat this directory's project as `@project/`." }));
41
42
  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
43
  /**
@@ -54,7 +55,7 @@ export function failureOf(error) {
54
55
  throw error;
55
56
  }
56
57
  /** Metadata keys this layer normalizes; everything else is exposed verbatim under `extra`. */
57
- const NORMALIZED_META_KEYS = new Set(["scope", "origin", "createdAt", "updatedAt", "lastAccessed", "accessCount", "crumpledAt", "project", "pinned", "budget", "readonly"]);
58
+ const NORMALIZED_META_KEYS = new Set(["scope", "origin", "createdAt", "updatedAt", "lastAccessed", "accessCount", "crumpledAt", "project", "pinned", "budget", "readonly", "description"]);
58
59
  /** One unrecognized entry, and the verbatim extras together, are bounded so `extra` cannot outgrow the read. */
59
60
  const MAX_METADATA_ENTRY_BYTES = 1024;
60
61
  const MAX_METADATA_VERBATIM_BYTES = 2048;
@@ -67,6 +68,7 @@ export const NoteMetadataSchema = Type.Object({
67
68
  updated_at: Type.String(),
68
69
  crumpled_at: Type.Optional(Type.String()),
69
70
  project: Type.Optional(Type.String()),
71
+ description: Type.Optional(Type.String()),
70
72
  extra: Type.Record(Type.String(), Type.Unknown()),
71
73
  }, { additionalProperties: false });
72
74
  /** Normalize known metadata and bound extras, naming an oversized value instead of hiding it. */
@@ -99,6 +101,7 @@ function noteMetadata(meta, address) {
99
101
  updated_at: localIso(meta.updatedAt),
100
102
  ...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
101
103
  ...(typeof meta.project === "string" ? { project: meta.project } : {}),
104
+ ...(typeof meta.description === "string" ? { description: meta.description } : {}),
102
105
  extra,
103
106
  };
104
107
  }
@@ -110,6 +113,7 @@ function renderMetadata(metadata) {
110
113
  `updated ${metadata.updated_at}`,
111
114
  ...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
112
115
  ...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
116
+ ...(metadata.description === undefined ? [] : [`description ${metadata.description}`]),
113
117
  ];
114
118
  const extra = Object.keys(metadata.extra);
115
119
  if (extra.length > 0)
@@ -142,6 +146,7 @@ export const ListedFileSchema = Type.Object({
142
146
  ...WarningsSchema,
143
147
  updated_at: Type.String(),
144
148
  crumpled_at: Type.Optional(Type.String()),
149
+ description: Type.Optional(Type.String()),
145
150
  }, { additionalProperties: false });
146
151
  const MatchSchema = Type.Object({
147
152
  line: Type.Integer(),
@@ -203,9 +208,9 @@ export function snapshot(rows, limit, status, renderData, shrink) {
203
208
  }
204
209
  export function listedFile(row, identity) {
205
210
  const policy = policyAt(row.meta, row.address);
206
- return { ...noteIdentity(identity, row.address), ...policy, warnings: row.warnings ?? (row.body === undefined ? [] : noteBudgetWarnings(row.body, policy)), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
211
+ return { ...noteIdentity(identity, row.address), ...policy, warnings: row.warnings ?? (row.body === undefined ? [] : noteBudgetWarnings(row.body, policy)), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }), ...(typeof row.meta.description === "string" ? { description: row.meta.description } : {}) };
207
212
  }
208
- export const notesWriteParameters = Type.Object({ address: ADDRESS_PARAMETER, content: Type.String({ description: "The whole page." }), origin: ORIGIN, ...POLICY_PARAMETERS, cwd: CWD_PARAMETER }, { additionalProperties: false });
213
+ export const notesWriteParameters = Type.Object({ address: ADDRESS_PARAMETER, content: Type.String({ description: "The whole page." }), origin: ORIGIN, description: DESCRIPTION_PARAMETER, ...POLICY_PARAMETERS, cwd: CWD_PARAMETER }, { additionalProperties: false });
209
214
  function renderWriteData(data) {
210
215
  return withWarnings(`${data.outcome} ${renderIdentity(data)} | ${renderPolicy(data)}`, data);
211
216
  }
@@ -216,7 +221,7 @@ export const notesWrite = {
216
221
  async execute(params, context) {
217
222
  try {
218
223
  const identity = notesIdentityForCall(context, params.cwd);
219
- const { outcome, meta, warnings } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin, pinned: params.pinned, budget: params.budget, readonly: params.readonly });
224
+ const { outcome, meta, warnings } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin, description: params.description, pinned: params.pinned, budget: params.budget, readonly: params.readonly });
220
225
  return success({ ...noteIdentity(identity, params.address), outcome, ...policyAt(meta, params.address), warnings });
221
226
  }
222
227
  catch (error) {
@@ -229,6 +234,7 @@ export const notesUpdateParameters = Type.Object({
229
234
  address: ADDRESS_PARAMETER,
230
235
  edits: Type.Optional(Type.Array(Type.Object({ oldText: Type.String({ description: "The passage as it stands on the page." }), newText: Type.String({ description: "What goes in its place." }) }, { additionalProperties: false }), { description: "Pen strokes, in order. Each `oldText` is the exact passage — same case, found once — and `newText` is what goes in its place." })),
231
236
  origin: ORIGIN,
237
+ description: DESCRIPTION_PARAMETER,
232
238
  ...POLICY_PARAMETERS,
233
239
  crumpled: CRUMPLED_PARAMETER,
234
240
  replace_all: Type.Optional(Type.Boolean({ description: "Strike every copy of `oldText`, not just one." })),
@@ -251,7 +257,7 @@ export const notesUpdate = {
251
257
  const store = createNotesStore(identity);
252
258
  // Empty filler is not a request: models that pass every parameter get the edit path.
253
259
  const renameTo = params.rename_to === "" ? undefined : params.rename_to;
254
- const { change, moved, meta, warnings } = await store.update(params.address, params.edits, { origin: params.origin, pinned: params.pinned, budget: params.budget, readonly: params.readonly, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
260
+ const { change, moved, meta, warnings } = await store.update(params.address, params.edits, { origin: params.origin, description: params.description, pinned: params.pinned, budget: params.budget, readonly: params.readonly, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
255
261
  onChange?.(change);
256
262
  const from = noteIdentity(identity, params.address).address;
257
263
  const to = noteIdentity(identity, renameTo ?? params.address);
@@ -302,7 +308,7 @@ export const notesListParameters = Type.Object({
302
308
  export function renderListData(data) {
303
309
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
304
310
  for (const file of data.files) {
305
- const fields = [`- ${renderIdentity(file)}`, renderPolicy(file), `updated ${file.updated_at}`];
311
+ const fields = [file.description === undefined ? `- ${renderIdentity(file)}` : `- ${renderIdentity(file)} — ${file.description}`, renderPolicy(file), `updated ${file.updated_at}`];
306
312
  if (file.last_accessed !== undefined)
307
313
  fields.push(`accessed ${file.last_accessed}`);
308
314
  if (file.crumpled_at !== undefined)
@@ -50,7 +50,7 @@ test("shared boot uses only explicit identity, loader, captured time and logical
50
50
  const block = { agentName: notesIdentity.agent, modelName: notesIdentity.model, tree: { trunk: "test", windows: [{ shortName: "root", isCurrent: false }, { shortName: "next", isCurrent: true }] }, notes: snapshot, tools };
51
51
  const rendered = renderBootBlock(block);
52
52
  assert.equal(renderBootBlock(block), rendered);
53
- assert.ok(rendered.includes("😀\n checkpoint.md · 1m ago"), "a feed entry is the note's own first line over its locator");
53
+ assert.ok(rendered.includes(" checkpoint.md · 1m ago — 😀"), "an index entry is the locator plus the note's own first line");
54
54
  assert.ok(rendered.includes("Try `memo_list` again"));
55
55
  assert.equal(/notes_\*|notes_list|history_\*|history_list|history_read|get_context_remaining|empty_brain/.test(rendered), false);
56
56
  });