@@ -9,6 +9,7 @@ import (
10 "github.com/opencode-ai/opencode/internal/config"
10 "github.com/opencode-ai/opencode/internal/config"
11 "github.com/opencode-ai/opencode/internal/llm/models"
11 "github.com/opencode-ai/opencode/internal/llm/models"
12+ "github.com/opencode-ai/opencode/internal/logging"
14func GetAgentPrompt(agentName config.AgentName, provider models.ModelProvider) string {
15func GetAgentPrompt(agentName config.AgentName, provider models.ModelProvider) string {
@@ -27,6 +28,7 @@ func GetAgentPrompt(agentName config.AgentName, provider models.ModelProvider) s
27 if agentName == config.AgentCoder || agentName == config.AgentTask {
28 if agentName == config.AgentCoder || agentName == config.AgentTask {
28 // Add context from project-specific instruction files if they exist
29 // Add context from project-specific instruction files if they exist
29 contextContent := getContextFromPaths()
30 contextContent := getContextFromPaths()
31+ logging.Debug("Context content", "Context", contextContent)
30 if contextContent != "" {
32 if contextContent != "" {
31 return fmt.Sprintf("%s\n\n# Project-Specific Context\n Make sure to follow the instructions in the context below\n%s", basePrompt, contextContent)
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)
@@ -59,6 +61,10 @@ func processContextPaths(workDir string, paths []string) string {
59 resultCh = make(chan string)
61 resultCh = make(chan string)
64+ // Track processed files to avoid duplicates
65+ processedFiles := make(map[string]bool)
66+ var processedMutex sync.Mutex
62 for _, path := range paths {
68 for _, path := range paths {
64 go func(p string) {
70 go func(p string) {
@@ -70,16 +76,38 @@ func processContextPaths(workDir string, paths []string) string {
70 return err
76 return err
72 if !d.IsDir() {
78 if !d.IsDir() {
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()
73− if result := processFile(path); result != "" {
86+ if result := processFile(path); result != "" {
74− resultCh <- result
87+ resultCh <- result
90+ processedMutex.Unlock()
77 return nil
93 return nil
80− result := processFile(filepath.Join(workDir, p))
96+ fullPath := filepath.Join(workDir, p)
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()
105+ result := processFile(fullPath)
81− if result != "" {
106+ if result != "" {
82− resultCh <- result
107+ resultCh <- result
110+ processedMutex.Unlock()
@@ -105,4 +133,3 @@ func processFile(filePath string) string {
106 return "# From:" + filePath + "\n" + string(content)
134 return "# From:" + filePath + "\n" + string(content)