ctxgraph-code 0.3.0__tar.gz → 0.4.1__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.3.0/src/ctxgraph_code.egg-info → ctxgraph_code-0.4.1}/PKG-INFO +58 -7
- ctxgraph_code-0.3.0/PKG-INFO → ctxgraph_code-0.4.1/README.md +386 -358
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/pyproject.toml +1 -1
- ctxgraph_code-0.4.1/src/ctxgraph_code/__init__.py +1 -0
- ctxgraph_code-0.4.1/src/ctxgraph_code/analyzers/treesitter/__init__.py +4 -0
- ctxgraph_code-0.4.1/src/ctxgraph_code/analyzers/treesitter/analyzer.py +249 -0
- ctxgraph_code-0.4.1/src/ctxgraph_code/analyzers/treesitter/languages.py +229 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/cli.py +1090 -873
- ctxgraph_code-0.4.1/src/ctxgraph_code/config/global_paths.py +9 -0
- ctxgraph_code-0.4.1/src/ctxgraph_code/config/hooks.py +165 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/config/settings.py +2 -2
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/graph/builder.py +59 -11
- ctxgraph_code-0.3.0/README.md → ctxgraph_code-0.4.1/src/ctxgraph_code.egg-info/PKG-INFO +409 -335
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code.egg-info/SOURCES.txt +4 -0
- ctxgraph_code-0.3.0/src/ctxgraph_code/config/global_paths.py +0 -16
- ctxgraph_code-0.3.0/src/ctxgraph_code/view/__init__.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/setup.cfg +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/__main__.py +0 -0
- {ctxgraph_code-0.3.0/src/ctxgraph_code → ctxgraph_code-0.4.1/src/ctxgraph_code/analyzers}/__init__.py +0 -0
- {ctxgraph_code-0.3.0/src/ctxgraph_code/analyzers → ctxgraph_code-0.4.1/src/ctxgraph_code/analyzers/python}/__init__.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/analyzers/python/importer.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/analyzers/python/semantic.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/analyzers/python/symbols.py +0 -0
- {ctxgraph_code-0.3.0/src/ctxgraph_code/analyzers/python → ctxgraph_code-0.4.1/src/ctxgraph_code/config}/__init__.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/config/build_status.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/config/init.py +0 -0
- {ctxgraph_code-0.3.0/src/ctxgraph_code/config → ctxgraph_code-0.4.1/src/ctxgraph_code/exclude}/__init__.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/exclude/patterns.py +0 -0
- {ctxgraph_code-0.3.0/src/ctxgraph_code/exclude → ctxgraph_code-0.4.1/src/ctxgraph_code/graph}/__init__.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/graph/models.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/graph/query.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/graph/storage.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/render.py +0 -0
- {ctxgraph_code-0.3.0/src/ctxgraph_code/graph → ctxgraph_code-0.4.1/src/ctxgraph_code/view}/__init__.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code/view/visualizer.py +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code.egg-info/dependency_links.txt +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code.egg-info/entry_points.txt +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/src/ctxgraph_code.egg-info/requires.txt +0 -0
- {ctxgraph_code-0.3.0 → ctxgraph_code-0.4.1}/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.
|
|
3
|
+
Version: 0.4.1
|
|
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
|
|
@@ -23,7 +23,7 @@ Requires-Dist: pytest>=7.0; extra == "dev"
|
|
|
23
23
|
|
|
24
24
|
# ctxgraph-code
|
|
25
25
|
|
|
26
|
-
**Code knowledge graph for Claude Code.** Build a relationship graph of your Python
|
|
26
|
+
**Code knowledge graph for Claude Code.** Build a relationship graph of your codebase (Python, JavaScript, TypeScript, C, Go, Rust, and more) so Claude Code understands imports, class hierarchies, function calls, and cross-file dependencies without reading every file.
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
pip install ctxgraph-code
|
|
@@ -215,6 +215,37 @@ ctxgraph-code build-status
|
|
|
215
215
|
|
|
216
216
|
Check whether a background build (`ctxgraph-code setup --background` or `ctxgraph-code build`) completed, failed, or is still running. Shows PID and start time for in-progress builds.
|
|
217
217
|
|
|
218
|
+
### `probe`
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
ctxgraph-code probe "database connection pool"
|
|
222
|
+
ctxgraph-code probe "user authentication" --max 3
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Searches the graph for relevant nodes **and reads the actual source code** inline. Claude gets paths + source in one command, saving 1–2 tool calls. Shows the first 40 lines of matched files with syntax highlighting.
|
|
226
|
+
|
|
227
|
+
- `--max` / `-m` — max files to probe (default: 5)
|
|
228
|
+
- `--context` / `-c` — lines of context around matches (default: 3)
|
|
229
|
+
|
|
230
|
+
### `install-hooks`
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
ctxgraph-code install-hooks
|
|
234
|
+
ctxgraph-code install-hooks --local
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Installs a **PreToolUse hook** in `.claude/settings.json` (global) or `.claude/settings.local.json` (project-local). On every `Bash|Glob|Grep` tool call, Claude Code automatically runs `ctxgraph-code hook-check` and injects graph context into the conversation — letting it know the graph exists, key files, and whether anything is stale.
|
|
238
|
+
|
|
239
|
+
Also prompted during `ctxgraph-code setup`.
|
|
240
|
+
|
|
241
|
+
### `uninstall-hooks`
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
ctxgraph-code uninstall-hooks
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Removes the PreToolUse hooks installed by `install-hooks`.
|
|
248
|
+
|
|
218
249
|
---
|
|
219
250
|
|
|
220
251
|
## How It Works
|
|
@@ -225,7 +256,7 @@ Python files ──AST──> Import/Symbol/Call analysis ──> SQLite gra
|
|
|
225
256
|
Claude Code ──/ctxgraph-code──> CLI query/deps/overview <───┘
|
|
226
257
|
```
|
|
227
258
|
|
|
228
|
-
1. **Build phase**: `ctxgraph-code build`
|
|
259
|
+
1. **Build phase**: `ctxgraph-code build` scans every matching file. Python files are analyzed with Python's `ast` module (fast, rich analysis with docstrings). All other languages (C, C++, JavaScript, TypeScript, Go, Rust, Java, Ruby, and more) are analyzed with **tree-sitter** via `tree-sitter-language-pack`. The result is a graph of **nodes** (files, functions, classes, structs, imports, calls) and **edges** (imports, defines, calls) stored in SQLite.
|
|
229
260
|
|
|
230
261
|
2. **Query phase**: In Claude Code, the `/ctxgraph-code` slash command injects instructions into the conversation. Claude then runs `ctxgraph-code` commands as shell commands to query the graph. Claude reads the text output and reasons about it alongside its own file-reading capabilities.
|
|
231
262
|
|
|
@@ -234,8 +265,13 @@ Claude Code ──/ctxgraph-code──> CLI query/deps/overview <───┘
|
|
|
234
265
|
| Node type | Example ID | Stored |
|
|
235
266
|
|-----------|-----------|--------|
|
|
236
267
|
| `file` | `file:src/api/routes.py` | Name, path, size, summary |
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
268
|
+
| `function` | `func:src/models.py::get_user` | Name, path, parent, summary, line number |
|
|
269
|
+
| `class` | `class:src/api/routes.py::UserAPI` | Name, path, parent file, summary, line number |
|
|
270
|
+
| `struct` | `struct:src/types.c::Point` | Name, path, parent file, line number |
|
|
271
|
+
| `interface` | `interface:src/types.ts::IUser` | Name, path, parent file, line number |
|
|
272
|
+
| `trait` | `trait:src/main.rs::Drawable` | Name, path, parent file, line number |
|
|
273
|
+
| `import` | `import:src/main.c::stdio.h` | Import path, parent file |
|
|
274
|
+
| `call` | `call:src/index.js::parse` | Function name, parent file, line number |
|
|
239
275
|
|
|
240
276
|
| Edge relation | Meaning |
|
|
241
277
|
|--------------|---------|
|
|
@@ -243,8 +279,19 @@ Claude Code ──/ctxgraph-code──> CLI query/deps/overview <───┘
|
|
|
243
279
|
| `defines` | A file/class defines a class/function |
|
|
244
280
|
| `extends` | Class A extends class B |
|
|
245
281
|
| `calls` | Function A calls function B |
|
|
282
|
+
| `includes` | C/C++ file includes a header |
|
|
283
|
+
|
|
284
|
+
Edge weights: `imports=1.0`, `defines=1.0`, `extends=0.8`, `calls=0.7`, `includes=0.6`
|
|
285
|
+
|
|
286
|
+
### Tamper Detection
|
|
287
|
+
|
|
288
|
+
Every build stores **SHA256 content hashes** for every analyzed file in the graph metadata. On every query, `ctxgraph-code` re-reads the file content, recomputes the hash, and compares:
|
|
289
|
+
|
|
290
|
+
- **No match → tamper warning** shown at the bottom of every command output
|
|
291
|
+
- PreToolUse hook also warns inside Claude Code before any search/grep tool runs
|
|
292
|
+
- Use `ctxgraph-code build --incremental` to refresh only tampered files
|
|
246
293
|
|
|
247
|
-
|
|
294
|
+
This catches the common case where you edit a file after building the graph and Claude would otherwise see stale data.
|
|
248
295
|
|
|
249
296
|
### Query relevance scoring
|
|
250
297
|
|
|
@@ -262,6 +309,7 @@ Edge weights: `imports=1.0`, `defines=1.0`, `extends=0.8`, `calls=0.7`
|
|
|
262
309
|
|
|
263
310
|
| Optimization | Details |
|
|
264
311
|
|---|---|
|
|
312
|
+
| **Multi-language** | Uses Python `ast` for `.py` (fast + docstrings) and **tree-sitter** for 25+ languages (C, C++, JS, TS, Go, Rust, Java, Ruby, Kotlin, Swift, and more) |
|
|
265
313
|
| **Parallel builds** | Per-directory graphs build concurrently via `ThreadPoolExecutor` |
|
|
266
314
|
| **Multiprocessing** | Combined graphs split files across CPU cores via `multiprocessing.Pool` |
|
|
267
315
|
| **`--jobs`** | Control parallelism level (default: CPU count) |
|
|
@@ -271,6 +319,8 @@ Edge weights: `imports=1.0`, `defines=1.0`, `extends=0.8`, `calls=0.7`
|
|
|
271
319
|
| **Batch SQLite inserts** | `executemany` instead of per-row `INSERT` statements |
|
|
272
320
|
| **`--no-summary`** | Skips docstring extraction (fastest rebuilds) |
|
|
273
321
|
| **`--background`** | Detach build process and continue working immediately |
|
|
322
|
+
| **Tamper detection** | SHA256 content hashes per file; warns on tampered data in every command output |
|
|
323
|
+
| **PreToolUse hook** | Claude Code auto-injects graph context before Bash/Glob/Grep, saving 1-3 exploratory tool calls |
|
|
274
324
|
|
|
275
325
|
---
|
|
276
326
|
|
|
@@ -287,6 +337,7 @@ After `ctxgraph-code setup`, the `/ctxgraph-code` slash command is installed glo
|
|
|
287
337
|
|
|
288
338
|
**Commands:**
|
|
289
339
|
- `ctxgraph-code query "terms"` -- Find relevant files, classes, and functions
|
|
340
|
+
- `ctxgraph-code probe "question"` -- Search graph and read matching source inline
|
|
290
341
|
- `ctxgraph-code deps <path>` -- Show what a file imports and what calls it
|
|
291
342
|
- `ctxgraph-code usedby <path>` -- Show what depends on a file
|
|
292
343
|
- `ctxgraph-code overview --dir <name>` -- Show project structure for a specific graph
|
|
@@ -335,7 +386,7 @@ Built-in default exclusion patterns (always applied): `__pycache__`, `*.pyc`, `.
|
|
|
335
386
|
|
|
336
387
|
| Feature | ctxgraph | ctxgraph-code |
|
|
337
388
|
|---------|----------|---------------|
|
|
338
|
-
| CLI commands | 9+ |
|
|
389
|
+
| CLI commands | 9+ | 16 (init, build, query, deps, usedby, overview, symbols, context, setup, view, info, install-slash, build-status, probe, install-hooks, uninstall-hooks) |
|
|
339
390
|
| LLM integration | Built-in (Ollama, Claude, OpenAI, Azure) | None (delegates to Claude Code) |
|
|
340
391
|
| Chat sessions | Yes | No |
|
|
341
392
|
| Visualizer | D3.js HTML + SVG | D3.js HTML (`view` opens in browser, `--tree` for text) |
|