agentic-qe 3.6.11 → 3.6.13

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.
Files changed (122) hide show
  1. package/.claude/helpers/learning-service.mjs +2 -0
  2. package/.claude/helpers/statusline-v3.cjs +2 -0
  3. package/.claude/skills/skills-manifest.json +1 -1
  4. package/package.json +1 -1
  5. package/scripts/migrate-v2-to-v3-memory.js +2 -0
  6. package/scripts/sync-claude-flow.cjs +1 -0
  7. package/v3/CHANGELOG.md +29 -0
  8. package/v3/dist/adapters/claude-flow/trajectory-bridge.js +2 -2
  9. package/v3/dist/adapters/claude-flow/trajectory-bridge.js.map +1 -1
  10. package/v3/dist/benchmarks/performance-benchmarks.js +1 -1
  11. package/v3/dist/cli/bundle.js +227 -98
  12. package/v3/dist/cli/commands/learning-helpers.d.ts.map +1 -1
  13. package/v3/dist/cli/commands/learning-helpers.js +3 -4
  14. package/v3/dist/cli/commands/learning-helpers.js.map +1 -1
  15. package/v3/dist/cli/commands/learning.d.ts.map +1 -1
  16. package/v3/dist/cli/commands/learning.js +5 -8
  17. package/v3/dist/cli/commands/learning.js.map +1 -1
  18. package/v3/dist/cli/commands/migrate.js +2 -2
  19. package/v3/dist/coordination/constants.d.ts +1 -1
  20. package/v3/dist/coordination/constants.js +1 -1
  21. package/v3/dist/coordination/task-executor.d.ts.map +1 -1
  22. package/v3/dist/coordination/task-executor.js +410 -88
  23. package/v3/dist/coordination/task-executor.js.map +1 -1
  24. package/v3/dist/domains/code-intelligence/coordinator-hypergraph.js +2 -2
  25. package/v3/dist/domains/code-intelligence/coordinator-hypergraph.js.map +1 -1
  26. package/v3/dist/domains/code-intelligence/coordinator.js +2 -2
  27. package/v3/dist/domains/code-intelligence/coordinator.js.map +1 -1
  28. package/v3/dist/domains/coverage-analysis/coordinator.js +1 -1
  29. package/v3/dist/domains/coverage-analysis/services/coverage-analyzer.js +1 -1
  30. package/v3/dist/domains/coverage-analysis/services/coverage-embedder.d.ts +1 -1
  31. package/v3/dist/domains/coverage-analysis/services/coverage-embedder.js +1 -1
  32. package/v3/dist/domains/coverage-analysis/services/gap-detector.js +1 -1
  33. package/v3/dist/domains/coverage-analysis/services/ghost-coverage-analyzer.js +1 -1
  34. package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts +2 -2
  35. package/v3/dist/domains/coverage-analysis/services/hnsw-index.js +3 -3
  36. package/v3/dist/domains/coverage-analysis/services/sublinear-analyzer.d.ts +1 -1
  37. package/v3/dist/domains/coverage-analysis/services/sublinear-analyzer.js +1 -1
  38. package/v3/dist/domains/security-compliance/services/scanners/security-patterns.d.ts.map +1 -1
  39. package/v3/dist/domains/security-compliance/services/scanners/security-patterns.js +12 -0
  40. package/v3/dist/domains/security-compliance/services/scanners/security-patterns.js.map +1 -1
  41. package/v3/dist/domains/test-execution/services/test-prioritizer.js +1 -1
  42. package/v3/dist/domains/test-generation/coordinator.js +1 -1
  43. package/v3/dist/governance/feature-flags.js +2 -2
  44. package/v3/dist/governance/feature-flags.js.map +1 -1
  45. package/v3/dist/governance/shard-embeddings.js +1 -1
  46. package/v3/dist/init/fleet-integration.d.ts.map +1 -1
  47. package/v3/dist/init/fleet-integration.js +3 -4
  48. package/v3/dist/init/fleet-integration.js.map +1 -1
  49. package/v3/dist/init/init-wizard-migration.d.ts.map +1 -1
  50. package/v3/dist/init/init-wizard-migration.js +3 -7
  51. package/v3/dist/init/init-wizard-migration.js.map +1 -1
  52. package/v3/dist/init/init-wizard-steps.d.ts.map +1 -1
  53. package/v3/dist/init/init-wizard-steps.js +3 -4
  54. package/v3/dist/init/init-wizard-steps.js.map +1 -1
  55. package/v3/dist/init/migration/data-migrator.d.ts.map +1 -1
  56. package/v3/dist/init/migration/data-migrator.js +6 -10
  57. package/v3/dist/init/migration/data-migrator.js.map +1 -1
  58. package/v3/dist/init/migration/detector.d.ts.map +1 -1
  59. package/v3/dist/init/migration/detector.js +2 -4
  60. package/v3/dist/init/migration/detector.js.map +1 -1
  61. package/v3/dist/init/phases/01-detection.d.ts.map +1 -1
  62. package/v3/dist/init/phases/01-detection.js +2 -4
  63. package/v3/dist/init/phases/01-detection.js.map +1 -1
  64. package/v3/dist/init/phases/06-code-intelligence.d.ts.map +1 -1
  65. package/v3/dist/init/phases/06-code-intelligence.js +4 -6
  66. package/v3/dist/init/phases/06-code-intelligence.js.map +1 -1
  67. package/v3/dist/init/phases/07-hooks.d.ts +11 -0
  68. package/v3/dist/init/phases/07-hooks.d.ts.map +1 -1
  69. package/v3/dist/init/phases/07-hooks.js +103 -1
  70. package/v3/dist/init/phases/07-hooks.js.map +1 -1
  71. package/v3/dist/init/phases/12-verification.d.ts.map +1 -1
  72. package/v3/dist/init/phases/12-verification.js +2 -4
  73. package/v3/dist/init/phases/12-verification.js.map +1 -1
  74. package/v3/dist/integrations/embeddings/cache/EmbeddingCache.d.ts.map +1 -1
  75. package/v3/dist/integrations/embeddings/cache/EmbeddingCache.js +2 -2
  76. package/v3/dist/integrations/embeddings/cache/EmbeddingCache.js.map +1 -1
  77. package/v3/dist/integrations/rl-suite/algorithms/decision-transformer.js +1 -1
  78. package/v3/dist/kernel/constants.d.ts +1 -1
  79. package/v3/dist/kernel/constants.js +1 -1
  80. package/v3/dist/kernel/unified-memory-hnsw.d.ts.map +1 -1
  81. package/v3/dist/kernel/unified-memory-hnsw.js +25 -6
  82. package/v3/dist/kernel/unified-memory-hnsw.js.map +1 -1
  83. package/v3/dist/kernel/unified-memory-migration.d.ts.map +1 -1
  84. package/v3/dist/kernel/unified-memory-migration.js +3 -3
  85. package/v3/dist/kernel/unified-memory-migration.js.map +1 -1
  86. package/v3/dist/learning/metrics-tracker.d.ts.map +1 -1
  87. package/v3/dist/learning/metrics-tracker.js +2 -2
  88. package/v3/dist/learning/metrics-tracker.js.map +1 -1
  89. package/v3/dist/learning/sqlite-persistence.d.ts.map +1 -1
  90. package/v3/dist/learning/sqlite-persistence.js +3 -6
  91. package/v3/dist/learning/sqlite-persistence.js.map +1 -1
  92. package/v3/dist/learning/v2-to-v3-migration.d.ts.map +1 -1
  93. package/v3/dist/learning/v2-to-v3-migration.js +4 -5
  94. package/v3/dist/learning/v2-to-v3-migration.js.map +1 -1
  95. package/v3/dist/mcp/bundle.js +890 -192
  96. package/v3/dist/mcp/entry.js +8 -0
  97. package/v3/dist/mcp/entry.js.map +1 -1
  98. package/v3/dist/mcp/handlers/domain-handler-configs.d.ts.map +1 -1
  99. package/v3/dist/mcp/handlers/domain-handler-configs.js +56 -4
  100. package/v3/dist/mcp/handlers/domain-handler-configs.js.map +1 -1
  101. package/v3/dist/mcp/handlers/handler-factory.d.ts.map +1 -1
  102. package/v3/dist/mcp/handlers/handler-factory.js +10 -5
  103. package/v3/dist/mcp/handlers/handler-factory.js.map +1 -1
  104. package/v3/dist/mcp/tools/security-compliance/scan.d.ts +3 -1
  105. package/v3/dist/mcp/tools/security-compliance/scan.d.ts.map +1 -1
  106. package/v3/dist/mcp/tools/security-compliance/scan.js +417 -72
  107. package/v3/dist/mcp/tools/security-compliance/scan.js.map +1 -1
  108. package/v3/dist/planning/plan-executor.d.ts.map +1 -1
  109. package/v3/dist/planning/plan-executor.js +2 -2
  110. package/v3/dist/planning/plan-executor.js.map +1 -1
  111. package/v3/dist/shared/safe-db.d.ts +32 -0
  112. package/v3/dist/shared/safe-db.d.ts.map +1 -0
  113. package/v3/dist/shared/safe-db.js +41 -0
  114. package/v3/dist/shared/safe-db.js.map +1 -0
  115. package/v3/dist/sync/claude-flow-bridge.js +5 -5
  116. package/v3/dist/sync/claude-flow-bridge.js.map +1 -1
  117. package/v3/dist/sync/embeddings/sync-embedding-generator.js +3 -3
  118. package/v3/dist/sync/embeddings/sync-embedding-generator.js.map +1 -1
  119. package/v3/dist/sync/readers/sqlite-reader.d.ts.map +1 -1
  120. package/v3/dist/sync/readers/sqlite-reader.js +2 -2
  121. package/v3/dist/sync/readers/sqlite-reader.js.map +1 -1
  122. package/v3/package.json +1 -1
@@ -149,7 +149,7 @@ var init_constants = __esm({
149
149
  /**
150
150
  * Vector dimension for coverage analysis embeddings.
151
151
  */
152
- COVERAGE_VECTOR_DIMENSION: 128
152
+ COVERAGE_VECTOR_DIMENSION: 768
153
153
  };
154
154
  AGENT_CONSTANTS = {
155
155
  /**
@@ -1595,7 +1595,10 @@ var init_unified_memory_hnsw = __esm({
1595
1595
  search(query, k68) {
1596
1596
  if (this.ids.length === 0) return [];
1597
1597
  const actualK = Math.min(k68, this.ids.length);
1598
- if (ruvectorDifferentiableSearch && this.vectors.length > 0) {
1598
+ const storedDim = this.vectors.length > 0 ? this.vectors[0].length : 0;
1599
+ const queryDim = query.length;
1600
+ const dimensionsMatch = storedDim === queryDim;
1601
+ if (ruvectorDifferentiableSearch && this.vectors.length > 0 && dimensionsMatch) {
1599
1602
  const queryF322 = new Float32Array(query);
1600
1603
  const queryNorm2 = computeNorm(queryF322);
1601
1604
  const result = ruvectorDifferentiableSearch(
@@ -1613,10 +1616,20 @@ var init_unified_memory_hnsw = __esm({
1613
1616
  const queryNorm = computeNorm(queryF32);
1614
1617
  const scored = [];
1615
1618
  for (let i58 = 0; i58 < this.ids.length; i58++) {
1616
- scored.push({
1617
- id: this.ids[i58],
1618
- score: fastCosine(queryF32, this.vectors[i58], queryNorm, this.norms[i58])
1619
- });
1619
+ const vec = this.vectors[i58];
1620
+ if (vec.length !== queryF32.length) {
1621
+ if (i58 === 0) {
1622
+ console.warn(
1623
+ `[RuvectorFlatIndex] Dimension mismatch: query=${queryF32.length}, stored=${vec.length}. Skipping ${this.ids.length} mismatched vectors. Re-index with correct dimensions.`
1624
+ );
1625
+ }
1626
+ continue;
1627
+ } else {
1628
+ scored.push({
1629
+ id: this.ids[i58],
1630
+ score: fastCosine(queryF32, vec, queryNorm, this.norms[i58])
1631
+ });
1632
+ }
1620
1633
  }
1621
1634
  scored.sort((a37, b68) => b68.score - a37.score);
1622
1635
  return scored.slice(0, actualK);
@@ -8717,7 +8730,7 @@ function createHNSWIndex(memory, config) {
8717
8730
  return new HNSWIndex(memory, config);
8718
8731
  }
8719
8732
  async function benchmarkHNSW(index, vectorCount = 1e4, searchCount = 1e3) {
8720
- const dimensions = 128;
8733
+ const dimensions = 768;
8721
8734
  const startInsert = performance.now();
8722
8735
  for (let i58 = 0; i58 < vectorCount; i58++) {
8723
8736
  const vector = Array.from({ length: dimensions }, () => Math.random());
@@ -8746,7 +8759,7 @@ var init_hnsw_index = __esm({
8746
8759
  QEGNNEmbeddingIndexClass = null;
8747
8760
  ruvectorLoaded = false;
8748
8761
  DEFAULT_HNSW_CONFIG = {
8749
- dimensions: 128,
8762
+ dimensions: 768,
8750
8763
  M: 16,
8751
8764
  efConstruction: 200,
8752
8765
  efSearch: 100,
@@ -8998,7 +9011,7 @@ var init_hnsw_index = __esm({
8998
9011
  /**
8999
9012
  * Validate and auto-resize vectors to match HNSW configured dimensions.
9000
9013
  * Fix #279: Prevents Rust WASM panic when RealEmbeddings (768-dim) are
9001
- * passed to a 128-dim HNSW index.
9014
+ * passed to a mismatched-dim HNSW index.
9002
9015
  */
9003
9016
  validateVector(vector) {
9004
9017
  if (vector.length !== this.config.dimensions) {
@@ -11598,6 +11611,33 @@ ${JSON.stringify(results.map((n61) => ({ id: n61.id, label: n61.label, propertie
11598
11611
  }
11599
11612
  });
11600
11613
 
11614
+ // src/shared/safe-db.ts
11615
+ var safe_db_exports = {};
11616
+ __export(safe_db_exports, {
11617
+ openDatabase: () => openDatabase
11618
+ });
11619
+ function openDatabase(dbPath, opts) {
11620
+ const readonly = opts?.readonly ?? false;
11621
+ const fileMustExist = opts?.fileMustExist ?? false;
11622
+ const busyTimeout = opts?.busyTimeout ?? 5e3;
11623
+ const walMode = opts?.walMode ?? !readonly;
11624
+ const db = new better_sqlite3_default(dbPath, {
11625
+ readonly,
11626
+ fileMustExist
11627
+ });
11628
+ db.pragma(`busy_timeout = ${busyTimeout}`);
11629
+ if (walMode) {
11630
+ db.pragma("journal_mode = WAL");
11631
+ }
11632
+ return db;
11633
+ }
11634
+ var init_safe_db = __esm({
11635
+ "src/shared/safe-db.ts"() {
11636
+ "use strict";
11637
+ init_better_sqlite3();
11638
+ }
11639
+ });
11640
+
11601
11641
  // src/integrations/vibium/types.ts
11602
11642
  var init_types3 = __esm({
11603
11643
  "src/integrations/vibium/types.ts"() {
@@ -15066,7 +15106,7 @@ var logger9, V2ToV3Migrator;
15066
15106
  var init_v2_to_v3_migration = __esm({
15067
15107
  "src/learning/v2-to-v3-migration.ts"() {
15068
15108
  "use strict";
15069
- init_better_sqlite3();
15109
+ init_safe_db();
15070
15110
  init_error_utils();
15071
15111
  init_safe_json();
15072
15112
  init_logging();
@@ -15168,9 +15208,8 @@ var init_v2_to_v3_migration = __esm({
15168
15208
  }
15169
15209
  }
15170
15210
  async connect() {
15171
- this.v2Db = new better_sqlite3_default(this.config.v2DbPath, { readonly: true });
15172
- this.v3Db = new better_sqlite3_default(this.config.v3PatternsDbPath);
15173
- this.v3Db.pragma("journal_mode = WAL");
15211
+ this.v2Db = openDatabase(this.config.v2DbPath, { readonly: true });
15212
+ this.v3Db = openDatabase(this.config.v3PatternsDbPath);
15174
15213
  this.createV3Schema();
15175
15214
  }
15176
15215
  async disconnect() {
@@ -15560,7 +15599,7 @@ var DEFAULT_SQLITE_CONFIG, SQLitePatternStore;
15560
15599
  var init_sqlite_persistence = __esm({
15561
15600
  "src/learning/sqlite-persistence.ts"() {
15562
15601
  "use strict";
15563
- init_better_sqlite3();
15602
+ init_safe_db();
15564
15603
  init_esm_node();
15565
15604
  init_safe_json();
15566
15605
  init_error_utils();
@@ -15604,10 +15643,7 @@ var init_sqlite_persistence = __esm({
15604
15643
  if (!fs23.existsSync(dir)) {
15605
15644
  fs23.mkdirSync(dir, { recursive: true });
15606
15645
  }
15607
- this.db = new better_sqlite3_default(this.config.dbPath);
15608
- if (this.config.walMode) {
15609
- this.db.pragma("journal_mode = WAL");
15610
- }
15646
+ this.db = openDatabase(this.config.dbPath);
15611
15647
  this.db.pragma(`mmap_size = ${this.config.mmapSize}`);
15612
15648
  this.db.pragma(`cache_size = ${this.config.cacheSize}`);
15613
15649
  if (this.config.foreignKeys) {
@@ -16782,11 +16818,11 @@ __export(hnswlib_node_exports, {
16782
16818
  init: () => init6,
16783
16819
  pipeline: () => pipeline7
16784
16820
  });
16785
- import { createRequire as createRequire9 } from "module";
16821
+ import { createRequire as createRequire6 } from "module";
16786
16822
  var __require7, __mod6, hnswlib_node_default, RuvectorLayer6, TensorCompress6, differentiableSearch6, hierarchicalForward6, getCompressionLevel6, init6, FlashAttention6, DotProductAttention6, MultiHeadAttention6, HyperbolicAttention6, LinearAttention6, MoEAttention6, SonaEngine6, pipeline7;
16787
16823
  var init_hnswlib_node = __esm({
16788
16824
  "native-require:hnswlib-node"() {
16789
- __require7 = createRequire9(import.meta.url);
16825
+ __require7 = createRequire6(import.meta.url);
16790
16826
  __mod6 = __require7("hnswlib-node");
16791
16827
  hnswlib_node_default = __mod6;
16792
16828
  ({
@@ -16839,11 +16875,11 @@ __export(pg_exports, {
16839
16875
  init: () => init7,
16840
16876
  pipeline: () => pipeline8
16841
16877
  });
16842
- import { createRequire as createRequire10 } from "module";
16878
+ import { createRequire as createRequire7 } from "module";
16843
16879
  var __require8, __mod7, pg_default, RuvectorLayer7, TensorCompress7, differentiableSearch7, hierarchicalForward7, getCompressionLevel7, init7, FlashAttention7, DotProductAttention7, MultiHeadAttention7, HyperbolicAttention7, LinearAttention7, MoEAttention7, SonaEngine7, pipeline8;
16844
16880
  var init_pg = __esm({
16845
16881
  "native-require:pg"() {
16846
- __require8 = createRequire10(import.meta.url);
16882
+ __require8 = createRequire7(import.meta.url);
16847
16883
  __mod7 = __require8("pg");
16848
16884
  pg_default = __mod7;
16849
16885
  ({
@@ -18294,11 +18330,11 @@ __export(prime_radiant_advanced_wasm_exports, {
18294
18330
  init: () => init8,
18295
18331
  pipeline: () => pipeline9
18296
18332
  });
18297
- import { createRequire as createRequire11 } from "module";
18333
+ import { createRequire as createRequire8 } from "module";
18298
18334
  var __require9, __mod8, prime_radiant_advanced_wasm_default, RuvectorLayer8, TensorCompress8, differentiableSearch8, hierarchicalForward8, getCompressionLevel8, init8, FlashAttention8, DotProductAttention8, MultiHeadAttention8, HyperbolicAttention8, LinearAttention8, MoEAttention8, SonaEngine8, pipeline9;
18299
18335
  var init_prime_radiant_advanced_wasm = __esm({
18300
18336
  "native-require:prime-radiant-advanced-wasm"() {
18301
- __require9 = createRequire11(import.meta.url);
18337
+ __require9 = createRequire8(import.meta.url);
18302
18338
  __mod8 = __require9("prime-radiant-advanced-wasm");
18303
18339
  prime_radiant_advanced_wasm_default = __mod8;
18304
18340
  ({
@@ -31486,8 +31522,8 @@ var DEFAULT_GOVERNANCE_FLAGS = {
31486
31522
  },
31487
31523
  shardEmbeddings: {
31488
31524
  enabled: true,
31489
- embeddingDimensions: 128,
31490
- // 128-dimensional embeddings
31525
+ embeddingDimensions: 768,
31526
+ // 768-dimensional embeddings (aligned with HNSW indices)
31491
31527
  persistEmbeddings: false,
31492
31528
  // Don't persist by default
31493
31529
  autoRebuildOnChange: true,
@@ -31608,7 +31644,7 @@ function loadFlagsFromEnv() {
31608
31644
  },
31609
31645
  shardEmbeddings: {
31610
31646
  enabled: env.GOVERNANCE_SHARD_EMBEDDINGS !== "false",
31611
- embeddingDimensions: parseInt(env.GOVERNANCE_EMBEDDING_DIMENSIONS || "128", 10),
31647
+ embeddingDimensions: parseInt(env.GOVERNANCE_EMBEDDING_DIMENSIONS || "768", 10),
31612
31648
  persistEmbeddings: env.GOVERNANCE_PERSIST_EMBEDDINGS === "true",
31613
31649
  autoRebuildOnChange: env.GOVERNANCE_AUTO_REBUILD !== "false",
31614
31650
  ngramMin: parseInt(env.GOVERNANCE_NGRAM_MIN || "2", 10),
@@ -39107,7 +39143,7 @@ init_safe_json();
39107
39143
  init_unified_memory();
39108
39144
  var DEFAULT_SHARD_EMBEDDINGS_FLAGS = {
39109
39145
  enabled: true,
39110
- embeddingDimensions: 128,
39146
+ embeddingDimensions: 768,
39111
39147
  persistEmbeddings: false,
39112
39148
  autoRebuildOnChange: true,
39113
39149
  ngramMin: 2,
@@ -41786,7 +41822,7 @@ var BaseRLAlgorithm = class {
41786
41822
  init_vector_math();
41787
41823
  var DEFAULT_DT_CONFIG = {
41788
41824
  contextLength: 10,
41789
- embeddingDim: 128,
41825
+ embeddingDim: 768,
41790
41826
  numHeads: 4,
41791
41827
  numLayers: 3,
41792
41828
  feedForwardDim: 256,
@@ -42547,7 +42583,7 @@ var TestGenerationCoordinator = class extends BaseDomainCoordinator {
42547
42583
  try {
42548
42584
  this.decisionTransformer = new DecisionTransformerAlgorithm({
42549
42585
  contextLength: 10,
42550
- embeddingDim: 128
42586
+ embeddingDim: 768
42551
42587
  });
42552
42588
  console.log("[TestGenerationCoordinator] DecisionTransformer created for test case selection");
42553
42589
  } catch (error) {
@@ -46391,7 +46427,7 @@ var DEFAULT_CONFIG10 = {
46391
46427
  enableAutoTraining: true,
46392
46428
  trainingInterval: 10,
46393
46429
  contextLength: 10,
46394
- embeddingDim: 128
46430
+ embeddingDim: 768
46395
46431
  };
46396
46432
  var TestPrioritizerService = class {
46397
46433
  constructor(memory, config = {}) {
@@ -51734,7 +51770,7 @@ var DEFAULT_CONFIG11 = {
51734
51770
  };
51735
51771
  var CoverageAnalyzerService = class _CoverageAnalyzerService {
51736
51772
  static DEFAULT_THRESHOLD = 80;
51737
- static VECTOR_DIMENSION = 128;
51773
+ static VECTOR_DIMENSION = 768;
51738
51774
  memory;
51739
51775
  config;
51740
51776
  llmRouter;
@@ -52268,7 +52304,7 @@ var DEFAULT_CONFIG12 = {
52268
52304
  };
52269
52305
  var GapDetectorService = class _GapDetectorService {
52270
52306
  static DEFAULT_MIN_COVERAGE = 80;
52271
- static VECTOR_DIMENSION = 128;
52307
+ static VECTOR_DIMENSION = 768;
52272
52308
  memory;
52273
52309
  config;
52274
52310
  llmRouter;
@@ -53266,7 +53302,7 @@ init_hnsw_index();
53266
53302
 
53267
53303
  // src/domains/coverage-analysis/services/coverage-embedder.ts
53268
53304
  var DEFAULT_EMBEDDER_CONFIG = {
53269
- dimensions: 128,
53305
+ dimensions: 768,
53270
53306
  includePathFeatures: true,
53271
53307
  includeTemporalFeatures: true,
53272
53308
  normalization: "l2"
@@ -53698,7 +53734,7 @@ var ALL_CATEGORIES = [
53698
53734
  "missing-security-check"
53699
53735
  ];
53700
53736
  var DEFAULT_CONFIG13 = {
53701
- dimensions: 128,
53737
+ dimensions: 768,
53702
53738
  minConfidence: 0.3,
53703
53739
  maxGaps: 50,
53704
53740
  riskWeight: 0.6,
@@ -55407,7 +55443,7 @@ var CoverageAnalysisCoordinator = class extends BaseDomainCoordinator {
55407
55443
  return forecast;
55408
55444
  }
55409
55445
  createGapEmbedding(gap) {
55410
- const VECTOR_DIMENSION = 128;
55446
+ const VECTOR_DIMENSION = 768;
55411
55447
  const embedding = new Array(VECTOR_DIMENSION).fill(0);
55412
55448
  embedding[0] = gap.riskScore;
55413
55449
  embedding[1] = Math.min(1, gap.lines.length / 100);
@@ -73262,7 +73298,7 @@ var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
73262
73298
  */
73263
73299
  async initializeHypergraph() {
73264
73300
  try {
73265
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
73301
+ const { openDatabase: openDatabase2 } = await Promise.resolve().then(() => (init_safe_db(), safe_db_exports));
73266
73302
  const fs23 = await import("fs");
73267
73303
  const path26 = await import("path");
73268
73304
  const { findProjectRoot: findProjectRoot2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
@@ -73272,7 +73308,7 @@ var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
73272
73308
  if (!fs23.existsSync(dir)) {
73273
73309
  fs23.mkdirSync(dir, { recursive: true });
73274
73310
  }
73275
- this.hypergraphDb = new Database(dbPath);
73311
+ this.hypergraphDb = openDatabase2(dbPath);
73276
73312
  this.hypergraph = await createHypergraphEngine({
73277
73313
  db: this.hypergraphDb,
73278
73314
  maxTraversalDepth: 10,
@@ -74884,6 +74920,18 @@ var SECRET_PATTERNS = [
74884
74920
  owaspId: "A02:2021",
74885
74921
  cweId: "CWE-798",
74886
74922
  remediation: "Use environment variables for Slack tokens"
74923
+ },
74924
+ {
74925
+ id: "secret-generic-assignment",
74926
+ pattern: /\b\w*(?:SECRET|secret)(?:_KEY|_key|Key)?\s*[:=]\s*['"`][^'"`]{4,}['"`]/g,
74927
+ category: "sensitive-data",
74928
+ severity: "high",
74929
+ title: "Generic Secret Assignment Detected",
74930
+ description: "Hardcoded secret assignment (SECRET_KEY, JWT_SECRET, APP_SECRET, etc.) found in source code",
74931
+ owaspId: "A02:2021",
74932
+ cweId: "CWE-798",
74933
+ remediation: "Use environment variables or a secrets manager instead of hardcoding secrets",
74934
+ fixExample: "const secretKey = process.env.SECRET_KEY"
74887
74935
  }
74888
74936
  ];
74889
74937
  var PATH_TRAVERSAL_PATTERNS2 = [
@@ -115401,7 +115449,7 @@ var ALL_DOMAINS2 = [
115401
115449
  "enterprise-integration"
115402
115450
  ];
115403
115451
  function getAQEVersion() {
115404
- return true ? "3.6.11" : "3.0.0";
115452
+ return true ? "3.6.13" : "3.0.0";
115405
115453
  }
115406
115454
  function createDefaultConfig(projectName, projectRoot) {
115407
115455
  return {
@@ -116307,14 +116355,12 @@ function createSelfConfigurator(options) {
116307
116355
  // src/init/init-wizard-migration.ts
116308
116356
  import { existsSync as existsSync15, mkdirSync as mkdirSync5, writeFileSync as writeFileSync2, readFileSync as readFileSync12, readdirSync as readdirSync5, statSync as statSync5, unlinkSync as unlinkSync2, copyFileSync as copyFileSync2 } from "fs";
116309
116357
  import { join as join17, dirname as dirname4 } from "path";
116310
- import { createRequire as createRequire6 } from "module";
116311
116358
  init_error_utils();
116312
116359
  init_safe_json();
116313
- var require2 = createRequire6(import.meta.url);
116360
+ init_safe_db();
116314
116361
  function readVersionFromDb(dbPath) {
116315
116362
  try {
116316
- const Database = require2("better-sqlite3");
116317
- const db = new Database(dbPath, { readonly: true, fileMustExist: true });
116363
+ const db = openDatabase(dbPath, { readonly: true, fileMustExist: true });
116318
116364
  try {
116319
116365
  const tableExists = db.prepare(`
116320
116366
  SELECT name FROM sqlite_master
@@ -116348,8 +116394,7 @@ async function writeVersionToDb(projectRoot, version) {
116348
116394
  if (!existsSync15(dir)) {
116349
116395
  mkdirSync5(dir, { recursive: true });
116350
116396
  }
116351
- const Database = require2("better-sqlite3");
116352
- const db = new Database(memoryDbPath);
116397
+ const db = openDatabase(memoryDbPath);
116353
116398
  try {
116354
116399
  db.exec(`
116355
116400
  CREATE TABLE IF NOT EXISTS kv_store (
@@ -118477,6 +118522,7 @@ function createN8nInstaller(options) {
118477
118522
 
118478
118523
  // src/init/init-wizard-steps.ts
118479
118524
  init_error_utils();
118525
+ init_safe_db();
118480
118526
  async function initializePersistenceDatabase(projectRoot) {
118481
118527
  let Database = null;
118482
118528
  try {
@@ -118536,8 +118582,7 @@ async function checkCodeIntelligenceIndex(projectRoot) {
118536
118582
  return false;
118537
118583
  }
118538
118584
  try {
118539
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
118540
- const db = new Database(dbPath);
118585
+ const db = openDatabase(dbPath);
118541
118586
  const result = db.prepare(`
118542
118587
  SELECT COUNT(*) as count FROM kv_store
118543
118588
  WHERE namespace = 'code-intelligence:kg'
@@ -118590,8 +118635,7 @@ async function runCodeIntelligenceScan(projectPath) {
118590
118635
  async function getKGEntryCount(projectRoot) {
118591
118636
  const dbPath = join22(projectRoot, ".agentic-qe", "memory.db");
118592
118637
  try {
118593
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
118594
- const db = new Database(dbPath);
118638
+ const db = openDatabase(dbPath);
118595
118639
  const result = db.prepare(`
118596
118640
  SELECT COUNT(*) as count FROM kv_store
118597
118641
  WHERE namespace LIKE 'code-intelligence:kg%'
@@ -119266,10 +119310,9 @@ var BasePhase = class {
119266
119310
 
119267
119311
  // src/init/phases/01-detection.ts
119268
119312
  init_safe_json();
119313
+ init_safe_db();
119269
119314
  import { existsSync as existsSync21 } from "fs";
119270
119315
  import { join as join23 } from "path";
119271
- import { createRequire as createRequire7 } from "module";
119272
- var require3 = createRequire7(import.meta.url);
119273
119316
  var DetectionPhase = class extends BasePhase {
119274
119317
  name = "detection";
119275
119318
  description = "Detect existing installations";
@@ -119358,8 +119401,7 @@ var DetectionPhase = class extends BasePhase {
119358
119401
  */
119359
119402
  readVersionFromDb(dbPath) {
119360
119403
  try {
119361
- const Database = require3("better-sqlite3");
119362
- const db = new Database(dbPath, { readonly: true, fileMustExist: true });
119404
+ const db = openDatabase(dbPath, { readonly: true, fileMustExist: true });
119363
119405
  try {
119364
119406
  const tableExists = db.prepare(`
119365
119407
  SELECT name FROM sqlite_master
@@ -119629,6 +119671,7 @@ var LearningPhase = class extends BasePhase {
119629
119671
 
119630
119672
  // src/init/phases/06-code-intelligence.ts
119631
119673
  init_safe_json();
119674
+ init_safe_db();
119632
119675
  import { existsSync as existsSync24, statSync as statSync8 } from "fs";
119633
119676
  import { join as join26 } from "path";
119634
119677
  var SCAN_IGNORE_PATTERNS = [
@@ -119698,8 +119741,7 @@ var CodeIntelligencePhase = class extends BasePhase {
119698
119741
  return false;
119699
119742
  }
119700
119743
  try {
119701
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
119702
- const db = new Database(dbPath);
119744
+ const db = openDatabase(dbPath);
119703
119745
  const result = db.prepare(`
119704
119746
  SELECT COUNT(*) as count FROM kv_store
119705
119747
  WHERE namespace = 'code-intelligence:kg'
@@ -119716,8 +119758,7 @@ var CodeIntelligencePhase = class extends BasePhase {
119716
119758
  async getKGEntryCount(projectRoot) {
119717
119759
  const dbPath = join26(projectRoot, ".agentic-qe", "memory.db");
119718
119760
  try {
119719
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
119720
- const db = new Database(dbPath);
119761
+ const db = openDatabase(dbPath);
119721
119762
  const result = db.prepare(`
119722
119763
  SELECT COUNT(*) as count FROM kv_store
119723
119764
  WHERE namespace LIKE 'code-intelligence:kg%'
@@ -119796,8 +119837,7 @@ var CodeIntelligencePhase = class extends BasePhase {
119796
119837
  async getLastIndexedAt(projectRoot) {
119797
119838
  const dbPath = join26(projectRoot, ".agentic-qe", "memory.db");
119798
119839
  try {
119799
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
119800
- const db = new Database(dbPath);
119840
+ const db = openDatabase(dbPath);
119801
119841
  const row = db.prepare(`
119802
119842
  SELECT value FROM kv_store
119803
119843
  WHERE namespace = 'code-intelligence:kg'
@@ -119872,6 +119912,10 @@ var HooksPhase = class extends BasePhase {
119872
119912
  if (!existsSync25(claudeDir)) {
119873
119913
  mkdirSync13(claudeDir, { recursive: true });
119874
119914
  }
119915
+ const hooksDir = join27(claudeDir, "hooks");
119916
+ if (!existsSync25(hooksDir)) {
119917
+ mkdirSync13(hooksDir, { recursive: true });
119918
+ }
119875
119919
  const settingsPath = join27(claudeDir, "settings.json");
119876
119920
  let settings = {};
119877
119921
  if (existsSync25(settingsPath)) {
@@ -119906,7 +119950,20 @@ var HooksPhase = class extends BasePhase {
119906
119950
  }
119907
119951
  settings.enabledMcpjsonServers = existingMcp;
119908
119952
  writeFileSync9(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
119953
+ this.writeHooksReadme(hooksDir, hookTypes);
119954
+ this.installHookAssets(hooksDir, context2);
119955
+ try {
119956
+ const verifyContent = readFileSync17(settingsPath, "utf-8");
119957
+ const verifySettings = safeJsonParse(verifyContent);
119958
+ const verifyHooks = verifySettings.hooks;
119959
+ if (!verifyHooks || !this.hasExistingAqeHooks(verifyHooks)) {
119960
+ context2.services.log(" WARNING: settings.json written but AQE hooks not detected \u2014 check settings-merge logic");
119961
+ }
119962
+ } catch {
119963
+ context2.services.log(" WARNING: Could not verify settings.json after write");
119964
+ }
119909
119965
  context2.services.log(` Settings: ${settingsPath}`);
119966
+ context2.services.log(` Hooks dir: ${hooksDir}`);
119910
119967
  context2.services.log(` Hook types: ${hookTypes.join(", ")}`);
119911
119968
  return {
119912
119969
  configured: true,
@@ -119915,6 +119972,83 @@ var HooksPhase = class extends BasePhase {
119915
119972
  existingAqeDetected
119916
119973
  };
119917
119974
  }
119975
+ /**
119976
+ * Write a README to .claude/hooks/ explaining the hook setup.
119977
+ * Actual hook config lives in .claude/settings.json (Claude Code reads it from there).
119978
+ * The hooks dir contains supporting infrastructure (bridge script, workers config).
119979
+ */
119980
+ writeHooksReadme(hooksDir, hookTypes) {
119981
+ const readmePath = join27(hooksDir, "README.txt");
119982
+ if (existsSync25(readmePath)) return;
119983
+ const content = [
119984
+ "AQE Hooks Directory",
119985
+ "====================",
119986
+ "",
119987
+ "Claude Code hooks are configured in .claude/settings.json (not as files here).",
119988
+ "This directory contains supporting infrastructure for the learning system.",
119989
+ "",
119990
+ "Configured hook types: " + hookTypes.join(", "),
119991
+ "",
119992
+ "Files:",
119993
+ " settings.json \u2014 Hook definitions (in parent .claude/ directory)",
119994
+ " v3-qe-bridge.sh \u2014 Bridge script connecting Claude Code events to QE learning",
119995
+ " v3-domain-workers.json \u2014 Domain worker configuration",
119996
+ " cross-phase-memory.yaml \u2014 QCSD feedback loop configuration",
119997
+ "",
119998
+ "Manual testing:",
119999
+ " npx agentic-qe hooks session-start --session-id test --json",
120000
+ ' npx agentic-qe hooks route --task "generate tests" --json',
120001
+ " npx agentic-qe hooks post-edit --file src/example.ts --success --json",
120002
+ ""
120003
+ ].join("\n");
120004
+ writeFileSync9(readmePath, content, "utf-8");
120005
+ }
120006
+ /**
120007
+ * Install hook assets (cross-phase memory config, domain workers).
120008
+ * Copies from v3/assets/hooks/ if available, otherwise creates minimal defaults.
120009
+ */
120010
+ installHookAssets(hooksDir, context2) {
120011
+ const { projectRoot } = context2;
120012
+ const crossPhasePath = join27(hooksDir, "cross-phase-memory.yaml");
120013
+ if (!existsSync25(crossPhasePath)) {
120014
+ const assetPaths = [
120015
+ join27(projectRoot, "v3", "assets", "hooks", "cross-phase-memory.yaml"),
120016
+ join27(projectRoot, "assets", "hooks", "cross-phase-memory.yaml"),
120017
+ join27(projectRoot, "node_modules", "agentic-qe", "v3", "assets", "hooks", "cross-phase-memory.yaml")
120018
+ ];
120019
+ let installed = false;
120020
+ for (const src of assetPaths) {
120021
+ if (existsSync25(src)) {
120022
+ const { copyFileSync: copyFileSync9 } = __require("fs");
120023
+ copyFileSync9(src, crossPhasePath);
120024
+ context2.services.log(" Installed cross-phase memory config");
120025
+ installed = true;
120026
+ break;
120027
+ }
120028
+ }
120029
+ if (!installed) {
120030
+ writeFileSync9(crossPhasePath, [
120031
+ "# Cross-Phase Memory Hooks Configuration",
120032
+ "# Generated by aqe init",
120033
+ 'version: "1.0"',
120034
+ "enabled: true",
120035
+ ""
120036
+ ].join("\n"), "utf-8");
120037
+ }
120038
+ }
120039
+ const workersPath = join27(hooksDir, "v3-domain-workers.json");
120040
+ if (!existsSync25(workersPath)) {
120041
+ writeFileSync9(workersPath, JSON.stringify({
120042
+ version: "3.0",
120043
+ workers: [
120044
+ { name: "pattern-consolidator", interval: "5m", enabled: true },
120045
+ { name: "routing-accuracy-monitor", interval: "10m", enabled: true },
120046
+ { name: "coverage-gap-scanner", interval: "15m", enabled: true },
120047
+ { name: "flaky-test-detector", interval: "30m", enabled: true }
120048
+ ]
120049
+ }, null, 2), "utf-8");
120050
+ }
120051
+ }
119918
120052
  /**
119919
120053
  * Check if existing hooks contain any AQE/agentic-qe entries
119920
120054
  */
@@ -120770,8 +120904,7 @@ Task({ prompt: "Security audit", subagent_type: "qe-security-scanner", run_in_ba
120770
120904
  import { existsSync as existsSync30, readFileSync as readFileSync22 } from "fs";
120771
120905
  import { join as join32, dirname as dirname9 } from "path";
120772
120906
  import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync13 } from "fs";
120773
- import { createRequire as createRequire8 } from "module";
120774
- var require4 = createRequire8(import.meta.url);
120907
+ init_safe_db();
120775
120908
  var VerificationPhase = class extends BasePhase {
120776
120909
  name = "verification";
120777
120910
  description = "Verify installation";
@@ -120828,8 +120961,7 @@ var VerificationPhase = class extends BasePhase {
120828
120961
  if (!existsSync30(dir)) {
120829
120962
  mkdirSync16(dir, { recursive: true });
120830
120963
  }
120831
- const Database = require4("better-sqlite3");
120832
- const db = new Database(memoryDbPath);
120964
+ const db = openDatabase(memoryDbPath);
120833
120965
  try {
120834
120966
  db.exec(`
120835
120967
  CREATE TABLE IF NOT EXISTS kv_store (
@@ -125002,7 +125134,7 @@ function createMigrateCommand(context2, cleanupAndExit2, ensureInitialized2) {
125002
125134
  migratedFrom: "v2",
125003
125135
  migratedAt: (/* @__PURE__ */ new Date()).toISOString(),
125004
125136
  hnswEnabled: true,
125005
- vectorDimensions: 128
125137
+ vectorDimensions: 768
125006
125138
  }, null, 2));
125007
125139
  const stats = fs23.statSync(v2Files.memoryDb);
125008
125140
  console.log(chalk17.green(` * Memory database migrated (${(stats.size / 1024).toFixed(1)} KB)
@@ -125031,7 +125163,7 @@ function createMigrateCommand(context2, cleanupAndExit2, ensureInitialized2) {
125031
125163
  domains: {
125032
125164
  "test-generation": { enabled: true },
125033
125165
  "test-execution": { enabled: true },
125034
- "coverage-analysis": { enabled: true, algorithm: "hnsw", dimensions: 128 },
125166
+ "coverage-analysis": { enabled: true, algorithm: "hnsw", dimensions: 768 },
125035
125167
  "quality-assessment": { enabled: true },
125036
125168
  "defect-intelligence": { enabled: true },
125037
125169
  "requirements-validation": { enabled: true },
@@ -126972,6 +127104,7 @@ import chalk20 from "chalk";
126972
127104
 
126973
127105
  // src/init/fleet-integration.ts
126974
127106
  init_error_utils();
127107
+ init_safe_db();
126975
127108
  import chalk19 from "chalk";
126976
127109
  import { existsSync as existsSync38 } from "fs";
126977
127110
  import { join as join40 } from "path";
@@ -127126,8 +127259,7 @@ var FleetInitEnhancer = class {
127126
127259
  return false;
127127
127260
  }
127128
127261
  try {
127129
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
127130
- const db = new Database(dbPath);
127262
+ const db = openDatabase(dbPath);
127131
127263
  const result = db.prepare(`
127132
127264
  SELECT COUNT(*) as count FROM kv_store
127133
127265
  WHERE namespace = 'code-intelligence:kg'
@@ -127144,8 +127276,7 @@ var FleetInitEnhancer = class {
127144
127276
  async getKGEntryCount() {
127145
127277
  const dbPath = join40(this.projectRoot, ".agentic-qe", "memory.db");
127146
127278
  try {
127147
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
127148
- const db = new Database(dbPath);
127279
+ const db = openDatabase(dbPath);
127149
127280
  const result = db.prepare(`
127150
127281
  SELECT COUNT(*) as count FROM kv_store
127151
127282
  WHERE namespace LIKE 'code-intelligence:kg%'
@@ -132580,7 +132711,7 @@ var DEFAULT_SYNC_CONFIG = {
132580
132711
  };
132581
132712
 
132582
132713
  // src/sync/readers/sqlite-reader.ts
132583
- init_better_sqlite3();
132714
+ init_safe_db();
132584
132715
  init_sql_safety();
132585
132716
  init_safe_json();
132586
132717
  init_error_utils();
@@ -132608,7 +132739,7 @@ var SQLiteReader = class {
132608
132739
  throw new Error(`SQLite database not found: ${this.dbPath}`);
132609
132740
  }
132610
132741
  try {
132611
- this.db = new better_sqlite3_default(this.dbPath, { readonly: true });
132742
+ this.db = openDatabase(this.dbPath, { readonly: true });
132612
132743
  this.db.pragma("journal_mode = WAL");
132613
132744
  this.db.pragma("synchronous = NORMAL");
132614
132745
  console.log(`[SQLiteReader:${this.name}] Initialized: ${this.dbPath}`);
@@ -133974,7 +134105,7 @@ async function syncIncrementalToCloud(since, config) {
133974
134105
  }
133975
134106
 
133976
134107
  // src/integrations/embeddings/cache/EmbeddingCache.ts
133977
- init_better_sqlite3();
134108
+ init_safe_db();
133978
134109
  init_unified_memory();
133979
134110
  init_safe_json();
133980
134111
 
@@ -133983,7 +134114,7 @@ init_transformers();
133983
134114
  init_vector_math();
133984
134115
 
133985
134116
  // src/sync/embeddings/sync-embedding-generator.ts
133986
- init_better_sqlite3();
134117
+ init_safe_db();
133987
134118
  init_sql_safety();
133988
134119
  init_error_utils();
133989
134120
  init_safe_json();
@@ -136938,7 +137069,7 @@ async function createCoherenceService(wasmLoader2, config, logger19) {
136938
137069
 
136939
137070
  // src/integrations/coherence/wasm-loader.ts
136940
137071
  init_error_utils();
136941
- import { createRequire as createRequire12 } from "node:module";
137072
+ import { createRequire as createRequire9 } from "node:module";
136942
137073
  import { fileURLToPath as fileURLToPath6 } from "node:url";
136943
137074
  import { dirname as dirname13, join as join44 } from "node:path";
136944
137075
  import { readFileSync as readFileSync32, existsSync as existsSync44 } from "node:fs";
@@ -137194,11 +137325,11 @@ var WasmLoader = class {
137194
137325
  return false;
137195
137326
  }
137196
137327
  try {
137197
- const require5 = createRequire12(import.meta.url);
137328
+ const require2 = createRequire9(import.meta.url);
137198
137329
  const wasmPaths = [
137199
137330
  (() => {
137200
137331
  try {
137201
- const modulePath = require5.resolve("prime-radiant-advanced-wasm");
137332
+ const modulePath = require2.resolve("prime-radiant-advanced-wasm");
137202
137333
  return join44(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
137203
137334
  } catch {
137204
137335
  return null;
@@ -137400,18 +137531,18 @@ var WasmLoader = class {
137400
137531
  * - Browser: Uses default() async init with fetch
137401
137532
  */
137402
137533
  async attemptLoad() {
137403
- let require5;
137534
+ let require2;
137404
137535
  try {
137405
- require5 = createRequire12(import.meta.url);
137536
+ require2 = createRequire9(import.meta.url);
137406
137537
  } catch {
137407
- require5 = globalThis.require || (await import("module")).createRequire(__filename);
137538
+ require2 = globalThis.require || (await import("module")).createRequire(__filename);
137408
137539
  }
137409
137540
  let wasmModule;
137410
137541
  try {
137411
137542
  wasmModule = await Promise.resolve().then(() => (init_prime_radiant_advanced_wasm(), prime_radiant_advanced_wasm_exports));
137412
137543
  } catch (importError) {
137413
137544
  try {
137414
- wasmModule = require5("prime-radiant-advanced-wasm");
137545
+ wasmModule = require2("prime-radiant-advanced-wasm");
137415
137546
  } catch (requireError) {
137416
137547
  throw new Error(
137417
137548
  `Failed to import prime-radiant-advanced-wasm: ${toErrorMessage(importError)}`
@@ -137420,7 +137551,7 @@ var WasmLoader = class {
137420
137551
  }
137421
137552
  const isNodeJs = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
137422
137553
  if (isNodeJs) {
137423
- await this.initializeForNodeJs(wasmModule, require5);
137554
+ await this.initializeForNodeJs(wasmModule, require2);
137424
137555
  } else {
137425
137556
  if (wasmModule.default && typeof wasmModule.default === "function") {
137426
137557
  await wasmModule.default();
@@ -137452,12 +137583,12 @@ var WasmLoader = class {
137452
137583
  * In Node.js, the default async init uses fetch() which isn't available.
137453
137584
  * Instead, we read the WASM binary from disk and use initSync().
137454
137585
  */
137455
- async initializeForNodeJs(wasmModule, require5) {
137586
+ async initializeForNodeJs(wasmModule, require2) {
137456
137587
  const wasmPaths = [
137457
137588
  // Resolve from require - most reliable
137458
137589
  (() => {
137459
137590
  try {
137460
- const modulePath = require5.resolve("prime-radiant-advanced-wasm");
137591
+ const modulePath = require2.resolve("prime-radiant-advanced-wasm");
137461
137592
  return join44(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
137462
137593
  } catch {
137463
137594
  return null;
@@ -138684,7 +138815,7 @@ import { existsSync as existsSync46, writeFileSync as writeFileSync22, readFileS
138684
138815
  import { stat as stat3, unlink } from "node:fs/promises";
138685
138816
 
138686
138817
  // src/learning/metrics-tracker.ts
138687
- init_better_sqlite3();
138818
+ init_safe_db();
138688
138819
  init_qe_patterns();
138689
138820
  init_safe_json();
138690
138821
  init_logging();
@@ -138706,7 +138837,7 @@ var LearningMetricsTracker = class {
138706
138837
  if (!existsSync45(this.dbPath)) {
138707
138838
  throw new Error(`Database not found: ${this.dbPath}. Run "aqe init --auto" first.`);
138708
138839
  }
138709
- this.db = new better_sqlite3_default(this.dbPath, { readonly: false });
138840
+ this.db = openDatabase(this.dbPath);
138710
138841
  this.ensureMetricsTable();
138711
138842
  this.initialized = true;
138712
138843
  }
@@ -139054,9 +139185,13 @@ function createLearningMetricsTracker(projectRoot) {
139054
139185
  return new LearningMetricsTracker(projectRoot);
139055
139186
  }
139056
139187
 
139188
+ // src/cli/commands/learning.ts
139189
+ init_safe_db();
139190
+
139057
139191
  // src/cli/commands/learning-helpers.ts
139058
139192
  init_unified_memory();
139059
139193
  init_qe_reasoning_bank();
139194
+ init_safe_db();
139060
139195
  import chalk28 from "chalk";
139061
139196
  import path24 from "node:path";
139062
139197
  import { createReadStream, createWriteStream } from "node:fs";
@@ -139205,8 +139340,7 @@ async function decompressFile(gzPath, outputPath) {
139205
139340
  }
139206
139341
  async function verifyDatabaseIntegrity(dbPath) {
139207
139342
  try {
139208
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
139209
- const db = new Database(dbPath, { readonly: true });
139343
+ const db = openDatabase(dbPath, { readonly: true });
139210
139344
  const result = db.prepare("PRAGMA integrity_check").get();
139211
139345
  db.close();
139212
139346
  if (result.integrity_check === "ok") {
@@ -139223,8 +139357,7 @@ async function verifyDatabaseIntegrity(dbPath) {
139223
139357
  }
139224
139358
  async function getSchemaVersion(dbPath) {
139225
139359
  try {
139226
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
139227
- const db = new Database(dbPath, { readonly: true });
139360
+ const db = openDatabase(dbPath, { readonly: true });
139228
139361
  const tableExists = db.prepare(
139229
139362
  "SELECT name FROM sqlite_master WHERE type='table' AND name='schema_version'"
139230
139363
  ).get();
@@ -139583,8 +139716,7 @@ function registerExtractCommand(learning) {
139583
139716
  console.log(` Min reward threshold: ${minReward}`);
139584
139717
  console.log(` Min occurrences: ${minCount}
139585
139718
  `);
139586
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
139587
- const db = new Database(dbPath, { readonly: true });
139719
+ const db = openDatabase(dbPath, { readonly: true });
139588
139720
  const experiences = db.prepare(`
139589
139721
  SELECT task_type, COUNT(*) as count, AVG(reward) as avg_reward, MAX(reward) as max_reward,
139590
139722
  MIN(reward) as min_reward, GROUP_CONCAT(DISTINCT action) as actions
@@ -139840,8 +139972,7 @@ function registerVerifyCommand(learning) {
139840
139972
  const fileStats = await stat3(dbPath);
139841
139973
  let tableCounts = {};
139842
139974
  try {
139843
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
139844
- const db = new Database(dbPath, { readonly: true });
139975
+ const db = openDatabase(dbPath, { readonly: true });
139845
139976
  for (const table of ["qe_patterns", "qe_trajectories", "learning_experiences", "kv_store", "vectors"]) {
139846
139977
  try {
139847
139978
  const r54 = db.prepare(`SELECT COUNT(*) as count FROM ${table}`).get();
@@ -139908,8 +140039,7 @@ function registerExportFullCommand(learning) {
139908
140039
  };
139909
140040
  if (options.includeTrajectories) {
139910
140041
  try {
139911
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
139912
- const db = new Database(dbPath, { readonly: true });
140042
+ const db = openDatabase(dbPath, { readonly: true });
139913
140043
  const trajectories = db.prepare(`SELECT id, task, agent, domain, success, steps_json FROM qe_trajectories ORDER BY started_at DESC LIMIT 1000`).all();
139914
140044
  exportData.trajectories = trajectories.map((t50) => ({ id: t50.id, task: t50.task, agent: t50.agent, domain: t50.domain, success: t50.success, stepsJson: t50.steps_json }));
139915
140045
  db.close();
@@ -139918,8 +140048,7 @@ function registerExportFullCommand(learning) {
139918
140048
  }
139919
140049
  if (options.includeExperiences) {
139920
140050
  try {
139921
- const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
139922
- const db = new Database(dbPath, { readonly: true });
140051
+ const db = openDatabase(dbPath, { readonly: true });
139923
140052
  const experiences = db.prepare(`SELECT task_type, action, AVG(reward) as avg_reward, COUNT(*) as count FROM learning_experiences GROUP BY task_type, action ORDER BY count DESC LIMIT 500`).all();
139924
140053
  exportData.experiences = experiences.map((e20) => ({ taskType: e20.task_type, action: e20.action, reward: e20.avg_reward, count: e20.count }));
139925
140054
  const metaRow = db.prepare(`SELECT COUNT(*) as total, AVG(reward) as avg_reward FROM learning_experiences`).get();
@@ -140415,7 +140544,7 @@ async function cleanupAndExit(code = 0) {
140415
140544
  process.exit(code);
140416
140545
  }
140417
140546
  var program = new Command18();
140418
- var VERSION = true ? "3.6.11" : "0.0.0-dev";
140547
+ var VERSION = true ? "3.6.13" : "0.0.0-dev";
140419
140548
  program.name("aqe").description("Agentic QE - Domain-Driven Quality Engineering").version(VERSION);
140420
140549
  var registry = createCommandRegistry(context, cleanupAndExit, ensureInitialized);
140421
140550
  registry.registerAll(program);