refactor(cli): restructure cmd packages into subdirectories
- Move CLI commands into subdirectories matching command hierarchy:
dev/, go/, php/, build/, ci/, sdk/, pkg/, vm/, docs/, setup/, doctor/, test/, ai/
- Create shared/ package for common styles and utilities
- Add new `core ai` root command with claude subcommand
- Update package declarations and imports across all files
- Create commands.go entry points for each package
- Remove GUI-related files (moved to core-gui repo)
This makes the filesystem structure match the CLI command structure,
improving context capture and code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:02:43 +00:00
|
|
|
// Package doctor provides environment check commands.
|
|
|
|
|
package doctor
|
2026-01-28 14:50:55 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
2026-01-29 18:13:51 +00:00
|
|
|
"github.com/host-uk/core/cmd/shared"
|
2026-01-30 00:47:54 +00:00
|
|
|
"github.com/spf13/cobra"
|
2026-01-28 14:50:55 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Style aliases from shared
|
refactor(cli): restructure cmd packages into subdirectories
- Move CLI commands into subdirectories matching command hierarchy:
dev/, go/, php/, build/, ci/, sdk/, pkg/, vm/, docs/, setup/, doctor/, test/, ai/
- Create shared/ package for common styles and utilities
- Add new `core ai` root command with claude subcommand
- Update package declarations and imports across all files
- Create commands.go entry points for each package
- Remove GUI-related files (moved to core-gui repo)
This makes the filesystem structure match the CLI command structure,
improving context capture and code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:02:43 +00:00
|
|
|
var (
|
|
|
|
|
successStyle = shared.SuccessStyle
|
|
|
|
|
errorStyle = shared.ErrorStyle
|
|
|
|
|
dimStyle = shared.DimStyle
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
// Flag variable for doctor command
|
|
|
|
|
var doctorVerbose bool
|
2026-01-28 14:50:55 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
var doctorCmd = &cobra.Command{
|
|
|
|
|
Use: "doctor",
|
|
|
|
|
Short: "Check development environment",
|
|
|
|
|
Long: `Checks that all required tools are installed and configured.
|
|
|
|
|
Run this before 'core setup' to ensure your environment is ready.`,
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
return runDoctor(doctorVerbose)
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-28 14:50:55 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
func init() {
|
|
|
|
|
doctorCmd.Flags().BoolVar(&doctorVerbose, "verbose", false, "Show detailed version information")
|
2026-01-28 14:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func runDoctor(verbose bool) error {
|
|
|
|
|
fmt.Println("Checking development environment...")
|
|
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
|
|
var passed, failed, optional int
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Check required tools
|
2026-01-28 14:50:55 +00:00
|
|
|
fmt.Println("Required:")
|
2026-01-30 00:22:47 +00:00
|
|
|
for _, c := range requiredChecks {
|
2026-01-28 14:50:55 +00:00
|
|
|
ok, version := runCheck(c)
|
|
|
|
|
if ok {
|
|
|
|
|
if verbose && version != "" {
|
|
|
|
|
fmt.Printf(" %s %s %s\n", successStyle.Render("✓"), c.name, dimStyle.Render(version))
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf(" %s %s\n", successStyle.Render("✓"), c.name)
|
|
|
|
|
}
|
|
|
|
|
passed++
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf(" %s %s - %s\n", errorStyle.Render("✗"), c.name, c.description)
|
|
|
|
|
failed++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Check optional tools
|
2026-01-28 14:50:55 +00:00
|
|
|
fmt.Println("\nOptional:")
|
2026-01-30 00:22:47 +00:00
|
|
|
for _, c := range optionalChecks {
|
2026-01-28 14:50:55 +00:00
|
|
|
ok, version := runCheck(c)
|
|
|
|
|
if ok {
|
|
|
|
|
if verbose && version != "" {
|
|
|
|
|
fmt.Printf(" %s %s %s\n", successStyle.Render("✓"), c.name, dimStyle.Render(version))
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf(" %s %s\n", successStyle.Render("✓"), c.name)
|
|
|
|
|
}
|
|
|
|
|
passed++
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf(" %s %s - %s\n", dimStyle.Render("○"), c.name, dimStyle.Render(c.description))
|
|
|
|
|
optional++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Check GitHub access
|
2026-01-28 14:50:55 +00:00
|
|
|
fmt.Println("\nGitHub Access:")
|
|
|
|
|
if checkGitHubSSH() {
|
|
|
|
|
fmt.Printf(" %s SSH key found\n", successStyle.Render("✓"))
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf(" %s SSH key missing - run: ssh-keygen && gh ssh-key add\n", errorStyle.Render("✗"))
|
|
|
|
|
failed++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if checkGitHubCLI() {
|
|
|
|
|
fmt.Printf(" %s CLI authenticated\n", successStyle.Render("✓"))
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf(" %s CLI authentication - run: gh auth login\n", errorStyle.Render("✗"))
|
|
|
|
|
failed++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check workspace
|
|
|
|
|
fmt.Println("\nWorkspace:")
|
2026-01-30 00:22:47 +00:00
|
|
|
checkWorkspace()
|
2026-01-28 14:50:55 +00:00
|
|
|
|
|
|
|
|
// Summary
|
|
|
|
|
fmt.Println()
|
|
|
|
|
if failed > 0 {
|
|
|
|
|
fmt.Printf("%s %d issues found\n", errorStyle.Render("Doctor:"), failed)
|
|
|
|
|
fmt.Println("\nInstall missing tools:")
|
|
|
|
|
printInstallInstructions()
|
|
|
|
|
return fmt.Errorf("%d required tools missing", failed)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%s Environment ready\n", successStyle.Render("Doctor:"))
|
|
|
|
|
return nil
|
|
|
|
|
}
|