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 /// Start MCP server for AI assistants (JSON-RPC stdio)
60 #[command(name = "mcp-server")]
61 McpServer,
62}
63
64#[derive(Subcommand)]
65pub enum TaskCommands {
66 /// Add a new task
67 Add {
68 /// Task name
69 #[arg(long)]
70 name: String,
71
72 /// Parent task ID
73 #[arg(long)]
74 parent: Option<i64>,
75
76 /// Read spec from stdin
77 #[arg(long)]
78 spec_stdin: bool,
79 },
80
81 /// Get a task by ID
82 Get {
83 /// Task ID
84 id: i64,
85
86 /// Include events summary
87 #[arg(long)]
88 with_events: bool,
89 },
90
91 /// Update a task
92 Update {
93 /// Task ID
94 id: i64,
95
96 /// New task name
97 #[arg(long)]
98 name: Option<String>,
99
100 /// New parent task ID
101 #[arg(long)]
102 parent: Option<i64>,
103
104 /// New status
105 #[arg(long)]
106 status: Option<String>,
107
108 /// Task complexity (1-10)
109 #[arg(long)]
110 complexity: Option<i32>,
111
112 /// Task priority
113 #[arg(long)]
114 priority: Option<i32>,
115
116 /// Read spec from stdin
117 #[arg(long)]
118 spec_stdin: bool,
119 },
120
121 /// Delete a task
122 Del {
123 /// Task ID
124 id: i64,
125 },
126
127 /// Find tasks with filters
128 Find {
129 /// Filter by status
130 #[arg(long)]
131 status: Option<String>,
132
133 /// Filter by parent ID (use "null" for no parent)
134 #[arg(long)]
135 parent: Option<String>,
136 },
137
138 /// Start a task (atomic: update status + set current)
139 Start {
140 /// Task ID
141 id: i64,
142
143 /// Include events summary
144 #[arg(long)]
145 with_events: bool,
146 },
147
148 /// Complete the current focused task (atomic: check children + update status + clear current)
149 /// This command only operates on the current_task_id. It will:
150 /// - Check all subtasks are done
151 /// - Update the task status to done
152 /// - Clear the current_task_id
153 ///
154 /// Prerequisites: A task must be set as current (via `current --set <ID>`)
155 Done,
156
157 /// Intelligently recommend the next task to work on
158 ///
159 /// This command uses a context-aware priority model to recommend a single task:
160 /// 1. First priority: Subtasks of the current focused task (depth-first)
161 /// 2. Second priority: Top-level tasks (breadth-first)
162 ///
163 /// The command is non-interactive and does not modify task status.
164 PickNext {
165 /// Output format (text or json)
166 #[arg(long, default_value = "text")]
167 format: String,
168 },
169
170 /// Create a subtask under current task and switch to it
171 SpawnSubtask {
172 /// Subtask name
173 #[arg(long)]
174 name: String,
175
176 /// Read spec from stdin
177 #[arg(long)]
178 spec_stdin: bool,
179 },
180
181 /// Switch to a specific task (atomic: update to doing + set current)
182 Switch {
183 /// Task ID
184 id: i64,
185 },
186
187 /// Search tasks by content using full-text search
188 Search {
189 /// Search query (supports FTS5 syntax like "bug AND NOT critical")
190 query: String,
191 },
192}
193
194#[derive(Subcommand)]
195pub enum EventCommands {
196 /// Add a new event
197 Add {
198 /// Task ID (optional, uses current task if not specified)
199 #[arg(long)]
200 task_id: Option<i64>,
201
202 /// Log type
203 #[arg(long = "type")]
204 log_type: String,
205
206 /// Read discussion data from stdin
207 #[arg(long)]
208 data_stdin: bool,
209 },
210
211 /// List events for a task
212 List {
213 /// Task ID
214 #[arg(long)]
215 task_id: i64,
216
217 /// Maximum number of events to return
218 #[arg(long)]
219 limit: Option<i64>,
220 },
221}