Check that an edit's old-string occurs exactly once in a file, with match contexts
Counts how many times an old-string occurs in a supplied file text (as a replace-in-file tool would see it) and returns each match's offset, line, column and surrounding lines, for an agent about to issue an edit. pass: exactly one literal match, even counting overlapping ones. unknown: several matches, or one match that overlaps another occurrence of the same text (ambiguous; contexts show how to extend the string). fail: no literal match; the response then reports whitespace-tolerant line matches and typographic-quote or dash folding matches so the agent can see why. Does not apply the edit (use patch-anchor) and never edits anything.
What you get
Catches a failed or ambiguous edit before spending a tool round trip on it.
Call it
Send the JSON body below to https://agents.writerslogic.com/api/v1/edit-anchor-check. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.
curl -i -X POST https://agents.writerslogic.com/api/v1/edit-anchor-check \
-H 'content-type: application/json' \
-d '{"file":"const a = 1;\nconst b = 2;\nconst a = 1;\n","oldString":"const b = 2;"}'
Input
| Field | Type | Required | Description |
|---|---|---|---|
file | string; length 0..524288 | yes | File text, at most 524288 UTF-8 bytes and 100000 lines. |
oldString | string; length 1..65536 | yes | |
contextLines | integer; 0..10 | no | Lines of context before and after each listed match. Default 2. |
Example request body
{
"file": "const a = 1;\nconst b = 2;\nconst a = 1;\n",
"oldString": "const b = 2;"
}
Result
The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass. |
exactCount | integer | no | Non-overlapping literal occurrences. |
overlappingCount | integer | no | Occurrences counting overlaps; differs from exactCount for self-overlapping strings. |
matches | array<object> | no | First 10 literal matches. |
tolerant | object | no | Only when there is no literal match: whole-line matches under the first tolerance rung that has any. |
foldedCount | integer | no | Only when there is no literal match: occurrences after folding curly quotes, en/em dashes and NBSP to ASCII. |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always true: pure code, no model. |
Pay and connect
Available through: x402 (USDC on Base), MCP. MCP clients reach it through the execution-safety-kit package.
Machine-readable
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent