#
tokens: 44586/50000 3/440 files (page 14/17)
lines: off (toggle) GitHub
raw markdown copy
This is page 14 of 17. Use http://codebase.md/shashankss1205/codegraphcontext?lines=false&page={x} to view the full context.

# Directory Structure

```
├── .cgcignore
├── .dockerignore
├── .env.example
├── .github
│   ├── FUNDING.yml
│   └── workflows
│       ├── docker-publish.yml
│       ├── e2e-tests.yml
│       ├── post_discord_invite.yml
│       ├── test.yml
│       └── update-contributors.yml
├── .gitignore
├── CLI_Commands.md
├── CONTRIBUTING.md
├── contributors.md
├── deploy-production.sh
├── DEPLOYMENT_CHECKLIST.md
├── DOCKER_COMPLETE_GUIDE.md
├── DOCKER_DEPLOYMENT.md
├── DOCKER_README.md
├── docker-compose.template.yml
├── docker-quickstart.sh
├── Dockerfile
├── 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
├── HOSTING_COMPARISON.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
├── k8s
│   ├── configmap.yaml
│   ├── deployment.yaml
│   ├── neo4j-deployment.yaml
│   ├── pvc.yaml
│   ├── README.md
│   └── service.yaml
├── 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

--------------------------------------------------------------------------------
/src/codegraphcontext/tools/code_finder.py:
--------------------------------------------------------------------------------

```python
# src/codegraphcontext/tools/code_finder.py
import logging
import re
from typing import Any, Dict, List, Literal, Optional
from pathlib import Path

from ..core.database import DatabaseManager

logger = logging.getLogger(__name__)

class CodeFinder:
    """Module for finding relevant code snippets and analyzing relationships."""

    def __init__(self, db_manager: DatabaseManager):
        self.db_manager = db_manager
        self.driver = self.db_manager.get_driver()

    def format_query(self, find_by: Literal["Class", "Function"], fuzzy_search:bool) -> str:
        """Format the search query based on the search type and fuzzy search settings."""
        return f"""
            CALL db.index.fulltext.queryNodes("code_search_index", $search_term) YIELD node, score
                WITH node, score
                WHERE node:{find_by} {'AND node.name CONTAINS $search_term' if not fuzzy_search else ''}
                RETURN node.name as name, node.file_path as file_path, node.line_number as line_number,
                    node.source as source, node.docstring as docstring, node.is_dependency as is_dependency
                ORDER BY score DESC
                LIMIT 20
            """

    def find_by_function_name(self, search_term: str, fuzzy_search: bool) -> List[Dict]:
        """Find functions by name matching."""
        with self.driver.session() as session:
            if not fuzzy_search:
                # Use simple match for exact search to avoid fulltext index dependency
                result = session.run("""
                    MATCH (node:Function {name: $name})
                    RETURN node.name as name, node.file_path as file_path, node.line_number as line_number,
                           node.source as source, node.docstring as docstring, node.is_dependency as is_dependency
                    LIMIT 20
                """, name=search_term)
                return result.data()
            
            # Fuzzy search using fulltext index
            formatted_search_term = f"name:{search_term}"
            result = session.run(self.format_query("Function", fuzzy_search), search_term=formatted_search_term)
            return result.data()

    def find_by_class_name(self, search_term: str, fuzzy_search: bool) -> List[Dict]:
        """Find classes by name matching."""
        with self.driver.session() as session:
            if not fuzzy_search:
                # Use simple match for exact search to avoid fulltext index dependency
                result = session.run("""
                    MATCH (node:Class {name: $name})
                    RETURN node.name as name, node.file_path as file_path, node.line_number as line_number,
                           node.source as source, node.docstring as docstring, node.is_dependency as is_dependency
                    LIMIT 20
                """, name=search_term)
                return result.data()

            # Fuzzy search using fulltext index
            formatted_search_term = f"name:{search_term}"
            result = session.run(self.format_query("Class", fuzzy_search), search_term=formatted_search_term)
            return result.data()

    def find_by_variable_name(self, search_term: str) -> List[Dict]:
        """Find variables by name matching"""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (v:Variable)
                WHERE v.name CONTAINS $search_term
                RETURN v.name as name, v.file_path as file_path, v.line_number as line_number,
                       v.value as value, v.context as context, v.is_dependency as is_dependency
                ORDER BY v.is_dependency ASC, v.name
                LIMIT 20
            """, search_term=search_term)
            
            return result.data()

    def find_by_content(self, search_term: str) -> List[Dict]:
        """Find code by content matching in source or docstrings using the full-text index."""
        with self.driver.session() as session:
            result = session.run("""
                CALL db.index.fulltext.queryNodes("code_search_index", $search_term) YIELD node, score
                WITH node, score
                WHERE node:Function OR node:Class OR node:Variable
                RETURN
                    CASE 
                        WHEN node:Function THEN 'function'
                        WHEN node:Class THEN 'class'
                        ELSE 'variable' 
                    END as type,
                    node.name as name, node.file_path as file_path,
                    node.line_number as line_number, node.source as source,
                    node.docstring as docstring, node.is_dependency as is_dependency
                ORDER BY score DESC
                LIMIT 20
            """, search_term=search_term)
            return result.data()
    
    def find_by_module_name(self, search_term: str) -> List[Dict]:
        """Find modules by name matching"""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (m:Module)
                WHERE m.name CONTAINS $search_term
                RETURN m.name as name, m.lang as lang
                ORDER BY m.name
                LIMIT 20
            """, search_term=search_term)
            return result.data()

    def find_imports(self, search_term: str) -> List[Dict]:
        """Find imported symbols (aliases or original names)."""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (f:File)-[r:IMPORTS]->(m:Module)
                WHERE r.alias = $search_term OR r.imported_name = $search_term
                RETURN 
                    r.alias as alias, 
                    r.imported_name as imported_name, 
                    m.name as module_name, 
                    f.path as file_path, 
                    r.line_number as line_number
                ORDER BY f.path
                LIMIT 20
            """, search_term=search_term)
            return result.data()

    def find_related_code(self, user_query: str, fuzzy_search: bool, edit_distance: int) -> Dict[str, Any]:
        """Find code related to a query using multiple search strategies"""
        if fuzzy_search:
            user_query_normalized = " ".join(map(lambda x: f"{x}~{edit_distance}", user_query.split(" ")))
        else:
            user_query_normalized = user_query

        results = {
            "query": user_query_normalized,
            "functions_by_name": self.find_by_function_name(user_query_normalized, fuzzy_search),
            "classes_by_name": self.find_by_class_name(user_query_normalized, fuzzy_search),
            "variables_by_name": self.find_by_variable_name(user_query),  # no fuzzy for variables as they are not using full-text index
            "content_matches": self.find_by_content(user_query_normalized)
        }
        
        all_results = []
        
        for func in results["functions_by_name"]:
            func["search_type"] = "function_name"
            func["relevance_score"] = 0.9 if not func["is_dependency"] else 0.7
            all_results.append(func)
        
        for cls in results["classes_by_name"]:
            cls["search_type"] = "class_name"
            cls["relevance_score"] = 0.8 if not cls["is_dependency"] else 0.6
            all_results.append(cls)

        for var in results["variables_by_name"]:
            var["search_type"] = "variable_name"
            var["relevance_score"] = 0.7 if not var["is_dependency"] else 0.5
            all_results.append(var)
        
        for content in results["content_matches"]:
            content["search_type"] = "content"
            content["relevance_score"] = 0.6 if not content["is_dependency"] else 0.4
            all_results.append(content)
        
        all_results.sort(key=lambda x: x["relevance_score"], reverse=True)
        
        results["ranked_results"] = all_results[:15]
        results["total_matches"] = len(all_results)
        
        return results
    
    def find_functions_by_argument(self, argument_name: str, file_path: str = None) -> List[Dict]:
        """Find functions that take a specific argument name."""
        with self.driver.session() as session:
            if file_path:
                query = """
                    MATCH (f:Function)-[:HAS_PARAMETER]->(p:Parameter)
                    WHERE p.name = $argument_name AND f.file_path = $file_path
                    RETURN f.name AS function_name, f.file_path AS file_path, f.line_number AS line_number,
                           f.docstring AS docstring, f.is_dependency AS is_dependency
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 20
                """
                result = session.run(query, argument_name=argument_name, file_path=file_path)
            else:
                query = """
                    MATCH (f:Function)-[:HAS_PARAMETER]->(p:Parameter)
                    WHERE p.name = $argument_name
                    RETURN f.name AS function_name, f.file_path AS file_path, f.line_number AS line_number,
                           f.docstring AS docstring, f.is_dependency AS is_dependency
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 20
                """
                result = session.run(query, argument_name=argument_name)
            return result.data()

    def find_functions_by_decorator(self, decorator_name: str, file_path: str = None) -> List[Dict]:
        """Find functions that have a specific decorator applied to them."""
        with self.driver.session() as session:
            if file_path:
                query = """
                    MATCH (f:Function)
                    WHERE f.file_path = $file_path AND $decorator_name IN f.decorators
                    RETURN f.name AS function_name, f.file_path AS file_path, f.line_number AS line_number,
                           f.docstring AS docstring, f.is_dependency AS is_dependency, f.decorators AS decorators
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 20
                """
                result = session.run(query, decorator_name=decorator_name, file_path=file_path)
            else:
                query = """
                    MATCH (f:Function)
                    WHERE $decorator_name IN f.decorators
                    RETURN f.name AS function_name, f.file_path AS file_path, f.line_number AS line_number,
                           f.docstring AS docstring, f.is_dependency AS is_dependency, f.decorators AS decorators
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 20
                """
                result = session.run(query, decorator_name=decorator_name)
            return result.data()
    
    def who_calls_function(self, function_name: str, file_path: str = None) -> List[Dict]:
        """Find what functions call a specific function using CALLS relationships with improved matching"""
        with self.driver.session() as session:
            if file_path:
                result = session.run("""
                    MATCH (caller:Function)-[call:CALLS]->(target:Function {name: $function_name, file_path: $file_path})
                    OPTIONAL MATCH (caller_file:File)-[:CONTAINS]->(caller)
                    RETURN DISTINCT
                        caller.name as caller_function,
                        caller.file_path as caller_file_path,
                        caller.line_number as caller_line_number,
                        caller.docstring as caller_docstring,
                        caller.is_dependency as caller_is_dependency,
                        call.line_number as call_line_number,
                        call.args as call_args,
                        call.full_call_name as full_call_name,
                        target.file_path as target_file_path
                    ORDER BY caller.is_dependency ASC, caller.file_path, caller.line_number
                    LIMIT 20
                """, function_name=function_name, file_path=file_path)
                
                results = [dict(record) for record in result]
                if not results:
                    result = session.run("""
                        MATCH (target:Function {name: $function_name})
                        MATCH (caller:Function)-[call:CALLS]->(target)
                        OPTIONAL MATCH (caller_file:File)-[:CONTAINS]->(caller)
                        RETURN DISTINCT
                            caller.name as caller_function,
                            caller.file_path as caller_file_path,
                            caller.line_number as caller_line_number,
                            caller.docstring as caller_docstring,
                            caller.is_dependency as caller_is_dependency,
                            call.line_number as call_line_number,
                            call.args as call_args,
                            call.full_call_name as full_call_name,
                            target.file_path as target_file_path
                        ORDER BY caller.is_dependency ASC, caller.file_path, caller.line_number
                        LIMIT 20
                    """, function_name=function_name)
                    results = [dict(record) for record in result]
            else:
                result = session.run("""
                    MATCH (target:Function {name: $function_name})
                    MATCH (caller:Function)-[call:CALLS]->(target)
                    OPTIONAL MATCH (caller_file:File)-[:CONTAINS]->(caller)
                    RETURN DISTINCT
                        caller.name as caller_function,
                        caller.file_path as caller_file_path,
                        caller.line_number as caller_line_number,
                        caller.docstring as caller_docstring,
                        caller.is_dependency as caller_is_dependency,
                        call.line_number as call_line_number,
                        call.args as call_args,
                        call.full_call_name as full_call_name,
                        target.file_path as target_file_path
                    ORDER BY caller.is_dependency ASC, caller.file_path, caller.line_number
                    LIMIT 20
                """, function_name=function_name)
                results = [dict(record) for record in result]
            
            return results
    
    def what_does_function_call(self, function_name: str, file_path: str = None) -> List[Dict]:
        """Find what functions a specific function calls using CALLS relationships"""
        with self.driver.session() as session:
            if file_path:
                # Convert file_path to absolute path
                absolute_file_path = str(Path(file_path).resolve())
                result = session.run("""
                    MATCH (caller:Function {name: $function_name, file_path: $absolute_file_path})
                    MATCH (caller)-[call:CALLS]->(called:Function)
                    OPTIONAL MATCH (called_file:File)-[:CONTAINS]->(called)
                    RETURN DISTINCT
                        called.name as called_function,
                        called.file_path as called_file_path,
                        called.line_number as called_line_number,
                        called.docstring as called_docstring,
                        called.is_dependency as called_is_dependency,
                        call.line_number as call_line_number,
                        call.args as call_args,
                        call.full_call_name as full_call_name
                    ORDER BY called.is_dependency ASC, called.name
                    LIMIT 20
                """, function_name=function_name, absolute_file_path=absolute_file_path)
            else:
                result = session.run("""
                    MATCH (caller:Function {name: $function_name})
                    MATCH (caller)-[call:CALLS]->(called:Function)
                    OPTIONAL MATCH (called_file:File)-[:CONTAINS]->(called)
                    RETURN DISTINCT
                        called.name as called_function,
                        called.file_path as called_file_path,
                        called.line_number as called_line_number,
                        called.docstring as called_docstring,
                        called.is_dependency as called_is_dependency,
                        call.line_number as call_line_number,
                        call.args as call_args,
                        call.full_call_name as full_call_name
                    ORDER BY called.is_dependency ASC, called.name
                    LIMIT 20
                """, function_name=function_name)
            
            return result.data()
    
    def who_imports_module(self, module_name: str) -> List[Dict]:
        """Find what files import a specific module using IMPORTS relationships"""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (file:File)-[imp:IMPORTS]->(module:Module)
                WHERE module.name = $module_name OR module.full_import_name CONTAINS $module_name
                OPTIONAL MATCH (repo:Repository)-[:CONTAINS]->(file)
                WITH file, repo, COLLECT({
                    imported_module: module.name,
                    import_alias: module.alias,
                    full_import_name: module.full_import_name
                }) AS imports
                RETURN
                    file.name AS file_name,
                    file.path AS file_path,
                    file.relative_path AS file_relative_path,
                    file.is_dependency AS file_is_dependency,
                    repo.name AS repository_name,
                    imports
                ORDER BY file.is_dependency ASC, file.path
                LIMIT 20
            """, module_name=module_name)
            
            return result.data()
    
    def who_modifies_variable(self, variable_name: str) -> List[Dict]:
        """Find what functions contain or modify a specific variable"""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (var:Variable {name: $variable_name})
                MATCH (container)-[:CONTAINS]->(var)
                WHERE container:Function OR container:Class OR container:File
                OPTIONAL MATCH (file:File)-[:CONTAINS]->(container)
                RETURN DISTINCT
                    CASE 
                        WHEN container:Function THEN container.name
                        WHEN container:Class THEN container.name
                        ELSE 'file_level'
                    END as container_name,
                    CASE 
                        WHEN container:Function THEN 'function'
                        WHEN container:Class THEN 'class'
                        ELSE 'file'
                    END as container_type,
                    COALESCE(container.file_path, file.path) as file_path,
                    container.line_number as container_line_number,
                    var.line_number as variable_line_number,
                    var.value as variable_value,
                    var.context as variable_context,
                    COALESCE(container.is_dependency, file.is_dependency, false) as is_dependency
                ORDER BY is_dependency ASC, file_path, variable_line_number
                LIMIT 20
            """, variable_name=variable_name)
            
            return result.data()
    
    def find_class_hierarchy(self, class_name: str, file_path: str = None) -> Dict[str, Any]:
        """Find class inheritance relationships using INHERITS relationships"""
        with self.driver.session() as session:
            if file_path:
                match_clause = "MATCH (child:Class {name: $class_name, file_path: $file_path})"
            else:
                match_clause = "MATCH (child:Class {name: $class_name})"

            parents_query = f"""
                {match_clause}
                MATCH (child)-[:INHERITS]->(parent:Class)
                OPTIONAL MATCH (parent_file:File)-[:CONTAINS]->(parent)
                RETURN DISTINCT
                    parent.name as parent_class,
                    parent.file_path as parent_file_path,
                    parent.line_number as parent_line_number,
                    parent.docstring as parent_docstring,
                    parent.is_dependency as parent_is_dependency
                ORDER BY parent.is_dependency ASC, parent.name
            """
            parents_result = session.run(parents_query, class_name=class_name, file_path=file_path)
            
            children_query = f"""
                {match_clause}
                MATCH (grandchild:Class)-[:INHERITS]->(child)
                OPTIONAL MATCH (child_file:File)-[:CONTAINS]->(grandchild)
                RETURN DISTINCT
                    grandchild.name as child_class,
                    grandchild.file_path as child_file_path,
                    grandchild.line_number as child_line_number,
                    grandchild.docstring as child_docstring,
                    grandchild.is_dependency as child_is_dependency
                ORDER BY grandchild.is_dependency ASC, grandchild.name
            """
            children_result = session.run(children_query, class_name=class_name, file_path=file_path)
            
            methods_query = f"""
                {match_clause}
                MATCH (child)-[:CONTAINS]->(method:Function)
                RETURN DISTINCT
                    method.name as method_name,
                    method.file_path as method_file_path,
                    method.line_number as method_line_number,
                    method.args as method_args,
                    method.docstring as method_docstring,
                    method.is_dependency as method_is_dependency
                ORDER BY method.is_dependency ASC, method.line_number
            """
            methods_result = session.run(methods_query, class_name=class_name, file_path=file_path)
            
            return {
                "class_name": class_name,
                "parent_classes": [dict(record) for record in parents_result],
                "child_classes": [dict(record) for record in children_result],
                "methods": [dict(record) for record in methods_result]
            }
    
    def find_function_overrides(self, function_name: str) -> List[Dict]:
        """Find all implementations of a function across different classes"""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (class:Class)-[:CONTAINS]->(func:Function {name: $function_name})
                OPTIONAL MATCH (file:File)-[:CONTAINS]->(class)
                RETURN DISTINCT
                    class.name as class_name,
                    class.file_path as class_file_path,
                    func.name as function_name,
                    func.line_number as function_line_number,
                    func.args as function_args,
                    func.docstring as function_docstring,
                    func.is_dependency as is_dependency,
                    file.name as file_name
                ORDER BY func.is_dependency ASC, class.name
                LIMIT 20
            """, function_name=function_name)
            
            return result.data()
    
    def find_dead_code(self, exclude_decorated_with: List[str] = None) -> Dict[str, Any]:
        """Find potentially unused functions (not called by other functions in the project), optionally excluding those with specific decorators."""
        if exclude_decorated_with is None:
            exclude_decorated_with = []

        with self.driver.session() as session:
            result = session.run("""
                MATCH (func:Function)
                WHERE func.is_dependency = false
                  AND NOT func.name IN ['main', '__init__', '__main__', 'setup', 'run', '__new__', '__del__']
                  AND NOT func.name STARTS WITH '_test'
                  AND NOT func.name STARTS WITH 'test_'
                  AND ALL(decorator_name IN $exclude_decorated_with WHERE NOT decorator_name IN func.decorators)
                WITH func
                OPTIONAL MATCH (caller:Function)-[:CALLS]->(func)
                WHERE caller.is_dependency = false
                WITH func, count(caller) as caller_count
                WHERE caller_count = 0
                OPTIONAL MATCH (file:File)-[:CONTAINS]->(func)
                RETURN
                    func.name as function_name,
                    func.file_path as file_path,
                    func.line_number as line_number,
                    func.docstring as docstring,
                    func.context as context,
                    file.name as file_name
                ORDER BY func.file_path, func.line_number
                LIMIT 50
            """, exclude_decorated_with=exclude_decorated_with)
            
            return {
                "potentially_unused_functions": [dict(record) for record in result],
                "note": "These functions might be unused, but could be entry points, callbacks, or called dynamically"
            }
    
    def find_all_callers(self, function_name: str, file_path: str = None) -> List[Dict]:
        """Find all direct and indirect callers of a specific function."""
        with self.driver.session() as session:
            if file_path:
                # Find functions within the specified file_path that call the target function
                query = """
                    MATCH (f:Function)-[:CALLS*]->(target:Function {name: $function_name, file_path: $file_path})
                    RETURN DISTINCT f.name AS caller_name, f.file_path AS caller_file_path, f.line_number AS caller_line_number, f.is_dependency AS caller_is_dependency
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 50
                """
                result = session.run(query, function_name=function_name, file_path=file_path)
            else:
                # If no file_path (context) is provided, find all callers of the function by name
                query = """
                    MATCH (f:Function)-[:CALLS*]->(target:Function {name: $function_name})
                    RETURN DISTINCT f.name AS caller_name, f.file_path AS caller_file_path, f.line_number AS caller_line_number, f.is_dependency AS caller_is_dependency
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 50
                """
                result = session.run(query, function_name=function_name)
            return result.data()

    def find_all_callees(self, function_name: str, file_path: str = None) -> List[Dict]:
        """Find all direct and indirect callees of a specific function."""
        with self.driver.session() as session:
            if file_path:
                query = """
                    MATCH (caller:Function {name: $function_name, file_path: $file_path})
                    MATCH (caller)-[:CALLS*]->(f:Function)
                    RETURN DISTINCT f.name AS callee_name, f.file_path AS callee_file_path, f.line_number AS callee_line_number, f.is_dependency AS callee_is_dependency
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 50
                """
                result = session.run(query, function_name=function_name, file_path=file_path)
            else:
                query = """
                    MATCH (caller:Function {name: $function_name})
                    MATCH (caller)-[:CALLS*]->(f:Function)
                    RETURN DISTINCT f.name AS callee_name, f.file_path AS callee_file_path, f.line_number AS callee_line_number, f.is_dependency AS callee_is_dependency
                    ORDER BY f.is_dependency ASC, f.file_path, f.line_number
                    LIMIT 50
                """
                result = session.run(query, function_name=function_name)
            return result.data()

    def find_function_call_chain(self, start_function: str, end_function: str, max_depth: int = 5, start_file: str = None, end_file: str = None) -> List[Dict]:
        """Find call chains between two functions"""
        with self.driver.session() as session:
            # Build match clauses based on whether files are specified
            start_props = "{name: $start_function" + (", file_path: $start_file}" if start_file else "}")
            end_props = "{name: $end_function" + (", file_path: $end_file}" if end_file else "}")

            query = f"""
                MATCH (start:Function {start_props}), (end:Function {end_props})
                WITH start, end
                MATCH path = (start)-[:CALLS*1..{max_depth}]->(end)
                WHERE path IS NOT NULL
                WITH path, nodes(path) as func_nodes, relationships(path) as call_rels
                RETURN 
                    [node in func_nodes | {{
                        name: node.name,
                        file_path: node.file_path,
                        line_number: node.line_number,
                        is_dependency: node.is_dependency
                    }}] as function_chain,
                    [rel in call_rels | {{
                        call_line: rel.line_number,
                        args: rel.args,
                        full_call_name: rel.full_call_name
                    }}] as call_details,
                    length(path) as chain_length
                ORDER BY chain_length ASC
                LIMIT 20
            """
            
            # Prepare parameters
            params = {
                "start_function": start_function,
                "end_function": end_function,
                "start_file": start_file,
                "end_file": end_file
            }
            
            result = session.run(query, **params)
            return result.data()

    def find_by_type(self, element_type: str, limit: int = 50) -> List[Dict]:
        """Find all elements of a specific type (Function, Class, File, Module)."""
        # Map input type to node label
        type_map = {
            "function": "Function",
            "class": "Class",
            "file": "File",
            "module": "Module"
        }
        label = type_map.get(element_type.lower())
        
        if not label:
            return []
            
        with self.driver.session() as session:
            if label == "File":
                query = f"""
                    MATCH (n:File)
                    RETURN n.name as name, n.path as file_path, n.is_dependency as is_dependency
                    ORDER BY n.path
                    LIMIT $limit
                """
            elif label == "Module":
                query = f"""
                    MATCH (n:Module)
                    RETURN n.name as name, n.name as file_path, false as is_dependency
                    ORDER BY n.name
                    LIMIT $limit
                """
            else:
                query = f"""
                    MATCH (n:{label})
                    RETURN n.name as name, n.file_path as file_path, n.line_number as line_number, n.is_dependency as is_dependency
                    ORDER BY n.is_dependency ASC, n.name
                    LIMIT $limit
                """
            
            result = session.run(query, limit=limit)
            return result.data()
    
    def find_module_dependencies(self, module_name: str) -> Dict[str, Any]:
        """Find all dependencies and dependents of a module"""
        with self.driver.session() as session:
            # Find files that import this module (who imports this module)
            importers_result = session.run("""
                MATCH (file:File)-[imp:IMPORTS]->(module:Module {name: $module_name})
                OPTIONAL MATCH (repo:Repository)-[:CONTAINS]->(file)
                RETURN DISTINCT
                    file.path as importer_file_path,
                    imp.line_number as import_line_number,
                    file.is_dependency as file_is_dependency,
                    repo.name as repository_name
                ORDER BY file.is_dependency ASC, file.path
                LIMIT 50
            """, module_name=module_name)
            
            # Find modules that are imported by files that also import the target module
            # This helps understand what this module is typically used with
            imports_result = session.run("""
                MATCH (file:File)-[:IMPORTS]->(target_module:Module {name: $module_name})
                MATCH (file)-[imp:IMPORTS]->(other_module:Module)
                WHERE other_module <> target_module
                RETURN DISTINCT
                    other_module.name as imported_module,
                    imp.alias as import_alias
                ORDER BY other_module.name
                LIMIT 50
            """, module_name=module_name)
            
            return {
                "module_name": module_name,
                "importers": [dict(record) for record in importers_result],
                "imports": [dict(record) for record in imports_result]
            }
    
    def find_variable_usage_scope(self, variable_name: str, file_path: str = None) -> Dict[str, Any]:
        """Find the scope and usage patterns of a variable, optional file path filtering"""
        with self.driver.session() as session:
            if file_path:
                variable_instances = session.run("""
                    MATCH (var:Variable {name: $variable_name})
                    WHERE var.file_path ENDS WITH $file_path OR var.file_path = $file_path
                    OPTIONAL MATCH (container)-[:CONTAINS]->(var)
                    WHERE container:Function OR container:Class OR container:File
                    OPTIONAL MATCH (file:File)-[:CONTAINS]->(var)
                    RETURN DISTINCT
                        var.name as variable_name,
                        var.value as variable_value,
                        var.line_number as line_number,
                        var.context as context,
                        COALESCE(var.file_path, file.path) as file_path,
                        CASE 
                        WHEN container:Function THEN 'function'
                        WHEN container:Class THEN 'class'
                        ELSE 'module'
                    END as scope_type,
                    CASE 
                        WHEN container:Function THEN container.name
                        WHEN container:Class THEN container.name
                        ELSE 'module_level'
                    END as scope_name,
                    var.is_dependency as is_dependency
                ORDER BY var.is_dependency ASC, file_path, line_number
            """, variable_name=variable_name, file_path=file_path)
            else:
                variable_instances = session.run("""
                    MATCH (var:Variable {name: $variable_name})
                    OPTIONAL MATCH (container)-[:CONTAINS]->(var)
                    WHERE container:Function OR container:Class OR container:File
                    OPTIONAL MATCH (file:File)-[:CONTAINS]->(var)
                    RETURN DISTINCT
                        var.name as variable_name,
                        var.value as variable_value,
                        var.line_number as line_number,
                        var.context as context,
                        COALESCE(var.file_path, file.path) as file_path,
                        CASE 
                            WHEN container:Function THEN 'function'
                            WHEN container:Class THEN 'class'
                            ELSE 'module'
                        END as scope_type,
                        CASE 
                            WHEN container:Function THEN container.name
                            WHEN container:Class THEN container.name
                            ELSE 'module_level'
                        END as scope_name,
                        var.is_dependency as is_dependency
                    ORDER BY var.is_dependency ASC, file_path, line_number
                """, variable_name=variable_name)
            
            return {
                "variable_name": variable_name,
                "instances": [dict(record) for record in variable_instances]
            }
    
    def analyze_code_relationships(self, query_type: str, target: str, context: str = None) -> Dict[str, Any]:
        """Main method to analyze different types of code relationships with fixed return types"""
        query_type = query_type.lower().strip()
        
        try:
            if query_type == "find_callers":
                results = self.who_calls_function(target, context)
                return {
                    "query_type": "find_callers", "target": target, "context": context, "results": results,
                    "summary": f"Found {len(results)} functions that call '{target}'"
                }
            
            elif query_type == "find_callees":
                results = self.what_does_function_call(target, context)
                return {
                    "query_type": "find_callees", "target": target, "context": context, "results": results,
                    "summary": f"Function '{target}' calls {len(results)} other functions"
                }
                
            elif query_type == "find_importers":
                results = self.who_imports_module(target)
                return {
                    "query_type": "find_importers", "target": target, "results": results,
                    "summary": f"Found {len(results)} files that import '{target}'"
                }
                
            elif query_type == "find_functions_by_argument":
                results = self.find_functions_by_argument(target, context)
                return {
                    "query_type": "find_functions_by_argument", "target": target, "context": context, "results": results,
                    "summary": f"Found {len(results)} functions that take '{target}' as an argument"
                }
            
            elif query_type == "find_functions_by_decorator":
                results = self.find_functions_by_decorator(target, context)
                return {
                    "query_type": "find_functions_by_decorator", "target": target, "context": context, "results": results,
                    "summary": f"Found {len(results)} functions decorated with '{target}'"
                }
                
            elif query_type in ["who_modifies", "modifies", "mutations", "changes", "variable_usage"]:
                results = self.who_modifies_variable(target)
                return {
                    "query_type": "who_modifies", "target": target, "results": results,
                    "summary": f"Found {len(results)} containers that hold variable '{target}'"
                }
            
            elif query_type in ["class_hierarchy", "inheritance", "extends"]:
                results = self.find_class_hierarchy(target, context)
                return {
                    "query_type": "class_hierarchy", "target": target, "results": results,
                    "summary": f"Class '{target}' has {len(results['parent_classes'])} parents, {len(results['child_classes'])} children, and {len(results['methods'])} methods"
                }
            
            elif query_type in ["overrides", "implementations", "polymorphism"]:
                results = self.find_function_overrides(target)
                return {
                    "query_type": "overrides", "target": target, "results": results,
                    "summary": f"Found {len(results)} implementations of function '{target}'"
                }
            
            elif query_type in ["dead_code", "unused", "unreachable"]:
                results = self.find_dead_code()
                return {
                    "query_type": "dead_code", "results": results,
                    "summary": f"Found {len(results['potentially_unused_functions'])} potentially unused functions"
                }
            
            elif query_type == "find_complexity":
                limit = int(context) if context and context.isdigit() else 10
                results = self.find_most_complex_functions(limit)
                return {
                    "query_type": "find_complexity", "limit": limit, "results": results,
                    "summary": f"Found the top {len(results)} most complex functions"
                }
            
            elif query_type == "find_all_callers":
                results = self.find_all_callers(target, context)
                return {
                    "query_type": "find_all_callers", "target": target, "context": context, "results": results,
                    "summary": f"Found {len(results)} direct and indirect callers of '{target}'"
                }

            elif query_type == "find_all_callees":
                results = self.find_all_callees(target, context)
                return {
                    "query_type": "find_all_callees", "target": target, "context": context, "results": results,
                    "summary": f"Found {len(results)} direct and indirect callees of '{target}'"
                }
                
            elif query_type in ["call_chain", "path", "chain"]:
                if '->' in target:
                    start_func, end_func = target.split('->', 1)
                    # max_depth can be passed as context, default to 5 if not provided or invalid
                    max_depth = int(context) if context and context.isdigit() else 5
                    results = self.find_function_call_chain(start_func.strip(), end_func.strip(), max_depth)
                    return {
                        "query_type": "call_chain", "target": target, "results": results,
                        "summary": f"Found {len(results)} call chains from '{start_func.strip()}' to '{end_func.strip()}' (max depth: {max_depth})"
                    }
                else:
                    return {
                        "error": "For call_chain queries, use format 'start_function->end_function'",
                        "example": "main->process_data"
                    }
            
            elif query_type in ["module_deps", "module_dependencies", "module_usage"]:
                results = self.find_module_dependencies(target)
                return {
                    "query_type": "module_dependencies", "target": target, "results": results,
                    "summary": f"Module '{target}' is imported by {len(results['imported_by_files'])} files"
                }
            
            elif query_type in ["variable_scope", "var_scope", "variable_usage_scope"]:
                results = self.find_variable_usage_scope(target)
                return {
                    "query_type": "variable_scope", "target": target, "results": results,
                    "summary": f"Variable '{target}' has {len(results['instances'])} instances across different scopes"
                }
            
            else:
                return {
                    "error": f"Unknown query type: {query_type}",
                    "supported_types": [
                        "find_callers", "find_callees", "find_importers", "who_modifies",
                        "class_hierarchy", "overrides", "dead_code", "call_chain",
                        "module_deps", "variable_scope", "find_complexity"
                    ]
                }
        
        except Exception as e:
            return {
                "error": f"Error executing relationship query: {str(e)}",
                "query_type": query_type,
                "target": target
            }

    def get_cyclomatic_complexity(self, function_name: str, file_path: str = None) -> Optional[Dict]:
        """Get the cyclomatic complexity of a function."""
        with self.driver.session() as session:
            if file_path:
                # Use ENDS WITH for flexible path matching, or exact match
                query = """
                    MATCH (f:Function {name: $function_name})
                    WHERE f.file_path ENDS WITH $file_path OR f.file_path = $file_path
                    RETURN f.name as function_name, f.cyclomatic_complexity as complexity,
                           f.file_path as file_path, f.line_number as line_number
                """
                result = session.run(query, function_name=function_name, file_path=file_path)
            else:
                query = """
                    MATCH (f:Function {name: $function_name})
                    RETURN f.name as function_name, f.cyclomatic_complexity as complexity,
                           f.file_path as file_path, f.line_number as line_number
                """
                result = session.run(query, function_name=function_name)
            
            result_data = result.data()
            if result_data:
                return result_data[0]
            return None

    def find_most_complex_functions(self, limit: int = 10) -> List[Dict]:
        """Find the most complex functions based on cyclomatic complexity."""
        with self.driver.session() as session:
            query = """
                MATCH (f:Function)
                WHERE f.cyclomatic_complexity IS NOT NULL AND f.is_dependency = false
                RETURN f.name as function_name, f.file_path as file_path, f.cyclomatic_complexity as complexity, f.line_number as line_number
                ORDER BY f.cyclomatic_complexity DESC
                LIMIT $limit
            """
            result = session.run(query, limit=limit)
            return result.data()

    def list_indexed_repositories(self) -> List[Dict]:
        """List all indexed repositories."""
        with self.driver.session() as session:
            result = session.run("""
                MATCH (r:Repository)
                RETURN r.name as name, r.path as path, r.is_dependency as is_dependency
                ORDER BY r.name
            """)
            return result.data()

```

--------------------------------------------------------------------------------
/src/codegraphcontext/tools/graph_builder.py:
--------------------------------------------------------------------------------

```python

# src/codegraphcontext/tools/graph_builder.py
import asyncio
import pathspec
from pathlib import Path
from typing import Any, Coroutine, Dict, Optional, Tuple
from datetime import datetime

from ..core.database import DatabaseManager
from ..core.jobs import JobManager, JobStatus
from ..utils.debug_log import debug_log, info_logger, error_logger, warning_logger

# New imports for tree-sitter (using tree-sitter-language-pack)
from tree_sitter import Language, Parser
from ..utils.tree_sitter_manager import get_tree_sitter_manager
from ..cli.config_manager import get_config_value

class TreeSitterParser:
    """A generic parser wrapper for a specific language using tree-sitter."""

    def __init__(self, language_name: str):
        self.language_name = language_name
        self.ts_manager = get_tree_sitter_manager()
        
        # Get the language (cached) and create a new parser for this instance
        self.language: Language = self.ts_manager.get_language_safe(language_name)
        # In tree-sitter 0.25+, Parser takes language in constructor
        self.parser = Parser(self.language)

        self.language_specific_parser = None
        if self.language_name == 'python':
            from .languages.python import PythonTreeSitterParser
            self.language_specific_parser = PythonTreeSitterParser(self)
        elif self.language_name == 'javascript':
            from .languages.javascript import JavascriptTreeSitterParser
            self.language_specific_parser = JavascriptTreeSitterParser(self)
        elif self.language_name == 'go':
            from .languages.go import GoTreeSitterParser
            self.language_specific_parser = GoTreeSitterParser(self)
        elif self.language_name == 'typescript':
            from .languages.typescript import TypescriptTreeSitterParser
            self.language_specific_parser = TypescriptTreeSitterParser(self)
        elif self.language_name == 'cpp':
            from .languages.cpp import CppTreeSitterParser
            self.language_specific_parser = CppTreeSitterParser(self)
        elif self.language_name == 'rust':
            from .languages.rust import RustTreeSitterParser
            self.language_specific_parser = RustTreeSitterParser(self)
        elif self.language_name == 'c':
            from .languages.c import CTreeSitterParser
            self.language_specific_parser = CTreeSitterParser(self)
        elif self.language_name == 'java':
            from .languages.java import JavaTreeSitterParser
            self.language_specific_parser = JavaTreeSitterParser(self)
        elif self.language_name == 'ruby':
            from .languages.ruby import RubyTreeSitterParser
            self.language_specific_parser = RubyTreeSitterParser(self)
        elif self.language_name == 'c_sharp':
            from .languages.csharp import CSharpTreeSitterParser
            self.language_specific_parser = CSharpTreeSitterParser(self)
        elif self.language_name == 'php':
            from .languages.php import PhpTreeSitterParser
            self.language_specific_parser = PhpTreeSitterParser(self)
        elif self.language_name == 'kotlin':
            from .languages.kotlin import KotlinTreeSitterParser
            self.language_specific_parser = KotlinTreeSitterParser(self)
        elif self.language_name == 'scala':
            from .languages.scala import ScalaTreeSitterParser
            self.language_specific_parser = ScalaTreeSitterParser(self)
        elif self.language_name == 'swift':
            from .languages.swift import SwiftTreeSitterParser
            self.language_specific_parser = SwiftTreeSitterParser(self)



    def parse(self, file_path: Path, is_dependency: bool = False, **kwargs) -> Dict:
        """Dispatches parsing to the language-specific parser."""
        if self.language_specific_parser:
            return self.language_specific_parser.parse(file_path, is_dependency, **kwargs)
        else:
            raise NotImplementedError(f"No language-specific parser implemented for {self.language_name}")

class GraphBuilder:
    """Module for building and managing the Neo4j code graph."""

    def __init__(self, db_manager: DatabaseManager, job_manager: JobManager, loop: asyncio.AbstractEventLoop):
        self.db_manager = db_manager
        self.job_manager = job_manager
        self.loop = loop
        self.driver = self.db_manager.get_driver()
        self.parsers = {
            '.py': TreeSitterParser('python'),
            '.ipynb': TreeSitterParser('python'),
            '.js': TreeSitterParser('javascript'),
            '.jsx': TreeSitterParser('javascript'),
            '.mjs': TreeSitterParser('javascript'),
            '.cjs': TreeSitterParser('javascript'),
            '.go': TreeSitterParser('go'),
            '.ts': TreeSitterParser('typescript'),
            '.tsx': TreeSitterParser('typescript'),
            '.cpp': TreeSitterParser('cpp'),
            '.h': TreeSitterParser('cpp'),
            '.hpp': TreeSitterParser('cpp'),
            '.rs': TreeSitterParser('rust'),
            '.c': TreeSitterParser('c'),
            # '.h': TreeSitterParser('c'), # Need to write an algo for distinguishing C vs C++ headers
            '.java': TreeSitterParser('java'),
            '.rb': TreeSitterParser('ruby'),
            '.java': TreeSitterParser('java'),
            '.rb': TreeSitterParser('ruby'),
            '.cs': TreeSitterParser('c_sharp'),
            '.php': TreeSitterParser('php'),
            '.kt': TreeSitterParser('kotlin'),
            '.scala': TreeSitterParser('scala'),
            '.sc': TreeSitterParser('scala'),
            '.swift': TreeSitterParser('swift'),
        }
        self.create_schema()

    # A general schema creation based on common features across languages
    def create_schema(self):
        """Create constraints and indexes in Neo4j."""
        # When adding a new node type with a unique key, add its constraint here.
        with self.driver.session() as session:
            try:
                session.run("CREATE CONSTRAINT repository_path IF NOT EXISTS FOR (r:Repository) REQUIRE r.path IS UNIQUE")
                session.run("CREATE CONSTRAINT file_path IF NOT EXISTS FOR (f:File) REQUIRE f.path IS UNIQUE")
                session.run("CREATE CONSTRAINT directory_path IF NOT EXISTS FOR (d:Directory) REQUIRE d.path IS UNIQUE")
                session.run("CREATE CONSTRAINT function_unique IF NOT EXISTS FOR (f:Function) REQUIRE (f.name, f.file_path, f.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT class_unique IF NOT EXISTS FOR (c:Class) REQUIRE (c.name, c.file_path, c.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT trait_unique IF NOT EXISTS FOR (t:Trait) REQUIRE (t.name, t.file_path, t.line_number) IS UNIQUE") # Added trait constraint
                session.run("CREATE CONSTRAINT interface_unique IF NOT EXISTS FOR (i:Interface) REQUIRE (i.name, i.file_path, i.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT macro_unique IF NOT EXISTS FOR (m:Macro) REQUIRE (m.name, m.file_path, m.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT variable_unique IF NOT EXISTS FOR (v:Variable) REQUIRE (v.name, v.file_path, v.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT module_name IF NOT EXISTS FOR (m:Module) REQUIRE m.name IS UNIQUE")
                session.run("CREATE CONSTRAINT struct_cpp IF NOT EXISTS FOR (cstruct: Struct) REQUIRE (cstruct.name, cstruct.file_path, cstruct.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT enum_cpp IF NOT EXISTS FOR (cenum: Enum) REQUIRE (cenum.name, cenum.file_path, cenum.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT union_cpp IF NOT EXISTS FOR (cunion: Union) REQUIRE (cunion.name, cunion.file_path, cunion.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT annotation_unique IF NOT EXISTS FOR (a:Annotation) REQUIRE (a.name, a.file_path, a.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT record_unique IF NOT EXISTS FOR (r:Record) REQUIRE (r.name, r.file_path, r.line_number) IS UNIQUE")
                session.run("CREATE CONSTRAINT property_unique IF NOT EXISTS FOR (p:Property) REQUIRE (p.name, p.file_path, p.line_number) IS UNIQUE")
                
                # Indexes for language attribute
                session.run("CREATE INDEX function_lang IF NOT EXISTS FOR (f:Function) ON (f.lang)")
                session.run("CREATE INDEX class_lang IF NOT EXISTS FOR (c:Class) ON (c.lang)")
                session.run("CREATE INDEX annotation_lang IF NOT EXISTS FOR (a:Annotation) ON (a.lang)")
                session.run("""
                    CREATE FULLTEXT INDEX code_search_index IF NOT EXISTS 
                    FOR (n:Function|Class|Variable) 
                    ON EACH [n.name, n.source, n.docstring]
                """ )
                
                info_logger("Database schema verified/created successfully")
            except Exception as e:
                warning_logger(f"Schema creation warning: {e}")


    def _pre_scan_for_imports(self, files: list[Path]) -> dict:
        """Dispatches pre-scan to the correct language-specific implementation."""
        imports_map = {}
        
        # Group files by language/extension
        files_by_lang = {}
        for file in files:
            if file.suffix in self.parsers:
                lang_ext = file.suffix
                if lang_ext not in files_by_lang:
                    files_by_lang[lang_ext] = []
                files_by_lang[lang_ext].append(file)

        if '.py' in files_by_lang:
            from .languages import python as python_lang_module
            imports_map.update(python_lang_module.pre_scan_python(files_by_lang['.py'], self.parsers['.py']))
        if '.ipynb' in files_by_lang:
            from .languages import python as python_lang_module
            imports_map.update(python_lang_module.pre_scan_python(files_by_lang['.ipynb'], self.parsers['.ipynb']))
        if '.js' in files_by_lang:
            from .languages import javascript as js_lang_module
            imports_map.update(js_lang_module.pre_scan_javascript(files_by_lang['.js'], self.parsers['.js']))
        if '.jsx' in files_by_lang:
            from .languages import javascript as js_lang_module
            imports_map.update(js_lang_module.pre_scan_javascript(files_by_lang['.jsx'], self.parsers['.jsx']))
        if '.mjs' in files_by_lang:
            from .languages import javascript as js_lang_module
            imports_map.update(js_lang_module.pre_scan_javascript(files_by_lang['.mjs'], self.parsers['.mjs']))
        if '.cjs' in files_by_lang:
            from .languages import javascript as js_lang_module
            imports_map.update(js_lang_module.pre_scan_javascript(files_by_lang['.cjs'], self.parsers['.cjs']))
        if '.go' in files_by_lang:
             from .languages import go as go_lang_module
             imports_map.update(go_lang_module.pre_scan_go(files_by_lang['.go'], self.parsers['.go']))
        if '.ts' in files_by_lang:
            from .languages import typescript as ts_lang_module
            imports_map.update(ts_lang_module.pre_scan_typescript(files_by_lang['.ts'], self.parsers['.ts']))
        if '.tsx' in files_by_lang:
            from .languages import typescriptjsx as tsx_lang_module
            imports_map.update(tsx_lang_module.pre_scan_typescript(files_by_lang['.tsx'], self.parsers['.tsx']))
        if '.cpp' in files_by_lang:
            from .languages import cpp as cpp_lang_module
            imports_map.update(cpp_lang_module.pre_scan_cpp(files_by_lang['.cpp'], self.parsers['.cpp']))
        if '.h' in files_by_lang:
            from .languages import cpp as cpp_lang_module
            imports_map.update(cpp_lang_module.pre_scan_cpp(files_by_lang['.h'], self.parsers['.h']))
        if '.hpp' in files_by_lang:
            from .languages import cpp as cpp_lang_module
            imports_map.update(cpp_lang_module.pre_scan_cpp(files_by_lang['.hpp'], self.parsers['.hpp']))
        if '.rs' in files_by_lang:
            from .languages import rust as rust_lang_module
            imports_map.update(rust_lang_module.pre_scan_rust(files_by_lang['.rs'], self.parsers['.rs']))
        if '.c' in files_by_lang:
            from .languages import c as c_lang_module
            imports_map.update(c_lang_module.pre_scan_c(files_by_lang['.c'], self.parsers['.c']))
        elif '.java' in files_by_lang:
            from .languages import java as java_lang_module
            imports_map.update(java_lang_module.pre_scan_java(files_by_lang['.java'], self.parsers['.java']))
        elif '.rb' in files_by_lang:
            from .languages import ruby as ruby_lang_module
            imports_map.update(ruby_lang_module.pre_scan_ruby(files_by_lang['.rb'], self.parsers['.rb']))
        elif '.cs' in files_by_lang:
            from .languages import csharp as csharp_lang_module
            imports_map.update(csharp_lang_module.pre_scan_csharp(files_by_lang['.cs'], self.parsers['.cs']))
        if '.kt' in files_by_lang:
            from .languages import kotlin as kotlin_lang_module
            imports_map.update(kotlin_lang_module.pre_scan_kotlin(files_by_lang['.kt'], self.parsers['.kt']))
        if '.scala' in files_by_lang:
            from .languages import scala as scala_lang_module
            imports_map.update(scala_lang_module.pre_scan_scala(files_by_lang['.scala'], self.parsers['.scala']))
        if '.sc' in files_by_lang:
            from .languages import scala as scala_lang_module
            imports_map.update(scala_lang_module.pre_scan_scala(files_by_lang['.sc'], self.parsers['.sc']))
        if '.swift' in files_by_lang:
            from .languages import swift as swift_lang_module
            imports_map.update(swift_lang_module.pre_scan_swift(files_by_lang['.swift'], self.parsers['.swift']))
            
        return imports_map

    # Language-agnostic method
    def add_repository_to_graph(self, repo_path: Path, is_dependency: bool = False):
        """Adds a repository node using its absolute path as the unique key."""
        repo_name = repo_path.name
        repo_path_str = str(repo_path.resolve())
        with self.driver.session() as session:
            session.run(
                """
                MERGE (r:Repository {path: $path})
                SET r.name = $name, r.is_dependency = $is_dependency
                """,
                path=repo_path_str,
                name=repo_name,
                is_dependency=is_dependency,
            )

    # First pass to add file and its contents
    def add_file_to_graph(self, file_data: Dict, repo_name: str, imports_map: dict):
        info_logger("Executing add_file_to_graph with my change!")
        """Adds a file and its contents within a single, unified session."""
        file_path_str = str(Path(file_data['file_path']).resolve())
        file_name = Path(file_path_str).name
        is_dependency = file_data.get('is_dependency', False)

        with self.driver.session() as session:
            try:
                # Match repository by path, not name, to avoid conflicts with same-named folders at different locations
                repo_result = session.run("MATCH (r:Repository {path: $repo_path}) RETURN r.path as path", repo_path=str(Path(file_data['repo_path']).resolve())).single()
                relative_path = str(Path(file_path_str).relative_to(Path(repo_result['path']))) if repo_result else file_name
            except ValueError:
                relative_path = file_name

            session.run("""
                MERGE (f:File {path: $path})
                SET f.name = $name, f.relative_path = $relative_path, f.is_dependency = $is_dependency
            """, path=file_path_str, name=file_name, relative_path=relative_path, is_dependency=is_dependency)

            file_path_obj = Path(file_path_str)
            repo_path_obj = Path(repo_result['path'])
            
            relative_path_to_file = file_path_obj.relative_to(repo_path_obj)
            
            parent_path = str(repo_path_obj)
            parent_label = 'Repository'

            for part in relative_path_to_file.parts[:-1]:
                current_path = Path(parent_path) / part
                current_path_str = str(current_path)
                
                session.run(f"""
                    MATCH (p:{parent_label} {{path: $parent_path}})
                    MERGE (d:Directory {{path: $current_path}})
                    SET d.name = $part
                    MERGE (p)-[:CONTAINS]->(d)
                """, parent_path=parent_path, current_path=current_path_str, part=part)

                parent_path = current_path_str
                parent_label = 'Directory'

            session.run(f"""
                MATCH (p:{parent_label} {{path: $parent_path}})
                MATCH (f:File {{path: $file_path}})
                MERGE (p)-[:CONTAINS]->(f)
            """, parent_path=parent_path, file_path=file_path_str)

            # CONTAINS relationships for functions, classes, and variables
            # To add a new language-specific node type (e.g., 'Trait' for Rust):
            # 1. Ensure your language-specific parser returns a list under a unique key (e.g., 'traits': [...] ).
            # 2. Add a new constraint for the new label in the `create_schema` method.
            # 3. Add a new entry to the `item_mappings` list below (e.g., (file_data.get('traits', []), 'Trait') ).
            item_mappings = [
                (file_data.get('functions', []), 'Function'),
                (file_data.get('classes', []), 'Class'),
                (file_data.get('traits', []), 'Trait'), # <-- Added trait mapping
                (file_data.get('variables', []), 'Variable'),
                (file_data.get('interfaces', []), 'Interface'),
                (file_data.get('macros', []), 'Macro'),
                (file_data.get('structs',[]), 'Struct'),
                (file_data.get('enums',[]), 'Enum'),
                (file_data.get('unions',[]), 'Union'),
                (file_data.get('records',[]), 'Record'),
                (file_data.get('properties',[]), 'Property'),
            ]
            for item_data, label in item_mappings:
                for item in item_data:
                    # Ensure cyclomatic_complexity is set for functions
                    if label == 'Function' and 'cyclomatic_complexity' not in item:
                        item['cyclomatic_complexity'] = 1 # Default value

                    query = f"""
                        MATCH (f:File {{path: $file_path}})
                        MERGE (n:{label} {{name: $name, file_path: $file_path, line_number: $line_number}})
                        SET n += $props
                        MERGE (f)-[:CONTAINS]->(n)
                    """
                    session.run(query, file_path=file_path_str, name=item['name'], line_number=item['line_number'], props=item)
                    
                    if label == 'Function':
                        for arg_name in item.get('args', []):
                            session.run("""
                                MATCH (fn:Function {name: $func_name, file_path: $file_path, line_number: $line_number})
                                MERGE (p:Parameter {name: $arg_name, file_path: $file_path, function_line_number: $line_number})
                                MERGE (fn)-[:HAS_PARAMETER]->(p)
                            """, func_name=item['name'], file_path=file_path_str, line_number=item['line_number'], arg_name=arg_name)

            # --- NEW: persist Ruby Modules ---
            for m in file_data.get('modules', []):
                session.run("""
                    MERGE (mod:Module {name: $name})
                    ON CREATE SET mod.lang = $lang
                    ON MATCH  SET mod.lang = coalesce(mod.lang, $lang)
                """, name=m["name"], lang=file_data.get("lang"))

            # Create CONTAINS relationships for nested functions
            for item in file_data.get('functions', []):
                if item.get("context_type") == "function_definition":
                    session.run("""
                        MATCH (outer:Function {name: $context, file_path: $file_path})
                        MATCH (inner:Function {name: $name, file_path: $file_path, line_number: $line_number})
                        MERGE (outer)-[:CONTAINS]->(inner)
                    """, context=item["context"], file_path=file_path_str, name=item["name"], line_number=item["line_number"])

            # Handle imports and create IMPORTS relationships
            for imp in file_data.get('imports', []):
                info_logger(f"Processing import: {imp}")
                lang = file_data.get('lang')
                if lang == 'javascript':
                    # New, correct logic for JS
                    module_name = imp.get('source')
                    if not module_name: continue

                    # Use a map for relationship properties to handle optional alias and line_number
                    rel_props = {'imported_name': imp.get('name', '*')}
                    if imp.get('alias'):
                        rel_props['alias'] = imp.get('alias')
                    if imp.get('line_number'):
                        rel_props['line_number'] = imp.get('line_number')

                    session.run("""
                        MATCH (f:File {path: $file_path})
                        MERGE (m:Module {name: $module_name})
                        MERGE (f)-[r:IMPORTS]->(m)
                        SET r += $props
                    """, file_path=file_path_str, module_name=module_name, props=rel_props)
                else:
                    # Existing logic for Python (and other languages)
                    set_clauses = ["m.alias = $alias"]
                    if 'full_import_name' in imp:
                        set_clauses.append("m.full_import_name = $full_import_name")
                    set_clause_str = ", ".join(set_clauses)

                    # Build relationship properties
                    rel_props = {}
                    if imp.get('line_number'):
                        rel_props['line_number'] = imp.get('line_number')
                    if imp.get('alias'):
                        rel_props['alias'] = imp.get('alias')

                    session.run(f"""
                        MATCH (f:File {{path: $file_path}})
                        MERGE (m:Module {{name: $name}})
                        SET {set_clause_str}
                        MERGE (f)-[r:IMPORTS]->(m)
                        SET r += $rel_props
                    """, file_path=file_path_str, rel_props=rel_props, **imp)


            # Handle CONTAINS relationship between class to their children like variables
            for func in file_data.get('functions', []):
                if func.get('class_context'):
                    session.run("""
                        MATCH (c:Class {name: $class_name, file_path: $file_path})
                        MATCH (fn:Function {name: $func_name, file_path: $file_path, line_number: $func_line})
                        MERGE (c)-[:CONTAINS]->(fn)
                    """, 
                    class_name=func['class_context'],
                    file_path=file_path_str,
                    func_name=func['name'],
                    func_line=func['line_number'])

            # --- NEW: Class INCLUDES Module (Ruby mixins) ---
            for inc in file_data.get('module_inclusions', []):
                session.run("""
                    MATCH (c:Class {name: $class_name, file_path: $file_path})
                    MERGE (m:Module {name: $module_name})
                    MERGE (c)-[:INCLUDES]->(m)
                """,
                class_name=inc["class"],
                file_path=file_path_str,
                module_name=inc["module"])

            # Class inheritance is handled in a separate pass after all files are processed.
            # Function calls are also handled in a separate pass after all files are processed.

    # Second pass to create relationships that depend on all files being present like call functions and class inheritance
    def _create_function_calls(self, session, file_data: Dict, imports_map: dict):
        """Create CALLS relationships with a unified, prioritized logic flow for all call types."""
        caller_file_path = str(Path(file_data['file_path']).resolve())
        local_names = {f['name'] for f in file_data.get('functions', [])} | \
                      {c['name'] for c in file_data.get('classes', [])}
        local_imports = {imp.get('alias') or imp['name'].split('.')[-1]: imp['name'] 
                        for imp in file_data.get('imports', [])}
        
        for call in file_data.get('function_calls', []):
            called_name = call['name']
            if called_name in __builtins__: continue

            resolved_path = None
            full_call = call.get('full_name', called_name)
            base_obj = full_call.split('.')[0] if '.' in full_call else None
            
            # For chained calls like self.graph_builder.method(), we need to look up 'method'
            # For direct calls like self.method(), we can use the caller's file
            is_chained_call = full_call.count('.') > 1 if '.' in full_call else False
            
            # Determine the lookup name:
            # - For chained calls (self.attr.method), use the actual method name
            # - For direct calls (self.method or module.function), use the base object
            if is_chained_call and base_obj in ('self', 'this', 'super', 'super()', 'cls', '@'):
                lookup_name = called_name  # Use the actual method name for lookup
            else:
                lookup_name = base_obj if base_obj else called_name

            # 1. Check for local context keywords/direct local names
            # Only resolve to caller_file_path for DIRECT self/this calls, not chained ones
            if base_obj in ('self', 'this', 'super', 'super()', 'cls', '@') and not is_chained_call:
                resolved_path = caller_file_path
            elif lookup_name in local_names:
                resolved_path = caller_file_path
            
            # 2. Check inferred type if available
            elif call.get('inferred_obj_type'):
                obj_type = call['inferred_obj_type']
                possible_paths = imports_map.get(obj_type, [])
                if len(possible_paths) > 0:
                    resolved_path = possible_paths[0]
            
            # 3. Check imports map with validation against local imports
            if not resolved_path:
                possible_paths = imports_map.get(lookup_name, [])
                if len(possible_paths) == 1:
                    resolved_path = possible_paths[0]
                elif len(possible_paths) > 1:
                    if lookup_name in local_imports:
                        full_import_name = local_imports[lookup_name]
                        
                        # Optimization: Check if the FQN is directly in imports_map (from pre-scan)
                        if full_import_name in imports_map:
                             direct_paths = imports_map[full_import_name]
                             if direct_paths and len(direct_paths) == 1:
                                 resolved_path = direct_paths[0]
                        
                        if not resolved_path:
                            for path in possible_paths:
                                if full_import_name.replace('.', '/') in path:
                                    resolved_path = path
                                    break
            
            if not resolved_path:
                 warning_logger(f"Could not resolve call {called_name} (lookup: {lookup_name}) in {caller_file_path}")
            # else:
            #      info_logger(f"Resolved call {called_name} -> {resolved_path}")
            
            # Legacy fallback block (was mis-indented)
            if not resolved_path:
                possible_paths = imports_map.get(lookup_name, [])
                if len(possible_paths) > 0:
                     # Final fallback: global candidate
                     # Check if it was imported explicitly, otherwise risky
                     if lookup_name in local_imports:
                         # We already tried specific matching above, but if we are here
                         # it means we had ambiguity without matching path?
                         pass
                     else:
                        # Fallback to first available if not imported? Or skip?
                        # Original logic: resolved_path = possible_paths[0]
                        # But wait, original code logic was:
                        pass
            if not resolved_path:
                if called_name in local_names:
                    resolved_path = caller_file_path
                elif called_name in imports_map and imports_map[called_name]:
                    # Check if any path in imports_map for called_name matches current file's imports
                    candidates = imports_map[called_name]
                    for path in candidates:
                        for imp_name in local_imports.values():
                            if imp_name.replace('.', '/') in path:
                                resolved_path = path
                                break
                        if resolved_path: break
                    if not resolved_path:
                        resolved_path = candidates[0]
                else:
                    resolved_path = caller_file_path

            caller_context = call.get('context')
            if caller_context and len(caller_context) == 3 and caller_context[0] is not None:
                caller_name, _, caller_line_number = caller_context
                # if called_name == "sumOfSquares":
                    # print(f"DEBUG_CYPHER: caller={caller_name}, caller_line={caller_line_number}, called={called_name}, path={resolved_path}")

                session.run("""
                    MATCH (caller) WHERE (caller:Function OR caller:Class) 
                      AND caller.name = $caller_name 
                      AND caller.file_path = $caller_file_path 
                      AND caller.line_number = $caller_line_number
                    MATCH (called) WHERE (called:Function OR called:Class)
                      AND called.name = $called_name 
                      AND called.file_path = $called_file_path
                    
                    WITH caller, called
                    OPTIONAL MATCH (called)-[:CONTAINS]->(init:Function)
                    WHERE called:Class AND init.name IN ["__init__", "constructor"]
                    WITH caller, COALESCE(init, called) as final_target
                    
                    MERGE (caller)-[:CALLS {line_number: $line_number, args: $args, full_call_name: $full_call_name}]->(final_target)
                """,
                caller_name=caller_name,
                caller_file_path=caller_file_path,
                caller_line_number=caller_line_number,
                called_name=called_name,
                called_file_path=resolved_path,
                line_number=call['line_number'],
                args=call.get('args', []),
                full_call_name=call.get('full_name', called_name))
            else:
                session.run("""
                    MATCH (caller:File {path: $caller_file_path})
                    MATCH (called) WHERE (called:Function OR called:Class)
                      AND called.name = $called_name 
                      AND called.file_path = $called_file_path
                    
                    WITH caller, called
                    OPTIONAL MATCH (called)-[:CONTAINS]->(init:Function)
                    WHERE called:Class AND init.name IN ["__init__", "constructor"]
                    WITH caller, COALESCE(init, called) as final_target

                    MERGE (caller)-[:CALLS {line_number: $line_number, args: $args, full_call_name: $full_call_name}]->(final_target)
                """,
                caller_file_path=caller_file_path,
                called_name=called_name,
                called_file_path=resolved_path,
                line_number=call['line_number'],
                args=call.get('args', []),
                full_call_name=call.get('full_name', called_name))

    def _create_all_function_calls(self, all_file_data: list[Dict], imports_map: dict):
        """Create CALLS relationships for all functions after all files have been processed."""
        with self.driver.session() as session:
            for file_data in all_file_data:
                self._create_function_calls(session, file_data, imports_map)

    def _create_inheritance_links(self, session, file_data: Dict, imports_map: dict):
        """Create INHERITS relationships with a more robust resolution logic."""
        caller_file_path = str(Path(file_data['file_path']).resolve())
        local_class_names = {c['name'] for c in file_data.get('classes', [])}
        # Create a map of local import aliases/names to full import names
        local_imports = {imp.get('alias') or imp['name'].split('.')[-1]: imp['name']
                         for imp in file_data.get('imports', [])}

        for class_item in file_data.get('classes', []):
            if not class_item.get('bases'):
                continue

            for base_class_str in class_item['bases']:
                if base_class_str == 'object':
                    continue

                resolved_path = None
                target_class_name = base_class_str.split('.')[-1]

                # Handle qualified names like module.Class or alias.Class
                if '.' in base_class_str:
                    lookup_name = base_class_str.split('.')[0]
                    
                    # Case 1: The prefix is a known import
                    if lookup_name in local_imports:
                        full_import_name = local_imports[lookup_name]
                        possible_paths = imports_map.get(target_class_name, [])
                        # Find the path that corresponds to the imported module
                        for path in possible_paths:
                            if full_import_name.replace('.', '/') in path:
                                resolved_path = path
                                break
                # Handle simple names
                else:
                    lookup_name = base_class_str
                    # Case 2: The base class is in the same file
                    if lookup_name in local_class_names:
                        resolved_path = caller_file_path
                    # Case 3: The base class was imported directly (e.g., from module import Parent)
                    elif lookup_name in local_imports:
                        full_import_name = local_imports[lookup_name]
                        possible_paths = imports_map.get(target_class_name, [])
                        for path in possible_paths:
                            if full_import_name.replace('.', '/') in path:
                                resolved_path = path
                                break
                    # Case 4: Fallback to global map (less reliable)
                    elif lookup_name in imports_map:
                        possible_paths = imports_map[lookup_name]
                        if len(possible_paths) == 1:
                            resolved_path = possible_paths[0]
                
                # If a path was found, create the relationship
                if resolved_path:
                    session.run("""
                        MATCH (child:Class {name: $child_name, file_path: $file_path})
                        MATCH (parent:Class {name: $parent_name, file_path: $resolved_parent_file_path})
                        MERGE (child)-[:INHERITS]->(parent)
                    """,
                    child_name=class_item['name'],
                    file_path=caller_file_path,
                    parent_name=target_class_name,
                    resolved_parent_file_path=resolved_path)


    def _create_csharp_inheritance_and_interfaces(self, session, file_data: Dict, imports_map: dict):
        """Create INHERITS and IMPLEMENTS relationships for C# types."""
        if file_data.get('lang') != 'c_sharp':
            return
            
        caller_file_path = str(Path(file_data['file_path']).resolve())
        
        # Collect all local type names
        local_type_names = set()
        for type_list in ['classes', 'interfaces', 'structs', 'records']:
            local_type_names.update(t['name'] for t in file_data.get(type_list, []))
        
        # Process all type declarations that can have bases
        for type_list_name, type_label in [('classes', 'Class'), ('structs', 'Struct'), ('records', 'Record'), ('interfaces', 'Interface')]:
            for type_item in file_data.get(type_list_name, []):
                if not type_item.get('bases'):
                    continue
                
                for base_str in type_item['bases']:
                    # Clean up the base name (remove generic parameters, etc.)
                    base_name = base_str.split('<')[0].strip()
                    
                    # Determine if this is an interface
                    is_interface = False
                    resolved_path = caller_file_path
                    
                    # Check if base is a local interface
                    for iface in file_data.get('interfaces', []):
                        if iface['name'] == base_name:
                            is_interface = True
                            break
                    
                    # Check if base is in imports_map
                    if base_name in imports_map:
                        possible_paths = imports_map[base_name]
                        if len(possible_paths) > 0:
                            resolved_path = possible_paths[0]
                    
                    # For C#, first base is usually the class (if any), rest are interfaces
                    base_index = type_item['bases'].index(base_str)
                    
                    # Try to determine if it's an interface
                    if is_interface or (base_index > 0 and type_label == 'Class'):
                        # This is an IMPLEMENTS relationship
                        session.run("""
                            MATCH (child {name: $child_name, file_path: $file_path})
                            WHERE child:Class OR child:Struct OR child:Record
                            MATCH (iface:Interface {name: $interface_name})
                            MERGE (child)-[:IMPLEMENTS]->(iface)
                        """,
                        child_name=type_item['name'],
                        file_path=caller_file_path,
                        interface_name=base_name)
                    else:
                        # This is an INHERITS relationship
                        session.run("""
                            MATCH (child {name: $child_name, file_path: $file_path})
                            WHERE child:Class OR child:Record OR child:Interface
                            MATCH (parent {name: $parent_name})
                            WHERE parent:Class OR parent:Record OR parent:Interface
                            MERGE (child)-[:INHERITS]->(parent)
                        """,
                        child_name=type_item['name'],
                        file_path=caller_file_path,
                        parent_name=base_name)

    def _create_all_inheritance_links(self, all_file_data: list[Dict], imports_map: dict):
        """Create INHERITS relationships for all classes after all files have been processed."""
        with self.driver.session() as session:
            for file_data in all_file_data:
                # Handle C# separately
                if file_data.get('lang') == 'c_sharp':
                    self._create_csharp_inheritance_and_interfaces(session, file_data, imports_map)
                else:
                    self._create_inheritance_links(session, file_data, imports_map)
                
    def delete_file_from_graph(self, file_path: str):
        """Deletes a file and all its contained elements and relationships."""
        file_path_str = str(Path(file_path).resolve())
        with self.driver.session() as session:
            parents_res = session.run("""
                MATCH (f:File {path: $path})<-[:CONTAINS*]-(d:Directory)
                RETURN d.path as path ORDER BY d.path DESC
            """, path=file_path_str)
            parent_paths = [record["path"] for record in parents_res]

            session.run(
                """
                MATCH (f:File {path: $path})
                OPTIONAL MATCH (f)-[:CONTAINS]->(element)
                DETACH DELETE f, element
                """,
                path=file_path_str,
            )
            info_logger(f"Deleted file and its elements from graph: {file_path_str}")

            for path in parent_paths:
                session.run("""
                    MATCH (d:Directory {path: $path})
                    WHERE NOT (d)-[:CONTAINS]->()
                    DETACH DELETE d
                """, path=path)

    def delete_repository_from_graph(self, repo_path: str) -> bool:
        """Deletes a repository and all its contents from the graph. Returns True if deleted, False if not found."""
        repo_path_str = str(Path(repo_path).resolve())
        with self.driver.session() as session:
            # Check if it exists
            result = session.run("MATCH (r:Repository {path: $path}) RETURN count(r) as cnt", path=repo_path_str).single()
            if not result or result["cnt"] == 0:
                warning_logger(f"Attempted to delete non-existent repository: {repo_path_str}")
                return False

            session.run("""MATCH (r:Repository {path: $path})
                          OPTIONAL MATCH (r)-[:CONTAINS*]->(e)
                          DETACH DELETE r, e""", path=repo_path_str)
            info_logger(f"Deleted repository and its contents from graph: {repo_path_str}")
            return True

    def update_file_in_graph(self, file_path: Path, repo_path: Path, imports_map: dict):
        """Updates a single file's nodes in the graph."""
        file_path_str = str(file_path.resolve())
        repo_name = repo_path.name
        
        self.delete_file_from_graph(file_path_str)

        if file_path.exists():
            file_data = self.parse_file(repo_path, file_path)
            
            if "error" not in file_data:
                self.add_file_to_graph(file_data, repo_name, imports_map)
                return file_data
            else:
                error_logger(f"Skipping graph add for {file_path_str} due to parsing error: {file_data['error']}")
                return None
        else:
            return {"deleted": True, "path": file_path_str}

    def parse_file(self, repo_path: Path, file_path: Path, is_dependency: bool = False) -> Dict:
        """Parses a file with the appropriate language parser and extracts code elements."""
        parser = self.parsers.get(file_path.suffix)
        if not parser:
            warning_logger(f"No parser found for file extension {file_path.suffix}. Skipping {file_path}")
            return {"file_path": str(file_path), "error": f"No parser for {file_path.suffix}"}

        debug_log(f"[parse_file] Starting parsing for: {file_path} with {parser.language_name} parser")
        try:
            if parser.language_name == 'python':
                is_notebook = file_path.suffix == '.ipynb'
                file_data = parser.parse(file_path, is_dependency, is_notebook=is_notebook)
            else:
                file_data = parser.parse(file_path, is_dependency)
            file_data['repo_path'] = str(repo_path)
            debug_log(f"[parse_file] Successfully parsed: {file_path}")
            return file_data
            
        except Exception as e:
            error_logger(f"Error parsing {file_path} with {parser.language_name} parser: {e}")
            debug_log(f"[parse_file] Error parsing {file_path}: {e}")
            return {"file_path": str(file_path), "error": str(e)}

    def estimate_processing_time(self, path: Path) -> Optional[Tuple[int, float]]:
        """Estimate processing time and file count"""
        try:
            supported_extensions = self.parsers.keys()
            if path.is_file():
                if path.suffix in supported_extensions:
                    files = [path]
                else:
                    return 0, 0.0 # Not a supported file type
            else:
                all_files = path.rglob("*")
                files = [f for f in all_files if f.is_file() and f.suffix in supported_extensions]

                # Filter default ignored directories
                ignore_dirs_str = get_config_value("IGNORE_DIRS") or ""
                if ignore_dirs_str:
                    ignore_dirs = {d.strip().lower() for d in ignore_dirs_str.split(',') if d.strip()}
                    if ignore_dirs:
                        kept_files = []
                        for f in files:
                            try:
                                parts = set(p.lower() for p in f.relative_to(path).parent.parts)
                                if not parts.intersection(ignore_dirs):
                                    kept_files.append(f)
                            except ValueError:
                                kept_files.append(f)
                        files = kept_files
            
            total_files = len(files)
            estimated_time = total_files * 0.05 # tree-sitter is faster
            return total_files, estimated_time
        except Exception as e:
            error_logger(f"Could not estimate processing time for {path}: {e}")
            return None

    async def build_graph_from_path_async(
        self, path: Path, is_dependency: bool = False, job_id: str = None
    ):
        """Builds graph from a directory or file path."""
        try:
            if job_id:
                self.job_manager.update_job(job_id, status=JobStatus.RUNNING)
            
            self.add_repository_to_graph(path, is_dependency)
            repo_name = path.name

            # Search for .cgcignore upwards
            cgcignore_path = None
            ignore_root = path.resolve()
            
            # Start search from path (or parent if path is file)
            curr = path.resolve()
            if not curr.is_dir():
                curr = curr.parent

            # Walk up looking for .cgcignore
            while True:
                candidate = curr / ".cgcignore"
                if candidate.exists():
                    cgcignore_path = candidate
                    ignore_root = curr
                    debug_log(f"Found .cgcignore at {ignore_root}")
                    break
                if curr.parent == curr: # Root hit
                    break
                curr = curr.parent

            if cgcignore_path:
                with open(cgcignore_path) as f:
                    ignore_patterns = f.read().splitlines()
                spec = pathspec.PathSpec.from_lines('gitwildmatch', ignore_patterns)
            else:
                spec = None

            supported_extensions = self.parsers.keys()
            all_files = path.rglob("*") if path.is_dir() else [path]
            files = [f for f in all_files if f.is_file() and f.suffix in supported_extensions]

            # Filter default ignored directories
            ignore_dirs_str = get_config_value("IGNORE_DIRS") or ""
            if ignore_dirs_str and path.is_dir():
                ignore_dirs = {d.strip().lower() for d in ignore_dirs_str.split(',') if d.strip()}
                if ignore_dirs:
                    kept_files = []
                    for f in files:
                        try:
                            # Check if any parent directory in the relative path is in ignore list
                            parts = set(p.lower() for p in f.relative_to(path).parent.parts)
                            if not parts.intersection(ignore_dirs):
                                kept_files.append(f)
                            else:
                                # debug_log(f"Skipping default ignored file: {f}")
                                pass
                        except ValueError:
                             kept_files.append(f)
                    files = kept_files
            
            if spec:
                filtered_files = []
                for f in files:
                    try:
                        # Match relative to the directory containing .cgcignore
                        rel_path = f.relative_to(ignore_root)
                        if not spec.match_file(str(rel_path)):
                            filtered_files.append(f)
                        else:
                            debug_log(f"Ignored file based on .cgcignore: {rel_path}")
                    except ValueError:
                        # Should not happen if ignore_root is a parent, but safety fallback
                        filtered_files.append(f)
                files = filtered_files
            if job_id:
                self.job_manager.update_job(job_id, total_files=len(files))
            
            debug_log("Starting pre-scan to build imports map...")
            imports_map = self._pre_scan_for_imports(files)
            debug_log(f"Pre-scan complete. Found {len(imports_map)} definitions.")

            all_file_data = []

            processed_count = 0
            for file in files:
                if file.is_file():
                    if job_id:
                        self.job_manager.update_job(job_id, current_file=str(file))
                    repo_path = path.resolve() if path.is_dir() else file.parent.resolve()
                    file_data = self.parse_file(repo_path, file, is_dependency)
                    if "error" not in file_data:
                        self.add_file_to_graph(file_data, repo_name, imports_map)
                        all_file_data.append(file_data)
                    processed_count += 1
                    if job_id:
                        self.job_manager.update_job(job_id, processed_files=processed_count)
                    await asyncio.sleep(0.01)

            self._create_all_inheritance_links(all_file_data, imports_map)
            self._create_all_function_calls(all_file_data, imports_map)
            
            if job_id:
                self.job_manager.update_job(job_id, status=JobStatus.COMPLETED, end_time=datetime.now())
        except Exception as e:
            error_message=str(e)
            error_logger(f"Failed to build graph for path {path}: {error_message}")
            if job_id:
                '''checking if the repo got deleted '''
                if "no such file found" in error_message or "deleted" in error_message or "not found" in error_message:
                    status=JobStatus.CANCELLED
                    
                else:
                    status=JobStatus.FAILED

                self.job_manager.update_job(
                    job_id, status=status, end_time=datetime.now(), errors=[str(e)]
                )

```

--------------------------------------------------------------------------------
/docs/site/cookbook/index.html:
--------------------------------------------------------------------------------

```html

<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      
        <link rel="prev" href="../tools/">
      
      
        <link rel="next" href="../contributing/">
      
      
        
      
      
      <link rel="icon" href="../assets/images/favicon.png">
      <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.7.1">
    
    
      
        <title>Cookbook - CodeGraphContext</title>
      
    
    
      <link rel="stylesheet" href="../assets/stylesheets/main.484c7ddc.min.css">
      
      


    
    
      
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
    <script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
  </head>
  
  
    <body dir="ltr">
  
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#mcp-tool-cookbook" class="md-skip">
          Skip to content
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

  

<header class="md-header md-header--shadow" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="Header">
    <a href=".." title="CodeGraphContext" class="md-header__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            CodeGraphContext
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              Cookbook
            
          </span>
        </div>
      </div>
    </div>
    
    
      <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
    
    
    
      
      
        <label class="md-header__button md-icon" for="__search">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        </label>
        <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="Search">
        
        <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
        </button>
      </nav>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            Initializing search
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
      
    
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    



<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href=".." title="CodeGraphContext" class="md-nav__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>

    </a>
    CodeGraphContext
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href=".." class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Home
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../installation/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Installation
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../use_cases/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Use Cases
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../architecture/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Architecture
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../cli/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    CLI Reference
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../watching/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Live Watching
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../server/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Server
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../core/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Core Concepts
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../tools/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Tools
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
    
  
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
        
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          
  
  
  <span class="md-ellipsis">
    
  
    Cookbook
  

    
  </span>
  
  

          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        
  
  
  <span class="md-ellipsis">
    
  
    Cookbook
  

    
  </span>
  
  

      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#basic-queries" class="md-nav__link">
    <span class="md-ellipsis">
      
        Basic Queries
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Basic Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1-find-a-specific-function-by-name" class="md-nav__link">
    <span class="md-ellipsis">
      
        1. Find a specific function by name
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2-find-all-calls-to-a-specific-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        2. Find all calls to a specific function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#3-find-what-a-function-calls" class="md-nav__link">
    <span class="md-ellipsis">
      
        3. Find what a function calls
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#4-find-all-imports-of-a-specific-module" class="md-nav__link">
    <span class="md-ellipsis">
      
        4. Find all imports of a specific module
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#5-find-all-methods-of-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      
        5. Find all methods of a class
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#6-find-all-classes-that-inherit-from-a-specific-class" class="md-nav__link">
    <span class="md-ellipsis">
      
        6. Find all classes that inherit from a specific class
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#7-find-all-functions-with-a-specific-decorator" class="md-nav__link">
    <span class="md-ellipsis">
      
        7. Find all functions with a specific decorator
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#8-find-all-dataclasses" class="md-nav__link">
    <span class="md-ellipsis">
      
        8. Find all dataclasses
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#code-analysis-quality" class="md-nav__link">
    <span class="md-ellipsis">
      
        Code Analysis &amp; Quality
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Code Analysis &amp; Quality">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#9-find-the-5-most-complex-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        9. Find the 5 most complex functions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#10-calculate-cyclomatic-complexity-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        10. Calculate cyclomatic complexity of a function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#11-find-unused-code" class="md-nav__link">
    <span class="md-ellipsis">
      
        11. Find unused code
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#12-find-the-call-chain-between-two-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        12. Find the call chain between two functions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#13-find-all-direct-and-indirect-callers-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        13. Find all direct and indirect callers of a function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#14-find-functions-by-argument-name" class="md-nav__link">
    <span class="md-ellipsis">
      
        14. Find functions by argument name
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#15-list-all-python-package-imports-from-a-directory" class="md-nav__link">
    <span class="md-ellipsis">
      
        15. List all python package imports from a directory
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#repository-information-queries" class="md-nav__link">
    <span class="md-ellipsis">
      
        Repository Information Queries
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Repository Information Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#16-list-all-indexed-projects" class="md-nav__link">
    <span class="md-ellipsis">
      
        16. List all indexed projects
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#17-check-the-status-of-an-indexing-job" class="md-nav__link">
    <span class="md-ellipsis">
      
        17. Check the status of an indexing job
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#18-list-all-background-jobs" class="md-nav__link">
    <span class="md-ellipsis">
      
        18. List all background jobs
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#advanced-cypher-queries" class="md-nav__link">
    <span class="md-ellipsis">
      
        Advanced Cypher Queries
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Advanced Cypher Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#19-find-all-function-definitions" class="md-nav__link">
    <span class="md-ellipsis">
      
        19. Find all function definitions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#20-find-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      
        20. Find all classes
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#21-find-all-functions-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        21. Find all functions in a file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#22-find-all-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        22. Find all classes in a file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#23-list-all-top-level-functions-and-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        23. List all top-level functions and classes in a file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#24-find-functions-in-one-module-that-call-a-function-in-another" class="md-nav__link">
    <span class="md-ellipsis">
      
        24. Find functions in one module that call a function in another
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#25-find-circular-file-imports" class="md-nav__link">
    <span class="md-ellipsis">
      
        25. Find circular file imports
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#26-find-all-functions-with-more-than-5-arguments" class="md-nav__link">
    <span class="md-ellipsis">
      
        26. Find all functions with more than 5 arguments
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#27-find-all-functions-in-a-file-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      
        27. Find all functions in a file that have a docstring
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#28-find-all-classes-that-have-a-specific-method" class="md-nav__link">
    <span class="md-ellipsis">
      
        28. Find all classes that have a specific method
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#29-find-the-depth-of-inheritance-for-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      
        29. Find the depth of inheritance for all classes
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#30-find-all-functions-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      
        30. Find all functions that have a docstring
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#31-find-all-decorated-methods-in-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      
        31. Find all decorated methods in a class
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#32-find-the-number-of-functions-in-each-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        32. Find the number of functions in each file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#33-find-all-methods-that-override-a-parent-method" class="md-nav__link">
    <span class="md-ellipsis">
      
        33. Find all methods that override a parent method
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#34-find-all-functions-that-call-super" class="md-nav__link">
    <span class="md-ellipsis">
      
        34. Find all functions that call super()
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#35-find-all-calls-to-a-function-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      
        35. Find all calls to a function with a specific argument
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#36-find-all-functions-that-are-not-called-by-any-other-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        36. Find all functions that are not called by any other function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#37-find-all-functions-that-are-called-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      
        37. Find all functions that are called with a specific argument
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#38-find-all-direct-and-indirect-callees-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        38. Find all direct and indirect callees of a function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#39-find-all-functions-that-are-overridden" class="md-nav__link">
    <span class="md-ellipsis">
      
        39. Find all functions that are overridden
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#40-find-all-modules-imported-by-module_a" class="md-nav__link">
    <span class="md-ellipsis">
      
        40. Find all modules imported by module_a
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#41-find-large-functions-that-should-be-refactored" class="md-nav__link">
    <span class="md-ellipsis">
      
        41. Find large functions that should be refactored
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#42-find-recursive-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        42. Find recursive functions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#43-find-most-connected-functions-hub-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        43. Find most connected functions (hub functions)
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#security-sensitive-data-analysis" class="md-nav__link">
    <span class="md-ellipsis">
      
        Security &amp; Sensitive Data Analysis
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Security &amp; Sensitive Data Analysis">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#44-find-potential-security-vulnerabilities-hardcoded-secrets" class="md-nav__link">
    <span class="md-ellipsis">
      
        44. Find potential security vulnerabilities (hardcoded secrets)
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_11" >
        
          
          <label class="md-nav__link" for="__nav_11" id="__nav_11_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    
  
    Contributing
  

    
  </span>
  
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_11_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_11">
            <span class="md-nav__icon md-icon"></span>
            
  
    Contributing
  

          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../contributing/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Overview
  

    
  </span>
  
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../contributing_languages/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Adding New Languages
  

    
  </span>
  
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../troubleshooting/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Troubleshooting
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../future_work/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    Future Work
  

    
  </span>
  
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../license/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    
  
    License
  

    
  </span>
  
  

      </a>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#basic-queries" class="md-nav__link">
    <span class="md-ellipsis">
      
        Basic Queries
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Basic Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1-find-a-specific-function-by-name" class="md-nav__link">
    <span class="md-ellipsis">
      
        1. Find a specific function by name
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2-find-all-calls-to-a-specific-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        2. Find all calls to a specific function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#3-find-what-a-function-calls" class="md-nav__link">
    <span class="md-ellipsis">
      
        3. Find what a function calls
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#4-find-all-imports-of-a-specific-module" class="md-nav__link">
    <span class="md-ellipsis">
      
        4. Find all imports of a specific module
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#5-find-all-methods-of-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      
        5. Find all methods of a class
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#6-find-all-classes-that-inherit-from-a-specific-class" class="md-nav__link">
    <span class="md-ellipsis">
      
        6. Find all classes that inherit from a specific class
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#7-find-all-functions-with-a-specific-decorator" class="md-nav__link">
    <span class="md-ellipsis">
      
        7. Find all functions with a specific decorator
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#8-find-all-dataclasses" class="md-nav__link">
    <span class="md-ellipsis">
      
        8. Find all dataclasses
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#code-analysis-quality" class="md-nav__link">
    <span class="md-ellipsis">
      
        Code Analysis &amp; Quality
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Code Analysis &amp; Quality">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#9-find-the-5-most-complex-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        9. Find the 5 most complex functions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#10-calculate-cyclomatic-complexity-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        10. Calculate cyclomatic complexity of a function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#11-find-unused-code" class="md-nav__link">
    <span class="md-ellipsis">
      
        11. Find unused code
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#12-find-the-call-chain-between-two-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        12. Find the call chain between two functions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#13-find-all-direct-and-indirect-callers-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        13. Find all direct and indirect callers of a function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#14-find-functions-by-argument-name" class="md-nav__link">
    <span class="md-ellipsis">
      
        14. Find functions by argument name
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#15-list-all-python-package-imports-from-a-directory" class="md-nav__link">
    <span class="md-ellipsis">
      
        15. List all python package imports from a directory
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#repository-information-queries" class="md-nav__link">
    <span class="md-ellipsis">
      
        Repository Information Queries
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Repository Information Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#16-list-all-indexed-projects" class="md-nav__link">
    <span class="md-ellipsis">
      
        16. List all indexed projects
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#17-check-the-status-of-an-indexing-job" class="md-nav__link">
    <span class="md-ellipsis">
      
        17. Check the status of an indexing job
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#18-list-all-background-jobs" class="md-nav__link">
    <span class="md-ellipsis">
      
        18. List all background jobs
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#advanced-cypher-queries" class="md-nav__link">
    <span class="md-ellipsis">
      
        Advanced Cypher Queries
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Advanced Cypher Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#19-find-all-function-definitions" class="md-nav__link">
    <span class="md-ellipsis">
      
        19. Find all function definitions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#20-find-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      
        20. Find all classes
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#21-find-all-functions-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        21. Find all functions in a file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#22-find-all-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        22. Find all classes in a file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#23-list-all-top-level-functions-and-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        23. List all top-level functions and classes in a file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#24-find-functions-in-one-module-that-call-a-function-in-another" class="md-nav__link">
    <span class="md-ellipsis">
      
        24. Find functions in one module that call a function in another
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#25-find-circular-file-imports" class="md-nav__link">
    <span class="md-ellipsis">
      
        25. Find circular file imports
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#26-find-all-functions-with-more-than-5-arguments" class="md-nav__link">
    <span class="md-ellipsis">
      
        26. Find all functions with more than 5 arguments
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#27-find-all-functions-in-a-file-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      
        27. Find all functions in a file that have a docstring
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#28-find-all-classes-that-have-a-specific-method" class="md-nav__link">
    <span class="md-ellipsis">
      
        28. Find all classes that have a specific method
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#29-find-the-depth-of-inheritance-for-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      
        29. Find the depth of inheritance for all classes
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#30-find-all-functions-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      
        30. Find all functions that have a docstring
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#31-find-all-decorated-methods-in-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      
        31. Find all decorated methods in a class
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#32-find-the-number-of-functions-in-each-file" class="md-nav__link">
    <span class="md-ellipsis">
      
        32. Find the number of functions in each file
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#33-find-all-methods-that-override-a-parent-method" class="md-nav__link">
    <span class="md-ellipsis">
      
        33. Find all methods that override a parent method
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#34-find-all-functions-that-call-super" class="md-nav__link">
    <span class="md-ellipsis">
      
        34. Find all functions that call super()
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#35-find-all-calls-to-a-function-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      
        35. Find all calls to a function with a specific argument
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#36-find-all-functions-that-are-not-called-by-any-other-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        36. Find all functions that are not called by any other function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#37-find-all-functions-that-are-called-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      
        37. Find all functions that are called with a specific argument
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#38-find-all-direct-and-indirect-callees-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      
        38. Find all direct and indirect callees of a function
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#39-find-all-functions-that-are-overridden" class="md-nav__link">
    <span class="md-ellipsis">
      
        39. Find all functions that are overridden
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#40-find-all-modules-imported-by-module_a" class="md-nav__link">
    <span class="md-ellipsis">
      
        40. Find all modules imported by module_a
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#41-find-large-functions-that-should-be-refactored" class="md-nav__link">
    <span class="md-ellipsis">
      
        41. Find large functions that should be refactored
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#42-find-recursive-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        42. Find recursive functions
      
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#43-find-most-connected-functions-hub-functions" class="md-nav__link">
    <span class="md-ellipsis">
      
        43. Find most connected functions (hub functions)
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#security-sensitive-data-analysis" class="md-nav__link">
    <span class="md-ellipsis">
      
        Security &amp; Sensitive Data Analysis
      
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Security &amp; Sensitive Data Analysis">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#44-find-potential-security-vulnerabilities-hardcoded-secrets" class="md-nav__link">
    <span class="md-ellipsis">
      
        44. Find potential security vulnerabilities (hardcoded secrets)
      
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              
              <article class="md-content__inner md-typeset">
                
                  



<h1 id="mcp-tool-cookbook">MCP Tool Cookbook</h1>
<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>
<hr />
<h2 id="basic-queries">Basic Queries</h2>
<h3 id="1-find-a-specific-function-by-name">1. Find a specific function by name</h3>
<ul>
<li><strong>Natural Language:</strong> "Where is the function <code>foo</code> defined?"</li>
<li><strong>Tool:</strong> <code>find_code</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query&quot;: &quot;foo&quot;
}
</code></pre>
<p><img alt="Query 1" src="../images/1.png" /></p>
<h3 id="2-find-all-calls-to-a-specific-function">2. Find all calls to a specific function</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all calls to the <code>helper</code> function."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_callers&quot;,
  &quot;target&quot;: &quot;helper&quot;
}
</code></pre>
<p><img alt="Query 2" src="../images/2.png" /></p>
<h3 id="3-find-what-a-function-calls">3. Find what a function calls</h3>
<ul>
<li><strong>Natural Language:</strong> "What functions are called inside the <code>foo</code> function?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_callees&quot;,
  &quot;target&quot;: &quot;foo&quot;,
  &quot;context&quot;: &quot;/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py&quot;
}
</code></pre>
<p><img alt="Query 3" src="../images/3.png" /></p>
<h3 id="4-find-all-imports-of-a-specific-module">4. Find all imports of a specific module</h3>
<ul>
<li><strong>Natural Language:</strong> "Where is the <code>math</code> module imported?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_importers&quot;,
  &quot;target&quot;: &quot;math&quot;
}
</code></pre>
<p><img alt="Query 4" src="../images/4.png" /></p>
<h3 id="5-find-all-methods-of-a-class">5. Find all methods of a class</h3>
<ul>
<li><strong>Natural Language:</strong> "What are the methods of the <code>A</code> class?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;class_hierarchy&quot;,
  &quot;target&quot;: &quot;A&quot;
}
</code></pre>
<ul>
<li><strong>Note:</strong> The response for <code>class_hierarchy</code> includes a list of methods.</li>
</ul>
<p><img alt="Query 5" src="../images/5.png" /></p>
<h3 id="6-find-all-classes-that-inherit-from-a-specific-class">6. Find all classes that inherit from a specific class</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all classes that inherit from <code>Base</code>."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;class_hierarchy&quot;,
  &quot;target&quot;: &quot;Base&quot;
}
</code></pre>
<ul>
<li><strong>Note:</strong> The response for <code>class_hierarchy</code> includes a list of child classes.</li>
</ul>
<p><img alt="Query 6" src="../images/6.png" /></p>
<h3 id="7-find-all-functions-with-a-specific-decorator">7. Find all functions with a specific decorator</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions with the <code>log_decorator</code>."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_functions_by_decorator&quot;,
  &quot;target&quot;: &quot;log_decorator&quot;
}
</code></pre>
<p><img alt="Query 7" src="../images/7.png" /></p>
<h3 id="8-find-all-dataclasses">8. Find all dataclasses</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all dataclasses."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class) WHERE 'dataclass' IN c.decorators RETURN c.name, c.file_path&quot;
}
</code></pre>
<p><img alt="Query 8" src="../images/8.png" /></p>
<hr />
<h2 id="code-analysis-quality">Code Analysis &amp; Quality</h2>
<h3 id="9-find-the-5-most-complex-functions">9. Find the 5 most complex functions</h3>
<ul>
<li><strong>Natural Language:</strong> "Find the 5 most complex functions."</li>
<li><strong>Tool:</strong> <code>find_most_complex_functions</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;limit&quot;: 5
}
</code></pre>
<p><img alt="Query 9" src="../images/9.png" /></p>
<h3 id="10-calculate-cyclomatic-complexity-of-a-function">10. Calculate cyclomatic complexity of a function</h3>
<ul>
<li><strong>Natural Language:</strong> "What is the cyclomatic complexity of <code>try_except_finally</code>?"</li>
<li><strong>Tool:</strong> <code>calculate_cyclomatic_complexity</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;function_name&quot;: &quot;try_except_finally&quot;
}
</code></pre>
<h3 id="11-find-unused-code">11. Find unused code</h3>
<ul>
<li><strong>Natural Language:</strong> "Find unused code, but ignore API endpoints decorated with <code>@app.route</code>."</li>
<li><strong>Tool:</strong> <code>find_dead_code</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;exclude_decorated_with&quot;: [&quot;@app.route&quot;]
}
</code></pre>
<p><img alt="Query 11" src="../images/11.png" /></p>
<h3 id="12-find-the-call-chain-between-two-functions">12. Find the call chain between two functions</h3>
<ul>
<li><strong>Natural Language:</strong> "What is the call chain from <code>wrapper</code> to <code>helper</code>?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;call_chain&quot;,
  &quot;target&quot;: &quot;wrapper-&gt;helper&quot;
}
</code></pre>
<p><img alt="Query 12" src="../images/12.png" /></p>
<h3 id="13-find-all-direct-and-indirect-callers-of-a-function">13. Find all direct and indirect callers of a function</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all functions that eventually call the <code>helper</code> function."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_all_callers&quot;,
  &quot;target&quot;: &quot;helper&quot;
}
</code></pre>
<p><img alt="Query 13" src="../images/13.png" /></p>
<h3 id="14-find-functions-by-argument-name">14. Find functions by argument name</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions that take <code>self</code> as an argument."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_functions_by_argument&quot;,
  &quot;target&quot;: &quot;self&quot;
}
</code></pre>
<p><img alt="Query 14" src="../images/14.png" /></p>
<h3 id="15-list-all-python-package-imports-from-a-directory">15. List all python package imports from a directory</h3>
<ul>
<li><strong>Natural Language:</strong> "List all python package imports from my project directory."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:File)-[:IMPORTS]-&gt;(m:Module) WHERE f.path ENDS WITH '.py' RETURN DISTINCT m.name&quot;
}
</code></pre>
<hr />
<h2 id="repository-information-queries">Repository Information Queries</h2>
<h3 id="16-list-all-indexed-projects">16. List all indexed projects</h3>
<ul>
<li><strong>Natural Language:</strong> "List all projects I have indexed."</li>
<li><strong>Tool:</strong> <code>list_indexed_repositories</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">  {}
</code></pre>
<p><img alt="Query 16" src="../images/16.png" /></p>
<h3 id="17-check-the-status-of-an-indexing-job">17. Check the status of an indexing job</h3>
<ul>
<li><strong>Natural Language:</strong> "What is the status of job <code>4cb9a60e-c1b1-43a7-9c94-c840771506bc</code>?"</li>
<li><strong>Tool:</strong> <code>check_job_status</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;job_id&quot;: &quot;4cb9a60e-c1b1-43a7-9c94-c840771506bc&quot;
}
</code></pre>
<h3 id="18-list-all-background-jobs">18. List all background jobs</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all background jobs."</li>
<li><strong>Tool:</strong> <code>list_jobs</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">  {}
</code></pre>
<hr />
<h2 id="advanced-cypher-queries">Advanced Cypher Queries</h2>
<p>These examples use the <code>execute_cypher_query</code> tool for more specific and complex questions.</p>
<h3 id="19-find-all-function-definitions">19. Find all function definitions</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all function definitions in the codebase."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (n:Function) RETURN n.name, n.file_path, n.line_number LIMIT 50&quot;
}
</code></pre>
<p><img alt="Query 19" src="../images/19.png" /></p>
<h3 id="20-find-all-classes">20. Find all classes</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all the classes."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (n:Class) RETURN n.name, n.file_path, n.line_number LIMIT 50&quot;
}
</code></pre>
<p><img alt="Query 20" src="../images/20.png" /></p>
<h3 id="21-find-all-functions-in-a-file">21. Find all functions in a file</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions in <code>module_a.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' RETURN f.name&quot;
}
</code></pre>
<p><img alt="Query 21" src="../images/21.png" /></p>
<h3 id="22-find-all-classes-in-a-file">22. Find all classes in a file</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all classes in <code>advanced_classes.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class) WHERE c.file_path ENDS WITH 'advanced_classes.py' RETURN c.name&quot;
}
</code></pre>
<p><img alt="Query 22" src="../images/22.png" /></p>
<h3 id="23-list-all-top-level-functions-and-classes-in-a-file">23. List all top-level functions and classes in a file</h3>
<ul>
<li><strong>Natural Language:</strong> "List all top-level functions and classes in <code>module_a.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<p><img alt="Query 23" src="../images/23.png" /></p>
<h3 id="24-find-functions-in-one-module-that-call-a-function-in-another">24. Find functions in one module that call a function in another</h3>
<ul>
<li><strong>Natural Language:</strong> "Find functions in <code>module_a.py</code> that call <code>helper</code> in <code>module_b.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<p><img alt="Query 24" src="../images/24.png" /></p>
<h3 id="25-find-circular-file-imports">25. Find circular file imports</h3>
<ul>
<li><strong>Natural Language:</strong> "Are there any circular dependencies between files?"</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<h3 id="26-find-all-functions-with-more-than-5-arguments">26. Find all functions with more than 5 arguments</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions with a large number of arguments."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE size(f.args) &gt; 5 RETURN f.name, f.file_path, size(f.args) as arg_count&quot;
}
</code></pre>
<p><img alt="Query 26" src="../images/26.png" /></p>
<h3 id="27-find-all-functions-in-a-file-that-have-a-docstring">27. Find all functions in a file that have a docstring</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions in <code>module_a.py</code> that have a docstring."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<h3 id="28-find-all-classes-that-have-a-specific-method">28. Find all classes that have a specific method</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all classes that have a <code>greet</code> method."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class)-[:CONTAINS]-&gt;(m:Function {name: 'greet'}) RETURN c.name, c.file_path&quot;
}
</code></pre>
<p><img alt="Query 28" src="../images/28.png" /></p>
<h3 id="29-find-the-depth-of-inheritance-for-all-classes">29. Find the depth of inheritance for all classes</h3>
<ul>
<li><strong>Natural Language:</strong> "How deep are the inheritance chains for all classes?"</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<p><img alt="Query 29" src="../images/29.png" /></p>
<h3 id="30-find-all-functions-that-have-a-docstring">30. Find all functions that have a docstring</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all functions that are documented."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name, f.file_path LIMIT 50&quot;
}
</code></pre>
<p><img alt="Query 30" src="../images/30.png" /></p>
<h3 id="31-find-all-decorated-methods-in-a-class">31. Find all decorated methods in a class</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all decorated methods in the <code>Child</code> class."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class {name: 'Child'})-[:CONTAINS]-&gt;(m:Function) WHERE m.decorators IS NOT NULL AND size(m.decorators) &gt; 0 RETURN m.name&quot;
}
</code></pre>
<p><img alt="Query 31" src="../images/31.png" /></p>
<h3 id="32-find-the-number-of-functions-in-each-file">32. Find the number of functions in each file</h3>
<ul>
<li><strong>Natural Language:</strong> "How many functions are in each file?"</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) RETURN f.file_path, count(f) AS function_count ORDER BY function_count DESC&quot;
}
</code></pre>
<p><img alt="Query 32" src="../images/32.png" /></p>
<h3 id="33-find-all-methods-that-override-a-parent-method">33. Find all methods that override a parent method</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all methods that are overridden from a parent class."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<p><img alt="Query 33" src="../images/33.png" /></p>
<h3 id="34-find-all-functions-that-call-super">34. Find all functions that call <code>super()</code></h3>
<ul>
<li><strong>Natural Language:</strong> "Find all methods that call their parent's method via <code>super()</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function)-[r:CALLS]-&gt;() WHERE r.full_call_name STARTS WITH 'super(' RETURN f.name, f.file_path&quot;
}
</code></pre>
<p><img alt="Query 34" src="../images/34.png" /></p>
<h3 id="35-find-all-calls-to-a-function-with-a-specific-argument">35. Find all calls to a function with a specific argument</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all calls to <code>helper</code> with the argument <code>x</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH ()-[r:CALLS]-&gt;(f:Function {name: 'helper'}) WHERE 'x' IN r.args RETURN r.full_call_name, r.line_number, r.file_path&quot;
}
</code></pre>
<p><img alt="Query 35" src="../images/35.png" /></p>
<h3 id="36-find-all-functions-that-are-not-called-by-any-other-function">36. Find all functions that are not called by any other function</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all dead code (functions that are never called)."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE NOT (()-[:CALLS]-&gt;(f)) AND f.is_dependency = false RETURN f.name, f.file_path&quot;
}
</code></pre>
<p><img alt="Query 36" src="../images/36.png" /></p>
<h3 id="37-find-all-functions-that-are-called-with-a-specific-argument">37. Find all functions that are called with a specific argument</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all calls to <code>print</code> with the argument <code>'hello'</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Call) WHERE c.name = 'print' AND 'hello' IN c.args RETURN c.file, c.lineno&quot;
}
</code></pre>
<h3 id="38-find-all-direct-and-indirect-callees-of-a-function">38. Find all direct and indirect callees of a function</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all functions that are eventually called by the <code>foo</code> function."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_all_callees&quot;,
  &quot;target&quot;: &quot;foo&quot;,
  &quot;context&quot;: &quot;/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py&quot;
}
</code></pre>
<p><img alt="Query 38" src="../images/38.png" /></p>
<h3 id="39-find-all-functions-that-are-overridden">39. Find all functions that are overridden</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions that are overridden."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;overrides&quot;,
  &quot;target&quot;: &quot;foo&quot;
}
</code></pre>
<p><img alt="Query 39" src="../images/39.png" /></p>
<h3 id="40-find-all-modules-imported-by-module_a">40. Find all modules imported by <code>module_a</code></h3>
<ul>
<li><strong>Natural Language:</strong> "Find all modules imported by <code>module_a</code>."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:File {name: 'module_a.py'})-[:IMPORTS]-&gt;(m:Module) RETURN m.name AS imported_module_name&quot;
}
</code></pre>
<p><img alt="Query 40" src="../images/40.png" /></p>
<h3 id="41-find-large-functions-that-should-be-refactored">41. Find large functions that should be refactored</h3>
<ul>
<li><strong>Natural Language:</strong> "Find functions with more than 20 lines of code that might need refactoring."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function)\n    WHERE f.end_line - f.line_number &gt; 20\n    RETURN f&quot;
}
</code></pre>
<p><img alt="Query 41" src="../images/41.png" /></p>
<h3 id="42-find-recursive-functions">42. Find recursive functions</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions that call themselves (recursive functions)."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH p=(f:Function)-[:CALLS]-&gt;(f2:Function)\n    WHERE f.name = f2.name AND f.file_path = f2.file_path\n    RETURN p&quot;
}
</code></pre>
<p><img alt="Query 42" src="../images/42.png" /></p>
<h3 id="43-find-most-connected-functions-hub-functions">43. Find most connected functions (hub functions)</h3>
<ul>
<li><strong>Natural Language:</strong> "Find the functions that are most central to the codebase (called by many and call many others)."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;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&quot;
}
</code></pre>
<p><img alt="Query 43" src="../images/43.png" /></p>
<h2 id="security-sensitive-data-analysis">Security &amp; Sensitive Data Analysis</h2>
<h3 id="44-find-potential-security-vulnerabilities-hardcoded-secrets">44. Find potential security vulnerabilities (hardcoded secrets)</h3>
<ul>
<li><strong>Natural Language:</strong> "Find potential hardcoded passwords, API keys, or secrets in the codebase."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;WITH [\&quot;password\&quot;,  \&quot;api_key\&quot;, \&quot;apikey\&quot;,    \&quot;secret_token\&quot;, \&quot;token\&quot;, \&quot;auth\&quot;, \&quot;access_key\&quot;, \&quot;private_key\&quot;, \&quot;client_secret\&quot;, \&quot;sessionid\&quot;, \&quot;jwt\&quot;] AS keywords\n    MATCH (f:Function)\n    WHERE ANY(word IN keywords WHERE toLower(f.source_code) CONTAINS word)\n    RETURN f&quot;
}
</code></pre>












                
              </article>
            </div>
          
          
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
        </div>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    
    
      
      
      <script id="__config" type="application/json">{"annotate": null, "base": "..", "features": [], "search": "../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
    
    
      <script src="../assets/javascripts/bundle.79ae519e.min.js"></script>
      
    
  </body>
</html>
```
Page 14/17FirstPrevNextLast