Patches to pi
PizzaPi carries a small set of Bun patches for upstream pi packages. The source of truth is:
patches/README.mdpatches/@earendil-works%2F*.patch- root
package.jsonpatchedDependencies packages/cli/src/patches.test.ts
Bun applies these patches automatically from patchedDependencies on every bun install. There is no postinstall script for pi patches.
Current patched packages
Section titled “Current patched packages”| Package | Patch file | Why it exists |
|---|---|---|
@earendil-works/pi-agent-core@1.0.0 |
patches/@earendil-works%2Fpi-agent-core@1.0.0.patch |
Refreshes the agent loop’s latest system prompt and tool list before each assistant response. This lets search_tools and other dynamic tool/prompt changes take effect in the next assistant response instead of the next user turn. |
@earendil-works/pi-ai@1.0.0 |
patches/@earendil-works%2Fpi-ai@1.0.0.patch |
Adds Anthropic and OpenAI Codex hosted web-search support, preserves hosted search blocks in transcripts, retries transient JSON parse failures, and falls back to Claude Code Anthropic OAuth credentials during refresh. |
@earendil-works/pi-coding-agent@1.0.0 |
patches/@earendil-works%2Fpi-coding-agent@1.0.0.patch |
Makes upstream pi behave as the PizzaPi wrapper: .pizzapi config directory, flat agent directory, PizzaPi changelog path, quiet startup by default, pizza update --extensions text, package/config command re-exports, inline /skill: expansion, ollama-cloud default model, OpenAI published context windows, removal of pi version-check UI, and a TUI live-bash-card reattach fix. |
@earendil-works/pi-tui@1.0.0 |
patches/@earendil-works%2Fpi-tui@1.0.0.patch |
Preserves Windows console lifecycle hooks and the globalThis.__PI_WINDOWS_CONSOLE_CAPS__ compatibility signal. The current lifecycle reports unknown capabilities; it does not itself enable VT or change console code pages. |
package.json also contains a non-pi patch for pptx-browser@4.1.5; this page tracks only the upstream pi patch set.
Patch application
Section titled “Patch application”package.json maps exact package versions to patch files:
{ "patchedDependencies": { "@earendil-works/pi-coding-agent@1.0.0": "patches/@earendil-works%2Fpi-coding-agent@1.0.0.patch", "@earendil-works/pi-agent-core@1.0.0": "patches/@earendil-works%2Fpi-agent-core@1.0.0.patch", "@earendil-works/pi-ai@1.0.0": "patches/@earendil-works%2Fpi-ai@1.0.0.patch", "@earendil-works/pi-tui@1.0.0": "patches/@earendil-works%2Fpi-tui@1.0.0.patch" }}When the dependency version changes, the key and patch filename must change together. If either side is stale, Bun will not apply the intended patch to the new package version. Root overrides also pin the Pi suite: upstream caret dependencies must not resolve a second, unpatched copy. The patch tests check that Pi and PizzaPi resolve the same runtime packages.
If an existing install still resolves older transitive packages after changing overrides, run bun install --frozen-lockfile --force to rebuild Bun’s isolated dependency links.
Regenerating patches on a pi bump
Section titled “Regenerating patches on a pi bump”Use a tarball-diff port for each patched package:
- Update the pi package versions in every relevant
package.json. - Fetch clean upstream package tarballs for the old and new versions.
- Extract the old clean tarball and the currently patched old package, then inspect the old patch as a tarball diff.
- Extract the new clean tarball, reapply each PizzaPi change by hand at the new upstream anchors, and keep only changes that are still needed.
- Generate a unified diff with paths rooted at the package root and
a//b/prefixes, matching the existingpatches/*.patchformat. - Save it as
patches/@earendil-works%2F<package>@<new-version>.patch. - Update root
package.jsonpatchedDependenciesto point at the new filename. - Run
bun installfrom the repo root so Bun applies the new patch set. - Run the patch guard tests.
The helper under packages/cli/scripts/diff-pi-pizza.ts is not a patch generator. It compares the live provider request shape for vanilla pi vs pizza and is useful when validating prompt/tool differences.
Tests that pin the patches
Section titled “Tests that pin the patches”Run the patch guard test after every upstream pi bump:
cd packages/clibun test src/patches.test.tspackages/cli/src/patches.test.ts checks both source markers and runtime behavior:
| Area | What the test pins |
|---|---|
pi-agent-core |
Dynamic tool/prompt refresh before each assistant response, including a regression where search_tools loads a deferred tool and the next assistant response can call it. |
pi-ai |
Anthropic web-search tool injection, server-tool block streaming/round-trip handling, retryable JSON parse errors, Claude Code credential fallback, and absence of retired ollama-cloud hunks. |
pi-coding-agent |
.pizzapi paths, flat agent directory, changelog override, removed pi version check, PizzaPi package-update command text, quiet startup default, OpenAI context-window override, inline skill expansion, package/config command exports, and removed legacy ExtensionAPI control-plane hunks. |
pi-tui |
Windows console lifecycle wiring and safe no-op behavior off Windows. |
If a test fails after a dependency bump, recreate the matching patch instead of changing PizzaPi source to depend on an unapplied upstream modification.
Pi 1.0’s codemode also needs its worker and QuickJS WASM embedded in compiled binaries. After building a native macOS/Linux target, run this offline smoke check from the repository root (Python 3 required):
python3 packages/cli/scripts/smoke-codemode-binary.py packages/cli/dist/binaries/macos-arm64/pizza-macos-arm64Use the matching native binary path on Linux. The check uses a temporary home and a synthetic provider to run return 6 * 7; through the actual compiled codemode tool. It makes no model-provider calls. It terminates the PTY after verifying the result; it does not test graceful interactive shutdown.