914345cb31
Native installs left Docker-era harness profiles in harnesses.json, so every authoring launch failed trying to reach a Docker service, and a retained draft bound to the old Docker server was silently projected onto the configured one. - harness: add Profile.Mode and VerifyDockerLink as the single mode/verification helpers. `harness setup --host` configures or converts a host profile and clears docker_directory; reconfiguring a Docker-linked profile re-verifies the recorded directory still owns compose.yaml and fails naming it instead of saving a link that cannot launch. Setup's summary and `harness list` (via the new List/ListView shape) report the resulting mode and, for Docker, the directory, without changing the stored Config schema. - setup-native.py: after build/install-skill it writes host (no docker_directory) profiles for the detected harnesses, defaulting to the detected OpenCode profile rather than a stale pi default, taking models from --model or the existing valid profile and never inventing one; it clears a stale Docker link and preserves unrelated keys/profiles. Detection-only: no harness install, upgrade or download. - draft: add Draft.Resolve, the shared mismatch helper, which projects a draft onto the configured server and returns a dual-URL notice. CLI validate/submit and the TUI draft browser use it so a foreign draft is never silently retargeted; the TUI pre-wraps the notice to the panel width. - Tests cover the Docker->host and host->host transitions, the missing-directory failure, installer write/migration (Python), and the CLI/TUI notice, using the real config file path in a temp dir. - Update help text, README, docs and the packaged authoring skill reference to describe host as the default and the Docker-linked case.
87 lines
3.2 KiB
Go
87 lines
3.2 KiB
Go
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 (<directory>)") 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
|
|
}
|
|
}
|