Skip to content
FadliilmiPublic

About

mend — one patch tool for every AI edit format (unified diff, SEARCH/REPLACE, V4A, JSON)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mend — one patch tool for every AI edit format

make.fun bounty rank reward

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.

Run it

Node 22, standard library only, nothing to install:

node main.ts [--format=NAME] [--check] [--strict] [PATCH]
  • PATCH is the patch file; when it is absent or -, the patch is read from standard input.
  • --format=NAME reads one format: unified, search-replace, v4a, json, or auto (the default), which detects the format.
  • --check does everything but write: same output and exit code, no file changed.
  • --strict matches lines exactly (tier 0 only).
  • Options and PATCH may 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).

Check it

The kit's practice set (100 checks with expected outcomes) runs on your own machine:

node check.ts ../program/generator/practice.json

Files

  • main.ts — the CLI.
  • runner.ts — the trial runner (kept as the kit has it); main.ts hands a trial over to it when MAKEFUN_ENV_URL is set.
  • check.ts — runs the practice set against main.ts.
  • SPEC.md — the specification.
  • LICENSE — MIT.

About

mend — one patch tool for every AI edit format (unified diff, SEARCH/REPLACE, V4A, JSON)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages