ralph-workflow 0.7.18

PROMPT-driven multi-agent orchestrator for git repos
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
//! Pure domain functions for diagnostic information.
//!
//! This module contains the policy logic extracted from boundary functions.
//! These functions are pure and testable without I/O.

use crate::agents::{AgentDrain, AgentRegistry};
use crate::checkpoint::load_checkpoint_with_workspace;
use crate::config::Config;
use crate::guidelines::{CheckSeverity, ReviewGuidelines};
use crate::language_detector;
use crate::workspace::Workspace;

/// Git diagnostic information.
#[derive(Debug, Clone)]
pub struct GitDiagnostics {
    pub version: Option<String>,
    pub is_repo: bool,
    pub branch: Option<String>,
    pub uncommitted_changes: Option<usize>,
}

/// Plan which git commands to execute based on repository state.
#[derive(Debug, Clone)]
pub enum GitCommandPlan {
    Full,
    None,
}

/// Determine which git commands to run based on initial version check.
///
/// This is the policy decision: "should we run more git commands?"
pub fn plan_git_commands(version_available: bool) -> GitCommandPlan {
    if !version_available {
        return GitCommandPlan::None;
    }
    GitCommandPlan::Full
}

/// Determine if we should check for branch (requires repo check first).
pub fn should_check_branch(is_repo: bool) -> bool {
    is_repo
}

/// Determine if we should check for uncommitted changes (requires repo check first).
pub fn should_check_uncommitted(is_repo: bool) -> bool {
    is_repo
}

/// Build GitDiagnostics from command outputs.
pub fn build_git_diagnostics(
    version: Option<String>,
    is_repo: bool,
    branch: Option<String>,
    uncommitted_changes: Option<usize>,
) -> GitDiagnostics {
    GitDiagnostics {
        version,
        is_repo,
        branch,
        uncommitted_changes,
    }
}

/// Format git diagnostic information as lines.
pub fn format_git_info_lines(diagnostics: &GitDiagnostics) -> Vec<String> {
    let version_line = diagnostics
        .version
        .as_ref()
        .map(|v| format!("  Version: {v}"));

    let repo_line = Some(format!(
        "  In git repo: {}",
        if diagnostics.is_repo { "yes" } else { "no" }
    ));

    let branch_line = diagnostics
        .branch
        .as_ref()
        .map(|b| format!("  Current branch: {b}"));

    let changes_line = diagnostics
        .uncommitted_changes
        .map(|c| format!("  Uncommitted changes: {c}"));

    [version_line, repo_line, branch_line, changes_line]
        .into_iter()
        .flatten()
        .collect()
}

/// Config existence status.
#[derive(Debug, Clone)]
pub enum ConfigExistsStatus {
    Yes,
    No,
    Unknown(String),
}

/// Determine config file existence status.
pub fn determine_config_exists(
    config_path_is_absolute: bool,
    workspace_root: &dyn crate::workspace::Workspace,
    config_path: &std::path::Path,
) -> ConfigExistsStatus {
    if config_path_is_absolute {
        config_path
            .strip_prefix(workspace_root.root())
            .ok()
            .map_or_else(
                || ConfigExistsStatus::Unknown("unknown (outside workspace)".to_string()),
                |relative| {
                    if workspace_root.exists(relative) {
                        ConfigExistsStatus::Yes
                    } else {
                        ConfigExistsStatus::No
                    }
                },
            )
    } else if workspace_root.exists(config_path) {
        ConfigExistsStatus::Yes
    } else {
        ConfigExistsStatus::No
    }
}

/// PROMPT.md analysis result.
#[derive(Debug, Clone)]
pub struct PromptAnalysis {
    pub size_bytes: Option<usize>,
    pub line_count: Option<usize>,
    pub has_goal_section: bool,
    pub has_acceptance_section: bool,
}

/// Analyze PROMPT.md content for key sections.
pub fn analyze_prompt_content(content: &str) -> PromptAnalysis {
    let has_goal = content.contains("## Goal") || content.contains("# Goal");
    let has_acceptance =
        content.contains("## Acceptance") || content.contains("Acceptance Criteria");

    PromptAnalysis {
        size_bytes: Some(content.len()),
        line_count: Some(content.lines().count()),
        has_goal_section: has_goal,
        has_acceptance_section: has_acceptance,
    }
}

/// Agent availability display info.
#[derive(Debug, Clone)]
pub struct AgentAvailabilityInfo {
    pub name: String,
    pub available: bool,
    pub json_parser: bool,
    pub command: String,
}

/// Get sorted list of agent availability info.
pub fn get_sorted_agent_availability(
    registry: &crate::agents::AgentRegistry,
) -> Vec<AgentAvailabilityInfo> {
    use itertools::Itertools;

    let all_agents = registry.list();
    all_agents
        .into_iter()
        .map(|(name, cfg)| AgentAvailabilityInfo {
            name: name.to_string(),
            available: registry.is_agent_available(name),
            json_parser: !matches!(
                cfg.json_parser,
                crate::agents::parser::JsonParserType::Generic
            ),
            command: cfg.cmd.clone(),
        })
        .sorted_by(|a, b| a.name.cmp(&b.name))
        .collect()
}

/// Agent drain display info.
#[derive(Debug, Clone)]
pub struct DrainBindingInfo {
    pub drain: AgentDrain,
    pub chain_name: String,
    pub agents: Vec<String>,
}

/// Get all drain bindings as display info.
pub fn get_drain_bindings(registry: &crate::agents::AgentRegistry) -> Vec<DrainBindingInfo> {
    let resolved = registry.resolved_drains();
    crate::agents::AgentDrain::all()
        .into_iter()
        .filter_map(|drain| {
            resolved.binding(drain).map(|binding| DrainBindingInfo {
                drain,
                chain_name: binding.chain_name.clone(),
                agents: binding.agents.clone(),
            })
        })
        .collect()
}

/// Resolve the checkpoint log path or find the latest run log directory.
pub fn find_log_path(workspace: &dyn Workspace) -> Option<std::path::PathBuf> {
    let checkpoint = load_checkpoint_with_workspace(workspace).ok().flatten()?;

    if let Some(log_run_id) = checkpoint.log_run_id {
        return Some(std::path::PathBuf::from(format!(
            ".agent/logs-{log_run_id}/pipeline.log"
        )));
    }

    find_latest_run_log_path(workspace)
}

/// Find the latest run log path by lexicographic sort.
fn find_latest_run_log_path(workspace: &dyn Workspace) -> Option<std::path::PathBuf> {
    use itertools::Itertools;
    use std::path::Path;

    let agent_dir = Path::new(".agent");
    if !workspace.is_dir(agent_dir) {
        return None;
    }

    let entries = workspace.read_dir(agent_dir).ok()?;

    entries
        .into_iter()
        .filter(|entry| {
            entry
                .file_name()
                .and_then(|n| n.to_str())
                .is_some_and(|s| s.starts_with("logs-") && entry.is_dir())
        })
        .filter_map(|entry| {
            entry
                .file_name()
                .and_then(|n| n.to_str())
                .map(std::string::ToString::to_string)
        })
        .sorted()
        .last()
        .map(|dir_name| Path::new(".agent").join(dir_name).join("pipeline.log"))
}

/// Format recent log lines from content string (last 10 lines).
pub fn format_recent_log_lines(content: &str) -> Vec<String> {
    let lines: Vec<&str> = content.lines().collect();
    let start = lines.len().saturating_sub(10);
    lines[start..].iter().map(|l| format!("  {l}")).collect()
}

/// Format configuration info section lines.
pub fn format_config_section_lines(
    config: &Config,
    config_path: &std::path::Path,
    config_sources: &[crate::agents::ConfigSource],
    workspace: &dyn Workspace,
) -> Vec<String> {
    let exists_status = determine_config_exists(config_path.is_absolute(), workspace, config_path);
    let exists_str: String = match exists_status {
        ConfigExistsStatus::Yes => "yes".to_string(),
        ConfigExistsStatus::No => "no".to_string(),
        ConfigExistsStatus::Unknown(s) => s,
    };

    let base_lines = [
        format!("  Unified config: {}", config_path.display()),
        format!("  Config exists: {exists_str}"),
        format!(
            "  Review depth: {:?} ({})",
            config.review_depth,
            config.review_depth.description()
        ),
    ];

    if config_sources.is_empty() {
        return base_lines.to_vec();
    }

    let source_lines: Vec<String> = std::iter::once("  Loaded sources:".to_string())
        .chain(config_sources.iter().map(|src| {
            format!(
                "    - {} ({} agents)",
                src.path.display(),
                src.agents_loaded
            )
        }))
        .collect();

    base_lines.into_iter().chain(source_lines).collect()
}

/// Format agent availability section lines.
pub fn format_agent_availability_section(registry: &AgentRegistry) -> Vec<String> {
    let agents = get_sorted_agent_availability(registry);
    agents
        .into_iter()
        .map(|agent| {
            let status_icon = if agent.available { "✓" } else { "✗" };
            let command_name = agent
                .command
                .split_whitespace()
                .next()
                .unwrap_or(&agent.command);
            format!(
                "  {status_icon} {} (parser: {}, cmd: {})",
                agent.name, agent.json_parser, command_name
            )
        })
        .collect()
}

/// Format PROMPT.md status section lines.
pub fn format_prompt_status_section(workspace: &dyn Workspace) -> Vec<String> {
    use std::path::Path;

    let prompt_path = Path::new("PROMPT.md");

    if !workspace.exists(prompt_path) {
        return vec!["  Exists: no".to_string()];
    }

    let Ok(content) = workspace.read(prompt_path) else {
        return vec!["  Exists: no".to_string()];
    };

    let analysis = analyze_prompt_content(&content);
    [
        Some("  Exists: yes".to_string()),
        Some(format!(
            "  Size: {} bytes",
            analysis.size_bytes.unwrap_or(0)
        )),
        Some(format!("  Lines: {}", analysis.line_count.unwrap_or(0))),
        Some(format!(
            "  Has Goal section: {}",
            if analysis.has_goal_section {
                "yes"
            } else {
                "no"
            }
        )),
        Some(format!(
            "  Has Acceptance section: {}",
            if analysis.has_acceptance_section {
                "yes"
            } else {
                "no"
            }
        )),
    ]
    .into_iter()
    .flatten()
    .collect()
}

/// Format project stack section lines.
pub fn format_project_stack_section(workspace: &dyn Workspace) -> Vec<String> {
    let stack =
        match language_detector::detect_stack_with_workspace(workspace, std::path::Path::new("")) {
            Ok(s) => s,
            Err(e) => return vec![format!("  Detection failed: {e}")],
        };

    let secondary = (!stack.secondary_languages.is_empty())
        .then_some(vec![format!(
            "  Secondary languages: {:?}",
            stack.secondary_languages
        )])
        .unwrap_or_default();

    let frameworks = (!stack.frameworks.is_empty())
        .then_some(vec![format!("  Frameworks: {:?}", stack.frameworks)])
        .unwrap_or_default();

    let package_manager = stack
        .package_manager
        .as_ref()
        .map(|pm| vec![format!("  Package manager: {pm}")])
        .unwrap_or_default();

    let test_framework = stack
        .test_framework
        .as_ref()
        .map(|tf| vec![format!("  Test framework: {tf}")])
        .unwrap_or_default();

    let language_types: Vec<&str> = [
        if stack.is_rust() { Some("Rust") } else { None },
        if stack.is_python() {
            Some("Python")
        } else {
            None
        },
        if stack.is_javascript_or_typescript() {
            Some("JS/TS")
        } else {
            None
        },
        if stack.is_go() { Some("Go") } else { None },
    ]
    .into_iter()
    .flatten()
    .collect();
    let language_flags = (!language_types.is_empty())
        .then_some(vec![format!(
            "  Language flags: {}",
            language_types.join(", ")
        )])
        .unwrap_or_default();

    let guidelines = ReviewGuidelines::for_stack(&stack);

    let all_checks = guidelines.get_all_checks();
    let critical_count = all_checks
        .iter()
        .filter(|c| matches!(c.severity, CheckSeverity::Critical))
        .count();
    let high_count = all_checks
        .iter()
        .filter(|c| matches!(c.severity, CheckSeverity::High))
        .count();

    let severity_line = (critical_count > 0 || high_count > 0)
        .then_some(vec![format!(
            "  Check severities: {critical_count} critical, {high_count} high"
        )])
        .unwrap_or_default();

    let critical_checks_lines: Vec<String> = all_checks
        .iter()
        .filter(|c| matches!(c.severity, CheckSeverity::Critical))
        .take(3)
        .map(|check| format!("    - {}", check.check))
        .collect();

    let checks_section = if critical_checks_lines.is_empty() {
        vec![]
    } else {
        std::iter::once("  Critical checks (sample):".to_string())
            .chain(critical_checks_lines)
            .collect()
    };

    [
        vec![format!("  Primary language: {}", stack.primary_language)],
        secondary,
        frameworks,
        package_manager,
        test_framework,
        language_flags,
        vec![format!(
            "  Review checks: {} total",
            guidelines.total_checks()
        )],
        severity_line,
        checks_section,
    ]
    .into_iter()
    .flatten()
    .collect()
}

/// Determine if template selection should use the default.
pub fn should_use_default_template(input: &str) -> bool {
    input.trim().is_empty()
}

/// Resolve the template name from user input.
pub fn resolve_template_name(input: &str) -> &str {
    if should_use_default_template(input) {
        "feature-spec"
    } else {
        input.trim()
    }
}

/// Result of template validation.
#[derive(Debug, Clone)]
pub enum TemplateValidation {
    Valid,
    Unknown,
}

pub fn validate_template_name(template_name: &str) -> TemplateValidation {
    use crate::templates::get_template;

    if get_template(template_name).is_some() {
        TemplateValidation::Valid
    } else {
        TemplateValidation::Unknown
    }
}

/// Determine if user declined the template selection.
pub fn did_user_decline_template(response: &str) -> bool {
    let response = response.trim().to_lowercase();
    response == "n" || response == "no" || response == "skip"
}

/// Init action based on file existence state.
#[derive(Debug, Clone, Copy)]
pub enum InitFileState {
    BothExist,
    ConfigOnly,
    PromptOnly,
    NeitherExists,
}

/// Determine the init action based on config and prompt file existence.
pub fn determine_init_action(
    config_exists: bool,
    prompt_exists: bool,
    _template_arg: Option<&str>,
) -> InitFileState {
    if config_exists && prompt_exists {
        InitFileState::BothExist
    } else if config_exists {
        InitFileState::ConfigOnly
    } else if prompt_exists {
        InitFileState::PromptOnly
    } else {
        InitFileState::NeitherExists
    }
}

/// Action to take for init when config exists but prompt doesn't.
#[derive(Debug, Clone)]
pub enum ConfigOnlyAction {
    CreateFromTemplate(String),
    CreateMinimal,
    Skip,
}

/// Decide the action when config exists but prompt doesn't.
pub fn decide_config_only_action(
    can_prompt: bool,
    template_name: Option<String>,
) -> ConfigOnlyAction {
    if can_prompt {
        if let Some(name) = template_name {
            return ConfigOnlyAction::CreateFromTemplate(name);
        }
        ConfigOnlyAction::Skip
    } else {
        ConfigOnlyAction::CreateMinimal
    }
}

/// Action to take for init when neither config nor prompt exists.
#[derive(Debug, Clone)]
pub enum NeitherExistsAction {
    CreateFromTemplate(String),
    CreateMinimal,
    Skip,
}

/// Decide the action when neither config nor prompt exists.
pub fn decide_neither_exists_action(
    can_prompt: bool,
    template_name: Option<String>,
) -> NeitherExistsAction {
    if can_prompt {
        if let Some(name) = template_name {
            return NeitherExistsAction::CreateFromTemplate(name);
        }
        NeitherExistsAction::Skip
    } else {
        NeitherExistsAction::CreateMinimal
    }
}

/// Result of git version command execution.
pub struct GitVersionResult {
    pub version: Option<String>,
    pub available: bool,
}

/// Execute git version command and extract version string.
pub fn get_git_version_result(
    executor_output: Option<crate::executor::ProcessOutput>,
) -> GitVersionResult {
    let version = executor_output.map(|o| o.stdout.trim().to_string());
    GitVersionResult {
        available: version.is_some(),
        version,
    }
}

/// Raw git execution results for domain processing.
pub struct GitRawResults {
    pub version_output: Option<crate::executor::ProcessOutput>,
    pub rev_parse_output: Option<crate::executor::ProcessOutput>,
    pub branch_output: Option<crate::executor::ProcessOutput>,
    pub status_output: Option<crate::executor::ProcessOutput>,
}

/// Determine if template selection prompt should be offered.
pub fn should_offer_template_prompt(is_terminal: bool) -> bool {
    is_terminal
}

#[derive(Debug)]
pub enum TemplatePromptResponseDecision {
    Declined,
    Selected,
}

pub fn evaluate_template_creation_response(response: &str) -> TemplatePromptResponseDecision {
    if did_user_decline_template(response) {
        TemplatePromptResponseDecision::Declined
    } else {
        TemplatePromptResponseDecision::Selected
    }
}

/// Resolve the selected template, returning the final template to use.
#[derive(Debug)]
pub enum TemplateSelectionOutcome {
    Selected(String),
    UseDefault { default: String },
}

/// Resolve selected template from user input, handling unknown templates.
pub fn resolve_selected_template(
    input: &str,
    templates: &[(&str, &str)],
) -> TemplateSelectionOutcome {
    let resolved = resolve_template_name(input);
    let template_exists = templates.iter().any(|(name, _)| *name == resolved);

    if template_exists {
        TemplateSelectionOutcome::Selected(resolved.to_string())
    } else {
        TemplateSelectionOutcome::UseDefault {
            default: "feature-spec".to_string(),
        }
    }
}

/// Result of create prompt from template operation.
#[derive(Debug)]
pub enum CreatePromptResult {
    SkippedBecauseExists,
    Created,
    UnknownTemplateError,
}

/// Determine result of trying to create prompt from template.
pub fn determine_create_prompt_result(
    validation: &TemplateValidation,
    prompt_exists: bool,
) -> CreatePromptResult {
    if matches!(validation, TemplateValidation::Unknown) {
        return CreatePromptResult::UnknownTemplateError;
    }
    if prompt_exists {
        return CreatePromptResult::SkippedBecauseExists;
    }
    CreatePromptResult::Created
}

/// Compute log section content from workspace state.
#[derive(Debug)]
pub enum ComputeLogSection {
    NotFound,
    Empty,
    Content(Vec<String>),
}

/// Compute what the log section should show.
pub fn compute_log_section(workspace: &dyn Workspace) -> ComputeLogSection {
    let log_path = match find_log_path(workspace) {
        Some(p) => p,
        None => return ComputeLogSection::NotFound,
    };

    if !workspace.exists(&log_path) {
        return ComputeLogSection::NotFound;
    }

    let content = match workspace.read(&log_path) {
        Ok(c) => c,
        Err(_) => return ComputeLogSection::Empty,
    };

    let lines = format_recent_log_lines(&content);
    if lines.is_empty() {
        ComputeLogSection::Empty
    } else {
        ComputeLogSection::Content(lines)
    }
}

/// Action for config_only init flow.
#[derive(Debug)]
pub enum ConfigOnlyNextAction {
    CreateFromTemplate(String),
    CreateMinimal,
    Skip,
}

/// Determine next action for config-only flow.
pub fn determine_config_only_next_action(
    can_prompt: bool,
    template_name: Option<String>,
) -> ConfigOnlyNextAction {
    match decide_config_only_action(can_prompt, template_name) {
        ConfigOnlyAction::CreateFromTemplate(name) => {
            ConfigOnlyNextAction::CreateFromTemplate(name)
        }
        ConfigOnlyAction::CreateMinimal => ConfigOnlyNextAction::CreateMinimal,
        ConfigOnlyAction::Skip => ConfigOnlyNextAction::Skip,
    }
}

/// Action for neither_exists init flow.
#[derive(Debug)]
pub enum NeitherExistsNextAction {
    CreateFromTemplate(String),
    CreateMinimal,
    Skip,
}

/// Determine next action for neither-exists flow.
pub fn determine_neither_exists_next_action(
    can_prompt: bool,
    template_name: Option<String>,
) -> NeitherExistsNextAction {
    match decide_neither_exists_action(can_prompt, template_name) {
        NeitherExistsAction::CreateFromTemplate(name) => {
            NeitherExistsNextAction::CreateFromTemplate(name)
        }
        NeitherExistsAction::CreateMinimal => NeitherExistsNextAction::CreateMinimal,
        NeitherExistsAction::Skip => NeitherExistsNextAction::Skip,
    }
}

pub fn compute_git_diagnostics_from_raw_results(
    results: GitRawResults,
    is_repo: bool,
) -> GitDiagnostics {
    let version_result = get_git_version_result(results.version_output);
    let plan = plan_git_commands(version_result.available);

    match plan {
        GitCommandPlan::None => GitDiagnostics {
            version: None,
            is_repo: false,
            branch: None,
            uncommitted_changes: None,
        },
        GitCommandPlan::Full => {
            let branch = results
                .branch_output
                .filter(|_| should_check_branch(is_repo))
                .map(|o| o.stdout.trim().to_string());

            let uncommitted_changes = results
                .status_output
                .filter(|_| should_check_uncommitted(is_repo))
                .map(|o| o.stdout.lines().count());

            build_git_diagnostics(version_result.version, is_repo, branch, uncommitted_changes)
        }
    }
}