@@ -4,7 +4,10 @@ import (
4 "encoding/json"
4 "encoding/json"
7+ "charm.land/catwalk/pkg/catwalk"
8+ "github.com/charmbracelet/crush/internal/agent/hyper"
7 "github.com/charmbracelet/crush/internal/config"
9 "github.com/charmbracelet/crush/internal/config"
10+ "github.com/charmbracelet/crush/internal/discover"
8 "github.com/invopop/jsonschema"
11 "github.com/invopop/jsonschema"
9 "github.com/spf13/cobra"
12 "github.com/spf13/cobra"
@@ -16,7 +19,9 @@ var schemaCmd = &cobra.Command{
16 Hidden: true,
19 Hidden: true,
17 RunE: func(cmd *cobra.Command, args []string) error {
20 RunE: func(cmd *cobra.Command, args []string) error {
18 reflector := new(jsonschema.Reflector)
21 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, "", " ")
20 if err != nil {
25 if err != nil {
21 return fmt.Errorf("failed to marshal schema: %w", err)
26 return fmt.Errorf("failed to marshal schema: %w", err)
@@ -24,3 +29,32 @@ var schemaCmd = &cobra.Command{
24 return nil
29 return nil
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 {
44+ typeProp, ok := def.Properties.Get("type")
50+ for _, t := range catwalk.KnownProviderTypes() {
51+ types = append(types, string(t))
53+ types = append(types, string(hyper.Name))
54+ types = append(types, discover.RegisteredProviderTypes()...)
56+ typeProp.Enum = make([]any, len(types))
57+ for i, t := range types {