@the-magic-tower/fixhive-opencode-plugin 0.1.28 → 0.1.29
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.js
CHANGED
|
@@ -27277,9 +27277,6 @@ ${toolOutput.stderr || ""}`;
|
|
|
27277
27277
|
}
|
|
27278
27278
|
var defaultErrorDetector = createErrorDetector();
|
|
27279
27279
|
|
|
27280
|
-
// src/storage/local-store.ts
|
|
27281
|
-
import Database from "better-sqlite3";
|
|
27282
|
-
|
|
27283
27280
|
// node_modules/uuid/dist-node/stringify.js
|
|
27284
27281
|
var byteToHex = [];
|
|
27285
27282
|
for (let i = 0;i < 256; ++i) {
|
|
@@ -27455,6 +27452,46 @@ var MIGRATIONS = [
|
|
|
27455
27452
|
];
|
|
27456
27453
|
|
|
27457
27454
|
// src/storage/local-store.ts
|
|
27455
|
+
var isBun = typeof Bun !== "undefined";
|
|
27456
|
+
async function createDatabase(dbPath) {
|
|
27457
|
+
if (isBun) {
|
|
27458
|
+
const { Database } = await import("bun:sqlite");
|
|
27459
|
+
const db = new Database(dbPath, { create: true });
|
|
27460
|
+
return {
|
|
27461
|
+
exec: (sql) => db.exec(sql),
|
|
27462
|
+
prepare: (sql) => {
|
|
27463
|
+
const stmt = db.prepare(sql);
|
|
27464
|
+
return {
|
|
27465
|
+
run: (...params) => {
|
|
27466
|
+
stmt.run(...params);
|
|
27467
|
+
return { changes: db.changes };
|
|
27468
|
+
},
|
|
27469
|
+
get: (...params) => stmt.get(...params),
|
|
27470
|
+
all: (...params) => stmt.all(...params)
|
|
27471
|
+
};
|
|
27472
|
+
},
|
|
27473
|
+
close: () => db.close()
|
|
27474
|
+
};
|
|
27475
|
+
} else {
|
|
27476
|
+
const BetterSqlite3 = (await import("better-sqlite3")).default;
|
|
27477
|
+
const db = new BetterSqlite3(dbPath);
|
|
27478
|
+
return {
|
|
27479
|
+
exec: (sql) => db.exec(sql),
|
|
27480
|
+
prepare: (sql) => {
|
|
27481
|
+
const stmt = db.prepare(sql);
|
|
27482
|
+
return {
|
|
27483
|
+
run: (...params) => {
|
|
27484
|
+
const result = stmt.run(...params);
|
|
27485
|
+
return { changes: result.changes };
|
|
27486
|
+
},
|
|
27487
|
+
get: (...params) => stmt.get(...params),
|
|
27488
|
+
all: (...params) => stmt.all(...params)
|
|
27489
|
+
};
|
|
27490
|
+
},
|
|
27491
|
+
close: () => db.close()
|
|
27492
|
+
};
|
|
27493
|
+
}
|
|
27494
|
+
}
|
|
27458
27495
|
var ALLOWED_STATS = [
|
|
27459
27496
|
"total_errors",
|
|
27460
27497
|
"resolved_errors",
|
|
@@ -27482,15 +27519,15 @@ function rowToRecord(row) {
|
|
|
27482
27519
|
cloudKnowledgeId: row.cloud_knowledge_id || undefined
|
|
27483
27520
|
};
|
|
27484
27521
|
}
|
|
27485
|
-
function createLocalStore(projectDirectory) {
|
|
27522
|
+
async function createLocalStore(projectDirectory) {
|
|
27486
27523
|
const dbPath = `${projectDirectory}/.fixhive/fixhive.db`;
|
|
27487
27524
|
const dir = dirname(dbPath);
|
|
27488
27525
|
if (!existsSync(dir)) {
|
|
27489
27526
|
mkdirSync(dir, { recursive: true });
|
|
27490
27527
|
}
|
|
27491
|
-
const db =
|
|
27492
|
-
db.
|
|
27493
|
-
db.
|
|
27528
|
+
const db = await createDatabase(dbPath);
|
|
27529
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
27530
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
27494
27531
|
runMigrations(db);
|
|
27495
27532
|
function incrementStat(stat) {
|
|
27496
27533
|
if (!ALLOWED_STATS.includes(stat)) {
|
|
@@ -27499,6 +27536,26 @@ function createLocalStore(projectDirectory) {
|
|
|
27499
27536
|
const stmt = db.prepare(`UPDATE usage_stats SET ${stat} = ${stat} + 1 WHERE id = 1`);
|
|
27500
27537
|
stmt.run();
|
|
27501
27538
|
}
|
|
27539
|
+
function getErrorById(id) {
|
|
27540
|
+
const stmt = db.prepare("SELECT * FROM error_records WHERE id = ?");
|
|
27541
|
+
const row = stmt.get(id);
|
|
27542
|
+
return row ? rowToRecord(row) : null;
|
|
27543
|
+
}
|
|
27544
|
+
function getSessionErrors(sessionId, options) {
|
|
27545
|
+
let query = "SELECT * FROM error_records WHERE session_id = ?";
|
|
27546
|
+
const params = [sessionId];
|
|
27547
|
+
if (options?.status) {
|
|
27548
|
+
query += " AND status = ?";
|
|
27549
|
+
params.push(options.status);
|
|
27550
|
+
}
|
|
27551
|
+
query += " ORDER BY created_at DESC";
|
|
27552
|
+
if (options?.limit) {
|
|
27553
|
+
query += " LIMIT ?";
|
|
27554
|
+
params.push(options.limit);
|
|
27555
|
+
}
|
|
27556
|
+
const stmt = db.prepare(query);
|
|
27557
|
+
return stmt.all(...params).map((row) => rowToRecord(row));
|
|
27558
|
+
}
|
|
27502
27559
|
return {
|
|
27503
27560
|
createErrorRecord(data) {
|
|
27504
27561
|
const id = v4_default();
|
|
@@ -27507,48 +27564,16 @@ function createLocalStore(projectDirectory) {
|
|
|
27507
27564
|
INSERT INTO error_records (
|
|
27508
27565
|
id, error_hash, error_type, error_message, error_stack,
|
|
27509
27566
|
language, framework, tool_name, tool_input, session_id, status
|
|
27510
|
-
) VALUES (
|
|
27511
|
-
@id, @errorHash, @errorType, @errorMessage, @errorStack,
|
|
27512
|
-
@language, @framework, @toolName, @toolInput, @sessionId, 'unresolved'
|
|
27513
|
-
)
|
|
27567
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'unresolved')
|
|
27514
27568
|
`);
|
|
27515
|
-
stmt.run(
|
|
27516
|
-
id,
|
|
27517
|
-
errorHash,
|
|
27518
|
-
errorType: data.errorType,
|
|
27519
|
-
errorMessage: data.errorMessage,
|
|
27520
|
-
errorStack: data.errorStack || null,
|
|
27521
|
-
language: data.language || null,
|
|
27522
|
-
framework: data.framework || null,
|
|
27523
|
-
toolName: data.toolName,
|
|
27524
|
-
toolInput: JSON.stringify(data.toolInput),
|
|
27525
|
-
sessionId: data.sessionId
|
|
27526
|
-
});
|
|
27569
|
+
stmt.run(id, errorHash, data.errorType, data.errorMessage, data.errorStack || null, data.language || null, data.framework || null, data.toolName, JSON.stringify(data.toolInput), data.sessionId);
|
|
27527
27570
|
incrementStat("total_errors");
|
|
27528
|
-
return
|
|
27529
|
-
},
|
|
27530
|
-
getErrorById(id) {
|
|
27531
|
-
const stmt = db.prepare("SELECT * FROM error_records WHERE id = ?");
|
|
27532
|
-
const row = stmt.get(id);
|
|
27533
|
-
return row ? rowToRecord(row) : null;
|
|
27534
|
-
},
|
|
27535
|
-
getSessionErrors(sessionId, options) {
|
|
27536
|
-
let query = "SELECT * FROM error_records WHERE session_id = ?";
|
|
27537
|
-
const params = [sessionId];
|
|
27538
|
-
if (options?.status) {
|
|
27539
|
-
query += " AND status = ?";
|
|
27540
|
-
params.push(options.status);
|
|
27541
|
-
}
|
|
27542
|
-
query += " ORDER BY created_at DESC";
|
|
27543
|
-
if (options?.limit) {
|
|
27544
|
-
query += " LIMIT ?";
|
|
27545
|
-
params.push(options.limit);
|
|
27546
|
-
}
|
|
27547
|
-
const stmt = db.prepare(query);
|
|
27548
|
-
return stmt.all(...params).map((row) => rowToRecord(row));
|
|
27571
|
+
return getErrorById(id);
|
|
27549
27572
|
},
|
|
27573
|
+
getErrorById,
|
|
27574
|
+
getSessionErrors,
|
|
27550
27575
|
getUnresolvedErrors(sessionId) {
|
|
27551
|
-
return
|
|
27576
|
+
return getSessionErrors(sessionId, { status: "unresolved" });
|
|
27552
27577
|
},
|
|
27553
27578
|
getRecentErrors(limit = 10) {
|
|
27554
27579
|
const stmt = db.prepare("SELECT * FROM error_records ORDER BY created_at DESC LIMIT ?");
|
|
@@ -27566,7 +27591,7 @@ function createLocalStore(projectDirectory) {
|
|
|
27566
27591
|
const result = stmt.run(data.resolution, data.resolutionCode || null, id);
|
|
27567
27592
|
if (result.changes > 0) {
|
|
27568
27593
|
incrementStat("resolved_errors");
|
|
27569
|
-
return
|
|
27594
|
+
return getErrorById(id);
|
|
27570
27595
|
}
|
|
27571
27596
|
return null;
|
|
27572
27597
|
},
|
|
@@ -28172,7 +28197,7 @@ var FixHivePlugin = async (ctx) => {
|
|
|
28172
28197
|
console.log("[FixHive:DEBUG] Step 5: Creating error detector");
|
|
28173
28198
|
const errorDetector = createErrorDetector(privacyFilter);
|
|
28174
28199
|
console.log("[FixHive:DEBUG] Step 6: Creating local store");
|
|
28175
|
-
const localStore = createLocalStore(ctx.directory);
|
|
28200
|
+
const localStore = await createLocalStore(ctx.directory);
|
|
28176
28201
|
console.log("[FixHive:DEBUG] Step 7: Local store created");
|
|
28177
28202
|
let cloudClient = null;
|
|
28178
28203
|
if (config2.supabaseUrl && config2.supabaseAnonKey) {
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FixHive Local Store
|
|
3
3
|
* SQLite-based local storage for error records and caching
|
|
4
|
+
* Automatically uses bun:sqlite for Bun runtime, better-sqlite3 for Node.js
|
|
4
5
|
*/
|
|
5
|
-
import Database from 'better-sqlite3';
|
|
6
6
|
import type { LocalErrorRecord, ErrorStatus, LocalStats, CloudKnowledgeEntry } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Unified database interface for both Bun and Node.js
|
|
9
|
+
*/
|
|
10
|
+
interface UnifiedDatabase {
|
|
11
|
+
exec(sql: string): void;
|
|
12
|
+
prepare(sql: string): UnifiedStatement;
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
interface UnifiedStatement {
|
|
16
|
+
run(...params: unknown[]): {
|
|
17
|
+
changes: number;
|
|
18
|
+
};
|
|
19
|
+
get(...params: unknown[]): Record<string, unknown> | undefined;
|
|
20
|
+
all(...params: unknown[]): Record<string, unknown>[];
|
|
21
|
+
}
|
|
7
22
|
/**
|
|
8
23
|
* LocalStore interface - defines all public methods
|
|
9
24
|
*/
|
|
@@ -29,13 +44,14 @@ export interface LocalStore {
|
|
|
29
44
|
getPreference(key: string): string | null;
|
|
30
45
|
setPreference(key: string, value: string): void;
|
|
31
46
|
close(): void;
|
|
32
|
-
getDatabase():
|
|
47
|
+
getDatabase(): UnifiedDatabase;
|
|
33
48
|
}
|
|
34
49
|
/**
|
|
35
50
|
* Create a LocalStore instance
|
|
36
51
|
* Factory function pattern to avoid ES6 class issues with Bun
|
|
52
|
+
* Automatically uses bun:sqlite for Bun runtime, better-sqlite3 for Node.js
|
|
37
53
|
*/
|
|
38
|
-
export declare function createLocalStore(projectDirectory: string): LocalStore
|
|
54
|
+
export declare function createLocalStore(projectDirectory: string): Promise<LocalStore>;
|
|
39
55
|
/**
|
|
40
56
|
* Legacy class wrapper for backwards compatibility
|
|
41
57
|
* @deprecated Use createLocalStore() instead
|
|
@@ -43,4 +59,5 @@ export declare function createLocalStore(projectDirectory: string): LocalStore;
|
|
|
43
59
|
export declare const LocalStore: {
|
|
44
60
|
create: typeof createLocalStore;
|
|
45
61
|
};
|
|
62
|
+
export {};
|
|
46
63
|
//# sourceMappingURL=local-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-store.d.ts","sourceRoot":"","sources":["../../src/storage/local-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"local-store.d.ts","sourceRoot":"","sources":["../../src/storage/local-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAU3B;;GAEG;AACH,UAAU,eAAe;IACvB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACvC,KAAK,IAAI,IAAI,CAAC;CACf;AAED,UAAU,gBAAgB;IACxB,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC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,MAAM,GAAG,IAAI,CAAC;IAC7F,iBAAiB,IAAI,MAAM,CAAC;IAC5B,QAAQ,IAAI,UAAU,CAAC;IACvB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,KAAK,IAAI,IAAI,CAAC;IACd,WAAW,IAAI,eAAe,CAAC;CAChC;AA2BD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA0RpF;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU;;CAEtB,CAAC"}
|
|
@@ -2,9 +2,22 @@
|
|
|
2
2
|
* FixHive Database Migrations
|
|
3
3
|
* SQLite schema setup and migrations
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Unified database interface for migrations
|
|
7
|
+
* Works with both bun:sqlite and better-sqlite3
|
|
8
|
+
*/
|
|
9
|
+
interface MigrationDatabase {
|
|
10
|
+
exec(sql: string): void;
|
|
11
|
+
prepare(sql: string): {
|
|
12
|
+
all(...params: unknown[]): Record<string, unknown>[];
|
|
13
|
+
run(...params: unknown[]): {
|
|
14
|
+
changes: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
6
18
|
/**
|
|
7
19
|
* Run all migrations on the database
|
|
8
20
|
*/
|
|
9
|
-
export declare function runMigrations(db:
|
|
21
|
+
export declare function runMigrations(db: MigrationDatabase): void;
|
|
22
|
+
export {};
|
|
10
23
|
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/storage/migrations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/storage/migrations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,UAAU,iBAAiB;IACzB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QACpB,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAChD,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAsBzD"}
|