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.
Files changed (206) hide show
  1. package/ARCHITECTURE.md +973 -372
  2. package/CHANGELOG.md +721 -0
  3. package/LICENSE +8 -0
  4. package/README.md +128 -640
  5. package/SECURITY.md +34 -12
  6. package/SUPPORT.md +26 -9
  7. package/assets/DejaVu-LICENSE.txt +187 -0
  8. package/assets/DejaVuSansMono.ttf +0 -0
  9. package/assets/README.md +26 -0
  10. package/assets/skills/context-management/SKILL.md +34 -0
  11. package/dist/app/anchor-cache.d.ts +36 -0
  12. package/dist/app/anchor-cache.d.ts.map +1 -0
  13. package/dist/app/artifact-storage.d.ts +47 -0
  14. package/dist/app/artifact-storage.d.ts.map +1 -0
  15. package/dist/app/background-preparation.d.ts +39 -0
  16. package/dist/app/background-preparation.d.ts.map +1 -0
  17. package/dist/app/compaction-commit-store.d.ts +5 -1
  18. package/dist/app/compaction-commit-store.d.ts.map +1 -1
  19. package/dist/app/context-evidence.d.ts +57 -0
  20. package/dist/app/context-evidence.d.ts.map +1 -0
  21. package/dist/app/context-guide.d.ts +3 -0
  22. package/dist/app/context-guide.d.ts.map +1 -0
  23. package/dist/app/context-operations.d.ts +106 -0
  24. package/dist/app/context-operations.d.ts.map +1 -0
  25. package/dist/app/effective-state.d.ts +23 -0
  26. package/dist/app/effective-state.d.ts.map +1 -0
  27. package/dist/app/global-settings-runtime.d.ts +3 -3
  28. package/dist/app/global-settings-runtime.d.ts.map +1 -1
  29. package/dist/app/hindsight-memory.d.ts +100 -0
  30. package/dist/app/hindsight-memory.d.ts.map +1 -0
  31. package/dist/app/host-cache-ledger.d.ts +68 -0
  32. package/dist/app/host-cache-ledger.d.ts.map +1 -0
  33. package/dist/app/lazy-tools.d.ts +36 -0
  34. package/dist/app/lazy-tools.d.ts.map +1 -0
  35. package/dist/app/memory-backend.d.ts +58 -0
  36. package/dist/app/memory-backend.d.ts.map +1 -0
  37. package/dist/app/mnemopi-memory.d.ts +13 -0
  38. package/dist/app/mnemopi-memory.d.ts.map +1 -0
  39. package/dist/app/mnemopi-protocol.d.ts +78 -0
  40. package/dist/app/mnemopi-protocol.d.ts.map +1 -0
  41. package/dist/app/mnemopi-worker.d.ts +2 -0
  42. package/dist/app/mnemopi-worker.d.ts.map +1 -0
  43. package/dist/app/model-feasibility.d.ts +20 -0
  44. package/dist/app/model-feasibility.d.ts.map +1 -0
  45. package/dist/app/native-compaction.d.ts +88 -0
  46. package/dist/app/native-compaction.d.ts.map +1 -0
  47. package/dist/app/native-continuity-bridge.d.ts.map +1 -1
  48. package/dist/app/navigation-data.d.ts +28 -0
  49. package/dist/app/navigation-data.d.ts.map +1 -0
  50. package/dist/app/navigation-types.d.ts +60 -0
  51. package/dist/app/navigation-types.d.ts.map +1 -0
  52. package/dist/app/pending-slot.d.ts +11 -1
  53. package/dist/app/pending-slot.d.ts.map +1 -1
  54. package/dist/app/preflight.d.ts.map +1 -1
  55. package/dist/app/register-context-tools.d.ts +16 -3
  56. package/dist/app/register-context-tools.d.ts.map +1 -1
  57. package/dist/app/register-navigation.d.ts +20 -0
  58. package/dist/app/register-navigation.d.ts.map +1 -0
  59. package/dist/app/register-smart-compact-command.d.ts +17 -2
  60. package/dist/app/register-smart-compact-command.d.ts.map +1 -1
  61. package/dist/app/register-smart-compact-tool.d.ts.map +1 -1
  62. package/dist/app/register-smart-context-tool.d.ts +55 -0
  63. package/dist/app/register-smart-context-tool.d.ts.map +1 -0
  64. package/dist/app/run-context.d.ts +1 -0
  65. package/dist/app/run-context.d.ts.map +1 -1
  66. package/dist/app/run-smart-compact.d.ts +3 -3
  67. package/dist/app/run-smart-compact.d.ts.map +1 -1
  68. package/dist/app/session-handoff.d.ts +64 -0
  69. package/dist/app/session-handoff.d.ts.map +1 -0
  70. package/dist/app/session-lineage.d.ts +17 -0
  71. package/dist/app/session-lineage.d.ts.map +1 -0
  72. package/dist/app/session-run-lock.d.ts +0 -2
  73. package/dist/app/session-run-lock.d.ts.map +1 -1
  74. package/dist/app/settled-auto-trigger.d.ts +2 -0
  75. package/dist/app/settled-auto-trigger.d.ts.map +1 -1
  76. package/dist/app/smart-compact-input.d.ts +1 -1
  77. package/dist/app/smart-compact-input.d.ts.map +1 -1
  78. package/dist/app/smart-compact-policy.d.ts +1 -1
  79. package/dist/app/smart-compact-policy.d.ts.map +1 -1
  80. package/dist/app/steps/extract.d.ts +45 -1
  81. package/dist/app/steps/extract.d.ts.map +1 -1
  82. package/dist/app/steps/metrics.d.ts +1 -0
  83. package/dist/app/steps/metrics.d.ts.map +1 -1
  84. package/dist/app/steps/persist.d.ts.map +1 -1
  85. package/dist/app/steps/prepare.d.ts.map +1 -1
  86. package/dist/app/steps/recover.d.ts +9 -0
  87. package/dist/app/steps/recover.d.ts.map +1 -1
  88. package/dist/app/steps/synthesize.d.ts.map +1 -1
  89. package/dist/app/steps/tier.d.ts.map +1 -1
  90. package/dist/app/steps/verify.d.ts.map +1 -1
  91. package/dist/app/steps/visual.d.ts +4 -0
  92. package/dist/app/steps/visual.d.ts.map +1 -0
  93. package/dist/app/steps/window.d.ts.map +1 -1
  94. package/dist/app/tool-artifacts.d.ts +27 -0
  95. package/dist/app/tool-artifacts.d.ts.map +1 -0
  96. package/dist/app/visual-archive.d.ts +29 -0
  97. package/dist/app/visual-archive.d.ts.map +1 -0
  98. package/dist/constants.d.ts +96 -1
  99. package/dist/constants.d.ts.map +1 -1
  100. package/dist/domain/compaction-usage.d.ts +16 -0
  101. package/dist/domain/compaction-usage.d.ts.map +1 -0
  102. package/dist/domain/model-capacity.d.ts +12 -0
  103. package/dist/domain/model-capacity.d.ts.map +1 -0
  104. package/dist/domain/provider-evaluation.d.ts +7 -0
  105. package/dist/domain/provider-evaluation.d.ts.map +1 -1
  106. package/dist/domain/telemetry.d.ts +43 -2
  107. package/dist/domain/telemetry.d.ts.map +1 -1
  108. package/dist/domain/tool-semantics.d.ts +23 -0
  109. package/dist/domain/tool-semantics.d.ts.map +1 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +15757 -6942
  112. package/dist/infra/ai-messages.d.ts +1 -1
  113. package/dist/infra/ai-messages.d.ts.map +1 -1
  114. package/dist/infra/context-graph.d.ts +38 -7
  115. package/dist/infra/context-graph.d.ts.map +1 -1
  116. package/dist/infra/fs.d.ts.map +1 -1
  117. package/dist/infra/hindsight-client.d.ts +73 -0
  118. package/dist/infra/hindsight-client.d.ts.map +1 -0
  119. package/dist/infra/hindsight-receipts.d.ts +68 -0
  120. package/dist/infra/hindsight-receipts.d.ts.map +1 -0
  121. package/dist/infra/llm-client.d.ts +26 -23
  122. package/dist/infra/llm-client.d.ts.map +1 -1
  123. package/dist/infra/memory-ref.d.ts +27 -0
  124. package/dist/infra/memory-ref.d.ts.map +1 -0
  125. package/dist/infra/native-protocol.d.ts +54 -0
  126. package/dist/infra/native-protocol.d.ts.map +1 -0
  127. package/dist/infra/optional-components.d.ts +15 -0
  128. package/dist/infra/optional-components.d.ts.map +1 -0
  129. package/dist/infra/paths.d.ts +2 -0
  130. package/dist/infra/paths.d.ts.map +1 -1
  131. package/dist/infra/services.d.ts +15 -5
  132. package/dist/infra/services.d.ts.map +1 -1
  133. package/dist/infra/visual-renderer.d.ts +16 -0
  134. package/dist/infra/visual-renderer.d.ts.map +1 -0
  135. package/dist/mnemopi-worker.js +213 -0
  136. package/dist/phases/explore.d.ts +12 -9
  137. package/dist/phases/explore.d.ts.map +1 -1
  138. package/dist/phases/synthesize.d.ts +18 -3
  139. package/dist/phases/synthesize.d.ts.map +1 -1
  140. package/dist/phases/verify.d.ts +5 -1
  141. package/dist/phases/verify.d.ts.map +1 -1
  142. package/dist/rtk.d.ts +7 -0
  143. package/dist/rtk.d.ts.map +1 -0
  144. package/dist/rtk.js +767 -0
  145. package/dist/types.d.ts +128 -4
  146. package/dist/types.d.ts.map +1 -1
  147. package/dist/ui/dashboard-format.d.ts +2 -1
  148. package/dist/ui/dashboard-format.d.ts.map +1 -1
  149. package/dist/ui/dashboard-insights.d.ts +9 -1
  150. package/dist/ui/dashboard-insights.d.ts.map +1 -1
  151. package/dist/ui/error-format.d.ts +7 -2
  152. package/dist/ui/error-format.d.ts.map +1 -1
  153. package/dist/ui/handoff-overlay.d.ts +26 -0
  154. package/dist/ui/handoff-overlay.d.ts.map +1 -0
  155. package/dist/ui/home-overlay.d.ts +54 -0
  156. package/dist/ui/home-overlay.d.ts.map +1 -0
  157. package/dist/ui/metrics-dashboard-overlay.d.ts.map +1 -1
  158. package/dist/ui/metrics-report.d.ts.map +1 -1
  159. package/dist/ui/navigation-overlay.d.ts +92 -0
  160. package/dist/ui/navigation-overlay.d.ts.map +1 -0
  161. package/dist/ui/overlays.d.ts +12 -2
  162. package/dist/ui/overlays.d.ts.map +1 -1
  163. package/dist/ui/profiles.d.ts +51 -0
  164. package/dist/ui/profiles.d.ts.map +1 -0
  165. package/dist/ui/settings-complex.d.ts +49 -3
  166. package/dist/ui/settings-complex.d.ts.map +1 -1
  167. package/dist/ui/settings-list.d.ts +28 -0
  168. package/dist/ui/settings-list.d.ts.map +1 -0
  169. package/dist/ui/settings-overlay.d.ts +13 -6
  170. package/dist/ui/settings-overlay.d.ts.map +1 -1
  171. package/dist/ui/storage-report.d.ts +4 -0
  172. package/dist/ui/storage-report.d.ts.map +1 -0
  173. package/dist/utils/backups.d.ts.map +1 -1
  174. package/dist/utils/cache.d.ts +6 -2
  175. package/dist/utils/cache.d.ts.map +1 -1
  176. package/dist/utils/config.d.ts +12 -0
  177. package/dist/utils/config.d.ts.map +1 -1
  178. package/dist/utils/helpers.d.ts.map +1 -1
  179. package/dist/utils/id-fingerprint.d.ts +3 -1
  180. package/dist/utils/id-fingerprint.d.ts.map +1 -1
  181. package/dist/utils/issues.d.ts +61 -0
  182. package/dist/utils/issues.d.ts.map +1 -0
  183. package/dist/utils/pruning.d.ts.map +1 -1
  184. package/dist/utils/session-log.d.ts +0 -2
  185. package/dist/utils/session-log.d.ts.map +1 -1
  186. package/dist/utils/state.d.ts +3 -1
  187. package/dist/utils/state.d.ts.map +1 -1
  188. package/dist/utils/tokens.d.ts +10 -2
  189. package/dist/utils/tokens.d.ts.map +1 -1
  190. package/docs/MIGRATING_TO_V8.md +7 -1
  191. package/docs/README.md +69 -0
  192. package/docs/RELEASE.md +173 -56
  193. package/docs/assets/banner.png +0 -0
  194. package/docs/assets/banner.svg +1158 -70
  195. package/docs/assets/pi-smart-compact.png +0 -0
  196. package/docs/assets/pi-smart-compact.svg +24 -0
  197. package/docs/configuration.md +637 -0
  198. package/docs/evaluation.md +408 -0
  199. package/docs/guide.md +860 -0
  200. package/docs/hindsight-memory.md +314 -0
  201. package/docs/identity.md +124 -0
  202. package/package.json +44 -11
  203. package/dist/provider-eval.js +0 -2122
  204. package/dist/provider-scenario-eval.js +0 -2900
  205. package/dist/telemetry-report.js +0 -1973
  206. package/docs/provider-evaluation-2026-08-06.md +0 -63
package/README.md CHANGED
@@ -1,678 +1,166 @@
1
- <div align="center">
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
- <a href="https://github.com/alpertarhan/pi-smart-compact">
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
- [![CI](https://github.com/alpertarhan/pi-smart-compact/actions/workflows/ci.yml/badge.svg)](https://github.com/alpertarhan/pi-smart-compact/actions/workflows/ci.yml)
8
- [![npm version](https://img.shields.io/npm/v/pi-smart-compact?color=60a5fa)](https://www.npmjs.com/package/pi-smart-compact)
9
- [![license](https://img.shields.io/npm/l/pi-smart-compact?color=22c55e)](https://github.com/alpertarhan/pi-smart-compact/blob/main/LICENSE)
10
- [![Pi package](https://img.shields.io/badge/Pi-package-fbbf24)](https://github.com/earendil-works/pi)
7
+ **Keep useful context. Keep the way back.**
11
8
 
12
- ### Verification-oriented context compaction for the Pi Coding Agent
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
- Preserve the agent's **working state**—goals, files, decisions, errors,
15
- constraints, and open loops—not just a vague recap of the conversation.
14
+ [Get started](#get-started) · [User guide](./docs/guide.md) ·
15
+ [Configuration](./docs/configuration.md) · [Documentation index](./docs/README.md)
16
16
 
17
- **Deterministic facts · fail-closed verification · branch-safe continuity · local-first privacy**
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
- [Install](#install) · [Why](#why-smart-compaction) · [Pipeline](#eesv-pipeline) · [Safety](#safety-and-privacy) · [Configuration](#configuration) · [Development](#development)
27
+ ## What it does
20
28
 
21
- </div>
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
- ## Install
43
+ ## Get started
24
44
 
25
- Requires the Pi Coding Agent on Node.js 22.19 or newer. The published extension
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 run `/smart-compact` for an explainable preflight before anything changes.
33
-
34
- ## Quick start
51
+ Then, in Pi's interactive TUI:
35
52
 
36
- ```bash
37
- /smart-compact # interactive preflight
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
- Command controls are consumed only from the left edge. Once note text starts,
52
- words such as `fast`, `balanced`, and paths such as `src/auth.ts` remain note
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
- > [!IMPORTANT]
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
- ## Why smart compaction?
68
-
69
- | Native-style recap | `pi-smart-compact` |
62
+ | Preset | Behavior |
70
63
  | --- | --- |
71
- | Summarizes prose | Preserves operational coding state |
72
- | Trusts one LLM response | Extracts deterministic ground truth first |
73
- | File/error omissions can be silent | Verifies coverage and repairs known gaps |
74
- | One strategy for every session | Chooses single-pass or hierarchical synthesis |
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
- The design principle is simple:
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
- > **Facts first. Synthesis second. Verification before apply.**
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
- Any unresolved verification gap rejects the custom summary before staging or apply. High-risk outcome claims such as “tests passed” or “deployed” must match source messages or a successful related tool result; unsupported claims are removed deterministically. A zero-gap fallback built only from extraction, continuity, and explicit focus/note steering is preferred over unverifiable model output; untrusted chunk prose cannot become the quality floor. A successful compaction must also meet its mode target and at least 10% estimated net savings both before synthesis and after the final summary is measured. Automatic failures leave Pi free to use its native compactor, while manual failures leave the conversation unchanged.
78
+ ### Optional components
83
79
 
84
- ## EESV pipeline
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
- ```text
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
- | Explore / segmentation | `segmentationModel` | selected model |
261
- | Synthesis / assembly | `summaryModel` | selected model |
262
- | Verification repair | `verificationModel` | summary/selected model |
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
- ```bash
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
- It covers common API keys (including Google and Stripe), AWS/GitHub/GitLab/npm/
354
- Slack tokens, JWTs, bearer tokens, private keys, secret-bearing object fields,
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
- /smart-compact loops
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
- `/smart-compact settings` separates **Current branch** overrides from **Global**
433
- defaults. The three branch controls (agent access, automatic compaction, and
434
- footer status) are stored in session history; session-tree navigation restores
435
- that branch's sparse overrides. Choosing `global` removes an override. Global
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
- `settled` requires a Pi host that emits `agent_settled`; the release boundary is
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
- `segmentationThinkingLevel` applies to exploration; `summaryThinkingLevel`
493
- applies to synthesis, assembly, and repair. Both default to `minimal` because
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
- Metrics include effective mode, profile, provider, phase timing, token/call estimates,
611
- verification quality, cache behavior, redactions, adaptation, fallbacks, and
612
- cancelled runs.
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
- <details>
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
- | `settings.json` | Host configuration; the settings TUI can update `smartCompact` defaults |
626
- | `compact-backups/` | Recovered selected pre-prune text backups without tool-output truncation; scrubbed and retention-pruned |
627
- | `.cache/compact-extraction-<session>.json` | Incremental extraction cache |
628
- | `.cache/compact-metrics.jsonl` | Tail-retained metrics log; 5 MiB cap |
629
- | `.cache/smart-compact-report.html` | Local HTML dashboard |
630
- | `.cache/smart-compact/projects/<projectId>.json` | Project fingerprint |
631
- | `.cache/smart-compact/states/<projectId>/<sessionId>.json` | Scoped compaction state and loop overrides |
632
- | `.cache/smart-compact/run-locks/` | 0600 cross-process session/global concurrency leases |
633
- | `.cache/smart-compact/native-continuity/` | 0600 one-shot project/session/branch handoffs |
634
- | `.cache/smart-compact/context-graph.sqlite` | Project-isolated FTS5 context graph and explicit saved memory |
635
- | `.cache/smart-compact/damage-reports.jsonl` | Damage reports; 5 MiB cap |
636
- | `.cache/smart-compact/remediation-<projectId>.json` | Files to preserve after damage |
637
-
638
- </details>
639
-
640
- ## Compatibility
641
-
642
- Pi core packages are host-provided wildcard peers and are excluded from the
643
- published bundle. The lockfile gives contributors a reproducible baseline,
644
- while CI validates the latest Pi release daily without changing the manifest.
645
- An exact version can be checked with `bun run compat:pi <version>`.
646
-
647
- `pi-smart-compact` is designed to coexist with
648
- [`pi-toolkit`](https://github.com/ersintarhan/pi-toolkit): toolkit handles daily
649
- context hygiene; smart-compact handles high-pressure verified compaction. If
650
- another extension also owns `session_before_compact` or rewrites branch history,
651
- coordinate hook order or prefer a single automatic compaction owner.
652
-
653
- ## Development
654
-
655
- ```bash
656
- bun install --frozen-lockfile
657
- bun run release:check # typecheck + tests + adversarial/performance gates + build + package audit
658
- bun run bench # standalone hot-path p95 regression gate
659
- bun run compat:pi # isolated latest-Pi compatibility check
660
- ```
661
-
662
- Pull requests run the same deterministic checks in GitHub Actions. See
663
- [CONTRIBUTING.md](./CONTRIBUTING.md) for focused test commands and
664
- [docs/RELEASE.md](./docs/RELEASE.md) for publication and canary gates.
665
-
666
- ## Project documentation
667
-
668
- - [Architecture](https://github.com/alpertarhan/pi-smart-compact/blob/main/ARCHITECTURE.md)
669
- - [Changelog](https://github.com/alpertarhan/pi-smart-compact/blob/main/CHANGELOG.md)
670
- - [Contributing](https://github.com/alpertarhan/pi-smart-compact/blob/main/CONTRIBUTING.md)
671
- - [Security](https://github.com/alpertarhan/pi-smart-compact/blob/main/SECURITY.md)
672
- - [Support](https://github.com/alpertarhan/pi-smart-compact/blob/main/SUPPORT.md)
673
- - [v8 migration guide](https://github.com/alpertarhan/pi-smart-compact/blob/main/docs/MIGRATING_TO_V8.md)
674
- - [Release checklist](https://github.com/alpertarhan/pi-smart-compact/blob/main/docs/RELEASE.md)
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).