Files
pipelines/cmd/pipelines/main.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

96 lines
2.7 KiB
Go

package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"git.a-wan.net/alan/pipelines/internal/author"
"git.a-wan.net/alan/pipelines/internal/cli"
"git.a-wan.net/alan/pipelines/internal/installation"
"os"
"os/signal"
"path/filepath"
"syscall"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()
app := cli.App{Out: os.Stdout, Err: os.Stderr, In: os.Stdin}
args := os.Args[1:]
executable, err := os.Executable()
if len(args) > 0 && args[0] == "skill" {
if len(args) == 2 && args[1] == "install" {
var dir string
dir, err = author.InstallSkill()
if err == nil {
fmt.Println("Installed skill:", dir)
return
}
} else {
err = fmt.Errorf("usage: pipelines skill install")
}
}
if err == nil && len(args) > 0 && args[0] == "service" {
err = installation.ServiceCommand(ctx, executable, args[1:], os.Stdout, os.Stderr)
if err == nil {
return
}
}
var config *installation.Config
if err == nil {
config, err = installation.Load(executable)
}
if err == nil && config != nil {
err = config.Environment()
if err == nil && len(args) > 0 && installation.Service(args[0]) {
err = syscall.Exec(config.Python, append([]string{config.Python, filepath.Join(config.Prefix, "lib/manage.py"), "--prefix", config.Prefix}, args...), os.Environ())
}
if len(args) == 0 {
args = []string{"tui"}
}
}
if err == nil && config == nil && len(args) > 0 && args[0] == "uninstall" {
err = installation.Uninstall(executable, args[1:], os.Stdin, os.Stdout)
if err == nil {
return
}
}
if err == nil && config == nil && len(args) > 0 && args[0] == "serve" {
var server string
server, err = installation.ServerExecutable(executable)
if err == nil {
err = syscall.Exec(server, append([]string{server}, args[1:]...), os.Environ())
}
}
if err == nil && len(args) > 0 && installation.Service(args[0]) {
err = fmt.Errorf("%s is a legacy managed-service command; use pipelines serve, or select an existing installation with PIPELINES_PREFIX", args[0])
}
if err == nil && len(args) == 0 {
args = []string{"tui"}
}
if err == nil {
err = app.Run(ctx, args)
}
if err != nil {
var dispatched *cli.ExitError
if errors.As(err, &dispatched) {
// A dispatched subprocess already streamed its own output.
os.Exit(dispatched.ExitCode())
}
jsonMode := false
for _, arg := range os.Args[1:] {
if arg == "--json" || arg == "-json" || arg == "--json=true" {
jsonMode = true
}
}
if jsonMode {
_ = json.NewEncoder(os.Stderr).Encode(map[string]string{"type": "error", "error": err.Error()})
} else {
fmt.Fprintln(os.Stderr, "pipelines:", err)
}
os.Exit(1)
}
}