pi-smart-compact 7.5.0 → 7.5.2
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/README.md +224 -95
- package/package.json +8 -1
- package/src/constants.ts +1 -1
- package/src/core.ts +8 -8
package/README.md
CHANGED
|
@@ -1,66 +1,81 @@
|
|
|
1
1
|
# Smart Compact
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](./package.json)
|
|
3
|
+
[](https://www.npmjs.com/package/pi-smart-compact)
|
|
6
4
|
[](./LICENSE)
|
|
5
|
+
[](https://github.com/alpertarhan/pi-smart-compact)
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
> EESV-powered intelligent context compaction for the [Pi Coding Agent](https://github.com/earendil-works/pi-coding-agent).
|
|
8
|
+
|
|
9
|
+
**Smart Compact** compresses long conversation contexts by understanding *what happened* — not by blindly truncating. It deterministically extracts files, errors, decisions, and constraints from your session, then uses LLM-guided exploration and parallel batch synthesis to produce a structured summary that preserves the meaning and state of your work.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
The result: a shorter context that the agent can actually work with, without losing critical information.
|
|
12
|
+
|
|
13
|
+
---
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
## Why Smart Compact?
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|-------|-------------|-----------|
|
|
16
|
-
| **Extract** | Deterministically pull files, errors, decisions, constraints, topics | 0 |
|
|
17
|
-
| **Explore** | Use LLM tools to verify boundaries and enrich context (skipped for simple sessions) | 0–8 |
|
|
18
|
-
| **Synthesize** | Parallel batch summarization + assembly | N + 1 |
|
|
19
|
-
| **Verify** | Check coverage, detect hallucinations, patch gaps | 0–1 |
|
|
17
|
+
Pi's built-in compaction truncates old messages. Smart Compact **understands** them first:
|
|
20
18
|
|
|
21
|
-
**
|
|
19
|
+
- **Zero-LLM extraction** — files modified/read, errors with retry lifecycle, user decisions, constraints, topic segmentation — all deterministically extracted before any LLM call
|
|
20
|
+
- **Hallucination detection** — verifies the summary doesn't invent file paths or misstate error status
|
|
21
|
+
- **Decision propagation** — carries decisions across batch boundaries so the LLM never forgets what was decided
|
|
22
|
+
- **Redundancy pruning** — collapses duplicate reads, consecutive failures, and low-info messages before compaction, reducing input by 15–30%
|
|
23
|
+
- **Cross-session memory** — learns your project's language, framework, and file structure across sessions
|
|
24
|
+
- **Damage detection** — monitors post-compaction behavior for regression signals
|
|
22
25
|
|
|
23
26
|
---
|
|
24
27
|
|
|
25
|
-
##
|
|
28
|
+
## The EESV Pipeline
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Extract → Explore → Synthesize → Verify
|
|
32
|
+
(0 LLM) (0–8 LLM) (N+1 LLM) (0–1 LLM)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| Phase | What it does | LLM cost |
|
|
36
|
+
|-------|-------------|----------|
|
|
37
|
+
| **Extract** | Deterministically mine files, errors, decisions, constraints, topics | **0 calls** |
|
|
38
|
+
| **Explore** | LLM investigates conversation with tools to verify boundaries and enrich context. **Skipped for simple sessions.** | 0–8 calls |
|
|
39
|
+
| **Synthesize** | Parallel batch summarization with decision propagation, then single-pass assembly | N+1 calls |
|
|
40
|
+
| **Verify** | Coverage checks, hallucination detection, deterministic patching (zero LLM), LLM patch only as last resort | 0–1 calls |
|
|
41
|
+
|
|
42
|
+
### Pre-Processing (before EESV)
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
```
|
|
45
|
+
Pruning: Remove duplicate reads, collapse error chains, strip acknowledgments, truncate long outputs
|
|
46
|
+
↳ Reduces compaction input by 15–30%
|
|
47
|
+
Fingerprint: Load project context (language, framework, known files) from previous sessions
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Post-Processing (after EESV)
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
Damage Detection: Monitor agent behavior for regression signals (re-reads, user complaints, re-questions)
|
|
54
|
+
↳ Builds a quality feedback dataset over time
|
|
55
|
+
```
|
|
36
56
|
|
|
37
57
|
---
|
|
38
58
|
|
|
39
|
-
##
|
|
59
|
+
## Installation
|
|
40
60
|
|
|
41
61
|
```bash
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
git clone https://github.com/YOUR_USERNAME/pi-smart-compact.git
|
|
45
|
-
cd pi-smart-compact
|
|
46
|
-
bun install
|
|
47
|
-
```
|
|
62
|
+
# Option 1: Install via bun (recommended)
|
|
63
|
+
bun add pi-smart-compact
|
|
48
64
|
|
|
49
|
-
|
|
65
|
+
# Option 2: Install via npm
|
|
66
|
+
npm install pi-smart-compact
|
|
50
67
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
# Option 3: Clone directly
|
|
69
|
+
cd ~/.pi/agent/extensions
|
|
70
|
+
git clone https://github.com/alpertarhan/pi-smart-compact.git
|
|
71
|
+
cd pi-smart-compact && bun install
|
|
55
72
|
```
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
Then add to your Pi `settings.json`:
|
|
58
75
|
|
|
59
76
|
```json
|
|
60
77
|
{
|
|
61
|
-
"
|
|
62
|
-
"extensions": ["./src/index.ts"]
|
|
63
|
-
}
|
|
78
|
+
"extensions": ["pi-smart-compact"]
|
|
64
79
|
}
|
|
65
80
|
```
|
|
66
81
|
|
|
@@ -68,26 +83,28 @@ Or via `package.json` (already configured):
|
|
|
68
83
|
|
|
69
84
|
## Usage
|
|
70
85
|
|
|
86
|
+
### Command
|
|
87
|
+
|
|
71
88
|
```bash
|
|
72
|
-
# TUI — pick model + profile
|
|
89
|
+
# Interactive TUI — pick model + profile
|
|
73
90
|
/smart-compact
|
|
74
91
|
|
|
75
92
|
# Direct — specific model + profile
|
|
76
93
|
/smart-compact anthropic/claude-sonnet-4 balanced
|
|
77
94
|
|
|
78
|
-
# Dry run — preview
|
|
95
|
+
# Dry run — preview what would be compacted
|
|
79
96
|
/smart-compact dry-run
|
|
80
97
|
|
|
81
|
-
# Verbose — detailed logging
|
|
98
|
+
# Verbose — detailed pipeline logging
|
|
82
99
|
/smart-compact debug
|
|
83
100
|
|
|
84
|
-
#
|
|
101
|
+
# Steering note — guide the summary focus
|
|
85
102
|
/smart-compact "focus on auth changes"
|
|
86
103
|
```
|
|
87
104
|
|
|
88
|
-
### Tool
|
|
105
|
+
### Tool (agent-callable)
|
|
89
106
|
|
|
90
|
-
The extension
|
|
107
|
+
The extension registers a tool the agent can call automatically:
|
|
91
108
|
|
|
92
109
|
```json
|
|
93
110
|
{
|
|
@@ -100,48 +117,9 @@ The extension also registers a tool named `smart_compact`:
|
|
|
100
117
|
}
|
|
101
118
|
```
|
|
102
119
|
|
|
103
|
-
|
|
120
|
+
### Auto-Trigger
|
|
104
121
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
┌─────────────────────────────────────────────┐
|
|
109
|
-
│ Conversation (too long) │
|
|
110
|
-
└──────────────┬──────────────────────────────┘
|
|
111
|
-
│
|
|
112
|
-
┌────────────▼────────────┐
|
|
113
|
-
│ Phase 1: EXTRACT │ ← deterministic (0 LLM calls)
|
|
114
|
-
│ • files modified/read │
|
|
115
|
-
│ • errors + retries │
|
|
116
|
-
│ • decisions │
|
|
117
|
-
│ • constraints │
|
|
118
|
-
└────────────┬────────────┘
|
|
119
|
-
│
|
|
120
|
-
┌────────────▼────────────┐
|
|
121
|
-
│ Phase 2: EXPLORE │ ← LLM with tools (0–8 rounds)
|
|
122
|
-
│ • verify topic bounds │ ← skipped for simple sessions
|
|
123
|
-
│ • find cross-references│
|
|
124
|
-
│ • assess status │
|
|
125
|
-
└────────────┬────────────┘
|
|
126
|
-
│
|
|
127
|
-
┌────────────▼────────────┐
|
|
128
|
-
│ Phase 3: SYNTHESIZE │ ← parallel batch summarize
|
|
129
|
-
│ • chunk messages │
|
|
130
|
-
│ • summarize batches │
|
|
131
|
-
│ • assemble final │
|
|
132
|
-
└────────────┬────────────┘
|
|
133
|
-
│
|
|
134
|
-
┌────────────▼────────────┐
|
|
135
|
-
│ Phase 4: VERIFY │ ← deterministic checks
|
|
136
|
-
│ • coverage gaps? │
|
|
137
|
-
│ • hallucinated files? │
|
|
138
|
-
│ • patch if needed │
|
|
139
|
-
└────────────┬────────────┘
|
|
140
|
-
│
|
|
141
|
-
┌────────────▼────────────┐
|
|
142
|
-
│ Compact context applied│
|
|
143
|
-
└─────────────────────────┘
|
|
144
|
-
```
|
|
122
|
+
When `autoTrigger` is enabled (default), Smart Compact runs automatically before Pi's built-in compaction kicks in. The `session_before_compact` hook intercepts the event and produces the smart summary instead of blind truncation.
|
|
145
123
|
|
|
146
124
|
---
|
|
147
125
|
|
|
@@ -149,15 +127,15 @@ The extension also registers a tool named `smart_compact`:
|
|
|
149
127
|
|
|
150
128
|
| Profile | Summary Budget | Keep Recent | Best For |
|
|
151
129
|
|---------|---------------|-------------|----------|
|
|
152
|
-
| **light** | 10K tokens | 30K tokens | Debugging, complex multi-file refactors |
|
|
130
|
+
| **light** | 10K tokens | 30K tokens | Debugging sessions, complex multi-file refactors where detail matters |
|
|
153
131
|
| **balanced** | 6K tokens | 20K tokens | General development (default) |
|
|
154
|
-
| **aggressive** | 3K tokens | 10K tokens | Quick exploration, prototyping |
|
|
132
|
+
| **aggressive** | 3K tokens | 10K tokens | Quick exploration, prototyping, or very large contexts |
|
|
155
133
|
|
|
156
134
|
---
|
|
157
135
|
|
|
158
136
|
## Configuration
|
|
159
137
|
|
|
160
|
-
|
|
138
|
+
Add to `~/.pi/agent/settings.json`:
|
|
161
139
|
|
|
162
140
|
```json
|
|
163
141
|
{
|
|
@@ -168,28 +146,179 @@ Create `~/.pi/agent/settings.json`:
|
|
|
168
146
|
"autoTrigger": true,
|
|
169
147
|
"backupEnabled": true,
|
|
170
148
|
"profiles": {
|
|
171
|
-
"
|
|
149
|
+
"balanced": { "summaryBudgetTokens": 6000, "keepRecentTokens": 20000 }
|
|
172
150
|
}
|
|
173
151
|
}
|
|
174
152
|
}
|
|
175
153
|
```
|
|
176
154
|
|
|
155
|
+
| Option | Type | Default | Description |
|
|
156
|
+
|--------|------|---------|-------------|
|
|
157
|
+
| `profile` | `"light"` \| `"balanced"` \| `"aggressive"` | `"balanced"` | Default compression profile |
|
|
158
|
+
| `summaryModel` | `string` \| `null` | `null` | Override model for summarization (e.g. `"anthropic/claude-sonnet-4"`) |
|
|
159
|
+
| `segmentationModel` | `string` \| `null` | `null` | Override model for exploration (e.g. `"anthropic/claude-haiku-3"`) |
|
|
160
|
+
| `autoTrigger` | `boolean` | `true` | Automatically run on Pi's `session_before_compact` hook |
|
|
161
|
+
| `backupEnabled` | `boolean` | `true` | Save conversation backup before compaction |
|
|
162
|
+
| `profiles` | `object` | — | Override per-profile token budgets |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Architecture Deep Dive
|
|
167
|
+
|
|
168
|
+
### Deterministic Extraction (Phase 1)
|
|
169
|
+
|
|
170
|
+
Zero LLM calls. Extracts purely from message structure:
|
|
171
|
+
|
|
172
|
+
- **File operations** — tracks read/write/edit/delete with no-op detection (`"applied: 0"`, `"no changes"`)
|
|
173
|
+
- **Error lifecycle** — not just "isError" but retry detection (same tool re-called within 6 messages) and resolution tracking
|
|
174
|
+
- **Decisions** — explicit (`ask_user` tool calls) and implicit (user choice patterns like "use X instead of Y")
|
|
175
|
+
- **Constraints** — regex-based mining with English + Turkish patterns, categorized as requirement/prohibition/preference
|
|
176
|
+
- **Topic segmentation** — heuristic boundaries based on file transitions, error density, user "shift" patterns, and token limits
|
|
177
|
+
|
|
178
|
+
### Adaptive Exploration Gate
|
|
179
|
+
|
|
180
|
+
Exploration is **skipped** for simple sessions that meet all criteria:
|
|
181
|
+
- ≤ 3 topics
|
|
182
|
+
- ≤ 1 unresolved error
|
|
183
|
+
- ≤ 2 decisions
|
|
184
|
+
- ≤ 2 directory groups
|
|
185
|
+
|
|
186
|
+
This saves 3–8 LLM calls on straightforward sessions.
|
|
187
|
+
|
|
188
|
+
### Decision Propagation
|
|
189
|
+
|
|
190
|
+
Each batch receives "Active Decisions from previous segments" — decisions made before the batch's message range. This prevents the common failure mode where Batch 2 doesn't know that Batch 1 decided to use React.
|
|
191
|
+
|
|
192
|
+
### Immutable Context Framing
|
|
193
|
+
|
|
194
|
+
The assembly prompt presents deterministic data as **IMMUTABLE CONTEXT** with explicit rules:
|
|
195
|
+
|
|
196
|
+
> *"These are deterministically verified from the original conversation. They take priority over ANY summary content below."*
|
|
197
|
+
|
|
198
|
+
This reduces fabrication by making the LLM treat verified data as ground truth.
|
|
199
|
+
|
|
200
|
+
### Verification & Patching
|
|
201
|
+
|
|
202
|
+
1. **Verification** — checks file coverage, error coverage, constraint coverage, hallucinated file paths, error-done inconsistencies, decision coverage
|
|
203
|
+
2. **Deterministic patch** (score < 85) — injects missing items directly into the relevant markdown sections, zero LLM cost
|
|
204
|
+
3. **LLM patch** (score < 75 after deterministic) — last resort, only if deterministic patch was insufficient
|
|
205
|
+
4. **Skip** (score ≥ 85) — no patching needed
|
|
206
|
+
|
|
207
|
+
### Redundancy Pruning
|
|
208
|
+
|
|
209
|
+
Before compaction, deterministic pruning removes:
|
|
210
|
+
- **Duplicate file reads** — keeps only the last read per file
|
|
211
|
+
- **Collapsed error chains** — 3+ consecutive same-tool failures → keep first + last only
|
|
212
|
+
- **Agent acknowledgments** — "I'll fix that", "Let me check", "Sure" (zero-information messages)
|
|
213
|
+
- **Long tool outputs** — truncates to 800 chars (head 400 + tail 400)
|
|
214
|
+
|
|
215
|
+
### Project Fingerprint
|
|
216
|
+
|
|
217
|
+
Cross-session learning stored at `~/.pi/agent/.cache/smart-compact/projects/`:
|
|
218
|
+
|
|
219
|
+
| Field | How it's detected |
|
|
220
|
+
|-------|-------------------|
|
|
221
|
+
| Language | Most common file extension (.ts → typescript, .rs → rust, etc.) |
|
|
222
|
+
| Framework | Config file patterns (next.config → nextjs, vite.config → vite, etc.) |
|
|
223
|
+
| Key directories | Most frequently modified directory paths |
|
|
224
|
+
| Known files | Last 50 unique files across sessions |
|
|
225
|
+
| Session count | Incremented each compaction |
|
|
226
|
+
|
|
227
|
+
30-day TTL. Loaded before Phase 1 and injected into the synthesis prompt as project context.
|
|
228
|
+
|
|
229
|
+
### Damage Detection
|
|
230
|
+
|
|
231
|
+
After compaction, monitors the next 15 messages for regression signals:
|
|
232
|
+
|
|
233
|
+
| Signal | Severity | Detection |
|
|
234
|
+
|--------|----------|-----------|
|
|
235
|
+
| Agent re-reads compacted file | Medium | Tool call `read` with path from compacted section |
|
|
236
|
+
| User complaint | High | Regex: "I already told you", "you forgot", "nerede kaldı" |
|
|
237
|
+
| Re-question | Low | User mentions compacted decision topic |
|
|
238
|
+
|
|
239
|
+
Logged to `~/.pi/agent/.cache/smart-compact/damage-reports.jsonl` for future analysis.
|
|
240
|
+
|
|
241
|
+
### Token Estimation
|
|
242
|
+
|
|
243
|
+
- **Provider-specific ratios** (OpenAI: 4.0, Anthropic: 3.5, MiniMax: 3.8)
|
|
244
|
+
- **JSON penalty** (0.85x) — JSON.stringify'd content has denser tokenization
|
|
245
|
+
- **Language penalty** (0.9x) — Turkish/CE characters tokenize differently
|
|
246
|
+
- **Per-provider EMA calibration** — learns from actual API responses, scoped per provider
|
|
247
|
+
|
|
248
|
+
### Provider Concurrency
|
|
249
|
+
|
|
250
|
+
| Provider | Concurrency Limit | Cache Strategy |
|
|
251
|
+
|----------|-------------------|----------------|
|
|
252
|
+
| OpenAI | 5 | prompt caching |
|
|
253
|
+
| Anthropic (zai) | 3 | anthropic caching |
|
|
254
|
+
| MiniMax | 2 | anthropic caching |
|
|
255
|
+
| Xiaomi | 2 | openai caching |
|
|
256
|
+
| Default | 2 | none |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Summary Format
|
|
261
|
+
|
|
262
|
+
Smart Compact produces structured markdown:
|
|
263
|
+
|
|
264
|
+
```markdown
|
|
265
|
+
## Goal
|
|
266
|
+
[What the user is trying to accomplish]
|
|
267
|
+
|
|
268
|
+
## Constraints & Preferences
|
|
269
|
+
- [requirement] Must use TypeScript strict mode
|
|
270
|
+
- [preference] Prefer functional components
|
|
271
|
+
|
|
272
|
+
## Progress
|
|
273
|
+
### Done
|
|
274
|
+
- [x] Auth module implemented (src/auth.ts)
|
|
275
|
+
### In Progress
|
|
276
|
+
- [ ] Database migration
|
|
277
|
+
### Blocked
|
|
278
|
+
- Waiting for API credentials
|
|
279
|
+
|
|
280
|
+
## Key Decisions
|
|
281
|
+
- **Use JWT for auth**: User confirmed over session cookies
|
|
282
|
+
|
|
283
|
+
## Files Modified
|
|
284
|
+
- src/auth.ts
|
|
285
|
+
- src/db/migrations/001.sql
|
|
286
|
+
|
|
287
|
+
## Files Read
|
|
288
|
+
- src/config.ts
|
|
289
|
+
- package.json
|
|
290
|
+
|
|
291
|
+
## Next Steps
|
|
292
|
+
1. Complete database migration
|
|
293
|
+
2. Add integration tests
|
|
294
|
+
|
|
295
|
+
## Critical Context
|
|
296
|
+
- Unresolved error: test failed in auth.ts line 42
|
|
297
|
+
- API base URL: https://api.example.com/v2
|
|
298
|
+
|
|
299
|
+
## Topics Covered
|
|
300
|
+
- **Auth implementation** [high]
|
|
301
|
+
- **DB schema design** [normal]
|
|
302
|
+
- **Config review** [low]
|
|
303
|
+
```
|
|
304
|
+
|
|
177
305
|
---
|
|
178
306
|
|
|
179
307
|
## Development
|
|
180
308
|
|
|
181
309
|
```bash
|
|
182
310
|
bun install
|
|
183
|
-
bun test
|
|
311
|
+
bun test # 56 tests across 7 files
|
|
312
|
+
bun run typecheck # TypeScript check
|
|
184
313
|
```
|
|
185
314
|
|
|
186
315
|
---
|
|
187
316
|
|
|
188
317
|
## Contributing
|
|
189
318
|
|
|
190
|
-
1. Fork
|
|
191
|
-
2. Create your
|
|
192
|
-
3. Commit
|
|
319
|
+
1. Fork the repo
|
|
320
|
+
2. Create your branch (`git checkout -b feat/amazing-feature`)
|
|
321
|
+
3. Commit (`git commit -am 'Add amazing feature'`)
|
|
193
322
|
4. Push (`git push origin feat/amazing-feature`)
|
|
194
323
|
5. Open a Pull Request
|
|
195
324
|
|
|
@@ -197,4 +326,4 @@ bun test # runs test suite
|
|
|
197
326
|
|
|
198
327
|
## License
|
|
199
328
|
|
|
200
|
-
MIT © [Alper](https://github.com/
|
|
329
|
+
MIT © [Alper Tarhan](https://github.com/alpertarhan)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-smart-compact",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.2",
|
|
4
4
|
"description": "EESV smart compaction extension for Pi Coding Agent — deterministic extraction, exploration, synthesis, verification with redundancy pruning, project fingerprinting, and damage detection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alper Tarhan <alpertarhan@gmail.com>",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/alpertarhan/pi-smart-compact/issues"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
|
+
"pi-package",
|
|
16
17
|
"pi",
|
|
17
18
|
"pi-extension",
|
|
18
19
|
"pi-coding-agent",
|
|
@@ -36,6 +37,12 @@
|
|
|
36
37
|
"pi": {
|
|
37
38
|
"extensions": ["./src/index.ts"]
|
|
38
39
|
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@earendil-works/pi-ai": "*",
|
|
42
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
43
|
+
"@earendil-works/pi-tui": "*",
|
|
44
|
+
"typebox": "*"
|
|
45
|
+
},
|
|
39
46
|
"publishConfig": {
|
|
40
47
|
"access": "public"
|
|
41
48
|
}
|
package/src/constants.ts
CHANGED
package/src/core.ts
CHANGED
|
@@ -103,14 +103,6 @@ export async function runSmartCompact(
|
|
|
103
103
|
const backupPath = backupConversation(convText, sessionId);
|
|
104
104
|
const prevContext = getPreviousCompactionContext(branch);
|
|
105
105
|
|
|
106
|
-
// ── Project fingerprint (cross-session context) ──
|
|
107
|
-
const projectId = deriveProjectId(extraction);
|
|
108
|
-
const fingerprint = loadProjectFingerprint(projectId);
|
|
109
|
-
if (fingerprint) {
|
|
110
|
-
notify("Project: " + fingerprint.language + (fingerprint.framework ? "/" + fingerprint.framework : "") + " (" + fingerprint.sessionCount + " sessions)", "info");
|
|
111
|
-
}
|
|
112
|
-
const projectCtx = buildProjectContext(fingerprint);
|
|
113
|
-
|
|
114
106
|
// Phase 1
|
|
115
107
|
const cachedExt = loadCachedExtraction(sessionId);
|
|
116
108
|
let extraction: StructuredExtraction;
|
|
@@ -125,6 +117,14 @@ export async function runSmartCompact(
|
|
|
125
117
|
}
|
|
126
118
|
saveCachedExtraction(sessionId, extraction, llmMessages.length);
|
|
127
119
|
|
|
120
|
+
// ── Project fingerprint (cross-session context) ──
|
|
121
|
+
const projectId = deriveProjectId(extraction);
|
|
122
|
+
const fingerprint = loadProjectFingerprint(projectId);
|
|
123
|
+
if (fingerprint) {
|
|
124
|
+
notify("Project: " + fingerprint.language + (fingerprint.framework ? "/" + fingerprint.framework : "") + " (" + fingerprint.sessionCount + " sessions)", "info");
|
|
125
|
+
}
|
|
126
|
+
const projectCtx = buildProjectContext(fingerprint);
|
|
127
|
+
|
|
128
128
|
let finalSummary: string;
|
|
129
129
|
let method: string;
|
|
130
130
|
let llmCalls = 0;
|