Enable explicit configuration imports and overlays

This commit is contained in:
2026-09-26 18:12:27 +00:00
parent 36e7e857f5
commit 9ac7006a79
15 changed files with 204 additions and 30 deletions

View File

@@ -1071,6 +1071,41 @@ profile_dir: %s
}
}
func TestRenderCommandLoadsImportsAndOverlayWithoutChangingExecutionProfile(t *testing.T) {
lib := newCLITestLibrary(t)
inputPath := lib.writeInputFile(t, "transcript.md", "hello transcript")
writePromptFile(t, lib.promptDir, "prompt.render", "local-default")
writeProfileFile(t, lib.profileDir, "local-default", "http://127.0.0.1:1/v1", "profile-model")
if err := os.MkdirAll(filepath.Join(lib.rootDir, "fragments"), 0o755); err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(filepath.Join(lib.rootDir, "overlays"), 0o755); err != nil {
t.Fatal(err)
}
base := filepath.Join(lib.rootDir, "config.yml")
for path, body := range map[string]string{
base: "configkit:\n imports:\n - path: fragments/sources.yml\n",
filepath.Join(lib.rootDir, "fragments", "sources.yml"): fmt.Sprintf("prompt_dir: %q\nprofile_dir: %q\n", lib.promptDir, lib.profileDir),
filepath.Join(lib.rootDir, "overlays", "local.yml"): "defaults:\n render_format: json\n",
} {
if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
t.Fatal(err)
}
}
args := []string{"--config", base, "--config-overlay", "local", "--profile", "local-default", "--prompt", "prompt.render", "--input", "transcript=" + inputPath}
cfg, err := parseRenderArgs(args)
if err != nil {
t.Fatal(err)
}
if cfg.profileID != "local-default" || cfg.outputFormat != renderformat.PreparedRunFormatJSON {
t.Fatalf("overlay changed execution profile or output selection: %+v", cfg)
}
code, stdout, stderr := runCLICommand(t, renderCommand, args)
if code != ExitOK || !strings.Contains(stdout, `"selected_profile_id": "local-default"`) {
t.Fatalf("render did not use composed config and independent execution profile: code=%d out=%q err=%q", code, stdout, stderr)
}
}
func TestRenderCommandUsesConfiguredCustomBackend(t *testing.T) {
lib := newCLITestLibrary(t)
writePromptDefinition(t, lib.promptDir, "custom.yaml", `id: custom