@@ -23,13 +23,14 @@ type Prompt struct {
25type PromptDat struct {
25type PromptDat struct {
26− Provider string
26+ Provider string
27− Model string
27+ Model string
28− Config config.Config
28+ Config config.Config
29− WorkingDir string
29+ WorkingDir string
30− IsGitRepo bool
30+ IsGitRepo bool
31− Platform string
31+ Platform string
32− Date string
32+ Date string
33+ ContextFiles []ContextFile
35type ContextFile struct {
36type ContextFile struct {
@@ -70,7 +71,7 @@ func NewPrompt(name, promptTemplate string, opts ...Option) (*Prompt, error) {
72func (p *Prompt) Build(provider, model string, cfg config.Config) (string, error) {
73func (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)
74 if err != nil {
75 if err != nil {
75 return "", fmt.Errorf("parsing template: %w", err)
76 return "", fmt.Errorf("parsing template: %w", err)
@@ -82,15 +83,6 @@ func (p *Prompt) Build(provider, model string, cfg config.Config) (string, error
82 return sb.String(), nil
83 return sb.String(), nil
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)
94func processFile(filePath string) *ContextFile {
86func processFile(filePath string) *ContextFile {
95 content, err := os.ReadFile(filePath)
87 content, err := os.ReadFile(filePath)
96 if err != nil {
88 if err != nil {
@@ -155,7 +147,20 @@ func (p *Prompt) promptData(provider, model string, cfg config.Config) PromptDat
155 if p.platform != "" {
147 if p.platform != "" {
156 platform = p.platform
148 platform = p.platform
151+ files := map[string][]ContextFile{}
153+ for _, pth := range cfg.Options.ContextPaths {
154+ expanded := expandPath(pth, cfg)
155+ pathKey := strings.ToLower(expanded)
156+ if _, ok := files[pathKey]; ok {
159+ content := processContextPath(expanded, cfg)
160+ files[pathKey] = content
158− return PromptDat{
163+ data := PromptDat{
159 Provider: provider,
164 Provider: provider,
160 Model: model,
165 Model: model,
161 Config: cfg,
166 Config: cfg,
@@ -164,6 +169,11 @@ func (p *Prompt) promptData(provider, model string, cfg config.Config) PromptDat
164 Platform: platform,
169 Platform: platform,
165 Date: p.now().Format("1/2/2006"),
170 Date: p.now().Format("1/2/2006"),
173+ for _, contextFiles := range files {
174+ data.ContextFiles = append(data.ContextFiles, contextFiles...)
169func isGitRepo(dir string) bool {
179func isGitRepo(dir string) bool {