@@ -4,6 +4,7 @@ import (
44 "fmt"
55 "os"
66 "path/filepath"
7+ "strings"
78
89 "github.com/opencode-ai/opencode/internal/config"
910 "github.com/opencode-ai/opencode/internal/llm/models"
@@ -13,6 +14,7 @@ import (
1314var contextFiles = []string{
1415 ".github/copilot-instructions.md",
1516 ".cursorrules",
17+ ".cursor/rules/", // Directory containing multiple rule files
1618 "CLAUDE.md",
1719 "CLAUDE.local.md",
1820 "opencode.md",
@@ -51,11 +53,30 @@ func getContextFromFiles() string {
5153 workDir := config.WorkingDirectory()
5254 var contextContent string
5355
54− for _, file := range contextFiles {
55− filePath := filepath.Join(workDir, file)
56− content, err := os.ReadFile(filePath)
57− if err == nil {
58− contextContent += fmt.Sprintf("\n%s\n", string(content))
56+ for _, path := range contextFiles {
57+ // Check if path ends with a slash (indicating a directory)
58+ if strings.HasSuffix(path, "/") {
59+ // Handle directory - read all files within it
60+ dirPath := filepath.Join(workDir, path)
61+ files, err := os.ReadDir(dirPath)
62+ if err == nil {
63+ for _, file := range files {
64+ if !file.IsDir() {
65+ filePath := filepath.Join(dirPath, file.Name())
66+ content, err := os.ReadFile(filePath)
67+ if err == nil {
68+ contextContent += fmt.Sprintf("\n# From %s\n%s\n", file.Name(), string(content))
69+ }
70+ }
71+ }
72+ }
73+ } else {
74+ // Handle individual file as before
75+ filePath := filepath.Join(workDir, path)
76+ content, err := os.ReadFile(filePath)
77+ if err == nil {
78+ contextContent += fmt.Sprintf("\n%s\n", string(content))
79+ }
5980 }
6081 }
6182