# WritersLogic Patch Anchor – Content-Located Diff/Edit Applier

> WritersLogic Patch Anchor – Content-Located Diff/Edit Applier is a paid API for AI agents from agents.writerslogic.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-11-19).

Applies unified-diff hunks or search/replace blocks to file text using content-based matching (ignoring line numbers), returning the fully patched text or refusing with diagnostic details if any hunk is ambiguous, missing, or overlapping.

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/patch-anchor?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-19
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/writerslogic-patch-anchor-content-located-diff-edit-applier-4a7cf6c5
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_RlB8B4zsaevStykza-MVw

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability writerslogic-patch-anchor-content-located-diff-edit-applier-4a7cf6c5 -d '<json body>'
```

Example prompt: My diff has drifted line numbers and my edit tool keeps failing — can you apply this unified diff to my file by matching the context content instead of line numbers, and give me back the patched text?

## When to prefer this

Use this endpoint when an AI agent's native edit tool has failed or when a unified diff has stale/drifted line numbers that prevent standard patching. It is ideal for content-aware patching where you trust the context lines but not the line numbers, or for search/replace edits that must be applied atomically (all-or-nothing). Prefer it over running shell patch commands when you need deterministic, filesystem-free, in-memory patching with structured diagnostics for failed hunks. Not suitable for multi-file diffs, binary files, new-file creation, or sub-line replacements.

## Known failure modes

- Hunk matched more than once — returns candidate lines with similarity scores, nothing applied
- One or more hunks not found in file — returns which hunks are missing, nothing applied
- Overlapping hunks detected — patch refused entirely, no partial application
- File or diff exceeds size limits (file >512KB or >100k lines, diff >256KB or >64 hunks) — request rejected
- Multi-file, new-file, rename, or binary diffs provided — not supported, returns error
- Attempting to match inside a line (sub-line) — not supported, whole-line matching only

## How this service works

Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.

## Output

Returns the fully patched file text when all hunks/edits are successfully located and applied. Per-hunk metadata includes the matching 'rung' used (exact, trailing-whitespace, outer-whitespace, or collapsed-whitespace). If any hunk is missing, ambiguous, or overlapping, nothing is applied and the response includes diagnostic details: candidate lines with similarity scores for ambiguous matches, and which hunks failed and why.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "diff": {
   "type": "string",
   "maxLength": 262144,
   "description": "Single-file unified diff, at most 64 hunks and 400 anchor lines each. Header counts and line numbers are ignored except as a reported hint. Give either diff or edits."
  },
  "file": {
   "type": "string",
   "maxLength": 524288,
   "description": "Current file text, at most 524288 UTF-8 bytes and 100000 lines. A leading BOM is preserved."
  },
  "edits": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "search",
     "replace"
    ],
    "properties": {
     "line": {
      "type": "integer",
      "maximum": 1000000,
      "minimum": 1,
      "description": "Optional line hint, reported as lineShift and never used to break ties."
     },
     "search": {
      "type": "string",
      "maxLength": 65536
     },
     "replace": {
      "type": "string",
      "maxLength": 65536,
      "description": "Empty string deletes the matched lines."
     }
    },
    "additionalProperties": false
   },
   "maxItems": 64,
   "minItems": 1,
   "description": "Search/replace blocks, matched as whole lines against the original file; all are located before any is applied."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-patch-anchor-content-located-diff-edit-applier-4a7cf6c5/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.writerslogic.com](https://www.zero.xyz/host/agents.writerslogic.com/llms.txt)
