refactor(cmd): use shared styles in ai, go, and vm packages

- ai: Replace local task priority/status styles with shared equivalents
- go: Use FormatCoverage() and ProgressLabel() helpers in test output
- vm: Use shared colour constants instead of hardcoded values
- shared: Add FormatTaskStatus(), StatusPrefix(), ProgressLabel() helpers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-01-30 01:22:31 +00:00
parent 4fa0e0310b
commit 90a049b937
4 changed files with 46 additions and 43 deletions

View file

@ -17,39 +17,28 @@ var (
formatAge = shared.FormatAge
)
// Task-specific styles
// Task priority/status styles from shared
var (
taskPriorityHighStyle = shared.PriorityHighStyle
taskPriorityMediumStyle = shared.PriorityMediumStyle
taskPriorityLowStyle = shared.PriorityLowStyle
taskStatusPendingStyle = shared.StatusPendingStyle
taskStatusInProgressStyle = shared.StatusRunningStyle
taskStatusCompletedStyle = shared.StatusSuccessStyle
taskStatusBlockedStyle = shared.StatusErrorStyle
)
// Task-specific styles (unique to task display)
var (
taskIDStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#3b82f6")) // blue-500
Foreground(shared.ColourBlue500)
taskTitleStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#e2e8f0")) // gray-200
taskPriorityHighStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ef4444")) // red-500
taskPriorityMediumStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f59e0b")) // amber-500
taskPriorityLowStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#22c55e")) // green-500
taskStatusPendingStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#6b7280")) // gray-500
taskStatusInProgressStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#3b82f6")) // blue-500
taskStatusCompletedStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#22c55e")) // green-500
taskStatusBlockedStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#ef4444")) // red-500
Foreground(shared.ColourGray200)
taskLabelStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#a78bfa")) // violet-400
Foreground(shared.ColourViolet400)
)
// AddAgenticCommands adds the agentic task management commands to the ai command.

View file

@ -8,7 +8,7 @@ import (
"regexp"
"strings"
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared"
"github.com/spf13/cobra"
)
@ -125,13 +125,7 @@ func runGoTest(coverage bool, pkg, run string, short, race, jsonOut, verbose boo
}
if cov > 0 {
covStyle := successStyle
if cov < 50 {
covStyle = errorStyle
} else if cov < 80 {
covStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#f59e0b"))
}
fmt.Printf("\n %s %s\n", dimStyle.Render("Coverage:"), covStyle.Render(fmt.Sprintf("%.1f%%", cov)))
fmt.Printf("\n %s %s\n", shared.ProgressLabel("Coverage"), shared.FormatCoverage(cov))
}
if err == nil {
@ -258,13 +252,7 @@ func addGoCovCommand(parent *cobra.Command) {
// Print coverage summary
fmt.Println()
covStyle := successStyle
if totalCov < 50 {
covStyle = errorStyle
} else if totalCov < 80 {
covStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#f59e0b"))
}
fmt.Printf(" %s %s\n", dimStyle.Render("Total:"), covStyle.Render(fmt.Sprintf("%.1f%%", totalCov)))
fmt.Printf(" %s %s\n", shared.ProgressLabel("Total"), shared.FormatCoverage(totalCov))
// Generate HTML if requested
if covHTML || covOpen {

View file

@ -522,6 +522,32 @@ func FormatPriority(level string) string {
}
}
// FormatTaskStatus returns styled text for a task status.
// Supports: pending, in_progress, completed, blocked, failed.
func FormatTaskStatus(status string) string {
switch strings.ToLower(status) {
case "in_progress", "in-progress", "running", "active":
return StatusRunningStyle.Render(status)
case "completed", "done", "finished", "success":
return StatusSuccessStyle.Render(status)
case "blocked", "failed", "error":
return StatusErrorStyle.Render(status)
default: // pending, waiting, queued
return StatusPendingStyle.Render(status)
}
}
// StatusPrefix returns a styled ">>" prefix for status messages.
func StatusPrefix(style lipgloss.Style) string {
return style.Render(">>")
}
// ProgressLabel returns a dimmed label with colon for progress output.
// Example: ProgressLabel("Installing") -> "Installing:" in dim gray
func ProgressLabel(label string) string {
return DimStyle.Render(label + ":")
}
// ─────────────────────────────────────────────────────────────────────────────
// Table Helpers
// ─────────────────────────────────────────────────────────────────────────────

View file

@ -17,8 +17,8 @@ var (
// VM-specific styles
var (
varStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#f59e0b"))
defaultStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#6b7280")).Italic(true)
varStyle = lipgloss.NewStyle().Foreground(shared.ColourAmber500)
defaultStyle = lipgloss.NewStyle().Foreground(shared.ColourGray500).Italic(true)
)
// AddVMCommands adds container-related commands under 'vm' to the CLI.