Skip to content

Commit b1c22e0

Browse files
Copilotgkorland
andcommitted
feat: split CLI into lightweight falkordb-cgraph package
Co-authored-by: gkorland <753206+gkorland@users.noreply.github.com> Agent-Logs-Url: https://github.com/FalkorDB/code-graph/sessions/b48ad8e3-c799-4522-9425-93bd5e5b2574
1 parent 35ec297 commit b1c22e0

8 files changed

Lines changed: 557 additions & 21 deletions

File tree

AGENTS.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Knowledge graph visualization tool for codebases. Python FastAPI backend + React
2121

2222
```text
2323
api/ # Python backend
24-
cli.py # cgraph CLI tool (typer)
24+
cli.py # cgraph CLI tool (typer) — full version used during dev
2525
index.py # FastAPI app, routes, auth, SPA serving
2626
graph.py # FalkorDB graph operations (sync + async)
2727
llm.py # GraphRAG + LiteLLM chat
@@ -32,6 +32,10 @@ api/ # Python backend
3232
analyzers/ # Language-specific code analyzers
3333
entities/ # Graph entity models
3434
git_utils/ # Git history graph construction
35+
cli/ # Lightweight CLI package (falkordb-cgraph)
36+
pyproject.toml # Minimal deps: falkordb + typer only
37+
cgraph/
38+
main.py # Standalone CLI commands (list, search, neighbors, paths, info, ensure-db)
3539
app/ # React frontend (Vite)
3640
src/components/ # React components (ForceGraph, chat, code-graph, etc.)
3741
src/lib/ # Utilities
@@ -136,16 +140,26 @@ Key variables (see `.env.template` for full list):
136140

137141
## CLI (`cgraph`)
138142

139-
Typer-based CLI wrapping the sync `Graph` and `Project` classes. Outputs JSON to stdout, status to stderr. Entry point: `api/cli.py`.
143+
Two packages provide the `cgraph` command:
140144

141-
Install: `pipx install falkordb-code-graph` or `pip install falkordb-code-graph`
145+
**Lightweight CLI** (`falkordb-cgraph` — the recommended install for end users):
142146

143-
For development: `make install-cli` or `uv pip install -e .`
147+
Install: `pipx install falkordb-cgraph`
148+
149+
For development: `make install-cli` (installs from `cli/`)
150+
151+
Provides query commands only (`list`, `search`, `neighbors`, `paths`, `info`, `ensure-db`). The `index` and `index-repo` commands print a helpful message directing users to install `falkordb-code-graph`.
152+
153+
**Full server package** (`falkordb-code-graph` — for development/Docker):
154+
155+
Install: `pip install falkordb-code-graph` or `uv sync`
156+
157+
Also provides `cgraph` via `api/cli.py` and includes all indexing commands.
144158

145159
```bash
146160
cgraph ensure-db # Start FalkorDB if not running
147-
cgraph index . --ignore node_modules # Index local folder
148-
cgraph index-repo <url> # Clone + index a repo
161+
cgraph index . --ignore node_modules # Index local folder (full package only)
162+
cgraph index-repo <url> # Clone + index a repo (full package only)
149163
cgraph list # List indexed repos
150164
cgraph search <prefix> [--repo <name>] # Full-text prefix search
151165
cgraph neighbors <id>... [--repo <name>] [--rel <type>] [--label <label>] # Connected entities

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ install: ## Install all dependencies (backend + frontend)
1010
uv sync --all-extras
1111
npm install --prefix ./app
1212

13-
install-cli: ## Install cgraph CLI entry point
14-
uv pip install -e .
13+
install-cli: ## Install lightweight cgraph CLI (falkordb-cgraph) entry point
14+
pip install -e ./cli
1515

1616
build-dev: ## Build frontend for development
1717
npm --prefix ./app run build:dev

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ code-graph/
2626
│ ├── project.py # Repository cloning and analysis orchestration
2727
│ ├── info.py # Repository metadata stored in Redis/FalkorDB
2828
│ ├── prompts.py # LLM system and prompt templates
29-
│ ├── cli.py # cgraph CLI tool (typer)
29+
│ ├── cli.py # cgraph CLI tool (full version, dev use)
3030
│ ├── auto_complete.py # Prefix search helper
3131
│ ├── analyzers/ # Source analyzers (Python, Java, C#)
3232
│ ├── entities/ # Graph/entity models
3333
│ ├── git_utils/ # Git history graph utilities
3434
│ └── code_coverage/ # Coverage utilities
35+
├── cli/ # Lightweight CLI package (falkordb-cgraph)
36+
│ ├── pyproject.toml # Minimal deps: falkordb + typer only
37+
│ └── cgraph/
38+
│ └── main.py # Standalone CLI (list, search, neighbors, paths, info, ensure-db)
3539
├── app/ # React frontend (Vite)
3640
│ ├── src/ # Frontend source code
3741
│ ├── public/ # Static assets
@@ -45,7 +49,7 @@ code-graph/
4549
├── docker-compose.yml # Local FalkorDB + app stack
4650
├── Makefile # Common dev/build/test commands
4751
├── start.sh # Container entrypoint
48-
├── pyproject.toml # Python package and dependency config
52+
├── pyproject.toml # Python server package (falkordb-code-graph) with all deps
4953
└── .env.template # Example environment variables
5054
```
5155

@@ -162,23 +166,31 @@ make clean # Remove build/test artifacts
162166

163167
## CLI Tool (`cgraph`)
164168

165-
CodeGraph includes a CLI tool for indexing codebases and querying the knowledge graph directly from the terminal. All output is JSON (to stdout), with status messages on stderr.
169+
CodeGraph includes a CLI tool for querying the knowledge graph directly from the terminal. All output is JSON (to stdout), with status messages on stderr.
166170

167171
### Install
168172

173+
**Lightweight CLI** (recommended for end users — fast install, only `falkordb` + `typer`):
174+
169175
```bash
170-
# Install from PyPI (recommended for end users)
171-
pipx install falkordb-code-graph
176+
# Install from PyPI (recommended)
177+
pipx install falkordb-cgraph
172178

173179
# Or with pip
180+
pip install falkordb-cgraph
181+
```
182+
183+
**Full server package** (includes indexing commands, web server, all heavy deps):
184+
185+
```bash
174186
pip install falkordb-code-graph
175187
```
176188

177189
For development (from a local clone):
178190

179191
```bash
180-
make install-cli
181-
# or
192+
make install-cli # installs falkordb-cgraph from cli/
193+
# or for full server package:
182194
uv pip install -e .
183195
```
184196

@@ -188,10 +200,10 @@ uv pip install -e .
188200
# Ensure FalkorDB is running (auto-starts a Docker container if needed)
189201
cgraph ensure-db
190202

191-
# Index the current project
203+
# Index the current project (requires falkordb-code-graph)
192204
cgraph index . --ignore node_modules --ignore .git --ignore venv --ignore __pycache__
193205

194-
# Index a remote repository
206+
# Index a remote repository (requires falkordb-code-graph)
195207
cgraph index-repo https://github.com/user/repo --ignore node_modules
196208

197209
# List indexed repos

cli/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# falkordb-cgraph
2+
3+
Lightweight CLI for querying [FalkorDB](https://falkordb.com) code-graph knowledge graphs.
4+
5+
## Installation
6+
7+
```bash
8+
pipx install falkordb-cgraph
9+
```
10+
11+
This installs only `falkordb` and `typer` — no heavy server-side dependencies.
12+
13+
## Usage
14+
15+
```bash
16+
cgraph --help
17+
18+
# Ensure FalkorDB is running (starts a Docker container if needed)
19+
cgraph ensure-db
20+
21+
# List all indexed repositories
22+
cgraph list
23+
24+
# Search for entities by prefix
25+
cgraph search <prefix> [--repo <name>]
26+
27+
# Get neighboring entities
28+
cgraph neighbors <id>... [--repo <name>] [--rel <type>] [--label <label>]
29+
30+
# Find call-chain paths between two nodes
31+
cgraph paths <src-id> <dest-id> [--repo <name>]
32+
33+
# Show repository statistics and metadata
34+
cgraph info [--repo <name>]
35+
```
36+
37+
`--repo` defaults to the current directory name.
38+
39+
## Indexing
40+
41+
The `index` and `index-repo` commands require the full server package:
42+
43+
```bash
44+
pip install falkordb-code-graph
45+
```
46+
47+
## Environment variables
48+
49+
| Variable | Default | Purpose |
50+
|----------|---------|---------|
51+
| `FALKORDB_HOST` | `localhost` | FalkorDB host |
52+
| `FALKORDB_PORT` | `6379` | FalkorDB port |
53+
| `FALKORDB_USERNAME` || FalkorDB username (optional) |
54+
| `FALKORDB_PASSWORD` || FalkorDB password (optional) |

cli/cgraph/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)