opencode-supertask 0.1.0 → 0.1.1
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 +74 -58
- 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 +79 -0
- 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/worker/index.js
CHANGED
|
@@ -5061,6 +5061,44 @@ function drizzle(...params) {
|
|
|
5061
5061
|
drizzle2.mock = mock;
|
|
5062
5062
|
})(drizzle || (drizzle = {}));
|
|
5063
5063
|
|
|
5064
|
+
// node_modules/drizzle-orm/migrator.js
|
|
5065
|
+
import crypto from "crypto";
|
|
5066
|
+
import fs from "fs";
|
|
5067
|
+
function readMigrationFiles(config) {
|
|
5068
|
+
const migrationFolderTo = config.migrationsFolder;
|
|
5069
|
+
const migrationQueries = [];
|
|
5070
|
+
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
|
|
5071
|
+
if (!fs.existsSync(journalPath)) {
|
|
5072
|
+
throw new Error(`Can't find meta/_journal.json file`);
|
|
5073
|
+
}
|
|
5074
|
+
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
|
|
5075
|
+
const journal = JSON.parse(journalAsString);
|
|
5076
|
+
for (const journalEntry of journal.entries) {
|
|
5077
|
+
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
|
|
5078
|
+
try {
|
|
5079
|
+
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
|
|
5080
|
+
const result = query.split("--> statement-breakpoint").map((it) => {
|
|
5081
|
+
return it;
|
|
5082
|
+
});
|
|
5083
|
+
migrationQueries.push({
|
|
5084
|
+
sql: result,
|
|
5085
|
+
bps: journalEntry.breakpoints,
|
|
5086
|
+
folderMillis: journalEntry.when,
|
|
5087
|
+
hash: crypto.createHash("sha256").update(query).digest("hex")
|
|
5088
|
+
});
|
|
5089
|
+
} catch {
|
|
5090
|
+
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
5091
|
+
}
|
|
5092
|
+
}
|
|
5093
|
+
return migrationQueries;
|
|
5094
|
+
}
|
|
5095
|
+
|
|
5096
|
+
// node_modules/drizzle-orm/bun-sqlite/migrator.js
|
|
5097
|
+
function migrate(db2, config) {
|
|
5098
|
+
const migrations = readMigrationFiles(config);
|
|
5099
|
+
db2.dialect.migrate(migrations, db2.session, config);
|
|
5100
|
+
}
|
|
5101
|
+
|
|
5064
5102
|
// src/core/db/schema.ts
|
|
5065
5103
|
var schema_exports = {};
|
|
5066
5104
|
__export(schema_exports, {
|
|
@@ -5151,11 +5189,18 @@ var taskTemplates = sqliteTable("task_templates", {
|
|
|
5151
5189
|
import { existsSync, mkdirSync } from "fs";
|
|
5152
5190
|
import { homedir } from "os";
|
|
5153
5191
|
import { join, dirname } from "path";
|
|
5192
|
+
import { fileURLToPath } from "url";
|
|
5154
5193
|
var DB_FILE_PATH = join(homedir(), ".local/share/opencode/tasks.db");
|
|
5155
5194
|
var _sqlite = null;
|
|
5156
5195
|
var _db = null;
|
|
5196
|
+
var _migrationRan = false;
|
|
5197
|
+
function getMigrationsFolder() {
|
|
5198
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5199
|
+
return join(__dirname, "../../drizzle");
|
|
5200
|
+
}
|
|
5157
5201
|
function initDb() {
|
|
5158
5202
|
const dataDir = dirname(DB_FILE_PATH);
|
|
5203
|
+
const dbExisted = existsSync(DB_FILE_PATH);
|
|
5159
5204
|
if (!existsSync(dataDir)) {
|
|
5160
5205
|
mkdirSync(dataDir, { recursive: true });
|
|
5161
5206
|
}
|
|
@@ -5171,6 +5216,14 @@ function initDb() {
|
|
|
5171
5216
|
);
|
|
5172
5217
|
`);
|
|
5173
5218
|
_db = drizzle(_sqlite, { schema: schema_exports });
|
|
5219
|
+
if (!_migrationRan) {
|
|
5220
|
+
_migrationRan = true;
|
|
5221
|
+
try {
|
|
5222
|
+
migrate(_db, { migrationsFolder: getMigrationsFolder() });
|
|
5223
|
+
} catch (err) {
|
|
5224
|
+
console.error("[supertask] migration failed:", err instanceof Error ? err.message : String(err));
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5174
5227
|
return _db;
|
|
5175
5228
|
}
|
|
5176
5229
|
function getDb() {
|