Buddhi AI CLI
Project description
Buddhi AI CLI
Buddhi AI CLI (buddhi-ai) is a powerful command-line tool designed to map structural entities and filter boilerplate in your codebase. Built on top of AST parsing (Tree-sitter) and graph analysis (igraph), Buddhi AI creates a topology-driven retrieval pipeline. It also seamlessly integrates with the Model Context Protocol (MCP) to provide intelligent code search, reading, and shell execution capabilities for AI agents.
Key Features
- Structural Code Mapping: Uses Tree-sitter to parse source code into an Abstract Syntax Tree (AST) and maps it into a graph database (SQLite).
- Boilerplate Filtering: Employs Shannon entropy thresholds to filter out boilerplate lines and highlight critical code paths.
- Topology-Driven Search: Community-aware search that traverses neighborhoods and includes bridge nodes instead of standard keyword-only retrieval.
- Dynamic File Reading: Reads files using dynamic compression, AST pruning, and bounce prevention logic to prevent prompt thrashing.
- Native Fallback & Telemetry: Gracefully degrades to native search when necessary, while comprehensively tracking token savings and tool execution metrics.
- MCP Integration: Fully exposes search and read tools via the FastMCP server.
Architecture & Tech Stack
- Python 3.10+: Core language.
- Tree-sitter: Used for parsing various programming languages into ASTs.
- igraph: Handles complex graph-based topological searches and structural abstraction.
- FastMCP: Provides the Model Context Protocol server interface.
- uv: Dependency management and build backend.
Prerequisites
- Python: 3.10 or higher.
- (Recommended) uv: For fast Python package resolution and virtual environment management.
Installation
From Source (Using uv)
-
Clone the repository:
git clone <repository_url> cd buddhi-cli
-
Sync dependencies using
uv(or install viapip):uv sync -
Activate the virtual environment:
source .venv/bin/activate
(On Windows, use
.venv\Scripts\activate)
From Source (Using pip)
Alternatively, install it in editable mode:
pip install -e .
Usage
1. The buddhi CLI
Before using the tools, you need to initialize the project directory and scan the codebase.
buddhi init [OPTIONS]
Options:
--entropy-threshold <FLOAT>: Shannon entropy threshold for filtering boilerplate lines. Default is3.0.
This will parse your workspace and create the Buddhi graph database at .buddhi/graph.db.
Additional Commands:
buddhi metrics [--days N] [--json] [--reset]: Show tool usage metrics and token savings.buddhi hook <name>: Run a named hook handler (e.g.gate-io,pre-invoke).
2. The MCP Server (buddhi-mcp)
Start the FastMCP server over standard input/output (StdIO):
buddhi-mcp [OPTIONS]
Options:
--db-path <PATH>: Explicit path to the.buddhi/graph.dbdatabase. Overrides the auto-detection traversing upwards from the current working directory.
Available MCP Tools
Once the server is running, the following tools are exposed via the Model Context Protocol:
-
buddhi_search(query, top_n=3, mode="full", include_bridges=True, budget=8000, cwd=None)Search the codebase using Buddhi's topology-driven retrieval. Replace keyword-only searches with community-aware context-optimized results. Features an automatic native fallback mechanism when graph database results are sparse. -
buddhi_read(filepath=None, query=None, mode="auto", task_intent=None, budget=4000, cwd=None)Read a file with dynamic compression, AST pruning, and bounce prevention logic, or search for files/symbols in the workspace. Mode options include'auto','full','signatures','map', or'entropy'.
Development & Contributing
- Linting & Formatting: Handled via
ruffandmypy(defined inpyproject.tomldependency groups). - Testing: Handled via
pytest.
To run tests:
pytest tests/
Testing the CLI Locally
To test the CLI tool locally as if it were in production without publishing to PyPI:
Option 1: Global Installation (Recommended)
Install the built .whl file globally using uv tool install:
uv build
uv tool install dist/buddhi_ai-<version>-py3-none-any.whl --force
To uninstall later:
uv tool uninstall buddhi-ai
Option 2: Editable Mode For active development, install the tool in editable mode so changes to the source code are reflected immediately:
uv tool install -e .
To uninstall:
uv tool uninstall buddhi-ai
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file buddhi_ai-1.0.0b5.tar.gz.
File metadata
- Download URL: buddhi_ai-1.0.0b5.tar.gz
- Upload date:
- Size: 50.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cc61e29be2e1e72430378ebcb34a20bec381abb3dc9d00709bac50fd9783957
|
|
| MD5 |
1a6d0e275fa04b29bc9affa078519101
|
|
| BLAKE2b-256 |
71271f67ec460cceb28e69a59b447b0a51f28d4e8c6cce808f5b82f5f6dbc961
|
File details
Details for the file buddhi_ai-1.0.0b5-py3-none-any.whl.
File metadata
- Download URL: buddhi_ai-1.0.0b5-py3-none-any.whl
- Upload date:
- Size: 64.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d96baa521deb4cb028ed05f7afae68338fb924acad1dd884a0c97e7b5882480f
|
|
| MD5 |
3f2105489504a1d0b9c455464a827dc3
|
|
| BLAKE2b-256 |
3b816ab638e8375206503c17df04d9f383351cb069d9e9dd31460c861be8bcfa
|