Myers common subsequence
myers-common-subsequence · version 1.0.0 · Sequences & diffs · free, no key needed
Return a canonical indexed LCS witness derived from bounded Myers search, or null when its cap is exceeded.
Use when you need to: find canonical longest common subsequence · return indexed LCS witness · bounded Myers common subsequence.
Decide before calling
Read the versioned contract and the supported scope below. Reuse myers-common-subsequence@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use myers-common-subsequence@1.0.0 for find canonical longest common subsequence. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- find canonical longest common subsequence
- return indexed LCS witness
- bounded Myers common subsequence
- match equal tokens between sequences
- compute LCS with a distance cap
- prove a common subsequence with indices
Not supported
- returning edit operations
- substring or approximate string matching
Behavior
- The witness contains the equal steps of the canonical Myers shortest edit script with zero-based indices.
- Implements Myers 1986; deletion wins frontier ties and therefore fixes one LCS when several exist.
Input
a(array of string, required): max items 256; each max length 1024b(array of string, required): max items 256; each max length 1024max_distance(integer, required): min 0; max 512
Output
reference(constant "Myers 1986; RFC 3284 section 5", required)version(constant "1.0.0", required)within_limit(boolean, required)distance(integer or null, required): min 0; max 512matches(array or null, required): max items 256
Limits
- max input bytes: 131072
- max items: 256
- max item bytes: 1024
- max distance: 512
- max iterations: 263169
- max output items: 512
Example
Request input:
{
"a": [
"A",
"B"
],
"b": [
"A",
"C"
],
"max_distance": 2
}
Response:
{
"result": {
"reference": "Myers 1986; RFC 3284 section 5",
"version": "1.0.0",
"within_limit": true,
"distance": 2,
"matches": [
{
"a_index": 0,
"b_index": 0,
"value": "A"
}
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "myers-common-subsequence",
"version": "1.0.0",
"input": {
"a": [
"A",
"B"
],
"b": [
"A",
"C"
],
"max_distance": 2
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/myers-common-subsequence/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":["A","B"],"b":["A","C"],"max_distance":2}'
The machine-readable contract is at /v1/tools/myers-common-subsequence/versions/1.0.0.
CLI
node cli.mjs run myers-common-subsequence 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Myers distance bounded: Compute Myers insert/delete distance up to a caller cap, returning null predictably when the cap is exceeded.
- Myers diff bounded: Produce a canonical Myers edit script within a caller distance cap, or a deterministic over-cap result.
- 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 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.