notesoup 0.61.0 → 0.62.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 (200) hide show
  1. package/.agents/plugins/marketplace.json +15 -0
  2. package/README.md +14 -11
  3. package/dist/plugins/antigravity/src/cli.d.ts +1 -0
  4. package/dist/plugins/antigravity/src/cli.js +23 -0
  5. package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
  6. package/dist/plugins/antigravity/src/hooks.js +53 -0
  7. package/dist/plugins/antigravity/src/identity.d.ts +26 -0
  8. package/dist/plugins/antigravity/src/identity.js +129 -0
  9. package/dist/plugins/claude/src/helper.js +2 -1
  10. package/dist/plugins/codex/src/hooks.js +1 -0
  11. package/dist/plugins/codex/src/identity.d.ts +6 -1
  12. package/dist/plugins/codex/src/identity.js +13 -1
  13. package/dist/plugins/codex/src/mcp.d.ts +35 -7
  14. package/dist/plugins/codex/src/mcp.js +26 -88
  15. package/dist/plugins/codex/src/text.js +3 -3
  16. package/dist/plugins/dsh/tools.js +8 -4
  17. package/dist/plugins/mcp/operations.d.ts +15 -0
  18. package/dist/plugins/mcp/operations.js +43 -0
  19. package/dist/plugins/mcp/server.d.ts +14 -0
  20. package/dist/plugins/mcp/server.js +13 -0
  21. package/dist/plugins/pi/budget.d.ts +1 -1
  22. package/dist/plugins/pi/budget.js +3 -2
  23. package/dist/plugins/pi/entries.d.ts +1 -0
  24. package/dist/plugins/pi/entries.js +1 -0
  25. package/dist/plugins/pi/history-tools.js +2 -1
  26. package/dist/plugins/pi/history.js +18 -1
  27. package/dist/plugins/pi/notes/tools.js +7 -3
  28. package/dist/plugins/pi/render.d.ts +7 -1
  29. package/dist/plugins/pi/render.js +2 -2
  30. package/dist/plugins/pi/reset/lifecycle.d.ts +1 -1
  31. package/dist/plugins/pi/reset/lifecycle.js +8 -9
  32. package/dist/plugins/pi/runtime.js +102 -61
  33. package/dist/plugins/pi/tool-result.js +7 -7
  34. package/dist/plugins/pi/window.d.ts +33 -3
  35. package/dist/plugins/pi/window.js +209 -9
  36. package/dist/src/boot/render.js +18 -15
  37. package/dist/src/boot/text.d.ts +3 -1
  38. package/dist/src/boot/text.js +22 -20
  39. package/dist/src/budget/text.d.ts +2 -2
  40. package/dist/src/budget/text.js +13 -13
  41. package/dist/src/history/claude.d.ts +2 -0
  42. package/dist/src/history/claude.js +46 -0
  43. package/dist/src/history/codex-transcript.js +7 -5
  44. package/dist/src/history/codex.js +3 -0
  45. package/dist/src/history/corpus.d.ts +28 -1
  46. package/dist/src/history/corpus.js +40 -0
  47. package/dist/src/history/history.d.ts +37 -46
  48. package/dist/src/history/history.js +21 -40
  49. package/dist/src/history/local.js +67 -32
  50. package/dist/src/history/pi.d.ts +2 -1
  51. package/dist/src/history/pi.js +122 -48
  52. package/dist/src/history/prefilter.js +76 -19
  53. package/dist/src/history/query.d.ts +28 -49
  54. package/dist/src/history/query.js +83 -68
  55. package/dist/src/history/summary-cache.d.ts +8 -1
  56. package/dist/src/history/summary-cache.js +138 -12
  57. package/dist/src/index.d.ts +1 -1
  58. package/dist/src/index.js +1 -1
  59. package/dist/src/notes/errors.d.ts +1 -1
  60. package/dist/src/notes/frontmatter.d.ts +0 -2
  61. package/dist/src/notes/frontmatter.js +0 -2
  62. package/dist/src/notes/index.d.ts +1 -1
  63. package/dist/src/notes/index.js +1 -1
  64. package/dist/src/notes/policy.d.ts +15 -1
  65. package/dist/src/notes/policy.js +46 -5
  66. package/dist/src/notes/store.d.ts +12 -0
  67. package/dist/src/notes/store.js +16 -20
  68. package/dist/src/text-match.d.ts +10 -1
  69. package/dist/src/text-match.js +42 -3
  70. package/dist/src/tools/dream.d.ts +22 -93
  71. package/dist/src/tools/dream.js +30 -27
  72. package/dist/src/tools/history.d.ts +33 -26
  73. package/dist/src/tools/history.js +257 -163
  74. package/dist/src/tools/notes.d.ts +51 -163
  75. package/dist/src/tools/notes.js +146 -100
  76. package/dist/src/tools/output.d.ts +2 -1
  77. package/dist/src/tools/output.js +2 -1
  78. package/dist/src/tools/result.d.ts +4 -7
  79. package/dist/src/tools/result.js +8 -9
  80. package/dist/src/tools/schema.d.ts +4 -1
  81. package/dist/src/tools/schema.js +25 -1
  82. package/dist/test/agent-loop.test.js +198 -16
  83. package/dist/test/antigravity-live.test.d.ts +1 -0
  84. package/dist/test/antigravity-live.test.js +142 -0
  85. package/dist/test/antigravity-plugin.test.d.ts +1 -0
  86. package/dist/test/antigravity-plugin.test.js +101 -0
  87. package/dist/test/boot.integration.test.js +133 -14
  88. package/dist/test/claude-history.test.js +14 -13
  89. package/dist/test/claude-mod.test.js +9 -6
  90. package/dist/test/codex-history.test.js +15 -3
  91. package/dist/test/codex-plugin.test.js +76 -38
  92. package/dist/test/dependencies.test.js +7 -3
  93. package/dist/test/dream-skill.test.js +3 -3
  94. package/dist/test/dream-tools.test.js +101 -56
  95. package/dist/test/dsh.test.js +34 -19
  96. package/dist/test/helpers/dependency-graph.js +2 -2
  97. package/dist/test/helpers/extension.d.ts +65 -2
  98. package/dist/test/helpers/extension.js +72 -3
  99. package/dist/test/history-corpus.test.js +79 -77
  100. package/dist/test/history-summary-cache.test.js +97 -9
  101. package/dist/test/history.integration.test.js +234 -168
  102. package/dist/test/host-neutral.test.js +69 -19
  103. package/dist/test/marker.test.js +1 -1
  104. package/dist/test/note-policy.test.js +96 -77
  105. package/dist/test/notes.integration.test.js +212 -94
  106. package/dist/test/notes.test.js +184 -113
  107. package/dist/test/pi-render.test.js +20 -12
  108. package/dist/test/project-namespace.test.js +3 -2
  109. package/dist/test/reset-lifecycle.test.js +2 -2
  110. package/docs/antigravity.md +44 -0
  111. package/docs/architecture.md +6 -4
  112. package/docs/claude-code-mod.md +2 -2
  113. package/docs/codex.md +36 -38
  114. package/docs/dsh.md +3 -3
  115. package/docs/history-sessions.md +28 -50
  116. package/docs/notes-library.md +4 -4
  117. package/docs/skills.md +3 -3
  118. package/docs/tool-results.md +47 -28
  119. package/package.json +3 -2
  120. package/playbook.md +1 -1
  121. package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
  122. package/plugins/antigravity/hooks.json +7 -0
  123. package/plugins/antigravity/mcp_config.json +8 -0
  124. package/plugins/antigravity/plugin.json +6 -0
  125. package/plugins/antigravity/src/cli.ts +22 -0
  126. package/plugins/antigravity/src/hooks.ts +51 -0
  127. package/plugins/antigravity/src/identity.ts +127 -0
  128. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  129. package/plugins/claude/dist/claude/helper.js +1059 -534
  130. package/plugins/claude/hooks/register.ts +2 -2
  131. package/plugins/claude/playbook.md +1 -1
  132. package/plugins/claude/skills/dream/SKILL.md +1 -1
  133. package/plugins/claude/skills/notesoup/SKILL.md +92 -0
  134. package/plugins/claude/src/helper.ts +2 -1
  135. package/plugins/codex/.codex-plugin/plugin.json +8 -0
  136. package/plugins/codex/.mcp.json +11 -0
  137. package/plugins/codex/README.md +5 -21
  138. package/plugins/codex/dist/codex/notesoup.js +18480 -17946
  139. package/plugins/codex/src/hooks.ts +1 -0
  140. package/plugins/codex/src/identity.ts +14 -1
  141. package/plugins/codex/src/mcp.ts +28 -98
  142. package/plugins/codex/src/text.ts +3 -3
  143. package/plugins/dsh/tools.ts +8 -4
  144. package/plugins/mcp/operations.ts +50 -0
  145. package/plugins/mcp/server.ts +23 -0
  146. package/plugins/paseo/README.md +5 -10
  147. package/plugins/paseo/client/brain-empty-card.tsx +3 -3
  148. package/plugins/paseo/client/markdown.tsx +50 -38
  149. package/plugins/paseo/client/notes-op-card.tsx +12 -9
  150. package/plugins/paseo/client/paper-card.tsx +6 -5
  151. package/plugins/paseo/client/paper-palette.ts +2 -9
  152. package/plugins/paseo/client/sticky-card.tsx +2 -2
  153. package/plugins/paseo/client/tool-result.ts +7 -14
  154. package/plugins/paseo/package-lock.json +3406 -0
  155. package/plugins/paseo/package.json +1 -0
  156. package/plugins/paseo/test/markdown-core.test.ts +73 -66
  157. package/plugins/pi/budget.ts +3 -3
  158. package/plugins/pi/entries.ts +1 -0
  159. package/plugins/pi/history-tools.ts +2 -1
  160. package/plugins/pi/history.ts +30 -1
  161. package/plugins/pi/notes/tools.ts +7 -3
  162. package/plugins/pi/render.ts +6 -6
  163. package/plugins/pi/reset/lifecycle.ts +9 -10
  164. package/plugins/pi/runtime.ts +96 -60
  165. package/plugins/pi/tool-result.ts +8 -8
  166. package/plugins/pi/window.ts +198 -9
  167. package/skills/dream/SKILL.md +1 -1
  168. package/skills/notesoup/SKILL.md +92 -0
  169. package/src/boot/render.ts +18 -15
  170. package/src/boot/text.ts +23 -19
  171. package/src/budget/text.ts +13 -13
  172. package/src/history/claude.ts +41 -0
  173. package/src/history/codex-transcript.ts +6 -4
  174. package/src/history/codex.ts +2 -0
  175. package/src/history/corpus.ts +51 -2
  176. package/src/history/history.ts +35 -44
  177. package/src/history/local.ts +67 -27
  178. package/src/history/pi.ts +113 -35
  179. package/src/history/prefilter.ts +73 -15
  180. package/src/history/query.ts +93 -73
  181. package/src/history/summary-cache.ts +142 -17
  182. package/src/index.ts +1 -1
  183. package/src/notes/errors.ts +1 -1
  184. package/src/notes/frontmatter.ts +0 -3
  185. package/src/notes/index.ts +1 -1
  186. package/src/notes/policy.ts +44 -5
  187. package/src/notes/store.ts +17 -20
  188. package/src/text-match.ts +46 -4
  189. package/src/tools/dream.ts +29 -31
  190. package/src/tools/history.ts +249 -142
  191. package/src/tools/notes.ts +145 -113
  192. package/src/tools/output.ts +2 -1
  193. package/src/tools/result.ts +12 -11
  194. package/src/tools/schema.ts +24 -1
  195. package/plugins/claude/skills/memory/SKILL.md +0 -69
  196. package/plugins/codex/mcp.json +0 -10
  197. package/plugins/codex/plugin.json +0 -6
  198. package/plugins/paseo/client/markdown-core.tsx +0 -189
  199. package/plugins/paseo/client/typography.ts +0 -24
  200. package/skills/memory/SKILL.md +0 -69
@@ -233,7 +233,7 @@ test("manual /empty spans tool turns and commits the stop at settlement", async
233
233
  assert.equal(markers.length, 1, "the reset commits at settlement");
234
234
  assert.equal(settle.continue, false, "a manual wipe does not continue after the reset");
235
235
  });
236
- test("off stops future automatic/manual reset requests while an existing marker remains authoritative", async () => {
236
+ test("off stops future automatic/manual reset requests and hands compaction back to native Pi", async () => {
237
237
  const h = harness();
238
238
  await h.callTool("empty_brain");
239
239
  const first = resultEntries(await h.emit("turn_end", fakeBoundaryEvent()));
@@ -248,7 +248,7 @@ test("off stops future automatic/manual reset requests while an existing marker
248
248
  preparation: { tokensBefore: 100, firstKeptEntryId: null, keptMessages: [], droppedMessages: [] },
249
249
  signal: new AbortController().signal,
250
250
  });
251
- assert.deepEqual(before.at(-1), { cancel: true }, "/compact is canceled when an existing marker would expose old canonical history");
251
+ assert.equal(before.at(-1), undefined, "off lets native Pi compaction run even after an earlier reset");
252
252
  const afterOff = resultEntries(await h.emit("turn_end", fakeBoundaryEvent()));
253
253
  assert.equal(afterOff.entries.length, 0, "off does not create another reset");
254
254
  await h.runCommand("notesoup", "on");
@@ -0,0 +1,44 @@
1
+ # Antigravity CLI
2
+
3
+ Notesoup provides a native **Antigravity CLI 1.5.17** plugin: a first-invocation notes boot and the four notes operations. It shares the same notes store, names, addressing, schemas, and rendering as the Pi and other Notesoup hosts. It does not implement native Antigravity history, context-budget reporting or context reset/compaction recovery.
4
+
5
+ ## Install
6
+
7
+ From an unpacked Notesoup distribution, install the plugin directory (it contains its bundled helper, so Node.js must be on your PATH). From a source checkout, run the build first:
8
+
9
+ ```sh
10
+ npm run build
11
+ agy plugin validate plugins/antigravity --strict
12
+ agy plugin install plugins/antigravity
13
+ agy plugin list
14
+ ```
15
+
16
+ For upgrades, repeat `agy plugin install` with the new build. Start or resume a conversation after installation. Notesoup does not request permissive global tool settings; approve its MCP calls using Antigravity's ordinary permissions. Its native MCP server appears as `notesoup_notesoup`, with `notes_write`, `notes_update`, `notes_read`, and `notes_list`.
17
+
18
+ Run `agy plugin disable notesoup` to disable the hooks and tools or `agy plugin uninstall notesoup` to remove the plugin. Neither command deletes the notes library. The default notes location is `~/.agents/notes`; set an absolute `NOTESOUP_HOME` before launching `agy` to use a different library.
19
+
20
+ ## Boot and identity
21
+
22
+ The plugin uses a `PreInvocation` command hook, which runs before Antigravity calls a model (including native subagents), and an ordinary stdio MCP server. It injects the shared Notesoup protocol as a native `systemMessage` step and the identity/pinned notes/index separately as a `userMessage` step. Writable notebooks never enter the protocol message. On the tested Gemini serialization, Antigravity itself wraps the system step as a user-role `<SYSTEM_MESSAGE>` rather than placing it in Gemini's `systemInstruction`; the actual notebook data remains a distinct user message.
23
+
24
+ The hook saves the model name and cwd that the host reports, keyed by the **native conversation ID**, under the plugin's `PLUGIN_DATA`. The conversation's first invocation emits its own boot. Subsequent invocations refresh the identity for tools without repeating the persisted boot. Resume retains that boot in the native trajectory. This is one boot per conversation, **not** one per compacted context window: there is no native compaction-boundary integration or acknowledgement of hook output persistence. If the host discards the injected steps, refresh is not automatic.
25
+
26
+ MCP tools require host-provided `_meta["antigravity.google/conversation_id"]` and `_meta["antigravity.google/root_conversation_id"]` on every operation, and an exact hook binding for the invoking conversation. Roots, children and parallel siblings have separate session notebooks; a root ID is never a replacement for a child ID. Native parent/root/agent facts are cross-checked when present in the hook and the call. Project selection uses the hook's actual cwd and the shared project namespace resolver, not the MCP process's working directory. The current hook's concrete `modelName` selects `@model` (last provider path component, slugged); absent/`auto` model facts are refused rather than assigned to an arbitrary model notebook. An identity-refresh failure stops that model invocation instead of allowing tools to reuse an older binding. Start a new conversation before switching `NOTESOUP_HOME`.
27
+
28
+ The tested host did not supply `agentName` or ancestry in either root or dynamically defined child hooks, and the corresponding calls had no `agent_name`. These conversations use the shared `anonymous` agent shelf, not a fabricated name inferred from the prompt, role or agent definition. If the host supplies an agent name, Notesoup uses it; MCP's native agent name can refine a hook that did not name an agent. This is a host limitation: an unreported named agent cannot have its own name's pins at boot. A mismatched, absent or unbound conversation is refused; no global/latest-conversation fallback exists.
29
+
30
+ See [Notes library](notes-library.md) for notes usage.
31
+
32
+ ## Native verification
33
+
34
+ The host contract comes from the installed 1.5.17 `agy-customizations/docs/{plugins,hooks,mcp_servers}.md` and its changelog (1.4.4 added the root conversation ID in MCP call metadata). The adapter was also verified against the actual 1.5.17 executable in a clean disposable home, with a scripted loopback Gemini API endpoint using the CLI's supported API-key provider. No personal account credentials, external model requests, real notes, or global permission changes were used. This verifies native host behavior, not model quality.
35
+
36
+ Run the normal fixture tests and the opt-in real-host smoke:
37
+
38
+ ```sh
39
+ npm run build
40
+ node --test dist/test/antigravity-plugin.test.js
41
+ NOTESOUP_AGY_LIVE="$(command -v agy)" node --test dist/test/antigravity-live.test.js
42
+ ```
43
+
44
+ The live smoke installs the unmodified native plugin in the isolated home. It confirms a first-turn request already contains pinned project, human and model sentinels with no tool reads; a root plus two overlapping native children each receive their own boot and successfully write, read, update and list their own session note through MCP; resuming the root retains one original boot and reads its original updated session note. The smoke's only permission rules are exact Notesoup operation allowances inside the disposable home.
@@ -8,6 +8,8 @@ notesoup uses Pi's session branch as the durable source of truth. It does not ma
8
8
  | --- | --- | --- |
9
9
  | `index.ts` | The curated host-neutral core surface: the notes library, the boot snapshot/renderer and bindings, the shared operations, and the budget prose | Host entry only; the core never imports a plugin |
10
10
  | `plugins/pi/index.ts` | The Pi plugin entry: default extension and `createNotesoup` | Pi only; composed from the domains |
11
+ | `plugins/mcp/` | Expose shared tool operations over stdio; validate arguments, then resolve identity for this request | No host session, hook, rollout, or process-cwd assumptions |
12
+ | `plugins/codex/`, `plugins/antigravity/` | Bind each native caller, register MCP and inject the shared notes snapshot through host hooks | Each owns its identity and lifecycle; neither imports the other |
11
13
  | `plugins/claude/src/` | Claude Code helper, live transcript/head binding and threshold derivation | Claude only; wire decoding is shared under `src/history/claude.ts` |
12
14
  | `notes/identity.ts`, `notes/store.ts`, `notes/address.ts`, `notes/paths.ts` | Explicit `NotesIdentity`, filesystem notebooks, metadata, addressing and mutations | Node filesystem, no SDK or host environment identity |
13
15
  | `boot/snapshot.ts` | Load each of the five notebooks once; isolate filesystem errno failures | Explicit identity, captured time and optional scope loader |
@@ -19,7 +21,7 @@ notesoup uses Pi's session branch as the durable source of truth. It does not ma
19
21
  | `budget/constants.ts`, `budget/policy.ts`, `budget/text.ts` | Pure thresholds, unknown/clamped countdown and reminder text | Values supplied by the caller; no settings reads or scheduling |
20
22
  | `tools/notes-context.ts` | Host base cwd plus default identity, and one per-call cwd resolver | Shared current-project selection; no host SDK or sticky cwd mutation |
21
23
  | `result.ts`, `text-match.ts` | Shared outcome/error primitives, literal-query validation/matching and prefix fitting | No tool-layer dependencies |
22
- | `tools/notes.ts`, `tools/history.ts`, `tools/schema.ts`, `tools/result.ts`, `tools/output.ts` | Tool schemas, note/history operations, output limits/refusal copy, bounded result selection and pure text rendering | Explicit tool context/projection; one bounded result feeds both text and structured output |
24
+ | `tools/notes.ts`, `tools/history.ts`, `tools/schema.ts`, `tools/result.ts`, `tools/output.ts` | Tool schemas, note/history operations, output limits/refusal copy, bounded result selection and pure text rendering | Explicit tool context/projection; text results within 32 KiB; structured data only for `notes_read` |
23
25
  | `settings.ts` | The `notesoup` settings key, the plain-object test and the per-key global/project merge | Raw records only; each host names and validates the fields it consumes |
24
26
  | `dream/settings.ts` | Dreamer-pattern validation over the merged record | Parsed values only; no SDK or I/O |
25
27
  | `dream/` | Jail, crumpled-only physical deletion, locks, gates, Git audit, doctor, playbook and result/report logic | Independent filesystem/policy functions; no reverse import into Pi |
@@ -62,13 +64,13 @@ The Pi history adapter supplies the selected raw session branch on demand withou
62
64
 
63
65
  The boot notes index in `boot/snapshot.ts` is a closed snapshot: the current session, project, human, agent, and model notebooks are each loaded at most once while constructing a boot. `boot/snapshot.ts` takes explicit `NotesIdentity`, captured `openedAt` and an optional notebook loader; `boot/render.ts` renders that snapshot and explicit tool bindings without reading the filesystem or consulting the clock. Pi supplies its unchanged tool names. MAP bodies and pocket metadata are derived from the same snapshot, so a boot cannot mix two filesystem reads. Note storage and notebook traversal use `node:fs/promises`; same-file operations queue by absolute physical filename across store instances in this process, without promising symlink/case-alias or cross-process locking. Known persisted metadata is camelCase. Old snake_case keys are unrecognized extras, not interpreted or migrated; startup does not migrate notes. A missing notebook (`ENOENT`) is normal. A real read failure omits only that notebook's index, preserves healthy notebooks, adds a model-facing `notes_list` recovery notice, and notifies the human once for that window. Boot/reset construction captures session, agent, and model identity before awaiting the snapshot, then checks lifecycle generation, active window, enabled state, and abort status before sending or returning artifacts; stale completions cannot commit into a switched or shut-down session. Boot acquisition uses listing and never updates access metadata. Explicit note reads update `lastAccessed` and `accessCount`; no fallback state is created.
64
66
 
65
- Notes remain in their filesystem-backed notebooks, unchanged by session branch navigation. Tool reads expose metadata separately from body windows; search/read code-point offsets are body-relative and do not depend on frontmatter serialization or access-counter changes. A single effective per-note policy resolves optional `pinned`, `budget`, and `readonly` frontmatter: root CHEATSHEET/MAP default pinned, ordinary pages default to a 4096-code-point advisory budget (2048 for root CHEATSHEET/MAP), and readonly defaults false (a soft lock, not security). Storage serializes pin admission per notebook (five live pins) before file mutation; boot uses that metadata to inject full pinned bodies with budget warnings, visibly naming omitted pins in manually over-cap notebooks.
67
+ Notes remain in their filesystem-backed notebooks, unchanged by session branch navigation. Tool reads expose metadata separately from body windows; search/read code-point offsets are body-relative and do not depend on frontmatter serialization or access-counter changes. A single effective per-note policy resolves optional `pinned`, `budget`, and `readonly` frontmatter (root `CHEATSHEET.md` defaults pinned with a tighter UTF-8 byte budget; `readonly` defaults false as a soft lock, not security; see [per-note policy](notes-library.md#per-note-policy)). Storage serializes pin admission per notebook before file mutation; boot uses that metadata to inject pinned bodies truncated to their byte budget with out-of-body `<notesoup:warning>` notices, visibly naming omitted pins in manually over-cap notebooks.
66
68
 
67
69
  Every notes tool accepts an optional per-call `cwd`. The host adapter supplies a `NotesToolContext` containing its base cwd and default `NotesIdentity`; shared tool code resolves a relative override against that base, requires an existing directory, and derives one override `projectKey` through the existing project resolver. Storage, addresses, globs, receipts, and new session-note ownership all consume that same resolved identity. The override neither mutates the context nor changes `NotesIdentity.home`; the standalone store still receives explicit identities and has no cwd-discovery behavior. Dream markers survive resolution, so an override cannot widen dream write permission.
68
70
 
69
- `notes_list` uses one schema and renderer for browse rows and query hits. Notes/history operations return schema-derived `Outcome<T>` values, not host `content` objects. One bounded candidate is measured against both its complete structured serialization and its text renderer. Pi registers the outcome schema and packages that same value as `structuredContent`, derives `isError` from it and puts rendered text in `content`. Claude uses the same operations and renderers. Neither adapter parses text or independently chooses a page. Read continuation hints follow Pi's native trailing-notice style and are not part of the addressed text. See [tool results](tool-results.md) for the breaking protocol and coordinate contract.
71
+ All shared tools return text within 32 KiB, including notices and continuation hints. Only `notes_read` also offers structured data, bounded to the same size in JSON. In Pi codemode and DSH the other tools return strings. Pi's note mutation cards display policy, warnings and diffs without adding a structured tool result. The same selected body window supplies both text and structured note reads; continuation markers are not part of the note body. See [tool results](tool-results.md) for how to read and continue results.
70
72
 
71
- The `/fresh-window` command only waits for idle when the session is busy with non-agent work; during model output it arms the close-out and steers the checkpoint prompt into the running turn. While enabled, `/compact` is cancelled with an actionable `/fresh-window` notice. Disabling notesoup stops new automatic resets, but an existing native checkpoint/marker still excludes earlier history and native compaction is still cancelled on that marked branch; a fresh root may use native Pi semantics. Threshold and warning accounting use active-window provider usage rather than pre-reset global usage. Pre-send hard-reserve checks estimate the complete projected transcript, including real system sections and tool declarations; native provider usage remains authoritative once available, and post-checkpoint unknown usage stays unknown. Budget policy and staged prompts are instance-owned, so concurrent sessions cannot share reserve/enablement or uncommitted drafts; default file-backed policy is cached per instance, while injected policy is resolved live on each decision and model/session transitions reset the diagnostic lifecycle.
73
+ The `/fresh-window` command only waits for idle when the session is busy with non-agent work; during model output it arms the close-out and steers the checkpoint prompt into the running turn. While enabled, `/compact` is cancelled with an actionable `/fresh-window` notice. Disabling notesoup stops new automatic resets and hands compaction back to native Pi semantics: before any later native compaction, an existing checkpoint/marker still excludes earlier history, and once a native compaction runs it supersedes the older reset boundary (and re-enabling notesoup lazily re-boots the post-compaction window). Threshold and warning accounting use active-window provider usage rather than pre-reset global usage. Pre-send hard-reserve checks estimate the complete projected transcript, including real system sections and tool declarations; native provider usage remains authoritative once available, and post-checkpoint unknown usage stays unknown. Budget policy and staged prompts are instance-owned, so concurrent sessions cannot share reserve/enablement or uncommitted drafts; default file-backed policy is cached per instance, while injected policy is resolved live on each decision and model/session transitions reset the diagnostic lifecycle.
72
74
 
73
75
  ## Evidence and limits
74
76
 
@@ -26,11 +26,11 @@ Both interactive and headless (`-p` / SDK) resets use `$.command.run({command:"c
26
26
 
27
27
  A command receipt and prepared boot are not commit evidence. On Claude Code 2.1.319, interactive completion exposes the installed boot through `$.session.messages()`. Headless completion still exposes the old request snapshot and precedes appends, so the worker waits for successful main `session.append` results: a kept compact boundary followed by the unchanged boot with its UUID. A missing or rewritten boot, veto, or rejected command cannot start continuation. Boot acquisition failure vetoes an explicit reset without advancing the window. After commit, a dropped or failed continuation is reported without compacting again. Native command/output rows remain alongside the fresh boot; no compaction model request is made. A Claude dream backend is not implemented, and budget reporting (`get_context_remaining`) remains Pi-only.
28
28
 
29
- The notes tools also serve subagent calls, using the same session identity and shared operations. The plugin exposes the shared memory and dream skills and the dream playbook; the build keeps these copies byte-identical to the canonical files.
29
+ The notes tools also serve subagent calls, using the same session identity and shared operations. The plugin exposes the shared notesoup and dream skills and the dream playbook; the build keeps these copies byte-identical to the canonical files.
30
30
 
31
31
  ## Persisted history
32
32
 
33
- The [shared schemas and results](tool-results.md) apply here too: `notes_list` browses or searches with `query`; `history_list` uses `after` / `before` for paging and accepts `context` alongside a query. With `session` omitted they read the current main session's persisted JSONL, via the documented `classic.SessionStart.transcript_path`; no path is guessed and `$.session.messages()` is not treated as full history. The classic binding survives typed `session.start`, which fires later. Without that path, current-session history calls refuse and the boot says history is unavailable. Subagent history calls refuse rather than silently exposing the main transcript.
33
+ The [shared schemas and results](tool-results.md) apply here too: `notes_list` browses or searches with `query`; `history_list` pages through one timeline with seq/time bounds or lists sessions via wildcards; `history_search` finds passages using a required query, time bounds and optional neighboring events. With `session` omitted they read the current main session's persisted JSONL, via the documented `classic.SessionStart.transcript_path`; no path is guessed and `$.session.messages()` is not treated as full history. The classic binding survives typed `session.start`, which fires later. Without that path, current-session history calls refuse and the boot says history is unavailable. Subagent history calls refuse rather than silently exposing the main transcript.
34
34
 
35
35
  Explicit `session` selectors use the [local cross-harness corpus](history-sessions.md), including Pi/Claude/Codex files, without needing the current main transcript to have a head yet. Explicitly selecting the current Claude session still uses its strict live binding. Offline Claude targets prefer non-attachment graph leaves when available, then select the last remaining leaf in transcript order; no leaves still refuses. The persisted Claude decoder is shared under `src/history/claude.ts`; its plugin entry remains in `plugins/claude/src/history.ts`.
36
36
 
package/docs/codex.md CHANGED
@@ -1,13 +1,11 @@
1
1
  # Codex plugin (native mode)
2
2
 
3
- `plugins/codex/` makes notesoup a native Codex plugin: the five notebooks and the two history tools over a bundled stdio MCP server, plus a SessionStart/SubagentStart hook that writes the notes boot into the window Codex is actually opening. It does not wrap Codex's conversation or replace its context engine. Reset and budget stay native.
3
+ `plugins/codex/` makes notesoup a native Codex plugin: five notebooks and two history tools over a bundled stdio MCP server, plus SessionStart/SubagentStart hooks that deliver the notes boot into the model's initial context. It does not wrap Codex's conversation or replace its context engine. Reset and budget stay native.
4
4
 
5
- Targets **Codex 0.160.1 only**, with the rollout format source-checked against the official 0.160.1 tree. No live Codex host or config-parser evidence is claimed at this stage. The rollout decoder rejects any other `cli_version`; it is not a forward-compatible reader. A `.jsonl.zst` rollout needs **Node >=22.15** (`zstdDecompressSync`); the plugin invokes `node`, which must resolve to that version.
5
+ Validated against the installed **Codex 0.171.0**, including real model turns. The rollout reader checks supported wire shapes, not a version whitelist; an unknown producer version isn't automatically rejected. Unsupported or ambiguous data still fails explicitly. Compressed `.jsonl.zst` rollouts require **Node >=22.15** (`zstdDecompressSync`).
6
6
 
7
7
  ## Install (from this checkout)
8
8
 
9
- Build the bundled helper first; `plugins/codex/dist/codex/notesoup.js` is generated and is not committed.
10
-
11
9
  ```sh
12
10
  npm ci
13
11
  npm run build
@@ -15,9 +13,9 @@ codex plugin marketplace add /absolute/path/to/notesoup
15
13
  codex plugin add notesoup@notesoup
16
14
  ```
17
15
 
18
- `codex plugin add` copies the plugin into Codex's plugin cache, so the marketplace path is needed only to add it. Approve the plugin's `SessionStart`, `SubagentStart` and `PreCompact` hooks when Codex asks; an untrusted hook does not run, and notesoup will then refuse its MCP calls as `unknown_thread`. Restart Codex or resume the thread after installing.
16
+ Codex copies the native `.codex-plugin/plugin.json`, `.mcp.json`, hooks and built helper into its cache; build before installing or refreshing the plugin. Review and trust the three notesoup hooks in Codex's `/hooks` UI. Review and approve the notesoup MCP tools according to your own permission settings. An untrusted hook does not run, and notesoup then refuses MCP calls as `unknown_thread`. Restart Codex or resume the thread after changing configuration.
19
17
 
20
- Native mode is switched on in `~/.codex/config.toml`. This is the source-checked shape (the stage does not run Codex's config parser):
18
+ Merge these settings into `~/.codex/config.toml` rather than replacing it (or use `CODEX_HOME` to select a different Codex home):
21
19
 
22
20
  ```toml
23
21
  [features]
@@ -29,63 +27,63 @@ enabled = true
29
27
  use_history_notes_extension = false
30
28
  ```
31
29
 
32
- Keep the forms separate: `token_budget` is a table here, so do not also write `token_budget = true`. These are under-development Codex flags; a different Codex release may rename them, which is one more reason this adapter pins 0.160.1. `retain_client_tool_outputs`, where a newer Codex provides it, is a separate flag from `retain_client_developer_messages`; do not assume one setting covers both.
33
-
34
- `context_management = false` disables the experiment notesoup replaces. `[features.token_budget]` supplies the native `new_context` and `get_context_remaining` tools; notesoup does not implement either one. `use_history_notes_extension = false` leaves notes and history to notesoup.
30
+ Do not also write `token_budget = true`: it is a table here. `context_management = false` disables the competing experiment. `token_budget` supplies native `new_context` and `get_context_remaining`, while `use_history_notes_extension = false` leaves persistent notes/history to notesoup. These flags are under development and may change in later releases.
35
31
 
36
32
  ## What the agent gets
37
33
 
38
- - **A boot per native window.** The `SessionStart` hook reads the thread's native rollout, binds the thread to this Codex root session, cwd, model, transcript and current window, and returns the shared notes boot with a window marker. The boot is deduped by the host's own persisted `hooks.additional_context` record for that exact thread and window, never by a quoted marker. A compact creates a new native window and therefore a fresh boot.
39
- - **Codex's `new_context` and `get_context_remaining`.** They remain Codex's tools. notesoup has no MCP reset or budget fallback, and an MCP call cannot trigger a reset.
40
- - **Five notebooks** through `notes_write`, `notes_update`, `notes_read` and `notes_list` (add `query` to search). `NOTESOUP_HOME` overrides the root (default `~/.agents/notes`); a root thread's agent name is `NOTESOUP_AGENT` or `anonymous`.
41
- - **Native history** through `history_list` and `history_read`: the root thread's events and a child's own ancestry, addressed by stable session-wide seqs. The boot's window tree retains native window UUIDs for orientation. Optional `session` targets other local sessions/harnesses, and `history_list` accepts `session: "*"` with a query for cross-session search; see [cross-session history](history-sessions.md).
42
- - **Per-turn model identity.** `@model` follows the current turn's `x-codex-turn-metadata.model`, not the model recorded at thread start. The start model only labels the boot.
43
- - **Subagents and forks.** `SubagentStart` binds the child or fork to its own transcript while keeping the parent's root session. Its `@self` notebook is the slugged `agent_type` (for example `worker`), not the parent's.
34
+ - **A boot at native window start.** `SessionStart` reads the native rollout, binds the root thread and returns a notes snapshot as hook additional context. `SubagentStart` does the same for each separately spawned child. Dedupe requires a host-persisted `hooks.additional_context` record for the exact thread and native window, never a quoted marker.
35
+ - **Codex-native reset and budget tools.** `new_context` and `get_context_remaining` remain Codex's tools; notesoup does not implement a fallback.
36
+ - **Five notebooks** through `notes_write`, `notes_update`, `notes_read` and `notes_list` (add `query` to search). `NOTESOUP_HOME` overrides the notes root (default `~/.agents/notes`); a root thread's agent name is `NOTESOUP_AGENT` or `anonymous`. A child uses its slugged hook `agent_type` (for example `worker` or `default`).
37
+ - **Native history** through `history_list` (browse a timeline or list sessions), `history_search` (find passages by query), and `history_read` (open one event by seq). Optional `session` targets another local session; `history_list` and `history_search` also accept wildcards such as `"*"`; see [cross-session history](history-sessions.md). The boot's window tree retains native window UUIDs.
38
+ - **Per-turn model identity.** `@model` follows the current turn's `x-codex-turn-metadata.model`, not the model recorded at thread start.
44
39
 
45
- Codex may prefix MCP tool names with a server namespace. Use the names that appear in the session's tool list; the boot says the same.
40
+ Codex may namespace MCP tools or expose them through its tool orchestrator; use the names in the current tool list.
46
41
 
47
42
  ## Native-window and identity rules
48
43
 
49
- Hooks are the only source of identity. The MCP server never guesses a project from its own cwd, and it reads exactly one binding per thread from `PLUGIN_DATA`.
50
-
51
- A notes or history call refuses, without reading or writing anything, when:
44
+ Hook-captured facts bind the thread and its cwd, root session, transcript, notes root, native window UUID and number. The MCP server never guesses a project from the server's working directory. Native Codex hooks receive `PLUGIN_DATA`; the native stdio launcher does not, so the fixed `notesoup@notesoup` installation reads the same binding directory at `$CODEX_HOME/plugins/data/notesoup-notesoup` (default `~/.codex`).
52
45
 
53
- - the thread has no hook binding (`unknown_thread`);
54
- - the binding's root session disagrees with the call's `sessionId` (`stale_thread_binding`);
55
- - the call carries no `windowId` (`missing_window`) or a different one from the binding (`stale_thread_binding`);
56
- - the turn supplies no model (`missing_model`);
57
- - history finds the transcript's root session or current window no longer matches the binding (`stale_native_state`).
46
+ Codex 0.171.0 MCP `windowId` uses `<thread-id>:<window-number>`, while the rollout records a native window UUID. The adapter accepts the numbered ID only when it exactly matches the bound thread and the transcript-proven window number; the persisted UUID remains the history window identity. The older UUID form also works when it matches the same binding. All calls recheck native facts before accessing notes or history.
58
47
 
59
- Resume or compact once to let `SessionStart` rebind a stale thread. A root-session disagreement is never overwritten during a hook run; the message asks for a resume instead.
48
+ Calls refuse for a missing binding (`unknown_thread`), conflicting caller or transcript thread/root/window (`stale_thread_binding` / `stale_native_state`), missing native window (`missing_window`), or missing current turn model (`missing_model`). Resume or compact once to rebind root identity; a root-session disagreement is never overwritten by a hook.
60
49
 
61
- The boot marker records the native thread and window. The transcript decoder is strict about producer facts: unknown record/response types, malformed committed JSONL, non-increasing ordinals, copied `session_meta` ancestry and `thread_rolled_back` selection are refusals, not skipped data. An incomplete final line is ignored as an append tail rather than treated as history.
50
+ The transcript decoder is strict about structural facts: unknown record/response types, malformed committed JSONL, non-increasing ordinals, copied `session_meta` ancestry and unsupported `thread_rolled_back` selection are refusals. An incomplete final line is ignored as an append tail. Native `additional_tools` catalog records consume their ordinal but aren't conversation events.
62
51
 
63
- ## Child limitation
52
+ ## Child rollover limitation
64
53
 
65
- Codex 0.160.1 has no supported child post-compact boot or recovery hook. notesoup therefore answers a **child** `PreCompact` with `continue: false`, before native history is cut, and tells the child to save a handoff note and finish. A root `PreCompact` is transparent. Continue a child by starting a fresh child from its handoff note; do not expect notesoup to recover a child after a native rollover.
54
+ The root recovery path is `SessionStart` after compaction. Codex 0.171.0's child startup hook contract does not provide a supported context-injecting post-compact child recovery hook. Notesoup therefore answers a child `PreCompact` with `continue: false` before native history is cut, and tells the child to save a handoff note and start a fresh child; root `PreCompact` is transparent. Independent child first-turn boot and MCP calls are verified, but child rollover recovery is not implemented.
66
55
 
67
56
  ## Limits
68
57
 
69
58
  | Limit | What to expect |
70
59
  | --- | --- |
71
- | Codex versions | 0.160.1 only; other `cli_version` values are refused. |
60
+ | Codex wire format | Real 0.171.0 root and child rollouts, plus older producer-shaped fixtures; unknown shapes may refuse regardless of version. |
72
61
  | Node | >=22.15 for compressed rollouts. |
73
- | Boot size | Local cap 128 KiB. The hook sets `additionalContextLimit: 0` so the host does not spill or silently truncate the boot; an oversized boot becomes a warning and nothing is injected. Slim the notebook MAPs. |
74
- | Tool output | Shared 32 KiB result bound; use continuation fields or narrower filters. |
75
- | History sources | Local Pi/Claude/Codex transcripts through the shared corpus; current Codex and targeted Codex use the same strict rollout decoder. DSH discovery needs its query service and is unavailable inside Codex. No app-server/remote history or text from opaque/encrypted payloads. |
76
- | Reset/budget | Codex-native only. No MCP fallback, no notesoup budget warning or close-out turn. |
62
+ | Boot size | Local cap 128 KiB; hook `additionalContextLimit: 0` avoids host spilling. Oversized boot warns instead of injecting truncated notes. |
63
+ | Tool output | Shared result bounds; use continuation fields or narrower filters. |
64
+ | History sources | Local Pi/Claude/Codex transcripts through the shared corpus. No remote history or text recovered from opaque/encrypted payloads. |
65
+ | Reset/budget | Codex-native only. No notesoup budget warning or close-out turn. |
77
66
  | Child rollover | Unsupported; blocked at `PreCompact` as above. |
78
67
  | Dream | No Codex dream backend or dream skill registration. |
79
- | Notifications/commands | No custom UI notification, runtime toggle or `/fresh-window` command is installed. |
68
+ | Notifications/commands | No custom UI notification, runtime toggle or `/fresh-window` command. |
80
69
 
81
- ## Validation stage
70
+ ## Validation
82
71
 
83
- This is a fixture- and SDK-validated stage, **not a verified real host loop**. The tests use producer-shaped synthetic rollouts derived from the frozen official 0.160.1 source (`d27764b8`), drive the bundled stdio MCP server through the official SDK client, and run the hook code both in-process and as the real bundled executable. They pin root and child history, forks, boot deduping by host provenance, stale identity/window refusals, native-window addresses and child `PreCompact`.
72
+ The targeted tests drive copied bundled stdio helpers via the MCP SDK and exercise root, child, and fork bindings, history coordinates and strict lineage validation, caller window identity, native hook boot and dedupe, and the child PreCompact guard.
73
+
74
+ Redacted live evidence (Codex 0.171.0, 2026-11-26; fresh installation of the unmodified native bundle into an isolated Codex home):
75
+
76
+ | Probe | Native rollout ordinals and result |
77
+ | --- | --- |
78
+ | Root | 12: `hooks.additional_context` contains the pinned-note sentinel; 16: first assistant commentary reproduces it, before any tool execution; 22/23: `notes_list` and `history_list` complete successfully. The model identifies both native context tools. |
79
+ | Independent child | Spawned with `fork_turns="none"`, without the sentinel in its task. Its own ordinal 12 contains hook boot; 28/29: `history_list` and `notes_list` complete successfully; 38: final assistant message reproduces the sentinel. Parent confirms the child's initial report; no shell or notes-read operation was used. |
80
+ | History decoder | Both completed root and child rollouts decode with native window number 0 and one window. |
81
+ | Default installation | CLI install succeeded and the installed app-server listed SessionStart, SubagentStart and PreCompact as enabled, untrusted. Existing user permissions were not changed. |
84
82
 
85
- The stage has not been published, installed into a live Codex session, or exercised against a real model turn. A local build and the scripted tests only establish the adapter's behavior against those fixtures and the documented hook/MCP surfaces. Before relying on it in a real thread, install it as above and verify that the boot appears once per window and that a `notes_write` succeeds from a model turn.
83
+ The isolated probes allowed only the locally vetted plugin hooks and the two read-only list operations in their temporary configuration. No private notes were used; temporary raw diagnostics were removed after validation. No live compaction completion is claimed.
86
84
 
87
85
  ```sh
88
86
  npm run typecheck
89
87
  npm test
90
- node --test dist/test/codex-plugin.test.js
88
+ node --test dist/test/codex-history.test.js dist/test/codex-plugin.test.js
91
89
  ```
package/docs/dsh.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DeepSeek Harness adapter
2
2
 
3
- notesoup for **dsh 0.2.1-alpha.2** gives the agent a fresh page when context runs low: frozen boot text, the five notebooks, six notes/history tools, `get_context_remaining`, and `empty_brain`. A reset makes **zero model calls**. The old conversation leaves the model surface and remains in the session log for history reads. `notes_list` browses the notebooks or returns match lines and offsets when given `query`. Dream is not registered on dsh.
3
+ notesoup for **dsh 0.2.1-alpha.2** gives the agent a fresh page when context runs low: frozen boot text, the five notebooks, seven notes/history tools, `get_context_remaining`, and `empty_brain`. A reset makes **zero model calls**. The old conversation leaves the model surface and remains in the session log for history reads. `notes_list` browses the notebooks or returns match lines and offsets when given `query`. Dream is not registered on dsh.
4
4
 
5
5
  Install the package in your chosen dsh profile with `dsh plugin --profile <profile> add notesoup`, then copy the model declaration from [the profile patch example](dsh.profile.patch.yml) into `$DSH_HOME/profiles/<profile>/cordis.patch.yml`. The package bundle patch disables `compaction-basic` and inserts `notesoup-engine` and `notesoup`. Do not duplicate those rows when adding the model declaration. A source checkout needs `npm ci --ignore-scripts` and `npm run build`; use absolute `file:///.../dist/plugins/dsh/engine.js` and `file:///.../dist/plugins/dsh/index.js` module names. The example shows all rows for a profile assembled without the package bundle.
6
6
 
@@ -14,7 +14,7 @@ On load and before requests, preflight probes `systemPrompt.section`, `tools.reg
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
 
17
- `history_list` and `history_read` obtain the full raw log through `ctx.sessionQuery.readSession`, then feed the shared pairing, `after` / `before` paging and literal search with optional `context` around hits. Public history seq **1** is native dsh seq **0**; always use the seq a notesoup tool returns. A fork's selected seed prefix is available in its history; no sibling or parent suffix is fetched. Tool results are paired at their call seq. Text blocks are verbatim; other recorded blocks are shown as JSON. Omit `session` to browse the current session. Explicit `session: "dsh:<id-or-prefix>"` resolves through `ctx.sessionQuery.listSessions()` and reads with `readSession`; `session: "*"` with a query also searches the Pi/Claude/Codex local-file corpus. DSH service-backed discovery is available only inside DSH. All hits and continuation recipes retain their canonical session identity; see [cross-session history](history-sessions.md).
17
+ `history_list`, `history_search`, and `history_read` obtain the full raw log through `ctx.sessionQuery.readSession`, then feed the shared pairing, integer `after` / `before` timeline paging and wildcard session overview (`history_list`), and literal search with ISO `since` / `until` bounds and optional `context` (`history_search`). Public history seq **1** is native dsh seq **0**; always use the seq a notesoup tool returns. A fork's selected seed prefix is available in its history; no sibling or parent suffix is fetched. Tool results are paired at their call seq. Text blocks are verbatim; other recorded blocks are shown as JSON. Omit `session` for the current session. Explicit `session: "dsh:<id-or-prefix>"` resolves through `ctx.sessionQuery.listSessions()` and reads with `readSession`; `history_list` and `history_search` with `session: "*"` also overview or search the Pi/Claude/Codex local-file corpus. DSH service-backed discovery is available only inside DSH. Explicit-session results group rows under `=== session <harness>:<id> ===` and retain canonical session identity in continuation recipes; see [cross-session history](history-sessions.md).
18
18
 
19
19
  ## Reset and budget
20
20
 
@@ -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 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. |
50
+ | Boot bounds | Shared per-notebook pin cap, UTF-8 byte budgets, and bounded auto-generated per-shelf index from the shared policy/renderer (see [per-note policy](notes-library.md#per-note-policy)). Over-budget pinned bodies truncate in boot with `<notesoup:warning>` outside the note frame; 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. |
@@ -1,39 +1,41 @@
1
1
  # Cross-session history
2
2
 
3
- `history_list` and `history_read` accept one optional `session` selector. This is read-only inspection of local transcripts, not a session switch or a note-notebook selector. Seq numbers are local to a session; keep a returned `session` together with its `seq`.
3
+ History tools inspect local sessions without switching sessions or changing them.
4
4
 
5
- ## Current session or one target
6
-
7
- Omit `session` to keep the current host's behavior unchanged. Items/read results do not contain `session`, headers remain `seq <seq> | <role>`, and the printed paging, expand and neighborhood recipes do not contain a session selector.
8
-
9
- Pass an ID or unique prefix, optionally qualified by `pi:`, `claude:`, `codex:` or `dsh:`:
5
+ ## Browse one timeline or list sessions
10
6
 
11
7
  ```js
12
- history_list({ session: "claude:target-prefix", query: "deployment" })
13
- history_read({ session: "claude:full-session-id", seq: 42 })
8
+ history_list({ before: 190, limit: 20 })
9
+ history_list({ session: "claude:target-prefix", after: 0 })
10
+ history_list({ session: "*" }) // Recent sessions, one representative each
11
+ history_list({ session: "pi:*", since: "2026-10-01", limit: 20 })
14
12
  ```
15
13
 
16
- Within the requested harness an exact ID wins over prefixes. Without a harness, resolution checks the current harness first (exact ID, then prefixes); only if it has no matches are the other harnesses checked. No match returns `unknown_session`. Multiple matches return `ambiguous_session` with up to five qualified candidates; specify a harness or a longer ID rather than guessing.
14
+ Omit `session` for the current session. For a single session, use exclusive integer seqs for `after` / `before` (`after: 0` starts at the beginning) and optional ISO 8601 `since` / `until`. Without `after` (or `since` alone), the newest eligible events are returned, still in ascending seq order. Follow the older/newer recipes to page with the same options. Use `roles` to see specific roles, or omit it to fold tool/context runs. Follow the expand recipe to see those events.
15
+
16
+ With a wildcard `session` (`*`, `pi:*`, `claude:prefix*`), `history_list` returns one representative event per session, preferring the first visible user prompt, then the latest assistant event, then the latest visible event. With `roles`, it returns the latest matching event. Role and ISO 8601 `since` / `until` filters apply before choosing representatives (`after` / `before` seq bounds are refused on wildcards). Wildcard overviews consider most recently modified sessions first (least recently modified first with `since`).
17
+
18
+ ## Find passages
17
19
 
18
- Explicit targeting always returns the canonical `session: "<harness>:<full-id>"`, even when the target is the current session. Headers become `session <harness>:<id> | seq <seq> | <role>`. Copy that session into `history_read` and any continuation reads. Paging, `expand` and `neighborhood` recipes already carry it. Structured pages expose `has_older` and `has_newer`; use the first or last non-context row's seq as `before` or `after`, respectively. For example: `→ newer: {"session":"<harness>:<full-id>","after":42}`. An `after` bound pages forward; otherwise the page starts at the newest eligible end. See [tool results](tool-results.md#bounds-and-continuation) for query context and bounds.
20
+ ```js
21
+ history_search({ query: "deployment", context: 1 })
22
+ history_search({ session: "*", query: ["deployment", "rollback"], limit: 20 })
23
+ history_search({ session: "codex:*", query: "migration", roles: ["tool"], since: "2026-10-01", context: 1 })
24
+ ```
19
25
 
20
- ## Browse or search across sessions
26
+ - `query` is required, matching literal text case-insensitively; a list matches any of its non-empty terms, and an empty query returns no matches. All roles are searched by default, including tool arguments and output. `context: N` adds up to N neighboring visible events on either side of a hit, even outside the hit's filters. Neighbors are marked `search context`, and don't count toward `limit`.
27
+ - `since` and `until` are exclusive ISO 8601 times (local time without an offset). Untimed events are excluded by time bounds. `limit` counts from the newest end, or oldest end with `since`; default 20. Results are grouped by session, with seqs ascending inside each group. If more results are available, narrow by time, role, query or session pattern.
28
+ - Both `history_list` and `history_search` accept wildcard session patterns: `*` covers all available sessions, `pi:*` restricts to Pi, and `claude:prefix*` narrows the ID. All characters except `*` are literal.
21
29
 
22
- Any selector containing `*` selects multiple sessions; `*` matches any string and all other characters are literal. `*` covers all available harnesses, `pi:*` restricts to Pi, and `claude:prefix*` narrows by session ID.
30
+ ## Read one event
23
31
 
24
32
  ```js
25
- history_list({ session: "*" }) // Recent sessions, one opening prompt/topic each
26
- history_list({ session: "*", query: ["deployment", "rollback"], limit: 20 })
27
- history_list({ session: "codex:*", query: "migration", roles: ["tool"], after: "2026-10-01", context: 1 })
33
+ history_read({ session: "claude:full-session-id", seq: 42, offset_chars: 120 })
28
34
  ```
29
35
 
30
- - With a non-empty `query`, matching is literal, case-insensitive, and ORs a list of texts, as in one-session search. Local files are conservatively pre-filtered before full decoding: JSON escapes, Unicode case folding, generated event text and inherited Codex history must not lose hits. Uncertain cases use the full decoder. A possible hit in a Pi or Claude file stops the prefilter early: the strict decoder will read and validate the file next.
31
- - Without a non-empty `query`, return a recent-sessions overview. Consider sessions newest-modified first, or oldest-modified first with `after`; stop loading once `limit` sessions (default 20) produce a representative. Apply `roles`, `after` and `before` before choosing a representative. Without roles, prefer the first visible user event, falling back to the latest visible assistant event or the latest event of any role. With roles, choose the latest matching visible event. Return the representatives oldest first by event time.
32
- - Wildcard bounds take only ISO 8601 times, both exclusive. Seqs from different sessions cannot define a common range. Time bounds exclude events with no usable timestamp.
33
- - `history_read` refuses wildcard selectors with `invalid_session`; take a specific `session` and `seq` from the result instead.
34
- - A query searches all roles, including tool arguments/output and injected context; `roles` can narrow the hits. `context: N` includes up to N neighbors on each side from the hit’s own session, even outside the hit bounds. There are no folded rows.
35
- - Hits and context are merged oldest first by event time, with a deterministic session/seq tie-break; untimed events sort first. `limit` counts hits from the newest end by default or from the oldest end with `after`. The complete text and structured result still share the 32 KiB budget.
36
- - Each event carries its canonical `session`. `has_older` and `has_newer` indicate more matching results beyond the page; an overview with unvisited sessions may have more even if those sessions have no representative. Narrow by session pattern, query, roles or time rather than trying to page across per-session seqs.
36
+ An explicit session is shown as `=== session <harness>:<full-id> ===` above list/search rows. Copy that full ID and the event's seq into `history_read`. If a preview header shows ` | offset_chars N`, use `offset_chars: N` to open that passage; a shortened preview ends with ` [truncated]`. Follow the continuation for more text. Without a session heading, omit `session` to read the current session. Seqs are local to a session.
37
+
38
+ All three tools accept a full ID or unique prefix, optionally qualified by `pi:`, `claude:`, `codex:` or `dsh:`. Exact IDs take precedence over prefixes. An unqualified ID checks the current harness first. If no match or several matches are found, use a longer or harness-qualified ID. `history_read` rejects wildcards. The three tools return plain text bounded to 32 KiB including notices and footers.
37
39
 
38
40
  ## Local discovery and limits
39
41
 
@@ -41,37 +43,13 @@ history_list({ session: "codex:*", query: "migration", roles: ["tool"], after: "
41
43
  | --- | --- | --- |
42
44
  | Pi | `~/.pi/agent/sessions/<workspace>/<timestamp>_<id>.jsonl` | Current session uses the native active branch. Offline current-format files follow persisted parent links from the last tree entry, preserving append seqs and inactive-branch holes. |
43
45
  | Claude | `~/.claude/projects/<project>/<id>.jsonl` | The current session still requires its live, confirmed append head. Offline files account for logical compact links, prefer non-attachment graph leaves when available, and select the last remaining leaf in transcript order. Only that leaf's confirmed ancestors are exposed; a graph with no leaves still refuses. |
44
- | Codex | `~/.codex/sessions/YYYY/MM/DD/rollout-...-<threadId>.jsonl(.zst)` | The same strict 0.160.1 rollout/lineage decoder as current-session history; compressed files need Node >=22.15. Root `session_id` is not a child thread ID. |
46
+ | Codex | `~/.codex/sessions/YYYY/MM/DD/rollout-...-<threadId>.jsonl(.zst)` | The same structural rollout/lineage decoder as current-session history; compressed files need Node >=22.15. Root `session_id` is not a child thread ID. |
45
47
  | DSH | `ctx.sessionQuery.listSessions()` / `readSession(id)` | Available inside DSH only, over its live-preferred local session corpus. Other hosts cannot discover DSH files themselves. |
46
48
 
47
- Filesystem discovery does not follow directory symlinks or recurse into Claude subagent stores. Missing roots are empty. Repeated native files for one qualified ID produce one descriptor (newest modified); the current live binding wins over its on-disk descriptor. Discovery and decoding never mutate transcript bytes or modification times. Unsupported/corrupt or unreadable selected transcripts return `history_unavailable` naming the session for single-session list/read calls. Wildcard searches and overviews skip individual sessions that cannot load; an empty wildcard result is not proof that an event never happened. A readable Claude ancestry gap appears as an optional `notice` in cross-session page/read data and in rendered text; it stays outside event text and search/read offsets and counts against the output budget.
49
+ Filesystem discovery does not follow directory symlinks or recurse into Claude subagent stores. Missing roots are empty. Repeated native files for one qualified ID produce one descriptor (newest modified); the current live binding wins over its on-disk descriptor. Discovery and decoding never mutate transcript bytes or modification times. Unsupported/corrupt or unreadable selected transcripts return `history_unavailable` naming the session for single-session calls. Wildcard searches and overviews skip individual sessions that cannot load; an empty wildcard result is not proof that an event never happened. A gap in Claude history appears as a notice; it does not change event text or read offsets.
48
50
 
49
51
  The default roots respect `PI_CODING_AGENT_DIR` (Pi agent directory), `CLAUDE_CONFIG_DIR` (Claude config directory), and `CODEX_HOME` (Codex home). For direct root overrides use absolute paths in `NOTESOUP_HISTORY_PI_ROOT`, `NOTESOUP_HISTORY_CLAUDE_ROOT`, and `NOTESOUP_HISTORY_CODEX_ROOT`; these name the **sessions**, **projects**, and **sessions** directories respectively, not notes storage. `NOTESOUP_HOME` only changes notes.
50
52
 
51
- ## Strict recent-session cache
52
-
53
- Only an unfiltered wildcard overview uses the persistent offline representative cache: no nonempty query and no `roles`, `after`, or `before`. Empty queries still mean an overview. Explicit session reads/lists, searches, filtered overviews, DSH service descriptors and the current live binding do not use this cache. Session discovery, modified-time ordering, representative ordering, output budgeting and full event-preview limits are unchanged.
54
-
55
- A cold miss deliberately reads and strictly decodes the whole transcript, including selected Codex ancestry. It saves only the complete selected event, canonical session identity, notice and source metadata—not a projection, header-only approximation or full-text index. Entries are versioned with the decoder/selection contract; decoder or presentation changes must bump that version. The key includes the canonical root transcript path, harness and session ID. Every source has a `dev`/`ino`/size/nanosecond mtime/ctime fingerprint taken before reading and checked after decoding. Codex records the actual root and ancestor files, and cache hits re-run native lineage discovery so newly ambiguous or missing sources cannot be hidden by unchanged file fingerprints. The fingerprint list must exactly match the root and lineage witness list.
56
-
57
- Cache storage is `~/Library/Caches/notesoup/history` on macOS, or `$XDG_CACHE_HOME/notesoup/history` (`~/.cache/notesoup/history` by default) elsewhere. Entries use atomic temporary-file rename and are individually capped at 8 MiB, both on admission and before/after reading. Oversized representatives still use normal strict decoding and normal output budgets; they are not truncated for cache admission. Missing, corrupt or unwritable caches are transparent misses. Raced decodes are returned without persistence. Transcript failures are never cached: wildcard calls still skip those sessions, while explicit calls still refuse. There is no public cache option, background warmup, or whole-corpus index; the internal test-root seam keeps tests out of the user's cache.
58
-
59
- ### Cold and warm evidence
60
-
61
- A November 1, 2026 local read-only measurement used a private empty cache and a fresh Node process for each pass. It ran the default 20-topic overview over offline descriptors last modified at least ten minutes earlier, excluding active work; both passes returned exactly the same serialized result. This is one local sample, not a cold-search or whole-corpus speed claim.
62
-
63
- | Measurement | Cold cache | Warm cache |
64
- | --- | ---: | ---: |
65
- | Elapsed | 462.58 ms | 89.63 ms |
66
- | Transcript body reads | 32 | 12 |
67
- | Transcript bytes | 159,240,525 | 70,962,466 |
68
- | JSON parses (including cache entries) | 10,636 | 32 |
69
- | Peak process RSS | 305,200 KiB | 134,208 KiB |
70
-
71
- All 20 unchanged supported sessions hit their summaries without body reads on the warm pass. The remaining 12 body reads in **both** passes were unavailable/unsupported sessions intentionally rechecked rather than negatively cached. Twenty entries occupied 184,431 bytes (largest 142,796 bytes). Focused hermetic tests independently prove zero second-call transcript reads for supported Pi and compressed Codex/ancestor fixtures, complete-event preview parity, invalidation, cache-growth fallback and live-binding precedence. Warm calls still pay discovery/stat/cache-validation costs; Codex lineage can require directory discovery. Cold decoding can still use substantial per-transcript memory, and rejected transcripts are retried on each browse.
72
-
73
- Embedders/tests can use `localHistoryCorpus({ current, roots, home, env, dshSessions })` from the source module `src/history/local.ts`. Each `roots` member overrides that harness's discovery directory; `null` disables it. A supplied `home` with `env: {}` makes the defaults hermetic. These source-module helpers are not new package exports.
74
-
75
- The shared operations still accept a bare `HistoryProjection` for current-session calls. Host adapters instead supply a `HistoryContext` with a lazy `current()` projection and a `HistoryCorpus`. Filesystem wire decoders live under `src/history/`, import no host SDK/plugin, and are shared by native adapter entries and corpus reads. DSH contributes descriptors through its public query service. Foreign reads do not require loading the current projection; Codex still validates the caller's hook binding and native identity/window before serving them.
53
+ ## Recent-session overview speed
76
54
 
77
- In single-session browse pages, `items` contains events only. A folded tool/context run appears in `folded_before` on the following event, or in `folded_after` at the end of the page. Folded runs do not count toward the event limit.
55
+ Repeated wildcard overviews can reuse saved session summaries for unchanged offline transcripts. Changes to a transcript or its source history invalidate the saved summary; live sessions are read directly. This does not change results, previews or notices. A missing or unusable cache falls back to reading transcripts. Searches may still take time when many sessions match.
@@ -55,16 +55,16 @@ A new notebook is staged under the notes home and renamed into `project/` with i
55
55
 
56
56
  ## Per-note policy
57
57
 
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.
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 saves over 160 Unicode code points with a warning (the boot index truncates it to 160). 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.
59
59
 
60
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:
61
61
 
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.
62
+ - Ordinary pages have a default budget of **8192 UTF-8 bytes**; root `CHEATSHEET.md` defaults to **4096 UTF-8 bytes**, overridable in frontmatter (or store options) to any positive safe integer. `warnings` on write/update/rename results report body overflow without rejecting or truncating the saved file. The separate serialized-file byte limit still applies.
63
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.
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.
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. Over-budget pinned bodies are truncated in boot to `budget` UTF-8 bytes on a code-point boundary with `[truncated at X/Y; offset_chars=X]` and an out-of-body `<notesoup:warning>`.
65
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.
66
66
 
67
- The four model tools accept the same policy options (write/update) and return effective policy visibly in receipts, read metadata and `notes_list` rows, alongside budget warnings. Notebook pin admission is serialized across stores **within this process**; manual edits and other processes are not locked by this cooperative API.
67
+ The model write/update tools expose `pinned`, `readonly`, and `description` (`budget` is not model-adjustable through tools; frontmatter overrides remain supported). Receipts and `notes_list` rows show only policy that differs from the note's path defaults; read metadata keeps the full effective policy. Warnings render inside `<notesoup:warning>...</notesoup:warning>`. Notebook pin admission is serialized across stores **within this process**; manual edits and other processes are not locked by this cooperative API.
68
68
 
69
69
  ## Library and plugin boundary
70
70
 
package/docs/skills.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Skills and dream
2
2
 
3
- ## Memory skill
3
+ ## Notesoup skill
4
4
 
5
- The package provides `/skill:memory`, a short self-contained guide to the notes and history tools: note addresses and notebooks, finding and paging notes, searching and paging history, saving recovery state, and what to do when a memory tool is unavailable. It is a fallback for sessions where the boot protocol is missing or unclear and a reference on demand; normal tool calls do not require reading it. It is written independently of the boot text rather than generated from it. The Claude Code Mod ships the same guide; current-session history requires the documented main-session transcript path and a confirmed append head, while explicit `session` selectors use the local cross-harness corpus (offline Claude prefers non-attachment leaves, then the last leaf in transcript order).
5
+ The package provides `/skill:notesoup`, a short self-contained guide to the notes and history tools: note addresses and notebooks, finding and paging notes, searching and paging history, saving recovery state, and what to do when a memory tool is unavailable. It is a fallback for sessions where the boot protocol is missing or unclear and a reference on demand; normal tool calls do not require reading it. It is written independently of the boot text rather than generated from it. The Claude Code Mod ships the same guide; current-session history requires the documented main-session transcript path and a confirmed append head, while explicit `session` selectors use the local cross-harness corpus (offline Claude prefers non-attachment leaves, then the last leaf in transcript order).
6
6
 
7
7
  ## Dream
8
8
 
@@ -10,7 +10,7 @@ The package provides `/skill:memory`, a short self-contained guide to the notes
10
10
 
11
11
  In Pi the session gets three hidden `dream_*` tools; they are not declared to the model and are found with `tool_search` or codemode's `searchTools("dream")`:
12
12
 
13
- - `dream_begin(project?)` opens one project, by default the current one, as in `@projects/<name>/`. It lists that project's notes and every session note whose frontmatter `project` names it, crumpled notes included. While it is open, `notes_write` and `notes_update` may edit those addresses (existing notes only in other sessions), and reads leave no access stamp. Other projects stay read-only.
13
+ - `dream_begin(cwd?)` opens one project, by default the current one, as in `@projects/<name>/`. Pass `cwd` to select a directory's project (relative paths resolve against the host cwd). It lists that project's notes and every session note whose frontmatter `project` names it, crumpled notes included. While it is open, `notes_write` and `notes_update` may edit those addresses (existing notes only in other sessions), and reads leave no access stamp. Other projects stay read-only.
14
14
  - `dream_forget(address)` permanently deletes one crumpled note within reach; live notes refuse.
15
15
  - `dream_end()` closes the dream.
16
16