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
@@ -17,8 +17,9 @@ const ORIGIN_VALUES = [Type.Literal("user"), Type.Literal("self"), Type.Literal(
17
17
  const ORIGIN = Type.Optional(Type.Union([...ORIGIN_VALUES], {
18
18
  description: "Whose handwriting: user, self, or external. Leave it out to keep what's there.",
19
19
  }));
20
+ const DESCRIPTION_PARAMETER = Type.Optional(Type.String({ description: "One-line summary of what's inside and when to open it (max 160 chars). Empty string clears it." }));
20
21
  const POLICY_PARAMETERS = {
21
- pinned: Type.Optional(Type.Boolean({ description: "Tape the page inside the cover: read whole at every wake-up. Five per notebook, CHEATSHEET and MAP included." })),
22
+ pinned: Type.Optional(Type.Boolean({ description: "Tape the page inside the cover: read whole at every wake-up. Five per notebook, CHEATSHEET included." })),
22
23
  budget: Type.Optional(Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "How much paper the page gets. Writing past it still saves, with a warning. A page over budget gets boiled down: stale lines out, repeats merged, the rest said shorter. More paper is for a page already boiled down that still needs the room." })),
23
24
  readonly: Type.Optional(Type.Boolean({ description: "A paperclip that keeps your own hands off. `false` takes it off — same call is fine." })),
24
25
  };
@@ -39,7 +40,7 @@ function withWarnings(text: string, data: { warnings: string[] }): string {
39
40
  const CRUMPLED_PARAMETER = Type.Optional(Type.Boolean({ description: "`true` balls the page up: gone from list and search, still readable. `false` smooths it flat again." }));
40
41
  const CRUMPLED_LIST_PARAMETER = Type.Optional(Type.Boolean({ description: "Only the crumpled balls." }));
41
42
  const FILE_LIMIT_PARAMETER = Type.Optional(Type.Integer({ minimum: 1, description: "How many pages at most." }));
42
- const GLOB_PARAMETER = Type.Optional(Type.String({ minLength: 1, description: "Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf · `MAP.md` that page in every notebook · `**` everything · `@sessions/*/**` every session." }));
43
+ const GLOB_PARAMETER = Type.Optional(Type.String({ minLength: 1, description: "Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf · `CHEATSHEET.md` that page in every notebook · `**` everything · `@sessions/*/**` every session." }));
43
44
  const CWD_PARAMETER = Type.Optional(Type.String({ minLength: 1, description: "Treat this directory's project as `@project/`." }));
44
45
  const ADDRESS_PARAMETER = Type.String({ description: "Which drawer the page sits in. `plan.md` — this session's desk, cleared when it ends. `@project/` this project's shelf · `@human/` your human's file · `@self/` your own notebook · `@model/` your brain's. `@projects/<name>/`, `@sessions/<id>/`, `@agents/<name>/`, `@models/<name>/` — someone else's shelf: read only. Paper, not files: hand one to read/write/edit/bash and a real `@project` folder is born." });
45
46
 
@@ -56,7 +57,7 @@ export function failureOf(error: unknown): Outcome<never> {
56
57
  }
57
58
 
58
59
  /** Metadata keys this layer normalizes; everything else is exposed verbatim under `extra`. */
59
- const NORMALIZED_META_KEYS = new Set(["scope", "origin", "createdAt", "updatedAt", "lastAccessed", "accessCount", "crumpledAt", "project", "pinned", "budget", "readonly"]);
60
+ const NORMALIZED_META_KEYS = new Set(["scope", "origin", "createdAt", "updatedAt", "lastAccessed", "accessCount", "crumpledAt", "project", "pinned", "budget", "readonly", "description"]);
60
61
  /** One unrecognized entry, and the verbatim extras together, are bounded so `extra` cannot outgrow the read. */
61
62
  const MAX_METADATA_ENTRY_BYTES = 1024;
62
63
  const MAX_METADATA_VERBATIM_BYTES = 2048;
@@ -70,6 +71,7 @@ export const NoteMetadataSchema = Type.Object({
70
71
  updated_at: Type.String(),
71
72
  crumpled_at: Type.Optional(Type.String()),
72
73
  project: Type.Optional(Type.String()),
74
+ description: Type.Optional(Type.String()),
73
75
  extra: Type.Record(Type.String(), Type.Unknown()),
74
76
  }, { additionalProperties: false });
75
77
  export type NoteMetadata = Static<typeof NoteMetadataSchema>;
@@ -102,6 +104,7 @@ function noteMetadata(meta: NoteMeta, address: string): NoteMetadata {
102
104
  updated_at: localIso(meta.updatedAt),
103
105
  ...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
104
106
  ...(typeof meta.project === "string" ? { project: meta.project } : {}),
107
+ ...(typeof meta.description === "string" ? { description: meta.description } : {}),
105
108
  extra,
106
109
  };
107
110
  }
@@ -114,6 +117,7 @@ function renderMetadata(metadata: NoteMetadata): string {
114
117
  `updated ${metadata.updated_at}`,
115
118
  ...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
116
119
  ...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
120
+ ...(metadata.description === undefined ? [] : [`description ${metadata.description}`]),
117
121
  ];
118
122
  const extra = Object.keys(metadata.extra);
119
123
  if (extra.length > 0) fields.push(`extra ${JSON.stringify(metadata.extra)}`);
@@ -147,6 +151,7 @@ export const ListedFileSchema = Type.Object({
147
151
  ...WarningsSchema,
148
152
  updated_at: Type.String(),
149
153
  crumpled_at: Type.Optional(Type.String()),
154
+ description: Type.Optional(Type.String()),
150
155
  }, { additionalProperties: false });
151
156
 
152
157
  const MatchSchema = Type.Object({
@@ -228,10 +233,10 @@ export function snapshot<T extends { address: string }>(
228
233
 
229
234
  export function listedFile(row: Pick<NoteRow, "address" | "meta"> & { body?: string; warnings?: string[] }, identity: NotesIdentity): ListedFile {
230
235
  const policy = policyAt(row.meta, row.address);
231
- return { ...noteIdentity(identity, row.address), ...policy, warnings: row.warnings ?? (row.body === undefined ? [] : noteBudgetWarnings(row.body, policy)), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
236
+ return { ...noteIdentity(identity, row.address), ...policy, warnings: row.warnings ?? (row.body === undefined ? [] : noteBudgetWarnings(row.body, policy)), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }), ...(typeof row.meta.description === "string" ? { description: row.meta.description } : {}) };
232
237
  }
233
238
 
234
- export const notesWriteParameters = Type.Object({ address: ADDRESS_PARAMETER, content: Type.String({ description: "The whole page." }), origin: ORIGIN, ...POLICY_PARAMETERS, cwd: CWD_PARAMETER }, { additionalProperties: false });
239
+ export const notesWriteParameters = Type.Object({ address: ADDRESS_PARAMETER, content: Type.String({ description: "The whole page." }), origin: ORIGIN, description: DESCRIPTION_PARAMETER, ...POLICY_PARAMETERS, cwd: CWD_PARAMETER }, { additionalProperties: false });
235
240
 
236
241
  function renderWriteData(data: NotesWriteData): string {
237
242
  return withWarnings(`${data.outcome} ${renderIdentity(data)} | ${renderPolicy(data)}`, data);
@@ -244,7 +249,7 @@ export const notesWrite = {
244
249
  async execute(params: Static<typeof notesWriteParameters>, context: NotesToolContext): Promise<Outcome<NotesWriteData>> {
245
250
  try {
246
251
  const identity = notesIdentityForCall(context, params.cwd);
247
- const { outcome, meta, warnings } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin, pinned: params.pinned, budget: params.budget, readonly: params.readonly });
252
+ const { outcome, meta, warnings } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin, description: params.description, pinned: params.pinned, budget: params.budget, readonly: params.readonly });
248
253
  return success({ ...noteIdentity(identity, params.address), outcome, ...policyAt(meta, params.address), warnings });
249
254
  } catch (error) { return failureOf(error); }
250
255
  },
@@ -255,6 +260,7 @@ export const notesUpdateParameters = Type.Object({
255
260
  address: ADDRESS_PARAMETER,
256
261
  edits: Type.Optional(Type.Array(Type.Object({ oldText: Type.String({ description: "The passage as it stands on the page." }), newText: Type.String({ description: "What goes in its place." }) }, { additionalProperties: false }), { description: "Pen strokes, in order. Each `oldText` is the exact passage — same case, found once — and `newText` is what goes in its place." })),
257
262
  origin: ORIGIN,
263
+ description: DESCRIPTION_PARAMETER,
258
264
  ...POLICY_PARAMETERS,
259
265
  crumpled: CRUMPLED_PARAMETER,
260
266
  replace_all: Type.Optional(Type.Boolean({ description: "Strike every copy of `oldText`, not just one." })),
@@ -279,7 +285,7 @@ export const notesUpdate = {
279
285
  const store = createNotesStore(identity);
280
286
  // Empty filler is not a request: models that pass every parameter get the edit path.
281
287
  const renameTo = params.rename_to === "" ? undefined : params.rename_to;
282
- const { change, moved, meta, warnings } = await store.update(params.address, params.edits, { origin: params.origin, pinned: params.pinned, budget: params.budget, readonly: params.readonly, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
288
+ const { change, moved, meta, warnings } = await store.update(params.address, params.edits, { origin: params.origin, description: params.description, pinned: params.pinned, budget: params.budget, readonly: params.readonly, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
283
289
  onChange?.(change);
284
290
  const from = noteIdentity(identity, params.address).address;
285
291
  const to = noteIdentity(identity, renameTo ?? params.address);
@@ -327,7 +333,7 @@ export const notesListParameters = Type.Object({
327
333
  export function renderListData(data: Snapshot<NotesListData["files"][number] & { last_accessed?: string }>): string {
328
334
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
329
335
  for (const file of data.files) {
330
- const fields = [`- ${renderIdentity(file)}`, renderPolicy(file), `updated ${file.updated_at}`];
336
+ const fields = [file.description === undefined ? `- ${renderIdentity(file)}` : `- ${renderIdentity(file)} — ${file.description}`, renderPolicy(file), `updated ${file.updated_at}`];
331
337
  if (file.last_accessed !== undefined) fields.push(`accessed ${file.last_accessed}`);
332
338
  if (file.crumpled_at !== undefined) fields.push(`crumpled ${file.crumpled_at}`);
333
339
  if (file.matches) fields.push(`${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
@@ -1,14 +0,0 @@
1
- /** One held dream lock; only the holder that wrote the token removes it. */
2
- export type DreamLock = {
3
- path: string;
4
- token: string;
5
- };
6
- /** One lock per notes home: its Git history cannot audit concurrent dreams independently. */
7
- export declare function dreamLockPath(home: string): string;
8
- /**
9
- * Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
10
- * whatever its age; a crash-left lock is removed by hand after confirming no dream runs.
11
- */
12
- export declare function acquireDreamLock(path: string): DreamLock | undefined;
13
- /** Release only a lock this holder wrote; repeated release is harmless. */
14
- export declare function releaseDreamLock(lock: DreamLock): void;
@@ -1,29 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
- import { join } from "node:path";
4
- /** One lock per notes home: its Git history cannot audit concurrent dreams independently. */
5
- export function dreamLockPath(home) {
6
- return join(home, ".dream.lock");
7
- }
8
- /**
9
- * Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
10
- * whatever its age; a crash-left lock is removed by hand after confirming no dream runs.
11
- */
12
- export function acquireDreamLock(path) {
13
- const token = `${process.pid} ${randomUUID()}`;
14
- try {
15
- writeFileSync(path, token, { flag: "wx" });
16
- }
17
- catch {
18
- return undefined;
19
- }
20
- return { path, token };
21
- }
22
- /** Release only a lock this holder wrote; repeated release is harmless. */
23
- export function releaseDreamLock(lock) {
24
- try {
25
- if (readFileSync(lock.path, "utf8") === lock.token)
26
- unlinkSync(lock.path);
27
- }
28
- catch { /* already gone */ }
29
- }
package/src/dream/lock.ts DELETED
@@ -1,28 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
- import { join } from "node:path";
4
-
5
- /** One held dream lock; only the holder that wrote the token removes it. */
6
- export type DreamLock = { path: string; token: string };
7
-
8
- /** One lock per notes home: its Git history cannot audit concurrent dreams independently. */
9
- export function dreamLockPath(home: string): string {
10
- return join(home, ".dream.lock");
11
- }
12
-
13
- /**
14
- * Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
15
- * whatever its age; a crash-left lock is removed by hand after confirming no dream runs.
16
- */
17
- export function acquireDreamLock(path: string): DreamLock | undefined {
18
- const token = `${process.pid} ${randomUUID()}`;
19
- try { writeFileSync(path, token, { flag: "wx" }); } catch { return undefined; }
20
- return { path, token };
21
- }
22
-
23
- /** Release only a lock this holder wrote; repeated release is harmless. */
24
- export function releaseDreamLock(lock: DreamLock): void {
25
- try {
26
- if (readFileSync(lock.path, "utf8") === lock.token) unlinkSync(lock.path);
27
- } catch { /* already gone */ }
28
- }