notesoup 0.60.0 → 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 (56) 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/dream/git.js +12 -13
  9. package/dist/src/notes/errors.d.ts +1 -1
  10. package/dist/src/notes/frontmatter.d.ts +6 -0
  11. package/dist/src/notes/frontmatter.js +17 -1
  12. package/dist/src/notes/policy.js +1 -1
  13. package/dist/src/notes/project-namespace.js +39 -73
  14. package/dist/src/notes/store.d.ts +2 -0
  15. package/dist/src/notes/store.js +30 -5
  16. package/dist/src/sqlite-lock.d.ts +2 -0
  17. package/dist/src/sqlite-lock.js +17 -0
  18. package/dist/src/tools/dream.d.ts +4 -4
  19. package/dist/src/tools/dream.js +15 -16
  20. package/dist/src/tools/notes.d.ts +10 -0
  21. package/dist/src/tools/notes.js +14 -8
  22. package/dist/test/dream-tools.test.js +42 -14
  23. package/dist/test/host-neutral.test.js +1 -1
  24. package/dist/test/note-policy.test.js +122 -8
  25. package/dist/test/notes.integration.test.js +3 -7
  26. package/dist/test/project-namespace.test.js +33 -88
  27. package/docs/dsh.md +2 -2
  28. package/docs/notes-library.md +10 -4
  29. package/docs/reset-lifecycle.md +1 -1
  30. package/docs/skills.md +2 -6
  31. package/docs/tool-results.md +1 -1
  32. package/package.json +1 -1
  33. package/playbook.md +3 -3
  34. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  35. package/plugins/claude/dist/claude/helper.js +150 -103
  36. package/plugins/claude/playbook.md +3 -3
  37. package/plugins/claude/skills/dream/SKILL.md +2 -2
  38. package/plugins/claude/skills/memory/SKILL.md +1 -1
  39. package/plugins/codex/dist/codex/notesoup.js +149 -102
  40. package/skills/dream/SKILL.md +2 -2
  41. package/skills/memory/SKILL.md +1 -1
  42. package/src/boot/render.ts +48 -17
  43. package/src/boot/text.ts +10 -11
  44. package/src/budget/text.ts +1 -1
  45. package/src/dream/git.ts +11 -11
  46. package/src/notes/errors.ts +1 -1
  47. package/src/notes/frontmatter.ts +19 -1
  48. package/src/notes/policy.ts +1 -1
  49. package/src/notes/project-namespace.ts +37 -59
  50. package/src/notes/store.ts +25 -7
  51. package/src/sqlite-lock.ts +14 -0
  52. package/src/tools/dream.ts +15 -14
  53. package/src/tools/notes.ts +14 -8
  54. package/dist/src/dream/lock.d.ts +0 -14
  55. package/dist/src/dream/lock.js +0 -29
  56. package/src/dream/lock.ts +0 -28
@@ -24868,7 +24868,7 @@ function eventDocument(event) {
24868
24868
  function toolEvent(item, result) {
24869
24869
  const run = result ?? item;
24870
24870
  const status = item.role === "tool_call" && result === void 0 ? "unfinished" : run.recordedStatus ?? (run.toolError === true ? "error" : "ok");
24871
- const truncated = run.outputTruncated === true;
24871
+ const truncated2 = run.outputTruncated === true;
24872
24872
  return {
24873
24873
  seq: item.seq,
24874
24874
  windowId: item.windowId,
@@ -24880,7 +24880,7 @@ function toolEvent(item, result) {
24880
24880
  status,
24881
24881
  // A call records its arguments; a bare result records none, and gets none invented.
24882
24882
  ...item.arguments === void 0 ? {} : { arguments: item.arguments },
24883
- ...truncated ? { outputTruncated: true, ...run.fullOutputPath ? { fullOutputPath: run.fullOutputPath } : {} } : {},
24883
+ ...truncated2 ? { outputTruncated: true, ...run.fullOutputPath ? { fullOutputPath: run.fullOutputPath } : {} } : {},
24884
24884
  ...run.nestedCalls ? { nestedCalls: run.nestedCalls } : {}
24885
24885
  }
24886
24886
  };
@@ -24963,14 +24963,14 @@ function visibleItem(event, maxChars, matchOffset) {
24963
24963
  const chars = Array.from(document);
24964
24964
  const start = matchOffset ?? 0;
24965
24965
  const limit = Math.max(0, maxChars);
24966
- const truncated = start > 0 || start + limit < chars.length;
24966
+ const truncated2 = start > 0 || start + limit < chars.length;
24967
24967
  return {
24968
24968
  seq: event.seq,
24969
24969
  role: event.role,
24970
24970
  created_at: event.createdAt ?? null,
24971
24971
  ...toolSummary(event),
24972
- content: truncated ? chars.slice(start, start + limit).join("") : document,
24973
- truncated,
24972
+ content: truncated2 ? chars.slice(start, start + limit).join("") : document,
24973
+ truncated: truncated2,
24974
24974
  ...matchOffset === void 0 ? {} : { offset_chars: matchOffset }
24975
24975
  };
24976
24976
  }
@@ -25140,7 +25140,7 @@ function addressFor(identity, scope, path, who) {
25140
25140
  // src/notes/policy.ts
25141
25141
  var DEFAULT_NOTE_BUDGET = 4096;
25142
25142
  var MAX_PINNED_NOTES = 5;
25143
- var DEFAULT_PINNED_PAGES = ["CHEATSHEET.md", "MAP.md"];
25143
+ var DEFAULT_PINNED_PAGES = ["CHEATSHEET.md"];
25144
25144
  function validateNotePolicy(fields) {
25145
25145
  for (const key of ["pinned", "readonly"]) {
25146
25146
  if (fields[key] !== void 0 && typeof fields[key] !== "boolean") throw new NoteError("invalid_policy", `${key} must be a boolean.`);
@@ -25180,7 +25180,12 @@ function applyNotePolicy(target, fields) {
25180
25180
  var SCOPES = ["session", "project", "human", "agent", "model"];
25181
25181
  var ORIGINS = ["user", "self", "external"];
25182
25182
  var TIMESTAMP_KEYS = ["createdAt", "updatedAt", "lastAccessed"];
25183
- var KNOWN_KEYS = ["pinned", "budget", "readonly", "origin", "crumpledAt", "createdAt", "updatedAt", "lastAccessed", "accessCount", "sourceWindow", "supersedes", "recurrenceCount", "recurrenceWindows"];
25183
+ var KNOWN_KEYS = ["pinned", "budget", "readonly", "description", "origin", "crumpledAt", "createdAt", "updatedAt", "lastAccessed", "accessCount", "sourceWindow", "supersedes", "recurrenceCount", "recurrenceWindows"];
25184
+ var MAX_DESCRIPTION_CHARS = 160;
25185
+ function collapseDescription(value) {
25186
+ const collapsed = value.replace(/\s+/g, " ").trim();
25187
+ return collapsed.length === 0 ? void 0 : collapsed;
25188
+ }
25184
25189
  var pad2 = (value) => String(value).padStart(2, "0");
25185
25190
  function localIso(epochMs) {
25186
25191
  const date3 = new Date(epochMs);
@@ -25256,6 +25261,11 @@ function parseNote(raw, now = Date.now()) {
25256
25261
  meta2.origin = isOrigin(meta2.origin) ? meta2.origin : "self";
25257
25262
  for (const key of TIMESTAMP_KEYS) meta2[key] = toEpoch(meta2[key], now);
25258
25263
  meta2.accessCount = typeof meta2.accessCount === "number" && Number.isFinite(meta2.accessCount) ? meta2.accessCount : 0;
25264
+ if (meta2.description !== void 0) {
25265
+ const description = typeof meta2.description === "string" ? collapseDescription(meta2.description) : void 0;
25266
+ if (description === void 0) delete meta2.description;
25267
+ else meta2.description = description;
25268
+ }
25259
25269
  return { meta: meta2, body };
25260
25270
  }
25261
25271
  function yamlScalar(value) {
@@ -25370,8 +25380,25 @@ var MAX_NOTE_PATH_BYTES = 512;
25370
25380
 
25371
25381
  // src/notes/project-namespace.ts
25372
25382
  import { randomUUID } from "node:crypto";
25373
- import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmdirSync, rmSync, statSync, writeFileSync } from "node:fs";
25383
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
25374
25384
  import { basename, dirname, join as join2, resolve as resolve2, sep } from "node:path";
25385
+
25386
+ // src/sqlite-lock.ts
25387
+ function trySqliteLock(path, waitMs) {
25388
+ const sqlite = process.getBuiltinModule?.("node:sqlite");
25389
+ if (!sqlite?.DatabaseSync) throw new Error("Notesoup locks require built-in node:sqlite (Node 22.13+).");
25390
+ const db = new sqlite.DatabaseSync(path);
25391
+ try {
25392
+ db.exec(`PRAGMA busy_timeout = ${waitMs}; BEGIN IMMEDIATE`);
25393
+ } catch (error2) {
25394
+ db.close();
25395
+ if (error2 instanceof Error && "errcode" in error2 && error2.errcode === 5) return void 0;
25396
+ throw error2;
25397
+ }
25398
+ return () => db.close();
25399
+ }
25400
+
25401
+ // src/notes/project-namespace.ts
25375
25402
  function errno(error2) {
25376
25403
  return typeof error2 === "object" && error2 !== null ? error2.code : void 0;
25377
25404
  }
@@ -25484,67 +25511,42 @@ function updateMarker(namespace, marker) {
25484
25511
  }
25485
25512
  return { ...namespace, ...marker };
25486
25513
  }
25487
- var claimSleep = new Int32Array(new SharedArrayBuffer(4));
25488
- function awaitClaim(path, attempt) {
25489
- const deadline = performance.now() + 5e3;
25490
- for (; ; ) {
25491
- const result = attempt();
25492
- if (result !== void 0) return result;
25493
- const remaining = deadline - performance.now();
25494
- if (remaining <= 0) throw new Error(`Timed out waiting for project claim at ${path}`);
25495
- Atomics.wait(claimSleep, 0, 0, Math.min(10, remaining));
25496
- }
25514
+ function checkoutMarker(cwd) {
25515
+ const path = canonicalRoot(cwd);
25516
+ return { id: originRemote(path) ?? path, path };
25497
25517
  }
25498
25518
  function resolveProjectNamespace(cwd, home) {
25499
- mkdirSync(projectRoot(home), { recursive: true });
25500
- const lock = join2(home, ".project-claim");
25501
- awaitClaim(lock, () => {
25502
- try {
25503
- mkdirSync(lock);
25504
- return true;
25505
- } catch (error2) {
25506
- if (errno(error2) === "EEXIST") return void 0;
25507
- throw error2;
25508
- }
25509
- });
25519
+ const expected = checkoutMarker(cwd);
25520
+ const current = projectNamespaces(home).find((candidate) => candidate.id === expected.id);
25521
+ if (current?.path === expected.path) return current;
25522
+ const root = projectRoot(home);
25523
+ mkdirSync(root, { recursive: true });
25524
+ const lockPath = join2(home, ".project-claim.sqlite");
25525
+ const release = trySqliteLock(lockPath, 5e3);
25526
+ if (!release) throw new Error(`Timed out waiting for project claim at ${lockPath}`);
25510
25527
  try {
25511
- return claimProjectNamespace(cwd, home);
25512
- } finally {
25513
- rmdirSync(lock);
25514
- }
25515
- }
25516
- function claimProjectNamespace(cwd, home) {
25517
- const root = canonicalRoot(cwd);
25518
- const remote = originRemote(root);
25519
- const id2 = remote ?? root;
25520
- const markerRoot = projectRoot(home);
25521
- mkdirSync(markerRoot, { recursive: true });
25522
- const namespaces = projectNamespaces(home);
25523
- let found = namespaces.find((candidate) => candidate.id === id2);
25524
- if (!found && remote) {
25525
- found = namespaces.find((candidate) => candidate.id === root);
25526
- if (found) found = updateMarker(found, { id: remote, path: root });
25527
- }
25528
- if (found) {
25529
- if (found.path !== root) found = updateMarker(found, { id: found.id, path: root });
25530
- return found;
25531
- }
25532
- const base = slugify2(basename(root));
25533
- const taken = new Set(readdirSync(markerRoot));
25534
- for (let suffix = 0; ; suffix++) {
25535
- const name = suffix === 0 ? base : `${base}-${suffix}`;
25536
- if (taken.has(name)) continue;
25537
- const dir = join2(markerRoot, name);
25538
- try {
25539
- mkdirSync(dir);
25540
- } catch (error2) {
25541
- if (errno(error2) !== "EEXIST") throw error2;
25542
- let winner = awaitClaim(join2(dir, ".project"), () => readMarker(dir));
25543
- if (winner.id !== id2 && !(remote && winner.id === root)) continue;
25544
- if (winner.id !== id2 || winner.path !== root) winner = updateMarker(winner, { id: id2, path: root });
25545
- return winner;
25528
+ const marker = checkoutMarker(cwd);
25529
+ const { id: id2, path } = marker;
25530
+ const namespaces = projectNamespaces(home);
25531
+ const found = namespaces.find((candidate) => candidate.id === id2) ?? namespaces.find((candidate) => candidate.id === path);
25532
+ if (found) return found.id === id2 && found.path === path ? found : updateMarker(found, marker);
25533
+ const base = slugify2(basename(path));
25534
+ for (let suffix = 0; ; suffix++) {
25535
+ const name = suffix === 0 ? base : `${base}-${suffix}`;
25536
+ const dir = join2(root, name);
25537
+ if (lstatSync(dir, { throwIfNoEntry: false })) continue;
25538
+ const staged = mkdtempSync(join2(home, ".project-pending-"));
25539
+ try {
25540
+ writeFileSync(join2(staged, ".project"), JSON.stringify(marker));
25541
+ renameSync(staged, dir);
25542
+ } catch (error2) {
25543
+ rmSync(staged, { recursive: true, force: true });
25544
+ throw error2;
25545
+ }
25546
+ return { name, dir, ...marker };
25546
25547
  }
25547
- return updateMarker({ name, dir, id: id2, path: root }, { id: id2, path: root });
25548
+ } finally {
25549
+ release();
25548
25550
  }
25549
25551
  }
25550
25552
  function gitRoot(cwd) {
@@ -25703,6 +25705,13 @@ function assertOrigin(value) {
25703
25705
  if (!isOrigin(value)) throw new NoteError("invalid_origin", `origin must be one of user, self, external (got ${JSON.stringify(value)})`);
25704
25706
  return value;
25705
25707
  }
25708
+ function normalizeDescription(value) {
25709
+ const collapsed = collapseDescription(value);
25710
+ if (collapsed === void 0) return void 0;
25711
+ const count = Array.from(collapsed).length;
25712
+ if (count > MAX_DESCRIPTION_CHARS) throw new NoteError("invalid_description", `description is ${count} characters; limit is ${MAX_DESCRIPTION_CHARS}.`);
25713
+ return collapsed;
25714
+ }
25706
25715
  function assertWho(value, scope) {
25707
25716
  if (typeof value !== "string" || !(scope === "session" ? isSessionId(value) : SLUG_PATTERN.test(value))) {
25708
25717
  throw new NoteError("invalid_scope", scope === "session" ? "session id must be a safe single directory component" : "who must be a canonical lowercase slug");
@@ -25792,6 +25801,7 @@ function createNotesStore(input) {
25792
25801
  async function write(address, content, options = {}) {
25793
25802
  const stableOptions = { ...options };
25794
25803
  validateNotePolicy(stableOptions);
25804
+ const description = stableOptions.description === void 0 ? void 0 : normalizeDescription(stableOptions.description);
25795
25805
  const destination = assertAddress(address);
25796
25806
  assertWritablePath(destination.path);
25797
25807
  const scope = destination.scope;
@@ -25819,6 +25829,9 @@ function createNotesStore(input) {
25819
25829
  };
25820
25830
  meta2.scope = scope;
25821
25831
  applyNotePolicy(meta2, stableOptions);
25832
+ if (description === void 0) {
25833
+ if (stableOptions.description !== void 0) delete meta2.description;
25834
+ } else meta2.description = description;
25822
25835
  if (origin !== void 0) meta2.origin = origin;
25823
25836
  delete meta2.crumpledAt;
25824
25837
  meta2.updatedAt = now;
@@ -25848,14 +25861,15 @@ function createNotesStore(input) {
25848
25861
  const operations = edits === void 0 ? [] : edits.map((operation) => ({ ...operation }));
25849
25862
  const stableOptions = { ...options };
25850
25863
  validateNotePolicy(stableOptions);
25864
+ const description = stableOptions.description === void 0 ? void 0 : normalizeDescription(stableOptions.description);
25851
25865
  const from = assertAddress(address);
25852
25866
  const destination = stableOptions.renameTo === void 0 ? from : assertAddress(stableOptions.renameTo);
25853
25867
  assertWritablePath(destination.path);
25854
25868
  const scope = destination.scope;
25855
25869
  assertWritableNamespace(from.scope, from.who, identity);
25856
25870
  assertWritableNamespace(scope, destination.who, identity);
25857
- if (operations.length === 0 && stableOptions.origin === void 0 && stableOptions.crumpled === void 0 && stableOptions.renameTo === void 0 && stableOptions.pinned === void 0 && stableOptions.budget === void 0 && stableOptions.readonly === void 0) {
25858
- throw new NoteError("nothing_to_do", "Nothing to change: provide edits, policy, an origin, a crumpled state, or a new address.");
25871
+ if (operations.length === 0 && stableOptions.origin === void 0 && stableOptions.description === void 0 && stableOptions.crumpled === void 0 && stableOptions.renameTo === void 0 && stableOptions.pinned === void 0 && stableOptions.budget === void 0 && stableOptions.readonly === void 0) {
25872
+ throw new NoteError("nothing_to_do", "Nothing to change: provide edits, a description, policy, an origin, a crumpled state, or a new address.");
25859
25873
  }
25860
25874
  const fromPath = physicalPath(from.scope, from.path, identity, from.who);
25861
25875
  const path = physicalPath(scope, destination.path, identity, destination.who);
@@ -25879,6 +25893,9 @@ function createNotesStore(input) {
25879
25893
  if (moved && targetRaw !== void 0) assertNoteUnlocked(parseNote(targetRaw).meta, stableOptions.readonly);
25880
25894
  const beforeMeta = { ...meta2 };
25881
25895
  applyNotePolicy(meta2, stableOptions);
25896
+ if (description === void 0) {
25897
+ if (stableOptions.description !== void 0) delete meta2.description;
25898
+ } else meta2.description = description;
25882
25899
  meta2.scope = scope;
25883
25900
  if (from.scope !== "session" && scope === "session") meta2.project = identity.projectKey;
25884
25901
  if (from.scope === "session" && scope !== "session") delete meta2.project;
@@ -25907,10 +25924,11 @@ function createNotesStore(input) {
25907
25924
  const bodyChanged = body !== next;
25908
25925
  const originChanged = beforeMeta.origin !== meta2.origin;
25909
25926
  const policyChanged = beforeMeta.pinned !== meta2.pinned || beforeMeta.budget !== meta2.budget || beforeMeta.readonly !== meta2.readonly;
25910
- if (bodyChanged || originChanged || policyChanged || moved) meta2.updatedAt = writeStamp();
25927
+ const descriptionChanged = beforeMeta.description !== meta2.description;
25928
+ if (bodyChanged || originChanged || policyChanged || descriptionChanged || moved) meta2.updatedAt = writeStamp();
25911
25929
  const serialized = serializeNote(meta2, next);
25912
25930
  assertSerializedSize(serialized);
25913
- const metadataChanged = originChanged || policyChanged || beforeMeta.crumpledAt !== meta2.crumpledAt;
25931
+ const metadataChanged = originChanged || policyChanged || descriptionChanged || beforeMeta.crumpledAt !== meta2.crumpledAt;
25914
25932
  let change;
25915
25933
  if (bodyChanged && (metadataChanged || moved)) change = { kind: "body", before: raw, after: serialized };
25916
25934
  else if (bodyChanged) change = { kind: "body", before: body, after: next };
@@ -26137,8 +26155,9 @@ var ORIGIN_VALUES = [typebox_exports.Literal("user"), typebox_exports.Literal("s
26137
26155
  var ORIGIN = typebox_exports.Optional(typebox_exports.Union([...ORIGIN_VALUES], {
26138
26156
  description: "Whose handwriting: user, self, or external. Leave it out to keep what's there."
26139
26157
  }));
26158
+ var DESCRIPTION_PARAMETER = typebox_exports.Optional(typebox_exports.String({ description: "One-line summary of what's inside and when to open it (max 160 chars). Empty string clears it." }));
26140
26159
  var POLICY_PARAMETERS = {
26141
- pinned: typebox_exports.Optional(typebox_exports.Boolean({ description: "Tape the page inside the cover: read whole at every wake-up. Five per notebook, CHEATSHEET and MAP included." })),
26160
+ pinned: typebox_exports.Optional(typebox_exports.Boolean({ description: "Tape the page inside the cover: read whole at every wake-up. Five per notebook, CHEATSHEET included." })),
26142
26161
  budget: typebox_exports.Optional(typebox_exports.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." })),
26143
26162
  readonly: typebox_exports.Optional(typebox_exports.Boolean({ description: "A paperclip that keeps your own hands off. `false` takes it off \u2014 same call is fine." }))
26144
26163
  };
@@ -26160,7 +26179,7 @@ function withWarnings(text2, data) {
26160
26179
  var CRUMPLED_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "`true` balls the page up: gone from list and search, still readable. `false` smooths it flat again." }));
26161
26180
  var CRUMPLED_LIST_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "Only the crumpled balls." }));
26162
26181
  var FILE_LIMIT_PARAMETER = typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "How many pages at most." }));
26163
- var GLOB_PARAMETER = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf \xB7 `MAP.md` that page in every notebook \xB7 `**` everything \xB7 `@sessions/*/**` every session." }));
26182
+ var GLOB_PARAMETER = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf \xB7 `CHEATSHEET.md` that page in every notebook \xB7 `**` everything \xB7 `@sessions/*/**` every session." }));
26164
26183
  var CWD_PARAMETER = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Treat this directory's project as `@project/`." }));
26165
26184
  var ADDRESS_PARAMETER = typebox_exports.String({ description: "Which drawer the page sits in. `plan.md` \u2014 this session's desk, cleared when it ends. `@project/` this project's shelf \xB7 `@human/` your human's file \xB7 `@self/` your own notebook \xB7 `@model/` your brain's. `@projects/<name>/`, `@sessions/<id>/`, `@agents/<name>/`, `@models/<name>/` \u2014 someone else's shelf: read only. Paper, not files: hand one to read/write/edit/bash and a real `@project` folder is born." });
26166
26185
  function failureOf(error2) {
@@ -26169,7 +26188,7 @@ function failureOf(error2) {
26169
26188
  if (isFilesystemError(error2)) return failure2("io_error", "notes operation failed");
26170
26189
  throw error2;
26171
26190
  }
26172
- var NORMALIZED_META_KEYS = /* @__PURE__ */ new Set(["scope", "origin", "createdAt", "updatedAt", "lastAccessed", "accessCount", "crumpledAt", "project", "pinned", "budget", "readonly"]);
26191
+ var NORMALIZED_META_KEYS = /* @__PURE__ */ new Set(["scope", "origin", "createdAt", "updatedAt", "lastAccessed", "accessCount", "crumpledAt", "project", "pinned", "budget", "readonly", "description"]);
26173
26192
  var MAX_METADATA_ENTRY_BYTES = 1024;
26174
26193
  var MAX_METADATA_VERBATIM_BYTES = 2048;
26175
26194
  var TOO_LARGE_EXTRA_VALUE = "[omitted: too large]";
@@ -26180,6 +26199,7 @@ var NoteMetadataSchema = typebox_exports.Object({
26180
26199
  updated_at: typebox_exports.String(),
26181
26200
  crumpled_at: typebox_exports.Optional(typebox_exports.String()),
26182
26201
  project: typebox_exports.Optional(typebox_exports.String()),
26202
+ description: typebox_exports.Optional(typebox_exports.String()),
26183
26203
  extra: typebox_exports.Record(typebox_exports.String(), typebox_exports.Unknown())
26184
26204
  }, { additionalProperties: false });
26185
26205
  function noteMetadata(meta2, address) {
@@ -26206,6 +26226,7 @@ function noteMetadata(meta2, address) {
26206
26226
  updated_at: localIso(meta2.updatedAt),
26207
26227
  ...typeof meta2.crumpledAt === "string" ? { crumpled_at: meta2.crumpledAt } : {},
26208
26228
  ...typeof meta2.project === "string" ? { project: meta2.project } : {},
26229
+ ...typeof meta2.description === "string" ? { description: meta2.description } : {},
26209
26230
  extra
26210
26231
  };
26211
26232
  }
@@ -26216,7 +26237,8 @@ function renderMetadata(metadata) {
26216
26237
  `created ${metadata.created_at}`,
26217
26238
  `updated ${metadata.updated_at}`,
26218
26239
  ...metadata.crumpled_at === void 0 ? [] : [`crumpled ${metadata.crumpled_at}`],
26219
- ...metadata.project === void 0 ? [] : [`project ${metadata.project}`]
26240
+ ...metadata.project === void 0 ? [] : [`project ${metadata.project}`],
26241
+ ...metadata.description === void 0 ? [] : [`description ${metadata.description}`]
26220
26242
  ];
26221
26243
  const extra = Object.keys(metadata.extra);
26222
26244
  if (extra.length > 0) fields.push(`extra ${JSON.stringify(metadata.extra)}`);
@@ -26243,7 +26265,8 @@ var ListedFileSchema = typebox_exports.Object({
26243
26265
  ...PolicySchema,
26244
26266
  ...WarningsSchema,
26245
26267
  updated_at: typebox_exports.String(),
26246
- crumpled_at: typebox_exports.Optional(typebox_exports.String())
26268
+ crumpled_at: typebox_exports.Optional(typebox_exports.String()),
26269
+ description: typebox_exports.Optional(typebox_exports.String())
26247
26270
  }, { additionalProperties: false });
26248
26271
  var MatchSchema = typebox_exports.Object({
26249
26272
  line: typebox_exports.Integer(),
@@ -26303,9 +26326,9 @@ function snapshot(rows, limit, status, renderData, shrink) {
26303
26326
  }
26304
26327
  function listedFile(row, identity) {
26305
26328
  const policy = policyAt(row.meta, row.address);
26306
- return { ...noteIdentity(identity, row.address), ...policy, warnings: row.warnings ?? (row.body === void 0 ? [] : noteBudgetWarnings(row.body, policy)), updated_at: localIso(row.meta.updatedAt), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt } };
26329
+ return { ...noteIdentity(identity, row.address), ...policy, warnings: row.warnings ?? (row.body === void 0 ? [] : noteBudgetWarnings(row.body, policy)), updated_at: localIso(row.meta.updatedAt), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt }, ...typeof row.meta.description === "string" ? { description: row.meta.description } : {} };
26307
26330
  }
26308
- var notesWriteParameters = typebox_exports.Object({ address: ADDRESS_PARAMETER, content: typebox_exports.String({ description: "The whole page." }), origin: ORIGIN, ...POLICY_PARAMETERS, cwd: CWD_PARAMETER }, { additionalProperties: false });
26331
+ var notesWriteParameters = typebox_exports.Object({ address: ADDRESS_PARAMETER, content: typebox_exports.String({ description: "The whole page." }), origin: ORIGIN, description: DESCRIPTION_PARAMETER, ...POLICY_PARAMETERS, cwd: CWD_PARAMETER }, { additionalProperties: false });
26309
26332
  function renderWriteData(data) {
26310
26333
  return withWarnings(`${data.outcome} ${renderIdentity(data)} | ${renderPolicy(data)}`, data);
26311
26334
  }
@@ -26319,7 +26342,7 @@ var notesWrite = {
26319
26342
  async execute(params, context2) {
26320
26343
  try {
26321
26344
  const identity = notesIdentityForCall(context2, params.cwd);
26322
- const { outcome, meta: meta2, warnings } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin, pinned: params.pinned, budget: params.budget, readonly: params.readonly });
26345
+ const { outcome, meta: meta2, warnings } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin, description: params.description, pinned: params.pinned, budget: params.budget, readonly: params.readonly });
26323
26346
  return success({ ...noteIdentity(identity, params.address), outcome, ...policyAt(meta2, params.address), warnings });
26324
26347
  } catch (error2) {
26325
26348
  return failureOf(error2);
@@ -26331,6 +26354,7 @@ var notesUpdateParameters = typebox_exports.Object({
26331
26354
  address: ADDRESS_PARAMETER,
26332
26355
  edits: typebox_exports.Optional(typebox_exports.Array(typebox_exports.Object({ oldText: typebox_exports.String({ description: "The passage as it stands on the page." }), newText: typebox_exports.String({ description: "What goes in its place." }) }, { additionalProperties: false }), { description: "Pen strokes, in order. Each `oldText` is the exact passage \u2014 same case, found once \u2014 and `newText` is what goes in its place." })),
26333
26356
  origin: ORIGIN,
26357
+ description: DESCRIPTION_PARAMETER,
26334
26358
  ...POLICY_PARAMETERS,
26335
26359
  crumpled: CRUMPLED_PARAMETER,
26336
26360
  replace_all: typebox_exports.Optional(typebox_exports.Boolean({ description: "Strike every copy of `oldText`, not just one." })),
@@ -26353,7 +26377,7 @@ var notesUpdate = {
26353
26377
  const identity = notesIdentityForCall(context2, params.cwd);
26354
26378
  const store = createNotesStore(identity);
26355
26379
  const renameTo = params.rename_to === "" ? void 0 : params.rename_to;
26356
- const { change, moved, meta: meta2, 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 });
26380
+ const { change, moved, meta: meta2, 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 });
26357
26381
  onChange?.(change);
26358
26382
  const from = noteIdentity(identity, params.address).address;
26359
26383
  const to = noteIdentity(identity, renameTo ?? params.address);
@@ -26405,7 +26429,7 @@ var notesListParameters = typebox_exports.Object({
26405
26429
  function renderListData(data) {
26406
26430
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
26407
26431
  for (const file of data.files) {
26408
- const fields = [`- ${renderIdentity(file)}`, renderPolicy(file), `updated ${file.updated_at}`];
26432
+ const fields = [file.description === void 0 ? `- ${renderIdentity(file)}` : `- ${renderIdentity(file)} \u2014 ${file.description}`, renderPolicy(file), `updated ${file.updated_at}`];
26409
26433
  if (file.last_accessed !== void 0) fields.push(`accessed ${file.last_accessed}`);
26410
26434
  if (file.crumpled_at !== void 0) fields.push(`crumpled ${file.crumpled_at}`);
26411
26435
  if (file.matches) fields.push(`${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
@@ -28256,7 +28280,6 @@ function localHistoryCorpus(options) {
28256
28280
  }
28257
28281
 
28258
28282
  // src/boot/text.ts
28259
- var SHELF_FRESH_LIMIT = 3;
28260
28283
  var WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
28261
28284
  var WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
28262
28285
  var NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
@@ -28298,24 +28321,25 @@ Still a tie? *shrugs* You've got a brain. Use it.
28298
28321
  Any other @ address is fake. End of discussion. @ addresses are not file paths: never pass them to file tools like \`read\`, \`write\`, \`edit\`, or \`bash\`.
28299
28322
  ${NOTES_PROTOCOL_CLOSE_TAG}`;
28300
28323
  var MAPS_BLOCK = `<notesoup:maps>
28301
- Every notebook's root has two default pins: \`CHEATSHEET.md\` and \`MAP.md\`.
28302
- Pinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next
28303
- reads them, and next is you. So keep them short, and keep them true.
28324
+ Each notebook has one default pin: \`CHEATSHEET.md\`. Pinned pages get jammed straight into your
28325
+ brain the moment you wake up. Whoever wakes up next reads them, and next is you. So keep them
28326
+ short, and keep them true.
28304
28327
 
28305
- Up to five pages per notebook can be taped inside the cover, these two included. Every page gets
28328
+ Up to five pages per notebook can be taped inside the cover, CHEATSHEET included. Every page gets
28306
28329
  a paper budget; when a page outgrows it, boil it down \u2014 stale lines out, repeats merged, the rest
28307
28330
  said shorter \u2014 instead of giving it more paper.
28308
28331
 
28309
28332
  - **\`CHEATSHEET.md\`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,
28310
28333
  a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
28311
28334
  and everybody pays for it.
28312
- - **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
28313
- enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
28314
- contents belong in their own notes \u2014 *taps the sign* not inline here.
28335
+ - **\`description\`** is one line saying what's inside a note and when to open it \u2014 max 160
28336
+ characters, set through your notes tools. Boot indexes every shelf from these,
28337
+ newest first, address and age beside them. No hand-written map to keep in sync: a stale
28338
+ description lies to the next window, so keep it true or crumple the page.
28315
28339
 
28316
28340
  Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
28317
- no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
28318
- line. And when a line goes wrong, stale, or useless, kill it \u2014 tomorrow's you reads that page as fact.
28341
+ no need to create empty ones. New rule worth remembering, new Cheatsheet line. And when a line
28342
+ goes wrong, stale, or useless, kill it \u2014 tomorrow's you reads that page as fact.
28319
28343
  </notesoup:maps>`;
28320
28344
  var DEFAULT_BOOT_TOOL_NAMES = {
28321
28345
  notes: "notes_*",
@@ -28350,14 +28374,30 @@ function relativeTime(timestamp, now) {
28350
28374
  const amount = `${Math.abs(Math.trunc(seconds / size))}${unit}`;
28351
28375
  return seconds > 0 ? `in ${amount}` : `${amount} ago`;
28352
28376
  }
28353
- var FEED_TITLE_MAX_CHARS = 40;
28377
+ var SHELF_INDEX_MAX_ENTRIES = 25;
28378
+ var SHELF_INDEX_MAX_CHARS = 4096;
28379
+ var FALLBACK_TITLE_MAX_CHARS = 80;
28380
+ function truncated(text2, max) {
28381
+ const chars = Array.from(text2);
28382
+ return chars.length > max ? `${chars.slice(0, max).join("")}\u2026` : chars.join("");
28383
+ }
28354
28384
  function feedTitle(body) {
28355
28385
  const lines = body.split("\n");
28356
28386
  const heading = lines.find((line) => /^#+\s+\S/.test(line));
28357
28387
  const raw = (heading ? heading.replace(/^#+\s+/, "") : lines.find((line) => line.trim().length > 0) ?? "").trim();
28358
- if (raw.length === 0) return void 0;
28359
- const chars = Array.from(raw);
28360
- return chars.length > FEED_TITLE_MAX_CHARS ? `${chars.slice(0, FEED_TITLE_MAX_CHARS).join("")}\u2026` : chars.join("");
28388
+ return raw.length === 0 ? void 0 : truncated(raw, FALLBACK_TITLE_MAX_CHARS);
28389
+ }
28390
+ function summaryOf(row) {
28391
+ if (typeof row.meta.description === "string") {
28392
+ const collapsed = collapseDescription(row.meta.description);
28393
+ return collapsed === void 0 ? void 0 : truncated(collapsed, MAX_DESCRIPTION_CHARS);
28394
+ }
28395
+ return feedTitle(row.body);
28396
+ }
28397
+ function indexLine(row, openedAt) {
28398
+ const locator = `${row.address} \xB7 ${relativeTime(row.meta.updatedAt, openedAt)}`;
28399
+ const summary = summaryOf(row);
28400
+ return summary === void 0 ? ` ${locator}` : ` ${locator} \u2014 ${summary}`;
28361
28401
  }
28362
28402
  function indent(text2) {
28363
28403
  return text2.split("\n").map((line) => line.length > 0 ? ` ${line}` : line).join("\n");
@@ -28385,13 +28425,20 @@ function notesIndex(snapshot2, tools2, agentName, modelName) {
28385
28425
  const rows = (snapshot2.namespaces.get(namespace.scope) ?? []).filter((row) => row.meta.crumpledAt === void 0);
28386
28426
  const pins = rows.filter((row) => effectiveNotePolicy(row.meta, row.path).pinned).sort((a, b) => pinnedPageOrder(a.path) - pinnedPageOrder(b.path) || a.path.localeCompare(b.path));
28387
28427
  const pinned = pins.slice(0, MAX_PINNED_NOTES);
28388
- const fresh = rows.filter((row) => !effectiveNotePolicy(row.meta, row.path).pinned).slice(0, SHELF_FRESH_LIMIT).map((row) => {
28389
- const locator = `${row.address} \xB7 ${relativeTime(row.meta.updatedAt, snapshot2.openedAt)}`;
28390
- const title = feedTitle(row.body);
28391
- return title === void 0 ? ` ${locator}` : ` ${title}
28392
- ${locator}`;
28393
- });
28394
- if (pinned.length === 0 && fresh.length === 0) continue;
28428
+ const unpinned = rows.filter((row) => !effectiveNotePolicy(row.meta, row.path).pinned);
28429
+ const index = [];
28430
+ let usedChars = 0;
28431
+ for (const row of unpinned) {
28432
+ if (index.length >= SHELF_INDEX_MAX_ENTRIES) break;
28433
+ const line = indexLine(row, snapshot2.openedAt);
28434
+ const nextChars = usedChars + (index.length > 0 ? 1 : 0) + line.length;
28435
+ if (index.length > 0 && nextChars > SHELF_INDEX_MAX_CHARS) break;
28436
+ index.push(line);
28437
+ usedChars = nextChars;
28438
+ }
28439
+ const omitted = unpinned.length - index.length;
28440
+ if (omitted > 0) index.push(` \u2026 and ${omitted} more (use ${tools2.notesList})`);
28441
+ if (pinned.length === 0 && index.length === 0) continue;
28395
28442
  const parts = pinned.map((row) => {
28396
28443
  const warnings = noteBudgetWarnings(row.body, effectiveNotePolicy(row.meta, row.path));
28397
28444
  return `${row.address}
@@ -28399,9 +28446,9 @@ function notesIndex(snapshot2, tools2, agentName, modelName) {
28399
28446
  ${indent([...warnings, row.body].join("\n"))}`;
28400
28447
  });
28401
28448
  if (pins.length > MAX_PINNED_NOTES) 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 ${tools2.notes}.`));
28402
- if (fresh.length > 0) parts.push(`recent
28449
+ if (index.length > 0) parts.push(pinned.length > 0 ? `notes
28403
28450
 
28404
- ${fresh.join("\n\n")}`);
28451
+ ${index.join("\n")}` : index.join("\n"));
28405
28452
  shelves.push(section(namespace.label, parts.join("\n\n")));
28406
28453
  }
28407
28454
  return shelves.length > 0 ? ["YOUR NOTES\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500", ...shelves].join("\n\n\n") : "YOUR NOTES\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nNone yet. A blank slate is a fine place to start \u2014 just don't finish there.";
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: dream
3
- description: Review and consolidate durable notes using notesoup's shared dream playbook. Use when the human asks to dream over notes, merge genuine duplicates, update maps, or promote durable findings.
3
+ description: Review and consolidate durable notes using notesoup's shared dream playbook. Use when the human asks to dream over notes, merge genuine duplicates, audit descriptions, or promote durable findings.
4
4
  ---
5
5
 
6
6
  # Dream
7
7
 
8
- Read `../../playbook.md` completely, resolving the path from this skill's directory. It is the shared guide to reviewing and organizing notes. Standing reminders belong in a separate `CHEATSHEET.md` (five lines); `MAP.md` holds only the note index. Both default to pinned and load every window when live unless explicitly unpinned. Ordinary notes default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md` and `MAP.md`), adjustable per note; pinned bodies load whole with overflow warnings. Respect soft readonly locks; explicitly unlock with `readonly:false` before changing a locked note.
8
+ Read `../../playbook.md` completely, resolving the path from this skill's directory. It is the shared guide to reviewing and organizing notes. Standing reminders belong in a separate `CHEATSHEET.md` (five lines), the one default-pinned page; it loads every window when live unless explicitly unpinned. Every durable note carries a one-line `description` (max 160 characters) saying what it holds and when to open it — boot renders each notebook's index from these, so a missing or stale description is an index defect. Ordinary notes default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md`), adjustable per note; pinned bodies load whole with overflow warnings. Respect soft readonly locks; explicitly unlock with `readonly:false` before changing a locked note.
9
9
 
10
10
  Dream in this agent's current session. Do not start another agent or model unless the human asks.
11
11
 
@@ -32,7 +32,7 @@ Any other `@` prefix is refused. A path is relative and `/`-separated, with no e
32
32
 
33
33
  `@` addresses are not file paths: never pass them to file tools like `read`, `write`, `edit`, or `bash`. That creates a stray directory instead of a note.
34
34
 
35
- `CHEATSHEET.md` and `MAP.md` at each notebook's root are separate default-pinned pages you wake up with; absent or crumpled pages are skipped. Set `pinned`, `budget`, and `readonly` through `notes_write`/`notes_update` or frontmatter. Explicit `pinned:false` unpins even a default page. Each notebook allows five live pins; ordinary pages default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md` and `MAP.md`), adjustable per note. Overflow warns but saves, and pinned bodies load whole. `readonly:true` is a soft lock, not security; explicitly set `readonly:false` to unlock, alone or alongside your changes. Keep standing reminders in `CHEATSHEET.md`, to five lines. `MAP.md` holds only the note index: each durable note's address and gist, for lookup. Update it whenever you add, move or crumple a durable note. Do not create empty pages.
35
+ `CHEATSHEET.md` at each notebook's root is the default-pinned page you wake up with; absent or crumpled pages are skipped. Set `pinned`, `budget`, and `readonly` through `notes_write`/`notes_update` or frontmatter. Explicit `pinned:false` unpins even a default page. Each notebook allows five live pins; ordinary pages default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md`), adjustable per note. Overflow warns but saves, and pinned bodies load whole. `readonly:true` is a soft lock, not security; explicitly set `readonly:false` to unlock, alone or alongside your changes. Keep standing reminders in `CHEATSHEET.md`, to five lines. Give each durable note a one-line `description` (max 160 characters, set with `notes_write`/`notes_update`): boot lists every notebook's unpinned pages newest first as address, age, and description, so it is the only index. Do not create empty pages.
36
36
 
37
37
  Keep notes focused on what is true now; if a piece of past context still matters (such as why an approach was ruled out), keep only a brief summary rather than a blow-by-blow log. Crumple notes that are no longer true; a stale note is worse than none.
38
38