Skip to content

Commit 54fb38f

Browse files
committed
fix: correct the type of arguments for the getToolDescription
1 parent 7bb1f3e commit 54fb38f

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/core/diff/strategies/__tests__/new-unified.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ describe("main", () => {
2424
})
2525
})
2626

27-
describe('getToolDescription', () => {
28-
it('should return tool description with correct cwd', () => {
29-
const cwd = '/test/path'
30-
const description = strategy.getToolDescription(cwd)
31-
32-
expect(description).toContain('apply_diff Tool - Generate Precise Code Changes')
33-
expect(description).toContain(cwd)
34-
expect(description).toContain('Step-by-Step Instructions')
35-
expect(description).toContain('Requirements')
36-
expect(description).toContain('Examples')
37-
expect(description).toContain('Parameters:')
38-
})
39-
})
27+
describe("getToolDescription", () => {
28+
it("should return tool description with correct cwd", () => {
29+
const cwd = "/test/path"
30+
const description = strategy.getToolDescription({ cwd })
31+
32+
expect(description).toContain("apply_diff Tool - Generate Precise Code Changes")
33+
expect(description).toContain(cwd)
34+
expect(description).toContain("Step-by-Step Instructions")
35+
expect(description).toContain("Requirements")
36+
expect(description).toContain("Examples")
37+
expect(description).toContain("Parameters:")
38+
})
39+
})
4040

4141
it("should apply simple diff correctly", async () => {
4242
const original = `line1

src/core/diff/strategies/new-unified/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class NewUnifiedDiffStrategy implements DiffStrategy {
107107
return { hunks }
108108
}
109109

110-
getToolDescription(cwd: string): string {
110+
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
111111
return `# apply_diff Tool - Generate Precise Code Changes
112112
113113
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.
164164
\`\`\`
165165
166166
Parameters:
167-
- path: (required) The path of the file to apply the diff to (relative to the current working directory ${args.cwd})
168-
- diff: (required) The diff content in unified format to apply to the file.
167+
- path: (required) File path relative to ${args.cwd}
168+
- diff: (required) Unified diff content in unified format to apply to the file.
169169
170170
Usage:
171171
<apply_diff>
@@ -233,7 +233,7 @@ Your diff here
233233
originalContent: string,
234234
diffContent: string,
235235
startLine?: number,
236-
endLine?: number,
236+
endLine?: number
237237
): Promise<DiffResult> {
238238
const parsedDiff = this.parseUnifiedDiff(diffContent)
239239
const originalLines = originalContent.split("\n")
@@ -271,7 +271,7 @@ Your diff here
271271
subHunkResult,
272272
subSearchResult.index,
273273
subSearchResult.confidence,
274-
this.confidenceThreshold,
274+
this.confidenceThreshold
275275
)
276276
if (subEditResult.confidence >= this.confidenceThreshold) {
277277
subHunkResult = subEditResult.result
@@ -293,12 +293,12 @@ Your diff here
293293
const contextRatio = contextLines / totalLines
294294

295295
let errorMsg = `Failed to find a matching location in the file (${Math.floor(
296-
confidence * 100,
296+
confidence * 100
297297
)}% confidence, needs ${Math.floor(this.confidenceThreshold * 100)}%)\n\n`
298298
errorMsg += "Debug Info:\n"
299299
errorMsg += `- Search Strategy Used: ${strategy}\n`
300300
errorMsg += `- Context Lines: ${contextLines} out of ${totalLines} total lines (${Math.floor(
301-
contextRatio * 100,
301+
contextRatio * 100
302302
)}%)\n`
303303
errorMsg += `- Attempted to split into ${subHunks.length} sub-hunks but still failed\n`
304304

@@ -330,7 +330,7 @@ Your diff here
330330
} else {
331331
// Edit failure - likely due to content mismatch
332332
let errorMsg = `Failed to apply the edit using ${editResult.strategy} strategy (${Math.floor(
333-
editResult.confidence * 100,
333+
editResult.confidence * 100
334334
)}% confidence)\n\n`
335335
errorMsg += "Debug Info:\n"
336336
errorMsg += "- The location was found but the content didn't match exactly\n"

0 commit comments

Comments
 (0)