pi-smart-compact 9.7.1 → 10.0.1
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/ARCHITECTURE.md +973 -372
- package/CHANGELOG.md +721 -0
- package/LICENSE +8 -0
- package/README.md +128 -640
- package/SECURITY.md +34 -12
- package/SUPPORT.md +26 -9
- package/assets/DejaVu-LICENSE.txt +187 -0
- package/assets/DejaVuSansMono.ttf +0 -0
- package/assets/README.md +26 -0
- package/assets/skills/context-management/SKILL.md +34 -0
- package/dist/app/anchor-cache.d.ts +36 -0
- package/dist/app/anchor-cache.d.ts.map +1 -0
- package/dist/app/artifact-storage.d.ts +47 -0
- package/dist/app/artifact-storage.d.ts.map +1 -0
- package/dist/app/background-preparation.d.ts +39 -0
- package/dist/app/background-preparation.d.ts.map +1 -0
- package/dist/app/compaction-commit-store.d.ts +5 -1
- package/dist/app/compaction-commit-store.d.ts.map +1 -1
- package/dist/app/context-evidence.d.ts +57 -0
- package/dist/app/context-evidence.d.ts.map +1 -0
- package/dist/app/context-guide.d.ts +3 -0
- package/dist/app/context-guide.d.ts.map +1 -0
- package/dist/app/context-operations.d.ts +106 -0
- package/dist/app/context-operations.d.ts.map +1 -0
- package/dist/app/effective-state.d.ts +23 -0
- package/dist/app/effective-state.d.ts.map +1 -0
- package/dist/app/global-settings-runtime.d.ts +3 -3
- package/dist/app/global-settings-runtime.d.ts.map +1 -1
- package/dist/app/hindsight-memory.d.ts +100 -0
- package/dist/app/hindsight-memory.d.ts.map +1 -0
- package/dist/app/host-cache-ledger.d.ts +68 -0
- package/dist/app/host-cache-ledger.d.ts.map +1 -0
- package/dist/app/lazy-tools.d.ts +36 -0
- package/dist/app/lazy-tools.d.ts.map +1 -0
- package/dist/app/memory-backend.d.ts +58 -0
- package/dist/app/memory-backend.d.ts.map +1 -0
- package/dist/app/mnemopi-memory.d.ts +13 -0
- package/dist/app/mnemopi-memory.d.ts.map +1 -0
- package/dist/app/mnemopi-protocol.d.ts +78 -0
- package/dist/app/mnemopi-protocol.d.ts.map +1 -0
- package/dist/app/mnemopi-worker.d.ts +2 -0
- package/dist/app/mnemopi-worker.d.ts.map +1 -0
- package/dist/app/model-feasibility.d.ts +20 -0
- package/dist/app/model-feasibility.d.ts.map +1 -0
- package/dist/app/native-compaction.d.ts +88 -0
- package/dist/app/native-compaction.d.ts.map +1 -0
- package/dist/app/native-continuity-bridge.d.ts.map +1 -1
- package/dist/app/navigation-data.d.ts +28 -0
- package/dist/app/navigation-data.d.ts.map +1 -0
- package/dist/app/navigation-types.d.ts +60 -0
- package/dist/app/navigation-types.d.ts.map +1 -0
- package/dist/app/pending-slot.d.ts +11 -1
- package/dist/app/pending-slot.d.ts.map +1 -1
- package/dist/app/preflight.d.ts.map +1 -1
- package/dist/app/register-context-tools.d.ts +16 -3
- package/dist/app/register-context-tools.d.ts.map +1 -1
- package/dist/app/register-navigation.d.ts +20 -0
- package/dist/app/register-navigation.d.ts.map +1 -0
- package/dist/app/register-smart-compact-command.d.ts +17 -2
- package/dist/app/register-smart-compact-command.d.ts.map +1 -1
- package/dist/app/register-smart-compact-tool.d.ts.map +1 -1
- package/dist/app/register-smart-context-tool.d.ts +55 -0
- package/dist/app/register-smart-context-tool.d.ts.map +1 -0
- package/dist/app/run-context.d.ts +1 -0
- package/dist/app/run-context.d.ts.map +1 -1
- package/dist/app/run-smart-compact.d.ts +3 -3
- package/dist/app/run-smart-compact.d.ts.map +1 -1
- package/dist/app/session-handoff.d.ts +64 -0
- package/dist/app/session-handoff.d.ts.map +1 -0
- package/dist/app/session-lineage.d.ts +17 -0
- package/dist/app/session-lineage.d.ts.map +1 -0
- package/dist/app/session-run-lock.d.ts +0 -2
- package/dist/app/session-run-lock.d.ts.map +1 -1
- package/dist/app/settled-auto-trigger.d.ts +2 -0
- package/dist/app/settled-auto-trigger.d.ts.map +1 -1
- package/dist/app/smart-compact-input.d.ts +1 -1
- package/dist/app/smart-compact-input.d.ts.map +1 -1
- package/dist/app/smart-compact-policy.d.ts +1 -1
- package/dist/app/smart-compact-policy.d.ts.map +1 -1
- package/dist/app/steps/extract.d.ts +45 -1
- package/dist/app/steps/extract.d.ts.map +1 -1
- package/dist/app/steps/metrics.d.ts +1 -0
- package/dist/app/steps/metrics.d.ts.map +1 -1
- package/dist/app/steps/persist.d.ts.map +1 -1
- package/dist/app/steps/prepare.d.ts.map +1 -1
- package/dist/app/steps/recover.d.ts +9 -0
- package/dist/app/steps/recover.d.ts.map +1 -1
- package/dist/app/steps/synthesize.d.ts.map +1 -1
- package/dist/app/steps/tier.d.ts.map +1 -1
- package/dist/app/steps/verify.d.ts.map +1 -1
- package/dist/app/steps/visual.d.ts +4 -0
- package/dist/app/steps/visual.d.ts.map +1 -0
- package/dist/app/steps/window.d.ts.map +1 -1
- package/dist/app/tool-artifacts.d.ts +27 -0
- package/dist/app/tool-artifacts.d.ts.map +1 -0
- package/dist/app/visual-archive.d.ts +29 -0
- package/dist/app/visual-archive.d.ts.map +1 -0
- package/dist/constants.d.ts +96 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/domain/compaction-usage.d.ts +16 -0
- package/dist/domain/compaction-usage.d.ts.map +1 -0
- package/dist/domain/model-capacity.d.ts +12 -0
- package/dist/domain/model-capacity.d.ts.map +1 -0
- package/dist/domain/provider-evaluation.d.ts +7 -0
- package/dist/domain/provider-evaluation.d.ts.map +1 -1
- package/dist/domain/telemetry.d.ts +43 -2
- package/dist/domain/telemetry.d.ts.map +1 -1
- package/dist/domain/tool-semantics.d.ts +23 -0
- package/dist/domain/tool-semantics.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15757 -6942
- package/dist/infra/ai-messages.d.ts +1 -1
- package/dist/infra/ai-messages.d.ts.map +1 -1
- package/dist/infra/context-graph.d.ts +38 -7
- package/dist/infra/context-graph.d.ts.map +1 -1
- package/dist/infra/fs.d.ts.map +1 -1
- package/dist/infra/hindsight-client.d.ts +73 -0
- package/dist/infra/hindsight-client.d.ts.map +1 -0
- package/dist/infra/hindsight-receipts.d.ts +68 -0
- package/dist/infra/hindsight-receipts.d.ts.map +1 -0
- package/dist/infra/llm-client.d.ts +26 -23
- package/dist/infra/llm-client.d.ts.map +1 -1
- package/dist/infra/memory-ref.d.ts +27 -0
- package/dist/infra/memory-ref.d.ts.map +1 -0
- package/dist/infra/native-protocol.d.ts +54 -0
- package/dist/infra/native-protocol.d.ts.map +1 -0
- package/dist/infra/optional-components.d.ts +15 -0
- package/dist/infra/optional-components.d.ts.map +1 -0
- package/dist/infra/paths.d.ts +2 -0
- package/dist/infra/paths.d.ts.map +1 -1
- package/dist/infra/services.d.ts +15 -5
- package/dist/infra/services.d.ts.map +1 -1
- package/dist/infra/visual-renderer.d.ts +16 -0
- package/dist/infra/visual-renderer.d.ts.map +1 -0
- package/dist/mnemopi-worker.js +213 -0
- package/dist/phases/explore.d.ts +12 -9
- package/dist/phases/explore.d.ts.map +1 -1
- package/dist/phases/synthesize.d.ts +18 -3
- package/dist/phases/synthesize.d.ts.map +1 -1
- package/dist/phases/verify.d.ts +5 -1
- package/dist/phases/verify.d.ts.map +1 -1
- package/dist/rtk.d.ts +7 -0
- package/dist/rtk.d.ts.map +1 -0
- package/dist/rtk.js +767 -0
- package/dist/types.d.ts +128 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/dashboard-format.d.ts +2 -1
- package/dist/ui/dashboard-format.d.ts.map +1 -1
- package/dist/ui/dashboard-insights.d.ts +9 -1
- package/dist/ui/dashboard-insights.d.ts.map +1 -1
- package/dist/ui/error-format.d.ts +7 -2
- package/dist/ui/error-format.d.ts.map +1 -1
- package/dist/ui/handoff-overlay.d.ts +26 -0
- package/dist/ui/handoff-overlay.d.ts.map +1 -0
- package/dist/ui/home-overlay.d.ts +54 -0
- package/dist/ui/home-overlay.d.ts.map +1 -0
- package/dist/ui/metrics-dashboard-overlay.d.ts.map +1 -1
- package/dist/ui/metrics-report.d.ts.map +1 -1
- package/dist/ui/navigation-overlay.d.ts +92 -0
- package/dist/ui/navigation-overlay.d.ts.map +1 -0
- package/dist/ui/overlays.d.ts +12 -2
- package/dist/ui/overlays.d.ts.map +1 -1
- package/dist/ui/profiles.d.ts +51 -0
- package/dist/ui/profiles.d.ts.map +1 -0
- package/dist/ui/settings-complex.d.ts +49 -3
- package/dist/ui/settings-complex.d.ts.map +1 -1
- package/dist/ui/settings-list.d.ts +28 -0
- package/dist/ui/settings-list.d.ts.map +1 -0
- package/dist/ui/settings-overlay.d.ts +13 -6
- package/dist/ui/settings-overlay.d.ts.map +1 -1
- package/dist/ui/storage-report.d.ts +4 -0
- package/dist/ui/storage-report.d.ts.map +1 -0
- package/dist/utils/backups.d.ts.map +1 -1
- package/dist/utils/cache.d.ts +6 -2
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/config.d.ts +12 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/id-fingerprint.d.ts +3 -1
- package/dist/utils/id-fingerprint.d.ts.map +1 -1
- package/dist/utils/issues.d.ts +61 -0
- package/dist/utils/issues.d.ts.map +1 -0
- package/dist/utils/pruning.d.ts.map +1 -1
- package/dist/utils/session-log.d.ts +0 -2
- package/dist/utils/session-log.d.ts.map +1 -1
- package/dist/utils/state.d.ts +3 -1
- package/dist/utils/state.d.ts.map +1 -1
- package/dist/utils/tokens.d.ts +10 -2
- package/dist/utils/tokens.d.ts.map +1 -1
- package/docs/MIGRATING_TO_V8.md +7 -1
- package/docs/README.md +69 -0
- package/docs/RELEASE.md +173 -56
- package/docs/assets/banner.png +0 -0
- package/docs/assets/banner.svg +1158 -70
- package/docs/assets/pi-smart-compact.png +0 -0
- package/docs/assets/pi-smart-compact.svg +24 -0
- package/docs/configuration.md +637 -0
- package/docs/evaluation.md +408 -0
- package/docs/guide.md +860 -0
- package/docs/hindsight-memory.md +314 -0
- package/docs/identity.md +124 -0
- package/package.json +44 -11
- package/dist/provider-eval.js +0 -2122
- package/dist/provider-scenario-eval.js +0 -2900
- package/dist/telemetry-report.js +0 -1973
- package/docs/provider-evaluation-2026-08-06.md +0 -63
package/README.md
CHANGED
|
@@ -1,678 +1,166 @@
|
|
|
1
|
-
<
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./docs/assets/banner.png" alt="Pi Continuity — context hygiene and session continuity for Pi" width="960" height="240" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
<img src="https://raw.githubusercontent.com/alpertarhan/pi-smart-compact/main/docs/assets/banner.svg" alt="pi-smart-compact" width="860" />
|
|
5
|
-
</a>
|
|
5
|
+
# Pi Continuity
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
[](https://www.npmjs.com/package/pi-smart-compact)
|
|
9
|
-
[](https://github.com/alpertarhan/pi-smart-compact/blob/main/LICENSE)
|
|
10
|
-
[](https://github.com/earendil-works/pi)
|
|
7
|
+
**Keep useful context. Keep the way back.**
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
Pi Continuity helps long-running [Pi Coding Agent](https://github.com/earendil-works/pi)
|
|
10
|
+
sessions manage noisy tool output, recover evidence, and carry goals, constraints,
|
|
11
|
+
decisions and unfinished work through compaction. Pi owns the session lifecycle;
|
|
12
|
+
this extension adds context hygiene and continuity policies around it.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
[Get started](#get-started) · [User guide](./docs/guide.md) ·
|
|
15
|
+
[Configuration](./docs/configuration.md) · [Documentation index](./docs/README.md)
|
|
16
16
|
|
|
17
|
-
**
|
|
17
|
+
> **Pi Continuity is the product name; `pi-smart-compact` is the package.**
|
|
18
|
+
> `/smart-compact`, `smart_*` tools and `smartCompact` settings are unchanged.
|
|
19
|
+
> The TUI still says **Smart Compact**. No data or configuration migration is
|
|
20
|
+
> needed. [Identity and naming](./docs/identity.md).
|
|
21
|
+
>
|
|
22
|
+
> **Pi Continuity 10.0.1:** upgrading from 9.x? Update Pi to 0.87.1 or newer
|
|
23
|
+
> and read the [upgrade notes](./docs/guide.md#upgrade-from-9x). Optional memory
|
|
24
|
+
> engines and image rendering are installed separately. The
|
|
25
|
+
> [changelog](./CHANGELOG.md) records the full release and its evidence limits.
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
## What it does
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
| Task | Use | Boundary |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| Reduce old tool-output noise | **Context hygiene**: archive eligible output behind retrievable references | Protected instructions, failures and recent work stay in context. |
|
|
32
|
+
| Finish a research detour | **Checkpoint and rewind**: retain a report and a path back to evidence | Not a filesystem or side-effect rollback. |
|
|
33
|
+
| Make room for the next stage | **Verified compaction**: extract working state, synthesize a bounded summary, check it before apply | Verification catches known gaps; it does not guarantee semantic truth. |
|
|
34
|
+
| Revisit a milestone | **Session navigation**: named anchors, read-only cross-session search, return on a new branch with carryover | Files, processes and external services are unchanged. |
|
|
35
|
+
| Continue in a fresh session | **Handoff**: seed a new session from recorded state, without a model call | Not a new summary of the entire transcript; parent evidence remains retrievable. |
|
|
36
|
+
| Reuse an approved fact | **Project memory**: scoped recall through one selected backend | Separate from session state, output archives and backups. |
|
|
37
|
+
|
|
38
|
+
The goal is a smaller **working set**, not an inaccessible history. Compaction
|
|
39
|
+
uses **Extract → Explore → Synthesize → Verify (EESV)**; exploration depends on
|
|
40
|
+
the mode, and verification is primarily deterministic.
|
|
41
|
+
[How it works](./docs/guide.md#how-it-works-in-one-minute) · [Architecture](./ARCHITECTURE.md)
|
|
22
42
|
|
|
23
|
-
##
|
|
43
|
+
## Get started
|
|
24
44
|
|
|
25
|
-
Requires
|
|
26
|
-
uses Pi's host packages and does not bundle a second Pi runtime.
|
|
45
|
+
Requires **Pi 0.87.1+** and **Node.js 22.19+**.
|
|
27
46
|
|
|
28
47
|
```bash
|
|
29
48
|
pi install npm:pi-smart-compact
|
|
30
49
|
```
|
|
31
50
|
|
|
32
|
-
Then
|
|
33
|
-
|
|
34
|
-
## Quick start
|
|
51
|
+
Then, in Pi's interactive TUI:
|
|
35
52
|
|
|
36
|
-
```
|
|
37
|
-
/smart-compact
|
|
38
|
-
/smart-compact auto # adaptive mode selection
|
|
39
|
-
/smart-compact anthropic/claude-sonnet-4 fast # explicit model + mode
|
|
40
|
-
/smart-compact balanced --focus=auth # preserve extra auth detail
|
|
41
|
-
/smart-compact --note="keep balanced and fast terminology"
|
|
42
|
-
/smart-compact -- preserve this note verbatim after the option boundary
|
|
43
|
-
/smart-compact metrics # text metrics report
|
|
44
|
-
/smart-compact dashboard # interactive dashboard
|
|
45
|
-
/smart-compact restore # browse and restore backups
|
|
46
|
-
/smart-compact loops # manage persisted open loops
|
|
47
|
-
/smart-compact settings # unified branch + global settings TUI
|
|
48
|
-
/smart-compact forget # permanently delete this project's graph memory
|
|
53
|
+
```text
|
|
54
|
+
/smart-compact
|
|
49
55
|
```
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
content. Use `--note=...` or `--` when the boundary should be explicit. Invalid
|
|
54
|
-
tool modes and budgets return an error instead of silently using defaults.
|
|
55
|
-
|
|
56
|
-
By default, at 60% context usage the extension participates when Pi starts its
|
|
57
|
-
native compaction flow. Set `autoTriggerStrategy` to `settled` to additionally
|
|
58
|
-
request that same host flow after an idle agent run crosses the pressure gate.
|
|
59
|
-
Long-running agents can also call `smart_compact`, `smart_recall`, and
|
|
60
|
-
`smart_save_memory` directly.
|
|
57
|
+
Opening Home changes nothing. Without a UI (print, RPC or SDK), the bare command
|
|
58
|
+
instead runs a compaction with your configured defaults.
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
> The tool path only stages a verified pending summary for Pi's next natural
|
|
64
|
-
> compact. It never compacts the active conversation in the middle of an agent
|
|
65
|
-
> turn.
|
|
60
|
+
Open **Settings → How it runs** to choose your level of control:
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
| Native-style recap | `pi-smart-compact` |
|
|
62
|
+
| Preset | Behavior |
|
|
70
63
|
| --- | --- |
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
| No quality feedback | Tracks provenance, damage signals, and metrics |
|
|
76
|
-
| No scoped cross-session recall | Searches a project-isolated SQLite FTS5 context graph |
|
|
64
|
+
| **Manual only** | You start compaction or cleanup; no extension-scheduled work. |
|
|
65
|
+
| **Manual + agent** | You or the agent can request compaction. |
|
|
66
|
+
| **Cleanup only** | Local, recoverable cleanup; no automatic summary generation. |
|
|
67
|
+
| **Fully automatic** | Cleanup plus compaction requests when idle at the configured context threshold. |
|
|
77
68
|
|
|
78
|
-
|
|
69
|
+
Pi's own compaction setting is separate. **With Pi (default)** participates when
|
|
70
|
+
Pi starts compaction; it does not independently schedule it. A threshold alone
|
|
71
|
+
is not an automatic trigger. [Trigger settings](./docs/configuration.md).
|
|
79
72
|
|
|
80
|
-
|
|
73
|
+
For your first run, choose **Compact now**, inspect the plan, then review the
|
|
74
|
+
result. **A** applies it; **C** or **Esc** cancels. **Enter does not apply** on
|
|
75
|
+
the review screen. Approval is required unless you explicitly disable
|
|
76
|
+
`requireApproval`.
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
### Optional components
|
|
83
79
|
|
|
84
|
-
|
|
80
|
+
A normal Pi install does **not** install these opt-in components. Enable them
|
|
81
|
+
only for the feature you need; nothing is downloaded, started or configured on
|
|
82
|
+
your behalf.
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
Pi conversation
|
|
88
|
-
│
|
|
89
|
-
▼
|
|
90
|
-
┌───────────┐ ┌───────────┐ ┌────────────┐ ┌───────────┐
|
|
91
|
-
│ Extract │ → │ Explore │ → │ Synthesize │ → │ Verify │
|
|
92
|
-
│ 0 LLM │ │ adaptive │ │ 1-pass or │ │ + repair │
|
|
93
|
-
│ calls │ │ │ │ hierarchical│ │ │
|
|
94
|
-
└───────────┘ └───────────┘ └────────────┘ └───────────┘
|
|
95
|
-
│
|
|
96
|
-
▼
|
|
97
|
-
staged/applied by Pi
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
| Stage | Responsibility |
|
|
101
|
-
| --- | --- |
|
|
102
|
-
| **Extract** | Deterministically catalogs files, errors, decisions, constraints, topics, media metadata, and open loops. This is the verification ground truth. |
|
|
103
|
-
| **Explore** | Runs only in `thorough` mode (or when `auto` selects it); cheaper modes use deterministic boundaries. |
|
|
104
|
-
| **Synthesize** | Uses adaptive single-pass or bounded hierarchical synthesis with per-mode call, prompt-token, chunk, and output budgets. |
|
|
105
|
-
| **Verify** | Applies deterministic repairs to a bounded fixed point, then uses a verified deterministic quality floor. Only `thorough` may spend one additional LLM repair call before that fallback. |
|
|
106
|
-
|
|
107
|
-
### What survives compaction
|
|
108
|
-
|
|
109
|
-
- The current goal and user constraints
|
|
110
|
-
- Modified, read, and deleted files
|
|
111
|
-
- Unresolved **and** resolved error history; free-form goal changes never claim an unfixed error was resolved
|
|
112
|
-
- Explicit and implicit decisions
|
|
113
|
-
- Open follow-ups, blockers, priorities, and pinned loops
|
|
114
|
-
- Next actions and critical continuation context
|
|
115
|
-
- Changes since the previous compaction
|
|
116
|
-
- A bounded **Continuity Ledger** carrying prior decisions, constraints, unresolved errors, and open loops across follow-ups and goal wording changes. Goal shifts are recorded as context; facts retire only through positive resolution evidence or an explicit override.
|
|
117
|
-
|
|
118
|
-
Summaries use a canonical H1/H2/H3-aware structure, collision-safe file
|
|
119
|
-
matching, typed verification gaps, and persisted repair provenance.
|
|
120
|
-
|
|
121
|
-
### Smart Recall
|
|
122
|
-
|
|
123
|
-
Applied compactions also index their verified scoped state into a bounded,
|
|
124
|
-
project-isolated SQLite FTS5 context graph. `smart_recall` searches goals,
|
|
125
|
-
decisions, constraints, unresolved errors, open loops, files, and critical
|
|
126
|
-
context across this project's sessions; recall and resolution use the complete
|
|
127
|
-
visible branch ancestry, never sibling-branch state. File relationships add
|
|
128
|
-
one-hop graph recall without an embedding service or extra LLM call.
|
|
129
|
-
|
|
130
|
-
`smart_save_memory` persists or explicitly resolves one user-confirmed decision,
|
|
131
|
-
constraint, preference, warning, procedure, or context fact. It fails closed
|
|
132
|
-
when the working directory is exactly `HOME` or the filesystem root, and
|
|
133
|
-
requires an interactive confirmation showing the complete scrubbed title,
|
|
134
|
-
content, and paths. Each project may have at most 500 active manual memories.
|
|
135
|
-
It rejects empty inputs, scrubs configured secrets/PII, deduplicates exact facts,
|
|
136
|
-
and must not be used for guesses, transient progress, secrets, or code that is
|
|
137
|
-
cheap to re-read. Set `contextGraphEnabled` to `false` to disable indexing and
|
|
138
|
-
remove both tools from the active tool set, so they no longer reach the system
|
|
139
|
-
prompt.
|
|
140
|
-
|
|
141
|
-
## Usage surfaces
|
|
142
|
-
|
|
143
|
-
| Surface | Behavior |
|
|
144
|
-
| --- | --- |
|
|
145
|
-
| `/smart-compact` | Explicit manual run. Opens a target-first preflight or accepts direct args, dry-run, focus, and budgets. |
|
|
146
|
-
| `session_before_compact` | Auto path. Returns/stages a verification-scored summary under pressure; durable state waits for matching `session_compact`. |
|
|
147
|
-
| `session_compact_failed` | Pi 0.85 cleanup path. Discards extension-owned staged state and records a failed/cancelled outcome; it is inert on older hosts. |
|
|
148
|
-
| `smart_compact` tool | Agent path. Produces a pending summary for Pi's next natural compact; does not compact mid-turn. Can be hidden from the agent. |
|
|
149
|
-
| `/smart-compact loops` | Project-level open-loop manager: resolve/reopen, priority, pin/unpin. |
|
|
150
|
-
| `/smart-compact forget` | Permanently deletes the project's graph memory (nodes, edges, FTS copies) after an explicit confirmation. Compaction state used for restore and backups are kept. |
|
|
151
|
-
| `/smart-compact settings` | Unified TUI for branch overrides and every `smartCompact` global setting. Manual `/smart-compact` always remains available. |
|
|
152
|
-
|
|
153
|
-
### Manual preflight
|
|
154
|
-
|
|
155
|
-
The interactive command uses the configured summary route and exact execution
|
|
156
|
-
planner before spending LLM tokens. Its compact decision card compares the
|
|
157
|
-
three modes by estimated after-size and saving, highlights the recommendation,
|
|
158
|
-
and keeps only the selected plan plus hard tool-pair/zero-gap guarantees in the
|
|
159
|
-
primary view. The plan reserves a calibrated allowance for verified
|
|
160
|
-
state/delta/continuity sections added after synthesis (at least 25% of the LLM
|
|
161
|
-
summary budget). The preview displays that actual allowance. Technical estimator,
|
|
162
|
-
target, route, and boundary data stays under `D` instead of crowding the decision.
|
|
163
|
-
|
|
164
|
-
- `↑` / `↓` changes `Fast`, `Balanced`, or `Thorough` and recalculates the plan.
|
|
165
|
-
- `Enter` runs only a viable plan; `Esc` cancels without mutation.
|
|
166
|
-
- `D` toggles calibrated estimator, target, boundary, and route details.
|
|
167
|
-
- `M` opens Advanced model selection and replans with that route's calibration.
|
|
168
|
-
|
|
169
|
-
Provider-reported token usage is used when available; missing or partial usage
|
|
170
|
-
is conservatively estimated for both metrics and aggregate budgets. Every
|
|
171
|
-
provider request is clamped to the selected model's advertised output limit
|
|
172
|
-
before reservation and dispatch. Smart Compact uses `~`/`≤` language for
|
|
173
|
-
post-compaction estimates, measures the completed summary again before staging,
|
|
174
|
-
and reports final success only after Pi confirms the matching
|
|
175
|
-
`session_compact` run ID. A single long user turn may be
|
|
176
|
-
split at a safe message boundary: its older prefix is verified into the summary
|
|
177
|
-
while the budgeted working tail stays raw. Tool exchanges remain complete
|
|
178
|
-
call/result pairs. Historical exchanges with names outside the portable
|
|
179
|
-
provider contract are summarized instead of leaving an unusable raw tail;
|
|
180
|
-
oversized result evidence is head/tail bounded only in the synthesis prompt
|
|
181
|
-
after deterministic extraction has consumed the full input.
|
|
182
|
-
If Verify, yield, provider, or native apply fails, the UI shows one bounded actionable line without evidence text or a
|
|
183
|
-
JavaScript stack. A successful `100/100` is labeled **verification coverage**;
|
|
184
|
-
the source score and deterministic/LLM/fallback provenance remain visible so
|
|
185
|
-
repaired coverage is never presented as raw synthesis quality. Stack diagnostics
|
|
186
|
-
are opt-in with `DEBUG=smart-compact`.
|
|
187
|
-
During execution a two-line live brief shows the EESV phase chain and the
|
|
188
|
-
meaningful current action; it states that the conversation remains unchanged
|
|
189
|
-
until verified Apply. Routine phase toasts and raw per-batch watchdog/provider
|
|
190
|
-
errors are suppressed by default: handled fallbacks appear as one content-free
|
|
191
|
-
brief with a failure category and next action. `verbose` (also spelled `debug`)
|
|
192
|
-
restores routine phase notices, not stack traces. For raw local diagnostics,
|
|
193
|
-
restart Pi with `DEBUG=smart-compact`; logs may contain private conversation evidence.
|
|
194
|
-
|
|
195
|
-
A skip at **38% / 102,957 tokens** means usage is below the configured
|
|
196
|
-
`minContextPercent` (60% by default), relative to the active model's window.
|
|
197
|
-
It does not mean 100K tokens is universally small. `tool=XX%` measures a different
|
|
198
|
-
quantity. Use `/smart-compact` for deliberate early compaction with preview and
|
|
199
|
-
unchanged verification/yield gates. The agent tool only **stages** a summary;
|
|
200
|
-
run `/compact` within five minutes to apply it. With automatic compaction disabled,
|
|
201
|
-
no background action consumes that candidate.
|
|
202
|
-
|
|
203
|
-
### Focus and budgets
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
/smart-compact balanced --focus=authentication
|
|
207
|
-
/smart-compact fast --max-input-tokens=120000
|
|
208
|
-
/smart-compact fast --focus=src/auth.ts --max-calls=3
|
|
209
|
-
/smart-compact thorough
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
- `--focus` assigns more synthesis/exploration budget to a topic or path. It
|
|
213
|
-
does **not** attempt unsupported non-contiguous compaction.
|
|
214
|
-
- `--max-calls` accepts `1–100`.
|
|
215
|
-
- `--max-input-tokens` accepts `10000–1000000` aggregate prompt tokens.
|
|
216
|
-
- `--max-latency` accepts `5000–600000` milliseconds as a provider/pipeline cancellation deadline; interactive summary review time is excluded.
|
|
217
|
-
- Budget exhaustion is recorded as an explicit fallback outcome and degrades to deterministic summaries instead of dropping context.
|
|
218
|
-
|
|
219
|
-
The tool exposes equivalent `focus`, `max_calls`, `max_input_tokens`, and
|
|
220
|
-
`max_latency_ms` parameters.
|
|
221
|
-
|
|
222
|
-
## Modes
|
|
223
|
-
|
|
224
|
-
| Mode | Calls | Prompt cap | Output cap | Behavior |
|
|
225
|
-
| --- | ---: | ---: | ---: | --- |
|
|
226
|
-
| `fast` | 3 | 100K | 20K | Quickest recovery; 3K summary, 10K recent tail, 30% context target |
|
|
227
|
-
| `balanced` | 6 | 200K | 40K | Default quality/speed trade-off; 6K summary, 20K recent tail, 40% target |
|
|
228
|
-
| `thorough` | 8 | 300K | 80K | Deepest analysis; 10K summary, 30K recent tail, 50% target, Explore and optional LLM repair |
|
|
229
|
-
|
|
230
|
-
These are the only three execution modes. Automatic runs choose among them
|
|
231
|
-
from context pressure and deterministic session risk; `auto` is a selector,
|
|
232
|
-
not a fourth execution policy. Fast can use a zero-call deterministic summary
|
|
233
|
-
when extraction confidence is high; otherwise it keeps the bounded LLM path.
|
|
234
|
-
The mode token target is binding: recent user turns, pi-toolkit checkpoints,
|
|
235
|
-
and topical grouping remain raw only when they fit the planned tail; otherwise
|
|
236
|
-
the verified summary carries them forward. Automatic risk refinement may deepen
|
|
237
|
-
analysis/repair strategy after extraction, but it does not mutate the profile
|
|
238
|
-
allowance or retention window that was already used to prove the target.
|
|
239
|
-
|
|
240
|
-
Output caps stop subsequent calls after reported or conservatively estimated usage reaches the threshold.
|
|
241
|
-
The ChatGPT Codex subscription endpoint rejects `max_output_tokens`,
|
|
242
|
-
`max_tokens`, and `max_completion_tokens`; Smart Compact therefore enforces a
|
|
243
|
-
15–90 second per-call watchdog plus a streamed visible-output ceiling and falls
|
|
244
|
-
back deterministically on abort. Custom Codex endpoints receive
|
|
245
|
-
`max_output_tokens` through Pi AI's payload hook.
|
|
246
|
-
|
|
247
|
-
Legacy compression profiles remain as advanced/backwards-compatible policy:
|
|
248
|
-
`light` maps to `thorough`, `balanced` maps to `balanced`, and `aggressive` maps
|
|
249
|
-
to `fast` with a deprecation warning. The selected model never changes
|
|
250
|
-
automatically; `M` changes the summary route inside preflight and recalculates
|
|
251
|
-
all three plans.
|
|
252
|
-
|
|
253
|
-
### Stage-aware provider routing
|
|
254
|
-
|
|
255
|
-
All stages use the selected Pi model by default. Routing is explicit and
|
|
256
|
-
independent of modes:
|
|
257
|
-
|
|
258
|
-
| Stage | Config key | Default |
|
|
84
|
+
| Feature (off by default) | Component | Approximate disk use¹ |
|
|
259
85
|
| --- | --- | --- |
|
|
260
|
-
|
|
|
261
|
-
|
|
|
262
|
-
|
|
|
263
|
-
|
|
264
|
-
Every run persists per-stage provider, model, reliability, latency, and token
|
|
265
|
-
telemetry with schema-versioned verifier quality. Failed dispatched calls also
|
|
266
|
-
retain content-free categories (authentication, rate-limit, timeout, and so on),
|
|
267
|
-
including runs completed by deterministic fallback. `/smart-compact metrics`
|
|
268
|
-
separates those call failures from the compaction outcome; older records without
|
|
269
|
-
categories remain explicitly unclassified. `bun run provider-eval`
|
|
270
|
-
builds an advisory matrix by context pressure and tool density; it never edits
|
|
271
|
-
configuration or selects a model. Legacy rows contribute operational evidence
|
|
272
|
-
but not quality because old verifier score semantics are incompatible.
|
|
273
|
-
|
|
274
|
-
A reproducible paid-API probe is opt-in only:
|
|
86
|
+
| Mnemopi memory store | `@oh-my-pi/pi-mnemopi@18.3.1` and its engine packages | 195 MB |
|
|
87
|
+
| Mnemopi without Bun 1.3.14+ on `PATH` | `bun@1.4.2` | 60 MB |
|
|
88
|
+
| Image snapshots (`visualArchiveEnabled`) | `@resvg/resvg-js@2.6.2` | 3.5 MB |
|
|
275
89
|
|
|
276
|
-
|
|
277
|
-
bun run provider-eval:live --live \
|
|
278
|
-
--models=openai/gpt-5.4,anthropic/claude-sonnet-4-6
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
It runs three bounded, identical coding-continuity scenarios and reports
|
|
282
|
-
verification score, latency, and token usage. Apply a route manually only after
|
|
283
|
-
representative evidence. See the dated [provider evaluation baseline](./docs/provider-evaluation-2026-08-06.md).
|
|
284
|
-
|
|
285
|
-
### Privacy-safe telemetry and canary gates
|
|
286
|
-
|
|
287
|
-
Raw local JSONL remains available to the interactive dashboard, while
|
|
288
|
-
`bun run telemetry-report` emits aggregate-only telemetry: no session/project
|
|
289
|
-
IDs, prompts, summaries, paths, or error text. Failures use a stable taxonomy
|
|
290
|
-
(cancelled, timeout, rate limit, authentication, budget, output limit,
|
|
291
|
-
provider, persistence, validation, verification, **yield**, internal).
|
|
292
|
-
Verification and yield failures retain only content-free diagnostics.
|
|
293
|
-
|
|
294
|
-
Set `telemetryChannel` to `canary` only on the externally selected canary
|
|
295
|
-
cohort. The report shows total/applied counts, but only non-dry, host-confirmed
|
|
296
|
-
applied runs satisfy promotion evidence. A deterministic green check never
|
|
297
|
-
implies `PROMOTE`; the report compares schema-v2 canary runs with the stable
|
|
298
|
-
baseline and returns `HOLD`, `ROLLBACK`, or `PROMOTE`. Rollback triggers are: failure rate
|
|
299
|
-
+5pp and ≥10%, verifier quality −5 points, p95 latency +50%, tokens +50%,
|
|
300
|
-
heuristic fallback +10pp, or post-compaction damage +10pp. Promotion requires
|
|
301
|
-
20 non-dry applied canary runs, a stable baseline, ≥70% verifier-quality coverage,
|
|
302
|
-
≥70% run-correlated damage-observation coverage in both cohorts, ≥85 absolute
|
|
303
|
-
canary quality, and ≥95% success. The extension reports the decision; it never
|
|
304
|
-
edits config or deploys automatically.
|
|
305
|
-
|
|
306
|
-
The interactive and HTML dashboards make trust evidence explicit: a **Data
|
|
307
|
-
Confidence** score (target ≥85) combines recent sample size (25 points),
|
|
308
|
-
schema-v2 coverage (25), verifier-quality coverage (20), field completeness
|
|
309
|
-
(20), and seven-day freshness (10). Separate views show repair gain and quality
|
|
310
|
-
bands, stage/provider/model reliability with quality coverage, stable-vs-canary
|
|
311
|
-
deltas, rollback triggers, and the failure taxonomy. Low confidence is shown as
|
|
312
|
-
low—not silently filled from incompatible legacy scores—and includes concrete
|
|
313
|
-
guidance for reaching the target.
|
|
314
|
-
|
|
315
|
-
## Safety and privacy
|
|
316
|
-
|
|
317
|
-
### Deterministic safeguards
|
|
318
|
-
|
|
319
|
-
- Tool-call-aware recent-tail budgeting
|
|
320
|
-
- Exact access-call pruning—different reads, searches, offsets, and patterns do not collapse
|
|
321
|
-
- Tool-call/tool-result pair integrity at the compaction boundary
|
|
322
|
-
- Collision-safe modified-file verification for monorepos
|
|
323
|
-
- Bounded fixed-point repair for patchable verification gaps, followed by a zero-gap deterministic quality floor
|
|
324
|
-
- High-risk success claims are grounded only in successful host/tool results or
|
|
325
|
-
deterministic resolved-error/file evidence; assistant prose is never proof
|
|
326
|
-
of its own claim.
|
|
327
|
-
- The window planner converts provider output caps through the calibrated local
|
|
328
|
-
estimator and reserves bounded deterministic repair/state additions before
|
|
329
|
-
choosing the retained tail.
|
|
330
|
-
- Recent resolved errors remain explicit in the Continuity Ledger instead of
|
|
331
|
-
disappearing when they leave the unresolved set.
|
|
332
|
-
- Cross-session guard and five-minute TTL for pending summaries
|
|
333
|
-
- Session-log recovery for older, truncated tool results
|
|
334
|
-
- Host-visible custom messages, branch summaries, and earlier compaction summaries
|
|
335
|
-
participate in planning and extraction, with original entry IDs. Context-excluded
|
|
336
|
-
messages and extension-private state stay excluded.
|
|
337
|
-
- Recovered pre-prune conversation text is backed up without an additional tool-result
|
|
338
|
-
length cap. Text backups are not binary attachment archives and remain subject to
|
|
339
|
-
configured redaction and available session-log recovery. The 0600 backup is
|
|
340
|
-
materialized and written only after the matching native compaction succeeds.
|
|
341
|
-
Marker-owned retention leaves foreign files in custom directories untouched.
|
|
342
|
-
- Private artifact directories are enforced as 0700 and files as 0600; stale state snapshots and orphaned atomic-write temp files are removed during bounded retention sweeps.
|
|
343
|
-
|
|
344
|
-
### Secrets and PII
|
|
345
|
-
|
|
346
|
-
High-confidence secret scrubbing is enabled by default at every relevant trust
|
|
347
|
-
boundary:
|
|
348
|
-
|
|
349
|
-
```text
|
|
350
|
-
provider request · extraction cache · backup · state · context graph · pending summary
|
|
351
|
-
```
|
|
90
|
+
¹ Measured on macOS arm64; not download sizes or cross-platform guarantees.
|
|
352
91
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
generic credential assignments, and passwords embedded in connection URIs.
|
|
356
|
-
Optional email/phone/payment-card scrubbing is available through `scrubPii`.
|
|
357
|
-
|
|
358
|
-
Secret scrubbing is defense in depth, **not a replacement for proper secret
|
|
359
|
-
handling or a dedicated DLP system**. See the
|
|
360
|
-
[security policy](https://github.com/alpertarhan/pi-smart-compact/blob/main/SECURITY.md).
|
|
361
|
-
|
|
362
|
-
### Approval and feedback
|
|
363
|
-
|
|
364
|
-
- Manual runs show a fail-closed verified-summary **Apply / Cancel** review by
|
|
365
|
-
default (`requireApproval: true`); set it to `false` only to opt out of the
|
|
366
|
-
second modal after preflight. Review time is not charged to the pipeline
|
|
367
|
-
deadline. Fingerprint, continuity state, context graph, prepared backup, and
|
|
368
|
-
success telemetry commit only after the host confirms the matching native
|
|
369
|
-
`session_compact` event. The UI reports `Applied` at that point and separately
|
|
370
|
-
warns if any durable persistence side effect was partial.
|
|
371
|
-
- Online damage monitoring observes the first post-compaction messages and
|
|
372
|
-
records re-read files or repeated context. Observations join the originating
|
|
373
|
-
compaction by a local run id; missing evidence lowers coverage rather than
|
|
374
|
-
counting as a clean run. Remediation hints feed affected files into the next
|
|
375
|
-
compaction.
|
|
376
|
-
- `adaptiveDamageFeedback` can opt a project into larger preservation budgets
|
|
377
|
-
after repeated high-damage reports.
|
|
378
|
-
|
|
379
|
-
## Open-loop control
|
|
92
|
+
**Status & help → Readiness & details** shows the exact install command for a
|
|
93
|
+
missing component and your Pi install root. A typical Mnemopi setup is:
|
|
380
94
|
|
|
381
95
|
```bash
|
|
382
|
-
/
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
The manager operates on the project's persisted `CompactionState`:
|
|
386
|
-
|
|
387
|
-
- resolve or reopen a loop
|
|
388
|
-
- change priority
|
|
389
|
-
- pin or unpin it across later compactions
|
|
390
|
-
|
|
391
|
-
Overrides use normalized summary identity instead of positional IDs, so a loop
|
|
392
|
-
cannot accidentally inherit another loop's state on a later run.
|
|
393
|
-
|
|
394
|
-
## Configuration
|
|
395
|
-
|
|
396
|
-
Add `smartCompact` to `~/.pi/agent/settings.json`:
|
|
397
|
-
|
|
398
|
-
```json
|
|
399
|
-
{
|
|
400
|
-
"smartCompact": {
|
|
401
|
-
"mode": "auto",
|
|
402
|
-
"profile": "balanced",
|
|
403
|
-
"summaryModel": null,
|
|
404
|
-
"segmentationModel": null,
|
|
405
|
-
"verificationModel": null,
|
|
406
|
-
"summaryThinkingLevel": "minimal",
|
|
407
|
-
"segmentationThinkingLevel": "minimal",
|
|
408
|
-
"agentToolAccess": "inherit",
|
|
409
|
-
"autoTrigger": true,
|
|
410
|
-
"autoTriggerStrategy": "native-hook",
|
|
411
|
-
"minContextPercent": 60,
|
|
412
|
-
"backupEnabled": true,
|
|
413
|
-
"scrubSecrets": true,
|
|
414
|
-
"scrubPii": false,
|
|
415
|
-
"requireApproval": true,
|
|
416
|
-
"maxLlmCalls": 8,
|
|
417
|
-
"maxLlmInputTokens": 0,
|
|
418
|
-
"codexMaxCallMs": 0,
|
|
419
|
-
"maxLatencyMs": 0,
|
|
420
|
-
"pendingTtlMs": 300000,
|
|
421
|
-
"focusWeighting": true,
|
|
422
|
-
"zeroCallEnabled": true,
|
|
423
|
-
"contextGraphEnabled": true,
|
|
424
|
-
"telemetryChannel": "stable",
|
|
425
|
-
"onlineDamageMonitor": true,
|
|
426
|
-
"adaptiveDamageFeedback": false,
|
|
427
|
-
"pinPaths": []
|
|
428
|
-
}
|
|
429
|
-
}
|
|
96
|
+
npm install @oh-my-pi/pi-mnemopi@18.3.1 bun@1.4.2 --prefix ~/.pi/agent/npm --legacy-peer-deps
|
|
430
97
|
```
|
|
431
98
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
categories persist every other setting under `smartCompact` in
|
|
437
|
-
`~/.pi/agent/settings.json` while preserving unrelated Pi and extension keys.
|
|
438
|
-
|
|
439
|
-
Agent access, automatic compaction, footer status, and project-memory tool
|
|
440
|
-
exposure apply immediately from the TUI without an extension reload. Active
|
|
441
|
-
tool schemas and prompt guidance update on the next agent turn. Mode, model,
|
|
442
|
-
budget, safety, path, profile, and monitoring changes apply to the next
|
|
443
|
-
compaction or indexing operation; a run already in progress keeps its starting
|
|
444
|
-
configuration. `"inherit"` respects Pi's `/tools`, host allowlists, and other
|
|
445
|
-
extensions instead of forcing `smart_compact` back on. Manual
|
|
446
|
-
`/smart-compact` remains available even when agent access is disabled.
|
|
447
|
-
|
|
448
|
-
Edits made externally to `settings.json` are detected by normal operations via
|
|
449
|
-
the config mtime cache. Because external writes do not emit a Pi UI event,
|
|
450
|
-
active tool/footer state is refreshed on `/reload` or the next session restore;
|
|
451
|
-
no filesystem watcher is installed.
|
|
452
|
-
|
|
453
|
-
Settings writes fail closed behind `~/.pi/agent/settings.json.lock`. If Pi is
|
|
454
|
-
terminated during a write and leaves that directory behind, verify no Pi
|
|
455
|
-
process is writing settings, then remove the stale lock directory manually.
|
|
456
|
-
|
|
457
|
-
`native-hook` preserves the existing passive behavior. The opt-in proactive
|
|
458
|
-
strategy is:
|
|
459
|
-
|
|
460
|
-
```json
|
|
461
|
-
{
|
|
462
|
-
"smartCompact": {
|
|
463
|
-
"autoTrigger": true,
|
|
464
|
-
"autoTriggerStrategy": "settled",
|
|
465
|
-
"minContextPercent": 80
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
```
|
|
99
|
+
Pi uses `--legacy-peer-deps`, so optional peers are not pulled in automatically.
|
|
100
|
+
Installing them explicitly records them in that package directory; they survive
|
|
101
|
+
`pi update`. For a bun- or pnpm-managed Pi install, use the equivalent add command
|
|
102
|
+
in the same directory. [Memory setup](./docs/guide.md#memory-store-memorybackend).
|
|
469
103
|
|
|
470
|
-
|
|
471
|
-
verified against Pi 0.84.x–0.85.x.
|
|
472
|
-
The settled handler never runs EESV or mutates pending state itself: after
|
|
473
|
-
checking finite context pressure, idle/queue state, per-session in-flight
|
|
474
|
-
deduplication, and cooldown, it asks Pi to compact. The existing
|
|
475
|
-
`session_before_compact` and correlated `session_compact` handlers still own
|
|
476
|
-
summary generation, cancellation, apply, and durable commit.
|
|
477
|
-
|
|
478
|
-
### Per-phase reasoning
|
|
479
|
-
|
|
480
|
-
Exploration can use a cheaper reasoning level while final synthesis and repair
|
|
481
|
-
use a stronger one:
|
|
482
|
-
|
|
483
|
-
```json
|
|
484
|
-
{
|
|
485
|
-
"smartCompact": {
|
|
486
|
-
"segmentationThinkingLevel": "low",
|
|
487
|
-
"summaryThinkingLevel": "high"
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
```
|
|
104
|
+
## One Home, five choices
|
|
491
105
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
reasoning tokens from multi-call compaction add up quickly. Supported values
|
|
495
|
-
are `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Set either value to
|
|
496
|
-
`null` to restore the provider's default behavior. An explicit call-level
|
|
497
|
-
reasoning option takes precedence.
|
|
498
|
-
|
|
499
|
-
### Cost safeguards
|
|
500
|
-
|
|
501
|
-
Automatic and tool-triggered runs operate on Pi's current active context, not
|
|
502
|
-
the append-only session history. A same-session staged summary is reused, the
|
|
503
|
-
exploration loop is limited to three rounds, provider and outer retries are
|
|
504
|
-
disabled, and every mode has finite call plus aggregate prompt-token budgets.
|
|
505
|
-
Complete tool-call/result pairs are the hard window boundary. Provider-incompatible
|
|
506
|
-
historical tool names move the boundary past their complete exchanges so a
|
|
507
|
-
provider switch cannot leave an unsendable raw tail. Recent user turns,
|
|
508
|
-
pi-toolkit checkpoints, and topical grouping are soft and may expand the raw
|
|
509
|
-
tail only while remaining inside the selected budget. Automatic/tool runs
|
|
510
|
-
normally return to Pi's native compactor without an LLM call when no
|
|
511
|
-
provider-safe hard boundary can meet the target. Overflow is the safety
|
|
512
|
-
exception: EESV keeps
|
|
513
|
-
chunked recovery rather than resending an oversized one-shot prompt to native
|
|
514
|
-
compaction. Manual `/smart-compact` uses an absolute adaptive tail rather than
|
|
515
|
-
a percentage of a large model window. A plan below 10% projected savings never
|
|
516
|
-
starts; if the measured final summary misses the same yield/target contract,
|
|
517
|
-
the run fails closed before staging or apply.
|
|
518
|
-
|
|
519
|
-
<details>
|
|
520
|
-
<summary><strong>All configuration keys</strong></summary>
|
|
521
|
-
|
|
522
|
-
| Key | Type | Default | Notes |
|
|
523
|
-
| --- | --- | --- | --- |
|
|
524
|
-
| `mode` | `auto \| fast \| balanced \| thorough` | `auto` | Automatic selector or one of the three execution modes |
|
|
525
|
-
| `profile` | `light \| balanced \| aggressive` | `balanced` | Legacy/advanced compression profile; used when mode is absent |
|
|
526
|
-
| `summaryModel` | `string \| null` | `null` | Uses the active session model when null |
|
|
527
|
-
| `segmentationModel` | `string \| null` | `null` | Optional explicit model for Explore |
|
|
528
|
-
| `verificationModel` | `string \| null` | `null` | Optional explicit model for LLM verification repair |
|
|
529
|
-
| `summaryThinkingLevel` | `minimal \| low \| medium \| high \| xhigh \| max \| null` | `minimal` | Reasoning level for synthesis and repair; provider default when null |
|
|
530
|
-
| `segmentationThinkingLevel` | `minimal \| low \| medium \| high \| xhigh \| max \| null` | `minimal` | Reasoning level for exploration; provider default when null |
|
|
531
|
-
| `agentToolAccess` | `"inherit" \| "enabled" \| "disabled"` | `"inherit"` | Respect Pi's active tools by default, or explicitly expose/hide `smart_compact`; manual command is unaffected |
|
|
532
|
-
| `autoTrigger` | `boolean` | `true` | Allow smart compaction in Pi's native hook and the selected trigger strategy |
|
|
533
|
-
| `showStatus` | `boolean` | `true` | Show the policy status line (e.g. "manual only") in Pi's footer; set `false` for a clean footer |
|
|
534
|
-
| `autoTriggerStrategy` | `native-hook \| settled` | `native-hook` | `settled` additionally requests Pi's normal compact flow after an idle high-pressure agent run; verified with Pi 0.84.x–0.85.x |
|
|
535
|
-
| `autoTriggerTimeoutMs` | `number` | `120000` | Requested auto cancellation deadline; the host hook clamps it to 60s and four LLM calls, shows live phase progress, then safely unwinds to native recovery |
|
|
536
|
-
| `minContextPercent` | `number` | `60` | Auto/tool context gate; manual `/smart-compact` warns and bypasses it |
|
|
537
|
-
| `backupEnabled` | `boolean` | `true` | Prepare a scrubbed pre-compaction backup; write it only after confirmed apply |
|
|
538
|
-
| `backupDir` | `string` | `~/.pi/agent/compact-backups` | Empty config value uses this path |
|
|
539
|
-
| `profiles` | object | built-ins | Per-profile numeric overrides |
|
|
540
|
-
| `pinPaths` | `string[]` | `[]` | Always preserve matching paths |
|
|
541
|
-
| `requireApproval` | `boolean` | `true` | Manual verified-summary review; cancel/error fails closed |
|
|
542
|
-
| `scrubSecrets` | `boolean` | `true` | High-confidence credential redaction |
|
|
543
|
-
| `scrubPii` | `boolean` | `false` | Email/phone/card-shaped redaction |
|
|
544
|
-
| `maxLlmCalls` | integer `0–100` | `8` | Global ceiling combined with the selected mode |
|
|
545
|
-
| `maxLlmInputTokens` | integer `0–1000000` | `0` | `0` uses the selected mode's aggregate prompt-token cap |
|
|
546
|
-
| `codexMaxCallMs` | integer `0` or `5000–3600000` | `0` | ChatGPT Codex per-call watchdog; `0` derives 15–90s from requested output tokens (scaled by the provider's timeout multiplier) |
|
|
547
|
-
| `maxLatencyMs` | `0` or `5000–7200000` | `0` | Pipeline cancellation deadline; `0` means unlimited |
|
|
548
|
-
| `pendingTtlMs` | integer `1000–3600000` | `300000` | How long a staged summary waits for run+session commit before expiry |
|
|
549
|
-
| `focusWeighting` | `boolean` | `true` | Weight focused topics/paths higher |
|
|
550
|
-
| `zeroCallEnabled` | `boolean` | `true` | Use deterministic synthesis for high-confidence Fast runs |
|
|
551
|
-
| `contextGraphEnabled` | `boolean` | `true` | Index verified state and enable project-scoped recall/save tools |
|
|
552
|
-
| `telemetryChannel` | `stable \| canary` | `stable` | Tag local schema-v2 metrics for external canary comparison |
|
|
553
|
-
| `onlineDamageMonitor` | `boolean` | `true` | Observe post-compaction regression signals |
|
|
554
|
-
| `adaptiveDamageFeedback` | `boolean` | `false` | Increase preservation after repeated damage |
|
|
555
|
-
|
|
556
|
-
The legacy `semanticCompact` root key is still accepted for compatibility.
|
|
557
|
-
|
|
558
|
-
</details>
|
|
559
|
-
|
|
560
|
-
## Example summary
|
|
561
|
-
|
|
562
|
-
<details>
|
|
563
|
-
<summary><strong>Show canonical output</strong></summary>
|
|
564
|
-
|
|
565
|
-
```markdown
|
|
566
|
-
## Goal
|
|
567
|
-
Tighten aggregate token budgets without breaking cancellation.
|
|
568
|
-
|
|
569
|
-
## Constraints & Preferences
|
|
570
|
-
- [requirement] Never compact mid-turn from the tool path.
|
|
571
|
-
|
|
572
|
-
## Progress
|
|
573
|
-
### Done
|
|
574
|
-
- [x] Reserved concurrent output budgets before provider calls.
|
|
575
|
-
### In Progress
|
|
576
|
-
- [ ] Collect canary evidence for the new limits.
|
|
577
|
-
### Blocked
|
|
578
|
-
- None.
|
|
579
|
-
|
|
580
|
-
## Key Decisions
|
|
581
|
-
- **Charge failed streams conservatively**: an interrupted stream consumes its output reservation.
|
|
582
|
-
|
|
583
|
-
## Files Modified
|
|
584
|
-
- src/infra/services.ts
|
|
585
|
-
- src/utils/cache.ts
|
|
586
|
-
|
|
587
|
-
## Open Loops
|
|
588
|
-
- [high] Verify provider usage reconciliation across cache-read/write responses.
|
|
589
|
-
|
|
590
|
-
## Changes Since Last Compaction
|
|
591
|
-
- Concurrent output accounting now fails closed.
|
|
592
|
-
|
|
593
|
-
## Next Steps
|
|
594
|
-
1. Run the adversarial release gate.
|
|
595
|
-
|
|
596
|
-
## Critical Context
|
|
597
|
-
- Input accounting includes uncached input, cache reads, and cache writes.
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
</details>
|
|
601
|
-
|
|
602
|
-
## Observability and recovery
|
|
603
|
-
|
|
604
|
-
```bash
|
|
605
|
-
/smart-compact metrics # text report
|
|
606
|
-
/smart-compact dashboard # interactive TUI; can write a local HTML report
|
|
607
|
-
/smart-compact restore # browse, inspect, and restore backups
|
|
608
|
-
```
|
|
106
|
+
**Compact now** · **Clean up tool output** · **Settings** ·
|
|
107
|
+
**History & recovery** · **Status & help**
|
|
609
108
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
109
|
+
Use arrows and Enter to navigate, Esc to go back, and **D** for planning or
|
|
110
|
+
result details. Home shows context usage and effective permissions; unavailable
|
|
111
|
+
actions explain why.
|
|
613
112
|
|
|
614
|
-
|
|
615
|
-
<summary><strong>Runtime artifacts</strong></summary>
|
|
616
|
-
|
|
617
|
-
Default artifacts live under `~/.pi/agent/`. Smart Compact normalizes the
|
|
618
|
-
private directories it creates to `0700` and its files to `0600`; a custom
|
|
619
|
-
`backupDir` receives the same protection. `settings.json` remains host-owned;
|
|
620
|
-
Smart Compact only updates its own `smartCompact` section through the settings
|
|
621
|
-
TUI, using a shared lock and atomic replacement while preserving other keys.
|
|
622
|
-
|
|
623
|
-
| Path | Purpose |
|
|
113
|
+
| Direct command | What happens |
|
|
624
114
|
| --- | --- |
|
|
625
|
-
| `
|
|
626
|
-
|
|
|
627
|
-
|
|
|
628
|
-
|
|
|
629
|
-
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
[
|
|
665
|
-
|
|
666
|
-
##
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
## License
|
|
115
|
+
| `/smart-compact trim` | Queues local cleanup without a model call. The next request is still untrimmed; the edit commits at the next natural completed-turn boundary. |
|
|
116
|
+
| `/smart-compact storage` | Reports archived output; never deletes it. A scan cannot prove that an unreferenced artifact is safe to remove. |
|
|
117
|
+
| `/smart-compact context` | Opens anchors, cross-session search and branch navigation. |
|
|
118
|
+
| `/smart-compact handoff dry-run` | Previews a new-session seed without opening one. Use `handoff [-- note]` to proceed. |
|
|
119
|
+
| `/smart-compact metrics` | Shows effective state, run outcomes, recent issues and the host prompt-cache ledger. |
|
|
120
|
+
|
|
121
|
+
By default the agent sees only the `smart_tools` loader, then loads the groups
|
|
122
|
+
it needs. The context guide is read on request, not injected. Tool availability
|
|
123
|
+
and compaction permission are separate controls.
|
|
124
|
+
[Agent tools](./docs/guide.md#agent-tools) · [All commands](./docs/guide.md#command-reference)
|
|
125
|
+
|
|
126
|
+
## Memory is optional; continuity is the core
|
|
127
|
+
|
|
128
|
+
No remote memory service is needed for session continuity. **Local graph** is
|
|
129
|
+
the default for on-machine scoped recall. Choose **Mnemopi** for a separate local
|
|
130
|
+
engine, or **Hindsight** for your existing server and bank. Only the selected
|
|
131
|
+
backend is read or written; failures never silently fall back to another store.
|
|
132
|
+
|
|
133
|
+
Explicit saves require confirmation. When enabled, the local graph also indexes
|
|
134
|
+
derived state after host-confirmed compactions. None of these stores replaces
|
|
135
|
+
session backups or archived tool output.
|
|
136
|
+
[Memory workflows](./docs/guide.md#memory-what-is-stored-where) · [Hindsight and privacy](./docs/hindsight-memory.md)
|
|
137
|
+
|
|
138
|
+
## Boundaries worth knowing
|
|
139
|
+
|
|
140
|
+
- **Recovery is bounded.** Rewind does not undo file changes. Archives cannot
|
|
141
|
+
restore bytes omitted before Pi recorded the output.
|
|
142
|
+
- **Review the summary.** Extraction and deterministic verification can miss
|
|
143
|
+
information. A verifier score is not a measure of task success.
|
|
144
|
+
- **Experimental formats are opt-in.** Provider-native summaries are not
|
|
145
|
+
EESV-verified. Image snapshots need a supported reader and a cost check;
|
|
146
|
+
otherwise text is used.
|
|
147
|
+
- **Claude OAuth needs a compatible adapter.** The published
|
|
148
|
+
`pi-claude-oauth-adapter@0.2.2` normalizes Pi's own requests, not all nested
|
|
149
|
+
model-runtime calls. Full coverage needs final-payload normalization
|
|
150
|
+
([upstream PR #10](https://github.com/minzique/pi-claude-oauth-adapter/pull/10)).
|
|
151
|
+
[Compatibility details](./docs/guide.md#summary-format-provider-compaction-and-images).
|
|
152
|
+
- **Cost and quality need live evidence.** Cancelled or discarded preparation
|
|
153
|
+
still costs. Offline pilots do not establish billed savings, model fidelity
|
|
154
|
+
or production readiness. [Evaluation limits](./docs/evaluation.md).
|
|
155
|
+
|
|
156
|
+
## Documentation and development
|
|
157
|
+
|
|
158
|
+
| Need | Start here |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| Use, configure or recover a session | [User guide](./docs/guide.md) · [Configuration](./docs/configuration.md) |
|
|
161
|
+
| Understand internals or evaluate behavior | [Architecture](./ARCHITECTURE.md) · [Evaluation](./docs/evaluation.md) |
|
|
162
|
+
| Contribute or prepare a package | [Contributing](https://github.com/alpertarhan/pi-smart-compact/blob/main/CONTRIBUTING.md) · [Release checklist](./docs/RELEASE.md) |
|
|
163
|
+
| Report a problem safely | [Support](./SUPPORT.md) · [Security](./SECURITY.md) |
|
|
164
|
+
| Browse every guide and historical report | [Documentation index](./docs/README.md) |
|
|
677
165
|
|
|
678
|
-
MIT © [Alper Tarhan](https://github.com/alpertarhan)
|
|
166
|
+
[MIT](./LICENSE) © [Alper Tarhan](https://github.com/alpertarhan).
|