#
tokens: 45701/50000 5/367 files (page 11/18)
lines: on (toggle) GitHub
raw markdown copy reset
This is page 11 of 18. Use http://codebase.md/shashankss1205/codegraphcontext?lines=true&page={x} to view the full context.

# Directory Structure

```
├── .github
│   └── workflows
│       ├── e2e-tests.yml
│       ├── post_discord_invite.yml
│       ├── test.yml
│       └── update-contributors.yml
├── .gitignore
├── CONTRIBUTING.md
├── contributors.md
├── docs
│   ├── docs
│   │   ├── architecture.md
│   │   ├── cli.md
│   │   ├── contributing_languages.md
│   │   ├── contributing.md
│   │   ├── cookbook.md
│   │   ├── core.md
│   │   ├── future_work.md
│   │   ├── images
│   │   │   ├── 1.png
│   │   │   ├── 11.png
│   │   │   ├── 12.png
│   │   │   ├── 13.png
│   │   │   ├── 14.png
│   │   │   ├── 16.png
│   │   │   ├── 19.png
│   │   │   ├── 2.png
│   │   │   ├── 20.png
│   │   │   ├── 21.png
│   │   │   ├── 22.png
│   │   │   ├── 23.png
│   │   │   ├── 24.png
│   │   │   ├── 26.png
│   │   │   ├── 28.png
│   │   │   ├── 29.png
│   │   │   ├── 3.png
│   │   │   ├── 30.png
│   │   │   ├── 31.png
│   │   │   ├── 32.png
│   │   │   ├── 33.png
│   │   │   ├── 34.png
│   │   │   ├── 35.png
│   │   │   ├── 36.png
│   │   │   ├── 38.png
│   │   │   ├── 39.png
│   │   │   ├── 4.png
│   │   │   ├── 40.png
│   │   │   ├── 41.png
│   │   │   ├── 42.png
│   │   │   ├── 43.png
│   │   │   ├── 44.png
│   │   │   ├── 5.png
│   │   │   ├── 6.png
│   │   │   ├── 7.png
│   │   │   ├── 8.png
│   │   │   ├── 9.png
│   │   │   ├── Indexing.gif
│   │   │   ├── tool_images
│   │   │   │   ├── 1.png
│   │   │   │   ├── 2.png
│   │   │   │   └── 3.png
│   │   │   └── Usecase.gif
│   │   ├── index.md
│   │   ├── installation.md
│   │   ├── license.md
│   │   ├── server.md
│   │   ├── tools.md
│   │   ├── troubleshooting.md
│   │   └── use_cases.md
│   ├── mkdocs.yml
│   └── site
│       ├── 404.html
│       ├── architecture
│       │   └── index.html
│       ├── assets
│       │   ├── images
│       │   │   └── favicon.png
│       │   ├── javascripts
│       │   │   ├── bundle.f55a23d4.min.js
│       │   │   ├── bundle.f55a23d4.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.973d3a69.min.js
│       │   │       └── search.973d3a69.min.js.map
│       │   └── stylesheets
│       │       ├── main.2a3383ac.min.css
│       │       ├── main.2a3383ac.min.css.map
│       │       ├── palette.06af60db.min.css
│       │       └── palette.06af60db.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
├── images
│   ├── 1.png
│   ├── 11.png
│   ├── 12.png
│   ├── 13.png
│   ├── 14.png
│   ├── 16.png
│   ├── 19.png
│   ├── 2.png
│   ├── 20.png
│   ├── 21.png
│   ├── 22.png
│   ├── 23.png
│   ├── 24.png
│   ├── 26.png
│   ├── 28.png
│   ├── 29.png
│   ├── 3.png
│   ├── 30.png
│   ├── 31.png
│   ├── 32.png
│   ├── 33.png
│   ├── 34.png
│   ├── 35.png
│   ├── 36.png
│   ├── 38.png
│   ├── 39.png
│   ├── 4.png
│   ├── 40.png
│   ├── 41.png
│   ├── 42.png
│   ├── 43.png
│   ├── 44.png
│   ├── 5.png
│   ├── 6.png
│   ├── 7.png
│   ├── 8.png
│   ├── 9.png
│   ├── Indexing.gif
│   ├── tool_images
│   │   ├── 1.png
│   │   ├── 2.png
│   │   └── 3.png
│   └── Usecase.gif
├── LICENSE
├── MANIFEST.in
├── organizer
│   ├── CONTRIBUTING_LANGUAGES.md
│   ├── cookbook.md
│   ├── docs.md
│   ├── language_specific_nodes.md
│   ├── Tools_Exploration.md
│   └── troubleshoot.md
├── package-lock.json
├── pyproject.toml
├── README.md
├── scripts
│   ├── generate_lang_contributors.py
│   └── post_install_fix.sh
├── SECURITY.md
├── src
│   └── codegraphcontext
│       ├── __init__.py
│       ├── __main__.py
│       ├── cli
│       │   ├── __init__.py
│       │   ├── cli_helpers.py
│       │   ├── main.py
│       │   ├── setup_macos.py
│       │   └── setup_wizard.py
│       ├── core
│       │   ├── __init__.py
│       │   ├── database.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
│       │   │   ├── go.py
│       │   │   ├── java.py
│       │   │   ├── javascript.py
│       │   │   ├── python.py
│       │   │   ├── ruby.py
│       │   │   ├── rust.py
│       │   │   └── typescript.py
│       │   ├── package_resolver.py
│       │   ├── query_tool_languages
│       │   │   ├── c_toolkit.py
│       │   │   ├── cpp_toolkit.py
│       │   │   ├── go_toolkit.py
│       │   │   ├── java_toolkit.py
│       │   │   ├── javascript_toolkit.py
│       │   │   ├── python_toolkit.py
│       │   │   ├── ruby_toolkit.py
│       │   │   ├── rust_toolkit.py
│       │   │   └── typescript_toolkit.py
│       │   └── system.py
│       └── utils
│           └── debug_log.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_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_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_typescript
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── 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_tree_sitter
│   │   ├── __init__.py
│   │   ├── class_instantiation.py
│   │   ├── complex_classes.py
│   │   └── test_file.py
│   └── test_typescript_parser.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
    │   │   ├── 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
```

# Files

--------------------------------------------------------------------------------
/src/codegraphcontext/tools/languages/javascript.py:
--------------------------------------------------------------------------------

```python
  1 | from pathlib import Path
  2 | from typing import Any, Dict, Optional, Tuple
  3 | import re
  4 | from codegraphcontext.utils.debug_log import debug_log, info_logger, error_logger, warning_logger
  5 | 
  6 | # --- Helpers to classify JS methods ---
  7 | _GETTER_RE = re.compile(r"^\s*(?:static\s+)?get\b")
  8 | _SETTER_RE = re.compile(r"^\s*(?:static\s+)?set\b")
  9 | _STATIC_RE = re.compile(r"^\s*static\b")
 10 | 
 11 | 
 12 | def _first_line_before_body(text: str) -> str:
 13 |     """
 14 |     Best-effort header extraction: take text before the first '{'
 15 |     (covers class/object methods). Fallback to the first line.
 16 |     """
 17 |     head = text.split("{", 1)[0]
 18 |     if not head.strip():
 19 |         return text.splitlines()[0] if text.splitlines() else text
 20 |     return head
 21 | 
 22 | 
 23 | def _classify_method_kind(header: str) -> Optional[str]:
 24 |     """
 25 |     Return 'getter' | 'setter' | 'static' | None.
 26 |     Prefer 'getter'/'setter' over 'static' when both appear.
 27 |     """
 28 |     if _GETTER_RE.search(header):
 29 |         return "getter"
 30 |     if _SETTER_RE.search(header):
 31 |         return "setter"
 32 |     if _STATIC_RE.search(header):
 33 |         return "static"
 34 |     return None
 35 | 
 36 | 
 37 | JS_QUERIES = {
 38 |     "functions": """
 39 |         (function_declaration 
 40 |             name: (identifier) @name
 41 |             parameters: (formal_parameters) @params
 42 |         ) @function_node
 43 |         
 44 |         (variable_declarator 
 45 |             name: (identifier) @name 
 46 |             value: (function 
 47 |                 parameters: (formal_parameters) @params
 48 |             ) @function_node
 49 |         )
 50 |         
 51 |         (variable_declarator 
 52 |             name: (identifier) @name 
 53 |             value: (arrow_function 
 54 |                 parameters: (formal_parameters) @params
 55 |             ) @function_node
 56 |         )
 57 |         
 58 |         (variable_declarator 
 59 |             name: (identifier) @name 
 60 |             value: (arrow_function 
 61 |                 parameter: (identifier) @single_param
 62 |             ) @function_node
 63 |         )
 64 |         
 65 |         (method_definition 
 66 |             name: (property_identifier) @name
 67 |             parameters: (formal_parameters) @params
 68 |         ) @function_node
 69 |         
 70 |         (assignment_expression
 71 |             left: (member_expression 
 72 |                 property: (property_identifier) @name
 73 |             )
 74 |             right: (function
 75 |                 parameters: (formal_parameters) @params
 76 |             ) @function_node
 77 |         )
 78 |         
 79 |         (assignment_expression
 80 |             left: (member_expression 
 81 |                 property: (property_identifier) @name
 82 |             )
 83 |             right: (arrow_function
 84 |                 parameters: (formal_parameters) @params
 85 |             ) @function_node
 86 |         )
 87 |     """,
 88 |     "classes": """
 89 |         (class_declaration) @class
 90 |         (class) @class
 91 |     """,
 92 |     "imports": """
 93 |         (import_statement) @import
 94 |         (call_expression
 95 |             function: (identifier) @require_call (#eq? @require_call "require")
 96 |         ) @import
 97 |     """,
 98 |     "calls": """
 99 |         (call_expression function: (identifier) @name)
100 |         (call_expression function: (member_expression property: (property_identifier) @name))
101 |     """,
102 |     "variables": """
103 |         (variable_declarator name: (identifier) @name)
104 |     """,
105 |     "docstrings": """
106 |         (comment) @docstring_comment
107 |     """,
108 | }
109 | 
110 | 
111 | class JavascriptTreeSitterParser:
112 |     """A JavaScript-specific parser using tree-sitter, encapsulating language-specific logic."""
113 | 
114 |     def __init__(self, generic_parser_wrapper):
115 |         self.generic_parser_wrapper = generic_parser_wrapper
116 |         self.language_name = generic_parser_wrapper.language_name
117 |         self.language = generic_parser_wrapper.language
118 |         self.parser = generic_parser_wrapper.parser
119 | 
120 |         self.queries = {
121 |             name: self.language.query(query_str)
122 |             for name, query_str in JS_QUERIES.items()
123 |         }
124 | 
125 |     def _get_node_text(self, node) -> str:
126 |         return node.text.decode('utf-8')
127 | 
128 |     def _get_parent_context(self, node, types=('function_declaration', 'class_declaration')):
129 |         # JS specific context types
130 |         curr = node.parent
131 |         while curr:
132 |             if curr.type in types:
133 |                 name_node = curr.child_by_field_name('name')
134 |                 return self._get_node_text(name_node) if name_node else None, curr.type, curr.start_point[0] + 1
135 |             curr = curr.parent
136 |         return None, None, None
137 | 
138 |     def _calculate_complexity(self, node):
139 |         # JS specific complexity nodes
140 |         complexity_nodes = {
141 |             "if_statement", "for_statement", "while_statement", "do_statement",
142 |             "switch_statement", "case_statement", "conditional_expression",
143 |             "logical_expression", "binary_expression", "catch_clause"
144 |         }
145 |         count = 1
146 | 
147 |         def traverse(n):
148 |             nonlocal count
149 |             if n.type in complexity_nodes:
150 |                 count += 1
151 |             for child in n.children:
152 |                 traverse(child)
153 | 
154 |         traverse(node)
155 |         return count
156 | 
157 |     def _get_docstring(self, body_node):
158 |         # JS specific docstring extraction (e.g., JSDoc comments)
159 |         # This is a placeholder and needs more sophisticated logic
160 |         return None
161 | 
162 |     def parse(self, file_path: Path, is_dependency: bool = False) -> Dict:
163 |         """Parses a file and returns its structure in a standardized dictionary format."""
164 |         with open(file_path, "r", encoding="utf-8") as f:
165 |             source_code = f.read()
166 | 
167 |         tree = self.parser.parse(bytes(source_code, "utf8"))
168 |         root_node = tree.root_node
169 | 
170 |         functions = self._find_functions(root_node)
171 |         classes = self._find_classes(root_node)
172 |         imports = self._find_imports(root_node)
173 |         function_calls = self._find_calls(root_node)
174 |         variables = self._find_variables(root_node)
175 | 
176 |         return {
177 |             "file_path": str(file_path),
178 |             "functions": functions,
179 |             "classes": classes,
180 |             "variables": variables,
181 |             "imports": imports,
182 |             "function_calls": function_calls,
183 |             "is_dependency": is_dependency,
184 |             "lang": self.language_name,
185 |         }
186 | 
187 |     def _find_functions(self, root_node):
188 |         functions = []
189 |         query = self.queries['functions']
190 | 
191 |     # Local helpers so we don't depend on class attrs being present
192 |         def _fn_for_name(name_node):
193 |             current = name_node.parent
194 |             while current:
195 |                 if current.type in ('function_declaration', 'function', 'arrow_function', 'method_definition'):
196 |                     return current
197 |                 elif current.type in ('variable_declarator', 'assignment_expression'):
198 |                     for child in current.children:
199 |                         if child.type in ('function', 'arrow_function'):
200 |                             return child
201 |                 current = current.parent
202 |             return None
203 | 
204 |         def _fn_for_params(params_node):
205 |             current = params_node.parent
206 |             while current:
207 |                 if current.type in ('function_declaration', 'function', 'arrow_function', 'method_definition'):
208 |                     return current
209 |                 current = current.parent
210 |             return None
211 |         # stable keys so the same function only gets one bucket
212 |         def _key(n):  # start/end byte + type is stable across captures
213 |             return (n.start_byte, n.end_byte, n.type)
214 | 
215 |         # Collect captures grouped by function node
216 |         captures_by_function = {}
217 |         def _bucket_for(node):
218 |             fid = id(node)
219 |             return captures_by_function.setdefault(fid, {
220 |                 'node': node, 'name': None, 'params': None, 'single_param': None
221 |             })
222 | 
223 |         for node, capture_name in query.captures(root_node):
224 |             if capture_name == 'function_node':
225 |                 _bucket_for(node)
226 |             elif capture_name == 'name':
227 |                 fn = _fn_for_name(node)
228 |                 if fn:
229 |                     b = _bucket_for(fn)
230 |                     b['name'] = self._get_node_text(node)
231 |             elif capture_name == 'params':
232 |                 fn = _fn_for_params(node)
233 |                 if fn:
234 |                     b = _bucket_for(fn)
235 |                     b['params'] = node
236 |             elif capture_name == 'single_param':
237 |                 fn = _fn_for_params(node)
238 |                 if fn:
239 |                     b = _bucket_for(fn)
240 |                     b['single_param'] = node
241 | 
242 |         # Build Function entries
243 |         for _, data in captures_by_function.items():
244 |             func_node = data['node']
245 | 
246 |             # Backfill name for method_definition if query didn't capture it
247 |             name = data.get('name')
248 |             if not name and func_node.type == 'method_definition':
249 |                 nm = func_node.child_by_field_name('name')
250 |                 if nm:
251 |                     name = self._get_node_text(nm)
252 |             if not name:
253 |                 continue  # skip nameless functions
254 | 
255 |             # Parameters
256 |             args = []
257 |             if data.get('params'):
258 |                 args = self._extract_parameters(data['params'])
259 |             elif data.get('single_param'):
260 |                 args = [self._get_node_text(data['single_param'])]
261 | 
262 |             # Context & docstring
263 |             context, context_type, _ = self._get_parent_context(func_node)
264 |             class_context = context if context_type == 'class_declaration' else None
265 |             docstring = self._get_jsdoc_comment(func_node)
266 | 
267 |             # Classify getter/setter/static (methods only)
268 |             js_kind = None
269 |             if func_node.type == 'method_definition':
270 |                 header = _first_line_before_body(self._get_node_text(func_node))
271 |                 js_kind = _classify_method_kind(header)
272 | 
273 |             func_data = {
274 |                 "name": name,
275 |                 "line_number": func_node.start_point[0] + 1,
276 |                 "end_line": func_node.end_point[0] + 1,
277 |                 "args": args,
278 |                 "source": self._get_node_text(func_node),
279 |                 "source_code": self._get_node_text(func_node),
280 |                 "docstring": docstring,
281 |                 "cyclomatic_complexity": self._calculate_complexity(func_node),
282 |                 "context": context,
283 |                 "context_type": context_type,
284 |                 "class_context": class_context,
285 |                 "decorators": [],
286 |                 "lang": self.language_name,
287 |                 "is_dependency": False,
288 |             }
289 |             if js_kind is not None:
290 |                 func_data["type"] = js_kind
291 | 
292 |             functions.append(func_data)
293 | 
294 |         return functions
295 | 
296 | 
297 | 
298 |     def _find_function_node_for_name(self, name_node):
299 |         """Find the function node that contains this name node."""
300 |         current = name_node.parent
301 |         while current:
302 |             if current.type in ('function_declaration', 'function', 'arrow_function', 'method_definition'):
303 |                 return current
304 |             elif current.type in ('variable_declarator', 'assignment_expression'):
305 |                 # Check if this declarator/assignment contains a function
306 |                 for child in current.children:
307 |                     if child.type in ('function', 'arrow_function'):
308 |                         return child
309 |             current = current.parent
310 |         return None
311 | 
312 | 
313 |     def _find_function_node_for_params(self, params_node):
314 |         """Find the function node that contains this parameters node."""
315 |         current = params_node.parent
316 |         while current:
317 |             if current.type in ('function_declaration', 'function', 'arrow_function', 'method_definition'):
318 |                 return current
319 |             current = current.parent
320 | 
321 |         return None
322 | 
323 | 
324 |     def _extract_parameters(self, params_node):
325 |         """Extract parameter names from formal_parameters node."""
326 |         params = []
327 |         if params_node.type == 'formal_parameters':
328 |             for child in params_node.children:
329 |                 if child.type == 'identifier':
330 |                     params.append(self._get_node_text(child))
331 |                 elif child.type == 'assignment_pattern':
332 |                     # Default parameter: param = defaultValue
333 |                     left_child = child.child_by_field_name('left')
334 |                     if left_child and left_child.type == 'identifier':
335 |                         params.append(self._get_node_text(left_child))
336 |                 elif child.type == 'rest_pattern':
337 |                     # Rest parameter: ...args
338 |                     argument = child.child_by_field_name('argument')
339 |                     if argument and argument.type == 'identifier':
340 |                         params.append(f"...{self._get_node_text(argument)}")
341 |         return params
342 | 
343 | 
344 |     def _get_jsdoc_comment(self, func_node):
345 |         """Extract JSDoc comment preceding the function."""
346 |         # Look for comments before the function
347 |         prev_sibling = func_node.prev_sibling
348 |         while prev_sibling and prev_sibling.type in ('comment', '\n', ' '):
349 |             if prev_sibling.type == 'comment':
350 |                 comment_text = self._get_node_text(prev_sibling)
351 |                 if comment_text.startswith('/**') and comment_text.endswith('*/'):
352 |                     return comment_text.strip()
353 |             prev_sibling = prev_sibling.prev_sibling
354 |         return None
355 | 
356 | 
357 |     def _find_classes(self, root_node):
358 |         classes = []
359 |         query = self.queries['classes']
360 |         for class_node, capture_name in query.captures(root_node):
361 |             if capture_name == 'class':
362 |                 name_node = class_node.child_by_field_name('name')
363 |                 if not name_node: continue
364 |                 name = self._get_node_text(name_node)
365 | 
366 |                 bases = []
367 |                 heritage_node = next((child for child in class_node.children if child.type == 'class_heritage'), None)
368 |                 if heritage_node:
369 |                     if heritage_node.named_child_count > 0:
370 |                         base_expr_node = heritage_node.named_child(0)
371 |                         bases.append(self._get_node_text(base_expr_node))
372 |                     elif heritage_node.child_count > 0:
373 |                         # Fallback for anonymous nodes
374 |                         base_expr_node = heritage_node.child(heritage_node.child_count - 1)
375 |                         bases.append(self._get_node_text(base_expr_node))
376 | 
377 |                 class_data = {
378 |                     "name": name,
379 |                     "line_number": class_node.start_point[0] + 1,
380 |                     "end_line": class_node.end_point[0] + 1,
381 |                     "bases": bases,
382 |                     "source": self._get_node_text(class_node),
383 |                     "docstring": self._get_docstring(class_node),
384 |                     "context": None,
385 |                     "decorators": [],
386 |                     "lang": self.language_name,
387 |                     "is_dependency": False,
388 |                 }
389 |                 classes.append(class_data)
390 |         return classes
391 | 
392 | 
393 |     def _find_imports(self, root_node):
394 |         imports = []
395 |         query = self.queries['imports']
396 |         for node, capture_name in query.captures(root_node):
397 |             if capture_name != 'import':
398 |                 continue
399 | 
400 |             line_number = node.start_point[0] + 1
401 | 
402 |             if node.type == 'import_statement':
403 |                 source = self._get_node_text(node.child_by_field_name('source')).strip('\'"')
404 | 
405 |                 # Look for different import structures
406 |                 import_clause = node.child_by_field_name('import')
407 |                 if not import_clause:
408 |                     imports.append({'name': source, 'source': source, 'alias': None, 'line_number': line_number,
409 |                                     'lang': self.language_name})
410 |                     continue
411 | 
412 |                 # Default import: import defaultExport from '...'
413 |                 if import_clause.type == 'identifier':
414 |                     alias = self._get_node_text(import_clause)
415 |                     imports.append({'name': 'default', 'source': source, 'alias': alias, 'line_number': line_number,
416 |                                     'lang': self.language_name})
417 | 
418 |                 # Namespace import: import * as name from '...'
419 |                 elif import_clause.type == 'namespace_import':
420 |                     alias_node = import_clause.child_by_field_name('alias')
421 |                     if alias_node:
422 |                         alias = self._get_node_text(alias_node)
423 |                         imports.append({'name': '*', 'source': source, 'alias': alias, 'line_number': line_number,
424 |                                         'lang': self.language_name})
425 | 
426 |                 # Named imports: import { name, name as alias } from '...'
427 |                 elif import_clause.type == 'named_imports':
428 |                     for specifier in import_clause.children:
429 |                         if specifier.type == 'import_specifier':
430 |                             name_node = specifier.child_by_field_name('name')
431 |                             alias_node = specifier.child_by_field_name('alias')
432 |                             original_name = self._get_node_text(name_node)
433 |                             alias = self._get_node_text(alias_node) if alias_node else None
434 |                             imports.append(
435 |                                 {'name': original_name, 'source': source, 'alias': alias, 'line_number': line_number,
436 |                                  'lang': self.language_name})
437 | 
438 |             elif node.type == 'call_expression':  # require('...')
439 |                 args = node.child_by_field_name('arguments')
440 |                 if not args or args.named_child_count == 0: continue
441 |                 source_node = args.named_child(0)
442 |                 if not source_node or source_node.type != 'string': continue
443 |                 source = self._get_node_text(source_node).strip('\'"')
444 | 
445 |                 alias = None
446 |                 if node.parent.type == 'variable_declarator':
447 |                     alias_node = node.parent.child_by_field_name('name')
448 |                     if alias_node:
449 |                         alias = self._get_node_text(alias_node)
450 |                 imports.append({'name': source, 'source': source, 'alias': alias, 'line_number': line_number,
451 |                                 'lang': self.language_name})
452 | 
453 |         return imports
454 | 
455 | 
456 |     def _find_calls(self, root_node):
457 |         calls = []
458 |         query = self.queries['calls']
459 |         for node, capture_name in query.captures(root_node):
460 |             # Placeholder for JS call extraction logic
461 |             if capture_name == 'name':
462 |                 call_node = node.parent
463 |                 name = self._get_node_text(node)
464 | 
465 |                 # Simplified args extraction for now
466 |                 args = []
467 | 
468 |                 call_data = {
469 |                     "name": name,
470 |                     "full_name": self._get_node_text(call_node),  # This might need refinement
471 |                     "line_number": node.start_point[0] + 1,
472 |                     "args": args,
473 |                     "inferred_obj_type": None,
474 |                     "context": None,  # Placeholder
475 |                     "class_context": None,  # Placeholder
476 |                     "lang": self.language_name,
477 |                     "is_dependency": False,
478 |                 }
479 |                 calls.append(call_data)
480 |         return calls
481 | 
482 | 
483 |     def _find_variables(self, root_node):
484 |         variables = []
485 |         query = self.queries['variables']
486 |         for match in query.captures(root_node):
487 |             capture_name = match[1]
488 |             node = match[0]
489 | 
490 |             # Placeholder for JS variable extraction logic
491 |             if capture_name == 'name':
492 |                 var_node = node.parent
493 |                 name = self._get_node_text(node)
494 |                 value = None 
495 |                 type_text = None  # Placeholder
496 | 
497 | 
498 |                 # Detect if variable assigned to a function
499 |                 value_node = var_node.child_by_field_name("value") if var_node else None
500 | 
501 |                 if value_node:
502 |                     value_type = value_node.type
503 | 
504 |                     # --- Skip variables that are assigned a function ---
505 |                     if value_type in ("function_expression", "arrow_function"):
506 |                         continue
507 | 
508 |                     # --- Handle various assignment types ---
509 |                     if value_type == "call_expression":
510 |                         func_name_node = value_node.child_by_field_name("name")
511 |                         func_name = (
512 |                             self._get_node_text(func_name_node) 
513 |                             if func_name_node
514 |                             else name
515 |                         )
516 |                         value = func_name
517 |                     else:
518 |                         # Anything else (e.g. binary expressions)
519 |                         value = self._get_node_text(value_node)
520 | 
521 |                 variable_data = {
522 |                     "name": name,
523 |                     "line_number": node.start_point[0] + 1,
524 |                     "value": value,
525 |                     "type": type_text,
526 |                     "context": None,  # Placeholder
527 |                     "class_context": None,  # Placeholder
528 |                     "lang": self.language_name,
529 |                     "is_dependency": False,
530 |                 }
531 |                 variables.append(variable_data)
532 |         return variables
533 | 
534 | 
535 | def pre_scan_javascript(files: list[Path], parser_wrapper) -> dict:
536 |     """Scans JavaScript files to create a map of class/function names to their file paths."""
537 |     imports_map = {}
538 |     query_str = """
539 |         (class_declaration name: (identifier) @name)
540 |         (function_declaration name: (identifier) @name)
541 |         (variable_declarator name: (identifier) @name value: (function))
542 |         (variable_declarator name: (identifier) @name value: (arrow_function))
543 |         (method_definition name: (property_identifier) @name)
544 |         (assignment_expression
545 |             left: (member_expression 
546 |                 property: (property_identifier) @name
547 |             )
548 |             right: (function)
549 |         )
550 |         (assignment_expression
551 |             left: (member_expression 
552 |                 property: (property_identifier) @name
553 |             )
554 |             right: (arrow_function)
555 |         )
556 |     """
557 |     query = parser_wrapper.language.query(query_str)
558 | 
559 |     for file_path in files:
560 |         try:
561 |             with open(file_path, "r", encoding="utf-8") as f:
562 |                 tree = parser_wrapper.parser.parse(bytes(f.read(), "utf8"))
563 | 
564 |             for capture, _ in query.captures(tree.root_node):
565 |                 name = capture.text.decode('utf-8')
566 |                 if name not in imports_map:
567 |                     imports_map[name] = []
568 |                 imports_map[name].append(str(file_path.resolve()))
569 |         except Exception as e:
570 |             warning_logger(f"Tree-sitter pre-scan failed for {file_path}: {e}")
571 |     return imports_map
572 | 
```

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

```html
  1 | 
  2 | <!doctype html>
  3 | <html lang="en" class="no-js">
  4 |   <head>
  5 |     
  6 |       <meta charset="utf-8">
  7 |       <meta name="viewport" content="width=device-width,initial-scale=1">
  8 |       
  9 |       
 10 |       
 11 |       
 12 |         <link rel="prev" href="../core/">
 13 |       
 14 |       
 15 |         <link rel="next" href="../cookbook/">
 16 |       
 17 |       
 18 |       <link rel="icon" href="../assets/images/favicon.png">
 19 |       <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.21">
 20 |     
 21 |     
 22 |       
 23 |         <title>Tools - CodeGraphContext</title>
 24 |       
 25 |     
 26 |     
 27 |       <link rel="stylesheet" href="../assets/stylesheets/main.2a3383ac.min.css">
 28 |       
 29 |       
 30 | 
 31 | 
 32 |     
 33 |     
 34 |       
 35 |     
 36 |     
 37 |       
 38 |         
 39 |         
 40 |         <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
 41 |         <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">
 42 |         <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
 43 |       
 44 |     
 45 |     
 46 |     <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>
 47 |     
 48 |       
 49 | 
 50 |     
 51 |     
 52 |     
 53 |   </head>
 54 |   
 55 |   
 56 |     <body dir="ltr">
 57 |   
 58 |     
 59 |     <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
 60 |     <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
 61 |     <label class="md-overlay" for="__drawer"></label>
 62 |     <div data-md-component="skip">
 63 |       
 64 |         
 65 |         <a href="#tools" class="md-skip">
 66 |           Skip to content
 67 |         </a>
 68 |       
 69 |     </div>
 70 |     <div data-md-component="announce">
 71 |       
 72 |     </div>
 73 |     
 74 |     
 75 |       
 76 | 
 77 |   
 78 | 
 79 | <header class="md-header md-header--shadow" data-md-component="header">
 80 |   <nav class="md-header__inner md-grid" aria-label="Header">
 81 |     <a href=".." title="CodeGraphContext" class="md-header__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
 82 |       
 83 |   
 84 |   <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>
 85 | 
 86 |     </a>
 87 |     <label class="md-header__button md-icon" for="__drawer">
 88 |       
 89 |       <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
 90 |     </label>
 91 |     <div class="md-header__title" data-md-component="header-title">
 92 |       <div class="md-header__ellipsis">
 93 |         <div class="md-header__topic">
 94 |           <span class="md-ellipsis">
 95 |             CodeGraphContext
 96 |           </span>
 97 |         </div>
 98 |         <div class="md-header__topic" data-md-component="header-topic">
 99 |           <span class="md-ellipsis">
100 |             
101 |               Tools
102 |             
103 |           </span>
104 |         </div>
105 |       </div>
106 |     </div>
107 |     
108 |     
109 |       <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>
110 |     
111 |     
112 |     
113 |       
114 |       
115 |         <label class="md-header__button md-icon" for="__search">
116 |           
117 |           <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>
118 |         </label>
119 |         <div class="md-search" data-md-component="search" role="dialog">
120 |   <label class="md-search__overlay" for="__search"></label>
121 |   <div class="md-search__inner" role="search">
122 |     <form class="md-search__form" name="search">
123 |       <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>
124 |       <label class="md-search__icon md-icon" for="__search">
125 |         
126 |         <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>
127 |         
128 |         <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>
129 |       </label>
130 |       <nav class="md-search__options" aria-label="Search">
131 |         
132 |         <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
133 |           
134 |           <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>
135 |         </button>
136 |       </nav>
137 |       
138 |     </form>
139 |     <div class="md-search__output">
140 |       <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
141 |         <div class="md-search-result" data-md-component="search-result">
142 |           <div class="md-search-result__meta">
143 |             Initializing search
144 |           </div>
145 |           <ol class="md-search-result__list" role="presentation"></ol>
146 |         </div>
147 |       </div>
148 |     </div>
149 |   </div>
150 | </div>
151 |       
152 |     
153 |     
154 |   </nav>
155 |   
156 | </header>
157 |     
158 |     <div class="md-container" data-md-component="container">
159 |       
160 |       
161 |         
162 |           
163 |         
164 |       
165 |       <main class="md-main" data-md-component="main">
166 |         <div class="md-main__inner md-grid">
167 |           
168 |             
169 |               
170 |               <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
171 |                 <div class="md-sidebar__scrollwrap">
172 |                   <div class="md-sidebar__inner">
173 |                     
174 | 
175 | 
176 | 
177 | <nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
178 |   <label class="md-nav__title" for="__drawer">
179 |     <a href=".." title="CodeGraphContext" class="md-nav__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
180 |       
181 |   
182 |   <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>
183 | 
184 |     </a>
185 |     CodeGraphContext
186 |   </label>
187 |   
188 |   <ul class="md-nav__list" data-md-scrollfix>
189 |     
190 |       
191 |       
192 |   
193 |   
194 |   
195 |   
196 |     <li class="md-nav__item">
197 |       <a href=".." class="md-nav__link">
198 |         
199 |   
200 |   
201 |   <span class="md-ellipsis">
202 |     Home
203 |     
204 |   </span>
205 |   
206 | 
207 |       </a>
208 |     </li>
209 |   
210 | 
211 |     
212 |       
213 |       
214 |   
215 |   
216 |   
217 |   
218 |     <li class="md-nav__item">
219 |       <a href="../installation/" class="md-nav__link">
220 |         
221 |   
222 |   
223 |   <span class="md-ellipsis">
224 |     Installation
225 |     
226 |   </span>
227 |   
228 | 
229 |       </a>
230 |     </li>
231 |   
232 | 
233 |     
234 |       
235 |       
236 |   
237 |   
238 |   
239 |   
240 |     <li class="md-nav__item">
241 |       <a href="../use_cases/" class="md-nav__link">
242 |         
243 |   
244 |   
245 |   <span class="md-ellipsis">
246 |     Use Cases
247 |     
248 |   </span>
249 |   
250 | 
251 |       </a>
252 |     </li>
253 |   
254 | 
255 |     
256 |       
257 |       
258 |   
259 |   
260 |   
261 |   
262 |     <li class="md-nav__item">
263 |       <a href="../architecture/" class="md-nav__link">
264 |         
265 |   
266 |   
267 |   <span class="md-ellipsis">
268 |     Architecture
269 |     
270 |   </span>
271 |   
272 | 
273 |       </a>
274 |     </li>
275 |   
276 | 
277 |     
278 |       
279 |       
280 |   
281 |   
282 |   
283 |   
284 |     <li class="md-nav__item">
285 |       <a href="../cli/" class="md-nav__link">
286 |         
287 |   
288 |   
289 |   <span class="md-ellipsis">
290 |     CLI Reference
291 |     
292 |   </span>
293 |   
294 | 
295 |       </a>
296 |     </li>
297 |   
298 | 
299 |     
300 |       
301 |       
302 |   
303 |   
304 |   
305 |   
306 |     <li class="md-nav__item">
307 |       <a href="../server/" class="md-nav__link">
308 |         
309 |   
310 |   
311 |   <span class="md-ellipsis">
312 |     Server
313 |     
314 |   </span>
315 |   
316 | 
317 |       </a>
318 |     </li>
319 |   
320 | 
321 |     
322 |       
323 |       
324 |   
325 |   
326 |   
327 |   
328 |     <li class="md-nav__item">
329 |       <a href="../core/" class="md-nav__link">
330 |         
331 |   
332 |   
333 |   <span class="md-ellipsis">
334 |     Core Concepts
335 |     
336 |   </span>
337 |   
338 | 
339 |       </a>
340 |     </li>
341 |   
342 | 
343 |     
344 |       
345 |       
346 |   
347 |   
348 |     
349 |   
350 |   
351 |   
352 |     <li class="md-nav__item md-nav__item--active">
353 |       
354 |       <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
355 |       
356 |       
357 |         
358 |       
359 |       
360 |         <label class="md-nav__link md-nav__link--active" for="__toc">
361 |           
362 |   
363 |   
364 |   <span class="md-ellipsis">
365 |     Tools
366 |     
367 |   </span>
368 |   
369 | 
370 |           <span class="md-nav__icon md-icon"></span>
371 |         </label>
372 |       
373 |       <a href="./" class="md-nav__link md-nav__link--active">
374 |         
375 |   
376 |   
377 |   <span class="md-ellipsis">
378 |     Tools
379 |     
380 |   </span>
381 |   
382 | 
383 |       </a>
384 |       
385 |         
386 | 
387 | <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
388 |   
389 |   
390 |   
391 |     
392 |   
393 |   
394 |     <label class="md-nav__title" for="__toc">
395 |       <span class="md-nav__icon md-icon"></span>
396 |       Table of contents
397 |     </label>
398 |     <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
399 |       
400 |         <li class="md-nav__item">
401 |   <a href="#graphbuilder" class="md-nav__link">
402 |     <span class="md-ellipsis">
403 |       GraphBuilder
404 |     </span>
405 |   </a>
406 |   
407 |     <nav class="md-nav" aria-label="GraphBuilder">
408 |       <ul class="md-nav__list">
409 |         
410 |           <li class="md-nav__item">
411 |   <a href="#treesitterparser" class="md-nav__link">
412 |     <span class="md-ellipsis">
413 |       TreeSitterParser
414 |     </span>
415 |   </a>
416 |   
417 | </li>
418 |         
419 |           <li class="md-nav__item">
420 |   <a href="#graph-building-process" class="md-nav__link">
421 |     <span class="md-ellipsis">
422 |       Graph Building Process
423 |     </span>
424 |   </a>
425 |   
426 | </li>
427 |         
428 |       </ul>
429 |     </nav>
430 |   
431 | </li>
432 |       
433 |         <li class="md-nav__item">
434 |   <a href="#codefinder" class="md-nav__link">
435 |     <span class="md-ellipsis">
436 |       CodeFinder
437 |     </span>
438 |   </a>
439 |   
440 |     <nav class="md-nav" aria-label="CodeFinder">
441 |       <ul class="md-nav__list">
442 |         
443 |           <li class="md-nav__item">
444 |   <a href="#key-methods" class="md-nav__link">
445 |     <span class="md-ellipsis">
446 |       Key Methods
447 |     </span>
448 |   </a>
449 |   
450 | </li>
451 |         
452 |       </ul>
453 |     </nav>
454 |   
455 | </li>
456 |       
457 |         <li class="md-nav__item">
458 |   <a href="#importextractor" class="md-nav__link">
459 |     <span class="md-ellipsis">
460 |       ImportExtractor
461 |     </span>
462 |   </a>
463 |   
464 | </li>
465 |       
466 |     </ul>
467 |   
468 | </nav>
469 |       
470 |     </li>
471 |   
472 | 
473 |     
474 |       
475 |       
476 |   
477 |   
478 |   
479 |   
480 |     <li class="md-nav__item">
481 |       <a href="../cookbook/" class="md-nav__link">
482 |         
483 |   
484 |   
485 |   <span class="md-ellipsis">
486 |     Cookbook
487 |     
488 |   </span>
489 |   
490 | 
491 |       </a>
492 |     </li>
493 |   
494 | 
495 |     
496 |       
497 |       
498 |   
499 |   
500 |   
501 |   
502 |     
503 |     
504 |     
505 |     
506 |     
507 |     <li class="md-nav__item md-nav__item--nested">
508 |       
509 |         
510 |         
511 |         <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_10" >
512 |         
513 |           
514 |           <label class="md-nav__link" for="__nav_10" id="__nav_10_label" tabindex="0">
515 |             
516 |   
517 |   
518 |   <span class="md-ellipsis">
519 |     Contributing
520 |     
521 |   </span>
522 |   
523 | 
524 |             <span class="md-nav__icon md-icon"></span>
525 |           </label>
526 |         
527 |         <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_10_label" aria-expanded="false">
528 |           <label class="md-nav__title" for="__nav_10">
529 |             <span class="md-nav__icon md-icon"></span>
530 |             Contributing
531 |           </label>
532 |           <ul class="md-nav__list" data-md-scrollfix>
533 |             
534 |               
535 |                 
536 |   
537 |   
538 |   
539 |   
540 |     <li class="md-nav__item">
541 |       <a href="../contributing/" class="md-nav__link">
542 |         
543 |   
544 |   
545 |   <span class="md-ellipsis">
546 |     Overview
547 |     
548 |   </span>
549 |   
550 | 
551 |       </a>
552 |     </li>
553 |   
554 | 
555 |               
556 |             
557 |               
558 |                 
559 |   
560 |   
561 |   
562 |   
563 |     <li class="md-nav__item">
564 |       <a href="../contributing_languages/" class="md-nav__link">
565 |         
566 |   
567 |   
568 |   <span class="md-ellipsis">
569 |     Adding New Languages
570 |     
571 |   </span>
572 |   
573 | 
574 |       </a>
575 |     </li>
576 |   
577 | 
578 |               
579 |             
580 |           </ul>
581 |         </nav>
582 |       
583 |     </li>
584 |   
585 | 
586 |     
587 |       
588 |       
589 |   
590 |   
591 |   
592 |   
593 |     <li class="md-nav__item">
594 |       <a href="../troubleshooting/" class="md-nav__link">
595 |         
596 |   
597 |   
598 |   <span class="md-ellipsis">
599 |     Troubleshooting
600 |     
601 |   </span>
602 |   
603 | 
604 |       </a>
605 |     </li>
606 |   
607 | 
608 |     
609 |       
610 |       
611 |   
612 |   
613 |   
614 |   
615 |     <li class="md-nav__item">
616 |       <a href="../future_work/" class="md-nav__link">
617 |         
618 |   
619 |   
620 |   <span class="md-ellipsis">
621 |     Future Work
622 |     
623 |   </span>
624 |   
625 | 
626 |       </a>
627 |     </li>
628 |   
629 | 
630 |     
631 |       
632 |       
633 |   
634 |   
635 |   
636 |   
637 |     <li class="md-nav__item">
638 |       <a href="../license/" class="md-nav__link">
639 |         
640 |   
641 |   
642 |   <span class="md-ellipsis">
643 |     License
644 |     
645 |   </span>
646 |   
647 | 
648 |       </a>
649 |     </li>
650 |   
651 | 
652 |     
653 |   </ul>
654 | </nav>
655 |                   </div>
656 |                 </div>
657 |               </div>
658 |             
659 |             
660 |               
661 |               <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
662 |                 <div class="md-sidebar__scrollwrap">
663 |                   <div class="md-sidebar__inner">
664 |                     
665 | 
666 | <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
667 |   
668 |   
669 |   
670 |     
671 |   
672 |   
673 |     <label class="md-nav__title" for="__toc">
674 |       <span class="md-nav__icon md-icon"></span>
675 |       Table of contents
676 |     </label>
677 |     <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
678 |       
679 |         <li class="md-nav__item">
680 |   <a href="#graphbuilder" class="md-nav__link">
681 |     <span class="md-ellipsis">
682 |       GraphBuilder
683 |     </span>
684 |   </a>
685 |   
686 |     <nav class="md-nav" aria-label="GraphBuilder">
687 |       <ul class="md-nav__list">
688 |         
689 |           <li class="md-nav__item">
690 |   <a href="#treesitterparser" class="md-nav__link">
691 |     <span class="md-ellipsis">
692 |       TreeSitterParser
693 |     </span>
694 |   </a>
695 |   
696 | </li>
697 |         
698 |           <li class="md-nav__item">
699 |   <a href="#graph-building-process" class="md-nav__link">
700 |     <span class="md-ellipsis">
701 |       Graph Building Process
702 |     </span>
703 |   </a>
704 |   
705 | </li>
706 |         
707 |       </ul>
708 |     </nav>
709 |   
710 | </li>
711 |       
712 |         <li class="md-nav__item">
713 |   <a href="#codefinder" class="md-nav__link">
714 |     <span class="md-ellipsis">
715 |       CodeFinder
716 |     </span>
717 |   </a>
718 |   
719 |     <nav class="md-nav" aria-label="CodeFinder">
720 |       <ul class="md-nav__list">
721 |         
722 |           <li class="md-nav__item">
723 |   <a href="#key-methods" class="md-nav__link">
724 |     <span class="md-ellipsis">
725 |       Key Methods
726 |     </span>
727 |   </a>
728 |   
729 | </li>
730 |         
731 |       </ul>
732 |     </nav>
733 |   
734 | </li>
735 |       
736 |         <li class="md-nav__item">
737 |   <a href="#importextractor" class="md-nav__link">
738 |     <span class="md-ellipsis">
739 |       ImportExtractor
740 |     </span>
741 |   </a>
742 |   
743 | </li>
744 |       
745 |     </ul>
746 |   
747 | </nav>
748 |                   </div>
749 |                 </div>
750 |               </div>
751 |             
752 |           
753 |           
754 |             <div class="md-content" data-md-component="content">
755 |               <article class="md-content__inner md-typeset">
756 |                 
757 |                   
758 | 
759 | 
760 | 
761 | <h1 id="tools">Tools</h1>
762 | <p>The <code>tools</code> directory contains the logic for code analysis, including building the graph, finding code, and extracting imports.</p>
763 | <h2 id="graphbuilder"><code>GraphBuilder</code></h2>
764 | <p>The <code>GraphBuilder</code> class in <code>graph_builder.py</code> is responsible for parsing the source code and building the graph representation that is stored in the Neo4j database.</p>
765 | <h3 id="treesitterparser"><code>TreeSitterParser</code></h3>
766 | <p><code>GraphBuilder</code> uses the <code>TreeSitterParser</code> class, which is a generic parser wrapper for a specific language using the tree-sitter library. This allows CodeGraphContext to support multiple programming languages in a modular way.</p>
767 | <h3 id="graph-building-process">Graph Building Process</h3>
768 | <p>The graph building process consists of several steps:</p>
769 | <ol>
770 | <li><strong>Pre-scan for Imports:</strong> A quick scan of all files to build a global map of where every symbol is defined.</li>
771 | <li><strong>Parse Files:</strong> Each file is parsed in detail to extract its structure, including functions, classes, variables, and imports.</li>
772 | <li><strong>Add Nodes to Graph:</strong> The extracted code elements are added to the graph as nodes.</li>
773 | <li><strong>Create Relationships:</strong> Relationships between the nodes are created, such as <code>CALLS</code> for function calls and <code>INHERITS</code> for class inheritance.</li>
774 | </ol>
775 | <h2 id="codefinder"><code>CodeFinder</code></h2>
776 | <p>The <code>CodeFinder</code> class in <code>code_finder.py</code> provides functionality to search for specific code elements and analyze their relationships within the indexed codebase.</p>
777 | <h3 id="key-methods">Key Methods</h3>
778 | <ul>
779 | <li><code>find_by_function_name()</code>: Finds functions by name.</li>
780 | <li><code>find_by_class_name()</code>: Finds classes by name.</li>
781 | <li><code>find_by_variable_name()</code>: Finds variables by name.</li>
782 | <li><code>find_by_content()</code>: Finds code by content matching in source or docstrings.</li>
783 | <li><code>find_related_code()</code>: Finds code related to a query using multiple search strategies.</li>
784 | <li><code>analyze_code_relationships()</code>: Analyzes different types of code relationships, such as callers, callees, importers, and class hierarchies.</li>
785 | </ul>
786 | <h2 id="importextractor"><code>ImportExtractor</code></h2>
787 | <p>The <code>ImportExtractor</code> class in <code>import_extractor.py</code> is a utility for extracting package and module imports from source code files of various programming languages. It uses the most appropriate parsing technique for each language, such as AST for Python and regular expressions for JavaScript.</p>
788 | <h1 id="tools-exploration">Tools Exploration</h1>
789 | <p>There are a total of 14 tools available to the users, and here we have attached illustrative demos for each one of them.</p>
790 | <h2 id="find_code-tool">find_code Tool</h2>
791 | <p>The <code>find_code</code> tool allows users to search for code snippets, functions, classes, and variables within the codebase using natural language queries. This tool helps developers understand and navigate large codebases efficiently.</p>
792 | <p>Below is an embedded link to a demo video showcasing the usage of the <code>find_code</code> tool in action.
793 | <a href="https://drive.google.com/file/d/1ojCDIIAwcir9e3jgHHIVC5weZ9nuIQcs/view?usp=drive_link"><img alt="Watch the demo video" src="../images/tool_images/1.png" /></a></p>
794 | <hr />
795 | <h2 id="watch_directory-tool">watch_directory Tool</h2>
796 | <p>The <code>watch_directory</code> tool allows users to monitor a specified directory for file changes, additions, or deletions in real-time. It helps developers automate workflows such as triggering scripts, updating indexes, or syncing files whenever changes occur in the directory.</p>
797 | <p>Below is an embedded link to a demo video showcasing the usage of the <code>watch_directory</code> tool in a development environment.
798 | <a href="https://drive.google.com/file/d/1OEjcS2iwwymss99zLidbeBjcblferKBX/view?usp=drive_link"><img alt="Watch the demo" src="../images/tool_images/2.png" /></a> </p>
799 | <hr />
800 | <h2 id="analyze_code_relationships-tool">analyze_code_relationships Tool</h2>
801 | <p>The <code>analyze_code_relationships</code> tool in CodeGraphContext is designed to let users query and explore the various relationships between code elements in a codebase, represented as a graph in Neo4j. </p>
802 | <h3 id="relationship-types-that-can-be-analyzed">Relationship Types That Can Be Analyzed</h3>
803 | <ul>
804 | <li><strong>CALLS:</strong> Finds which functions call or are called by a function.</li>
805 | <li><strong>CALLED_BY:</strong> Finds all functions that directly or indirectly call a target function (inverse of CALLS).</li>
806 | <li><strong>INHERITS_FROM:</strong> Finds class inheritance relationships; which classes inherit from which.</li>
807 | <li><strong>CONTAINS:</strong> Shows containment (which classes/functions are inside which modules or files).</li>
808 | <li><strong>IMPLEMENTS:</strong> Shows which classes implement an interface.</li>
809 | <li><strong>IMPORTS:</strong> Identifies which files or modules import a specific module.</li>
810 | <li><strong>DEFINED_IN:</strong> Locates where an entity (function/class) is defined.</li>
811 | <li><strong>HAS_ARGUMENT:</strong> Shows relationships from functions to their arguments.</li>
812 | <li><strong>DECLARES:</strong> Finds variables declared in functions or classes.</li>
813 | </ul>
814 | <p>Below is an embedded link to a demo video showcasing the usage of the <code>analyse_code_relationships</code> tool.
815 | <a href="https://drive.google.com/file/d/154M_lTPbg9_Gj9bd2ErnAVbJArSbcb2M/view?usp=drive_link"><img alt="Watch the demo" src="../images/tool_images/3.png" /></a> </p>
816 | <hr />
817 | 
818 | 
819 | 
820 | 
821 | 
822 | 
823 | 
824 | 
825 | 
826 | 
827 | 
828 | 
829 |                 
830 |               </article>
831 |             </div>
832 |           
833 |           
834 | <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
835 |         </div>
836 |         
837 |       </main>
838 |       
839 |         <footer class="md-footer">
840 |   
841 |   <div class="md-footer-meta md-typeset">
842 |     <div class="md-footer-meta__inner md-grid">
843 |       <div class="md-copyright">
844 |   
845 |   
846 |     Made with
847 |     <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
848 |       Material for MkDocs
849 |     </a>
850 |   
851 | </div>
852 |       
853 |     </div>
854 |   </div>
855 | </footer>
856 |       
857 |     </div>
858 |     <div class="md-dialog" data-md-component="dialog">
859 |       <div class="md-dialog__inner md-typeset"></div>
860 |     </div>
861 |     
862 |     
863 |     
864 |       
865 |       <script id="__config" type="application/json">{"base": "..", "features": [], "search": "../assets/javascripts/workers/search.973d3a69.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>
866 |     
867 |     
868 |       <script src="../assets/javascripts/bundle.f55a23d4.min.js"></script>
869 |       
870 |     
871 |   </body>
872 | </html>
```

--------------------------------------------------------------------------------
/website/src/components/ui/sidebar.tsx:
--------------------------------------------------------------------------------

```typescript
  1 | import * as React from "react";
  2 | import { Slot } from "@radix-ui/react-slot";
  3 | import { VariantProps, cva } from "class-variance-authority";
  4 | import { PanelLeft } from "lucide-react";
  5 | 
  6 | import { useIsMobile } from "@/hooks/use-mobile";
  7 | import { cn } from "@/lib/utils";
  8 | import { Button } from "@/components/ui/button";
  9 | import { Input } from "@/components/ui/input";
 10 | import { Separator } from "@/components/ui/separator";
 11 | import { Sheet, SheetContent } from "@/components/ui/sheet";
 12 | import { Skeleton } from "@/components/ui/skeleton";
 13 | import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
 14 | 
 15 | const SIDEBAR_COOKIE_NAME = "sidebar:state";
 16 | const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
 17 | const SIDEBAR_WIDTH = "16rem";
 18 | const SIDEBAR_WIDTH_MOBILE = "18rem";
 19 | const SIDEBAR_WIDTH_ICON = "3rem";
 20 | const SIDEBAR_KEYBOARD_SHORTCUT = "b";
 21 | 
 22 | type SidebarContext = {
 23 |   state: "expanded" | "collapsed";
 24 |   open: boolean;
 25 |   setOpen: (open: boolean) => void;
 26 |   openMobile: boolean;
 27 |   setOpenMobile: (open: boolean) => void;
 28 |   isMobile: boolean;
 29 |   toggleSidebar: () => void;
 30 | };
 31 | 
 32 | const SidebarContext = React.createContext<SidebarContext | null>(null);
 33 | 
 34 | function useSidebar() {
 35 |   const context = React.useContext(SidebarContext);
 36 |   if (!context) {
 37 |     throw new Error("useSidebar must be used within a SidebarProvider.");
 38 |   }
 39 | 
 40 |   return context;
 41 | }
 42 | 
 43 | const SidebarProvider = React.forwardRef<
 44 |   HTMLDivElement,
 45 |   React.ComponentProps<"div"> & {
 46 |     defaultOpen?: boolean;
 47 |     open?: boolean;
 48 |     onOpenChange?: (open: boolean) => void;
 49 |   }
 50 | >(({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }, ref) => {
 51 |   const isMobile = useIsMobile();
 52 |   const [openMobile, setOpenMobile] = React.useState(false);
 53 | 
 54 |   // This is the internal state of the sidebar.
 55 |   // We use openProp and setOpenProp for control from outside the component.
 56 |   const [_open, _setOpen] = React.useState(defaultOpen);
 57 |   const open = openProp ?? _open;
 58 |   const setOpen = React.useCallback(
 59 |     (value: boolean | ((value: boolean) => boolean)) => {
 60 |       const openState = typeof value === "function" ? value(open) : value;
 61 |       if (setOpenProp) {
 62 |         setOpenProp(openState);
 63 |       } else {
 64 |         _setOpen(openState);
 65 |       }
 66 | 
 67 |       // This sets the cookie to keep the sidebar state.
 68 |       document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
 69 |     },
 70 |     [setOpenProp, open],
 71 |   );
 72 | 
 73 |   // Helper to toggle the sidebar.
 74 |   const toggleSidebar = React.useCallback(() => {
 75 |     return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
 76 |   }, [isMobile, setOpen, setOpenMobile]);
 77 | 
 78 |   // Adds a keyboard shortcut to toggle the sidebar.
 79 |   React.useEffect(() => {
 80 |     const handleKeyDown = (event: KeyboardEvent) => {
 81 |       if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
 82 |         event.preventDefault();
 83 |         toggleSidebar();
 84 |       }
 85 |     };
 86 | 
 87 |     window.addEventListener("keydown", handleKeyDown);
 88 |     return () => window.removeEventListener("keydown", handleKeyDown);
 89 |   }, [toggleSidebar]);
 90 | 
 91 |   // We add a state so that we can do data-state="expanded" or "collapsed".
 92 |   // This makes it easier to style the sidebar with Tailwind classes.
 93 |   const state = open ? "expanded" : "collapsed";
 94 | 
 95 |   const contextValue = React.useMemo<SidebarContext>(
 96 |     () => ({
 97 |       state,
 98 |       open,
 99 |       setOpen,
100 |       isMobile,
101 |       openMobile,
102 |       setOpenMobile,
103 |       toggleSidebar,
104 |     }),
105 |     [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
106 |   );
107 | 
108 |   return (
109 |     <SidebarContext.Provider value={contextValue}>
110 |       <TooltipProvider delayDuration={0}>
111 |         <div
112 |           style={
113 |             {
114 |               "--sidebar-width": SIDEBAR_WIDTH,
115 |               "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
116 |               ...style,
117 |             } as React.CSSProperties
118 |           }
119 |           className={cn("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar", className)}
120 |           ref={ref}
121 |           {...props}
122 |         >
123 |           {children}
124 |         </div>
125 |       </TooltipProvider>
126 |     </SidebarContext.Provider>
127 |   );
128 | });
129 | SidebarProvider.displayName = "SidebarProvider";
130 | 
131 | const Sidebar = React.forwardRef<
132 |   HTMLDivElement,
133 |   React.ComponentProps<"div"> & {
134 |     side?: "left" | "right";
135 |     variant?: "sidebar" | "floating" | "inset";
136 |     collapsible?: "offcanvas" | "icon" | "none";
137 |   }
138 | >(({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, ...props }, ref) => {
139 |   const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
140 | 
141 |   if (collapsible === "none") {
142 |     return (
143 |       <div
144 |         className={cn("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground", className)}
145 |         ref={ref}
146 |         {...props}
147 |       >
148 |         {children}
149 |       </div>
150 |     );
151 |   }
152 | 
153 |   if (isMobile) {
154 |     return (
155 |       <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
156 |         <SheetContent
157 |           data-sidebar="sidebar"
158 |           data-mobile="true"
159 |           className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
160 |           style={
161 |             {
162 |               "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
163 |             } as React.CSSProperties
164 |           }
165 |           side={side}
166 |         >
167 |           <div className="flex h-full w-full flex-col">{children}</div>
168 |         </SheetContent>
169 |       </Sheet>
170 |     );
171 |   }
172 | 
173 |   return (
174 |     <div
175 |       ref={ref}
176 |       className="group peer hidden text-sidebar-foreground md:block"
177 |       data-state={state}
178 |       data-collapsible={state === "collapsed" ? collapsible : ""}
179 |       data-variant={variant}
180 |       data-side={side}
181 |     >
182 |       {/* This is what handles the sidebar gap on desktop */}
183 |       <div
184 |         className={cn(
185 |           "relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
186 |           "group-data-[collapsible=offcanvas]:w-0",
187 |           "group-data-[side=right]:rotate-180",
188 |           variant === "floating" || variant === "inset"
189 |             ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
190 |             : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]",
191 |         )}
192 |       />
193 |       <div
194 |         className={cn(
195 |           "fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
196 |           side === "left"
197 |             ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
198 |             : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
199 |           // Adjust the padding for floating and inset variants.
200 |           variant === "floating" || variant === "inset"
201 |             ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
202 |             : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
203 |           className,
204 |         )}
205 |         {...props}
206 |       >
207 |         <div
208 |           data-sidebar="sidebar"
209 |           className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
210 |         >
211 |           {children}
212 |         </div>
213 |       </div>
214 |     </div>
215 |   );
216 | });
217 | Sidebar.displayName = "Sidebar";
218 | 
219 | const SidebarTrigger = React.forwardRef<React.ElementRef<typeof Button>, React.ComponentProps<typeof Button>>(
220 |   ({ className, onClick, ...props }, ref) => {
221 |     const { toggleSidebar } = useSidebar();
222 | 
223 |     return (
224 |       <Button
225 |         ref={ref}
226 |         data-sidebar="trigger"
227 |         variant="ghost"
228 |         size="icon"
229 |         className={cn("h-7 w-7", className)}
230 |         onClick={(event) => {
231 |           onClick?.(event);
232 |           toggleSidebar();
233 |         }}
234 |         {...props}
235 |       >
236 |         <PanelLeft />
237 |         <span className="sr-only">Toggle Sidebar</span>
238 |       </Button>
239 |     );
240 |   },
241 | );
242 | SidebarTrigger.displayName = "SidebarTrigger";
243 | 
244 | const SidebarRail = React.forwardRef<HTMLButtonElement, React.ComponentProps<"button">>(
245 |   ({ className, ...props }, ref) => {
246 |     const { toggleSidebar } = useSidebar();
247 | 
248 |     return (
249 |       <button
250 |         ref={ref}
251 |         data-sidebar="rail"
252 |         aria-label="Toggle Sidebar"
253 |         tabIndex={-1}
254 |         onClick={toggleSidebar}
255 |         title="Toggle Sidebar"
256 |         className={cn(
257 |           "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 hover:after:bg-sidebar-border sm:flex",
258 |           "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
259 |           "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
260 |           "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
261 |           "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
262 |           "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
263 |           className,
264 |         )}
265 |         {...props}
266 |       />
267 |     );
268 |   },
269 | );
270 | SidebarRail.displayName = "SidebarRail";
271 | 
272 | const SidebarInset = React.forwardRef<HTMLDivElement, React.ComponentProps<"main">>(({ className, ...props }, ref) => {
273 |   return (
274 |     <main
275 |       ref={ref}
276 |       className={cn(
277 |         "relative flex min-h-svh flex-1 flex-col bg-background",
278 |         "peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
279 |         className,
280 |       )}
281 |       {...props}
282 |     />
283 |   );
284 | });
285 | SidebarInset.displayName = "SidebarInset";
286 | 
287 | const SidebarInput = React.forwardRef<React.ElementRef<typeof Input>, React.ComponentProps<typeof Input>>(
288 |   ({ className, ...props }, ref) => {
289 |     return (
290 |       <Input
291 |         ref={ref}
292 |         data-sidebar="input"
293 |         className={cn(
294 |           "h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
295 |           className,
296 |         )}
297 |         {...props}
298 |       />
299 |     );
300 |   },
301 | );
302 | SidebarInput.displayName = "SidebarInput";
303 | 
304 | const SidebarHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
305 |   return <div ref={ref} data-sidebar="header" className={cn("flex flex-col gap-2 p-2", className)} {...props} />;
306 | });
307 | SidebarHeader.displayName = "SidebarHeader";
308 | 
309 | const SidebarFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
310 |   return <div ref={ref} data-sidebar="footer" className={cn("flex flex-col gap-2 p-2", className)} {...props} />;
311 | });
312 | SidebarFooter.displayName = "SidebarFooter";
313 | 
314 | const SidebarSeparator = React.forwardRef<React.ElementRef<typeof Separator>, React.ComponentProps<typeof Separator>>(
315 |   ({ className, ...props }, ref) => {
316 |     return (
317 |       <Separator
318 |         ref={ref}
319 |         data-sidebar="separator"
320 |         className={cn("mx-2 w-auto bg-sidebar-border", className)}
321 |         {...props}
322 |       />
323 |     );
324 |   },
325 | );
326 | SidebarSeparator.displayName = "SidebarSeparator";
327 | 
328 | const SidebarContent = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
329 |   return (
330 |     <div
331 |       ref={ref}
332 |       data-sidebar="content"
333 |       className={cn(
334 |         "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
335 |         className,
336 |       )}
337 |       {...props}
338 |     />
339 |   );
340 | });
341 | SidebarContent.displayName = "SidebarContent";
342 | 
343 | const SidebarGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
344 |   return (
345 |     <div
346 |       ref={ref}
347 |       data-sidebar="group"
348 |       className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
349 |       {...props}
350 |     />
351 |   );
352 | });
353 | SidebarGroup.displayName = "SidebarGroup";
354 | 
355 | const SidebarGroupLabel = React.forwardRef<HTMLDivElement, React.ComponentProps<"div"> & { asChild?: boolean }>(
356 |   ({ className, asChild = false, ...props }, ref) => {
357 |     const Comp = asChild ? Slot : "div";
358 | 
359 |     return (
360 |       <Comp
361 |         ref={ref}
362 |         data-sidebar="group-label"
363 |         className={cn(
364 |           "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
365 |           "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
366 |           className,
367 |         )}
368 |         {...props}
369 |       />
370 |     );
371 |   },
372 | );
373 | SidebarGroupLabel.displayName = "SidebarGroupLabel";
374 | 
375 | const SidebarGroupAction = React.forwardRef<HTMLButtonElement, React.ComponentProps<"button"> & { asChild?: boolean }>(
376 |   ({ className, asChild = false, ...props }, ref) => {
377 |     const Comp = asChild ? Slot : "button";
378 | 
379 |     return (
380 |       <Comp
381 |         ref={ref}
382 |         data-sidebar="group-action"
383 |         className={cn(
384 |           "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
385 |           // Increases the hit area of the button on mobile.
386 |           "after:absolute after:-inset-2 after:md:hidden",
387 |           "group-data-[collapsible=icon]:hidden",
388 |           className,
389 |         )}
390 |         {...props}
391 |       />
392 |     );
393 |   },
394 | );
395 | SidebarGroupAction.displayName = "SidebarGroupAction";
396 | 
397 | const SidebarGroupContent = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(
398 |   ({ className, ...props }, ref) => (
399 |     <div ref={ref} data-sidebar="group-content" className={cn("w-full text-sm", className)} {...props} />
400 |   ),
401 | );
402 | SidebarGroupContent.displayName = "SidebarGroupContent";
403 | 
404 | const SidebarMenu = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(({ className, ...props }, ref) => (
405 |   <ul ref={ref} data-sidebar="menu" className={cn("flex w-full min-w-0 flex-col gap-1", className)} {...props} />
406 | ));
407 | SidebarMenu.displayName = "SidebarMenu";
408 | 
409 | const SidebarMenuItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ className, ...props }, ref) => (
410 |   <li ref={ref} data-sidebar="menu-item" className={cn("group/menu-item relative", className)} {...props} />
411 | ));
412 | SidebarMenuItem.displayName = "SidebarMenuItem";
413 | 
414 | const sidebarMenuButtonVariants = cva(
415 |   "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
416 |   {
417 |     variants: {
418 |       variant: {
419 |         default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
420 |         outline:
421 |           "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
422 |       },
423 |       size: {
424 |         default: "h-8 text-sm",
425 |         sm: "h-7 text-xs",
426 |         lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
427 |       },
428 |     },
429 |     defaultVariants: {
430 |       variant: "default",
431 |       size: "default",
432 |     },
433 |   },
434 | );
435 | 
436 | const SidebarMenuButton = React.forwardRef<
437 |   HTMLButtonElement,
438 |   React.ComponentProps<"button"> & {
439 |     asChild?: boolean;
440 |     isActive?: boolean;
441 |     tooltip?: string | React.ComponentProps<typeof TooltipContent>;
442 |   } & VariantProps<typeof sidebarMenuButtonVariants>
443 | >(({ asChild = false, isActive = false, variant = "default", size = "default", tooltip, className, ...props }, ref) => {
444 |   const Comp = asChild ? Slot : "button";
445 |   const { isMobile, state } = useSidebar();
446 | 
447 |   const button = (
448 |     <Comp
449 |       ref={ref}
450 |       data-sidebar="menu-button"
451 |       data-size={size}
452 |       data-active={isActive}
453 |       className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
454 |       {...props}
455 |     />
456 |   );
457 | 
458 |   if (!tooltip) {
459 |     return button;
460 |   }
461 | 
462 |   if (typeof tooltip === "string") {
463 |     tooltip = {
464 |       children: tooltip,
465 |     };
466 |   }
467 | 
468 |   return (
469 |     <Tooltip>
470 |       <TooltipTrigger asChild>{button}</TooltipTrigger>
471 |       <TooltipContent side="right" align="center" hidden={state !== "collapsed" || isMobile} {...tooltip} />
472 |     </Tooltip>
473 |   );
474 | });
475 | SidebarMenuButton.displayName = "SidebarMenuButton";
476 | 
477 | const SidebarMenuAction = React.forwardRef<
478 |   HTMLButtonElement,
479 |   React.ComponentProps<"button"> & {
480 |     asChild?: boolean;
481 |     showOnHover?: boolean;
482 |   }
483 | >(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
484 |   const Comp = asChild ? Slot : "button";
485 | 
486 |   return (
487 |     <Comp
488 |       ref={ref}
489 |       data-sidebar="menu-action"
490 |       className={cn(
491 |         "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
492 |         // Increases the hit area of the button on mobile.
493 |         "after:absolute after:-inset-2 after:md:hidden",
494 |         "peer-data-[size=sm]/menu-button:top-1",
495 |         "peer-data-[size=default]/menu-button:top-1.5",
496 |         "peer-data-[size=lg]/menu-button:top-2.5",
497 |         "group-data-[collapsible=icon]:hidden",
498 |         showOnHover &&
499 |           "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",
500 |         className,
501 |       )}
502 |       {...props}
503 |     />
504 |   );
505 | });
506 | SidebarMenuAction.displayName = "SidebarMenuAction";
507 | 
508 | const SidebarMenuBadge = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(
509 |   ({ className, ...props }, ref) => (
510 |     <div
511 |       ref={ref}
512 |       data-sidebar="menu-badge"
513 |       className={cn(
514 |         "pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground",
515 |         "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
516 |         "peer-data-[size=sm]/menu-button:top-1",
517 |         "peer-data-[size=default]/menu-button:top-1.5",
518 |         "peer-data-[size=lg]/menu-button:top-2.5",
519 |         "group-data-[collapsible=icon]:hidden",
520 |         className,
521 |       )}
522 |       {...props}
523 |     />
524 |   ),
525 | );
526 | SidebarMenuBadge.displayName = "SidebarMenuBadge";
527 | 
528 | const SidebarMenuSkeleton = React.forwardRef<
529 |   HTMLDivElement,
530 |   React.ComponentProps<"div"> & {
531 |     showIcon?: boolean;
532 |   }
533 | >(({ className, showIcon = false, ...props }, ref) => {
534 |   // Random width between 50 to 90%.
535 |   const width = React.useMemo(() => {
536 |     return `${Math.floor(Math.random() * 40) + 50}%`;
537 |   }, []);
538 | 
539 |   return (
540 |     <div
541 |       ref={ref}
542 |       data-sidebar="menu-skeleton"
543 |       className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
544 |       {...props}
545 |     >
546 |       {showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
547 |       <Skeleton
548 |         className="h-4 max-w-[--skeleton-width] flex-1"
549 |         data-sidebar="menu-skeleton-text"
550 |         style={
551 |           {
552 |             "--skeleton-width": width,
553 |           } as React.CSSProperties
554 |         }
555 |       />
556 |     </div>
557 |   );
558 | });
559 | SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
560 | 
561 | const SidebarMenuSub = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(
562 |   ({ className, ...props }, ref) => (
563 |     <ul
564 |       ref={ref}
565 |       data-sidebar="menu-sub"
566 |       className={cn(
567 |         "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
568 |         "group-data-[collapsible=icon]:hidden",
569 |         className,
570 |       )}
571 |       {...props}
572 |     />
573 |   ),
574 | );
575 | SidebarMenuSub.displayName = "SidebarMenuSub";
576 | 
577 | const SidebarMenuSubItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ ...props }, ref) => (
578 |   <li ref={ref} {...props} />
579 | ));
580 | SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
581 | 
582 | const SidebarMenuSubButton = React.forwardRef<
583 |   HTMLAnchorElement,
584 |   React.ComponentProps<"a"> & {
585 |     asChild?: boolean;
586 |     size?: "sm" | "md";
587 |     isActive?: boolean;
588 |   }
589 | >(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
590 |   const Comp = asChild ? Slot : "a";
591 | 
592 |   return (
593 |     <Comp
594 |       ref={ref}
595 |       data-sidebar="menu-sub-button"
596 |       data-size={size}
597 |       data-active={isActive}
598 |       className={cn(
599 |         "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
600 |         "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
601 |         size === "sm" && "text-xs",
602 |         size === "md" && "text-sm",
603 |         "group-data-[collapsible=icon]:hidden",
604 |         className,
605 |       )}
606 |       {...props}
607 |     />
608 |   );
609 | });
610 | SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
611 | 
612 | export {
613 |   Sidebar,
614 |   SidebarContent,
615 |   SidebarFooter,
616 |   SidebarGroup,
617 |   SidebarGroupAction,
618 |   SidebarGroupContent,
619 |   SidebarGroupLabel,
620 |   SidebarHeader,
621 |   SidebarInput,
622 |   SidebarInset,
623 |   SidebarMenu,
624 |   SidebarMenuAction,
625 |   SidebarMenuBadge,
626 |   SidebarMenuButton,
627 |   SidebarMenuItem,
628 |   SidebarMenuSkeleton,
629 |   SidebarMenuSub,
630 |   SidebarMenuSubButton,
631 |   SidebarMenuSubItem,
632 |   SidebarProvider,
633 |   SidebarRail,
634 |   SidebarSeparator,
635 |   SidebarTrigger,
636 |   useSidebar,
637 | };
638 | 
```

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

```html
  1 | 
  2 | <!doctype html>
  3 | <html lang="en" class="no-js">
  4 |   <head>
  5 |     
  6 |       <meta charset="utf-8">
  7 |       <meta name="viewport" content="width=device-width,initial-scale=1">
  8 |       
  9 |       
 10 |       
 11 |       
 12 |         <link rel="prev" href="../contributing_languages/">
 13 |       
 14 |       
 15 |         <link rel="next" href="../future_work/">
 16 |       
 17 |       
 18 |       <link rel="icon" href="../assets/images/favicon.png">
 19 |       <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.21">
 20 |     
 21 |     
 22 |       
 23 |         <title>Troubleshooting - CodeGraphContext</title>
 24 |       
 25 |     
 26 |     
 27 |       <link rel="stylesheet" href="../assets/stylesheets/main.2a3383ac.min.css">
 28 |       
 29 |       
 30 | 
 31 | 
 32 |     
 33 |     
 34 |       
 35 |     
 36 |     
 37 |       
 38 |         
 39 |         
 40 |         <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
 41 |         <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">
 42 |         <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
 43 |       
 44 |     
 45 |     
 46 |     <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>
 47 |     
 48 |       
 49 | 
 50 |     
 51 |     
 52 |     
 53 |   </head>
 54 |   
 55 |   
 56 |     <body dir="ltr">
 57 |   
 58 |     
 59 |     <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
 60 |     <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
 61 |     <label class="md-overlay" for="__drawer"></label>
 62 |     <div data-md-component="skip">
 63 |       
 64 |         
 65 |         <a href="#codegraphcontext-troubleshooting-guide" class="md-skip">
 66 |           Skip to content
 67 |         </a>
 68 |       
 69 |     </div>
 70 |     <div data-md-component="announce">
 71 |       
 72 |     </div>
 73 |     
 74 |     
 75 |       
 76 | 
 77 |   
 78 | 
 79 | <header class="md-header md-header--shadow" data-md-component="header">
 80 |   <nav class="md-header__inner md-grid" aria-label="Header">
 81 |     <a href=".." title="CodeGraphContext" class="md-header__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
 82 |       
 83 |   
 84 |   <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>
 85 | 
 86 |     </a>
 87 |     <label class="md-header__button md-icon" for="__drawer">
 88 |       
 89 |       <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
 90 |     </label>
 91 |     <div class="md-header__title" data-md-component="header-title">
 92 |       <div class="md-header__ellipsis">
 93 |         <div class="md-header__topic">
 94 |           <span class="md-ellipsis">
 95 |             CodeGraphContext
 96 |           </span>
 97 |         </div>
 98 |         <div class="md-header__topic" data-md-component="header-topic">
 99 |           <span class="md-ellipsis">
100 |             
101 |               Troubleshooting
102 |             
103 |           </span>
104 |         </div>
105 |       </div>
106 |     </div>
107 |     
108 |     
109 |       <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>
110 |     
111 |     
112 |     
113 |       
114 |       
115 |         <label class="md-header__button md-icon" for="__search">
116 |           
117 |           <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>
118 |         </label>
119 |         <div class="md-search" data-md-component="search" role="dialog">
120 |   <label class="md-search__overlay" for="__search"></label>
121 |   <div class="md-search__inner" role="search">
122 |     <form class="md-search__form" name="search">
123 |       <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>
124 |       <label class="md-search__icon md-icon" for="__search">
125 |         
126 |         <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>
127 |         
128 |         <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>
129 |       </label>
130 |       <nav class="md-search__options" aria-label="Search">
131 |         
132 |         <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
133 |           
134 |           <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>
135 |         </button>
136 |       </nav>
137 |       
138 |     </form>
139 |     <div class="md-search__output">
140 |       <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
141 |         <div class="md-search-result" data-md-component="search-result">
142 |           <div class="md-search-result__meta">
143 |             Initializing search
144 |           </div>
145 |           <ol class="md-search-result__list" role="presentation"></ol>
146 |         </div>
147 |       </div>
148 |     </div>
149 |   </div>
150 | </div>
151 |       
152 |     
153 |     
154 |   </nav>
155 |   
156 | </header>
157 |     
158 |     <div class="md-container" data-md-component="container">
159 |       
160 |       
161 |         
162 |           
163 |         
164 |       
165 |       <main class="md-main" data-md-component="main">
166 |         <div class="md-main__inner md-grid">
167 |           
168 |             
169 |               
170 |               <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
171 |                 <div class="md-sidebar__scrollwrap">
172 |                   <div class="md-sidebar__inner">
173 |                     
174 | 
175 | 
176 | 
177 | <nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
178 |   <label class="md-nav__title" for="__drawer">
179 |     <a href=".." title="CodeGraphContext" class="md-nav__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
180 |       
181 |   
182 |   <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>
183 | 
184 |     </a>
185 |     CodeGraphContext
186 |   </label>
187 |   
188 |   <ul class="md-nav__list" data-md-scrollfix>
189 |     
190 |       
191 |       
192 |   
193 |   
194 |   
195 |   
196 |     <li class="md-nav__item">
197 |       <a href=".." class="md-nav__link">
198 |         
199 |   
200 |   
201 |   <span class="md-ellipsis">
202 |     Home
203 |     
204 |   </span>
205 |   
206 | 
207 |       </a>
208 |     </li>
209 |   
210 | 
211 |     
212 |       
213 |       
214 |   
215 |   
216 |   
217 |   
218 |     <li class="md-nav__item">
219 |       <a href="../installation/" class="md-nav__link">
220 |         
221 |   
222 |   
223 |   <span class="md-ellipsis">
224 |     Installation
225 |     
226 |   </span>
227 |   
228 | 
229 |       </a>
230 |     </li>
231 |   
232 | 
233 |     
234 |       
235 |       
236 |   
237 |   
238 |   
239 |   
240 |     <li class="md-nav__item">
241 |       <a href="../use_cases/" class="md-nav__link">
242 |         
243 |   
244 |   
245 |   <span class="md-ellipsis">
246 |     Use Cases
247 |     
248 |   </span>
249 |   
250 | 
251 |       </a>
252 |     </li>
253 |   
254 | 
255 |     
256 |       
257 |       
258 |   
259 |   
260 |   
261 |   
262 |     <li class="md-nav__item">
263 |       <a href="../architecture/" class="md-nav__link">
264 |         
265 |   
266 |   
267 |   <span class="md-ellipsis">
268 |     Architecture
269 |     
270 |   </span>
271 |   
272 | 
273 |       </a>
274 |     </li>
275 |   
276 | 
277 |     
278 |       
279 |       
280 |   
281 |   
282 |   
283 |   
284 |     <li class="md-nav__item">
285 |       <a href="../cli/" class="md-nav__link">
286 |         
287 |   
288 |   
289 |   <span class="md-ellipsis">
290 |     CLI Reference
291 |     
292 |   </span>
293 |   
294 | 
295 |       </a>
296 |     </li>
297 |   
298 | 
299 |     
300 |       
301 |       
302 |   
303 |   
304 |   
305 |   
306 |     <li class="md-nav__item">
307 |       <a href="../server/" class="md-nav__link">
308 |         
309 |   
310 |   
311 |   <span class="md-ellipsis">
312 |     Server
313 |     
314 |   </span>
315 |   
316 | 
317 |       </a>
318 |     </li>
319 |   
320 | 
321 |     
322 |       
323 |       
324 |   
325 |   
326 |   
327 |   
328 |     <li class="md-nav__item">
329 |       <a href="../core/" class="md-nav__link">
330 |         
331 |   
332 |   
333 |   <span class="md-ellipsis">
334 |     Core Concepts
335 |     
336 |   </span>
337 |   
338 | 
339 |       </a>
340 |     </li>
341 |   
342 | 
343 |     
344 |       
345 |       
346 |   
347 |   
348 |   
349 |   
350 |     <li class="md-nav__item">
351 |       <a href="../tools/" class="md-nav__link">
352 |         
353 |   
354 |   
355 |   <span class="md-ellipsis">
356 |     Tools
357 |     
358 |   </span>
359 |   
360 | 
361 |       </a>
362 |     </li>
363 |   
364 | 
365 |     
366 |       
367 |       
368 |   
369 |   
370 |   
371 |   
372 |     <li class="md-nav__item">
373 |       <a href="../cookbook/" class="md-nav__link">
374 |         
375 |   
376 |   
377 |   <span class="md-ellipsis">
378 |     Cookbook
379 |     
380 |   </span>
381 |   
382 | 
383 |       </a>
384 |     </li>
385 |   
386 | 
387 |     
388 |       
389 |       
390 |   
391 |   
392 |   
393 |   
394 |     
395 |     
396 |     
397 |     
398 |     
399 |     <li class="md-nav__item md-nav__item--nested">
400 |       
401 |         
402 |         
403 |         <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_10" >
404 |         
405 |           
406 |           <label class="md-nav__link" for="__nav_10" id="__nav_10_label" tabindex="0">
407 |             
408 |   
409 |   
410 |   <span class="md-ellipsis">
411 |     Contributing
412 |     
413 |   </span>
414 |   
415 | 
416 |             <span class="md-nav__icon md-icon"></span>
417 |           </label>
418 |         
419 |         <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_10_label" aria-expanded="false">
420 |           <label class="md-nav__title" for="__nav_10">
421 |             <span class="md-nav__icon md-icon"></span>
422 |             Contributing
423 |           </label>
424 |           <ul class="md-nav__list" data-md-scrollfix>
425 |             
426 |               
427 |                 
428 |   
429 |   
430 |   
431 |   
432 |     <li class="md-nav__item">
433 |       <a href="../contributing/" class="md-nav__link">
434 |         
435 |   
436 |   
437 |   <span class="md-ellipsis">
438 |     Overview
439 |     
440 |   </span>
441 |   
442 | 
443 |       </a>
444 |     </li>
445 |   
446 | 
447 |               
448 |             
449 |               
450 |                 
451 |   
452 |   
453 |   
454 |   
455 |     <li class="md-nav__item">
456 |       <a href="../contributing_languages/" class="md-nav__link">
457 |         
458 |   
459 |   
460 |   <span class="md-ellipsis">
461 |     Adding New Languages
462 |     
463 |   </span>
464 |   
465 | 
466 |       </a>
467 |     </li>
468 |   
469 | 
470 |               
471 |             
472 |           </ul>
473 |         </nav>
474 |       
475 |     </li>
476 |   
477 | 
478 |     
479 |       
480 |       
481 |   
482 |   
483 |     
484 |   
485 |   
486 |   
487 |     <li class="md-nav__item md-nav__item--active">
488 |       
489 |       <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
490 |       
491 |       
492 |         
493 |       
494 |       
495 |         <label class="md-nav__link md-nav__link--active" for="__toc">
496 |           
497 |   
498 |   
499 |   <span class="md-ellipsis">
500 |     Troubleshooting
501 |     
502 |   </span>
503 |   
504 | 
505 |           <span class="md-nav__icon md-icon"></span>
506 |         </label>
507 |       
508 |       <a href="./" class="md-nav__link md-nav__link--active">
509 |         
510 |   
511 |   
512 |   <span class="md-ellipsis">
513 |     Troubleshooting
514 |     
515 |   </span>
516 |   
517 | 
518 |       </a>
519 |       
520 |         
521 | 
522 | <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
523 |   
524 |   
525 |   
526 |     
527 |   
528 |   
529 |     <label class="md-nav__title" for="__toc">
530 |       <span class="md-nav__icon md-icon"></span>
531 |       Table of contents
532 |     </label>
533 |     <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
534 |       
535 |         <li class="md-nav__item">
536 |   <a href="#1-prerequisites-at-a-glance" class="md-nav__link">
537 |     <span class="md-ellipsis">
538 |       1. Prerequisites at a glance
539 |     </span>
540 |   </a>
541 |   
542 | </li>
543 |       
544 |         <li class="md-nav__item">
545 |   <a href="#2-create-and-activate-a-virtual-environment" class="md-nav__link">
546 |     <span class="md-ellipsis">
547 |       2. Create and activate a virtual environment
548 |     </span>
549 |   </a>
550 |   
551 | </li>
552 |       
553 |         <li class="md-nav__item">
554 |   <a href="#3-run-the-setup-wizard-preferred" class="md-nav__link">
555 |     <span class="md-ellipsis">
556 |       3. Run the setup wizard (preferred)
557 |     </span>
558 |   </a>
559 |   
560 | </li>
561 |       
562 |         <li class="md-nav__item">
563 |   <a href="#4-start-the-mcp-server" class="md-nav__link">
564 |     <span class="md-ellipsis">
565 |       4. Start the MCP server
566 |     </span>
567 |   </a>
568 |   
569 | </li>
570 |       
571 |         <li class="md-nav__item">
572 |   <a href="#5-manual-credential-setup-fallback" class="md-nav__link">
573 |     <span class="md-ellipsis">
574 |       5. Manual credential setup (fallback)
575 |     </span>
576 |   </a>
577 |   
578 | </li>
579 |       
580 |         <li class="md-nav__item">
581 |   <a href="#6-common-issues-fixes" class="md-nav__link">
582 |     <span class="md-ellipsis">
583 |       6. Common issues &amp; fixes
584 |     </span>
585 |   </a>
586 |   
587 | </li>
588 |       
589 |         <li class="md-nav__item">
590 |   <a href="#7-after-the-server-is-running" class="md-nav__link">
591 |     <span class="md-ellipsis">
592 |       7. After the server is running
593 |     </span>
594 |   </a>
595 |   
596 | </li>
597 |       
598 |     </ul>
599 |   
600 | </nav>
601 |       
602 |     </li>
603 |   
604 | 
605 |     
606 |       
607 |       
608 |   
609 |   
610 |   
611 |   
612 |     <li class="md-nav__item">
613 |       <a href="../future_work/" class="md-nav__link">
614 |         
615 |   
616 |   
617 |   <span class="md-ellipsis">
618 |     Future Work
619 |     
620 |   </span>
621 |   
622 | 
623 |       </a>
624 |     </li>
625 |   
626 | 
627 |     
628 |       
629 |       
630 |   
631 |   
632 |   
633 |   
634 |     <li class="md-nav__item">
635 |       <a href="../license/" class="md-nav__link">
636 |         
637 |   
638 |   
639 |   <span class="md-ellipsis">
640 |     License
641 |     
642 |   </span>
643 |   
644 | 
645 |       </a>
646 |     </li>
647 |   
648 | 
649 |     
650 |   </ul>
651 | </nav>
652 |                   </div>
653 |                 </div>
654 |               </div>
655 |             
656 |             
657 |               
658 |               <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
659 |                 <div class="md-sidebar__scrollwrap">
660 |                   <div class="md-sidebar__inner">
661 |                     
662 | 
663 | <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
664 |   
665 |   
666 |   
667 |     
668 |   
669 |   
670 |     <label class="md-nav__title" for="__toc">
671 |       <span class="md-nav__icon md-icon"></span>
672 |       Table of contents
673 |     </label>
674 |     <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
675 |       
676 |         <li class="md-nav__item">
677 |   <a href="#1-prerequisites-at-a-glance" class="md-nav__link">
678 |     <span class="md-ellipsis">
679 |       1. Prerequisites at a glance
680 |     </span>
681 |   </a>
682 |   
683 | </li>
684 |       
685 |         <li class="md-nav__item">
686 |   <a href="#2-create-and-activate-a-virtual-environment" class="md-nav__link">
687 |     <span class="md-ellipsis">
688 |       2. Create and activate a virtual environment
689 |     </span>
690 |   </a>
691 |   
692 | </li>
693 |       
694 |         <li class="md-nav__item">
695 |   <a href="#3-run-the-setup-wizard-preferred" class="md-nav__link">
696 |     <span class="md-ellipsis">
697 |       3. Run the setup wizard (preferred)
698 |     </span>
699 |   </a>
700 |   
701 | </li>
702 |       
703 |         <li class="md-nav__item">
704 |   <a href="#4-start-the-mcp-server" class="md-nav__link">
705 |     <span class="md-ellipsis">
706 |       4. Start the MCP server
707 |     </span>
708 |   </a>
709 |   
710 | </li>
711 |       
712 |         <li class="md-nav__item">
713 |   <a href="#5-manual-credential-setup-fallback" class="md-nav__link">
714 |     <span class="md-ellipsis">
715 |       5. Manual credential setup (fallback)
716 |     </span>
717 |   </a>
718 |   
719 | </li>
720 |       
721 |         <li class="md-nav__item">
722 |   <a href="#6-common-issues-fixes" class="md-nav__link">
723 |     <span class="md-ellipsis">
724 |       6. Common issues &amp; fixes
725 |     </span>
726 |   </a>
727 |   
728 | </li>
729 |       
730 |         <li class="md-nav__item">
731 |   <a href="#7-after-the-server-is-running" class="md-nav__link">
732 |     <span class="md-ellipsis">
733 |       7. After the server is running
734 |     </span>
735 |   </a>
736 |   
737 | </li>
738 |       
739 |     </ul>
740 |   
741 | </nav>
742 |                   </div>
743 |                 </div>
744 |               </div>
745 |             
746 |           
747 |           
748 |             <div class="md-content" data-md-component="content">
749 |               <article class="md-content__inner md-typeset">
750 |                 
751 |                   
752 | 
753 | 
754 | 
755 | <h1 id="codegraphcontext-troubleshooting-guide">CodeGraphContext Troubleshooting Guide</h1>
756 | <p>Use this checklist whenever <code>cgc setup</code> or <code>cgc start</code> doesn’t behave as expected. It keeps the happy path short, but includes the fallback steps when something goes wrong.</p>
757 | <h2 id="1-prerequisites-at-a-glance">1. Prerequisites at a glance</h2>
758 | <ul>
759 | <li><strong>Windows + PowerShell</strong> commands below assume the <code>py</code> launcher. Adapt to <code>python3</code> if you’re on macOS/Linux.</li>
760 | <li><strong>Python 3.11</strong> (recommended). Run <code>py -3.11 --version</code> to confirm.</li>
761 | <li><strong>Neo4j account</strong> (only required if you prefer Neo4j AuraDB instead of Docker).</li>
762 | </ul>
763 | <h2 id="2-create-and-activate-a-virtual-environment">2. Create and activate a virtual environment</h2>
764 | <p>From the repository root (<code>CodeGraphContext/</code>):</p>
765 | <pre><code class="language-powershell">py -3.11 -m venv venv
766 | .\venv\Scripts\python.exe -m pip install --upgrade pip
767 | </code></pre>
768 | <ul>
769 | <li>On Windows, Neo4j driver 6.x can crash with <code>AttributeError: socket.EAI_ADDRFAMILY</code>. If you see that, run:
770 |   <code>powershell
771 |   .\venv\Scripts\python.exe -m pip install "neo4j&lt;6"</code></li>
772 | </ul>
773 | <h2 id="3-run-the-setup-wizard-preferred">3. Run the setup wizard (preferred)</h2>
774 | <p>Launch the wizard:</p>
775 | <pre><code class="language-powershell">.\venv\Scripts\cgc.exe setup
776 | </code></pre>
777 | <blockquote>
778 | <p><strong>Tip:</strong> If you want the wizard to spin up a local Neo4j instance for you, make sure <strong>Docker Desktop</strong> is installed and running before you launch <code>cgc setup</code>. If Docker isn’t running, the setup wizard will fail when it tries to install Neo4j locally.</p>
779 | </blockquote>
780 | <p>What happens next:</p>
781 | <ul>
782 | <li>The wizard checks for Docker. If it’s running, it can auto-provision a local Neo4j instance for you.</li>
783 | <li>Alternatively, you can supply credentials for an existing Neo4j AuraDB database.</li>
784 | <li>At the end, it generates:</li>
785 | <li><code>mcp.json</code> in your project directory (stores the MCP server command + env vars).</li>
786 | <li><code>~/.codegraphcontext/.env</code> containing <code>NEO4J_URI</code>, <code>NEO4J_USERNAME</code>, <code>NEO4J_PASSWORD</code>.</li>
787 | </ul>
788 | <p>Make sure the Docker container (or remote Neo4j) is still running before you start the server.</p>
789 | <h2 id="4-start-the-mcp-server">4. Start the MCP server</h2>
790 | <p>Once the wizard completes successfully:</p>
791 | <pre><code class="language-powershell">.\venv\Scripts\cgc.exe start
792 | </code></pre>
793 | <p>Expected output includes:</p>
794 | <pre><code class="language-text">Starting CodeGraphContext Server...
795 | ...
796 | MCP Server is running. Waiting for requests...
797 | </code></pre>
798 | <p>If you instead see:</p>
799 | <pre><code class="language-text">Configuration Error: Neo4j credentials must be set via environment variables
800 | </code></pre>
801 | <p>then either no credentials were saved, or the wizard was skipped—see the manual alternative below.</p>
802 | <h2 id="5-manual-credential-setup-fallback">5. Manual credential setup (fallback)</h2>
803 | <p>If you prefer not to use the wizard or need to fix a broken configuration:</p>
804 | <ol>
805 | <li>Create a <code>mcp.json</code> (or edit the one that exists) in the repository root:</li>
806 | </ol>
807 | <p><code>json
808 |    {
809 |      "mcpServers": {
810 |        "CodeGraphContext": {
811 |          "command": "cgc",
812 |          "args": ["start"],
813 |          "env": {
814 |            "NEO4J_URI": "neo4j+s://YOUR-HOSTNAME:7687",
815 |            "NEO4J_USERNAME": "neo4j",
816 |            "NEO4J_PASSWORD": "super-secret-password"
817 |          }
818 |        }
819 |      }
820 |    }</code></p>
821 | <ol>
822 | <li>
823 | <p>(Optional) Also create <code>%USERPROFILE%\.codegraphcontext\.env</code> with the same key/value pairs. The CLI loads that file automatically.</p>
824 | </li>
825 | <li>
826 | <p>Re-run:</p>
827 | </li>
828 | </ol>
829 | <p><code>powershell
830 |    .\venv\Scripts\cgc.exe start</code></p>
831 | <h2 id="6-common-issues-fixes">6. Common issues &amp; fixes</h2>
832 | <table>
833 | <thead>
834 | <tr>
835 | <th>Symptom</th>
836 | <th>Likely Cause</th>
837 | <th>Fix</th>
838 | </tr>
839 | </thead>
840 | <tbody>
841 | <tr>
842 | <td><code>Configuration Error: Neo4j credentials must be set…</code></td>
843 | <td><code>mcp.json</code>/<code>.env</code> missing or empty</td>
844 | <td>Run <code>cgc setup</code> again <strong>with Docker running</strong>, or create the files manually (section 5).</td>
845 | </tr>
846 | <tr>
847 | <td><code>AttributeError: socket.EAI_ADDRFAMILY</code></td>
848 | <td>Neo4j 6.x bug on Windows</td>
849 | <td>Install the 5.x driver: <code>.\venv\Scripts\python.exe -m pip install "neo4j&lt;6"</code> and retry.</td>
850 | </tr>
851 | <tr>
852 | <td>Setup wizard fails while pulling Docker image</td>
853 | <td>Docker Desktop not running or Docker permissions missing</td>
854 | <td>Start Docker Desktop, wait for it to report “Running”, then rerun <code>cgc setup</code>.</td>
855 | </tr>
856 | <tr>
857 | <td>Server exits immediately with no log</td>
858 | <td>Neo4j instance is offline</td>
859 | <td>Check Docker container status or AuraDB dashboard; restart Neo4j and call <code>cgc start</code> again.</td>
860 | </tr>
861 | </tbody>
862 | </table>
863 | <h2 id="7-after-the-server-is-running">7. After the server is running</h2>
864 | <ul>
865 | <li>Keep the virtual environment active whenever you run <code>cgc</code> commands.</li>
866 | <li>Use <code>pytest</code> from the same env to run tests:</li>
867 | </ul>
868 | <p><code>powershell
869 |   .\venv\Scripts\pytest</code></p>
870 | <ul>
871 | <li>Front-end website lives under <code>website/</code> if you need to run <code>npm run dev</code>.</li>
872 | </ul>
873 | <p>When in doubt, re-run the wizard with Docker active—it regenerates the configuration files without touching your code. Let me know if any section needs clarifying! :)</p>
874 | 
875 | 
876 | 
877 | 
878 | 
879 | 
880 | 
881 | 
882 | 
883 | 
884 | 
885 | 
886 |                 
887 |               </article>
888 |             </div>
889 |           
890 |           
891 | <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
892 |         </div>
893 |         
894 |       </main>
895 |       
896 |         <footer class="md-footer">
897 |   
898 |   <div class="md-footer-meta md-typeset">
899 |     <div class="md-footer-meta__inner md-grid">
900 |       <div class="md-copyright">
901 |   
902 |   
903 |     Made with
904 |     <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
905 |       Material for MkDocs
906 |     </a>
907 |   
908 | </div>
909 |       
910 |     </div>
911 |   </div>
912 | </footer>
913 |       
914 |     </div>
915 |     <div class="md-dialog" data-md-component="dialog">
916 |       <div class="md-dialog__inner md-typeset"></div>
917 |     </div>
918 |     
919 |     
920 |     
921 |       
922 |       <script id="__config" type="application/json">{"base": "..", "features": [], "search": "../assets/javascripts/workers/search.973d3a69.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>
923 |     
924 |     
925 |       <script src="../assets/javascripts/bundle.f55a23d4.min.js"></script>
926 |       
927 |     
928 |   </body>
929 | </html>
```

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

```html
  1 | 
  2 | <!doctype html>
  3 | <html lang="en" class="no-js">
  4 |   <head>
  5 |     
  6 |       <meta charset="utf-8">
  7 |       <meta name="viewport" content="width=device-width,initial-scale=1">
  8 |       
  9 |       
 10 |       
 11 |       
 12 |         <link rel="prev" href="../architecture/">
 13 |       
 14 |       
 15 |         <link rel="next" href="../server/">
 16 |       
 17 |       
 18 |       <link rel="icon" href="../assets/images/favicon.png">
 19 |       <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.21">
 20 |     
 21 |     
 22 |       
 23 |         <title>CLI Reference - CodeGraphContext</title>
 24 |       
 25 |     
 26 |     
 27 |       <link rel="stylesheet" href="../assets/stylesheets/main.2a3383ac.min.css">
 28 |       
 29 |       
 30 | 
 31 | 
 32 |     
 33 |     
 34 |       
 35 |     
 36 |     
 37 |       
 38 |         
 39 |         
 40 |         <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
 41 |         <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">
 42 |         <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
 43 |       
 44 |     
 45 |     
 46 |     <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>
 47 |     
 48 |       
 49 | 
 50 |     
 51 |     
 52 |     
 53 |   </head>
 54 |   
 55 |   
 56 |     <body dir="ltr">
 57 |   
 58 |     
 59 |     <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
 60 |     <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
 61 |     <label class="md-overlay" for="__drawer"></label>
 62 |     <div data-md-component="skip">
 63 |       
 64 |         
 65 |         <a href="#cli-reference" class="md-skip">
 66 |           Skip to content
 67 |         </a>
 68 |       
 69 |     </div>
 70 |     <div data-md-component="announce">
 71 |       
 72 |     </div>
 73 |     
 74 |     
 75 |       
 76 | 
 77 |   
 78 | 
 79 | <header class="md-header md-header--shadow" data-md-component="header">
 80 |   <nav class="md-header__inner md-grid" aria-label="Header">
 81 |     <a href=".." title="CodeGraphContext" class="md-header__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
 82 |       
 83 |   
 84 |   <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>
 85 | 
 86 |     </a>
 87 |     <label class="md-header__button md-icon" for="__drawer">
 88 |       
 89 |       <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
 90 |     </label>
 91 |     <div class="md-header__title" data-md-component="header-title">
 92 |       <div class="md-header__ellipsis">
 93 |         <div class="md-header__topic">
 94 |           <span class="md-ellipsis">
 95 |             CodeGraphContext
 96 |           </span>
 97 |         </div>
 98 |         <div class="md-header__topic" data-md-component="header-topic">
 99 |           <span class="md-ellipsis">
100 |             
101 |               CLI Reference
102 |             
103 |           </span>
104 |         </div>
105 |       </div>
106 |     </div>
107 |     
108 |     
109 |       <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>
110 |     
111 |     
112 |     
113 |       
114 |       
115 |         <label class="md-header__button md-icon" for="__search">
116 |           
117 |           <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>
118 |         </label>
119 |         <div class="md-search" data-md-component="search" role="dialog">
120 |   <label class="md-search__overlay" for="__search"></label>
121 |   <div class="md-search__inner" role="search">
122 |     <form class="md-search__form" name="search">
123 |       <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>
124 |       <label class="md-search__icon md-icon" for="__search">
125 |         
126 |         <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>
127 |         
128 |         <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>
129 |       </label>
130 |       <nav class="md-search__options" aria-label="Search">
131 |         
132 |         <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
133 |           
134 |           <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>
135 |         </button>
136 |       </nav>
137 |       
138 |     </form>
139 |     <div class="md-search__output">
140 |       <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
141 |         <div class="md-search-result" data-md-component="search-result">
142 |           <div class="md-search-result__meta">
143 |             Initializing search
144 |           </div>
145 |           <ol class="md-search-result__list" role="presentation"></ol>
146 |         </div>
147 |       </div>
148 |     </div>
149 |   </div>
150 | </div>
151 |       
152 |     
153 |     
154 |   </nav>
155 |   
156 | </header>
157 |     
158 |     <div class="md-container" data-md-component="container">
159 |       
160 |       
161 |         
162 |           
163 |         
164 |       
165 |       <main class="md-main" data-md-component="main">
166 |         <div class="md-main__inner md-grid">
167 |           
168 |             
169 |               
170 |               <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
171 |                 <div class="md-sidebar__scrollwrap">
172 |                   <div class="md-sidebar__inner">
173 |                     
174 | 
175 | 
176 | 
177 | <nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
178 |   <label class="md-nav__title" for="__drawer">
179 |     <a href=".." title="CodeGraphContext" class="md-nav__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
180 |       
181 |   
182 |   <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>
183 | 
184 |     </a>
185 |     CodeGraphContext
186 |   </label>
187 |   
188 |   <ul class="md-nav__list" data-md-scrollfix>
189 |     
190 |       
191 |       
192 |   
193 |   
194 |   
195 |   
196 |     <li class="md-nav__item">
197 |       <a href=".." class="md-nav__link">
198 |         
199 |   
200 |   
201 |   <span class="md-ellipsis">
202 |     Home
203 |     
204 |   </span>
205 |   
206 | 
207 |       </a>
208 |     </li>
209 |   
210 | 
211 |     
212 |       
213 |       
214 |   
215 |   
216 |   
217 |   
218 |     <li class="md-nav__item">
219 |       <a href="../installation/" class="md-nav__link">
220 |         
221 |   
222 |   
223 |   <span class="md-ellipsis">
224 |     Installation
225 |     
226 |   </span>
227 |   
228 | 
229 |       </a>
230 |     </li>
231 |   
232 | 
233 |     
234 |       
235 |       
236 |   
237 |   
238 |   
239 |   
240 |     <li class="md-nav__item">
241 |       <a href="../use_cases/" class="md-nav__link">
242 |         
243 |   
244 |   
245 |   <span class="md-ellipsis">
246 |     Use Cases
247 |     
248 |   </span>
249 |   
250 | 
251 |       </a>
252 |     </li>
253 |   
254 | 
255 |     
256 |       
257 |       
258 |   
259 |   
260 |   
261 |   
262 |     <li class="md-nav__item">
263 |       <a href="../architecture/" class="md-nav__link">
264 |         
265 |   
266 |   
267 |   <span class="md-ellipsis">
268 |     Architecture
269 |     
270 |   </span>
271 |   
272 | 
273 |       </a>
274 |     </li>
275 |   
276 | 
277 |     
278 |       
279 |       
280 |   
281 |   
282 |     
283 |   
284 |   
285 |   
286 |     <li class="md-nav__item md-nav__item--active">
287 |       
288 |       <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
289 |       
290 |       
291 |         
292 |       
293 |       
294 |         <label class="md-nav__link md-nav__link--active" for="__toc">
295 |           
296 |   
297 |   
298 |   <span class="md-ellipsis">
299 |     CLI Reference
300 |     
301 |   </span>
302 |   
303 | 
304 |           <span class="md-nav__icon md-icon"></span>
305 |         </label>
306 |       
307 |       <a href="./" class="md-nav__link md-nav__link--active">
308 |         
309 |   
310 |   
311 |   <span class="md-ellipsis">
312 |     CLI Reference
313 |     
314 |   </span>
315 |   
316 | 
317 |       </a>
318 |       
319 |         
320 | 
321 | <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
322 |   
323 |   
324 |   
325 |     
326 |   
327 |   
328 |     <label class="md-nav__title" for="__toc">
329 |       <span class="md-nav__icon md-icon"></span>
330 |       Table of contents
331 |     </label>
332 |     <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
333 |       
334 |         <li class="md-nav__item">
335 |   <a href="#cgc-setup" class="md-nav__link">
336 |     <span class="md-ellipsis">
337 |       cgc setup
338 |     </span>
339 |   </a>
340 |   
341 | </li>
342 |       
343 |         <li class="md-nav__item">
344 |   <a href="#cgc-start" class="md-nav__link">
345 |     <span class="md-ellipsis">
346 |       cgc start
347 |     </span>
348 |   </a>
349 |   
350 | </li>
351 |       
352 |         <li class="md-nav__item">
353 |   <a href="#cgc-index-path" class="md-nav__link">
354 |     <span class="md-ellipsis">
355 |       cgc index [PATH]
356 |     </span>
357 |   </a>
358 |   
359 |     <nav class="md-nav" aria-label="cgc index [PATH]">
360 |       <ul class="md-nav__list">
361 |         
362 |           <li class="md-nav__item">
363 |   <a href="#ignoring-files-cgcignore" class="md-nav__link">
364 |     <span class="md-ellipsis">
365 |       Ignoring Files (.cgcignore)
366 |     </span>
367 |   </a>
368 |   
369 | </li>
370 |         
371 |       </ul>
372 |     </nav>
373 |   
374 | </li>
375 |       
376 |         <li class="md-nav__item">
377 |   <a href="#cgc-delete-path" class="md-nav__link">
378 |     <span class="md-ellipsis">
379 |       cgc delete &lt;PATH&gt;
380 |     </span>
381 |   </a>
382 |   
383 | </li>
384 |       
385 |         <li class="md-nav__item">
386 |   <a href="#cgc-visualize-query" class="md-nav__link">
387 |     <span class="md-ellipsis">
388 |       cgc visualize [QUERY]
389 |     </span>
390 |   </a>
391 |   
392 | </li>
393 |       
394 |         <li class="md-nav__item">
395 |   <a href="#cgc-list_repos" class="md-nav__link">
396 |     <span class="md-ellipsis">
397 |       cgc list_repos
398 |     </span>
399 |   </a>
400 |   
401 | </li>
402 |       
403 |         <li class="md-nav__item">
404 |   <a href="#cgc-add_package-package_name" class="md-nav__link">
405 |     <span class="md-ellipsis">
406 |       cgc add_package &lt;PACKAGE_NAME&gt;
407 |     </span>
408 |   </a>
409 |   
410 | </li>
411 |       
412 |         <li class="md-nav__item">
413 |   <a href="#cgc-cypher-query" class="md-nav__link">
414 |     <span class="md-ellipsis">
415 |       cgc cypher &lt;QUERY&gt;
416 |     </span>
417 |   </a>
418 |   
419 | </li>
420 |       
421 |         <li class="md-nav__item">
422 |   <a href="#cgc-list_mcp_tools" class="md-nav__link">
423 |     <span class="md-ellipsis">
424 |       cgc list_mcp_tools
425 |     </span>
426 |   </a>
427 |   
428 | </li>
429 |       
430 |         <li class="md-nav__item">
431 |   <a href="#cgc-help" class="md-nav__link">
432 |     <span class="md-ellipsis">
433 |       cgc help
434 |     </span>
435 |   </a>
436 |   
437 | </li>
438 |       
439 |         <li class="md-nav__item">
440 |   <a href="#cgc-version" class="md-nav__link">
441 |     <span class="md-ellipsis">
442 |       cgc version
443 |     </span>
444 |   </a>
445 |   
446 | </li>
447 |       
448 |     </ul>
449 |   
450 | </nav>
451 |       
452 |     </li>
453 |   
454 | 
455 |     
456 |       
457 |       
458 |   
459 |   
460 |   
461 |   
462 |     <li class="md-nav__item">
463 |       <a href="../server/" class="md-nav__link">
464 |         
465 |   
466 |   
467 |   <span class="md-ellipsis">
468 |     Server
469 |     
470 |   </span>
471 |   
472 | 
473 |       </a>
474 |     </li>
475 |   
476 | 
477 |     
478 |       
479 |       
480 |   
481 |   
482 |   
483 |   
484 |     <li class="md-nav__item">
485 |       <a href="../core/" class="md-nav__link">
486 |         
487 |   
488 |   
489 |   <span class="md-ellipsis">
490 |     Core Concepts
491 |     
492 |   </span>
493 |   
494 | 
495 |       </a>
496 |     </li>
497 |   
498 | 
499 |     
500 |       
501 |       
502 |   
503 |   
504 |   
505 |   
506 |     <li class="md-nav__item">
507 |       <a href="../tools/" class="md-nav__link">
508 |         
509 |   
510 |   
511 |   <span class="md-ellipsis">
512 |     Tools
513 |     
514 |   </span>
515 |   
516 | 
517 |       </a>
518 |     </li>
519 |   
520 | 
521 |     
522 |       
523 |       
524 |   
525 |   
526 |   
527 |   
528 |     <li class="md-nav__item">
529 |       <a href="../cookbook/" class="md-nav__link">
530 |         
531 |   
532 |   
533 |   <span class="md-ellipsis">
534 |     Cookbook
535 |     
536 |   </span>
537 |   
538 | 
539 |       </a>
540 |     </li>
541 |   
542 | 
543 |     
544 |       
545 |       
546 |   
547 |   
548 |   
549 |   
550 |     
551 |     
552 |     
553 |     
554 |     
555 |     <li class="md-nav__item md-nav__item--nested">
556 |       
557 |         
558 |         
559 |         <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_10" >
560 |         
561 |           
562 |           <label class="md-nav__link" for="__nav_10" id="__nav_10_label" tabindex="0">
563 |             
564 |   
565 |   
566 |   <span class="md-ellipsis">
567 |     Contributing
568 |     
569 |   </span>
570 |   
571 | 
572 |             <span class="md-nav__icon md-icon"></span>
573 |           </label>
574 |         
575 |         <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_10_label" aria-expanded="false">
576 |           <label class="md-nav__title" for="__nav_10">
577 |             <span class="md-nav__icon md-icon"></span>
578 |             Contributing
579 |           </label>
580 |           <ul class="md-nav__list" data-md-scrollfix>
581 |             
582 |               
583 |                 
584 |   
585 |   
586 |   
587 |   
588 |     <li class="md-nav__item">
589 |       <a href="../contributing/" class="md-nav__link">
590 |         
591 |   
592 |   
593 |   <span class="md-ellipsis">
594 |     Overview
595 |     
596 |   </span>
597 |   
598 | 
599 |       </a>
600 |     </li>
601 |   
602 | 
603 |               
604 |             
605 |               
606 |                 
607 |   
608 |   
609 |   
610 |   
611 |     <li class="md-nav__item">
612 |       <a href="../contributing_languages/" class="md-nav__link">
613 |         
614 |   
615 |   
616 |   <span class="md-ellipsis">
617 |     Adding New Languages
618 |     
619 |   </span>
620 |   
621 | 
622 |       </a>
623 |     </li>
624 |   
625 | 
626 |               
627 |             
628 |           </ul>
629 |         </nav>
630 |       
631 |     </li>
632 |   
633 | 
634 |     
635 |       
636 |       
637 |   
638 |   
639 |   
640 |   
641 |     <li class="md-nav__item">
642 |       <a href="../troubleshooting/" class="md-nav__link">
643 |         
644 |   
645 |   
646 |   <span class="md-ellipsis">
647 |     Troubleshooting
648 |     
649 |   </span>
650 |   
651 | 
652 |       </a>
653 |     </li>
654 |   
655 | 
656 |     
657 |       
658 |       
659 |   
660 |   
661 |   
662 |   
663 |     <li class="md-nav__item">
664 |       <a href="../future_work/" class="md-nav__link">
665 |         
666 |   
667 |   
668 |   <span class="md-ellipsis">
669 |     Future Work
670 |     
671 |   </span>
672 |   
673 | 
674 |       </a>
675 |     </li>
676 |   
677 | 
678 |     
679 |       
680 |       
681 |   
682 |   
683 |   
684 |   
685 |     <li class="md-nav__item">
686 |       <a href="../license/" class="md-nav__link">
687 |         
688 |   
689 |   
690 |   <span class="md-ellipsis">
691 |     License
692 |     
693 |   </span>
694 |   
695 | 
696 |       </a>
697 |     </li>
698 |   
699 | 
700 |     
701 |   </ul>
702 | </nav>
703 |                   </div>
704 |                 </div>
705 |               </div>
706 |             
707 |             
708 |               
709 |               <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
710 |                 <div class="md-sidebar__scrollwrap">
711 |                   <div class="md-sidebar__inner">
712 |                     
713 | 
714 | <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
715 |   
716 |   
717 |   
718 |     
719 |   
720 |   
721 |     <label class="md-nav__title" for="__toc">
722 |       <span class="md-nav__icon md-icon"></span>
723 |       Table of contents
724 |     </label>
725 |     <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
726 |       
727 |         <li class="md-nav__item">
728 |   <a href="#cgc-setup" class="md-nav__link">
729 |     <span class="md-ellipsis">
730 |       cgc setup
731 |     </span>
732 |   </a>
733 |   
734 | </li>
735 |       
736 |         <li class="md-nav__item">
737 |   <a href="#cgc-start" class="md-nav__link">
738 |     <span class="md-ellipsis">
739 |       cgc start
740 |     </span>
741 |   </a>
742 |   
743 | </li>
744 |       
745 |         <li class="md-nav__item">
746 |   <a href="#cgc-index-path" class="md-nav__link">
747 |     <span class="md-ellipsis">
748 |       cgc index [PATH]
749 |     </span>
750 |   </a>
751 |   
752 |     <nav class="md-nav" aria-label="cgc index [PATH]">
753 |       <ul class="md-nav__list">
754 |         
755 |           <li class="md-nav__item">
756 |   <a href="#ignoring-files-cgcignore" class="md-nav__link">
757 |     <span class="md-ellipsis">
758 |       Ignoring Files (.cgcignore)
759 |     </span>
760 |   </a>
761 |   
762 | </li>
763 |         
764 |       </ul>
765 |     </nav>
766 |   
767 | </li>
768 |       
769 |         <li class="md-nav__item">
770 |   <a href="#cgc-delete-path" class="md-nav__link">
771 |     <span class="md-ellipsis">
772 |       cgc delete &lt;PATH&gt;
773 |     </span>
774 |   </a>
775 |   
776 | </li>
777 |       
778 |         <li class="md-nav__item">
779 |   <a href="#cgc-visualize-query" class="md-nav__link">
780 |     <span class="md-ellipsis">
781 |       cgc visualize [QUERY]
782 |     </span>
783 |   </a>
784 |   
785 | </li>
786 |       
787 |         <li class="md-nav__item">
788 |   <a href="#cgc-list_repos" class="md-nav__link">
789 |     <span class="md-ellipsis">
790 |       cgc list_repos
791 |     </span>
792 |   </a>
793 |   
794 | </li>
795 |       
796 |         <li class="md-nav__item">
797 |   <a href="#cgc-add_package-package_name" class="md-nav__link">
798 |     <span class="md-ellipsis">
799 |       cgc add_package &lt;PACKAGE_NAME&gt;
800 |     </span>
801 |   </a>
802 |   
803 | </li>
804 |       
805 |         <li class="md-nav__item">
806 |   <a href="#cgc-cypher-query" class="md-nav__link">
807 |     <span class="md-ellipsis">
808 |       cgc cypher &lt;QUERY&gt;
809 |     </span>
810 |   </a>
811 |   
812 | </li>
813 |       
814 |         <li class="md-nav__item">
815 |   <a href="#cgc-list_mcp_tools" class="md-nav__link">
816 |     <span class="md-ellipsis">
817 |       cgc list_mcp_tools
818 |     </span>
819 |   </a>
820 |   
821 | </li>
822 |       
823 |         <li class="md-nav__item">
824 |   <a href="#cgc-help" class="md-nav__link">
825 |     <span class="md-ellipsis">
826 |       cgc help
827 |     </span>
828 |   </a>
829 |   
830 | </li>
831 |       
832 |         <li class="md-nav__item">
833 |   <a href="#cgc-version" class="md-nav__link">
834 |     <span class="md-ellipsis">
835 |       cgc version
836 |     </span>
837 |   </a>
838 |   
839 | </li>
840 |       
841 |     </ul>
842 |   
843 | </nav>
844 |                   </div>
845 |                 </div>
846 |               </div>
847 |             
848 |           
849 |           
850 |             <div class="md-content" data-md-component="content">
851 |               <article class="md-content__inner md-typeset">
852 |                 
853 |                   
854 | 
855 | 
856 | 
857 | <h1 id="cli-reference">CLI Reference</h1>
858 | <p>The CodeGraphContext CLI provides a set of commands to manage the server, index your code, and interact with the code graph.</p>
859 | <h2 id="cgc-setup"><code>cgc setup</code></h2>
860 | <p>Runs the interactive setup wizard to configure the server and database connection. This helps users set up a local Docker-based Neo4j instance or connect to a remote one.</p>
861 | <p><strong>Usage:</strong></p>
862 | <pre><code class="language-bash">cgc setup
863 | </code></pre>
864 | <h2 id="cgc-start"><code>cgc start</code></h2>
865 | <p>Starts the CodeGraphContext MCP server, which listens for JSON-RPC requests from stdin.</p>
866 | <p><strong>Usage:</strong></p>
867 | <pre><code class="language-bash">cgc start
868 | </code></pre>
869 | <h2 id="cgc-index-path"><code>cgc index [PATH]</code></h2>
870 | <p>Indexes a directory or file by adding it to the code graph. If no path is provided, it indexes the current directory.</p>
871 | <p><strong>Arguments:</strong>
872 | *   <code>PATH</code> (optional): Path to the directory or file to index. Defaults to the current directory.</p>
873 | <p><strong>Usage:</strong></p>
874 | <pre><code class="language-bash">cgc index /path/to/your/project
875 | </code></pre>
876 | <h3 id="ignoring-files-cgcignore">Ignoring Files (<code>.cgcignore</code>)</h3>
877 | <p>You can tell CodeGraphContext to ignore specific files and directories by creating a <code>.cgcignore</code> file in the root of your project. This file uses the same syntax as <code>.gitignore</code>.</p>
878 | <p>When you run <code>cgc index</code>, the command will look for a <code>.cgcignore</code> file in the directory being indexed and exclude any files or directories that match the patterns in the file.</p>
879 | <p><strong>Example <code>.cgcignore</code> file:</strong></p>
880 | <pre><code># Ignore build artifacts
881 | /build/
882 | /dist/
883 | 
884 | # Ignore dependencies
885 | /node_modules/
886 | /vendor/
887 | 
888 | # Ignore logs
889 | *.log
890 | </code></pre>
891 | <h2 id="cgc-delete-path"><code>cgc delete &lt;PATH&gt;</code></h2>
892 | <p>Deletes a repository from the code graph.</p>
893 | <p><strong>Arguments:</strong>
894 | *   <code>PATH</code> (required): Path of the repository to delete from the code graph.</p>
895 | <p><strong>Usage:</strong></p>
896 | <pre><code class="language-bash">cgc delete /path/to/your/project
897 | </code></pre>
898 | <h2 id="cgc-visualize-query"><code>cgc visualize [QUERY]</code></h2>
899 | <p>Generates a URL to visualize a Cypher query in the Neo4j Browser. If no query is provided, a default query will be used.</p>
900 | <p><strong>Arguments:</strong>
901 | *   <code>QUERY</code> (optional): The Cypher query to visualize.</p>
902 | <p><strong>Usage:</strong></p>
903 | <pre><code class="language-bash">cgc visualize &quot;MATCH (n) RETURN n&quot;
904 | </code></pre>
905 | <h2 id="cgc-list_repos"><code>cgc list_repos</code></h2>
906 | <p>Lists all indexed repositories.</p>
907 | <p><strong>Usage:</strong></p>
908 | <pre><code class="language-bash">cgc list_repos
909 | </code></pre>
910 | <h2 id="cgc-add_package-package_name"><code>cgc add_package &lt;PACKAGE_NAME&gt;</code></h2>
911 | <p>Adds a Python package to the code graph.</p>
912 | <p><strong>Arguments:</strong>
913 | *   <code>PACKAGE_NAME</code> (required): Name of the Python package to add.</p>
914 | <p><strong>Usage:</strong></p>
915 | <pre><code class="language-bash">cgc add_package requests
916 | </code></pre>
917 | <h2 id="cgc-cypher-query"><code>cgc cypher &lt;QUERY&gt;</code></h2>
918 | <p>Executes a read-only Cypher query.</p>
919 | <p><strong>Arguments:</strong>
920 | *   <code>QUERY</code> (required): The read-only Cypher query to execute.</p>
921 | <p><strong>Usage:</strong></p>
922 | <pre><code class="language-bash">cgc cypher &quot;MATCH (n:Function) RETURN n.name&quot;
923 | </code></pre>
924 | <h2 id="cgc-list_mcp_tools"><code>cgc list_mcp_tools</code></h2>
925 | <p>Lists all available tools and their descriptions.</p>
926 | <p><strong>Usage:</strong></p>
927 | <pre><code class="language-bash">cgc list_mcp_tools
928 | </code></pre>
929 | <h2 id="cgc-help"><code>cgc help</code></h2>
930 | <p>Show the main help message and exit.</p>
931 | <p><strong>Usage:</strong></p>
932 | <pre><code class="language-bash">cgc help
933 | </code></pre>
934 | <h2 id="cgc-version"><code>cgc version</code></h2>
935 | <p>Show the application version.</p>
936 | <p><strong>Usage:</strong></p>
937 | <pre><code class="language-bash">cgc --version
938 | </code></pre>
939 | <p>or</p>
940 | <pre><code class="language-bash">cgc version
941 | </code></pre>
942 | 
943 | 
944 | 
945 | 
946 | 
947 | 
948 | 
949 | 
950 | 
951 | 
952 | 
953 | 
954 |                 
955 |               </article>
956 |             </div>
957 |           
958 |           
959 | <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
960 |         </div>
961 |         
962 |       </main>
963 |       
964 |         <footer class="md-footer">
965 |   
966 |   <div class="md-footer-meta md-typeset">
967 |     <div class="md-footer-meta__inner md-grid">
968 |       <div class="md-copyright">
969 |   
970 |   
971 |     Made with
972 |     <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
973 |       Material for MkDocs
974 |     </a>
975 |   
976 | </div>
977 |       
978 |     </div>
979 |   </div>
980 | </footer>
981 |       
982 |     </div>
983 |     <div class="md-dialog" data-md-component="dialog">
984 |       <div class="md-dialog__inner md-typeset"></div>
985 |     </div>
986 |     
987 |     
988 |     
989 |       
990 |       <script id="__config" type="application/json">{"base": "..", "features": [], "search": "../assets/javascripts/workers/search.973d3a69.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>
991 |     
992 |     
993 |       <script src="../assets/javascripts/bundle.f55a23d4.min.js"></script>
994 |       
995 |     
996 |   </body>
997 | </html>
```
Page 11/18FirstPrevNextLast