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
@@ -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) {
@@ -25695,6 +25705,13 @@ function assertOrigin(value) {
25695
25705
  if (!isOrigin(value)) throw new NoteError("invalid_origin", `origin must be one of user, self, external (got ${JSON.stringify(value)})`);
25696
25706
  return value;
25697
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
+ }
25698
25715
  function assertWho(value, scope) {
25699
25716
  if (typeof value !== "string" || !(scope === "session" ? isSessionId(value) : SLUG_PATTERN.test(value))) {
25700
25717
  throw new NoteError("invalid_scope", scope === "session" ? "session id must be a safe single directory component" : "who must be a canonical lowercase slug");
@@ -25784,6 +25801,7 @@ function createNotesStore(input) {
25784
25801
  async function write(address, content, options = {}) {
25785
25802
  const stableOptions = { ...options };
25786
25803
  validateNotePolicy(stableOptions);
25804
+ const description = stableOptions.description === void 0 ? void 0 : normalizeDescription(stableOptions.description);
25787
25805
  const destination = assertAddress(address);
25788
25806
  assertWritablePath(destination.path);
25789
25807
  const scope = destination.scope;
@@ -25811,6 +25829,9 @@ function createNotesStore(input) {
25811
25829
  };
25812
25830
  meta2.scope = scope;
25813
25831
  applyNotePolicy(meta2, stableOptions);
25832
+ if (description === void 0) {
25833
+ if (stableOptions.description !== void 0) delete meta2.description;
25834
+ } else meta2.description = description;
25814
25835
  if (origin !== void 0) meta2.origin = origin;
25815
25836
  delete meta2.crumpledAt;
25816
25837
  meta2.updatedAt = now;
@@ -25840,14 +25861,15 @@ function createNotesStore(input) {
25840
25861
  const operations = edits === void 0 ? [] : edits.map((operation) => ({ ...operation }));
25841
25862
  const stableOptions = { ...options };
25842
25863
  validateNotePolicy(stableOptions);
25864
+ const description = stableOptions.description === void 0 ? void 0 : normalizeDescription(stableOptions.description);
25843
25865
  const from = assertAddress(address);
25844
25866
  const destination = stableOptions.renameTo === void 0 ? from : assertAddress(stableOptions.renameTo);
25845
25867
  assertWritablePath(destination.path);
25846
25868
  const scope = destination.scope;
25847
25869
  assertWritableNamespace(from.scope, from.who, identity);
25848
25870
  assertWritableNamespace(scope, destination.who, identity);
25849
- 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) {
25850
- 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.");
25851
25873
  }
25852
25874
  const fromPath = physicalPath(from.scope, from.path, identity, from.who);
25853
25875
  const path = physicalPath(scope, destination.path, identity, destination.who);
@@ -25871,6 +25893,9 @@ function createNotesStore(input) {
25871
25893
  if (moved && targetRaw !== void 0) assertNoteUnlocked(parseNote(targetRaw).meta, stableOptions.readonly);
25872
25894
  const beforeMeta = { ...meta2 };
25873
25895
  applyNotePolicy(meta2, stableOptions);
25896
+ if (description === void 0) {
25897
+ if (stableOptions.description !== void 0) delete meta2.description;
25898
+ } else meta2.description = description;
25874
25899
  meta2.scope = scope;
25875
25900
  if (from.scope !== "session" && scope === "session") meta2.project = identity.projectKey;
25876
25901
  if (from.scope === "session" && scope !== "session") delete meta2.project;
@@ -25899,10 +25924,11 @@ function createNotesStore(input) {
25899
25924
  const bodyChanged = body !== next;
25900
25925
  const originChanged = beforeMeta.origin !== meta2.origin;
25901
25926
  const policyChanged = beforeMeta.pinned !== meta2.pinned || beforeMeta.budget !== meta2.budget || beforeMeta.readonly !== meta2.readonly;
25902
- 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();
25903
25929
  const serialized = serializeNote(meta2, next);
25904
25930
  assertSerializedSize(serialized);
25905
- const metadataChanged = originChanged || policyChanged || beforeMeta.crumpledAt !== meta2.crumpledAt;
25931
+ const metadataChanged = originChanged || policyChanged || descriptionChanged || beforeMeta.crumpledAt !== meta2.crumpledAt;
25906
25932
  let change;
25907
25933
  if (bodyChanged && (metadataChanged || moved)) change = { kind: "body", before: raw, after: serialized };
25908
25934
  else if (bodyChanged) change = { kind: "body", before: body, after: next };
@@ -26129,8 +26155,9 @@ var ORIGIN_VALUES = [typebox_exports.Literal("user"), typebox_exports.Literal("s
26129
26155
  var ORIGIN = typebox_exports.Optional(typebox_exports.Union([...ORIGIN_VALUES], {
26130
26156
  description: "Whose handwriting: user, self, or external. Leave it out to keep what's there."
26131
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." }));
26132
26159
  var POLICY_PARAMETERS = {
26133
- 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." })),
26134
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." })),
26135
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." }))
26136
26163
  };
@@ -26152,7 +26179,7 @@ function withWarnings(text2, data) {
26152
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." }));
26153
26180
  var CRUMPLED_LIST_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "Only the crumpled balls." }));
26154
26181
  var FILE_LIMIT_PARAMETER = typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "How many pages at most." }));
26155
- 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." }));
26156
26183
  var CWD_PARAMETER = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Treat this directory's project as `@project/`." }));
26157
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." });
26158
26185
  function failureOf(error2) {
@@ -26161,7 +26188,7 @@ function failureOf(error2) {
26161
26188
  if (isFilesystemError(error2)) return failure2("io_error", "notes operation failed");
26162
26189
  throw error2;
26163
26190
  }
26164
- 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"]);
26165
26192
  var MAX_METADATA_ENTRY_BYTES = 1024;
26166
26193
  var MAX_METADATA_VERBATIM_BYTES = 2048;
26167
26194
  var TOO_LARGE_EXTRA_VALUE = "[omitted: too large]";
@@ -26172,6 +26199,7 @@ var NoteMetadataSchema = typebox_exports.Object({
26172
26199
  updated_at: typebox_exports.String(),
26173
26200
  crumpled_at: typebox_exports.Optional(typebox_exports.String()),
26174
26201
  project: typebox_exports.Optional(typebox_exports.String()),
26202
+ description: typebox_exports.Optional(typebox_exports.String()),
26175
26203
  extra: typebox_exports.Record(typebox_exports.String(), typebox_exports.Unknown())
26176
26204
  }, { additionalProperties: false });
26177
26205
  function noteMetadata(meta2, address) {
@@ -26198,6 +26226,7 @@ function noteMetadata(meta2, address) {
26198
26226
  updated_at: localIso(meta2.updatedAt),
26199
26227
  ...typeof meta2.crumpledAt === "string" ? { crumpled_at: meta2.crumpledAt } : {},
26200
26228
  ...typeof meta2.project === "string" ? { project: meta2.project } : {},
26229
+ ...typeof meta2.description === "string" ? { description: meta2.description } : {},
26201
26230
  extra
26202
26231
  };
26203
26232
  }
@@ -26208,7 +26237,8 @@ function renderMetadata(metadata) {
26208
26237
  `created ${metadata.created_at}`,
26209
26238
  `updated ${metadata.updated_at}`,
26210
26239
  ...metadata.crumpled_at === void 0 ? [] : [`crumpled ${metadata.crumpled_at}`],
26211
- ...metadata.project === void 0 ? [] : [`project ${metadata.project}`]
26240
+ ...metadata.project === void 0 ? [] : [`project ${metadata.project}`],
26241
+ ...metadata.description === void 0 ? [] : [`description ${metadata.description}`]
26212
26242
  ];
26213
26243
  const extra = Object.keys(metadata.extra);
26214
26244
  if (extra.length > 0) fields.push(`extra ${JSON.stringify(metadata.extra)}`);
@@ -26235,7 +26265,8 @@ var ListedFileSchema = typebox_exports.Object({
26235
26265
  ...PolicySchema,
26236
26266
  ...WarningsSchema,
26237
26267
  updated_at: typebox_exports.String(),
26238
- 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())
26239
26270
  }, { additionalProperties: false });
26240
26271
  var MatchSchema = typebox_exports.Object({
26241
26272
  line: typebox_exports.Integer(),
@@ -26295,9 +26326,9 @@ function snapshot(rows, limit, status, renderData, shrink) {
26295
26326
  }
26296
26327
  function listedFile(row, identity) {
26297
26328
  const policy = policyAt(row.meta, row.address);
26298
- 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 } : {} };
26299
26330
  }
26300
- 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 });
26301
26332
  function renderWriteData(data) {
26302
26333
  return withWarnings(`${data.outcome} ${renderIdentity(data)} | ${renderPolicy(data)}`, data);
26303
26334
  }
@@ -26311,7 +26342,7 @@ var notesWrite = {
26311
26342
  async execute(params, context2) {
26312
26343
  try {
26313
26344
  const identity = notesIdentityForCall(context2, params.cwd);
26314
- 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 });
26315
26346
  return success({ ...noteIdentity(identity, params.address), outcome, ...policyAt(meta2, params.address), warnings });
26316
26347
  } catch (error2) {
26317
26348
  return failureOf(error2);
@@ -26323,6 +26354,7 @@ var notesUpdateParameters = typebox_exports.Object({
26323
26354
  address: ADDRESS_PARAMETER,
26324
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." })),
26325
26356
  origin: ORIGIN,
26357
+ description: DESCRIPTION_PARAMETER,
26326
26358
  ...POLICY_PARAMETERS,
26327
26359
  crumpled: CRUMPLED_PARAMETER,
26328
26360
  replace_all: typebox_exports.Optional(typebox_exports.Boolean({ description: "Strike every copy of `oldText`, not just one." })),
@@ -26345,7 +26377,7 @@ var notesUpdate = {
26345
26377
  const identity = notesIdentityForCall(context2, params.cwd);
26346
26378
  const store = createNotesStore(identity);
26347
26379
  const renameTo = params.rename_to === "" ? void 0 : params.rename_to;
26348
- 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 });
26349
26381
  onChange?.(change);
26350
26382
  const from = noteIdentity(identity, params.address).address;
26351
26383
  const to = noteIdentity(identity, renameTo ?? params.address);
@@ -26397,7 +26429,7 @@ var notesListParameters = typebox_exports.Object({
26397
26429
  function renderListData(data) {
26398
26430
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
26399
26431
  for (const file of data.files) {
26400
- 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}`];
26401
26433
  if (file.last_accessed !== void 0) fields.push(`accessed ${file.last_accessed}`);
26402
26434
  if (file.crumpled_at !== void 0) fields.push(`crumpled ${file.crumpled_at}`);
26403
26435
  if (file.matches) fields.push(`${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
@@ -28248,7 +28280,6 @@ function localHistoryCorpus(options) {
28248
28280
  }
28249
28281
 
28250
28282
  // src/boot/text.ts
28251
- var SHELF_FRESH_LIMIT = 3;
28252
28283
  var WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
28253
28284
  var WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
28254
28285
  var NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
@@ -28290,24 +28321,25 @@ Still a tie? *shrugs* You've got a brain. Use it.
28290
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\`.
28291
28322
  ${NOTES_PROTOCOL_CLOSE_TAG}`;
28292
28323
  var MAPS_BLOCK = `<notesoup:maps>
28293
- Every notebook's root has two default pins: \`CHEATSHEET.md\` and \`MAP.md\`.
28294
- Pinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next
28295
- 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.
28296
28327
 
28297
- 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
28298
28329
  a paper budget; when a page outgrows it, boil it down \u2014 stale lines out, repeats merged, the rest
28299
28330
  said shorter \u2014 instead of giving it more paper.
28300
28331
 
28301
28332
  - **\`CHEATSHEET.md\`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,
28302
28333
  a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
28303
28334
  and everybody pays for it.
28304
- - **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
28305
- enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
28306
- 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.
28307
28339
 
28308
28340
  Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
28309
- no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
28310
- 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.
28311
28343
  </notesoup:maps>`;
28312
28344
  var DEFAULT_BOOT_TOOL_NAMES = {
28313
28345
  notes: "notes_*",
@@ -28342,14 +28374,30 @@ function relativeTime(timestamp, now) {
28342
28374
  const amount = `${Math.abs(Math.trunc(seconds / size))}${unit}`;
28343
28375
  return seconds > 0 ? `in ${amount}` : `${amount} ago`;
28344
28376
  }
28345
- 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
+ }
28346
28384
  function feedTitle(body) {
28347
28385
  const lines = body.split("\n");
28348
28386
  const heading = lines.find((line) => /^#+\s+\S/.test(line));
28349
28387
  const raw = (heading ? heading.replace(/^#+\s+/, "") : lines.find((line) => line.trim().length > 0) ?? "").trim();
28350
- if (raw.length === 0) return void 0;
28351
- const chars = Array.from(raw);
28352
- 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}`;
28353
28401
  }
28354
28402
  function indent(text2) {
28355
28403
  return text2.split("\n").map((line) => line.length > 0 ? ` ${line}` : line).join("\n");
@@ -28377,13 +28425,20 @@ function notesIndex(snapshot2, tools2, agentName, modelName) {
28377
28425
  const rows = (snapshot2.namespaces.get(namespace.scope) ?? []).filter((row) => row.meta.crumpledAt === void 0);
28378
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));
28379
28427
  const pinned = pins.slice(0, MAX_PINNED_NOTES);
28380
- const fresh = rows.filter((row) => !effectiveNotePolicy(row.meta, row.path).pinned).slice(0, SHELF_FRESH_LIMIT).map((row) => {
28381
- const locator = `${row.address} \xB7 ${relativeTime(row.meta.updatedAt, snapshot2.openedAt)}`;
28382
- const title = feedTitle(row.body);
28383
- return title === void 0 ? ` ${locator}` : ` ${title}
28384
- ${locator}`;
28385
- });
28386
- 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;
28387
28442
  const parts = pinned.map((row) => {
28388
28443
  const warnings = noteBudgetWarnings(row.body, effectiveNotePolicy(row.meta, row.path));
28389
28444
  return `${row.address}
@@ -28391,9 +28446,9 @@ function notesIndex(snapshot2, tools2, agentName, modelName) {
28391
28446
  ${indent([...warnings, row.body].join("\n"))}`;
28392
28447
  });
28393
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}.`));
28394
- if (fresh.length > 0) parts.push(`recent
28449
+ if (index.length > 0) parts.push(pinned.length > 0 ? `notes
28395
28450
 
28396
- ${fresh.join("\n\n")}`);
28451
+ ${index.join("\n")}` : index.join("\n"));
28397
28452
  shelves.push(section(namespace.label, parts.join("\n\n")));
28398
28453
  }
28399
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
 
@@ -1,6 +1,8 @@
1
1
  import type { NotesNamespace, NotesSnapshot } from "./snapshot.js";
2
2
  import { effectiveNotePolicy, MAX_PINNED_NOTES, noteBudgetWarnings, pinnedPageOrder } from "../notes/policy.js";
3
- import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, NAMELESS_AGENT, SHELF_FRESH_LIMIT, renderProtocolBlock, type BootToolNames } from "./text.js";
3
+ import { collapseDescription, MAX_DESCRIPTION_CHARS } from "../notes/frontmatter.js";
4
+ import type { NoteRow } from "../notes/index.js";
5
+ import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, NAMELESS_AGENT, renderProtocolBlock, type BootToolNames } from "./text.js";
4
6
 
5
7
  function relativeTime(timestamp: number, now: number): string {
6
8
  const seconds = Math.trunc((timestamp - now) / 1000);
@@ -11,16 +13,38 @@ function relativeTime(timestamp: number, now: number): string {
11
13
  return seconds > 0 ? `in ${amount}` : `${amount} ago`;
12
14
  }
13
15
 
14
- /** A feed entry is announced in the note's own words: its first heading, else its first line, cut short. */
15
- const FEED_TITLE_MAX_CHARS = 40;
16
+ /** The shelf index is bounded: enough to find a page, never the whole drawer. */
17
+ export const SHELF_INDEX_MAX_ENTRIES = 25;
18
+ export const SHELF_INDEX_MAX_CHARS = 4096;
19
+ /** A fallback title is the note's own first heading or line, cut short. */
20
+ export const FALLBACK_TITLE_MAX_CHARS = 80;
21
+
22
+ function truncated(text: string, max: number): string {
23
+ const chars = Array.from(text);
24
+ return chars.length > max ? `${chars.slice(0, max).join("")}…` : chars.join("");
25
+ }
16
26
 
17
27
  function feedTitle(body: string): string | undefined {
18
28
  const lines = body.split("\n");
19
29
  const heading = lines.find((line) => /^#+\s+\S/.test(line));
20
30
  const raw = (heading ? heading.replace(/^#+\s+/, "") : lines.find((line) => line.trim().length > 0) ?? "").trim();
21
- if (raw.length === 0) return undefined;
22
- const chars = Array.from(raw);
23
- return chars.length > FEED_TITLE_MAX_CHARS ? `${chars.slice(0, FEED_TITLE_MAX_CHARS).join("")}…` : chars.join("");
31
+ return raw.length === 0 ? undefined : truncated(raw, FALLBACK_TITLE_MAX_CHARS);
32
+ }
33
+
34
+ /** A stale hand-edited description is cut for display; the authored value was already refused at write time. */
35
+ function summaryOf(row: NoteRow): string | undefined {
36
+ if (typeof row.meta.description === "string") {
37
+ const collapsed = collapseDescription(row.meta.description);
38
+ return collapsed === undefined ? undefined : truncated(collapsed, MAX_DESCRIPTION_CHARS);
39
+ }
40
+ return feedTitle(row.body);
41
+ }
42
+
43
+ /** One index entry: where the page sits, how fresh it is, and one line saying whether to open it. */
44
+ function indexLine(row: NoteRow, openedAt: number): string {
45
+ const locator = `${row.address} · ${relativeTime(row.meta.updatedAt, openedAt)}`;
46
+ const summary = summaryOf(row);
47
+ return summary === undefined ? ` ${locator}` : ` ${locator} — ${summary}`;
24
48
  }
25
49
 
26
50
  /** Two spaces of indent say "shelved content" without any furniture. */
@@ -33,7 +57,7 @@ function section(label: string, body: string): string {
33
57
  return `${label}\n${"─".repeat(Array.from(label).length)}\n\n${body}`;
34
58
  }
35
59
 
36
- /** One closed boot snapshot: five tabbed shelves, current hands first, durable last; each shelf keeps its pinned pages and its own freshest pages. */
60
+ /** 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. */
37
61
  function notesIndex(snapshot: NotesSnapshot, tools: BootToolNames, agentName: string, modelName: string): string {
38
62
  const namespaces: ReadonlyArray<{ scope: NotesNamespace["scope"]; label: string }> = [
39
63
  { scope: "session", label: "no @ — this session" },
@@ -53,21 +77,28 @@ function notesIndex(snapshot: NotesSnapshot, tools: BootToolNames, agentName: st
53
77
  const pins = rows.filter(row => effectiveNotePolicy(row.meta, row.path).pinned)
54
78
  .sort((a, b) => pinnedPageOrder(a.path) - pinnedPageOrder(b.path) || a.path.localeCompare(b.path));
55
79
  const pinned = pins.slice(0, MAX_PINNED_NOTES);
56
- const fresh = rows
57
- .filter(row => !effectiveNotePolicy(row.meta, row.path).pinned)
58
- .slice(0, SHELF_FRESH_LIMIT)
59
- .map((row) => {
60
- const locator = `${row.address} · ${relativeTime(row.meta.updatedAt, snapshot.openedAt)}`;
61
- const title = feedTitle(row.body);
62
- return title === undefined ? ` ${locator}` : ` ${title}\n ${locator}`;
63
- });
64
- if (pinned.length === 0 && fresh.length === 0) continue;
80
+ const unpinned = rows.filter(row => !effectiveNotePolicy(row.meta, row.path).pinned);
81
+ // Both caps count joined lines; the first entry is always admitted, so a huge shelf still
82
+ // shows its freshest page plus an honest count of what was left behind.
83
+ const index: string[] = [];
84
+ let usedChars = 0;
85
+ for (const row of unpinned) {
86
+ if (index.length >= SHELF_INDEX_MAX_ENTRIES) break;
87
+ const line = indexLine(row, snapshot.openedAt);
88
+ const nextChars = usedChars + (index.length > 0 ? 1 : 0) + line.length;
89
+ if (index.length > 0 && nextChars > SHELF_INDEX_MAX_CHARS) break;
90
+ index.push(line);
91
+ usedChars = nextChars;
92
+ }
93
+ const omitted = unpinned.length - index.length;
94
+ if (omitted > 0) index.push(` … and ${omitted} more (use ${tools.notesList})`);
95
+ if (pinned.length === 0 && index.length === 0) continue;
65
96
  const parts = pinned.map(row => {
66
97
  const warnings = noteBudgetWarnings(row.body, effectiveNotePolicy(row.meta, row.path));
67
98
  return `${row.address}\n\n${indent([...warnings, row.body].join("\n"))}`;
68
99
  });
69
100
  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 ${tools.notes}.`));
70
- if (fresh.length > 0) parts.push(`recent\n\n${fresh.join("\n\n")}`);
101
+ if (index.length > 0) parts.push(pinned.length > 0 ? `notes\n\n${index.join("\n")}` : index.join("\n"));
71
102
  shelves.push(section(namespace.label, parts.join("\n\n")));
72
103
  }
73
104
 
package/src/boot/text.ts CHANGED
@@ -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>";
@@ -58,24 +56,25 @@ ${NOTES_PROTOCOL_CLOSE_TAG}`;
58
56
  * Default pinned pages and per-note policy are taught between the protocol and the notes index.
59
57
  */
60
58
  export const MAPS_BLOCK = `<notesoup:maps>
61
- Every notebook's root has two default pins: \`CHEATSHEET.md\` and \`MAP.md\`.
62
- Pinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next
63
- reads them, and next is you. So keep them short, and keep them true.
59
+ Each notebook has one default pin: \`CHEATSHEET.md\`. Pinned pages get jammed straight into your
60
+ brain the moment you wake up. Whoever wakes up next reads them, and next is you. So keep them
61
+ short, and keep them true.
64
62
 
65
- Up to five pages per notebook can be taped inside the cover, these two included. Every page gets
63
+ Up to five pages per notebook can be taped inside the cover, CHEATSHEET included. Every page gets
66
64
  a paper budget; when a page outgrows it, boil it down — stale lines out, repeats merged, the rest
67
65
  said shorter — instead of giving it more paper.
68
66
 
69
67
  - **\`CHEATSHEET.md\`** holds what you'll want next time — a rule, a warning, a grudge, a name,
70
68
  a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
71
69
  and everybody pays for it.
72
- - **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
73
- enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
74
- contents belong in their own notes — *taps the sign* not inline here.
70
+ - **\`description\`** is one line saying what's inside a note and when to open it — max 160
71
+ characters, set through your notes tools. Boot indexes every shelf from these,
72
+ newest first, address and age beside them. No hand-written map to keep in sync: a stale
73
+ description lies to the next window, so keep it true or crumple the page.
75
74
 
76
75
  Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
77
- no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
78
- line. And when a line goes wrong, stale, or useless, kill it — tomorrow's you reads that page as fact.
76
+ no need to create empty ones. New rule worth remembering, new Cheatsheet line. And when a line
77
+ goes wrong, stale, or useless, kill it — tomorrow's you reads that page as fact.
79
78
  </notesoup:maps>`;
80
79
 
81
80
  /** Logical tool names are supplied by the composing host, not discovered here. */
@@ -33,7 +33,7 @@ export const WARNING_TIMING = "The reserve is nearly spent. The wipe lands at th
33
33
 
34
34
  /** The shared handoff instructions, used for both budget and manual close-outs. */
35
35
  export const WARNING_BODY =
36
- "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.";
36
+ "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.";
37
37
 
38
38
  export const WARNING_CALL = "Then call `empty_brain`. Nothing in between.";
39
39
 
@@ -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
 
3
3
  /** Typed store refusal. Edit locations are exposed in camelCase. */
4
4
  export class NoteError extends Error {
@@ -23,6 +23,8 @@ export type NoteMeta = NotePolicyFields & {
23
23
  recurrenceWindows?: string[];
24
24
  /** Project ownership on newly-created session notes; legacy/invalid values are preserved as-is. */
25
25
  project?: unknown;
26
+ /** One-line index entry: what the note holds and when to open it. */
27
+ description?: string;
26
28
  [key: string]: unknown;
27
29
  };
28
30
 
@@ -30,7 +32,16 @@ const SCOPES: readonly Scope[] = ["session", "project", "human", "agent", "model
30
32
  const ORIGINS: readonly Origin[] = ["user", "self", "external"];
31
33
  const TIMESTAMP_KEYS = ["createdAt", "updatedAt", "lastAccessed"] as const;
32
34
  /** Emission order, exactly the Design's key list. */
33
- const KNOWN_KEYS = ["pinned", "budget", "readonly", "origin", "crumpledAt", "createdAt", "updatedAt", "lastAccessed", "accessCount", "sourceWindow", "supersedes", "recurrenceCount", "recurrenceWindows"] as const;
35
+ const KNOWN_KEYS = ["pinned", "budget", "readonly", "description", "origin", "crumpledAt", "createdAt", "updatedAt", "lastAccessed", "accessCount", "sourceWindow", "supersedes", "recurrenceCount", "recurrenceWindows"] as const;
36
+
37
+ /** A note description is one line; longer is not a description, it is prose in the wrong place. */
38
+ export const MAX_DESCRIPTION_CHARS = 160;
39
+
40
+ /** Collapse any whitespace run to one space and trim; an empty result is no description. */
41
+ export function collapseDescription(value: string): string | undefined {
42
+ const collapsed = value.replace(/\s+/g, " ").trim();
43
+ return collapsed.length === 0 ? undefined : collapsed;
44
+ }
34
45
 
35
46
  const pad2 = (value: number) => String(value).padStart(2, "0");
36
47
 
@@ -131,6 +142,13 @@ export function parseNote(raw: string, now = Date.now()): { meta: NoteMeta; body
131
142
  meta.origin = isOrigin(meta.origin) ? meta.origin : "self";
132
143
  for (const key of TIMESTAMP_KEYS) meta[key] = toEpoch(meta[key], now);
133
144
  meta.accessCount = typeof meta.accessCount === "number" && Number.isFinite(meta.accessCount) ? meta.accessCount : 0;
145
+ // A hand-edited description is never allowed to break a boot: non-strings are absent, empty
146
+ // ones are dropped, and an oversized one is cut only when rendered.
147
+ if (meta.description !== undefined) {
148
+ const description = typeof meta.description === "string" ? collapseDescription(meta.description) : undefined;
149
+ if (description === undefined) delete meta.description;
150
+ else meta.description = description;
151
+ }
134
152
  return { meta: meta as NoteMeta, body };
135
153
  }
136
154