A pi extension package that exposes the upstream Codex apply_patch WASM binary as an apply_patch tool, with Codex-style patch summaries and diff previews in the TUI.
Local path:
pi install /absolute/path/to/pi-codex-apply-patch-wasm
pi install ./.pi/extensions/apply-patchGitHub:
pi install git:github.com/trotsky1997/pi-codex-apply-patch-wasmProject-local install:
pi install -l ./.pi/extensions/apply-patchAfter install, restart pi or use /reload in an active session.
apply_patchtool compatible with the Codex patch envelope- Codex-style path preparation before execution
- bundled
apply_patch.wasmfor standalone installs - compact patch summaries in collapsed tool rows
- expanded diff previews for multi-file and code patches
/apply-patch-selftestcommand to verify the WASM runner locally
The extension now mirrors the upstream Codex path flow more closely before handing work to the bundled WASM runner:
- relative patch paths are kept as-is and resolved by the runner against the active
cwd - missing
*** Begin Patch/*** End Patchlines are safely restored when the patch body is otherwise valid - footer lines such as
*** End Patchare normalized, and trailing chatty text after the footer is ignored - absolute paths that stay inside the current
cwdare rewritten back to relative paths before execution - absolute paths outside the current
cwdare rejected with a runner-specific error because this standalone WASM setup only preopens the current working directory *** End of Filemarkers are preserved when a patch needs to be rewritten
This means the tool behaves closer to Codex for path normalization, while still making the WASM runner's sandbox limits explicit.
The package prefers the bundled vendor/apply_patch.wasm. If that file is missing, it falls back to a local workspace build at:
codex/codex-rs/target/wasm32-wasip1/release/apply_patch.wasmcodex/codex-rs/target/wasm32-wasip1/debug/apply_patch.wasm
To refresh the bundled binary from this workspace build:
cp codex/codex-rs/target/wasm32-wasip1/debug/apply_patch.wasm .pi/extensions/apply-patch/vendor/apply_patch.wasmOr use the bundled rebuild script and point it at an existing codex/codex-rs checkout:
./scripts/rebuild-codex-apply-patch-wasm.sh \
--codex-rs-dir /path/to/codex/codex-rs \
--wasi-sdk-dir /path/to/wasi-sdk-32.0-x86_64-linuxRun the focused path-handling smoke tests with:
npm test