Skip to content

Commit 645082f

Browse files
authored
Merge pull request #16 from doITmagic/feature/mixt_search_code_documentation
Feature/mixt search code documentation
2 parents 293b7b3 + 2558812 commit 645082f

File tree

5 files changed

+75
-32
lines changed

5 files changed

+75
-32
lines changed

.github/workflows/build-binaries.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build and Commit Binaries
22

33
permissions:
44
contents: write
5+
pull-requests: write
56

67
on:
78
workflow_dispatch:
@@ -35,13 +36,11 @@ jobs:
3536
steps:
3637
- name: Checkout code
3738
uses: actions/checkout@v4
38-
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
40-
39+
4140
- name: Set up Go
4241
uses: actions/setup-go@v5
4342
with:
44-
go-version: '1.23' # Use stable version compatible with 1.25.1
43+
go-version: '1.23'
4544
cache: true
4645

4746
- name: Run tests
@@ -59,22 +58,17 @@ jobs:
5958
go build -o bin/ragcode-installer ./cmd/install
6059
6160
chmod +x bin/*
62-
63-
- name: Check if binaries changed
64-
id: check_changes
65-
run: |
66-
git add -f bin/
67-
if git diff --cached --quiet; then
68-
echo "changed=false" >> $GITHUB_OUTPUT
69-
else
70-
echo "changed=true" >> $GITHUB_OUTPUT
71-
fi
72-
73-
- name: Commit and push binaries
74-
if: github.event_name == 'push' && steps.check_changes.outputs.changed == 'true'
75-
run: |
76-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
77-
git config --local user.name "github-actions[bot]"
78-
git add -f bin/
79-
git commit -m "chore: auto-build binaries [skip ci]"
80-
git push
61+
62+
- name: Stage binaries
63+
run: git add -f bin/
64+
65+
- name: Create Pull Request
66+
uses: peter-evans/create-pull-request@v6
67+
with:
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
commit-message: "chore: update binaries [skip ci]"
70+
title: "chore: update binaries"
71+
body: "Auto-generated PR to update binaries after code changes."
72+
branch: "chore/update-binaries"
73+
base: ${{ github.head_ref || github.ref_name }}
74+
delete-branch: true

cmd/rag-code-mcp/main.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,10 @@ type MCPTool interface {
270270

271271
// SearchCodeInput defines the typed input for the search_code tool.
272272
type SearchCodeInput struct {
273-
Query string `json:"query"`
274-
Limit int `json:"limit,omitempty"`
275-
FilePath string `json:"file_path,omitempty"`
273+
Query string `json:"query"`
274+
Limit int `json:"limit,omitempty"`
275+
FilePath string `json:"file_path,omitempty"`
276+
IncludeDocs bool `json:"include_docs,omitempty"`
276277
}
277278

278279
// SearchCodeOutput defines the typed output for the search_code tool.
@@ -702,6 +703,9 @@ func registerSearchCodeToolTyped(server *mcp.Server, tool *tools.SearchLocalInde
702703
if input.FilePath != "" {
703704
args["file_path"] = input.FilePath
704705
}
706+
if input.IncludeDocs {
707+
args["include_docs"] = input.IncludeDocs
708+
}
705709

706710
start := time.Now()
707711
logger.Info("🛠️ Executing tool '%s' with args: %v", tool.Name(), args)
@@ -944,6 +948,10 @@ func getToolSchema(toolName string) map[string]interface{} {
944948
"type": "number",
945949
"description": "Maximum number of results to return (default: 5)",
946950
},
951+
"include_docs": map[string]interface{}{
952+
"type": "boolean",
953+
"description": "Optional: Include documentation (markdown, txt, etc.) in search results. Default is false (code only).",
954+
},
947955
},
948956
"required": []string{"query"},
949957
}
@@ -1112,6 +1120,10 @@ func getToolSchema(toolName string) map[string]interface{} {
11121120
"type": "number",
11131121
"description": "Maximum number of results to return (default: 5)",
11141122
},
1123+
"include_docs": map[string]interface{}{
1124+
"type": "boolean",
1125+
"description": "Optional: Include documentation (markdown, txt, etc.) in search results. Default is false (code only).",
1126+
},
11151127
},
11161128
"required": []string{"query"},
11171129
}

internal/tools/hybrid_search.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,23 @@ func (t *HybridSearchTool) Execute(ctx context.Context, params map[string]interf
146146
SearchCodeOnly(ctx context.Context, query []float64, limit int) ([]memory.Document, error)
147147
}
148148

149+
// Optional: include documentation in results
150+
includeDocs := false
151+
if inc, ok := params["include_docs"].(bool); ok {
152+
includeDocs = inc
153+
}
154+
149155
fetchLimit := int(math.Max(float64(limit*5), 10))
150156
var docs []memory.Document
151-
if codeSearcher, ok := searchMemory.(CodeSearcher); ok {
157+
158+
// If include_docs is true, use generic Search (returns all types)
159+
// If include_docs is false (default), try to use SearchCodeOnly
160+
if includeDocs {
161+
docs, err = searchMemory.Search(ctx, queryEmbedding, fetchLimit)
162+
} else if codeSearcher, ok := searchMemory.(CodeSearcher); ok {
152163
docs, err = codeSearcher.SearchCodeOnly(ctx, queryEmbedding, fetchLimit)
153164
} else {
165+
// Fallback if SearchCodeOnly not implemented
154166
docs, err = searchMemory.Search(ctx, queryEmbedding, fetchLimit)
155167
}
156168
if err != nil {

internal/tools/search_local_index.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ func (t *SearchLocalIndexTool) Execute(ctx context.Context, params map[string]in
167167
}
168168
}
169169

170-
// Search in workspace-specific collection, preferring code-only search
171-
// Try SearchCodeOnly first (excludes markdown), fall back to Search
170+
// Optional: include documentation in results
171+
includeDocs := false
172+
if inc, ok := params["include_docs"].(bool); ok {
173+
includeDocs = inc
174+
}
175+
176+
// Search in workspace-specific collection
172177
var docs []memory.Document
173178
var searchErr error
174179

@@ -177,9 +182,14 @@ func (t *SearchLocalIndexTool) Execute(ctx context.Context, params map[string]in
177182
SearchCodeOnly(ctx context.Context, query []float64, limit int) ([]memory.Document, error)
178183
}
179184

180-
if searcher, ok := workspaceMem.(CodeSearcher); ok {
185+
// If include_docs is true, use generic Search (returns all types)
186+
// If include_docs is false (default), try to use SearchCodeOnly
187+
if includeDocs {
188+
docs, searchErr = workspaceMem.Search(ctx, queryEmbedding, limit)
189+
} else if searcher, ok := workspaceMem.(CodeSearcher); ok {
181190
docs, searchErr = searcher.SearchCodeOnly(ctx, queryEmbedding, limit)
182191
} else {
192+
// Fallback if SearchCodeOnly not implemented
183193
docs, searchErr = workspaceMem.Search(ctx, queryEmbedding, limit)
184194
}
185195

internal/workspace/manager.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,25 @@ func (m *Manager) scanWorkspace(info *Info) (*workspaceScan, error) {
138138
case ".html", ".htm":
139139
addDirForLanguage(scan, dirCache, "html", filepath.Dir(path))
140140
addFileForLanguage(scan, "html", path)
141-
case ".md":
141+
case ".md", ".markdown", ".rst", ".adoc":
142142
scan.DocFiles = append(scan.DocFiles, path)
143+
case ".txt":
144+
// Only include .txt files if they are in a documentation directory
145+
dir := strings.ToLower(filepath.Base(filepath.Dir(path)))
146+
if dir == "docs" || dir == "doc" || dir == "documentation" {
147+
scan.DocFiles = append(scan.DocFiles, path)
148+
}
143149
default:
144-
// ignored
150+
// Check for standard documentation files without extension or specific names
151+
baseName := strings.ToUpper(filepath.Base(path))
152+
if strings.HasPrefix(baseName, "README") ||
153+
strings.HasPrefix(baseName, "LICENSE") ||
154+
strings.HasPrefix(baseName, "CHANGELOG") ||
155+
strings.HasPrefix(baseName, "CONTRIBUTING") ||
156+
strings.HasPrefix(baseName, "HISTORY") ||
157+
strings.HasPrefix(baseName, "NOTICE") {
158+
scan.DocFiles = append(scan.DocFiles, path)
159+
}
145160
}
146161
return nil
147162
})

0 commit comments

Comments
 (0)