@retaw106/mmc-pi 1.2.2 → 1.2.3

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 (3) hide show
  1. package/README.md +30 -96
  2. package/dist/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # Magic Context — Pi / OMP extension
1
+ # Magic Context — Pi extension (mmc)
2
2
 
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).
3
+ Cross-session memory and context management for the [Pi coding agent](https://github.com/earendil-works/pi-mono). The extension shares its SQLite database with the OpenCode 2 plugin [`@retaw106/mmc-oc`](https://www.npmjs.com/package/@retaw106/mmc-oc).
4
4
 
5
- Requires Pi `>= 0.74.0` or OMP `>= 17.1.7`.
5
+ This is the `moon-magic-context` fork of [magic-context](https://github.com/cortexkit/magic-context): the core transform pipeline, historian, and FTS5 memory retrieval only. The upstream embedding/semantic-search stack, dashboard, CLI, and OMP support are not part of this fork.
6
+
7
+ Requires `@earendil-works/pi-coding-agent` `>= 0.80.2`.
6
8
 
7
9
  ---
8
10
 
9
11
  ## What it does
10
12
 
11
- Magic Context is a context engine that keeps long Pi sessions productive by:
12
-
13
13
  | Feature | What it does |
14
14
  |---|---|
15
15
  | **Tagging + drops** | Tags every assistant/user/tool message with `§N§ ` so you can drop specific turns later via `mmc_reduce` |
16
16
  | **Historian** | Background subagent compresses old conversation into compartments + facts at threshold pressure or commit boundaries |
17
- | **`<session-history>` injection** | Prepends compressed history into the system prompt every turn so the agent never loses context |
18
- | **Project memories** | Persistent cross-session knowledge store with embedding-based semantic search |
17
+ | **`m[0]`/`m[1]` history injection** | Renders compressed history and project memories into two synthetic leading messages every turn so the agent never loses context — without busting the provider's prompt cache on stable turns |
18
+ | **Project memories** | Persistent cross-session knowledge store with FTS5 full-text search |
19
19
  | **Auto-search hint** | When user prompts mention previously-discussed topics, appends a compact memory hint |
20
20
  | **Cross-harness sharing** | Memories written from OpenCode appear in Pi (and vice versa) for the same project |
21
21
 
@@ -23,90 +23,41 @@ Magic Context is a context engine that keeps long Pi sessions productive by:
23
23
 
24
24
  ## Installation
25
25
 
26
- The fastest path is the unified Magic Context CLI — `--harness pi` selects the Pi-specific setup pipeline (registers the extension with Pi, writes a sensible `mmc.jsonc`, and verifies your model picks):
27
-
28
- ```bash
29
- npx @retaw106/mmc-oc@latest setup --harness pi
30
- ```
31
-
32
- This handles everything for you:
33
- 1. Adds `npm:@retaw106/mmc-pi` to Pi's `packages` array in `~/.pi/agent/settings.json` (the same place `pi install` writes to)
34
- 2. Creates `~/.pi/agent/mmc.jsonc` with defaults
35
- 3. Prompts you for historian and embedding model choices
36
- 4. Warns about provider-specific gotchas (e.g. GitHub Copilot reasoning models need an explicit `thinking_level`)
37
-
38
- If you'd rather register the Pi extension package directly with Pi (skipping the wizard), use Pi's own installer:
26
+ Install the published package with Pi's own installer:
39
27
 
40
28
  ```bash
41
29
  pi install npm:@retaw106/mmc-pi
42
30
  ```
43
31
 
44
- This adds the extension to `~/.pi/agent/settings.json` but won't write `mmc.jsonc` for you — create it manually at `~/.pi/agent/mmc.jsonc` (see Configuration below).
45
-
46
- To check installation health later:
47
-
48
- ```bash
49
- npx @retaw106/mmc-oc@latest doctor --harness pi
50
- ```
51
-
52
- ### Oh My Pi (OMP)
53
-
54
- 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:
55
-
56
- ```bash
57
- npx @retaw106/mmc-oc@latest setup --harness omp
58
- ```
59
-
60
- Manual installation is also supported:
32
+ This adds the extension to `~/.pi/agent/settings.json`. Then create the config file manually at `~/.pi/agent/mmc.jsonc` (see Configuration below) — the historian model is required, or no summarization ever happens.
61
33
 
62
- ```bash
63
- omp plugin install @retaw106/mmc-pi
64
- omp config set compaction.enabled false
65
- omp config set memory.backend off
66
- ```
67
-
68
- Verify with:
34
+ > There is no setup wizard and no `doctor` CLI in this fork. Configuration is a hand-edited `mmc.jsonc`; the upstream `npx … setup` / `doctor` commands do not exist here.
69
35
 
70
- ```bash
71
- npx @retaw106/mmc-oc@latest doctor --harness omp
72
- ```
73
-
74
- OMP's legacy Pi loader maps `@earendil-works/*` imports to its bundled `@oh-my-pi/*` runtime. Magic Context identifies OMP from `@oh-my-pi/pi-utils`'s in-process `APP_NAME` through the running host's module graph, not from an executable basename, so compiled and symlinked launches behave the same. It also re-invokes the current host executable for historian and dreamer children, so OMP children remain OMP processes.
36
+ To build from the monorepo instead (requires Bun `>= 1.4.0`): point Pi's `packages` array at `packages/pi-plugin` and run `bun run build` before starting Pi — the host loads the prebuilt `dist`.
75
37
 
76
38
  ---
77
39
 
78
40
  ## Configuration
79
41
 
80
- Magic Context reads the Pi host's own config (project overrides user):
42
+ mmc reads the Pi host's own config (project overrides user):
81
43
 
82
44
  1. `$cwd/.mmc/mmc.jsonc`
83
45
  2. `~/.pi/agent/mmc.jsonc`
84
46
 
85
- 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.
86
-
87
47
  ### Minimal config
88
48
 
89
49
  ```jsonc
90
50
  {
91
- "$schema": "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
92
51
  "enabled": true,
93
52
  "historian": {
94
53
  "pi": {
95
54
  "model": "anthropic/claude-haiku-4-5"
96
- },
97
- "omp": {
98
- "model": { "model": "opencode/claude-haiku-4-5", "thinking_level": "auto" }
99
55
  }
100
- },
101
- "embedding": {
102
- "provider": "local"
103
56
  }
104
57
  }
105
58
  ```
106
59
 
107
- OMP uses `historian.omp ?? historian.pi`; leaving the OMP block absent preserves existing Pi-compatible configuration. OMP supports `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, `inherit`, and `auto` thinking levels.
108
-
109
- For the full configuration reference (including 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.
60
+ For the full configuration reference, see `CONFIGURATION.md` in the monorepo root — OpenCode and Pi share the same schema (`assets/magic-context.schema.json`, regenerated by the plugin build).
110
61
 
111
62
  ---
112
63
 
@@ -125,42 +76,27 @@ All commands trigger `triggerTurn: false` (never sent to the LLM):
125
76
 
126
77
  ## Storage
127
78
 
128
- Magic Context stores everything in a single shared SQLite database at:
79
+ mmc stores everything in a single shared SQLite database at:
129
80
 
130
81
  ```
131
82
  ~/.local/share/mmc/context.db
132
83
  ```
133
84
 
134
85
  When a host isolates `XDG_DATA_HOME` per process, set
135
- `MMC_STORAGE_DIR` to the absolute, complete shared Magic Context
86
+ `MMC_STORAGE_DIR` to the absolute, complete shared mmc
136
87
  storage directory. The explicit path takes precedence over the XDG-derived path
137
88
  and does not change Pi's own configuration or session directories. The host must
138
- propagate one identical value to every process that shares the database; Magic
139
- Context never originates this variable from its default. This affects the
140
- harness-side database only, not `subc` daemon state. Mixed-version processes on
141
- one directory still block migrations until all processes use a compatible build.
89
+ propagate one identical value to every process that shares the database; mmc
90
+ never originates this variable from its default.
91
+ Mixed-version processes on one directory still block migrations until all processes use a compatible build.
142
92
 
143
- This is the **same database** the OpenCode plugin and OMP extension use. Tables are scoped by:
144
- - `harness` column (`'pi'` or `'opencode'`) for session-scoped data; OMP intentionally uses `'pi'`
145
- - `project_path` (resolved git root) for project-scoped data (memories, embeddings)
93
+ This is the **same database** the OpenCode 2 plugin uses. Tables are scoped by:
94
+ - `harness` column (`'pi'` or `'opencode2'`; legacy rows may carry `'opencode'`) for session-scoped data
95
+ - `project_path` (resolved git root) for project-scoped data (memories)
146
96
 
147
- Memories are shared across all three harnesses for the same project; per-session tagging stays correctly attributed.
97
+ Memories are shared across both harnesses for the same project; per-session tagging stays correctly attributed.
148
98
 
149
- 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.
150
-
151
- ---
152
-
153
- ## Cross-harness coherence
154
-
155
- 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:
156
-
157
- ```
158
- WARN embedding model mismatch detected for project ...:
159
- stored vectors use "openai-compatible:Qwen/Qwen3-Embedding-8B" but Pi is configured with "local:Xenova/all-MiniLM-L6-v2".
160
- Cross-harness search will return zero results until vectors are re-embedded.
161
- ```
162
-
163
- Configure `embedding` once in the shared `~/.config/mmc/mmc.jsonc`; OpenCode, Pi, and OMP all read it. Use `$cwd/.mmc/mmc.jsonc` only when that project intentionally needs an override.
99
+ Storage failures are fatal — mmc will refuse to register hooks rather than run with ephemeral state, since that would let context grow unbounded across restarts.
164
100
 
165
101
  ---
166
102
 
@@ -174,29 +110,27 @@ Configure `embedding` once in the shared `~/.config/mmc/mmc.jsonc`; OpenCode, Pi
174
110
  | `mmc_expand` | `start`/`end`, `message`, `verbose` | Recover complete messages or expand a compressed conversation range |
175
111
  | `mmc_reduce` | `drop` | Queue tagged turns for cache-safe removal from the live context |
176
112
 
177
- `mmc_note`, `mmc_expand`, and `mmc_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; `mmc_reduce` is additionally omitted when compaction is disabled.
113
+ `mmc_note`, `mmc_expand`, and `mmc_reduce` are session-scoped and are exposed in primary Pi sessions. mmc omits them from ephemeral `--no-session` child processes, where they would otherwise target the hidden child session; `mmc_reduce` is additionally omitted when compaction is disabled.
178
114
 
179
115
  ---
180
116
 
181
117
  ## Architecture & implementation
182
118
 
183
- 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:
119
+ This package is part of the moon-magic-context monorepo (`packages/pi-plugin`). Pi shares the adapter layer and core implementation with the OpenCode 2 plugin:
184
120
 
185
121
  | Pi-specific module | Responsibility |
186
122
  |---|---|
187
123
  | `context-handler.ts` | Pi `pi.on("context", ...)` adapter — tags, drops, runs nudges and auto-search |
188
- | `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 |
124
+ | `subagent-runner.ts` | Re-invokes the Pi host with `--print --mode json --no-session` for hidden child sessions, with per-agent tool isolation |
189
125
  | `tools/` | Pi `pi.registerTool` wrappers around the shared tool implementations |
190
126
  | `commands/` | Pi `pi.registerCommand` wrappers for the four `/mmc-*` slash commands |
191
- | `system-prompt.ts` | Pi `before_agent_start` injector for the `## Magic Context` guidance block and sticky date (v2 never emits data blocks such as `<project-docs>`/`<user-profile>`/`<key-files>`) |
192
- | `config/` | Shared MMC config loader with legacy Pi migration fallback |
193
-
194
- The unified [`@retaw106/mmc-oc`](https://www.npmjs.com/package/@retaw106%2Fmmc-oc) CLI exposes separate `pi` and `omp` setup/doctor pipelines while both use this runtime adapter.
127
+ | `system-prompt.ts` | Pi `before_agent_start` injector for the `## Magic Context` guidance block and sticky date |
128
+ | `config/` | Fork copy of the plugin config loader (divergences from the shared loader are registered in the monorepo root `UPSTREAM.md`) |
195
129
 
196
- For deeper architectural detail, see the main repo's [ARCHITECTURE.md](https://github.com/cortexkit/magic-context/blob/master/ARCHITECTURE.md).
130
+ The OpenCode 2 plugin [`@retaw106/mmc-oc`](https://www.npmjs.com/package/@retaw106/mmc-oc) lives in the same monorepo (`packages/plugin`). For deeper architectural detail, see `ARCHITECTURE.md` in the monorepo root.
197
131
 
198
132
  ---
199
133
 
200
134
  ## License
201
135
 
202
- MIT — see [LICENSE](https://github.com/cortexkit/magic-context/blob/master/LICENSE).
136
+ MIT — see `LICENSE` in the monorepo root.
package/dist/index.js CHANGED
@@ -48717,7 +48717,7 @@ function buildStatusViewFor(check, options) {
48717
48717
  // package.json
48718
48718
  var package_default = {
48719
48719
  name: "@retaw106/mmc-pi",
48720
- version: "1.2.2",
48720
+ version: "1.2.3",
48721
48721
  type: "module",
48722
48722
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
48723
48723
  main: "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retaw106/mmc-pi",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",