pub enum CliCommand {
Show 34 variants
Experience {
tenant_id: Option<String>,
project_id: Option<String>,
output: Option<PathBuf>,
warm: WarmMode,
command: ExperienceCommand,
},
Add {
tenant_id: Option<String>,
text: String,
chunk_type: ChunkType,
project_id: Option<String>,
tags: Option<Vec<String>>,
source_uri: Option<String>,
source_path: Option<String>,
warm: WarmMode,
},
Search {Show 23 fields
tenant_id: Option<String>,
query: Option<String>,
query_positional: Option<String>,
k: usize,
project_id: Option<String>,
task_id: Option<String>,
thread_id: Option<String>,
compact: bool,
dedupe_by_source: bool,
token_budget: Option<usize>,
mode: CliQueryMode,
no_text: bool,
include_artifact: bool,
include_superseded: bool,
format: ExportFormat,
output: Option<PathBuf>,
reranker: SearchReranker,
reranker_model: String,
reranker_device: String,
reranker_batch_size: usize,
reranker_timeout_seconds: u64,
reranker_python: String,
warm: WarmMode,
},
AgentContext {Show 14 fields
tenant_id: Option<String>,
project_id: Option<String>,
task_id: Option<String>,
thread_id: Option<String>,
query: Vec<String>,
k: usize,
token_budget: usize,
mode: CliQueryMode,
no_text: bool,
include_artifact: bool,
format: ExportFormat,
output: Option<PathBuf>,
log_dir: Option<PathBuf>,
warm: WarmMode,
},
MemoryMd {
tenant_id: Option<String>,
project_id: Option<String>,
project_dir: PathBuf,
output: PathBuf,
project_limit: usize,
global_limit: usize,
candidate_k: usize,
explain_output: Option<PathBuf>,
},
EvalMemoryMd {
tenant_id: Option<String>,
project_id: Option<String>,
project_dir: PathBuf,
output: PathBuf,
project_limit: usize,
candidate_k: usize,
top_n: usize,
min_useful_ratio: f64,
max_generated_wrappers: usize,
agent_usefulness: bool,
gold_file: Option<PathBuf>,
},
EvalRetrieval {
tenant_id: String,
project_id: Option<String>,
project_dir: PathBuf,
queries: Option<PathBuf>,
k: usize,
min_precision_at_k: f64,
min_hit_rate_at_k: f64,
min_known_recall_at_k: f64,
min_mrr: f64,
},
EvalWriteQuality {
project_dir: PathBuf,
min_rejection_or_downgrade_rate: f64,
min_duplicate_reuse_rate: f64,
max_total_chunks: usize,
max_disk_bytes: u64,
require_retention_compaction: bool,
},
Consolidate {
tenant_id: Option<String>,
project_id: Option<String>,
project_dir: PathBuf,
max_region: usize,
dry_run: bool,
background: bool,
force: bool,
promote: bool,
legacy_immediate: bool,
warm: WarmMode,
},
ConsolidateReview {
run_id: Option<String>,
tenant_id: Option<String>,
project_id: Option<String>,
list: bool,
limit: usize,
accept: bool,
reject: bool,
warm: WarmMode,
},
Outcome {
episode_id: String,
tenant_id: Option<String>,
outcome: String,
verifier: String,
used: Vec<String>,
harmful: Vec<String>,
evidence: Option<String>,
event_time_ms: Option<i64>,
warm: WarmMode,
},
OutcomeScan {
project_dir: PathBuf,
sessions_dir: Option<PathBuf>,
since_days: u64,
dry_run: bool,
},
EvalCounterfactual {
tenant_id: String,
project_id: Option<String>,
project_dir: PathBuf,
queries: Option<PathBuf>,
k: usize,
},
EvalOutcomeRanking {
tenant_id: String,
project_id: Option<String>,
project_dir: PathBuf,
queries: PathBuf,
k: usize,
report_json: PathBuf,
},
SessionStart {
project_dir: PathBuf,
native_hook: Option<NativeHookHarness>,
},
Call {
tool: String,
json: Option<String>,
input: Option<PathBuf>,
output: Option<PathBuf>,
warm: WarmMode,
},
Batch {
jsonl: Option<PathBuf>,
stream: bool,
continue_on_error: bool,
output: Option<PathBuf>,
warm: WarmMode,
},
Warm {
command: WarmCommand,
},
WarmWorker {
socket: PathBuf,
embedding_model: Option<String>,
search_variant: Option<String>,
},
Get {
tenant_id: Option<String>,
chunk_id: Option<String>,
chunk_id_positional: Option<String>,
},
Delete {
tenant_id: Option<String>,
chunk_id: String,
warm: WarmMode,
},
Stats {
tenant_id: Option<String>,
},
Audit {
tenant_id: Option<String>,
project_id: Option<String>,
format: ExportFormat,
strict: bool,
output: Option<PathBuf>,
page_size: usize,
duplicate_examples: usize,
top_projects: usize,
},
Report {
tenant_id: Option<String>,
project_id: Option<String>,
since: String,
format: ReportFormat,
strict: bool,
top: usize,
output: Option<PathBuf>,
warm: WarmMode,
},
CleanupPlan {
tenant_id: Option<String>,
project_id: Option<String>,
project_dir: PathBuf,
format: ExportFormat,
output: Option<PathBuf>,
archive_dir: PathBuf,
older_than_days: u64,
candidate_limit: usize,
page_size: usize,
top_projects: usize,
},
Purge {
tenant_id: String,
project_id: Option<String>,
older_than_days: u64,
limit: usize,
include_unreadable_active: bool,
archive: Option<PathBuf>,
apply: bool,
vacuum_metadata: bool,
rewrite_segments: bool,
warm: WarmMode,
},
PurgeArchive {
archive: PathBuf,
expect_tenant_id: Option<String>,
expect_project_id: Option<String>,
min_records: Option<usize>,
format: ExportFormat,
output: Option<PathBuf>,
},
Export {
tenant_id: Option<String>,
format: ExportFormat,
output: Option<PathBuf>,
page_size: usize,
},
ExportMarkdown {
tenant_id: Option<String>,
outdir: PathBuf,
project_id: Option<String>,
include_history: bool,
data_dir: Option<PathBuf>,
},
ExportOmf {
tenant_id: Option<String>,
project_id: Option<String>,
output: Option<PathBuf>,
include_history: bool,
include_superseded: bool,
include_expired: bool,
},
ImportOmf {
tenant_id: Option<String>,
input: Option<PathBuf>,
include_archived: bool,
fuzzy_threshold: Option<f32>,
dry_run: bool,
warm: WarmMode,
},
Init {
tenant_id: String,
project_dir: PathBuf,
project_id: Option<String>,
memd_command: String,
memd_data_dir: Option<PathBuf>,
write_agent_files: bool,
},
Doctor {
project_dir: PathBuf,
format: ExportFormat,
strict: bool,
},
Maintenance {
data_dir: Option<PathBuf>,
tenant_id: Option<String>,
dry_run: bool,
aggressive: bool,
},
}Expand description
CLI subcommands for memory operations
Variants§
Experience
Linked problems, attempts, executed checks, and conditional lessons.
Fields
command: ExperienceCommandAdd
Add a memory chunk
Fields
chunk_type: ChunkTypeType of chunk (code, doc, trace, decision, plan, research, message, summary, other)
Optional tags (comma-separated)
Search
Search memory chunks
Fields
task_id: Option<String>Optional memd task identifier for retrieval-outcome attribution. Defaults to MEMD_TASK_ID when that variable is set.
thread_id: Option<String>Optional native thread identifier for retrieval-outcome attribution. Defaults to the calling client’s observed native thread.
dedupe_by_source: boolCollapse results sharing a source URI to the best-ranked one, so fragments of one document don’t crowd out other relevant sources
mode: CliQueryModeRetrieval intent for digest-biased searches
include_superseded: boolInclude superseded chunks (hidden by default) — for provenance lookups of consolidated lessons.
format: ExportFormatOutput format
reranker: SearchRerankerOptional high-quality post-retrieval reranker
AgentContext
Build a bounded local context file for agents using CLI-only retrieval.
This is the preferred CLI-only orchestration path: a controller runs retrieval before launching the agent, writes a compact context file into the workspace, and the agent reads that file during the solve.
Fields
mode: CliQueryModeRetrieval intent for digest-biased searches
format: ExportFormatOutput format
MemoryMd
Refresh a project memory.md file with the highest-priority takeaways.
This is intended for agent session startup. It distills up to 10
project-scoped fact-library items from memd, writes them to memory.md,
and prints a JSON summary. Up to 2 machine-wide fact-library items are
included by default; tune with --global-limit (0 disables).
Fields
global_limit: usizeMaximum machine-wide fact-library items to keep, capped at 10. Defaults to 2; 0 disables the section.
EvalMemoryMd
Evaluate default memory.md startup quality against fixed thresholds.
Fields
EvalRetrieval
Evaluate fixed retrieval queries with known useful chunk IDs.
Fields
EvalWriteQuality
Evaluate synthetic write admission, dedupe, and storage-growth behavior.
Fields
Consolidate
Consolidate recent memory chunks into deduplicated lessons.
Builds a working region from chunks written/retrieved since the
last run, asks the configured LLM consolidator to rewrite them,
and stages hidden kind:consolidated candidates for review.
Backend is chosen by MEMD_CONSOLIDATOR.
Fields
tenant_id: Option<String>Tenant identifier. Defaults to .memd/project_scope.json
or .memd/config.json when present.
project_id: Option<String>Optional project identifier. Defaults to the scope file only when –tenant-id is also omitted.
ConsolidateReview
Inspect, accept, or reject a consolidation run.
Fields
tenant_id: Option<String>Optional tenant scope. Defaults to the current project scope when present.
Outcome
Record a verified task outcome against one retrieval episode.
Only chunks that were rendered in the named episode may be attributed. Agent self-reports are retained for audit but never train ranking.
Fields
OutcomeScan
Scan Codex session logs for observed memd retrieval reuse.
Detects tool-call outputs that rendered a retrieval episode, then
records served chunks whose distinctive literals appear in later
tool-call inputs (commands or patches) of the same session. Writes
non-ranking external_tool observed_used events;
.memd/data/outcome_scan_state.json keeps re-runs from writing
duplicate events.
Fields
EvalCounterfactual
Counterfactual retrieval eval (Phase 3).
For each query in the benchmark file, runs retrieval twice
(full bank vs. kind:consolidated-filtered) and reports the
overlap@k loss and mean rank shift. Writes a Markdown report
under evals/bench/reports/.
Fields
EvalOutcomeRanking
Compare served retrieval order with the outcome-v1 shadow policy.
Query rows declare relevant and harmful chunk IDs. The command records normal privacy-safe retrieval episodes, reconstructs a source-deduped shadow top-k, and writes JSON plus Markdown counterfactual artifacts.
Fields
SessionStart
Session-start hook entry point.
Refreshes memory.md synchronously and, when enough chunks
have accumulated, spawns a detached background consolidation.
Safe to wire into a SessionStart hook for every repo: a missing
.memd scope is created automatically unless MEMD_AUTO_SCOPE=0
or a .memd-skip marker disables startup for the repository.
Fields
native_hook: Option<NativeHookHarness>Read one bounded native SessionStart event from stdin. Only session identity, model, and cwd fields are retained.
Call
Invoke a local memd operation by its historical tool name.
This preserves the former structured operation surface without starting
an external service. Pass a JSON object with --json or --input; omit both for
{}. The result is unwrapped to the operation payload when possible.
Fields
Batch
Run local operation calls from JSONL in one process.
Each non-empty input line must be a JSON object with tool and
optional arguments. Results are emitted as JSONL with one row
per input line.
Fields
Warm
Manage the local warm worker used by --warm auto|required.
Fields
command: WarmCommandWarmWorker
Internal warm worker entrypoint. Not an agent-facing interface.
Fields
Get
Get a chunk by ID
Fields
Delete
Delete a chunk (soft delete)
Fields
Stats
Show statistics for a tenant
Audit
Audit memory storage and signal quality by tenant/project.
Reports storage footprint, scope distribution, generated-digest noise, duplicate health, age buckets, and project-id alias candidates. Use this before cleanup or retention changes.
Fields
format: ExportFormatOutput format.
Report
Usefulness & self-diagnosis report from the usage ledger and store metadata.
Fields
format: ReportFormatOutput format.
CleanupPlan
Build a non-destructive cleanup approval plan.
Classifies tenants/projects for archive review, hidden-row purge readiness, high generated-digest noise, and missing project scope. Emits command previews only; it never deletes or rewrites data.
Fields
format: ExportFormatOutput format.
Purge
Archive and hard-purge old hidden chunks from metadata and indexes.
Defaults to dry-run. Destructive cleanup requires --apply and
--archive; eligible rows are soft-deleted and index-pruned before
metadata rows are physically removed.
Fields
include_unreadable_active: boolAlso include live metadata rows whose segment payload cannot be read.
PurgeArchive
Inspect and verify a purge archive without writing to the store.
Use this after memd purge --apply --archive <path> writes an
archive and before trusting any destructive cleanup result.
Fields
format: ExportFormatOutput format.
Export
Export all tenant chunks in a human-readable or machine-readable format
Fields
format: ExportFormatExport format
ExportMarkdown
Export tenant chunks as a tree of markdown files.
Uses G1’s render_markdown_tree (one file per (project, chunk_type)
bucket) and writes each (path, content) under <outdir> on the
user’s machine. Refuses to write if the normalised <outdir> is a
descendant of memd’s data directory, because writing a markdown tree
into $MEMD_DATA_DIR would silently corrupt segment / SQLite layouts.
Fields
ExportOmf
Export tenant memory as an OMF 1.0 JSON document.
Writes to --output if provided, else stdout. The opened path is
honoured as-is; CLI callers are already on the writer side, so there
is no data-dir containment guard.
Fields
ImportOmf
Import an OMF 1.0 JSON document into a tenant.
Reads the document from --input (or stdin if - / omitted).
Use --dry-run for a read-only preview that reports counts
without writing.
Fields
Init
Initialize memd CLI guardrails for agent workflows
Fields
Doctor
Diagnose host wiring and per-repo scope.
Reports the state of: memd binary discovery, data directory,
global agent rules (Claude / Codex / Cursor), Claude
SessionStart hook, and the current project’s .memd
scope. By default this is informational and exits 0; use
--strict to fail when any doctor check fails.
Fields
format: ExportFormatOutput format. markdown (default) renders a human-readable
report with stable [ok]/[--] prefixes; json emits the
raw structured report.
Maintenance
Disk hygiene: sweep orphan HNSW snapshots and, with –aggressive, force-merge the global sparse index. Takes the data-directory writer lock. Output uses key:value lines for shell parsing.
Implementations§
Source§impl CliCommand
impl CliCommand
Sourcepub fn normalize_positional_aliases(&mut self)
pub fn normalize_positional_aliases(&mut self)
Fold positional aliases into their long-option fields so every
downstream consumer sees a single canonical source. Clap cannot make
one argument both positional and --long, so the positional arrives
in a separate field; the two are mutually exclusive at parse time.
pub fn store_access(&self) -> StoreAccess
Sourcepub fn requires_store(&self) -> bool
pub fn requires_store(&self) -> bool
Whether this command needs an initialized backing store.
Trait Implementations§
Source§impl Clone for CliCommand
impl Clone for CliCommand
Source§impl Debug for CliCommand
impl Debug for CliCommand
Source§impl FromArgMatches for CliCommand
impl FromArgMatches for CliCommand
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut<'b>(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Subcommand for CliCommand
impl Subcommand for CliCommand
Source§fn augment_subcommands<'b>(__clap_app: Command) -> Command
fn augment_subcommands<'b>(__clap_app: Command) -> Command
Source§fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§fn has_subcommand(__clap_name: &str) -> bool
fn has_subcommand(__clap_name: &str) -> bool
Self can parse a specific subcommandAuto Trait Implementations§
impl Freeze for CliCommand
impl RefUnwindSafe for CliCommand
impl Send for CliCommand
impl Sync for CliCommand
impl Unpin for CliCommand
impl UnsafeUnpin for CliCommand
impl UnwindSafe for CliCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more