@@ -4,7 +4,10 @@ import (
44 "encoding/json"
55 "fmt"
66
7+ "charm.land/catwalk/pkg/catwalk"
8+ "github.com/charmbracelet/crush/internal/agent/hyper"
79 "github.com/charmbracelet/crush/internal/config"
10+ "github.com/charmbracelet/crush/internal/discover"
811 "github.com/invopop/jsonschema"
912 "github.com/spf13/cobra"
1013)
@@ -16,7 +19,9 @@ var schemaCmd = &cobra.Command{
1619 Hidden: true,
1720 RunE: func(cmd *cobra.Command, args []string) error {
1821 reflector := new(jsonschema.Reflector)
19− bts, err := json.MarshalIndent(reflector.Reflect(&config.Config{}), "", " ")
22+ schema := reflector.Reflect(&config.Config{})
23+ setProviderTypeEnum(schema)
24+ bts, err := json.MarshalIndent(schema, "", " ")
2025 if err != nil {
2126 return fmt.Errorf("failed to marshal schema: %w", err)
2227 }
@@ -24,3 +29,32 @@ var schemaCmd = &cobra.Command{
2429 return nil
2530 },
2631}
32+
33+// setProviderTypeEnum overwrites the provider `type` enum with the live set
34+// of accepted values rather than a hand-maintained struct tag. The values
35+// must match exactly what load.go validates against: the catwalk provider
36+// types, the Charm Hyper type, and any locally-discovered providers that
37+// self-register an enricher (e.g. ollama, omlx). Sourcing the enum here keeps
38+// the published schema from drifting as provider types are added or renamed.
39+func setProviderTypeEnum(schema *jsonschema.Schema) {
40+ def, ok := schema.Definitions["ProviderConfig"]
41+ if !ok || def.Properties == nil {
42+ return
43+ }
44+ typeProp, ok := def.Properties.Get("type")
45+ if !ok {
46+ return
47+ }
48+
49+ var types []string
50+ for _, t := range catwalk.KnownProviderTypes() {
51+ types = append(types, string(t))
52+ }
53+ types = append(types, string(hyper.Name))
54+ types = append(types, discover.RegisteredProviderTypes()...)
55+
56+ typeProp.Enum = make([]any, len(types))
57+ for i, t := range types {
58+ typeProp.Enum[i] = t
59+ }
60+}