New:Socket for Asana Is Now Available.Learn more
Get Started

agentpatch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agentpatch

A robust patch applier for AI-generated patches with explicit grammar, fuzzy matching, and idempotent application

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
9
350%
Maintainers
1
Weekly downloads
 
Created
Source

agentpatch

agentpatch is a tiny toolkit + conventions for applying AI-generated patches safely and repeatably.

bin/apply_patch

A robust patch applier that supports a simplified, explicit patch grammar:

  • *** Begin Patch / *** End Patch
  • *** Update File: path
  • *** Add File: path
  • *** Delete File: path (requires --allow-delete)
  • *** Rename File: old -> new (requires --allow-rename)
  • @@ ... @@ hunks containing lines prefixed with:
    • - remove
    • + add
    • context

Anchors

Inside the @@ ... @@ header you can include anchor directives:

  • @@ at:top @@
  • @@ at:bottom @@
  • @@ before:/regex/ @@
  • @@ after:/regex/ @@

If a - block can’t be found, anchors provide a deterministic insertion location.

Idempotence

If the + block already exists (exact or whitespace-insensitive match), the hunk is treated as already applied.

Usage

bin/apply_patch --verbose <<'PATCH'
*** Begin Patch
*** Add File: hello.txt
+hello\n
*** End Patch
PATCH

License

MIT

Tests

Run a small gauntlet against bin/apply_patch:

node tests/run-tests.mjs

# or point at a different apply_patch implementation
APPLY_PATCH=/path/to/bin/apply_patch node tests/run-tests.mjs

Keywords

patch

FAQs

Package last updated on 21 Feb 2026

Related posts