@@ -89,6 +89,7 @@ import { writeToFileTool } from "./tools/writeToFileTool"
8989import { applyDiffTool } from "./tools/applyDiffTool"
9090import { insertContentTool } from "./tools/insertContentTool"
9191import { searchAndReplaceTool } from "./tools/searchAndReplaceTool"
92+ import { listCodeDefinitionNamesTool } from "./tools/listCodeDefinitionNamesTool"
9293
9394export type ToolResponse = string | Array < Anthropic . TextBlockParam | Anthropic . ImageBlockParam >
9495type UserContent = Array < Anthropic . Messages . ContentBlockParam >
@@ -1596,66 +1597,16 @@ export class Cline extends EventEmitter<ClineEvents> {
15961597 case "list_files" :
15971598 await listFilesTool ( this , block , askApproval , handleError , pushToolResult , removeClosingTag )
15981599 break
1599- case "list_code_definition_names" : {
1600- const relPath : string | undefined = block . params . path
1601- const sharedMessageProps : ClineSayTool = {
1602- tool : "listCodeDefinitionNames" ,
1603- path : getReadablePath ( this . cwd , removeClosingTag ( "path" , relPath ) ) ,
1604- }
1605- try {
1606- if ( block . partial ) {
1607- const partialMessage = JSON . stringify ( {
1608- ...sharedMessageProps ,
1609- content : "" ,
1610- } satisfies ClineSayTool )
1611- await this . ask ( "tool" , partialMessage , block . partial ) . catch ( ( ) => { } )
1612- break
1613- } else {
1614- if ( ! relPath ) {
1615- this . consecutiveMistakeCount ++
1616- pushToolResult (
1617- await this . sayAndCreateMissingParamError ( "list_code_definition_names" , "path" ) ,
1618- )
1619- break
1620- }
1621- this . consecutiveMistakeCount = 0
1622- const absolutePath = path . resolve ( this . cwd , relPath )
1623- let result : string
1624- try {
1625- const stats = await fs . stat ( absolutePath )
1626- if ( stats . isFile ( ) ) {
1627- const fileResult = await parseSourceCodeDefinitionsForFile (
1628- absolutePath ,
1629- this . rooIgnoreController ,
1630- )
1631- result = fileResult ?? "No source code definitions found in this file."
1632- } else if ( stats . isDirectory ( ) ) {
1633- result = await parseSourceCodeForDefinitionsTopLevel (
1634- absolutePath ,
1635- this . rooIgnoreController ,
1636- )
1637- } else {
1638- result = "The specified path is neither a file nor a directory."
1639- }
1640- } catch {
1641- result = `${ absolutePath } : does not exist or cannot be accessed.`
1642- }
1643- const completeMessage = JSON . stringify ( {
1644- ...sharedMessageProps ,
1645- content : result ,
1646- } satisfies ClineSayTool )
1647- const didApprove = await askApproval ( "tool" , completeMessage )
1648- if ( ! didApprove ) {
1649- break
1650- }
1651- pushToolResult ( result )
1652- break
1653- }
1654- } catch ( error ) {
1655- await handleError ( "parsing source code definitions" , error )
1656- break
1657- }
1658- }
1600+ case "list_code_definition_names" :
1601+ await listCodeDefinitionNamesTool (
1602+ this ,
1603+ block ,
1604+ askApproval ,
1605+ handleError ,
1606+ pushToolResult ,
1607+ removeClosingTag ,
1608+ )
1609+ break
16591610 case "search_files" : {
16601611 const relDirPath : string | undefined = block . params . path
16611612 const regex : string | undefined = block . params . regex
0 commit comments