@autodev/codebase 0.0.7 → 1.0.1
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 +142 -119
- package/dist/cli.js +128743 -116952
- package/dist/cli.js.map +1 -1
- package/dist/index.js +20663 -7738
- package/dist/index.js.map +1 -1
- package/dist/static/graph_viewer.html +2333 -0
- package/package.json +17 -16
- package/dist/yoga.wasm +0 -0
- /package/dist/{tree-sitter.wasm → tree-sitter/tree-sitter.wasm} +0 -0
package/README.md
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# @autodev/codebase
|
|
2
2
|
|
|
3
|
-
<
|
|
3
|
+
<p align="center">
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@autodev/codebase)
|
|
6
6
|
[](https://github.com/anrgct/autodev-codebase)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
</
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
A vector embedding-based code semantic search tool with MCP server and multi-model integration. Can be used as a pure CLI tool. Supports Ollama for fully local embedding and reranking, enabling complete offline operation and privacy protection for your code repository.
|
|
10
12
|
|
|
11
13
|
```sh
|
|
14
|
+
# Semantic code search - Find code by meaning, not just keywords
|
|
12
15
|
╭─ ~/workspace/autodev-codebase
|
|
13
|
-
╰─❯ codebase
|
|
14
|
-
Found
|
|
16
|
+
╰─❯ codebase search "user manage" --demo
|
|
17
|
+
Found 20 results in 5 files for: "user manage"
|
|
15
18
|
|
|
16
19
|
==================================================
|
|
17
20
|
File: "hello.js"
|
|
@@ -31,36 +34,44 @@ class UserManager {
|
|
|
31
34
|
return this.users;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
……
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
- UserManager
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## Search Examples
|
|
47
|
-
|
|
48
|
-
Try searching for:
|
|
49
|
-
- "greet user"
|
|
50
|
-
- "process data"
|
|
51
|
-
- "user management"
|
|
52
|
-
- "batch processing"
|
|
53
|
-
- "YOLO model"
|
|
54
|
-
- "computer vision"
|
|
55
|
-
- "object detection"
|
|
56
|
-
- "model training"
|
|
39
|
+
# Call graph analysis - Trace function call relationships and execution paths
|
|
40
|
+
╭─ ~/workspace/autodev-codebase
|
|
41
|
+
╰─❯ codebase call --demo --query="app,addUser"
|
|
42
|
+
Connections between app, addUser:
|
|
43
|
+
|
|
44
|
+
Found 2 matching node(s):
|
|
45
|
+
- demo/app:L1-29
|
|
46
|
+
- demo/hello.UserManager.addUser:L12-15
|
|
47
|
+
|
|
48
|
+
Direct connections:
|
|
49
|
+
- demo/app:L1-29 → demo/hello.UserManager.addUser:L12-15
|
|
57
50
|
|
|
51
|
+
Chains found:
|
|
52
|
+
- demo/app:L1-29 → demo/hello.UserManager.addUser:L12-15
|
|
53
|
+
|
|
54
|
+
# Code outline with AI summaries - Understand code structure at a glance
|
|
55
|
+
╭─ ~/workspace/autodev-codebase
|
|
56
|
+
╰─❯ codebase outline 'hello.js' --demo --summarize
|
|
57
|
+
# hello.js (23 lines)
|
|
58
|
+
└─ Defines a greeting function that logs a personalized hello message and returns a welcome string. Implements a UserManager class managing an array of users with methods to add users and retrieve the current user list. Exports both components for external use.
|
|
59
|
+
|
|
60
|
+
2--5 | function greetUser
|
|
61
|
+
└─ Implements user greeting logic by logging a personalized hello message and returning a welcome message
|
|
62
|
+
|
|
63
|
+
7--20 | class UserManager
|
|
64
|
+
└─ Manages user data with methods to add users to a list and retrieve all stored users
|
|
65
|
+
|
|
66
|
+
12--15 | method addUser
|
|
67
|
+
└─ Adds a user to the users array and logs a confirmation message with the user's name.
|
|
58
68
|
```
|
|
59
|
-
|
|
69
|
+
|
|
60
70
|
|
|
61
71
|
## 🚀 Features
|
|
62
72
|
|
|
63
73
|
- **🔍 Semantic Code Search**: Vector-based search using advanced embedding models
|
|
74
|
+
- **🔗 Call Graph Analysis**: Trace function call relationships and execution paths
|
|
64
75
|
- **🌐 MCP Server**: HTTP-based MCP server with SSE and stdio adapters
|
|
65
76
|
- **💻 Pure CLI Tool**: Standalone command-line interface without GUI dependencies
|
|
66
77
|
- **⚙️ Layered Configuration**: CLI, project, and global config management
|
|
@@ -71,6 +82,7 @@ A vector embedding-based code semantic search tool with MCP server and multi-mod
|
|
|
71
82
|
- **📊 Real-time Watching**: Automatic index updates
|
|
72
83
|
- **⚡ Batch Processing**: Efficient parallel processing
|
|
73
84
|
- **📝 Code Outline Extraction**: Generate structured code outlines with AI summaries
|
|
85
|
+
- **💨 Dependency Analysis Cache**: Intelligent caching for 10-50x faster re-analysis
|
|
74
86
|
|
|
75
87
|
## 📦 Installation
|
|
76
88
|
|
|
@@ -89,7 +101,7 @@ docker run -d -p 6333:6333 -p 6334:6334 --name qdrant qdrant/qdrant
|
|
|
89
101
|
### 3. Install
|
|
90
102
|
```bash
|
|
91
103
|
npm install -g @autodev/codebase
|
|
92
|
-
codebase --set
|
|
104
|
+
codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text
|
|
93
105
|
```
|
|
94
106
|
|
|
95
107
|
## 🛠️ Quick Start
|
|
@@ -99,108 +111,125 @@ codebase --set-config embedderProvider=ollama,embedderModelId=nomic-embed-text
|
|
|
99
111
|
# Creates a demo directory in current working directory for testing
|
|
100
112
|
|
|
101
113
|
# Index & search
|
|
102
|
-
codebase --demo
|
|
103
|
-
codebase
|
|
114
|
+
codebase index --demo
|
|
115
|
+
codebase search "user greet" --demo
|
|
116
|
+
|
|
117
|
+
# Call graph analysis
|
|
118
|
+
codebase call --demo --query="app,addUser"
|
|
104
119
|
|
|
105
120
|
# MCP server
|
|
106
|
-
codebase --
|
|
121
|
+
codebase index --serve --demo
|
|
107
122
|
```
|
|
108
123
|
|
|
109
124
|
## 📋 Commands
|
|
110
125
|
|
|
111
|
-
### 📝
|
|
112
|
-
|
|
113
|
-
Generate intelligent code summaries with one command:
|
|
114
|
-
|
|
126
|
+
### 📝 Code Outlines
|
|
115
127
|
```bash
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
**Output Example:**
|
|
120
|
-
```
|
|
121
|
-
# src/cli.ts (1902 lines)
|
|
122
|
-
└─ Implements a simplified CLI for @autodev/codebase using Node.js native parseArgs.
|
|
123
|
-
Manages codebase indexing, searching, and MCP server operations.
|
|
128
|
+
# Extract code structure (functions, classes, methods)
|
|
129
|
+
codebase outline "src/**/*.ts"
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
# Generate code structure with AI summaries
|
|
132
|
+
codebase outline "src/**/*.ts" --summarize
|
|
127
133
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
and relevance score.
|
|
134
|
+
# View only file-level summaries
|
|
135
|
+
codebase outline "src/**/*.ts" --summarize --title
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
# Clear summary cache
|
|
138
|
+
codebase outline --clear-summarize-cache
|
|
133
139
|
```
|
|
134
140
|
|
|
135
|
-
|
|
136
|
-
- 🧠 **Understand code fast** - Get function-level summaries without reading every line
|
|
137
|
-
- 💾 **Smart caching** - Only summarizes changed code blocks
|
|
138
|
-
- 🌐 **Multi-language** - English/Chinese summaries supported
|
|
139
|
-
- ⚡ **Batch processing** - Efficiently handles large codebases
|
|
140
|
-
|
|
141
|
-
**Quick Setup:**
|
|
141
|
+
### 🔗 Call Graph Analysis
|
|
142
142
|
```bash
|
|
143
|
-
#
|
|
144
|
-
codebase
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
# 📊 Statistics Overview (no --query)
|
|
144
|
+
codebase call # Show statistics overview
|
|
145
|
+
codebase call --json # JSON format
|
|
146
|
+
codebase call src/commands # Analyze specific directory
|
|
147
|
+
|
|
148
|
+
# 🔍 Function Query (with --query)
|
|
149
|
+
codebase call --query="getUser" # Single function call tree (default depth: 3)
|
|
150
|
+
codebase call --query="main" --depth=5 # Custom depth
|
|
151
|
+
codebase call --query="getUser,validateUser" # Multi-function connections (default depth: 10)
|
|
152
|
+
|
|
153
|
+
# 🎨 Visualization
|
|
154
|
+
codebase call --viz graph.json # Export Cytoscape.js format
|
|
155
|
+
codebase call --open # Open interactive viewer
|
|
156
|
+
codebase call --viz graph.json --open # Export and open
|
|
157
|
+
|
|
158
|
+
# Specify workspace (works for both modes)
|
|
159
|
+
codebase call --path=/my/project --query="main"
|
|
148
160
|
```
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
**Query Patterns:**
|
|
163
|
+
- **Exact match**: `--query="functionName"` or `--query="*ClassName.methodName"`
|
|
164
|
+
- **Wildcards**: `*` (any characters), `?` (single character)
|
|
165
|
+
- Examples: `--query="get*"`, `--query="*User*"`, `--query="*.*.get*"`
|
|
166
|
+
- **Single function**: `--query="main"` - Shows call tree (upward + downward)
|
|
167
|
+
- Default depth: **3** (avoids excessive output)
|
|
168
|
+
- **Multiple functions**: `--query="main,helper"` - Analyzes connection paths between functions
|
|
169
|
+
- Default depth: **10** (deeper search needed for path finding)
|
|
170
|
+
|
|
171
|
+
**Supported Languages:**
|
|
172
|
+
- **TypeScript/JavaScript** (.ts, .tsx, .js, .jsx)
|
|
173
|
+
- **Python** (.py)
|
|
174
|
+
- **Java** (.java)
|
|
175
|
+
- **C/C++** (.c, .h, .cpp, .cc, .cxx, .hpp, .hxx, .c++)
|
|
176
|
+
- **C#** (.cs)
|
|
177
|
+
- **Rust** (.rs)
|
|
178
|
+
- **Go** (.go)
|
|
179
|
+
|
|
180
|
+
### 🔍 Indexing & Search
|
|
152
181
|
```bash
|
|
153
182
|
# Index the codebase
|
|
154
|
-
codebase
|
|
183
|
+
codebase index --path=/my/project --force
|
|
155
184
|
|
|
156
185
|
# Search with filters
|
|
157
|
-
codebase
|
|
186
|
+
codebase search "error handling" --path-filters="src/**/*.ts"
|
|
158
187
|
|
|
159
188
|
# Search with custom limit and minimum score
|
|
160
|
-
codebase
|
|
161
|
-
codebase
|
|
189
|
+
codebase search "authentication" --limit=20 --min-score=0.7
|
|
190
|
+
codebase search "API" -l 30 -S 0.5
|
|
162
191
|
|
|
163
192
|
# Search in JSON format
|
|
164
|
-
codebase
|
|
193
|
+
codebase search "authentication" --json
|
|
165
194
|
|
|
166
195
|
# Clear index data
|
|
167
|
-
codebase --clear --path=/my/project
|
|
196
|
+
codebase index --clear-cache --path=/my/project
|
|
168
197
|
```
|
|
169
198
|
|
|
170
|
-
### MCP Server
|
|
199
|
+
### 🌐 MCP Server
|
|
171
200
|
```bash
|
|
172
201
|
# HTTP mode (recommended)
|
|
173
|
-
codebase --serve --port=3001 --path=/my/project
|
|
202
|
+
codebase index --serve --port=3001 --path=/my/project
|
|
174
203
|
|
|
175
204
|
# Stdio adapter
|
|
176
|
-
codebase
|
|
205
|
+
codebase stdio --server-url=http://localhost:3001/mcp
|
|
177
206
|
```
|
|
178
207
|
|
|
179
|
-
### Configuration
|
|
208
|
+
### ⚙️ Configuration
|
|
180
209
|
```bash
|
|
181
210
|
# View config
|
|
182
|
-
codebase --get
|
|
183
|
-
codebase --get
|
|
211
|
+
codebase config --get
|
|
212
|
+
codebase config --get embedderProvider --json
|
|
184
213
|
|
|
185
214
|
# Set config
|
|
186
|
-
codebase --set
|
|
187
|
-
codebase --set
|
|
215
|
+
codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text
|
|
216
|
+
codebase config --set --global qdrantUrl=http://localhost:6333
|
|
188
217
|
```
|
|
189
218
|
|
|
190
|
-
### Advanced Features
|
|
219
|
+
### 🚀 Advanced Features
|
|
191
220
|
|
|
192
221
|
#### 🔍 LLM-Powered Search Reranking
|
|
193
222
|
Enable LLM reranking to dramatically improve search relevance:
|
|
194
223
|
|
|
195
224
|
```bash
|
|
196
225
|
# Enable reranking with Ollama (recommended)
|
|
197
|
-
codebase --set
|
|
226
|
+
codebase config --set rerankerEnabled=true,rerankerProvider=ollama,rerankerOllamaModelId=qwen3-vl:4b-instruct
|
|
198
227
|
|
|
199
228
|
# Or use OpenAI-compatible providers
|
|
200
|
-
codebase --set
|
|
229
|
+
codebase config --set rerankerEnabled=true,rerankerProvider=openai-compatible,rerankerOpenAiCompatibleModelId=deepseek-chat
|
|
201
230
|
|
|
202
231
|
# Search with automatic reranking
|
|
203
|
-
codebase
|
|
232
|
+
codebase search "user authentication" # Results are automatically reranked by LLM
|
|
204
233
|
```
|
|
205
234
|
|
|
206
235
|
**Benefits:**
|
|
@@ -212,36 +241,24 @@ codebase --search="user authentication" # Results are automatically reranked by
|
|
|
212
241
|
#### Path Filtering & Export
|
|
213
242
|
```bash
|
|
214
243
|
# Path filtering with brace expansion and exclusions
|
|
215
|
-
codebase
|
|
216
|
-
codebase
|
|
244
|
+
codebase search "API" --path-filters="src/**/*.ts,lib/**/*.js"
|
|
245
|
+
codebase search "utils" --path-filters="{src,test}/**/*.ts"
|
|
217
246
|
|
|
218
247
|
# Export results in JSON format for scripts
|
|
219
|
-
codebase
|
|
248
|
+
codebase search "auth" --json
|
|
220
249
|
```
|
|
221
250
|
|
|
222
|
-
####
|
|
223
|
-
Generate intelligent code summaries and outlines:
|
|
251
|
+
#### Path Filtering & Export
|
|
224
252
|
|
|
225
253
|
```bash
|
|
226
|
-
#
|
|
227
|
-
codebase --
|
|
228
|
-
|
|
229
|
-
# With AI summaries (recommended)
|
|
230
|
-
codebase --outline "src/**/*.ts" --summarize
|
|
231
|
-
|
|
232
|
-
# Preview before processing
|
|
233
|
-
codebase --outline "src/**/*.ts" --dry-run
|
|
254
|
+
# Path filtering with brace expansion and exclusions
|
|
255
|
+
codebase search "API" --path-filters="src/**/*.ts,lib/**/*.js"
|
|
256
|
+
codebase search "utils" --path-filters="{src,test}/**/*.ts"
|
|
234
257
|
|
|
235
|
-
#
|
|
236
|
-
codebase
|
|
258
|
+
# Export results in JSON format for scripts
|
|
259
|
+
codebase search "auth" --json
|
|
237
260
|
```
|
|
238
261
|
|
|
239
|
-
**Key Benefits:**
|
|
240
|
-
- 🎯 **Function-level summaries**: Understand code purpose at a glance
|
|
241
|
-
- 💾 **Smart caching**: Avoid redundant LLM calls
|
|
242
|
-
- 🌐 **Multi-language**: English / Chinese support
|
|
243
|
-
- ⚡ **Batch processing**: Efficiently handle large codebases
|
|
244
|
-
|
|
245
262
|
## ⚙️ Configuration
|
|
246
263
|
|
|
247
264
|
### Config Layers (Priority Order)
|
|
@@ -250,7 +267,7 @@ codebase --outline src/index.ts --summarize --clear-summarize-cache
|
|
|
250
267
|
3. **Global Config** - `~/.autodev-cache/autodev-config.json`
|
|
251
268
|
4. **Built-in Defaults** - Fallback values
|
|
252
269
|
|
|
253
|
-
**Note:** CLI arguments provide runtime override for paths, logging, and operational behavior. For persistent configuration (embedderProvider, API keys, search parameters), use
|
|
270
|
+
**Note:** CLI arguments provide runtime override for paths, logging, and operational behavior. For persistent configuration (embedderProvider, API keys, search parameters), use `config --set` to save to config files.
|
|
254
271
|
|
|
255
272
|
### Common Config Examples
|
|
256
273
|
|
|
@@ -295,36 +312,42 @@ codebase --outline src/index.ts --summarize --clear-summarize-cache
|
|
|
295
312
|
| **Summarizer** | `summarizerProvider`, `summarizerLanguage`, `summarizerBatchSize` | AI summary generation |
|
|
296
313
|
|
|
297
314
|
**Key CLI Arguments:**
|
|
298
|
-
-
|
|
299
|
-
-
|
|
315
|
+
- `index` - Index the codebase
|
|
316
|
+
- `search <query>` - Search the codebase (required positional argument)
|
|
317
|
+
- `outline <pattern>` - Extract code outlines (supports glob patterns)
|
|
318
|
+
- `call` - Analyze function call relationships and dependency graphs
|
|
319
|
+
- `stdio` - Start stdio adapter for MCP
|
|
320
|
+
- `config` - Manage configuration (use with --get or --set)
|
|
321
|
+
- `--serve` - Start MCP HTTP server (use with `index` command)
|
|
300
322
|
- `--summarize` - Generate AI summaries for code outlines
|
|
301
323
|
- `--dry-run` - Preview operations before execution
|
|
302
324
|
- `--title` - Show only file-level summaries
|
|
303
325
|
- `--clear-summarize-cache` - Clear all summary caches
|
|
304
|
-
- `--get-config` / `--set-config` - Configuration management
|
|
305
326
|
- `--path`, `--demo`, `--force` - Common options
|
|
306
327
|
- `--limit` / `-l <number>` - Maximum number of search results (default: from config, max 50)
|
|
307
328
|
- `--min-score` / `-S <number>` - Minimum similarity score for search results (0-1, default: from config)
|
|
329
|
+
- `--query <patterns>` - Query patterns for call graph analysis (comma-separated)
|
|
330
|
+
- `--viz <file>` - Export full dependency data for visualization (cannot use with --query)
|
|
331
|
+
- `--open` - Open interactive graph viewer
|
|
332
|
+
- `--depth <number>` - Set analysis depth for call graphs
|
|
308
333
|
- `--help` - Show all available options
|
|
309
334
|
|
|
310
|
-
For complete CLI reference, see [CONFIG.md](CONFIG.md).
|
|
311
|
-
|
|
312
335
|
**Configuration Commands:**
|
|
313
336
|
```bash
|
|
314
337
|
# View config
|
|
315
|
-
codebase --get
|
|
316
|
-
codebase --get
|
|
338
|
+
codebase config --get
|
|
339
|
+
codebase config --get --json
|
|
317
340
|
|
|
318
341
|
# Set config (saves to file)
|
|
319
|
-
codebase --set
|
|
320
|
-
codebase --set
|
|
342
|
+
codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text
|
|
343
|
+
codebase config --set --global embedderProvider=openai,embedderOpenAiApiKey=sk-xxx
|
|
321
344
|
|
|
322
345
|
# Use custom config file
|
|
323
|
-
codebase --config=/path/to/config.json --get
|
|
324
|
-
codebase --config=/path/to/config.json --set
|
|
346
|
+
codebase --config=/path/to/config.json config --get
|
|
347
|
+
codebase --config=/path/to/config.json config --set embedderProvider=ollama
|
|
325
348
|
|
|
326
349
|
# Runtime override (paths, logging, etc.)
|
|
327
|
-
codebase
|
|
350
|
+
codebase index --path=/my/project --log-level=info --force
|
|
328
351
|
```
|
|
329
352
|
|
|
330
353
|
For complete configuration reference, see [CONFIG.md](CONFIG.md).
|
|
@@ -333,7 +356,7 @@ For complete configuration reference, see [CONFIG.md](CONFIG.md).
|
|
|
333
356
|
|
|
334
357
|
### HTTP Streamable Mode (Recommended)
|
|
335
358
|
```bash
|
|
336
|
-
codebase --serve --port=3001
|
|
359
|
+
codebase index --serve --port=3001
|
|
337
360
|
```
|
|
338
361
|
|
|
339
362
|
**IDE Config:**
|
|
@@ -350,10 +373,10 @@ codebase --serve --port=3001
|
|
|
350
373
|
### Stdio Adapter
|
|
351
374
|
```bash
|
|
352
375
|
# First start the MCP server in one terminal
|
|
353
|
-
codebase --serve --port=3001
|
|
376
|
+
codebase index --serve --port=3001
|
|
354
377
|
|
|
355
378
|
# Then connect via stdio adapter in another terminal (for IDEs that require stdio)
|
|
356
|
-
codebase
|
|
379
|
+
codebase stdio --server-url=http://localhost:3001/mcp
|
|
357
380
|
```
|
|
358
381
|
|
|
359
382
|
**IDE Config:**
|
|
@@ -362,7 +385,7 @@ codebase --stdio-adapter --server-url=http://localhost:3001/mcp
|
|
|
362
385
|
"mcpServers": {
|
|
363
386
|
"codebase": {
|
|
364
387
|
"command": "codebase",
|
|
365
|
-
"args": ["stdio
|
|
388
|
+
"args": ["stdio", "--server-url=http://localhost:3001/mcp"]
|
|
366
389
|
}
|
|
367
390
|
}
|
|
368
391
|
}
|