pi-smart-compact 7.22.0 → 8.0.0-rc.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 +38 -0
- package/README.md +149 -38
- package/dist/app/mode-policy.d.ts +26 -0
- package/dist/app/mode-policy.d.ts.map +1 -0
- package/dist/app/native-continuity-bridge.d.ts +12 -0
- package/dist/app/native-continuity-bridge.d.ts.map +1 -0
- package/dist/app/pending-slot.d.ts +6 -63
- package/dist/app/pending-slot.d.ts.map +1 -1
- package/dist/app/run-context.d.ts +12 -4
- package/dist/app/run-context.d.ts.map +1 -1
- package/dist/app/run-smart-compact.d.ts +9 -3
- package/dist/app/run-smart-compact.d.ts.map +1 -1
- package/dist/app/session-run-lock.d.ts +11 -0
- package/dist/app/session-run-lock.d.ts.map +1 -0
- 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/state.d.ts.map +1 -1
- package/dist/app/steps/synthesize.d.ts.map +1 -1
- package/dist/app/steps/verify.d.ts.map +1 -1
- package/dist/app/steps/window.d.ts +1 -1
- package/dist/app/steps/window.d.ts.map +1 -1
- package/dist/constants.d.ts +13 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/domain/provider-evaluation.d.ts +48 -0
- package/dist/domain/provider-evaluation.d.ts.map +1 -0
- package/dist/domain/telemetry.d.ts +65 -0
- package/dist/domain/telemetry.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2359 -353
- package/dist/infra/context-graph.d.ts +49 -0
- package/dist/infra/context-graph.d.ts.map +1 -0
- package/dist/infra/llm-client.d.ts +8 -8
- package/dist/infra/llm-client.d.ts.map +1 -1
- package/dist/infra/paths.d.ts +5 -1
- package/dist/infra/paths.d.ts.map +1 -1
- package/dist/infra/services.d.ts +18 -6
- package/dist/infra/services.d.ts.map +1 -1
- package/dist/infra/synthesis-cache.d.ts +19 -0
- package/dist/infra/synthesis-cache.d.ts.map +1 -0
- package/dist/phases/explore.d.ts +4 -4
- package/dist/phases/explore.d.ts.map +1 -1
- package/dist/phases/synthesize.d.ts +5 -5
- package/dist/phases/synthesize.d.ts.map +1 -1
- package/dist/phases/verify.d.ts +5 -5
- package/dist/phases/verify.d.ts.map +1 -1
- package/dist/provider-eval.js +1009 -0
- package/dist/provider-scenario-eval.js +1250 -0
- package/dist/telemetry-report.js +1050 -0
- package/dist/types.d.ts +67 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/dashboard-format.d.ts.map +1 -1
- package/dist/ui/dashboard-insights.d.ts +58 -0
- package/dist/ui/dashboard-insights.d.ts.map +1 -0
- package/dist/ui/metrics-report.d.ts +5 -2
- package/dist/ui/metrics-report.d.ts.map +1 -1
- package/dist/ui/overlays.d.ts +6 -4
- package/dist/ui/overlays.d.ts.map +1 -1
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/damage.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/state.d.ts +13 -1
- package/dist/utils/state.d.ts.map +1 -1
- package/dist/utils/type-guards.d.ts.map +1 -1
- package/docs/MIGRATING_TO_V8.md +99 -0
- package/docs/RELEASE.md +99 -22
- package/docs/provider-evaluation-2026-08-06.md +63 -0
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
No changes yet.
|
|
6
|
+
|
|
7
|
+
## [8.0.0-rc.1] - 2026-08-06
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Adaptive modes** — `/smart-compact` and the tool now support `auto`, `balanced`, `aggressive`, `fast`, and `thorough` execution policies with finite call and prompt-token ceilings plus observed output-token stop thresholds. Legacy `light` remains a `thorough` alias.
|
|
12
|
+
- **Continuity Ledger** — previous verified summaries and bounded structured state now carry goals, decisions, constraints, unresolved errors, and open loops forward until explicit resolution.
|
|
13
|
+
- **Aggregate prompt budget** — every LLM request reserves estimated input centrally and reconciles against provider usage; `--max-input-tokens` / `max_input_tokens` can override the mode ceiling.
|
|
14
|
+
- **Codex hybrid output limiter** — custom Codex endpoints receive `max_output_tokens`; ChatGPT subscription Codex uses a configurable per-call stream watchdog and visible-output ceiling because its endpoint rejects all server-side output-cap fields.
|
|
15
|
+
- **Smart Recall context graph** — consumed verified state is indexed into a project-isolated, 2,000-node SQLite FTS5 graph with file-reference edges, weighted same-session/branch retrieval, active fact resolution, and bounded `smart_recall` results.
|
|
16
|
+
- **Explicit project memory** — `smart_save_memory` stores deduplicated, user-confirmed durable facts after configured secret/PII scrubbing; `contextGraphEnabled` disables indexing and both memory tools.
|
|
17
|
+
- **Stage-aware provider routing** — Explore, Synthesis, and Verify can use independent explicitly configured models; all default to the selected model and mode changes never reroute providers.
|
|
18
|
+
- **Provider evaluation harness** — schema-v2 per-stage telemetry feeds an advisory context-pressure × tool-density matrix, plus an explicit paid-API scenario probe; neither path edits routing automatically.
|
|
19
|
+
- **Privacy-safe canary telemetry** — aggregate-only exports omit conversation/session/project data, failures use a stable content-free taxonomy, and explicit stable/canary tags drive Hold/Rollback/Promote gates for quality, failures, latency, tokens, fallback, and damage.
|
|
20
|
+
- **Dashboard trust UX** — TUI/text/HTML surfaces now show an auditable Data Confidence score (≥85 target), quality bands and repair gain, stage/provider/model evidence with quality coverage, stable-vs-canary deltas, rollback triggers, and failure taxonomy.
|
|
21
|
+
- **Session-aware run control** — same-session runs serialize, different sessions share a bounded global concurrency of two, pending state is TTL/LRU bounded, and synthesis caches key by session/branch/model/mode.
|
|
22
|
+
- **Native continuity bridge** — after Pi native compaction, scoped continuity is delivered exactly once at the next agent start instead of being lost or repeatedly injected.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **Runaway token consumption** — compaction windows now use Pi's active, compaction-aware entries instead of re-summarizing append-only session history. Retained tokens are re-counted after anchor/tool-call boundary expansion; non-viable automatic windows fall back to native compaction before any LLM call.
|
|
27
|
+
- **Repeated staged runs** — a same-session pending summary is reused rather than regenerated.
|
|
28
|
+
- **Unbounded LLM amplification** — safe defaults now use at most 8 calls, 3 exploration rounds, minimal per-phase reasoning, no automatic whole-request retries, explicit exploration output caps, and prompt caching for the growing exploration loop.
|
|
29
|
+
- **Calibration skew** — request calibration includes system/tools and cached prompt tokens instead of calibrating message text against incomplete usage.
|
|
30
|
+
- **Oversized synthesis chunks** — `maxChunkTokens` is now enforced by splitting large semantic segments; batch output budgets match the requested 2–4 sentence summaries instead of allocating 1,500 tokens per chunk.
|
|
31
|
+
- **Cross-generation context loss** — absent prior facts are no longer interpreted as deleted; cumulative state is conservatively merged and bounded.
|
|
32
|
+
- **Cross-session/branch contamination** — continuity state now carries project/session/branch ancestry scope with Branch > Session > Project precedence; legacy project-wide state is not injected into unrelated work.
|
|
33
|
+
- **Post-compaction false positives** — one normal file re-read or topic mention no longer counts as damage; repeated re-reads and explicit correction language remain actionable signals.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- High-confidence Fast/Aggressive runs can use zero-call deterministic synthesis; the verifier replaces lower-scoring model output with a deterministic quality floor, and Auto planning escalates from continuity/prior-damage risk.
|
|
38
|
+
- Recent-tail retention scales with model context, preserves the two newest user turns when enough history exists, and validates mode-specific post-compaction headroom.
|
|
39
|
+
- Refreshed the development lockfile to Pi `0.84.0`, TypeBox `1.3.11`, and `@types/node` `26.1.2` while preserving Pi host packages as wildcard-only peer dependencies.
|
|
40
|
+
|
|
3
41
|
## [7.22.0] - 2026-07-15
|
|
4
42
|
|
|
5
43
|
### Added
|
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ pi install git:github.com/alpertarhan/pi-smart-compact
|
|
|
31
31
|
## Quick start
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
/smart-compact # interactive model +
|
|
35
|
-
/smart-compact
|
|
36
|
-
/smart-compact anthropic/claude-sonnet-4
|
|
34
|
+
/smart-compact # interactive model + mode picker
|
|
35
|
+
/smart-compact auto # adaptive default
|
|
36
|
+
/smart-compact anthropic/claude-sonnet-4 fast # direct model + mode
|
|
37
37
|
/smart-compact balanced --focus=auth # preserve extra auth detail
|
|
38
38
|
/smart-compact metrics # text metrics report
|
|
39
39
|
/smart-compact dashboard # interactive metrics dashboard
|
|
@@ -43,7 +43,7 @@ pi install git:github.com/alpertarhan/pi-smart-compact
|
|
|
43
43
|
|
|
44
44
|
The extension also participates in Pi's native compaction flow automatically
|
|
45
45
|
when actual context usage crosses the configured threshold (60% by default),
|
|
46
|
-
and exposes
|
|
46
|
+
and exposes `smart_compact`, `smart_recall`, and `smart_save_memory` tools for long-running agents.
|
|
47
47
|
|
|
48
48
|
> The tool path stages a safe pending summary. It never compacts the active
|
|
49
49
|
> conversation in the middle of an agent turn.
|
|
@@ -57,6 +57,7 @@ and exposes a `smart_compact` tool for long-running agents.
|
|
|
57
57
|
| File/error omissions can be silent | Verifies coverage and repairs known gaps |
|
|
58
58
|
| One strategy for every session | Chooses single-pass or hierarchical synthesis |
|
|
59
59
|
| No quality feedback | Tracks provenance, damage signals, and metrics |
|
|
60
|
+
| No scoped cross-session recall | Searches a project-isolated SQLite FTS5 context graph |
|
|
60
61
|
|
|
61
62
|
The design principle is simple:
|
|
62
63
|
|
|
@@ -81,9 +82,9 @@ Pi conversation
|
|
|
81
82
|
| Stage | Responsibility |
|
|
82
83
|
| --- | --- |
|
|
83
84
|
| **Extract** | Deterministically catalogs files, errors, decisions, constraints, topics, media metadata, and open loops. This is the verification ground truth. |
|
|
84
|
-
| **Explore** |
|
|
85
|
-
| **Synthesize** | Uses
|
|
86
|
-
| **Verify** |
|
|
85
|
+
| **Explore** | Runs only in `thorough` mode (or when `auto` selects it); cheaper modes use deterministic boundaries. |
|
|
86
|
+
| **Synthesize** | Uses adaptive single-pass or bounded hierarchical synthesis with per-mode call, prompt-token, chunk, and output budgets. |
|
|
87
|
+
| **Verify** | Always applies deterministic repairs. Only `thorough` may spend one additional LLM call on unresolved gaps. |
|
|
87
88
|
|
|
88
89
|
### What survives compaction
|
|
89
90
|
|
|
@@ -94,10 +95,26 @@ Pi conversation
|
|
|
94
95
|
- Open follow-ups, blockers, priorities, and pinned loops
|
|
95
96
|
- Next actions and critical continuation context
|
|
96
97
|
- Changes since the previous compaction
|
|
98
|
+
- A bounded **Continuity Ledger** carrying prior decisions, constraints, unresolved errors, and open loops until explicit resolution
|
|
97
99
|
|
|
98
100
|
Summaries use a canonical H1/H2/H3-aware structure, collision-safe file
|
|
99
101
|
matching, typed verification gaps, and persisted repair provenance.
|
|
100
102
|
|
|
103
|
+
### Smart Recall
|
|
104
|
+
|
|
105
|
+
Applied compactions also index their verified scoped state into a bounded,
|
|
106
|
+
project-isolated SQLite FTS5 context graph. `smart_recall` searches goals,
|
|
107
|
+
decisions, constraints, unresolved errors, open loops, files, and critical
|
|
108
|
+
context across this project's sessions; same-session and same-branch evidence
|
|
109
|
+
ranks first. File relationships add one-hop graph recall without an embedding
|
|
110
|
+
service or extra LLM call.
|
|
111
|
+
|
|
112
|
+
`smart_save_memory` persists or explicitly resolves one user-confirmed decision,
|
|
113
|
+
constraint, preference, warning, procedure, or context fact. It rejects empty inputs,
|
|
114
|
+
scrubs configured secrets/PII, deduplicates exact facts, and must not be used
|
|
115
|
+
for guesses, transient progress, secrets, or code that is cheap to re-read.
|
|
116
|
+
Set `contextGraphEnabled` to `false` to disable indexing and both tools.
|
|
117
|
+
|
|
101
118
|
## Usage surfaces
|
|
102
119
|
|
|
103
120
|
| Surface | Behavior |
|
|
@@ -110,31 +127,97 @@ matching, typed verification gaps, and persisted repair provenance.
|
|
|
110
127
|
### Focus and budgets
|
|
111
128
|
|
|
112
129
|
```bash
|
|
113
|
-
/smart-compact
|
|
114
|
-
/smart-compact aggressive --max-
|
|
115
|
-
/smart-compact
|
|
130
|
+
/smart-compact auto --focus=authentication
|
|
131
|
+
/smart-compact aggressive --max-input-tokens=120000
|
|
132
|
+
/smart-compact fast --focus=src/auth.ts --max-calls=3
|
|
133
|
+
/smart-compact thorough
|
|
116
134
|
```
|
|
117
135
|
|
|
118
136
|
- `--focus` assigns more synthesis/exploration budget to a topic or path. It
|
|
119
137
|
does **not** attempt unsupported non-contiguous compaction.
|
|
120
138
|
- `--max-calls` accepts `1–100`.
|
|
121
|
-
- `--max-
|
|
122
|
-
-
|
|
123
|
-
|
|
139
|
+
- `--max-input-tokens` accepts `10000–1000000` aggregate prompt tokens.
|
|
140
|
+
- `--max-latency` accepts `5000–600000` milliseconds as an explicit hard override; mode latency targets are otherwise soft.
|
|
141
|
+
- Budget exhaustion degrades to deterministic summaries instead of dropping context.
|
|
142
|
+
|
|
143
|
+
The tool exposes equivalent `focus`, `max_calls`, `max_input_tokens`, and
|
|
144
|
+
`max_latency_ms` parameters.
|
|
145
|
+
|
|
146
|
+
## Modes
|
|
147
|
+
|
|
148
|
+
| Mode | Calls | Prompt cap | Output cap | Behavior |
|
|
149
|
+
| --- | ---: | ---: | ---: | --- |
|
|
150
|
+
| `auto` | adaptive | adaptive | adaptive | Default; selects from context pressure and deterministic session risk |
|
|
151
|
+
| `balanced` | 6 | 200K | 40K | Token/continuity balance; deterministic boundaries and repair |
|
|
152
|
+
| `aggressive` | 4 | 120K | 25K | Maximum context recovery with a 3K summary and 10K live tail |
|
|
153
|
+
| `fast` | 3 | 100K | 20K | Favors larger single-pass windows and minimum waiting |
|
|
154
|
+
| `thorough` (`slow` alias) | 8 | 300K | 80K | Maximum fidelity; enables Explore and one optional LLM repair |
|
|
155
|
+
|
|
156
|
+
Fast and aggressive modes use a zero-call deterministic summary when extraction confidence is high; otherwise they keep the bounded LLM path. Auto planning also raises fidelity when scoped continuity or prior damage indicates risk. Recent-tail retention scales with model context while preserving the two newest user turns when enough history exists.
|
|
124
157
|
|
|
125
|
-
|
|
126
|
-
|
|
158
|
+
Output caps stop subsequent calls after observed usage reaches the threshold.
|
|
159
|
+
The ChatGPT Codex subscription endpoint rejects `max_output_tokens`,
|
|
160
|
+
`max_tokens`, and `max_completion_tokens`; Smart Compact therefore enforces a
|
|
161
|
+
15–90 second per-call watchdog plus a streamed visible-output ceiling and falls
|
|
162
|
+
back deterministically on abort. Custom Codex endpoints receive
|
|
163
|
+
`max_output_tokens` through Pi AI's payload hook.
|
|
127
164
|
|
|
128
|
-
|
|
165
|
+
Legacy compression profiles remain as advanced/backwards-compatible policy:
|
|
166
|
+
`light` maps to `thorough`; `balanced` and `aggressive` map to their same-named
|
|
167
|
+
modes. The selected model never changes automatically.
|
|
129
168
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
169
|
+
### Stage-aware provider routing
|
|
170
|
+
|
|
171
|
+
All stages use the selected Pi model by default. Routing is explicit and
|
|
172
|
+
independent of modes:
|
|
173
|
+
|
|
174
|
+
| Stage | Config key | Default |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| Explore / segmentation | `segmentationModel` | selected model |
|
|
177
|
+
| Synthesis / assembly | `summaryModel` | selected model |
|
|
178
|
+
| Verification repair | `verificationModel` | summary/selected model |
|
|
179
|
+
|
|
180
|
+
Every run persists per-stage provider, model, reliability, latency, and token
|
|
181
|
+
telemetry with schema-versioned verifier quality. `bun run provider-eval`
|
|
182
|
+
builds an advisory matrix by context pressure and tool density; it never edits
|
|
183
|
+
configuration or selects a model. Legacy rows contribute operational evidence
|
|
184
|
+
but not quality because old verifier score semantics are incompatible.
|
|
185
|
+
|
|
186
|
+
A reproducible paid-API probe is opt-in only:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
bun run provider-eval:live --live \
|
|
190
|
+
--models=openai/gpt-5.4,anthropic/claude-sonnet-4-6
|
|
191
|
+
```
|
|
135
192
|
|
|
136
|
-
|
|
137
|
-
|
|
193
|
+
It runs three bounded, identical coding-continuity scenarios and reports
|
|
194
|
+
verification score, latency, and token usage. Apply a route manually only after
|
|
195
|
+
representative evidence. See the dated [provider evaluation baseline](./docs/provider-evaluation-2026-08-06.md).
|
|
196
|
+
|
|
197
|
+
### Privacy-safe telemetry and canary gates
|
|
198
|
+
|
|
199
|
+
Raw local JSONL remains available to the interactive dashboard, while
|
|
200
|
+
`bun run telemetry-report` emits aggregate-only telemetry: no session/project
|
|
201
|
+
IDs, prompts, summaries, paths, or error text. Failures use a stable taxonomy
|
|
202
|
+
(cancelled, timeout, rate limit, authentication, budget, output limit,
|
|
203
|
+
provider, persistence, validation, internal).
|
|
204
|
+
|
|
205
|
+
Set `telemetryChannel` to `canary` only on the externally selected canary
|
|
206
|
+
cohort. The report compares schema-v2 canary runs with the stable baseline and
|
|
207
|
+
returns `HOLD`, `ROLLBACK`, or `PROMOTE`. Rollback triggers are: failure rate
|
|
208
|
+
+5pp and ≥10%, verifier quality −5 points, p95 latency +50%, tokens +50%,
|
|
209
|
+
heuristic fallback +10pp, or post-compaction damage +10pp. Promotion requires
|
|
210
|
+
at least 20 canary runs, a stable baseline, and ≥70% quality coverage. The
|
|
211
|
+
extension reports the decision; it never edits config or deploys automatically.
|
|
212
|
+
|
|
213
|
+
The interactive and HTML dashboards make trust evidence explicit: a **Data
|
|
214
|
+
Confidence** score (target ≥85) combines recent sample size (25 points),
|
|
215
|
+
schema-v2 coverage (25), verifier-quality coverage (20), field completeness
|
|
216
|
+
(20), and seven-day freshness (10). Separate views show repair gain and quality
|
|
217
|
+
bands, stage/provider/model reliability with quality coverage, stable-vs-canary
|
|
218
|
+
deltas, rollback triggers, and the failure taxonomy. Low confidence is shown as
|
|
219
|
+
low—not silently filled from incompatible legacy scores—and includes concrete
|
|
220
|
+
guidance for reaching the target.
|
|
138
221
|
|
|
139
222
|
## Safety and privacy
|
|
140
223
|
|
|
@@ -155,7 +238,7 @@ High-confidence secret scrubbing is enabled by default at every relevant trust
|
|
|
155
238
|
boundary:
|
|
156
239
|
|
|
157
240
|
```text
|
|
158
|
-
provider request · extraction cache · backup · state · pending summary
|
|
241
|
+
provider request · extraction cache · backup · state · context graph · pending summary
|
|
159
242
|
```
|
|
160
243
|
|
|
161
244
|
It covers common API keys, cloud/GitHub/Slack tokens, JWTs, bearer tokens,
|
|
@@ -199,20 +282,27 @@ Add `smartCompact` to `~/.pi/agent/settings.json`:
|
|
|
199
282
|
```json
|
|
200
283
|
{
|
|
201
284
|
"smartCompact": {
|
|
285
|
+
"mode": "auto",
|
|
202
286
|
"profile": "balanced",
|
|
203
287
|
"summaryModel": null,
|
|
204
288
|
"segmentationModel": null,
|
|
205
|
-
"
|
|
206
|
-
"
|
|
289
|
+
"verificationModel": null,
|
|
290
|
+
"summaryThinkingLevel": "minimal",
|
|
291
|
+
"segmentationThinkingLevel": "minimal",
|
|
207
292
|
"autoTrigger": true,
|
|
208
293
|
"minContextPercent": 60,
|
|
209
294
|
"backupEnabled": true,
|
|
210
295
|
"scrubSecrets": true,
|
|
211
296
|
"scrubPii": false,
|
|
212
297
|
"requireApproval": false,
|
|
213
|
-
"maxLlmCalls":
|
|
298
|
+
"maxLlmCalls": 8,
|
|
299
|
+
"maxLlmInputTokens": 0,
|
|
300
|
+
"codexMaxCallMs": 0,
|
|
214
301
|
"maxLatencyMs": 0,
|
|
215
302
|
"focusWeighting": true,
|
|
303
|
+
"zeroCallEnabled": true,
|
|
304
|
+
"contextGraphEnabled": true,
|
|
305
|
+
"telemetryChannel": "stable",
|
|
216
306
|
"onlineDamageMonitor": true,
|
|
217
307
|
"adaptiveDamageFeedback": false,
|
|
218
308
|
"pinPaths": []
|
|
@@ -235,21 +325,35 @@ use a stronger one:
|
|
|
235
325
|
```
|
|
236
326
|
|
|
237
327
|
`segmentationThinkingLevel` applies to exploration; `summaryThinkingLevel`
|
|
238
|
-
applies to synthesis, assembly, and repair.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
328
|
+
applies to synthesis, assembly, and repair. Both default to `minimal` because
|
|
329
|
+
reasoning tokens from multi-call compaction add up quickly. Supported values
|
|
330
|
+
are `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Set either value to
|
|
331
|
+
`null` to restore the provider's default behavior. An explicit call-level
|
|
332
|
+
reasoning option takes precedence.
|
|
333
|
+
|
|
334
|
+
### Cost safeguards
|
|
335
|
+
|
|
336
|
+
Automatic and tool-triggered runs operate on Pi's current active context, not
|
|
337
|
+
the append-only session history. A same-session staged summary is reused, the
|
|
338
|
+
exploration loop is limited to three rounds, provider and outer retries are
|
|
339
|
+
disabled, and every mode has finite call plus aggregate prompt-token budgets.
|
|
340
|
+
If anchor/tool-call
|
|
341
|
+
protection leaves too much live context to get below the configured trigger,
|
|
342
|
+
Smart Compact spends no LLM tokens and lets Pi's native compactor handle it.
|
|
343
|
+
Manual `/smart-compact` remains an explicit force path.
|
|
242
344
|
|
|
243
345
|
<details>
|
|
244
346
|
<summary><strong>All configuration keys</strong></summary>
|
|
245
347
|
|
|
246
348
|
| Key | Type | Default | Notes |
|
|
247
349
|
| --- | --- | --- | --- |
|
|
248
|
-
| `
|
|
350
|
+
| `mode` | `auto \| balanced \| aggressive \| fast \| thorough` | `auto` | User-facing execution preset |
|
|
351
|
+
| `profile` | `light \| balanced \| aggressive` | `balanced` | Legacy/advanced compression profile; used when mode is absent |
|
|
249
352
|
| `summaryModel` | `string \| null` | `null` | Uses the active session model when null |
|
|
250
|
-
| `segmentationModel` | `string \| null` | `null` | Optional
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
353
|
+
| `segmentationModel` | `string \| null` | `null` | Optional explicit model for Explore |
|
|
354
|
+
| `verificationModel` | `string \| null` | `null` | Optional explicit model for LLM verification repair |
|
|
355
|
+
| `summaryThinkingLevel` | `minimal \| low \| medium \| high \| xhigh \| max \| null` | `minimal` | Reasoning level for synthesis and repair; provider default when null |
|
|
356
|
+
| `segmentationThinkingLevel` | `minimal \| low \| medium \| high \| xhigh \| max \| null` | `minimal` | Reasoning level for exploration; provider default when null |
|
|
253
357
|
| `autoTrigger` | `boolean` | `true` | Participate in Pi's native compact hook |
|
|
254
358
|
| `autoTriggerTimeoutMs` | `number` | `120000` | Hard timeout for automatic runs |
|
|
255
359
|
| `minContextPercent` | `number` | `60` | Actual context usage gate |
|
|
@@ -260,9 +364,14 @@ option takes precedence over these defaults.
|
|
|
260
364
|
| `requireApproval` | `boolean` | `false` | Manual UI only; cancel/error fails closed |
|
|
261
365
|
| `scrubSecrets` | `boolean` | `true` | High-confidence credential redaction |
|
|
262
366
|
| `scrubPii` | `boolean` | `false` | Email/phone/card-shaped redaction |
|
|
263
|
-
| `maxLlmCalls` | integer `0–100` | `
|
|
367
|
+
| `maxLlmCalls` | integer `0–100` | `8` | Global ceiling combined with the selected mode |
|
|
368
|
+
| `maxLlmInputTokens` | integer `0–1000000` | `0` | `0` uses the selected mode's aggregate prompt-token cap |
|
|
369
|
+
| `codexMaxCallMs` | integer `0` or `5000–300000` | `0` | ChatGPT Codex per-call watchdog; `0` derives 15–90s from requested output tokens |
|
|
264
370
|
| `maxLatencyMs` | `0` or `5000–600000` | `0` | `0` means unlimited |
|
|
265
371
|
| `focusWeighting` | `boolean` | `true` | Weight focused topics/paths higher |
|
|
372
|
+
| `zeroCallEnabled` | `boolean` | `true` | Use deterministic synthesis for high-confidence fast/aggressive runs |
|
|
373
|
+
| `contextGraphEnabled` | `boolean` | `true` | Index verified state and enable project-scoped recall/save tools |
|
|
374
|
+
| `telemetryChannel` | `stable \| canary` | `stable` | Tag local schema-v2 metrics for external canary comparison |
|
|
266
375
|
| `onlineDamageMonitor` | `boolean` | `true` | Observe post-compaction regression signals |
|
|
267
376
|
| `adaptiveDamageFeedback` | `boolean` | `false` | Increase preservation after repeated damage |
|
|
268
377
|
|
|
@@ -320,7 +429,7 @@ Add retry/backoff to the LLM client without breaking cancellation.
|
|
|
320
429
|
/smart-compact restore # browse, inspect, and restore backups
|
|
321
430
|
```
|
|
322
431
|
|
|
323
|
-
Metrics include
|
|
432
|
+
Metrics include effective mode, profile, provider, phase timing, token/call estimates,
|
|
324
433
|
verification quality, cache behavior, redactions, adaptation, fallbacks, and
|
|
325
434
|
cancelled runs.
|
|
326
435
|
|
|
@@ -337,7 +446,8 @@ All files live under `~/.pi/agent/`.
|
|
|
337
446
|
| `.cache/compact-metrics.jsonl` | Tail-retained metrics log; 5 MiB cap |
|
|
338
447
|
| `.cache/smart-compact-report.html` | Local HTML dashboard |
|
|
339
448
|
| `.cache/smart-compact/projects/<projectId>.json` | Project fingerprint |
|
|
340
|
-
| `.cache/smart-compact/states/<projectId>.json` |
|
|
449
|
+
| `.cache/smart-compact/states/<projectId>/<sessionId>.json` | Scoped compaction state and loop overrides |
|
|
450
|
+
| `.cache/smart-compact/context-graph.sqlite` | Project-isolated FTS5 context graph and explicit saved memory |
|
|
341
451
|
| `.cache/smart-compact/damage-reports.jsonl` | Damage reports; 5 MiB cap |
|
|
342
452
|
| `.cache/smart-compact/remediation-<projectId>.json` | Files to preserve after damage |
|
|
343
453
|
|
|
@@ -378,6 +488,7 @@ the build in GitHub Actions.
|
|
|
378
488
|
- [Contributing](https://github.com/alpertarhan/pi-smart-compact/blob/main/CONTRIBUTING.md)
|
|
379
489
|
- [Security](https://github.com/alpertarhan/pi-smart-compact/blob/main/SECURITY.md)
|
|
380
490
|
- [Support](https://github.com/alpertarhan/pi-smart-compact/blob/main/SUPPORT.md)
|
|
491
|
+
- [v8 migration guide](https://github.com/alpertarhan/pi-smart-compact/blob/main/docs/MIGRATING_TO_V8.md)
|
|
381
492
|
- [Release checklist](https://github.com/alpertarhan/pi-smart-compact/blob/main/docs/RELEASE.md)
|
|
382
493
|
|
|
383
494
|
## License
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CompactionMode, CompactionState, CompressionProfile, EffectiveCompactionMode, StructuredExtraction } from "../types.ts";
|
|
2
|
+
export interface ModePolicy {
|
|
3
|
+
profile: CompressionProfile;
|
|
4
|
+
maxLlmCalls: number;
|
|
5
|
+
maxInputTokens: number;
|
|
6
|
+
maxOutputTokens: number;
|
|
7
|
+
explore: boolean;
|
|
8
|
+
allowLlmPatch: boolean;
|
|
9
|
+
singlePassMultiplier: number;
|
|
10
|
+
batchOutput: {
|
|
11
|
+
min: number;
|
|
12
|
+
perChunk: number;
|
|
13
|
+
max: number;
|
|
14
|
+
};
|
|
15
|
+
softLatencyMs: number;
|
|
16
|
+
targetContextPercent: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const MODE_POLICIES: Readonly<Record<EffectiveCompactionMode, ModePolicy>>;
|
|
19
|
+
export declare function modeFromLegacyProfile(profile: CompressionProfile): EffectiveCompactionMode;
|
|
20
|
+
/** Cheap preflight choice used before deterministic extraction is available. */
|
|
21
|
+
export declare function resolveMode(requested: CompactionMode, contextPercent: number, extraction?: StructuredExtraction, additionalRisk?: number): EffectiveCompactionMode;
|
|
22
|
+
export declare function deterministicExtractionConfidence(extraction: StructuredExtraction): number;
|
|
23
|
+
export declare function continuityRisk(state: CompactionState | null): number;
|
|
24
|
+
export declare function batchOutputLimit(mode: EffectiveCompactionMode, chunks: number, providerMax: number): number;
|
|
25
|
+
export declare function effectiveBudget(configured: number, modeDefault: number): number;
|
|
26
|
+
//# sourceMappingURL=mode-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-policy.d.ts","sourceRoot":"","sources":["../../src/app/mode-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,oBAAoB,EACnG,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAqB/E,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,uBAAuB,CAE1F;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,cAAc,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,oBAAoB,EACjC,cAAc,SAAI,GACjB,uBAAuB,CAezB;AAED,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAW1F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,MAAM,CAOpE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAG3G;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAG/E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface NativeContinuityBridge {
|
|
2
|
+
stage(sessionId: string, text: string): void;
|
|
3
|
+
take(sessionId: string): string | null;
|
|
4
|
+
clear(sessionId?: string): void;
|
|
5
|
+
size(): number;
|
|
6
|
+
}
|
|
7
|
+
export declare function createNativeContinuityBridge(opts?: {
|
|
8
|
+
ttlMs?: number;
|
|
9
|
+
maxEntries?: number;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
}): NativeContinuityBridge;
|
|
12
|
+
//# sourceMappingURL=native-continuity-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-continuity-bridge.d.ts","sourceRoot":"","sources":["../../src/app/native-continuity-bridge.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,IAAI,IAAI,MAAM,CAAC;CAChB;AAED,wBAAgB,4BAA4B,CAAC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GAAG,sBAAsB,CAwB3I"}
|
|
@@ -1,46 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pending-compaction slot.
|
|
3
|
-
*
|
|
4
|
-
* A single-element, owner-private state cell that holds the *most recently
|
|
5
|
-
* prepared* `PendingCompaction` until the next `session_before_compact`
|
|
6
|
-
* event consumes it. Concurrency model:
|
|
7
|
-
*
|
|
8
|
-
* - One producer (`runSmartCompact` → `stagePendingCompaction`).
|
|
9
|
-
* - One consumer (`session_before_compact` event handler).
|
|
10
|
-
* - Single-threaded JS event loop; no atomic primitives needed.
|
|
11
|
-
*
|
|
12
|
-
* Design rationale — why an encapsulated factory instead of a mutable
|
|
13
|
-
* `{ value, createdAt }` ref-cell:
|
|
14
|
-
*
|
|
15
|
-
* 1. **Invariant centralization.** The "set → consume → clear" lifecycle
|
|
16
|
-
* lives in one file. Callers cannot accidentally null `value` without
|
|
17
|
-
* also resetting `createdAt`, nor can they read a `value` snapshot
|
|
18
|
-
* against a freshly-overwritten `createdAt` (the original bare-ref
|
|
19
|
-
* shape allowed this race; see B3 in code-review #3).
|
|
20
|
-
*
|
|
21
|
-
* 2. **Observable consume result.** `consume()` returns a discriminated
|
|
22
|
-
* union that records *why* a payload was rejected (empty / expired /
|
|
23
|
-
* session-mismatch). The previous helper folded all three into
|
|
24
|
-
* `null`, which hid information the caller might want to surface as
|
|
25
|
-
* metrics or differentiated notifications.
|
|
26
|
-
*
|
|
27
|
-
* 3. **Atomic snapshot.** Every consume path destructures a single
|
|
28
|
-
* `{ value, createdAt }` snapshot up front so the TTL and id checks
|
|
29
|
-
* operate on a coherent view, even if a future maintainer threads an
|
|
30
|
-
* `await` into the middle of the function.
|
|
31
|
-
*
|
|
32
|
-
* 4. **No host-context coupling.** The slot does NOT call
|
|
33
|
-
* `ctx.ui.notify` itself — the caller decides the UX (silent metric,
|
|
34
|
-
* toast, log line). This keeps the module pure / fully unit-testable
|
|
35
|
-
* without a fake host context.
|
|
36
|
-
*/
|
|
1
|
+
/** Session-scoped pending compaction store with TTL and bounded memory. */
|
|
37
2
|
import type { PendingCompaction } from "../types.ts";
|
|
38
3
|
import { type SessionIdentityContext } from "../infra/session-identity.ts";
|
|
39
|
-
/**
|
|
40
|
-
* Outcome of `PendingSlot.consume()`. Discriminated union so callers can
|
|
41
|
-
* react differently to each rejection reason (e.g. log a stale payload at
|
|
42
|
-
* `warn`, but a cross-session mismatch at `error`).
|
|
43
|
-
*/
|
|
44
4
|
export type ConsumeResult = {
|
|
45
5
|
kind: "ok";
|
|
46
6
|
pending: PendingCompaction;
|
|
@@ -54,35 +14,18 @@ export type ConsumeResult = {
|
|
|
54
14
|
expected: string;
|
|
55
15
|
actual: string;
|
|
56
16
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Public surface of an owned pending-compaction slot. Producers call
|
|
59
|
-
* `set()` once they have a finished summary; consumers call `consume()` at
|
|
60
|
-
* the next compact boundary. `isPresent()` is a non-mutating peek used by
|
|
61
|
-
* the orchestrator for UI wording ("prepared, awaiting native /compact"
|
|
62
|
-
* vs. "run finished").
|
|
63
|
-
*/
|
|
64
17
|
export interface PendingSlot {
|
|
65
18
|
set(pending: PendingCompaction): void;
|
|
66
19
|
consume(ctx: SessionIdentityContext): ConsumeResult;
|
|
67
|
-
clear(): void;
|
|
68
|
-
isPresent(): boolean;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
* or running any guard checks. Intended for *display* paths (e.g. a tool
|
|
72
|
-
* response that wants to surface `tokensBefore` after a prepare-only run).
|
|
73
|
-
* Callers must NOT pass the returned payload to the host — only `consume`
|
|
74
|
-
* enforces the freshness + session-match invariants.
|
|
75
|
-
*/
|
|
76
|
-
peek(): Readonly<PendingCompaction> | null;
|
|
20
|
+
clear(sessionId?: string): void;
|
|
21
|
+
isPresent(sessionId?: string): boolean;
|
|
22
|
+
peek(sessionId?: string): Readonly<PendingCompaction> | null;
|
|
23
|
+
size(): number;
|
|
77
24
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Optional injection seam for `Date.now`. Tests pass a fake clock so they
|
|
80
|
-
* can advance time without `await new Promise(setTimeout)`. Production
|
|
81
|
-
* callers omit this and get real wall-clock time.
|
|
82
|
-
*/
|
|
83
25
|
export interface PendingSlotOptions {
|
|
84
26
|
ttlMs: number;
|
|
85
27
|
now?: () => number;
|
|
28
|
+
maxEntries?: number;
|
|
86
29
|
}
|
|
87
30
|
export declare function createPendingSlot(opts: PendingSlotOptions): PendingSlot;
|
|
88
31
|
//# sourceMappingURL=pending-slot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-slot.d.ts","sourceRoot":"","sources":["../../src/app/pending-slot.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pending-slot.d.ts","sourceRoot":"","sources":["../../src/app/pending-slot.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAoB,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE7F,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,GAAG,EAAE,sBAAsB,GAAG,aAAa,CAAC;IACpD,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAC7D,IAAI,IAAI,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,WAAW,CAoEvE"}
|
|
@@ -33,13 +33,14 @@
|
|
|
33
33
|
* working for the `applyCompaction` / metrics paths that ran post-`buildState`.
|
|
34
34
|
*/
|
|
35
35
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
36
|
-
import type { Model, Api } from "@earendil-works/pi-ai";
|
|
37
|
-
import type { CompressionProfile, LlmMessage, StructuredExtraction, ExplorationReport, ChunkSummary, SessionMessageEntry, PipelinePhaseTiming, CompactConfig, ProfileConfig, ProviderCapabilities, SmartCompactDetails, CompactionState, OpenLoop, Cell } from "../types.ts";
|
|
36
|
+
import type { Model, Api, ProviderHeaders } from "@earendil-works/pi-ai";
|
|
37
|
+
import type { CompressionProfile, CompactionMode, EffectiveCompactionMode, LlmMessage, StructuredExtraction, ExplorationReport, ChunkSummary, SessionMessageEntry, PipelinePhaseTiming, CompactConfig, ProfileConfig, ProviderCapabilities, SmartCompactDetails, CompactionState, ContinuityScope, OpenLoop, Cell } from "../types.ts";
|
|
38
38
|
import type { PendingSlot } from "./pending-slot.ts";
|
|
39
39
|
import type { PruningResult } from "../utils/pruning.ts";
|
|
40
40
|
import type { CompactionTier } from "../utils/helpers.ts";
|
|
41
41
|
import type { TokenEstimator } from "../utils/tokens.ts";
|
|
42
42
|
import type { SmartCompactServices } from "../infra/services.ts";
|
|
43
|
+
import type { SessionRunLock } from "./session-run-lock.ts";
|
|
43
44
|
export type Notifier = (msg: string, type?: "info" | "success" | "warning" | "error") => void;
|
|
44
45
|
export interface CancellationToken {
|
|
45
46
|
controller: AbortController;
|
|
@@ -65,7 +66,7 @@ export interface RunFlags {
|
|
|
65
66
|
}
|
|
66
67
|
export interface ResolvedAuth {
|
|
67
68
|
apiKey: string;
|
|
68
|
-
headers?:
|
|
69
|
+
headers?: ProviderHeaders;
|
|
69
70
|
}
|
|
70
71
|
export interface RcBase {
|
|
71
72
|
ctx: ExtensionContext;
|
|
@@ -74,18 +75,22 @@ export interface RcBase {
|
|
|
74
75
|
services: SmartCompactServices;
|
|
75
76
|
cancellation: CancellationToken;
|
|
76
77
|
pendingRef: PendingRef;
|
|
77
|
-
isRunning: Cell<boolean
|
|
78
|
+
isRunning: Cell<boolean> | SessionRunLock;
|
|
78
79
|
flags: RunFlags;
|
|
79
80
|
userNote?: string;
|
|
80
81
|
focus?: string;
|
|
81
82
|
maxLlmCalls?: number;
|
|
83
|
+
maxLlmInputTokens?: number;
|
|
82
84
|
timeoutMs: number;
|
|
83
85
|
phaseTimings: PipelinePhaseTiming[];
|
|
84
86
|
pipelineStart: number;
|
|
85
87
|
phaseStart: number;
|
|
86
88
|
summaryModel: Model<Api>;
|
|
87
89
|
segModel: Model<Api>;
|
|
90
|
+
verifyModel: Model<Api>;
|
|
88
91
|
modelLabel: string;
|
|
92
|
+
requestedMode: CompactionMode;
|
|
93
|
+
mode: EffectiveCompactionMode;
|
|
89
94
|
profile: CompressionProfile;
|
|
90
95
|
}
|
|
91
96
|
export interface PreparedExt {
|
|
@@ -98,6 +103,7 @@ export interface PreparedExt {
|
|
|
98
103
|
adapted: boolean;
|
|
99
104
|
summaryAuth: ResolvedAuth;
|
|
100
105
|
segAuth: ResolvedAuth;
|
|
106
|
+
verifyAuth: ResolvedAuth;
|
|
101
107
|
}
|
|
102
108
|
export type PreparedRc = RcBase & PreparedExt;
|
|
103
109
|
export interface WindowedExt extends PreparedExt {
|
|
@@ -135,6 +141,8 @@ export interface ExtractedExt extends TieredExt {
|
|
|
135
141
|
prevContext: string;
|
|
136
142
|
projectCtx: string;
|
|
137
143
|
projectId: string;
|
|
144
|
+
continuityScope: ContinuityScope;
|
|
145
|
+
previousState: CompactionState | null;
|
|
138
146
|
/**
|
|
139
147
|
* Serialized pruned conversation text. Computed once in `extractWithCache`
|
|
140
148
|
* and reused by `summarizeConversation` so we don't `serializeConversation`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/app/run-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/app/run-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KA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,GAAG,MAAM,GAAG,WAAW,CAAC;AAQ9C,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;AAElC,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,KAAK,SAAa,GACjB,IAAI,CAGN;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,CAE/E;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,SAAS,MAAM,EAAE,IAAI,SAAS,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAE/F"}
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
20
20
|
import type { Cell } from "../types.ts";
|
|
21
|
+
import type { SessionRunLock } from "./session-run-lock.ts";
|
|
21
22
|
import type { Model, Api } from "@earendil-works/pi-ai";
|
|
22
|
-
import type { CompressionProfile } from "../types.ts";
|
|
23
|
+
import type { CompactionMode, CompressionProfile } from "../types.ts";
|
|
23
24
|
import type { PendingRef } from "./run-context.ts";
|
|
24
25
|
/**
|
|
25
26
|
* Co-operative cancellation surface that the extension entry point can hand
|
|
@@ -50,15 +51,20 @@ export interface SmartCompactOptions {
|
|
|
50
51
|
ctx: ExtensionContext;
|
|
51
52
|
summaryModel: Model<Api>;
|
|
52
53
|
segModel: Model<Api>;
|
|
53
|
-
|
|
54
|
+
/** Optional explicit verification/repair route; defaults to the summary model. */
|
|
55
|
+
verifyModel?: Model<Api>;
|
|
56
|
+
/** New execution preset. Omit to preserve the legacy profile mapping. */
|
|
57
|
+
mode?: CompactionMode;
|
|
58
|
+
profile?: CompressionProfile;
|
|
54
59
|
verbose?: boolean;
|
|
55
60
|
dryRun?: boolean;
|
|
56
61
|
pendingRef: PendingRef;
|
|
57
|
-
isRunning: Cell<boolean
|
|
62
|
+
isRunning: Cell<boolean> | SessionRunLock;
|
|
58
63
|
autoTriggered?: boolean;
|
|
59
64
|
userNote?: string;
|
|
60
65
|
focus?: string;
|
|
61
66
|
maxLlmCalls?: number;
|
|
67
|
+
maxLlmInputTokens?: number;
|
|
62
68
|
skipCompact?: boolean;
|
|
63
69
|
/** Explicit user command may bypass adaptive context-pressure tier gate. */
|
|
64
70
|
force?: boolean;
|