Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions internal/llm/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/opencode-ai/opencode/internal/config"
"github.com/opencode-ai/opencode/internal/llm/models"
Expand All @@ -13,6 +14,7 @@ import (
var contextFiles = []string{
".github/copilot-instructions.md",
".cursorrules",
".cursor/rules/", // Directory containing multiple rule files
"CLAUDE.md",
"CLAUDE.local.md",
"opencode.md",
Expand Down Expand Up @@ -51,11 +53,30 @@ func getContextFromFiles() string {
workDir := config.WorkingDirectory()
var contextContent string

for _, file := range contextFiles {
filePath := filepath.Join(workDir, file)
content, err := os.ReadFile(filePath)
if err == nil {
contextContent += fmt.Sprintf("\n%s\n", string(content))
for _, path := range contextFiles {
// Check if path ends with a slash (indicating a directory)
if strings.HasSuffix(path, "/") {
// Handle directory - read all files within it
dirPath := filepath.Join(workDir, path)
files, err := os.ReadDir(dirPath)
if err == nil {
for _, file := range files {
if !file.IsDir() {
filePath := filepath.Join(dirPath, file.Name())
content, err := os.ReadFile(filePath)
if err == nil {
contextContent += fmt.Sprintf("\n# From %s\n%s\n", file.Name(), string(content))
}
}
}
}
} else {
// Handle individual file as before
filePath := filepath.Join(workDir, path)
content, err := os.ReadFile(filePath)
if err == nil {
contextContent += fmt.Sprintf("\n%s\n", string(content))
}
}
}

Expand Down