Retire the legacy CLI and document native operator workflows
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"go.maximumdirect.net/promptkit"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -41,37 +43,46 @@ func TestCollectionCheckoutDiscoveryAcrossInvocations(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
config := writeAppConfigFile(t, fmt.Sprintf("promptkit_sources:\n - file: %q\n", frameworkPath))
|
||||
config := filepath.Join(root, "app.yml")
|
||||
writeNativeFile(t, config, fmt.Sprintf("promptkit:\n configuration: %q\n", frameworkPath))
|
||||
input := filepath.Join(root, "transcript.md")
|
||||
if err := os.WriteFile(input, []byte("synthetic discovery transcript"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
args := func(name string) []string {
|
||||
if name == "support-repo" {
|
||||
return []string{"--config", config, "--prompt", "support/answer", "--profile", "support/fast", "--input", "transcript=" + input}
|
||||
return []string{"support/answer", "--config", config, "--profile", "support/fast", "--input-file", "transcript=" + input}
|
||||
}
|
||||
return []string{"--config", config, "--prompt", "review/answer", "--profile", "review/base"}
|
||||
return []string{"review/answer", "--config", config, "--profile", "review/base"}
|
||||
}
|
||||
check := func(name string) {
|
||||
t.Helper()
|
||||
code, out, stderr := runCLICommand(t, renderCommand, args(name))
|
||||
if code != ExitOK {
|
||||
t.Fatalf("render %s: code=%d stderr=%s", name, code, stderr)
|
||||
command := append([]string{"promptkit", "show", "prepared"}, args(name)...)
|
||||
outcome, out, stderr := executeNative(t, append(command, "--format=json")...)
|
||||
if outcome.Status != 0 {
|
||||
t.Fatalf("prepare %s: outcome=%+v stderr=%s", name, outcome, stderr)
|
||||
}
|
||||
var prepared promptkit.PreparedRun
|
||||
if err := json.Unmarshal([]byte(out), &prepared); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if name == "support-repo" {
|
||||
for _, want := range []string{"prompt: support/answer", "selected_profile_id: support/fast", "model: support-example", "max_tokens: 256", "Answer the support request", "synthetic discovery transcript"} {
|
||||
for _, want := range []string{"support/answer", "support/fast", "support-example", "Answer the support request", "synthetic discovery transcript"} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Fatalf("missing %q: %s", want, out)
|
||||
}
|
||||
}
|
||||
} else if !strings.Contains(out, "prompt: review/answer") || !strings.Contains(out, "model: review-example") || !strings.Contains(out, "Review this material") {
|
||||
if prepared.EffectiveModelParams.MaxTokens != 256 {
|
||||
t.Fatalf("inherited profile setting missing: %+v", prepared)
|
||||
}
|
||||
} else if !strings.Contains(out, "review/answer") || !strings.Contains(out, "review-example") || !strings.Contains(out, "Review this material") {
|
||||
t.Fatalf("unexpected review render: %s", out)
|
||||
}
|
||||
}
|
||||
install(tc.first)
|
||||
check(tc.first)
|
||||
code, _, _ := runCLICommand(t, renderCommand, args(tc.second))
|
||||
if code != ExitRuntimeError {
|
||||
outcome, _, _ := executeNative(t, append([]string{"promptkit", "show", "prepared"}, args(tc.second)...)...)
|
||||
if outcome.Status != 1 {
|
||||
t.Fatal("uninstalled collection unexpectedly selected")
|
||||
}
|
||||
install(tc.second)
|
||||
|
||||
Reference in New Issue
Block a user