Sequence apply hunks
sequence-apply-hunks · version 1.0.0 · Sequences & diffs · free, no key needed
Apply disjoint original-address sequence hunks with exact context and no fuzz.
Use when you need to: sequence apply hunks · apply sequence diff hunks · apply exact sequence hunks.
Supported
- sequence apply hunks
- apply sequence diff hunks
- apply exact sequence hunks
Not supported
- fuzzy matching
- offset search
- chained coordinate rewriting
- patience diff
- RFC 6902 JSON Patch
Behavior
- sequence is an array of JSON null, boolean, string, or IEEE-754 safe integer items.
- hunks use original addressing against that sequence. They must be sorted by old_start.
- Old ranges [old_start, old_start+old_count) must not overlap. Two empty ranges at the same index overlap and are rejected.
- keep+delete ops must equal old_count; keep+insert ops must equal new_count. Extra hunk keys are rejected.
- The old side must equal the original slice; there is no fuzz or offset search.
- Every hunk op.value must be a sequence item. Line records and other objects are rejected.
- The resulting sequence must not exceed 1024 items.
- Applying the context-0 hunk that replaces B with X in ["A","B","C"] yields ["A","X","C"].
- The string "__proto__" is an ordinary item. Unknown input fields are rejected.
Input
sequence(array of null or boolean or string or integer, required): max items 1024hunks(array of any, required): max items 1024
Output
sequence(array of null or boolean or string or integer, required): max items 1024
Limits
- max sequence items: 1024
- max item string bytes: 4096
- max hunks: 1024
- max output bytes: 1048576
Example
Request input:
{
"sequence": [
"A",
"B",
"C"
],
"hunks": [
{
"old_start": 1,
"old_count": 1,
"new_start": 1,
"new_count": 1,
"ops": [
{
"op": "delete",
"value": "B"
},
{
"op": "insert",
"value": "X"
}
]
}
]
}
Response:
{
"result": {
"sequence": [
"A",
"X",
"C"
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "sequence-apply-hunks",
"version": "1.0.0",
"input": {
"sequence": [
"A",
"B",
"C"
],
"hunks": [
{
"old_start": 1,
"old_count": 1,
"new_start": 1,
"new_count": 1,
"ops": [
{
"op": "delete",
"value": "B"
},
{
"op": "insert",
"value": "X"
}
]
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/sequence-apply-hunks/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"sequence":["A","B","C"],"hunks":[{"old_start":1,"old_count":1,"new_start":1,"new_count":1,"ops":[{"op":"delete","value":"B"},{"op":"insert","value":"X"}]}]}'
The machine-readable contract is at /v1/tools/sequence-apply-hunks/versions/1.0.0.
CLI
node cli.mjs run sequence-apply-hunks 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Sequence diff hunks: Group a Myers sequence edit script into context hunks with 0-based original addresses.
- Sequence invert hunks: Invert sequence hunks by swapping delete/insert and old/new counts.
- 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 edit script: Compute the Myers shortest edit script between two bounded sequences, with keep/delete/insert counts.
- Sequence index map: Map each left-sequence index to a kept right index, or null if deleted, and list inserted right indices.