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