@wolfx/opencode-magic-context 0.21.8-patch.8 → 0.22.1-patch.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 (220) hide show
  1. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  2. package/dist/agents/permissions.d.ts +29 -14
  3. package/dist/agents/permissions.d.ts.map +1 -1
  4. package/dist/config/index.d.ts.map +1 -1
  5. package/dist/config/migrate-experimental.d.ts +30 -0
  6. package/dist/config/migrate-experimental.d.ts.map +1 -0
  7. package/dist/config/schema/agent-overrides.d.ts.map +1 -1
  8. package/dist/config/schema/magic-context.d.ts +110 -118
  9. package/dist/config/schema/magic-context.d.ts.map +1 -1
  10. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  11. package/dist/features/magic-context/compartment-embedding.d.ts +34 -0
  12. package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -0
  13. package/dist/features/magic-context/compartment-events.d.ts +50 -0
  14. package/dist/features/magic-context/compartment-events.d.ts.map +1 -0
  15. package/dist/features/magic-context/compartment-storage.d.ts +22 -0
  16. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/queue.d.ts +13 -2
  19. package/dist/features/magic-context/dreamer/queue.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/runner.d.ts +11 -0
  21. package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -1
  23. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  24. package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -1
  25. package/dist/features/magic-context/key-files/identify-key-files.d.ts +1 -1
  26. package/dist/features/magic-context/key-files/identify-key-files.d.ts.map +1 -1
  27. package/dist/features/magic-context/key-files/project-key-files.d.ts.map +1 -1
  28. package/dist/features/magic-context/key-files/read-stats.d.ts +1 -1
  29. package/dist/features/magic-context/key-files/read-stats.d.ts.map +1 -1
  30. package/dist/features/magic-context/memory/constants.d.ts +4 -0
  31. package/dist/features/magic-context/memory/constants.d.ts.map +1 -1
  32. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  33. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  34. package/dist/features/magic-context/memory/embedding-openai.d.ts +6 -0
  35. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  36. package/dist/features/magic-context/memory/embedding-probe.d.ts +5 -0
  37. package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -1
  38. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  39. package/dist/features/magic-context/memory/index.d.ts +1 -1
  40. package/dist/features/magic-context/memory/index.d.ts.map +1 -1
  41. package/dist/features/magic-context/memory/memory-migration.d.ts +133 -0
  42. package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -0
  43. package/dist/features/magic-context/memory/project-identity.d.ts +38 -7
  44. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  45. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
  46. package/dist/features/magic-context/memory/storage-memory.d.ts +15 -1
  47. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
  48. package/dist/features/magic-context/memory/types.d.ts +3 -1
  49. package/dist/features/magic-context/memory/types.d.ts.map +1 -1
  50. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  51. package/dist/features/magic-context/migrations.d.ts +7 -0
  52. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  53. package/dist/features/magic-context/project-docs-hash.d.ts +6 -0
  54. package/dist/features/magic-context/project-docs-hash.d.ts.map +1 -0
  55. package/dist/features/magic-context/project-identity.d.ts +2 -0
  56. package/dist/features/magic-context/project-identity.d.ts.map +1 -0
  57. package/dist/features/magic-context/storage-db.d.ts +51 -7
  58. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  59. package/dist/features/magic-context/storage-historian-runs.d.ts +73 -0
  60. package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -0
  61. package/dist/features/magic-context/storage-identity-rekey-map.d.ts +11 -0
  62. package/dist/features/magic-context/storage-identity-rekey-map.d.ts.map +1 -0
  63. package/dist/features/magic-context/storage-m0-mutation-log.d.ts +22 -0
  64. package/dist/features/magic-context/storage-m0-mutation-log.d.ts.map +1 -0
  65. package/dist/features/magic-context/storage-memory-mutation-log.d.ts +25 -0
  66. package/dist/features/magic-context/storage-memory-mutation-log.d.ts.map +1 -0
  67. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  68. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  69. package/dist/features/magic-context/storage-meta-shared.d.ts +44 -0
  70. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  71. package/dist/features/magic-context/storage-meta.d.ts +1 -0
  72. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  73. package/dist/features/magic-context/storage-project-state.d.ts +19 -0
  74. package/dist/features/magic-context/storage-project-state.d.ts.map +1 -0
  75. package/dist/features/magic-context/storage-subagent-invocations.d.ts +9 -0
  76. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  77. package/dist/features/magic-context/storage-tags.d.ts +21 -1
  78. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  79. package/dist/features/magic-context/storage-v22-backfill-failures.d.ts +24 -0
  80. package/dist/features/magic-context/storage-v22-backfill-failures.d.ts.map +1 -0
  81. package/dist/features/magic-context/storage.d.ts +12 -3
  82. package/dist/features/magic-context/storage.d.ts.map +1 -1
  83. package/dist/features/magic-context/subagent-token-capture.d.ts +1 -1
  84. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  85. package/dist/features/magic-context/tagger.d.ts +15 -1
  86. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  87. package/dist/features/magic-context/types.d.ts +21 -0
  88. package/dist/features/magic-context/types.d.ts.map +1 -1
  89. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  90. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  91. package/dist/features/magic-context/v22-deferred-backfill.d.ts +46 -0
  92. package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -0
  93. package/dist/features/magic-context/work-metrics.d.ts +66 -0
  94. package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/cache-busting-signals.d.ts +9 -0
  96. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/command-handler.d.ts +13 -1
  98. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/compartment-parser.d.ts +25 -0
  100. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
  101. package/dist/hooks/magic-context/compartment-prompt.d.ts +27 -16
  102. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  104. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts +6 -2
  105. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts.map +1 -1
  106. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +9 -1
  108. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  109. package/dist/hooks/magic-context/compartment-runner-types.d.ts +67 -4
  110. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  111. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  113. package/dist/hooks/magic-context/decay-curve.d.ts +78 -0
  114. package/dist/hooks/magic-context/decay-curve.d.ts.map +1 -0
  115. package/dist/hooks/magic-context/decay-render.d.ts +67 -0
  116. package/dist/hooks/magic-context/decay-render.d.ts.map +1 -0
  117. package/dist/hooks/magic-context/event-handler.d.ts +1 -1
  118. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  119. package/dist/hooks/magic-context/event-resolvers.d.ts +17 -0
  120. package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
  121. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  122. package/dist/hooks/magic-context/historian-prompt.generated.d.ts +2 -0
  123. package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -0
  124. package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
  125. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  126. package/dist/hooks/magic-context/hook.d.ts +12 -22
  127. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  128. package/dist/hooks/magic-context/inject-compartments.d.ts +126 -0
  129. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  130. package/dist/hooks/magic-context/key-files-block.d.ts.map +1 -1
  131. package/dist/hooks/magic-context/live-session-state.d.ts +9 -0
  132. package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/m0-token-breakdown.d.ts +35 -0
  134. package/dist/hooks/magic-context/m0-token-breakdown.d.ts.map +1 -0
  135. package/dist/hooks/magic-context/read-session-chunk.d.ts +9 -0
  136. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  137. package/dist/hooks/magic-context/read-session-db.d.ts +7 -0
  138. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  139. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +104 -0
  140. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -0
  141. package/dist/hooks/magic-context/reference-retrieval.d.ts +61 -0
  142. package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -0
  143. package/dist/hooks/magic-context/reference-seeds.generated.d.ts +8 -0
  144. package/dist/hooks/magic-context/reference-seeds.generated.d.ts.map +1 -0
  145. package/dist/hooks/magic-context/send-session-notification.d.ts +1 -1
  146. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  147. package/dist/hooks/magic-context/system-prompt-hash.d.ts +5 -6
  148. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  149. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  150. package/dist/hooks/magic-context/tokenizer-calibration.d.ts +6 -0
  151. package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -1
  152. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +0 -7
  153. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  154. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +18 -0
  155. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  156. package/dist/hooks/magic-context/transform.d.ts +9 -7
  157. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  158. package/dist/hooks/magic-context/upgrade-reminder.d.ts +73 -0
  159. package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +1 -0
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.js +9378 -3950
  162. package/dist/plugin/conflict-warning-hook.d.ts +13 -0
  163. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
  164. package/dist/plugin/dream-timer.d.ts.map +1 -1
  165. package/dist/plugin/event.d.ts +10 -0
  166. package/dist/plugin/event.d.ts.map +1 -1
  167. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  168. package/dist/plugin/messages-transform.d.ts.map +1 -1
  169. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  170. package/dist/plugin/tool-registry.d.ts.map +1 -1
  171. package/dist/shared/announcement.d.ts +17 -1
  172. package/dist/shared/announcement.d.ts.map +1 -1
  173. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  174. package/dist/shared/rpc-client.d.ts +1 -0
  175. package/dist/shared/rpc-client.d.ts.map +1 -1
  176. package/dist/shared/rpc-notifications.d.ts +27 -5
  177. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  178. package/dist/shared/rpc-server.d.ts +1 -0
  179. package/dist/shared/rpc-server.d.ts.map +1 -1
  180. package/dist/shared/rpc-types.d.ts +30 -2
  181. package/dist/shared/rpc-types.d.ts.map +1 -1
  182. package/dist/shared/rpc-utils.d.ts +9 -0
  183. package/dist/shared/rpc-utils.d.ts.map +1 -1
  184. package/dist/shared/sqlite-helpers.d.ts +7 -7
  185. package/dist/shared/sqlite.d.ts +23 -14
  186. package/dist/shared/sqlite.d.ts.map +1 -1
  187. package/dist/shared/tag-transcript.d.ts +10 -1
  188. package/dist/shared/tag-transcript.d.ts.map +1 -1
  189. package/dist/tools/ctx-expand/tools.d.ts +5 -1
  190. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  191. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  192. package/dist/tui/data/context-db.d.ts +16 -1
  193. package/dist/tui/data/context-db.d.ts.map +1 -1
  194. package/package.json +2 -3
  195. package/src/shared/announcement.test.ts +23 -7
  196. package/src/shared/announcement.ts +30 -8
  197. package/src/shared/conflict-detector.test.ts +15 -2
  198. package/src/shared/conflict-fixer.test.ts +5 -1
  199. package/src/shared/models-dev-cache.test.ts +72 -4
  200. package/src/shared/models-dev-cache.ts +47 -8
  201. package/src/shared/opencode-compaction-detector.test.ts +10 -2
  202. package/src/shared/rpc-client.test.ts +54 -3
  203. package/src/shared/rpc-client.ts +19 -9
  204. package/src/shared/rpc-notifications.test.ts +54 -1
  205. package/src/shared/rpc-notifications.ts +82 -13
  206. package/src/shared/rpc-server.ts +33 -4
  207. package/src/shared/rpc-types.ts +30 -2
  208. package/src/shared/rpc-utils.ts +10 -0
  209. package/src/shared/sqlite-helpers.ts +9 -9
  210. package/src/shared/sqlite.ts +99 -80
  211. package/src/shared/tag-transcript.test.ts +280 -0
  212. package/src/shared/tag-transcript.ts +162 -33
  213. package/src/tui/data/context-db.ts +75 -11
  214. package/src/tui/index.tsx +223 -32
  215. package/src/tui/slots/sidebar-content.tsx +366 -34
  216. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts +0 -87
  217. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +0 -1
  218. package/dist/shared/native-binding.d.ts +0 -87
  219. package/dist/shared/native-binding.d.ts.map +0 -1
  220. package/src/shared/native-binding.ts +0 -311
@@ -1 +1 @@
1
- {"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAmFxE,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,aAAa,EAAE,MAAM,EACrB,gBAAgB,UAAO,EACvB,cAAc,UAAQ,EACtB,iBAAiB,UAAO,EACxB,wBAAwB,UAAQ,EAChC,6BAA6B,UAAQ,GACtC,MAAM,CAiBR"}
1
+ {"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA,wEAAwE;AA+GxE,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,aAAa,EAAE,MAAM,EACrB,gBAAgB,UAAO,EACvB,cAAc,UAAQ,EACtB,iBAAiB,UAAO,EACxB,wBAAwB,UAAQ,EAChC,6BAA6B,UAAQ,GACtC,MAAM,CAiBR"}
@@ -40,16 +40,17 @@
40
40
  * # What each agent needs
41
41
  *
42
42
  * - **historian / historian-editor / compressor**: `read` plus the
43
- * read-only AFT navigation tools `aft_outline` and `aft_zoom`.
44
- * The runner offloads large existing-state XML to a temp file
45
- * under `<project>/.magic-context/historian/` and the
46
- * prompt instructs the model to read that file. AFT navigation
47
- * is allowed so historian can verify a symbol or file structure
48
- * when writing accurate compartment summaries.
49
- *
50
- * - **dreamer**: `read`, `grep`, `glob`, `bash`, the read-only AFT
51
- * navigation tools `aft_outline` and `aft_zoom`, plus the Magic
52
- * Context MCP tools `ctx_memory`, `ctx_search`, `ctx_note`.
43
+ * read-only AFT navigation/search tools `aft_outline`, `aft_zoom`,
44
+ * and `aft_search`. The runner offloads large existing-state XML to
45
+ * a temp file under `<project>/.magic-context/historian/`
46
+ * and the prompt instructs the model to read that file. AFT
47
+ * navigation is allowed so historian can find or verify a symbol or
48
+ * file structure when writing accurate compartment summaries.
49
+ *
50
+ * - **dreamer**: `read`, `grep`, `glob`, `bash`, `write`, `edit`, the
51
+ * read-only AFT navigation/search tools `aft_outline`, `aft_zoom`,
52
+ * `aft_search`, plus the Magic Context MCP tools `ctx_memory`,
53
+ * `ctx_search`, `ctx_note`.
53
54
  * Dreamer task prompts in
54
55
  * `features/magic-context/dreamer/task-prompts.ts` explicitly tell
55
56
  * the model to grep schema files for defaults, read source to
@@ -95,7 +96,7 @@ export declare function buildAllowOnlyPermission(allowedTools: readonly string[]
95
96
  * websearch. Historian's job is summarizing the input it was given,
96
97
  * not exploring the repo.
97
98
  */
98
- export declare const HISTORIAN_ALLOWED_TOOLS: readonly ["read", "aft_outline", "aft_zoom"];
99
+ export declare const HISTORIAN_ALLOWED_TOOLS: readonly ["read", "aft_outline", "aft_zoom", "aft_search"];
99
100
  /**
100
101
  * Tools the dreamer agent needs. This is the broadest hidden-agent
101
102
  * surface because dreamer's tasks legitimately require local-repo
@@ -116,15 +117,29 @@ export declare const HISTORIAN_ALLOWED_TOOLS: readonly ["read", "aft_outline", "
116
117
  * consolidate / verify / improve / archive-stale / smart-notes
117
118
  * dreamer child sessions, so removing it would regress real,
118
119
  * documented dreamer behavior.
120
+ * - `write` / `edit` — the maintain-docs task (`task-prompts.ts`)
121
+ * explicitly instructs the model to "Write or update using the
122
+ * Write tool" to keep `ARCHITECTURE.md` / `STRUCTURE.md` at the
123
+ * project root synchronized. Without these tools the dreamer was
124
+ * forced to emit docs through `bash` heredocs/`sed` — fragile and
125
+ * hard to review. Granting `write` + `edit` lets it use the proper
126
+ * file tools (which back up + validate) instead.
127
+ * - `aft_search` — primary read-only code search for the verify /
128
+ * improve / maintain-docs tasks; finds the symbols and call sites a
129
+ * doc/memory rewrite must describe, more precisely than raw `grep`.
119
130
  *
120
131
  * Deliberately NOT allowed:
121
132
  * - `task` — no subagent fanout from dreamer
122
- * - `edit` / `write` — dreamer must not modify project files;
123
- * `task-prompts.ts` explicitly states "Do not commit changes"
124
133
  * - `webfetch` / `websearch` — out of scope; smart-note URL fetches
125
134
  * go through `bash` + `curl` instead
135
+ *
136
+ * Note: `write` / `edit` grant general file-write capability (the
137
+ * permission gate is tool-level, not path-level). Dreamer is a trusted
138
+ * hidden agent whose prompts scope writes to docs + memory; the
139
+ * task-prompts still say "Do not commit changes," so it edits the
140
+ * working tree but never commits.
126
141
  */
127
- export declare const DREAMER_ALLOWED_TOOLS: readonly ["read", "grep", "glob", "bash", "aft_outline", "aft_zoom", "ctx_memory", "ctx_search", "ctx_note"];
142
+ export declare const DREAMER_ALLOWED_TOOLS: readonly ["read", "grep", "glob", "bash", "write", "edit", "aft_outline", "aft_zoom", "aft_search", "ctx_memory", "ctx_search", "ctx_note"];
128
143
  /**
129
144
  * Tools the sidekick agent needs. Sidekick is a read-only memory
130
145
  * retriever for `/ctx-aug` — it queries the project's memory store
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/agents/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACpC,YAAY,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAMlC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,8CAA+C,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,qBAAqB,8GAUxB,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,kEAKzB,CAAC"}
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/agents/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACpC,YAAY,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAMlC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,4DAA6D,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,qBAAqB,6IAaxB,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,kEAKzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,wBAAwB,CAAC;AAG3F,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAChE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CACZ,MAAM,EACN;QACI,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACrB,CACJ,CAAC;CACL;AAmBD,MAAM,MAAM,WAAW,GACjB,IAAI,GACJ,0BAA0B,GAC1B,uBAAuB,GACvB,iBAAiB,GACjB,sBAAsB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,wBAAwB,GAAG;QAAE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,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B,OAAO,EAAE;QACL,UAAU,EAAE,WAAW,CAAC;QACxB,aAAa,EAAE,WAAW,CAAC;KAC9B,CAAC;IACF,oBAAoB,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9F,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACnC;AAoQD,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,GAClB,wBAAwB,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CA2D1D;AAgDD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,CA4D9E"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Startup-time shim for graduated experimental features (shared OpenCode + Pi).
3
+ *
4
+ * Features have graduated out of the `experimental.*` namespace across releases:
5
+ * - v0.14: `experimental.user_memories` / `experimental.pin_key_files` →
6
+ * `dreamer.user_memories` / `dreamer.pin_key_files`.
7
+ * - this release: `experimental.temporal_awareness` / `caveman_text_compression`
8
+ * → top-level keys; `experimental.auto_search` / `git_commit_indexing` →
9
+ * `memory.auto_search` / `memory.git_commit_indexing`.
10
+ * - fork: `experimental.text_complete_strip` → top-level `text_complete_strip`.
11
+ *
12
+ * Doctor runs an on-disk migration, but users who never run doctor would
13
+ * otherwise lose their opt-in/opt-out because the graduated keys are no longer
14
+ * in the schema — Zod silently strips unknown keys. This shim runs in-memory on
15
+ * every load: if the user has legacy `experimental.<graduated-key>` blocks, it
16
+ * reshapes the raw config so the new schema sees them at their graduated path.
17
+ * The on-disk file stays untouched (doctor is the tool that cleans it up), and
18
+ * the user's explicit intent is preserved for this session's runtime behavior.
19
+ *
20
+ * Primitive values (e.g., `experimental.user_memories: true`) are coerced to
21
+ * `{ enabled: <bool> }` object form so Zod accepts them. Without this coercion,
22
+ * the primitive would fail schema validation and fall back to the graduated
23
+ * default — silently flipping a user's explicit `false` to the new `true`
24
+ * default, or vice versa.
25
+ *
26
+ * Idempotent: if the destination path already has a value, the destination wins
27
+ * (the user has started graduating), merging sub-fields so nothing is lost.
28
+ */
29
+ export declare function migrateLegacyExperimental(rawConfig: Record<string, unknown>, warnings: string[]): Record<string, unknown>;
30
+ //# sourceMappingURL=migrate-experimental.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-experimental.d.ts","sourceRoot":"","sources":["../../src/config/migrate-experimental.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,yBAAyB,CACrC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,EAAE,MAAM,EAAE,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkIzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-overrides.d.ts","sourceRoot":"","sources":["../../../src/config/schema/agent-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iCAAiC,+CAAgD,CAAC;AAgB/F,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkBpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"agent-overrides.d.ts","sourceRoot":"","sources":["../../../src/config/schema/agent-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iCAAiC,+CAAgD,CAAC;AAgB/F,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC"}
@@ -1,23 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export declare const DEFAULT_NUDGE_INTERVAL_TOKENS = 10000;
3
3
  export declare const DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE = 65;
4
+ export declare const EXECUTE_THRESHOLD_CAP_MESSAGE = "execute_threshold is capped at 80% for cache safety: a single large agent step can overflow the context window before Magic Context can compact between turns, forcing OpenCode's native compaction (hard to recover from). 80% also leaves headroom below the 85%/95% emergency bands. Use a value between 20 and 80.";
4
5
  export declare const DEFAULT_HISTORIAN_TIMEOUT_MS = 300000;
5
6
  export declare const DEFAULT_HISTORY_BUDGET_PERCENTAGE = 0.15;
6
7
  export declare const DEFAULT_LOCAL_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2";
7
- /** Compressor defaults — see CompressorConfigSchema below for details. */
8
- export declare const DEFAULT_COMPRESSOR_MIN_COMPARTMENT_RATIO = 1000;
9
- export declare const DEFAULT_COMPRESSOR_MAX_MERGE_DEPTH = 5;
10
- export declare const DEFAULT_COMPRESSOR_COOLDOWN_MS = 600000;
11
- /** Max compartments merged in one LLM pass. LLM quality degrades with larger inputs,
12
- * and smaller batches reduce ordinal-drift risk when the model outputs merged boundaries. */
13
- export declare const DEFAULT_COMPRESSOR_MAX_COMPARTMENTS_PER_PASS = 15;
14
- /** Number of newest compartments always excluded from compression.
15
- * Protects freshly-published historian compartments from immediate re-compression,
16
- * which would lose narrative quality before the agent has even used the compartment. */
17
- export declare const DEFAULT_COMPRESSOR_GRACE_COMPARTMENTS = 10;
18
- /** Output count at each depth = ceil(input / ratio).
19
- * Lower ratios = gentler compression. Depth 5 is title-only (no LLM call). */
20
- export declare const COMPRESSOR_MERGE_RATIO_BY_DEPTH: Record<number, number>;
21
8
  export declare const DREAMER_TASKS: readonly ["consolidate", "verify", "archive-stale", "improve", "maintain-docs"];
22
9
  export declare const DreamingTaskSchema: z.ZodEnum<{
23
10
  consolidate: "consolidate";
@@ -255,10 +242,14 @@ export declare const EmbeddingConfigSchema: z.ZodPipe<z.ZodObject<{
255
242
  model: z.ZodOptional<z.ZodString>;
256
243
  endpoint: z.ZodOptional<z.ZodString>;
257
244
  api_key: z.ZodOptional<z.ZodString>;
245
+ input_type: z.ZodOptional<z.ZodString>;
246
+ truncate: z.ZodOptional<z.ZodString>;
258
247
  }, z.core.$strip>, z.ZodTransform<{
259
248
  provider: "local";
260
249
  model: string;
261
250
  } | {
251
+ truncate?: string | undefined;
252
+ input_type?: string | undefined;
262
253
  api_key?: string | undefined;
263
254
  provider: "openai-compatible";
264
255
  model: string;
@@ -271,6 +262,8 @@ export declare const EmbeddingConfigSchema: z.ZodPipe<z.ZodObject<{
271
262
  model?: string | undefined;
272
263
  endpoint?: string | undefined;
273
264
  api_key?: string | undefined;
265
+ input_type?: string | undefined;
266
+ truncate?: string | undefined;
274
267
  }>>;
275
268
  export type EmbeddingConfig = z.infer<typeof EmbeddingConfigSchema>;
276
269
  export interface MagicContextConfig {
@@ -308,6 +301,11 @@ export interface MagicContextConfig {
308
301
  enabled: boolean;
309
302
  min_clusters: number;
310
303
  };
304
+ /** Per-connection SQLite tuning for Magic Context's own context.db. */
305
+ sqlite: {
306
+ cache_size_mb: number;
307
+ mmap_size_mb: number;
308
+ };
311
309
  /**
312
310
  * Controls whether and where Magic Context augments the system prompt
313
311
  * (`## Magic Context` guidance, `<project-docs>`, `<user-profile>`,
@@ -329,32 +327,49 @@ export interface MagicContextConfig {
329
327
  */
330
328
  skip_signatures: string[];
331
329
  };
332
- compressor: {
330
+ /** Inject elapsed-time markers between user messages and date ranges on
331
+ * compartments so the agent has a wall-clock sense of the session.
332
+ * Graduated from `experimental.temporal_awareness`; default: true. */
333
+ temporal_awareness: boolean;
334
+ /**
335
+ * Age-tier caveman compression for long user/assistant text parts.
336
+ * Graduated from `experimental.caveman_text_compression`; opt-in, default off.
337
+ *
338
+ * Only active when `ctx_reduce_enabled: false`. Buckets eligible
339
+ * (outside-protected-tail) messages into four age tiers by tag
340
+ * position — oldest 20% → ultra, next 20% → full, next 20% → lite,
341
+ * newest 40% → untouched — and rewrites the text part in place.
342
+ * Always compresses from the original source (source_contents), so
343
+ * tier shifts produce the same result as if the target depth were
344
+ * applied directly to the original text.
345
+ *
346
+ * Disabled by default because it rewrites agent-visible history.
347
+ */
348
+ caveman_text_compression: {
333
349
  enabled: boolean;
334
- min_compartment_ratio: number;
335
- max_merge_depth: number;
336
- cooldown_ms: number;
337
- max_compartments_per_pass: number;
338
- grace_compartments: number;
350
+ /** Text parts shorter than this (characters) are left untouched. */
351
+ min_chars: number;
339
352
  };
340
- experimental: {
341
- /** Inject elapsed-time markers between user messages and date ranges on
342
- * compartments so the agent has a wall-clock sense of the session. */
343
- temporal_awareness: boolean;
344
- /** Index git commit messages from HEAD into a new ctx_search source so
345
- * agents can recall recent regressions, fixes, and decisions from
346
- * commit history without running git log manually. */
347
- git_commit_indexing: {
348
- enabled: boolean;
349
- /** Days of history to index (default: 365) */
350
- since_days: number;
351
- /** Max commits kept per project; oldest evicted (default: 2000) */
352
- max_commits: number;
353
- };
353
+ /** Custom leading prefix strip patterns for text-complete handler.
354
+ * When configured, overrides the built-in §N§/§N° patterns entirely.
355
+ * Falls back to built-in defaults when omitted. */
356
+ text_complete_strip?: {
357
+ enabled: boolean;
358
+ patterns?: string[];
359
+ };
360
+ embedding: EmbeddingConfig;
361
+ memory: {
362
+ enabled: boolean;
363
+ injection_budget_tokens: number;
364
+ auto_promote: boolean;
365
+ retrieval_count_promotion_threshold: number;
354
366
  /** Appends a compact hint to new user messages when ctx_search finds
355
- * highly-related memories, facts, or git commits. Does NOT inject
356
- * full content — just vague fragments that nudge the agent to run
357
- * ctx_search for full context if relevant. */
367
+ * highly-related memories, conversation, or git commits. Does NOT
368
+ * inject full content — just vague fragments that nudge the agent to
369
+ * run ctx_search for full context if relevant. Graduated from
370
+ * `experimental.auto_search`; enabled by default. Independent of
371
+ * `memory.enabled` — it can still surface conversation/git hints when
372
+ * the memory store is off. */
358
373
  auto_search: {
359
374
  enabled: boolean;
360
375
  /** Top hit score must exceed this threshold for the hint to fire. */
@@ -362,38 +377,19 @@ export interface MagicContextConfig {
362
377
  /** Minimum user message length in characters (skip short prompts). */
363
378
  min_prompt_chars: number;
364
379
  };
365
- /** Custom leading prefix strip patterns for text-complete handler.
366
- * When configured, overrides the built-in §N§/§N° patterns entirely. */
367
- text_complete_strip?: {
368
- enabled: boolean;
369
- patterns?: string[];
370
- };
371
- /**
372
- * Age-tier caveman compression for long user/assistant text parts.
373
- *
374
- * Only active when `ctx_reduce_enabled: false`. Buckets eligible
375
- * (outside-protected-tail) messages into four age tiers by tag
376
- * position — oldest 20% → ultra, next 20% → full, next 20% → lite,
377
- * newest 40% → untouched — and rewrites the text part in place.
378
- * Always compresses from the original source (source_contents), so
379
- * tier shifts produce the same result as if the target depth were
380
- * applied directly to the original text.
381
- *
382
- * Disabled by default because it rewrites agent-visible history.
383
- */
384
- caveman_text_compression: {
380
+ /** Index git commit messages from HEAD into a new ctx_search source so
381
+ * agents can recall recent regressions, fixes, and decisions from
382
+ * commit history without running git log manually. Graduated from
383
+ * `experimental.git_commit_indexing`; opt-in, default off. Independent
384
+ * of `memory.enabled`. */
385
+ git_commit_indexing: {
385
386
  enabled: boolean;
386
- /** Text parts shorter than this (characters) are left untouched. */
387
- min_chars: number;
387
+ /** Days of history to index (default: 365) */
388
+ since_days: number;
389
+ /** Max commits kept per project; oldest evicted (default: 2000) */
390
+ max_commits: number;
388
391
  };
389
392
  };
390
- embedding: EmbeddingConfig;
391
- memory: {
392
- enabled: boolean;
393
- injection_budget_tokens: number;
394
- auto_promote: boolean;
395
- retrieval_count_promotion_threshold: number;
396
- };
397
393
  sidekick?: SidekickConfig;
398
394
  }
399
395
  export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
@@ -561,13 +557,9 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
561
557
  enabled: z.ZodDefault<z.ZodBoolean>;
562
558
  skip_signatures: z.ZodDefault<z.ZodArray<z.ZodString>>;
563
559
  }, z.core.$strip>>;
564
- compressor: z.ZodDefault<z.ZodObject<{
565
- enabled: z.ZodDefault<z.ZodBoolean>;
566
- min_compartment_ratio: z.ZodDefault<z.ZodNumber>;
567
- max_merge_depth: z.ZodDefault<z.ZodNumber>;
568
- cooldown_ms: z.ZodDefault<z.ZodNumber>;
569
- max_compartments_per_pass: z.ZodDefault<z.ZodNumber>;
570
- grace_compartments: z.ZodDefault<z.ZodNumber>;
560
+ sqlite: z.ZodDefault<z.ZodObject<{
561
+ cache_size_mb: z.ZodDefault<z.ZodNumber>;
562
+ mmap_size_mb: z.ZodDefault<z.ZodNumber>;
571
563
  }, z.core.$strip>>;
572
564
  embedding: z.ZodDefault<z.ZodPipe<z.ZodObject<{
573
565
  provider: z.ZodDefault<z.ZodEnum<{
@@ -578,10 +570,14 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
578
570
  model: z.ZodOptional<z.ZodString>;
579
571
  endpoint: z.ZodOptional<z.ZodString>;
580
572
  api_key: z.ZodOptional<z.ZodString>;
573
+ input_type: z.ZodOptional<z.ZodString>;
574
+ truncate: z.ZodOptional<z.ZodString>;
581
575
  }, z.core.$strip>, z.ZodTransform<{
582
576
  provider: "local";
583
577
  model: string;
584
578
  } | {
579
+ truncate?: string | undefined;
580
+ input_type?: string | undefined;
585
581
  api_key?: string | undefined;
586
582
  provider: "openai-compatible";
587
583
  model: string;
@@ -594,34 +590,34 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
594
590
  model?: string | undefined;
595
591
  endpoint?: string | undefined;
596
592
  api_key?: string | undefined;
593
+ input_type?: string | undefined;
594
+ truncate?: string | undefined;
597
595
  }>>>;
598
- experimental: z.ZodDefault<z.ZodObject<{
599
- temporal_awareness: z.ZodDefault<z.ZodBoolean>;
600
- git_commit_indexing: z.ZodDefault<z.ZodObject<{
601
- enabled: z.ZodDefault<z.ZodBoolean>;
602
- since_days: z.ZodDefault<z.ZodNumber>;
603
- max_commits: z.ZodDefault<z.ZodNumber>;
604
- }, z.core.$strip>>;
596
+ temporal_awareness: z.ZodDefault<z.ZodBoolean>;
597
+ caveman_text_compression: z.ZodDefault<z.ZodObject<{
598
+ enabled: z.ZodDefault<z.ZodBoolean>;
599
+ min_chars: z.ZodDefault<z.ZodNumber>;
600
+ }, z.core.$strip>>;
601
+ text_complete_strip: z.ZodOptional<z.ZodObject<{
602
+ enabled: z.ZodDefault<z.ZodBoolean>;
603
+ patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
604
+ }, z.core.$strip>>;
605
+ memory: z.ZodDefault<z.ZodObject<{
606
+ enabled: z.ZodDefault<z.ZodBoolean>;
607
+ injection_budget_tokens: z.ZodDefault<z.ZodNumber>;
608
+ auto_promote: z.ZodDefault<z.ZodBoolean>;
609
+ retrieval_count_promotion_threshold: z.ZodDefault<z.ZodNumber>;
605
610
  auto_search: z.ZodDefault<z.ZodObject<{
606
611
  enabled: z.ZodDefault<z.ZodBoolean>;
607
612
  score_threshold: z.ZodDefault<z.ZodNumber>;
608
613
  min_prompt_chars: z.ZodDefault<z.ZodNumber>;
609
614
  }, z.core.$strip>>;
610
- text_complete_strip: z.ZodOptional<z.ZodObject<{
611
- enabled: z.ZodDefault<z.ZodBoolean>;
612
- patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
613
- }, z.core.$strip>>;
614
- caveman_text_compression: z.ZodDefault<z.ZodObject<{
615
+ git_commit_indexing: z.ZodDefault<z.ZodObject<{
615
616
  enabled: z.ZodDefault<z.ZodBoolean>;
616
- min_chars: z.ZodDefault<z.ZodNumber>;
617
+ since_days: z.ZodDefault<z.ZodNumber>;
618
+ max_commits: z.ZodDefault<z.ZodNumber>;
617
619
  }, z.core.$strip>>;
618
620
  }, z.core.$strip>>;
619
- memory: z.ZodDefault<z.ZodObject<{
620
- enabled: z.ZodDefault<z.ZodBoolean>;
621
- injection_budget_tokens: z.ZodDefault<z.ZodNumber>;
622
- auto_promote: z.ZodDefault<z.ZodBoolean>;
623
- retrieval_count_promotion_threshold: z.ZodDefault<z.ZodNumber>;
624
- }, z.core.$strip>>;
625
621
  sidekick: z.ZodOptional<z.ZodObject<{
626
622
  model: z.ZodOptional<z.ZodString>;
627
623
  temperature: z.ZodOptional<z.ZodNumber>;
@@ -708,18 +704,16 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
708
704
  enabled: boolean;
709
705
  skip_signatures: string[];
710
706
  };
711
- compressor: {
712
- enabled: boolean;
713
- min_compartment_ratio: number;
714
- max_merge_depth: number;
715
- cooldown_ms: number;
716
- max_compartments_per_pass: number;
717
- grace_compartments: number;
707
+ sqlite: {
708
+ cache_size_mb: number;
709
+ mmap_size_mb: number;
718
710
  };
719
711
  embedding: {
720
712
  provider: "local";
721
713
  model: string;
722
714
  } | {
715
+ truncate?: string | undefined;
716
+ input_type?: string | undefined;
723
717
  api_key?: string | undefined;
724
718
  provider: "openai-compatible";
725
719
  model: string;
@@ -728,32 +722,26 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
728
722
  provider: "off";
729
723
  model?: undefined;
730
724
  };
731
- experimental: {
732
- temporal_awareness: boolean;
733
- git_commit_indexing: {
734
- enabled: boolean;
735
- since_days: number;
736
- max_commits: number;
737
- };
725
+ temporal_awareness: boolean;
726
+ caveman_text_compression: {
727
+ enabled: boolean;
728
+ min_chars: number;
729
+ };
730
+ memory: {
731
+ enabled: boolean;
732
+ injection_budget_tokens: number;
733
+ auto_promote: boolean;
734
+ retrieval_count_promotion_threshold: number;
738
735
  auto_search: {
739
736
  enabled: boolean;
740
737
  score_threshold: number;
741
738
  min_prompt_chars: number;
742
739
  };
743
- caveman_text_compression: {
740
+ git_commit_indexing: {
744
741
  enabled: boolean;
745
- min_chars: number;
742
+ since_days: number;
743
+ max_commits: number;
746
744
  };
747
- text_complete_strip?: {
748
- enabled: boolean;
749
- patterns?: string[] | undefined;
750
- } | undefined;
751
- };
752
- memory: {
753
- enabled: boolean;
754
- injection_budget_tokens: number;
755
- auto_promote: boolean;
756
- retrieval_count_promotion_threshold: number;
757
745
  };
758
746
  historian?: {
759
747
  two_pass: boolean;
@@ -821,6 +809,10 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
821
809
  default?: number | undefined;
822
810
  } | undefined;
823
811
  protected_tags?: number | undefined;
812
+ text_complete_strip?: {
813
+ enabled: boolean;
814
+ patterns?: string[] | undefined;
815
+ } | undefined;
824
816
  sidekick?: {
825
817
  timeout_ms: number;
826
818
  model?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"magic-context.d.ts","sourceRoot":"","sources":["../../../src/config/schema/magic-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,6BAA6B,QAAS,CAAC;AACpD,eAAO,MAAM,oCAAoC,KAAK,CAAC;AACvD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,0EAA0E;AAC1E,eAAO,MAAM,wCAAwC,OAAO,CAAC;AAC7D,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,8BAA8B,SAAU,CAAC;AACtD;8FAC8F;AAC9F,eAAO,MAAM,4CAA4C,KAAK,CAAC;AAC/D;;yFAEyF;AACzF,eAAO,MAAM,qCAAqC,KAAK,CAAC;AACxD;+EAC+E;AAC/E,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMlE,C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,EAAE;YACjB,OAAO,EAAE,OAAO,CAAC;YACjB,8CAA8C;YAC9C,UAAU,EAAE,MAAM,CAAC;YACnB,mEAAmE;YACnE,WAAW,EAAE,MAAM,CAAC;SACvB,CAAC;KACL,CAAC;IACF,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyT/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/features/builtin-commands/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,8BAA8B,IAAI,oBAAoB,CAwBrE"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/features/builtin-commands/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,8BAA8B,IAAI,oBAAoB,CA6BrE"}
@@ -0,0 +1,34 @@
1
+ import type { Database } from "../../shared/sqlite";
2
+ /**
3
+ * Compartment P1 embedding (v2 / E2).
4
+ *
5
+ * The LOCKED substrate decision: `p1_embedding` is computed + stored on EVERY
6
+ * compartment publish, even though the historian no longer uses embedding to
7
+ * pick its own reference block (that switched to recency). The embedding exists
8
+ * for two consumers:
9
+ * - ctx_search semantic retrieval over compartments (E2 consumption),
10
+ * - future dreamer cross-compartment linking (e.g. "key-files 2 months ago
11
+ * ↔ key-files now").
12
+ *
13
+ * Fire-and-forget + best-effort, mirroring memory promotion: a missing/slow
14
+ * embedding provider must never block or fail a historian publish. Gated by the
15
+ * same `memory.enabled` / `auto_promote` flags as memory promotion (no embedding
16
+ * endpoint hits when memory is off).
17
+ */
18
+ interface CompartmentToEmbed {
19
+ id: number;
20
+ /** P1 tier text (fullest) — the embedding source. */
21
+ p1: string;
22
+ }
23
+ /**
24
+ * Embed the P1 text of the given compartments and persist each vector into
25
+ * `compartments.p1_embedding` (+ `p1_embedding_model_id`). Best-effort per row:
26
+ * one failure logs and continues. Never throws.
27
+ *
28
+ * `embedTextForProject` resolves the project's configured provider/model, so the
29
+ * stored `model_id` stays consistent with memory embeddings for the same project
30
+ * (vector compatibility for cross-corpus search later).
31
+ */
32
+ export declare function embedAndStoreCompartments(db: Database, sessionId: string, projectPath: string, compartments: readonly CompartmentToEmbed[]): Promise<void>;
33
+ export {};
34
+ //# sourceMappingURL=compartment-embedding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compartment-embedding.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/compartment-embedding.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;;;;;;;;;;GAeG;AAEH,UAAU,kBAAkB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC3C,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,SAAS,kBAAkB,EAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAqBf"}
@@ -0,0 +1,50 @@
1
+ import type { Database } from "../../shared/sqlite";
2
+ /**
3
+ * Compartment events storage (v2 / E2).
4
+ *
5
+ * The historian extracts discrete events (`causal_incident`,
6
+ * `trajectory_correction`, and any future kinds) while compartmentalizing. v2.0
7
+ * STORES these events but does NOT render them — they are a corpus for a future
8
+ * dreamer aggregation/steering feature (cross-session pattern detection). Parsed
9
+ * kind-agnostically (`kind` = element name, `fields` = child elements), so a new
10
+ * event kind or field needs no schema change — `fields` round-trips as JSON.
11
+ *
12
+ * Anchoring: `at_compartment="N"` is a 1-based index INTO THE CURRENT PUBLISH's
13
+ * emitted compartment list. We resolve it to the `compartment_id` of the matching
14
+ * persisted row at store time. When resolution fails (out-of-range index, e.g. an
15
+ * event anchored to a discard-last compartment), `compartment_id` is NULL and we
16
+ * keep the raw `at_compartment` for debugging.
17
+ *
18
+ * Durability caveat: `compartment_id` is a bare INTEGER (no FK). It points at the
19
+ * compartment row that existed at store time. Full/partial recomp deletes and
20
+ * re-inserts compartment rows, so a stored `compartment_id` can become stale
21
+ * (dangling) after recomp. This is acceptable for v2.0 because events are
22
+ * STORED-ONLY (not rendered or consumed yet); the future dreamer aggregation
23
+ * feature that reads events must re-anchor or tolerate dangling ids. Do NOT rely
24
+ * on `compartment_id` surviving recomp.
25
+ */
26
+ export interface CompartmentEventInput {
27
+ /** Event element name, e.g. "causal_incident" | "trajectory_correction". */
28
+ kind: string;
29
+ /** 1-based index into the publish's emitted compartments; null if absent/invalid. */
30
+ atCompartment: number | null;
31
+ /** Child elements verbatim (e.g. trigger, implication). */
32
+ fields: Record<string, string>;
33
+ }
34
+ export interface StoredCompartmentEvent extends CompartmentEventInput {
35
+ id: number;
36
+ sessionId: string;
37
+ compartmentId: number | null;
38
+ createdAt: number;
39
+ }
40
+ /**
41
+ * Persist historian-extracted events for a publish.
42
+ *
43
+ * @param compartmentIds durable compartment ids for the publish's emitted
44
+ * compartments, in emission order (index i → the (i+1)-th emitted compartment).
45
+ * Used to resolve `at_compartment` (1-based) to a durable `compartment_id`.
46
+ */
47
+ export declare function insertCompartmentEvents(db: Database, sessionId: string, events: readonly CompartmentEventInput[], compartmentIds: readonly number[]): void;
48
+ /** Load all stored events for a session (newest first). For diagnostics / future dreamer aggregation. */
49
+ export declare function getCompartmentEvents(db: Database, sessionId: string): StoredCompartmentEvent[];
50
+ //# sourceMappingURL=compartment-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compartment-events.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/compartment-events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,qBAAqB;IAClC,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,qBAAqB,EAAE,EACxC,cAAc,EAAE,SAAS,MAAM,EAAE,GAClC,IAAI,CAqBN;AAED,yGAAyG;AACzG,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAuB9F"}
@@ -8,7 +8,19 @@ export interface Compartment {
8
8
  startMessageId: string;
9
9
  endMessageId: string;
10
10
  title: string;
11
+ /** v2: P1 tier text (fullest). Legacy rows: flat v1 content. Always present (NOT NULL). */
11
12
  content: string;
13
+ /** v2 paraphrase tiers (model B). NULL for legacy=1 rows. */
14
+ p1: string | null;
15
+ p2: string | null;
16
+ p3: string | null;
17
+ p4: string | null;
18
+ /** Decay-rate signal (1-100). Defaults to 50. */
19
+ importance: number;
20
+ /** Comma-separated activity types (e.g. "design,feature"). NULL for legacy rows. */
21
+ episodeType: string | null;
22
+ /** 1 = pre-v2 flat compartment (no tiers); 0 = v2 tiered. */
23
+ legacy: number;
12
24
  createdAt: number;
13
25
  }
14
26
  export interface SessionFact {
@@ -26,7 +38,17 @@ export interface CompartmentInput {
26
38
  startMessageId: string;
27
39
  endMessageId: string;
28
40
  title: string;
41
+ /** v2: P1 tier text. Legacy/compressor inserts: flat content. */
29
42
  content: string;
43
+ /** v2 paraphrase tiers (model B). Omitted/null for legacy or compressor inserts → stored NULL. */
44
+ p1?: string | null;
45
+ p2?: string | null;
46
+ p3?: string | null;
47
+ p4?: string | null;
48
+ /** Decay-rate signal (1-100). Omitted → stored 50. */
49
+ importance?: number | null;
50
+ /** Comma-separated activity types. Omitted/null → stored NULL. */
51
+ episodeType?: string | null;
30
52
  }
31
53
  export declare function getCompartments(db: Database, sessionId: string): Compartment[];
32
54
  export declare function getLastCompartmentEndMessage(db: Database, sessionId: string): number;