---
name: compile-anything
description: "Polymorphic commercial software compiler at compile.fastmesh.dev: compile briefs, competitor pricing specs, OpenAPI 3.x / JSON Schemas, CSV/JSON lookup tables, or deterministic Python functions into runnable HTTP/MCP micro-products with Creem billing, Treg Hub 4-file packs, and strict $0 billing on HTTP 422 failures."
---

# Compile-Anything (`compile.fastmesh.dev`) — Agent Integration Skill

Flat, zero-canvas commercial compiler backend for AI coding agents, software factories, and automated product pipelines. Invoke identically via Streamable Remote MCP (`POST /mcp`), REST (`POST /api/compile`), 0%-commission `treg hub` (`compile-anything`), or Causal Bazaar (`hand_any_a06_compile_anything_v1`).

## Key Identifiers & Invariants

- **Domain**: `https://compile.fastmesh.dev` (local default port `8806`)
- **Remote MCP**: `POST https://compile.fastmesh.dev/mcp` (JSON-RPC 2.0)
- **REST Compile**: `POST https://compile.fastmesh.dev/api/compile`
- **Health & Cache Telemetry**: `GET https://compile.fastmesh.dev/health`
- **SKU Catalog**: `GET https://compile.fastmesh.dev/api/skus`
- **Creem Webhook**: `POST https://compile.fastmesh.dev/webhooks/creem` (`creem-signature` HMAC-SHA256)
- **Treg Hub Tool**: `compile-anything` (`0%` platform commission, `$0.15` verified compile)
- **Causal Bazaar Card**: `compile_anything_v1` / `hand_any_a06_compile_anything_v1` (`price_micros: 150000`, cache repeat `15000`)
- **`$0` Failed-Compile Guarantee**: Invalid JSON, broken OpenAPI/CSV schemas, unsafe Python AST calls (`os.system`, `subprocess`, `eval`, `exec`, `socket`, `__import__`, file writes), SSRF/private-IP URLs (`127.0.0.1`, `169.254.169.254`, RFC 1918), and path-traversal slugs return `HTTP 422` with `ok: false` and `billed_micros: 0`.
- **Zero Prompt & Trace Resale**: Inputs and generated bundles are never resold or used to train models. Cross-tenant `ArchiveCache` strips tenant identifiers before hashing specs.

## Supported Input Modes (`input_type`)

| `input_type` | Expected `spec` Payload | Primary Compiled Outputs |
| :--- | :--- | :--- |
| `brief` | Plain-English string or structured brief object (`name`, `title`, `problem`, `price_usd`, `core_operation`) | Runnable `server.py` (REST + `/mcp`), Try-Now UI, Creem SKUs, `treg_hub/`, `gateway_route.json`, `market_kill_clock.json` |
| `competitor` | Public pricing JSON or safe HTTPS URL (`competitor_name`, `competitor_price_usd`, `core_features`) | 5x-cheaper replacement API, side-by-side comparison page (with independent-alternative disclaimer), Creem SKUs |
| `openapi` | OpenAPI 3.x document or JSON Schema Draft 2020-12 object | Metered gateway server, cross-tenant `ArchiveCache`, flat `/mcp` tools derived from operations |
| `table` | CSV string (`csv_data`) or JSON array (`rows`) with `primary_key` | Queryable Data Tollbooth REST + MCP API, interactive Try-Now lookup UI, `treg_hub/` QuickJS pack |
| `python_spec` | Deterministic pure-Python function spec (`function_name`, `source_code`, `sample_input`) | AST-audited paid microservice with `/health`, `/mcp`, `/webhooks/creem`, and `market_kill_clock.json` |

## 1. Streamable Remote MCP (`POST /mcp`)

### Initialize & Discover Tools

```bash
curl -fsSL -X POST "https://compile.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"agent-client","version":"1.0"}}}'

curl -fsSL -X POST "https://compile.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
```

Available MCP tools: `compile_spec`, `preview_bundle`, `verify_bundle`, `list_input_types`, `get_cache_stats`.

### Call `compile_spec` over MCP

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "compile_spec",
    "arguments": {
      "input_type": "table",
      "slug": "us_sales_tax_rates",
      "spec": {
        "name": "us_sales_tax_rates",
        "format": "json",
        "primary_key": "state_code",
        "rows": [
          {"state_code": "CA", "base_rate_pct": 7.25, "nexus_usd": 500000},
          {"state_code": "TX", "base_rate_pct": 6.25, "nexus_usd": 500000},
          {"state_code": "WA", "base_rate_pct": 6.50, "nexus_usd": 100000}
        ]
      },
      "dry_run": false,
      "verify_live": true
    }
  }
}
```

## 2. REST API (`POST /api/compile`)

```bash
# Compile an OpenAPI spec into a verified HTTP + MCP micro-product
curl -fsSL -X POST "https://compile.fastmesh.dev/api/compile" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: tenant_alpha" \
  -H "X-Idempotency-Key: req_20261202_001" \
  -d '{
    "input_type": "openapi",
    "slug": "eu_vat_checker",
    "spec": {
      "name": "eu_vat_checker",
      "openapi": "3.1.0",
      "info": {"title": "EU VAT Checksum Validator", "version": "1.0.0"},
      "paths": {
        "/v1/check": {
          "post": {
            "operationId": "checkEuVat",
            "summary": "Validate EU VAT prefix and invoice totals"
          }
        }
      }
    },
    "dry_run": false,
    "verify_live": true
  }'

# Inspect service health and ArchiveCache hit/miss counters
curl -fsSL "https://compile.fastmesh.dev/health"

# Inspect Creem prepaid SKUs and manifest SHA-256
curl -fsSL "https://compile.fastmesh.dev/api/skus"
```

### Expected Success Response (`HTTP 200`)

Returns `ok: true`, `status_code: 200`, `task_id: "ANY-A06"`, `slug`, `domain` (`<slug>.fastmesh.dev`), `bundle_sha256`, `cache_hit`, `billed_micros`, `file_tree`, `files`, `gateway_route`, `skus`, `mcp_tools`, `treg_hub`, `bazaar_card`, `try_now_html`, and `verification`.

### Expected Rejected Response (`HTTP 422`, `$0` Billed)

```json
{
  "ok": false,
  "status_code": 422,
  "error_code": "UNSAFE_PYTHON_AST",
  "error": "Blocked unsafe AST call: os.system",
  "billed_micros": 0
}
```

## 3. Treg Hub CLI (`0%` Platform Commission)

```bash
treg call compile-anything --data '{
  "input_type": "competitor",
  "slug": "flat_hook_router",
  "spec": {
    "competitor_name": "Zapier Team Webhooks",
    "competitor_price_usd": 103.5,
    "core_features": ["HMAC verification", "JSON payload reshaping", "Idempotent retries"]
  },
  "verify_live": true
}'
```

## 4. Prepaid Creem Credit Packs (Non-Expiring)

- **Starter Pack** (`sku_compile_starter_9` / `prod_compile_starter_9`): `$9` for 50 compiles (`$0.1800`/compile) — https://www.creem.io/checkout/prod_compile_starter_9
- **Pro Pack** (`sku_compile_pro_29` / `prod_compile_pro_29`): `$29` for 250 compiles (`$0.1160`/compile) — https://www.creem.io/checkout/prod_compile_pro_29
- **Scale Pack** (`sku_compile_scale_99` / `prod_compile_scale_99`): `$99` for 1,200 compiles (`$0.0825`/compile) — https://www.creem.io/checkout/prod_compile_scale_99
