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.
73 lines
2.7 KiB
Go
73 lines
2.7 KiB
Go
package runinspect
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
)
|
|
|
|
func TestDebugLaunchIsFreshAndQueriesExactRunAndVersion(t *testing.T) {
|
|
root := t.TempDir()
|
|
workspace := filepath.Join(root, "project")
|
|
os.Mkdir(workspace, 0700)
|
|
capture := filepath.Join(root, "capture")
|
|
t.Setenv("DEBUG_CAPTURE", capture)
|
|
fake := filepath.Join(root, "opencode")
|
|
os.WriteFile(fake, []byte("#!/bin/sh\npwd > \"$DEBUG_CAPTURE\"\nprintf '%s\\n' \"$@\" >> \"$DEBUG_CAPTURE\"\n"), 0700)
|
|
d := New(&protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 7, PipelineID: 4, Version: 2}, Workspace: workspace}, "/bin/pipelines --url 'ws://example/connect'")
|
|
for _, text := range []string{"inspect 7 --json", "show 4 --version 2 --json", "runs --pipeline 4 --json", "ws://example/connect", "NEW debugging conversation"} {
|
|
if !strings.Contains(d.Prompt, text) {
|
|
t.Fatal("debug context omitted authoritative query", text)
|
|
}
|
|
}
|
|
cmd := d.Command(context.Background(), fake)
|
|
if len(cmd.Args) != 3 || cmd.Args[1] != "--prompt" || cmd.Dir != workspace {
|
|
t.Fatal("debug resumed a session or lost workspace", cmd.Args, cmd.Dir)
|
|
}
|
|
if err := cmd.Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
data, err := os.ReadFile(capture)
|
|
if err != nil || !strings.Contains(string(data), d.Prompt) {
|
|
t.Fatal("OpenCode launch did not receive debug prompt", err)
|
|
}
|
|
d.Workspace = filepath.Join(root, "missing")
|
|
if cmd := d.Command(context.Background(), fake); cmd.Dir != "" {
|
|
t.Fatal("historical debugging requires deleted workspace")
|
|
}
|
|
}
|
|
|
|
func TestLargeDebugContextIsRetainedWithoutArgumentOverflow(t *testing.T) {
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
d := New(&protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 42, Diagnostic: "provider failure"}, Input: map[string]any{"prompt": strings.Repeat("original task", 20000)}}, "/bin/pipelines --url 'ws://example/connect'")
|
|
if !strings.Contains(d.Prompt, "original task") {
|
|
t.Fatal("large run snapshot discarded")
|
|
}
|
|
prepared, err := d.Prepare()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if prepared.ContextFile == "" || len(prepared.Prompt) > 64<<10 {
|
|
t.Fatal("packet was not materialized", len(prepared.Prompt))
|
|
}
|
|
contents, err := os.ReadFile(prepared.ContextFile)
|
|
if err != nil || string(contents) != d.Prompt {
|
|
t.Fatal("packet lost evidence", err)
|
|
}
|
|
info, err := os.Stat(prepared.ContextFile)
|
|
if err != nil || info.Mode().Perm() != 0600 {
|
|
t.Fatal("packet is not private", err)
|
|
}
|
|
fake := filepath.Join(t.TempDir(), "opencode")
|
|
if err = os.WriteFile(fake, []byte("#!/bin/sh\nexit 0\n"), 0700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = prepared.Command(context.Background(), fake).Run(); err != nil {
|
|
t.Fatal("large-context launch failed", err)
|
|
}
|
|
}
|