Adopt ConfigKit 1.2.0

This commit is contained in:
2026-11-10 15:14:31 +00:00
parent 8ff9aa3efd
commit 7df7e420aa
7 changed files with 90 additions and 14 deletions

View File

@@ -63,6 +63,47 @@ func TestCollectionInputLoadsNativeImportsAndLaterOverride(t *testing.T) {
}
}
func TestCollectionInputUsesMainRelativeContext(t *testing.T) {
filesystem := configkit.NewFilesystem("application", fstest.MapFS{
"site/main.yaml": {Data: []byte("version: '2'\n")},
"site/prompts/greeting.yaml": {Data: []byte(`id: greeting
messages:
- role: user
content_file: greeting.txt
output: {format: text, validation_mode: none}
`)},
"site/prompts/greeting.txt": {Data: []byte("Hello from the imported prompt's directory.")},
})
companion, err := promptkit.CollectionInput("support", configkit.Bytes("companion prompts", []byte(`
config:
imports:
- dir: prompts
pattern: ["*.yaml", "*.yml"]
destination: [prompts]
placement: sequence-item
required: true
`)))
if err != nil {
t.Fatal(err)
}
companion.MainRelative = configkit.MainRelative()
main := configkit.Input{Source: filesystem.File("site/main.yaml")}
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
Main: &main,
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{companion}}},
}}, promptkit.WithBundledOpenRouter(false))
if err != nil {
t.Fatalf("construct engine with main-relative imports: %v", err)
}
inspection, err := engine.InspectPrompt(t.Context(), "support/greeting")
if err != nil {
t.Fatal(err)
}
if len(inspection.Messages) != 1 || inspection.Messages[0].Content != "Hello from the imported prompt's directory." {
t.Fatalf("unexpected imported messages: %+v", inspection.Messages)
}
}
func TestCollectionInputLoadsEmbeddedImportsAndLaterOverride(t *testing.T) {
files := fstest.MapFS{
"collection.yaml": {Data: []byte("config:\n imports:\n - path: defaults.yaml\n required: true\n")},