agentic-qe 3.6.9 → 3.6.10

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 (55) hide show
  1. package/.claude/skills/.validation/schemas/skill-eval.schema.json +11 -1
  2. package/.claude/skills/pr-review/SKILL.md +2 -2
  3. package/.claude/skills/qcsd-production-swarm/SKILL.md +2781 -0
  4. package/.claude/skills/qcsd-production-swarm/evals/qcsd-production-swarm.yaml +246 -0
  5. package/.claude/skills/qcsd-production-swarm/schemas/output.json +505 -0
  6. package/.claude/skills/qcsd-production-swarm/scripts/validate-config.json +25 -0
  7. package/.claude/skills/skills-manifest.json +5 -5
  8. package/package.json +1 -1
  9. package/scripts/benchmark-hnsw-loading.ts +480 -0
  10. package/scripts/benchmark-kg-assisted.ts +725 -0
  11. package/scripts/collect-production-telemetry.sh +291 -0
  12. package/scripts/detect-skill-conflicts.ts +347 -0
  13. package/scripts/eval-driven-workflow.ts +704 -0
  14. package/scripts/run-skill-eval.ts +210 -10
  15. package/scripts/score-skill-quality.ts +511 -0
  16. package/v3/CHANGELOG.md +19 -0
  17. package/v3/assets/skills/pr-review/SKILL.md +2 -2
  18. package/v3/dist/cli/bundle.js +1064 -363
  19. package/v3/dist/cli/commands/hooks.d.ts.map +1 -1
  20. package/v3/dist/cli/commands/hooks.js +143 -2
  21. package/v3/dist/cli/commands/hooks.js.map +1 -1
  22. package/v3/dist/cli/commands/test.d.ts.map +1 -1
  23. package/v3/dist/cli/commands/test.js +6 -0
  24. package/v3/dist/cli/commands/test.js.map +1 -1
  25. package/v3/dist/domains/test-generation/generators/jest-vitest-generator.d.ts.map +1 -1
  26. package/v3/dist/domains/test-generation/generators/jest-vitest-generator.js +58 -6
  27. package/v3/dist/domains/test-generation/generators/jest-vitest-generator.js.map +1 -1
  28. package/v3/dist/domains/test-generation/generators/mocha-generator.d.ts.map +1 -1
  29. package/v3/dist/domains/test-generation/generators/mocha-generator.js +79 -7
  30. package/v3/dist/domains/test-generation/generators/mocha-generator.js.map +1 -1
  31. package/v3/dist/domains/test-generation/generators/pytest-generator.d.ts +4 -0
  32. package/v3/dist/domains/test-generation/generators/pytest-generator.d.ts.map +1 -1
  33. package/v3/dist/domains/test-generation/generators/pytest-generator.js +77 -10
  34. package/v3/dist/domains/test-generation/generators/pytest-generator.js.map +1 -1
  35. package/v3/dist/domains/test-generation/interfaces/test-generator.interface.d.ts +21 -0
  36. package/v3/dist/domains/test-generation/interfaces/test-generator.interface.d.ts.map +1 -1
  37. package/v3/dist/domains/test-generation/interfaces.d.ts +21 -0
  38. package/v3/dist/domains/test-generation/interfaces.d.ts.map +1 -1
  39. package/v3/dist/domains/test-generation/services/test-generator.d.ts +22 -0
  40. package/v3/dist/domains/test-generation/services/test-generator.d.ts.map +1 -1
  41. package/v3/dist/domains/test-generation/services/test-generator.js +163 -3
  42. package/v3/dist/domains/test-generation/services/test-generator.js.map +1 -1
  43. package/v3/dist/kernel/unified-memory-hnsw.d.ts +29 -0
  44. package/v3/dist/kernel/unified-memory-hnsw.d.ts.map +1 -1
  45. package/v3/dist/kernel/unified-memory-hnsw.js +136 -0
  46. package/v3/dist/kernel/unified-memory-hnsw.js.map +1 -1
  47. package/v3/dist/kernel/unified-memory.d.ts +2 -2
  48. package/v3/dist/kernel/unified-memory.d.ts.map +1 -1
  49. package/v3/dist/kernel/unified-memory.js +7 -9
  50. package/v3/dist/kernel/unified-memory.js.map +1 -1
  51. package/v3/dist/learning/qe-hooks.d.ts.map +1 -1
  52. package/v3/dist/learning/qe-hooks.js +34 -3
  53. package/v3/dist/learning/qe-hooks.js.map +1 -1
  54. package/v3/dist/mcp/bundle.js +857 -329
  55. package/v3/package.json +1 -1
@@ -1144,13 +1144,90 @@ var init_sql_safety = __esm({
1144
1144
  }
1145
1145
  });
1146
1146
 
1147
+ // native-require:@ruvector/gnn
1148
+ var gnn_exports = {};
1149
+ __export(gnn_exports, {
1150
+ DotProductAttention: () => DotProductAttention2,
1151
+ FlashAttention: () => FlashAttention2,
1152
+ HyperbolicAttention: () => HyperbolicAttention2,
1153
+ LinearAttention: () => LinearAttention2,
1154
+ MoEAttention: () => MoEAttention2,
1155
+ MultiHeadAttention: () => MultiHeadAttention2,
1156
+ RuvectorLayer: () => RuvectorLayer2,
1157
+ SonaEngine: () => SonaEngine2,
1158
+ TensorCompress: () => TensorCompress2,
1159
+ default: () => gnn_default,
1160
+ differentiableSearch: () => differentiableSearch2,
1161
+ getCompressionLevel: () => getCompressionLevel2,
1162
+ hierarchicalForward: () => hierarchicalForward2,
1163
+ init: () => init2,
1164
+ pipeline: () => pipeline2
1165
+ });
1166
+ import { createRequire as createRequire2 } from "module";
1167
+ var __require3, __mod2, gnn_default, RuvectorLayer2, TensorCompress2, differentiableSearch2, hierarchicalForward2, getCompressionLevel2, init2, FlashAttention2, DotProductAttention2, MultiHeadAttention2, HyperbolicAttention2, LinearAttention2, MoEAttention2, SonaEngine2, pipeline2;
1168
+ var init_gnn = __esm({
1169
+ "native-require:@ruvector/gnn"() {
1170
+ __require3 = createRequire2(import.meta.url);
1171
+ __mod2 = __require3("@ruvector/gnn");
1172
+ gnn_default = __mod2;
1173
+ ({
1174
+ RuvectorLayer: (
1175
+ // @ruvector/gnn
1176
+ RuvectorLayer2
1177
+ ),
1178
+ TensorCompress: TensorCompress2,
1179
+ differentiableSearch: differentiableSearch2,
1180
+ hierarchicalForward: hierarchicalForward2,
1181
+ getCompressionLevel: getCompressionLevel2,
1182
+ init: init2,
1183
+ FlashAttention: (
1184
+ // @ruvector/attention
1185
+ FlashAttention2
1186
+ ),
1187
+ DotProductAttention: DotProductAttention2,
1188
+ MultiHeadAttention: MultiHeadAttention2,
1189
+ HyperbolicAttention: HyperbolicAttention2,
1190
+ LinearAttention: LinearAttention2,
1191
+ MoEAttention: MoEAttention2,
1192
+ SonaEngine: (
1193
+ // @ruvector/sona
1194
+ SonaEngine2
1195
+ ),
1196
+ pipeline: (
1197
+ // @xenova/transformers
1198
+ pipeline2
1199
+ )
1200
+ } = __mod2 || {});
1201
+ }
1202
+ });
1203
+
1147
1204
  // src/kernel/unified-memory-hnsw.ts
1148
- var BinaryHeap, InMemoryHNSWIndex;
1205
+ function computeNorm(v62) {
1206
+ let sum = 0;
1207
+ for (let i58 = 0; i58 < v62.length; i58++) sum += v62[i58] * v62[i58];
1208
+ return Math.sqrt(sum);
1209
+ }
1210
+ function fastCosine(a37, b68, normA, normB) {
1211
+ const denom = normA * normB;
1212
+ if (denom === 0) return 0;
1213
+ let dot = 0;
1214
+ for (let i58 = 0; i58 < a37.length; i58++) dot += a37[i58] * b68[i58];
1215
+ return dot / denom;
1216
+ }
1217
+ var ruvectorDifferentiableSearch, ruvectorInit, BinaryHeap, InMemoryHNSWIndex, RuvectorFlatIndex;
1149
1218
  var init_unified_memory_hnsw = __esm({
1150
1219
  "src/kernel/unified-memory-hnsw.ts"() {
1151
1220
  "use strict";
1152
1221
  init_vector_math();
1153
1222
  init_constants();
1223
+ ruvectorDifferentiableSearch = null;
1224
+ ruvectorInit = null;
1225
+ try {
1226
+ const gnn = (init_gnn(), __toCommonJS(gnn_exports));
1227
+ ruvectorDifferentiableSearch = gnn.differentiableSearch;
1228
+ ruvectorInit = gnn.init;
1229
+ } catch {
1230
+ }
1154
1231
  BinaryHeap = class {
1155
1232
  data = [];
1156
1233
  compareFn;
@@ -1483,6 +1560,94 @@ var init_unified_memory_hnsw = __esm({
1483
1560
  this.currentMaxLevel = -1;
1484
1561
  }
1485
1562
  };
1563
+ RuvectorFlatIndex = class {
1564
+ ids = [];
1565
+ vectors = [];
1566
+ /** Pre-computed L2 norms for each vector (enables dot-product-only cosine). */
1567
+ norms = [];
1568
+ idToIndex = /* @__PURE__ */ new Map();
1569
+ initialized = false;
1570
+ constructor() {
1571
+ if (ruvectorInit && !this.initialized) {
1572
+ try {
1573
+ ruvectorInit();
1574
+ this.initialized = true;
1575
+ } catch {
1576
+ this.initialized = ruvectorDifferentiableSearch !== null;
1577
+ }
1578
+ }
1579
+ }
1580
+ add(id, embedding) {
1581
+ const f322 = new Float32Array(embedding);
1582
+ const norm = computeNorm(f322);
1583
+ if (this.idToIndex.has(id)) {
1584
+ const idx2 = this.idToIndex.get(id);
1585
+ this.vectors[idx2] = f322;
1586
+ this.norms[idx2] = norm;
1587
+ return;
1588
+ }
1589
+ const idx = this.ids.length;
1590
+ this.ids.push(id);
1591
+ this.vectors.push(f322);
1592
+ this.norms.push(norm);
1593
+ this.idToIndex.set(id, idx);
1594
+ }
1595
+ search(query, k68) {
1596
+ if (this.ids.length === 0) return [];
1597
+ const actualK = Math.min(k68, this.ids.length);
1598
+ if (ruvectorDifferentiableSearch && this.vectors.length > 0) {
1599
+ const queryF322 = new Float32Array(query);
1600
+ const queryNorm2 = computeNorm(queryF322);
1601
+ const result = ruvectorDifferentiableSearch(
1602
+ queryF322,
1603
+ this.vectors,
1604
+ actualK,
1605
+ 1
1606
+ );
1607
+ return result.indices.map((idx) => ({
1608
+ id: this.ids[idx],
1609
+ score: fastCosine(queryF322, this.vectors[idx], queryNorm2, this.norms[idx])
1610
+ }));
1611
+ }
1612
+ const queryF32 = new Float32Array(query);
1613
+ const queryNorm = computeNorm(queryF32);
1614
+ const scored = [];
1615
+ 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
+ });
1620
+ }
1621
+ scored.sort((a37, b68) => b68.score - a37.score);
1622
+ return scored.slice(0, actualK);
1623
+ }
1624
+ remove(id) {
1625
+ const idx = this.idToIndex.get(id);
1626
+ if (idx === void 0) return false;
1627
+ const lastIdx = this.ids.length - 1;
1628
+ if (idx !== lastIdx) {
1629
+ const lastId = this.ids[lastIdx];
1630
+ this.ids[idx] = lastId;
1631
+ this.vectors[idx] = this.vectors[lastIdx];
1632
+ this.norms[idx] = this.norms[lastIdx];
1633
+ this.idToIndex.set(lastId, idx);
1634
+ }
1635
+ this.ids.pop();
1636
+ this.vectors.pop();
1637
+ this.norms.pop();
1638
+ this.idToIndex.delete(id);
1639
+ return true;
1640
+ }
1641
+ clear() {
1642
+ this.ids = [];
1643
+ this.vectors = [];
1644
+ this.norms = [];
1645
+ this.idToIndex.clear();
1646
+ }
1647
+ size() {
1648
+ return this.ids.length;
1649
+ }
1650
+ };
1486
1651
  }
1487
1652
  });
1488
1653
 
@@ -3037,6 +3202,7 @@ __export(unified_memory_exports, {
3037
3202
  BinaryHeap: () => BinaryHeap,
3038
3203
  DEFAULT_UNIFIED_MEMORY_CONFIG: () => DEFAULT_UNIFIED_MEMORY_CONFIG,
3039
3204
  InMemoryHNSWIndex: () => InMemoryHNSWIndex,
3205
+ RuvectorFlatIndex: () => RuvectorFlatIndex,
3040
3206
  UnifiedMemoryManager: () => UnifiedMemoryManager,
3041
3207
  clearProjectRootCache: () => clearProjectRootCache,
3042
3208
  findProjectRoot: () => findProjectRoot,
@@ -3167,7 +3333,7 @@ var init_unified_memory = __esm({
3167
3333
  vectorsLoaded = false;
3168
3334
  initPromise = null;
3169
3335
  preparedStatements = /* @__PURE__ */ new Map();
3170
- vectorIndex = new InMemoryHNSWIndex();
3336
+ vectorIndex = new RuvectorFlatIndex();
3171
3337
  // CRDT store for distributed state synchronization
3172
3338
  crdtStore = null;
3173
3339
  constructor(config) {
@@ -3335,7 +3501,7 @@ var init_unified_memory = __esm({
3335
3501
  this.vectorIndex.add(row.id, embedding);
3336
3502
  }
3337
3503
  this.vectorsLoaded = true;
3338
- console.log(`[UnifiedMemory] Loaded ${rows.length} vectors into HNSW index`);
3504
+ console.log(`[UnifiedMemory] Loaded ${rows.length} vectors into vector index (ruvector flat)`);
3339
3505
  }
3340
3506
  // ============================================================================
3341
3507
  // KV Store Operations (v2 compatible)
@@ -3639,9 +3805,8 @@ var init_unified_memory = __esm({
3639
3805
  return buffer;
3640
3806
  }
3641
3807
  bufferToFloatArray(buffer, dimensions) {
3642
- const arr = [];
3643
- for (let i58 = 0; i58 < dimensions; i58++) arr.push(buffer.readFloatLE(i58 * 4));
3644
- return arr;
3808
+ const f322 = new Float32Array(buffer.buffer, buffer.byteOffset, dimensions);
3809
+ return Array.from(f322);
3645
3810
  }
3646
3811
  };
3647
3812
  exitHandlersRegistered = false;
@@ -3652,57 +3817,57 @@ var init_unified_memory = __esm({
3652
3817
  // native-require:@xenova/transformers
3653
3818
  var transformers_exports = {};
3654
3819
  __export(transformers_exports, {
3655
- DotProductAttention: () => DotProductAttention2,
3656
- FlashAttention: () => FlashAttention2,
3657
- HyperbolicAttention: () => HyperbolicAttention2,
3658
- LinearAttention: () => LinearAttention2,
3659
- MoEAttention: () => MoEAttention2,
3660
- MultiHeadAttention: () => MultiHeadAttention2,
3661
- RuvectorLayer: () => RuvectorLayer2,
3662
- SonaEngine: () => SonaEngine2,
3663
- TensorCompress: () => TensorCompress2,
3820
+ DotProductAttention: () => DotProductAttention3,
3821
+ FlashAttention: () => FlashAttention3,
3822
+ HyperbolicAttention: () => HyperbolicAttention3,
3823
+ LinearAttention: () => LinearAttention3,
3824
+ MoEAttention: () => MoEAttention3,
3825
+ MultiHeadAttention: () => MultiHeadAttention3,
3826
+ RuvectorLayer: () => RuvectorLayer3,
3827
+ SonaEngine: () => SonaEngine3,
3828
+ TensorCompress: () => TensorCompress3,
3664
3829
  default: () => transformers_default,
3665
- differentiableSearch: () => differentiableSearch2,
3666
- getCompressionLevel: () => getCompressionLevel2,
3667
- hierarchicalForward: () => hierarchicalForward2,
3668
- init: () => init2,
3669
- pipeline: () => pipeline2
3830
+ differentiableSearch: () => differentiableSearch3,
3831
+ getCompressionLevel: () => getCompressionLevel3,
3832
+ hierarchicalForward: () => hierarchicalForward3,
3833
+ init: () => init3,
3834
+ pipeline: () => pipeline3
3670
3835
  });
3671
- import { createRequire as createRequire2 } from "module";
3672
- var __require3, __mod2, transformers_default, RuvectorLayer2, TensorCompress2, differentiableSearch2, hierarchicalForward2, getCompressionLevel2, init2, FlashAttention2, DotProductAttention2, MultiHeadAttention2, HyperbolicAttention2, LinearAttention2, MoEAttention2, SonaEngine2, pipeline2;
3836
+ import { createRequire as createRequire3 } from "module";
3837
+ var __require4, __mod3, transformers_default, RuvectorLayer3, TensorCompress3, differentiableSearch3, hierarchicalForward3, getCompressionLevel3, init3, FlashAttention3, DotProductAttention3, MultiHeadAttention3, HyperbolicAttention3, LinearAttention3, MoEAttention3, SonaEngine3, pipeline3;
3673
3838
  var init_transformers = __esm({
3674
3839
  "native-require:@xenova/transformers"() {
3675
- __require3 = createRequire2(import.meta.url);
3676
- __mod2 = __require3("@xenova/transformers");
3677
- transformers_default = __mod2;
3840
+ __require4 = createRequire3(import.meta.url);
3841
+ __mod3 = __require4("@xenova/transformers");
3842
+ transformers_default = __mod3;
3678
3843
  ({
3679
3844
  RuvectorLayer: (
3680
3845
  // @ruvector/gnn
3681
- RuvectorLayer2
3846
+ RuvectorLayer3
3682
3847
  ),
3683
- TensorCompress: TensorCompress2,
3684
- differentiableSearch: differentiableSearch2,
3685
- hierarchicalForward: hierarchicalForward2,
3686
- getCompressionLevel: getCompressionLevel2,
3687
- init: init2,
3848
+ TensorCompress: TensorCompress3,
3849
+ differentiableSearch: differentiableSearch3,
3850
+ hierarchicalForward: hierarchicalForward3,
3851
+ getCompressionLevel: getCompressionLevel3,
3852
+ init: init3,
3688
3853
  FlashAttention: (
3689
3854
  // @ruvector/attention
3690
- FlashAttention2
3855
+ FlashAttention3
3691
3856
  ),
3692
- DotProductAttention: DotProductAttention2,
3693
- MultiHeadAttention: MultiHeadAttention2,
3694
- HyperbolicAttention: HyperbolicAttention2,
3695
- LinearAttention: LinearAttention2,
3696
- MoEAttention: MoEAttention2,
3857
+ DotProductAttention: DotProductAttention3,
3858
+ MultiHeadAttention: MultiHeadAttention3,
3859
+ HyperbolicAttention: HyperbolicAttention3,
3860
+ LinearAttention: LinearAttention3,
3861
+ MoEAttention: MoEAttention3,
3697
3862
  SonaEngine: (
3698
3863
  // @ruvector/sona
3699
- SonaEngine2
3864
+ SonaEngine3
3700
3865
  ),
3701
3866
  pipeline: (
3702
3867
  // @xenova/transformers
3703
- pipeline2
3868
+ pipeline3
3704
3869
  )
3705
- } = __mod2 || {});
3870
+ } = __mod3 || {});
3706
3871
  }
3707
3872
  });
3708
3873
 
@@ -3730,10 +3895,10 @@ async function initializeModel(config = {}) {
3730
3895
  initPromise = (async () => {
3731
3896
  try {
3732
3897
  const transformers = await Promise.resolve().then(() => (init_transformers(), transformers_exports));
3733
- pipeline3 = transformers.pipeline;
3898
+ pipeline4 = transformers.pipeline;
3734
3899
  console.log(`[RealEmbeddings] Loading model: ${fullConfig.modelName}`);
3735
3900
  const startTime = performance.now();
3736
- embeddingModel = await pipeline3("feature-extraction", fullConfig.modelName, {
3901
+ embeddingModel = await pipeline4("feature-extraction", fullConfig.modelName, {
3737
3902
  quantized: fullConfig.quantized
3738
3903
  });
3739
3904
  const loadTime = performance.now() - startTime;
@@ -3851,20 +4016,20 @@ function getEmbeddingDimension() {
3851
4016
  return 384;
3852
4017
  }
3853
4018
  function resetInitialization() {
3854
- pipeline3 = null;
4019
+ pipeline4 = null;
3855
4020
  embeddingModel = null;
3856
4021
  initPromise = null;
3857
4022
  initializationFailed = false;
3858
4023
  failureReason = "";
3859
4024
  embeddingCache.clear();
3860
4025
  }
3861
- var pipeline3, embeddingModel, initPromise, initializationFailed, failureReason, DEFAULT_EMBEDDING_CONFIG, embeddingCache, CACHE_TTL_MS;
4026
+ var pipeline4, embeddingModel, initPromise, initializationFailed, failureReason, DEFAULT_EMBEDDING_CONFIG, embeddingCache, CACHE_TTL_MS;
3862
4027
  var init_real_embeddings = __esm({
3863
4028
  "src/learning/real-embeddings.ts"() {
3864
4029
  "use strict";
3865
4030
  init_vector_math();
3866
4031
  init_error_utils();
3867
- pipeline3 = null;
4032
+ pipeline4 = null;
3868
4033
  embeddingModel = null;
3869
4034
  initPromise = null;
3870
4035
  initializationFailed = false;
@@ -4688,6 +4853,120 @@ var init_embeddings = __esm({
4688
4853
  }
4689
4854
  });
4690
4855
 
4856
+ // src/learning/qe-patterns.ts
4857
+ function detectQEDomain(taskDescription) {
4858
+ for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
4859
+ if (pattern.test(taskDescription)) {
4860
+ return domain;
4861
+ }
4862
+ }
4863
+ return null;
4864
+ }
4865
+ function detectQEDomains(taskDescription) {
4866
+ const detected = [];
4867
+ for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
4868
+ if (pattern.test(taskDescription)) {
4869
+ detected.push(domain);
4870
+ }
4871
+ }
4872
+ return detected;
4873
+ }
4874
+ function mapQEDomainToAQE(qeDomain) {
4875
+ return qeDomain;
4876
+ }
4877
+ function calculateQualityScore(pattern) {
4878
+ const usageScore = Math.min(pattern.usageCount / 100, 1);
4879
+ return pattern.confidence * 0.3 + usageScore * 0.2 + pattern.successRate * 0.5;
4880
+ }
4881
+ function shouldPromotePattern(pattern, coherenceEnergy, coherenceThreshold = 0.4) {
4882
+ const meetsUsageCriteria = pattern.tier === "short-term" && pattern.successfulUses >= 3;
4883
+ const meetsQualityCriteria = pattern.successRate >= 0.7 && pattern.confidence >= 0.6;
4884
+ const meetsCoherenceCriteria = coherenceEnergy === void 0 || coherenceEnergy < coherenceThreshold;
4885
+ let blockReason;
4886
+ if (!meetsUsageCriteria) {
4887
+ blockReason = "insufficient_usage";
4888
+ } else if (!meetsQualityCriteria) {
4889
+ blockReason = "low_quality";
4890
+ } else if (!meetsCoherenceCriteria) {
4891
+ blockReason = "coherence_violation";
4892
+ }
4893
+ return {
4894
+ meetsUsageCriteria,
4895
+ meetsQualityCriteria,
4896
+ meetsCoherenceCriteria,
4897
+ blockReason
4898
+ };
4899
+ }
4900
+ function validateQEPattern(pattern) {
4901
+ const errors = [];
4902
+ if (!pattern.id) errors.push("Pattern ID is required");
4903
+ if (!pattern.patternType) errors.push("Pattern type is required");
4904
+ if (!pattern.qeDomain) errors.push("QE domain is required");
4905
+ if (!pattern.name) errors.push("Pattern name is required");
4906
+ if (!pattern.template?.content) errors.push("Template content is required");
4907
+ if (pattern.confidence !== void 0 && (pattern.confidence < 0 || pattern.confidence > 1)) {
4908
+ errors.push("Confidence must be between 0 and 1");
4909
+ }
4910
+ if (pattern.successRate !== void 0 && (pattern.successRate < 0 || pattern.successRate > 1)) {
4911
+ errors.push("Success rate must be between 0 and 1");
4912
+ }
4913
+ if (pattern.template?.variables) {
4914
+ const variableNames = /* @__PURE__ */ new Set();
4915
+ for (const variable of pattern.template.variables) {
4916
+ if (variableNames.has(variable.name)) {
4917
+ errors.push(`Duplicate variable name: ${variable.name}`);
4918
+ }
4919
+ variableNames.add(variable.name);
4920
+ if (!pattern.template.content.includes(`{{${variable.name}}}`)) {
4921
+ errors.push(
4922
+ `Variable ${variable.name} not referenced in template`
4923
+ );
4924
+ }
4925
+ }
4926
+ }
4927
+ return { valid: errors.length === 0, errors };
4928
+ }
4929
+ function applyPatternTemplate(template, variables) {
4930
+ let content = template.content;
4931
+ for (const variable of template.variables) {
4932
+ const value = variables[variable.name] ?? variable.defaultValue;
4933
+ if (variable.required && value === void 0) {
4934
+ throw new Error(`Required variable ${variable.name} not provided`);
4935
+ }
4936
+ if (value !== void 0) {
4937
+ const placeholder = `{{${variable.name}}}`;
4938
+ const stringValue = typeof value === "object" ? JSON.stringify(value) : String(value);
4939
+ content = content.split(placeholder).join(stringValue);
4940
+ }
4941
+ }
4942
+ return content;
4943
+ }
4944
+ var QE_DOMAINS, QE_DOMAIN_LIST;
4945
+ var init_qe_patterns = __esm({
4946
+ "src/learning/qe-patterns.ts"() {
4947
+ "use strict";
4948
+ QE_DOMAINS = {
4949
+ // Core Testing Domains
4950
+ "test-generation": /test|spec|describe|it\(|expect|assert|mock|stub|fixture|tdd|bdd/i,
4951
+ "test-execution": /run|execute|parallel|retry|flaky|timeout|worker|orchestrat/i,
4952
+ "coverage-analysis": /coverage|branch|line|uncovered|gap|untested|percentage|sublinear/i,
4953
+ // Quality Domains
4954
+ "quality-assessment": /quality|gate|deploy|readiness|metric|threshold|sla|score/i,
4955
+ "defect-intelligence": /defect|bug|predict|root.?cause|regression|failure|incident/i,
4956
+ "requirements-validation": /requirement|bdd|gherkin|testabil|accept|criteri|scenario/i,
4957
+ // Analysis Domains
4958
+ "code-intelligence": /semantic|knowledge|graph|ast|symbol|reference|impact|depend/i,
4959
+ "security-compliance": /vuln|cve|owasp|xss|sqli|injection|csrf|auth|secret|compliance|sast|dast/i,
4960
+ "contract-testing": /contract|pact|openapi|swagger|graphql|schema|endpoint|api/i,
4961
+ // Specialized Testing Domains
4962
+ "visual-accessibility": /screenshot|visual|snapshot|pixel|percy|a11y|aria|wcag|screen.?reader|accessible|contrast/i,
4963
+ "chaos-resilience": /chaos|resilience|fault|inject|blast|recover|latency|failure|stress|load/i,
4964
+ "learning-optimization": /learn|pattern|optim|neural|embedding|vector|memory|adapt|train/i
4965
+ };
4966
+ QE_DOMAIN_LIST = Object.keys(QE_DOMAINS);
4967
+ }
4968
+ });
4969
+
4691
4970
  // src/coordination/consensus/model-provider.ts
4692
4971
  function buildVerificationPrompt(finding, options = {}) {
4693
4972
  const {
@@ -6683,57 +6962,57 @@ var init_regex_safety_validator = __esm({
6683
6962
  // native-require:@ruvector/sona
6684
6963
  var sona_exports = {};
6685
6964
  __export(sona_exports, {
6686
- DotProductAttention: () => DotProductAttention3,
6687
- FlashAttention: () => FlashAttention3,
6688
- HyperbolicAttention: () => HyperbolicAttention3,
6689
- LinearAttention: () => LinearAttention3,
6690
- MoEAttention: () => MoEAttention3,
6691
- MultiHeadAttention: () => MultiHeadAttention3,
6692
- RuvectorLayer: () => RuvectorLayer3,
6693
- SonaEngine: () => SonaEngine3,
6694
- TensorCompress: () => TensorCompress3,
6965
+ DotProductAttention: () => DotProductAttention4,
6966
+ FlashAttention: () => FlashAttention4,
6967
+ HyperbolicAttention: () => HyperbolicAttention4,
6968
+ LinearAttention: () => LinearAttention4,
6969
+ MoEAttention: () => MoEAttention4,
6970
+ MultiHeadAttention: () => MultiHeadAttention4,
6971
+ RuvectorLayer: () => RuvectorLayer4,
6972
+ SonaEngine: () => SonaEngine4,
6973
+ TensorCompress: () => TensorCompress4,
6695
6974
  default: () => sona_default,
6696
- differentiableSearch: () => differentiableSearch3,
6697
- getCompressionLevel: () => getCompressionLevel3,
6698
- hierarchicalForward: () => hierarchicalForward3,
6699
- init: () => init3,
6700
- pipeline: () => pipeline4
6975
+ differentiableSearch: () => differentiableSearch4,
6976
+ getCompressionLevel: () => getCompressionLevel4,
6977
+ hierarchicalForward: () => hierarchicalForward4,
6978
+ init: () => init4,
6979
+ pipeline: () => pipeline5
6701
6980
  });
6702
- import { createRequire as createRequire3 } from "module";
6703
- var __require4, __mod3, sona_default, RuvectorLayer3, TensorCompress3, differentiableSearch3, hierarchicalForward3, getCompressionLevel3, init3, FlashAttention3, DotProductAttention3, MultiHeadAttention3, HyperbolicAttention3, LinearAttention3, MoEAttention3, SonaEngine3, pipeline4;
6981
+ import { createRequire as createRequire4 } from "module";
6982
+ var __require5, __mod4, sona_default, RuvectorLayer4, TensorCompress4, differentiableSearch4, hierarchicalForward4, getCompressionLevel4, init4, FlashAttention4, DotProductAttention4, MultiHeadAttention4, HyperbolicAttention4, LinearAttention4, MoEAttention4, SonaEngine4, pipeline5;
6704
6983
  var init_sona = __esm({
6705
6984
  "native-require:@ruvector/sona"() {
6706
- __require4 = createRequire3(import.meta.url);
6707
- __mod3 = __require4("@ruvector/sona");
6708
- sona_default = __mod3;
6985
+ __require5 = createRequire4(import.meta.url);
6986
+ __mod4 = __require5("@ruvector/sona");
6987
+ sona_default = __mod4;
6709
6988
  ({
6710
6989
  RuvectorLayer: (
6711
6990
  // @ruvector/gnn
6712
- RuvectorLayer3
6991
+ RuvectorLayer4
6713
6992
  ),
6714
- TensorCompress: TensorCompress3,
6715
- differentiableSearch: differentiableSearch3,
6716
- hierarchicalForward: hierarchicalForward3,
6717
- getCompressionLevel: getCompressionLevel3,
6718
- init: init3,
6993
+ TensorCompress: TensorCompress4,
6994
+ differentiableSearch: differentiableSearch4,
6995
+ hierarchicalForward: hierarchicalForward4,
6996
+ getCompressionLevel: getCompressionLevel4,
6997
+ init: init4,
6719
6998
  FlashAttention: (
6720
6999
  // @ruvector/attention
6721
- FlashAttention3
7000
+ FlashAttention4
6722
7001
  ),
6723
- DotProductAttention: DotProductAttention3,
6724
- MultiHeadAttention: MultiHeadAttention3,
6725
- HyperbolicAttention: HyperbolicAttention3,
6726
- LinearAttention: LinearAttention3,
6727
- MoEAttention: MoEAttention3,
7002
+ DotProductAttention: DotProductAttention4,
7003
+ MultiHeadAttention: MultiHeadAttention4,
7004
+ HyperbolicAttention: HyperbolicAttention4,
7005
+ LinearAttention: LinearAttention4,
7006
+ MoEAttention: MoEAttention4,
6728
7007
  SonaEngine: (
6729
7008
  // @ruvector/sona
6730
- SonaEngine3
7009
+ SonaEngine4
6731
7010
  ),
6732
7011
  pipeline: (
6733
7012
  // @xenova/transformers
6734
- pipeline4
7013
+ pipeline5
6735
7014
  )
6736
- } = __mod3 || {});
7015
+ } = __mod4 || {});
6737
7016
  }
6738
7017
  });
6739
7018
 
@@ -6875,7 +7154,7 @@ var init_sona_wrapper = __esm({
6875
7154
  qualityThreshold: this.config.qualityThreshold,
6876
7155
  enableSimd: this.config.enableSimd
6877
7156
  };
6878
- this.engine = SonaEngine3.withConfig(jsConfig);
7157
+ this.engine = SonaEngine4.withConfig(jsConfig);
6879
7158
  this.registry = new QESONAPatternRegistry(this.config.maxPatterns ?? 1e4);
6880
7159
  }
6881
7160
  /**
@@ -7304,57 +7583,57 @@ var init_sona_wrapper = __esm({
7304
7583
  // native-require:@ruvector/attention
7305
7584
  var attention_exports = {};
7306
7585
  __export(attention_exports, {
7307
- DotProductAttention: () => DotProductAttention4,
7308
- FlashAttention: () => FlashAttention4,
7309
- HyperbolicAttention: () => HyperbolicAttention4,
7310
- LinearAttention: () => LinearAttention4,
7311
- MoEAttention: () => MoEAttention4,
7312
- MultiHeadAttention: () => MultiHeadAttention4,
7313
- RuvectorLayer: () => RuvectorLayer4,
7314
- SonaEngine: () => SonaEngine4,
7315
- TensorCompress: () => TensorCompress4,
7586
+ DotProductAttention: () => DotProductAttention5,
7587
+ FlashAttention: () => FlashAttention5,
7588
+ HyperbolicAttention: () => HyperbolicAttention5,
7589
+ LinearAttention: () => LinearAttention5,
7590
+ MoEAttention: () => MoEAttention5,
7591
+ MultiHeadAttention: () => MultiHeadAttention5,
7592
+ RuvectorLayer: () => RuvectorLayer5,
7593
+ SonaEngine: () => SonaEngine5,
7594
+ TensorCompress: () => TensorCompress5,
7316
7595
  default: () => attention_default,
7317
- differentiableSearch: () => differentiableSearch4,
7318
- getCompressionLevel: () => getCompressionLevel4,
7319
- hierarchicalForward: () => hierarchicalForward4,
7320
- init: () => init4,
7321
- pipeline: () => pipeline5
7596
+ differentiableSearch: () => differentiableSearch5,
7597
+ getCompressionLevel: () => getCompressionLevel5,
7598
+ hierarchicalForward: () => hierarchicalForward5,
7599
+ init: () => init5,
7600
+ pipeline: () => pipeline6
7322
7601
  });
7323
- import { createRequire as createRequire4 } from "module";
7324
- var __require5, __mod4, attention_default, RuvectorLayer4, TensorCompress4, differentiableSearch4, hierarchicalForward4, getCompressionLevel4, init4, FlashAttention4, DotProductAttention4, MultiHeadAttention4, HyperbolicAttention4, LinearAttention4, MoEAttention4, SonaEngine4, pipeline5;
7602
+ import { createRequire as createRequire5 } from "module";
7603
+ var __require6, __mod5, attention_default, RuvectorLayer5, TensorCompress5, differentiableSearch5, hierarchicalForward5, getCompressionLevel5, init5, FlashAttention5, DotProductAttention5, MultiHeadAttention5, HyperbolicAttention5, LinearAttention5, MoEAttention5, SonaEngine5, pipeline6;
7325
7604
  var init_attention = __esm({
7326
7605
  "native-require:@ruvector/attention"() {
7327
- __require5 = createRequire4(import.meta.url);
7328
- __mod4 = __require5("@ruvector/attention");
7329
- attention_default = __mod4;
7606
+ __require6 = createRequire5(import.meta.url);
7607
+ __mod5 = __require6("@ruvector/attention");
7608
+ attention_default = __mod5;
7330
7609
  ({
7331
7610
  RuvectorLayer: (
7332
7611
  // @ruvector/gnn
7333
- RuvectorLayer4
7612
+ RuvectorLayer5
7334
7613
  ),
7335
- TensorCompress: TensorCompress4,
7336
- differentiableSearch: differentiableSearch4,
7337
- hierarchicalForward: hierarchicalForward4,
7338
- getCompressionLevel: getCompressionLevel4,
7339
- init: init4,
7614
+ TensorCompress: TensorCompress5,
7615
+ differentiableSearch: differentiableSearch5,
7616
+ hierarchicalForward: hierarchicalForward5,
7617
+ getCompressionLevel: getCompressionLevel5,
7618
+ init: init5,
7340
7619
  FlashAttention: (
7341
7620
  // @ruvector/attention
7342
- FlashAttention4
7621
+ FlashAttention5
7343
7622
  ),
7344
- DotProductAttention: DotProductAttention4,
7345
- MultiHeadAttention: MultiHeadAttention4,
7346
- HyperbolicAttention: HyperbolicAttention4,
7347
- LinearAttention: LinearAttention4,
7348
- MoEAttention: MoEAttention4,
7623
+ DotProductAttention: DotProductAttention5,
7624
+ MultiHeadAttention: MultiHeadAttention5,
7625
+ HyperbolicAttention: HyperbolicAttention5,
7626
+ LinearAttention: LinearAttention5,
7627
+ MoEAttention: MoEAttention5,
7349
7628
  SonaEngine: (
7350
7629
  // @ruvector/sona
7351
- SonaEngine4
7630
+ SonaEngine5
7352
7631
  ),
7353
7632
  pipeline: (
7354
7633
  // @xenova/transformers
7355
- pipeline5
7634
+ pipeline6
7356
7635
  )
7357
- } = __mod4 || {});
7636
+ } = __mod5 || {});
7358
7637
  }
7359
7638
  });
7360
7639
 
@@ -7512,23 +7791,23 @@ var init_attention_wrapper = __esm({
7512
7791
  static create(config) {
7513
7792
  switch (config.strategy) {
7514
7793
  case "flash":
7515
- return new FlashAttention4(config.dim, config.blockSize);
7794
+ return new FlashAttention5(config.dim, config.blockSize);
7516
7795
  case "dot-product":
7517
- return new DotProductAttention4(config.dim);
7796
+ return new DotProductAttention5(config.dim);
7518
7797
  case "multi-head":
7519
- return new MultiHeadAttention4(config.dim, config.numHeads ?? 8);
7798
+ return new MultiHeadAttention5(config.dim, config.numHeads ?? 8);
7520
7799
  case "hyperbolic":
7521
- return new HyperbolicAttention4(config.dim, config.curvature);
7800
+ return new HyperbolicAttention5(config.dim, config.curvature);
7522
7801
  case "linear":
7523
- return new LinearAttention4(config.dim, config.features);
7802
+ return new LinearAttention5(config.dim, config.features);
7524
7803
  case "moe":
7525
- return MoEAttention4.simple(
7804
+ return MoEAttention5.simple(
7526
7805
  config.dim,
7527
7806
  config.moeConfig?.numExperts ?? 8,
7528
7807
  config.moeConfig?.topK ?? 2
7529
7808
  );
7530
7809
  default:
7531
- return new FlashAttention4(config.dim, config.blockSize);
7810
+ return new FlashAttention5(config.dim, config.blockSize);
7532
7811
  }
7533
7812
  }
7534
7813
  };
@@ -7585,20 +7864,20 @@ var init_attention_wrapper = __esm({
7585
7864
  const keys = this.splitMatrix(K58, seqLen, dim);
7586
7865
  const values = this.splitMatrix(V45, seqLen, dim);
7587
7866
  let output;
7588
- if (this.attention instanceof FlashAttention4) {
7867
+ if (this.attention instanceof FlashAttention5) {
7589
7868
  output = this.attention.compute(query, keys, values);
7590
- } else if (this.attention instanceof DotProductAttention4) {
7869
+ } else if (this.attention instanceof DotProductAttention5) {
7591
7870
  output = this.attention.compute(query, keys, values);
7592
- } else if (this.attention instanceof MultiHeadAttention4) {
7871
+ } else if (this.attention instanceof MultiHeadAttention5) {
7593
7872
  output = this.attention.compute(query, keys, values);
7594
- } else if (this.attention instanceof HyperbolicAttention4) {
7873
+ } else if (this.attention instanceof HyperbolicAttention5) {
7595
7874
  output = this.attention.compute(query, keys, values);
7596
- } else if (this.attention instanceof LinearAttention4) {
7875
+ } else if (this.attention instanceof LinearAttention5) {
7597
7876
  output = this.attention.compute(query, keys, values);
7598
- } else if (this.attention instanceof MoEAttention4) {
7877
+ } else if (this.attention instanceof MoEAttention5) {
7599
7878
  output = this.attention.compute(query, keys, values);
7600
7879
  } else {
7601
- const fallback = new FlashAttention4(this.config.dim);
7880
+ const fallback = new FlashAttention5(this.config.dim);
7602
7881
  output = fallback.compute(query, keys, values);
7603
7882
  }
7604
7883
  const endTime = performance.now();
@@ -7843,77 +8122,20 @@ var init_attention_wrapper = __esm({
7843
8122
  }
7844
8123
  });
7845
8124
 
7846
- // native-require:@ruvector/gnn
7847
- var gnn_exports = {};
7848
- __export(gnn_exports, {
7849
- DotProductAttention: () => DotProductAttention5,
7850
- FlashAttention: () => FlashAttention5,
7851
- HyperbolicAttention: () => HyperbolicAttention5,
7852
- LinearAttention: () => LinearAttention5,
7853
- MoEAttention: () => MoEAttention5,
7854
- MultiHeadAttention: () => MultiHeadAttention5,
7855
- RuvectorLayer: () => RuvectorLayer5,
7856
- SonaEngine: () => SonaEngine5,
7857
- TensorCompress: () => TensorCompress5,
7858
- default: () => gnn_default,
7859
- differentiableSearch: () => differentiableSearch5,
7860
- getCompressionLevel: () => getCompressionLevel5,
7861
- hierarchicalForward: () => hierarchicalForward5,
7862
- init: () => init5,
7863
- pipeline: () => pipeline6
7864
- });
7865
- import { createRequire as createRequire5 } from "module";
7866
- var __require6, __mod5, gnn_default, RuvectorLayer5, TensorCompress5, differentiableSearch5, hierarchicalForward5, getCompressionLevel5, init5, FlashAttention5, DotProductAttention5, MultiHeadAttention5, HyperbolicAttention5, LinearAttention5, MoEAttention5, SonaEngine5, pipeline6;
7867
- var init_gnn = __esm({
7868
- "native-require:@ruvector/gnn"() {
7869
- __require6 = createRequire5(import.meta.url);
7870
- __mod5 = __require6("@ruvector/gnn");
7871
- gnn_default = __mod5;
7872
- ({
7873
- RuvectorLayer: (
7874
- // @ruvector/gnn
7875
- RuvectorLayer5
7876
- ),
7877
- TensorCompress: TensorCompress5,
7878
- differentiableSearch: differentiableSearch5,
7879
- hierarchicalForward: hierarchicalForward5,
7880
- getCompressionLevel: getCompressionLevel5,
7881
- init: init5,
7882
- FlashAttention: (
7883
- // @ruvector/attention
7884
- FlashAttention5
7885
- ),
7886
- DotProductAttention: DotProductAttention5,
7887
- MultiHeadAttention: MultiHeadAttention5,
7888
- HyperbolicAttention: HyperbolicAttention5,
7889
- LinearAttention: LinearAttention5,
7890
- MoEAttention: MoEAttention5,
7891
- SonaEngine: (
7892
- // @ruvector/sona
7893
- SonaEngine5
7894
- ),
7895
- pipeline: (
7896
- // @xenova/transformers
7897
- pipeline6
7898
- )
7899
- } = __mod5 || {});
7900
- }
7901
- });
7902
-
7903
8125
  // src/integrations/ruvector/gnn-wrapper.ts
7904
8126
  var gnn_wrapper_exports = {};
7905
8127
  __export(gnn_wrapper_exports, {
7906
8128
  GNNLayerFactory: () => GNNLayerFactory,
7907
8129
  QEGNNEmbeddingIndex: () => QEGNNEmbeddingIndex,
7908
8130
  QEGNNIndexFactory: () => QEGNNIndexFactory,
7909
- RuvectorLayer: () => RuvectorLayer5,
7910
- TensorCompress: () => TensorCompress5,
8131
+ RuvectorLayer: () => RuvectorLayer2,
8132
+ TensorCompress: () => TensorCompress2,
7911
8133
  TensorCompressionFactory: () => TensorCompressionFactory,
7912
8134
  batchDifferentiableSearch: () => batchDifferentiableSearch,
7913
- differentiableSearch: () => differentiableSearch5,
7914
- getCompressionLevel: () => getCompressionLevel5,
7915
- hierarchicalForward: () => hierarchicalForward5,
7916
- init: () => init5,
8135
+ differentiableSearch: () => differentiableSearch2,
8136
+ getCompressionLevel: () => getCompressionLevel2,
8137
+ hierarchicalForward: () => hierarchicalForward2,
8138
+ init: () => init2,
7917
8139
  initGNN: () => initGNN,
7918
8140
  toFloat32Array: () => toFloat32Array2,
7919
8141
  toIEmbedding: () => toIEmbedding,
@@ -7921,7 +8143,7 @@ __export(gnn_wrapper_exports, {
7921
8143
  });
7922
8144
  function initGNN() {
7923
8145
  if (!gnnInitialized) {
7924
- const result = init5();
8146
+ const result = init2();
7925
8147
  gnnInitialized = true;
7926
8148
  return result;
7927
8149
  }
@@ -7962,7 +8184,7 @@ function batchDifferentiableSearch(queries, candidateEmbeddings, k68, temperatur
7962
8184
  );
7963
8185
  for (const query of queries) {
7964
8186
  const queryFloat32 = query instanceof Float32Array ? query : new Float32Array(query);
7965
- const result = differentiableSearch5(
8187
+ const result = differentiableSearch2(
7966
8188
  queryFloat32,
7967
8189
  candidatesFloat32,
7968
8190
  k68,
@@ -8000,7 +8222,7 @@ var init_gnn_wrapper = __esm({
8000
8222
  this.indexes = /* @__PURE__ */ new Map();
8001
8223
  this.nextId = /* @__PURE__ */ new Map();
8002
8224
  this.gnnLayers = /* @__PURE__ */ new Map();
8003
- this.compressor = new TensorCompress5();
8225
+ this.compressor = new TensorCompress2();
8004
8226
  initGNN();
8005
8227
  }
8006
8228
  /**
@@ -8061,7 +8283,7 @@ var init_gnn_wrapper = __esm({
8061
8283
  }
8062
8284
  const queryFloat32 = new Float32Array(query.vector);
8063
8285
  const candidateFloat32s = candidates.map((c70) => new Float32Array(c70.vector));
8064
- const result = differentiableSearch5(
8286
+ const result = differentiableSearch2(
8065
8287
  queryFloat32,
8066
8288
  candidateFloat32s,
8067
8289
  Math.min(k68, candidates.length),
@@ -8084,7 +8306,7 @@ var init_gnn_wrapper = __esm({
8084
8306
  const candidateVectors = candidates.map(
8085
8307
  (c70) => new Float32Array(c70.embedding.vector)
8086
8308
  );
8087
- const result = differentiableSearch5(
8309
+ const result = differentiableSearch2(
8088
8310
  queryVector,
8089
8311
  candidateVectors,
8090
8312
  Math.min(k68, candidates.length),
@@ -8105,7 +8327,7 @@ var init_gnn_wrapper = __esm({
8105
8327
  if (!this.gnnLayers.has(layerKey)) {
8106
8328
  const layers = [];
8107
8329
  for (const config of layerConfigs) {
8108
- const layer2 = new RuvectorLayer5(
8330
+ const layer2 = new RuvectorLayer2(
8109
8331
  config.inputDim,
8110
8332
  config.hiddenDim,
8111
8333
  config.heads,
@@ -8121,7 +8343,7 @@ var init_gnn_wrapper = __esm({
8121
8343
  const layerEmbeddingsFloat32 = layerEmbeddings.map(
8122
8344
  (layer2) => layer2.map((emb) => new Float32Array(emb))
8123
8345
  );
8124
- return Array.from(hierarchicalForward5(
8346
+ return Array.from(hierarchicalForward2(
8125
8347
  queryFloat32,
8126
8348
  layerEmbeddingsFloat32,
8127
8349
  [gnnLayerJson]
@@ -8136,7 +8358,7 @@ var init_gnn_wrapper = __esm({
8136
8358
  * - Cold data (low access): product quantization
8137
8359
  */
8138
8360
  compressEmbedding(embedding, accessFreq) {
8139
- const rawLevel = getCompressionLevel5(accessFreq);
8361
+ const rawLevel = getCompressionLevel2(accessFreq);
8140
8362
  const levelMap = {
8141
8363
  "none": "none",
8142
8364
  "half": "half",
@@ -8182,7 +8404,7 @@ var init_gnn_wrapper = __esm({
8182
8404
  * Get compression level for access frequency
8183
8405
  */
8184
8406
  getCompressionLevelForFrequency(accessFreq) {
8185
- return getCompressionLevel5(accessFreq);
8407
+ return getCompressionLevel2(accessFreq);
8186
8408
  }
8187
8409
  /**
8188
8410
  * Get index statistics
@@ -8326,7 +8548,7 @@ var init_gnn_wrapper = __esm({
8326
8548
  static getLayer(config) {
8327
8549
  const key = `${config.inputDim}-${config.hiddenDim}-${config.heads}-${config.dropout}`;
8328
8550
  if (!this.layers.has(key)) {
8329
- const layer = new RuvectorLayer5(
8551
+ const layer = new RuvectorLayer2(
8330
8552
  config.inputDim,
8331
8553
  config.hiddenDim,
8332
8554
  config.heads,
@@ -8340,7 +8562,7 @@ var init_gnn_wrapper = __esm({
8340
8562
  * Create layer from JSON
8341
8563
  */
8342
8564
  static layerFromJson(json) {
8343
- return RuvectorLayer5.fromJson(json);
8565
+ return RuvectorLayer2.fromJson(json);
8344
8566
  }
8345
8567
  /**
8346
8568
  * Clear cached layers
@@ -8350,7 +8572,7 @@ var init_gnn_wrapper = __esm({
8350
8572
  }
8351
8573
  };
8352
8574
  TensorCompressionFactory = class {
8353
- static compressor = new TensorCompress5();
8575
+ static compressor = new TensorCompress2();
8354
8576
  /**
8355
8577
  * Compress tensor with specific level
8356
8578
  */
@@ -8376,7 +8598,7 @@ var init_gnn_wrapper = __esm({
8376
8598
  * Get compression level for frequency
8377
8599
  */
8378
8600
  static getLevel(accessFreq) {
8379
- return getCompressionLevel5(accessFreq);
8601
+ return getCompressionLevel2(accessFreq);
8380
8602
  }
8381
8603
  };
8382
8604
  }
@@ -8393,14 +8615,14 @@ __export(wrappers_exports, {
8393
8615
  QE_FLASH_ATTENTION_CONFIG: () => QE_FLASH_ATTENTION_CONFIG,
8394
8616
  QE_PERFORMANCE_TARGETS: () => QE_PERFORMANCE_TARGETS,
8395
8617
  QE_SONA_CONFIG: () => QE_SONA_CONFIG,
8396
- RuvectorDotProductAttention: () => DotProductAttention4,
8397
- RuvectorFlashAttention: () => FlashAttention4,
8398
- RuvectorHyperbolicAttention: () => HyperbolicAttention4,
8399
- RuvectorLayer: () => RuvectorLayer5,
8400
- RuvectorLinearAttention: () => LinearAttention4,
8401
- RuvectorMoEAttention: () => MoEAttention4,
8402
- RuvectorMultiHeadAttention: () => MultiHeadAttention4,
8403
- TensorCompress: () => TensorCompress5,
8618
+ RuvectorDotProductAttention: () => DotProductAttention5,
8619
+ RuvectorFlashAttention: () => FlashAttention5,
8620
+ RuvectorHyperbolicAttention: () => HyperbolicAttention5,
8621
+ RuvectorLayer: () => RuvectorLayer2,
8622
+ RuvectorLinearAttention: () => LinearAttention5,
8623
+ RuvectorMoEAttention: () => MoEAttention5,
8624
+ RuvectorMultiHeadAttention: () => MultiHeadAttention5,
8625
+ TensorCompress: () => TensorCompress2,
8404
8626
  TensorCompressionFactory: () => TensorCompressionFactory,
8405
8627
  batchComputeAttention: () => batchComputeAttention,
8406
8628
  batchDifferentiableSearch: () => batchDifferentiableSearch,
@@ -8408,14 +8630,14 @@ __export(wrappers_exports, {
8408
8630
  createDomainQESONA: () => createDomainQESONA,
8409
8631
  createQEFlashAttention: () => createQEFlashAttention,
8410
8632
  createQESONA: () => createQESONA,
8411
- differentiableSearch: () => differentiableSearch5,
8412
- getCompressionLevel: () => getCompressionLevel5,
8633
+ differentiableSearch: () => differentiableSearch2,
8634
+ getCompressionLevel: () => getCompressionLevel2,
8413
8635
  getOptimalBlockConfig: () => getOptimalBlockConfig,
8414
8636
  getQEFlashAttentionConfig: () => getQEFlashAttentionConfig,
8415
8637
  getRuvectorPackageVersions: () => getRuvectorPackageVersions,
8416
8638
  getWorkloadTypes: () => getWorkloadTypes,
8417
- hierarchicalForward: () => hierarchicalForward5,
8418
- init: () => init5,
8639
+ hierarchicalForward: () => hierarchicalForward2,
8640
+ init: () => init2,
8419
8641
  initAllRuvectorPackages: () => initAllRuvectorPackages,
8420
8642
  initGNN: () => initGNN,
8421
8643
  toFloat32Array: () => toFloat32Array,
@@ -14095,120 +14317,6 @@ var init_dream = __esm({
14095
14317
  }
14096
14318
  });
14097
14319
 
14098
- // src/learning/qe-patterns.ts
14099
- function detectQEDomain(taskDescription) {
14100
- for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
14101
- if (pattern.test(taskDescription)) {
14102
- return domain;
14103
- }
14104
- }
14105
- return null;
14106
- }
14107
- function detectQEDomains(taskDescription) {
14108
- const detected = [];
14109
- for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
14110
- if (pattern.test(taskDescription)) {
14111
- detected.push(domain);
14112
- }
14113
- }
14114
- return detected;
14115
- }
14116
- function mapQEDomainToAQE(qeDomain) {
14117
- return qeDomain;
14118
- }
14119
- function calculateQualityScore(pattern) {
14120
- const usageScore = Math.min(pattern.usageCount / 100, 1);
14121
- return pattern.confidence * 0.3 + usageScore * 0.2 + pattern.successRate * 0.5;
14122
- }
14123
- function shouldPromotePattern(pattern, coherenceEnergy, coherenceThreshold = 0.4) {
14124
- const meetsUsageCriteria = pattern.tier === "short-term" && pattern.successfulUses >= 3;
14125
- const meetsQualityCriteria = pattern.successRate >= 0.7 && pattern.confidence >= 0.6;
14126
- const meetsCoherenceCriteria = coherenceEnergy === void 0 || coherenceEnergy < coherenceThreshold;
14127
- let blockReason;
14128
- if (!meetsUsageCriteria) {
14129
- blockReason = "insufficient_usage";
14130
- } else if (!meetsQualityCriteria) {
14131
- blockReason = "low_quality";
14132
- } else if (!meetsCoherenceCriteria) {
14133
- blockReason = "coherence_violation";
14134
- }
14135
- return {
14136
- meetsUsageCriteria,
14137
- meetsQualityCriteria,
14138
- meetsCoherenceCriteria,
14139
- blockReason
14140
- };
14141
- }
14142
- function validateQEPattern(pattern) {
14143
- const errors = [];
14144
- if (!pattern.id) errors.push("Pattern ID is required");
14145
- if (!pattern.patternType) errors.push("Pattern type is required");
14146
- if (!pattern.qeDomain) errors.push("QE domain is required");
14147
- if (!pattern.name) errors.push("Pattern name is required");
14148
- if (!pattern.template?.content) errors.push("Template content is required");
14149
- if (pattern.confidence !== void 0 && (pattern.confidence < 0 || pattern.confidence > 1)) {
14150
- errors.push("Confidence must be between 0 and 1");
14151
- }
14152
- if (pattern.successRate !== void 0 && (pattern.successRate < 0 || pattern.successRate > 1)) {
14153
- errors.push("Success rate must be between 0 and 1");
14154
- }
14155
- if (pattern.template?.variables) {
14156
- const variableNames = /* @__PURE__ */ new Set();
14157
- for (const variable of pattern.template.variables) {
14158
- if (variableNames.has(variable.name)) {
14159
- errors.push(`Duplicate variable name: ${variable.name}`);
14160
- }
14161
- variableNames.add(variable.name);
14162
- if (!pattern.template.content.includes(`{{${variable.name}}}`)) {
14163
- errors.push(
14164
- `Variable ${variable.name} not referenced in template`
14165
- );
14166
- }
14167
- }
14168
- }
14169
- return { valid: errors.length === 0, errors };
14170
- }
14171
- function applyPatternTemplate(template, variables) {
14172
- let content = template.content;
14173
- for (const variable of template.variables) {
14174
- const value = variables[variable.name] ?? variable.defaultValue;
14175
- if (variable.required && value === void 0) {
14176
- throw new Error(`Required variable ${variable.name} not provided`);
14177
- }
14178
- if (value !== void 0) {
14179
- const placeholder = `{{${variable.name}}}`;
14180
- const stringValue = typeof value === "object" ? JSON.stringify(value) : String(value);
14181
- content = content.split(placeholder).join(stringValue);
14182
- }
14183
- }
14184
- return content;
14185
- }
14186
- var QE_DOMAINS, QE_DOMAIN_LIST;
14187
- var init_qe_patterns = __esm({
14188
- "src/learning/qe-patterns.ts"() {
14189
- "use strict";
14190
- QE_DOMAINS = {
14191
- // Core Testing Domains
14192
- "test-generation": /test|spec|describe|it\(|expect|assert|mock|stub|fixture|tdd|bdd/i,
14193
- "test-execution": /run|execute|parallel|retry|flaky|timeout|worker|orchestrat/i,
14194
- "coverage-analysis": /coverage|branch|line|uncovered|gap|untested|percentage|sublinear/i,
14195
- // Quality Domains
14196
- "quality-assessment": /quality|gate|deploy|readiness|metric|threshold|sla|score/i,
14197
- "defect-intelligence": /defect|bug|predict|root.?cause|regression|failure|incident/i,
14198
- "requirements-validation": /requirement|bdd|gherkin|testabil|accept|criteri|scenario/i,
14199
- // Analysis Domains
14200
- "code-intelligence": /semantic|knowledge|graph|ast|symbol|reference|impact|depend/i,
14201
- "security-compliance": /vuln|cve|owasp|xss|sqli|injection|csrf|auth|secret|compliance|sast|dast/i,
14202
- "contract-testing": /contract|pact|openapi|swagger|graphql|schema|endpoint|api/i,
14203
- // Specialized Testing Domains
14204
- "visual-accessibility": /screenshot|visual|snapshot|pixel|percy|a11y|aria|wcag|screen.?reader|accessible|contrast/i,
14205
- "chaos-resilience": /chaos|resilience|fault|inject|blast|recover|latency|failure|stress|load/i,
14206
- "learning-optimization": /learn|pattern|optim|neural|embedding|vector|memory|adapt|train/i
14207
- };
14208
- QE_DOMAIN_LIST = Object.keys(QE_DOMAINS);
14209
- }
14210
- });
14211
-
14212
14320
  // src/learning/pattern-store.ts
14213
14321
  function createPatternStore(memory, config) {
14214
14322
  return new PatternStore(memory, config);
@@ -25341,7 +25449,7 @@ var JestVitestGenerator = class extends BaseTestGenerator {
25341
25449
  * Generate complete test file from analysis
25342
25450
  */
25343
25451
  generateTests(context2) {
25344
- const { moduleName, importPath, testType, patterns, analysis } = context2;
25452
+ const { moduleName, importPath, testType, patterns, analysis, dependencies } = context2;
25345
25453
  if (!analysis || analysis.functions.length === 0 && analysis.classes.length === 0) {
25346
25454
  return this.generateStubTests(context2);
25347
25455
  }
@@ -25351,8 +25459,23 @@ var JestVitestGenerator = class extends BaseTestGenerator {
25351
25459
  const mockImport = this.framework === "vitest" ? ", vi" : "";
25352
25460
  let testCode = `${patternComment}import { describe, it, expect, beforeEach${mockImport} } from '${this.framework}';
25353
25461
  ${importStatement}
25354
-
25355
25462
  `;
25463
+ if (dependencies && dependencies.imports.length > 0) {
25464
+ const mockFn = this.framework === "vitest" ? "vi.fn()" : "jest.fn()";
25465
+ testCode += `
25466
+ // Auto-generated mocks from Knowledge Graph dependency analysis
25467
+ `;
25468
+ for (const dep of dependencies.imports.slice(0, 10)) {
25469
+ const depName = dep.split("/").pop()?.replace(/[^a-zA-Z0-9_]/g, "_") || dep;
25470
+ testCode += `${this.framework === "vitest" ? "vi" : "jest"}.mock('${dep}', () => ({ default: ${mockFn} }));
25471
+ `;
25472
+ }
25473
+ testCode += `
25474
+ `;
25475
+ } else {
25476
+ testCode += `
25477
+ `;
25478
+ }
25356
25479
  for (const fn of analysis.functions) {
25357
25480
  testCode += this.generateFunctionTests(fn, testType);
25358
25481
  }
@@ -25472,22 +25595,80 @@ ${importStatement}
25472
25595
  * Generate stub tests when no AST analysis is available
25473
25596
  */
25474
25597
  generateStubTests(context2) {
25475
- const { moduleName, importPath, testType, patterns } = context2;
25598
+ const { moduleName, importPath, testType, patterns, dependencies, similarCode } = context2;
25476
25599
  const patternComment = this.generatePatternComment(patterns);
25477
25600
  const basicOpsTest = this.generateBasicOpsTest(moduleName, patterns);
25478
25601
  const edgeCaseTest = this.generateEdgeCaseTest(moduleName, patterns);
25479
25602
  const errorHandlingTest = this.generateErrorHandlingTest(moduleName, patterns);
25603
+ let mockDeclarations = "";
25604
+ if (dependencies && dependencies.imports.length > 0) {
25605
+ const mockFn = this.framework === "vitest" ? "vi.fn()" : "jest.fn()";
25606
+ mockDeclarations += `
25607
+ // Auto-generated mocks from Knowledge Graph dependency analysis
25608
+ `;
25609
+ for (const dep of dependencies.imports.slice(0, 10)) {
25610
+ mockDeclarations += `${this.mockUtil}.mock('${dep}', () => ({ default: ${mockFn} }));
25611
+ `;
25612
+ }
25613
+ }
25614
+ let similarityComment = "";
25615
+ if (similarCode && similarCode.snippets.length > 0) {
25616
+ similarityComment += ` // KG: Similar modules found - consider testing shared patterns:
25617
+ `;
25618
+ for (const s70 of similarCode.snippets.slice(0, 3)) {
25619
+ similarityComment += ` // - ${s70.file} (${(s70.score * 100).toFixed(0)}% similar)
25620
+ `;
25621
+ }
25622
+ similarityComment += `
25623
+ `;
25624
+ }
25625
+ let depTest = "";
25626
+ if (dependencies && dependencies.imports.length > 0) {
25627
+ depTest += `
25628
+ it('should interact with dependencies correctly', () => {
25629
+ `;
25630
+ depTest += ` // KG-informed: module depends on ${dependencies.imports.length} imports
25631
+ `;
25632
+ depTest += ` const instance = typeof ${moduleName} === 'function'
25633
+ `;
25634
+ depTest += ` ? new ${moduleName}()
25635
+ `;
25636
+ depTest += ` : ${moduleName};
25637
+ `;
25638
+ depTest += ` expect(instance).toBeDefined();
25639
+ `;
25640
+ depTest += ` });
25641
+ `;
25642
+ }
25643
+ let callerTest = "";
25644
+ if (dependencies && dependencies.importedBy.length > 0) {
25645
+ callerTest += `
25646
+ it('should expose stable API for ${dependencies.importedBy.length} consumers', () => {
25647
+ `;
25648
+ callerTest += ` // KG-informed: used by ${dependencies.importedBy.slice(0, 3).join(", ")}
25649
+ `;
25650
+ callerTest += ` const publicKeys = Object.keys(typeof ${moduleName} === 'function'
25651
+ `;
25652
+ callerTest += ` ? ${moduleName}.prototype || {}
25653
+ `;
25654
+ callerTest += ` : ${moduleName});
25655
+ `;
25656
+ callerTest += ` expect(publicKeys.length).toBeGreaterThan(0);
25657
+ `;
25658
+ callerTest += ` });
25659
+ `;
25660
+ }
25480
25661
  return `${patternComment}import { ${moduleName} } from '${importPath}';
25481
-
25662
+ ${mockDeclarations}
25482
25663
  describe('${moduleName}', () => {
25483
- describe('${testType} tests', () => {
25664
+ ${similarityComment} describe('${testType} tests', () => {
25484
25665
  it('should be defined', () => {
25485
25666
  expect(${moduleName}).toBeDefined();
25486
25667
  });
25487
25668
 
25488
25669
  ${basicOpsTest}
25489
25670
  ${edgeCaseTest}
25490
- ${errorHandlingTest}
25671
+ ${errorHandlingTest}${depTest}${callerTest}
25491
25672
  });
25492
25673
  });
25493
25674
  `;
@@ -25695,18 +25876,51 @@ var MochaGenerator = class extends BaseTestGenerator {
25695
25876
  * Generate complete test file from analysis
25696
25877
  */
25697
25878
  generateTests(context2) {
25698
- const { moduleName, importPath, testType, patterns, analysis } = context2;
25879
+ const { moduleName, importPath, testType, patterns, analysis, dependencies } = context2;
25699
25880
  if (!analysis || analysis.functions.length === 0 && analysis.classes.length === 0) {
25700
25881
  return this.generateStubTests(context2);
25701
25882
  }
25702
25883
  const patternComment = this.generatePatternComment(patterns);
25703
25884
  const exports = this.extractExports(analysis.functions, analysis.classes);
25704
25885
  const importStatement = this.generateImportStatement(exports, importPath, moduleName);
25886
+ let sinonImport = "";
25887
+ let stubSetup = "";
25888
+ if (dependencies && dependencies.imports.length > 0) {
25889
+ sinonImport = `import sinon from 'sinon';
25890
+ `;
25891
+ const depsToMock = dependencies.imports.slice(0, 5);
25892
+ stubSetup += ` // Auto-generated stubs from Knowledge Graph dependency analysis
25893
+ `;
25894
+ stubSetup += ` let stubs;
25895
+
25896
+ `;
25897
+ stubSetup += ` beforeEach(function() {
25898
+ `;
25899
+ stubSetup += ` stubs = {
25900
+ `;
25901
+ for (const dep of depsToMock) {
25902
+ const depName = dep.split("/").pop()?.replace(/[^a-zA-Z0-9_]/g, "_") || dep;
25903
+ stubSetup += ` ${depName}: sinon.stub(),
25904
+ `;
25905
+ }
25906
+ stubSetup += ` };
25907
+ `;
25908
+ stubSetup += ` });
25909
+
25910
+ `;
25911
+ stubSetup += ` afterEach(function() {
25912
+ `;
25913
+ stubSetup += ` sinon.restore();
25914
+ `;
25915
+ stubSetup += ` });
25916
+
25917
+ `;
25918
+ }
25705
25919
  let code = `${patternComment}import { expect } from 'chai';
25706
- ${importStatement}
25920
+ ${sinonImport}${importStatement}
25707
25921
 
25708
25922
  describe('${moduleName} - ${testType} tests', function() {
25709
- `;
25923
+ ${stubSetup}`;
25710
25924
  for (const fn of analysis.functions) {
25711
25925
  code += this.generateFunctionTests(fn, testType);
25712
25926
  }
@@ -25796,18 +26010,100 @@ describe('${moduleName} - ${testType} tests', function() {
25796
26010
  * Generate stub tests when no AST analysis is available
25797
26011
  */
25798
26012
  generateStubTests(context2) {
25799
- const { moduleName, importPath, testType, patterns } = context2;
26013
+ const { moduleName, importPath, testType, patterns, dependencies, similarCode } = context2;
25800
26014
  const patternComment = this.generatePatternComment(patterns);
25801
26015
  const isAsync = patterns.some(
25802
26016
  (p74) => p74.name.toLowerCase().includes("async") || p74.name.toLowerCase().includes("promise")
25803
26017
  );
25804
26018
  const asyncSetup = isAsync ? "async " : "";
26019
+ let sinonImport = "";
26020
+ let stubSetup = "";
26021
+ let stubTeardown = "";
26022
+ if (dependencies && dependencies.imports.length > 0) {
26023
+ sinonImport = `import sinon from 'sinon';
26024
+ `;
26025
+ const depsToMock = dependencies.imports.slice(0, 5);
26026
+ stubSetup += `
26027
+ // Auto-generated stubs from Knowledge Graph dependency analysis
26028
+ `;
26029
+ stubSetup += ` let stubs;
26030
+
26031
+ `;
26032
+ stubSetup += ` beforeEach(function() {
26033
+ `;
26034
+ stubSetup += ` stubs = {
26035
+ `;
26036
+ for (const dep of depsToMock) {
26037
+ const depName = dep.split("/").pop()?.replace(/[^a-zA-Z0-9_]/g, "_") || dep;
26038
+ stubSetup += ` ${depName}: sinon.stub(),
26039
+ `;
26040
+ }
26041
+ stubSetup += ` };
26042
+ `;
26043
+ stubSetup += ` });
26044
+
26045
+ `;
26046
+ stubTeardown += ` afterEach(function() {
26047
+ `;
26048
+ stubTeardown += ` sinon.restore();
26049
+ `;
26050
+ stubTeardown += ` });
26051
+
26052
+ `;
26053
+ }
26054
+ let similarityComment = "";
26055
+ if (similarCode && similarCode.snippets.length > 0) {
26056
+ similarityComment += ` // KG: Similar modules found - consider testing shared patterns:
26057
+ `;
26058
+ for (const s70 of similarCode.snippets.slice(0, 3)) {
26059
+ similarityComment += ` // - ${s70.file} (${(s70.score * 100).toFixed(0)}% similar)
26060
+ `;
26061
+ }
26062
+ similarityComment += `
26063
+ `;
26064
+ }
26065
+ let depTest = "";
26066
+ if (dependencies && dependencies.imports.length > 0) {
26067
+ depTest += `
26068
+ it('should interact with dependencies correctly', function() {
26069
+ `;
26070
+ depTest += ` // KG-informed: module depends on ${dependencies.imports.length} imports
26071
+ `;
26072
+ depTest += ` const instance = typeof ${moduleName} === 'function'
26073
+ `;
26074
+ depTest += ` ? new ${moduleName}()
26075
+ `;
26076
+ depTest += ` : ${moduleName};
26077
+ `;
26078
+ depTest += ` expect(instance).to.exist;
26079
+ `;
26080
+ depTest += ` });
26081
+ `;
26082
+ }
26083
+ let callerTest = "";
26084
+ if (dependencies && dependencies.importedBy.length > 0) {
26085
+ callerTest += `
26086
+ it('should expose stable API for ${dependencies.importedBy.length} consumers', function() {
26087
+ `;
26088
+ callerTest += ` // KG-informed: used by ${dependencies.importedBy.slice(0, 3).join(", ")}
26089
+ `;
26090
+ callerTest += ` const publicKeys = Object.keys(typeof ${moduleName} === 'function'
26091
+ `;
26092
+ callerTest += ` ? ${moduleName}.prototype || {}
26093
+ `;
26094
+ callerTest += ` : ${moduleName});
26095
+ `;
26096
+ callerTest += ` expect(publicKeys.length).to.be.greaterThan(0);
26097
+ `;
26098
+ callerTest += ` });
26099
+ `;
26100
+ }
25805
26101
  return `${patternComment}import { expect } from 'chai';
25806
- import { ${moduleName} } from '${importPath}';
26102
+ ${sinonImport}import { ${moduleName} } from '${importPath}';
25807
26103
 
25808
26104
  describe('${moduleName}', function() {
25809
26105
  describe('${testType} tests', function() {
25810
- it('should be defined', function() {
26106
+ ${stubSetup}${stubTeardown}${similarityComment} it('should be defined', function() {
25811
26107
  expect(${moduleName}).to.not.be.undefined;
25812
26108
  });
25813
26109
 
@@ -25841,7 +26137,7 @@ describe('${moduleName}', function() {
25841
26137
  : ${moduleName};
25842
26138
  return instance;
25843
26139
  }).to.not.throw();
25844
- });
26140
+ });${depTest}${callerTest}
25845
26141
  });
25846
26142
  });
25847
26143
  `;
@@ -25889,7 +26185,7 @@ var PytestGenerator = class extends BaseTestGenerator {
25889
26185
  * Generate complete test file from analysis
25890
26186
  */
25891
26187
  generateTests(context2) {
25892
- const { moduleName, importPath, testType, patterns, analysis } = context2;
26188
+ const { moduleName, importPath, testType, patterns, analysis, dependencies } = context2;
25893
26189
  if (!analysis || analysis.functions.length === 0 && analysis.classes.length === 0) {
25894
26190
  return this.generateStubTests(context2);
25895
26191
  }
@@ -25897,8 +26193,18 @@ var PytestGenerator = class extends BaseTestGenerator {
25897
26193
  const exports = this.extractExports(analysis.functions, analysis.classes);
25898
26194
  const pythonImport = importPath.replace(/\//g, ".").replace(/\.(ts|js)$/, "");
25899
26195
  const importStatement = exports.length > 0 ? `from ${pythonImport} import ${exports.join(", ")}` : `import ${pythonImport} as ${moduleName}`;
26196
+ let mockImport = "";
26197
+ if (dependencies && dependencies.imports.length > 0) {
26198
+ mockImport = `from unittest.mock import patch, MagicMock
26199
+ `;
26200
+ }
26201
+ const depsToMock = dependencies?.imports.slice(0, 5) || [];
26202
+ const patchDecorators = depsToMock.map((dep) => {
26203
+ const depModule = dep.replace(/\//g, ".").replace(/\.py$/, "");
26204
+ return `@patch('${depModule}')`;
26205
+ });
25900
26206
  let code = `${patternComment}import pytest
25901
- ${importStatement}
26207
+ ${mockImport}${importStatement}
25902
26208
 
25903
26209
 
25904
26210
  class Test${this.pascalCase(moduleName)}:
@@ -25906,7 +26212,7 @@ class Test${this.pascalCase(moduleName)}:
25906
26212
 
25907
26213
  `;
25908
26214
  for (const fn of analysis.functions) {
25909
- code += this.generateFunctionTests(fn, testType);
26215
+ code += this.generateFunctionTestsWithPatches(fn, testType, patchDecorators);
25910
26216
  }
25911
26217
  for (const cls of analysis.classes) {
25912
26218
  code += this.generateClassTests(cls, testType);
@@ -25917,8 +26223,18 @@ class Test${this.pascalCase(moduleName)}:
25917
26223
  * Generate tests for a standalone function
25918
26224
  */
25919
26225
  generateFunctionTests(fn, _testType) {
26226
+ return this.generateFunctionTestsWithPatches(fn, _testType, []);
26227
+ }
26228
+ /**
26229
+ * Generate tests for a function with @patch decorators from KG dependencies
26230
+ */
26231
+ generateFunctionTestsWithPatches(fn, _testType, patchDecorators) {
25920
26232
  const validParams = fn.parameters.map((p74) => this.generatePythonTestValue(p74)).join(", ");
25921
- let code = ` def test_${fn.name}_valid_input(self):
26233
+ const mockParams = patchDecorators.map((_56, i58) => `mock_dep_${i58}`).reverse().join(", ");
26234
+ const allParams = mockParams ? `self, ${mockParams}` : "self";
26235
+ const patchPrefix = patchDecorators.map((d74) => ` ${d74}
26236
+ `).join("");
26237
+ let code = `${patchPrefix} def test_${fn.name}_valid_input(${allParams}):
25922
26238
  `;
25923
26239
  code += ` """Test ${fn.name} with valid input"""
25924
26240
  `;
@@ -25929,7 +26245,7 @@ class Test${this.pascalCase(moduleName)}:
25929
26245
  `;
25930
26246
  for (const param of fn.parameters) {
25931
26247
  if (!param.optional && param.type?.includes("str")) {
25932
- code += ` def test_${fn.name}_empty_${param.name}(self):
26248
+ code += `${patchPrefix} def test_${fn.name}_empty_${param.name}(${allParams}):
25933
26249
  `;
25934
26250
  code += ` """Test ${fn.name} with empty ${param.name}"""
25935
26251
  `;
@@ -25984,21 +26300,84 @@ class Test${cls.name}:
25984
26300
  * Generate stub tests when no AST analysis is available
25985
26301
  */
25986
26302
  generateStubTests(context2) {
25987
- const { moduleName, importPath, testType, patterns } = context2;
26303
+ const { moduleName, importPath, testType, patterns, dependencies, similarCode } = context2;
25988
26304
  const patternComment = this.generatePythonPatternComment(patterns);
25989
26305
  const isAsync = patterns.some(
25990
26306
  (p74) => p74.name.toLowerCase().includes("async") || p74.name.toLowerCase().includes("promise")
25991
26307
  );
25992
26308
  const asyncDecorator = isAsync ? "@pytest.mark.asyncio\n " : "";
25993
26309
  const asyncDef = isAsync ? "async def" : "def";
26310
+ let mockImports = "";
26311
+ let mockPatches = "";
26312
+ if (dependencies && dependencies.imports.length > 0) {
26313
+ mockImports = `from unittest.mock import patch, MagicMock
26314
+ `;
26315
+ const depsToMock = dependencies.imports.slice(0, 5);
26316
+ for (const dep of depsToMock) {
26317
+ const depModule = dep.replace(/\//g, ".").replace(/\.py$/, "");
26318
+ mockPatches += ` @patch('${depModule}')
26319
+ `;
26320
+ }
26321
+ }
26322
+ let similarityComment = "";
26323
+ if (similarCode && similarCode.snippets.length > 0) {
26324
+ similarityComment = ` # KG: Similar modules found - consider testing shared patterns:
26325
+ `;
26326
+ for (const s70 of similarCode.snippets.slice(0, 3)) {
26327
+ similarityComment += ` # - ${s70.file} (${(s70.score * 100).toFixed(0)}% similar)
26328
+ `;
26329
+ }
26330
+ similarityComment += `
26331
+ `;
26332
+ }
26333
+ let depTests = "";
26334
+ if (dependencies && dependencies.imports.length > 0) {
26335
+ depTests += `
26336
+ def test_dependencies_importable(self):
26337
+ `;
26338
+ depTests += ` """Verify all dependencies are importable (KG-informed)."""
26339
+ `;
26340
+ for (const dep of dependencies.imports.slice(0, 5)) {
26341
+ const depModule = dep.replace(/\//g, ".").replace(/\.py$/, "");
26342
+ depTests += ` import importlib
26343
+ `;
26344
+ depTests += ` mod = importlib.import_module('${depModule}')
26345
+ `;
26346
+ depTests += ` assert mod is not None
26347
+ `;
26348
+ }
26349
+ depTests += `
26350
+ def test_dependency_interactions(self):
26351
+ `;
26352
+ depTests += ` """Test module interactions with its dependencies (KG-informed)."""
26353
+ `;
26354
+ depTests += ` # Module should handle dependency failures gracefully
26355
+ `;
26356
+ depTests += ` assert ${moduleName} is not None
26357
+ `;
26358
+ depTests += ` assert hasattr(${moduleName}, '__name__') or hasattr(${moduleName}, '__class__')
26359
+ `;
26360
+ }
26361
+ let callerTests = "";
26362
+ if (dependencies && dependencies.importedBy.length > 0) {
26363
+ callerTests += `
26364
+ def test_public_api_surface(self):
26365
+ `;
26366
+ callerTests += ` """Verify public API used by ${dependencies.importedBy.length} consumers (KG-informed)."""
26367
+ `;
26368
+ callerTests += ` public_attrs = [a for a in dir(${moduleName}) if not a.startswith('_')]
26369
+ `;
26370
+ callerTests += ` assert len(public_attrs) > 0, "Module should expose public API"
26371
+ `;
26372
+ }
25994
26373
  return `${patternComment}import pytest
25995
- from ${importPath} import ${moduleName}
26374
+ ${mockImports}from ${importPath} import ${moduleName}
25996
26375
 
25997
26376
 
25998
26377
  class Test${this.pascalCase(moduleName)}:
25999
26378
  """${testType} tests for ${moduleName}"""
26000
26379
 
26001
- def test_is_defined(self):
26380
+ ${similarityComment} def test_is_defined(self):
26002
26381
  """Verify the module is properly exported and defined."""
26003
26382
  assert ${moduleName} is not None
26004
26383
 
@@ -26032,7 +26411,7 @@ class Test${this.pascalCase(moduleName)}:
26032
26411
  except TypeError:
26033
26412
  # Expected if constructor requires arguments
26034
26413
  pass
26035
- `;
26414
+ ${depTests}${callerTests}`;
26036
26415
  }
26037
26416
  /**
26038
26417
  * Generate coverage-focused tests for specific lines
@@ -27050,10 +27429,46 @@ var TestGeneratorService = class {
27050
27429
  * Enhance generated test code using LLM
27051
27430
  * Adds edge cases, improves assertions, and adds documentation
27052
27431
  */
27053
- async enhanceTestWithLLM(testCode, sourceCode, analysis) {
27432
+ async enhanceTestWithLLM(testCode, sourceCode, analysis, context2) {
27054
27433
  if (!this.llmRouter) return testCode;
27055
27434
  try {
27056
- const prompt = this.buildTestEnhancementPrompt(testCode, sourceCode, analysis);
27435
+ let prompt = this.buildTestEnhancementPrompt(testCode, sourceCode, analysis);
27436
+ if (context2?.dependencies) {
27437
+ prompt += `
27438
+ ## Dependency Context (from Knowledge Graph):
27439
+ `;
27440
+ if (context2.dependencies.imports.length > 0) {
27441
+ prompt += `- Imports: ${context2.dependencies.imports.join(", ")}
27442
+ `;
27443
+ prompt += ` \u2192 Generate mock declarations for these dependencies
27444
+ `;
27445
+ }
27446
+ if (context2.dependencies.importedBy.length > 0) {
27447
+ prompt += `- Imported by: ${context2.dependencies.importedBy.join(", ")}
27448
+ `;
27449
+ prompt += ` \u2192 Focus tests on the public API surface these consumers use
27450
+ `;
27451
+ }
27452
+ if (context2.dependencies.callers.length > 0) {
27453
+ prompt += `- Called by: ${context2.dependencies.callers.join(", ")}
27454
+ `;
27455
+ }
27456
+ if (context2.dependencies.callees.length > 0) {
27457
+ prompt += `- Calls: ${context2.dependencies.callees.join(", ")}
27458
+ `;
27459
+ }
27460
+ }
27461
+ if (context2?.similarCode && context2.similarCode.snippets.length > 0) {
27462
+ prompt += `
27463
+ ## Similar Code Patterns (from Knowledge Graph):
27464
+ `;
27465
+ for (const s70 of context2.similarCode.snippets.slice(0, 3)) {
27466
+ prompt += `- ${s70.file} (similarity: ${(s70.score * 100).toFixed(0)}%): ${s70.snippet}
27467
+ `;
27468
+ }
27469
+ prompt += ` \u2192 Use similar patterns as templates for assertions
27470
+ `;
27471
+ }
27057
27472
  const modelId = this.getModelForTier(this.config.llmModelTier);
27058
27473
  const response = await this.llmRouter.chat({
27059
27474
  messages: [
@@ -27293,6 +27708,15 @@ ${sourceCode}
27293
27708
  codeAnalysis = this.analyzeSourceCode(sourceContent, sourceFile);
27294
27709
  } catch {
27295
27710
  }
27711
+ let dependencies;
27712
+ let similarCode;
27713
+ if (this.memory && sourceContent) {
27714
+ const hasKGVectors = await this.hasKGVectors();
27715
+ if (hasKGVectors) {
27716
+ dependencies = await this.queryKGDependencies(sourceFile, sourceContent);
27717
+ similarCode = await this.queryKGSimilarCode(sourceContent);
27718
+ }
27719
+ }
27296
27720
  const generator = this.generatorFactory.create(framework);
27297
27721
  const moduleName = this.extractModuleName(sourceFile);
27298
27722
  const importPath = this.getImportPath(sourceFile);
@@ -27301,11 +27725,13 @@ ${sourceCode}
27301
27725
  importPath,
27302
27726
  testType,
27303
27727
  patterns: applicablePatterns,
27304
- analysis: codeAnalysis ?? void 0
27728
+ analysis: codeAnalysis ?? void 0,
27729
+ dependencies,
27730
+ similarCode
27305
27731
  };
27306
27732
  let testCode = generator.generateTests(context2);
27307
27733
  if (this.isLLMEnhancementAvailable() && sourceContent) {
27308
- testCode = await this.enhanceTestWithLLM(testCode, sourceContent, codeAnalysis);
27734
+ testCode = await this.enhanceTestWithLLM(testCode, sourceContent, codeAnalysis, context2);
27309
27735
  }
27310
27736
  const test = {
27311
27737
  id: v4_default(),
@@ -27500,6 +27926,107 @@ ${sourceCode}
27500
27926
  return complexity;
27501
27927
  }
27502
27928
  // ============================================================================
27929
+ // Private Helper Methods - Knowledge Graph Queries
27930
+ // ============================================================================
27931
+ /**
27932
+ * Check if KG vectors exist by probing a vector search.
27933
+ * Returns true if vectorSearch returns any results (indicating indexed code exists).
27934
+ */
27935
+ async hasKGVectors() {
27936
+ try {
27937
+ const probe = new Array(768).fill(0);
27938
+ probe[0] = 1;
27939
+ const results = await this.memory.vectorSearch(probe, 1);
27940
+ return results.length > 0;
27941
+ } catch {
27942
+ return false;
27943
+ }
27944
+ }
27945
+ /**
27946
+ * Query KG for dependency information about a file.
27947
+ * Extracts imports from source and cross-references with KG vector index
27948
+ * to find which indexed modules this file depends on and which depend on it.
27949
+ */
27950
+ async queryKGDependencies(filePath, sourceContent) {
27951
+ try {
27952
+ const imports = [];
27953
+ const importedBy = [];
27954
+ const callees = [];
27955
+ const callers = [];
27956
+ const tsImports = sourceContent.matchAll(/(?:import|from)\s+['"]([^'"]+)['"]/g);
27957
+ const pyImports = sourceContent.matchAll(/(?:^|\n)\s*(?:from\s+(\S+)\s+import|import\s+(\S+))/g);
27958
+ for (const match of tsImports) {
27959
+ imports.push(match[1]);
27960
+ }
27961
+ for (const match of pyImports) {
27962
+ imports.push(match[1] || match[2]);
27963
+ }
27964
+ const normalizedPath = filePath.replace(/\\/g, "/");
27965
+ const baseName = normalizedPath.split("/").pop()?.replace(/\.(ts|js|tsx|jsx|py)$/, "") || "";
27966
+ const nodeKeys = await this.memory.search(`code-intelligence:kg:node:*${baseName}*`, 50);
27967
+ for (const key of nodeKeys) {
27968
+ if (!key.includes(baseName)) continue;
27969
+ const parts = key.split(":");
27970
+ const nodeType = parts[parts.length - 2];
27971
+ const nodeName = parts[parts.length - 1];
27972
+ if (nodeType === "function") {
27973
+ callees.push(nodeName);
27974
+ }
27975
+ }
27976
+ if (imports.length === 0 && importedBy.length === 0 && callees.length === 0 && callers.length === 0) {
27977
+ return void 0;
27978
+ }
27979
+ return { imports, importedBy, callees, callers };
27980
+ } catch {
27981
+ return void 0;
27982
+ }
27983
+ }
27984
+ /**
27985
+ * Query KG for semantically similar code snippets.
27986
+ * Uses vector search against the persisted vectors table.
27987
+ * KG nodes are stored as vectors with IDs like code-intelligence:kg:node:*
27988
+ */
27989
+ async queryKGSimilarCode(sourceContent) {
27990
+ try {
27991
+ const embedding = this.generatePseudoEmbedding(sourceContent);
27992
+ const results = await this.memory.vectorSearch(embedding, 5);
27993
+ if (results.length === 0) return void 0;
27994
+ const snippets = [];
27995
+ for (const result of results) {
27996
+ if (result.score < 0.1) continue;
27997
+ const metadata = result.metadata;
27998
+ const file = metadata?.file || result.key;
27999
+ const snippet = metadata?.name || metadata?.type || result.key.split(":").pop() || "";
28000
+ snippets.push({ file, snippet, score: result.score });
28001
+ }
28002
+ return snippets.length > 0 ? { snippets } : void 0;
28003
+ } catch {
28004
+ return void 0;
28005
+ }
28006
+ }
28007
+ /**
28008
+ * Generate a simple pseudo-embedding for vector search.
28009
+ * Uses token-based feature extraction similar to semantic-analyzer.
28010
+ */
28011
+ generatePseudoEmbedding(code) {
28012
+ const dimension = 768;
28013
+ const embedding = new Array(dimension).fill(0);
28014
+ const tokens = code.split(/[^a-zA-Z0-9_$]+/).filter((t50) => t50.length > 1);
28015
+ for (let i58 = 0; i58 < tokens.length; i58++) {
28016
+ const token = tokens[i58];
28017
+ for (let j52 = 0; j52 < token.length && j52 < embedding.length; j52++) {
28018
+ embedding[(i58 + j52) % dimension] += token.charCodeAt(j52) / 1e3;
28019
+ }
28020
+ }
28021
+ const magnitude2 = Math.sqrt(embedding.reduce((sum, v62) => sum + v62 * v62, 0));
28022
+ if (magnitude2 > 0) {
28023
+ for (let i58 = 0; i58 < dimension; i58++) {
28024
+ embedding[i58] /= magnitude2;
28025
+ }
28026
+ }
28027
+ return embedding;
28028
+ }
28029
+ // ============================================================================
27503
28030
  // Private Helper Methods - Utility Functions
27504
28031
  // ============================================================================
27505
28032
  async findApplicablePatterns(sourceFile, requestedPatterns) {
@@ -28853,6 +29380,7 @@ var TypeScriptASTParser = class {
28853
29380
  // src/learning/qe-hooks.ts
28854
29381
  init_error_utils();
28855
29382
  init_logging();
29383
+ init_qe_patterns();
28856
29384
  var logger5 = LoggerFactory.create("qe-hooks");
28857
29385
  var QE_HOOK_EVENTS = {
28858
29386
  // Test lifecycle
@@ -29133,9 +29661,36 @@ ${suggestedTests}`,
29133
29661
  },
29134
29662
  [QE_HOOK_EVENTS.QEAgentCompletion]: async (ctx) => {
29135
29663
  const { agentType, task, success, duration, patternId, feedback } = ctx.data;
29136
- if (patternId) {
29664
+ let patternsLearned = 0;
29665
+ const effectivePatternId = patternId;
29666
+ if (effectivePatternId) {
29667
+ try {
29668
+ const existing = await reasoningBank.getPattern(effectivePatternId);
29669
+ if (!existing) {
29670
+ const agent = agentType || "unknown";
29671
+ const domain = detectQEDomain(task || agent) || "learning-optimization";
29672
+ await reasoningBank.storePattern({
29673
+ patternType: "test-template",
29674
+ qeDomain: domain,
29675
+ name: `Auto: ${agent} completion`,
29676
+ description: `Auto-created pattern for ${agent} task completion tracking`,
29677
+ template: {
29678
+ type: "prompt",
29679
+ content: `Agent ${agent} task pattern`,
29680
+ variables: []
29681
+ },
29682
+ context: {
29683
+ tags: ["auto-created", "agent-completion", agent]
29684
+ },
29685
+ confidence: 0.5
29686
+ });
29687
+ patternsLearned = 1;
29688
+ }
29689
+ } catch (e20) {
29690
+ logger5.debug("Auto-create pattern failed", { error: e20 instanceof Error ? e20.message : String(e20) });
29691
+ }
29137
29692
  await reasoningBank.recordOutcome({
29138
- patternId,
29693
+ patternId: effectivePatternId,
29139
29694
  success,
29140
29695
  metrics: {
29141
29696
  executionTimeMs: duration
@@ -29145,6 +29700,7 @@ ${suggestedTests}`,
29145
29700
  }
29146
29701
  return {
29147
29702
  success: true,
29703
+ patternsLearned,
29148
29704
  data: { agentType, success, duration }
29149
29705
  };
29150
29706
  },
@@ -114762,7 +115318,7 @@ var ALL_DOMAINS2 = [
114762
115318
  "enterprise-integration"
114763
115319
  ];
114764
115320
  function getAQEVersion() {
114765
- return true ? "3.6.9" : "3.0.0";
115321
+ return true ? "3.6.10" : "3.0.0";
114766
115322
  }
114767
115323
  function createDefaultConfig(projectName, projectRoot) {
114768
115324
  return {
@@ -122595,6 +123151,14 @@ function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
122595
123151
  console.log(` ${chalk9.white(test.name)}`);
122596
123152
  console.log(chalk9.gray(` Source: ${path26.basename(test.sourceFile)}`));
122597
123153
  console.log(chalk9.gray(` Assertions: ${test.assertions}`));
123154
+ if (test.testCode) {
123155
+ console.log(chalk9.gray(` Test File: ${test.testFile}`));
123156
+ console.log(`
123157
+ --- Generated Code ---`);
123158
+ console.log(test.testCode);
123159
+ console.log(`--- End Generated Code ---
123160
+ `);
123161
+ }
122598
123162
  }
122599
123163
  if (generated.tests.length > 10) {
122600
123164
  console.log(chalk9.gray(` ... and ${generated.tests.length - 10} more`));
@@ -137156,6 +137720,34 @@ async function incrementDreamExperience(memoryBackend2) {
137156
137720
  return 0;
137157
137721
  }
137158
137722
  }
137723
+ async function persistCommandExperience(opts) {
137724
+ try {
137725
+ const { getUnifiedMemory: getUnifiedMemory2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
137726
+ const um = getUnifiedMemory2();
137727
+ if (!um.isInitialized()) {
137728
+ await um.initialize();
137729
+ }
137730
+ const db = um.getDatabase();
137731
+ const id = `cli-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
137732
+ db.prepare(`
137733
+ INSERT OR REPLACE INTO captured_experiences
137734
+ (id, task, agent, domain, success, quality, duration_ms,
137735
+ started_at, completed_at, source)
137736
+ VALUES (?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'), ?)
137737
+ `).run(
137738
+ id,
137739
+ opts.task.slice(0, 500),
137740
+ opts.agent,
137741
+ opts.domain,
137742
+ opts.success ? 1 : 0,
137743
+ opts.success ? 0.7 : 0.3,
137744
+ opts.durationMs || 0,
137745
+ opts.source
137746
+ );
137747
+ } catch (error) {
137748
+ console.error(chalk27.dim(`[hooks] persistCommandExperience: ${error instanceof Error ? error.message : "unknown"}`));
137749
+ }
137750
+ }
137159
137751
  function printGuidance(guidance) {
137160
137752
  if (guidance.length === 0) {
137161
137753
  console.log(chalk27.dim(" No specific guidance"));
@@ -137237,14 +137829,39 @@ Examples:
137237
137829
  try {
137238
137830
  const { hookRegistry } = await getHooksSystem();
137239
137831
  const success = options.success || !options.failure;
137832
+ const filePath = options.file || "";
137833
+ const fileName = filePath.split("/").pop() || "unknown";
137834
+ const isTestFile2 = /\.(test|spec)\.(ts|js|tsx|jsx)$/.test(fileName);
137835
+ const domain = isTestFile2 ? "test-generation" : "code-intelligence";
137836
+ const syntheticPatternId = options.patternId || `edit:${domain}:${fileName}`;
137240
137837
  const results = await hookRegistry.emit(QE_HOOK_EVENTS.PostTestGeneration, {
137241
137838
  targetFile: options.file,
137242
137839
  success,
137243
- patternId: options.patternId,
137840
+ patternId: syntheticPatternId,
137244
137841
  generatedTests: null,
137245
137842
  testCount: 0
137246
137843
  });
137247
137844
  const result = results[0] || { success: true, patternsLearned: 0 };
137845
+ try {
137846
+ const { reasoningBank } = await getHooksSystem();
137847
+ await reasoningBank.recordOutcome({
137848
+ patternId: syntheticPatternId,
137849
+ success,
137850
+ metrics: { executionTimeMs: 0 },
137851
+ feedback: `Edit ${success ? "succeeded" : "failed"}: ${filePath}`
137852
+ });
137853
+ } catch {
137854
+ }
137855
+ try {
137856
+ await persistCommandExperience({
137857
+ task: `edit: ${filePath}`,
137858
+ agent: "cli-hook",
137859
+ domain,
137860
+ success,
137861
+ source: "cli-hook-post-edit"
137862
+ });
137863
+ } catch {
137864
+ }
137248
137865
  let dreamTriggered = false;
137249
137866
  try {
137250
137867
  const projectRoot = findProjectRoot();
@@ -137314,6 +137931,45 @@ Examples:
137314
137931
  printGuidance(routing.guidance);
137315
137932
  console.log(chalk27.bold("\n\u{1F4D6} Reasoning:"), chalk27.dim(routing.reasoning));
137316
137933
  }
137934
+ try {
137935
+ const { getUnifiedMemory: getUnifiedMemory2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
137936
+ const um = getUnifiedMemory2();
137937
+ if (!um.isInitialized()) {
137938
+ await um.initialize();
137939
+ }
137940
+ const db = um.getDatabase();
137941
+ const outcomeId = `route-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
137942
+ db.prepare(`
137943
+ INSERT OR REPLACE INTO routing_outcomes (
137944
+ id, task_json, decision_json, used_agent,
137945
+ followed_recommendation, success, quality_score,
137946
+ duration_ms, error
137947
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
137948
+ `).run(
137949
+ outcomeId,
137950
+ JSON.stringify({ description: options.task, domain: options.domain }),
137951
+ JSON.stringify({
137952
+ recommended: routing.recommendedAgent,
137953
+ confidence: routing.confidence,
137954
+ alternatives: routing.alternatives
137955
+ }),
137956
+ routing.recommendedAgent,
137957
+ 1,
137958
+ // followed_recommendation = true (recommendation stage)
137959
+ 1,
137960
+ // success = true (routing itself succeeded)
137961
+ routing.confidence,
137962
+ 0,
137963
+ // duration not tracked at routing stage
137964
+ null
137965
+ );
137966
+ const projectRoot = findProjectRoot();
137967
+ const dataDir = path22.join(projectRoot, ".agentic-qe");
137968
+ const memoryBackend2 = await createHybridBackendWithTimeout(dataDir);
137969
+ await incrementDreamExperience(memoryBackend2);
137970
+ } catch (persistError) {
137971
+ console.error(chalk27.dim(`[hooks] route persist: ${persistError instanceof Error ? persistError.message : "unknown"}`));
137972
+ }
137317
137973
  process.exit(0);
137318
137974
  } catch (error) {
137319
137975
  printError(`route failed: ${error instanceof Error ? error.message : "unknown"}`);
@@ -137828,12 +138484,57 @@ Registered: ${events.length}/${Object.keys(QE_HOOK_EVENTS).length}`)
137828
138484
  try {
137829
138485
  const success = options.success === "true" || options.success === true;
137830
138486
  const exitCode = options.exitCode ? parseInt(options.exitCode, 10) : success ? 0 : 1;
138487
+ const command = (options.command || "").substring(0, 200);
138488
+ const isTestCmd = /\b(test|vitest|jest|pytest|mocha)\b/i.test(command);
138489
+ const isBuildCmd = /\b(build|compile|tsc)\b/i.test(command);
138490
+ const isLintCmd = /\b(lint|eslint|prettier)\b/i.test(command);
138491
+ let patternsLearned = 0;
138492
+ let experienceRecorded = false;
138493
+ try {
138494
+ const { reasoningBank } = await getHooksSystem();
138495
+ if (isTestCmd) {
138496
+ const { hookRegistry } = await getHooksSystem();
138497
+ await hookRegistry.emit(QE_HOOK_EVENTS.TestExecutionResult, {
138498
+ runId: `cmd-${Date.now()}`,
138499
+ patternId: `cmd:test:${command.split(/\s+/).slice(0, 3).join("-")}`,
138500
+ passed: success ? 1 : 0,
138501
+ failed: success ? 0 : 1,
138502
+ duration: 0,
138503
+ flaky: false
138504
+ });
138505
+ }
138506
+ const cmdSlug = command.replace(/[^a-zA-Z0-9]/g, "-").slice(0, 80);
138507
+ const domain = isTestCmd ? "test-execution" : isBuildCmd ? "code-intelligence" : isLintCmd ? "quality-assessment" : "code-intelligence";
138508
+ await reasoningBank.recordOutcome({
138509
+ patternId: `cmd:${cmdSlug}`,
138510
+ success,
138511
+ metrics: { executionTimeMs: 0 },
138512
+ feedback: `Command: ${command}, exit: ${exitCode}`
138513
+ });
138514
+ patternsLearned = 1;
138515
+ await persistCommandExperience({
138516
+ task: `bash: ${command}`,
138517
+ agent: "cli-hook",
138518
+ domain,
138519
+ success,
138520
+ source: "cli-hook-post-command"
138521
+ });
138522
+ experienceRecorded = true;
138523
+ const projectRoot = findProjectRoot();
138524
+ const dataDir = path22.join(projectRoot, ".agentic-qe");
138525
+ const memoryBackend2 = await createHybridBackendWithTimeout(dataDir);
138526
+ await incrementDreamExperience(memoryBackend2);
138527
+ } catch (initError) {
138528
+ console.error(chalk27.dim(`[hooks] post-command learning: ${initError instanceof Error ? initError.message : "unknown"}`));
138529
+ }
137831
138530
  if (options.json) {
137832
138531
  printJson({
137833
138532
  success: true,
137834
- command: (options.command || "").substring(0, 100),
138533
+ command: command.substring(0, 100),
137835
138534
  commandSuccess: success,
137836
- exitCode
138535
+ exitCode,
138536
+ patternsLearned,
138537
+ experienceRecorded
137837
138538
  });
137838
138539
  }
137839
138540
  process.exit(0);
@@ -139589,7 +140290,7 @@ async function cleanupAndExit(code = 0) {
139589
140290
  process.exit(code);
139590
140291
  }
139591
140292
  var program = new Command18();
139592
- var VERSION = true ? "3.6.9" : "0.0.0-dev";
140293
+ var VERSION = true ? "3.6.10" : "0.0.0-dev";
139593
140294
  program.name("aqe").description("Agentic QE - Domain-Driven Quality Engineering").version(VERSION);
139594
140295
  var registry = createCommandRegistry(context, cleanupAndExit, ensureInitialized);
139595
140296
  registry.registerAll(program);