opencode-supertask 0.1.0 → 0.1.2
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/cli/index.js +273 -67
- package/dist/cli/index.js.map +1 -1
- package/dist/gateway/index.js +53 -0
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +157 -4
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +53 -0
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.js +53 -0
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/web/index.js
CHANGED
|
@@ -16432,6 +16432,44 @@ function drizzle(...params) {
|
|
|
16432
16432
|
drizzle2.mock = mock;
|
|
16433
16433
|
})(drizzle || (drizzle = {}));
|
|
16434
16434
|
|
|
16435
|
+
// node_modules/drizzle-orm/migrator.js
|
|
16436
|
+
import crypto from "crypto";
|
|
16437
|
+
import fs from "fs";
|
|
16438
|
+
function readMigrationFiles(config) {
|
|
16439
|
+
const migrationFolderTo = config.migrationsFolder;
|
|
16440
|
+
const migrationQueries = [];
|
|
16441
|
+
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
|
|
16442
|
+
if (!fs.existsSync(journalPath)) {
|
|
16443
|
+
throw new Error(`Can't find meta/_journal.json file`);
|
|
16444
|
+
}
|
|
16445
|
+
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
|
|
16446
|
+
const journal = JSON.parse(journalAsString);
|
|
16447
|
+
for (const journalEntry of journal.entries) {
|
|
16448
|
+
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
|
|
16449
|
+
try {
|
|
16450
|
+
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
|
|
16451
|
+
const result = query.split("--> statement-breakpoint").map((it) => {
|
|
16452
|
+
return it;
|
|
16453
|
+
});
|
|
16454
|
+
migrationQueries.push({
|
|
16455
|
+
sql: result,
|
|
16456
|
+
bps: journalEntry.breakpoints,
|
|
16457
|
+
folderMillis: journalEntry.when,
|
|
16458
|
+
hash: crypto.createHash("sha256").update(query).digest("hex")
|
|
16459
|
+
});
|
|
16460
|
+
} catch {
|
|
16461
|
+
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
16462
|
+
}
|
|
16463
|
+
}
|
|
16464
|
+
return migrationQueries;
|
|
16465
|
+
}
|
|
16466
|
+
|
|
16467
|
+
// node_modules/drizzle-orm/bun-sqlite/migrator.js
|
|
16468
|
+
function migrate(db2, config) {
|
|
16469
|
+
const migrations = readMigrationFiles(config);
|
|
16470
|
+
db2.dialect.migrate(migrations, db2.session, config);
|
|
16471
|
+
}
|
|
16472
|
+
|
|
16435
16473
|
// src/core/db/schema.ts
|
|
16436
16474
|
var schema_exports = {};
|
|
16437
16475
|
__export(schema_exports, {
|
|
@@ -16522,11 +16560,18 @@ var taskTemplates = sqliteTable("task_templates", {
|
|
|
16522
16560
|
import { existsSync, mkdirSync } from "fs";
|
|
16523
16561
|
import { homedir } from "os";
|
|
16524
16562
|
import { join, dirname } from "path";
|
|
16563
|
+
import { fileURLToPath } from "url";
|
|
16525
16564
|
var DB_FILE_PATH = join(homedir(), ".local/share/opencode/tasks.db");
|
|
16526
16565
|
var _sqlite = null;
|
|
16527
16566
|
var _db = null;
|
|
16567
|
+
var _migrationRan = false;
|
|
16568
|
+
function getMigrationsFolder() {
|
|
16569
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16570
|
+
return join(__dirname, "../../drizzle");
|
|
16571
|
+
}
|
|
16528
16572
|
function initDb() {
|
|
16529
16573
|
const dataDir = dirname(DB_FILE_PATH);
|
|
16574
|
+
const dbExisted = existsSync(DB_FILE_PATH);
|
|
16530
16575
|
if (!existsSync(dataDir)) {
|
|
16531
16576
|
mkdirSync(dataDir, { recursive: true });
|
|
16532
16577
|
}
|
|
@@ -16542,6 +16587,14 @@ function initDb() {
|
|
|
16542
16587
|
);
|
|
16543
16588
|
`);
|
|
16544
16589
|
_db = drizzle(_sqlite, { schema: schema_exports });
|
|
16590
|
+
if (!_migrationRan) {
|
|
16591
|
+
_migrationRan = true;
|
|
16592
|
+
try {
|
|
16593
|
+
migrate(_db, { migrationsFolder: getMigrationsFolder() });
|
|
16594
|
+
} catch (err) {
|
|
16595
|
+
console.error("[supertask] migration failed:", err instanceof Error ? err.message : String(err));
|
|
16596
|
+
}
|
|
16597
|
+
}
|
|
16545
16598
|
return _db;
|
|
16546
16599
|
}
|
|
16547
16600
|
function getDb() {
|