Skip to main content

Module cli

Module cli 

Source
Expand description

CLI command modules. Wave 5a (v0.6.3) extracted these out of main.rs so each handler can be unit-tested by capturing output into a Vec<u8> via CliOutput instead of literal println!s.

§Public surface

  • CliOutput (re-exported at cli::CliOutput): output abstraction.
  • helpers::{id_short, auto_namespace, human_age}: pure helpers.
  • store::run, update::run, io::{export, import, mine}: handler entry points called by main.rs’s dispatch arm.

Each handler takes &mut CliOutput<'_> and routes every emit through writeln! so tests can assert on captured bytes.

Re-exports§

pub use io_writer::CliOutput;

Modules§

agents
cmd_agents and cmd_pending migrations. See cli::store for the design pattern.
archive
cmd_archive migration. See cli::store for the design pattern.
audit
ai-memory audit — operator-facing CLI for the security audit trail (PR-5 of issue #487).
backup
cmd_backup and cmd_restore migrations. See cli::store for the design pattern.
boot
ai-memory boot — universal session-boot context primitive (issue #487).
commands
v0.7.0 QW-1 — new-format CLI command modules (return exit codes rather than calling process::exit). v0.7.0 QW-1 — new-format CLI command modules.
consolidate
cmd_consolidate and cmd_auto_consolidate migrations. See cli::store for the design pattern.
crud
cmd_get, cmd_list, cmd_delete migrations. See cli::store for the design pattern.
curator
cmd_curator migration. The daemon-mode body delegates to daemon_runtime::run_curator_daemon_with_primitives (W3 work); this module owns only the outer wrapper and the report printer.
doctor
ai-memory doctor (Phase P7 / R7) — operator-visible health dashboard.
export
v0.7.0 L2-5 (issue #670) — ai-memory export-forensic-bundle and ai-memory verify-forensic-bundle subcommands. v0.7.0 L2-5 (issue #670) — ai-memory export-forensic-bundle and ai-memory verify-forensic-bundle CLI surface.
forget
cmd_forget migration. See cli::store for the design pattern.
gc
cmd_gc, cmd_stats, and cmd_namespaces migrations. See cli::store for the design pattern.
governance
Shared governance enforcement helper. Wave 5b (v0.6.3) lifted the match db::enforce_governance(...) block out of every governed cmd_* so the printing-side of governance decisions has a single testable home and the call-sites collapse to a 3-arm match on the returned GovernanceOutcome.
governance_check_action
v0.7.0 issue #863 — ai-memory governance check-action subcommand. Shell-side parity for the MCP tool memory_check_agent_action so operators can dry-run a substrate rule from a terminal without driving JSON-RPC over stdio. v0.7.0 issue #863 — ai-memory governance check-action CLI subcommand. Shell-side parity surface for the MCP tool memory_check_agent_action. Operators can dry-run any substrate agent-action rule (R001-R004 plus any operator-added rule) from a terminal without driving JSON-RPC over stdio.
governance_install_defaults
v0.7.0 7th-form (issue #760) — ai-memory governance install-defaults subcommand. Bulk-flip seed rules R001-R004 to enabled = 1 after operator confirmation (interactive prompt; --yes overrides). v0.7.0 7th-form closeout (issue #760) — ai-memory governance install-defaults CLI subcommand.
governance_migrate
v0.7.0 K11 — ai-memory governance migrate-to-permissions CLI.
helpers
Public API
identity
ai-memory identity subcommand — per-agent Ed25519 keypair lifecycle (Track H, Task H1).
install
ai-memory install <agent> — wire ai-memory boot and the ai-memory-mcp server into AI agents’ config files (issue #487 PR-2/3).
io
cmd_export, cmd_import, cmd_mine migrations.
io_writer
Public API
link
cmd_link and cmd_resolve migrations. See cli::store for the design pattern.
logs
ai-memory logs — operator-facing CLI for the file logging facility (PR-5 of issue #487). Tail, archive, purge, filter.
namespace
v0.7.0 (issue #800) — ai-memory namespace subcommand. CRUD over the per-namespace standard policy memory pointer. Closes Crack 1 from the Batman Mode acceptance review by giving operators a first-class CLI verb instead of forcing them into an MCP-stdio JSON-RPC dance just to bind a GovernancePolicy to a namespace. ai-memory namespace subcommand — operator-facing CRUD for the per-namespace standard policy memory pointer (issue #800 Crack 1).
offload
v0.7.0 QW-3 — ai-memory offload / ai-memory deref subcommands. Substrate-only wrappers over crate::offload::ContextOffloader. v0.7.0 QW-3 — ai-memory offload and ai-memory deref CLI commands.
promote
cmd_promote migration. See cli::store for the design pattern.
recall
cmd_recall migration. See cli::store for the design pattern.
rules
v0.7.0 (issue #691) — ai-memory rules subcommand. CRUD for the substrate-level agent-action rules engine. Mutation verbs (add / enable / disable / remove) require the operator keypair on disk. ai-memory rules subcommand — operator-facing CRUD for the substrate-level agent-action rules engine (issue #691).
search
cmd_search migration. See cli::store for the design pattern.
serve_banner
Round-2 F8 + F12 — ai-memory serve startup banner.
share
v0.7.0 #1095 — ai-memory share subcommand. Closes the SR-4 three-surface-parity gap by shipping the CLI counterpart to the MCP tool memory_share and the HTTP route POST /api/v1/share. All three surfaces dispatch through the same substrate primitive (crate::mcp::tools::share::handle_share). v0.7.0 #1095 — ai-memory share CLI subcommand.
shell
cmd_shell REPL migration. The line-handling logic is extracted into handle_command(parts, conn, out) so unit tests can drive command parsing/dispatch without spawning a subprocess. The outer stdin loop is intentionally minimal and is not covered by unit tests — its read_line blocking call would deadlock a buffer-driven test fixture.
store
cmd_store migration. Handler writes through CliOutput so unit tests can capture stdout/stderr into Vec<u8> buffers.
sync
cmd_sync and cmd_sync_daemon migrations. The daemon-mode body delegates to daemon_runtime::run_sync_daemon_with_shutdown_using_client (W3 work); this module owns only the wrapper + the in-process sync body (pull/push/merge/dry-run).
update
cmd_update migration. See cli::store for the design pattern.
verify
ai-memory verify-reflection-chain — external verifier for reflection chains (procurement-grade audit tool, v0.7.0 L1-3).
verify_signed_events
ai-memory verify-signed-events-chain — walk the SQL-side signed_events cross-row hash chain (v34, #698 V-4 closeout) and emit a structured chain-integrity report.
wrap
ai-memory wrap <agent> — cross-platform Rust replacement for the shell wrappers PR-1 of issue #487 shipped in the integration recipes.