Files
zeekay 63bde13037 fix: replace invalid hyphenated Go identifiers with camelCase
The bulk rename from agentfield to hanzo-agents introduced hyphens into
Go variable names (e.g. hanzo-agentsHome), which are not valid Go
identifiers. Fixed 361 occurrences across 36 files to use camelCase
(e.g. hanzoAgentsHome). String literals like ".hanzo-agents" are
preserved as-is.
2026-02-13 12:43:38 -08:00

83 lines
2.1 KiB
Go

package cli
import (
"errors"
"fmt"
"os"
"path/filepath"
"github.com/hanzoai/agents/control-plane/internal/packages"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)
// NewListCommand creates the list command
func NewListCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List installed HanzoAgents agent node packages",
Long: `Display all installed HanzoAgents agent node packages with their status.
Shows package name, version, status (running/stopped), and port if running.
Examples:
af list`,
Run: runListCommand,
}
return cmd
}
func runListCommand(cmd *cobra.Command, args []string) {
hanzoAgentsHome := getHanzoAgentsHomeDir()
registryPath := filepath.Join(hanzoAgentsHome, "installed.yaml")
// Load registry
registry := &packages.InstallationRegistry{
Installed: make(map[string]packages.InstalledPackage),
}
if data, err := os.ReadFile(registryPath); err == nil {
if err := yaml.Unmarshal(data, registry); err != nil {
cmd.PrintErrf("failed to parse registry: %v\n", err)
return
}
} else if !errors.Is(err, os.ErrNotExist) {
cmd.PrintErrf("failed to read registry: %v\n", err)
return
}
if len(registry.Installed) == 0 {
fmt.Println("đŸ“Ļ No agent node packages installed")
fmt.Println("💡 Install packages with: hanzo-agents install <package-path>")
return
}
fmt.Printf("đŸ“Ļ Installed Agent Node Packages (%d total):\n\n", len(registry.Installed))
for name, pkg := range registry.Installed {
status := pkg.Status
statusIcon := "âšī¸"
if status == "running" {
statusIcon = "đŸŸĸ"
} else if status == "error" {
statusIcon = "🔴"
}
fmt.Printf("%s %s (v%s)\n", statusIcon, name, pkg.Version)
fmt.Printf(" %s\n", pkg.Description)
if status == "running" && pkg.Runtime.Port != nil {
fmt.Printf(" 🌐 Running on port %d (PID: %d)\n", *pkg.Runtime.Port, *pkg.Runtime.PID)
}
fmt.Printf(" 📁 %s\n", pkg.Path)
fmt.Println()
}
fmt.Println("💡 Commands:")
fmt.Println(" af run <name> - Start an agent node")
fmt.Println(" af stop <name> - Stop a running agent node")
fmt.Println(" af logs <name> - View agent node logs")
}