codeimpact 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Abhishek Arun Savakar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,348 @@
1
+ # CodeImpact
2
+
3
+ **Persistent codebase understanding for AI assistants.**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/codeimpact.svg?style=flat-square)](https://www.npmjs.com/package/codeimpact)
6
+ [![npm downloads](https://img.shields.io/npm/dm/codeimpact.svg?style=flat-square)](https://www.npmjs.com/package/codeimpact)
7
+ [![npm total downloads](https://img.shields.io/npm/dt/codeimpact.svg?style=flat-square)](https://www.npmjs.com/package/codeimpact)
8
+ [![license](https://img.shields.io/npm/l/codeimpact.svg?style=flat-square)](https://github.com/abhisavakar/codeimpact/blob/main/LICENSE)
9
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-339933.svg?style=flat-square)](https://nodejs.org/)
10
+ [![MCP](https://img.shields.io/badge/MCP-Compatible-blue.svg?style=flat-square)](https://modelcontextprotocol.io/)
11
+
12
+ ```bash
13
+ npm i codeimpact
14
+ ```
15
+
16
+ CodeImpact is an MCP server that indexes your codebase and gives AI assistants like Claude the ability to understand your project's structure, dependencies, and history across sessions.
17
+
18
+ ---
19
+
20
+ ## What CodeImpact Does
21
+
22
+ - **Indexes your code** - Extracts functions, classes, imports, and exports using true Tree-sitter AST parsing
23
+ - **Builds a dependency graph** - Tracks what files import what, transitively
24
+ - **Dead code detection** - Finds unused exports and orphan files with confidence scoring
25
+ - **Test impact analysis** - Shows which tests to run when you change a file
26
+ - **Blast radius analysis** - Risk scoring and critical path detection for any file change
27
+ - **Cost tracking** - Monitors token usage and costs for CodeImpact queries
28
+ - **Detects circular dependencies** - Finds import cycles in your codebase
29
+ - **Indexes tests** - Identifies test files and what source files they cover
30
+ - **Records decisions** - Stores architectural decisions that persist across sessions
31
+ - **Semantic search** - Find code by meaning using local embeddings
32
+
33
+ All processing happens locally on your machine. No cloud services, no telemetry.
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ```bash
40
+ # Install globally
41
+ npm i -g codeimpact
42
+
43
+ # Or use with npx (no install)
44
+ npx codeimpact init
45
+
46
+ # Initialize in your project
47
+ cd your-project
48
+ codeimpact init
49
+ ```
50
+
51
+ This registers your project and configures Claude Desktop, Claude Code, OpenCode, and Cursor automatically. Restart your AI tool and you're ready.
52
+
53
+ > **Windows users**: If upgrading, close any AI tools using CodeImpact first (or run `taskkill /f /im node.exe`) before reinstalling. Windows locks native binaries while they're in use.
54
+
55
+ ---
56
+
57
+ ## Key Features
58
+
59
+ ### Dead Code Detection
60
+
61
+ Find unused exports and orphan files in your codebase:
62
+
63
+ ```bash
64
+ codeimpact deadcode
65
+ codeimpact deadcode --json --threshold 80
66
+ ```
67
+
68
+ **Output:**
69
+ ```
70
+ Dead Code Report:
71
+ - 4,230 lines of unused code detected
72
+ - 12 files with zero imports
73
+ - 23 functions never called
74
+ Safe to delete: 89% confidence
75
+ ```
76
+
77
+ ### Test Impact Analysis
78
+
79
+ Know exactly which tests to run when you change a file:
80
+
81
+ ```bash
82
+ codeimpact test-impact
83
+ codeimpact test-impact --changed src/auth/login.ts
84
+ codeimpact test-impact --branch main
85
+ ```
86
+
87
+ **Output:**
88
+ ```
89
+ Analyzing impact of src/auth/login.ts...
90
+ Files affected: 12
91
+ Tests to run: 8 (instead of 234)
92
+ Estimated time: 2m (instead of 28m)
93
+ Time saved: 26 minutes
94
+ ```
95
+
96
+ ### Blast Radius Analysis
97
+
98
+ Understand the risk of changing any file:
99
+
100
+ ```bash
101
+ codeimpact impact src/core/engine.ts
102
+ codeimpact impact src/auth/session.ts --depth 5 --json
103
+ ```
104
+
105
+ **Output:**
106
+ ```
107
+ File: src/auth/session.ts
108
+ Risk Score: 78/100 (HIGH)
109
+ Direct dependents: 8 files
110
+ Transitive dependents: 34 files
111
+ Critical paths affected: src/api/checkout.ts, src/billing/payments.ts
112
+ Recommendation: Senior review required
113
+ ```
114
+
115
+ ### Usage Dashboard
116
+
117
+ Track token usage and costs for CodeImpact queries:
118
+
119
+ ```bash
120
+ codeimpact stats
121
+ codeimpact stats --period week
122
+ codeimpact stats --period all --json
123
+ ```
124
+
125
+ **Output:**
126
+ ```
127
+ This Month:
128
+ - Queries: 1,247
129
+ - Tokens used: 892K
130
+ - Estimated cost: $5.35
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Supported AI Tools
136
+
137
+ | Tool | Setup |
138
+ |------|-------|
139
+ | Claude Desktop | `codeimpact init` (auto) |
140
+ | Claude Code (CLI) | [`codeimpact init` (auto)](./doc/CLAUDE-CODE-SETUP.md) |
141
+ | Cursor | `codeimpact init` (auto) |
142
+ | OpenCode | [`codeimpact init` (auto)](./doc/OPENCODE-SETUP.md) |
143
+ | Any MCP Client | Manual config |
144
+ | **Any tool (HTTP)** | `codeimpact serve` |
145
+
146
+ All tools share the same data - switch between them freely.
147
+
148
+ ---
149
+
150
+ ## What You Can Ask
151
+
152
+ Once CodeImpact is running, your AI assistant can:
153
+
154
+ **Understand dependencies:**
155
+ ```
156
+ "What files depend on src/auth/login.ts?"
157
+ "Show me the import chain for this module"
158
+ ```
159
+
160
+ **Analyze impact:**
161
+ ```
162
+ "If I change this file, what else might break?"
163
+ "What's the blast radius of changing this module?"
164
+ "What tests cover this function?"
165
+ ```
166
+
167
+ **Find dead code:**
168
+ ```
169
+ "Are there any unused exports in this project?"
170
+ "Which files have no dependents?"
171
+ ```
172
+
173
+ **Find code:**
174
+ ```
175
+ "Find all authentication-related code"
176
+ "Where is the user validation logic?"
177
+ ```
178
+
179
+ **Check for issues:**
180
+ ```
181
+ "Are there any circular dependencies?"
182
+ "What decisions have we made about authentication?"
183
+ ```
184
+
185
+ ---
186
+
187
+ ## How It Works
188
+
189
+ CodeImpact watches your project and maintains:
190
+
191
+ 1. **Symbol index** - Functions, classes, imports, exports
192
+ 2. **Dependency graph** - File-to-file import relationships
193
+ 3. **Decision log** - Architectural decisions you've recorded
194
+ 4. **Embeddings** - For semantic search (using MiniLM-L6 locally)
195
+ 5. **Test index** - Test files and their coverage mappings
196
+ 6. **Token usage** - Query tracking for cost analysis
197
+
198
+ When your AI assistant asks a question, CodeImpact provides the relevant context.
199
+
200
+ ---
201
+
202
+ ## Language Support
203
+
204
+ | Language | What's Extracted |
205
+ |----------|------------------|
206
+ | TypeScript/JavaScript | Functions, classes, imports, exports |
207
+ | Python | Functions, classes, imports |
208
+ | Go | Functions, structs, imports |
209
+ | Rust | Functions, structs, imports |
210
+ | Java | Classes, methods, imports |
211
+
212
+ Parsing is powered by **Tree-sitter WASM**, providing true Abstract Syntax Tree (AST) understanding rather than fragile regex matching. This ensures 100% accurate symbol extraction, boundary detection, and method signatures across all supported languages.
213
+
214
+ ---
215
+
216
+ ## CLI Commands
217
+
218
+ ```bash
219
+ # Setup
220
+ codeimpact init # Set up project + configure AI tools
221
+ codeimpact serve # Start HTTP API server
222
+
223
+ # Analysis
224
+ codeimpact deadcode # Find unused exports and dead code
225
+ codeimpact test-impact # Find which tests to run for changes
226
+ codeimpact impact <file> # Analyze blast radius of a file
227
+ codeimpact stats # Show token usage and costs
228
+
229
+ # Project Management
230
+ codeimpact projects list # List registered projects
231
+ codeimpact projects add . # Add current directory
232
+ codeimpact projects switch # Switch active project
233
+ codeimpact export # Export decisions to ADR files
234
+ codeimpact help # Show help
235
+ ```
236
+
237
+ ### CLI Options
238
+
239
+ ```bash
240
+ --project, -p <path> # Path to the project directory
241
+ --json # Output as JSON
242
+ --threshold <percent> # Minimum confidence % (for deadcode)
243
+ --changed <file> # Specify changed file(s) (for test-impact)
244
+ --git-diff # Use git diff to detect changes
245
+ --branch <name> # Compare to branch (e.g., main)
246
+ --depth <n> # Max dependency depth (default: 3)
247
+ --period <type> # Time period: day, week, month, all
248
+ ```
249
+
250
+ ---
251
+
252
+ ## HTTP API
253
+
254
+ For tools that don't support MCP, CodeImpact provides a REST API:
255
+
256
+ ```bash
257
+ codeimpact serve --project /path/to/project --port 3333
258
+ ```
259
+
260
+ **Endpoints:**
261
+
262
+ | Method | Endpoint | Description |
263
+ |--------|----------|-------------|
264
+ | GET | `/status` | Project stats |
265
+ | GET | `/search?q=...` | Semantic code search |
266
+ | GET | `/dependencies?file=...` | File dependencies |
267
+ | GET | `/impact?file=...` | Impact analysis |
268
+ | GET | `/circular` | Find circular deps |
269
+ | GET | `/decisions` | List decisions |
270
+ | POST | `/decisions` | Record a decision |
271
+ | GET | `/symbols?file=...` | Get file symbols |
272
+
273
+ **Example:**
274
+ ```bash
275
+ curl "http://localhost:3333/impact?file=src/auth/login.ts"
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Manual Configuration
281
+
282
+ If `codeimpact init` doesn't work for your setup, add to your Claude Desktop config:
283
+
284
+ ```json
285
+ {
286
+ "mcpServers": {
287
+ "codeimpact": {
288
+ "command": "npx",
289
+ "args": ["-y", "codeimpact", "--project", "/path/to/your/project"]
290
+ }
291
+ }
292
+ }
293
+ ```
294
+
295
+ Config locations:
296
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
297
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
298
+ - **Linux**: `~/.config/claude/claude_desktop_config.json`
299
+
300
+ ---
301
+
302
+ ## Data Storage
303
+
304
+ Project data is stored locally in each project:
305
+
306
+ ```
307
+ your-project/
308
+ ├── .codeimpact/
309
+ │ ├── codeimpact.db # SQLite database
310
+ │ ├── tier1.json # Hot context cache
311
+ │ └── feature-context.json # Session tracking
312
+ ├── src/
313
+ └── ...
314
+ ```
315
+
316
+ Each project has its own isolated `.codeimpact/` folder - no cross-contamination between projects.
317
+
318
+ Global registry for project listing:
319
+ ```
320
+ ~/.codeimpact/
321
+ └── registry.json # Project list
322
+ ```
323
+
324
+ ---
325
+
326
+ ## Privacy
327
+
328
+ - All data stays on your machine
329
+ - No cloud services
330
+ - No telemetry
331
+ - Works offline
332
+
333
+ ---
334
+
335
+ ## Development
336
+
337
+ ```bash
338
+ git clone https://github.com/abhisavakar/codeimpact.git
339
+ cd codeimpact
340
+ npm install
341
+ npm run build
342
+ ```
343
+
344
+ ---
345
+
346
+ **Author:** Abhishek Arun Savakar - [savakar.com](https://savakar.com)
347
+
348
+ Built with [Model Context Protocol](https://modelcontextprotocol.io/) by Anthropic.