Skip to main content

Crate keel_cli

Crate keel_cli 

Source
Expand description

keel — the command-line face of the product (dx-spec §1–2, §5–6).

Subcommands: run (dispatch a script into a language front end), init (evidence-merged policy generation), doctor (the honesty report; --effective-policy prints the composed defaults < packs < user policy via effective), status (the “what is Keel doing for me” screen), explain (the frozen error taxonomy), tail (the live Tier 1 event view), fsck (journal integrity check/repair and retention pruning), the Tier 2 flow inspectors flows (list durable flows), flows::trace (keel trace), and replay (keel replay — a journal-driven dry run of what a re-entry would substitute vs. re-execute), mcp (keel mcp: the CLI doubles as an MCP server over stdio whose six tools return the same bytes as the corresponding --json twins), and the Level 2 on-ramp flows_suggest (keel flows suggest, a replay-safety analysis over candidate entrypoints), flows_add (keel flows add <entrypoint>, one-command durability designation), resume (keel flows resume — actually re-invoke a resumable flow’s recorded entrypoint through keel run), and force (keel flows force — arm the durable one-shot KEEL-E033 override, the out-of-process equivalent of keel exec --force).

Every command obeys the DX invariants: a --json twin with byte-deterministic output (sorted keys, no wall-clock timestamps), and stable exit codes — EXIT_OK, EXIT_FAILURE, EXIT_USAGE. The command modules are the testable core; main is a thin clap front.

Modules§

agents_cli
Detection for Google’s agents-cli project layout.
diff
Applyable policy diffs — “diffs as the lingua franca” (dx-spec §5).
doctor
keel doctor — the honesty report (dx-spec §2).
effective
keel doctor --effective-policy — show the composed policy the core is given (the defaults/E005 CCR: front ends and CLI compose defaults < packs < user before keel_configure; the core layers no pack underneath, contracts/core-ffi.h).
exec
keel exec --flow <name> -- <program> [args…] — wrap one external command as a journaled Tier-2 durable flow (CCR-4).
explain
keel explain <code> — the frozen error taxonomy, for humans and agents.
flows
keel flows and keel trace <flow> — the Tier 2 durable-flow inspectors (dx-spec §6; architecture spec §4.3–4.4).
flows_add
keel flows add <entrypoint> — one-command durability designation (dx-spec §1 Level 2: “Durability, still config-only”).
flows_suggest
keel flows suggest — replay-safety analysis over candidate flow entrypoints (dx-spec §1 Level 2: “Durability, still config-only”).
force
keel flows force <FLOW> — arm the durable one-shot KEEL-E033 force override (CCR-5 decision 2 / CCR-6) for one flow.
fsck
keel fsck — journal integrity check, safe repairs, and retention pruning (architecture spec §6: “journal corruption → SQLite WAL recovery, plus keel fsck”).
init
keel init — evidence-merged policy generation (dx-spec §1, Level 1).
mcp
keel mcp — the CLI doubles as an MCP server for coding agents (dx-spec §5).
record
keel record — capture effects during a run, then turn the capture into an offline replay fixture + generated test glue (dx-spec §6 standing structure item 5; docs/recording-format.md).
render
Output rendering: the one place JSON is serialized, so every command’s --json twin is byte-deterministic the same way.
replay
keel replay <flow> — journal-driven replay inspection (architecture spec FR6; dx-spec §5–6).
resume
keel flows resume <FLOW> [-- ARGS…] / keel flows resume --all — re-invoke a resumable flow’s recorded entrypoint through keel run semantics (architecture spec §4.3 “Recovery … re-execute”; §6 laptop model “a crashed script resumes when re-invoked”).
run
keel run <script> [args…] — dispatch a program into its language front end.
scan
Static scanning — the first of the three evidence sources behind keel init and keel doctor (dx-spec §2). No code runs: we read the project’s source and find where effects enter.
sim
keel sim <plan> — fault/latency/crash-restart simulation over a declarative plan (docs/sim-format.md; architecture-spec §8: v1 scope is ADAPTER-LEVEL fault injection, not full hermetic/wasmtime determinism).
status
keel status — the “what is Keel doing for me” screen (dx-spec §6).
tail
keel tail — the live view of what Keel is doing for a running program: attempts, backoff waits, breaker open/half-open/close, rate-limit queueing, cache hits (dx-spec §6 — “the conversion moment”).

Structs§

Rendered
A fully rendered command result: the two audiences (human prose and the json twin) plus the exit code the process should carry. Commands build one of these; emit prints the right half and the caller exits.

Constants§

EXIT_FAILURE
The underlying program or verb failed (a run’s child exited non-zero, an error surfaced by the report). Distinct from a usage problem.
EXIT_OK
Success. The command did what was asked.
EXIT_USAGE
A usage or policy error: bad arguments, an unknown error code, an invalid keel.toml. The caller must fix the request or the policy.