mend applies an edit that an AI model wrote to a tree of text files. Models write edits
in four formats, and mend reads them all: unified diffs (often with wrong line numbers),
SEARCH/REPLACE blocks, V4A patches, and text-editor tool calls as JSON. Each edit's old
lines are found at the first of three matching tiers — exact, trailing whitespace ignored,
then leading and trailing whitespace ignored with re-indentation — and every file is
changed or nothing is. SPEC.md is the whole specification.
Node 22, standard library only, nothing to install:
node main.ts [--format=NAME] [--check] [--strict] [PATCH]
PATCHis the patch file; when it is absent or-, the patch is read from standard input.--format=NAMEreads one format:unified,search-replace,v4a,json, orauto(the default), which detects the format.--checkdoes everything but write: same output and exit code, no file changed.--strictmatches lines exactly (tier 0 only).- Options and
PATCHmay come in any order;--ends the options.
Exit codes: 0 when the tree is written (M/A/D/R lines, then ok: <n> files),
1 when edits failed (error: <code> <path> per failed edit, then failed: <k> of <n> edits,
nothing written), 2 on a usage, missing-patch, format or parse error (exactly one line).
The kit's practice set (100 checks with expected outcomes) runs on your own machine:
node check.ts ../program/generator/practice.json
main.ts— the CLI.runner.ts— the trial runner (kept as the kit has it);main.tshands a trial over to it whenMAKEFUN_ENV_URLis set.check.ts— runs the practice set againstmain.ts.SPEC.md— the specification.LICENSE— MIT.