pi-smart-compact 7.11.0 → 7.12.4

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,54 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.12.4] - 2026-05-20
4
+
5
+ ### Fixed
6
+ - **Manual command override** — Explicit user-run `/smart-compact` commands now bypass the adaptive `minContextPercent` tier gate, while auto-trigger and agent tool calls still respect it. This keeps cache-protective behavior for agents but preserves user control.
7
+
8
+ ## [7.12.3] - 2026-05-20
9
+
10
+ ### Changed
11
+ - **Safer pi-toolkit threshold** — Raised the default `minContextPercent` from 30 to 60 so high `tool=XX%` ratios from pi-auto-context do not trigger smart compaction while actual context usage is still moderate.
12
+ - **Agent guidance** — Updated the `smart_compact` tool description and guidelines to explicitly ignore pi-auto-context `tool=XX%` as a compaction signal and use actual `context=XX%` instead.
13
+ - **Package image metadata** — Switched the package gallery image URL to the stable `main` asset path to avoid version-tag drift.
14
+
15
+ ### Fixed
16
+ - **Provider capability mapping** — Added explicit pi-toolkit provider entries for `kimi-coding`, `xiaomi-mimo`, and `crofai` so timeout/concurrency/cache metadata does not fall through to generic defaults.
17
+ - **Open-loop indexing** — Replaced `msgs.indexOf(msg)` with indexed loops in open-loop extraction to avoid O(n²) scans and incorrect source indexes for repeated message references.
18
+ - **Batch summary fallback** — Hardened `summarizeBatch()` so a missing or merged LLM section falls back to the original chunk preview instead of producing an empty segment summary.
19
+ - **Pending summary observability** — Log when an expired pending smart summary is discarded.
20
+
21
+ ## [7.12.2] - 2026-05-20
22
+
23
+ ### Fixed
24
+ - **Context threshold guard completion** — Completed the `minContextPercent` guard across config, types, tier selection, core pipeline, tool handler, and tests.
25
+ - **Precise threshold comparison** — `smart_compact` now compares raw context percentage for the guard and uses rounded percentage only for user-facing text.
26
+
27
+ ## [7.12.1] - 2026-05-19
28
+
29
+ ### Fixed
30
+ - **Pi package gallery preview** — Added `pi.image` metadata pointing to the packaged logo asset so pi.dev/package listings can render the package image.
31
+
32
+ ## [7.12.0] - 2026-05-19
33
+
34
+ ### Added
35
+ - **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.
36
+ - **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.
37
+ - **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.
38
+ - **Multimodal metadata extraction** — The deterministic extractor now preserves image/file/audio/video attachment metadata without embedding binary/base64 payloads in summaries.
39
+
40
+ ### Fixed
41
+ - **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.
42
+ - **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.
43
+ - **Single-pass output budget** — Single-pass compaction now caps `maxTokens` to the selected profile's `summaryBudgetTokens` instead of the provider's maximum output size.
44
+ - **Runtime version drift** — Synced the exported runtime `VERSION` with `package.json` and added a regression test.
45
+ - **Config validation hardening** — Invalid per-profile overrides are now sanitized instead of reaching the compaction pipeline as non-numeric budget values.
46
+ - **Metrics failure observability** — Timeout and unexpected error exits now write metrics entries with `status: "timeout"` or `status: "error"` before rethrowing.
47
+ - **Dashboard hardening** — The local HTML dashboard escapes metric values and the metrics reader skips corrupt JSONL rows instead of dropping the whole report.
48
+
49
+ ### Performance
50
+ - **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.
51
+
3
52
  ## [7.11.0] - 2026-05-19
4
53
 
5
54
  ### Changed
package/README.md CHANGED
@@ -153,6 +153,8 @@ With no arguments, the extension opens a small picker for:
153
153
  /smart-compact anthropic/claude-sonnet-4 balanced
154
154
  /smart-compact dry-run
155
155
  /smart-compact debug
156
+ /smart-compact metrics
157
+ /smart-compact dashboard
156
158
  /smart-compact "focus on auth changes and unresolved follow-up work"
157
159
  ```
158
160
 
@@ -164,7 +166,9 @@ With no arguments, the extension opens a small picker for:
164
166
  "parameters": {
165
167
  "profile": "balanced",
166
168
  "verbose": false,
167
- "dry_run": false
169
+ "dry_run": false,
170
+ "report": false,
171
+ "dashboard": false
168
172
  }
169
173
  }
170
174
  ```
@@ -175,10 +179,14 @@ The tool prepares a pending smart summary and lets Pi consume it on the next nat
175
179
 
176
180
  ## Usage notes
177
181
 
178
- - compaction is skipped when the context is still small enough
182
+ - auto/tool compaction is skipped when the context is still small enough (default: below 60% actual context usage)
183
+ - explicit manual `/smart-compact` commands bypass the 60% adaptive gate because the user intentionally requested compaction
184
+ - pi-toolkit `tool=XX%` status means tool-output ratio, **not** context fullness; smart-compact uses actual `context=XX%`
179
185
  - the tool path does **not** compact the conversation mid-turn
180
186
  - pending summaries are kept in memory for **5 minutes**
181
187
  - exploration is adaptive and may be skipped for simple sessions
188
+ - use `/smart-compact metrics` for profile/provider comparisons
189
+ - use `/smart-compact dashboard` to write a local HTML report at `.cache/smart-compact-report.html`
182
190
 
183
191
  This keeps the extension helpful without forcing extra work when it is not needed.
184
192
 
@@ -195,6 +203,8 @@ Add this to `~/.pi/agent/settings.json`:
195
203
  "summaryModel": "anthropic/claude-sonnet-4",
196
204
  "segmentationModel": "anthropic/claude-haiku-3",
197
205
  "autoTrigger": true,
206
+ "autoTriggerTimeoutMs": 120000,
207
+ "minContextPercent": 60,
198
208
  "backupEnabled": true,
199
209
  "profiles": {
200
210
  "balanced": {
@@ -214,6 +224,8 @@ Add this to `~/.pi/agent/settings.json`:
214
224
  | `summaryModel` | `string \| null` | `null` |
215
225
  | `segmentationModel` | `string \| null` | `null` |
216
226
  | `autoTrigger` | `boolean` | `true` |
227
+ | `autoTriggerTimeoutMs` | `number` | `120000` |
228
+ | `minContextPercent` | `number` | `60` |
217
229
  | `backupEnabled` | `boolean` | `true` |
218
230
  | `backupDir` | `string` | `~/.pi/agent/compact-backups` |
219
231
  | `profiles` | partial per-profile overrides | built-ins |
@@ -269,8 +281,10 @@ The current design includes:
269
281
  - hallucinated file-reference detection
270
282
  - open-loop injection
271
283
  - project fingerprinting and delta tracking
284
+ - provider-specific timeout and single-pass strategies
285
+ - multimodal attachment metadata preservation
272
286
  - backup creation before compaction
273
- - metrics logging and damage detection
287
+ - metrics logging, profile/provider comparison, and damage detection
274
288
 
275
289
  ---
276
290
 
@@ -282,6 +296,7 @@ At runtime, the extension writes to paths under `~/.pi/agent/`, including:
282
296
  - `compact-backups/`
283
297
  - `.cache/compact-extraction-<session>.json`
284
298
  - `.cache/compact-metrics.jsonl`
299
+ - `.cache/smart-compact-report.html`
285
300
  - `.cache/smart-compact/projects/<projectId>.json`
286
301
  - `.cache/smart-compact/states/<projectId>.json`
287
302
  - `.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.4";
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>;
@@ -15,6 +15,7 @@ export declare const DEFAULT_CONFIG: {
15
15
  autoTriggerTimeoutMs: number;
16
16
  backupEnabled: boolean;
17
17
  backupDir: string;
18
+ minContextPercent: number;
18
19
  };
19
20
  export declare const NO_OP_RE: RegExp;
20
21
  export declare const SHIFT_RE: RegExp;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"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C;AACtC,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAClE,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AACpD,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAC1D,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAClD,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;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,10 @@ export interface SmartCompactOptions {
22
22
  autoTriggered?: boolean;
23
23
  userNote?: string;
24
24
  skipCompact?: boolean;
25
+ /** Explicit user command may bypass adaptive context-pressure tier gate. */
26
+ force?: boolean;
27
+ /** Optional hard budget for native auto-trigger only. Manual/tool runs do not time out by default. */
28
+ timeoutMs?: number;
25
29
  }
26
30
  export declare function runSmartCompact(opts: SmartCompactOptions): Promise<void>;
27
31
  //# 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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IACjB,UAAU,EAAE;QAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,SAAS,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+e9E"}
@@ -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,QA0L7D"}