Skip to content

Commit 584227e

Browse files
authored
feat!: drop web UI and REST API — MCP stdio only (#3)
* feat!: drop web UI and REST API — MCP stdio only Strip Next.js app router, React components, Express server, REST API, Playwright E2E tests, and HTTP MCP transport. Package is now a pure MCP stdio analysis engine. - Delete app/, components/, hooks/, lib/, e2e/, public/ directories - Delete next.config.ts, postcss.config.mjs, playwright.config.ts - Simplify cli.ts: remove --port, browser mode, keep --mcp as no-op - Strip graph-store.ts to MCP-needed exports only - Remove 20 deps (next, react, three, tailwind, playwright, etc.) - Remove JSX, DOM, Next.js plugin from tsconfig - Update README, CLAUDE.md, docs for MCP-only architecture - Remove web-specific test suites, update remaining tests Core pipeline (parser → graph → analyzer → MCP) unchanged. All 131 tests pass. All quality gates green. BREAKING CHANGE: browser mode and REST API removed. --mcp flag kept as backward-compatible no-op. * test: add MCP tool tests + coverage config + CI workflow - Add tests/mcp-tools.test.ts: 47 tests covering all 15 MCP tools, 2 prompts, 3 resources via Client + InMemoryTransport - Add tests/graph-store.test.ts: 5 tests for full graph-store coverage - Configure vitest coverage: v8 provider, 80% thresholds, exclude cli.ts and types/ - Add .github/workflows/ci.yml: lint/typecheck/build/test on PRs, Node 18/20/22 matrix, auto-publish to npm on v* tags Coverage: 64.95% → 96.3% statements, 85.47% branch, 98.18% functions * docs: remove legacy --mcp flags and phantom workflow references from README
1 parent 493546d commit 584227e

85 files changed

Lines changed: 1205 additions & 7075 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
tags: ["v*"]
9+
10+
jobs:
11+
ci:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [18, 20, 22]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: pnpm/action-setup@v4
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: pnpm
25+
26+
- run: pnpm install --frozen-lockfile
27+
28+
- name: Lint
29+
run: pnpm lint
30+
31+
- name: Typecheck
32+
run: pnpm typecheck
33+
34+
- name: Build
35+
run: pnpm build
36+
37+
- name: Test with coverage
38+
run: pnpm test -- --coverage
39+
40+
- name: Upload coverage
41+
if: matrix.node-version == 22
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: coverage-report
45+
path: coverage/
46+
47+
publish:
48+
needs: ci
49+
if: startsWith(github.ref, 'refs/tags/v')
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
id-token: write
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: pnpm/action-setup@v4
58+
59+
- uses: actions/setup-node@v4
60+
with:
61+
node-version: 22
62+
cache: pnpm
63+
registry-url: https://registry.npmjs.org
64+
65+
- run: pnpm install --frozen-lockfile
66+
67+
- name: Build
68+
run: pnpm build
69+
70+
- name: Publish to npm
71+
run: npm publish --access public --provenance
72+
env:
73+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CLAUDE.md

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Project Overview
44

5-
npm package that generates 3D interactive maps of TypeScript codebases. Two modes: browser (3D visualization) and MCP stdio (LLM integration).
5+
npm package that analyzes TypeScript codebases — parses source, builds dependency graphs, computes architectural metrics, and exposes everything via MCP stdio for LLM-assisted code understanding.
66

77
## Architecture
88

@@ -12,25 +12,28 @@ src/
1212
parser/index.ts <- TS Compiler API parser (files, functions, imports)
1313
graph/index.ts <- graphology graph builder + circular dep detection
1414
analyzer/index.ts <- Metrics engine (PageRank, betweenness, cohesion, tension, churn, complexity, blast radius, dead exports)
15-
mcp/index.ts <- MCP stdio server (7 tools)
16-
server/index.ts <- Express web server
17-
server/api.ts <- REST API routes
15+
mcp/index.ts <- MCP stdio server (15 tools, 2 prompts, 3 resources)
16+
mcp/hints.ts <- Next-step hints for MCP tool responses
17+
server/graph-store.ts <- Global graph state (shared by CLI + MCP)
18+
impact/index.ts <- Symbol-level impact analysis + rename planning
19+
search/index.ts <- BM25 search engine
20+
process/index.ts <- Entry point detection + call chain tracing
21+
community/index.ts <- Louvain clustering
22+
persistence/index.ts <- Graph export/import to .code-visualizer/
1823
cli.ts <- CLI entry point (commander)
19-
public/
20-
index.html <- Client-side 3D renderer (8 views, uses 3d-force-graph from CDN)
2124
docs/
2225
architecture.md <- Pipeline, module map, data flow, design decisions
2326
data-model.md <- All TypeScript interfaces with field descriptions
2427
metrics.md <- Per-file + module metrics, force analysis, complexity scoring
25-
mcp-tools.md <- 7 MCP tools: inputs, outputs, use cases, selection guide
28+
mcp-tools.md <- 15 MCP tools: inputs, outputs, use cases, selection guide
2629
specs/
2730
active/ <- Current spec
2831
```
2932

3033
## Pipeline
3134

3235
```
33-
CLI args -> Parser (TS AST) -> Graph Builder (graphology) -> Analyzer (metrics) -> Server (Express | MCP stdio)
36+
CLI args -> Parser (TS AST) -> Graph Builder (graphology) -> Analyzer (metrics) -> MCP stdio
3437
```
3538

3639
## Key Conventions
@@ -47,9 +50,9 @@ CLI args -> Parser (TS AST) -> Graph Builder (graphology) -> Analyzer (metrics)
4750
- **graphology** — graph data structure. Import as `import Graph from "graphology"`. Use as both constructor and type.
4851
- **graphology-metrics** — PageRank, betweenness. Default imports from subpaths.
4952
- **@modelcontextprotocol/sdk** — MCP server. Uses `McpServer` class with `server.tool()` registration.
50-
- **express** — web server. Routes in `server/api.ts`, static files from `public/`.
5153
- **typescript** — used as a library (Compiler API), not just a dev tool.
5254
- **zod** — MCP tool input validation.
55+
- **commander** — CLI argument parsing.
5356

5457
### Quality Gates
5558

@@ -68,7 +71,7 @@ All four must pass before shipping. Run in order: lint -> typecheck -> build ->
6871

6972
| Change Type | Bump | Example |
7073
|-------------|------|---------|
71-
| New MCP tools, new views, new metrics | minor | 1.0.1 → 1.1.0 |
74+
| New MCP tools, new metrics | minor | 1.0.1 → 1.1.0 |
7275
| Bug fixes, description changes, doc sync | patch | 1.1.0 → 1.1.1 |
7376
| Breaking: removed tool, changed tool params | major | 1.1.0 → 2.0.0 |
7477

@@ -117,23 +120,13 @@ pnpm publish:npm
117120

118121
## Security Rules
119122

120-
### Client-side (public/index.html)
121-
- **NEVER use innerHTML with dynamic data** — use DOM API (`createElement` + `textContent`)
122-
- **NEVER use inline onclick attributes** — use `addEventListener`
123-
- All node data from the API must be treated as untrusted (file paths can contain HTML metacharacters)
124-
- Use the `el()` helper for safe DOM construction
125-
126-
### Server-side
127-
- Validate and clamp all query parameters (especially `limit`)
128-
- API routes should return JSON 404s, not HTML
123+
- Validate and clamp all MCP tool input parameters
129124
- No filesystem access beyond the parsed graph data
130125

131126
## File Conventions
132127

133128
- New analysis metrics go in `src/analyzer/index.ts`
134129
- New MCP tools go in `src/mcp/index.ts` (register with `server.tool()`)
135-
- New REST endpoints go in `src/server/api.ts`
136-
- New browser views go in `public/index.html` (add render function + view tab)
137130
- Types always in `src/types/index.ts`
138131

139132
## Common Pitfalls
@@ -153,12 +146,12 @@ LLM knowledge base for building this tool. Single source of truth per topic:
153146
| `docs/architecture.md` | Pipeline, module map, data flow, design decisions | New module or pipeline change |
154147
| `docs/data-model.md` | All TypeScript interfaces (mirrors `src/types/index.ts`) | Type changes |
155148
| `docs/metrics.md` | Per-file + module metrics, force analysis, complexity scoring | New metric added |
156-
| `docs/mcp-tools.md` | 7 MCP tools with inputs/outputs/use cases | New tool or param change |
149+
| `docs/mcp-tools.md` | 15 MCP tools with inputs/outputs/use cases | New tool or param change |
157150

158151
## Testing (BLOCKING)
159152

160153
- Test runner: vitest
161-
- Test files: `src/**/*.test.ts`
154+
- Test files: `src/**/*.test.ts`, `tests/**/*.test.ts`
162155
- Run: `npm test` or `npx vitest run`
163156

164157
### Coverage Policy (ENFORCE)
@@ -171,7 +164,6 @@ LLM knowledge base for building this tool. Single source of truth per topic:
171164
### Real Environment Tests (MANDATORY)
172165

173166
- **NEVER mock internal modules** — use real parser, real graph, real analyzer
174-
- **NEVER mock Express** — use `supertest` against the real app
175167
- **NEVER mock graphology** — build real graphs with real data
176168
- **NEVER mock filesystem for parser tests** — use real fixture directories with real `.ts` files
177169
- **Only mock external third-party APIs** that require network/auth (none currently)
@@ -184,23 +176,12 @@ LLM knowledge base for building this tool. Single source of truth per topic:
184176
| Parser | Real `.ts` fixture files on disk, assert parsed output |
185177
| Graph | Real parsed files -> real graph builder, assert nodes/edges |
186178
| Analyzer | Real graph -> real metrics, assert values |
187-
| API | `supertest` against real Express app with real graph data |
188179
| MCP | Real MCP server instance, assert tool responses |
189180
| CLI | Real process execution where feasible |
190181

191-
### Visual Verification (MANDATORY for UI changes)
192-
193-
- After ANY UI change (HTML/CSS/client JS), start the server and verify in a browser
194-
- Start server: `node dist/cli.js ./src --port 3333`
195-
- Verify: page loads, graph renders, changed feature works visually
196-
- Check browser console for JavaScript errors
197-
- Kill server after verification
198-
- If browser agent is available, use it for automated visual verification
199-
200182
### Anti-Patterns (NEVER)
201183

202184
- NEVER use `jest.mock()` or `vi.mock()` for internal modules
203185
- NEVER create fake/stub graph objects — build them through the real pipeline
204-
- NEVER skip tests because "it's just UI" or "it's just config"
186+
- NEVER skip tests because "it's just config"
205187
- NEVER write tests that pass regardless of implementation (test behavior, not existence)
206-
- NEVER ship UI changes without visual verification in a real browser

0 commit comments

Comments
 (0)