Similar functions

bun scripts/similar.ts <file> (or - for stdin) lists the functions under src/ most like a snippet, with path:line. bun scripts/similar.ts --diff main does it for each function your branch adds. Read-only; flags --top N (5), --min S (0.8) and --src DIR (src). Arguments are parsed by parseArgs, the diff by addedLines; both are tested.

It is a builder's tool, deliberately without a src/tui/ entry: it reads the clone, not the running forge. It indexes src/ on every run (about 6 s), so run it once on a finished draft or on the branch before pushing, not on every edit.

It is Aroma's cheap pass (Luan et al., OOPSLA 2019): tokens and adjacent token pairs, names a function declares itself replaced by #, scored by how much of the snippet a function holds. A half-written snippet finds the whole.

The crew's brief for a forge issue names it, and asks the pull to say what it reused (#14619).

The hand trial (#14619)

The last 14 non-merge commits touching src/ that added functions, each checked against src/ as it was before the commit. Three of the 14 added a helper that already existed in another shape: attr in the Collada pull (xmlAttr, src/web/render/office-zip.ts) and plural in the Gerber and WebAssembly pulls (plural, src/web/render/dxf.ts). Two more (daeFromText, readDae) followed src/web/render/obj.ts by design. Scores under 0.8 were noise.

The trial is 14 commits by hand, fewer than the 20 the issue asked for, and is a sample, not a measurement of review round-trips saved.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs