Skip to content

Commit 1d63fb6

Browse files
authored
Run prettier on src (RooCodeInc#4478)
1 parent 5bc6690 commit 1d63fb6

File tree

7 files changed

+135
-55
lines changed

7 files changed

+135
-55
lines changed

src/core/prompts/sections/__tests__/objective.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ describe("getObjectiveSection", () => {
1919
describe("when codebase_search is available", () => {
2020
it("should include codebase_search first enforcement in thinking process", () => {
2121
const objective = getObjectiveSection(mockCodeIndexManagerEnabled)
22-
22+
2323
// Check that the objective includes the codebase_search enforcement
24-
expect(objective).toContain("if the task involves understanding existing code or functionality, you MUST use the `codebase_search` tool")
24+
expect(objective).toContain(
25+
"if the task involves understanding existing code or functionality, you MUST use the `codebase_search` tool",
26+
)
2527
expect(objective).toContain("BEFORE using any other search or file exploration tools")
2628
})
2729
})
2830

2931
describe("when codebase_search is not available", () => {
3032
it("should not include codebase_search enforcement", () => {
3133
const objective = getObjectiveSection(mockCodeIndexManagerDisabled)
32-
34+
3335
// Check that the objective does not include the codebase_search enforcement
3436
expect(objective).not.toContain("you MUST use the `codebase_search` tool")
3537
expect(objective).not.toContain("BEFORE using any other search or file exploration tools")
@@ -39,7 +41,7 @@ describe("getObjectiveSection", () => {
3941
it("should maintain proper structure regardless of codebase_search availability", () => {
4042
const objectiveEnabled = getObjectiveSection(mockCodeIndexManagerEnabled)
4143
const objectiveDisabled = getObjectiveSection(mockCodeIndexManagerDisabled)
42-
44+
4345
// Check that all numbered items are present in both cases
4446
for (const objective of [objectiveEnabled, objectiveDisabled]) {
4547
expect(objective).toContain("1. Analyze the user's task")
@@ -53,7 +55,7 @@ describe("getObjectiveSection", () => {
5355
it("should include thinking tags guidance regardless of codebase_search availability", () => {
5456
const objectiveEnabled = getObjectiveSection(mockCodeIndexManagerEnabled)
5557
const objectiveDisabled = getObjectiveSection(mockCodeIndexManagerDisabled)
56-
58+
5759
// Check that thinking tags guidance is included in both cases
5860
for (const objective of [objectiveEnabled, objectiveDisabled]) {
5961
expect(objective).toContain("<thinking></thinking> tags")
@@ -65,13 +67,15 @@ describe("getObjectiveSection", () => {
6567
it("should include parameter inference guidance regardless of codebase_search availability", () => {
6668
const objectiveEnabled = getObjectiveSection(mockCodeIndexManagerEnabled)
6769
const objectiveDisabled = getObjectiveSection(mockCodeIndexManagerDisabled)
68-
70+
6971
// Check parameter inference guidance in both cases
7072
for (const objective of [objectiveEnabled, objectiveDisabled]) {
7173
expect(objective).toContain("Go through each of the required parameters")
72-
expect(objective).toContain("determine if the user has directly provided or given enough information to infer a value")
74+
expect(objective).toContain(
75+
"determine if the user has directly provided or given enough information to infer a value",
76+
)
7377
expect(objective).toContain("DO NOT invoke the tool (not even with fillers for the missing params)")
7478
expect(objective).toContain("ask_followup_question tool")
7579
}
7680
})
77-
})
81+
})

src/core/prompts/sections/__tests__/tool-use-guidelines.test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ describe("getToolUseGuidelinesSection", () => {
1919
describe("when codebase_search is available", () => {
2020
it("should include codebase_search first enforcement", () => {
2121
const guidelines = getToolUseGuidelinesSection(mockCodeIndexManagerEnabled)
22-
22+
2323
// Check that the guidelines include the codebase_search enforcement
24-
expect(guidelines).toContain("IMPORTANT: When starting a new task or when you need to understand existing code/functionality, you MUST use the `codebase_search` tool FIRST")
24+
expect(guidelines).toContain(
25+
"IMPORTANT: When starting a new task or when you need to understand existing code/functionality, you MUST use the `codebase_search` tool FIRST",
26+
)
2527
expect(guidelines).toContain("before any other search tools")
26-
expect(guidelines).toContain("semantic search tool helps you find relevant code based on meaning rather than just keywords")
28+
expect(guidelines).toContain(
29+
"semantic search tool helps you find relevant code based on meaning rather than just keywords",
30+
)
2731
})
2832

2933
it("should maintain proper numbering with codebase_search", () => {
3034
const guidelines = getToolUseGuidelinesSection(mockCodeIndexManagerEnabled)
31-
35+
3236
// Check that all numbered items are present
3337
expect(guidelines).toContain("1. In <thinking> tags")
3438
expect(guidelines).toContain("2. **IMPORTANT:")
@@ -43,15 +47,17 @@ describe("getToolUseGuidelinesSection", () => {
4347
describe("when codebase_search is not available", () => {
4448
it("should not include codebase_search enforcement", () => {
4549
const guidelines = getToolUseGuidelinesSection(mockCodeIndexManagerDisabled)
46-
50+
4751
// Check that the guidelines do not include the codebase_search enforcement
48-
expect(guidelines).not.toContain("IMPORTANT: When starting a new task or when you need to understand existing code/functionality, you MUST use the `codebase_search` tool FIRST")
52+
expect(guidelines).not.toContain(
53+
"IMPORTANT: When starting a new task or when you need to understand existing code/functionality, you MUST use the `codebase_search` tool FIRST",
54+
)
4955
expect(guidelines).not.toContain("semantic search tool helps you find relevant code based on meaning")
5056
})
5157

5258
it("should maintain proper numbering without codebase_search", () => {
5359
const guidelines = getToolUseGuidelinesSection(mockCodeIndexManagerDisabled)
54-
60+
5561
// Check that all numbered items are present with correct numbering
5662
expect(guidelines).toContain("1. In <thinking> tags")
5763
expect(guidelines).toContain("2. Choose the most appropriate tool")
@@ -65,7 +71,7 @@ describe("getToolUseGuidelinesSection", () => {
6571
it("should include iterative process guidelines regardless of codebase_search availability", () => {
6672
const guidelinesEnabled = getToolUseGuidelinesSection(mockCodeIndexManagerEnabled)
6773
const guidelinesDisabled = getToolUseGuidelinesSection(mockCodeIndexManagerDisabled)
68-
74+
6975
// Check that the iterative process section is included in both cases
7076
for (const guidelines of [guidelinesEnabled, guidelinesDisabled]) {
7177
expect(guidelines).toContain("It is crucial to proceed step-by-step")
@@ -75,4 +81,4 @@ describe("getToolUseGuidelinesSection", () => {
7581
expect(guidelines).toContain("4. Ensure that each action builds correctly")
7682
}
7783
})
78-
})
84+
})

src/core/prompts/sections/objective.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import { EXPERIMENT_IDS, experiments } from "../../../shared/experiments"
22
import { CodeIndexManager } from "../../../services/code-index/manager"
33

4-
export function getObjectiveSection(codeIndexManager?: CodeIndexManager, experimentsConfig?: Record<string, boolean>): string {
5-
const isCodebaseSearchAvailable = codeIndexManager &&
4+
export function getObjectiveSection(
5+
codeIndexManager?: CodeIndexManager,
6+
experimentsConfig?: Record<string, boolean>,
7+
): string {
8+
const isCodebaseSearchAvailable =
9+
codeIndexManager &&
610
codeIndexManager.isFeatureEnabled &&
711
codeIndexManager.isFeatureConfigured &&
812
codeIndexManager.isInitialized
913

1014
const codebaseSearchInstruction = isCodebaseSearchAvailable
1115
? "First, if the task involves understanding existing code or functionality, you MUST use the `codebase_search` tool to search for relevant code based on the task's intent BEFORE using any other search or file exploration tools. Then, "
1216
: "First, "
13-
17+
1418
// Check if command execution is disabled via experiment
1519
const isCommandDisabled = experimentsConfig && experimentsConfig[EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND]
16-
20+
1721
const commandInstruction = !isCommandDisabled
1822
? " You may also provide a CLI command to showcase the result of your task; this can be particularly useful for web development tasks, where you can run e.g. \`open index.html\` to show the website you've built."
1923
: ""

src/core/prompts/sections/rules.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ function getEditingInstructions(diffStrategy?: DiffStrategy): string {
4545
return instructions.join("\n")
4646
}
4747

48-
export function getRulesSection(cwd: string, supportsComputerUse: boolean, diffStrategy?: DiffStrategy, codeIndexManager?: CodeIndexManager): string {
49-
const isCodebaseSearchAvailable = codeIndexManager &&
48+
export function getRulesSection(
49+
cwd: string,
50+
supportsComputerUse: boolean,
51+
diffStrategy?: DiffStrategy,
52+
codeIndexManager?: CodeIndexManager,
53+
): string {
54+
const isCodebaseSearchAvailable =
55+
codeIndexManager &&
5056
codeIndexManager.isFeatureEnabled &&
5157
codeIndexManager.isFeatureConfigured &&
5258
codeIndexManager.isInitialized

src/core/prompts/sections/tool-use-guidelines.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,53 @@
11
import { CodeIndexManager } from "../../../services/code-index/manager"
22

33
export function getToolUseGuidelinesSection(codeIndexManager?: CodeIndexManager): string {
4-
const isCodebaseSearchAvailable = codeIndexManager &&
4+
const isCodebaseSearchAvailable =
5+
codeIndexManager &&
56
codeIndexManager.isFeatureEnabled &&
67
codeIndexManager.isFeatureConfigured &&
78
codeIndexManager.isInitialized
89

910
// Build guidelines array with automatic numbering
10-
let itemNumber = 1;
11-
const guidelinesList: string[] = [];
11+
let itemNumber = 1
12+
const guidelinesList: string[] = []
1213

1314
// 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+
)
1518

1619
// Conditional codebase search guideline
1720
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+
)
2027
} 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+
)
2231
}
2332

2433
// 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.`)
2738
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:
2839
- Information about whether the tool succeeded or failed, along with any reasons for failure.
2940
- Linter errors that may have arisen due to the changes you made, which you'll need to address.
3041
- 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+
)
3346

3447
// Join guidelines and add the footer
3548
return `# Tool Use Guidelines
3649
37-
${guidelinesList.join('\n')}
50+
${guidelinesList.join("\n")}
3851
3952
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:
4053
1. Confirm the success of each step before proceeding.

src/core/prompts/tools/attempt-completion.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,39 @@ import { ToolArgs } from "./types"
33

44
export function getAttemptCompletionDescription(args?: ToolArgs): string {
55
// Check if command execution is disabled via experiment
6-
const isCommandDisabled = args?.experiments && experiments.isEnabled(
7-
args.experiments,
8-
EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND
9-
)
6+
const isCommandDisabled =
7+
args?.experiments && experiments.isEnabled(args.experiments, EXPERIMENT_IDS.DISABLE_COMPLETION_COMMAND)
108

119
const baseDescription = `## attempt_completion
12-
Description: After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user.${!isCommandDisabled ? ' Optionally you may provide a CLI command to showcase the result of your work.' : ''} The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again.
10+
Description: After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user.${!isCommandDisabled ? " Optionally you may provide a CLI command to showcase the result of your work." : ""} The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again.
1311
IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in <thinking></thinking> tags if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool.
1412
Parameters:
1513
- result: (required) The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.`
1614

17-
const commandParameter = !isCommandDisabled ? `
18-
- command: (optional) A CLI command to execute to show a live demo of the result to the user. For example, use \`open index.html\` to display a created html website, or \`open localhost:3000\` to display a locally running development server. But DO NOT use commands like \`echo\` or \`cat\` that merely print text. This command should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.` : ''
15+
const commandParameter = !isCommandDisabled
16+
? `
17+
- command: (optional) A CLI command to execute to show a live demo of the result to the user. For example, use \`open index.html\` to display a created html website, or \`open localhost:3000\` to display a locally running development server. But DO NOT use commands like \`echo\` or \`cat\` that merely print text. This command should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.`
18+
: ""
1919

2020
const usage = `
2121
Usage:
2222
<attempt_completion>
2323
<result>
2424
Your final result description here
25-
</result>${!isCommandDisabled ? '\n<command>Command to demonstrate result (optional)</command>' : ''}
25+
</result>${!isCommandDisabled ? "\n<command>Command to demonstrate result (optional)</command>" : ""}
2626
</attempt_completion>`
2727

28-
const example = !isCommandDisabled ? `
28+
const example = !isCommandDisabled
29+
? `
2930
3031
Example: Requesting to attempt completion with a result and command
3132
<attempt_completion>
3233
<result>
3334
I've updated the CSS
3435
</result>
3536
<command>open index.html</command>
36-
</attempt_completion>` : `
37+
</attempt_completion>`
38+
: `
3739
3840
Example: Requesting to attempt completion with a result
3941
<attempt_completion>

0 commit comments

Comments
 (0)