05ae530442
Install current verified harness releases inside Docker, preserve persistent accounts and settings, and provide separate interactive and pipeline model defaults with terminal onboarding and fuzzy pickers. Add Docker-aware authoring transport, Pi stage execution, bounded workflow controls, reliable final-result readback and usage settlement, and finite short-lived CLI pipe draining. Keep dated installation evidence and packaged authoring guidance consistent. Verified with a real Docker installation, both harness stages and interactive authors, the built-in plan/implement/review starter, independent host race/vet checks, installer tests, and packaged skill tests. Generated release receipts stay ignored in clean checkouts.
71 lines
2.4 KiB
Go
71 lines
2.4 KiB
Go
package harness
|
|
|
|
import (
|
|
"context"
|
|
"github.com/charmbracelet/bubbles/textinput"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestConfigurationAndLaunch(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "harnesses.json")
|
|
t.Setenv("PIPELINES_HARNESS_CONFIG", path)
|
|
if _, err := Command(context.Background(), "", "/workspace", "", ""); err == nil {
|
|
t.Fatal("unconfigured launch permitted")
|
|
}
|
|
if err := os.WriteFile(path, []byte(`{"future":"preserve"}`), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
c := Config{Default: "pi", Profiles: map[string]Profile{"pi": {Executable: "custom-pi", Model: "a/interactive", PipelineModel: "b/stages"}, "opencode": {Executable: "opencode", Model: "c/model", PipelineModel: "c/model"}}}
|
|
if err := Save(c); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
loaded, err := Load()
|
|
if err != nil || loaded.Profiles["pi"].PipelineModel != "b/stages" {
|
|
t.Fatal(loaded, err)
|
|
}
|
|
data, _ := os.ReadFile(path)
|
|
if !strings.Contains(string(data), "preserve") {
|
|
t.Fatal("discarded unrelated setting")
|
|
}
|
|
choices, def, err := Choices()
|
|
if err != nil || def != "pi" || choices[0] != "pi" {
|
|
t.Fatal(choices, def, err)
|
|
}
|
|
cmd, err := Command(context.Background(), "", "/workspace", "task", "/skill")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if strings.Join(cmd.Args, "|") != "custom-pi|--model|a/interactive|--skill|/skill|--|task" || cmd.Dir != "/workspace" {
|
|
t.Fatal(cmd.Args, cmd.Dir)
|
|
}
|
|
c.Profiles["opencode"] = Profile{Executable: "opencode", Model: "c/model", PipelineModel: "c/model", DockerDirectory: "/checkout"}
|
|
if err := Save(c); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cmd, err = Command(context.Background(), "opencode", "/workspace", "task", "")
|
|
if err != nil || strings.Join(cmd.Args, "|") != "docker|compose|--project-directory|/checkout|exec|--workdir|/workspace|pipelines|opencode|mini|--model|c/model|--prompt|task" {
|
|
t.Fatal(cmd, err)
|
|
}
|
|
}
|
|
|
|
func TestFuzzyPickerSelectionAndCancellation(t *testing.T) {
|
|
q := textinput.New()
|
|
q.SetValue("dskfl")
|
|
p := picker{options: []string{"other/model", "opencode-go/deepseek-flash"}, query: q}
|
|
if got := p.matches(); len(got) != 1 || got[0] != "opencode-go/deepseek-flash" {
|
|
t.Fatal(got)
|
|
}
|
|
model, _ := p.Update(tea.KeyMsg{Type: tea.KeyEnter})
|
|
if model.(picker).selected != "opencode-go/deepseek-flash" {
|
|
t.Fatal(model)
|
|
}
|
|
model, _ = p.Update(tea.KeyMsg{Type: tea.KeyEsc})
|
|
if !model.(picker).canceled {
|
|
t.Fatal("escape ignored")
|
|
}
|
|
}
|