Skip to content

Commit 4cc6191

Browse files
committed
refactor: implement final review feedback for workspace detection and tool evaluation
1 parent 4f675a3 commit 4cc6191

File tree

19 files changed

+131
-56
lines changed

19 files changed

+131
-56
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ jobs:
2727
id: check_token
2828
run: |
2929
if [ -n "${{ secrets.HOMEBREW_TAP_TOKEN }}" ]; then
30-
echo "HAS_TAP_TOKEN=true" >> $GITHUB_OUTPUT
31-
echo "HOMEBREW_TAP_TOKEN is present. Using it for Homebrew updates."
30+
echo "SKIP_HOMEBREW=" >> $GITHUB_OUTPUT
31+
echo "HOMEBREW_TAP_TOKEN is present. Homebrew updates enabled."
3232
else
33-
echo "HAS_TAP_TOKEN=false" >> $GITHUB_OUTPUT
34-
echo "HOMEBREW_TAP_TOKEN is missing. Homebrew Tap update will be skipped or may fail if GITHUB_TOKEN has no cross-repo access."
33+
echo "SKIP_HOMEBREW=--skip=homebrew" >> $GITHUB_OUTPUT
34+
echo "HOMEBREW_TAP_TOKEN is missing. Homebrew Tap update will be skipped."
3535
fi
3636
3737
- name: Fetch all tags
@@ -48,10 +48,10 @@ jobs:
4848
with:
4949
distribution: goreleaser
5050
version: v2.6.1
51-
args: release --clean
51+
args: release --clean ${{ steps.check_token.outputs.SKIP_HOMEBREW }}
5252
env:
5353
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN || secrets.GITHUB_TOKEN }}
54+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
5555

5656
- name: Update server.json version
5757
run: |

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ brews:
187187
- repository:
188188
owner: doITmagic
189189
name: homebrew-tap
190-
# Use a dedicated token if available, otherwise fallback to GITHUB_TOKEN
190+
# REQUIRED: A dedicated token (HOMEBREW_TAP_TOKEN) with write access to the tap repository.
191191
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
192192

193193
directory: Formula

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ First query triggers background indexing. Subsequent queries are instant.
148148
- **Without RagCode:** AI reads 5-10 files (~15,000 tokens) to find a function
149149
- **With RagCode:** AI gets exact function + context (~200 tokens)
150150
151+
> [!TIP]
152+
> **Token Management:** By default, search tools return the top **5 most relevant results**. This is optimized to provide high-quality context while keeping token usage low. You can customize this by passing a `limit` parameter to any search tool.
153+
151154
### RagCode vs Cloud-Based Solutions
152155
153156
| Feature | RagCode (Local) | Cloud AI Search |

cmd/rag-code-mcp/main.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,20 @@ func extractFilePathsFromRoots(roots []*mcp.Root) []string {
13571357
var rootPaths []string
13581358
for _, r := range roots {
13591359
u, err := url.Parse(r.URI)
1360-
if err == nil && u.Scheme == "file" {
1361-
rootPaths = append(rootPaths, u.Path)
1360+
if err != nil {
1361+
logger.Warn("Failed to parse workspace root URI %s: %v", r.URI, err)
1362+
continue
1363+
}
1364+
1365+
if u.Scheme == "file" {
1366+
path := u.Path
1367+
// On Windows, the path might be /C:/path, trim the leading slash
1368+
if len(path) > 2 && path[0] == '/' && path[2] == ':' {
1369+
path = path[1:]
1370+
}
1371+
rootPaths = append(rootPaths, path)
1372+
} else {
1373+
logger.Warn("Workspace root URI scheme %q is not supported: %s. Only 'file://' roots are registered automatically for local indexing.", u.Scheme, r.URI)
13621374
}
13631375
}
13641376
return rootPaths

docs/CONFIGURATION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ llm:
3030
model: "phi3:medium" # LLM for code analysis
3131
embed_model: "mxbai-embed-large" # Embedding model
3232

33+
> [!WARNING]
34+
> **Model Naming:** When specifying models, use the exact name as shown in `ollama list`.
35+
> RagCode automatically handles the implicit `:latest` tag (e.g., `model` matches `model:latest`).
36+
> If you use a specific tag like `:v1`, ensure it is included both in your config and in your `ollama pull` command.
37+
3338
storage:
3439
vector_db:
3540
url: "http://localhost:6333"

internal/healthcheck/healthcheck.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,36 @@ func CheckOllamaWithModels(baseURL string, requiredModels []string) CheckResult
7979
return result
8080
}
8181

82-
installed := make(map[string]bool)
83-
for _, m := range tags.Models {
84-
installed[m.Name] = true
85-
// Also track without :latest tag
86-
if strings.HasSuffix(m.Name, ":latest") {
87-
installed[strings.TrimSuffix(m.Name, ":latest")] = true
82+
// Normalize helper: returns model name and tag
83+
normalize := func(name string) (string, string) {
84+
if !strings.Contains(name, ":") {
85+
return name, "latest"
8886
}
87+
parts := strings.SplitN(name, ":", 2)
88+
return parts[0], parts[1]
8989
}
9090

9191
var missing []string
9292
for _, req := range requiredModels {
93-
if !installed[req] {
93+
reqBase, reqTag := normalize(req)
94+
found := false
95+
96+
for _, m := range tags.Models {
97+
mBase, mTag := normalize(m.Name)
98+
if reqBase == mBase && reqTag == mTag {
99+
found = true
100+
break
101+
}
102+
}
103+
104+
if !found {
94105
missing = append(missing, req)
95106
}
96107
}
97108

98109
if len(missing) > 0 {
99110
result.Status = "error"
100-
result.Message = fmt.Sprintf("Missing models: %s", strings.Join(missing, ", "))
111+
result.Message = fmt.Sprintf("Missing models: %s (Ollama implicit :latest tag might cause mismatch if you have specific versions installed)", strings.Join(missing, ", "))
101112
return result
102113
}
103114

internal/ragcode/analyzers/generic/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (a *CodeAnalyzer) shouldSkipDir(path, root string) bool {
120120
return true
121121
}
122122
switch base {
123-
case "node_modules", "vendor", "dist", "build", "public", "tmp":
123+
case "node_modules", "vendor", "dist", "build":
124124
return true
125125
default:
126126
return false

internal/ragcode/analyzers/html/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func shouldSkipDir(path, root string) bool {
187187
return true
188188
}
189189
switch base {
190-
case "node_modules", "vendor", "dist", "build", "public", "tmp":
190+
case "node_modules", "vendor", "dist", "build":
191191
return true
192192
default:
193193
return false

internal/tools/evaluate_ragcode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ func (t *EvaluateRagCodeTool) Name() string {
2424
}
2525

2626
func (t *EvaluateRagCodeTool) Description() string {
27-
return "Request a performance and quality evaluation of RagCode MCP from the AI assistant's perspective. Use this to provide feedback on benefits, pain points, and suggest improvements. IMPORTANT: Always provide the 'file_path' of the file you are currently working on for better context detection."
27+
return "Request a performance and quality evaluation of RagCode MCP from the AI assistant's perspective. Use this to provide feedback on benefits, pain points, and suggest improvements. RECOMMENDED: Providing the 'file_path' helps identifies the current project context for a more accurate evaluation, but it is not strictly mandatory."
2828
}
2929

3030
func (t *EvaluateRagCodeTool) Execute(ctx context.Context, args map[string]interface{}) (string, error) {
3131
log.Printf("[INFO] 🛠️ Executing tool '%s'\n", t.Name())
3232

3333
// Detect workspace for context, but continue gracefully if it fails
34-
info, err := t.wm.DetectWorkspace(args)
34+
info, err := DetectAndRegisterWorkspace(t.wm, args)
3535
var languages []string
3636
if err != nil {
3737
// For evaluation, lack of workspace context should not be fatal; log and continue.
@@ -76,7 +76,7 @@ func (t *EvaluateRagCodeTool) Execute(ctx context.Context, args map[string]inter
7676
builder.WriteString(fmt.Sprintf("- **Workspace**: %s\n", info.Root))
7777
builder.WriteString(fmt.Sprintf("- **Languages**: %s\n", strings.Join(languages, ", ")))
7878
} else {
79-
builder.WriteString("- **Workspace**: Not detected (fallback mode)\n")
79+
builder.WriteString("- **Workspace**: Not detected (fallback mode). This means RagCode is using global settings because it couldn't identify a specific project root. To enable workspace-specific context, please ensure you provide a 'file_path' of a file within the project in your tool requests.\n")
8080
}
8181
builder.WriteString(fmt.Sprintf("- **System Status**:\n%s\n", strings.Join(healthStatus, "\n")))
8282
builder.WriteString(fmt.Sprintf("- **Models**: Chat=%s, Embed=%s\n\n", cfg.LLM.OllamaModel, cfg.LLM.OllamaEmbed))

internal/tools/find_implementations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (t *FindImplementationsTool) Execute(ctx context.Context, args map[string]i
6464
var workspaceInfo *workspace.Info
6565
if t.workspaceManager != nil {
6666
var err error
67-
workspaceInfo, err = t.workspaceManager.DetectWorkspace(args)
67+
workspaceInfo, err = DetectAndRegisterWorkspace(t.workspaceManager, args)
6868
if err != nil {
6969
return HandleWorkspaceDetectionError(err, "")
7070
}

0 commit comments

Comments
 (0)