1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
use clap::{Parser, Subcommand};
const LONG_ABOUT: &str = r#"
Intent-Engine - AI Long-Term Task Memory System
What does it offer beyond Claude Code's built-in TodoWrite?
✅ Cross-session persistence (never lost)
✅ Hierarchical task trees (parent-child, dependencies)
✅ Decision logs (why you made choices)
✅ Web Dashboard (visual management)
When to use ie instead of TodoWrite?
• Would be a shame to lose it → use ie
• Use once and discard → use TodoWrite
AI Workflow:
ie status ← Run at session start to restore context
ie plan ← Declarative task management (create/update/complete)
ie log ← Record decisions, blockers, milestones
ie search ← Search tasks and event history
Key Rules:
• status:doing requires spec (description)
• status:done requires all children complete first
• parent_id:null creates independent root task
Documentation:
• User Guide: docs/help/user-guide.md
• System Prompt: docs/system_prompt.md
• Interface Spec: docs/spec-03-interface-current.md
"#;
#[derive(Parser, Clone)]
#[command(name = "intent-engine")]
#[command(
about = "AI Long-Term Task Memory - Cross-session persistence, hierarchical tasks, decision logs"
)]
#[command(long_about = LONG_ABOUT)]
#[command(version)]
pub struct Cli {
/// Enable verbose output (-v)
#[arg(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
/// Suppress non-error output (-q)
#[arg(short, long)]
pub quiet: bool,
/// Output logs in JSON format
#[arg(long)]
pub json: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Clone)]
pub enum Commands {
/// Create or update task structures declaratively
#[command(long_about = include_str!("../docs/help/plan.md"))]
Plan {
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Record events (decisions, blockers, milestones, notes)
///
/// Quick event logging for the current focused task or a specific task.
///
/// Examples:
/// ie log decision "Chose JWT authentication"
/// ie log blocker "API rate limit hit" --task 42
/// ie log milestone "MVP complete"
/// ie log note "Consider caching optimization"
Log {
/// Event type: decision, blocker, milestone, note
#[arg(value_enum)]
event_type: LogEventType,
/// Event message (markdown supported)
message: String,
/// Target task ID (optional, uses current focused task if not specified)
#[arg(long)]
task: Option<i64>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Unified search across tasks and events
///
/// Smart keyword detection:
/// - Query with ONLY status keywords (todo, doing, done) → filters by status
/// - Query with other words → uses FTS5 full-text search
///
/// Status filter examples (returns tasks with matching status):
/// ie search "todo doing" # All unfinished tasks (AI session start)
/// ie search "todo" # Only todo tasks
/// ie search "done" # Only completed tasks
///
/// FTS5 search examples (full-text search):
/// ie search "JWT authentication"
/// ie search "API AND client"
/// ie search "blocker" --events --no-tasks
Search {
/// Search query: status keywords (todo/doing/done) or FTS5 syntax
query: String,
/// Search in tasks (default: true)
#[arg(long, default_value = "true")]
tasks: bool,
/// Search in events (default: true)
#[arg(long, default_value = "true")]
events: bool,
/// Maximum number of results (default: 20)
#[arg(long)]
limit: Option<i64>,
/// Result offset for pagination (default: 0)
#[arg(long)]
offset: Option<i64>,
/// Filter by start time (e.g., "7d", "1w", "2025-01-01")
#[arg(long)]
since: Option<String>,
/// Filter by end time (e.g., "1d", "2025-12-31")
#[arg(long)]
until: Option<String>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Initialize a new Intent-Engine project
///
/// Creates a .intent-engine directory with database in the current working directory.
///
/// Examples:
/// ie init # Initialize in current directory
/// ie init --at /my/project # Initialize at specific directory
Init {
/// Custom directory to initialize (default: current directory)
#[arg(long)]
at: Option<String>,
/// Re-initialize even if .intent-engine already exists
#[arg(long)]
force: bool,
},
/// Dashboard management commands
#[command(subcommand)]
Dashboard(DashboardCommands),
/// Check system health and dependencies
Doctor,
/// Show current task context (focus spotlight)
///
/// Displays the focused task with its complete context:
/// - Current task details (full info)
/// - Ancestors chain (full info)
/// - Siblings (id + name + status)
/// - Descendants (id + name + status + parent_id)
///
/// Examples:
/// ie status # Show current focused task context
/// ie status 42 # Show task 42's context (without changing focus)
/// ie status -e # Include event history
Status {
/// Task ID to inspect (optional, defaults to current focused task)
task_id: Option<i64>,
/// Include event history
#[arg(short = 'e', long)]
with_events: bool,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// CRUD operations on individual tasks
///
/// Direct task manipulation commands for creating, reading, updating,
/// and deleting tasks, plus workflow shortcuts (start, done, next).
///
/// Examples:
/// ie task create "Implement auth" --description "JWT-based auth"
/// ie task get 42 --with-context
/// ie task list --status todo
/// ie task start 42
/// ie task done
/// ie task next
#[command(subcommand)]
Task(TaskCommands),
/// Manage LLM-generated suggestions
///
/// View and dismiss suggestions generated by background analysis.
/// Suggestions include task structure reorganization hints and analysis errors.
///
/// Examples:
/// ie suggestions list
/// ie suggestions dismiss 5
/// ie suggestions dismiss --all
/// ie suggestions clear
#[command(subcommand)]
Suggestions(SuggestionsCommands),
/// Configuration management (key-value store)
///
/// Manage configuration settings stored in the project database.
/// Used for LLM endpoints, API keys, and other project-level settings.
///
/// Examples:
/// ie config set llm.endpoint "http://localhost:8080/v1/chat/completions"
/// ie config get llm.api_key
/// ie config list --prefix llm
/// ie config unset llm.model
#[command(subcommand)]
Config(ConfigCommands),
}
#[derive(Subcommand, Clone)]
pub enum SuggestionsCommands {
/// List all active suggestions
///
/// Shows suggestions that haven't been dismissed yet.
///
/// Examples:
/// ie suggestions list
/// ie suggestions list --format json
List {
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Dismiss a specific suggestion
///
/// Mark a suggestion as read/acted upon so it won't be shown again.
///
/// Examples:
/// ie suggestions dismiss 5
/// ie suggestions dismiss --all
Dismiss {
/// Suggestion ID to dismiss (omit to use --all)
id: Option<i64>,
/// Dismiss all active suggestions
#[arg(long)]
all: bool,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Clear all dismissed suggestions from database
///
/// Permanently removes dismissed suggestions to clean up the database.
/// Active (non-dismissed) suggestions are not affected.
///
/// Examples:
/// ie suggestions clear
Clear {
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
}
#[derive(Subcommand, Clone)]
pub enum ConfigCommands {
/// Set a configuration value
///
/// Examples:
/// ie config set llm.endpoint "http://localhost:8080/v1/chat/completions"
/// ie config set llm.api_key "sk-your-key"
Set {
/// Configuration key (e.g., llm.endpoint)
key: String,
/// Configuration value
value: String,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Get a configuration value
///
/// Sensitive values (api_key, secret) are automatically masked.
///
/// Examples:
/// ie config get llm.endpoint
/// ie config get llm.api_key # Shows masked value
Get {
/// Configuration key
key: String,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// List configuration entries
///
/// Examples:
/// ie config list
/// ie config list --prefix llm
List {
/// Filter by key prefix (e.g., "llm" shows all llm.* keys)
#[arg(long)]
prefix: Option<String>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Remove a configuration entry
///
/// Examples:
/// ie config unset llm.model
Unset {
/// Configuration key to remove
key: String,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Test LLM endpoint connectivity
///
/// Sends a simple test message to verify the configured LLM endpoint is working.
///
/// Examples:
/// ie config test-llm
/// ie config test-llm --prompt "Hello, introduce yourself"
TestLlm {
/// Custom test prompt (default: "你好,请用一句话介绍你自己")
#[arg(long)]
prompt: Option<String>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
}
#[derive(Subcommand, Clone)]
pub enum TaskCommands {
/// Create a new task
///
/// Examples:
/// ie task create "Implement auth"
/// ie task create "Add tests" --description "Unit + integration tests" --parent 42
/// ie task create "Fix bug" --status doing --priority 1
Create {
/// Task name
name: String,
/// Task description/spec (markdown supported)
#[arg(short, long)]
description: Option<String>,
/// Parent task ID (0 = root task, omit = auto-parent to current focus)
#[arg(short, long)]
parent: Option<i64>,
/// Initial status (default: todo)
#[arg(short, long, default_value = "todo")]
status: String,
/// Priority (1=critical, 2=high, 3=medium, 4=low)
#[arg(long)]
priority: Option<i32>,
/// Task owner (default: human)
#[arg(long, default_value = "human")]
owner: String,
/// Metadata key=value pairs (e.g., --metadata type=epic --metadata tag=auth)
#[arg(long)]
metadata: Vec<String>,
/// IDs of tasks that block this task (this task depends on them)
#[arg(long = "blocked-by")]
blocked_by: Vec<i64>,
/// IDs of tasks that this task blocks (they depend on this task)
#[arg(long)]
blocks: Vec<i64>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Get task details
///
/// Examples:
/// ie task get 42
/// ie task get 42 --with-events
/// ie task get 42 --with-context
Get {
/// Task ID
id: i64,
/// Include event history
#[arg(short = 'e', long)]
with_events: bool,
/// Include full context (ancestors, siblings, children, dependencies)
#[arg(short = 'c', long)]
with_context: bool,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Update an existing task
///
/// Examples:
/// ie task update 42 --name "New name"
/// ie task update 42 --description "Updated spec" --priority 1
/// ie task update 42 --status doing
/// ie task update 42 --metadata type=epic --metadata "key=" (delete key)
Update {
/// Task ID
id: i64,
/// New task name
#[arg(long)]
name: Option<String>,
/// New description/spec
#[arg(short, long)]
description: Option<String>,
/// New status (todo, doing, done)
#[arg(short, long)]
status: Option<String>,
/// New priority (1=critical, 2=high, 3=medium, 4=low)
#[arg(long)]
priority: Option<i32>,
/// New active form text
#[arg(long)]
active_form: Option<String>,
/// New owner
#[arg(long)]
owner: Option<String>,
/// New parent task ID (0 = make root task)
#[arg(long)]
parent: Option<i64>,
/// Metadata key=value pairs to merge (key= to delete)
#[arg(long)]
metadata: Vec<String>,
/// Add dependency: this task is blocked by these task IDs
#[arg(long = "add-blocked-by")]
add_blocked_by: Vec<i64>,
/// Add dependency: this task blocks these task IDs
#[arg(long = "add-blocks")]
add_blocks: Vec<i64>,
/// Remove dependency: remove blocked-by relationship
#[arg(long = "rm-blocked-by")]
rm_blocked_by: Vec<i64>,
/// Remove dependency: remove blocks relationship
#[arg(long = "rm-blocks")]
rm_blocks: Vec<i64>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// List tasks with optional filters
///
/// Examples:
/// ie task list
/// ie task list --status todo
/// ie task list --parent 42
/// ie task list --tree
List {
/// Filter by status (todo, doing, done)
#[arg(short, long)]
status: Option<String>,
/// Filter by parent ID (0 = root tasks only)
#[arg(short, long)]
parent: Option<i64>,
/// Sort by (id, priority, time, focus_aware)
#[arg(long)]
sort: Option<String>,
/// Maximum number of results
#[arg(long)]
limit: Option<i64>,
/// Result offset for pagination
#[arg(long)]
offset: Option<i64>,
/// Show as hierarchical tree
#[arg(long)]
tree: bool,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Delete a task
///
/// Examples:
/// ie task delete 42
/// ie task delete 42 --cascade
Delete {
/// Task ID
id: i64,
/// Also delete all descendant tasks
#[arg(long)]
cascade: bool,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Start working on a task (sets status to doing and focuses it)
///
/// Examples:
/// ie task start 42
/// ie task start 42 --description "Starting with validation layer"
Start {
/// Task ID
id: i64,
/// Update description before starting
#[arg(short, long)]
description: Option<String>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Mark a task as done
///
/// Examples:
/// ie task done # Complete current focused task
/// ie task done 42 # Focus task 42 then complete it
Done {
/// Task ID (optional, defaults to current focused task)
id: Option<i64>,
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
/// Suggest the next task to work on
///
/// Uses context-aware priority: subtasks of focused task first,
/// then top-level tasks, based on priority ordering.
///
/// Examples:
/// ie task next
Next {
/// Output format (text or json)
#[arg(long, default_value = "text")]
format: String,
},
}
#[derive(clap::ValueEnum, Clone, Debug)]
pub enum LogEventType {
Decision,
Blocker,
Milestone,
Note,
}
impl LogEventType {
pub fn as_str(&self) -> &str {
match self {
LogEventType::Decision => "decision",
LogEventType::Blocker => "blocker",
LogEventType::Milestone => "milestone",
LogEventType::Note => "note",
}
}
}
#[derive(Subcommand, Clone)]
pub enum DashboardCommands {
/// Start the Dashboard server
Start {
/// Port to bind (default: 11391)
#[arg(long)]
port: Option<u16>,
/// Auto-open browser
#[arg(long)]
browser: bool,
/// Start in daemon mode (background)
#[arg(long)]
daemon: bool,
},
/// Stop the Dashboard server
Stop {
/// Stop all running dashboards
#[arg(long)]
all: bool,
},
/// Show Dashboard status
Status {
/// Show all instances
#[arg(long)]
all: bool,
},
/// List registered projects
List,
/// Open Dashboard in browser
Open,
}