# Sequence apply edit script

`sequence-apply-edit-script` · version 1.0.0 · Sequences & diffs · free, no key needed

Apply a keep/delete/insert edit script to a bounded sequence with exact value matching and no fuzz.

**Use when you need to: sequence apply edit script · apply sequence edit script · apply keep delete insert ops to a sequence.**

## Supported

- sequence apply edit script
- apply sequence edit script
- apply keep delete insert ops to a sequence

## Not supported

- fuzzy matching
- offset search
- patience diff
- RFC 6902 JSON Patch
- locale compare
- unicode normalization

## Behavior

- sequence is an array of JSON null, boolean, string, or IEEE-754 safe integer items.
- Each op requires op (keep, delete, or insert) and value (a sequence item). Extra keys are rejected.
- Optional left_index and right_index, if present, must equal the inferred walk index; omitted indices are inferred.
- keep and delete consume sequence from the left with === equality; keep and insert produce the output sequence.
- The walk must consume sequence exactly. Length or value mismatch is rejected. There is no fuzz or offset search.
- For sequence ["A","B"] and ops delete A, keep B, insert A the result is ["B","A"].
- 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 1024
- `ops` (array of object, required): max items 4096

## 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 text bytes: 262144
- max edit ops: 4096
- max output bytes: 1048576

## Example

Request input:

```json
{
  "sequence": [
    "A",
    "B"
  ],
  "ops": [
    {
      "op": "delete",
      "value": "A"
    },
    {
      "op": "keep",
      "value": "B"
    },
    {
      "op": "insert",
      "value": "A"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "sequence": [
      "B",
      "A"
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "sequence-apply-edit-script",
  "version": "1.0.0",
  "input": {
    "sequence": [
      "A",
      "B"
    ],
    "ops": [
      {
        "op": "delete",
        "value": "A"
      },
      {
        "op": "keep",
        "value": "B"
      },
      {
        "op": "insert",
        "value": "A"
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/sequence-apply-edit-script/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"sequence":["A","B"],"ops":[{"op":"delete","value":"A"},{"op":"keep","value":"B"},{"op":"insert","value":"A"}]}'
```

The machine-readable contract is at [/v1/tools/sequence-apply-edit-script/versions/1.0.0](/v1/tools/sequence-apply-edit-script/versions/1.0.0).

### CLI

```sh
node cli.mjs run sequence-apply-edit-script 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Sequence compose edit scripts](/tools/sequence-compose-edit-scripts): Compose two sequence edit scripts into one per-item keep/delete/insert script.
- [Sequence edit script](/tools/sequence-edit-script): Compute the Myers shortest edit script between two bounded sequences, with keep/delete/insert counts.
- [Sequence index map](/tools/sequence-index-map): Map each left-sequence index to a kept right index, or null if deleted, and list inserted right indices.
- [Sequence apply hunks](/tools/sequence-apply-hunks): Apply disjoint original-address sequence hunks with exact context and no fuzz.
- [Sequence three way merge](/tools/sequence-three-way-merge): Three-way merge two sequence descendants against a shared base into clean or conflict regions.
- [Sequence diff hunks](/tools/sequence-diff-hunks): Group a Myers sequence edit script into context hunks with 0-based original addresses.
