Skip to main content

Crate memstead_cli

Crate memstead_cli 

Source
Expand description

Memstead CLI library — the command modules, utility modules, and the shared CliError behind the memstead binary (src/main.rs).

One crate, two build configs. The default build (mem-repo feature on) is the full memstead: every subcommand, including the multi-mem / mem-repo lifecycle (mem, workspace, install, batch-update, recover). --no-default-features drops the git-branch backend and the mem-repo-only subcommands, yielding the lean engine-agnostic surface (a CI / wasm-adjacent config, not shipped).

Modules§

auth
Auth plumbing for the registry commands.
cli
Clap derive for the memstead binary, lifted out of main.rs so the xtask doc generator can call Cli::command() against the same tree the binary exposes — no duplicated declarations, no drift.
commands
outer_gitignore
Shared helper: detect the enclosing git repo and append a path to its .gitignore.
output
Output rendering and exit codes.
registry
HTTP client for the Memstead registry (memstead.io).
setup
Engine setup from global CLI flags. Produces an Engine synchronously (no tokio) for the CLI to call into directly.

Structs§

CliError
Typed CLI error that carries an exit-code kind, a stable UPPER_SNAKE_CASE code (matching EngineError::code() for engine-sourced errors), and an optional structured details payload. Wrap with anyhow::Error via .into() or map_err to propagate up to main, which renders the error through output::print_cli_error in the documented {code, message, details} shape (or memstead: ERROR [<CODE>]: <message> on the text channel).

Constants§

ARCHIVE_VALIDATION_FAILED_CODE
memstead install <archive> refusal: archive failed strict validation (any of the variants the strict-archive validator can produce).
CHUNK_OUT_OF_RANGE_CODE
memstead overview --chunk <N> refusal: requested chunk index is beyond the actual chunk count.
HASH_FLAG_REQUIRED_CODE
Argument-validation refusal: mutating commands require one of --auto-hash, --expected-hash, or --force. The typed code lets agents branch on the wire token rather than parsing the message.
INTERNAL_CODE
Stable wire token for genuinely-systemic failures the agent can’t recover from (I/O panic, store corruption, unreachable branch). The code field is non-optional, so this constant exists for callsites that explicitly choose it — defaulting to it is not possible. Adding a new callsite using this constant should carry a comment explaining why no recoverable typed code applies.
TARGET_NOT_EMPTY_CODE
memstead init <target> refusal: target directory is non-empty (the init refuses to scribble over existing files / pre-existing workspaces).
WORKSPACE_ALREADY_EXISTS_ABOVE_CODE
memstead init refusal: ancestor walk found an existing .memstead/workspace.toml above the target. Without this guard a standalone init would silently nest a fresh filesystem-mem workspace inside an existing one, with neither workspace aware of the other.