| 131 | } |
| 132 | |
| 133 | function listAvailableSymbols(rootNode: any, nodeTypes: string[]): string[] { |
| 134 | const names: string[] = []; |
| 135 | function visit(node: any) { |
| 136 | if (nodeTypes.includes(node.type)) { |
| 137 | const nameNode = node.childForFieldName('name'); |
| 138 | if (nameNode) names.push(nameNode.text); |
| 139 | else { |
| 140 | for (let i = 0; i < node.childCount; i++) { |
| 141 | const c = node.child(i); |
| 142 | if (c && (c.type === 'identifier' || c.type === 'property_identifier' || c.type === 'type_identifier')) { |
| 143 | names.push(c.text); |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | for (let i = 0; i < node.childCount; i++) { |
| 150 | const c = node.child(i); |
| 151 | if (c) visit(c); |
| 152 | } |
| 153 | } |
| 154 | visit(rootNode); |
| 155 | return [...new Set(names)]; |
| 156 | } |
| 157 | |
| 158 | export class EditSymbolTool extends Tool<z.infer<typeof ArgsSchema>> { |
| 159 | name = 'edit_symbol'; |