@cortexkit/pi-magic-context 0.35.0 → 0.36.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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Magic Context — Pi extension
1
+ # Magic Context — Pi / OMP extension
2
2
 
3
- Cross-session memory and context management for [Pi coding agent](https://github.com/earendil-works/pi-mono). Shares the same SQLite database as the [OpenCode plugin](https://www.npmjs.com/package/@cortexkit/opencode-magic-context), so memories, embeddings, dreamer state, and project knowledge follow you across both harnesses.
3
+ Cross-session memory and context management for [Pi coding agent](https://github.com/earendil-works/pi-mono) and [Oh My Pi (OMP)](https://github.com/can1357/oh-my-pi). The same extension package runs on both hosts and shares its SQLite database with the [OpenCode plugin](https://www.npmjs.com/package/@cortexkit/opencode-magic-context).
4
4
 
5
- Requires `@earendil-works/pi-coding-agent` and `@earendil-works/pi-tui` `>= 0.74.0`.
5
+ Requires Pi `>= 0.74.0` or OMP `>= 17.1.7`.
6
6
 
7
7
  ---
8
8
 
@@ -34,7 +34,7 @@ npx @cortexkit/magic-context@latest setup --harness pi
34
34
 
35
35
  This handles everything for you:
36
36
  1. Adds `npm:@cortexkit/pi-magic-context` to Pi's `packages` array in `~/.pi/agent/settings.json` (the same place `pi install` writes to)
37
- 2. Creates `~/.pi/agent/magic-context.jsonc` with defaults
37
+ 2. Creates `~/.config/cortexkit/magic-context.jsonc` with defaults
38
38
  3. Prompts you for historian, dreamer, sidekick, and embedding model choices
39
39
  4. Warns about provider-specific gotchas (e.g. GitHub Copilot reasoning models need an explicit `thinking_level`)
40
40
 
@@ -44,7 +44,7 @@ If you'd rather register the Pi extension package directly with Pi (skipping the
44
44
  pi install npm:@cortexkit/pi-magic-context
45
45
  ```
46
46
 
47
- This adds the extension to `~/.pi/agent/settings.json` but won't write `magic-context.jsonc` for you — you'll need to create it manually (see Configuration below).
47
+ This adds the extension to `~/.pi/agent/settings.json` but won't write `magic-context.jsonc` for you — create the shared config manually at `~/.config/cortexkit/magic-context.jsonc` (see Configuration below).
48
48
 
49
49
  To check installation health later:
50
50
 
@@ -52,16 +52,40 @@ To check installation health later:
52
52
  npx @cortexkit/magic-context@latest doctor --harness pi
53
53
  ```
54
54
 
55
+ ### Oh My Pi (OMP)
56
+
57
+ Use the OMP-specific setup path. It installs the package through OMP's plugin manager, disables OMP native compaction and automatic memory to prevent duplicate context managers, and verifies the effective project plugin state:
58
+
59
+ ```bash
60
+ npx @cortexkit/magic-context@latest setup --harness omp
61
+ ```
62
+
63
+ Manual installation is also supported:
64
+
65
+ ```bash
66
+ omp plugin install @cortexkit/pi-magic-context
67
+ omp config set compaction.enabled false
68
+ omp config set memory.backend off
69
+ ```
70
+
71
+ Verify with:
72
+
73
+ ```bash
74
+ npx @cortexkit/magic-context@latest doctor --harness omp
75
+ ```
76
+
77
+ OMP's legacy Pi loader maps `@earendil-works/*` imports to its bundled `@oh-my-pi/*` runtime. Magic Context also re-invokes the current host executable for historian, dreamer, and sidekick children, so OMP children remain OMP processes.
78
+
55
79
  ---
56
80
 
57
81
  ## Configuration
58
82
 
59
- Magic Context reads two config files (in this priority order):
83
+ Magic Context reads the shared CortexKit config (project overrides user):
60
84
 
61
- 1. `$cwd/.pi/magic-context.jsonc` (project-level overrides)
62
- 2. `~/.pi/agent/magic-context.jsonc` (user-level defaults)
85
+ 1. `$cwd/.cortexkit/magic-context.jsonc`
86
+ 2. `~/.config/cortexkit/magic-context.jsonc`
63
87
 
64
- Both are merged through a Zod schema. Invalid fields fall back to defaults — bad config never disables the plugin entirely.
88
+ Session discovery follows the active host. Relative `pi.subagent_extensions` are deliberately isolated by host: plain Pi resolves them from `~/.pi/agent`, while a positively identified OMP process uses `PI_CODING_AGENT_DIR` when set and otherwise derives the active `~/.omp` config/profile agent directory.
65
89
 
66
90
  ### Minimal config
67
91
 
@@ -78,7 +102,7 @@ Both are merged through a Zod schema. Invalid fields fall back to defaults — b
78
102
  }
79
103
  ```
80
104
 
81
- For the full configuration reference (including dreamer, sidekick, auto-search, and experimental features), see [CONFIGURATION.md](https://github.com/cortexkit/magic-context/blob/master/CONFIGURATION.md) in the main repository — the schema is shared between both plugins.
105
+ For the full configuration reference (including dreamer, sidekick, auto-search, and experimental features), see [CONFIGURATION.md](https://github.com/cortexkit/magic-context/blob/master/CONFIGURATION.md) in the main repository — OpenCode, Pi, and OMP share the same schema.
82
106
 
83
107
  ---
84
108
 
@@ -105,11 +129,11 @@ Magic Context stores everything in a single shared SQLite database at:
105
129
  ~/.local/share/cortexkit/magic-context/context.db
106
130
  ```
107
131
 
108
- This is the **same database** the OpenCode plugin uses. Tables are scoped by:
109
- - `harness` column (`'pi'` or `'opencode'`) for session-scoped data (tags, compartments, facts, notes)
132
+ This is the **same database** the OpenCode plugin and OMP extension use. Tables are scoped by:
133
+ - `harness` column (`'pi'` or `'opencode'`) for session-scoped data; OMP intentionally uses `'pi'`
110
134
  - `project_path` (resolved git root) for project-scoped data (memories, embeddings, dreamer runs)
111
135
 
112
- So memories and dreamer state are shared across both harnesses for the same project; per-session tagging stays correctly attributed.
136
+ Memories and dreamer state are shared across all three harnesses for the same project; per-session tagging stays correctly attributed.
113
137
 
114
138
  Storage failures are fatal — Magic Context will refuse to register hooks rather than run with ephemeral state, since that would let context grow unbounded across restarts.
115
139
 
@@ -117,7 +141,7 @@ Storage failures are fatal — Magic Context will refuse to register hooks rathe
117
141
 
118
142
  ## Cross-harness coherence
119
143
 
120
- For semantic search to work across harnesses, both plugins must use the **same embedding model**. Magic Context detects mismatch on Pi startup and warns:
144
+ For semantic search to work across harnesses, every host must use the **same embedding model**. Magic Context detects a mismatch on Pi or OMP startup and warns:
121
145
 
122
146
  ```
123
147
  WARN embedding model mismatch detected for project ...:
@@ -125,7 +149,7 @@ stored vectors use "openai-compatible:Qwen/Qwen3-Embedding-8B" but Pi is configu
125
149
  Cross-harness search will return zero results until vectors are re-embedded.
126
150
  ```
127
151
 
128
- Easiest fix: configure `embedding` once in `~/.pi/agent/magic-context.jsonc` (Pi) and `~/.config/opencode/magic-context.jsonc` (OpenCode) with identical settings.
152
+ Configure `embedding` once in the shared `~/.config/cortexkit/magic-context.jsonc`; OpenCode, Pi, and OMP all read it. Use `$cwd/.cortexkit/magic-context.jsonc` only when that project intentionally needs an override.
129
153
 
130
154
  ---
131
155
 
@@ -136,26 +160,28 @@ Easiest fix: configure `embedding` once in `~/.pi/agent/magic-context.jsonc` (Pi
136
160
  | `ctx_search` | n/a | Search memories + raw session history; returns ranked results with previews |
137
161
  | `ctx_memory` | `write`, `delete` | Manage project memories explicitly (most writes happen via dreamer instead) |
138
162
  | `ctx_note` | `read`, `write`, `update`, `dismiss` | Defer intentions for later — surfaced via note nudges at work boundaries |
163
+ | `ctx_expand` | `start`/`end`, `message`, `verbose` | Recover complete messages or expand a compressed conversation range |
164
+ | `ctx_reduce` | `drop` | Queue tagged turns for cache-safe removal from the live context |
139
165
 
140
- `ctx_expand` and `ctx_reduce` from the OpenCode plugin are **intentionally not exposed on Pi** — they depend on raw OpenCode message ordinals, while Pi has its own message identity model. Drops still happen automatically via threshold-driven historian; you don't need an explicit `ctx_reduce` to trigger reduction.
166
+ `ctx_note`, `ctx_expand`, and `ctx_reduce` are session-scoped and are exposed in primary Pi/OMP sessions. Magic Context omits them from ephemeral `--no-session` child processes, where they would otherwise target the hidden child session; `ctx_reduce` is additionally omitted when compaction is disabled.
141
167
 
142
168
  ---
143
169
 
144
170
  ## Architecture & implementation
145
171
 
146
- This package is part of the [magic-context monorepo](https://github.com/cortexkit/magic-context). The Pi extension shares the core implementation with the OpenCode plugin via the `@magic-context/core` workspace dependency, exposing only the Pi-specific adapter layer:
172
+ This package is part of the [magic-context monorepo](https://github.com/cortexkit/magic-context). Pi and OMP share the same adapter layer and core implementation:
147
173
 
148
174
  | Pi-specific module | Responsibility |
149
175
  |---|---|
150
176
  | `context-handler.ts` | Pi `pi.on("context", ...)` adapter — tags, drops, runs nudges and auto-search |
151
- | `subagent-runner.ts` | Spawns `pi --print --mode json --no-session ...` for historian/sidekick/dreamer subagents, keeps extension discovery on for provider/AFT extensions, sets `MAGIC_CONTEXT_PI_SUBAGENT=1` so the full Magic Context entry no-ops, and applies a per-agent `--tools`/`--no-tools` allow-list plus a 2-second terminal drain |
177
+ | `subagent-runner.ts` | Re-invokes the current Pi/OMP host with `--print --mode json --no-session`; resolves relative allowlisted extensions from plain Pi's `~/.pi/agent` or an identified OMP host's active agent directory; and applies per-agent tool isolation |
152
178
  | `tools/` | Pi `pi.registerTool` wrappers around the shared tool implementations |
153
179
  | `commands/` | Pi `pi.registerCommand` wrappers for the five `/ctx-*` slash commands |
154
180
  | `dreamer/` | Pi-side adapter for the shared dreamer scheduler |
155
181
  | `system-prompt.ts` | Pi `before_agent_start` injector for `<session-history>`, `<project-memory>`, `<project-docs>` |
156
- | `config/` | Pi-convention config loader (`$cwd/.pi/magic-context.jsonc` + `~/.pi/agent/magic-context.jsonc`) |
182
+ | `config/` | Shared CortexKit config loader with legacy Pi migration fallback |
157
183
 
158
- The CLI lives in the unified [`@cortexkit/magic-context`](https://www.npmjs.com/package/@cortexkit/magic-context) package — `setup --harness pi` and `doctor --harness pi` route to the Pi-specific code paths in `packages/cli/src/commands/`.
184
+ The unified [`@cortexkit/magic-context`](https://www.npmjs.com/package/@cortexkit/magic-context) CLI exposes separate `pi` and `omp` setup/doctor pipelines while both use this runtime adapter.
159
185
 
160
186
  For deeper architectural detail, see the main repo's [ARCHITECTURE.md](https://github.com/cortexkit/magic-context/blob/master/ARCHITECTURE.md).
161
187