codebaxing 0.2.1 → 0.2.3

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,304 +35,203 @@ 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
26
-
27
- ### Kiến trúc tổng quan
38
+ ## Bắt đầu nhanh
28
39
 
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
 
59
+ Bạn: Tìm logic xác thực
60
+ Claude: [gọi search tool, trả về code liên quan]
90
61
  ```
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
- }
101
- ```
102
62
 
103
- #### 2. Embedding (all-MiniLM-L6-v2)
63
+ ## Cách sử dụng
64
+
65
+ ### Qua AI Agents (MCP)
104
66
 
105
- Mỗi code chunk được chuyển thành vector 384 chiều bằng neural network:
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
154
-
155
- Embedding model được train trên hàng triệu cặp text, học được rằng:
94
+ #### Bảng tham chiếu MCP Tools
156
95
 
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 |
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 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()` |
163
106
 
164
- Điều này cho phép tìm code theo **ý nghĩa**, không chỉ từ khóa.
107
+ ### Qua CLI (Terminal)
165
108
 
166
- ## Tính năng
167
-
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
174
-
175
- ## Yêu cầu
176
-
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)
179
-
180
- ## Cài đặt
109
+ Bạn thể dùng Codebaxing trực tiếp từ terminal mà không cần AI agents:
181
110
 
182
- ### Cài nhanh (Khuyến nghị)
111
+ #### Bước 1: Index codebase (Bắt buộc đầu tiên)
183
112
 
184
113
  ```bash
185
- # Cài vào Claude Desktop
186
- npx codebaxing install
187
-
188
- # Cài vào Cursor
189
- npx codebaxing install --cursor
190
-
191
- # Cài vào Windsurf
192
- npx codebaxing install --windsurf
193
-
194
- # Cài vào tất cả editors
195
- npx codebaxing install --all
114
+ npx codebaxing index /path/to/project
196
115
  ```
197
116
 
198
- Sau đó restart editor. Xong!
199
-
200
- ### Gỡ cài đặt
201
-
202
- ```bash
203
- npx codebaxing uninstall # Gỡ khỏi Claude Desktop
204
- npx codebaxing uninstall --all # Gỡ khỏi tất cả editors
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
205
138
  ```
206
139
 
207
- ### CLI Commands (Dùng trực tiếp)
208
-
209
- Bạn có thể dùng Codebaxing trực tiếp từ terminal mà không cần AI agents:
140
+ #### Bước 2: Tìm kiếm code
210
141
 
211
142
  ```bash
212
- # Index codebase
213
- npx codebaxing index /path/to/project
214
-
215
- # Tìm kiếm code
216
143
  npx codebaxing search "authentication middleware"
217
144
  npx codebaxing search "database connection" --path ./src --limit 10
218
-
219
- # Xem thống kê
220
- npx codebaxing stats /path/to/project
221
145
  ```
222
146
 
223
- **Lưu ý:** Để lưu trữ vĩnh viễn, chạy ChromaDB trước:
224
- ```bash
225
- docker run -d -p 8000:8000 chromadb/chroma
226
- export CHROMADB_URL=http://localhost:8000
147
+ Output:
227
148
  ```
149
+ 🔧 Codebaxing - Search
228
150
 
229
- ### Cài thủ công
151
+ 📁 Path: /path/to/project
152
+ 🔍 Query: "authentication middleware"
153
+ 📊 Limit: 5
230
154
 
231
- 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.
155
+ ────────────────────────────────────────────────────────────
156
+ Results:
232
157
 
233
- ### (Tùy chọn) Persistent Storage
158
+ 1. src/middleware/auth.ts:15 - authMiddleware()
159
+ 2. src/services/auth.ts:42 - validateToken()
160
+ 3. src/routes/login.ts:8 - loginHandler()
234
161
 
235
- Mặc định, index được lưu trong memory và mất khi server restart.
162
+ ────────────────────────────────────────────────────────────
163
+ ```
236
164
 
237
- Để lưu trữ vĩnh viễn, chạy ChromaDB:
165
+ #### Bước 3: Xem thống
238
166
 
239
167
  ```bash
240
- # Dùng Docker (khuyến nghị)
241
- docker run -d -p 8000:8000 chromadb/chroma
242
-
243
- # Set biến môi trường
244
- export CHROMADB_URL=http://localhost:8000
168
+ npx codebaxing stats /path/to/project
245
169
  ```
246
170
 
247
- ### Cấu hình thủ công
171
+ #### Bảng tham chiếu CLI Commands
248
172
 
249
- #### Cấu hình Claude Desktop
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 |
250
181
 
251
- Thêm vào file config của Claude Desktop:
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)
252
185
 
253
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
254
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
186
+ ## Cài đặt
255
187
 
256
- #### Qua npx (không cần cài):
188
+ ### Cách 1: Cài nhanh (Khuyến nghị)
257
189
 
258
- ```json
259
- {
260
- "mcpServers": {
261
- "codebaxing": {
262
- "command": "npx",
263
- "args": ["-y", "codebaxing"]
264
- }
265
- }
266
- }
190
+ ```bash
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
267
196
  ```
268
197
 
269
- #### Qua global install:
198
+ Sau đó restart editor.
270
199
 
271
- ```bash
272
- npm install -g codebaxing
273
- ```
200
+ ### Cách 2: Cấu hình thủ công
274
201
 
275
- ```json
276
- {
277
- "mcpServers": {
278
- "codebaxing": {
279
- "command": "codebaxing"
280
- }
281
- }
282
- }
283
- ```
202
+ #### Claude Desktop
284
203
 
285
- #### Với persistent storage (ChromaDB):
204
+ Thêm vào `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) hoặc `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
286
205
 
287
206
  ```json
288
207
  {
289
208
  "mcpServers": {
290
209
  "codebaxing": {
291
210
  "command": "npx",
292
- "args": ["-y", "codebaxing"],
293
- "env": {
294
- "CHROMADB_URL": "http://localhost:8000"
295
- }
211
+ "args": ["-y", "codebaxing"]
296
212
  }
297
213
  }
298
214
  }
299
215
  ```
300
216
 
301
- #### Từ source (development):
217
+ #### Cursor
218
+
219
+ Thêm vào `~/.cursor/mcp.json`:
302
220
 
303
221
  ```json
304
222
  {
305
223
  "mcpServers": {
306
224
  "codebaxing": {
307
- "command": "node",
308
- "args": ["/path/to/codebaxing/dist/mcp/server.js"]
225
+ "command": "npx",
226
+ "args": ["-y", "codebaxing"]
309
227
  }
310
228
  }
311
229
  }
312
230
  ```
313
231
 
314
- ### Khởi động lại Claude Desktop
315
-
316
- Các tool Codebaxing sẽ có sẵn trong Claude.
317
-
318
- ### Tích hợp với AI Agents khác
319
-
320
- #### Cursor
232
+ #### Windsurf
321
233
 
322
- Thêm vào Cursor settings (`~/.cursor/mcp.json`):
234
+ Thêm vào `~/.codeium/windsurf/mcp_config.json`:
323
235
 
324
236
  ```json
325
237
  {
@@ -332,16 +244,18 @@ Thêm vào Cursor settings (`~/.cursor/mcp.json`):
332
244
  }
333
245
  ```
334
246
 
335
- #### Windsurf (Codeium)
247
+ #### Zed
336
248
 
337
- Thêm vào Windsurf MCP config (`~/.codeium/windsurf/mcp_config.json`):
249
+ Thêm vào `~/.config/zed/settings.json`:
338
250
 
339
251
  ```json
340
252
  {
341
- "mcpServers": {
253
+ "context_servers": {
342
254
  "codebaxing": {
343
- "command": "npx",
344
- "args": ["-y", "codebaxing"]
255
+ "command": {
256
+ "path": "npx",
257
+ "args": ["-y", "codebaxing"]
258
+ }
345
259
  }
346
260
  }
347
261
  }
@@ -349,7 +263,7 @@ Thêm vào Windsurf MCP config (`~/.codeium/windsurf/mcp_config.json`):
349
263
 
350
264
  #### VS Code + Continue
351
265
 
352
- Thêm vào Continue config (`~/.continue/config.json`):
266
+ Thêm vào `~/.continue/config.json`:
353
267
 
354
268
  ```json
355
269
  {
@@ -367,79 +281,67 @@ Thêm vào Continue config (`~/.continue/config.json`):
367
281
  }
368
282
  ```
369
283
 
370
- #### Zed
371
-
372
- Thêm vào Zed settings (`~/.config/zed/settings.json`):
284
+ ### Gỡ cài đặt
373
285
 
374
- ```json
375
- {
376
- "context_servers": {
377
- "codebaxing": {
378
- "command": {
379
- "path": "npx",
380
- "args": ["-y", "codebaxing"]
381
- }
382
- }
383
- }
384
- }
286
+ ```bash
287
+ npx codebaxing uninstall # Claude Desktop
288
+ npx codebaxing uninstall --all # Tất cả editors
385
289
  ```
386
290
 
387
- #### MCP Client khác
291
+ ## chế hoạt động
388
292
 
389
- Với bất kỳ MCP client nào, dùng stdio transport:
293
+ ### Kiến trúc
390
294
 
391
- ```bash
392
- # Command
393
- 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
+ └─────────────────────────────────────────────────────────────────┘
394
316
 
395
- # Hoặc nếu đã install global
396
- 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
+ └─────────────────────────────────────────────────────────────────┘
397
334
  ```
398
335
 
399
- ## Sử dụng
400
-
401
- ### MCP Tools
402
-
403
- | Tool | Mô tả |
404
- |------|-------|
405
- | `index` | Index codebase. Modes: `auto` (incremental), `full`, `load-only` |
406
- | `search` | Semantic search. Trả về ranked code chunks |
407
- | `stats` | Thống kê index (files, symbols, chunks) |
408
- | `languages` | Liệt kê các file extensions được hỗ trợ |
409
- | `remember` | Lưu memories (conversation, status, decision, preference, doc, note) |
410
- | `recall` | Semantic search trên memories |
411
- | `forget` | Xóa memories theo ID, type, tags, hoặc tuổi |
412
- | `memory-stats` | Thống kê memory theo type |
413
-
414
- ### Ví dụ Workflow
415
-
416
- 1. **Index codebase:**
417
- ```
418
- index(path="/path/to/your/project")
419
- ```
420
-
421
- 2. **Tìm kiếm code:**
422
- ```
423
- search(question="authentication middleware")
424
- search(question="database connection", language="typescript")
425
- search(question="error handling", symbol_type="function")
426
- ```
427
-
428
- 3. **Lưu context:**
429
- ```
430
- remember(content="Sử dụng PostgreSQL với Prisma ORM", memory_type="decision")
431
- remember(content="Auth dùng JWT tokens", memory_type="doc", tags=["auth", "security"])
432
- ```
433
-
434
- 4. **Truy xuất context:**
435
- ```
436
- recall(query="database setup")
437
- recall(query="authentication", memory_type="decision")
438
- ```
439
-
440
- ## Ngôn ngữ được hỗ trợ
336
+ ### Tại sao Semantic Search hoạt động
441
337
 
442
- 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
338
+ Embedding model hiểu rằng:
339
+
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 |
443
345
 
444
346
  ## Cấu hình
445
347
 
@@ -448,62 +350,65 @@ Python, JavaScript, TypeScript, C, C++, Bash, Go, Java, Kotlin, Rust, Ruby, C#,
448
350
  | Biến | Mô tả | Mặc định |
449
351
  |------|-------|----------|
450
352
  | `CHROMADB_URL` | URL ChromaDB server để lưu trữ vĩnh viễn | (in-memory) |
451
- | `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` |
452
354
 
453
- ### Tăng tốc GPU
355
+ ### Lưu trữ vĩnh viễn
356
+
357
+ Mặc định, index được lưu trong memory và mất khi server restart.
454
358
 
455
- Bật GPU để tạo embedding nhanh hơn:
359
+ Để lưu trữ vĩnh viễn:
456
360
 
457
361
  ```bash
458
- # WebGPU (thử nghiệm, dùng Metal trên macOS)
459
- export CODEBAXING_DEVICE=webgpu
460
-
461
- # Tự động chọn thiết bị tốt nhất
462
- export CODEBAXING_DEVICE=auto
362
+ # Khởi động ChromaDB
363
+ docker run -d -p 8000:8000 chromadb/chroma
463
364
 
464
- # NVIDIA GPU (chỉ Linux/Windows, cần CUDA)
465
- export CODEBAXING_DEVICE=cuda
365
+ # Set biến môi trường
366
+ export CHROMADB_URL=http://localhost:8000
466
367
  ```
467
368
 
468
- Mặc định `cpu`, hoạt động mọi nơi.
469
-
470
- **Lưu ý:** macOS không hỗ trợ CUDA (không có NVIDIA drivers). Dùng `webgpu` để tăng tốc trên Mac.
369
+ Hoặc trong MCP config:
471
370
 
472
- ### Lưu trữ
473
-
474
- Metadata được lưu trong thư mục `.codebaxing/` trong project:
475
- - `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
+ ```
476
384
 
477
- ## Development
385
+ ### Tăng tốc GPU
478
386
 
479
387
  ```bash
480
- npm run dev # Chạy với tsx (không cần build)
481
- npm run build # Compile TypeScript
482
- npm start # Chạy bản đã compile
483
- npm test # Chạy tests
484
- 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
485
391
  ```
486
392
 
487
- ### Testing
393
+ **Lưu ý:** macOS không hỗ trợ CUDA. Dùng `webgpu` để tăng tốc trên Mac.
488
394
 
489
- ```bash
490
- # Chạy unit tests
491
- npm test
395
+ ## Ngôn ngữ hỗ trợ
492
396
 
493
- # Test indexing thủ công
494
- CHROMADB_URL=http://localhost:8000 npx tsx test-indexing.ts
495
- ```
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
496
398
 
497
- ## So sánh: Grep vs Semantic Search
399
+ ## Tính năng
498
400
 
499
- | Khía cạnh | Grep | Semantic Search |
500
- |-----------|------|-----------------|
501
- | Query | Match exact text | Ngôn ngữ tự nhiên |
502
- | "authentication" | Chỉ tìm "authentication" | Tìm login, auth, credentials, v.v. |
503
- | Hiểu context | Không | |
504
- | Tìm từ đồng nghĩa | Không | Có |
505
- | Tốc độ | Rất nhanh | Nhanh (sau khi index) |
506
- | 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)
507
412
 
508
413
  ## Chi tiết kỹ thuật
509
414
 
@@ -515,6 +420,15 @@ CHROMADB_URL=http://localhost:8000 npx tsx test-indexing.ts
515
420
  | Code Parser | Tree-sitter |
516
421
  | MCP SDK | `@modelcontextprotocol/sdk` |
517
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
+
518
432
  ## License
519
433
 
520
434
  MIT