prompt-diff-lite
v0.1.0
Published
Line-level diff viewer for prompt template versions — see exactly what changed between two prompt revisions.
Readme
prompt-diff-lite
Line-level diff for prompt template versions — see exactly what changed between two revisions before you ship a prompt edit. LCS-based, zero dependencies.
Install
npm install prompt-diff-liteQuick start
import { diffLines, formatDiff, summarize } from 'prompt-diff-lite';
const diff = diffLines(promptV1, promptV2);
console.log(formatDiff(diff));
// unchanged lines prefixed with a space, additions with +, removals with -
console.log(summarize(diff)); // { added: 3, removed: 1, unchanged: 12 }Why line-level, not word-level
Prompt edits are usually restructuring at the sentence/instruction level — reordering a bullet point, adding a constraint, dropping an example — which shows up cleanly as line changes. Word-level diffing adds real complexity (and is much noisier to read) for a case where most edits are already easy to review at line granularity, so prompt-diff-lite intentionally stays at that level.
API
diffLines(a, b)— returns aDiffLine[]({ op: 'equal' | 'add' | 'remove', line })formatDiff(diff)— unified-diff-style string (unchanged,+ added,- removed)summarize(diff)—{ added, removed, unchanged }counts
License
MIT
