|
1 | 1 | import { CodeIndexManager } from "../../../services/code-index/manager" |
2 | 2 |
|
3 | 3 | export function getToolUseGuidelinesSection(codeIndexManager?: CodeIndexManager): string { |
4 | | - const isCodebaseSearchAvailable = codeIndexManager && |
| 4 | + const isCodebaseSearchAvailable = |
| 5 | + codeIndexManager && |
5 | 6 | codeIndexManager.isFeatureEnabled && |
6 | 7 | codeIndexManager.isFeatureConfigured && |
7 | 8 | codeIndexManager.isInitialized |
8 | 9 |
|
9 | 10 | // Build guidelines array with automatic numbering |
10 | | - let itemNumber = 1; |
11 | | - const guidelinesList: string[] = []; |
| 11 | + let itemNumber = 1 |
| 12 | + const guidelinesList: string[] = [] |
12 | 13 |
|
13 | 14 | // First guideline is always the same |
14 | | - guidelinesList.push(`${itemNumber++}. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.`); |
| 15 | + guidelinesList.push( |
| 16 | + `${itemNumber++}. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.`, |
| 17 | + ) |
15 | 18 |
|
16 | 19 | // Conditional codebase search guideline |
17 | 20 | if (isCodebaseSearchAvailable) { |
18 | | - guidelinesList.push(`${itemNumber++}. **IMPORTANT: When starting a new task or when you need to understand existing code/functionality, you MUST use the \`codebase_search\` tool FIRST before any other search tools.** This semantic search tool helps you find relevant code based on meaning rather than just keywords. Only after using codebase_search should you use other tools like search_files, list_files, or read_file for more specific exploration.`); |
19 | | - guidelinesList.push(`${itemNumber++}. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.`); |
| 21 | + guidelinesList.push( |
| 22 | + `${itemNumber++}. **IMPORTANT: When starting a new task or when you need to understand existing code/functionality, you MUST use the \`codebase_search\` tool FIRST before any other search tools.** This semantic search tool helps you find relevant code based on meaning rather than just keywords. Only after using codebase_search should you use other tools like search_files, list_files, or read_file for more specific exploration.`, |
| 23 | + ) |
| 24 | + guidelinesList.push( |
| 25 | + `${itemNumber++}. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.`, |
| 26 | + ) |
20 | 27 | } else { |
21 | | - guidelinesList.push(`${itemNumber++}. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.`); |
| 28 | + guidelinesList.push( |
| 29 | + `${itemNumber++}. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.`, |
| 30 | + ) |
22 | 31 | } |
23 | 32 |
|
24 | 33 | // Remaining guidelines |
25 | | - guidelinesList.push(`${itemNumber++}. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.`); |
26 | | - guidelinesList.push(`${itemNumber++}. Formulate your tool use using the XML format specified for each tool.`); |
| 34 | + guidelinesList.push( |
| 35 | + `${itemNumber++}. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.`, |
| 36 | + ) |
| 37 | + guidelinesList.push(`${itemNumber++}. Formulate your tool use using the XML format specified for each tool.`) |
27 | 38 | guidelinesList.push(`${itemNumber++}. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include: |
28 | 39 | - Information about whether the tool succeeded or failed, along with any reasons for failure. |
29 | 40 | - Linter errors that may have arisen due to the changes you made, which you'll need to address. |
30 | 41 | - New terminal output in reaction to the changes, which you may need to consider or act upon. |
31 | | - - Any other relevant feedback or information related to the tool use.`); |
32 | | - guidelinesList.push(`${itemNumber++}. ALWAYS wait for user confirmation after each tool use before proceeding. Never assume the success of a tool use without explicit confirmation of the result from the user.`); |
| 42 | + - Any other relevant feedback or information related to the tool use.`) |
| 43 | + guidelinesList.push( |
| 44 | + `${itemNumber++}. ALWAYS wait for user confirmation after each tool use before proceeding. Never assume the success of a tool use without explicit confirmation of the result from the user.`, |
| 45 | + ) |
33 | 46 |
|
34 | 47 | // Join guidelines and add the footer |
35 | 48 | return `# Tool Use Guidelines |
36 | 49 |
|
37 | | -${guidelinesList.join('\n')} |
| 50 | +${guidelinesList.join("\n")} |
38 | 51 |
|
39 | 52 | It is crucial to proceed step-by-step, waiting for the user's message after each tool use before moving forward with the task. This approach allows you to: |
40 | 53 | 1. Confirm the success of each step before proceeding. |
|
0 commit comments