agentic-qe 3.6.10 → 3.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/learning-service.mjs +2 -0
- package/.claude/helpers/statusline-v3.cjs +2 -0
- package/.claude/skills/skills-manifest.json +1 -1
- package/package.json +1 -1
- package/scripts/migrate-v2-to-v3-memory.js +2 -0
- package/scripts/sync-claude-flow.cjs +1 -0
- package/v3/CHANGELOG.md +39 -0
- package/v3/dist/adapters/claude-flow/trajectory-bridge.js +2 -2
- package/v3/dist/adapters/claude-flow/trajectory-bridge.js.map +1 -1
- package/v3/dist/benchmarks/performance-benchmarks.js +1 -1
- package/v3/dist/cli/bundle.js +659 -427
- package/v3/dist/cli/commands/code.d.ts.map +1 -1
- package/v3/dist/cli/commands/code.js +9 -85
- package/v3/dist/cli/commands/code.js.map +1 -1
- package/v3/dist/cli/commands/coverage.d.ts.map +1 -1
- package/v3/dist/cli/commands/coverage.js +3 -28
- package/v3/dist/cli/commands/coverage.js.map +1 -1
- package/v3/dist/cli/commands/learning-helpers.d.ts.map +1 -1
- package/v3/dist/cli/commands/learning-helpers.js +3 -4
- package/v3/dist/cli/commands/learning-helpers.js.map +1 -1
- package/v3/dist/cli/commands/learning.d.ts.map +1 -1
- package/v3/dist/cli/commands/learning.js +5 -8
- package/v3/dist/cli/commands/learning.js.map +1 -1
- package/v3/dist/cli/commands/migrate.js +2 -2
- package/v3/dist/cli/commands/security.d.ts.map +1 -1
- package/v3/dist/cli/commands/security.js +3 -29
- package/v3/dist/cli/commands/security.js.map +1 -1
- package/v3/dist/cli/commands/test.d.ts.map +1 -1
- package/v3/dist/cli/commands/test.js +5 -58
- package/v3/dist/cli/commands/test.js.map +1 -1
- package/v3/dist/cli/utils/file-discovery.d.ts +27 -0
- package/v3/dist/cli/utils/file-discovery.d.ts.map +1 -0
- package/v3/dist/cli/utils/file-discovery.js +105 -0
- package/v3/dist/cli/utils/file-discovery.js.map +1 -0
- package/v3/dist/coordination/constants.d.ts +1 -1
- package/v3/dist/coordination/constants.js +1 -1
- package/v3/dist/coordination/task-executor.d.ts.map +1 -1
- package/v3/dist/coordination/task-executor.js +612 -104
- package/v3/dist/coordination/task-executor.js.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator-hypergraph.js +2 -2
- package/v3/dist/domains/code-intelligence/coordinator-hypergraph.js.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator.js +10 -3
- package/v3/dist/domains/code-intelligence/coordinator.js.map +1 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/index.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/index.js +10 -0
- package/v3/dist/domains/code-intelligence/services/metric-collector/index.js.map +1 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.d.ts +7 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.js +10 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/interfaces.js.map +1 -1
- package/v3/dist/domains/code-intelligence/services/metric-collector/loc-counter.js +34 -10
- package/v3/dist/domains/code-intelligence/services/metric-collector/loc-counter.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/coordinator.js +1 -1
- package/v3/dist/domains/coverage-analysis/services/coverage-analyzer.js +1 -1
- package/v3/dist/domains/coverage-analysis/services/coverage-embedder.d.ts +1 -1
- package/v3/dist/domains/coverage-analysis/services/coverage-embedder.js +1 -1
- package/v3/dist/domains/coverage-analysis/services/gap-detector.js +1 -1
- package/v3/dist/domains/coverage-analysis/services/ghost-coverage-analyzer.js +1 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts +10 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.js +40 -5
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/sublinear-analyzer.d.ts +1 -1
- package/v3/dist/domains/coverage-analysis/services/sublinear-analyzer.js +1 -1
- package/v3/dist/init/fleet-integration.d.ts.map +1 -1
- package/v3/dist/init/fleet-integration.js +3 -4
- package/v3/dist/init/fleet-integration.js.map +1 -1
- package/v3/dist/init/init-wizard-hooks.d.ts +8 -1
- package/v3/dist/init/init-wizard-hooks.d.ts.map +1 -1
- package/v3/dist/init/init-wizard-hooks.js +47 -39
- package/v3/dist/init/init-wizard-hooks.js.map +1 -1
- package/v3/dist/init/init-wizard-migration.d.ts.map +1 -1
- package/v3/dist/init/init-wizard-migration.js +3 -7
- package/v3/dist/init/init-wizard-migration.js.map +1 -1
- package/v3/dist/init/init-wizard-steps.d.ts.map +1 -1
- package/v3/dist/init/init-wizard-steps.js +3 -4
- package/v3/dist/init/init-wizard-steps.js.map +1 -1
- package/v3/dist/init/migration/data-migrator.d.ts.map +1 -1
- package/v3/dist/init/migration/data-migrator.js +6 -10
- package/v3/dist/init/migration/data-migrator.js.map +1 -1
- package/v3/dist/init/migration/detector.d.ts.map +1 -1
- package/v3/dist/init/migration/detector.js +2 -4
- package/v3/dist/init/migration/detector.js.map +1 -1
- package/v3/dist/init/phases/01-detection.d.ts.map +1 -1
- package/v3/dist/init/phases/01-detection.js +2 -4
- package/v3/dist/init/phases/01-detection.js.map +1 -1
- package/v3/dist/init/phases/06-code-intelligence.d.ts.map +1 -1
- package/v3/dist/init/phases/06-code-intelligence.js +4 -6
- package/v3/dist/init/phases/06-code-intelligence.js.map +1 -1
- package/v3/dist/init/phases/07-hooks.d.ts +22 -1
- package/v3/dist/init/phases/07-hooks.d.ts.map +1 -1
- package/v3/dist/init/phases/07-hooks.js +137 -51
- package/v3/dist/init/phases/07-hooks.js.map +1 -1
- package/v3/dist/init/phases/12-verification.d.ts.map +1 -1
- package/v3/dist/init/phases/12-verification.js +2 -4
- package/v3/dist/init/phases/12-verification.js.map +1 -1
- package/v3/dist/init/settings-merge.d.ts +35 -0
- package/v3/dist/init/settings-merge.d.ts.map +1 -0
- package/v3/dist/init/settings-merge.js +140 -0
- package/v3/dist/init/settings-merge.js.map +1 -0
- package/v3/dist/integrations/agentic-flow/model-router/router.js +1 -1
- package/v3/dist/integrations/agentic-flow/model-router/router.js.map +1 -1
- package/v3/dist/integrations/agentic-flow/model-router/score-calculator.d.ts.map +1 -1
- package/v3/dist/integrations/agentic-flow/model-router/score-calculator.js +18 -3
- package/v3/dist/integrations/agentic-flow/model-router/score-calculator.js.map +1 -1
- package/v3/dist/integrations/agentic-flow/model-router/signal-collector.d.ts +3 -3
- package/v3/dist/integrations/agentic-flow/model-router/signal-collector.d.ts.map +1 -1
- package/v3/dist/integrations/agentic-flow/model-router/signal-collector.js +18 -0
- package/v3/dist/integrations/agentic-flow/model-router/signal-collector.js.map +1 -1
- package/v3/dist/integrations/embeddings/cache/EmbeddingCache.d.ts.map +1 -1
- package/v3/dist/integrations/embeddings/cache/EmbeddingCache.js +2 -2
- package/v3/dist/integrations/embeddings/cache/EmbeddingCache.js.map +1 -1
- package/v3/dist/kernel/constants.d.ts +1 -1
- package/v3/dist/kernel/constants.js +1 -1
- package/v3/dist/kernel/unified-memory-hnsw.d.ts.map +1 -1
- package/v3/dist/kernel/unified-memory-hnsw.js +25 -6
- package/v3/dist/kernel/unified-memory-hnsw.js.map +1 -1
- package/v3/dist/kernel/unified-memory-migration.d.ts.map +1 -1
- package/v3/dist/kernel/unified-memory-migration.js +3 -3
- package/v3/dist/kernel/unified-memory-migration.js.map +1 -1
- package/v3/dist/learning/metrics-tracker.d.ts.map +1 -1
- package/v3/dist/learning/metrics-tracker.js +2 -2
- package/v3/dist/learning/metrics-tracker.js.map +1 -1
- package/v3/dist/learning/sqlite-persistence.d.ts.map +1 -1
- package/v3/dist/learning/sqlite-persistence.js +3 -6
- package/v3/dist/learning/sqlite-persistence.js.map +1 -1
- package/v3/dist/learning/v2-to-v3-migration.d.ts.map +1 -1
- package/v3/dist/learning/v2-to-v3-migration.js +4 -5
- package/v3/dist/learning/v2-to-v3-migration.js.map +1 -1
- package/v3/dist/mcp/bundle.js +1266 -245
- package/v3/dist/mcp/handlers/domain-handler-configs.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/domain-handler-configs.js +40 -31
- package/v3/dist/mcp/handlers/domain-handler-configs.js.map +1 -1
- package/v3/dist/mcp/handlers/task-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/task-handlers.js +68 -5
- package/v3/dist/mcp/handlers/task-handlers.js.map +1 -1
- package/v3/dist/mcp/protocol-server.d.ts.map +1 -1
- package/v3/dist/mcp/protocol-server.js +16 -2
- package/v3/dist/mcp/protocol-server.js.map +1 -1
- package/v3/dist/mcp/tools/security-compliance/scan.d.ts +3 -1
- package/v3/dist/mcp/tools/security-compliance/scan.d.ts.map +1 -1
- package/v3/dist/mcp/tools/security-compliance/scan.js +417 -72
- package/v3/dist/mcp/tools/security-compliance/scan.js.map +1 -1
- package/v3/dist/planning/plan-executor.d.ts.map +1 -1
- package/v3/dist/planning/plan-executor.js +2 -2
- package/v3/dist/planning/plan-executor.js.map +1 -1
- package/v3/dist/shared/safe-db.d.ts +32 -0
- package/v3/dist/shared/safe-db.d.ts.map +1 -0
- package/v3/dist/shared/safe-db.js +41 -0
- package/v3/dist/shared/safe-db.js.map +1 -0
- package/v3/dist/sync/claude-flow-bridge.js +5 -5
- package/v3/dist/sync/claude-flow-bridge.js.map +1 -1
- package/v3/dist/sync/embeddings/sync-embedding-generator.js +3 -3
- package/v3/dist/sync/embeddings/sync-embedding-generator.js.map +1 -1
- package/v3/dist/sync/readers/sqlite-reader.d.ts.map +1 -1
- package/v3/dist/sync/readers/sqlite-reader.js +2 -2
- package/v3/dist/sync/readers/sqlite-reader.js.map +1 -1
- package/v3/package.json +1 -1
package/v3/dist/cli/bundle.js
CHANGED
|
@@ -149,7 +149,7 @@ var init_constants = __esm({
|
|
|
149
149
|
/**
|
|
150
150
|
* Vector dimension for coverage analysis embeddings.
|
|
151
151
|
*/
|
|
152
|
-
COVERAGE_VECTOR_DIMENSION:
|
|
152
|
+
COVERAGE_VECTOR_DIMENSION: 768
|
|
153
153
|
};
|
|
154
154
|
AGENT_CONSTANTS = {
|
|
155
155
|
/**
|
|
@@ -1595,7 +1595,10 @@ var init_unified_memory_hnsw = __esm({
|
|
|
1595
1595
|
search(query, k68) {
|
|
1596
1596
|
if (this.ids.length === 0) return [];
|
|
1597
1597
|
const actualK = Math.min(k68, this.ids.length);
|
|
1598
|
-
|
|
1598
|
+
const storedDim = this.vectors.length > 0 ? this.vectors[0].length : 0;
|
|
1599
|
+
const queryDim = query.length;
|
|
1600
|
+
const dimensionsMatch = storedDim === queryDim;
|
|
1601
|
+
if (ruvectorDifferentiableSearch && this.vectors.length > 0 && dimensionsMatch) {
|
|
1599
1602
|
const queryF322 = new Float32Array(query);
|
|
1600
1603
|
const queryNorm2 = computeNorm(queryF322);
|
|
1601
1604
|
const result = ruvectorDifferentiableSearch(
|
|
@@ -1613,10 +1616,20 @@ var init_unified_memory_hnsw = __esm({
|
|
|
1613
1616
|
const queryNorm = computeNorm(queryF32);
|
|
1614
1617
|
const scored = [];
|
|
1615
1618
|
for (let i58 = 0; i58 < this.ids.length; i58++) {
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1619
|
+
const vec = this.vectors[i58];
|
|
1620
|
+
if (vec.length !== queryF32.length) {
|
|
1621
|
+
if (i58 === 0) {
|
|
1622
|
+
console.warn(
|
|
1623
|
+
`[RuvectorFlatIndex] Dimension mismatch: query=${queryF32.length}, stored=${vec.length}. Skipping ${this.ids.length} mismatched vectors. Re-index with correct dimensions.`
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
continue;
|
|
1627
|
+
} else {
|
|
1628
|
+
scored.push({
|
|
1629
|
+
id: this.ids[i58],
|
|
1630
|
+
score: fastCosine(queryF32, vec, queryNorm, this.norms[i58])
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1620
1633
|
}
|
|
1621
1634
|
scored.sort((a37, b68) => b68.score - a37.score);
|
|
1622
1635
|
return scored.slice(0, actualK);
|
|
@@ -8717,7 +8730,7 @@ function createHNSWIndex(memory, config) {
|
|
|
8717
8730
|
return new HNSWIndex(memory, config);
|
|
8718
8731
|
}
|
|
8719
8732
|
async function benchmarkHNSW(index, vectorCount = 1e4, searchCount = 1e3) {
|
|
8720
|
-
const dimensions =
|
|
8733
|
+
const dimensions = 768;
|
|
8721
8734
|
const startInsert = performance.now();
|
|
8722
8735
|
for (let i58 = 0; i58 < vectorCount; i58++) {
|
|
8723
8736
|
const vector = Array.from({ length: dimensions }, () => Math.random());
|
|
@@ -8746,7 +8759,7 @@ var init_hnsw_index = __esm({
|
|
|
8746
8759
|
QEGNNEmbeddingIndexClass = null;
|
|
8747
8760
|
ruvectorLoaded = false;
|
|
8748
8761
|
DEFAULT_HNSW_CONFIG = {
|
|
8749
|
-
dimensions:
|
|
8762
|
+
dimensions: 768,
|
|
8750
8763
|
M: 16,
|
|
8751
8764
|
efConstruction: 200,
|
|
8752
8765
|
efSearch: 100,
|
|
@@ -8841,7 +8854,7 @@ var init_hnsw_index = __esm({
|
|
|
8841
8854
|
if (!this.initialized) {
|
|
8842
8855
|
await this.initialize();
|
|
8843
8856
|
}
|
|
8844
|
-
this.validateVector(vector);
|
|
8857
|
+
vector = this.validateVector(vector);
|
|
8845
8858
|
if (this.keyToLabel.has(key)) {
|
|
8846
8859
|
await this.delete(key);
|
|
8847
8860
|
}
|
|
@@ -8870,7 +8883,7 @@ var init_hnsw_index = __esm({
|
|
|
8870
8883
|
if (!this.initialized) {
|
|
8871
8884
|
await this.initialize();
|
|
8872
8885
|
}
|
|
8873
|
-
this.validateVector(query);
|
|
8886
|
+
query = this.validateVector(query);
|
|
8874
8887
|
const startTime = performance.now();
|
|
8875
8888
|
const results = this.stats.vectorCount > 0 ? this.searchRuvector(query, k68) : [];
|
|
8876
8889
|
const endTime = performance.now();
|
|
@@ -8995,17 +9008,46 @@ var init_hnsw_index = __esm({
|
|
|
8995
9008
|
// ============================================================================
|
|
8996
9009
|
// Private Helper Methods
|
|
8997
9010
|
// ============================================================================
|
|
9011
|
+
/**
|
|
9012
|
+
* Validate and auto-resize vectors to match HNSW configured dimensions.
|
|
9013
|
+
* Fix #279: Prevents Rust WASM panic when RealEmbeddings (768-dim) are
|
|
9014
|
+
* passed to a mismatched-dim HNSW index.
|
|
9015
|
+
*/
|
|
8998
9016
|
validateVector(vector) {
|
|
8999
9017
|
if (vector.length !== this.config.dimensions) {
|
|
9000
|
-
|
|
9001
|
-
`Vector dimension mismatch: expected ${this.config.dimensions}, got ${vector.length}`
|
|
9002
|
-
);
|
|
9018
|
+
return this.resizeVector(vector, this.config.dimensions);
|
|
9003
9019
|
}
|
|
9004
9020
|
for (let i58 = 0; i58 < vector.length; i58++) {
|
|
9005
9021
|
if (!Number.isFinite(vector[i58])) {
|
|
9006
9022
|
throw new Error(`Invalid vector value at index ${i58}: ${vector[i58]}`);
|
|
9007
9023
|
}
|
|
9008
9024
|
}
|
|
9025
|
+
return vector;
|
|
9026
|
+
}
|
|
9027
|
+
/**
|
|
9028
|
+
* Resize vector to target dimensions using averaging (shrink) or zero-padding (grow).
|
|
9029
|
+
*/
|
|
9030
|
+
resizeVector(vector, targetDim) {
|
|
9031
|
+
if (vector.length === targetDim) return vector;
|
|
9032
|
+
if (vector.length > targetDim) {
|
|
9033
|
+
const result2 = new Array(targetDim).fill(0);
|
|
9034
|
+
const ratio = vector.length / targetDim;
|
|
9035
|
+
for (let i58 = 0; i58 < targetDim; i58++) {
|
|
9036
|
+
const start = Math.floor(i58 * ratio);
|
|
9037
|
+
const end = Math.floor((i58 + 1) * ratio);
|
|
9038
|
+
let sum = 0;
|
|
9039
|
+
for (let j52 = start; j52 < end; j52++) {
|
|
9040
|
+
sum += vector[j52];
|
|
9041
|
+
}
|
|
9042
|
+
result2[i58] = sum / (end - start);
|
|
9043
|
+
}
|
|
9044
|
+
return result2;
|
|
9045
|
+
}
|
|
9046
|
+
const result = new Array(targetDim).fill(0);
|
|
9047
|
+
for (let i58 = 0; i58 < vector.length; i58++) {
|
|
9048
|
+
result[i58] = vector[i58];
|
|
9049
|
+
}
|
|
9050
|
+
return result;
|
|
9009
9051
|
}
|
|
9010
9052
|
buildKey(key) {
|
|
9011
9053
|
return `${this.config.namespace}:${key}`;
|
|
@@ -11569,6 +11611,33 @@ ${JSON.stringify(results.map((n61) => ({ id: n61.id, label: n61.label, propertie
|
|
|
11569
11611
|
}
|
|
11570
11612
|
});
|
|
11571
11613
|
|
|
11614
|
+
// src/shared/safe-db.ts
|
|
11615
|
+
var safe_db_exports = {};
|
|
11616
|
+
__export(safe_db_exports, {
|
|
11617
|
+
openDatabase: () => openDatabase
|
|
11618
|
+
});
|
|
11619
|
+
function openDatabase(dbPath, opts) {
|
|
11620
|
+
const readonly = opts?.readonly ?? false;
|
|
11621
|
+
const fileMustExist = opts?.fileMustExist ?? false;
|
|
11622
|
+
const busyTimeout = opts?.busyTimeout ?? 5e3;
|
|
11623
|
+
const walMode = opts?.walMode ?? !readonly;
|
|
11624
|
+
const db = new better_sqlite3_default(dbPath, {
|
|
11625
|
+
readonly,
|
|
11626
|
+
fileMustExist
|
|
11627
|
+
});
|
|
11628
|
+
db.pragma(`busy_timeout = ${busyTimeout}`);
|
|
11629
|
+
if (walMode) {
|
|
11630
|
+
db.pragma("journal_mode = WAL");
|
|
11631
|
+
}
|
|
11632
|
+
return db;
|
|
11633
|
+
}
|
|
11634
|
+
var init_safe_db = __esm({
|
|
11635
|
+
"src/shared/safe-db.ts"() {
|
|
11636
|
+
"use strict";
|
|
11637
|
+
init_better_sqlite3();
|
|
11638
|
+
}
|
|
11639
|
+
});
|
|
11640
|
+
|
|
11572
11641
|
// src/integrations/vibium/types.ts
|
|
11573
11642
|
var init_types3 = __esm({
|
|
11574
11643
|
"src/integrations/vibium/types.ts"() {
|
|
@@ -15037,7 +15106,7 @@ var logger9, V2ToV3Migrator;
|
|
|
15037
15106
|
var init_v2_to_v3_migration = __esm({
|
|
15038
15107
|
"src/learning/v2-to-v3-migration.ts"() {
|
|
15039
15108
|
"use strict";
|
|
15040
|
-
|
|
15109
|
+
init_safe_db();
|
|
15041
15110
|
init_error_utils();
|
|
15042
15111
|
init_safe_json();
|
|
15043
15112
|
init_logging();
|
|
@@ -15139,9 +15208,8 @@ var init_v2_to_v3_migration = __esm({
|
|
|
15139
15208
|
}
|
|
15140
15209
|
}
|
|
15141
15210
|
async connect() {
|
|
15142
|
-
this.v2Db =
|
|
15143
|
-
this.v3Db =
|
|
15144
|
-
this.v3Db.pragma("journal_mode = WAL");
|
|
15211
|
+
this.v2Db = openDatabase(this.config.v2DbPath, { readonly: true });
|
|
15212
|
+
this.v3Db = openDatabase(this.config.v3PatternsDbPath);
|
|
15145
15213
|
this.createV3Schema();
|
|
15146
15214
|
}
|
|
15147
15215
|
async disconnect() {
|
|
@@ -15531,7 +15599,7 @@ var DEFAULT_SQLITE_CONFIG, SQLitePatternStore;
|
|
|
15531
15599
|
var init_sqlite_persistence = __esm({
|
|
15532
15600
|
"src/learning/sqlite-persistence.ts"() {
|
|
15533
15601
|
"use strict";
|
|
15534
|
-
|
|
15602
|
+
init_safe_db();
|
|
15535
15603
|
init_esm_node();
|
|
15536
15604
|
init_safe_json();
|
|
15537
15605
|
init_error_utils();
|
|
@@ -15575,10 +15643,7 @@ var init_sqlite_persistence = __esm({
|
|
|
15575
15643
|
if (!fs23.existsSync(dir)) {
|
|
15576
15644
|
fs23.mkdirSync(dir, { recursive: true });
|
|
15577
15645
|
}
|
|
15578
|
-
this.db =
|
|
15579
|
-
if (this.config.walMode) {
|
|
15580
|
-
this.db.pragma("journal_mode = WAL");
|
|
15581
|
-
}
|
|
15646
|
+
this.db = openDatabase(this.config.dbPath);
|
|
15582
15647
|
this.db.pragma(`mmap_size = ${this.config.mmapSize}`);
|
|
15583
15648
|
this.db.pragma(`cache_size = ${this.config.cacheSize}`);
|
|
15584
15649
|
if (this.config.foreignKeys) {
|
|
@@ -16753,11 +16818,11 @@ __export(hnswlib_node_exports, {
|
|
|
16753
16818
|
init: () => init6,
|
|
16754
16819
|
pipeline: () => pipeline7
|
|
16755
16820
|
});
|
|
16756
|
-
import { createRequire as
|
|
16821
|
+
import { createRequire as createRequire6 } from "module";
|
|
16757
16822
|
var __require7, __mod6, hnswlib_node_default, RuvectorLayer6, TensorCompress6, differentiableSearch6, hierarchicalForward6, getCompressionLevel6, init6, FlashAttention6, DotProductAttention6, MultiHeadAttention6, HyperbolicAttention6, LinearAttention6, MoEAttention6, SonaEngine6, pipeline7;
|
|
16758
16823
|
var init_hnswlib_node = __esm({
|
|
16759
16824
|
"native-require:hnswlib-node"() {
|
|
16760
|
-
__require7 =
|
|
16825
|
+
__require7 = createRequire6(import.meta.url);
|
|
16761
16826
|
__mod6 = __require7("hnswlib-node");
|
|
16762
16827
|
hnswlib_node_default = __mod6;
|
|
16763
16828
|
({
|
|
@@ -16810,11 +16875,11 @@ __export(pg_exports, {
|
|
|
16810
16875
|
init: () => init7,
|
|
16811
16876
|
pipeline: () => pipeline8
|
|
16812
16877
|
});
|
|
16813
|
-
import { createRequire as
|
|
16878
|
+
import { createRequire as createRequire7 } from "module";
|
|
16814
16879
|
var __require8, __mod7, pg_default, RuvectorLayer7, TensorCompress7, differentiableSearch7, hierarchicalForward7, getCompressionLevel7, init7, FlashAttention7, DotProductAttention7, MultiHeadAttention7, HyperbolicAttention7, LinearAttention7, MoEAttention7, SonaEngine7, pipeline8;
|
|
16815
16880
|
var init_pg = __esm({
|
|
16816
16881
|
"native-require:pg"() {
|
|
16817
|
-
__require8 =
|
|
16882
|
+
__require8 = createRequire7(import.meta.url);
|
|
16818
16883
|
__mod7 = __require8("pg");
|
|
16819
16884
|
pg_default = __mod7;
|
|
16820
16885
|
({
|
|
@@ -18265,11 +18330,11 @@ __export(prime_radiant_advanced_wasm_exports, {
|
|
|
18265
18330
|
init: () => init8,
|
|
18266
18331
|
pipeline: () => pipeline9
|
|
18267
18332
|
});
|
|
18268
|
-
import { createRequire as
|
|
18333
|
+
import { createRequire as createRequire8 } from "module";
|
|
18269
18334
|
var __require9, __mod8, prime_radiant_advanced_wasm_default, RuvectorLayer8, TensorCompress8, differentiableSearch8, hierarchicalForward8, getCompressionLevel8, init8, FlashAttention8, DotProductAttention8, MultiHeadAttention8, HyperbolicAttention8, LinearAttention8, MoEAttention8, SonaEngine8, pipeline9;
|
|
18270
18335
|
var init_prime_radiant_advanced_wasm = __esm({
|
|
18271
18336
|
"native-require:prime-radiant-advanced-wasm"() {
|
|
18272
|
-
__require9 =
|
|
18337
|
+
__require9 = createRequire8(import.meta.url);
|
|
18273
18338
|
__mod8 = __require9("prime-radiant-advanced-wasm");
|
|
18274
18339
|
prime_radiant_advanced_wasm_default = __mod8;
|
|
18275
18340
|
({
|
|
@@ -51705,7 +51770,7 @@ var DEFAULT_CONFIG11 = {
|
|
|
51705
51770
|
};
|
|
51706
51771
|
var CoverageAnalyzerService = class _CoverageAnalyzerService {
|
|
51707
51772
|
static DEFAULT_THRESHOLD = 80;
|
|
51708
|
-
static VECTOR_DIMENSION =
|
|
51773
|
+
static VECTOR_DIMENSION = 768;
|
|
51709
51774
|
memory;
|
|
51710
51775
|
config;
|
|
51711
51776
|
llmRouter;
|
|
@@ -52239,7 +52304,7 @@ var DEFAULT_CONFIG12 = {
|
|
|
52239
52304
|
};
|
|
52240
52305
|
var GapDetectorService = class _GapDetectorService {
|
|
52241
52306
|
static DEFAULT_MIN_COVERAGE = 80;
|
|
52242
|
-
static VECTOR_DIMENSION =
|
|
52307
|
+
static VECTOR_DIMENSION = 768;
|
|
52243
52308
|
memory;
|
|
52244
52309
|
config;
|
|
52245
52310
|
llmRouter;
|
|
@@ -53237,7 +53302,7 @@ init_hnsw_index();
|
|
|
53237
53302
|
|
|
53238
53303
|
// src/domains/coverage-analysis/services/coverage-embedder.ts
|
|
53239
53304
|
var DEFAULT_EMBEDDER_CONFIG = {
|
|
53240
|
-
dimensions:
|
|
53305
|
+
dimensions: 768,
|
|
53241
53306
|
includePathFeatures: true,
|
|
53242
53307
|
includeTemporalFeatures: true,
|
|
53243
53308
|
normalization: "l2"
|
|
@@ -53669,7 +53734,7 @@ var ALL_CATEGORIES = [
|
|
|
53669
53734
|
"missing-security-check"
|
|
53670
53735
|
];
|
|
53671
53736
|
var DEFAULT_CONFIG13 = {
|
|
53672
|
-
dimensions:
|
|
53737
|
+
dimensions: 768,
|
|
53673
53738
|
minConfidence: 0.3,
|
|
53674
53739
|
maxGaps: 50,
|
|
53675
53740
|
riskWeight: 0.6,
|
|
@@ -55378,7 +55443,7 @@ var CoverageAnalysisCoordinator = class extends BaseDomainCoordinator {
|
|
|
55378
55443
|
return forecast;
|
|
55379
55444
|
}
|
|
55380
55445
|
createGapEmbedding(gap) {
|
|
55381
|
-
const VECTOR_DIMENSION =
|
|
55446
|
+
const VECTOR_DIMENSION = 768;
|
|
55382
55447
|
const embedding = new Array(VECTOR_DIMENSION).fill(0);
|
|
55383
55448
|
embedding[0] = gap.riskScore;
|
|
55384
55449
|
embedding[1] = Math.min(1, gap.lines.length / 100);
|
|
@@ -70816,7 +70881,35 @@ import { join as join10, extname as extname3 } from "path";
|
|
|
70816
70881
|
// src/domains/code-intelligence/services/metric-collector/interfaces.ts
|
|
70817
70882
|
var DEFAULT_METRIC_CONFIG = {
|
|
70818
70883
|
timeout: 6e4,
|
|
70819
|
-
excludeDirs: [
|
|
70884
|
+
excludeDirs: [
|
|
70885
|
+
// JS/TS ecosystem
|
|
70886
|
+
"node_modules",
|
|
70887
|
+
"dist",
|
|
70888
|
+
"build",
|
|
70889
|
+
"coverage",
|
|
70890
|
+
".nyc_output",
|
|
70891
|
+
".next",
|
|
70892
|
+
".nuxt",
|
|
70893
|
+
".output",
|
|
70894
|
+
// Python ecosystem
|
|
70895
|
+
"__pycache__",
|
|
70896
|
+
".venv",
|
|
70897
|
+
"venv",
|
|
70898
|
+
".tox",
|
|
70899
|
+
".mypy_cache",
|
|
70900
|
+
".pytest_cache",
|
|
70901
|
+
".eggs",
|
|
70902
|
+
"*.egg-info",
|
|
70903
|
+
// Rust / Java / Go
|
|
70904
|
+
"target",
|
|
70905
|
+
".gradle",
|
|
70906
|
+
"vendor",
|
|
70907
|
+
".bundle",
|
|
70908
|
+
// General
|
|
70909
|
+
".git",
|
|
70910
|
+
".svn",
|
|
70911
|
+
".hg"
|
|
70912
|
+
],
|
|
70820
70913
|
testPatterns: ["**/*.test.ts", "**/*.spec.ts", "**/*.test.js", "**/*.spec.js"],
|
|
70821
70914
|
enableCache: true,
|
|
70822
70915
|
cacheTTL: 3e5
|
|
@@ -70824,7 +70917,7 @@ var DEFAULT_METRIC_CONFIG = {
|
|
|
70824
70917
|
|
|
70825
70918
|
// src/domains/code-intelligence/services/metric-collector/loc-counter.ts
|
|
70826
70919
|
import { execSync as execSync3, spawnSync as spawnSync2 } from "child_process";
|
|
70827
|
-
import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5 } from "fs";
|
|
70920
|
+
import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
|
|
70828
70921
|
import { join as join8, extname } from "path";
|
|
70829
70922
|
init_safe_json();
|
|
70830
70923
|
async function countLOC(projectPath, config = {}) {
|
|
@@ -70968,22 +71061,35 @@ function getLanguageForExtension(ext) {
|
|
|
70968
71061
|
function manualLOCCount(projectPath, config) {
|
|
70969
71062
|
const byLanguage = {};
|
|
70970
71063
|
let total = 0;
|
|
70971
|
-
|
|
70972
|
-
|
|
71064
|
+
const excludeSet = new Set(config.excludeDirs);
|
|
71065
|
+
const MAX_FILE_SIZE = 2 * 1024 * 1024;
|
|
71066
|
+
function walkDirectory3(dirPath, depth) {
|
|
71067
|
+
if (!existsSync6(dirPath) || depth > 20) {
|
|
71068
|
+
return;
|
|
71069
|
+
}
|
|
71070
|
+
let entries;
|
|
71071
|
+
try {
|
|
71072
|
+
entries = readdirSync(dirPath, { withFileTypes: true });
|
|
71073
|
+
} catch {
|
|
70973
71074
|
return;
|
|
70974
71075
|
}
|
|
70975
|
-
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
70976
71076
|
for (const entry of entries) {
|
|
70977
71077
|
const fullPath = join8(dirPath, entry.name);
|
|
70978
71078
|
if (entry.isDirectory()) {
|
|
70979
|
-
if (
|
|
71079
|
+
if (excludeSet.has(entry.name) || entry.name.startsWith(".")) {
|
|
70980
71080
|
continue;
|
|
70981
71081
|
}
|
|
70982
|
-
walkDirectory3(fullPath);
|
|
71082
|
+
walkDirectory3(fullPath, depth + 1);
|
|
70983
71083
|
} else if (entry.isFile()) {
|
|
70984
71084
|
const ext = extname(entry.name);
|
|
70985
71085
|
const language = getLanguageForExtension(ext);
|
|
70986
71086
|
if (language) {
|
|
71087
|
+
try {
|
|
71088
|
+
const stat4 = statSync2(fullPath);
|
|
71089
|
+
if (stat4.size > MAX_FILE_SIZE) continue;
|
|
71090
|
+
} catch {
|
|
71091
|
+
continue;
|
|
71092
|
+
}
|
|
70987
71093
|
const lines = countFileLines(fullPath);
|
|
70988
71094
|
byLanguage[language] = (byLanguage[language] || 0) + lines;
|
|
70989
71095
|
total += lines;
|
|
@@ -70991,11 +71097,11 @@ function manualLOCCount(projectPath, config) {
|
|
|
70991
71097
|
}
|
|
70992
71098
|
}
|
|
70993
71099
|
}
|
|
70994
|
-
walkDirectory3(projectPath);
|
|
71100
|
+
walkDirectory3(projectPath, 0);
|
|
70995
71101
|
return {
|
|
70996
71102
|
total,
|
|
70997
71103
|
byLanguage,
|
|
70998
|
-
source: "
|
|
71104
|
+
source: "node-native",
|
|
70999
71105
|
excludedDirs: config.excludeDirs
|
|
71000
71106
|
};
|
|
71001
71107
|
}
|
|
@@ -71626,12 +71732,19 @@ var MetricCollectorService = class {
|
|
|
71626
71732
|
const toolsUsed = [];
|
|
71627
71733
|
if (loc.source !== "fallback") toolsUsed.push(loc.source);
|
|
71628
71734
|
if (tests.source !== "fallback") toolsUsed.push(tests.source);
|
|
71735
|
+
const locAccuracy = loc.source === "fallback" ? "approximate" : "accurate";
|
|
71736
|
+
const testAccuracy = tests.source === "fallback" ? "approximate" : "accurate";
|
|
71629
71737
|
const metrics = {
|
|
71630
71738
|
loc,
|
|
71631
71739
|
tests,
|
|
71632
71740
|
patterns,
|
|
71633
71741
|
collectedAt: /* @__PURE__ */ new Date(),
|
|
71634
|
-
toolsUsed
|
|
71742
|
+
toolsUsed,
|
|
71743
|
+
accuracy: {
|
|
71744
|
+
loc: locAccuracy,
|
|
71745
|
+
tests: testAccuracy,
|
|
71746
|
+
overall: locAccuracy === "accurate" && testAccuracy === "accurate" ? "accurate" : "approximate"
|
|
71747
|
+
}
|
|
71635
71748
|
};
|
|
71636
71749
|
if (this.config.enableCache) {
|
|
71637
71750
|
this.setInCache(cacheKey, metrics);
|
|
@@ -73185,7 +73298,7 @@ var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
|
|
|
73185
73298
|
*/
|
|
73186
73299
|
async initializeHypergraph() {
|
|
73187
73300
|
try {
|
|
73188
|
-
const
|
|
73301
|
+
const { openDatabase: openDatabase2 } = await Promise.resolve().then(() => (init_safe_db(), safe_db_exports));
|
|
73189
73302
|
const fs23 = await import("fs");
|
|
73190
73303
|
const path26 = await import("path");
|
|
73191
73304
|
const { findProjectRoot: findProjectRoot2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
|
|
@@ -73195,7 +73308,7 @@ var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
|
|
|
73195
73308
|
if (!fs23.existsSync(dir)) {
|
|
73196
73309
|
fs23.mkdirSync(dir, { recursive: true });
|
|
73197
73310
|
}
|
|
73198
|
-
this.hypergraphDb =
|
|
73311
|
+
this.hypergraphDb = openDatabase2(dbPath);
|
|
73199
73312
|
this.hypergraph = await createHypergraphEngine({
|
|
73200
73313
|
db: this.hypergraphDb,
|
|
73201
73314
|
maxTraversalDepth: 10,
|
|
@@ -73861,9 +73974,15 @@ var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
|
|
|
73861
73974
|
try {
|
|
73862
73975
|
console.log(`[CodeIntelligence] Collecting real metrics for ${projectPath}`);
|
|
73863
73976
|
const metrics = await this.metricCollector.collectAll(projectPath);
|
|
73977
|
+
const toolsLabel = metrics.toolsUsed.length > 0 ? metrics.toolsUsed.join(", ") : metrics.loc.source === "node-native" ? "node-native" : "fallback";
|
|
73864
73978
|
console.log(
|
|
73865
|
-
`[CodeIntelligence] Real metrics collected: ${metrics.loc.total} LOC, ${metrics.tests.total} tests, tools: ${
|
|
73979
|
+
`[CodeIntelligence] Real metrics collected: ${metrics.loc.total} LOC, ${metrics.tests.total} tests, tools: ${toolsLabel}`
|
|
73866
73980
|
);
|
|
73981
|
+
if (metrics.loc.source === "node-native") {
|
|
73982
|
+
console.log(
|
|
73983
|
+
`[CodeIntelligence] Using Node.js-native line counter (no cloc/tokei needed)`
|
|
73984
|
+
);
|
|
73985
|
+
}
|
|
73867
73986
|
await this.storeProjectMetricsInMemory(projectPath, metrics);
|
|
73868
73987
|
if (this.config.publishEvents) {
|
|
73869
73988
|
const event = createEvent(
|
|
@@ -115318,7 +115437,7 @@ var ALL_DOMAINS2 = [
|
|
|
115318
115437
|
"enterprise-integration"
|
|
115319
115438
|
];
|
|
115320
115439
|
function getAQEVersion() {
|
|
115321
|
-
return true ? "3.6.
|
|
115440
|
+
return true ? "3.6.12" : "3.0.0";
|
|
115322
115441
|
}
|
|
115323
115442
|
function createDefaultConfig(projectName, projectRoot) {
|
|
115324
115443
|
return {
|
|
@@ -116224,14 +116343,12 @@ function createSelfConfigurator(options) {
|
|
|
116224
116343
|
// src/init/init-wizard-migration.ts
|
|
116225
116344
|
import { existsSync as existsSync15, mkdirSync as mkdirSync5, writeFileSync as writeFileSync2, readFileSync as readFileSync12, readdirSync as readdirSync5, statSync as statSync5, unlinkSync as unlinkSync2, copyFileSync as copyFileSync2 } from "fs";
|
|
116226
116345
|
import { join as join17, dirname as dirname4 } from "path";
|
|
116227
|
-
import { createRequire as createRequire6 } from "module";
|
|
116228
116346
|
init_error_utils();
|
|
116229
116347
|
init_safe_json();
|
|
116230
|
-
|
|
116348
|
+
init_safe_db();
|
|
116231
116349
|
function readVersionFromDb(dbPath) {
|
|
116232
116350
|
try {
|
|
116233
|
-
const
|
|
116234
|
-
const db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
116351
|
+
const db = openDatabase(dbPath, { readonly: true, fileMustExist: true });
|
|
116235
116352
|
try {
|
|
116236
116353
|
const tableExists = db.prepare(`
|
|
116237
116354
|
SELECT name FROM sqlite_master
|
|
@@ -116265,8 +116382,7 @@ async function writeVersionToDb(projectRoot, version) {
|
|
|
116265
116382
|
if (!existsSync15(dir)) {
|
|
116266
116383
|
mkdirSync5(dir, { recursive: true });
|
|
116267
116384
|
}
|
|
116268
|
-
const
|
|
116269
|
-
const db = new Database(memoryDbPath);
|
|
116385
|
+
const db = openDatabase(memoryDbPath);
|
|
116270
116386
|
try {
|
|
116271
116387
|
db.exec(`
|
|
116272
116388
|
CREATE TABLE IF NOT EXISTS kv_store (
|
|
@@ -116525,6 +116641,110 @@ function readJsonSafe(filePath) {
|
|
|
116525
116641
|
init_safe_json();
|
|
116526
116642
|
import { existsSync as existsSync16, mkdirSync as mkdirSync6, writeFileSync as writeFileSync3, readFileSync as readFileSync13, copyFileSync as copyFileSync3 } from "fs";
|
|
116527
116643
|
import { join as join18, dirname as dirname5 } from "path";
|
|
116644
|
+
|
|
116645
|
+
// src/init/settings-merge.ts
|
|
116646
|
+
var AQE_COMMAND_PATTERNS = [
|
|
116647
|
+
/\baqe\b/i,
|
|
116648
|
+
/\bagentic-qe\b/i,
|
|
116649
|
+
/\bnpx\s+agentic-qe\b/i,
|
|
116650
|
+
/\bnpx\s+@anthropics\/agentic-qe\b/i
|
|
116651
|
+
];
|
|
116652
|
+
function isAqeHookEntry(entry) {
|
|
116653
|
+
const hookEntry = entry;
|
|
116654
|
+
if (!hookEntry?.hooks || !Array.isArray(hookEntry.hooks)) return false;
|
|
116655
|
+
return hookEntry.hooks.some((h66) => {
|
|
116656
|
+
if (!h66.command || typeof h66.command !== "string") return false;
|
|
116657
|
+
return AQE_COMMAND_PATTERNS.some((pattern) => pattern.test(h66.command));
|
|
116658
|
+
});
|
|
116659
|
+
}
|
|
116660
|
+
function mergeHooksSmart(existingHooks, newAqeHooks) {
|
|
116661
|
+
const merged = {};
|
|
116662
|
+
for (const [hookType, newEntries] of Object.entries(newAqeHooks)) {
|
|
116663
|
+
const existing = existingHooks[hookType] || [];
|
|
116664
|
+
const userEntries = Array.isArray(existing) ? existing.filter((entry) => !isAqeHookEntry(entry)) : [];
|
|
116665
|
+
merged[hookType] = [...newEntries, ...userEntries];
|
|
116666
|
+
}
|
|
116667
|
+
for (const [hookType, hookArray] of Object.entries(existingHooks)) {
|
|
116668
|
+
if (!merged[hookType]) {
|
|
116669
|
+
merged[hookType] = hookArray;
|
|
116670
|
+
}
|
|
116671
|
+
}
|
|
116672
|
+
return merged;
|
|
116673
|
+
}
|
|
116674
|
+
function generateAqeEnvVars(config) {
|
|
116675
|
+
const domains = config.domains?.enabled || [];
|
|
116676
|
+
return {
|
|
116677
|
+
AQE_MEMORY_PATH: ".agentic-qe/memory.db",
|
|
116678
|
+
AQE_MEMORY_ENABLED: "true",
|
|
116679
|
+
AQE_LEARNING_ENABLED: config.learning?.enabled ? "true" : "false",
|
|
116680
|
+
AQE_V3_MODE: "true",
|
|
116681
|
+
AQE_V3_DDD_ENABLED: "true",
|
|
116682
|
+
AQE_V3_DOMAINS: domains.join(","),
|
|
116683
|
+
AQE_V3_SWARM_SIZE: String(config.agents?.maxConcurrent ?? 15),
|
|
116684
|
+
AQE_V3_TOPOLOGY: "hierarchical",
|
|
116685
|
+
AQE_V3_SUBLINEAR_ENABLED: "true",
|
|
116686
|
+
AQE_V3_HNSW_ENABLED: config.learning?.hnswConfig ? "true" : "false",
|
|
116687
|
+
AQE_V3_HOOKS_ENABLED: "true",
|
|
116688
|
+
AQE_V3_HOOK_BRIDGE: ".claude/hooks/v3-qe-bridge.sh",
|
|
116689
|
+
AQE_V3_DOMAIN_WORKERS: ".claude/hooks/v3-domain-workers.json",
|
|
116690
|
+
AQE_V3_AISP_ENABLED: "true",
|
|
116691
|
+
AQE_V3_REASONING_BANK: ".agentic-qe/memory.db",
|
|
116692
|
+
AQE_V3_PATTERN_PROMOTION_THRESHOLD: String(config.learning?.promotionThreshold ?? 3),
|
|
116693
|
+
AQE_V3_SUCCESS_RATE_THRESHOLD: String(config.learning?.qualityThreshold ?? 0.7)
|
|
116694
|
+
};
|
|
116695
|
+
}
|
|
116696
|
+
function generateV3SettingsSections(config) {
|
|
116697
|
+
const domains = config.domains?.enabled || [];
|
|
116698
|
+
return {
|
|
116699
|
+
aqe: {
|
|
116700
|
+
version: config.version ?? "3.0.0",
|
|
116701
|
+
initialized: (/* @__PURE__ */ new Date()).toISOString(),
|
|
116702
|
+
hooksConfigured: true
|
|
116703
|
+
},
|
|
116704
|
+
statusLine: {
|
|
116705
|
+
type: "command",
|
|
116706
|
+
command: 'node .claude/helpers/statusline-v3.cjs 2>/dev/null || .claude/statusline-v3.sh 2>/dev/null || echo "\u258A Agentic QE v3"',
|
|
116707
|
+
refreshMs: 5e3,
|
|
116708
|
+
enabled: true
|
|
116709
|
+
},
|
|
116710
|
+
permissions: {
|
|
116711
|
+
allow: [
|
|
116712
|
+
"Bash(npx claude-flow:*)",
|
|
116713
|
+
"Bash(npx @claude-flow/cli:*)",
|
|
116714
|
+
"mcp__claude-flow__:*",
|
|
116715
|
+
"mcp__agentic_qe__*"
|
|
116716
|
+
],
|
|
116717
|
+
deny: [
|
|
116718
|
+
"Bash(rm -rf /)"
|
|
116719
|
+
]
|
|
116720
|
+
},
|
|
116721
|
+
includeCoAuthoredBy: true,
|
|
116722
|
+
v3Configuration: {
|
|
116723
|
+
domains: {
|
|
116724
|
+
total: domains.length,
|
|
116725
|
+
names: domains
|
|
116726
|
+
},
|
|
116727
|
+
swarm: {
|
|
116728
|
+
totalAgents: config.agents?.maxConcurrent ?? 15,
|
|
116729
|
+
topology: "hierarchical",
|
|
116730
|
+
coordination: "queen-led"
|
|
116731
|
+
}
|
|
116732
|
+
},
|
|
116733
|
+
v3Learning: {
|
|
116734
|
+
enabled: config.learning?.enabled ?? true,
|
|
116735
|
+
reasoningBank: {
|
|
116736
|
+
dbPath: ".agentic-qe/memory.db",
|
|
116737
|
+
enableHNSW: !!config.learning?.hnswConfig
|
|
116738
|
+
},
|
|
116739
|
+
patternPromotion: {
|
|
116740
|
+
threshold: config.learning?.promotionThreshold ?? 3,
|
|
116741
|
+
successRateMin: config.learning?.qualityThreshold ?? 0.7
|
|
116742
|
+
}
|
|
116743
|
+
}
|
|
116744
|
+
};
|
|
116745
|
+
}
|
|
116746
|
+
|
|
116747
|
+
// src/init/init-wizard-hooks.ts
|
|
116528
116748
|
async function configureHooks(projectRoot, config) {
|
|
116529
116749
|
if (!config.hooks.claudeCode) {
|
|
116530
116750
|
return false;
|
|
@@ -116543,14 +116763,25 @@ async function configureHooks(projectRoot, config) {
|
|
|
116543
116763
|
settings = {};
|
|
116544
116764
|
}
|
|
116545
116765
|
}
|
|
116546
|
-
const
|
|
116766
|
+
const aqeHooks = {
|
|
116547
116767
|
PreToolUse: [
|
|
116548
116768
|
{
|
|
116549
116769
|
matcher: "^(Write|Edit|MultiEdit)$",
|
|
116550
116770
|
hooks: [
|
|
116551
116771
|
{
|
|
116552
116772
|
type: "command",
|
|
116553
|
-
command: '
|
|
116773
|
+
command: 'npx agentic-qe hooks guard --file "$TOOL_INPUT_file_path" --json',
|
|
116774
|
+
timeout: 3e3,
|
|
116775
|
+
continueOnError: true
|
|
116776
|
+
}
|
|
116777
|
+
]
|
|
116778
|
+
},
|
|
116779
|
+
{
|
|
116780
|
+
matcher: "^(Write|Edit|MultiEdit)$",
|
|
116781
|
+
hooks: [
|
|
116782
|
+
{
|
|
116783
|
+
type: "command",
|
|
116784
|
+
command: 'npx agentic-qe hooks pre-edit --file "$TOOL_INPUT_file_path" --json',
|
|
116554
116785
|
timeout: 5e3,
|
|
116555
116786
|
continueOnError: true
|
|
116556
116787
|
}
|
|
@@ -116561,8 +116792,8 @@ async function configureHooks(projectRoot, config) {
|
|
|
116561
116792
|
hooks: [
|
|
116562
116793
|
{
|
|
116563
116794
|
type: "command",
|
|
116564
|
-
command: '
|
|
116565
|
-
timeout:
|
|
116795
|
+
command: 'npx agentic-qe hooks pre-command --command "$TOOL_INPUT_command" --json',
|
|
116796
|
+
timeout: 3e3,
|
|
116566
116797
|
continueOnError: true
|
|
116567
116798
|
}
|
|
116568
116799
|
]
|
|
@@ -116572,7 +116803,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116572
116803
|
hooks: [
|
|
116573
116804
|
{
|
|
116574
116805
|
type: "command",
|
|
116575
|
-
command: '
|
|
116806
|
+
command: 'npx agentic-qe hooks pre-task --description "$TOOL_INPUT_prompt" --json',
|
|
116576
116807
|
timeout: 5e3,
|
|
116577
116808
|
continueOnError: true
|
|
116578
116809
|
}
|
|
@@ -116585,7 +116816,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116585
116816
|
hooks: [
|
|
116586
116817
|
{
|
|
116587
116818
|
type: "command",
|
|
116588
|
-
command: '
|
|
116819
|
+
command: 'npx agentic-qe hooks post-edit --file "$TOOL_INPUT_file_path" --success --json',
|
|
116589
116820
|
timeout: 5e3,
|
|
116590
116821
|
continueOnError: true
|
|
116591
116822
|
}
|
|
@@ -116596,7 +116827,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116596
116827
|
hooks: [
|
|
116597
116828
|
{
|
|
116598
116829
|
type: "command",
|
|
116599
|
-
command: '
|
|
116830
|
+
command: 'npx agentic-qe hooks post-command --command "$TOOL_INPUT_command" --success --json',
|
|
116600
116831
|
timeout: 5e3,
|
|
116601
116832
|
continueOnError: true
|
|
116602
116833
|
}
|
|
@@ -116607,7 +116838,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116607
116838
|
hooks: [
|
|
116608
116839
|
{
|
|
116609
116840
|
type: "command",
|
|
116610
|
-
command: '
|
|
116841
|
+
command: 'npx agentic-qe hooks post-task --task-id "$TOOL_RESULT_agent_id" --success --json',
|
|
116611
116842
|
timeout: 5e3,
|
|
116612
116843
|
continueOnError: true
|
|
116613
116844
|
}
|
|
@@ -116619,7 +116850,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116619
116850
|
hooks: [
|
|
116620
116851
|
{
|
|
116621
116852
|
type: "command",
|
|
116622
|
-
command: '
|
|
116853
|
+
command: 'npx agentic-qe hooks route --task "$PROMPT" --json',
|
|
116623
116854
|
timeout: 5e3,
|
|
116624
116855
|
continueOnError: true
|
|
116625
116856
|
}
|
|
@@ -116631,7 +116862,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116631
116862
|
hooks: [
|
|
116632
116863
|
{
|
|
116633
116864
|
type: "command",
|
|
116634
|
-
command: '
|
|
116865
|
+
command: 'npx agentic-qe hooks session-start --session-id "$SESSION_ID" --json',
|
|
116635
116866
|
timeout: 1e4,
|
|
116636
116867
|
continueOnError: true
|
|
116637
116868
|
}
|
|
@@ -116643,7 +116874,7 @@ async function configureHooks(projectRoot, config) {
|
|
|
116643
116874
|
hooks: [
|
|
116644
116875
|
{
|
|
116645
116876
|
type: "command",
|
|
116646
|
-
command: "
|
|
116877
|
+
command: "npx agentic-qe hooks session-end --save-state --json",
|
|
116647
116878
|
timeout: 5e3,
|
|
116648
116879
|
continueOnError: true
|
|
116649
116880
|
}
|
|
@@ -116652,33 +116883,22 @@ async function configureHooks(projectRoot, config) {
|
|
|
116652
116883
|
]
|
|
116653
116884
|
};
|
|
116654
116885
|
const existingHooks = settings.hooks || {};
|
|
116655
|
-
|
|
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;
|
|
116886
|
+
settings.hooks = mergeHooksSmart(existingHooks, aqeHooks);
|
|
116666
116887
|
const existingEnv = settings.env || {};
|
|
116667
116888
|
settings.env = {
|
|
116668
116889
|
...existingEnv,
|
|
116669
|
-
|
|
116670
|
-
AQE_V3_MODE: "true",
|
|
116671
|
-
AQE_LEARNING_ENABLED: config.learning.enabled ? "true" : "false"
|
|
116890
|
+
...generateAqeEnvVars(config)
|
|
116672
116891
|
};
|
|
116673
|
-
|
|
116674
|
-
|
|
116675
|
-
|
|
116676
|
-
|
|
116677
|
-
|
|
116678
|
-
|
|
116679
|
-
if (!existingMcp.includes("
|
|
116680
|
-
|
|
116892
|
+
const v3Sections = generateV3SettingsSections(config);
|
|
116893
|
+
for (const [key, value] of Object.entries(v3Sections)) {
|
|
116894
|
+
settings[key] = value;
|
|
116895
|
+
}
|
|
116896
|
+
let existingMcp = settings.enabledMcpjsonServers || [];
|
|
116897
|
+
existingMcp = existingMcp.filter((s70) => s70 !== "aqe");
|
|
116898
|
+
if (!existingMcp.includes("agentic-qe")) {
|
|
116899
|
+
existingMcp.push("agentic-qe");
|
|
116681
116900
|
}
|
|
116901
|
+
settings.enabledMcpjsonServers = existingMcp;
|
|
116682
116902
|
writeFileSync3(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
116683
116903
|
await installCrossPhaseMemoryHooks(projectRoot);
|
|
116684
116904
|
return true;
|
|
@@ -118290,6 +118510,7 @@ function createN8nInstaller(options) {
|
|
|
118290
118510
|
|
|
118291
118511
|
// src/init/init-wizard-steps.ts
|
|
118292
118512
|
init_error_utils();
|
|
118513
|
+
init_safe_db();
|
|
118293
118514
|
async function initializePersistenceDatabase(projectRoot) {
|
|
118294
118515
|
let Database = null;
|
|
118295
118516
|
try {
|
|
@@ -118349,8 +118570,7 @@ async function checkCodeIntelligenceIndex(projectRoot) {
|
|
|
118349
118570
|
return false;
|
|
118350
118571
|
}
|
|
118351
118572
|
try {
|
|
118352
|
-
const
|
|
118353
|
-
const db = new Database(dbPath);
|
|
118573
|
+
const db = openDatabase(dbPath);
|
|
118354
118574
|
const result = db.prepare(`
|
|
118355
118575
|
SELECT COUNT(*) as count FROM kv_store
|
|
118356
118576
|
WHERE namespace = 'code-intelligence:kg'
|
|
@@ -118403,8 +118623,7 @@ async function runCodeIntelligenceScan(projectPath) {
|
|
|
118403
118623
|
async function getKGEntryCount(projectRoot) {
|
|
118404
118624
|
const dbPath = join22(projectRoot, ".agentic-qe", "memory.db");
|
|
118405
118625
|
try {
|
|
118406
|
-
const
|
|
118407
|
-
const db = new Database(dbPath);
|
|
118626
|
+
const db = openDatabase(dbPath);
|
|
118408
118627
|
const result = db.prepare(`
|
|
118409
118628
|
SELECT COUNT(*) as count FROM kv_store
|
|
118410
118629
|
WHERE namespace LIKE 'code-intelligence:kg%'
|
|
@@ -119079,10 +119298,9 @@ var BasePhase = class {
|
|
|
119079
119298
|
|
|
119080
119299
|
// src/init/phases/01-detection.ts
|
|
119081
119300
|
init_safe_json();
|
|
119301
|
+
init_safe_db();
|
|
119082
119302
|
import { existsSync as existsSync21 } from "fs";
|
|
119083
119303
|
import { join as join23 } from "path";
|
|
119084
|
-
import { createRequire as createRequire7 } from "module";
|
|
119085
|
-
var require3 = createRequire7(import.meta.url);
|
|
119086
119304
|
var DetectionPhase = class extends BasePhase {
|
|
119087
119305
|
name = "detection";
|
|
119088
119306
|
description = "Detect existing installations";
|
|
@@ -119171,8 +119389,7 @@ var DetectionPhase = class extends BasePhase {
|
|
|
119171
119389
|
*/
|
|
119172
119390
|
readVersionFromDb(dbPath) {
|
|
119173
119391
|
try {
|
|
119174
|
-
const
|
|
119175
|
-
const db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
119392
|
+
const db = openDatabase(dbPath, { readonly: true, fileMustExist: true });
|
|
119176
119393
|
try {
|
|
119177
119394
|
const tableExists = db.prepare(`
|
|
119178
119395
|
SELECT name FROM sqlite_master
|
|
@@ -119442,6 +119659,7 @@ var LearningPhase = class extends BasePhase {
|
|
|
119442
119659
|
|
|
119443
119660
|
// src/init/phases/06-code-intelligence.ts
|
|
119444
119661
|
init_safe_json();
|
|
119662
|
+
init_safe_db();
|
|
119445
119663
|
import { existsSync as existsSync24, statSync as statSync8 } from "fs";
|
|
119446
119664
|
import { join as join26 } from "path";
|
|
119447
119665
|
var SCAN_IGNORE_PATTERNS = [
|
|
@@ -119511,8 +119729,7 @@ var CodeIntelligencePhase = class extends BasePhase {
|
|
|
119511
119729
|
return false;
|
|
119512
119730
|
}
|
|
119513
119731
|
try {
|
|
119514
|
-
const
|
|
119515
|
-
const db = new Database(dbPath);
|
|
119732
|
+
const db = openDatabase(dbPath);
|
|
119516
119733
|
const result = db.prepare(`
|
|
119517
119734
|
SELECT COUNT(*) as count FROM kv_store
|
|
119518
119735
|
WHERE namespace = 'code-intelligence:kg'
|
|
@@ -119529,8 +119746,7 @@ var CodeIntelligencePhase = class extends BasePhase {
|
|
|
119529
119746
|
async getKGEntryCount(projectRoot) {
|
|
119530
119747
|
const dbPath = join26(projectRoot, ".agentic-qe", "memory.db");
|
|
119531
119748
|
try {
|
|
119532
|
-
const
|
|
119533
|
-
const db = new Database(dbPath);
|
|
119749
|
+
const db = openDatabase(dbPath);
|
|
119534
119750
|
const result = db.prepare(`
|
|
119535
119751
|
SELECT COUNT(*) as count FROM kv_store
|
|
119536
119752
|
WHERE namespace LIKE 'code-intelligence:kg%'
|
|
@@ -119609,8 +119825,7 @@ var CodeIntelligencePhase = class extends BasePhase {
|
|
|
119609
119825
|
async getLastIndexedAt(projectRoot) {
|
|
119610
119826
|
const dbPath = join26(projectRoot, ".agentic-qe", "memory.db");
|
|
119611
119827
|
try {
|
|
119612
|
-
const
|
|
119613
|
-
const db = new Database(dbPath);
|
|
119828
|
+
const db = openDatabase(dbPath);
|
|
119614
119829
|
const row = db.prepare(`
|
|
119615
119830
|
SELECT value FROM kv_store
|
|
119616
119831
|
WHERE namespace = 'code-intelligence:kg'
|
|
@@ -119677,13 +119892,18 @@ var HooksPhase = class extends BasePhase {
|
|
|
119677
119892
|
return {
|
|
119678
119893
|
configured: false,
|
|
119679
119894
|
settingsPath: "",
|
|
119680
|
-
hookTypes: []
|
|
119895
|
+
hookTypes: [],
|
|
119896
|
+
existingAqeDetected: false
|
|
119681
119897
|
};
|
|
119682
119898
|
}
|
|
119683
119899
|
const claudeDir = join27(projectRoot, ".claude");
|
|
119684
119900
|
if (!existsSync25(claudeDir)) {
|
|
119685
119901
|
mkdirSync13(claudeDir, { recursive: true });
|
|
119686
119902
|
}
|
|
119903
|
+
const hooksDir = join27(claudeDir, "hooks");
|
|
119904
|
+
if (!existsSync25(hooksDir)) {
|
|
119905
|
+
mkdirSync13(hooksDir, { recursive: true });
|
|
119906
|
+
}
|
|
119687
119907
|
const settingsPath = join27(claudeDir, "settings.json");
|
|
119688
119908
|
let settings = {};
|
|
119689
119909
|
if (existsSync25(settingsPath)) {
|
|
@@ -119694,61 +119914,131 @@ var HooksPhase = class extends BasePhase {
|
|
|
119694
119914
|
settings = {};
|
|
119695
119915
|
}
|
|
119696
119916
|
}
|
|
119697
|
-
const
|
|
119698
|
-
const hookTypes = Object.keys(
|
|
119917
|
+
const aqeHooks = this.generateHooksConfig(config);
|
|
119918
|
+
const hookTypes = Object.keys(aqeHooks);
|
|
119699
119919
|
const existingHooks = settings.hooks || {};
|
|
119700
|
-
const
|
|
119701
|
-
|
|
119702
|
-
|
|
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];
|
|
119920
|
+
const existingAqeDetected = this.hasExistingAqeHooks(existingHooks);
|
|
119921
|
+
if (existingAqeDetected) {
|
|
119922
|
+
context2.services.log(" Detected existing AQE hooks \u2014 replacing with updated config");
|
|
119720
119923
|
}
|
|
119721
|
-
|
|
119722
|
-
if (!mergedHooks[hookType]) {
|
|
119723
|
-
mergedHooks[hookType] = hookArray;
|
|
119724
|
-
}
|
|
119725
|
-
}
|
|
119726
|
-
settings.hooks = mergedHooks;
|
|
119924
|
+
settings.hooks = mergeHooksSmart(existingHooks, aqeHooks);
|
|
119727
119925
|
const existingEnv = settings.env || {};
|
|
119728
119926
|
settings.env = {
|
|
119729
119927
|
...existingEnv,
|
|
119730
|
-
|
|
119731
|
-
AQE_V3_MODE: "true",
|
|
119732
|
-
AQE_LEARNING_ENABLED: config.learning.enabled ? "true" : "false"
|
|
119928
|
+
...generateAqeEnvVars(config)
|
|
119733
119929
|
};
|
|
119734
|
-
|
|
119735
|
-
|
|
119736
|
-
|
|
119737
|
-
|
|
119738
|
-
|
|
119739
|
-
|
|
119740
|
-
if (!existingMcp.includes("
|
|
119741
|
-
|
|
119930
|
+
const v3Sections = generateV3SettingsSections(config);
|
|
119931
|
+
for (const [key, value] of Object.entries(v3Sections)) {
|
|
119932
|
+
settings[key] = value;
|
|
119933
|
+
}
|
|
119934
|
+
let existingMcp = settings.enabledMcpjsonServers || [];
|
|
119935
|
+
existingMcp = existingMcp.filter((s70) => s70 !== "aqe");
|
|
119936
|
+
if (!existingMcp.includes("agentic-qe")) {
|
|
119937
|
+
existingMcp.push("agentic-qe");
|
|
119742
119938
|
}
|
|
119939
|
+
settings.enabledMcpjsonServers = existingMcp;
|
|
119743
119940
|
writeFileSync9(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
119941
|
+
this.writeHooksReadme(hooksDir, hookTypes);
|
|
119942
|
+
this.installHookAssets(hooksDir, context2);
|
|
119744
119943
|
context2.services.log(` Settings: ${settingsPath}`);
|
|
119944
|
+
context2.services.log(` Hooks dir: ${hooksDir}`);
|
|
119745
119945
|
context2.services.log(` Hook types: ${hookTypes.join(", ")}`);
|
|
119746
119946
|
return {
|
|
119747
119947
|
configured: true,
|
|
119748
119948
|
settingsPath,
|
|
119749
|
-
hookTypes
|
|
119949
|
+
hookTypes,
|
|
119950
|
+
existingAqeDetected
|
|
119750
119951
|
};
|
|
119751
119952
|
}
|
|
119953
|
+
/**
|
|
119954
|
+
* Write a README to .claude/hooks/ explaining the hook setup.
|
|
119955
|
+
* Actual hook config lives in .claude/settings.json (Claude Code reads it from there).
|
|
119956
|
+
* The hooks dir contains supporting infrastructure (bridge script, workers config).
|
|
119957
|
+
*/
|
|
119958
|
+
writeHooksReadme(hooksDir, hookTypes) {
|
|
119959
|
+
const readmePath = join27(hooksDir, "README.txt");
|
|
119960
|
+
if (existsSync25(readmePath)) return;
|
|
119961
|
+
const content = [
|
|
119962
|
+
"AQE Hooks Directory",
|
|
119963
|
+
"====================",
|
|
119964
|
+
"",
|
|
119965
|
+
"Claude Code hooks are configured in .claude/settings.json (not as files here).",
|
|
119966
|
+
"This directory contains supporting infrastructure for the learning system.",
|
|
119967
|
+
"",
|
|
119968
|
+
"Configured hook types: " + hookTypes.join(", "),
|
|
119969
|
+
"",
|
|
119970
|
+
"Files:",
|
|
119971
|
+
" settings.json \u2014 Hook definitions (in parent .claude/ directory)",
|
|
119972
|
+
" v3-qe-bridge.sh \u2014 Bridge script connecting Claude Code events to QE learning",
|
|
119973
|
+
" v3-domain-workers.json \u2014 Domain worker configuration",
|
|
119974
|
+
" cross-phase-memory.yaml \u2014 QCSD feedback loop configuration",
|
|
119975
|
+
"",
|
|
119976
|
+
"Manual testing:",
|
|
119977
|
+
" npx agentic-qe hooks session-start --session-id test --json",
|
|
119978
|
+
' npx agentic-qe hooks route --task "generate tests" --json',
|
|
119979
|
+
" npx agentic-qe hooks post-edit --file src/example.ts --success --json",
|
|
119980
|
+
""
|
|
119981
|
+
].join("\n");
|
|
119982
|
+
writeFileSync9(readmePath, content, "utf-8");
|
|
119983
|
+
}
|
|
119984
|
+
/**
|
|
119985
|
+
* Install hook assets (cross-phase memory config, domain workers).
|
|
119986
|
+
* Copies from v3/assets/hooks/ if available, otherwise creates minimal defaults.
|
|
119987
|
+
*/
|
|
119988
|
+
installHookAssets(hooksDir, context2) {
|
|
119989
|
+
const { projectRoot } = context2;
|
|
119990
|
+
const crossPhasePath = join27(hooksDir, "cross-phase-memory.yaml");
|
|
119991
|
+
if (!existsSync25(crossPhasePath)) {
|
|
119992
|
+
const assetPaths = [
|
|
119993
|
+
join27(projectRoot, "v3", "assets", "hooks", "cross-phase-memory.yaml"),
|
|
119994
|
+
join27(projectRoot, "assets", "hooks", "cross-phase-memory.yaml"),
|
|
119995
|
+
join27(projectRoot, "node_modules", "agentic-qe", "v3", "assets", "hooks", "cross-phase-memory.yaml")
|
|
119996
|
+
];
|
|
119997
|
+
let installed = false;
|
|
119998
|
+
for (const src of assetPaths) {
|
|
119999
|
+
if (existsSync25(src)) {
|
|
120000
|
+
const { copyFileSync: copyFileSync9 } = __require("fs");
|
|
120001
|
+
copyFileSync9(src, crossPhasePath);
|
|
120002
|
+
context2.services.log(" Installed cross-phase memory config");
|
|
120003
|
+
installed = true;
|
|
120004
|
+
break;
|
|
120005
|
+
}
|
|
120006
|
+
}
|
|
120007
|
+
if (!installed) {
|
|
120008
|
+
writeFileSync9(crossPhasePath, [
|
|
120009
|
+
"# Cross-Phase Memory Hooks Configuration",
|
|
120010
|
+
"# Generated by aqe init",
|
|
120011
|
+
'version: "1.0"',
|
|
120012
|
+
"enabled: true",
|
|
120013
|
+
""
|
|
120014
|
+
].join("\n"), "utf-8");
|
|
120015
|
+
}
|
|
120016
|
+
}
|
|
120017
|
+
const workersPath = join27(hooksDir, "v3-domain-workers.json");
|
|
120018
|
+
if (!existsSync25(workersPath)) {
|
|
120019
|
+
writeFileSync9(workersPath, JSON.stringify({
|
|
120020
|
+
version: "3.0",
|
|
120021
|
+
workers: [
|
|
120022
|
+
{ name: "pattern-consolidator", interval: "5m", enabled: true },
|
|
120023
|
+
{ name: "routing-accuracy-monitor", interval: "10m", enabled: true },
|
|
120024
|
+
{ name: "coverage-gap-scanner", interval: "15m", enabled: true },
|
|
120025
|
+
{ name: "flaky-test-detector", interval: "30m", enabled: true }
|
|
120026
|
+
]
|
|
120027
|
+
}, null, 2), "utf-8");
|
|
120028
|
+
}
|
|
120029
|
+
}
|
|
120030
|
+
/**
|
|
120031
|
+
* Check if existing hooks contain any AQE/agentic-qe entries
|
|
120032
|
+
*/
|
|
120033
|
+
hasExistingAqeHooks(hooks) {
|
|
120034
|
+
for (const hookArray of Object.values(hooks)) {
|
|
120035
|
+
if (!Array.isArray(hookArray)) continue;
|
|
120036
|
+
for (const entry of hookArray) {
|
|
120037
|
+
if (isAqeHookEntry(entry)) return true;
|
|
120038
|
+
}
|
|
120039
|
+
}
|
|
120040
|
+
return false;
|
|
120041
|
+
}
|
|
119752
120042
|
/**
|
|
119753
120043
|
* Generate hooks configuration
|
|
119754
120044
|
*
|
|
@@ -120592,8 +120882,7 @@ Task({ prompt: "Security audit", subagent_type: "qe-security-scanner", run_in_ba
|
|
|
120592
120882
|
import { existsSync as existsSync30, readFileSync as readFileSync22 } from "fs";
|
|
120593
120883
|
import { join as join32, dirname as dirname9 } from "path";
|
|
120594
120884
|
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync13 } from "fs";
|
|
120595
|
-
|
|
120596
|
-
var require4 = createRequire8(import.meta.url);
|
|
120885
|
+
init_safe_db();
|
|
120597
120886
|
var VerificationPhase = class extends BasePhase {
|
|
120598
120887
|
name = "verification";
|
|
120599
120888
|
description = "Verify installation";
|
|
@@ -120650,8 +120939,7 @@ var VerificationPhase = class extends BasePhase {
|
|
|
120650
120939
|
if (!existsSync30(dir)) {
|
|
120651
120940
|
mkdirSync16(dir, { recursive: true });
|
|
120652
120941
|
}
|
|
120653
|
-
const
|
|
120654
|
-
const db = new Database(memoryDbPath);
|
|
120942
|
+
const db = openDatabase(memoryDbPath);
|
|
120655
120943
|
try {
|
|
120656
120944
|
db.exec(`
|
|
120657
120945
|
CREATE TABLE IF NOT EXISTS kv_store (
|
|
@@ -123090,6 +123378,116 @@ function createCommandRegistry(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
123090
123378
|
// src/cli/commands/test.ts
|
|
123091
123379
|
import { Command } from "commander";
|
|
123092
123380
|
import chalk9 from "chalk";
|
|
123381
|
+
|
|
123382
|
+
// src/cli/utils/file-discovery.ts
|
|
123383
|
+
import { existsSync as existsSync35, readdirSync as readdirSync10, statSync as statSync9 } from "fs";
|
|
123384
|
+
import { join as join37, extname as extname7 } from "path";
|
|
123385
|
+
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
123386
|
+
// JavaScript / TypeScript
|
|
123387
|
+
".ts",
|
|
123388
|
+
".tsx",
|
|
123389
|
+
".js",
|
|
123390
|
+
".jsx",
|
|
123391
|
+
".mjs",
|
|
123392
|
+
".cjs",
|
|
123393
|
+
// Python
|
|
123394
|
+
".py",
|
|
123395
|
+
".pyw",
|
|
123396
|
+
// Go
|
|
123397
|
+
".go",
|
|
123398
|
+
// Rust
|
|
123399
|
+
".rs",
|
|
123400
|
+
// Java / Kotlin
|
|
123401
|
+
".java",
|
|
123402
|
+
".kt",
|
|
123403
|
+
".kts",
|
|
123404
|
+
// Ruby
|
|
123405
|
+
".rb",
|
|
123406
|
+
// C#
|
|
123407
|
+
".cs",
|
|
123408
|
+
// PHP
|
|
123409
|
+
".php",
|
|
123410
|
+
// Swift
|
|
123411
|
+
".swift",
|
|
123412
|
+
// C / C++
|
|
123413
|
+
".c",
|
|
123414
|
+
".h",
|
|
123415
|
+
".cpp",
|
|
123416
|
+
".hpp",
|
|
123417
|
+
".cc",
|
|
123418
|
+
// Scala
|
|
123419
|
+
".scala"
|
|
123420
|
+
]);
|
|
123421
|
+
var TEST_PATTERNS = [".test.", ".spec.", "_test.", "_spec."];
|
|
123422
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
123423
|
+
"node_modules",
|
|
123424
|
+
"dist",
|
|
123425
|
+
"build",
|
|
123426
|
+
"coverage",
|
|
123427
|
+
".git",
|
|
123428
|
+
"__pycache__",
|
|
123429
|
+
".venv",
|
|
123430
|
+
"venv",
|
|
123431
|
+
".tox",
|
|
123432
|
+
".mypy_cache",
|
|
123433
|
+
"target",
|
|
123434
|
+
".gradle",
|
|
123435
|
+
"vendor",
|
|
123436
|
+
".bundle",
|
|
123437
|
+
".next",
|
|
123438
|
+
".nuxt",
|
|
123439
|
+
".output"
|
|
123440
|
+
]);
|
|
123441
|
+
function walkSourceFiles(targetPath, options = {}) {
|
|
123442
|
+
const {
|
|
123443
|
+
maxDepth = 6,
|
|
123444
|
+
includeTests = false,
|
|
123445
|
+
testsOnly = false,
|
|
123446
|
+
extraExtensions = []
|
|
123447
|
+
} = options;
|
|
123448
|
+
if (!existsSync35(targetPath)) {
|
|
123449
|
+
return [];
|
|
123450
|
+
}
|
|
123451
|
+
const stat4 = statSync9(targetPath);
|
|
123452
|
+
if (stat4.isFile()) {
|
|
123453
|
+
return [targetPath];
|
|
123454
|
+
}
|
|
123455
|
+
if (!stat4.isDirectory()) {
|
|
123456
|
+
return [];
|
|
123457
|
+
}
|
|
123458
|
+
const extraSet = new Set(extraExtensions.map((e20) => e20.startsWith(".") ? e20 : `.${e20}`));
|
|
123459
|
+
const result = [];
|
|
123460
|
+
function walk(dir, depth) {
|
|
123461
|
+
if (depth > maxDepth) return;
|
|
123462
|
+
let entries;
|
|
123463
|
+
try {
|
|
123464
|
+
entries = readdirSync10(dir, { withFileTypes: true });
|
|
123465
|
+
} catch {
|
|
123466
|
+
return;
|
|
123467
|
+
}
|
|
123468
|
+
for (const entry of entries) {
|
|
123469
|
+
if (entry.isDirectory()) {
|
|
123470
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
123471
|
+
walk(join37(dir, entry.name), depth + 1);
|
|
123472
|
+
} else if (entry.isFile()) {
|
|
123473
|
+
const ext = extname7(entry.name).toLowerCase();
|
|
123474
|
+
const isSourceExt = SOURCE_EXTENSIONS.has(ext) || extraSet.has(ext);
|
|
123475
|
+
if (!isSourceExt) continue;
|
|
123476
|
+
if (entry.name.endsWith(".d.ts")) continue;
|
|
123477
|
+
const isTestFile2 = TEST_PATTERNS.some((p74) => entry.name.includes(p74)) || entry.name.startsWith("test_");
|
|
123478
|
+
if (testsOnly) {
|
|
123479
|
+
if (isTestFile2) result.push(join37(dir, entry.name));
|
|
123480
|
+
} else if (includeTests || !isTestFile2) {
|
|
123481
|
+
result.push(join37(dir, entry.name));
|
|
123482
|
+
}
|
|
123483
|
+
}
|
|
123484
|
+
}
|
|
123485
|
+
}
|
|
123486
|
+
walk(targetPath, 0);
|
|
123487
|
+
return result;
|
|
123488
|
+
}
|
|
123489
|
+
|
|
123490
|
+
// src/cli/commands/test.ts
|
|
123093
123491
|
function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
123094
123492
|
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
123493
|
if (!await ensureInitialized2()) return;
|
|
@@ -123103,33 +123501,9 @@ function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
123103
123501
|
console.log(chalk9.red("Test generation domain not available"));
|
|
123104
123502
|
return;
|
|
123105
123503
|
}
|
|
123106
|
-
const fs23 = await import("fs");
|
|
123107
123504
|
const path26 = await import("path");
|
|
123108
123505
|
const targetPath = path26.resolve(target || ".");
|
|
123109
|
-
|
|
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
|
-
}
|
|
123506
|
+
const sourceFiles = walkSourceFiles(targetPath, { includeTests: false });
|
|
123133
123507
|
if (sourceFiles.length === 0) {
|
|
123134
123508
|
console.log(chalk9.yellow("No source files found"));
|
|
123135
123509
|
return;
|
|
@@ -123180,33 +123554,9 @@ function createTestCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
123180
123554
|
console.log(chalk9.red("Test execution domain not available"));
|
|
123181
123555
|
return;
|
|
123182
123556
|
}
|
|
123183
|
-
const fs23 = await import("fs");
|
|
123184
123557
|
const path26 = await import("path");
|
|
123185
123558
|
const targetPath = path26.resolve(target || ".");
|
|
123186
|
-
|
|
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
|
-
}
|
|
123559
|
+
const testFiles = walkSourceFiles(targetPath, { testsOnly: true });
|
|
123210
123560
|
if (testFiles.length === 0) {
|
|
123211
123561
|
console.log(chalk9.yellow("No test files found"));
|
|
123212
123562
|
return;
|
|
@@ -123283,13 +123633,13 @@ var BaseWizardCommand = class {
|
|
|
123283
123633
|
|
|
123284
123634
|
// src/cli/wizards/core/wizard-step.ts
|
|
123285
123635
|
import chalk11 from "chalk";
|
|
123286
|
-
import { existsSync as
|
|
123636
|
+
import { existsSync as existsSync37 } from "fs";
|
|
123287
123637
|
import { resolve as resolve8 } from "path";
|
|
123288
123638
|
|
|
123289
123639
|
// src/cli/wizards/core/wizard-utils.ts
|
|
123290
123640
|
import chalk10 from "chalk";
|
|
123291
|
-
import { existsSync as
|
|
123292
|
-
import { join as
|
|
123641
|
+
import { existsSync as existsSync36, statSync as statSync10 } from "fs";
|
|
123642
|
+
import { join as join38, relative as relative6 } from "path";
|
|
123293
123643
|
var WizardPrompt = class {
|
|
123294
123644
|
/**
|
|
123295
123645
|
* Generic prompt helper - wraps readline.question in a Promise
|
|
@@ -123380,8 +123730,8 @@ var WizardSuggestions = class _WizardSuggestions {
|
|
|
123380
123730
|
const suggestions = [];
|
|
123381
123731
|
const commonDirs = ["src", "lib", "app", "packages", "api"];
|
|
123382
123732
|
for (const dir of commonDirs) {
|
|
123383
|
-
const dirPath =
|
|
123384
|
-
if (
|
|
123733
|
+
const dirPath = join38(cwd, dir);
|
|
123734
|
+
if (existsSync36(dirPath) && statSync10(dirPath).isDirectory()) {
|
|
123385
123735
|
suggestions.push(dir);
|
|
123386
123736
|
}
|
|
123387
123737
|
}
|
|
@@ -123399,8 +123749,8 @@ var WizardSuggestions = class _WizardSuggestions {
|
|
|
123399
123749
|
".nyc_output"
|
|
123400
123750
|
];
|
|
123401
123751
|
for (const loc of coverageLocations) {
|
|
123402
|
-
const locPath =
|
|
123403
|
-
if (
|
|
123752
|
+
const locPath = join38(cwd, loc);
|
|
123753
|
+
if (existsSync36(locPath)) {
|
|
123404
123754
|
suggestions.push(loc);
|
|
123405
123755
|
}
|
|
123406
123756
|
}
|
|
@@ -123422,8 +123772,8 @@ var WizardSuggestions = class _WizardSuggestions {
|
|
|
123422
123772
|
"Dockerfile"
|
|
123423
123773
|
];
|
|
123424
123774
|
for (const file of securityFiles) {
|
|
123425
|
-
const filePath =
|
|
123426
|
-
if (
|
|
123775
|
+
const filePath = join38(cwd, file);
|
|
123776
|
+
if (existsSync36(filePath)) {
|
|
123427
123777
|
suggestions.push(file);
|
|
123428
123778
|
}
|
|
123429
123779
|
}
|
|
@@ -123436,13 +123786,13 @@ var WizardSuggestions = class _WizardSuggestions {
|
|
|
123436
123786
|
const suggestions = [];
|
|
123437
123787
|
const commonDirs = ["src", "lib", "app", "packages"];
|
|
123438
123788
|
for (const dir of commonDirs) {
|
|
123439
|
-
const dirPath =
|
|
123440
|
-
if (
|
|
123789
|
+
const dirPath = join38(cwd, dir);
|
|
123790
|
+
if (existsSync36(dirPath) && statSync10(dirPath).isDirectory()) {
|
|
123441
123791
|
suggestions.push(`${dir}/**/*.ts`);
|
|
123442
123792
|
suggestions.push(dir);
|
|
123443
123793
|
}
|
|
123444
123794
|
}
|
|
123445
|
-
if (
|
|
123795
|
+
if (existsSync36(join38(cwd, "src"))) {
|
|
123446
123796
|
suggestions.push("src/services/**/*.ts");
|
|
123447
123797
|
suggestions.push("src/utils/**/*.ts");
|
|
123448
123798
|
suggestions.push("src/components/**/*.tsx");
|
|
@@ -123454,12 +123804,12 @@ var WizardSuggestions = class _WizardSuggestions {
|
|
|
123454
123804
|
*/
|
|
123455
123805
|
static checkPatternsExist(cwd) {
|
|
123456
123806
|
const patternLocations = [
|
|
123457
|
-
|
|
123458
|
-
|
|
123459
|
-
|
|
123460
|
-
|
|
123807
|
+
join38(cwd, ".agentic-qe", "patterns"),
|
|
123808
|
+
join38(cwd, ".agentic-qe", "memory.db"),
|
|
123809
|
+
join38(cwd, ".aqe", "patterns"),
|
|
123810
|
+
join38(cwd, "data", "patterns")
|
|
123461
123811
|
];
|
|
123462
|
-
return patternLocations.some((loc) =>
|
|
123812
|
+
return patternLocations.some((loc) => existsSync36(loc));
|
|
123463
123813
|
}
|
|
123464
123814
|
};
|
|
123465
123815
|
var WizardFormat = class {
|
|
@@ -123736,7 +124086,7 @@ var PathInputStep = class extends BaseWizardCommand {
|
|
|
123736
124086
|
async execute(context2) {
|
|
123737
124087
|
if (context2.nonInteractive) {
|
|
123738
124088
|
const resolved2 = resolve8(context2.cwd, this.defaultValue);
|
|
123739
|
-
return this.success(
|
|
124089
|
+
return this.success(existsSync37(resolved2) ? resolved2 : context2.cwd);
|
|
123740
124090
|
}
|
|
123741
124091
|
WizardPrompt.printStepHeader(this.stepNumber, this.title, this.description);
|
|
123742
124092
|
if (this.examples) {
|
|
@@ -123759,7 +124109,7 @@ var PathInputStep = class extends BaseWizardCommand {
|
|
|
123759
124109
|
);
|
|
123760
124110
|
const value = input.trim() || this.defaultValue;
|
|
123761
124111
|
const resolved = resolve8(context2.cwd, value);
|
|
123762
|
-
if (this.validatePath && !
|
|
124112
|
+
if (this.validatePath && !existsSync37(resolved)) {
|
|
123763
124113
|
console.log(chalk11.yellow(` Warning: '${value}' does not exist, using current directory.`));
|
|
123764
124114
|
return this.success(context2.cwd);
|
|
123765
124115
|
}
|
|
@@ -124111,30 +124461,7 @@ function createCoverageCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124111
124461
|
const fs23 = await import("fs");
|
|
124112
124462
|
const path26 = await import("path");
|
|
124113
124463
|
const targetPath = path26.resolve(analyzeTarget);
|
|
124114
|
-
|
|
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
|
-
}
|
|
124464
|
+
const sourceFiles = walkSourceFiles(targetPath, { includeTests: false });
|
|
124138
124465
|
if (sourceFiles.length === 0) {
|
|
124139
124466
|
console.log(chalk13.yellow("No source files found"));
|
|
124140
124467
|
return;
|
|
@@ -124320,33 +124647,9 @@ function createSecurityCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124320
124647
|
console.log(chalk15.red("Security domain not available"));
|
|
124321
124648
|
return;
|
|
124322
124649
|
}
|
|
124323
|
-
const fs23 = await import("fs");
|
|
124324
124650
|
const path26 = await import("path");
|
|
124325
124651
|
const targetPath = path26.resolve(options.target);
|
|
124326
|
-
|
|
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
|
-
}
|
|
124652
|
+
const files = walkSourceFiles(targetPath, { includeTests: true });
|
|
124350
124653
|
if (files.length === 0) {
|
|
124351
124654
|
console.log(chalk15.yellow("No files found to scan"));
|
|
124352
124655
|
return;
|
|
@@ -124421,37 +124724,15 @@ function createCodeCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124421
124724
|
console.log(chalk16.red("Code intelligence domain not available"));
|
|
124422
124725
|
return;
|
|
124423
124726
|
}
|
|
124424
|
-
const fs23 = await import("fs");
|
|
124425
124727
|
const path26 = await import("path");
|
|
124426
124728
|
if (action === "index") {
|
|
124427
124729
|
console.log(chalk16.blue(`
|
|
124428
124730
|
Indexing codebase at ${target || "."}...
|
|
124429
124731
|
`));
|
|
124430
124732
|
const targetPath = path26.resolve(target || ".");
|
|
124431
|
-
|
|
124432
|
-
|
|
124433
|
-
|
|
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
|
-
}
|
|
124733
|
+
const paths = walkSourceFiles(targetPath, {
|
|
124734
|
+
includeTests: options.includeTests || false
|
|
124735
|
+
});
|
|
124455
124736
|
console.log(chalk16.gray(` Found ${paths.length} files to index...
|
|
124456
124737
|
`));
|
|
124457
124738
|
const result = await codeAPI.index({
|
|
@@ -124510,30 +124791,7 @@ function createCodeCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124510
124791
|
Analyzing impact for ${target || "recent changes"}...
|
|
124511
124792
|
`));
|
|
124512
124793
|
const targetPath = path26.resolve(target || ".");
|
|
124513
|
-
|
|
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
|
-
}
|
|
124794
|
+
const changedFiles = walkSourceFiles(targetPath, { maxDepth: 2 }).slice(0, 10);
|
|
124537
124795
|
const result = await codeAPI.analyzeImpact({
|
|
124538
124796
|
changedFiles,
|
|
124539
124797
|
depth: parseInt(options.depth),
|
|
@@ -124579,30 +124837,7 @@ function createCodeCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124579
124837
|
Mapping dependencies for ${target || "."}...
|
|
124580
124838
|
`));
|
|
124581
124839
|
const targetPath = path26.resolve(target || ".");
|
|
124582
|
-
|
|
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
|
-
}
|
|
124840
|
+
const files = walkSourceFiles(targetPath, { maxDepth: 2 }).slice(0, 50);
|
|
124606
124841
|
const result = await codeAPI.mapDependencies({
|
|
124607
124842
|
files,
|
|
124608
124843
|
direction: "both",
|
|
@@ -124877,7 +125112,7 @@ function createMigrateCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124877
125112
|
migratedFrom: "v2",
|
|
124878
125113
|
migratedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
124879
125114
|
hnswEnabled: true,
|
|
124880
|
-
vectorDimensions:
|
|
125115
|
+
vectorDimensions: 768
|
|
124881
125116
|
}, null, 2));
|
|
124882
125117
|
const stats = fs23.statSync(v2Files.memoryDb);
|
|
124883
125118
|
console.log(chalk17.green(` * Memory database migrated (${(stats.size / 1024).toFixed(1)} KB)
|
|
@@ -124906,7 +125141,7 @@ function createMigrateCommand(context2, cleanupAndExit2, ensureInitialized2) {
|
|
|
124906
125141
|
domains: {
|
|
124907
125142
|
"test-generation": { enabled: true },
|
|
124908
125143
|
"test-execution": { enabled: true },
|
|
124909
|
-
"coverage-analysis": { enabled: true, algorithm: "hnsw", dimensions:
|
|
125144
|
+
"coverage-analysis": { enabled: true, algorithm: "hnsw", dimensions: 768 },
|
|
124910
125145
|
"quality-assessment": { enabled: true },
|
|
124911
125146
|
"defect-intelligence": { enabled: true },
|
|
124912
125147
|
"requirements-validation": { enabled: true },
|
|
@@ -126847,9 +127082,10 @@ import chalk20 from "chalk";
|
|
|
126847
127082
|
|
|
126848
127083
|
// src/init/fleet-integration.ts
|
|
126849
127084
|
init_error_utils();
|
|
127085
|
+
init_safe_db();
|
|
126850
127086
|
import chalk19 from "chalk";
|
|
126851
|
-
import { existsSync as
|
|
126852
|
-
import { join as
|
|
127087
|
+
import { existsSync as existsSync38 } from "fs";
|
|
127088
|
+
import { join as join40 } from "path";
|
|
126853
127089
|
var FleetInitEnhancer = class {
|
|
126854
127090
|
projectRoot;
|
|
126855
127091
|
options;
|
|
@@ -126961,7 +127197,7 @@ var FleetInitEnhancer = class {
|
|
|
126961
127197
|
});
|
|
126962
127198
|
console.log(chalk19.gray(` Indexing ${files.length} files...`));
|
|
126963
127199
|
const result = await kgService.index({
|
|
126964
|
-
paths: files.map((f74) =>
|
|
127200
|
+
paths: files.map((f74) => join40(this.projectRoot, f74)),
|
|
126965
127201
|
incremental: false,
|
|
126966
127202
|
includeTests: true
|
|
126967
127203
|
});
|
|
@@ -126996,13 +127232,12 @@ var FleetInitEnhancer = class {
|
|
|
126996
127232
|
* Checks the memory database for code-intelligence:kg namespace entries
|
|
126997
127233
|
*/
|
|
126998
127234
|
async hasCodeIntelligenceIndex() {
|
|
126999
|
-
const dbPath =
|
|
127000
|
-
if (!
|
|
127235
|
+
const dbPath = join40(this.projectRoot, ".agentic-qe", "memory.db");
|
|
127236
|
+
if (!existsSync38(dbPath)) {
|
|
127001
127237
|
return false;
|
|
127002
127238
|
}
|
|
127003
127239
|
try {
|
|
127004
|
-
const
|
|
127005
|
-
const db = new Database(dbPath);
|
|
127240
|
+
const db = openDatabase(dbPath);
|
|
127006
127241
|
const result = db.prepare(`
|
|
127007
127242
|
SELECT COUNT(*) as count FROM kv_store
|
|
127008
127243
|
WHERE namespace = 'code-intelligence:kg'
|
|
@@ -127017,10 +127252,9 @@ var FleetInitEnhancer = class {
|
|
|
127017
127252
|
* Get count of knowledge graph entries
|
|
127018
127253
|
*/
|
|
127019
127254
|
async getKGEntryCount() {
|
|
127020
|
-
const dbPath =
|
|
127255
|
+
const dbPath = join40(this.projectRoot, ".agentic-qe", "memory.db");
|
|
127021
127256
|
try {
|
|
127022
|
-
const
|
|
127023
|
-
const db = new Database(dbPath);
|
|
127257
|
+
const db = openDatabase(dbPath);
|
|
127024
127258
|
const result = db.prepare(`
|
|
127025
127259
|
SELECT COUNT(*) as count FROM kv_store
|
|
127026
127260
|
WHERE namespace LIKE 'code-intelligence:kg%'
|
|
@@ -128523,7 +128757,7 @@ function createParallelEvalRunner(skillValidationLearner, config = {}, executor2
|
|
|
128523
128757
|
|
|
128524
128758
|
// src/validation/validation-result-aggregator.ts
|
|
128525
128759
|
init_safe_json();
|
|
128526
|
-
import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as
|
|
128760
|
+
import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as existsSync40 } from "fs";
|
|
128527
128761
|
var DEFAULT_CONFIG60 = {
|
|
128528
128762
|
varianceThreshold: 0.04,
|
|
128529
128763
|
// ~20% standard deviation
|
|
@@ -128868,7 +129102,7 @@ var ValidationResultAggregator = class {
|
|
|
128868
129102
|
* Update trust tier manifest with new pass rates
|
|
128869
129103
|
*/
|
|
128870
129104
|
async updateManifest(report) {
|
|
128871
|
-
if (!
|
|
129105
|
+
if (!existsSync40(this.manifestPath)) {
|
|
128872
129106
|
throw new Error(`Manifest file not found: ${this.manifestPath}`);
|
|
128873
129107
|
}
|
|
128874
129108
|
const manifest = safeJsonParse(readFileSync28(this.manifestPath, "utf-8"));
|
|
@@ -130655,18 +130889,18 @@ function formatDuration2(ms) {
|
|
|
130655
130889
|
// src/cli/commands/validate.ts
|
|
130656
130890
|
init_safe_json();
|
|
130657
130891
|
import { Command as Command10 } from "commander";
|
|
130658
|
-
import { readFileSync as readFileSync29, writeFileSync as writeFileSync18, existsSync as
|
|
130659
|
-
import { join as
|
|
130892
|
+
import { readFileSync as readFileSync29, writeFileSync as writeFileSync18, existsSync as existsSync41, readdirSync as readdirSync11, statSync as statSync12 } from "fs";
|
|
130893
|
+
import { join as join42, resolve as resolve9, basename as basename7 } from "path";
|
|
130660
130894
|
import chalk22 from "chalk";
|
|
130661
130895
|
function loadValidationResults(inputPath) {
|
|
130662
130896
|
const resolvedPath = resolve9(inputPath);
|
|
130663
|
-
if (!
|
|
130897
|
+
if (!existsSync41(resolvedPath)) {
|
|
130664
130898
|
throw new Error(`Input path not found: ${resolvedPath}`);
|
|
130665
130899
|
}
|
|
130666
|
-
const stat4 =
|
|
130900
|
+
const stat4 = statSync12(resolvedPath);
|
|
130667
130901
|
if (stat4.isDirectory()) {
|
|
130668
130902
|
const results = [];
|
|
130669
|
-
const files =
|
|
130903
|
+
const files = readdirSync11(resolvedPath).filter((f74) => f74.endsWith(".json")).map((f74) => join42(resolvedPath, f74));
|
|
130670
130904
|
for (const file of files) {
|
|
130671
130905
|
try {
|
|
130672
130906
|
const content = safeJsonParse(readFileSync29(file, "utf-8"));
|
|
@@ -130716,15 +130950,15 @@ function createMockLearner() {
|
|
|
130716
130950
|
function getDefaultManifestPath() {
|
|
130717
130951
|
const cwd = process.cwd();
|
|
130718
130952
|
const candidates = [
|
|
130719
|
-
|
|
130720
|
-
|
|
130953
|
+
join42(cwd, ".claude/skills/trust-tier-manifest.json"),
|
|
130954
|
+
join42(cwd, ".claude/skills/skills-manifest.json")
|
|
130721
130955
|
];
|
|
130722
130956
|
for (const candidate of candidates) {
|
|
130723
|
-
if (
|
|
130957
|
+
if (existsSync41(candidate)) {
|
|
130724
130958
|
return candidate;
|
|
130725
130959
|
}
|
|
130726
130960
|
}
|
|
130727
|
-
return
|
|
130961
|
+
return join42(cwd, ".claude/skills/trust-tier-manifest.json");
|
|
130728
130962
|
}
|
|
130729
130963
|
function writeReport(report, aggregator, options) {
|
|
130730
130964
|
const format = options.format || "markdown";
|
|
@@ -132455,7 +132689,7 @@ var DEFAULT_SYNC_CONFIG = {
|
|
|
132455
132689
|
};
|
|
132456
132690
|
|
|
132457
132691
|
// src/sync/readers/sqlite-reader.ts
|
|
132458
|
-
|
|
132692
|
+
init_safe_db();
|
|
132459
132693
|
init_sql_safety();
|
|
132460
132694
|
init_safe_json();
|
|
132461
132695
|
init_error_utils();
|
|
@@ -132483,7 +132717,7 @@ var SQLiteReader = class {
|
|
|
132483
132717
|
throw new Error(`SQLite database not found: ${this.dbPath}`);
|
|
132484
132718
|
}
|
|
132485
132719
|
try {
|
|
132486
|
-
this.db =
|
|
132720
|
+
this.db = openDatabase(this.dbPath, { readonly: true });
|
|
132487
132721
|
this.db.pragma("journal_mode = WAL");
|
|
132488
132722
|
this.db.pragma("synchronous = NORMAL");
|
|
132489
132723
|
console.log(`[SQLiteReader:${this.name}] Initialized: ${this.dbPath}`);
|
|
@@ -133849,7 +134083,7 @@ async function syncIncrementalToCloud(since, config) {
|
|
|
133849
134083
|
}
|
|
133850
134084
|
|
|
133851
134085
|
// src/integrations/embeddings/cache/EmbeddingCache.ts
|
|
133852
|
-
|
|
134086
|
+
init_safe_db();
|
|
133853
134087
|
init_unified_memory();
|
|
133854
134088
|
init_safe_json();
|
|
133855
134089
|
|
|
@@ -133858,7 +134092,7 @@ init_transformers();
|
|
|
133858
134092
|
init_vector_math();
|
|
133859
134093
|
|
|
133860
134094
|
// src/sync/embeddings/sync-embedding-generator.ts
|
|
133861
|
-
|
|
134095
|
+
init_safe_db();
|
|
133862
134096
|
init_sql_safety();
|
|
133863
134097
|
init_error_utils();
|
|
133864
134098
|
init_safe_json();
|
|
@@ -136813,10 +137047,10 @@ async function createCoherenceService(wasmLoader2, config, logger19) {
|
|
|
136813
137047
|
|
|
136814
137048
|
// src/integrations/coherence/wasm-loader.ts
|
|
136815
137049
|
init_error_utils();
|
|
136816
|
-
import { createRequire as
|
|
137050
|
+
import { createRequire as createRequire9 } from "node:module";
|
|
136817
137051
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
136818
|
-
import { dirname as dirname13, join as
|
|
136819
|
-
import { readFileSync as readFileSync32, existsSync as
|
|
137052
|
+
import { dirname as dirname13, join as join44 } from "node:path";
|
|
137053
|
+
import { readFileSync as readFileSync32, existsSync as existsSync44 } from "node:fs";
|
|
136820
137054
|
var FALLBACK_RETRY_DELAYS_MS = [1e3, 2e3, 4e3];
|
|
136821
137055
|
var WasmLoader = class {
|
|
136822
137056
|
state = "unloaded";
|
|
@@ -137069,20 +137303,20 @@ var WasmLoader = class {
|
|
|
137069
137303
|
return false;
|
|
137070
137304
|
}
|
|
137071
137305
|
try {
|
|
137072
|
-
const
|
|
137306
|
+
const require2 = createRequire9(import.meta.url);
|
|
137073
137307
|
const wasmPaths = [
|
|
137074
137308
|
(() => {
|
|
137075
137309
|
try {
|
|
137076
|
-
const modulePath =
|
|
137077
|
-
return
|
|
137310
|
+
const modulePath = require2.resolve("prime-radiant-advanced-wasm");
|
|
137311
|
+
return join44(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
|
|
137078
137312
|
} catch {
|
|
137079
137313
|
return null;
|
|
137080
137314
|
}
|
|
137081
137315
|
})(),
|
|
137082
|
-
|
|
137316
|
+
join44(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
|
|
137083
137317
|
].filter((p74) => p74 !== null);
|
|
137084
137318
|
for (const path26 of wasmPaths) {
|
|
137085
|
-
if (
|
|
137319
|
+
if (existsSync44(path26)) {
|
|
137086
137320
|
return true;
|
|
137087
137321
|
}
|
|
137088
137322
|
}
|
|
@@ -137275,18 +137509,18 @@ var WasmLoader = class {
|
|
|
137275
137509
|
* - Browser: Uses default() async init with fetch
|
|
137276
137510
|
*/
|
|
137277
137511
|
async attemptLoad() {
|
|
137278
|
-
let
|
|
137512
|
+
let require2;
|
|
137279
137513
|
try {
|
|
137280
|
-
|
|
137514
|
+
require2 = createRequire9(import.meta.url);
|
|
137281
137515
|
} catch {
|
|
137282
|
-
|
|
137516
|
+
require2 = globalThis.require || (await import("module")).createRequire(__filename);
|
|
137283
137517
|
}
|
|
137284
137518
|
let wasmModule;
|
|
137285
137519
|
try {
|
|
137286
137520
|
wasmModule = await Promise.resolve().then(() => (init_prime_radiant_advanced_wasm(), prime_radiant_advanced_wasm_exports));
|
|
137287
137521
|
} catch (importError) {
|
|
137288
137522
|
try {
|
|
137289
|
-
wasmModule =
|
|
137523
|
+
wasmModule = require2("prime-radiant-advanced-wasm");
|
|
137290
137524
|
} catch (requireError) {
|
|
137291
137525
|
throw new Error(
|
|
137292
137526
|
`Failed to import prime-radiant-advanced-wasm: ${toErrorMessage(importError)}`
|
|
@@ -137295,7 +137529,7 @@ var WasmLoader = class {
|
|
|
137295
137529
|
}
|
|
137296
137530
|
const isNodeJs = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
137297
137531
|
if (isNodeJs) {
|
|
137298
|
-
await this.initializeForNodeJs(wasmModule,
|
|
137532
|
+
await this.initializeForNodeJs(wasmModule, require2);
|
|
137299
137533
|
} else {
|
|
137300
137534
|
if (wasmModule.default && typeof wasmModule.default === "function") {
|
|
137301
137535
|
await wasmModule.default();
|
|
@@ -137327,25 +137561,25 @@ var WasmLoader = class {
|
|
|
137327
137561
|
* In Node.js, the default async init uses fetch() which isn't available.
|
|
137328
137562
|
* Instead, we read the WASM binary from disk and use initSync().
|
|
137329
137563
|
*/
|
|
137330
|
-
async initializeForNodeJs(wasmModule,
|
|
137564
|
+
async initializeForNodeJs(wasmModule, require2) {
|
|
137331
137565
|
const wasmPaths = [
|
|
137332
137566
|
// Resolve from require - most reliable
|
|
137333
137567
|
(() => {
|
|
137334
137568
|
try {
|
|
137335
|
-
const modulePath =
|
|
137336
|
-
return
|
|
137569
|
+
const modulePath = require2.resolve("prime-radiant-advanced-wasm");
|
|
137570
|
+
return join44(dirname13(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
|
|
137337
137571
|
} catch {
|
|
137338
137572
|
return null;
|
|
137339
137573
|
}
|
|
137340
137574
|
})(),
|
|
137341
137575
|
// Direct node_modules path from current file
|
|
137342
|
-
|
|
137576
|
+
join44(dirname13(fileURLToPath6(import.meta.url)), "../../../../node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm"),
|
|
137343
137577
|
// Workspace root
|
|
137344
|
-
|
|
137578
|
+
join44(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
|
|
137345
137579
|
].filter((p74) => p74 !== null);
|
|
137346
137580
|
let wasmPath = null;
|
|
137347
137581
|
for (const path26 of wasmPaths) {
|
|
137348
|
-
if (
|
|
137582
|
+
if (existsSync44(path26)) {
|
|
137349
137583
|
wasmPath = path26;
|
|
137350
137584
|
break;
|
|
137351
137585
|
}
|
|
@@ -138555,16 +138789,16 @@ init_qe_patterns();
|
|
|
138555
138789
|
import { Command as Command16 } from "commander";
|
|
138556
138790
|
import chalk29 from "chalk";
|
|
138557
138791
|
import path25 from "node:path";
|
|
138558
|
-
import { existsSync as
|
|
138792
|
+
import { existsSync as existsSync46, writeFileSync as writeFileSync22, readFileSync as readFileSync33, mkdirSync as mkdirSync19, copyFileSync as copyFileSync8 } from "node:fs";
|
|
138559
138793
|
import { stat as stat3, unlink } from "node:fs/promises";
|
|
138560
138794
|
|
|
138561
138795
|
// src/learning/metrics-tracker.ts
|
|
138562
|
-
|
|
138796
|
+
init_safe_db();
|
|
138563
138797
|
init_qe_patterns();
|
|
138564
138798
|
init_safe_json();
|
|
138565
138799
|
init_logging();
|
|
138566
138800
|
import path23 from "node:path";
|
|
138567
|
-
import { existsSync as
|
|
138801
|
+
import { existsSync as existsSync45 } from "node:fs";
|
|
138568
138802
|
var logger18 = LoggerFactory.create("metrics-tracker");
|
|
138569
138803
|
var LearningMetricsTracker = class {
|
|
138570
138804
|
db = null;
|
|
@@ -138578,10 +138812,10 @@ var LearningMetricsTracker = class {
|
|
|
138578
138812
|
*/
|
|
138579
138813
|
async initialize() {
|
|
138580
138814
|
if (this.initialized) return;
|
|
138581
|
-
if (!
|
|
138815
|
+
if (!existsSync45(this.dbPath)) {
|
|
138582
138816
|
throw new Error(`Database not found: ${this.dbPath}. Run "aqe init --auto" first.`);
|
|
138583
138817
|
}
|
|
138584
|
-
this.db =
|
|
138818
|
+
this.db = openDatabase(this.dbPath);
|
|
138585
138819
|
this.ensureMetricsTable();
|
|
138586
138820
|
this.initialized = true;
|
|
138587
138821
|
}
|
|
@@ -138929,9 +139163,13 @@ function createLearningMetricsTracker(projectRoot) {
|
|
|
138929
139163
|
return new LearningMetricsTracker(projectRoot);
|
|
138930
139164
|
}
|
|
138931
139165
|
|
|
139166
|
+
// src/cli/commands/learning.ts
|
|
139167
|
+
init_safe_db();
|
|
139168
|
+
|
|
138932
139169
|
// src/cli/commands/learning-helpers.ts
|
|
138933
139170
|
init_unified_memory();
|
|
138934
139171
|
init_qe_reasoning_bank();
|
|
139172
|
+
init_safe_db();
|
|
138935
139173
|
import chalk28 from "chalk";
|
|
138936
139174
|
import path24 from "node:path";
|
|
138937
139175
|
import { createReadStream, createWriteStream } from "node:fs";
|
|
@@ -139080,8 +139318,7 @@ async function decompressFile(gzPath, outputPath) {
|
|
|
139080
139318
|
}
|
|
139081
139319
|
async function verifyDatabaseIntegrity(dbPath) {
|
|
139082
139320
|
try {
|
|
139083
|
-
const
|
|
139084
|
-
const db = new Database(dbPath, { readonly: true });
|
|
139321
|
+
const db = openDatabase(dbPath, { readonly: true });
|
|
139085
139322
|
const result = db.prepare("PRAGMA integrity_check").get();
|
|
139086
139323
|
db.close();
|
|
139087
139324
|
if (result.integrity_check === "ok") {
|
|
@@ -139098,8 +139335,7 @@ async function verifyDatabaseIntegrity(dbPath) {
|
|
|
139098
139335
|
}
|
|
139099
139336
|
async function getSchemaVersion(dbPath) {
|
|
139100
139337
|
try {
|
|
139101
|
-
const
|
|
139102
|
-
const db = new Database(dbPath, { readonly: true });
|
|
139338
|
+
const db = openDatabase(dbPath, { readonly: true });
|
|
139103
139339
|
const tableExists = db.prepare(
|
|
139104
139340
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='schema_version'"
|
|
139105
139341
|
).get();
|
|
@@ -139367,7 +139603,7 @@ function registerImportCommand(learning) {
|
|
|
139367
139603
|
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
139604
|
try {
|
|
139369
139605
|
const inputPath = path25.resolve(options.input);
|
|
139370
|
-
if (!
|
|
139606
|
+
if (!existsSync46(inputPath)) throw new Error(`File not found: ${inputPath}`);
|
|
139371
139607
|
const content = readFileSync33(inputPath, "utf-8");
|
|
139372
139608
|
const importData = safeJsonParse(content);
|
|
139373
139609
|
if (!importData.patterns || !Array.isArray(importData.patterns)) throw new Error("Invalid pattern file format");
|
|
@@ -139436,7 +139672,7 @@ function registerResetCommand(learning) {
|
|
|
139436
139672
|
if (!options.patternsOnly) filesToReset.push(path25.join(dataDir, "data", "learning-config.json"));
|
|
139437
139673
|
console.log(chalk29.bold("\n\u{1F5D1}\uFE0F Resetting Learning Data\n"));
|
|
139438
139674
|
for (const file of filesToReset) {
|
|
139439
|
-
if (
|
|
139675
|
+
if (existsSync46(file)) console.log(chalk29.dim(` Removing: ${path25.relative(projectRoot, file)}`));
|
|
139440
139676
|
}
|
|
139441
139677
|
printSuccess2('Learning data reset. Run "aqe init --auto" to reinitialize.\n');
|
|
139442
139678
|
process.exit(0);
|
|
@@ -139451,15 +139687,14 @@ function registerExtractCommand(learning) {
|
|
|
139451
139687
|
try {
|
|
139452
139688
|
const projectRoot = findProjectRoot();
|
|
139453
139689
|
const dbPath = path25.join(projectRoot, ".agentic-qe", "memory.db");
|
|
139454
|
-
if (!
|
|
139690
|
+
if (!existsSync46(dbPath)) throw new Error('No memory database found. Run "aqe init --auto" first.');
|
|
139455
139691
|
const minReward = parseFloat(options.minReward);
|
|
139456
139692
|
const minCount = parseInt(options.minCount, 10);
|
|
139457
139693
|
console.log(chalk29.bold("\n\u{1F52C} Pattern Extraction from Learning Experiences\n"));
|
|
139458
139694
|
console.log(` Min reward threshold: ${minReward}`);
|
|
139459
139695
|
console.log(` Min occurrences: ${minCount}
|
|
139460
139696
|
`);
|
|
139461
|
-
const
|
|
139462
|
-
const db = new Database(dbPath, { readonly: true });
|
|
139697
|
+
const db = openDatabase(dbPath, { readonly: true });
|
|
139463
139698
|
const experiences = db.prepare(`
|
|
139464
139699
|
SELECT task_type, COUNT(*) as count, AVG(reward) as avg_reward, MAX(reward) as max_reward,
|
|
139465
139700
|
MIN(reward) as min_reward, GROUP_CONCAT(DISTINCT action) as actions
|
|
@@ -139605,22 +139840,22 @@ function registerBackupCommand(learning) {
|
|
|
139605
139840
|
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
139841
|
try {
|
|
139607
139842
|
const dbPath = getDbPath();
|
|
139608
|
-
if (!
|
|
139843
|
+
if (!existsSync46(dbPath)) throw new Error(`No learning database found at: ${dbPath}`);
|
|
139609
139844
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
139610
139845
|
const defaultOutput = path25.join(process.cwd(), "backups", `learning-${timestamp}.db`);
|
|
139611
139846
|
let outputPath = options.output ? path25.resolve(options.output) : defaultOutput;
|
|
139612
139847
|
const backupDir = path25.dirname(outputPath);
|
|
139613
|
-
if (!
|
|
139848
|
+
if (!existsSync46(backupDir)) mkdirSync19(backupDir, { recursive: true });
|
|
139614
139849
|
const sourceStats = await stat3(dbPath);
|
|
139615
139850
|
const sourceSizeKB = (sourceStats.size / 1024).toFixed(2);
|
|
139616
139851
|
copyFileSync8(dbPath, outputPath);
|
|
139617
139852
|
const walPath = `${dbPath}-wal`;
|
|
139618
|
-
if (
|
|
139853
|
+
if (existsSync46(walPath)) copyFileSync8(walPath, `${outputPath}-wal`);
|
|
139619
139854
|
let finalPath = outputPath;
|
|
139620
139855
|
if (options.compress) {
|
|
139621
139856
|
finalPath = await compressFile(outputPath);
|
|
139622
139857
|
await unlink(outputPath);
|
|
139623
|
-
if (
|
|
139858
|
+
if (existsSync46(`${outputPath}-wal`)) await unlink(`${outputPath}-wal`);
|
|
139624
139859
|
}
|
|
139625
139860
|
const finalStats = await stat3(finalPath);
|
|
139626
139861
|
const finalSizeKB = (finalStats.size / 1024).toFixed(2);
|
|
@@ -139658,7 +139893,7 @@ function registerRestoreCommand(learning) {
|
|
|
139658
139893
|
try {
|
|
139659
139894
|
const inputPath = path25.resolve(options.input);
|
|
139660
139895
|
const dbPath = getDbPath();
|
|
139661
|
-
if (!
|
|
139896
|
+
if (!existsSync46(inputPath)) throw new Error(`Backup file not found: ${inputPath}`);
|
|
139662
139897
|
const isCompressed = inputPath.endsWith(".gz");
|
|
139663
139898
|
let restorePath = inputPath;
|
|
139664
139899
|
if (isCompressed) {
|
|
@@ -139669,23 +139904,23 @@ function registerRestoreCommand(learning) {
|
|
|
139669
139904
|
if (options.verify) {
|
|
139670
139905
|
const verificationResult = await verifyDatabaseIntegrity(restorePath);
|
|
139671
139906
|
if (!verificationResult.valid) {
|
|
139672
|
-
if (isCompressed &&
|
|
139907
|
+
if (isCompressed && existsSync46(restorePath)) await unlink(restorePath);
|
|
139673
139908
|
throw new Error(`Backup verification failed: ${verificationResult.message}`);
|
|
139674
139909
|
}
|
|
139675
139910
|
}
|
|
139676
|
-
if (
|
|
139911
|
+
if (existsSync46(dbPath) && !options.force) {
|
|
139677
139912
|
printError2(`Database already exists at: ${dbPath}`);
|
|
139678
139913
|
console.log(chalk29.yellow(" Use --force to overwrite"));
|
|
139679
|
-
if (isCompressed &&
|
|
139914
|
+
if (isCompressed && existsSync46(restorePath)) await unlink(restorePath);
|
|
139680
139915
|
process.exit(1);
|
|
139681
139916
|
}
|
|
139682
139917
|
const targetDir = path25.dirname(dbPath);
|
|
139683
|
-
if (!
|
|
139684
|
-
if (
|
|
139685
|
-
if (
|
|
139686
|
-
if (
|
|
139918
|
+
if (!existsSync46(targetDir)) mkdirSync19(targetDir, { recursive: true });
|
|
139919
|
+
if (existsSync46(dbPath)) await unlink(dbPath);
|
|
139920
|
+
if (existsSync46(`${dbPath}-wal`)) await unlink(`${dbPath}-wal`);
|
|
139921
|
+
if (existsSync46(`${dbPath}-shm`)) await unlink(`${dbPath}-shm`);
|
|
139687
139922
|
copyFileSync8(restorePath, dbPath);
|
|
139688
|
-
if (isCompressed &&
|
|
139923
|
+
if (isCompressed && existsSync46(restorePath)) await unlink(restorePath);
|
|
139689
139924
|
const restoredStats = await stat3(dbPath);
|
|
139690
139925
|
const schemaVersion = await getSchemaVersion(dbPath);
|
|
139691
139926
|
if (options.json) {
|
|
@@ -139709,14 +139944,13 @@ function registerVerifyCommand(learning) {
|
|
|
139709
139944
|
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
139945
|
try {
|
|
139711
139946
|
const dbPath = options.file ? path25.resolve(options.file) : getDbPath();
|
|
139712
|
-
if (!
|
|
139947
|
+
if (!existsSync46(dbPath)) throw new Error(`Database file not found: ${dbPath}`);
|
|
139713
139948
|
const verificationResult = await verifyDatabaseIntegrity(dbPath);
|
|
139714
139949
|
const schemaVersion = await getSchemaVersion(dbPath);
|
|
139715
139950
|
const fileStats = await stat3(dbPath);
|
|
139716
139951
|
let tableCounts = {};
|
|
139717
139952
|
try {
|
|
139718
|
-
const
|
|
139719
|
-
const db = new Database(dbPath, { readonly: true });
|
|
139953
|
+
const db = openDatabase(dbPath, { readonly: true });
|
|
139720
139954
|
for (const table of ["qe_patterns", "qe_trajectories", "learning_experiences", "kv_store", "vectors"]) {
|
|
139721
139955
|
try {
|
|
139722
139956
|
const r54 = db.prepare(`SELECT COUNT(*) as count FROM ${table}`).get();
|
|
@@ -139752,7 +139986,7 @@ function registerExportFullCommand(learning) {
|
|
|
139752
139986
|
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
139987
|
try {
|
|
139754
139988
|
const dbPath = getDbPath();
|
|
139755
|
-
if (!
|
|
139989
|
+
if (!existsSync46(dbPath)) throw new Error('No learning database found. Run "aqe init --auto" first.');
|
|
139756
139990
|
const reasoningBank = await initializeLearningSystem2();
|
|
139757
139991
|
const schemaVersion = await getSchemaVersion(dbPath);
|
|
139758
139992
|
const searchResult = await reasoningBank.searchPatterns("*", { limit: 1e4 });
|
|
@@ -139783,8 +140017,7 @@ function registerExportFullCommand(learning) {
|
|
|
139783
140017
|
};
|
|
139784
140018
|
if (options.includeTrajectories) {
|
|
139785
140019
|
try {
|
|
139786
|
-
const
|
|
139787
|
-
const db = new Database(dbPath, { readonly: true });
|
|
140020
|
+
const db = openDatabase(dbPath, { readonly: true });
|
|
139788
140021
|
const trajectories = db.prepare(`SELECT id, task, agent, domain, success, steps_json FROM qe_trajectories ORDER BY started_at DESC LIMIT 1000`).all();
|
|
139789
140022
|
exportData.trajectories = trajectories.map((t50) => ({ id: t50.id, task: t50.task, agent: t50.agent, domain: t50.domain, success: t50.success, stepsJson: t50.steps_json }));
|
|
139790
140023
|
db.close();
|
|
@@ -139793,8 +140026,7 @@ function registerExportFullCommand(learning) {
|
|
|
139793
140026
|
}
|
|
139794
140027
|
if (options.includeExperiences) {
|
|
139795
140028
|
try {
|
|
139796
|
-
const
|
|
139797
|
-
const db = new Database(dbPath, { readonly: true });
|
|
140029
|
+
const db = openDatabase(dbPath, { readonly: true });
|
|
139798
140030
|
const experiences = db.prepare(`SELECT task_type, action, AVG(reward) as avg_reward, COUNT(*) as count FROM learning_experiences GROUP BY task_type, action ORDER BY count DESC LIMIT 500`).all();
|
|
139799
140031
|
exportData.experiences = experiences.map((e20) => ({ taskType: e20.task_type, action: e20.action, reward: e20.avg_reward, count: e20.count }));
|
|
139800
140032
|
const metaRow = db.prepare(`SELECT COUNT(*) as total, AVG(reward) as avg_reward FROM learning_experiences`).get();
|
|
@@ -139833,7 +140065,7 @@ function registerImportMergeCommand(learning) {
|
|
|
139833
140065
|
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
140066
|
try {
|
|
139835
140067
|
let inputPath = path25.resolve(options.input);
|
|
139836
|
-
if (!
|
|
140068
|
+
if (!existsSync46(inputPath)) throw new Error(`File not found: ${inputPath}`);
|
|
139837
140069
|
let content;
|
|
139838
140070
|
if (inputPath.endsWith(".gz")) {
|
|
139839
140071
|
const tempPath = inputPath.replace(".gz", ".tmp.json");
|
|
@@ -140115,8 +140347,8 @@ function registerDreamCommand(learning) {
|
|
|
140115
140347
|
// src/cli/commands/mcp.ts
|
|
140116
140348
|
import { Command as Command17 } from "commander";
|
|
140117
140349
|
import { spawn as spawn7 } from "child_process";
|
|
140118
|
-
import { join as
|
|
140119
|
-
import { existsSync as
|
|
140350
|
+
import { join as join45, dirname as dirname14 } from "path";
|
|
140351
|
+
import { existsSync as existsSync47 } from "fs";
|
|
140120
140352
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
140121
140353
|
function createMcpCommand() {
|
|
140122
140354
|
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 +140390,17 @@ function findMcpEntry() {
|
|
|
140158
140390
|
const __dirname5 = dirname14(__filename5);
|
|
140159
140391
|
const candidates = [
|
|
140160
140392
|
// 1. Bundled dist (production)
|
|
140161
|
-
|
|
140393
|
+
join45(__dirname5, "..", "..", "mcp", "bundle.js"),
|
|
140162
140394
|
// 2. Compiled dist
|
|
140163
|
-
|
|
140395
|
+
join45(__dirname5, "..", "..", "mcp", "entry.js"),
|
|
140164
140396
|
// 3. Source (development with tsx)
|
|
140165
|
-
|
|
140397
|
+
join45(__dirname5, "..", "..", "mcp", "entry.ts"),
|
|
140166
140398
|
// 4. From node_modules (when used as dependency)
|
|
140167
|
-
|
|
140168
|
-
|
|
140399
|
+
join45(process.cwd(), "node_modules", "agentic-qe", "v3", "dist", "mcp", "bundle.js"),
|
|
140400
|
+
join45(process.cwd(), "node_modules", "agentic-qe", "v3", "dist", "mcp", "entry.js")
|
|
140169
140401
|
];
|
|
140170
140402
|
for (const candidate of candidates) {
|
|
140171
|
-
if (
|
|
140403
|
+
if (existsSync47(candidate)) {
|
|
140172
140404
|
return candidate;
|
|
140173
140405
|
}
|
|
140174
140406
|
}
|
|
@@ -140290,7 +140522,7 @@ async function cleanupAndExit(code = 0) {
|
|
|
140290
140522
|
process.exit(code);
|
|
140291
140523
|
}
|
|
140292
140524
|
var program = new Command18();
|
|
140293
|
-
var VERSION = true ? "3.6.
|
|
140525
|
+
var VERSION = true ? "3.6.12" : "0.0.0-dev";
|
|
140294
140526
|
program.name("aqe").description("Agentic QE - Domain-Driven Quality Engineering").version(VERSION);
|
|
140295
140527
|
var registry = createCommandRegistry(context, cleanupAndExit, ensureInitialized);
|
|
140296
140528
|
registry.registerAll(program);
|