pi-mega-compact 0.11.10 → 0.11.11
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 +36 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,15 +6,19 @@ A local context compressor for the [pi coding agent](https://github.com/earendil
|
|
|
6
6
|
|
|
7
7
|
- **Auto-compaction** — the store watches context pressure and compacts quietly in the background. You'll notice when a long session just stays long while the token gauge rests comfortably far from the ceiling.
|
|
8
8
|
- **Two-layer compaction** — every LLM call sees a live trim of the context window, and every trim is checkpointed to SQLite so a crash or a `/clear` never loses the work.
|
|
9
|
-
- **Semantic dedup, three layers deep** — exact hash
|
|
10
|
-
- **RAPTOR memory hierarchy** — decisions you made an hour ago don't scroll off; they get packed up as hierarchical checkpoints and re-inlined the moment your next session asks for them. Multi-level retrieval (leaves + summary clusters) is on by default
|
|
9
|
+
- **Semantic dedup, three layers deep** — exact hash (L0) -> MinHash/LSH (L1) -> cosine over trigram embeddings (L2). The dedup audit log records per-tier decisions with similarity scores for tuning.
|
|
10
|
+
- **RAPTOR memory hierarchy** — decisions you made an hour ago don't scroll off; they get packed up as hierarchical checkpoints and re-inlined the moment your next session asks for them. Multi-level retrieval (leaves + summary clusters) is on by default. Since v0.11.10, RAPTOR tree updates are incremental (no full rebuild) — enabled by default.
|
|
11
11
|
- **Per-turn tracking + rewind.** Every turn, checkpoint, and recall hit lands as a row in an isolated `turns.db` — `turns`, `turn_recall`, `conversation_forks`. The dashboard **Turns tab** shows turn-by-turn memory: context pressure, the compact epoch that superseded each turn, and the exact checkpoints recalled into it. A **fork** action branches a conversation at any turn (carrying its recall set); a **rewind** action queues an intent the host consumes at the next `before_agent_start`. The `TurnStore` is contract-first (capability-gated reader/writer/admin views) so the same spine backs the dashboard, the TUI, or an API gateway.
|
|
12
|
-
- **Cross-repo recall** — doors
|
|
13
|
-
- **Durable memory** —
|
|
12
|
+
- **Cross-repo recall** — doors you close in one repo don't reopen when you move to another. A decision stored while hacking repo A is a recall hit the next time you're in repo B.
|
|
13
|
+
- **Durable memory** — on a cadence the store auto-reviews and safe-keeps decisions, facts, and preferences as first-class RAG memories, so long-running projects remember what mattered.
|
|
14
|
+
- **Prompt-cache optimization** — message separation + cache striping (default OFF, opt-in). Targets 82-90% cache hit rate by structuring context around provider cache boundaries. Enables with `MEGACOMPACT_MESSAGE_SEPARATION` and `MEGACOMPACT_CACHE_STRIPING`.
|
|
15
|
+
- **RAG suite** — query reformulation (TF-IDF + RRF), tiered routing (L0 cache -> L1 FTS5 -> L2 PGlite), and recall-quality metrics (CRAG). All default OFF, opt-in via flags `MEGACOMPACT_QUERY_REFORMULATION`, `MEGACOMPACT_TIERED_ROUTER`, `MEGACOMPACT_RECALL_METRICS`.
|
|
16
|
+
- **Stacked memory graph** — the dashboard shows memory composition over time from 3 content sources (turns, durable memories, wiki) with a 9-gate validation system and a graph-health indicator. Per-model provider cache breakdown in the Cache tab.
|
|
17
|
+
- **Debug bundle** — Maintenance tab in the dashboard has a **Gather Debug Logs** button that collects events, config, and store state into a shareable archive for bug reports.
|
|
14
18
|
- **Fully local** — node:sqlite + trigram embeddings by default. Bring your own localhost embedder (ONNX, Ollama, TEI) for better semantic matches. Zero calls off your machine except the optional, localhost-only dashboard.
|
|
15
19
|
- **Team-run aware** — fine-grained durable trim fires at agent settle during sub-agent runs, so long multi-agent work doesn't just collapse at the end.
|
|
16
|
-
- **Multi-pi dashboard** — one dashboard tab per active pi process with the context stack, per-repo stats, and a live SSE feed across all of them. The React SPA
|
|
17
|
-
- **Auto-categorizing wiki.** Every
|
|
20
|
+
- **Multi-pi dashboard** — one dashboard tab per active pi process with the context stack, per-repo stats, and a live SSE feed across all of them. The React SPA has lazy-loaded tabs: Overview, Repos, Events, Config, Metrics, Cache, Game, Achievements, Sessions, Topics (wiki), Turns (per-turn memory + recall + rewind), and Maintenance (debug bundle).
|
|
21
|
+
- **Auto-categorizing wiki.** Every 3 compactions (seeds from turns before that), the store clusters your real memory embeddings (k-means) and labels each cluster with its most discriminative terms (TF-IDF) — no LLM, no Ollama, fully local. The dashboard **Wiki tab** browses topics, searches by label or term, and drills down into the member memories of each cluster.
|
|
18
22
|
|
|
19
23
|
## Install
|
|
20
24
|
|
|
@@ -22,7 +26,7 @@ A local context compressor for the [pi coding agent](https://github.com/earendil
|
|
|
22
26
|
pi install npm:pi-mega-compact
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
That's it.
|
|
29
|
+
That's it. **`pi update --extensions`** pulls updates going forward. npm is the only distribution path — never use `.tgz` tarballs or symlinks for shipping.
|
|
26
30
|
|
|
27
31
|
<details>
|
|
28
32
|
<summary>From source (development)</summary>
|
|
@@ -48,6 +52,7 @@ Key commands:
|
|
|
48
52
|
- `/mega-recall [query]` — semantic search the store, `--cross-repo` for all repos
|
|
49
53
|
- `/mega-memory save|list|search|forget` — manage durable memories
|
|
50
54
|
- `/mega-dashboard` — start the localhost dashboard
|
|
55
|
+
- `/mega-setup` — embedding wizard: detects Ollama/llama.cpp, suggests upgrades when recall quality is low
|
|
51
56
|
|
|
52
57
|
Full command reference: [`docs/COMMANDS.md`](docs/COMMANDS.md)
|
|
53
58
|
|
|
@@ -62,7 +67,15 @@ Set env vars before starting pi. Defaults are in `src/config/dedup.ts`.
|
|
|
62
67
|
| `MEGACOMPACT_DEDUP_SIM` | `0.90` | Cosine threshold for near-dup collapse |
|
|
63
68
|
| `MEGACOMPACT_CROSSREPO_ENABLED` | `true` | Cross-repo recall on resume |
|
|
64
69
|
| `MEGACOMPACT_EMBEDDING_URL` | _(unset)_ | BYO localhost embedder endpoint |
|
|
65
|
-
| `MEGACOMPACT_TUI_WIDGET` | `true` | Render the above-editor panel
|
|
70
|
+
| `MEGACOMPACT_TUI_WIDGET` | `true` | Render the above-editor panel |
|
|
71
|
+
| `MEGACOMPACT_MESSAGE_SEPARATION` | `false` | Opt-in: separate messages at provider cache boundaries |
|
|
72
|
+
| `MEGACOMPACT_CACHE_STRIPING` | `false` | Opt-in: stripe cache stripes across conversation |
|
|
73
|
+
| `MEGACOMPACT_QUERY_REFORMULATION` | `false` | Opt-in: TF-IDF + RRF query reformulation |
|
|
74
|
+
| `MEGACOMPACT_TIERED_ROUTER` | `false` | Opt-in: L0->L1->L2 recall routing |
|
|
75
|
+
| `MEGACOMPACT_RECALL_METRICS` | `false` | Opt-in: CRAG recall quality metrics |
|
|
76
|
+
| `MEGACOMPACT_MEMORY_GRAPH_SEED_TURNS` | `true` | Seed memory graph from turns (default ON) |
|
|
77
|
+
| `MEGACOMPACT_WIKI_SEED_FROM_TURNS` | `true` | Seed wiki from turns (default ON) |
|
|
78
|
+
| `MEGACOMPACT_RAPTOR_INCREMENTAL` | `true` | Incremental RAPTOR updates (default ON) |
|
|
66
79
|
|
|
67
80
|
Full config reference: [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md)
|
|
68
81
|
|
|
@@ -70,11 +83,11 @@ Full config reference: [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md)
|
|
|
70
83
|
|
|
71
84
|
```
|
|
72
85
|
extensions/ Pi entry points (mega-compact, mega-trim, dashboard)
|
|
73
|
-
src/engine.ts Trident pipeline (supersede
|
|
86
|
+
src/engine.ts Trident pipeline (supersede -> collapse -> cluster)
|
|
74
87
|
src/vectorStore.ts Local vector DB (add/search/dedupe)
|
|
75
88
|
src/compact.ts Summarize / merge / auto-compact
|
|
76
89
|
src/memory.ts Durable memories + auto-review
|
|
77
|
-
src/store/sqlite.ts node:sqlite store (Node
|
|
90
|
+
src/store/sqlite.ts node:sqlite store (Node >=22.13)
|
|
78
91
|
src/store/vectorIndex.ts PGlite/HNSW cross-repo index
|
|
79
92
|
```
|
|
80
93
|
|
|
@@ -84,12 +97,22 @@ Detailed architecture: [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md)
|
|
|
84
97
|
|
|
85
98
|
```bash
|
|
86
99
|
npm run build # TypeScript compile
|
|
87
|
-
npm test # Build +
|
|
100
|
+
npm test # Build + 1112 tests
|
|
88
101
|
npm run lint # Type check + guardrails scan
|
|
89
102
|
```
|
|
90
103
|
|
|
91
104
|
Testing guide: [`TESTER_GUIDE.md`](TESTER_GUIDE.md)
|
|
92
105
|
|
|
106
|
+
## Tester requests
|
|
107
|
+
|
|
108
|
+
These areas benefit from real-world usage data. The automated test suite covers correctness, but tuning requires diverse sessions.
|
|
109
|
+
|
|
110
|
+
- **Cosine threshold validation** — the 0.90 dedup threshold may need adjustment per content type (try 0.93 for code, 0.87 for prose). Run with `MEGACOMPACT_DEDUP_SIM` set to different values and report false positives via the debug bundle (Maintenance -> Gather Debug Logs). The dedup audit log (events.log) records `similarityScore` + `matchedId` per decision.
|
|
111
|
+
- **Cross-repo recall quality** — enable cross-repo recall and report the relevance-vs-noise ratio from real multi-repo sessions. The Turns tab shows recall hits per turn.
|
|
112
|
+
- **Dedup layer audit** — is MinHash/LSH (L1) catching enough over exact-hash (L0) + cosine (L2) to justify the complexity? If L1 catches <5% additional in your sessions, we may simplify to 2-layer. The dedup audit log has per-tier decisions.
|
|
113
|
+
- **Compaction death-spiral** — v0.11.9 fixed an "Already compacted" loop that made sessions unrecoverable (critical-over escape hatch forces a trim + durable compact at >=90% context). If you see this recur, report it immediately with the debug bundle.
|
|
114
|
+
- **Share debug bundles** — when reporting any issue, first gather from Maintenance -> Gather Debug Logs and include the archive.
|
|
115
|
+
|
|
93
116
|
## Troubleshooting
|
|
94
117
|
|
|
95
118
|
### npm lifecycle scripts disabled
|
|
@@ -107,7 +130,7 @@ npm install --install-strategy=linked
|
|
|
107
130
|
|
|
108
131
|
### node:sqlite not found / experimental flag required
|
|
109
132
|
|
|
110
|
-
pi-mega-compact requires Node
|
|
133
|
+
pi-mega-compact requires Node >=22.13 for the built-in `node:sqlite` module. If you're on an older version or your Node build doesn't include it by default:
|
|
111
134
|
|
|
112
135
|
```bash
|
|
113
136
|
export NODE_OPTIONS="--experimental-sqlite"
|
|
@@ -120,7 +143,7 @@ Add the export to your shell profile (`.bashrc`, `.zshrc`, etc.) to make it perm
|
|
|
120
143
|
|
|
121
144
|
BSD 3-Clause
|
|
122
145
|
|
|
123
|
-
##
|
|
146
|
+
## Support
|
|
124
147
|
|
|
125
148
|
If this project helped you, consider buying me a coffee:
|
|
126
149
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-mega-compact",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
4
|
"description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSD-3-Clause",
|