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/gateway/index.js
CHANGED
|
@@ -14256,6 +14256,44 @@ function drizzle(...params) {
|
|
|
14256
14256
|
drizzle2.mock = mock;
|
|
14257
14257
|
})(drizzle || (drizzle = {}));
|
|
14258
14258
|
|
|
14259
|
+
// node_modules/drizzle-orm/migrator.js
|
|
14260
|
+
import crypto from "crypto";
|
|
14261
|
+
import fs from "fs";
|
|
14262
|
+
function readMigrationFiles(config) {
|
|
14263
|
+
const migrationFolderTo = config.migrationsFolder;
|
|
14264
|
+
const migrationQueries = [];
|
|
14265
|
+
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
|
|
14266
|
+
if (!fs.existsSync(journalPath)) {
|
|
14267
|
+
throw new Error(`Can't find meta/_journal.json file`);
|
|
14268
|
+
}
|
|
14269
|
+
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
|
|
14270
|
+
const journal = JSON.parse(journalAsString);
|
|
14271
|
+
for (const journalEntry of journal.entries) {
|
|
14272
|
+
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
|
|
14273
|
+
try {
|
|
14274
|
+
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
|
|
14275
|
+
const result = query.split("--> statement-breakpoint").map((it) => {
|
|
14276
|
+
return it;
|
|
14277
|
+
});
|
|
14278
|
+
migrationQueries.push({
|
|
14279
|
+
sql: result,
|
|
14280
|
+
bps: journalEntry.breakpoints,
|
|
14281
|
+
folderMillis: journalEntry.when,
|
|
14282
|
+
hash: crypto.createHash("sha256").update(query).digest("hex")
|
|
14283
|
+
});
|
|
14284
|
+
} catch {
|
|
14285
|
+
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
14286
|
+
}
|
|
14287
|
+
}
|
|
14288
|
+
return migrationQueries;
|
|
14289
|
+
}
|
|
14290
|
+
|
|
14291
|
+
// node_modules/drizzle-orm/bun-sqlite/migrator.js
|
|
14292
|
+
function migrate(db2, config) {
|
|
14293
|
+
const migrations = readMigrationFiles(config);
|
|
14294
|
+
db2.dialect.migrate(migrations, db2.session, config);
|
|
14295
|
+
}
|
|
14296
|
+
|
|
14259
14297
|
// src/core/db/schema.ts
|
|
14260
14298
|
var schema_exports = {};
|
|
14261
14299
|
__export(schema_exports, {
|
|
@@ -14346,11 +14384,18 @@ var taskTemplates = sqliteTable("task_templates", {
|
|
|
14346
14384
|
import { existsSync, mkdirSync } from "fs";
|
|
14347
14385
|
import { homedir } from "os";
|
|
14348
14386
|
import { join, dirname } from "path";
|
|
14387
|
+
import { fileURLToPath } from "url";
|
|
14349
14388
|
var DB_FILE_PATH = join(homedir(), ".local/share/opencode/tasks.db");
|
|
14350
14389
|
var _sqlite = null;
|
|
14351
14390
|
var _db = null;
|
|
14391
|
+
var _migrationRan = false;
|
|
14392
|
+
function getMigrationsFolder() {
|
|
14393
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14394
|
+
return join(__dirname, "../../drizzle");
|
|
14395
|
+
}
|
|
14352
14396
|
function initDb() {
|
|
14353
14397
|
const dataDir = dirname(DB_FILE_PATH);
|
|
14398
|
+
const dbExisted = existsSync(DB_FILE_PATH);
|
|
14354
14399
|
if (!existsSync(dataDir)) {
|
|
14355
14400
|
mkdirSync(dataDir, { recursive: true });
|
|
14356
14401
|
}
|
|
@@ -14366,6 +14411,14 @@ function initDb() {
|
|
|
14366
14411
|
);
|
|
14367
14412
|
`);
|
|
14368
14413
|
_db = drizzle(_sqlite, { schema: schema_exports });
|
|
14414
|
+
if (!_migrationRan) {
|
|
14415
|
+
_migrationRan = true;
|
|
14416
|
+
try {
|
|
14417
|
+
migrate(_db, { migrationsFolder: getMigrationsFolder() });
|
|
14418
|
+
} catch (err) {
|
|
14419
|
+
console.error("[supertask] migration failed:", err instanceof Error ? err.message : String(err));
|
|
14420
|
+
}
|
|
14421
|
+
}
|
|
14369
14422
|
return _db;
|
|
14370
14423
|
}
|
|
14371
14424
|
function getDb() {
|