diff options
Diffstat (limited to 'makima/src/bin/makima.rs')
| -rw-r--r-- | makima/src/bin/makima.rs | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs index ee5895c..308d689 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<dyn std::error::Error + Send + Sync>> { 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,67 @@ async fn run_contract( Ok(()) } +/// Run a directive subcommand. +async fn run_directive( + cmd: DirectiveCommand, +) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { + match cmd { + DirectiveCommand::Status(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.directive_status(args.directive_id).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Goals(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.directive_status(args.directive_id).await?; + // Extract goal-related fields from directive + let directive = &result.0; + let goals = serde_json::json!({ + "goal": directive.get("goal"), + "requirements": directive.get("requirements"), + "acceptanceCriteria": directive.get("acceptanceCriteria"), + "constraints": directive.get("constraints"), + "externalDependencies": directive.get("externalDependencies"), + }); + println!("{}", serde_json::to_string(&goals)?); + } + DirectiveCommand::Chains(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + let result = client.directive_chains(args.directive_id).await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Chain(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let result = client + .directive_chain(args.common.directive_id, args.chain_id) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + DirectiveCommand::Steps(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let result = client + .directive_chain(args.common.directive_id, args.chain_id) + .await?; + // Extract steps from chain response + let steps = result.0.get("steps").cloned().unwrap_or(serde_json::json!([])); + println!("{}", serde_json::to_string(&steps)?); + } + DirectiveCommand::UpdateStatus(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + let req = makima::daemon::api::directive::UpdateDirectiveRequest { + status: Some(args.status), + version: None, + }; + let result = client + .directive_update(args.common.directive_id, req) + .await?; + println!("{}", serde_json::to_string(&result.0)?); + } + } + + Ok(()) +} + /// Run the TUI view command. async fn run_view(args: ViewArgs) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { // Load CLI config for defaults |
