package main import ( "fmt" "io" "os" "sort" "strings" "git.a-wan.net/alan/pipelines/internal/buildinfo" "git.a-wan.net/alan/pipelines/internal/claude" "git.a-wan.net/alan/pipelines/internal/harness" "git.a-wan.net/alan/pipelines/internal/protocol" ) // startup is what the server reports about itself once it is configured. type startup struct { Build buildinfo.Info Addr string Database string Artifacts string Authoring bool OpenCode protocol.ServiceStatus Chat []string Harnesses harness.ListView HarnessErr error WebURL string // ClaudeToken reports a service token for Claude Code chats. ClaudeToken bool } // banner writes the server and backend summary. `pipelines start` prints the // latest one from the server log, so its first and last lines are markers. func banner(w io.Writer, s startup) { version := s.Build.Version if version == "" { version = "dev" } commit := s.Build.Commit if len(commit) > 12 { commit = commit[:12] } if s.Build.Dirty != nil && *s.Build.Dirty { commit += " (modified)" } row := func(label, value string) { fmt.Fprintf(w, " %-10s %s\n", label, value) } fmt.Fprintf(w, "== Pipelines server %s\n", version) if commit != "" { row("Commit", commit) } row("API", "http://"+s.Addr+" (WebSocket /connect)") if s.WebURL != "" { row("Web", s.WebURL) } row("Database", s.Database) row("Artifacts", s.Artifacts) if s.Authoring { row("Authoring", "enabled (pipelines can be published)") } else { row("Authoring", "disabled (execution only)") } fmt.Fprintln(w, "== Backends") opencode := s.OpenCode.Health switch s.OpenCode.Health { case "endpoint": opencode = "attached to " + s.OpenCode.URL case "spawned": opencode = "own instance at " + s.OpenCode.URL case "fallback": opencode = s.OpenCode.URL + " unreachable; using the server's own instance" } row("OpenCode", opencode) if len(s.Chat) == 0 { row("Chat", "unavailable") } else { row("Chat", strings.Join(s.Chat, ", ")) } if s.ClaudeToken { row("Claude", "service token present") } if s.HarnessErr != nil { row("Harnesses", "unreadable: "+s.HarnessErr.Error()) } else if len(s.Harnesses.Profiles) == 0 { row("Harnesses", "none configured") } else { names := make([]string, 0, len(s.Harnesses.Profiles)) for name := range s.Harnesses.Profiles { names = append(names, name) } sort.Strings(names) for _, name := range names { profile := s.Harnesses.Profiles[name] label := "" if name == s.Harnesses.Default { label = "Default" } detail := name if model := firstNonEmpty(profile.PipelineModel, profile.Model); model != "" { detail += " · " + model } if profile.Mode != "" { detail += " · " + profile.Mode } if profile.Executable != "" { detail += " · " + profile.Executable } if label == "" { label = "Harness" } row(label, detail) } } fmt.Fprintln(w, "==") } func firstNonEmpty(values ...string) string { for _, value := range values { if value != "" { return value } } return "" } func printBanner(s startup) { s.Harnesses, s.HarnessErr = harness.List() s.WebURL = os.Getenv("PIPELINES_WEB_PUBLIC_URL") s.ClaudeToken = claude.HasServiceToken() banner(os.Stdout, s) }