@cortexkit/opencode-magic-context 0.44.1 → 0.44.3

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 (216) hide show
  1. package/README.md +6 -0
  2. package/dist/agents/dreamer.d.ts +4 -6
  3. package/dist/agents/dreamer.d.ts.map +1 -1
  4. package/dist/config/live-child-output-cap.d.ts.map +1 -1
  5. package/dist/config/schema/magic-context.d.ts +63 -10
  6. package/dist/config/schema/magic-context.d.ts.map +1 -1
  7. package/dist/{conflict-warning-hook-d14ah73v.js → conflict-warning-hook-hmpzxep6.js} +3 -3
  8. package/dist/{derive-budgets-gd2270s0.js → derive-budgets-vjmvh6pz.js} +3 -1
  9. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  10. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +11 -0
  11. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  12. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +2 -0
  15. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/lease.d.ts +1 -1
  18. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +1 -1
  21. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/map-memories.d.ts +5 -0
  23. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +5 -0
  25. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  26. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -2
  27. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  28. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +8 -1
  29. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  31. package/dist/features/magic-context/dreamer/task-executor.d.ts +5 -0
  32. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  33. package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
  34. package/dist/features/magic-context/dreamer/task-prompts.d.ts +18 -2
  35. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  36. package/dist/features/magic-context/dreamer/task-registry.d.ts +12 -0
  37. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  38. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -1
  39. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  40. package/dist/features/magic-context/dreamer/token-budget.d.ts +33 -0
  41. package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -0
  42. package/dist/features/magic-context/dreamer/verify-diff.d.ts +15 -0
  43. package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -0
  44. package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
  45. package/dist/features/magic-context/dreamer/verify-prompt.d.ts +5 -2
  46. package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
  47. package/dist/features/magic-context/dreamer/verify-read-cap.d.ts +4 -0
  48. package/dist/features/magic-context/dreamer/verify-read-cap.d.ts.map +1 -0
  49. package/dist/features/magic-context/dreamer/verify.d.ts +5 -0
  50. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  51. package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -1
  52. package/dist/features/magic-context/memory/project-identity-cache.d.ts +6 -0
  53. package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -0
  54. package/dist/features/magic-context/memory/project-identity.d.ts +11 -22
  55. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  56. package/dist/features/magic-context/memory/storage-memory-fts.d.ts +1 -0
  57. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
  58. package/dist/features/magic-context/memory/verification-paths.d.ts +1 -0
  59. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  60. package/dist/features/magic-context/message-index-async.d.ts +1 -1
  61. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  62. package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
  63. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  64. package/dist/features/magic-context/search.d.ts.map +1 -1
  65. package/dist/features/magic-context/session-activity.d.ts +10 -0
  66. package/dist/features/magic-context/session-activity.d.ts.map +1 -0
  67. package/dist/features/magic-context/session-project-backfill.d.ts +4 -1
  68. package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
  69. package/dist/features/magic-context/session-project-storage.d.ts +5 -5
  70. package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
  71. package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -0
  72. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  73. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +1 -0
  74. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
  75. package/dist/features/magic-context/smart-notes/storage.d.ts +1 -1
  76. package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
  77. package/dist/features/magic-context/smart-notes/types.d.ts +2 -0
  78. package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
  79. package/dist/features/magic-context/storage-db.d.ts +2 -1
  80. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  81. package/dist/features/magic-context/storage-embedding-measurements.d.ts.map +1 -1
  82. package/dist/features/magic-context/storage-identity-merge.d.ts +4 -1
  83. package/dist/features/magic-context/storage-identity-merge.d.ts.map +1 -1
  84. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  85. package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -1
  86. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  88. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -1
  89. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  92. package/dist/hooks/magic-context/compartment-runner-types.d.ts +1 -0
  93. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  94. package/dist/hooks/magic-context/compartment-runner.d.ts +1 -0
  95. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/derive-budgets.d.ts +4 -0
  97. package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
  98. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/embed-session-state.d.ts +3 -0
  100. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
  101. package/dist/hooks/magic-context/event-handler.d.ts +1 -0
  102. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/event-payloads.d.ts +1 -0
  104. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  106. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/lkg-persist.d.ts +1 -4
  109. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  110. package/dist/hooks/magic-context/lkg-replay.d.ts +6 -4
  111. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  113. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  114. package/dist/hooks/magic-context/producer-window-guard.d.ts +4 -1
  115. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
  117. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/storage-busy-refusal.d.ts +13 -0
  119. package/dist/hooks/magic-context/storage-busy-refusal.d.ts.map +1 -0
  120. package/dist/hooks/magic-context/strip-content.d.ts +1 -0
  121. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  122. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  124. package/dist/{index-a9vbtdzv.js → index-33q7s9y2.js} +1 -1
  125. package/dist/{index-cz88kw0n.js → index-4an2p8qa.js} +183 -39
  126. package/dist/{index-d107az47.js → index-638hf49n.js} +1 -1
  127. package/dist/{index-stb5fg12.js → index-9y5p0d50.js} +31 -1
  128. package/dist/{index-s6b7h12g.js → index-dgg5y7er.js} +73 -2
  129. package/dist/{index-6w9p73jz.js → index-jqcbs2k1.js} +10 -0
  130. package/dist/{index-0rp6pj54.js → index-nf9sk8sh.js} +7 -5
  131. package/dist/index-q5p1aqvv.js +7260 -0
  132. package/dist/index-rdsaxnf2.js +125 -0
  133. package/dist/{index-jtdrvmcn.js → index-yhm60r53.js} +37544 -37072
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +8402 -14429
  136. package/dist/plugin/dream-timer.d.ts.map +1 -1
  137. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  138. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  139. package/dist/plugin/messages-transform.d.ts +10 -9
  140. package/dist/plugin/messages-transform.d.ts.map +1 -1
  141. package/dist/plugin/rpc-handlers.d.ts +1 -0
  142. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  143. package/dist/{read-session-chunk-fkdv2g5b.js → read-session-chunk-n072mcq4.js} +2 -2
  144. package/dist/{recomp-orchestrator-k4h5n0p3.js → recomp-orchestrator-19tr6zya.js} +6 -5
  145. package/dist/{send-session-notification-g2k03zyn.js → send-session-notification-04hvd54c.js} +2 -2
  146. package/dist/shared/model-suggestion-retry.d.ts +1 -1
  147. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  148. package/dist/shared/prompt-async-transport.d.ts +7 -7
  149. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  150. package/dist/shared/rpc-server.d.ts.map +1 -1
  151. package/dist/shared/rpc-utils.d.ts +21 -0
  152. package/dist/shared/rpc-utils.d.ts.map +1 -1
  153. package/dist/shared/run-token-log.d.ts +13 -0
  154. package/dist/shared/run-token-log.d.ts.map +1 -0
  155. package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -1
  156. package/dist/shared/sqlite.d.ts +19 -0
  157. package/dist/shared/sqlite.d.ts.map +1 -1
  158. package/dist/shared/subagent-runner.d.ts +3 -1
  159. package/dist/shared/subagent-runner.d.ts.map +1 -1
  160. package/dist/shared/user-facing-codes.d.ts +5 -0
  161. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  162. package/dist/{task-config-mgf5nsh3.js → task-config-2bm68628.js} +1 -1
  163. package/dist/transform-postprocess-phase-z2mfc5w1.js +36 -0
  164. package/dist/v2/hidden-completion.d.ts +9 -1
  165. package/dist/v2/hidden-completion.d.ts.map +1 -1
  166. package/dist/v2/hooks/context.d.ts.map +1 -1
  167. package/dist/v2/hooks/hidden-child.d.ts +1 -0
  168. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  169. package/dist/v2/hooks/hidden-terminal-error.d.ts +8 -0
  170. package/dist/v2/hooks/hidden-terminal-error.d.ts.map +1 -0
  171. package/dist/v2/hooks/lkg-system.d.ts +11 -0
  172. package/dist/v2/hooks/lkg-system.d.ts.map +1 -0
  173. package/dist/v2/hooks/session-project-backfill.d.ts +1 -1
  174. package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
  175. package/dist/v2/hooks/storage-gate.d.ts +11 -5
  176. package/dist/v2/hooks/storage-gate.d.ts.map +1 -1
  177. package/dist/v2/hooks/tools.d.ts +1 -1
  178. package/dist/v2/hooks/tools.d.ts.map +1 -1
  179. package/dist/v2/host-service.d.ts +2 -1
  180. package/dist/v2/host-service.d.ts.map +1 -1
  181. package/dist/v2/server.js +24948 -22659
  182. package/dist/v2/store-reader.d.ts +2 -0
  183. package/dist/v2/store-reader.d.ts.map +1 -1
  184. package/dist/{wrapup-orchestrator-35y56636.js → wrapup-orchestrator-sy4m56a7.js} +7 -6
  185. package/package.json +1 -1
  186. package/src/agents/dreamer.ts +4 -6
  187. package/src/agents/hidden-agent-registrations.ts +3 -3
  188. package/src/agents/permissions.test.ts +3 -4
  189. package/src/config/latch-permanence-guard.test.ts +13 -0
  190. package/src/config/live-child-output-cap.test.ts +26 -0
  191. package/src/config/live-child-output-cap.ts +6 -2
  192. package/src/config/schema/magic-context.ts +21 -6
  193. package/src/features/magic-context/dreamer/task-registry.ts +13 -0
  194. package/src/shared/data-path.test.ts +1 -1
  195. package/src/shared/logger.test.ts +1 -0
  196. package/src/shared/model-suggestion-retry.ts +9 -2
  197. package/src/shared/models-dev-cache.test.ts +30 -1
  198. package/src/shared/prompt-async-transport.test.ts +254 -1
  199. package/src/shared/prompt-async-transport.ts +153 -44
  200. package/src/shared/rpc-async-probes.test.ts +230 -0
  201. package/src/shared/rpc-server.ts +6 -4
  202. package/src/shared/rpc-utils.test.ts +27 -1
  203. package/src/shared/rpc-utils.ts +161 -9
  204. package/src/shared/run-token-log.test.ts +65 -0
  205. package/src/shared/run-token-log.ts +39 -0
  206. package/src/shared/sqlite-acquisition-fence.test.ts +132 -0
  207. package/src/shared/sqlite-acquisition-routing.test.ts +102 -0
  208. package/src/shared/sqlite-pass-scope.test.ts +153 -0
  209. package/src/shared/sqlite-transaction-mode-guard.test.ts +42 -10
  210. package/src/shared/sqlite-write-locker-test-support.ts +1 -0
  211. package/src/shared/sqlite.ts +245 -56
  212. package/src/shared/storage-busy.test.ts +72 -0
  213. package/src/shared/subagent-runner.ts +4 -0
  214. package/src/shared/user-facing-codes.ts +6 -0
  215. package/src/shared/windows-hidden-spawns.test.ts +132 -0
  216. package/src/shared/write-transaction-attribution.test.ts +14 -11
@@ -114,6 +114,7 @@ export declare class V2StoreReader {
114
114
  sessionId: string;
115
115
  directory: string;
116
116
  }>;
117
+ latestMessageTime(sessionID: string): number | undefined;
117
118
  storedMessageCount(sessionID: string): number;
118
119
  messageById(sessionID: string, id: string): StoreRow | null;
119
120
  messageExistsById(sessionID: string, id: string): boolean;
@@ -139,6 +140,7 @@ export declare class V2StoreReader {
139
140
  idleRows(sessionID: string, after?: number): StoreRow<"idle">[];
140
141
  earliestSequence(sessionID: string): number | undefined;
141
142
  latestSequence(sessionID: string): number;
143
+ assistantSince(sessionID: string, afterSeq: number): StoreRow<"assistant">[];
142
144
  latestAssistant(sessionID: string): StoreRow<"assistant"> | undefined;
143
145
  latestIdle(sessionID: string): StoreRow<"idle"> | undefined;
144
146
  /** Include the completed checkpoint itself, matching the host history cut. */
@@ -1 +1 @@
1
- {"version":3,"file":"store-reader.d.ts","sourceRoot":"","sources":["../../src/v2/store-reader.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAW,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAGD,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,OAAO,GACP,OAAO,GACP,WAAW,GACX,YA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.js";
4
+ import"./index-rdsaxnf2.js";
5
+ import"./index-yhm60r53.js";
5
6
  import"./index-sd3egckz.js";
6
- import"./index-stb5fg12.js";
7
- import"./index-a9vbtdzv.js";
8
- import"./index-s6b7h12g.js";
7
+ import"./index-9y5p0d50.js";
8
+ import"./index-33q7s9y2.js";
9
+ import"./index-dgg5y7er.js";
9
10
  import"./index-y5145x8k.js";
10
- import"./index-cz88kw0n.js";
11
+ import"./index-4an2p8qa.js";
11
12
  import"./index-kr5qehbd.js";
12
13
  import"./index-jdxxq8cz.js";
13
14
  import"./index-kwe03yde.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.44.1",
3
+ "version": "0.44.3",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -51,9 +51,7 @@ export const DREAMER_DOCS_ALLOWED_TOOLS = [
51
51
  // calls NO tools (zero), so it gets the empty allow-list, locked.
52
52
  export const DREAMER_REVIEWER_AGENT = "dreamer-reviewer";
53
53
 
54
- /** Tool profile for the base `dreamer` agent, now CURATE-ONLY (memory-pool
55
- * hygiene). Curate edits memories through ctx_memory and enumerates them through
56
- * the dreamer-only ctx_memory_list; it never reads code because a separate verify
57
- * task owns memory-vs-code correctness. Kept on the `dreamer` id so memory-tool
58
- * agent gates recognize it. */
59
- export const DREAMER_CURATE_ALLOWED_TOOLS = ["ctx_memory", "ctx_memory_list"] as const;
54
+ /** Curate receives its category snapshot from the host and edits memories via
55
+ * ctx_memory. It does not read code; the verify task checks memory accuracy.
56
+ * Keep the `dreamer` id because memory-tool authorization matches that id. */
57
+ export const DREAMER_CURATE_ALLOWED_TOOLS = ["ctx_memory"] as const;
@@ -102,15 +102,15 @@ export function buildHiddenAgentRegistrations(args: {
102
102
  hidden: true,
103
103
  description: HIDDEN_AGENT_DESCRIPTION,
104
104
  prompt: args.dreamerPrompt,
105
- // CURATE-ONLY now. Curate edits through ctx_memory and enumerates through
106
- // ctx_memory_list; it never reads code because a separate verify task
105
+ // Curate receives its category snapshot in the first message and edits
106
+ // through ctx_memory; it never reads code because a separate verify task
107
107
  // owns memory-vs-code correctness. No former bash/write/edit/read/aft/
108
108
  // ctx_search/ctx_note surface remains. maintain-docs
109
109
  // and review-user-memories moved to their own scoped agents below.
110
110
  // (Inline literal — kept byte-identical to DREAMER_CURATE_ALLOWED_TOOLS
111
111
  // by agent-registration-drift.test.ts; see the module header for why
112
112
  // these are not const imports.)
113
- allowedTools: ["ctx_memory", "ctx_memory_list"],
113
+ allowedTools: ["ctx_memory"],
114
114
  // Curate is a genuine multi-step whole-pool hygiene loop, so it keeps a
115
115
  // high cap.
116
116
  maxSteps: 150,
@@ -125,10 +125,10 @@ describe("applyDisallowedTools", () => {
125
125
  });
126
126
 
127
127
  describe("DREAMER_CURATE_ALLOWED_TOOLS (base dreamer = curate only)", () => {
128
- it("allows only the two memory tools — curate edits and enumerates the memory store", () => {
128
+ it("allows only ctx_memory — the category snapshot replaces enumeration", () => {
129
129
  // A separate verify task owns memory-vs-code correctness; curate is
130
130
  // pure pool hygiene, so it has no read/grep/bash/write/edit surface.
131
- expect([...DREAMER_CURATE_ALLOWED_TOOLS]).toEqual(["ctx_memory", "ctx_memory_list"]);
131
+ expect([...DREAMER_CURATE_ALLOWED_TOOLS]).toEqual(["ctx_memory"]);
132
132
  });
133
133
 
134
134
  it("does NOT include any codebase / shell / file-write tool", () => {
@@ -183,12 +183,11 @@ describe("integration: full hidden-agent permission shape", () => {
183
183
  });
184
184
  });
185
185
 
186
- it("base dreamer permission object denies all except the two memory tools", () => {
186
+ it("base dreamer permission object denies all except ctx_memory", () => {
187
187
  const perm = buildAllowOnlyPermission(DREAMER_CURATE_ALLOWED_TOOLS);
188
188
  expect(perm).toEqual({
189
189
  "*": "deny",
190
190
  ctx_memory: "allow",
191
- ctx_memory_list: "allow",
192
191
  });
193
192
  });
194
193
 
@@ -19,6 +19,15 @@ type KnownSlot = {
19
19
  * a negative cache cannot quietly become permanent.
20
20
  */
21
21
  const KNOWN_SLOTS: Record<string, KnownSlot> = {
22
+ "packages/pi-plugin/src/index.ts:databaseExitHookRegistered": {
23
+ classification: "PUBLICATION",
24
+ reason: "Correct: records that the one process-exit handler closing the shared database is installed, so /reload doesn't register a second one; it holds no failure or absence verdict.",
25
+ },
26
+ "packages/plugin/src/features/magic-context/compartment-chunk-embedding.ts:cachedCoverageWindows":
27
+ {
28
+ classification: "VERDICT",
29
+ reason: "Bounded LRU keyed by compartment id, canonical transcript content hash, chunker version, embedding model and token budget; a content or identity change cannot reuse a prior classification.",
30
+ },
22
31
  "packages/plugin/src/features/magic-context/compaction-marker.ts:cachedSchemaCompatible": {
23
32
  classification: "VERDICT",
24
33
  reason: "DEFECT: a transient PRAGMA/read failure is cached as incompatible until the writable DB is closed.",
@@ -44,6 +53,10 @@ const KNOWN_SLOTS: Record<string, KnownSlot> = {
44
53
  classification: "VERDICT",
45
54
  reason: "Correct: circuit state expires and a half-open probe re-evaluates the endpoint.",
46
55
  },
56
+ "packages/plugin/src/features/magic-context/memory/project-identity.ts:homeProjectPermission": {
57
+ classification: "VERDICT",
58
+ reason: "Boot config publishes the home-project permission; the setter replaces it on another host initialization, while explicit resolution arguments override it.",
59
+ },
47
60
  "packages/plugin/src/features/magic-context/memory/project-identity.ts:directoryFallbackCache":
48
61
  {
49
62
  classification: "VERDICT",
@@ -73,3 +73,29 @@ test("OpenCode 1 historian keeps the sampled reserve and child output cap", () =
73
73
  sampler.delete("hist-a");
74
74
  sampler.delete("hist-b");
75
75
  });
76
+
77
+ test("an unset cap leaves the host's own output limit untouched", () => {
78
+ // OpenCode computes maxOutputTokens from the model before chat.params runs.
79
+ // With no historian.maxTokens or dreamer.maxTokens configured, the hook must
80
+ // not overwrite that value with undefined.
81
+ const config = MagicContextConfigSchema.parse({});
82
+ const sampler = createDreamerOutputCapSampler(config, () => config);
83
+
84
+ const historianOutput = { maxOutputTokens: 32_000 as number | undefined };
85
+ rememberHistorianOutputCap("hist-unset", config.historian?.maxTokens);
86
+ sampler.apply({ sessionID: "hist-unset", agent: "historian" }, historianOutput);
87
+ expect(historianOutput.maxOutputTokens).toBe(32_000);
88
+
89
+ const editorOutput = { maxOutputTokens: 32_000 as number | undefined };
90
+ rememberHistorianOutputCap("editor-unset", undefined);
91
+ sampler.apply({ sessionID: "editor-unset", agent: "historian-editor" }, editorOutput);
92
+ expect(editorOutput.maxOutputTokens).toBe(32_000);
93
+
94
+ const dreamerOutput = { maxOutputTokens: 16_000 as number | undefined };
95
+ sampler.apply({ sessionID: "dream-unset", agent: "dreamer-classifier" }, dreamerOutput);
96
+ expect(dreamerOutput.maxOutputTokens).toBe(16_000);
97
+
98
+ sampler.delete("hist-unset");
99
+ sampler.delete("editor-unset");
100
+ sampler.delete("dream-unset");
101
+ });
@@ -44,9 +44,13 @@ export function createDreamerOutputCapSampler<T extends MagicContextConfig>(
44
44
  input: { sessionID: string; agent: string },
45
45
  output: { maxOutputTokens: number | undefined },
46
46
  ) {
47
+ // An unset cap must leave the host's own output limit in place. Writing
48
+ // `undefined` over it removes the limit OpenCode computed from the model,
49
+ // and some providers then send no usable max_tokens (a local Anthropic-
50
+ // compatible server answered every historian run with zero output).
47
51
  if (input.agent.startsWith("historian")) {
48
52
  const historian = historianCaps.get(input.sessionID);
49
- if (historian) output.maxOutputTokens = historian.value;
53
+ if (historian?.value !== undefined) output.maxOutputTokens = historian.value;
50
54
  return;
51
55
  }
52
56
  if (
@@ -60,7 +64,7 @@ export function createDreamerOutputCapSampler<T extends MagicContextConfig>(
60
64
  cap = { value: dreamerRunConfig(boot, fresh()).dreamer?.maxTokens };
61
65
  caps.set(input.sessionID, cap);
62
66
  }
63
- output.maxOutputTokens = cap.value;
67
+ if (cap.value !== undefined) output.maxOutputTokens = cap.value;
64
68
  },
65
69
  delete(sessionId: string) {
66
70
  caps.delete(sessionId);
@@ -484,14 +484,27 @@ const CronScheduleSchema = z
484
484
  const DreamTaskBaseConfigSchema = z
485
485
  .object({
486
486
  schedule: CronScheduleSchema.default(""),
487
+ token_budget: z
488
+ .number()
489
+ .int()
490
+ .positive()
491
+ .optional()
492
+ .describe(
493
+ "Maximum cumulative prompt tokens (input + cache read + cache write) for one tool-loop child. Defaults vary by task.",
494
+ ),
487
495
  })
488
496
  .strict();
489
497
 
498
+ export const DREAM_TASK_PROMOTION_DEFAULTS = {
499
+ "review-user-memories": 3,
500
+ "promote-primers": 2,
501
+ } as const;
502
+
490
503
  const PromotionThresholdSchema = z
491
504
  .number()
492
505
  .min(2)
493
506
  .max(20)
494
- .optional()
507
+ .default(DREAM_TASK_PROMOTION_DEFAULTS["review-user-memories"])
495
508
  .describe(
496
509
  "review-user-memories: min candidate observations before promotion is considered (default: 3)",
497
510
  );
@@ -499,7 +512,7 @@ const PrimerPromotionThresholdSchema = z
499
512
  .number()
500
513
  .min(2)
501
514
  .max(20)
502
- .optional()
515
+ .default(DREAM_TASK_PROMOTION_DEFAULTS["promote-primers"])
503
516
  .describe(
504
517
  "promote-primers: min recurring source days before promotion is considered (default: 2)",
505
518
  );
@@ -548,8 +561,10 @@ const DEFAULT_TASK_SCHEDULES: Record<DreamTaskName, string> = {
548
561
 
549
562
  function defaultTaskConfig(task: DreamTaskName): z.input<typeof DreamTaskConfigSchema> {
550
563
  const base: z.input<typeof DreamTaskConfigSchema> = { schedule: DEFAULT_TASK_SCHEDULES[task] };
551
- if (task === "review-user-memories") base.promotion_threshold = 3;
552
- if (task === "promote-primers") base.promotion_threshold = 2;
564
+ if (task === "review-user-memories")
565
+ base.promotion_threshold = DREAM_TASK_PROMOTION_DEFAULTS["review-user-memories"];
566
+ if (task === "promote-primers")
567
+ base.promotion_threshold = DREAM_TASK_PROMOTION_DEFAULTS["promote-primers"];
553
568
  return base;
554
569
  }
555
570
 
@@ -888,7 +903,7 @@ export interface MuralConfig {
888
903
 
889
904
  export interface MagicContextConfig {
890
905
  enabled: boolean;
891
- /** User-level setting that lets a session started exactly in the canonical home directory use a deterministic directory identity. */
906
+ /** User-level setting that lets a session in the canonical home directory use project memory. */
892
907
  allow_home_project: boolean;
893
908
  mural: MuralConfig;
894
909
  /** Selects the runtime implementation for this project. Rust mode is experimental and requires user-level subc configuration. */
@@ -1074,7 +1089,7 @@ export const MagicContextConfigSchema = z
1074
1089
  .boolean()
1075
1090
  .default(false)
1076
1091
  .describe(
1077
- "Allow Magic Context sessions launched from the exact canonical home directory. The home session uses its deterministic dir: identity so pre-gate memories reconnect. USER-LEVEL ONLY: project config is ignored. The home identity is excluded from registry seed exports, never resolves descendants by containment, and cannot join a workspace.",
1092
+ "Allow Magic Context sessions launched from the exact canonical home directory. A non-git home uses its deterministic dir: identity; a home repository uses its git: identity. USER-LEVEL ONLY: project config is ignored. The home identity is excluded from registry seed exports, never resolves descendants by containment, and cannot join a workspace.",
1078
1093
  ),
1079
1094
  mural: z
1080
1095
  .object({
@@ -29,6 +29,19 @@ export const CANONICAL_DREAM_TASKS = [
29
29
 
30
30
  export type DreamTaskName = (typeof CANONICAL_DREAM_TASKS)[number];
31
31
 
32
+ /** Prompt-token ceilings informed by docs/reports/dreamer-token-usage.md.
33
+ * Multi-memory batches need more room than a single primer investigation;
34
+ * curate's 150-step tool loop warrants a larger allowance too. */
35
+ export const DREAM_TOOL_LOOP_TOKEN_BUDGETS = {
36
+ "map-memories": 1_500_000,
37
+ verify: 1_700_000,
38
+ "verify-broad": 1_700_000,
39
+ curate: 1_500_000,
40
+ retrospective: 300_000,
41
+ "maintain-docs": 1_600_000,
42
+ "refresh-primers": 350_000,
43
+ } as const;
44
+
32
45
  /**
33
46
  * How a Dreamer task reaches its result, which is what decides whether a host
34
47
  * without a tool loop can run it:
@@ -29,7 +29,7 @@ const savedEnv = {
29
29
  describe("data-path", () => {
30
30
  beforeEach(() => {
31
31
  process.env.XDG_CACHE_HOME = undefined;
32
- process.env.XDG_DATA_HOME = undefined;
32
+ process.env.XDG_DATA_HOME = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
33
33
  delete process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
34
34
  delete process.env.NODE_ENV;
35
35
  process.env.LOCALAPPDATA = undefined;
@@ -189,6 +189,7 @@ async function runLoggerScenario<T>(
189
189
  const root = mkdtempSync(path.join(os.tmpdir(), "magic-context-logger-test-"));
190
190
  scenarioRoots.push(root);
191
191
  const child = Bun.spawn({
192
+ windowsHide: true,
192
193
  cmd: ["bun", "--eval", loggerScenario],
193
194
  cwd: import.meta.dir,
194
195
  env: {
@@ -1,5 +1,5 @@
1
1
  import type { createOpencodeClient } from "@opencode-ai/sdk";
2
-
2
+ import { DreamTokenBudgetExceeded } from "../features/magic-context/dreamer/token-budget";
3
3
  import { detectOverflow } from "../features/magic-context/overflow-detection";
4
4
  import { HiddenAgentStepLimit } from "../v2/hooks/hidden-child";
5
5
  import {
@@ -115,6 +115,7 @@ export type PromptFailureClass =
115
115
  | "provider_timeout"
116
116
  | "provider_error"
117
117
  | "step_limit"
118
+ | "token_budget"
118
119
  | "empty_completion"
119
120
  | "no_models"
120
121
  | "child_aborted"
@@ -351,7 +352,12 @@ async function abortChildRun(client: Client, sessionId: string): Promise<void> {
351
352
  * different model.
352
353
  */
353
354
  function isNonRetryable(error: unknown, externalSignal?: AbortSignal): boolean {
354
- if (externalSignal?.aborted || error instanceof HiddenAgentStepLimit) return true;
355
+ if (
356
+ externalSignal?.aborted ||
357
+ error instanceof HiddenAgentStepLimit ||
358
+ error instanceof DreamTokenBudgetExceeded
359
+ )
360
+ return true;
355
361
 
356
362
  if (error instanceof Error) {
357
363
  if (error.name === "AbortError") return true;
@@ -393,6 +399,7 @@ function classifyPromptFailure(
393
399
  ): PromptFailureClass {
394
400
  const message = extractMessage(error);
395
401
  if (error instanceof HiddenAgentStepLimit) return "step_limit";
402
+ if (error instanceof DreamTokenBudgetExceeded) return "token_budget";
396
403
  if (externalSignal?.aborted || message === "prompt aborted by external signal") {
397
404
  return "child_aborted";
398
405
  }
@@ -2,7 +2,14 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2
2
  import { mkdtempSync, rmSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
- import { resolveKnownHistorianContextLimit } from "../hooks/magic-context/derive-budgets";
5
+ import {
6
+ resolveHistorianProducerLimits,
7
+ resolveKnownHistorianContextLimit,
8
+ } from "../hooks/magic-context/derive-budgets";
9
+ import {
10
+ historianProducerReserve,
11
+ producerInputTokenLimit,
12
+ } from "../hooks/magic-context/producer-window-guard";
6
13
  import {
7
14
  clearModelsDevCache,
8
15
  getModelsDevCacheState,
@@ -231,6 +238,28 @@ describe("models-dev-cache (SDK-only)", () => {
231
238
  expect(getSdkContextLimit("openai", "gpt-5.4-mini")).toBe(922000);
232
239
  });
233
240
 
241
+ test("issue 567: production resolver keeps input cap separate from context reserve", async () => {
242
+ await refreshModelLimitsFromApi(
243
+ makeClient([
244
+ {
245
+ id: "auth-provider",
246
+ models: {
247
+ model: { limit: { context: 400_000, input: 272_000, output: 128_000 } },
248
+ },
249
+ },
250
+ ]),
251
+ );
252
+ const resolved = getSdkContextLimit("auth-provider", "model", undefined, {
253
+ reservation: "none",
254
+ });
255
+ const limits = resolveHistorianProducerLimits("auth-provider/model");
256
+ const reserve = historianProducerReserve(limits.context, undefined, 128_000);
257
+ expect(resolved).toBe(272_000);
258
+ expect(limits).toEqual({ context: 400_000, input: 272_000 });
259
+ expect(reserve).toBe(100_000);
260
+ expect(producerInputTokenLimit(limits.context, reserve, limits.input)).toBe(263_840);
261
+ });
262
+
234
263
  test("explicit SDK-resolved config limit wins over a larger catalog or detected value", async () => {
235
264
  // OpenCode's config.providers() has already applied opencode.json over its
236
265
  // catalog. The cache must preserve that 120K effective value, and a later