codegraphcontext 0.3.9__tar.gz → 0.4.0__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.
Files changed (88) hide show
  1. {codegraphcontext-0.3.9/src/codegraphcontext.egg-info → codegraphcontext-0.4.0}/PKG-INFO +3 -3
  2. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/README.md +2 -2
  3. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/pyproject.toml +1 -1
  4. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/config_manager.py +1 -1
  5. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/main.py +19 -5
  6. codegraphcontext-0.4.0/src/codegraphcontext/core/cgcignore.py +118 -0
  7. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/graph_builder.py +20 -39
  8. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/viz/server.py +10 -0
  9. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0/src/codegraphcontext.egg-info}/PKG-INFO +3 -3
  10. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext.egg-info/SOURCES.txt +1 -0
  11. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/LICENSE +0 -0
  12. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/MANIFEST.in +0 -0
  13. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/setup.cfg +0 -0
  14. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/__init__.py +0 -0
  15. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/__main__.py +0 -0
  16. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/__init__.py +0 -0
  17. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/cli_helpers.py +0 -0
  18. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/registry_commands.py +0 -0
  19. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/setup_macos.py +0 -0
  20. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/setup_wizard.py +0 -0
  21. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/cli/visualizer.py +0 -0
  22. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/__init__.py +0 -0
  23. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/bundle_registry.py +0 -0
  24. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/cgc_bundle.py +0 -0
  25. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/database.py +0 -0
  26. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/database_falkordb.py +0 -0
  27. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/database_falkordb_remote.py +0 -0
  28. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/database_kuzu.py +0 -0
  29. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/falkor_worker.py +0 -0
  30. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/jobs.py +0 -0
  31. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/core/watcher.py +0 -0
  32. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/prompts.py +0 -0
  33. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/server.py +0 -0
  34. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tool_definitions.py +0 -0
  35. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/__init__.py +0 -0
  36. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/advanced_language_query_tool.py +0 -0
  37. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/code_finder.py +0 -0
  38. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/handlers/analysis_handlers.py +0 -0
  39. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/handlers/indexing_handlers.py +0 -0
  40. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/handlers/management_handlers.py +0 -0
  41. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/handlers/query_handlers.py +0 -0
  42. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/handlers/watcher_handlers.py +0 -0
  43. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/c.py +0 -0
  44. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/cpp.py +0 -0
  45. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/csharp.py +0 -0
  46. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/dart.py +0 -0
  47. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/elixir.py +0 -0
  48. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/go.py +0 -0
  49. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/haskell.py +0 -0
  50. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/java.py +0 -0
  51. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/javascript.py +0 -0
  52. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/kotlin.py +0 -0
  53. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/perl.py +0 -0
  54. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/php.py +0 -0
  55. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/python.py +0 -0
  56. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/ruby.py +0 -0
  57. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/rust.py +0 -0
  58. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/scala.py +0 -0
  59. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/swift.py +0 -0
  60. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/typescript.py +0 -0
  61. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/languages/typescriptjsx.py +0 -0
  62. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/package_resolver.py +0 -0
  63. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/c_toolkit.py +0 -0
  64. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/cpp_toolkit.py +0 -0
  65. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/csharp_toolkit.py +0 -0
  66. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/dart_toolkit.py +0 -0
  67. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/go_toolkit.py +0 -0
  68. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/haskell_toolkit.py +0 -0
  69. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/java_toolkit.py +0 -0
  70. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/javascript_toolkit.py +0 -0
  71. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/perl_toolkit.py +0 -0
  72. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/python_toolkit.py +0 -0
  73. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/ruby_toolkit.py +0 -0
  74. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/rust_toolkit.py +0 -0
  75. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/scala_toolkit.py +0 -0
  76. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/swift_toolkit.py +0 -0
  77. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/query_tool_languages/typescript_toolkit.py +0 -0
  78. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/scip_indexer.py +0 -0
  79. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/scip_pb2.py +0 -0
  80. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/tools/system.py +0 -0
  81. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/utils/debug_log.py +0 -0
  82. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/utils/path_ignore.py +0 -0
  83. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/utils/tree_sitter_manager.py +0 -0
  84. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext/utils/visualize_graph.py +0 -0
  85. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext.egg-info/dependency_links.txt +0 -0
  86. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext.egg-info/entry_points.txt +0 -0
  87. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/src/codegraphcontext.egg-info/requires.txt +0 -0
  88. {codegraphcontext-0.3.9 → codegraphcontext-0.4.0}/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.9
3
+ Version: 0.4.0
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
@@ -74,8 +74,8 @@ Dynamic: license-file
74
74
  - 🇨🇳 [中文](README.zh-CN.md)
75
75
  - 🇰🇷 [한국어](README.kor.md)
76
76
  - 🇺🇦 [Українська](README.uk.md)
77
+ - 🇷🇺 [Русский](README.ru-RU.md)
77
78
  - 🇯🇵 日本語 (Soon)
78
- - 🇷🇺 Русский (Soon)
79
79
  - 🇪🇸 Español (Soon)
80
80
 
81
81
  🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on https://github.com/Shashankss1205/CodeGraphContext/issues!**
@@ -164,7 +164,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
164
164
  ---
165
165
 
166
166
  ## Project Details
167
- - **Version:** 0.3.9
167
+ - **Version:** 0.4.0
168
168
  - **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
169
169
  - **License:** MIT License (See [LICENSE](LICENSE) for details)
170
170
  - **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
@@ -7,8 +7,8 @@
7
7
  - 🇨🇳 [中文](README.zh-CN.md)
8
8
  - 🇰🇷 [한국어](README.kor.md)
9
9
  - 🇺🇦 [Українська](README.uk.md)
10
+ - 🇷🇺 [Русский](README.ru-RU.md)
10
11
  - 🇯🇵 日本語 (Soon)
11
- - 🇷🇺 Русский (Soon)
12
12
  - 🇪🇸 Español (Soon)
13
13
 
14
14
  🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on https://github.com/Shashankss1205/CodeGraphContext/issues!**
@@ -97,7 +97,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
97
97
  ---
98
98
 
99
99
  ## Project Details
100
- - **Version:** 0.3.9
100
+ - **Version:** 0.4.0
101
101
  - **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
102
102
  - **License:** MIT License (See [LICENSE](LICENSE) for details)
103
103
  - **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codegraphcontext"
3
- version = "0.3.9"
3
+ version = "0.4.0"
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"
@@ -78,7 +78,7 @@ CONFIG_DESCRIPTIONS = {
78
78
 
79
79
  # Valid values for each config key
80
80
  CONFIG_VALIDATORS = {
81
- "DEFAULT_DATABASE": ["neo4j", "falkordb", "kuzudb"],
81
+ "DEFAULT_DATABASE": ["neo4j", "falkordb", "falkordb-remote", "kuzudb"],
82
82
  "INDEX_VARIABLES": ["true", "false"],
83
83
  "ALLOW_DB_DELETION": ["true", "false"],
84
84
  "DEBUG_LOGS": ["true", "false"],
@@ -474,7 +474,7 @@ def config_reset():
474
474
  console.print("[yellow]Reset cancelled[/yellow]")
475
475
 
476
476
  @config_app.command("db")
477
- def config_db(backend: str = typer.Argument(..., help="Database backend: 'neo4j' or 'falkordb'")):
477
+ def config_db(backend: str = typer.Argument(..., help="Database backend: 'neo4j', 'falkordb', 'falkordb-remote', or 'kuzudb'")):
478
478
  """
479
479
  Quickly switch the default database backend.
480
480
 
@@ -483,14 +483,19 @@ def config_db(backend: str = typer.Argument(..., help="Database backend: 'neo4j'
483
483
  Examples:
484
484
  cgc config db neo4j
485
485
  cgc config db falkordb
486
+ cgc config db kuzudb
486
487
  """
487
488
  backend = backend.lower()
488
- if backend not in ['falkordb', 'falkordb-remote', 'neo4j']:
489
+ if backend not in ['falkordb', 'falkordb-remote', 'neo4j', 'kuzudb']:
489
490
  console.print(f"[bold red]Invalid backend: {backend}[/bold red]")
490
- console.print("Must be 'falkordb', 'falkordb-remote', or 'neo4j'")
491
+ console.print("Must be 'falkordb', 'falkordb-remote', 'neo4j', or 'kuzudb'")
491
492
  raise typer.Exit(code=1)
492
493
 
493
- config_manager.set_config_value("DEFAULT_DATABASE", backend)
494
+ updated = config_manager.set_config_value("DEFAULT_DATABASE", backend)
495
+ if not updated:
496
+ console.print(f"[bold red]Failed to switch default database to {backend}[/bold red]")
497
+ raise typer.Exit(code=1)
498
+
494
499
  console.print(f"[green]✔ Default database switched to {backend}[/green]")
495
500
 
496
501
  # ============================================================================
@@ -851,6 +856,15 @@ def doctor():
851
856
  all_checks_passed = False
852
857
  else:
853
858
  console.print(f" [yellow]⚠[/yellow] Neo4j credentials not set. Run 'cgc neo4j setup'")
859
+ elif default_db == "kuzudb":
860
+ from importlib.util import find_spec
861
+
862
+ if find_spec("kuzu") is not None:
863
+ console.print(f" [green]✓[/green] KuzuDB is installed")
864
+ else:
865
+ console.print(f" [red]✗[/red] KuzuDB is not installed")
866
+ console.print(f" Run: pip install kuzu")
867
+ all_checks_passed = False
854
868
  else:
855
869
  # FalkorDB
856
870
  try:
@@ -2313,7 +2327,7 @@ def main(
2313
2327
  None,
2314
2328
  "--database",
2315
2329
  "-db",
2316
- help="[Global] Temporarily override database backend (falkordb or neo4j) for any command"
2330
+ help="[Global] Temporarily override database backend (falkordb, falkordb-remote, neo4j, or kuzudb) for any command"
2317
2331
  ),
2318
2332
  visual: bool = typer.Option(
2319
2333
  False,
@@ -0,0 +1,118 @@
1
+ from pathlib import Path
2
+ from typing import Iterable, Optional, Tuple
3
+ from pathspec import PathSpec
4
+
5
+
6
+ def _resolve_explicit_path(ignore_root: Path, explicit_path: Optional[str]) -> Optional[Path]:
7
+ """Resolve an explicit .cgcignore path relative to *ignore_root*."""
8
+ if not explicit_path:
9
+ return None
10
+
11
+ candidate = Path(explicit_path)
12
+ if not candidate.is_absolute():
13
+ candidate = (ignore_root / candidate).resolve()
14
+ return candidate
15
+
16
+ def parse_cgcignore_lines(lines: Iterable[str]) -> list[str]:
17
+ """Return valid ignore patterns from raw .cgcignore lines.
18
+
19
+ Valid patterns are non-empty lines that do not start with '#'.
20
+ """
21
+ patterns: list[str] = []
22
+ for raw_line in lines:
23
+ line = raw_line.strip()
24
+ if not line or line.startswith("#"):
25
+ continue
26
+ patterns.append(line)
27
+ return patterns
28
+
29
+
30
+ def find_cgcignore(ignore_root: Path, explicit_path: Optional[str] = None) -> Optional[Path]:
31
+ """Find a repository-local .cgcignore, with explicit path fallback."""
32
+
33
+ # Search parent folders only within the current git worktree. If the
34
+ # indexed path is outside a git repo (e.g. /tmp test dirs), avoid crawling
35
+ # up to filesystem-wide locations like /tmp/.cgcignore.
36
+ git_root: Optional[Path] = None
37
+ probe = ignore_root
38
+ while True:
39
+ if (probe / ".git").exists():
40
+ git_root = probe
41
+ break
42
+ if probe.parent == probe:
43
+ break
44
+ probe = probe.parent
45
+
46
+ curr = ignore_root
47
+ while True:
48
+ candidate = curr / ".cgcignore"
49
+ if candidate.exists():
50
+ return candidate
51
+
52
+ if git_root is None:
53
+ return None
54
+
55
+ if curr == git_root:
56
+ break
57
+
58
+ curr = curr.parent
59
+
60
+ explicit_candidate = _resolve_explicit_path(ignore_root, explicit_path)
61
+ if explicit_candidate and explicit_candidate.exists():
62
+ return explicit_candidate
63
+ return None
64
+
65
+ def ensure_default_cgcignore(path: Path, default_patterns: list[str]) -> None:
66
+ """Create a .cgcignore file with default patterns when it does not exist."""
67
+ path.parent.mkdir(parents=True, exist_ok=True)
68
+ content = "# Auto-generated by CodeGraphContext\n"
69
+ content += "# Default ignore patterns for binary/media files\n"
70
+ content += "# Add your own patterns below\n\n"
71
+ content += "\n".join(default_patterns) + "\n"
72
+ path.write_text(content, encoding="utf-8")
73
+
74
+
75
+ def read_cgcignore_patterns(path: Path, default_patterns: list[str]) -> list[str]:
76
+ """Read .cgcignore patterns and merge them with defaults.
77
+
78
+ Empty lines and comment lines are ignored.
79
+ """
80
+ if not path.exists():
81
+ return list(default_patterns)
82
+
83
+ user_patterns = parse_cgcignore_lines(path.read_text(encoding="utf-8").splitlines())
84
+ # User patterns first so explicit repo rules take precedence.
85
+ return user_patterns + list(default_patterns)
86
+
87
+ def build_ignore_spec(
88
+ ignore_root: Path,
89
+ default_patterns: list[str],
90
+ explicit_path: Optional[str] = None,
91
+ ) -> Tuple[PathSpec, Optional[Path]]:
92
+ """Build PathSpec using merged default + user .cgcignore patterns.
93
+
94
+ Returns the compiled spec and the discovered/created .cgcignore path.
95
+ """
96
+ local_cgcignore_path = find_cgcignore(ignore_root, explicit_path=None)
97
+ explicit_cgcignore_path = _resolve_explicit_path(ignore_root, explicit_path)
98
+
99
+ if local_cgcignore_path is None:
100
+ local_cgcignore_path = ignore_root / ".cgcignore"
101
+ ensure_default_cgcignore(local_cgcignore_path, default_patterns)
102
+
103
+ merged_user_patterns: list[str] = []
104
+ merged_user_patterns.extend(
105
+ parse_cgcignore_lines(local_cgcignore_path.read_text(encoding="utf-8").splitlines())
106
+ )
107
+
108
+ if (
109
+ explicit_cgcignore_path
110
+ and explicit_cgcignore_path.exists()
111
+ and explicit_cgcignore_path != local_cgcignore_path
112
+ ):
113
+ merged_user_patterns.extend(
114
+ parse_cgcignore_lines(explicit_cgcignore_path.read_text(encoding="utf-8").splitlines())
115
+ )
116
+
117
+ all_patterns = merged_user_patterns + list(default_patterns)
118
+ return PathSpec.from_lines("gitwildmatch", all_patterns), local_cgcignore_path
@@ -1,12 +1,12 @@
1
1
 
2
2
  # src/codegraphcontext/tools/graph_builder.py
3
3
  import asyncio
4
- import pathspec
5
4
  from pathlib import Path
6
5
  from typing import Any, Coroutine, Dict, Optional, Tuple
7
6
  from datetime import datetime
8
7
 
9
8
  from ..core.database import DatabaseManager
9
+ from ..core.cgcignore import build_ignore_spec
10
10
  from ..core.jobs import JobManager, JobStatus
11
11
  from ..utils.debug_log import debug_log, info_logger, error_logger, warning_logger
12
12
 
@@ -1512,44 +1512,25 @@ class GraphBuilder:
1512
1512
  self.add_repository_to_graph(path, is_dependency)
1513
1513
  repo_name = path.name
1514
1514
 
1515
- resolved_cgcignore = None
1515
+ # ignore_root is always the indexed path itself so that file paths
1516
+ # are matched relative to the project being indexed. A parent
1517
+ # .cgcignore is still loaded (for monorepo support), but anchoring
1518
+ # to its directory would make patterns like "website/" incorrectly
1519
+ # filter out every file when indexing the website sub-directory.
1516
1520
  ignore_root = path.resolve() if path.is_dir() else path.resolve().parent
1517
1521
 
1518
- if cgcignore_path:
1519
- resolved_cgcignore = Path(cgcignore_path)
1520
- # If a specific cgcignore path was given but it doesn't exist yet, we will auto-create it there
1521
- else:
1522
- # Search for .cgcignore upwards in the project
1523
- curr = ignore_root
1524
- while True:
1525
- candidate = curr / ".cgcignore"
1526
- if candidate.exists():
1527
- resolved_cgcignore = candidate
1528
- debug_log(f"Found .cgcignore at {curr} (filtering relative to {ignore_root})")
1529
- break
1530
- if curr.parent == curr: # Root hit
1531
- break
1532
- curr = curr.parent
1533
-
1534
1522
  spec = None
1535
- if resolved_cgcignore and resolved_cgcignore.exists():
1536
- with open(resolved_cgcignore) as f:
1537
- user_patterns = [line.strip() for line in f.read().splitlines() if line.strip() and not line.strip().startswith('#')]
1538
- ignore_patterns = DEFAULT_IGNORE_PATTERNS + user_patterns
1539
- spec = pathspec.PathSpec.from_lines('gitwildmatch', ignore_patterns)
1540
- else:
1541
- # No .cgcignore found — create one in the designated path or project root with default patterns
1542
- new_cgcignore = resolved_cgcignore if resolved_cgcignore else (ignore_root / ".cgcignore")
1543
- try:
1544
- cgcignore_content = "# Auto-generated by CodeGraphContext\n"
1545
- cgcignore_content += "# Default ignore patterns for binary/media files\n"
1546
- cgcignore_content += "# Add your own patterns below\n\n"
1547
- cgcignore_content += "\n".join(DEFAULT_IGNORE_PATTERNS) + "\n"
1548
- new_cgcignore.write_text(cgcignore_content)
1549
- info_logger(f"Created default .cgcignore at {new_cgcignore}")
1550
- except OSError as e:
1551
- warning_logger(f"Could not create .cgcignore at {new_cgcignore}: {e}")
1552
- spec = pathspec.PathSpec.from_lines('gitwildmatch', DEFAULT_IGNORE_PATTERNS)
1523
+ resolved_cgcignore = None
1524
+ try:
1525
+ spec, resolved_cgcignore = build_ignore_spec(
1526
+ ignore_root=ignore_root,
1527
+ default_patterns=DEFAULT_IGNORE_PATTERNS,
1528
+ explicit_path=cgcignore_path,
1529
+ )
1530
+ if resolved_cgcignore:
1531
+ debug_log(f"Using .cgcignore at {resolved_cgcignore} (filtering relative to {ignore_root})")
1532
+ except OSError as e:
1533
+ warning_logger(f"Could not load/create .cgcignore: {e}")
1553
1534
 
1554
1535
  supported_extensions = self.parsers.keys()
1555
1536
  all_files = path.rglob("*") if path.is_dir() else [path]
@@ -1582,9 +1563,9 @@ class GraphBuilder:
1582
1563
  filtered_files = []
1583
1564
  for f in files:
1584
1565
  try:
1585
- # Match relative to the directory containing .cgcignore
1586
- rel_path = f.relative_to(ignore_root)
1587
- if not spec.match_file(str(rel_path)):
1566
+ # Match relative to the indexed project path.
1567
+ rel_path = f.relative_to(ignore_root).as_posix()
1568
+ if not spec.match_file(rel_path):
1588
1569
  filtered_files.append(f)
1589
1570
  else:
1590
1571
  debug_log(f"Ignored file based on .cgcignore: {rel_path}")
@@ -216,10 +216,20 @@ async def get_graph(repo_path: Optional[str] = None, cypher_query: Optional[str]
216
216
  file_paths.append(str(n["file"]))
217
217
  file_paths = sorted(list(set(file_paths)))
218
218
 
219
+ # Read file contents so the frontend never needs a separate API call
220
+ file_contents: dict[str, str] = {}
221
+ for fp in file_paths:
222
+ try:
223
+ with open(fp, "r", encoding="utf-8", errors="replace") as f:
224
+ file_contents[fp] = f.read()
225
+ except Exception:
226
+ pass
227
+
219
228
  response_data = {
220
229
  "nodes": list(nodes_dict.values()),
221
230
  "links": edges,
222
231
  "files": file_paths,
232
+ "fileContents": file_contents,
223
233
  }
224
234
 
225
235
  print(f"API SUCCESS: Returning graph with {len(response_data['nodes'])} nodes and {len(response_data['links'])} links.", file=sys.stderr, flush=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codegraphcontext
3
- Version: 0.3.9
3
+ Version: 0.4.0
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
@@ -74,8 +74,8 @@ Dynamic: license-file
74
74
  - 🇨🇳 [中文](README.zh-CN.md)
75
75
  - 🇰🇷 [한국어](README.kor.md)
76
76
  - 🇺🇦 [Українська](README.uk.md)
77
+ - 🇷🇺 [Русский](README.ru-RU.md)
77
78
  - 🇯🇵 日本語 (Soon)
78
- - 🇷🇺 Русский (Soon)
79
79
  - 🇪🇸 Español (Soon)
80
80
 
81
81
  🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on https://github.com/Shashankss1205/CodeGraphContext/issues!**
@@ -164,7 +164,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
164
164
  ---
165
165
 
166
166
  ## Project Details
167
- - **Version:** 0.3.9
167
+ - **Version:** 0.4.0
168
168
  - **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
169
169
  - **License:** MIT License (See [LICENSE](LICENSE) for details)
170
170
  - **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
@@ -24,6 +24,7 @@ src/codegraphcontext/cli/visualizer.py
24
24
  src/codegraphcontext/core/__init__.py
25
25
  src/codegraphcontext/core/bundle_registry.py
26
26
  src/codegraphcontext/core/cgc_bundle.py
27
+ src/codegraphcontext/core/cgcignore.py
27
28
  src/codegraphcontext/core/database.py
28
29
  src/codegraphcontext/core/database_falkordb.py
29
30
  src/codegraphcontext/core/database_falkordb_remote.py