summaryrefslogtreecommitdiff
path: root/makima/src/daemon/cli
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-03 23:19:40 +0000
committersoryu <soryu@soryu.co>2026-02-03 23:19:40 +0000
commitbfa3af9ef16fd5e255bdb606a99a5ebb535ba7cc (patch)
tree53da855b4ca61a5c0856fc15112daa7a3748c637 /makima/src/daemon/cli
parent1ce281adb89683a5fccfd153706383b14b944f32 (diff)
parentdcbf8c834626870a43b633b099f409d69d4f9b87 (diff)
downloadsoryu-makima/discuss-contract-feature.tar.gz
soryu-makima/discuss-contract-feature.zip
fix: Resolve merge conflict in server/mod.rsmakima/discuss-contract-feature
Combine imports from both branches - include both chains and contract_discuss handlers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/daemon/cli')
-rw-r--r--makima/src/daemon/cli/chain.rs107
-rw-r--r--makima/src/daemon/cli/mod.rs52
2 files changed, 159 insertions, 0 deletions
diff --git a/makima/src/daemon/cli/chain.rs b/makima/src/daemon/cli/chain.rs
new file mode 100644
index 0000000..1d7c167
--- /dev/null
+++ b/makima/src/daemon/cli/chain.rs
@@ -0,0 +1,107 @@
+//! Chain CLI commands for multi-contract orchestration.
+//!
+//! Provides commands for creating, managing, and visualizing chains
+//! (DAGs of contracts).
+
+use clap::Args;
+use std::path::PathBuf;
+use uuid::Uuid;
+
+/// Common arguments for chain commands requiring API access.
+#[derive(Args, Debug, Clone)]
+pub struct ChainArgs {
+ /// API URL
+ #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp", global = true)]
+ pub api_url: String,
+
+ /// API key for authentication
+ #[arg(long, env = "MAKIMA_API_KEY", global = true)]
+ pub api_key: String,
+}
+
+/// Arguments for the `run` command (create chain from YAML file).
+#[derive(Args, Debug)]
+pub struct RunArgs {
+ #[command(flatten)]
+ pub common: ChainArgs,
+
+ /// Path to the chain YAML file
+ pub file: PathBuf,
+
+ /// Don't actually create the chain, just validate and show what would be created
+ #[arg(long)]
+ pub dry_run: bool,
+}
+
+/// Arguments for the `status` command.
+#[derive(Args, Debug)]
+pub struct StatusArgs {
+ #[command(flatten)]
+ pub common: ChainArgs,
+
+ /// Chain ID
+ pub chain_id: Uuid,
+}
+
+/// Arguments for the `list` command.
+#[derive(Args, Debug)]
+pub struct ListArgs {
+ #[command(flatten)]
+ pub common: ChainArgs,
+
+ /// Filter by status (active, completed, archived)
+ #[arg(long)]
+ pub status: Option<String>,
+
+ /// Limit number of results
+ #[arg(long, default_value = "50")]
+ pub limit: i32,
+}
+
+/// Arguments for the `contracts` command.
+#[derive(Args, Debug)]
+pub struct ContractsArgs {
+ #[command(flatten)]
+ pub common: ChainArgs,
+
+ /// Chain ID
+ pub chain_id: Uuid,
+}
+
+/// Arguments for the `graph` command (ASCII DAG visualization).
+#[derive(Args, Debug)]
+pub struct GraphArgs {
+ #[command(flatten)]
+ pub common: ChainArgs,
+
+ /// Chain ID
+ pub chain_id: Uuid,
+
+ /// Show contract status in nodes
+ #[arg(long)]
+ pub with_status: bool,
+}
+
+/// Arguments for the `validate` command.
+#[derive(Args, Debug)]
+pub struct ValidateArgs {
+ /// Path to the chain YAML file
+ pub file: PathBuf,
+}
+
+/// Arguments for the `preview` command.
+#[derive(Args, Debug)]
+pub struct PreviewArgs {
+ /// Path to the chain YAML file
+ pub file: PathBuf,
+}
+
+/// Arguments for the `archive` command.
+#[derive(Args, Debug)]
+pub struct ArchiveArgs {
+ #[command(flatten)]
+ pub common: ChainArgs,
+
+ /// Chain ID
+ pub chain_id: Uuid,
+}
diff --git a/makima/src/daemon/cli/mod.rs b/makima/src/daemon/cli/mod.rs
index 0805edd..035a784 100644
--- a/makima/src/daemon/cli/mod.rs
+++ b/makima/src/daemon/cli/mod.rs
@@ -1,5 +1,6 @@
//! Command-line interface for the makima CLI.
+pub mod chain;
pub mod config;
pub mod contract;
pub mod daemon;
@@ -9,6 +10,7 @@ pub mod view;
use clap::{Parser, Subcommand};
+pub use chain::ChainArgs;
pub use config::CliConfig;
pub use contract::ContractArgs;
pub use daemon::DaemonArgs;
@@ -58,6 +60,14 @@ pub enum Commands {
/// Saves configuration to ~/.makima/config.toml for use by CLI commands.
#[command(subcommand)]
Config(ConfigCommand),
+
+ /// Chain commands for multi-contract orchestration
+ ///
+ /// Chains are DAGs (directed acyclic graphs) of contracts that work together
+ /// to achieve a larger goal. Contracts can depend on each other, and run
+ /// in parallel when no dependencies exist.
+ #[command(subcommand)]
+ Chain(ChainCommand),
}
/// Config subcommands for CLI configuration.
@@ -196,6 +206,48 @@ pub enum ContractCommand {
CreateFile(contract::CreateFileArgs),
}
+/// Chain subcommands for multi-contract orchestration.
+#[derive(Subcommand, Debug)]
+pub enum ChainCommand {
+ /// Create a chain from a YAML file
+ ///
+ /// Parses the chain definition, validates the DAG, and creates
+ /// contracts in the correct dependency order.
+ Run(chain::RunArgs),
+
+ /// Get chain status and progress
+ Status(chain::StatusArgs),
+
+ /// List all chains
+ List(chain::ListArgs),
+
+ /// List contracts in a chain
+ Contracts(chain::ContractsArgs),
+
+ /// Display ASCII DAG visualization
+ ///
+ /// Shows the chain structure as an ASCII graph with
+ /// contracts as nodes and dependencies as edges.
+ Graph(chain::GraphArgs),
+
+ /// Validate a chain YAML file without creating
+ ///
+ /// Checks syntax, validates the DAG (no cycles), and
+ /// reports any errors.
+ Validate(chain::ValidateArgs),
+
+ /// Preview what would be created from a chain file
+ ///
+ /// Shows execution order and contract details without
+ /// actually creating anything.
+ Preview(chain::PreviewArgs),
+
+ /// Archive a chain
+ ///
+ /// Marks the chain as archived. Does not delete contracts.
+ Archive(chain::ArchiveArgs),
+}
+
impl Cli {
/// Parse command-line arguments
pub fn parse_args() -> Self {