notesoup 0.52.6 → 0.53.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 (84) hide show
  1. package/README.md +3 -1
  2. package/dist/plugins/claude/src/helper.js +34 -7
  3. package/dist/plugins/claude/src/history.d.ts +7 -2
  4. package/dist/plugins/claude/src/history.js +53 -22
  5. package/dist/plugins/claude/src/text.d.ts +5 -0
  6. package/dist/plugins/claude/src/text.js +12 -0
  7. package/dist/plugins/codex/src/cli.d.ts +2 -0
  8. package/dist/plugins/codex/src/cli.js +25 -0
  9. package/dist/plugins/codex/src/history.d.ts +8 -0
  10. package/dist/plugins/codex/src/history.js +238 -0
  11. package/dist/plugins/codex/src/hooks.d.ts +9 -0
  12. package/dist/plugins/codex/src/hooks.js +196 -0
  13. package/dist/plugins/codex/src/identity.d.ts +35 -0
  14. package/dist/plugins/codex/src/identity.js +134 -0
  15. package/dist/plugins/codex/src/mcp.d.ts +7 -0
  16. package/dist/plugins/codex/src/mcp.js +159 -0
  17. package/dist/plugins/codex/src/state.d.ts +23 -0
  18. package/dist/plugins/codex/src/state.js +92 -0
  19. package/dist/plugins/codex/src/text.d.ts +14 -0
  20. package/dist/plugins/codex/src/text.js +25 -0
  21. package/dist/plugins/codex/src/transcript.d.ts +39 -0
  22. package/dist/plugins/codex/src/transcript.js +313 -0
  23. package/dist/src/boot/render.js +11 -10
  24. package/dist/src/boot/text.d.ts +4 -5
  25. package/dist/src/boot/text.js +14 -28
  26. package/dist/src/budget/text.d.ts +1 -1
  27. package/dist/src/budget/text.js +1 -1
  28. package/dist/src/history/history.js +12 -11
  29. package/dist/src/tools/history.d.ts +5 -3
  30. package/dist/src/tools/history.js +9 -11
  31. package/dist/test/claude-history.test.js +135 -3
  32. package/dist/test/codex-history.test.d.ts +1 -0
  33. package/dist/test/codex-history.test.js +330 -0
  34. package/dist/test/codex-plugin.test.d.ts +1 -0
  35. package/dist/test/codex-plugin.test.js +365 -0
  36. package/dist/test/dependencies.test.js +8 -2
  37. package/dist/test/dsh.test.js +1 -1
  38. package/dist/test/helpers/dependency-graph.js +1 -1
  39. package/dist/test/history.integration.test.js +26 -1
  40. package/dist/test/model-facing-text.test.js +41 -26
  41. package/dist/test/notes.integration.test.js +3 -0
  42. package/docs/claude-code-mod.md +6 -2
  43. package/docs/codex.md +91 -0
  44. package/docs/dsh.md +1 -1
  45. package/docs/reset-lifecycle.md +1 -1
  46. package/docs/tool-results.md +2 -2
  47. package/package.json +6 -3
  48. package/playbook.md +1 -1
  49. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  50. package/plugins/claude/dist/claude/helper.js +120 -74
  51. package/plugins/claude/playbook.md +1 -1
  52. package/plugins/claude/skills/dream/SKILL.md +1 -1
  53. package/plugins/claude/skills/memory/SKILL.md +1 -1
  54. package/plugins/claude/src/helper.ts +34 -9
  55. package/plugins/claude/src/history.ts +54 -22
  56. package/plugins/claude/src/text.ts +13 -0
  57. package/plugins/codex/README.md +43 -0
  58. package/plugins/codex/dist/codex/notesoup.js +27800 -0
  59. package/plugins/codex/hooks/hooks.json +41 -0
  60. package/plugins/codex/mcp.json +10 -0
  61. package/plugins/codex/plugin.json +6 -0
  62. package/plugins/codex/src/cli.ts +26 -0
  63. package/plugins/codex/src/history.ts +193 -0
  64. package/plugins/codex/src/hooks.ts +190 -0
  65. package/plugins/codex/src/identity.ts +147 -0
  66. package/plugins/codex/src/mcp.ts +171 -0
  67. package/plugins/codex/src/state.ts +102 -0
  68. package/plugins/codex/src/text.ts +31 -0
  69. package/plugins/codex/src/transcript.ts +275 -0
  70. package/plugins/paseo/OVERVIEW.md +6 -2
  71. package/plugins/paseo/client/brain-empty-card.tsx +3 -1
  72. package/plugins/paseo/client/brain-empty-transformer.ts +7 -14
  73. package/plugins/paseo/client/notes-op-transformer.ts +10 -18
  74. package/plugins/paseo/client/tool-result.ts +31 -0
  75. package/plugins/paseo/test/brain-empty.test.ts +24 -1
  76. package/plugins/paseo/test/fixtures/claude-tool-calls.ts +86 -0
  77. package/plugins/paseo/test/notes-op.test.ts +39 -1
  78. package/skills/dream/SKILL.md +1 -1
  79. package/skills/memory/SKILL.md +1 -1
  80. package/src/boot/render.ts +11 -9
  81. package/src/boot/text.ts +16 -30
  82. package/src/budget/text.ts +1 -1
  83. package/src/history/history.ts +12 -10
  84. package/src/tools/history.ts +14 -13
package/docs/codex.md ADDED
@@ -0,0 +1,91 @@
1
+ # Codex plugin (native mode)
2
+
3
+ `plugins/codex/` makes notesoup a native Codex plugin: the five notes homes and the three 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.
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.
6
+
7
+ ## Install (from this checkout)
8
+
9
+ Build the bundled helper first; `plugins/codex/dist/codex/notesoup.js` is generated and is not committed.
10
+
11
+ ```sh
12
+ npm ci
13
+ npm run build
14
+ codex plugin marketplace add /absolute/path/to/notesoup
15
+ codex plugin add notesoup@notesoup
16
+ ```
17
+
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.
19
+
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):
21
+
22
+ ```toml
23
+ [features]
24
+ context_management = false
25
+ retain_client_developer_messages = false
26
+
27
+ [features.token_budget]
28
+ enabled = true
29
+ use_history_notes_extension = false
30
+ ```
31
+
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.
35
+
36
+ ## What the agent gets
37
+
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 notes homes** through `notes_write`, `notes_update`, `notes_read`, `notes_list` and `notes_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_windows`, `history_list` and `history_read`: the root thread's windows and a child's own ancestry. Window ids are `codex:<thread>:<native-window-uuid>`, and the boot's window tree uses those same UUIDs, so the shared `trunk:shortname` rule names the address history actually serves.
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` home is the slugged `agent_type` (for example `worker`), not the parent's.
44
+
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.
46
+
47
+ ## Native-window and identity rules
48
+
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:
52
+
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`).
58
+
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.
60
+
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.
62
+
63
+ ## Child limitation
64
+
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.
66
+
67
+ ## Limits
68
+
69
+ | Limit | What to expect |
70
+ | --- | --- |
71
+ | Codex versions | 0.160.1 only; other `cli_version` values are refused. |
72
+ | 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 home MAPs. |
74
+ | Tool output | Shared 32 KiB result bound; use continuation fields or narrower filters. |
75
+ | History sources | Local rollout files only. No app-server history API, no remote history, no text from opaque/encrypted payloads. |
76
+ | Reset/budget | Codex-native only. No MCP fallback, no notesoup budget warning or close-out turn. |
77
+ | Child rollover | Unsupported; blocked at `PreCompact` as above. |
78
+ | Dream | No Codex dream backend or dream skill registration. |
79
+ | Notifications/commands | No custom UI notification, runtime toggle or `/fresh-window` command is installed. |
80
+
81
+ ## Validation stage
82
+
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`.
84
+
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.
86
+
87
+ ```sh
88
+ npm run typecheck
89
+ npm test
90
+ node --test dist/test/codex-plugin.test.js
91
+ ```
package/docs/dsh.md CHANGED
@@ -10,7 +10,7 @@ On load and before requests, preflight probes `systemPrompt.section`, `tools.reg
10
10
 
11
11
  ## Notes, boot and history
12
12
 
13
- `notesHome` defaults to `~/.agents/notes`; `agentName` defaults to `dsh`. The filesystem layout and addressing match Pi and Claude: bare paths are session notes, with `@project`, `@human`, `@self`, and `@model` durable homes. Project identity uses the shared `resolveProjectHome(cwd, notesHome)` resolver: readable slug homes with a `.project` marker, including repository/worktree and origin identity. Other marked projects are readable through `@projects/<name>/`; named-home reads do not update access metadata and named-home writes are refused. Receipts, boot protocol (including MAP Cheatsheets), and bounds come from the shared modules, not dsh copies. A model change changes subsequent tools' `@model` identity; the boot remains frozen until reset.
13
+ `notesHome` defaults to `~/.agents/notes`; `agentName` defaults to `dsh`. The filesystem layout and addressing match Pi and Claude: bare paths are session notes, with `@project`, `@human`, `@self`, and `@model` durable homes. Project identity uses the shared `resolveProjectHome(cwd, notesHome)` resolver: readable slug homes with a `.project` marker, including repository/worktree and origin identity. Other marked projects are readable through `@projects/<name>/`; named-home reads do not update access metadata and named-home writes are refused. Receipts, boot protocol (including separate CHEATSHEET.md and MAP.md pages), and bounds come from the shared modules, not dsh copies. A model change changes subsequent tools' `@model` identity; the boot remains frozen until reset.
14
14
 
15
15
  The boot is a `systemPrompt.section` at order **2450**, with `interpolate: false`. Shared snapshot/render functions read the five homes 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
 
@@ -61,7 +61,7 @@ After a manual safety reset, `context_with_system` checks the committed boundary
61
61
 
62
62
  Budget reminders are staged once per window at reserve plus reminder margin, then reserve plus warning runway. Hard reserve remains independent. Budget and command warnings use different types. The final budget warning notifies at first provider injection, not durability; early guidance stays UI-silent. Budget drafts are instance-local and discarded on abort, failed turn, transition or window mismatch. Active-window usage and the exact public `SettingsManager` authority determine thresholds.
63
63
 
64
- Pi and Claude use the same budget warning: budget timing, the handoff checklist, note maintenance (including updating and trimming MAP files), a warning against large tool outputs, then `empty_brain` and the countdown. Pi's manual warnings replace the budget opening with the `/empty` notice inside `<notesoup:budget_notice>`. Optional command text sits after the closing tag in `<notesoup:next_window_prompt>`. The first-tier reminder reports the remaining room, explains that notes survive the wipe, asks for updated notes and offers an optional `empty_brain`, warning that it also clears what the model says to the human right before emptying. Pi's boot retains its existing pre-reset hints; warnings no longer repeat those or the tool's `last_word` description.
64
+ Pi and Claude use the same budget warning: budget timing, the handoff checklist, note maintenance (including updating and trimming CHEATSHEET.md and MAP.md), a warning against large tool outputs, then `empty_brain` and the countdown. Pi's manual warnings replace the budget opening with the `/empty` notice inside `<notesoup:budget_notice>`. Optional command text sits after the closing tag in `<notesoup:next_window_prompt>`. The first-tier reminder reports the remaining room, explains that notes survive the wipe, asks for updated notes and offers an optional `empty_brain`, warning that it also clears what the model says to the human right before emptying. Pi's boot retains its existing pre-reset hints; warnings no longer repeat those or the tool's `last_word` description.
65
65
 
66
66
  `context_with_system` selects the boot by durable window identity, using Pi's canonical checkpoint projection or legacy slicing. Missing boot aborts safely instead of exposing raw history. Usage estimates use the same projection decision. `/tree` summaries are suppressed when crossing reset branches because native branch summarization bypasses this projection.
67
67
 
@@ -59,7 +59,7 @@ Pi's nested records contain child ID, name, optional arguments, status, timing a
59
59
 
60
60
  ## Bounds and continuation
61
61
 
62
- One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one.
62
+ One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one. History operations accept an optional pure text wrapper from the host: selection and read-window checks measure that wrapper around the shared rendering, and the caller must apply the same wrapper at delivery. Host prose stays in its plugin; no final clipping or separate query is involved.
63
63
 
64
64
  History pages carry `page_older` and `page_newer`, the exact params to merge into the next call; `from` picks which end of a bounded range `limit` counts from, `since`/`until` narrow that range by event `created_at`, and only a call without roles or a non-empty query folds tool/context runs. Omitted queries, empty strings and empty lists all disable search filtering; empty entries in a query list are ignored. Without a query, notes search returns scoped notes with empty `matches`, not every body line. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. `history_windows` is a snapshot too: its `more` counts the windows the budget left out and there is no window cursor, because `history_list` rows also expose `window_id`. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
65
65
 
@@ -73,6 +73,6 @@ A note read reports unrecognized frontmatter under `metadata.extra`; a value too
73
73
  - The history adapter owns native decoding, seq allocation and branch visibility.
74
74
  - Shared operations own the typed result, filtering, paging, character windows and refusal messages.
75
75
  - Shared renderers derive text from that result.
76
- - Pi/Claude adapters supply host identity, projections and transport packaging only.
76
+ - Pi/Claude adapters supply host identity, projections, optional pure text decoration and transport packaging only.
77
77
 
78
78
  There is no second query implementation for codemode, no copy of session storage and no migration of user records.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.52.6",
3
+ "version": "0.53.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -23,13 +23,15 @@
23
23
  "import": "./dist/plugins/dsh/engine.js"
24
24
  }
25
25
  },
26
- "description": "Host-neutral notes, history and context-window core, with plugins for Pi, Claude Code and the DeepSeek Harness.",
26
+ "description": "Host-neutral notes, history and context-window core, with plugins for Pi, Claude Code, the DeepSeek Harness and Codex.",
27
27
  "license": "MIT",
28
28
  "keywords": [
29
29
  "pi-package",
30
30
  "pi-extension",
31
31
  "agent-memory",
32
- "notes"
32
+ "notes",
33
+ "codex",
34
+ "claude-code"
33
35
  ],
34
36
  "repository": {
35
37
  "type": "git",
@@ -137,6 +139,7 @@
137
139
  "@earendil-works/pi-ai": "^1.0.0",
138
140
  "@earendil-works/pi-coding-agent": "^1.0.0",
139
141
  "@earendil-works/pi-tui": "1.0.0",
142
+ "@modelcontextprotocol/sdk": "^1.32.1",
140
143
  "@types/node": "^22.19.19",
141
144
  "esbuild": "^0.28.2",
142
145
  "typebox": "1.3.27",
package/playbook.md CHANGED
@@ -27,7 +27,7 @@ Durable notes hold decisions, constraints, and lessons that stay true after the
27
27
  5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper home, move it there, preserving its metadata, and update both homes' maps. Do it, don't propose it. Propose only when the destination home itself is unclear.
28
28
  6. **Preserve meaning and provenance.** Keep facts, conditions, exceptions, uncertainty, authorship, and sources. When promoting a finding, cite its source. Do not relabel agent-authored material as human-authored. If its destination or authority is unclear, propose the promotion instead.
29
29
  7. **Keep notes manageable.** Aim below about 200 lines / 8KB per note. Split oversized notes by topic with one-line cross-links.
30
- 8. **Keep maps useful.** Each writable home's MAP.md may include a Cheatsheet of rules that apply in every window; keep it short, about 5 lines. The rest stays the note index: durable notes' addresses and short gists, for lookup. Preserve standing rules, add promoted notes, and drop entries that no longer hold. Maps follow the same size budget.
30
+ 8. **Keep wake-up pages useful.** Each writable home's `CHEATSHEET.md` holds standing reminders, kept to five lines. Its `MAP.md` holds only the note index: durable notes' addresses and short gists. Both load every window when present; do not create empty pages. Preserve standing rules, add promoted notes to the map, and drop entries that no longer hold. Maps follow the same size budget.
31
31
 
32
32
  ## Deleting
33
33
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.52.6",
3
+ "version": "0.53.0",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"
@@ -8900,28 +8900,28 @@ function toolEvent(item, result) {
8900
8900
  };
8901
8901
  }
8902
8902
  function projectHistory(rawWindows, highestSeq, branchSeqs) {
8903
- const raw = rawWindows.flatMap((current) => current.items);
8903
+ const raw = rawWindows.flatMap((current) => current.items).sort((a, b) => a.seq - b.seq);
8904
8904
  const resultsById = /* @__PURE__ */ new Map();
8905
8905
  for (const item of raw) {
8906
8906
  if (item.role === "tool" && item.toolCallId && !resultsById.has(item.toolCallId)) resultsById.set(item.toolCallId, item);
8907
8907
  }
8908
8908
  const pairedResults = /* @__PURE__ */ new Map();
8909
- const consumed = /* @__PURE__ */ new Set();
8909
+ for (const item of raw) {
8910
+ const result = item.role === "tool_call" && item.toolCallId ? resultsById.get(item.toolCallId) : void 0;
8911
+ if (result && result.seq > item.seq && !pairedResults.has(result.seq)) {
8912
+ pairedResults.set(result.seq, item.seq);
8913
+ }
8914
+ }
8910
8915
  const windows = rawWindows.map((current) => ({
8911
8916
  windowId: current.windowId,
8912
8917
  ...current.createdAt ? { createdAt: current.createdAt } : {},
8913
8918
  items: current.items.flatMap((item) => {
8914
- if (consumed.has(item.seq)) return [];
8915
- if (item.role === "tool_call") {
8919
+ if (pairedResults.has(item.seq)) return [];
8920
+ if (item.role === "tool_call" || item.role === "tool") {
8916
8921
  const result = item.toolCallId ? resultsById.get(item.toolCallId) : void 0;
8917
- const paired = result && result.seq > item.seq && !consumed.has(result.seq) ? result : void 0;
8918
- if (paired) {
8919
- consumed.add(paired.seq);
8920
- pairedResults.set(paired.seq, item.seq);
8921
- }
8922
+ const paired = result && pairedResults.get(result.seq) === item.seq ? result : void 0;
8922
8923
  return [toolEvent(item, paired)];
8923
8924
  }
8924
- if (item.role === "tool") return [toolEvent(item)];
8925
8925
  return [{ seq: item.seq, windowId: item.windowId, role: item.role === "system" || item.role === "developer" ? "context" : item.role, text: item.text, createdAt: item.createdAt }];
8926
8926
  })
8927
8927
  }));
@@ -9541,9 +9541,7 @@ function renderRead(data) {
9541
9541
  const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...afterSeq >= 1 ? { after_seq: afterSeq } : {}, before_seq: data.seq + 10 })})`;
9542
9542
  return [header(data), ...tool ? [tool] : [], neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
9543
9543
  }
9544
- function pageFits(page) {
9545
- return fitsResult(success(page), (result) => renderOutcome(result, renderPage));
9546
- }
9544
+ var plainText = (text) => text;
9547
9545
  var MAX_REPORTED_WINDOWS = 5;
9548
9546
  function knownWindowSuffix(known) {
9549
9547
  return known.length === 0 ? "" : `; its windows: ${known.slice(0, MAX_REPORTED_WINDOWS).join(", ")}`;
@@ -9568,9 +9566,9 @@ var historyWindows = {
9568
9566
  description: "List this session's context windows, oldest first, with seq ranges.",
9569
9567
  parameters: historyWindowsParameters,
9570
9568
  outputSchema: resultSchema(HistoryWindowsDataSchema),
9571
- async execute(_params, projection, sessionId) {
9569
+ async execute(_params, projection, sessionId, wrapText = plainText) {
9572
9570
  const data = { session_id: sessionId, windows: [], more: projection.windows.length };
9573
- const fits = (candidate) => fitsResult(success(candidate), (result) => renderOutcome(result, renderWindows));
9571
+ const fits = (candidate) => fitsResult(success(candidate), (result) => wrapText(renderOutcome(result, renderWindows)));
9574
9572
  for (const window of projection.windows) {
9575
9573
  let first = null;
9576
9574
  let last = null;
@@ -9610,13 +9608,14 @@ var historyList = {
9610
9608
  description: "Browse or search this session's events, a page at a time. Read one in full with `history_read`.",
9611
9609
  parameters: historyListParameters,
9612
9610
  outputSchema: resultSchema(HistoryPageSchema),
9613
- async execute(params, projection) {
9611
+ async execute(params, projection, wrapText = plainText) {
9614
9612
  const resolved = resolveWindowId(projection, params.window_id);
9615
9613
  if (!resolved.ok) return resolved.outcome;
9616
9614
  const scoped = { ...params, window_id: resolved.window_id };
9617
9615
  const badWindow = badWindowId(projection, scoped);
9618
9616
  if (badWindow) return badWindow;
9619
- return selectPage(projection, scoped, pageFits, scoped.max_chars_per_item ?? HISTORY_PREVIEW_CHARS);
9617
+ const fits = (page) => fitsResult(success(page), (result) => wrapText(renderOutcome(result, renderPage)));
9618
+ return selectPage(projection, scoped, fits, scoped.max_chars_per_item ?? HISTORY_PREVIEW_CHARS);
9620
9619
  },
9621
9620
  render: (result) => renderOutcome(result, renderPage)
9622
9621
  };
@@ -9627,7 +9626,7 @@ var historyRead = {
9627
9626
  description: "Read one event in full: tool arguments, output, and nested calls.",
9628
9627
  parameters: historyReadParameters,
9629
9628
  outputSchema: resultSchema(HistoryReadDataSchema),
9630
- async execute(params, projection) {
9629
+ async execute(params, projection, wrapText = plainText) {
9631
9630
  const item = allItems(projection).find((event) => event.seq === params.seq);
9632
9631
  if (item === void 0 && params.seq > projection.highestSeq) {
9633
9632
  return failure("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
@@ -9660,7 +9659,7 @@ var historyRead = {
9660
9659
  ...nestedCallSummary(item),
9661
9660
  ...window
9662
9661
  }),
9663
- (result) => renderOutcome(result, renderRead)
9662
+ (result) => wrapText(renderOutcome(result, renderRead))
9664
9663
  );
9665
9664
  },
9666
9665
  render: (result) => renderOutcome(result, renderRead)
@@ -9783,26 +9782,32 @@ function claudeHistoryFromJsonl(text, source) {
9783
9782
  nextSeq += items.length;
9784
9783
  nodes.set(uuid, { first: version, latest: version, items });
9785
9784
  }
9786
- function ordinalOf(version) {
9785
+ const missingAncestors = /* @__PURE__ */ new Set();
9786
+ function positionOf(version) {
9787
9787
  const chain = [], calculating = /* @__PURE__ */ new Set();
9788
9788
  let cursor = version;
9789
- while (cursor.ordinal === void 0) {
9789
+ let before = { ordinal: 0 };
9790
+ while (cursor.position === void 0) {
9790
9791
  cursor.ancestor ??= cursor.ancestorUuid === void 0 ? void 0 : nodes.get(cursor.ancestorUuid)?.first;
9791
9792
  if (calculating.has(cursor)) throw new Error("cyclic Claude transcript ancestry");
9792
- if (cursor.ancestorUuid !== void 0 && cursor.ancestor === void 0) throw new Error(`missing Claude transcript ancestor: ${cursor.ancestorUuid}`);
9793
9793
  calculating.add(cursor);
9794
9794
  chain.push(cursor);
9795
+ if (cursor.ancestorUuid !== void 0 && cursor.ancestor === void 0) {
9796
+ missingAncestors.add(cursor.ancestorUuid);
9797
+ before = { unknownAncestor: cursor.ancestorUuid };
9798
+ break;
9799
+ }
9795
9800
  if (cursor.ancestor === void 0) break;
9796
9801
  cursor = cursor.ancestor;
9797
9802
  }
9798
- let before = cursor.ordinal ?? 0;
9799
- for (const current of chain.reverse()) {
9800
- const retained = current.row.isCompactSummary === true || current.ancestor !== void 0 && boundary(current.ancestor.row);
9801
- const marked = bootOrdinal(current.row, retained);
9802
- current.ordinal = marked === void 0 ? before + (boundary(current.row) ? 1 : 0) : Math.max(before, marked);
9803
- before = current.ordinal;
9803
+ before = cursor.position ?? before;
9804
+ for (const current2 of chain.reverse()) {
9805
+ const retained = current2.row.isCompactSummary === true || current2.ancestor !== void 0 && boundary(current2.ancestor.row);
9806
+ const marked = bootOrdinal(current2.row, retained);
9807
+ current2.position = marked !== void 0 ? { ordinal: "ordinal" in before ? Math.max(before.ordinal, marked) : marked } : "ordinal" in before ? { ordinal: before.ordinal + (boundary(current2.row) ? 1 : 0) } : before;
9808
+ before = current2.position;
9804
9809
  }
9805
- return version.ordinal;
9810
+ return version.position;
9806
9811
  }
9807
9812
  if (!source.headUuid) throw new Error("Claude history has no confirmed active head yet; wait for a main-session append after startup/resume");
9808
9813
  if (!nodes.has(source.headUuid)) throw new Error("Claude history active head is not persisted yet; retry after the transcript write");
@@ -9821,7 +9826,10 @@ function claudeHistoryFromJsonl(text, source) {
9821
9826
  visiting.add(key);
9822
9827
  stack.push({ ...step, exit: true });
9823
9828
  const node = nodes.get(uuid);
9824
- if (!node) throw new Error(`missing Claude transcript ancestor: ${uuid}`);
9829
+ if (!node) {
9830
+ missingAncestors.add(uuid);
9831
+ continue;
9832
+ }
9825
9833
  selected.add(uuid);
9826
9834
  const row = (historical ? node.first : node.latest).row;
9827
9835
  const ancestor = parent(row);
@@ -9843,20 +9851,35 @@ function claudeHistoryFromJsonl(text, source) {
9843
9851
  }
9844
9852
  }
9845
9853
  }
9846
- let maxOrdinal = ordinalOf(nodes.get(source.headUuid).latest);
9847
- for (const uuid of selected) maxOrdinal = Math.max(maxOrdinal, ordinalOf(nodes.get(uuid).first));
9848
- const windows = Array.from({ length: maxOrdinal + 1 }, (_, index) => ({ windowId: `claude:${source.sessionId}:${index}`, items: [] }));
9854
+ const current = positionOf(nodes.get(source.headUuid).latest);
9855
+ const windowId = (position) => `claude:${source.sessionId}:${"ordinal" in position ? position.ordinal : `unknown:${position.unknownAncestor}`}`;
9856
+ const windowsById = /* @__PURE__ */ new Map();
9849
9857
  const branchSeqs = /* @__PURE__ */ new Set();
9858
+ let maxOrdinal = "ordinal" in current ? current.ordinal : 0;
9850
9859
  for (const [uuid, node] of nodes) {
9851
9860
  if (!selected.has(uuid)) continue;
9852
- const window = windows[ordinalOf(node.first)];
9861
+ const position = positionOf(node.first);
9862
+ if ("ordinal" in position) maxOrdinal = Math.max(maxOrdinal, position.ordinal);
9863
+ const id = windowId(position);
9864
+ let window = windowsById.get(id);
9865
+ if (!window) {
9866
+ window = { windowId: id, ..."ordinal" in position ? { ordinal: position.ordinal } : {}, items: [] };
9867
+ windowsById.set(id, window);
9868
+ }
9853
9869
  window.createdAt ??= node.items[0]?.createdAt;
9854
9870
  for (const item of node.items) {
9855
9871
  branchSeqs.add(item.seq);
9856
- window.items.push({ ...item, windowId: window.windowId });
9872
+ window.items.push({ ...item, windowId: id });
9857
9873
  }
9858
9874
  }
9859
- return projectHistory(windows, nextSeq - 1, branchSeqs);
9875
+ if (missingAncestors.size === 0) {
9876
+ for (let ordinal = 0; ordinal <= maxOrdinal; ordinal++) {
9877
+ const id = windowId({ ordinal });
9878
+ if (!windowsById.has(id)) windowsById.set(id, { windowId: id, ordinal, items: [] });
9879
+ }
9880
+ }
9881
+ const windows = [...windowsById.values()].sort((a, b) => a.ordinal === void 0 ? b.ordinal === void 0 ? 0 : 1 : b.ordinal === void 0 ? -1 : a.ordinal - b.ordinal);
9882
+ return { ...projectHistory(windows, nextSeq - 1, branchSeqs), missingAncestors: [...missingAncestors], currentWindowOrdinal: "ordinal" in current ? current.ordinal : void 0 };
9860
9883
  }
9861
9884
  async function readClaudeHistory(source) {
9862
9885
  if (!source || typeof source.transcriptPath !== "string" || !source.transcriptPath || typeof source.sessionId !== "string") throw new Error("Claude history transcript_path is unavailable");
@@ -9936,32 +9959,19 @@ Still a tie? *shrugs* You've got a brain. Use it.
9936
9959
  Any other @ address is fake. End of discussion. @ addresses are not file paths: never pass them to file tools like \`read\`, \`write\`, \`edit\`, or \`bash\`.
9937
9960
  ${NOTES_PROTOCOL_CLOSE_TAG}`;
9938
9961
  var MAPS_BLOCK = `<notesoup:maps>
9939
- Every home's root can hold a \`MAP.md\`, and a MAP is the one page that never waits on a shelf \u2014 it
9940
- gets jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever wakes
9941
- up next reads it, and next is you. So keep it short, and keep it true.
9942
-
9943
- Two things live in there:
9944
-
9945
- - **Cheatsheet.** A cheatsheet is a cheatsheet. Scribble whatever you'll want next time \u2014 a rule, a
9946
- warning, a grudge, a name, a phone number you'll regret losing. Nobody grades it. Just keep it
9947
- under five lines, or it grows fat and everybody pays for it.
9948
- - **Index.** One line per durable note: the address, then a gist short enough to tell whether the
9949
- thing is worth opening.
9950
-
9951
- \`\`\`
9952
- # CHEATSHEET
9953
- - Read the repo before asking; run it before believing it
9954
- - Report times in Beijing time
9955
-
9956
- # INDEX
9957
- - release-and-local-install.md \u2014 version bump, local override install, host load timing
9958
- - history-api-v2-design.md \u2014 seq addressing; read before touching history
9959
- - current-reset-and-dream-scope.md \u2014 reset scope, dream territory, session ownership
9960
- \`\`\`
9961
-
9962
- Every home gets one: \`@project\`, \`@human\`, \`@self\`, \`@model\`. New note, new line. New rule worth
9963
- remembering, new Cheatsheet line. And when a line stops being true, kill it \u2014 every window after you
9964
- reads that page as fact.
9962
+ Every home's root can hold two pages that never wait on a shelf: \`CHEATSHEET.md\` and \`MAP.md\`.
9963
+ Both get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever
9964
+ wakes up next reads them, and next is you. So keep them short, and keep them true.
9965
+
9966
+ - **\`CHEATSHEET.md\`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,
9967
+ a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
9968
+ and everybody pays for it.
9969
+ - **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
9970
+ enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, not here.
9971
+
9972
+ Each home keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
9973
+ no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
9974
+ line. And when a line stops being true, kill it \u2014 every window after you reads that page as fact.
9965
9975
  </notesoup:maps>`;
9966
9976
  function renderProtocolBlock(tools) {
9967
9977
  const names = {
@@ -10022,18 +10032,20 @@ function notesIndex(snapshot2, tools, agentName, modelName) {
10022
10032
  continue;
10023
10033
  }
10024
10034
  const rows = (snapshot2.homes.get(home.scope) ?? []).filter((row) => row.meta.crumpledAt === void 0);
10025
- const map = rows.find((row) => row.path === "MAP.md");
10026
- const fresh = rows.filter((row) => row.path !== "MAP.md").slice(0, SHELF_FRESH_LIMIT).map((row) => {
10035
+ const pinned = ["CHEATSHEET.md", "MAP.md"].flatMap((path) => {
10036
+ const row = rows.find((row2) => row2.path === path);
10037
+ return row?.body ? [row] : [];
10038
+ });
10039
+ const fresh = rows.filter((row) => row.path !== "MAP.md" && row.path !== "CHEATSHEET.md").slice(0, SHELF_FRESH_LIMIT).map((row) => {
10027
10040
  const locator = `${row.address} \xB7 ${relativeTime(row.meta.updatedAt, snapshot2.openedAt)}`;
10028
10041
  const title = feedTitle(row.body);
10029
10042
  return title === void 0 ? ` ${locator}` : ` ${title}
10030
10043
  ${locator}`;
10031
10044
  });
10032
- if (!map?.body && fresh.length === 0) continue;
10033
- const parts = [];
10034
- if (map?.body) parts.push(`map
10045
+ if (pinned.length === 0 && fresh.length === 0) continue;
10046
+ const parts = pinned.map((row) => `${row.path === "MAP.md" ? "map" : "cheatsheet"}
10035
10047
 
10036
- ${indent(mapBodyForBoot(map.address, map.body))}`);
10048
+ ${indent(pinnedBodyForBoot(row.address, row.body))}`);
10037
10049
  if (fresh.length > 0) parts.push(`recent
10038
10050
 
10039
10051
  ${fresh.join("\n\n")}`);
@@ -10041,11 +10053,11 @@ ${fresh.join("\n\n")}`);
10041
10053
  }
10042
10054
  return shelves.length > 0 ? ["YOUR NOTES\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500", ...shelves].join("\n\n\n") : "YOUR NOTES\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nNone yet. A blank slate is a fine place to start \u2014 just don't finish there.";
10043
10055
  }
10044
- function mapBodyForBoot(address, body) {
10056
+ function pinnedBodyForBoot(address, body) {
10045
10057
  const chars = Array.from(body);
10046
10058
  if (chars.length <= MAP_BOOT_MAX_CHARS) return body;
10047
10059
  return `${chars.slice(0, MAP_BOOT_MAX_CHARS).join("")}
10048
- [truncated at ${MAP_BOOT_MAX_CHARS} chars; slim this MAP down, full body at \`${address}\`]`;
10060
+ [truncated at ${MAP_BOOT_MAX_CHARS} chars; slim this page down, full body at \`${address}\`]`;
10049
10061
  }
10050
10062
  function renderBootBlock(data) {
10051
10063
  const shown2 = /* @__PURE__ */ new Set([0, data.tree.windows.length - 2, data.tree.windows.length - 1]);
@@ -10084,7 +10096,7 @@ function selectContinuation(origin) {
10084
10096
  return pool[Math.floor(Math.random() * pool.length)];
10085
10097
  }
10086
10098
  var WARNING_TIMING = "The reserve is nearly spent. The wipe lands at the end of whichever turn spends the last of it, possibly this one.";
10087
- var WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim the MAP files; every new window loads them. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
10099
+ var WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim CHEATSHEET.md and MAP.md; every new window loads them. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
10088
10100
  var WARNING_CALL = "Then call `empty_brain`. Nothing in between.";
10089
10101
  function warningPrompt() {
10090
10102
  return `${WARNING_TIMING}
@@ -10102,6 +10114,18 @@ var COUNTDOWN_LINE = "Brain emptied in 3\u2026 2\u2026";
10102
10114
  // plugins/claude/src/text.ts
10103
10115
  var CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
10104
10116
  var CLAUDE_WARNING_PROMPT = warningNotice();
10117
+ var CLAUDE_HISTORY_UNKNOWN_WINDOW = "Claude history cannot determine the current window ordinal across a missing ancestor; restore the ancestry or use a retained notesoup boot to re-anchor it.";
10118
+ var CLAUDE_HISTORY_UNKNOWN_PREVIOUS = 'Cannot resolve "@previous": the immediately preceding window is not confirmed across the ancestry gap. Use an explicit window id from history_windows.';
10119
+ function claudeHistoryUnconfirmedSeq(seq) {
10120
+ return `Seq ${seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`;
10121
+ }
10122
+ function claudeHistoryGapNotice(missing) {
10123
+ if (missing.length === 0) return "";
10124
+ const evidence = missing.slice(0, 5).map((uuid) => JSON.stringify(uuid.length > 160 ? `${uuid.slice(0, 160)}\u2026` : uuid)).join(", ");
10125
+ return `Claude history is incomplete: missing ancestor UUID(s): ${evidence}${missing.length > 5 ? `; ${missing.length - 5} more` : ""}. Only confirmed selected ancestry is returned; disconnected prefixes and unrelated branches are excluded. Window IDs containing :unknown: have unconfirmed ordinal/ownership and may span native compactions; they are listed separately after numbered windows, not placed in a chronological order. A later retained boot can re-anchor window numbering, but cannot fill the history gap.
10126
+
10127
+ `;
10128
+ }
10105
10129
 
10106
10130
  // src/budget/constants.ts
10107
10131
  var WARNING_RUNWAY_TOKENS = 16384;
@@ -10249,7 +10273,6 @@ function boundOperation(operation) {
10249
10273
  description: operation.description,
10250
10274
  parameters: operation.parameters,
10251
10275
  async call(params, ...context) {
10252
- if (!Check2(operation.parameters, params)) throw new Error(`invalid ${operation.name} parameters: ${paramProblem(operation.parameters, params)}`);
10253
10276
  const outcome = await operation.execute(params, ...context);
10254
10277
  return { text: operation.render(outcome), ok: outcome.ok };
10255
10278
  }
@@ -10285,17 +10308,40 @@ async function dispatch(request) {
10285
10308
  if (value.op === "limits") return resolveClaudeLimits(value.facts);
10286
10309
  if (value.op === "tool") {
10287
10310
  if (typeof value.tool !== "string" || !Object.hasOwn(OPERATIONS, value.tool) && !Object.hasOwn(HISTORY_OPERATIONS, value.tool)) throw new Error("unknown tool");
10311
+ const operation = Object.hasOwn(OPERATIONS, value.tool) ? OPERATIONS[value.tool] : HISTORY_OPERATIONS[value.tool];
10312
+ if (!Check2(operation.parameters, value.params)) throw new Error(`invalid ${value.tool} parameters: ${paramProblem(operation.parameters, value.params)}`);
10288
10313
  const id = identity(value.identity);
10289
10314
  if (Object.hasOwn(HISTORY_OPERATIONS, value.tool)) {
10315
+ const tool = value.tool;
10290
10316
  const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
10291
- return HISTORY_OPERATIONS[value.tool].call(value.params, projection, id.sessionId);
10317
+ const notice = claudeHistoryGapNotice(projection.missingAncestors);
10318
+ const wrapText = (text) => notice + text;
10319
+ let params = value.params;
10320
+ if (projection.missingAncestors.length > 0) {
10321
+ if (params.window_id === "@previous") {
10322
+ const previous = projection.currentWindowOrdinal === void 0 ? void 0 : `claude:${id.sessionId}:${projection.currentWindowOrdinal - 1}`;
10323
+ if (!projection.windows.some((window) => window.windowId === previous)) {
10324
+ return { ok: false, text: wrapText(CLAUDE_HISTORY_UNKNOWN_PREVIOUS) };
10325
+ }
10326
+ params = { ...params, window_id: previous };
10327
+ }
10328
+ if (value.tool === "history_read") {
10329
+ const { seq } = params;
10330
+ if (seq <= projection.highestSeq && !projection.branchSeqs.has(seq)) {
10331
+ return { ok: false, text: wrapText(claudeHistoryUnconfirmedSeq(seq)) };
10332
+ }
10333
+ }
10334
+ }
10335
+ const result = tool === "history_windows" ? await HISTORY_OPERATIONS[tool].call(params, projection, id.sessionId, wrapText) : await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
10336
+ return { ...result, text: wrapText(result.text) };
10292
10337
  }
10293
10338
  return OPERATIONS[value.tool].call(value.params, id);
10294
10339
  }
10295
10340
  if (value.op === "history_state") {
10296
10341
  const id = identity(value.identity);
10297
10342
  const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
10298
- return { window: projection.windows.length - 1 };
10343
+ if (projection.currentWindowOrdinal === void 0) throw new Error(CLAUDE_HISTORY_UNKNOWN_WINDOW);
10344
+ return { window: projection.currentWindowOrdinal };
10299
10345
  }
10300
10346
  if (value.op === "boot") {
10301
10347
  const id = identity(value.identity);
@@ -27,7 +27,7 @@ Durable notes hold decisions, constraints, and lessons that stay true after the
27
27
  5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper home, move it there, preserving its metadata, and update both homes' maps. Do it, don't propose it. Propose only when the destination home itself is unclear.
28
28
  6. **Preserve meaning and provenance.** Keep facts, conditions, exceptions, uncertainty, authorship, and sources. When promoting a finding, cite its source. Do not relabel agent-authored material as human-authored. If its destination or authority is unclear, propose the promotion instead.
29
29
  7. **Keep notes manageable.** Aim below about 200 lines / 8KB per note. Split oversized notes by topic with one-line cross-links.
30
- 8. **Keep maps useful.** Each writable home's MAP.md may include a Cheatsheet of rules that apply in every window; keep it short, about 5 lines. The rest stays the note index: durable notes' addresses and short gists, for lookup. Preserve standing rules, add promoted notes, and drop entries that no longer hold. Maps follow the same size budget.
30
+ 8. **Keep wake-up pages useful.** Each writable home's `CHEATSHEET.md` holds standing reminders, kept to five lines. Its `MAP.md` holds only the note index: durable notes' addresses and short gists. Both load every window when present; do not create empty pages. Preserve standing rules, add promoted notes to the map, and drop entries that no longer hold. Maps follow the same size budget.
31
31
 
32
32
  ## Deleting
33
33
 
@@ -5,7 +5,7 @@ description: Review and consolidate durable notes using notesoup's shared dream
5
5
 
6
6
  # Dream
7
7
 
8
- Read `../../playbook.md` completely, resolving the path from this skill's directory. It is the shared guide to reviewing and organizing notes. MAP may include a short Cheatsheet of rules that apply in every window (about 5 lines); the rest stays the note index, for lookup.
8
+ Read `../../playbook.md` completely, resolving the path from this skill's directory. It is the shared guide to reviewing and organizing notes. Standing reminders belong in a separate `CHEATSHEET.md` (five lines); `MAP.md` holds only the note index. Both load every window when present.
9
9
 
10
10
  Dream in this agent's current session. Do not start another agent or model unless the human asks.
11
11
 
@@ -32,7 +32,7 @@ Any other `@` prefix is refused. A path is relative and `/`-separated, with no e
32
32
 
33
33
  `@` addresses are not file paths: never pass them to file tools like `read`, `write`, `edit`, or `bash`. That creates a stray directory instead of a note.
34
34
 
35
- `MAP.md` at the root of each `@` home is a page you wake up with. It may include a Cheatsheet of rules that apply in every window; keep it short, about 5 lines. The rest is the note index: each durable note's address and gist, for lookup. Update it whenever you add, move or crumple a durable note.
35
+ `CHEATSHEET.md` and `MAP.md` at the root of each `@` home are separate pages you wake up with; absent pages are skipped. Keep standing reminders in `CHEATSHEET.md`, to five lines. `MAP.md` holds only the note index: each durable note's address and gist, for lookup. Update it whenever you add, move or crumple a durable note. Do not create empty pages.
36
36
 
37
37
  Write only what git and history cannot give back. Crumple notes that are no longer true; a stale note is worse than none.
38
38