@cortexkit/opencode-magic-context 0.15.6 → 0.16.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 (192) hide show
  1. package/README.md +41 -15
  2. package/dist/agents/magic-context-prompt.d.ts +2 -13
  3. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  4. package/dist/cli/diagnostics.d.ts.map +1 -1
  5. package/dist/cli/migrate.d.ts +70 -0
  6. package/dist/cli/migrate.d.ts.map +1 -0
  7. package/dist/cli.js +666 -29
  8. package/dist/config/schema/magic-context.d.ts +67 -4
  9. package/dist/config/schema/magic-context.d.ts.map +1 -1
  10. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  11. package/dist/features/magic-context/compaction.d.ts +1 -1
  12. package/dist/features/magic-context/compaction.d.ts.map +1 -1
  13. package/dist/features/magic-context/compartment-storage.d.ts +1 -1
  14. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  15. package/dist/features/magic-context/compression-depth-storage.d.ts +1 -1
  16. package/dist/features/magic-context/compression-depth-storage.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/lease.d.ts +1 -1
  18. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/queue.d.ts +8 -3
  20. package/dist/features/magic-context/dreamer/queue.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/runner.d.ts +1 -1
  22. package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/scheduler.d.ts +1 -1
  24. package/dist/features/magic-context/dreamer/scheduler.d.ts.map +1 -1
  25. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +1 -1
  26. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  27. package/dist/features/magic-context/dreamer/storage-dream-state.d.ts +1 -1
  28. package/dist/features/magic-context/dreamer/storage-dream-state.d.ts.map +1 -1
  29. package/dist/features/magic-context/git-commits/indexer.d.ts +1 -1
  30. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
  31. package/dist/features/magic-context/git-commits/search-git-commits.d.ts +1 -1
  32. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
  33. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +1 -1
  34. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -1
  35. package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +1 -1
  36. package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -1
  37. package/dist/features/magic-context/key-files/identify-key-files.d.ts +1 -1
  38. package/dist/features/magic-context/key-files/identify-key-files.d.ts.map +1 -1
  39. package/dist/features/magic-context/key-files/read-stats.d.ts +1 -1
  40. package/dist/features/magic-context/key-files/read-stats.d.ts.map +1 -1
  41. package/dist/features/magic-context/key-files/storage-key-files.d.ts +1 -1
  42. package/dist/features/magic-context/key-files/storage-key-files.d.ts.map +1 -1
  43. package/dist/features/magic-context/memory/embedding-backfill.d.ts +1 -1
  44. package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
  45. package/dist/features/magic-context/memory/embedding-cache.d.ts +1 -1
  46. package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -1
  47. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  48. package/dist/features/magic-context/memory/embedding.d.ts +1 -1
  49. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  50. package/dist/features/magic-context/memory/normalize-hash.d.ts.map +1 -1
  51. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  52. package/dist/features/magic-context/memory/promotion.d.ts +1 -1
  53. package/dist/features/magic-context/memory/promotion.d.ts.map +1 -1
  54. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +1 -1
  55. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
  56. package/dist/features/magic-context/memory/storage-memory-fts.d.ts +1 -1
  57. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
  58. package/dist/features/magic-context/memory/storage-memory.d.ts +1 -1
  59. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
  60. package/dist/features/magic-context/message-index.d.ts +1 -1
  61. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  62. package/dist/features/magic-context/migrations.d.ts +1 -1
  63. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  64. package/dist/features/magic-context/mock-database.d.ts +1 -1
  65. package/dist/features/magic-context/mock-database.d.ts.map +1 -1
  66. package/dist/features/magic-context/plugin-messages.d.ts +1 -1
  67. package/dist/features/magic-context/plugin-messages.d.ts.map +1 -1
  68. package/dist/features/magic-context/search.d.ts +1 -1
  69. package/dist/features/magic-context/search.d.ts.map +1 -1
  70. package/dist/features/magic-context/sidekick/agent.d.ts +2 -1
  71. package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -1
  72. package/dist/features/magic-context/sidekick/core.d.ts +38 -0
  73. package/dist/features/magic-context/sidekick/core.d.ts.map +1 -0
  74. package/dist/features/magic-context/storage-db.d.ts +20 -1
  75. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  76. package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -1
  77. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  78. package/dist/features/magic-context/storage-meta-session.d.ts +1 -1
  79. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  80. package/dist/features/magic-context/storage-meta-shared.d.ts +1 -1
  81. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  82. package/dist/features/magic-context/storage-notes.d.ts +1 -1
  83. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  84. package/dist/features/magic-context/storage-ops.d.ts +1 -1
  85. package/dist/features/magic-context/storage-ops.d.ts.map +1 -1
  86. package/dist/features/magic-context/storage-source.d.ts +1 -1
  87. package/dist/features/magic-context/storage-source.d.ts.map +1 -1
  88. package/dist/features/magic-context/storage-tags.d.ts +25 -1
  89. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  90. package/dist/features/magic-context/tagger.d.ts +1 -1
  91. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  92. package/dist/features/magic-context/user-memory/review-user-memories.d.ts +1 -1
  93. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  94. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +1 -1
  95. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/auto-search-runner.d.ts +1 -1
  98. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/command-handler.d.ts +1 -1
  100. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  101. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +1 -1
  102. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/compartment-prompt.d.ts +1 -0
  104. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts +1 -1
  106. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +1 -1
  108. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
  109. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -0
  110. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  111. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/compartment-runner-types.d.ts +1 -1
  113. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  114. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  115. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/execute-flush.d.ts +1 -1
  117. package/dist/hooks/magic-context/execute-flush.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/execute-status.d.ts +1 -1
  119. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  120. package/dist/hooks/magic-context/historian-state-file.d.ts +29 -0
  121. package/dist/hooks/magic-context/historian-state-file.d.ts.map +1 -0
  122. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/inject-compartments.d.ts +1 -1
  124. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  125. package/dist/hooks/magic-context/note-nudger.d.ts +1 -1
  126. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  127. package/dist/hooks/magic-context/nudge-placement-store.d.ts +1 -1
  128. package/dist/hooks/magic-context/nudge-placement-store.d.ts.map +1 -1
  129. package/dist/hooks/magic-context/read-session-chunk.d.ts +39 -0
  130. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  131. package/dist/hooks/magic-context/read-session-db.d.ts +1 -1
  132. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/read-session-raw.d.ts +1 -1
  134. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  136. package/dist/hooks/magic-context/system-prompt-hash.d.ts +6 -5
  137. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  138. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  139. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  140. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  141. package/dist/index.js +8512 -8321
  142. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  143. package/dist/plugin/messages-transform.d.ts +1 -1
  144. package/dist/plugin/rpc-handlers.d.ts +4 -0
  145. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  146. package/dist/plugin/tool-registry.d.ts.map +1 -1
  147. package/dist/shared/conflict-detector.d.ts.map +1 -1
  148. package/dist/shared/data-path.d.ts +22 -0
  149. package/dist/shared/data-path.d.ts.map +1 -1
  150. package/dist/shared/harness.d.ts +43 -0
  151. package/dist/shared/harness.d.ts.map +1 -0
  152. package/dist/shared/rpc-notifications.d.ts +4 -2
  153. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  154. package/dist/shared/sqlite-helpers.d.ts +16 -0
  155. package/dist/shared/sqlite-helpers.d.ts.map +1 -0
  156. package/dist/shared/sqlite.d.ts +55 -0
  157. package/dist/shared/sqlite.d.ts.map +1 -0
  158. package/dist/shared/subagent-runner.d.ts +202 -0
  159. package/dist/shared/subagent-runner.d.ts.map +1 -0
  160. package/dist/shared/tag-transcript.d.ts +66 -0
  161. package/dist/shared/tag-transcript.d.ts.map +1 -0
  162. package/dist/shared/transcript-opencode.d.ts +71 -0
  163. package/dist/shared/transcript-opencode.d.ts.map +1 -0
  164. package/dist/shared/transcript.d.ts +212 -0
  165. package/dist/shared/transcript.d.ts.map +1 -0
  166. package/dist/shared/tui-config.d.ts.map +1 -1
  167. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  168. package/dist/tools/ctx-memory/types.d.ts +13 -2
  169. package/dist/tools/ctx-memory/types.d.ts.map +1 -1
  170. package/dist/tools/ctx-note/tools.d.ts +8 -2
  171. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  172. package/dist/tools/ctx-reduce/tools.d.ts +1 -1
  173. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  174. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  175. package/dist/tools/ctx-search/types.d.ts +8 -2
  176. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  177. package/dist/tui/data/context-db.d.ts.map +1 -1
  178. package/package.json +7 -5
  179. package/src/shared/conflict-detector.test.ts +44 -1
  180. package/src/shared/conflict-detector.ts +24 -8
  181. package/src/shared/data-path.test.ts +53 -1
  182. package/src/shared/data-path.ts +28 -0
  183. package/src/shared/harness.ts +61 -0
  184. package/src/shared/rpc-notifications.ts +11 -5
  185. package/src/shared/sqlite-helpers.ts +27 -0
  186. package/src/shared/sqlite.ts +91 -0
  187. package/src/shared/subagent-runner.ts +206 -0
  188. package/src/shared/tag-transcript.ts +541 -0
  189. package/src/shared/transcript-opencode.ts +259 -0
  190. package/src/shared/transcript.ts +226 -0
  191. package/src/shared/tui-config.ts +34 -8
  192. package/src/tui/data/context-db.ts +5 -1
package/README.md CHANGED
@@ -2,18 +2,23 @@
2
2
 
3
3
  <p align="center">
4
4
  <strong>Cache-aware infinite context, cross-session memory, and background history compression for AI coding agents.</strong><br>
5
- An <a href="https://github.com/anomalyco/opencode">OpenCode</a> plugin that keeps your agent's memory intact — no matter how long the session runs.
5
+ Keeps your agent's memory intact — no matter how long the session runs.
6
6
  </p>
7
7
 
8
8
  <p align="center">
9
- <a href="https://www.npmjs.com/package/@cortexkit/opencode-magic-context"><img src="https://img.shields.io/npm/v/@cortexkit/opencode-magic-context?color=blue&style=flat-square" alt="npm"></a>
10
- <a href="https://github.com/cortexkit/opencode-magic-context/stargazers"><img src="https://img.shields.io/github/stars/cortexkit/opencode-magic-context?style=flat-square&color=yellow" alt="stars"></a>
11
- <a href="https://github.com/cortexkit/opencode-magic-context/commits"><img src="https://img.shields.io/github/last-commit/cortexkit/opencode-magic-context?style=flat-square&color=green" alt="last commit"></a>
12
- <a href="https://github.com/cortexkit/opencode-magic-context/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT License"></a>
9
+ <a href="https://www.npmjs.com/package/@cortexkit/opencode-magic-context"><img src="https://img.shields.io/npm/v/@cortexkit/opencode-magic-context?label=opencode&color=blue&style=flat-square" alt="npm @cortexkit/opencode-magic-context"></a>
10
+ <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>
11
+ <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>
12
+ <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>
13
+ <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>
13
14
  </p>
14
15
 
15
16
  <p align="center">
16
- <img src="https://raw.githubusercontent.com/cortexkit/opencode-magic-context/master/packages/plugin/docs/animation/out/optimized2.gif" alt="Magic Context in action" width="720">
17
+ Available for <a href="https://github.com/anomalyco/opencode">OpenCode</a> and the <a href="https://github.com/mariozechner/pi-mono">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
+ </p>
19
+
20
+ <p align="center">
21
+ <img src="https://raw.githubusercontent.com/cortexkit/magic-context/master/packages/plugin/docs/animation/out/optimized2.gif" alt="Magic Context in action" width="720">
17
22
  </p>
18
23
 
19
24
  <p align="center">
@@ -62,7 +67,7 @@ Keep using the **same session** for **weeks**, **months**, or even **years**. **
62
67
 
63
68
  ### 🧪 New Experimental Features
64
69
 
65
- **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/opencode-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`.
70
+ **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`.
66
71
 
67
72
  **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`.
68
73
 
@@ -80,12 +85,12 @@ Run the interactive setup wizard — it detects your models, configures everythi
80
85
 
81
86
  **macOS / Linux:**
82
87
  ```bash
83
- curl -fsSL https://raw.githubusercontent.com/cortexkit/opencode-magic-context/master/scripts/install.sh | bash
88
+ curl -fsSL https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/install.sh | bash
84
89
  ```
85
90
 
86
91
  **Windows (PowerShell):**
87
92
  ```powershell
88
- irm https://raw.githubusercontent.com/cortexkit/opencode-magic-context/master/scripts/install.ps1 | iex
93
+ irm https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/install.ps1 | iex
89
94
  ```
90
95
 
91
96
  **Or run directly (any OS):**
@@ -119,7 +124,7 @@ Create `magic-context.jsonc` in your project root, `.opencode/`, or `~/.config/o
119
124
 
120
125
  ```jsonc
121
126
  {
122
- "$schema": "https://raw.githubusercontent.com/cortexkit/opencode-magic-context/master/assets/magic-context.schema.json",
127
+ "$schema": "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
123
128
  "enabled": true,
124
129
 
125
130
  // Which model the historian uses for background compression,
@@ -175,6 +180,27 @@ bunx --bun @cortexkit/opencode-magic-context@latest doctor --issue
175
180
 
176
181
  ---
177
182
 
183
+ ## Pi coding agent (beta)
184
+
185
+ Magic Context is also available as a [Pi](https://github.com/mariozechner/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.
186
+
187
+ > ⚠️ 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).
188
+
189
+ ```bash
190
+ # Setup wizard for Pi (analogous to the OpenCode flow above)
191
+ bunx --bun @cortexkit/pi-magic-context@latest setup
192
+ ```
193
+
194
+ 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).
195
+
196
+ For health checks:
197
+
198
+ ```bash
199
+ bunx --bun @cortexkit/pi-magic-context@latest doctor
200
+ ```
201
+
202
+ ---
203
+
178
204
  ## What Your Agent Gets
179
205
 
180
206
  Magic Context injects structured context automatically and gives the agent five tools.
@@ -353,7 +379,7 @@ On startup, Magic Context checks for common configuration problems — OpenCode'
353
379
  A companion desktop app for browsing and managing Magic Context state outside of OpenCode.
354
380
 
355
381
  <p align="center">
356
- <a href="https://github.com/cortexkit/opencode-magic-context/releases/tag/dashboard-v0.3.4"><strong>⬇️ Download for macOS · Windows · Linux</strong></a></p>
382
+ <a href="https://github.com/cortexkit/magic-context/releases/tag/dashboard-v0.3.4"><strong>⬇️ Download for macOS · Windows · Linux</strong></a></p>
357
383
 
358
384
  **Features:**
359
385
  - **Memory Browser** — search, filter, and edit project memories with category and project filtering
@@ -413,11 +439,11 @@ All durable states live in a local SQLite database. If the database can't be ope
413
439
 
414
440
  ## Star History
415
441
 
416
- <a href="https://www.star-history.com/?repos=cortexkit%2Fopencode-magic-context&type=date&legend=bottom-right">
442
+ <a href="https://www.star-history.com/?repos=cortexkit%2Fmagic-context&type=date&legend=bottom-right">
417
443
  <picture>
418
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=cortexkit/opencode-magic-context&type=date&theme=dark&legend=top-left" />
419
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=cortexkit/opencode-magic-context&type=date&legend=top-left" />
420
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=cortexkit/opencode-magic-context&type=date&legend=top-left" />
444
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=cortexkit/magic-context&type=date&theme=dark&legend=top-left" />
445
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=cortexkit/magic-context&type=date&legend=top-left" />
446
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=cortexkit/magic-context&type=date&legend=top-left" />
421
447
  </picture>
422
448
  </a>
423
449
 
@@ -1,14 +1,3 @@
1
- /**
2
- * Per-agent magic context system prompt sections.
3
- * Each agent gets tailored guidance based on its workflow patterns.
4
- */
5
- type AgentType = "sisyphus" | "atlas" | "hephaestus" | "sisyphus-junior" | "oracle" | "athena" | "athena-junior";
6
- /**
7
- * Detect which agent is active by scanning the system prompt for known signatures.
8
- * Returns the detected agent type or null for unknown agents.
9
- * Order matters — more specific signatures (e.g., "Sisyphus-Junior") are checked first.
10
- */
11
- export declare function detectAgentFromSystemPrompt(systemPrompt: string): AgentType | null;
12
- export declare function buildMagicContextSection(agent: AgentType | null, protectedTags: number, ctxReduceEnabled?: boolean, dreamerEnabled?: boolean, dropToolStructure?: boolean, temporalAwarenessEnabled?: boolean): string;
13
- export {};
1
+ /** Generic magic context system prompt section shared by all agents. */
2
+ export declare function buildMagicContextSection(_agent: string | null, protectedTags: number, ctxReduceEnabled?: boolean, dreamerEnabled?: boolean, dropToolStructure?: boolean, temporalAwarenessEnabled?: boolean, cavemanTextCompressionEnabled?: boolean): string;
14
3
  //# sourceMappingURL=magic-context-prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,SAAS,GACR,UAAU,GACV,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,eAAe,CAAC;AA4MtB;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOlF;AAID,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,aAAa,EAAE,MAAM,EACrB,gBAAgB,UAAO,EACvB,cAAc,UAAQ,EACtB,iBAAiB,UAAO,EACxB,wBAAwB,UAAQ,GACjC,MAAM,CAWR"}
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 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/cli/diagnostics.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,gBAAgB,CAAC;AAMrE,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IA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E,MAAM,GAAG,IAAI,CAAC;IAC/B,kDAAkD;IAClD,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,2CAA2C;IAC3C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kGAAkG;IAClG,eAAe,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,mBAAmB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;CACzB;AA6RD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAgDpE;AASD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA8E1E"}
@@ -0,0 +1,70 @@
1
+ import type { Database as DatabaseType } from "../shared/sqlite";
2
+ export interface MigrateOpenCodeSessionToPiOptions {
3
+ /**
4
+ * OpenCode source DB handle. Read-only operations: session, message,
5
+ * part rows. Owns nothing about Magic Context state — that lives in
6
+ * the cortexkit DB below.
7
+ */
8
+ db?: DatabaseLike;
9
+ /**
10
+ * Magic Context shared-DB handle (`~/.local/share/cortexkit/magic-context/context.db`).
11
+ * The migrator reads source compartments + facts under
12
+ * `harness='opencode'` keyed by source session_id and writes copies
13
+ * keyed by the new Pi session_id under `harness='pi'`. When omitted,
14
+ * the migrator opens the canonical path read-write.
15
+ *
16
+ * Pass `null` explicitly to skip the cortexkit copy entirely (the
17
+ * legacy V1 behavior — JSONL only).
18
+ */
19
+ cortexkitDb?: DatabaseLike | null;
20
+ fs?: FileSystemLike;
21
+ now?: Date;
22
+ sessionId: string;
23
+ maxMessages?: number;
24
+ dryRun?: boolean;
25
+ opencodeDbPath?: string;
26
+ piSessionsRoot?: string;
27
+ provider?: string;
28
+ modelId?: string;
29
+ }
30
+ export interface MigrationResult {
31
+ outputPath: string;
32
+ piSessionId: string;
33
+ messageCount: number;
34
+ byteCount: number;
35
+ sourceMessageCount: number;
36
+ /** Number of OpenCode compartments copied to the new Pi session_id. */
37
+ compartmentsCopied: number;
38
+ /** Number of OpenCode session_facts copied to the new Pi session_id. */
39
+ factsCopied: number;
40
+ /** Number of compartment boundaries that were nearest-at-or-before remapped (vs exact match). */
41
+ boundariesApproximated: number;
42
+ compactionMarkerWritten: boolean;
43
+ compactionBoundaryEntryId?: string;
44
+ compactionFirstKeptEntryId?: string;
45
+ dryRun: boolean;
46
+ }
47
+ export interface MigrateCliOptions {
48
+ from?: string;
49
+ to?: string;
50
+ session?: string;
51
+ maxMessages?: number;
52
+ dryRun?: boolean;
53
+ }
54
+ type DatabaseLike = Pick<DatabaseType, "prepare" | "close" | "exec">;
55
+ type FileSystemLike = {
56
+ existsSync(path: string): boolean;
57
+ mkdirSync(path: string, options?: {
58
+ recursive?: boolean;
59
+ }): unknown;
60
+ writeFileSync(path: string, data: string): unknown;
61
+ };
62
+ export declare function projectPathToPiDirSlug(projectPath: string): string;
63
+ export declare function formatPiFilenameTimestamp(date: Date): string;
64
+ export declare function generateUuidV7(date?: Date): string;
65
+ export declare function migrateOpenCodeSessionToPi(opts: MigrateOpenCodeSessionToPiOptions): MigrationResult;
66
+ export declare function parseMigrateArgs(args: string[]): MigrateCliOptions;
67
+ export declare function printMigrateHelp(): void;
68
+ export declare function runMigrateCli(args: string[]): Promise<number>;
69
+ export {};
70
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/cli/migrate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGjE,MAAM,WAAW,iCAAiC;IAC9C;;;;OAIG;IACH,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB;;;;;;;;;OASG;IACH,WA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