@the-magic-tower/fixhive-opencode-plugin 0.1.22 → 0.1.23

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/dist/index.d.ts CHANGED
@@ -1,45 +1,473 @@
1
+ import { Plugin } from '@opencode-ai/plugin';
2
+ import Database from 'better-sqlite3';
3
+
1
4
  /**
2
- * FixHive - Community-based Error Knowledge Sharing for OpenCode
3
- *
4
- * @module @fixhive/opencode-plugin
5
- * @description
6
- * FixHive is an OpenCode plugin that automatically captures errors during
7
- * development sessions, queries a community knowledge base for solutions,
8
- * and shares resolved errors with other developers.
9
- *
10
- * @example
11
- * ```typescript
12
- * // In your OpenCode plugin configuration
13
- * import FixHivePlugin from '@fixhive/opencode-plugin';
14
- *
15
- * export default FixHivePlugin;
16
- * ```
17
- *
18
- * @example
19
- * ```bash
20
- * # Environment variables
21
- * FIXHIVE_SUPABASE_URL=https://your-project.supabase.co
22
- * FIXHIVE_SUPABASE_KEY=your-anon-key
23
- * OPENAI_API_KEY=sk-... # Optional, for embeddings
24
- * ```
25
- */
26
- export { FixHivePlugin, default } from './plugin/index.js';
27
- export { createErrorDetector, defaultErrorDetector } from './core/error-detector.js';
28
- export { createPrivacyFilter, defaultPrivacyFilter, createFilterContext } from './core/privacy-filter.js';
29
- export { sha256, shortHash, generateErrorFingerprint, normalizeErrorContent, generateContributorId, generateSessionHash, fingerprintsMatch, calculateStringSimilarity, } from './core/hash.js';
30
- export { createLocalStore } from './storage/local-store.js';
31
- export { runMigrations } from './storage/migrations.js';
32
- export { createCloudClient } from './cloud/client.js';
33
- export { createEmbeddingService, cosineSimilarity } from './cloud/embedding.js';
34
- export { ErrorDetector } from './core/error-detector.js';
35
- export { PrivacyFilter } from './core/privacy-filter.js';
36
- export { LocalStore } from './storage/local-store.js';
37
- export { CloudClient } from './cloud/client.js';
38
- export { EmbeddingService } from './cloud/embedding.js';
39
- export type { ErrorType, ErrorStatus, Language, Severity, LocalErrorRecord, QueryCacheEntry, LocalStats, CloudKnowledgeEntry, DuplicateCheckResult, ContributorStats, DetectedSignal, ErrorDetectionResult, StackFrame, StackTraceInfo, FixHiveContext, ToolOutput, PrivacyFilterRule, SanitizedContent, FilterContext, SearchRequest, SearchResponse, UploadRequest, UploadResponse, QueryKnowledgeArgs, SubmitResolutionArgs, ListErrorsArgs, MarkResolvedArgs, VoteArgs, FixHiveConfig, PartialConfig, FixHiveEvent, } from './types/index.js';
40
- export type { ErrorDetector as ErrorDetectorInterface } from './core/error-detector.js';
41
- export type { PrivacyFilter as PrivacyFilterInterface } from './core/privacy-filter.js';
42
- export type { LocalStore as LocalStoreInterface } from './storage/local-store.js';
43
- export type { CloudClient as CloudClientInterface } from './cloud/client.js';
44
- export type { EmbeddingService as EmbeddingServiceInterface, EmbeddingServiceConfig } from './cloud/embedding.js';
45
- //# sourceMappingURL=index.d.ts.map
5
+ * FixHive OpenCode Plugin
6
+ * Community-based error knowledge sharing plugin for OpenCode
7
+ */
8
+
9
+ /**
10
+ * FixHive Plugin Factory
11
+ */
12
+ declare const FixHivePlugin: Plugin;
13
+
14
+ /**
15
+ * FixHive Type Definitions
16
+ * Community-based error knowledge sharing for OpenCode
17
+ */
18
+ type ErrorType = 'runtime' | 'build' | 'lint' | 'test' | 'network' | 'permission' | 'dependency' | 'syntax' | 'type_error' | 'unknown';
19
+ type ErrorStatus = 'unresolved' | 'resolved' | 'uploaded';
20
+ type Language = 'typescript' | 'javascript' | 'python' | 'rust' | 'go' | 'java' | 'ruby' | 'php' | 'csharp' | 'cpp' | 'other';
21
+ type Severity = 'critical' | 'error' | 'warning';
22
+ interface LocalErrorRecord {
23
+ id: string;
24
+ errorHash: string;
25
+ errorType: ErrorType;
26
+ errorMessage: string;
27
+ errorStack?: string;
28
+ language?: Language;
29
+ framework?: string;
30
+ toolName: string;
31
+ toolInput: Record<string, unknown>;
32
+ sessionId: string;
33
+ status: ErrorStatus;
34
+ resolution?: string;
35
+ resolutionCode?: string;
36
+ createdAt: string;
37
+ resolvedAt?: string;
38
+ uploadedAt?: string;
39
+ cloudKnowledgeId?: string;
40
+ }
41
+ interface QueryCacheEntry {
42
+ id: string;
43
+ errorHash: string;
44
+ results: CloudKnowledgeEntry[];
45
+ createdAt: string;
46
+ expiresAt: string;
47
+ }
48
+ interface LocalStats {
49
+ totalErrors: number;
50
+ resolvedErrors: number;
51
+ uploadedErrors: number;
52
+ }
53
+ interface CloudKnowledgeEntry {
54
+ id: string;
55
+ errorHash: string;
56
+ errorType: ErrorType;
57
+ errorMessage: string;
58
+ errorStack?: string;
59
+ language: Language;
60
+ framework?: string;
61
+ dependencies?: Record<string, string>;
62
+ embedding?: number[];
63
+ resolutionDescription: string;
64
+ resolutionCode?: string;
65
+ resolutionSteps?: string[];
66
+ contributorId: string;
67
+ upvotes: number;
68
+ downvotes: number;
69
+ usageCount: number;
70
+ createdAt: string;
71
+ updatedAt: string;
72
+ isVerified: boolean;
73
+ similarity?: number;
74
+ }
75
+ interface DuplicateCheckResult {
76
+ isDuplicate: boolean;
77
+ existingId?: string;
78
+ similarityScore: number;
79
+ }
80
+ interface ContributorStats {
81
+ contributionCount: number;
82
+ helpedCount: number;
83
+ totalUpvotes: number;
84
+ }
85
+ interface DetectedSignal {
86
+ type: 'exit_code' | 'stderr' | 'pattern' | 'stack_trace';
87
+ weight: number;
88
+ value: string | number;
89
+ description: string;
90
+ }
91
+ interface ErrorDetectionResult {
92
+ detected: boolean;
93
+ confidence: number;
94
+ errorType: ErrorType;
95
+ severity: Severity;
96
+ signals: DetectedSignal[];
97
+ errorMessage: string;
98
+ errorStack?: string;
99
+ rawOutput: string;
100
+ }
101
+ interface StackFrame {
102
+ function: string;
103
+ file: string;
104
+ line: number;
105
+ column?: number;
106
+ isProjectCode: boolean;
107
+ }
108
+ interface StackTraceInfo {
109
+ hasStackTrace: boolean;
110
+ language: string | null;
111
+ frames: string[];
112
+ }
113
+ interface FixHiveContext {
114
+ sessionId: string;
115
+ projectDirectory: string;
116
+ language?: Language;
117
+ framework?: string;
118
+ }
119
+ interface ToolOutput {
120
+ tool: string;
121
+ output: string;
122
+ exitCode?: number;
123
+ stderr?: string;
124
+ metadata?: Record<string, unknown>;
125
+ }
126
+ interface PrivacyFilterRule {
127
+ name: string;
128
+ category: 'secret' | 'identity' | 'infrastructure' | 'path' | 'environment';
129
+ pattern: RegExp;
130
+ replacement: string | ((match: string, ...groups: string[]) => string);
131
+ priority: number;
132
+ }
133
+ interface SanitizedContent {
134
+ original: string;
135
+ sanitized: string;
136
+ redactedCount: number;
137
+ appliedFilters: string[];
138
+ }
139
+ interface FilterContext {
140
+ projectRoot: string;
141
+ homeDir: string;
142
+ commonPaths: Map<string, string>;
143
+ }
144
+ interface SearchRequest {
145
+ errorMessage: string;
146
+ errorStack?: string;
147
+ language?: Language;
148
+ framework?: string;
149
+ limit?: number;
150
+ threshold?: number;
151
+ }
152
+ interface SearchResponse {
153
+ results: CloudKnowledgeEntry[];
154
+ queryTime: number;
155
+ cached: boolean;
156
+ }
157
+ interface UploadRequest {
158
+ errorRecord: LocalErrorRecord;
159
+ resolution: string;
160
+ resolutionCode?: string;
161
+ resolutionSteps?: string[];
162
+ }
163
+ interface UploadResponse {
164
+ success: boolean;
165
+ knowledgeId?: string;
166
+ isDuplicate: boolean;
167
+ existingId?: string;
168
+ message: string;
169
+ }
170
+ interface QueryKnowledgeArgs {
171
+ errorMessage: string;
172
+ language?: string;
173
+ framework?: string;
174
+ limit?: number;
175
+ }
176
+ interface SubmitResolutionArgs {
177
+ errorId: string;
178
+ resolution: string;
179
+ resolutionCode?: string;
180
+ }
181
+ interface ListErrorsArgs {
182
+ status?: ErrorStatus;
183
+ limit?: number;
184
+ }
185
+ interface MarkResolvedArgs {
186
+ errorId: string;
187
+ resolution: string;
188
+ resolutionCode?: string;
189
+ upload?: boolean;
190
+ }
191
+ interface VoteArgs {
192
+ knowledgeId: string;
193
+ helpful: boolean;
194
+ }
195
+ interface FixHiveConfig {
196
+ supabaseUrl: string;
197
+ supabaseAnonKey: string;
198
+ openaiApiKey?: string;
199
+ contributorId: string;
200
+ cacheExpirationMs: number;
201
+ embeddingModel: string;
202
+ embeddingDimensions: number;
203
+ similarityThreshold: number;
204
+ maxSearchResults: number;
205
+ }
206
+ interface PartialConfig {
207
+ supabaseUrl?: string;
208
+ supabaseAnonKey?: string;
209
+ openaiApiKey?: string;
210
+ contributorId?: string;
211
+ cacheExpirationMs?: number;
212
+ }
213
+ type FixHiveEvent = {
214
+ type: 'error:detected';
215
+ payload: LocalErrorRecord;
216
+ } | {
217
+ type: 'error:resolved';
218
+ payload: {
219
+ errorId: string;
220
+ resolution: string;
221
+ };
222
+ } | {
223
+ type: 'solution:uploaded';
224
+ payload: {
225
+ knowledgeId: string;
226
+ };
227
+ } | {
228
+ type: 'solution:found';
229
+ payload: CloudKnowledgeEntry[];
230
+ };
231
+
232
+ /**
233
+ * FixHive Privacy Filter
234
+ * Sanitizes sensitive information from error messages before sharing
235
+ */
236
+
237
+ /**
238
+ * Create a PrivacyFilter instance
239
+ * Factory function pattern to avoid ES6 class issues with Bun
240
+ */
241
+ declare function createPrivacyFilter(customRules?: PrivacyFilterRule[]): PrivacyFilter;
242
+ /**
243
+ * PrivacyFilter interface - defines all public methods
244
+ */
245
+ interface PrivacyFilter {
246
+ sanitize(content: string, context?: FilterContext): SanitizedContent;
247
+ addRule(rule: PrivacyFilterRule): void;
248
+ removeRule(name: string): boolean;
249
+ getRules(): ReadonlyArray<PrivacyFilterRule>;
250
+ containsSensitiveData(content: string): boolean;
251
+ }
252
+ /**
253
+ * Legacy class wrapper for backwards compatibility
254
+ * @deprecated Use createPrivacyFilter() instead
255
+ */
256
+ declare const PrivacyFilter: {
257
+ create: typeof createPrivacyFilter;
258
+ };
259
+ /**
260
+ * Create default filter context from project directory
261
+ */
262
+ declare function createFilterContext(projectDirectory: string): FilterContext;
263
+ declare const defaultPrivacyFilter: PrivacyFilter;
264
+
265
+ /**
266
+ * FixHive Error Detector
267
+ * Detects errors from tool outputs using multi-signal analysis
268
+ */
269
+
270
+ /**
271
+ * Create an ErrorDetector instance
272
+ * Factory function pattern to avoid ES6 class issues with Bun
273
+ */
274
+ declare function createErrorDetector(privacyFilter?: PrivacyFilter): ErrorDetector;
275
+ /**
276
+ * ErrorDetector interface - defines all public methods
277
+ */
278
+ interface ErrorDetector {
279
+ detect(toolOutput: ToolOutput): ErrorDetectionResult;
280
+ }
281
+ /**
282
+ * Legacy class wrapper for backwards compatibility
283
+ * @deprecated Use createErrorDetector() instead
284
+ */
285
+ declare const ErrorDetector: {
286
+ create: typeof createErrorDetector;
287
+ };
288
+ declare const defaultErrorDetector: ErrorDetector;
289
+
290
+ /**
291
+ * FixHive Hash Utilities
292
+ * Generates fingerprints and hashes for error deduplication
293
+ */
294
+ /**
295
+ * Generate SHA-256 hash of content
296
+ */
297
+ declare function sha256(content: string): string;
298
+ /**
299
+ * Generate a shortened hash (first 16 characters)
300
+ */
301
+ declare function shortHash(content: string): string;
302
+ /**
303
+ * Generate error fingerprint for matching similar errors
304
+ * Normalizes variable parts (paths, numbers, hashes) before hashing
305
+ */
306
+ declare function generateErrorFingerprint(errorMessage: string, errorStack?: string): string;
307
+ /**
308
+ * Normalize error content by replacing variable parts
309
+ */
310
+ declare function normalizeErrorContent(content: string): string;
311
+ /**
312
+ * Generate contributor ID (anonymous hash)
313
+ * Uses machine-specific information to create a stable anonymous ID
314
+ */
315
+ declare function generateContributorId(): string;
316
+ /**
317
+ * Generate session-specific hash
318
+ */
319
+ declare function generateSessionHash(sessionId: string): string;
320
+ /**
321
+ * Compare two fingerprints for similarity
322
+ * Returns true if they're identical (exact match)
323
+ */
324
+ declare function fingerprintsMatch(fp1: string, fp2: string): boolean;
325
+ /**
326
+ * Calculate simple string similarity (Jaccard index)
327
+ * Used as a fallback when embeddings aren't available
328
+ */
329
+ declare function calculateStringSimilarity(str1: string, str2: string): number;
330
+
331
+ /**
332
+ * FixHive Local Store
333
+ * SQLite-based local storage for error records and caching
334
+ */
335
+
336
+ /**
337
+ * Create a LocalStore instance
338
+ * Factory function pattern to avoid ES6 class issues with Bun
339
+ */
340
+ declare function createLocalStore(projectDirectory: string): LocalStore;
341
+ /**
342
+ * LocalStore interface - defines all public methods
343
+ */
344
+ interface LocalStore {
345
+ createErrorRecord(data: Omit<LocalErrorRecord, 'id' | 'errorHash' | 'status' | 'createdAt'>): LocalErrorRecord;
346
+ getErrorById(id: string): LocalErrorRecord | null;
347
+ getSessionErrors(sessionId: string, options?: {
348
+ status?: ErrorStatus;
349
+ limit?: number;
350
+ }): LocalErrorRecord[];
351
+ getUnresolvedErrors(sessionId: string): LocalErrorRecord[];
352
+ getRecentErrors(limit?: number): LocalErrorRecord[];
353
+ markResolved(id: string, data: {
354
+ resolution: string;
355
+ resolutionCode?: string;
356
+ }): LocalErrorRecord | null;
357
+ markUploaded(id: string, cloudKnowledgeId: string): void;
358
+ findSimilarErrors(errorHash: string): LocalErrorRecord[];
359
+ getCachedResults(errorHash: string): CloudKnowledgeEntry[] | null;
360
+ cacheResults(errorHash: string, results: CloudKnowledgeEntry[], expirationMs?: number): void;
361
+ clearExpiredCache(): number;
362
+ getStats(): LocalStats;
363
+ getPreference(key: string): string | null;
364
+ setPreference(key: string, value: string): void;
365
+ close(): void;
366
+ getDatabase(): Database.Database;
367
+ }
368
+ /**
369
+ * Legacy class wrapper for backwards compatibility
370
+ * @deprecated Use createLocalStore() instead
371
+ */
372
+ declare const LocalStore: {
373
+ create: typeof createLocalStore;
374
+ };
375
+
376
+ /**
377
+ * FixHive Database Migrations
378
+ * SQLite schema setup and migrations
379
+ */
380
+
381
+ /**
382
+ * Run all migrations on the database
383
+ */
384
+ declare function runMigrations(db: Database.Database): void;
385
+
386
+ /**
387
+ * FixHive Cloud Client
388
+ * Supabase client for cloud knowledge base operations
389
+ */
390
+
391
+ /**
392
+ * Cloud Client Configuration
393
+ */
394
+ interface CloudClientConfig {
395
+ supabaseUrl: string;
396
+ supabaseAnonKey: string;
397
+ openaiApiKey?: string;
398
+ contributorId?: string;
399
+ similarityThreshold?: number;
400
+ }
401
+ /**
402
+ * Create a CloudClient instance
403
+ * Factory function pattern to avoid ES6 class issues with Bun
404
+ */
405
+ declare function createCloudClient(config: CloudClientConfig): Promise<CloudClient>;
406
+ /**
407
+ * CloudClient interface - defines all public methods
408
+ */
409
+ interface CloudClient {
410
+ searchSimilar(request: SearchRequest): Promise<SearchResponse>;
411
+ uploadResolution(request: UploadRequest): Promise<UploadResponse>;
412
+ checkDuplicate(errorHash: string, embedding: number[]): Promise<DuplicateCheckResult>;
413
+ vote(knowledgeId: string, helpful: boolean): Promise<{
414
+ success: boolean;
415
+ error?: string;
416
+ }>;
417
+ reportEntry(knowledgeId: string, reason?: string): Promise<{
418
+ success: boolean;
419
+ }>;
420
+ reportHelpful(knowledgeId: string): Promise<void>;
421
+ getContributorStats(): Promise<ContributorStats>;
422
+ getEntry(id: string): Promise<CloudKnowledgeEntry | null>;
423
+ getContributorId(): string;
424
+ hasEmbeddingService(): boolean;
425
+ }
426
+ declare const CloudClient: {
427
+ create: typeof createCloudClient;
428
+ };
429
+
430
+ /**
431
+ * EmbeddingService configuration
432
+ */
433
+ interface EmbeddingServiceConfig {
434
+ apiKey: string;
435
+ model?: string;
436
+ dimensions?: number;
437
+ }
438
+ /**
439
+ * Calculate cosine similarity between two embeddings
440
+ */
441
+ declare function cosineSimilarity(a: number[], b: number[]): number;
442
+ /**
443
+ * Create an EmbeddingService instance
444
+ * Factory function pattern to avoid ES6 class issues with Bun
445
+ */
446
+ declare function createEmbeddingService(config: EmbeddingServiceConfig): EmbeddingService;
447
+ /**
448
+ * FixHive Embedding Service
449
+ * Generates text embeddings for semantic search using OpenAI
450
+ */
451
+ /**
452
+ * EmbeddingService interface - defines all public methods
453
+ */
454
+ interface EmbeddingService {
455
+ generate(text: string): Promise<number[]>;
456
+ generateBatch(texts: string[]): Promise<number[][]>;
457
+ generateErrorEmbedding(errorMessage: string, errorStack?: string, context?: {
458
+ language?: string;
459
+ framework?: string;
460
+ }): Promise<number[]>;
461
+ getDimensions(): number;
462
+ getModel(): string;
463
+ }
464
+ /**
465
+ * Legacy class wrapper for backwards compatibility
466
+ * @deprecated Use createEmbeddingService() instead
467
+ */
468
+ declare const EmbeddingService: {
469
+ create: typeof createEmbeddingService;
470
+ cosineSimilarity: typeof cosineSimilarity;
471
+ };
472
+
473
+ export { CloudClient, CloudClient as CloudClientInterface, type CloudKnowledgeEntry, type ContributorStats, type DetectedSignal, type DuplicateCheckResult, EmbeddingService, type EmbeddingServiceConfig, EmbeddingService as EmbeddingServiceInterface, type ErrorDetectionResult, ErrorDetector, ErrorDetector as ErrorDetectorInterface, type ErrorStatus, type ErrorType, type FilterContext, type FixHiveConfig, type FixHiveContext, type FixHiveEvent, FixHivePlugin, type Language, type ListErrorsArgs, type LocalErrorRecord, type LocalStats, LocalStore, LocalStore as LocalStoreInterface, type MarkResolvedArgs, type PartialConfig, PrivacyFilter, PrivacyFilter as PrivacyFilterInterface, type PrivacyFilterRule, type QueryCacheEntry, type QueryKnowledgeArgs, type SanitizedContent, type SearchRequest, type SearchResponse, type Severity, type StackFrame, type StackTraceInfo, type SubmitResolutionArgs, type ToolOutput, type UploadRequest, type UploadResponse, type VoteArgs, calculateStringSimilarity, cosineSimilarity, createCloudClient, createEmbeddingService, createErrorDetector, createFilterContext, createLocalStore, createPrivacyFilter, FixHivePlugin as default, defaultErrorDetector, defaultPrivacyFilter, fingerprintsMatch, generateContributorId, generateErrorFingerprint, generateSessionHash, normalizeErrorContent, runMigrations, sha256, shortHash };