ctxgraph-code 0.2.1__tar.gz → 0.3.0__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.2.1 → ctxgraph_code-0.3.0}/PKG-INFO +77 -29
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/README.md +76 -28
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/pyproject.toml +1 -1
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/cli.py +153 -21
- ctxgraph_code-0.3.0/src/ctxgraph_code/config/build_status.py +93 -0
- ctxgraph_code-0.3.0/src/ctxgraph_code/graph/builder.py +333 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/graph/storage.py +44 -30
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code.egg-info/PKG-INFO +77 -29
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code.egg-info/SOURCES.txt +1 -0
- ctxgraph_code-0.2.1/src/ctxgraph_code/graph/builder.py +0 -204
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/setup.cfg +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/__main__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/analyzers/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/analyzers/python/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/analyzers/python/importer.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/analyzers/python/semantic.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/analyzers/python/symbols.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/config/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/config/global_paths.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/config/init.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/config/settings.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/exclude/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/exclude/patterns.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/graph/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/graph/models.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/graph/query.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/render.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/view/__init__.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code/view/visualizer.py +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code.egg-info/dependency_links.txt +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code.egg-info/entry_points.txt +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/src/ctxgraph_code.egg-info/requires.txt +0 -0
- {ctxgraph_code-0.2.1 → ctxgraph_code-0.3.0}/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.3.0
|
|
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
|
|
@@ -76,15 +76,23 @@ Interactive walkthrough — prompts for:
|
|
|
76
76
|
|
|
77
77
|
Does everything in one step:
|
|
78
78
|
1. Creates `.ctxgraph/config.toml` with your chosen extensions and excludes
|
|
79
|
-
2.
|
|
80
|
-
3.
|
|
79
|
+
2. Installs the `/ctxgraph-code` slash command globally (works in every Claude Code session)
|
|
80
|
+
3. Builds the knowledge graph from all matching files
|
|
81
81
|
|
|
82
|
-
Non-interactive mode
|
|
82
|
+
Non-interactive mode:
|
|
83
83
|
```bash
|
|
84
84
|
ctxgraph-code setup --extensions .py,.js,.ts --exclude tests/,examples/
|
|
85
85
|
ctxgraph-code setup -y # all defaults
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
Options:
|
|
89
|
+
- `--project-slash` — install slash command in project's `.claude/` instead of globally
|
|
90
|
+
- `--background` / `-b` — launch build in background and exit immediately (check with `build-status`)
|
|
91
|
+
- `--jobs` / `-j` — number of parallel workers (default: CPU count)
|
|
92
|
+
- `--incremental` / `-i` — only rebuild files that changed since last build
|
|
93
|
+
- `--verbose` / `-v` — show per-file progress
|
|
94
|
+
- `--no-summary` — skip docstring extraction for faster builds
|
|
95
|
+
|
|
88
96
|
### `init`
|
|
89
97
|
|
|
90
98
|
```bash
|
|
@@ -103,24 +111,27 @@ ctxgraph-code build --exclude tests/ --exclude *.generated.py
|
|
|
103
111
|
|
|
104
112
|
Scans all matching files in the project, runs AST analysis. Extensions are read from config (`.py` by default, or whatever was set in `setup`).
|
|
105
113
|
|
|
106
|
-
- **
|
|
107
|
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
114
|
+
**By default, builds a separate graph per top-level directory** (e.g., `src/`, `api/`, `tests/`) in parallel. This keeps each graph small and fast to query. Use `--dir <name>` on query commands to select one, or let it auto-detect from file paths.
|
|
115
|
+
|
|
116
|
+
- `--all` / `-a` — build a single combined graph instead of per-directory
|
|
117
|
+
- `--jobs` / `-j` — number of parallel workers (default: CPU count)
|
|
118
|
+
- `--incremental` / `-i` — only rebuild files that changed since last build
|
|
119
|
+
- `--verbose` / `-v` — show per-file progress
|
|
120
|
+
- `--no-summary` — skip docstring extraction for faster builds
|
|
111
121
|
|
|
112
|
-
Stores
|
|
122
|
+
Stores graphs in `.ctxgraph/graphs/<dir>.db` (per-directory) or `.ctxgraph/graph.db` (combined).
|
|
113
123
|
|
|
114
|
-
> The graph is a **static snapshot**. If code changes, run `ctxgraph-code build` again to refresh.
|
|
124
|
+
> The graph is a **static snapshot**. If code changes, run `ctxgraph-code build` again to refresh. Use `--incremental` to only reprocess changed files.
|
|
115
125
|
|
|
116
126
|
### `query`
|
|
117
127
|
|
|
118
128
|
```bash
|
|
119
129
|
ctxgraph-code query "user authentication"
|
|
120
130
|
ctxgraph-code query "database connection" --max 20
|
|
131
|
+
ctxgraph-code query "api routes" --dir src
|
|
121
132
|
```
|
|
122
133
|
|
|
123
|
-
Searches the graph by relevance scoring (name matches > summary matches > path matches) and expands to neighboring nodes via BFS up to depth 2.
|
|
134
|
+
Searches the graph by relevance scoring (name matches > summary matches > path matches) and expands to neighboring nodes via BFS up to depth 2. Use `--dir` to scope to a specific per-directory graph.
|
|
124
135
|
|
|
125
136
|
### `deps`
|
|
126
137
|
|
|
@@ -128,7 +139,7 @@ Searches the graph by relevance scoring (name matches > summary matches > path m
|
|
|
128
139
|
ctxgraph-code deps src/api/routes.py
|
|
129
140
|
```
|
|
130
141
|
|
|
131
|
-
Shows all relationships for a file: imports, imported-by, function calls, class definitions.
|
|
142
|
+
Shows all relationships for a file: imports, imported-by, function calls, class definitions. Auto-detects the per-directory graph from the file path.
|
|
132
143
|
|
|
133
144
|
### `usedby`
|
|
134
145
|
|
|
@@ -142,9 +153,10 @@ Shows every file that imports or calls something in the given file. Useful to un
|
|
|
142
153
|
|
|
143
154
|
```bash
|
|
144
155
|
ctxgraph-code overview
|
|
156
|
+
ctxgraph-code overview --dir src
|
|
145
157
|
```
|
|
146
158
|
|
|
147
|
-
Prints the project structure: every file with its summary and top-level symbols.
|
|
159
|
+
Prints the project structure: every file with its summary and top-level symbols. Use `--dir` to scope to a per-directory graph.
|
|
148
160
|
|
|
149
161
|
### `symbols`
|
|
150
162
|
|
|
@@ -181,10 +193,28 @@ Use `--tree` for a terminal-friendly text view of the directory hierarchy with s
|
|
|
181
193
|
|
|
182
194
|
```bash
|
|
183
195
|
ctxgraph-code info
|
|
196
|
+
ctxgraph-code info --dir src
|
|
184
197
|
```
|
|
185
198
|
|
|
186
199
|
Shows graph statistics: node/edge counts, type distribution, build time.
|
|
187
200
|
|
|
201
|
+
### `install-slash`
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
ctxgraph-code install-slash
|
|
205
|
+
ctxgraph-code install-slash --project-slash # project-local instead of global
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Install or update the `/ctxgraph-code` slash command for Claude Code. By default installs globally so it works in every Claude Code session. Use `--project-slash` to install in the project's `.claude/commands/` directory instead.
|
|
209
|
+
|
|
210
|
+
### `build-status`
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
ctxgraph-code build-status
|
|
214
|
+
```
|
|
215
|
+
|
|
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
|
+
|
|
188
218
|
---
|
|
189
219
|
|
|
190
220
|
## How It Works
|
|
@@ -192,7 +222,7 @@ Shows graph statistics: node/edge counts, type distribution, build time.
|
|
|
192
222
|
```
|
|
193
223
|
Python files ──AST──> Import/Symbol/Call analysis ──> SQLite graph.db
|
|
194
224
|
│
|
|
195
|
-
Claude Code ──/ctxgraph-code──> CLI query/deps/overview
|
|
225
|
+
Claude Code ──/ctxgraph-code──> CLI query/deps/overview <───┘
|
|
196
226
|
```
|
|
197
227
|
|
|
198
228
|
1. **Build phase**: `ctxgraph-code build` parses every `.py` file with Python's `ast` module. It extracts imports, class/function definitions, function calls, and docstrings. The result is a graph of **nodes** (files, classes, functions) and **edges** (imports, defines, extends, calls) stored in SQLite.
|
|
@@ -226,25 +256,43 @@ Edge weights: `imports=1.0`, `defines=1.0`, `extends=0.8`, `calls=0.7`
|
|
|
226
256
|
|
|
227
257
|
---
|
|
228
258
|
|
|
229
|
-
##
|
|
259
|
+
## Performance
|
|
230
260
|
|
|
231
|
-
|
|
261
|
+
`ctxgraph-code` includes several optimizations for large codebases:
|
|
232
262
|
|
|
233
|
-
|
|
263
|
+
| Optimization | Details |
|
|
264
|
+
|---|---|
|
|
265
|
+
| **Parallel builds** | Per-directory graphs build concurrently via `ThreadPoolExecutor` |
|
|
266
|
+
| **Multiprocessing** | Combined graphs split files across CPU cores via `multiprocessing.Pool` |
|
|
267
|
+
| **`--jobs`** | Control parallelism level (default: CPU count) |
|
|
268
|
+
| **Incremental builds** | `--incremental` caches file mtimes, only reprocesses changed files |
|
|
269
|
+
| **Trivial file skip** | `_quick_scan()` pre-checks before AST parse for files with no imports/classes/functions |
|
|
270
|
+
| **Cached excludes** | `lru_cache` on `should_exclude()` during `os.walk` |
|
|
271
|
+
| **Batch SQLite inserts** | `executemany` instead of per-row `INSERT` statements |
|
|
272
|
+
| **`--no-summary`** | Skips docstring extraction (fastest rebuilds) |
|
|
273
|
+
| **`--background`** | Detach build process and continue working immediately |
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Using with Claude Code
|
|
278
|
+
|
|
279
|
+
After `ctxgraph-code setup`, the `/ctxgraph-code` slash command is installed globally by default — it works in every Claude Code session. Claude sees:
|
|
234
280
|
|
|
235
281
|
```
|
|
236
282
|
# ctxgraph-code: Code Relationship Graph
|
|
237
283
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
- ctxgraph-code
|
|
244
|
-
- ctxgraph-code
|
|
245
|
-
- ctxgraph-code
|
|
246
|
-
- ctxgraph-code
|
|
247
|
-
- ctxgraph-code
|
|
284
|
+
**First time in this project?** Tell the user to run `ctxgraph-code setup`.
|
|
285
|
+
**Graph needs refresh?** Tell the user to run `ctxgraph-code build`.
|
|
286
|
+
**Available graphs:** src api tests
|
|
287
|
+
|
|
288
|
+
**Commands:**
|
|
289
|
+
- `ctxgraph-code query "terms"` -- Find relevant files, classes, and functions
|
|
290
|
+
- `ctxgraph-code deps <path>` -- Show what a file imports and what calls it
|
|
291
|
+
- `ctxgraph-code usedby <path>` -- Show what depends on a file
|
|
292
|
+
- `ctxgraph-code overview --dir <name>` -- Show project structure for a specific graph
|
|
293
|
+
- `ctxgraph-code symbols <path>` -- List classes/functions defined in a file
|
|
294
|
+
- `ctxgraph-code context "task"` -- Generate a focused context summary
|
|
295
|
+
- `ctxgraph-code view --dir <name>` -- Visualize a graph interactively
|
|
248
296
|
```
|
|
249
297
|
|
|
250
298
|
Claude then uses these commands as needed during the conversation.
|
|
@@ -287,7 +335,7 @@ Built-in default exclusion patterns (always applied): `__pycache__`, `*.pyc`, `.
|
|
|
287
335
|
|
|
288
336
|
| Feature | ctxgraph | ctxgraph-code |
|
|
289
337
|
|---------|----------|---------------|
|
|
290
|
-
| CLI commands | 9
|
|
338
|
+
| CLI commands | 9+ | 12 (init, build, query, deps, usedby, overview, symbols, context, setup, view, info, install-slash, build-status) |
|
|
291
339
|
| LLM integration | Built-in (Ollama, Claude, OpenAI, Azure) | None (delegates to Claude Code) |
|
|
292
340
|
| Chat sessions | Yes | No |
|
|
293
341
|
| Visualizer | D3.js HTML + SVG | D3.js HTML (`view` opens in browser, `--tree` for text) |
|
|
@@ -53,15 +53,23 @@ Interactive walkthrough — prompts for:
|
|
|
53
53
|
|
|
54
54
|
Does everything in one step:
|
|
55
55
|
1. Creates `.ctxgraph/config.toml` with your chosen extensions and excludes
|
|
56
|
-
2.
|
|
57
|
-
3.
|
|
56
|
+
2. Installs the `/ctxgraph-code` slash command globally (works in every Claude Code session)
|
|
57
|
+
3. Builds the knowledge graph from all matching files
|
|
58
58
|
|
|
59
|
-
Non-interactive mode
|
|
59
|
+
Non-interactive mode:
|
|
60
60
|
```bash
|
|
61
61
|
ctxgraph-code setup --extensions .py,.js,.ts --exclude tests/,examples/
|
|
62
62
|
ctxgraph-code setup -y # all defaults
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
Options:
|
|
66
|
+
- `--project-slash` — install slash command in project's `.claude/` instead of globally
|
|
67
|
+
- `--background` / `-b` — launch build in background and exit immediately (check with `build-status`)
|
|
68
|
+
- `--jobs` / `-j` — number of parallel workers (default: CPU count)
|
|
69
|
+
- `--incremental` / `-i` — only rebuild files that changed since last build
|
|
70
|
+
- `--verbose` / `-v` — show per-file progress
|
|
71
|
+
- `--no-summary` — skip docstring extraction for faster builds
|
|
72
|
+
|
|
65
73
|
### `init`
|
|
66
74
|
|
|
67
75
|
```bash
|
|
@@ -80,24 +88,27 @@ ctxgraph-code build --exclude tests/ --exclude *.generated.py
|
|
|
80
88
|
|
|
81
89
|
Scans all matching files in the project, runs AST analysis. Extensions are read from config (`.py` by default, or whatever was set in `setup`).
|
|
82
90
|
|
|
83
|
-
- **
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
91
|
+
**By default, builds a separate graph per top-level directory** (e.g., `src/`, `api/`, `tests/`) in parallel. This keeps each graph small and fast to query. Use `--dir <name>` on query commands to select one, or let it auto-detect from file paths.
|
|
92
|
+
|
|
93
|
+
- `--all` / `-a` — build a single combined graph instead of per-directory
|
|
94
|
+
- `--jobs` / `-j` — number of parallel workers (default: CPU count)
|
|
95
|
+
- `--incremental` / `-i` — only rebuild files that changed since last build
|
|
96
|
+
- `--verbose` / `-v` — show per-file progress
|
|
97
|
+
- `--no-summary` — skip docstring extraction for faster builds
|
|
88
98
|
|
|
89
|
-
Stores
|
|
99
|
+
Stores graphs in `.ctxgraph/graphs/<dir>.db` (per-directory) or `.ctxgraph/graph.db` (combined).
|
|
90
100
|
|
|
91
|
-
> The graph is a **static snapshot**. If code changes, run `ctxgraph-code build` again to refresh.
|
|
101
|
+
> The graph is a **static snapshot**. If code changes, run `ctxgraph-code build` again to refresh. Use `--incremental` to only reprocess changed files.
|
|
92
102
|
|
|
93
103
|
### `query`
|
|
94
104
|
|
|
95
105
|
```bash
|
|
96
106
|
ctxgraph-code query "user authentication"
|
|
97
107
|
ctxgraph-code query "database connection" --max 20
|
|
108
|
+
ctxgraph-code query "api routes" --dir src
|
|
98
109
|
```
|
|
99
110
|
|
|
100
|
-
Searches the graph by relevance scoring (name matches > summary matches > path matches) and expands to neighboring nodes via BFS up to depth 2.
|
|
111
|
+
Searches the graph by relevance scoring (name matches > summary matches > path matches) and expands to neighboring nodes via BFS up to depth 2. Use `--dir` to scope to a specific per-directory graph.
|
|
101
112
|
|
|
102
113
|
### `deps`
|
|
103
114
|
|
|
@@ -105,7 +116,7 @@ Searches the graph by relevance scoring (name matches > summary matches > path m
|
|
|
105
116
|
ctxgraph-code deps src/api/routes.py
|
|
106
117
|
```
|
|
107
118
|
|
|
108
|
-
Shows all relationships for a file: imports, imported-by, function calls, class definitions.
|
|
119
|
+
Shows all relationships for a file: imports, imported-by, function calls, class definitions. Auto-detects the per-directory graph from the file path.
|
|
109
120
|
|
|
110
121
|
### `usedby`
|
|
111
122
|
|
|
@@ -119,9 +130,10 @@ Shows every file that imports or calls something in the given file. Useful to un
|
|
|
119
130
|
|
|
120
131
|
```bash
|
|
121
132
|
ctxgraph-code overview
|
|
133
|
+
ctxgraph-code overview --dir src
|
|
122
134
|
```
|
|
123
135
|
|
|
124
|
-
Prints the project structure: every file with its summary and top-level symbols.
|
|
136
|
+
Prints the project structure: every file with its summary and top-level symbols. Use `--dir` to scope to a per-directory graph.
|
|
125
137
|
|
|
126
138
|
### `symbols`
|
|
127
139
|
|
|
@@ -158,10 +170,28 @@ Use `--tree` for a terminal-friendly text view of the directory hierarchy with s
|
|
|
158
170
|
|
|
159
171
|
```bash
|
|
160
172
|
ctxgraph-code info
|
|
173
|
+
ctxgraph-code info --dir src
|
|
161
174
|
```
|
|
162
175
|
|
|
163
176
|
Shows graph statistics: node/edge counts, type distribution, build time.
|
|
164
177
|
|
|
178
|
+
### `install-slash`
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
ctxgraph-code install-slash
|
|
182
|
+
ctxgraph-code install-slash --project-slash # project-local instead of global
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Install or update the `/ctxgraph-code` slash command for Claude Code. By default installs globally so it works in every Claude Code session. Use `--project-slash` to install in the project's `.claude/commands/` directory instead.
|
|
186
|
+
|
|
187
|
+
### `build-status`
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
ctxgraph-code build-status
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
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.
|
|
194
|
+
|
|
165
195
|
---
|
|
166
196
|
|
|
167
197
|
## How It Works
|
|
@@ -169,7 +199,7 @@ Shows graph statistics: node/edge counts, type distribution, build time.
|
|
|
169
199
|
```
|
|
170
200
|
Python files ──AST──> Import/Symbol/Call analysis ──> SQLite graph.db
|
|
171
201
|
│
|
|
172
|
-
Claude Code ──/ctxgraph-code──> CLI query/deps/overview
|
|
202
|
+
Claude Code ──/ctxgraph-code──> CLI query/deps/overview <───┘
|
|
173
203
|
```
|
|
174
204
|
|
|
175
205
|
1. **Build phase**: `ctxgraph-code build` parses every `.py` file with Python's `ast` module. It extracts imports, class/function definitions, function calls, and docstrings. The result is a graph of **nodes** (files, classes, functions) and **edges** (imports, defines, extends, calls) stored in SQLite.
|
|
@@ -203,25 +233,43 @@ Edge weights: `imports=1.0`, `defines=1.0`, `extends=0.8`, `calls=0.7`
|
|
|
203
233
|
|
|
204
234
|
---
|
|
205
235
|
|
|
206
|
-
##
|
|
236
|
+
## Performance
|
|
207
237
|
|
|
208
|
-
|
|
238
|
+
`ctxgraph-code` includes several optimizations for large codebases:
|
|
209
239
|
|
|
210
|
-
|
|
240
|
+
| Optimization | Details |
|
|
241
|
+
|---|---|
|
|
242
|
+
| **Parallel builds** | Per-directory graphs build concurrently via `ThreadPoolExecutor` |
|
|
243
|
+
| **Multiprocessing** | Combined graphs split files across CPU cores via `multiprocessing.Pool` |
|
|
244
|
+
| **`--jobs`** | Control parallelism level (default: CPU count) |
|
|
245
|
+
| **Incremental builds** | `--incremental` caches file mtimes, only reprocesses changed files |
|
|
246
|
+
| **Trivial file skip** | `_quick_scan()` pre-checks before AST parse for files with no imports/classes/functions |
|
|
247
|
+
| **Cached excludes** | `lru_cache` on `should_exclude()` during `os.walk` |
|
|
248
|
+
| **Batch SQLite inserts** | `executemany` instead of per-row `INSERT` statements |
|
|
249
|
+
| **`--no-summary`** | Skips docstring extraction (fastest rebuilds) |
|
|
250
|
+
| **`--background`** | Detach build process and continue working immediately |
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Using with Claude Code
|
|
255
|
+
|
|
256
|
+
After `ctxgraph-code setup`, the `/ctxgraph-code` slash command is installed globally by default — it works in every Claude Code session. Claude sees:
|
|
211
257
|
|
|
212
258
|
```
|
|
213
259
|
# ctxgraph-code: Code Relationship Graph
|
|
214
260
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
- ctxgraph-code
|
|
221
|
-
- ctxgraph-code
|
|
222
|
-
- ctxgraph-code
|
|
223
|
-
- ctxgraph-code
|
|
224
|
-
- ctxgraph-code
|
|
261
|
+
**First time in this project?** Tell the user to run `ctxgraph-code setup`.
|
|
262
|
+
**Graph needs refresh?** Tell the user to run `ctxgraph-code build`.
|
|
263
|
+
**Available graphs:** src api tests
|
|
264
|
+
|
|
265
|
+
**Commands:**
|
|
266
|
+
- `ctxgraph-code query "terms"` -- Find relevant files, classes, and functions
|
|
267
|
+
- `ctxgraph-code deps <path>` -- Show what a file imports and what calls it
|
|
268
|
+
- `ctxgraph-code usedby <path>` -- Show what depends on a file
|
|
269
|
+
- `ctxgraph-code overview --dir <name>` -- Show project structure for a specific graph
|
|
270
|
+
- `ctxgraph-code symbols <path>` -- List classes/functions defined in a file
|
|
271
|
+
- `ctxgraph-code context "task"` -- Generate a focused context summary
|
|
272
|
+
- `ctxgraph-code view --dir <name>` -- Visualize a graph interactively
|
|
225
273
|
```
|
|
226
274
|
|
|
227
275
|
Claude then uses these commands as needed during the conversation.
|
|
@@ -264,7 +312,7 @@ Built-in default exclusion patterns (always applied): `__pycache__`, `*.pyc`, `.
|
|
|
264
312
|
|
|
265
313
|
| Feature | ctxgraph | ctxgraph-code |
|
|
266
314
|
|---------|----------|---------------|
|
|
267
|
-
| CLI commands | 9
|
|
315
|
+
| CLI commands | 9+ | 12 (init, build, query, deps, usedby, overview, symbols, context, setup, view, info, install-slash, build-status) |
|
|
268
316
|
| LLM integration | Built-in (Ollama, Claude, OpenAI, Azure) | None (delegates to Claude Code) |
|
|
269
317
|
| Chat sessions | Yes | No |
|
|
270
318
|
| Visualizer | D3.js HTML + SVG | D3.js HTML (`view` opens in browser, `--tree` for text) |
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ctxgraph-code"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Code knowledge graph for Claude Code. Build a relationship graph of your Python codebase and query it during coding sessions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|