@autodev/codebase 0.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.
Files changed (2) hide show
  1. package/README.md +211 -0
  2. package/package.json +63 -0
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+
2
+
3
+ # @autodev/codebase
4
+
5
+ <div align="center">
6
+ <img src="src/images/image1.png" width="300" alt="Image 1" style="margin: 0 10px;" />
7
+ <img src="src/images/image2.png" width="200" alt="Image 2" style="margin: 0 10px;" />
8
+ <img src="src/images/image3.png" height="150" alt="Image 3" style="margin: 0 10px;" />
9
+ </div>
10
+
11
+ <br />
12
+
13
+ A platform-agnostic code analysis library with semantic search capabilities and MCP (Model Context Protocol) server support. This library provides intelligent code indexing, vector-based semantic search, and can be integrated into various development tools and IDEs.
14
+
15
+ ## 🚀 Features
16
+
17
+ - **Semantic Code Search**: Vector-based code search using embeddings
18
+ - **MCP Server Support**: HTTP-based MCP server for IDE integration
19
+ - **Terminal UI**: Interactive CLI with rich terminal interface
20
+ - **Tree-sitter Parsing**: Advanced code parsing and analysis
21
+ - **Vector Storage**: Qdrant vector database integration
22
+ - **Flexible Embedding**: Support for various embedding models via Ollama
23
+
24
+ ## 📦 Installation
25
+
26
+ ### 1. Install and Start Ollama
27
+
28
+ ```bash
29
+ # Install Ollama (macOS)
30
+ brew install ollama
31
+
32
+ # Start Ollama service
33
+ ollama serve
34
+
35
+ # In a new terminal, pull the embedding model
36
+ ollama pull nomic-embed-text
37
+ ```
38
+
39
+ ### 2. Install and Start Qdrant
40
+
41
+ Start Qdrant using Docker:
42
+
43
+ ```bash
44
+ # Start Qdrant container
45
+ docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
46
+ ```
47
+
48
+ Or download and run Qdrant directly:
49
+
50
+ ```bash
51
+ # Download and run Qdrant
52
+ wget https://github.com/qdrant/qdrant/releases/latest/download/qdrant-x86_64-unknown-linux-gnu.tar.gz
53
+ tar -xzf qdrant-x86_64-unknown-linux-gnu.tar.gz
54
+ ./qdrant
55
+ ```
56
+
57
+ ### 3. Verify Services Are Running
58
+
59
+ ```bash
60
+ # Check Ollama
61
+ curl http://localhost:11434/api/tags
62
+
63
+ # Check Qdrant
64
+ curl http://localhost:6333/collections
65
+ ```
66
+ ### 4. Install project locally
67
+
68
+ ```
69
+ git clone https://github.com/anrgct/autodev-codebase
70
+ cd autodev-codebase
71
+ npm install
72
+ npm run build
73
+ npm link
74
+ ```
75
+ ## 🛠️ Usage
76
+
77
+ ### Command Line Interface
78
+
79
+ The CLI provides two main modes:
80
+
81
+ #### 1. Interactive TUI Mode (Default)
82
+ ```bash
83
+ # Basic usage: index your current folder as the codebase.
84
+ # Be cautious when running this command if you have a large number of files.
85
+ codebase
86
+
87
+
88
+ # With custom options
89
+ codebase --demo # Create a local demo directory and test the indexing service, recommend for setup
90
+ codebase --path=/my/project
91
+ codebase --path=/my/project --log-level=info
92
+ ```
93
+
94
+ #### 2. MCP Server Mode (Recommended for IDE Integration)
95
+ ```bash
96
+ # Start long-running MCP server
97
+ cd /my/project
98
+ codebase mcp-server
99
+
100
+ # With custom configuration
101
+ codebase mcp-server --port=3001 --host=localhost
102
+ codebase mcp-server --path=/workspace --port=3002
103
+ ```
104
+
105
+ ### IDE Integration (Cursor/Claude)
106
+
107
+ Configure your IDE to connect to the MCP server:
108
+
109
+ ```json
110
+ {
111
+ "mcpServers": {
112
+ "codebase": {
113
+ "url": "http://localhost:3001/sse"
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ ### Library Usage
120
+
121
+ #### Node.js Usage
122
+ ```typescript
123
+ import { createNodeDependencies } from '@autodev/codebase/adapters/nodejs'
124
+ import { CodeIndexManager } from '@autodev/codebase'
125
+
126
+ const deps = createNodeDependencies({
127
+ workspacePath: '/path/to/project',
128
+ storageOptions: { /* ... */ },
129
+ loggerOptions: { /* ... */ },
130
+ configOptions: { /* ... */ }
131
+ })
132
+
133
+ const manager = CodeIndexManager.getInstance(deps)
134
+ await manager.initialize()
135
+ await manager.startIndexing()
136
+ ```
137
+
138
+ ## 🔧 CLI Options
139
+
140
+ ### Global Options
141
+ - `--path=<path>` - Workspace path (default: current directory)
142
+ - `--demo` - Create demo files in workspace
143
+ - `--ollama-url=<url>` - Ollama API URL (default: http://localhost:11434)
144
+ - `--qdrant-url=<url>` - Qdrant vector DB URL (default: http://localhost:6333)
145
+ - `--model=<model>` - Embedding model (default: nomic-embed-text)
146
+ - `--config=<path>` - Config file path
147
+ - `--storage=<path>` - Storage directory path
148
+ - `--cache=<path>` - Cache directory path
149
+ - `--log-level=<level>` - Log level: error|warn|info|debug (default: error)
150
+ - `--help, -h` - Show help
151
+
152
+ ### MCP Server Options
153
+ - `--port=<port>` - HTTP server port (default: 3001)
154
+ - `--host=<host>` - HTTP server host (default: localhost)
155
+
156
+ ## 🌐 MCP Server Features
157
+
158
+ ### Web Interface
159
+ - **Home Page**: `http://localhost:3001` - Server status and configuration
160
+ - **Health Check**: `http://localhost:3001/health` - JSON status endpoint
161
+ - **MCP Endpoint**: `http://localhost:3001/sse` - SSE/HTTP MCP protocol endpoint
162
+
163
+ ### Available MCP Tools
164
+ - **`search_codebase`** - Semantic search through your codebase
165
+ - Parameters: `query` (string), `limit` (number), `filters` (object)
166
+ - Returns: Formatted search results with file paths, scores, and code blocks
167
+ - **`get_search_stats`** - Get indexing status and statistics
168
+ - **`configure_search`** - Configure search parameters at runtime
169
+
170
+
171
+ ### Scripts
172
+ ```bash
173
+ # Development mode with demo files
174
+ npm run dev
175
+
176
+ # Build for production
177
+ npm run build
178
+
179
+ # Type checking
180
+ npm run type-check
181
+
182
+ # Run TUI demo
183
+ npm run demo-tui
184
+
185
+ # Start MCP server demo
186
+ npm run mcp-server
187
+ ```
188
+
189
+ ## 💡 Why Use MCP Server Mode?
190
+
191
+ ### Problems Solved
192
+ - **❌ Repeated Indexing**: Every IDE connection re-indexes, wasting time and resources
193
+ - **❌ Complex Configuration**: Each project needs different path parameters in IDE
194
+ - **❌ Resource Waste**: Multiple IDE windows start multiple server instances
195
+
196
+ ### Benefits
197
+ - **✅ One-time Indexing**: Server runs long-term, index persists
198
+ - **✅ Simplified Configuration**: Universal IDE configuration, no project-specific paths
199
+ - **✅ Resource Efficiency**: One server instance per project
200
+ - **✅ Better Developer Experience**: Start server in project directory intuitively
201
+ - **✅ Backward Compatible**: Still supports traditional per-connection mode
202
+ - **✅ Web Interface**: Status monitoring and configuration help
203
+ - **✅ Dual Mode**: Can run both TUI and MCP server simultaneously
204
+
205
+
206
+ This is a platform-agnostic library extracted from the roo-code VSCode plugin.
207
+ ## 📚 Examples
208
+
209
+ See the `examples/` directory for complete usage examples:
210
+ - `nodejs-usage.ts` - Node.js integration examples
211
+ - `run-demo-tui.tsx` - TUI demo application
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@autodev/codebase",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "codebase": "./dist/cli.js"
7
+ },
8
+ "files": [
9
+ "dist/**/*"
10
+ ],
11
+ "scripts": {
12
+ "dev": "rm -rf .autodev-cache/ && npx tsx src/index.ts --demo",
13
+ "build": "rollup -c rollup.config.cjs && chmod +x dist/cli.js",
14
+ "type-check": "npx tsc -p tsconfig.cli.json --noEmit",
15
+ "demo-tui": "npx tsx src/examples/run-demo-tui.tsx",
16
+ "mcp-server": "npx tsx src/index.ts mcp-server --demo --port=3002"
17
+ },
18
+ "peerDependencies": {
19
+ "vscode": "^1.74.0"
20
+ },
21
+ "peerDependenciesMeta": {
22
+ "vscode": {
23
+ "optional": true
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "@modelcontextprotocol/sdk": "^1.13.1",
28
+ "@qdrant/js-client-rest": "^1.11.0",
29
+ "@types/ink": "^2.0.3",
30
+ "async-mutex": "^0.5.0",
31
+ "csstype": "^3.1.3",
32
+ "form-data": "^4.0.3",
33
+ "fzf": "^0.5.2",
34
+ "ignore": "^5.3.1",
35
+ "ink": "^4.4.1",
36
+ "lodash.debounce": "^4.0.8",
37
+ "openai": "^4.52.0",
38
+ "p-limit": "^3.1.0",
39
+ "react": "^18.3.1",
40
+ "tree-sitter": "^0.21.1",
41
+ "tree-sitter-wasms": "^0.1.12",
42
+ "tslib": "^2.7.0",
43
+ "undici-types": "^7.10.0",
44
+ "uuid": "^10.0.0",
45
+ "vitest": "^3.2.4",
46
+ "web-tree-sitter": "^0.23.0"
47
+ },
48
+ "devDependencies": {
49
+ "@rollup/plugin-commonjs": "^26.0.1",
50
+ "@rollup/plugin-json": "^6.1.0",
51
+ "@rollup/plugin-node-resolve": "^15.2.3",
52
+ "@rollup/plugin-typescript": "^11.1.6",
53
+ "@types/express": "^5.0.3",
54
+ "@types/lodash.debounce": "^4.0.9",
55
+ "@types/react": "^18.3.23",
56
+ "@types/uuid": "^10.0.0",
57
+ "@types/vscode": "^1.101.0",
58
+ "rollup": "^4.21.2",
59
+ "tsx": "^4.20.3",
60
+ "typescript": "^5.6.2",
61
+ "vscode": "^1.1.37"
62
+ }
63
+ }