package harness import ( "fmt" "io" "strings" ) // Onboarding renders the styled, non-interactive presentation for // `pipelines harness setup`. It shares the picker's style vocabulary, performs no // inference or network access, and is used by both fresh setup and reconfiguration // so the two paths never duplicate presentation logic. type Onboarding struct { out io.Writer plain bool } func NewOnboarding(out io.Writer) Onboarding { return Onboarding{out: out, plain: plainOutput() || !isTerminal(out)} } func (o Onboarding) styles() pickerStyles { return pickerStyles{plain: o.plain} } // Header introduces a harness configuration session. func (o Onboarding) Header(name, action string) { s := o.styles() fmt.Fprintln(o.out) fmt.Fprintln(o.out, s.title("Pipelines harness setup")) fmt.Fprintln(o.out, s.muted(action+" ยท "+DisplayName(name))) fmt.Fprintln(o.out) } // Versions prints the Docker harness versions already verified by the single // in-image probe, so setup never runs another subprocess just to show them. func (o Onboarding) Versions(versions string) { if strings.TrimSpace(versions) == "" { return } fmt.Fprintf(o.out, "%s %s\n\n", o.styles().muted("Docker image harnesses:"), versions) } // AuthHandoff explains exactly how Pi's in-session sign-in works. Pi has no // standalone `auth login` command, so we open a fresh, no-context, // extension-free, no-tools session and never inject a coding/task prompt or // scripted keys. The copy is deliberately a few short lines so the Pipelines // header and this handoff stay visible above Pi's regular interface at 80x30; // it names Pi's real authentication-method step and exit keys, notes that // existing sign-ins can be reused in the Docker volume, and makes the API-key // choice conditional on using provider API credentials. func (o Onboarding) AuthHandoff() { s := o.styles() fmt.Fprintln(o.out, s.title("Pi sign-in")) for _, line := range []string{ "Existing credentials stay; exit to reuse them. Type /login.", "Choose an authentication method (account/API key/Radius).", "Finish provider sign-in (API: \"Sign in with an API key\"); exit ctrl+c/ctrl+d.", } { fmt.Fprintln(o.out, s.muted(line)) } } // Summary reports the saved choices without implying inference. Mode is the // resulting launch mode ("host" or "Docker-linked ()") so a setup run // always states where the harness will actually run. func (o Onboarding) Summary(name, harnessModel, pipelineModel, defaultHarness, mode string) { s := o.styles() fmt.Fprintln(o.out) fmt.Fprintln(o.out, s.title("Configuration complete")) fmt.Fprintf(o.out, " %s %s\n", s.muted("Interactive "+DisplayName(name)+" model:"), s.step(harnessModel)) fmt.Fprintf(o.out, " %s %s\n", s.muted("New "+DisplayName(name)+" pipeline model:"), s.step(pipelineModel)) fmt.Fprintf(o.out, " %s %s\n", s.muted("Default harness:"), s.step(defaultHarness)) fmt.Fprintf(o.out, " %s %s\n", s.muted("Launch mode:"), s.step(mode)) fmt.Fprintln(o.out, s.muted(" No inference was performed; published workflows and drafts were not rewritten.")) } // DisplayName returns the human-facing name of a configured harness. func DisplayName(name string) string { switch name { case "opencode": return "OpenCode" case "pi": return "Pi" default: return name } }