codemap-ai 0.2.0 → 3.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/LICENSE +21 -0
- package/README.md +257 -94
- package/dist/chunk-GX7ZMBC2.js +730 -0
- package/dist/chunk-GX7ZMBC2.js.map +1 -0
- package/dist/chunk-XNA2HNUR.js +733 -0
- package/dist/chunk-XNA2HNUR.js.map +1 -0
- package/dist/cli.js +636 -688
- package/dist/cli.js.map +1 -1
- package/dist/flow-server-QO7IWYLE.js +246 -0
- package/dist/flow-server-QO7IWYLE.js.map +1 -0
- package/dist/index.d.ts +167 -190
- package/dist/index.js +597 -485
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +144 -265
- package/dist/mcp-server.js.map +1 -1
- package/package.json +13 -17
- package/dist/chunk-5ONPBEWJ.js +0 -350
- package/dist/chunk-5ONPBEWJ.js.map +0 -1
- package/dist/chunk-FLUWKIEM.js +0 -347
- package/dist/chunk-FLUWKIEM.js.map +0 -1
- package/dist/server-3W7ZN3LX.js +0 -103
- package/dist/server-3W7ZN3LX.js.map +0 -1
- package/dist/server-TBIVIIUJ.js +0 -367
- package/dist/server-TBIVIIUJ.js.map +0 -1
- package/web/index.html +0 -639
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sahan Nishshanka, JUST ADD AI GmbH
|
|
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
CHANGED
|
@@ -1,156 +1,319 @@
|
|
|
1
|
-
# CodeMap
|
|
1
|
+
# CodeMap AI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Call graph analyzer for understanding code impact and execution flows - built for Claude Code**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Stop guessing what breaks when you change code. CodeMap builds a complete call graph of your codebase so Claude can answer "what depends on this?" with surgical precision.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🔍 **Call Graph Analysis** - Trace every function call across your entire codebase
|
|
10
|
+
- 🎯 **Impact Analysis** - Know exactly what breaks before you change code
|
|
11
|
+
- 🔗 **Cross-File Resolution** - Follows imports and tracks dependencies
|
|
12
|
+
- 🚀 **FastAPI Support** - Detects HTTP endpoints and dependency injection patterns
|
|
13
|
+
- 💾 **Incremental Updates** - Only re-indexes changed files
|
|
14
|
+
- 🤖 **Claude Code Integration** - MCP server for AI-powered code queries
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Use directly with npx (recommended)
|
|
20
|
+
npx codemap-ai index /path/to/project
|
|
21
|
+
|
|
22
|
+
# Or install globally
|
|
23
|
+
npm install -g codemap-ai
|
|
24
|
+
```
|
|
6
25
|
|
|
7
26
|
## Quick Start
|
|
8
27
|
|
|
9
28
|
```bash
|
|
10
|
-
#
|
|
11
|
-
npx codemap-ai
|
|
29
|
+
# Index your codebase
|
|
30
|
+
npx codemap-ai index /path/to/project
|
|
31
|
+
|
|
32
|
+
# Start MCP server for Claude Code
|
|
33
|
+
npx codemap-ai mcp-server
|
|
12
34
|
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
# /patterns - Code conventions
|
|
16
|
-
# /impact - Change analysis
|
|
35
|
+
# Add to Claude Code (one-time setup)
|
|
36
|
+
claude mcp add codemap -- npx codemap-ai mcp-server --path /path/to/project
|
|
17
37
|
```
|
|
18
38
|
|
|
19
|
-
##
|
|
39
|
+
## Commands
|
|
20
40
|
|
|
21
|
-
|
|
22
|
-
2. **Builds** a knowledge graph of all functions, classes, imports, and calls
|
|
23
|
-
3. **Generates** Claude Code skills that understand your project
|
|
24
|
-
4. **Connects** to Claude Code via MCP for intelligent queries
|
|
41
|
+
### `codemap index [path]`
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
Build a call graph of your codebase:
|
|
27
44
|
|
|
28
45
|
```bash
|
|
29
|
-
#
|
|
30
|
-
|
|
46
|
+
# Index current directory
|
|
47
|
+
codemap index
|
|
31
48
|
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
# Index specific directory
|
|
50
|
+
codemap index /path/to/project
|
|
51
|
+
|
|
52
|
+
# Force re-index everything
|
|
53
|
+
codemap index --force
|
|
54
|
+
|
|
55
|
+
# Custom file patterns
|
|
56
|
+
codemap index --include "src/**/*.py" --exclude "**/tests/**"
|
|
35
57
|
```
|
|
36
58
|
|
|
37
|
-
|
|
59
|
+
**Options:**
|
|
60
|
+
- `--force` - Force re-index all files (default: incremental)
|
|
61
|
+
- `--include <patterns>` - File patterns to include (can be repeated)
|
|
62
|
+
- `--exclude <patterns>` - File patterns to exclude (can be repeated)
|
|
63
|
+
|
|
64
|
+
**Output:**
|
|
65
|
+
```
|
|
66
|
+
CodeMap Call Graph Indexer
|
|
38
67
|
|
|
39
|
-
|
|
68
|
+
Indexed: 290 files
|
|
69
|
+
Resolved: 3,987 function calls
|
|
70
|
+
Unresolved: 12,253 calls (external/dynamic)
|
|
40
71
|
|
|
41
|
-
|
|
72
|
+
Framework Detection:
|
|
73
|
+
HTTP Endpoints: 283 routes detected
|
|
74
|
+
Dependencies: 30/30 resolved (FastAPI Depends)
|
|
75
|
+
|
|
76
|
+
Call resolution rate: 25%
|
|
77
|
+
Database saved to: .codemap/graph.db
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `codemap mcp-server`
|
|
81
|
+
|
|
82
|
+
Start the MCP server for Claude Code integration:
|
|
42
83
|
|
|
43
84
|
```bash
|
|
44
|
-
|
|
85
|
+
codemap mcp-server --path /path/to/project
|
|
45
86
|
```
|
|
46
87
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
2. Generate Claude Code skills
|
|
50
|
-
3. Add the MCP server to Claude Code
|
|
88
|
+
**Options:**
|
|
89
|
+
- `--path <path>` - Path to indexed project (default: current directory)
|
|
51
90
|
|
|
52
|
-
|
|
53
|
-
- `--name <name>` - Project name for skill descriptions
|
|
54
|
-
- `--skip-mcp` - Skip adding MCP server (just scan + skills)
|
|
91
|
+
## MCP Tools for Claude Code
|
|
55
92
|
|
|
56
|
-
|
|
93
|
+
Once connected via MCP, Claude gains these capabilities:
|
|
57
94
|
|
|
58
|
-
|
|
95
|
+
### `codemap_callers`
|
|
96
|
+
Find all functions that call a specific function:
|
|
59
97
|
|
|
60
|
-
```
|
|
61
|
-
|
|
98
|
+
```
|
|
99
|
+
Claude: "What calls the authenticate_user function?"
|
|
100
|
+
→ Returns: 12 callers with file:line references
|
|
62
101
|
```
|
|
63
102
|
|
|
64
|
-
|
|
103
|
+
### `codemap_impact`
|
|
104
|
+
Analyze the blast radius of changing code:
|
|
65
105
|
|
|
66
|
-
|
|
106
|
+
```
|
|
107
|
+
Claude: "If I change authenticate_user, what breaks?"
|
|
108
|
+
→ Returns: 15 affected files, call chain, risk level
|
|
109
|
+
```
|
|
67
110
|
|
|
68
|
-
|
|
111
|
+
### `codemap_trace_flow`
|
|
112
|
+
Trace execution paths between functions:
|
|
69
113
|
|
|
70
|
-
```
|
|
71
|
-
|
|
114
|
+
```
|
|
115
|
+
Claude: "Show me the flow from chat endpoint to database"
|
|
116
|
+
→ Returns: handle_chat → authenticate → get_handler → save_chat → db.insert
|
|
72
117
|
```
|
|
73
118
|
|
|
74
|
-
### `
|
|
119
|
+
### `codemap_dependencies`
|
|
120
|
+
Get import/export relationships:
|
|
75
121
|
|
|
76
|
-
|
|
122
|
+
```
|
|
123
|
+
Claude: "What does auth.py import?"
|
|
124
|
+
→ Returns: All imports and what they're used for
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### `codemap_search`
|
|
128
|
+
Search for functions, classes, files:
|
|
77
129
|
|
|
78
|
-
```bash
|
|
79
|
-
npx codemap-ai affected src/auth/login.ts
|
|
80
|
-
npx codemap-ai affected UserService
|
|
81
130
|
```
|
|
131
|
+
Claude: "Find all database operations"
|
|
132
|
+
→ Returns: 476 operations (find_one: 137, update_one: 122, ...)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Supported Languages
|
|
136
|
+
|
|
137
|
+
| Language | Parsing | Imports | Calls | Classes | Methods |
|
|
138
|
+
|------------|---------|---------|-------|---------|---------|
|
|
139
|
+
| Python | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
140
|
+
| TypeScript | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
141
|
+
| JavaScript | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
82
142
|
|
|
83
|
-
##
|
|
143
|
+
## Framework Detection
|
|
84
144
|
|
|
85
|
-
|
|
145
|
+
CodeMap understands framework-specific patterns:
|
|
86
146
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
147
|
+
**FastAPI:**
|
|
148
|
+
- HTTP route decorators (`@router.post("/chat")`)
|
|
149
|
+
- Dependency injection (`Depends()`)
|
|
150
|
+
- Request handlers and middleware
|
|
151
|
+
|
|
152
|
+
**Coming Soon:**
|
|
153
|
+
- Django views and models
|
|
154
|
+
- Express.js routes
|
|
155
|
+
- React component hierarchy
|
|
94
156
|
|
|
95
157
|
## How It Works
|
|
96
158
|
|
|
97
159
|
```
|
|
98
|
-
┌──────────────┐
|
|
99
|
-
│ Your Code │
|
|
100
|
-
│
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
160
|
+
┌──────────────┐
|
|
161
|
+
│ Your Code │
|
|
162
|
+
│ .py/.ts/.js │
|
|
163
|
+
└──────┬───────┘
|
|
164
|
+
│
|
|
165
|
+
▼
|
|
166
|
+
┌──────────────┐
|
|
167
|
+
│ Tree-sitter │ Parse AST for every file
|
|
168
|
+
│ Parser │ Extract: functions, classes, calls, imports
|
|
169
|
+
└──────┬───────┘
|
|
170
|
+
│
|
|
171
|
+
▼
|
|
172
|
+
┌──────────────┐
|
|
173
|
+
│ Resolution │ Resolve all calls to definitions
|
|
174
|
+
│ Engine │ Track: variable types, inheritance, imports
|
|
175
|
+
└──────┬───────┘
|
|
176
|
+
│
|
|
177
|
+
▼
|
|
178
|
+
┌──────────────┐
|
|
179
|
+
│ SQLite │ Store: nodes (functions/classes)
|
|
180
|
+
│ Database │ edges (calls/imports)
|
|
181
|
+
└──────┬───────┘
|
|
182
|
+
│
|
|
183
|
+
├─────────────┬─────────────┐
|
|
184
|
+
▼ ▼ ▼
|
|
185
|
+
┌───────────┐ ┌───────────┐ ┌───────────┐
|
|
186
|
+
│ MCP Tools │ │ Stats │ │ Impact │
|
|
187
|
+
│ Impact │ │ Reporting │ │ Analysis │
|
|
188
|
+
│ Callers │ │ │ │ │
|
|
189
|
+
└───────────┘ └───────────┘ └───────────┘
|
|
111
190
|
```
|
|
112
191
|
|
|
113
|
-
##
|
|
192
|
+
## Use Cases
|
|
114
193
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
| Rust | 🚧 | 🚧 | 🚧 | 🚧 |
|
|
194
|
+
### Before Refactoring
|
|
195
|
+
```bash
|
|
196
|
+
codemap index
|
|
197
|
+
# Ask Claude: "Show me everything that calls UserService.authenticate"
|
|
198
|
+
# → Make informed decisions about API changes
|
|
199
|
+
```
|
|
122
200
|
|
|
123
|
-
|
|
201
|
+
### Understanding Legacy Code
|
|
202
|
+
```bash
|
|
203
|
+
codemap index
|
|
204
|
+
# Ask Claude: "How does the payment flow work from API to database?"
|
|
205
|
+
# → Get complete execution traces
|
|
206
|
+
```
|
|
124
207
|
|
|
125
|
-
###
|
|
208
|
+
### Security Audits
|
|
209
|
+
```bash
|
|
210
|
+
codemap index
|
|
211
|
+
# Ask Claude: "Find all functions that access user credentials"
|
|
212
|
+
# → Trace data flow through the system
|
|
213
|
+
```
|
|
126
214
|
|
|
127
|
-
|
|
215
|
+
### Dependency Analysis
|
|
216
|
+
```bash
|
|
217
|
+
codemap index
|
|
218
|
+
# Ask Claude: "What would break if I remove this utility function?"
|
|
219
|
+
# → Impact analysis before deletion
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Advanced Features
|
|
223
|
+
|
|
224
|
+
### Incremental Indexing
|
|
225
|
+
|
|
226
|
+
CodeMap uses file hashing to only re-index changed files:
|
|
128
227
|
|
|
129
228
|
```bash
|
|
130
|
-
#
|
|
131
|
-
|
|
229
|
+
# First run: indexes all 290 files
|
|
230
|
+
codemap index
|
|
132
231
|
|
|
133
|
-
#
|
|
134
|
-
|
|
232
|
+
# Second run: only indexes changed files
|
|
233
|
+
codemap index
|
|
234
|
+
→ Indexed: 3 files, Skipped: 287 files (unchanged)
|
|
235
|
+
```
|
|
135
236
|
|
|
136
|
-
|
|
137
|
-
|
|
237
|
+
### Variable Type Tracking
|
|
238
|
+
|
|
239
|
+
Resolves method calls through type inference:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
user = UserService() # Type tracked
|
|
243
|
+
user.authenticate() # ✅ Resolved to UserService.authenticate
|
|
138
244
|
```
|
|
139
245
|
|
|
140
|
-
###
|
|
246
|
+
### Super() Resolution
|
|
141
247
|
|
|
142
|
-
|
|
248
|
+
Follows inheritance chains:
|
|
143
249
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
250
|
+
```python
|
|
251
|
+
class Child(Parent):
|
|
252
|
+
def method(self):
|
|
253
|
+
super().method() # ✅ Resolved to Parent.method
|
|
254
|
+
```
|
|
149
255
|
|
|
150
|
-
|
|
256
|
+
### Database Operation Detection
|
|
151
257
|
|
|
152
|
-
|
|
258
|
+
Tracks MongoDB operations:
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
db.users.find_one({"id": user_id})
|
|
262
|
+
# ✅ Tracked as database operation: find_one on users collection
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Performance
|
|
266
|
+
|
|
267
|
+
- **Indexing Speed**: ~290 files in 2-3 seconds
|
|
268
|
+
- **Resolution Rate**: 25% internal calls (75% are external libraries/builtins)
|
|
269
|
+
- **Incremental Updates**: Only re-indexes changed files
|
|
270
|
+
- **Memory Usage**: ~50MB for 290 Python files
|
|
271
|
+
- **Database Size**: ~2MB for 290 files, 16K nodes, 12K edges
|
|
272
|
+
|
|
273
|
+
## Configuration
|
|
274
|
+
|
|
275
|
+
CodeMap stores data in `.codemap/graph.db` (SQLite) in your project root.
|
|
276
|
+
|
|
277
|
+
**File patterns:**
|
|
278
|
+
- Default include: `**/*.py`, `**/*.ts`, `**/*.tsx`, `**/*.js`, `**/*.jsx`
|
|
279
|
+
- Default exclude: `**/node_modules/**`, `**/__pycache__/**`, `**/venv/**`
|
|
280
|
+
- Max file size: 200KB (larger files skipped)
|
|
281
|
+
|
|
282
|
+
## Troubleshooting
|
|
283
|
+
|
|
284
|
+
### No functions detected
|
|
285
|
+
- Check file patterns with `--include` and `--exclude`
|
|
286
|
+
- Ensure files are under 200KB
|
|
287
|
+
- Verify supported language (.py, .ts, .js)
|
|
288
|
+
|
|
289
|
+
### Low resolution rate
|
|
290
|
+
- Normal for projects with many external libraries
|
|
291
|
+
- Internal calls should resolve at ~90%+
|
|
292
|
+
- Use `codemap_search` to find unresolved patterns
|
|
293
|
+
|
|
294
|
+
### MCP server not connecting
|
|
295
|
+
- Ensure Claude Code is running
|
|
296
|
+
- Check `~/.claude/config.json` for MCP configuration
|
|
297
|
+
- Restart Claude Code after adding MCP server
|
|
298
|
+
|
|
299
|
+
## Contributing
|
|
300
|
+
|
|
301
|
+
CodeMap is focused on call graph accuracy and performance. We welcome:
|
|
302
|
+
- Parser improvements for better resolution
|
|
303
|
+
- New language support (Go, Rust, Java)
|
|
304
|
+
- Framework-specific pattern detection
|
|
305
|
+
- Performance optimizations
|
|
153
306
|
|
|
154
307
|
## License
|
|
155
308
|
|
|
156
|
-
MIT
|
|
309
|
+
MIT License - see [LICENSE](LICENSE) file
|
|
310
|
+
|
|
311
|
+
## Author
|
|
312
|
+
|
|
313
|
+
Sahan Nishshanka, JUST ADD AI GmbH
|
|
314
|
+
|
|
315
|
+
## Links
|
|
316
|
+
|
|
317
|
+
- Repository: https://github.com/justaddai/codemap-ai
|
|
318
|
+
- Issues: https://github.com/justaddai/codemap-ai/issues
|
|
319
|
+
- NPM: https://www.npmjs.com/package/codemap-ai
|