loctree 0.8.16

Structural code intelligence for AI agents. Scan once, query everything.
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
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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
//! Static help text constants for CLI commands.
//!
//! Each constant provides detailed usage documentation for a specific command.
//!
//! VibeCrafted with AI Agents (c)2026 Loctree Team

pub(super) const AUTO_HELP: &str =
    "loct auto - Full auto-scan with stack detection (default command)

USAGE:
    loct auto [OPTIONS] [PATHS...]
    loct [OPTIONS] [PATHS...]    # 'auto' is the default command

DESCRIPTION:
    Performs a comprehensive analysis of your codebase:
    - Detects project type and language stack automatically
    - Builds dependency graph and import relationships
    - Analyzes code structure and exports
    - Identifies potential issues (dead code, cycles, etc.)

OPTIONS:
    --full-scan          Force full rescan (ignore cache)
    --scan-all           Scan all files including hidden/ignored
    --for-agent-feed     Output optimized format for AI agents (JSONL stream)
    --agent-json         Emit a single agent bundle JSON (full issue lists + ranked anchors)
    --no-duplicates      Hide duplicate export sections in CLI output
    --no-dynamic-imports Hide dynamic import sections in CLI output
    --help, -h           Show this help message

ARGUMENTS:
    [PATHS...]           Root directories to scan (default: current directory)

EXAMPLES:
    loct                         # Auto-scan current directory
    loct auto                    # Explicit auto command
    loct auto --full-scan        # Force full rescan
    loct auto src/ lib/          # Scan specific directories
    loct --for-agent-feed        # AI-optimized output (JSONL stream)
    loct --agent-json            # One-shot agent bundle JSON";

pub(super) const AGENT_HELP: &str =
    "loct agent - Agent bundle JSON (shortcut for auto --agent-json)

USAGE:
    loct agent [PATHS...]

DESCRIPTION:
    Runs the auto scan and emits a single JSON tuned for AI agents:
    full handlers, duplicates, dead exports, dynamic imports, cycles, and lint findings,
    plus prioritized quick wins and top files for context anchoring.
    The bundle is also saved to the artifacts dir (cache by default; set LOCT_CACHE_DIR to override).

OPTIONS:
    --full-scan          Force full rescan (ignore cache)
    --scan-all           Scan all files including hidden/ignored
    --help, -h           Show this help message

ARGUMENTS:
    [PATHS...]           Root directories to scan (default: current directory)

EXAMPLES:
    loct agent                   # Agent bundle for current directory
    loct agent src/              # Agent bundle for src/";

pub(super) const SCAN_HELP: &str = "loct scan - Build/update snapshot for current HEAD

USAGE:
    loct scan [OPTIONS] [PATHS...]

DESCRIPTION:
    Scans the codebase and updates the internal snapshot database.
    Builds the dependency graph and prepares data for other commands.
    Unlike 'auto', it only builds the snapshot without extra analysis.

OPTIONS:
    --full-scan       Force full rescan, ignore cached data
    --scan-all        Include hidden and ignored files
    --watch           Watch for changes and re-scan automatically
    --help, -h        Show this help message

ARGUMENTS:
    [PATHS...]        Root directories to scan (default: current directory)

EXAMPLES:
    loct scan                    # Scan current directory
    loct scan --full-scan        # Force complete rescan
    loct scan src/ lib/          # Scan specific directories
    loct scan --scan-all         # Include all files (even hidden)
    loct scan --watch            # Watch mode with live refresh";

pub(super) const TREE_HELP: &str = "loct tree - Display LOC tree / structural overview

USAGE:
    loct tree [OPTIONS] [PATHS...]

DESCRIPTION:
    Hierarchical tree of the codebase with LOC metrics.
    Similar to 'tree' but with LOC and gitignore handling.

OPTIONS:
    --depth <N>, -L <N>    Maximum depth (default: unlimited)
    --summary [N]          Show top N largest items (default: 5)
    --top [N]              Only show top N largest items (default: 50)
    --loc <N>              Only show items with LOC >= N
    --min-loc <N>          Alias for --loc
    --show-hidden, -H      Include hidden files/directories
    --find-artifacts       Highlight build/generated artifacts
    --show-ignored         Show gitignored files
    --help, -h             Show this help message

ARGUMENTS:
    [PATHS...]             Roots to analyze (default: current directory)

EXAMPLES:
    loct tree                       # Full tree
    loct tree --depth 3             # Limit depth
    loct tree --summary 10          # Top 10 largest
    loct tree --loc 100             # LOC threshold
    loct tree src/ --show-hidden    # Include dotfiles";

pub(super) const SLICE_HELP: &str = "loct slice - Extract file + dependencies for AI context

USAGE:
    loct slice <TARGET_PATH> [OPTIONS]

DESCRIPTION:
    Extracts a 'holographic slice' - the target file plus all its dependencies.
    Perfect for feeding focused context to AI assistants.

    Shows what the file USES, not what USES it.
    For reverse dependencies, use --consumers or 'loct query who-imports'.

OPTIONS:
    --consumers, -c    Include reverse dependencies (files that import this)
    --depth <N>        Maximum dependency depth to traverse
    --root <PATH>      Project root for resolving imports
    --rescan           Force snapshot update (includes new/uncommitted files)
    --help, -h         Show this help message

EXAMPLES:
    loct slice src/main.rs              # File + its dependencies
    loct slice src/utils.ts --consumers # Include reverse deps
    loct slice lib/api.ts --depth 2     # Limit to 2 levels
    loct slice src/app.tsx --json       # JSON output for AI tools
    loct slice src/new-file.ts --rescan # Slice a newly created file

RELATED COMMANDS:
    loct query who-imports <file>    Find all importers
    loct auto --for-agent-feed       Full codebase context
    loct focus <dir>                 Slice for a directory";

pub(super) const FIND_HELP: &str = "loct find - Semantic search for symbols and parameters

USAGE:
    loct find [QUERY...] [OPTIONS]

DESCRIPTION:
    Semantic search for symbols (functions, classes, types) AND function parameters.
    Uses regex patterns to match names in your codebase.

    Query modes:
    - Split-mode (multiple args): `loct find Foo Bar Baz`
        Runs separate searches per term and prints a cross-match summary of files
        that match 2+ queries.
    - AND-mode (single arg with spaces): `loct find \"Foo Bar Baz\"`
        Treats whitespace as AND and prints only the intersection (files matching
        all terms). This avoids the legacy \"auto-OR\" behavior.
    - Regex OR (explicit `|`): `loct find \"Foo|Bar|Baz\"`
        Preserves regex OR and enables built-in cross-match output.
    - Legacy OR: `loct find --or Foo Bar Baz`
        Forces old behavior (combines terms with `|`).

    Returns three types of matches:
    - Symbol Matches: exported functions, classes, types
    - Parameter Matches: function parameter names (NEW in 0.8.4)
    - Semantic Matches: similar symbol names (fuzzy matching)

    NOT impact analysis - for dependency impact, use 'loct impact'.
    NOT dead code detection - use 'loct dead' or 'loct twins'.

OPTIONS:
    --or                Force legacy OR for multi-arg queries (Foo|Bar|Baz)
    --symbol <PATTERN>   Search for symbols matching regex
    --file <PATTERN>     Search for files matching regex
    --similar <SYMBOL>   Find symbols with similar names (fuzzy)
    --dead               Only show dead/unused symbols
    --exported           Only show exported symbols
    --lang <LANG>        Filter by language (ts, rs, js, py, etc.)
    --limit <N>          Maximum results to show
    --help, -h           Show this help message

EXAMPLES:
    loct find request                   # Find 'request' in symbols AND params
    loct find Props Options ViewModel   # Split-mode + cross-match summary
    loct find \"Props Options\"          # AND-mode (intersection)
    loct find \"Props|Options|ViewModel\" # Regex OR (explicit)
    loct find --or Props Options        # Legacy OR (Props|Options)
    loct find --symbol \".*Config$\"      # Regex: symbols ending with Config
    loct find --file \"utils\"            # Files containing \"utils\" in path
    loct find --dead --exported         # Dead exported symbols

OUTPUT:
    === Symbol Matches (10) ===
      src/auth.py:45 - export def login
    === Parameter Matches (34) ===
      src/auth.py:45 - request: Request in login()
    === Semantic Matches (5) ===
      loginUser (score: 0.85) in src/users.py

RELATED COMMANDS:
    loct dead              Find unused exports / dead code
    loct twins             Find duplicate exports and dead parrots
    loct slice <file>      Extract file dependencies
    loct query where-symbol  Find where a symbol is defined";

pub(super) const DEAD_HELP: &str = "loct dead - Detect unused exports / dead code

USAGE:
    loct dead [OPTIONS] [PATHS...]

DESCRIPTION:
    Detects unused exports with confidence levels and optional
    inclusion of tests/helpers. Integrates with quick wins.

OPTIONS:
    --confidence <lvl>   normal|high (default: normal)
    --top <N>            Limit results to top N (default: 20)
    --full, --all        Show all results (ignore --top limit)
    --with-tests         Include test files
    --with-helpers       Include helper files
    --with-shadows       Detect shadow exports (same symbol, multiple files)
    --help, -h           Show this help message

EXAMPLES:
    loct dead
    loct dead --confidence high
    loct dead --with-tests
    loct dead --with-shadows";

pub(super) const CYCLES_HELP: &str = "loct cycles - Detect circular import chains

USAGE:
    loct cycles [OPTIONS] [PATHS...]

DESCRIPTION:
    Detects circular dependencies in your import graph.
    Example: A -> B -> C -> A

    Circular imports cause:
    - Runtime initialization errors
    - Build/bundling failures
    - Flaky test behavior

OPTIONS:
    --path <PATTERN>     Filter to files matching pattern
    --help, -h           Show this help message

EXAMPLES:
    loct cycles                # Detect all cycles
    loct cycles src/           # Only analyze src/
    loct cycles --json         # JSON output for CI

RELATED COMMANDS:
    loct slice <file>       See what a file depends on
    loct query who-imports  Find reverse dependencies
    loct lint --fail        Run as CI check";

pub(super) const TRACE_HELP: &str = "loct trace - Trace a Tauri/IPC handler end-to-end

USAGE:
    loct trace <handler> [ROOTS...]

DESCRIPTION:
    Investigates why a handler is missing/unused:
    - Backend definition (file, line, exposed name)
    - Frontend invoke() calls and plain mentions
    - Registration status in generate_handler![]
    - Verdict + suggestion to fix

OPTIONS:
    --help, -h           Show this help message

ARGUMENTS:
    <handler>            Handler name to trace (exposed or internal)
    [ROOTS...]           Root directories to scan (default: current directory)

EXAMPLES:
    loct trace toggle_assistant
    loct trace standard_command apps/desktop";

pub(super) const JQ_HELP: &str = "loct jq - Query snapshot with jq-style filters

USAGE:
    loct '<filter>' [OPTIONS]

DESCRIPTION:
    Execute jq-style filter expressions on the latest snapshot JSON.
    Automatically finds the most recent snapshot in the cache (override with LOCT_CACHE_DIR).

    The filter syntax follows jq conventions:
    - .metadata          Extract metadata field
    - .files[]           Iterate over files array
    - .files[0]          Get first file
    - .[\"key\"]         Access key with special characters

OPTIONS:
    -r, --raw-output         Output raw strings, not JSON
    -c, --compact-output     Compact JSON output (no pretty-printing)
    -e, --exit-status        Set exit code based on output (0 if truthy)
    --arg <name> <value>     Pass string variable to filter
    --argjson <name> <json>  Pass JSON variable to filter
    --snapshot <path>        Use specific snapshot file instead of latest
    --help, -h               Show this help message

EXAMPLES:
    loct '.metadata'                         # Extract metadata
    loct '.files | length'                   # Count files
    loct '.files[] | .path'                  # List file paths
    loct '.metadata.total_loc' -r            # Raw number output
    loct '.files[] | select(.lang == \"ts\")' -c
    loct '.files[] | select(.loc > 500)' -c

NOTE:
    This command requires jaq dependencies (enabled by default in the CLI build).";

pub(super) const COMMANDS_HELP: &str = "loct commands - Tauri FE<->BE handler coverage analysis

USAGE:
    loct commands [OPTIONS] [PATHS...]

DESCRIPTION:
    Analyzes Tauri command bridge contracts between frontend and backend.

    Detects:
    - Missing handlers: FE calls invoke('cmd') but no BE #[tauri::command]
    - Unused handlers: BE has #[tauri::command] but FE never calls it
    - Matched handlers: Both FE and BE exist (healthy)

OPTIONS:
    --name <PATTERN>     Filter to commands matching pattern
    --missing-only       Show only missing handlers
    --unused-only        Show only unused handlers
    --limit <N>          Maximum results to show
    --help, -h           Show this help message

EXAMPLES:
    loct commands                    # Full coverage report
    loct commands --missing-only     # Only missing handlers
    loct commands --json --missing   # JSON for CI

RELATED COMMANDS:
    loct events        Analyze Tauri event flow
    loct lint --tauri  Full Tauri contract validation";

pub(super) const EVENTS_HELP: &str = "loct events - Show event flow and issues

USAGE:
    loct events [OPTIONS] [PATHS...]

DESCRIPTION:
    Analyzes event emit/listen pairs, ghost events, and race conditions.

OPTIONS:
    --races             Enable race detection (async/await gaps)
    --no-duplicates     Hide duplicate sections in CLI output
    --no-dynamic-imports Hide dynamic import sections in CLI output
    --help, -h          Show this help message

EXAMPLES:
    loct events
    loct events --races";

pub(super) const ROUTES_HELP: &str = "loct routes - List backend/web routes (FastAPI/Flask)

USAGE:
    loct routes [OPTIONS] [PATHS...]

DESCRIPTION:
    Detects Python web routes based on common decorators:
    - FastAPI: @app.get/post/put/delete/patch, @router.*, @api_router.*
    - Flask:   @app.route, @blueprint.route, .route(...)

OPTIONS:
    --framework <NAME>   Filter by framework label (fastapi, flask)
    --path <PATTERN>     Filter by route path substring
    --help, -h           Show this help message

EXAMPLES:
    loct routes
    loct routes --framework fastapi
    loct routes --path /patients";

pub(super) const INFO_HELP: &str = "loct info - Show snapshot metadata and project info

USAGE:
    loct info

DESCRIPTION:
    Prints snapshot metadata, detected stack, and analysis summary.

OPTIONS:
    --help, -h          Show this help message";

pub(super) const LINT_HELP: &str = "loct lint - Structural lint and policy checks

USAGE:
    loct lint [OPTIONS] [PATHS...]

DESCRIPTION:
    Runs structural linting: entrypoints, handlers, ghost events, races.

OPTIONS:
    --entrypoints        List entrypoints
    --sarif              Emit SARIF
    --tauri              Apply Tauri presets
    --fail               Exit non-zero on findings
    --deep               Include ts/react/memory lint checks
    --ts                 Include TypeScript lint checks
    --react              Include React lint checks
    --memory             Include memory leak lint checks
    --no-duplicates      Hide duplicate sections in CLI output
    --no-dynamic-imports Hide dynamic import sections in CLI output
    --help, -h           Show this help message

EXAMPLES:
    loct lint
    loct lint --deep
    loct lint --fail --sarif";

pub(super) const PIPELINES_HELP: &str = "loct pipelines - Pipeline summary (events/commands/risks)

USAGE:
    loct pipelines [PATHS...]

DESCRIPTION:
    Prints a concise pipeline summary (events, commands, risk buckets)
    using the current snapshot.

OPTIONS:
    --help, -h        Show this help message

EXAMPLES:
    loct pipelines
    loct pipelines .";

pub(super) const INSIGHTS_HELP: &str = "loct insights - AI insights summary

USAGE:
    loct insights [PATHS...]

DESCRIPTION:
    Emits the AI insight hints (huge files, cross-language stems, missing handlers).

OPTIONS:
    --help, -h        Show this help message

EXAMPLES:
    loct insights
    loct insights .";

pub(super) const MANIFESTS_HELP: &str = "loct manifests - Manifest summaries

USAGE:
    loct manifests [PATHS...]

DESCRIPTION:
    Prints manifest summaries from snapshot metadata (package.json, Cargo.toml, pyproject).

OPTIONS:
    --help, -h        Show this help message

EXAMPLES:
    loct manifests
    loct manifests .";

pub(super) const REPORT_HELP: &str = "loct report - Generate HTML report + cached artifacts

USAGE:
    loct report [OPTIONS] [PATHS...]

DESCRIPTION:
    Runs full analysis and writes the full HTML report plus cached artifacts
    such as findings.json, agent.json, analysis.json, and report.sarif.

OPTIONS:
    --output <FILE>      Output HTML path
    --serve              Serve report locally
    --port <N>           Port for --serve
    --editor <NAME>      Editor integration (code/cursor/windsurf/jetbrains)
    --help, -h           Show this help message

EXAMPLES:
    loct report
    loct report --output report.html
    loct report --serve --port 4173";

pub(super) const FINDINGS_HELP: &str = "loct findings - Emit findings JSON to stdout

USAGE:
    loct findings [OPTIONS] [PATHS...]

DESCRIPTION:
    Runs the full findings pipeline and prints the same issue payload that
    powers findings.json, but directly to stdout for piping and automation.

    Use --summary for the compact health/counts payload when you only need
    top-line status in CI or scripts.

OPTIONS:
    --summary         Emit only the compact summary payload
    --json            Output as JSON (default for this command)
    --help, -h        Show this help message

ARGUMENTS:
    [PATHS...]        Root directories to scan (default: current directory)

EXAMPLES:
    loct findings
    loct findings --summary
    loct findings src/ > findings.json
    loct findings --summary | jq '.health_score'";

pub(super) const QUERY_HELP: &str = "loct query - Graph queries (who-imports, who-exports, etc.)

USAGE:
    loct query <KIND> <TARGET>

DESCRIPTION:
    Query the import graph and symbol index for specific relationships.
    Targeted queries against the dependency graph built by 'loct scan'.

QUERY KINDS:
    who-imports <FILE>      Find all files that import the file (reverse deps)
    where-symbol <SYMBOL>   Find where a symbol is defined/exported
    component-of <FILE>     Show which component/module contains the file

OPTIONS:
    --help, -h              Show this help message

EXAMPLES:
    loct query who-imports src/utils.ts       # What imports utils.ts?
    loct query where-symbol PatientRecord     # Where is it defined?
    loct query component-of src/ui/Button.tsx # What owns Button?

RELATED COMMANDS:
    loct slice <file>           Show what a file depends on
    loct find --symbol <name>   Search for symbols by pattern
    loct dead                   Find symbols with 0 imports";

pub(super) const IMPACT_HELP: &str = "loct impact - Analyze impact of modifying/removing a file

USAGE:
    loct impact <FILE> [OPTIONS]

DESCRIPTION:
    Shows \"what breaks if you modify or remove this file\" by traversing
    the reverse dependency graph. Finds all direct and transitive consumers.

    This is different from 'query who-imports':
    - who-imports: Finds direct importers only
    - impact: Finds ALL affected files (direct + transitive)

    Useful for:
    - Understanding change impact before refactoring
    - Identifying critical files (high fan-out)
    - Safe deletion analysis

OPTIONS:
    --depth <N>          Limit traversal depth (default: unlimited)
    --root <PATH>        Project root (default: current directory)
    --json               Output as JSON for agent consumption
    --help, -h           Show this help message

ARGUMENTS:
    <FILE>               Path to the file to analyze (required)

EXAMPLES:
    loct impact src/utils.ts                # Full impact analysis
    loct impact src/api.ts --depth 2        # Limit to 2 levels deep
    loct impact lib/helpers.ts --json       # JSON output
    loct impact src/core.ts --root ./       # Specify project root

OUTPUT FORMAT:
    Direct consumers (5 files):
      src/app.ts (import)
      src/lib.ts (import)
      ...

    Transitive impact (23 files total):
      [depth 2] src/page.tsx (import)
      ...

    Warning: Removing this file would break 28 files (max depth: 3)";

pub(super) const DIFF_HELP: &str = "loct diff - Compare snapshots between branches/commits

USAGE:
    loct diff --since <SNAPSHOT> [--to <SNAPSHOT>] [OPTIONS]

DESCRIPTION:
    Compares two code snapshots and shows semantic differences.

    Unlike git diff (line changes), this shows structural changes:
    - New/removed files and symbols
    - Import graph changes
    - New dead code introduced (regressions)
    - New circular dependencies

OPTIONS:
    --since <SNAPSHOT>   Base snapshot to compare from (required)
    --to <SNAPSHOT>      Target snapshot (default: current working tree)
    --auto-scan-base     Auto-create git worktree and scan target branch
    --problems-only      Show only regressions (new dead code, new cycles)
    --help, -h           Show this help message

EXAMPLES:
    loct diff --since main                    # Compare main to working tree
    loct diff --since HEAD~1                  # Compare to previous commit
    loct diff --since main --auto-scan-base   # Auto-scan main branch
    loct diff --since v1.0.0 --to v2.0.0      # Compare two tags

RELATED COMMANDS:
    loct scan             Run scan to create snapshot
    loct auto --full-scan Force full rescan";

pub(super) const MEMEX_HELP: &str = "loct memex - Index analysis into AI memory (vector DB)

USAGE:
    loct memex [OPTIONS]

DESCRIPTION:
    Pushes analysis artifacts to vector memory for agents.

OPTIONS:
    --help, -h          Show this help message";

pub(super) const CROWD_HELP: &str =
    "loct crowd - Detect functional crowds (similar files clustering)

USAGE:
    loct crowd [PATTERN]

DESCRIPTION:
    Groups related files around a seed pattern (name or path fragment).

OPTIONS:
    --help, -h          Show this help message

EXAMPLES:
    loct crowd cache
    loct crowd session";

pub(super) const TAGMAP_HELP: &str = "loct tagmap - Unified search around a keyword

USAGE:
    loct tagmap <KEYWORD> [OPTIONS]

DESCRIPTION:
    Aggregates three analyses into one view:
    1. FILES:  All files with keyword in path or name
    2. CROWD:  Functional clustering around the keyword
    3. DEAD:   Dead exports related to the keyword

    Perfect for understanding everything about a domain/feature at once.

OPTIONS:
    --include-tests    Include test files in analysis
    --limit <N>        Maximum results per section (default: 20)
    --json             Output as JSON for AI tools
    --help, -h         Show this help message

ARGUMENTS:
    <KEYWORD>          Keyword to search for (required)

EXAMPLES:
    loct tagmap patient           # Everything about 'patient' feature
    loct tagmap auth              # Auth-related files, crowds, dead code
    loct tagmap message --json    # JSON output for AI processing
    loct tagmap api --limit 10    # Limit results

OUTPUT FORMAT:
    === TAGMAP: 'patient' ===

    FILES MATCHING KEYWORD (12):
      src/features/patients/PatientsList.tsx
      src/hooks/usePatient.ts
      ...

    CROWD ANALYSIS (8 files):
      Score: 7.2/10
      Members: PatientsList, PatientDetail, PatientForm...
      Issues: Consider consolidating similar files

    DEAD EXPORTS (3):
      oldPatientHandler in src/api/patients.ts
      PatientV1 in src/types/patient.ts
      ...

RELATED COMMANDS:
    loct crowd <pattern>    Detailed crowd analysis
    loct dead               All dead exports
    loct find <query>       Symbol/file search
    loct focus <dir>        Directory-level context";

pub(super) const TWINS_HELP: &str =
    "loct twins - Find dead parrots (0 imports) and duplicate exports

USAGE:
    loct twins [OPTIONS] [PATH]

DESCRIPTION:
    Detects semantic issues in your export/import graph:

    Dead Parrots:   Exports with 0 imports anywhere in the codebase
                    (Monty Python reference - code that looks alive but isn't used)

    Exact Twins:    Same symbol name exported from multiple files
                    (can cause import confusion)

    Barrel Chaos:   Re-export anti-patterns
                    (missing index.ts, deep re-export chains)

    This is a code smell detector - findings are hints, not verdicts.

OPTIONS:
    --path <DIR>           Root directory to analyze
    --dead-only            Show only dead parrots (0 imports)
    --include-tests        Include test files (excluded by default)
    --include-suppressed   Show suppressed findings too
    --help, -h             Show this help message

EXAMPLES:
    loct twins                    # Full analysis
    loct twins --dead-only        # Only exports with 0 imports
    loct twins src/               # Analyze specific directory
    loct twins --include-tests    # Include test files
    loct twins --include-suppressed  # Include suppressed items

SUPPRESSION:
    Mark findings as false positives (they won't show in subsequent runs):
    loct suppress twins <symbol>              # Suppress a twin
    loct suppress twins <symbol> --file <f>   # Suppress only in specific file
    loct suppress --list                      # Show all suppressions
    loct suppress --clear                     # Clear all suppressions

RELATED COMMANDS:
    loct dead              Detailed dead code analysis
    loct sniff             Aggregate code smell analysis
    loct suppress          Manage false positive suppressions
    loct find --dead       Search for specific dead symbols";

pub(super) const DIST_HELP: &str = "loct dist - Verify tree-shaking from production source maps

USAGE:
    loct dist --src <DIR> --source-map <PATH> [--source-map <PATH> ...] [--report <PATH>]

DESCRIPTION:
    Simple mental model:
    - Point loct at the source directory you own
    - Point it at one or more production source maps or a dist/ directory
    - loct builds a chunk matrix and ranks suspicious runtime classes

    Candidate classes:
    - dead_in_all_chunks
    - boot_path_only
    - feature_local
    - fake_lazy
    - verify_first

    loct uses symbol or line evidence when a source map exposes it.
    If a map does not, it falls back to file-level chunk coverage for that map.
    The standard artifact set under `.loctree/` is refreshed as part of the run,
    so bundle intelligence also lands in report.html, findings.json, agent.json,
    and manifest.json.

OPTIONS:
    --src <DIR>              Source directory to scan once (e.g., src/)
    --source-map <PATH>      Production source map or directory to compare against
                             Repeat for multi-entry or multi-bundle builds
    --report <PATH>          Write the raw dist JSON result to a file
    --help, -h               Show this help message

EXAMPLES:
    loct dist --src src/ --source-map dist/main.js.map
    loct dist --src src/ --source-map dist/
    loct dist --src src/ --source-map dist/app.js.map --source-map dist/admin.js.map
    loct dist --src src/ --source-map dist/main.js.map --report .loctree/dist-report.json

OUTPUT:
    Default stdout: human summary
    Add --json: machine-readable stdout
    Add --report: save the JSON result to disk

JSON adds chunk summaries, candidate counts, and ranked candidates while keeping
the existing dead export fields stable.";

pub(super) const COVERAGE_HELP: &str =
    "loct coverage - Analyze test coverage gaps (structural coverage)

USAGE:
    loct coverage [OPTIONS] [PATHS...]

DESCRIPTION:
    Performs structural test coverage analysis by cross-referencing:
    - Frontend invoke/emit calls (what the app uses)
    - Backend handlers and events (what the app exposes)
    - Test file imports (what tests actually cover)

    Unlike line coverage tools, this shows:
    - Which handlers have no corresponding tests
    - Which events are emitted but never tested
    - Which exports are tested but never used in production

    This is semantic coverage - not 'how many lines' but 'what functionality'.

OPTIONS:
    --handlers            Only show handler gaps (skip events/exports)
    --events              Only show event gaps (skip handlers/exports)
    --tests               Show structural test coverage report
    --gaps                Show coverage gap analysis (default)
    --min-severity <LVL>  Filter by minimum severity: critical, high, medium, low
    --json                Output as JSON for programmatic use
    --help, -h            Show this help message

ARGUMENTS:
    [PATHS...]            Root directories to scan (default: current directory)

EXAMPLES:
    loct coverage                          # Show all coverage gaps
    loct coverage --handlers              # Focus on untested handlers
    loct coverage --tests                 # Structural test coverage
    loct coverage --min-severity high      # Only critical/high issues
    loct coverage --json                   # Machine-readable output

OUTPUT:
    Groups findings by severity:
    - CRITICAL: Handlers without any test (used in production!)
    - HIGH: Events emitted but never tested
    - MEDIUM: Exports without test imports
    - LOW: Tests that import unused code

    Each gap shows the source location and usage context.";

pub(super) const SNIFF_HELP: &str = "loct sniff - Sniff for code smells (aggregate analysis)

USAGE:
    loct sniff [OPTIONS]

DESCRIPTION:
    Aggregates all smell-level findings worth checking:

    Twins:        Same symbol name in multiple files
                  - Can cause import confusion

    Dead Parrots: Exports with 0 imports
                  - Potentially unused code

    Crowds:       Files with similar dependency patterns
                  - Possible duplication or fragmentation

    Output is friendly and non-judgmental. These are hints, not verdicts.

OPTIONS:
    --path <DIR>           Root directory to analyze (default: current directory)
    --dead-only            Show only dead parrots (skip twins and crowds)
    --twins-only           Show only twins (skip dead parrots and crowds)
    --crowds-only          Show only crowds (skip twins and dead parrots)
    --include-tests        Include test files in analysis (default: false)
    --min-crowd-size <N>   Minimum crowd size to report (default: 2)
    --json                 Output as JSON for programmatic use
    --help, -h             Show this help message

EXAMPLES:
    loct sniff                    # Full code smell analysis
    loct sniff --dead-only        # Only dead parrots
    loct sniff --twins-only       # Only duplicate names
    loct sniff --crowds-only      # Only similar file clusters
    loct sniff --include-tests    # Include test files
    loct sniff --json             # Machine-readable output

OUTPUT:
    Aggregates three types of code smells:
    - TWINS: Same symbol exported from multiple files
    - DEAD PARROTS: Exports with 0 imports
    - CROWDS: Files clustering around similar functionality

    Each section provides actionable suggestions for consolidation or cleanup.";

pub(super) const SUPPRESS_HELP: &str = "loct suppress - Mark findings as false positives

USAGE:
    loct suppress <type> <symbol> [OPTIONS]
    loct suppress --list
    loct suppress --clear

DESCRIPTION:
    Manages false positive suppressions so reviewed findings don't appear
    in subsequent runs. Suppressions are stored in .loctree/suppressions.toml.

    Use this when you've reviewed a finding and determined it's intentional:
    - FE/BE type mirrors (same type defined in TypeScript and Rust)
    - Intentional re-exports for public APIs
    - Entry points that appear 'dead' but are used externally

TYPES:
    twins          Exact twin (same symbol in multiple files)
    dead_parrot    Dead parrot (export with 0 imports)
    dead_export    Dead export (unused export)
    circular       Circular import

OPTIONS:
    --file <PATH>      Only suppress in specific file (default: all files)
    --reason <TEXT>    Document why this is a false positive
    --list             Show all current suppressions
    --clear            Remove all suppressions
    --help, -h         Show this help message

EXAMPLES:
    loct suppress twins Message              # Suppress 'Message' twin everywhere
    loct suppress twins Message --file src/types.ts  # Only in specific file
    loct suppress dead_parrot unusedHelper --reason 'Used via dynamic import'
    loct suppress --list                     # View all suppressions
    loct suppress --clear                    # Reset suppressions

STORAGE:
    Suppressions are stored in .loctree/suppressions.toml
    Commit this file to share suppressions with your team.

RELATED COMMANDS:
    loct twins         Find twins and dead parrots (--include-suppressed to show all)
    loct dead          Find unused exports
    loct sniff         Aggregate smell analysis";

pub(super) const FOCUS_HELP: &str = "loct focus - Extract holographic context for a directory

USAGE:
    loct focus <DIRECTORY> [OPTIONS]

DESCRIPTION:
    Like 'slice' but for directories. Extracts a holographic view of a directory:

    Core:       All files within the target directory
    Internal:   Import edges between files inside the directory
    Deps:       External files imported by core (outside the directory)
    Consumers:  Files outside the directory that import core files

    Perfect for understanding feature modules like 'src/features/patients/'.

OPTIONS:
    --consumers, -c    Include files that import from this directory
    --depth <N>        Maximum depth for external dependency traversal
    --root <PATH>      Project root (default: current directory)
    --json             Output as JSON for agent consumption
    --help, -h         Show this help message

ARGUMENTS:
    <DIRECTORY>        Path to the directory to analyze (required)

EXAMPLES:
    loct focus src/features/patients/           # Focus on patients feature
    loct focus src/components/ --consumers      # Include external consumers
    loct focus lib/utils/ --depth 1             # Limit external dep depth
    loct focus src/api/ --json                  # JSON output for AI tools

OUTPUT FORMAT:
    Focus: src/features/patients/

    Core (12 files, 2,340 LOC):
      src/features/patients/index.ts
      src/features/patients/PatientsList.tsx
      ...

    Internal edges: 18 imports within directory

    External Deps (8 files, 890 LOC):
      [d1] src/components/Button.tsx
      ...

    Consumers (3 files, 450 LOC):
      src/App.tsx
      ...

    Total: 23 files, 3,680 LOC

RELATED COMMANDS:
    loct slice <file>       Extract context for a single file
    loct impact <file>      Show what breaks if you change a file
    loct crowd <pattern>    Find files clustering around a pattern";

pub(super) const HOTSPOTS_HELP: &str =
    "loct hotspots - Import frequency heatmap (core vs peripheral)

USAGE:
    loct hotspots [OPTIONS]

DESCRIPTION:
    Ranks files by how often they are imported (in-degree) to identify:

    CORE:       Files imported by 10+ others (critical infrastructure)
    SHARED:     Files imported by 3-9 others (shared utilities)
    PERIPHERAL: Files imported by 1-2 others (feature-specific)
    LEAF:       Files with 0 importers (entry points or dead code)

    This helps AI agents understand which files are risky to modify
    (high in-degree = many dependents) vs safe to refactor (low in-degree).

OPTIONS:
    --min <N>              Minimum import count to show (default: 1)
    --limit <N>            Maximum files to show (default: 50)
    --leaves               Show only leaf nodes (0 importers)
    --coupling             Include out-degree (files that import many others)
    --root <PATH>          Project root (default: current directory)
    --json                 Output as JSON for agent consumption
    --help, -h             Show this help message

EXAMPLES:
    loct hotspots                    # Show top 50 most-imported files
    loct hotspots --limit 20         # Top 20 only
    loct hotspots --leaves           # Find leaf nodes (entry points / dead)
    loct hotspots --coupling         # Show both in-degree and out-degree
    loct hotspots --min 5            # Only files with 5+ importers
    loct hotspots --json             # JSON output for AI tools

OUTPUT FORMAT:
    Import Hotspots (42 files analyzed)

    CORE (10+ importers):
      [32] src/utils/helpers.ts           # hub module
      [18] src/components/Button.tsx

    SHARED (3-9 importers):
      [7]  src/hooks/useAuth.ts
      [5]  src/api/client.ts

    PERIPHERAL (1-2 importers):
      [2]  src/features/login/form.tsx
      [1]  src/features/login/types.ts

    LEAF (0 importers):
      src/pages/index.tsx               # entry point
      src/features/old/legacy.ts        # possibly dead

    With --coupling:
      [in:32 out:3]  src/utils/helpers.ts    # hub, low coupling
      [in:2  out:15] src/features/main.tsx   # feature root, high coupling

RELATED COMMANDS:
    loct dead               Find unused exports
    loct impact <file>      Show what breaks if you modify a file
    loct focus <dir>        Extract context for a directory";

pub(super) const LAYOUTMAP_HELP: &str = "loct layoutmap - Analyze CSS layout properties

USAGE:
    loct layoutmap [OPTIONS]

DESCRIPTION:
    Extracts and analyzes layout-related CSS properties from your codebase:

    Z-INDEX:    Shows all z-index values across CSS/SCSS files, sorted by value.
                Helps identify layering conflicts and understand UI stacking.

    POSITION:   Lists sticky/fixed positioned elements.
                Useful for understanding what elements persist during scroll.

    DISPLAY:    Identifies grid/flex layouts and their locations.
                Maps out the layout architecture of your components.

OPTIONS:
    --zindex-only          Show only z-index values
    --sticky-only          Show only sticky/fixed position elements
    --grid-only            Show only grid/flex layouts
    --min-zindex <N>       Filter z-index values >= N (default: show all)
    --exclude <PATTERN>    Exclude paths matching glob (can be repeated)
    --root <PATH>          Project root (default: current directory)
    --json                 Output as JSON for agent consumption
    --help, -h             Show this help message

EXAMPLES:
    loct layoutmap                  # Full CSS layout analysis
    loct layoutmap --zindex-only    # Only z-index hierarchy
    loct layoutmap --sticky-only    # Only sticky/fixed elements
    loct layoutmap --min-zindex 100 # High z-index values (likely overlays)
    loct layoutmap --exclude .obsidian --exclude prototype  # Skip dirs
    loct layoutmap --json           # JSON output for AI tools

OUTPUT FORMAT:
    Z-INDEX HIERARCHY:
      [9999] src/components/Modal.css:15       .modal-overlay
      [1000] src/components/Toast.css:8        .toast-container
      [ 100] src/components/Dropdown.css:23    .dropdown-menu
      [  10] src/components/Header.css:5       .header

    STICKY/FIXED ELEMENTS:
      [fixed]  src/components/Header.css:12    .header
      [sticky] src/components/Sidebar.css:5    .sidebar-nav

    GRID/FLEX LAYOUTS:
      [grid]   src/layouts/Dashboard.css:8     .dashboard-grid
      [flex]   src/components/Card.css:3       .card-content

RELATED COMMANDS:
    loct crowd              Find functionally similar components
    loct find <pattern>     Search for CSS selectors or properties";

pub(super) const ZOMBIE_HELP: &str = "loct zombie - Find all zombie code (combined analysis)

USAGE:
    loct zombie [OPTIONS] [PATHS...]

DESCRIPTION:
    Combines three sources of dead code into one actionable report:

    DEAD EXPORTS:     Unused exports detected by dead code analysis
                      (symbols with 0 imports)

    ORPHAN FILES:     Files with 0 importers (not imported by any other file)
                      Entry points are OK, but others might be dead

    SHADOW EXPORTS:   Same symbol exported by multiple files where some
                      have 0 imports (likely consolidation candidates)

    This is a comprehensive zombie hunter - finds all forms of potentially
    dead code in a single scan.

OPTIONS:
    --include-tests    Include test files in analysis (default: false)
    --json             Output as JSON for programmatic use
    --help, -h         Show this help message

ARGUMENTS:
    [PATHS...]         Root directories to scan (default: current directory)

EXAMPLES:
    loct zombie                    # Find all zombie code
    loct zombie --include-tests    # Include test files
    loct zombie src/               # Analyze specific directory
    loct zombie --json             # Machine-readable output

OUTPUT FORMAT:
    Zombie Code Report

    Dead Exports (3):
      src/utils/old.ts:15 - unusedFunction
      src/hooks/legacy.ts:8 - useLegacyHook
      ...

    Orphan Files (0 importers, 2):
      src/features/patients/PatientsList.tsx (504 LOC)
      src/components/deprecated/OldButton.tsx (89 LOC)

    Shadow Exports (1):
      conversationHostStore exported by 2 files, 1 dead

    Total: 6 zombie items, ~950 LOC to review

RELATED COMMANDS:
    loct dead               Detailed dead export analysis
    loct twins              Dead parrots and semantic duplicates
    loct hotspots --leaves  Find leaf nodes (0 importers)
    loct sniff              Code smell analysis";

pub(super) const HEALTH_HELP: &str = "loct health - Quick health check summary

USAGE:
    loct health [OPTIONS] [PATHS...]

DESCRIPTION:
    One-shot summary of all structural issues in your codebase:
    - Cycles: Circular import count (hard vs structural)
    - Dead: Unused exports (high confidence count)
    - Twins: Duplicate symbol names across files

    Use this as a quick sanity check before commits or in CI.
    Run individual commands for detailed analysis.

OPTIONS:
    --include-tests    Include test files in analysis (default: false)
    --json             Output as JSON for programmatic use
    --help, -h         Show this help message

ARGUMENTS:
    [PATHS...]         Root directories to scan (default: current directory)

EXAMPLES:
    loct health                    # Quick health summary
    loct health --include-tests    # Include test files
    loct health src/               # Analyze specific directory
    loct health --json             # Machine-readable output

OUTPUT FORMAT:
    Health Check Summary

    Cycles:      3 total (2 hard, 1 structural)
    Dead:        6 high confidence, 24 low
    Twins:       2 duplicate symbol groups

    Run `loct cycles`, `loct dead`, `loct twins` for details.

RELATED COMMANDS:
    loct cycles    Detailed circular import analysis
    loct dead      Detailed dead export analysis
    loct twins     Duplicate export analysis
    loct zombie    Combined dead/orphan/shadow analysis";

pub(super) const AUDIT_HELP: &str = "loct audit - Full codebase audit with actionable findings

USAGE:
    loct audit [OPTIONS] [PATHS...]

DESCRIPTION:
    Comprehensive analysis combining all structural checks into one report.
    Perfect for getting a complete picture of codebase health on day one.

    Includes:
    - Cycles: Circular imports (hard + structural)
    - Dead exports: Unused code with 0 imports
    - Twins: Same symbol exported from multiple files
    - Orphan files: Files with 0 importers (not entry points)
    - Shadow exports: Consolidation candidates
    - Crowds: Files with similar dependency patterns

    Each finding includes actionable suggestions for cleanup.

OPTIONS:
    --include-tests    Include test files in analysis (default: false)
    --todos            Save an actionable todo checklist instead of the full audit report
    --limit <N>        Intentionally truncate each section to N items (JSON marks omissions)
    --no-open          Save report without opening it automatically
    --json             Output as JSON for programmatic use
    --help, -h         Show this help message

ARGUMENTS:
    [PATHS...]         Root directories to scan (default: current directory)

EXAMPLES:
    loct audit                     # Full audit of current directory
    loct audit --include-tests     # Include test files
    loct audit src/                # Audit specific directory
    loct audit --todos             # Save a focused cleanup checklist
    loct audit --limit 25          # Intentionally trim each section
    loct audit --json              # Machine-readable output for CI

OUTPUT FORMAT:
    Markdown report saved to the loct cache artifacts directory.
    Terminal output shows a short summary plus the saved report path.
    JSON output is full by default; when --limit is set, each section includes
    explicit truncated/omitted metadata.

    Full Codebase Audit

    CYCLES (3 total)
      2 hard cycles (breaking)
      1 structural cycle

    DEAD EXPORTS (12 total)
      6 high confidence
      6 low confidence

    TWINS (2 groups)
      useAuth exported from 2 files
      formatDate exported from 3 files

    ORPHAN FILES (4 files, 1,200 LOC)
      src/legacy/old-utils.ts (450 LOC)
      src/deprecated/helper.ts (320 LOC)
      ...

    SHADOW EXPORTS (1)
      store exported by 2 files, 1 dead

    CROWDS (2 clusters)
      API handlers: 5 similar files
      Form components: 3 similar files

    ----------------------
    Total: 22 findings to review
    Run individual commands for details.

RELATED COMMANDS:
    loct health    Quick summary (cycles + dead + twins only)
    loct zombie    Dead exports + orphans + shadows
    loct sniff     Code smells (twins + dead + crowds)
    loct cycles    Detailed cycle analysis
    loct dead      Detailed dead export analysis";

pub(super) const DOCTOR_HELP: &str =
    "loct doctor - Interactive diagnostics with categorized findings

USAGE:
    loct doctor [OPTIONS] [PATHS...]

DESCRIPTION:
    Interactive troubleshooting command that analyzes your codebase and
    categorizes findings into actionable groups:

    1. Auto-fixable: Issues with clear automated solutions
    2. Needs Review: Potential issues requiring human judgment
    3. Suggested Suppressions: Patterns to add to .loctignore

    Unlike 'audit' which dumps everything, doctor guides you through
    the most impactful fixes first.

OPTIONS:
    --include-tests        Include test files in analysis (default: false)
    --apply-suppressions   Auto-add suggested patterns to .loctignore
    --help, -h             Show this help message

ARGUMENTS:
    [PATHS...]             Root directories to scan (default: current directory)

EXAMPLES:
    loct doctor                        # Interactive diagnostics
    loct doctor --apply-suppressions   # Auto-add .loctignore patterns
    loct doctor src/                   # Analyze specific directory
    loct doctor --include-tests        # Include test files

OUTPUT FORMAT:
    Codebase Diagnostics

    AUTO-FIXABLE (3 issues)
    ------------------------
    v Dead export: formatLegacy in src/utils.ts
      -> Remove or add @loctignore:dead-ok

    NEEDS REVIEW (2 issues)
    ------------------------
    ? Cycle: src/a.ts <-> src/b.ts (structural)
      -> Consider extracting shared types

    SUGGESTED SUPPRESSIONS
    ------------------------
    Add to .loctignore:
      @loctignore:dead-ok src/generated/**

    Run with --apply-suppressions to auto-add.

RELATED COMMANDS:
    loct health    Quick summary (cycles + dead + twins)
    loct audit     Full audit without categorization
    loct dead      Detailed dead export analysis
    loct cycles    Detailed cycle analysis";

pub(super) const PLAN_HELP: &str = "loct plan - Generate architectural refactoring plan

USAGE:
    loct plan [OPTIONS] [PATHS...]
    loct p [OPTIONS] [PATHS...]

DESCRIPTION:
    Analyzes module coupling and generates a safe refactoring plan.
    Detects architectural layers (UI, App, Kernel, Infra) and suggests
    file moves ordered by risk level (LOW first).

    The plan includes:
    - Layer detection via path heuristics
    - Risk scoring based on consumer count and file size
    - Cyclic dependency warnings
    - Re-export shim generation for backward compatibility

OPTIONS:
    --target-layout <SPEC>   Custom layer mapping (e.g., \"core=src/kernel,ui=src/views\")
    --markdown               Output as markdown (default)
    --json                   Output as JSON
    --script                 Output as executable shell script
    --all                    Generate all formats (.md, .json, .sh)
    --output, -o <PATH>      Output file path (without extension for --all)
    --no-open                Don't auto-open the generated report
    --include-tests          Include test files in analysis
    --min-coupling <N>       Minimum coupling score to include (0.0-1.0)
    --max-module-size <N>    Maximum module LOC before suggesting split
    --help, -h               Show this help message

ARGUMENTS:
    [PATHS...]               Directory/directories to analyze (default: current directory)

EXAMPLES:
    loct plan                          # Analyze current directory
    loct plan src/features             # Analyze specific directory
    loct plan src app                  # Analyze multiple targets
    loct plan --all -o refactor-2026   # Generate all formats
    loct plan --json                   # Output JSON to stdout
    loct plan --script > migrate.sh    # Generate executable script

OUTPUT FORMATS:

    Markdown (default):
    - Summary with file counts and risk breakdown
    - Layer distribution before/after
    - Phased execution plan (LOW -> MEDIUM -> HIGH risk)
    - Git commands for each phase
    - Shim generation instructions

    Shell Script (--script):
    - Executable bash script with phases
    - Dry-run support: ./migrate.sh --dry
    - Phase selection: ./migrate.sh 1

    JSON (--json):
    - Full RefactorPlan structure
    - Moves, shims, cyclic groups, stats

LAYER DETECTION:
    UI       components/, views/, pages/, ui/, widgets/
    App      hooks/, services/, stores/, state/, providers/
    Kernel   core/, domain/, models/, entities/, business/
    Infra    utils/, helpers/, lib/, adapters/, api/
    Test     tests/, __tests__/, .test., .spec.

RISK LEVELS:
    LOW      Few consumers (<5), small file (<200 LOC), not in cycle
    MEDIUM   Moderate consumers (5-10), medium file (200-500 LOC)
    HIGH     Many consumers (>10), large file (>500 LOC), or in cycle

RELATED COMMANDS:
    loct impact <file>   What breaks if you modify this file
    loct focus <dir>     Holographic context for a directory
    loct cycles          Detect circular imports
    loct audit           Full codebase audit";