Add collection input helper

This commit is contained in:
2026-10-17 06:09:52 +00:00
parent 13b60a72ac
commit 8dfe35a1f0
3 changed files with 97 additions and 0 deletions

View File

@@ -8,9 +8,25 @@ import (
"path/filepath"
"gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/promptkit/internal/domain"
"gitea.maximumdirect.net/eric/promptkit/internal/filecatalog"
)
// CollectionInput mounts source at the selected collection's configuration
// destination and enables ConfigKit imports for that input. The source is not
// read or validated until ConfigKit loads it. Callers may adjust the returned
// input, including its filesystem context or imports setting.
func CollectionInput(namespace string, source configkit.Source) (configkit.Input, error) {
if !domain.IsValidResourceNamespace(namespace) {
return configkit.Input{}, fmt.Errorf("%w: invalid collection namespace %q", ErrInvalidConfig, namespace)
}
return configkit.Input{
Source: source,
Destination: configkit.Keys("collections", namespace),
Imports: true,
}, nil
}
// DirectoryInputs selects the YAML files beneath an explicitly chosen host
// directory as one strict-composition group. The returned order is deterministic;
// it does not assign precedence among those files. Discovery is recursive over