From 88a4f15ce1310f8ee8693835be14aa5280233f17 Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 5 Feb 2026 23:42:48 +0000 Subject: Add directive-first chain system redesign Redesigns the chain system with a directive-first architecture where Directive is the top-level entity (the "why/what") and Chains are generated execution plans (the "how") that can be dynamically modified. Backend: - Add database migration for directive system tables - Add Directive, DirectiveChain, ChainStep, DirectiveEvent models - Add DirectiveVerifier and DirectiveApproval models - Add orchestration module with engine, planner, and verifier - Add comprehensive API handlers for directives - Add daemon CLI commands for directive management - Add directive skill documentation - Integrate contract completion with directive engine - Add SSE endpoint for real-time directive events Frontend: - Add directives route with split-view layout - Add 6-tab detail view (Overview, Chain, Events, Evaluations, Approvals, Verifiers) - Add React Flow DAG visualization for chain steps - Add SSE subscription hook for real-time event updates - Add useDirectives and useDirectiveEventSubscription hooks - Add directive types and API functions Fixes: - Fix test failures in ws/protocol, task_output, completion_gate, patch - Fix word boundary matching in looks_like_task() - Fix parse_last() to find actual last completion gate - Fix create_export_patch when merge-base equals HEAD - Clean up clippy warnings in new code Co-Authored-By: Claude Opus 4.5 --- makima/src/daemon/cli/directive.rs | 186 +++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 makima/src/daemon/cli/directive.rs (limited to 'makima/src/daemon/cli/directive.rs') diff --git a/makima/src/daemon/cli/directive.rs b/makima/src/daemon/cli/directive.rs new file mode 100644 index 0000000..a2bb34b --- /dev/null +++ b/makima/src/daemon/cli/directive.rs @@ -0,0 +1,186 @@ +//! Directive CLI commands for autonomous goal-driven orchestration. +//! +//! Directives are top-level goals that the system works toward. Each directive +//! generates a chain of steps that are executed autonomously with configurable +//! guardrails. + +use clap::Args; +use uuid::Uuid; + +/// Common arguments for directive commands requiring API access. +#[derive(Args, Debug, Clone)] +pub struct DirectiveArgs { + /// 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 `create` command. +#[derive(Args, Debug)] +pub struct CreateArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// The goal for the directive + #[arg(short, long)] + pub goal: String, + + /// Repository URL (optional) + #[arg(short, long)] + pub repository: Option, + + /// Autonomy level: full_auto, guardrails, or manual + #[arg(short, long, default_value = "guardrails")] + pub autonomy: String, +} + +/// Arguments for the `status` command. +#[derive(Args, Debug)] +pub struct StatusArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `list` command. +#[derive(Args, Debug)] +pub struct ListArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Filter by status (draft, planning, active, paused, completed, archived, failed) + #[arg(long)] + pub status: Option, + + /// Limit number of results + #[arg(long, default_value = "50")] + pub limit: i32, +} + +/// Arguments for the `steps` command. +#[derive(Args, Debug)] +pub struct StepsArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `events` command. +#[derive(Args, Debug)] +pub struct EventsArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, + + /// Limit number of events + #[arg(long, default_value = "50")] + pub limit: i32, +} + +/// Arguments for the `approve` command. +#[derive(Args, Debug)] +pub struct ApproveArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, + + /// Approval ID + pub approval_id: Uuid, + + /// Response message (optional) + #[arg(short, long)] + pub response: Option, +} + +/// Arguments for the `deny` command. +#[derive(Args, Debug)] +pub struct DenyArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, + + /// Approval ID + pub approval_id: Uuid, + + /// Reason for denial (optional) + #[arg(short, long)] + pub reason: Option, +} + +/// Arguments for the `start` command. +#[derive(Args, Debug)] +pub struct StartArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `pause` command. +#[derive(Args, Debug)] +pub struct PauseArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `resume` command. +#[derive(Args, Debug)] +pub struct ResumeArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `stop` command. +#[derive(Args, Debug)] +pub struct StopArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `archive` command. +#[derive(Args, Debug)] +pub struct ArchiveArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, +} + +/// Arguments for the `graph` command (ASCII DAG visualization). +#[derive(Args, Debug)] +pub struct GraphArgs { + #[command(flatten)] + pub common: DirectiveArgs, + + /// Directive ID + pub directive_id: Uuid, + + /// Show step status in nodes + #[arg(long)] + pub with_status: bool, +} -- cgit v1.2.3