crafter station / gov-tech · v0.1.6

Mapping SUNAT,
making it agent-ready

Agent-first CLI for Peru's tax authority. CPE emission (UBL 2.1 + XAdES + SOAP), SIRE filing, GRE shipping notices, REST OAuth APIs, RHE/F616 — all under one binary.

$ bun add -g @crafter/sunat-cli

# Install globally
$ bun add -g @crafter/sunat-cli

# Introspect schema (agents self-serve)
$ sunat-cli schema cpe-factura --output json
{ "command": "cpe factura emit", "fields": {...} }

# Always dry-run first
$ sunat-cli cpe factura preview --params @factura.json
{ "dryRun": true, "hash": "sha256:...", "validacion": {"ok": true} }

# Ship it — UBL 2.1 + XAdES + SOAP, end-to-end
$ sunat-cli cpe factura emit --params @factura.json --yes
 Aceptado · CDR 0000 · F001-1234
61%
Agent-ready
9
SUNAT domains
283
Tests passing
0
CAPTCHAs

Everything SUNAT, one command

CPE Emission (Factura, Boleta, NC, ND)

UBL 2.1 + XAdES-BES + SOAP directo a SUNAT. End-to-end verified against beta.

$ sunat-cli cpe factura emit \
  --params '{"serie":"F001",...}' --yes

GRE Remitente (Guía Modal 02)

REST API + JWT. Tracker idempotente, retries con backoff.

$ sunat-cli cpe gre emit \
  --params @guia.json --yes

SIRE RVIE + RCE

Propuesta de ventas/compras, ticket polling, descarga ZIP, importar via TUS 1.0.0.

$ sunat-cli sire rvie propuesta \
  --periodo 202504 --yes

Resumen Diario + Baja

Boletas <S/700 batched, comunicación de baja con ticket polling.

$ sunat-cli cpe resumen send \
  --fecha 2026-04-29 --yes

RHE + F616 (personas naturales)

Browser automation sin CAPTCHA. RHE en batch, F616 mensual via CDP raw.

$ sunat-cli rhe emit --batch ./data.csv

Schema Introspection

Agents self-serve field definitions at runtime. 25+ schemas exposed.

$ sunat-cli schema cpe-factura
# Returns JSON schema of all fields

Padrón RUC + Consulta CPE

REST OAuth2 client_credentials. Padrón sync incremental, lookup local sub-ms.

$ sunat-cli api consulta \
  --tipo 01 --serie F001 --numero 123

Tipo de Cambio SBS

Scrape diario, cache local, fallback a fecha hábil previa.

$ sunat-cli tipo-cambio --fecha hoy
# {compra: 3.752, venta: 3.758}
61%

SUNAT mapped & agent-ready

Per-domain breakdown of how much of each SUNAT surface is wrapped, validated against the beta endpoint, and exposed as an agent-callable command. Green = shipped & verified. Yellow = partial. Orange/Red = shaped or needs production credentials.

REST APIs (Consulta CPE, Padrón, Tipo Cambio)
shipped
90%
RHE + F616 (personas naturales)
shipped
95%
CPE Factura / Boleta / NC / ND
shipped
85%
Resumen Diario + Comunicación de Baja
shipped
80%
SIRE (RVIE Ventas + RCE Compras)
shipped, partial
70%
GRE Remitente + Transportista
modal 02 only
50%
CPE void T3 (intent-token)
shaped
30%
Drivers (mock, sunat-direct, facturador, PSE/OSE)
2 of 5
40%
Producción end-to-end (live)
untested
10%

What's shipping next

Agent DX first

Following Justin Poehnelt's "Rewrite Your CLI for AI Agents" principles and the agentskills.io specification. The agent is not a trusted operator.

--json payloads over flags
--dry-run for all mutations
--output json by default
Schema introspection at runtime
Input hardening against hallucinations
SKILL.md per agentskills.io spec