codegraphcontext-rust 0.5.5__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. codegraphcontext/__init__.py +2 -0
  2. codegraphcontext/__main__.py +5 -0
  3. codegraphcontext/_cgc_rust.cp310-win_amd64.pyd +0 -0
  4. codegraphcontext/cli/__init__.py +1 -0
  5. codegraphcontext/cli/cli_helpers.py +774 -0
  6. codegraphcontext/cli/config_manager.py +1051 -0
  7. codegraphcontext/cli/main.py +2386 -0
  8. codegraphcontext/cli/registry_commands.py +404 -0
  9. codegraphcontext/cli/setup_macos.py +93 -0
  10. codegraphcontext/cli/setup_wizard.py +991 -0
  11. codegraphcontext/cli/visualizer.py +50 -0
  12. codegraphcontext/core/__init__.py +165 -0
  13. codegraphcontext/core/bundle_registry.py +181 -0
  14. codegraphcontext/core/cgc_bundle.py +858 -0
  15. codegraphcontext/core/cgcignore.py +118 -0
  16. codegraphcontext/core/database.py +273 -0
  17. codegraphcontext/core/database_falkordb.py +480 -0
  18. codegraphcontext/core/database_falkordb_remote.py +199 -0
  19. codegraphcontext/core/database_kuzu.py +636 -0
  20. codegraphcontext/core/falkor_worker.py +132 -0
  21. codegraphcontext/core/jobs.py +132 -0
  22. codegraphcontext/core/watcher.py +260 -0
  23. codegraphcontext/prompts.py +125 -0
  24. codegraphcontext/server.py +471 -0
  25. codegraphcontext/tool_definitions.py +220 -0
  26. codegraphcontext/tools/__init__.py +0 -0
  27. codegraphcontext/tools/advanced_language_query_tool.py +103 -0
  28. codegraphcontext/tools/code_finder.py +1160 -0
  29. codegraphcontext/tools/graph_builder.py +337 -0
  30. codegraphcontext/tools/handlers/analysis_handlers.py +114 -0
  31. codegraphcontext/tools/handlers/indexing_handlers.py +116 -0
  32. codegraphcontext/tools/handlers/management_handlers.py +339 -0
  33. codegraphcontext/tools/handlers/query_handlers.py +83 -0
  34. codegraphcontext/tools/handlers/watcher_handlers.py +83 -0
  35. codegraphcontext/tools/indexing/__init__.py +1 -0
  36. codegraphcontext/tools/indexing/constants.py +25 -0
  37. codegraphcontext/tools/indexing/discovery.py +64 -0
  38. codegraphcontext/tools/indexing/engine.py +109 -0
  39. codegraphcontext/tools/indexing/persistence/__init__.py +3 -0
  40. codegraphcontext/tools/indexing/persistence/parquet_loader.py +643 -0
  41. codegraphcontext/tools/indexing/persistence/writer.py +1114 -0
  42. codegraphcontext/tools/indexing/pipeline.py +171 -0
  43. codegraphcontext/tools/indexing/pre_scan.py +105 -0
  44. codegraphcontext/tools/indexing/resolution/__init__.py +8 -0
  45. codegraphcontext/tools/indexing/resolution/calls.py +253 -0
  46. codegraphcontext/tools/indexing/resolution/inheritance.py +91 -0
  47. codegraphcontext/tools/indexing/sanitize.py +41 -0
  48. codegraphcontext/tools/indexing/schema.py +79 -0
  49. codegraphcontext/tools/indexing/schema_contract.py +44 -0
  50. codegraphcontext/tools/indexing/scip_pipeline.py +140 -0
  51. codegraphcontext/tools/languages/c.py +563 -0
  52. codegraphcontext/tools/languages/cpp.py +616 -0
  53. codegraphcontext/tools/languages/csharp.py +551 -0
  54. codegraphcontext/tools/languages/dart.py +378 -0
  55. codegraphcontext/tools/languages/elixir.py +460 -0
  56. codegraphcontext/tools/languages/go.py +499 -0
  57. codegraphcontext/tools/languages/haskell.py +426 -0
  58. codegraphcontext/tools/languages/java.py +500 -0
  59. codegraphcontext/tools/languages/javascript.py +589 -0
  60. codegraphcontext/tools/languages/kotlin.py +640 -0
  61. codegraphcontext/tools/languages/perl.py +260 -0
  62. codegraphcontext/tools/languages/php.py +519 -0
  63. codegraphcontext/tools/languages/python.py +576 -0
  64. codegraphcontext/tools/languages/ruby.py +537 -0
  65. codegraphcontext/tools/languages/rust.py +295 -0
  66. codegraphcontext/tools/languages/scala.py +519 -0
  67. codegraphcontext/tools/languages/swift.py +491 -0
  68. codegraphcontext/tools/languages/typescript.py +575 -0
  69. codegraphcontext/tools/languages/typescriptjsx.py +151 -0
  70. codegraphcontext/tools/package_resolver.py +472 -0
  71. codegraphcontext/tools/query_tool_languages/c_toolkit.py +5 -0
  72. codegraphcontext/tools/query_tool_languages/cpp_toolkit.py +87 -0
  73. codegraphcontext/tools/query_tool_languages/csharp_toolkit.py +5 -0
  74. codegraphcontext/tools/query_tool_languages/dart_toolkit.py +5 -0
  75. codegraphcontext/tools/query_tool_languages/go_toolkit.py +5 -0
  76. codegraphcontext/tools/query_tool_languages/haskell_toolkit.py +5 -0
  77. codegraphcontext/tools/query_tool_languages/java_toolkit.py +5 -0
  78. codegraphcontext/tools/query_tool_languages/javascript_toolkit.py +5 -0
  79. codegraphcontext/tools/query_tool_languages/perl_toolkit.py +5 -0
  80. codegraphcontext/tools/query_tool_languages/python_toolkit.py +5 -0
  81. codegraphcontext/tools/query_tool_languages/ruby_toolkit.py +5 -0
  82. codegraphcontext/tools/query_tool_languages/rust_toolkit.py +5 -0
  83. codegraphcontext/tools/query_tool_languages/scala_toolkit.py +5 -0
  84. codegraphcontext/tools/query_tool_languages/swift_toolkit.py +5 -0
  85. codegraphcontext/tools/query_tool_languages/typescript_toolkit.py +5 -0
  86. codegraphcontext/tools/scip_indexer.py +467 -0
  87. codegraphcontext/tools/scip_pb2.py +2455 -0
  88. codegraphcontext/tools/system.py +133 -0
  89. codegraphcontext/tools/tree_sitter_parser.py +103 -0
  90. codegraphcontext/utils/debug_log.py +90 -0
  91. codegraphcontext/utils/path_ignore.py +55 -0
  92. codegraphcontext/utils/repo_path.py +27 -0
  93. codegraphcontext/utils/tree_sitter_manager.py +285 -0
  94. codegraphcontext/utils/visualize_graph.py +0 -0
  95. codegraphcontext/viz/server.py +282 -0
  96. codegraphcontext_rust-0.5.5.dist-info/METADATA +537 -0
  97. codegraphcontext_rust-0.5.5.dist-info/RECORD +101 -0
  98. codegraphcontext_rust-0.5.5.dist-info/WHEEL +4 -0
  99. codegraphcontext_rust-0.5.5.dist-info/entry_points.txt +3 -0
  100. codegraphcontext_rust-0.5.5.dist-info/licenses/LICENSE +21 -0
  101. codegraphcontext_rust-0.5.5.dist-info/sboms/cgc-python.cyclonedx.json +2333 -0
@@ -0,0 +1,220 @@
1
+
2
+ TOOLS = {
3
+ "add_code_to_graph": {
4
+ "name": "add_code_to_graph",
5
+ "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.",
6
+ "inputSchema": {
7
+ "type": "object",
8
+ "properties": {
9
+ "path": {"type": "string", "description": "Path to the directory or file to add."},
10
+ "is_dependency": {"type": "boolean", "description": "Whether this code is a dependency.", "default": False}
11
+ },
12
+ "required": ["path"]
13
+ }
14
+ },
15
+ "check_job_status": {
16
+ "name": "check_job_status",
17
+ "description": "Check the status and progress of a background job.",
18
+ "inputSchema": {
19
+ "type": "object",
20
+ "properties": { "job_id": {"type": "string", "description": "Job ID from a previous tool call"} },
21
+ "required": ["job_id"]
22
+ }
23
+ },
24
+ "list_jobs": {
25
+ "name": "list_jobs",
26
+ "description": "List all background jobs and their current status.",
27
+ "inputSchema": {"type": "object", "properties": {}}
28
+ },
29
+ "find_code": {
30
+ "name": "find_code",
31
+ "description": "Find relevant code snippets related to a keyword (e.g., function name, class name, or content).",
32
+ "inputSchema": {
33
+ "type": "object",
34
+ "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}, "repo_path": {"type": "string", "description": "Optional: Path to the repository to restrict the search to."}},
35
+ "required": ["query"]
36
+ }
37
+ },
38
+ "analyze_code_relationships": {
39
+ "name": "analyze_code_relationships",
40
+ "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.",
41
+ "inputSchema": {
42
+ "type": "object",
43
+ "properties": {
44
+ "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"]},
45
+ "target": {"type": "string", "description": "The function, class, or module to analyze."},
46
+ "context": {"type": "string", "description": "Optional: specific file path for precise results."},
47
+ "repo_path": {"type": "string", "description": "Optional: Path to the repository to restrict the search to."}
48
+ },
49
+ "required": ["query_type", "target"]
50
+ }
51
+ },
52
+ "watch_directory": {
53
+ "name": "watch_directory",
54
+ "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.",
55
+ "inputSchema": {
56
+ "type": "object",
57
+ "properties": { "path": {"type": "string", "description": "Path to directory to watch"} },
58
+ "required": ["path"]
59
+ }
60
+ },
61
+ "execute_cypher_query": {
62
+ "name": "execute_cypher_query",
63
+ "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).",
64
+ "inputSchema": {
65
+ "type": "object",
66
+ "properties": { "cypher_query": {"type": "string", "description": "The read-only Cypher query to execute."} },
67
+ "required": ["cypher_query"]
68
+ }
69
+ },
70
+ "add_package_to_graph": {
71
+ "name": "add_package_to_graph",
72
+ "description": "Add a package to the graph by discovering its location. Supports multiple languages. Returns immediately with a job ID.",
73
+ "inputSchema": {
74
+ "type": "object",
75
+ "properties": {
76
+ "package_name": {"type": "string", "description": "Name of the package to add (e.g., 'requests', 'express', 'moment', 'lodash')."},
77
+ "language": {"type": "string", "description": "The programming language of the package.", "enum": ["python", "javascript", "typescript", "java", "c", "go", "ruby", "php","cpp"]},
78
+ "is_dependency": {"type": "boolean", "description": "Mark as a dependency.", "default": True}
79
+ },
80
+ "required": ["package_name", "language"]
81
+ }
82
+ },
83
+ "find_dead_code": {
84
+ "name": "find_dead_code",
85
+ "description": "Find potentially unused functions (dead code) across the entire indexed codebase, optionally excluding functions with specific decorators.",
86
+ "inputSchema": {
87
+ "type": "object",
88
+ "properties": {
89
+ "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": []},
90
+ "repo_path": {"type": "string", "description": "Optional: Path to the repository to restrict the search to."}
91
+ }
92
+ }
93
+ },
94
+ "calculate_cyclomatic_complexity": {
95
+ "name": "calculate_cyclomatic_complexity",
96
+ "description": "Calculate the cyclomatic complexity of a specific function to measure its complexity.",
97
+ "inputSchema": {
98
+ "type": "object",
99
+ "properties": {
100
+ "function_name": {"type": "string", "description": "The name of the function to analyze."},
101
+ "path": {"type": "string", "description": "Optional: The full path to the file containing the function for a more specific query."},
102
+ "repo_path": {"type": "string", "description": "Optional: Path to the repository to restrict the search to."}
103
+ },
104
+ "required": ["function_name"]
105
+ }
106
+ },
107
+ "find_most_complex_functions": {
108
+ "name": "find_most_complex_functions",
109
+ "description": "Find the most complex functions in the codebase based on cyclomatic complexity.",
110
+ "inputSchema": {
111
+ "type": "object",
112
+ "properties": {
113
+ "limit": {"type": "integer", "description": "The maximum number of complex functions to return.", "default": 10},
114
+ "repo_path": {"type": "string", "description": "Optional: Path to the repository to restrict the search to."}
115
+ }
116
+ }
117
+ },
118
+ "list_indexed_repositories": {
119
+ "name": "list_indexed_repositories",
120
+ "description": "List all indexed repositories.",
121
+ "inputSchema": {
122
+ "type": "object",
123
+ "properties": {}
124
+ }
125
+ },
126
+ "delete_repository": {
127
+ "name": "delete_repository",
128
+ "description": "Delete an indexed repository from the graph.",
129
+ "inputSchema": {
130
+ "type": "object",
131
+ "properties": {
132
+ "repo_path": {"type": "string", "description": "The path of the repository to delete."}
133
+ },
134
+ "required": ["repo_path"]
135
+ }
136
+ },
137
+ "visualize_graph_query": {
138
+ "name": "visualize_graph_query",
139
+ "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.",
140
+ "inputSchema": {
141
+ "type": "object",
142
+ "properties": {
143
+ "cypher_query": {"type": "string", "description": "The Cypher query to visualize."}
144
+ },
145
+ "required": ["cypher_query"]
146
+ }
147
+ },
148
+ "list_watched_paths": {
149
+ "name": "list_watched_paths",
150
+ "description": "Lists all directories currently being watched for live file changes.",
151
+ "inputSchema": {"type": "object", "properties": {}}
152
+ },
153
+ "unwatch_directory": {
154
+ "name": "unwatch_directory",
155
+ "description": "Stops watching a directory for live file changes.",
156
+ "inputSchema": {
157
+ "type": "object",
158
+ "properties": {
159
+ "path": {"type": "string", "description": "The absolute path of the directory to stop watching."}
160
+ },
161
+ "required": ["path"]
162
+ }
163
+ },
164
+ "load_bundle": {
165
+ "name": "load_bundle",
166
+ "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.",
167
+ "inputSchema": {
168
+ "type": "object",
169
+ "properties": {
170
+ "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."},
171
+ "clear_existing": {"type": "boolean", "description": "Whether to clear existing data before loading. Use with caution.", "default": False}
172
+ },
173
+ "required": ["bundle_name"]
174
+ }
175
+ },
176
+ "search_registry_bundles": {
177
+ "name": "search_registry_bundles",
178
+ "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.",
179
+ "inputSchema": {
180
+ "type": "object",
181
+ "properties": {
182
+ "query": {"type": "string", "description": "Search query to find bundles (searches in name, repository, and description). Leave empty to list all bundles."},
183
+ "unique_only": {"type": "boolean", "description": "If true, show only the most recent version of each package. If false, show all versions.", "default": False}
184
+ }
185
+ }
186
+ },
187
+ "get_repository_stats": {
188
+ "name": "get_repository_stats",
189
+ "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.",
190
+ "inputSchema": {
191
+ "type": "object",
192
+ "properties": {
193
+ "repo_path": {"type": "string", "description": "Optional: Path to a specific repository. If not provided, returns overall database statistics."}
194
+ }
195
+ }
196
+ },
197
+ "discover_codegraph_contexts": {
198
+ "name": "discover_codegraph_contexts",
199
+ "description": "Scan child directories of the current workspace (or a given path) for .codegraphcontext folders that contain indexed code graph databases. Useful when the IDE is opened on a parent folder that itself has no database, but its sub-projects do.",
200
+ "inputSchema": {
201
+ "type": "object",
202
+ "properties": {
203
+ "path": {"type": "string", "description": "Optional: Root directory to scan. Defaults to the server's current working directory."},
204
+ "max_depth": {"type": "integer", "description": "How many levels of child directories to scan. Defaults to 1 (immediate children only).", "default": 1}
205
+ }
206
+ }
207
+ },
208
+ "switch_context": {
209
+ "name": "switch_context",
210
+ "description": "Switch the current MCP session to use a different .codegraphcontext database. Provide the path to the repo directory (or its .codegraphcontext/ folder). The server will reconnect to that database so subsequent queries use it. By default the mapping is saved globally for persistence across restarts.",
211
+ "inputSchema": {
212
+ "type": "object",
213
+ "properties": {
214
+ "context_path": {"type": "string", "description": "Path to the repository root that contains a .codegraphcontext/ folder, or directly to the .codegraphcontext/ folder itself."},
215
+ "save": {"type": "boolean", "description": "Whether to persist this mapping so the server reconnects automatically next time. Defaults to true.", "default": True}
216
+ },
217
+ "required": ["context_path"]
218
+ }
219
+ }
220
+ }
File without changes
@@ -0,0 +1,103 @@
1
+ import re
2
+ import logging
3
+ #importing all the language toolkits
4
+ from ..tools.query_tool_languages.c_toolkit import CToolkit
5
+ from ..tools.query_tool_languages.cpp_toolkit import CppToolkit
6
+ from ..tools.query_tool_languages.go_toolkit import GoToolkit
7
+ from ..tools.query_tool_languages.java_toolkit import JavaToolkit
8
+ from ..tools.query_tool_languages.javascript_toolkit import JavascriptToolkit
9
+ from ..tools.query_tool_languages.python_toolkit import PythonToolkit
10
+ from ..tools.query_tool_languages.ruby_toolkit import RubyToolkit
11
+ from ..tools.query_tool_languages.rust_toolkit import RustToolkit
12
+ from ..tools.query_tool_languages.typescript_toolkit import TypescriptToolkit
13
+ from ..tools.query_tool_languages.csharp_toolkit import CSharpToolkit
14
+ from ..tools.query_tool_languages.dart_toolkit import DartToolkit
15
+ from ..tools.query_tool_languages.perl_toolkit import PerlToolkit
16
+
17
+ from ..core.database import DatabaseManager
18
+ from ..utils.debug_log import debug_log
19
+
20
+ logger = logging.getLogger(__name__)
21
+
22
+ class Advanced_language_query:
23
+ """
24
+ Tool implementation for executing a read-only language specific Cypher query.
25
+
26
+ Important: Includes a safety check to prevent any database modification
27
+ by disallowing keywords like CREATE, MERGE, DELETE, etc.
28
+ """
29
+
30
+ TOOLKITS = {
31
+ "c": CToolkit,
32
+ "cpp": CppToolkit,
33
+ "go": GoToolkit,
34
+ "java": JavaToolkit,
35
+ "javascript": JavascriptToolkit,
36
+ "python": PythonToolkit,
37
+ "ruby": RubyToolkit,
38
+ "rust": RustToolkit,
39
+ "typescript": TypescriptToolkit,
40
+ "c_sharp": CSharpToolkit,
41
+ "dart": DartToolkit,
42
+ "perl": PerlToolkit
43
+ }
44
+ Supported_queries = {
45
+ "repository": "Repository",
46
+ "directory": "Directory",
47
+ "file": "File",
48
+ "module": "Module",
49
+ "function": "Function",
50
+ "class": "Class",
51
+ "struct": "Struct",
52
+ "enum": "Enum",
53
+ "union": "Union",
54
+ "macro": "Macro",
55
+ "variable": "Variable"
56
+ }
57
+
58
+
59
+ def __init__(self, db_manager: DatabaseManager):
60
+ self.db_manager = db_manager
61
+
62
+ def advanced_language_query(self, language: str, query: str):
63
+ # Validating whether query is valid or not
64
+ query = query.strip().lower()
65
+ if query not in self.Supported_queries:
66
+ raise ValueError(
67
+ f"Unsupported query type '{query}'"
68
+ f"Supported: {', '.join(self.Supported_queries.keys())}"
69
+ )
70
+ label = self.Supported_queries[query]
71
+
72
+ # Set toolkit for the specified language
73
+ language = language.lower()
74
+
75
+ if language not in self.TOOLKITS:
76
+ raise ValueError(f"Unsupported language: {language}")
77
+ self.toolkit = self.TOOLKITS[language]()
78
+
79
+ # Getting the language query
80
+ cypher_query = self.toolkit.get_cypher_query(label)
81
+ try:
82
+ debug_log(f"Executing Cypher query: {cypher_query}")
83
+ with self.db_manager.get_driver().session() as session:
84
+ result = session.run(cypher_query)
85
+ # Convert results to a list of dictionaries for clean JSON serialization
86
+ records = [record.data() for record in result]
87
+
88
+ return {
89
+ "success": True,
90
+ "language": language,
91
+ "query": cypher_query,
92
+ "results": records
93
+ }
94
+ except Exception as e:
95
+ debug_log(f"Error executing Cypher query: {str(e)}")
96
+ return {
97
+ "error": "An unexpected error occurred while executing the query.",
98
+ "details": str(e)
99
+ }
100
+
101
+
102
+
103
+