@optave/codegraph 2.2.0 → 2.2.1
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.
- package/README.md +39 -15
- package/package.json +5 -5
- package/src/cli.js +3 -3
- package/src/config.js +1 -1
- package/src/embedder.js +1 -1
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ Most code graph tools make you choose: **fast local analysis with no AI, or powe
|
|
|
93
93
|
| **⚡** | **Always-fresh graph** | Three-tier change detection: journal (O(changed)) → mtime+size (O(n) stats) → hash (O(changed) reads). Sub-second rebuilds even on large codebases. Competitors re-index everything from scratch; Merkle-tree approaches still require O(n) filesystem scanning |
|
|
94
94
|
| **🔓** | **Zero-cost core, LLM-enhanced when you want** | Full graph analysis with no API keys, no accounts, no cost. Optionally bring your own LLM provider for richer embeddings and AI-powered search — your code only goes to the provider you already chose |
|
|
95
95
|
| **🔬** | **Function-level, not just files** | Traces `handleAuth()` → `validateToken()` → `decryptJWT()` and shows 14 callers across 9 files break if `decryptJWT` changes |
|
|
96
|
-
| **🤖** | **Built for AI agents** | 17-tool [MCP server](https://modelcontextprotocol.io/) — AI assistants
|
|
96
|
+
| **🤖** | **Built for AI agents** | 17-tool [MCP server](https://modelcontextprotocol.io/) with `context` and `explain` compound commands — AI assistants get full function context in one call. Single-repo by default, your code doesn't leak to other projects |
|
|
97
97
|
| **🌐** | **Multi-language, one CLI** | JS/TS + Python + Go + Rust + Java + C# + PHP + Ruby + HCL in a single graph — no juggling Madge, pyan, and cflow |
|
|
98
98
|
| **💥** | **Git diff impact** | `codegraph diff-impact` shows changed functions, their callers, and full blast radius — ships with a GitHub Actions workflow |
|
|
99
99
|
| **🧠** | **Semantic search** | Local embeddings by default, LLM-powered embeddings when opted in — multi-query with RRF ranking via `"auth; token; JWT"` |
|
|
@@ -180,12 +180,15 @@ codegraph deps src/index.ts # file-level import/export map
|
|
|
180
180
|
|
|
181
181
|
| | Feature | Description |
|
|
182
182
|
|---|---|---|
|
|
183
|
-
| 🔍 | **Symbol search** | Find any function, class, or method by name
|
|
183
|
+
| 🔍 | **Symbol search** | Find any function, class, or method by name — exact match priority, relevance scoring, `--file` and `--kind` filters |
|
|
184
184
|
| 📁 | **File dependencies** | See what a file imports and what imports it |
|
|
185
185
|
| 💥 | **Impact analysis** | Trace every file affected by a change (transitive) |
|
|
186
|
-
| 🧬 | **Function-level tracing** | Call chains, caller trees, and function-level impact |
|
|
186
|
+
| 🧬 | **Function-level tracing** | Call chains, caller trees, and function-level impact with qualified call resolution |
|
|
187
|
+
| 🎯 | **Deep context** | `context` gives AI agents source, deps, callers, signature, and tests for a function in one call; `explain` gives structural summaries of files or functions |
|
|
188
|
+
| 📍 | **Fast lookup** | `where` shows exactly where a symbol is defined and used — minimal, fast |
|
|
187
189
|
| 📊 | **Diff impact** | Parse `git diff`, find overlapping functions, trace their callers |
|
|
188
190
|
| 🗺️ | **Module map** | Bird's-eye view of your most-connected files |
|
|
191
|
+
| 🏗️ | **Structure & hotspots** | Directory cohesion scores, fan-in/fan-out hotspot detection, module boundaries |
|
|
189
192
|
| 🔄 | **Cycle detection** | Find circular dependencies at file or function level |
|
|
190
193
|
| 📤 | **Export** | DOT (Graphviz), Mermaid, and JSON graph export |
|
|
191
194
|
| 🧠 | **Semantic search** | Embeddings-powered natural language search with multi-query RRF ranking |
|
|
@@ -210,7 +213,19 @@ codegraph watch [dir] # Watch for changes, update graph incrementally
|
|
|
210
213
|
codegraph query <name> # Find a symbol — shows callers and callees
|
|
211
214
|
codegraph deps <file> # File imports/exports
|
|
212
215
|
codegraph map # Top 20 most-connected files
|
|
213
|
-
codegraph map -n 50
|
|
216
|
+
codegraph map -n 50 --no-tests # Top 50, excluding test files
|
|
217
|
+
codegraph where <name> # Where is a symbol defined and used?
|
|
218
|
+
codegraph where --file src/db.js # List symbols, imports, exports for a file
|
|
219
|
+
codegraph stats # Graph health: nodes, edges, languages, quality score
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Deep Context (AI-Optimized)
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
codegraph context <name> # Full context: source, deps, callers, signature, tests
|
|
226
|
+
codegraph context <name> --depth 2 --no-tests # Include callee source 2 levels deep
|
|
227
|
+
codegraph explain <file> # Structural summary: public API, internals, data flow
|
|
228
|
+
codegraph explain <function> # Function summary: signature, calls, callers, tests
|
|
214
229
|
```
|
|
215
230
|
|
|
216
231
|
### Impact Analysis
|
|
@@ -225,6 +240,14 @@ codegraph diff-impact --staged # Impact of staged changes
|
|
|
225
240
|
codegraph diff-impact HEAD~3 # Impact vs a specific ref
|
|
226
241
|
```
|
|
227
242
|
|
|
243
|
+
### Structure & Hotspots
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
codegraph structure # Directory overview with cohesion scores
|
|
247
|
+
codegraph hotspots # Files with extreme fan-in, fan-out, or density
|
|
248
|
+
codegraph hotspots --metric coupling --level directory --no-tests
|
|
249
|
+
```
|
|
250
|
+
|
|
228
251
|
### Export & Visualization
|
|
229
252
|
|
|
230
253
|
```bash
|
|
@@ -268,9 +291,9 @@ A single trailing semicolon is ignored (falls back to single-query mode). The `-
|
|
|
268
291
|
| `minilm` | all-MiniLM-L6-v2 | 384 | ~23 MB | Apache-2.0 | Fastest, good for quick iteration |
|
|
269
292
|
| `jina-small` | jina-embeddings-v2-small-en | 512 | ~33 MB | Apache-2.0 | Better quality, still small |
|
|
270
293
|
| `jina-base` | jina-embeddings-v2-base-en | 768 | ~137 MB | Apache-2.0 | High quality, 8192 token context |
|
|
271
|
-
| `jina-code`
|
|
294
|
+
| `jina-code` | jina-embeddings-v2-base-code | 768 | ~137 MB | Apache-2.0 | Best for code search, trained on code+text (requires HF token) |
|
|
272
295
|
| `nomic` | nomic-embed-text-v1 | 768 | ~137 MB | Apache-2.0 | Good quality, 8192 context |
|
|
273
|
-
| `nomic-v1.5` | nomic-embed-text-v1.5 | 768 | ~137 MB | Apache-2.0 | Improved nomic, Matryoshka dimensions |
|
|
296
|
+
| `nomic-v1.5` (default) | nomic-embed-text-v1.5 | 768 | ~137 MB | Apache-2.0 | **Improved nomic, Matryoshka dimensions** |
|
|
274
297
|
| `bge-large` | bge-large-en-v1.5 | 1024 | ~335 MB | MIT | Best general retrieval, top MTEB scores |
|
|
275
298
|
|
|
276
299
|
The model used during `embed` is stored in the database, so `search` auto-detects it — no need to pass `--model` when searching.
|
|
@@ -304,13 +327,13 @@ By default, the MCP server only exposes the local project's graph. AI agents can
|
|
|
304
327
|
| Flag | Description |
|
|
305
328
|
|---|---|
|
|
306
329
|
| `-d, --db <path>` | Custom path to `graph.db` |
|
|
307
|
-
| `-T, --no-tests` | Exclude `.test.`, `.spec.`, `__test__` files |
|
|
330
|
+
| `-T, --no-tests` | Exclude `.test.`, `.spec.`, `__test__` files (available on `fn`, `fn-impact`, `context`, `explain`, `where`, `diff-impact`, `search`, `map`, `hotspots`, `deps`, `impact`) |
|
|
308
331
|
| `--depth <n>` | Transitive trace depth (default varies by command) |
|
|
309
332
|
| `-j, --json` | Output as JSON |
|
|
310
333
|
| `-v, --verbose` | Enable debug output |
|
|
311
334
|
| `--engine <engine>` | Parser engine: `native`, `wasm`, or `auto` (default: `auto`) |
|
|
312
|
-
| `-k, --kind <kind>` | Filter by kind: `function`, `method`, `class`, `struct`, `enum`, `trait`, `record`, `module` (search) |
|
|
313
|
-
|
|
|
335
|
+
| `-k, --kind <kind>` | Filter by kind: `function`, `method`, `class`, `struct`, `enum`, `trait`, `record`, `module` (`fn`, `context`, `search`) |
|
|
336
|
+
| `-f, --file <path>` | Scope to a specific file (`fn`, `context`, `where`) |
|
|
314
337
|
| `--rrf-k <n>` | RRF smoothing constant for multi-query search (default 60) |
|
|
315
338
|
|
|
316
339
|
## 🌐 Language Support
|
|
@@ -361,18 +384,19 @@ Both engines produce identical output. Use `--engine native|wasm|auto` to contro
|
|
|
361
384
|
|
|
362
385
|
### Call Resolution
|
|
363
386
|
|
|
364
|
-
Calls are resolved with
|
|
387
|
+
Calls are resolved with **qualified resolution** — method calls (`obj.method()`) are distinguished from standalone function calls, and built-in receivers (`console`, `Math`, `JSON`, `Array`, `Promise`, etc.) are filtered out automatically. Import scope is respected: a call to `foo()` only resolves to functions that are actually imported or defined in the same file, eliminating false positives from name collisions.
|
|
365
388
|
|
|
366
389
|
| Priority | Source | Confidence |
|
|
367
390
|
|---|---|---|
|
|
368
391
|
| 1 | **Import-aware** — `import { foo } from './bar'` → link to `bar` | `1.0` |
|
|
369
392
|
| 2 | **Same-file** — definitions in the current file | `1.0` |
|
|
370
|
-
| 3 | **Same directory** — definitions in sibling files | `0.7` |
|
|
371
|
-
| 4 | **Same parent directory** — definitions in sibling dirs | `0.5` |
|
|
372
|
-
| 5 | **
|
|
373
|
-
|
|
393
|
+
| 3 | **Same directory** — definitions in sibling files (standalone calls only) | `0.7` |
|
|
394
|
+
| 4 | **Same parent directory** — definitions in sibling dirs (standalone calls only) | `0.5` |
|
|
395
|
+
| 5 | **Method hierarchy** — resolved through `extends`/`implements` | varies |
|
|
396
|
+
|
|
397
|
+
Method calls on unknown receivers skip global fallback entirely — `stmt.run()` will never resolve to a standalone `run` function in another file. Duplicate caller/callee edges are deduplicated automatically. Dynamic patterns like `fn.call()`, `fn.apply()`, `fn.bind()`, and `obj["method"]()` are also detected on a best-effort basis.
|
|
374
398
|
|
|
375
|
-
|
|
399
|
+
Codegraph also extracts symbols from common callback patterns: Commander `.command().action()` callbacks (as `command:build`), Express route handlers (as `route:GET /api/users`), and event emitter listeners (as `event:data`).
|
|
376
400
|
|
|
377
401
|
## 📊 Performance
|
|
378
402
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optave/codegraph",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Local code graph CLI — parse codebases with tree-sitter, build dependency graphs, query them",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"optionalDependencies": {
|
|
62
62
|
"@huggingface/transformers": "^3.8.1",
|
|
63
63
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
64
|
-
"@optave/codegraph-darwin-arm64": "2.2.
|
|
65
|
-
"@optave/codegraph-darwin-x64": "2.2.
|
|
66
|
-
"@optave/codegraph-linux-x64-gnu": "2.2.
|
|
67
|
-
"@optave/codegraph-win32-x64-msvc": "2.2.
|
|
64
|
+
"@optave/codegraph-darwin-arm64": "2.2.1",
|
|
65
|
+
"@optave/codegraph-darwin-x64": "2.2.1",
|
|
66
|
+
"@optave/codegraph-linux-x64-gnu": "2.2.1",
|
|
67
|
+
"@optave/codegraph-win32-x64-msvc": "2.2.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@biomejs/biome": "^2.4.4",
|
package/src/cli.js
CHANGED
|
@@ -374,7 +374,7 @@ program
|
|
|
374
374
|
.action(() => {
|
|
375
375
|
console.log('\nAvailable embedding models:\n');
|
|
376
376
|
for (const [key, config] of Object.entries(MODELS)) {
|
|
377
|
-
const def = key === '
|
|
377
|
+
const def = key === 'nomic-v1.5' ? ' (default)' : '';
|
|
378
378
|
console.log(` ${key.padEnd(12)} ${String(config.dim).padStart(4)}d ${config.desc}${def}`);
|
|
379
379
|
}
|
|
380
380
|
console.log('\nUsage: codegraph embed --model <name>');
|
|
@@ -388,8 +388,8 @@ program
|
|
|
388
388
|
)
|
|
389
389
|
.option(
|
|
390
390
|
'-m, --model <name>',
|
|
391
|
-
'Embedding model: minilm, jina-small, jina-base, jina-code
|
|
392
|
-
'
|
|
391
|
+
'Embedding model: minilm, jina-small, jina-base, jina-code, nomic, nomic-v1.5 (default), bge-large. Run `codegraph models` for details',
|
|
392
|
+
'nomic-v1.5',
|
|
393
393
|
)
|
|
394
394
|
.action(async (dir, opts) => {
|
|
395
395
|
const root = path.resolve(dir || '.');
|
package/src/config.js
CHANGED
|
@@ -19,7 +19,7 @@ export const DEFAULTS = {
|
|
|
19
19
|
defaultDepth: 3,
|
|
20
20
|
defaultLimit: 20,
|
|
21
21
|
},
|
|
22
|
-
embeddings: { model: '
|
|
22
|
+
embeddings: { model: 'nomic-v1.5', llmProvider: null },
|
|
23
23
|
llm: { provider: null, model: null, baseUrl: null, apiKey: null, apiKeyCommand: null },
|
|
24
24
|
search: { defaultMinScore: 0.2, rrfK: 60, topK: 15 },
|
|
25
25
|
ci: { failOnCycles: false, impactThreshold: null },
|