codebaxing 0.2.0 → 0.2.2

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.vi.md CHANGED
@@ -3,15 +3,28 @@
3
3
  [![npm version](https://img.shields.io/npm/v/codebaxing.svg)](https://www.npmjs.com/package/codebaxing)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
+ [English](README.md) | **[Tiếng Việt](README.vi.md)**
7
+
6
8
  MCP server cho **semantic code search**. Index codebase và tìm kiếm bằng ngôn ngữ tự nhiên.
7
9
 
10
+ ## Mục lục
11
+
12
+ - [Ý tưởng](#ý-tưởng)
13
+ - [Bắt đầu nhanh](#bắt-đầu-nhanh)
14
+ - [Cách sử dụng](#cách-sử-dụng)
15
+ - [Qua AI Agents (MCP)](#qua-ai-agents-mcp)
16
+ - [Qua CLI (Terminal)](#qua-cli-terminal)
17
+ - [Cài đặt](#cài-đặt)
18
+ - [Cơ chế hoạt động](#cơ-chế-hoạt-động)
19
+ - [Cấu hình](#cấu-hình)
20
+ - [Ngôn ngữ hỗ trợ](#ngôn-ngữ-hỗ-trợ)
21
+
8
22
  ## Ý tưởng
9
23
 
10
24
  Tìm kiếm code truyền thống (grep, ripgrep) chỉ match exact text. Nhưng lập trình viên suy nghĩ theo khái niệm:
11
25
 
12
26
  - *"Logic xác thực người dùng ở đâu?"* - không phải `grep "authentication"`
13
27
  - *"Tìm code kết nối database"* - không phải `grep "database"`
14
- - *"Xử lý lỗi hoạt động như thế nào?"* - không phải `grep "error"`
15
28
 
16
29
  **Codebaxing** giải quyết vấn đề này bằng **semantic search**:
17
30
 
@@ -22,216 +35,173 @@ Tìm được: login(), validateCredentials(), checkPassword(), authMiddleware()
22
35
  (dù chúng không chứa từ "authentication")
23
36
  ```
24
37
 
25
- ## chế hoạt động
38
+ ## Bắt đầu nhanh
26
39
 
27
- ### Kiến trúc tổng quan
28
-
29
- ```
30
- ┌─────────────────────────────────────────────────────────────────┐
31
- │ INDEXING │
32
- ├─────────────────────────────────────────────────────────────────┤
33
- │ │
34
- │ Source Files (.py, .ts, .js, .go, .rs, ...) │
35
- │ │ │
36
- │ ▼ │
37
- │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
38
- │ │ Tree-sitter │───▶│ Symbols │───▶│ Embedding │ │
39
- │ │ Parser │ │ Extraction │ │ Model │ │
40
- │ └──────────────┘ └──────────────┘ └──────────────┘ │
41
- │ │ │ │ │
42
- │ Parse AST Functions, Text → Vector │
43
- │ Classes, etc. (384 chiều) │
44
- │ │ │
45
- │ ▼ │
46
- │ ┌──────────────┐ │
47
- │ │ ChromaDB │ │
48
- │ │ (vectors) │ │
49
- │ └──────────────┘ │
50
- │ │
51
- └─────────────────────────────────────────────────────────────────┘
40
+ ### 1. Cài vào AI editor của bạn
52
41
 
53
- ┌─────────────────────────────────────────────────────────────────┐
54
- │ SEARCH │
55
- ├─────────────────────────────────────────────────────────────────┤
56
- │ │
57
- │ "find auth code" │
58
- │ │ │
59
- │ ▼ │
60
- │ ┌──────────────┐ ┌──────────────┐ │
61
- │ │ Embedding │────────▶│ ChromaDB │ │
62
- │ │ Model │ query │ Query │ │
63
- │ └──────────────┘ vector └──────────────┘ │
64
- │ │ │
65
- │ ▼ │
66
- │ Cosine Similarity │
67
- │ │ │
68
- │ ▼ │
69
- │ Top-k Results │
70
- │ (login.py, auth.ts, ...) │
71
- │ │
72
- └─────────────────────────────────────────────────────────────────┘
42
+ ```bash
43
+ npx codebaxing install # Claude Desktop
44
+ npx codebaxing install --cursor # Cursor
45
+ npx codebaxing install --windsurf # Windsurf
46
+ npx codebaxing install --all # Tất cả editors
73
47
  ```
74
48
 
75
- ### Quy trình chi tiết
49
+ ### 2. Khởi động lại editor
76
50
 
77
- #### 1. Parsing (Tree-sitter)
51
+ ### 3. Bắt đầu sử dụng
78
52
 
79
- Tree-sitter parse source code thành Abstract Syntax Tree (AST), trích xuất các symbols có ý nghĩa:
53
+ Trong Claude Desktop (hoặc Cursor, Windsurf...):
80
54
 
81
- ```python
82
- # Input: auth.py
83
- def login(username, password):
84
- """Authenticate user credentials"""
85
- if validate(username, password):
86
- return create_session(username)
87
- raise AuthError("Invalid credentials")
88
55
  ```
56
+ Bạn: Index project của tôi tại /path/to/myproject
57
+ Claude: [gọi index tool]
89
58
 
90
- ```
91
- # Output: Symbol
92
- {
93
- name: "login",
94
- type: "function",
95
- signature: "def login(username, password)",
96
- code: "def login(username, password):...",
97
- filepath: "auth.py",
98
- lineStart: 1,
99
- lineEnd: 6
100
- }
59
+ Bạn: Tìm logic xác thực
60
+ Claude: [gọi search tool, trả về code liên quan]
101
61
  ```
102
62
 
103
- #### 2. Embedding (all-MiniLM-L6-v2)
63
+ ## Cách sử dụng
104
64
 
105
- Mỗi code chunk được chuyển thành vector 384 chiều bằng neural network:
65
+ ### Qua AI Agents (MCP)
66
+
67
+ Sau khi cài vào AI editor, bạn tương tác qua hội thoại tự nhiên:
68
+
69
+ #### Bước 1: Index codebase (Bắt buộc đầu tiên)
106
70
 
107
71
  ```
108
- "def login(username, password): authenticate user..."
109
-
110
- Embedding Model (chạy local, ONNX)
111
-
112
- [0.12, -0.34, 0.56, 0.08, ..., -0.22] (384 số)
72
+ Bạn: Index codebase tại /Users/me/projects/myapp
113
73
  ```
114
74
 
115
- Model hiểu được quan hệ ngữ nghĩa:
116
- - `"authentication"` ≈ `"login"` ≈ `"credentials"` (vectors gần nhau)
117
- - `"database"` ≈ `"query"` ≈ `"SQL"` (vectors gần nhau)
118
- - `"authentication"` ≠ `"database"` (vectors xa nhau)
75
+ Claude sẽ gọi `index(path="/Users/me/projects/myapp")` hiển thị tiến trình.
119
76
 
120
- #### 3. Lưu trữ (ChromaDB)
77
+ > **Lưu ý:** Lần đầu chạy sẽ download embedding model (~90MB), mất 1-2 phút.
121
78
 
122
- Vectors được lưu trong ChromaDB, database tối ưu cho similarity search:
79
+ #### Bước 2: Tìm kiếm code
123
80
 
124
81
  ```
125
- ChromaDB Collection:
126
- ┌─────────────────────────────────────────────────────┐
127
- ID │ Vector (384d) │ Metadata │
128
- ├─────────────────────────────────────────────────────┤
129
- │ chunk_001 │ [0.12, -0.34, ...] │ {file: auth.py} │
130
- │ chunk_002 │ [0.45, 0.23, ...] │ {file: db.py} │
131
- │ chunk_003 │ [-0.11, 0.67, ...] │ {file: api.ts} │
132
- │ ... │ ... │ ... │
133
- └─────────────────────────────────────────────────────┘
82
+ Bạn: Tìm code xử lý xác thực người dùng
83
+ Bạn: Logic kết nối database ở đâu?
84
+ Bạn: Cho tôi xem patterns xử lý lỗi
134
85
  ```
135
86
 
136
- #### 4. Tìm kiếm (Cosine Similarity)
137
-
138
- Khi bạn search, query được embed và so sánh với tất cả vectors đã lưu:
87
+ #### Bước 3: Sử dụng memory (tùy chọn)
139
88
 
140
89
  ```
141
- Query: "user authentication"
142
-
143
- Query Vector: [0.15, -0.31, 0.52, ...]
144
-
145
- So sánh với tất cả vectors bằng cosine similarity:
146
- - chunk_001 (login): similarity = 0.89 ← CAO
147
- - chunk_002 (db): similarity = 0.23 ← THẤP
148
- - chunk_003 (auth): similarity = 0.85 ← CAO
149
-
150
- Trả về top-k chunks tương tự nhất
90
+ Bạn: Ghi nhớ rằng chúng ta dùng PostgreSQL với Prisma ORM
91
+ Bạn: Những quyết định nào đã được đưa ra về database?
151
92
  ```
152
93
 
153
- ### Tại sao Semantic Search hoạt động
94
+ #### Bảng tham chiếu MCP Tools
154
95
 
155
- Embedding model được train trên hàng triệu cặp text, học được rằng:
96
+ | Tool | tả | dụ |
97
+ |------|-------|-------|
98
+ | `index` | Index codebase (**bắt buộc đầu tiên**) | `index(path="/project")` |
99
+ | `search` | Tìm kiếm code semantic | `search(question="auth middleware")` |
100
+ | `stats` | Thống kê index | `stats()` |
101
+ | `languages` | Extensions hỗ trợ | `languages()` |
102
+ | `remember` | Lưu memory | `remember(content="Dùng Redis", memory_type="decision")` |
103
+ | `recall` | Truy xuất memories | `recall(query="database")` |
104
+ | `forget` | Xóa memories | `forget(memory_type="note")` |
105
+ | `memory-stats` | Thống kê memory | `memory-stats()` |
156
106
 
157
- | Khái niệm A | ≈ Tương tự với | Khoảng cách |
158
- |-------------|----------------|-------------|
159
- | authentication | login, credentials, auth, signin | Gần |
160
- | database | query, SQL, connection, ORM | Gần |
161
- | error | exception, failure, catch, throw | Gần |
162
- | parse | tokenize, lexer, AST, syntax | Gần |
107
+ ### Qua CLI (Terminal)
163
108
 
164
- Điều này cho phép tìm code theo **ý nghĩa**, không chỉ từ khóa.
109
+ Bạn thể dùng Codebaxing trực tiếp từ terminal không cần AI agents:
165
110
 
166
- ## Tính năng
111
+ #### Bước 1: Index codebase (Bắt buộc đầu tiên)
167
112
 
168
- - **Semantic Code Search**: Tìm code bằng cách mô tả những gì bạn cần
169
- - **24+ Ngôn ngữ**: Python, TypeScript, JavaScript, Go, Rust, Java, C/C++, và nhiều hơn nữa
170
- - **Memory Layer**: Lưu trữ và truy xuất context dự án qua các session
171
- - **Incremental Indexing**: Chỉ re-index các file đã thay đổi
172
- - **100% Local**: Không gọi API, không cloud, hoạt động offline
173
- - **GPU Acceleration**: Hỗ trợ WebGPU/CUDA tùy chọn
113
+ ```bash
114
+ npx codebaxing index /path/to/project
115
+ ```
174
116
 
175
- ## Yêu cầu
117
+ Output:
118
+ ```
119
+ 🔧 Codebaxing - Index Codebase
120
+
121
+ 📁 Path: /path/to/project
122
+
123
+ ================================================================================
124
+ INDEXING CODEBASE
125
+ ================================================================================
126
+ Found 47 files
127
+ Parsed 645 symbols from 47 files
128
+ Generating embeddings for 645 chunks...
129
+ Model loaded: Xenova/all-MiniLM-L6-v2 (384 dims, CPU)
130
+
131
+ ================================================================================
132
+ INDEXING COMPLETE
133
+ ================================================================================
134
+ Files parsed: 47
135
+ Symbols extracted: 645
136
+ Chunks created: 645
137
+ Time elapsed: 21.9s
138
+ ```
176
139
 
177
- - Node.js >= 20.0.0
178
- - ~500MB dung lượng đĩa cho embedding model (tải xuống lần chạy đầu tiên)
140
+ #### Bước 2: Tìm kiếm code
179
141
 
180
- ## Cài đặt
142
+ ```bash
143
+ npx codebaxing search "authentication middleware"
144
+ npx codebaxing search "database connection" --path ./src --limit 10
145
+ ```
181
146
 
182
- ### Cài nhanh (Khuyến nghị)
147
+ Output:
148
+ ```
149
+ 🔧 Codebaxing - Search
183
150
 
184
- ```bash
185
- # Cài vào Claude Desktop
186
- npx codebaxing install
151
+ 📁 Path: /path/to/project
152
+ 🔍 Query: "authentication middleware"
153
+ 📊 Limit: 5
187
154
 
188
- # Cài vào Cursor
189
- npx codebaxing install --cursor
155
+ ────────────────────────────────────────────────────────────
156
+ Results:
190
157
 
191
- # Cài vào Windsurf
192
- npx codebaxing install --windsurf
158
+ 1. src/middleware/auth.ts:15 - authMiddleware()
159
+ 2. src/services/auth.ts:42 - validateToken()
160
+ 3. src/routes/login.ts:8 - loginHandler()
193
161
 
194
- # Cài vào tất cả editors
195
- npx codebaxing install --all
162
+ ────────────────────────────────────────────────────────────
196
163
  ```
197
164
 
198
- Sau đó restart editor. Xong!
199
-
200
- ### Gỡ cài đặt
165
+ #### Bước 3: Xem thống kê
201
166
 
202
167
  ```bash
203
- npx codebaxing uninstall # Gỡ khỏi Claude Desktop
204
- npx codebaxing uninstall --all # Gỡ khỏi tất cả editors
168
+ npx codebaxing stats /path/to/project
205
169
  ```
206
170
 
207
- ### Cài thủ công
171
+ #### Bảng tham chiếu CLI Commands
208
172
 
209
- Nếu muốn cấu hình thủ công, xem [Cấu hình thủ công](#cấu-hình-claude-desktop) bên dưới.
173
+ | Command | tả |
174
+ |---------|-------|
175
+ | `npx codebaxing install [--editor]` | Cài MCP server vào AI editor |
176
+ | `npx codebaxing uninstall [--editor]` | Gỡ MCP server |
177
+ | `npx codebaxing index <path>` | Index codebase |
178
+ | `npx codebaxing search <query> [options]` | Tìm kiếm codebase đã index |
179
+ | `npx codebaxing stats [path]` | Hiển thị thống kê index |
180
+ | `npx codebaxing --help` | Hiển thị help |
210
181
 
211
- ### (Tùy chọn) Persistent Storage
182
+ **Search options:**
183
+ - `--path, -p <path>` - Đường dẫn codebase (mặc định: thư mục hiện tại)
184
+ - `--limit, -n <number>` - Số kết quả (mặc định: 5)
212
185
 
213
- Mặc định, index được lưu trong memory và mất khi server restart.
186
+ ## Cài đặt
214
187
 
215
- Để lưu trữ vĩnh viễn, chạy ChromaDB:
188
+ ### Cách 1: Cài nhanh (Khuyến nghị)
216
189
 
217
190
  ```bash
218
- # Dùng Docker (khuyến nghị)
219
- docker run -d -p 8000:8000 chromadb/chroma
220
-
221
- # Set biến môi trường
222
- export CHROMADB_URL=http://localhost:8000
191
+ npx codebaxing install # Claude Desktop (mặc định)
192
+ npx codebaxing install --cursor # Cursor
193
+ npx codebaxing install --windsurf # Windsurf (Codeium)
194
+ npx codebaxing install --zed # Zed
195
+ npx codebaxing install --all # Tất cả editors
223
196
  ```
224
197
 
225
- ### Cấu hình thủ công
226
-
227
- #### Cấu hình Claude Desktop
198
+ Sau đó restart editor.
228
199
 
229
- Thêm vào file config của Claude Desktop:
200
+ ### Cách 2: Cấu hình thủ công
230
201
 
231
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
232
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
202
+ #### Claude Desktop
233
203
 
234
- #### Qua npx (không cần cài):
204
+ Thêm vào `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) hoặc `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
235
205
 
236
206
  ```json
237
207
  {
@@ -244,60 +214,24 @@ Thêm vào file config của Claude Desktop:
244
214
  }
245
215
  ```
246
216
 
247
- #### Qua global install:
248
-
249
- ```bash
250
- npm install -g codebaxing
251
- ```
252
-
253
- ```json
254
- {
255
- "mcpServers": {
256
- "codebaxing": {
257
- "command": "codebaxing"
258
- }
259
- }
260
- }
261
- ```
217
+ #### Cursor
262
218
 
263
- #### Với persistent storage (ChromaDB):
219
+ Thêm vào `~/.cursor/mcp.json`:
264
220
 
265
221
  ```json
266
222
  {
267
223
  "mcpServers": {
268
224
  "codebaxing": {
269
225
  "command": "npx",
270
- "args": ["-y", "codebaxing"],
271
- "env": {
272
- "CHROMADB_URL": "http://localhost:8000"
273
- }
274
- }
275
- }
276
- }
277
- ```
278
-
279
- #### Từ source (development):
280
-
281
- ```json
282
- {
283
- "mcpServers": {
284
- "codebaxing": {
285
- "command": "node",
286
- "args": ["/path/to/codebaxing/dist/mcp/server.js"]
226
+ "args": ["-y", "codebaxing"]
287
227
  }
288
228
  }
289
229
  }
290
230
  ```
291
231
 
292
- ### Khởi động lại Claude Desktop
293
-
294
- Các tool Codebaxing sẽ có sẵn trong Claude.
295
-
296
- ### Tích hợp với AI Agents khác
297
-
298
- #### Cursor
232
+ #### Windsurf
299
233
 
300
- Thêm vào Cursor settings (`~/.cursor/mcp.json`):
234
+ Thêm vào `~/.codeium/windsurf/mcp_config.json`:
301
235
 
302
236
  ```json
303
237
  {
@@ -310,16 +244,18 @@ Thêm vào Cursor settings (`~/.cursor/mcp.json`):
310
244
  }
311
245
  ```
312
246
 
313
- #### Windsurf (Codeium)
247
+ #### Zed
314
248
 
315
- Thêm vào Windsurf MCP config (`~/.codeium/windsurf/mcp_config.json`):
249
+ Thêm vào `~/.config/zed/settings.json`:
316
250
 
317
251
  ```json
318
252
  {
319
- "mcpServers": {
253
+ "context_servers": {
320
254
  "codebaxing": {
321
- "command": "npx",
322
- "args": ["-y", "codebaxing"]
255
+ "command": {
256
+ "path": "npx",
257
+ "args": ["-y", "codebaxing"]
258
+ }
323
259
  }
324
260
  }
325
261
  }
@@ -327,7 +263,7 @@ Thêm vào Windsurf MCP config (`~/.codeium/windsurf/mcp_config.json`):
327
263
 
328
264
  #### VS Code + Continue
329
265
 
330
- Thêm vào Continue config (`~/.continue/config.json`):
266
+ Thêm vào `~/.continue/config.json`:
331
267
 
332
268
  ```json
333
269
  {
@@ -345,79 +281,67 @@ Thêm vào Continue config (`~/.continue/config.json`):
345
281
  }
346
282
  ```
347
283
 
348
- #### Zed
349
-
350
- Thêm vào Zed settings (`~/.config/zed/settings.json`):
284
+ ### Gỡ cài đặt
351
285
 
352
- ```json
353
- {
354
- "context_servers": {
355
- "codebaxing": {
356
- "command": {
357
- "path": "npx",
358
- "args": ["-y", "codebaxing"]
359
- }
360
- }
361
- }
362
- }
286
+ ```bash
287
+ npx codebaxing uninstall # Claude Desktop
288
+ npx codebaxing uninstall --all # Tất cả editors
363
289
  ```
364
290
 
365
- #### MCP Client khác
291
+ ## chế hoạt động
366
292
 
367
- Với bất kỳ MCP client nào, dùng stdio transport:
293
+ ### Kiến trúc
368
294
 
369
- ```bash
370
- # Command
371
- npx -y codebaxing
295
+ ```
296
+ ┌─────────────────────────────────────────────────────────────────┐
297
+ │ INDEXING │
298
+ ├─────────────────────────────────────────────────────────────────┤
299
+ │ Source Files (.py, .ts, .js, .go, .rs, ...) │
300
+ │ │ │
301
+ │ ▼ │
302
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
303
+ │ │ Tree-sitter │───▶│ Symbols │───▶│ Embedding │ │
304
+ │ │ Parser │ │ Extraction │ │ Model │ │
305
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
306
+ │ │ │ │ │
307
+ │ Parse AST Functions, Text → Vector │
308
+ │ Classes, etc. (384 chiều) │
309
+ │ │ │
310
+ │ ▼ │
311
+ │ ┌──────────────┐ │
312
+ │ │ ChromaDB │ │
313
+ │ │ (vectors) │ │
314
+ │ └──────────────┘ │
315
+ └─────────────────────────────────────────────────────────────────┘
372
316
 
373
- # Hoặc nếu đã install global
374
- codebaxing
317
+ ┌─────────────────────────────────────────────────────────────────┐
318
+ │ SEARCH │
319
+ ├─────────────────────────────────────────────────────────────────┤
320
+ │ "find auth code" │
321
+ │ │ │
322
+ │ ▼ │
323
+ │ ┌──────────────┐ ┌──────────────┐ │
324
+ │ │ Embedding │────────▶│ ChromaDB │ │
325
+ │ │ Model │ query │ Query │ │
326
+ │ └──────────────┘ vector └──────────────┘ │
327
+ │ │ │
328
+ │ ▼ │
329
+ │ Cosine Similarity │
330
+ │ │ │
331
+ │ ▼ │
332
+ │ Top-k Results │
333
+ └─────────────────────────────────────────────────────────────────┘
375
334
  ```
376
335
 
377
- ## Sử dụng
378
-
379
- ### MCP Tools
380
-
381
- | Tool | Mô tả |
382
- |------|-------|
383
- | `index` | Index codebase. Modes: `auto` (incremental), `full`, `load-only` |
384
- | `search` | Semantic search. Trả về ranked code chunks |
385
- | `stats` | Thống kê index (files, symbols, chunks) |
386
- | `languages` | Liệt kê các file extensions được hỗ trợ |
387
- | `remember` | Lưu memories (conversation, status, decision, preference, doc, note) |
388
- | `recall` | Semantic search trên memories |
389
- | `forget` | Xóa memories theo ID, type, tags, hoặc tuổi |
390
- | `memory-stats` | Thống kê memory theo type |
391
-
392
- ### Ví dụ Workflow
393
-
394
- 1. **Index codebase:**
395
- ```
396
- index(path="/path/to/your/project")
397
- ```
398
-
399
- 2. **Tìm kiếm code:**
400
- ```
401
- search(question="authentication middleware")
402
- search(question="database connection", language="typescript")
403
- search(question="error handling", symbol_type="function")
404
- ```
405
-
406
- 3. **Lưu context:**
407
- ```
408
- remember(content="Sử dụng PostgreSQL với Prisma ORM", memory_type="decision")
409
- remember(content="Auth dùng JWT tokens", memory_type="doc", tags=["auth", "security"])
410
- ```
411
-
412
- 4. **Truy xuất context:**
413
- ```
414
- recall(query="database setup")
415
- recall(query="authentication", memory_type="decision")
416
- ```
417
-
418
- ## Ngôn ngữ được hỗ trợ
336
+ ### Tại sao Semantic Search hoạt động
337
+
338
+ Embedding model hiểu rằng:
419
339
 
420
- Python, JavaScript, TypeScript, C, C++, Bash, Go, Java, Kotlin, Rust, Ruby, C#, PHP, Scala, Swift, Lua, Dart, Elixir, Haskell, OCaml, Zig, Perl, CSS, HTML, Vue, JSON, YAML, TOML, Makefile
340
+ | Query | Tìm được (dù không match exact) |
341
+ |-------|----------------------------------|
342
+ | "authentication" | login, credentials, auth, signin, validateUser |
343
+ | "database" | query, SQL, connection, ORM, repository |
344
+ | "error handling" | try/catch, exception, throw, ErrorBoundary |
421
345
 
422
346
  ## Cấu hình
423
347
 
@@ -426,62 +350,65 @@ Python, JavaScript, TypeScript, C, C++, Bash, Go, Java, Kotlin, Rust, Ruby, C#,
426
350
  | Biến | Mô tả | Mặc định |
427
351
  |------|-------|----------|
428
352
  | `CHROMADB_URL` | URL ChromaDB server để lưu trữ vĩnh viễn | (in-memory) |
429
- | `CODEBAXING_DEVICE` | Thiết bị tính toán cho embeddings | `cpu` |
353
+ | `CODEBAXING_DEVICE` | Thiết bị tính toán: `cpu`, `webgpu`, `cuda`, `auto` | `cpu` |
430
354
 
431
- ### Tăng tốc GPU
355
+ ### Lưu trữ vĩnh viễn
432
356
 
433
- Bật GPU để tạo embedding nhanh hơn:
357
+ Mặc định, index được lưu trong memory và mất khi server restart.
434
358
 
435
- ```bash
436
- # WebGPU (thử nghiệm, dùng Metal trên macOS)
437
- export CODEBAXING_DEVICE=webgpu
359
+ Để lưu trữ vĩnh viễn:
438
360
 
439
- # Tự động chọn thiết bị tốt nhất
440
- export CODEBAXING_DEVICE=auto
361
+ ```bash
362
+ # Khởi động ChromaDB
363
+ docker run -d -p 8000:8000 chromadb/chroma
441
364
 
442
- # NVIDIA GPU (chỉ Linux/Windows, cần CUDA)
443
- export CODEBAXING_DEVICE=cuda
365
+ # Set biến môi trường
366
+ export CHROMADB_URL=http://localhost:8000
444
367
  ```
445
368
 
446
- Mặc định `cpu`, hoạt động mọi nơi.
369
+ Hoặc trong MCP config:
447
370
 
448
- **Lưu ý:** macOS không hỗ trợ CUDA (không có NVIDIA drivers). Dùng `webgpu` để tăng tốc trên Mac.
449
-
450
- ### Lưu trữ
451
-
452
- Metadata được lưu trong thư mục `.codebaxing/` trong project:
453
- - `metadata.json` - Index metadata và file timestamps
371
+ ```json
372
+ {
373
+ "mcpServers": {
374
+ "codebaxing": {
375
+ "command": "npx",
376
+ "args": ["-y", "codebaxing"],
377
+ "env": {
378
+ "CHROMADB_URL": "http://localhost:8000"
379
+ }
380
+ }
381
+ }
382
+ }
383
+ ```
454
384
 
455
- ## Development
385
+ ### Tăng tốc GPU
456
386
 
457
387
  ```bash
458
- npm run dev # Chạy với tsx (không cần build)
459
- npm run build # Compile TypeScript
460
- npm start # Chạy bản đã compile
461
- npm test # Chạy tests
462
- npm run typecheck # Type check không emit
388
+ export CODEBAXING_DEVICE=webgpu # macOS (Metal)
389
+ export CODEBAXING_DEVICE=cuda # Linux/Windows (NVIDIA)
390
+ export CODEBAXING_DEVICE=auto # Tự động detect
463
391
  ```
464
392
 
465
- ### Testing
393
+ **Lưu ý:** macOS không hỗ trợ CUDA. Dùng `webgpu` để tăng tốc trên Mac.
466
394
 
467
- ```bash
468
- # Chạy unit tests
469
- npm test
395
+ ## Ngôn ngữ hỗ trợ
470
396
 
471
- # Test indexing thủ công
472
- CHROMADB_URL=http://localhost:8000 npx tsx test-indexing.ts
473
- ```
397
+ Python, JavaScript, TypeScript, C, C++, Bash, Go, Java, Kotlin, Rust, Ruby, C#, PHP, Scala, Swift, Lua, Dart, Elixir, Haskell, OCaml, Zig, Perl, CSS, HTML, Vue, JSON, YAML, TOML, Makefile
474
398
 
475
- ## So sánh: Grep vs Semantic Search
399
+ ## Tính năng
476
400
 
477
- | Khía cạnh | Grep | Semantic Search |
478
- |-----------|------|-----------------|
479
- | Query | Match exact text | Ngôn ngữ tự nhiên |
480
- | "authentication" | Chỉ tìm "authentication" | Tìm login, auth, credentials, v.v. |
481
- | Hiểu context | Không | |
482
- | Tìm từ đồng nghĩa | Không | Có |
483
- | Tốc độ | Rất nhanh | Nhanh (sau khi index) |
484
- | Setup | Không cần | Cần indexing |
401
+ - **Semantic Code Search**: Tìm code bằng cách mô tả những gì bạn cần
402
+ - **24+ Ngôn ngữ**: Python, TypeScript, JavaScript, Go, Rust, Java, C/C++, và nhiều hơn nữa
403
+ - **Memory Layer**: Lưu trữ truy xuất context dự án qua các session
404
+ - **Incremental Indexing**: Chỉ re-index các file đã thay đổi
405
+ - **100% Local**: Không gọi API, không cloud, hoạt động offline
406
+ - **GPU Acceleration**: Hỗ trợ WebGPU/CUDA tùy chọn
407
+
408
+ ## Yêu cầu
409
+
410
+ - Node.js >= 20.0.0
411
+ - ~500MB dung lượng đĩa cho embedding model (tải xuống lần chạy đầu tiên)
485
412
 
486
413
  ## Chi tiết kỹ thuật
487
414
 
@@ -493,6 +420,15 @@ CHROMADB_URL=http://localhost:8000 npx tsx test-indexing.ts
493
420
  | Code Parser | Tree-sitter |
494
421
  | MCP SDK | `@modelcontextprotocol/sdk` |
495
422
 
423
+ ## Development
424
+
425
+ ```bash
426
+ npm install # Cài dependencies
427
+ npm run dev # Chạy với tsx (không cần build)
428
+ npm run build # Compile TypeScript
429
+ npm test # Chạy tests
430
+ ```
431
+
496
432
  ## License
497
433
 
498
434
  MIT