cellstate/
main.rs

1//! CELLSTATE CLI — Universal installer and local development tool.
2//!
3//! Install:
4//!   curl -fsSL https://cellstate.batterypack.dev/install | sh
5//!
6//! Commands:
7//!   cellstate setup    ← Interactive first-run installer (detect env, install SDKs)
8//!   cellstate init     ← Scaffold .cellstate/ config in current project
9//!   cellstate start    ← Start local CELLSTATE server (Docker)
10//!   cellstate stop     ← Stop local CELLSTATE server
11//!   cellstate inspect  ← View live memory state
12
13mod commands;
14pub(crate) mod http;
15mod ui;
16
17use clap::{Parser, Subcommand};
18
19// ============================================================================
20// CLI definition
21// ============================================================================
22
23#[derive(Parser)]
24#[command(
25    name = "cellstate",
26    about = "Agent memory that doesn't forget, lie, or black-box you.",
27    long_about = None,
28    version,
29    propagate_version = true,
30)]
31struct Cli {
32    #[command(subcommand)]
33    command: Option<Commands>,
34}
35
36#[derive(Subcommand)]
37enum Commands {
38    /// Interactive first-run setup: detect environment, install SDKs, start server.
39    ///
40    /// Run this first. It detects Python, Node, Rust, and Docker,
41    /// asks what you're building with, installs only what you need,
42    /// and optionally starts a local CELLSTATE server.
43    Setup,
44
45    /// Scaffold a CELLSTATE project in the current directory.
46    ///
47    /// Creates .cellstate/config.toml, .env.example, and cellstate.lock.
48    Init,
49
50    /// Start the local CELLSTATE server (PostgreSQL + API) via Docker.
51    ///
52    /// Equivalent to docker compose up with a minimal production-like stack.
53    /// Runs in the background. Use `cellstate stop` to shut down.
54    Start,
55
56    /// Stop the local CELLSTATE server.
57    Stop,
58
59    /// View live memory state from a running CELLSTATE instance.
60    ///
61    /// Polls the API and displays active memories with Blake3 receipts.
62    /// For streaming TUI: see `cellstate watch` (coming soon).
63    Inspect(commands::inspect::InspectArgs),
64
65    /// Pack compilation and AAIF convergence output commands.
66    ///
67    /// Compile a CELLSTATE pack and emit convergence outputs: AGENTS.md,
68    /// llms.txt, A2A Agent Card, SKILL.md, A2UI schema.
69    Pack(commands::pack::PackArgs),
70}
71
72// ============================================================================
73// Entry point
74// ============================================================================
75
76fn main() {
77    let cli = Cli::parse();
78
79    let result = match cli.command {
80        Some(Commands::Setup) | None => commands::setup::run(),
81        Some(Commands::Init) => commands::init::run(),
82        Some(Commands::Start) => commands::start::run(),
83        Some(Commands::Stop) => commands::start::stop(),
84        Some(Commands::Inspect(args)) => commands::inspect::run(&args),
85        Some(Commands::Pack(args)) => commands::pack::run(&args),
86    };
87
88    if let Err(e) = result {
89        eprintln!("{} {}", console::style("error:").red().bold(), e);
90        std::process::exit(1);
91    }
92}