smart-tree 8.0.1

Smart Tree - An intelligent, AI-friendly directory visualization tool
Documentation
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
// -----------------------------------------------------------------------------
// CLI Definitions for Smart Tree
// All command-line argument parsing happens here using clap.
// Extracted from main.rs to keep things organized!
// -----------------------------------------------------------------------------

use anyhow::{Context, Result};
use chrono::NaiveDate;
use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
use std::time::SystemTime;

/// Smart Tree CLI - intelligent directory visualization
#[derive(Parser, Debug)]
#[command(
    name = "st",
    about = "Smart Tree - An intelligent directory visualization tool. Not just a tree, it's a smart-tree!",
    author
)]
pub struct Cli {
    // =========================================================================
    // GETTING STARTED
    // =========================================================================
    /// Show the cheatsheet - quick reference for all commands
    #[arg(long, exclusive = true, help_heading = "Getting Started")]
    pub cheet: bool,

    /// Show version information and check for updates
    #[arg(short = 'V', long, exclusive = true, help_heading = "Getting Started")]
    pub version: bool,

    /// Generate shell completion scripts (bash, zsh, fish, powershell)
    #[arg(
        long,
        exclusive = true,
        value_name = "SHELL",
        help_heading = "Getting Started"
    )]
    pub completions: Option<clap_complete::Shell>,

    /// Generate the man page
    #[arg(long, exclusive = true, help_heading = "Getting Started")]
    pub man: bool,

    /// Check for updates and install the latest version
    #[arg(long, exclusive = true, help_heading = "Getting Started")]
    pub update: bool,

    /// Skip the automatic update check on startup
    #[arg(long, help_heading = "Getting Started")]
    pub no_update_check: bool,

    // =========================================================================
    // INTERACTIVE MODES
    // =========================================================================
    /// Launch Spicy TUI - interactive file browser with fuzzy search!
    #[arg(long, help_heading = "Interactive Modes")]
    pub spicy: bool,

    /// Launch Smart Tree Terminal Interface (STTI)
    #[arg(long, exclusive = true, help_heading = "Interactive Modes")]
    pub terminal: bool,

    /// Launch web dashboard (browser-based terminal + file browser)
    #[arg(long, exclusive = true, help_heading = "Interactive Modes")]
    pub dashboard: bool,

    /// Open browser automatically when starting dashboard
    #[arg(long, requires = "dashboard", help_heading = "Interactive Modes")]
    pub open_browser: bool,

    /// Network CIDR allow-list for dashboard (e.g., 192.168.1.0/24)
    #[arg(long, value_name = "CIDR", requires = "dashboard", help_heading = "Interactive Modes")]
    pub allow: Vec<String>,

    /// Start HTTP daemon (MCP over HTTP, LLM proxy, The Custodian)
    #[arg(long, alias = "daemon", help_heading = "Interactive Modes")]
    pub http_daemon: bool,

    // =========================================================================
    // MCP SERVER (via Daemon)
    // =========================================================================
    /// Run as MCP server for AI assistants (auto-starts daemon)
    #[arg(long, exclusive = true, help_heading = "MCP Server")]
    pub mcp: bool,

    /// Install Smart Tree as MCP server in Claude Desktop
    #[arg(long, exclusive = true, help_heading = "MCP Server")]
    pub mcp_install: bool,

    /// Uninstall Smart Tree MCP server from Claude Desktop
    #[arg(long, exclusive = true, help_heading = "MCP Server")]
    pub mcp_uninstall: bool,

    /// Check MCP installation status in Claude Desktop
    #[arg(long, exclusive = true, help_heading = "MCP Server")]
    pub mcp_status: bool,

    // =========================================================================
    // DAEMON CONTROL
    // =========================================================================
    /// Set the log level
    #[arg(long, value_enum, help_heading = "Daemon Control")]
    pub log_level: Option<LogLevel>,

    /// Start the Smart Tree daemon
    #[arg(long, exclusive = true, help_heading = "Daemon Control")]
    pub daemon_start: bool,

    /// Stop the Smart Tree daemon
    #[arg(long, exclusive = true, help_heading = "Daemon Control")]
    pub daemon_stop: bool,

    /// Show Smart Tree daemon status
    #[arg(long, exclusive = true, help_heading = "Daemon Control")]
    pub daemon_status: bool,

    /// Get context from the daemon
    #[arg(long, exclusive = true, help_heading = "Daemon Control")]
    pub daemon_context: bool,

    /// List projects tracked by the daemon
    #[arg(long, exclusive = true, help_heading = "Daemon Control")]
    pub daemon_projects: bool,

    /// Show Foken credits from daemon
    #[arg(long, exclusive = true, help_heading = "Daemon Control")]
    pub daemon_credits: bool,

    /// [DEPRECATED: use `st service install`] Install daemon as a system service
    #[arg(long, exclusive = true, help_heading = "Daemon Control", hide = true)]
    pub daemon_install: bool,

    // =========================================================================
    // CONSCIOUSNESS & MEMORY
    // =========================================================================
    /// Save agent consciousness state to .aye_consciousness.m8
    #[arg(long, exclusive = true, help_heading = "Consciousness & Memory")]
    pub agent_save: bool,

    /// Restore agent consciousness from .aye_consciousness.m8
    #[arg(long, exclusive = true, help_heading = "Consciousness & Memory")]
    pub agent_restore: bool,

    /// Show agent consciousness status and summary
    #[arg(long, exclusive = true, help_heading = "Consciousness & Memory")]
    pub agent_context: bool,

    /// Ultra-compressed consciousness restoration format
    #[arg(long, exclusive = true, help_heading = "Consciousness & Memory")]
    pub agent_kickstart: bool,

    /// Dump raw consciousness file content for debugging
    #[arg(long, exclusive = true, help_heading = "Consciousness & Memory")]
    pub agent_dump: bool,

    /// Anchor a memory: --memory-anchor <TYPE> <KEYWORDS> <CONTEXT>
    /// Types: insight, decision, pattern, gotcha, todo
    #[arg(long, num_args = 3, value_names = ["TYPE", "KEYWORDS", "CONTEXT"], help_heading = "Consciousness & Memory")]
    pub memory_anchor: Option<Vec<String>>,

    /// Find memories by keywords (comma-separated)
    #[arg(long, value_name = "KEYWORDS", help_heading = "Consciousness & Memory")]
    pub memory_find: Option<String>,

    /// Show memory statistics
    #[arg(long, exclusive = true, help_heading = "Consciousness & Memory")]
    pub memory_stats: bool,

    /// Update .m8 consciousness files for a directory
    #[arg(long, value_name = "PATH", help_heading = "Consciousness & Memory")]
    pub update_consciousness: Option<String>,

    // =========================================================================
    // SECURITY
    // =========================================================================
    /// Scan codebase for supply chain attack patterns (default: current dir)
    #[arg(long, value_name = "PATH", default_missing_value = ".", num_args = 0..=1, help_heading = "Security")]
    pub security_scan: Option<String>,

    /// Scan a file for prompt injection patterns
    #[arg(long, value_name = "FILE", help_heading = "Security")]
    pub guardian_scan: Option<String>,

    /// Run Guardian daemon for system-wide AI protection
    #[arg(long, exclusive = true, help_heading = "Security")]
    pub guardian_daemon: bool,

    /// Security cleanup - detect and remove malicious MCP entries
    #[arg(long, exclusive = true, help_heading = "Security")]
    pub cleanup: bool,

    // =========================================================================
    // HOOKS
    // =========================================================================
    /// Install Smart Tree hooks to AI Agent settings
    #[arg(long, exclusive = true, help_heading = "Hooks")]
    pub hooks_install: bool,

    /// Manage hooks: enable, disable, status
    #[arg(long, value_name = "ACTION", value_parser = ["enable", "disable", "status"], help_heading = "Hooks")]
    pub hooks_config: Option<String>,

    // =========================================================================
    // MEGA SESSIONS
    // =========================================================================
    /// Start a mega session (persistent cross-context conversation)
    #[arg(long, value_name = "NAME", default_missing_value = "", num_args = 0..=1, help_heading = "Mega Sessions")]
    pub mega_start: Option<String>,

    /// Save current mega session snapshot
    #[arg(long, exclusive = true, help_heading = "Mega Sessions")]
    pub mega_save: bool,

    /// List all mega sessions
    #[arg(long, exclusive = true, help_heading = "Mega Sessions")]
    pub mega_list: bool,

    /// Show mega session statistics
    #[arg(long, exclusive = true, help_heading = "Mega Sessions")]
    pub mega_stats: bool,

    // =========================================================================
    // ANALYSIS
    // =========================================================================
    /// Show tokenization statistics for a path
    #[arg(long, value_name = "PATH", help_heading = "Analysis")]
    pub token_stats: Option<String>,

    /// Get wave frequency for a directory
    #[arg(long, value_name = "PATH", help_heading = "Analysis")]
    pub get_frequency: Option<String>,

    // =========================================================================
    // LOGGING & TRANSPARENCY
    // =========================================================================
    /// Enable activity logging to JSONL file
    #[arg(long, value_name = "PATH", help_heading = "Logging & Transparency")]
    pub log: Option<Option<String>>,

    /// Control smart tips (on/off)
    #[arg(long, value_name = "STATE", value_parser = ["on", "off"], help_heading = "Logging & Transparency")]
    pub tips: Option<String>,

    // =========================================================================
    // TOP-LEVEL COMMANDS
    // =========================================================================
    #[command(subcommand)]
    pub cmd: Option<Cmd>,

    // =========================================================================
    // SCAN OPTIONS
    // =========================================================================
    /// Path to analyze (directory, file, URL, or stream)
    pub path: Option<String>,

    /// Specify input type explicitly (filesystem, qcp, sse, openapi, mem8)
    #[arg(long, value_name = "TYPE")]
    pub input: Option<String>,

    #[command(flatten)]
    pub scan_opts: ScanArgs,
}

#[derive(Parser, Debug)]
pub struct ScanArgs {
    // =========================================================================
    // OUTPUT FORMAT
    // =========================================================================
    /// Output format (classic, ai, quantum, json, etc.)
    #[arg(
        short,
        long,
        value_enum,
        default_value = "auto",
        help_heading = "Output Format"
    )]
    pub mode: OutputMode,

    // =========================================================================
    // FILTERING - What to include/exclude
    // =========================================================================
    /// Find files matching regex pattern (e.g., --find "README\.md")
    #[arg(long, help_heading = "Filtering")]
    pub find: Option<String>,

    /// Filter by file extension (e.g., --type rs)
    #[arg(long = "type", help_heading = "Filtering")]
    pub filter_type: Option<String>,

    /// Filter by entry type: f (files) or d (directories)
    #[arg(long = "entry-type", value_parser = ["f", "d"], help_heading = "Filtering")]
    pub entry_type: Option<String>,

    /// Only files larger than size (e.g., --min-size 1M)
    #[arg(long, help_heading = "Filtering")]
    pub min_size: Option<String>,

    /// Only files smaller than size (e.g., --max-size 100K)
    #[arg(long, help_heading = "Filtering")]
    pub max_size: Option<String>,

    /// Files newer than date (YYYY-MM-DD)
    #[arg(long, help_heading = "Filtering")]
    pub newer_than: Option<String>,

    /// Files older than date (YYYY-MM-DD)
    #[arg(long, help_heading = "Filtering")]
    pub older_than: Option<String>,

    // =========================================================================
    // TRAVERSAL - How to scan
    // =========================================================================
    /// Traversal depth (0 = auto, 1 = shallow, 10 = deep)
    #[arg(short, long, default_value = "0", help_heading = "Traversal")]
    pub depth: usize,

    /// Ignore .gitignore files
    #[arg(long, help_heading = "Traversal")]
    pub no_ignore: bool,

    /// Ignore default patterns (node_modules, __pycache__, etc.)
    #[arg(long, help_heading = "Traversal")]
    pub no_default_ignore: bool,

    /// Show hidden files (starting with .)
    #[arg(long, short = 'a', help_heading = "Traversal")]
    pub all: bool,

    /// Show ignored directories in brackets
    #[arg(long, help_heading = "Traversal")]
    pub show_ignored: bool,

    /// Show EVERYTHING (--all + --no-ignore + --no-default-ignore)
    #[arg(long, help_heading = "Traversal")]
    pub everything: bool,

    // =========================================================================
    // SMART SCANNING - Intelligent context-aware output
    // =========================================================================
    /// Enable smart mode - surface what matters, not everything
    /// Groups output by interest: security, changes, important, background
    #[arg(long, help_heading = "Smart Scanning")]
    pub smart: bool,

    /// Only show changes since last scan
    #[arg(long, help_heading = "Smart Scanning")]
    pub changes_only: bool,

    /// Minimum interest level (0.0-1.0) to display
    #[arg(long, default_value = "0.0", help_heading = "Smart Scanning")]
    pub min_interest: f32,

    /// Disable security scanning during traversal
    #[arg(long, help_heading = "Smart Scanning")]
    pub no_security: bool,

    // =========================================================================
    // DISPLAY - How output looks
    // =========================================================================
    /// Show filesystem type indicators (X=XFS, 4=ext4, B=Btrfs)
    #[arg(long, help_heading = "Display")]
    pub show_filesystems: bool,

    /// Disable emojis (Trish will miss them!)
    #[arg(long, help_heading = "Display")]
    pub no_emoji: bool,

    /// Compress output with zlib (base64 encoded)
    #[arg(short = 'z', long, help_heading = "Display")]
    pub compress: bool,

    /// Optimize for MCP/API (compression + no colors/emoji)
    #[arg(long, help_heading = "Display")]
    pub mcp_optimize: bool,

    /// Compact JSON (single line)
    #[arg(long, help_heading = "Display")]
    pub compact: bool,

    /// Path display: off, relative, or full
    #[arg(
        long = "path-mode",
        value_enum,
        default_value = "off",
        help_heading = "Display"
    )]
    pub path_mode: PathMode,

    /// Color output: always, never, or auto
    #[arg(long, value_enum, default_value = "auto", help_heading = "Display")]
    pub color: ColorMode,

    /// Wrap AI output in JSON structure
    #[arg(long, help_heading = "Display")]
    pub ai_json: bool,

    // =========================================================================
    // STREAMING - Real-time output
    // =========================================================================
    /// Stream output as files are scanned
    #[arg(long, help_heading = "Streaming")]
    pub stream: bool,

    /// Start SSE server for real-time monitoring
    #[arg(long, help_heading = "Streaming")]
    pub sse_server: bool,

    /// SSE server port (also used as daemon port)
    #[arg(long, alias = "daemon-port", default_value = "28428", help_heading = "Streaming")]
    pub sse_port: u16,

    // =========================================================================
    // SEARCH & ANALYSIS
    // =========================================================================
    /// Search file contents (e.g., --search "TODO")
    #[arg(long, help_heading = "Search & Analysis")]
    pub search: Option<String>,

    /// Group by semantic similarity
    #[arg(long, help_heading = "Search & Analysis")]
    pub semantic: bool,

    /// Focus analysis on specific file (relations mode)
    #[arg(long, value_name = "FILE", help_heading = "Search & Analysis")]
    pub focus: Option<PathBuf>,

    /// Filter relationships: imports, calls, types, tests, coupled
    #[arg(long, value_name = "TYPE", help_heading = "Search & Analysis")]
    pub relations_filter: Option<String>,

    // =========================================================================
    // SORTING
    // =========================================================================
    /// Sort by: a-to-z, z-to-a, largest, smallest, newest, oldest, type
    #[arg(long, value_enum, help_heading = "Sorting")]
    pub sort: Option<SortField>,

    /// Show only top N results (use with --sort)
    #[arg(long, value_name = "N", help_heading = "Sorting")]
    pub top: Option<usize>,

    // =========================================================================
    // MERMAID & MARKDOWN OPTIONS
    // =========================================================================
    /// Mermaid style: flowchart, mindmap, gitgraph, treemap
    #[arg(
        long,
        value_enum,
        default_value = "flowchart",
        help_heading = "Mermaid & Markdown"
    )]
    pub mermaid_style: MermaidStyleArg,

    /// Exclude mermaid diagrams from markdown
    #[arg(long, help_heading = "Mermaid & Markdown")]
    pub no_markdown_mermaid: bool,

    /// Exclude tables from markdown
    #[arg(long, help_heading = "Mermaid & Markdown")]
    pub no_markdown_tables: bool,

    /// Exclude pie charts from markdown
    #[arg(long, help_heading = "Mermaid & Markdown")]
    pub no_markdown_pie_charts: bool,

    // =========================================================================
    // ADVANCED
    // =========================================================================
    /// Index code to SmartPastCode registry
    #[arg(long, value_name = "URL", help_heading = "Advanced")]
    pub index_registry: Option<String>,

    /// Show private functions in docs (function-markdown mode)
    #[arg(long, help_heading = "Advanced")]
    pub show_private: bool,

    /// View Smart Edit diffs from .st folder
    #[arg(long, help_heading = "Advanced")]
    pub view_diffs: bool,

    /// Clean up old diffs, keep last N per file
    #[arg(long, value_name = "N", help_heading = "Advanced")]
    pub cleanup_diffs: Option<usize>,
}

#[derive(Debug, Subcommand)]
pub enum Cmd {
    /// Manage the smart-tree daemon (Linux: systemd, macOS: launchctl, Windows: Task Scheduler)
    #[command(subcommand)]
    Service(Service),

    /// Manage project tags
    #[command(subcommand, name = "project-tags")]
    ProjectTags(ProjectTags),
}

#[derive(Debug, Subcommand)]
pub enum Service {
    /// Install the smart-tree daemon as a system service
    Install,
    /// Uninstall the service
    Uninstall,
    /// Start the service for the current project
    Start,
    /// Stop the service
    Stop,
    /// Show service status
    Status,
    /// Show service logs
    Logs,
}

#[derive(Debug, Subcommand)]
pub enum ProjectTags {
    /// Add a tag to the project
    Add {
        /// The tag to add
        #[arg(required = true)]
        tag: String,
    },
    /// Remove a tag from the project
    Remove {
        /// The tag to remove
        #[arg(required = true)]
        tag: String,
    },
}

/// Sort field options with intuitive names
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum SortField {
    /// Sort alphabetically A to Z
    #[value(name = "a-to-z")]
    AToZ,
    /// Sort alphabetically Z to A
    #[value(name = "z-to-a")]
    ZToA,
    /// Sort by size, largest files first
    #[value(name = "largest")]
    Largest,
    /// Sort by size, smallest files first
    #[value(name = "smallest")]
    Smallest,
    /// Sort by modification date, newest first
    #[value(name = "newest")]
    Newest,
    /// Sort by modification date, oldest first
    #[value(name = "oldest")]
    Oldest,
    /// Sort by file type/extension
    #[value(name = "type")]
    Type,
    /// Legacy aliases for backward compatibility
    #[value(name = "name", alias = "alpha")]
    Name,
    #[value(name = "size")]
    Size,
    #[value(name = "date", alias = "modified")]
    Date,
}

/// Enum for mermaid style argument
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum MermaidStyleArg {
    /// Traditional flowchart (default)
    Flowchart,
    /// Mind map style
    Mindmap,
    /// Git graph style
    Gitgraph,
    /// Treemap style (shows file sizes visually)
    Treemap,
}

/// Color mode for output
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum ColorMode {
    /// Always use colors
    Always,
    /// Never use colors
    Never,
    /// Auto-detect (colors if terminal)
    Auto,
}

/// Path display mode
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum PathMode {
    /// Show only filenames (default)
    Off,
    /// Show paths relative to scan root
    Relative,
    /// Show full absolute paths
    Full,
}

/// Output format mode
#[derive(Debug, Clone, Copy, ValueEnum, PartialEq)]
pub enum OutputMode {
    /// Auto mode - smart default selection based on context
    Auto,
    /// Classic tree format with metadata and emojis
    Classic,
    /// Hexadecimal format with fixed-width fields
    Hex,
    /// HexTree - readable quantum compression with tree structure
    HexTree,
    /// JSON output for programmatic use
    Json,
    /// Unix ls -Alh format
    Ls,
    /// AI-optimized format for LLMs
    Ai,
    /// Directory statistics only
    Stats,
    /// CSV format
    Csv,
    /// TSV format
    Tsv,
    /// Super compact digest format
    Digest,
    /// Emotional tree - files with feelings!
    Emotional,
    /// MEM|8 Quantum format - ultimate compression
    Quantum,
    /// Semantic grouping format
    Semantic,
    /// Projects discovery mode
    Projects,
    /// Mermaid diagram format
    Mermaid,
    /// Markdown report format
    Markdown,
    /// Interactive summary mode
    Summary,
    /// AI-optimized summary mode
    SummaryAi,
    /// Context mode for AI conversations
    Context,
    /// Code relationship analysis
    Relations,
    /// Quantum compression with semantic understanding
    QuantumSemantic,
    /// Waste detection and optimization analysis
    Waste,
    /// Marqant - Quantum-compressed markdown format
    Marqant,
    /// SSE - Server-Sent Events streaming format
    Sse,
    /// Function documentation in markdown format
    FunctionMarkdown,
}

/// Get the ideal depth for each output mode
pub fn get_ideal_depth_for_mode(mode: &OutputMode) -> usize {
    match mode {
        OutputMode::Auto => 3,
        OutputMode::Ls => 1,
        OutputMode::Classic => 3,
        OutputMode::Ai | OutputMode::Hex => 5,
        OutputMode::Stats => 10,
        OutputMode::Digest => 10,
        OutputMode::Emotional => 5,
        OutputMode::Quantum | OutputMode::QuantumSemantic | OutputMode::HexTree => 5,
        OutputMode::Summary | OutputMode::SummaryAi | OutputMode::Context => 4,
        OutputMode::Waste => 10,
        OutputMode::Relations => 10,
        OutputMode::Projects => 5,
        _ => 4,
    }
}

/// Parse a date string (YYYY-MM-DD) into SystemTime
pub fn parse_date(date_str: &str) -> Result<SystemTime> {
    let date = NaiveDate::parse_from_str(date_str, "%Y-%m-%d")?;
    let datetime = date.and_hms_opt(0, 0, 0).context("Invalid time")?;
    Ok(SystemTime::from(
        datetime
            .and_local_timezone(chrono::Local)
            .single()
            .context("Invalid timezone")?,
    ))
}

#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum LogLevel {
    Error,
    Warn,
    Info,
    Debug,
    Trace,
}