package harness import ( "context" "fmt" "os/exec" ) func Command(ctx context.Context, name, directory, prompt, skill string) (*exec.Cmd, error) { c, err := Load() if err != nil { return nil, err } if name == "" { name = c.Default } p, ok := c.Profiles[name] if !ok { return nil, fmt.Errorf("harness %q is not configured; run pipelines harness setup opencode or pi", name) } var args []string switch name { case "opencode": // V2's full CLI has no --model flag. Mini selects it explicitly per session, // without mutating shared OpenCode/project model defaults. args = []string{"mini", "--model", p.Model} if prompt != "" { args = append(args, "--prompt", prompt) } case "pi": args = []string{"--model", p.Model} if skill != "" { args = append(args, "--skill", skill) } if prompt != "" { args = append(args, "--", prompt) } default: return nil, fmt.Errorf("unsupported harness %q", name) } var cmd *exec.Cmd if p.DockerDirectory != "" { prefix := []string{"compose", "--project-directory", p.DockerDirectory, "exec", "--workdir", directory, "pipelines", name} cmd = exec.CommandContext(ctx, "docker", append(prefix, args...)...) } else { cmd = exec.CommandContext(ctx, p.Executable, args...) } cmd.Dir = directory return cmd, nil }