codegraphcontext 0.3.1__tar.gz → 0.3.2__tar.gz
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.
- {codegraphcontext-0.3.1/src/codegraphcontext.egg-info → codegraphcontext-0.3.2}/PKG-INFO +4 -4
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/README.md +3 -2
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/pyproject.toml +1 -2
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/cgc_bundle.py +5 -1
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/graph_builder.py +157 -6
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/package_resolver.py +12 -10
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2/src/codegraphcontext.egg-info}/PKG-INFO +4 -4
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext.egg-info/SOURCES.txt +1 -13
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext.egg-info/requires.txt +0 -1
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/assets/function-calls-BtRHrqa2.png +0 -0
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/assets/graph-total-D1fBAugo.png +0 -0
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/assets/hero-graph-2voMJp2a.jpg +0 -0
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/assets/hierarchy-DGADo0YT.png +0 -0
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/assets/index-DDAcqlyl.css +0 -1
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/assets/index-Do_-h1Gi.js +0 -23776
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/favicon.ico +0 -0
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/index.html +0 -31
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/placeholder.svg +0 -1
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/preview-image.png +0 -0
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/robots.txt +0 -14
- codegraphcontext-0.3.1/src/codegraphcontext/viz/dist/tree-sitter.wasm +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/LICENSE +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/MANIFEST.in +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/setup.cfg +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/__init__.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/__main__.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/__init__.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/cli_helpers.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/config_manager.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/main.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/registry_commands.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/setup_macos.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/setup_wizard.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/cli/visualizer.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/__init__.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/bundle_registry.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/database.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/database_falkordb.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/database_falkordb_remote.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/database_kuzu.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/falkor_worker.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/jobs.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/core/watcher.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/prompts.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/server.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tool_definitions.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/__init__.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/advanced_language_query_tool.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/code_finder.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/handlers/analysis_handlers.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/handlers/indexing_handlers.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/handlers/management_handlers.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/handlers/query_handlers.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/handlers/watcher_handlers.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/c.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/cpp.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/csharp.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/dart.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/elixir.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/go.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/haskell.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/java.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/javascript.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/kotlin.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/perl.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/php.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/python.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/ruby.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/rust.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/scala.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/swift.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/typescript.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/languages/typescriptjsx.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/c_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/cpp_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/csharp_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/dart_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/go_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/haskell_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/java_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/javascript_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/perl_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/python_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/ruby_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/rust_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/scala_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/swift_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/query_tool_languages/typescript_toolkit.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/scip_indexer.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/scip_pb2.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/system.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/utils/debug_log.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/utils/tree_sitter_manager.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/utils/visualize_graph.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/viz/server.py +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext.egg-info/dependency_links.txt +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext.egg-info/entry_points.txt +0 -0
- {codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegraphcontext
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: An MCP server that indexes local code into a graph database to provide context to AI assistants.
|
|
5
5
|
Author-email: Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -46,7 +46,6 @@ Requires-Dist: python-dotenv>=1.0.0
|
|
|
46
46
|
Requires-Dist: tree-sitter>=0.21.0
|
|
47
47
|
Requires-Dist: tree-sitter-language-pack>=0.6.0
|
|
48
48
|
Requires-Dist: pyyaml
|
|
49
|
-
Requires-Dist: pytest
|
|
50
49
|
Requires-Dist: nbformat
|
|
51
50
|
Requires-Dist: nbconvert>=7.16.6
|
|
52
51
|
Requires-Dist: pathspec>=0.12.1
|
|
@@ -70,6 +69,7 @@ Dynamic: license-file
|
|
|
70
69
|
🌐 **Languages:**
|
|
71
70
|
- 🇬🇧 [English](README.md)
|
|
72
71
|
- 🇨🇳 [中文](README.zh-CN.md)
|
|
72
|
+
- 🇰🇷 [한국어](README.kor.md)
|
|
73
73
|
- 🇯🇵 日本語 (Soon)
|
|
74
74
|
- 🇷🇺 Русский (Soon)
|
|
75
75
|
- 🇪🇸 Español (Soon)
|
|
@@ -160,7 +160,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
|
|
|
160
160
|
---
|
|
161
161
|
|
|
162
162
|
## Project Details
|
|
163
|
-
- **Version:** 0.3.
|
|
163
|
+
- **Version:** 0.3.2
|
|
164
164
|
- **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
165
165
|
- **License:** MIT License (See [LICENSE](LICENSE) for details)
|
|
166
166
|
- **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
|
|
@@ -365,7 +365,7 @@ cgc watch .
|
|
|
365
365
|
cgc help
|
|
366
366
|
```
|
|
367
367
|
|
|
368
|
-
**See the full [CLI Commands Guide](
|
|
368
|
+
**See the full [CLI Commands Guide](docs/CLI_COMPLETE_REFERENCE.md) for all available commands and usage scenarios.**
|
|
369
369
|
|
|
370
370
|
### 🎨 Premium Interactive Visualization
|
|
371
371
|
CodeGraphContext can generate stunning, interactive knowledge graphs of your code. Unlike static diagrams, these are premium web-based explorers:
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
🌐 **Languages:**
|
|
6
6
|
- 🇬🇧 [English](README.md)
|
|
7
7
|
- 🇨🇳 [中文](README.zh-CN.md)
|
|
8
|
+
- 🇰🇷 [한국어](README.kor.md)
|
|
8
9
|
- 🇯🇵 日本語 (Soon)
|
|
9
10
|
- 🇷🇺 Русский (Soon)
|
|
10
11
|
- 🇪🇸 Español (Soon)
|
|
@@ -95,7 +96,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
|
|
|
95
96
|
---
|
|
96
97
|
|
|
97
98
|
## Project Details
|
|
98
|
-
- **Version:** 0.3.
|
|
99
|
+
- **Version:** 0.3.2
|
|
99
100
|
- **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
100
101
|
- **License:** MIT License (See [LICENSE](LICENSE) for details)
|
|
101
102
|
- **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
|
|
@@ -300,7 +301,7 @@ cgc watch .
|
|
|
300
301
|
cgc help
|
|
301
302
|
```
|
|
302
303
|
|
|
303
|
-
**See the full [CLI Commands Guide](
|
|
304
|
+
**See the full [CLI Commands Guide](docs/CLI_COMPLETE_REFERENCE.md) for all available commands and usage scenarios.**
|
|
304
305
|
|
|
305
306
|
### 🎨 Premium Interactive Visualization
|
|
306
307
|
CodeGraphContext can generate stunning, interactive knowledge graphs of your code. Unlike static diagrams, these are premium web-based explorers:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codegraphcontext"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.2"
|
|
4
4
|
description = "An MCP server that indexes local code into a graph database to provide context to AI assistants."
|
|
5
5
|
authors = [{ name = "Shashank Shekhar Singh", email = "shashankshekharsingh1205@gmail.com" }]
|
|
6
6
|
readme = "README.md"
|
|
@@ -25,7 +25,6 @@ dependencies = [
|
|
|
25
25
|
"tree-sitter>=0.21.0",
|
|
26
26
|
"tree-sitter-language-pack>=0.6.0",
|
|
27
27
|
"pyyaml",
|
|
28
|
-
"pytest",
|
|
29
28
|
"nbformat",
|
|
30
29
|
"nbconvert>=7.16.6",
|
|
31
30
|
"pathspec>=0.12.1",
|
|
@@ -161,9 +161,13 @@ class CGCBundle:
|
|
|
161
161
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
162
162
|
temp_path = Path(temp_dir)
|
|
163
163
|
|
|
164
|
-
# Step 1: Extract ZIP
|
|
164
|
+
# Step 1: Extract ZIP (with Zip Slip protection)
|
|
165
165
|
info_logger("Extracting bundle...")
|
|
166
166
|
with zipfile.ZipFile(bundle_path, 'r') as zip_ref:
|
|
167
|
+
for entry in zip_ref.namelist():
|
|
168
|
+
resolved = (temp_path / entry).resolve()
|
|
169
|
+
if not str(resolved).startswith(str(temp_path.resolve())):
|
|
170
|
+
return False, f"Zip Slip detected: entry '{entry}' escapes target directory"
|
|
167
171
|
zip_ref.extractall(temp_path)
|
|
168
172
|
|
|
169
173
|
# Step 2: Validate bundle
|
{codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/graph_builder.py
RENAMED
|
@@ -14,7 +14,20 @@ from ..utils.debug_log import debug_log, info_logger, error_logger, warning_logg
|
|
|
14
14
|
from tree_sitter import Language, Parser
|
|
15
15
|
from ..utils.tree_sitter_manager import get_tree_sitter_manager
|
|
16
16
|
from ..cli.config_manager import get_config_value
|
|
17
|
-
|
|
17
|
+
import fnmatch
|
|
18
|
+
|
|
19
|
+
DEFAULT_IGNORE_PATTERNS = [
|
|
20
|
+
"*.png",
|
|
21
|
+
"*.jpg",
|
|
22
|
+
"*.jpeg",
|
|
23
|
+
"*.gif",
|
|
24
|
+
"*.svg",
|
|
25
|
+
"*.mp4",
|
|
26
|
+
"*.mp3",
|
|
27
|
+
"*.zip",
|
|
28
|
+
"*.tar",
|
|
29
|
+
"*.gz",
|
|
30
|
+
]
|
|
18
31
|
|
|
19
32
|
class TreeSitterParser:
|
|
20
33
|
"""A generic parser wrapper for a specific language using tree-sitter."""
|
|
@@ -181,6 +194,38 @@ class GraphBuilder:
|
|
|
181
194
|
except Exception as e:
|
|
182
195
|
warning_logger(f"Schema creation warning: {e}")
|
|
183
196
|
|
|
197
|
+
@staticmethod
|
|
198
|
+
def _sanitize_props(props: Dict) -> Dict:
|
|
199
|
+
"""Return a copy of *props* with all values coerced to database-safe types.
|
|
200
|
+
|
|
201
|
+
FalkorDB and KùzuDB only accept node properties that are primitives
|
|
202
|
+
(str, int, float, bool, None) or flat lists of primitives. Complex
|
|
203
|
+
values such as tuples, dicts, or lists-of-dicts that come from language
|
|
204
|
+
parsers (e.g. C's ``detailed_args`` or Scala's tuple ``class_context``)
|
|
205
|
+
are serialized to a JSON string so the data is preserved rather than
|
|
206
|
+
being silently dropped.
|
|
207
|
+
"""
|
|
208
|
+
import json
|
|
209
|
+
|
|
210
|
+
def _is_primitive(v):
|
|
211
|
+
return isinstance(v, (str, int, float, bool)) or v is None
|
|
212
|
+
|
|
213
|
+
def _is_flat_list(v):
|
|
214
|
+
return isinstance(v, list) and all(_is_primitive(item) for item in v)
|
|
215
|
+
|
|
216
|
+
def _coerce(v):
|
|
217
|
+
if _is_primitive(v):
|
|
218
|
+
return v
|
|
219
|
+
if _is_flat_list(v):
|
|
220
|
+
return v
|
|
221
|
+
# Tuples, dicts, lists-of-dicts, nested structures → JSON string
|
|
222
|
+
try:
|
|
223
|
+
return json.dumps(v, default=str)
|
|
224
|
+
except Exception:
|
|
225
|
+
return str(v)
|
|
226
|
+
|
|
227
|
+
return {k: _coerce(v) for k, v in props.items()}
|
|
228
|
+
|
|
184
229
|
|
|
185
230
|
def _pre_scan_for_imports(self, files: list[Path]) -> dict:
|
|
186
231
|
"""Dispatches pre-scan to the correct language-specific implementation."""
|
|
@@ -381,7 +426,12 @@ class GraphBuilder:
|
|
|
381
426
|
MERGE (f)-[:CONTAINS]->(n)
|
|
382
427
|
"""
|
|
383
428
|
|
|
384
|
-
|
|
429
|
+
# Strip non-primitive fields (dicts, tuples, lists-of-dicts)
|
|
430
|
+
# before writing to the database to avoid runtime errors such as
|
|
431
|
+
# "Property values can only be of primitive types or arrays of
|
|
432
|
+
# primitive types" raised by FalkorDB / KùzuDB.
|
|
433
|
+
safe_props = self._sanitize_props(item)
|
|
434
|
+
session.run(query, path=file_path_str, name=item['name'], line_number=item['line_number'], props=safe_props)
|
|
385
435
|
|
|
386
436
|
if label == 'Function':
|
|
387
437
|
for arg_name in item.get('args', []):
|
|
@@ -1231,16 +1281,35 @@ class GraphBuilder:
|
|
|
1231
1281
|
break
|
|
1232
1282
|
curr = curr.parent
|
|
1233
1283
|
|
|
1284
|
+
spec = None
|
|
1234
1285
|
if cgcignore_path:
|
|
1235
1286
|
with open(cgcignore_path) as f:
|
|
1236
|
-
|
|
1287
|
+
user_patterns = [line.strip() for line in f.read().splitlines() if line.strip() and not line.strip().startswith('#')]
|
|
1288
|
+
ignore_patterns = DEFAULT_IGNORE_PATTERNS + user_patterns
|
|
1237
1289
|
spec = pathspec.PathSpec.from_lines('gitwildmatch', ignore_patterns)
|
|
1238
1290
|
else:
|
|
1239
|
-
|
|
1291
|
+
# No .cgcignore found — create one in the project root with default patterns
|
|
1292
|
+
# so the user can see and customize what's being ignored
|
|
1293
|
+
project_root = path.resolve() if path.is_dir() else path.resolve().parent
|
|
1294
|
+
new_cgcignore = project_root / ".cgcignore"
|
|
1295
|
+
try:
|
|
1296
|
+
cgcignore_content = "# Auto-generated by CodeGraphContext\n"
|
|
1297
|
+
cgcignore_content += "# Default ignore patterns for binary/media files\n"
|
|
1298
|
+
cgcignore_content += "# Add your own patterns below\n\n"
|
|
1299
|
+
cgcignore_content += "\n".join(DEFAULT_IGNORE_PATTERNS) + "\n"
|
|
1300
|
+
new_cgcignore.write_text(cgcignore_content)
|
|
1301
|
+
info_logger(f"Created default .cgcignore at {new_cgcignore}")
|
|
1302
|
+
except OSError as e:
|
|
1303
|
+
warning_logger(f"Could not create .cgcignore at {new_cgcignore}: {e}")
|
|
1304
|
+
spec = pathspec.PathSpec.from_lines('gitwildmatch', DEFAULT_IGNORE_PATTERNS)
|
|
1240
1305
|
|
|
1241
1306
|
supported_extensions = self.parsers.keys()
|
|
1242
1307
|
all_files = path.rglob("*") if path.is_dir() else [path]
|
|
1243
|
-
|
|
1308
|
+
|
|
1309
|
+
# Previously only files with supported extensions were indexed.
|
|
1310
|
+
# Updated to include all files so that unsupported file types
|
|
1311
|
+
# can still be represented as minimal File nodes in the graph.
|
|
1312
|
+
files = [f for f in all_files if f.is_file()]
|
|
1244
1313
|
|
|
1245
1314
|
# Filter default ignored directories
|
|
1246
1315
|
ignore_dirs_str = get_config_value("IGNORE_DIRS") or ""
|
|
@@ -1291,10 +1360,28 @@ class GraphBuilder:
|
|
|
1291
1360
|
self.job_manager.update_job(job_id, current_file=str(file))
|
|
1292
1361
|
repo_path = path.resolve() if path.is_dir() else file.parent.resolve()
|
|
1293
1362
|
file_data = self.parse_file(repo_path, file, is_dependency)
|
|
1363
|
+
# Previously only files with supported extensions were indexed.
|
|
1364
|
+
# Updated to include all files so that unsupported file types
|
|
1365
|
+
# can still be represented as minimal File nodes in the graph.
|
|
1294
1366
|
if "error" not in file_data:
|
|
1295
|
-
|
|
1367
|
+
try:
|
|
1368
|
+
self.add_file_to_graph(file_data, repo_name, imports_map)
|
|
1369
|
+
except Exception as file_err:
|
|
1370
|
+
# Re-raise with the offending file path so the user
|
|
1371
|
+
# can identify which source file triggered the error.
|
|
1372
|
+
raise RuntimeError(
|
|
1373
|
+
f"{file_err} (while indexing file: {file})"
|
|
1374
|
+
) from file_err
|
|
1296
1375
|
all_file_data.append(file_data)
|
|
1376
|
+
|
|
1377
|
+
# Previously only files with supported extensions were indexed.
|
|
1378
|
+
# Updated to include all files so that unsupported file types
|
|
1379
|
+
# can still be represented as minimal File nodes in the graph.
|
|
1380
|
+
else:
|
|
1381
|
+
# create minimal node if parser not available
|
|
1382
|
+
self.add_minimal_file_node(file, repo_path, is_dependency)
|
|
1297
1383
|
processed_count += 1
|
|
1384
|
+
|
|
1298
1385
|
if job_id:
|
|
1299
1386
|
self.job_manager.update_job(job_id, processed_files=processed_count)
|
|
1300
1387
|
await asyncio.sleep(0.01)
|
|
@@ -1318,3 +1405,67 @@ class GraphBuilder:
|
|
|
1318
1405
|
self.job_manager.update_job(
|
|
1319
1406
|
job_id, status=status, end_time=datetime.now(), errors=[str(e)]
|
|
1320
1407
|
)
|
|
1408
|
+
|
|
1409
|
+
# Create a minimal File node for unsupported file types.
|
|
1410
|
+
# These files do not contain parsed entities but should still
|
|
1411
|
+
# appear in the repository graph as requested in issue #707.
|
|
1412
|
+
def add_minimal_file_node(self, file_path: Path, repo_path: Path, is_dependency: bool = False):
|
|
1413
|
+
|
|
1414
|
+
file_path_str = str(file_path.resolve())
|
|
1415
|
+
file_name = file_path.name
|
|
1416
|
+
repo_name = repo_path.name
|
|
1417
|
+
repo_path_str = str(repo_path.resolve())
|
|
1418
|
+
|
|
1419
|
+
with self.driver.session() as session:
|
|
1420
|
+
|
|
1421
|
+
session.run(
|
|
1422
|
+
"""
|
|
1423
|
+
MERGE (r:Repository {path: $repo_path})
|
|
1424
|
+
SET r.name = $repo_name
|
|
1425
|
+
""",
|
|
1426
|
+
repo_path=repo_path_str,
|
|
1427
|
+
repo_name=repo_name
|
|
1428
|
+
)
|
|
1429
|
+
|
|
1430
|
+
session.run(
|
|
1431
|
+
"""
|
|
1432
|
+
MERGE (f:File {path: $file_path})
|
|
1433
|
+
SET f.name = $file_name,
|
|
1434
|
+
f.is_dependency = $is_dependency
|
|
1435
|
+
""",
|
|
1436
|
+
file_path=file_path_str,
|
|
1437
|
+
file_name=file_name,
|
|
1438
|
+
is_dependency=is_dependency
|
|
1439
|
+
)
|
|
1440
|
+
|
|
1441
|
+
# Establish directory structure
|
|
1442
|
+
file_path_obj = Path(file_path_str)
|
|
1443
|
+
repo_path_obj = Path(repo_path_str)
|
|
1444
|
+
try:
|
|
1445
|
+
relative_path_to_file = file_path_obj.relative_to(repo_path_obj)
|
|
1446
|
+
except ValueError:
|
|
1447
|
+
# Fallback if not relative
|
|
1448
|
+
relative_path_to_file = Path(file_path_obj.name)
|
|
1449
|
+
|
|
1450
|
+
parent_path = repo_path_str
|
|
1451
|
+
parent_label = 'Repository'
|
|
1452
|
+
|
|
1453
|
+
for part in relative_path_to_file.parts[:-1]:
|
|
1454
|
+
current_path = Path(parent_path) / part
|
|
1455
|
+
current_path_str = str(current_path)
|
|
1456
|
+
|
|
1457
|
+
session.run(f"""
|
|
1458
|
+
MATCH (p:{parent_label} {{path: $parent_path}})
|
|
1459
|
+
MERGE (d:Directory {{path: $current_path}})
|
|
1460
|
+
SET d.name = $part
|
|
1461
|
+
MERGE (p)-[:CONTAINS]->(d)
|
|
1462
|
+
""", parent_path=parent_path, current_path=current_path_str, part=part)
|
|
1463
|
+
|
|
1464
|
+
parent_path = current_path_str
|
|
1465
|
+
parent_label = 'Directory'
|
|
1466
|
+
|
|
1467
|
+
session.run(f"""
|
|
1468
|
+
MATCH (p:{parent_label} {{path: $parent_path}})
|
|
1469
|
+
MATCH (f:File {{path: $file_path}})
|
|
1470
|
+
MERGE (p)-[:CONTAINS]->(f)
|
|
1471
|
+
""", parent_path=parent_path, file_path=file_path_str)
|
{codegraphcontext-0.3.1 → codegraphcontext-0.3.2}/src/codegraphcontext/tools/package_resolver.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# src/codegraphcontext/tools/package_resolver.py
|
|
2
|
-
import importlib
|
|
2
|
+
import importlib.util
|
|
3
3
|
import stdlibs
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import subprocess
|
|
@@ -10,25 +10,27 @@ from ..utils.debug_log import debug_log
|
|
|
10
10
|
def _get_python_package_path(package_name: str) -> Optional[str]:
|
|
11
11
|
"""
|
|
12
12
|
Finds the local installation path of a Python package.
|
|
13
|
+
Uses importlib.util.find_spec() to locate the module without executing its code.
|
|
13
14
|
"""
|
|
14
15
|
try:
|
|
15
16
|
debug_log(f"Getting local path for Python package: {package_name}")
|
|
16
|
-
|
|
17
|
-
if
|
|
18
|
-
|
|
17
|
+
spec = importlib.util.find_spec(package_name)
|
|
18
|
+
if spec is None:
|
|
19
|
+
return None
|
|
20
|
+
if spec.origin and spec.origin != "frozen":
|
|
21
|
+
module_file = Path(spec.origin)
|
|
19
22
|
if module_file.name == '__init__.py':
|
|
20
23
|
return str(module_file.parent)
|
|
21
24
|
elif package_name in stdlibs.module_names:
|
|
22
25
|
return str(module_file)
|
|
23
26
|
else:
|
|
24
27
|
return str(module_file.parent)
|
|
25
|
-
elif
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return str(Path(str(module.__path__)))
|
|
28
|
+
elif spec.submodule_search_locations:
|
|
29
|
+
locations = list(spec.submodule_search_locations)
|
|
30
|
+
if locations:
|
|
31
|
+
return str(Path(locations[0]))
|
|
30
32
|
return None
|
|
31
|
-
except
|
|
33
|
+
except (ModuleNotFoundError, ValueError):
|
|
32
34
|
return None
|
|
33
35
|
except Exception as e:
|
|
34
36
|
debug_log(f"Error getting local path for {package_name}: {e}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegraphcontext
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: An MCP server that indexes local code into a graph database to provide context to AI assistants.
|
|
5
5
|
Author-email: Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -46,7 +46,6 @@ Requires-Dist: python-dotenv>=1.0.0
|
|
|
46
46
|
Requires-Dist: tree-sitter>=0.21.0
|
|
47
47
|
Requires-Dist: tree-sitter-language-pack>=0.6.0
|
|
48
48
|
Requires-Dist: pyyaml
|
|
49
|
-
Requires-Dist: pytest
|
|
50
49
|
Requires-Dist: nbformat
|
|
51
50
|
Requires-Dist: nbconvert>=7.16.6
|
|
52
51
|
Requires-Dist: pathspec>=0.12.1
|
|
@@ -70,6 +69,7 @@ Dynamic: license-file
|
|
|
70
69
|
🌐 **Languages:**
|
|
71
70
|
- 🇬🇧 [English](README.md)
|
|
72
71
|
- 🇨🇳 [中文](README.zh-CN.md)
|
|
72
|
+
- 🇰🇷 [한국어](README.kor.md)
|
|
73
73
|
- 🇯🇵 日本語 (Soon)
|
|
74
74
|
- 🇷🇺 Русский (Soon)
|
|
75
75
|
- 🇪🇸 Español (Soon)
|
|
@@ -160,7 +160,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
|
|
|
160
160
|
---
|
|
161
161
|
|
|
162
162
|
## Project Details
|
|
163
|
-
- **Version:** 0.3.
|
|
163
|
+
- **Version:** 0.3.2
|
|
164
164
|
- **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
165
165
|
- **License:** MIT License (See [LICENSE](LICENSE) for details)
|
|
166
166
|
- **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
|
|
@@ -365,7 +365,7 @@ cgc watch .
|
|
|
365
365
|
cgc help
|
|
366
366
|
```
|
|
367
367
|
|
|
368
|
-
**See the full [CLI Commands Guide](
|
|
368
|
+
**See the full [CLI Commands Guide](docs/CLI_COMPLETE_REFERENCE.md) for all available commands and usage scenarios.**
|
|
369
369
|
|
|
370
370
|
### 🎨 Premium Interactive Visualization
|
|
371
371
|
CodeGraphContext can generate stunning, interactive knowledge graphs of your code. Unlike static diagrams, these are premium web-based explorers:
|
|
@@ -81,16 +81,4 @@ src/codegraphcontext/tools/query_tool_languages/typescript_toolkit.py
|
|
|
81
81
|
src/codegraphcontext/utils/debug_log.py
|
|
82
82
|
src/codegraphcontext/utils/tree_sitter_manager.py
|
|
83
83
|
src/codegraphcontext/utils/visualize_graph.py
|
|
84
|
-
src/codegraphcontext/viz/server.py
|
|
85
|
-
src/codegraphcontext/viz/dist/favicon.ico
|
|
86
|
-
src/codegraphcontext/viz/dist/index.html
|
|
87
|
-
src/codegraphcontext/viz/dist/placeholder.svg
|
|
88
|
-
src/codegraphcontext/viz/dist/preview-image.png
|
|
89
|
-
src/codegraphcontext/viz/dist/robots.txt
|
|
90
|
-
src/codegraphcontext/viz/dist/tree-sitter.wasm
|
|
91
|
-
src/codegraphcontext/viz/dist/assets/function-calls-BtRHrqa2.png
|
|
92
|
-
src/codegraphcontext/viz/dist/assets/graph-total-D1fBAugo.png
|
|
93
|
-
src/codegraphcontext/viz/dist/assets/hero-graph-2voMJp2a.jpg
|
|
94
|
-
src/codegraphcontext/viz/dist/assets/hierarchy-DGADo0YT.png
|
|
95
|
-
src/codegraphcontext/viz/dist/assets/index-DDAcqlyl.css
|
|
96
|
-
src/codegraphcontext/viz/dist/assets/index-Do_-h1Gi.js
|
|
84
|
+
src/codegraphcontext/viz/server.py
|
|
Binary file
|
|
Binary file
|
|
Binary file
|