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
package/README.md CHANGED
@@ -11,7 +11,7 @@ The old name is retired: `@astrosheep/pi-context` is deprecated, and the package
11
11
  ## Why not just compaction?
12
12
 
13
13
  - **Reset ≠ summary.** Compaction is lossy compression you sit and wait for — and the next one summarizes the summary of the summary. A notesoup reset summarizes *nothing*: the window closes in O(1), because whatever mattered was already written to notes beforehand. Fast because there's nothing to compute; safe because the raw history never leaves disk.
14
- - **Notes are files you can open.** Plain Markdown in `~/.agents/notes`, in named homes (`@project`, `@human`, `@self`, `@model`, plus per-session). Readable, editable, greppable, git-able. Not an encrypted blob — and not a secret the model is instructed to keep from you. (Yes, that was a real instruction. No, we didn't port it.)
14
+ - **Notes are files you can open.** Plain Markdown in `~/.agents/notes`, in named notebooks (`@project`, `@human`, `@self`, `@model`, plus per-session). Readable, editable, greppable, git-able. Not an encrypted blob — and not a secret the model is instructed to keep from you. (Yes, that was a real instruction. No, we didn't port it.)
15
15
  - **History never forgets.** Every closed window — messages, tool calls, tool output — stays fully searchable through the `history_*` tools. Notes are the agent's lossy index; history is the lossless record underneath. This is the half the original experiment never shipped.
16
16
 
17
17
  ## Install
@@ -100,7 +100,7 @@ npm test # build from a clean dist, then run the suite
100
100
  npm run typecheck
101
101
  git diff --check
102
102
  node scripts/check-notes-package.mjs # optional built /notes CRUD smoke; no install
103
- npx tsx scripts/boot-smoke.mts [cwd] # optional live boot render against the real notes homes
103
+ npx tsx scripts/boot-smoke.mts [cwd] # optional live boot render against the real notes notebooks
104
104
  ```
105
105
 
106
106
  The repository splits host-neutral code from host plugins:
@@ -10,6 +10,7 @@ import { selectContinuation } from "../../../src/budget/text.js";
10
10
  import { claudeHistoryGapNotice, claudeHistoryUnconfirmedSeq, CLAUDE_HISTORY_UNKNOWN_PREVIOUS, CLAUDE_HISTORY_UNKNOWN_WINDOW, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
11
11
  import { resolveClaudeLimits } from "./thresholds.js";
12
12
  import { projectKey, snapshotNotesIdentity } from "../../../src/notes/index.js";
13
+ import { notesToolContext } from "../../../src/tools/notes-context.js";
13
14
  const MAX_REQUEST_BYTES = 512 * 1024;
14
15
  const MAX_RESPONSE_BYTES = 1024 * 1024;
15
16
  function identity(input) {
@@ -115,7 +116,7 @@ export async function dispatch(request) {
115
116
  : await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
116
117
  return { ...result, text: wrapText(result.text) };
117
118
  }
118
- return OPERATIONS[value.tool].call(value.params, id);
119
+ return OPERATIONS[value.tool].call(value.params, notesToolContext(id, value.identity.cwd));
119
120
  }
120
121
  if (value.op === "history_state") {
121
122
  const id = identity(value.identity);
@@ -58,9 +58,8 @@ function blocksOf(value) {
58
58
  });
59
59
  }
60
60
  function decode(row, seq) {
61
- // Native duration bookkeeping has a UUID/parent but no message body. Keep its
62
- // graph edge, not a fabricated empty message or serialized timing payload.
63
- if (row.type === "system" && row.subtype === "turn_duration")
61
+ // A system record without a body is graph metadata, not a message.
62
+ if (row.type === "system" && row.content == null)
64
63
  return [];
65
64
  const common = { windowId: "", ...(typeof row.timestamp === "string" ? { createdAt: row.timestamp } : {}) };
66
65
  let blocks, role;
@@ -118,9 +118,11 @@ export function resolveClaudeLimits(facts) {
118
118
  if (window !== undefined) {
119
119
  const configured = configuredWindow(settings, env, breakdown.model);
120
120
  const effective = Math.min(configured ?? window, window);
121
+ const available = effective - CLAUDE_OUTPUT_RESERVE_TOKENS;
122
+ const threshold = available - CLAUDE_AUTOCOMPACT_BUFFER_TOKENS;
121
123
  const native = autoCompact
122
- ? effective - CLAUDE_OUTPUT_RESERVE_TOKENS - CLAUDE_AUTOCOMPACT_BUFFER_TOKENS
123
- : effective - CLAUDE_OUTPUT_RESERVE_TOKENS;
124
+ ? pct === undefined ? threshold : Math.min(Math.floor(available * (pct / 100)), threshold)
125
+ : available;
124
126
  return tokenLimits("window", autoCompact, native, resetMargin, warningRunway);
125
127
  }
126
128
  // (c) Nothing usable but percentages.
@@ -27,7 +27,7 @@ export function bootWithinCap(boot) {
27
27
  const bytes = Buffer.byteLength(boot, "utf8");
28
28
  return bytes <= MAX_BOOT_BYTES
29
29
  ? undefined
30
- : `notesoup: this window's boot is ${bytes} bytes, over the ${MAX_BOOT_BYTES}-byte cap. No truncated or spilled boot was injected; slim the home MAPs and restart/resume the thread.`;
30
+ : `notesoup: this window's boot is ${bytes} bytes, over the ${MAX_BOOT_BYTES}-byte cap. No truncated or spilled boot was injected; slim the notebook MAPs and restart/resume the thread.`;
31
31
  }
32
32
  export async function readHookInput(stream) {
33
33
  return await new Promise((resolveInput, reject) => {
@@ -23,7 +23,7 @@ export declare function safeThreadId(value: unknown, field?: string): string;
23
23
  /** The portable server and the hook must share this root; Codex injects it into both. */
24
24
  export declare function pluginDataRoot(env?: NodeJS.ProcessEnv): string;
25
25
  export declare function notesHome(env?: NodeJS.ProcessEnv): string;
26
- /** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other home. */
26
+ /** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other notebook. */
27
27
  export declare function modelSlug(value: unknown): string | undefined;
28
28
  /** Validate every field before it becomes an identity; a corrupt binding never half-applies. */
29
29
  export declare function readBinding(root: string, threadId: string): Promise<ThreadBinding>;
@@ -24,7 +24,7 @@ export function safeThreadId(value, field = "threadId") {
24
24
  export function pluginDataRoot(env = process.env) {
25
25
  const value = env.PLUGIN_DATA;
26
26
  if (typeof value !== "string" || value.trim() === "" || !isAbsolute(value)) {
27
- throw new CodexIdentityError("missing_plugin_data", "PLUGIN_DATA is unavailable. Install notesoup as a Codex plugin (or set PLUGIN_DATA for a standalone test) so hook bindings have one mutable home.");
27
+ throw new CodexIdentityError("missing_plugin_data", "PLUGIN_DATA is unavailable. Install notesoup as a Codex plugin (or set PLUGIN_DATA for a standalone test) so hook bindings have one mutable data directory.");
28
28
  }
29
29
  return resolve(value);
30
30
  }
@@ -32,7 +32,7 @@ export function notesHome(env = process.env) {
32
32
  const value = env.NOTESOUP_HOME;
33
33
  return value !== undefined && value.trim() !== "" ? resolve(value) : join(homedir(), ".agents", "notes");
34
34
  }
35
- /** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other home. */
35
+ /** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other notebook. */
36
36
  export function modelSlug(value) {
37
37
  if (typeof value !== "string")
38
38
  return undefined;
@@ -126,7 +126,7 @@ export function turnModel(meta) {
126
126
  const model = typeof value === "object" && value !== null ? value.model : undefined;
127
127
  const slug = modelSlug(model);
128
128
  if (slug === undefined)
129
- throw new CodexIdentityError("missing_model", "Codex did not supply this turn's model in MCP metadata, so notesoup cannot choose an @model home. Update Codex, or call notes from a model turn.");
129
+ throw new CodexIdentityError("missing_model", "Codex did not supply this turn's model in MCP metadata, so notesoup cannot choose an @model notebook. Update Codex, or call notes from a model turn.");
130
130
  return slug;
131
131
  }
132
132
  export function rootSessionIdOf(meta) {
@@ -9,6 +9,7 @@ import { wireResult } from "../../../src/tools/result.js";
9
9
  import { CodexIdentityError, notesIdentityFor, pluginDataRoot, readBinding, rootSessionIdOf, safeThreadId, turnModel } from "./identity.js";
10
10
  import { readCodexHistory } from "./history.js";
11
11
  import { readStartState } from "./state.js";
12
+ import { notesToolContext } from "../../../src/tools/notes-context.js";
12
13
  const OPERATIONS = {
13
14
  notes_write: { operation: notesWrite, history: false },
14
15
  notes_update: { operation: notesUpdate, history: false },
@@ -119,7 +120,7 @@ export async function callTool(name, args, meta, env = process.env) {
119
120
  const { binding, rootSessionId, model } = await identityFor(meta, env);
120
121
  const native = await readNative(binding, rootSessionId, bound.history, meta, env);
121
122
  if (!bound.history) {
122
- const outcome = await bound.operation.execute(params, notesIdentityFor(binding, model));
123
+ const outcome = await bound.operation.execute(params, notesToolContext(notesIdentityFor(binding, model), binding.cwd));
123
124
  return successFor(bound, outcome);
124
125
  }
125
126
  const projection = native.projection;
@@ -10,5 +10,5 @@ export declare const CODEX_PRE_RESET_HINTS: string;
10
10
  export declare const CODEX_SETUP_HINT = "Enable and trust the notesoup plugin in Codex, then start or resume the thread. notesoup binds identities from hooks and never from the MCP server's cwd.";
11
11
  export declare function unsupportedChildCompaction(): string;
12
12
  export declare function missingNativeFacts(reason: string): string;
13
- /** A boot can still identify itself when the note store itself refused; it must not pretend homes are empty. */
13
+ /** A boot can still identify itself when the note store itself refused; it must not pretend notebooks are empty. */
14
14
  export declare function notesFailureBoot(reason: string): string;
@@ -19,7 +19,7 @@ export function unsupportedChildCompaction() {
19
19
  export function missingNativeFacts(reason) {
20
20
  return `notesoup: no boot injected because Codex's native window facts could not be read (${reason}). ${CODEX_SETUP_HINT} notesoup supports Codex 0.160.1 transcripts.`;
21
21
  }
22
- /** A boot can still identify itself when the note store itself refused; it must not pretend homes are empty. */
22
+ /** A boot can still identify itself when the note store itself refused; it must not pretend notebooks are empty. */
23
23
  export function notesFailureBoot(reason) {
24
- return `notesoup: your notes did not load this time (${reason}). Try the notes_list tool; if it fails too, tell the human. Do not assume a home is empty from this failure.`;
24
+ return `notesoup: your notes did not load this time (${reason}). Try the notes_list tool; if it fails too, tell the human. Do not assume a notebook is empty from this failure.`;
25
25
  }
@@ -142,8 +142,8 @@ export class NotesoupCompactionEngine extends CompactionEngine {
142
142
  const next = await this.windows.mint(agent, previous.window + 1, opened.time);
143
143
  signal?.throwIfAborted();
144
144
  if (session.surface.contentGeneration !== generation || session.surface.nodes.length !== shadowedSeqs.length + 1)
145
- throw new ManualCompactionError("changed", "notesoup: the surface changed while opening the next notebook; retry after current work finishes.");
146
- // Mint BEFORE writing the checkpoint. A rejected append restores the previous notebook.
145
+ throw new ManualCompactionError("changed", "notesoup: the surface changed while opening the next page; retry after current work finishes.");
146
+ // Mint BEFORE writing the checkpoint. A rejected append restores the previous page.
147
147
  // One draw per reset artifact: the checkpoint text and the steered copy share it.
148
148
  const continuation = selectContinuation(origin);
149
149
  state.snapshot = next;
@@ -5,7 +5,8 @@ import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../.
5
5
  import { historyList, historyRead, historyWindows } from "../../src/tools/history.js";
6
6
  import { success } from "../../src/tools/result.js";
7
7
  import { historyProjection } from "./history.js";
8
- import { notesIdentity } from "./window.js";
8
+ import { notesCwd, notesIdentity } from "./window.js";
9
+ import { notesToolContext } from "../../src/tools/notes-context.js";
9
10
  import { measureBudget } from "./budget.js";
10
11
  import { preflight } from "./engine.js";
11
12
  /** dsh enforces a small schema subset; TypeBox remains the full validator at execution. */
@@ -75,12 +76,12 @@ export function registerTools(ctx, engine) {
75
76
  if (!exec.parent && nestedResets.get(exec.agent)?.delete(exec.rootCallId) && !result.isError)
76
77
  state.pendingReset = true;
77
78
  });
78
- const identity = (agent) => notesIdentity(agent, engine.config);
79
- register(ctx, notesWrite, (agent) => [identity(agent)]);
80
- register(ctx, notesUpdate, (agent) => [identity(agent)]);
81
- register(ctx, notesRead, (agent) => [identity(agent)]);
82
- register(ctx, notesList, (agent) => [identity(agent)]);
83
- register(ctx, notesSearch, (agent) => [identity(agent)]);
79
+ const toolContext = (agent) => notesToolContext(notesIdentity(agent, engine.config), notesCwd(agent));
80
+ register(ctx, notesWrite, (agent) => [toolContext(agent)]);
81
+ register(ctx, notesUpdate, (agent) => [toolContext(agent)]);
82
+ register(ctx, notesRead, (agent) => [toolContext(agent)]);
83
+ register(ctx, notesList, (agent) => [toolContext(agent)]);
84
+ register(ctx, notesSearch, (agent) => [toolContext(agent)]);
84
85
  register(ctx, historyList, async (agent) => [await historyProjection(ctx, agent.session.id)]);
85
86
  register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)]);
86
87
  register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id]);
@@ -34,6 +34,7 @@ export declare function recordSnapshot(event: SessionEvent): WindowSnapshot | un
34
34
  /** The checkpoint is authoritative when an ignorable record was lost or the transaction's close failed. */
35
35
  export declare function checkpointSnapshot(event: SessionEvent): WindowSnapshot | undefined;
36
36
  export declare function recoverSnapshot(events: readonly SessionEvent[]): WindowSnapshot | undefined;
37
+ export declare function notesCwd(agent: Pick<Agent, "session" | "options">): string;
37
38
  /** Identity is extracted here, never in the filesystem domain. */
38
39
  export declare function notesIdentity(agent: Pick<Agent, "session" | "options">, config: NotesConfig): NotesIdentity;
39
40
  /** Engine-owned, per-session state; prompt reads are synchronous and never read notes again. */
@@ -79,13 +79,16 @@ export function recoverSnapshot(events) {
79
79
  }
80
80
  return latest;
81
81
  }
82
+ export function notesCwd(agent) {
83
+ return agent.session.header.cwd ?? process.cwd();
84
+ }
82
85
  /** Identity is extracted here, never in the filesystem domain. */
83
86
  export function notesIdentity(agent, config) {
84
87
  const home = config.notesHome ?? join(homedir(), ".agents", "notes");
85
88
  return snapshotNotesIdentity({
86
89
  home,
87
90
  sessionId: agent.session.id,
88
- projectKey: projectKey(agent.session.header.cwd ?? process.cwd(), home),
91
+ projectKey: projectKey(notesCwd(agent), home),
89
92
  agent: slugify(config.agentName ?? "dsh"),
90
93
  model: slugify(agent.session.requestHeader()?.config.model ?? agent.options.model ?? "unknown"),
91
94
  });
@@ -108,9 +111,10 @@ export class Windows {
108
111
  if (existing)
109
112
  return existing;
110
113
  const restored = recoverSnapshot(agent.session.snapshotEvents());
111
- const snapshot = restored ?? await this.mint(agent, 0, agent.session.header.createdAt);
114
+ const sameSession = restored !== undefined && restored.windowId === windowId(agent.session.id, restored.window);
115
+ const snapshot = sameSession ? restored : await this.mint(agent, restored?.window ?? 0, agent.session.header.createdAt);
112
116
  signal?.throwIfAborted();
113
- if (!restored)
117
+ if (!sameSession)
114
118
  appendPluginRecord(agent.session, WINDOW_RECORD, snapshot);
115
119
  const state = { snapshot, pendingReset: false, warned: false, reminded: false };
116
120
  restoreWarnings(state, agent.session.snapshotEvents());
@@ -7,3 +7,4 @@ export declare const CONTINUATION_TYPE = "notesoup/continuation";
7
7
  export declare const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
8
8
  export declare const CARRIED_INPUT_TYPE = "notesoup/carried-input";
9
9
  export declare const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
10
+ export declare const MARKER_TYPE = "notesoup/marker";
@@ -7,3 +7,4 @@ export const CONTINUATION_TYPE = "notesoup/continuation";
7
7
  export const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
8
8
  export const CARRIED_INPUT_TYPE = "notesoup/carried-input";
9
9
  export const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
10
+ export const MARKER_TYPE = "notesoup/marker";
@@ -1,3 +1,3 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- /** Register the three shared history operations; the adapter allocates addresses and supplies them. */
2
+ /** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
3
3
  export declare function registerHistoryTools(pi: ExtensionAPI): void;
@@ -1,9 +1,9 @@
1
1
  import { historyWindows, historyList, historyRead } from "../../src/tools/history.js";
2
2
  import { historyFromSession } from "./history.js";
3
3
  import { HISTORY_NAMESPACE, registerOperation } from "./tool-result.js";
4
- /** Register the three shared history operations; the adapter allocates addresses and supplies them. */
4
+ /** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
5
5
  export function registerHistoryTools(pi) {
6
- registerOperation(pi, historyWindows, (params, ctx) => historyWindows.execute(params, historyFromSession(ctx), ctx.sessionManager.getSessionId()), HISTORY_NAMESPACE);
7
- registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE);
8
- registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE);
6
+ registerOperation(pi, historyWindows, (params, ctx) => historyWindows.execute(params, historyFromSession(ctx), ctx.sessionManager.getSessionId()), HISTORY_NAMESPACE, undefined, "deferred");
7
+ registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
8
+ registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
9
9
  }
@@ -0,0 +1,9 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ /** Spacing between durable seq breadcrumbs, in projected history seq. */
3
+ export declare const MARKER_INTERVAL = 50;
4
+ /**
5
+ * Stamp the current seq every MARKER_INTERVAL seqs. The marker names the seq it occupies, so a
6
+ * model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
7
+ * tail still awaits boot or continuation: a foreign message there would close the repair shape.
8
+ */
9
+ export declare function maybeSendMarker(pi: ExtensionAPI, ctx: ExtensionContext): void;
@@ -0,0 +1,36 @@
1
+ import { MARKER_TYPE } from "./entries.js";
2
+ import { nextHistorySeq } from "./history.js";
3
+ import { inspectResetTail } from "./reset/artifacts.js";
4
+ import { markerContent } from "./text.js";
5
+ import { currentReset } from "./window.js";
6
+ /** Spacing between durable seq breadcrumbs, in projected history seq. */
7
+ export const MARKER_INTERVAL = 50;
8
+ /** Highest seq already stamped by a marker; 0 before the first. */
9
+ function lastMarkerSeq(ctx) {
10
+ let last = 0;
11
+ for (const entry of ctx.sessionManager.getEntries()) {
12
+ if (entry.type !== "custom_message" || entry.customType !== MARKER_TYPE)
13
+ continue;
14
+ const seq = entry.details?.seq;
15
+ if (typeof seq === "number" && seq > last)
16
+ last = seq;
17
+ }
18
+ return last;
19
+ }
20
+ /**
21
+ * Stamp the current seq every MARKER_INTERVAL seqs. The marker names the seq it occupies, so a
22
+ * model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
23
+ * tail still awaits boot or continuation: a foreign message there would close the repair shape.
24
+ */
25
+ export function maybeSendMarker(pi, ctx) {
26
+ const reset = currentReset(ctx);
27
+ if (reset) {
28
+ const tail = inspectResetTail(ctx, reset.id, reset.data.windowId);
29
+ if (tail && (!tail.boot || !tail.continuation))
30
+ return;
31
+ }
32
+ const seq = nextHistorySeq(ctx);
33
+ if (seq - lastMarkerSeq(ctx) < MARKER_INTERVAL)
34
+ return;
35
+ pi.sendMessage({ customType: MARKER_TYPE, content: markerContent(seq), display: false, details: { seq } }, { triggerTurn: false });
36
+ }
@@ -4,12 +4,13 @@ import { abandonDream, dreamBegin, dreamEnd, dreamForget, dreamingIdentity } fro
4
4
  import { notesIdentityFromPi } from "./adapter.js";
5
5
  import { notesReadRenderers, notesUpdateRenderers, notesWriteRenderers } from "../render.js";
6
6
  import { DREAM_NAMESPACE, NOTES_NAMESPACE, registerOperation } from "../tool-result.js";
7
+ import { notesToolContext } from "../../../src/tools/notes-context.js";
7
8
  function renderDiff(change) {
8
9
  return change.kind === "none" ? "" : generateDiffString(change.before, change.after, 1).diff;
9
10
  }
10
11
  /** Register the five shared note operations and the three hidden dream tools; an open dream widens the note identity. */
11
12
  export function registerNotesTools(pi) {
12
- // One open dream per session, in memory: shutdown releases its lock without the end commit.
13
+ // One pending or open dream per session: shutdown releases ownership without the end commit.
13
14
  const dreams = new Map();
14
15
  pi.on("session_shutdown", () => {
15
16
  for (const state of dreams.values())
@@ -24,11 +25,12 @@ export function registerNotesTools(pi) {
24
25
  return state;
25
26
  };
26
27
  const identity = (ctx) => dreamingIdentity(notesIdentityFromPi(ctx), dreamOf(ctx));
27
- registerOperation(pi, notesWrite, (params, ctx) => notesWrite.execute(params, identity(ctx)), NOTES_NAMESPACE, notesWriteRenderers);
28
- registerOperation(pi, notesUpdate, (params, ctx) => notesUpdate.execute(params, identity(ctx), renderDiff), NOTES_NAMESPACE, notesUpdateRenderers);
29
- registerOperation(pi, notesRead, (params, ctx) => notesRead.execute(params, identity(ctx)), NOTES_NAMESPACE, notesReadRenderers);
30
- registerOperation(pi, notesList, (params, ctx) => notesList.execute(params, identity(ctx)), NOTES_NAMESPACE);
31
- registerOperation(pi, notesSearch, (params, ctx) => notesSearch.execute(params, identity(ctx)), NOTES_NAMESPACE);
28
+ const toolContext = (ctx) => notesToolContext(identity(ctx), ctx.cwd);
29
+ registerOperation(pi, notesWrite, (params, ctx) => notesWrite.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesWriteRenderers);
30
+ registerOperation(pi, notesUpdate, (params, ctx) => notesUpdate.execute(params, toolContext(ctx), renderDiff), NOTES_NAMESPACE, notesUpdateRenderers);
31
+ registerOperation(pi, notesRead, (params, ctx) => notesRead.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesReadRenderers);
32
+ registerOperation(pi, notesList, (params, ctx) => notesList.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
33
+ registerOperation(pi, notesSearch, (params, ctx) => notesSearch.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
32
34
  registerOperation(pi, dreamBegin, (params, ctx) => dreamBegin.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
33
35
  registerOperation(pi, dreamForget, (params, ctx) => dreamForget.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
34
36
  registerOperation(pi, dreamEnd, (params, ctx) => dreamEnd.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
@@ -1,6 +1,6 @@
1
1
  /** Pi TUI renderers for notesoup's own tools: collapsed one-line slips, expandable bodies. */
2
2
  import { renderDiff } from "@earendil-works/pi-coding-agent";
3
- import { Text, TruncatedText, visibleWidth } from "@earendil-works/pi-tui";
3
+ import { Text, TruncatedText, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
4
4
  /** Expanded bodies show this many lines before a "more lines" marker; the full text is in the receipt. */
5
5
  const EXPANDED_LINE_CAP = 80;
6
6
  /** structuredContent is wireResult(outcome): the data itself, or {error, code}. Old sessions may lack it. */
@@ -155,13 +155,16 @@ export const emptyBrainRenderers = {
155
155
  return {
156
156
  invalidate() { },
157
157
  render(width) {
158
+ if (width <= 0)
159
+ return [];
158
160
  const label = "✂ brain emptied";
159
161
  const prefix = "── ";
160
- const fill = Math.max(2, width - visibleWidth(prefix) - visibleWidth(label) - 1);
162
+ const fill = Math.max(0, width - visibleWidth(prefix) - visibleWidth(label) - 1);
161
163
  const lines = [theme.fg("dim", `${prefix}${label} ${"─".repeat(fill)}`)];
162
164
  if (lastWord !== undefined)
163
- lines.push(theme.fg("warning", theme.italic(`“${lastWord}”`)));
164
- return lines;
165
+ lines.push(...new Text(theme.fg("warning", theme.italic(`“${lastWord}”`)), 0, 0).render(width));
166
+ // The divider, or a wide glyph in a one-column viewport, may still need clipping.
167
+ return lines.map((line) => truncateToWidth(line, width, ""));
165
168
  },
166
169
  };
167
170
  },
@@ -15,9 +15,9 @@ export declare function carriedInputDrafts(inputs: readonly CarriedInput[]): Ext
15
15
  }>[];
16
16
  export declare function isCarriedInputEntry(entry: SessionEntry): boolean;
17
17
  /** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
18
- export declare const LAST_WORD_ADVERTISED_CHARS = 250;
18
+ export declare const LAST_WORD_ADVERTISED_CHARS = 300;
19
19
  /** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
20
- export declare const MAX_LAST_WORD_CHARS = 300;
20
+ export declare const MAX_LAST_WORD_CHARS = 500;
21
21
  /** How the next window finds the note. */
22
22
  export declare const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
23
23
  /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
@@ -10,9 +10,9 @@ export function isCarriedInputEntry(entry) {
10
10
  return entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE && entry.display === true;
11
11
  }
12
12
  /** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
13
- export const LAST_WORD_ADVERTISED_CHARS = 250;
13
+ export const LAST_WORD_ADVERTISED_CHARS = 300;
14
14
  /** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
15
- export const MAX_LAST_WORD_CHARS = 300;
15
+ export const MAX_LAST_WORD_CHARS = 500;
16
16
  /** How the next window finds the note. */
17
17
  export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
18
18
  /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
@@ -11,6 +11,7 @@ import { buildResetDrafts, LAST_WORD_ADVERTISED_CHARS, MAX_LAST_WORD_CHARS, repa
11
11
  import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
12
12
  import { commandWarningContent } from "./text.js";
13
13
  import { buildBootMessage, sendBoot } from "./boot.js";
14
+ import { maybeSendMarker } from "./marker.js";
14
15
  import { nextHistorySeq } from "./history.js";
15
16
  import { errorMessage } from "../../src/error-message.js";
16
17
  function readPackageVersion() {
@@ -73,13 +74,15 @@ export function registerContext(pi, settingsManager) {
73
74
  if (!marker || !isCheckpointBackedReset(ctx, marker) || !resetBoundaryCommitted(ctx, marker.id, windowId))
74
75
  continue;
75
76
  pendingResetNotices.delete(windowId);
76
- // The last word already lands as its own visible sticky-note entry; the
77
- // committed notice stays a one-line marker instead of repeating it.
78
- const forced = markerResetOrigin(marker) === "forced";
79
- ctx.ui.notify(forced ? "🥣 Brain forcibly emptied: overflow" : "🥣 Fresh brain", forced ? "warning" : "info");
77
+ if (markerResetOrigin(marker) === "forced")
78
+ ctx.ui.notify("🥣 Brain forcibly emptied: overflow", "warning");
80
79
  }
81
80
  };
82
- pi.on("turn_start", (_event, ctx) => notifyCommittedResets(ctx));
81
+ pi.on("turn_start", (_event, ctx) => {
82
+ notifyCommittedResets(ctx);
83
+ if (enabled)
84
+ maybeSendMarker(pi, ctx);
85
+ });
83
86
  pi.on("agent_settled", (_event, ctx) => {
84
87
  notifyCommittedResets(ctx);
85
88
  pendingResetNotices.clear();
@@ -88,8 +91,8 @@ export function registerContext(pi, settingsManager) {
88
91
  if (snapshot.unavailable.length === 0 || incompleteNotesNotified.has(windowId))
89
92
  return;
90
93
  incompleteNotesNotified.add(windowId);
91
- const homes = snapshot.unavailable.map((home) => home.label).join(", ");
92
- ctx.ui.notify(`🥣 Some notes went missing: ${homes}`, "warning");
94
+ const namespaces = snapshot.unavailable.map((namespace) => namespace.label).join(", ");
95
+ ctx.ui.notify(`🥣 Some notes went missing: ${namespaces}`, "warning");
93
96
  };
94
97
  const budget = registerBudget(pi, () => enabled, settingsManager);
95
98
  pi.on("session_start", async (_event, ctx) => {
@@ -193,7 +196,7 @@ export function registerContext(pi, settingsManager) {
193
196
  cmdCtx.ui.notify("🥣 Brain already being emptied", "info");
194
197
  return;
195
198
  }
196
- cmdCtx.ui.notify("🥣 Brain being emptied", "info");
199
+ cmdCtx.ui.notify("🥣 Dumping Brain", "info");
197
200
  try {
198
201
  pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: commandWarningContent(prompt !== undefined ? `/empty ${prompt}` : undefined), display: false }, { triggerTurn: true, deliverAs: "steer" });
199
202
  }
@@ -6,6 +6,8 @@
6
6
  */
7
7
  export declare const PI_PRE_RESET_HINTS = "Anything you say here is erased with the reset \u2014 the human can't read it afterward either. Put the handoff in your notes; explanations belong after the reset.\nUnless the human explicitly directs otherwise, decide for yourself when to call empty_brain. Don't keep asking them whether to reset.";
8
8
  export { warningNotice as warningContent } from "../../src/budget/text.js";
9
+ /** Odometer breadcrumb: the marker names its own seq, so history paging reads the landscape directly. */
10
+ export declare function markerContent(seq: number): string;
9
11
  /** The closing model sees deferred input as a bare next-window prompt block. */
10
12
  export declare function promptBlock(commandLine: string): string;
11
13
  /** Approved manual close-out notices; both variants live here. */
@@ -8,6 +8,10 @@ import { COUNTDOWN_LINE, GUIDANCE_CLOSE_TAG, GUIDANCE_OPEN_TAG, WARNING_BODY, WA
8
8
  export const PI_PRE_RESET_HINTS = `Anything you say here is erased with the reset — the human can't read it afterward either. Put the handoff in your notes; explanations belong after the reset.
9
9
  Unless the human explicitly directs otherwise, decide for yourself when to call empty_brain. Don't keep asking them whether to reset.`;
10
10
  export { warningNotice as warningContent } from "../../src/budget/text.js";
11
+ /** Odometer breadcrumb: the marker names its own seq, so history paging reads the landscape directly. */
12
+ export function markerContent(seq) {
13
+ return `<notesoup:marker seq="${seq}" />`;
14
+ }
11
15
  /** The closing model sees deferred input as a bare next-window prompt block. */
12
16
  export function promptBlock(commandLine) {
13
17
  return `<notesoup:next_window_prompt>\n${commandLine}\n</notesoup:next_window_prompt>`;
@@ -116,19 +116,33 @@ export function projectRootWindow(messages, windowId) {
116
116
  /** Usage for the selected window, excluding provider usage recorded before its marker. */
117
117
  export function windowUsage(ctx) {
118
118
  const reset = currentReset(ctx);
119
- if (!reset)
119
+ // Native checkpoints already cut the active projection and Pi invalidates usage
120
+ // after context edits. Preserve that authority, including unknown/unavailable usage.
121
+ if (!reset || isCheckpointBackedReset(ctx, reset))
120
122
  return ctx.getContextUsage();
121
123
  const contextWindow = ctx.model?.contextWindow ?? ctx.getContextUsage()?.contextWindow;
122
124
  if (!contextWindow)
123
125
  return undefined;
124
126
  const windowId = reset.data.windowId;
125
127
  try {
126
- const canonicalMessages = ctx.sessionManager.buildSessionProjection().messages;
127
- // New resets already cut the durable Pi projection. Marker slicing is retained only
128
- // for sessions written before native reset checkpoints existed.
129
- const messages = isCheckpointBackedReset(ctx, reset)
130
- ? canonicalMessages
131
- : projectWindow(canonicalMessages, windowId);
128
+ const projection = ctx.sessionManager.buildSessionProjection();
129
+ const branch = ctx.sessionManager.getBranch();
130
+ let invalidatedThrough = -1;
131
+ for (let i = branch.length - 1; i >= 0; i--) {
132
+ if (branch[i].type === "context_edit" || branch[i].type === "compaction") {
133
+ invalidatedThrough = i;
134
+ break;
135
+ }
136
+ }
137
+ const staleIds = new Set(branch.slice(0, invalidatedThrough + 1).map((entry) => entry.id));
138
+ const staleMessages = new Set(projection.entries
139
+ .filter((entry) => staleIds.has(entry.sourceEntry.id))
140
+ .flatMap((entry) => entry.messages));
141
+ // Legacy marker-only windows still need slicing. Edits preserve assistant metadata,
142
+ // so clear stale usage only in this estimate, never in the persisted projection.
143
+ const messages = projectWindow(projection.messages, windowId).map((message) => message.role === "assistant" && staleMessages.has(message)
144
+ ? { ...message, usage: { ...message.usage, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 } }
145
+ : message);
132
146
  const { tokens } = estimateContextTokens(convertToLlm(messages));
133
147
  return { tokens, contextWindow, percent: tokens / contextWindow * 100 };
134
148
  }
@@ -31,7 +31,7 @@ function section(label, body) {
31
31
  const NAMELESS_AGENT = "anonymous";
32
32
  /** One closed boot snapshot: five tabbed shelves, current hands first, durable last; each shelf keeps its pinned pages and its own freshest pages. */
33
33
  function notesIndex(snapshot, tools, agentName, modelName) {
34
- const homes = [
34
+ const namespaces = [
35
35
  { scope: "session", label: "no @ — this session" },
36
36
  { scope: "project", label: "@project — this project" },
37
37
  { scope: "agent", label: agentName === NAMELESS_AGENT ? "@self — every nameless agent shares this" : `@self — ${agentName} only` },
@@ -39,12 +39,12 @@ function notesIndex(snapshot, tools, agentName, modelName) {
39
39
  { scope: "human", label: "@human — the human" },
40
40
  ];
41
41
  const shelves = [];
42
- for (const home of homes) {
43
- if (snapshot.unavailable.some((failed) => failed.scope === home.scope)) {
44
- shelves.push(section(home.label, indent(`This drawer wouldn't open. Try \`${tools.notesList}\` again.`)));
42
+ for (const namespace of namespaces) {
43
+ if (snapshot.unavailable.some((failed) => failed.scope === namespace.scope)) {
44
+ shelves.push(section(namespace.label, indent(`This drawer wouldn't open. Try \`${tools.notesList}\` again.`)));
45
45
  continue;
46
46
  }
47
- const rows = (snapshot.homes.get(home.scope) ?? []).filter((row) => row.meta.crumpledAt === undefined);
47
+ const rows = (snapshot.namespaces.get(namespace.scope) ?? []).filter((row) => row.meta.crumpledAt === undefined);
48
48
  const pinned = ["CHEATSHEET.md", "MAP.md"].flatMap((path) => {
49
49
  const row = rows.find((row) => row.path === path);
50
50
  return row?.body ? [row] : [];
@@ -59,10 +59,10 @@ function notesIndex(snapshot, tools, agentName, modelName) {
59
59
  });
60
60
  if (pinned.length === 0 && fresh.length === 0)
61
61
  continue;
62
- const parts = pinned.map((row) => `${row.path === "MAP.md" ? "map" : "cheatsheet"}\n\n${indent(pinnedBodyForBoot(row.address, row.body, row.path === "MAP.md" ? MAP_BOOT_MAX_CHARS : CHEATSHEET_BOOT_MAX_CHARS))}`);
62
+ const parts = pinned.map((row) => `${row.address}\n\n${indent(pinnedBodyForBoot(row.address, row.body, row.path === "MAP.md" ? MAP_BOOT_MAX_CHARS : CHEATSHEET_BOOT_MAX_CHARS))}`);
63
63
  if (fresh.length > 0)
64
64
  parts.push(`recent\n\n${fresh.join("\n\n")}`);
65
- shelves.push(section(home.label, parts.join("\n\n")));
65
+ shelves.push(section(namespace.label, parts.join("\n\n")));
66
66
  }
67
67
  return shelves.length > 0
68
68
  ? ["YOUR NOTES\n──────────", ...shelves].join("\n\n\n")
@@ -1,6 +1,6 @@
1
1
  import type { NotesIdentity } from "../notes/identity.js";
2
2
  import { type NoteRow, type Scope } from "../notes/index.js";
3
- declare const NOTES_HOMES: readonly [{
3
+ declare const NOTES_NAMESPACES: readonly [{
4
4
  readonly scope: "session";
5
5
  readonly label: "this session";
6
6
  }, {
@@ -16,19 +16,19 @@ declare const NOTES_HOMES: readonly [{
16
16
  readonly scope: "model";
17
17
  readonly label: "@model";
18
18
  }];
19
- export type NotesHome = (typeof NOTES_HOMES)[number];
19
+ export type NotesNamespace = (typeof NOTES_NAMESPACES)[number];
20
20
  export type NotesLoader = (scope: Scope) => NoteRow[] | Promise<NoteRow[]>;
21
21
  export type NotesSnapshot = {
22
22
  /** Wall-clock instant captured when this boot began; rendering never consults Date.now(). */
23
23
  readonly openedAt: number;
24
- readonly homes: ReadonlyMap<Scope, readonly NoteRow[]>;
25
- readonly unavailable: readonly NotesHome[];
24
+ readonly namespaces: ReadonlyMap<Scope, readonly NoteRow[]>;
25
+ readonly unavailable: readonly NotesNamespace[];
26
26
  };
27
- /** Identity resolution failed before any home could be loaded; boot can still explain the failure. */
27
+ /** Identity resolution failed before any notebook could be loaded; boot can still explain the failure. */
28
28
  export declare function unavailableNotesSnapshot(openedAt: number): NotesSnapshot;
29
29
  /**
30
- * Acquire the five homes once for one boot. Only filesystem-style errno failures are isolated;
30
+ * Acquire the five notebooks once for one boot. Only filesystem-style errno failures are isolated;
31
31
  * malformed note data and unrelated construction errors remain visible to the caller.
32
32
  */
33
- export declare function loadNotesSnapshot(identity: NotesIdentity, openedAt: number, loadHome?: NotesLoader): Promise<NotesSnapshot>;
33
+ export declare function loadNotesSnapshot(identity: NotesIdentity, openedAt: number, loadNamespace?: NotesLoader): Promise<NotesSnapshot>;
34
34
  export {};