@the-magic-tower/fixhive-opencode-plugin 0.1.4 → 0.1.6

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 CHANGED
@@ -11,6 +11,19 @@
11
11
  <a href="README.nl.md">Nederlands</a>
12
12
  </p>
13
13
 
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/@the-magic-tower/fixhive-opencode-plugin">
16
+ <img src="https://img.shields.io/npm/v/@the-magic-tower/fixhive-opencode-plugin.svg" alt="npm version">
17
+ </a>
18
+ <a href="https://github.com/SeoulVentures/FixHive/actions/workflows/ci.yml">
19
+ <img src="https://github.com/SeoulVentures/FixHive/actions/workflows/ci.yml/badge.svg" alt="CI Status">
20
+ </a>
21
+ <a href="https://opensource.org/licenses/MIT">
22
+ <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT">
23
+ </a>
24
+ <img src="https://img.shields.io/badge/Node.js-18%20%7C%2020%20%7C%2022-green" alt="Node.js Version">
25
+ </p>
26
+
14
27
  > Community-based Error Knowledge Sharing for OpenCode
15
28
 
16
29
  FixHive is an OpenCode plugin that automatically captures errors during development sessions, queries a community knowledge base for solutions, and shares resolved errors with other developers.
@@ -22,6 +35,7 @@ FixHive is an OpenCode plugin that automatically captures errors during developm
22
35
  - **Local Caching**: SQLite-based local storage for offline access
23
36
  - **Privacy Filtering**: Automatically redacts sensitive data (API keys, paths, emails)
24
37
  - **Real-time Sync**: Immediate cloud communication on error/resolution
38
+ - **Duplicate Prevention**: Smart deduplication using embeddings and hash matching
25
39
 
26
40
  ## Installation
27
41
 
@@ -43,6 +57,30 @@ export default {
43
57
 
44
58
  **That's it!** FixHive connects to the community knowledge base by default. No environment variables required.
45
59
 
60
+ ## How It Works
61
+
62
+ ```
63
+ ┌─────────────────────────────────────────────────────────────────┐
64
+ │ FixHive Flow │
65
+ ├─────────────────────────────────────────────────────────────────┤
66
+ │ │
67
+ │ 1. Error Occurs │
68
+ │ ↓ │
69
+ │ 2. Auto Detection (tool.execute.after hook) │
70
+ │ ↓ │
71
+ │ 3. Privacy Filter (redact API keys, paths, etc.) │
72
+ │ ↓ │
73
+ │ 4. Local Storage (SQLite) │
74
+ │ ↓ │
75
+ │ 5. Cloud Search (Supabase + pgvector) │
76
+ │ ↓ │
77
+ │ 6. Display Solutions (ranked by similarity & votes) │
78
+ │ ↓ │
79
+ │ 7. Resolution → Upload to Community │
80
+ │ │
81
+ └─────────────────────────────────────────────────────────────────┘
82
+ ```
83
+
46
84
  ## Configuration (Optional)
47
85
 
48
86
  Environment variables to customize behavior:
@@ -66,43 +104,176 @@ FIXHIVE_CONTRIBUTOR_ID=your-contributor-id
66
104
  | `OPENAI_API_KEY` | None | Enables semantic similarity search |
67
105
  | `FIXHIVE_CONTRIBUTOR_ID` | Auto-generated | Your unique contributor ID |
68
106
 
69
- ## Available Commands
107
+ ## Available Tools
108
+
109
+ ### `fixhive_search`
110
+
111
+ Search the knowledge base for error solutions.
112
+
113
+ ```typescript
114
+ // Arguments
115
+ {
116
+ errorMessage: string; // Required: The error message to search for
117
+ language?: string; // Optional: Programming language (typescript, python, etc.)
118
+ framework?: string; // Optional: Framework (react, nextjs, express, etc.)
119
+ limit?: number; // Optional: Maximum results (default: 5)
120
+ }
121
+ ```
122
+
123
+ **Example:**
124
+ ```
125
+ fixhive_search "Cannot find module 'react'" --language typescript --framework nextjs
126
+ ```
127
+
128
+ ### `fixhive_resolve`
129
+
130
+ Mark an error as resolved and share the solution.
131
+
132
+ ```typescript
133
+ // Arguments
134
+ {
135
+ errorId: string; // Required: Error ID from fixhive_list
136
+ resolution: string; // Required: Description of how the error was resolved
137
+ resolutionCode?: string; // Optional: Code fix or diff
138
+ upload?: boolean; // Optional: Upload to community (default: true)
139
+ }
140
+ ```
141
+
142
+ **Example:**
143
+ ```
144
+ fixhive_resolve abc12345 "Missing dependency. Fixed by running npm install react"
145
+ ```
146
+
147
+ ### `fixhive_list`
148
+
149
+ List errors detected in the current session.
150
+
151
+ ```typescript
152
+ // Arguments
153
+ {
154
+ status?: 'unresolved' | 'resolved' | 'uploaded'; // Optional: Filter by status
155
+ limit?: number; // Optional: Maximum results (default: 10)
156
+ }
157
+ ```
158
+
159
+ ### `fixhive_vote`
160
+
161
+ Upvote or downvote a solution.
162
+
163
+ ```typescript
164
+ // Arguments
165
+ {
166
+ knowledgeId: string; // Required: Knowledge entry ID
167
+ helpful: boolean; // Required: true for upvote, false for downvote
168
+ }
169
+ ```
170
+
171
+ ### `fixhive_stats`
172
+
173
+ View usage statistics.
174
+
175
+ ```typescript
176
+ // No arguments required
177
+ ```
178
+
179
+ **Output:**
180
+ ```markdown
181
+ ## FixHive Statistics
182
+
183
+ ### Local
184
+ - Errors recorded: 42
185
+ - Resolved: 38
186
+ - Uploaded: 25
187
+
188
+ ### Community Contributions
189
+ - Solutions shared: 25
190
+ - Times your solutions helped: 156
191
+ - Total upvotes received: 89
192
+ ```
193
+
194
+ ### `fixhive_helpful`
195
+
196
+ Report that a solution was helpful.
197
+
198
+ ```typescript
199
+ // Arguments
200
+ {
201
+ knowledgeId: string; // Required: Knowledge entry ID that helped
202
+ }
203
+ ```
204
+
205
+ ### `fixhive_report`
206
+
207
+ Report inappropriate content.
208
+
209
+ ```typescript
210
+ // Arguments
211
+ {
212
+ knowledgeId: string; // Required: Knowledge entry ID to report
213
+ reason?: string; // Optional: Reason for reporting
214
+ }
215
+ ```
216
+
217
+ ## Example Workflow
218
+
219
+ ```
220
+ 1. Run a command that fails
221
+ $ npm run build
222
+ > error TS2307: Cannot find module '@/components/Button'
70
223
 
71
- | Command | Description |
72
- |---------|-------------|
73
- | `fixhive_search` | Search knowledge base for error solutions |
74
- | `fixhive_resolve` | Mark error as resolved and share solution |
75
- | `fixhive_list` | List errors in current session |
76
- | `fixhive_vote` | Upvote/downvote a solution |
77
- | `fixhive_stats` | View usage statistics |
78
- | `fixhive_helpful` | Report a solution was helpful |
79
- | `fixhive_report` | Report inappropriate content |
224
+ 2. FixHive automatically:
225
+ - Detects the error
226
+ - Records it locally
227
+ - Searches for solutions
228
+ - Displays matching community solutions
80
229
 
81
- ### Example Workflow
230
+ 3. Apply the fix from community solution
231
+ $ npm install @/components/Button --save
82
232
 
83
- 1. **Error occurs** FixHive automatically detects and records it
84
- 2. **Search solutions** `fixhive_search "Module not found: react"`
85
- 3. **Apply fix** → Follow community solution
86
- 4. **Share resolution** `fixhive_resolve <error-id> "Installed missing dependency"`
233
+ 4. Mark as resolved and share
234
+ fixhive_resolve <error-id> "Missing alias configuration in tsconfig.json. Added paths mapping."
235
+
236
+ 5. Your solution helps other developers!
237
+ ```
238
+
239
+ ## Privacy
240
+
241
+ FixHive automatically filters sensitive information before sharing:
242
+
243
+ | Category | Examples | Replacement |
244
+ |----------|----------|-------------|
245
+ | API Keys | `sk-abc123...`, `ghp_xxx...` | `[API_KEY_REDACTED]` |
246
+ | Tokens | `Bearer eyJ...`, `xoxb-...` | `[TOKEN_REDACTED]` |
247
+ | Emails | `user@example.com` | `[EMAIL_REDACTED]` |
248
+ | Paths | `/Users/john/projects/...` | `~/projects/...` |
249
+ | Env Vars | `DATABASE_URL=postgres://...` | `[ENV_REDACTED]` |
250
+ | Connection Strings | `mongodb://user:pass@...` | `[CONNECTION_STRING_REDACTED]` |
251
+ | IP Addresses | `192.168.1.100` | `[IP_REDACTED]` |
87
252
 
88
253
  ## Self-Hosted Setup (Optional)
89
254
 
90
255
  Skip this section if you're using the default community knowledge base.
91
256
 
92
- To run your own FixHive backend:
257
+ ### 1. Create Supabase Project
93
258
 
94
- 1. Create a new Supabase project (Free tier works)
95
- 2. Run the setup script in SQL Editor:
259
+ 1. Go to [supabase.com](https://supabase.com) and create a new project (Free tier works)
260
+ 2. Wait for the project to be ready
96
261
 
97
- ```bash
98
- cat scripts/setup-supabase.sql | pbcopy
99
- # Paste in Supabase SQL Editor
262
+ ### 2. Enable pgvector Extension
263
+
264
+ In SQL Editor, run:
265
+ ```sql
266
+ CREATE EXTENSION IF NOT EXISTS vector;
100
267
  ```
101
268
 
102
- 3. Get your project URL and anon key from Settings > API
103
- 4. Set environment variables:
269
+ ### 3. Run Setup Script
270
+
271
+ Copy and run the contents of `scripts/setup-supabase.sql` in the SQL Editor.
272
+
273
+ ### 4. Configure Environment
104
274
 
105
275
  ```bash
276
+ # Get these from Settings > API
106
277
  FIXHIVE_SUPABASE_URL=https://your-project.supabase.co
107
278
  FIXHIVE_SUPABASE_KEY=your-anon-key
108
279
  ```
@@ -110,28 +281,129 @@ FIXHIVE_SUPABASE_KEY=your-anon-key
110
281
  ## Architecture
111
282
 
112
283
  ```
113
- FixHive Plugin
114
- ├── Error Detection (tool.execute.after hook)
115
- ├── Privacy Filter (redacts sensitive data)
116
- ├── Local Storage (SQLite)
117
- ├── error_records
118
- └── query_cache
119
- └── Cloud Client (Supabase + pgvector)
120
- ├── knowledge_entries
121
- └── usage_logs
284
+ @the-magic-tower/fixhive-opencode-plugin
285
+ ├── src/
286
+ ├── plugin/
287
+ │ │ ├── index.ts # Plugin definition (hooks)
288
+ │ └── tools.ts # Custom tools (7 tools)
289
+ ├── core/
290
+ │ │ ├── error-detector.ts # Multi-signal error detection
291
+ │ │ ├── privacy-filter.ts # Sensitive data redaction
292
+ │ │ └── hash.ts # Fingerprinting & deduplication
293
+ │ ├── storage/
294
+ │ │ ├── local-store.ts # SQLite local storage
295
+ │ │ └── migrations.ts # Database migrations
296
+ │ ├── cloud/
297
+ │ │ ├── client.ts # Supabase client
298
+ │ │ └── embedding.ts # OpenAI embeddings
299
+ │ └── types/
300
+ │ └── index.ts # TypeScript definitions
301
+ └── scripts/
302
+ └── setup-supabase.sql # Cloud schema
122
303
  ```
123
304
 
124
- ## Privacy
305
+ ## API Reference
125
306
 
126
- FixHive automatically filters sensitive information:
307
+ ### TypeScript Types
127
308
 
128
- - API keys (OpenAI, GitHub, AWS, Stripe, etc.)
129
- - JWT tokens and bearer tokens
130
- - Email addresses
131
- - File paths (replaced with `~` or `<PROJECT>`)
132
- - Environment variables with sensitive names
133
- - Database connection strings
134
- - IP addresses (except localhost)
309
+ ```typescript
310
+ import type {
311
+ LocalErrorRecord,
312
+ CloudKnowledgeEntry,
313
+ ErrorType,
314
+ ErrorStatus,
315
+ Language,
316
+ Severity,
317
+ } from '@the-magic-tower/fixhive-opencode-plugin';
318
+
319
+ // Error types
320
+ type ErrorType =
321
+ | 'runtime' | 'build' | 'lint' | 'test'
322
+ | 'network' | 'permission' | 'dependency'
323
+ | 'syntax' | 'type_error' | 'unknown';
324
+
325
+ // Error status
326
+ type ErrorStatus = 'unresolved' | 'resolved' | 'uploaded';
327
+
328
+ // Supported languages
329
+ type Language =
330
+ | 'typescript' | 'javascript' | 'python' | 'rust'
331
+ | 'go' | 'java' | 'ruby' | 'php' | 'csharp' | 'cpp' | 'other';
332
+ ```
333
+
334
+ ### Programmatic Usage
335
+
336
+ ```typescript
337
+ import {
338
+ ErrorDetector,
339
+ PrivacyFilter,
340
+ LocalStore,
341
+ CloudClient,
342
+ createEmbeddingService,
343
+ } from '@the-magic-tower/fixhive-opencode-plugin';
344
+
345
+ // Create instances
346
+ const detector = new ErrorDetector();
347
+ const filter = new PrivacyFilter();
348
+ const store = new LocalStore('/path/to/project');
349
+ const cloud = new CloudClient({
350
+ supabaseUrl: 'https://xxx.supabase.co',
351
+ supabaseAnonKey: 'your-key',
352
+ });
353
+
354
+ // Detect errors
355
+ const result = detector.detect({
356
+ tool: 'bash',
357
+ output: 'error TS2307: Cannot find module...',
358
+ exitCode: 1,
359
+ });
360
+
361
+ // Sanitize content
362
+ const sanitized = filter.sanitize('API key: sk-abc123...');
363
+ // { sanitized: 'API key: [API_KEY_REDACTED]', redactedCount: 1, ... }
364
+
365
+ // Search solutions
366
+ const solutions = await cloud.searchSimilar({
367
+ errorMessage: 'Module not found',
368
+ language: 'typescript',
369
+ });
370
+ ```
371
+
372
+ ## Troubleshooting
373
+
374
+ ### Plugin not loading
375
+
376
+ Make sure you're using OpenCode v1.1.1 or later:
377
+ ```bash
378
+ npm list @opencode-ai/plugin
379
+ ```
380
+
381
+ ### No solutions found
382
+
383
+ 1. Check if you have `OPENAI_API_KEY` set for semantic search
384
+ 2. Try broader search terms
385
+ 3. The community database may not have solutions for rare errors yet
386
+
387
+ ### Privacy concerns
388
+
389
+ FixHive automatically filters sensitive data, but you can disable cloud sync:
390
+ ```typescript
391
+ fixhive_resolve <error-id> "My resolution" --upload false
392
+ ```
393
+
394
+ ### SQLite errors
395
+
396
+ Clear local database:
397
+ ```bash
398
+ rm -rf .fixhive/
399
+ ```
400
+
401
+ ### Connection errors
402
+
403
+ Check your network and Supabase status:
404
+ ```bash
405
+ curl https://your-project.supabase.co/rest/v1/
406
+ ```
135
407
 
136
408
  ## Development
137
409
 
@@ -150,16 +422,45 @@ npm run typecheck
150
422
 
151
423
  # Run tests
152
424
  npm test
425
+
426
+ # Run tests with coverage
427
+ npm run test:coverage
153
428
  ```
154
429
 
155
- ## License
430
+ ### Test Coverage
156
431
 
157
- MIT
432
+ | Module | Coverage |
433
+ |--------|----------|
434
+ | Core (error-detector, privacy-filter, hash) | 99% |
435
+ | Storage (local-store) | 98% |
436
+ | Cloud (client, embedding) | 96% |
158
437
 
159
438
  ## Contributing
160
439
 
161
440
  1. Fork the repository
162
- 2. Create your feature branch
163
- 3. Commit your changes
164
- 4. Push to the branch
441
+ 2. Create your feature branch (`git checkout -b feature/amazing`)
442
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
443
+ 4. Push to the branch (`git push origin feature/amazing`)
165
444
  5. Create a Pull Request
445
+
446
+ ### Guidelines
447
+
448
+ - Write tests for new features
449
+ - Follow existing code style
450
+ - Update documentation
451
+ - Keep commits atomic
452
+
453
+ ## Changelog
454
+
455
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
456
+
457
+ ## License
458
+
459
+ MIT - see [LICENSE](LICENSE) for details.
460
+
461
+ ## Acknowledgments
462
+
463
+ - [OpenCode](https://github.com/opencode-ai/opencode) - AI coding assistant
464
+ - [Supabase](https://supabase.com) - Backend as a Service
465
+ - [pgvector](https://github.com/pgvector/pgvector) - Vector similarity search
466
+ - [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) - Fast SQLite bindings