Skip to content

Commit 40b50e5

Browse files
author
razvan
committed
workspace: centralize default detection markers and include .ragcode
1 parent 0c22bf4 commit 40b50e5

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed

cmd/rag-code-mcp/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ workspace:
333333
- build.gradle
334334
- Gemfile
335335
- Package.swift
336+
- .ragcode
337+
- .agent
338+
- .idea
339+
- .vscode
340+
- .vs
341+
- .cursor
342+
- .windsurf
343+
- AGENTS.md
344+
- CLAUDE.md
336345
exclude_patterns:
337346
- node_modules
338347
- .git
@@ -1361,7 +1370,7 @@ func ensureIDERules(cfg *config.Config, filePath string) {
13611370
}
13621371

13631372
workspaceRoot := ""
1364-
markers := []string{".git", "go.mod", "package.json", "composer.json"}
1373+
markers := append([]string(nil), config.DefaultWorkspaceDetectionMarkers...)
13651374
if cfg != nil && len(cfg.Workspace.DetectionMarkers) > 0 {
13661375
markers = cfg.Workspace.DetectionMarkers
13671376
}
@@ -1415,6 +1424,8 @@ func ensureIDERules(cfg *config.Config, filePath string) {
14151424

14161425
// 3. Define target rule files
14171426
targets := []string{
1427+
"AGENTS.md", // Agent instruction file (Cursor/Windsurf ecosystem)
1428+
"CLAUDE.md", // Claude Code project instructions
14181429
".cursorrules", // Cursor
14191430
".windsurfrules", // Windsurf
14201431
".clinerules", // Cline

internal/config/config.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ import (
44
"time"
55
)
66

7+
// DefaultWorkspaceDetectionMarkers defines default files/directories used to
8+
// detect workspace roots across config generation and runtime detection.
9+
var DefaultWorkspaceDetectionMarkers = []string{
10+
".git",
11+
"go.mod",
12+
"package.json",
13+
"Cargo.toml",
14+
"pyproject.toml",
15+
"setup.py",
16+
"requirements.txt",
17+
"composer.json",
18+
"pom.xml",
19+
"build.gradle",
20+
"Gemfile",
21+
"Package.swift",
22+
".ragcode",
23+
".agent",
24+
".idea",
25+
".vscode",
26+
".vs",
27+
".cursor",
28+
".windsurf",
29+
"AGENTS.md",
30+
"CLAUDE.md",
31+
}
32+
733
// Config represents the global application configuration
834
type Config struct {
935
// LLM configuration
@@ -172,7 +198,8 @@ type WorkspaceConfig struct {
172198
MaxWorkspaces int `yaml:"max_workspaces"`
173199

174200
// DetectionMarkers are files/directories used to identify workspace roots
175-
// Default: [".git", "go.mod", "package.json", "Cargo.toml", "pyproject.toml"]
201+
// Default includes language markers plus workspace metadata/IDE markers
202+
// (e.g. .ragcode, .agent, .idea, .cursor, AGENTS.md, CLAUDE.md)
176203
DetectionMarkers []string `yaml:"detection_markers"`
177204

178205
// ExcludePatterns are glob patterns for paths to exclude from workspace detection

internal/config/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func DefaultConfig() *Config {
138138
Enabled: true,
139139
AutoIndex: true,
140140
MaxWorkspaces: 10,
141-
DetectionMarkers: []string{".git", "go.mod", "package.json", "Cargo.toml", "pyproject.toml", "pom.xml"},
141+
DetectionMarkers: append([]string(nil), DefaultWorkspaceDetectionMarkers...),
142142
ExcludePatterns: []string{"node_modules", ".git", "vendor", "target", "build", "dist", ".venv"},
143143
CollectionPrefix: "ragcode",
144144
IndexInclude: []string{}, // Empty means use global rag_code.include

internal/workspace/detector.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"runtime"
1111
"strings"
1212
"time"
13+
14+
"github.com/doITmagic/rag-code-mcp/internal/config"
1315
)
1416

1517
// Detector detects workspace roots from file paths
@@ -31,32 +33,7 @@ type Detector struct {
3133
// NewDetector creates a new workspace detector with default markers
3234
func NewDetector() *Detector {
3335
return &Detector{
34-
markers: []string{
35-
".git", // Git repository (highest priority)
36-
"go.mod", // Go project
37-
"composer.json", // PHP/Laravel project
38-
"artisan", // Laravel project (specific)
39-
"package.json", // Node.js project
40-
"Cargo.toml", // Rust project
41-
"pyproject.toml", // Python project (PEP 518)
42-
"setup.py", // Python project (legacy)
43-
"pom.xml", // Maven project (Java)
44-
"build.gradle", // Gradle project (Java/Kotlin)
45-
"tsconfig.json", // TypeScript project
46-
"tailwind.config.js", // Tailwind CSS
47-
"tailwind.config.ts", // Tailwind CSS (TS)
48-
"vite.config.js", // Vite project
49-
"vite.config.ts", // Vite project (TS)
50-
"next.config.js", // Next.js project
51-
"deno.json", // Deno project
52-
"Makefile", // Generic automated build
53-
"Dockerfile", // Docker project
54-
"docker-compose.yml", // Docker compose project
55-
"Gemfile", // Ruby project
56-
"mix.exs", // Elixir project
57-
".project", // Generic project marker
58-
".vscode", // VS Code workspace
59-
},
36+
markers: append([]string(nil), config.DefaultWorkspaceDetectionMarkers...),
6037
excludePatterns: []string{
6138
// Only exclude common cache/temp directories in home or system paths
6239
// Don't exclude test temp directories

0 commit comments

Comments
 (0)