Expand description
Engine setup from global CLI flags. Produces an Engine
synchronously (no tokio) for the CLI to call into directly.
Post-rebuild there is one workspace marker: .memstead/workspace.toml
at the workspace root. The mem-repo Cargo feature decides
which engine factory consumes it — full routes through
memstead_git_branch::workspace_store::engine_from_workspace_root
(git-branch backends plus folder + archive), lean routes through
memstead_base::Engine::from_workspace_root (folder + archive
only).
CliEngine wraps either flavour; subcommands match-dispatch on
it. The WorkspaceShape variant is retained so the lean build
can still surface an actionable “this is the lean binary, your
workspace has git-branch mounts” error when the operator points a
lean binary at a full workspace — the shape tag is derived from
mem-repo/.git co-existing with the marker rather than the
marker itself.
Structs§
- CliContext
- Global CLI state: shared flags + a lazily-initialized
Engine. - Shape
Disclosure - The three-part disclosure a workspace-creating command owes its caller: which shape was just made, one concrete thing that shape cannot do, and the exact command that produces the other one.
Enums§
- CliEngine
- Engine instance + the workspace flavour it serves. Subcommands
match on the variant to call the right engine API; the read-side
store accessor (
engine.store()) lives on both flavours so simple read commands can share most of their bodies. - Workspace
Shape - Workspace flavour resolved from cwd. Subcommands dispatch on this to pick the right engine accessor.
Constants§
- WORKSPACE_
NOT_ INITIALISED_ CODE - Structured-code constant for the missing-workspace exit envelope.
Surfaced on both
--jsonoutput (under thecodekey indetails) and as theDisplaybody of the underlyingCliError. Scripts and agents branch on this stable token; the human prose (which mentions the recovery command) is the message and can be adjusted without breaking the contract. - WORKSPACE_
RECOVERY_ COMMAND - Recovery command suggested when no
.memstead/workspace.tomlis reachable from cwd.memstead mem-repo initin the full build (this binary speaks mem-repo);memstead initin the lean build. The structuredhint.recovery_commandfield carries this token verbatim so an agent can re-exec it.
Functions§
- boot_
error_ to_ cli - Lift a
memstead_base::BootErrorinto the typed CLI envelope. The boot seam previously flattened these throughanyhow, so themaindowncast missed them and every boot failure surfaced ascode: INTERNALwith no next step (plenum 2026-08-06/07, expertise 2026-08-07). The typed material lives onmemstead_base::BootError::code; this function only wraps it in the CLI’s exit shape. The message ismemstead_base::BootError::surface_messageverbatim — identical on the MCP server’s boot diagnostics for the same broken workspace. - cli_
client_ id - The
memstead-cli@<version>client identity stamped into the commit body’sClient:provenance trailer. Shared by every CLI mutation path so the trailer is uniform acrosscreate/update/relate/rename. Un-gated (unlikecli_ctx_with_note) because therelatepath passes the client torelate_entitydirectly rather than through aCommitContext, and that path compiles on both flavours. - cli_ctx
- Provenance bundle for every CLI-initiated mutation.
Actor::Cli+memstead-cli@<CARGO_PKG_VERSION>. TheTool:trailer staysNone: CLI subcommands aren’t MCP tools and the commit subject (memstead: create …) already carries the action verb — a second taxonomy would drift. - cli_
ctx_ with_ note - Provenance bundle carrying an optional agent-authored
--note. The note rides into the same payload slot the MCPnoteparameter uses; the engine’srequire_notespolicy gate firesNOTE_MISSINGsymmetrically across both surfaces. - find_
filesystem_ workspace_ root - Compatibility alias for
find_workspace_root— kept so existing CLI subcommands (export, changes, …) that historically routed through the lean-flavour walker continue to compile. Both walkers now find the same marker; the alias is intentional for call-site clarity (find_workspace_rootreads as the canonical surface;find_filesystem_workspace_rootdocuments the folder-mount-only intent of its caller). - find_
workspace_ root - Walk upward from
startlooking for the first ancestor that contains.memstead/workspace.toml(the post-rebuild workspace marker). Returns the first ancestor directory carrying the marker, orNoneif the walk reaches filesystem root without finding one. - full_
engine - Build the unified
memstead_base::Enginefor a mem-repo-shaped workspace. Delegates toengine_from_workspace_rootwhich handles layout detection, mount enumeration, schema resolution, and readMems hydration in one pass. - memstead_
program - Resolve the running
memsteadbinary to something the reader can actually type. Barememsteadwhen that name onPATHresolves to this very binary; otherwise the path we were invoked as. - shape_
disclosure - The disclosure for a shape.
- shape_
disclosure_ lines - Convenience for callers that only render markdown.
- shell_
quote - Render a string as one POSIX shell word. Bare when every character
is safe unquoted; otherwise single-quoted, with embedded
'closed and re-opened the POSIX way ('\''). - workspace_
not_ initialised_ error - Build the typed
WORKSPACE_NOT_INITIALISEDexit envelope. Goes throughCliErrorso the top-levelmaindowncast lifts thecode+hintfields into the JSON output.