9
9
10
10
"github.com/opencode-ai/opencode/internal/config"
11
11
"github.com/opencode-ai/opencode/internal/llm/models"
12
+ "github.com/opencode-ai/opencode/internal/logging"
12
13
)
13
14
14
15
func GetAgentPrompt (agentName config.AgentName , provider models.ModelProvider ) string {
@@ -27,6 +28,7 @@ func GetAgentPrompt(agentName config.AgentName, provider models.ModelProvider) s
27
28
if agentName == config .AgentCoder || agentName == config .AgentTask {
28
29
// Add context from project-specific instruction files if they exist
29
30
contextContent := getContextFromPaths ()
31
+ logging .Debug ("Context content" , "Context" , contextContent )
30
32
if contextContent != "" {
31
33
return fmt .Sprintf ("%s\n \n # Project-Specific Context\n Make sure to follow the instructions in the context below\n %s" , basePrompt , contextContent )
32
34
}
@@ -59,6 +61,10 @@ func processContextPaths(workDir string, paths []string) string {
59
61
resultCh = make (chan string )
60
62
)
61
63
64
+ // Track processed files to avoid duplicates
65
+ processedFiles := make (map [string ]bool )
66
+ var processedMutex sync.Mutex
67
+
62
68
for _ , path := range paths {
63
69
wg .Add (1 )
64
70
go func (p string ) {
@@ -70,16 +76,38 @@ func processContextPaths(workDir string, paths []string) string {
70
76
return err
71
77
}
72
78
if ! d .IsDir () {
73
- if result := processFile (path ); result != "" {
74
- resultCh <- result
79
+ // Check if we've already processed this file (case-insensitive)
80
+ processedMutex .Lock ()
81
+ lowerPath := strings .ToLower (path )
82
+ if ! processedFiles [lowerPath ] {
83
+ processedFiles [lowerPath ] = true
84
+ processedMutex .Unlock ()
85
+
86
+ if result := processFile (path ); result != "" {
87
+ resultCh <- result
88
+ }
89
+ } else {
90
+ processedMutex .Unlock ()
75
91
}
76
92
}
77
93
return nil
78
94
})
79
95
} else {
80
- result := processFile (filepath .Join (workDir , p ))
81
- if result != "" {
82
- resultCh <- result
96
+ fullPath := filepath .Join (workDir , p )
97
+
98
+ // Check if we've already processed this file (case-insensitive)
99
+ processedMutex .Lock ()
100
+ lowerPath := strings .ToLower (fullPath )
101
+ if ! processedFiles [lowerPath ] {
102
+ processedFiles [lowerPath ] = true
103
+ processedMutex .Unlock ()
104
+
105
+ result := processFile (fullPath )
106
+ if result != "" {
107
+ resultCh <- result
108
+ }
109
+ } else {
110
+ processedMutex .Unlock ()
83
111
}
84
112
}
85
113
}(path )
@@ -105,4 +133,3 @@ func processFile(filePath string) string {
105
133
}
106
134
return "# From:" + filePath + "\n " + string (content )
107
135
}
108
-
0 commit comments