{"uid":"cap_RlB8B4zsaevStykza-MVw","slug":"writerslogic-patch-anchor-content-located-diff-edit-applier-4a7cf6c5","name":"WritersLogic Patch Anchor – Content-Located Diff/Edit Applier","description":"Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.","url":"https://agents.writerslogic.com/api/v1/patch-anchor?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":{"type":"json"},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.005","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.005/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_bSuG6jhb7cui5ftYGVVsO","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.005","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Recover stale diff after upstream merge","prompt":"I have a unified diff that was generated against an older version of my file and the line numbers are now all wrong after a merge. Here's the current file text and the diff — can you locate each hunk by its content and apply the patch, returning the updated file?"},{"title":"Targeted search-replace edits in source file","prompt":"I need to rename the function `computeTotal` to `calculateTotal` and update its docstring in this Python file — can you apply these search/replace blocks to the file text and give me back the patched version?"},{"title":"Debug ambiguous or unmatched diff hunks","prompt":"I tried applying this diff to my file but it failed — can you tell me which hunks couldn't be located or were matched more than once, and show me the candidate lines with similarity scores so I can figure out what went wrong?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-19T06:37:30.581Z","isFirstParty":false,"canonicalSlug":"writerslogic-patch-anchor-content-located-diff-edit-applier-4a7cf6c5"}