forked from CodeGraphContext/CodeGraphContext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_definitions.py
More file actions
193 lines (192 loc) · 10.6 KB
/
tool_definitions.py
File metadata and controls
193 lines (192 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
TOOLS = {
"add_code_to_graph": {
"name": "add_code_to_graph",
"description": "Performs a one-time scan of a local folder to add its code to the graph. Ideal for indexing libraries, dependencies, or projects not being actively modified. Returns a job ID for background processing.",
"inputSchema": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "Path to the directory or file to add."},
"is_dependency": {"type": "boolean", "description": "Whether this code is a dependency.", "default": False}
},
"required": ["path"]
}
},
"check_job_status": {
"name": "check_job_status",
"description": "Check the status and progress of a background job.",
"inputSchema": {
"type": "object",
"properties": { "job_id": {"type": "string", "description": "Job ID from a previous tool call"} },
"required": ["job_id"]
}
},
"list_jobs": {
"name": "list_jobs",
"description": "List all background jobs and their current status.",
"inputSchema": {"type": "object", "properties": {}}
},
"find_code": {
"name": "find_code",
"description": "Find relevant code snippets related to a keyword (e.g., function name, class name, or content).",
"inputSchema": {
"type": "object",
"properties": { "query": {"type": "string", "description": "Keyword or phrase to search for"}, "fuzzy_search": {"type": "boolean", "description": "Whether to use fuzzy search", "default": False}, "edit_distance": {"type": "number", "description": "Edit distance for fuzzy search (between 0-2)", "default": 2}},
"required": ["query"]
}
},
"analyze_code_relationships": {
"name": "analyze_code_relationships",
"description": "Analyze code relationships like 'who calls this function' or 'class hierarchy'. Supported query types include: find_callers, find_callees, find_all_callers, find_all_callees, find_importers, who_modifies, class_hierarchy, overrides, dead_code, call_chain, module_deps, variable_scope, find_complexity, find_functions_by_argument, find_functions_by_decorator.",
"inputSchema": {
"type": "object",
"properties": {
"query_type": {"type": "string", "description": "Type of relationship query to run.", "enum": ["find_callers", "find_callees", "find_all_callers", "find_all_callees", "find_importers", "who_modifies", "class_hierarchy", "overrides", "dead_code", "call_chain", "module_deps", "variable_scope", "find_complexity", "find_functions_by_argument", "find_functions_by_decorator"]},
"target": {"type": "string", "description": "The function, class, or module to analyze."},
"context": {"type": "string", "description": "Optional: specific file path for precise results."}
},
"required": ["query_type", "target"]
}
},
"watch_directory": {
"name": "watch_directory",
"description": "Performs an initial scan of a directory and then continuously monitors it for changes, automatically keeping the graph up-to-date. Ideal for projects under active development. Returns a job ID for the initial scan.",
"inputSchema": {
"type": "object",
"properties": { "path": {"type": "string", "description": "Path to directory to watch"} },
"required": ["path"]
}
},
"execute_cypher_query": {
"name": "execute_cypher_query",
"description": "Fallback tool to run a direct, read-only Cypher query against the code graph. Use this for complex questions not covered by other tools. The graph contains nodes representing code structures and relationships between them. **Schema Overview:**\n- **Nodes:** `Repository`, `File`, `Module`, `Class`, `Function`.\n- **Properties:** Nodes have properties like `name`, `path`, `cyclomatic_complexity` (on Function nodes), and `source`.\n- **Relationships:** `CONTAINS` (e.g., File-[:CONTAINS]->Function), `CALLS` (Function-[:CALLS]->Function or File-[:CALLS]->Function), `IMPORTS` (File-[:IMPORTS]->Module), `INHERITS` (Class-[:INHERITS]->Class).",
"inputSchema": {
"type": "object",
"properties": { "cypher_query": {"type": "string", "description": "The read-only Cypher query to execute."} },
"required": ["cypher_query"]
}
},
"add_package_to_graph": {
"name": "add_package_to_graph",
"description": "Add a package to the graph by discovering its location. Supports multiple languages. Returns immediately with a job ID.",
"inputSchema": {
"type": "object",
"properties": {
"package_name": {"type": "string", "description": "Name of the package to add (e.g., 'requests', 'express', 'moment', 'lodash')."},
"language": {"type": "string", "description": "The programming language of the package.", "enum": ["python", "javascript", "typescript", "java", "c", "go", "ruby", "php","cpp"]},
"is_dependency": {"type": "boolean", "description": "Mark as a dependency.", "default": True}
},
"required": ["package_name", "language"]
}
},
"find_dead_code": {
"name": "find_dead_code",
"description": "Find potentially unused functions (dead code) across the entire indexed codebase, optionally excluding functions with specific decorators.",
"inputSchema": {
"type": "object",
"properties": {
"exclude_decorated_with": {"type": "array", "items": {"type": "string"}, "description": "Optional: A list of decorator names (e.g., '@app.route') to exclude from dead code detection.", "default": []}
}
}
},
"calculate_cyclomatic_complexity": {
"name": "calculate_cyclomatic_complexity",
"description": "Calculate the cyclomatic complexity of a specific function to measure its complexity.",
"inputSchema": {
"type": "object",
"properties": {
"function_name": {"type": "string", "description": "The name of the function to analyze."},
"path": {"type": "string", "description": "Optional: The full path to the file containing the function for a more specific query."}
},
"required": ["function_name"]
}
},
"find_most_complex_functions": {
"name": "find_most_complex_functions",
"description": "Find the most complex functions in the codebase based on cyclomatic complexity.",
"inputSchema": {
"type": "object",
"properties": {
"limit": {"type": "integer", "description": "The maximum number of complex functions to return.", "default": 10}
}
}
},
"list_indexed_repositories": {
"name": "list_indexed_repositories",
"description": "List all indexed repositories.",
"inputSchema": {
"type": "object",
"properties": {}
}
},
"delete_repository": {
"name": "delete_repository",
"description": "Delete an indexed repository from the graph.",
"inputSchema": {
"type": "object",
"properties": {
"repo_path": {"type": "string", "description": "The path of the repository to delete."}
},
"required": ["repo_path"]
}
},
"visualize_graph_query": {
"name": "visualize_graph_query",
"description": "Generates a URL to visualize the results of a Cypher query in the Neo4j Browser. The user can open this URL in their web browser to see the graph visualization.",
"inputSchema": {
"type": "object",
"properties": {
"cypher_query": {"type": "string", "description": "The Cypher query to visualize."}
},
"required": ["cypher_query"]
}
},
"list_watched_paths": {
"name": "list_watched_paths",
"description": "Lists all directories currently being watched for live file changes.",
"inputSchema": {"type": "object", "properties": {}}
},
"unwatch_directory": {
"name": "unwatch_directory",
"description": "Stops watching a directory for live file changes.",
"inputSchema": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "The absolute path of the directory to stop watching."}
},
"required": ["path"]
}
},
"load_bundle": {
"name": "load_bundle",
"description": "Load a pre-indexed .cgc bundle into the database. Can load from local file or automatically download from registry if not found locally. Bundles are portable snapshots of indexed code that load instantly without re-indexing.",
"inputSchema": {
"type": "object",
"properties": {
"bundle_name": {"type": "string", "description": "Name of the bundle to load (e.g., 'flask', 'pandas', 'flask-main-2579ce9.cgc'). Can be a full filename or just the package name."},
"clear_existing": {"type": "boolean", "description": "Whether to clear existing data before loading. Use with caution.", "default": False}
},
"required": ["bundle_name"]
}
},
"search_registry_bundles": {
"name": "search_registry_bundles",
"description": "Search for available pre-indexed bundles in the registry. Returns bundles matching the search query with details like repository, version, size, and download information.",
"inputSchema": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query to find bundles (searches in name, repository, and description). Leave empty to list all bundles."},
"unique_only": {"type": "boolean", "description": "If true, show only the most recent version of each package. If false, show all versions.", "default": False}
}
}
},
"get_repository_stats": {
"name": "get_repository_stats",
"description": "Get statistics about indexed repositories, including counts of files, functions, classes, and modules. Can show overall database statistics or stats for a specific repository.",
"inputSchema": {
"type": "object",
"properties": {
"repo_path": {"type": "string", "description": "Optional: Path to a specific repository. If not provided, returns overall database statistics."}
}
}
}
}