Skip to main content

Module share

Module share 

Source
Expand description

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.

Closes the SR-4 three-surface-parity gap on memory_share. The MCP tool ([crate::mcp::tools::share::handle_share]) and the HTTP route (POST /api/v1/share, crate::handlers::share::share_memory) landed at v0.7.0 RC; this module wires the third surface so operators can share a memory from a terminal without driving MCP-stdio JSON-RPC or constructing an HTTP request by hand.

§Wire shape

ai-memory share \
    --memory-id <source uuid or unique prefix> \
    --target-agent <recipient agent_id> \
    [--json]

Both --memory-id and --target-agent are required and validated by the shared substrate primitive (crate::validate::validate_id / crate::validate::validate_agent_id). The dispatch is byte-equal to the MCP tool so the JSON envelope (shared_memory_id, source_memory_id, target_namespace, target_agent_id, from_agent_id) round-trips intact.

§DRY contract

No business logic lives here — this module is a clap arg-parser plus an output formatter. The actual share semantics (provenance metadata, _shared/<from>→<to>/ namespace construction, fresh row insert) live in [crate::mcp::tools::share::handle_share]. The MCP, HTTP, and CLI surfaces share that one implementation; adding a CLI verb is one Command::Share(ShareArgs) arm + this module.

Structs§

ShareArgs
CLI args for ai-memory share. Mirrors the MCP memory_share input_schema shape: source_memory_id (here exposed as --memory-id for shell ergonomics) + target_agent_id (here --target-agent for the same reason). The substrate primitive accepts both spellings via the JSON params bag the CLI constructs below.

Functions§

cmd_share
ai-memory share dispatch entry. Opens the DB at db_path, builds the same JSON params bag the MCP tool consumes, and routes through the shared [crate::mcp::tools::share::handle_share] substrate primitive — guaranteeing the wire envelope is byte-equal across the three surfaces.