59 lines
1.9 KiB
Go
59 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"pipelines/internal/tui"
|
|
)
|
|
|
|
func main() {
|
|
url := flag.String("url", "ws://127.0.0.1:8080/connect", "server WebSocket URL")
|
|
run := flag.Bool("run", false, "Select a registered pipeline and run it in this repository")
|
|
name := flag.String("pipeline", "", "Registered pipeline name; omitted opens fuzzy selection")
|
|
prompt := flag.String("prompt", "", "Task prompt; omitted opens a multiline composer")
|
|
workspace := flag.String("workspace", "", "Repository directory (defaults to current directory with -run)")
|
|
yes := flag.Bool("yes", false, "Start a supplied name/prompt without typing RUN (no implicit tool approval)")
|
|
allow := flag.Bool("allow-tools", false, "Approve declared shell/edit tools with -yes")
|
|
paths := flag.String("write-paths", "", "Comma-separated exact existing project-local Go files")
|
|
flag.Parse()
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
model := tui.New(ctx, *url)
|
|
if *run {
|
|
if *workspace == "" {
|
|
var err error
|
|
*workspace, err = os.Getwd()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
options := tui.RunOptions{Pipeline: *name, Prompt: *prompt, Workspace: *workspace, Yes: *yes, AllowTools: *allow}
|
|
for _, path := range strings.Split(*paths, ",") {
|
|
if path = strings.TrimSpace(path); path != "" {
|
|
options.WritePaths = append(options.WritePaths, path)
|
|
}
|
|
}
|
|
if *yes && (*name == "" || strings.TrimSpace(*prompt) == "") {
|
|
fmt.Fprintln(os.Stderr, "-yes requires -pipeline and a nonempty -prompt")
|
|
os.Exit(2)
|
|
}
|
|
if *yes && len(options.WritePaths) > 0 && !*allow {
|
|
fmt.Fprintln(os.Stderr, "-write-paths with -yes requires -allow-tools")
|
|
os.Exit(2)
|
|
}
|
|
model = tui.NewRun(ctx, *url, options)
|
|
}
|
|
if _, err := tea.NewProgram(model, tea.WithAltScreen()).Run(); err != nil {
|
|
cancel()
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|