pi-openai-codex-compat 0.0.10-alpha.1 → 0.0.10-alpha.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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Added
6
+
7
+ - Show the current Pi session ID on the compatibility footer's first line.
8
+ - Add default-off, failure-only `apply_patch` diagnostics capture with
9
+ pre-execution text snapshots and binary metadata for every instruction in a
10
+ failed patch, runtime and filesystem identity metadata, nested error causes,
11
+ patch outcomes, and Pi/provider trace identifiers linked from tool-result
12
+ details.
13
+
5
14
  ### Fixed
6
15
 
7
16
  - Preserve regular-file permission modes across sequential `apply_patch`
@@ -32,6 +41,9 @@
32
41
 
33
42
  ### Changed
34
43
 
44
+ - Align deferred tool loading with Pi 0.84.3, preferring message-anchored
45
+ additional tools on capable Codex models while retaining tool-search and
46
+ top-level fallbacks.
35
47
  - Simplify `apply_patch` for its queued single-writer operating model: retain
36
48
  Pi's mutation queue, remove the extension-local alias queue and
37
49
  preflight-to-execution drift machinery, use direct writes for in-place text
package/README.md CHANGED
@@ -7,13 +7,14 @@ OpenAI Codex compatibility for [Pi](https://github.com/earendil-works/pi-mono),
7
7
  - **Request-level fast mode**: keeps the canonical `openai-codex` provider id and models selected while adding `service_tier: "priority"` at the request boundary.
8
8
  - **Native compaction**: uses Codex `remote_compaction_v2` for `/compact`, Pi threshold compaction, context-overflow recovery, and an optional percentage threshold.
9
9
  - **Codex `apply_patch`**: provides an optional patch tool with the Codex grammar, parser, fuzzy matcher, overwrite semantics, filesystem behavior, model-facing result format, structured history, and diff-oriented TUI rendering. Pi sends it as an OpenAI custom grammar tool when the model supports that protocol and as a normal function tool otherwise.
10
+ - **Opt-in patch diagnostics**: records failed `apply_patch` requests with pre-execution text snapshots or binary metadata for every instruction, outcomes, and Pi/Codex identifiers.
10
11
  - **Standalone image generation**: exposes Pi's dotted `image_gen.imagegen` tool as a native Responses namespace and executes generation or edits through the Codex Images endpoints.
11
12
  - **Standalone web search**: exposes Pi's dotted `web.run` tool as a native Responses namespace and executes search and browsing through Codex `alpha/search`.
12
13
  - **Dedicated Codex tool UI**: renders `apply_patch`, `image_gen.imagegen`, and `web.run` on a shared configurable surface with compact summaries and `Ctrl+O` expansion.
13
14
  - **Hosted web-search fallback**: injects native `web_search` only when `web.run` is inactive, with cached, indexed, or live modes.
14
15
  - **Native request controls**: configures Responses API text verbosity, reasoning summaries, and GPT-5.6 standard/pro reasoning mode.
15
16
  - **Session-local settings pane**: `/codex-settings` changes every compatibility setting for the current session; `Enter` persists and closes, `Escape` discards unsaved changes and closes, and `Ctrl+S` persists without closing.
16
- - **Compact footer indicators**: non-default Codex request modes are appended to the model side of Pi's normal second footer line.
17
+ - **Session-aware footer**: shows the current Pi session ID on the first line and appends non-default Codex request modes to the model side of Pi's normal second line.
17
18
 
18
19
  Pi provides the Codex OAuth flow and model catalog. At session start, this package overrides the built-in `openai-codex` runtime under the same provider id so ordinary responses and remote compaction share one transport, parser, native-history store, and sticky WebSocket session.
19
20
 
@@ -43,6 +44,7 @@ The compatibility baseline is official Codex CLI `0.149.0`, released August 20,
43
44
  | Hosted web search | Disabled by default; when enabled, injected only for ordinary Responses while `web.run` is inactive. Responses Lite omits hosted tools. | Omitted for `gpt-5.6-sol` while standalone `web.run` is available; otherwise defaults to cached mode when hosted search is supported. | `webRun` and `webSearch`: `disabled`, `cached`, `indexed`, or `live`. |
44
45
  | Coding mutation tools | Enables `apply_patch` and suppresses Pi's active `edit` and `write` tools. | Chooses its tool surface from model metadata and runtime capabilities; there are no Pi `edit` or `write` tools to suppress. | `applyPatch`: boolean. |
45
46
  | `apply_patch` debug output | Disabled; collapsed results show the normal visual summary and instruction rows. | Not applicable to Pi's tool-result renderer. | `applyPatchDebug`: boolean. |
47
+ | `apply_patch` diagnostics capture | Disabled; no separate request or filesystem snapshot artifacts are retained. | Codex owns its rollout diagnostics rather than writing this package's artifact format. | `applyPatchDiagnostics`: boolean. |
46
48
  | Codex tool background | Uses a subtle theme-derived surface for extension-owned Codex tools. | Uses Codex's own TUI activity cells rather than Pi tool rows. | `toolBackground`: `subtle`, `status`, or `none`. |
47
49
  | Auto-compaction trigger | Relies on Pi's reserve-token threshold unless a percentage is configured. | Tracks Codex's model/token-budget state before and between sampling steps. | `autoCompactAtPercent`: percentage or unset. Mid-response percentage boundaries use Pi's bounded compact-and-continue lifecycle, so Pi auto-compaction must remain enabled. |
48
50
  | Fast mode | Uses the normal tier. | Uses the configured Codex service tier. | `fastMode`: boolean; `true` requests the priority tier. |
@@ -165,7 +167,7 @@ A trusted project can override it at:
165
167
 
166
168
  Each session inherits the effective file-backed settings. Open `/codex-settings` to make immediate session-local changes. Press `Enter` to persist and close, `Escape` to discard unsaved changes and close, or `Ctrl+S` to persist without closing. The global file is the normal save target, while an existing trusted project override remains the target for that project. After `Ctrl+S`, later unsaved changes can still be discarded back to the values from that save.
167
169
 
168
- The effective settings are printed once when a TUI session starts. The footer shows `fast` and `pro` only when enabled, and shows text verbosity or reasoning summary only when they differ from their defaults.
170
+ The effective settings are printed once when a TUI session starts. The footer shows the current Pi session ID alongside the working directory and optional session name. It shows `fast` and `pro` only when enabled, and shows text verbosity or reasoning summary only when they differ from their defaults.
169
171
 
170
172
  Example:
171
173
 
@@ -176,6 +178,7 @@ Example:
176
178
  "toolBackground": "subtle",
177
179
  "applyPatch": true,
178
180
  "applyPatchDebug": false,
181
+ "applyPatchDiagnostics": false,
179
182
  "imageGeneration": true,
180
183
  "imageDetail": "auto",
181
184
  "webRun": false,
@@ -189,41 +192,43 @@ Example:
189
192
 
190
193
  Defaults:
191
194
 
192
- | Setting | Values | Default | Behavior |
193
- | ---------------------- | ---------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194
- | `fastMode` | boolean | `false` | Adds `service_tier: "priority"` to requests while retaining the current `openai-codex` provider and model. |
195
- | `responsesLite` | boolean | `false` | Uses Codex's Responses Lite input envelope on supported GPT-5.6 models when enabled. By default, those models use ordinary Responses instructions and tools. |
196
- | `toolBackground` | `subtle`, `status`, `none` | `subtle` | Controls the shared self-rendered background for `apply_patch`, `image_gen.imagegen`, and `web.run`. `status` uses Pi's pending/success/error backgrounds; `none` keeps the custom layout transparent. |
197
- | `applyPatch` | boolean | `true` | On selected `openai-codex` models, uses the extension's `apply_patch` tool instead of Pi's active `edit` and `write` tools. Other providers always use their normal Pi tool set. |
198
- | `applyPatchDebug` | boolean | `false` | Shows the exact model-facing tool result while a completed `apply_patch` result is collapsed. Expanded results continue to show the normal visual summary and complete diffs. |
199
- | `imageGeneration` | boolean | `true` | Enables the extension-owned `image_gen.imagegen` tool on selected `openai-codex` models. |
200
- | `imageDetail` | `auto`, `low`, `high`, `original` | `auto` | Sets `input_image.detail` when an image tool result is sent back to the model. It does not change `gpt-image-2` generation quality. |
201
- | `webRun` | boolean | `false` | Enables the extension-owned `web.run` tool on selected `openai-codex` models. When active, it replaces hosted `web_search` in the Responses tool list. |
202
- | `autoCompactAtPercent` | number greater than `0` and at most `100`, or `null` | unset | Adds provider-boundary compaction independently of Pi's normal reserve-token threshold. Mid-response boundaries require Pi auto-compaction. A project value of `null` disables a global percentage threshold. |
203
- | `webSearch` | `disabled`, `cached`, `indexed`, `live` | `disabled` | Controls hosted search and standalone-search external access. `disabled` removes hosted search but leaves an independently enabled `web.run` in cached-only mode; `indexed` prefers indexed content; `live` permits live external access. |
204
- | `textVerbosity` | `low`, `medium`, `high` | `low` | Sets Responses API `text.verbosity`. |
205
- | `reasoningSummary` | `auto`, `concise`, `detailed`, `off` | `auto` | Sets `reasoning.summary` when reasoning is enabled; `off` omits the summary parameter. |
206
- | `reasoningMode` | `standard`, `pro` | `standard` | Controls GPT-5.6 execution mode independently of Pi's reasoning-effort control. The default omits `reasoning.mode`; `pro` sends `reasoning.mode: "pro"`. |
195
+ | Setting | Values | Default | Behavior |
196
+ | ----------------------- | ---------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
197
+ | `fastMode` | boolean | `false` | Adds `service_tier: "priority"` to requests while retaining the current `openai-codex` provider and model. |
198
+ | `responsesLite` | boolean | `false` | Uses Codex's Responses Lite input envelope on supported GPT-5.6 models when enabled. By default, those models use ordinary Responses instructions and tools. |
199
+ | `toolBackground` | `subtle`, `status`, `none` | `subtle` | Controls the shared self-rendered background for `apply_patch`, `image_gen.imagegen`, and `web.run`. `status` uses Pi's pending/success/error backgrounds; `none` keeps the custom layout transparent. |
200
+ | `applyPatch` | boolean | `true` | On selected `openai-codex` models, uses the extension's `apply_patch` tool instead of Pi's active `edit` and `write` tools. Other providers always use their normal Pi tool set. |
201
+ | `applyPatchDebug` | boolean | `false` | Shows the exact model-facing tool result while a completed `apply_patch` result is collapsed. Expanded results continue to show the normal visual summary and complete diffs. |
202
+ | `applyPatchDiagnostics` | boolean | `false` | Persists failed patch requests with pre-execution text snapshots or binary metadata for every instruction, outcomes, and trace identifiers. See [`apply_patch`](#apply_patch) for storage and sensitivity details. |
203
+ | `imageGeneration` | boolean | `true` | Enables the extension-owned `image_gen.imagegen` tool on selected `openai-codex` models. |
204
+ | `imageDetail` | `auto`, `low`, `high`, `original` | `auto` | Sets `input_image.detail` when an image tool result is sent back to the model. It does not change `gpt-image-2` generation quality. |
205
+ | `webRun` | boolean | `false` | Enables the extension-owned `web.run` tool on selected `openai-codex` models. When active, it replaces hosted `web_search` in the Responses tool list. |
206
+ | `autoCompactAtPercent` | number greater than `0` and at most `100`, or `null` | unset | Adds provider-boundary compaction independently of Pi's normal reserve-token threshold. Mid-response boundaries require Pi auto-compaction. A project value of `null` disables a global percentage threshold. |
207
+ | `webSearch` | `disabled`, `cached`, `indexed`, `live` | `disabled` | Controls hosted search and standalone-search external access. `disabled` removes hosted search but leaves an independently enabled `web.run` in cached-only mode; `indexed` prefers indexed content; `live` permits live external access. |
208
+ | `textVerbosity` | `low`, `medium`, `high` | `low` | Sets Responses API `text.verbosity`. |
209
+ | `reasoningSummary` | `auto`, `concise`, `detailed`, `off` | `auto` | Sets `reasoning.summary` when reasoning is enabled; `off` omits the summary parameter. |
210
+ | `reasoningMode` | `standard`, `pro` | `standard` | Controls GPT-5.6 execution mode independently of Pi's reasoning-effort control. The default omits `reasoning.mode`; `pro` sends `reasoning.mode: "pro"`. |
207
211
 
208
212
  Invalid JSON setting values are ignored and invalid JSON does not prevent Pi from starting. The settings pane never writes on ordinary changes, refuses to overwrite invalid JSON when `Enter` or `Ctrl+S` attempts to save, and retains unknown keys when saving. Project configuration is read only when the project is trusted.
209
213
 
210
214
  Every setting can also be overridden for one Pi process with an environment variable:
211
215
 
212
- | Setting | Environment variable |
213
- | ---------------------- | ------------------------------------------------ |
214
- | `fastMode` | `PI_OPENAI_CODEX_COMPAT_FAST_MODE` |
215
- | `responsesLite` | `PI_OPENAI_CODEX_COMPAT_RESPONSES_LITE` |
216
- | `toolBackground` | `PI_OPENAI_CODEX_COMPAT_TOOL_BACKGROUND` |
217
- | `applyPatch` | `PI_OPENAI_CODEX_COMPAT_APPLY_PATCH` |
218
- | `applyPatchDebug` | `PI_OPENAI_CODEX_COMPAT_APPLY_PATCH_DEBUG` |
219
- | `imageGeneration` | `PI_OPENAI_CODEX_COMPAT_IMAGE_GENERATION` |
220
- | `imageDetail` | `PI_OPENAI_CODEX_COMPAT_IMAGE_DETAIL` |
221
- | `webRun` | `PI_OPENAI_CODEX_COMPAT_WEB_RUN` |
222
- | `autoCompactAtPercent` | `PI_OPENAI_CODEX_COMPAT_AUTO_COMPACT_AT_PERCENT` |
223
- | `webSearch` | `PI_OPENAI_CODEX_COMPAT_WEB_SEARCH_MODE` |
224
- | `textVerbosity` | `PI_OPENAI_CODEX_COMPAT_TEXT_VERBOSITY` |
225
- | `reasoningSummary` | `PI_OPENAI_CODEX_COMPAT_REASONING_SUMMARY` |
226
- | `reasoningMode` | `PI_OPENAI_CODEX_COMPAT_REASONING_MODE` |
216
+ | Setting | Environment variable |
217
+ | ----------------------- | ------------------------------------------------ |
218
+ | `fastMode` | `PI_OPENAI_CODEX_COMPAT_FAST_MODE` |
219
+ | `responsesLite` | `PI_OPENAI_CODEX_COMPAT_RESPONSES_LITE` |
220
+ | `toolBackground` | `PI_OPENAI_CODEX_COMPAT_TOOL_BACKGROUND` |
221
+ | `applyPatch` | `PI_OPENAI_CODEX_COMPAT_APPLY_PATCH` |
222
+ | `applyPatchDebug` | `PI_OPENAI_CODEX_COMPAT_APPLY_PATCH_DEBUG` |
223
+ | `applyPatchDiagnostics` | `PI_OPENAI_CODEX_COMPAT_APPLY_PATCH_DIAGNOSTICS` |
224
+ | `imageGeneration` | `PI_OPENAI_CODEX_COMPAT_IMAGE_GENERATION` |
225
+ | `imageDetail` | `PI_OPENAI_CODEX_COMPAT_IMAGE_DETAIL` |
226
+ | `webRun` | `PI_OPENAI_CODEX_COMPAT_WEB_RUN` |
227
+ | `autoCompactAtPercent` | `PI_OPENAI_CODEX_COMPAT_AUTO_COMPACT_AT_PERCENT` |
228
+ | `webSearch` | `PI_OPENAI_CODEX_COMPAT_WEB_SEARCH_MODE` |
229
+ | `textVerbosity` | `PI_OPENAI_CODEX_COMPAT_TEXT_VERBOSITY` |
230
+ | `reasoningSummary` | `PI_OPENAI_CODEX_COMPAT_REASONING_SUMMARY` |
231
+ | `reasoningMode` | `PI_OPENAI_CODEX_COMPAT_REASONING_MODE` |
227
232
 
228
233
  Environment variables have the highest precedence: defaults < global JSON < trusted-project JSON < environment. Boolean values accept `true`/`false`, `1`/`0`, `on`/`off`, or `enabled`/`disabled`. Other settings use the values in the defaults table; `PI_OPENAI_CODEX_COMPAT_AUTO_COMPACT_AT_PERCENT=off` and `PI_OPENAI_CODEX_COMPAT_AUTO_COMPACT_AT_PERCENT=default` explicitly select Pi's default compaction lifecycle.
229
234
 
@@ -318,6 +323,47 @@ Compatibility behavior:
318
323
  - With `applyPatchDebug` enabled, the tool title becomes `apply_patch (debug)` and a completed collapsed result shows the exact text returned to the model without an extra renderer-only heading; expanding it with `Ctrl+O` still shows the normal visual summary and complete diffs.
319
324
  - Failed instruction feedback colocates its error, completed effects, and final path states without repeating patch text or using speculative language. Matching failures report the original context or expected-lines mismatch.
320
325
 
326
+ With `applyPatchDiagnostics` enabled, the extension prepares pre-execution
327
+ snapshots in memory for each invocation. A successful invocation discards that
328
+ prepared data and writes no diagnostic artifacts or tool-result references. A
329
+ failed invocation writes paired JSON artifacts under:
330
+
331
+ ```text
332
+ ~/.pi/agent/openai-codex-compat-apply-patch-diagnostics/<session-id>/
333
+ ```
334
+
335
+ The active Pi agent directory replaces `~/.pi/agent` when configured
336
+ differently. The request artifact contains the raw patch, parsed instructions
337
+ (or parse failure), pre-execution snapshots for paths referenced by every
338
+ instruction in the failed patch, and available session, assistant, response,
339
+ turn, transport-request, and tool-call identifiers. It also records the
340
+ compatibility-package, Pi, Node.js, operating-system, and architecture versions.
341
+ Process identity, working directory, and umask are included when available.
342
+ Each file and parent-directory snapshot includes mode, size, modification time,
343
+ device, inode, link count, user ID, and group ID so hard-link, alias,
344
+ cross-filesystem, and permission failures remain traceable. Parent metadata is
345
+ collected from each referenced path through the filesystem root. Malformed
346
+ patches retain snapshots for every instruction recognized by the fallback
347
+ scanner.
348
+
349
+ Valid UTF-8 regular-file content is stored as text with its byte length and
350
+ SHA-256. Binary content is not copied; its snapshot contains only the byte
351
+ length and SHA-256. Symlink snapshots retain the raw target and either readable
352
+ UTF-8 target content or binary target metadata. The result artifact records the
353
+ failed outcome, structured tool details, and the error chain up to eight causes,
354
+ including available filesystem codes, operation names, source paths, and
355
+ destination paths. Those details also retain the diagnostic record ID and both
356
+ artifact paths so the invocation can be located from Pi session history.
357
+
358
+ These artifacts can contain sensitive source code, ownership and filesystem
359
+ identity metadata, absolute paths, patches, and request identifiers. Capture is
360
+ disabled by default.
361
+ Directories are restricted to mode `0700`, files to `0600`, and records are not
362
+ automatically pruned; delete them manually when they are no longer needed. If
363
+ either artifact cannot be written after a patch failure, the diagnostic error
364
+ is reported to stderr without replacing or changing the original patch
365
+ failure.
366
+
321
367
  Filesystem behavior:
322
368
 
323
369
  - Relative paths resolve from Pi's current working directory; absolute paths and `..` traversal are honored.