pi-codex-compaction 0.1.3 → 0.1.5
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 +12 -0
- package/README.md +16 -0
- package/extensions/index.ts +19 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ This project follows the spirit of [Keep a Changelog](https://keepachangelog.com
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.5] - 2026-09-17
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Persist the Codex compaction confirmation as a rendered, non-model session entry so Pi's post-compaction chat rebuild does not erase it.
|
|
14
|
+
|
|
15
|
+
## [0.1.4] - 2026-09-15
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Show `[compaction (codex)] Checkpoint saved.` in the TUI after a Codex checkpoint is saved, to distinguish it from standard Pi compaction.
|
|
20
|
+
|
|
9
21
|
## [0.1.3] - 2026-09-11
|
|
10
22
|
|
|
11
23
|
### Fixed
|
package/README.md
CHANGED
|
@@ -35,6 +35,13 @@ pi -e /path/to/pi-mono/packages/pi-codex-compaction
|
|
|
35
35
|
|
|
36
36
|
## Behavior
|
|
37
37
|
|
|
38
|
+
After a Codex checkpoint is saved, the TUI shows
|
|
39
|
+
`[compaction (codex)] Checkpoint saved.` Pi's built-in `[compaction]` heading
|
|
40
|
+
remains unchanged. The notice is stored as a TUI-only custom session entry, so it
|
|
41
|
+
survives the compaction chat rebuild and reload. It is not added to model context.
|
|
42
|
+
Standard Pi compaction does not create a Codex success notice.
|
|
43
|
+
Print, JSON, and RPC modes receive no extra notification.
|
|
44
|
+
|
|
38
45
|
When Pi starts compaction on a supported Codex model, the extension sends a streamed Responses request whose `input` contains only discardable history, any compatible prior checkpoint, and a `compaction_trigger` item. The normal request envelope is retained because Codex's compaction path is parity-tested against ordinary Responses requests; this includes the effective system prompt, active tool definitions, reasoning level, prompt-cache fields, and routing fields. The request uses the `remote_compaction_v2` beta feature, and the returned opaque checkpoint and bounded provider usage are stored in the Pi compaction entry. Later requests rehydrate the raw checkpoint only when the model, endpoint, account, and authentication mode match; other providers/models receive the bounded textual fallback instead.
|
|
39
46
|
|
|
40
47
|
Compaction uses the model active when Pi triggers it. If a session switches from a larger to a smaller model, the remote request is bounded against the new model's context window and tool outputs are reduced before sending. A previous opaque checkpoint is treated as incompatible after a model, endpoint, account, or authentication-mode switch; Pi's readable previous summary is sent instead. If the full request still cannot fit, the extension leaves compaction to Pi's normal implementation.
|
|
@@ -105,6 +112,11 @@ Costs follow Pi's catalog estimates. They are not a ChatGPT subscription bill.
|
|
|
105
112
|
|
|
106
113
|
### Reference and smoke test
|
|
107
114
|
|
|
115
|
+
The automated display smoke tests exercise Pi's actual compaction-end handler
|
|
116
|
+
and chat renderer for manual, threshold, and overflow compaction. They check
|
|
117
|
+
redraw, reload, standard compaction, and exclusion from subsequent model requests.
|
|
118
|
+
Only provider responses and terminal I/O are replaced with local fixtures.
|
|
119
|
+
|
|
108
120
|
Behavior was checked against `openai/codex` commit
|
|
109
121
|
`654b0a77d0d2f81aa21f61caf7af4be88fe550bb` (2026-09-11), notably
|
|
110
122
|
`core/src/compact_remote_v2{,_attempt}.rs`. No Codex code was copied.
|
|
@@ -113,6 +125,10 @@ API. Async tools and mid-turn steering require upstream Pi support.
|
|
|
113
125
|
|
|
114
126
|
For a small live test, load this package and select `openai-codex/gpt-6-astra`.
|
|
115
127
|
Send two short messages, run `/compact`, then ask about the first message.
|
|
128
|
+
Confirm `[compaction (codex)] Checkpoint saved.` remains visible after the
|
|
129
|
+
compaction finishes and after `/reload`. Then run
|
|
130
|
+
`/compact Focus on recent work` and confirm the standard-compaction warning
|
|
131
|
+
appears without a new Codex success notice.
|
|
116
132
|
Repeat with `/fast on` and `pi-codex-tools` loaded. Check that compaction succeeds,
|
|
117
133
|
the continuation retains context, and session usage includes compaction tokens.
|
|
118
134
|
Use only a temporary file if you test `apply_patch`. Do not generate images.
|
package/extensions/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
ExtensionHandler,
|
|
4
4
|
SessionBeforeCompactEvent,
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
6
7
|
import { BETA_FEATURE, getCodexAccountFingerprint } from "../src/codex-wire.js";
|
|
7
8
|
import { reportInstallTelemetry } from "../src/install-telemetry.js";
|
|
8
9
|
import {
|
|
@@ -26,9 +27,15 @@ const FALLBACK_MESSAGES: Record<CompactionFallback["reason"], string> = {
|
|
|
26
27
|
"remote-failed": "the remote request failed",
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
const COMPACTION_SAVED_ENTRY = "pi-codex-compaction:saved:v1";
|
|
31
|
+
|
|
29
32
|
export default function piCodexCompaction(pi: ExtensionAPI): void {
|
|
30
33
|
reportInstallTelemetry();
|
|
31
34
|
|
|
35
|
+
pi.registerEntryRenderer(COMPACTION_SAVED_ENTRY, (_entry, _options, theme) =>
|
|
36
|
+
new Text(theme.fg("dim", "[compaction (codex)] Checkpoint saved."), 1, 0),
|
|
37
|
+
);
|
|
38
|
+
|
|
32
39
|
const onBeforeCompact: ExtensionHandler<SessionBeforeCompactEvent, { compaction?: NonNullable<Awaited<ReturnType<typeof createRemoteCompaction>>> }> = async (event, ctx) => {
|
|
33
40
|
if (!supportsRemoteCompaction(ctx.model)) return undefined;
|
|
34
41
|
|
|
@@ -84,6 +91,18 @@ export default function piCodexCompaction(pi: ExtensionAPI): void {
|
|
|
84
91
|
};
|
|
85
92
|
pi.on("session_before_compact", onBeforeCompact);
|
|
86
93
|
|
|
94
|
+
pi.on("session_compact", (event, ctx) => {
|
|
95
|
+
if (ctx.mode !== "tui" || !ctx.hasUI || !event.fromExtension) return;
|
|
96
|
+
if (!findActiveRemoteCompaction([event.compactionEntry])) return;
|
|
97
|
+
try {
|
|
98
|
+
// Pi rebuilds chat after session_compact, removing transient notifications.
|
|
99
|
+
// A rendered custom entry survives that rebuild without entering LLM context.
|
|
100
|
+
pi.appendEntry(COMPACTION_SAVED_ENTRY, { version: 1 });
|
|
101
|
+
} catch {
|
|
102
|
+
// Display failures must not affect a saved checkpoint or continuation.
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
87
106
|
pi.on("before_provider_headers", (event, ctx) => {
|
|
88
107
|
if (!supportsRemoteCompaction(ctx.model)) return;
|
|
89
108
|
const existing = event.headers["x-codex-beta-features"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-codex-compaction",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Use OpenAI Codex RemoteCompactionV2 for supported Pi sessions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,11 +49,13 @@
|
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@earendil-works/pi-ai": "*",
|
|
52
|
-
"@earendil-works/pi-coding-agent": "*"
|
|
52
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
53
|
+
"@earendil-works/pi-tui": "*"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@earendil-works/pi-ai": "^0.85.1",
|
|
56
57
|
"@earendil-works/pi-coding-agent": "^0.85.1",
|
|
58
|
+
"@earendil-works/pi-tui": "^0.85.1",
|
|
57
59
|
"@types/node": "^26.2.0",
|
|
58
60
|
"tsx": "^4.23.5",
|
|
59
61
|
"typescript": "^7.0.2"
|