mycelium-manager 0.2.3

A robust, production-grade task/plan manager CLI (binary: myc)
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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
use clap::{Args, Parser, Subcommand};

#[derive(Parser)]
#[command(name = "myc")]
#[command(about = "A robust, production-grade task/plan manager CLI")]
#[command(version = env!("CARGO_PKG_VERSION"))]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,

    /// Output format (table, json)
    #[arg(global = true, short, long, default_value = "table")]
    pub format: OutputFormat,

    /// Suppress non-error output
    #[arg(global = true, short, long)]
    pub quiet: bool,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Initialize a new mycelium project
    Init,

    /// Generate or update AGENTS.md with mycelium instructions
    PrimeAgents {
        /// Force regeneration even if file exists
        #[arg(long)]
        force: bool,

        /// Path to AGENTS.md (defaults to ./AGENTS.md)
        #[arg(long)]
        path: Option<std::path::PathBuf>,
    },

    /// Manage epics
    #[command(subcommand)]
    Epic(EpicCommands),

    /// Manage tasks
    #[command(subcommand)]
    Task(TaskCommands),

    /// Manage assignees
    #[command(subcommand)]
    Assignee(AssigneeCommands),

    /// Manage dependencies
    #[command(subcommand)]
    Deps(DepsCommands),

    /// List and filter tasks
    List(ListArgs),

    /// Show project summary
    Summary,

    /// Export data
    #[command(subcommand)]
    Export(ExportCommands),

    /// Run health checks on the project
    Doctor {
        /// Automatically fix issues where possible
        #[arg(long)]
        fix: bool,
    },

    /// Linear integration (bidirectional sync)
    #[command(subcommand)]
    Linear(LinearCommands),

    /// Manage follow-ups (lightweight "oh-by-the-way" items)
    #[command(subcommand, alias = "fu")]
    Followup(FollowupCommands),
}

#[derive(Subcommand)]
pub enum FollowupCommands {
    /// Add a follow-up (body required, title optional)
    Add {
        /// Follow-up body (required)
        body: String,

        /// Optional title (defaults to first 60 chars of body)
        #[arg(short, long)]
        title: Option<String>,
    },

    /// List follow-ups (defaults to all)
    List {
        /// Filter by exact status: open, in_progress, done, wontfix
        #[arg(short, long, conflicts_with_all = ["all", "open", "closed"])]
        status: Option<String>,

        /// Show all follow-ups (default)
        #[arg(short = 'a', long, conflicts_with_all = ["open", "closed"])]
        all: bool,

        /// Show only active items (open + in_progress)
        #[arg(short = 'o', long, conflicts_with = "closed")]
        open: bool,

        /// Show only closed items (done + wontfix)
        #[arg(short = 'c', long)]
        closed: bool,
    },

    /// Show a follow-up
    Show {
        /// Follow-up ID
        id: i64,
    },

    /// Pull the lowest-ID active follow-up (agent loop primitive)
    Next,

    /// Mark a follow-up as in_progress
    Start {
        /// Follow-up ID
        id: i64,
    },

    /// Mark a follow-up as done
    Done {
        /// Follow-up ID
        id: i64,

        /// Optional closure reason
        #[arg(short, long)]
        reason: Option<String>,
    },

    /// Mark a follow-up as wontfix
    Wontfix {
        /// Follow-up ID
        id: i64,

        /// Optional closure reason
        #[arg(short, long)]
        reason: Option<String>,
    },

    /// Reopen a follow-up
    Reopen {
        /// Follow-up ID
        id: i64,
    },

    /// Replace body or title of a follow-up
    Edit {
        /// Follow-up ID
        id: i64,

        /// New body (omit to keep current)
        #[arg(short, long)]
        body: Option<String>,

        /// New title (use `-` to clear, omit to keep current)
        #[arg(short, long)]
        title: Option<String>,
    },

    /// Append text to a follow-up's body (timestamped, preserves existing)
    Append {
        /// Follow-up ID
        id: i64,

        /// Text to append
        text: String,
    },

    /// Delete a follow-up
    Rm {
        /// Follow-up ID
        id: i64,

        /// Skip confirmation
        #[arg(long)]
        force: bool,
    },

    /// Promote a follow-up to a full task (marks follow-up done)
    Promote {
        /// Follow-up ID
        id: i64,

        /// Epic ID to assign the new task to
        #[arg(short, long)]
        epic: Option<i64>,

        /// Priority (low, medium, high, critical)
        #[arg(short, long, default_value = "medium")]
        priority: String,
    },

    /// Show counts (great for end-of-task agent checks)
    Count,
}

#[derive(Subcommand)]
pub enum LinearCommands {
    /// Set up Linear integration (API key, team, mappings)
    Setup,

    /// Bidirectional sync with Linear
    Sync {
        /// Force local changes to win on conflicts
        #[arg(long)]
        force_local: bool,

        /// Force remote changes to win on conflicts
        #[arg(long)]
        force_remote: bool,
    },

    /// Push local tasks to Linear
    Push,

    /// Pull Linear issues to local
    Pull,

    /// Show Linear integration status
    Status,

    /// Remove Linear integration and sync data
    Unlink,
}

#[derive(Subcommand)]
pub enum EpicCommands {
    /// Create a new epic
    Create {
        /// Epic title
        #[arg(short, long)]
        title: String,

        /// Epic description
        #[arg(short, long)]
        description: Option<String>,

        /// Notes (free-form text for comments, tips, or context)
        #[arg(short = 'n', long)]
        notes: Option<String>,

        /// Additional user info (context for agents or collaborators)
        #[arg(long)]
        user_info: Option<String>,
    },

    /// List all epics
    List,

    /// Show epic details
    Show {
        /// Epic ID
        id: i64,
    },

    /// Update an epic
    Update {
        /// Epic ID
        id: i64,

        /// New title
        #[arg(short, long)]
        title: Option<String>,

        /// New description
        #[arg(short, long)]
        description: Option<String>,

        /// New status
        #[arg(short, long, value_parser = ["open", "in_progress", "closed"])]
        status: Option<String>,

        /// New notes (use - to remove)
        #[arg(short = 'n', long)]
        notes: Option<String>,

        /// New user info (use - to remove)
        #[arg(long)]
        user_info: Option<String>,

        /// Agent questions (use - to remove)
        #[arg(long)]
        agent_questions: Option<String>,
    },

    /// Add a note to an epic
    Note {
        /// Epic ID
        epic_id: i64,

        /// Note content
        content: String,
    },

    /// Show epic notes
    Notes {
        /// Epic ID
        epic_id: i64,
    },

    /// Delete an epic
    Delete {
        /// Epic ID
        id: i64,

        /// Force deletion without confirmation
        #[arg(long)]
        force: bool,
    },
}

#[derive(Subcommand)]
pub enum TaskCommands {
    /// Create a new task
    Create {
        /// Task title
        #[arg(short, long)]
        title: String,

        /// Task description
        #[arg(short, long)]
        description: Option<String>,

        /// Epic ID to assign to
        #[arg(short, long)]
        epic: Option<i64>,

        /// Priority (low, medium, high, critical)
        #[arg(short, long, default_value = "medium")]
        priority: String,

        /// Assignee ID
        #[arg(short, long)]
        assignee: Option<i64>,

        /// Due date (YYYY-MM-DD)
        #[arg(short = 'u', long)]
        due: Option<String>,

        /// Tags (comma-separated, e.g., "frontend,urgent")
        #[arg(short = 'g', long)]
        tags: Option<String>,

        /// Notes (free-form text for comments, tips, or context)
        #[arg(short = 'n', long)]
        notes: Option<String>,

        /// Additional user info (context for agents or collaborators)
        #[arg(long)]
        user_info: Option<String>,

        /// Use a template
        #[arg(short = 'm', long)]
        template: Option<String>,
    },

    /// List tasks
    List {
        /// Filter by epic ID
        #[arg(short, long)]
        epic: Option<i64>,

        /// Filter by status (defaults to 'open')
        #[arg(short, long)]
        status: Option<String>,

        /// Filter by priority
        #[arg(short, long)]
        priority: Option<String>,

        /// Filter by assignee ID
        #[arg(short, long)]
        assignee: Option<i64>,

        /// Show only blocked tasks
        #[arg(long)]
        blocked: bool,

        /// Show only overdue tasks
        #[arg(long)]
        overdue: bool,

        /// Filter by tag
        #[arg(short, long)]
        tag: Option<String>,

        /// Show all tasks including closed (overrides default open filter)
        #[arg(long)]
        all: bool,
    },

    /// Batch create tasks from JSON file
    Batch {
        /// JSON file path
        #[arg(short, long)]
        file: String,
    },

    /// Show task details
    Show {
        /// Task ID
        id: i64,
    },

    /// Update a task
    Update {
        /// Task ID
        id: i64,

        /// New title
        #[arg(short, long)]
        title: Option<String>,

        /// New description
        #[arg(short, long)]
        description: Option<String>,

        /// New status
        #[arg(short, long)]
        status: Option<String>,

        /// New priority
        #[arg(short, long)]
        priority: Option<String>,

        /// New epic ID (use 0 to remove)
        #[arg(short, long)]
        epic: Option<i64>,

        /// New assignee ID (use 0 to remove)
        #[arg(short, long)]
        assignee: Option<i64>,

        /// New due date (YYYY-MM-DD)
        #[arg(short = 'u', long)]
        due: Option<String>,

        /// New tags (comma-separated, use - to remove)
        #[arg(short = 'g', long)]
        tags: Option<String>,

        /// New notes (use - to remove)
        #[arg(short = 'n', long)]
        notes: Option<String>,

        /// New user info (use - to remove)
        #[arg(long)]
        user_info: Option<String>,

        /// Agent questions (use - to remove)
        #[arg(long)]
        agent_questions: Option<String>,
    },

    /// Delete a task
    Delete {
        /// Task ID
        id: i64,

        /// Force deletion without confirmation
        #[arg(long)]
        force: bool,
    },

    /// Assign a task to someone
    Assign {
        /// Task ID
        task_id: i64,

        /// Assignee ID (use 0 to unassign)
        assignee_id: i64,
    },

    /// Link task to external resources
    #[command(subcommand)]
    Link(LinkCommands),

    /// Unlink external reference
    Unlink {
        /// Reference ID
        ref_id: i64,
    },

    /// Close a task
    Close {
        /// Task ID
        id: i64,

        /// Force close even if blocked
        #[arg(long)]
        force: bool,
    },

    /// Reopen a task
    Reopen {
        /// Task ID
        id: i64,
    },

    /// Add a note to a task
    Note {
        /// Task ID
        task_id: i64,

        /// Note content
        content: String,
    },

    /// Show task notes
    Notes {
        /// Task ID
        task_id: i64,
    },

    /// Clone a task
    Clone {
        /// Task ID to clone
        id: i64,

        /// New title (optional, defaults to "Original (copy)")
        #[arg(short, long)]
        title: Option<String>,
    },

    /// Batch operations on multiple tasks
    #[command(subcommand)]
    BatchOp(BatchOpCommands),
}

#[derive(Subcommand)]
pub enum BatchOpCommands {
    /// Close multiple tasks
    Close {
        /// Task IDs to close
        ids: Vec<i64>,

        /// Force close even if blocked
        #[arg(long)]
        force: bool,
    },

    /// Add a tag to multiple tasks
    Tag {
        /// Tag to add
        tag: String,

        /// Task IDs
        ids: Vec<i64>,
    },

    /// Move multiple tasks to an epic
    Move {
        /// Epic ID (use 0 for no epic)
        epic_id: i64,

        /// Task IDs
        ids: Vec<i64>,
    },

    /// Delete tasks that are not assigned to any epic
    DeleteOrphans {
        /// Force deletion without confirmation
        #[arg(long)]
        force: bool,
    },
}

#[derive(Subcommand)]
pub enum LinkCommands {
    /// Link to GitHub issue
    GithubIssue {
        /// Task ID
        #[arg(short, long)]
        task: i64,

        /// GitHub reference (owner/repo#number)
        reference: String,
    },

    /// Link to GitHub PR
    GithubPr {
        /// Task ID
        #[arg(short, long)]
        task: i64,

        /// GitHub reference (owner/repo#number)
        reference: String,
    },

    /// Link to URL
    Url {
        /// Task ID
        #[arg(short, long)]
        task: i64,

        /// URL
        url: String,
    },

    /// Mark task as blocking another
    Blocks {
        /// Task ID that blocks
        #[arg(short, long)]
        task: i64,

        /// Task ID being blocked
        blocked: i64,
    },
}

#[derive(Subcommand)]
pub enum AssigneeCommands {
    /// Create a new assignee
    Create {
        /// Assignee name
        #[arg(short, long)]
        name: String,

        /// Email address
        #[arg(short, long)]
        email: Option<String>,

        /// GitHub username
        #[arg(short, long)]
        github: Option<String>,
    },

    /// List all assignees
    List,

    /// Show assignee details
    Show {
        /// Assignee ID
        id: i64,
    },

    /// Delete an assignee
    Delete {
        /// Assignee ID
        id: i64,

        /// Force deletion without confirmation
        #[arg(short, long)]
        force: bool,
    },
}

#[derive(Subcommand)]
pub enum DepsCommands {
    /// Show dependency tree for a task
    Show {
        /// Task ID
        task_id: i64,
    },

    /// Remove a dependency
    Unlink {
        /// Task ID
        task_id: i64,

        /// Task ID that was being blocked
        blocked_task_id: i64,
    },
}

#[derive(Args)]
pub struct ListArgs {
    /// Filter by epic ID
    #[arg(short, long)]
    pub epic: Option<i64>,

    /// Filter by status (defaults to 'open')
    #[arg(short, long)]
    pub status: Option<String>,

    /// Filter by priority
    #[arg(short, long)]
    pub priority: Option<String>,

    /// Filter by assignee ID
    #[arg(short, long)]
    pub assignee: Option<i64>,

    /// Show only blocked tasks
    #[arg(long)]
    pub blocked: bool,

    /// Show only overdue tasks
    #[arg(long)]
    pub overdue: bool,

    /// Filter by tag
    #[arg(short, long)]
    pub tag: Option<String>,

    /// Show all tasks including closed (overrides default open filter)
    #[arg(long)]
    pub all: bool,
}

#[derive(Subcommand)]
pub enum ExportCommands {
    /// Export to JSON
    Json {
        /// Output file (defaults to stdout)
        #[arg(short, long)]
        output: Option<String>,
    },

    /// Export to CSV
    Csv {
        /// Output file (defaults to stdout)
        #[arg(short, long)]
        output: Option<String>,
    },
}

#[derive(Clone, Debug)]
pub enum OutputFormat {
    Table,
    Json,
}

impl std::str::FromStr for OutputFormat {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().as_str() {
            "table" => Ok(OutputFormat::Table),
            "json" => Ok(OutputFormat::Json),
            _ => Err(format!("Invalid format: {}. Use 'table' or 'json'", s)),
        }
    }
}

impl std::fmt::Display for OutputFormat {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            OutputFormat::Table => write!(f, "table"),
            OutputFormat::Json => write!(f, "json"),
        }
    }
}