Install native PromptKit diagnostics and reusable execution overrides
This commit is contained in:
54
internal/cli/execution_overrides_test.go
Normal file
54
internal/cli/execution_overrides_test.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"go.maximumdirect.net/commandkit"
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func TestRunOverrideFlagsPreserveNativeSuppliedValues(t *testing.T) {
|
||||
type input struct{ Overrides executionOverrides }
|
||||
var received executionOverrides
|
||||
app, err := commandkit.New(commandkit.Identity{Name: "fixture"}, commandkit.NewCommand(commandkit.CommandSpec[input]{
|
||||
Name: "execute",
|
||||
Flags: executionOverrideFlags(func(value *input) *executionOverrides { return &value.Overrides }),
|
||||
Run: func(_ commandkit.Invocation, value input) commandkit.Outcome {
|
||||
received = value.Overrides
|
||||
return commandkit.Success()
|
||||
},
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
execute := func(args ...string) commandkit.Outcome {
|
||||
return app.Execute(context.Background(), append([]string{"execute"}, args...), commandkit.Streams{Out: io.Discard, Err: io.Discard})
|
||||
}
|
||||
if outcome := execute(); outcome.Status != 0 {
|
||||
t.Fatal(outcome)
|
||||
}
|
||||
request := promptkit.RunRequest{PromptID: "notarius/producer", ProfileID: "bound", SessionID: "generated"}
|
||||
unchanged := received.apply(request)
|
||||
if unchanged.ProfileID != "bound" || unchanged.SessionID != "generated" || unchanged.Execution != nil {
|
||||
t.Fatalf("omission changed the request: %#v", unchanged)
|
||||
}
|
||||
if outcome := execute("--llm-profile=chosen", "--llm-session-id=operator", "--llm-reasoning-effort=", "--llm-temperature=0", "--llm-transient-retries=0", `--llm-extra-params={"enabled":false}`); outcome.Status != 0 {
|
||||
t.Fatal(outcome)
|
||||
}
|
||||
applied := received.apply(request)
|
||||
if applied.PromptID != request.PromptID || applied.ProfileID != "chosen" || applied.SessionID != "operator" || applied.Execution == nil || applied.Execution.ReasoningEffort == nil || *applied.Execution.ReasoningEffort != "" || applied.Execution.Temperature == nil || *applied.Execution.Temperature != 0 || applied.TransientRetries == nil || *applied.TransientRetries != 0 || applied.Execution.ExtraParams["enabled"] != false {
|
||||
t.Fatalf("native values lost: %#v", applied)
|
||||
}
|
||||
if request.ProfileID != "bound" || request.Execution != nil {
|
||||
t.Fatal("application changed operation input")
|
||||
}
|
||||
// Every singleton occurrence must be valid, even if a later value parses.
|
||||
if outcome := execute("--llm-temperature=invalid", "--llm-temperature=0"); outcome.Status != 2 {
|
||||
t.Fatalf("invalid occurrence skipped: %#v", outcome)
|
||||
}
|
||||
if outcome := execute("--llm-profile=first", "--llm-profile=last"); outcome.Status != 0 || received.Resources.Profile.Value != "last" {
|
||||
t.Fatalf("last supplied profile lost: %#v", outcome)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user