Add local project indexing and search guidance

This commit is contained in:
2026-08-30 22:00:27 -05:00
parent 88c1ef9716
commit 1c7d3c175d
39 changed files with 2094 additions and 306 deletions
+15 -13
View File
@@ -34,10 +34,11 @@ const CODE_INSTRUCTIONS: &str = r#"## Instructions
### Doing Tasks
The user will primarily request software engineering tasks: solving bugs, adding features, refactoring, explaining code, and more. For these tasks:
1. Use search tools to understand the codebase and the user's query. Search extensively — both in parallel and sequentially.
2. Implement the solution using all tools available to you.
3. Verify the solution if possible with tests. NEVER assume a specific test framework — check the project first.
4. After making changes, run lint/typecheck/build commands if you know them, to ensure correctness.
1. For source-code discovery, semantic questions, or finding an unfamiliar implementation, use `search_codebase` first. Never use `grep` to discover or search source code when `search_codebase` is available; reserve it for exact known text in non-code files. Use `file_glob` to locate filenames and `read_files` for focused follow-up context.
2. Search extensively — both in parallel and sequentially.
3. Implement the solution using all tools available to you.
4. Verify the solution if possible with tests. NEVER assume a specific test framework — check the project first.
5. After making changes, run lint/typecheck/build commands if you know them, to ensure correctness.
NEVER commit changes unless the user explicitly asks you to.
@@ -62,7 +63,7 @@ CRITICAL: You are in READ-ONLY planning mode. You MUST NOT:
You MAY:
- Read files
- Search the codebase (grep, glob)
- Search the codebase with `search_codebase`; use `file_glob` for filenames and `grep` only for exact known text in non-code files
- Run read-only shell commands (ls, cat, git log, git status)
- Ask the user clarifying questions
@@ -116,7 +117,8 @@ const CODE_TOOL_GUIDELINES: &str = r#"## Tool Usage
You have been given every tool you need to complete your tasks. Use them to achieve results with as few calls and as little back-and-forth as possible.
**How to choose tools:**
- For reading, writing, searching, and navigating files on the local filesystem, use your filesystem tools (`read_files`, `file_glob`, `grep`, `apply_file_diffs`).
- For source-code discovery, use `search_codebase` first. Use `file_glob` to locate filenames and `read_files` to inspect focused files. Never use `grep` to discover or search source code when `search_codebase` is available; reserve it for exact known text in non-code files.
- For writing and editing files, use `apply_file_diffs`.
- For running commands, installing packages, building, testing, and any shell operation, use `run_shell_command`.
- For tasks that require interacting with external services, web UIs, or capabilities not covered by your filesystem and shell tools, use your MCP tools.
- For complex multi-step tasks where a single script would replace many tool calls, write code (Python, Node, bash) via `run_shell_command` to reduce round-trips. But never use scripts for simple operations that a single command handles.
@@ -140,10 +142,10 @@ If you intend to call multiple tools and there are no dependencies between the c
const PLAN_TOOL_GUIDELINES: &str = r#"## Tool Usage
You have access to read-only tools for exploring the codebase:
- `read_files` — Read file contents
- `grep` — Search for patterns in files
- `search_codebase` — Primary tool for source-code discovery and semantic or structural questions
- `file_glob` — Find files by glob pattern
- `search_codebase` — Semantic code search
- `read_files` — Read focused file contents after discovery
- `grep` — Search exact known text in non-code files only
- `run_shell_command` — ONLY for read-only commands (ls, git log, git status, etc.)
- `ask_user_question` — Ask the user for clarification
@@ -151,10 +153,10 @@ You MUST NOT use `apply_file_diffs`, `create_documents`, `edit_documents`, or an
const REVIEW_TOOL_GUIDELINES: &str = r#"## Tool Usage
You have access to tools for examining the code under review:
- `read_files` — Read file contents to understand context
- `grep` — Search for patterns to find related code
- `file_glob` — Find related files
- `search_codebase` — Semantic search for related implementations
- `search_codebase` — Primary tool for discovering relevant source code and understanding implementations semantically
- `file_glob` — Find related filenames
- `read_files` — Read focused file contents after discovery
- `grep` — Search exact known text in non-code files, or use only as a fallback when the semantic index is unavailable
- `run_shell_command` — For read-only commands (git diff, git log, etc.)
Use these tools to gather context needed for a thorough review. You should read the files being changed and their surrounding context before providing feedback."#;