Adopt ConfigKit 1.2.0
This commit is contained in:
@@ -18,7 +18,7 @@ import "go.maximumdirect.net/promptkit"
|
||||
For migration from the former module path, see
|
||||
[Update Go Imports](configuration-migration.md#update-go-imports).
|
||||
|
||||
Configuration APIs use `go.maximumdirect.net/configkit` v1.1.0. Its types are
|
||||
Configuration APIs use `go.maximumdirect.net/configkit` v1.2.0. Its types are
|
||||
not interchangeable with the old ConfigKit module path.
|
||||
|
||||
The maintained [offline preparation example](../../examples/go-library/prepare/main.go)
|
||||
@@ -102,6 +102,39 @@ new engine to observe configuration edits. See the [constructor GoDoc](../../eng
|
||||
for the exact public contract and the [framework format reference](../formats.md)
|
||||
for definition fields.
|
||||
|
||||
### Load Companion Prompts Relative To The Main Configuration
|
||||
|
||||
A non-file underlay can use the selected main configuration's directory for
|
||||
caller-declared imports. For example, this loads standalone prompt definitions
|
||||
from the adjacent `prompts/` directory into the `support` collection:
|
||||
|
||||
```go
|
||||
main := configkit.Input{Source: configkit.File(configPath)}
|
||||
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 { return err }
|
||||
companion.MainRelative = configkit.MainRelative()
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
|
||||
Main: &main,
|
||||
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{companion}}},
|
||||
}})
|
||||
```
|
||||
|
||||
`CollectionInput` enables imports; for a raw `configkit.Input`, enable them with
|
||||
`Imports: true`. The binding itself does not enable imports, and an explicit
|
||||
`Input.Filesystem` takes precedence. Imported prompt `content_file` references
|
||||
keep their source-local context. See ConfigKit's
|
||||
[layered-loading contract](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.2.0/docs/config.md#layered-loading)
|
||||
for eligible inputs, fallback contexts, and behavior when the main has no usable
|
||||
filesystem context.
|
||||
|
||||
### Use Scoped Engine Views
|
||||
|
||||
Create a view when an application wants short request IDs to resolve within a
|
||||
@@ -181,7 +214,9 @@ input := configkit.Input{Source: document}
|
||||
null is not needed. Prompt and backend helpers, like profiles, support sibling
|
||||
inheritance via `Extends`; partial records can be completed by other layers.
|
||||
For relative prompt `content_file` references, supply the ordinary ConfigKit
|
||||
`Input.Filesystem` context for that source. The helpers do not read files or
|
||||
`Input.Filesystem` context for that source, or use a
|
||||
[main-relative underlay](#load-companion-prompts-relative-to-the-main-configuration).
|
||||
The helpers do not read files or
|
||||
validate final definitions. Profile and backend provider maps use ConfigKit Mapping input forms: built-in
|
||||
scalars, `[]any`, and `map[string]any` recursively. Convert `json.Number` or
|
||||
typed containers explicitly to an appropriate supported value, choosing numeric
|
||||
@@ -300,7 +335,7 @@ for _, difference := range differences {
|
||||
```
|
||||
|
||||
See the [`ConfigurationInspection.Diff` GoDoc](../../configuration_inspection.go)
|
||||
and ConfigKit's [v1.1.0 effective-configuration diff guidance](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.1.0/docs/config.md#effective-configuration-diffs)
|
||||
and ConfigKit's [effective-configuration diff guidance](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.2.0/docs/config.md#effective-configuration-diffs)
|
||||
for the exact comparison contract. The operation compares only frozen effective
|
||||
configuration values: it does not reread external files or compare their
|
||||
contents, resolved credential contents, later execution preparation, or
|
||||
|
||||
Reference in New Issue
Block a user