Sequence edit script
sequence-edit-script · version 1.0.0 · Sequences & diffs · free, no key needed
Compute the Myers shortest edit script between two bounded sequences, with keep/delete/insert counts.
Use when you need to: sequence edit script · myers shortest edit script of two sequences · sequence shortest edit script.
Supported
- sequence edit script
- myers shortest edit script of two sequences
- sequence shortest edit script
Not supported
- patience diff
- histogram diff
- fuzzy matching
- unicode normalization
- locale compare
- RFC 6902 JSON Patch
Behavior
- left and right are sequences of JSON null, boolean, string, or IEEE-754 safe integer items.
- Item equality is JavaScript === after validation; there is no case folding, locale compare, or Unicode normalization.
- ops is the Myers shortest edit script: one op per item, with keep, delete, and insert.
- When two Myers D-paths tie, the library prefers a delete from the left sequence.
- For left ["A","B"] and right ["B","A"] the script is delete A, keep B, insert A.
- keeps, deletions, and insertions count those op kinds. Empty vs empty yields ops [] and zero counts.
- The string "__proto__" is an ordinary item. Unknown input fields are rejected.
Input
left(array of null or boolean or string or integer, required): max items 1024right(array of null or boolean or string or integer, required): max items 1024
Output
ops(array of object, required): max items 4096keeps(integer, required): min 0deletions(integer, required): min 0insertions(integer, required): min 0
Limits
- max sequence items: 1024
- max item string bytes: 4096
- max text bytes: 262144
- max edit ops: 4096
- max output bytes: 1048576
Example
Request input:
{
"left": [
"A",
"B"
],
"right": [
"B",
"A"
]
}
Response:
{
"result": {
"ops": [
{
"op": "delete",
"value": "A",
"left_index": 0
},
{
"op": "keep",
"value": "B",
"left_index": 1,
"right_index": 0
},
{
"op": "insert",
"value": "A",
"right_index": 1
}
],
"keeps": 1,
"deletions": 1,
"insertions": 1
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "sequence-edit-script",
"version": "1.0.0",
"input": {
"left": [
"A",
"B"
],
"right": [
"B",
"A"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/sequence-edit-script/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"left":["A","B"],"right":["B","A"]}'
The machine-readable contract is at /v1/tools/sequence-edit-script/versions/1.0.0.
CLI
node cli.mjs run sequence-edit-script 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Sequence LCS: Compute the longest common subsequence of two bounded sequences from the Myers shortest edit script.
- Sequence longest common substring: Find the longest contiguous common subarray of two bounded sequences.
- Sequence apply edit script: Apply a keep/delete/insert edit script to a bounded sequence with exact value matching and no fuzz.
- Sequence compose edit scripts: Compose two sequence edit scripts into one per-item keep/delete/insert script.
- Sequence three way merge: Three-way merge two sequence descendants against a shared base into clean or conflict regions.
- Sequence apply hunks: Apply disjoint original-address sequence hunks with exact context and no fuzz.