Skip to main content

Crate cli

Crate cli 

Source
Expand description

mushroomdb CLI library: hand-rolled arg parsing and the demo dataset builder.

The binary in main.rs stays thin — it dispatches on parse_args and prints what the lib functions return.

Modules§

doctor
mushroomdb doctor — verify an install end to end: the config entry, the store, the hooks, and a real stdio handshake with the configured MCP command.
enrich
mushroomdb enrich — the optional PostToolUse hook body for Grep.
export
Export writer for mushroomdb export.
impact_hook
mushroomdb impact-hook — the optional PreToolUse hook body for edits.
ingest_git
mushroomdb ingest-git <db> <repo>: build and maintain a graph of a git repository. First run ingests the whole history; later runs apply only the commits after the recorded GitSync head, so deletes and renames retract or move derived edges instead of leaving them stale.
install
mushroomdb install / uninstall — wire the /mushroom skill, the MCP server, the prompt hooks and the git hooks into an assistant.
intercept
mushroomdb intercept — the optional PreToolUse hook body (experimental).
recall
mushroomdb recall <db>: the body of the UserPromptSubmit hook.
structure
Structure ingest: the working tree, read as graph.

Structs§

CliError
CLI-facing error. [Display] is the message printed to stderr.
DemoOutcome
Outcome of run_demo. Counts are deterministic.

Enums§

AlgoSubcmd
Algorithm subcommand for mushroomdb algo.
Command
Parsed mushroomdb invocation.
RestoreOutcome
Re-exported where it has always been named: cli::RestoreOutcome. What restore_if_empty did.
ServeUi
How serve should mount a UI. Precedence: --ui dir > embedded > --no-ui.
WalDisposition
What a snapshot does with the WAL it folds in.

Constants§

AUTOMATIC_SNAPSHOT
What every snapshot mushroomdb takes on its own does with the WAL.
AUTO_SNAPSHOT_RETENTION
How many WAL archives a snapshot mushroomdb takes on its own keeps. None = all of them. Retention is configured, never defaulted: deleting history nobody asked to delete is not a default worth having.
N_ORGS
Deterministic demo: 10 Orgs, 20 Projects, 30 People.
N_PEOPLE
N_PROJECTS
SAMPLE_QUERY
Sample query printed by mushroomdb demo and executed against the fresh store.
SNAPSHOT_LOCK_WAIT
How long a server-initiated snapshot waits for the store’s cross-process write lock before giving up.
VERSION
Build version, printed by mushroomdb --version.

Functions§

build_index_on
run_build_index against an already-open handle.
format_backup
Format a BackupReport for display.
format_demo
Render a DemoOutcome the way mushroomdb demo prints it.
format_stats
Pretty-print Stats for mushroomdb stats and the demo smoke test.
format_suggest
Pretty-print a list of RuleSuggestions for mushroomdb suggest.
maybe_run_demo_if_empty
Run run_demo when dir is missing or empty; otherwise leave it alone.
parse_args
Parse argv after the binary name. Hand-rolled — no clap.
read_stats
Open dir and return live stats.
resolve_auto_db
Where --auto looks for a database, in order.
restore_if_empty
core_api::restore::restore_if_empty, in the CLI’s error type.
run_algo
Run a graph algorithm and return a formatted string.
run_asof
Execute an as-of query at the given commit and print results.
run_backup
Create a consistent, verified backup of db_dir to dest.
run_brief
Body of mushroomdb brief <db-dir>|--auto, the SessionStart hook.
run_build_index
Pump every outstanding vector-index build to completion, one slice per call, printing a line per slice.
run_context
Body of mushroomdb context <db-dir> <target> [--full].
run_demo
Build the deterministic demo dataset in an empty dir.
run_explore
Body of mushroomdb explore <db-dir> <target> [--depth …] [--full].
run_export
Export all data from db_dir to dest in format.
run_impact
Body of mushroomdb impact <db-dir> <file>....
run_map
Body of mushroomdb map <db-dir> [--json].
run_migrate
Migrate the snapshot at db_dir to the current format version.
run_owners
Body of mushroomdb owners <db-dir> <path>.
run_query
Run a Cypher read or write and print columns/rows like run_asof.
run_schema_apply
Read schema_file, open db_dir, apply the schema, and return the diff as one line per entry: "created rule:x", "updated view:y", etc.
run_snapshot
Open dir and write snapshot.bin, archiving the WAL by default.
run_suggest
Profile the database at dir and return all rule suggestions.
run_verify
Validate the CRC32 integrity of every section in a V8 snapshot.
run_why
Body of mushroomdb why <db-dir> <a> <b>.
snapshot_automatically
Take AUTOMATIC_SNAPSHOT under a held write lock, keeping AUTO_SNAPSHOT_RETENTION archives.
snapshot_shared
Take the snapshot serve takes — on a --snapshot-every tick, and once more on a graceful shutdown.
usage
Usage text for no-args / --help / -h.
validate_ui_dir
--ui <dir> must be a directory that contains index.html.
version_string
The one line --version and the version subcommand print.
worktree_root
The root of the working tree dir sits in: the nearest ancestor holding a .git entry, or None outside a checkout.