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
@@ -3,14 +3,13 @@ import { pathToFileURL } from "node:url";
3
3
  import type { Static, TSchema } from "typebox";
4
4
  import { Check, Errors } from "typebox/value";
5
5
  import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
6
- import { historyList, historyRead, historyWindows } from "../../../src/tools/history.js";
6
+ import { historyList, historyRead, historyWindows, type HistoryTextWrapper } from "../../../src/tools/history.js";
7
7
  import { readClaudeHistory, type ClaudeHistorySource } from "./history.js";
8
- import type { HistoryProjection } from "../../../src/history/history.js";
9
8
  import { loadNotesSnapshot } from "../../../src/boot/snapshot.js";
10
9
  import { renderBootBlock } from "../../../src/boot/render.js";
11
10
  import type { BootToolNames } from "../../../src/boot/text.js";
12
11
  import { selectContinuation } from "../../../src/budget/text.js";
13
- import { CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
12
+ import { claudeHistoryGapNotice, claudeHistoryUnconfirmedSeq, CLAUDE_HISTORY_UNKNOWN_PREVIOUS, CLAUDE_HISTORY_UNKNOWN_WINDOW, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
14
13
  import { resolveClaudeLimits } from "./thresholds.js";
15
14
  import { projectKey, snapshotNotesIdentity, type NotesIdentity } from "../../../src/notes/index.js";
16
15
  import type { Operation } from "../../../src/tools/result.js";
@@ -41,7 +40,7 @@ function paramProblem(schema: TSchema, params: unknown): string {
41
40
  return `${field ? `${field} ` : ""}${first.message}${extra}`;
42
41
  }
43
42
 
44
- /** Bind one shared operation to the identity Claude supplies. Validate untyped Claude parameters against the shared operation schema before execution. */
43
+ /** Bind shared execution/rendering to a host context; dispatch validates parameters before calling. */
45
44
  function boundOperation<TParams extends TSchema, TData, TContext extends readonly unknown[]>(
46
45
  operation: Operation<TParams, TData, TContext>,
47
46
  ): BoundOperation<TContext> {
@@ -49,8 +48,6 @@ function boundOperation<TParams extends TSchema, TData, TContext extends readonl
49
48
  description: operation.description,
50
49
  parameters: operation.parameters,
51
50
  async call(params, ...context) {
52
- // Refuse before the operation can act: a rejected shape never reaches a write.
53
- if (!Check(operation.parameters, params)) throw new Error(`invalid ${operation.name} parameters: ${paramProblem(operation.parameters, params)}`);
54
51
  // The same business outcome and the same renderer as the Pi tool; only the envelope differs.
55
52
  const outcome = await operation.execute(params as Static<TParams>, ...context);
56
53
  return { text: operation.render(outcome), ok: outcome.ok };
@@ -66,7 +63,7 @@ const OPERATIONS: Record<string, BoundOperation<[NotesIdentity]>> = {
66
63
  notes_search: boundOperation(notesSearch),
67
64
  };
68
65
 
69
- const HISTORY_OPERATIONS: Record<string, BoundOperation<[HistoryProjection, string]>> = {
66
+ const HISTORY_OPERATIONS = {
70
67
  history_list: boundOperation(historyList),
71
68
  history_read: boundOperation(historyRead),
72
69
  history_windows: boundOperation(historyWindows),
@@ -95,17 +92,45 @@ export async function dispatch(request: unknown): Promise<unknown> {
95
92
  if (value.op === "limits") return resolveClaudeLimits(value.facts);
96
93
  if (value.op === "tool") {
97
94
  if (typeof value.tool !== "string" || (!Object.hasOwn(OPERATIONS, value.tool) && !Object.hasOwn(HISTORY_OPERATIONS, value.tool))) throw new Error("unknown tool");
95
+ const operation = Object.hasOwn(OPERATIONS, value.tool) ? OPERATIONS[value.tool]! : HISTORY_OPERATIONS[value.tool as keyof typeof HISTORY_OPERATIONS];
96
+ // Refuse before any operation can act: a rejected shape never reaches a write.
97
+ if (!Check(operation.parameters, value.params)) throw new Error(`invalid ${value.tool} parameters: ${paramProblem(operation.parameters, value.params)}`);
98
98
  const id = identity(value.identity as ClaudeIdentityInput);
99
99
  if (Object.hasOwn(HISTORY_OPERATIONS, value.tool)) {
100
+ const tool = value.tool as keyof typeof HISTORY_OPERATIONS;
100
101
  const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
101
- return HISTORY_OPERATIONS[value.tool]!.call(value.params, projection, id.sessionId);
102
+ const notice = claudeHistoryGapNotice(projection.missingAncestors);
103
+ const wrapText: HistoryTextWrapper = (text) => notice + text;
104
+ let params = value.params;
105
+ if (projection.missingAncestors.length > 0) {
106
+ // An unknown segment is not evidence for the window before the current
107
+ // one. Resolve the exact ordinal, never array adjacency across a gap.
108
+ if ((params as { window_id?: string }).window_id === "@previous") {
109
+ const previous = projection.currentWindowOrdinal === undefined ? undefined : `claude:${id.sessionId}:${projection.currentWindowOrdinal - 1}`;
110
+ if (!projection.windows.some((window) => window.windowId === previous)) {
111
+ return { ok: false, text: wrapText(CLAUDE_HISTORY_UNKNOWN_PREVIOUS) };
112
+ }
113
+ params = { ...params as object, window_id: previous };
114
+ }
115
+ if (value.tool === "history_read") {
116
+ const { seq } = params as { seq: number };
117
+ if (seq <= projection.highestSeq && !projection.branchSeqs.has(seq)) {
118
+ return { ok: false, text: wrapText(claudeHistoryUnconfirmedSeq(seq)) };
119
+ }
120
+ }
121
+ }
122
+ const result = tool === "history_windows"
123
+ ? await HISTORY_OPERATIONS[tool].call(params, projection, id.sessionId, wrapText)
124
+ : await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
125
+ return { ...result, text: wrapText(result.text) };
102
126
  }
103
127
  return OPERATIONS[value.tool]!.call(value.params, id);
104
128
  }
105
129
  if (value.op === "history_state") {
106
130
  const id = identity(value.identity as ClaudeIdentityInput);
107
131
  const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
108
- return { window: projection.windows.length - 1 };
132
+ if (projection.currentWindowOrdinal === undefined) throw new Error(CLAUDE_HISTORY_UNKNOWN_WINDOW);
133
+ return { window: projection.currentWindowOrdinal };
109
134
  }
110
135
  if (value.op === "boot") {
111
136
  const id = identity(value.identity as ClaudeIdentityInput);
@@ -4,9 +4,12 @@ import { isDeepStrictEqual } from "node:util";
4
4
  import { contentText, projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection } from "../../../src/history/history.js";
5
5
 
6
6
  type Row = Record<string, unknown>;
7
- type Version = { row: Row; ancestorUuid?: string; ancestor?: Version; ordinal?: number };
7
+ type WindowPosition = { ordinal: number } | { unknownAncestor: string };
8
+ type Version = { row: Row; ancestorUuid?: string; ancestor?: Version; position?: WindowPosition };
8
9
  type Node = { first: Version; latest: Version; items: DecodedHistoryItem[] };
9
10
  export type ClaudeHistorySource = { sessionId: string; transcriptPath: string; headUuid?: string };
11
+ /** Claude graph evidence stays in the adapter; shared queries only see addressed windows. */
12
+ export type ClaudeHistoryProjection = HistoryProjection & { missingAncestors: string[]; currentWindowOrdinal: number | undefined };
10
13
  const MESSAGE_TYPES = new Set(["user", "assistant", "system", "attachment"]);
11
14
  const NON_TEXT_BLOCKS = new Set(["thinking", "redacted_thinking", "image", "document", "audio", "video", "server_tool_use", "web_search_tool_result", "tool_reference"]);
12
15
  function object(value: unknown): value is Row { return typeof value === "object" && value !== null && !Array.isArray(value); }
@@ -112,12 +115,12 @@ function bootOrdinal(row: Row, retained: boolean): number | undefined {
112
115
  }
113
116
 
114
117
  /** All addresses are allocated on the full first-occurrence log, before branch selection. */
115
- export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistorySource, "transcriptPath">): HistoryProjection {
118
+ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistorySource, "transcriptPath">): ClaudeHistoryProjection {
116
119
  const nodes = new Map<string, Node>();
117
120
  let nextSeq = 1;
118
121
  for (const row of rowsOf(text)) {
119
- // Ignore non-message records, including future metadata. A skipped UUID that
120
- // the selected branch actually requires still fails ancestry resolution below.
122
+ // Ignore non-message records, including future metadata. If selected ancestry
123
+ // reaches a skipped UUID, it becomes a gap, never permission to expose its payload.
121
124
  if (!MESSAGE_TYPES.has(row.type as string)) continue;
122
125
  const uuid = requiredString(row.uuid, "uuid");
123
126
  parent(row);
@@ -141,29 +144,37 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
141
144
  nextSeq += items.length;
142
145
  nodes.set(uuid, { first: version, latest: version, items });
143
146
  }
144
- function ordinalOf(version: Version): number {
145
- // Persisted history is not limited to the host's newest 4096 inference rows.
146
- // Resolve long parent chains iteratively, not with the JavaScript call stack.
147
+ const missingAncestors = new Set<string>();
148
+ function positionOf(version: Version): WindowPosition {
149
+ // Resolve long chains iteratively. A gap destroys ordinal evidence, not the
150
+ // confirmed suffix. Only a retained boot can re-anchor that suffix's ordinal.
147
151
  const chain: Version[] = [], calculating = new Set<Version>();
148
152
  let cursor = version;
149
- while (cursor.ordinal === undefined) {
150
- // A notice can precede its parent on disk; use that parent's first eventual version.
153
+ let before: WindowPosition = { ordinal: 0 };
154
+ while (cursor.position === undefined) {
155
+ // Forward references use the parent's first eventual version, not a rewrite.
151
156
  cursor.ancestor ??= cursor.ancestorUuid === undefined ? undefined : nodes.get(cursor.ancestorUuid)?.first;
152
157
  if (calculating.has(cursor)) throw new Error("cyclic Claude transcript ancestry");
153
- if (cursor.ancestorUuid !== undefined && cursor.ancestor === undefined) throw new Error(`missing Claude transcript ancestor: ${cursor.ancestorUuid}`);
154
158
  calculating.add(cursor);
155
159
  chain.push(cursor);
160
+ if (cursor.ancestorUuid !== undefined && cursor.ancestor === undefined) {
161
+ missingAncestors.add(cursor.ancestorUuid);
162
+ before = { unknownAncestor: cursor.ancestorUuid };
163
+ break;
164
+ }
156
165
  if (cursor.ancestor === undefined) break;
157
166
  cursor = cursor.ancestor;
158
167
  }
159
- let before = cursor.ordinal ?? 0;
168
+ before = cursor.position ?? before;
160
169
  for (const current of chain.reverse()) {
161
170
  const retained = current.row.isCompactSummary === true || (current.ancestor !== undefined && boundary(current.ancestor.row));
162
171
  const marked = bootOrdinal(current.row, retained);
163
- current.ordinal = marked === undefined ? before + (boundary(current.row) ? 1 : 0) : Math.max(before, marked);
164
- before = current.ordinal;
172
+ current.position = marked !== undefined
173
+ ? { ordinal: "ordinal" in before ? Math.max(before.ordinal, marked) : marked }
174
+ : "ordinal" in before ? { ordinal: before.ordinal + (boundary(current.row) ? 1 : 0) } : before;
175
+ before = current.position;
165
176
  }
166
- return version.ordinal!;
177
+ return version.position!;
167
178
  }
168
179
  if (!source.headUuid) throw new Error("Claude history has no confirmed active head yet; wait for a main-session append after startup/resume");
169
180
  if (!nodes.has(source.headUuid)) throw new Error("Claude history active head is not persisted yet; retry after the transcript write");
@@ -182,7 +193,7 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
182
193
  visiting.add(key);
183
194
  stack.push({ ...step, exit: true });
184
195
  const node = nodes.get(uuid);
185
- if (!node) throw new Error(`missing Claude transcript ancestor: ${uuid}`);
196
+ if (!node) { missingAncestors.add(uuid); continue; }
186
197
  selected.add(uuid);
187
198
  const row = (historical ? node.first : node.latest).row;
188
199
  const ancestor = parent(row);
@@ -207,20 +218,41 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
207
218
  }
208
219
  }
209
220
 
210
- let maxOrdinal = ordinalOf(nodes.get(source.headUuid)!.latest);
211
- for (const uuid of selected) maxOrdinal = Math.max(maxOrdinal, ordinalOf(nodes.get(uuid)!.first));
212
- const windows: DecodedHistoryWindow[] = Array.from({ length: maxOrdinal + 1 }, (_, index) => ({ windowId: `claude:${source.sessionId}:${index}`, items: [] }));
221
+ const current = positionOf(nodes.get(source.headUuid)!.latest);
222
+ const windowId = (position: WindowPosition) => `claude:${source.sessionId}:${"ordinal" in position ? position.ordinal : `unknown:${position.unknownAncestor}`}`;
223
+ const windowsById = new Map<string, DecodedHistoryWindow & { ordinal?: number }>();
213
224
  const branchSeqs = new Set<number>();
225
+ let maxOrdinal = "ordinal" in current ? current.ordinal : 0;
214
226
  for (const [uuid, node] of nodes) {
215
227
  if (!selected.has(uuid)) continue;
216
- const window = windows[ordinalOf(node.first)]!;
228
+ const position = positionOf(node.first);
229
+ if ("ordinal" in position) maxOrdinal = Math.max(maxOrdinal, position.ordinal);
230
+ const id = windowId(position);
231
+ let window = windowsById.get(id);
232
+ if (!window) {
233
+ window = { windowId: id, ...("ordinal" in position ? { ordinal: position.ordinal } : {}), items: [] };
234
+ windowsById.set(id, window);
235
+ }
217
236
  window.createdAt ??= node.items[0]?.createdAt;
218
- for (const item of node.items) { branchSeqs.add(item.seq); window.items.push({ ...item, windowId: window.windowId }); }
237
+ for (const item of node.items) { branchSeqs.add(item.seq); window.items.push({ ...item, windowId: id }); }
238
+ }
239
+ // Preserve complete-history empty windows (including copied boot ordinals).
240
+ // With gaps, report only evidenced windows, never invent the missing ordinals.
241
+ if (missingAncestors.size === 0) {
242
+ for (let ordinal = 0; ordinal <= maxOrdinal; ordinal++) {
243
+ const id = windowId({ ordinal });
244
+ if (!windowsById.has(id)) windowsById.set(id, { windowId: id, ordinal, items: [] });
245
+ }
219
246
  }
220
- return projectHistory(windows, nextSeq - 1, branchSeqs);
247
+ // Forward references can put a newer numbered window on disk first. Unknown
248
+ // segments are a separate, unordered group, not an inferred place in that timeline.
249
+ const windows = [...windowsById.values()].sort((a, b) => a.ordinal === undefined
250
+ ? b.ordinal === undefined ? 0 : 1
251
+ : b.ordinal === undefined ? -1 : a.ordinal - b.ordinal);
252
+ return { ...projectHistory(windows, nextSeq - 1, branchSeqs), missingAncestors: [...missingAncestors], currentWindowOrdinal: "ordinal" in current ? current.ordinal : undefined };
221
253
  }
222
254
 
223
- export async function readClaudeHistory(source: ClaudeHistorySource): Promise<HistoryProjection> {
255
+ export async function readClaudeHistory(source: ClaudeHistorySource): Promise<ClaudeHistoryProjection> {
224
256
  if (!source || typeof source.transcriptPath !== "string" || !source.transcriptPath || typeof source.sessionId !== "string") throw new Error("Claude history transcript_path is unavailable");
225
257
  return claudeHistoryFromJsonl(await readFile(source.transcriptPath, "utf8"), source);
226
258
  }
@@ -5,3 +5,16 @@ export const CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in t
5
5
 
6
6
  /** The same notice as Pi; empty_brain's result explains Claude's deferred reset. */
7
7
  export const CLAUDE_WARNING_PROMPT = warningNotice();
8
+
9
+ export const 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.";
10
+ export const 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.';
11
+ export function claudeHistoryUnconfirmedSeq(seq: number): string {
12
+ return `Seq ${seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`;
13
+ }
14
+
15
+ /** Bounded host-only evidence, outside event documents/search offsets and shared schemas. */
16
+ export function claudeHistoryGapNotice(missing: readonly string[]): string {
17
+ if (missing.length === 0) return "";
18
+ const evidence = missing.slice(0, 5).map((uuid) => JSON.stringify(uuid.length > 160 ? `${uuid.slice(0, 160)}…` : uuid)).join(", ");
19
+ 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.\n\n`;
20
+ }
@@ -0,0 +1,43 @@
1
+ # notesoup for Codex
2
+
3
+ Native notes and history for Codex **0.160.1**. The plugin bundles one stdio MCP server with the five notes homes and three history tools, and one hook helper that injects the notes boot into each native context window. `new_context` and `get_context_remaining` stay Codex's own tools; notesoup does not replace Codex's reset or budget.
4
+
5
+ ## Install
6
+
7
+ Build the bundle, add this repository as a marketplace, install the plugin, and approve its hooks:
8
+
9
+ ```sh
10
+ npm ci && npm run build
11
+ codex plugin marketplace add /absolute/path/to/notesoup
12
+ codex plugin add notesoup@notesoup
13
+ ```
14
+
15
+ Then set the target native-mode configuration in `~/.codex/config.toml` (source-checked, not exercised against a live Codex config parser in this stage):
16
+
17
+ ```toml
18
+ [features]
19
+ context_management = false
20
+ retain_client_developer_messages = false
21
+
22
+ [features.token_budget]
23
+ enabled = true
24
+ use_history_notes_extension = false
25
+ ```
26
+
27
+ Do not also set `token_budget = true`: the table above is the whole setting. Restart Codex or resume the thread after installing, so `SessionStart` can bind the thread.
28
+
29
+ ## What it does
30
+
31
+ - The `SessionStart` hook reads the native rollout, binds thread identity from hook facts, and returns the notes boot for the current native window. A restart, resume or compact without an existing boot for that window gets one.
32
+ - `notes_*` uses `NOTESOUP_HOME` (default `~/.agents/notes`) and the current turn's model for `@model`.
33
+ - `history_*` reads the local rollout: root windows and a child's own ancestry. Window ids are `codex:<thread>:<native-window-uuid>`.
34
+ - Stale roots, missing windows, missing turn models and missing bindings are refusals. Resume or compact once to rebind.
35
+ - A child `PreCompact` is stopped with `continue: false`: Codex 0.160.1 has no child post-compact recovery hook. Save a handoff and start a fresh child.
36
+
37
+ Requires Node **>=22.15** for compressed `.jsonl.zst` rollouts.
38
+
39
+ ## Limits
40
+
41
+ 128 KiB boot cap (host spilling disabled), 32 KiB tool results, local rollout history only, no MCP reset or budget fallback, no dream backend, no notifications or commands. Codex versions other than 0.160.1 are refused.
42
+
43
+ This stage is validated with producer-shaped fixtures and the official MCP SDK client, not against a live Codex model loop. See [docs/codex.md](../../docs/codex.md) for setup, refusal codes, window identity and the validation scope.