printCompilationSummary prints a summary of the compilation results
(stats *CompilationStats, showAllErrors bool)
| 138 | |
| 139 | // printCompilationSummary prints a summary of the compilation results |
| 140 | func printCompilationSummary(stats *CompilationStats, showAllErrors bool) { |
| 141 | if stats.Total == 0 { |
| 142 | return |
| 143 | } |
| 144 | |
| 145 | summary := fmt.Sprintf("Compiled %d workflow(s): %d error(s), %d warning(s)", |
| 146 | stats.Total, stats.Errors, stats.Warnings) |
| 147 | failedWorkflowCount := len(stats.FailureDetails) |
| 148 | if failedWorkflowCount == 0 { |
| 149 | failedWorkflowCount = len(stats.FailedWorkflows) |
| 150 | } |
| 151 | if stats.Errors > 0 && failedWorkflowCount > 0 { |
| 152 | summary = fmt.Sprintf("Compiled %d workflow(s): %d error(s) across %d failed workflow(s), %d warning(s)", |
| 153 | stats.Total, stats.Errors, failedWorkflowCount, stats.Warnings) |
| 154 | } |
| 155 | |
| 156 | // Use different formatting based on whether there were errors |
| 157 | if stats.Errors > 0 { |
| 158 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage(summary)) |
| 159 | |
| 160 | // Show agent-friendly list of failed workflow IDs first |
| 161 | if len(stats.FailureDetails) > 0 { |
| 162 | fmt.Fprintln(os.Stderr) |
| 163 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage("Failed workflows:")) |
| 164 | for _, failure := range stats.FailureDetails { |
| 165 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage(filepath.Base(failure.Path))) |
| 166 | } |
| 167 | fmt.Fprintln(os.Stderr) |
| 168 | |
| 169 | // Display the actual error messages for each failed workflow |
| 170 | for _, failure := range stats.FailureDetails { |
| 171 | report := workflow.BuildPrioritizedErrorReportFromMessages(failure.ErrorMessages, showAllErrors) |
| 172 | if report.TotalCount == 0 { |
| 173 | continue |
| 174 | } |
| 175 | |
| 176 | header := fmt.Sprintf("%s (%d error(s)", filepath.Base(failure.Path), report.TotalCount) |
| 177 | if !showAllErrors && report.HiddenCount > 0 { |
| 178 | header += fmt.Sprintf(", showing top %d", len(report.DisplayedErrors)) |
| 179 | } |
| 180 | header += "):" |
| 181 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage(header)) |
| 182 | |
| 183 | lastHeading := "" |
| 184 | for i, prioritized := range report.DisplayedErrors { |
| 185 | heading := prioritized.Severity.Heading() |
| 186 | if heading != lastHeading { |
| 187 | fmt.Fprintln(os.Stderr, console.FormatListItem(fmt.Sprintf("%s %s:", prioritized.Severity.Icon(), heading))) |
| 188 | lastHeading = heading |
| 189 | } |
| 190 | fmt.Fprintln(os.Stderr, console.FormatListItem(fmt.Sprintf("%d. %s", i+1, prioritized.Message))) |
| 191 | if prioritized.Suggestion != "" { |
| 192 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("→ "+prioritized.Suggestion)) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | if report.RecoveryPlan != nil && len(report.RecoveryPlan.Steps) > 0 { |
| 197 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("💡 Recovery plan:")) |