---
name: code-anything
description: Polymorphic 5-domain deterministic static code compiler, schema migration differ, and AST auditor across OpenAPI 3.x -> 4-lang zero-dep SDKs (openapi_sdk), GraphQL SDL typed client & validator (graphql_client), SQL DDL breaking-change & rollback-safe migration diff (sql_migration), Python/JS-TS AST dead-code & cyclomatic complexity audit (ast_audit), and REST OpenAPI -> Remote MCP bundle (openapi_mcp) via REST, JSON-RPC 2.0 /mcp, 0%-commission Treg Hub, or run_hand.py. Strictly bills $0 on invalid input, syntax errors (HTTP 422), SSRF blocks, or errors.
---

# Code-Anything — Agent-Executable Skill Contract

Use **Code-Anything** (`https://code.fastmesh.dev`, local dev `http://127.0.0.1:9012`) whenever a coding agent, CI/CD release pipeline, or API engineering team needs deterministic, verifiable code generation, schema migration safety checks, or AST complexity/dead-code auditing across 5 polymorphic domains.

> **Security & Technical Tooling Notice**: Code-Anything runs pure Python 3 standard-library deterministic parsers and compilers. It **never calls `eval()` or `exec()`** on untrusted user input, **never resells customer source code or specs**, and **never uses customer payloads to train AI models** (`zero_data_resale: true`).

---

## Core Surfaces & Distribution Channels

- **Web 5-Second Try-Now Console (zero signup)**: `https://code.fastmesh.dev/`
- **Compile & Audit REST API**: `POST https://code.fastmesh.dev/api/v1/compile` (aliases: `POST /api/v1/audit`, `POST /api/v1/try`, `POST /api/compile`, `POST /api/audit`)
- **Concurrent Batch API**: `POST https://code.fastmesh.dev/api/v1/batch` (alias: `POST /api/batch`)
- **Multi-Format Exporter (JSON / Markdown / Bundle)**: `POST https://code.fastmesh.dev/api/v1/export` (alias: `POST /api/export`)
- **Native Streamable MCP Server (JSON-RPC 2.0)**: `POST https://code.fastmesh.dev/mcp`
- **OpenAPI 3.1.0 Spec**: `GET https://code.fastmesh.dev/openapi.json`
- **Health & Readiness**: `GET https://code.fastmesh.dev/health`
- **Treg Hub 0%-Commission Package**: `code-anything-deterministic-compiler` (`c12_code_anything_v1`)
- **Causal Bazaar Edge Hand**: `run_hand.py` (`hand_id: c12_code_anything_hand_v1`, `card_id: c12_code_anything_v1`)
- **Discovery Manifest & Guides**: `https://code.fastmesh.dev/llms.txt`, `https://code.fastmesh.dev/guides`, `https://code.fastmesh.dev/sitemap.xml`

---

## Per-Call Pricing, Credit Packs & Billing Invariants

| Domain | Deliverable | Live / New-Tenant Cache (`100%`) | Same-Tenant Recheck (`10%`) | Invalid / `422` Syntax Error / SSRF |
| :--- | :--- | :---: | :---: | :---: |
| `openapi_sdk` | OpenAPI 3.x -> 4 zero-dep typed SDKs (Python `urllib`+`dataclass`, TS `fetch`+`interface`, Go `net/http`+`struct`, Rust `struct`+client) | `$0.08` (`80,000` micros) | `$0.008` (`8,000`) | `$0.00` |
| `graphql_client` | GraphQL SDL (`type`, `input`, `enum`, `Query`, `Mutation`, nested inputs) -> strongly-typed client + field/input validator | `$0.05` (`50,000` micros) | `$0.005` (`5,000`) | `$0.00` |
| `sql_migration` | Old vs new SQL DDL breaking-change differ (dropped cols, narrowed types, `NOT NULL` without `DEFAULT`, lock risks + rollback-safe SQL) | `$0.05` (`50,000` micros) | `$0.005` (`5,000`) | `$0.00` |
| `ast_audit` | Python (`ast`) & JS/TS static dead-code, unused imports, cyclomatic complexity hotspots, oversized functions & missing exception handling | `$0.04` (`40,000` micros) | `$0.004` (`4,000`) | `$0.00` |
| `openapi_mcp` | REST OpenAPI 3.x -> Remote MCP `mcp.json` tool definitions + runnable JSON-RPC 2.0 route adapter | `$0.06` (`60,000` micros) | `$0.006` (`6,000`) | `$0.00` |
| `auto` | Deterministic input classifier routing across all 5 domains | Matched rate (`$0.04–$0.08`) | `10%` of matched rate | `$0.00` |

**Prepaid Non-Expiring Creem Credit Packs**: Starter `$19` (`sku_code_starter_19`, `$19.00` credits), Growth `$79` (`sku_code_growth_79`, `$86.90` credits, `+10%`), Scale `$199` (`sku_code_scale_199`, `$238.80` credits, `+20%`).

### Non-Negotiable Security & Billing Guarantees

1. **Zero `eval()` / `exec()` on Untrusted Input**: All parsing runs in pure Python 3 `ast`, `json`, and deterministic lexical scanners.
2. **Strict `$0` on Syntax Errors / Malformed Payloads (`HTTP 422`)**: Broken JSON, invalid GraphQL SDL, unparseable SQL DDL, Python `SyntaxError`, empty/sentinel strings, and private-IP/metadata SSRF URLs strictly return `ok: false`, `status_code: 422`, `billed_micros: 0`, `charged_micros: 0`, `billed: false`, and never poison the archive cache.
3. **SSRF Protection (`HTTP 422`, `$0` Billed)**: Public OpenAPI `url` fetches unconditionally block loopback (`127.0.0.0/8`, `::1`, `localhost`), RFC 1918 (`10/8`, `172.16/12`, `192.168/16`), link-local/metadata (`169.254/16`, `metadata.google.internal`), and non-HTTP(S) schemes.
4. **Hard `$2.00` Spend Cap**: `/api/v1/batch` and `run_hand.py` enforce `max_budget_micros <= 2000000` (`$2.00`).
5. **Zero Data Resale (`zero_data_resale: true`)**: Submitted code, schemas, and specs stay deterministic and local — never sold or sent to external model providers.

---

## Invocation Pattern 1: REST API (`POST /api/v1/compile`, `/api/v1/audit`, `/api/v1/batch`)

```bash
# 1. Compile OpenAPI 3.1 -> 4 zero-dep SDKs ($0.08)
curl -fsSL -X POST "https://code.fastmesh.dev/api/v1/compile" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: api-ci" \
  -d '{"domain":"openapi_sdk","languages":["python","typescript","go","rust"],"content":"{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Orders\",\"version\":\"1.0.0\"},\"paths\":{\"/orders\":{\"get\":{\"operationId\":\"listOrders\",\"responses\":{\"200\":{\"description\":\"ok\"}}}}}}"}'

# 2. GraphQL SDL -> Typed Client & Field Validator ($0.05)
curl -fsSL -X POST "https://code.fastmesh.dev/api/v1/compile" \
  -H "Content-Type: application/json" \
  -d '{"domain":"graphql_client","content":"enum Status { OPEN PAID }\ninput OrderIn { id: ID! }\ntype Query { order(id: ID!): String }\ntype Mutation { pay(input: OrderIn!): Status }"}'

# 3. SQL DDL Breaking-Change & Rollback-Safe Migration Diff ($0.05)
curl -fsSL -X POST "https://code.fastmesh.dev/api/v1/compile" \
  -H "Content-Type: application/json" \
  -d '{"domain":"sql_migration","old_sql":"CREATE TABLE users (id BIGINT PRIMARY KEY, email VARCHAR(255) NOT NULL);","new_sql":"CREATE TABLE users (id BIGINT PRIMARY KEY, phone VARCHAR(20) NOT NULL);"}'

# 4. Python / JS-TS AST Dead-Code & Cyclomatic Complexity Audit ($0.04)
curl -fsSL -X POST "https://code.fastmesh.dev/api/v1/audit" \
  -H "Content-Type: application/json" \
  -d '{"domain":"ast_audit","content":"import os\ndef dead_fn():\n    return 1\ndef run_app(x):\n    if x > 0:\n        return x\n    return 0"}'

# 5. REST OpenAPI -> Remote MCP mcp.json + JSON-RPC Router ($0.06)
curl -fsSL -X POST "https://code.fastmesh.dev/api/v1/compile" \
  -H "Content-Type: application/json" \
  -d '{"domain":"openapi_mcp","content":"{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Billing\",\"version\":\"1.0.0\"},\"paths\":{\"/invoices\":{\"get\":{\"operationId\":\"listInvoices\",\"responses\":{\"200\":{\"description\":\"ok\"}}}}}}"}'
```

---

## Invocation Pattern 2: Native JSON-RPC 2.0 MCP (`POST /mcp`)

Four flat tools exposed via `initialize`, `tools/list`, and `tools/call`:

| MCP Tool | Purpose | Key Arguments |
| :--- | :--- | :--- |
| `code_compile` | Run a single compilation, DDL diff, or AST audit across any of the 5 domains | `domain`, `content` / `spec` / `url` / `old_sql`+`new_sql`, `languages`, `no_cache` |
| `code_batch` | Concurrent heterogeneous batch execution with hard `$2.00` ceiling | `items`, `max_budget_micros` |
| `code_pricing` | Fetch live micro-USD domain pricing, cache economics, and Creem packs (`$0`) | `{}` |
| `code_verify_attestation` | Verify 64-hex `sha256_attestation` on any response envelope (`$0`) | `dossier` (or `artifact`) |

```bash
curl -fsSL -X POST "https://code.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: mcp-coding-agent" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "code_compile",
      "arguments": {
        "domain": "ast_audit",
        "content": "import sys\ndef unused():\n    return 42"
      }
    }
  }'
```

---

## Invocation Pattern 3: Treg Hub (0%-Commission QuickJS Package)

```bash
treg call code-anything-deterministic-compiler --data '{
  "domain": "openapi_sdk",
  "content": "{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Orders\",\"version\":\"1.0.0\"},\"paths\":{\"/orders\":{\"get\":{\"operationId\":\"listOrders\",\"responses\":{\"200\":{\"description\":\"ok\"}}}}}}",
  "languages": ["python", "typescript", "go", "rust"],
  "max_cost_micros": 100000
}'
```

---

## Invocation Pattern 4: Causal Bazaar Edge Hand (`run_hand.py`)

```bash
python3 run_hand.py --json '{"domain":"sql_migration","old_sql":"CREATE TABLE t (id INT PRIMARY KEY, a TEXT);","new_sql":"CREATE TABLE t (id INT PRIMARY KEY);"}'
```

---

## Response Envelope & Agent Recovery Playbook

Every `200 OK` call returns:
- `ok` (`true`), `status_code` (`200`), `dossier_id`, `artifact_id`, `domain`, `detected_format`
- `score` (`0..100`), `grade` (`A+`, `A`, `B`, `C`, `D`, `F`), `summary`
- `findings_count` (`{critical, high, medium, low, info, total}`), `findings` (`list[dict]`)
- `artifacts` (compiled Python/TS/Go/Rust SDK source, GraphQL typed client, forward/rollback SQL, AST report, or `mcp.json` + JSON-RPC router)
- `metrics` (`dict`), `cache` (`dict`), `billing` (`dict`), `billed_micros`, `charged_micros`, `billed`
- `sha256_attestation` (64-hex), `zero_data_resale` (`true`), `disclaimer`, `generated_at_utc`

**HTTP `422` Recovery**: When `status_code == 422`, `ok` is `false` and `billed_micros == 0` (`charged_micros == 0`, `billed == false`). Fix the malformed JSON, GraphQL SDL, SQL DDL, Python syntax, or SSRF URL and retry — zero credits were deducted.
