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 recommend the next task to work on
154    ///
155    /// This command uses a context-aware priority model to recommend a single task:
156    /// 1. First priority: Subtasks of the current focused task (depth-first)
157    /// 2. Second priority: Top-level tasks (breadth-first)
158    ///
159    /// The command is non-interactive and does not modify task status.
160    PickNext {
161        /// Output format (text or json)
162        #[arg(long, default_value = "text")]
163        format: String,
164    },
165
166    /// Create a subtask under current task and switch to it
167    SpawnSubtask {
168        /// Subtask name
169        #[arg(long)]
170        name: String,
171
172        /// Read spec from stdin
173        #[arg(long)]
174        spec_stdin: bool,
175    },
176
177    /// Switch to a specific task (atomic: update to doing + set current)
178    Switch {
179        /// Task ID
180        id: i64,
181    },
182
183    /// Search tasks by content using full-text search
184    Search {
185        /// Search query (supports FTS5 syntax like "bug AND NOT critical")
186        query: String,
187    },
188}
189
190#[derive(Subcommand)]
191pub enum EventCommands {
192    /// Add a new event
193    Add {
194        /// Task ID (optional, uses current task if not specified)
195        #[arg(long)]
196        task_id: Option<i64>,
197
198        /// Log type
199        #[arg(long = "type")]
200        log_type: String,
201
202        /// Read discussion data from stdin
203        #[arg(long)]
204        data_stdin: bool,
205    },
206
207    /// List events for a task
208    List {
209        /// Task ID
210        #[arg(long)]
211        task_id: i64,
212
213        /// Maximum number of events to return
214        #[arg(long)]
215        limit: Option<i64>,
216    },
217}