Files
optimclaw/src/cli/mod.rs
T
Illia PolosukhinandClaude Opus 4.6 f3c85f57fc Add proactivity features: memory CLI, session pruning, self-repair notifications, slash commands, status diagnostics, context warnings
Closes the proactivity gap with six features:

- Memory CLI (`ironclaw memory search/read/write/tree/status`) for direct workspace access without starting the full agent
- Session pruning background task that evicts idle sessions (configurable TTL, default 7 days)
- Self-repair notifications broadcast recovery results through channel manager instead of silent logging
- `/heartbeat`, `/summarize`, `/suggest` slash commands for manual heartbeat trigger, thread summarization, and next-step suggestions
- `ironclaw status` diagnostics command checking DB, session, secrets, embeddings, WASM tools, channels, heartbeat, and MCP servers
- Context pressure warning that notifies users before auto-compaction fires

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-05 19:28:13 -08:00

103 lines
2.7 KiB
Rust

//! CLI command handling.
//!
//! Provides subcommands for:
//! - Running the agent (`run`)
//! - Interactive setup wizard (`setup`)
//! - Managing configuration (`config list`, `config get`, `config set`)
//! - Managing WASM tools (`tool install`, `tool list`, `tool remove`)
//! - Managing MCP servers (`mcp add`, `mcp auth`, `mcp list`, `mcp test`)
//! - Querying workspace memory (`memory search`, `memory read`, `memory write`)
//! - Checking system health (`status`)
mod config;
mod mcp;
pub mod memory;
pub mod status;
mod tool;
pub use config::{ConfigCommand, run_config_command};
pub use mcp::{McpCommand, run_mcp_command};
pub use memory::{MemoryCommand, run_memory_command};
pub use status::run_status_command;
pub use tool::{ToolCommand, run_tool_command};
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "ironclaw")]
#[command(
about = "Secure personal AI assistant that protects your data and expands its capabilities"
)]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Command>,
/// Run in interactive CLI mode only (disable other channels)
#[arg(long, global = true)]
pub cli_only: bool,
/// Skip database connection (for testing)
#[arg(long, global = true)]
pub no_db: bool,
/// Simple REPL mode without TUI (for testing)
#[arg(long, global = true)]
pub repl: bool,
/// Single message mode - send one message and exit
#[arg(short, long, global = true)]
pub message: Option<String>,
/// Configuration file path (optional, uses env vars by default)
#[arg(short, long, global = true)]
pub config: Option<std::path::PathBuf>,
/// Skip first-run setup check
#[arg(long, global = true)]
pub no_setup: bool,
}
#[derive(Subcommand, Debug)]
pub enum Command {
/// Run the agent (default if no subcommand given)
Run,
/// Interactive setup wizard
Setup {
/// Skip authentication (use existing session)
#[arg(long)]
skip_auth: bool,
/// Reconfigure channels only
#[arg(long)]
channels_only: bool,
},
/// Manage configuration settings
#[command(subcommand)]
Config(ConfigCommand),
/// Manage WASM tools
#[command(subcommand)]
Tool(ToolCommand),
/// Manage MCP servers (hosted tool providers)
#[command(subcommand)]
Mcp(McpCommand),
/// Query and manage workspace memory
#[command(subcommand)]
Memory(MemoryCommand),
/// Show system health and diagnostics
Status,
}
impl Cli {
/// Check if we should run the agent (default behavior or explicit `run` command).
pub fn should_run_agent(&self) -> bool {
matches!(self.command, None | Some(Command::Run))
}
}