Files
pipelines/internal/author/author.go
T
alan 05ae530442 Make Pipelines Docker-only with OpenCode and Pi
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.
2026-10-11 23:00:25 +01:00

78 lines
2.3 KiB
Go

package author
import (
"context"
"embed"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"git.a-wan.net/alan/pipelines/internal/draft"
"git.a-wan.net/alan/pipelines/internal/harness"
)
//go:embed skill/SKILL.md skill/references/*.md
var content embed.FS
// Command launches the normal CLI directly. Skill loading and questions belong
// to OpenCode; no session/API/backend discovery is performed before launch.
func Command(ctx context.Context, executable string, d draft.Draft, request, cli string) (*exec.Cmd, error) {
dir, err := SkillDirectory()
if err != nil {
return nil, err
}
if _, err := os.Stat(filepath.Join(dir, "SKILL.md")); err != nil {
return nil, fmt.Errorf("pipelines skill is not installed; run pipelines skill install: %w", err)
}
cwd, err := os.Getwd()
if err != nil {
return nil, err
}
cmd := exec.CommandContext(ctx, executable, cwd, "--prompt", Prompt(d, request, cli))
cmd.Dir = cwd
return cmd, nil
}
func Prompt(d draft.Draft, request, command string) string {
prompt := fmt.Sprintf("@pipelines\nDraft context: %q\nCLI: %s", d.Path+".json", command)
if strings.TrimSpace(request) != "" {
prompt += "\nRequest: " + request
prompt += "\nFirst response: briefly acknowledge the request, then read only the draft and relevant authoring references."
} else {
task := "What should this pipeline do?"
if !d.CreateOnly && d.BaseVersion > 0 {
task = "What would you like to change in this pipeline?"
}
prompt += "\nFirst response: ask the user " + fmt.Sprintf("%q", task) + " before reading files or running commands. Load the skill if needed; do not investigate before asking."
}
return prompt
}
func HarnessCommand(ctx context.Context, name string, d draft.Draft, request, cli string) (*exec.Cmd, error) {
skill, err := SkillDirectory()
if err != nil {
return nil, err
}
if _, err := os.Stat(filepath.Join(skill, "SKILL.md")); err != nil {
return nil, fmt.Errorf("pipelines skill is not installed; run pipelines skill install: %w", err)
}
cwd, err := os.Getwd()
if err != nil {
return nil, err
}
prompt := Prompt(d, request, cli)
config, err := harness.Load()
if err != nil {
return nil, err
}
if name == "" {
name = config.Default
}
if name == "pi" {
prompt = strings.Replace(prompt, "@pipelines", "/skill:pipelines", 1)
}
return harness.Command(ctx, name, cwd, prompt, skill)
}