@@ -23,13 +23,14 @@ type Prompt struct {
2323}
2424
2525type PromptDat struct {
26− Provider string
27− Model string
28− Config config.Config
29− WorkingDir string
30− IsGitRepo bool
31− Platform string
32− Date string
26+ Provider string
27+ Model string
28+ Config config.Config
29+ WorkingDir string
30+ IsGitRepo bool
31+ Platform string
32+ Date string
33+ ContextFiles []ContextFile
3334}
3435
3536type ContextFile struct {
@@ -70,7 +71,7 @@ func NewPrompt(name, promptTemplate string, opts ...Option) (*Prompt, error) {
7071}
7172
7273func (p *Prompt) Build(provider, model string, cfg config.Config) (string, error) {
73− t, err := template.New(p.name).Funcs(p.funcMap(cfg)).Parse(p.template)
74+ t, err := template.New(p.name).Parse(p.template)
7475 if err != nil {
7576 return "", fmt.Errorf("parsing template: %w", err)
7677 }
@@ -82,15 +83,6 @@ func (p *Prompt) Build(provider, model string, cfg config.Config) (string, error
8283 return sb.String(), nil
8384}
8485
85−func (p *Prompt) funcMap(cfg config.Config) template.FuncMap {
86− return template.FuncMap{
87− "contextFiles": func(path string) []ContextFile {
88− path = expandPath(path, cfg)
89− return processContextPath(path, cfg)
90− },
91− }
92−}
93−
9486func processFile(filePath string) *ContextFile {
9587 content, err := os.ReadFile(filePath)
9688 if err != nil {
@@ -155,7 +147,20 @@ func (p *Prompt) promptData(provider, model string, cfg config.Config) PromptDat
155147 if p.platform != "" {
156148 platform = p.platform
157149 }
158− return PromptDat{
150+
151+ files := map[string][]ContextFile{}
152+
153+ for _, pth := range cfg.Options.ContextPaths {
154+ expanded := expandPath(pth, cfg)
155+ pathKey := strings.ToLower(expanded)
156+ if _, ok := files[pathKey]; ok {
157+ continue
158+ }
159+ content := processContextPath(expanded, cfg)
160+ files[pathKey] = content
161+ }
162+
163+ data := PromptDat{
159164 Provider: provider,
160165 Model: model,
161166 Config: cfg,
@@ -164,6 +169,11 @@ func (p *Prompt) promptData(provider, model string, cfg config.Config) PromptDat
164169 Platform: platform,
165170 Date: p.now().Format("1/2/2006"),
166171 }
172+
173+ for _, contextFiles := range files {
174+ data.ContextFiles = append(data.ContextFiles, contextFiles...)
175+ }
176+ return data
167177}
168178
169179func isGitRepo(dir string) bool {