Description
Bridge the gap between validation errors (currently plain text) and CLI console formatting to provide consistent, styled error display. Currently 0 validation errors use console formatting, leading to inconsistent user experience between validation errors and other CLI output.
Current Situation
Console Formatting Gap:
- 0 validation errors use
console.FormatErrorMessage()
- Validation errors appear as plain text without color/emphasis
- Inconsistent with CLI command error handling patterns
- 22 direct stderr writes bypass console formatting system
- Users see unstyled errors in CLI context where other errors are styled
Current Pattern:
// CLI command (using console formatting)
fmt.Fprintln(os.Stderr, console.FormatErrorMessage("Failed to process"))
// Validation error (plain text, inconsistent)
fmt.Fprintln(os.Stderr, err)
Proposed Architecture
Design Principle: Separation of concerns
- Validation layer: Plain text errors (testable, reusable, framework-agnostic)
- CLI layer: Console formatting wrapper (user-facing, styled, accessible)
This approach:
- ✅ Keeps validation logic pure and testable
- ✅ Allows validation errors to be used in non-CLI contexts
- ✅ Centralizes formatting logic in CLI layer
- ✅ Maintains existing test coverage
Implementation Plan
Phase 1: Create Formatting Helper (Day 1)
Create pkg/cli/validation_output.go:
package cli
import (
"fmt"
"os"
"strings"
"github.com/githubnext/gh-aw/pkg/console"
)
// FormatValidationError formats validation errors for console output
// Preserves structured error content while applying console styling
func FormatValidationError(err error) string {
if err == nil {
return ""
}
errMsg := err.Error()
// Detect multi-line structured errors (like GitHubToolsetValidationError)
if strings.Contains(errMsg, "\n\n") || strings.HasPrefix(errMsg, "ERROR:") {
// Preserve structure, apply styling to header only
return console.FormatErrorMessage(errMsg)
}
// Standard single-line or simple multi-line error
return console.FormatErrorMessage(errMsg)
}
// PrintValidationError prints a validation error to stderr with formatting
func PrintValidationError(err error) {
if err == nil {
return
}
fmt.Fprintln(os.Stderr, FormatValidationError(err))
}
Phase 2: Update CLI Commands (Day 1-2)
Pattern:
// OLD
if err := ValidateWorkflow(config); err != nil {
fmt.Fprintln(os.Stderr, err)
return err
}
// NEW
if err := ValidateWorkflow(config); err != nil {
PrintValidationError(err)
return err
}
Commands to update (minimum 5):
pkg/cli/compile_command.go - RunCompileWorkflow
pkg/cli/run_command.go - RunRunWorkflow
pkg/cli/mcp_inspect_command.go - inspect operations
pkg/cli/audit_command.go - validation failures
pkg/cli/compile_validation.go - all validation error prints
Phase 3: Testing (Day 2)
Create pkg/cli/validation_output_test.go:
- Verify styling applied correctly
- Verify structured errors preserve formatting
- Verify error content unchanged (only styling added)
- Test both simple and complex error types
Example Transformation
Before:
$ gh aw compile invalid.md
missing required field 'engine'
After:
$ gh aw compile invalid.md
✖ missing required field 'engine'. Example:
engine: copilot
(where ✖ and error text are styled with red color)
Success Criteria
Expected Outcomes
- Consistent styled output for all CLI errors (validation + command)
- Improved user experience with color/emphasis on errors
- Better accessibility through console formatting system
- Maintains validation layer purity (no CLI dependencies)
Priority
Medium - User experience improvement
Estimated Effort
Medium (1-2 days)
Files to Create
pkg/cli/validation_output.go (new file)
pkg/cli/validation_output_test.go (new file)
Files to Update
pkg/cli/compile_command.go
pkg/cli/run_command.go
pkg/cli/mcp_inspect_command.go
pkg/cli/audit_command.go
pkg/cli/compile_validation.go
Related Issues
Source
Extracted from Repository Quality Improvement Report #11292 - Validation Message Clarity & Developer Guidance (Task 5)
AI generated by Discussion Task Miner - Code Quality Improvement Agent
Description
Bridge the gap between validation errors (currently plain text) and CLI console formatting to provide consistent, styled error display. Currently 0 validation errors use console formatting, leading to inconsistent user experience between validation errors and other CLI output.
Current Situation
Console Formatting Gap:
console.FormatErrorMessage()Current Pattern:
Proposed Architecture
Design Principle: Separation of concerns
This approach:
Implementation Plan
Phase 1: Create Formatting Helper (Day 1)
Create
pkg/cli/validation_output.go:Phase 2: Update CLI Commands (Day 1-2)
Pattern:
Commands to update (minimum 5):
pkg/cli/compile_command.go-RunCompileWorkflowpkg/cli/run_command.go-RunRunWorkflowpkg/cli/mcp_inspect_command.go- inspect operationspkg/cli/audit_command.go- validation failurespkg/cli/compile_validation.go- all validation error printsPhase 3: Testing (Day 2)
Create
pkg/cli/validation_output_test.go:Example Transformation
Before:
$ gh aw compile invalid.md missing required field 'engine'After:
$ gh aw compile invalid.md ✖ missing required field 'engine'. Example: engine: copilot(where ✖ and error text are styled with red color)
Success Criteria
pkg/cli/validation_output.gowithFormatValidationErrorhelperconsole.FormatErrorMessagestylingGitHubToolsetValidationError) preserve structurevalidation_output_test.goverify formatting doesn't alter error contentmake agent-finishsuccessfullyExpected Outcomes
Priority
Medium - User experience improvement
Estimated Effort
Medium (1-2 days)
Files to Create
pkg/cli/validation_output.go(new file)pkg/cli/validation_output_test.go(new file)Files to Update
pkg/cli/compile_command.gopkg/cli/run_command.gopkg/cli/mcp_inspect_command.gopkg/cli/audit_command.gopkg/cli/compile_validation.goRelated Issues
Source
Extracted from Repository Quality Improvement Report #11292 - Validation Message Clarity & Developer Guidance (Task 5)