@cortexkit/opencode-magic-context 0.4.2 → 0.5.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 (35) hide show
  1. package/README.md +41 -0
  2. package/dist/cli/config-paths.d.ts +2 -0
  3. package/dist/cli/config-paths.d.ts.map +1 -1
  4. package/dist/cli/doctor.d.ts +2 -0
  5. package/dist/cli/doctor.d.ts.map +1 -0
  6. package/dist/cli/setup.d.ts.map +1 -1
  7. package/dist/cli.js +8549 -125
  8. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  9. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  10. package/dist/features/magic-context/scheduler.d.ts.map +1 -1
  11. package/dist/features/magic-context/search.d.ts +2 -0
  12. package/dist/features/magic-context/search.d.ts.map +1 -1
  13. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  14. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +8653 -238
  20. package/dist/plugin/conflict-warning-hook.d.ts +24 -0
  21. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -0
  22. package/dist/shared/conflict-detector.d.ts +29 -0
  23. package/dist/shared/conflict-detector.d.ts.map +1 -0
  24. package/dist/shared/conflict-fixer.d.ts +3 -0
  25. package/dist/shared/conflict-fixer.d.ts.map +1 -0
  26. package/dist/shared/tui-config.d.ts +10 -0
  27. package/dist/shared/tui-config.d.ts.map +1 -0
  28. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  29. package/dist/tui/data/context-db.d.ts +54 -0
  30. package/dist/tui/data/context-db.d.ts.map +1 -0
  31. package/package.json +20 -1
  32. package/src/tui/data/context-db.ts +584 -0
  33. package/src/tui/index.tsx +461 -0
  34. package/src/tui/slots/sidebar-content.tsx +422 -0
  35. package/src/tui/types/opencode-plugin-tui.d.ts +232 -0
package/README.md CHANGED
@@ -37,6 +37,8 @@ Your agent should never stop working to manage its own context. Magic Context is
37
37
 
38
38
  **4.** On-demand sidekick that augments prompts with relevant project context.
39
39
 
40
+ **5.** TUI sidebar with live context breakdown, token usage, historian status, and memory counts — right inside the terminal.
41
+
40
42
  ---
41
43
 
42
44
  ## Get Started
@@ -86,6 +88,7 @@ Create `magic-context.jsonc` in your project root, `.opencode/`, or `~/.config/o
86
88
 
87
89
  ```jsonc
88
90
  {
91
+ "$schema": "https://raw.githubusercontent.com/cortexkit/opencode-magic-context/master/assets/magic-context.schema.json",
89
92
  "enabled": true,
90
93
 
91
94
  // Which model the historian uses for background compression,
@@ -97,6 +100,8 @@ Create `magic-context.jsonc` in your project root, `.opencode/`, or `~/.config/o
97
100
  }
98
101
  ```
99
102
 
103
+ > **Tip:** The `$schema` key enables autocomplete and validation in VS Code and other editors.
104
+
100
105
  That's it. Everything else has sensible defaults. Project config merges on top of user-wide settings.
101
106
 
102
107
  ### Oh-My-OpenCode / Oh-My-OpenAgent Users
@@ -115,6 +120,16 @@ If you use [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) (f
115
120
 
116
121
  The setup wizard handles this automatically if it detects an oh-my-openagent or oh-my-opencode config.
117
122
 
123
+ ### Doctor (Troubleshooting)
124
+
125
+ Already installed but something isn't working? Run the doctor to check and auto-fix configuration issues:
126
+
127
+ ```bash
128
+ bunx @cortexkit/opencode-magic-context doctor
129
+ ```
130
+
131
+ Doctor checks for conflicts (compaction, DCP, OMO hooks), ensures the TUI sidebar is configured, and verifies the plugin is registered — fixing what it can automatically.
132
+
118
133
  ---
119
134
 
120
135
  ## What Your Agent Gets
@@ -243,6 +258,30 @@ The dreamer runs during a configurable schedule window and creates ephemeral Ope
243
258
 
244
259
  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.
245
260
 
261
+ ### TUI Sidebar
262
+
263
+ When running in OpenCode's terminal UI, Magic Context shows a live sidebar panel with:
264
+
265
+ - **Context breakdown bar** — visual token split across System Prompt, Compartments, Facts, Memories, and Conversation
266
+ - **Historian status** — idle, running, or compartment/fact counts
267
+ - **Memory counts** — total project memories and how many are injected
268
+ - **Dreamer status** — last run time
269
+ - **Queue status** — pending operations count
270
+
271
+ The sidebar updates after every message. Commands (`/ctx-status`, `/ctx-flush`, `/ctx-aug`) also work directly in TUI mode via dialogs and toasts.
272
+
273
+ 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`:
274
+
275
+ ```jsonc
276
+ {
277
+ "plugin": ["@cortexkit/opencode-magic-context"]
278
+ }
279
+ ```
280
+
281
+ ### Startup conflict detection
282
+
283
+ 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 `bunx @cortexkit/opencode-magic-context doctor`.
284
+
246
285
  ---
247
286
 
248
287
  ## Commands
@@ -290,6 +329,8 @@ All durable states live in a local SQLite database. If the database can't be ope
290
329
  | `memory_embeddings` | Embedding vectors for semantic search |
291
330
  | `dream_state` | Dreamer lease locking and task progress |
292
331
  | `dream_queue` | Queued projects awaiting dream processing |
332
+ | `dream_runs` | Per-project dream run history — task names, durations, memory changes |
333
+ | `compression_depth` | Per-message compression depth for weighted compressor selection |
293
334
  | `message_history_fts` | FTS5 index of user/assistant message text for `ctx_search` |
294
335
  | `message_history_index` | Tracks last indexed ordinal per session for incremental FTS population |
295
336
  | `recomp_compartments` | Staging for `/ctx-recomp` partial progress |
@@ -4,6 +4,8 @@ export interface ConfigPaths {
4
4
  opencodeConfigFormat: "json" | "jsonc" | "none";
5
5
  magicContextConfig: string;
6
6
  omoConfig: string | null;
7
+ tuiConfig: string;
8
+ tuiConfigFormat: "json" | "jsonc" | "none";
7
9
  }
8
10
  export declare function detectConfigPaths(): ConfigPaths;
9
11
  //# sourceMappingURL=config-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-paths.d.ts","sourceRoot":"","sources":["../../src/cli/config-paths.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAChD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AA8BD,wBAAgB,iBAAiB,IAAI,WAAW,CA2B/C"}
1
+ {"version":3,"file":"config-paths.d.ts","sourceRoot":"","sources":["../../src/cli/config-paths.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAChD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAC9C;AA8BD,wBAAgB,iBAAiB,IAAI,WAAW,CA6C/C"}
@@ -0,0 +1,2 @@
1
+ export declare function runDoctor(): Promise<number>;
2
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAWA,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAwHjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AAgMA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CA6MhD"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AA4JA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAyPhD"}