pi-smart-compact 7.10.0 → 7.12.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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.12.1] - 2026-05-19
4
+
5
+ ### Fixed
6
+ - **Pi package gallery preview** — Added `pi.image` metadata pointing to the packaged logo asset so pi.dev/package listings can render the package image.
7
+
8
+ ## [7.12.0] - 2026-05-19
9
+
10
+ ### Added
11
+ - **Performance monitoring report** — Metrics now include run status, method, provider/model, run type, total duration, verification gaps, and phase timings. `/smart-compact metrics` and the `smart_compact` tool's `report` parameter return a profile/provider comparison report for A/B-style evaluation.
12
+ - **Professional local HTML dashboard** — `/smart-compact dashboard` and `smart_compact({ dashboard: true })` write `.cache/smart-compact-report.html` with KPI cards, reliability badges, duration trends, profile/provider comparison tables, phase timing bars, recent-run diagnostics, responsive dark/light styling, and aggregate metrics.
13
+ - **Provider strategy fields** — Provider capabilities now include timeout multipliers, single-pass threshold multipliers, and multimodal support mode. Auto-trigger timeout and single-pass selection adapt to the selected provider.
14
+ - **Multimodal metadata extraction** — The deterministic extractor now preserves image/file/audio/video attachment metadata without embedding binary/base64 payloads in summaries.
15
+
16
+ ### Fixed
17
+ - **Manual tool timeout warning** — `smart_compact` tool calls no longer inherit the native auto-trigger timeout. The timeout guard now only applies when Pi's `session_before_compact` hook is trying to prepare a summary before native compaction.
18
+ - **Auto-trigger robustness** — Increased the default `autoTriggerTimeoutMs` from 45s to 120s, cleared the hook timeout timer deterministically, and kept the native fallback warning specific to auto-trigger runs.
19
+ - **Single-pass output budget** — Single-pass compaction now caps `maxTokens` to the selected profile's `summaryBudgetTokens` instead of the provider's maximum output size.
20
+ - **Runtime version drift** — Synced the exported runtime `VERSION` with `package.json` and added a regression test.
21
+ - **Config validation hardening** — Invalid per-profile overrides are now sanitized instead of reaching the compaction pipeline as non-numeric budget values.
22
+ - **Metrics failure observability** — Timeout and unexpected error exits now write metrics entries with `status: "timeout"` or `status: "error"` before rethrowing.
23
+ - **Dashboard hardening** — The local HTML dashboard escapes metric values and the metrics reader skips corrupt JSONL rows instead of dropping the whole report.
24
+
25
+ ### Performance
26
+ - **Session log recovery cache** — Session log path lookup and parsed message maps are cached with mtime/size invalidation to avoid repeatedly scanning `~/.pi/agent/sessions` during recovery.
27
+
28
+ ## [7.11.0] - 2026-05-19
29
+
30
+ ### Changed
31
+ - **README compatibility guidance** — Added a prominent note documenting conflict-prone extension behavior around compaction hooks, session/branch history, message and tool metadata, tool output rewriting, compaction boundaries, and session log storage. Also clarified that `pi-smart-compact` is recommended alongside `pi-toolkit` for complementary context hygiene and verified compaction.
32
+
3
33
  ## [7.10.0] - 2026-05-19
4
34
 
5
35
  ### Added
package/README.md CHANGED
@@ -37,6 +37,25 @@ The extension stages a short-lived pending summary in memory, then hands it back
37
37
 
38
38
  ---
39
39
 
40
+ ## Compatibility note
41
+
42
+ `pi-smart-compact` sits close to Pi's compaction path: it registers `session_before_compact`, reads the active branch and session log, stages a pending summary, and may call Pi's native compaction flow from `/smart-compact`.
43
+
44
+ Because of that, use extra care with extensions that also manipulate:
45
+
46
+ - **compaction hooks** — especially extensions that return a custom result from `session_before_compact`
47
+ - **session / branch history** — rewriting, pruning, reordering, or replacing entries before compaction
48
+ - **message identity** — removing entry IDs, tool-call IDs, or tool-result metadata used to align log entries
49
+ - **tool output content** — truncating or rewriting `toolResult` messages before extraction
50
+ - **compaction boundaries** — moving the keep/discard split or splitting `toolCall` / `toolResult` pairs
51
+ - **session log storage** — replacing or deleting Pi's `.jsonl` logs under `~/.pi/agent/sessions`
52
+
53
+ It is intentionally compatible with, and recommended alongside, [`pi-toolkit`](https://github.com/ersintarhan/pi-toolkit): pi-toolkit handles everyday context hygiene such as anchors, pivots, status lines, and old tool-output trimming; `pi-smart-compact` handles high-pressure verified compaction. The integration protects recent pi-toolkit anchors and can recover original tool outputs from the session log when older tool results were trimmed.
54
+
55
+ If you use another automatic compaction or context-rewriting extension, prefer enabling only one `session_before_compact` owner unless the hook order and returned values are explicitly coordinated.
56
+
57
+ ---
58
+
40
59
  ## Why it exists
41
60
 
42
61
  Default compaction often loses the parts that matter most during coding work:
@@ -134,6 +153,8 @@ With no arguments, the extension opens a small picker for:
134
153
  /smart-compact anthropic/claude-sonnet-4 balanced
135
154
  /smart-compact dry-run
136
155
  /smart-compact debug
156
+ /smart-compact metrics
157
+ /smart-compact dashboard
137
158
  /smart-compact "focus on auth changes and unresolved follow-up work"
138
159
  ```
139
160
 
@@ -145,7 +166,9 @@ With no arguments, the extension opens a small picker for:
145
166
  "parameters": {
146
167
  "profile": "balanced",
147
168
  "verbose": false,
148
- "dry_run": false
169
+ "dry_run": false,
170
+ "report": false,
171
+ "dashboard": false
149
172
  }
150
173
  }
151
174
  ```
@@ -160,6 +183,8 @@ The tool prepares a pending smart summary and lets Pi consume it on the next nat
160
183
  - the tool path does **not** compact the conversation mid-turn
161
184
  - pending summaries are kept in memory for **5 minutes**
162
185
  - exploration is adaptive and may be skipped for simple sessions
186
+ - use `/smart-compact metrics` for profile/provider comparisons
187
+ - use `/smart-compact dashboard` to write a local HTML report at `.cache/smart-compact-report.html`
163
188
 
164
189
  This keeps the extension helpful without forcing extra work when it is not needed.
165
190
 
@@ -176,6 +201,7 @@ Add this to `~/.pi/agent/settings.json`:
176
201
  "summaryModel": "anthropic/claude-sonnet-4",
177
202
  "segmentationModel": "anthropic/claude-haiku-3",
178
203
  "autoTrigger": true,
204
+ "autoTriggerTimeoutMs": 120000,
179
205
  "backupEnabled": true,
180
206
  "profiles": {
181
207
  "balanced": {
@@ -195,6 +221,7 @@ Add this to `~/.pi/agent/settings.json`:
195
221
  | `summaryModel` | `string \| null` | `null` |
196
222
  | `segmentationModel` | `string \| null` | `null` |
197
223
  | `autoTrigger` | `boolean` | `true` |
224
+ | `autoTriggerTimeoutMs` | `number` | `120000` |
198
225
  | `backupEnabled` | `boolean` | `true` |
199
226
  | `backupDir` | `string` | `~/.pi/agent/compact-backups` |
200
227
  | `profiles` | partial per-profile overrides | built-ins |
@@ -250,8 +277,10 @@ The current design includes:
250
277
  - hallucinated file-reference detection
251
278
  - open-loop injection
252
279
  - project fingerprinting and delta tracking
280
+ - provider-specific timeout and single-pass strategies
281
+ - multimodal attachment metadata preservation
253
282
  - backup creation before compaction
254
- - metrics logging and damage detection
283
+ - metrics logging, profile/provider comparison, and damage detection
255
284
 
256
285
  ---
257
286
 
@@ -263,6 +292,7 @@ At runtime, the extension writes to paths under `~/.pi/agent/`, including:
263
292
  - `compact-backups/`
264
293
  - `.cache/compact-extraction-<session>.json`
265
294
  - `.cache/compact-metrics.jsonl`
295
+ - `.cache/smart-compact-report.html`
266
296
  - `.cache/smart-compact/projects/<projectId>.json`
267
297
  - `.cache/smart-compact/states/<projectId>.json`
268
298
  - `.cache/smart-compact/damage-reports.jsonl`
@@ -2,7 +2,7 @@
2
2
  * Constants, prompts, and profile defaults.
3
3
  */
4
4
  import type { CompressionProfile, ProfileConfig } from "./types.ts";
5
- export declare const VERSION = "7.9.5";
5
+ export declare const VERSION = "7.12.1";
6
6
  export declare const CHARS_PER_TOKEN = 3.8;
7
7
  export declare const COMPACT_SYSTEM_PREFIX: string;
8
8
  export declare const PROFILES: Record<CompressionProfile, ProfileConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpE,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,qBAAqB,QAKqB,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAyB9D,CAAC;AAEF,eAAO,MAAM,cAAc;aACF,kBAAkB;;kBAEnB,MAAM,GAAG,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AAC;AAClD,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAGlE,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAG5C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAGxC,eAAO,MAAM,UAAU,iBAAiB,CAAC;AACzC,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,sBAAsB,QAU6T,CAAC"}
package/dist/core.d.ts CHANGED
@@ -22,6 +22,8 @@ export interface SmartCompactOptions {
22
22
  autoTriggered?: boolean;
23
23
  userNote?: string;
24
24
  skipCompact?: boolean;
25
+ /** Optional hard budget for native auto-trigger only. Manual/tool runs do not time out by default. */
26
+ timeoutMs?: number;
25
27
  }
26
28
  export declare function runSmartCompact(opts: SmartCompactOptions): Promise<void>;
27
29
  //# sourceMappingURL=core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,kBAAkB,EAAE,iBAAiB,EAEtC,MAAM,YAAY,CAAC;AAuBpB,yEAAyE;AACzE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,uBAAuB,CAAC;IAC7B,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE;QAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,SA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@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,iCAAiC,CAAC;AAwC7F,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,EAAE,YAAY,QA2J7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,iCAAiC,CAAC;AA0C7F,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,EAAE,YAAY,QA6K7D"}