@arcbridge/core 0.4.0 → 0.4.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/index.d.ts CHANGED
@@ -743,7 +743,7 @@ declare function openMemoryDatabase(): Database;
743
743
  */
744
744
  declare function transaction<T>(db: Database, fn: () => T): T;
745
745
 
746
- declare const CURRENT_SCHEMA_VERSION = 3;
746
+ declare const CURRENT_SCHEMA_VERSION = 4;
747
747
  declare function initializeSchema(db: Database): void;
748
748
 
749
749
  declare function migrate(db: Database): void;
package/dist/index.js CHANGED
@@ -292,7 +292,7 @@ function transaction(db, fn) {
292
292
  }
293
293
 
294
294
  // src/db/schema.ts
295
- var CURRENT_SCHEMA_VERSION = 3;
295
+ var CURRENT_SCHEMA_VERSION = 4;
296
296
  var SCHEMA_SQL = `
297
297
  -- Metadata
298
298
  CREATE TABLE IF NOT EXISTS arcbridge_meta (
@@ -447,6 +447,9 @@ CREATE TABLE IF NOT EXISTS tasks (
447
447
  completed_at TEXT
448
448
  );
449
449
 
450
+ CREATE INDEX IF NOT EXISTS idx_tasks_phase ON tasks(phase_id);
451
+ CREATE INDEX IF NOT EXISTS idx_phases_status ON phases(status);
452
+
450
453
  CREATE TABLE IF NOT EXISTS drift_log (
451
454
  id INTEGER PRIMARY KEY AUTOINCREMENT,
452
455
  detected_at TEXT NOT NULL,
@@ -560,6 +563,15 @@ var migrations = [
560
563
  ALTER TABLE tasks_new RENAME TO tasks;
561
564
  `);
562
565
  }
566
+ },
567
+ {
568
+ version: 4,
569
+ up: (db) => {
570
+ db.exec(`
571
+ CREATE INDEX IF NOT EXISTS idx_tasks_phase ON tasks(phase_id);
572
+ CREATE INDEX IF NOT EXISTS idx_phases_status ON phases(status);
573
+ `);
574
+ }
563
575
  }
564
576
  ];
565
577
  function migrate(db) {
@@ -7593,7 +7605,7 @@ function detectMissingModules(db, entries) {
7593
7605
  const paths = safeParseJson(block.code_paths, []);
7594
7606
  for (const cp of paths) {
7595
7607
  const prefix = normalizePath(cp);
7596
- const match = db.prepare("SELECT 1 FROM symbols WHERE file_path LIKE ? LIMIT 1").get(`${escapeLike(prefix)}%`);
7608
+ const match = db.prepare("SELECT 1 FROM symbols WHERE file_path LIKE ? ESCAPE '\\' LIMIT 1").get(`${escapeLike(prefix)}%`);
7597
7609
  if (!match) {
7598
7610
  entries.push({
7599
7611
  kind: "missing_module",
@@ -7697,7 +7709,7 @@ function detectStaleAdrs(db, entries) {
7697
7709
  if (files.length === 0) continue;
7698
7710
  for (const file of files) {
7699
7711
  const prefix = normalizePath(file);
7700
- const match = db.prepare("SELECT 1 FROM symbols WHERE file_path LIKE ? LIMIT 1").get(`${escapeLike(prefix)}%`);
7712
+ const match = db.prepare("SELECT 1 FROM symbols WHERE file_path LIKE ? ESCAPE '\\' LIMIT 1").get(`${escapeLike(prefix)}%`);
7701
7713
  if (!match) {
7702
7714
  entries.push({
7703
7715
  kind: "stale_adr",
@@ -7781,7 +7793,7 @@ function fileMatchesPath(filePath, prefix) {
7781
7793
  return filePath === prefix || filePath.startsWith(prefix);
7782
7794
  }
7783
7795
  function escapeLike(value) {
7784
- return value.replace(/%/g, "\\%").replace(/_/g, "\\_");
7796
+ return value.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
7785
7797
  }
7786
7798
  function safeParseJson(value, fallback) {
7787
7799
  if (value === null || value === void 0) return fallback;
@@ -8096,7 +8108,7 @@ function inferSingleTask(db, task) {
8096
8108
  return null;
8097
8109
  }
8098
8110
  function escapeLike2(value) {
8099
- return value.replace(/%/g, "\\%").replace(/_/g, "\\_");
8111
+ return value.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
8100
8112
  }
8101
8113
  function safeParseJson2(value, fallback) {
8102
8114
  if (value === null || value === void 0) return fallback;