laramux 1.3.0

A TUI application for managing Laravel development processes
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
use std::collections::HashMap;
use std::path::Path;
use std::process::{Command, Stdio};

use serde::Deserialize;

use crate::config::LaramuxConfig;
use crate::error::{LaraMuxError, Result};
use crate::process::types::{ProcessConfig, ProcessId, ProcessKind, ProcessRegistry};

/// A discovered quality tool (PHPStan, Pint, Rector, Pest, etc.)
#[derive(Debug, Clone)]
pub struct QualityTool {
    /// Display name (e.g., "PHPStan")
    pub display_name: String,
    /// Command to run (e.g., "./vendor/bin/phpstan")
    pub command: String,
    /// Default arguments
    pub args: Vec<String>,
}

/// Result of service discovery
pub struct DiscoveryResult {
    pub is_sail: bool,
    pub configs: Vec<ProcessConfig>,
    pub registry: ProcessRegistry,
    pub artisan_commands: Vec<FullArtisanCommand>,
    pub artisan_make_commands: Vec<FullArtisanCommand>,
    pub quality_tools: Vec<QualityTool>,
    pub testing_tools: Vec<QualityTool>,
    pub supervised_kinds: Vec<ProcessKind>,
}

/// Check if Laravel Herd is installed (macOS or Windows)
fn is_herd_installed() -> bool {
    #[cfg(target_os = "macos")]
    {
        // Check for Herd application
        let herd_app = Path::new("/Applications/Herd.app");
        if herd_app.exists() {
            return true;
        }

        // Check for Herd config directory
        if let Some(home) = std::env::var_os("HOME") {
            let herd_config = Path::new(&home).join("Library/Application Support/Herd");
            if herd_config.exists() {
                return true;
            }
        }

        false
    }

    #[cfg(target_os = "windows")]
    {
        // Check for Herd executable in common locations
        if let Some(local_app_data) = std::env::var_os("LOCALAPPDATA") {
            let herd_exe = Path::new(&local_app_data).join("Programs/Herd/Herd.exe");
            if herd_exe.exists() {
                return true;
            }
        }

        // Check for Herd config directory
        if let Some(app_data) = std::env::var_os("APPDATA") {
            let herd_config = Path::new(&app_data).join("Herd");
            if herd_config.exists() {
                return true;
            }
        }

        // Check if herd is in PATH
        if let Ok(output) = std::process::Command::new("where").arg("herd").output() {
            if output.status.success() {
                return true;
            }
        }

        false
    }

    #[cfg(not(any(target_os = "macos", target_os = "windows")))]
    {
        false
    }
}

/// Check if Laravel Sail is present and its Docker container is running
fn is_sail_project(working_dir: &Path) -> bool {
    if !working_dir.join("vendor/bin/sail").exists() {
        return false;
    }
    // Verify the Sail container is actually running
    let output = Command::new("docker")
        .args(["compose", "ps", "-q", "laravel.test"])
        .current_dir(working_dir)
        .stdin(Stdio::null())
        .stdout(Stdio::piped())
        .stderr(Stdio::null())
        .output();
    match output {
        Ok(o) if o.status.success() => {
            !o.stdout.is_empty() && !o.stdout.iter().all(|b| b.is_ascii_whitespace())
        }
        _ => false,
    }
}

/// Info about a supervised program parsed from the supervisor config
struct SupervisedProgram {
    /// The program name from [program:NAME]
    name: String,
    /// The stdout_logfile path (if it points to a real file, not /dev/stdout)
    log_file: Option<String>,
}

/// Detect services managed by supervisord inside the Sail container.
///
/// Sail's supervisord config typically lacks a [unix_http_server] section, so
/// `supervisorctl status` won't work. Instead we:
///   1. Read the supervisor config to find [program:X] sections
///   2. Map program names to ProcessKind via fuzzy match
///   3. Extract log file paths for per-program tailing
///
/// Returns a map of ProcessKind → SupervisedProgram for detected programs.
/// Programs are included if they are defined in the config, regardless of
/// whether they are currently running (supervisor manages their lifecycle).
fn detect_supervised_services(working_dir: &Path) -> HashMap<ProcessKind, SupervisedProgram> {
    let mut supervised = HashMap::new();

    // Read the supervisor config inside the container
    let config_output = Command::new("docker")
        .args([
            "compose",
            "exec",
            "-T",
            "laravel.test",
            "cat",
            "/etc/supervisor/conf.d/supervisord.conf",
        ])
        .current_dir(working_dir)
        .stdin(Stdio::null())
        .stdout(Stdio::piped())
        .stderr(Stdio::null())
        .output();

    let config_text = match config_output {
        Ok(output) if output.status.success() => String::from_utf8(output.stdout).ok(),
        _ => None,
    };

    let Some(config_text) = config_text else {
        return supervised;
    };

    // Parse config: extract [program:NAME] sections with their stdout_logfile
    let mut current_kind: Option<(ProcessKind, String)> = None;
    let mut current_log: Option<String> = None;

    let map_name_to_kind = |name: &str| -> Option<ProcessKind> {
        let lower = name.to_lowercase();
        if lower.contains("horizon") {
            Some(ProcessKind::Horizon)
        } else if lower.contains("reverb") {
            Some(ProcessKind::Reverb)
        } else if lower.contains("worker") || lower.contains("queue") {
            Some(ProcessKind::Queue)
        } else if lower.contains("vite") {
            Some(ProcessKind::Vite)
        } else {
            None
        }
    };

    // Helper to flush the current section
    let flush = |kind: &mut Option<(ProcessKind, String)>,
                 log: &mut Option<String>,
                 map: &mut HashMap<ProcessKind, SupervisedProgram>| {
        if let Some((k, name)) = kind.take() {
            map.insert(
                k,
                SupervisedProgram {
                    name,
                    log_file: log.take(),
                },
            );
        }
        *log = None;
    };

    for line in config_text.lines() {
        let trimmed = line.trim();

        // New section header
        if trimmed.starts_with('[') && trimmed.ends_with(']') {
            // Flush previous section
            flush(&mut current_kind, &mut current_log, &mut supervised);

            // Check if this is a [program:NAME] we care about
            if trimmed.starts_with("[program:") {
                let name = &trimmed[9..trimmed.len() - 1];
                if let Some(kind) = map_name_to_kind(name) {
                    current_kind = Some((kind, name.to_string()));
                }
            }
            continue;
        }

        // Parse stdout_logfile within a matched section
        if current_kind.is_some() && trimmed.starts_with("stdout_logfile=") {
            let path = trimmed.trim_start_matches("stdout_logfile=").trim();
            // Only use real file paths, not /dev/stdout
            if !path.starts_with("/dev/") && path.starts_with('/') {
                current_log = Some(path.to_string());
            }
        }
    }
    // Flush last section
    flush(&mut current_kind, &mut current_log, &mut supervised);

    // If any programs log to /dev/stdout (no per-program log file), automatically
    // set up per-program log files inside the container
    let needs_setup: Vec<String> = supervised
        .iter()
        .filter(|(_, info)| info.log_file.is_none())
        .map(|(_, info)| info.name.clone())
        .collect();

    if !needs_setup.is_empty() && setup_supervised_log_files(working_dir, &needs_setup) {
        for info in supervised.values_mut() {
            if info.log_file.is_none() {
                info.log_file = Some(format!("/var/log/supervisor/{}.log", info.name));
            }
        }
    }

    supervised
}

/// Set up per-program log files for supervised services that log to /dev/stdout.
///
/// Modifies the supervisor config inside the running container to redirect each
/// program's output to individual log files under /var/log/supervisor/, then
/// reloads supervisor via SIGHUP. Targeted programs will briefly restart.
///
/// Uses a marker file to avoid re-running on subsequent laramux starts within
/// the same container lifetime.
fn setup_supervised_log_files(working_dir: &Path, program_names: &[String]) -> bool {
    if program_names.is_empty() {
        return true;
    }

    let targets = program_names.join(",");
    let touch_files: String = program_names
        .iter()
        .map(|n| format!("/var/log/supervisor/{}.log", n))
        .collect::<Vec<_>>()
        .join(" ");

    let script = format!(
        r#"MARKER="/tmp/.laramux-logging-setup"
[ -f "$MARKER" ] && exit 0
mkdir -p /var/log/supervisor
touch {touch_files}
CONFIG="/etc/supervisor/conf.d/supervisord.conf"
grep -q "stdout_logfile=/dev/stdout" "$CONFIG" 2>/dev/null || {{ touch "$MARKER"; exit 0; }}
awk -v targets="{targets}" '
BEGIN {{ split(targets, t, ","); for (i in t) target[t[i]] = 1 }}
/^\[program:/ {{
    prog = $0; sub(/^\[program:/, "", prog); sub(/\].*/, "", prog)
    is_target = (prog in target)
}}
/^\[/ && !/^\[program:/ {{ is_target = 0 }}
is_target && /^stdout_logfile=\/dev\/stdout/ {{
    print "stdout_logfile=/var/log/supervisor/" prog ".log"
    print "stdout_logfile_maxbytes=10MB"
    next
}}
is_target && /^stderr_logfile=\/dev\/stderr/ {{
    print "stderr_logfile=/var/log/supervisor/" prog ".log"
    print "stderr_logfile_maxbytes=0"
    next
}}
is_target && /^stdout_logfile_maxbytes=/ {{ next }}
is_target && /^stderr_logfile_maxbytes=/ {{ next }}
{{ print }}
' "$CONFIG" > "${{CONFIG}}.tmp" && mv "${{CONFIG}}.tmp" "$CONFIG"
kill -HUP 1
sleep 1
touch "$MARKER""#
    );

    let output = Command::new("docker")
        .args([
            "compose",
            "exec",
            "-T",
            "laravel.test",
            "bash",
            "-c",
            &script,
        ])
        .current_dir(working_dir)
        .stdin(Stdio::null())
        .stdout(Stdio::piped())
        .stderr(Stdio::null())
        .output();

    matches!(output, Ok(ref o) if o.status.success())
}

#[derive(Debug, Deserialize)]
struct ComposerJson {
    require: Option<std::collections::HashMap<String, String>>,
    #[serde(rename = "require-dev")]
    require_dev: Option<std::collections::HashMap<String, String>>,
}

#[derive(Debug, Deserialize)]
struct PackageJson {
    scripts: Option<std::collections::HashMap<String, String>>,
    #[serde(rename = "devDependencies")]
    dev_dependencies: Option<std::collections::HashMap<String, String>>,
    dependencies: Option<std::collections::HashMap<String, String>>,
}

/// Helper to apply config overrides to a ProcessConfig
fn apply_overrides(
    mut config: ProcessConfig,
    kind: ProcessKind,
    laramux_config: Option<&LaramuxConfig>,
    working_dir: &Path,
) -> ProcessConfig {
    if let Some(cfg) = laramux_config {
        if let Some(override_cfg) = cfg.get_override(kind.config_name()) {
            if let Some(ref cmd) = override_cfg.command {
                config.command = cmd.clone();
            }
            if let Some(ref args) = override_cfg.args {
                config.args = args.clone();
            }
            if let Some(ref wd) = override_cfg.working_dir {
                config.working_dir = working_dir.join(wd);
            }
            if let Some(ref env) = override_cfg.env {
                config.env = env.clone();
            }
            if let Some(restart_policy) = override_cfg.restart_policy {
                config.restart_policy = restart_policy;
            }
        }
    }
    config
}

/// Discover available Laravel services in the project
pub fn discover_services(
    working_dir: &Path,
    config: Option<&LaramuxConfig>,
) -> Result<DiscoveryResult> {
    let mut configs = Vec::new();
    let mut registry = ProcessRegistry::new();

    // Detect Laravel Sail (project-level, takes precedence over Herd)
    let is_sail = match config.and_then(|c| c.sail) {
        Some(forced) => forced,
        None => is_sail_project(working_dir),
    };

    // Check for Laravel (composer.json)
    let composer_path = working_dir.join("composer.json");
    if !composer_path.exists() {
        return Err(LaraMuxError::FileNotFound(
            "composer.json not found. Is this a Laravel project?".to_string(),
        ));
    }

    let composer_content = std::fs::read_to_string(&composer_path)?;
    let composer: ComposerJson = serde_json::from_str(&composer_content)?;

    // Check for Laravel framework
    let has_laravel = composer
        .require
        .as_ref()
        .map(|r| r.contains_key("laravel/framework"))
        .unwrap_or(false);

    if !has_laravel {
        return Err(LaraMuxError::Config(
            "Not a Laravel project (laravel/framework not found in composer.json)".to_string(),
        ));
    }

    // Helper to check if a process is disabled
    let is_disabled = |name: &str| config.map(|c| c.is_disabled(name)).unwrap_or(false);

    // Detect supervised services running inside the Sail container
    let supervised_map = if is_sail {
        detect_supervised_services(working_dir)
    } else {
        HashMap::new()
    };
    let mut supervised_kinds: Vec<ProcessKind> = Vec::new();

    // Helper to create a supervised ProcessConfig that tails the program's log file
    let supervised_config =
        |kind: ProcessKind, info: &SupervisedProgram, working_dir: &Path| -> ProcessConfig {
            let (cmd, args) = if let Some(ref log_file) = info.log_file {
                // Tail the per-program log file inside the container
                (
                    "docker",
                    vec![
                        "compose".to_string(),
                        "exec".to_string(),
                        "-T".to_string(),
                        "laravel.test".to_string(),
                        "tail".to_string(),
                        "-f".to_string(),
                        "-n".to_string(),
                        "100".to_string(),
                        log_file.clone(),
                    ],
                )
            } else {
                // Fallback: tail combined container logs
                (
                    "docker",
                    vec![
                        "compose".to_string(),
                        "logs".to_string(),
                        "-f".to_string(),
                        "--tail".to_string(),
                        "100".to_string(),
                        "--no-log-prefix".to_string(),
                        "laravel.test".to_string(),
                    ],
                )
            };
            ProcessConfig::new(kind, cmd, working_dir.to_path_buf())
                .with_args(args)
                .with_supervised(info.name.clone())
        };

    // Add artisan serve (unless Sail handles it, Herd is installed, or disabled)
    // Sail manages its own web server via Docker, so serve is not needed.
    if !is_sail && !is_herd_installed() && !is_disabled("serve") {
        let serve_config = ProcessConfig::new(ProcessKind::Serve, "php", working_dir.to_path_buf())
            .with_args(vec!["artisan".to_string(), "serve".to_string()]);
        configs.push(apply_overrides(
            serve_config,
            ProcessKind::Serve,
            config,
            working_dir,
        ));
    }

    // Check for Laravel Horizon (advanced queue dashboard)
    let has_horizon = composer
        .require
        .as_ref()
        .map(|r| r.contains_key("laravel/horizon"))
        .unwrap_or(false)
        || composer
            .require_dev
            .as_ref()
            .map(|r| r.contains_key("laravel/horizon"))
            .unwrap_or(false);

    // Use Horizon if installed, otherwise fall back to basic queue:work
    if has_horizon && !is_disabled("horizon") {
        if let Some(info) = supervised_map.get(&ProcessKind::Horizon) {
            configs.push(supervised_config(ProcessKind::Horizon, info, working_dir));
            supervised_kinds.push(ProcessKind::Horizon);
        } else {
            let (cmd, args) = if is_sail {
                (
                    "./vendor/bin/sail",
                    vec!["artisan".to_string(), "horizon".to_string()],
                )
            } else {
                ("php", vec!["artisan".to_string(), "horizon".to_string()])
            };
            let horizon_config =
                ProcessConfig::new(ProcessKind::Horizon, cmd, working_dir.to_path_buf())
                    .with_args(args);
            configs.push(apply_overrides(
                horizon_config,
                ProcessKind::Horizon,
                config,
                working_dir,
            ));
        }
    } else if !is_disabled("queue") {
        if let Some(info) = supervised_map.get(&ProcessKind::Queue) {
            configs.push(supervised_config(ProcessKind::Queue, info, working_dir));
            supervised_kinds.push(ProcessKind::Queue);
        } else {
            let (cmd, args) = if is_sail {
                (
                    "./vendor/bin/sail",
                    vec![
                        "artisan".to_string(),
                        "queue:work".to_string(),
                        "--tries=3".to_string(),
                    ],
                )
            } else {
                (
                    "php",
                    vec![
                        "artisan".to_string(),
                        "queue:work".to_string(),
                        "--tries=3".to_string(),
                    ],
                )
            };
            let queue_config =
                ProcessConfig::new(ProcessKind::Queue, cmd, working_dir.to_path_buf())
                    .with_args(args);
            configs.push(apply_overrides(
                queue_config,
                ProcessKind::Queue,
                config,
                working_dir,
            ));
        }
    }

    // Check for Reverb (Laravel Reverb websocket server)
    let has_reverb = composer
        .require
        .as_ref()
        .map(|r| r.contains_key("laravel/reverb"))
        .unwrap_or(false)
        || composer
            .require_dev
            .as_ref()
            .map(|r| r.contains_key("laravel/reverb"))
            .unwrap_or(false);

    if has_reverb && !is_disabled("reverb") {
        if let Some(info) = supervised_map.get(&ProcessKind::Reverb) {
            configs.push(supervised_config(ProcessKind::Reverb, info, working_dir));
            supervised_kinds.push(ProcessKind::Reverb);
        } else {
            let (cmd, args) = if is_sail {
                (
                    "./vendor/bin/sail",
                    vec!["artisan".to_string(), "reverb:start".to_string()],
                )
            } else {
                (
                    "php",
                    vec!["artisan".to_string(), "reverb:start".to_string()],
                )
            };
            let reverb_config =
                ProcessConfig::new(ProcessKind::Reverb, cmd, working_dir.to_path_buf())
                    .with_args(args);
            configs.push(apply_overrides(
                reverb_config,
                ProcessKind::Reverb,
                config,
                working_dir,
            ));
        }
    }

    // Check for Vite (package.json)
    let package_path = working_dir.join("package.json");
    if package_path.exists() && !is_disabled("vite") {
        let package_content = std::fs::read_to_string(&package_path)?;
        let package: PackageJson = serde_json::from_str(&package_content)?;

        let has_vite = package
            .dev_dependencies
            .as_ref()
            .map(|d| d.contains_key("vite") || d.contains_key("laravel-vite-plugin"))
            .unwrap_or(false)
            || package
                .dependencies
                .as_ref()
                .map(|d| d.contains_key("vite"))
                .unwrap_or(false);

        let has_dev_script = package
            .scripts
            .as_ref()
            .map(|s| s.contains_key("dev"))
            .unwrap_or(false);

        if has_vite && has_dev_script {
            if let Some(program) = supervised_map.get(&ProcessKind::Vite) {
                configs.push(supervised_config(ProcessKind::Vite, program, working_dir));
                supervised_kinds.push(ProcessKind::Vite);
            } else {
                // Detect package manager
                let pkg_manager = detect_package_manager(working_dir);

                let (cmd, args) = if is_sail {
                    let sail_args = if pkg_manager == "yarn" {
                        vec![pkg_manager.clone(), "dev".to_string()]
                    } else {
                        vec![pkg_manager.clone(), "run".to_string(), "dev".to_string()]
                    };
                    ("./vendor/bin/sail".to_string(), sail_args)
                } else if pkg_manager == "yarn" {
                    (pkg_manager, vec!["dev".to_string()])
                } else {
                    (pkg_manager, vec!["run".to_string(), "dev".to_string()])
                };

                let vite_config =
                    ProcessConfig::new(ProcessKind::Vite, &cmd, working_dir.to_path_buf())
                        .with_args(args);
                configs.push(apply_overrides(
                    vite_config,
                    ProcessKind::Vite,
                    config,
                    working_dir,
                ));
            }
        }
    }

    // Add custom processes from config
    if let Some(cfg) = config {
        for custom in cfg.enabled_custom_processes() {
            let custom_working_dir = custom
                .working_dir
                .as_ref()
                .map(|wd| working_dir.join(wd))
                .unwrap_or_else(|| working_dir.to_path_buf());

            let mut custom_config = ProcessConfig::new(
                ProcessId::custom(custom.name.clone()),
                custom.command.clone(),
                custom_working_dir,
            )
            .with_args(custom.args.clone());

            if let Some(ref env) = custom.env {
                custom_config = custom_config.with_env(env.clone());
            }
            if let Some(restart_policy) = custom.restart_policy {
                custom_config = custom_config.with_restart_policy(restart_policy);
            }

            configs.push(custom_config);

            // Register custom process metadata
            registry.register_custom(
                custom.name.clone(),
                custom.display_name.clone(),
                custom.hotkey,
            );
        }
    }

    // Discover all artisan commands
    let artisan_commands = discover_all_artisan_commands(working_dir, is_sail);

    // Discover artisan make commands
    let artisan_make_commands = discover_artisan_make_commands(working_dir, is_sail);

    // Load package.json if it exists
    let package_path = working_dir.join("package.json");
    let package: Option<PackageJson> = if package_path.exists() {
        std::fs::read_to_string(&package_path)
            .ok()
            .and_then(|content| serde_json::from_str(&content).ok())
    } else {
        None
    };

    // Detect package manager
    let package_manager = detect_package_manager(working_dir);

    // Discover quality and testing tools from composer.json and package.json
    let (mut quality_tools, mut testing_tools) =
        discover_dev_tools(&composer, package.as_ref(), &package_manager, is_sail);

    // Apply quality config: filter disabled tools, merge default args, add custom tools
    if let Some(cfg) = config {
        // Filter out disabled tools
        quality_tools.retain(|tool| !cfg.is_tool_disabled(&tool.display_name));
        testing_tools.retain(|tool| !cfg.is_tool_disabled(&tool.display_name));

        // Merge default args into tools
        for tool in quality_tools.iter_mut().chain(testing_tools.iter_mut()) {
            if let Some(extra_args) = cfg.tool_default_args(&tool.display_name.to_lowercase()) {
                tool.args.extend(extra_args.iter().cloned());
            }
        }

        // Add custom quality tools
        for custom_tool in cfg.custom_quality_tools() {
            quality_tools.push(QualityTool {
                display_name: custom_tool.display_name.clone(),
                command: custom_tool.command.clone(),
                args: custom_tool.args.clone(),
            });
        }

        // Add custom testing tools
        for custom_tool in cfg.custom_testing_tools() {
            testing_tools.push(QualityTool {
                display_name: custom_tool.display_name.clone(),
                command: custom_tool.command.clone(),
                args: custom_tool.args.clone(),
            });
        }
    }

    Ok(DiscoveryResult {
        is_sail,
        configs,
        registry,
        artisan_commands,
        artisan_make_commands,
        quality_tools,
        testing_tools,
        supervised_kinds,
    })
}

/// Detect the package manager used in the project
fn detect_package_manager(working_dir: &Path) -> String {
    let bun_lock = working_dir.join("bun.lockb");
    let pnpm_lock = working_dir.join("pnpm-lock.yaml");
    let yarn_lock = working_dir.join("yarn.lock");

    if bun_lock.exists() {
        "bun".to_string()
    } else if pnpm_lock.exists() {
        "pnpm".to_string()
    } else if yarn_lock.exists() {
        "yarn".to_string()
    } else {
        "npm".to_string()
    }
}

/// Discover development tools from composer.json and package.json
fn discover_dev_tools(
    composer: &ComposerJson,
    package: Option<&PackageJson>,
    package_manager: &str,
    is_sail: bool,
) -> (Vec<QualityTool>, Vec<QualityTool>) {
    let mut quality_tools = Vec::new();
    let mut testing_tools = Vec::new();

    // Combine require and require-dev for checking
    let all_deps: std::collections::HashSet<&str> = composer
        .require
        .as_ref()
        .map(|r| r.keys().map(|s| s.as_str()).collect::<Vec<_>>())
        .unwrap_or_default()
        .into_iter()
        .chain(
            composer
                .require_dev
                .as_ref()
                .map(|r| r.keys().map(|s| s.as_str()).collect::<Vec<_>>())
                .unwrap_or_default(),
        )
        .collect();

    // Helper to create a PHP vendor tool, wrapping with Sail if needed
    let php_tool = |display_name: &str, bin: &str, args: Vec<String>| -> QualityTool {
        if is_sail {
            let mut sail_args = vec!["php".to_string(), bin.to_string()];
            sail_args.extend(args);
            QualityTool {
                display_name: display_name.to_string(),
                command: "./vendor/bin/sail".to_string(),
                args: sail_args,
            }
        } else {
            QualityTool {
                display_name: display_name.to_string(),
                command: bin.to_string(),
                args,
            }
        }
    };

    // PHP Quality tools
    if all_deps.contains("phpstan/phpstan") || all_deps.contains("larastan/larastan") {
        quality_tools.push(php_tool(
            "PHPStan",
            "./vendor/bin/phpstan",
            vec!["analyse".to_string(), "--ansi".to_string()],
        ));
    }

    if all_deps.contains("laravel/pint") {
        quality_tools.push(php_tool(
            "Pint",
            "./vendor/bin/pint",
            vec!["--ansi".to_string()],
        ));
    }

    if all_deps.contains("friendsofphp/php-cs-fixer") {
        quality_tools.push(php_tool(
            "PHP CS Fixer",
            "./vendor/bin/php-cs-fixer",
            vec!["fix".to_string(), "--ansi".to_string()],
        ));
    }

    if all_deps.contains("rector/rector") || all_deps.contains("rectorphp/rector") {
        quality_tools.push(php_tool(
            "Rector",
            "./vendor/bin/rector",
            vec!["--ansi".to_string()],
        ));
    }

    if all_deps.contains("squizlabs/php_codesniffer") {
        quality_tools.push(php_tool(
            "PHP_CodeSniffer",
            "./vendor/bin/phpcs",
            vec!["--colors".to_string()],
        ));
    }

    if all_deps.contains("vimeo/psalm") {
        quality_tools.push(php_tool(
            "Psalm",
            "./vendor/bin/psalm",
            vec!["--output-format=console".to_string()],
        ));
    }

    // Helper to create a JS script tool, wrapping with Sail if needed
    let js_tool = |display_name: &str, script_name: &str| -> QualityTool {
        if is_sail {
            let mut sail_args = vec![package_manager.to_string()];
            if package_manager != "yarn" {
                sail_args.push("run".to_string());
            }
            sail_args.push(script_name.to_string());
            QualityTool {
                display_name: display_name.to_string(),
                command: "./vendor/bin/sail".to_string(),
                args: sail_args,
            }
        } else {
            let args = if package_manager == "yarn" {
                vec![script_name.to_string()]
            } else {
                vec!["run".to_string(), script_name.to_string()]
            };
            QualityTool {
                display_name: display_name.to_string(),
                command: package_manager.to_string(),
                args,
            }
        }
    };

    // NPM/PNPM/Yarn/Bun scripts from package.json
    if let Some(pkg) = package {
        if let Some(scripts) = &pkg.scripts {
            // Common quality tool script names
            let quality_scripts = [
                ("lint", "Lint"),
                ("lint:fix", "Lint Fix"),
                ("format", "Format"),
                ("format:check", "Format Check"),
                ("types", "Type Check"),
                ("typecheck", "Type Check"),
                ("type-check", "Type Check"),
                ("check", "Check"),
            ];

            for (script_name, display_name) in quality_scripts {
                if scripts.contains_key(script_name) {
                    quality_tools.push(js_tool(display_name, script_name));
                }
            }

            // Testing scripts from package.json
            let test_scripts = [
                ("test", "JS Test"),
                ("test:unit", "JS Unit Test"),
                ("test:e2e", "JS E2E Test"),
                ("test:coverage", "JS Test Coverage"),
            ];

            for (script_name, display_name) in test_scripts {
                if scripts.contains_key(script_name) {
                    testing_tools.push(js_tool(display_name, script_name));
                }
            }
        }
    }

    // PHP Testing tools
    if all_deps.contains("pestphp/pest") {
        testing_tools.push(php_tool(
            "Pest",
            "./vendor/bin/pest",
            vec!["--colors=always".to_string()],
        ));
        testing_tools.push(php_tool(
            "Pest Coverage",
            "./vendor/bin/pest",
            vec!["--coverage".to_string(), "--colors=always".to_string()],
        ));
    } else if all_deps.contains("phpunit/phpunit") {
        testing_tools.push(php_tool(
            "PHPUnit",
            "./vendor/bin/phpunit",
            vec!["--colors=always".to_string()],
        ));
    }

    // Laravel's artisan test is always available
    if is_sail {
        testing_tools.push(QualityTool {
            display_name: "Artisan Test".to_string(),
            command: "./vendor/bin/sail".to_string(),
            args: vec![
                "artisan".to_string(),
                "test".to_string(),
                "--ansi".to_string(),
            ],
        });
    } else {
        testing_tools.push(QualityTool {
            display_name: "Artisan Test".to_string(),
            command: "php".to_string(),
            args: vec![
                "artisan".to_string(),
                "test".to_string(),
                "--ansi".to_string(),
            ],
        });
    }

    if all_deps.contains("brianium/paratest") {
        testing_tools.push(php_tool(
            "Paratest",
            "./vendor/bin/paratest",
            vec!["--colors".to_string()],
        ));
    }

    (quality_tools, testing_tools)
}

/// JSON structure for artisan list output
#[derive(Debug, Deserialize)]
struct ArtisanListOutput {
    commands: Vec<ArtisanListCommand>,
}

#[derive(Debug, Deserialize)]
struct ArtisanListCommand {
    name: String,
    description: String,
    #[serde(default)]
    definition: Option<ArtisanCommandDefinition>,
}

#[derive(Debug, Deserialize, Clone)]
struct ArtisanCommandDefinition {
    #[serde(default, deserialize_with = "deserialize_map_or_empty")]
    arguments: std::collections::HashMap<String, ArtisanArgument>,
    #[serde(default, deserialize_with = "deserialize_map_or_empty")]
    options: std::collections::HashMap<String, ArtisanOption>,
}

/// Deserialize a field that can be either a map or an empty array
fn deserialize_map_or_empty<'de, D, V>(
    deserializer: D,
) -> std::result::Result<std::collections::HashMap<String, V>, D::Error>
where
    D: serde::Deserializer<'de>,
    V: serde::Deserialize<'de>,
{
    use serde::de::{self, MapAccess, SeqAccess, Visitor};
    use std::collections::HashMap;
    use std::fmt;
    use std::marker::PhantomData;

    struct MapOrEmptyArrayVisitor<V>(PhantomData<V>);

    impl<'de, V> Visitor<'de> for MapOrEmptyArrayVisitor<V>
    where
        V: serde::Deserialize<'de>,
    {
        type Value = HashMap<String, V>;

        fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
            formatter.write_str("a map or an empty array")
        }

        fn visit_seq<A>(self, mut seq: A) -> std::result::Result<Self::Value, A::Error>
        where
            A: SeqAccess<'de>,
        {
            // Check if the sequence is empty; if not, it's an error
            if seq.next_element::<serde::de::IgnoredAny>()?.is_some() {
                return Err(de::Error::custom("expected empty array or map"));
            }
            Ok(HashMap::new())
        }

        fn visit_map<M>(self, mut map: M) -> std::result::Result<Self::Value, M::Error>
        where
            M: MapAccess<'de>,
        {
            let mut result = HashMap::new();
            while let Some((key, value)) = map.next_entry()? {
                result.insert(key, value);
            }
            Ok(result)
        }
    }

    deserializer.deserialize_any(MapOrEmptyArrayVisitor(PhantomData))
}

#[derive(Debug, Deserialize, Clone)]
struct ArtisanArgument {
    name: String,
    #[serde(default)]
    is_required: bool,
    #[serde(default)]
    description: String,
}

#[derive(Debug, Deserialize, Clone)]
struct ArtisanOption {
    name: String,
    #[serde(default)]
    shortcut: String,
    #[serde(default)]
    description: String,
    #[serde(default)]
    #[allow(dead_code)]
    accept_value: bool,
}

/// A full artisan command with its arguments and options
#[derive(Debug, Clone)]
pub struct FullArtisanCommand {
    /// The full command name (e.g., "optimize:clear")
    pub name: String,
    /// Description of what the command does
    pub description: String,
    /// Required and optional arguments: (name, is_required, description)
    pub arguments: Vec<(String, bool, String)>,
    /// Available options/flags: (name, shortcut, description)
    pub options: Vec<(String, String, String)>,
}

/// Discover available artisan make:* commands with full details
fn discover_artisan_make_commands(working_dir: &Path, is_sail: bool) -> Vec<FullArtisanCommand> {
    // Run php artisan list make --format=json (or via Sail)
    let output = if is_sail {
        Command::new("./vendor/bin/sail")
            .args(["artisan", "list", "make", "--format=json"])
            .current_dir(working_dir)
            .stdin(Stdio::null())
            .output()
    } else {
        Command::new("php")
            .args(["artisan", "list", "make", "--format=json"])
            .current_dir(working_dir)
            .stdin(Stdio::null())
            .output()
    };

    let output = match output {
        Ok(o) if o.status.success() => o,
        Ok(o) => {
            eprintln!(
                "[discovery] artisan list make failed: {}",
                String::from_utf8_lossy(&o.stderr)
            );
            return default_make_commands();
        }
        Err(e) => {
            eprintln!("[discovery] failed to run artisan for make commands: {}", e);
            return default_make_commands();
        }
    };

    let json_str = match String::from_utf8(output.stdout) {
        Ok(s) => s,
        Err(e) => {
            eprintln!("[discovery] invalid UTF-8 in artisan make output: {}", e);
            return default_make_commands();
        }
    };

    let parsed: ArtisanListOutput = match serde_json::from_str(&json_str) {
        Ok(p) => p,
        Err(e) => {
            eprintln!("[discovery] failed to parse artisan make JSON: {}", e);
            eprintln!("[discovery] JSON snippet: {:.500}", json_str);
            return default_make_commands();
        }
    };

    let mut commands: Vec<FullArtisanCommand> = parsed
        .commands
        .into_iter()
        .filter(|cmd| cmd.name.starts_with("make:"))
        .map(|cmd| {
            let arguments = cmd
                .definition
                .as_ref()
                .map(|def| {
                    let mut args: Vec<_> = def
                        .arguments
                        .values()
                        .filter(|arg| arg.name != "command") // Skip the command argument itself
                        .map(|arg| (arg.name.clone(), arg.is_required, arg.description.clone()))
                        .collect();
                    args.sort_by(|a, b| a.0.cmp(&b.0));
                    args
                })
                .unwrap_or_default();

            let options = cmd
                .definition
                .as_ref()
                .map(|def| {
                    let mut opts: Vec<_> = def
                        .options
                        .values()
                        .filter(|opt| {
                            // Skip common global options (name includes -- prefix)
                            !matches!(
                                opt.name.as_str(),
                                "--help"
                                    | "--quiet"
                                    | "--silent"
                                    | "--verbose"
                                    | "--version"
                                    | "--ansi"
                                    | "--no-ansi"
                                    | "--no-interaction"
                                    | "--env"
                            )
                        })
                        .map(|opt| {
                            (
                                opt.name.clone(),
                                opt.shortcut.clone(),
                                opt.description.clone(),
                            )
                        })
                        .collect();
                    opts.sort_by(|a, b| a.0.cmp(&b.0));
                    opts
                })
                .unwrap_or_default();

            FullArtisanCommand {
                name: cmd.name,
                description: cmd.description,
                arguments,
                options,
            }
        })
        .collect();

    // Sort alphabetically by name
    commands.sort_by(|a, b| a.name.cmp(&b.name));

    if commands.is_empty() {
        default_make_commands()
    } else {
        commands
    }
}

/// Discover all artisan commands (excluding make:* which are handled separately)
fn discover_all_artisan_commands(working_dir: &Path, is_sail: bool) -> Vec<FullArtisanCommand> {
    // Run php artisan list --format=json (or via Sail)
    let output = if is_sail {
        Command::new("./vendor/bin/sail")
            .args(["artisan", "list", "--format=json"])
            .current_dir(working_dir)
            .stdin(Stdio::null())
            .output()
    } else {
        Command::new("php")
            .args(["artisan", "list", "--format=json"])
            .current_dir(working_dir)
            .stdin(Stdio::null())
            .output()
    };

    let output = match output {
        Ok(o) if o.status.success() => o,
        Ok(o) => {
            eprintln!(
                "[discovery] artisan list failed: {}",
                String::from_utf8_lossy(&o.stderr)
            );
            return default_artisan_commands();
        }
        Err(e) => {
            eprintln!("[discovery] failed to run artisan: {}", e);
            return default_artisan_commands();
        }
    };

    let json_str = match String::from_utf8(output.stdout) {
        Ok(s) => s,
        Err(e) => {
            eprintln!("[discovery] invalid UTF-8 in artisan output: {}", e);
            return default_artisan_commands();
        }
    };

    let parsed: ArtisanListOutput = match serde_json::from_str(&json_str) {
        Ok(p) => p,
        Err(e) => {
            eprintln!("[discovery] failed to parse artisan JSON: {}", e);
            eprintln!("[discovery] JSON snippet: {:.500}", json_str);
            return default_artisan_commands();
        }
    };

    let mut commands: Vec<FullArtisanCommand> = parsed
        .commands
        .into_iter()
        .filter(|cmd| {
            // Exclude make:* commands (handled separately), help, list, and internal commands
            !cmd.name.starts_with("make:")
                && !cmd.name.starts_with("_")
                && cmd.name != "help"
                && cmd.name != "list"
                && cmd.name != "completion"
        })
        .map(|cmd| {
            let arguments = cmd
                .definition
                .as_ref()
                .map(|def| {
                    let mut args: Vec<_> = def
                        .arguments
                        .values()
                        .filter(|arg| arg.name != "command") // Skip the command argument itself
                        .map(|arg| (arg.name.clone(), arg.is_required, arg.description.clone()))
                        .collect();
                    args.sort_by(|a, b| a.0.cmp(&b.0));
                    args
                })
                .unwrap_or_default();

            let options = cmd
                .definition
                .as_ref()
                .map(|def| {
                    let mut opts: Vec<_> = def
                        .options
                        .values()
                        .filter(|opt| {
                            // Skip common global options (name includes -- prefix)
                            !matches!(
                                opt.name.as_str(),
                                "--help"
                                    | "--quiet"
                                    | "--silent"
                                    | "--verbose"
                                    | "--version"
                                    | "--ansi"
                                    | "--no-ansi"
                                    | "--no-interaction"
                                    | "--env"
                            )
                        })
                        .map(|opt| {
                            (
                                opt.name.clone(),
                                opt.shortcut.clone(),
                                opt.description.clone(),
                            )
                        })
                        .collect();
                    opts.sort_by(|a, b| a.0.cmp(&b.0));
                    opts
                })
                .unwrap_or_default();

            FullArtisanCommand {
                name: cmd.name,
                description: cmd.description,
                arguments,
                options,
            }
        })
        .collect();

    // Sort alphabetically by name
    commands.sort_by(|a, b| a.name.cmp(&b.name));

    if commands.is_empty() {
        default_artisan_commands()
    } else {
        commands
    }
}

/// Default artisan commands if discovery fails
fn default_artisan_commands() -> Vec<FullArtisanCommand> {
    let defaults = [
        ("about", "Display basic information about your application"),
        ("clear-compiled", "Remove the compiled class file"),
        ("completion", "Dump the shell completion script"),
        ("db", "Start a new database CLI session"),
        ("down", "Put the application into maintenance mode"),
        ("env", "Display the current framework environment"),
        ("inspire", "Display an inspiring quote"),
        ("migrate", "Run the database migrations"),
        (
            "optimize",
            "Cache framework bootstrap, configuration, and metadata",
        ),
        ("optimize:clear", "Remove the cached bootstrap files"),
        (
            "serve",
            "Serve the application on the PHP development server",
        ),
        ("tinker", "Interact with your application"),
        ("up", "Bring the application out of maintenance mode"),
        ("cache:clear", "Flush the application cache"),
        (
            "config:cache",
            "Create a cache file for faster configuration loading",
        ),
        ("config:clear", "Remove the configuration cache file"),
        ("db:seed", "Seed the database with records"),
        (
            "event:cache",
            "Discover and cache the application's events and listeners",
        ),
        ("event:clear", "Clear all cached events and listeners"),
        ("key:generate", "Set the application key"),
        ("migrate:fresh", "Drop all tables and re-run all migrations"),
        ("migrate:refresh", "Reset and re-run all migrations"),
        ("migrate:reset", "Rollback all database migrations"),
        ("migrate:rollback", "Rollback the last database migration"),
        ("migrate:status", "Show the status of each migration"),
        (
            "queue:clear",
            "Delete all of the jobs from the specified queue",
        ),
        ("queue:failed", "List all of the failed queue jobs"),
        ("queue:flush", "Flush all of the failed queue jobs"),
        (
            "queue:restart",
            "Restart queue worker daemons after their current job",
        ),
        ("queue:retry", "Retry a failed queue job"),
        (
            "route:cache",
            "Create a route cache file for faster route registration",
        ),
        ("route:clear", "Remove the route cache file"),
        ("route:list", "List all registered routes"),
        ("schedule:list", "List all scheduled tasks"),
        (
            "storage:link",
            "Create the symbolic links configured for the application",
        ),
        (
            "view:cache",
            "Compile all of the application's Blade templates",
        ),
        ("view:clear", "Clear all compiled view files"),
    ];

    defaults
        .into_iter()
        .map(|(name, desc)| FullArtisanCommand {
            name: name.to_string(),
            description: desc.to_string(),
            arguments: Vec::new(),
            options: Vec::new(),
        })
        .collect()
}

/// Default make commands if discovery fails
fn default_make_commands() -> Vec<FullArtisanCommand> {
    let defaults = [
        ("make:controller", "Create a new controller class"),
        ("make:model", "Create a new Eloquent model class"),
        ("make:migration", "Create a new migration file"),
        ("make:seeder", "Create a new seeder class"),
        ("make:factory", "Create a new model factory"),
        ("make:request", "Create a new form request class"),
        ("make:resource", "Create a new resource"),
        ("make:event", "Create a new event class"),
        ("make:listener", "Create a new event listener class"),
        ("make:job", "Create a new job class"),
        ("make:command", "Create a new Artisan command"),
        ("make:mail", "Create a new email class"),
        ("make:notification", "Create a new notification class"),
        ("make:policy", "Create a new policy class"),
        ("make:rule", "Create a new validation rule"),
    ];

    defaults
        .into_iter()
        .map(|(name, desc)| FullArtisanCommand {
            name: name.to_string(),
            description: desc.to_string(),
            arguments: vec![(
                "name".to_string(),
                true,
                "The name of the class".to_string(),
            )],
            options: Vec::new(),
        })
        .collect()
}