vibe-splain 2.7.2 → 2.7.3
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 +237 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>◈ VIBE-SPLAIN</strong>
|
|
3
|
+
<br />
|
|
4
|
+
<em>Map architectural DNA and behavioral call-chains in complex codebases.</em>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="#install">Install</a> ·
|
|
9
|
+
<a href="#how-it-works">How It Works</a> ·
|
|
10
|
+
<a href="#mcp-tools">MCP Tools</a> ·
|
|
11
|
+
<a href="#dossier-ui">Dossier UI</a> ·
|
|
12
|
+
<a href="#development">Development</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
VIBE-SPLAIN is a high-fidelity **static analysis engine** and MCP server. It uses [Tree-Sitter](https://tree-sitter.github.io/tree-sitter/) to extract the structural and behavioral patterns of a codebase—identifying high-gravity components, mapping semantic actions, and tracing call-chains between entrypoints and side effects.
|
|
18
|
+
|
|
19
|
+
While VIBE-SPLAIN is built on a language-agnostic foundation, the current toolset is **highly optimized for TypeScript and JavaScript** (especially Next.js, Prisma, and tRPC environments).
|
|
20
|
+
|
|
21
|
+
**Zero LLM calls. Zero API keys. Pure static analysis.**
|
|
22
|
+
|
|
23
|
+
Your coding agent does all the thinking — VIBE-SPLAIN just gives it the right data.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx vibe-splain install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
That's it. This patches your coding agent's MCP config so it can call VIBE-SPLAIN's tools. Restart your agent.
|
|
32
|
+
|
|
33
|
+
### Running the Analysis
|
|
34
|
+
|
|
35
|
+
You don't need to write a complex prompt. VIBE-SPLAIN provides a built-in MCP Prompt called `build_dossier` that automatically tells your agent exactly what to do.
|
|
36
|
+
|
|
37
|
+
**In Claude Code / Gemini CLI:**
|
|
38
|
+
Type `/prompt build_dossier` and press enter.
|
|
39
|
+
|
|
40
|
+
**In Cursor / Windsurf:**
|
|
41
|
+
Open the MCP panel or agent chat, select the `build_dossier` prompt from the VIBE-SPLAIN server, and run it.
|
|
42
|
+
|
|
43
|
+
Your agent will loop through the high-gravity files, analyze each one, and build an **Architectural Dossier** — a structured set of **Decision Cards** explaining the technical rationale of the code.
|
|
44
|
+
|
|
45
|
+
### Supported Agents
|
|
46
|
+
|
|
47
|
+
| Agent | Config File |
|
|
48
|
+
|-------|------------|
|
|
49
|
+
| Claude Code | `~/.claude/claude_desktop_config.json` |
|
|
50
|
+
| Gemini CLI | `~/.gemini/settings.json` |
|
|
51
|
+
| Cursor | `~/.cursor/mcp.json` |
|
|
52
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` |
|
|
53
|
+
|
|
54
|
+
## How It Works
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
┌─────────────────────────────────────────────────────────┐
|
|
58
|
+
│ Your Coding Agent (Claude / Gemini / Cursor) │
|
|
59
|
+
│ │
|
|
60
|
+
│ "Scan this project" ──► scan_project ──► get_file_ctx │
|
|
61
|
+
│ │ │ │
|
|
62
|
+
│ Agent synthesizes ◄──────┘ ◄──────────────┘ │
|
|
63
|
+
│ narratives + diagrams │
|
|
64
|
+
│ │ │
|
|
65
|
+
│ ▼ │
|
|
66
|
+
│ write_decision_card ──► .vibe-splainer/dossier.json │
|
|
67
|
+
│ │ │
|
|
68
|
+
│ ▼ │
|
|
69
|
+
│ file:// Dossier UI │
|
|
70
|
+
└─────────────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Three Levels of Analysis
|
|
74
|
+
|
|
75
|
+
1. **Level 0 — Semantic Classification**: Maps files to architectural "pillars" (Auth, Payments, Database, etc.) using import-path heuristics and library signatures.
|
|
76
|
+
|
|
77
|
+
2. **Level 1 — Cognitive Complexity**: Tree-Sitter AST analysis computes a complexity score per file based on link density, nesting depth, and mutation counts. Files scoring ≥ 15 are identified as **High-Gravity**.
|
|
78
|
+
|
|
79
|
+
3. **Level 2 — Behavioral Traceability**: Tree-Sitter powered call-graph analysis. It maps function-level dependencies and identifies **Critical Functions** (entrypoints, semantic actions, or high-outbound callers) so your agent can trace the exact ripple effect of a code change.
|
|
80
|
+
|
|
81
|
+
## MCP Tools
|
|
82
|
+
|
|
83
|
+
VIBE-SPLAIN exposes **8 tools** over MCP stdio:
|
|
84
|
+
|
|
85
|
+
| Tool | Purpose |
|
|
86
|
+
|------|---------|
|
|
87
|
+
| `scan_project` | **Call first.** Scans the codebase, returns high-gravity files grouped by pillar. Starts file watcher. |
|
|
88
|
+
| `get_file_context` | Returns full source + import graph neighbors for a specific file. |
|
|
89
|
+
| `get_call_chain` | **New.** Traces function-level call chains (upstream/downstream) to map behavior paths. |
|
|
90
|
+
| `write_decision_card` | Persists a Decision Card (narrative + evidence + optional Mermaid diagram). |
|
|
91
|
+
| `get_strategic_overview` | Returns dossier state without evidence snippets (saves tokens). |
|
|
92
|
+
| `inspect_pillar` | Returns all Decision Cards for a pillar with full evidence. |
|
|
93
|
+
| `get_wild_discoveries` | Returns the most complex files that don't fit standard patterns. |
|
|
94
|
+
| `mark_stale` | Marks cards as stale when you modify files during a session. |
|
|
95
|
+
|
|
96
|
+
### Recommended Agent Workflow
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
1. scan_project → get high-gravity files
|
|
100
|
+
2. For each file: get_file_context → read source + neighbors
|
|
101
|
+
3. Trace: use get_call_chain to see what calls what
|
|
102
|
+
4. Synthesize: "WHY does this code exist?"
|
|
103
|
+
5. write_decision_card → persist the narrative
|
|
104
|
+
6. Share the file:// UI link with the user
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## How It Works
|
|
108
|
+
|
|
109
|
+
### Deep Analysis Pipeline
|
|
110
|
+
Unlike simple regex scanners, VIBE-SPLAIN runs a deterministic **13-stage pipeline**—from AST inventory and alias resolution to semantic classification and function-level scoring—to ensure every Decision Card is grounded in actual code paths.
|
|
111
|
+
|
|
112
|
+
### Semantic Rulesets
|
|
113
|
+
VIBE-SPLAIN uses specialized rulesets to understand framework-specific semantics. Current optimizations include:
|
|
114
|
+
- **Next.js**: Server Actions, `cookies()`, `headers()`, and App Router conventions.
|
|
115
|
+
- **Database**: Prisma model mutations and raw query patterns.
|
|
116
|
+
- **API**: tRPC procedure calls (`mutate`/`query`) and standard `fetch`/`axios` patterns.
|
|
117
|
+
- **Auth**: Clerk, NextAuth, and custom rate-limiting/validation logic.
|
|
118
|
+
|
|
119
|
+
## Dossier UI
|
|
120
|
+
|
|
121
|
+
After your agent writes Decision Cards, open the generated file in your browser:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
file:///path/to/your/project/.vibe-splainer/ui/index.html
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The UI features:
|
|
128
|
+
- **Dark theme** with glassmorphism and subtle grid texture
|
|
129
|
+
- **Pillar tabs** for navigating architectural areas
|
|
130
|
+
- **Decision Cards** with fresh/stale status badges
|
|
131
|
+
- **Mermaid diagrams** rendered inline as SVG
|
|
132
|
+
- **Evidence sidebar** with Shiki syntax highlighting (tokyo-night)
|
|
133
|
+
- **Wild Discoveries** tab for the most complex outlier files
|
|
134
|
+
- Works entirely offline via `file://` — no server needed
|
|
135
|
+
|
|
136
|
+
## Architecture
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
packages/
|
|
140
|
+
├── brain/ # @vibe-splain/brain — analysis engine
|
|
141
|
+
│ └── src/
|
|
142
|
+
│ ├── scanner.ts # Tree-Sitter AST analysis (L0 + L1 + L2)
|
|
143
|
+
│ ├── dossier.ts # Atomic persistence + UI regeneration
|
|
144
|
+
│ ├── graph.ts # Import graph read/write
|
|
145
|
+
│ └── watcher.ts # Chokidar file watcher
|
|
146
|
+
├── cli/ # vibe-splain — MCP server + CLI
|
|
147
|
+
│ └── src/
|
|
148
|
+
│ ├── index.ts # #!/usr/bin/env node entry
|
|
149
|
+
│ ├── commands/
|
|
150
|
+
│ │ ├── install.ts # Agent config patcher
|
|
151
|
+
│ │ └── serve.ts # MCP server launcher
|
|
152
|
+
│ └── mcp/
|
|
153
|
+
│ ├── server.ts # @modelcontextprotocol/sdk setup
|
|
154
|
+
│ └── tools/ # 7 tool handlers
|
|
155
|
+
└── ui/ # @vibe-splain/ui — React dossier viewer
|
|
156
|
+
└── src/
|
|
157
|
+
├── App.tsx # Main app (reads window.__VIBE_DOSSIER__)
|
|
158
|
+
├── components/ # Header, PillarTabs, DecisionCard, etc.
|
|
159
|
+
└── index.css # Design system
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Key Design Decisions
|
|
163
|
+
|
|
164
|
+
- **No LLM calls**: VIBE-SPLAIN is a pure static analysis tool. The coding agent provides all synthesis.
|
|
165
|
+
- **`async-mutex`**: All dossier writes are guarded by a mutex with atomic tmp+rename.
|
|
166
|
+
- **`startOnLoad: false`**: Mermaid is initialized manually — never auto-scans the DOM.
|
|
167
|
+
- **`base: './'`**: Vite builds with relative paths so the UI works from `file://` URLs.
|
|
168
|
+
- **`console.log` banned**: Brain and CLI use only `console.error` to avoid corrupting MCP stdio.
|
|
169
|
+
- **Tree-Sitter WASM**: Loaded from the `tree-sitter-wasms` npm package — no network calls.
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
### Prerequisites
|
|
174
|
+
|
|
175
|
+
- Node.js ≥ 18
|
|
176
|
+
- npm ≥ 9 (for workspaces)
|
|
177
|
+
|
|
178
|
+
### Setup
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
git clone https://github.com/abp2204/vibe-splain.git
|
|
182
|
+
cd vibe-splain
|
|
183
|
+
npm install
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Build
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npm run build
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
This runs in sequence: brain → cli → ui → bundle-ui (copies UI dist into CLI dist).
|
|
193
|
+
|
|
194
|
+
### Dev UI
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm run dev:ui
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Starts the Vite dev server for the UI package at `http://localhost:5173`.
|
|
201
|
+
|
|
202
|
+
### Test Install Locally
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
node packages/cli/dist/index.js install
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Test MCP Server
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
node packages/cli/dist/index.js serve
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Then send JSON-RPC messages over stdin (see [MCP specification](https://modelcontextprotocol.io)).
|
|
215
|
+
|
|
216
|
+
### Publish
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm run release
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Builds everything and publishes the `vibe-splain` CLI package to npm.
|
|
223
|
+
|
|
224
|
+
## How the Dossier Stays Fresh
|
|
225
|
+
|
|
226
|
+
When `scan_project` runs, it starts a [Chokidar](https://github.com/paulmillr/chokidar) file watcher. When source files change:
|
|
227
|
+
|
|
228
|
+
1. The watcher detects the change
|
|
229
|
+
2. Matching Decision Cards are marked **stale** (amber badge in UI)
|
|
230
|
+
3. The `stalePaths` array in the dossier tracks which files need re-analysis
|
|
231
|
+
4. Your agent can call `get_strategic_overview` to see what's stale, then re-scan
|
|
232
|
+
|
|
233
|
+
You can also manually mark files stale with `mark_stale` if you modify code during a session.
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibe-splain",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"description": "Architectural mapping and behavioral call-chain engine. Built on a language-agnostic foundation with specialized optimization for TypeScript/JavaScript projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|