pi-tuck 1.0.33 → 1.1.0
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 +24 -0
- package/dist/src/build-id.d.ts +1 -1
- package/dist/src/build-id.js +1 -1
- package/dist/src/diagnostics.d.ts +1 -1
- package/dist/src/kept-reads.d.ts +4 -0
- package/dist/src/kept-reads.js +40 -0
- package/dist/src/tuck/core/transcript.js +1 -1
- package/dist/src/tuck.js +24 -2
- package/package.json +1 -1
- package/src/build-id.ts +1 -1
- package/src/kept-reads.ts +36 -0
- package/src/tuck/core/transcript.ts +1 -1
- package/src/tuck.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to pi-tuck. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
4
4
|
[Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [1.1.0] - 2026-11-13
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- **A cut's summary now carries the files the session last read and has not changed since.** After a cut, agents often doubted what an
|
|
11
|
+
earlier read had shown and read the same file again, even though no edit had touched it. The summary now includes, after the Files
|
|
12
|
+
list, the newest whole read of each file that has no later write or edit, headed `read PATH (as recorded at #N; no write or edit
|
|
13
|
+
recorded since):`. It keeps at most 4 files, whole outputs only, within 20% of the summary's room and never more than 24,000
|
|
14
|
+
characters. When the summary is over its target these records are dropped first, oldest first. With no such reads the summary is
|
|
15
|
+
unchanged. Tool outputs are never touched.
|
|
16
|
+
|
|
17
|
+
### Release gates
|
|
18
|
+
|
|
19
|
+
- **Shipped before its Tier 1, on a 5-task gate.** The Tier 1 runs after release against 1.0.33; if it fails, npm and installs go back
|
|
20
|
+
to 1.0.33.
|
|
21
|
+
- **5-task check against 1.0.31:** no breakage in 5 of 5; re-checks after a doubt 22 against 45; doubt moments 9 against 24; cuts 22
|
|
22
|
+
against 26; turns 305 against 384; all 5 solved on both. One heavy task went worse: 90 turns against 59, 9 cuts against 4, 3 doubts
|
|
23
|
+
against 1.
|
|
24
|
+
- **Replay against 1.0.33:** 13,946 requests. In every recording that differs, the first difference is the first summary carrying one of
|
|
25
|
+
these records; 11 of 29 never differ. 0 lost or dead tasks, clips 17 → 16, cuts 1,946 → 1,971 (larger summaries bring later cuts
|
|
26
|
+
sooner).
|
|
27
|
+
- **Strict stress, 313 cells:** 0 findings on Pi 1.2.0 and the newest Pi, including the large-session test. Tests and CI. The packed
|
|
28
|
+
tarball loaded in the real installed Pi 1.5.2.
|
|
29
|
+
|
|
6
30
|
## [1.0.33] - 2026-11-13
|
|
7
31
|
|
|
8
32
|
### Fixed
|
package/dist/src/build-id.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BUILD_ID = "
|
|
1
|
+
export declare const BUILD_ID = "4031a9c8a1371d6ed9eb73970d3b1f676181d9065a344501750ef711a9aaba4a";
|
package/dist/src/build-id.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "4031a9c8a1371d6ed9eb73970d3b1f676181d9065a344501750ef711a9aaba4a";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RecallPolicy } from './recall.js';
|
|
2
2
|
import type { SessionEntry } from '@earendil-works/pi-coding-agent';
|
|
3
|
-
export declare const DIAGNOSTIC_BUILD = "
|
|
3
|
+
export declare const DIAGNOSTIC_BUILD = "4031a9c8a1371d6ed9eb73970d3b1f676181d9065a344501750ef711a9aaba4a";
|
|
4
4
|
export interface Receipt {
|
|
5
5
|
id: string;
|
|
6
6
|
build: string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { TranscriptRecord } from "./tuck/core/transcript.js";
|
|
3
|
+
/** Whole successful text reads, newest result first. Mutations invalidate earlier calls even when they fail or have no result. */
|
|
4
|
+
export declare function keptReadCandidates(entries: readonly SessionEntry[], indices: ReadonlyMap<string, number>, resolvable: (entry: SessionEntry) => boolean): TranscriptRecord[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isTextOnly, textOf } from "./tuck/core/content.js";
|
|
2
|
+
import { extractPath } from "./tuck/core/tool-args.js";
|
|
3
|
+
/** Whole successful text reads, newest result first. Mutations invalidate earlier calls even when they fail or have no result. */
|
|
4
|
+
export function keptReadCandidates(entries, indices, resolvable) {
|
|
5
|
+
const reads = new Map(), mutations = new Map();
|
|
6
|
+
let order = 0;
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
if (entry.type !== "message" || entry.message.role !== "assistant")
|
|
9
|
+
continue;
|
|
10
|
+
for (const block of entry.message.content) {
|
|
11
|
+
if (block.type !== "toolCall" || !["read", "write", "edit"].includes(block.name) ||
|
|
12
|
+
!block.arguments || typeof block.arguments !== "object")
|
|
13
|
+
continue;
|
|
14
|
+
const path = extractPath(block.arguments);
|
|
15
|
+
if (!path || /[\r\n]/u.test(path))
|
|
16
|
+
continue;
|
|
17
|
+
order++;
|
|
18
|
+
if (block.name === "read")
|
|
19
|
+
reads.set(block.id, { path, order });
|
|
20
|
+
else
|
|
21
|
+
mutations.set(path, order);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const seen = new Set(), records = [];
|
|
25
|
+
for (let at = entries.length - 1; at >= 0; at--) {
|
|
26
|
+
const entry = entries[at];
|
|
27
|
+
if (entry.type !== "message" || entry.message.role !== "toolResult" || entry.message.isError || !isTextOnly(entry.message.content))
|
|
28
|
+
continue;
|
|
29
|
+
const read = reads.get(entry.message.toolCallId), sourceIndex = indices.get(entry.id);
|
|
30
|
+
if (!read || seen.has(read.path) || (mutations.get(read.path) ?? -1) > read.order)
|
|
31
|
+
continue;
|
|
32
|
+
const text = textOf(entry.message.content);
|
|
33
|
+
if (!text.length || sourceIndex === undefined || !resolvable(entry))
|
|
34
|
+
continue;
|
|
35
|
+
seen.add(read.path);
|
|
36
|
+
records.push({ kind: "section", title: "Kept-read", sourceIndex,
|
|
37
|
+
text: `read ${read.path} (as recorded at #${sourceIndex}; no write or edit recorded since):\n${text}` });
|
|
38
|
+
}
|
|
39
|
+
return records;
|
|
40
|
+
}
|
|
@@ -57,7 +57,7 @@ const LEGACY_RECEIPT_RANGE_NOTICE = RECEIPT_RANGE_NOTICE.replace("tuck_recall",
|
|
|
57
57
|
* or, with no role, of the tool history
|
|
58
58
|
* | role " omitted " count " #" index "-#" index ":" ... counted inclusive index range
|
|
59
59
|
* | role " omitted " count [ " " locator-time { " " locator-time } ] ":" ... omission of unselected text blocks
|
|
60
|
-
* | [ locator " " ] title ":" ... section (
|
|
60
|
+
* | [ locator " " ] title ":" ... section (Files, Actions, Kept-read)
|
|
61
61
|
* locator = "#" index the source's session-wide index, as tuck_recall {"index"} takes it
|
|
62
62
|
* locator-time = locator [ "@" time-value ] every locator of a record has a time, or none does
|
|
63
63
|
* role = "user" | "assistant" | "custom" | "toolResult" (omissions only)
|
package/dist/src/tuck.js
CHANGED
|
@@ -7,6 +7,7 @@ import { carriedTailTokens, carriedTarget, conversationTokens } from "./budget.j
|
|
|
7
7
|
import { omissionRecord, userPrefixRecords } from "./tuck/core/brief.js";
|
|
8
8
|
import { isTextOnly, textOf } from "./tuck/core/content.js";
|
|
9
9
|
import { MAX_ACTION_LINES, MAX_LEDGER_LINES, actionItems, actionRecords, ledgerItems, ledgerRecords } from "./ledger.js";
|
|
10
|
+
import { keptReadCandidates } from "./kept-reads.js";
|
|
10
11
|
import { convertToLlm, SessionManager } from "@earendil-works/pi-coding-agent";
|
|
11
12
|
import { ATTEMPT_NOTICE, createRecall } from "./recall.js";
|
|
12
13
|
/** Includes JSON escaping, hit metadata and continuation, not just excerpt text. */
|
|
@@ -376,9 +377,26 @@ export function tuckObservedDraft(tuck, input, ctx, reserveTokens, measure, poli
|
|
|
376
377
|
let { boundary, high: protectedView } = selected;
|
|
377
378
|
const sourceRows = rows.filter(row => row.position < boundary);
|
|
378
379
|
const lists = listsAt(boundary);
|
|
379
|
-
|
|
380
|
+
const maxSummaryCharactersAt = (at) => Math.floor((target - offset - nativeAt(at)) * 4) - wrapperCharacters;
|
|
381
|
+
const maxSummaryCharacters = maxSummaryCharactersAt(boundary);
|
|
382
|
+
let allowance = Math.min(Math.floor(0.20 * maxSummaryCharacters), 24000);
|
|
383
|
+
const keptReads = [];
|
|
384
|
+
for (const record of keptReadCandidates(entries.slice(0, boundary), indices, entry => readable(entry) !== undefined)) {
|
|
385
|
+
const cost = lineCost([record]);
|
|
386
|
+
if (cost > allowance)
|
|
387
|
+
continue;
|
|
388
|
+
keptReads.push(record);
|
|
389
|
+
allowance -= cost;
|
|
390
|
+
if (keptReads.length === 4)
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
let ledger = [...lists.records, ...keptReads];
|
|
380
394
|
// List caps are existing ranking policy; only the carried target is a
|
|
381
395
|
// spending limit. Candidate list sizes have fixed, cached line prices.
|
|
396
|
+
while (keptReads.length && price(frameLength(protectedView.cost + lineCost(ledger), protectedView.rows.length + ledger.length), boundary) > target) {
|
|
397
|
+
keptReads.pop();
|
|
398
|
+
ledger = [...lists.records, ...keptReads];
|
|
399
|
+
}
|
|
382
400
|
if (price(frameLength(protectedView.cost + lineCost(ledger), protectedView.rows.length + ledger.length), boundary) > target) {
|
|
383
401
|
ledger = [];
|
|
384
402
|
for (let keep = 0; keep <= Math.min(Math.max(MAX_LEDGER_LINES, MAX_ACTION_LINES), Math.max(lists.files.length, lists.actions.length)); keep++) {
|
|
@@ -392,7 +410,6 @@ export function tuckObservedDraft(tuck, input, ctx, reserveTokens, measure, poli
|
|
|
392
410
|
return row?.message.role === "user" && isTextOnly(row.message.content);
|
|
393
411
|
}));
|
|
394
412
|
const fixed = [...protectedView.kept, ...ledger], fixedCost = lineCost(fixed);
|
|
395
|
-
const maxSummaryCharacters = Math.floor((target - offset - nativeAt(boundary)) * 4) - wrapperCharacters;
|
|
396
413
|
const maxBriefChars = Math.max(0, maxSummaryCharacters - fixedCost);
|
|
397
414
|
const compileInput = { messages: sourceRows.map(row => row.message), sourceIndices: sourceRows.map(row => row.index),
|
|
398
415
|
sourceEntryIds: sourceRows.map(row => row.id), sourceTimes: sourceRows.map(row => resolveSourceTime(byId.get(row.id))),
|
|
@@ -502,7 +519,12 @@ export function tuckObservedDraft(tuck, input, ctx, reserveTokens, measure, poli
|
|
|
502
519
|
return [{ role, missing, ends, counts, cost: lineCost([record]) }];
|
|
503
520
|
});
|
|
504
521
|
const baseCost = lineCost(offer.records) + lineCost(ledger), baseCount = offer.records.length + ledger.length;
|
|
522
|
+
const keptReadCost = lineCost(keptReads), keptReadIndices = new Set(keptReads.map(record => record.sourceIndex));
|
|
523
|
+
const lastKeptReadPosition = entries.findLastIndex(entry => keptReadIndices.has(indices.get(entry.id)));
|
|
505
524
|
const extensionPrice = (at) => {
|
|
525
|
+
// Fixed kept reads outrank this optional tail extension: it cannot move one out of the prefix or spend its allowance.
|
|
526
|
+
if (keptReads.length && (at <= lastKeptReadPosition || keptReadCost > Math.min(Math.floor(0.20 * maxSummaryCharactersAt(at)), 24000)))
|
|
527
|
+
return Infinity;
|
|
506
528
|
let cost = baseCost - (recordCosts[compiledBoundary] - recordCosts[at]);
|
|
507
529
|
let count = baseCount - (recordCounts[compiledBoundary] - recordCounts[at]);
|
|
508
530
|
for (const range of ranges) {
|
package/package.json
CHANGED
package/src/build-id.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "4031a9c8a1371d6ed9eb73970d3b1f676181d9065a344501750ef711a9aaba4a";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { isTextOnly, textOf } from "./tuck/core/content";
|
|
3
|
+
import { extractPath } from "./tuck/core/tool-args";
|
|
4
|
+
import type { TranscriptRecord } from "./tuck/core/transcript";
|
|
5
|
+
|
|
6
|
+
/** Whole successful text reads, newest result first. Mutations invalidate earlier calls even when they fail or have no result. */
|
|
7
|
+
export function keptReadCandidates(entries: readonly SessionEntry[], indices: ReadonlyMap<string, number>,
|
|
8
|
+
resolvable: (entry: SessionEntry) => boolean): TranscriptRecord[] {
|
|
9
|
+
const reads = new Map<string, { path: string; order: number }>(), mutations = new Map<string, number>();
|
|
10
|
+
let order = 0;
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
if (entry.type !== "message" || entry.message.role !== "assistant") continue;
|
|
13
|
+
for (const block of entry.message.content) {
|
|
14
|
+
if (block.type !== "toolCall" || !["read", "write", "edit"].includes(block.name) ||
|
|
15
|
+
!block.arguments || typeof block.arguments !== "object") continue;
|
|
16
|
+
const path = extractPath(block.arguments as Record<string, unknown>);
|
|
17
|
+
if (!path || /[\r\n]/u.test(path)) continue;
|
|
18
|
+
order++;
|
|
19
|
+
if (block.name === "read") reads.set(block.id, { path, order });
|
|
20
|
+
else mutations.set(path, order);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const seen = new Set<string>(), records: TranscriptRecord[] = [];
|
|
24
|
+
for (let at = entries.length - 1; at >= 0; at--) {
|
|
25
|
+
const entry = entries[at]!;
|
|
26
|
+
if (entry.type !== "message" || entry.message.role !== "toolResult" || entry.message.isError || !isTextOnly(entry.message.content)) continue;
|
|
27
|
+
const read = reads.get(entry.message.toolCallId), sourceIndex = indices.get(entry.id);
|
|
28
|
+
if (!read || seen.has(read.path) || (mutations.get(read.path) ?? -1) > read.order) continue;
|
|
29
|
+
const text = textOf(entry.message.content);
|
|
30
|
+
if (!text.length || sourceIndex === undefined || !resolvable(entry)) continue;
|
|
31
|
+
seen.add(read.path);
|
|
32
|
+
records.push({ kind: "section", title: "Kept-read", sourceIndex,
|
|
33
|
+
text: `read ${read.path} (as recorded at #${sourceIndex}; no write or edit recorded since):\n${text}` });
|
|
34
|
+
}
|
|
35
|
+
return records;
|
|
36
|
+
}
|
|
@@ -83,7 +83,7 @@ const LEGACY_RECEIPT_RANGE_NOTICE = RECEIPT_RANGE_NOTICE.replace("tuck_recall",
|
|
|
83
83
|
* or, with no role, of the tool history
|
|
84
84
|
* | role " omitted " count " #" index "-#" index ":" ... counted inclusive index range
|
|
85
85
|
* | role " omitted " count [ " " locator-time { " " locator-time } ] ":" ... omission of unselected text blocks
|
|
86
|
-
* | [ locator " " ] title ":" ... section (
|
|
86
|
+
* | [ locator " " ] title ":" ... section (Files, Actions, Kept-read)
|
|
87
87
|
* locator = "#" index the source's session-wide index, as tuck_recall {"index"} takes it
|
|
88
88
|
* locator-time = locator [ "@" time-value ] every locator of a record has a time, or none does
|
|
89
89
|
* role = "user" | "assistant" | "custom" | "toolResult" (omissions only)
|
package/src/tuck.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { carriedTailTokens, carriedTarget, conversationTokens } from "./budget";
|
|
|
7
7
|
import { omissionRecord, userPrefixRecords } from "./tuck/core/brief";
|
|
8
8
|
import { isTextOnly, textOf } from "./tuck/core/content";
|
|
9
9
|
import { MAX_ACTION_LINES, MAX_LEDGER_LINES, actionItems, actionRecords, ledgerItems, ledgerRecords } from "./ledger.js";
|
|
10
|
+
import { keptReadCandidates } from "./kept-reads.js";
|
|
10
11
|
import type { Message } from "@earendil-works/pi-ai";
|
|
11
12
|
import { convertToLlm, SessionManager, type ExtensionContext,
|
|
12
13
|
type SessionBeforeCompactEvent, type SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
@@ -362,9 +363,23 @@ export function tuckObservedDraft(tuck: Tuck, input: { branchEntries: SessionEnt
|
|
|
362
363
|
let { boundary, high: protectedView } = selected;
|
|
363
364
|
const sourceRows = rows.filter(row => row.position < boundary);
|
|
364
365
|
const lists = listsAt(boundary);
|
|
365
|
-
|
|
366
|
+
const maxSummaryCharactersAt = (at: number) => Math.floor((target - offset - nativeAt(at)) * 4) - wrapperCharacters;
|
|
367
|
+
const maxSummaryCharacters = maxSummaryCharactersAt(boundary);
|
|
368
|
+
let allowance = Math.min(Math.floor(0.20 * maxSummaryCharacters), 24000);
|
|
369
|
+
const keptReads: TranscriptRecord[] = [];
|
|
370
|
+
for (const record of keptReadCandidates(entries.slice(0, boundary), indices, entry => readable(entry) !== undefined)) {
|
|
371
|
+
const cost = lineCost([record]);
|
|
372
|
+
if (cost > allowance) continue;
|
|
373
|
+
keptReads.push(record); allowance -= cost;
|
|
374
|
+
if (keptReads.length === 4) break;
|
|
375
|
+
}
|
|
376
|
+
let ledger: TranscriptRecord[] = [...lists.records, ...keptReads];
|
|
366
377
|
// List caps are existing ranking policy; only the carried target is a
|
|
367
378
|
// spending limit. Candidate list sizes have fixed, cached line prices.
|
|
379
|
+
while (keptReads.length && price(frameLength(protectedView.cost + lineCost(ledger), protectedView.rows.length + ledger.length), boundary) > target) {
|
|
380
|
+
keptReads.pop();
|
|
381
|
+
ledger = [...lists.records, ...keptReads];
|
|
382
|
+
}
|
|
368
383
|
if (price(frameLength(protectedView.cost + lineCost(ledger), protectedView.rows.length + ledger.length), boundary) > target) {
|
|
369
384
|
ledger = [];
|
|
370
385
|
for (let keep = 0; keep <= Math.min(Math.max(MAX_LEDGER_LINES, MAX_ACTION_LINES), Math.max(lists.files.length, lists.actions.length)); keep++) {
|
|
@@ -377,7 +392,6 @@ export function tuckObservedDraft(tuck: Tuck, input: { branchEntries: SessionEnt
|
|
|
377
392
|
return row?.message.role === "user" && isTextOnly(row.message.content);
|
|
378
393
|
}));
|
|
379
394
|
const fixed = [...protectedView.kept, ...ledger], fixedCost = lineCost(fixed);
|
|
380
|
-
const maxSummaryCharacters = Math.floor((target - offset - nativeAt(boundary)) * 4) - wrapperCharacters;
|
|
381
395
|
const maxBriefChars = Math.max(0, maxSummaryCharacters - fixedCost);
|
|
382
396
|
const compileInput = { messages: sourceRows.map(row => row.message), sourceIndices: sourceRows.map(row => row.index),
|
|
383
397
|
sourceEntryIds: sourceRows.map(row => row.id), sourceTimes: sourceRows.map(row => resolveSourceTime(byId.get(row.id)!)),
|
|
@@ -472,7 +486,11 @@ export function tuckObservedDraft(tuck: Tuck, input: { branchEntries: SessionEnt
|
|
|
472
486
|
return [{ role, missing, ends, counts, cost: lineCost([record]) }];
|
|
473
487
|
});
|
|
474
488
|
const baseCost = lineCost(offer.records) + lineCost(ledger), baseCount = offer.records.length + ledger.length;
|
|
489
|
+
const keptReadCost = lineCost(keptReads), keptReadIndices = new Set(keptReads.map(record => record.sourceIndex));
|
|
490
|
+
const lastKeptReadPosition = entries.findLastIndex(entry => keptReadIndices.has(indices.get(entry.id)));
|
|
475
491
|
const extensionPrice = (at: number) => {
|
|
492
|
+
// Fixed kept reads outrank this optional tail extension: it cannot move one out of the prefix or spend its allowance.
|
|
493
|
+
if (keptReads.length && (at <= lastKeptReadPosition || keptReadCost > Math.min(Math.floor(0.20 * maxSummaryCharactersAt(at)), 24000))) return Infinity;
|
|
476
494
|
let cost = baseCost - (recordCosts[compiledBoundary]! - recordCosts[at]!);
|
|
477
495
|
let count = baseCount - (recordCounts[compiledBoundary]! - recordCounts[at]!);
|
|
478
496
|
for (const range of ranges) {
|