#
tokens: 33388/50000 1/422 files (page 15/17)
lines: off (toggle) GitHub
raw markdown copy
This is page 15 of 17. Use http://codebase.md/shashankss1205/codegraphcontext?page={x} to view the full context.

# Directory Structure

```
├── .cgcignore
├── .github
│   ├── FUNDING.yml
│   └── workflows
│       ├── e2e-tests.yml
│       ├── post_discord_invite.yml
│       ├── test.yml
│       └── update-contributors.yml
├── .gitignore
├── CLI_Commands.md
├── CONTRIBUTING.md
├── contributors.md
├── docs
│   ├── docs
│   │   ├── architecture.md
│   │   ├── cli.md
│   │   ├── contributing_languages.md
│   │   ├── contributing.md
│   │   ├── cookbook.md
│   │   ├── core.md
│   │   ├── future_work.md
│   │   ├── images
│   │   │   ├── 1.png
│   │   │   ├── 11.png
│   │   │   ├── 12.png
│   │   │   ├── 13.png
│   │   │   ├── 14.png
│   │   │   ├── 16.png
│   │   │   ├── 19.png
│   │   │   ├── 2.png
│   │   │   ├── 20.png
│   │   │   ├── 21.png
│   │   │   ├── 22.png
│   │   │   ├── 23.png
│   │   │   ├── 24.png
│   │   │   ├── 26.png
│   │   │   ├── 28.png
│   │   │   ├── 29.png
│   │   │   ├── 3.png
│   │   │   ├── 30.png
│   │   │   ├── 31.png
│   │   │   ├── 32.png
│   │   │   ├── 33.png
│   │   │   ├── 34.png
│   │   │   ├── 35.png
│   │   │   ├── 36.png
│   │   │   ├── 38.png
│   │   │   ├── 39.png
│   │   │   ├── 4.png
│   │   │   ├── 40.png
│   │   │   ├── 41.png
│   │   │   ├── 42.png
│   │   │   ├── 43.png
│   │   │   ├── 44.png
│   │   │   ├── 5.png
│   │   │   ├── 6.png
│   │   │   ├── 7.png
│   │   │   ├── 8.png
│   │   │   ├── 9.png
│   │   │   ├── Indexing.gif
│   │   │   ├── tool_images
│   │   │   │   ├── 1.png
│   │   │   │   ├── 2.png
│   │   │   │   └── 3.png
│   │   │   └── Usecase.gif
│   │   ├── index.md
│   │   ├── installation.md
│   │   ├── license.md
│   │   ├── server.md
│   │   ├── tools.md
│   │   ├── troubleshooting.md
│   │   ├── use_cases.md
│   │   └── watching.md
│   ├── mkdocs.yml
│   └── site
│       ├── 404.html
│       ├── architecture
│       │   └── index.html
│       ├── assets
│       │   ├── images
│       │   │   └── favicon.png
│       │   ├── javascripts
│       │   │   ├── bundle.79ae519e.min.js
│       │   │   ├── bundle.79ae519e.min.js.map
│       │   │   ├── lunr
│       │   │   │   ├── min
│       │   │   │   │   ├── lunr.ar.min.js
│       │   │   │   │   ├── lunr.da.min.js
│       │   │   │   │   ├── lunr.de.min.js
│       │   │   │   │   ├── lunr.du.min.js
│       │   │   │   │   ├── lunr.el.min.js
│       │   │   │   │   ├── lunr.es.min.js
│       │   │   │   │   ├── lunr.fi.min.js
│       │   │   │   │   ├── lunr.fr.min.js
│       │   │   │   │   ├── lunr.he.min.js
│       │   │   │   │   ├── lunr.hi.min.js
│       │   │   │   │   ├── lunr.hu.min.js
│       │   │   │   │   ├── lunr.hy.min.js
│       │   │   │   │   ├── lunr.it.min.js
│       │   │   │   │   ├── lunr.ja.min.js
│       │   │   │   │   ├── lunr.jp.min.js
│       │   │   │   │   ├── lunr.kn.min.js
│       │   │   │   │   ├── lunr.ko.min.js
│       │   │   │   │   ├── lunr.multi.min.js
│       │   │   │   │   ├── lunr.nl.min.js
│       │   │   │   │   ├── lunr.no.min.js
│       │   │   │   │   ├── lunr.pt.min.js
│       │   │   │   │   ├── lunr.ro.min.js
│       │   │   │   │   ├── lunr.ru.min.js
│       │   │   │   │   ├── lunr.sa.min.js
│       │   │   │   │   ├── lunr.stemmer.support.min.js
│       │   │   │   │   ├── lunr.sv.min.js
│       │   │   │   │   ├── lunr.ta.min.js
│       │   │   │   │   ├── lunr.te.min.js
│       │   │   │   │   ├── lunr.th.min.js
│       │   │   │   │   ├── lunr.tr.min.js
│       │   │   │   │   ├── lunr.vi.min.js
│       │   │   │   │   └── lunr.zh.min.js
│       │   │   │   ├── tinyseg.js
│       │   │   │   └── wordcut.js
│       │   │   └── workers
│       │   │       ├── search.2c215733.min.js
│       │   │       └── search.2c215733.min.js.map
│       │   └── stylesheets
│       │       ├── main.484c7ddc.min.css
│       │       ├── main.484c7ddc.min.css.map
│       │       ├── palette.ab4e12ef.min.css
│       │       └── palette.ab4e12ef.min.css.map
│       ├── cli
│       │   └── index.html
│       ├── contributing
│       │   └── index.html
│       ├── contributing_languages
│       │   └── index.html
│       ├── cookbook
│       │   └── index.html
│       ├── core
│       │   └── index.html
│       ├── future_work
│       │   └── index.html
│       ├── images
│       │   ├── 1.png
│       │   ├── 11.png
│       │   ├── 12.png
│       │   ├── 13.png
│       │   ├── 14.png
│       │   ├── 16.png
│       │   ├── 19.png
│       │   ├── 2.png
│       │   ├── 20.png
│       │   ├── 21.png
│       │   ├── 22.png
│       │   ├── 23.png
│       │   ├── 24.png
│       │   ├── 26.png
│       │   ├── 28.png
│       │   ├── 29.png
│       │   ├── 3.png
│       │   ├── 30.png
│       │   ├── 31.png
│       │   ├── 32.png
│       │   ├── 33.png
│       │   ├── 34.png
│       │   ├── 35.png
│       │   ├── 36.png
│       │   ├── 38.png
│       │   ├── 39.png
│       │   ├── 4.png
│       │   ├── 40.png
│       │   ├── 41.png
│       │   ├── 42.png
│       │   ├── 43.png
│       │   ├── 44.png
│       │   ├── 5.png
│       │   ├── 6.png
│       │   ├── 7.png
│       │   ├── 8.png
│       │   ├── 9.png
│       │   ├── Indexing.gif
│       │   ├── tool_images
│       │   │   ├── 1.png
│       │   │   ├── 2.png
│       │   │   └── 3.png
│       │   └── Usecase.gif
│       ├── index.html
│       ├── installation
│       │   └── index.html
│       ├── license
│       │   └── index.html
│       ├── search
│       │   └── search_index.json
│       ├── server
│       │   └── index.html
│       ├── sitemap.xml
│       ├── sitemap.xml.gz
│       ├── tools
│       │   └── index.html
│       ├── troubleshooting
│       │   └── index.html
│       ├── use_cases
│       │   └── index.html
│       └── watching
│           └── index.html
├── funding.json
├── images
│   ├── 1.png
│   ├── 11.png
│   ├── 12.png
│   ├── 13.png
│   ├── 14.png
│   ├── 16.png
│   ├── 19.png
│   ├── 2.png
│   ├── 20.png
│   ├── 21.png
│   ├── 22.png
│   ├── 23.png
│   ├── 24.png
│   ├── 26.png
│   ├── 28.png
│   ├── 29.png
│   ├── 3.png
│   ├── 30.png
│   ├── 31.png
│   ├── 32.png
│   ├── 33.png
│   ├── 34.png
│   ├── 35.png
│   ├── 36.png
│   ├── 38.png
│   ├── 39.png
│   ├── 4.png
│   ├── 40.png
│   ├── 41.png
│   ├── 42.png
│   ├── 43.png
│   ├── 44.png
│   ├── 5.png
│   ├── 6.png
│   ├── 7.png
│   ├── 8.png
│   ├── 9.png
│   ├── Indexing.gif
│   ├── tool_images
│   │   ├── 1.png
│   │   ├── 2.png
│   │   └── 3.png
│   └── Usecase.gif
├── LICENSE
├── MANIFEST.in
├── organizer
│   ├── CONTRIBUTING_LANGUAGES.md
│   ├── cookbook.md
│   ├── docs.md
│   ├── language_specific_nodes.md
│   ├── Tools_Exploration.md
│   └── troubleshoot.md
├── pyproject.toml
├── README.md
├── scripts
│   ├── generate_lang_contributors.py
│   ├── post_install_fix.sh
│   ├── test_all_parsers.py
│   └── update_language_parsers.py
├── SECURITY.md
├── src
│   └── codegraphcontext
│       ├── __init__.py
│       ├── __main__.py
│       ├── cli
│       │   ├── __init__.py
│       │   ├── cli_helpers.py
│       │   ├── config_manager.py
│       │   ├── main.py
│       │   ├── setup_macos.py
│       │   └── setup_wizard.py
│       ├── core
│       │   ├── __init__.py
│       │   ├── database_falkordb.py
│       │   ├── database.py
│       │   ├── falkor_worker.py
│       │   ├── jobs.py
│       │   └── watcher.py
│       ├── prompts.py
│       ├── server.py
│       ├── tools
│       │   ├── __init__.py
│       │   ├── advanced_language_query_tool.py
│       │   ├── code_finder.py
│       │   ├── graph_builder.py
│       │   ├── languages
│       │   │   ├── c.py
│       │   │   ├── cpp.py
│       │   │   ├── csharp.py
│       │   │   ├── go.py
│       │   │   ├── java.py
│       │   │   ├── javascript.py
│       │   │   ├── kotlin.py
│       │   │   ├── php.py
│       │   │   ├── python.py
│       │   │   ├── ruby.py
│       │   │   ├── rust.py
│       │   │   ├── scala.py
│       │   │   ├── swift.py
│       │   │   ├── typescript.py
│       │   │   └── typescriptjsx.py
│       │   ├── package_resolver.py
│       │   ├── query_tool_languages
│       │   │   ├── c_toolkit.py
│       │   │   ├── cpp_toolkit.py
│       │   │   ├── csharp_toolkit.py
│       │   │   ├── go_toolkit.py
│       │   │   ├── java_toolkit.py
│       │   │   ├── javascript_toolkit.py
│       │   │   ├── python_toolkit.py
│       │   │   ├── ruby_toolkit.py
│       │   │   ├── rust_toolkit.py
│       │   │   ├── scala_toolkit.py
│       │   │   ├── swift_toolkit.py
│       │   │   └── typescript_toolkit.py
│       │   └── system.py
│       └── utils
│           ├── debug_log.py
│           └── tree_sitter_manager.py
├── tests
│   ├── __init__.py
│   ├── conftest.py
│   ├── sample_project
│   │   ├── advanced_calls.py
│   │   ├── advanced_classes.py
│   │   ├── advanced_classes2.py
│   │   ├── advanced_functions.py
│   │   ├── advanced_imports.py
│   │   ├── async_features.py
│   │   ├── callbacks_decorators.py
│   │   ├── circular1.py
│   │   ├── circular2.py
│   │   ├── class_instantiation.py
│   │   ├── cli_and_dunder.py
│   │   ├── complex_classes.py
│   │   ├── comprehensions_generators.py
│   │   ├── context_managers.py
│   │   ├── control_flow.py
│   │   ├── datatypes.py
│   │   ├── dynamic_dispatch.py
│   │   ├── dynamic_imports.py
│   │   ├── edge_cases
│   │   │   ├── comments_only.py
│   │   │   ├── docstring_only.py
│   │   │   ├── empty.py
│   │   │   ├── hardcoded_secrets.py
│   │   │   ├── long_functions.py
│   │   │   └── syntax_error.py
│   │   ├── function_chains.py
│   │   ├── generators.py
│   │   ├── import_reexports.py
│   │   ├── mapping_calls.py
│   │   ├── module_a.py
│   │   ├── module_b.py
│   │   ├── module_c
│   │   │   ├── __init__.py
│   │   │   ├── submodule1.py
│   │   │   └── submodule2.py
│   │   ├── namespace_pkg
│   │   │   └── ns_module.py
│   │   ├── pattern_matching.py
│   │   └── typing_examples.py
│   ├── sample_project_c
│   │   ├── cgc_sample
│   │   ├── include
│   │   │   ├── config.h
│   │   │   ├── math
│   │   │   │   └── vec.h
│   │   │   ├── module.h
│   │   │   ├── platform.h
│   │   │   └── util.h
│   │   ├── Makefile
│   │   ├── README.md
│   │   └── src
│   │       ├── main.c
│   │       ├── math
│   │       │   └── vec.c
│   │       ├── module.c
│   │       └── util.c
│   ├── sample_project_cpp
│   │   ├── class_features.cpp
│   │   ├── classes.cpp
│   │   ├── control_flow.cpp
│   │   ├── edge_cases.cpp
│   │   ├── enum_struct_union.cpp
│   │   ├── exceptions.cpp
│   │   ├── file_io.cpp
│   │   ├── function_chain.cpp
│   │   ├── function_chain.h
│   │   ├── function_types.cpp
│   │   ├── main.cpp
│   │   ├── main.exe
│   │   ├── namespaces.cpp
│   │   ├── raii_example.cpp
│   │   ├── README.md
│   │   ├── sample_project.exe
│   │   ├── stl_usage.cpp
│   │   ├── templates.cpp
│   │   └── types_variable_assignments.cpp
│   ├── sample_project_csharp
│   │   ├── README.md
│   │   └── src
│   │       └── Example.App
│   │           ├── Attributes
│   │           │   └── CustomAttributes.cs
│   │           ├── Example.App.csproj
│   │           ├── Models
│   │           │   ├── Person.cs
│   │           │   ├── Point.cs
│   │           │   ├── Role.cs
│   │           │   └── User.cs
│   │           ├── OuterClass.cs
│   │           ├── Program.cs
│   │           ├── Services
│   │           │   ├── GreetingService.cs
│   │           │   ├── IGreetingService.cs
│   │           │   └── LegacyService.cs
│   │           └── Utils
│   │               ├── CollectionHelper.cs
│   │               └── FileHelper.cs
│   ├── sample_project_go
│   │   ├── advanced_types.go
│   │   ├── basic_functions.go
│   │   ├── embedded_composition.go
│   │   ├── error_handling.go
│   │   ├── generics.go
│   │   ├── go.mod
│   │   ├── goroutines_channels.go
│   │   ├── interfaces.go
│   │   ├── packages_imports.go
│   │   ├── README.md
│   │   ├── structs_methods.go
│   │   └── util
│   │       └── helpers.go
│   ├── sample_project_java
│   │   ├── out
│   │   │   └── com
│   │   │       └── example
│   │   │           └── app
│   │   │               ├── annotations
│   │   │               │   └── Logged.class
│   │   │               ├── Main.class
│   │   │               ├── misc
│   │   │               │   ├── Outer.class
│   │   │               │   └── Outer$Inner.class
│   │   │               ├── model
│   │   │               │   ├── Role.class
│   │   │               │   └── User.class
│   │   │               ├── service
│   │   │               │   ├── AbstractGreeter.class
│   │   │               │   ├── GreetingService.class
│   │   │               │   └── impl
│   │   │               │       └── GreetingServiceImpl.class
│   │   │               └── util
│   │   │                   ├── CollectionUtils.class
│   │   │                   └── IOHelper.class
│   │   ├── README.md
│   │   ├── sources.txt
│   │   └── src
│   │       └── com
│   │           └── example
│   │               └── app
│   │                   ├── annotations
│   │                   │   └── Logged.java
│   │                   ├── Main.java
│   │                   ├── misc
│   │                   │   └── Outer.java
│   │                   ├── model
│   │                   │   ├── Role.java
│   │                   │   └── User.java
│   │                   ├── service
│   │                   │   ├── AbstractGreeter.java
│   │                   │   ├── GreetingService.java
│   │                   │   └── impl
│   │                   │       └── GreetingServiceImpl.java
│   │                   └── util
│   │                       ├── CollectionUtils.java
│   │                       └── IOHelper.java
│   ├── sample_project_javascript
│   │   ├── arrays.js
│   │   ├── asyncAwait.js
│   │   ├── classes.js
│   │   ├── dom.js
│   │   ├── errorHandling.js
│   │   ├── events.js
│   │   ├── exporter.js
│   │   ├── fetchAPI.js
│   │   ├── fixtures
│   │   │   └── js
│   │   │       └── accessors.js
│   │   ├── functions.js
│   │   ├── importer.js
│   │   ├── objects.js
│   │   ├── promises.js
│   │   ├── README.md
│   │   └── variables.js
│   ├── sample_project_kotlin
│   │   ├── AdvancedClasses.kt
│   │   ├── Annotations.kt
│   │   ├── Coroutines.kt
│   │   ├── EdgeCases.kt
│   │   ├── Functions.kt
│   │   ├── Main.kt
│   │   ├── Properties.kt
│   │   └── User.kt
│   ├── sample_project_misc
│   │   ├── index.html
│   │   ├── README.md
│   │   ├── styles.css
│   │   ├── tables.css
│   │   └── tables.html
│   ├── sample_project_php
│   │   ├── classes_objects.php
│   │   ├── database.php
│   │   ├── edgecases.php
│   │   ├── error_handling.php
│   │   ├── file_handling.php
│   │   ├── functions.php
│   │   ├── generators_iterators.php
│   │   ├── globals_superglobals.php
│   │   ├── Inheritance.php
│   │   ├── interface_traits.php
│   │   └── README.md
│   ├── sample_project_ruby
│   │   ├── class_example.rb
│   │   ├── enumerables.rb
│   │   ├── error_handling.rb
│   │   ├── file_io.rb
│   │   ├── inheritance_example.rb
│   │   ├── main.rb
│   │   ├── metaprogramming.rb
│   │   ├── mixins_example.rb
│   │   ├── module_example.rb
│   │   └── tests
│   │       ├── test_mixins.py
│   │       └── test_sample.rb
│   ├── sample_project_rust
│   │   ├── Cargo.toml
│   │   ├── README.md
│   │   └── src
│   │       ├── basic_functions.rs
│   │       ├── concurrency.rs
│   │       ├── error_handling.rs
│   │       ├── generics.rs
│   │       ├── iterators_closures.rs
│   │       ├── lib.rs
│   │       ├── lifetimes_references.rs
│   │       ├── modules.rs
│   │       ├── smart_pointers.rs
│   │       ├── structs_enums.rs
│   │       └── traits.rs
│   ├── sample_project_scala
│   │   ├── Animals.scala
│   │   ├── Complex.scala
│   │   ├── Functional.scala
│   │   ├── Geometry.scala
│   │   ├── Main.scala
│   │   ├── PackageObject.scala
│   │   ├── Script.sc
│   │   ├── Services.scala
│   │   ├── Shapes.scala
│   │   ├── Utils.scala
│   │   └── Variables.scala
│   ├── sample_project_swift
│   │   ├── Generics.swift
│   │   ├── Main.swift
│   │   ├── README.md
│   │   ├── Shapes.swift
│   │   ├── User.swift
│   │   └── Vehicles.swift
│   ├── sample_project_typescript
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── sample_tsx.tsx
│   │   ├── src
│   │   │   ├── advanced-types.ts
│   │   │   ├── async-promises.ts
│   │   │   ├── classes-inheritance.ts
│   │   │   ├── decorators-metadata.ts
│   │   │   ├── error-validation.ts
│   │   │   ├── functions-generics.ts
│   │   │   ├── index.ts
│   │   │   ├── modules-namespaces.ts
│   │   │   ├── types-interfaces.ts
│   │   │   └── utilities-helpers.ts
│   │   └── tsconfig.json
│   ├── test_cpp_parser.py
│   ├── test_database_validation.py
│   ├── test_end_to_end.py
│   ├── test_graph_indexing_js.py
│   ├── test_graph_indexing.py
│   ├── test_kotlin_parser.py
│   ├── test_swift_parser.py
│   ├── test_tree_sitter
│   │   ├── __init__.py
│   │   ├── class_instantiation.py
│   │   ├── complex_classes.py
│   │   └── test_file.py
│   ├── test_tree_sitter_manager.py
│   └── test_typescript_parser.py
├── visualize_graph.py
├── website
│   ├── .example.env
│   ├── .gitignore
│   ├── api
│   │   └── pypi.ts
│   ├── bun.lockb
│   ├── components.json
│   ├── eslint.config.js
│   ├── index.html
│   ├── package-lock.json
│   ├── package.json
│   ├── postcss.config.js
│   ├── public
│   │   ├── favicon.ico
│   │   ├── placeholder.svg
│   │   └── robots.txt
│   ├── README.md
│   ├── src
│   │   ├── App.css
│   │   ├── App.tsx
│   │   ├── assets
│   │   │   ├── function-calls.png
│   │   │   ├── graph-total.png
│   │   │   ├── hero-graph.jpg
│   │   │   └── hierarchy.png
│   │   ├── components
│   │   │   ├── ComparisonTable.tsx
│   │   │   ├── CookbookSection.tsx
│   │   │   ├── DemoSection.tsx
│   │   │   ├── ExamplesSection.tsx
│   │   │   ├── FeaturesSection.tsx
│   │   │   ├── Footer.tsx
│   │   │   ├── HeroSection.tsx
│   │   │   ├── InstallationSection.tsx
│   │   │   ├── MoveToTop.tsx
│   │   │   ├── ShowDownloads.tsx
│   │   │   ├── ShowStarGraph.tsx
│   │   │   ├── SocialMentionsTimeline.tsx
│   │   │   ├── TestimonialSection.tsx
│   │   │   ├── ThemeProvider.tsx
│   │   │   ├── ThemeToggle.tsx
│   │   │   └── ui
│   │   │       ├── accordion.tsx
│   │   │       ├── alert-dialog.tsx
│   │   │       ├── alert.tsx
│   │   │       ├── aspect-ratio.tsx
│   │   │       ├── avatar.tsx
│   │   │       ├── badge.tsx
│   │   │       ├── breadcrumb.tsx
│   │   │       ├── button.tsx
│   │   │       ├── calendar.tsx
│   │   │       ├── card.tsx
│   │   │       ├── carousel.tsx
│   │   │       ├── chart.tsx
│   │   │       ├── checkbox.tsx
│   │   │       ├── collapsible.tsx
│   │   │       ├── command.tsx
│   │   │       ├── context-menu.tsx
│   │   │       ├── dialog.tsx
│   │   │       ├── drawer.tsx
│   │   │       ├── dropdown-menu.tsx
│   │   │       ├── form.tsx
│   │   │       ├── hover-card.tsx
│   │   │       ├── input-otp.tsx
│   │   │       ├── input.tsx
│   │   │       ├── label.tsx
│   │   │       ├── menubar.tsx
│   │   │       ├── navigation-menu.tsx
│   │   │       ├── orbiting-circles.tsx
│   │   │       ├── pagination.tsx
│   │   │       ├── popover.tsx
│   │   │       ├── progress.tsx
│   │   │       ├── radio-group.tsx
│   │   │       ├── resizable.tsx
│   │   │       ├── scroll-area.tsx
│   │   │       ├── select.tsx
│   │   │       ├── separator.tsx
│   │   │       ├── sheet.tsx
│   │   │       ├── sidebar.tsx
│   │   │       ├── skeleton.tsx
│   │   │       ├── slider.tsx
│   │   │       ├── sonner.tsx
│   │   │       ├── switch.tsx
│   │   │       ├── table.tsx
│   │   │       ├── tabs.tsx
│   │   │       ├── textarea.tsx
│   │   │       ├── toast.tsx
│   │   │       ├── toaster.tsx
│   │   │       ├── toggle-group.tsx
│   │   │       ├── toggle.tsx
│   │   │       ├── tooltip.tsx
│   │   │       └── use-toast.ts
│   │   ├── hooks
│   │   │   ├── use-mobile.tsx
│   │   │   └── use-toast.ts
│   │   ├── index.css
│   │   ├── lib
│   │   │   └── utils.ts
│   │   ├── main.tsx
│   │   ├── pages
│   │   │   ├── Index.tsx
│   │   │   └── NotFound.tsx
│   │   └── vite-env.d.ts
│   ├── tailwind.config.ts
│   ├── tsconfig.app.json
│   ├── tsconfig.json
│   ├── tsconfig.node.json
│   ├── vercel.json
│   └── vite.config.ts
└── windows_setup_guide.md
```

# Files

--------------------------------------------------------------------------------
/docs/site/search/search_index.json:
--------------------------------------------------------------------------------

```json
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"],"fields":{"title":{"boost":1000.0},"text":{"boost":1.0},"tags":{"boost":1000000.0}}},"docs":[{"location":"","title":"Welcome to CodeGraphContext","text":"<p>This is the official documentation for CodeGraphContext.</p>"},{"location":"#codegraphcontext","title":"CodeGraphContext","text":"<p>A powerful MCP server and CLI toolkit that indexes local code into a graph database to provide context to AI assistants and developers. Use it as a standalone CLI for comprehensive code analysis or connect it to your favorite AI IDE via MCP for AI-powered code understanding.</p>"},{"location":"#indexing-a-codebase-cli-or-mcp","title":"Indexing a codebase (CLI or MCP)","text":""},{"location":"#using-the-mcp-server","title":"Using the MCP server","text":""},{"location":"#project-details","title":"Project Details","text":"<ul> <li>Version: 0.1.15</li> <li>Authors: Shashank Shekhar Singh [email protected]</li> <li>License: MIT License (See LICENSE for details)</li> <li>Website: CodeGraphContext</li> </ul>"},{"location":"#star-history","title":"Star History","text":""},{"location":"#features","title":"Features","text":"<ul> <li>Code Indexing: Analyzes code and builds a knowledge graph of its components.</li> <li>Relationship Analysis: Query for callers, callees, class hierarchies, call chains and more.</li> <li>Live File Watching: Watch directories for changes and automatically update the graph in real-time (<code>cgc watch</code>).</li> <li>Interactive Setup: A user-friendly command-line wizard for easy setup.</li> <li>Dual Mode: Works as a standalone CLI toolkit for developers and as an MCP server for AI agents.</li> <li>Multi-Language Support: Full support for 11 programming languages.</li> <li>Flexible Database Backend: FalkorDB Lite (default, inbuilt for Unix) or Neo4j (all platforms via Docker/WSL/native).</li> <li>File Exclusion: Supports <code>.cgcignore</code> files to exclude specific files and directories from indexing.</li> </ul>"},{"location":"#used-by","title":"Used By","text":"<p>CodeGraphContext is already being explored by developers and projects for:</p> <ul> <li>Static code analysis in AI assistants</li> <li>Graph-based visualization of projects</li> <li>Dead code and complexity detection</li> </ul> <p>If you\u2019re using CodeGraphContext in your project, feel free to open a PR and add it here! \ud83d\ude80</p>"},{"location":"#dependencies","title":"Dependencies","text":"<ul> <li><code>neo4j&gt;=5.15.0</code></li> <li><code>watchdog&gt;=3.0.0</code></li> <li><code>requests&gt;=2.31.0</code></li> <li><code>stdlibs&gt;=2023.11.18</code></li> <li><code>typer[all]&gt;=0.9.0</code></li> <li><code>rich&gt;=13.7.0</code></li> <li><code>inquirerpy&gt;=0.3.4</code></li> <li><code>python-dotenv&gt;=1.0.0</code></li> <li><code>tree-sitter==0.20.4</code></li> <li><code>tree-sitter-languages==1.10.2</code></li> </ul>"},{"location":"#getting-started","title":"Getting Started","text":"<ol> <li>Install: <code>pip install codegraphcontext</code></li> <li> <p>Configure Your Environment:     Run the interactive setup wizard to connect to your database and configure your IDE:     <code>bash     cgc mcp setup</code>     This ensures your IDE is configured. To configure a Neo4j database, use <code>cgc neo4j setup</code>.     The wizard helps you with:</p> <ul> <li>Database Connection:<ul> <li>Docker (Recommended): Automatically sets up a local Neo4j instance.</li> <li>Linux Binary: Installs Neo4j directly on Debian-based systems.</li> <li>Hosted: Connects to a remote Neo4j database like AuraDB.</li> </ul> </li> <li>IDE Integration:<ul> <li>Automatically configures tools like VS Code, Cursor, Gemini CLI, and more.</li> <li>Generates the necessary <code>mcp.json</code> and <code>.env</code> files for you.</li> </ul> </li> </ul> </li> <li> <p>Start: <code>cgc mcp start</code></p> </li> </ol>"},{"location":"#mcp-client-configuration","title":"MCP Client Configuration","text":"<p>The <code>cgc mcp setup</code> command attempts to automatically configure your IDE/CLI. If you choose not to use the automatic setup, or if your tool is not supported, you can configure it manually.</p> <p>Add the following server configuration to your client's settings file (e.g., VS Code's <code>settings.json</code> or <code>.claude.json</code>):</p> <pre><code>{\n  \"mcpServers\": {\n    \"CodeGraphContext\": {\n      \"command\": \"cgc\",\n      \"args\": [\n        \"mcp\",\n        \"start\"\n      ],\n      \"env\": {\n        \"NEO4J_URI\": \"YOUR_NEO4J_URI\",\n        \"NEO4J_USERNAME\": \"YOUR_NEO4J_USERNAME\",\n        \"NEO4J_PASSWORD\": \"YOUR_NEO4J_PASSWORD\"\n      },\n      \"tools\": {\n        \"alwaysAllow\": [\n          \"add_code_to_graph\",\n          \"add_package_to_graph\",\n          \"check_job_status\",\n          \"list_jobs\",\n          \"find_code\",\n          \"analyze_code_relationships\",\n          \"watch_directory\",\n          \"find_dead_code\",\n          \"execute_cypher_query\",\n          \"calculate_cyclomatic_complexity\",\n          \"find_most_complex_functions\",\n          \"list_indexed_repositories\",\n          \"delete_repository\",\n          \"visualize_graph_query\",\n          \"list_watched_paths\",\n          \"unwatch_directory\"\n        ],\n        \"disabled\": false\n      },\n      \"disabled\": false,\n      \"alwaysAllow\": []\n    }\n  }\n}\n</code></pre>"},{"location":"#natural-language-interaction-examples","title":"Natural Language Interaction Examples","text":"<p>Once the server is running, you can interact with it through your AI assistant using plain English. Here are some examples of what you can say:</p>"},{"location":"#indexing-and-watching-files","title":"Indexing and Watching Files","text":"<ul> <li> <p>To index a new project:</p> <ul> <li>\"Please index the code in the <code>/path/to/my-project</code> directory.\" OR</li> <li>\"Add the project at <code>~/dev/my-other-project</code> to the code graph.\"</li> </ul> </li> <li> <p>To start watching a directory for live changes:</p> <ul> <li>\"Watch the <code>/path/to/my-active-project</code> directory for changes.\" OR</li> <li>\"Keep the code graph updated for the project I'm working on at <code>~/dev/main-app</code>.\"</li> </ul> <p>When you ask to watch a directory, the system performs two actions at once: 1.  It kicks off a full scan to index all the code in that directory. This process runs in the background, and you'll receive a <code>job_id</code> to track its progress. 2.  It begins watching the directory for any file changes to keep the graph updated in real-time.</p> <p>This means you can start by simply telling the system to watch a directory, and it will handle both the initial indexing and the continuous updates automatically.</p> </li> </ul>"},{"location":"#querying-and-understanding-code","title":"Querying and Understanding Code","text":"<ul> <li> <p>Finding where code is defined:</p> <ul> <li>\"Where is the <code>process_payment</code> function?\"</li> <li>\"Find the <code>User</code> class for me.\"</li> <li>\"Show me any code related to 'database connection'.\"</li> </ul> </li> <li> <p>Analyzing relationships and impact:</p> <ul> <li>\"What other functions call the <code>get_user_by_id</code> function?\"</li> <li>\"If I change the <code>calculate_tax</code> function, what other parts of the code will be affected?\"</li> <li>\"Show me the inheritance hierarchy for the <code>BaseController</code> class.\"</li> <li>\"What methods does the <code>Order</code> class have?\"</li> </ul> </li> <li> <p>Exploring dependencies:</p> <ul> <li>\"Which files import the <code>requests</code> library?\"</li> <li>\"Find all implementations of the <code>render</code> method.\"</li> </ul> </li> <li> <p>Advanced Call Chain and Dependency Tracking (Spanning Hundreds of Files):     The CodeGraphContext excels at tracing complex execution flows and dependencies across vast codebases. Leveraging the power of graph databases, it can identify direct and indirect callers and callees, even when a function is called through multiple layers of abstraction or across numerous files. This is invaluable for:</p> <ul> <li>Impact Analysis: Understand the full ripple effect of a change to a core function.</li> <li>Debugging: Trace the path of execution from an entry point to a specific bug.</li> <li> <p>Code Comprehension: Grasp how different parts of a large system interact.</p> </li> <li> <p>\"Show me the full call chain from the <code>main</code> function to <code>process_data</code>.\"</p> </li> <li>\"Find all functions that directly or indirectly call <code>validate_input</code>.\"</li> <li>\"What are all the functions that <code>initialize_system</code> eventually calls?\"</li> <li>\"Trace the dependencies of the <code>DatabaseManager</code> module.\"</li> </ul> </li> <li> <p>Code Quality and Maintenance:</p> <ul> <li>\"Is there any dead or unused code in this project?\"</li> <li>\"Calculate the cyclomatic complexity of the <code>process_data</code> function in <code>src/utils.py</code>.\"</li> <li>\"Find the 5 most complex functions in the codebase.\"</li> </ul> </li> <li> <p>Repository Management:</p> <ul> <li>\"List all currently indexed repositories.\"</li> <li>\"Delete the indexed repository at <code>/path/to/old-project</code>.\"</li> </ul> </li> </ul>"},{"location":"#social-coverage","title":"Social Coverage","text":"<ul> <li>Youtube: https://www.youtube.com/watch?v=KYYSdxhg1xU</li> <li>Blog: https://medium.com/@shashankshekharsingh1205/building-codegraphcontext-my-end-term-journey-in-summer-of-bitcoin-2025-422c9a4dc87e</li> <li>Twitter: https://x.com/braidpool/status/1968683721625637203</li> <li>PulseMCP: https://www.pulsemcp.com/servers/codegraphcontext</li> <li>MCPMarket: https://mcpmarket.com/server/codegraphcontext</li> <li>Playbooks: https://playbooks.com/mcp/codegraphcontext</li> <li>MCPHunt: https://mcp-hunt.com/mcp/server/codegraphcontext</li> <li>StackerNews: https://stacker.news/items/1227191</li> <li>Glama.ai: https://glama.ai/mcp/servers/@Shashankss1205/CodeGraphContext/blob/a346d340d8f705ce93626b4b322dd0e2823ba46b/src/codegraphcontext/core/jobs.py</li> </ul>"},{"location":"#contributing","title":"Contributing","text":"<p>Contributions are welcome! \ud83c\udf89 Please see our CONTRIBUTING.md for detailed guidelines. If you have ideas for new features, integrations, or improvements, open an issue or submit a Pull Request.</p> <p>Join discussions and help shape the future of CodeGraphContext.</p>"},{"location":"architecture/","title":"Architecture Documentation","text":"<p>This document provides a detailed overview of the architecture of the CodeGraphContext project.</p>"},{"location":"architecture/#high-level-overview","title":"High-Level Overview","text":"<p>The project is a client-server application designed to analyze and visualize codebases. It consists of:</p> <ul> <li>A Python backend: This is the core of the application, responsible for parsing and analyzing code, building a graph representation of the codebase, and exposing this data through an API.</li> <li>A web-based frontend: A user interface for interacting with the backend, visualizing the code graph, and exploring the codebase.</li> <li>A command-line interface (CLI): For managing the backend and performing analysis from the terminal.</li> </ul>"},{"location":"architecture/#backend-architecture","title":"Backend Architecture","text":"<p>The backend is a Python application located in the <code>src/codegraphcontext</code> directory.</p>"},{"location":"architecture/#core-components","title":"Core Components","text":"<p>The <code>src/codegraphcontext/core</code> directory contains the fundamental building blocks of the backend:</p> <ul> <li>Database: A graph database is used to store the code graph. This allows for efficient querying of relationships between code elements (e.g., function calls, class inheritance).</li> <li>Jobs: Asynchronous jobs are used for long-running tasks like indexing a new codebase. This prevents the application from becoming unresponsive.</li> <li>Watcher: A file system watcher monitors the codebase for changes and triggers re-indexing, keeping the code graph up-to-date.</li> </ul>"},{"location":"architecture/#tools","title":"Tools","text":"<p>The <code>src/codegraphcontext/tools</code> directory contains the logic for code analysis:</p> <ul> <li>Graph Builder: This component is responsible for parsing the code and building the graph representation that is stored in the database.</li> <li>Code Finder: Provides functionality to search for specific code elements within the indexed codebase.</li> <li>Import Extractor: This tool analyzes the import statements in the code to understand dependencies between modules.</li> </ul>"},{"location":"architecture/#server","title":"Server","text":"<p>The <code>src/codegraphcontext/server.py</code> file implements the API server. It exposes the functionality of the backend to the frontend through a JSON-RPC API.</p>"},{"location":"architecture/#cli","title":"CLI","text":"<p>The <code>src/codegraphcontext/cli</code> directory contains the implementation of the command-line interface. It allows users to:</p> <ul> <li>Start and stop the backend server.</li> <li>Index new projects.</li> <li>Run analysis tools from the command line.</li> </ul>"},{"location":"architecture/#frontend-architecture","title":"Frontend Architecture","text":"<p>The frontend is a modern web application located in the <code>website/</code> directory.</p> <ul> <li>Framework: It is built using React and TypeScript.</li> <li>Build Tool: Vite is used for fast development and building the application.</li> <li>Component-Based: The UI is organized into reusable components, located in <code>website/src/components</code>. This includes UI elements like buttons and dialogs, as well as higher-level components for different sections of the application.</li> <li>Styling: Tailwind CSS is used for styling the application.</li> </ul>"},{"location":"architecture/#testing","title":"Testing","text":"<p>The <code>tests/</code> directory contains the test suite for the project.</p> <ul> <li>Integration Tests: <code>test_cgc_integration.py</code> contains tests that verify the interaction between different components of the backend.</li> <li>Unit Tests: Other files in this directory contain unit tests for specific modules and functions.</li> <li>Sample Project: The <code>tests/sample_project</code> directory contains a variety of Python files used as input for testing the code analysis tools.</li> </ul>"},{"location":"cli/","title":"CLI Reference","text":"<p>The CodeGraphContext CLI provides a comprehensive command-line interface to manage the server, index your code, search, analyzing and interact with the code graph.</p>"},{"location":"cli/#1-project-management","title":"1. Project Management","text":"<p>Use these commands to manage the repositories in your code graph.</p> Command Arguments Description <code>cgc index</code> <code>[path]</code> <code>--force</code> Adds a repository to the graph. Default path is current directory. Use <code>--force</code> to re-index from scratch.  (Alias: <code>cgc i</code>) <code>cgc list</code> None Lists all repositories currently indexed in the database.  (Alias: <code>cgc ls</code>) <code>cgc delete</code> <code>[path]</code> <code>--all</code> Removes a repository from the graph. Use <code>--all</code> to wipe everything.  (Alias: <code>cgc rm</code>) <code>cgc stats</code> <code>[path]</code> Shows indexing statistics (node counts) for the DB or a specific repo. <code>cgc clean</code> None Removes orphaned nodes and cleans up the database. <code>cgc add-package</code> <code>&lt;name&gt; &lt;lang&gt;</code> Manually adds an external package node (e.g., <code>cgc add-package requests python</code>)."},{"location":"cli/#2-watching-monitoring","title":"2. Watching &amp; Monitoring","text":"<p>Automatically track changes and keep your code graph up-to-date.</p> Command Arguments Description <code>cgc watch</code> <code>[path]</code> Watches a directory for file changes and automatically re-indexes. Runs in foreground. Default path is current directory.  (Alias: <code>cgc w</code>) <code>cgc unwatch</code> <code>&lt;path&gt;</code> Stops watching a previously watched directory. (Primarily for MCP mode) <code>cgc watching</code> None Lists all directories currently being watched for changes. (Primarily for MCP mode)"},{"location":"cli/#3-code-analysis","title":"3. Code Analysis","text":"<p>Understand the structure, quality, and relationships of your code.</p> Command Arguments Description <code>cgc analyze calls</code> <code>&lt;func_name&gt;</code> <code>--file</code> Shows outgoing calls: what functions does this function call? <code>cgc analyze callers</code> <code>&lt;func_name&gt;</code> <code>--file</code> Shows incoming calls: who calls this function? <code>cgc analyze chain</code> <code>&lt;start&gt; &lt;end&gt;</code> <code>--depth</code> Finds the call path between two functions. Default depth is 5. <code>cgc analyze deps</code> <code>&lt;module&gt;</code> <code>--no-external</code> Inspects dependencies (imports and importers) for a module. <code>cgc analyze tree</code> <code>&lt;class_name&gt;</code> <code>--file</code> Visualizes the Class Inheritance hierarchy for a given class. <code>cgc analyze complexity</code> <code>[path]</code> <code>--threshold</code> <code>--limit</code> Lists functions with high Cyclomatic Complexity. Default threshold: 10. <code>cgc analyze dead-code</code> <code>--exclude</code> Finds potentially unused functions (0 callers). Use <code>--exclude</code> for decorators."},{"location":"cli/#4-discovery-search","title":"4. Discovery &amp; Search","text":"<p>Find code elements when you don't know the exact structure.</p> Command Arguments Description <code>cgc find name</code> <code>&lt;name&gt;</code> <code>--type</code> Finds code elements (Class, Function) by their exact name. <code>cgc find pattern</code> <code>&lt;pattern&gt;</code> <code>--case-sensitive</code> Finds elements using fuzzy substring matching (e.g. \"User\" finds \"UserHelper\"). <code>cgc find type</code> <code>&lt;type&gt;</code> <code>--limit</code> Lists all nodes of a specific type (e.g. <code>function</code>, <code>class</code>, <code>module</code>)."},{"location":"cli/#5-configuration-setup","title":"5. Configuration &amp; Setup","text":"<p>Manage your environment and database connections.</p> Command Arguments Description <code>cgc mcp setup</code> None Configures your IDE/MCP Client. Creates <code>mcp.json</code>.  (Alias: <code>cgc m</code>) <code>cgc neo4j setup</code> None Wizard to configure a Neo4j connection.  (Alias: <code>cgc n</code>) <code>cgc config show</code> None Displays current configuration values. <code>cgc config set</code> <code>&lt;key&gt; &lt;value&gt;</code> Sets a config value (e.g. <code>DEFAULT_DATABASE</code>). <code>cgc config reset</code> None Resets configuration to defaults. <code>cgc config db</code> <code>&lt;backend&gt;</code> Quick switch between <code>neo4j</code> and <code>falkordb</code>."},{"location":"cli/#6-utilities-runtime","title":"6. Utilities &amp; Runtime","text":"<p>Helper commands for developers and the MCP server.</p> Command Arguments Description <code>cgc doctor</code> None Runs system diagnostics (DB connection, dependencies, permissions). <code>cgc visualize</code> <code>[query]</code> Generates a link to open the Neo4j Browser.  (Alias: <code>cgc v</code>) <code>cgc query</code> <code>&lt;query&gt;</code> Executes a raw Cypher query directly against the DB. <code>cgc mcp start</code> None Starts the MCP Server (used by IDEs). <code>cgc mcp tools</code> None Lists all available MCP tools supported by the server. <code>cgc start</code> None Deprecated. Use <code>cgc mcp start</code> instead."},{"location":"contributing/","title":"Contributing to CodeGraphContext","text":"<p>We welcome contributions! Please follow these steps:</p>"},{"location":"contributing/#general-guidelines","title":"General Guidelines","text":"<ul> <li>Ensure your code adheres to the existing style and conventions of the project.</li> <li>Write clear, concise, and well-documented code.</li> <li>All new features or bug fixes should be accompanied by appropriate tests.</li> <li>Keep your pull requests focused on a single feature or bug fix.</li> </ul>"},{"location":"contributing/#setting-up-your-development-environment","title":"Setting up Your Development Environment","text":"<ol> <li>Fork the repository.</li> <li>Set up your development environment: <code>pip install -e \".[dev]\"</code></li> <li>Create a new branch for your feature or bugfix (e.g., <code>git checkout -b feature/my-new-feature</code>).</li> </ol>"},{"location":"contributing/#debugging","title":"Debugging","text":"<p>To enable debug mode for detailed logging, locate the <code>debug_mode</code> variable in <code>src/codegraphcontext/tools/graph_builder.py</code> and set its value to <code>1</code>.</p> <pre><code># src/codegraphcontext/tools/graph_builder.py\ndebug_mode = 1\n</code></pre>"},{"location":"contributing/#running-tests","title":"Running Tests","text":"<p>Tests are located in the <code>tests/</code> directory and are run using <code>pytest</code>.</p> <ol> <li>Navigate to the root of the <code>CodeGraphContext</code> directory.</li> <li>Run all tests using the command: <code>pytest</code></li> <li>To run specific tests, you can provide the path to the test file, for example: <code>pytest tests/test_tools.py</code></li> <li>Skipping Re-indexing: To speed up test runs, especially during development, you can set the <code>CGC_SKIP_REINDEX</code> environment variable to <code>true</code>. This will prevent the test suite from re-indexing the sample project if it's already indexed.     <code>bash     CGC_SKIP_REINDEX=true pytest</code></li> </ol>"},{"location":"contributing/#submitting-changes","title":"Submitting Changes","text":"<ol> <li>Write your code and add corresponding tests in the <code>tests/</code> directory.</li> <li>Ensure all tests pass and your code lints without errors.</li> <li>Commit your changes with a descriptive commit message.</li> <li>Submit a pull request to the <code>main</code> branch.</li> </ol>"},{"location":"contributing_languages/","title":"Contributing New Language Support to CodeGraphContext","text":"<p>This document outlines the steps and best practices for adding support for a new programming language to CodeGraphContext. By following this guide, contributors can efficiently integrate new languages and leverage the Neo4j graph for verification.</p>"},{"location":"contributing_languages/#1-understanding-the-architecture","title":"1. Understanding the Architecture","text":"<p>CodeGraphContext uses a modular architecture for multi-language support:</p> <ul> <li>Generic <code>TreeSitterParser</code> (in <code>graph_builder.py</code>): This acts as a wrapper, dispatching parsing tasks to language-specific implementations.</li> <li>Language-Specific Parser Modules (in <code>src/codegraphcontext/tools/languages/</code>): Each language (e.g., Python, JavaScript) has its own module (e.g., <code>python.py</code>, <code>javascript.py</code>) containing:<ul> <li>Tree-sitter queries (<code>&lt;LANG&gt;_QUERIES</code>).</li> <li>A <code>&lt;Lang&gt;TreeSitterParser</code> class that encapsulates language-specific parsing logic.</li> <li>A <code>pre_scan_&lt;lang&gt;</code> function for initial symbol mapping.</li> </ul> </li> <li><code>GraphBuilder</code> (in <code>graph_builder.py</code>): Manages the overall graph building process, including file discovery, pre-scanning, and dispatching to the correct language parser.</li> </ul>"},{"location":"contributing_languages/#2-steps-to-add-a-new-language-eg-typescript-ts","title":"2. Steps to Add a New Language (e.g., TypeScript - <code>.ts</code>)","text":""},{"location":"contributing_languages/#step-21-create-the-language-module-file","title":"Step 2.1: Create the Language Module File","text":"<ol> <li>Create a new file: <code>src/codegraphcontext/tools/languages/typescript.py</code>.</li> <li>Add the necessary imports: <code>from pathlib import Path</code>, <code>from typing import Any, Dict, Optional, Tuple</code>, <code>import logging</code>, <code>import ast</code> (if needed for AST manipulation).</li> <li>Define <code>TS_QUERIES</code> (Tree-sitter queries for TypeScript).</li> <li>Create a <code>TypescriptTreeSitterParser</code> class.</li> <li>Create a <code>pre_scan_typescript</code> function.</li> </ol>"},{"location":"contributing_languages/#step-22-define-tree-sitter-queries-ts_queries","title":"Step 2.2: Define Tree-sitter Queries (<code>TS_QUERIES</code>)","text":"<p>This is the most critical and often iterative step. You'll need to define queries for:</p> <ul> <li><code>functions</code>: Function declarations, arrow functions, methods.</li> <li><code>classes</code>: Class declarations, class expressions.</li> <li><code>imports</code>: ES6 imports (<code>import ... from ...</code>), CommonJS <code>require()</code>.</li> <li><code>calls</code>: Function calls, method calls.</li> <li><code>variables</code>: Variable declarations (<code>let</code>, <code>const</code>, <code>var</code>).</li> <li><code>docstrings</code>: (Optional) How documentation comments are identified.</li> <li><code>lambda_assignments</code>: (Optional, Python-specific) If the language has similar constructs.</li> </ul> <p>Tips for Query Writing: *   Consult Tree-sitter Grammars: Find the <code>node-types.json</code> or grammar definition for your language (e.g., <code>tree-sitter-typescript</code>). *   Use <code>tree-sitter parse</code>: Use the <code>tree-sitter parse</code> command-line tool to inspect the AST of sample code snippets. This is invaluable for identifying correct node types and field names. *   Start Simple: Begin with basic queries and gradually add complexity. *   Test Iteratively: After each query, test it with sample code.</p>"},{"location":"contributing_languages/#step-23-implement-langtreesitterparser-class","title":"Step 2.3: Implement <code>&lt;Lang&gt;TreeSitterParser</code> Class","text":"<p>This class (e.g., <code>TypescriptTreeSitterParser</code>) will encapsulate the language-specific logic.</p> <ol> <li><code>__init__(self, generic_parser_wrapper)</code>:<ul> <li>Store <code>generic_parser_wrapper</code>, <code>language_name</code>, <code>language</code>, <code>parser</code> from the generic wrapper.</li> <li>Load <code>TS_QUERIES</code> using <code>self.language.query(query_str)</code>.</li> </ul> </li> <li>Helper Methods:<ul> <li><code>_get_node_text(self, node)</code>: Extracts text from a tree-sitter node.</li> <li><code>_get_parent_context(self, node, types=...)</code>: (Language-specific node types for context).</li> <li><code>_calculate_complexity(self, node)</code>: (Language-specific complexity nodes).</li> <li><code>_get_docstring(self, body_node)</code>: (Language-specific docstring extraction).</li> </ul> </li> <li><code>parse(self, file_path: Path, is_dependency: bool = False) -&gt; Dict</code>:<ul> <li>Reads the file, parses it with <code>self.parser</code>.</li> <li>Calls its own <code>_find_*</code> methods (<code>_find_functions</code>, <code>_find_classes</code>, etc.).</li> <li>Returns a standardized dictionary format (as seen in <code>python.py</code> and <code>javascript.py</code>).</li> </ul> </li> <li><code>_find_*</code> Methods:     Implement these for each query type, extracting data from the AST and populating the standardized dictionary.</li> </ol>"},{"location":"contributing_languages/#step-24-implement-pre_scan_lang-function","title":"Step 2.4: Implement <code>pre_scan_&lt;lang&gt;</code> Function","text":"<p>This function (e.g., <code>pre_scan_typescript</code>) will quickly scan files to build an initial <code>imports_map</code>.</p> <ol> <li>It takes <code>files: list[Path]</code> and <code>parser_wrapper</code> (an instance of <code>TreeSitterParser</code>).</li> <li>Uses a simplified query (e.g., for <code>class_declaration</code> and <code>function_declaration</code>) to quickly find definitions.</li> <li>Returns a dictionary mapping symbol names to file paths.</li> </ol>"},{"location":"contributing_languages/#step-25-integrate-into-graph_builderpy","title":"Step 2.5: Integrate into <code>graph_builder.py</code>","text":"<ol> <li><code>GraphBuilder.__init__</code>:<ul> <li>Add <code>'.ts': TreeSitterParser('typescript')</code> to <code>self.parsers</code>.</li> </ul> </li> <li><code>TreeSitterParser.__init__</code>:<ul> <li>Add an <code>elif self.language_name == 'typescript':</code> block to initialize <code>self.language_specific_parser</code> with <code>TypescriptTreeSitterParser(self)</code>.</li> </ul> </li> <li><code>GraphBuilder._pre_scan_for_imports</code>:<ul> <li>Add an <code>elif '.ts' in files_by_lang:</code> block to import <code>pre_scan_typescript</code> and call it.</li> </ul> </li> </ol>"},{"location":"contributing_languages/#3-verification-and-debugging-using-neo4j","title":"3. Verification and Debugging using Neo4j","text":"<p>After implementing support for a new language, it's crucial to verify that the graph is being built correctly.</p>"},{"location":"contributing_languages/#step-31-prepare-a-sample-project","title":"Step 3.1: Prepare a Sample Project","text":"<p>Create a small sample project for your new language (e.g., <code>tests/sample_project_typescript/</code>) with: *   Function declarations. *   Class declarations (including inheritance). *   Various import types (if applicable). *   Function calls. *   Variable declarations.</p>"},{"location":"contributing_languages/#step-32-index-the-sample-project","title":"Step 3.2: Index the Sample Project","text":"<ol> <li>Delete existing data (if any):     ```bash     # Replace with your sample project path     print(default_api.delete_repository(repo_path='/path/to/your/sample_project'))</li> <li>Index the project:     ```bash     # Replace with your sample project path     print(default_api.add_code_to_graph(path='/path/to/your/sample_project'))</li> <li>Monitor job status:     ```bash     # Use the job_id returned by add_code_to_graph     print(default_api.check_job_status(job_id=''))"},{"location":"contributing_languages/#step-33-query-the-neo4j-graph","title":"Step 3.3: Query the Neo4j Graph","text":"<p>Use Cypher queries to inspect the generated graph.</p> <ul> <li> <p>Check for Files and Language Tags: <code>cypher     MATCH (f:File)     WHERE f.path STARTS WITH '/path/to/your/sample_project'     RETURN f.name, f.path, f.lang</code> Expected: All files from your sample project should be listed with the correct <code>lang</code> tag.</p> </li> <li> <p>Check for Functions: <code>cypher     MATCH (f:File)-[:CONTAINS]-&gt;(fn:Function)     WHERE f.path STARTS WITH '/path/to/your/sample_project'       AND fn.lang = '&lt;your_language_name&gt;'     RETURN f.name AS FileName, fn.name AS FunctionName, fn.line_number AS Line</code> Expected: All functions from your sample project should be listed.</p> </li> <li> <p>Check for Classes: <code>cypher     MATCH (f:File)-[:CONTAINS]-&gt;(c:Class)     WHERE f.path STARTS WITH '/path/to/your/sample_project'       AND c.lang = '&lt;your_language_name&gt;'     RETURN f.name AS FileName, c.name AS ClassName, c.line_number AS Line</code> Expected: All classes from your sample project should be listed.</p> </li> <li> <p>Check for Imports (Module-level): <code>cypher     MATCH (f:File)-[:IMPORTS]-&gt;(m:Module)     WHERE f.path STARTS WITH '/path/to/your/sample_project'       AND f.lang = '&lt;your_language_name&gt;'     RETURN f.name AS FileName, m.name AS ImportedModule, m.full_import_name AS FullImportName</code> Expected: All module-level imports should be listed.</p> </li> <li> <p>Check for Function Calls: <code>cypher     MATCH (caller:Function)-[:CALLS]-&gt;(callee:Function)     WHERE caller.file_path STARTS WITH '/path/to/your/sample_project'       AND caller.lang = '&lt;your_language_name&gt;'     RETURN caller.name AS Caller, callee.name AS Callee, caller.file_path AS CallerFile, callee.file_path AS CalleeFile</code> Expected: All function calls should be correctly linked.</p> </li> <li> <p>Check for Class Inheritance: <code>cypher     MATCH (child:Class)-[:INHERITS]-&gt;(parent:Class)     WHERE child.file_path STARTS WITH '/path/to/your/sample_project'       AND child.lang = '&lt;your_language_name&gt;'     RETURN child.name AS ChildClass, parent.name AS ParentClass, child.file_path AS ChildFile, parent.file_path AS ParentFile</code> Expected: All inheritance relationships should be correctly linked.</p> </li> </ul>"},{"location":"contributing_languages/#step-34-debugging-common-issues","title":"Step 3.4: Debugging Common Issues","text":"<ul> <li><code>NameError: Invalid node type ...</code>: Your tree-sitter query is using a node type that doesn't exist in the language's grammar. Use <code>tree-sitter parse</code> to inspect the AST.</li> <li>Missing Relationships (e.g., <code>CALLS</code>, <code>IMPORTS</code>):<ul> <li>Check <code>_find_*</code> methods: Ensure your <code>_find_*</code> methods are correctly extracting the necessary data.</li> <li>Check <code>imports_map</code>: Verify that the <code>pre_scan_&lt;lang&gt;</code> function is correctly populating the <code>imports_map</code>.</li> <li>Check <code>local_imports</code> map: Ensure the <code>local_imports</code> map (built in <code>_create_function_calls</code> and <code>_create_inheritance_links</code>) is correctly resolving symbols.</li> </ul> </li> <li>Incorrect <code>lang</code> tags: Ensure <code>self.language_name</code> is correctly passed and stored.</li> </ul> <p>By following these steps, contributors can effectively add and verify new language support.</p>"},{"location":"cookbook/","title":"MCP Tool Cookbook","text":"<p>This cookbook provides examples of how to use the <code>mcp</code> tool to query and understand your Python codebase. The \"Tool\" indicates which <code>mcp</code> tool to use, and the \"JSON Arguments\" are what the LLM would provide to that tool.</p>"},{"location":"cookbook/#basic-queries","title":"Basic Queries","text":""},{"location":"cookbook/#1-find-a-specific-function-by-name","title":"1. Find a specific function by name","text":"<ul> <li>Natural Language: \"Where is the function <code>foo</code> defined?\"</li> <li>Tool: <code>find_code</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query\": \"foo\"\n}\n</code></pre>"},{"location":"cookbook/#2-find-all-calls-to-a-specific-function","title":"2. Find all calls to a specific function","text":"<ul> <li>Natural Language: \"Find all calls to the <code>helper</code> function.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_callers\",\n  \"target\": \"helper\"\n}\n</code></pre>"},{"location":"cookbook/#3-find-what-a-function-calls","title":"3. Find what a function calls","text":"<ul> <li>Natural Language: \"What functions are called inside the <code>foo</code> function?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_callees\",\n  \"target\": \"foo\",\n  \"context\": \"/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py\"\n}\n</code></pre>"},{"location":"cookbook/#4-find-all-imports-of-a-specific-module","title":"4. Find all imports of a specific module","text":"<ul> <li>Natural Language: \"Where is the <code>math</code> module imported?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_importers\",\n  \"target\": \"math\"\n}\n</code></pre>"},{"location":"cookbook/#5-find-all-methods-of-a-class","title":"5. Find all methods of a class","text":"<ul> <li>Natural Language: \"What are the methods of the <code>A</code> class?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"class_hierarchy\",\n  \"target\": \"A\"\n}\n</code></pre> <ul> <li>Note: The response for <code>class_hierarchy</code> includes a list of methods.</li> </ul>"},{"location":"cookbook/#6-find-all-classes-that-inherit-from-a-specific-class","title":"6. Find all classes that inherit from a specific class","text":"<ul> <li>Natural Language: \"Show me all classes that inherit from <code>Base</code>.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"class_hierarchy\",\n  \"target\": \"Base\"\n}\n</code></pre> <ul> <li>Note: The response for <code>class_hierarchy</code> includes a list of child classes.</li> </ul>"},{"location":"cookbook/#7-find-all-functions-with-a-specific-decorator","title":"7. Find all functions with a specific decorator","text":"<ul> <li>Natural Language: \"Find all functions with the <code>log_decorator</code>.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_functions_by_decorator\",\n  \"target\": \"log_decorator\"\n}\n</code></pre>"},{"location":"cookbook/#8-find-all-dataclasses","title":"8. Find all dataclasses","text":"<ul> <li>Natural Language: \"Find all dataclasses.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class) WHERE 'dataclass' IN c.decorators RETURN c.name, c.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#code-analysis-quality","title":"Code Analysis &amp; Quality","text":""},{"location":"cookbook/#9-find-the-5-most-complex-functions","title":"9. Find the 5 most complex functions","text":"<ul> <li>Natural Language: \"Find the 5 most complex functions.\"</li> <li>Tool: <code>find_most_complex_functions</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"limit\": 5\n}\n</code></pre>"},{"location":"cookbook/#10-calculate-cyclomatic-complexity-of-a-function","title":"10. Calculate cyclomatic complexity of a function","text":"<ul> <li>Natural Language: \"What is the cyclomatic complexity of <code>try_except_finally</code>?\"</li> <li>Tool: <code>calculate_cyclomatic_complexity</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"function_name\": \"try_except_finally\"\n}\n</code></pre>"},{"location":"cookbook/#11-find-unused-code","title":"11. Find unused code","text":"<ul> <li>Natural Language: \"Find unused code, but ignore API endpoints decorated with <code>@app.route</code>.\"</li> <li>Tool: <code>find_dead_code</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"exclude_decorated_with\": [\"@app.route\"]\n}\n</code></pre>"},{"location":"cookbook/#12-find-the-call-chain-between-two-functions","title":"12. Find the call chain between two functions","text":"<ul> <li>Natural Language: \"What is the call chain from <code>wrapper</code> to <code>helper</code>?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"call_chain\",\n  \"target\": \"wrapper-&gt;helper\"\n}\n</code></pre>"},{"location":"cookbook/#13-find-all-direct-and-indirect-callers-of-a-function","title":"13. Find all direct and indirect callers of a function","text":"<ul> <li>Natural Language: \"Show me all functions that eventually call the <code>helper</code> function.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_all_callers\",\n  \"target\": \"helper\"\n}\n</code></pre>"},{"location":"cookbook/#14-find-functions-by-argument-name","title":"14. Find functions by argument name","text":"<ul> <li>Natural Language: \"Find all functions that take <code>self</code> as an argument.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_functions_by_argument\",\n  \"target\": \"self\"\n}\n</code></pre>"},{"location":"cookbook/#15-list-all-python-package-imports-from-a-directory","title":"15. List all python package imports from a directory","text":"<ul> <li>Natural Language: \"List all python package imports from my project directory.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:File)-[:IMPORTS]-&gt;(m:Module) WHERE f.path ENDS WITH '.py' RETURN DISTINCT m.name\"\n}\n</code></pre>"},{"location":"cookbook/#repository-information-queries","title":"Repository Information Queries","text":""},{"location":"cookbook/#16-list-all-indexed-projects","title":"16. List all indexed projects","text":"<ul> <li>Natural Language: \"List all projects I have indexed.\"</li> <li>Tool: <code>list_indexed_repositories</code></li> <li>JSON Arguments:</li> </ul> <pre><code>  {}\n</code></pre>"},{"location":"cookbook/#17-check-the-status-of-an-indexing-job","title":"17. Check the status of an indexing job","text":"<ul> <li>Natural Language: \"What is the status of job <code>4cb9a60e-c1b1-43a7-9c94-c840771506bc</code>?\"</li> <li>Tool: <code>check_job_status</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"job_id\": \"4cb9a60e-c1b1-43a7-9c94-c840771506bc\"\n}\n</code></pre>"},{"location":"cookbook/#18-list-all-background-jobs","title":"18. List all background jobs","text":"<ul> <li>Natural Language: \"Show me all background jobs.\"</li> <li>Tool: <code>list_jobs</code></li> <li>JSON Arguments:</li> </ul> <pre><code>  {}\n</code></pre>"},{"location":"cookbook/#advanced-cypher-queries","title":"Advanced Cypher Queries","text":"<p>These examples use the <code>execute_cypher_query</code> tool for more specific and complex questions.</p>"},{"location":"cookbook/#19-find-all-function-definitions","title":"19. Find all function definitions","text":"<ul> <li>Natural Language: \"Find all function definitions in the codebase.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (n:Function) RETURN n.name, n.file_path, n.line_number LIMIT 50\"\n}\n</code></pre>"},{"location":"cookbook/#20-find-all-classes","title":"20. Find all classes","text":"<ul> <li>Natural Language: \"Show me all the classes.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (n:Class) RETURN n.name, n.file_path, n.line_number LIMIT 50\"\n}\n</code></pre>"},{"location":"cookbook/#21-find-all-functions-in-a-file","title":"21. Find all functions in a file","text":"<ul> <li>Natural Language: \"Find all functions in <code>module_a.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' RETURN f.name\"\n}\n</code></pre>"},{"location":"cookbook/#22-find-all-classes-in-a-file","title":"22. Find all classes in a file","text":"<ul> <li>Natural Language: \"Find all classes in <code>advanced_classes.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class) WHERE c.file_path ENDS WITH 'advanced_classes.py' RETURN c.name\"\n}\n</code></pre>"},{"location":"cookbook/#23-list-all-top-level-functions-and-classes-in-a-file","title":"23. List all top-level functions and classes in a file","text":"<ul> <li>Natural Language: \"List all top-level functions and classes in <code>module_a.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:File)-[:CONTAINS]-&gt;(n) WHERE f.name = 'module_a.py' AND (n:Function OR n:Class) AND n.context IS NULL RETURN n.name\"\n}\n</code></pre>"},{"location":"cookbook/#24-find-functions-in-one-module-that-call-a-function-in-another","title":"24. Find functions in one module that call a function in another","text":"<ul> <li>Natural Language: \"Find functions in <code>module_a.py</code> that call <code>helper</code> in <code>module_b.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (caller:Function)-[:CALLS]-&gt;(callee:Function {name: 'helper'}) WHERE caller.file_path ENDS WITH 'module_a.py' AND callee.file_path ENDS WITH 'module_b.py' RETURN caller.name\"\n}\n</code></pre>"},{"location":"cookbook/#25-find-circular-file-imports","title":"25. Find circular file imports","text":"<ul> <li>Natural Language: \"Are there any circular dependencies between files?\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f1:File)-[:IMPORTS]-&gt;(m2:Module), (f2:File)-[:IMPORTS]-&gt;(m1:Module) WHERE f1.name = m1.name + '.py' AND f2.name = m2.name + '.py' RETURN f1.name, f2.name\"\n}\n</code></pre>"},{"location":"cookbook/#26-find-all-functions-with-more-than-5-arguments","title":"26. Find all functions with more than 5 arguments","text":"<ul> <li>Natural Language: \"Find all functions with a large number of arguments.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE size(f.args) &gt; 5 RETURN f.name, f.file_path, size(f.args) as arg_count\"\n}\n</code></pre>"},{"location":"cookbook/#27-find-all-functions-in-a-file-that-have-a-docstring","title":"27. Find all functions in a file that have a docstring","text":"<ul> <li>Natural Language: \"Find all functions in <code>module_a.py</code> that have a docstring.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' AND f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name\"\n}\n</code></pre>"},{"location":"cookbook/#28-find-all-classes-that-have-a-specific-method","title":"28. Find all classes that have a specific method","text":"<ul> <li>Natural Language: \"Find all classes that have a <code>greet</code> method.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class)-[:CONTAINS]-&gt;(m:Function {name: 'greet'}) RETURN c.name, c.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#29-find-the-depth-of-inheritance-for-all-classes","title":"29. Find the depth of inheritance for all classes","text":"<ul> <li>Natural Language: \"How deep are the inheritance chains for all classes?\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class) OPTIONAL MATCH path = (c)-[:INHERITS*]-&gt;(parent:Class) RETURN c.name, c.file_path, length(path) AS depth ORDER BY depth DESC\"\n}\n</code></pre>"},{"location":"cookbook/#30-find-all-functions-that-have-a-docstring","title":"30. Find all functions that have a docstring","text":"<ul> <li>Natural Language: \"Show me all functions that are documented.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name, f.file_path LIMIT 50\"\n}\n</code></pre>"},{"location":"cookbook/#31-find-all-decorated-methods-in-a-class","title":"31. Find all decorated methods in a class","text":"<ul> <li>Natural Language: \"Find all decorated methods in the <code>Child</code> class.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class {name: 'Child'})-[:CONTAINS]-&gt;(m:Function) WHERE m.decorators IS NOT NULL AND size(m.decorators) &gt; 0 RETURN m.name\"\n}\n</code></pre>"},{"location":"cookbook/#32-find-the-number-of-functions-in-each-file","title":"32. Find the number of functions in each file","text":"<ul> <li>Natural Language: \"How many functions are in each file?\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) RETURN f.file_path, count(f) AS function_count ORDER BY function_count DESC\"\n}\n</code></pre>"},{"location":"cookbook/#33-find-all-methods-that-override-a-parent-method","title":"33. Find all methods that override a parent method","text":"<ul> <li>Natural Language: \"Find all methods that are overridden from a parent class.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class)-[:INHERITS]-&gt;(p:Class), (c)-[:CONTAINS]-&gt;(m:Function), (p)-[:CONTAINS]-&gt;(m_parent:Function) WHERE m.name = m_parent.name RETURN m.name as method, c.name as child_class, p.name as parent_class\"\n}\n</code></pre>"},{"location":"cookbook/#34-find-all-functions-that-call-super","title":"34. Find all functions that call <code>super()</code>","text":"<ul> <li>Natural Language: \"Find all methods that call their parent's method via <code>super()</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function)-[r:CALLS]-&gt;() WHERE r.full_call_name STARTS WITH 'super(' RETURN f.name, f.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#35-find-all-calls-to-a-function-with-a-specific-argument","title":"35. Find all calls to a function with a specific argument","text":"<ul> <li>Natural Language: \"Find all calls to <code>helper</code> with the argument <code>x</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH ()-[r:CALLS]-&gt;(f:Function {name: 'helper'}) WHERE 'x' IN r.args RETURN r.full_call_name, r.line_number, r.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#36-find-all-functions-that-are-not-called-by-any-other-function","title":"36. Find all functions that are not called by any other function","text":"<ul> <li>Natural Language: \"Find all dead code (functions that are never called).\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE NOT (()-[:CALLS]-&gt;(f)) AND f.is_dependency = false RETURN f.name, f.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#37-find-all-functions-that-are-called-with-a-specific-argument","title":"37. Find all functions that are called with a specific argument","text":"<ul> <li>Natural Language: \"Find all calls to <code>print</code> with the argument <code>'hello'</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Call) WHERE c.name = 'print' AND 'hello' IN c.args RETURN c.file, c.lineno\"\n}\n</code></pre>"},{"location":"cookbook/#38-find-all-direct-and-indirect-callees-of-a-function","title":"38. Find all direct and indirect callees of a function","text":"<ul> <li>Natural Language: \"Show me all functions that are eventually called by the <code>foo</code> function.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_all_callees\",\n  \"target\": \"foo\",\n  \"context\": \"/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py\"\n}\n</code></pre>"},{"location":"cookbook/#39-find-all-functions-that-are-overridden","title":"39. Find all functions that are overridden","text":"<ul> <li>Natural Language: \"Find all functions that are overridden.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"overrides\",\n  \"target\": \"foo\"\n}\n</code></pre>"},{"location":"cookbook/#40-find-all-modules-imported-by-module_a","title":"40. Find all modules imported by <code>module_a</code>","text":"<ul> <li>Natural Language: \"Find all modules imported by <code>module_a</code>.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:File {name: 'module_a.py'})-[:IMPORTS]-&gt;(m:Module) RETURN m.name AS imported_module_name\"\n}\n</code></pre>"},{"location":"cookbook/#41-find-large-functions-that-should-be-refactored","title":"41. Find large functions that should be refactored","text":"<ul> <li>Natural Language: \"Find functions with more than 20 lines of code that might need refactoring.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function)\\n    WHERE f.end_line - f.line_number &gt; 20\\n    RETURN f\"\n}\n</code></pre>"},{"location":"cookbook/#42-find-recursive-functions","title":"42. Find recursive functions","text":"<ul> <li>Natural Language: \"Find all functions that call themselves (recursive functions).\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH p=(f:Function)-[:CALLS]-&gt;(f2:Function)\\n    WHERE f.name = f2.name AND f.file_path = f2.file_path\\n    RETURN p\"\n}\n</code></pre>"},{"location":"cookbook/#43-find-most-connected-functions-hub-functions","title":"43. Find most connected functions (hub functions)","text":"<ul> <li>Natural Language: \"Find the functions that are most central to the codebase (called by many and call many others).\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function)\\n    OPTIONAL MATCH (f)-[:CALLS]-&gt;(callee:Function)\\n    OPTIONAL MATCH (caller:Function)-[:CALLS]-&gt;(f)\\n    WITH f, count(DISTINCT callee) AS calls_out, count(DISTINCT caller) AS calls_in\\n    ORDER BY (calls_out + calls_in) DESC\\n    LIMIT 5\\n    MATCH p=(f)-[*0..2]-()\\n    RETURN p\"\n}\n</code></pre>"},{"location":"cookbook/#security-sensitive-data-analysis","title":"Security &amp; Sensitive Data Analysis","text":""},{"location":"cookbook/#44-find-potential-security-vulnerabilities-hardcoded-secrets","title":"44. Find potential security vulnerabilities (hardcoded secrets)","text":"<ul> <li>Natural Language: \"Find potential hardcoded passwords, API keys, or secrets in the codebase.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"WITH [\\\"password\\\",  \\\"api_key\\\", \\\"apikey\\\",    \\\"secret_token\\\", \\\"token\\\", \\\"auth\\\", \\\"access_key\\\", \\\"private_key\\\", \\\"client_secret\\\", \\\"sessionid\\\", \\\"jwt\\\"] AS keywords\\n    MATCH (f:Function)\\n    WHERE ANY(word IN keywords WHERE toLower(f.source_code) CONTAINS word)\\n    RETURN f\"\n}\n</code></pre>"},{"location":"core/","title":"Core Concepts","text":"<p>The core of CodeGraphContext is built upon a few key components that manage the database connection, handle background tasks, and watch for file system changes.</p>"},{"location":"core/#databasemanager","title":"<code>DatabaseManager</code>","text":"<p>The <code>DatabaseManager</code> class in <code>database.py</code> is a thread-safe singleton responsible for managing the connection to the Neo4j database. This ensures that only one connection pool is created and shared across the application, which is crucial for performance and resource management.</p>"},{"location":"core/#key-methods","title":"Key Methods","text":"<ul> <li><code>get_driver()</code>: Returns the active Neo4j Driver instance, creating it if it doesn't exist.</li> <li><code>close_driver()</code>: Closes the Neo4j driver connection.</li> <li><code>is_connected()</code>: Checks if the database connection is currently active.</li> </ul>"},{"location":"core/#jobmanager","title":"<code>JobManager</code>","text":"<p>The <code>JobManager</code> class in <code>jobs.py</code> handles long-running, background jobs, such as code indexing. It stores job information in memory and provides a thread-safe way to create, update, and retrieve information about these jobs.</p>"},{"location":"core/#jobstatus","title":"<code>JobStatus</code>","text":"<p>An enumeration for the possible statuses of a background job: - <code>PENDING</code> - <code>RUNNING</code> - <code>COMPLETED</code> - <code>FAILED</code> - <code>CANCELLED</code></p>"},{"location":"core/#jobinfo","title":"<code>JobInfo</code>","text":"<p>A data class that holds all information about a single background job, including its ID, status, start/end times, progress, and any errors.</p>"},{"location":"core/#key-methods_1","title":"Key Methods","text":"<ul> <li><code>create_job()</code>: Creates a new job with a unique ID.</li> <li><code>update_job()</code>: Updates the information for a specific job.</li> <li><code>get_job()</code>: Retrieves the information for a single job.</li> <li><code>list_jobs()</code>: Returns a list of all jobs.</li> <li><code>cleanup_old_jobs()</code>: Removes old, completed jobs from memory.</li> </ul>"},{"location":"core/#codewatcher","title":"<code>CodeWatcher</code>","text":"<p>The <code>CodeWatcher</code> class in <code>watcher.py</code> implements the live file-watching functionality using the <code>watchdog</code> library. It observes directories for changes and triggers updates to the code graph.</p>"},{"location":"core/#repositoryeventhandler","title":"<code>RepositoryEventHandler</code>","text":"<p>A dedicated event handler for a single repository. It performs an initial scan and then uses a debouncing mechanism to efficiently handle file changes, creations, or deletions.</p>"},{"location":"core/#key-methods_2","title":"Key Methods","text":"<ul> <li><code>watch_directory()</code>: Schedules a directory to be watched for changes.</li> <li><code>unwatch_directory()</code>: Stops watching a directory.</li> <li><code>list_watched_paths()</code>: Returns a list of all currently watched directory paths.</li> <li><code>start()</code>: Starts the observer thread.</li> <li><code>stop()</code>: Stops the observer thread gracefully.</li> </ul>"},{"location":"future_work/","title":"Ongoing Concerns and Future Work","text":"<p>This page outlines some of the current limitations of CodeGraphContext and areas for future development.</p>"},{"location":"future_work/#semantic-search","title":"Semantic Search","text":"<p>The tool is smart enough to find and analyze a function through millions of code files, but the tool is not yet smart enough to understand that a user searching for \u201ccalculate_sum\u201d is also intending to look at the \u201ccalculate_addition\u201d function. This level of semantic similarity needs to be researched, developed, tested and eventually implemented by our tool.</p>"},{"location":"installation/","title":"Installation","text":""},{"location":"installation/#installation-guide","title":"\ud83e\udde9 Installation Guide","text":"<p>Welcome to CodeGraphContext! This guide provides a clear and seamless path to installing and configuring the tool.</p>"},{"location":"installation/#understanding-codegraphcontext-modes","title":"\ud83d\udccb Understanding CodeGraphContext Modes","text":"<p>CodeGraphContext operates in two modes, and you can use either or both:</p>"},{"location":"installation/#mode-1-cli-toolkit-standalone","title":"\ud83d\udee0\ufe0f Mode 1: CLI Toolkit (Standalone)","text":"<p>Use CodeGraphContext as a powerful command-line toolkit for code analysis: - Index and analyze codebases directly from your terminal - Query code relationships, find dead code, analyze complexity - Visualize code graphs and dependencies - Perfect for developers who want direct control via CLI commands</p>"},{"location":"installation/#mode-2-mcp-server-ai-powered","title":"\ud83e\udd16 Mode 2: MCP Server (AI-Powered)","text":"<p>Use CodeGraphContext as an MCP server for AI assistants: - Connect to AI IDEs (VS Code, Cursor, Windsurf, Claude, etc.) - Let AI agents query your codebase using natural language - Automatic code understanding and relationship analysis - Perfect for AI-assisted development workflows</p> <p>You can use both modes! Install once, then use CLI commands directly OR connect to your AI assistant.</p>"},{"location":"installation/#prerequisites","title":"\u2699\ufe0f Prerequisites","text":"<p>Ensure the following are installed before you begin:</p> <ul> <li>Python: Version 3.10 or higher (3.12+ recommended for FalkorDB Lite support)</li> <li>AI Assistant (optional): An MCP-compatible tool (e.g., VS Code, Cursor, Claude, Gemini CLI) if you plan to use Mode 2</li> </ul>"},{"location":"installation/#installation","title":"\ud83d\ude80 Installation","text":""},{"location":"installation/#step-1-install-from-pypi","title":"Step 1: Install from PyPI","text":"<p>Install the <code>codegraphcontext</code> package using pip:</p> <pre><code>pip install codegraphcontext\n</code></pre>"},{"location":"installation/#step-2-database-setup","title":"Step 2: Database Setup","text":"<p>CodeGraphContext uses a graph database to store code relationships. You have two options:</p>"},{"location":"installation/#option-a-falkordb-lite-default-recommended","title":"Option A: FalkorDB Lite (Default - Recommended)","text":"<ul> <li>Automatic on Unix/Linux/macOS/WSL with Python 3.12+</li> <li>No configuration needed - works out of the box</li> <li>Lightweight, in-memory, perfect for most use cases</li> </ul> <p>If you're on Unix/Linux/macOS/WSL with Python 3.12+, you're done! Skip to Step 3.</p>"},{"location":"installation/#option-b-neo4j-alternative","title":"Option B: Neo4j (Alternative)","text":"<ul> <li>Available on all platforms (Windows, Linux, macOS)</li> <li>Required if you're on Windows without WSL or prefer Neo4j</li> <li>Can be installed via Docker, native installation, or cloud (AuraDB)</li> </ul> <p>To set up Neo4j, run:</p> <pre><code>cgc neo4j setup\n</code></pre> <p>The wizard will guide you through: - Docker (recommended): Automatically sets up a local Neo4j container - Native Installation: Installs Neo4j directly on Debian-based systems or macOS - Hosted/AuraDB: Connect to a remote Neo4j instance - Existing Instance: Use your own Neo4j server</p>"},{"location":"installation/#mode-specific-setup","title":"\ud83c\udfaf Mode-Specific Setup","text":""},{"location":"installation/#for-cli-toolkit-mode-mode-1","title":"For CLI Toolkit Mode (Mode 1)","text":"<p>You're ready to go! Start using CLI commands:</p> <pre><code># Index your current directory\ncgc index .\n\n# List indexed repositories\ncgc list\n\n# Analyze code relationships\ncgc analyze callers my_function\n\n# Find complex functions\ncgc analyze complexity --threshold 10\n\n# See all available commands\ncgc --help\n</code></pre> <p>See the CLI Reference for all available commands.</p>"},{"location":"installation/#for-mcp-server-mode-mode-2","title":"For MCP Server Mode (Mode 2)","text":"<p>Configure your AI assistant to connect to CodeGraphContext:</p>"},{"location":"installation/#step-1-run-mcp-setup-wizard","title":"Step 1: Run MCP Setup Wizard","text":"<pre><code>cgc mcp setup\n</code></pre> <p>The wizard will: - Detect your installed AI tools (VS Code, Cursor, Claude, etc.) - Automatically configure the selected tool - Generate <code>mcp.json</code> configuration file - Store credentials securely in <code>~/.codegraphcontext/.env</code></p> <p>Supported AI Tools: - VS Code - Cursor - Windsurf - Claude Desktop - Gemini CLI - ChatGPT Codex - Cline - RooCode - Amazon Q Developer</p>"},{"location":"installation/#step-2-start-the-mcp-server","title":"Step 2: Start the MCP Server","text":"<pre><code>cgc mcp start\n</code></pre> <p>Your MCP server is now running and ready to receive requests from your AI assistant!</p>"},{"location":"installation/#manual-configuration-optional","title":"Manual Configuration (Optional)","text":"<p>If you prefer to configure manually or your tool isn't auto-detected, add this to your tool's settings file:</p> <pre><code>{\n  \"mcpServers\": {\n    \"CodeGraphContext\": {\n      \"command\": \"cgc\",\n      \"args\": [\"mcp\", \"start\"],\n      \"env\": {\n        \"NEO4J_URI\": \"bolt://localhost:7687\",\n        \"NEO4J_USERNAME\": \"neo4j\",\n        \"NEO4J_PASSWORD\": \"your-password\"\n      }\n    }\n  }\n}\n</code></pre> <p>Note: If using FalkorDB Lite (default), you don't need to set NEO4J_* environment variables.</p>"},{"location":"installation/#quick-start-examples","title":"\ud83e\udded Quick Start Examples","text":""},{"location":"installation/#cli-toolkit-workflow","title":"CLI Toolkit Workflow","text":"<pre><code># Install\npip install codegraphcontext\n\n# Index a project\ncgc index /path/to/my-project\n\n# Find all callers of a function\ncgc analyze callers process_payment\n\n# Find dead code\ncgc analyze dead-code\n\n# Check database stats\ncgc stats\n</code></pre>"},{"location":"installation/#mcp-server-workflow","title":"MCP Server Workflow","text":"<pre><code># Install\npip install codegraphcontext\n\n# Configure your AI assistant\ncgc mcp setup\n\n# Start the server\ncgc mcp start\n\n# Now use natural language in your AI assistant:\n# \"Index the code in /path/to/my-project\"\n# \"Find all functions that call process_payment\"\n# \"Show me the class hierarchy for UserController\"\n</code></pre>"},{"location":"installation/#database-configuration-details","title":"\ud83d\udd27 Database Configuration Details","text":""},{"location":"installation/#falkordb-lite-default","title":"FalkorDB Lite (Default)","text":"<ul> <li>Platform: Unix/Linux/macOS/WSL</li> <li>Python: 3.12+ required</li> <li>Setup: Automatic, no configuration needed</li> <li>Storage: In-memory</li> <li>Best for: Most use cases, quick testing, development</li> </ul>"},{"location":"installation/#neo4j","title":"Neo4j","text":"<ul> <li>Platform: All (Windows, Linux, macOS)</li> <li>Python: 3.10+ supported</li> <li>Setup: Via <code>cgc neo4j setup</code> wizard</li> <li>Storage: Persistent disk storage</li> <li>Best for: Windows users, production deployments, large codebases</li> </ul>"},{"location":"installation/#next-steps","title":"\ud83d\udcda Next Steps","text":""},{"location":"installation/#for-cli-users","title":"For CLI Users","text":"<ul> <li>Explore the CLI Reference for all available commands</li> <li>Check out the Cookbook for common analysis patterns</li> <li>Learn about Code Analysis capabilities</li> </ul>"},{"location":"installation/#for-mcp-users","title":"For MCP Users","text":"<ul> <li>See MCP Tools Documentation for available AI tools</li> <li>Review Natural Language Examples</li> <li>Explore the Use Cases guide</li> </ul>"},{"location":"installation/#troubleshooting","title":"\ud83c\udd98 Troubleshooting","text":"<p>If you encounter issues, see our Troubleshooting Guide for common problems and solutions.</p> <p>Common Issues: - \"cgc: command not found\": Run the PATH fix script (see main README) - Database connection errors: Ensure Neo4j is running (if using Neo4j) or Python 3.12+ (if using FalkorDB) - MCP server won't start: Check that your AI assistant is properly configured</p> <p>With CodeGraphContext installed, you're ready to explore powerful code analysis capabilities! Happy coding \u2728!</p>"},{"location":"license/","title":"License","text":"<p>CodeGraphContext is licensed under the MIT License.</p> <pre><code>MIT License\n\nCopyright (c) 2025\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n</code></pre>"},{"location":"server/","title":"MCPServer","text":"<p>The <code>MCPServer</code> class is the core of the CodeGraphContext application. It orchestrates all the major components, including database management, background job tracking, file system watching, and tool handling.</p>"},{"location":"server/#initialization","title":"Initialization","text":"<p>The server is initialized with an asyncio event loop. Upon initialization, it sets up the following components:</p> <ul> <li><code>DatabaseManager</code>: Manages the connection to the Neo4j database.</li> <li><code>JobManager</code>: Tracks the status of background jobs, such as code indexing.</li> <li><code>CodeWatcher</code>: Monitors the file system for changes to keep the code graph up-to-date.</li> <li><code>GraphBuilder</code>: Builds the code graph from the source code.</li> <li><code>CodeFinder</code>: Provides tools for searching and analyzing the code graph.</li> </ul>"},{"location":"server/#tool-manifest","title":"Tool Manifest","text":"<p>The <code>MCPServer</code> exposes a set of tools to the AI assistant. These tools are defined in the <code>_init_tools</code> method. Here is a list of available tools:</p>"},{"location":"server/#add_code_to_graph","title":"<code>add_code_to_graph</code>","text":"<p>Performs a one-time scan of a local folder to add its code to the graph. Ideal for indexing libraries, dependencies, or projects not being actively modified. Returns a job ID for background processing.</p>"},{"location":"server/#check_job_status","title":"<code>check_job_status</code>","text":"<p>Check the status and progress of a background job.</p>"},{"location":"server/#list_jobs","title":"<code>list_jobs</code>","text":"<p>List all background jobs and their current status.</p>"},{"location":"server/#find_code","title":"<code>find_code</code>","text":"<p>Find relevant code snippets related to a keyword (e.g., function name, class name, or content).</p>"},{"location":"server/#analyze_code_relationships","title":"<code>analyze_code_relationships</code>","text":"<p>Analyze code relationships like 'who calls this function' or 'class hierarchy'. Supported query types include: find_callers, find_callees, find_all_callers, find_all_callees, find_importers, who_modifies, class_hierarchy, overrides, dead_code, call_chain, module_deps, variable_scope, find_complexity, find_functions_by_argument, find_functions_by_decorator.</p>"},{"location":"server/#watch_directory","title":"<code>watch_directory</code>","text":"<p>Performs an initial scan of a directory and then continuously monitors it for changes, automatically keeping the graph up-to-date. Ideal for projects under active development. Returns a job ID for the initial scan.</p>"},{"location":"server/#execute_cypher_query","title":"<code>execute_cypher_query</code>","text":"<p>This is an advanced tool for directly querying the underlying Neo4j graph using a read-only Cypher query. It should be used as a fallback when other tools cannot answer very specific or complex questions about the code graph.</p> <p>Schema Overview:</p> <p>The code graph has the following structure:</p> <ul> <li>Nodes:<ul> <li><code>Repository</code>: Represents a project repository.</li> <li><code>File</code>: Represents a single source code file.</li> <li><code>Module</code>: Represents a package or a module.</li> <li><code>Class</code>: Represents a class definition.</li> <li><code>Function</code>: Represents a function or method definition.</li> </ul> </li> <li>Properties:<ul> <li>Nodes have properties like <code>name</code>, <code>path</code>, <code>cyclomatic_complexity</code> (for functions), and <code>code</code>.</li> </ul> </li> <li>Relationships:<ul> <li><code>CONTAINS</code>: e.g., <code>(:File)-[:CONTAINS]-&gt;(:Function)</code></li> <li><code>CALLS</code>: e.g., <code>(:Function)-[:CALLS]-&gt;(:Function)</code></li> <li><code>IMPORTS</code>: e.g., <code>(:File)-[:IMPORTS]-&gt;(:Module)</code></li> <li><code>INHERITS</code>: e.g., <code>(:Class)-[:INHERITS]-&gt;(:Class)</code></li> </ul> </li> </ul>"},{"location":"server/#add_package_to_graph","title":"<code>add_package_to_graph</code>","text":"<p>Add a Python package to Neo4j graph by discovering its location. Returns immediately with job ID.</p>"},{"location":"server/#find_dead_code","title":"<code>find_dead_code</code>","text":"<p>Find potentially unused functions (dead code) across the entire indexed codebase, optionally excluding functions with specific decorators.</p>"},{"location":"server/#calculate_cyclomatic_complexity","title":"<code>calculate_cyclomatic_complexity</code>","text":"<p>Calculate the cyclomatic complexity of a specific function to measure its complexity.</p>"},{"location":"server/#find_most_complex_functions","title":"<code>find_most_complex_functions</code>","text":"<p>Find the most complex functions in the codebase based on cyclomatic complexity.</p>"},{"location":"server/#list_indexed_repositories","title":"<code>list_indexed_repositories</code>","text":"<p>List all indexed repositories.</p>"},{"location":"server/#delete_repository","title":"<code>delete_repository</code>","text":"<p>Delete an indexed repository from the graph.</p>"},{"location":"server/#visualize_graph_query","title":"<code>visualize_graph_query</code>","text":"<p>Generates a URL to visualize the results of a Cypher query in the Neo4j Browser. The user can open this URL in their web browser to see the graph visualization.</p>"},{"location":"server/#list_watched_paths","title":"<code>list_watched_paths</code>","text":"<p>Lists all directories currently being watched for live file changes.</p>"},{"location":"server/#unwatch_directory","title":"<code>unwatch_directory</code>","text":"<p>Stops watching a directory for live file changes.</p>"},{"location":"server/#other-methods","title":"Other Methods","text":"<ul> <li><code>get_database_status()</code>: Returns the current connection status of the Neo4j database.</li> <li><code>get_local_package_path(package_name)</code>: Finds the local installation path of a Python package.</li> <li><code>run()</code>: Runs the main server loop, listening for JSON-RPC requests from stdin.</li> <li><code>shutdown()</code>: Gracefully shuts down the server and its components.</li> </ul>"},{"location":"tools/","title":"Tools","text":"<p>The <code>tools</code> directory contains the logic for code analysis, including building the graph, finding code, and extracting imports.</p>"},{"location":"tools/#graphbuilder","title":"<code>GraphBuilder</code>","text":"<p>The <code>GraphBuilder</code> class in <code>graph_builder.py</code> is responsible for parsing the source code and building the graph representation that is stored in the Neo4j database.</p>"},{"location":"tools/#treesitterparser","title":"<code>TreeSitterParser</code>","text":"<p><code>GraphBuilder</code> uses the <code>TreeSitterParser</code> class, which is a generic parser wrapper for a specific language using the tree-sitter library. This allows CodeGraphContext to support multiple programming languages in a modular way.</p>"},{"location":"tools/#graph-building-process","title":"Graph Building Process","text":"<p>The graph building process consists of several steps:</p> <ol> <li>Pre-scan for Imports: A quick scan of all files to build a global map of where every symbol is defined.</li> <li>Parse Files: Each file is parsed in detail to extract its structure, including functions, classes, variables, and imports.</li> <li>Add Nodes to Graph: The extracted code elements are added to the graph as nodes.</li> <li>Create Relationships: Relationships between the nodes are created, such as <code>CALLS</code> for function calls and <code>INHERITS</code> for class inheritance.</li> </ol>"},{"location":"tools/#codefinder","title":"<code>CodeFinder</code>","text":"<p>The <code>CodeFinder</code> class in <code>code_finder.py</code> provides functionality to search for specific code elements and analyze their relationships within the indexed codebase.</p>"},{"location":"tools/#key-methods","title":"Key Methods","text":"<ul> <li><code>find_by_function_name()</code>: Finds functions by name.</li> <li><code>find_by_class_name()</code>: Finds classes by name.</li> <li><code>find_by_variable_name()</code>: Finds variables by name.</li> <li><code>find_by_content()</code>: Finds code by content matching in source or docstrings.</li> <li><code>find_related_code()</code>: Finds code related to a query using multiple search strategies.</li> <li><code>analyze_code_relationships()</code>: Analyzes different types of code relationships, such as callers, callees, importers, and class hierarchies.</li> </ul>"},{"location":"tools/#importextractor","title":"<code>ImportExtractor</code>","text":"<p>The <code>ImportExtractor</code> class in <code>import_extractor.py</code> is a utility for extracting package and module imports from source code files of various programming languages. It uses the most appropriate parsing technique for each language, such as AST for Python and regular expressions for JavaScript.</p>"},{"location":"tools/#tools-exploration","title":"Tools Exploration","text":"<p>There are a total of 14 tools available to the users, and here we have attached illustrative demos for each one of them.</p>"},{"location":"tools/#find_code-tool","title":"find_code Tool","text":"<p>The <code>find_code</code> tool allows users to search for code snippets, functions, classes, and variables within the codebase using natural language queries. This tool helps developers understand and navigate large codebases efficiently.</p> <p>Below is an embedded link to a demo video showcasing the usage of the <code>find_code</code> tool in action. </p>"},{"location":"tools/#watch_directory-tool","title":"watch_directory Tool","text":"<p>The <code>watch_directory</code> tool allows users to monitor a specified directory for file changes, additions, or deletions in real-time. It helps developers automate workflows such as triggering scripts, updating indexes, or syncing files whenever changes occur in the directory.</p> <p>Below is an embedded link to a demo video showcasing the usage of the <code>watch_directory</code> tool in a development environment.  </p>"},{"location":"tools/#analyze_code_relationships-tool","title":"analyze_code_relationships Tool","text":"<p>The <code>analyze_code_relationships</code> tool in CodeGraphContext is designed to let users query and explore the various relationships between code elements in a codebase, represented as a graph in Neo4j. </p>"},{"location":"tools/#relationship-types-that-can-be-analyzed","title":"Relationship Types That Can Be Analyzed","text":"<ul> <li>CALLS: Finds which functions call or are called by a function.</li> <li>CALLED_BY: Finds all functions that directly or indirectly call a target function (inverse of CALLS).</li> <li>INHERITS_FROM: Finds class inheritance relationships; which classes inherit from which.</li> <li>CONTAINS: Shows containment (which classes/functions are inside which modules or files).</li> <li>IMPLEMENTS: Shows which classes implement an interface.</li> <li>IMPORTS: Identifies which files or modules import a specific module.</li> <li>DEFINED_IN: Locates where an entity (function/class) is defined.</li> <li>HAS_ARGUMENT: Shows relationships from functions to their arguments.</li> <li>DECLARES: Finds variables declared in functions or classes.</li> </ul> <p>Below is an embedded link to a demo video showcasing the usage of the <code>analyse_code_relationships</code> tool.  </p>"},{"location":"troubleshooting/","title":"CodeGraphContext Troubleshooting Guide","text":"<p>Use this checklist whenever <code>cgc mcp setup</code> or <code>cgc mcp start</code> doesn\u2019t behave as expected. It keeps the happy path short, but includes the fallback steps when something goes wrong.</p>"},{"location":"troubleshooting/#1-prerequisites-at-a-glance","title":"1. Prerequisites at a glance","text":"<ul> <li>Windows + PowerShell commands below assume the <code>py</code> launcher. Adapt to <code>python3</code> if you're on macOS/Linux.</li> <li>Python 3.12+ (recommended for FalkorDB Lite support). Run <code>py -3.12 --version</code> to confirm.</li> <li>Database Options:</li> <li>FalkorDB Lite (default for Unix/Linux/macOS, Python 3.12+): No setup required, works out of the box.</li> <li>Neo4j (required for Windows, optional for others): Requires Docker, WSL, or native installation. Setup via <code>cgc neo4j setup</code>.</li> </ul>"},{"location":"troubleshooting/#2-create-and-activate-a-virtual-environment","title":"2. Create and activate a virtual environment","text":"<p>From the repository root (<code>CodeGraphContext/</code>):</p> <pre><code>py -3.11 -m venv venv\n.\\venv\\Scripts\\python.exe -m pip install --upgrade pip\n</code></pre> <ul> <li>On Windows, Neo4j driver 6.x can crash with <code>AttributeError: socket.EAI_ADDRFAMILY</code>. If you see that, run:   <code>powershell   .\\venv\\Scripts\\python.exe -m pip install \"neo4j&lt;6\"</code></li> </ul>"},{"location":"troubleshooting/#3-run-the-neo4j-setup-wizard-optional-for-unix-required-for-windows","title":"3. Run the Neo4j setup wizard (optional for Unix, required for Windows)","text":"<p>Note: If you're on Unix/Linux/macOS with Python 3.12+, FalkorDB Lite is already your default database. You can skip this step unless you prefer Neo4j.</p> <p>For Windows users or those preferring Neo4j, launch the wizard:</p> <pre><code>.\\venv\\Scripts\\cgc.exe neo4j setup\n</code></pre> <p>Tip: If you want the wizard to spin up a local Neo4j instance for you, make sure Docker Desktop is installed and running before you launch <code>cgc neo4j setup</code>. If Docker isn't running, the setup wizard will fail when it tries to install Neo4j locally.</p> <p>What happens next:</p> <ul> <li>The wizard checks for Docker. If it's running, it can auto-provision a local Neo4j instance for you.</li> <li>Alternatively, you can supply credentials for an existing Neo4j AuraDB database.</li> <li>At the end, it generates:</li> <li><code>mcp.json</code> in your project directory (stores the MCP server command + env vars).</li> <li><code>~/.codegraphcontext/.env</code> containing <code>NEO4J_URI</code>, <code>NEO4J_USERNAME</code>, <code>NEO4J_PASSWORD</code>.</li> </ul> <p>Make sure the Docker container (or remote Neo4j) is still running before you start the server.</p>"},{"location":"troubleshooting/#4-start-the-mcp-server","title":"4. Start the MCP server","text":"<p>Once the wizard completes successfully:</p> <pre><code>.\\venv\\Scripts\\cgc.exe mcp start\n</code></pre> <p>Expected output includes:</p> <pre><code>Starting CodeGraphContext Server...\n...\nMCP Server is running. Waiting for requests...\n</code></pre> <p>If you instead see:</p> <pre><code>Configuration Error: Neo4j credentials must be set via environment variables\n</code></pre> <p>then either no credentials were saved, or the wizard was skipped\u2014see the manual alternative below.</p>"},{"location":"troubleshooting/#5-manual-credential-setup-fallback","title":"5. Manual credential setup (fallback)","text":"<p>If you prefer not to use the wizard or need to fix a broken configuration:</p> <ol> <li>Create a <code>mcp.json</code> (or edit the one that exists) in the repository root:</li> </ol> <p><code>json    {      \"mcpServers\": {        \"CodeGraphContext\": {          \"command\": \"cgc\",          \"args\": [\"mcp\", \"start\"],          \"env\": {            \"NEO4J_URI\": \"neo4j+s://YOUR-HOSTNAME:7687\",            \"NEO4J_USERNAME\": \"neo4j\",            \"NEO4J_PASSWORD\": \"super-secret-password\"          }        }      }    }</code></p> <ol> <li> <p>(Optional) Also create <code>%USERPROFILE%\\.codegraphcontext\\.env</code> with the same key/value pairs. The CLI loads that file automatically.</p> </li> <li> <p>Re-run:</p> </li> </ol> <p><code>powershell    .\\venv\\Scripts\\cgc.exe mcp start</code></p>"},{"location":"troubleshooting/#6-common-issues-fixes","title":"6. Common issues &amp; fixes","text":"Symptom Likely Cause Fix <code>Configuration Error: Neo4j credentials must be set\u2026</code> <code>mcp.json</code>/<code>.env</code> missing or empty Run <code>cgc neo4j setup</code> again with Docker running, or create the files manually (section 5). <code>AttributeError: socket.EAI_ADDRFAMILY</code> Neo4j 6.x bug on Windows Install the 5.x driver: <code>.\\venv\\Scripts\\python.exe -m pip install \"neo4j&lt;6\"</code> and retry. Setup wizard fails while pulling Docker image Docker Desktop not running or Docker permissions missing Start Docker Desktop, wait for it to report \u201cRunning\u201d, then rerun <code>cgc neo4j setup</code>. Server exits immediately with no log Neo4j instance is offline Check Docker container status or AuraDB dashboard; restart Neo4j and call <code>cgc mcp start</code> again."},{"location":"troubleshooting/#7-after-the-server-is-running","title":"7. After the server is running","text":"<ul> <li>Keep the virtual environment active whenever you run <code>cgc</code> commands.</li> <li>Use <code>pytest</code> from the same env to run tests:</li> </ul> <p><code>powershell   .\\venv\\Scripts\\pytest</code></p> <ul> <li>Front-end website lives under <code>website/</code> if you need to run <code>npm run dev</code>.</li> </ul> <p>When in doubt, re-run the wizard with Docker active\u2014it regenerates the configuration files without touching your code. Let me know if any section needs clarifying! :)</p>"},{"location":"use_cases/","title":"Real World Use Cases","text":"<p>CodeGraphContext can be a powerful ally in your daily coding journey. Here are some real-world scenarios where it can significantly boost your productivity and understanding of a codebase:</p> <ol> <li> <p>Onboarding New Developers: A new team member can quickly get up to speed by asking questions like:</p> <ul> <li>\"Where is the authentication logic handled?\"</li> <li>\"Show me the main entry point of the application.\"</li> </ul> </li> <li> <p>Impact Analysis: Before making a change, assess the potential ripple effects:</p> <ul> <li>\"What other parts of the code will be affected if I change the <code>calculate_total</code> function?\"</li> </ul> </li> <li> <p>Code Review: Gain context on pull requests faster:</p> <ul> <li>\"Show me the callers of this new function.\"</li> <li>\"Does this change introduce any new dependencies?\"</li> </ul> </li> <li> <p>Debugging: Trace execution flows to pinpoint the source of a bug:</p> <ul> <li>\"Show me the call chain from <code>handle_request</code> to <code>process_payment</code>.\"</li> </ul> </li> <li> <p>Refactoring: Identify and plan large-scale code changes:</p> <ul> <li>\"Find all instances of the deprecated <code>OldApiClass</code>.\"</li> <li>\"List all functions that use the <code>urllib</code> library so I can replace them with <code>requests</code>.\"</li> </ul> </li> <li> <p>Identifying Code Smells: Proactively find areas that need improvement:</p> <ul> <li>\"Find the 10 most complex functions in the codebase.\"</li> <li>\"Show me functions with more than 5 arguments.\"</li> </ul> </li> <li> <p>Security Audits: Search for potentially vulnerable code patterns:</p> <ul> <li>\"Find all functions that use the <code>eval</code> function.\"</li> <li>\"Show me where raw SQL queries are being executed.\"</li> </ul> </li> <li> <p>Automated Documentation: Use the tool's understanding of the code to generate documentation. (This is what this agent is doing!)</p> </li> <li> <p>Dependency Management: Understand how your project uses its dependencies:</p> <ul> <li>\"Which files import the <code>requests</code> library?\"</li> <li>\"Are there any circular dependencies between modules?\"</li> </ul> </li> <li> <p>Cleaning Up Unused Code: Keep your codebase lean and maintainable:</p> <ul> <li>\"Is there any dead or unused code in this project?\"</li> </ul> </li> <li> <p>Exploring a Large Codebase: Navigate large, unfamiliar projects with ease:</p> <ul> <li>\"List all the classes in the <code>core</code> module.\"</li> <li>\"What are the top-level functions in the <code>utils</code> directory?\"</li> </ul> </li> <li> <p>Enforcing Coding Standards: Check for adherence to team conventions:</p> <ul> <li>\"Find all functions that are not decorated with <code>@log_execution</code>.\"</li> <li>\"Show me all public methods that don't have a docstring.\"</li> </ul> </li> <li> <p>Discovering API Usage: Find examples of how to use internal or external APIs:</p> <ul> <li>\"Show me how other parts of the code use the <code>UserService</code>.\"</li> </ul> </li> <li> <p>Improving Test Coverage: Identify areas that may lack test coverage:</p> <ul> <li>\"Find all functions that are not called by any test files.\"</li> </ul> </li> <li> <p>Visualizing Code Structure: Get a bird's-eye view of your project's architecture:</p> <ul> <li>\"Generate a graph visualization of the <code>auth</code> module and its dependencies.\"</li> </ul> </li> <li> <p>Learning a New Framework: Understand how a new framework operates by exploring its source code.</p> </li> <li> <p>Code Archeology: Investigate legacy code to understand its history and purpose.</p> </li> <li> <p>Planning a Migration: Identify all points of contact when migrating a library or framework:</p> <ul> <li>\"Find all the places where the <code>old_payment_gateway</code> is used.\"</li> </ul> </li> <li> <p>Knowledge Sharing: Use the code graph as a centralized, always-up-to-date knowledge base for your team.</p> </li> <li> <p>Automated Code Reviews: Integrate CodeGraphContext into your CI/CD pipeline to automatically flag potential issues in pull requests.</p> </li> </ol>"},{"location":"watching/","title":"Live File Watching","text":"<p>CodeGraphContext can automatically monitor your codebase for changes and update the code graph in real-time as you develop.</p>"},{"location":"watching/#quick-start","title":"Quick Start","text":"<p>Start watching your project directory:</p> <pre><code>cgc watch .\n</code></pre> <p>You'll see:</p> <pre><code>\ud83d\udd0d Watching /path/to/your/project for changes...\n\u2713 Already indexed (no initial scan needed)\n\ud83d\udc40 Monitoring for file changes... (Press Ctrl+C to stop)\n\n\ud83d\udca1 Tip: Open a new terminal window to continue working\n</code></pre>"},{"location":"watching/#how-it-works","title":"How It Works","text":"<p>The watcher uses file system events to detect when you:</p> <ul> <li>Create new files</li> <li>Modify existing files</li> <li>Delete files</li> <li>Move/rename files</li> </ul> <p>When changes are detected, CodeGraphContext automatically:</p> <ol> <li>Re-parses the affected files</li> <li>Updates the code graph</li> <li>Maintains all relationships and dependencies</li> </ol>"},{"location":"watching/#commands","title":"Commands","text":""},{"location":"watching/#cgc-watch-path","title":"<code>cgc watch [path]</code>","text":"<p>Start watching a directory for changes.</p> <p>Examples:</p> <pre><code>cgc watch .                    # Watch current directory\ncgc watch /path/to/project     # Watch specific directory\ncgc w .                        # Shortcut alias\n</code></pre> <p>Behavior: - Runs in the foreground (blocking mode) - Performs initial scan if directory is not yet indexed - Monitors for all file system changes - Uses 2-second debouncing to batch rapid changes - Press <code>Ctrl+C</code> to stop</p>"},{"location":"watching/#cgc-watching","title":"<code>cgc watching</code>","text":"<p>List all directories currently being watched.</p> <pre><code>cgc watching\n</code></pre> <p>Note: This command is primarily for MCP server mode. For CLI watch mode, check the terminal where you ran <code>cgc watch</code>.</p>"},{"location":"watching/#cgc-unwatch-path","title":"<code>cgc unwatch &lt;path&gt;</code>","text":"<p>Stop watching a directory.</p> <pre><code>cgc unwatch /path/to/project\n</code></pre> <p>Note: This command is primarily for MCP server mode. For CLI watch mode, simply press <code>Ctrl+C</code> in the watch terminal.</p>"},{"location":"watching/#best-practices","title":"Best Practices","text":""},{"location":"watching/#development-workflow","title":"Development Workflow","text":"<ol> <li>Start watching at the beginning of your coding session</li> <li>Open a new terminal tab/window for your actual work</li> <li>Code normally - changes are automatically tracked</li> <li>Stop watching (Ctrl+C) when you're done</li> </ol>"},{"location":"watching/#performance-tips","title":"Performance Tips","text":"<ul> <li>The watcher uses debouncing (2-second delay) to avoid excessive re-indexing</li> <li>Only modified files and their dependencies are re-processed</li> <li>Large projects may take a moment to process changes</li> </ul>"},{"location":"watching/#when-to-use-watch-mode","title":"When to Use Watch Mode","text":"<p>\u2705 Good for:</p> <ul> <li>Active development sessions</li> <li>Refactoring work</li> <li>Keeping AI assistants up-to-date with latest code</li> <li>Live code analysis during development</li> </ul> <p>\u274c Not needed for:</p> <ul> <li>One-time indexing</li> <li>CI/CD pipelines</li> <li>Read-only code analysis</li> <li>Batch processing</li> </ul>"},{"location":"watching/#example-workflow","title":"Example Workflow","text":"<p>Here's a typical development session using watch mode:</p> <pre><code># Terminal 1: Start the watcher\n$ cd ~/my-project\n$ cgc watch .\n\ud83d\udd0d Watching /home/user/my-project for changes...\n\u2713 Already indexed (no initial scan needed)\n\ud83d\udc40 Monitoring for file changes... (Press Ctrl+C to stop)\n\n\ud83d\udca1 Tip: Open a new terminal window to continue working\n\n# ... watcher runs and shows updates as you code ...\n[21:15:32] \ud83d\udcdd Modified: src/utils.py (re-indexing...)\n[21:15:32] \u2713 Updated graph (3 nodes, 2 relationships)\n[21:16:45] \ud83d\udcdd Created: src/new_feature.py (re-indexing...)\n[21:16:45] \u2713 Updated graph (8 nodes, 5 relationships)\n</code></pre> <pre><code># Terminal 2: Do your development work\n$ cd ~/my-project\n$ code .                       # Open your editor\n$ git checkout -b new-feature  # Work normally\n$ # ... make changes, save files ...\n$ # The watcher in Terminal 1 automatically picks up changes!\n</code></pre>"},{"location":"watching/#troubleshooting","title":"Troubleshooting","text":""},{"location":"watching/#watcher-not-detecting-changes","title":"Watcher not detecting changes","text":"<ul> <li>Ensure the path is correct and accessible</li> <li>Check file permissions</li> <li>Some editors use atomic writes which may not trigger events</li> <li>Try restarting the watcher</li> </ul>"},{"location":"watching/#high-cpu-usage","title":"High CPU usage","text":"<ul> <li>The watcher may be processing too many files</li> <li>Consider watching a smaller directory</li> <li>Check for file loops or symlinks</li> <li>Verify you're not watching <code>node_modules</code> or similar large directories</li> </ul>"},{"location":"watching/#changes-not-appearing","title":"Changes not appearing","text":"<ul> <li>Wait for the debounce interval (2 seconds)</li> <li>Check the watcher output for errors</li> <li>Verify the file type is supported (Python, JavaScript, TypeScript, etc.)</li> <li>Ensure the file is within the watched directory</li> </ul>"},{"location":"watching/#already-watching-message","title":"\"Already watching\" message","text":"<p>If you see this message, it means the directory is already being watched. This can happen if:</p> <ul> <li>You're running multiple watch commands</li> <li>The MCP server is already watching this directory</li> <li>A previous watch session didn't terminate cleanly</li> </ul> <p>Solution: Stop all watch processes and start fresh.</p>"},{"location":"watching/#mcp-server-vs-cli-watch-mode","title":"MCP Server vs CLI Watch Mode","text":"<p>CodeGraphContext supports two watch modes:</p>"},{"location":"watching/#cli-watch-mode-this-guide","title":"CLI Watch Mode (This Guide)","text":"<ul> <li>Command: <code>cgc watch .</code></li> <li>Runs: In foreground (blocking)</li> <li>Use case: Active development sessions</li> <li>Control: Press <code>Ctrl+C</code> to stop</li> <li>Best for: Single project, focused development</li> </ul>"},{"location":"watching/#mcp-server-watch-mode","title":"MCP Server Watch Mode","text":"<ul> <li>Command: Via MCP tools (<code>watch_directory</code>, <code>unwatch_directory</code>, <code>list_watched_paths</code>)</li> <li>Runs: In background (as part of MCP server)</li> <li>Use case: IDE integration, multiple projects</li> <li>Control: MCP tool calls</li> <li>Best for: AI assistant integration, persistent watching</li> </ul>"},{"location":"watching/#technical-details","title":"Technical Details","text":"<ul> <li>Library: Uses <code>watchdog</code> for cross-platform file monitoring</li> <li>Debouncing: 2-second delay to batch rapid changes</li> <li>Scope: Watches recursively, respects <code>.gitignore</code></li> <li>Performance: Only re-indexes changed files and affected relationships</li> <li>Thread-safe: Uses background threads for file monitoring</li> <li>Graceful shutdown: Properly cleans up on <code>Ctrl+C</code></li> </ul>"},{"location":"watching/#integration-with-ai-assistants","title":"Integration with AI Assistants","text":"<p>Watch mode is particularly powerful when combined with AI coding assistants:</p> <ol> <li> <p>Start watching your project: <code>bash    cgc watch .</code></p> </li> <li> <p>Configure your AI assistant to use the CodeGraphContext MCP server</p> </li> <li> <p>Code normally - your AI assistant always has the latest code context</p> </li> <li> <p>Ask questions about your code, and the AI will have up-to-date information</p> </li> </ol> <p>This creates a seamless development experience where your AI assistant stays synchronized with your codebase in real-time!</p>"},{"location":"watching/#see-also","title":"See Also","text":"<ul> <li>CLI Reference - Complete list of CLI commands</li> <li>MCP Tools - MCP server tools including watch functionality</li> <li>Installation - Getting started with CodeGraphContext</li> </ul>"}]}
```
Page 15/17FirstPrevNextLast