Skip to main content

Crate logicaffeine_cli

Crate logicaffeine_cli 

Source
Expand description

§logicaffeine-cli

largo is the LOGOS build tool, and it works the way Cargo does for Rust: one Largo.toml manifest and one binary that takes a project from largo new to a package in the registry. Running a program, translating English to first-order logic, checking a proof, solving a SAT instance and serving a website are all subcommands of that one tool, so there is one front door to learn rather than one per job. Rust is optional: only the compiled build goes through cargo, while the interpreter, the logic and proof commands and --emit wasm run without a Rust toolchain.

Part of the Logicaffeine workspace, tier 6. The crate ships one binary, largo, over the logicaffeine_cli library; the JIT links only on x86-64 System V (Linux and macOS), and Z3 verification sits behind the verification feature.

§Getting started

curl -fsSL https://logicaffeine.com/install.sh | sh

Windows, in PowerShell: irm https://logicaffeine.com/install.ps1 | iex. The installer fetches the prebuilt binary for Linux or macOS (x64 and arm64) or Windows x64 and checks its SHA-256 against the release’s SHA256SUMS. On Linux and macOS it installs to ~/.local/bin, with no sudo and no shell-config edits. curl -fsSL https://logicaffeine.com/install.sh | sh -s -- --full installs the flavor with Z3 verification statically linked, which largo --version reports as (full). From source: cargo install logicaffeine-cli.

Then make a project and run it:

largo new hello && cd hello
largo run --interpret   # runs in-process, no Rust toolchain needed
largo run               # compiles to Rust and builds with cargo, so it needs Rust
largo doctor            # reports what this machine has: cargo, the wasm32 target, node, verification, the registry

largo build needs Rust for the same reason largo run does; largo build --emit wasm does not.

§Role in the workspace

largo is the user-facing end of the LOGOS pipeline. Every command lives in the library crate logicaffeine_cli, and the binary (src/main.rs) is one call to largo_main(). That function runs run_cli on a worker thread whose stack is sized from the AST depth limit, renders errors in the error:/help: style, and exits 0 on success, 1 on failure and 2 on a usage error. A command may set its own code: sat uses the SAT Competition’s 10/20, run exits 122 when its --max-steps budget runs out and 124 when its --timeout expires, and lean import exits 0–5 by outcome and 64 for usage.

On x86-64 System V, largo_main installs EXODIA, the copy-and-patch JIT, process-wide before dispatch, so the bytecode VM tiers hot functions and hot loops up to native code. LOGOS_NO_JIT=1 skips the install and leaves the VM on its own; on Windows, aarch64 and wasm32 the JIT is not linked.

A project is a directory with a Largo.toml manifest: [package] (name, version, description, authors, an entry that defaults to src/main.lg, and site, a website’s public address), [dependencies] keyed by version, path or git, and optional [test] and [web] sections. build generates a Cargo crate under target/<mode>/build and publishes the binary at target/<mode>/<name>. The generated crate depends on the runtime (logicaffeine-data, logicaffeine-system with full and http, and tokio): path dependencies on staged sources inside a checkout, and the exact crates.io release of this largo everywhere else. Release builds get LTO, opt-level = 3, one codegen unit, panic = "abort" and stripping, plus target-cpu=native unless cross-compiling. Cargo’s own colored progress streams through live, and a failure is classified as a ## Requires dependency problem or a compiler bug in the generated Rust, then framed to match.

Every flag and environment variable is documented in docs/cli.md.

§Commands

The subcommands of the clap Commands enum in src/cli.rs, each dispatched by run_cli to a handler in src/commands/:

CommandPurpose
new <name> / initScaffold a project (Largo.toml, src/main.lg, .gitignore); --site scaffolds a static site, --web a full-stack one
buildCompile .lg to Rust, then cargo build it with cargo’s output streamed live; --emit c builds the same executable through C and the system C compiler; --emit wasm uses the direct backend instead; a site exports to dist/
run [args…]Build and execute; -i/--interpret runs the program in-process with no Rust build
serveServe the project over HTTP (a site, a full-stack site, or a backend) with --watch live reload
checkParse and type-check the entry and every page without producing a binary; --json for agents
test [filter]Run the project’s ## Test blocks, each in an isolated world, with a deterministic report
replay <bundle>Re-run a recorded .replay bundle: reproduced, fixed, or diverged
bringup <checkpoint>Bring a model (a GGUF file or a Hugging Face directory) up on every chip from its one program: the CPU tiers, the CUDA lane, the D5005 decode engine, the SN50 and the fabric, each artifact naming the cut of the program it was lowered from; --run runs it on every chip here — a prompt, or every prompt of a golden with --prompts — and reports tokens, speed and agreement
expand <file>Show the functions an LGX page’s components, actions and routes lower to (LGX is the LOGOS web framework)
replInteractive session: imperative statements plus English→FOL logic mode (:help inside)
dapDebug a program over the Debug Adapter Protocol on stdio, reverse execution included (stepBack, reverseContinue); it serializes the same DebugSession the Studio’s debugger renders
explain <topic>Look up a diagnostic code or a construct, offline
mcpServe the toolchain to AI agents over the Model Context Protocol (stdio)
logic [sentence]English → first-order logic (--format unicode|latex|ascii|kripke, --all-readings, --discourse)
prove [file]Kernel-certified proving of ## Theory developments and ## Theorem blocks (--trace, --json)
sat <file.cnf>The certified SAT solver; --proof writes a DRAT (or DPR/SR) refutation; exits 10/20
lean import / lean replayImport a Lean 4 declaration as a checked LOGOS package, or re-verify a published one
fmt [paths…]Format sources with the canonical rules the language server uses; --check for CI
emit <target>Print or write a compiled translation without building a binary (every target: docs/cli.md)
doc [--out DIR]Generate markdown documentation from a project’s ## blocks
add <spec> / remove <name>Edit Largo.toml dependencies, preserving its formatting (toml_edit)
clean [--all]Remove target/ (and .logos-native/ with --all)
opts <file>Report which optimizations fired for a .lg file
verifyRun Z3 static verification only (Pro license or above; verification feature)
completions <shell>Shell completion scripts (bash, zsh, fish, powershell, elvish)
doctorDiagnose the environment: whether largo is current, cargo, the wasm32 target, node for --emit wasm, the verification flavor, the registry and stored credentials, and manifest health; works offline
publish / login / logoutRegistry packaging, upload, and credentials

Global flags on every command: -q/--quiet, -v/--verbose, --color auto|always|never (NO_COLOR is respected). The environment variables (LOGOS_NO_JIT, LOGOS_TOKEN, LOGOS_CREDENTIALS_PATH) are documented in docs/cli.md. Default registry: https://registry.logicaffeine.com.

§Public API

The binary is a thin shell over the logicaffeine_cli library, which exposes:

  • largo_main() — the whole largo process: the native tier, the sized worker, error rendering, the exit code. run_cli() parses argv and dispatches (also cli::{Cli, Commands}).
  • ui::{CliError, render_error, ColorMode} and the exit-code constants — the error and exit contract shared with the binary.
  • project::{BuildConfig, BuildResult, BuildError, CargoFailure, CargoFailureKind, classify_cargo_failure, build, run, find_project_root} — build orchestration.
  • project::{Manifest, ManifestError} — Largo.toml parse and serialize.
  • project::{RegistryClient, create_tarball, is_git_dirty} — registry client and publishing.
  • project::{Credentials, get_registry_token} — credential storage and token lookup.
  • project::{Loader, ModuleSource} — the module loader, re-exported from the compile crate.
  • project::shape / project::deps — the project-shape classifier and the dependency resolver.
  • compile::* (including compile_project), plus the re-exports interface (kernel) and analysis (compile) for external tooling.
  • dap::DapServer — the pure DAP transition behind largo dap (handle: one request in, responses and events out).
  • mcp::{McpServer, cmd_mcp} — the MCP server behind largo mcp. Its pure handle_line JSON-RPC transition serves the check/run/logic/prove/emit/opts tools and the embedded learning-corpus resources; agents register it with claude mcp add logos -- largo mcp.
  • browser::{Browser, Page, PageBundle, Snapshot, ChromeLauncher} — the headless-Chrome page tier behind largo test --browser. It is a DevTools-protocol client over --remote-debugging-pipe that serves a built page from a loopback HTTP server, then drives it with trusted input events, virtual time, stubbed fetches, a host-call trace and canonical document snapshots. ChromeLauncher adapts it to page_host::RemotePageLauncher, the seam that largo test --browser and the tree-walker/VM/Chrome corpus lock drive.

§Source layout

src/
├── main.rs        # `largo` binary: exactly `largo_main()`
├── lib.rs         # public API surface, `largo_main`, the web-serving helpers
├── cli.rs         # Cli / Commands parser + dispatch
├── ui.rs          # CliError, exit codes, color state, clap palette, phase headers
├── diagnostics.rs # every diagnostic placed in the author's file: terminal, `--json`, dev-server overlay
├── closure.rs     # the entry's assembled import closure (and the files behind it) every command compiles
├── commands/      # one module per verb (build, run, logic, prove, sat, fmt, …)
├── repl/          # the interactive session: loop, meta-commands, multiline, editor
├── mcp/           # `largo mcp`: the Model Context Protocol server (JSON-RPC/stdio, tools, resources, run sandbox)
├── dap/           # `largo dap`: the Debug Adapter Protocol server over `DebugSession`
├── browser/       # the headless-Chrome page tier behind `largo test --browser`
├── compile.rs     # re-export of logicaffeine_compile::compile::*
└── project/
    ├── manifest.rs    # Largo.toml: Manifest, Package, DependencySpec
    ├── build.rs       # build orchestration: BuildConfig → BuildResult (+ cargo failure classifier)
    ├── deps.rs        # `[dependencies]` path and git (exact rev) entries → the loader's dependency roots
    ├── shape.rs       # project shape: program, backend, site, or full-stack site
    ├── registry.rs    # RegistryClient + tarball packaging
    └── credentials.rs # token storage / lookup
assets/agent/          # the agent pack `largo mcp` embeds as resources (quick guide, docs, examples)
templates/AGENTS.md    # the agent guide `largo new` writes into a project

§Feature flags

FeatureDefaultEnables
verificationofflargo verify against the system Z3 (dynamic link): the optional logicaffeine-verify dependency plus verification in logicaffeine-compile and logicaffeine-proof.
verification-staticoffverification with Z3 built from its vendored source and statically linked (logicaffeine-verify/static-link-z3): the release largo-full flavor. Needs cmake, a C++ toolchain and libclang.

Without either feature, largo verify is a stub that points at the --full installer. largo --version reports (full) when verification is compiled in.

§Dependencies

  • Internal: logicaffeine-base, logicaffeine-kernel (lean), logicaffeine-language, logicaffeine-compile (wasm-jit), logicaffeine-proof (sat/prove), logicaffeine-system; logicaffeine-verify (optional, verification); plus logicaffeine-jit under cfg(all(target_arch = "x86_64", not(target_os = "windows"))) for the native JIT tier.
  • Command line: clap + clap_complete (argument parsing, completions), anstream + anstyle (color that strips itself on pipes and honors NO_COLOR), rustyline (REPL line editing), futures (block_on for interpret and the REPL), rand.
  • Projects and the registry: toml + toml_edit + serde (manifest read and edit), ureq + serde_json (registry HTTP and JSON), flate2 + tar (publish tarballs), dirs (config-dir resolution).
  • Headless Chrome: base64 (CDP fetch bodies) and libc on Unix (the Chrome pipe).
  • Dev: tempfile, libc.

§License

MIT License — see LICENSE.md.


Docs index · Root README · Changelog

Re-exports§

pub use cli::run_cli;

Modules§

analysis
Re-export of analysis utilities from the compile crate.
browser
A real browser as a page tier: headless Chrome, driven over the DevTools protocol.
cli
LOGOS CLI (largo) — argument parsing and dispatch.
compile
LOGOS Compilation Pipeline for CLI
dap
largo dap — the LOGOS debugger served over the Debug Adapter Protocol.
interface
Re-export of the LOGOS interface types from the kernel crate.
mcp
largo mcp — the LOGOS toolchain served over the Model Context Protocol.
project
Phase 36/37/39: Project Module System
ui
Terminal output substrate for largo.

Functions§

assets_module
The generated logos_assets module a built site bakes into its binary — the REAL table, so a lock holds the headers that actually ship rather than the rule that computes them.
cache_control_for
The Cache-Control a path is served with — immutable for a content-addressed name, revalidated for a name people link to.
conditional_response
Answer a conditional request: (status, body length) for an ETag and a client’s If-None-Match.
content_hash
The short content digest an asset’s file name carries — see web_bundle::content_hash.
content_type_for
The content type largo serves a path as — the table largo serve and largo build both use.
dev_page_html
The document largo serve sends for a page — the same pre-rendered markup largo build ships, so what a developer looks at is what their visitors get.
etag_for
An asset’s quoted ETag.
gzip_asset
gzip some bytes the way largo build does, or None when a compressed form is not worth shipping — exposed so asset_compression_lock measures the REAL compressor on a REAL asset rather than a copy of the rule.
largo_main
The largo process: installs the native tier, runs run_cli on a worker whose stack is sized from the AST depth limit, renders any error, and exits with its code. src/main.rs is exactly this call, and so is the test crate’s largo-under-test, so the CLI suites spawn what ships.
page_asset_base
The URL-and-filesystem-safe form of a page path (/posts/:id → /posts/id) — the shipped name, exposed so the lock holds the published bytes rather than a copy of the rule.
page_html_paths
The URLs a page answers — the ONE rule largo serve and largo build both follow.
page_path_matches
Does a concrete request path match a page’s declared ## Page path? A :name segment matches any one segment — the same rule web.lg’s matchRoute applies inside the page, exposed so page_pattern_routing_lock holds the REAL matcher the router uses.
parse_error_report
Everything largo writes to standard error for a program the compiler rejects with pe, whose span is in text, the text of file: the error: block with the explanation, the excerpt and the --> file:line:col, without terminal styles. Every backend largo drives reports a rejected program in exactly these bytes, and the tier-parity census holds the backends it drives in-process to them too.
plan_site_assets
A built site’s planned assets as (path, content type, bytes) — the REAL table largo build bakes into the binary, exposed so asset_cache_lock holds the shipped names and headers rather than a copy of the rule.
prerender_page_html
A built page’s document with its markup already in it — the static-render half of largo build. Public so ssg_lock exercises the REAL function the build calls, rather than a copy that could drift from it.
stylesheet_links_for
Which stylesheets a page links — the ONE rule largo serve and largo build both apply.