skill-base
Advanced tools
Sorry, the diff of this file is too big to display
+1
-1
| { | ||
| "name": "skill-base", | ||
| "version": "2.0.30", | ||
| "version": "2.0.31", | ||
| "description": "Skill Base - A lightweight, privately deployable agent skills distribution hub", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
+54
-11
@@ -56,11 +56,11 @@ const { execFileSync } = require('child_process'); | ||
| function hasWalSidecarFiles(dbFilePath) { | ||
| return fs.existsSync(`${dbFilePath}-wal`) || fs.existsSync(`${dbFilePath}-shm`); | ||
| } | ||
| /** | ||
| * better-sqlite3 / 系统 SQLite 默认常用 WAL;node-sqlite3-wasm 的 Node VFS 无法正常打开带 WAL 侧车的库。 | ||
| * 启动前用 sqlite3 helper 自动 checkpoint 并改为 DELETE journal,保证旧库可无缝升级。 | ||
| * 用 sqlite3 CLI 做 checkpoint 并改为 DELETE journal。 | ||
| */ | ||
| function tryNormalizeSqliteJournalForWasm(dbFilePath) { | ||
| if (!fs.existsSync(dbFilePath)) return; | ||
| const walSidecar = `${dbFilePath}-wal`; | ||
| const shmSidecar = `${dbFilePath}-shm`; | ||
| const hasWalSidecar = fs.existsSync(walSidecar) || fs.existsSync(shmSidecar); | ||
| function normalizeJournalWithSqlite3Cli(dbFilePath) { | ||
| const helperPath = resolveMigrationHelperPath(); | ||
@@ -74,5 +74,2 @@ try { | ||
| } catch (err) { | ||
| if (!hasWalSidecar && !process.env.SKILL_BASE_SQLITE3_PATH && helperPath === 'sqlite3') { | ||
| return; | ||
| } | ||
| throw new Error( | ||
@@ -82,3 +79,3 @@ 'Skill Base 无法自动迁移旧版 SQLite WAL 数据库。' + | ||
| `\nhelper: ${helperPath}` + | ||
| '\n请确保当前平台的内置 sqlite3 helper 已随包发布,或手动设置 SKILL_BASE_SQLITE3_PATH 指向可执行 sqlite3。' + | ||
| '\n请确保当前平台的内置 sqlite3 helper 可执行,或手动设置 SKILL_BASE_SQLITE3_PATH 指向本机 sqlite3。' + | ||
| `\nUnderlying error: ${err && err.message ? err.message : String(err)}` | ||
@@ -89,2 +86,14 @@ ); | ||
| /** | ||
| * 有 -wal/-shm 时必须先迁出;无侧车时多数已是 DELETE journal,不应每次启动都跑 bundled sqlite3 | ||
| *(部分 Linux 上该二进制可能无法运行,会误杀正常实例)。 | ||
| * 少数「头文件仍是 WAL、但侧车已被 checkpoint 掉」的库,由下方首次 open 失败后再跑一次 CLI 兜底。 | ||
| */ | ||
| function tryNormalizeSqliteJournalForWasm(dbFilePath) { | ||
| if (!fs.existsSync(dbFilePath)) return; | ||
| if (hasWalSidecarFiles(dbFilePath)) { | ||
| normalizeJournalWithSqlite3Cli(dbFilePath); | ||
| } | ||
| } | ||
| // In tests we reload this module with different DATABASE_PATH values. | ||
@@ -131,3 +140,37 @@ closeSilently(global[DB_CLOSE_KEY]?.database); | ||
| const rawDb = new Database(dbPath); | ||
| function openRawDatabaseOrMigrate() { | ||
| let db; | ||
| try { | ||
| db = new Database(dbPath); | ||
| } catch (err) { | ||
| if (!fs.existsSync(dbPath)) { | ||
| throw err; | ||
| } | ||
| if (hasWalSidecarFiles(dbPath)) { | ||
| throw err; | ||
| } | ||
| normalizeJournalWithSqlite3Cli(dbPath); | ||
| db = new Database(dbPath); | ||
| } | ||
| try { | ||
| db.exec('SELECT 1'); | ||
| return db; | ||
| } catch { | ||
| closeSilently(db); | ||
| if (!fs.existsSync(dbPath)) { | ||
| throw new Error('SQLite 数据库文件在启动探测阶段不存在'); | ||
| } | ||
| if (hasWalSidecarFiles(dbPath)) { | ||
| throw new Error( | ||
| '数据库处于 WAL 且仍存在 -wal/-shm 侧车,但当前驱动无法执行 SQL。请确认无其他进程占用该库,或设置 SKILL_BASE_SQLITE3_PATH 使用本机 sqlite3 完成迁移。' | ||
| ); | ||
| } | ||
| normalizeJournalWithSqlite3Cli(dbPath); | ||
| db = new Database(dbPath); | ||
| db.exec('SELECT 1'); | ||
| return db; | ||
| } | ||
| } | ||
| const rawDb = openRawDatabaseOrMigrate(); | ||
| global[DB_CLOSE_KEY] = { database: rawDb }; | ||
@@ -134,0 +177,0 @@ |
@@ -12,3 +12,3 @@ <!DOCTYPE html> | ||
| <title>Skill Base</title> | ||
| <script type="module" crossorigin src="./assets/index-CFOunYgq.js"></script> | ||
| <script type="module" crossorigin src="./assets/index-BRia_9xP.js"></script> | ||
| <link rel="stylesheet" crossorigin href="./assets/index-oLMg54m4.css"> | ||
@@ -15,0 +15,0 @@ </head> |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
14334658
0.01%9649
0.42%45
-2.17%