Merge lane-go: keep the lane's reviewed work
Combines lane-go's typed omni search, launch-time model overrides, TUI artifacts view, run-state websocket push, and the "reflect the change where it belongs" committer rule with the Templates gallery, chat/omni-search and other reviewed work already on main. The 12 files both sides touched keep both intents composed rather than dropping either side: the omni search keeps the typed search contract (CLI `pipelines search` and the TUI popup with type badges and marked snippets) alongside the run-list quick filter; cli.md and ui-ux-review.md document both the search rework and the artifacts view; orchestration.md, harnesses.md and operations.md keep the model-override and reflect-where-it-belongs guidance; and the protocol/CLI/server/TUI code keeps the new search, run-event, override and artifacts paths alongside the existing run, title and help surfaces. Checks before committing: - go build ./... -- pass - go vet ./... -- pass - go test -count=1 ./internal/... ./cmd/... -- all pass Doc check before committing: nothing needs updating. The lane's own docs and references (docs/cli.md, docs/ui-ux-review.md, and the orchestration, harnesses and operations skill references) already carry the new features. format.md and the packaged templates already describe the line-oriented result format and the human decision stage from the earlier lane-go merge. The root README already describes the omni search popup. Model overrides, the search command, run events and the artifacts view are runtime/CLI/TUI surfaces that cli.md documents; no template, README or topic-doc edit is required by this merge.
This commit is contained in:
+83
-26
@@ -10,6 +10,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -43,6 +44,41 @@ type options struct {
|
||||
json, source, noOpen, yes, allow, createOnly, force, wait bool
|
||||
version, expected, limit int
|
||||
timeout, waitTimeout time.Duration
|
||||
stageModels stageModelFlags
|
||||
}
|
||||
|
||||
// stageModelFlags collects the repeatable --stage-model STAGE=PROVIDER/MODEL
|
||||
// values. A repeated key is last-wins. It is a flag.Value so the repeatable flag
|
||||
// needs no dependency (Go stdlib has no slice flag).
|
||||
type stageModelFlags map[string]string
|
||||
|
||||
// String renders the collected overrides for flag's defaults display.
|
||||
func (s stageModelFlags) String() string {
|
||||
keys := make([]string, 0, len(s))
|
||||
for key := range s {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
parts := make([]string, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
parts = append(parts, key+"="+s[key])
|
||||
}
|
||||
return strings.Join(parts, ",")
|
||||
}
|
||||
|
||||
// Set parses one STAGE=PROVIDER/MODEL value and validates the provider/model with
|
||||
// the shared parser, so a malformed value fails before any run is created.
|
||||
func (s stageModelFlags) Set(value string) error {
|
||||
key, model, ok := strings.Cut(value, "=")
|
||||
key, model = strings.TrimSpace(key), strings.TrimSpace(model)
|
||||
if !ok || key == "" || model == "" {
|
||||
return fmt.Errorf("--stage-model requires STAGE=PROVIDER/MODEL")
|
||||
}
|
||||
if _, err := pipeline.ParseModelOverride(model); err != nil {
|
||||
return fmt.Errorf("--stage-model %s: %w", key, err)
|
||||
}
|
||||
s[key] = model
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
@@ -98,6 +134,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.StringVar(&o.paths, "write-paths", "", "Optional narrower edit scope; default is all files in the run directory")
|
||||
f.StringVar(&o.key, "request-key", "", "Idempotency key (default: generated unique key)")
|
||||
f.IntVar(&o.version, "version", 0, "Version to run (default: latest)")
|
||||
f.StringVar(&o.model, "model", "", "Override the model for every stage of this run (PROVIDER/MODEL)")
|
||||
o.stageModels = stageModelFlags{}
|
||||
f.Var(o.stageModels, "stage-model", "Override one stage's model; repeatable (STAGE=PROVIDER/MODEL); beats --model")
|
||||
f.BoolVar(&o.wait, "wait", false, "In JSON mode, wait for a terminal run state")
|
||||
f.DurationVar(&o.waitTimeout, "wait-timeout", 0, "Client limit for --wait after the run is admitted (0 waits until terminal); separate from per-request --timeout")
|
||||
case "runs":
|
||||
@@ -278,10 +317,11 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
if len(pos) != 0 {
|
||||
return fmt.Errorf("provider-check takes no positional arguments")
|
||||
}
|
||||
provider, model, ok := strings.Cut(o.model, "/")
|
||||
if !ok || !stage.ValidModel(provider, model) {
|
||||
override, err := pipeline.ParseModelOverride(o.model)
|
||||
if err != nil {
|
||||
return fmt.Errorf("--model requires provider/model")
|
||||
}
|
||||
provider, model := override.Provider, override.Model
|
||||
if err := a.confirmAction("Validate "+o.model+" with one small tool-free generation (provider charges may apply)?", o.yes); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -752,7 +792,13 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
fmt.Fprintln(a.Out, "No matches")
|
||||
}
|
||||
for _, hit := range r.SearchResults.Results {
|
||||
fmt.Fprintf(a.Out, "%s\t%s\t%d\t%s\t%s\n", hit.Kind, hit.Target, hit.Score, hit.MatchedField, searchLabel(hit))
|
||||
// The shared Label renders every kind; the CLI additionally shows a
|
||||
// text-field hit's snippet, which the TUI marks on its own line.
|
||||
label := hit.Label()
|
||||
if hit.Field != nil {
|
||||
label += ": " + hit.Field.Snippet
|
||||
}
|
||||
fmt.Fprintf(a.Out, "%s\t%s\t%d\t%s\t%s\n", hit.Kind, hit.Target, hit.Score, hit.MatchedField, label)
|
||||
}
|
||||
if r.SearchResults.Truncated {
|
||||
fmt.Fprintf(a.Err, "Results truncated (cap %d, scan bound %d bytes)\n", r.SearchResults.Cap, r.SearchResults.ScanBoundBytes)
|
||||
@@ -932,26 +978,6 @@ func (a App) output(value any) error {
|
||||
return encoder.Encode(value)
|
||||
}
|
||||
|
||||
// searchLabel renders one search hit's compact human line. Each kind exposes a
|
||||
// different typed payload; the target stays the navigable identity.
|
||||
func searchLabel(hit protocol.SearchResult) string {
|
||||
switch {
|
||||
case hit.Pipeline != nil:
|
||||
return fmt.Sprintf("%s · v%d · %d stages", hit.Pipeline.Name, hit.Pipeline.Version, hit.Pipeline.Stages)
|
||||
case hit.Version != nil:
|
||||
return fmt.Sprintf("pipeline %d · v%d · %s", hit.Version.PipelineID, hit.Version.Version, hit.Version.ContentHash)
|
||||
case hit.Run != nil:
|
||||
return fmt.Sprintf("run %d · %s · %s", hit.Run.ID, hit.Run.PipelineName, hit.Run.Status)
|
||||
case hit.Step != nil:
|
||||
return fmt.Sprintf("run %d · step %d · %s · %s", hit.Step.RunID, hit.Step.Sequence, hit.Step.Stage, hit.Step.Outcome)
|
||||
case hit.Field != nil:
|
||||
return fmt.Sprintf("run %d · step %d · %s: %s", hit.Field.RunID, hit.Field.Sequence, hit.Field.Field, hit.Field.Snippet)
|
||||
case hit.Artifact != nil:
|
||||
return fmt.Sprintf("run %d · step %d · %s · %s", hit.Artifact.RunID, hit.Artifact.Sequence, hit.Artifact.Name, hit.Artifact.ContentType)
|
||||
}
|
||||
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.
|
||||
@@ -1131,6 +1157,14 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
|
||||
paths = append(paths, p)
|
||||
}
|
||||
}
|
||||
// Pre-flight form validation of the whole-run override with the same parser
|
||||
// the server uses; stage-key existence stays server-authoritative. A malformed
|
||||
// value fails here, before any confirmation or run request.
|
||||
if o.model != "" {
|
||||
if _, err := pipeline.ParseModelOverride(o.model); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if o.yes && (o.name == "" || strings.TrimSpace(o.prompt) == "") {
|
||||
return fmt.Errorf("--yes requires a pipeline and nonempty prompt")
|
||||
}
|
||||
@@ -1145,7 +1179,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, Title: o.title, 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, Model: o.model, StageModels: o.stageModels}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
|
||||
return err
|
||||
}
|
||||
if o.name == "" || strings.TrimSpace(o.prompt) == "" {
|
||||
@@ -1159,20 +1193,43 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
|
||||
if version == 0 {
|
||||
version = p.Version
|
||||
}
|
||||
if err := a.confirmAction(fmt.Sprintf("Run %s v%d in %s? This may edit files, execute commands and publish notifications.", p.Name, version, workspace), o.yes); err != nil {
|
||||
confirmation := fmt.Sprintf("Run %s v%d in %s? This may edit files, execute commands and publish notifications.", p.Name, version, workspace) + o.modelSummary()
|
||||
if err := a.confirmAction(confirmation, o.yes); err != nil {
|
||||
return err
|
||||
}
|
||||
key := o.key
|
||||
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, Title: o.title, 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, Model: o.model, StageModels: o.stageModels})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
|
||||
// modelSummary describes the launch-time model overrides for the action
|
||||
// confirmation, so a model mutation is visible before approval. It is empty when
|
||||
// no override was supplied.
|
||||
func (o *options) modelSummary() string {
|
||||
if o.model == "" && len(o.stageModels) == 0 {
|
||||
return ""
|
||||
}
|
||||
parts := []string{}
|
||||
if o.model != "" {
|
||||
parts = append(parts, "all stages: "+o.model)
|
||||
}
|
||||
keys := make([]string, 0, len(o.stageModels))
|
||||
for key := range o.stageModels {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, key := range keys {
|
||||
parts = append(parts, key+": "+o.stageModels[key])
|
||||
}
|
||||
return " Model overrides — " + strings.Join(parts, "; ") + "."
|
||||
}
|
||||
|
||||
func (a App) finishRun(ctx context.Context, r protocol.Message, o *options, call callFunc) error {
|
||||
var err error
|
||||
if o.wait {
|
||||
|
||||
@@ -17,7 +17,7 @@ var usage = map[string]string{
|
||||
"import": "import [FILE.zip] [--all] [--on-conflict ask|keep|both|import] [--yes] [--json]",
|
||||
"templates": "templates [--json]",
|
||||
"template": "template <key> [--source | --json]",
|
||||
"run": "run [name|id] [prompt] [--title TITLE] [--json [--wait [--wait-timeout DURATION]]]",
|
||||
"run": "run [name|id] [prompt] [--title TITLE] [--model PROVIDER/MODEL] [--stage-model STAGE=PROVIDER/MODEL ...] [--json [--wait [--wait-timeout DURATION]]]",
|
||||
"runs": "runs [--pipeline NAME] [--json]",
|
||||
"inspect": "inspect <run-id> [--json]",
|
||||
"cancel": "cancel <run-id> [--json]",
|
||||
@@ -45,13 +45,13 @@ var notes = map[string]string{
|
||||
"edit": "Omit the name to open fuzzy selection. Original immutable source is copied to a private draft. The configured harness 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": "Confirm publication at the prompt, or use --yes for explicit automation; schedules activate on acceptance. Managed drafts provide the name and base-version guard. --force never bypasses validation.",
|
||||
"run": "Runs in your current directory after action confirmation (--yes skips it). Select a pipeline and compose a multiline task with Ctrl+S. Stage tools are enabled automatically; no file list or typed RUN confirmation. Cancellation does not undo edits. --title sets an explicit run title; without it the title is derived from the prompt. In JSON mode --wait polls until terminal; --wait-timeout bounds only the client wait after admission and is independent of per-request --timeout. A reached wait limit leaves the run active: inspect read-only with `inspect <run-id> --json`, or reattach with --wait reusing the original --request-key (never an automatic replay or cancel).",
|
||||
"run": "Runs in your current directory after action confirmation (--yes skips it). Select a pipeline and compose a multiline task with Ctrl+S. Stage tools are enabled automatically; no file list or typed RUN confirmation. Cancellation does not undo edits. --title sets an explicit run title; without it the title is derived from the prompt. --model PROVIDER/MODEL overrides the model for every stage of that run; --stage-model STAGE=PROVIDER/MODEL overrides one stage and is repeatable, with a repeated key last-wins. Precedence is per-stage > whole-run > the model pinned in the pipeline version; overrides apply to that run only and never change the pinned definition. An unknown stage key or a malformed provider/model is refused before the run starts, naming the valid stage keys. In JSON mode --wait polls until terminal; --wait-timeout bounds only the client wait after admission and is independent of per-request --timeout. A reached wait limit leaves the run active: inspect read-only with `inspect <run-id> --json`, or reattach with --wait reusing the original --request-key (never an automatic replay or cancel).",
|
||||
"retry": "Start a new attempt of a failed run with the same initial input, directory, pipeline version, and edit scope. Original history is retained. Already-completed side effects are not undone. --wait/--wait-timeout behave as for run: a reached wait limit leaves the new run active; inspect read-only with `inspect <run-id> --json`, or reattach with --wait and the original --request-key instead of starting a duplicate retry.",
|
||||
"title": "Rename a run's operator-facing title after the fact without touching its input, steps or execution. The title is collapsed to a single bounded line and recorded as explicitly set. `pipelines runs` and `pipelines inspect` then show it.",
|
||||
"decide": "Choose an option for a run waiting on a human stage. The run must be `waiting`; the option must be one of that stage's non-error edges. The stage is inferred from the run's current stage unless named. The choice and optional --feedback are recorded as the step's evidence (visible in inspect and the TUI) and the run resumes along the chosen edge. An unknown option is refused with the valid list; a repeated decision for an already-decided visit does not double-apply. Works across a server restart because the wait is persisted.",
|
||||
"debug": "Open a fresh configured harness conversation to investigate a run using inspect/show/runs CLI queries. --harness opencode|pi|nvim chooses another configured harness or read-only nvim packet. Does not resume implementation or retry. --json returns the prompt without launching anything.",
|
||||
"rpc": "Accepts a JSON protocol envelope; '-' reads stdin. Every TUI server operation is available here too. Mutating commands are not dry runs. The omni-search command is `search` (fields query, optional kind and limit) and answers with ranked `search_results`.",
|
||||
"search": "One read-only query over pipelines, versions, runs, steps, field text and artifacts. QUERY is free text, a bare status word (queued, running, succeeded, failed, canceled, interrupted) selecting those runs, or a lone date expression (today, yesterday, this week [Monday 00:00 local], or YYYY-MM-DD) selecting the runs created in that window. --type is the only narrowing mechanism and takes one kind: pipeline, version, run, step, field or artifact; an unknown kind is an error. Ranking: an exact name match (3) beats a name substring (2) beats a body-text match (1); equal tiers break by recency, then a stable kind/target tie-break, and every hit reports score, matched_field and recency so a client can re-rank. Bounds: the result cap defaults to 50 and clamps to 200 (0 = default); every kind scans at most 2000 rows and field-text scanning is additionally capped at 2000 steps / 1 MiB; Truncated plus scanned_steps, scanned_bytes and scan_bound_bytes report when a bound applied. Targets are stable: pipeline:<id>, pipeline:<id>:v<version>, run:<id>, run:<id>:<sequence>, run:<id>:<sequence>:<field>, or an artifact URL.",
|
||||
"search": "One read-only query over pipelines, versions, runs, steps, field text and artifacts. QUERY is free text, a bare status word (queued, running, succeeded, failed, canceled, interrupted) selecting those runs, or a lone date expression (today, yesterday, this week [Monday 00:00 local], or YYYY-MM-DD) selecting the runs created in that window. --type is the only narrowing mechanism and takes one kind: pipeline, version, run, step, field or artifact; an unknown kind is an error. Ranking: an exact name match (3) beats a name substring (2) beats a body-text match (1); equal tiers break by recency, then a stable kind/target tie-break, and every hit reports score, matched_field and recency so a client can re-rank. Bounds: the result cap defaults to 50 and clamps to 200 (0 = default); every kind scans at most 2000 rows and field-text scanning is additionally capped at 2000 steps / 1 MiB; Truncated plus scanned_steps, scanned_bytes and scan_bound_bytes report when a bound applied. Targets are stable: pipeline:<id>, pipeline:<id>:v<version>, run:<id>, run:<id>:<sequence>, run:<id>:<sequence>:<field>, or an artifact URL.",
|
||||
}
|
||||
|
||||
var serviceHelp = map[string]string{
|
||||
|
||||
+20
-7
@@ -55,6 +55,13 @@ restart/doctor/logs and retained-data or --purge uninstallation.
|
||||
Options: --url ws://127.0.0.1:8080/connect --json --help
|
||||
Use pipelines help <command> for its flags. Names with spaces must be quoted.
|
||||
|
||||
Stage result format:
|
||||
Model and agent stages accept a line-oriented result. The first non-empty line
|
||||
is the declared outcome, followed by "# " sections. "# output" is required and
|
||||
short (a JSON object carrying the next stage's data); additional sections are
|
||||
free-form markdown evidence. The legacy {"outcome":...,"output":...} JSON
|
||||
envelope remains accepted for compatibility.
|
||||
|
||||
Examples:
|
||||
pipelines edit "bug fix" "Add a review step"
|
||||
pipelines new "release notes" "Summarize changes and notify my phone"
|
||||
@@ -62,6 +69,13 @@ Examples:
|
||||
pipelines validate /path/to/draft.md --json
|
||||
pipelines submit /path/to/draft.md
|
||||
pipelines run "bug fix" "Fix the layout" --json
|
||||
pipelines run "bug fix" "Fix the layout" --model openai/gpt-5 --stage-model review=openai/o4 --json
|
||||
|
||||
Launch-time model overrides: 'pipelines run --model P/M' covers every model stage;
|
||||
'--stage-model STAGE=P/M' (repeatable; a repeated key is last-wins) overrides one
|
||||
stage and wins over --model, which wins over the model pinned in the pipeline
|
||||
version. Overrides apply to that run only, are recorded on the run, and are
|
||||
validated before the run starts (an unknown stage key names the valid keys).
|
||||
|
||||
Draft-first: the configured harness (Pi/OpenCode; host by default, or Docker-linked
|
||||
when a checkout is linked) edits a private draft; nvim remains a client editor.
|
||||
@@ -69,11 +83,10 @@ Nothing is published automatically.
|
||||
Every submission is validated server-side. Submission activates any schedules.
|
||||
JSON mode never launches an editor or picker; supply explicit arguments.
|
||||
|
||||
Search: the TUI '/' popup and the protocol 'search' command (via 'pipelines rpc')
|
||||
find pipelines, versions, runs, stages/visits, artifact names and the text of stage
|
||||
inputs, outputs and evidence. A bare status word (queued, running, succeeded,
|
||||
failed, canceled, interrupted) or a date (today, yesterday, this week, or
|
||||
YYYY-MM-DD interpreted in UTC) selects runs. A leading prefix pipeline:, version:,
|
||||
run:, step:, field:, artifact: or match: (a field alias) narrows the result kind;
|
||||
unrecognised words stay text.
|
||||
Search: the 'pipelines search QUERY' command and the TUI '/' popup find pipelines,
|
||||
versions, runs, steps/visits, artifact names and the text of stage inputs,
|
||||
outputs and evidence. A bare status word (queued, running, succeeded, failed,
|
||||
canceled, interrupted) or a date (today, yesterday, this week, or YYYY-MM-DD in
|
||||
local time) selects runs. --type narrows to pipeline, version, run, step, field
|
||||
or artifact; unrecognised words stay text.
|
||||
`
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
// TestRunModelOverrideFlagsParse proves the repeatable --stage-model flag and the
|
||||
// whole-run --model flag parse onto options, with a repeated key last-wins.
|
||||
func TestRunModelOverrideFlagsParse(t *testing.T) {
|
||||
app := App{Out: &bytes.Buffer{}, Err: &bytes.Buffer{}}
|
||||
f, o := app.flags("run")
|
||||
if err := parse(f, []string{"--pipeline", "p", "--prompt", "task", "--model", "acme/whole", "--stage-model", "one=acme/first", "--stage-model", "two=acme/two", "--stage-model", "one=acme/last"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if o.model != "acme/whole" {
|
||||
t.Fatalf("--model = %q", o.model)
|
||||
}
|
||||
if o.stageModels["one"] != "acme/last" {
|
||||
t.Fatalf("repeated --stage-model key not last-wins: %+v", o.stageModels)
|
||||
}
|
||||
if o.stageModels["two"] != "acme/two" {
|
||||
t.Fatalf("second --stage-model missing: %+v", o.stageModels)
|
||||
}
|
||||
}
|
||||
|
||||
// TestStageModelFlagRejectsMalformedValues proves a value that is not
|
||||
// STAGE=PROVIDER/MODEL fails at flag parse, before any run is created.
|
||||
func TestStageModelFlagRejectsMalformedValues(t *testing.T) {
|
||||
for _, value := range []string{"nope", "one", "=acme/x", "one=", "one=not-a-pair", "one=acme/"} {
|
||||
app := App{Out: &bytes.Buffer{}, Err: &bytes.Buffer{}}
|
||||
f, _ := app.flags("run")
|
||||
if err := parse(f, []string{"--stage-model", value}); err == nil {
|
||||
t.Fatalf("malformed --stage-model %q was accepted", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunRejectsInvalidWholeRunModel proves the whole-run --model is form-checked
|
||||
// with the shared parser before any server request.
|
||||
func TestRunRejectsInvalidWholeRunModel(t *testing.T) {
|
||||
app := App{Out: &bytes.Buffer{}, Err: &bytes.Buffer{}}
|
||||
called := false
|
||||
call := func(protocol.Message) (protocol.Message, error) { called = true; return protocol.Message{}, nil }
|
||||
resolve := func(string) (protocol.PipelineSummary, error) { return protocol.PipelineSummary{}, nil }
|
||||
o := &options{json: true, yes: true, model: "not-a-pair", prompt: "task"}
|
||||
err := app.run(context.Background(), []string{"pipe"}, o, call, resolve)
|
||||
if err == nil || !strings.Contains(err.Error(), "provider/model") {
|
||||
t.Fatalf("invalid --model error = %v", err)
|
||||
}
|
||||
if called {
|
||||
t.Fatal("an invalid --model still sent a run request")
|
||||
}
|
||||
}
|
||||
|
||||
// TestHelpDocumentsModelOverrides proves the usage map, notes and flag help
|
||||
// advertise --model and repeatable --stage-model and state the precedence.
|
||||
func TestHelpDocumentsModelOverrides(t *testing.T) {
|
||||
if !strings.Contains(usage["run"], "--model") || !strings.Contains(usage["run"], "--stage-model") {
|
||||
t.Fatalf("run usage does not document the model overrides: %q", usage["run"])
|
||||
}
|
||||
note := notes["run"]
|
||||
for _, want := range []string{"--model", "--stage-model", "per-stage", "pinned"} {
|
||||
if !strings.Contains(note, want) {
|
||||
t.Fatalf("run note does not document %q: %q", want, note)
|
||||
}
|
||||
}
|
||||
app := App{Out: &bytes.Buffer{}, Err: &bytes.Buffer{}}
|
||||
f, _ := app.flags("run")
|
||||
f.Usage()
|
||||
help := app.Out.(*bytes.Buffer).String()
|
||||
if !strings.Contains(help, "--model") || !strings.Contains(help, "--stage-model") {
|
||||
t.Fatalf("run --help omits the overrides:\n%s", help)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user