intent_engine/
cli.rs

1use clap::{Parser, Subcommand};
2
3#[derive(Parser)]
4#[command(name = "intent-engine")]
5#[command(about = "A command-line database service for tracking strategic intent", long_about = None)]
6pub struct Cli {
7    #[command(subcommand)]
8    pub command: Commands,
9}
10
11#[derive(Subcommand)]
12pub enum Commands {
13    /// Task management commands
14    #[command(subcommand)]
15    Task(TaskCommands),
16
17    /// Workspace state management
18    Current {
19        /// Set the current task ID
20        #[arg(long)]
21        set: Option<i64>,
22    },
23
24    /// Generate analysis and reports
25    Report {
26        /// Time duration (e.g., "7d", "2h", "30m")
27        #[arg(long)]
28        since: Option<String>,
29
30        /// Filter by status
31        #[arg(long)]
32        status: Option<String>,
33
34        /// Filter by name pattern (FTS5)
35        #[arg(long)]
36        filter_name: Option<String>,
37
38        /// Filter by spec pattern (FTS5)
39        #[arg(long)]
40        filter_spec: Option<String>,
41
42        /// Output format
43        #[arg(long, default_value = "json")]
44        format: String,
45
46        /// Return summary only
47        #[arg(long)]
48        summary_only: bool,
49    },
50
51    /// Event logging commands
52    #[command(subcommand)]
53    Event(EventCommands),
54
55    /// Check system health and dependencies
56    Doctor,
57}
58
59#[derive(Subcommand)]
60pub enum TaskCommands {
61    /// Add a new task
62    Add {
63        /// Task name
64        #[arg(long)]
65        name: String,
66
67        /// Parent task ID
68        #[arg(long)]
69        parent: Option<i64>,
70
71        /// Read spec from stdin
72        #[arg(long)]
73        spec_stdin: bool,
74    },
75
76    /// Get a task by ID
77    Get {
78        /// Task ID
79        id: i64,
80
81        /// Include events summary
82        #[arg(long)]
83        with_events: bool,
84    },
85
86    /// Update a task
87    Update {
88        /// Task ID
89        id: i64,
90
91        /// New task name
92        #[arg(long)]
93        name: Option<String>,
94
95        /// New parent task ID
96        #[arg(long)]
97        parent: Option<i64>,
98
99        /// New status
100        #[arg(long)]
101        status: Option<String>,
102
103        /// Task complexity (1-10)
104        #[arg(long)]
105        complexity: Option<i32>,
106
107        /// Task priority
108        #[arg(long)]
109        priority: Option<i32>,
110
111        /// Read spec from stdin
112        #[arg(long)]
113        spec_stdin: bool,
114    },
115
116    /// Delete a task
117    Del {
118        /// Task ID
119        id: i64,
120    },
121
122    /// Find tasks with filters
123    Find {
124        /// Filter by status
125        #[arg(long)]
126        status: Option<String>,
127
128        /// Filter by parent ID (use "null" for no parent)
129        #[arg(long)]
130        parent: Option<String>,
131    },
132
133    /// Start a task (atomic: update status + set current)
134    Start {
135        /// Task ID
136        id: i64,
137
138        /// Include events summary
139        #[arg(long)]
140        with_events: bool,
141    },
142
143    /// Complete the current focused task (atomic: check children + update status + clear current)
144    /// This command only operates on the current_task_id. It will:
145    /// - Check all subtasks are done
146    /// - Update the task status to done
147    /// - Clear the current_task_id
148    ///
149    /// Prerequisites: A task must be set as current (via `current --set <ID>`)
150    Done,
151
152    /// Intelligently pick tasks from todo and move to doing
153    PickNext {
154        /// Maximum number of tasks to pick
155        #[arg(long, default_value = "5")]
156        max_count: usize,
157
158        /// Maximum total tasks allowed in doing status
159        #[arg(long, default_value = "5")]
160        capacity: usize,
161    },
162
163    /// Create a subtask under current task and switch to it
164    SpawnSubtask {
165        /// Subtask name
166        #[arg(long)]
167        name: String,
168
169        /// Read spec from stdin
170        #[arg(long)]
171        spec_stdin: bool,
172    },
173
174    /// Switch to a specific task (atomic: update to doing + set current)
175    Switch {
176        /// Task ID
177        id: i64,
178    },
179
180    /// Search tasks by content using full-text search
181    Search {
182        /// Search query (supports FTS5 syntax like "bug AND NOT critical")
183        query: String,
184    },
185}
186
187#[derive(Subcommand)]
188pub enum EventCommands {
189    /// Add a new event
190    Add {
191        /// Task ID
192        #[arg(long)]
193        task_id: i64,
194
195        /// Log type
196        #[arg(long = "type")]
197        log_type: String,
198
199        /// Read discussion data from stdin
200        #[arg(long)]
201        data_stdin: bool,
202    },
203
204    /// List events for a task
205    List {
206        /// Task ID
207        #[arg(long)]
208        task_id: i64,
209
210        /// Maximum number of events to return
211        #[arg(long)]
212        limit: Option<i64>,
213    },
214}