Skip to content

Commit 8509bf8

Browse files
committed
Refine documentation and logic for include_content usage in codebase_search across repositories, clarifying external vs. current repo handling and adding URL comparison guidelines.
1 parent 163e8f9 commit 8509bf8

File tree

3 files changed

+59
-18
lines changed

3 files changed

+59
-18
lines changed

src/codealive_mcp_server.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
- IMPORTANT: Only use "deep" search mode for very complex conceptual queries as it's resource-intensive
5454
- Remember that context from previous messages is maintained in the same conversation
5555
56+
CRITICAL - include_content parameter usage:
57+
- For the CURRENT repository (user's working directory): Use include_content=false
58+
* You already have file access via Read tool
59+
* Get file paths from search, then read them directly for latest content
60+
- For EXTERNAL repositories (not in working directory): Use include_content=true
61+
* You cannot access these files directly
62+
* Content must be included in search results
63+
- Compare repository URLs from get_data_sources with current git repo to identify which is which
64+
5665
Flexible data source usage:
5766
- You can use a workspace name as a single data source to search or chat across all its repositories at once
5867
- Alternatively, you can use specific repository names for more targeted searches

src/tools/datasources.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ async def get_data_sources(ctx: Context, alive_only: bool = True) -> str:
2828
- description: Summary of the codebase contents to guide search and chat usage
2929
- type: The type of data source ("Repository" or "Workspace")
3030
- url: URL of the repository (for Repository type only)
31+
IMPORTANT: Use this URL to identify if a repository matches your current working directory.
32+
Compare with your local git remote URL to determine if it's the current or external repo.
3133
- state: The processing state of the data source (if alive_only=false)
3234
3335
Examples:
@@ -42,8 +44,12 @@ async def get_data_sources(ctx: Context, alive_only: bool = True) -> str:
4244
Other states include "New" (just added), "Processing" (being indexed),
4345
"Failed" (indexing failed), etc.
4446
45-
For repositories, the URL can be used to match with local git repositories
46-
to provide enhanced context for code understanding.
47+
CRITICAL for optimizing include_content parameter:
48+
- Compare repository URLs with your current git remote URL (git config --get remote.origin.url)
49+
- If URLs match: This is your CURRENT repository
50+
→ Use include_content=false in codebase_search, then read files with Read tool
51+
- If URLs don't match: This is an EXTERNAL repository
52+
→ Use include_content=true in codebase_search to get content directly
4753
4854
Use the returned data source names with the codebase_search and codebase_consultant functions.
4955
"""

src/tools/search.py

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,53 @@ async def codebase_search(
6666
cross-cutting questions.
6767
6868
include_content: Whether to include full file content in results (default: false).
69-
Agents should proactively request content when needed by setting this to true.
70-
Note: File content may be outdated compared to current local state.
7169
72-
Returns:
73-
Search results as JSON including source info, file paths, line numbers, and code snippets.
74-
75-
Examples:
76-
1. Natural-language question (recommended):
77-
codebase_search(query="What is the auth flow?", data_sources=["repo123"])
70+
IMPORTANT - When to include content:
71+
- For EXTERNAL repositories (not in your current working directory):
72+
SET TO TRUE - you don't have file access, so you need the content.
73+
- For CURRENT repository (the one you're working in):
74+
SET TO FALSE - you already have file access via Read tool, so just get
75+
file paths and read them directly for the latest content.
7876
79-
2. Intent query:
80-
codebase_search(query="Where is user registration logic?", data_sources=["repo123"])
77+
How to identify current vs external repositories:
78+
- Compare repository URLs from get_data_sources with your current git repo URL
79+
- Current repo: Use include_content=false, then use Read tool on result paths
80+
- External repos: Use include_content=true to get the content directly
8181
82-
3. Workspace-wide question:
83-
codebase_search(query="How do microservices talk to the billing API?", data_sources=["backend-team"])
82+
Note: Indexed content may be from a different branch than your local state.
8483
85-
4. Mixed query with a known identifier:
86-
codebase_search(query="Where do we validate JWTs (AuthService)?", data_sources=["repo123"])
84+
Returns:
85+
Search results as JSON including source info, file paths, line numbers, and code snippets.
8786
88-
5. Concise results without full file contents:
89-
codebase_search(query="Where is password reset handled?", data_sources=["repo123"], include_content=false)
87+
Examples:
88+
1. Search CURRENT repository (you have file access):
89+
codebase_search(
90+
query="Where is user authentication handled?",
91+
data_sources=["my-current-repo"],
92+
include_content=false # Get paths only, then use Read tool
93+
)
94+
# Then read the files: Read(file_path="/path/from/results")
95+
96+
2. Search EXTERNAL repository (no file access):
97+
codebase_search(
98+
query="How does the payment service validate cards?",
99+
data_sources=["external-payments-repo"],
100+
include_content=true # Need content, can't read files directly
101+
)
102+
103+
3. Workspace-wide question across external repos:
104+
codebase_search(
105+
query="How do microservices talk to the billing API?",
106+
data_sources=["backend-team"],
107+
include_content=true # External workspace, include content
108+
)
109+
110+
4. Mixed query with known identifier:
111+
codebase_search(
112+
query="Where do we validate JWTs (AuthService)?",
113+
data_sources=["repo123"],
114+
include_content=false # Current repo, read files separately
115+
)
90116
91117
Note:
92118
- At least one data source name must be provided

0 commit comments

Comments
 (0)