Update integration fixtures and collection examples

This commit is contained in:
2026-11-17 22:12:10 +00:00
parent 03b479b4d7
commit 79dfe0a3ef
11 changed files with 87 additions and 18 deletions

View File

@@ -276,6 +276,11 @@ clone ConfigKit's complete format suite.
## Stage 5: Migrate CLI Integration Fixtures And Maintain Runnable Examples ## Stage 5: Migrate CLI Integration Fixtures And Maintain Runnable Examples
**Complete.** CLI, HTTP, and report suites passed with Go 1.27.4, including
both native diagnostic paths and collection-example renders. After `go mod
tidy`, the selected graph retains both ConfigKit versions and YAML rc.6;
ReleaseKit, Goldmark, and Go tooling are not executable dependencies.
**Primary files:** CLI configuration/execution/inspection tests and **Primary files:** CLI configuration/execution/inspection tests and
`examples/`. Review HTTP/report test helpers only for their ConfigKit owner. `examples/`. Review HTTP/report test helpers only for their ConfigKit owner.

View File

@@ -0,0 +1,2 @@
promptkit_sources:
- file: ./examples/framework/backends.yml

View File

@@ -0,0 +1,2 @@
promptkit_sources:
- file: ./examples/profiles/local-fast.yaml

View File

@@ -0,0 +1,2 @@
promptkit_sources:
- file: ./examples/prompts/generic.markdown_summary.yaml

View File

@@ -0,0 +1,10 @@
config:
sequences:
- destination: [promptkit_sources]
key: file
mode: upsert
imports:
- dir: config-fragments/collections
pattern: '*.yml'
required: true
schema_dir: ./examples/schemas

View File

@@ -1,7 +1,8 @@
# Select from the repository root; application paths remain working-directory-relative. # Select from the repository root; application paths remain working-directory-relative.
configkit: config:
imports: imports:
- path: config-fragments/sources.yml - path: config-fragments/sources.yml
required: true
server: server:
addr: :8080 addr: :8080

View File

@@ -0,0 +1,2 @@
promptkit_sources:
- file: ./examples/profiles/local-gpu.yml

2
go.mod
View File

@@ -5,13 +5,13 @@ go 1.27.0
require ( require (
gitea.maximumdirect.net/eric/ConfigKit v0.5.0 gitea.maximumdirect.net/eric/ConfigKit v0.5.0
gitea.maximumdirect.net/eric/promptkit v0.12.0 gitea.maximumdirect.net/eric/promptkit v0.12.0
go.maximumdirect.net/configkit v1.2.0
) )
require ( require (
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0 // indirect gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0 // indirect
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0 // indirect gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
go.maximumdirect.net/configkit v1.2.0
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect
golang.org/x/text v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect
) )

10
go.sum
View File

@@ -10,21 +10,11 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/yuin/goldmark/v2 v2.1.6 h1:igy0q9JcqovoFXFx/XjtU8sHVhcUHavPj2sA3EoKJUE=
github.com/yuin/goldmark/v2 v2.1.6/go.mod h1:G6M4/qOFtfn01/o14BU1UR2Lo5N3S9Qo7xCuz/sHjGQ=
go.maximumdirect.net/configkit v1.2.0 h1:c4tDJ6Xeh/Jg90UZplLxsnf500lvrZBVj0E3i1ysir8= go.maximumdirect.net/configkit v1.2.0 h1:c4tDJ6Xeh/Jg90UZplLxsnf500lvrZBVj0E3i1ysir8=
go.maximumdirect.net/configkit v1.2.0/go.mod h1:s1zLJ9GGB/1Q4a+aOHMLISonJxWFgNWpA6SpPlOafeA= go.maximumdirect.net/configkit v1.2.0/go.mod h1:s1zLJ9GGB/1Q4a+aOHMLISonJxWFgNWpA6SpPlOafeA=
go.maximumdirect.net/releasekit v0.8.0 h1:hSaHPbUI7tAhnolfbu7UMj2fvmm9FGBY+jhkygdbxR0=
go.maximumdirect.net/releasekit v0.8.0/go.mod h1:QE4BLrAhVJTzi+/YTcVl21K/qZp9ojRLg5kuoy3Zb44=
go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4= go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4=
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs=
golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -7,8 +7,11 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"reflect"
"strings" "strings"
"testing" "testing"
appconfig "gitea.maximumdirect.net/eric/scriptorium/internal/config"
) )
func TestConfigCommandsInspectApplicationWithoutEngine(t *testing.T) { func TestConfigCommandsInspectApplicationWithoutEngine(t *testing.T) {
@@ -29,13 +32,43 @@ func TestConfigCommandsInspectApplicationWithoutEngine(t *testing.T) {
} }
case "sources": case "sources":
var sources []configurationSource var sources []configurationSource
if err := json.Unmarshal([]byte(stdout), &sources); err != nil || len(sources) != 1 || sources[0].Layer != "base" { if err := json.Unmarshal([]byte(stdout), &sources); err != nil || len(sources) != 1 || sources[0].Layer != "main" {
t.Fatalf("unexpected source records: %q (%v)", stdout, err) t.Fatalf("unexpected source records: %q (%v)", stdout, err)
} }
} }
} }
} }
func TestCollectionExampleLoadsAndRenders(t *testing.T) {
t.Chdir(filepath.Join("..", "..", ".."))
want := []appconfig.SourceSelection{
{File: "examples/framework/backends.yml"},
{File: "examples/profiles/local-fast.yaml"},
{File: "examples/prompts/generic.markdown_summary.yaml"},
}
for _, overlay := range []string{"", "collection"} {
result, err := appconfig.Load(appconfig.LoadOptions{Path: "examples/config.collections.yml", Explicit: true, Overlay: overlay})
if err != nil {
t.Fatal(err)
}
expected := append([]appconfig.SourceSelection{}, want...)
if overlay != "" {
expected = append(expected, appconfig.SourceSelection{File: "examples/profiles/local-gpu.yml"})
}
if !reflect.DeepEqual(result.Config.PromptKitSources, expected) {
t.Fatalf("overlay %q selectors = %+v, want %+v", overlay, result.Config.PromptKitSources, expected)
}
args := []string{"--config", "examples/config.collections.yml", "--prompt", "generic.markdown_summary", "--input", "transcript=examples/fixtures/transcript.md", "--input", "glossary=examples/fixtures/glossary.yml"}
if overlay != "" {
args = append(args, "--config-overlay", overlay)
}
code, stdout, stderr := runCLICommand(t, renderCommand, args)
if code != ExitOK || !strings.Contains(stdout, "generic.markdown_summary") || !strings.Contains(stdout, "local-fast") {
t.Fatalf("collection render failed: code=%d stdout=%q stderr=%q", code, stdout, stderr)
}
}
}
func TestConfigCommandsExposeComposedSourcesAndResolvedValues(t *testing.T) { func TestConfigCommandsExposeComposedSourcesAndResolvedValues(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
if err := os.MkdirAll(filepath.Join(dir, "overlays"), 0o755); err != nil { if err := os.MkdirAll(filepath.Join(dir, "overlays"), 0o755); err != nil {
@@ -43,7 +76,7 @@ func TestConfigCommandsExposeComposedSourcesAndResolvedValues(t *testing.T) {
} }
base := filepath.Join(dir, "config.yml") base := filepath.Join(dir, "config.yml")
for path, body := range map[string]string{ for path, body := range map[string]string{
base: "configkit:\n imports:\n - path: fragment.yml\npromptkit_sources:\n - directory: ' ./before/../prompts '\nschema_dir: ./schemas\n", base: "config:\n imports:\n - path: fragment.yml\n required: true\npromptkit_sources:\n - directory: ' ./before/../prompts '\nschema_dir: ./schemas\n",
filepath.Join(dir, "fragment.yml"): "server:\n addr: :8081\n", filepath.Join(dir, "fragment.yml"): "server:\n addr: :8081\n",
filepath.Join(dir, "overlays", "local.yml"): "promptkit_sources:\n - directory: ./overlay-prompts\nserver:\n addr: :9090\n", filepath.Join(dir, "overlays", "local.yml"): "promptkit_sources:\n - directory: ./overlay-prompts\nserver:\n addr: :9090\n",
} { } {
@@ -64,7 +97,7 @@ func TestConfigCommandsExposeComposedSourcesAndResolvedValues(t *testing.T) {
if err := json.Unmarshal([]byte(stdout), &sources); err != nil || len(sources) != 5 { if err := json.Unmarshal([]byte(stdout), &sources); err != nil || len(sources) != 5 {
t.Fatalf("unexpected composed source records: %+v (%v)", sources, err) t.Fatalf("unexpected composed source records: %+v (%v)", sources, err)
} }
for i, layer := range []string{"base", "base", "overlay", "cli", "cli"} { for i, layer := range []string{"main", "main", "overlay", "cli", "cli"} {
if string(sources[i].Layer) != layer { if string(sources[i].Layer) != layer {
t.Fatalf("source %d layer = %q, want %q", i, sources[i].Layer, layer) t.Fatalf("source %d layer = %q, want %q", i, sources[i].Layer, layer)
} }

View File

@@ -18,11 +18,12 @@ import (
"testing" "testing"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" legacyconfigkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/promptkit" "gitea.maximumdirect.net/eric/promptkit"
appconfig "gitea.maximumdirect.net/eric/scriptorium/internal/config" appconfig "gitea.maximumdirect.net/eric/scriptorium/internal/config"
"gitea.maximumdirect.net/eric/scriptorium/internal/defaults" "gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
renderformat "gitea.maximumdirect.net/eric/scriptorium/internal/format" renderformat "gitea.maximumdirect.net/eric/scriptorium/internal/format"
"go.maximumdirect.net/configkit"
) )
func TestParseMappingsSingleAndRepeated(t *testing.T) { func TestParseMappingsSingleAndRepeated(t *testing.T) {
@@ -554,6 +555,26 @@ func TestApplicationDiagnosticWriterFailure(t *testing.T) {
} }
} }
func TestConfigurationErrorsUseTheirNativeDiagnosticWriters(t *testing.T) {
application := writeAppConfigFile(t, "unknown_field: value\n")
framework := writeFrameworkFile(t, t.TempDir(), "invalid.yml", "not: [valid\n")
frameworkConfig := writeAppConfigFile(t, fmt.Sprintf("promptkit_sources:\n - file: %q\n", framework))
for _, path := range []string{application, frameworkConfig} {
code, stdout, stderr := runCLICommand(t, renderCommand, []string{"--config", path, "--prompt", "sample"})
if code != ExitRuntimeError || stdout != "" || !strings.Contains(stderr, "error [") {
t.Fatalf("expected native diagnostics: code=%d stdout=%q stderr=%q", code, stdout, stderr)
}
if code := renderCommand([]string{"--config", path, "--prompt", "sample"}, io.Discard, failingDiagnosticWriter{}); code != ExitRuntimeError {
t.Fatalf("diagnostic write failure returned %d", code)
}
}
_, err := newEngine(engineSettings{promptkitSources: []appconfig.SourceSelection{{File: framework}}})
var legacyError *legacyconfigkit.LoadError
if !errors.As(err, &legacyError) {
t.Fatalf("framework load lost legacy diagnostic identity: %v", err)
}
}
func TestParseRenderArgsWithExplicitConfigLoadsDirectoriesAndFormat(t *testing.T) { func TestParseRenderArgsWithExplicitConfigLoadsDirectoriesAndFormat(t *testing.T) {
configPath := writeAppConfigFile(t, ` configPath := writeAppConfigFile(t, `
promptkit_sources: promptkit_sources:
@@ -1092,9 +1113,10 @@ func TestRenderCommandLoadsImportsAndOverlayWithoutChangingExecutionProfile(t *t
t.Fatal(err) t.Fatal(err)
} }
base := filepath.Join(lib.rootDir, "config.yml") base := filepath.Join(lib.rootDir, "config.yml")
framework := writeFrameworkSourceFile(t, lib.rootDir, "framework.yml", "configkit:\n imports:\n - path: prompts/prompt.render.yaml\n")
for path, body := range map[string]string{ for path, body := range map[string]string{
base: "configkit:\n imports:\n - path: fragments/sources.yml\n", base: "config:\n imports:\n - path: fragments/sources.yml\n required: true\n",
filepath.Join(lib.rootDir, "fragments", "sources.yml"): sourceSelectionsYAML(lib.promptDir, lib.profileDir, ""), filepath.Join(lib.rootDir, "fragments", "sources.yml"): fmt.Sprintf("promptkit_sources:\n - file: %q\n - directory: %q\n", framework, lib.profileDir),
filepath.Join(lib.rootDir, "overlays", "local.yml"): "defaults:\n render_format: json\n", filepath.Join(lib.rootDir, "overlays", "local.yml"): "defaults:\n render_format: json\n",
} { } {
if err := os.WriteFile(path, []byte(body), 0o644); err != nil { if err := os.WriteFile(path, []byte(body), 0o644); err != nil {