Observed since 21 Oct, 09:03 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xkobold/pi-patch
patch-package clone for pi - fuzzy matching and agent integration
A full patch-package clone for pi. Create and apply patches to node_modules packages with fuzzy matching support.
🎯 Goal: Drop-in replacement for
patch-packagethat works inside pi with agent integration.
# 1. Edit a dependency
$EDITOR node_modules/express/index.js
# 2. Create patch (exactly like patch-package)
/patch-package express
# 3. Commit patches
git add .patches/
git commit -m "fix: patch express"
Patches auto-apply when pi starts.
| Command | Description |
|---|---|
/patch-package <package> | Create patch from modified package |
/patch-package | Create patches for ALL modified packages |
/patch or /patch apply | Apply all patches |
/patch dry-run | Test patches without applying |
/patch revert | Revert all patches |
/patch status | Show modified packages & patches |
The agent can use the patch_package tool to manage patches programmatically:
// Create patch for a specific package
{
"action": "create",
"package_name": "lodash"
}
// Create patches for all modified packages
{ "action": "create_all" }
// List modified packages
{ "action": "list_modified" }
// Apply patches
{ "action": "apply" }
// Dry run
{ "action": "dry_run" }
// Status check
{ "action": "status" }
# Edit files in node_modules/
ed node_modules/some-package/index.js
# Files are automatically backed up as .orig
# Single package
/patch-package some-package
# All modified
/patch-package
Patch naming: package-name+1.2.3.patch
Patches apply automatically on pi startup, or manually:
/patch apply
Fuzzy matching: Uses git apply with 3-way support (like patch-package).
mkdir -p ~/.pi/agent/extensions/pi-patch
cp extension.ts ~/.pi/agent/extensions/pi-patch/
mkdir -p .pi/extensions/pi-patch
cp extension.ts .pi/extensions/pi-patch/
ln -s $(pwd)/extension.ts ~/.pi/agent/extensions/pi-patch/index.ts
| Feature | patch-package | pi-patch |
|---|---|---|
| Patch node_modules | ✅ | ✅ |
| Fuzzy matching | ✅ (git apply) | ✅ (git apply) |
| Auto-apply | ✅ (postinstall) | ✅ (pi startup) |
| Version in filename | ✅ | ✅ |
| Scoped packages (@x/y) | ✅ | ✅ |
| Dry run | ✅ | ✅ |
| Revert patches | ✅ | ✅ |
| Agent tool access | ❌ | ✅ |
| Patch pi internals | ❌ | ✅ |
Drop-in compatible: Same workflow, same patch format.
Create .patches/pi-patch.json:
{
"autoApply": true,
"allowFuzzy": true,
"postinstall": false,
"excludePackages": ["@types/node"]
}
| Option | Description |
|---|---|
autoApply | Apply patches on pi startup |
allowFuzzy | Allow git fuzzy matching (recommended) |
excludePackages | Skip these packages |
Standard unified diff (same as patch-package):
diff --git a/lodash b/lodash
# Package: lodash
--- a/lib/debounce.js
+++ b/lib/debounce.js
@@ -10,3 +10,4 @@
function debounce() {
+ if (!func) return;
setup();
}
# Check what would happen
/patch dry-run
# See detailed output
/patch status
If upstream changed significantly:
# 1. Revert patch
/patch revert
# 2. Update package
npm update some-package
# 3. Re-apply your changes
# 4. Create new patch
/patch-package some-package
The extension uses .orig files to detect modifications. Make sure:
node_modules/.orig backups exist (created automatically on first edit)To force detect changes:
# Manually back up before editing
cp node_modules/pkg/file.js node_modules/pkg/file.js.orig
# Now edit the file
bun test # Run all tests
bun test --watch # Watch mode
54 tests covering:
# Find the bug in node_modules/express/lib/router.js
# Back up and edit
cp node_modules/express/lib/router.js{,.orig}
$EDITOR node_modules/express/lib/router.js
# Create patch
/patch-package express
# Commit
git add .patches/
git commit -m "fix: express router bug"
# Next deploy: patches auto-apply
# Heavy customization of a package
# Edit many files in node_modules/my-fork/
# Create patches for all modifications
/patch-package
# Result: Multiple patches committed to repo
# Patches survive npm install
You can ask the agent to create patches:
"The lodash merge function has a bug. Can you patch it?"
The agent will:
node_modules/lodash/merge.js.origpatch_package tool to create the patchMIT
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@sinclair/typeboxEnvironment{
"local_name": "@sinclair/typebox",
"alias": false,
"peer_metadata": null
} | ^0.32.0 | runtime |
@mariozechner/pi-coding-agentEnvironment{
"local_name": "@mariozechner/pi-coding-agent",
"alias": false,
"peer_metadata": null
} | * | peer |
Source distribution
{
"shasum": "967cd33175148470741f77e22df107007718c227",
"tarball": "https://registry.npmjs.org/@0xkobold/pi-patch/-/pi-patch-1.0.0.tgz",
"fileCount": 9,
"integrity": "sha512-7cEy7wCoPF9GZXdlKFat0T1sciDHmtPDcYrsK49c+nJXgfW47mSJnFw966f1pQ+MmyXU4Q4et2emAitpOkxrxw==",
"signatures": [
{
"sig": "MEUCIQDpb87jzUzXnMQGszBrhHd1f1q7DRQe2C2R9z7y/84PQwIgSn1AYKGmmBEugLJ6ICtZmuOmJYJ71MUjZ8l046ueNYc=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 84307
}Observed since 21 Oct, 09:03 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:f2cae40c90ec8c6101f66d2c94bd1963bc6f72e1f8fb14249f0e38cbd5f9ea67