notesoup 0.53.1 → 0.54.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 (153) hide show
  1. package/README.md +2 -2
  2. package/dist/plugins/claude/src/helper.js +2 -1
  3. package/dist/plugins/claude/src/history.js +2 -3
  4. package/dist/plugins/claude/src/thresholds.js +4 -2
  5. package/dist/plugins/codex/src/hooks.js +1 -1
  6. package/dist/plugins/codex/src/identity.d.ts +1 -1
  7. package/dist/plugins/codex/src/identity.js +3 -3
  8. package/dist/plugins/codex/src/mcp.js +2 -1
  9. package/dist/plugins/codex/src/text.d.ts +1 -1
  10. package/dist/plugins/codex/src/text.js +2 -2
  11. package/dist/plugins/dsh/engine.js +2 -2
  12. package/dist/plugins/dsh/tools.js +8 -7
  13. package/dist/plugins/dsh/window.d.ts +1 -0
  14. package/dist/plugins/dsh/window.js +7 -3
  15. package/dist/plugins/pi/entries.d.ts +1 -0
  16. package/dist/plugins/pi/entries.js +1 -0
  17. package/dist/plugins/pi/history-tools.d.ts +1 -1
  18. package/dist/plugins/pi/history-tools.js +4 -4
  19. package/dist/plugins/pi/marker.d.ts +9 -0
  20. package/dist/plugins/pi/marker.js +36 -0
  21. package/dist/plugins/pi/notes/tools.js +8 -6
  22. package/dist/plugins/pi/render.js +7 -4
  23. package/dist/plugins/pi/reset/artifacts.d.ts +2 -2
  24. package/dist/plugins/pi/reset/artifacts.js +2 -2
  25. package/dist/plugins/pi/runtime.js +11 -8
  26. package/dist/plugins/pi/text.d.ts +2 -0
  27. package/dist/plugins/pi/text.js +4 -0
  28. package/dist/plugins/pi/window.js +21 -7
  29. package/dist/src/boot/render.js +7 -7
  30. package/dist/src/boot/snapshot.d.ts +7 -7
  31. package/dist/src/boot/snapshot.js +17 -17
  32. package/dist/src/boot/text.d.ts +2 -2
  33. package/dist/src/boot/text.js +7 -5
  34. package/dist/src/dream/git.d.ts +2 -11
  35. package/dist/src/dream/git.js +6 -23
  36. package/dist/src/dream/lock.d.ts +2 -2
  37. package/dist/src/dream/lock.js +3 -3
  38. package/dist/src/index.d.ts +2 -1
  39. package/dist/src/index.js +3 -2
  40. package/dist/src/notes/address.d.ts +8 -8
  41. package/dist/src/notes/address.js +13 -13
  42. package/dist/src/notes/errors.d.ts +1 -1
  43. package/dist/src/notes/frontmatter.js +2 -2
  44. package/dist/src/notes/index.d.ts +1 -1
  45. package/dist/src/notes/index.js +1 -1
  46. package/dist/src/notes/paths.d.ts +6 -6
  47. package/dist/src/notes/paths.js +9 -9
  48. package/dist/src/notes/{project-home.d.ts → project-namespace.d.ts} +7 -7
  49. package/dist/src/notes/{project-home.js → project-namespace.js} +67 -25
  50. package/dist/src/notes/store.d.ts +4 -4
  51. package/dist/src/notes/store.js +55 -52
  52. package/dist/src/tools/dream.d.ts +21 -3
  53. package/dist/src/tools/dream.js +54 -16
  54. package/dist/src/tools/notes-context.d.ts +10 -0
  55. package/dist/src/tools/notes-context.js +27 -0
  56. package/dist/src/tools/notes.d.ts +69 -20
  57. package/dist/src/tools/notes.js +40 -31
  58. package/dist/test/agent-loop.test.js +8 -8
  59. package/dist/test/boot.integration.test.js +5 -5
  60. package/dist/test/claude-history.test.js +26 -0
  61. package/dist/test/claude-mod.test.js +257 -86
  62. package/dist/test/codex-plugin.test.js +18 -1
  63. package/dist/test/context-edit-budget.test.js +121 -0
  64. package/dist/test/dependencies.test.js +71 -4
  65. package/dist/test/dream-tools.test.js +153 -8
  66. package/dist/test/dsh.test.js +62 -15
  67. package/dist/test/helpers/dsh.d.ts +4 -1
  68. package/dist/test/helpers/dsh.js +20 -4
  69. package/dist/test/helpers/extension.d.ts +5 -0
  70. package/dist/test/helpers/extension.js +33 -2
  71. package/dist/test/host-neutral.test.js +17 -15
  72. package/dist/test/marker.test.js +78 -0
  73. package/dist/test/model-facing-text.test.js +12 -8
  74. package/dist/test/notes-cwd.test.d.ts +1 -0
  75. package/dist/test/notes-cwd.test.js +114 -0
  76. package/dist/test/notes-library.test.js +4 -4
  77. package/dist/test/notes-query-namespaces.test.d.ts +1 -0
  78. package/dist/test/{notes-query-homes.test.js → notes-query-namespaces.test.js} +13 -13
  79. package/dist/test/notes.integration.test.js +72 -23
  80. package/dist/test/notes.test.js +50 -20
  81. package/dist/test/pi-render.test.js +33 -1
  82. package/dist/test/project-namespace.test.d.ts +1 -0
  83. package/dist/test/project-namespace.test.js +324 -0
  84. package/dist/test/reset-lifecycle.test.js +12 -0
  85. package/docs/architecture.md +13 -8
  86. package/docs/claude-code-mod.md +7 -7
  87. package/docs/codex.md +4 -4
  88. package/docs/dsh.md +8 -8
  89. package/docs/notes-library.md +9 -5
  90. package/docs/skills.md +3 -3
  91. package/docs/tool-results.md +6 -2
  92. package/package.json +4 -6
  93. package/playbook.md +6 -6
  94. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  95. package/plugins/claude/dist/claude/helper.js +681 -617
  96. package/plugins/claude/hooks/register.ts +61 -65
  97. package/plugins/claude/playbook.md +6 -6
  98. package/plugins/claude/skills/memory/SKILL.md +4 -4
  99. package/plugins/claude/src/helper.ts +3 -2
  100. package/plugins/claude/src/history.ts +2 -3
  101. package/plugins/claude/src/thresholds.ts +4 -2
  102. package/plugins/codex/README.md +1 -1
  103. package/plugins/codex/dist/codex/notesoup.js +877 -815
  104. package/plugins/codex/src/hooks.ts +1 -1
  105. package/plugins/codex/src/identity.ts +3 -3
  106. package/plugins/codex/src/mcp.ts +2 -1
  107. package/plugins/codex/src/text.ts +2 -2
  108. package/plugins/dsh/engine.ts +2 -2
  109. package/plugins/dsh/tools.ts +8 -7
  110. package/plugins/dsh/window.ts +8 -3
  111. package/plugins/paseo/OVERVIEW.md +4 -4
  112. package/plugins/paseo/README.md +1 -1
  113. package/plugins/paseo/client/brain-empty-card.tsx +3 -4
  114. package/plugins/paseo/client/markdown.tsx +179 -0
  115. package/plugins/paseo/client/notes-op-card.tsx +35 -34
  116. package/plugins/paseo/client/notes-op-transformer.ts +17 -68
  117. package/plugins/paseo/client/paper-card.tsx +8 -19
  118. package/plugins/paseo/client/paper-palette.ts +40 -0
  119. package/plugins/paseo/client/sticky-card.tsx +6 -4
  120. package/plugins/paseo/package.json +3 -0
  121. package/plugins/paseo/paseo-plugin.json +2 -2
  122. package/plugins/paseo/shared/notes-op.ts +13 -9
  123. package/plugins/paseo/test/notes-op.test.ts +52 -73
  124. package/plugins/paseo/test/paper-palette.test.ts +54 -0
  125. package/plugins/pi/entries.ts +1 -0
  126. package/plugins/pi/history-tools.ts +4 -4
  127. package/plugins/pi/marker.ts +39 -0
  128. package/plugins/pi/notes/tools.ts +8 -6
  129. package/plugins/pi/render.ts +6 -4
  130. package/plugins/pi/reset/artifacts.ts +2 -2
  131. package/plugins/pi/runtime.ts +9 -8
  132. package/plugins/pi/text.ts +5 -0
  133. package/plugins/pi/window.ts +22 -7
  134. package/skills/memory/SKILL.md +4 -4
  135. package/src/boot/render.ts +8 -8
  136. package/src/boot/snapshot.ts +20 -20
  137. package/src/boot/text.ts +7 -5
  138. package/src/dream/git.ts +7 -24
  139. package/src/dream/lock.ts +3 -3
  140. package/src/index.ts +4 -3
  141. package/src/notes/address.ts +13 -13
  142. package/src/notes/errors.ts +1 -1
  143. package/src/notes/frontmatter.ts +2 -2
  144. package/src/notes/index.ts +1 -1
  145. package/src/notes/paths.ts +9 -9
  146. package/src/notes/{project-home.ts → project-namespace.ts} +59 -28
  147. package/src/notes/store.ts +61 -58
  148. package/src/tools/dream.ts +63 -16
  149. package/src/tools/notes-context.ts +29 -0
  150. package/src/tools/notes.ts +39 -29
  151. package/dist/test/project-home.test.js +0 -134
  152. /package/dist/test/{notes-query-homes.test.d.ts → context-edit-budget.test.d.ts} +0 -0
  153. /package/dist/test/{project-home.test.d.ts → marker.test.d.ts} +0 -0
@@ -1,42 +1,42 @@
1
1
  import { isFilesystemError } from "../notes/fs-error.js";
2
2
  import { createNotesStore } from "../notes/index.js";
3
- const NOTES_HOMES = [
3
+ const NOTES_NAMESPACES = [
4
4
  { scope: "session", label: "this session" },
5
5
  { scope: "project", label: "@project" },
6
6
  { scope: "human", label: "@human" },
7
7
  { scope: "agent", label: "@self" },
8
8
  { scope: "model", label: "@model" },
9
9
  ];
10
- /** Identity resolution failed before any home could be loaded; boot can still explain the failure. */
10
+ /** Identity resolution failed before any notebook could be loaded; boot can still explain the failure. */
11
11
  export function unavailableNotesSnapshot(openedAt) {
12
- return { openedAt, homes: new Map(), unavailable: NOTES_HOMES };
12
+ return { openedAt, namespaces: new Map(), unavailable: NOTES_NAMESPACES };
13
13
  }
14
14
  /**
15
- * Acquire the five homes once for one boot. Only filesystem-style errno failures are isolated;
15
+ * Acquire the five notebooks once for one boot. Only filesystem-style errno failures are isolated;
16
16
  * malformed note data and unrelated construction errors remain visible to the caller.
17
17
  */
18
- export async function loadNotesSnapshot(identity, openedAt, loadHome) {
19
- const homes = new Map();
18
+ export async function loadNotesSnapshot(identity, openedAt, loadNamespace) {
19
+ const namespaces = new Map();
20
20
  const unavailable = [];
21
- if (!loadHome) {
21
+ if (!loadNamespace) {
22
22
  const { rows, status } = await createNotesStore(identity).listWithStatus();
23
- for (const home of NOTES_HOMES) {
24
- homes.set(home.scope, rows.filter(row => row.scope === home.scope));
25
- if (status.homesUnavailable.some(address => home.scope === "session" ? !address.startsWith("@") : address === home.label || address.startsWith(`${home.label}/`)))
26
- unavailable.push(home);
23
+ for (const namespace of NOTES_NAMESPACES) {
24
+ namespaces.set(namespace.scope, rows.filter(row => row.scope === namespace.scope));
25
+ if (status.namespacesUnavailable.some(address => namespace.scope === "session" ? !address.startsWith("@") : address === namespace.label || address.startsWith(`${namespace.label}/`)))
26
+ unavailable.push(namespace);
27
27
  }
28
- return { openedAt, homes, unavailable };
28
+ return { openedAt, namespaces, unavailable };
29
29
  }
30
- for (const home of NOTES_HOMES) {
30
+ for (const namespace of NOTES_NAMESPACES) {
31
31
  try {
32
- homes.set(home.scope, await loadHome(home.scope));
32
+ namespaces.set(namespace.scope, await loadNamespace(namespace.scope));
33
33
  }
34
34
  catch (error) {
35
35
  if (!isFilesystemError(error))
36
36
  throw error;
37
- homes.set(home.scope, []);
38
- unavailable.push(home);
37
+ namespaces.set(namespace.scope, []);
38
+ unavailable.push(namespace);
39
39
  }
40
40
  }
41
- return { openedAt, homes, unavailable };
41
+ return { openedAt, namespaces, unavailable };
42
42
  }
@@ -1,7 +1,7 @@
1
1
  /** Each shelf shows this many of its own freshest pages beneath its pinned pages. */
2
2
  export declare const SHELF_FRESH_LIMIT = 3;
3
3
  /** Each pinned page has its own code-point cap; overflow keeps a lookup pointer. */
4
- export declare const CHEATSHEET_BOOT_MAX_CHARS = 2048;
4
+ export declare const CHEATSHEET_BOOT_MAX_CHARS = 1536;
5
5
  export declare const MAP_BOOT_MAX_CHARS = 4096;
6
6
  export declare const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
7
7
  export declare const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
@@ -16,7 +16,7 @@ export declare const PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, p
16
16
  /**
17
17
  * The two pinned pages are taught once per window between the protocol and the notes index.
18
18
  */
19
- export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery home's root can hold two pages that never wait on a shelf: `CHEATSHEET.md` and `MAP.md`.\nBoth get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever\nwakes up next reads them, and next is you. So keep them short, and keep them true.\n\n- **`CHEATSHEET.md`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,\n a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat\n and everybody pays for it.\n- **`MAP.md`** is only the note index. One line per durable note: the address, then a gist short\n enough to tell whether the thing is worth opening. Rules belong in `CHEATSHEET.md`, not here.\n\nEach home keeps its own: `@project`, `@human`, `@self`, `@model`. Missing pages are skipped;\nno need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet\nline. And when a line stops being true, kill it \u2014 every window after you reads that page as fact.\n</notesoup:maps>";
19
+ export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery notebook's root can hold two pages that never wait on a shelf: `CHEATSHEET.md` and `MAP.md`.\nBoth get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever\nwakes up next reads them, and next is you. So keep them short, and keep them true.\n\n- **`CHEATSHEET.md`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,\n a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat\n and everybody pays for it.\n- **`MAP.md`** is only the note index. One line per durable note: the address, then a gist short\n enough to tell whether the thing is worth opening. Rules belong in `CHEATSHEET.md`, and note\n contents belong in their own notes \u2014 *taps the sign* not inline here.\n\nEach notebook keeps its own: `@project`, `@human`, `@self`, `@model`. Missing pages are skipped;\nno need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet\nline. And when a line stops being true, kill it \u2014 every window after you reads that page as fact.\n</notesoup:maps>";
20
20
  /** Logical tool names are supplied by the composing host, not discovered here. */
21
21
  export type BootToolNames = Readonly<{
22
22
  notes: string;
@@ -1,7 +1,7 @@
1
1
  /** Each shelf shows this many of its own freshest pages beneath its pinned pages. */
2
2
  export const SHELF_FRESH_LIMIT = 3;
3
3
  /** Each pinned page has its own code-point cap; overflow keeps a lookup pointer. */
4
- export const CHEATSHEET_BOOT_MAX_CHARS = 2048;
4
+ export const CHEATSHEET_BOOT_MAX_CHARS = 1536;
5
5
  export const MAP_BOOT_MAX_CHARS = 4096;
6
6
  export const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
7
7
  export const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
@@ -33,13 +33,14 @@ While you're doing that... thing you're doing, don't make the poor future you gu
33
33
  Notes are for what's true NOW. Not a diary of every dumb thing you did on the way here.
34
34
  *flips a page* "First I tried this, then that broke, then—" Nobody reads that!
35
35
  Something's not true anymore? Cross it out! Write the right thing!
36
+ *rolls eyes* ...Ugh, fine. If a piece of history *actually* matters — like why Plan A blew up so tomorrow's you doesn't try it again — I'll let it slide. Keep the short version! A few lines, max! *squints at you* Turn it into a blow-by-blow log and you're dead.
36
37
 
37
38
  \`get_context_remaining\` tells you how much room is left. Check it before you do something ambitious. When it reaches zero, your brain gets reset immediately, taking every unwritten brilliant idea with it. ${PROTOCOL_WIPE_SENTENCE}
38
39
 
39
40
  An address decides who the note belongs to — and how long it is meant to last. Ask that first; the rest follows.
40
41
 
41
42
  - \`<path>\`, no @ — session notes, the ones from above: this session's state and loose ends. They go away with the session.
42
- - \`@project/<path>\` — this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Commit hashes, test counts, dates, the story of how you got here: git and history already have them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
43
+ - \`@project/<path>\` — this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Raw logs, scorecards, and blow-by-blow recaps don't belong here — history already has them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
43
44
  - \`@human/<path>\` — the long-term manual for your troublesome human, and only what stays true in EVERY project: how to deal with them, which lines not to cross, and what will make them accept the result. "The human said it" is not enough — if it stops being true the moment you switch projects, it was never theirs; it belongs to that project's notes. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
44
45
  - \`@self/<path>\` — yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
45
46
  - \`@model/<path>\` — different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
@@ -56,7 +57,7 @@ ${NOTES_PROTOCOL_CLOSE_TAG}`;
56
57
  * The two pinned pages are taught once per window between the protocol and the notes index.
57
58
  */
58
59
  export const MAPS_BLOCK = `<notesoup:maps>
59
- Every home's root can hold two pages that never wait on a shelf: \`CHEATSHEET.md\` and \`MAP.md\`.
60
+ Every notebook's root can hold two pages that never wait on a shelf: \`CHEATSHEET.md\` and \`MAP.md\`.
60
61
  Both get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever
61
62
  wakes up next reads them, and next is you. So keep them short, and keep them true.
62
63
 
@@ -64,9 +65,10 @@ wakes up next reads them, and next is you. So keep them short, and keep them tru
64
65
  a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
65
66
  and everybody pays for it.
66
67
  - **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
67
- enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, not here.
68
+ enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
69
+ contents belong in their own notes — *taps the sign* not inline here.
68
70
 
69
- Each home keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
71
+ Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
70
72
  no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
71
73
  line. And when a line stops being true, kill it — every window after you reads that page as fact.
72
74
  </notesoup:maps>`;
@@ -1,8 +1,4 @@
1
- /**
2
- * Outcome of one audit commit. `ok: true` always carries a real `commit` snapshot;
3
- * `empty: true` only means no files changed (an empty baseline commit or no commit was
4
- * needed). `ok: false` means the audit layer could not guarantee a snapshot.
5
- */
1
+ /** A successful audit always names a real snapshot, even when the tree was already clean. */
6
2
  export type AuditResult = {
7
3
  ok: true;
8
4
  commit: string;
@@ -11,10 +7,5 @@ export type AuditResult = {
11
7
  ok: false;
12
8
  error: string;
13
9
  };
14
- /**
15
- * Git audit layer for a dream: one commit at dream_begin (baseline) and one at dream_end,
16
- * so the human reviews `git show` instead of trusting a report, and rollback is `git revert`. The caller decides how loud a failure is; this function only reports it.
17
- * A clean tree on an established repository commits nothing; a repository with no HEAD
18
- * gets an empty baseline commit, because an audit run with no snapshot is not a success.
19
- */
10
+ /** Snapshot at begin and end; a repository without HEAD gets an empty baseline commit. */
20
11
  export declare function gitCommit(home: string, message: string): AuditResult;
@@ -1,4 +1,4 @@
1
- import { execFileSync } from "node:child_process";
1
+ import { execFileSync, spawnSync } from "node:child_process";
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { errorMessage } from "../error-message.js";
@@ -17,12 +17,7 @@ function ensureRuntimeIgnored(home) {
17
17
  }
18
18
  catch { /* best effort: an unignored lock only adds noise to the audit */ }
19
19
  }
20
- /**
21
- * Git audit layer for a dream: one commit at dream_begin (baseline) and one at dream_end,
22
- * so the human reviews `git show` instead of trusting a report, and rollback is `git revert`. The caller decides how loud a failure is; this function only reports it.
23
- * A clean tree on an established repository commits nothing; a repository with no HEAD
24
- * gets an empty baseline commit, because an audit run with no snapshot is not a success.
25
- */
20
+ /** Snapshot at begin and end; a repository without HEAD gets an empty baseline commit. */
26
21
  export function gitCommit(home, message) {
27
22
  try {
28
23
  if (!existsSync(join(home, ".git"))) {
@@ -30,21 +25,9 @@ export function gitCommit(home, message) {
30
25
  }
31
26
  ensureRuntimeIgnored(home);
32
27
  execFileSync("git", ["add", "-A"], { cwd: home, stdio: "ignore" });
33
- let clean = false;
34
- try {
35
- execFileSync("git", ["diff", "--cached", "--quiet"], { cwd: home, stdio: "ignore" });
36
- clean = true; // clean tree — no empty commit on an established repository
37
- }
38
- catch {
39
- clean = false;
40
- }
41
- const before = headCommit(home);
42
- if (!clean) {
43
- execFileSync("git", ["commit", "-q", "-m", message], { cwd: home, stdio: "ignore" });
44
- }
45
- else if (before === undefined) {
46
- // A newly initialized repository has no snapshot at all; give the audit one.
47
- execFileSync("git", ["commit", "-q", "--allow-empty", "-m", message], { cwd: home, stdio: "ignore" });
28
+ const clean = spawnSync("git", ["diff", "--cached", "--quiet"], { cwd: home, stdio: "ignore" }).status === 0;
29
+ if (!clean || headCommit(home) === undefined) {
30
+ execFileSync("git", ["commit", "-q", ...(clean ? ["--allow-empty"] : []), "-m", message], { cwd: home, stdio: "ignore" });
48
31
  }
49
32
  const commit = headCommit(home);
50
33
  if (commit === undefined)
@@ -58,7 +41,7 @@ export function gitCommit(home, message) {
58
41
  /** HEAD sha, or undefined when the repository has no commit yet. */
59
42
  function headCommit(home) {
60
43
  try {
61
- const head = execFileSync("git", ["rev-parse", "HEAD"], { cwd: home, encoding: "utf8" }).trim();
44
+ const head = execFileSync("git", ["rev-parse", "HEAD"], { cwd: home, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
62
45
  return head.length > 0 ? head : undefined;
63
46
  }
64
47
  catch {
@@ -3,8 +3,8 @@ export type DreamLock = {
3
3
  path: string;
4
4
  token: string;
5
5
  };
6
- /** The per-project lock file in the notes home; `.dream.lock*` is excluded from the Git audit. */
7
- export declare function dreamLockPath(home: string, project: string): string;
6
+ /** One lock per notes home: its Git history cannot audit concurrent dreams independently. */
7
+ export declare function dreamLockPath(home: string): string;
8
8
  /**
9
9
  * Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
10
10
  * whatever its age; a crash-left lock is removed by hand after confirming no dream runs.
@@ -1,9 +1,9 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
- /** The per-project lock file in the notes home; `.dream.lock*` is excluded from the Git audit. */
5
- export function dreamLockPath(home, project) {
6
- return join(home, `.dream.lock.${project}`);
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
7
  }
8
8
  /**
9
9
  * Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
@@ -13,12 +13,13 @@
13
13
  export { createNotesStore, noteIdentity, projectKey, slugify, NoteError } from "./notes/index.js";
14
14
  export type { NoteEditResult, NoteMatch, NoteMeta, NoteReadResult, NoteRenameResult, NoteRow, NoteSearchRow, NotesIdentity, NotesQuery, NotesStore, NoteWriteResult, Origin, Scope, } from "./notes/index.js";
15
15
  export { loadNotesSnapshot, unavailableNotesSnapshot } from "./boot/snapshot.js";
16
- export type { NotesHome, NotesSnapshot } from "./boot/snapshot.js";
16
+ export type { NotesNamespace, NotesSnapshot } from "./boot/snapshot.js";
17
17
  export { renderBootBlock } from "./boot/render.js";
18
18
  export type { BootRenderData, BootWindowTree } from "./boot/render.js";
19
19
  export { DEFAULT_BOOT_TOOL_NAMES, renderProtocolBlock } from "./boot/text.js";
20
20
  export type { BootToolNames } from "./boot/text.js";
21
21
  export { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "./tools/notes.js";
22
+ export { notesIdentityForCall, notesToolContext, type NotesToolContext } from "./tools/notes-context.js";
22
23
  export { historyList, historyRead, historyWindows } from "./tools/history.js";
23
24
  export { projectHistory } from "./history/history.js";
24
25
  export type { HistoryProjection } from "./history/history.js";
package/dist/src/index.js CHANGED
@@ -12,13 +12,14 @@
12
12
  */
13
13
  // Notes: the standalone filesystem library, addressed by an explicit identity.
14
14
  export { createNotesStore, noteIdentity, projectKey, slugify, NoteError } from "./notes/index.js";
15
- // Boot: five homes captured once, rendered from explicit logical tool names.
15
+ // Boot: five notebooks captured once, rendered from explicit logical tool names.
16
16
  export { loadNotesSnapshot, unavailableNotesSnapshot } from "./boot/snapshot.js";
17
17
  export { renderBootBlock } from "./boot/render.js";
18
18
  export { DEFAULT_BOOT_TOOL_NAMES, renderProtocolBlock } from "./boot/text.js";
19
19
  // Operations: the schemas and typed outcomes a host registers as its own tools, over a
20
- // host-supplied notes identity or decoded history projection.
20
+ // host-supplied notes tool context or decoded history projection.
21
21
  export { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "./tools/notes.js";
22
+ export { notesIdentityForCall, notesToolContext } from "./tools/notes-context.js";
22
23
  export { historyList, historyRead, historyWindows } from "./tools/history.js";
23
24
  export { projectHistory } from "./history/history.js";
24
25
  // Budget: pure thresholds and the approved reset prose.
@@ -5,11 +5,11 @@ export type NoteAddress = {
5
5
  path: string;
6
6
  who?: string;
7
7
  };
8
- export declare const ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> and @sessions/<id>/<path> read named homes.";
9
- /** The one home-head vocabulary: the scope each public `@head` names, and the home directory family a head with `home` lists. */
10
- export declare const HOME_HEADS: ReadonlyMap<string, {
8
+ export declare const ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> and @sessions/<id>/<path> read named notebooks.";
9
+ /** The one namespace-head vocabulary: the scope each public `@head` names, and the directory family a head with `dir` lists. */
10
+ export declare const NAMESPACE_HEADS: ReadonlyMap<string, {
11
11
  readonly scope: Scope;
12
- readonly home?: "sessions" | "project" | "agents" | "models";
12
+ readonly dir?: "sessions" | "project" | "agents" | "models";
13
13
  }>;
14
14
  /**
15
15
  * Minimal glob over virtual note paths: `*` matches any run within a segment (never
@@ -22,15 +22,15 @@ export declare function globToRegExp(pattern: string): RegExp;
22
22
  /** Glob patterns are not virtual paths (`*` is legal), so they get their own guard. */
23
23
  export declare function assertGlobPattern(value: unknown): string | undefined;
24
24
  /**
25
- * Decode one public note address into its physical home and virtual path. @self and @model
25
+ * Decode one public note address into its physical namespace and virtual path. @self and @model
26
26
  * are relative; projects/agents/models name a canonical slug, sessions a directory component.
27
27
  */
28
28
  export declare function assertAddress(value: unknown): NoteAddress;
29
29
  /** Render a virtual path in its one unambiguous address form, used to match patterns. */
30
30
  export declare function canonicalAddressFor(identity: NotesIdentity, scope: Scope, path: string, who?: string): string;
31
31
  /**
32
- * Render the address a caller sees. The current agent and model homes read as @self/ and
33
- * @model/. Current session and project homes retain bare paths and @project/; explicitly
34
- * named session/project homes keep their read-only addresses, even for the current identity.
32
+ * Render the address a caller sees. The current agent and model notebooks read as @self/ and
33
+ * @model/. Current session and project notebooks retain bare paths and @project/; explicitly
34
+ * named session/project notebooks keep their read-only addresses, even for the current identity.
35
35
  */
36
36
  export declare function addressFor(identity: NotesIdentity, scope: Scope, path: string, who?: string): string;
@@ -1,16 +1,16 @@
1
1
  import { NoteError, shown } from "./errors.js";
2
2
  import { assertVirtualPath, isSessionId, SLUG_PATTERN } from "./paths.js";
3
- export const ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> and @sessions/<id>/<path> read named homes.";
4
- /** The one home-head vocabulary: the scope each public `@head` names, and the home directory family a head with `home` lists. */
5
- export const HOME_HEADS = new Map([
3
+ export const ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> and @sessions/<id>/<path> read named notebooks.";
4
+ /** The one namespace-head vocabulary: the scope each public `@head` names, and the directory family a head with `dir` lists. */
5
+ export const NAMESPACE_HEADS = new Map([
6
6
  ["project", { scope: "project" }],
7
7
  ["human", { scope: "human" }],
8
8
  ["self", { scope: "agent" }],
9
9
  ["model", { scope: "model" }],
10
- ["sessions", { scope: "session", home: "sessions" }],
11
- ["projects", { scope: "project", home: "project" }],
12
- ["agents", { scope: "agent", home: "agents" }],
13
- ["models", { scope: "model", home: "models" }],
10
+ ["sessions", { scope: "session", dir: "sessions" }],
11
+ ["projects", { scope: "project", dir: "project" }],
12
+ ["agents", { scope: "agent", dir: "agents" }],
13
+ ["models", { scope: "model", dir: "models" }],
14
14
  ]);
15
15
  /**
16
16
  * Minimal glob over virtual note paths: `*` matches any run within a segment (never
@@ -53,7 +53,7 @@ export function assertGlobPattern(value) {
53
53
  return value;
54
54
  }
55
55
  /**
56
- * Decode one public note address into its physical home and virtual path. @self and @model
56
+ * Decode one public note address into its physical namespace and virtual path. @self and @model
57
57
  * are relative; projects/agents/models name a canonical slug, sessions a directory component.
58
58
  */
59
59
  export function assertAddress(value) {
@@ -64,11 +64,11 @@ export function assertAddress(value) {
64
64
  let who;
65
65
  if (value.startsWith("@")) {
66
66
  const [rawHead, ...tail] = value.slice(1).split("/");
67
- const head = HOME_HEADS.get(rawHead);
67
+ const head = NAMESPACE_HEADS.get(rawHead);
68
68
  if (head === undefined)
69
69
  throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
70
70
  scope = head.scope;
71
- if (head.home === undefined)
71
+ if (head.dir === undefined)
72
72
  path = tail.join("/");
73
73
  else {
74
74
  who = tail[0] ?? "";
@@ -97,9 +97,9 @@ export function canonicalAddressFor(identity, scope, path, who) {
97
97
  return `@models/${who ?? identity.model}/${path}`;
98
98
  }
99
99
  /**
100
- * Render the address a caller sees. The current agent and model homes read as @self/ and
101
- * @model/. Current session and project homes retain bare paths and @project/; explicitly
102
- * named session/project homes keep their read-only addresses, even for the current identity.
100
+ * Render the address a caller sees. The current agent and model notebooks read as @self/ and
101
+ * @model/. Current session and project notebooks retain bare paths and @project/; explicitly
102
+ * named session/project notebooks keep their read-only addresses, even for the current identity.
103
103
  */
104
104
  export function addressFor(identity, scope, path, who) {
105
105
  if (scope === "session" && who === undefined)
@@ -1,4 +1,4 @@
1
- export type NoteErrorCode = "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" | "io_error" | "internal_error";
1
+ export type NoteErrorCode = "not_found" | "already_exists" | "ambiguous_edit" | "no_match" | "invalid_edit" | "nothing_to_do" | "not_crumpled" | "too_large" | "invalid_scope" | "invalid_origin" | "invalid_address" | "invalid_pattern" | "invalid_query" | "invalid_offset" | "invalid_cwd" | "io_error" | "internal_error";
2
2
  /** Typed store refusal. Edit locations are exposed in camelCase. */
3
3
  export declare class NoteError extends Error {
4
4
  readonly code: NoteErrorCode;
@@ -98,7 +98,7 @@ function parseFrontmatter(raw) {
98
98
  export function parseNote(raw, now = Date.now()) {
99
99
  const { fields, body } = parseFrontmatter(raw);
100
100
  const meta = { ...fields };
101
- // scope is a legacy on-disk field: store callers derive it from the file's home and
101
+ // scope is a legacy on-disk field: store callers derive it from the file's notebook and
102
102
  // overwrite it after parsing, so an absent or outdated value just falls back.
103
103
  meta.scope = isScope(meta.scope) ? meta.scope : "session";
104
104
  meta.origin = isOrigin(meta.origin) ? meta.origin : "self";
@@ -143,7 +143,7 @@ export function serializeNote(meta, body) {
143
143
  lines.push(`${key}: ${yamlScalar(value)}`);
144
144
  }
145
145
  for (const key of Object.keys(meta)) {
146
- // scope is a legacy on-disk field. Store callers derive it from the home's location,
146
+ // scope is a legacy on-disk field. Store callers derive it from the notebook's location,
147
147
  // but serialization intentionally drops it on the next write.
148
148
  if (key === "scope" || KNOWN_KEYS.includes(key))
149
149
  continue;
@@ -1,6 +1,6 @@
1
1
  export { createNotesStore, noteIdentity } from "./store.js";
2
2
  export { NoteError, type NoteErrorCode } from "./errors.js";
3
- export { projectKey } from "./project-home.js";
3
+ export { projectKey } from "./project-namespace.js";
4
4
  export { slugify } from "./paths.js";
5
5
  export { snapshotNotesIdentity, type NotesIdentity } from "./identity.js";
6
6
  export { isFilesystemError } from "./fs-error.js";
@@ -1,6 +1,6 @@
1
1
  export { createNotesStore, noteIdentity } from "./store.js";
2
2
  export { NoteError } from "./errors.js";
3
- export { projectKey } from "./project-home.js";
3
+ export { projectKey } from "./project-namespace.js";
4
4
  export { slugify } from "./paths.js";
5
5
  export { snapshotNotesIdentity } from "./identity.js";
6
6
  export { isFilesystemError } from "./fs-error.js";
@@ -1,6 +1,6 @@
1
1
  import type { NotesIdentity } from "./identity.js";
2
2
  export type Scope = "session" | "project" | "human" | "agent" | "model";
3
- /** The one legal home-name shape: lowercase [a-z0-9-] runs separated by single dashes. */
3
+ /** The one legal namespace-name shape: lowercase [a-z0-9-] runs separated by single dashes. */
4
4
  export declare const SLUG_PATTERN: RegExp;
5
5
  /** Session identities use the same single-directory-component grammar as NotesIdentity, not slugs. */
6
6
  export declare function isSessionId(value: string): boolean;
@@ -9,15 +9,15 @@ export declare function slugify(value: string): string;
9
9
  /**
10
10
  * The one virtual-path grammar: a relative, `/`-separated path with no empty, `.` or `..`
11
11
  * segment. Both the address decoder and the physical-path builder enforce it here, so a
12
- * caller that reaches a path without going through an address still cannot escape a home.
12
+ * caller that reaches a path without going through an address still cannot escape a namespace.
13
13
  */
14
14
  export declare function assertVirtualPath(value: unknown): string;
15
- /** Absolute directory holding the per-session note homes. */
16
- export declare function sessionHomesRoot(home: string): string;
15
+ /** Absolute directory holding the per-session note namespaces. */
16
+ export declare function sessionNamespacesRoot(home: string): string;
17
17
  /** Absolute directory holding one scope's notes. The identity's home is already resolved. */
18
18
  export declare function scopeDir(scope: Scope, identity: NotesIdentity, who?: string): string;
19
- /** Every addressable home directory in a namespace; sessions keep their original identity spelling. */
20
- export declare function namespaceSlugs(namespace: "sessions" | "project" | "agents" | "models", home: string): Promise<string[]>;
19
+ /** Every addressable directory of a namespace family; sessions keep their original identity spelling. */
20
+ export declare function namespaceSlugs(family: "sessions" | "project" | "agents" | "models", home: string): Promise<string[]>;
21
21
  /**
22
22
  * Notes are markdown files: a virtual path without an `.md` suffix gains one, an explicit
23
23
  * `.md` is kept as-is, so `a/b` and `a/b.md` name the same physical file.
@@ -1,7 +1,7 @@
1
1
  import { readdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { NoteError, shown } from "./errors.js";
4
- /** The one legal home-name shape: lowercase [a-z0-9-] runs separated by single dashes. */
4
+ /** The one legal namespace-name shape: lowercase [a-z0-9-] runs separated by single dashes. */
5
5
  export const SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
6
  /** Session identities use the same single-directory-component grammar as NotesIdentity, not slugs. */
7
7
  export function isSessionId(value) {
@@ -15,7 +15,7 @@ export function slugify(value) {
15
15
  /**
16
16
  * The one virtual-path grammar: a relative, `/`-separated path with no empty, `.` or `..`
17
17
  * segment. Both the address decoder and the physical-path builder enforce it here, so a
18
- * caller that reaches a path without going through an address still cannot escape a home.
18
+ * caller that reaches a path without going through an address still cannot escape a namespace.
19
19
  */
20
20
  export function assertVirtualPath(value) {
21
21
  if (typeof value !== "string" || value.length === 0)
@@ -27,8 +27,8 @@ export function assertVirtualPath(value) {
27
27
  throw new NoteError("invalid_address", `${shown(value)}: a note path can't have empty, ".", or ".." folder names.`);
28
28
  return value;
29
29
  }
30
- /** Absolute directory holding the per-session note homes. */
31
- export function sessionHomesRoot(home) {
30
+ /** Absolute directory holding the per-session note namespaces. */
31
+ export function sessionNamespacesRoot(home) {
32
32
  return join(home, "pi", "session");
33
33
  }
34
34
  /** Absolute directory holding one scope's notes. The identity's home is already resolved. */
@@ -45,14 +45,14 @@ export function scopeDir(scope, identity, who) {
45
45
  return join(identity.home, "agents", who ?? identity.agent);
46
46
  if (scope === "model")
47
47
  return join(identity.home, "models", who ?? identity.model);
48
- return join(sessionHomesRoot(identity.home), who ?? identity.sessionId);
48
+ return join(sessionNamespacesRoot(identity.home), who ?? identity.sessionId);
49
49
  }
50
- /** Every addressable home directory in a namespace; sessions keep their original identity spelling. */
51
- export async function namespaceSlugs(namespace, home) {
52
- const root = namespace === "sessions" ? sessionHomesRoot(home) : join(home, namespace);
50
+ /** Every addressable directory of a namespace family; sessions keep their original identity spelling. */
51
+ export async function namespaceSlugs(family, home) {
52
+ const root = family === "sessions" ? sessionNamespacesRoot(home) : join(home, family);
53
53
  try {
54
54
  return (await readdir(root, { withFileTypes: true }))
55
- .filter((entry) => entry.isDirectory() && (namespace === "sessions" ? isSessionId(entry.name) : SLUG_PATTERN.test(entry.name)))
55
+ .filter((entry) => entry.isDirectory() && (family === "sessions" ? isSessionId(entry.name) : SLUG_PATTERN.test(entry.name)))
56
56
  .map((entry) => entry.name)
57
57
  .sort();
58
58
  }
@@ -2,16 +2,16 @@ export type ProjectMarker = {
2
2
  id: string;
3
3
  path: string;
4
4
  };
5
- export type ProjectHome = ProjectMarker & {
5
+ export type ProjectNamespace = ProjectMarker & {
6
6
  name: string;
7
7
  dir: string;
8
8
  };
9
9
  /** Normalize the small set of Git remote spellings used by ordinary repositories. */
10
10
  export declare function normalizeRemote(value: string): string;
11
- /** Read marked project homes. Unmarked legacy directories are deliberately omitted. */
12
- export declare function projectHomes(home: string): ProjectHome[];
13
- /** Resolve and claim the readable home for one repository identity. */
14
- export declare function resolveProjectHome(cwd: string, home: string): ProjectHome;
11
+ /** Read marked project notebooks. Unmarked legacy directories are deliberately omitted. */
12
+ export declare function projectNamespaces(home: string): ProjectNamespace[];
13
+ /** Resolve and claim the readable notebook for one repository identity. */
14
+ export declare function resolveProjectNamespace(cwd: string, home: string): ProjectNamespace;
15
15
  export type ProjectReceipt = {
16
16
  project_root?: string;
17
17
  project_siblings?: Array<{
@@ -19,7 +19,7 @@ export type ProjectReceipt = {
19
19
  path: string;
20
20
  }>;
21
21
  };
22
- /** Display-only context for an explicitly named project home. */
22
+ /** Display-only context for an explicitly named project notebook. */
23
23
  export declare function projectReceipt(home: string, name: string): ProjectReceipt;
24
- /** Names a project home, claiming it when the notes home has not seen this identity. */
24
+ /** Names a project notebook, claiming it when the notes store has not seen this identity. */
25
25
  export declare function projectKey(cwd: string, home: string): string;