codegraphcontext 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.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.
@@ -1,9 +1,10 @@
1
1
  """Tree-sitter parser dispatch by language name."""
2
2
 
3
3
  from pathlib import Path
4
- from typing import Dict, Optional
4
+ from typing import TYPE_CHECKING, Dict
5
5
 
6
- from tree_sitter import Language, Parser
6
+ if TYPE_CHECKING:
7
+ from tree_sitter import Language
7
8
 
8
9
  from ..utils.tree_sitter_manager import get_tree_sitter_manager
9
10
 
@@ -15,8 +16,8 @@ class TreeSitterParser:
15
16
  self.language_name = language_name
16
17
  self.ts_manager = get_tree_sitter_manager()
17
18
 
18
- self.language: Language = self.ts_manager.get_language_safe(language_name)
19
- self.parser = Parser(self.language)
19
+ self.language: "Language" = self.ts_manager.get_language_safe(language_name)
20
+ self.parser = self.ts_manager.create_parser(language_name)
20
21
 
21
22
  self.language_specific_parser = None
22
23
  if self.language_name == "python":
@@ -11,11 +11,55 @@ Key design principles:
11
11
  4. Support optional tree-sitter dependency
12
12
  """
13
13
 
14
- from typing import Dict, Optional
14
+ from __future__ import annotations
15
+
16
+ from typing import TYPE_CHECKING, Any, Dict, Optional
15
17
  import threading
18
+ import sys
19
+
20
+ if TYPE_CHECKING:
21
+ from tree_sitter import Language, Parser
22
+
23
+ Language = Any
24
+ Parser = Any
25
+ _tree_sitter_import_error: Optional[ImportError] = None
26
+ _Language = None
27
+ _Parser = None
28
+ _get_language = None
29
+
30
+
31
+ def _missing_tree_sitter_error(import_error: ImportError) -> ImportError:
32
+ """Return an actionable error for optional tree-sitter dependencies."""
33
+ if sys.version_info >= (3, 13):
34
+ return ImportError(
35
+ "Tree-sitter parsing is not available on Python 3.13 because "
36
+ "tree-sitter-language-pack does not publish cp313 wheels. "
37
+ "Install CodeGraphContext with Python 3.12 or 3.14 to use indexing/parsing."
38
+ )
39
+ return ImportError(
40
+ "tree-sitter and tree-sitter-language-pack are required for code parsing. "
41
+ "Install them with: pip install codegraphcontext[parsing]"
42
+ )
43
+
16
44
 
17
- from tree_sitter import Language, Parser
18
- from tree_sitter_language_pack import get_language
45
+ def _load_tree_sitter_dependencies():
46
+ """Load optional tree-sitter dependencies only when parsing is used."""
47
+ global _tree_sitter_import_error, _Language, _Parser, _get_language
48
+
49
+ if _Language is not None and _Parser is not None and _get_language is not None:
50
+ return _Language, _Parser, _get_language
51
+
52
+ try:
53
+ from tree_sitter import Language as ImportedLanguage, Parser as ImportedParser
54
+ from tree_sitter_language_pack import get_language as imported_get_language
55
+ except ImportError as e:
56
+ _tree_sitter_import_error = e
57
+ raise _missing_tree_sitter_error(e) from e
58
+
59
+ _Language = ImportedLanguage
60
+ _Parser = ImportedParser
61
+ _get_language = imported_get_language
62
+ return _Language, _Parser, _get_language
19
63
 
20
64
 
21
65
  # Language name aliases for compatibility
@@ -122,6 +166,7 @@ class TreeSitterManager:
122
166
  """
123
167
  # Normalize the language name
124
168
  canonical_name = self._normalize_language_name(lang)
169
+ _, _, load_language = _load_tree_sitter_dependencies()
125
170
 
126
171
  # Check cache first (fast path, no lock needed for reads)
127
172
  if canonical_name in self._language_cache:
@@ -136,7 +181,7 @@ class TreeSitterManager:
136
181
  try:
137
182
  # Map canonical name to language-pack name where they differ
138
183
  pack_name = LANGUAGE_PACK_NAMES.get(canonical_name, canonical_name)
139
- language = get_language(pack_name)
184
+ language = load_language(pack_name)
140
185
 
141
186
  self._language_cache[canonical_name] = language
142
187
  return language
@@ -167,9 +212,10 @@ class TreeSitterManager:
167
212
  ValueError: If language is not supported
168
213
  Exception: If parser creation fails
169
214
  """
215
+ _, parser_cls, _ = _load_tree_sitter_dependencies()
170
216
  language = self.get_language_safe(lang)
171
217
  # In tree-sitter 0.25+, Parser takes language in constructor
172
- parser = Parser(language)
218
+ parser = parser_cls(language)
173
219
  return parser
174
220
 
175
221
  def is_language_available(self, lang: str) -> bool:
@@ -256,7 +302,10 @@ def execute_query(language: Language, query_string: str, node):
256
302
  >>> for node, name in captures:
257
303
  ... print(f'{name}: {node.type}')
258
304
  """
259
- from tree_sitter import Query, QueryCursor
305
+ try:
306
+ from tree_sitter import Query, QueryCursor
307
+ except ImportError as e:
308
+ raise _missing_tree_sitter_error(e) from e
260
309
 
261
310
  try:
262
311
  # Create query and cursor
@@ -282,4 +331,3 @@ def execute_query(language: Language, query_string: str, node):
282
331
  f"Failed to execute query: {e}\n"
283
332
  f"Query string: {query_string[:100]}..."
284
333
  )
285
-
@@ -81,13 +81,16 @@ async def get_graph(repo_path: Optional[str] = None, cypher_query: Optional[str]
81
81
  elif repo_path:
82
82
  repo_path = str(Path(repo_path).resolve())
83
83
  print(f"DEBUG: Fetching subgraph for: {repo_path}", flush=True)
84
+ # Get all nodes within the repository scope
84
85
  query = """
85
86
  MATCH (r:Repository {path: $repo_path})
86
87
  OPTIONAL MATCH (r)-[:CONTAINS*0..]->(n)
87
- WITH DISTINCT n
88
- WHERE n IS NOT NULL
89
- OPTIONAL MATCH (n)-[rel]->(m)
90
- RETURN n, rel, m
88
+ WITH DISTINCT r, COLLECT(DISTINCT n) as repo_nodes
89
+ UNWIND repo_nodes as node
90
+ OPTIONAL MATCH (node)-[rel]->(target)
91
+ WITH r, node, rel, target, repo_nodes
92
+ WHERE target IN repo_nodes OR target = r
93
+ RETURN node as n, rel, target as m
91
94
  """
92
95
  result = session.run(query, repo_path=repo_path)
93
96
  else:
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codegraphcontext
3
- Version: 0.4.2
3
+ Version: 0.4.4
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
7
7
 
8
- Copyright (c) 2025
8
+ Copyright (c) 2025-2026
9
9
 
10
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
11
  of this software and associated documentation files (the "Software"), to deal
@@ -39,13 +39,13 @@ License-File: LICENSE
39
39
  Requires-Dist: neo4j>=5.15.0
40
40
  Requires-Dist: watchdog>=3.0.0
41
41
  Requires-Dist: stdlibs>=2023.11.18
42
- Requires-Dist: typer[all]>=0.9.0
42
+ Requires-Dist: typer>=0.9.0
43
43
  Requires-Dist: rich>=13.7.0
44
44
  Requires-Dist: inquirerpy>=0.3.4
45
45
  Requires-Dist: python-dotenv>=1.0.0
46
- Requires-Dist: tree-sitter>=0.21.0
47
- Requires-Dist: tree-sitter-language-pack>=0.6.0
48
- Requires-Dist: tree-sitter-c-sharp>=0.21.0
46
+ Requires-Dist: tree-sitter>=0.21.0; python_version != "3.13"
47
+ Requires-Dist: tree-sitter-language-pack>=0.6.0; python_version != "3.13"
48
+ Requires-Dist: tree-sitter-c-sharp>=0.21.0; python_version != "3.13"
49
49
  Requires-Dist: pyyaml
50
50
  Requires-Dist: nbformat
51
51
  Requires-Dist: nbconvert>=7.16.6
@@ -57,9 +57,9 @@ Requires-Dist: kuzu>=0.4.0; sys_platform == "win32" or (sys_platform != "win32"
57
57
  Requires-Dist: fastapi>=0.100.0
58
58
  Requires-Dist: uvicorn>=0.22.0
59
59
  Provides-Extra: parsing
60
- Requires-Dist: tree-sitter>=0.21.0; extra == "parsing"
61
- Requires-Dist: tree-sitter-language-pack>=0.6.0; extra == "parsing"
62
- Requires-Dist: tree-sitter-c-sharp>=0.21.0; extra == "parsing"
60
+ Requires-Dist: tree-sitter>=0.21.0; python_version != "3.13" and extra == "parsing"
61
+ Requires-Dist: tree-sitter-language-pack>=0.6.0; python_version != "3.13" and extra == "parsing"
62
+ Requires-Dist: tree-sitter-c-sharp>=0.21.0; python_version != "3.13" and extra == "parsing"
63
63
  Provides-Extra: dev
64
64
  Requires-Dist: pytest>=7.4.0; extra == "dev"
65
65
  Requires-Dist: black>=23.11.0; extra == "dev"
@@ -165,7 +165,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
165
165
  ---
166
166
 
167
167
  ## Project Details
168
- - **Version:** 0.4.2
168
+ - **Version:** 0.4.4
169
169
  - **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
170
170
  - **License:** MIT License (See [LICENSE](LICENSE) for details)
171
171
  - **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
@@ -251,12 +251,12 @@ _If you’re using CodeGraphContext in your project, feel free to open a PR and
251
251
  - `neo4j>=5.15.0`
252
252
  - `watchdog>=3.0.0`
253
253
  - `stdlibs>=2023.11.18`
254
- - `typer[all]>=0.9.0`
254
+ - `typer>=0.9.0`
255
255
  - `rich>=13.7.0`
256
256
  - `inquirerpy>=0.3.7`
257
257
  - `python-dotenv>=1.0.0`
258
- - `tree-sitter>=0.21.0`
259
- - `tree-sitter-language-pack>=0.6.0`
258
+ - `tree-sitter>=0.21.0` (not installed on Python 3.13)
259
+ - `tree-sitter-language-pack>=0.6.0` (not installed on Python 3.13)
260
260
  - `pyyaml`
261
261
  - `pytest`
262
262
  - `nbformat`
@@ -30,7 +30,7 @@ codegraphcontext/tools/package_resolver.py,sha256=KtbdMReTezszjdsqYniL-Xb-QUsrAJ
30
30
  codegraphcontext/tools/scip_indexer.py,sha256=MdxesJ4GQBOwrE2q3SZjImkzh6BSPQeA1tYsR5Zerok,20021
31
31
  codegraphcontext/tools/scip_pb2.py,sha256=dwOMNKlu6VyLq5h8kTPZRDqxrwfVL8yw7I7ziokFG48,98229
32
32
  codegraphcontext/tools/system.py,sha256=goQOs1A9gvd7SvDPVZB6Jd0DRJKQmjEkn-uiTE40VNM,6046
33
- codegraphcontext/tools/tree_sitter_parser.py,sha256=3LW7ewMoU7X2hVKdqvSTBO2PvWv22ITKZWGJbQwqrtI,4456
33
+ codegraphcontext/tools/tree_sitter_parser.py,sha256=x8gDBCQze65r97DwlIovflg02wrY5SKm4nCVxxIja2E,4500
34
34
  codegraphcontext/tools/handlers/analysis_handlers.py,sha256=ZhwPNIm6aLBcaDORiMeLx0Mq7QWj4hS64Gozh5KTerY,4792
35
35
  codegraphcontext/tools/handlers/indexing_handlers.py,sha256=RfmJf57oAnVYca8lOBQz8vcjxkSQn7NbixSgGDHm59g,5273
36
36
  codegraphcontext/tools/handlers/management_handlers.py,sha256=_sWVum15qdoMBSx6si7-CRJCr3fmBW4p7npxEoAStcU,13806
@@ -87,9 +87,9 @@ codegraphcontext/tools/query_tool_languages/typescript_toolkit.py,sha256=3S4hpmO
87
87
  codegraphcontext/utils/debug_log.py,sha256=Qg7jwyeg7x2h3Ur_2S34bdMCkHdlk_ngHfPwa97A9vE,2836
88
88
  codegraphcontext/utils/path_ignore.py,sha256=WPIcDmyAi6eL9692rPBQrUZunn5gHRb57nzNRHSIq28,2124
89
89
  codegraphcontext/utils/repo_path.py,sha256=2ydwYV4aK04eGPKqjhKMPZFZv7sNJitjig4hcl8cssw,1079
90
- codegraphcontext/utils/tree_sitter_manager.py,sha256=n8z45gxiOH_W1cbwe9Z7mvbB5gjGjUGRvV78JjftG_M,8993
90
+ codegraphcontext/utils/tree_sitter_manager.py,sha256=OMegIfLi95l3zC-SkGoxYdFd2FidKfDA-hPRhoLONp8,10803
91
91
  codegraphcontext/utils/visualize_graph.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
- codegraphcontext/viz/server.py,sha256=LUK3aHPpapZATG9c9ZeTsx3624bzy0w4rocms--VbWc,13155
92
+ codegraphcontext/viz/server.py,sha256=UThvOdqlRT3aA5_lhS32FLQlAZu-U9mhPWCHnGmFSI0,13393
93
93
  codegraphcontext/viz/dist/favicon.ico,sha256=AjhUxD_Eslt5XuSVHIAZ494Fk__rb5GLXR8qm0elfP4,1870
94
94
  codegraphcontext/viz/dist/index.html,sha256=g97sbeOQEOHA75sDelnPBEuzLfcaKGdH9DAQ7hfE6PU,1879
95
95
  codegraphcontext/viz/dist/placeholder.svg,sha256=ZLrfeqvaC5YwuHAg_7YJXLhYzLz2azVcKqCLEGOVTTs,3253
@@ -124,9 +124,9 @@ codegraphcontext/viz/dist/wasm/tree-sitter-typescript.wasm,sha256=hRVATc7tOOHthq
124
124
  codegraphcontext/viz/dist/wasm/tree-sitter.wasm,sha256=CCeVuI_hXktkBD-DW01xYPv5XoAYVRIqzJUJI5te-RY,196763
125
125
  codegraphcontext/viz/dist/wasm/web-tree-sitter.js,sha256=DIaCNqRylrT_PBVw8g4ImeSnhP9uXNe_ycOlUiVGPko,153666
126
126
  codegraphcontext/viz/dist/wasm/web-tree-sitter.wasm,sha256=CCeVuI_hXktkBD-DW01xYPv5XoAYVRIqzJUJI5te-RY,196763
127
- codegraphcontext-0.4.2.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
128
- codegraphcontext-0.4.2.dist-info/METADATA,sha256=2lvZnJhWuYSikZZsvR7UoLO3v0oPZO29J-917UPht4M,22108
129
- codegraphcontext-0.4.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
130
- codegraphcontext-0.4.2.dist-info/entry_points.txt,sha256=LCxWCWMshdvYGoHBPuQZ8C-e4CiNSHCLXofrNSGHkoE,103
131
- codegraphcontext-0.4.2.dist-info/top_level.txt,sha256=CBgc6LAPZIO5FS0nSYYkylDifHsZTIqw3Gf5UwDxeGI,17
132
- codegraphcontext-0.4.2.dist-info/RECORD,,
127
+ codegraphcontext-0.4.4.dist-info/licenses/LICENSE,sha256=rh8M-bJpQYJnw2vtRVgt0t7piMZXh5QzaKeNEI0vqqA,1061
128
+ codegraphcontext-0.4.4.dist-info/METADATA,sha256=FDddbhcyfIBGfUlyBl9UHaQgdtotbA4sed_Jo_M59rM,22330
129
+ codegraphcontext-0.4.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
130
+ codegraphcontext-0.4.4.dist-info/entry_points.txt,sha256=LCxWCWMshdvYGoHBPuQZ8C-e4CiNSHCLXofrNSGHkoE,103
131
+ codegraphcontext-0.4.4.dist-info/top_level.txt,sha256=CBgc6LAPZIO5FS0nSYYkylDifHsZTIqw3Gf5UwDxeGI,17
132
+ codegraphcontext-0.4.4.dist-info/RECORD,,
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025
3
+ Copyright (c) 2025-2026
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal