codegraphcontext-rust 0.9.24__cp314-cp314-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 (112) hide show
  1. codegraphcontext/__init__.py +2 -0
  2. codegraphcontext/__main__.py +5 -0
  3. codegraphcontext/_cgc_rust.cp314-win_amd64.pyd +4 -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/entry.py +21 -0
  8. codegraphcontext/cli/main.py +2386 -0
  9. codegraphcontext/cli/registry_commands.py +404 -0
  10. codegraphcontext/cli/setup_macos.py +93 -0
  11. codegraphcontext/cli/setup_wizard.py +991 -0
  12. codegraphcontext/cli/visualizer.py +50 -0
  13. codegraphcontext/core/__init__.py +165 -0
  14. codegraphcontext/core/bundle_registry.py +181 -0
  15. codegraphcontext/core/cgc_bundle.py +858 -0
  16. codegraphcontext/core/cgcignore.py +118 -0
  17. codegraphcontext/core/database.py +273 -0
  18. codegraphcontext/core/database_falkordb.py +480 -0
  19. codegraphcontext/core/database_falkordb_remote.py +199 -0
  20. codegraphcontext/core/database_kuzu.py +636 -0
  21. codegraphcontext/core/falkor_worker.py +132 -0
  22. codegraphcontext/core/jobs.py +132 -0
  23. codegraphcontext/core/watcher.py +260 -0
  24. codegraphcontext/prompts.py +125 -0
  25. codegraphcontext/server.py +471 -0
  26. codegraphcontext/tool_definitions.py +220 -0
  27. codegraphcontext/tools/__init__.py +0 -0
  28. codegraphcontext/tools/advanced_language_query_tool.py +103 -0
  29. codegraphcontext/tools/code_finder.py +1160 -0
  30. codegraphcontext/tools/graph_builder.py +337 -0
  31. codegraphcontext/tools/handlers/analysis_handlers.py +114 -0
  32. codegraphcontext/tools/handlers/indexing_handlers.py +116 -0
  33. codegraphcontext/tools/handlers/management_handlers.py +339 -0
  34. codegraphcontext/tools/handlers/query_handlers.py +83 -0
  35. codegraphcontext/tools/handlers/watcher_handlers.py +83 -0
  36. codegraphcontext/tools/indexing/__init__.py +1 -0
  37. codegraphcontext/tools/indexing/angular_routes.py +396 -0
  38. codegraphcontext/tools/indexing/cgc_wiki_cli.py +1334 -0
  39. codegraphcontext/tools/indexing/constants.py +70 -0
  40. codegraphcontext/tools/indexing/context_generator.py +461 -0
  41. codegraphcontext/tools/indexing/discovery.py +64 -0
  42. codegraphcontext/tools/indexing/engine.py +114 -0
  43. codegraphcontext/tools/indexing/execution_flows.py +355 -0
  44. codegraphcontext/tools/indexing/module_grouping.py +551 -0
  45. codegraphcontext/tools/indexing/noise_filter.py +131 -0
  46. codegraphcontext/tools/indexing/op_param_extraction.py +287 -0
  47. codegraphcontext/tools/indexing/persistence/__init__.py +3 -0
  48. codegraphcontext/tools/indexing/persistence/duckdb_writer.py +1116 -0
  49. codegraphcontext/tools/indexing/persistence/parquet_loader.py +643 -0
  50. codegraphcontext/tools/indexing/persistence/writer.py +1562 -0
  51. codegraphcontext/tools/indexing/pipeline.py +171 -0
  52. codegraphcontext/tools/indexing/pre_scan.py +105 -0
  53. codegraphcontext/tools/indexing/rationale_extraction.py +154 -0
  54. codegraphcontext/tools/indexing/resolution/__init__.py +8 -0
  55. codegraphcontext/tools/indexing/resolution/calls.py +253 -0
  56. codegraphcontext/tools/indexing/resolution/inheritance.py +91 -0
  57. codegraphcontext/tools/indexing/route_extraction.py +659 -0
  58. codegraphcontext/tools/indexing/sanitize.py +41 -0
  59. codegraphcontext/tools/indexing/schema.py +79 -0
  60. codegraphcontext/tools/indexing/schema_contract.py +44 -0
  61. codegraphcontext/tools/indexing/scip_pipeline.py +140 -0
  62. codegraphcontext/tools/languages/c.py +563 -0
  63. codegraphcontext/tools/languages/cpp.py +616 -0
  64. codegraphcontext/tools/languages/csharp.py +551 -0
  65. codegraphcontext/tools/languages/dart.py +378 -0
  66. codegraphcontext/tools/languages/elixir.py +460 -0
  67. codegraphcontext/tools/languages/go.py +499 -0
  68. codegraphcontext/tools/languages/haskell.py +426 -0
  69. codegraphcontext/tools/languages/java.py +500 -0
  70. codegraphcontext/tools/languages/javascript.py +589 -0
  71. codegraphcontext/tools/languages/kotlin.py +640 -0
  72. codegraphcontext/tools/languages/perl.py +260 -0
  73. codegraphcontext/tools/languages/php.py +519 -0
  74. codegraphcontext/tools/languages/python.py +578 -0
  75. codegraphcontext/tools/languages/ruby.py +537 -0
  76. codegraphcontext/tools/languages/rust.py +295 -0
  77. codegraphcontext/tools/languages/scala.py +519 -0
  78. codegraphcontext/tools/languages/swift.py +491 -0
  79. codegraphcontext/tools/languages/typescript.py +606 -0
  80. codegraphcontext/tools/languages/typescriptjsx.py +151 -0
  81. codegraphcontext/tools/package_resolver.py +472 -0
  82. codegraphcontext/tools/query_tool_languages/c_toolkit.py +5 -0
  83. codegraphcontext/tools/query_tool_languages/cpp_toolkit.py +87 -0
  84. codegraphcontext/tools/query_tool_languages/csharp_toolkit.py +5 -0
  85. codegraphcontext/tools/query_tool_languages/dart_toolkit.py +5 -0
  86. codegraphcontext/tools/query_tool_languages/go_toolkit.py +5 -0
  87. codegraphcontext/tools/query_tool_languages/haskell_toolkit.py +5 -0
  88. codegraphcontext/tools/query_tool_languages/java_toolkit.py +5 -0
  89. codegraphcontext/tools/query_tool_languages/javascript_toolkit.py +5 -0
  90. codegraphcontext/tools/query_tool_languages/perl_toolkit.py +5 -0
  91. codegraphcontext/tools/query_tool_languages/python_toolkit.py +5 -0
  92. codegraphcontext/tools/query_tool_languages/ruby_toolkit.py +5 -0
  93. codegraphcontext/tools/query_tool_languages/rust_toolkit.py +5 -0
  94. codegraphcontext/tools/query_tool_languages/scala_toolkit.py +5 -0
  95. codegraphcontext/tools/query_tool_languages/swift_toolkit.py +5 -0
  96. codegraphcontext/tools/query_tool_languages/typescript_toolkit.py +5 -0
  97. codegraphcontext/tools/scip_indexer.py +467 -0
  98. codegraphcontext/tools/scip_pb2.py +2455 -0
  99. codegraphcontext/tools/system.py +133 -0
  100. codegraphcontext/tools/tree_sitter_parser.py +103 -0
  101. codegraphcontext/utils/debug_log.py +90 -0
  102. codegraphcontext/utils/path_ignore.py +55 -0
  103. codegraphcontext/utils/repo_path.py +27 -0
  104. codegraphcontext/utils/tree_sitter_manager.py +285 -0
  105. codegraphcontext/utils/visualize_graph.py +0 -0
  106. codegraphcontext/viz/server.py +282 -0
  107. codegraphcontext_rust-0.9.24.dist-info/METADATA +543 -0
  108. codegraphcontext_rust-0.9.24.dist-info/RECORD +112 -0
  109. codegraphcontext_rust-0.9.24.dist-info/WHEEL +4 -0
  110. codegraphcontext_rust-0.9.24.dist-info/entry_points.txt +4 -0
  111. codegraphcontext_rust-0.9.24.dist-info/licenses/LICENSE +21 -0
  112. codegraphcontext_rust-0.9.24.dist-info/sboms/cgc-python.cyclonedx.json +2302 -0
@@ -0,0 +1,253 @@
1
+ """Heuristic resolution of function calls into CALLS edge payloads (no DB I/O)."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any, Dict, List, Optional, Tuple
5
+
6
+ from ....cli.config_manager import get_config_value
7
+ from ....utils.debug_log import info_logger
8
+
9
+
10
+ def resolve_function_call(
11
+ call: Dict[str, Any],
12
+ caller_file_path: str,
13
+ local_names: set,
14
+ local_imports: dict,
15
+ imports_map: dict,
16
+ skip_external: bool,
17
+ ) -> Optional[Dict[str, Any]]:
18
+ """Resolve a single function call to its target. Returns call params dict or None if skipped."""
19
+ called_name = call["name"]
20
+ if called_name in __builtins__:
21
+ return None
22
+
23
+ resolved_path = None
24
+ full_call = call.get("full_name", called_name)
25
+ base_obj = full_call.split(".")[0] if "." in full_call else None
26
+
27
+ is_chained_call = full_call.count(".") > 1 if "." in full_call else False
28
+
29
+ if is_chained_call and base_obj in ("self", "this", "super", "super()", "cls", "@"):
30
+ lookup_name = called_name
31
+ else:
32
+ lookup_name = base_obj if base_obj else called_name
33
+
34
+ if base_obj in ("self", "this", "super", "super()", "cls", "@") and not is_chained_call:
35
+ resolved_path = caller_file_path
36
+ elif lookup_name in local_names:
37
+ resolved_path = caller_file_path
38
+ elif call.get("inferred_obj_type"):
39
+ obj_type = call["inferred_obj_type"]
40
+ possible_paths = imports_map.get(obj_type, [])
41
+ if len(possible_paths) > 0:
42
+ resolved_path = possible_paths[0]
43
+
44
+ if not resolved_path:
45
+ possible_paths = imports_map.get(lookup_name, [])
46
+ if len(possible_paths) == 1:
47
+ resolved_path = possible_paths[0]
48
+ elif len(possible_paths) > 1:
49
+ if lookup_name in local_imports:
50
+ full_import_name = local_imports[lookup_name]
51
+ if full_import_name in imports_map:
52
+ direct_paths = imports_map[full_import_name]
53
+ if direct_paths and len(direct_paths) == 1:
54
+ resolved_path = direct_paths[0]
55
+ if not resolved_path:
56
+ for path in possible_paths:
57
+ if full_import_name.replace(".", "/") in path:
58
+ resolved_path = path
59
+ break
60
+
61
+ if not resolved_path:
62
+ is_unresolved_external = True
63
+ else:
64
+ is_unresolved_external = False
65
+
66
+ if not resolved_path:
67
+ possible_paths = imports_map.get(lookup_name, [])
68
+ if len(possible_paths) > 0:
69
+ if lookup_name in local_imports:
70
+ pass
71
+ else:
72
+ pass
73
+ if not resolved_path:
74
+ if called_name in local_names:
75
+ resolved_path = caller_file_path
76
+ is_unresolved_external = False
77
+ elif called_name in imports_map and imports_map[called_name]:
78
+ candidates = imports_map[called_name]
79
+ for path in candidates:
80
+ for imp_name in local_imports.values():
81
+ if imp_name.replace(".", "/") in path:
82
+ resolved_path = path
83
+ is_unresolved_external = False
84
+ break
85
+ if resolved_path:
86
+ break
87
+ if not resolved_path:
88
+ resolved_path = candidates[0]
89
+ else:
90
+ resolved_path = caller_file_path
91
+
92
+ if skip_external and is_unresolved_external:
93
+ return None
94
+
95
+ caller_context = call.get("context")
96
+ if caller_context and len(caller_context) == 3 and caller_context[0] is not None:
97
+ caller_name, _, caller_line_number = caller_context
98
+ return {
99
+ "type": "function",
100
+ "caller_name": caller_name,
101
+ "caller_file_path": caller_file_path,
102
+ "caller_line_number": caller_line_number,
103
+ "called_name": called_name,
104
+ "called_file_path": resolved_path,
105
+ "line_number": call["line_number"],
106
+ "args": call.get("args", []),
107
+ "full_call_name": call.get("full_name", called_name),
108
+ }
109
+ return {
110
+ "type": "file",
111
+ "caller_file_path": caller_file_path,
112
+ "called_name": called_name,
113
+ "called_file_path": resolved_path,
114
+ "line_number": call["line_number"],
115
+ "args": call.get("args", []),
116
+ "full_call_name": call.get("full_name", called_name),
117
+ }
118
+
119
+
120
+ def build_function_call_groups(
121
+ all_file_data: List[Dict[str, Any]],
122
+ imports_map: dict,
123
+ file_class_lookup: Optional[Dict[str, set]] = None,
124
+ ) -> Tuple[
125
+ List[Dict],
126
+ List[Dict],
127
+ List[Dict],
128
+ List[Dict],
129
+ List[Dict],
130
+ List[Dict],
131
+ ]:
132
+ """Phase 1 of CALLS linking: resolve and bucket by (caller_label, called_label) pair."""
133
+ skip_external = (get_config_value("SKIP_EXTERNAL_RESOLUTION") or "false").lower() == "true"
134
+
135
+ if file_class_lookup is None:
136
+ file_class_lookup = {}
137
+ for fd in all_file_data:
138
+ fp = str(Path(fd["path"]).resolve())
139
+ file_class_lookup[fp] = {c["name"] for c in fd.get("classes", [])}
140
+
141
+ info_logger(f"[CALLS] Resolving function calls across {len(all_file_data)} files...")
142
+ fn_to_fn: List[Dict] = []
143
+ fn_to_cls: List[Dict] = []
144
+ cls_to_fn: List[Dict] = []
145
+ cls_to_cls: List[Dict] = []
146
+ file_to_fn: List[Dict] = []
147
+ file_to_cls: List[Dict] = []
148
+
149
+ # Pre-build per-language-extension filtered imports_map views.
150
+ # When a caller is Java, we only want to resolve against Java files —
151
+ # this prevents false-positive CALLS edges from names that coincidentally
152
+ # exist in another language's file (e.g. Java `add()` -> JS `add`).
153
+ _lang_imports_cache: Dict[str, dict] = {}
154
+
155
+ def _get_lang_imports(caller_lang: str) -> dict:
156
+ if caller_lang not in _lang_imports_cache:
157
+ # Map language name to typical file extensions
158
+ _LANG_EXTS: Dict[str, set] = {
159
+ "java": {".java"},
160
+ "python": {".py", ".ipynb"},
161
+ "javascript": {".js", ".jsx", ".mjs", ".cjs"},
162
+ "typescript": {".ts", ".tsx"},
163
+ "go": {".go"},
164
+ "rust": {".rs"},
165
+ "cpp": {".cpp", ".h", ".hpp", ".hh"},
166
+ "c": {".c"},
167
+ "c_sharp": {".cs"},
168
+ "kotlin": {".kt"},
169
+ "scala": {".scala", ".sc"},
170
+ "ruby": {".rb"},
171
+ "swift": {".swift"},
172
+ "php": {".php"},
173
+ "dart": {".dart"},
174
+ "perl": {".pl", ".pm"},
175
+ "haskell": {".hs"},
176
+ "elixir": {".ex", ".exs"},
177
+ }
178
+ exts = _LANG_EXTS.get(caller_lang)
179
+ if not exts:
180
+ # Unknown language — use full imports_map unchanged
181
+ _lang_imports_cache[caller_lang] = imports_map
182
+ else:
183
+ filtered: dict = {}
184
+ for name, paths in imports_map.items():
185
+ same_lang = [p for p in paths if Path(p).suffix in exts]
186
+ if same_lang:
187
+ filtered[name] = same_lang
188
+ elif paths:
189
+ # Keep non-file entries (e.g. package names with no extension)
190
+ if not any(Path(p).suffix for p in paths):
191
+ filtered[name] = paths
192
+ _lang_imports_cache[caller_lang] = filtered
193
+ return _lang_imports_cache[caller_lang]
194
+
195
+ for idx, file_data in enumerate(all_file_data):
196
+ caller_file_path = str(Path(file_data["path"]).resolve())
197
+ func_names = {f["name"] for f in file_data.get("functions", [])}
198
+ class_names = {c["name"] for c in file_data.get("classes", [])}
199
+ local_names = func_names | class_names
200
+ local_imports = {
201
+ imp.get("alias") or imp["name"].split(".")[-1]: imp["name"]
202
+ for imp in file_data.get("imports", [])
203
+ }
204
+
205
+ caller_lang = file_data.get("lang", "")
206
+ effective_imports_map = _get_lang_imports(caller_lang) if caller_lang else imports_map
207
+
208
+ for call in file_data.get("function_calls", []):
209
+ resolved = resolve_function_call(
210
+ call, caller_file_path, local_names, local_imports, effective_imports_map, skip_external
211
+ )
212
+ if not resolved:
213
+ continue
214
+
215
+ called_path = resolved.get("called_file_path", "")
216
+ called_name = resolved["called_name"]
217
+ called_is_class = called_name in file_class_lookup.get(called_path, set())
218
+
219
+ if resolved["type"] == "file":
220
+ if called_is_class:
221
+ file_to_cls.append(resolved)
222
+ else:
223
+ file_to_fn.append(resolved)
224
+ else:
225
+ caller_name = resolved["caller_name"]
226
+ caller_is_class = caller_name in class_names
227
+ if caller_is_class:
228
+ (cls_to_cls if called_is_class else cls_to_fn).append(resolved)
229
+ else:
230
+ (fn_to_cls if called_is_class else fn_to_fn).append(resolved)
231
+
232
+ if (idx + 1) % 1000 == 0:
233
+ total = len(fn_to_fn) + len(fn_to_cls) + len(cls_to_fn) + len(cls_to_cls)
234
+ file_total = len(file_to_fn) + len(file_to_cls)
235
+ info_logger(
236
+ f"[CALLS] Resolved {idx + 1}/{len(all_file_data)} files... "
237
+ f"({total} fn/cls calls, {file_total} file calls)"
238
+ )
239
+
240
+ total_all = (
241
+ len(fn_to_fn)
242
+ + len(fn_to_cls)
243
+ + len(cls_to_fn)
244
+ + len(cls_to_cls)
245
+ + len(file_to_fn)
246
+ + len(file_to_cls)
247
+ )
248
+ info_logger(
249
+ f"[CALLS] Resolution complete: fn→fn={len(fn_to_fn)}, fn→cls={len(fn_to_cls)}, "
250
+ f"cls→fn={len(cls_to_fn)}, cls→cls={len(cls_to_cls)}, "
251
+ f"file→fn={len(file_to_fn)}, file→cls={len(file_to_cls)}. Total={total_all}"
252
+ )
253
+ return fn_to_fn, fn_to_cls, cls_to_fn, cls_to_cls, file_to_fn, file_to_cls
@@ -0,0 +1,91 @@
1
+ """Resolve class inheritance into INHERITS row payloads (no DB I/O for non-C# batch)."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any, Dict, List, Optional, Tuple
5
+
6
+
7
+ def resolve_inheritance_link(
8
+ class_item: Dict[str, Any],
9
+ base_class_str: str,
10
+ caller_file_path: str,
11
+ local_class_names: set,
12
+ local_imports: dict,
13
+ imports_map: dict,
14
+ ) -> Optional[Dict[str, Any]]:
15
+ """Resolve a single inheritance link. Returns row dict or None."""
16
+ if base_class_str == "object":
17
+ return None
18
+
19
+ resolved_path = None
20
+ target_class_name = base_class_str.split(".")[-1]
21
+
22
+ if "." in base_class_str:
23
+ lookup_name = base_class_str.split(".")[0]
24
+ if lookup_name in local_imports:
25
+ full_import_name = local_imports[lookup_name]
26
+ possible_paths = imports_map.get(target_class_name, [])
27
+ for path in possible_paths:
28
+ if full_import_name.replace(".", "/") in path:
29
+ resolved_path = path
30
+ break
31
+ else:
32
+ lookup_name = base_class_str
33
+ if lookup_name in local_class_names:
34
+ resolved_path = caller_file_path
35
+ elif lookup_name in local_imports:
36
+ full_import_name = local_imports[lookup_name]
37
+ possible_paths = imports_map.get(target_class_name, [])
38
+ for path in possible_paths:
39
+ if full_import_name.replace(".", "/") in path:
40
+ resolved_path = path
41
+ break
42
+ elif lookup_name in imports_map:
43
+ possible_paths = imports_map[lookup_name]
44
+ if len(possible_paths) == 1:
45
+ resolved_path = possible_paths[0]
46
+
47
+ if resolved_path:
48
+ return {
49
+ "child_name": class_item["name"],
50
+ "path": caller_file_path,
51
+ "parent_name": target_class_name,
52
+ "resolved_parent_file_path": resolved_path,
53
+ }
54
+ return None
55
+
56
+
57
+ def build_inheritance_and_csharp_files(
58
+ all_file_data: List[Dict[str, Any]], imports_map: dict
59
+ ) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]:
60
+ """Returns (inheritance_batch_rows, csharp_file_data_list)."""
61
+ inheritance_batch: List[Dict[str, Any]] = []
62
+ csharp_files: List[Dict[str, Any]] = []
63
+
64
+ for file_data in all_file_data:
65
+ if file_data.get("lang") == "c_sharp":
66
+ csharp_files.append(file_data)
67
+ continue
68
+
69
+ caller_file_path = str(Path(file_data["path"]).resolve())
70
+ local_class_names = {c["name"] for c in file_data.get("classes", [])}
71
+ local_imports = {
72
+ imp.get("alias") or imp["name"].split(".")[-1]: imp["name"]
73
+ for imp in file_data.get("imports", [])
74
+ }
75
+
76
+ for class_item in file_data.get("classes", []):
77
+ if not class_item.get("bases"):
78
+ continue
79
+ for base_class_str in class_item["bases"]:
80
+ resolved = resolve_inheritance_link(
81
+ class_item,
82
+ base_class_str,
83
+ caller_file_path,
84
+ local_class_names,
85
+ local_imports,
86
+ imports_map,
87
+ )
88
+ if resolved:
89
+ inheritance_batch.append(resolved)
90
+
91
+ return inheritance_batch, csharp_files