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
use clap::{Args, Parser, Subcommand};
pub mod commands;
pub mod discovery;
pub mod output;
#[derive(Parser, Debug, Default)]
#[command(name = "lf")]
#[command(about = "Run skills and flows with coding agents")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
/// List available skills and flows
#[arg(short, long)]
pub list: bool,
/// Direction(s) to apply (repeatable or comma-separated)
#[arg(
short = 'd',
long = "direction",
value_delimiter = ',',
short_alias = 'D'
)]
pub direction: Vec<String>,
/// Exclude config default directions
#[arg(long = "no-direction")]
pub no_direction: bool,
/// Docs paths, globs, or directories to include in context
#[arg(long = "docs", value_delimiter = ',')]
pub docs: Vec<String>,
/// Include clipboard content in prompt
#[arg(short = 'c', long = "clipboard", short_alias = 'C')]
pub clipboard: bool,
/// Model to use (harness or harness:model)
#[arg(short = 'm', long = "model", short_alias = 'M')]
pub model: Option<String>,
/// Skip permission prompts
#[arg(long)]
pub yolo: bool,
/// Run interactively
#[arg(short = 'i', long = "interactive", short_alias = 'I')]
pub interactive: bool,
/// Run in batch/headless mode
#[arg(short = 'b', long = "batch", short_alias = 'B')]
pub batch: bool,
/// Hand off to an interactive vendor session in the terminal (overrides session.launch)
#[arg(long, conflicts_with = "ide")]
pub tui: bool,
/// Hand off to an interactive vendor session in the vendor app (overrides session.launch)
#[arg(long)]
pub ide: bool,
/// Enable Chrome integration (Claude)
#[arg(long)]
pub chrome: bool,
/// Disable Chrome integration (Claude)
#[arg(long = "no-chrome", overrides_with = "chrome")]
pub no_chrome: bool,
/// Include files changed on branch
#[arg(long = "diff-files")]
pub diff_files: bool,
/// Exclude files changed on branch
#[arg(long = "no-diff-files", overrides_with = "diff_files")]
pub no_diff_files: bool,
/// Include raw git diff
#[arg(long = "diff")]
pub diff: bool,
/// Exclude raw git diff
#[arg(long = "no-diff", overrides_with = "diff")]
pub no_diff: bool,
/// Maximum agent turns for this invocation
#[arg(long = "max-turns")]
pub max_turns: Option<u32>,
/// Wave name for wave/ scoping
#[arg(short = 'w', long = "wave", short_alias = 'W')]
pub wave: Option<String>,
/// Exclude loopflow operating guidance
#[arg(long = "no-loopflow")]
pub no_loopflow: bool,
}
impl Cli {
fn toggle_setting(enabled: bool, disabled: bool) -> Option<bool> {
if enabled {
Some(true)
} else if disabled {
Some(false)
} else {
None
}
}
/// Get chrome setting: Some(true) if --chrome, Some(false) if --no-chrome, None if neither.
pub fn chrome_setting(&self) -> Option<bool> {
Self::toggle_setting(self.chrome, self.no_chrome)
}
/// Get diff_files setting: Some(true) if --diff-files, Some(false) if --no-diff-files, None if neither.
pub fn diff_files_setting(&self) -> Option<bool> {
Self::toggle_setting(self.diff_files, self.no_diff_files)
}
/// Get diff setting: Some(true) if --diff, Some(false) if --no-diff, None if neither.
pub fn diff_setting(&self) -> Option<bool> {
Self::toggle_setting(self.diff, self.no_diff)
}
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Run an inline prompt
#[command(name = ":")]
Inline {
#[arg(trailing_var_arg = true)]
prompt: Vec<String>,
},
/// Pull request lifecycle
Pr {
#[command(subcommand)]
cmd: Option<PrCommand>,
},
/// Worktree operations
Wt {
#[command(subcommand)]
cmd: WtCommand,
},
/// Rebase current branch onto target (default: main)
Rebase {
/// Print the planned rebase strategy without mutating git
#[arg(long, conflicts_with_all = ["manual", "continue_rebase", "abort"])]
plan: bool,
/// Keep the rebase local and leave conflicts for this process to resolve
#[arg(long, conflicts_with_all = ["plan", "continue_rebase", "abort"])]
manual: bool,
/// Stage resolved conflict paths and continue the local rebase
#[arg(long = "continue", conflicts_with_all = ["plan", "manual", "abort"])]
continue_rebase: bool,
/// Abort the local rebase in progress
#[arg(long, conflicts_with_all = ["plan", "manual", "continue_rebase"])]
abort: bool,
/// Branch to rebase onto
onto: Option<String>,
},
/// Commit changes
Commit {
#[arg(short = 'm', long = "message", short_alias = 'M')]
message: Option<String>,
#[arg(short = 'p', long = "push", short_alias = 'P')]
push: bool,
#[arg(long = "no-add")]
no_add: bool,
},
/// Provider authentication for local lf skills and ops
Auth {
#[command(subcommand)]
cmd: AuthCommand,
},
/// Release operations (run, check, notes, bump, tag, status)
Release {
#[command(subcommand)]
cmd: ReleaseCommand,
},
/// Linear Initiatives, Projects, and tasks for waves
Pm {
#[command(subcommand)]
cmd: PmCommand,
},
/// Compile loopflow skills into your home vendor Skills directories.
#[command(name = "sync-skills", hide = true)]
SyncSkills {
/// Confirm writes under ~/ without prompting
#[arg(short = 'y', long = "yes")]
yes: bool,
/// Keep stale loopflow-generated skills
#[arg(long = "no-prune")]
no_prune: bool,
},
/// Local launchd jobs that run lf commands on a schedule
Cron {
#[command(subcommand)]
cmd: CronCommand,
},
/// Run a Wave's listener, thread, and residency. Steerable.
///
/// By convention this is the wave loop's entrypoint — a served mind is one
/// you can chat with while it runs.
Wave {
/// Wave name
name: String,
/// Take over even if another live wave session is registered
#[arg(long)]
force: bool,
},
/// Stop a served wave gracefully
Stop {
/// Wave name
name: String,
},
/// Internal: the resident body a listener spawns for its own wave. Never
/// booted by hand — `lf wave` owns the listener half.
#[command(name = "__resident", hide = true)]
Resident {
/// Wave name
name: String,
},
/// Internal resident primitive: execute one expanded top-level flow step.
#[command(name = "__flow-step", hide = true)]
FlowStep {
flow: String,
index: usize,
seed: String,
},
/// Project lifecycle operations
Project {
#[command(subcommand)]
cmd: ProjectCommand,
},
/// Linear-backed Task Session lifecycle
Task {
#[command(subcommand)]
cmd: TaskCommand,
},
/// Internal: run one durable Task Session process generation
#[command(name = "__task", hide = true)]
TaskRunner {
session_id: String,
#[arg(long)]
generation: u32,
},
/// Internal: run one durable Project Session process generation
#[command(name = "__project", hide = true)]
ProjectRunner {
session_id: String,
#[arg(long)]
generation: u32,
},
/// Measure this codebase: lines and tokens per directory (tracked files only)
Tokens {
/// Emit as JSON
#[arg(long)]
json: bool,
/// Walk git history instead: the codebase's size on each day it changed
#[arg(long, value_name = "DAYS")]
days: Option<u32>,
},
/// Show token usage and cost by repo and provider (from the local ledger)
Usage {
/// Emit per-boundary spend (skill, provider:model, repo) as JSON
#[arg(long)]
json: bool,
/// Window for --json, in days
#[arg(long, default_value_t = 30)]
days: u32,
},
/// Inspect supplied agent context and its contributing assets
Context {
/// Window in days
#[arg(long, default_value_t = 30)]
days: u32,
/// Filter by wave
#[arg(long)]
wave: Option<String>,
/// Filter by absolute main-repo path
#[arg(long)]
repo: Option<String>,
/// Emit the stable context dataset as JSON
#[arg(long)]
json: bool,
},
/// Audit the local run ledger: continuity, vocabulary, attribution, identity, lineage, coverage
Doctor {
/// Emit the audit as JSON
#[arg(long)]
json: bool,
},
/// List every wave in the registry (running and stopped), marking which
/// have a live server. Local-only query over the shared ledger.
Ls {
/// Emit the wave snapshot as JSON (Loopflow's dashboard snapshot)
#[arg(long)]
json: bool,
},
/// Show one wave's Project/Task hierarchy, runs, attention, and live loop
/// state from the registry. Defaults to the ambient wave (`LF_WAVE_ID`).
Status {
/// Wave name (default: the ambient wave)
wave: Option<String>,
/// Emit the status snapshot as JSON
#[arg(long)]
json: bool,
},
/// Show recent loopflow runs from the local ledger (all repos, local-only)
Runs {
/// Emit the run history as JSON
#[arg(long)]
json: bool,
},
/// Reconstruct one run from the local ledger: skills, durations, tokens, prompt logs
Trace {
/// Run id from `lf runs` (a unique prefix is enough)
run_id: String,
/// Emit the process tree as JSON
#[arg(long)]
json: bool,
/// Render the normalized recorded conversation
#[arg(long, conflicts_with = "json")]
events: bool,
/// Stream stored event objects as JSONL
#[arg(long, requires = "events")]
jsonl: bool,
/// Select one launch by id prefix
#[arg(long, requires = "events")]
launch: Option<String>,
},
/// Converse with a served mind's thread (humans); --follow replays it and
/// --steer reaches the live body. Agents use `lf radio pub` for
/// agent-to-agent comms, not this.
Chat {
/// Message text (reads stdin when omitted unless --follow)
#[arg(trailing_var_arg = true)]
text: Vec<String>,
/// Replay and follow the thread while typed lines post into it.
#[arg(long, conflicts_with = "text")]
follow: bool,
/// Inject into a live steer-capable turn; otherwise queue.
#[arg(long, conflicts_with = "parent")]
steer: bool,
#[command(flatten)]
target: WaveTargetArgs,
},
/// Publish to or subscribe to the ephemeral agent bus.
#[command(subcommand_required = true, arg_required_else_help = true)]
Radio {
#[command(subcommand)]
command: RadioCommand,
},
// Reserve the retired spelling so the external-subcommand fallback cannot
// reinterpret the retired top-level spelling as a skill. This variant can
// never parse.
#[command(
name = "sub",
hide = true,
about = "Removed; use `lf radio sub`",
arg_required_else_help = true
)]
RetiredSub {
#[arg(required = true, value_parser = reject_retired_sub)]
removed: String,
},
// Same reservation for the retired `lf op` namespace, which held every
// operation before the runtime collapsed to waves, projects, and tasks.
// Without it, `lf op land` reports a missing skill named `op` instead of
// naming the command that replaced it.
#[command(
name = "op",
hide = true,
about = "Removed; the operations are top-level (`lf pr`, `lf rebase`, `lf wt`, `lf pm`)",
arg_required_else_help = true
)]
RetiredOp {
#[arg(required = true, value_name = "COMMAND", value_parser = reject_retired_op)]
removed: String,
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
rest: Vec<String>,
},
/// Read or curate a wave's MEMORY.md (server-owned; bare `lf memory` = show)
Memory {
#[command(subcommand)]
cmd: Option<MemoryCommand>,
#[command(flatten)]
target: WaveTargetArgs,
},
/// Run a command on a remote host carrying your local credentials.
///
/// Resolves the local credential bundle (GitHub, Claude, PM) and forwards it
/// over the ssh channel per-invocation; nothing persists on the remote. The
/// Doppler token is never forwarded — name specific secrets with `--secret`
/// to resolve them locally. Example: `lf ssh mini-heart -- lf pr open`.
Ssh {
/// Remote host (ssh alias or user@host)
host: String,
/// Repository path on the remote, relative to $HOME
#[arg(long = "repo")]
repo: Option<String>,
/// Doppler secret to resolve locally and forward as an env var
/// (repeatable). The Doppler token itself is never forwarded.
#[arg(long = "secret")]
secret: Vec<String>,
/// Forward the ssh-agent (`ssh -A`). Off by default: git pushes use the
/// forwarded GH_TOKEN over HTTPS, so agent forwarding is unneeded risk.
#[arg(long = "forward-agent")]
forward_agent: bool,
/// Command to run on the remote (after `--`)
#[arg(last = true)]
cmd: Vec<String>,
},
/// Run a flow by name — the explicit form for names that collide with a
/// built-in command
Flow {
/// Flow name
name: String,
/// Message for the flow
#[arg(trailing_var_arg = true)]
args: Vec<String>,
},
/// Run a skill (skill) by name — the explicit form
Skill {
/// Skill name
name: String,
/// Message for the skill
#[arg(trailing_var_arg = true)]
args: Vec<String>,
},
/// External: skill/flow name (when no subcommand matches)
#[command(external_subcommand)]
External(Vec<String>),
}
#[derive(Subcommand, Debug)]
pub enum RadioCommand {
/// Broadcast on the agent bus. Reads stdin when TEXT is omitted.
Pub {
/// Message text (reads stdin when omitted — heredoc-friendly)
#[arg(trailing_var_arg = true)]
text: Vec<String>,
/// Broadcast on another channel (a hand's `goals.<run>`) instead of
/// your own.
#[arg(short = 'c', long = "channel", conflicts_with = "parent")]
channel: Option<String>,
/// Broadcast to the parent wave's channel (escalation up the tree).
#[arg(long)]
parent: bool,
/// Byline for machine speech (e.g. --from ci). Testimony, not proof:
/// the row records it beside the channel it arrived on.
#[arg(long)]
from: Option<String>,
},
/// Hear broadcasts on a channel and its descendants while listening.
Sub {
/// Channel prefix (default: the ambient channel — env, else worktree)
channel: Option<String>,
/// Emit heard frames as NDJSON instead of human lines
#[arg(long)]
json: bool,
},
}
fn reject_retired_sub(_: &str) -> Result<String, String> {
Err("the top-level subscription command was removed; use `lf radio sub`".to_string())
}
/// Name the surviving spelling for each retired `lf op` verb. Prompts, `.lf/`
/// adaptations, and older installed binaries still say `lf op …`; a caller who
/// types it should learn where the operation went, not that a skill named `op`
/// is missing. Nothing here executes — it only fails with a memory.
fn reject_retired_op(sub: &str) -> Result<String, String> {
let hint = match sub {
// Ephemeral rotation is gone, not renamed: a worker forks from and
// targets its parent branch, so no branch rotates through a worktree.
"next" | "advance" => {
"it has no replacement — dispatch work with `lf task run <issue-id>`, \
and the worker forks from and targets its parent branch"
.to_string()
}
"pr" => "use `lf pr open`".to_string(),
"submit" => "use `lf pr submit`".to_string(),
"land" => "use `lf pr land`".to_string(),
"dispatch" => "use `lf task run <issue-id>`".to_string(),
"auth" | "commit" | "cron" | "doctor" | "pm" | "rebase" | "release" | "sync-skills"
| "wt" => format!("use `lf {sub}`"),
_ => "the operations are top-level now — see `lf --help`".to_string(),
};
Err(format!("`lf op {sub}` was removed; {hint}"))
}
/// Wave targeting shared by `lf chat` and `lf memory`: default is the
/// invoking context's wave (`LF_WAVE_ID` env, else the worktree name).
#[derive(Args, Debug, Clone, Default)]
pub struct WaveTargetArgs {
/// Target wave by name
#[arg(short = 'w', long = "wave", conflicts_with = "parent")]
pub wave: Option<String>,
/// Target the invoking wave's parent (escalation up the wave tree)
#[arg(long)]
pub parent: bool,
}
#[derive(Subcommand, Debug)]
pub enum MemoryCommand {
/// Print the wave's MEMORY.md
Show {
#[command(flatten)]
target: WaveTargetArgs,
},
/// Print memory facts added since the last update
Log {
#[command(flatten)]
target: WaveTargetArgs,
},
/// Replace MEMORY.md from stdin (written by the live server, journaled)
Update {
/// One-line summary journaled with the update (default: first line)
#[arg(long)]
summary: Option<String>,
#[command(flatten)]
target: WaveTargetArgs,
},
/// Publish one fact to the replayable memory stream
Add {
/// The fact to publish
fact: String,
#[command(flatten)]
target: WaveTargetArgs,
},
}
#[derive(Subcommand, Debug)]
pub enum ProjectCommand {
/// Create a Linear Project first, then start its durable Project Session
Start {
title: String,
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
#[arg(long)]
directive: Option<String>,
#[arg(long)]
json: bool,
},
/// Start or resume the one durable Session for an existing Linear Project
Run {
/// Linear Project UUID or unique slug
project_id: String,
#[arg(long)]
directive: Option<String>,
#[arg(long)]
json: bool,
},
/// Show durable Project Session state and reconcile process liveness
Status {
project_id: String,
#[arg(long)]
json: bool,
},
/// Queue an audited instruction for exactly the next provider turn
FollowUp {
project_id: String,
message: String,
#[arg(long)]
json: bool,
},
/// Redirect Project work now, relaunching the Session when needed
Steer {
project_id: String,
message: String,
#[arg(long)]
json: bool,
},
/// Interrupt the active Project turn and optionally replace its next instruction
Interrupt {
project_id: String,
#[arg(long = "message")]
message: Option<String>,
#[arg(long)]
json: bool,
},
/// Read or wait for one durable Project command receipt
Receipt {
command_id: String,
#[arg(long, value_enum)]
until: Option<crate::ops::ChildReceiptUntil>,
#[arg(long, default_value = "30s")]
timeout: String,
#[arg(long)]
json: bool,
},
/// Confirm that this Project incorporated its current direction
Acknowledge {
project_id: String,
#[arg(long)]
directive: u32,
#[arg(long)]
summary: String,
#[arg(long)]
json: bool,
},
/// Resolve a durable Project decision request
Decide {
project_id: String,
decision_id: String,
choice: String,
#[arg(long)]
message: Option<String>,
#[arg(long)]
json: bool,
},
/// Ask the owning Wave to choose while preserving this Project Session
RequestDecision {
project_id: String,
prompt: String,
#[arg(long = "option", required = true)]
options: Vec<String>,
#[arg(long)]
wait: bool,
#[arg(long, default_value = "30m")]
timeout: String,
#[arg(long)]
json: bool,
},
/// Wait without polling an LM
Wait {
project_id: String,
#[arg(long, default_value = "terminal", value_parser = ["waiting", "terminal"])]
until: String,
#[arg(long)]
timeout: Option<String>,
#[arg(long)]
json: bool,
},
/// Resume the same Project Session and provider history
Resume {
project_id: String,
message: Option<String>,
#[arg(long)]
json: bool,
},
/// Attach to the writable Project Session control terminal
Attach { project_id: String },
/// End Project pursuit without deleting its durable history
Abandon {
project_id: String,
#[arg(long)]
reason: String,
#[arg(long)]
json: bool,
},
/// Promote a project into a resident child wave through the authored flow
Promote {
/// Linear Project slug under the parent wave
slug: String,
/// Parent wave (default: ambient wave)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
},
}
#[derive(Subcommand, Debug)]
pub enum TaskCommand {
/// Ensure its Project Session, then start or return the existing Linear task
Run {
issue: String,
#[arg(long)]
directive: Option<String>,
#[arg(long)]
json: bool,
},
/// Create a Linear task, ensure its Project Session, then start its Task Session
Start {
title: String,
#[arg(short = 'p', long = "project")]
project_id: String,
#[arg(long)]
directive: Option<String>,
#[arg(long)]
json: bool,
},
/// Show durable state and reconcile process liveness
Status {
issue: String,
#[arg(long)]
json: bool,
},
/// List files changed from this Task's recorded base commit
Changes {
issue: String,
#[arg(long)]
json: bool,
},
/// Show this Task's patch, optionally limited to one changed file
Diff {
issue: String,
path: Option<String>,
#[arg(long)]
json: bool,
},
/// Read one file from this Task's worktree
File {
issue: String,
path: String,
#[arg(long)]
json: bool,
},
/// Queue an audited instruction for exactly the next provider turn
FollowUp {
issue: String,
message: String,
#[arg(long)]
json: bool,
},
/// Redirect the active provider turn, interrupting when live steer is unavailable
Steer {
issue: String,
message: String,
#[arg(long)]
json: bool,
},
/// Interrupt the active provider turn and optionally replace its next instruction
Interrupt {
issue: String,
#[arg(long = "message")]
message: Option<String>,
#[arg(long)]
json: bool,
},
/// Read or wait for one durable command receipt
Receipt {
command_id: String,
#[arg(long, value_enum)]
until: Option<crate::ops::ChildReceiptUntil>,
#[arg(long, default_value = "30s")]
timeout: String,
#[arg(long)]
json: bool,
},
/// Confirm that this Task incorporated its current direction
Acknowledge {
issue: String,
#[arg(long)]
directive: u32,
#[arg(long)]
summary: String,
#[arg(long)]
json: bool,
},
/// Resolve a durable Task decision request
Decide {
issue: String,
decision_id: String,
choice: String,
#[arg(long)]
message: Option<String>,
#[arg(long)]
json: bool,
},
/// Ask the Task's Project Session to choose while preserving this Task Session
RequestDecision {
issue: String,
prompt: String,
#[arg(long = "option", required = true)]
options: Vec<String>,
#[arg(long)]
wait: bool,
#[arg(long, default_value = "30m")]
timeout: String,
#[arg(long)]
json: bool,
},
/// Wait without polling an LM
Wait {
issue: String,
#[arg(long, default_value = "terminal", value_parser = ["submitted", "terminal"])]
until: String,
#[arg(long)]
timeout: Option<String>,
#[arg(long)]
json: bool,
},
/// Resume the same Task Session, worktree, and provider history
Resume {
issue: String,
message: Option<String>,
#[arg(long)]
json: bool,
},
/// Attach read-write to the Task Session control terminal
Attach { issue: String },
/// Explicitly end a Task Session without merging
Abandon {
issue: String,
#[arg(long)]
reason: String,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand, Debug)]
pub enum PrCommand {
/// Show current branch's PR state
Status,
/// Create or update a PR
Open {
#[arg(short = 'm', long = "model", short_alias = 'M')]
model: Option<String>,
#[arg(long = "title")]
title: Option<String>,
#[arg(long = "body")]
body: Option<String>,
},
/// Prepare a PR to land: rebase, clear scratch, mark ready, and assign it
/// to you. Nothing merges until you click merge on GitHub.
Submit {
#[arg(long)]
strict: bool,
#[arg(short = 'c', long = "create-pr")]
create_pr: bool,
#[arg(short = 'w', long = "worktree")]
worktree: Option<String>,
#[arg(short = 'm', long = "message")]
message: Option<String>,
#[arg(long = "title")]
title: Option<String>,
#[arg(long = "body")]
body: Option<String>,
},
/// Land a PR hands-off: rebase, clear scratch, and arm auto-merge
Land {
#[arg(long)]
strict: bool,
#[arg(long)]
local: bool,
#[arg(short = 'c', long = "create-pr")]
create_pr: bool,
#[arg(short = 'w', long = "worktree")]
worktree: Option<String>,
#[arg(short = 'm', long = "message")]
message: Option<String>,
#[arg(long = "title")]
title: Option<String>,
#[arg(long = "body")]
body: Option<String>,
},
/// Abandon branch: close PR, remove worktree, delete branch
Abandon {
/// Branch to abandon (default: current)
branch: Option<String>,
#[arg(short = 'f', long)]
force: bool,
},
}
#[derive(Subcommand, Debug)]
pub enum CronCommand {
/// Install or replace a scheduled lf invocation
Add {
/// Wave name passed to `lf <flow> --wave <wave>`
#[arg(short = 'w', long = "wave")]
wave: String,
/// Flow or skill name to run
#[arg(long = "flow")]
flow: String,
/// Schedule expression. v0 supports `daily`.
#[arg(long = "schedule", default_value = "daily")]
schedule: String,
},
/// List installed loopflow cron jobs
List,
/// Uninstall a scheduled lf invocation
Remove {
/// Wave name passed to `lf <flow> --wave <wave>`
#[arg(short = 'w', long = "wave")]
wave: String,
/// Flow or skill name to remove
#[arg(long = "flow")]
flow: String,
},
}
#[derive(Subcommand, Debug)]
pub enum PmCommand {
/// Connect a wave to a Linear Initiative
Init {
/// Wave name (auto-detected if omitted)
wave: Option<String>,
/// Wave name (flag form; same as positional wave)
#[arg(short = 'w', long = "wave", conflicts_with_all = ["wave", "all"])]
wave_flag: Option<String>,
/// Initialize all waves under wave/
#[arg(long, conflicts_with_all = ["wave", "wave_flag"])]
all: bool,
},
/// Read the wave's local Project and task snapshot
Show {
/// Wave name (auto-detected if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// Linear Project slug
#[arg(short = 'p', long = "project")]
project: Option<String>,
/// Emit the task snapshot as JSON
#[arg(long)]
json: bool,
/// Force a refresh from Linear before reading
#[arg(long = "sync", conflicts_with = "no_sync")]
sync: bool,
/// Read the local cache only; never contact Linear
#[arg(long = "no-sync")]
no_sync: bool,
},
/// Show local PM status for linked waves
Status {
/// Wave name (all PM-enabled waves if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
},
/// Compare Linear with local wave bindings
Doctor,
/// Refresh the local PM snapshot from Linear
Sync {
/// Wave name (all linked waves if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// Compare without writing the SQLite snapshot
#[arg(long = "plan")]
plan: bool,
},
/// Rename the Linear Initiative backing a wave
Rename {
/// Wave name (auto-detected if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// Linear Initiative title
#[arg(long = "title")]
title: String,
},
/// Linear task operations
Task {
#[command(subcommand)]
cmd: PmTaskCommand,
},
/// Linear Project operations
Project {
#[command(subcommand)]
cmd: PmProjectCommand,
},
}
#[derive(Subcommand, Debug)]
pub enum PmProjectCommand {
/// Create a Linear Project in the wave's Initiative
Create {
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
#[arg(long = "title")]
title: String,
#[arg(long = "definition")]
definition: String,
/// Key result; repeat for each KR. Prefix with `[x] ` when it holds.
#[arg(long = "kr", required = true)]
krs: Vec<String>,
},
/// Replace a Linear Project's definition and KRs
Update {
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
#[arg(short = 'p', long = "project")]
project: String,
#[arg(long = "title")]
title: Option<String>,
#[arg(long = "definition")]
definition: String,
/// Key result; repeat for each KR. Prefix with `[x] ` when it holds.
#[arg(long = "kr", required = true)]
krs: Vec<String>,
},
/// Archive a Linear Project and refresh the wave snapshot
Archive {
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
#[arg(short = 'p', long = "project")]
project: String,
},
}
#[derive(Subcommand, Debug)]
pub enum PmTaskCommand {
/// Create a Linear task
Create {
/// Wave name (auto-detected if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// Linear Project slug
#[arg(short = 'p', long = "project")]
project: String,
/// Task title
#[arg(long = "title")]
title: String,
/// Task notes/description
#[arg(long = "notes")]
notes: Option<String>,
},
/// Update a Linear task
Update {
/// Existing task id to edit
#[arg(long = "id")]
id: String,
/// Wave name (auto-detected if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// Linear Project slug
#[arg(short = 'p', long = "project")]
project: Option<String>,
/// Task title
#[arg(long = "title")]
title: Option<String>,
/// Task notes/description
#[arg(long = "notes")]
notes: Option<String>,
},
/// Close a Linear task and optionally link the shipped PR
Done {
/// Existing task id to close
#[arg(long = "id")]
id: String,
/// Wave name (auto-detected if omitted)
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// PR URL to attach as a comment
#[arg(long = "pr")]
pr: Option<String>,
},
/// Move a task into a wave's Linear Project
Move {
/// Existing task id to move
#[arg(long = "id")]
id: String,
/// Destination wave
#[arg(short = 'w', long = "wave")]
wave: Option<String>,
/// Destination Linear Project slug
#[arg(short = 'p', long = "project")]
project: String,
},
}
#[derive(Subcommand, Debug)]
pub enum AuthCommand {
/// Show authentication status for local credentials
Status {
/// Provider name (optional)
provider: Option<String>,
},
/// Disconnect a provider from local lf credentials
Disconnect {
/// Provider name
provider: String,
},
/// Store an API key from the provider's environment variable
Configure {
/// Provider name
provider: String,
},
/// Start a provider auth flow explicitly
Connect {
/// Provider name
provider: String,
},
/// External: provider name (so `lf auth linear` works)
#[command(external_subcommand)]
External(Vec<String>),
}
#[derive(Subcommand, Debug)]
pub enum ReleaseCommand {
/// Run the full release workflow end-to-end
Run {
/// Version to release: patch|minor|major|X.Y.Z (default: patch)
version: Option<String>,
#[arg(short = 't', long = "target")]
target: Option<String>,
},
/// Check if PRs have merged since the last tag
Check {
#[arg(short = 't', long = "target")]
target: Option<String>,
},
/// Generate release notes for a version
Notes {
/// Version (e.g. 0.9.6)
version: String,
#[arg(long = "prev-tag")]
prev_tag: Option<String>,
#[arg(short = 't', long = "target")]
target: Option<String>,
},
/// Bump version in manifest files
Bump {
/// Version to bump to (e.g. 0.9.6)
version: String,
#[arg(short = 't', long = "target")]
target: Option<String>,
},
/// Create a git tag and push it
Tag {
/// Version to tag (e.g. 0.9.6)
version: String,
#[arg(short = 't', long = "target")]
target: Option<String>,
},
/// Check release workflow status
Status {
#[arg(short = 't', long = "target")]
target: Option<String>,
},
}
#[derive(Subcommand, Debug)]
pub enum WtCommand {
/// Create a low-level sibling worktree
Create {
/// Worktree name
name: String,
/// Print the placement plan without creating a worktree
#[arg(long)]
plan: bool,
},
/// Switch to a worktree by name, identity leaf, or full branch
Switch {
/// Worktree name or full branch name to switch to
name: String,
},
/// List worktrees
List {
#[arg(long)]
format: Option<String>,
#[arg(long)]
full: bool,
#[arg(long)]
sync: bool,
},
/// Remove worktrees whose branches have been merged
Prune {
/// Show what would be pruned without removing anything
#[arg(long)]
dry_run: bool,
/// Also prune fresh worktrees (no commits beyond main)
#[arg(long)]
include_fresh: bool,
},
/// Remove a worktree
#[command(alias = "rm")]
Remove {
/// Worktree name to remove
name: String,
#[arg(short = 'f', long = "force")]
force: bool,
},
/// Show CI status for current branch
Ci {
#[arg(short = 'w', long = "watch")]
watch: bool,
#[arg(short = 'l', long = "logs")]
logs: bool,
},
}
#[cfg(test)]
mod tests {
use super::*;
use clap::CommandFactory;
#[test]
fn pm_init_accepts_positional_wave() {
let cli = Cli::try_parse_from(["lf", "pm", "init", "pm"]).expect("parse");
let Some(Commands::Pm {
cmd:
PmCommand::Init {
wave,
wave_flag,
all,
},
}) = cli.command
else {
panic!("expected pm init command");
};
assert_eq!(wave.as_deref(), Some("pm"));
assert_eq!(wave_flag, None);
assert!(!all);
}
#[test]
fn task_run_accepts_linear_identifier_and_json() {
let cli = Cli::try_parse_from(["lf", "task", "run", "INF-123", "--json"])
.expect("parse task run");
let Some(Commands::Task {
cmd: TaskCommand::Run { issue, json, .. },
}) = cli.command
else {
panic!("expected task run command");
};
assert_eq!(issue, "INF-123");
assert!(json);
}
#[test]
fn task_workspace_commands_address_the_task_then_optional_file() {
let changes = Cli::try_parse_from(["lf", "task", "changes", "INF-123", "--json"])
.expect("parse task changes");
assert!(matches!(
changes.command,
Some(Commands::Task {
cmd: TaskCommand::Changes { issue, json: true }
}) if issue == "INF-123"
));
let diff =
Cli::try_parse_from(["lf", "task", "diff", "INF-123", "src/parser.rs", "--json"])
.expect("parse task diff");
assert!(matches!(
diff.command,
Some(Commands::Task {
cmd: TaskCommand::Diff {
issue,
path: Some(path),
json: true,
}
}) if issue == "INF-123" && path == "src/parser.rs"
));
let file =
Cli::try_parse_from(["lf", "task", "file", "INF-123", "src/parser.rs", "--json"])
.expect("parse task file");
assert!(matches!(
file.command,
Some(Commands::Task {
cmd: TaskCommand::File { issue, path, json: true }
}) if issue == "INF-123" && path == "src/parser.rs"
));
}
#[test]
fn task_interrupt_requires_explicit_message_flag() {
let cli = Cli::try_parse_from([
"lf",
"task",
"interrupt",
"INF-123",
"--message",
"take the smaller approach",
])
.expect("parse task interrupt");
let Some(Commands::Task {
cmd:
TaskCommand::Interrupt {
issue,
message,
json,
},
}) = cli.command
else {
panic!("expected task interrupt command");
};
assert_eq!(issue, "INF-123");
assert_eq!(message.as_deref(), Some("take the smaller approach"));
assert!(!json);
}
#[test]
fn task_receipt_and_decision_commands_parse_the_durable_ids() {
let receipt = Cli::try_parse_from([
"lf",
"task",
"receipt",
"cc_00000000000000000000000000000000",
"--until",
"incorporated",
"--timeout",
"30s",
"--json",
])
.expect("parse task receipt");
assert!(matches!(
receipt.command,
Some(Commands::Task {
cmd: TaskCommand::Receipt {
until: Some(crate::ops::ChildReceiptUntil::Incorporated),
timeout,
json: true,
..
}
}) if timeout == "30s"
));
let acknowledge = Cli::try_parse_from([
"lf",
"task",
"acknowledge",
"INF-123",
"--directive",
"2",
"--summary",
"parser work is now first",
])
.expect("parse task acknowledgement");
assert!(matches!(
acknowledge.command,
Some(Commands::Task {
cmd: TaskCommand::Acknowledge {
issue,
directive: 2,
..
}
}) if issue == "INF-123"
));
let decide = Cli::try_parse_from([
"lf",
"task",
"decide",
"INF-123",
"cd_00000000000000000000000000000000",
"revise",
"--message",
"cover the race",
"--json",
])
.expect("parse task decide");
assert!(matches!(
decide.command,
Some(Commands::Task {
cmd: TaskCommand::Decide {
issue,
choice,
json: true,
..
}
}) if issue == "INF-123" && choice == "revise"
));
}
#[test]
fn task_steering_verbs_are_distinct_and_support_json_receipts() {
let follow_up = Cli::try_parse_from([
"lf",
"task",
"follow-up",
"INF-123",
"audit retry callers",
"--json",
])
.expect("parse task follow-up");
let Some(Commands::Task {
cmd:
TaskCommand::FollowUp {
issue,
message,
json,
},
}) = follow_up.command
else {
panic!("expected task follow-up command");
};
assert_eq!(issue, "INF-123");
assert_eq!(message, "audit retry callers");
assert!(json);
let steer = Cli::try_parse_from([
"lf",
"task",
"steer",
"INF-123",
"take the smaller approach",
])
.expect("parse task steer");
let Some(Commands::Task {
cmd:
TaskCommand::Steer {
issue,
message,
json,
},
}) = steer.command
else {
panic!("expected task steer command");
};
assert_eq!(issue, "INF-123");
assert_eq!(message, "take the smaller approach");
assert!(!json);
}
#[test]
fn project_start_accepts_title_wave_and_json() {
let cli = Cli::try_parse_from([
"lf",
"project",
"start",
"Release stability",
"--wave",
"infrastructure",
"--json",
])
.expect("parse project start");
let Some(Commands::Project {
cmd: ProjectCommand::Start {
title, wave, json, ..
},
}) = cli.command
else {
panic!("expected project start command");
};
assert_eq!(title, "Release stability");
assert_eq!(wave.as_deref(), Some("infrastructure"));
assert!(json);
}
#[test]
fn project_session_controls_parse_durable_ids_and_waits() {
let steer = Cli::try_parse_from([
"lf",
"project",
"steer",
"project-uuid",
"prioritize the CLI path",
"--json",
])
.expect("parse project steer");
assert!(matches!(
steer.command,
Some(Commands::Project {
cmd: ProjectCommand::Steer {
project_id,
message,
json: true,
},
}) if project_id == "project-uuid" && message == "prioritize the CLI path"
));
let receipt = Cli::try_parse_from([
"lf",
"project",
"receipt",
"cc_00000000000000000000000000000000",
"--until",
"applied",
"--timeout",
"30s",
])
.expect("parse project receipt");
assert!(matches!(
receipt.command,
Some(Commands::Project {
cmd: ProjectCommand::Receipt {
command_id,
until: Some(crate::ops::ChildReceiptUntil::Applied),
timeout,
..
},
}) if command_id.starts_with("cc_") && timeout == "30s"
));
}
#[test]
fn retired_loop_and_stack_surfaces_are_not_first_class_commands() {
let loop_cli = Cli::try_parse_from(["lf", "loop", "infrastructure"])
.expect("unknown names remain eligible for skill discovery");
assert!(matches!(loop_cli.command, Some(Commands::External(_))));
assert!(Cli::try_parse_from(["lf", "wt", "create", "child", "--stack"]).is_err());
assert!(Cli::try_parse_from(["lf", "wt", "create", "child", "--child"]).is_err());
assert!(Cli::try_parse_from(["lf", "wt", "up"]).is_err());
assert!(Cli::try_parse_from(["lf", "wt", "down"]).is_err());
}
#[test]
fn rebase_manual_recovery_modes_are_explicit_and_exclusive() {
let manual = Cli::try_parse_from(["lf", "rebase", "--manual", "origin/main"])
.expect("parse manual rebase");
assert!(matches!(
manual.command,
Some(Commands::Rebase {
manual: true,
continue_rebase: false,
abort: false,
onto: Some(ref onto),
..
}) if onto == "origin/main"
));
assert!(Cli::try_parse_from(["lf", "rebase", "--continue", "--abort"]).is_err());
assert!(Cli::try_parse_from(["lf", "rebase", "--plan", "--manual"]).is_err());
}
#[test]
fn pm_init_accepts_all_flag() {
let cli = Cli::try_parse_from(["lf", "pm", "init", "--all"]).expect("parse");
let Some(Commands::Pm {
cmd:
PmCommand::Init {
wave,
wave_flag,
all,
},
}) = cli.command
else {
panic!("expected pm init command");
};
assert_eq!(wave, None);
assert_eq!(wave_flag, None);
assert!(all);
}
#[test]
fn pm_project_archive_accepts_wave_and_project() {
let cli = Cli::try_parse_from([
"lf",
"pm",
"project",
"archive",
"--wave",
"product",
"--project",
"wave-chat",
])
.expect("parse");
let Some(Commands::Pm {
cmd:
PmCommand::Project {
cmd: PmProjectCommand::Archive { wave, project },
},
}) = cli.command
else {
panic!("expected pm project archive command");
};
assert_eq!(wave.as_deref(), Some("product"));
assert_eq!(project, "wave-chat");
}
#[test]
fn pm_show_parses_refresh_modes() {
let cli = Cli::try_parse_from(["lf", "pm", "show", "--wave", "goals"]).expect("parse");
let Some(Commands::Pm {
cmd:
PmCommand::Show {
wave,
project,
json,
sync,
no_sync,
},
}) = cli.command
else {
panic!("expected pm show command");
};
assert_eq!(wave.as_deref(), Some("goals"));
assert_eq!(project, None);
assert!(!json);
assert!(!sync);
assert!(!no_sync);
let cli = Cli::try_parse_from(["lf", "pm", "show", "--sync"]).expect("force sync");
let Some(Commands::Pm {
cmd: PmCommand::Show { sync, no_sync, .. },
}) = cli.command
else {
panic!("expected pm show command");
};
assert!(sync);
assert!(!no_sync);
let cli = Cli::try_parse_from(["lf", "pm", "show", "--no-sync"]).expect("cache-only read");
let Some(Commands::Pm {
cmd: PmCommand::Show { sync, no_sync, .. },
}) = cli.command
else {
panic!("expected pm show command");
};
assert!(!sync);
assert!(no_sync);
assert!(Cli::try_parse_from(["lf", "pm", "show", "--sync", "--no-sync"]).is_err());
}
#[test]
fn chat_parses_text_and_targeting() {
let cli = Cli::try_parse_from(["lf", "chat", "shipped", "the", "parser"]).expect("parse");
let Some(Commands::Chat {
text,
follow,
steer,
target,
}) = cli.command
else {
panic!("expected chat command");
};
assert_eq!(text, vec!["shipped", "the", "parser"]);
assert!(!follow);
assert!(!steer);
assert_eq!(target.wave, None);
assert!(!target.parent);
// No text: stdin is the body. Flags come before the trailing text.
let cli = Cli::try_parse_from(["lf", "chat", "--parent"]).expect("parse");
let Some(Commands::Chat { text, target, .. }) = cli.command else {
panic!("expected chat command");
};
assert!(text.is_empty());
assert!(target.parent);
let cli = Cli::try_parse_from(["lf", "chat", "--wave", "goals", "hi"]).expect("parse");
let Some(Commands::Chat { text, target, .. }) = cli.command else {
panic!("expected chat command");
};
assert_eq!(text, vec!["hi"]);
assert_eq!(target.wave.as_deref(), Some("goals"));
// Machine speech does not ride this verb: bylines belong to the bus
// (`lf radio pub --from`), and chat refuses the flag at parse.
assert!(Cli::try_parse_from([
"lf",
"chat",
"--wave",
"goals",
"--from",
"ci",
"CI failed"
])
.is_err());
let cli =
Cli::try_parse_from(["lf", "chat", "--steer", "change course"]).expect("parse steer");
let Some(Commands::Chat { text, steer, .. }) = cli.command else {
panic!("expected chat command");
};
assert_eq!(text, vec!["change course"]);
assert!(steer);
assert!(
Cli::try_parse_from(["lf", "chat", "--steer", "--from", "ci", "change course"])
.is_err()
);
assert!(Cli::try_parse_from(["lf", "chat", "--steer", "--parent", "x"]).is_err());
// --wave and --parent are mutually exclusive.
assert!(Cli::try_parse_from(["lf", "chat", "--wave", "goals", "--parent", "x"]).is_err());
let cli = Cli::try_parse_from(["lf", "chat", "--follow", "--wave", "goals"])
.expect("parse follow");
let Some(Commands::Chat {
text,
follow,
steer,
target,
}) = cli.command
else {
panic!("expected chat command");
};
assert!(text.is_empty());
assert!(follow);
assert!(!steer);
assert_eq!(target.wave.as_deref(), Some("goals"));
assert!(Cli::try_parse_from(["lf", "chat", "--follow", "hello"]).is_err());
assert!(Cli::command().find_subcommand("wavechat").is_none());
}
#[test]
fn radio_pub_parses_channel_parent_and_byline() {
// `-c`/`--channel` addresses a hand's channel; text trails.
let cli = Cli::try_parse_from(["lf", "radio", "pub", "-c", "goals.148e", "landed PR"])
.expect("parse");
let Some(Commands::Radio {
command:
RadioCommand::Pub {
text,
channel,
parent,
from,
},
}) = cli.command
else {
panic!("expected radio pub command");
};
assert_eq!(text, vec!["landed PR"]);
assert_eq!(channel.as_deref(), Some("goals.148e"));
assert!(!parent);
assert_eq!(from, None);
// Escalation up the tree.
let cli = Cli::try_parse_from(["lf", "radio", "pub", "--parent", "blocked"])
.expect("parse parent");
let Some(Commands::Radio {
command: RadioCommand::Pub { parent, .. },
}) = cli.command
else {
panic!("expected radio pub command");
};
assert!(parent);
// A channel and the parent are mutually exclusive — a report goes to
// one place.
assert!(
Cli::try_parse_from(["lf", "radio", "pub", "-c", "goals.148e", "--parent", "x"])
.is_err()
);
}
#[test]
fn radio_sub_parses_channel_and_json() {
let cli = Cli::try_parse_from(["lf", "radio", "sub", "goals", "--json"]).expect("parse");
let Some(Commands::Radio {
command: RadioCommand::Sub { channel, json },
}) = cli.command
else {
panic!("expected radio sub command");
};
assert_eq!(channel.as_deref(), Some("goals"));
assert!(json);
}
#[test]
fn radio_requires_an_explicit_operation_and_rejects_old_forms() {
let error = Cli::try_parse_from(["lf", "radio"]).expect_err("bare radio shows help");
assert_eq!(
error.kind(),
clap::error::ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
);
assert!(Cli::try_parse_from(["lf", "radio", "worker done"]).is_err());
assert!(Cli::try_parse_from(["lf", "sub"]).is_err());
assert!(Cli::try_parse_from(["lf", "sub", "goals"]).is_err());
}
/// Steer is a thread op, and the thread is not the bus. The shared
/// dispatch once let `--steer` leak across the verb split; separate
/// transports make it unspellable.
#[test]
fn radio_has_no_steer_flag() {
assert!(Cli::try_parse_from(["lf", "radio", "pub", "--steer", "gate it"]).is_err());
}
#[test]
fn memory_parses_bare_show_update_and_add() {
let cli = Cli::try_parse_from(["lf", "memory", "--wave", "goals"]).expect("parse");
let Some(Commands::Memory { cmd, target }) = cli.command else {
panic!("expected memory command");
};
assert!(cmd.is_none(), "bare memory is show");
assert_eq!(target.wave.as_deref(), Some("goals"));
let cli =
Cli::try_parse_from(["lf", "memory", "update", "--summary", "learned"]).expect("parse");
let Some(Commands::Memory {
cmd: Some(MemoryCommand::Update { summary, .. }),
..
}) = cli.command
else {
panic!("expected memory update");
};
assert_eq!(summary.as_deref(), Some("learned"));
let cli =
Cli::try_parse_from(["lf", "memory", "add", "one fact", "--parent"]).expect("parse");
let Some(Commands::Memory {
cmd: Some(MemoryCommand::Add { fact, target }),
..
}) = cli.command
else {
panic!("expected memory add");
};
assert_eq!(fact, "one fact");
assert!(target.parent);
}
#[test]
fn pr_open_accepts_model_override() {
let cli = Cli::try_parse_from(["lf", "pr", "open", "-m", "codex"]).expect("parse");
let Some(Commands::Pr {
cmd: Some(PrCommand::Open { model, title, body }),
}) = cli.command
else {
panic!("expected pr command");
};
assert_eq!(model.as_deref(), Some("codex"));
assert_eq!(title, None);
assert_eq!(body, None);
}
#[test]
fn top_level_model_reaches_pr_open() {
let cli = Cli::try_parse_from(["lf", "-m", "codex", "pr", "open"]).expect("parse");
let Some(Commands::Pr {
cmd: Some(PrCommand::Open { model, title, body }),
}) = cli.command
else {
panic!("expected pr command");
};
assert_eq!(cli.model.as_deref(), Some("codex"));
assert_eq!(model, None);
assert_eq!(title, None);
assert_eq!(body, None);
}
}