ctxgraph-code 0.6.1__tar.gz → 0.6.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ctxgraph_code-0.6.1/src/ctxgraph_code.egg-info → ctxgraph_code-0.6.2}/PKG-INFO +182 -3
- ctxgraph_code-0.6.1/PKG-INFO → ctxgraph_code-0.6.2/README.md +587 -434
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/pyproject.toml +1 -1
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/cli.py +1 -1
- ctxgraph_code-0.6.1/README.md → ctxgraph_code-0.6.2/src/ctxgraph_code.egg-info/PKG-INFO +613 -408
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/setup.cfg +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/__main__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/python/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/python/importer.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/python/semantic.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/python/symbols.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/treesitter/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/treesitter/analyzer.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/analyzers/treesitter/languages.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/config/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/config/build_status.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/config/global_paths.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/config/hooks.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/config/init.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/config/settings.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/exclude/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/exclude/patterns.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/graph/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/graph/builder.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/graph/models.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/graph/query.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/graph/storage.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/render/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/render/_text.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/render/mermaid.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/view/__init__.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code/view/visualizer.py +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code.egg-info/SOURCES.txt +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code.egg-info/dependency_links.txt +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code.egg-info/entry_points.txt +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code.egg-info/requires.txt +0 -0
- {ctxgraph_code-0.6.1 → ctxgraph_code-0.6.2}/src/ctxgraph_code.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ctxgraph-code
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Code knowledge graph for Claude Code. Build a relationship graph of your Python codebase and query it during coding sessions.
|
|
5
5
|
Author: ctxgraph-code contributors
|
|
6
6
|
License: MIT
|
|
@@ -26,7 +26,13 @@ Requires-Dist: pytest>=7.0; extra == "dev"
|
|
|
26
26
|
|
|
27
27
|
# ctxgraph-code
|
|
28
28
|
|
|
29
|
-
**
|
|
29
|
+
**How do we give AI the right context without sending the entire codebase every time?**
|
|
30
|
+
|
|
31
|
+
`ctxgraph-code` answers that question. Instead of dumping files into the context window, it builds a **relationship graph** of your codebase using static AST analysis, stores it in a local SQLite database, and retrieves only the relevant symbols and dependencies when Claude Code needs to understand your code.
|
|
32
|
+
|
|
33
|
+
**Result:** One codebase question drops from ~25,000 tokens to ~800 tokens — a **95% reduction** in context usage. A full 30-question benchmark showed **90% fewer tokens** than traditional file reading, and **16% fewer than graph-based alternatives**.
|
|
34
|
+
|
|
35
|
+

|
|
30
36
|
|
|
31
37
|
```bash
|
|
32
38
|
pip install ctxgraph-code
|
|
@@ -67,6 +73,29 @@ ctxgraph-code setup
|
|
|
67
73
|
# /ctxgraph-code
|
|
68
74
|
```
|
|
69
75
|
|
|
76
|
+
## How It Works (At a Glance)
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Your Codebase
|
|
80
|
+
│
|
|
81
|
+
▼
|
|
82
|
+
1. Static AST Analysis ──► Extract imports, classes, functions, calls, relationships
|
|
83
|
+
│
|
|
84
|
+
▼
|
|
85
|
+
2. Knowledge Graph ──► Store everything in local SQLite (files, symbols, edges)
|
|
86
|
+
│
|
|
87
|
+
▼
|
|
88
|
+
3. Query Engine ──► Search graph by relevance, expand to neighbors via BFS
|
|
89
|
+
│
|
|
90
|
+
▼
|
|
91
|
+
4. Context Retrieval ──► Only the relevant snippets, not whole files
|
|
92
|
+
│
|
|
93
|
+
▼
|
|
94
|
+
5. Claude Code ──► Receives focused context → Better answers, fewer tokens, less noise
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
No huge graph-building prompts sent to the LLM. The graph is built locally with Python's AST parser — zero LLM calls, zero API costs.
|
|
98
|
+
|
|
70
99
|
## Commands
|
|
71
100
|
|
|
72
101
|
### `setup` (recommended)
|
|
@@ -113,6 +142,37 @@ ctxgraph-code init
|
|
|
113
142
|
|
|
114
143
|
Creates the `.ctxgraph/` directory with a default `config.toml`.
|
|
115
144
|
|
|
145
|
+
### `subgraph`
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
ctxgraph-code subgraph "add pagination to the users endpoint"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Extracts a **focused subgraph** relevant to a task description — returns matching nodes, their relationships, and inline source code in a single compact response. Saves 1-2 tool calls by combining graph search, dependency resolution, and file reading.
|
|
152
|
+
|
|
153
|
+
- `--max-nodes` / `-n` — max nodes in subgraph (default: 10)
|
|
154
|
+
|
|
155
|
+
### `diff`
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
ctxgraph-code diff
|
|
159
|
+
ctxgraph-code diff --ref main
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Compares the graph with the filesystem. Shows files that have been **added, removed, or changed** since the graph was built. Use `--ref` for a git-aware diff against a branch. Essential for knowing when to run `ctxgraph-code build --incremental`.
|
|
163
|
+
|
|
164
|
+
### `mermaid`
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
ctxgraph-code mermaid classDiagram
|
|
168
|
+
ctxgraph-code mermaid flowchart --output diagram.md
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Exports the graph as a **Mermaid diagram** for embedding in documentation or PRs. Supported types: `classDiagram`, `flowchart`, `sequence`.
|
|
172
|
+
|
|
173
|
+
- `--output` / `-o` — save to file instead of stdout
|
|
174
|
+
- `--max-nodes` / `-n` — maximum nodes in diagram (default: 50)
|
|
175
|
+
|
|
116
176
|
### `build`
|
|
117
177
|
|
|
118
178
|
```bash
|
|
@@ -348,6 +408,105 @@ This catches the common case where you edit a file after building the graph and
|
|
|
348
408
|
|
|
349
409
|
---
|
|
350
410
|
|
|
411
|
+
## Benchmark Results
|
|
412
|
+
|
|
413
|
+
Real-world benchmarks against a production Python/UI codebase. Three approaches compared across 30 code understanding questions.
|
|
414
|
+
|
|
415
|
+
### Repository Profile
|
|
416
|
+
|
|
417
|
+
| Metric | Value |
|
|
418
|
+
|---|---|
|
|
419
|
+
| Backend Python LOC | 45,570 |
|
|
420
|
+
| UI Source LOC | 37,317 |
|
|
421
|
+
| Documentation LOC | 9,120 |
|
|
422
|
+
| Source Files | 143 |
|
|
423
|
+
| Raw Tokens | ~140,000 |
|
|
424
|
+
|
|
425
|
+
### Three Retrieval Methods Compared
|
|
426
|
+
|
|
427
|
+
| Approach | How It Works |
|
|
428
|
+
|---|---|
|
|
429
|
+
| **Baseline** (File Reading) | `grep` → read entire files → answer. Every question repeatedly loads large source files. |
|
|
430
|
+
| **Graphify** (Knowledge Graph) | Build full graph → compressed node summaries → answer. Incurs large upfront graph-building cost. |
|
|
431
|
+
| **CtxGraph-Code** (Symbol Graph) | Local AST → SQLite symbol graph → retrieve only relevant files → answer. Only targeted files opened. |
|
|
432
|
+
|
|
433
|
+
### Combined Results (30 Questions)
|
|
434
|
+
|
|
435
|
+
| Approach | Total Tokens | Avg/Question | Reduction |
|
|
436
|
+
|---|---|---|---|
|
|
437
|
+
| Baseline (File Reading) | 203,590 | 6,786 | — |
|
|
438
|
+
| Graphify | 25,100 | 837 | 88% |
|
|
439
|
+
| **CtxGraph-Code** | **21,120** | **704** | **90%** |
|
|
440
|
+
|
|
441
|
+
CtxGraph-Code is **9.6× more efficient** than reading raw files, and uses **16% fewer tokens** than Graphify.
|
|
442
|
+
|
|
443
|
+

|
|
444
|
+
|
|
445
|
+
### Per-Suite Breakdown
|
|
446
|
+
|
|
447
|
+
| Suite | Baseline | Graphify | CtxGraph-Code | Winner |
|
|
448
|
+
|---|---|---|---|---|
|
|
449
|
+
| BM1: Architecture | 73,500 | 12,100 | 10,150 | CtxGraph-Code |
|
|
450
|
+
| BM2: Data Flow & UI Logic | 130,090 | 13,000 | 10,970 | CtxGraph-Code |
|
|
451
|
+
| **Combined** | **203,590** | **25,100** | **21,120** | **CtxGraph-Code** |
|
|
452
|
+
|
|
453
|
+
### Biggest Win: File Comparison
|
|
454
|
+
|
|
455
|
+
Question: *"How does tasks_fixed.py differ from tasks.py?"*
|
|
456
|
+
|
|
457
|
+
- `tasks.py`: 2,372 lines
|
|
458
|
+
- `tasks_fixed.py`: 1,512 lines
|
|
459
|
+
|
|
460
|
+
| Approach | Tokens |
|
|
461
|
+
|---|---|
|
|
462
|
+
| Baseline | 31,070 |
|
|
463
|
+
| Graphify | 1,400 |
|
|
464
|
+
| **CtxGraph-Code** | **1,150 (96% savings)** |
|
|
465
|
+
|
|
466
|
+
Instead of reading both files completely, CtxGraph-Code compares symbols and retrieves only relevant differences.
|
|
467
|
+
|
|
468
|
+
### Context Window Longevity
|
|
469
|
+
|
|
470
|
+
With a 200K token context window:
|
|
471
|
+
|
|
472
|
+
| Approach | Tokens/Question | Questions Before Exhaustion |
|
|
473
|
+
|---|---|---|
|
|
474
|
+
| Baseline | 6,786 | ~29 |
|
|
475
|
+
| Graphify | 837 | ~239 |
|
|
476
|
+
| **CtxGraph-Code** | **704** | **~284 (10× longer sessions)** |
|
|
477
|
+
|
|
478
|
+
### Graphify vs CtxGraph-Code: Detailed Comparison
|
|
479
|
+
|
|
480
|
+

|
|
481
|
+
|
|
482
|
+
| Metric | Graphify | CtxGraph-Code |
|
|
483
|
+
|---|---|---|
|
|
484
|
+
| **Build approach** | Full knowledge graph first | Local symbol graph via AST + SQLite |
|
|
485
|
+
| **Upfront LLM cost** | ~141,728 input tokens | ~0 tokens (local AST parse, ~246s) |
|
|
486
|
+
| **Total input tokens** | ~157,728 | ~22,500 (**85.7% fewer**) |
|
|
487
|
+
| **Output tokens** | ~12,000 | ~3,500 (**70.8% fewer**) |
|
|
488
|
+
| **Query speed** | Moderate (BFS/DFS traversal) | Fast (SQLite indexed lookup) |
|
|
489
|
+
| **Strengths** | Architecture visualization, community detection, cross-file relationship discovery | Inline source retrieval, indexed search, symbol resolution, implementation-focused answers |
|
|
490
|
+
| **Weaknesses** | No implementation snippets; often requires opening source files after | Less visualization; relationship discovery less deep |
|
|
491
|
+
| **Best for** | Architecture discovery, planning, cross-cutting concerns | Code navigation, execution flow, symbol lookup, implementation questions |
|
|
492
|
+
|
|
493
|
+
**Bottom line:** Use CtxGraph-Code for fast code search and implementation answers. Use Graphify when you need architecture visualization and cross-file relationship discovery.
|
|
494
|
+
|
|
495
|
+
### Real-World Example Results
|
|
496
|
+
|
|
497
|
+
| Question | Without | With CtxGraph-Code | Savings |
|
|
498
|
+
|---|---|---|---|
|
|
499
|
+
| Learning Mode | 9,498 | 3,267 | 66% |
|
|
500
|
+
| Planner Node | 13,166 | 7,043 | 47% |
|
|
501
|
+
| Dashboard Embedding | 5,180 | 2,840 | 45% |
|
|
502
|
+
| Authentication | 9,498 | 3,267 | 66% |
|
|
503
|
+
| Deep Learning Mode | 25,000 | 800 | 95% |
|
|
504
|
+
| **Overall (30 questions)** | **203,590** | **21,120** | **90%** |
|
|
505
|
+
|
|
506
|
+

|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
351
510
|
## Using with Claude Code
|
|
352
511
|
|
|
353
512
|
After `ctxgraph-code setup`, the `/ctxgraph-code` slash command is installed globally by default — it works in every Claude Code session. Claude sees:
|
|
@@ -367,6 +526,9 @@ After `ctxgraph-code setup`, the `/ctxgraph-code` slash command is installed glo
|
|
|
367
526
|
- `ctxgraph-code overview --dir <name>` -- Show project structure for a specific graph
|
|
368
527
|
- `ctxgraph-code symbols <path>` -- List classes/functions defined in a file
|
|
369
528
|
- `ctxgraph-code context "task"` -- Generate a focused context summary
|
|
529
|
+
- `ctxgraph-code subgraph "task"` -- Focused subgraph with inline source
|
|
530
|
+
- `ctxgraph-code diff` -- Files changed since build
|
|
531
|
+
- `ctxgraph-code mermaid --type classDiagram` -- Export as Mermaid diagram
|
|
370
532
|
- `ctxgraph-code view --dir <name>` -- Visualize a graph interactively
|
|
371
533
|
```
|
|
372
534
|
|
|
@@ -404,13 +566,30 @@ Built-in default exclusion patterns (always applied): `__pycache__`, `*.pyc`, `.
|
|
|
404
566
|
|
|
405
567
|
---
|
|
406
568
|
|
|
569
|
+
## Where It Helps
|
|
570
|
+
|
|
571
|
+
`ctxgraph-code` delivers the most value when working with **existing codebases built over months or years**:
|
|
572
|
+
|
|
573
|
+
| Helps Most | Helps Less |
|
|
574
|
+
|---|---|
|
|
575
|
+
| 🐛 Debugging production issues | Tiny projects (2–3 files) |
|
|
576
|
+
| 🏗 Understanding architecture | Throwaway scripts |
|
|
577
|
+
| 🔍 Tracing dependencies | Greenfield projects created entirely in the same Claude session |
|
|
578
|
+
| 🔄 Safe refactoring | Short experiments |
|
|
579
|
+
| 📚 Onboarding into large existing codebases | |
|
|
580
|
+
| 🧩 Multi-module repositories | |
|
|
581
|
+
|
|
582
|
+
The biggest gains come when AI needs to understand **existing code written over months or years**, not when starting from scratch.
|
|
583
|
+
|
|
584
|
+
---
|
|
585
|
+
|
|
407
586
|
## Differences from `ctxgraph`
|
|
408
587
|
|
|
409
588
|
`ctxgraph-code` is a **focused subset** of [ctxgraph](https://github.com/shashi3070/ctxgraph) designed specifically for Claude Code.
|
|
410
589
|
|
|
411
590
|
| Feature | ctxgraph | ctxgraph-code |
|
|
412
591
|
|---------|----------|---------------|
|
|
413
|
-
| CLI commands | 9+ |
|
|
592
|
+
| CLI commands | 9+ | 20 (init, build, query, deps, usedby, overview, symbols, context, subgraph, diff, mermaid, setup, view, info, install-slash, build-status, probe, install-hooks, uninstall-hooks, version) |
|
|
414
593
|
| LLM integration | Built-in (Ollama, Claude, OpenAI, Azure) | None (delegates to Claude Code) |
|
|
415
594
|
| Chat sessions | Yes | No |
|
|
416
595
|
| Visualizer | D3.js HTML + SVG | D3.js HTML (`view` opens in browser, `--tree` for text) |
|