@@ -29,16 +29,17 @@ type Prompt struct {
31type PromptDat struct {
31type PromptDat struct {
32− Provider string
32+ Provider string
33− Model string
33+ Model string
34− Config config.Config
34+ Config config.Config
35− WorkingDir string
35+ WorkingDir string
36− IsGitRepo bool
36+ IsGitRepo bool
37− Platform string
37+ Platform string
38− Date string
38+ Date string
39− GitStatus string
39+ GitStatus string
40− ContextFiles []ContextFile
40+ ContextFiles []ContextFile
41+ GlobalContextFiles []ContextFile
41− AvailSkillXML string
42+ AvailSkillXML string
44type ContextFile struct {
45type ContextFile struct {
@@ -147,22 +148,27 @@ func expandPath(path string, store *config.ConfigStore) string {
147 return path
148 return path
150−func (p *Prompt) promptData(ctx context.Context, provider, model string, store *config.ConfigStore) (PromptDat, error) {
151+// loadContextFiles loads and deduplicates context files from a list of paths.
151− workingDir := cmp.Or(p.workingDir, store.WorkingDir())
152+func loadContextFiles(paths []string, store *config.ConfigStore) map[string][]ContextFile {
152− platform := cmp.Or(p.platform, runtime.GOOS)
154 files := map[string][]ContextFile{}
153 files := map[string][]ContextFile{}
156− cfg := store.Config()
157− for _, pth := range cfg.Options.ContextPaths {
154+ for _, pth := range paths {
158 expanded := expandPath(pth, store)
155 expanded := expandPath(pth, store)
159 pathKey := strings.ToLower(expanded)
156 pathKey := strings.ToLower(expanded)
160 if _, ok := files[pathKey]; ok {
157 if _, ok := files[pathKey]; ok {
163− content := processContextPath(expanded, store)
160+ files[pathKey] = processContextPath(expanded, store)
164− files[pathKey] = content
165+func (p *Prompt) promptData(ctx context.Context, provider, model string, store *config.ConfigStore) (PromptDat, error) {
166+ workingDir := cmp.Or(p.workingDir, store.WorkingDir())
167+ platform := cmp.Or(p.platform, runtime.GOOS)
169+ cfg := store.Config()
170+ contextFiles := loadContextFiles(cfg.Options.ContextPaths, store)
171+ globalContextFiles := loadContextFiles(cfg.Options.GlobalContextPaths, store)
167 // Discover and load skills metadata.
173 // Discover and load skills metadata.
168 var availSkillXML string
174 var availSkillXML string
@@ -217,8 +223,11 @@ func (p *Prompt) promptData(ctx context.Context, provider, model string, store *
220− for _, contextFiles := range files {
226+ for _, files := range contextFiles {
221− data.ContextFiles = append(data.ContextFiles, contextFiles...)
227+ data.ContextFiles = append(data.ContextFiles, files...)
229+ for _, files := range globalContextFiles {
230+ data.GlobalContextFiles = append(data.GlobalContextFiles, files...)
223 return data, nil
232 return data, nil