fittings-text-char-edit

Original🇺🇸 English
Translated
1 scripts

Insert, delete, replace, extract, locate or measure at exact character offsets, counting by grapheme, code point or UTF-16 unit, with the affected range reported in both the chosen unit and UTF-16. Called as POST /v1/text/char-edit, it takes text, op, unit, index and returns op, unit, text, inputLength. Character-indexed string edits are a measured failure mode for language models (arXiv:2409.15452), and the index a model reasons about is rarely the index a runtime uses: a skin-toned emoji is one grapheme, two code points and four UTF-16 units, so an offset is wrong until the unit is named. Reading this schema and dry-running the call are free and need no wallet; a real call costs $0.003, paid in USDC on Base over x402.

1installs
Added on

NPX Install

npx skill4agent add fittings-sh/fittings fittings-text-char-edit

Exact character-position string edit

text.char-edit
on
https://fittings.sh
. One endpoint, deterministic compute.
Insert, delete, replace, extract, locate or measure at exact character offsets, counting by grapheme, code point or UTF-16 unit, with the affected range reported in both the chosen unit and UTF-16.

The call

POST https://fittings.sh/v1/text/char-edit
FieldTypeRequiredNotes
text
stringyesText to operate on, 20000 UTF-16 units or fewer
op
stringyesinsert | delete | replace | extract | find | measure
unit
stringnographeme | codepoint (default) | utf16
index
numbernoinsert: offset to insert before
start
numbernodelete, replace, extract: first offset in the range
end
numbernodelete, replace, extract: offset just past the range
value
stringnoinsert, replace: text to put in, 5000 UTF-16 units or fewer
find
stringnofind: substring to locate
from
numbernofind: offset to start searching at, default 0
Example input:
json
{
  "text": "The quick brown fox",
  "op": "replace",
  "unit": "codepoint",
  "start": 4,
  "end": 9,
  "value": "slow"
}

Metered

The 402 quotes a ceiling — the price of the declared cap, 20000 characters — and settlement is for what the call actually used. A small request settles for less than it was quoted, so read the quote as an upper bound rather than a price.

Cost and provenance

Price$0.003 per call, metered per characters
Sourcenone (pure compute)
Licencenone-needed

Why call it rather than answer from memory

Character-indexed string edits are a measured failure mode for language models (arXiv:2409.15452), and the index a model reasons about is rarely the index a runtime uses: a skin-toned emoji is one grapheme, two code points and four UTF-16 units, so an offset is wrong until the unit is named.

Calling it

A skill is loaded on its own, so this document has to be enough by itself. It does not assume the general
fittings
skill is also loaded.
call.mjs
ships alongside this file; if it is missing (this document reached you without the rest of the skill), fetch it once with
curl -sO https://fittings.sh/skill/call.mjs
.
Free, and needs no wallet. Read the schema and see what a call would cost:
bash
curl -s https://fittings.sh/catalog/text.char-edit | jq
Paying. The endpoint answers
402 Payment Required
with a signed quote, you sign an authorization, and a facilitator settles it — you never send a transaction and never pay gas. Before it spends anything, the client checks its own hash against the gateway and refuses rather than sign with logic the gateway has moved past:
bash
# Dry run. Prints the quote and pays nothing, because no key is set.
node call.mjs text.char-edit text="The quick brown fox" op=replace unit=codepoint start=4 end=9 value=slow

# For real: a wallet holding USDC on Base, and nothing else.
export FITTINGS_PRIVATE_KEY=0x...
node call.mjs text.char-edit text="The quick brown fox" op=replace unit=codepoint start=4 end=9 value=slow
Spending is never a side effect of curiosity: with no
FITTINGS_PRIVATE_KEY
the client fetches the quote and stops.
FITTINGS_MAX_PRICE
caps what it will pay without asking, and defaults to $0.05.
Use a throwaway wallet holding a few dollars, not a main one. The key sits in plaintext wherever the agent runs, and the whole cost of entry is USDC on Base — no account, no API key, and no ETH, because the payer signs off-chain and the facilitator broadcasts and pays the gas.
Writing your own client instead of using this one?
@x402/core
and
@x402/evm
on npm, and the
fittings
skill records the two things that cost real debugging time: the challenge is in a response header rather than the body, and it must be re-signed from the exact request being retried.
If this is not the right service,
https://fittings.sh/catalog/search?q=...
searches all of them for free.