Toolchain CLI
X07 ships multiple small CLIs with JSON-first contracts so both humans and agents can drive it deterministically.
Key commands
New project skeleton
x07 init- Creates
x07.json(withos/sandboxprofiles),x07.lock.json, a minimalsrc/program, and atests/harness (tests/tests.json).
- Creates
x07 init --package- Creates a publishable package repo:
x07-package.json, a minimalx07.json+x07.lock.json, publishablemodules/layout, and a CI-friendlytests/tests.json. - Not compatible with
--template(templates are for app scaffolds).
- Creates a publishable package repo:
MCP kit tooling
x07 mcp [ARGS...]- Delegates to
x07-mcpon PATH. - Delegated commands exit with code
2ifx07-mcpis not installed/discoverable.
- Delegates to
- Common subcommands (provided by
x07-mcp):x07 mcp registry gen --in <x07.mcp.json> --out <server.json> [--mcpb <file>] [--schema <schema.json>]x07 mcp publish --dry-run --server-json <server.json> --mcpb <file>x07 mcp conformance --url <url> [--baseline <path>] [--spawn <server-id> --mode <noauth|oauth>]x07 mcp bundle --mcpb --server-dir <servers/<id>> [--out <dist/...mcpb>]
x07 init --template mcp-server|mcp-server-stdio|mcp-server-http|mcp-server-http-tasks- Delegates template generation to
x07-mcp scaffold init ... --machine json. - Creates the agent kit and a worker base policy at
.x07/policies/base/worker.sandbox.base.policy.json.
- Delegates template generation to
WASM tooling (Phases 0–3)
x07 wasm [ARGS...]- Delegates to
x07-wasmon PATH. - Delegated commands exit with code
2ifx07-wasmis not installed/discoverable.
- Delegates to
- Common subcommands (provided by
x07-wasm):x07 wasm doctorx07 wasm buildx07 wasm runx07 wasm profile validatex07 wasm cli specrows checkx07 wasm wit validatex07 wasm component profile validatex07 wasm component buildx07 wasm component composex07 wasm component targetsx07 wasm servex07 wasm component runx07 wasm web-ui contracts validatex07 wasm web-ui profile validatex07 wasm web-ui buildx07 wasm web-ui servex07 wasm web-ui testx07 wasm web-ui regress-from-incidentx07 wasm app contracts validatex07 wasm app profile validatex07 wasm app buildx07 wasm app servex07 wasm app testx07 wasm app regress from-incident
See: WASM (Phases 0–3).
Doctor (platform prerequisites)
x07 doctor- Checks host prerequisites for OS worlds (C compiler + common native deps).
- Emits a JSON report to stdout.
Guide (built-in language + stdlib reference)
x07 guide- Prints the built-in language + stdlib reference guide (Markdown).
Formatting (x07AST JSON)
x07 fmt --check <path>...x07 fmt --write <path>...x07 fmt --input <path> --checkx07 fmt --input <path> --write
--input may be repeated. Positional <path> inputs may also be repeated. Each <path> may be a file or a directory; directory inputs are scanned recursively for *.x07.json.
Assets (embed files)
x07 assets embed-dir --in <dir> --module-id <module_id> --out <path>- Generates an
.x07.jsonmodule that embeds all matching files under<dir>as base64 payloads. - Useful for shipping templates or other static assets inside bundled OS-world CLIs (similar to Rust
include_bytes!).
- Generates an
Linting + diagnostics (x07diag JSON)
x07 lint --input <path>- Prints an
x07diagJSON report to stdout.
- Prints an
x07 fix --input <path> --write- Applies quickfixes (JSON Patch) and rewrites the file deterministically.
x07 fix --from-pbt <repro.json> --write- Converts a PBT repro artifact into a deterministic regression test (wrapper module + manifest entry).
See: PBT repro → regression test.
AST slicing (deterministic context views)
x07 ast slice --in <path> --ptr <json_pointer> [--enclosure decl|defn|module] [--closure locals|types|imports|all] [--max-nodes N] [--max-bytes BYTES]- Emits a minimal, semantically-closed x07AST slice around
--ptr(plusslice_metadescribing omissions, remaps, and truncation). - Pointers refer to the canonical x07AST view (run
x07 fmtor use pointers produced by toolchain diagnostics). - If the focus decl is re-indexed to
decls[0],slice_meta.ptr_remap[]records the pointer rewrite. - If bounds force truncation,
slice_meta.truncated=trueand diagnosticX07-AST-SLICE-0001is emitted. - With global
--out <path>, writes the canonicalslice_astto<path>and omits it from the stdout report to avoid duplication. - Tool wrapper schema (
--json):spec/x07-tool-ast-slice.report.schema.json(schema_version: "x07.tool.ast.slice.report@0.1.0").
- Emits a minimal, semantically-closed x07AST slice around
AST editing (targeted structural edits)
x07 ast edit insert-stmts --in <path> --defn <name> --stmt-file <path> [--stmt-file <path>...] [--validate]- Inserts statement expression(s) into a single function body by name (decl
kind=defn|defasync).
- Inserts statement expression(s) into a single function body by name (decl
x07 ast edit insert-stmts --in <path> --ptr <json_pointer> --stmt-file <path> [--stmt-file <path>...] [--validate]- Uses a JSON Pointer target directly.
- If the target is a
["begin", ...]body, inserts statements before the tail expression. - Otherwise rewrites the body to
["begin", <stmts...>, <original_expr>].
x07 ast edit apply-quickfix --in <path> --ptr <json_pointer> [--code <diag_code>] [--validate]- Applies exactly one lint quickfix (JSON Patch) selected by pointer (and optional diagnostic code).
All edit commands write canonical one-line JSON. With global --out <path>, they write to that path; otherwise they edit in place.
Agent context packs
x07 agent context --diag <path> --project <path> [--enclosure ...] [--closure ...] [--max-nodes ...] [--max-bytes ...]- Produces a deterministic, portable context artifact (
schema_version: "x07.agent.context@0.1.0") that embeds:- the diagnostics (focus = first
severity=error, else first), - an AST slice of the project entry module at the focused diagnostic pointer,
- input digests for traceability.
- the diagnostics (focus = first
--diagaccepts either rawx07diag(x07.x07diag@0.1.0) or a tool wrapper report (x07.tool.*.report@0.1.0); diagnostics are extracted deterministically.- With global
--out <path>, writes the canonical context pack JSON to<path>and prints nothing to stdout. - Artifact schema:
spec/x07-agent.context.schema.json. - Tool wrapper schema (
--json):spec/x07-tool-agent-context.report.schema.json(schema_version: "x07.tool.agent.context.report@0.1.0").
- Produces a deterministic, portable context artifact (
Architecture check (repo contracts)
x07 arch check- Verifies the repo’s
*.x07.jsonimport graph againstarch/manifest.x07arch.json. - Emits an
x07.arch.report@0.1.0report and optional JSON Patch suggestions.
- Verifies the repo’s
See: Architecture check.
Review artifacts (semantic diff)
x07 review diff --from <path> --to <path> --html-out <path>x07 review diff --from <path> --to <path> --html-out <path> --json-out <path>- Produces an intent-level semantic diff for x07AST/project/arch/policy changes.
- Supports CI gates via
--fail-on world-capability|budget-increase|allow-unsafe|allow-ffi. - JSON schema:
spec/x07-review.diff.schema.json(schema_version: "x07.review.diff@0.1.0").
See: Review & trust artifacts.
Trust artifacts (CI security posture summary)
x07 trust report --project x07.json --out <path>x07 trust report --project x07.json --profile sandbox --out <path> --html-out <path>- Emits a machine-readable trust summary (budgets/caps, declared+used capabilities, nondeterminism flags, deterministic SBOM artifacts).
- Supports observed merges via
--run-report,--bundle-report,--x07test. - SBOM output:
--sbom-format none|cyclonedx|spdx(default:cyclonedx) writes*.sbom.cdx.json(or*.sbom.spdx.json) next to the trust report output. - Dependency capability policy:
--deps-cap-policy <path>(safe relative path) + CI gate--fail-on deps-capability. - Supports CI gates via
--strictand--fail-on .... - JSON schema:
spec/x07-trust.report.schema.json(schema_version: "x07.trust.report@0.1.0").
See: Review & trust artifacts.
Diagnostics catalog / coverage
x07 diag catalog --catalog catalog/diagnostics.json --format both- Validates
catalog/diagnostics.jsonagainstx07.diag.catalog@0.1.0. - Emits canonical JSON and generated docs (default:
docs/toolchain/diagnostic-codes.md).
- Validates
x07 diag check- Scans source diagnostic codes and fails on catalog drift.
- Writes extracted scan data to
target/x07diag/extracted_codes.json.
x07 diag coverage- Emits
x07.diag.coverage@0.1.0quickfix coverage report JSON. - Supports threshold gating with
--min-coverage.
- Emits
x07 diag explain <CODE>- Prints summary, origins, quickfix policy, and agent strategy for one code.
x07 diag sarif --in <x07diag.json> --out <results.sarif>- Converts
x07diagto SARIF v2.1.0 for code-scanning UIs.
- Converts
Patching (RFC 6902 JSON Patch)
x07 ast apply-patch --in <path> --patch <patch.json> --out <path> --validatex07 patch apply --in <patchset.json> --repo-root . --write- Applies a multi-file patchset (
schema_version: "x07.patchset@0.1.0"). - Without
--write, validates and reports only (dry run).
- Applies a multi-file patchset (
x07AST schema + grammar generation pack
x07 ast schema- Emits the canonical
x07ast.schema.jsondocument on stdout (raw JSON bytes + trailing newline).
- Emits the canonical
x07 ast schema --out <path>- Writes the schema document bytes to file.
x07 ast schema --pretty --out <path>- Writes a pretty-printed schema document to file.
x07 ast grammar --cfg- Emits a machine-readable grammar bundle JSON:
schema_version: "x07.ast.grammar_bundle@0.1.0"variants[](min,pretty) with GBNF contentsemantic_supplement- per-artifact sha256 hashes
- Emits a machine-readable grammar bundle JSON:
x07 ast grammar --cfg --out-dir <dir>- Materializes:
x07ast.schema.jsonx07ast.min.gbnfx07ast.pretty.gbnfx07ast.semantic.jsonmanifest.json
- Materializes:
Cookbook integrations:
Testing (x07test JSON)
x07 test --manifest tests/tests.json- Runs each test in its declared world.
- Prints an
x07testJSON report (or writes it with--report-out).
x07 test --pbt --manifest tests/tests.json- Runs property-based tests only (entries where
pbtis set).
- Runs property-based tests only (entries where
x07 test --all --manifest tests/tests.json- Runs both unit tests and property-based tests.
x07 test --pbt --pbt-repro <repro.json> --manifest tests/tests.json- Replays exactly one counterexample artifact (single test + single case).
See: Property-based testing.
Verification (contracts)
x07 verify --bmc --entry <sym>x07 verify --smt --entry <sym>--project <path>(or one/more--module-root <dir>)--unwind <n>(CBMC loop unwinding bound)--max-bytes-len <n>(bound forbytes/bytes_viewparams)
Notes:
- v0.1 verifies only a selected subset:
defntargets only (nodefasync), no recursion, andforloops must have literal bounds. - v0.1 supports params:
i32,u32,bytes,bytes_view(use a wrapper if you need other types). x07 verifyrequires at least one contract clause (requires/ensures/invariant) on the target function.- Artifacts are written under
.x07/artifacts/verify/<mode>/<entry>/(driver module, emitted C, CBMC output, counterexample/SMT artifacts when present).
Report schema: spec/x07-verify.report.schema.json (schema_version: "x07.verify.report@0.1.0").
Agent correctness benchmarks (x07bench JSON)
x07 bench list --suite labs/x07bench/suites/core_v1/suite.jsonx07 bench validate --suite labs/x07bench/suites/core_v1/suite.jsonx07 bench eval --suite labs/x07bench/suites/core_v1/suite.json --predictions <predictions.jsonl>x07 bench eval --suite labs/x07bench/suites/core_v1/suite.json --oraclex07 bench eval --suite labs/x07bench/suites/core_v1/suite.json --oracle --runner docker
Reports use schema_version: "x07.bench.report@0.1.0".
See: Benchmarks.
Doc (module exports)
x07 doc <module-id>x07 doc <module-id>.<exported_symbol>- Prints exported symbol signatures from a module file (useful for agents exploring unfamiliar modules).
x07 doc --json <query>- Emits a stable machine-readable report (
schema_version: "x07.doc.report@0.1.0"). - Exit codes:
0onok=true1onok=false(for example: not found or query errors)2on tool failures (for example: filesystem read/write errors)
- Emits a stable machine-readable report (
x07 doc --json <query> --report-out <path> --quiet-json- Writes the JSON report to a file and suppresses stdout.
x07 doc --json spec:<path-or-id>- Resolves published spec docs and schemas via
docs/spec//.agent/docs/spec/.
- Resolves published spec docs and schemas via
Doc report schema: docs/spec/schemas/x07-doc.report.schema.json.
Schema derive (generate modules + tests)
x07 schema derive --input <schema.x07schema.json> --out-dir <dir> --writex07 schema derive --input <schema.x07schema.json> --out-dir <dir> --checkx07 schema derive --json ...
See: Schema derive.
State machines (generate step functions + tests)
x07 sm check --input <sm.json>x07 sm gen --input <sm.json> --out <dir> --writex07 sm gen --input <sm.json> --out <dir> --check
See: State machines.
Packages (pack/lock/publish)
x07 pkg add <name>x07 pkg add <name> --syncx07 pkg add <name>@<version>x07 pkg add <name>@<version> --syncx07 pkg remove <name>x07 pkg remove <name> --syncx07 pkg versions <name>x07 pkg lock --project x07.jsonx07 pkg provides <module-id>x07 pkg pack --package <dir> --out <path>x07 pkg login --index <registry_url>x07 pkg publish --package <dir> --index <registry_url>
Notes:
x07 pkg add <name>@<version>editsx07.jsononly (no network) unless you pass--sync.x07 pkg add <name>consults the index to resolve a version (network unless you use a file-based index).x07 pkg lockuses the official registry index by default when fetching is required; override with--indexor use--offline.- Use
x07 pkg lock --project x07.json --checkin CI to fail ifx07.lock.jsonis out of date. - When the index can be consulted,
x07 pkg lock --checkalso fails on yanked dependencies and active advisories unless you explicitly allow them (--allow-yanked/--allow-advisories). - For transitive dependency overrides, use
project.patchinx07.json(canonical manifest schema:x07.project@0.3.0;x07.project@0.2.0is accepted for legacy manifests but does not supportproject.patch). - Some packages may declare required helper packages via
meta.requires_packages. When present,x07 pkg lockmay add them tox07.jsonbefore locking; do not rely on this for correctness (prefer the capability map and templates, which list the full canonical set explicitly).
Project check (no emit)
x07 check --project x07.json- Reads
x07.json+x07.lock.jsonand resolves the full module import graph (including locked dependencies). - Runs schema validation + lint + project-wide typecheck + backend-check.
- Non-mutating: does not run the repair loop and does not write source files.
- Does not emit C and does not invoke any native compiler.
- Emits an
x07diagJSON report to stdout (or writes it with global--out).
- Reads
Tool wrapper schema (--json): spec/x07-tool-check.report.schema.json (schema_version: "x07.tool.check.report@0.1.0").
Build to C (project)
x07 build --project x07.json --out build/program.c- Reads
x07.json+x07.lock.json. - Uses
x07.jsonmodule_rootsplus locked dependency module roots (from the lockfile).
- Reads
x07 build --project x07.json --out build/program.c --emit-c-header build/x07.h --freestanding- Emits an embeddable
x07_solve_v2entry point.
- Emits an embeddable
See: Embedding in C.
Bundle a native executable (distribution)
x07 bundle --project x07.json --profile os --out dist/mytool- Produces a native CLI executable (standard
argc/argv, raw stdout). - Runs without the X07 toolchain installed at runtime.
- Produces a native CLI executable (standard
x07 bundle --project x07.json --profile sandbox --out dist/mytool- Bundles a VM-backed sandbox bundle by default (requires a base policy via profile or
--policy). - To emit a legacy policy-only bundle (weaker isolation), add:
--sandbox-backend os --i-accept-weaker-isolation.
- Bundles a VM-backed sandbox bundle by default (requires a base policy via profile or
Bundle report schema: spec/x07-bundle.report.schema.json (schema_version: "x07.bundle.report@0.2.0").
Running programs (canonical)
Use x07 run as the canonical entry point for execution. Prefer intent-driven profiles (x07.json.default_profile + x07.json.profiles) so most invocations look like:
x07 runx07 run --profile osx07 run --profile sandbox
x07 run runs the canonical auto-repair loop by default (format → lint → quickfix, repeatable). Control it with:
x07 run --repair=offx07 run --repair=memoryx07 run --repair=write(default)
For the complete guide (targets, worlds, input, policies, reports), see Running programs.
JSON outputs (agent-friendly)
All command scopes support machine schema discovery:
x07 <scope> --json-schemax07 <scope> --json-schema-id
Machine report output:
x07 <scope> --jsonx07 <scope> --json=prettyx07 <scope> --jsonlx07 <scope> --json --report-out <path>x07 <scope> --json --report-out <path> --quiet-jsonx07 <scope> --out <path>(redirect primary output, when applicable)
Schemas:
- Tool report base schema:
spec/x07-tool.report.schema.json(schema_version: "x07.tool.report@0.1.0") - Tool report per-scope schemas:
- Root:
spec/x07-tool-root.report.schema.json - Wrapped scopes:
spec/x07-tool-<scope>.report.schema.json(schema_version: "x07.tool.<scope>.report@0.1.0") x07 doc(native):spec/x07-doc.report.schema.json(schema_version: "x07.doc.report@0.1.0")
- Root:
- JSONL events schema:
spec/x07-tool.events.schema.json(schema_version: "x07.tool.events@0.1.0")
Structured commands must guarantee:
- valid JSON
- schema-valid output
- stable ordering (canonical JSON writer)
Review/trust artifact commands also follow this contract:
x07 review diffx07 trust report
For machine-first discovery and debugging:
x07 --cli-specrowsemits a deterministic CLI surface description.--report-jsonis accepted as a hidden alias for--jsonduring migration.
See Diagnostics & repair.
Programmatic CLI discovery (--cli-specrows)
Agents should not scrape --help text. Use --cli-specrows:
x07 --cli-specrowsx07c --cli-specrowsx07-os-runner --cli-specrows
Output is a single JSON object:
schema_version: "x07cli.specrows@0.1.0"rows: [...](a flat, ordered table describing the CLI surface)
Each row is a small tuple. Examples:
["root","help","-h","--help","Print help"]["root","version","","--version","Print version"]
Schema: spec/x07cli.specrows.schema.json.
Legacy alias (--report-json)
Compatibility mode is still available for existing automation:
x07 <scope> --report-jsonis equivalent tox07 <scope> --json(same report schema + output shape).
Notes:
x07 lintwithout--jsonprints the raw diagnostics report (x07diag, seespec/x07diag.schema.json).x07 fixwithout--jsonprints the fixed x07AST JSON to stdout unless--writeis set.x07 fix --suggest-genericsemits a suggestedx07.patchset@0.1.0to stdout (or--out <PATH>in--jsonworkflows).
Agent bootstrap recipe
Canonical minimal sequence (keep the loop simple; prefer x07 run):
- Discover CLIs:
x07 --cli-specrows - Iterate:
x07 run(auto-repair by default; use--repair=offwhen debugging) - Validate whole project (non-mutating):
x07 check --project x07.json - Validate behavior:
x07 test - Debug/repair explicitly (when needed):
x07 fmt/x07 lint/x07 fix/x07 ast apply-patch
See: Agent quickstart.