codegraphcontext 0.4.17__tar.gz → 0.5.1__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 (179) hide show
  1. {codegraphcontext-0.4.17/src/codegraphcontext.egg-info → codegraphcontext-0.5.1}/PKG-INFO +15 -9
  2. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/README.md +8 -8
  3. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/pyproject.toml +10 -1
  4. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/api/app.py +9 -1
  5. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/api/mcp_sse.py +10 -5
  6. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/api/router.py +3 -6
  7. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/cli_helpers.py +82 -12
  8. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/config_manager.py +83 -39
  9. codegraphcontext-0.5.1/src/codegraphcontext/cli/hook_manager.py +220 -0
  10. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/main.py +212 -45
  11. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/registry_commands.py +11 -4
  12. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/setup_macos.py +6 -1
  13. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/setup_wizard.py +96 -10
  14. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/visualizer.py +25 -1
  15. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/__init__.py +71 -10
  16. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/cgc_bundle.py +14 -4
  17. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/database_falkordb.py +41 -2
  18. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/database_kuzu.py +103 -53
  19. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/database_ladybug.py +55 -23
  20. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/jobs.py +7 -2
  21. codegraphcontext-0.5.1/src/codegraphcontext/core/watcher.py +325 -0
  22. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/prompts.py +1 -1
  23. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/server.py +54 -5
  24. codegraphcontext-0.5.1/src/codegraphcontext/stdlibs.py +18 -0
  25. codegraphcontext-0.5.1/src/codegraphcontext/tool_definitions.py +389 -0
  26. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/code_finder.py +18 -1
  27. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/graph_builder.py +297 -185
  28. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/handlers/analysis_handlers.py +5 -0
  29. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/handlers/indexing_handlers.py +4 -1
  30. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/handlers/management_handlers.py +12 -9
  31. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/handlers/query_handlers.py +21 -3
  32. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/handlers/watcher_handlers.py +9 -4
  33. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/discovery.py +1 -2
  34. codegraphcontext-0.5.1/src/codegraphcontext/tools/indexing/persistence/utils.py +46 -0
  35. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/persistence/writer.py +630 -129
  36. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/pipeline.py +49 -14
  37. codegraphcontext-0.5.1/src/codegraphcontext/tools/indexing/resolution/__init__.py +19 -0
  38. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/resolution/calls.py +506 -63
  39. codegraphcontext-0.5.1/src/codegraphcontext/tools/indexing/resolution/inheritance.py +547 -0
  40. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/resolution/post_resolution.py +56 -19
  41. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/schema.py +5 -0
  42. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/schema_contract.py +7 -0
  43. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/scip_pipeline.py +38 -3
  44. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/c.py +154 -2
  45. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/cpp.py +13 -1
  46. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/csharp.py +1 -0
  47. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/css.py +13 -4
  48. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/dart.py +170 -41
  49. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/elixir.py +9 -6
  50. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/go.py +56 -16
  51. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/haskell.py +80 -8
  52. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/html.py +23 -8
  53. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/javascript.py +2 -2
  54. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/lua.py +61 -19
  55. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/perl.py +37 -4
  56. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/php.py +56 -4
  57. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/python.py +21 -14
  58. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/rust.py +70 -6
  59. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/swift.py +61 -11
  60. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/typescript.py +63 -6
  61. codegraphcontext-0.5.1/src/codegraphcontext/tools/package_resolver.py +267 -0
  62. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/report_generator.py +11 -11
  63. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/system.py +8 -1
  64. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/path_sandbox.py +2 -1
  65. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1/src/codegraphcontext.egg-info}/PKG-INFO +15 -9
  66. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext.egg-info/SOURCES.txt +3 -0
  67. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext.egg-info/requires.txt +7 -0
  68. codegraphcontext-0.4.17/src/codegraphcontext/core/watcher.py +0 -425
  69. codegraphcontext-0.4.17/src/codegraphcontext/tool_definitions.py +0 -280
  70. codegraphcontext-0.4.17/src/codegraphcontext/tools/indexing/resolution/__init__.py +0 -9
  71. codegraphcontext-0.4.17/src/codegraphcontext/tools/indexing/resolution/inheritance.py +0 -111
  72. codegraphcontext-0.4.17/src/codegraphcontext/tools/package_resolver.py +0 -472
  73. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/LICENSE +0 -0
  74. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/MANIFEST.in +0 -0
  75. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/setup.cfg +0 -0
  76. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/__init__.py +0 -0
  77. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/__main__.py +0 -0
  78. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/api/__init__.py +0 -0
  79. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/api/schemas.py +0 -0
  80. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/cli/__init__.py +0 -0
  81. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/bundle_registry.py +0 -0
  82. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/cgcignore.py +0 -0
  83. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/database.py +0 -0
  84. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/database_falkordb_remote.py +0 -0
  85. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/database_nornic.py +0 -0
  86. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/core/falkor_worker.py +0 -0
  87. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/__init__.py +0 -0
  88. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/advanced_language_query_tool.py +0 -0
  89. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/datasources/__init__.py +0 -0
  90. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/datasources/cassandra_ingester.py +0 -0
  91. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/datasources/mysql_ingester.py +0 -0
  92. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/datasources/redis_ingester.py +0 -0
  93. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/__init__.py +0 -0
  94. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/constants.py +0 -0
  95. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/embeddings.py +0 -0
  96. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/persistence/__init__.py +0 -0
  97. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/pre_scan.py +0 -0
  98. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/sanitize.py +0 -0
  99. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/indexing/vector_resolver.py +0 -0
  100. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/elisp.py +0 -0
  101. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/gradle.py +0 -0
  102. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/java.py +0 -0
  103. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/kotlin.py +0 -0
  104. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/maven.py +0 -0
  105. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/mybatis.py +0 -0
  106. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/ruby.py +0 -0
  107. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/scala.py +0 -0
  108. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/languages/typescriptjsx.py +0 -0
  109. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/c_toolkit.py +0 -0
  110. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/cpp_toolkit.py +0 -0
  111. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/csharp_toolkit.py +0 -0
  112. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/dart_toolkit.py +0 -0
  113. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/elisp_toolkit.py +0 -0
  114. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/go_toolkit.py +0 -0
  115. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/haskell_toolkit.py +0 -0
  116. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/java_toolkit.py +0 -0
  117. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/javascript_toolkit.py +0 -0
  118. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/perl_toolkit.py +0 -0
  119. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/python_toolkit.py +0 -0
  120. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/ruby_toolkit.py +0 -0
  121. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/rust_toolkit.py +0 -0
  122. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/scala_toolkit.py +0 -0
  123. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/swift_toolkit.py +0 -0
  124. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/query_tool_languages/typescript_toolkit.py +0 -0
  125. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/scip_indexer.py +0 -0
  126. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/scip_pb2.py +0 -0
  127. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/tree_sitter_parser.py +0 -0
  128. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/tools/type_utils.py +0 -0
  129. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/cypher_readonly.py +0 -0
  130. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/debug_log.py +0 -0
  131. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/git_utils.py +0 -0
  132. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/path_ignore.py +0 -0
  133. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/repo_path.py +0 -0
  134. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/tool_limits.py +0 -0
  135. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/tree_sitter_manager.py +0 -0
  136. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/utils/visualize_graph.py +0 -0
  137. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/__vite-browser-external-9wXp6ZBx.js +0 -0
  138. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/function-calls-BtRHrqa2.png +0 -0
  139. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/graph-total-D1fBAugo.png +0 -0
  140. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/hero-graph-2voMJp2a.jpg +0 -0
  141. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/hierarchy-DGADo0YT.png +0 -0
  142. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/index-C-187lf0.js +0 -0
  143. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/index-fNAa6jgv.css +0 -0
  144. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/parser-pyodide.worker-BgsDfaad.js +0 -0
  145. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/parser.worker-_nvrecvj.js +0 -0
  146. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/assets/tree-sitter-qKYAACSa.wasm +0 -0
  147. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/cgcIcon.png +0 -0
  148. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/favicon.ico +0 -0
  149. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/index.html +0 -0
  150. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/logo-icon.svg +0 -0
  151. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/logo.svg +0 -0
  152. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/placeholder.svg +0 -0
  153. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/preview-image.png +0 -0
  154. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/robots.txt +0 -0
  155. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-c.wasm +0 -0
  156. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-c_sharp.wasm +0 -0
  157. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-core.js +0 -0
  158. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-cpp.wasm +0 -0
  159. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-dart.wasm +0 -0
  160. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-go.wasm +0 -0
  161. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-java.wasm +0 -0
  162. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-javascript.wasm +0 -0
  163. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-kotlin.wasm +0 -0
  164. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-perl.wasm +0 -0
  165. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-php.wasm +0 -0
  166. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-python.wasm +0 -0
  167. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-ruby.wasm +0 -0
  168. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-rust.wasm +0 -0
  169. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-swift.wasm +0 -0
  170. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-tsx.wasm +0 -0
  171. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter-typescript.wasm +0 -0
  172. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/tree-sitter.wasm +0 -0
  173. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/web-tree-sitter.js +0 -0
  174. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/dist/wasm/web-tree-sitter.wasm +0 -0
  175. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext/viz/server.py +0 -0
  176. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext.egg-info/dependency_links.txt +0 -0
  177. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext.egg-info/entry_points.txt +0 -0
  178. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/src/codegraphcontext.egg-info/top_level.txt +0 -0
  179. {codegraphcontext-0.4.17 → codegraphcontext-0.5.1}/tests/test_issue_806_fix.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codegraphcontext
3
- Version: 0.4.17
3
+ Version: 0.5.1
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
@@ -81,6 +81,12 @@ Provides-Extra: dev
81
81
  Requires-Dist: pytest>=7.4.0; extra == "dev"
82
82
  Requires-Dist: black>=23.11.0; extra == "dev"
83
83
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
84
+ Requires-Dist: pytest-mock; extra == "dev"
85
+ Requires-Dist: ruff; extra == "dev"
86
+ Provides-Extra: datasources
87
+ Requires-Dist: pymysql; extra == "datasources"
88
+ Requires-Dist: mysql-connector-python; extra == "datasources"
89
+ Requires-Dist: cassandra-driver; extra == "datasources"
84
90
  Dynamic: license-file
85
91
 
86
92
  # 🏗️ CodeGraphContext (CGC)
@@ -96,7 +102,7 @@ Dynamic: license-file
96
102
  - 🇯🇵 [日本語](docs/translations/README.ja.md)
97
103
  - 🇪🇸 Español (Soon)
98
104
 
99
- 🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on https://github.com/Shashankss1205/CodeGraphContext/issues!**
105
+ 🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on [GitHub Issues](https://github.com/Shashankss1205/CodeGraphContext/issues)!**
100
106
 
101
107
  <p align="center">
102
108
  <br>
@@ -185,7 +191,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
185
191
  ---
186
192
 
187
193
  ## Project Details
188
- - **Version:** 0.4.17
194
+ - **Version:** 0.5.1
189
195
  - **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
190
196
  - **License:** MIT License (See [LICENSE](LICENSE) for details)
191
197
  - **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
@@ -213,11 +219,11 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
213
219
  ## Features
214
220
  - **Code Indexing:** Analyzes code and builds a knowledge graph of its components.
215
221
  - **Relationship Analysis:** Query for callers, callees, class hierarchies, call chains and more.
216
- - **Pre-indexed Bundles:** Load famous repositories instantly with `.cgc` bundles - no indexing required! ([Learn more](docs/BUNDLES.md))
217
- - **Live File Watching:** Watch directories for changes and automatically update the graph in real-time (`codegraphcontext watch`).
222
+ - **Pre-indexed Bundles:** Load famous repositories instantly with `.cgc` bundles - no indexing required! ([Learn more](docs/docs/guides/bundles.md))
223
+ - **Live File Watching:** Watch directories for changes and automatically update the graph in real-time (`cgc watch`).
218
224
  - **Interactive Setup:** A user-friendly command-line wizard for easy setup.
219
225
  - **Dual Mode:** Works as a standalone **CLI toolkit** for developers and as an **MCP server** for AI agents.
220
- - **Multi-Language Support:** Full support for 22 programming languages.
226
+ - **Multi-Language Support:** Full support for 23 programming languages.
221
227
  - **Flexible Database Backend:** FalkorDB Lite (Default), KuzuDB, LadybugDB, FalkorDB Remote, Nornic DB, or Neo4j (all platforms via Docker/native).
222
228
 
223
229
 
@@ -248,7 +254,7 @@ CodeGraphContext supports multiple graph database backends to suit your environm
248
254
 
249
255
  | Feature | KuzuDB | LadybugDB | FalkorDB Lite | Neo4j / Nornic DB |
250
256
  | :--- | :--- | :--- | :--- | :--- |
251
- | **Typical default** | **Standard Default** (embedded, powered by KuzuDB) | **Specialized Embedded** (similar to Kuzu) | **Unix** (Python 3.12+, when `falkordblite` works) | When explicitly configured |
257
+ | **Typical default** | Cross-platform fallback when FalkorDB Lite is unavailable | Optional embedded backend | **Default on Unix** (Python 3.12+, when `falkordblite` is installed) | When explicitly configured via `cgc config db` |
252
258
  | **Setup** | Zero-config / Embedded | Zero-config / Embedded | Zero-config / In-process | Docker / External |
253
259
  | **Platform** | **All (Windows Native, macOS, Linux)** | **All (Windows Native, macOS, Linux)** | Unix-only (Linux/macOS/WSL) | All Platforms |
254
260
  | **Use Case** | Desktop, IDE, Local development | Custom research projects | Specialized Unix development | Enterprise, Massive graphs |
@@ -295,8 +301,8 @@ _If you’re using CodeGraphContext in your project, feel free to open a PR and
295
301
  - `tree-sitter-language-pack>=0.6.0` (not installed on Python 3.13)
296
302
  - `pyyaml`
297
303
  - `pathspec>=0.12.1`
298
- - `falkordb>=0.1.0`
299
- - `falkordblite>=0.1.0` (Unix only)
304
+ - `falkordb>=1.0,<1.6`
305
+ - `falkordblite>=0.7,<0.10` (Unix only, Python 3.12+)
300
306
  - `kuzu` (KuzuDB engine)
301
307
  - `fastapi>=0.100.0`
302
308
  - `uvicorn>=0.22.0`
@@ -11,7 +11,7 @@
11
11
  - 🇯🇵 [日本語](docs/translations/README.ja.md)
12
12
  - 🇪🇸 Español (Soon)
13
13
 
14
- 🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on https://github.com/Shashankss1205/CodeGraphContext/issues!**
14
+ 🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on [GitHub Issues](https://github.com/Shashankss1205/CodeGraphContext/issues)!**
15
15
 
16
16
  <p align="center">
17
17
  <br>
@@ -100,7 +100,7 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
100
100
  ---
101
101
 
102
102
  ## Project Details
103
- - **Version:** 0.4.17
103
+ - **Version:** 0.5.1
104
104
  - **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
105
105
  - **License:** MIT License (See [LICENSE](LICENSE) for details)
106
106
  - **Website:** [CodeGraphContext](http://codegraphcontext.vercel.app/)
@@ -128,11 +128,11 @@ A powerful **MCP server** and **CLI toolkit** that indexes local code into a gra
128
128
  ## Features
129
129
  - **Code Indexing:** Analyzes code and builds a knowledge graph of its components.
130
130
  - **Relationship Analysis:** Query for callers, callees, class hierarchies, call chains and more.
131
- - **Pre-indexed Bundles:** Load famous repositories instantly with `.cgc` bundles - no indexing required! ([Learn more](docs/BUNDLES.md))
132
- - **Live File Watching:** Watch directories for changes and automatically update the graph in real-time (`codegraphcontext watch`).
131
+ - **Pre-indexed Bundles:** Load famous repositories instantly with `.cgc` bundles - no indexing required! ([Learn more](docs/docs/guides/bundles.md))
132
+ - **Live File Watching:** Watch directories for changes and automatically update the graph in real-time (`cgc watch`).
133
133
  - **Interactive Setup:** A user-friendly command-line wizard for easy setup.
134
134
  - **Dual Mode:** Works as a standalone **CLI toolkit** for developers and as an **MCP server** for AI agents.
135
- - **Multi-Language Support:** Full support for 22 programming languages.
135
+ - **Multi-Language Support:** Full support for 23 programming languages.
136
136
  - **Flexible Database Backend:** FalkorDB Lite (Default), KuzuDB, LadybugDB, FalkorDB Remote, Nornic DB, or Neo4j (all platforms via Docker/native).
137
137
 
138
138
 
@@ -163,7 +163,7 @@ CodeGraphContext supports multiple graph database backends to suit your environm
163
163
 
164
164
  | Feature | KuzuDB | LadybugDB | FalkorDB Lite | Neo4j / Nornic DB |
165
165
  | :--- | :--- | :--- | :--- | :--- |
166
- | **Typical default** | **Standard Default** (embedded, powered by KuzuDB) | **Specialized Embedded** (similar to Kuzu) | **Unix** (Python 3.12+, when `falkordblite` works) | When explicitly configured |
166
+ | **Typical default** | Cross-platform fallback when FalkorDB Lite is unavailable | Optional embedded backend | **Default on Unix** (Python 3.12+, when `falkordblite` is installed) | When explicitly configured via `cgc config db` |
167
167
  | **Setup** | Zero-config / Embedded | Zero-config / Embedded | Zero-config / In-process | Docker / External |
168
168
  | **Platform** | **All (Windows Native, macOS, Linux)** | **All (Windows Native, macOS, Linux)** | Unix-only (Linux/macOS/WSL) | All Platforms |
169
169
  | **Use Case** | Desktop, IDE, Local development | Custom research projects | Specialized Unix development | Enterprise, Massive graphs |
@@ -210,8 +210,8 @@ _If you’re using CodeGraphContext in your project, feel free to open a PR and
210
210
  - `tree-sitter-language-pack>=0.6.0` (not installed on Python 3.13)
211
211
  - `pyyaml`
212
212
  - `pathspec>=0.12.1`
213
- - `falkordb>=0.1.0`
214
- - `falkordblite>=0.1.0` (Unix only)
213
+ - `falkordb>=1.0,<1.6`
214
+ - `falkordblite>=0.7,<0.10` (Unix only, Python 3.12+)
215
215
  - `kuzu` (KuzuDB engine)
216
216
  - `fastapi>=0.100.0`
217
217
  - `uvicorn>=0.22.0`
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codegraphcontext"
3
- version = "0.4.17"
3
+ version = "0.5.1"
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"
@@ -92,6 +92,15 @@ dev = [
92
92
  "pytest>=7.4.0",
93
93
  "black>=23.11.0",
94
94
  "pytest-asyncio>=0.21.0",
95
+ "pytest-mock",
96
+ "ruff",
97
+ ]
98
+ # Optional drivers for `cgc datasource` ingestion (MySQL/Aurora, Cassandra).
99
+ # Redis ingestion uses the ``redis`` package already pinned in core deps.
100
+ datasources = [
101
+ "pymysql",
102
+ "mysql-connector-python",
103
+ "cassandra-driver",
95
104
  ]
96
105
 
97
106
  [project.urls]
@@ -17,13 +17,21 @@ def create_app() -> FastAPI:
17
17
  app.add_middleware(
18
18
  CORSMiddleware,
19
19
  allow_origins=["*"], # In production, restrict this
20
- allow_credentials=True,
20
+ # Credentials must stay disabled while origins is a wildcard; the
21
+ # combination is rejected by browsers and would leak cookie-authed
22
+ # responses to any site.
23
+ allow_credentials=False,
21
24
  allow_methods=["*"],
22
25
  allow_headers=["*"],
23
26
  )
24
27
 
25
28
  app.include_router(router, prefix="/api/v1")
26
29
 
30
+ @app.get("/health")
31
+ async def health():
32
+ """Liveness probe for load balancers and k8s."""
33
+ return {"status": "ok"}
34
+
27
35
  # MCP-over-SSE Endpoints
28
36
  app.add_api_route("/api/v1/mcp/sse", handle_sse, methods=["GET"])
29
37
  app.add_api_route("/api/v1/mcp/messages", handle_messages, methods=["POST"])
@@ -8,16 +8,17 @@ from mcp.types import Tool, TextContent, ServerCapabilities, ToolsCapability
8
8
  from mcp.server.sse import SseServerTransport
9
9
 
10
10
  from codegraphcontext.api.router import get_server
11
- from codegraphcontext.tool_definitions import TOOLS
11
+ from codegraphcontext.server import _strip_workspace_prefix, _apply_response_token_limit
12
12
 
13
13
  # Create the MCP Server instance using the SDK
14
14
  mcp_server = Server("CodeGraphContext")
15
15
 
16
16
  @mcp_server.list_tools()
17
17
  async def handle_list_tools() -> list[Tool]:
18
- """List available tools."""
18
+ """List available tools (honors disabledTools from mcp.json)."""
19
+ server = get_server()
19
20
  tools = []
20
- for name, defn in TOOLS.items():
21
+ for name, defn in server.tools.items():
21
22
  tools.append(Tool(
22
23
  name=name,
23
24
  description=defn["description"],
@@ -33,12 +34,16 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[TextConten
33
34
 
34
35
  # Execute via the existing handler logic
35
36
  result = await server.handle_tool_call(name, args)
37
+ result = _strip_workspace_prefix(result)
36
38
 
37
39
  if "error" in result:
38
40
  return [TextContent(type="text", text=f"Error: {result['error']}")]
39
41
 
40
- # Format result as JSON string for the AI
41
- return [TextContent(type="text", text=json.dumps(result, indent=2))]
42
+ # Format result as JSON string for the AI, with the same token budget
43
+ # the stdio transport applies.
44
+ response_text = json.dumps(result, indent=2)
45
+ response_text = _apply_response_token_limit(name, response_text)
46
+ return [TextContent(type="text", text=response_text)]
42
47
 
43
48
  # Create the SSE transport.
44
49
  # The messages_url is where the client will POST JSON-RPC messages.
@@ -91,12 +91,9 @@ async def index_repository(
91
91
  background_tasks: BackgroundTasks,
92
92
  server: MCPServer = Depends(get_server)
93
93
  ):
94
- args = {
95
- "path": request.path,
96
- "repo_name": request.repo_name,
97
- "branch": request.branch,
98
- "force": request.force
99
- }
94
+ # The add_code_to_graph handler only understands "path" (and is_dependency);
95
+ # repo_name/branch/force from the request model are not supported by it.
96
+ args = {"path": request.path}
100
97
 
101
98
  try:
102
99
  result = await server.handle_tool_call(
@@ -35,6 +35,7 @@ from .config_manager import (
35
35
  register_repo_in_context,
36
36
  ensure_first_run_bootstrap,
37
37
  ContextNotFoundError,
38
+ is_db_deletion_allowed,
38
39
  )
39
40
 
40
41
  console = Console()
@@ -260,6 +261,10 @@ def index_helper(path: str, context: Optional[str] = None):
260
261
  """Synchronously indexes a repository in a given context."""
261
262
  time_start = time.time()
262
263
  path_obj = Path(path).resolve()
264
+ # Normalize to forward slashes for cross-platform DB consistency.
265
+ # The graph DB always stores paths via Path.resolve().as_posix(),
266
+ # so Cypher queries must also use forward slashes on Windows.
267
+ repo_path_str = path_obj.as_posix()
263
268
  index_cwd = path_obj if path_obj.is_dir() else path_obj.parent
264
269
  services = _initialize_services(context, cwd=index_cwd)
265
270
  if not all(services[:3]):
@@ -283,7 +288,7 @@ def index_helper(path: str, context: Optional[str] = None):
283
288
  with db_manager.get_driver().session() as session:
284
289
  result = session.run(
285
290
  "MATCH (r:Repository {path: $path})-[:CONTAINS*]->(f:File) RETURN count(DISTINCT f) as file_count",
286
- path=str(path_obj)
291
+ path=repo_path_str
287
292
  )
288
293
  record = result.single()
289
294
  file_count = record["file_count"] if record else 0
@@ -415,6 +420,49 @@ def delete_helper(repo_path: str, context: Optional[str] = None):
415
420
  finally:
416
421
  db_manager.close_driver()
417
422
 
423
+ def _print_query_exception(e: Exception, query: str) -> None:
424
+ """
425
+ Pretty-print a database query exception, surfacing the raw driver
426
+ error message so Cypher syntax problems are clearly visible.
427
+ """
428
+ import traceback
429
+
430
+ error_type = type(e).__name__
431
+ error_module = type(e).__module__ or ""
432
+
433
+ # Neo4j: CypherSyntaxError and other ClientError subclasses carry
434
+ # a .message and .code attribute with the full server-side detail.
435
+ if "neo4j" in error_module:
436
+ code = getattr(e, "code", None)
437
+ msg = getattr(e, "message", None) or str(e)
438
+ console.print(f"[bold red]Query Error ({error_type}):[/bold red]")
439
+ if code:
440
+ console.print(f" [yellow]Code:[/yellow] {code}")
441
+ console.print(f" [yellow]Message:[/yellow] {msg}")
442
+
443
+ # FalkorDB: ResponseError / exceptions in falkordb or redis packages
444
+ elif "falkordb" in error_module or "redis" in error_module:
445
+ console.print(f"[bold red]Query Error ({error_type}):[/bold red]")
446
+ console.print(f" [yellow]Database message:[/yellow] {e}")
447
+
448
+ # KuzuDB: RuntimeError from the kuzu extension
449
+ # KuzuDB: RuntimeError from the kuzu extension or database_kuzu wrapper
450
+ elif "kuzu" in error_module or (
451
+ error_type == "RuntimeError" and "Parser exception" in str(e)
452
+ ):
453
+ console.print(f"[bold red]Query Error ({error_type}):[/bold red]")
454
+ console.print(f" [yellow]Database message:[/yellow] {e}")
455
+
456
+ else:
457
+ # Fallback: unknown backend — print type + message + traceback
458
+ console.print(f"[bold red]An error occurred while executing query ({error_type}):[/bold red]")
459
+ console.print(f" [yellow]Message:[/yellow] {e}")
460
+ console.print("[dim]--- Traceback ---[/dim]")
461
+ console.print(f"[dim]{traceback.format_exc()}[/dim]")
462
+
463
+ console.print(f"\n[dim]Failed query:[/dim]")
464
+ console.print(f"[dim] {query}[/dim]")
465
+
418
466
 
419
467
  def cypher_helper(query: str, context: Optional[str] = None):
420
468
  """Executes a read-only Cypher query."""
@@ -440,7 +488,7 @@ def cypher_helper(query: str, context: Optional[str] = None):
440
488
  records = [record.data() for record in result]
441
489
  console.print(json.dumps(records, indent=2))
442
490
  except Exception as e:
443
- console.print(f"[bold red]An error occurred while executing query:[/bold red] {e}")
491
+ _print_query_exception(e, query)
444
492
  db_manager.close_driver()
445
493
  raise typer.Exit(code=1)
446
494
  finally:
@@ -466,7 +514,7 @@ def cypher_helper_visual(query: str, context: Optional[str] = None):
466
514
  try:
467
515
  visualize_cypher_results(query)
468
516
  except Exception as e:
469
- console.print(f"[bold red]An error occurred while executing query:[/bold red] {e}")
517
+ _print_query_exception(e, query)
470
518
  db_manager.close_driver()
471
519
  raise typer.Exit(code=1)
472
520
  finally:
@@ -626,14 +674,32 @@ def reindex_helper(path: str, context: Optional[str] = None):
626
674
  db_manager.close_driver()
627
675
 
628
676
 
629
- def update_helper(path: str, context: Optional[str] = None):
630
- """Update/refresh index for a path (alias for reindex)."""
677
+ def update_helper(path: str, context: Optional[str] = None, quiet: bool = False):
678
+ """Update/refresh index for a path (alias for reindex).
679
+
680
+ When *quiet* is True (e.g. when invoked from Git hooks with --quiet),
681
+ Rich console output, including progress rendering, is suppressed.
682
+ """
683
+ if quiet:
684
+ console.quiet = True
685
+ try:
686
+ reindex_helper(path, context)
687
+ finally:
688
+ console.quiet = False
689
+ return
631
690
  console.print("[cyan]Updating repository index...[/cyan]")
632
691
  reindex_helper(path, context)
633
692
 
634
693
 
635
694
  def clean_helper(context: Optional[str] = None):
636
695
  """Remove orphaned nodes and relationships from the database."""
696
+ if not is_db_deletion_allowed():
697
+ console.print(
698
+ "[bold red]Error:[/bold red] Database cleanup is disabled. "
699
+ "Set ALLOW_DB_DELETION=true in config to enable."
700
+ )
701
+ raise typer.Exit(code=1)
702
+
637
703
  services = _initialize_services(context)
638
704
  if not all(services[:3]):
639
705
  _fail_services_init()
@@ -691,6 +757,9 @@ def stats_helper(path: str = None, context: Optional[str] = None):
691
757
  if path:
692
758
  # Stats for specific repository
693
759
  path_obj = Path(path).resolve()
760
+ # Paths are stored with forward slashes (as_posix) in the graph DB,
761
+ # so lookups must use the same normalization on Windows too.
762
+ repo_path_str = path_obj.as_posix()
694
763
  console.print(f"[cyan]📊 Statistics for: {path_obj}[/cyan]\n")
695
764
 
696
765
  with db_manager.get_driver().session() as session:
@@ -699,7 +768,7 @@ def stats_helper(path: str = None, context: Optional[str] = None):
699
768
  MATCH (r:Repository {path: $path})
700
769
  RETURN r
701
770
  """
702
- result = session.run(repo_query, path=str(path_obj))
771
+ result = session.run(repo_query, path=repo_path_str)
703
772
  if not result.single():
704
773
  console.print(f"[red]Repository not found: {path_obj}[/red]")
705
774
  return
@@ -708,20 +777,20 @@ def stats_helper(path: str = None, context: Optional[str] = None):
708
777
  # Get stats using separate queries to handle depth and avoid Cartesian products
709
778
  # 1. Files
710
779
  file_query = "MATCH (r:Repository {path: $path})-[:CONTAINS*]->(f:File) RETURN count(f) as c"
711
- file_count = session.run(file_query, path=str(path_obj)).single()["c"]
780
+ file_count = session.run(file_query, path=repo_path_str).single()["c"]
712
781
 
713
782
  # 2. Functions (including methods in classes)
714
783
  func_query = "MATCH (r:Repository {path: $path})-[:CONTAINS*]->(func:Function) RETURN count(func) as c"
715
- func_count = session.run(func_query, path=str(path_obj)).single()["c"]
784
+ func_count = session.run(func_query, path=repo_path_str).single()["c"]
716
785
 
717
786
  # 3. Classes
718
787
  class_query = "MATCH (r:Repository {path: $path})-[:CONTAINS*]->(c:Class) RETURN count(c) as c"
719
- class_count = session.run(class_query, path=str(path_obj)).single()["c"]
788
+ class_count = session.run(class_query, path=repo_path_str).single()["c"]
720
789
 
721
790
  # 4. Modules (imported) - Note: Module nodes are outside the repo structure usually, connected via IMPORTS
722
791
  # We need to traverse from files to modules
723
792
  module_query = "MATCH (r:Repository {path: $path})-[:CONTAINS*]->(f:File)-[:IMPORTS]->(m:Module) RETURN count(DISTINCT m) as c"
724
- module_count = session.run(module_query, path=str(path_obj)).single()["c"]
793
+ module_count = session.run(module_query, path=repo_path_str).single()["c"]
725
794
 
726
795
  table = Table(show_header=True, header_style="bold magenta")
727
796
  table.add_column("Metric", style="cyan")
@@ -822,7 +891,7 @@ def watch_helper(path: str, context: Optional[str] = None, use_polling: Optional
822
891
  with code_finder.driver.session() as _s:
823
892
  _r = _s.run(
824
893
  "MATCH (n:File) WHERE n.path STARTS WITH $p RETURN count(n) AS c",
825
- p=str(path_obj) + "/"
894
+ p=path_obj.as_posix() + "/"
826
895
  )
827
896
  _count = _r.single()["c"]
828
897
  if _count > 100:
@@ -844,10 +913,11 @@ def watch_helper(path: str, context: Optional[str] = None, use_polling: Optional
844
913
 
845
914
  # Add the directory to watch
846
915
  if is_indexed:
847
- console.print("[green]✓[/green] Already indexed (no initial scan needed)")
916
+ console.print("[green]✓[/green] Already indexed. Synchronizing current files...")
848
917
  watcher.watch_directory(
849
918
  str(path_obj),
850
919
  perform_initial_scan=False,
920
+ sync_on_start=True,
851
921
  cgcignore_path=ctx.cgcignore_path,
852
922
  )
853
923
  else:
@@ -15,6 +15,19 @@ import yaml
15
15
 
16
16
  console = Console()
17
17
 
18
+
19
+ def _atomic_write_text(path: Path, content: str, *, secure: bool = False) -> None:
20
+ """Write *content* to *path* atomically (temp file + replace)."""
21
+ path.parent.mkdir(parents=True, exist_ok=True)
22
+ tmp_path = path.with_suffix(path.suffix + ".tmp")
23
+ with open(tmp_path, "w", encoding="utf-8") as f:
24
+ f.write(content)
25
+ f.flush()
26
+ os.fsync(f.fileno())
27
+ os.replace(tmp_path, path)
28
+ if secure:
29
+ os.chmod(path, 0o600)
30
+
18
31
  # Configuration file location
19
32
  CONFIG_DIR = Path.home() / ".codegraphcontext"
20
33
  CONFIG_FILE = CONFIG_DIR / ".env"
@@ -160,6 +173,14 @@ CONFIG_VALIDATORS = {
160
173
  "CGC_EMBEDDING_MODEL": ["local", "openai"],
161
174
  "FUZZY_SEARCH": ["true", "false"],
162
175
  }
176
+
177
+ SUPPORTED_DATABASES: List[str] = CONFIG_VALIDATORS["DEFAULT_DATABASE"]
178
+ DATABASE_CLI_HELP = (
179
+ "Database backend ("
180
+ + "|".join(SUPPORTED_DATABASES)
181
+ + "). Defaults to DEFAULT_DATABASE from config."
182
+ )
183
+
163
184
  DEFAULT_CGCIGNORE_PATTERNS = """\
164
185
  # Default .cgcignore patterns
165
186
  # Lines starting with # are comments; blank lines are ignored.
@@ -279,18 +300,25 @@ def load_config() -> Dict[str, str]:
279
300
  def should_apply_project_dotenv() -> bool:
280
301
  """True when cwd-local ``.codegraphcontext/.env`` should merge with global config.
281
302
 
282
- Skips project env when ``HOME`` is isolated (e.g. E2E) but ``cwd`` is an unrelated
283
- checkout, unless ``CGC_LOAD_PROJECT_ENV=1``. Set ``CGC_IGNORE_PROJECT_ENV=1`` to force skip.
303
+ Project env is loaded only in **per-repo** context mode (or when
304
+ ``CGC_LOAD_PROJECT_ENV=1``). In **global** / **named** mode, ``~/.codegraphcontext/.env``
305
+ wins so clones with a checked-in ``.codegraphcontext/.env`` do not hijack config.
306
+
307
+ Set ``CGC_IGNORE_PROJECT_ENV=1`` to force skip; ``CGC_LOAD_PROJECT_ENV=1`` to force load.
284
308
  """
285
309
  if os.getenv("CGC_IGNORE_PROJECT_ENV", "").strip().lower() in ("1", "true", "yes"):
286
310
  return False
287
311
  if os.getenv("CGC_LOAD_PROJECT_ENV", "").strip().lower() in ("1", "true", "yes"):
288
312
  return True
313
+ cfg = load_context_config()
314
+ if cfg.mode != "per-repo":
315
+ return False
289
316
  try:
290
317
  Path.cwd().resolve().relative_to(Path.home().resolve())
291
318
  return True
292
319
  except ValueError:
293
- return False
320
+ # Per-repo indexing from /tmp with an isolated HOME (common in E2E/CI).
321
+ return True
294
322
 
295
323
 
296
324
  def find_local_env() -> Optional[Path]:
@@ -370,30 +398,27 @@ def save_config(config: Dict[str, str], preserve_db_credentials: bool = True):
370
398
  credentials_to_write[key] = config[key]
371
399
 
372
400
  try:
373
- with open(CONFIG_FILE, "w", encoding="utf-8") as f:
374
- f.write("# CodeGraphContext Configuration\n")
375
- f.write(f"# Location: {CONFIG_FILE}\n\n")
376
-
377
- # Write database credentials first if they exist
378
- if credentials_to_write:
379
- f.write("# ===== Database Credentials =====\n")
380
- for key in sorted(DATABASE_CREDENTIAL_KEYS):
381
- if key in credentials_to_write:
382
- f.write(f"{key}={credentials_to_write[key]}\n")
383
- f.write("\n")
384
-
385
- # Write configuration settings
386
- f.write("# ===== Configuration Settings =====\n")
387
- for key, value in sorted(config.items()):
388
- # Skip database credentials (already written above)
389
- if key in DATABASE_CREDENTIAL_KEYS:
390
- continue
391
-
392
- description = CONFIG_DESCRIPTIONS.get(key, "")
393
- if description:
394
- f.write(f"# {description}\n")
395
- f.write(f"{key}={value}\n\n")
396
-
401
+ lines = [
402
+ "# CodeGraphContext Configuration",
403
+ f"# Location: {CONFIG_FILE}",
404
+ "",
405
+ ]
406
+ if credentials_to_write:
407
+ lines.append("# ===== Database Credentials =====")
408
+ for key in sorted(DATABASE_CREDENTIAL_KEYS):
409
+ if key in credentials_to_write:
410
+ lines.append(f"{key}={credentials_to_write[key]}")
411
+ lines.append("")
412
+ lines.append("# ===== Configuration Settings =====")
413
+ for key, value in sorted(config.items()):
414
+ if key in DATABASE_CREDENTIAL_KEYS:
415
+ continue
416
+ description = CONFIG_DESCRIPTIONS.get(key, "")
417
+ if description:
418
+ lines.append(f"# {description}")
419
+ lines.append(f"{key}={value}")
420
+ lines.append("")
421
+ _atomic_write_text(CONFIG_FILE, "\n".join(lines), secure=True)
397
422
  console.print(f"[green]✅ Configuration saved to {CONFIG_FILE}[/green]")
398
423
  except Exception as e:
399
424
  console.print(f"[red]Error saving config: {e}[/red]")
@@ -789,8 +814,10 @@ def save_context_config(cfg: ContextConfig) -> None:
789
814
  }
790
815
 
791
816
  try:
792
- with open(CONTEXT_CONFIG_FILE, "w", encoding="utf-8") as f:
793
- yaml.dump(raw, f, default_flow_style=False, sort_keys=False)
817
+ _atomic_write_text(
818
+ CONTEXT_CONFIG_FILE,
819
+ yaml.dump(raw, default_flow_style=False, sort_keys=False),
820
+ )
794
821
  except Exception as e:
795
822
  console.print(f"[red]Error saving config.yaml: {e}[/red]")
796
823
 
@@ -869,23 +896,38 @@ def resolve_context(
869
896
  local_cgc = cwd / ".codegraphcontext"
870
897
  local_cgc.mkdir(parents=True, exist_ok=True)
871
898
  (local_cgc / "db").mkdir(exist_ok=True)
872
-
873
- # Copy global .env into local context for easy per-repo tweaking
899
+
900
+ inherited_db = load_config().get("DEFAULT_DATABASE", "falkordb")
901
+
902
+ # Copy global .env into local context for easy per-repo tweaking.
903
+ # Guard against the self-copy case: when cwd is the home directory,
904
+ # local_cgc resolves to CONFIG_DIR itself, so `local_cgc / ".env"` is
905
+ # CONFIG_FILE. Copying a file onto itself raises shutil.SameFileError,
906
+ # which crashes resolve_context for any session started from home.
874
907
  import shutil
875
- if CONFIG_FILE.exists():
876
- shutil.copy2(CONFIG_FILE, local_cgc / ".env")
877
-
878
- console.print(f"[dim]Auto-initialized per-repo context at {local_cgc}[/dim]")
908
+ _target_env = local_cgc / ".env"
909
+ if CONFIG_FILE.exists() and _target_env.resolve() != CONFIG_FILE.resolve():
910
+ shutil.copy2(CONFIG_FILE, _target_env)
911
+
912
+ local_yaml = local_cgc / "config.yaml"
913
+ if not local_yaml.exists():
914
+ with open(local_yaml, "w", encoding="utf-8") as f:
915
+ yaml.safe_dump({"database": inherited_db}, f)
916
+
917
+ console.print(
918
+ f"[dim]Auto-initialized per-repo context at {local_cgc} "
919
+ f"(Database: {inherited_db})[/dim]"
920
+ )
879
921
 
880
922
  if local_cgc is not None:
881
923
  # Read local config.yaml if present
882
924
  local_yaml = local_cgc / "config.yaml"
883
- local_db = "falkordb"
925
+ local_db = load_config().get("DEFAULT_DATABASE", "falkordb")
884
926
  if local_yaml.exists():
885
927
  try:
886
928
  with open(local_yaml, encoding="utf-8") as f:
887
929
  local_raw = yaml.safe_load(f) or {}
888
- local_db = local_raw.get("database", "falkordb")
930
+ local_db = local_raw.get("database", local_db)
889
931
  except Exception:
890
932
  pass
891
933
  db_path = str(local_cgc / "db" / local_db)
@@ -1147,8 +1189,10 @@ def _save_workspace_mappings(mappings: Dict[str, Dict[str, str]]) -> None:
1147
1189
  raw = {}
1148
1190
  raw["workspace_mappings"] = mappings
1149
1191
  try:
1150
- with open(CONTEXT_CONFIG_FILE, "w", encoding="utf-8") as f:
1151
- yaml.dump(raw, f, default_flow_style=False, sort_keys=False)
1192
+ _atomic_write_text(
1193
+ CONTEXT_CONFIG_FILE,
1194
+ yaml.dump(raw, default_flow_style=False, sort_keys=False),
1195
+ )
1152
1196
  except Exception as e:
1153
1197
  console.print(f"[red]Error saving workspace mappings: {e}[/red]")
1154
1198