Merge lane-go: titles, verdicts, human stage, line result format, stale-client guard
Integrates nine commits of reviewed work from the lane-go branch after the automated resolver failed on this merge five times (each attempt dying on the malformed-result defect whose fix is contained in this same merge). Integration decisions: - Search: kept main's shipped design (Store.Search + SearchResponse.Results) and dropped lane-go's parallel, older attempt (an unused Message.Matches field, an absent runs.search, and two partial TUI plumbing blocks). lane-go itself did not compile: protocol.SearchMatch was undefined and model.go referenced searchNav, requestSearch and applyRunNav, which exist nowhere. Those partial TUI blocks are removed; the queued TUI omni-search item will implement the surface properly on main's design. - Both sides' additions are kept where they are independent: run titles and provenance, the human decision stage and its CLI/TUI surface, the derived stage verdict, the stale-client guard, the line-oriented result format, and main's search command. - The search key's help label is now "/ omni search"; the two tests asserting the old label are updated rather than the label reverted. - docs/cli.md and the packaged operations reference carry both sides' text. Verified: go build ./... , go vet ./... and the full go test ./... suite pass.
This commit is contained in:
+113
-12
@@ -33,15 +33,16 @@ type App struct {
|
||||
In io.Reader
|
||||
}
|
||||
type options struct {
|
||||
harness string
|
||||
url, name, prompt, template, workspace, paths, key, opencode, model string
|
||||
output string
|
||||
conflict string
|
||||
kind string
|
||||
all bool
|
||||
json, source, noOpen, yes, allow, createOnly, force, wait bool
|
||||
version, expected, limit int
|
||||
timeout, waitTimeout time.Duration
|
||||
harness string
|
||||
url, name, prompt, title, template, workspace, paths, key, opencode, model string
|
||||
option, feedback string
|
||||
output string
|
||||
conflict string
|
||||
kind string
|
||||
all bool
|
||||
json, source, noOpen, yes, allow, createOnly, force, wait bool
|
||||
version, expected, limit int
|
||||
timeout, waitTimeout time.Duration
|
||||
}
|
||||
|
||||
func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
@@ -90,6 +91,7 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
case "run":
|
||||
f.StringVar(&o.name, "pipeline", "", "Exact registered pipeline name or ID")
|
||||
f.StringVar(&o.prompt, "prompt", "", "Task prompt; omitted opens a multiline composer")
|
||||
f.StringVar(&o.title, "title", "", "Explicit run title; default is derived from the prompt")
|
||||
f.StringVar(&o.workspace, "workspace", "", "Run directory (default: current directory)")
|
||||
f.BoolVar(&o.yes, "yes", false, "Confirm execution without an interactive prompt")
|
||||
f.BoolVar(&o.allow, "allow-tools", false, "Compatibility flag; stage-declared tools are enabled automatically")
|
||||
@@ -110,6 +112,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.DurationVar(&o.waitTimeout, "wait-timeout", 0, "Client limit for --wait (0 waits until the run ends); independent of --timeout")
|
||||
case "cancel", "draft-delete":
|
||||
f.BoolVar(&o.yes, "yes", false, "Confirm this action without an interactive prompt")
|
||||
case "decide":
|
||||
f.StringVar(&o.option, "option", "", "Option key to choose among the waiting stage's edges (required)")
|
||||
f.StringVar(&o.feedback, "feedback", "", "Optional free-text feedback recorded with the decision")
|
||||
case "debug":
|
||||
f.StringVar(&o.harness, "harness", "", "Debugging harness: configured opencode/pi, or nvim")
|
||||
f.BoolVar(&o.yes, "yes", false, "Approve opening a debugging session without prompting")
|
||||
@@ -145,6 +150,18 @@ func envOr(key, value string) string {
|
||||
return value
|
||||
}
|
||||
|
||||
// recordedFeedback returns the feedback the server actually stored for the
|
||||
// decided step that carries the chosen option, so a repeated (idempotent)
|
||||
// decision reports the recorded evidence rather than the ignored request text.
|
||||
func recordedFeedback(detail *protocol.RunDetail, option string) string {
|
||||
for i := len(detail.Steps) - 1; i >= 0; i-- {
|
||||
if chosen, feedback := protocol.DecisionEvidence(detail.Steps[i].Output); chosen == option {
|
||||
return strings.TrimSpace(feedback)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// parse allows flags before or after positional arguments without reinterpreting values.
|
||||
func parse(f *flag.FlagSet, args []string) error {
|
||||
var flags, positionals []string
|
||||
@@ -391,6 +408,13 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
return err
|
||||
}
|
||||
defer c.Close()
|
||||
// Report at most one build/protocol warning per invocation on stderr, so
|
||||
// stdout stays parseable JSON; an unsafe newer server fails the command.
|
||||
c.Report(func(relationship buildinfo.Relationship) {
|
||||
if relationship.Message != "" {
|
||||
a.notice("warning: " + relationship.Message)
|
||||
}
|
||||
})
|
||||
call := func(request protocol.Message) (protocol.Message, error) {
|
||||
requestCtx, cancel := context.WithTimeout(ctx, o.timeout)
|
||||
defer cancel()
|
||||
@@ -662,7 +686,7 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
}
|
||||
case "runs":
|
||||
for _, run := range r.Runs {
|
||||
fmt.Fprintf(a.Out, "%d\t%s\tv%d\t%s\n", run.ID, run.Name, run.Version, run.Status)
|
||||
fmt.Fprintf(a.Out, "%d\t%s\t%s\tv%d\t%s\n", run.ID, run.Label(), run.Name, run.Version, run.Status)
|
||||
}
|
||||
case "ping":
|
||||
fmt.Fprintln(a.Out, "Connected ·", r.Time)
|
||||
@@ -671,11 +695,19 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
} else {
|
||||
fmt.Fprintln(a.Out, "Server build: unavailable (older server)")
|
||||
}
|
||||
build := buildinfo.Current()
|
||||
fmt.Fprintf(a.Out, "Client: %s (commit %s)\n", build.Version, build.Commit)
|
||||
if note := identityNote(r); note != "" {
|
||||
fmt.Fprintln(a.Out, "Note:", note)
|
||||
}
|
||||
case "connection":
|
||||
fmt.Fprintln(a.Out, "Server:", o.url)
|
||||
for _, n := range r.NotificationEndpoints {
|
||||
fmt.Fprintf(a.Out, "ntfy: %s · topic %s\n", n.ServerURL, n.Topic)
|
||||
}
|
||||
if note := identityNote(r); note != "" {
|
||||
fmt.Fprintln(a.Out, "Note:", note)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "export":
|
||||
@@ -806,6 +838,58 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
return a.output(r.RunDetail)
|
||||
case "decide":
|
||||
if len(pos) < 1 || len(pos) > 2 {
|
||||
return fmt.Errorf("decide requires a run ID and an optional stage key")
|
||||
}
|
||||
id, err := strconv.ParseInt(pos[0], 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return fmt.Errorf("run ID must be positive")
|
||||
}
|
||||
option := strings.TrimSpace(o.option)
|
||||
if option == "" {
|
||||
return fmt.Errorf("decide requires --option KEY")
|
||||
}
|
||||
stageKey := ""
|
||||
if len(pos) == 2 {
|
||||
stageKey = pos[1]
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.DecideRun, RunID: id, Stage: stageKey, Option: option, Feedback: o.feedback})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r.RunDetail == nil {
|
||||
return fmt.Errorf("server did not return run detail")
|
||||
}
|
||||
if o.json {
|
||||
return a.output(r.RunDetail)
|
||||
}
|
||||
line := fmt.Sprintf("Decided run #%d: %s · %s", r.RunDetail.ID, option, r.RunDetail.Status)
|
||||
if feedback := recordedFeedback(r.RunDetail, option); feedback != "" {
|
||||
line += " · feedback: " + feedback
|
||||
}
|
||||
_, err = fmt.Fprintln(a.Out, line)
|
||||
return err
|
||||
case "title":
|
||||
if len(pos) != 2 {
|
||||
return fmt.Errorf("title requires a run ID and a title")
|
||||
}
|
||||
id, err := strconv.ParseInt(pos[0], 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return fmt.Errorf("run ID must be positive")
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.SetRunTitle, RunID: id, Title: pos[1]})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r.RunDetail == nil {
|
||||
return fmt.Errorf("server did not return run detail")
|
||||
}
|
||||
if o.json {
|
||||
return a.output(r.RunDetail)
|
||||
}
|
||||
_, err = fmt.Fprintf(a.Out, "Renamed run #%d to %s\n", r.RunDetail.ID, r.RunDetail.Label())
|
||||
return err
|
||||
case "rpc":
|
||||
path, err := one()
|
||||
if err != nil {
|
||||
@@ -868,6 +952,23 @@ func searchLabel(hit protocol.SearchResult) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// notice writes one non-fatal line to stderr so machine-readable stdout stays
|
||||
// intact. It never falls back to stdout, where it could corrupt --json output
|
||||
// for an embedder that does not configure Err.
|
||||
func (a App) notice(line string) {
|
||||
w := a.Err
|
||||
if w == nil {
|
||||
w = os.Stderr
|
||||
}
|
||||
fmt.Fprintln(w, line)
|
||||
}
|
||||
|
||||
// identityNote describes how this client build relates to a server response for
|
||||
// human output; it is empty when both peers match.
|
||||
func identityNote(response protocol.Message) string {
|
||||
return buildinfo.Compare(buildinfo.Current(), protocol.MaxSupportedProtocol, response.Protocol, response.Build).Message
|
||||
}
|
||||
|
||||
type callFunc func(protocol.Message) (protocol.Message, error)
|
||||
type resolveFunc func(string) (protocol.PipelineSummary, error)
|
||||
|
||||
@@ -1044,7 +1145,7 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
|
||||
if o.wait || o.key != "" || o.version > 0 {
|
||||
return fmt.Errorf("--wait, --request-key and --version require --json")
|
||||
}
|
||||
_, err := tea.NewProgram(tui.NewRun(ctx, o.url, tui.RunOptions{Pipeline: o.name, Prompt: o.prompt, Workspace: workspace, Yes: o.yes, AllowTools: o.allow, WritePaths: paths}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
|
||||
_, err := tea.NewProgram(tui.NewRun(ctx, o.url, tui.RunOptions{Pipeline: o.name, Prompt: o.prompt, Title: o.title, Workspace: workspace, Yes: o.yes, AllowTools: o.allow, WritePaths: paths}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
|
||||
return err
|
||||
}
|
||||
if o.name == "" || strings.TrimSpace(o.prompt) == "" {
|
||||
@@ -1065,7 +1166,7 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
|
||||
if key == "" {
|
||||
key = fmt.Sprintf("cli-%d-%d", os.Getpid(), time.Now().UnixNano())
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.RunPipeline, PipelineID: p.ID, Version: version, RequestKey: key, Workspace: workspace, Input: map[string]any{"prompt": o.prompt}, AllowTools: o.allow, WritePaths: paths})
|
||||
r, err := call(protocol.Message{Type: protocol.RunPipeline, PipelineID: p.ID, Version: version, RequestKey: key, Workspace: workspace, Title: o.title, Input: map[string]any{"prompt": o.prompt}, AllowTools: o.allow, WritePaths: paths})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user