Text diff stats
text-diff-stats · version 1.0.0 · Text · free, no key needed
Summarize a line-record diff as keep, insert, delete, and hunk counts.
Use when you need to: text diff stats · count line diff insertions and deletions · summarize text line differences.
Supported
- text diff stats
- count line diff insertions and deletions
- summarize text line differences
Not supported
- character-level stats
- fuzzy matching
- patience/histogram diff
- binary patches
- git diff --git headers
- filesystem access
Behavior
- left and right are split with splitRecords. Record equality is text plus eol.
- Counts come from the Myers line-record SES: keeps, insertions, and deletions are op-kind totals.
- hunks is the integer hunk count from hunksFromSes, not the hunk list. context defaults to 3, may be 0, and is at most 16.
- identical is true iff there are no change ops. lines_left and lines_right are record counts.
- A single isolated replacement is one hunk for any context 0..16. Far-apart changes may merge when context is large enough.
- Unknown input fields are rejected.
Input
left(string, required): max length 262144right(string, required): max length 262144context(integer, optional): min 0; max 16
Output
lines_left(integer, required): min 0lines_right(integer, required): min 0keeps(integer, required): min 0insertions(integer, required): min 0deletions(integer, required): min 0hunks(integer, required): min 0identical(boolean, required)
Limits
- max text bytes: 262144
- max line count: 4096
- max line bytes: 16384
- max context: 16
- max hunks: 1024
- max output bytes: 1048576
Example
Request input:
{
"left": "a\nb\n",
"right": "a\nc\n"
}
Response:
{
"result": {
"lines_left": 2,
"lines_right": 2,
"keeps": 1,
"insertions": 1,
"deletions": 1,
"hunks": 1,
"identical": false
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "text-diff-stats",
"version": "1.0.0",
"input": {
"left": "a\nb\n",
"right": "a\nc\n"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/text-diff-stats/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"left":"a\nb\n","right":"a\nc\n"}'
The machine-readable contract is at /v1/tools/text-diff-stats/versions/1.0.0.
CLI
node cli.mjs run text-diff-stats 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Text line diff: Diff two texts as line records, preserving each line terminator.
- Text lines count: Count exact line multiplicities in first-seen order.
- Text parse unified patch: Parse a one-file unified patch into path names and 0-based hunks.
- Text apply unified patch: Apply a one-file unified patch to text at original line addresses with exact hunk matches.
- Text count: Count Unicode code points, UTF-16 code units, UTF-8 bytes, and lines.
- Text extract between: Extract exact substrings between start and end markers, left to right and non-overlapping.