pi-condense 2.0.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 +73 -0
- package/LICENSE +22 -0
- package/PRUNING.md +1028 -0
- package/README.md +243 -0
- package/index.ts +858 -0
- package/package.json +56 -0
- package/src/batch-capture.ts +226 -0
- package/src/block-refs.test.ts +42 -0
- package/src/block-refs.ts +16 -0
- package/src/budget.test.ts +66 -0
- package/src/budget.ts +39 -0
- package/src/chain-compressor.test.ts +283 -0
- package/src/chain-compressor.ts +132 -0
- package/src/chain-detector.test.ts +302 -0
- package/src/chain-detector.ts +128 -0
- package/src/chain-range-prune.test.ts +522 -0
- package/src/chain-range-prune.ts +128 -0
- package/src/commands.test.ts +67 -0
- package/src/commands.ts +1207 -0
- package/src/config.ts +126 -0
- package/src/content-hash.ts +35 -0
- package/src/error-purge.test.ts +186 -0
- package/src/error-purge.ts +71 -0
- package/src/frontier.ts +62 -0
- package/src/indexer.ts +393 -0
- package/src/nested-placeholders.test.ts +82 -0
- package/src/nested-placeholders.ts +20 -0
- package/src/oversized-spill.integration.test.ts +73 -0
- package/src/protected.test.ts +62 -0
- package/src/protected.ts +51 -0
- package/src/pruner.test.ts +508 -0
- package/src/pruner.ts +156 -0
- package/src/query-tool.ts +78 -0
- package/src/range-compression.integration.test.ts +252 -0
- package/src/spill.test.ts +102 -0
- package/src/spill.ts +90 -0
- package/src/stats.test.ts +114 -0
- package/src/stats.ts +190 -0
- package/src/summarizer.test.ts +17 -0
- package/src/summarizer.ts +262 -0
- package/src/summary-refs.ts +61 -0
- package/src/thinking-strip.test.ts +175 -0
- package/src/thinking-strip.ts +42 -0
- package/src/tree-browser.ts +382 -0
- package/src/types.ts +764 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, it, expect } from "bun:test";
|
|
2
|
+
import { pruneStatusText, setPruneStatusWidget } from "./commands.js";
|
|
3
|
+
import type { ContextPruneConfig } from "./types.js";
|
|
4
|
+
|
|
5
|
+
const cfg = (enabled: boolean): ContextPruneConfig => ({ enabled } as ContextPruneConfig);
|
|
6
|
+
const cfgVisible = (enabled: boolean): ContextPruneConfig =>
|
|
7
|
+
({ enabled, showPruneStatusLine: true } as ContextPruneConfig);
|
|
8
|
+
|
|
9
|
+
function captureStatus(config: ContextPruneConfig, value?: Parameters<typeof setPruneStatusWidget>[2]): string | undefined {
|
|
10
|
+
let captured: string | undefined;
|
|
11
|
+
setPruneStatusWidget({ ui: { setStatus: (_id, text) => { captured = text; } } }, config, value);
|
|
12
|
+
return captured;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe("pruneStatusText", () => {
|
|
16
|
+
it("disabled config -> 'prune: OFF'", () => {
|
|
17
|
+
expect(pruneStatusText(cfg(false))).toBe("prune: OFF");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("enabled, no reclaim -> 'prune: ON'", () => {
|
|
21
|
+
expect(pruneStatusText(cfg(true))).toBe("prune: ON");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("enabled, undefined reclaim -> 'prune: ON'", () => {
|
|
25
|
+
expect(pruneStatusText(cfg(true), undefined)).toBe("prune: ON");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("enabled, beforeChars=0, afterChars=0 -> 'prune: ON' (guard divide-by-zero)", () => {
|
|
29
|
+
expect(pruneStatusText(cfg(true), { beforeChars: 0, afterChars: 0 })).toBe("prune: ON");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("enabled, {beforeChars:368000, afterChars:56000} -> ratio line", () => {
|
|
33
|
+
// beforeTok=92000 -> "92.0k", afterTok=14000 -> "14.0k", reduction=85%
|
|
34
|
+
expect(pruneStatusText(cfg(true), { beforeChars: 368000, afterChars: 56000 })).toBe(
|
|
35
|
+
"prune: ON \u00b7 92.0k->14.0k (-85%)",
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("enabled, no reduction (before==after) -> clamps to 0%", () => {
|
|
40
|
+
// beforeTok=25, afterTok=25
|
|
41
|
+
expect(pruneStatusText(cfg(true), { beforeChars: 100, afterChars: 100 })).toBe(
|
|
42
|
+
"prune: ON \u00b7 25->25 (-0%)",
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("enabled, expansion (afterChars > beforeChars) -> clamps to 0%", () => {
|
|
47
|
+
expect(pruneStatusText(cfg(true), { beforeChars: 100, afterChars: 150 })).toMatch(/\(-0%\)$/);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("setPruneStatusWidget", () => {
|
|
52
|
+
it("prefixes every rendered state with a single leading '\u2502' for load-order-independent isolation", () => {
|
|
53
|
+
expect(captureStatus(cfgVisible(false))).toBe("\u2502 prune: OFF");
|
|
54
|
+
expect(captureStatus(cfgVisible(true))).toBe("\u2502 prune: ON");
|
|
55
|
+
expect(captureStatus(cfgVisible(true), { beforeChars: 368000, afterChars: 56000 })).toBe(
|
|
56
|
+
"\u2502 prune: ON \u00b7 92.0k->14.0k (-85%)",
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("prefixes string progress values too", () => {
|
|
61
|
+
expect(captureStatus(cfgVisible(true), "prune: 3 pending")).toBe("\u2502 prune: 3 pending");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("clears (no wrap) when the status line is hidden", () => {
|
|
65
|
+
expect(captureStatus(cfg(true))).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
});
|