mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
fix: correct the type of arguments for the getToolDescription
This commit is contained in:
@@ -24,19 +24,19 @@ describe("main", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getToolDescription', () => {
|
describe("getToolDescription", () => {
|
||||||
it('should return tool description with correct cwd', () => {
|
it("should return tool description with correct cwd", () => {
|
||||||
const cwd = '/test/path'
|
const cwd = "/test/path"
|
||||||
const description = strategy.getToolDescription(cwd)
|
const description = strategy.getToolDescription({ cwd })
|
||||||
|
|
||||||
expect(description).toContain('apply_diff Tool - Generate Precise Code Changes')
|
expect(description).toContain("apply_diff Tool - Generate Precise Code Changes")
|
||||||
expect(description).toContain(cwd)
|
expect(description).toContain(cwd)
|
||||||
expect(description).toContain('Step-by-Step Instructions')
|
expect(description).toContain("Step-by-Step Instructions")
|
||||||
expect(description).toContain('Requirements')
|
expect(description).toContain("Requirements")
|
||||||
expect(description).toContain('Examples')
|
expect(description).toContain("Examples")
|
||||||
expect(description).toContain('Parameters:')
|
expect(description).toContain("Parameters:")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should apply simple diff correctly", async () => {
|
it("should apply simple diff correctly", async () => {
|
||||||
const original = `line1
|
const original = `line1
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export class NewUnifiedDiffStrategy implements DiffStrategy {
|
|||||||
return { hunks }
|
return { hunks }
|
||||||
}
|
}
|
||||||
|
|
||||||
getToolDescription(cwd: string): string {
|
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
|
||||||
return `# apply_diff Tool - Generate Precise Code Changes
|
return `# apply_diff Tool - Generate Precise Code Changes
|
||||||
|
|
||||||
Generate a unified diff that can be cleanly applied to modify code files.
|
Generate a unified diff that can be cleanly applied to modify code files.
|
||||||
@@ -164,8 +164,8 @@ Generate a unified diff that can be cleanly applied to modify code files.
|
|||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- path: (required) The path of the file to apply the diff to (relative to the current working directory ${args.cwd})
|
- path: (required) File path relative to ${args.cwd}
|
||||||
- diff: (required) The diff content in unified format to apply to the file.
|
- diff: (required) Unified diff content in unified format to apply to the file.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
<apply_diff>
|
<apply_diff>
|
||||||
@@ -233,7 +233,7 @@ Your diff here
|
|||||||
originalContent: string,
|
originalContent: string,
|
||||||
diffContent: string,
|
diffContent: string,
|
||||||
startLine?: number,
|
startLine?: number,
|
||||||
endLine?: number,
|
endLine?: number
|
||||||
): Promise<DiffResult> {
|
): Promise<DiffResult> {
|
||||||
const parsedDiff = this.parseUnifiedDiff(diffContent)
|
const parsedDiff = this.parseUnifiedDiff(diffContent)
|
||||||
const originalLines = originalContent.split("\n")
|
const originalLines = originalContent.split("\n")
|
||||||
@@ -271,7 +271,7 @@ Your diff here
|
|||||||
subHunkResult,
|
subHunkResult,
|
||||||
subSearchResult.index,
|
subSearchResult.index,
|
||||||
subSearchResult.confidence,
|
subSearchResult.confidence,
|
||||||
this.confidenceThreshold,
|
this.confidenceThreshold
|
||||||
)
|
)
|
||||||
if (subEditResult.confidence >= this.confidenceThreshold) {
|
if (subEditResult.confidence >= this.confidenceThreshold) {
|
||||||
subHunkResult = subEditResult.result
|
subHunkResult = subEditResult.result
|
||||||
@@ -293,12 +293,12 @@ Your diff here
|
|||||||
const contextRatio = contextLines / totalLines
|
const contextRatio = contextLines / totalLines
|
||||||
|
|
||||||
let errorMsg = `Failed to find a matching location in the file (${Math.floor(
|
let errorMsg = `Failed to find a matching location in the file (${Math.floor(
|
||||||
confidence * 100,
|
confidence * 100
|
||||||
)}% confidence, needs ${Math.floor(this.confidenceThreshold * 100)}%)\n\n`
|
)}% confidence, needs ${Math.floor(this.confidenceThreshold * 100)}%)\n\n`
|
||||||
errorMsg += "Debug Info:\n"
|
errorMsg += "Debug Info:\n"
|
||||||
errorMsg += `- Search Strategy Used: ${strategy}\n`
|
errorMsg += `- Search Strategy Used: ${strategy}\n`
|
||||||
errorMsg += `- Context Lines: ${contextLines} out of ${totalLines} total lines (${Math.floor(
|
errorMsg += `- Context Lines: ${contextLines} out of ${totalLines} total lines (${Math.floor(
|
||||||
contextRatio * 100,
|
contextRatio * 100
|
||||||
)}%)\n`
|
)}%)\n`
|
||||||
errorMsg += `- Attempted to split into ${subHunks.length} sub-hunks but still failed\n`
|
errorMsg += `- Attempted to split into ${subHunks.length} sub-hunks but still failed\n`
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ Your diff here
|
|||||||
} else {
|
} else {
|
||||||
// Edit failure - likely due to content mismatch
|
// Edit failure - likely due to content mismatch
|
||||||
let errorMsg = `Failed to apply the edit using ${editResult.strategy} strategy (${Math.floor(
|
let errorMsg = `Failed to apply the edit using ${editResult.strategy} strategy (${Math.floor(
|
||||||
editResult.confidence * 100,
|
editResult.confidence * 100
|
||||||
)}% confidence)\n\n`
|
)}% confidence)\n\n`
|
||||||
errorMsg += "Debug Info:\n"
|
errorMsg += "Debug Info:\n"
|
||||||
errorMsg += "- The location was found but the content didn't match exactly\n"
|
errorMsg += "- The location was found but the content didn't match exactly\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user