# MechaCut — deterministic data transforms (agent skill) Stateless, no API key. Charts, reshaping, validation, and the data-repair bundle. Deterministic: same request → same sha256. Nothing is stored. **Weak model? Start at `/SKILL-MINI.md`** — the whole manual in ~650 tokens, written to be followed literally. **When to use:** whenever you are about to *reason over data* — hand-writing a chart spec, restructuring a JSON payload, repairing broken JSON, cleaning CSV, or checking a payload against a schema — send it here instead. One API call does the job for zero tokens. **Not here — Moovicut (https://moovicut.studio):** storyboards, shot lists, scene breakdowns. The sister product does deterministic storyboarding; the task router (`/route`) points media-shaped queries there. Data mechanics stay here. ## Discovery — don't read this whole file `GET /agent/manifest` -> every tool, one line each (~4 KB, sha256 on it). `GET /tools/.json` -> one full schema on demand, not all 53. `GET /SKILL-.md` -> install only your bundle (core|repair|code| dates|numbers|identity|checks|text|design). Start with the manifest, pull what you need, skip the rest. Lost? `GET /route?q="dirty csv to typed rows"` -> ranked tools from a closed vocabulary (no LLM: same words, same answer, sha256 on it). Multi-step jobs are one call: named recipes (`POST /api/v1/recipe/clean-table`, `.../clean-json`, registry at `GET /api/v1/recipes`) or the general pipeline: `POST /api/v1/pipeline {"steps": [{"tool", "args"}, ...]}` — up to 8 tools chained server-side, later steps reference earlier outputs with `{"$from": [step_index, "key"]}`, only the final result is returned, so intermediate bytes never enter your context. Free tools + capped tools under 32 KB only; paid steps answer 402 with the direct route. ## Multi-step math protocol (what weak models get RIGHT with it) For any task needing more than one arithmetic operation (word problems, unit chains, financial steps): the model decomposes, the server computes. Each turn the model emits EXACTLY one line — `{"expr": ""}` — and Mechacut `/api/v1/math/calc` answers `{"value": ""}` (language closed, refusal named, 0.1+0.2 = 0.3). The model copies that value verbatim into the next step. Final turn: `{"answer": ""}`. Cap 6 steps; one named repair per cell. Never let the model do arithmetic inline — bench v14: protocol failures drop to ZERO and a 7B reaches 14/20 on GSM8K items it scored 2/20 on with free-form tool JSON. Remaining failures are comprehension, and they are now readable step by step in the trace. Raw evidence: bench/results_v14_skill.jsonl + bench/FINDINGS-V14.md. ## chart_from_data — POST /api/v1/chart ```json {"kind": "bar", "x": "month", "y": "revenue", "series": "product", "title": "Revenue", "data": [{"month": "Jan", "revenue": 1200, "product": "moovicut"}]} ``` - `kind`: bar, line, area, point, step, histogram, pie. `y` required unless `histogram`. Send `data` (records) or `csv` (text, header row required). - `format`: `both` (default) | `spec` (Vega-Lite only) | `png` (image only). - Response: `vega` (embeddable spec), `png_base64`, `sha256`, `sha256_png`. - MechaCut never reorders your data: bars/pies aggregate (sum) per category in first-appearance order; lines keep input order. ## reshape_json — POST /api/v1/reshape ```json {"input": {"person": {"name": "Davincc", "age": "44"}}, "mapping": {"fields": { "name": {"path": "person.name"}, "age": {"path": "person.age", "cast": "int"}, "nick": {"path": "person.nickname", "default": "anon"}, "tags": {"path": "items", "each": {"fields": {"k": {"path": "t"}}}} }}, "outputSchema": {"type": "object", "required": ["age"]}} ``` - Paths: dot keys, `[n]` indices, optional leading `$.`. - Casts: int, float, str, bool, upper, lower, strip. - Missing path → `default`, else error when required (default true). - `each` maps a sub-mapping over an array. `{const: v}` emits a literal. - `outputSchema` (JSON Schema draft 2020-12) gates the output: violations return 400 `schema_violation` with precise errors — your safety net for hallucination-free plumbing between APIs. ## validate_json — POST /api/v1/validate `{"payload": , "schema": }` → `{"valid": true}` or 400 with `errors: [{field, message}]`. ## Bundle 1 — data repair & cleaning ### json_repair — POST /api/v1/json/repair `{"text": ""}` → `{"output": , "repairs": [names], "sha256"}`. Closed, deterministic set of repairs: markdown fences, BOM, smart/single quotes, `//` and `/* */` comments, bare keys, trailing commas, Python literals (`True/False/None/NaN/Infinity`), JSONL one-object-per-line. Unrepairable → 400 `unrepairable` (never a silent wrong answer). ### json_diff — POST /api/v1/json/diff `{"a": , "b": }` → `{"changes": [{op, path, value|before/after}], "count", "identical", "sha256"}`. RFC 6901 pointer paths, sorted — same two inputs always give the same list. ### json_patch — POST /api/v1/json/patch `{"document": , "patch": [RFC 6902 ops]}` → `{"output", "operations_applied", "sha256"}`. add/remove/replace/move/copy/test; a failed op returns 400 `patch_failed` naming `patch[i]` — the input document is never mutated in place. ### json_canonical — POST /api/v1/json/canonical `{"input": , "style": "minified"|"pretty"}` → `{"text", "bytes", "sha256"}`. Keys sorted at every depth: the stable bytes for your caches and fingerprints. ### csv_fix — POST /api/v1/csv/fix `{"csv": "", "preserve_delimiter": false}` → `{"output", "notes", "sha256"}`. BOM, CRLF/CR, delimiter detection (`;` `tab` `|`), blank rows removed, empty headers named, duplicates suffixed, short rows padded / long truncated — every action reported in `notes`. ### csv_types — POST /api/v1/csv/types `{"csv": ""} ` or `{"rows": [...]}` → `{"output": typed rows, "columns": [{name, type, nulls}], "sha256"}`. Types: int, float, bool (true/false), date (ISO), datetime (ISO), string, null (empty / na / n/a / null / none / nan / `-` → null). ### csv_join — POST /api/v1/csv/join `{"left"|"left_csv", "right"|"right_csv", "on": "col"|["lc","rc"]|{"left","right"}, "how": "inner|left|right|outer"}` → `{"output", "counts", "sha256"}`. Deterministic rules: overlapping columns — left wins; duplicate right keys fan out in table order; unmatched outer rows are appended in right-table order. ### table_pivot — POST /api/v1/table/pivot Pivot: `{"data"|"csv", "index": c|[c], "columns": c, "values": c, "agg": sum|count|mean|min|max|first}` → rows in first-seen index order, spread columns sorted, missing → null. Unpivot (melt): `{"mode": "unpivot", "keep": [c]|"vars": [c], "var_name", "value_name"}`. ### list_dedupe — POST /api/v1/list/dedupe `{"items": [...], "mode": "exact|text|url|email"}` → `{"output", "removed", "sha256"}`. First occurrence wins, original values kept. `text`: NFC + whitespace + casefold. `url`: host/scheme case, default ports, trailing slash, fragment dropped, query sorted. `email`: lowercase local@domain. ### format_convert — POST /api/v1/format/convert `{"input": "", "from": "json|yaml|toml|csv|env", "to": "..."}` → `{"output", "sha256"}`. Deterministic: keys sorted where the format allows, `\n` endings. Constraints: `toml` needs an object, `env` needs flat scalars, `csv` needs an array of objects (`csv` as source yields typed values). ## Bundle 2 — code editing ### text_patch — POST /api/v1/text/patch `{"text": "", "edits": [{"find", "replace", "occurrences"?}]}` → `{"output", "edits_applied", "changed", "sha256"}`. `occurrences` defaults to `"one"`: the find must match **exactly once** or the call fails naming the edit index and the count it found. `"all"` or an exact integer are explicit opt-ins. Edits apply in order on the evolving text. ### text_diff — POST /api/v1/text/diff `{"a", "b", "context": 3}` → `{"diff", "hunks", "added", "removed", "identical", "sha256"}`. Unified format, fixed labels `before`/`after`, `\n` endings — byte-identical across calls. ### text_apply_diff — POST /api/v1/text/apply-diff `{"text", "diff"}` → `{"output", "hunks_applied", "added", "removed", "sha256"}`. Strict: context and deletion lines must match at their stated positions; drift names the hunk and line. No fuzz, ever. ### path_normalize — POST /api/v1/path/normalize `{"path", "os": "auto|posix|windows", "case": "keep|lower"}` → `{"path", "absolute", "name", "stem", "extension", "sha256"}`. Lexical only — never touches a filesystem. `..` never climbs above the start. ### glob_match — POST /api/v1/glob/match `{"pattern": "src/**/test_*.py", "paths": [...]}` → `{"matched", "count", "sha256"}`. `*`/`?` do not cross `/`, `**` spans segments, dots are literal, case-sensitive, input order preserved. ### env_interpolate — POST /api/v1/env/interpolate `{"template", "vars": {...}, "strict": true}` → `{"output", "substituted", "missing", "sha256"}`. `$VAR`, `${VAR}`, `${VAR:-default}`. Strict fails naming every missing var; `strict: false` keeps them literal. ## Bundle 3 — dates & scheduling ### date_parse — POST /api/v1/date/parse `{"text": "", "prefer": "dmy|mdy", "tz?": "Europe/Paris"}` → `{"iso", "utc", "epoch", "date", "weekday", "iso_week", "naive", "source", "sha256"}`. Accepts ISO 8601, RFC 2822, epoch seconds, slashed numeric (order by `prefer`, resolved by the numbers when they decide — never guessed), month-name forms. Unparsable → 400 `unparsable_date`. ### date_tz — POST /api/v1/date/tz `{"datetime", "source": "UTC", "targets": ["Europe/Paris", ...], "at"?}` → per-zone ISO + offset + `dst` flag. IANA zones, DST-correct. ### date_calc — POST /api/v1/date/calc `{"base", "op", "params"}` — ops: `add` {duration "1y2m3dT4h", month-end clamped}, `business_days` {n, holidays?, weekend?}, `diff` {until, unit: days|business_days|human|calendar}, `boundary` {unit day|week|month|quarter|year, edge start|end}, `age` {on?}. ### cron_next — POST /api/v1/cron/next `{"expression", "count": 1-1000, "after"?, "tz"}` → next N fire times. Wall-clock semantics (crontab behavior); Vixie rule: dom and dow both restricted → day matches if EITHER. Pin `after` for byte-stable answers. ### cron_humanize — POST /api/v1/cron/humanize `{"expression"}` → plain reading + resolved field sets. ### ics_generate / ics_parse — POST /api/v1/ics/generate, /api/v1/ics/parse Events → RFC 5545 VCALENDAR: CRLF, 75-octet folded lines, deterministic DTSTAMP (mirrors DTSTART; never wall-clock now unless given). Parse side normalizes to ISO + duration seconds, RRULE raw passthrough. Round-trip stable by construction. Free under 32 KB, x402 above. ## Bundle 4 — numbers & money (lot 4.1) ### num_format — POST /api/v1/num/format `{"value", "locale": "en-US", "style": "number|currency|percent", "currency"?, "decimals"?, "grouping": true}` → `{"formatted", "locale", "style", "currency", "decimals", "sha256"}`. Closed tables: 13 locales, 20 currencies (JPY-type currencies default to 0 decimals). Decimal-based — `1234.567` → `"1,234.567"`, fr-FR EUR → `"1 234,57 €"`, `"0.1234"` percent → `"12.34%"`. Unknown locale or currency: 400 naming the closed table. ### num_parse — POST /api/v1/num/parse `{"text", "prefer"?}` → `{"decimal_string", "float", "is_integer", "currency", "percent", "sha256"}`. Accepts `1,234.56`, `1.234,56`, `1'234.56`, spaced forms, symbols and ISO codes, `%`, scientific notation. Ambiguity is refused, never guessed: `1,234` answers 400 unless you pass `prefer="decimal"` or `prefer="group"` — same stance as date/parse. ### num_round — POST /api/v1/num/round `{"value", "places": 0, "mode": "half_even|half_up|half_down|ceil|floor| trunc|up", "significant": false}` → `{"result", "float", "mode", "places", "significant", "changed", "sha256"}`. Exact Decimal arithmetic: `0.145` at 2 places is `"0.14"` under banker's rounding, `"0.15"` under half_up — and 20-digit integers work because no float touches the path. ### units_convert — POST /api/v1/units/convert `{"value", "from", "to", "places": 10}` → `{"value", "float", "from", "to", "base", "places", "sha256"}`. Closed families: length, mass, volume, area, speed, data (kB/KiB and bit/Byte are distinct, `GiB` for the power-of-two), duration, temperature (C/F/K). Exact rational factors — `km/h → m/s` of 90 is exactly `"25"`. Cross-family: refused with the families named; unknown unit: refused with the table named. ### money_prorate — POST /api/v1/money/prorate (paid) `{"amount", "cycle_start", "cycle_end", "service_start", "service_end", "places": 2, "mode": "half_up", "inclusive": true, "clamp": true}` → prorated = amount × covered_days / cycle_days. The exact fraction is reported before rounding; rounding runs last; the service window clamps to the cycle (a December window on a November cycle is 0.00, not a negative invoice). ### money_split — POST /api/v1/money/split `{"total", "participants": [name | {name, weight?}], "mode": "remainder_order"}` → shares summing exactly to the total. Leftover cents go by largest fractional part, ties by list order — who gets the extra cent is a deterministic function, not a coin flip. ### number_spell — POST /api/v1/number/spell `{"value": "1234.56", "lang": "fr|en|pt", "currency"?: "EUR", "cents": true, "capital": false}` → `{"words", "lang", "currency", "amount", "sha256"}`. The invoice mention no model gets right twice: quatre-vingts takes its s only at the end, cent stays singular before mille, duzentos / trezentos / quinhentos are words, not formulas. Closed currency table per language; more than 2 decimals refused (the law speaks in cents). Free under 32 KB, x402 above. ## Bundle 5 — hashes, encodings & identity (all free) ### hash_digest — POST /api/v1/hash/digest `{"data", "algo": "sha256"|md5|sha1|sha512|blake2b, "input_kind": "text"|"base64"|"hex"}` → `{algo, hex, base64, input_bytes, sha256}`. A model cannot hash and will fake one confidently — never roll a digest yourself, call this. ### enc_base64 — POST /api/v1/enc/base64 `{"text", "op": "encode"|"decode", "variant": "base64"|base64url|hex, "padding": true}` → `{op, variant, result, input_bytes, output_bytes, sha256}`. Decode is STRICT: junk characters are a 400, never a silent empty byte string. urlsafe input is accepted on any variant. ### jwt_decode — POST /api/v1/jwt/decode `{"token"}` → header, claims, signature, `verified: false` stated, and iat/exp/nbf as ISO. Decode only — no key ever touches this server, so no verification is ever faked. ### id_uuid — POST /api/v1/id/uuid `{"op": "v5", "name", "namespace": "url|dns|oid|x500|"}`, `{"op":"v4_seeded","seed"}`, or `{"op":"v7","at":,"seed"?}` — v7 REQUIRES an explicit instant (the wall clock would break same-request-same-bytes, so it is refused). ### id_slug — POST /api/v1/id/slug `{"text", "sep": "-"|"_", "lower": true, "max_len": 0}` → transliterated (NFKD), separators collapsed, word-boundary cut when bounded. ### fingerprint — POST /api/v1/fingerprint `{"value": , "kind": "json"|"csv"}` → canonical sha256 (keys sorted at every depth, csv header-aligned) + the canonical text for json. Your cache key: same content in any order → same hash → skip the re-call everywhere. ## Bundle 6 — validators & color ### validate_iban — POST /api/v1/validate/iban ($0.0005) `{"iban": "FR76 3000 …"}` → valid + country/length/checksum/bban pieces. Closed 61-country structure table + mod-97; spaces tolerated, anything else refused with the exact failing rule (`check_failed`). Paid tier by the money rule: a bot sending funds pays without blinking. ### validate_phone — POST /api/v1/validate/phone `{"phone": "01 23 45 67 89", "default_country": "FR"}` → `e164`, country, dial code, national digits. 00-intl, +, bare national (trunk 0 dropped) all accepted; per-country digit ranges from a closed table. ### validate_email — POST /api/v1/validate/email `{"email"}` → structure verdict + `normalized` (domain lowercased). No DNS, no mailbox claim — the same honest scope as /validate. ### validate_url — POST /api/v1/validate/url `{"url"}` → components + `canonical`: IDN to punycode, default port dropped, `..` resolved, password in userinfo masked, secure flag. ### color_check — POST /api/v1/color/check `{"color": "#767676|rgb(…)", "against": "#ffffff"?}` → hex/rgb/hsl + luminance; with `against`: contrast ratio + AA/AAA (normal/large) booleans. ## Bundle 7.1 — context & text (free) ### text_count — POST /api/v1/text/count `{"text"}` → chars, chars_nospace, words, sentences, paragraphs, lines, bytes. Same sentence splitter as text/truncate and text/chunk: the count and the cuts can never disagree. ### sort_natural — POST /api/v1/sort/natural `{"items": [...], "reverse": false}` → human-order strings (file2 < file10) + `permutation` (index map to reapply elsewhere). ### text_case — POST /api/v1/text/case `{"text", "op": snake|kebab|camel|pascal|title|upper|lower|sentence}`. Word-boundary aware in both directions (camelCase in, snake_case out). ### text_truncate — POST /api/v1/text/truncate `{"text", "max", "unit": chars|words|sentences, "strategy": cut|word|sentence, "ellipsis": "…"}` → boundary-exact cut + removed count + end offset. Never mid-word unless strategy="cut". ### regex_test — POST /api/v1/regex/test `{"pattern", "text", "flags": "imsxua", "mode": test|findall|groups| replace, "template"?, "count"?}` → match+span / all matches+spans / named+numbered groups / template result+replacement count. Inputs over 64 KB refused (ReDoS blast-radius rule). ### text_chunk — POST /api/v1/text/chunk ($0.001) `{"text", "budget": 512, "overlap": 0, "encoding": "cl100k_base", "unit": "sentence|paragraph"}` → chunks with `tokens` counted by the REAL BPE tokenizer, char offsets, `hard_cut` flags. Overlap must stay below budget; encodings closed to cl100k/o200k/o250k/p50k/gpt2. This is the flagship that funds the free 45: RAG pipelines chunk all day. ### md_render — POST /api/v1/md/render `{"markdown", "heading_ids": false}` → `
…`. CLOSED SUBSET, not CommonMark: headings, bold/italic/code, links/images (javascript:/data: refused), lists, tables, fences with language class, blockquotes, hr. Raw HTML is escaped before anything else, so injection is structurally impossible, and the same markdown renders the same bytes forever. Free under 32 KB, x402 above. ### html_text — POST /api/v1/html/text ($0.001) `{"html", "keep_links": false, "max_bytes": 1048576}` → canonical text: script/style/head/svg/noscript dropped, blocks become lines, whitespace collapsed by the closed rule, entities decoded exactly once, img alt in brackets, `keep_links` renders `label (href)` with javascript:/data:/ vbscript: refused and counted. Over max_bytes: `truncated: true` with the byte cap honored — never a silent half-page. ### color_palette — POST /api/v1/color/palette `{"color", "scheme": complementary|analogous|triad|tetradic|split, "steps": 5, "neutral": false}` -> base + scheme swatches (closed hue rotations) + even-lightness ramp (2..21 steps) + optional neutral ramp. Design agents: the brand palette stops drifting between generations. Free. ## Paying (x402, per call) — three tiers - **Free routes** (most Bundle 1 tools, chart…): no key, no account, 30 req/min/IP. A 402 never sits on your core loop. - **Capped routes** (`json/patch`, `csv/fix`, `csv/types`, `format/convert`): free while the request is under 32 KB; above, x402 per call ($0.0005). Small jobs never see a payment wall. - **Priced routes** (`chart` $0.001; `reshape`, `validate`, `csv/join`, `table/pivot` $0.0005): 402 from the first request, with x402 requirements (USDC on Base, EIP-3009). Retry with an `X-PAYMENT` header — x402 clients (x402-fetch) pay automatically. Failed (400) calls are always free. ## Verify what you OUTPUT (the verdict gates) Intake checked your input. Before your answer leaves the machine, three free gates close the loop — each returns a verdict, never a lecture: - `POST /api/v1/check/agreement {"payloads": [, ]}` — two parties believe they agreed. The pointer diff says if that is true; `first_divergence` is the one field to escalate. Numeric strings are compared as numbers ("4250.00" == 4250), so format noise is not reported as disagreement — only meaning is. - `POST /api/v1/check/redlines {"text": "", "rules": {...}}` — instructions like "never include identifiers" or "max 280 chars" decay as your context grows. This scan does not. Forbidden words, regexes, PII shapes (email/card/iban/phone/ssn), byte budget -> first violation with offset. Re-check AFTER every edit. - `POST /api/v1/check/refs` (see manifest) — every URL/ID you cited must exist in the source you were given. Citing what is not there is the one error an agent should never ship. Chain for a handoff between agents: intake card -> run -> agreement -> redlines -> refs -> send. A reply that passed all four is not "probably correct"; it is gated. ## When the user's words are vague Never improvise a call from a vague sentence. Send the words AS SAID to `POST /api/v1/intent/card {"utterance": "..."}`: - `ready` -> run the tool, or fill the remaining defaults yourself and `POST /api/v1/intent/check` first (free) to be sure before paying; - `incomplete` -> show `question_human` to the human verbatim; do not guess the missing fields — a guessed field that bills is a broken trust; - `ambiguous` -> show the candidate shortlist and ask which one; - `no_match` -> say so; browse /agent/manifest together. The card is deterministic and sha256-stamped: the same sentence always yields the same form, so an agent can cache nothing and still be exact. ## Rules - Nothing stored; only IPs in a one-minute rate-limit window in memory. - Every 400 is public, anonymized, for 60 minutes: `GET /misses.json` (kind + route counts; no payloads). Every 402 (unpaid attempt) is counted there too, labelled `payment_required`. - Request bodies over 5 MB are refused (413) before any payment or route work. - Deterministic: byte-stable responses, pinned by `sha256` fields.