@cortexkit/opencode-magic-context 0.21.8 → 0.22.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 (207) hide show
  1. package/README.md +116 -325
  2. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  3. package/dist/agents/permissions.d.ts +29 -14
  4. package/dist/agents/permissions.d.ts.map +1 -1
  5. package/dist/config/index.d.ts.map +1 -1
  6. package/dist/config/migrate-experimental.d.ts +29 -0
  7. package/dist/config/migrate-experimental.d.ts.map +1 -0
  8. package/dist/config/schema/magic-context.d.ts +80 -104
  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-local.d.ts.map +1 -1
  33. package/dist/features/magic-context/memory/index.d.ts +1 -1
  34. package/dist/features/magic-context/memory/index.d.ts.map +1 -1
  35. package/dist/features/magic-context/memory/memory-migration.d.ts +133 -0
  36. package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -0
  37. package/dist/features/magic-context/memory/project-identity.d.ts +38 -7
  38. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  39. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
  40. package/dist/features/magic-context/memory/storage-memory.d.ts +15 -1
  41. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
  42. package/dist/features/magic-context/memory/types.d.ts +3 -1
  43. package/dist/features/magic-context/memory/types.d.ts.map +1 -1
  44. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  45. package/dist/features/magic-context/migrations.d.ts +7 -0
  46. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  47. package/dist/features/magic-context/project-docs-hash.d.ts +6 -0
  48. package/dist/features/magic-context/project-docs-hash.d.ts.map +1 -0
  49. package/dist/features/magic-context/project-identity.d.ts +2 -0
  50. package/dist/features/magic-context/project-identity.d.ts.map +1 -0
  51. package/dist/features/magic-context/storage-db.d.ts +51 -7
  52. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  53. package/dist/features/magic-context/storage-historian-runs.d.ts +73 -0
  54. package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -0
  55. package/dist/features/magic-context/storage-identity-rekey-map.d.ts +11 -0
  56. package/dist/features/magic-context/storage-identity-rekey-map.d.ts.map +1 -0
  57. package/dist/features/magic-context/storage-m0-mutation-log.d.ts +22 -0
  58. package/dist/features/magic-context/storage-m0-mutation-log.d.ts.map +1 -0
  59. package/dist/features/magic-context/storage-memory-mutation-log.d.ts +25 -0
  60. package/dist/features/magic-context/storage-memory-mutation-log.d.ts.map +1 -0
  61. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  62. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  63. package/dist/features/magic-context/storage-meta-shared.d.ts +44 -0
  64. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  65. package/dist/features/magic-context/storage-meta.d.ts +1 -0
  66. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  67. package/dist/features/magic-context/storage-project-state.d.ts +19 -0
  68. package/dist/features/magic-context/storage-project-state.d.ts.map +1 -0
  69. package/dist/features/magic-context/storage-subagent-invocations.d.ts +9 -0
  70. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  71. package/dist/features/magic-context/storage-tags.d.ts +21 -1
  72. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  73. package/dist/features/magic-context/storage-v22-backfill-failures.d.ts +24 -0
  74. package/dist/features/magic-context/storage-v22-backfill-failures.d.ts.map +1 -0
  75. package/dist/features/magic-context/storage.d.ts +12 -3
  76. package/dist/features/magic-context/storage.d.ts.map +1 -1
  77. package/dist/features/magic-context/subagent-token-capture.d.ts +1 -1
  78. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  79. package/dist/features/magic-context/tagger.d.ts +15 -1
  80. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  81. package/dist/features/magic-context/types.d.ts +21 -0
  82. package/dist/features/magic-context/types.d.ts.map +1 -1
  83. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  84. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  85. package/dist/features/magic-context/v22-deferred-backfill.d.ts +46 -0
  86. package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -0
  87. package/dist/features/magic-context/work-metrics.d.ts +66 -0
  88. package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
  89. package/dist/hooks/auto-update-checker/cache.d.ts.map +1 -1
  90. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/cache-busting-signals.d.ts +9 -0
  92. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  93. package/dist/hooks/magic-context/command-handler.d.ts +13 -1
  94. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/compartment-parser.d.ts +25 -0
  96. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/compartment-prompt.d.ts +27 -16
  98. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  100. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts +6 -2
  101. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +9 -1
  104. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/compartment-runner-types.d.ts +67 -4
  106. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  109. package/dist/hooks/magic-context/decay-curve.d.ts +78 -0
  110. package/dist/hooks/magic-context/decay-curve.d.ts.map +1 -0
  111. package/dist/hooks/magic-context/decay-render.d.ts +67 -0
  112. package/dist/hooks/magic-context/decay-render.d.ts.map +1 -0
  113. package/dist/hooks/magic-context/event-handler.d.ts +1 -1
  114. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  115. package/dist/hooks/magic-context/event-resolvers.d.ts +17 -0
  116. package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
  117. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/historian-prompt.generated.d.ts +2 -0
  119. package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -0
  120. package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
  121. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  122. package/dist/hooks/magic-context/hook.d.ts +9 -21
  123. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  124. package/dist/hooks/magic-context/inject-compartments.d.ts +126 -0
  125. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  126. package/dist/hooks/magic-context/key-files-block.d.ts.map +1 -1
  127. package/dist/hooks/magic-context/live-session-state.d.ts +9 -0
  128. package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
  129. package/dist/hooks/magic-context/m0-token-breakdown.d.ts +35 -0
  130. package/dist/hooks/magic-context/m0-token-breakdown.d.ts.map +1 -0
  131. package/dist/hooks/magic-context/read-session-chunk.d.ts +9 -0
  132. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/read-session-db.d.ts +7 -0
  134. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +104 -0
  136. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -0
  137. package/dist/hooks/magic-context/reference-retrieval.d.ts +61 -0
  138. package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -0
  139. package/dist/hooks/magic-context/reference-seeds.generated.d.ts +8 -0
  140. package/dist/hooks/magic-context/reference-seeds.generated.d.ts.map +1 -0
  141. package/dist/hooks/magic-context/send-session-notification.d.ts +1 -1
  142. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  143. package/dist/hooks/magic-context/system-prompt-hash.d.ts +5 -6
  144. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  145. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  146. package/dist/hooks/magic-context/tokenizer-calibration.d.ts +6 -0
  147. package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -1
  148. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +0 -7
  149. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  150. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +18 -0
  151. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  152. package/dist/hooks/magic-context/transform.d.ts +9 -7
  153. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  154. package/dist/hooks/magic-context/upgrade-reminder.d.ts +73 -0
  155. package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +1 -0
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/index.js +9258 -3915
  158. package/dist/plugin/conflict-warning-hook.d.ts +13 -0
  159. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
  160. package/dist/plugin/dream-timer.d.ts.map +1 -1
  161. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  162. package/dist/plugin/messages-transform.d.ts.map +1 -1
  163. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  164. package/dist/plugin/tool-registry.d.ts.map +1 -1
  165. package/dist/shared/announcement.d.ts +1 -1
  166. package/dist/shared/announcement.d.ts.map +1 -1
  167. package/dist/shared/rpc-client.d.ts +1 -0
  168. package/dist/shared/rpc-client.d.ts.map +1 -1
  169. package/dist/shared/rpc-notifications.d.ts +27 -5
  170. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  171. package/dist/shared/rpc-server.d.ts +1 -0
  172. package/dist/shared/rpc-server.d.ts.map +1 -1
  173. package/dist/shared/rpc-types.d.ts +30 -2
  174. package/dist/shared/rpc-types.d.ts.map +1 -1
  175. package/dist/shared/rpc-utils.d.ts +9 -0
  176. package/dist/shared/rpc-utils.d.ts.map +1 -1
  177. package/dist/shared/sqlite-helpers.d.ts +7 -7
  178. package/dist/shared/sqlite.d.ts +23 -14
  179. package/dist/shared/sqlite.d.ts.map +1 -1
  180. package/dist/shared/tag-transcript.d.ts +10 -1
  181. package/dist/shared/tag-transcript.d.ts.map +1 -1
  182. package/dist/tools/ctx-expand/tools.d.ts +5 -1
  183. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  184. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  185. package/dist/tui/data/context-db.d.ts +16 -1
  186. package/dist/tui/data/context-db.d.ts.map +1 -1
  187. package/package.json +2 -4
  188. package/src/shared/announcement.ts +6 -7
  189. package/src/shared/rpc-client.test.ts +49 -2
  190. package/src/shared/rpc-client.ts +19 -9
  191. package/src/shared/rpc-notifications.test.ts +54 -1
  192. package/src/shared/rpc-notifications.ts +82 -13
  193. package/src/shared/rpc-server.ts +33 -4
  194. package/src/shared/rpc-types.ts +30 -2
  195. package/src/shared/rpc-utils.ts +10 -0
  196. package/src/shared/sqlite-helpers.ts +9 -9
  197. package/src/shared/sqlite.ts +99 -80
  198. package/src/shared/tag-transcript.test.ts +280 -0
  199. package/src/shared/tag-transcript.ts +162 -33
  200. package/src/tui/data/context-db.ts +75 -11
  201. package/src/tui/index.tsx +223 -32
  202. package/src/tui/slots/sidebar-content.tsx +366 -34
  203. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts +0 -87
  204. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +0 -1
  205. package/dist/shared/native-binding.d.ts +0 -87
  206. package/dist/shared/native-binding.d.ts.map +0 -1
  207. package/src/shared/native-binding.ts +0 -311
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  <h1 align="center">Magic Context</h1>
2
2
 
3
3
  <p align="center">
4
- <strong>Cache-aware infinite context, cross-session memory, and background history compression for AI coding agents.</strong><br>
5
- Keeps your agent's memory intact no matter how long the session runs.
4
+ <strong>Unbounded context. Memory that manages itself. One session, for life.</strong><br>
5
+ The hippocampus for coding agents, part of CortexKit.
6
6
  </p>
7
7
 
8
8
  <p align="center">
@@ -11,26 +11,21 @@
11
11
  <a href="https://www.npmjs.com/package/@cortexkit/pi-magic-context"><img src="https://img.shields.io/npm/v/@cortexkit/pi-magic-context?label=pi&color=purple&style=flat-square" alt="npm @cortexkit/pi-magic-context"></a>
12
12
  <a href="https://discord.gg/DSa65w8wuf"><img src="https://img.shields.io/discord/1488852091056295957?style=flat-square&logo=discord&logoColor=white&label=Discord&color=5865F2" alt="Discord"></a>
13
13
  <a href="https://github.com/cortexkit/magic-context/stargazers"><img src="https://img.shields.io/github/stars/cortexkit/magic-context?style=flat-square&color=yellow" alt="stars"></a>
14
- <a href="https://github.com/cortexkit/magic-context/commits"><img src="https://img.shields.io/github/last-commit/cortexkit/magic-context?style=flat-square&color=green" alt="last commit"></a>
15
14
  <a href="https://github.com/cortexkit/magic-context/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT License"></a>
16
15
  </p>
17
16
 
18
17
  <p align="center">
19
- Available for <a href="https://opencode.ai/">OpenCode</a> and the <a href="https://pi.dev">Pi coding agent</a>. Memories, embeddings, dreamer state, and project knowledge are <strong>shared across both</strong> write a memory in OpenCode, retrieve it in Pi (and vice versa).
18
+ <em>You don't hire a developer for one task and fire them when they ship.<br>Stop doing it to your agent.</em>
20
19
  </p>
21
20
 
22
21
  <p align="center">
23
- <img src="https://raw.githubusercontent.com/cortexkit/magic-context/master/packages/plugin/docs/animation/out/optimized2.gif" alt="Magic Context in action" width="720">
24
- </p>
25
-
26
- <p align="center">
27
- <a href="#get-started">Get Started</a> ·
28
22
  <a href="#what-is-magic-context">What is Magic Context?</a> ·
29
- <a href="#what-your-agent-gets">What Your Agent Gets</a> ·
30
- <a href="#how-it-works">How It Works</a> ·
31
- <a href="#magic-context-app">🖥️ Desktop App</a> ·
32
- <a href="#commands">Commands</a> ·
33
- <a href="#configuration">Configuration</a> ·
23
+ <a href="#quick-start">Quick Start</a> ·
24
+ <a href="#part-of-cortexkit">CortexKit</a> ·
25
+ <a href="#-context-management">Context</a> ·
26
+ <a href="#-capture">Capture</a> ·
27
+ <a href="#-consolidate">Consolidate</a> ·
28
+ <a href="#-recall">Recall</a> ·
34
29
  <a href="https://discord.gg/DSa65w8wuf">💬 Discord</a>
35
30
  </p>
36
31
 
@@ -38,53 +33,25 @@
38
33
 
39
34
  ## What is Magic Context?
40
35
 
41
- Your agent **should never stop working** to manage its own context. Magic Context is an OpenCode plugin that handles context and memory management entirely in the background:
42
-
43
- **1.** Transparent context compaction via a **background historian** — the main agent keeps working while a separate model compresses older conversation. All operations are **cache-aware** and deferred to avoid wasting cached prefixes.
44
-
45
- **2.** **Cross-session project memory** — architecture decisions, constraints, and preferences persist across conversations.
46
-
47
- **3.** Overnight dreamer agent that consolidates, deduplicates, and promotes memories into canonical facts, plus maintains codebase documentation.
48
-
49
- **4.** On-demand sidekick that augments prompts with relevant project context.
50
-
51
- **5.** TUI sidebar with live context breakdown, token usage, historian status, and memory counts — right inside the terminal.
52
-
53
- ## Best way to use Magic Context?
54
-
55
- Keep using the **same session** for **weeks**, **months**, or even **years**. **One session** per **project**!
56
-
57
- ---
58
-
59
- ### ✨ Recent Highlights
60
-
61
- **Subagents now self-manage context (v0.15)** — subagent sessions now run age-based tool drops, reasoning clearing, and structural stripping at the execute threshold — the same way primary sessions with `ctx_reduce_enabled: false` behave. Previously they had no automatic reduction and grew silently until overflow. Nudges, historian/compartment runs, and the `<session-history>` block remain primary-only — subagents stay lean and parent-driven.
36
+ You don't hire a developer to fix one bug and fire them the moment it ships. You keep the good ones. They learn the codebase, remember why decisions were made, and get sharper every week.
62
37
 
63
- **Lean sessions when `ctx_reduce_enabled: false` (v0.15)** when you opt out of agent-driven reduction, the `§N§` tag prefix on user/assistant text and tool output is no longer injected, saving several thousand tokens per long session. The injected prompt guidance also switches to the no-reduce variant so the agent isn't told about a tool it can't use. DB tag records still exist (heuristic cleanup, persistence, and replay all depend on them); only the agent-visible prefix is skipped.
38
+ Coding agents work the opposite way. Every task is a fresh hire with no memory of your project, and at the end of each session you fire them and start from zero. Mid-task they even hit "compaction" pauses that break the flow and quietly drop what they knew. It is anterograde amnesia, the same thing that happens when the hippocampus is damaged.
64
39
 
65
- **User Memories (v0.14)** enabled by default under `dreamer.user_memories`. Historian extracts behavioral observations about you alongside its normal compartment output (communication style, expertise level, review focus, working patterns). Recurring observations are promoted by the dreamer to stable user memories that appear in all sessions via `<user-profile>`. Set `dreamer.user_memories.enabled: false` to opt out. Requires dreamer.
40
+ Magic Context gives them one. It is the **hippocampus** for coding agents, the part of the brain that forms memories, consolidates them, and recalls them, entirely in the background. One session stops being a disposable contractor and becomes a long-term teammate who was there for the whole project:
66
41
 
67
- **Key File Pinning (v0.14)** under `dreamer.pin_key_files`, still opt-in. Dreamer analyzes which files your agent reads most frequently across the session. Core orientation files (architecture, config, types) that get re-read after every context drop are pinned into the system prompt as `<key-files>`, so the agent always has them without needing to re-read from disk. Files are read fresh on each cache-busting pass. Enable with `dreamer.pin_key_files.enabled: true`.
42
+ - **Capture.** As the historian compresses your history, it lifts the durable knowledge (decisions, constraints, conventions) into project memory. You get a memory system for free, from work you are already doing.
43
+ - **Consolidate.** Overnight, a dreamer agent does what sleep does for you: it merges duplicates, verifies memories against the codebase, retires the stale, and promotes what recurs.
44
+ - **Recall.** The right memories surface automatically every turn, and the agent can search across memories, past conversations, and git history on demand. Across sessions, and across OpenCode and Pi.
68
45
 
69
- > Migrating from an earlier version? Running `npx @cortexkit/magic-context@latest doctor` rewrites old `experimental.user_memories.*` and `experimental.pin_key_files.*` keys into their new `dreamer.*` homes, preserving any `enabled` state you had.
46
+ Two promises: your agent **never stops to manage its context** (no compaction pauses, no broken flow) and it **never forgets**.
70
47
 
71
- ### 🧪 New Experimental Features
72
-
73
- **Age-tier caveman text compression (v0.15)** — opt-in companion to `ctx_reduce_enabled: false`. Older user/assistant text parts are progressively compressed using deterministic [caveman rules](https://github.com/cortexkit/magic-context/blob/master/packages/plugin/src/hooks/magic-context/caveman.ts) — the oldest 20% go to ultra-compressed, next 20% to full, next 20% to lite, newest 40% untouched. Tier shifts always recompress from the pristine original, never from an already-cavemaned intermediate, so the result is stable across passes. Cache-safe by design. Enable with `experimental.caveman_text_compression: { enabled: true }`. Only active when `ctx_reduce_enabled: false`.
74
-
75
- **Temporal Awareness** — gives the agent real-time perception. Each user message gets a small `<!-- +5m -->`/`<!-- +2h 15m -->`/`<!-- +3d 4h -->` gap marker showing time since the previous message, and every compartment in `<session-history>` carries `start-date`/`end-date` attributes. Lets the agent reason correctly about how long a build ran, when a decision was made, or how stale a prior session is. Cache-safe — markers derive from immutable timestamps. Enable with `experimental.temporal_awareness: true`.
76
-
77
- **Git Commit Indexing** — indexes HEAD git commits (skipping merges) from the project and makes them searchable through `ctx_search`. Commits are embedded so semantic queries like "when did we change the auth pattern" or "why did we pick X over Y" surface the right work. HEAD-only, windowed to the last year by default, capped at 2000 commits per project with oldest evicted. Enable with `experimental.git_commit_indexing.enabled: true`.
78
-
79
- **Auto Search Hints** — before each turn, Magic Context runs a background `ctx_search` on your prompt. When highly relevant content exists, a compact "vague recall" hint is appended to your message with caveman-compressed fragments of the top matches — like a human feeling they almost remember something and going to check their notes. The agent then decides whether to run `ctx_search` for the full content. Cache-safe, fires on top-score ≥ 0.55 by default. Enable with `experimental.auto_search.enabled: true`.
48
+ Run one session per project and keep it going for weeks, months, or years. It remembers everything you've built together.
80
49
 
81
50
  ---
82
51
 
83
- ## Get Started
52
+ ## Quick start
84
53
 
85
- ### Quick Setup (Recommended)
86
-
87
- Run the interactive setup wizard — it detects your models, configures everything, and handles compatibility:
54
+ Run the interactive setup wizard. It detects your models, configures everything, and handles compatibility.
88
55
 
89
56
  **macOS / Linux:**
90
57
  ```bash
@@ -101,271 +68,132 @@ irm https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/ins
101
68
  npx @cortexkit/magic-context@latest setup
102
69
  ```
103
70
 
104
- The unified setup wizard auto-detects which harnesses you have installed (OpenCode, Pi, or both) and configures each one. Use `--harness opencode` or `--harness pi` to target a specific harness.
105
-
106
- The wizard will:
107
- 1. Detect installed harnesses and available models
108
- 2. Add the plugin and disable built-in compaction
109
- 3. Help you pick models for historian, dreamer, and sidekick
110
- 4. Handle oh-my-opencode compatibility if needed
71
+ The wizard auto-detects which harnesses you have (OpenCode, Pi, or both), adds the plugin, disables built-in compaction, helps you pick models for the historian, dreamer, and sidekick, and resolves conflicts with other context-management plugins. Target a specific harness with `--harness opencode` or `--harness pi`.
111
72
 
112
- ### Manual Setup
73
+ > **Why disable built-in compaction?** Magic Context manages context itself. The host's compaction would interfere with its cache-aware deferred operations and double-compress.
113
74
 
114
- Add to your OpenCode config (`opencode.json` or `opencode.jsonc`):
75
+ **Manual setup** (OpenCode): add the plugin and turn compaction off in `opencode.json`, then drop a `magic-context.jsonc` in your project root. See the [configuration reference](./CONFIGURATION.md).
115
76
 
116
77
  ```jsonc
117
78
  {
118
79
  "plugin": ["@cortexkit/opencode-magic-context"],
119
- "compaction": {
120
- "auto": false,
121
- "prune": false
122
- }
123
- }
124
- ```
125
-
126
- > **Why disable compaction?** Magic Context manages context itself — built-in compaction interferes with its cache-aware deferred operations and would cause duplicate compression.
127
-
128
- Create `magic-context.jsonc` in your project root, `.opencode/`, or `~/.config/opencode/`:
129
-
130
- ```jsonc
131
- {
132
- "$schema": "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
133
- "enabled": true,
134
-
135
- // Which model the historian uses for background compression,
136
- // Prefer providers that charge by request instead of tokens
137
- "historian": {
138
- "model": "github-copilot/gpt-5.4",
139
- "fallback_models": ["opencode-go/glm-5"]
140
- }
141
- }
142
- ```
143
-
144
- > **Tip:** The `$schema` key enables autocomplete and validation in VS Code and other editors.
145
-
146
- That's it. Everything else has sensible defaults. Project config merges on top of user-wide settings; `auto_update` is user-config-only so projects cannot disable plugin self-updates.
147
-
148
- ### Oh-My-OpenCode / Oh-My-OpenAgent Users
149
-
150
- If you use [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) (formerly oh-my-opencode), disable the hooks that conflict with Magic Context in your `oh-my-openagent.json`:
151
-
152
- ```json
153
- {
154
- "disabled_hooks": [
155
- "context-window-monitor",
156
- "preemptive-compaction",
157
- "anthropic-context-window-limit-recovery"
158
- ]
80
+ "compaction": { "auto": false, "prune": false }
159
81
  }
160
82
  ```
161
83
 
162
- The setup wizard handles this automatically if it detects an oh-my-openagent or oh-my-opencode config.
84
+ **Pi (beta):** `npx @cortexkit/magic-context@latest setup --harness pi` (requires Pi `>= 0.74.0`). The Pi extension shares the same database as OpenCode; project memories and embeddings pool across both.
163
85
 
164
- ### Doctor (Troubleshooting)
86
+ **Troubleshooting:** `npx @cortexkit/magic-context@latest doctor` auto-detects your harnesses, checks for conflicts (compaction, OMO hooks, DCP), verifies the plugin and TUI sidebar, runs an integrity check on the database, and fixes what it can. Add `--issue` to file a ready-to-submit bug report.
165
87
 
166
- Already installed but something isn't working? Run the doctor to check and auto-fix configuration issues:
88
+ <details>
89
+ <summary><strong>Compatibility with other context-management plugins</strong></summary>
167
90
 
168
- ```bash
169
- npx @cortexkit/magic-context@latest doctor
170
- ```
91
+ <br>
171
92
 
172
- Doctor auto-detects installed harnesses and runs the right checks for each. Pass `--harness opencode` or `--harness pi` to target a specific harness when you have both installed.
93
+ Magic Context owns context management end to end, so it **disables itself** if another plugin is already doing that job. Running two context managers at once would double-compress your history and thrash the prompt cache. On startup it checks for the following; setup and `doctor` help you resolve each, and until they're resolved Magic Context stays off (fail-safe) and tells you why:
173
94
 
174
- Doctor checks for conflicts (compaction, DCP, OMO hooks), ensures the TUI sidebar is configured (OpenCode), verifies the plugin is registered, validates the magic-context.jsonc, runs `PRAGMA integrity_check` on the shared SQLite DB, and checks the npm cache — fixing what it can automatically. The summary line reports `PASS X / WARN Y / FAIL Z` so you can scan results at a glance.
95
+ - **OpenCode built-in compaction** (`compaction.auto` / `compaction.prune`) Magic Context replaces it. Setup turns it off.
96
+ - **DCP** (`opencode-dcp`) — a separate context-pruning plugin. The two cannot run together; remove it from your `plugin` list.
97
+ - **oh-my-opencode (OMO)** — setup offers to disable the three hooks that overlap:
98
+ - `preemptive-compaction` — triggers compaction that conflicts with the historian.
99
+ - `context-window-monitor` — injects usage warnings that overlap with Magic Context's nudges.
100
+ - `anthropic-context-window-limit-recovery` — triggers emergency compaction that bypasses the historian.
175
101
 
176
- Use `--force` to force-clear the plugin cache even when versions match (fixes broken transitive dependencies):
102
+ Run `npx @cortexkit/magic-context@latest doctor` any time to re-check and auto-fix.
177
103
 
178
- ```bash
179
- npx @cortexkit/magic-context@latest doctor --force
180
- ```
181
-
182
- Hit a real bug? Use `--issue` to collect environment, sanitized config, and the last 400 log lines into a ready-to-submit report. It can also open the issue directly via `gh` if you have it installed:
183
-
184
- ```bash
185
- npx @cortexkit/magic-context@latest doctor --issue
186
- ```
104
+ </details>
187
105
 
188
106
  ---
189
107
 
190
- ## Pi coding agent (beta)
191
-
192
- Magic Context is also available as a [Pi](https://github.com/earendil-works/pi-mono) extension, sharing the **same SQLite database** as the OpenCode plugin. Project memories, embeddings, dreamer state, and key-file pins are pooled across both harnesses; per-session state (tags, compartments, facts, notes) stays harness-scoped.
108
+ ## Part of CortexKit
193
109
 
194
- > ⚠️ The Pi extension is published as **beta** while it accumulates real-world usage. Core flows are validated with end-to-end tests; report issues at [github.com/cortexkit/magic-context/issues](https://github.com/cortexkit/magic-context/issues).
110
+ A brain isn't one organ. Neither is a capable coding agent.
195
111
 
196
- ```bash
197
- # Setup wizard for Pi (uses the same unified CLI as OpenCode)
198
- npx @cortexkit/magic-context@latest setup --harness pi
199
- ```
112
+ **CortexKit** is a family of plugins, each modeled on a different region of the brain. Install one and your agent gets sharper. Install all three and it has a brain.
200
113
 
201
- Requires Pi `>= 0.71.0`. The wizard handles registration with Pi (`packages` array in `~/.pi/agent/settings.json`), writes `~/.pi/agent/magic-context.jsonc`, and prompts for historian/dreamer/sidekick model picks. Pi-specific docs and config notes live in [`packages/pi-plugin/README.md`](https://github.com/cortexkit/magic-context/blob/master/packages/pi-plugin/README.md).
114
+ | Plugin | Region | What it does |
115
+ |---|---|---|
116
+ | **Magic Context** *(you are here)* | Hippocampus & medial temporal lobe | Self-managing context and long-term memory. Keeps sessions running with no compaction pauses while it forms, consolidates, and recalls project knowledge across them. |
117
+ | **[AFT](https://github.com/cortexkit/aft)** | Sensorimotor cortex | Perceives code structure and acts on it precisely. A proper IDE and OS for your agent. |
118
+ | **Alfonso** *(coming soon)* | Prefrontal cortex | Executive control. Plans, decomposes work, chooses agents and models, and decides when to ask, verify, and commit. |
202
119
 
203
- For health checks:
204
-
205
- ```bash
206
- npx @cortexkit/magic-context@latest doctor --harness pi
207
- ```
120
+ Magic Context is **1 of the 3 plugins you'll ever need.** It remembers; AFT perceives and acts; Alfonso decides. They share one CortexKit store, so memory pools across harnesses and tools.
208
121
 
209
122
  ---
210
123
 
211
- ## What Your Agent Gets
124
+ ## Context management
212
125
 
213
- Magic Context injects structured context automatically and gives the agent five tools.
126
+ *An unbounded session that manages itself.* The context window fills up as you work, and the usual fix, compaction, stops the agent cold to re-read everything. Magic Context handles it continuously in the background, so the session just keeps going.
214
127
 
215
- ### `ctx_reduce` Shed weight
128
+ - **Historian compartmentalization**: a background historian compresses old raw history into **tiered compartments**, chronological summaries that stand in for older messages. Each carries an importance score, so the live window stays small without losing the thread. Summarizing doesn't need your primary's coding muscle, so you can run the historian on a cheap or even fully local model while your main agent stays top-tier.
129
+ - **Decay rendering**: compartments render at the right fidelity for the moment, by a deterministic, no-LLM rule that self-tunes to the model's context window. Old history fades gracefully instead of dropping off a cliff, and because it is deterministic, the same history always renders the same way.
130
+ - **The agent hints what to drop, or it doesn't**: with agent-driven reduction on, the agent calls `ctx_reduce` to mark stale tool outputs or long messages for removal. Drops are **queued and cache-aware**, applied only at cache-safe moments so reduction never thrashes the cache. Switch it off and the agent stays out of context management entirely: stale output is shed automatically by age, with optional caveman compression of the oldest text.
131
+ - **Cache-stable layout**: all of this is structured so background work never invalidates the cached prefix of your prompt. Your cache survives the whole session.
216
132
 
217
- After tool-heavy turns (large grep results, file reads, bash output), the agent calls `ctx_reduce` to mark stale content for removal. Drops are queued not applied immediately until the cache expires or context pressure forces it.
133
+ The result: one session runs for months, with no compaction pauses and low cost on cache-priced providers. You can watch it happen in OpenCode's TUI, where a live sidebar shows the context breakdown by source, historian status, and memory counts, updating after every message.
218
134
 
219
- ```
220
- ctx_reduce(drop="3-5,12") // Drop tags 3, 4, 5, and 12
221
- ```
222
-
223
- Recent tags (last 20 by default) are protected. Drops targeting them stay queued until they age out.
224
-
225
- ### `ctx_expand` — Decompress history
135
+ > *Optional (off by default):* **caveman text compression** progressively compresses the oldest user and assistant text by a deterministic age-tiered rule, for sessions that run with agent-driven reduction off.
226
136
 
227
- When the agent needs to recall details from a compressed history range, it can expand specific compartment ranges back to the original conversation transcript.
228
-
229
- ```
230
- ctx_expand(start=100, end=200) // Expand raw messages 100-200
231
- ```
232
-
233
- Returns the same compact `U:`/`A:` transcript format the historian sees, capped at ~15K tokens per request. Use `start`/`end` from compartment attributes visible in `<session-history>`.
234
-
235
- ### `ctx_note` — Deferred intentions
236
-
237
- Session notes are the agent's scratchpad for things to tackle later — not task tracking (that's what todos are for), but deferred work and reminders that should surface at the right time.
238
-
239
- ```
240
- ctx_note(action="write", content="After this fix, check if the compressor budget formula is correct")
241
- ctx_note(action="read")
242
- ```
243
-
244
- Notes surface automatically at natural work boundaries: after commits, after historian runs, and after all todos complete.
245
-
246
- **Smart notes** are project-scoped notes with an open-ended `surface_condition` that the dreamer evaluates nightly. When the condition is met, the note surfaces in the next session:
247
-
248
- ```
249
- ctx_note(action="write", content="Implement X because Y", surface_condition="When PR #42 is merged in this repo")
250
- ctx_note(action="dismiss", note_id=1)
251
- ```
252
-
253
- Smart notes require dreamer enabled. Pending notes are invisible until the dreamer marks them ready. Use `dismiss` to clear a surfaced note.
254
-
255
- ### `ctx_memory` — Persistent cross-session knowledge
137
+ ---
256
138
 
257
- Architecture decisions, naming conventions, user preferences — anything that should survive across conversations. Memories are project-scoped and automatically promoted from session facts by the historian.
139
+ ## 🧠 Capture
258
140
 
259
- ```
260
- ctx_memory(action="write", category="ARCHITECTURE_DECISIONS", content="Event sourcing for orders.")
261
- ctx_memory(action="delete", id=42)
262
- ```
141
+ *Memory, for free.* To compress your history, the historian has to read all of it. So in the same pass it lifts out the knowledge worth keeping forever, decisions, constraints, conventions, config values, and promotes it into **project memory**, categorized and carried into every future session. Your memory builds itself from the work you are already doing.
263
142
 
264
- ### `ctx_search` Unified search
143
+ The agent can also record memories explicitly, though most are captured automatically for it:
265
144
 
266
- Search across all data layers with a single query — project memories, session facts, and raw conversation history. Results are ranked by source (memories first, then facts, then message hits).
145
+ - **`ctx_memory`**: write or delete cross-session knowledge directly, in a small category taxonomy (`PROJECT_RULES`, `ARCHITECTURE`, `CONSTRAINTS`, `CONFIG_VALUES`, `NAMING`).
267
146
 
268
147
  ```
269
- ctx_search(query="authentication approach")
148
+ ctx_memory(action="write", category="ARCHITECTURE", content="Event sourcing for orders.")
270
149
  ```
271
150
 
272
- Message results include ordinal numbers the agent can pass to `ctx_expand` to retrieve the surrounding conversation context.
273
-
274
- ### Automatic context injection
275
-
276
- Every turn, Magic Context injects a `<session-history>` block containing:
277
-
278
- - **Project memories** — cross-session decisions, constraints, and preferences
279
- - **Compartments** — structured summaries replacing older raw history
280
- - **Session facts** — durable categorized facts from the current session
281
-
282
- This block is stable between historian runs. Memory writes persist immediately for search but don't change the injected block until the next historian run — so writes never bust the cache mid-conversation.
151
+ > **Temporal awareness** *(on by default)* gives the agent a sense of time, with gap markers like `+2h 15m` between messages and dated compartments, so it can reason about how long ago something happened. Set `temporal_awareness: false` to turn it off.
283
152
 
284
153
  ---
285
154
 
286
- ## How It Works
287
-
288
- ### Tagging
289
-
290
- Every message, tool output, and file attachment gets a monotonically increasing `§N§` tag. The agent sees these inline and uses them to reference specific content when calling `ctx_reduce`. Tags persist in the database and resume across restarts.
291
-
292
- ### Queued reductions
293
-
294
- When the agent calls `ctx_reduce`, drops go into a pending queue — not applied immediately. Two conditions trigger execution:
295
-
296
- - **Cache expired** — enough time has passed that the cached prefix is likely stale (configurable per model, default 5 minutes)
297
- - **Threshold reached** — context usage hits `execute_threshold_percentage` (default 65%)
298
-
299
- Between triggers, the conversation continues unchanged. The agent doesn't need to think about timing.
300
-
301
- ### Background historian
302
-
303
- When local drops aren't buying enough headroom, Magic Context starts a historian — a separate lightweight model that reads an eligible prefix of raw history and produces:
155
+ ## 🌙 Consolidate
304
156
 
305
- - **Compartments** chronological blocks that replace older raw messages
306
- - **Facts** — durable decisions, constraints, and preferences (categorized)
157
+ *What sleep does for memory.* An optional **dreamer** agent runs overnight to keep memory quality high, spinning up ephemeral child sessions for each task:
307
158
 
308
- The historian runs asynchronously. The main agent never waits for it. When the historian finishes, its output is materialized on the next transform pass.
159
+ - **Consolidate**: merge semantically similar memories into canonical facts.
160
+ - **Verify**: check memories against the current codebase (paths, configs, patterns).
161
+ - **Archive stale**: retire memories about removed features or old paths.
162
+ - **Improve**: rewrite verbose memories into terse, operational form.
163
+ - **Maintain docs**: keep `ARCHITECTURE.md` and `STRUCTURE.md` current from codebase changes.
164
+ - **User memories**: promote recurring observations about how you work (communication style, review focus, working patterns) into a `<user-profile>` that travels with every session.
165
+ - **Smart notes**: evaluate deferred notes whose `surface_condition` has come true and surface the ready ones.
309
166
 
310
- A **separate compressor** pass fires when the rendered history block exceeds the configured history budget, merging the oldest compartments to keep the injected context lean.
167
+ Because it runs during idle time, the dreamer pairs well with local models, even slow ones. Nobody is waiting. Trigger a run any time with `/ctx-dream`.
311
168
 
312
- ### Nudging
313
-
314
- As context usage grows, Magic Context sends rolling reminders suggesting the agent reduce. Cadence tightens as usage approaches the threshold — from gentle reminders to urgent warnings. If the agent recently called `ctx_reduce`, reminders are suppressed. At 85% Magic Context force-materializes queued drops and emergency cleanup; at 95% it blocks the turn until background historian completes.
315
-
316
- ### Cross-session memory
317
-
318
- After each historian run, qualifying facts are promoted to the persistent memory store. On every subsequent turn, active memories are injected in `<session-history>`. New sessions inherit all project memories from previous sessions.
319
-
320
- Memories are searchable via `ctx_search` alongside session facts and raw conversation history, using semantic embeddings (local by default) with full-text search as fallback.
321
-
322
- ### Dreamer
323
-
324
- An optional background agent that maintains memory quality overnight:
325
-
326
- - **Consolidate** — merge semantically similar memories into canonical facts
327
- - **Verify** — check memories against current codebase (configs, paths, code patterns)
328
- - **Archive stale** — retire memories referencing removed features or old paths
329
- - **Improve** — rewrite verbose memories into terse operational form
330
- - **Maintain docs** — update ARCHITECTURE.md and STRUCTURE.md from codebase changes
331
- - **Evaluate smart notes** — check pending smart note conditions and surface ready notes
332
- - **Review user memories** — promote recurring user behavior observations to stable memories
333
-
334
- The dreamer runs during a configurable schedule window and creates ephemeral OpenCode child sessions for each task. Since it runs during idle time (typically overnight), it works well with local models — even slower ones like `ollama/mlx-qwen3.5-27b-claude-4.6-opus-reasoning-distilled` are fine since there's no user waiting.
335
-
336
- When dreamer is enabled, ARCHITECTURE.md and STRUCTURE.md are automatically injected into the agent's system prompt (configurable via `inject_docs`). Content is cached per-session and refreshed on cache-busting passes.
169
+ ---
337
170
 
338
- ### User Memories
171
+ ## 🔎 Recall
339
172
 
340
- Enabled by default under `dreamer.user_memories`. Historian extracts behavioral observations about the user alongside its normal compartment output things like communication style, expertise level, review focus, and working patterns. These go into a candidate pool.
173
+ *The right memory at the right moment.* Every turn, active project memories and the compacted session history are injected automatically and cache-stably. On demand, the agent reaches for:
341
174
 
342
- During dreamer runs, a dedicated review pass checks candidates for recurring patterns across sessions. Observations that appear at least `promotion_threshold` times (default 3) are promoted to stable user memories and injected into all sessions via `<user-profile>` in the system prompt.
175
+ - **`ctx_search`**: one query across three layers at once: project **memories**, raw **conversation** history, and indexed **git commits**. Semantic embeddings with full-text fallback.
343
176
 
344
- Stable user memories are visible and manageable in the dashboard's User Memories page. Requires dreamer to be enabled for the promotion step — without dreamer, candidates accumulate but are never promoted. Set `dreamer.user_memories.enabled: false` to opt out.
177
+ ```
178
+ ctx_search(query="why did we pick event sourcing for orders")
179
+ ```
345
180
 
346
- ### TUI Sidebar
181
+ - **`ctx_expand`**: pull a compressed history range back to the original `U:`/`A:` transcript when the agent needs the exact details.
182
+ - **`ctx_note`**: a scratchpad for deferred intentions. Notes resurface at natural boundaries (after commits, after historian runs, when todos finish). **Smart notes** carry an open-ended condition the dreamer watches for.
347
183
 
348
- When running in OpenCode's terminal UI, Magic Context shows a live sidebar panel with:
184
+ Recall works **across sessions** (a new session inherits everything) and **across harnesses** (write a memory in OpenCode, retrieve it in Pi).
349
185
 
350
- - **Context breakdown bar** — visual token split across System Prompt, Compartments, Facts, Memories, Conversation, Tool Calls, Tool Definitions (measured from the `tool.definition` hook), and Overhead. Cool palette for structured injections, warm palette for user/tool traffic.
351
- - **Historian status** — idle, running, or compartment/fact counts
352
- - **Memory counts** — total project memories and how many are injected
353
- - **Dreamer status** — last run time
354
- - **Queue status** — pending operations count
186
+ > **Auto search hints** *(on by default)* run a background `ctx_search` each turn and whisper a "vague recall" when something relevant exists like almost remembering a note you took. It appends only compact fragments, never full content; set `memory.auto_search.enabled: false` to turn it off. **Git commit indexing** *(opt-in)* makes your project history semantically searchable as a fourth `ctx_search` source — enable with `memory.git_commit_indexing.enabled: true`.
355
187
 
356
- The sidebar updates after every message. Commands (`/ctx-status`, `/ctx-flush`, `/ctx-aug`) also work directly in TUI mode via dialogs and toasts.
188
+ ### Agent tools at a glance
357
189
 
358
- The TUI plugin is configured automatically by the setup wizard and the `doctor` command. If you installed manually, add to your `tui.json` or `tui.jsonc`:
359
-
360
- ```jsonc
361
- {
362
- "plugin": ["@cortexkit/opencode-magic-context"]
363
- }
364
- ```
365
-
366
- ### Startup conflict detection
367
-
368
- On startup, Magic Context checks for common configuration problems — OpenCode's built-in compaction being enabled, DCP plugin being active alongside Magic Context, or conflicting oh-my-openagent hooks. When conflicts are detected, it warns the active session with a fix suggestion pointing to `npx @cortexkit/magic-context@latest doctor`.
190
+ | Tool | Section | What it does |
191
+ |------|-------|-------------|
192
+ | `ctx_reduce` | Context | Queue stale tagged content for removal, cache-aware |
193
+ | `ctx_memory` | Capture | Write or delete durable cross-session memories |
194
+ | `ctx_search` | Recall | Search memories, conversation history, and git commits |
195
+ | `ctx_expand` | Recall | Decompress a history range back to the transcript |
196
+ | `ctx_note` | Recall | Deferred intentions and dreamer-evaluated smart notes |
369
197
 
370
198
  ---
371
199
 
@@ -373,37 +201,37 @@ On startup, Magic Context checks for common configuration problems — OpenCode'
373
201
 
374
202
  | Command | Description |
375
203
  |---------|-------------|
376
- | `/ctx-status` | Debug view: tags, pending drops, cache TTL, nudge state, historian progress, compartment coverage, history compression budget |
204
+ | `/ctx-status` | Debug view: tags, pending drops, cache TTL, nudge state, historian progress, compartment coverage, history budget |
377
205
  | `/ctx-flush` | Force all queued operations immediately, bypassing cache TTL |
378
- | `/ctx-recomp` | Rebuild compartments and facts from raw history use when stored state seems wrong |
379
- | `/ctx-aug` | Run sidekick augmentation on a prompt retrieves relevant memories via a separate model |
380
- | `/ctx-dream` | Run dreamer maintenance on demand consolidate, verify, archive, improve memories |
206
+ | `/ctx-recomp` | Rebuild compartments from raw history (accepts a `start-end` range). Use when stored state seems wrong |
207
+ | `/ctx-session-upgrade` | Upgrade this session to the latest history format: rebuild compartments and migrate project memories |
208
+ | `/ctx-aug` | Run sidekick augmentation on a prompt: retrieve relevant memories via a separate model |
209
+ | `/ctx-dream` | Run dreamer maintenance on demand: consolidate, verify, archive, improve |
381
210
 
382
211
  ---
383
212
 
384
- ## Magic Context App
213
+ ## Desktop app
385
214
 
386
- A companion desktop app for browsing and managing Magic Context state outside of OpenCode.
215
+ A companion desktop app for browsing and managing Magic Context state outside the terminal.
387
216
 
388
217
  <p align="center">
389
- <a href="https://github.com/cortexkit/magic-context/releases/tag/dashboard-v0.4.8"><strong>⬇️ Download for macOS · Windows · Linux</strong></a></p>
218
+ <a href="https://github.com/cortexkit/magic-context/releases"><strong>⬇️ Download for macOS · Windows · Linux</strong></a>
219
+ </p>
390
220
 
391
- **Features:**
392
- - **Memory Browser** search, filter, and edit project memories with category and project filtering
393
- - **Session History** browse compartments, facts, and notes for any session with timeline navigation
394
- - **Cache Diagnostics** real-time cache hit/miss timeline, bust cause detection, per-session stats
395
- - **Dreamer Management** view dream run history per project, trigger runs, inspect task results
396
- - **Configuration Editor** — form-based editing for all settings including model selection with fallback chains
397
- - **Log Viewer** — live-tailing log viewer with search
398
- - **System Tray** — quick access to dreamer status and controls
221
+ - **Memory browser**: search, filter, and edit project memories by category and project.
222
+ - **Session history**: browse compartments and notes for any session with timeline navigation.
223
+ - **Cache diagnostics**: real-time cache hit/miss timeline and bust-cause detection.
224
+ - **Dreamer management**: view dream-run history, trigger runs, inspect task results.
225
+ - **Configuration editor**: form-based editing for every setting, including model fallback chains.
226
+ - **Log viewer**: live-tailing logs with search.
399
227
 
400
- The app reads directly from Magic Context's SQLite database no additional server or API required. Auto-updates are built in.
228
+ It reads directly from Magic Context's SQLite database. No extra server, no API. Auto-updates built in.
401
229
 
402
230
  ---
403
231
 
404
232
  ## Configuration
405
233
 
406
- All settings live in `magic-context.jsonc` as flat top-level keys. See **[CONFIGURATION.md](./CONFIGURATION.md)** for the full reference cache TTL tuning, per-model execute thresholds, historian model selection, embedding providers, memory settings, sidekick, and dreamer.
234
+ Settings live in `magic-context.jsonc`. Everything has sensible defaults; project config merges on top of user-wide settings. See **[CONFIGURATION.md](./CONFIGURATION.md)** for the full reference: cache TTL tuning, per-model execute thresholds, historian and dreamer model selection, embedding providers, and memory settings.
407
235
 
408
236
  **Config locations** (merged in order, project overrides user):
409
237
  1. `<project-root>/magic-context.jsonc`
@@ -414,33 +242,7 @@ All settings live in `magic-context.jsonc` as flat top-level keys. See **[CONFIG
414
242
 
415
243
  ## Storage
416
244
 
417
- All durable states live in a local SQLite database. If the database can't be opened, Magic Context disables itself and notifies the user.
418
-
419
- ```
420
- ~/.local/share/opencode/storage/plugin/magic-context/context.db
421
- ```
422
-
423
- | Table | Purpose |
424
- |-------|---------|
425
- | `tags` | Tag assignments — message ID, tag number, session, status |
426
- | `pending_ops` | Queued drop operations |
427
- | `source_contents` | Raw content snapshots for persisted reductions |
428
- | `compartments` | Historian-produced structured history blocks |
429
- | `session_facts` | Categorized durable facts from historian runs |
430
- | `notes` | Unified session notes and project-scoped smart notes |
431
- | `session_meta` | Per-session state — usage, nudge flags, anchors |
432
- | `memories` | Cross-session persistent memories |
433
- | `memory_embeddings` | Embedding vectors for semantic search |
434
- | `dream_state` | Dreamer lease locking and task progress |
435
- | `dream_queue` | Queued projects awaiting dream processing |
436
- | `dream_runs` | Per-project dream run history — task names, durations, memory changes |
437
- | `compression_depth` | Per-message compression depth for weighted compressor selection |
438
- | `message_history_fts` | FTS5 index of user/assistant message text for `ctx_search` |
439
- | `message_history_index` | Tracks last indexed ordinal per session for incremental FTS population |
440
- | `recomp_compartments` | Staging for `/ctx-recomp` partial progress |
441
- | `recomp_facts` | Staging for `/ctx-recomp` partial progress |
442
- | `user_memory_candidates` | User behavior observations from historian (experimental) |
443
- | `user_memories` | Promoted stable user memories injected into all sessions (experimental) |
245
+ All durable state lives in a local SQLite database under the shared CortexKit store (`~/.local/share/cortexkit/magic-context/context.db`, XDG-equivalent on Windows; legacy OpenCode-folder databases are migrated forward on first boot). If the database can't be opened, Magic Context disables itself and notifies you. Memories are keyed to a **stable project identity** derived from the repo, so they follow a project across worktrees, clones, and forks rather than being tied to a directory path.
444
246
 
445
247
  ---
446
248
 
@@ -461,32 +263,21 @@ All durable states live in a local SQLite database. If the database can't be ope
461
263
  **Requirements:** [Bun](https://bun.sh) ≥ 1.0
462
264
 
463
265
  ```sh
464
- bun install # Install dependencies
465
- bun run build # Build the plugin
466
- bun run typecheck # Type-check without emitting
467
- bun test # Run tests
468
- bun run lint # Lint (Biome)
469
- bun run lint:fix # Lint with auto-fix
470
- bun run format # Format (Biome)
471
- ```
472
-
473
- **Utility scripts:**
474
-
475
- ```sh
476
- bun packages/plugin/scripts/tail-view.ts # Show post-compartment message tail
477
- bun packages/plugin/scripts/context-dump/index.ts # Dump full context state for a session
478
- bun packages/plugin/scripts/backfill-embeddings.ts # Backfill missing memory embeddings
266
+ bun install # Install dependencies
267
+ bun run build # Build the plugin
268
+ bun run typecheck # Type-check without emitting
269
+ bun test # Run tests
270
+ bun run lint # Lint (Biome)
271
+ bun run format # Format (Biome)
479
272
  ```
480
273
 
481
- Dream execution requires a live OpenCode server the dreamer creates ephemeral child sessions. Use `/ctx-dream` inside OpenCode for on-demand maintenance.
274
+ Dream execution requires a live OpenCode server (the dreamer creates ephemeral child sessions). Use `/ctx-dream` inside OpenCode for on-demand maintenance.
482
275
 
483
276
  ---
484
277
 
485
278
  ## Contributing
486
279
 
487
- Bug reports and pull requests are welcome. For larger changes, open an issue first to discuss the approach.
488
-
489
- Run `bun run format` before submitting — CI rejects unformatted code.
280
+ Bug reports and pull requests are welcome. For larger changes, open an issue first to discuss the approach. Run `bun run format` before submitting; CI rejects unformatted code.
490
281
 
491
282
  ---
492
283
 
@@ -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"}