package llm import ( "path/filepath" "sort" "gitea.maximumdirect.net/eric/audita/v4/internal/appconfig" ck "go.maximumdirect.net/configkit" pk "go.maximumdirect.net/promptkit" ) func capturedSourcePaths(loaded *ck.Result[appconfig.Config]) ([]string, error) { sources := loaded.Sources() hostByID := make(map[string]string, len(sources)) paths := make(map[string]struct{}, len(sources)) for _, source := range sources { if source.Kind == ck.SourceKindFile && source.Path != "" { hostByID[source.ID] = source.Path paths[source.Path] = struct{}{} } } metadata := loaded.Metadata() captureFile := func(fieldPath ck.Path, filename *string) { if filename == nil { return } field, ok := metadata.Lookup(fieldPath) if !ok { return } for _, location := range field.Origin.Locations { if host := hostByID[location.SourceID]; host != "" { paths[filepath.Join(filepath.Dir(host), filepath.FromSlash(*filename))] = struct{}{} } } } capture := func(base ck.Path, prompts []pk.PromptSettings) { for i, prompt := range prompts { record := base.Index(i) if prompt.Output != nil { captureFile(record.Key("output").Key("schema_file"), prompt.Output.SchemaFile) } for j, message := range prompt.Messages { captureFile(record.Key("messages").Index(j).Key("content_file"), message.ContentFile) } } } capture(ck.Keys("promptkit", "prompts"), loaded.Config.PromptKit.Prompts) for name, collection := range loaded.Config.PromptKit.Collections { capture(ck.Keys("promptkit", "collections", name, "prompts"), collection.Prompts) } result := make([]string, 0, len(paths)) for path := range paths { result = append(result, path) } sort.Strings(result) return result, nil }