summaryrefslogtreecommitdiff
path: root/makima/src/daemon/cli/supervisor.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-15 22:33:47 +0000
committerGitHub <noreply@github.com>2026-01-15 22:33:47 +0000
commit6ee2e75834bff187b8c262e0798ef365bc21cd59 (patch)
treed4bd61c7740835acfc9a9dff952d1d088ff6d535 /makima/src/daemon/cli/supervisor.rs
parent908973b5c08a8b7b624880843c512e8bddf37896 (diff)
downloadsoryu-6ee2e75834bff187b8c262e0798ef365bc21cd59.tar.gz
soryu-6ee2e75834bff187b8c262e0798ef365bc21cd59.zip
Add resume and history system for makima (#1)
This PR implements a comprehensive resume and history system that enables: 1. **History Viewing** - View complete conversation history for contracts across all phases - View conversation history for individual tasks - View task output/tool call history with timestamps - View checkpoint history - Timeline view showing all activities 2. **Resume System** - Resume interrupted supervisor conversations with full context - Resume interrupted task conversations - Resume from specific checkpoints - Continue tasks from previous task state (worktree inheritance) 3. **Rewind/Restore Features** - Rewind code to any checkpoint (git restore) - Rewind conversation to any point - Create new branches from historical points - Fork tasks from any point in history - New migration: 20250117000000_history_tables.sql - conversation_snapshots table for storing conversation state - history_events table for unified timeline - Added forking fields to tasks table - Added conversation_snapshot_id to task_checkpoints - ConversationSnapshot, HistoryEvent, ConversationMessage - Request/response types for resume and rewind operations - Query filter types for history endpoints - CRUD functions for conversation_snapshots - CRUD functions for history_events - Task conversation retrieval from task_events - GET /api/v1/contracts/{id}/history - GET /api/v1/contracts/{id}/supervisor/conversation - GET /api/v1/mesh/tasks/{id}/conversation - GET /api/v1/timeline - POST /api/v1/contracts/{id}/supervisor/resume - POST /api/v1/mesh/tasks/{id}/rewind - POST /api/v1/mesh/tasks/{id}/fork - POST /api/v1/mesh/tasks/{id}/checkpoints/{cid}/resume - POST /api/v1/mesh/tasks/{id}/checkpoints/{cid}/branch - POST /api/v1/contracts/{id}/supervisor/conversation/rewind - task-history: View task conversation history - task-checkpoints: List task checkpoints - resume: Resume supervisor after interruption - task-resume-from: Resume task from checkpoint - task-rewind: Rewind task code to checkpoint - task-fork: Fork task from historical point - rewind-conversation: Rewind supervisor conversation
Diffstat (limited to 'makima/src/daemon/cli/supervisor.rs')
-rw-r--r--makima/src/daemon/cli/supervisor.rs161
1 files changed, 161 insertions, 0 deletions
diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs
index 2bc4c89..ba4fb2b 100644
--- a/makima/src/daemon/cli/supervisor.rs
+++ b/makima/src/daemon/cli/supervisor.rs
@@ -221,3 +221,164 @@ pub struct GetTaskOutputArgs {
#[arg(index = 1, id = "target_task_id")]
pub target_task_id: Uuid,
}
+
+// ============================================================================
+// History Command Args
+// ============================================================================
+
+/// Arguments for task-history command.
+#[derive(Args, Debug)]
+pub struct TaskHistoryArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Task ID to view history for
+ #[arg(index = 1)]
+ pub task_id: Uuid,
+
+ /// Include tool calls in output
+ #[arg(long, default_value = "true")]
+ pub tool_calls: bool,
+
+ /// Maximum messages to return
+ #[arg(long)]
+ pub limit: Option<i32>,
+
+ /// Output format (table, json, chat)
+ #[arg(long, default_value = "chat")]
+ pub format: String,
+}
+
+/// Arguments for task-checkpoints command (with optional diff).
+#[derive(Args, Debug)]
+pub struct TaskCheckpointsArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Task ID to list checkpoints for
+ #[arg(index = 1)]
+ pub task_id: Uuid,
+
+ /// Include diff summary
+ #[arg(long)]
+ pub with_diff: bool,
+}
+
+// ============================================================================
+// Resume Command Args
+// ============================================================================
+
+/// Arguments for resume command.
+#[derive(Args, Debug)]
+pub struct ResumeArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Resume mode: continue, restart_phase, from_checkpoint
+ #[arg(long, default_value = "continue")]
+ pub mode: String,
+
+ /// Checkpoint ID (required for from_checkpoint mode)
+ #[arg(long)]
+ pub checkpoint: Option<Uuid>,
+
+ /// Additional context to inject
+ #[arg(long)]
+ pub context: Option<String>,
+}
+
+/// Arguments for task-resume-from command.
+#[derive(Args, Debug)]
+pub struct TaskResumeFromArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Source task ID
+ #[arg(index = 1)]
+ pub task_id: Uuid,
+
+ /// Checkpoint number to resume from
+ #[arg(long)]
+ pub checkpoint: i32,
+
+ /// Plan for the new task
+ #[arg(long)]
+ pub plan: String,
+
+ /// Name for the new task
+ #[arg(long)]
+ pub name: Option<String>,
+}
+
+// ============================================================================
+// Rewind Command Args
+// ============================================================================
+
+/// Arguments for task-rewind command.
+#[derive(Args, Debug)]
+pub struct TaskRewindArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Task ID to rewind
+ #[arg(index = 1)]
+ pub task_id: Uuid,
+
+ /// Checkpoint number to rewind to
+ #[arg(long)]
+ pub checkpoint: i32,
+
+ /// Preserve mode: discard, create_branch, stash
+ #[arg(long, default_value = "create_branch")]
+ pub preserve: String,
+
+ /// Branch name (for create_branch mode)
+ #[arg(long)]
+ pub branch_name: Option<String>,
+}
+
+/// Arguments for task-fork command.
+#[derive(Args, Debug)]
+pub struct TaskForkArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Source task ID
+ #[arg(index = 1)]
+ pub task_id: Uuid,
+
+ /// Checkpoint number to fork from
+ #[arg(long)]
+ pub checkpoint: i32,
+
+ /// Name for the new task
+ #[arg(long)]
+ pub name: String,
+
+ /// Plan for the new task
+ #[arg(long)]
+ pub plan: String,
+
+ /// Include conversation history
+ #[arg(long, default_value = "true")]
+ pub include_conversation: bool,
+}
+
+/// Arguments for rewind-conversation command.
+#[derive(Args, Debug)]
+pub struct ConversationRewindArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+
+ /// Number of messages to rewind
+ #[arg(long)]
+ pub by_messages: Option<i32>,
+
+ /// Message ID to rewind to
+ #[arg(long)]
+ pub to_message: Option<String>,
+
+ /// Also rewind code to matching checkpoint
+ #[arg(long)]
+ pub rewind_code: bool,
+}