Skip to content

Commit 7adda5a

Browse files
authored
Merge pull request #25 from doITmagic/v2-detection-core
Major architectural overhaul of RagCode MCP (V2) — new unified service layer, deterministic AST-based exact match tools, native Ollama API client, stateless Streamable HTTP transport, and a dramatically reduced hardware footprint. Key Highlights & Features: * 🚀 **Deterministic Code Graph AST Search**: Completely replaced fuzzy keyword-based implementations with exact-match AST relation traversals natively inside Qdrant for 100% precision. * 📦 **Polyglot Parsing Subsystem**: Updated the language processors, modernized Python parsing natively via Tree-sitter, and standardized polyglot visibility logic. * 🛡️ **Hardened Error & Output Handling**: Removed LLM payload hallucinations in errors by strongly passing determinist Go errs. Redacted sensitive environment metadata from indexing payloads to block path-traversal/fingerprinting risks. * 🔄 **Memory-Safe State Operations**: Introduced safe unblocking disk reads/writes mechanism outside lock-states inside [index_progress.go](cci:7://file:///home/razvan/go/src/github.com/doITmagic/rag-code-mcp/internal/service/engine/index_progress.go:0:0-0:0) for zero-friction telemetry logging during parallel operations. * 📡 **Stateless MCP Transport**: Completely decoupled internal commands from legacy SSE stream constraints inside the stateless `mcp-http-client`. * ✅ **Comprehensive Testing Cover**: Added unit tests to `detect_context`, exactly matched relations arrays in [FindUsagesTool](cci:2://file:///home/razvan/go/src/github.com/doITmagic/rag-code-mcp/internal/service/tools/find_usages.go:17:0-19:1) and [IndexWorkspaceTool](cci:2://file:///home/razvan/go/src/github.com/doITmagic/rag-code-mcp/internal/service/tools/index_workspace.go:14:0-16:1) edge-case routing scenarios.
2 parents 0e897e4 + 344d4fa commit 7adda5a

346 files changed

Lines changed: 40917 additions & 24731 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
description: Global efficiency and token-optimization rules for senior development
3+
applyTo: '*'
4+
---
5+
6+
# Precision & Token Efficiency Rules
7+
8+
### 1. Response Constraints (Token Saving)
9+
* **No Prose:** Skip introductions, greetings, and "I've updated the file" summaries. Go straight to the solution.
10+
* **Diffs Only:** Never output the entire file. Use standard diff format or provide only the specific functions/blocks that changed.
11+
* **No Thinking Out Loud:** Do not explain your reasoning or "Chain of Thought" unless explicitly asked with "Explain your logic".
12+
* **Dry Output:** Use a telegraphic style. If a fix is obvious, just provide the code.
13+
14+
### 2. Context Handling
15+
* **Lazy Loading:** Do not read files outside the immediate scope of the task unless necessary for type definitions or interface alignment.
16+
* **Reference-Only:** When referring to existing code, use line numbers or function names instead of re-quoting the code in the chat.
17+
* **Minimal Boilerplate:** Do not generate repetitive code (getters/setters, imports) unless they are new or modified. Use `// ... existing code ...` to skip unchanged sections.
18+
19+
### 3. Engineering Standards
20+
* **Interface-Driven:** Prioritize checking interfaces/types before suggesting logic changes to avoid iterative fixes.
21+
* **Silence is Golden:** If the task is completed via a file edit, do not repeat the changes in the chat window. A simple "Done" or a brief summary of the file name is sufficient.
22+
* **Fail Fast:** If context is missing or ambiguous, ask a single clarifying question instead of guessing and generating high-token "hallucinated" solutions.
23+
24+
### 4. Technical Bias
25+
* Assume Senior-level competence: No basic explanations of language features or patterns.
26+
* Use concise modern syntax (e.g., arrow functions, destructuring, shorthand) by default to keep output length minimal.

.github/workflows/build-binaries.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ jobs:
4141
echo "Building rag-code-mcp..."
4242
go build -o bin/rag-code-mcp ./cmd/rag-code-mcp
4343
44-
echo "Building index-all..."
45-
go build -o bin/index-all ./cmd/index-all
46-
47-
echo "Building ragcode-installer..."
48-
go build -o bin/ragcode-installer ./cmd/install
44+
echo "Building rag-code-install..."
45+
go build -o bin/rag-code-install ./cmd/rag-code-install
4946
5047
chmod +x bin/*
5148

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ data/
33
test_data/
44
qdrant_data/
55
barou/
6+
inspirations/
7+
relations/
68

79
# Binaries
810
/cmd/agent-runner/agent-runner
911
/rag-code-mcp
1012
test-*
1113
bin/
12-
ragcode-installer
14+
tests/e2e/bin/
15+
rag-code-install
1316
index-all
14-
cmd/rag-code-mcp/rag-code-mcp
17+
rag-code-mcp
1518

1619
# Test programs
1720
cmd/test-*/
@@ -59,6 +62,7 @@ temp/
5962
scripts/
6063
.ragcode/
6164
.agent/skills/
65+
build-binaries.sh
6266

6367
# Debug logs
6468
startup_debug.txt

.goreleaser.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ builds:
4040
- -X main.Date={{.Date}}
4141
- -X main.BuiltBy=goreleaser
4242

43-
- id: ragcode-installer
44-
main: ./cmd/install
45-
binary: ragcode-installer
43+
- id: rag-code-install
44+
main: ./cmd/rag-code-install
45+
binary: rag-code-install
4646

4747
env:
4848
- CGO_ENABLED=0
@@ -110,8 +110,8 @@ archives:
110110
files:
111111
- LICENSE
112112
- README.md
113-
- config.yaml
114-
- .env.example
113+
- llms.txt
114+
- internal/config/default.yaml
115115

116116
checksum:
117117
name_template: 'checksums.txt'
@@ -162,13 +162,13 @@ release:
162162
**Linux (amd64):**
163163
```bash
164164
curl -L https://github.com/doITmagic/rag-code-mcp/releases/latest/download/rag-code-mcp_linux_amd64.tar.gz | tar xz
165-
./ragcode-installer -ollama=docker -qdrant=docker
165+
./rag-code-install -ollama=docker -qdrant=docker
166166
```
167167
168168
**macOS (Apple Silicon):**
169169
```bash
170170
curl -L https://github.com/doITmagic/rag-code-mcp/releases/latest/download/rag-code-mcp_darwin_arm64.tar.gz | tar xz
171-
./ragcode-installer -ollama=docker -qdrant=docker
171+
./rag-code-install -ollama=docker -qdrant=docker
172172
```
173173
174174
**Or download the archive for your platform below.**
@@ -198,8 +198,7 @@ brews:
198198
# Custom install script to handle multiple binaries
199199
install: |
200200
bin.install "rag-code-mcp"
201-
bin.install "ragcode-installer"
202-
bin.install "index-all"
201+
bin.install "rag-code-install"
203202
204203
test: |
205204
system "#{bin}/rag-code-mcp --version"

.windsurf/rules/general.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
# AI Governance Rules – Project Control Mode (Strict)
6+
7+
## 1. General Behavior Rules
8+
9+
### AI must never modify existing code unless:
10+
- A bug is proven.
11+
- A security issue is identified.
12+
- A performance bottleneck is demonstrated with measurable data.
13+
- The user explicitly approves the change.
14+
15+
### AI must never:
16+
- Refactor for style preference.
17+
- Rename variables for aesthetics.
18+
- Reorganize project structure.
19+
- “Improve readability” unless requested.
20+
21+
### All suggested changes must:
22+
- Be shown as a diff.
23+
- Include explanation.
24+
- Include impact analysis.
25+
- Include rollback instructions.
26+
27+
### No change is considered successful unless:
28+
- Tests pass.
29+
- Build passes.
30+
- Lint passes.
31+
- Manual verification steps are described.
32+
33+
### AI must ask for clarification if:
34+
- Business logic is unclear.
35+
- There is ambiguity in naming.
36+
- Multiple valid architectural choices exist.
37+
38+
## 🧠 Decision Gatekeeping Rule
39+
Before proposing ANY code change, AI must answer internally:
40+
- Is this required?
41+
- Is this measurable?
42+
- Is this aligned with existing architecture?
43+
- Is this backward compatible?
44+
45+
If one answer is "no" → ASK FIRST.
46+
47+
## 🧪 Testing Requirements (Mandatory)
48+
49+
### Golang — every backend change must include:
50+
- Unit test
51+
- Table-driven test when applicable
52+
- Error case coverage
53+
- Benchmark if performance-related
54+
- go vet clean
55+
- golangci-lint clean
56+
- No “looks correct”. Only tested code.
57+
58+
### JavaScript — if JS is touched:
59+
- No global scope pollution
60+
- No magic numbers
61+
- Defensive null checks
62+
- No breaking of existing event bindings
63+
- Must verify browser compatibility assumptions
64+
65+
If DOM is modified:
66+
- Ensure no layout shift unless intended
67+
- Verify no performance regression (reflow-heavy operations)
68+
69+
### Python — if Python is touched:
70+
- No side effects at module import (guard with `if __name__ == "__main__"`)
71+
- Avoid global mutable state; prefer dependency injection
72+
- Keep `pytest` (or equivalent) passing; add negative-path tests
73+
- Use type hints; keep `mypy`/type-checkers clean when configured
74+
- Pin dependencies in lock/constraints files (no implicit upgrades)
75+
76+
### CSS — AI must:
77+
- Not change global styles without explicit approval
78+
- Not introduce !important unless justified
79+
- Not break mobile layout
80+
- Not modify spacing system
81+
- Follow existing naming convention (BEM or whatever you use)
82+
83+
### HTML — AI must:
84+
- Not restructure markup unless required
85+
- Preserve accessibility attributes
86+
- Not remove ARIA roles
87+
- Not remove semantic tags
88+
- Keep forms backward compatible
89+
90+
## 🚫 Optimization Control Rules
91+
AI must NOT:
92+
- Optimize prematurely
93+
- Replace loops with concurrency without justification
94+
- Introduce goroutines unless concurrency is proven necessary
95+
- Add caching without defining invalidation strategy
96+
- Change data structures without complexity analysis
97+
98+
## 🔐 Backend Specific (Golang)
99+
AI must:
100+
- Not introduce global state
101+
- Not introduce hidden side effects
102+
- Respect context propagation (context.Context)
103+
- Not swallow errors
104+
- Always wrap errors properly
105+
- Not introduce reflection unless necessary
106+
- Not introduce generics unless justified
107+
108+
If touching DB:
109+
- Must preserve transaction boundaries
110+
- Must describe migration impact
111+
- Must describe rollback strategy
112+
113+
## 📦 Dependency Rules
114+
AI must:
115+
- Not introduce new dependencies without approval
116+
- Justify every dependency
117+
- Prefer standard library
118+
- Check license compatibility
119+
- Evaluate maintenance status
120+
121+
## 📊 Reporting Rules
122+
AI must never say:
123+
- “It should work.”
124+
- “This is fixed.”
125+
- “Problem solved.”
126+
127+
Instead must report:
128+
- What was changed
129+
- What was tested
130+
- What was verified
131+
- What was not verified
132+
- Potential side effects
133+
134+
## 🔍 Change Proposal Format (Mandatory)
135+
Every change must follow this structure:
136+
- Problem Description
137+
- Root Cause Analysis
138+
- Proposed Change (diff)
139+
- Impact Scope
140+
- Risk Assessment
141+
- Test Plan
142+
- Rollback Plan
143+
144+
No exceptions.
145+
146+
## 🧱 Architecture Preservation Rule
147+
AI must:
148+
- Preserve layering (handler → service → repository)
149+
- Not bypass service layer
150+
- Not mix transport and business logic
151+
- Not leak DB models into API layer
152+
- Not couple JS tightly to backend implementation details
153+
154+
## ⚠️ Failure Handling Rules
155+
AI must:
156+
- Never ignore error return values
157+
- Never panic in production paths
158+
- Not suppress logs
159+
- Use structured logging
160+
161+
## 📈 Performance Rules
162+
Before suggesting performance optimization, AI must provide:
163+
- Current complexity (Big O)
164+
- Proposed complexity
165+
- Expected gain
166+
- Trade-offs
167+
- Benchmark example
168+
169+
## 🧭 When AI Must Stop and Ask
170+
- When modifying authentication
171+
- When modifying authorization
172+
- When touching financial logic
173+
- When changing concurrency model
174+
- When modifying public API
175+
176+
## 💬 Strict Interaction Rule
177+
AI must:
178+
- Treat all existing code as intentional
179+
- Assume developer competence
180+
- Not override architectural decisions
181+
- Provide alternatives, not unilateral decisions
182+
- Never perform changes autonomously; always explain the motivation before modifying code
183+
- Never run destructive Git commands (reset/rebase/clean/force push) without explicit user approval
184+
- Never optimize code outside the current task scope

0 commit comments

Comments
 (0)