A hybrid web framework and orchestration toolkit that bridges Next.js (TypeScript) with the Xz programming language.
AI-written, Human-reviewed.
Next.js owns the UI and routing shell. Xz owns the backend business logic.
Because Xz makes every behavior explicit — typed contracts, value semantics,
derived effect profiles, structured JSON diagnostics — an AI Agent can generate
backend code safely, self-correct against xz check-json, and hand a human a
one-glance audit instead of a multi-file TS diff.
| Problem | How next.xz answers it |
|---|---|
| TypeScript's escape hatches let LLM output hide side effects and runtime bugs. | Xz requires @intent / @effects at every public boundary and derives the real effect profile from the body. |
| Reviewing AI-generated TS PRs is slow. | A human audits contract badges and a diff on /___audit, not deep code paths. |
| Compiler output is written for humans, not models. | xz check-json emits stable codes, spans, categories, and suggested fixes for a machine self-correction loop. |
Next.js App Router (TS/JS)
│ Server Actions / generated bindings
▼
next.xz ── bridge · agent · audit
│ C ABI / Bun FFI / Wasm
▼
Xz Core (.xz) ── LLVM 17 native / shared library / JIT
See ARCHITECTURE.md for the component contracts and prd.md for the product requirements.
| Package | Role |
|---|---|
@xz-lang/bridge |
Generate TypeScript bindings from .xzint interfaces; load and call Xz shared libraries from Server Actions. |
@xz-lang/agent |
Drive the LLM → xz check-json → repair loop with a bounded retry budget. |
@xz-lang/audit |
Next.js dev overlay at /___audit that renders contract and effect badges for human approval. |
# 1. Write a contract shell (human or agent)
cat > src/logic/order.xz <<'XZ'
/// Computes the payable total for an order.
/// @intent Sums line items and applies the tax rate.
/// @ensures result >= 0.0
/// @effects none
@export func payable_total(subtotal: Float, tax_rate: Float) -> Float
post result >= 0.0
{
subtotal * (1.0 + tax_rate)
}
XZ
# 2. Deterministic verification
xz check-json src/logic/order.xz
# 3. Compile and bind
xz build --shared --out .next-xz/liborder.so src/logic/order.xz
# 4. Call it from a Server Action
# (bindings generated by @xz-lang/bridge)xz here is the Xz language CLI, not XZ Utils. If the two collide on
PATH, point XZ_CLI at the Xz CLI build
(XZ_CLI=path/to/xz-cli/target/release/xz xz check-json …); the runner
resolves it in that order and the root scripts read XZ_CLI. See
docs/02-agent-loop.md.
v0.1.0-draft — design phase. This repository currently holds the PRD,
architecture, and per-subsystem specs. The Xz compiler it targets lives in the
Xz repository; xz check-json,
xz build --shared, xz bind --lang python, and the LSP server are already
implemented there. The TypeScript/Bun bridge, agent loop, and audit UI are the
work this repo tracks.
next-xz/
├── README.md
├── prd.md # Product requirements (authoritative scope)
├── ARCHITECTURE.md # Components, contracts, data flow
├── AGENT.md # Working agreements for contributors/AI
└── docs/
├── 01-bridge.md # FFI + TypeScript binding generation
├── 02-agent-loop.md # Self-correction pipeline
├── 03-audit-ui.md # Human audit interface
├── 04-nfr.md # Non-functional requirements
└── 05-roadmap.md # Phase plan