From 8c23b3ab6f7fabca01b0468911bae073aa5ced32 Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 9 Feb 2026 00:11:51 +0000 Subject: Add new directive mechanism v3 --- makima/src/bin/makima.rs | 105 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) (limited to 'makima/src/bin/makima.rs') diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs index ee5895c..639c88b 100644 --- a/makima/src/bin/makima.rs +++ b/makima/src/bin/makima.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use makima::daemon::api::{ApiClient, CreateContractRequest}; use makima::daemon::cli::{ Cli, CliConfig, Commands, ConfigCommand, ContractCommand, - SupervisorCommand, ViewArgs, + DirectiveCommand, SupervisorCommand, ViewArgs, }; use makima::daemon::tui::{self, Action, App, ListItem, ViewType, TuiWsClient, WsEvent, OutputLine, OutputMessageType, WsConnectionState, RepositorySuggestion}; use makima::daemon::config::{DaemonConfig, RepoEntry}; @@ -29,6 +29,7 @@ async fn main() -> Result<(), Box> { Commands::Daemon(args) => run_daemon(args).await, Commands::Supervisor(cmd) => run_supervisor(cmd).await, Commands::Contract(cmd) => run_contract(cmd).await, + Commands::Directive(cmd) => run_directive(cmd).await, Commands::View(args) => run_view(args).await, Commands::Config(cmd) => run_config(cmd).await, } @@ -711,6 +712,108 @@ async fn run_contract( Ok(()) } +/// Run directive commands. +async fn run_directive( + cmd: DirectiveCommand, +) -> Result<(), Box> { + use makima::daemon::api::directive::*; + + match cmd { + DirectiveCommand::List(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.list_directives().await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Get(args) | DirectiveCommand::Status(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.get_directive(args.directive_id).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::AddStep(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let depends_on: Vec = args + .depends_on + .map(|d| { + d.split(',') + .filter_map(|s| uuid::Uuid::parse_str(s.trim()).ok()) + .collect() + }) + .unwrap_or_default(); + let req = CreateStepRequest { + name: args.name, + description: args.description, + task_plan: args.task_plan, + depends_on, + order_index: args.order_index, + }; + let result = client.directive_add_step(args.common.directive_id, req).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::RemoveStep(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + client.directive_remove_step(args.common.directive_id, args.step_id).await?; + println!(r#"{{"success": true}}"#); + } + DirectiveCommand::SetDeps(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let depends_on: Vec = args + .depends_on + .split(',') + .filter_map(|s| uuid::Uuid::parse_str(s.trim()).ok()) + .collect(); + let result = client + .directive_set_deps(args.common.directive_id, args.step_id, depends_on) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Start(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.directive_start(args.directive_id).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Pause(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.directive_pause(args.directive_id).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Advance(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.directive_advance(args.directive_id).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::CompleteStep(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let result = client + .directive_complete_step(args.common.directive_id, args.step_id) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::FailStep(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let result = client + .directive_fail_step(args.common.directive_id, args.step_id) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::SkipStep(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let result = client + .directive_skip_step(args.common.directive_id, args.step_id) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::UpdateGoal(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let result = client + .directive_update_goal(args.common.directive_id, &args.goal) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + } + + Ok(()) +} + /// Run the TUI view command. async fn run_view(args: ViewArgs) -> Result<(), Box> { // Load CLI config for defaults -- cgit v1.2.3