Install shared authoring skill and add retained drafts browser
This commit is contained in:
+6
-21
@@ -1,7 +1,6 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -9,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -47,7 +45,7 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.StringVar(&o.name, "name", "", "Pipeline name (or edit ID)")
|
||||
f.StringVar(&o.prompt, "prompt", "", "Request to give OpenCode; omitted asks what to change")
|
||||
f.BoolVar(&o.noOpen, "no-open", false, "Create the draft without opening OpenCode")
|
||||
f.StringVar(&o.opencode, "opencode", envOr("PIPELINES_OPENCODE", "opencode"), "Host OpenCode V2 executable")
|
||||
f.StringVar(&o.opencode, "opencode", envOr("PIPELINES_OPENCODE", "opencode"), "Host OpenCode executable")
|
||||
if command == "new" {
|
||||
f.StringVar(&o.template, "template", "", "Optional template key; omitted starts a one-stage draft")
|
||||
}
|
||||
@@ -521,14 +519,8 @@ func (a App) author(ctx context.Context, command string, pos []string, o *option
|
||||
if o.json || o.noOpen {
|
||||
return fmt.Errorf("new requires a name in noninteractive mode")
|
||||
}
|
||||
fmt.Fprint(a.Err, "New pipeline name: ")
|
||||
name, err := bufio.NewReader(a.In).ReadString('\n')
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.name = strings.TrimSpace(name)
|
||||
}
|
||||
if strings.TrimSpace(o.name) == "" || len(o.name) > 200 || strings.ContainsAny(o.name, "\r\n\x00") {
|
||||
if (o.name != "" && strings.TrimSpace(o.name) == "") || len(o.name) > 200 || strings.ContainsAny(o.name, "\r\n\x00") {
|
||||
return fmt.Errorf("name must be 1–200 bytes without line breaks or NUL")
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.List})
|
||||
@@ -570,23 +562,16 @@ func (a App) author(ctx context.Context, command string, pos []string, o *option
|
||||
if o.noOpen {
|
||||
return nil
|
||||
}
|
||||
workspace, err := author.Workspace(d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
prepareCtx, cancel := context.WithTimeout(ctx, o.timeout)
|
||||
session, err := author.PrepareSession(prepareCtx, o.opencode, workspace, d.Name)
|
||||
cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Give the agent a directly executable command even in an uninstalled source tree.
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cliCommand := shellQuote(executable) + " --url " + shellQuote(o.url)
|
||||
cmd := exec.CommandContext(ctx, o.opencode, workspace, "--session", session, "--prompt", author.Prompt(d, o.prompt, cliCommand))
|
||||
cmd, err := author.Command(ctx, o.opencode, d, o.prompt, cliCommand)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.Stdin = a.In
|
||||
cmd.Stdout = a.Out
|
||||
cmd.Stderr = a.Err
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.a-wan.net/alan/pipelines/internal/author"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -139,7 +140,11 @@ func TestCLIDraftValidateSubmitAndImmutableHistory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCLIAuthorOpenCodeGetsScopedSkillAndLeavesDraft(t *testing.T) {
|
||||
func TestCLIAuthorOpenCodeReferencesGlobalSkillAndLeavesDraft(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
if _, err := author.InstallSkill(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
run, store, _ := setup(t)
|
||||
// A fake executable captures launch behavior without spending model tokens.
|
||||
root := t.TempDir()
|
||||
@@ -154,13 +159,18 @@ func TestCLIAuthorOpenCodeGetsScopedSkillAndLeavesDraft(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
parts := strings.SplitN(string(data), "\n", 3)
|
||||
if parts[1] != "--session" || !strings.Contains(parts[2], "ses_test\n--prompt\n@pipelines") || !strings.Contains(parts[2], "Make a digest") {
|
||||
if parts[1] != "--prompt" || !strings.HasPrefix(parts[2], "@pipelines") || !strings.Contains(parts[2], "Make a digest") {
|
||||
t.Fatal(string(data))
|
||||
}
|
||||
for _, name := range []string{"DRAFT.json", ".opencode/skills/pipelines/SKILL.md", ".opencode/skills/pipelines/references/format.md"} {
|
||||
if _, err := os.Stat(filepath.Join(parts[0], name)); err != nil {
|
||||
t.Fatal(name, err)
|
||||
}
|
||||
skillDir, err := author.SkillDirectory()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(skillDir, "SKILL.md")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := run("new", "--opencode", script); err != nil {
|
||||
t.Fatal("unnamed draft should go straight to OpenCode", err)
|
||||
}
|
||||
items, _ := store.List(context.Background())
|
||||
if len(items) != 0 {
|
||||
|
||||
@@ -24,7 +24,7 @@ var usage = map[string]string{
|
||||
}
|
||||
|
||||
var notes = map[string]string{
|
||||
"new": "Create an optional template copy or a one-stage starter. Opens OpenCode with the pipeline skill already loaded. No submission is performed.",
|
||||
"new": "Create an optional template copy or a one-stage starter. Opens OpenCode with @pipelines; the skill asks any missing questions, including the name. No submission is performed.",
|
||||
"edit": "Omit the name to open fuzzy selection. Original immutable source is copied to a private draft. OpenCode edits that draft, never the live definition.",
|
||||
"validate": "Uses the same server parser as submission. Does not persist or activate schedules. Structural validity does not prove runtime/tool availability.",
|
||||
"submit": "This command is explicit approval to publish; schedules activate on acceptance. Managed drafts provide the name and base-version guard. --force never bypasses validation.",
|
||||
@@ -33,6 +33,7 @@ var notes = map[string]string{
|
||||
}
|
||||
|
||||
var serviceHelp = map[string]string{
|
||||
"skill": "pipelines skill install installs/updates the bundled global OpenCode skill without changing login/config or user-modified skills. install.sh includes this step.",
|
||||
"service": "Configure per-user OS autostart: pipelines service enable. Runs use the directory you invoke pipelines run from. Use --print to preview, service status to inspect, and service disable before uninstalling. Linux uses systemd; macOS uses launchd. No sudo.",
|
||||
"serve": "Run the native server in the foreground. Its flags are documented by pipelines serve --help. Installation never starts it automatically.",
|
||||
"start": "Start the per-user native pipeline server and this installation's Docker ntfy together.",
|
||||
|
||||
@@ -33,6 +33,7 @@ SERVER / INTERFACE
|
||||
serve Start native server in the foreground (Ctrl+C stops it)
|
||||
service enable Configure user autostart
|
||||
service disable | status Stop/remove autostart, or inspect OS service status
|
||||
skill install Install/update the shared OpenCode authoring skill
|
||||
uninstall [--yes] Remove verified Go binaries; retain data and drafts
|
||||
|
||||
Legacy managed installs: select PIPELINES_PREFIX explicitly for start/stop,
|
||||
|
||||
Reference in New Issue
Block a user