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 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
- AI-powered codebase knowledge graph generator with Claude Code integration.
3
+ **Call graph analyzer for understanding code impact and execution flows - built for Claude Code**
4
4
 
5
- **One command to understand your entire codebase.**
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
- # Initialize everything in one command
11
- npx codemap-ai init
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
- # That's it! Now use skills in Claude Code:
14
- # /architecture - Project overview
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
- ## What It Does
39
+ ## Commands
20
40
 
21
- 1. **Scans** your codebase using Tree-sitter (Python, TypeScript, JavaScript)
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
- ## Installation
43
+ Build a call graph of your codebase:
27
44
 
28
45
  ```bash
29
- # Option 1: Use directly with npx (recommended)
30
- npx codemap-ai init
46
+ # Index current directory
47
+ codemap index
31
48
 
32
- # Option 2: Install globally
33
- npm install -g codemap-ai
34
- codemap init
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
- ## Commands
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
- ### `codemap init` (Recommended)
68
+ Indexed: 290 files
69
+ Resolved: 3,987 function calls
70
+ Unresolved: 12,253 calls (external/dynamic)
40
71
 
41
- **One command that does everything:**
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
- npx codemap-ai init /path/to/project --name "My Project"
85
+ codemap mcp-server --path /path/to/project
45
86
  ```
46
87
 
47
- This will:
48
- 1. Scan your codebase and build the knowledge graph
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
- Options:
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
- ### `codemap serve`
93
+ Once connected via MCP, Claude gains these capabilities:
57
94
 
58
- Start the web visualization:
95
+ ### `codemap_callers`
96
+ Find all functions that call a specific function:
59
97
 
60
- ```bash
61
- npx codemap-ai serve
98
+ ```
99
+ Claude: "What calls the authenticate_user function?"
100
+ → Returns: 12 callers with file:line references
62
101
  ```
63
102
 
64
- Opens an interactive graph at `http://localhost:3333`
103
+ ### `codemap_impact`
104
+ Analyze the blast radius of changing code:
65
105
 
66
- ### `codemap stats`
106
+ ```
107
+ Claude: "If I change authenticate_user, what breaks?"
108
+ → Returns: 15 affected files, call chain, risk level
109
+ ```
67
110
 
68
- Show codebase statistics:
111
+ ### `codemap_trace_flow`
112
+ Trace execution paths between functions:
69
113
 
70
- ```bash
71
- npx codemap-ai stats
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
- ### `codemap affected <target>`
119
+ ### `codemap_dependencies`
120
+ Get import/export relationships:
75
121
 
76
- Analyze what files would be affected by changes:
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
- ## Generated Skills
143
+ ## Framework Detection
84
144
 
85
- After initialization, these skills are available in Claude Code:
145
+ CodeMap understands framework-specific patterns:
86
146
 
87
- | Skill | Description |
88
- |-------|-------------|
89
- | `/architecture` | Project overview, stats, directory structure |
90
- | `/patterns` | Key classes, common functions, conventions |
91
- | `/impact <file>` | What's affected by changes to a file |
92
- | `/navigate <query>` | Find code by name |
93
- | `/dependencies <file>` | Import/export relationships |
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 │ ───► │ Tree-sitter │ ───► │ Knowledge │
100
- .ts/.py/.js │ Parser │ │ Graph (SQLite)│
101
- └──────────────┘ └─────────────┘ └──────────────┘
102
-
103
- ┌───────────────────────────┼───────────────────────────┐
104
- │ │ │
105
- ▼ ▼ ▼
106
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
107
- │ Skills │ │ MCP Server │ │ Web UI │
108
- /impact │ │ codemap_* │ │ Graph Viz │
109
- │ /patterns │ │ tools │ │ │
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
- ## Supported Languages
192
+ ## Use Cases
114
193
 
115
- | Language | Parsing | Imports | Calls | Classes |
116
- |----------|---------|---------|-------|---------|
117
- | TypeScript | ✅ | ✅ | ✅ | ✅ |
118
- | JavaScript | | | | ✅ |
119
- | Python | | | ✅ | ✅ |
120
- | Go | 🚧 | 🚧 | 🚧 | 🚧 |
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
- ## Advanced Usage
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
- ### Individual Commands
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
- If you prefer step-by-step:
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
- # Step 1: Scan
131
- npx codemap-ai scan /path/to/project
229
+ # First run: indexes all 290 files
230
+ codemap index
132
231
 
133
- # Step 2: Generate skills
134
- npx codemap-ai generate-skills /path/to/project --name "My Project"
232
+ # Second run: only indexes changed files
233
+ codemap index
234
+ → Indexed: 3 files, Skipped: 287 files (unchanged)
235
+ ```
135
236
 
136
- # Step 3: Add MCP server (optional, for database queries)
137
- claude mcp add codemap -- npx codemap-ai mcp-server --path /path/to/project
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
- ### MCP Tools
246
+ ### Super() Resolution
141
247
 
142
- When the MCP server is connected, Claude Code gains these tools:
248
+ Follows inheritance chains:
143
249
 
144
- - `codemap_search` - Search functions, classes, files
145
- - `codemap_callers` - Find who calls a function
146
- - `codemap_dependencies` - Get import relationships
147
- - `codemap_impact` - Analyze change impact
148
- - `codemap_stats` - Get codebase statistics
250
+ ```python
251
+ class Child(Parent):
252
+ def method(self):
253
+ super().method() # Resolved to Parent.method
254
+ ```
149
255
 
150
- ## Author
256
+ ### Database Operation Detection
151
257
 
152
- Sahan Nishshanka (Hub.KI GmbH)
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