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
@@ -1,7 +1,7 @@
1
1
  import { notesIdentityFromPi } from "../plugins/pi/notes/adapter.js";
2
2
  import { DEFAULT_BOOT_TOOL_NAMES, renderProtocolBlock } from "../src/boot/text.js";
3
3
  import assert from "node:assert/strict";
4
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { mkdirSync, rmSync, writeFileSync } from "node:fs";
5
5
  import fs from "node:fs/promises";
6
6
  import { syncBuiltinESMExports } from "node:module";
7
7
  import { dirname, join } from "node:path";
@@ -31,7 +31,6 @@ for (const scanFails of [false, true]) {
31
31
  const otherCtx = context(manager(), undefined, undefined, true, join(testEnvironment.cwd, "other-project"));
32
32
  const other = notesIdentityFromPi(otherCtx);
33
33
  assert.notEqual(other.projectKey, me.projectKey);
34
- const lockPath = join(me.home, ".dream.lock");
35
34
  const original = fs.readdir;
36
35
  let enter;
37
36
  let release;
@@ -52,20 +51,17 @@ for (const scanFails of [false, true]) {
52
51
  t.after(() => { release(); t.mock.restoreAll(); syncBuiltinESMExports(); });
53
52
  const opening = call(captured, "dream_begin", {}, ctx);
54
53
  await entered;
55
- assert.ok(existsSync(lockPath), "begin acquired ownership before the controlled scan await");
54
+ assert.equal(resultError(await call(captured, "dream_begin", {}, otherCtx)).code, "already_dreaming");
56
55
  assert.equal(resultError(await call(captured, "dream_begin", {}, ctx)).code, "already_dreaming");
57
56
  await runHandlers(captured, "session_shutdown", { type: "session_shutdown" }, ctx);
58
- assert.equal(existsSync(lockPath), false, "the registered shutdown handler releases pending ownership");
59
57
  assert.equal(resultError(await call(captured, "dream_end", {}, ctx)).code, "not_dreaming");
60
58
  const newer = resultData(await call(captured, "dream_begin", {}, otherCtx));
61
59
  assert.equal(newer.project, other.projectKey, "another project can immediately begin after shutdown");
62
- const newerToken = readFileSync(lockPath, "utf8");
63
60
  release();
64
61
  assert.equal(resultError(await opening).code, "cancelled", "the stale opener cannot return success or resurrect state");
65
- assert.equal(readFileSync(lockPath, "utf8"), newerToken, "stale cleanup cannot release the newer owner's token");
62
+ assert.equal(resultError(await call(captured, "dream_begin", {}, ctx)).code, "already_dreaming", "stale cleanup cannot unlock the newer dream");
66
63
  assert.equal(resultError(await call(captured, "dream_end", {}, ctx)).code, "not_dreaming");
67
64
  resultData(await call(captured, "dream_end", {}, otherCtx));
68
- assert.equal(existsSync(lockPath), false);
69
65
  });
70
66
  }
71
67
  test("notes_list browses and searches recent-first snapshots", async () => {
@@ -28,7 +28,7 @@ function fixture(t) {
28
28
  return { root, home, repo, marker, identity };
29
29
  }
30
30
  // Each participant imports the real built module and operates on the same disk.
31
- // Optional pauses widen publication/snapshot windows without faking fs outcomes.
31
+ // Pause immediately before publication, with the real writer transaction held.
32
32
  const claimWorker = `
33
33
  import fs from "node:fs";
34
34
  import { syncBuiltinESMExports } from "node:module";
@@ -42,35 +42,25 @@ function wait(name) {
42
42
  Atomics.wait(sleep, 0, 0, 5);
43
43
  }
44
44
  }
45
- function paused() { fs.writeFileSync(join(control, "paused"), ""); wait("continue"); }
46
45
  if (pause) {
47
- const mkdir = fs.mkdirSync, readdir = fs.readdirSync, read = fs.readFileSync;
48
- fs.mkdirSync = function(path, ...args) {
49
- const result = mkdir(path, ...args);
50
- if (pause === "publication" && path === join(home, "project", "api")) paused();
51
- return result;
52
- };
53
- fs.readdirSync = function(path, ...args) {
54
- const result = readdir(path, ...args);
55
- if (pause === "snapshot" && path === join(home, "project") && args.length === 0) paused();
56
- return result;
57
- };
58
- fs.readFileSync = function(path, ...args) {
59
- try { return read(path, ...args); } catch (error) {
60
- if (path === join(home, "project", "api", ".project") && error.code === "ENOENT") fs.writeFileSync(join(control, "missing"), "");
61
- throw error;
46
+ const rename = fs.renameSync;
47
+ fs.renameSync = function(from, to) {
48
+ if (to === join(home, "project", "api")) {
49
+ fs.writeFileSync(join(control, "paused"), "");
50
+ wait("continue");
62
51
  }
52
+ return rename(from, to);
63
53
  };
64
54
  syncBuiltinESMExports();
65
55
  }
66
- const { projectKey } = await import(${JSON.stringify(new URL("../src/notes/project-namespace.js", import.meta.url).href)});
56
+ const { projectKey, createNotesStore } = await import(${JSON.stringify(new URL("../src/notes/index.js", import.meta.url).href)});
67
57
  fs.writeFileSync(join(control, "ready"), "");
68
58
  wait("start");
69
59
  const key = projectKey(cwd, home);
70
- const dir = join(home, "project", key);
71
- const probe = join(dir, "probe-" + process.pid);
72
- fs.writeFileSync(probe, "usable");
73
- console.log(JSON.stringify({ key, marker: JSON.parse(fs.readFileSync(join(dir, ".project"), "utf8")), probe: fs.readFileSync(probe, "utf8") }));
60
+ const notes = createNotesStore({ home, projectKey: key, sessionId: "session", agent: "test", model: "test" });
61
+ const probe = "@project/probe-" + process.pid;
62
+ await notes.write(probe, "usable");
63
+ console.log(JSON.stringify({ key, marker: JSON.parse(fs.readFileSync(join(home, "project", key, ".project"), "utf8")), probe: (await notes.read(probe)).body }));
74
64
  `;
75
65
  async function waitForFile(path) {
76
66
  const deadline = Date.now() + 10_000;
@@ -93,6 +83,7 @@ function racer(t, root, cwd, home, pause = "") {
93
83
  });
94
84
  return {
95
85
  result,
86
+ kill: () => child.kill("SIGKILL"),
96
87
  wait: (stage) => waitForFile(join(control, stage)),
97
88
  release: (stage) => writeFileSync(join(control, stage), ""),
98
89
  };
@@ -118,7 +109,6 @@ test("sixteen first claimants converge on one usable notebook for root and remot
118
109
  assert.equal(new Set(keys).size, 1);
119
110
  assert.deepEqual(readdirSync(join(home, "project")), [keys[0]]);
120
111
  assert.equal(marker(keys[0]).id, remote ? "host/team/api" : cwd);
121
- assert.equal(existsSync(join(home, ".project-claim")), false);
122
112
  });
123
113
  });
124
114
  test("different concurrent identities retain distinct suffixes", async (t) => {
@@ -134,72 +124,28 @@ test("different concurrent identities retain distinct suffixes", async (t) => {
134
124
  assert.deepEqual(results.map(result => JSON.parse(result.stdout).key).sort(), ["api", "api-1"]);
135
125
  assert.deepEqual(readdirSync(join(home, "project")).sort(), ["api", "api-1"]);
136
126
  });
137
- test("a claimant waits for another process between directory creation and marker publication", async (t) => {
127
+ test("a killed claimant releases its transaction without publishing a partial notebook", async (t) => {
138
128
  const { root, home, repo } = fixture(t);
139
129
  const cwd = repo("api");
140
- const first = racer(t, root, cwd, home, "publication");
141
- await first.wait("ready");
142
- first.release("start");
143
- await first.wait("paused");
144
- assert.equal(existsSync(join(home, "project/api/.project")), false);
145
- const second = racer(t, root, cwd, home);
146
- await second.wait("ready");
147
- second.release("start");
148
- await delay(100);
149
- assert.deepEqual(readdirSync(join(home, "project")), ["api"]);
150
- first.release("continue");
151
- for (const result of await Promise.all([first.result, second.result])) {
152
- assert.equal(result.code, 0, result.stderr);
153
- assert.equal(JSON.parse(result.stdout).key, "api");
154
- }
155
- });
156
- test("a directory appearing after the snapshot waits for its marker before adoption or suffixing", async (t) => {
157
- for (const same of [true, false])
158
- await t.test(same ? "adopt matching root as remote" : "suffix a different identity", async (t) => {
159
- const { root, home, repo, marker } = fixture(t);
160
- const cwd = repo("api", "https://host/team/api");
161
- const worker = racer(t, root, cwd, home, "snapshot");
162
- await worker.wait("ready");
163
- worker.release("start");
164
- await worker.wait("paused");
165
- mkdirSync(join(home, "project/api"));
166
- worker.release("continue");
167
- await worker.wait("missing");
168
- writeFileSync(join(home, "project/api/.project"), JSON.stringify({ id: same ? cwd : "host/other/api", path: "/old/root" }));
169
- const result = await worker.result;
170
- assert.equal(result.code, 0, result.stderr);
171
- const key = same ? "api" : "api-1";
172
- assert.equal(JSON.parse(result.stdout).key, key);
173
- assert.deepEqual(marker(key), { id: "host/team/api", path: cwd });
174
- if (!same)
175
- assert.deepEqual(marker("api"), { id: "host/other/api", path: "/old/root" });
176
- });
177
- });
178
- test("an unfinished claim times out without silently allocating another notebook", async (t) => {
179
- const { root, home, repo } = fixture(t);
180
- const worker = racer(t, root, repo("api"), home, "snapshot");
181
- await worker.wait("ready");
182
- worker.release("start");
183
- await worker.wait("paused");
184
- mkdirSync(join(home, "project/api"));
185
- worker.release("continue");
186
- const result = await worker.result;
187
- assert.notEqual(result.code, 0);
188
- assert.match(result.stderr, /Timed out waiting for project claim.*api/);
189
- assert.deepEqual(readdirSync(join(home, "project")), ["api"]);
190
- assert.equal(existsSync(join(home, ".project-claim")), false);
191
- });
192
- test("a stuck claim lock has a bounded timeout and is never stolen", async (t) => {
193
- const { root, home, repo } = fixture(t);
194
- mkdirSync(join(home, ".project-claim"), { recursive: true });
195
- const worker = racer(t, root, repo("api"), home);
196
- await worker.wait("ready");
197
- worker.release("start");
198
- const result = await worker.result;
199
- assert.notEqual(result.code, 0);
200
- assert.match(result.stderr, /Timed out waiting for project claim.*\.project-claim/);
201
- assert.deepEqual(readdirSync(join(home, "project")), []);
202
- assert.equal(existsSync(join(home, ".project-claim")), true);
130
+ const stable = repo("stable");
131
+ assert.equal(projectKey(stable, home), "stable");
132
+ const holder = racer(t, root, cwd, home, "publication");
133
+ await holder.wait("ready");
134
+ holder.release("start");
135
+ await holder.wait("paused");
136
+ // An unchanged identity needs no writer lock. Another claimant cannot steal it.
137
+ assert.equal(projectKey(stable, home), "stable");
138
+ assert.throws(() => projectKey(cwd, home), /Timed out waiting for project claim/);
139
+ assert.deepEqual(readdirSync(join(home, "project")), ["stable"]);
140
+ assert.ok(holder.kill());
141
+ assert.equal((await holder.result).code, null);
142
+ const next = racer(t, root, cwd, home);
143
+ await next.wait("ready");
144
+ next.release("start");
145
+ const result = await next.result;
146
+ assert.equal(result.code, 0, result.stderr);
147
+ assert.deepEqual(JSON.parse(result.stdout), { key: "api", marker: { id: cwd, path: cwd }, probe: "usable" });
148
+ assert.deepEqual(readdirSync(join(home, "project")).sort(), ["api", "stable"]);
203
149
  });
204
150
  test("malformed marker evidence refuses instead of becoming an unmarked legacy notebook", t => {
205
151
  const { home, repo } = fixture(t);
@@ -210,7 +156,6 @@ test("malformed marker evidence refuses instead of becoming an unmarked legacy n
210
156
  assert.throws(() => projectKey(cwd, home), /Invalid project marker.*api/);
211
157
  assert.equal(readFileSync(join(home, "project/api/.project"), "utf8"), raw);
212
158
  assert.deepEqual(readdirSync(join(home, "project")), ["api"]);
213
- assert.equal(existsSync(join(home, ".project-claim")), false);
214
159
  }
215
160
  });
216
161
  function data(result) {
package/docs/dsh.md CHANGED
@@ -10,7 +10,7 @@ On load and before requests, preflight probes `systemPrompt.section`, `tools.reg
10
10
 
11
11
  ## Notes, boot and history
12
12
 
13
- `notesHome` defaults to `~/.agents/notes`; `agentName` defaults to `dsh`. The filesystem layout and addressing match Pi and Claude: bare paths are session notes, with `@project`, `@human`, `@self`, and `@model` durable notebooks. Project identity uses the shared `resolveProjectNamespace(cwd, notesHome)` resolver: readable slug notebooks with a `.project` marker, including repository/worktree and origin identity. Other marked projects are readable through `@projects/<name>/`; named-notebook reads do not update access metadata and named-notebook writes are refused. Receipts, boot protocol (including separate CHEATSHEET.md and MAP.md pages), and bounds come from the shared modules, not dsh copies. A model change changes subsequent tools' `@model` identity; the boot remains frozen until reset.
13
+ `notesHome` defaults to `~/.agents/notes`; `agentName` defaults to `dsh`. The filesystem layout and addressing match Pi and Claude: bare paths are session notes, with `@project`, `@human`, `@self`, and `@model` durable notebooks. Project identity uses the shared `resolveProjectNamespace(cwd, notesHome)` resolver: readable slug notebooks with a `.project` marker, including repository/worktree and origin identity. Other marked projects are readable through `@projects/<name>/`; named-notebook reads do not update access metadata and named-notebook writes are refused. Receipts, boot protocol (including root CHEATSHEET.md and the auto-generated per-shelf index), and bounds come from the shared modules, not dsh copies. A model change changes subsequent tools' `@model` identity; the boot remains frozen until reset.
14
14
 
15
15
  The boot is a `systemPrompt.section` at order **2450**, with `interpolate: false`. Shared snapshot/render functions read the five notebooks once, using a captured timestamp. Rendering is deterministic for those inputs. A `plugin:notesoup/window` record stores the ordinal, id, timestamp, digest and exact boot text. `agent/created` adopts it before the first assembly. Notes written later appear in the next window's boot. Missing records reconstruct from the notesoup compact checkpoint, or from the marked root system section. Neither path rereads notes or regenerates a summary. Records are informational; checkpoints control the model surface.
16
16
 
@@ -47,7 +47,7 @@ The reminder and close-out warning go through `agent.steer`. Close-out remains a
47
47
  | dsh versions | Tested against **0.2.1-alpha.2**. Capability checks do not establish wire or persistence compatibility with every newer preview. Run the scripted tests before upgrading. |
48
48
  | Model calls per reset | **0** auxiliary model calls. The agent's note-writing turns and fresh-window continuation still make ordinary calls. |
49
49
  | Retention | Surface node **0**, one boot/continuation checkpoint, and subsequent messages. An unfinished tool batch postpones reset; no partial tool pairs are discarded. |
50
- | Boot bounds | Up to **5 live pins** and **3 recent notes per notebook**, from the shared policy/renderer. Root CHEATSHEET/MAP default pinned; explicit `pinned:false` overrides. Ordinary pages default to a **4096-code-point advisory budget**; root CHEATSHEET/MAP default to **2048**, adjustable per note. Pinned bodies arrive **whole**, with over-budget warnings instead of truncation; manually over-cap pins are omitted with a visible address list. |
50
+ | Boot bounds | Up to **5 live pins** and a **bounded auto-generated per-shelf index** (up to 25 unpinned notes / 4096 chars per notebook), from the shared policy/renderer. Root `CHEATSHEET.md` defaults pinned; explicit `pinned:false` overrides. Ordinary pages default to a **4096-code-point advisory budget**; root `CHEATSHEET.md` defaults to **2048**, adjustable per note. Pinned bodies arrive **whole**, with over-budget warnings instead of truncation; manually over-cap pins are omitted with a visible address list. |
51
51
  | Tool output | Shared **32 KiB** bounds; use `next_offset_chars`, history cursors, or narrower filters. There is no unbounded hidden result. |
52
52
  | Warning timing | Steering enters the next step; a large current response/tool batch can spend the runway. The hard reserve protects the next balanced boundary, not an in-flight provider call. |
53
53
  | Unknown capacity | Countdown is **null** and automatic reserve checks skip. Add `models[].contextWindow` to `llm-deepseek`; explicit resets still work. |
@@ -47,14 +47,20 @@ The library returns full data, not tool envelopes or paginated/truncated output.
47
47
 
48
48
  Addresses are a relative path (a current-session note), `@project/`, `@human/`, `@self/`, `@model/`, or explicit `@projects/<slug>/`, `@sessions/<id>/`, `@agents/<slug>/` and `@models/<slug>/`. Named project and session addresses are read-only, including for rename sources and destinations. Session IDs use the same safe single-directory-component grammar as `NotesIdentity.sessionId`, not the agent/model slug grammar. Only the first character of an address is sigil-position: an unknown leading `@head` refuses, while `@` inside the path (`release@v1.md`, `@project/mail/alice@example.com.md`) is an ordinary character. Relative self/model addresses resolve to the supplied identity. Results show the current agent's and model's notes as `@self/` and `@model/`; only other agents' or models' notes carry an explicit `@agents/<slug>/` or `@models/<slug>/`. Globs accept either form. The disk layout remains `pi/session/<sessionId>/`, `project/<projectKey>/`, `human/`, `agents/<agent>/`, and `models/<model>/`. No data migration happens on library import or construction. Notes already using camelCase metadata retain their metadata; old snake_case keys are preserved as unrecognized extras, not interpreted or migrated. New session notes record the supplied project key.
49
49
 
50
+ ### Cross-process project claims
51
+
52
+ An unchanged project marker is resolved without a lock. To allocate a notebook, adopt a remote, or update its display path, the resolver takes a SQLite writer transaction on `<home>/.project-claim.sqlite` and checks the markers again. This requires the built-in `node:sqlite` (available without a flag in Node 22.13+) and a local filesystem. The database stores no notes. Leave the file in place: the transaction, not the file's existence, is the lock. A competing writer waits up to five seconds; if the holder exits, the OS releases its lock.
53
+
54
+ A new notebook is staged under the notes home and renamed into `project/` with its marker already present (both locations must be on the same filesystem). Killing a writer before the rename can leave a hidden staging directory, but it neither claims a name nor blocks other sessions. When upgrading, stop old Notesoup processes sharing the home before running the new version; the old directory lock and SQLite do not coordinate. No notes migration is needed.
55
+
50
56
  ## Per-note policy
51
57
 
52
- `NoteMeta` has optional `pinned?: boolean`, `budget?: number`, and `readonly?: boolean` fields. Set these in on-disk frontmatter or in write/update options. Values are validated on parse and mutation: booleans must be actual booleans; budget must be a positive safe integer. Invalid values raise `NoteError("invalid_policy", ...)` without saving. Unknown frontmatter remains intact across rewrites. As before, a leading frontmatter block in `write`'s **content** is stripped, not used to set metadata; use the options or edit the on-disk frontmatter instead.
58
+ `NoteMeta` has optional `pinned?: boolean`, `budget?: number`, `readonly?: boolean`, and `description?: string` fields. Set these in on-disk frontmatter or in write/update options. Policy values are validated on parse and mutation: booleans must be actual booleans; budget must be a positive safe integer. Invalid policy values raise `NoteError("invalid_policy", ...)` without saving. `description` collapses whitespace to a single line, clears on empty string, and refuses over 160 Unicode code points with `NoteError("invalid_description", ...)` on write/update. Unknown frontmatter remains intact across rewrites. As before, a leading frontmatter block in `write`'s **content** is stripped, not used to set metadata; use the options or edit the on-disk frontmatter instead.
53
59
 
54
- `effectiveNotePolicy(meta, path)` returns `{ pinned, budget, readonly }` for a notebook-relative Markdown path (`MAP.md`, not an `@` address). This is the shared default resolver used by storage, tools and boot:
60
+ `effectiveNotePolicy(meta, path)` returns `{ pinned, budget, readonly }` for a notebook-relative Markdown path (`CHEATSHEET.md`, not an `@` address). This is the shared default resolver used by storage, tools and boot:
55
61
 
56
- - Ordinary pages have a default budget of **4096 Unicode code points**; root `CHEATSHEET.md` and `MAP.md` default to **2048**, adjustable to any positive safe integer. `warnings` on write/update/rename results report body overflow but do not reject it. Astral characters count once. The separate serialized-file byte limit still applies.
57
- - Only root `CHEATSHEET.md` and `MAP.md` default to pinned; all other paths, including nested files with those names, default false. Explicit false overrides the default. Raw `meta` keeps absent policy fields absent, so implicit defaults are re-evaluated at a move's destination; explicitly set values travel with the note.
62
+ - Ordinary pages have a default budget of **4096 Unicode code points**; root `CHEATSHEET.md` defaults to **2048**, adjustable to any positive safe integer. `warnings` on write/update/rename results report body overflow but do not reject it. Astral characters count once. The separate serialized-file byte limit still applies.
63
+ - Only root `CHEATSHEET.md` defaults to pinned; all other paths, including nested files with that name, default false. Explicit false overrides the default. Raw `meta` keeps absent policy fields absent, so implicit defaults are re-evaluated at a move's destination; explicitly set values travel with the note.
58
64
  - Every physical notebook allows **5 live pins**, including existing default pages. Crumpled pins don't count. New pinning, writes that restore notes, explicit restores, and moves/renames all check admission and refuse with `pin_limit` before mutation if they would add a sixth pin. Same-notebook moves of an already-live pin don't consume another slot. Existing over-cap notes can still be edited, unpinned or crumpled. Boot defensively selects at most five pins, default-page-first then path order, visibly naming omitted pins in a manually over-cap notebook. Pinned bodies are injected whole, with budget warnings rather than truncation.
59
65
  - `readonly: true` is a **soft lock**, not an authorization/security boundary. Existing locked notes refuse changes, overwrite, crumple/restore, rename/move, and dream deletion with `readonly`. Explicit `readonly: false` permits a metadata-only unlock or unlock plus the requested mutation in one call. A new/unlocked note may be written and locked together. Replacing a locked crumpled move target also requires explicit false. Reads/access counters still write, and filesystem edits can bypass the lock.
60
66
 
@@ -64,7 +64,7 @@ After a manual safety reset, `context_with_system` checks the committed boundary
64
64
 
65
65
  Budget reminders are staged once per window at reserve plus reminder margin, then reserve plus warning runway. Hard reserve remains independent. Budget and command warnings use different types. The final budget warning notifies at first provider injection, not durability; early guidance stays UI-silent. Budget drafts are instance-local and discarded on abort, failed turn, transition or window mismatch. Active-window usage and the exact public `SettingsManager` authority determine thresholds.
66
66
 
67
- Pi and Claude use the same budget warning: budget timing, the handoff checklist, note maintenance (including updating and trimming pinned pages, CHEATSHEET.md and MAP.md by default), a warning against large tool outputs, then `empty_brain` and the countdown. Pi's manual warnings replace the budget opening with the `/empty` notice inside `<notesoup:budget_notice>`. Optional command text sits after the closing tag as plain text for the closing model's notes; separate human input during close-out is intercepted and carried, never steered. The first-tier reminder reports the remaining room, explains that notes survive the wipe, asks for updated notes and offers an optional `empty_brain`, warning that it also clears what the model says to the human right before emptying. Pi's fixed system protocol retains its existing pre-reset hints; warnings no longer repeat those or the tool's `last_word` description.
67
+ Pi and Claude use the same budget warning: budget timing, the handoff checklist, note maintenance (including updating and trimming pinned pages, `CHEATSHEET.md` by default, and keeping note descriptions accurate), a warning against large tool outputs, then `empty_brain` and the countdown. Pi's manual warnings replace the budget opening with the `/empty` notice inside `<notesoup:budget_notice>`. Optional command text sits after the closing tag as plain text for the closing model's notes; separate human input during close-out is intercepted and carried, never steered. The first-tier reminder reports the remaining room, explains that notes survive the wipe, asks for updated notes and offers an optional `empty_brain`, warning that it also clears what the model says to the human right before emptying. Pi's fixed system protocol retains its existing pre-reset hints; warnings no longer repeat those or the tool's `last_word` description.
68
68
 
69
69
  `before_agent_start` supplies fixed protocol/maps teaching through the public named system sections, without promoting any note body. The hidden user boot remains the closed per-window identity/notes snapshot. `context_with_system` selects that boot by durable window identity, using Pi's canonical checkpoint projection or legacy slicing, and removes only recognized top-level teaching from older combined boots in the request projection; raw history and note quotations remain unchanged. Missing boot aborts safely instead of exposing raw history. Usage estimates use the same projection decision, and pre-send checks include the complete system/tool state. `/tree` summaries are suppressed when crossing reset branches because native branch summarization bypasses this projection.
70
70
 
package/docs/skills.md CHANGED
@@ -18,10 +18,6 @@ One session dreams over one project at a time. New session notes record their pr
18
18
 
19
19
  ## The dream lock and Git audit
20
20
 
21
- `dream_begin` takes one exclusive `.dream.lock` for the whole notes home with a single O_CREAT|O_EXCL creation, then commits a baseline of that home to its Git repository (initialized on first use). The lock is home-wide, not per-project: concurrent dreams cannot interleave changes in the shared Git history. `dream_end` commits the dream's changes and releases the lock, so `git show` reviews a dream and `git revert` rolls it back. A session shutdown releases the lock without the final commit.
21
+ `dream_begin` takes a SQLite writer transaction on `<home>/.dream.lock.sqlite` and commits a Git baseline. Only one dream can run per notes home, even across projects; competing dreams refuse immediately. This lock is separate from project claims and does not block ordinary note reads or writes. The baseline and end commits snapshot the whole home, so they can include ordinary edits made by other sessions as well as edits made by the dream.
22
22
 
23
- An existing lock refuses a new dream regardless of its age. If a Pi process crashed mid-dream, remove the stale lock by hand after confirming no dream is running:
24
-
25
- ```sh
26
- rm "${NOTESOUP_HOME:-$HOME/.agents/notes}/.dream.lock"
27
- ```
23
+ `dream_end` commits and releases the lock. Session shutdown releases it without a final commit. If the process dies, the OS releases the lock; completed note edits stay on disk. Leave the SQLite file in place. Stop older processes sharing this home when upgrading: the old existence lock and the transaction lock do not coordinate.
@@ -75,7 +75,7 @@ With a non-empty `query`, `context: N` includes up to N events on each side of e
75
75
 
76
76
  A history read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments.
77
77
 
78
- `notes_write` and `notes_update` accept optional `pinned`, `budget`, and `readonly` policy fields. Their receipts, list/search rows, and read `metadata` expose the effective `pinned`, `budget`, and `readonly` values as structured fields **and visible text**. Successes also carry a `warnings` array (per file for list/search), rendered visibly when a body exceeds its budget: the default is 4096 Unicode code points for ordinary pages and 2048 for root `CHEATSHEET.md` and `MAP.md`, adjustable per note. Overflow saves successfully; boot injects full pinned bodies instead of cutting them. Pi's custom write/update/read renderers show policy and warnings even when collapsed, outside the expandable body/diff and clipped summary. A readonly note refuses mutations with `readonly` until explicitly unlocked with `readonly:false`; this is a soft lock, not security. Pin admission refuses a sixth live pin per notebook with `pin_limit`, including restore/move/rename. Invalid policy fields refuse with `invalid_policy`.
78
+ `notes_write` and `notes_update` accept optional `pinned`, `budget`, `readonly`, and `description` fields. Their receipts, list/search rows, and read `metadata` expose the effective `pinned`, `budget`, and `readonly` values as structured fields **and visible text** (with `description` included on read metadata and list/search rows when present). Successes also carry a `warnings` array (per file for list/search), rendered visibly when a body exceeds its budget: the default is 4096 Unicode code points for ordinary pages and 2048 for root `CHEATSHEET.md`, adjustable per note. Overflow saves successfully; boot injects full pinned bodies instead of cutting them. Pi's custom write/update/read renderers show policy and warnings even when collapsed, outside the expandable body/diff and clipped summary. A readonly note refuses mutations with `readonly` until explicitly unlocked with `readonly:false`; this is a soft lock, not security. Pin admission refuses a sixth live pin per notebook with `pin_limit`, including restore/move/rename. Invalid policy fields refuse with `invalid_policy`; a `description` over 160 Unicode code points refuses with `invalid_description`.
79
79
 
80
80
  A note read reports unrecognized frontmatter under `metadata.extra`; a value too large to carry, or past the verbatim budget, is named in place as `[omitted: too large]` under its key rather than delivered in part, and the value itself stays in the note file. A rename receipt uses `address` for the destination and `rename_from` for the source; it has no duplicate `rename_to` field.
81
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.60.0",
3
+ "version": "0.61.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
package/playbook.md CHANGED
@@ -22,12 +22,12 @@ Durable notes hold decisions, constraints, and lessons that stay true after the
22
22
 
23
23
  1. **Leave stable notes alone.** Change a note to incorporate new evidence, fix a verified error, retire a stale claim, merge a genuine duplicate, trim diary content, or split an oversized file, not merely to shorten or rephrase it. No change is a valid outcome.
24
24
  2. **Verify only what the proposed change depends on.** Before correcting, retiring, or promoting a conclusion, check the relevant evidence as needed. Do not revalidate every stable note or turn dream into a source-code audit. An unavailable referent is unverified, not proof that it is dead.
25
- 3. **Retire what is no longer true.** When evidence shows a durable note is stale, correct it in place; if nothing true remains, crumple it. Remove or fix its MAP line either way. A note's last access is a hint, not evidence: long-unread notes are candidates to check, not to crumple on sight. `dream_begin` lists each note's last access; reads during a dream leave no stamp, so reviewing a note does not make it look fresh.
25
+ 3. **Retire what is no longer true.** When evidence shows a durable note is stale, correct it in place; if nothing true remains, crumple it. Fix its `description` either way. A note's last access is a hint, not evidence: long-unread notes are candidates to check, not to crumple on sight. `dream_begin` lists each note's last access; reads during a dream leave no stamp, so reviewing a note does not make it look fresh.
26
26
  4. **Merge only genuine duplicates.** Merge two notes only when they share a topic and kind (checkpoint, design, log). First carry every fact, condition, and exception unique to the absorbed note into the survivor, then crumple the absorbed note. Otherwise keep both and record any unresolved conflict.
27
- 5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper notebook, move it there, preserving its metadata, and update both notebooks' maps. Do it, don't propose it. Propose only when the destination notebook itself is unclear.
27
+ 5. **Relocate misfiled notes.** When a standing ruling or the note's own `description` already names its proper notebook, move it there, preserving its metadata, and keep its `description` true. Do it, don't propose it. Propose only when the destination notebook itself is unclear.
28
28
  6. **Preserve meaning and provenance.** Keep facts, conditions, exceptions, uncertainty, authorship, and sources. When promoting a finding, cite its source. Do not relabel agent-authored material as human-authored. If its destination or authority is unclear, propose the promotion instead.
29
29
  7. **Keep notes manageable.** Aim below about 200 lines / 8KB per note. Split oversized notes by topic with one-line cross-links.
30
- 8. **Keep wake-up pages useful.** Each writable notebook's `CHEATSHEET.md` holds standing reminders, kept to five lines. Its `MAP.md` holds only the note index: durable notes' addresses and short gists. Both default to pinned and load every window when live unless explicitly unpinned; do not create empty pages. 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 without truncating a pinned body. Preserve standing rules, add promoted notes to the map, and drop entries that no longer hold.
30
+ 8. **Keep wake-up pages useful.** Each writable notebook's `CHEATSHEET.md` holds standing reminders, kept to five lines; it is the one default-pinned page and loads every window when live unless explicitly unpinned. Every durable note gets a one-line `description` (max 160 characters) saying what it holds and when to open it — boot lists each notebook's unpinned notes newest first from these, so a missing, stale, or vague description hides the page. A hand-written `MAP.md` is an ordinary note now; once its lines live in `description`s, crumple it. Do not create empty pages. 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 without truncating a pinned body. Preserve standing rules and keep descriptions true as notes are promoted or retired.
31
31
 
32
32
  ## Deleting
33
33
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.59.1",
3
+ "version": "0.61.0",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"