agentic-qe 3.6.10 → 3.6.11

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 (71) hide show
  1. package/.claude/skills/skills-manifest.json +1 -1
  2. package/package.json +1 -1
  3. package/v3/CHANGELOG.md +25 -0
  4. package/v3/dist/cli/bundle.js +464 -339
  5. package/v3/dist/cli/commands/code.d.ts.map +1 -1
  6. package/v3/dist/cli/commands/code.js +9 -85
  7. package/v3/dist/cli/commands/code.js.map +1 -1
  8. package/v3/dist/cli/commands/coverage.d.ts.map +1 -1
  9. package/v3/dist/cli/commands/coverage.js +3 -28
  10. package/v3/dist/cli/commands/coverage.js.map +1 -1
  11. package/v3/dist/cli/commands/security.d.ts.map +1 -1
  12. package/v3/dist/cli/commands/security.js +3 -29
  13. package/v3/dist/cli/commands/security.js.map +1 -1
  14. package/v3/dist/cli/commands/test.d.ts.map +1 -1
  15. package/v3/dist/cli/commands/test.js +5 -58
  16. package/v3/dist/cli/commands/test.js.map +1 -1
  17. package/v3/dist/cli/utils/file-discovery.d.ts +27 -0
  18. package/v3/dist/cli/utils/file-discovery.d.ts.map +1 -0
  19. package/v3/dist/cli/utils/file-discovery.js +105 -0
  20. package/v3/dist/cli/utils/file-discovery.js.map +1 -0
  21. package/v3/dist/coordination/task-executor.d.ts.map +1 -1
  22. package/v3/dist/coordination/task-executor.js +304 -44
  23. package/v3/dist/coordination/task-executor.js.map +1 -1
  24. package/v3/dist/domains/code-intelligence/coordinator.d.ts.map +1 -1
  25. package/v3/dist/domains/code-intelligence/coordinator.js +8 -1
  26. package/v3/dist/domains/code-intelligence/coordinator.js.map +1 -1
  27. package/v3/dist/domains/code-intelligence/services/metric-collector/index.d.ts.map +1 -1
  28. package/v3/dist/domains/code-intelligence/services/metric-collector/index.js +10 -0
  29. package/v3/dist/domains/code-intelligence/services/metric-collector/index.js.map +1 -1
  30. package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.d.ts +7 -1
  31. package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.d.ts.map +1 -1
  32. package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.js +10 -1
  33. package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.js.map +1 -1
  34. package/v3/dist/domains/code-intelligence/services/metric-collector/loc-counter.js +34 -10
  35. package/v3/dist/domains/code-intelligence/services/metric-collector/loc-counter.js.map +1 -1
  36. package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts +9 -0
  37. package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts.map +1 -1
  38. package/v3/dist/domains/coverage-analysis/services/hnsw-index.js +38 -3
  39. package/v3/dist/domains/coverage-analysis/services/hnsw-index.js.map +1 -1
  40. package/v3/dist/init/init-wizard-hooks.d.ts +8 -1
  41. package/v3/dist/init/init-wizard-hooks.d.ts.map +1 -1
  42. package/v3/dist/init/init-wizard-hooks.js +47 -39
  43. package/v3/dist/init/init-wizard-hooks.js.map +1 -1
  44. package/v3/dist/init/phases/07-hooks.d.ts +11 -1
  45. package/v3/dist/init/phases/07-hooks.d.ts.map +1 -1
  46. package/v3/dist/init/phases/07-hooks.js +46 -50
  47. package/v3/dist/init/phases/07-hooks.js.map +1 -1
  48. package/v3/dist/init/settings-merge.d.ts +35 -0
  49. package/v3/dist/init/settings-merge.d.ts.map +1 -0
  50. package/v3/dist/init/settings-merge.js +140 -0
  51. package/v3/dist/init/settings-merge.js.map +1 -0
  52. package/v3/dist/integrations/agentic-flow/model-router/router.js +1 -1
  53. package/v3/dist/integrations/agentic-flow/model-router/router.js.map +1 -1
  54. package/v3/dist/integrations/agentic-flow/model-router/score-calculator.d.ts.map +1 -1
  55. package/v3/dist/integrations/agentic-flow/model-router/score-calculator.js +18 -3
  56. package/v3/dist/integrations/agentic-flow/model-router/score-calculator.js.map +1 -1
  57. package/v3/dist/integrations/agentic-flow/model-router/signal-collector.d.ts +3 -3
  58. package/v3/dist/integrations/agentic-flow/model-router/signal-collector.d.ts.map +1 -1
  59. package/v3/dist/integrations/agentic-flow/model-router/signal-collector.js +18 -0
  60. package/v3/dist/integrations/agentic-flow/model-router/signal-collector.js.map +1 -1
  61. package/v3/dist/mcp/bundle.js +546 -96
  62. package/v3/dist/mcp/handlers/domain-handler-configs.d.ts.map +1 -1
  63. package/v3/dist/mcp/handlers/domain-handler-configs.js +40 -31
  64. package/v3/dist/mcp/handlers/domain-handler-configs.js.map +1 -1
  65. package/v3/dist/mcp/handlers/task-handlers.d.ts.map +1 -1
  66. package/v3/dist/mcp/handlers/task-handlers.js +68 -5
  67. package/v3/dist/mcp/handlers/task-handlers.js.map +1 -1
  68. package/v3/dist/mcp/protocol-server.d.ts.map +1 -1
  69. package/v3/dist/mcp/protocol-server.js +16 -2
  70. package/v3/dist/mcp/protocol-server.js.map +1 -1
  71. package/v3/package.json +1 -1
@@ -8841,7 +8841,7 @@ var init_hnsw_index = __esm({
8841
8841
  if (!this.initialized) {
8842
8842
  await this.initialize();
8843
8843
  }
8844
- this.validateVector(vector);
8844
+ vector = this.validateVector(vector);
8845
8845
  if (this.keyToLabel.has(key)) {
8846
8846
  await this.delete(key);
8847
8847
  }
@@ -8870,7 +8870,7 @@ var init_hnsw_index = __esm({
8870
8870
  if (!this.initialized) {
8871
8871
  await this.initialize();
8872
8872
  }
8873
- this.validateVector(query);
8873
+ query = this.validateVector(query);
8874
8874
  const startTime = performance.now();
8875
8875
  const results = this.stats.vectorCount > 0 ? this.searchRuvector(query, k68) : [];
8876
8876
  const endTime = performance.now();
@@ -8995,17 +8995,46 @@ var init_hnsw_index = __esm({
8995
8995
  // ============================================================================
8996
8996
  // Private Helper Methods
8997
8997
  // ============================================================================
8998
+ /**
8999
+ * Validate and auto-resize vectors to match HNSW configured dimensions.
9000
+ * Fix #279: Prevents Rust WASM panic when RealEmbeddings (768-dim) are
9001
+ * passed to a 128-dim HNSW index.
9002
+ */
8998
9003
  validateVector(vector) {
8999
9004
  if (vector.length !== this.config.dimensions) {
9000
- throw new Error(
9001
- `Vector dimension mismatch: expected ${this.config.dimensions}, got ${vector.length}`
9002
- );
9005
+ return this.resizeVector(vector, this.config.dimensions);
9003
9006
  }
9004
9007
  for (let i58 = 0; i58 < vector.length; i58++) {
9005
9008
  if (!Number.isFinite(vector[i58])) {
9006
9009
  throw new Error(`Invalid vector value at index ${i58}: ${vector[i58]}`);
9007
9010
  }
9008
9011
  }
9012
+ return vector;
9013
+ }
9014
+ /**
9015
+ * Resize vector to target dimensions using averaging (shrink) or zero-padding (grow).
9016
+ */
9017
+ resizeVector(vector, targetDim) {
9018
+ if (vector.length === targetDim) return vector;
9019
+ if (vector.length > targetDim) {
9020
+ const result2 = new Array(targetDim).fill(0);
9021
+ const ratio = vector.length / targetDim;
9022
+ for (let i58 = 0; i58 < targetDim; i58++) {
9023
+ const start = Math.floor(i58 * ratio);
9024
+ const end = Math.floor((i58 + 1) * ratio);
9025
+ let sum = 0;
9026
+ for (let j52 = start; j52 < end; j52++) {
9027
+ sum += vector[j52];
9028
+ }
9029
+ result2[i58] = sum / (end - start);
9030
+ }
9031
+ return result2;
9032
+ }
9033
+ const result = new Array(targetDim).fill(0);
9034
+ for (let i58 = 0; i58 < vector.length; i58++) {
9035
+ result[i58] = vector[i58];
9036
+ }
9037
+ return result;
9009
9038
  }
9010
9039
  buildKey(key) {
9011
9040
  return `${this.config.namespace}:${key}`;
@@ -70816,7 +70845,35 @@ import { join as join10, extname as extname3 } from "path";
70816
70845
  // src/domains/code-intelligence/services/metric-collector/interfaces.ts
70817
70846
  var DEFAULT_METRIC_CONFIG = {
70818
70847
  timeout: 6e4,
70819
- excludeDirs: ["node_modules", "dist", "coverage", "build", ".git", "vendor", "target"],
70848
+ excludeDirs: [
70849
+ // JS/TS ecosystem
70850
+ "node_modules",
70851
+ "dist",
70852
+ "build",
70853
+ "coverage",
70854
+ ".nyc_output",
70855
+ ".next",
70856
+ ".nuxt",
70857
+ ".output",
70858
+ // Python ecosystem
70859
+ "__pycache__",
70860
+ ".venv",
70861
+ "venv",
70862
+ ".tox",
70863
+ ".mypy_cache",
70864
+ ".pytest_cache",
70865
+ ".eggs",
70866
+ "*.egg-info",
70867
+ // Rust / Java / Go
70868
+ "target",
70869
+ ".gradle",
70870
+ "vendor",
70871
+ ".bundle",
70872
+ // General
70873
+ ".git",
70874
+ ".svn",
70875
+ ".hg"
70876
+ ],
70820
70877
  testPatterns: ["**/*.test.ts", "**/*.spec.ts", "**/*.test.js", "**/*.spec.js"],
70821
70878
  enableCache: true,
70822
70879
  cacheTTL: 3e5
@@ -70824,7 +70881,7 @@ var DEFAULT_METRIC_CONFIG = {
70824
70881
 
70825
70882
  // src/domains/code-intelligence/services/metric-collector/loc-counter.ts
70826
70883
  import { execSync as execSync3, spawnSync as spawnSync2 } from "child_process";
70827
- import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5 } from "fs";
70884
+ import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
70828
70885
  import { join as join8, extname } from "path";
70829
70886
  init_safe_json();
70830
70887
  async function countLOC(projectPath, config = {}) {
@@ -70968,22 +71025,35 @@ function getLanguageForExtension(ext) {
70968
71025
  function manualLOCCount(projectPath, config) {
70969
71026
  const byLanguage = {};
70970
71027
  let total = 0;
70971
- function walkDirectory3(dirPath) {
70972
- if (!existsSync6(dirPath)) {
71028
+ const excludeSet = new Set(config.excludeDirs);
71029
+ const MAX_FILE_SIZE = 2 * 1024 * 1024;
71030
+ function walkDirectory3(dirPath, depth) {
71031
+ if (!existsSync6(dirPath) || depth > 20) {
71032
+ return;
71033
+ }
71034
+ let entries;
71035
+ try {
71036
+ entries = readdirSync(dirPath, { withFileTypes: true });
71037
+ } catch {
70973
71038
  return;
70974
71039
  }
70975
- const entries = readdirSync(dirPath, { withFileTypes: true });
70976
71040
  for (const entry of entries) {
70977
71041
  const fullPath = join8(dirPath, entry.name);
70978
71042
  if (entry.isDirectory()) {
70979
- if (config.excludeDirs.includes(entry.name)) {
71043
+ if (excludeSet.has(entry.name) || entry.name.startsWith(".")) {
70980
71044
  continue;
70981
71045
  }
70982
- walkDirectory3(fullPath);
71046
+ walkDirectory3(fullPath, depth + 1);
70983
71047
  } else if (entry.isFile()) {
70984
71048
  const ext = extname(entry.name);
70985
71049
  const language = getLanguageForExtension(ext);
70986
71050
  if (language) {
71051
+ try {
71052
+ const stat4 = statSync2(fullPath);
71053
+ if (stat4.size > MAX_FILE_SIZE) continue;
71054
+ } catch {
71055
+ continue;
71056
+ }
70987
71057
  const lines = countFileLines(fullPath);
70988
71058
  byLanguage[language] = (byLanguage[language] || 0) + lines;
70989
71059
  total += lines;
@@ -70991,11 +71061,11 @@ function manualLOCCount(projectPath, config) {
70991
71061
  }
70992
71062
  }
70993
71063
  }
70994
- walkDirectory3(projectPath);
71064
+ walkDirectory3(projectPath, 0);
70995
71065
  return {
70996
71066
  total,
70997
71067
  byLanguage,
70998
- source: "fallback",
71068
+ source: "node-native",
70999
71069
  excludedDirs: config.excludeDirs
71000
71070
  };
71001
71071
  }
@@ -71626,12 +71696,19 @@ var MetricCollectorService = class {
71626
71696
  const toolsUsed = [];
71627
71697
  if (loc.source !== "fallback") toolsUsed.push(loc.source);
71628
71698
  if (tests.source !== "fallback") toolsUsed.push(tests.source);
71699
+ const locAccuracy = loc.source === "fallback" ? "approximate" : "accurate";
71700
+ const testAccuracy = tests.source === "fallback" ? "approximate" : "accurate";
71629
71701
  const metrics = {
71630
71702
  loc,
71631
71703
  tests,
71632
71704
  patterns,
71633
71705
  collectedAt: /* @__PURE__ */ new Date(),
71634
- toolsUsed
71706
+ toolsUsed,
71707
+ accuracy: {
71708
+ loc: locAccuracy,
71709
+ tests: testAccuracy,
71710
+ overall: locAccuracy === "accurate" && testAccuracy === "accurate" ? "accurate" : "approximate"
71711
+ }
71635
71712
  };
71636
71713
  if (this.config.enableCache) {
71637
71714
  this.setInCache(cacheKey, metrics);
@@ -73861,9 +73938,15 @@ var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
73861
73938
  try {
73862
73939
  console.log(`[CodeIntelligence] Collecting real metrics for ${projectPath}`);
73863
73940
  const metrics = await this.metricCollector.collectAll(projectPath);
73941
+ const toolsLabel = metrics.toolsUsed.length > 0 ? metrics.toolsUsed.join(", ") : metrics.loc.source === "node-native" ? "node-native" : "fallback";
73864
73942
  console.log(
73865
- `[CodeIntelligence] Real metrics collected: ${metrics.loc.total} LOC, ${metrics.tests.total} tests, tools: ${metrics.toolsUsed.join(", ") || "fallback"}`
73943
+ `[CodeIntelligence] Real metrics collected: ${metrics.loc.total} LOC, ${metrics.tests.total} tests, tools: ${toolsLabel}`
73866
73944
  );
73945
+ if (metrics.loc.source === "node-native") {
73946
+ console.log(
73947
+ `[CodeIntelligence] Using Node.js-native line counter (no cloc/tokei needed)`
73948
+ );
73949
+ }
73867
73950
  await this.storeProjectMetricsInMemory(projectPath, metrics);
73868
73951
  if (this.config.publishEvents) {
73869
73952
  const event = createEvent(
@@ -115318,7 +115401,7 @@ var ALL_DOMAINS2 = [
115318
115401
  "enterprise-integration"
115319
115402
  ];
115320
115403
  function getAQEVersion() {
115321
- return true ? "3.6.10" : "3.0.0";
115404
+ return true ? "3.6.11" : "3.0.0";
115322
115405
  }
115323
115406
  function createDefaultConfig(projectName, projectRoot) {
115324
115407
  return {
@@ -116525,6 +116608,110 @@ function readJsonSafe(filePath) {
116525
116608
  init_safe_json();
116526
116609
  import { existsSync as existsSync16, mkdirSync as mkdirSync6, writeFileSync as writeFileSync3, readFileSync as readFileSync13, copyFileSync as copyFileSync3 } from "fs";
116527
116610
  import { join as join18, dirname as dirname5 } from "path";
116611
+
116612
+ // src/init/settings-merge.ts
116613
+ var AQE_COMMAND_PATTERNS = [
116614
+ /\baqe\b/i,
116615
+ /\bagentic-qe\b/i,
116616
+ /\bnpx\s+agentic-qe\b/i,
116617
+ /\bnpx\s+@anthropics\/agentic-qe\b/i
116618
+ ];
116619
+ function isAqeHookEntry(entry) {
116620
+ const hookEntry = entry;
116621
+ if (!hookEntry?.hooks || !Array.isArray(hookEntry.hooks)) return false;
116622
+ return hookEntry.hooks.some((h66) => {
116623
+ if (!h66.command || typeof h66.command !== "string") return false;
116624
+ return AQE_COMMAND_PATTERNS.some((pattern) => pattern.test(h66.command));
116625
+ });
116626
+ }
116627
+ function mergeHooksSmart(existingHooks, newAqeHooks) {
116628
+ const merged = {};
116629
+ for (const [hookType, newEntries] of Object.entries(newAqeHooks)) {
116630
+ const existing = existingHooks[hookType] || [];
116631
+ const userEntries = Array.isArray(existing) ? existing.filter((entry) => !isAqeHookEntry(entry)) : [];
116632
+ merged[hookType] = [...newEntries, ...userEntries];
116633
+ }
116634
+ for (const [hookType, hookArray] of Object.entries(existingHooks)) {
116635
+ if (!merged[hookType]) {
116636
+ merged[hookType] = hookArray;
116637
+ }
116638
+ }
116639
+ return merged;
116640
+ }
116641
+ function generateAqeEnvVars(config) {
116642
+ const domains = config.domains?.enabled || [];
116643
+ return {
116644
+ AQE_MEMORY_PATH: ".agentic-qe/memory.db",
116645
+ AQE_MEMORY_ENABLED: "true",
116646
+ AQE_LEARNING_ENABLED: config.learning?.enabled ? "true" : "false",
116647
+ AQE_V3_MODE: "true",
116648
+ AQE_V3_DDD_ENABLED: "true",
116649
+ AQE_V3_DOMAINS: domains.join(","),
116650
+ AQE_V3_SWARM_SIZE: String(config.agents?.maxConcurrent ?? 15),
116651
+ AQE_V3_TOPOLOGY: "hierarchical",
116652
+ AQE_V3_SUBLINEAR_ENABLED: "true",
116653
+ AQE_V3_HNSW_ENABLED: config.learning?.hnswConfig ? "true" : "false",
116654
+ AQE_V3_HOOKS_ENABLED: "true",
116655
+ AQE_V3_HOOK_BRIDGE: ".claude/hooks/v3-qe-bridge.sh",
116656
+ AQE_V3_DOMAIN_WORKERS: ".claude/hooks/v3-domain-workers.json",
116657
+ AQE_V3_AISP_ENABLED: "true",
116658
+ AQE_V3_REASONING_BANK: ".agentic-qe/memory.db",
116659
+ AQE_V3_PATTERN_PROMOTION_THRESHOLD: String(config.learning?.promotionThreshold ?? 3),
116660
+ AQE_V3_SUCCESS_RATE_THRESHOLD: String(config.learning?.qualityThreshold ?? 0.7)
116661
+ };
116662
+ }
116663
+ function generateV3SettingsSections(config) {
116664
+ const domains = config.domains?.enabled || [];
116665
+ return {
116666
+ aqe: {
116667
+ version: config.version ?? "3.0.0",
116668
+ initialized: (/* @__PURE__ */ new Date()).toISOString(),
116669
+ hooksConfigured: true
116670
+ },
116671
+ statusLine: {
116672
+ type: "command",
116673
+ command: 'node .claude/helpers/statusline-v3.cjs 2>/dev/null || .claude/statusline-v3.sh 2>/dev/null || echo "\u258A Agentic QE v3"',
116674
+ refreshMs: 5e3,
116675
+ enabled: true
116676
+ },
116677
+ permissions: {
116678
+ allow: [
116679
+ "Bash(npx claude-flow:*)",
116680
+ "Bash(npx @claude-flow/cli:*)",
116681
+ "mcp__claude-flow__:*",
116682
+ "mcp__agentic_qe__*"
116683
+ ],
116684
+ deny: [
116685
+ "Bash(rm -rf /)"
116686
+ ]
116687
+ },
116688
+ includeCoAuthoredBy: true,
116689
+ v3Configuration: {
116690
+ domains: {
116691
+ total: domains.length,
116692
+ names: domains
116693
+ },
116694
+ swarm: {
116695
+ totalAgents: config.agents?.maxConcurrent ?? 15,
116696
+ topology: "hierarchical",
116697
+ coordination: "queen-led"
116698
+ }
116699
+ },
116700
+ v3Learning: {
116701
+ enabled: config.learning?.enabled ?? true,
116702
+ reasoningBank: {
116703
+ dbPath: ".agentic-qe/memory.db",
116704
+ enableHNSW: !!config.learning?.hnswConfig
116705
+ },
116706
+ patternPromotion: {
116707
+ threshold: config.learning?.promotionThreshold ?? 3,
116708
+ successRateMin: config.learning?.qualityThreshold ?? 0.7
116709
+ }
116710
+ }
116711
+ };
116712
+ }
116713
+
116714
+ // src/init/init-wizard-hooks.ts
116528
116715
  async function configureHooks(projectRoot, config) {
116529
116716
  if (!config.hooks.claudeCode) {
116530
116717
  return false;
@@ -116543,14 +116730,25 @@ async function configureHooks(projectRoot, config) {
116543
116730
  settings = {};
116544
116731
  }
116545
116732
  }
116546
- const hooks = {
116733
+ const aqeHooks = {
116547
116734
  PreToolUse: [
116548
116735
  {
116549
116736
  matcher: "^(Write|Edit|MultiEdit)$",
116550
116737
  hooks: [
116551
116738
  {
116552
116739
  type: "command",
116553
- command: 'aqe hooks pre-edit --file "$TOOL_INPUT_file_path"',
116740
+ command: 'npx agentic-qe hooks guard --file "$TOOL_INPUT_file_path" --json',
116741
+ timeout: 3e3,
116742
+ continueOnError: true
116743
+ }
116744
+ ]
116745
+ },
116746
+ {
116747
+ matcher: "^(Write|Edit|MultiEdit)$",
116748
+ hooks: [
116749
+ {
116750
+ type: "command",
116751
+ command: 'npx agentic-qe hooks pre-edit --file "$TOOL_INPUT_file_path" --json',
116554
116752
  timeout: 5e3,
116555
116753
  continueOnError: true
116556
116754
  }
@@ -116561,8 +116759,8 @@ async function configureHooks(projectRoot, config) {
116561
116759
  hooks: [
116562
116760
  {
116563
116761
  type: "command",
116564
- command: 'aqe hooks pre-command --command "$TOOL_INPUT_command"',
116565
- timeout: 5e3,
116762
+ command: 'npx agentic-qe hooks pre-command --command "$TOOL_INPUT_command" --json',
116763
+ timeout: 3e3,
116566
116764
  continueOnError: true
116567
116765
  }
116568
116766
  ]
@@ -116572,7 +116770,7 @@ async function configureHooks(projectRoot, config) {
116572
116770
  hooks: [
116573
116771
  {
116574
116772
  type: "command",
116575
- command: 'aqe hooks pre-task --description "$TOOL_INPUT_prompt"',
116773
+ command: 'npx agentic-qe hooks pre-task --description "$TOOL_INPUT_prompt" --json',
116576
116774
  timeout: 5e3,
116577
116775
  continueOnError: true
116578
116776
  }
@@ -116585,7 +116783,7 @@ async function configureHooks(projectRoot, config) {
116585
116783
  hooks: [
116586
116784
  {
116587
116785
  type: "command",
116588
- command: 'aqe hooks post-edit --file "$TOOL_INPUT_file_path" --success "$TOOL_SUCCESS"',
116786
+ command: 'npx agentic-qe hooks post-edit --file "$TOOL_INPUT_file_path" --success --json',
116589
116787
  timeout: 5e3,
116590
116788
  continueOnError: true
116591
116789
  }
@@ -116596,7 +116794,7 @@ async function configureHooks(projectRoot, config) {
116596
116794
  hooks: [
116597
116795
  {
116598
116796
  type: "command",
116599
- command: 'aqe hooks post-command --command "$TOOL_INPUT_command" --success "$TOOL_SUCCESS"',
116797
+ command: 'npx agentic-qe hooks post-command --command "$TOOL_INPUT_command" --success --json',
116600
116798
  timeout: 5e3,
116601
116799
  continueOnError: true
116602
116800
  }
@@ -116607,7 +116805,7 @@ async function configureHooks(projectRoot, config) {
116607
116805
  hooks: [
116608
116806
  {
116609
116807
  type: "command",
116610
- command: 'aqe hooks post-task --task-id "$TOOL_RESULT_agent_id" --success "$TOOL_SUCCESS"',
116808
+ command: 'npx agentic-qe hooks post-task --task-id "$TOOL_RESULT_agent_id" --success --json',
116611
116809
  timeout: 5e3,
116612
116810
  continueOnError: true
116613
116811
  }
@@ -116619,7 +116817,7 @@ async function configureHooks(projectRoot, config) {
116619
116817
  hooks: [
116620
116818
  {
116621
116819
  type: "command",
116622
- command: 'aqe hooks route --task "$PROMPT"',
116820
+ command: 'npx agentic-qe hooks route --task "$PROMPT" --json',
116623
116821
  timeout: 5e3,
116624
116822
  continueOnError: true
116625
116823
  }
@@ -116631,7 +116829,7 @@ async function configureHooks(projectRoot, config) {
116631
116829
  hooks: [
116632
116830
  {
116633
116831
  type: "command",
116634
- command: 'aqe hooks session-start --session-id "$SESSION_ID"',
116832
+ command: 'npx agentic-qe hooks session-start --session-id "$SESSION_ID" --json',
116635
116833
  timeout: 1e4,
116636
116834
  continueOnError: true
116637
116835
  }
@@ -116643,7 +116841,7 @@ async function configureHooks(projectRoot, config) {
116643
116841
  hooks: [
116644
116842
  {
116645
116843
  type: "command",
116646
- command: "aqe hooks session-end --save-state",
116844
+ command: "npx agentic-qe hooks session-end --save-state --json",
116647
116845
  timeout: 5e3,
116648
116846
  continueOnError: true
116649
116847
  }
@@ -116652,33 +116850,22 @@ async function configureHooks(projectRoot, config) {
116652
116850
  ]
116653
116851
  };
116654
116852
  const existingHooks = settings.hooks || {};
116655
- const mergedHooks = {};
116656
- for (const [hookType, hookArray] of Object.entries(hooks)) {
116657
- const existing = existingHooks[hookType] || [];
116658
- mergedHooks[hookType] = [...existing, ...hookArray];
116659
- }
116660
- for (const [hookType, hookArray] of Object.entries(existingHooks)) {
116661
- if (!mergedHooks[hookType]) {
116662
- mergedHooks[hookType] = hookArray;
116663
- }
116664
- }
116665
- settings.hooks = mergedHooks;
116853
+ settings.hooks = mergeHooksSmart(existingHooks, aqeHooks);
116666
116854
  const existingEnv = settings.env || {};
116667
116855
  settings.env = {
116668
116856
  ...existingEnv,
116669
- AQE_MEMORY_PATH: ".agentic-qe/memory.db",
116670
- AQE_V3_MODE: "true",
116671
- AQE_LEARNING_ENABLED: config.learning.enabled ? "true" : "false"
116857
+ ...generateAqeEnvVars(config)
116672
116858
  };
116673
- settings.aqe = {
116674
- version: config.version,
116675
- initialized: (/* @__PURE__ */ new Date()).toISOString(),
116676
- hooksConfigured: true
116677
- };
116678
- const existingMcp = settings.enabledMcpjsonServers || [];
116679
- if (!existingMcp.includes("aqe")) {
116680
- settings.enabledMcpjsonServers = [...existingMcp, "aqe"];
116859
+ const v3Sections = generateV3SettingsSections(config);
116860
+ for (const [key, value] of Object.entries(v3Sections)) {
116861
+ settings[key] = value;
116862
+ }
116863
+ let existingMcp = settings.enabledMcpjsonServers || [];
116864
+ existingMcp = existingMcp.filter((s70) => s70 !== "aqe");
116865
+ if (!existingMcp.includes("agentic-qe")) {
116866
+ existingMcp.push("agentic-qe");
116681
116867
  }
116868
+ settings.enabledMcpjsonServers = existingMcp;
116682
116869
  writeFileSync3(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
116683
116870
  await installCrossPhaseMemoryHooks(projectRoot);
116684
116871
  return true;
@@ -119677,7 +119864,8 @@ var HooksPhase = class extends BasePhase {
119677
119864
  return {
119678
119865
  configured: false,
119679
119866
  settingsPath: "",
119680
- hookTypes: []
119867
+ hookTypes: [],
119868
+ existingAqeDetected: false
119681
119869
  };
119682
119870
  }
119683
119871
  const claudeDir = join27(projectRoot, ".claude");
@@ -119694,61 +119882,51 @@ var HooksPhase = class extends BasePhase {
119694
119882
  settings = {};
119695
119883
  }
119696
119884
  }
119697
- const hooks = this.generateHooksConfig(config);
119698
- const hookTypes = Object.keys(hooks);
119885
+ const aqeHooks = this.generateHooksConfig(config);
119886
+ const hookTypes = Object.keys(aqeHooks);
119699
119887
  const existingHooks = settings.hooks || {};
119700
- const mergedHooks = {};
119701
- for (const [hookType, hookArray] of Object.entries(hooks)) {
119702
- const existing = existingHooks[hookType] || [];
119703
- const newHooks = hookArray;
119704
- const existingCommands = /* @__PURE__ */ new Set();
119705
- for (const hook of existing) {
119706
- const h66 = hook;
119707
- if (h66.hooks) {
119708
- for (const innerHook of h66.hooks) {
119709
- if (innerHook.command) {
119710
- existingCommands.add(innerHook.command);
119711
- }
119712
- }
119713
- }
119714
- }
119715
- const uniqueNewHooks = newHooks.filter((hook) => {
119716
- if (!hook.hooks) return true;
119717
- return !hook.hooks.some((h66) => h66.command && existingCommands.has(h66.command));
119718
- });
119719
- mergedHooks[hookType] = [...existing, ...uniqueNewHooks];
119720
- }
119721
- for (const [hookType, hookArray] of Object.entries(existingHooks)) {
119722
- if (!mergedHooks[hookType]) {
119723
- mergedHooks[hookType] = hookArray;
119724
- }
119888
+ const existingAqeDetected = this.hasExistingAqeHooks(existingHooks);
119889
+ if (existingAqeDetected) {
119890
+ context2.services.log(" Detected existing AQE hooks \u2014 replacing with updated config");
119725
119891
  }
119726
- settings.hooks = mergedHooks;
119892
+ settings.hooks = mergeHooksSmart(existingHooks, aqeHooks);
119727
119893
  const existingEnv = settings.env || {};
119728
119894
  settings.env = {
119729
119895
  ...existingEnv,
119730
- AQE_MEMORY_PATH: ".agentic-qe/memory.db",
119731
- AQE_V3_MODE: "true",
119732
- AQE_LEARNING_ENABLED: config.learning.enabled ? "true" : "false"
119733
- };
119734
- settings.aqe = {
119735
- version: config.version,
119736
- initialized: (/* @__PURE__ */ new Date()).toISOString(),
119737
- hooksConfigured: true
119896
+ ...generateAqeEnvVars(config)
119738
119897
  };
119739
- const existingMcp = settings.enabledMcpjsonServers || [];
119740
- if (!existingMcp.includes("aqe")) {
119741
- settings.enabledMcpjsonServers = [...existingMcp, "aqe"];
119898
+ const v3Sections = generateV3SettingsSections(config);
119899
+ for (const [key, value] of Object.entries(v3Sections)) {
119900
+ settings[key] = value;
119901
+ }
119902
+ let existingMcp = settings.enabledMcpjsonServers || [];
119903
+ existingMcp = existingMcp.filter((s70) => s70 !== "aqe");
119904
+ if (!existingMcp.includes("agentic-qe")) {
119905
+ existingMcp.push("agentic-qe");
119742
119906
  }
119907
+ settings.enabledMcpjsonServers = existingMcp;
119743
119908
  writeFileSync9(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
119744
119909
  context2.services.log(` Settings: ${settingsPath}`);
119745
119910
  context2.services.log(` Hook types: ${hookTypes.join(", ")}`);
119746
119911
  return {
119747
119912
  configured: true,
119748
119913
  settingsPath,
119749
- hookTypes
119914
+ hookTypes,
119915
+ existingAqeDetected
119750
119916
  };
119751
119917
  }
119918
+ /**
119919
+ * Check if existing hooks contain any AQE/agentic-qe entries
119920
+ */
119921
+ hasExistingAqeHooks(hooks) {
119922
+ for (const hookArray of Object.values(hooks)) {
119923
+ if (!Array.isArray(hookArray)) continue;
119924
+ for (const entry of hookArray) {
119925
+ if (isAqeHookEntry(entry)) return true;
119926
+ }
119927
+ }
119928
+ return false;
119929
+ }
119752
119930
  /**
119753
119931
  * Generate hooks configuration
119754
119932
  *
@@ -123090,6 +123268,116 @@ function createCommandRegistry(context2, cleanupAndExit2, ensureInitialized2) {
123090
123268
  // src/cli/commands/test.ts
123091
123269
  import { Command } from "commander";
123092
123270
  import chalk9 from "chalk";
123271
+
123272
+ // src/cli/utils/file-discovery.ts
123273
+ import { existsSync as existsSync35, readdirSync as readdirSync10, statSync as statSync9 } from "fs";
123274
+ import { join as join37, extname as extname7 } from "path";
123275
+ var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
123276
+ // JavaScript / TypeScript
123277
+ ".ts",
123278
+ ".tsx",
123279
+ ".js",
123280
+ ".jsx",
123281
+ ".mjs",
123282
+ ".cjs",
123283
+ // Python
123284
+ ".py",
123285
+ ".pyw",
123286
+ // Go
123287
+ ".go",
123288
+ // Rust
123289
+ ".rs",
123290
+ // Java / Kotlin
123291
+ ".java",
123292
+ ".kt",
123293
+ ".kts",
123294
+ // Ruby
123295
+ ".rb",
123296
+ // C#
123297
+ ".cs",
123298
+ // PHP
123299
+ ".php",
123300
+ // Swift
123301
+ ".swift",
123302
+ // C / C++
123303
+ ".c",
123304
+ ".h",
123305
+ ".cpp",
123306
+ ".hpp",
123307
+ ".cc",
123308
+ // Scala
123309
+ ".scala"
123310
+ ]);
123311
+ var TEST_PATTERNS = [".test.", ".spec.", "_test.", "_spec."];
123312
+ var SKIP_DIRS = /* @__PURE__ */ new Set([
123313
+ "node_modules",
123314
+ "dist",
123315
+ "build",
123316
+ "coverage",
123317
+ ".git",
123318
+ "__pycache__",
123319
+ ".venv",
123320
+ "venv",
123321
+ ".tox",
123322
+ ".mypy_cache",
123323
+ "target",
123324
+ ".gradle",
123325
+ "vendor",
123326
+ ".bundle",
123327
+ ".next",
123328
+ ".nuxt",
123329
+ ".output"
123330
+ ]);
123331
+ function walkSourceFiles(targetPath, options = {}) {
123332
+ const {
123333
+ maxDepth = 6,
123334
+ includeTests = false,
123335
+ testsOnly = false,
123336
+ extraExtensions = []
123337
+ } = options;
123338
+ if (!existsSync35(targetPath)) {
123339
+ return [];
123340
+ }
123341
+ const stat4 = statSync9(targetPath);
123342
+ if (stat4.isFile()) {
123343
+ return [targetPath];
123344
+ }
123345
+ if (!stat4.isDirectory()) {
123346
+ return [];
123347
+ }
123348
+ const extraSet = new Set(extraExtensions.map((e20) => e20.startsWith(".") ? e20 : `.${e20}`));
123349
+ const result = [];
123350
+ function walk(dir, depth) {
123351
+ if (depth > maxDepth) return;
123352
+ let entries;
123353
+ try {
123354
+ entries = readdirSync10(dir, { withFileTypes: true });
123355
+ } catch {
123356
+ return;
123357
+ }
123358
+ for (const entry of entries) {
123359
+ if (entry.isDirectory()) {
123360
+ if (SKIP_DIRS.has(entry.name)) continue;
123361
+ walk(join37(dir, entry.name), depth + 1);
123362
+ } else if (entry.isFile()) {
123363
+ const ext = extname7(entry.name).toLowerCase();
123364
+ const isSourceExt = SOURCE_EXTENSIONS.has(ext) || extraSet.has(ext);
123365
+ if (!isSourceExt) continue;
123366
+ if (entry.name.endsWith(".d.ts")) continue;
123367
+ const isTestFile2 = TEST_PATTERNS.some((p74) => entry.name.includes(p74)) || entry.name.startsWith("test_");
123368
+ if (testsOnly) {
123369
+ if (isTestFile2) result.push(join37(dir, entry.name));
123370
+ } else if (includeTests || !isTestFile2) {
123371
+ result.push(join37(dir, entry.name));
123372
+ }
123373
+ }
123374
+ }
123375
+ }
123376
+ walk(targetPath, 0);
123377
+ return result;
123378
+ }
123379
+
123380
+ // src/cli/commands/test.ts
123093
123381
  function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
123094
123382
  const testCmd = new Command("test").description("Test generation shortcut").argument("<action>", "Action (generate|execute)").argument("[target]", "Target file or directory").option("-f, --framework <framework>", "Test framework", "vitest").option("-t, --type <type>", "Test type (unit|integration|e2e)", "unit").action(async (action, target, options) => {
123095
123383
  if (!await ensureInitialized2()) return;
@@ -123103,33 +123391,9 @@ function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
123103
123391
  console.log(chalk9.red("Test generation domain not available"));
123104
123392
  return;
123105
123393
  }
123106
- const fs23 = await import("fs");
123107
123394
  const path26 = await import("path");
123108
123395
  const targetPath = path26.resolve(target || ".");
123109
- let sourceFiles = [];
123110
- if (fs23.existsSync(targetPath)) {
123111
- if (fs23.statSync(targetPath).isDirectory()) {
123112
- const walkDir2 = (dir, depth = 0) => {
123113
- if (depth > 4) return [];
123114
- const result2 = [];
123115
- const items = fs23.readdirSync(dir);
123116
- for (const item of items) {
123117
- if (item === "node_modules" || item === "dist" || item === "tests" || item.includes(".test.") || item.includes(".spec.")) continue;
123118
- const fullPath = path26.join(dir, item);
123119
- const stat4 = fs23.statSync(fullPath);
123120
- if (stat4.isDirectory()) {
123121
- result2.push(...walkDir2(fullPath, depth + 1));
123122
- } else if (item.endsWith(".ts") && !item.endsWith(".d.ts")) {
123123
- result2.push(fullPath);
123124
- }
123125
- }
123126
- return result2;
123127
- };
123128
- sourceFiles = walkDir2(targetPath);
123129
- } else {
123130
- sourceFiles = [targetPath];
123131
- }
123132
- }
123396
+ const sourceFiles = walkSourceFiles(targetPath, { includeTests: false });
123133
123397
  if (sourceFiles.length === 0) {
123134
123398
  console.log(chalk9.yellow("No source files found"));
123135
123399
  return;
@@ -123180,33 +123444,9 @@ function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
123180
123444
  console.log(chalk9.red("Test execution domain not available"));
123181
123445
  return;
123182
123446
  }
123183
- const fs23 = await import("fs");
123184
123447
  const path26 = await import("path");
123185
123448
  const targetPath = path26.resolve(target || ".");
123186
- let testFiles = [];
123187
- if (fs23.existsSync(targetPath)) {
123188
- if (fs23.statSync(targetPath).isDirectory()) {
123189
- const walkDir2 = (dir, depth = 0) => {
123190
- if (depth > 4) return [];
123191
- const result2 = [];
123192
- const items = fs23.readdirSync(dir);
123193
- for (const item of items) {
123194
- if (item === "node_modules" || item === "dist") continue;
123195
- const fullPath = path26.join(dir, item);
123196
- const stat4 = fs23.statSync(fullPath);
123197
- if (stat4.isDirectory()) {
123198
- result2.push(...walkDir2(fullPath, depth + 1));
123199
- } else if ((item.includes(".test.") || item.includes(".spec.")) && item.endsWith(".ts")) {
123200
- result2.push(fullPath);
123201
- }
123202
- }
123203
- return result2;
123204
- };
123205
- testFiles = walkDir2(targetPath);
123206
- } else {
123207
- testFiles = [targetPath];
123208
- }
123209
- }
123449
+ const testFiles = walkSourceFiles(targetPath, { testsOnly: true });
123210
123450
  if (testFiles.length === 0) {
123211
123451
  console.log(chalk9.yellow("No test files found"));
123212
123452
  return;
@@ -123283,13 +123523,13 @@ var BaseWizardCommand = class {
123283
123523
 
123284
123524
  // src/cli/wizards/core/wizard-step.ts
123285
123525
  import chalk11 from "chalk";
123286
- import { existsSync as existsSync36 } from "fs";
123526
+ import { existsSync as existsSync37 } from "fs";
123287
123527
  import { resolve as resolve8 } from "path";
123288
123528
 
123289
123529
  // src/cli/wizards/core/wizard-utils.ts
123290
123530
  import chalk10 from "chalk";
123291
- import { existsSync as existsSync35, statSync as statSync9 } from "fs";
123292
- import { join as join37, relative as relative6 } from "path";
123531
+ import { existsSync as existsSync36, statSync as statSync10 } from "fs";
123532
+ import { join as join38, relative as relative6 } from "path";
123293
123533
  var WizardPrompt = class {
123294
123534
  /**
123295
123535
  * Generic prompt helper - wraps readline.question in a Promise
@@ -123380,8 +123620,8 @@ var WizardSuggestions = class _WizardSuggestions {
123380
123620
  const suggestions = [];
123381
123621
  const commonDirs = ["src", "lib", "app", "packages", "api"];
123382
123622
  for (const dir of commonDirs) {
123383
- const dirPath = join37(cwd, dir);
123384
- if (existsSync35(dirPath) && statSync9(dirPath).isDirectory()) {
123623
+ const dirPath = join38(cwd, dir);
123624
+ if (existsSync36(dirPath) && statSync10(dirPath).isDirectory()) {
123385
123625
  suggestions.push(dir);
123386
123626
  }
123387
123627
  }
@@ -123399,8 +123639,8 @@ var WizardSuggestions = class _WizardSuggestions {
123399
123639
  ".nyc_output"
123400
123640
  ];
123401
123641
  for (const loc of coverageLocations) {
123402
- const locPath = join37(cwd, loc);
123403
- if (existsSync35(locPath)) {
123642
+ const locPath = join38(cwd, loc);
123643
+ if (existsSync36(locPath)) {
123404
123644
  suggestions.push(loc);
123405
123645
  }
123406
123646
  }
@@ -123422,8 +123662,8 @@ var WizardSuggestions = class _WizardSuggestions {
123422
123662
  "Dockerfile"
123423
123663
  ];
123424
123664
  for (const file of securityFiles) {
123425
- const filePath = join37(cwd, file);
123426
- if (existsSync35(filePath)) {
123665
+ const filePath = join38(cwd, file);
123666
+ if (existsSync36(filePath)) {
123427
123667
  suggestions.push(file);
123428
123668
  }
123429
123669
  }
@@ -123436,13 +123676,13 @@ var WizardSuggestions = class _WizardSuggestions {
123436
123676
  const suggestions = [];
123437
123677
  const commonDirs = ["src", "lib", "app", "packages"];
123438
123678
  for (const dir of commonDirs) {
123439
- const dirPath = join37(cwd, dir);
123440
- if (existsSync35(dirPath) && statSync9(dirPath).isDirectory()) {
123679
+ const dirPath = join38(cwd, dir);
123680
+ if (existsSync36(dirPath) && statSync10(dirPath).isDirectory()) {
123441
123681
  suggestions.push(`${dir}/**/*.ts`);
123442
123682
  suggestions.push(dir);
123443
123683
  }
123444
123684
  }
123445
- if (existsSync35(join37(cwd, "src"))) {
123685
+ if (existsSync36(join38(cwd, "src"))) {
123446
123686
  suggestions.push("src/services/**/*.ts");
123447
123687
  suggestions.push("src/utils/**/*.ts");
123448
123688
  suggestions.push("src/components/**/*.tsx");
@@ -123454,12 +123694,12 @@ var WizardSuggestions = class _WizardSuggestions {
123454
123694
  */
123455
123695
  static checkPatternsExist(cwd) {
123456
123696
  const patternLocations = [
123457
- join37(cwd, ".agentic-qe", "patterns"),
123458
- join37(cwd, ".agentic-qe", "memory.db"),
123459
- join37(cwd, ".aqe", "patterns"),
123460
- join37(cwd, "data", "patterns")
123697
+ join38(cwd, ".agentic-qe", "patterns"),
123698
+ join38(cwd, ".agentic-qe", "memory.db"),
123699
+ join38(cwd, ".aqe", "patterns"),
123700
+ join38(cwd, "data", "patterns")
123461
123701
  ];
123462
- return patternLocations.some((loc) => existsSync35(loc));
123702
+ return patternLocations.some((loc) => existsSync36(loc));
123463
123703
  }
123464
123704
  };
123465
123705
  var WizardFormat = class {
@@ -123736,7 +123976,7 @@ var PathInputStep = class extends BaseWizardCommand {
123736
123976
  async execute(context2) {
123737
123977
  if (context2.nonInteractive) {
123738
123978
  const resolved2 = resolve8(context2.cwd, this.defaultValue);
123739
- return this.success(existsSync36(resolved2) ? resolved2 : context2.cwd);
123979
+ return this.success(existsSync37(resolved2) ? resolved2 : context2.cwd);
123740
123980
  }
123741
123981
  WizardPrompt.printStepHeader(this.stepNumber, this.title, this.description);
123742
123982
  if (this.examples) {
@@ -123759,7 +123999,7 @@ var PathInputStep = class extends BaseWizardCommand {
123759
123999
  );
123760
124000
  const value = input.trim() || this.defaultValue;
123761
124001
  const resolved = resolve8(context2.cwd, value);
123762
- if (this.validatePath && !existsSync36(resolved)) {
124002
+ if (this.validatePath && !existsSync37(resolved)) {
123763
124003
  console.log(chalk11.yellow(` Warning: '${value}' does not exist, using current directory.`));
123764
124004
  return this.success(context2.cwd);
123765
124005
  }
@@ -124111,30 +124351,7 @@ function createCoverageCommand(context2, cleanupAndExit2, ensureInitialized2) {
124111
124351
  const fs23 = await import("fs");
124112
124352
  const path26 = await import("path");
124113
124353
  const targetPath = path26.resolve(analyzeTarget);
124114
- let sourceFiles = [];
124115
- if (fs23.existsSync(targetPath)) {
124116
- if (fs23.statSync(targetPath).isDirectory()) {
124117
- const walkDir2 = (dir, depth = 0) => {
124118
- if (depth > 4) return [];
124119
- const result2 = [];
124120
- const items = fs23.readdirSync(dir);
124121
- for (const item of items) {
124122
- if (item === "node_modules" || item === "dist") continue;
124123
- const fullPath = path26.join(dir, item);
124124
- const stat4 = fs23.statSync(fullPath);
124125
- if (stat4.isDirectory()) {
124126
- result2.push(...walkDir2(fullPath, depth + 1));
124127
- } else if (item.endsWith(".ts") && !item.endsWith(".d.ts")) {
124128
- result2.push(fullPath);
124129
- }
124130
- }
124131
- return result2;
124132
- };
124133
- sourceFiles = walkDir2(targetPath);
124134
- } else {
124135
- sourceFiles = [targetPath];
124136
- }
124137
- }
124354
+ const sourceFiles = walkSourceFiles(targetPath, { includeTests: false });
124138
124355
  if (sourceFiles.length === 0) {
124139
124356
  console.log(chalk13.yellow("No source files found"));
124140
124357
  return;
@@ -124320,33 +124537,9 @@ function createSecurityCommand(context2, cleanupAndExit2, ensureInitialized2) {
124320
124537
  console.log(chalk15.red("Security domain not available"));
124321
124538
  return;
124322
124539
  }
124323
- const fs23 = await import("fs");
124324
124540
  const path26 = await import("path");
124325
124541
  const targetPath = path26.resolve(options.target);
124326
- let files = [];
124327
- if (fs23.existsSync(targetPath)) {
124328
- if (fs23.statSync(targetPath).isDirectory()) {
124329
- const walkDir2 = (dir, depth = 0) => {
124330
- if (depth > 4) return [];
124331
- const result = [];
124332
- const items = fs23.readdirSync(dir);
124333
- for (const item of items) {
124334
- if (item === "node_modules" || item === "dist") continue;
124335
- const fullPath = path26.join(dir, item);
124336
- const stat4 = fs23.statSync(fullPath);
124337
- if (stat4.isDirectory()) {
124338
- result.push(...walkDir2(fullPath, depth + 1));
124339
- } else if (item.endsWith(".ts") && !item.endsWith(".d.ts")) {
124340
- result.push(fullPath);
124341
- }
124342
- }
124343
- return result;
124344
- };
124345
- files = walkDir2(targetPath);
124346
- } else {
124347
- files = [targetPath];
124348
- }
124349
- }
124542
+ const files = walkSourceFiles(targetPath, { includeTests: true });
124350
124543
  if (files.length === 0) {
124351
124544
  console.log(chalk15.yellow("No files found to scan"));
124352
124545
  return;
@@ -124421,37 +124614,15 @@ function createCodeCommand(context2, cleanupAndExit2, ensureInitialized2) {
124421
124614
  console.log(chalk16.red("Code intelligence domain not available"));
124422
124615
  return;
124423
124616
  }
124424
- const fs23 = await import("fs");
124425
124617
  const path26 = await import("path");
124426
124618
  if (action === "index") {
124427
124619
  console.log(chalk16.blue(`
124428
124620
  Indexing codebase at ${target || "."}...
124429
124621
  `));
124430
124622
  const targetPath = path26.resolve(target || ".");
124431
- let paths = [];
124432
- if (fs23.existsSync(targetPath)) {
124433
- if (fs23.statSync(targetPath).isDirectory()) {
124434
- const walkDir2 = (dir, depth = 0) => {
124435
- if (depth > 4) return [];
124436
- const result2 = [];
124437
- const items = fs23.readdirSync(dir);
124438
- for (const item of items) {
124439
- if (item === "node_modules" || item === "dist") continue;
124440
- const fullPath = path26.join(dir, item);
124441
- const stat4 = fs23.statSync(fullPath);
124442
- if (stat4.isDirectory()) {
124443
- result2.push(...walkDir2(fullPath, depth + 1));
124444
- } else if (item.endsWith(".ts") && !item.endsWith(".d.ts")) {
124445
- result2.push(fullPath);
124446
- }
124447
- }
124448
- return result2;
124449
- };
124450
- paths = walkDir2(targetPath);
124451
- } else {
124452
- paths = [targetPath];
124453
- }
124454
- }
124623
+ const paths = walkSourceFiles(targetPath, {
124624
+ includeTests: options.includeTests || false
124625
+ });
124455
124626
  console.log(chalk16.gray(` Found ${paths.length} files to index...
124456
124627
  `));
124457
124628
  const result = await codeAPI.index({
@@ -124510,30 +124681,7 @@ function createCodeCommand(context2, cleanupAndExit2, ensureInitialized2) {
124510
124681
  Analyzing impact for ${target || "recent changes"}...
124511
124682
  `));
124512
124683
  const targetPath = path26.resolve(target || ".");
124513
- let changedFiles = [];
124514
- if (fs23.existsSync(targetPath)) {
124515
- if (fs23.statSync(targetPath).isFile()) {
124516
- changedFiles = [targetPath];
124517
- } else {
124518
- const walkDir2 = (dir, depth = 0) => {
124519
- if (depth > 2) return [];
124520
- const result2 = [];
124521
- const items = fs23.readdirSync(dir);
124522
- for (const item of items) {
124523
- if (item === "node_modules" || item === "dist") continue;
124524
- const fullPath = path26.join(dir, item);
124525
- const stat4 = fs23.statSync(fullPath);
124526
- if (stat4.isDirectory()) {
124527
- result2.push(...walkDir2(fullPath, depth + 1));
124528
- } else if (item.endsWith(".ts") && !item.endsWith(".d.ts")) {
124529
- result2.push(fullPath);
124530
- }
124531
- }
124532
- return result2;
124533
- };
124534
- changedFiles = walkDir2(targetPath).slice(0, 10);
124535
- }
124536
- }
124684
+ const changedFiles = walkSourceFiles(targetPath, { maxDepth: 2 }).slice(0, 10);
124537
124685
  const result = await codeAPI.analyzeImpact({
124538
124686
  changedFiles,
124539
124687
  depth: parseInt(options.depth),
@@ -124579,30 +124727,7 @@ function createCodeCommand(context2, cleanupAndExit2, ensureInitialized2) {
124579
124727
  Mapping dependencies for ${target || "."}...
124580
124728
  `));
124581
124729
  const targetPath = path26.resolve(target || ".");
124582
- let files = [];
124583
- if (fs23.existsSync(targetPath)) {
124584
- if (fs23.statSync(targetPath).isFile()) {
124585
- files = [targetPath];
124586
- } else {
124587
- const walkDir2 = (dir, depth = 0) => {
124588
- if (depth > 2) return [];
124589
- const result2 = [];
124590
- const items = fs23.readdirSync(dir);
124591
- for (const item of items) {
124592
- if (item === "node_modules" || item === "dist") continue;
124593
- const fullPath = path26.join(dir, item);
124594
- const stat4 = fs23.statSync(fullPath);
124595
- if (stat4.isDirectory()) {
124596
- result2.push(...walkDir2(fullPath, depth + 1));
124597
- } else if (item.endsWith(".ts") && !item.endsWith(".d.ts")) {
124598
- result2.push(fullPath);
124599
- }
124600
- }
124601
- return result2;
124602
- };
124603
- files = walkDir2(targetPath).slice(0, 50);
124604
- }
124605
- }
124730
+ const files = walkSourceFiles(targetPath, { maxDepth: 2 }).slice(0, 50);
124606
124731
  const result = await codeAPI.mapDependencies({
124607
124732
  files,
124608
124733
  direction: "both",
@@ -126848,8 +126973,8 @@ import chalk20 from "chalk";
126848
126973
  // src/init/fleet-integration.ts
126849
126974
  init_error_utils();
126850
126975
  import chalk19 from "chalk";
126851
- import { existsSync as existsSync37 } from "fs";
126852
- import { join as join39 } from "path";
126976
+ import { existsSync as existsSync38 } from "fs";
126977
+ import { join as join40 } from "path";
126853
126978
  var FleetInitEnhancer = class {
126854
126979
  projectRoot;
126855
126980
  options;
@@ -126961,7 +127086,7 @@ var FleetInitEnhancer = class {
126961
127086
  });
126962
127087
  console.log(chalk19.gray(` Indexing ${files.length} files...`));
126963
127088
  const result = await kgService.index({
126964
- paths: files.map((f74) => join39(this.projectRoot, f74)),
127089
+ paths: files.map((f74) => join40(this.projectRoot, f74)),
126965
127090
  incremental: false,
126966
127091
  includeTests: true
126967
127092
  });
@@ -126996,8 +127121,8 @@ var FleetInitEnhancer = class {
126996
127121
  * Checks the memory database for code-intelligence:kg namespace entries
126997
127122
  */
126998
127123
  async hasCodeIntelligenceIndex() {
126999
- const dbPath = join39(this.projectRoot, ".agentic-qe", "memory.db");
127000
- if (!existsSync37(dbPath)) {
127124
+ const dbPath = join40(this.projectRoot, ".agentic-qe", "memory.db");
127125
+ if (!existsSync38(dbPath)) {
127001
127126
  return false;
127002
127127
  }
127003
127128
  try {
@@ -127017,7 +127142,7 @@ var FleetInitEnhancer = class {
127017
127142
  * Get count of knowledge graph entries
127018
127143
  */
127019
127144
  async getKGEntryCount() {
127020
- const dbPath = join39(this.projectRoot, ".agentic-qe", "memory.db");
127145
+ const dbPath = join40(this.projectRoot, ".agentic-qe", "memory.db");
127021
127146
  try {
127022
127147
  const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
127023
127148
  const db = new Database(dbPath);
@@ -128523,7 +128648,7 @@ function createParallelEvalRunner(skillValidationLearner, config = {}, executor2
128523
128648
 
128524
128649
  // src/validation/validation-result-aggregator.ts
128525
128650
  init_safe_json();
128526
- import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as existsSync39 } from "fs";
128651
+ import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as existsSync40 } from "fs";
128527
128652
  var DEFAULT_CONFIG60 = {
128528
128653
  varianceThreshold: 0.04,
128529
128654
  // ~20% standard deviation
@@ -128868,7 +128993,7 @@ var ValidationResultAggregator = class {
128868
128993
  * Update trust tier manifest with new pass rates
128869
128994
  */
128870
128995
  async updateManifest(report) {
128871
- if (!existsSync39(this.manifestPath)) {
128996
+ if (!existsSync40(this.manifestPath)) {
128872
128997
  throw new Error(`Manifest file not found: ${this.manifestPath}`);
128873
128998
  }
128874
128999
  const manifest = safeJsonParse(readFileSync28(this.manifestPath, "utf-8"));
@@ -130655,18 +130780,18 @@ function formatDuration2(ms) {
130655
130780
  // src/cli/commands/validate.ts
130656
130781
  init_safe_json();
130657
130782
  import { Command as Command10 } from "commander";
130658
- import { readFileSync as readFileSync29, writeFileSync as writeFileSync18, existsSync as existsSync40, readdirSync as readdirSync10, statSync as statSync11 } from "fs";
130659
- import { join as join41, resolve as resolve9, basename as basename7 } from "path";
130783
+ import { readFileSync as readFileSync29, writeFileSync as writeFileSync18, existsSync as existsSync41, readdirSync as readdirSync11, statSync as statSync12 } from "fs";
130784
+ import { join as join42, resolve as resolve9, basename as basename7 } from "path";
130660
130785
  import chalk22 from "chalk";
130661
130786
  function loadValidationResults(inputPath) {
130662
130787
  const resolvedPath = resolve9(inputPath);
130663
- if (!existsSync40(resolvedPath)) {
130788
+ if (!existsSync41(resolvedPath)) {
130664
130789
  throw new Error(`Input path not found: ${resolvedPath}`);
130665
130790
  }
130666
- const stat4 = statSync11(resolvedPath);
130791
+ const stat4 = statSync12(resolvedPath);
130667
130792
  if (stat4.isDirectory()) {
130668
130793
  const results = [];
130669
- const files = readdirSync10(resolvedPath).filter((f74) => f74.endsWith(".json")).map((f74) => join41(resolvedPath, f74));
130794
+ const files = readdirSync11(resolvedPath).filter((f74) => f74.endsWith(".json")).map((f74) => join42(resolvedPath, f74));
130670
130795
  for (const file of files) {
130671
130796
  try {
130672
130797
  const content = safeJsonParse(readFileSync29(file, "utf-8"));
@@ -130716,15 +130841,15 @@ function createMockLearner() {
130716
130841
  function getDefaultManifestPath() {
130717
130842
  const cwd = process.cwd();
130718
130843
  const candidates = [
130719
- join41(cwd, ".claude/skills/trust-tier-manifest.json"),
130720
- join41(cwd, ".claude/skills/skills-manifest.json")
130844
+ join42(cwd, ".claude/skills/trust-tier-manifest.json"),
130845
+ join42(cwd, ".claude/skills/skills-manifest.json")
130721
130846
  ];
130722
130847
  for (const candidate of candidates) {
130723
- if (existsSync40(candidate)) {
130848
+ if (existsSync41(candidate)) {
130724
130849
  return candidate;
130725
130850
  }
130726
130851
  }
130727
- return join41(cwd, ".claude/skills/trust-tier-manifest.json");
130852
+ return join42(cwd, ".claude/skills/trust-tier-manifest.json");
130728
130853
  }
130729
130854
  function writeReport(report, aggregator, options) {
130730
130855
  const format = options.format || "markdown";
@@ -136815,8 +136940,8 @@ async function createCoherenceService(wasmLoader2, config, logger19) {
136815
136940
  init_error_utils();
136816
136941
  import { createRequire as createRequire12 } from "node:module";
136817
136942
  import { fileURLToPath as fileURLToPath6 } from "node:url";
136818
- import { dirname as dirname13, join as join43 } from "node:path";
136819
- import { readFileSync as readFileSync32, existsSync as existsSync43 } from "node:fs";
136943
+ import { dirname as dirname13, join as join44 } from "node:path";
136944
+ import { readFileSync as readFileSync32, existsSync as existsSync44 } from "node:fs";
136820
136945
  var FALLBACK_RETRY_DELAYS_MS = [1e3, 2e3, 4e3];
136821
136946
  var WasmLoader = class {
136822
136947
  state = "unloaded";
@@ -137074,15 +137199,15 @@ var WasmLoader = class {
137074
137199
  (() => {
137075
137200
  try {
137076
137201
  const modulePath = require5.resolve("prime-radiant-advanced-wasm");
137077
- return join43(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
137202
+ return join44(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
137078
137203
  } catch {
137079
137204
  return null;
137080
137205
  }
137081
137206
  })(),
137082
- join43(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
137207
+ join44(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
137083
137208
  ].filter((p74) => p74 !== null);
137084
137209
  for (const path26 of wasmPaths) {
137085
- if (existsSync43(path26)) {
137210
+ if (existsSync44(path26)) {
137086
137211
  return true;
137087
137212
  }
137088
137213
  }
@@ -137333,19 +137458,19 @@ var WasmLoader = class {
137333
137458
  (() => {
137334
137459
  try {
137335
137460
  const modulePath = require5.resolve("prime-radiant-advanced-wasm");
137336
- return join43(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
137461
+ return join44(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
137337
137462
  } catch {
137338
137463
  return null;
137339
137464
  }
137340
137465
  })(),
137341
137466
  // Direct node_modules path from current file
137342
- join43(dirname13(fileURLToPath6(import.meta.url)), "../../../../node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm"),
137467
+ join44(dirname13(fileURLToPath6(import.meta.url)), "../../../../node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm"),
137343
137468
  // Workspace root
137344
- join43(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
137469
+ join44(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
137345
137470
  ].filter((p74) => p74 !== null);
137346
137471
  let wasmPath = null;
137347
137472
  for (const path26 of wasmPaths) {
137348
- if (existsSync43(path26)) {
137473
+ if (existsSync44(path26)) {
137349
137474
  wasmPath = path26;
137350
137475
  break;
137351
137476
  }
@@ -138555,7 +138680,7 @@ init_qe_patterns();
138555
138680
  import { Command as Command16 } from "commander";
138556
138681
  import chalk29 from "chalk";
138557
138682
  import path25 from "node:path";
138558
- import { existsSync as existsSync45, writeFileSync as writeFileSync22, readFileSync as readFileSync33, mkdirSync as mkdirSync19, copyFileSync as copyFileSync8 } from "node:fs";
138683
+ import { existsSync as existsSync46, writeFileSync as writeFileSync22, readFileSync as readFileSync33, mkdirSync as mkdirSync19, copyFileSync as copyFileSync8 } from "node:fs";
138559
138684
  import { stat as stat3, unlink } from "node:fs/promises";
138560
138685
 
138561
138686
  // src/learning/metrics-tracker.ts
@@ -138564,7 +138689,7 @@ init_qe_patterns();
138564
138689
  init_safe_json();
138565
138690
  init_logging();
138566
138691
  import path23 from "node:path";
138567
- import { existsSync as existsSync44 } from "node:fs";
138692
+ import { existsSync as existsSync45 } from "node:fs";
138568
138693
  var logger18 = LoggerFactory.create("metrics-tracker");
138569
138694
  var LearningMetricsTracker = class {
138570
138695
  db = null;
@@ -138578,7 +138703,7 @@ var LearningMetricsTracker = class {
138578
138703
  */
138579
138704
  async initialize() {
138580
138705
  if (this.initialized) return;
138581
- if (!existsSync44(this.dbPath)) {
138706
+ if (!existsSync45(this.dbPath)) {
138582
138707
  throw new Error(`Database not found: ${this.dbPath}. Run "aqe init --auto" first.`);
138583
138708
  }
138584
138709
  this.db = new better_sqlite3_default(this.dbPath, { readonly: false });
@@ -139367,7 +139492,7 @@ function registerImportCommand(learning) {
139367
139492
  learning.command("import").description("Import patterns from file").requiredOption("-i, --input <file>", "Input file path").option("--dry-run", "Show what would be imported without making changes").option("--json", "Output as JSON").action(async (options) => {
139368
139493
  try {
139369
139494
  const inputPath = path25.resolve(options.input);
139370
- if (!existsSync45(inputPath)) throw new Error(`File not found: ${inputPath}`);
139495
+ if (!existsSync46(inputPath)) throw new Error(`File not found: ${inputPath}`);
139371
139496
  const content = readFileSync33(inputPath, "utf-8");
139372
139497
  const importData = safeJsonParse(content);
139373
139498
  if (!importData.patterns || !Array.isArray(importData.patterns)) throw new Error("Invalid pattern file format");
@@ -139436,7 +139561,7 @@ function registerResetCommand(learning) {
139436
139561
  if (!options.patternsOnly) filesToReset.push(path25.join(dataDir, "data", "learning-config.json"));
139437
139562
  console.log(chalk29.bold("\n\u{1F5D1}\uFE0F Resetting Learning Data\n"));
139438
139563
  for (const file of filesToReset) {
139439
- if (existsSync45(file)) console.log(chalk29.dim(` Removing: ${path25.relative(projectRoot, file)}`));
139564
+ if (existsSync46(file)) console.log(chalk29.dim(` Removing: ${path25.relative(projectRoot, file)}`));
139440
139565
  }
139441
139566
  printSuccess2('Learning data reset. Run "aqe init --auto" to reinitialize.\n');
139442
139567
  process.exit(0);
@@ -139451,7 +139576,7 @@ function registerExtractCommand(learning) {
139451
139576
  try {
139452
139577
  const projectRoot = findProjectRoot();
139453
139578
  const dbPath = path25.join(projectRoot, ".agentic-qe", "memory.db");
139454
- if (!existsSync45(dbPath)) throw new Error('No memory database found. Run "aqe init --auto" first.');
139579
+ if (!existsSync46(dbPath)) throw new Error('No memory database found. Run "aqe init --auto" first.');
139455
139580
  const minReward = parseFloat(options.minReward);
139456
139581
  const minCount = parseInt(options.minCount, 10);
139457
139582
  console.log(chalk29.bold("\n\u{1F52C} Pattern Extraction from Learning Experiences\n"));
@@ -139605,22 +139730,22 @@ function registerBackupCommand(learning) {
139605
139730
  learning.command("backup").description("Backup learning database to a file").option("-o, --output <path>", "Output file path").option("--compress", "Compress backup with gzip").option("--verify", "Verify backup integrity after creation").option("--json", "Output as JSON").action(async (options) => {
139606
139731
  try {
139607
139732
  const dbPath = getDbPath();
139608
- if (!existsSync45(dbPath)) throw new Error(`No learning database found at: ${dbPath}`);
139733
+ if (!existsSync46(dbPath)) throw new Error(`No learning database found at: ${dbPath}`);
139609
139734
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
139610
139735
  const defaultOutput = path25.join(process.cwd(), "backups", `learning-${timestamp}.db`);
139611
139736
  let outputPath = options.output ? path25.resolve(options.output) : defaultOutput;
139612
139737
  const backupDir = path25.dirname(outputPath);
139613
- if (!existsSync45(backupDir)) mkdirSync19(backupDir, { recursive: true });
139738
+ if (!existsSync46(backupDir)) mkdirSync19(backupDir, { recursive: true });
139614
139739
  const sourceStats = await stat3(dbPath);
139615
139740
  const sourceSizeKB = (sourceStats.size / 1024).toFixed(2);
139616
139741
  copyFileSync8(dbPath, outputPath);
139617
139742
  const walPath = `${dbPath}-wal`;
139618
- if (existsSync45(walPath)) copyFileSync8(walPath, `${outputPath}-wal`);
139743
+ if (existsSync46(walPath)) copyFileSync8(walPath, `${outputPath}-wal`);
139619
139744
  let finalPath = outputPath;
139620
139745
  if (options.compress) {
139621
139746
  finalPath = await compressFile(outputPath);
139622
139747
  await unlink(outputPath);
139623
- if (existsSync45(`${outputPath}-wal`)) await unlink(`${outputPath}-wal`);
139748
+ if (existsSync46(`${outputPath}-wal`)) await unlink(`${outputPath}-wal`);
139624
139749
  }
139625
139750
  const finalStats = await stat3(finalPath);
139626
139751
  const finalSizeKB = (finalStats.size / 1024).toFixed(2);
@@ -139658,7 +139783,7 @@ function registerRestoreCommand(learning) {
139658
139783
  try {
139659
139784
  const inputPath = path25.resolve(options.input);
139660
139785
  const dbPath = getDbPath();
139661
- if (!existsSync45(inputPath)) throw new Error(`Backup file not found: ${inputPath}`);
139786
+ if (!existsSync46(inputPath)) throw new Error(`Backup file not found: ${inputPath}`);
139662
139787
  const isCompressed = inputPath.endsWith(".gz");
139663
139788
  let restorePath = inputPath;
139664
139789
  if (isCompressed) {
@@ -139669,23 +139794,23 @@ function registerRestoreCommand(learning) {
139669
139794
  if (options.verify) {
139670
139795
  const verificationResult = await verifyDatabaseIntegrity(restorePath);
139671
139796
  if (!verificationResult.valid) {
139672
- if (isCompressed && existsSync45(restorePath)) await unlink(restorePath);
139797
+ if (isCompressed && existsSync46(restorePath)) await unlink(restorePath);
139673
139798
  throw new Error(`Backup verification failed: ${verificationResult.message}`);
139674
139799
  }
139675
139800
  }
139676
- if (existsSync45(dbPath) && !options.force) {
139801
+ if (existsSync46(dbPath) && !options.force) {
139677
139802
  printError2(`Database already exists at: ${dbPath}`);
139678
139803
  console.log(chalk29.yellow(" Use --force to overwrite"));
139679
- if (isCompressed && existsSync45(restorePath)) await unlink(restorePath);
139804
+ if (isCompressed && existsSync46(restorePath)) await unlink(restorePath);
139680
139805
  process.exit(1);
139681
139806
  }
139682
139807
  const targetDir = path25.dirname(dbPath);
139683
- if (!existsSync45(targetDir)) mkdirSync19(targetDir, { recursive: true });
139684
- if (existsSync45(dbPath)) await unlink(dbPath);
139685
- if (existsSync45(`${dbPath}-wal`)) await unlink(`${dbPath}-wal`);
139686
- if (existsSync45(`${dbPath}-shm`)) await unlink(`${dbPath}-shm`);
139808
+ if (!existsSync46(targetDir)) mkdirSync19(targetDir, { recursive: true });
139809
+ if (existsSync46(dbPath)) await unlink(dbPath);
139810
+ if (existsSync46(`${dbPath}-wal`)) await unlink(`${dbPath}-wal`);
139811
+ if (existsSync46(`${dbPath}-shm`)) await unlink(`${dbPath}-shm`);
139687
139812
  copyFileSync8(restorePath, dbPath);
139688
- if (isCompressed && existsSync45(restorePath)) await unlink(restorePath);
139813
+ if (isCompressed && existsSync46(restorePath)) await unlink(restorePath);
139689
139814
  const restoredStats = await stat3(dbPath);
139690
139815
  const schemaVersion = await getSchemaVersion(dbPath);
139691
139816
  if (options.json) {
@@ -139709,7 +139834,7 @@ function registerVerifyCommand(learning) {
139709
139834
  learning.command("verify").description("Verify learning database integrity").option("-f, --file <path>", "Database file to verify (defaults to current)").option("--json", "Output as JSON").action(async (options) => {
139710
139835
  try {
139711
139836
  const dbPath = options.file ? path25.resolve(options.file) : getDbPath();
139712
- if (!existsSync45(dbPath)) throw new Error(`Database file not found: ${dbPath}`);
139837
+ if (!existsSync46(dbPath)) throw new Error(`Database file not found: ${dbPath}`);
139713
139838
  const verificationResult = await verifyDatabaseIntegrity(dbPath);
139714
139839
  const schemaVersion = await getSchemaVersion(dbPath);
139715
139840
  const fileStats = await stat3(dbPath);
@@ -139752,7 +139877,7 @@ function registerExportFullCommand(learning) {
139752
139877
  learning.command("export-full").description("Export all learning data including patterns, trajectories, and experiences").option("-o, --output <file>", "Output file path", "aqe-learning-export.json").option("--compress", "Compress output with gzip").option("--include-trajectories", "Include learning trajectories").option("--include-experiences", "Include learning experiences").option("--json", "Output as JSON (to stdout)").action(async (options) => {
139753
139878
  try {
139754
139879
  const dbPath = getDbPath();
139755
- if (!existsSync45(dbPath)) throw new Error('No learning database found. Run "aqe init --auto" first.');
139880
+ if (!existsSync46(dbPath)) throw new Error('No learning database found. Run "aqe init --auto" first.');
139756
139881
  const reasoningBank = await initializeLearningSystem2();
139757
139882
  const schemaVersion = await getSchemaVersion(dbPath);
139758
139883
  const searchResult = await reasoningBank.searchPatterns("*", { limit: 1e4 });
@@ -139833,7 +139958,7 @@ function registerImportMergeCommand(learning) {
139833
139958
  learning.command("import-merge").description("Import and merge patterns from export file (preserves existing data)").requiredOption("-i, --input <file>", "Input file path").option("--skip-duplicates", "Skip patterns with matching names (default: update)").option("--dry-run", "Show what would be imported without making changes").option("--json", "Output as JSON").action(async (options) => {
139834
139959
  try {
139835
139960
  let inputPath = path25.resolve(options.input);
139836
- if (!existsSync45(inputPath)) throw new Error(`File not found: ${inputPath}`);
139961
+ if (!existsSync46(inputPath)) throw new Error(`File not found: ${inputPath}`);
139837
139962
  let content;
139838
139963
  if (inputPath.endsWith(".gz")) {
139839
139964
  const tempPath = inputPath.replace(".gz", ".tmp.json");
@@ -140115,8 +140240,8 @@ function registerDreamCommand(learning) {
140115
140240
  // src/cli/commands/mcp.ts
140116
140241
  import { Command as Command17 } from "commander";
140117
140242
  import { spawn as spawn7 } from "child_process";
140118
- import { join as join44, dirname as dirname14 } from "path";
140119
- import { existsSync as existsSync46 } from "fs";
140243
+ import { join as join45, dirname as dirname14 } from "path";
140244
+ import { existsSync as existsSync47 } from "fs";
140120
140245
  import { fileURLToPath as fileURLToPath7 } from "url";
140121
140246
  function createMcpCommand() {
140122
140247
  const cmd = new Command17("mcp").description("Start the MCP protocol server for Claude Code integration").option("--http <port>", "Also start HTTP server for AG-UI/A2A protocols", "0").option("--verbose", "Enable verbose logging").action(async (options) => {
@@ -140158,17 +140283,17 @@ function findMcpEntry() {
140158
140283
  const __dirname5 = dirname14(__filename5);
140159
140284
  const candidates = [
140160
140285
  // 1. Bundled dist (production)
140161
- join44(__dirname5, "..", "..", "mcp", "bundle.js"),
140286
+ join45(__dirname5, "..", "..", "mcp", "bundle.js"),
140162
140287
  // 2. Compiled dist
140163
- join44(__dirname5, "..", "..", "mcp", "entry.js"),
140288
+ join45(__dirname5, "..", "..", "mcp", "entry.js"),
140164
140289
  // 3. Source (development with tsx)
140165
- join44(__dirname5, "..", "..", "mcp", "entry.ts"),
140290
+ join45(__dirname5, "..", "..", "mcp", "entry.ts"),
140166
140291
  // 4. From node_modules (when used as dependency)
140167
- join44(process.cwd(), "node_modules", "agentic-qe", "v3", "dist", "mcp", "bundle.js"),
140168
- join44(process.cwd(), "node_modules", "agentic-qe", "v3", "dist", "mcp", "entry.js")
140292
+ join45(process.cwd(), "node_modules", "agentic-qe", "v3", "dist", "mcp", "bundle.js"),
140293
+ join45(process.cwd(), "node_modules", "agentic-qe", "v3", "dist", "mcp", "entry.js")
140169
140294
  ];
140170
140295
  for (const candidate of candidates) {
140171
- if (existsSync46(candidate)) {
140296
+ if (existsSync47(candidate)) {
140172
140297
  return candidate;
140173
140298
  }
140174
140299
  }
@@ -140290,7 +140415,7 @@ async function cleanupAndExit(code = 0) {
140290
140415
  process.exit(code);
140291
140416
  }
140292
140417
  var program = new Command18();
140293
- var VERSION = true ? "3.6.10" : "0.0.0-dev";
140418
+ var VERSION = true ? "3.6.11" : "0.0.0-dev";
140294
140419
  program.name("aqe").description("Agentic QE - Domain-Driven Quality Engineering").version(VERSION);
140295
140420
  var registry = createCommandRegistry(context, cleanupAndExit, ensureInitialized);
140296
140421
  registry.registerAll(program);