@pi-unipi/unipi 2.0.3 → 2.0.5
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 +4 -4
- package/package.json +2 -2
- package/packages/autocomplete/README.md +1 -0
- package/packages/autocomplete/src/provider.ts +17 -2
- package/packages/compactor/README.md +290 -73
- package/packages/compactor/skills/compactor/SKILL.md +2 -3
- package/packages/compactor/skills/compactor-detail/SKILL.md +49 -64
- package/packages/compactor/skills/compactor-doctor/SKILL.md +28 -31
- package/packages/compactor/skills/compactor-stats/SKILL.md +22 -20
- package/packages/compactor/src/commands/index.ts +4 -1
- package/packages/compactor/src/compaction/auto-trigger.ts +306 -0
- package/packages/compactor/src/config/manager.ts +1 -0
- package/packages/compactor/src/config/presets.ts +26 -0
- package/packages/compactor/src/config/schema.ts +7 -0
- package/packages/compactor/src/index.ts +74 -1
- package/packages/compactor/src/tools/context-budget.ts +18 -2
- package/packages/compactor/src/tools/register.ts +19 -11
- package/packages/compactor/src/tui/settings-overlay.ts +142 -3
- package/packages/compactor/src/types.ts +17 -0
- package/packages/core/events.ts +2 -0
- package/packages/footer/README.md +12 -0
- package/packages/footer/src/config.ts +9 -1
- package/packages/footer/src/rendering/renderer.ts +14 -1
- package/packages/footer/src/rendering/theme.ts +187 -6
- package/packages/footer/src/types.ts +5 -0
- package/packages/notify/README.md +2 -2
- package/packages/notify/commands.ts +9 -4
- package/packages/notify/events.ts +12 -2
- package/packages/notify/platforms/focus-win.ts +123 -0
- package/packages/notify/platforms/focus.ts +33 -0
- package/packages/notify/platforms/native.ts +33 -1
- package/packages/notify/settings.ts +1 -0
- package/packages/notify/tui/settings-overlay.ts +33 -7
- package/packages/notify/types.ts +8 -0
- package/packages/utility/README.md +3 -0
- package/packages/utility/src/display/capabilities.ts +29 -15
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ pi install npm:@pi-unipi/unipi
|
|
|
15
15
|
|
|
16
16
|
**[Memory](./packages/memory/README.md)** — SQLite + vector search stores facts, preferences, and decisions. Project-scoped and global. The agent remembers what you told it last week.
|
|
17
17
|
|
|
18
|
-
**[Compactor](./packages/compactor/README.md)** — Zero-LLM context engine. 6-stage pipeline hits 95%+ token reduction at zero API cost. Session continuity,
|
|
18
|
+
**[Compactor](./packages/compactor/README.md)** — Zero-LLM context engine. 6-stage pipeline hits 95%+ token reduction at zero API cost. Session continuity, percentage auto-compaction, session recall, and sandbox execution.
|
|
19
19
|
|
|
20
20
|
**[CocoIndex](./packages/cocoindex/README.md)** — Project indexing and semantic code search backed by CocoIndex and LanceDB. Agent tools and slash commands for status, init, update, and search.
|
|
21
21
|
|
|
@@ -25,9 +25,9 @@ pi install npm:@pi-unipi/unipi
|
|
|
25
25
|
|
|
26
26
|
**[MCP](./packages/mcp/README.md)** — Browse 7,800+ MCP servers, add them interactively. Tools from servers register automatically as Pi tools.
|
|
27
27
|
|
|
28
|
-
**[Notify](./packages/notify/README.md)** — Push notifications to native OS, Gotify, Telegram, or ntfy. Per-event platform routing
|
|
28
|
+
**[Notify](./packages/notify/README.md)** — Push notifications to native OS, Gotify, Telegram, or ntfy. Per-event platform routing plus native focus suppression so alerts can stay quiet while Pi is already focused.
|
|
29
29
|
|
|
30
|
-
**[Footer](./packages/footer/README.md)** — Persistent status bar showing live stats from every package. Responsive layout, presets, per-segment toggling.
|
|
30
|
+
**[Footer](./packages/footer/README.md)** — Persistent status bar showing live stats from every package. Responsive layout, presets, per-segment toggling, and terminal-aware color fallback.
|
|
31
31
|
|
|
32
32
|
**[BTW](./packages/btw/README.md)** — Side conversations that run in parallel. Ask questions without interrupting the main agent.
|
|
33
33
|
|
|
@@ -45,7 +45,7 @@ pi install npm:@pi-unipi/unipi
|
|
|
45
45
|
|
|
46
46
|
**[Input Shortcuts](./packages/input-shortcuts/README.md)** — Keyboard shortcuts via vim-style chord overlay. Stash/restore, undo/redo, clipboard, thinking toggle.
|
|
47
47
|
|
|
48
|
-
**[Command Enchantment](./packages/autocomplete/README.md)** — Enhanced `/unipi:*` autocomplete with package
|
|
48
|
+
**[Command Enchantment](./packages/autocomplete/README.md)** — Enhanced `/unipi:*` autocomplete with full command names, package tags, descriptions, colors, and registry audits that catch stale command docs before release.
|
|
49
49
|
|
|
50
50
|
## Architecture
|
|
51
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/unipi",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "All-in-one extension suite for Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"typecheck": "npx tsc --noEmit --skipLibCheck",
|
|
27
|
-
"test": "npm test --workspaces",
|
|
27
|
+
"test": "npm test --workspaces --if-present",
|
|
28
28
|
"publish:all": "npm publish --workspaces --access public"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
@@ -9,6 +9,7 @@ Command Enchantment has no user commands. It improves the editor autocomplete ex
|
|
|
9
9
|
## What It Does
|
|
10
10
|
|
|
11
11
|
- Groups `/unipi:*` commands by package so workflow, memory, web, footer, and other commands are visually distinct.
|
|
12
|
+
- Shows full command values like `unipi:brainstorm` while replacing Pi source tags with concise package tags like `[workflow]`.
|
|
12
13
|
- Sorts matches in predictable tiers: exact Unipi matches first, then other Unipi matches, then system commands.
|
|
13
14
|
- Preserves dynamic argument completions from command providers, including workflow document and worktree suggestions.
|
|
14
15
|
- Ships an audit test that checks registered Unipi commands are represented in the autocomplete registry and have descriptions.
|
|
@@ -43,6 +43,18 @@ function fuzzyMatch(text: string, query: string): boolean {
|
|
|
43
43
|
|
|
44
44
|
// ─── Namespace detection ─────────────────────────────────────────────
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Pi prefixes extension command descriptions with source tags such as
|
|
48
|
+
* `[u:npm:@pi-unipi/unipi]`. The enchanted provider replaces that with
|
|
49
|
+
* package tags (`[workflow]`, `[memory]`, …), so strip the source tag from
|
|
50
|
+
* base descriptions before reusing them.
|
|
51
|
+
*/
|
|
52
|
+
function stripPiSourceTag(description: string): string {
|
|
53
|
+
return description
|
|
54
|
+
.replace(/^\[(?:[upt])(?::[^\]]+)?\]\s*/, "")
|
|
55
|
+
.trimStart();
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
/**
|
|
47
59
|
* If the query looks like a package namespace (e.g. "workflow", "memory",
|
|
48
60
|
* "utility"), return that package name so its commands sort to the top.
|
|
@@ -174,7 +186,7 @@ function getEnhancedUnipiItems(
|
|
|
174
186
|
|
|
175
187
|
return {
|
|
176
188
|
value: cmd,
|
|
177
|
-
label: cmd
|
|
189
|
+
label: cmd,
|
|
178
190
|
description: desc ? `${tag} ${desc}` : tag,
|
|
179
191
|
};
|
|
180
192
|
});
|
|
@@ -261,7 +273,10 @@ export function createEnchantedProvider(
|
|
|
261
273
|
for (const item of baseSuggestions.items) {
|
|
262
274
|
if (item.value.startsWith("unipi:")) {
|
|
263
275
|
if (item.description) {
|
|
264
|
-
|
|
276
|
+
const cleanDescription = stripPiSourceTag(item.description);
|
|
277
|
+
if (cleanDescription) {
|
|
278
|
+
descriptionOverrides.set(item.value, cleanDescription);
|
|
279
|
+
}
|
|
265
280
|
}
|
|
266
281
|
} else {
|
|
267
282
|
nonUnipiItems.push(item);
|
|
@@ -1,101 +1,318 @@
|
|
|
1
1
|
# @pi-unipi/compactor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Deterministic context management for Pi/UniPi. The compactor keeps long coding sessions usable by replacing large conversation history with a structured, zero-LLM summary, while preserving session recall, continuity snapshots, stats, sandbox helpers, and safer tool display.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What it does
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **Zero-LLM compaction:** Pi asks for compaction; UniPi builds the summary locally instead of spending model tokens on a summarization call.
|
|
8
|
+
- **Session continuity:** important goals, changed files, commits, blockers, preferences, and a recent transcript survive compaction.
|
|
9
|
+
- **Optional percentage trigger:** UniPi can compact at a configured context percentage before Pi's fixed reserve-token safety net fires.
|
|
10
|
+
- **Recall:** agents can search the append-only session branch, including messages that no longer fit in live LLM context.
|
|
11
|
+
- **Runtime helpers:** sandbox execution, context budget checks, diagnostics, and stats.
|
|
12
|
+
- **Display guards:** tool output/diff rendering is clamped and summarized to avoid noisy or terminal-breaking output.
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|---------|-------------|
|
|
11
|
-
| `/unipi:lossless-compact` | Immediate zero-LLM compaction with structured summary |
|
|
12
|
-
| `/unipi:session-recall` | Search session history (BM25 or regex) |
|
|
13
|
-
| `/unipi:content-index` | Index current project into FTS5 |
|
|
14
|
-
| `/unipi:content-search` | Search indexed content |
|
|
15
|
-
| `/unipi:content-purge` | Wipe all indexed content |
|
|
16
|
-
| `/unipi:compact-stats` | Context savings dashboard |
|
|
17
|
-
| `/unipi:compact-doctor` | Run diagnostics |
|
|
18
|
-
| `/unipi:compact-settings` | TUI settings overlay |
|
|
19
|
-
| `/unipi:compact-preset <name>` | Apply quick preset |
|
|
20
|
-
| `/unipi:compact-help` | Show detailed documentation |
|
|
14
|
+
The compaction pipeline is deterministic and runs locally. It does not call an LLM during compaction.
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
---
|
|
23
17
|
|
|
24
|
-
##
|
|
18
|
+
## Quick start
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
```text
|
|
21
|
+
/unipi:compact-settings
|
|
22
|
+
```
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
1. Choose a preset in **Presets**.
|
|
25
|
+
2. Optionally enable **Auto → Percentage Trigger**.
|
|
26
|
+
3. Press **Enter** to save.
|
|
27
|
+
4. Use `/unipi:lossless-compact` when you want to compact immediately.
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
Config files:
|
|
31
30
|
|
|
32
|
-
|
|
|
33
|
-
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
| `sandbox` | sandbox | Run code in sandbox (11 languages) |
|
|
37
|
-
| `sandbox_file` | sandbox | Execute file via FILE_CONTENT |
|
|
38
|
-
| `sandbox_batch` | sandbox | Atomic batch of commands + searches |
|
|
39
|
-
| `content_index` | content | Chunk content to FTS5 index |
|
|
40
|
-
| `content_search` | content | Query indexed content |
|
|
41
|
-
| `content_fetch` | content | Fetch URL and index |
|
|
42
|
-
| `compactor_stats` | compactor | Context savings dashboard |
|
|
43
|
-
| `compactor_doctor` | compactor | Diagnostics checklist |
|
|
44
|
-
| `context_budget` | compactor | Estimate remaining context window |
|
|
31
|
+
| Scope | Path | Notes |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| Global | `~/.unipi/config/compactor/config.json` | Used by default |
|
|
34
|
+
| Per project | `<project>/.unipi/config/compactor.json` | Enabled from settings with **Project Override** |
|
|
45
35
|
|
|
46
|
-
|
|
36
|
+
Per-project config is merged over global config when the current project directory is known.
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
- **Tier 2** (`compactor-detail`): On-demand. Full tool reference, anti-patterns, sandbox languages, FTS5 modes, workflows.
|
|
38
|
+
---
|
|
50
39
|
|
|
51
|
-
##
|
|
40
|
+
## User-facing slash commands
|
|
52
41
|
|
|
53
|
-
|
|
42
|
+
| Command | What it does | Notes |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `/unipi:lossless-compact` | Immediately calls Pi compaction with UniPi's zero-LLM sentinel. | Main manual compaction command. |
|
|
45
|
+
| `/unipi:compact` | Deprecated alias for `/unipi:lossless-compact`. | Kept for backward compatibility. |
|
|
46
|
+
| `/unipi:session-recall <query>` | Searches current session history with BM25/regex recall. | Uses the append-only session branch when available, so pre-compaction messages can still be found. |
|
|
47
|
+
| `/unipi:compact-recall <query>` | Deprecated alias for `/unipi:session-recall`. | Kept for backward compatibility. |
|
|
48
|
+
| `/unipi:compact-stats` | Shows session events, compaction count, token savings, sandbox runs, and search counts. | Stats are DB-backed with runtime fallbacks. |
|
|
49
|
+
| `/unipi:compact-doctor` | Runs diagnostics for config, SQLite/session DB, and runtimes. | Useful when stats/recall/sandbox look broken. |
|
|
50
|
+
| `/unipi:compact-settings` | Opens the TUI settings overlay. | Tabs: Presets, Strategies, Auto, Pipeline. |
|
|
51
|
+
| `/unipi:compact-preset <name>` | Applies a preset globally. | Names: `precise`, `balanced`, `thorough`, `lean`. Old names map to new ones: `opencode→precise`, `verbose→thorough`, `minimal→lean`. |
|
|
52
|
+
| `/unipi:compact-help` | Shows compact help inside Pi. | Quick command reference. |
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
Content/project indexing is handled by `@pi-unipi/cocoindex`, not this package. Use `/unipi:cocoindex-init`, `/unipi:cocoindex-update`, and `cocoindex_search` for indexed project search.
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|--------|-------------|
|
|
59
|
-
| `precise` | Code-heavy, minimal waste — compaction: full, pipeline: 2/6 on |
|
|
60
|
-
| `balanced` | Daily use (default) — all strategies moderate, pipeline: all on |
|
|
61
|
-
| `thorough` | Debug/audit — everything on, full transcript |
|
|
62
|
-
| `lean` | Quick fixes — compaction only, pipeline: all off |
|
|
56
|
+
---
|
|
63
57
|
|
|
64
|
-
|
|
58
|
+
## User-facing settings
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
Open settings with `/unipi:compact-settings`.
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|---------|-------------|---------|
|
|
70
|
-
| TTL Cache | Cache with time-based expiry | On Compaction |
|
|
71
|
-
| Auto Injection | Inject behavioral state after compaction | On Compaction |
|
|
72
|
-
| MMap Pragma | Use mmap for SQLite I/O | On Compaction |
|
|
73
|
-
| Proximity Reranking | Rerank search results by proximity | On Search |
|
|
74
|
-
| Timeline Sort | Sort session events chronologically | On Search |
|
|
75
|
-
| Progressive Throttling | Slow down indexing for large projects | On Index |
|
|
62
|
+
Keyboard:
|
|
76
63
|
|
|
77
|
-
|
|
64
|
+
| Key | Action |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `Tab` | Switch tabs |
|
|
67
|
+
| `↑/↓` | Move selection |
|
|
68
|
+
| `Space` | Cycle/toggle selected value |
|
|
69
|
+
| `/` | Search inside the Strategies tab |
|
|
70
|
+
| `Enter` | Save and close |
|
|
71
|
+
| `Esc` | Cancel |
|
|
78
72
|
|
|
79
|
-
|
|
80
|
-
- `/` key opens search filter in Strategies tab
|
|
81
|
-
- Preset selection shows 3-line preview
|
|
82
|
-
- Per-project override checkbox (`o` key)
|
|
83
|
-
- Keyboard: left/right cycle modes, Space toggle, `s` save, Esc cancel
|
|
73
|
+
### Presets tab
|
|
84
74
|
|
|
85
|
-
|
|
75
|
+
Presets are profiles that set strategies, pipeline switches, sandbox mode, and display mode.
|
|
86
76
|
|
|
77
|
+
| Preset | Intended use | Important effects |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `precise` | Code-heavy work, minimal waste | Full compaction sections, safe-only sandbox, opencode display, Pipeline: `ttlCache` + `mmapPragma` on. |
|
|
80
|
+
| `balanced` | Daily/default profile | Compact transcript, balanced display, FTS mode auto, sandbox all, Pipeline: all six switches on. |
|
|
81
|
+
| `thorough` | Debug/audit sessions | Full transcript, verbose display, sandbox all, Pipeline: all six switches on. |
|
|
82
|
+
| `lean` | Quick fixes or short sessions | Brief/minimal compaction sections, no sandbox, no session continuity, Pipeline: all off. |
|
|
83
|
+
|
|
84
|
+
The **Project Override** row controls where settings are saved:
|
|
85
|
+
|
|
86
|
+
- `disabled` → save global config.
|
|
87
|
+
- `enabled` → save `<project>/.unipi/config/compactor.json` for only this project.
|
|
88
|
+
|
|
89
|
+
### Strategies tab
|
|
90
|
+
|
|
91
|
+
These settings control what is extracted into compaction summaries or how related compactor features behave.
|
|
92
|
+
|
|
93
|
+
| Setting | Values | Meaning |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `Verbose Debug` | `on`, `off` | Enables internal debug state. Console debug output is intentionally muted to avoid TUI rendering issues. |
|
|
96
|
+
| `Session Goals` | `full`, `brief`, `off` | Extracts the user's active goals/request history into `[Session Goal]`. |
|
|
97
|
+
| `Files & Changes` | `all`, `modified-only`, `off` | Tracks read, created, edited, and written files in `[Files And Changes]`. |
|
|
98
|
+
| `Commits` | `full`, `brief`, `off` | Captures git commit hashes/messages detected in the conversation. |
|
|
99
|
+
| `Outstanding Context` | `full`, `critical-only`, `off` | Keeps blockers, TODOs, pending decisions, and follow-ups. |
|
|
100
|
+
| `User Preferences` | `all`, `recent-only`, `off` | Preserves user preferences learned during the session. |
|
|
101
|
+
| `Brief Transcript` | `full`, `compact`, `minimal`, `off` | Keeps a rolling recent transcript after the structured sections. |
|
|
102
|
+
| `Session Continuity` | `full`, `essential-only`, `off` | Controls XML-style resume snapshots that help the next turn continue after compaction. |
|
|
103
|
+
| `Sandbox Execution` | `all`, `safe-only`, `off` | Controls agent-facing sandbox availability/intent. Safe-only is intended for less risky execution. |
|
|
104
|
+
| `Tool Display` | `opencode`, `balanced`, `verbose`, `custom` | Controls built-in tool output rendering style and diff display behavior. |
|
|
105
|
+
|
|
106
|
+
Config-only legacy field: `fts5Index` remains in the schema for compatibility, but project indexing has moved to `@pi-unipi/cocoindex`.
|
|
107
|
+
|
|
108
|
+
### Auto tab
|
|
109
|
+
|
|
110
|
+
These settings control UniPi-managed percentage auto-compaction. They are separate from Pi core's own `compaction.reserveTokens` behavior.
|
|
111
|
+
|
|
112
|
+
| Setting | Default | Meaning |
|
|
113
|
+
|---|---:|---|
|
|
114
|
+
| `Percentage Trigger` | `off` | When on, UniPi checks context usage at `turn_end` and can call compaction when the threshold is reached. Disabled by default for backward compatibility. |
|
|
115
|
+
| `Threshold` | `80%` | Trigger point using Pi's live `ctx.getContextUsage().percent`. |
|
|
116
|
+
| `Cooldown` | `60s` | Minimum time between UniPi-triggered compaction attempts. Prevents loops. |
|
|
117
|
+
| `Repeat Growth` | `4k` | If usage is still above threshold after compaction, require this many new tokens before triggering again. |
|
|
118
|
+
| `Notifications` | `on` | Shows user-visible notifications for UniPi-triggered compaction attempts/results. |
|
|
119
|
+
|
|
120
|
+
Example config:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"autoCompaction": {
|
|
125
|
+
"enabled": true,
|
|
126
|
+
"thresholdPercent": 80,
|
|
127
|
+
"cooldownMs": 60000,
|
|
128
|
+
"repeatMinGrowthTokens": 4000,
|
|
129
|
+
"notify": true
|
|
130
|
+
}
|
|
131
|
+
}
|
|
87
132
|
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
133
|
+
|
|
134
|
+
### Pipeline tab
|
|
135
|
+
|
|
136
|
+
Pipeline switches are low-level feature flags used by presets and advanced users.
|
|
137
|
+
|
|
138
|
+
| Setting | Preset behavior | Current effect |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `TTL Cache` | On in `precise`, `balanced`, `thorough`; off in `lean` | Reserved/compatibility switch for cache behavior. Search has an internal cache, but this toggle is not currently required for it. |
|
|
141
|
+
| `Auto Injection` | On in `balanced`, `thorough`; off in `precise`, `lean` | Active. Adds behavioral/session state to the resume snapshot after compaction. |
|
|
142
|
+
| `MMap Pragma` | On in `precise`, `balanced`, `thorough`; off in `lean` | Reserved/compatibility switch for SQLite mmap tuning. |
|
|
143
|
+
| `Proximity Reranking` | On in `balanced`, `thorough`; off in `precise`, `lean` | Reserved/compatibility switch for future recall/search ranking. |
|
|
144
|
+
| `Timeline Sort` | On in `balanced`, `thorough`; off in `precise`, `lean` | Reserved/compatibility switch for future chronological recall sorting. |
|
|
145
|
+
| `Progressive Throttling` | On in `balanced`, `thorough`; off in `precise`, `lean` | Reserved/compatibility switch for future large-project throttling. |
|
|
146
|
+
|
|
147
|
+
If all Pipeline values stay `off` after choosing a preset, that means the running version is not applying preset pipeline values correctly. Choose a preset, press **Enter** to save, and verify you are on a version containing the preset pipeline fix.
|
|
148
|
+
|
|
149
|
+
Config-only pipeline field:
|
|
150
|
+
|
|
151
|
+
| Field | Meaning |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `customNoisePatterns` | Extra regex/string patterns used by session recall filtering to remove noisy user blocks. |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## What the agent gets
|
|
158
|
+
|
|
159
|
+
### Agent tools
|
|
160
|
+
|
|
161
|
+
The extension registers tools during `session_start` after the session DB is initialized.
|
|
162
|
+
|
|
163
|
+
| Tool | Purpose |
|
|
164
|
+
|---|---|
|
|
165
|
+
| `compact` | Agent-facing compaction request; supports `dryRun: true` preview. Slash command `/unipi:lossless-compact` is the user-facing immediate compaction path. |
|
|
166
|
+
| `session_recall` | Search current session history with BM25 or regex. |
|
|
167
|
+
| `vcc_recall` | Deprecated alias for `session_recall`. |
|
|
168
|
+
| `sandbox` | Run code in a sandboxed environment. Languages: JavaScript, TypeScript, Python, shell, Ruby, Go, Rust, PHP, Perl, R, Elixir. |
|
|
169
|
+
| `sandbox_file` | Execute a file with its content injected as `FILE_CONTENT`. |
|
|
170
|
+
| `sandbox_batch` | Run multiple sandbox execution items in one atomic response. |
|
|
171
|
+
| `ctx_execute` | Deprecated alias for `sandbox`. |
|
|
172
|
+
| `ctx_execute_file` | Deprecated alias for `sandbox_file`. |
|
|
173
|
+
| `ctx_batch_execute` | Deprecated alias for `sandbox_batch`. |
|
|
174
|
+
| `compactor_stats` | Agent-readable stats dashboard. |
|
|
175
|
+
| `ctx_stats` | Deprecated alias for `compactor_stats`. |
|
|
176
|
+
| `compactor_doctor` | Agent-readable diagnostics. |
|
|
177
|
+
| `ctx_doctor` | Deprecated alias for `compactor_doctor`. |
|
|
178
|
+
| `context_budget` | Uses live Pi context usage when available and returns compaction guidance. |
|
|
179
|
+
|
|
180
|
+
### Agent skills
|
|
181
|
+
|
|
182
|
+
| Skill | Purpose |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `compactor` | Small always-loadable routing skill: when to compact, recall, check budget, or use sandbox. |
|
|
185
|
+
| `compactor-detail` | On-demand full tool reference and workflow guidance. |
|
|
186
|
+
| `compactor-stats` | Help interpreting compactor stats. |
|
|
187
|
+
| `compactor-doctor` | Help diagnosing config/DB/runtime issues. |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## How the system works
|
|
192
|
+
|
|
193
|
+
### Chronological hook flow
|
|
194
|
+
|
|
195
|
+
Typical session order:
|
|
196
|
+
|
|
197
|
+
1. **Extension load**
|
|
198
|
+
- Registers compaction hooks immediately with lazy dependencies.
|
|
199
|
+
- Creates in-memory runtime counters/state.
|
|
200
|
+
|
|
201
|
+
2. **`session_start`**
|
|
202
|
+
- Scaffolds config if needed.
|
|
203
|
+
- Initializes `SessionDB` and sandbox executor.
|
|
204
|
+
- Computes the current session ID, including worktree suffix.
|
|
205
|
+
- Registers agent tools and slash commands.
|
|
206
|
+
- Registers the info-screen Compactor group.
|
|
207
|
+
- Emits UniPi `MODULE_READY`.
|
|
208
|
+
|
|
209
|
+
3. **`before_agent_start`**
|
|
210
|
+
- Reloads config for the active project.
|
|
211
|
+
- Applies runtime `autoDetect` behavior, such as disabling commit extraction outside git repos.
|
|
212
|
+
- Rebuilds cached recall blocks from Pi's append-only session branch.
|
|
213
|
+
- If a resume snapshot exists from a prior compaction, injects it into session context and marks it consumed.
|
|
214
|
+
|
|
215
|
+
4. **`input`**
|
|
216
|
+
- Performs advisory security checks for shell/network/file patterns.
|
|
217
|
+
- Can block some known-dangerous network shell commands.
|
|
218
|
+
|
|
219
|
+
5. **Tool execution → `tool_result`**
|
|
220
|
+
- Extracts file/change/search/sandbox events into the session DB.
|
|
221
|
+
- Updates runtime byte/tool counters.
|
|
222
|
+
- Applies display overrides and width-safe diff clamping before output reaches the TUI.
|
|
223
|
+
|
|
224
|
+
6. **`turn_end`**
|
|
225
|
+
- If percentage auto-compaction is enabled, reads `ctx.getContextUsage()`.
|
|
226
|
+
- Runs cooldown/repeat-growth safeguards.
|
|
227
|
+
- Calls `ctx.compact({ customInstructions: COMPACTOR_INSTRUCTION })` when eligible.
|
|
228
|
+
|
|
229
|
+
7. **Pi decides to compact**
|
|
230
|
+
- This can be from `/unipi:lossless-compact`, UniPi percentage auto-compaction, or Pi core's reserve-token fallback.
|
|
231
|
+
|
|
232
|
+
8. **`session_before_compact`**
|
|
233
|
+
- Pi provides `preparation`, `branchEntries`, and optional custom instructions.
|
|
234
|
+
- If compactor should handle it, UniPi:
|
|
235
|
+
1. chooses the safe cut point (`buildOwnCut`),
|
|
236
|
+
2. converts messages to LLM-like input,
|
|
237
|
+
3. runs the zero-LLM compile pipeline,
|
|
238
|
+
4. persists stats/snapshots,
|
|
239
|
+
5. returns `{ compaction: { summary, details, tokensBefore, firstKeptEntryId } }` to Pi.
|
|
240
|
+
|
|
241
|
+
9. **`session_compact`**
|
|
242
|
+
- Pi commits the compaction entry.
|
|
243
|
+
- UniPi increments compaction counters and persists token/character savings.
|
|
244
|
+
|
|
245
|
+
10. **Next `before_agent_start` after compaction**
|
|
246
|
+
- UniPi injects the resume snapshot so the agent gets continuity without needing the full old transcript in context.
|
|
247
|
+
|
|
248
|
+
11. **`session_shutdown`**
|
|
249
|
+
- Cleans old sessions.
|
|
250
|
+
- Cleans sandbox/background processes.
|
|
251
|
+
- Closes DB handles.
|
|
252
|
+
|
|
253
|
+
### Zero-LLM compile pipeline
|
|
254
|
+
|
|
255
|
+
When UniPi handles `session_before_compact`, it transforms old messages through these deterministic stages:
|
|
256
|
+
|
|
257
|
+
1. **Normalize** — flatten user/assistant/tool/thinking messages into normalized blocks.
|
|
258
|
+
2. **Filter** — remove noise and apply `customNoisePatterns`.
|
|
259
|
+
3. **Build sections** — extract goals, files, commits, outstanding context, preferences, and transcript entries.
|
|
260
|
+
4. **Brief** — cap and condense transcript lines.
|
|
261
|
+
5. **Format** — emit a structured markdown summary.
|
|
262
|
+
6. **Merge** — merge with the previous summary when Pi provides one.
|
|
263
|
+
|
|
264
|
+
The resulting summary is optimized for continuity, not for perfect archival fidelity. Use `session_recall` when the agent needs details from the raw session branch.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Benchmarks
|
|
269
|
+
|
|
270
|
+
Synthetic compile-only benchmark, run on this repository with Node 24 using `compile()` directly. Token counts use the common `chars / 4` estimate. Real compaction also keeps a recent live tail, so final live-context size can be larger than the summary-only number below.
|
|
271
|
+
|
|
272
|
+
| Synthetic session | Input chars | Approx input tokens | Summary chars | Approx summary tokens | Reduction | Compile time |
|
|
273
|
+
|---:|---:|---:|---:|---:|---:|---:|
|
|
274
|
+
| 100 turns / 400 messages | 356,913 | 89,228 | 36,451 | 9,113 | 89.8% | 12.5 ms |
|
|
275
|
+
| 250 turns / 1,000 messages | 894,063 | 223,516 | 36,585 | 9,146 | 95.9% | 16.6 ms |
|
|
276
|
+
| 500 turns / 2,000 messages | 1,789,313 | 447,328 | 36,605 | 9,151 | 98.0% | 35.8 ms |
|
|
277
|
+
|
|
278
|
+
Practical interpretation:
|
|
279
|
+
|
|
280
|
+
- Larger sessions compress better because the structured summary has fixed caps.
|
|
281
|
+
- Runtime is local and usually small relative to model/tool latency.
|
|
282
|
+
- Actual savings reported to users should come from `/unipi:compact-stats`, because Pi supplies real `tokensBefore` during compaction when available.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Troubleshooting
|
|
287
|
+
|
|
288
|
+
### "Whatever preset I choose, Pipeline is always off"
|
|
289
|
+
|
|
290
|
+
That means preset application is not updating `config.pipeline`. The intended behavior is:
|
|
291
|
+
|
|
292
|
+
- `precise`: `ttlCache` + `mmapPragma` on.
|
|
293
|
+
- `balanced`: all six pipeline switches on.
|
|
294
|
+
- `thorough`: all six pipeline switches on.
|
|
295
|
+
- `lean`: all pipeline switches off.
|
|
296
|
+
|
|
297
|
+
Make sure you are running a version with the preset pipeline fix, select the preset, and press **Enter** to save.
|
|
298
|
+
|
|
299
|
+
### "Compaction did not happen"
|
|
300
|
+
|
|
301
|
+
- For immediate user-triggered compaction, use `/unipi:lossless-compact`.
|
|
302
|
+
- For automatic percentage compaction, enable **Auto → Percentage Trigger**.
|
|
303
|
+
- Pi core still has its own reserve-token fallback; UniPi's percentage trigger is optional and disabled by default.
|
|
304
|
+
|
|
305
|
+
### "Stats show zero"
|
|
306
|
+
|
|
307
|
+
- Stats only increase after compaction or after tracked sandbox/search events.
|
|
308
|
+
- Run `/unipi:compact-doctor` to check DB/config health.
|
|
309
|
+
- Long sessions may show all-time DB fallbacks if current in-memory counters are zero.
|
|
310
|
+
|
|
311
|
+
### "Recall cannot find something"
|
|
312
|
+
|
|
313
|
+
- Use specific terms with `/unipi:session-recall <query>`.
|
|
314
|
+
- The recall path prefers Pi's append-only branch and falls back to cached normalized blocks.
|
|
315
|
+
- Extra noise filtering can be added with `pipeline.customNoisePatterns`.
|
|
99
316
|
|
|
100
317
|
## License
|
|
101
318
|
|
|
@@ -11,9 +11,8 @@ description: Context management — compact session, recall history, run code, s
|
|
|
11
11
|
- `compactor_stats` → check savings. `compactor_doctor` → diagnose.
|
|
12
12
|
|
|
13
13
|
## Finding Past Work
|
|
14
|
-
- `session_recall(query)` → search this session (BM25 or regex).
|
|
15
|
-
- `
|
|
16
|
-
→ Index first: `content_index` or `content_fetch(url)`.
|
|
14
|
+
- `session_recall(query)` → search this session (BM25 or regex), including raw messages that may no longer be in live context after compaction.
|
|
15
|
+
- For indexed project/file search, use the CocoIndex package (`cocoindex_search`) when installed; content indexing no longer lives in compactor.
|
|
17
16
|
|
|
18
17
|
## Running Code
|
|
19
18
|
- `sandbox(lang, code)` → single script. `sandbox_batch(items)` → atomic.
|