MCPcopy Create free account
hub / github.com/github/gh-aw / printCompilationSummary

Function printCompilationSummary

pkg/cli/compile_stats.go:140–225  ·  view source on GitHub ↗

printCompilationSummary prints a summary of the compilation results

(stats *CompilationStats, showAllErrors bool)

Source from the content-addressed store, hash-verified

138
139// printCompilationSummary prints a summary of the compilation results
140func 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:"))

Calls 8

FormatErrorMessageFunction · 0.92
FormatListItemFunction · 0.92
FormatInfoMessageFunction · 0.92
FormatWarningMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
HeadingMethod · 0.80
IconMethod · 0.80