diff options
| author | soryu <soryu@soryu.co> | 2026-01-11 05:52:14 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-15 00:21:16 +0000 |
| commit | 87044a747b47bd83249d61a45842c7f7b2eae56d (patch) | |
| tree | ef2000ce79ffcc2723ef841acef5aa1deb1d5378 /makima/src/daemon/cli | |
| parent | 077820c4167c168072d217a1b01df840463a12a8 (diff) | |
| download | soryu-87044a747b47bd83249d61a45842c7f7b2eae56d.tar.gz soryu-87044a747b47bd83249d61a45842c7f7b2eae56d.zip | |
Contract system
Diffstat (limited to 'makima/src/daemon/cli')
| -rw-r--r-- | makima/src/daemon/cli/contract.rs | 87 | ||||
| -rw-r--r-- | makima/src/daemon/cli/daemon.rs | 36 | ||||
| -rw-r--r-- | makima/src/daemon/cli/mod.rs | 120 | ||||
| -rw-r--r-- | makima/src/daemon/cli/server.rs | 43 | ||||
| -rw-r--r-- | makima/src/daemon/cli/supervisor.rs | 146 |
5 files changed, 432 insertions, 0 deletions
diff --git a/makima/src/daemon/cli/contract.rs b/makima/src/daemon/cli/contract.rs new file mode 100644 index 0000000..5fef5ec --- /dev/null +++ b/makima/src/daemon/cli/contract.rs @@ -0,0 +1,87 @@ +//! Contract subcommand - task-contract interaction commands. + +use clap::Args; +use uuid::Uuid; + +/// Common arguments for contract commands. +#[derive(Args, Debug, Clone)] +pub struct ContractArgs { + /// API URL + #[arg(long, env = "MAKIMA_API_URL", default_value = "http://localhost:8080", global = true)] + pub api_url: String, + + /// API key for authentication + #[arg(long, env = "MAKIMA_API_KEY", global = true)] + pub api_key: String, + + /// Current task ID (optional) + #[arg(long, env = "MAKIMA_TASK_ID", global = true)] + pub task_id: Option<Uuid>, + + /// Contract ID + #[arg(long, env = "MAKIMA_CONTRACT_ID", global = true)] + pub contract_id: Uuid, +} + +/// Arguments for file command (get specific file). +#[derive(Args, Debug)] +pub struct FileArgs { + #[command(flatten)] + pub common: ContractArgs, + + /// File ID to retrieve + pub file_id: Uuid, +} + +/// Arguments for report command. +#[derive(Args, Debug)] +pub struct ReportArgs { + #[command(flatten)] + pub common: ContractArgs, + + /// Progress message + pub message: String, +} + +/// Arguments for completion-action command. +#[derive(Args, Debug)] +pub struct CompletionActionArgs { + #[command(flatten)] + pub common: ContractArgs, + + /// Comma-separated list of modified files + #[arg(long)] + pub files: Option<String>, + + /// Number of lines added + #[arg(long, default_value = "0")] + pub lines_added: i32, + + /// Number of lines removed + #[arg(long, default_value = "0")] + pub lines_removed: i32, + + /// Whether there are code changes + #[arg(long)] + pub code: bool, +} + +/// Arguments for update-file command. +#[derive(Args, Debug)] +pub struct UpdateFileArgs { + #[command(flatten)] + pub common: ContractArgs, + + /// File ID to update + pub file_id: Uuid, +} + +/// Arguments for create-file command. +#[derive(Args, Debug)] +pub struct CreateFileArgs { + #[command(flatten)] + pub common: ContractArgs, + + /// Name of the new file + pub name: String, +} diff --git a/makima/src/daemon/cli/daemon.rs b/makima/src/daemon/cli/daemon.rs new file mode 100644 index 0000000..de4cff4 --- /dev/null +++ b/makima/src/daemon/cli/daemon.rs @@ -0,0 +1,36 @@ +//! Daemon subcommand - connect to server and manage tasks. + +use clap::Args; +use std::path::PathBuf; + +/// Run the makima daemon (connect to server and manage tasks). +#[derive(Args, Debug)] +pub struct DaemonArgs { + /// Path to custom config file + #[arg(short, long)] + pub config: Option<PathBuf>, + + /// Directory where repositories are cloned + #[arg(long, env = "MAKIMA_DAEMON_REPOS_DIR")] + pub repos_dir: Option<PathBuf>, + + /// Directory where worktrees are created + #[arg(long, env = "MAKIMA_DAEMON_WORKTREES_DIR")] + pub worktrees_dir: Option<PathBuf>, + + /// WebSocket server URL to connect to + #[arg(long, env = "MAKIMA_DAEMON_SERVER_URL")] + pub server_url: Option<String>, + + /// API key for server authentication + #[arg(long, env = "MAKIMA_DAEMON_SERVER_APIKEY")] + pub api_key: Option<String>, + + /// Maximum number of concurrent tasks + #[arg(long)] + pub max_tasks: Option<u32>, + + /// Log level (trace, debug, info, warn, error) + #[arg(short, long, default_value = "info")] + pub log_level: String, +} diff --git a/makima/src/daemon/cli/mod.rs b/makima/src/daemon/cli/mod.rs new file mode 100644 index 0000000..24c19c6 --- /dev/null +++ b/makima/src/daemon/cli/mod.rs @@ -0,0 +1,120 @@ +//! Command-line interface for the makima CLI. + +pub mod contract; +pub mod daemon; +pub mod server; +pub mod supervisor; + +use clap::{Parser, Subcommand}; + +pub use contract::ContractArgs; +pub use daemon::DaemonArgs; +pub use server::ServerArgs; +pub use supervisor::SupervisorArgs; + +/// Makima - unified CLI for server, daemon, and task management. +#[derive(Parser, Debug)] +#[command(name = "makima")] +#[command(version, about = "Makima CLI - server, daemon, and task management", long_about = None)] +pub struct Cli { + #[command(subcommand)] + pub command: Commands, +} + +#[derive(Subcommand, Debug)] +pub enum Commands { + /// Run the makima server + Server(ServerArgs), + + /// Run the daemon (connect to server, manage tasks) + Daemon(DaemonArgs), + + /// Supervisor commands for contract orchestration + #[command(subcommand)] + Supervisor(SupervisorCommand), + + /// Contract commands for task-contract interaction + #[command(subcommand)] + Contract(ContractCommand), +} + +/// Supervisor subcommands for contract orchestration. +#[derive(Subcommand, Debug)] +pub enum SupervisorCommand { + /// List all tasks in the contract + Tasks(SupervisorArgs), + + /// Get the task tree structure + Tree(SupervisorArgs), + + /// Create and start a new task + Spawn(supervisor::SpawnArgs), + + /// Wait for a task to complete + Wait(supervisor::WaitArgs), + + /// Read a file from a task's worktree + ReadFile(supervisor::ReadFileArgs), + + /// Create a git branch + Branch(supervisor::BranchArgs), + + /// Merge a task's changes to a branch + Merge(supervisor::MergeArgs), + + /// Create a pull request + Pr(supervisor::PrArgs), + + /// View task diff + Diff(supervisor::DiffArgs), + + /// Create a checkpoint + Checkpoint(supervisor::CheckpointArgs), + + /// List checkpoints + Checkpoints(SupervisorArgs), + + /// Get contract status + Status(SupervisorArgs), +} + +/// Contract subcommands for task-contract interaction. +#[derive(Subcommand, Debug)] +pub enum ContractCommand { + /// Get contract status + Status(ContractArgs), + + /// Get the phase checklist + Checklist(ContractArgs), + + /// Get contract goals + Goals(ContractArgs), + + /// List contract files + Files(ContractArgs), + + /// Get a specific file's content + File(contract::FileArgs), + + /// Report progress on the contract + Report(contract::ReportArgs), + + /// Get suggested next action + SuggestAction(ContractArgs), + + /// Get completion recommendation + CompletionAction(contract::CompletionActionArgs), + + /// Update a file (reads content from stdin) + UpdateFile(contract::UpdateFileArgs), + + /// Create a new file (reads content from stdin) + CreateFile(contract::CreateFileArgs), +} + +impl Cli { + /// Parse command-line arguments + pub fn parse_args() -> Self { + Self::parse() + } +} diff --git a/makima/src/daemon/cli/server.rs b/makima/src/daemon/cli/server.rs new file mode 100644 index 0000000..371a912 --- /dev/null +++ b/makima/src/daemon/cli/server.rs @@ -0,0 +1,43 @@ +//! Server subcommand - run the makima server. + +use clap::Args; + +/// Run the makima server. +#[derive(Args, Debug)] +pub struct ServerArgs { + /// Server port + #[arg(long, env = "PORT", default_value = "8080")] + pub port: u16, + + /// Path to parakeet model directory + #[arg( + long, + env = "PARAKEET_MODEL_DIR", + default_value = "models/parakeet-tdt-0.6b-v3" + )] + pub parakeet_model_dir: String, + + /// Path to parakeet EOU model directory + #[arg( + long, + env = "PARAKEET_EOU_DIR", + default_value = "models/realtime_eou_120m-v1-onnx" + )] + pub parakeet_eou_dir: String, + + /// Path to sortformer model + #[arg( + long, + env = "SORTFORMER_MODEL_PATH", + default_value = "models/diarization/diar_streaming_sortformer_4spk-v2.1.onnx" + )] + pub sortformer_model_path: String, + + /// PostgreSQL connection URI + #[arg(long, env = "POSTGRES_CONNECTION_URI")] + pub database_url: Option<String>, + + /// Log level (trace, debug, info, warn, error) + #[arg(short, long, default_value = "info")] + pub log_level: String, +} diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs new file mode 100644 index 0000000..00c7ff4 --- /dev/null +++ b/makima/src/daemon/cli/supervisor.rs @@ -0,0 +1,146 @@ +//! Supervisor subcommand - contract orchestration commands. + +use clap::Args; +use uuid::Uuid; + +/// Common arguments for supervisor commands. +#[derive(Args, Debug, Clone)] +pub struct SupervisorArgs { + /// API URL + #[arg(long, env = "MAKIMA_API_URL", default_value = "http://localhost:8080", global = true)] + pub api_url: String, + + /// API key for authentication + #[arg(long, env = "MAKIMA_API_KEY", global = true)] + pub api_key: String, + + /// Current task ID (optional) + #[arg(long, env = "MAKIMA_TASK_ID", global = true)] + pub task_id: Option<Uuid>, + + /// Contract ID + #[arg(long, env = "MAKIMA_CONTRACT_ID", global = true)] + pub contract_id: Uuid, +} + +/// Arguments for spawn command. +#[derive(Args, Debug)] +pub struct SpawnArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Name of the task + pub name: String, + + /// Plan/description for the task + pub plan: String, + + /// Parent task ID to branch from + #[arg(long)] + pub parent: Option<Uuid>, + + /// Checkpoint SHA to start from + #[arg(long)] + pub checkpoint: Option<String>, +} + +/// Arguments for wait command. +#[derive(Args, Debug)] +pub struct WaitArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Task ID to wait for + pub task_id: Uuid, + + /// Timeout in seconds + #[arg(default_value = "300")] + pub timeout: i32, +} + +/// Arguments for read-file command. +#[derive(Args, Debug)] +pub struct ReadFileArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Task ID to read from + pub task_id: Uuid, + + /// File path to read + pub file_path: String, +} + +/// Arguments for branch command. +#[derive(Args, Debug)] +pub struct BranchArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Branch name to create + pub name: String, + + /// Reference (task ID or SHA) to branch from + #[arg(long)] + pub from: Option<String>, +} + +/// Arguments for merge command. +#[derive(Args, Debug)] +pub struct MergeArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Task ID to merge + pub task_id: Uuid, + + /// Target branch to merge into + #[arg(long)] + pub to: Option<String>, + + /// Squash commits on merge + #[arg(long)] + pub squash: bool, +} + +/// Arguments for pr command. +#[derive(Args, Debug)] +pub struct PrArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Task ID to create PR for + pub task_id: Uuid, + + /// PR title + #[arg(long)] + pub title: String, + + /// PR body/description + #[arg(long)] + pub body: Option<String>, + + /// Base branch (default: main) + #[arg(long, default_value = "main")] + pub base: String, +} + +/// Arguments for diff command. +#[derive(Args, Debug)] +pub struct DiffArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Task ID to get diff for + pub task_id: Uuid, +} + +/// Arguments for checkpoint command. +#[derive(Args, Debug)] +pub struct CheckpointArgs { + #[command(flatten)] + pub common: SupervisorArgs, + + /// Checkpoint message + pub message: String, +} |
