Move harness profiles between host and Docker and stop silent draft retargeting

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.
This commit is contained in:
2026-10-15 19:53:10 +01:00
parent d00bd37833
commit 914345cb31
21 changed files with 732 additions and 141 deletions
+53
View File
@@ -37,6 +37,31 @@ func Path() (string, error) {
return filepath.Join(root, "pipelines", "harnesses.json"), nil
}
// Mode returns the profile's launch mode. A profile with a recorded Docker
// directory launches through that Compose installation; every other profile
// launches the host executable. It is the single mode label shared by setup's
// summary and any caller that reports where a harness runs.
func (p Profile) Mode() string {
if p.DockerDirectory == "" {
return "host"
}
return "Docker-linked (" + p.DockerDirectory + ")"
}
// VerifyDockerLink re-checks that a recorded Docker installation still owns a
// compose.yaml, the same requirement `harness link` enforces when first
// linking. It is the single re-verification used before a Docker-linked profile
// is reconfigured or reported as usable, so a stale link is never silently kept.
func VerifyDockerLink(directory string) error {
if directory == "" {
return fmt.Errorf("no Docker installation directory is recorded; run pipelines harness setup <opencode|pi> --host for a native harness")
}
if _, err := os.Stat(filepath.Join(directory, "compose.yaml")); err != nil {
return fmt.Errorf("recorded Docker installation %s is no longer usable: %w; relink with pipelines harness link <opencode|pi> --docker-directory <checkout>, or switch to a host harness with pipelines harness setup <opencode|pi> --host", directory, err)
}
return nil
}
func ValidModel(value string) bool {
provider, model, ok := strings.Cut(value, "/")
if !ok || provider == "" || model == "" || len(value) > 501 {
@@ -134,6 +159,34 @@ func Save(c Config) error {
return os.Rename(file.Name(), path)
}
// ListView is the JSON shape `harness list` emits. It mirrors Config and adds a
// computed per-profile Mode so callers and scripts can read the launch mode
// without inferring it from docker_directory. The embedded Profile keeps every
// stored field (executable/model/pipeline_model/docker_directory) at the same
// level, so existing consumers such as setup-docker.py's link_host are unaffected.
type ListView struct {
Default string `json:"default"`
Profiles map[string]ProfileView `json:"profiles"`
}
type ProfileView struct {
Profile
Mode string `json:"mode"`
}
// List returns the configured profiles with an explicit launch mode.
func List() (ListView, error) {
c, err := Load()
if err != nil {
return ListView{}, err
}
view := ListView{Default: c.Default, Profiles: map[string]ProfileView{}}
for name, p := range c.Profiles {
view.Profiles[name] = ProfileView{Profile: p, Mode: p.Mode()}
}
return view, nil
}
func Choices() ([]string, string, error) {
c, err := Load()
if err != nil {
+5 -2
View File
@@ -59,14 +59,17 @@ func (o Onboarding) AuthHandoff() {
}
}
// Summary reports the saved choices without implying inference.
func (o Onboarding) Summary(name, harnessModel, pipelineModel, defaultHarness string) {
// 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."))
}
+1 -1
View File
@@ -149,7 +149,7 @@ func TestOnboardingPlainOutputHasHandoffAndSummary(t *testing.T) {
o.Header("pi", "Configure")
o.Versions("OpenCode 2.0.26 · Pi 1.1.0 · Node 22.19.0")
o.AuthHandoff()
o.Summary("pi", "provider/interactive", "provider/stages", "pi")
o.Summary("pi", "provider/interactive", "provider/stages", "pi", "host")
text := out.String()
if strings.Contains(text, "\x1b[") {
t.Fatalf("non-terminal onboarding emitted ANSI: %q", text)