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
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
use anyhow::Result;
use clap::{Parser, Subcommand};
use scud::commands;
use scud::SwarmMode;
use std::path::PathBuf;
#[derive(Subcommand)]
enum ConfigCommands {
/// Show current configuration
Show,
/// Set LLM provider
SetProvider {
/// Provider name (xai, anthropic, openai, openrouter)
provider: String,
/// Optional model name (defaults to provider's default)
#[arg(short, long)]
model: Option<String>,
},
/// Manage SCUD agents (Claude Code slash commands)
Agents {
#[command(subcommand)]
command: AgentsCommands,
},
/// Configure backpressure validation commands
Backpressure {
/// Commands to set (replaces existing). Use multiple args: "cargo build" "cargo test"
#[arg(trailing_var_arg = true)]
commands: Vec<String>,
/// Add a command to existing list
#[arg(long, conflicts_with = "commands")]
add: Option<String>,
/// Remove a command from list
#[arg(long, conflicts_with = "commands")]
remove: Option<String>,
/// List current backpressure config
#[arg(long, conflicts_with_all = ["commands", "add", "remove"])]
list: bool,
/// Clear all commands (use auto-detect)
#[arg(long, conflicts_with_all = ["commands", "add", "remove", "list"])]
clear: bool,
},
/// Manage spawn agent definitions (harness/model routing)
#[command(name = "spawn-agents")]
SpawnAgents {
#[command(subcommand)]
command: SpawnAgentsCommands,
},
}
#[derive(Subcommand)]
enum AgentsCommands {
/// List installed SCUD agents
List,
/// Add SCUD agent(s) to the project
Add {
/// Agent name (pm, sm, architect, dev, retrospective, status) or use --all
name: Option<String>,
/// Add all SCUD agents
#[arg(long)]
all: bool,
},
/// Remove SCUD agent(s) from the project
Remove {
/// Agent name (pm, sm, architect, dev, retrospective, status) or use --all
name: Option<String>,
/// Remove all SCUD agents
#[arg(long)]
all: bool,
},
/// Configure agent harness and model settings interactively
Configure {
/// Agent name (optional - prompts for selection if not provided)
name: Option<String>,
},
}
#[derive(Subcommand)]
enum SpawnAgentsCommands {
/// List available spawn agents
List,
/// Add spawn agent(s) to the project
Add {
/// Agent name (builder, reviewer, planner, researcher, analyzer, fast-builder, outside-generalist, repairer)
name: Option<String>,
/// Add all spawn agents
#[arg(long)]
all: bool,
/// Interactive selection
#[arg(short, long)]
interactive: bool,
},
/// Remove spawn agent(s) from the project
Remove {
/// Agent name
name: Option<String>,
/// Remove all spawn agents
#[arg(long)]
all: bool,
},
/// Update spawn agents to match current configuration
UpdateFromConfig,
}
#[derive(Subcommand)]
enum DoctorCommands {
/// Diagnose stuck task states (legacy functionality)
Workflow {
/// Phase tag (checks all phases if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Stale lock threshold in hours (default: 24)
#[arg(long, default_value = "24")]
stale_hours: f64,
/// Attempt auto-fix for recoverable issues
#[arg(long)]
fix: bool,
},
/// Validate extension installations
ScanExt,
}
#[derive(Parser)]
#[command(name = "scud")]
#[command(about = "Fast, simple task master for AI-driven development", long_about = None)]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Commands,
/// Project root directory
#[arg(short, long, global = true)]
project: Option<PathBuf>,
}
#[derive(Subcommand)]
enum Commands {
/// Build and install SCUD binary (replaces npm install)
Install,
/// Initialize SCUD in current directory
Init {
/// LLM provider to use (xai, anthropic, openai, openrouter)
#[arg(long)]
provider: Option<String>,
},
/// List phase tags or set active tag
Tags {
/// Tag to set as active (lists tags if not provided)
tag: Option<String>,
},
/// List tasks in active phase
List {
/// Filter by status
#[arg(short, long)]
status: Option<String>,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Output as JSON instead of human-readable format
#[arg(long)]
json: bool,
/// Output raw SCG format (default: human-readable)
#[arg(short = 'v', long)]
verbose: bool,
},
/// Open interactive task viewer in browser
View,
/// Show detailed task information
Show {
/// Task ID
task_id: String,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
},
/// Update task status
///
/// Single task: scud set-status <task_id> <status>
/// Multiple tasks: scud set-status <status> <task_id> [task_id...]
/// Bulk transition: scud set-status --from <status> --to <status>
SetStatus {
/// Status (for multi-task mode) or task ID (for single task mode)
first_arg: Option<String>,
/// Task IDs (for multi-task mode) or status (for single task mode)
rest: Vec<String>,
/// Source status for bulk transition
#[arg(long)]
from: Option<String>,
/// Target status for bulk transition
#[arg(long)]
to: Option<String>,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Apply to all tags
#[arg(long)]
all_tags: bool,
},
/// Find next available task
Next {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Output machine-readable JSON for orchestrators
#[arg(long)]
spawn: bool,
/// Search across all phases for globally-correct next task
#[arg(long)]
all_tags: bool,
},
/// Show phase statistics
Stats {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
},
/// Migrate task data to new format (namespaced IDs, parent-child relationships)
Migrate {
/// Show what would change without making changes
#[arg(long)]
dry_run: bool,
},
/// Plan parallel execution waves based on task dependencies
Waves {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Maximum parallel tasks per round (default: 5, min: 1)
#[arg(short = 'n', long, default_value = "5")]
max_parallel: usize,
/// Plan across all phases
#[arg(long)]
all_tags: bool,
},
/// Configuration management
Config {
#[command(subcommand)]
command: ConfigCommands,
},
/// Parse PRD/phase markdown into tasks (AI-powered)
#[command(alias = "parse-prd")]
Parse {
/// Path to PRD/phase markdown file
file: PathBuf,
/// Phase tag to create
#[arg(short, long)]
tag: String,
/// Number of tasks to generate (default: 10)
#[arg(short = 'n', long, default_value = "10")]
num_tasks: u32,
/// Append tasks to existing tag instead of replacing
#[arg(long)]
append: bool,
/// Skip loading guidance from .scud/guidance/
#[arg(long)]
no_guidance: bool,
/// Task ID format: sequential (default) or uuid
#[arg(long, default_value = "sequential")]
id_format: String,
/// Model to use for task generation (overrides config)
#[arg(long)]
model: Option<String>,
},
/// Generate tasks from PRD (parse → expand → check-deps pipeline)
Generate {
/// Path to PRD/spec document
file: PathBuf,
/// Tag name for generated tasks
#[arg(short, long)]
tag: String,
/// Number of tasks to generate (default: 10)
#[arg(short = 'n', long, default_value = "10")]
num_tasks: u32,
// === Phase Control ===
/// Skip task expansion phase
#[arg(long)]
no_expand: bool,
/// Skip dependency validation phase
#[arg(long)]
no_check_deps: bool,
// === Parse Options ===
/// Append tasks to existing tag instead of replacing
#[arg(long)]
append: bool,
/// Skip loading guidance from .scud/guidance/
#[arg(long)]
no_guidance: bool,
/// Task ID format: sequential (default) or uuid
#[arg(long, default_value = "sequential")]
id_format: String,
// === Model Selection ===
/// Model to use for all AI operations (overrides config)
#[arg(long)]
model: Option<String>,
// === Output Control ===
/// Show what would be done without making changes
#[arg(long)]
dry_run: bool,
/// Verbose output showing each phase's details
#[arg(short, long)]
verbose: bool,
/// Generate an Attractor pipeline instead of a task graph
#[arg(long)]
pipeline: bool,
/// Output file path (default: .scud/tasks/tasks.scg for pipeline)
#[arg(short, long)]
output: Option<PathBuf>,
},
/// Clear tasks (archives by default, use --delete to permanently remove)
Clean {
/// Skip confirmation prompt
#[arg(long)]
force: bool,
/// Only clean a specific tag
#[arg(short, long)]
tag: Option<String>,
/// Tags to keep (comma-separated or repeat flag)
#[arg(long, value_delimiter = ',')]
keep: Vec<String>,
/// Permanently delete instead of archiving
#[arg(long)]
delete: bool,
/// List archived phases
#[arg(long)]
list: bool,
/// Restore an archived phase
#[arg(long)]
restore: Option<String>,
},
/// Analyze task complexity (AI-powered)
AnalyzeComplexity {
/// Specific task ID (analyzes all if not provided)
#[arg(short = 'i', long)]
task: Option<String>,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Model to use for complexity analysis (overrides config)
#[arg(long)]
model: Option<String>,
},
/// Expand complex task into subtasks (AI-powered)
Expand {
/// Specific task ID to expand (expands all in current tag if not provided)
#[arg(short = 'i', long)]
task: Option<String>,
/// Expand all tasks across ALL tags (default: current tag only)
#[arg(short, long)]
all: bool,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Skip loading guidance from .scud/guidance/
#[arg(long)]
no_guidance: bool,
/// Model to use for subtask generation (overrides config)
#[arg(long)]
model: Option<String>,
},
/// Re-analyze and suggest cross-tag dependencies (AI-powered)
ReanalyzeDeps {
/// Tag to analyze (default: all tags)
#[arg(short, long)]
tag: Option<String>,
/// Analyze all tags (default if no tag specified)
#[arg(long)]
all_tags: bool,
/// Automatically apply suggestions without prompting
#[arg(long)]
apply: bool,
/// Show suggestions without applying
#[arg(long)]
dry_run: bool,
/// Model to use for dependency analysis (overrides config)
#[arg(long)]
model: Option<String>,
},
// Task Assignment commands
/// Assign task to a developer
Assign {
/// Task ID
task_id: String,
/// Assignee name
assignee: String,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
},
/// Show who is working on what
WhoIs {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
},
/// Get multiple ready tasks at once (for orchestrators)
NextBatch {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Maximum number of tasks to return
#[arg(short, long, default_value = "5")]
limit: usize,
/// Search across all phases for globally-correct tasks
#[arg(long)]
all_tags: bool,
},
/// Convert task storage format between JSON and SCG
Convert {
/// Source format (json, scg)
#[arg(long)]
from: String,
/// Target format (json, scg)
#[arg(long)]
to: String,
/// Create backup of source file (default: true)
#[arg(long, default_value = "true")]
backup: bool,
},
/// [EXPERIMENTAL] Diagnose workflow and extension issues
Doctor {
#[command(subcommand)]
command: DoctorCommands,
},
/// Check dependency validity and optionally validate against PRD
CheckDeps {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Check across all phases
#[arg(long)]
all_tags: bool,
/// Path to PRD file to validate task coverage (AI-powered)
#[arg(long)]
prd: Option<PathBuf>,
/// Auto-fix PRD coverage issues (requires --prd)
#[arg(long)]
fix: bool,
/// Model to use for PRD validation (overrides config)
#[arg(long)]
model: Option<String>,
},
/// Generate Mermaid diagram of task graph
Mermaid {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Include all phases in the diagram
#[arg(long)]
all_tags: bool,
},
/// Write a summary log entry for a task
Log {
/// Task ID to log for
task_id: String,
/// Summary text (100-200 words recommended)
summary: String,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
},
/// Show log entries for a task
LogShow {
/// Task ID
task_id: String,
},
/// Show recent log entries from all tasks (for discovery sharing)
LogAll {
/// Maximum number of entries to show (default: 20)
#[arg(short, long, default_value = "20")]
limit: usize,
/// Only show logs from tasks in this tag
#[arg(short, long)]
tag: Option<String>,
},
/// Quick orientation for new session (show recent commits, active sessions, next task)
Warmup,
/// Create a git commit with task context
Commit {
/// Commit message (uses task title if not provided)
#[arg(short, long)]
message: Option<String>,
/// Stage all changes before committing
#[arg(short, long)]
all: bool,
},
/// Spawn parallel Claude Code agents in terminal windows
Spawn {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Maximum agents to spawn (default: 5)
#[arg(short = 'n', long, default_value = "5")]
limit: usize,
/// Search across all phases for ready tasks
#[arg(long)]
all_tags: bool,
/// Show plan without spawning
#[arg(long)]
dry_run: bool,
/// Session name (default: scud-<tag>)
#[arg(long)]
session: Option<String>,
/// Attach to tmux session after spawn
#[arg(long)]
attach: bool,
/// Start TUI monitor after spawn (recommended)
#[arg(short, long)]
monitor: bool,
/// Mark spawned tasks as in-progress
#[arg(short, long)]
claim: bool,
/// Run in headless mode (no TUI monitor or attach)
#[arg(long)]
headless: bool,
/// AI harness: rho, claude, opencode (overridden by task's agent_type if set)
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Model to use with harness (overridden by task's agent_type if set)
#[arg(short = 'M', long, default_value = "xai/grok-code-fast-1")]
model: String,
},
/// Monitor spawn session with interactive TUI
Monitor {
/// Session name to monitor (auto-detects if only one exists)
#[arg(short, long)]
session: Option<String>,
/// Read from swarm session (shows actual wave/round structure)
#[arg(long)]
swarm: bool,
},
/// List spawn sessions
Sessions {
/// Show detailed info for each session
#[arg(short, long)]
verbose: bool,
},
/// Discover all tmux sessions
Discover,
/// Attach to a headless session
Attach {
/// Task ID to attach to
task_id: String,
/// Override harness (rho, claude, opencode)
#[arg(short, long)]
harness: Option<String>,
},
/// Detach from current tmux session
Detach,
/// Restart a task - reset status to pending and spawn in tmux
Restart {
/// Task ID to restart
task_id: String,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// AI harness: rho, claude, opencode (overridden by task's agent_type if set)
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Model to use with harness (overridden by task's agent_type if set)
#[arg(short = 'M', long, default_value = "xai/grok-code-fast-1")]
model: String,
/// Tmux session name (default: scud-<tag>)
#[arg(long)]
session: Option<String>,
/// Attach to tmux session after spawn
#[arg(long)]
attach: bool,
},
/// Retry a single agent without stopping the swarm
RetryAgent {
/// Task ID to retry
task_id: String,
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// AI harness: rho, claude, opencode (overridden by task's agent_type if set)
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Model to use with harness (overridden by task's agent_type if set)
#[arg(short = 'M', long, default_value = "xai/grok-code-fast-1")]
model: String,
/// Tmux session name (default: scud-<tag>)
#[arg(long)]
session: Option<String>,
},
/// Run a single AI agent with an arbitrary prompt
Run {
/// The prompt to send to the agent
prompt: String,
/// AI harness: rho, claude, opencode
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Model to use with harness
#[arg(short = 'M', long, default_value = "xai/grok-code-fast-1")]
model: String,
/// Tmux session name (default: scud-run)
#[arg(long)]
session: Option<String>,
/// Attach to tmux session after spawn
#[arg(long)]
attach: bool,
/// Window name/ID for the agent (default: auto-generated)
#[arg(long)]
name: Option<String>,
},
/// Run swarm mode - wave-based parallel execution with backpressure
Swarm {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Maximum tasks per round (default: 5)
#[arg(short = 'n', long, default_value = "5")]
round_size: usize,
/// Execute across all phases
#[arg(long)]
all_tags: bool,
/// AI harness: rho, claude, opencode (default: rho)
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Execution mode: tmux (default), headless, extensions, server, beads
#[arg(long, value_enum, default_value_t = SwarmMode::Tmux)]
swarm_mode: SwarmMode,
/// Run in headless mode (shorthand for --swarm-mode headless)
#[arg(long)]
headless: bool,
/// Show execution plan without spawning
#[arg(long)]
dry_run: bool,
/// Session name (default: swarm-<tag>)
#[arg(long)]
session: Option<String>,
/// Skip research phase (use existing tasks as-is)
#[arg(long)]
no_research: bool,
/// Skip backpressure validation after wave
#[arg(long)]
no_validate: bool,
/// Enable code review after each wave (samples 3 tasks per wave)
#[arg(long)]
review: bool,
/// Review all tasks after each wave (more expensive than --review)
#[arg(long)]
review_all: bool,
/// Disable automatic repair on validation failure
#[arg(long)]
no_repair: bool,
/// Maximum repair attempts per task before giving up (default: 3)
#[arg(long, default_value = "3")]
max_repair_attempts: usize,
/// Skip automatic salvo worktree creation (run in-place)
#[arg(long)]
no_worktree: bool,
/// Custom directory for salvo worktree (default: ../<project>.salvo.<tag>/)
#[arg(long)]
salvo_dir: Option<std::path::PathBuf>,
/// Timeout in minutes for stale tasks (default: 30). Tasks running longer
/// than this with no tmux window will be reset to pending.
#[arg(long, default_value = "30")]
stale_timeout: u64,
/// Minutes of inactivity before marking idle agent as failed (default: 5).
/// Only applies when the agent's tmux pane shows a shell prompt.
#[arg(long, default_value = "5")]
idle_timeout_minutes: u64,
/// Disable ZMQ event publishing (no real-time monitoring)
#[arg(long, default_value = "false")]
no_publish_events: bool,
},
/// Watch running swarm via ZMQ events
Watch {
/// Session ID to watch (discovers automatically if not specified)
#[arg(long)]
session: Option<String>,
/// Tag to filter sessions
#[arg(long)]
tag: Option<String>,
/// Project root directory
#[arg(long)]
project_root: Option<PathBuf>,
/// Output format: text, json
#[arg(long, default_value = "text")]
format: String,
},
/// View swarm session retrospective (event timeline and analysis)
Retro {
/// Session ID to view (shows latest if not specified)
#[arg(short, long)]
session: Option<String>,
/// Export as JSON instead of formatted output
#[arg(long)]
json: bool,
},
/// Claude Code conversation transcripts (full LLM input/output logs)
#[command(subcommand)]
Transcript(TranscriptCommand),
/// Run tests and spawn repair agents until they pass
Test {
/// Test command to run (uses backpressure config if not provided)
#[arg(short, long)]
command: Option<String>,
/// Maximum repair attempts before giving up (default: 10)
#[arg(short = 'n', long, default_value = "10")]
max_attempts: usize,
/// AI harness: rho, claude, opencode (default: rho)
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Agent type to use for repairs (default: repairer)
#[arg(short, long, default_value = "repairer")]
agent: String,
/// Tmux session name (default: scud-test)
#[arg(long)]
session: Option<String>,
/// Attach to tmux session while agent works
#[arg(long)]
attach: bool,
},
/// Run Ralph mode - sequential iteration loop with fresh context per task
Ralph {
/// Phase tag (uses active phase if not provided)
#[arg(short, long)]
tag: Option<String>,
/// Maximum iterations (0 = unlimited)
#[arg(short = 'n', long, default_value = "0")]
max_iterations: usize,
/// Skip backpressure validation
#[arg(long)]
no_validate: bool,
/// Disable automatic repair on validation failure
#[arg(long)]
no_repair: bool,
/// Maximum repair attempts per task (default: 3)
#[arg(long, default_value = "3")]
max_repair_attempts: usize,
/// AI harness: rho, claude, opencode
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Model to use with harness
#[arg(short = 'M', long)]
model: Option<String>,
/// Session name (default: ralph-<tag>)
#[arg(long)]
session: Option<String>,
/// Show plan without executing
#[arg(long)]
dry_run: bool,
/// Push to git after each successful iteration
#[arg(long)]
push: bool,
},
/// Start JSON RPC server for IPC with external orchestrators
///
/// Reads JSON RPC 2.0 requests from stdin and emits events/responses to stdout.
/// Use this for programmatic control of SCUD agents from external tools.
Serve {
/// AI harness: rho, claude, opencode
#[arg(short = 'H', long, default_value = "rho")]
harness: String,
/// Default model to use with harness
#[arg(short = 'M', long)]
model: Option<String>,
},
/// Manage salvo worktrees for parallel tag execution
#[command(subcommand)]
Salvo(SalvoCommand),
/// Sync task changes from Claude Tasks back to SCUD (internal use by hooks)
#[command(hide = true)]
SyncFromClaude,
/// Run Attractor pipelines (DOT-based AI workflow graphs)
Attractor {
#[command(subcommand)]
command: AttractorCommands,
},
/// Execute an agent loop using direct API calls (Anthropic, OpenAI, xAI, etc.)
#[cfg(feature = "direct-api")]
AgentExec {
/// Prompt text to send to the agent
#[arg(long)]
prompt: Option<String>,
/// File containing the prompt
#[arg(long)]
prompt_file: Option<std::path::PathBuf>,
/// Model to use (default depends on provider)
#[arg(short, long)]
model: Option<String>,
/// LLM provider: anthropic, openai, xai, openrouter, opencode-zen
#[arg(long)]
provider: Option<String>,
},
/// B-thread coordination (scud-weave)
Weave {
#[command(subcommand)]
command: commands::weave::WeaveCommands,
},
// /// Start interactive REPL for task management - temporarily disabled
// Repl,
}
#[derive(Subcommand)]
enum AttractorCommands {
/// Execute an Attractor pipeline
Run {
/// Path to the DOT pipeline file
file: PathBuf,
/// Resume from a checkpoint file
#[arg(long)]
resume: Option<PathBuf>,
/// Run without human interaction (auto-approve gates)
#[arg(long)]
headless: bool,
/// Use simulated backend (no LLM calls)
#[arg(long)]
simulated: bool,
/// Directory for run output (default: same as pipeline file)
#[arg(long)]
runs_dir: Option<PathBuf>,
/// Model to use (overrides pipeline defaults)
#[arg(long)]
model: Option<String>,
/// Provider to use (overrides pipeline defaults)
#[arg(long)]
provider: Option<String>,
},
/// Validate a pipeline without executing it
Validate {
/// Path to the DOT pipeline file
file: PathBuf,
},
/// Import a pipeline from another format
Import {
/// Source file path
file: PathBuf,
/// Output file path
#[arg(short, long)]
output: Option<PathBuf>,
},
/// Export a pipeline to another format
Export {
/// Source pipeline file
file: PathBuf,
/// Output format (default: dot)
#[arg(long, default_value = "dot")]
format: String,
/// Output file path (default: stdout)
#[arg(short, long)]
output: Option<PathBuf>,
},
}
#[derive(Subcommand, Clone)]
enum TranscriptCommand {
/// View a transcript (shows latest if no session specified)
View {
/// Session ID to view
#[arg(short, long)]
session: Option<String>,
/// Show full transcript (all messages and tool calls)
#[arg(short, long)]
full: bool,
/// Export as JSON
#[arg(long)]
json: bool,
},
/// List available transcripts (from Claude Code project files)
List,
/// Search transcript content in the database
Search {
/// Search query
query: String,
},
/// Show transcript statistics from the database
Stats,
/// Import all transcripts for current project into the database
Import,
}
#[derive(Subcommand, Clone)]
enum SalvoCommand {
/// List all salvo worktrees
List,
/// Sync a salvo worktree's task status back to main
Sync {
/// Tag name of the salvo
tag: String,
},
/// Remove a salvo worktree
Remove {
/// Tag name of the salvo
tag: String,
},
}
fn resolve_swarm_mode(swarm_mode: SwarmMode, headless: bool) -> SwarmMode {
if headless {
SwarmMode::Headless
} else {
swarm_mode
}
}
#[tokio::main]
async fn main() -> Result<()> {
// Load .env file if present (before anything else)
// Tries: .env, .scud/.env, ~/.scud/.env
if dotenvy::dotenv().is_err() {
// Try .scud/.env
let _ = dotenvy::from_filename(".scud/.env");
}
// Also try home directory
if let Some(home) = dirs::home_dir() {
let _ = dotenvy::from_path(home.join(".scud/.env"));
}
let cli = Cli::parse();
match cli.command {
Commands::Install => commands::install::run(),
Commands::Init { provider } => commands::init::run(cli.project, provider),
Commands::Tags { tag } => commands::tags::run(cli.project, tag.as_deref()),
Commands::List {
status,
tag,
json,
verbose,
} => commands::list::run(
cli.project,
status.as_deref(),
tag.as_deref(),
json,
verbose,
),
Commands::View => commands::view::run(cli.project),
Commands::Show { task_id, tag } => {
commands::show::run(cli.project, &task_id, tag.as_deref())
}
Commands::SetStatus {
first_arg,
rest,
from,
to,
tag,
all_tags,
} => commands::set_status::run(
cli.project,
first_arg.as_deref(),
&rest,
from.as_deref(),
to.as_deref(),
tag.as_deref(),
all_tags,
),
Commands::Next {
tag,
spawn,
all_tags,
} => commands::next::run(cli.project, tag.as_deref(), spawn, all_tags),
Commands::Stats { tag } => commands::stats::run(cli.project, tag.as_deref()),
Commands::Migrate { dry_run } => commands::migrate::run(cli.project, dry_run),
Commands::Waves {
tag,
max_parallel,
all_tags,
} => commands::waves::run(cli.project, tag.as_deref(), max_parallel, all_tags),
Commands::Config { command } => match command {
ConfigCommands::Show => commands::config::show(cli.project),
ConfigCommands::SetProvider { provider, model } => {
commands::config::set_provider(cli.project, &provider, model)
}
ConfigCommands::Agents { command } => match command {
AgentsCommands::List => commands::config::agents_list(cli.project),
AgentsCommands::Add { name, all } => {
commands::config::agents_add(cli.project, name, all)
}
AgentsCommands::Remove { name, all } => {
commands::config::agents_remove(cli.project, name, all)
}
AgentsCommands::Configure { name } => {
commands::config::spawn_agents_configure(cli.project, name)
}
},
ConfigCommands::Backpressure {
commands,
add,
remove,
list,
clear,
} => commands::config::backpressure(cli.project, commands, add, remove, list, clear),
ConfigCommands::SpawnAgents { command } => match command {
SpawnAgentsCommands::List => commands::config::spawn_agents_list(cli.project),
SpawnAgentsCommands::Add {
name,
all,
interactive,
} => commands::config::spawn_agents_add(cli.project, name, all, interactive),
SpawnAgentsCommands::Remove { name, all } => {
commands::config::spawn_agents_remove(cli.project, name, all)
}
SpawnAgentsCommands::UpdateFromConfig => {
commands::config::spawn_agents_update_from_config(cli.project)
}
},
},
Commands::Parse {
file,
tag,
num_tasks,
append,
no_guidance,
id_format,
model,
} => {
commands::ai::parse_prd::run(
cli.project,
&file,
&tag,
num_tasks,
append,
no_guidance,
&id_format,
model.as_deref(),
)
.await
}
Commands::Generate {
file,
tag,
num_tasks,
no_expand,
no_check_deps,
append,
no_guidance,
id_format,
model,
dry_run,
verbose,
pipeline,
output,
} => {
if pipeline {
commands::generate::run_pipeline(
cli.project,
&file,
&tag,
model.as_deref(),
output,
dry_run,
verbose,
)
.await
} else {
commands::generate::run(
cli.project,
&file,
&tag,
num_tasks,
no_expand,
no_check_deps,
append,
no_guidance,
&id_format,
model.as_deref(),
dry_run,
verbose,
)
.await
}
}
Commands::Clean {
force,
tag,
keep,
delete,
list,
restore,
} => commands::clean::run(
cli.project,
force,
tag.as_deref(),
&keep,
delete,
list,
restore.as_deref(),
),
Commands::AnalyzeComplexity { task, tag, model } => {
commands::ai::analyze_complexity::run(
cli.project,
task.as_deref(),
tag.as_deref(),
model.as_deref(),
)
.await
}
Commands::Expand {
task,
all,
tag,
no_guidance,
model,
} => {
commands::ai::expand::run(
cli.project,
task.as_deref(),
all,
tag.as_deref(),
no_guidance,
model.as_deref(),
)
.await
}
Commands::ReanalyzeDeps {
tag,
all_tags,
apply,
dry_run,
model,
} => {
commands::ai::reanalyze_deps::run(
cli.project,
tag.as_deref(),
all_tags,
apply,
dry_run,
model.as_deref(),
)
.await
}
Commands::Assign {
task_id,
assignee,
tag,
} => commands::assign::run(cli.project, &task_id, &assignee, tag.as_deref()),
Commands::WhoIs { tag } => commands::whois::run(cli.project, tag.as_deref()),
Commands::NextBatch {
tag,
limit,
all_tags,
} => commands::next_batch::run(cli.project, tag.as_deref(), limit, all_tags),
Commands::Convert { from, to, backup } => {
commands::convert::run(cli.project, &from, &to, backup)
}
Commands::Doctor { command } => match command {
DoctorCommands::Workflow {
tag,
stale_hours,
fix,
} => commands::doctor::run(cli.project, tag.as_deref(), stale_hours, fix),
DoctorCommands::ScanExt => commands::doctor::scan_ext(cli.project),
},
Commands::CheckDeps {
tag,
all_tags,
prd,
fix,
model,
} => {
commands::check_deps::run(
cli.project,
tag.as_deref(),
all_tags,
prd.as_deref(),
fix,
model.as_deref(),
)
.await
}
Commands::Mermaid { tag, all_tags } => {
commands::mermaid::run(cli.project, tag.as_deref(), all_tags)
}
Commands::Log {
task_id,
summary,
tag,
} => commands::log::run(cli.project, &task_id, &summary, tag.as_deref()),
Commands::LogShow { task_id } => commands::log::show(cli.project, &task_id),
Commands::LogAll { limit, tag } => {
commands::log::show_all(cli.project, limit, tag.as_deref())
}
Commands::Warmup => commands::warmup::run(cli.project),
Commands::Commit { message, all } => {
commands::commit::run(cli.project, message.as_deref(), all)
}
Commands::Spawn {
tag,
limit,
all_tags,
dry_run,
session,
attach,
monitor,
claim,
headless,
harness,
model,
} => commands::spawn::run(
cli.project,
tag.as_deref(),
limit,
all_tags,
dry_run,
session,
attach,
monitor,
claim,
headless,
&harness,
&model,
),
Commands::Monitor { session, swarm } => {
commands::spawn::run_monitor(cli.project, session, swarm)
}
Commands::Sessions { verbose } => commands::spawn::run_sessions(cli.project, verbose),
Commands::Discover => commands::spawn::run_discover_sessions(cli.project),
Commands::Attach { task_id, harness } => {
commands::attach::run(cli.project, &task_id, harness.as_deref())
}
Commands::Detach => commands::spawn::run_detach_session(cli.project),
Commands::Restart {
task_id,
tag,
harness,
model,
session,
attach,
} => commands::restart::run(
cli.project,
&task_id,
tag.as_deref(),
&harness,
&model,
session,
attach,
),
Commands::RetryAgent {
task_id,
tag,
harness,
model,
session,
} => commands::restart::run(
cli.project,
&task_id,
tag.as_deref(),
&harness,
&model,
session,
false, // no auto-attach for in-flight swarm retries
),
Commands::Run {
prompt,
harness,
model,
session,
attach,
name,
} => commands::run::run(
cli.project,
&prompt,
&harness,
&model,
session,
attach,
name,
),
Commands::Swarm {
tag,
round_size,
all_tags,
harness,
swarm_mode,
headless,
dry_run,
session,
no_research,
no_validate,
review,
review_all,
no_repair,
max_repair_attempts,
no_worktree,
salvo_dir,
stale_timeout,
idle_timeout_minutes,
no_publish_events,
} => {
commands::swarm::run(commands::swarm::SwarmConfig {
project_root: cli.project,
tag,
round_size,
all_tags,
harness_arg: harness,
swarm_mode: resolve_swarm_mode(swarm_mode, headless),
dry_run,
session_name: session,
no_research,
no_validate,
review,
review_all,
no_repair,
max_repair_attempts,
no_worktree,
salvo_dir,
stale_timeout_minutes: Some(stale_timeout),
idle_timeout_minutes,
no_publish_events,
pause_flag: None,
stop_flag: None,
})
.await
}
Commands::Watch {
session,
tag,
project_root,
format,
} => {
let args = commands::watch::WatchArgs {
session,
tag,
project_root,
format,
};
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(commands::watch::run(args))
}
Commands::Retro { session, json } => {
let project_root = cli
.project
.clone()
.unwrap_or_else(|| std::env::current_dir().unwrap_or_default());
if json {
let session_id = session.as_deref().unwrap_or("latest");
match commands::swarm::events::export_retro_json(&project_root, session_id) {
Ok(json_str) => println!("{}", json_str),
Err(e) => anyhow::bail!("Failed to export retro: {}", e),
}
} else {
commands::swarm::events::print_retro(&project_root, session.as_deref())?;
}
Ok(())
}
Commands::Transcript(cmd) => {
let project_root = cli
.project
.clone()
.unwrap_or_else(|| std::env::current_dir().unwrap_or_default());
match cmd {
TranscriptCommand::View {
session,
full,
json,
} => {
if json {
match commands::swarm::transcript::export_transcript_json(
&project_root,
session.as_deref(),
) {
Ok(json_str) => println!("{}", json_str),
Err(e) => anyhow::bail!("Failed to export transcript: {}", e),
}
} else {
commands::swarm::transcript::view_transcript(
&project_root,
session.as_deref(),
full,
)?;
}
}
TranscriptCommand::List => {
commands::swarm::transcript::list_transcripts(&project_root)?;
}
TranscriptCommand::Search { query } => {
let db = scud::db::Database::new(&project_root);
db.initialize()?;
let guard = db.connection()?;
let conn = guard.as_ref().unwrap();
let results = scud::db::transcripts::search_transcripts(conn, &query)?;
if results.is_empty() {
println!("No results found for '{}'", query);
} else {
for r in results {
println!(
"{} [{}] {}: {}",
r.timestamp,
r.task_id.unwrap_or_default(),
r.role,
r.content_preview
);
}
}
}
TranscriptCommand::Stats => {
let db = scud::db::Database::new(&project_root);
db.initialize()?;
let guard = db.connection()?;
let conn = guard.as_ref().unwrap();
let stats = scud::db::transcripts::get_transcript_stats(conn)?;
println!("Transcript Statistics:");
println!(" Sessions: {}", stats.total_sessions);
println!(" Messages: {}", stats.total_messages);
println!(" Tool calls: {}", stats.total_tool_calls);
}
TranscriptCommand::Import => {
let db = std::sync::Arc::new(scud::db::Database::new(&project_root));
db.initialize()?;
let watcher =
scud::transcript_watcher::TranscriptWatcher::new(&project_root, db);
let count = watcher.import_all(None, None)?;
println!("Imported {} transcript sessions", count);
}
}
Ok(())
}
Commands::Test {
command,
max_attempts,
harness,
agent,
session,
attach,
} => commands::test::run(
cli.project,
command.as_deref(),
max_attempts,
&harness,
&agent,
session,
attach,
),
Commands::Ralph {
tag,
max_iterations,
no_validate,
no_repair,
max_repair_attempts,
harness,
model,
session,
dry_run,
push,
} => commands::ralph::run(
cli.project,
tag.as_deref(),
max_iterations,
no_validate,
no_repair,
max_repair_attempts,
&harness,
model.as_deref(),
session,
dry_run,
push,
),
Commands::Serve { harness, model } => {
commands::serve::run(cli.project, &harness, model.as_deref()).await
}
Commands::Salvo(cmd) => {
let project_root = cli
.project
.clone()
.unwrap_or_else(|| std::env::current_dir().unwrap_or_default());
match cmd {
SalvoCommand::List => {
commands::salvo::list_worktrees(&project_root)?;
}
SalvoCommand::Sync { tag } => {
let db = scud::db::Database::new(&project_root);
db.initialize()?;
let guard = db.connection()?;
let conn = guard.as_ref().unwrap();
let path: String = conn.query_row(
"SELECT worktree_path FROM salvo_worktrees WHERE tag = ?",
[&tag],
|row| row.get(0),
)?;
commands::salvo::sync_to_main(
&project_root,
&std::path::PathBuf::from(path),
&tag,
)?;
}
SalvoCommand::Remove { tag } => {
commands::salvo::remove_worktree(&project_root, &tag)?;
}
}
Ok(())
}
Commands::Attractor { command } => match command {
AttractorCommands::Run {
file,
resume,
headless,
simulated,
runs_dir,
model,
provider,
} => {
commands::attractor::run::run(
&file,
resume.as_deref(),
headless,
simulated,
model.as_deref(),
provider.as_deref(),
runs_dir.as_deref(),
)
.await
}
AttractorCommands::Validate { file } => commands::attractor::validate::run(&file),
AttractorCommands::Import { file, output } => {
commands::attractor::import::run(&file, output.as_deref())
}
AttractorCommands::Export {
file,
format,
output,
} => commands::attractor::export::run(&file, &format, output.as_deref()),
},
Commands::SyncFromClaude => commands::sync_from_claude::run(cli.project),
#[cfg(feature = "direct-api")]
Commands::Heavy {
query,
provider,
model,
captain_model,
agents,
debate_rounds,
verbose,
json,
query_file,
} => {
commands::heavy::run(
query, provider, model, captain_model, agents, debate_rounds, verbose, json,
query_file,
)
.await
}
#[cfg(feature = "direct-api")]
Commands::AgentExec {
prompt,
prompt_file,
model,
provider,
} => commands::agent_exec::run(prompt, prompt_file, model, provider).await,
Commands::Weave { command } => {
use commands::weave::WeaveCommands;
match command {
WeaveCommands::Check { event_json } => {
commands::weave::check::run(cli.project, &event_json)
}
WeaveCommands::Record { event_json } => {
commands::weave::record::run(cli.project, &event_json)
}
WeaveCommands::Release { lock_key, agent } => {
commands::weave::release::run_release(
cli.project,
&lock_key,
agent.as_deref(),
)
}
WeaveCommands::ReleaseAll { agent, task } => {
commands::weave::release::run_release_all(
cli.project,
&agent,
task.as_deref(),
)
}
WeaveCommands::Init => commands::weave::manage::run_init(cli.project),
WeaveCommands::Add {
id,
name,
rule_type,
rule_spec,
} => commands::weave::manage::run_add(
cli.project,
&id,
&name,
&rule_type,
&rule_spec,
),
WeaveCommands::Enable { id } => {
commands::weave::manage::run_enable(cli.project, &id)
}
WeaveCommands::Disable { id } => {
commands::weave::manage::run_disable(cli.project, &id)
}
WeaveCommands::Remove { id } => {
commands::weave::manage::run_remove(cli.project, &id)
}
WeaveCommands::List => commands::weave::manage::run_list(cli.project),
WeaveCommands::Status => commands::weave::status::run(cli.project),
WeaveCommands::Log { tail } => commands::weave::log::run(cli.project, tail),
WeaveCommands::Explain { event_json } => {
commands::weave::explain::run(cli.project, &event_json)
}
WeaveCommands::Summary => commands::weave::summary::run(cli.project),
WeaveCommands::Gate { tool, input } => {
commands::weave::gate::run(cli.project, &tool, &input)
}
WeaveCommands::Template { command } => {
use commands::weave::TemplateCommands;
match command {
TemplateCommands::List => commands::weave::template::run_list(),
TemplateCommands::Apply { name } => {
commands::weave::template::run_apply(cli.project, &name)
}
}
}
}
}
// Commands::Repl => commands::repl::run(), // temporarily disabled
}
}
#[cfg(test)]
mod tests {
use super::*;
use clap::Parser;
#[test]
fn spawn_defaults_to_rho_harness() {
let cli = Cli::parse_from(["scud", "spawn"]);
match cli.command {
Commands::Spawn { harness, .. } => assert_eq!(harness, "rho"),
_ => panic!("expected spawn command"),
}
}
#[test]
fn swarm_defaults_to_rho_harness() {
let cli = Cli::parse_from(["scud", "swarm"]);
match cli.command {
Commands::Swarm { harness, .. } => assert_eq!(harness, "rho"),
_ => panic!("expected swarm command"),
}
}
#[test]
fn run_defaults_to_rho_harness() {
let cli = Cli::parse_from(["scud", "run", "hello"]);
match cli.command {
Commands::Run { harness, .. } => assert_eq!(harness, "rho"),
_ => panic!("expected run command"),
}
}
#[test]
fn test_defaults_to_rho_harness() {
let cli = Cli::parse_from(["scud", "test"]);
match cli.command {
Commands::Test { harness, .. } => assert_eq!(harness, "rho"),
_ => panic!("expected test command"),
}
}
}