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