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
+20 -6
View File
@@ -17,11 +17,11 @@ import (
func (a App) harness(ctx context.Context, args []string) error {
if len(args) > 0 && args[0] == "list" {
c, err := harness.Load()
list, err := harness.List()
if err != nil {
return err
}
return a.output(c)
return a.output(list)
}
if len(args) > 0 && args[0] == "default" {
c, err := harness.Load()
@@ -66,7 +66,7 @@ func (a App) harness(ctx context.Context, args []string) error {
if err != nil || *directory == "" {
return fmt.Errorf("Docker installation directory is required")
}
if _, err := os.Stat(filepath.Join(absolute, "compose.yaml")); err != nil {
if err := harness.VerifyDockerLink(absolute); err != nil {
return err
}
c, err := harness.Load()
@@ -88,12 +88,13 @@ func (a App) harness(ctx context.Context, args []string) error {
executable := f.String("executable", "", "Harness executable (defaults to its name)")
login := f.Bool("login", false, "Open the harness login without deleting credentials")
makeDefault := f.Bool("default", false, "Use this harness by default")
host := f.Bool("host", false, "Configure a native host harness and clear any Docker link")
versions := f.String("versions", "", "Verified Docker harness versions to display (from the in-image probe)")
if err := parse(f, args[1:]); err != nil {
return err
}
if len(f.Args()) > 1 {
return fmt.Errorf("usage: pipelines harness setup [opencode|pi] [--login] [--model P/M] [--pipeline-model P/M] [--default]")
return fmt.Errorf("usage: pipelines harness setup [opencode|pi] [--login] [--host] [--model P/M] [--pipeline-model P/M] [--default]")
}
name := ""
if len(f.Args()) == 1 {
@@ -131,9 +132,19 @@ func (a App) harness(ctx context.Context, args []string) error {
if err != nil {
return err
}
existing, exists := c.Profiles[name]
// A profile can move between Docker and host. Without an explicit
// --host selection a Docker-linked profile is only reconfigured when its
// recorded installation is still verifiable; otherwise setup fails
// naming the directory instead of saving a link that cannot launch.
if !*host && exists && existing.DockerDirectory != "" {
if err := harness.VerifyDockerLink(existing.DockerDirectory); err != nil {
return err
}
}
onboarding := harness.NewOnboarding(a.Out)
action := "Configure"
if _, ok := c.Profiles[name]; ok {
if exists {
action = "Reconfigure"
}
onboarding.Header(name, action)
@@ -211,6 +222,9 @@ func (a App) harness(ctx context.Context, args []string) error {
}
profile := c.Profiles[name]
profile.Executable, profile.Model, profile.PipelineModel = *executable, *model, *pipelineModel
if *host {
profile.DockerDirectory = ""
}
c.Profiles[name] = profile
if *makeDefault || c.Default == "" {
c.Default = name
@@ -218,7 +232,7 @@ func (a App) harness(ctx context.Context, args []string) error {
if err = harness.Save(c); err != nil {
return err
}
onboarding.Summary(name, *model, *pipelineModel, c.Default)
onboarding.Summary(name, *model, *pipelineModel, c.Default, c.Profiles[name].Mode())
return nil
}
name := ""