Sequence three way merge
sequence-three-way-merge · version 1.0.0 · Sequences & diffs · free, no key needed
Three-way merge two sequence descendants against a shared base into clean or conflict regions.
Use when you need to: sequence three way merge · three-way merge two sequences against a base · sequence merge regions.
Supported
- sequence three way merge
- three-way merge two sequences against a base
- sequence merge regions
Not supported
- fuzzy matching
- text conflict markers
- RFC 7396 JSON merge patch
- RFC 6902 JSON Patch
- csv row diff
- patience merge
Behavior
- base, ours, and theirs are sequences of JSON null, boolean, string, or IEEE-754 safe integer items.
- Regions come from mergeRegions on the Myers SES of base→ours and base→theirs.
- Non-empty abutting ranges do not overlap. Empty spans at the same base index overlap. An insertion index inside another span overlaps.
- Identical overlapping replacements collapse to one ok region. Distinct overlapping replacements are a conflict.
- status is clean or conflict. result concatenates ok items when clean and is null when any conflict exists.
- A clean result must not exceed 1024 items.
- Ok regions are {type, items}. Conflict regions are {type, base, ours, theirs}.
- base ["A","B","C"], ours ["A","X","C"], theirs ["A","B","Y"] is clean with result ["A","X","Y"].
- ours ["A","X","C"] vs theirs ["A","Y","C"] is a conflict on B. The string "__proto__" is an ordinary item.
Input
base(array of null or boolean or string or integer, required): max items 1024ours(array of null or boolean or string or integer, required): max items 1024theirs(array of null or boolean or string or integer, required): max items 1024
Output
status(one of "clean", "conflict", required)regions(array of any, required)result(array or null, required)
Limits
- max sequence items: 1024
- max item string bytes: 4096
- max text bytes: 262144
- max output bytes: 1048576
Example
Request input:
{
"base": [
"A",
"B",
"C"
],
"ours": [
"A",
"X",
"C"
],
"theirs": [
"A",
"B",
"Y"
]
}
Response:
{
"result": {
"status": "clean",
"regions": [
{
"type": "ok",
"items": [
"A",
"X",
"Y"
]
}
],
"result": [
"A",
"X",
"Y"
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "sequence-three-way-merge",
"version": "1.0.0",
"input": {
"base": [
"A",
"B",
"C"
],
"ours": [
"A",
"X",
"C"
],
"theirs": [
"A",
"B",
"Y"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/sequence-three-way-merge/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"base":["A","B","C"],"ours":["A","X","C"],"theirs":["A","B","Y"]}'
The machine-readable contract is at /v1/tools/sequence-three-way-merge/versions/1.0.0.
CLI
node cli.mjs run sequence-three-way-merge 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Sequence edit script: Compute the Myers shortest edit script between two bounded sequences, with keep/delete/insert counts.
- 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 index map: Map each left-sequence index to a kept right index, or null if deleted, and list inserted right indices.