@comfanion/usethis_search 0.1.4 → 0.1.5

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 +333 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,32 @@
1
- # @comfanion/usethis_search
1
+ # 🔍 @comfanion/usethis_search
2
2
 
3
- OpenCode plugin that provides semantic search and index management tools.
3
+ **Semantic code search with automatic indexing**
4
4
 
5
- ## Tools
5
+ Forget about `grep` and `find` — search code by meaning, not by text!
6
6
 
7
- - `search` (semantic search)
8
- - `codeindex` (index status, list, reindex)
7
+ ---
9
8
 
10
- ## Storage
9
+ ## ✨ What is this?
11
10
 
12
- - Vectors are stored in `.opencode/vectors/<index>/` in the project.
11
+ An OpenCode plugin that adds **smart search** to your project:
13
12
 
14
- ## Install (OpenCode)
13
+ - 🧠 **Semantic search** — finds code by meaning, even when words don't match
14
+ - ⚡ **Automatic indexing** — files are indexed on change (zero effort)
15
+ - 📦 **Local vectorization** — works offline, no API keys needed
16
+ - 🎯 **Three indexes** — separate for code, docs, and configs
17
+ - 🌍 **Multilingual** — supports Ukrainian, Russian, and English
18
+
19
+ ---
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ### Installation
24
+
25
+ ```bash
26
+ npm install @comfanion/usethis_search
27
+ ```
28
+
29
+ ### Configuration
15
30
 
16
31
  Add to `opencode.json`:
17
32
 
@@ -20,3 +35,313 @@ Add to `opencode.json`:
20
35
  "plugin": ["@comfanion/usethis_search"]
21
36
  }
22
37
  ```
38
+
39
+ ### First Run
40
+
41
+ On OpenCode startup, the plugin automatically:
42
+ 1. Creates indexes for code and documentation
43
+ 2. Indexes all project files
44
+ 3. Shows progress via toast notifications
45
+
46
+ **First indexing may take time:**
47
+ - < 20 files — Quick coffee? ☕
48
+ - < 100 files — ~1min. Stretch break? 🧘
49
+ - < 500 files — ~3min. Make coffee ☕ and relax 🛋️
50
+ - 500+ files — ~10min. Go touch grass 🌿 or take a nap 😴
51
+
52
+ ---
53
+
54
+ ## 🎯 How to Use
55
+
56
+ ### Search
57
+
58
+ ```javascript
59
+ // Search for authentication logic
60
+ search({
61
+ query: "authentication logic",
62
+ index: "code"
63
+ })
64
+
65
+ // Search for deployment instructions
66
+ search({
67
+ query: "how to deploy",
68
+ index: "docs"
69
+ })
70
+
71
+ // Search for API keys in configs
72
+ search({
73
+ query: "API keys",
74
+ index: "config"
75
+ })
76
+
77
+ // Search across all indexes
78
+ search({
79
+ query: "database connection",
80
+ searchAll: true
81
+ })
82
+ ```
83
+
84
+ ### Index Management
85
+
86
+ ```javascript
87
+ // List all indexes
88
+ codeindex({ action: "list" })
89
+
90
+ // Check specific index status
91
+ codeindex({ action: "status", index: "code" })
92
+
93
+ // Reindex
94
+ codeindex({ action: "reindex", index: "code" })
95
+
96
+ // Index specific directory
97
+ codeindex({
98
+ action: "reindex",
99
+ index: "docs",
100
+ dir: "docs/"
101
+ })
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 🧠 How It Works
107
+
108
+ ### Semantic Search
109
+
110
+ Instead of searching for exact text matches, the plugin:
111
+ 1. Converts code into **vectors** (numerical representations of meaning)
112
+ 2. Compares vectors of your query with vectors of code
113
+ 3. Finds the most **semantically similar** fragments
114
+
115
+ **Example:**
116
+ ```javascript
117
+ // You search for: "user authentication"
118
+ // It will find code with:
119
+ // - "login handler"
120
+ // - "verify credentials"
121
+ // - "session management"
122
+ // Even if words "user" and "authentication" are absent!
123
+ ```
124
+
125
+ ### Automatic Indexing
126
+
127
+ The plugin tracks file changes and automatically updates indexes:
128
+
129
+ 1. **On OpenCode startup** — checks all indexes, updates stale ones
130
+ 2. **On file edit** — queues file for reindexing
131
+ 3. **After 1 second** (debounce) — indexes changed files
132
+
133
+ **Configuration in `.opencode/vectorizer.yaml`:**
134
+
135
+ ```yaml
136
+ vectorizer:
137
+ enabled: true # Enable plugin
138
+ auto_index: true # Automatic indexing
139
+ debounce_ms: 1000 # Delay before indexing (ms)
140
+
141
+ indexes:
142
+ code:
143
+ enabled: true
144
+ extensions: [.js, .ts, .jsx, .tsx, .py, .go, ...]
145
+ docs:
146
+ enabled: true
147
+ extensions: [.md, .mdx, .txt, .rst, .adoc]
148
+ config:
149
+ enabled: false # Disabled by default
150
+ extensions: [.yaml, .yml, .json, .toml, ...]
151
+
152
+ exclude:
153
+ - node_modules
154
+ - vendor
155
+ - dist
156
+ - build
157
+ - __pycache__
158
+ ```
159
+
160
+ ---
161
+
162
+ ## 📦 Data Structure
163
+
164
+ Indexes are stored locally in your project:
165
+
166
+ ```
167
+ .opencode/
168
+ vectors/
169
+ code/ # Code index
170
+ data/ # LanceDB tables
171
+ hashes.json # File hashes (for change detection)
172
+ docs/ # Documentation index
173
+ data/
174
+ hashes.json
175
+ vectorizer.yaml # Configuration
176
+ indexer.log # Indexing log (if DEBUG=*)
177
+ ```
178
+
179
+ ---
180
+
181
+ ## 🎨 Usage Examples
182
+
183
+ ### 1. Find all API endpoints
184
+
185
+ ```javascript
186
+ search({
187
+ query: "REST API endpoints routes",
188
+ index: "code"
189
+ })
190
+ ```
191
+
192
+ ### 2. Find testing documentation
193
+
194
+ ```javascript
195
+ search({
196
+ query: "how to write tests",
197
+ index: "docs"
198
+ })
199
+ ```
200
+
201
+ ### 3. Find database configuration
202
+
203
+ ```javascript
204
+ search({
205
+ query: "database connection settings",
206
+ index: "config"
207
+ })
208
+ ```
209
+
210
+ ### 4. Find error handling
211
+
212
+ ```javascript
213
+ search({
214
+ query: "error handling try catch",
215
+ index: "code",
216
+ limit: 20 // More results
217
+ })
218
+ ```
219
+
220
+ ### 5. Search across entire project
221
+
222
+ ```javascript
223
+ search({
224
+ query: "authentication",
225
+ searchAll: true // Searches in code, docs, config
226
+ })
227
+ ```
228
+
229
+ ---
230
+
231
+ ## 🛠️ Configuration
232
+
233
+ ### Disable automatic indexing
234
+
235
+ ```yaml
236
+ # .opencode/vectorizer.yaml
237
+ vectorizer:
238
+ enabled: true
239
+ auto_index: false # Manual indexing only
240
+ ```
241
+
242
+ ### Add custom index
243
+
244
+ ```yaml
245
+ vectorizer:
246
+ indexes:
247
+ tests:
248
+ enabled: true
249
+ extensions: [.test.js, .spec.ts]
250
+ ```
251
+
252
+ ### Change indexing delay
253
+
254
+ ```yaml
255
+ vectorizer:
256
+ debounce_ms: 3000 # 3 seconds instead of 1
257
+ ```
258
+
259
+ ### Temporarily disable plugin
260
+
261
+ ```bash
262
+ export OPENCODE_SKIP_AUTO_INDEX=1
263
+ ```
264
+
265
+ ---
266
+
267
+ ## 🐛 Debugging
268
+
269
+ ### Enable logs
270
+
271
+ ```bash
272
+ export DEBUG=file-indexer
273
+ # or
274
+ export DEBUG=*
275
+ ```
276
+
277
+ Logs will be in `.opencode/indexer.log`
278
+
279
+ ### Reindex everything
280
+
281
+ ```javascript
282
+ codeindex({ action: "reindex", index: "code" })
283
+ codeindex({ action: "reindex", index: "docs" })
284
+ ```
285
+
286
+ ### Check index status
287
+
288
+ ```javascript
289
+ codeindex({ action: "list" })
290
+ ```
291
+
292
+ ---
293
+
294
+ ## 🌟 Advantages
295
+
296
+ ### Compared to `grep`/`find`
297
+
298
+ | Feature | grep/find | usethis_search |
299
+ |---------|-----------|----------------|
300
+ | Text search | ✅ | ✅ |
301
+ | Semantic search | ❌ | ✅ |
302
+ | Finds synonyms | ❌ | ✅ |
303
+ | Understands context | ❌ | ✅ |
304
+ | Works offline | ✅ | ✅ |
305
+ | Auto-updates | ❌ | ✅ |
306
+
307
+ ### Compared to online search (GitHub Copilot, ChatGPT)
308
+
309
+ | Feature | Online | usethis_search |
310
+ |---------|--------|----------------|
311
+ | Works offline | ❌ | ✅ |
312
+ | Privacy | ❌ | ✅ |
313
+ | Free | ❌ | ✅ |
314
+ | Speed | 🐌 | ⚡ |
315
+ | Knows your code | ❌ | ✅ |
316
+
317
+ ---
318
+
319
+ ## 📊 Technical Details
320
+
321
+ - **Vectorization:** [@xenova/transformers](https://github.com/xenova/transformers.js) (ONNX Runtime)
322
+ - **Vector DB:** [LanceDB](https://lancedb.com/) (local, serverless)
323
+ - **Model:** `Xenova/all-MiniLM-L6-v2` (multilingual, 384 dimensions)
324
+ - **Model size:** ~23 MB (downloaded once)
325
+ - **Speed:** ~0.5 sec/file (after model loading)
326
+
327
+ ---
328
+
329
+ ## 🤝 Contributing
330
+
331
+ Found a bug? Have an idea? Open an issue or PR!
332
+
333
+ ---
334
+
335
+ ## 📄 License
336
+
337
+ MIT
338
+
339
+ ---
340
+
341
+ ## 🎉 Authors
342
+
343
+ Made with ❤️ by the **Comfanion** team
344
+
345
+ ---
346
+
347
+ **Search smart, not hard!** 🚀
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comfanion/usethis_search",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "OpenCode plugin: semantic search + code index management",
5
5
  "type": "module",
6
6
  "main": "./index.ts",