# Sequence index map

`sequence-index-map` · version 1.0.0 · Sequences & diffs · free, no key needed

Map each left-sequence index to a kept right index, or null if deleted, and list inserted right indices.

**Use when you need to: sequence index map · map left indices onto a right sequence · sequence keep index map.**

## Supported

- sequence index map
- map left indices onto a right sequence
- sequence keep index map

## Not supported

- fuzzy matching
- patience diff
- histogram diff
- unicode normalization
- locale compare
- longest common substring

## 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.
- The map is built from the Myers shortest edit script: keep stores the right index, delete stores null.
- When two Myers D-paths tie, the library prefers a delete from the left sequence.
- inserted lists right indices that came from insert ops, in script order.
- For left ["A","B","C"] and right ["A","X","C"] the map is [0, null, 2] and inserted is [1].
- Empty left yields map [] . 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 1024
- `right` (array of null or boolean or string or integer, required): max items 1024

## Output

- `map` (array of integer or null, required): max items 1024; each min 0
- `inserted` (array of integer, required): each min 0

## Limits

- max sequence items: 1024
- max item string bytes: 4096
- max text bytes: 262144
- max output bytes: 1048576

## Example

Request input:

```json
{
  "left": [
    "A",
    "B",
    "C"
  ],
  "right": [
    "A",
    "X",
    "C"
  ]
}
```

Response:

```json
{
  "result": {
    "map": [
      0,
      null,
      2
    ],
    "inserted": [
      1
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "sequence-index-map",
  "version": "1.0.0",
  "input": {
    "left": [
      "A",
      "B",
      "C"
    ],
    "right": [
      "A",
      "X",
      "C"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/sequence-index-map/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"left":["A","B","C"],"right":["A","X","C"]}'
```

The machine-readable contract is at [/v1/tools/sequence-index-map/versions/1.0.0](/v1/tools/sequence-index-map/versions/1.0.0).

### CLI

```sh
node cli.mjs run sequence-index-map 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Sequence apply edit script](/tools/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](/tools/sequence-compose-edit-scripts): Compose two sequence edit scripts into one per-item keep/delete/insert script.
- [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 apply hunks](/tools/sequence-apply-hunks): Apply disjoint original-address sequence hunks with exact context and no fuzz.
- [Sequence diff hunks](/tools/sequence-diff-hunks): Group a Myers sequence edit script into context hunks with 0-based original addresses.
- [Sequence edit script](/tools/sequence-edit-script): Compute the Myers shortest edit script between two bounded sequences, with keep/delete/insert counts.
