@vohongtho.infotech/code-intel 0.8.0 → 1.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Code Intelligence Platform
2
2
 
3
- [![npm version](https://img.shields.io/badge/npm-v0.8.0-blue)](https://www.npmjs.com/package/@vohongtho.infotech/code-intel)
3
+ [![npm version](https://img.shields.io/badge/npm-v1.0.0-blue)](https://www.npmjs.com/package/@vohongtho.infotech/code-intel)
4
4
 
5
5
  A static code analysis platform that builds a **Knowledge Graph** from your source code and makes it explorable through a Web UI, HTTP API, CLI, and MCP server.
6
6
 
@@ -27,28 +27,88 @@ A static code analysis platform that builds a **Knowledge Graph** from your sour
27
27
  - **Complexity Metrics** — `code-intel complexity --top N` ranks functions by cyclomatic + cognitive complexity; `complexity_hotspots` MCP tool
28
28
  - **Test Coverage Gaps** — `code-intel coverage` lists untested exported symbols sorted by blast radius; `--threshold <pct>` fails CI if below target
29
29
  - **Deprecated API Detection** — `code-intel deprecated` finds usages of `@deprecated` JSDoc, `@Deprecated` (Java), `#[deprecated]` (Rust), and built-in Node.js deprecated APIs
30
- - **AI Context Files** — auto-generates `AGENTS.md`, `CLAUDE.md`, `.github/copilot-instructions.md`, `.cursor/rules/code-intel.mdc`, and `.kiro/steering/code-intel.md` after every analysis — supporting Amp, Claude Code, Codex, Copilot, Cursor, Aider, Gemini, Kiro, Trae, Hermes, Factory, OpenCode, Pi, Antigravity, OpenClaw, and more
30
+ - **CLI** — analyze, serve, watch, query, search, inspect, impact, health commands with animated `█░` progress bars and braille spinners
31
31
  - **Multi-language** — TypeScript, JavaScript, Python, Java, Go, C, C++, C#, Rust, PHP, Ruby, Swift, Kotlin, Dart (14 languages via tree-sitter AST)
32
- - **Incremental Analysis** — `--incremental` re-parses only changed files; 10k-file repo / 3 changes: 288ms
33
- - **Parallel Analysis** — `--parallel` runs parse + resolve phases on worker threads for large repos
34
- - **Structured Logging** — winston-based logger with daily-rotating log files, sensitive-data masking, and configurable log levels
32
+ - **Incremental Analysis** — `--incremental` flag re-parses only git-changed/mtime-changed files; 10k-file repo with 3 changes: 288ms
33
+ - **Parallel Analysis** — `--parallel` flag runs parse + resolve phases on worker threads for large repos
34
+ - **AI Context Files** — auto-generates `AGENTS.md`, `CLAUDE.md`, `.github/copilot-instructions.md`, `.cursor/rules/code-intel.mdc`, and `.kiro/steering/code-intel.md` after every analysis with live stats, CLI reference, development workflows, and skill links — supporting Amp, Claude Code, Codex, Copilot, Cursor, Aider, Gemini, Kiro, Trae, Hermes, Factory, OpenCode, Pi, Antigravity, OpenClaw, and more
35
+ - **Skill Files** — generates `.claude/skills/code-intel/` with per-cluster SKILL.md files (hot symbols, entry points, impact guidance) for AI assistants
36
+ - **Repository Groups** — multi-repo / monorepo service tracking with workspace auto-discovery (npm, pnpm, Nx, Turborepo), contract extraction (OpenAPI, GraphQL, Protobuf), type-aware similarity scoring, and cross-repo dependency detection
37
+ - **`.codeintelignore`** — exclude directories from analysis (like `.gitignore` but for code-intel)
38
+ - **Structured Logging** — winston-based logger with daily-rotating log files at `~/.code-intel/logs/`, sensitive-data masking, and configurable log levels
39
+ - **Performance** — parallel batch file I/O, shared file cache (zero double-reads), O(log n) binary-search enclosing-function lookup
40
+ - **`code-intel init` Wizard** _(v0.9)_ — interactive 5-step setup wizard; creates `~/.code-intel/config.json` with editor MCP registration, LLM provider, embeddings, auth mode, and port settings
41
+ - **Config Management CLI** _(v0.9)_ — `config get/set/list/validate/reset` with JSON Schema, `$ENV_VAR` expansion, and masked secret output
42
+ - **Better Error Messages** _(v0.9)_ — `CI-XXXX` error codes, actionable hints, `--debug` stack traces, startup prerequisite checks
43
+ - **Shell Completion** _(v0.9)_ — `code-intel completion bash|zsh|fish`; dynamic repo + group name completion; `setup --completion` auto-installs
44
+ - **VS Code Extension** _(v0.9)_ — symbol hover tooltips, Symbol Explorer panel, status bar freshness indicator, "Open in Graph" command, command palette integration
45
+ - **Self-Update** _(v0.9)_ — `code-intel update` checks npm registry; background version check on startup; `--no-update-check` to suppress
46
+ - **`--dry-run` flag** _(v0.9)_ — `analyze`, `clean`, `group sync` preview what would happen without side effects
47
+ - **`code-intel doctor`** _(v0.9)_ — full diagnostics: Node.js, git, config, registry, DB integrity, network; exit 1 on any failure
48
+ - **Lazy Graph Loading** _(v1.0)_ — `serve` starts in <2s for 10k-file repos; LRU node cache (5,000 nodes by default, `GRAPH_CACHE_SIZE` env var); background warm of high-blast-radius nodes
49
+ - **Pre-Built BM25 Index** _(v1.0)_ — inverted index built at analysis time; loaded into memory on `serve` startup; 2,000+ q/s throughput; incremental-only updates on re-index
50
+ - **Memory-Efficient Graph** _(v1.0)_ — `Int32Array`-packed adjacency + symbol interning = ≥30% memory reduction; `--max-memory <MB>` flag spills node content to DB
51
+ - **Pipeline Profiling** _(v1.0)_ — `analyze --profile` writes `.code-intel/profile.json`; per-phase heap memory captured; bottleneck warning if any phase >50% of total; verbose timing table
52
+ - **Load & Soak Tests** _(v1.0)_ — nightly CI load tests (1k/10k fixture repos), weekly soak tests (memory stability, watcher throughput), regression gate: >20% regression fails CI; `tests/perf/baseline.json` committed to repo
53
+ - **Graceful Degradation** _(v1.0)_ — `X-Stale`/`X-Stale-Since` headers on DB outage; LLM-unavailable summarize skip; MCP tool timeout → `{ truncated: true }`; watcher crash recovery; worker crash retry
35
54
 
36
55
  ---
37
56
 
38
57
  ## 🚀 Quick Start
39
58
 
40
- ### Install from npm _(recommended)_
59
+ ### Requirements
60
+
61
+ - **Node.js** 22+
62
+ - **npm** 10+
63
+
64
+ ---
65
+
66
+ ### Option A — Install globally from npm _(recommended)_
41
67
 
42
68
  ```bash
43
69
  npm install -g @vohongtho.infotech/code-intel
44
70
  ```
45
71
 
46
- > **Note:** You may see `npm warn ERESOLVE overriding peer dependency` warnings about `tree-sitter`. These are **harmless** — they relate to the native Node.js bindings which are not used. The CLI uses `web-tree-sitter` (WASM) exclusively. If you prefer a warning-free install, use:
47
- > ```bash
48
- > npm install -g @vohongtho.infotech/code-intel --legacy-peer-deps
49
- > ```
72
+ > **Note:** You may see `npm warn ERESOLVE overriding peer dependency` warnings about `tree-sitter`. These are **harmless** — they relate to native Node.js bindings that are not used; the CLI uses `web-tree-sitter` (WASM) exclusively. For a warning-free install, add `--legacy-peer-deps`.
73
+
74
+ Verify the installation:
75
+
76
+ ```bash
77
+ code-intel --version
78
+ ```
79
+
80
+ ---
81
+
82
+ ### Option B — Build from source
83
+
84
+ Use this if you want to develop, modify, or contribute to the platform.
85
+
86
+ **1. Clone the repository**
87
+
88
+ ```bash
89
+ git clone https://github.com/vohongtho/code-intel-platform.git
90
+ cd code-intel-platform
91
+ ```
92
+
93
+ **2. Install all workspace dependencies**
94
+
95
+ ```bash
96
+ npm install --legacy-peer-deps
97
+ ```
98
+
99
+ **3. Build all packages** (shared → core → web)
100
+
101
+ ```bash
102
+ npm run build
103
+ ```
104
+
105
+ This runs `tsup` for the core package (outputs to `code-intel/core/dist/`) and `vite` for the web UI (outputs to `code-intel/web/dist/`).
106
+
107
+ **4. Install the built CLI globally**
50
108
 
51
- The `code-intel` binary is placed in your `$PATH` automatically (via the `bin` field in `package.json`).
109
+ ```bash
110
+ npm install -g ./code-intel/core
111
+ ```
52
112
 
53
113
  Verify:
54
114
 
@@ -56,13 +116,143 @@ Verify:
56
116
  code-intel --version
57
117
  ```
58
118
 
59
- ### Build from source
119
+ > **Tip:** After making code changes, re-run `npm run build` — the CLI picks up the new build automatically since the global install points to the local `dist/` folder.
120
+
121
+ ---
122
+
123
+ ### Option C — Build locally & install globally _(CI / automation)_
124
+
125
+ Use this approach in CI pipelines, Docker images, or any environment where you need a clean, self-contained global install from local source without a persistent `node_modules` link.
126
+
127
+ **1. Clone & install dependencies**
60
128
 
61
129
  ```bash
130
+ git clone https://github.com/vohongtho/code-intel-platform.git
131
+ cd code-intel-platform
62
132
  npm install --legacy-peer-deps
133
+ ```
134
+
135
+ **2. Build all packages**
136
+
137
+ ```bash
63
138
  npm run build
64
139
  ```
65
140
 
141
+ **3. Pack the core package into a tarball**
142
+
143
+ ```bash
144
+ cd code-intel/core
145
+ npm pack
146
+ # produces: vohongtho.infotech-code-intel-0.1.4.tgz (version number may vary)
147
+ cd ../..
148
+ ```
149
+
150
+ **4. Install the tarball globally**
151
+
152
+ ```bash
153
+ npm install -g code-intel/core/vohongtho.infotech-code-intel-*.tgz
154
+ ```
155
+
156
+ **5. Verify**
157
+
158
+ ```bash
159
+ code-intel --version
160
+ ```
161
+
162
+ #### One-liner (copy-paste for CI scripts)
163
+
164
+ ```bash
165
+ git clone https://github.com/vohongtho/code-intel-platform.git && \
166
+ cd code-intel-platform && \
167
+ npm install --legacy-peer-deps && \
168
+ npm run build && \
169
+ npm pack --workspace=code-intel/core && \
170
+ npm install -g vohongtho.infotech-code-intel-*.tgz
171
+ ```
172
+
173
+ #### Docker example
174
+
175
+ ```dockerfile
176
+ FROM node:22-bookworm-slim
177
+
178
+ RUN git clone https://github.com/vohongtho/code-intel-platform.git /opt/code-intel && \
179
+ cd /opt/code-intel && \
180
+ npm install --legacy-peer-deps && \
181
+ npm run build && \
182
+ npm pack --workspace=code-intel/core && \
183
+ npm install -g vohongtho.infotech-code-intel-*.tgz && \
184
+ rm -rf /opt/code-intel
185
+
186
+ WORKDIR /workspace
187
+ ENTRYPOINT ["code-intel"]
188
+ ```
189
+
190
+ > **Why pack instead of `npm install -g ./code-intel/core`?**
191
+ > `npm pack` produces a standalone tarball containing only the published `files` (the `dist/` folder + `package.json`). This mirrors exactly what is published to npm and avoids bringing in dev symlinks or workspace hoisting artefacts.
192
+
193
+ ---
194
+
195
+ ### Analyze & Serve
196
+
197
+ ```bash
198
+ # First, analyze the project to build the index
199
+ code-intel analyze
200
+
201
+ # Then start the server (requires an existing index)
202
+ code-intel serve
203
+
204
+ # Or with a specific path and port
205
+ code-intel analyze ./my-project
206
+ code-intel serve ./my-project --port 4747
207
+ ```
208
+
209
+ Then open **http://localhost:4747** in your browser — the Web UI auto-connects and loads the graph.
210
+
211
+ ### After analysis
212
+
213
+ `code-intel analyze` automatically generates or updates:
214
+ - **`AGENTS.md`** + **`CLAUDE.md`** — AI context files with stats, CLI reference, and skill links. These files are managed with **surgical precision**:
215
+ - **File does not exist** → created from a template with a managed block and a clearly marked section for your own notes
216
+ - **File exists with markers** → only the `<!-- code-intel:start -->…<!-- code-intel:end -->` block is updated; all your custom content is preserved untouched
217
+ - **File exists without markers** → the block is appended at the end; existing content is never overwritten
218
+ - **`.claude/skills/code-intel/`** — per-cluster SKILL.md files with hot symbols, entry points, and impact guidance
219
+
220
+ ### Exclude directories
221
+
222
+ Create a `.codeintelignore` file in your project root:
223
+
224
+ ```
225
+ # one directory name per line
226
+ vendor
227
+ generated
228
+ fixtures
229
+ ```
230
+
231
+ ---
232
+
233
+ ## 🤖 MCP Setup (one-time)
234
+
235
+ Run the one-time setup command to configure the MCP server for your AI editor (Claude Desktop / Claude Code):
236
+
237
+ ```bash
238
+ code-intel setup
239
+ ```
240
+
241
+ This writes the MCP server configuration to `~/.config/claude/claude_desktop_config.json`:
242
+
243
+ ```json
244
+ {
245
+ "mcpServers": {
246
+ "code-intel": {
247
+ "command": "npx",
248
+ "args": ["@vohongtho.infotech/code-intel", "mcp", "."]
249
+ }
250
+ }
251
+ }
252
+ ```
253
+
254
+ After setup, the MCP server starts automatically when your AI editor launches, giving it direct access to all code-intel tools.
255
+
66
256
  ---
67
257
 
68
258
  ## 🖥️ Web UI
@@ -72,9 +262,8 @@ npm run build
72
262
  | **Explorer** | Graph composition stats, search results, overview counters |
73
263
  | **Filters** | Toggle node/edge types, set focus depth |
74
264
  | **Files** | Recursive file tree with search filter and file icons |
265
+ | **Group** | Multi-repo group view with contracts and cross-repo links (visible when in group mode) |
75
266
  | **Graph Canvas** | Force-directed graph, click nodes to inspect, hover to highlight neighbors |
76
- | **Source Preview** | Syntax-highlighted source code at the exact symbol line; resizable panel; "Open in editor" button |
77
- | **Query Console** | GQL editor with keyword highlighting, run button (`Ctrl+Enter`), sortable results table, query history |
78
267
  | **Code AI** | Chat with grounded answers citing source file locations |
79
268
 
80
269
  ### Search Modes
@@ -91,54 +280,93 @@ Toggle between modes using the `vec` button in the header search bar.
91
280
  ```
92
281
  code-intel-platform/
93
282
  ├── code-intel/
94
- │ ├── shared/ # Shared types: CodeNode, CodeEdge, NodeKind, EdgeKind, Language
95
- ├── core/ # Backend: pipeline, parser, HTTP API, MCP, CLI, storage
283
+ │ ├── shared/ # Shared types published alongside core
284
+ │ └── src/
285
+ │ │ ├── graph-types.ts # CodeNode, CodeEdge, NodeKind, EdgeKind
286
+ │ │ ├── languages.ts # Language enum (14 languages)
287
+ │ │ ├── pipeline-types.ts # PipelineContext, PhaseResult
288
+ │ │ └── detection.ts # Language detection helpers
289
+ │ │
290
+ │ ├── core/ # Backend: pipeline, parsers, HTTP API, MCP, CLI, storage
96
291
  │ │ └── src/
97
- │ │ ├── pipeline/ # 6-phase DAG: scan→structure→parse→resolve→cluster→flow
98
- │ │ ├── languages/ # 14 language modules (tree-sitter queries)
99
- │ │ ├── graph/ # In-memory knowledge graph with O(1) lookup
100
- │ │ ├── search/ # BM25 text search + vector embeddings
101
- │ │ ├── storage/ # LadybugDB persistence, repo registry
102
- │ │ ├── http/ # Express REST API + static web UI serving
103
- │ │ ├── mcp-server/ # MCP stdio transport
104
- │ │ ├── multi-repo/ # Group registry, group sync, cross-repo query
105
- │ │ ├── shared/ # Logger, language detection utilities
106
- │ │ └── cli/ # Commander CLI (progress bars, spinners)
107
- └── web/ # React + Sigma.js frontend
292
+ │ │ ├── pipeline/ # 6-phase DAG orchestrator + DAG validator
293
+ │ │ │ └── phases/ # scan · structure · parse · resolve · cluster · flow
294
+ │ │
295
+ │ │ ├── parsing/ # Tree-sitter AST parsing layer
296
+ │ │ ├── parser-manager.ts # Loads + caches tree-sitter parsers
297
+ │ │ ├── ast-cache.ts # AST memoization
298
+ │ │ ├── query-runner.ts # Executes tree-sitter queries
299
+ │ │ │ └── queries/ # Per-language query files (14 languages)
300
+ │ │
301
+ │ │ ├── languages/ # Language registry + per-language extraction modules
302
+ │ │ ├── registry.ts # Maps file extension → language module
303
+ │ │ │ └── modules/ # ts · js · py · java · go · rs · c · cpp · cs
304
+ │ │ │ # php · kt · rb · swift · dart
305
+ │ │ │
306
+ │ │ ├── resolver/ # Import resolution (edges between files/symbols)
307
+ │ │ │ ├── import-resolver.ts
308
+ │ │ │ ├── binding-tracker.ts
309
+ │ │ │ └── strategies/ # relative-path · package-lookup · namespace-alias · wildcard-expand
310
+ │ │ │
311
+ │ │ ├── call-graph/ # Call edge builder + call classifier
312
+ │ │ ├── inheritance/ # Heritage builder, MRO walker, override detector
313
+ │ │ ├── scope-analysis/ # Scope builder (variable / binding scope trees)
314
+ │ │ ├── clustering/ # Directory-based community detection
315
+ │ │ ├── flow-detection/ # Entry-point finder + execution flow tracer
316
+ │ │ │
317
+ │ │ ├── graph/ # In-memory knowledge graph (O(1) node/edge lookup)
318
+ │ │ ├── search/ # BM25 text search · vector embedder · vector index (LadybugDB)
319
+ │ │ ├── storage/ # LadybugDB graph persistence · repo registry · metadata
320
+ │ │ │
321
+ │ │ ├── multi-repo/ # Repository groups, contract extraction, cross-repo linking
322
+ │ │ │ ├── group-registry.ts # Load/save group configs + sync results
323
+ │ │ │ ├── group-sync.ts # Extract contracts + match via RRF
324
+ │ │ │ ├── group-query.ts # Cross-repo BM25 search with RRF merge
325
+ │ │ │ └── types.ts # RepoGroup, Contract, ContractLink, GroupSyncResult
326
+ │ │ │
327
+ │ │ ├── http/ # Express REST API + static web UI serving
328
+ │ │ ├── mcp-server/ # MCP stdio transport + all tool/resource handlers
329
+ │ │ ├── shared/ # Logger (winston, sensitive-data masking, ~/.code-intel/logs/)
330
+ │ │ └── cli/ # Commander CLI (progress bars, spinners)
331
+ │ │ ├── main.ts # All CLI commands
332
+ │ │ ├── skill-writer.ts # Generates .claude/skills/code-intel/ SKILL.md files
333
+ │ │ └── context-writer.ts # Upserts AGENTS.md + CLAUDE.md blocks
334
+ │ │
335
+ │ └── web/ # React + Sigma.js frontend
108
336
  │ └── src/
109
- │ ├── components/ # GraphView, NodeDetail, SidebarChat, SidebarFiles, Filters
110
- │ ├── ai/ # Agent with intent parsing + tool calls
111
- │ ├── api/ # ApiClient (search, vector-search, inspect, blast-radius)
112
- │ ├── graph/ # Colors palette, layout utilities
113
- │ └── state/ # React context + reducer
114
- └── .code-intel/ # Generated per-repo: graph.db, vector.db, meta.json
337
+ │ ├── pages/ # ConnectPage · LoadingPage · ExplorerPage
338
+ │ ├── components/
339
+ ├── graph/ # GraphView (Sigma.js force-directed canvas)
340
+ ├── panels/ # NodeDetail · SearchBar · SidebarChat · SidebarFiles · SidebarFilters
341
+ └── shared/ # Header · StatusFooter · KeyboardShortcutsModal
342
+ │ ├── ai/ # Chat agent with intent parsing + tool calls
343
+ │ ├── api/ # ApiClient (search, vector-search, inspect, blast-radius, flows, clusters)
344
+ │ ├── graph/ # Node color palette + ForceAtlas2 layout utilities
345
+ │ └── state/ # React context + reducer (AppContext, AppState)
346
+
347
+ ├── .code-intel/ # Generated per-repo: graph.db · vector.db · meta.json
348
+ └── .codeintelignore # Optional: directories to exclude (like .gitignore)
115
349
  ```
116
350
 
117
351
  ### Pipeline Phases
118
352
 
119
353
  | Phase | Description |
120
354
  |-------|-------------|
121
- | `scan` | Walk filesystem, collect source files (parallel batch I/O), ignore `node_modules`, `dist`, large files, etc. |
355
+ | `scan` | Walk filesystem, collect source files (parallel batch I/O, 512 KB limit), ignore `node_modules`, `dist`, `.venv`, etc. |
122
356
  | `structure` | Create file and directory nodes in the graph |
123
- | `parse` | Read files in parallel batches of 64, extract symbols (functions, classes, etc.), build per-file function index |
124
- | `resolve` | Resolve imports → edges, build call graph (O(log n) lookup), detect heritage (extends/implements) |
357
+ | `parse` | Read files in parallel batches of 64, extract symbols (functions, classes, etc.), build per-file sorted function index |
358
+ | `resolve` | Resolve imports → edges, build call graph (O(log n) binary-search lookup), detect heritage (extends/implements) |
125
359
  | `cluster` | Directory-based community detection, add cluster nodes |
126
360
  | `flow` | Detect entry points, trace execution flows |
127
- | `summarize` | _(opt-in)_ Generate 1–2 sentence AI summaries via OpenAI, Anthropic, or Ollama; skips unchanged nodes |
361
+ | `summarize` | _(opt-in)_ Generate 1–2 sentence AI summaries for `function`/`class`/`method`/`interface` nodes via OpenAI, Anthropic, or Ollama; skips unchanged nodes (code-hash cache) |
128
362
 
129
- Each phase reports live progress to the CLI via animated `█░` progress bars.
130
-
131
- ---
132
-
133
- ## 🖥️ CLI Progress Display
134
-
135
- When running `code-intel analyze`, each pipeline phase shows a real-time progress bar:
363
+ Each phase streams live progress to the CLI via animated `█░` progress bars:
136
364
 
137
365
  ```
138
366
  [parse ] ████████████████░░░░░░░░░░░░░░ 53% (80/151)
139
367
  ```
140
368
 
141
- Post-pipeline steps (DB persist, skill generation, context files) show a braille spinner:
369
+ Post-pipeline steps (DB persist, skill files, context files) show a braille spinner:
142
370
 
143
371
  ```
144
372
  ⠹ Persisting graph to DB…
@@ -148,7 +376,7 @@ Post-pipeline steps (DB persist, skill generation, context files) show a braille
148
376
 
149
377
  ## 📋 Logging
150
378
 
151
- Logs are written to **`~/.code-intel/logs/`** using daily rotation:
379
+ Logs are written to **`~/.code-intel/logs/`** using daily rotation (powered by [winston](https://github.com/winstonjs/winston)):
152
380
 
153
381
  | Setting | Default | Override |
154
382
  |---------|---------|----------|
@@ -159,39 +387,104 @@ Logs are written to **`~/.code-intel/logs/`** using daily rotation:
159
387
  | Log level | `info` | `LOG_LEVEL=debug\|info\|warn\|error\|silent` |
160
388
  | Production mode | Console only | `NODE_ENV=production` |
161
389
 
162
- Sensitive data (passwords, tokens, API keys, emails, etc.) is automatically masked before writing.
390
+ Sensitive data (passwords, tokens, API keys, emails, credit cards, etc.) is automatically **masked** before writing — only the first and last character are visible.
163
391
 
164
392
  ---
165
393
 
166
394
  ## 🛠️ CLI Commands
167
395
 
396
+ ### Setup
397
+
398
+ ```bash
399
+ code-intel setup # Register the MCP server in your editor config (one-time)
400
+ ```
401
+
402
+ ### Analyze
403
+
404
+ ```bash
405
+ code-intel analyze [path] # Parse source code and build the knowledge graph
406
+ code-intel analyze --force # Discard existing index and perform a full re-analysis
407
+ code-intel analyze --skills # Emit per-cluster SKILL.md files under .claude/skills/code-intel/
408
+ code-intel analyze --embeddings # Build a vector index for semantic (natural-language) search
409
+ code-intel analyze --skip-embeddings # Omit embedding generation for a significantly faster run
410
+ code-intel analyze --skip-agents-md # Preserve any hand-edited content in AGENTS.md / CLAUDE.md
411
+ code-intel analyze --skip-git # Allow analysis of directories that are not Git repositories
412
+ code-intel analyze --verbose # Print every file skipped due to an unsupported parser
413
+ ```
414
+
415
+ ### Server
416
+
417
+ ```bash
418
+ code-intel mcp [path] # Launch the MCP stdio server consumed by AI-enabled editors
419
+ code-intel serve [path] --port <n> # Start the HTTP API and serve the interactive web UI (default :4747)
420
+ code-intel watch [path] --port <n> # Start HTTP server + file watcher (auto-reindex on file saves)
421
+ ```
422
+
423
+ ### Query (GQL)
424
+
425
+ ```bash
426
+ code-intel query "<gql>" # Run a GQL query (FIND / TRAVERSE / PATH / COUNT GROUP BY)
427
+ code-intel query "<gql>" --format table|json|csv # Output format (default: table)
428
+ code-intel query --file <path.gql> # Load query from file
429
+ code-intel query "<gql>" --limit <n> # Override LIMIT in the query
430
+ code-intel query --save <name> "<gql>" # Save a named query to .code-intel/queries/
431
+ code-intel query --run <name> # Run a saved query by name
432
+ code-intel query --list # List all saved queries
433
+ code-intel query --delete <name> # Delete a saved query
434
+ ```
435
+
436
+ ### Health
437
+
438
+ ```bash
439
+ code-intel health [path] # Show health score + dead code / cycles / god nodes / orphans
440
+ code-intel health --dead-code # List all dead-code symbols
441
+ code-intel health --cycles # List all circular dependency cycles
442
+ code-intel health --orphans # List all orphan files
443
+ code-intel health --json # Machine-readable JSON output
444
+ ```
445
+
446
+ ### Registry
447
+
448
+ ```bash
449
+ code-intel list # Display all repositories that have been indexed
450
+ code-intel status [path] # Report index freshness, symbol counts, and last-run duration
451
+ code-intel clean [path] # Remove the .code-intel/ index for the specified repository
452
+ code-intel clean --all --force # Permanently remove all indexed repositories (requires --force)
453
+ ```
454
+
455
+ ### Exploration
456
+
168
457
  ```bash
169
- code-intel analyze [path] # Analyze and persist graph
170
- code-intel analyze --incremental # Re-parse only changed files (git diff / mtime)
171
- code-intel analyze --parallel # Use worker threads (faster on multi-core)
172
- code-intel analyze --summarize # Generate AI summaries after analysis
173
- code-intel analyze --skills # Emit per-cluster SKILL.md files
174
- code-intel serve [path] -p 4747 # Analyze + start HTTP server
175
- code-intel watch [path] -p 4747 # HTTP server + file watcher (auto-reindex on save)
176
- code-intel mcp [path] # Start MCP server (stdio)
177
- code-intel setup # Register MCP server in editor config (one-time)
178
- code-intel query "<gql>" # Run a GQL query (FIND / TRAVERSE / PATH / COUNT GROUP BY)
179
- code-intel query "<gql>" --format table|json|csv
180
- code-intel query --save <name> "<gql>" # Save a named query
181
- code-intel query --run <name> # Run a saved query
182
- code-intel query --list # List saved queries
183
- code-intel health [path] # Code health: dead code, cycles, god nodes, orphans, score
184
- code-intel health --dead-code # List dead-code symbols
185
- code-intel health --cycles # List circular dependency cycles
186
- code-intel health --json # Machine-readable output
187
- code-intel search <query> # Text search
188
- code-intel inspect <symbol> # Inspect a symbol
189
- code-intel impact <symbol> # Blast radius analysis
190
- code-intel list # List indexed repos
191
- code-intel status [path] # Show index status
192
- code-intel clean [path] # Remove index data
458
+ code-intel search <query> # Execute a BM25 keyword search across all indexed symbols
459
+ code-intel search <query> --limit <n> # Limit number of results (default: 20)
460
+ code-intel inspect <symbol> # Show callers, callees, import edges, and source location
461
+ code-intel impact <symbol> # Compute the transitive blast radius of a change to a symbol
462
+ code-intel impact <symbol> --depth <n> # Set maximum traversal depth / hops (default: 5)
193
463
  ```
194
464
 
465
+ ### Groups (multi-repo / monorepo service tracking)
466
+
467
+ ```bash
468
+ code-intel group create <name> # Create a named group to track multiple repositories together
469
+ code-intel group add <group> <groupPath> <registryName> # Enroll an indexed repo in a group under the given hierarchy path
470
+ code-intel group remove <group> <groupPath> # Remove a repository from a group by its hierarchy path
471
+ code-intel group list [name] # List all groups, or print the full membership of one group
472
+ code-intel group sync <name> # Extract cross-repo contracts and resolve provider/consumer links
473
+ code-intel group contracts <name> [--kind] [--repo] [--min-confidence] # Inspect extracted contracts and confidence-ranked cross-links
474
+ code-intel group query <name> <q> # Run a merged RRF search across every repository in a group
475
+ code-intel group status <name> # Audit index freshness and sync staleness for all group members
476
+ ```
477
+
478
+ **`group add` parameters:**
479
+ - `<group>` — name of the group
480
+ - `<groupPath>` — hierarchy path (e.g. `hr/hiring/backend`)
481
+ - `<registryName>` — the repo's name as shown by `code-intel list`
482
+
483
+ **`group contracts` options:**
484
+ - `--kind <kind>` — filter by contract kind: `export` | `route` | `schema` | `event`
485
+ - `--repo <repo>` — filter by registry name
486
+ - `--min-confidence <pct>` — minimum link confidence 0–100 (default: 0)
487
+
195
488
  ---
196
489
 
197
490
  ## 🌐 HTTP API
@@ -206,58 +499,73 @@ code-intel clean [path] # Remove index data
206
499
  | `GET` | `/api/v1/vector-status` | Vector index ready/building status |
207
500
  | `GET` | `/api/v1/nodes/:id` | Node detail (callers, callees, imports, etc.) |
208
501
  | `POST` | `/api/v1/blast-radius` | Impact analysis |
209
- | `POST` | `/api/v1/query` | Execute GQL query; 408 on timeout with partial results |
502
+ | `POST` | `/api/v1/query` | Execute a GQL query string; returns nodes/edges/groups + executionTimeMs |
210
503
  | `POST` | `/api/v1/query/explain` | Return query plan without executing |
211
- | `GET` | `/api/v1/source` | File content with ±20 lines context; path-traversal protected |
504
+ | `GET` | `/api/v1/source` | Fetch file content with ±20 lines context; path-traversal protected |
212
505
  | `POST` | `/api/v1/grep` | Regex search in file content |
213
506
  | `GET` | `/api/v1/flows` | List detected flows |
214
507
  | `GET` | `/api/v1/clusters` | List clusters |
215
- | `GET` | `/api/v1/openapi.json` | OpenAPI 3.1 spec |
216
508
 
217
509
  ---
218
510
 
219
511
  ## 🤖 MCP Server Tools
220
512
 
221
- | Tool | Description |
222
- |------|-------------|
223
- | `repos` | List all indexed repositories |
224
- | `overview` | Repository summary: total nodes/edges + full breakdown by kind |
225
- | `search` | BM25 / hybrid keyword + semantic search across all symbols |
226
- | `inspect` | 360° view of a symbol: definition, callers, callees, imports, heritage, members, cluster |
227
- | `blast_radius` | Impact analysis: traverse call/import graph to find all affected symbols |
228
- | `file_symbols` | List all symbols defined in a file, ordered by line number |
229
- | `find_path` | Shortest call/import path between two symbols via BFS |
230
- | `list_exports` | List all exported symbols the public API surface of the codebase |
231
- | `routes` | List all HTTP route handler mappings detected in the codebase |
232
- | `clusters` | List detected code clusters with member counts and top symbols |
233
- | `flows` | List detected execution flows with entry points and steps |
234
- | `query` | Execute a GQL query (`FIND`, `TRAVERSE`, `PATH`, `COUNT GROUP BY`); returns nodes/edges/groups + executionTimeMs |
235
- | `detect_changes` | Git-diff impact analysis: maps changed lines to graph symbols |
236
- | `raw_query` | _(deprecated use `query`)_ Simplified Cypher-like graph query |
237
- | `group_list` | List all configured repository groups |
238
- | `group_sync` | Extract contracts and detect cross-repo provider→consumer links |
239
- | `group_contracts` | Inspect extracted contracts and confidence-ranked cross-repo links |
240
- | `group_query` | BM25 search across all repos in a group merged via RRF |
241
- | `group_status` | Check index freshness and sync staleness for all group members |
513
+ All tools are available to any MCP-capable editor (Claude Desktop, Claude Code, VS Code, Cursor, etc.) after running `code-intel setup`.
514
+
515
+ ### Core Tools
516
+
517
+ | Tool | Input | Description |
518
+ |------|-------|-------------|
519
+ | `repos` | _(none)_ | List all indexed repositories with path, indexedAt, and node/edge counts |
520
+ | `overview` | _(none)_ | Repository summary: total nodes/edges + full breakdown by kind. **Use this first** to understand the codebase shape. |
521
+ | `search` | `query` (string), `limit` (number, default 20) | BM25 / hybrid keyword + semantic search across all symbols |
522
+ | `inspect` | `symbol_name` (string) | 360° view of a symbol: definition, callers, callees, imports, heritage (extends/implements), members, cluster, and source preview |
523
+ | `blast_radius` | `target` (string), `direction` (`callers`\|`callees`\|`both`), `max_hops` (number, default 5) | Impact analysis: traverse the call/import graph to find all affected symbols. Returns a `riskLevel` (LOW / MEDIUM / HIGH). |
524
+ | `file_symbols` | `file_path` (string, partial match) | List all symbols defined in a file, ordered by line number. Avoids having to read raw source. |
525
+ | `find_path` | `from` (string), `to` (string), `max_hops` (number, default 8) | Find the shortest call/import path between two symbols via BFS. |
526
+ | `list_exports` | `kind` (string, optional), `limit` (number, default 100) | List all exported symbols — the public API surface of the codebase. Filter by kind: `function`, `class`, `interface`, etc. |
527
+ | `routes` | _(none)_ | List all HTTP route handler mappings detected in the codebase |
528
+ | `clusters` | `limit` (number, default 50) | List detected code clusters (directory-based communities) with member counts and top 10 symbols each |
529
+ | `flows` | `limit` (number, default 50) | List detected execution flows with entry points, steps, and step counts |
530
+ | `query` | `gql` (string), `limit` (number, optional) | Execute a GQL query (`FIND`, `TRAVERSE`, `PATH`, `COUNT GROUP BY`) against the live graph; returns nodes/edges/groups + executionTimeMs |
531
+ | `detect_changes` | `base_ref` (string, default `HEAD`), `diff_text` (string, optional) | **Git-diff impact analysis**: maps changed lines to graph symbols and computes combined blast radius. Ideal for PR review or pre-commit checks. |
532
+ | `raw_query` | `cypher` (string) | _(deprecated use `query` instead)_ Simplified Cypher-like graph query: `name='X'` or `:kind` |
533
+
534
+ ### Group / Multi-Repo Tools
535
+
536
+ | Tool | Input | Description |
537
+ |------|-------|-------------|
538
+ | `group_list` | `name` (string, optional) | List all configured repository groups, or show full membership of one group |
539
+ | `group_sync` | `name` (string) | Extract contracts (exports, routes, schemas, events) from all member repos and detect cross-repo provider→consumer links via name matching + RRF scoring |
540
+ | `group_contracts` | `name` (string), `kind` (`export`\|`route`\|`schema`\|`event`, optional), `repo` (string, optional), `min_confidence` (number 0–1, optional) | Inspect extracted contracts and confidence-ranked cross-repo links from the last sync |
541
+ | `group_query` | `name` (string), `query` (string), `limit` (number, default 10) | BM25 search across all repos in a group, merged via Reciprocal Rank Fusion. Returns unified ranked list + per-repo breakdown. |
542
+ | `group_status` | `name` (string) | Check index freshness and sync staleness for all repos in a group. Flags repos as `OK`, `STALE` (>24h), or `NOT_INDEXED`. |
543
+
544
+ ### Resources
545
+
546
+ MCP resources are readable via `ReadResource` — your editor can pull them as structured context.
547
+
548
+ | URI | Description |
549
+ |-----|-------------|
550
+ | `codeintel://repo/<name>/overview` | Repository stats: total nodes, edges, and per-kind node counts |
551
+ | `codeintel://repo/<name>/clusters` | All cluster nodes with member counts |
552
+ | `codeintel://repo/<name>/flows` | All detected execution flows with entry points and steps |
242
553
 
243
554
  ---
244
555
 
245
- ## 🔬 Node Type Color Palette
246
-
247
- | Type | Color | Hex |
248
- |------|-------|-----|
249
- | Function | 🩵 Cyan | `#22D3EE` |
250
- | File | 🟠 Orange | `#FB923C` |
251
- | Class | 🟢 Green | `#4ADE80` |
252
- | Interface | 🟣 Purple | `#A78BFA` |
253
- | Enum | 🔷 Indigo | `#6366F1` |
254
- | Constant | 🟡 Yellow | `#FACC15` |
255
- | Type Alias | 🔴 Pink | `#FB7185` |
256
- | Flow | 🩵 Teal | `#14B8A6` |
257
- | Method | 💙 Sky Blue | `#38BDF8` |
258
- | Module | 🪻 Fuchsia | `#E879F9` |
259
- | Route | 🔴 Red | `#F87171` |
260
- | Cluster | ⬜ Slate | `#64748B` |
556
+ ## 💾 Storage
557
+
558
+ All generated files are stored locally — nothing is sent to external servers.
559
+
560
+ | Path | Contents |
561
+ |------|----------|
562
+ | `.code-intel/graph.db` | LadybugDB knowledge graph |
563
+ | `.code-intel/vector.db` | LadybugDB vector index |
564
+ | `.code-intel/meta.json` | Index metadata (timestamp, stats) |
565
+ | `~/.code-intel/registry.json` | Global registry of all indexed repos |
566
+ | `~/.code-intel/groups/<name>.json` | Repository group configuration |
567
+ | `~/.code-intel/groups/<name>.sync.json` | Last group sync results (contracts + cross-repo links) |
568
+ | `~/.code-intel/logs/YYYY-MM-DD-code-intel.log` | Daily-rotating application logs (14-day retention) |
261
569
 
262
570
  ---
263
571
 
@@ -267,7 +575,7 @@ code-intel clean [path] # Remove index data
267
575
  npm run test
268
576
  ```
269
577
 
270
- 46+ tests across unit + integration suites covering:
578
+ 46 tests across unit + integration suites covering:
271
579
  - Knowledge graph operations
272
580
  - Language detection
273
581
  - Call classifier
@@ -275,15 +583,142 @@ npm run test
275
583
  - Scope analysis
276
584
  - Text search
277
585
  - Pipeline integration (parse → resolve)
278
- - Parser corpus golden-file regression (10 languages, 100% recall)
279
- - Tree-sitter query correctness (Swift, Kotlin, Dart)
280
586
 
281
587
  ---
282
588
 
283
- ## 📋 Requirements
589
+ ## 📊 Benchmark / Eval
284
590
 
285
- - **Node.js** 22+
286
- - **npm** 10+
591
+ Measure accuracy of the knowledge graph, skill files, MCP tools, and context file generation:
592
+
593
+ ```bash
594
+ # Single-language fixture (TypeScript)
595
+ npm run eval
596
+
597
+ # Multi-language fixture (Python + TypeScript)
598
+ npm run eval:multi
599
+
600
+ # Run all fixtures
601
+ npm run eval:all
602
+
603
+ # Save results as JSON
604
+ npm run eval:json
605
+ ```
606
+
607
+ Results are written to `eval/results/`. Each run scores:
608
+
609
+ | Phase | What is tested |
610
+ |-------|---------------|
611
+ | Analysis | Symbol count, edge count, exit code |
612
+ | Search | BM25 keyword search accuracy |
613
+ | Inspect | Symbol detail retrieval |
614
+ | Impact | Blast radius correctness |
615
+ | Skill Files | SKILL.md generation, hot symbols, frontmatter |
616
+ | Context Files | AGENTS.md / CLAUDE.md upsert + idempotency |
617
+ | Status | Index freshness reporting |
618
+ | Clean | Index removal |
619
+
620
+ Current score: **25/25 (100%)** TypeScript · **15/15 (100%)** multi-lang
621
+
622
+ ### Agent Benchmark (Before vs After)
623
+
624
+ The `bench` command simulates an AI agent answering code questions with and without code-intel:
625
+
626
+ ```bash
627
+ npm run bench
628
+ ```
629
+
630
+ Latest results on the TypeScript fixture (6 tasks):
631
+
632
+ | Metric | Baseline (grep + read files) | Enhanced (code-intel tools) | Δ |
633
+ |--------|-----------------------------|-----------------------------|---|
634
+ | **Accuracy** | 58% | **100%** | +42pp |
635
+ | **Tool calls/task** | 2.0 | **1.0** | −50% |
636
+ | **Response size** | 1023 chars | **189 chars** | −82% token cost |
637
+
638
+ ### MCP Server Benchmark
639
+
640
+ Test all MCP tools directly over the JSON-RPC stdio transport:
641
+
642
+ ```bash
643
+ npm run bench:mcp
644
+ ```
645
+
646
+ Latest results (16 cases, TypeScript fixture):
647
+
648
+ | Metric | Result |
649
+ |--------|--------|
650
+ | **Score** | 16/16 (100%) |
651
+ | **Avg tool latency** | 39ms/call |
652
+
653
+ Tools tested: `repos`, `search`, `inspect`, `blast_radius`, `routes`, `raw_query` + `ListTools`, `ListResources`, `ReadResource`
654
+
655
+ ---
656
+
657
+ ## 🔧 Technical Implementation Details
658
+
659
+ ### web-tree-sitter v0.26 API
660
+
661
+ - `Parser.SyntaxNode` → `Node` (named export)
662
+ - `Parser.Language` → `Language` (named export)
663
+ - `language.query(src)` → `new Query(language, src)`
664
+ - `Parser.Language.load()` → `Language.load()`
665
+
666
+ ### GraphView (Sigma.js)
667
+
668
+ - Graph built once from data; Sigma `nodeReducer`/`edgeReducer` used for filter/selection/hover changes (no remount)
669
+ - `stateRef`/`dispatchRef` pattern to avoid stale closures in event handlers
670
+ - `suppressNextStage` guard ensures `clickNode` event wins over `clickStage`
671
+ - Camera fly-to uses `renderer.getNodeDisplayData(id)` for normalized coordinates (NOT raw graphology attributes)
672
+ - ForceAtlas2 layout applied synchronously after graph build
673
+
674
+ ### Multi-repo Groups
675
+
676
+ - Contract kinds: `export`, `route`, `schema`, `event`
677
+ - Cross-repo matching via Reciprocal Rank Fusion (RRF)
678
+ - Confidence scoring for cross-repo links
679
+
680
+ ### Build System
681
+
682
+ - Core: `tsup` bundler → `dist/cli/main.js` + `dist/index.js`
683
+ - Web: Vite + Tailwind CSS v4
684
+ - `esbuild` and `vite` must be in root `devDependencies` to be hoisted for monorepo npm workspaces
685
+
686
+ ---
687
+
688
+ ## 🚢 CI/CD
689
+
690
+ ### GitHub Actions Workflows
691
+
692
+ | Workflow | Trigger | Steps |
693
+ |----------|---------|-------|
694
+ | **test.yml** | PRs | `npm ci --legacy-peer-deps` + `npm test` |
695
+ | **quality.yml** | PRs | Typecheck shared + core + web |
696
+ | **publish.yml** | `v*.*.*` tags | Typecheck → Test → npm audit → License gate → Build core → Build web → `npm publish --provenance` → Build + push multi-arch Docker (linux/amd64 + linux/arm64) → Trivy CRITICAL CVE gate → cosign keyless sign → GitHub Release with CycloneDX SBOM → Discord notification |
697
+
698
+ ### Publishing a New Version
699
+
700
+ ```bash
701
+ # Bump version in code-intel/core/package.json, then:
702
+ git tag v0.1.5
703
+ git push origin v0.1.5
704
+ ```
705
+
706
+ The publish workflow automatically runs all checks, builds the packages, publishes to npm, and sends a Discord notification (📦 success or ❌ failure).
707
+
708
+ **Required GitHub Secrets:**
709
+
710
+ | Secret | Purpose |
711
+ |--------|---------|
712
+ | `NPM_TOKEN` | npm access token with publish rights |
713
+ | `DISCORD_WEBHOOK` | Discord webhook URL for deploy notifications |
714
+
715
+ ### Local CI Simulation
716
+
717
+ ```bash
718
+ docker compose -f docker-compose.build.yml build
719
+ ```
720
+
721
+ Uses `node:22-bookworm-slim` — the same base image as GitHub Actions.
287
722
 
288
723
  ---
289
724