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,287 @@
1
+ """Extract operational parameters from source code.
2
+
3
+ Captures: timeouts, cron schedules, retry configs, pool sizes,
4
+ rate limits, and other runtime configuration values.
5
+
6
+ These are found in:
7
+ - Variable declarations with config-like names
8
+ - Annotation arguments (@Scheduled, @Retryable, @Backoff)
9
+ - Method calls (setTimeout, setConnectTimeout, etc.)
10
+ - Constants (MAX_*, TIMEOUT_*, etc.)
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import logging
16
+ import os
17
+ import re
18
+ from pathlib import Path
19
+ from typing import Any, Dict, List
20
+
21
+ logger = logging.getLogger(__name__)
22
+
23
+ # Regex for config-like variable/constant names
24
+ _NAME_PATTERN = re.compile(
25
+ r"(?i)(timeout|cron|schedule|interval|retry|retries|"
26
+ r"max_|min_|port|host|redis|celery|ttl|cooldown|"
27
+ r"batch|concurren|threshold|limit|delay|period|frequency|"
28
+ r"worker|queue|pool.?size|backoff|rate.?limit|"
29
+ r"expir|duration|capacity|buffer.?size|chunk)"
30
+ )
31
+
32
+ # Patterns to extract from source lines
33
+ _LINE_PATTERNS = [
34
+ # Java annotations: @Scheduled(fixedRate = 21600000)
35
+ re.compile(
36
+ r"@(?:Scheduled|Retryable|Backoff|CacheConfig|Cacheable)\s*\("
37
+ r"([^)]+)\)",
38
+ re.IGNORECASE,
39
+ ),
40
+ # Java/general: setTimeout(30000), setConnectTimeout(30000)
41
+ re.compile(
42
+ r"(?:set|get)?(?:Connect|Read|Write|Socket|Request)?Timeout\s*\(\s*(\d+)",
43
+ re.IGNORECASE,
44
+ ),
45
+ # Constant assignments: MAX_RETRIES = 3, TIMEOUT_MS = 5000
46
+ re.compile(
47
+ r"(?:final\s+)?(?:static\s+)?(?:final\s+)?(?:\w+\s+)?"
48
+ r"([A-Z][A-Z_0-9]*(?:TIMEOUT|RETRY|LIMIT|INTERVAL|DELAY|MAX|MIN|TTL|CRON|POOL|BATCH|RATE|BUFFER|DURATION|CAPACITY)[\w]*)"
49
+ r"\s*=\s*([^;{]+)",
50
+ re.MULTILINE,
51
+ ),
52
+ # Python/YAML-style: timeout = 30, max_retries = 3
53
+ re.compile(
54
+ r"^\s*([a-z][a-z_0-9]*(?:timeout|retry|limit|interval|delay|max|min|ttl|cron|pool|batch|rate|buffer|duration|capacity)[\w]*)"
55
+ r"\s*[:=]\s*(.+?)(?:\s*#.*)?$",
56
+ re.IGNORECASE | re.MULTILINE,
57
+ ),
58
+ ]
59
+
60
+ # Languages to scan
61
+ _SCAN_EXTENSIONS = {
62
+ ".java", ".py", ".js", ".ts", ".go", ".rs", ".rb", ".php",
63
+ ".kt", ".scala", ".swift", ".cs", ".c", ".cpp",
64
+ }
65
+
66
+ # Value validation: only keep values that look like actual config values
67
+ # (numbers, string literals, durations, cron expressions, booleans)
68
+ # Reject: type declarations (String, Integer, CompletableFuture<T>, etc.)
69
+ _VALID_VALUE_RE = re.compile(
70
+ r"^("
71
+ r"\d[\d_.,]*" # numbers: 30000, 5_000, 3.14
72
+ r"|['\"].*['\"]" # string literals: "0 */6 * * *"
73
+ r"|true|false|True|False" # booleans
74
+ r"|null|None|nil" # null values
75
+ r"|\d+\s*\*\s*\d+" # expressions: 60 * 1000
76
+ r"|Duration\.of\w+" # Java Duration.ofSeconds(30)
77
+ r"|Period\.of\w+" # Java Period.ofDays(7)
78
+ r"|TimeUnit\.\w+" # Java TimeUnit.SECONDS
79
+ r"|timedelta\(" # Python timedelta(...)
80
+ r"|\d+[smhd]" # duration shorthand: 30s, 5m, 1h, 7d
81
+ r")"
82
+ )
83
+
84
+ # Type names that indicate a type declaration (NOT a config value)
85
+ _TYPE_DECLARATION_RE = re.compile(
86
+ r"^(String|Integer|Long|Double|Float|Boolean|Byte|Short|Character"
87
+ r"|int|long|double|float|boolean|byte|short|char|void"
88
+ r"|List|Map|Set|Queue|Deque|Collection|Optional"
89
+ r"|CompletableFuture|Future|Callable|Runnable|Supplier|Consumer"
90
+ r"|AtomicInteger|AtomicLong|AtomicReference|AtomicBoolean"
91
+ r"|BigDecimal|BigInteger"
92
+ r"|LocalDateTime|Instant|Date|Duration|ZonedDateTime"
93
+ r"|[A-Z]\w*<)" # any Generic<T>
94
+ )
95
+
96
+
97
+ def _is_valid_config_value(value: str) -> bool:
98
+ """Return True if value looks like an actual config value, not a type declaration."""
99
+ v = value.strip().rstrip(",;")
100
+ if not v:
101
+ return False
102
+ # Accept known config value patterns FIRST (before type check)
103
+ if _VALID_VALUE_RE.match(v):
104
+ return True
105
+ # Reject type declarations
106
+ if _TYPE_DECLARATION_RE.match(v):
107
+ return False
108
+ # Accept if it's a short constant reference (all caps, e.g. MAX_RETRIES)
109
+ if re.match(r"^[A-Z][A-Z_0-9]+$", v):
110
+ return True
111
+ # Accept annotation values (already validated by annotation pattern)
112
+ if v.startswith("@"):
113
+ return True
114
+ # Reject anything that looks like a type (starts with uppercase, contains generic)
115
+ if re.match(r"^[A-Z][a-zA-Z]*$", v) or "<" in v:
116
+ return False
117
+ # Accept numeric expressions
118
+ if re.match(r"^[\d\s+\-*/().]+$", v):
119
+ return True
120
+ return False
121
+
122
+
123
+ def extract_operational_params(
124
+ parsed_results: List[Dict[str, Any]],
125
+ repo_path: str,
126
+ ) -> List[Dict[str, Any]]:
127
+ """Extract operational parameters from source files.
128
+
129
+ Returns list of:
130
+ {
131
+ name: str,
132
+ value: str,
133
+ path: str (relative),
134
+ line_number: int,
135
+ category: str (timeout|schedule|retry|limit|pool|config),
136
+ }
137
+ """
138
+ params: List[Dict[str, Any]] = []
139
+ seen: set = set() # deduplicate
140
+
141
+ # Pre-filter: only scan files likely to have config values
142
+ # (files with config-like variable names, or Java/Python config files)
143
+ _CONFIG_PATH_HINTS = {"config", "setting", "constant", "env", "properties"}
144
+ files_to_scan = []
145
+ for file_data in parsed_results:
146
+ if "error" in file_data:
147
+ continue
148
+ file_path = file_data.get("path", "")
149
+ ext = Path(file_path).suffix.lower()
150
+ if ext not in _SCAN_EXTENSIONS or not os.path.exists(file_path):
151
+ continue
152
+ # Scan if: has config-like variables, or path contains config hints
153
+ has_config_var = any(
154
+ _NAME_PATTERN.search(v.get("name", ""))
155
+ for v in file_data.get("variables", [])
156
+ )
157
+ path_lower = file_path.lower()
158
+ has_config_path = any(h in path_lower for h in _CONFIG_PATH_HINTS)
159
+ # Java/Python files with decorators (@Scheduled, @Retryable)
160
+ has_decorators = any(
161
+ any(d for d in f.get("decorators", []) or []
162
+ if any(k in str(d).lower() for k in ("scheduled", "retryable", "backoff", "cacheable")))
163
+ for f in file_data.get("functions", [])
164
+ )
165
+ if has_config_var or has_config_path or has_decorators:
166
+ files_to_scan.append(file_data)
167
+
168
+ logger.debug("op_params: scanning %d/%d files (pre-filtered)", len(files_to_scan), len(parsed_results))
169
+
170
+ for file_data in files_to_scan:
171
+ file_path = file_data.get("path", "")
172
+ ext = Path(file_path).suffix.lower()
173
+
174
+ try:
175
+ rel_path = os.path.relpath(file_path, repo_path)
176
+ except ValueError:
177
+ rel_path = Path(file_path).name
178
+
179
+ try:
180
+ with open(file_path, "r", encoding="utf-8", errors="replace") as fh:
181
+ for line_no, line in enumerate(fh, 1):
182
+ # Skip comments-only lines and imports
183
+ stripped = line.strip()
184
+ if stripped.startswith(("//", "#", "*", "/*", "import ", "package ")):
185
+ continue
186
+
187
+ for pattern in _LINE_PATTERNS:
188
+ for m in pattern.finditer(line):
189
+ groups = m.groups()
190
+ if len(groups) >= 2:
191
+ name = groups[0].strip()
192
+ value = groups[1].strip().rstrip(",;")
193
+ elif len(groups) == 1:
194
+ # Annotation args: parse key=value pairs
195
+ arg_str = groups[0]
196
+ for kv in re.finditer(r"(\w+)\s*=\s*([^,)]+)", arg_str):
197
+ k, v = kv.group(1).strip(), kv.group(2).strip()
198
+ key = f"@{m.group(0).split('(')[0].strip('@')}({k})"
199
+ dedup_key = f"{key}|{rel_path}|{line_no}"
200
+ if dedup_key in seen:
201
+ continue
202
+ seen.add(dedup_key)
203
+ params.append({
204
+ "name": key,
205
+ "value": v,
206
+ "path": rel_path,
207
+ "line_number": line_no,
208
+ "category": _categorize(key),
209
+ })
210
+ continue
211
+ else:
212
+ continue
213
+
214
+ # Check if name matches config pattern
215
+ if not _NAME_PATTERN.search(name):
216
+ continue
217
+
218
+ # Validate value is a real config value, not a type declaration
219
+ if not _is_valid_config_value(value):
220
+ continue
221
+
222
+ dedup_key = f"{name}|{rel_path}|{line_no}"
223
+ if dedup_key in seen:
224
+ continue
225
+ seen.add(dedup_key)
226
+
227
+ params.append({
228
+ "name": name,
229
+ "value": value[:200],
230
+ "path": rel_path,
231
+ "line_number": line_no,
232
+ "category": _categorize(name),
233
+ })
234
+ except OSError:
235
+ continue
236
+
237
+ # Also scan variables from parsed results
238
+ for file_data in parsed_results:
239
+ if "error" in file_data:
240
+ continue
241
+ file_path = file_data.get("path", "")
242
+ try:
243
+ rel_path = os.path.relpath(file_path, repo_path)
244
+ except ValueError:
245
+ rel_path = Path(file_path).name
246
+
247
+ for var in file_data.get("variables", []):
248
+ name = var.get("name", "")
249
+ if not _NAME_PATTERN.search(name):
250
+ continue
251
+ var_value = var.get("type", "")
252
+ # Only keep variables whose captured value looks like a real config
253
+ # value. Empty/missing values (common from parsers that extract
254
+ # declarations but not literals) are noise in a config panel.
255
+ if not var_value or not _is_valid_config_value(var_value):
256
+ continue
257
+ dedup_key = f"{name}|{rel_path}|{var.get('line_number', 0)}"
258
+ if dedup_key in seen:
259
+ continue
260
+ seen.add(dedup_key)
261
+ params.append({
262
+ "name": name,
263
+ "value": var_value,
264
+ "path": rel_path,
265
+ "line_number": var.get("line_number", 0),
266
+ "category": _categorize(name),
267
+ })
268
+
269
+ params.sort(key=lambda p: (p["path"], p["line_number"]))
270
+ logger.info("Extracted %d operational parameters", len(params))
271
+ return params
272
+
273
+
274
+ def _categorize(name: str) -> str:
275
+ """Categorize an operational parameter by name."""
276
+ n = name.lower()
277
+ if any(x in n for x in ("timeout", "ttl", "expir", "duration")):
278
+ return "timeout"
279
+ if any(x in n for x in ("cron", "schedule", "interval", "period", "frequency")):
280
+ return "schedule"
281
+ if any(x in n for x in ("retry", "retries", "backoff")):
282
+ return "retry"
283
+ if any(x in n for x in ("max", "min", "limit", "threshold", "capacity")):
284
+ return "limit"
285
+ if any(x in n for x in ("pool", "worker", "queue", "concurren", "batch")):
286
+ return "pool"
287
+ return "config"
@@ -0,0 +1,3 @@
1
+ from .writer import GraphWriter
2
+
3
+ __all__ = ["GraphWriter"]