# YAMS CLI Reference A practical, task-focused reference for the `yams` command-line interface. This document covers global flags, environment variables, and each subcommand with usage notes and examples. It is structured so tools can extract command-specific sections. For help: - `yams --help` - Show all available commands - `yams --help` - Show command-specific help ## Synopsis ```bash yams [OPTIONS] [command-options] ``` ## Environment Variables **Precedence:** explicit CLI flags > configuration file > environment variables > defaults - **YAMS_STORAGE** - Storage root directory when `--data-dir` is not provided and config does not set `core.data_dir` - **XDG_DATA_HOME** - Default storage location (`~/.local/share` if unset) - **XDG_CONFIG_HOME** - Default config location (`~/.config` if unset) - **HOME** - Fallback when XDG paths are not set ## Global Options - `--data-dir, --storage ` - Override storage root (default: `$XDG_DATA_HOME/yams`) - `--json` - Output in JSON format where supported - `-v, --verbose` - Enable verbose output - `--version` - Display program version - `-h, --help` - Print help message ## Commands ### Core Operations - `init` - Initialize YAMS storage and configuration - `add` - Add document(s) or directory to content store - `get` - Retrieve a document from content store - `cat` - Display document content to stdout - `delete, rm` - Delete documents by hash, name, or pattern - `list, ls` - List stored documents - `update` - Update metadata for existing document ### Search & Discovery - `search` - Search documents by query (semantic + keyword) - `grep` - Search for regex patterns within file contents - `tree` - Inspect aggregated path tree statistics - `graph` - Inspect knowledge graph relationships ### Collections & Snapshots - `restore` - Restore documents from collections/snapshots to filesystem - `diff` - Compare two snapshots and show file changes ### System Management - `daemon` - Manage YAMS daemon process (start/stop/restart/status) - `doctor` - Diagnose system health, connectivity, and repair issues - `status` - Show quick system status and health overview - `stats` - Show detailed system statistics - `config` - Manage YAMS configuration settings - `auth` - Manage authentication keys and tokens ### Advanced Features - `model` - Download and manage ONNX embedding models - `plugin, plugins` - Manage plugins (list/scan/load/unload/trust) - `session` - Manage interactive session selectors and warming - `watch` - Enable session-based auto-ingest for a project - `download` - Download artifacts and store directly into YAMS - `repair` - Repair and maintain storage integrity - `migrate` - Migrate YAMS data and configuration - `dr` - Disaster recovery operations (plugin-gated) ### User Interface - `serve` - Start MCP (Model Context Protocol) server - `completion` - Generate shell completion scripts (bash/zsh/fish/powershell) ### Utilities - `uninstall` - Remove YAMS from your system --- ## init {#cmd-init} Initialize YAMS storage and configuration (interactive or non-interactive). Synopsis: - yams init [OPTIONS] Options: - --non-interactive - Run without prompts, using defaults and passed flags. - --auto - Run setup with defaults for headless environments. - --force - Overwrite existing config/keys if already initialized. - --no-keygen - Skip authentication key generation. - --print - Print resulting configuration to stdout (secrets masked). - --enable-plugins - Create and trust a local plugins directory (`~/.local/lib/yams/plugins`). Notes: - The storage directory can be set globally via --storage/--data-dir or YAMS_STORAGE. - On first run, initialization will create the storage directory, database, and configuration. - Interactive mode prompts for optional model, grammar, and agent-skill setup. - Init also bootstraps a per-project session (scoping + watch). - Use `yams watch` to enable auto-ingest for existing projects. Examples: ```bash # Interactive initialization yams init # Auto mode for headless environments yams init --auto # Non-interactive with explicit storage yams --storage "$HOME/.local/share/yams" init --non-interactive # Force re-initialization yams init --force # Print config without secrets yams init --print ``` --- ## watch {#cmd-watch} Enable or disable session-based auto-ingest for a project. Synopsis: - yams watch [OPTIONS] - yams watch --stop [OPTIONS] Options: - --start - Enable watch (default) - --stop - Disable watch - --interval - Set polling interval in milliseconds - --root - Project root to watch (default: git root or cwd) - --session - Session name (default: auto) - --no-use - Do not set the session as current - --no-selector - Do not add the project root as a session selector - --daemon-ready-timeout-ms - Max time to wait for daemon readiness (0 to skip) Notes: - If the session does not exist, `yams watch` creates it and sets watch settings. - If no root is provided, the git root is used when available. - `yams watch` waits for daemon readiness by default to avoid ingesting while the daemon is still initializing. Examples: ```bash # Enable watch for the current project (auto session) yams watch # Use a 5s polling interval yams watch --interval 5000 # Disable watch yams watch --stop # Explicit root and session yams watch --root . --session my-project ``` --- ## add {#cmd-add} Manual indexing (when watch is disabled) Use YAMS to index code updates if auto-ingest is not enabled. Examples: ```bash # Index entire source tree (initial import) yams add src/ --recursive --include="*.cpp,*.hpp,*.h" --tags "code,source" yams add include/ --recursive --include="*.hpp,*.h" --tags "code,headers" # Re-index after local edits (quick pass) yams add . --recursive --include="*.cpp,*.hpp,*.h,*.md" --tags "code,working" # Add a single updated file yams add path/to/file.cpp --tags "code,source" # Update metadata for an existing document by name yams update --name path/to/file.cpp --metadata "updated=$(date -Iseconds)" ``` Tips: - Prefer comma-separated patterns with --include for multiple file types. - Tag code consistently (e.g., code,source; code,headers) to improve later queries. Add a document to the store from a file or stdin. Synopsis: - yams add [options] - yams add [options] - yams add - [options] # read from stdin Options: - -n, --name - Set the document name (especially useful for stdin input) - -t, --tags - Comma-separated tags for the document (repeatable) - -m, --metadata - Custom metadata key-value pairs (repeatable) - --mime-type - Override MIME type detection - --no-auto-mime - Disable automatic MIME type detection - --no-embeddings - Disable automatic embedding generation for added documents - -r, --recursive - Recursively add files from directories - --include - File patterns to include (e.g., '*.txt,*.md') - --exclude - File patterns to exclude (e.g., '*.tmp,*.log') - -c, --collection - Collection name for organizing documents - --snapshot-id - Unique snapshot identifier - --snapshot-label