Migrate CLI inspection and resource context tests

This commit is contained in:
2026-11-23 03:34:43 +00:00
parent 7870acc492
commit 700f3fab63
5 changed files with 113 additions and 164 deletions

View File

@@ -13,7 +13,6 @@ import (
"go.maximumdirect.net/ckconfig"
"go.maximumdirect.net/commandkit"
"go.maximumdirect.net/configkit"
"go.maximumdirect.net/promptkit"
)
func TestServerSelectorsPreservePresenceAndEvidence(t *testing.T) {
@@ -98,58 +97,3 @@ func TestApplicationSelectionErrorsAndCancellation(t *testing.T) {
t.Fatalf("cancellation lost: %v", err)
}
}
func TestEngineUsesOptionalMainAndNativeResourceContexts(t *testing.T) {
root := t.TempDir()
t.Chdir(root)
write := func(path, body string) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path, []byte(body), 0600); err != nil {
t.Fatal(err)
}
}
settings := appconfig.Settings(appconfig.Document{})
engine, err := newEngine(settings)
if err != nil {
t.Fatal(err)
}
if _, err := engine.InspectProfile(context.Background(), "auto"); err != nil {
t.Fatalf("bundle missing without external main: %v", err)
}
settings.PromptKitConfiguration = "missing.yml"
if _, err := newEngine(settings); err == nil {
t.Fatal("missing selected main accepted")
}
write("framework/main.yml", "config:\n imports:\n - glob: collections/*/collection.yml\n - glob: collections/*/collection.yaml\n")
write("framework/collections/example/collection.yaml", "config:\n imports:\n - path: definitions.yml\ncollections:\n review:\n release_version: '1'\n")
write("framework/collections/example/definitions.yml", "collections:\n review:\n prompts:\n - id: summary\n messages:\n - role: user\n content_file: message.txt\n output:\n format: text\n validation_mode: none\n")
write("framework/collections/example/message.txt", "source-relative body")
settings.PromptKitConfiguration = "framework/main.yml"
engine, err = newEngine(settings)
if err != nil {
t.Fatal(err)
}
_, err = engine.InspectPrompt(context.Background(), "review/summary")
if err != nil {
t.Fatal(err)
}
// Native preparation uses the captured source-relative message resource,
// not the process cwd or application configuration's directory.
prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{PromptID: "review/summary", ProfileID: "auto"})
if err != nil {
t.Fatal(err)
}
if len(prepared.Messages) != 1 || prepared.Messages[0].Content != "source-relative body" {
t.Fatalf("resource context lost: %+v", prepared)
}
view, err := engine.InspectConfiguration()
if err != nil {
t.Fatal(err)
}
if len(view.Sources()) < 3 {
t.Fatalf("native source evidence missing: %+v", view.Sources())
}
}