@paulpham157/apply-patch

Universal apply_patch for every model on Pi, not just gpt-*: GPT, Claude, Gemini, DeepSeek, Kimi, GLM, Qwen, and more. One patch tool across providers with grammar support and JSON fallback.

Packages

Package details

extension

Install @paulpham157/apply-patch from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@paulpham157/apply-patch
Package
@paulpham157/apply-patch
Version
0.3.0
Published
Sep 14, 2026
Downloads
125/mo · 125/wk
Author
paulpham157
License
MIT
Types
extension
Size
607.8 KB
Dependencies
1 dependency · 5 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

apply-patch

One apply_patch for every model on Pi: GPT, Claude, Gemini, DeepSeek, Kimi, GLM, Qwen, and others. The extension replaces edit/write, choosing the grammar or JSON function tool based on provider capability.

Repo: https://github.com/paulpham157/pi-apply-patch

Why apply-patch

Native edit fails when the exact match string is off, while apply_patch applies the same intent with context matching:

Install

Requires Pi >=0.85.1 and Node >=22.

pi install npm:@paulpham157/apply-patch

If Pi is running, use /reload. The extension activates automatically and keeps working across model switches.

Features

  • Create, edit, delete, and move files with a single patch tool.
  • Confines paths to cwd; rejects symlinks, existing destinations on create/move, and overlapping path operations.
  • Validates the full patch before writing; no full rollback on filesystem write errors.

Read a file before editing it; on patch failure, re-read the relevant region and generate a new patch. Patch usage quality varies by model. bash still works and is not subject to this tool's path limits.

Contributing and support

Read CONTRIBUTION.md, AGENTS.md, and run the required tests before opening a PR. See live testing with Pi and releasing.

Issues? Open one here with the Pi version, provider/model, and reproduction steps. Do not attach API keys.

Quick create: Bug report · Model/provider issue · Feature request.

Forked from code-yeongyu/pi-apply-patch: at the time, upstream had no updates for ~2 months and only supported gpt-* models, so this fork was created for personal use. MIT license.