Files
pipelines/internal/author/author.go
T
alan c42a19f7d3 Improve workflow UI, retain stage diffs, and add portable pipeline transfers
Make OpenCode authoring responsive and expand the managed skill references. Add conflict-aware import/export, real-provider reference workflows, and tracked V2 generation for reliable budget accounting.
2026-10-10 20:55:42 +01:00

51 lines
1.6 KiB
Go

package author
import (
"context"
"embed"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"git.a-wan.net/alan/pipelines/internal/draft"
)
//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
}