Add PromptKit catalog YAML encoders

This commit is contained in:
2026-10-12 02:12:47 +00:00
parent 330017fd75
commit c75d371ecd
3 changed files with 114 additions and 1 deletions

View File

@@ -322,6 +322,34 @@ func encodePromptYAML(writer io.Writer, value any) error {
return encoder.Encode(value)
}
type promptCatalogEntry struct {
ID string `yaml:"id"`
Version string `yaml:"version"`
}
func encodePromptCatalog(prompts []promptkit.PromptIdentity) ([]byte, error) {
entries := make([]promptCatalogEntry, len(prompts))
for index, prompt := range prompts {
entries[index] = promptCatalogEntry{ID: prompt.ID, Version: prompt.Version}
}
return encodePromptYAMLBytes(entries)
}
func encodeProfileCatalog(profiles []string) ([]byte, error) {
if profiles == nil {
profiles = []string{}
}
return encodePromptYAMLBytes(profiles)
}
func encodePromptYAMLBytes(value any) ([]byte, error) {
var output bytes.Buffer
if err := encodePromptYAML(&output, value); err != nil {
return nil, err
}
return output.Bytes(), nil
}
func writePromptReport(invocation commandkit.Invocation, output []byte, diagnostics []commandkit.Diagnostic) commandkit.Outcome {
if invocation.Context != nil {
if err := invocation.Context.Err(); err != nil {