repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

fix(prune): cap raw compaction tail

9ae51e5007d171ac88bb86526dc77c11d5710cf6

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (10)

extensions/prune/README.md

Modified
34 34 | Hook | Behavior |
35 35 | --- | --- |
36 -| `session_before_compact` | Returns prune compaction when `prune.overrideDefault` is true. Includes `firstKeptEntryId`, `tokensBefore`, and details `{ kind: "prune", version: 1, sourceEntriesProcessed, tailKept }`. |
36 +| `session_before_compact` | Returns prune compaction when `prune.overrideDefault` is true. Hard-caps raw kept tail at ~32k tokens when a safe boundary exists. Includes `firstKeptEntryId`, `tokensBefore`, and details `{ kind: "prune", version: 1, sourceEntriesProcessed, tailKept, splitPrefixMessages }`. |
37 37 | `session_start` | Enables/disables `prune_recall` from current branch state. |
38 38 | `session_tree` | Enables/disables `prune_recall` from current branch state. |
39 39 | `session_compact` | Enables `prune_recall` after a prune compaction, logs in debug mode, and notifies UI when present. |
44 44 | --- | ---: | --- |
45 45 | `prune.overrideDefault` | `true` | Return prune compaction from `session_before_compact`. |
46 46 | `prune.sectionLimit` | `8` | Max lines per structured section in formatted output. |
47 -| `prune.transcriptLimit` | `120` | Max transcript lines kept in summary tail. |
48 -| `prune.toolCapPerTurn` | `8` | Loaded setting; not currently applied by source. |
47 +| `prune.transcriptLimit` | `60` | Max transcript lines kept in summary tail. |
48 +| `prune.toolCapPerTurn` | `8` | Max tool-call transcript lines per user turn. Errors are always kept. |
49 49 | `prune.debug` | `false` | Log prune stats, skipped roles, and compaction status. |
51 51 ## Behavior
60 60 - `[Files And Changes]`: paths inferred from read/write/edit tool args and simple bash path matches.
61 61 - `[Outstanding Context]`: tool errors and recent blocker/failure lines.
62 62 - `[User Preferences]`: explicit user preference lines.
63 + - `[Continue Now]`: deterministic resume block from the transcript tail.
63 64 - Empty structured sections are omitted.
64 65 - Transcript entries keep stable `#N` source refs from the compaction input order.
65 66 - Tool calls render as `* tool "arg" (#N)` when a command/path is available, otherwise `* tool (#N)`.
66 67 - Bash tool commands are shortened: leading `cd ... &&` is removed, and a trailing simple pipe such as `tail`/`head` is removed.
67 68 - Tool errors render as `[tool_error] [ERROR] tool (#N)`.
68 -- Existing prune summaries are merged with fresh summaries. Goals/preferences/files are deduped, context is refreshed, transcript keeps previous entries before fresh entries.
69 +- Existing prune summaries are merged with fresh summaries. Goals/preferences/files are deduped, context and continue block are refreshed, transcript keeps previous entries before fresh entries.
69 70 - Prune compactions are detected by `details.kind === "prune"`; older hook summaries are also detected when they contain the prune recall note.
70 71 - Recall searches current branch lineage by default. `scope: "all"` searches all session entries.
71 72 - Recall includes message entries, compaction summaries, and `custom_message` content.
88 89 [Outstanding Context]
89 90 - lint still failing
92 +[Continue Now]
93 +- Current request: Fix the auth bug (#1)
94 +- Last action: read src/auth/session.ts (#3)
95 +- Next: continue current request; use prune_recall before redoing old work.
93 99 [user]
99 -prune: 10 source entries processed; tail kept 3 (~18.9k tok)
105 +prune: 10 entries summarized; before 18.9k tok; raw kept 3 entries; split-prefix 0

extensions/prune/SPEC.md

Modified
53 53 [Commits]
54 54 - abc1234: Fix token refresh
56 +[Continue Now]
57 +- Current request: Fix the auth bug (#5)
58 +- Last action: edit session.ts (#9)
59 +- Next: continue current request; use prune_recall before redoing old work.
57 62 [user] Fix the auth bug (#5)
58 63 [assistant] Root cause found
63 68 ───────────────────────────────────────────────────────────────
65 - prune: 309 source entries processed; tail kept 67 (~18.9k tok)
70 + prune: 309 entries summarized; before 18.9k tok; raw kept 67 entries; split-prefix 0
67 72 Use prune_recall to search for prior work, decisions, and context from before this summary.
68 73 Do not redo work already completed.
77 82 | `[Outstanding Context]` | Errors, blockers, pending questions | Fresh (replace) |
78 83 | `[User Preferences]` | prefer/never/always patterns | Sticky (accumulate, cap 15) |
79 84 | `[Commits]` | Extracted git commits with hashes | Sticky (keep recent 8) |
85 +| `[Continue Now]` | Resume block from latest transcript tail | Fresh (replace) |
80 86 | `---` | Brief transcript | Append fresh after previous, then cap tail (older first in final output) |
82 88 ## Extract Algorithm
227 233 // - Tool calls: 120 chars, compress bash
229 235 // Collapse:
230 -// - Consecutive identical tools → grouped refs
231 -// - Consecutive identical errors → xN notation
232 -// - Cap at 8 tools per [assistant] turn (keep tail)
236 +// - Cap at toolCapPerTurn tool-call lines per user turn
237 +// - Errors are always kept
235 240 ### 4. Merge
237 242 ```typescript
238 243 merge(previousSummary: string | undefined, freshSummary: string): string {
239 244 // Text merge using stable section headers.
240 - // Outstanding Context: REPLACE (fresh only)
245 + // Outstanding Context + Continue Now: REPLACE (fresh only)
241 246 // Files: union by category + dedup
242 247 // Goals/Preferences/Commits: union + dedup + cap
243 248 // Transcript: previous brief + fresh brief, then cap tail
274 279 ### Metadata footer
277 -prune: 309 source entries processed; tail kept 67 (~18.9k tok)
282 +prune: 309 entries summarized; before 18.9k tok; raw kept 67 entries; split-prefix 0
280 -- `source entries processed` = `messagesToSummarize.length + turnPrefixMessages.length`
281 -- `tail kept` = `turnPrefixMessages.length`
282 -- token count = use compaction event token info if available; otherwise omit `(~N tok)`
285 +- `entries summarized` = messages passed to deterministic extraction, including old raw-tail entries moved into summary
286 +- `before N tok` = compaction event `tokensBefore`, if available
287 +- `raw kept` = branch entries kept after returned `firstKeptEntryId`
288 +- `split-prefix` = `turnPrefixMessages.length`
284 290 ## Commands
296 302 "prune": {
297 303 "sectionLimit": 8,
298 - "transcriptLimit": 120,
304 + "transcriptLimit": 60,
299 305 "toolCapPerTurn": 8,
300 306 "debug": false

extensions/prune/__tests__/extract.test.ts

Modified
184 184 expect(result.transcript[2].cmd).toBeUndefined();
187 + it('caps tool calls per turn and keeps errors', () => {
188 + const result = extract(normalize([
189 + { role: 'user', content: 'fix it' },
190 + { role: 'assistant', content: [{ type: 'toolCall', name: 'read', arguments: { path: 'a.ts' } }] },
191 + { role: 'assistant', content: [{ type: 'toolCall', name: 'read', arguments: { path: 'b.ts' } }] },
192 + { role: 'tool', toolName: 'bash', isError: true, content: 'failed' },
193 + ]), { toolCapPerTurn: 1 });
194 + expect(result.transcript.map(entry => entry.cmd)).toContain('a.ts');
195 + expect(result.transcript.map(entry => entry.cmd)).not.toContain('b.ts');
196 + expect(result.transcript.some(entry => entry.role === 'error')).toBe(true);
197 + });
187 199 it('ignores thinking blocks if present directly', () => {
188 200 const result = extract([{ kind: 'thinking', text: 'secret', sourceIndex: 1 }]);
189 201 expect(result.transcript).toHaveLength(0);

extensions/prune/__tests__/format.test.ts

Modified
30 30 expect(out).toContain('[Files And Changes]');
31 31 expect(out).toContain('[Outstanding Context]');
32 32 expect(out).toContain('[User Preferences]');
33 + expect(out).toContain('[Continue Now]');
34 + expect(out).toContain('- Current request: Fix the auth bug (#1)');
33 35 expect(out).toContain('[user]\nFix the auth bug (#1)');
34 - expect(out).toContain('prune: 10 source entries processed; tail kept 3 (~18.9k tok)');
36 + expect(out).toContain('prune: 10 entries summarized; before 18.9k tok; raw kept 3 entries');
35 37 expect(out).toContain('Use prune_recall');
36 38 expect(out).not.toContain('vcc_recall');
74 76 for (let i = 0; i < 12; i++) data.files.modified.add(`file${i}.ts`);
75 77 const out = format(data, { sourceEntriesProcessed: 12, tailKept: 0 }).summary;
76 78 expect(out).toContain('(+2 more)');
77 - expect(out).toContain('prune: 12 source entries processed; tail kept 0');
78 - expect(out).not.toContain('tok)');
79 + expect(out).toContain('prune: 12 entries summarized; raw kept 0 entries');
80 + expect(out).not.toContain('; before');
81 83 it('formats small token estimates without k suffix', () => {
82 84 const data = emptyData();
83 85 const out = format(data, { sourceEntriesProcessed: 1, tailKept: 0, tokenEstimate: 999 }).summary;
84 - expect(out).toContain('(~999 tok)');
86 + expect(out).toContain('before 999 tok');

extensions/prune/__tests__/harness.test.ts

Modified
51 51 expect(result?.compaction?.summary).toContain('[Session Goal]');
52 52 expect(result?.compaction?.summary).toContain('Fix auth token refresh');
53 - expect(result?.compaction?.summary).toContain('tail kept 1 (~1.2k tok)');
53 + expect(result?.compaction?.summary).toContain('before 1.2k tok; raw kept 0 entries; split-prefix 1');
54 + expect(result?.compaction?.summary).toContain('[Continue Now]');
54 55 expect(result?.compaction?.summary).not.toContain('- Successfully wrote 123 bytes');
55 56 expect(result?.compaction?.firstKeptEntryId).toBe('keep-1');
56 57 expect(result?.compaction?.details).toEqual({
57 58 kind: 'prune',
58 59 version: 1,
59 60 sourceEntriesProcessed: 4,
60 - tailKept: 1,
61 + tailKept: 0,
62 + splitPrefixMessages: 1,
66 + it('moves oversized raw tail into summary at safe boundary', async () => {
67 + const prunePath = path.resolve(import.meta.dir, '../index.ts');
68 + t = await createTestSession({ extensions: [prunePath] });
70 + const result = await t.session.extensionRunner.emit({
71 + type: 'session_before_compact',
72 + preparation: {
73 + firstKeptEntryId: 'keep-old',
74 + messagesToSummarize: [],
75 + turnPrefixMessages: [],
76 + isSplitTurn: false,
77 + tokensBefore: 90000,
78 + fileOps: { readFiles: [], modifiedFiles: [] },
79 + settings: { enabled: true, reserveTokens: 1000, keepRecentTokens: 1 },
80 + },
81 + branchEntries: [
82 + { type: 'message', id: 'keep-old', parentId: null, timestamp: '', message: { role: 'user', content: 'old kept huge '.repeat(20000) } },
83 + { type: 'message', id: 'safe-new', parentId: 'keep-old', timestamp: '', message: { role: 'user', content: 'new request' } },
84 + { type: 'message', id: 'tail-assistant', parentId: 'safe-new', timestamp: '', message: { role: 'assistant', content: 'done' } },
85 + ],
86 + signal: new AbortController().signal,
87 + });
89 + expect(result?.compaction?.firstKeptEntryId).toBe('safe-new');
90 + expect(result?.compaction?.details).toMatchObject({ sourceEntriesProcessed: 1, tailKept: 2 });
91 + expect(result?.compaction?.summary).toContain('raw kept 2 entries');
92 + });
64 94 it('activates prune_recall only after prune compaction exists in branch', async () => {
65 95 const prunePath = path.resolve(import.meta.dir, '../index.ts');
66 96 t = await createTestSession({ extensions: [prunePath] });

extensions/prune/index.ts

Modified
13 13 import { merge } from './src/merge.ts';
14 14 import { recall, formatRecallResults } from './src/recall.ts';
15 15 import type { PruneSettings, Message } from './src/types.ts';
16 -import { DEFAULT_SECTION_LIMIT, DEFAULT_TRANSCRIPT_LIMIT } from './src/constants.ts';
16 +import { DEFAULT_SECTION_LIMIT, DEFAULT_TRANSCRIPT_LIMIT, MAX_RAW_TAIL_TOKENS } from './src/constants.ts';
18 18 // ─── Settings ──────────────────────────────────────────────────────────────
25 25 version: 1;
26 26 sourceEntriesProcessed: number;
27 27 tailKept: number;
28 + splitPrefixMessages: number;
30 31 const DEFAULT_SETTINGS: Required<PruneSettings> = {
66 67 function prune(
67 68 messages: Message[],
68 69 previous?: string,
69 - metadata: { sourceEntriesProcessed?: number; tailKept?: number; tokenEstimate?: number } = {},
70 + metadata: { sourceEntriesProcessed?: number; tailKept?: number; splitPrefixMessages?: number; tokenEstimate?: number } = {},
70 71 ): string {
71 72 const blocks = normalize(messages);
72 - const data = extract(blocks);
73 + const data = extract(blocks, { toolCapPerTurn: settings.toolCapPerTurn });
74 75 const output = format(data, {
75 76 sectionLimit: settings.sectionLimit,
137 +type SessionEntryLike = {
138 + type?: string;
139 + id?: string;
140 + message?: unknown;
141 + summary?: string;
142 + content?: unknown;
145 +function planRawTail(
146 + branchEntries: unknown[],
147 + firstKeptEntryId: string,
148 +): { firstKeptEntryId: string; extraMessages: Message[]; rawTailKept: number } {
149 + const entries = branchEntries as SessionEntryLike[];
150 + const oldIndex = entries.findIndex(entry => entry.id === firstKeptEntryId);
151 + if (oldIndex < 0) return { firstKeptEntryId, extraMessages: [], rawTailKept: 0 };
153 + let accumulated = 0;
154 + let candidate = oldIndex;
155 + for (let i = entries.length - 1; i >= oldIndex; i--) {
156 + const next = accumulated + estimateEntryTokens(entries[i]);
157 + if (next > MAX_RAW_TAIL_TOKENS) break;
158 + accumulated = next;
159 + if (isSafeBoundary(entries[i])) candidate = i;
162 + const newFirstKeptEntryId = entries[candidate]?.id ?? firstKeptEntryId;
163 + const extraMessages = candidate > oldIndex
164 + ? entries.slice(oldIndex, candidate).map(entryToPruneMessage).filter((message): message is Message => message !== undefined)
165 + : [];
167 + return {
168 + firstKeptEntryId: newFirstKeptEntryId,
169 + extraMessages,
170 + rawTailKept: entries.length - candidate,
171 + };
174 +function entryToPruneMessage(entry: SessionEntryLike): Message | undefined {
175 + if (entry.type === 'message') return toPruneMessage(entry.message);
176 + if (entry.type === 'branch_summary' && entry.summary) return { role: 'assistant', content: entry.summary };
177 + if (entry.type === 'custom_message') return { role: 'user', content: entry.content as Message['content'] };
178 + return undefined;
181 +function isSafeBoundary(entry: SessionEntryLike): boolean {
182 + if (entry.type === 'custom_message' || entry.type === 'branch_summary') return true;
183 + if (entry.type !== 'message') return false;
184 + const role = (entry.message as { role?: string } | undefined)?.role;
185 + return role === 'user' || role === 'assistant' || role === 'bashExecution';
188 +function estimateEntryTokens(entry: SessionEntryLike): number {
189 + if (entry.type === 'message') return estimateUnknownTokens(entry.message);
190 + if (entry.type === 'branch_summary') return estimateStringTokens(entry.summary ?? '');
191 + if (entry.type === 'custom_message') return estimateUnknownTokens(entry.content);
192 + return 0;
195 +function estimateUnknownTokens(value: unknown): number {
196 + if (typeof value === 'string') return estimateStringTokens(value);
197 + if (Array.isArray(value)) return estimateStringTokens(value.map(part => {
198 + if (typeof part !== 'object' || part == null) return String(part);
199 + const p = part as { text?: string; thinking?: string; arguments?: unknown; name?: string };
200 + if (p.text) return p.text;
201 + if (p.thinking) return p.thinking;
202 + if (p.arguments) return `${p.name ?? ''} ${JSON.stringify(p.arguments)}`;
203 + return JSON.stringify(p);
204 + }).join('\n'));
205 + if (value && typeof value === 'object' && 'content' in value) {
206 + return estimateUnknownTokens((value as { content?: unknown }).content);
208 + return estimateStringTokens(JSON.stringify(value ?? ''));
211 +function estimateStringTokens(text: string): number {
212 + return Math.ceil(text.length / 4);
136 215 // ─── Extension ────────────────────────────────────────────────────────────
138 217 export default function (pi: ExtensionAPI) {
162 241 if (!settings.overrideDefault) return;
243 + const tail = planRawTail(event.branchEntries, preparation.firstKeptEntryId);
164 244 const allMessages = [
165 245 ...preparation.messagesToSummarize,
166 246 ...preparation.turnPrefixMessages,
167 247 ].map(toPruneMessage).filter((message): message is Message => message !== undefined);
248 + allMessages.push(...tail.extraMessages);
169 250 const summary = prune(allMessages, preparation.previousSummary, {
170 251 sourceEntriesProcessed: allMessages.length,
171 - tailKept: preparation.turnPrefixMessages.length,
252 + tailKept: tail.rawTailKept,
253 + splitPrefixMessages: preparation.turnPrefixMessages.length,
172 254 tokenEstimate: preparation.tokensBefore,
176 258 kind: PRUNE_DETAILS_KIND,
177 259 version: 1,
178 260 sourceEntriesProcessed: allMessages.length,
179 - tailKept: preparation.turnPrefixMessages.length,
261 + tailKept: tail.rawTailKept,
262 + splitPrefixMessages: preparation.turnPrefixMessages.length,
182 265 return {
183 266 compaction: {
184 267 summary,
185 - firstKeptEntryId: preparation.firstKeptEntryId,
268 + firstKeptEntryId: tail.firstKeptEntryId,
186 269 tokensBefore: preparation.tokensBefore,
187 270 details,

extensions/prune/src/constants.ts

Modified
5 5 // ─── Limits ─────────────────────────────────────────────────────────────────
7 7 export const DEFAULT_SECTION_LIMIT = 8;
8 -export const DEFAULT_TRANSCRIPT_LIMIT = 120;
8 +export const DEFAULT_TRANSCRIPT_LIMIT = 60;
9 9 export const DEFAULT_TOOL_CAP = 8;
10 +export const MAX_RAW_TAIL_TOKENS = 32000;
11 12 export const TRUNCATE_USER = 256;
12 13 export const TRUNCATE_ASSISTANT = 200;
67 68 export const SECTION_FILES = '[Files And Changes]';
68 69 export const SECTION_CONTEXT = '[Outstanding Context]';
69 70 export const SECTION_PREFS = '[User Preferences]';
71 +export const SECTION_CONTINUE = '[Continue Now]';
70 72 export const SECTION_COMMITS = '[Commits]';
71 73 export const SEPARATOR = '\n\n---\n\n';

extensions/prune/src/extract.ts

Modified
16 16 TRUNCATE_ASSISTANT,
17 17 PREF_PATTERNS,
18 18 GENERATED_PREF_FALSE_POSITIVE_RE,
19 + DEFAULT_TOOL_CAP,
19 20 } from './constants.ts';
22 23 * Extract structured sections from blocks.
24 -export function extract(blocks: Block[]): ExtractOutput {
25 +export interface ExtractOptions {
26 + toolCapPerTurn?: number;
29 +export function extract(blocks: Block[], options: ExtractOptions = {}): ExtractOutput {
30 + const toolCapPerTurn = options.toolCapPerTurn ?? DEFAULT_TOOL_CAP;
25 31 const goals: string[] = [];
26 32 const scopeChanges: string[] = [];
27 33 const modified = new Set<string>();
87 - const transcript = buildTranscript(blocks);
93 + const transcript = buildTranscript(blocks, toolCapPerTurn);
89 95 return {
90 96 goals: goals.slice(0, 8),
205 211 * Build brief transcript from blocks.
207 -function buildTranscript(blocks: Block[]): TranscriptEntry[] {
213 +function buildTranscript(blocks: Block[], toolCapPerTurn: number): TranscriptEntry[] {
208 214 const entries: TranscriptEntry[] = [];
215 + let toolCallsThisTurn = 0;
210 217 for (const block of blocks) {
211 218 switch (block.kind) {
212 219 case 'user': {
220 + toolCallsThisTurn = 0;
213 221 const text = truncate(stripSelfTalk(block.text), TRUNCATE_USER);
214 222 if (text) {
215 223 entries.push({ role: 'user', text, ref: `#${block.sourceIndex}` });
224 232 break;
226 234 case 'tool_call': {
235 + if (toolCallsThisTurn >= toolCapPerTurn) break;
236 + toolCallsThisTurn++;
227 237 const tool = block.name || 'unknown';
228 238 const cmd = extractToolCmd(block.args || {});
229 239 entries.push({

extensions/prune/src/format.ts

Modified
8 8 SECTION_FILES,
9 9 SECTION_CONTEXT,
10 10 SECTION_PREFS,
11 + SECTION_CONTINUE,
11 12 SEPARATOR,
12 13 DEFAULT_SECTION_LIMIT,
13 14 DEFAULT_TRANSCRIPT_LIMIT,
19 20 transcriptLimit?: number;
20 21 sourceEntriesProcessed?: number;
21 22 tailKept?: number;
23 + splitPrefixMessages?: number;
22 24 tokenEstimate?: number;
35 37 transcriptLimit = DEFAULT_TRANSCRIPT_LIMIT,
36 38 sourceEntriesProcessed,
37 39 tailKept,
40 + splitPrefixMessages,
38 41 tokenEstimate,
39 42 } = options;
72 75 transcriptLimit,
78 + const continueLines = formatContinueLines(data.transcript);
79 + if (continueLines.length > 0) {
80 + sections.push(`${SECTION_CONTINUE}\n${continueLines.join('\n')}`);
81 + }
75 83 const parts: string[] = [];
76 84 if (sections.length > 0) parts.push(sections.join('\n\n'));
77 85 if (transcriptLines.length > 0) parts.push(transcriptLines.join('\n'));
79 - const footer = formatFooter({ sourceEntriesProcessed, tailKept, tokenEstimate });
87 + const footer = formatFooter({ sourceEntriesProcessed, tailKept, splitPrefixMessages, tokenEstimate });
80 88 if (footer) parts.push(footer);
81 89 parts.push(RECALL_NOTE);
121 129 function formatFooter(options: {
122 130 sourceEntriesProcessed?: number;
123 131 tailKept?: number;
132 + splitPrefixMessages?: number;
124 133 tokenEstimate?: number;
125 134 }): string {
126 135 if (options.sourceEntriesProcessed == null || options.tailKept == null) return '';
127 - const tok = options.tokenEstimate == null ? '' : ` (~${formatTokenEstimate(options.tokenEstimate)} tok)`;
128 - return `prune: ${options.sourceEntriesProcessed} source entries processed; tail kept ${options.tailKept}${tok}`;
136 + const before = options.tokenEstimate == null ? '' : `; before ${formatTokenEstimate(options.tokenEstimate)} tok`;
137 + const split = options.splitPrefixMessages == null ? '' : `; split-prefix ${options.splitPrefixMessages}`;
138 + return `prune: ${options.sourceEntriesProcessed} entries summarized${before}; raw kept ${options.tailKept} entries${split}`;
141 +function formatContinueLines(transcript: TranscriptEntry[]): string[] {
142 + if (transcript.length === 0) return [];
143 + const lastUser = findLast(transcript, entry => entry.role === 'user');
144 + const lastFailure = findLast(transcript, entry => entry.role === 'error');
145 + const lastAction = findLast(transcript, entry => entry.role !== 'user');
146 + const lines: string[] = [];
147 + if (lastUser) lines.push(`- Current request: ${formatBriefEntry(lastUser)}`);
148 + if (lastAction) lines.push(`- Last action: ${formatBriefEntry(lastAction)}`);
149 + if (lastFailure) lines.push(`- Last failure: ${formatBriefEntry(lastFailure)}`);
150 + lines.push('- Next: continue current request; use prune_recall before redoing old work.');
151 + return lines;
154 +function findLast<T>(items: T[], predicate: (item: T) => boolean): T | undefined {
155 + for (let i = items.length - 1; i >= 0; i--) {
156 + if (predicate(items[i])) return items[i];
158 + return undefined;
161 +function formatBriefEntry(entry: TranscriptEntry): string {
162 + if (entry.tool) {
163 + const cmd = entry.cmd ? ` ${entry.cmd}` : '';
164 + return `${entry.tool}${cmd}${entry.ref ? ` (${entry.ref})` : ''}`;
166 + return `${entry.text}${entry.ref ? ` (${entry.ref})` : ''}`;
131 169 function formatTokenEstimate(tokens: number): string {

extensions/prune/src/merge.ts

Modified
7 7 SECTION_FILES,
8 8 SECTION_CONTEXT,
9 9 SECTION_PREFS,
10 + SECTION_CONTINUE,
10 11 SECTION_COMMITS,
11 12 SEPARATOR,
12 13 RECALL_NOTE,
17 18 SECTION_FILES,
18 19 SECTION_CONTEXT,
19 20 SECTION_PREFS,
21 + SECTION_CONTINUE,
20 22 SECTION_COMMITS,
43 45 function mergeSection(header: string, prev: string, fresh: string): string {
44 - if (header === SECTION_CONTEXT) return fresh;
46 + if (header === SECTION_CONTEXT || header === SECTION_CONTINUE) return fresh;
45 47 if (header === SECTION_FILES) {
46 48 if (!prev) return fresh;
47 49 if (!fresh) return prev;