@@ -4,6 +4,7 @@ import (
6 "path/filepath"
6 "path/filepath"
8 "github.com/opencode-ai/opencode/internal/config"
9 "github.com/opencode-ai/opencode/internal/config"
9 "github.com/opencode-ai/opencode/internal/llm/models"
10 "github.com/opencode-ai/opencode/internal/llm/models"
@@ -13,6 +14,7 @@ import (
13var contextFiles = []string{
14var contextFiles = []string{
14 ".github/copilot-instructions.md",
15 ".github/copilot-instructions.md",
15 ".cursorrules",
16 ".cursorrules",
17+ ".cursor/rules/", // Directory containing multiple rule files
16 "CLAUDE.md",
18 "CLAUDE.md",
17 "CLAUDE.local.md",
19 "CLAUDE.local.md",
18 "opencode.md",
20 "opencode.md",
@@ -51,11 +53,30 @@ func getContextFromFiles() string {
51 workDir := config.WorkingDirectory()
53 workDir := config.WorkingDirectory()
52 var contextContent string
54 var contextContent string
54− for _, file := range contextFiles {
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)
63+ for _, file := range files {
55− filePath := filepath.Join(workDir, file)
65+ filePath := filepath.Join(dirPath, file.Name())
66+ content, err := os.ReadFile(filePath)
68+ contextContent += fmt.Sprintf("\n# From %s\n%s\n", file.Name(), string(content))
74+ // Handle individual file as before
75+ filePath := filepath.Join(workDir, path)
56− content, err := os.ReadFile(filePath)
76+ content, err := os.ReadFile(filePath)
57− if err == nil {
77+ if err == nil {
58− contextContent += fmt.Sprintf("\n%s\n", string(content))
78+ contextContent += fmt.Sprintf("\n%s\n", string(content))