agentic-qe 3.7.20 → 3.7.22
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/agents/v3/qe-deployment-advisor.md +14 -0
- package/.claude/agents/v3/qe-gap-detector.md +8 -0
- package/.claude/agents/v3/qe-impact-analyzer.md +11 -0
- package/.claude/agents/v3/qe-queen-coordinator.md +45 -0
- package/.claude/agents/v3/qe-root-cause-analyzer.md +11 -0
- package/.claude/agents/v3/qe-security-scanner.md +25 -16
- package/.claude/helpers/brain-checkpoint.cjs +7 -4
- package/.claude/helpers/statusline-v3.cjs +7 -4
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +34 -0
- package/README.md +0 -12
- package/assets/agents/v3/qe-deployment-advisor.md +14 -0
- package/assets/agents/v3/qe-gap-detector.md +8 -0
- package/assets/agents/v3/qe-impact-analyzer.md +11 -0
- package/assets/agents/v3/qe-queen-coordinator.md +45 -0
- package/assets/agents/v3/qe-root-cause-analyzer.md +11 -0
- package/assets/agents/v3/qe-security-scanner.md +25 -16
- package/assets/helpers/statusline-v3.cjs +7 -4
- package/dist/adapters/claude-flow/model-router-bridge.d.ts +0 -6
- package/dist/adapters/claude-flow/model-router-bridge.js +4 -17
- package/dist/adapters/claude-flow/pretrain-bridge.d.ts +0 -6
- package/dist/adapters/claude-flow/pretrain-bridge.js +6 -19
- package/dist/adapters/claude-flow/trajectory-bridge.d.ts +0 -6
- package/dist/adapters/claude-flow/trajectory-bridge.js +21 -23
- package/dist/cli/brain-commands.js +6 -10
- package/dist/cli/bundle.js +3124 -3622
- package/dist/cli/commands/hooks.js +29 -6
- package/dist/cli/commands/init.js +1 -73
- package/dist/cli/commands/learning.js +164 -12
- package/dist/cli/handlers/init-handler.d.ts +0 -1
- package/dist/cli/handlers/init-handler.js +0 -6
- package/dist/cli/index.js +0 -2
- package/dist/context/sources/defect-source.js +2 -2
- package/dist/context/sources/memory-source.js +2 -2
- package/dist/context/sources/requirements-source.js +2 -2
- package/dist/coordination/protocols/security-audit.d.ts +3 -6
- package/dist/coordination/protocols/security-audit.js +8 -88
- package/dist/coordination/queen-coordinator.d.ts +13 -0
- package/dist/coordination/queen-coordinator.js +76 -0
- package/dist/coordination/queen-task-management.d.ts +2 -0
- package/dist/coordination/queen-task-management.js +10 -0
- package/dist/coordination/queen-types.d.ts +3 -0
- package/dist/coordination/task-executor.js +7 -5
- package/dist/domains/security-compliance/services/scanners/sast-scanner.d.ts +25 -1
- package/dist/domains/security-compliance/services/scanners/sast-scanner.js +140 -11
- package/dist/domains/security-compliance/services/scanners/scanner-types.d.ts +2 -0
- package/dist/domains/security-compliance/services/scanners/scanner-types.js +1 -0
- package/dist/domains/test-execution/services/mincut-test-optimizer.js +2 -0
- package/dist/init/agents-installer.d.ts +2 -0
- package/dist/init/agents-installer.js +13 -0
- package/dist/init/enhancements/claude-flow-adapter.js +51 -24
- package/dist/init/index.d.ts +0 -2
- package/dist/init/index.js +0 -1
- package/dist/init/init-wizard-steps.d.ts +10 -0
- package/dist/init/init-wizard-steps.js +87 -1
- package/dist/init/init-wizard.d.ts +1 -9
- package/dist/init/init-wizard.js +3 -69
- package/dist/init/orchestrator.js +0 -1
- package/dist/init/phases/01-detection.js +0 -27
- package/dist/init/phases/07-hooks.js +12 -10
- package/dist/init/phases/phase-interface.d.ts +0 -1
- package/dist/init/settings-merge.js +1 -1
- package/dist/integrations/ruvector/brain-rvf-exporter.js +14 -2
- package/dist/kernel/unified-memory.js +5 -6
- package/dist/learning/experience-capture-middleware.js +23 -1
- package/dist/learning/index.d.ts +0 -2
- package/dist/learning/index.js +0 -4
- package/dist/learning/metrics-tracker.js +15 -13
- package/dist/learning/pattern-lifecycle.d.ts +1 -1
- package/dist/learning/pattern-lifecycle.js +18 -20
- package/dist/learning/qe-reasoning-bank.js +3 -3
- package/dist/learning/qe-unified-memory.js +1 -28
- package/dist/learning/sqlite-persistence.js +16 -0
- package/dist/learning/token-tracker.js +4 -2
- package/dist/mcp/bundle.js +1162 -478
- package/dist/routing/agent-dependency-graph.d.ts +77 -0
- package/dist/routing/agent-dependency-graph.js +359 -0
- package/dist/routing/co-execution-repository.d.ts +68 -0
- package/dist/routing/co-execution-repository.js +184 -0
- package/dist/routing/index.d.ts +6 -0
- package/dist/routing/index.js +6 -0
- package/dist/routing/qe-task-router.d.ts +7 -0
- package/dist/routing/qe-task-router.js +63 -1
- package/dist/routing/signal-merger.d.ts +81 -0
- package/dist/routing/signal-merger.js +136 -0
- package/dist/routing/types.d.ts +1 -0
- package/dist/shared/llm/providers/azure-openai.js +3 -2
- package/dist/shared/llm/providers/bedrock.js +3 -2
- package/dist/shared/llm/providers/claude.js +3 -2
- package/dist/shared/llm/providers/gemini.js +3 -2
- package/dist/shared/llm/providers/openai.js +3 -2
- package/dist/shared/llm/providers/openrouter.js +3 -2
- package/dist/shared/llm/retry.d.ts +10 -0
- package/dist/shared/llm/retry.js +16 -0
- package/dist/shared/llm/router/agent-router-config.d.ts +2 -1
- package/dist/shared/llm/router/agent-router-config.js +38 -88
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +4 -0
- package/dist/validation/steps/agent-mcp-validator.d.ts +88 -0
- package/dist/validation/steps/agent-mcp-validator.js +254 -0
- package/package.json +1 -1
- package/dist/cli/commands/migrate.d.ts +0 -9
- package/dist/cli/commands/migrate.js +0 -566
- package/dist/init/init-wizard-migration.d.ts +0 -52
- package/dist/init/init-wizard-migration.js +0 -345
- package/dist/init/migration/config-migrator.d.ts +0 -31
- package/dist/init/migration/config-migrator.js +0 -149
- package/dist/init/migration/data-migrator.d.ts +0 -72
- package/dist/init/migration/data-migrator.js +0 -232
- package/dist/init/migration/detector.d.ts +0 -44
- package/dist/init/migration/detector.js +0 -105
- package/dist/init/migration/index.d.ts +0 -8
- package/dist/init/migration/index.js +0 -8
- package/dist/learning/v2-to-v3-migration.d.ts +0 -86
- package/dist/learning/v2-to-v3-migration.js +0 -529
package/dist/mcp/bundle.js
CHANGED
|
@@ -5151,6 +5151,9 @@ var init_console_logger = __esm({
|
|
|
5151
5151
|
});
|
|
5152
5152
|
|
|
5153
5153
|
// src/logging/logger-factory.ts
|
|
5154
|
+
function createLogger(domain, context) {
|
|
5155
|
+
return LoggerFactory.create(domain, context);
|
|
5156
|
+
}
|
|
5154
5157
|
var DEFAULT_FACTORY_CONFIG, LoggerFactory;
|
|
5155
5158
|
var init_logger_factory = __esm({
|
|
5156
5159
|
"src/logging/logger-factory.ts"() {
|
|
@@ -6180,6 +6183,33 @@ var init_better_sqlite3 = __esm({
|
|
|
6180
6183
|
}
|
|
6181
6184
|
});
|
|
6182
6185
|
|
|
6186
|
+
// src/shared/safe-db.ts
|
|
6187
|
+
var safe_db_exports = {};
|
|
6188
|
+
__export(safe_db_exports, {
|
|
6189
|
+
openDatabase: () => openDatabase
|
|
6190
|
+
});
|
|
6191
|
+
function openDatabase(dbPath, opts) {
|
|
6192
|
+
const readonly = opts?.readonly ?? false;
|
|
6193
|
+
const fileMustExist = opts?.fileMustExist ?? false;
|
|
6194
|
+
const busyTimeout = opts?.busyTimeout ?? 5e3;
|
|
6195
|
+
const walMode = opts?.walMode ?? !readonly;
|
|
6196
|
+
const db = new better_sqlite3_default(dbPath, {
|
|
6197
|
+
readonly,
|
|
6198
|
+
fileMustExist
|
|
6199
|
+
});
|
|
6200
|
+
db.pragma(`busy_timeout = ${busyTimeout}`);
|
|
6201
|
+
if (walMode) {
|
|
6202
|
+
db.pragma("journal_mode = WAL");
|
|
6203
|
+
}
|
|
6204
|
+
return db;
|
|
6205
|
+
}
|
|
6206
|
+
var init_safe_db = __esm({
|
|
6207
|
+
"src/shared/safe-db.ts"() {
|
|
6208
|
+
"use strict";
|
|
6209
|
+
init_better_sqlite3();
|
|
6210
|
+
}
|
|
6211
|
+
});
|
|
6212
|
+
|
|
6183
6213
|
// src/shared/sql-safety.ts
|
|
6184
6214
|
function validateTableName(tableName) {
|
|
6185
6215
|
if (!ALLOWED_TABLE_NAMES.has(tableName)) {
|
|
@@ -8952,7 +8982,7 @@ var logger3, _cachedProjectRoot, DEFAULT_UNIFIED_MEMORY_CONFIG, UnifiedMemoryMan
|
|
|
8952
8982
|
var init_unified_memory = __esm({
|
|
8953
8983
|
"src/kernel/unified-memory.ts"() {
|
|
8954
8984
|
"use strict";
|
|
8955
|
-
|
|
8985
|
+
init_safe_db();
|
|
8956
8986
|
init_safe_json();
|
|
8957
8987
|
init_error_utils();
|
|
8958
8988
|
init_constants();
|
|
@@ -9068,13 +9098,12 @@ var init_unified_memory = __esm({
|
|
|
9068
9098
|
dbSizeBefore = newest.size;
|
|
9069
9099
|
}
|
|
9070
9100
|
}
|
|
9071
|
-
this.db =
|
|
9072
|
-
|
|
9073
|
-
this.
|
|
9074
|
-
}
|
|
9101
|
+
this.db = openDatabase(this.config.dbPath, {
|
|
9102
|
+
walMode: this.config.walMode,
|
|
9103
|
+
busyTimeout: this.config.busyTimeout
|
|
9104
|
+
});
|
|
9075
9105
|
this.db.pragma(`mmap_size = ${this.config.mmapSize}`);
|
|
9076
9106
|
this.db.pragma(`cache_size = ${this.config.cacheSize}`);
|
|
9077
|
-
this.db.pragma(`busy_timeout = ${this.config.busyTimeout}`);
|
|
9078
9107
|
this.db.pragma("foreign_keys = ON");
|
|
9079
9108
|
await this.runMigrations();
|
|
9080
9109
|
if (dbExistedBefore && dbSizeBefore > 1e6) {
|
|
@@ -57291,6 +57320,7 @@ var init_mincut_test_optimizer = __esm({
|
|
|
57291
57320
|
criticalTests.add(promotedId);
|
|
57292
57321
|
skippableTests.delete(promotedId);
|
|
57293
57322
|
const promotedTest = testMap.get(promotedId);
|
|
57323
|
+
if (!promotedTest) continue;
|
|
57294
57324
|
for (const file of promotedTest.coveredFiles) {
|
|
57295
57325
|
covered.add(file);
|
|
57296
57326
|
}
|
|
@@ -83016,33 +83046,6 @@ var init_coordinator_consensus = __esm({
|
|
|
83016
83046
|
}
|
|
83017
83047
|
});
|
|
83018
83048
|
|
|
83019
|
-
// src/shared/safe-db.ts
|
|
83020
|
-
var safe_db_exports = {};
|
|
83021
|
-
__export(safe_db_exports, {
|
|
83022
|
-
openDatabase: () => openDatabase
|
|
83023
|
-
});
|
|
83024
|
-
function openDatabase(dbPath, opts) {
|
|
83025
|
-
const readonly = opts?.readonly ?? false;
|
|
83026
|
-
const fileMustExist = opts?.fileMustExist ?? false;
|
|
83027
|
-
const busyTimeout = opts?.busyTimeout ?? 5e3;
|
|
83028
|
-
const walMode = opts?.walMode ?? !readonly;
|
|
83029
|
-
const db = new better_sqlite3_default(dbPath, {
|
|
83030
|
-
readonly,
|
|
83031
|
-
fileMustExist
|
|
83032
|
-
});
|
|
83033
|
-
db.pragma(`busy_timeout = ${busyTimeout}`);
|
|
83034
|
-
if (walMode) {
|
|
83035
|
-
db.pragma("journal_mode = WAL");
|
|
83036
|
-
}
|
|
83037
|
-
return db;
|
|
83038
|
-
}
|
|
83039
|
-
var init_safe_db = __esm({
|
|
83040
|
-
"src/shared/safe-db.ts"() {
|
|
83041
|
-
"use strict";
|
|
83042
|
-
init_better_sqlite3();
|
|
83043
|
-
}
|
|
83044
|
-
});
|
|
83045
|
-
|
|
83046
83049
|
// src/domains/code-intelligence/coordinator.ts
|
|
83047
83050
|
var DEFAULT_CONFIG40, CodeIntelligenceCoordinator;
|
|
83048
83051
|
var init_coordinator7 = __esm({
|
|
@@ -84551,8 +84554,10 @@ var init_scanner_types = __esm({
|
|
|
84551
84554
|
dastActiveScanning: false,
|
|
84552
84555
|
enableLLMAnalysis: true,
|
|
84553
84556
|
// On by default - opt-out (ADR-051)
|
|
84554
|
-
llmModelTier: 4
|
|
84557
|
+
llmModelTier: 4,
|
|
84555
84558
|
// Opus for security analysis (needs expert reasoning)
|
|
84559
|
+
enableSemgrep: true
|
|
84560
|
+
// Use semgrep when installed for real SAST
|
|
84556
84561
|
};
|
|
84557
84562
|
}
|
|
84558
84563
|
});
|
|
@@ -85041,6 +85046,179 @@ var init_security_patterns = __esm({
|
|
|
85041
85046
|
}
|
|
85042
85047
|
});
|
|
85043
85048
|
|
|
85049
|
+
// src/domains/security-compliance/services/semgrep-integration.ts
|
|
85050
|
+
import { execFile as execFile2 } from "child_process";
|
|
85051
|
+
import { promisify as promisify4 } from "util";
|
|
85052
|
+
import * as path14 from "path";
|
|
85053
|
+
async function isSemgrepAvailable() {
|
|
85054
|
+
try {
|
|
85055
|
+
await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
85056
|
+
return true;
|
|
85057
|
+
} catch {
|
|
85058
|
+
return false;
|
|
85059
|
+
}
|
|
85060
|
+
}
|
|
85061
|
+
async function getSemgrepVersion() {
|
|
85062
|
+
try {
|
|
85063
|
+
const { stdout } = await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
85064
|
+
return stdout.trim();
|
|
85065
|
+
} catch {
|
|
85066
|
+
return null;
|
|
85067
|
+
}
|
|
85068
|
+
}
|
|
85069
|
+
async function runSemgrep(config) {
|
|
85070
|
+
const fullConfig = {
|
|
85071
|
+
target: config.target || ".",
|
|
85072
|
+
config: config.config || "auto",
|
|
85073
|
+
exclude: config.exclude || ["node_modules", ".git", "dist", "build", "coverage"],
|
|
85074
|
+
maxFileSize: config.maxFileSize || 5e6,
|
|
85075
|
+
// 5MB
|
|
85076
|
+
timeout: config.timeout || 300,
|
|
85077
|
+
verbose: config.verbose || false
|
|
85078
|
+
};
|
|
85079
|
+
const available = await isSemgrepAvailable();
|
|
85080
|
+
if (!available) {
|
|
85081
|
+
return {
|
|
85082
|
+
success: false,
|
|
85083
|
+
findings: [],
|
|
85084
|
+
errors: ["Semgrep is not installed. Install with: pip install semgrep"]
|
|
85085
|
+
};
|
|
85086
|
+
}
|
|
85087
|
+
try {
|
|
85088
|
+
const args = [
|
|
85089
|
+
"scan",
|
|
85090
|
+
`--config=${fullConfig.config}`,
|
|
85091
|
+
"--json",
|
|
85092
|
+
fullConfig.verbose ? "--verbose" : "--quiet",
|
|
85093
|
+
`--max-target-bytes=${fullConfig.maxFileSize}`
|
|
85094
|
+
];
|
|
85095
|
+
for (const excludePattern of fullConfig.exclude) {
|
|
85096
|
+
args.push(`--exclude=${excludePattern}`);
|
|
85097
|
+
}
|
|
85098
|
+
args.push(fullConfig.target);
|
|
85099
|
+
const timeoutMs = (fullConfig.timeout ?? 300) * 1e3;
|
|
85100
|
+
const { stdout, stderr } = await execFileAsync2("semgrep", args, {
|
|
85101
|
+
timeout: timeoutMs,
|
|
85102
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
85103
|
+
// 50MB buffer for large results
|
|
85104
|
+
cwd: path14.isAbsolute(fullConfig.target) ? void 0 : process.cwd()
|
|
85105
|
+
});
|
|
85106
|
+
const result = parseSemgrepOutput(stdout);
|
|
85107
|
+
if (stderr && fullConfig.verbose) {
|
|
85108
|
+
result.errors.push(stderr);
|
|
85109
|
+
}
|
|
85110
|
+
result.version = await getSemgrepVersion() || void 0;
|
|
85111
|
+
return result;
|
|
85112
|
+
} catch (error) {
|
|
85113
|
+
const execError = error;
|
|
85114
|
+
if (execError.stdout) {
|
|
85115
|
+
try {
|
|
85116
|
+
const result = parseSemgrepOutput(execError.stdout);
|
|
85117
|
+
result.version = await getSemgrepVersion() || void 0;
|
|
85118
|
+
return result;
|
|
85119
|
+
} catch {
|
|
85120
|
+
}
|
|
85121
|
+
}
|
|
85122
|
+
return {
|
|
85123
|
+
success: false,
|
|
85124
|
+
findings: [],
|
|
85125
|
+
errors: [execError.message ?? String(error)]
|
|
85126
|
+
};
|
|
85127
|
+
}
|
|
85128
|
+
}
|
|
85129
|
+
function parseSemgrepOutput(stdout) {
|
|
85130
|
+
try {
|
|
85131
|
+
const parsed = safeJsonParse(stdout);
|
|
85132
|
+
const results = parsed.results || parsed.findings || [];
|
|
85133
|
+
const errors = parsed.errors?.map((e20) => e20.message || String(e20)) || [];
|
|
85134
|
+
return {
|
|
85135
|
+
success: true,
|
|
85136
|
+
findings: results.map((r54) => ({
|
|
85137
|
+
check_id: r54.check_id || r54.rule_id || "unknown",
|
|
85138
|
+
path: r54.path,
|
|
85139
|
+
start: { line: r54.start?.line || 1, col: r54.start?.col || 1 },
|
|
85140
|
+
end: { line: r54.end?.line || r54.start?.line || 1, col: r54.end?.col || 1 },
|
|
85141
|
+
extra: {
|
|
85142
|
+
message: r54.extra?.message || r54.message || "Security issue detected",
|
|
85143
|
+
severity: r54.extra?.severity || r54.severity || "WARNING",
|
|
85144
|
+
lines: r54.extra?.lines || "",
|
|
85145
|
+
metadata: {
|
|
85146
|
+
cwe: r54.extra?.metadata?.cwe || r54.metadata?.cwe,
|
|
85147
|
+
owasp: r54.extra?.metadata?.owasp || r54.metadata?.owasp,
|
|
85148
|
+
category: r54.extra?.metadata?.category || r54.metadata?.category,
|
|
85149
|
+
description: r54.extra?.metadata?.description || r54.metadata?.description,
|
|
85150
|
+
fix: r54.extra?.metadata?.fix || r54.extra?.fix,
|
|
85151
|
+
references: r54.extra?.metadata?.references || r54.metadata?.references,
|
|
85152
|
+
confidence: r54.extra?.metadata?.confidence || r54.metadata?.confidence
|
|
85153
|
+
}
|
|
85154
|
+
}
|
|
85155
|
+
})),
|
|
85156
|
+
errors
|
|
85157
|
+
};
|
|
85158
|
+
} catch (error) {
|
|
85159
|
+
return {
|
|
85160
|
+
success: false,
|
|
85161
|
+
findings: [],
|
|
85162
|
+
errors: [`Failed to parse semgrep output: ${toErrorMessage(error)}`]
|
|
85163
|
+
};
|
|
85164
|
+
}
|
|
85165
|
+
}
|
|
85166
|
+
async function runSemgrepWithRules(target, rules, options) {
|
|
85167
|
+
const configMapping = {
|
|
85168
|
+
"owasp-top-10": "p/owasp-top-ten",
|
|
85169
|
+
"cwe-sans-25": "p/cwe-top-25",
|
|
85170
|
+
"nodejs-security": "p/nodejs",
|
|
85171
|
+
"typescript-security": "p/typescript",
|
|
85172
|
+
"javascript-security": "p/javascript",
|
|
85173
|
+
"react-security": "p/react",
|
|
85174
|
+
"express-security": "p/express",
|
|
85175
|
+
"secrets": "p/secrets",
|
|
85176
|
+
"sql-injection": "p/sql-injection",
|
|
85177
|
+
"xss": "p/xss",
|
|
85178
|
+
"command-injection": "p/command-injection",
|
|
85179
|
+
"path-traversal": "p/path-traversal"
|
|
85180
|
+
};
|
|
85181
|
+
const configs = rules.map((r54) => configMapping[r54] || `p/${r54}`).join(",");
|
|
85182
|
+
return runSemgrep({
|
|
85183
|
+
...options,
|
|
85184
|
+
target,
|
|
85185
|
+
config: configs || "auto"
|
|
85186
|
+
});
|
|
85187
|
+
}
|
|
85188
|
+
function mapSemgrepSeverity(severity) {
|
|
85189
|
+
const mapping = {
|
|
85190
|
+
ERROR: "high",
|
|
85191
|
+
WARNING: "medium",
|
|
85192
|
+
INFO: "low"
|
|
85193
|
+
};
|
|
85194
|
+
return mapping[severity] || "medium";
|
|
85195
|
+
}
|
|
85196
|
+
function convertSemgrepFindings(findings) {
|
|
85197
|
+
return findings.map((f74) => ({
|
|
85198
|
+
id: f74.check_id,
|
|
85199
|
+
title: f74.check_id.split(".").pop() || f74.check_id,
|
|
85200
|
+
description: f74.extra.message,
|
|
85201
|
+
severity: mapSemgrepSeverity(f74.extra.severity),
|
|
85202
|
+
file: f74.path,
|
|
85203
|
+
line: f74.start.line,
|
|
85204
|
+
column: f74.start.col,
|
|
85205
|
+
snippet: f74.extra.lines,
|
|
85206
|
+
cweId: f74.extra.metadata?.cwe?.[0],
|
|
85207
|
+
owaspCategory: f74.extra.metadata?.owasp?.[0],
|
|
85208
|
+
remediation: f74.extra.metadata?.fix || "Review and fix the identified security issue",
|
|
85209
|
+
references: f74.extra.metadata?.references || []
|
|
85210
|
+
}));
|
|
85211
|
+
}
|
|
85212
|
+
var execFileAsync2;
|
|
85213
|
+
var init_semgrep_integration = __esm({
|
|
85214
|
+
"src/domains/security-compliance/services/semgrep-integration.ts"() {
|
|
85215
|
+
"use strict";
|
|
85216
|
+
init_error_utils();
|
|
85217
|
+
init_safe_json();
|
|
85218
|
+
execFileAsync2 = promisify4(execFile2);
|
|
85219
|
+
}
|
|
85220
|
+
});
|
|
85221
|
+
|
|
85044
85222
|
// src/domains/security-compliance/services/scanners/sast-scanner.ts
|
|
85045
85223
|
var SASTScanner;
|
|
85046
85224
|
var init_sast_scanner = __esm({
|
|
@@ -85051,6 +85229,7 @@ var init_sast_scanner = __esm({
|
|
|
85051
85229
|
init_security_patterns();
|
|
85052
85230
|
init_error_utils();
|
|
85053
85231
|
init_safe_json();
|
|
85232
|
+
init_semgrep_integration();
|
|
85054
85233
|
SASTScanner = class {
|
|
85055
85234
|
config;
|
|
85056
85235
|
memory;
|
|
@@ -85072,7 +85251,9 @@ var init_sast_scanner = __esm({
|
|
|
85072
85251
|
return this.scanWithRules(files, this.config.defaultRuleSets);
|
|
85073
85252
|
}
|
|
85074
85253
|
/**
|
|
85075
|
-
* Scan with specific rule sets
|
|
85254
|
+
* Scan with specific rule sets.
|
|
85255
|
+
* Runs pattern-based scanning and semgrep (when available) in parallel,
|
|
85256
|
+
* then merges and deduplicates results.
|
|
85076
85257
|
*/
|
|
85077
85258
|
async scanWithRules(files, ruleSetIds) {
|
|
85078
85259
|
const scanId = v4_default();
|
|
@@ -85088,23 +85269,26 @@ var init_sast_scanner = __esm({
|
|
|
85088
85269
|
if (ruleSets.length === 0) {
|
|
85089
85270
|
return err(new Error(`No valid rule sets found: ${ruleSetIds.join(", ")}`));
|
|
85090
85271
|
}
|
|
85091
|
-
const
|
|
85092
|
-
|
|
85093
|
-
|
|
85094
|
-
|
|
85095
|
-
|
|
85096
|
-
|
|
85097
|
-
|
|
85272
|
+
const [patternResult, semgrepVulns] = await Promise.all([
|
|
85273
|
+
this.runPatternScanning(files, ruleSets),
|
|
85274
|
+
this.runSemgrepScanning(files, ruleSetIds)
|
|
85275
|
+
]);
|
|
85276
|
+
const vulnerabilities = this.mergeVulnerabilities(
|
|
85277
|
+
patternResult.vulnerabilities,
|
|
85278
|
+
semgrepVulns
|
|
85279
|
+
);
|
|
85280
|
+
const linesScanned = patternResult.linesScanned;
|
|
85098
85281
|
const scanDurationMs = Date.now() - startTime;
|
|
85099
85282
|
const summary = this.calculateSummary(
|
|
85100
85283
|
vulnerabilities,
|
|
85101
85284
|
files.length,
|
|
85102
85285
|
scanDurationMs
|
|
85103
85286
|
);
|
|
85287
|
+
const patternRules = ruleSets.reduce((acc, rs2) => acc + rs2.ruleCount, 0);
|
|
85104
85288
|
const coverage = {
|
|
85105
85289
|
filesScanned: files.length,
|
|
85106
85290
|
linesScanned,
|
|
85107
|
-
rulesApplied:
|
|
85291
|
+
rulesApplied: patternRules + (semgrepVulns.length > 0 ? semgrepVulns.length : 0)
|
|
85108
85292
|
};
|
|
85109
85293
|
await this.storeScanResults(scanId, "sast", vulnerabilities, summary);
|
|
85110
85294
|
this.activeScans.set(scanId, "completed");
|
|
@@ -85119,6 +85303,119 @@ var init_sast_scanner = __esm({
|
|
|
85119
85303
|
return err(toError(error));
|
|
85120
85304
|
}
|
|
85121
85305
|
}
|
|
85306
|
+
/**
|
|
85307
|
+
* Run pattern-based scanning on all files
|
|
85308
|
+
*/
|
|
85309
|
+
async runPatternScanning(files, ruleSets) {
|
|
85310
|
+
const vulnerabilities = [];
|
|
85311
|
+
let linesScanned = 0;
|
|
85312
|
+
for (const file of files) {
|
|
85313
|
+
const fileVulns = await this.analyzeFile(file, ruleSets);
|
|
85314
|
+
vulnerabilities.push(...fileVulns.vulnerabilities);
|
|
85315
|
+
linesScanned += fileVulns.linesScanned;
|
|
85316
|
+
}
|
|
85317
|
+
return { vulnerabilities, linesScanned };
|
|
85318
|
+
}
|
|
85319
|
+
/**
|
|
85320
|
+
* Run semgrep scanning when enabled and available.
|
|
85321
|
+
* Returns converted vulnerabilities or empty array on failure/unavailability.
|
|
85322
|
+
*/
|
|
85323
|
+
async runSemgrepScanning(files, ruleSetIds) {
|
|
85324
|
+
if (!this.config.enableSemgrep) {
|
|
85325
|
+
return [];
|
|
85326
|
+
}
|
|
85327
|
+
try {
|
|
85328
|
+
const available = await isSemgrepAvailable();
|
|
85329
|
+
if (!available) {
|
|
85330
|
+
return [];
|
|
85331
|
+
}
|
|
85332
|
+
const targetDir = this.resolveTargetDirectory(files);
|
|
85333
|
+
const semgrepResult = await runSemgrepWithRules(targetDir, ruleSetIds);
|
|
85334
|
+
if (!semgrepResult.success || semgrepResult.findings.length === 0) {
|
|
85335
|
+
return [];
|
|
85336
|
+
}
|
|
85337
|
+
const converted = convertSemgrepFindings(semgrepResult.findings);
|
|
85338
|
+
return converted.map((f74) => ({
|
|
85339
|
+
id: v4_default(),
|
|
85340
|
+
cveId: void 0,
|
|
85341
|
+
title: f74.title,
|
|
85342
|
+
description: `[semgrep] ${f74.description}`,
|
|
85343
|
+
severity: f74.severity,
|
|
85344
|
+
category: this.mapSemgrepCategory(f74.owaspCategory),
|
|
85345
|
+
location: {
|
|
85346
|
+
file: f74.file,
|
|
85347
|
+
line: f74.line,
|
|
85348
|
+
column: f74.column,
|
|
85349
|
+
snippet: f74.snippet
|
|
85350
|
+
},
|
|
85351
|
+
remediation: {
|
|
85352
|
+
description: f74.remediation,
|
|
85353
|
+
estimatedEffort: "moderate",
|
|
85354
|
+
automatable: false
|
|
85355
|
+
},
|
|
85356
|
+
references: f74.references
|
|
85357
|
+
}));
|
|
85358
|
+
} catch {
|
|
85359
|
+
return [];
|
|
85360
|
+
}
|
|
85361
|
+
}
|
|
85362
|
+
/**
|
|
85363
|
+
* Resolve the common parent directory from a set of file paths
|
|
85364
|
+
*/
|
|
85365
|
+
resolveTargetDirectory(files) {
|
|
85366
|
+
if (files.length === 0) return ".";
|
|
85367
|
+
if (files.length === 1) return files[0].directory || ".";
|
|
85368
|
+
const dirs = files.map((f74) => f74.directory || ".");
|
|
85369
|
+
const first = dirs[0];
|
|
85370
|
+
let commonLen = first.length;
|
|
85371
|
+
for (let i58 = 1; i58 < dirs.length; i58++) {
|
|
85372
|
+
const dir = dirs[i58];
|
|
85373
|
+
const maxLen = Math.min(commonLen, dir.length);
|
|
85374
|
+
let j52 = 0;
|
|
85375
|
+
while (j52 < maxLen && first[j52] === dir[j52]) j52++;
|
|
85376
|
+
commonLen = j52;
|
|
85377
|
+
}
|
|
85378
|
+
const common = first.substring(0, commonLen);
|
|
85379
|
+
const lastSep = common.lastIndexOf("/");
|
|
85380
|
+
return lastSep > 0 ? common.substring(0, lastSep) : common || ".";
|
|
85381
|
+
}
|
|
85382
|
+
/**
|
|
85383
|
+
* Map semgrep OWASP category string to VulnerabilityCategory
|
|
85384
|
+
*/
|
|
85385
|
+
mapSemgrepCategory(owaspCategory) {
|
|
85386
|
+
if (!owaspCategory) return "injection";
|
|
85387
|
+
const categoryMap = {
|
|
85388
|
+
"A01": "access-control",
|
|
85389
|
+
"A02": "sensitive-data",
|
|
85390
|
+
"A03": "injection",
|
|
85391
|
+
"A04": "insecure-deserialization",
|
|
85392
|
+
"A05": "security-misconfiguration",
|
|
85393
|
+
"A06": "vulnerable-components",
|
|
85394
|
+
"A07": "broken-auth",
|
|
85395
|
+
"A08": "insecure-deserialization",
|
|
85396
|
+
"A09": "insufficient-logging",
|
|
85397
|
+
"A10": "xxe"
|
|
85398
|
+
};
|
|
85399
|
+
for (const [key, value] of Object.entries(categoryMap)) {
|
|
85400
|
+
if (owaspCategory.startsWith(key)) return value;
|
|
85401
|
+
}
|
|
85402
|
+
return "injection";
|
|
85403
|
+
}
|
|
85404
|
+
/**
|
|
85405
|
+
* Merge pattern-based and semgrep vulnerabilities, deduplicating
|
|
85406
|
+
* findings that overlap on the same file and line.
|
|
85407
|
+
*/
|
|
85408
|
+
mergeVulnerabilities(patternVulns, semgrepVulns) {
|
|
85409
|
+
if (semgrepVulns.length === 0) return patternVulns;
|
|
85410
|
+
if (patternVulns.length === 0) return semgrepVulns;
|
|
85411
|
+
const patternKeys = new Set(
|
|
85412
|
+
patternVulns.map((v65) => `${v65.location.file}:${v65.location.line ?? 0}:${v65.category}`)
|
|
85413
|
+
);
|
|
85414
|
+
const uniqueSemgrep = semgrepVulns.filter(
|
|
85415
|
+
(v65) => !patternKeys.has(`${v65.location.file}:${v65.location.line ?? 0}:${v65.category}`)
|
|
85416
|
+
);
|
|
85417
|
+
return [...patternVulns, ...uniqueSemgrep];
|
|
85418
|
+
}
|
|
85122
85419
|
/**
|
|
85123
85420
|
* Get available rule sets
|
|
85124
85421
|
*/
|
|
@@ -87819,7 +88116,7 @@ var init_security_auditor_types = __esm({
|
|
|
87819
88116
|
|
|
87820
88117
|
// src/domains/security-compliance/services/security-auditor-sast.ts
|
|
87821
88118
|
import * as fs12 from "fs/promises";
|
|
87822
|
-
import * as
|
|
88119
|
+
import * as path15 from "path";
|
|
87823
88120
|
function getSASTVulnerabilityPatterns() {
|
|
87824
88121
|
return [
|
|
87825
88122
|
// SQL Injection patterns
|
|
@@ -87970,7 +88267,7 @@ async function performSASTScan(findSourceFiles, shouldExclude) {
|
|
|
87970
88267
|
if (shouldExclude(filePath)) {
|
|
87971
88268
|
continue;
|
|
87972
88269
|
}
|
|
87973
|
-
const ext =
|
|
88270
|
+
const ext = path15.extname(filePath).toLowerCase();
|
|
87974
88271
|
if (![".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
|
|
87975
88272
|
continue;
|
|
87976
88273
|
}
|
|
@@ -88696,7 +88993,7 @@ var init_security_auditor_reports = __esm({
|
|
|
88696
88993
|
|
|
88697
88994
|
// src/domains/security-compliance/services/security-auditor.ts
|
|
88698
88995
|
import * as fs14 from "fs/promises";
|
|
88699
|
-
import * as
|
|
88996
|
+
import * as path16 from "path";
|
|
88700
88997
|
var SecurityAuditorService;
|
|
88701
88998
|
var init_security_auditor = __esm({
|
|
88702
88999
|
"src/domains/security-compliance/services/security-auditor.ts"() {
|
|
@@ -89182,7 +89479,7 @@ var init_security_auditor = __esm({
|
|
|
89182
89479
|
const vulnerabilities = [];
|
|
89183
89480
|
const outdatedPackages = [];
|
|
89184
89481
|
try {
|
|
89185
|
-
const manifestPath =
|
|
89482
|
+
const manifestPath = path16.join(process.cwd(), "package.json");
|
|
89186
89483
|
const dependencies = await this.parseDependencies(manifestPath, "npm");
|
|
89187
89484
|
for (const dep of dependencies) {
|
|
89188
89485
|
const vulns = await this.checkDependencyVulnerabilities(dep, dep.ecosystem);
|
|
@@ -89236,14 +89533,14 @@ var init_security_auditor = __esm({
|
|
|
89236
89533
|
try {
|
|
89237
89534
|
const entries = await fs14.readdir(dir, { withFileTypes: true });
|
|
89238
89535
|
for (const entry of entries) {
|
|
89239
|
-
const fullPath =
|
|
89536
|
+
const fullPath = path16.join(dir, entry.name);
|
|
89240
89537
|
if (this.shouldExclude(fullPath)) {
|
|
89241
89538
|
continue;
|
|
89242
89539
|
}
|
|
89243
89540
|
if (entry.isDirectory()) {
|
|
89244
89541
|
await this.findSourceFiles(fullPath, files);
|
|
89245
89542
|
} else if (entry.isFile()) {
|
|
89246
|
-
const ext =
|
|
89543
|
+
const ext = path16.extname(entry.name).toLowerCase();
|
|
89247
89544
|
if (sourceExtensions.includes(ext) || entry.name.startsWith(".env")) {
|
|
89248
89545
|
files.push(fullPath);
|
|
89249
89546
|
}
|
|
@@ -101280,7 +101577,7 @@ var init_plugin10 = __esm({
|
|
|
101280
101577
|
|
|
101281
101578
|
// src/domains/chaos-resilience/services/chaos-engineer.ts
|
|
101282
101579
|
import * as net from "net";
|
|
101283
|
-
import { execFile as
|
|
101580
|
+
import { execFile as execFile3 } from "child_process";
|
|
101284
101581
|
var DEFAULT_CONFIG55, ChaosEngineerService;
|
|
101285
101582
|
var init_chaos_engineer = __esm({
|
|
101286
101583
|
"src/domains/chaos-resilience/services/chaos-engineer.ts"() {
|
|
@@ -101790,7 +102087,7 @@ Provide:
|
|
|
101790
102087
|
const parts = sanitizedCommand.trim().split(/\s+/);
|
|
101791
102088
|
const executable = parts[0];
|
|
101792
102089
|
const args = parts.slice(1);
|
|
101793
|
-
|
|
102090
|
+
execFile3(executable, args, { timeout }, (error, stdout, _stderr) => {
|
|
101794
102091
|
if (error) {
|
|
101795
102092
|
console.log(`Command probe failed: ${probe.name} -> ${error.message}`);
|
|
101796
102093
|
resolve11(false);
|
|
@@ -102134,7 +102431,7 @@ Provide:
|
|
|
102134
102431
|
const parts = sanitizedCommand.trim().split(/\s+/);
|
|
102135
102432
|
const executable = parts[0];
|
|
102136
102433
|
const args = parts.slice(1);
|
|
102137
|
-
|
|
102434
|
+
execFile3(executable, args, { timeout }, (error, _stdout, stderr) => {
|
|
102138
102435
|
if (error) {
|
|
102139
102436
|
reject(new Error(`Command rollback failed: ${error.message}. ${stderr}`));
|
|
102140
102437
|
} else {
|
|
@@ -114833,179 +115130,6 @@ var init_coverage_analysis = __esm({
|
|
|
114833
115130
|
}
|
|
114834
115131
|
});
|
|
114835
115132
|
|
|
114836
|
-
// src/domains/security-compliance/services/semgrep-integration.ts
|
|
114837
|
-
import { execFile as execFile3 } from "child_process";
|
|
114838
|
-
import { promisify as promisify4 } from "util";
|
|
114839
|
-
import * as path16 from "path";
|
|
114840
|
-
async function isSemgrepAvailable() {
|
|
114841
|
-
try {
|
|
114842
|
-
await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
114843
|
-
return true;
|
|
114844
|
-
} catch {
|
|
114845
|
-
return false;
|
|
114846
|
-
}
|
|
114847
|
-
}
|
|
114848
|
-
async function getSemgrepVersion() {
|
|
114849
|
-
try {
|
|
114850
|
-
const { stdout } = await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
114851
|
-
return stdout.trim();
|
|
114852
|
-
} catch {
|
|
114853
|
-
return null;
|
|
114854
|
-
}
|
|
114855
|
-
}
|
|
114856
|
-
async function runSemgrep(config) {
|
|
114857
|
-
const fullConfig = {
|
|
114858
|
-
target: config.target || ".",
|
|
114859
|
-
config: config.config || "auto",
|
|
114860
|
-
exclude: config.exclude || ["node_modules", ".git", "dist", "build", "coverage"],
|
|
114861
|
-
maxFileSize: config.maxFileSize || 5e6,
|
|
114862
|
-
// 5MB
|
|
114863
|
-
timeout: config.timeout || 300,
|
|
114864
|
-
verbose: config.verbose || false
|
|
114865
|
-
};
|
|
114866
|
-
const available = await isSemgrepAvailable();
|
|
114867
|
-
if (!available) {
|
|
114868
|
-
return {
|
|
114869
|
-
success: false,
|
|
114870
|
-
findings: [],
|
|
114871
|
-
errors: ["Semgrep is not installed. Install with: pip install semgrep"]
|
|
114872
|
-
};
|
|
114873
|
-
}
|
|
114874
|
-
try {
|
|
114875
|
-
const args = [
|
|
114876
|
-
"scan",
|
|
114877
|
-
`--config=${fullConfig.config}`,
|
|
114878
|
-
"--json",
|
|
114879
|
-
fullConfig.verbose ? "--verbose" : "--quiet",
|
|
114880
|
-
`--max-target-bytes=${fullConfig.maxFileSize}`
|
|
114881
|
-
];
|
|
114882
|
-
for (const excludePattern of fullConfig.exclude) {
|
|
114883
|
-
args.push(`--exclude=${excludePattern}`);
|
|
114884
|
-
}
|
|
114885
|
-
args.push(fullConfig.target);
|
|
114886
|
-
const timeoutMs = (fullConfig.timeout ?? 300) * 1e3;
|
|
114887
|
-
const { stdout, stderr } = await execFileAsync2("semgrep", args, {
|
|
114888
|
-
timeout: timeoutMs,
|
|
114889
|
-
maxBuffer: 50 * 1024 * 1024,
|
|
114890
|
-
// 50MB buffer for large results
|
|
114891
|
-
cwd: path16.isAbsolute(fullConfig.target) ? void 0 : process.cwd()
|
|
114892
|
-
});
|
|
114893
|
-
const result = parseSemgrepOutput(stdout);
|
|
114894
|
-
if (stderr && fullConfig.verbose) {
|
|
114895
|
-
result.errors.push(stderr);
|
|
114896
|
-
}
|
|
114897
|
-
result.version = await getSemgrepVersion() || void 0;
|
|
114898
|
-
return result;
|
|
114899
|
-
} catch (error) {
|
|
114900
|
-
const execError = error;
|
|
114901
|
-
if (execError.stdout) {
|
|
114902
|
-
try {
|
|
114903
|
-
const result = parseSemgrepOutput(execError.stdout);
|
|
114904
|
-
result.version = await getSemgrepVersion() || void 0;
|
|
114905
|
-
return result;
|
|
114906
|
-
} catch {
|
|
114907
|
-
}
|
|
114908
|
-
}
|
|
114909
|
-
return {
|
|
114910
|
-
success: false,
|
|
114911
|
-
findings: [],
|
|
114912
|
-
errors: [execError.message ?? String(error)]
|
|
114913
|
-
};
|
|
114914
|
-
}
|
|
114915
|
-
}
|
|
114916
|
-
function parseSemgrepOutput(stdout) {
|
|
114917
|
-
try {
|
|
114918
|
-
const parsed = safeJsonParse(stdout);
|
|
114919
|
-
const results = parsed.results || parsed.findings || [];
|
|
114920
|
-
const errors = parsed.errors?.map((e20) => e20.message || String(e20)) || [];
|
|
114921
|
-
return {
|
|
114922
|
-
success: true,
|
|
114923
|
-
findings: results.map((r54) => ({
|
|
114924
|
-
check_id: r54.check_id || r54.rule_id || "unknown",
|
|
114925
|
-
path: r54.path,
|
|
114926
|
-
start: { line: r54.start?.line || 1, col: r54.start?.col || 1 },
|
|
114927
|
-
end: { line: r54.end?.line || r54.start?.line || 1, col: r54.end?.col || 1 },
|
|
114928
|
-
extra: {
|
|
114929
|
-
message: r54.extra?.message || r54.message || "Security issue detected",
|
|
114930
|
-
severity: r54.extra?.severity || r54.severity || "WARNING",
|
|
114931
|
-
lines: r54.extra?.lines || "",
|
|
114932
|
-
metadata: {
|
|
114933
|
-
cwe: r54.extra?.metadata?.cwe || r54.metadata?.cwe,
|
|
114934
|
-
owasp: r54.extra?.metadata?.owasp || r54.metadata?.owasp,
|
|
114935
|
-
category: r54.extra?.metadata?.category || r54.metadata?.category,
|
|
114936
|
-
description: r54.extra?.metadata?.description || r54.metadata?.description,
|
|
114937
|
-
fix: r54.extra?.metadata?.fix || r54.extra?.fix,
|
|
114938
|
-
references: r54.extra?.metadata?.references || r54.metadata?.references,
|
|
114939
|
-
confidence: r54.extra?.metadata?.confidence || r54.metadata?.confidence
|
|
114940
|
-
}
|
|
114941
|
-
}
|
|
114942
|
-
})),
|
|
114943
|
-
errors
|
|
114944
|
-
};
|
|
114945
|
-
} catch (error) {
|
|
114946
|
-
return {
|
|
114947
|
-
success: false,
|
|
114948
|
-
findings: [],
|
|
114949
|
-
errors: [`Failed to parse semgrep output: ${toErrorMessage(error)}`]
|
|
114950
|
-
};
|
|
114951
|
-
}
|
|
114952
|
-
}
|
|
114953
|
-
async function runSemgrepWithRules(target, rules, options) {
|
|
114954
|
-
const configMapping = {
|
|
114955
|
-
"owasp-top-10": "p/owasp-top-ten",
|
|
114956
|
-
"cwe-sans-25": "p/cwe-top-25",
|
|
114957
|
-
"nodejs-security": "p/nodejs",
|
|
114958
|
-
"typescript-security": "p/typescript",
|
|
114959
|
-
"javascript-security": "p/javascript",
|
|
114960
|
-
"react-security": "p/react",
|
|
114961
|
-
"express-security": "p/express",
|
|
114962
|
-
"secrets": "p/secrets",
|
|
114963
|
-
"sql-injection": "p/sql-injection",
|
|
114964
|
-
"xss": "p/xss",
|
|
114965
|
-
"command-injection": "p/command-injection",
|
|
114966
|
-
"path-traversal": "p/path-traversal"
|
|
114967
|
-
};
|
|
114968
|
-
const configs = rules.map((r54) => configMapping[r54] || `p/${r54}`).join(",");
|
|
114969
|
-
return runSemgrep({
|
|
114970
|
-
...options,
|
|
114971
|
-
target,
|
|
114972
|
-
config: configs || "auto"
|
|
114973
|
-
});
|
|
114974
|
-
}
|
|
114975
|
-
function mapSemgrepSeverity(severity) {
|
|
114976
|
-
const mapping = {
|
|
114977
|
-
ERROR: "high",
|
|
114978
|
-
WARNING: "medium",
|
|
114979
|
-
INFO: "low"
|
|
114980
|
-
};
|
|
114981
|
-
return mapping[severity] || "medium";
|
|
114982
|
-
}
|
|
114983
|
-
function convertSemgrepFindings(findings) {
|
|
114984
|
-
return findings.map((f74) => ({
|
|
114985
|
-
id: f74.check_id,
|
|
114986
|
-
title: f74.check_id.split(".").pop() || f74.check_id,
|
|
114987
|
-
description: f74.extra.message,
|
|
114988
|
-
severity: mapSemgrepSeverity(f74.extra.severity),
|
|
114989
|
-
file: f74.path,
|
|
114990
|
-
line: f74.start.line,
|
|
114991
|
-
column: f74.start.col,
|
|
114992
|
-
snippet: f74.extra.lines,
|
|
114993
|
-
cweId: f74.extra.metadata?.cwe?.[0],
|
|
114994
|
-
owaspCategory: f74.extra.metadata?.owasp?.[0],
|
|
114995
|
-
remediation: f74.extra.metadata?.fix || "Review and fix the identified security issue",
|
|
114996
|
-
references: f74.extra.metadata?.references || []
|
|
114997
|
-
}));
|
|
114998
|
-
}
|
|
114999
|
-
var execFileAsync2;
|
|
115000
|
-
var init_semgrep_integration = __esm({
|
|
115001
|
-
"src/domains/security-compliance/services/semgrep-integration.ts"() {
|
|
115002
|
-
"use strict";
|
|
115003
|
-
init_error_utils();
|
|
115004
|
-
init_safe_json();
|
|
115005
|
-
execFileAsync2 = promisify4(execFile3);
|
|
115006
|
-
}
|
|
115007
|
-
});
|
|
115008
|
-
|
|
115009
115133
|
// src/domains/security-compliance/index.ts
|
|
115010
115134
|
var init_security_compliance = __esm({
|
|
115011
115135
|
"src/domains/security-compliance/index.ts"() {
|
|
@@ -119094,6 +119218,457 @@ var init_queen_integration2 = __esm({
|
|
|
119094
119218
|
}
|
|
119095
119219
|
});
|
|
119096
119220
|
|
|
119221
|
+
// src/routing/co-execution-repository.ts
|
|
119222
|
+
function getCoExecutionRepository() {
|
|
119223
|
+
if (!_instance2) {
|
|
119224
|
+
_instance2 = new CoExecutionRepository();
|
|
119225
|
+
}
|
|
119226
|
+
return _instance2;
|
|
119227
|
+
}
|
|
119228
|
+
var CONFIDENCE_RAMP_THRESHOLD, CoExecutionRepository, _instance2;
|
|
119229
|
+
var init_co_execution_repository = __esm({
|
|
119230
|
+
"src/routing/co-execution-repository.ts"() {
|
|
119231
|
+
"use strict";
|
|
119232
|
+
init_error_utils();
|
|
119233
|
+
CONFIDENCE_RAMP_THRESHOLD = 20;
|
|
119234
|
+
CoExecutionRepository = class {
|
|
119235
|
+
db = null;
|
|
119236
|
+
initialized = false;
|
|
119237
|
+
/**
|
|
119238
|
+
* Initialize with a database connection.
|
|
119239
|
+
* Creates the co-execution table if it doesn't exist.
|
|
119240
|
+
*/
|
|
119241
|
+
initialize(db) {
|
|
119242
|
+
if (this.initialized) return;
|
|
119243
|
+
this.db = db;
|
|
119244
|
+
try {
|
|
119245
|
+
this.db.exec(`
|
|
119246
|
+
CREATE TABLE IF NOT EXISTS qe_agent_co_execution (
|
|
119247
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
119248
|
+
agent_a TEXT NOT NULL,
|
|
119249
|
+
agent_b TEXT NOT NULL,
|
|
119250
|
+
domain TEXT NOT NULL,
|
|
119251
|
+
success INTEGER NOT NULL DEFAULT 0,
|
|
119252
|
+
task_description TEXT,
|
|
119253
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
119254
|
+
);
|
|
119255
|
+
|
|
119256
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_agents
|
|
119257
|
+
ON qe_agent_co_execution(agent_a, agent_b);
|
|
119258
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_domain
|
|
119259
|
+
ON qe_agent_co_execution(domain);
|
|
119260
|
+
`);
|
|
119261
|
+
this.initialized = true;
|
|
119262
|
+
} catch (error) {
|
|
119263
|
+
console.error(`[CoExecutionRepository] Init error: ${toErrorMessage(error)}`);
|
|
119264
|
+
}
|
|
119265
|
+
}
|
|
119266
|
+
/**
|
|
119267
|
+
* Record a co-execution event between two agents.
|
|
119268
|
+
* Agent order is normalized (sorted) so A-B and B-A are the same pair.
|
|
119269
|
+
*/
|
|
119270
|
+
recordCoExecution(record) {
|
|
119271
|
+
if (!this.db) return;
|
|
119272
|
+
const [a37, b68] = [record.agentA, record.agentB].sort();
|
|
119273
|
+
try {
|
|
119274
|
+
this.db.prepare(`
|
|
119275
|
+
INSERT INTO qe_agent_co_execution (agent_a, agent_b, domain, success, task_description)
|
|
119276
|
+
VALUES (?, ?, ?, ?, ?)
|
|
119277
|
+
`).run(
|
|
119278
|
+
a37,
|
|
119279
|
+
b68,
|
|
119280
|
+
record.domain,
|
|
119281
|
+
record.success ? 1 : 0,
|
|
119282
|
+
record.taskDescription?.slice(0, 500) || null
|
|
119283
|
+
);
|
|
119284
|
+
} catch (error) {
|
|
119285
|
+
console.debug(`[CoExecutionRepository] Record error: ${toErrorMessage(error)}`);
|
|
119286
|
+
}
|
|
119287
|
+
}
|
|
119288
|
+
/**
|
|
119289
|
+
* Get co-execution stats for a specific agent pair.
|
|
119290
|
+
* Returns behavioral confidence using linear ramp: min(1.0, successCount / 20).
|
|
119291
|
+
*/
|
|
119292
|
+
getCoExecutionStats(agentA, agentB) {
|
|
119293
|
+
if (!this.db) return null;
|
|
119294
|
+
const [a37, b68] = [agentA, agentB].sort();
|
|
119295
|
+
try {
|
|
119296
|
+
const row2 = this.db.prepare(`
|
|
119297
|
+
SELECT
|
|
119298
|
+
agent_a,
|
|
119299
|
+
agent_b,
|
|
119300
|
+
COUNT(*) as total_executions,
|
|
119301
|
+
SUM(CASE WHEN success = 1 THEN 1 ELSE 0 END) as success_count
|
|
119302
|
+
FROM qe_agent_co_execution
|
|
119303
|
+
WHERE agent_a = ? AND agent_b = ?
|
|
119304
|
+
GROUP BY agent_a, agent_b
|
|
119305
|
+
`).get(a37, b68);
|
|
119306
|
+
if (!row2) return null;
|
|
119307
|
+
const successRate = row2.total_executions > 0 ? row2.success_count / row2.total_executions : 0;
|
|
119308
|
+
const behavioralConfidence = Math.min(1, row2.success_count / CONFIDENCE_RAMP_THRESHOLD);
|
|
119309
|
+
return {
|
|
119310
|
+
agentA: row2.agent_a,
|
|
119311
|
+
agentB: row2.agent_b,
|
|
119312
|
+
totalExecutions: row2.total_executions,
|
|
119313
|
+
successCount: row2.success_count,
|
|
119314
|
+
successRate,
|
|
119315
|
+
behavioralConfidence
|
|
119316
|
+
};
|
|
119317
|
+
} catch (error) {
|
|
119318
|
+
console.debug(`[CoExecutionRepository] Stats error: ${toErrorMessage(error)}`);
|
|
119319
|
+
return null;
|
|
119320
|
+
}
|
|
119321
|
+
}
|
|
119322
|
+
/**
|
|
119323
|
+
* Get all agents that have successfully co-executed with the given agent.
|
|
119324
|
+
* Returns them sorted by behavioral confidence (descending).
|
|
119325
|
+
*/
|
|
119326
|
+
getCoExecutionPartners(agentId, limit = 10) {
|
|
119327
|
+
if (!this.db) return [];
|
|
119328
|
+
try {
|
|
119329
|
+
const rows = this.db.prepare(`
|
|
119330
|
+
SELECT
|
|
119331
|
+
agent_a,
|
|
119332
|
+
agent_b,
|
|
119333
|
+
COUNT(*) as total_executions,
|
|
119334
|
+
SUM(CASE WHEN success = 1 THEN 1 ELSE 0 END) as success_count
|
|
119335
|
+
FROM qe_agent_co_execution
|
|
119336
|
+
WHERE agent_a = ? OR agent_b = ?
|
|
119337
|
+
GROUP BY agent_a, agent_b
|
|
119338
|
+
ORDER BY success_count DESC
|
|
119339
|
+
LIMIT ?
|
|
119340
|
+
`).all(agentId, agentId, limit);
|
|
119341
|
+
return rows.map((row2) => {
|
|
119342
|
+
const successRate = row2.total_executions > 0 ? row2.success_count / row2.total_executions : 0;
|
|
119343
|
+
return {
|
|
119344
|
+
agentA: row2.agent_a,
|
|
119345
|
+
agentB: row2.agent_b,
|
|
119346
|
+
totalExecutions: row2.total_executions,
|
|
119347
|
+
successCount: row2.success_count,
|
|
119348
|
+
successRate,
|
|
119349
|
+
behavioralConfidence: Math.min(1, row2.success_count / CONFIDENCE_RAMP_THRESHOLD)
|
|
119350
|
+
};
|
|
119351
|
+
});
|
|
119352
|
+
} catch (error) {
|
|
119353
|
+
console.debug(`[CoExecutionRepository] Partners error: ${toErrorMessage(error)}`);
|
|
119354
|
+
return [];
|
|
119355
|
+
}
|
|
119356
|
+
}
|
|
119357
|
+
/**
|
|
119358
|
+
* Record a batch of co-executions from a swarm task.
|
|
119359
|
+
* Given a list of agents that participated in a task together,
|
|
119360
|
+
* records co-execution for every unique pair.
|
|
119361
|
+
*/
|
|
119362
|
+
recordSwarmCoExecution(agentIds, domain, success, taskDescription) {
|
|
119363
|
+
if (!this.db || agentIds.length < 2) return;
|
|
119364
|
+
try {
|
|
119365
|
+
const insert = this.db.prepare(`
|
|
119366
|
+
INSERT INTO qe_agent_co_execution (agent_a, agent_b, domain, success, task_description)
|
|
119367
|
+
VALUES (?, ?, ?, ?, ?)
|
|
119368
|
+
`);
|
|
119369
|
+
const transaction = this.db.transaction(() => {
|
|
119370
|
+
for (let i58 = 0; i58 < agentIds.length; i58++) {
|
|
119371
|
+
for (let j52 = i58 + 1; j52 < agentIds.length; j52++) {
|
|
119372
|
+
const [a37, b68] = [agentIds[i58], agentIds[j52]].sort();
|
|
119373
|
+
insert.run(a37, b68, domain, success ? 1 : 0, taskDescription?.slice(0, 500) || null);
|
|
119374
|
+
}
|
|
119375
|
+
}
|
|
119376
|
+
});
|
|
119377
|
+
transaction();
|
|
119378
|
+
} catch (error) {
|
|
119379
|
+
console.debug(`[CoExecutionRepository] Swarm record error: ${toErrorMessage(error)}`);
|
|
119380
|
+
}
|
|
119381
|
+
}
|
|
119382
|
+
};
|
|
119383
|
+
_instance2 = null;
|
|
119384
|
+
}
|
|
119385
|
+
});
|
|
119386
|
+
|
|
119387
|
+
// src/validation/steps/agent-mcp-validator.ts
|
|
119388
|
+
import { readFileSync as readFileSync9, existsSync as existsSync11, readdirSync as readdirSync6 } from "fs";
|
|
119389
|
+
import { join as join16 } from "path";
|
|
119390
|
+
function getAvailableMcpServers(projectRoot) {
|
|
119391
|
+
const servers = [];
|
|
119392
|
+
const mcpConfigPaths = [
|
|
119393
|
+
join16(projectRoot, ".claude", "mcp.json"),
|
|
119394
|
+
join16(projectRoot, ".mcp.json")
|
|
119395
|
+
];
|
|
119396
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
119397
|
+
if (homeDir) {
|
|
119398
|
+
mcpConfigPaths.push(join16(homeDir, ".claude", "mcp.json"));
|
|
119399
|
+
}
|
|
119400
|
+
for (const configPath of mcpConfigPaths) {
|
|
119401
|
+
if (!existsSync11(configPath)) continue;
|
|
119402
|
+
try {
|
|
119403
|
+
const content = readFileSync9(configPath, "utf-8");
|
|
119404
|
+
const config = JSON.parse(content);
|
|
119405
|
+
if (config.mcpServers && typeof config.mcpServers === "object") {
|
|
119406
|
+
servers.push(...Object.keys(config.mcpServers));
|
|
119407
|
+
}
|
|
119408
|
+
} catch {
|
|
119409
|
+
}
|
|
119410
|
+
}
|
|
119411
|
+
return [...new Set(servers)];
|
|
119412
|
+
}
|
|
119413
|
+
var MAX_SCAN_SIZE_BYTES;
|
|
119414
|
+
var init_agent_mcp_validator = __esm({
|
|
119415
|
+
"src/validation/steps/agent-mcp-validator.ts"() {
|
|
119416
|
+
"use strict";
|
|
119417
|
+
MAX_SCAN_SIZE_BYTES = 100 * 1024;
|
|
119418
|
+
}
|
|
119419
|
+
});
|
|
119420
|
+
|
|
119421
|
+
// src/routing/agent-dependency-graph.ts
|
|
119422
|
+
import { readFileSync as readFileSync10, existsSync as existsSync12, readdirSync as readdirSync7 } from "fs";
|
|
119423
|
+
import { join as join17, basename as basename3 } from "path";
|
|
119424
|
+
function extractFrontmatter(content) {
|
|
119425
|
+
const lines = content.split("\n");
|
|
119426
|
+
if (lines.length < 2 || lines[0].trim() !== "---") return null;
|
|
119427
|
+
for (let i58 = 1; i58 < lines.length; i58++) {
|
|
119428
|
+
if (lines[i58].trim() === "---") return lines.slice(1, i58).join("\n");
|
|
119429
|
+
}
|
|
119430
|
+
return null;
|
|
119431
|
+
}
|
|
119432
|
+
function parseYamlValue(raw) {
|
|
119433
|
+
const t50 = raw.trim();
|
|
119434
|
+
if (t50.startsWith('"') && t50.endsWith('"') || t50.startsWith("'") && t50.endsWith("'")) {
|
|
119435
|
+
return t50.slice(1, -1);
|
|
119436
|
+
}
|
|
119437
|
+
return t50;
|
|
119438
|
+
}
|
|
119439
|
+
function parseDependenciesFromFrontmatter(content) {
|
|
119440
|
+
const frontmatter = extractFrontmatter(content);
|
|
119441
|
+
if (!frontmatter) return null;
|
|
119442
|
+
const lines = frontmatter.split("\n");
|
|
119443
|
+
let depsStart = -1;
|
|
119444
|
+
for (let i58 = 0; i58 < lines.length; i58++) {
|
|
119445
|
+
if (/^dependencies:\s*$/.test(lines[i58])) {
|
|
119446
|
+
depsStart = i58 + 1;
|
|
119447
|
+
break;
|
|
119448
|
+
}
|
|
119449
|
+
}
|
|
119450
|
+
if (depsStart === -1) return null;
|
|
119451
|
+
const depsLines = [];
|
|
119452
|
+
for (let i58 = depsStart; i58 < lines.length; i58++) {
|
|
119453
|
+
const line = lines[i58];
|
|
119454
|
+
if (line.trim() === "") continue;
|
|
119455
|
+
if (line.length > 0 && line[0] !== " " && line[0] !== " ") break;
|
|
119456
|
+
depsLines.push(line);
|
|
119457
|
+
}
|
|
119458
|
+
if (depsLines.length === 0) return null;
|
|
119459
|
+
const result = {};
|
|
119460
|
+
const st2 = { section: "none", item: {}, inList: false };
|
|
119461
|
+
const flushAgent = () => {
|
|
119462
|
+
if (!st2.item.name) return;
|
|
119463
|
+
if (!result.agents) result.agents = [];
|
|
119464
|
+
result.agents.push({ name: st2.item.name, type: st2.item.type || "hard", reason: st2.item.reason || "" });
|
|
119465
|
+
st2.item = {};
|
|
119466
|
+
};
|
|
119467
|
+
const flushMcp = () => {
|
|
119468
|
+
if (!st2.item.name) return;
|
|
119469
|
+
if (!result.mcpServers) result.mcpServers = [];
|
|
119470
|
+
result.mcpServers.push({ name: st2.item.name, required: st2.item.required === "true" });
|
|
119471
|
+
st2.item = {};
|
|
119472
|
+
};
|
|
119473
|
+
for (const line of depsLines) {
|
|
119474
|
+
const trimmed = line.trim();
|
|
119475
|
+
if (trimmed === "") continue;
|
|
119476
|
+
const secMatch = trimmed.match(/^(agents|mcp_servers|models):\s*$/);
|
|
119477
|
+
if (secMatch) {
|
|
119478
|
+
if (st2.section === "agents" && st2.inList) flushAgent();
|
|
119479
|
+
if (st2.section === "mcp_servers" && st2.inList) flushMcp();
|
|
119480
|
+
st2.inList = false;
|
|
119481
|
+
st2.section = secMatch[1];
|
|
119482
|
+
continue;
|
|
119483
|
+
}
|
|
119484
|
+
if (st2.section === "agents" || st2.section === "mcp_servers") {
|
|
119485
|
+
const listStart = trimmed.match(/^-\s+(\w+):\s*(.*)$/);
|
|
119486
|
+
if (listStart) {
|
|
119487
|
+
if (st2.inList) {
|
|
119488
|
+
st2.section === "agents" ? flushAgent() : flushMcp();
|
|
119489
|
+
}
|
|
119490
|
+
st2.inList = true;
|
|
119491
|
+
st2.item = { [listStart[1]]: parseYamlValue(listStart[2]) };
|
|
119492
|
+
continue;
|
|
119493
|
+
}
|
|
119494
|
+
if (st2.inList) {
|
|
119495
|
+
const kv = trimmed.match(/^(\w+):\s*(.*)$/);
|
|
119496
|
+
if (kv) {
|
|
119497
|
+
st2.item[kv[1]] = parseYamlValue(kv[2]);
|
|
119498
|
+
continue;
|
|
119499
|
+
}
|
|
119500
|
+
}
|
|
119501
|
+
}
|
|
119502
|
+
if (st2.section === "models") {
|
|
119503
|
+
if (!result.models) result.models = {};
|
|
119504
|
+
const kv = trimmed.match(/^(\w+):\s*(.*)$/);
|
|
119505
|
+
if (kv) {
|
|
119506
|
+
const val = parseYamlValue(kv[2]);
|
|
119507
|
+
if (kv[1] === "minimum") result.models = { ...result.models, minimum: val };
|
|
119508
|
+
else if (kv[1] === "capabilities") {
|
|
119509
|
+
const arr = val.match(/^\[(.+)]$/);
|
|
119510
|
+
if (arr) result.models = { ...result.models, capabilities: arr[1].split(",").map((s70) => parseYamlValue(s70.trim())) };
|
|
119511
|
+
}
|
|
119512
|
+
}
|
|
119513
|
+
const li = trimmed.match(/^-\s+(.+)$/);
|
|
119514
|
+
if (li && result.models) {
|
|
119515
|
+
const caps = result.models.capabilities || [];
|
|
119516
|
+
result.models = { ...result.models, capabilities: [...caps, parseYamlValue(li[1])] };
|
|
119517
|
+
}
|
|
119518
|
+
}
|
|
119519
|
+
}
|
|
119520
|
+
if (st2.section === "agents" && st2.inList) flushAgent();
|
|
119521
|
+
if (st2.section === "mcp_servers" && st2.inList) flushMcp();
|
|
119522
|
+
if (!result.agents && !result.mcpServers && !result.models) return null;
|
|
119523
|
+
return result;
|
|
119524
|
+
}
|
|
119525
|
+
function extractAgentName(content) {
|
|
119526
|
+
const fm = extractFrontmatter(content);
|
|
119527
|
+
if (!fm) return null;
|
|
119528
|
+
for (const line of fm.split("\n")) {
|
|
119529
|
+
const m74 = line.match(/^name:\s*(.+)$/);
|
|
119530
|
+
if (m74) return parseYamlValue(m74[1]);
|
|
119531
|
+
}
|
|
119532
|
+
return null;
|
|
119533
|
+
}
|
|
119534
|
+
function buildDependencyGraph(agentsDir) {
|
|
119535
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
119536
|
+
const warnings = [];
|
|
119537
|
+
if (!existsSync12(agentsDir)) {
|
|
119538
|
+
warnings.push(`Agents directory not found: ${agentsDir}`);
|
|
119539
|
+
return { nodes, spawnOrder: [], cycles: [], warnings };
|
|
119540
|
+
}
|
|
119541
|
+
const files = readdirSync7(agentsDir).filter((f74) => f74.startsWith("qe-") && f74.endsWith(".md"));
|
|
119542
|
+
for (const file of files) {
|
|
119543
|
+
let content;
|
|
119544
|
+
try {
|
|
119545
|
+
content = readFileSync10(join17(agentsDir, file), "utf-8");
|
|
119546
|
+
} catch {
|
|
119547
|
+
warnings.push(`Failed to read agent file: ${file}`);
|
|
119548
|
+
continue;
|
|
119549
|
+
}
|
|
119550
|
+
const agentName = extractAgentName(content) || basename3(file, ".md");
|
|
119551
|
+
const deps = parseDependenciesFromFrontmatter(content);
|
|
119552
|
+
const hardDeps = [], softDeps = [], peerDeps = [];
|
|
119553
|
+
if (deps?.agents) {
|
|
119554
|
+
for (const dep of deps.agents) {
|
|
119555
|
+
if (dep.type === "hard") hardDeps.push(dep.name);
|
|
119556
|
+
else if (dep.type === "soft") softDeps.push(dep.name);
|
|
119557
|
+
else if (dep.type === "peer") peerDeps.push(dep.name);
|
|
119558
|
+
}
|
|
119559
|
+
}
|
|
119560
|
+
nodes.set(agentName, { agentName, hardDeps, softDeps, peerDeps, dependencies: deps || {} });
|
|
119561
|
+
}
|
|
119562
|
+
const allNames = new Set(nodes.keys());
|
|
119563
|
+
for (const [name, node] of nodes) {
|
|
119564
|
+
for (const dep of node.hardDeps) {
|
|
119565
|
+
if (!allNames.has(dep)) {
|
|
119566
|
+
warnings.push(`Agent "${name}" declares hard dependency on "${dep}" which is not in the agent directory`);
|
|
119567
|
+
}
|
|
119568
|
+
}
|
|
119569
|
+
}
|
|
119570
|
+
const cycles = detectCycles(nodes);
|
|
119571
|
+
for (const cycle of cycles) warnings.push(`Dependency cycle detected: ${cycle.join(" -> ")}`);
|
|
119572
|
+
return { nodes, spawnOrder: topologicalSort(nodes, cycles), cycles, warnings };
|
|
119573
|
+
}
|
|
119574
|
+
function detectCycles(nodes) {
|
|
119575
|
+
const cycles = [];
|
|
119576
|
+
const visited = /* @__PURE__ */ new Set();
|
|
119577
|
+
const stack = /* @__PURE__ */ new Set();
|
|
119578
|
+
const path31 = [];
|
|
119579
|
+
function dfs(name) {
|
|
119580
|
+
visited.add(name);
|
|
119581
|
+
stack.add(name);
|
|
119582
|
+
path31.push(name);
|
|
119583
|
+
const node = nodes.get(name);
|
|
119584
|
+
if (node) {
|
|
119585
|
+
for (const dep of node.hardDeps) {
|
|
119586
|
+
if (!visited.has(dep) && nodes.has(dep)) dfs(dep);
|
|
119587
|
+
else if (stack.has(dep)) {
|
|
119588
|
+
const start = path31.indexOf(dep);
|
|
119589
|
+
if (start !== -1) cycles.push([...path31.slice(start), dep]);
|
|
119590
|
+
}
|
|
119591
|
+
}
|
|
119592
|
+
}
|
|
119593
|
+
path31.pop();
|
|
119594
|
+
stack.delete(name);
|
|
119595
|
+
}
|
|
119596
|
+
for (const name of nodes.keys()) {
|
|
119597
|
+
if (!visited.has(name)) dfs(name);
|
|
119598
|
+
}
|
|
119599
|
+
return cycles;
|
|
119600
|
+
}
|
|
119601
|
+
function topologicalSort(nodes, cycles) {
|
|
119602
|
+
const cycleAgents = new Set(cycles.flat());
|
|
119603
|
+
const sorted = [];
|
|
119604
|
+
const visited = /* @__PURE__ */ new Set();
|
|
119605
|
+
const temp = /* @__PURE__ */ new Set();
|
|
119606
|
+
function visit(name) {
|
|
119607
|
+
if (visited.has(name) || cycleAgents.has(name) || temp.has(name)) return;
|
|
119608
|
+
temp.add(name);
|
|
119609
|
+
const node = nodes.get(name);
|
|
119610
|
+
if (node) {
|
|
119611
|
+
for (const dep of node.hardDeps) {
|
|
119612
|
+
if (nodes.has(dep)) visit(dep);
|
|
119613
|
+
}
|
|
119614
|
+
}
|
|
119615
|
+
temp.delete(name);
|
|
119616
|
+
visited.add(name);
|
|
119617
|
+
sorted.push(name);
|
|
119618
|
+
}
|
|
119619
|
+
for (const name of nodes.keys()) visit(name);
|
|
119620
|
+
for (const agent of cycleAgents) {
|
|
119621
|
+
if (!sorted.includes(agent)) sorted.push(agent);
|
|
119622
|
+
}
|
|
119623
|
+
return sorted;
|
|
119624
|
+
}
|
|
119625
|
+
function createSpawnPlan(agentNames, graph) {
|
|
119626
|
+
const requested = new Set(agentNames);
|
|
119627
|
+
const warnings = [];
|
|
119628
|
+
const unsatisfiedHardDeps = [];
|
|
119629
|
+
for (const name of agentNames) {
|
|
119630
|
+
const node = graph.nodes.get(name);
|
|
119631
|
+
if (!node) continue;
|
|
119632
|
+
const missing = node.hardDeps.filter((d74) => !requested.has(d74));
|
|
119633
|
+
if (missing.length > 0) {
|
|
119634
|
+
unsatisfiedHardDeps.push({ agent: name, missing });
|
|
119635
|
+
warnings.push(`Advisory: "${name}" has unsatisfied hard dependencies: ${missing.join(", ")}. Proceeding anyway.`);
|
|
119636
|
+
}
|
|
119637
|
+
}
|
|
119638
|
+
const phases = [];
|
|
119639
|
+
const placed = /* @__PURE__ */ new Set();
|
|
119640
|
+
let remaining = new Set(agentNames);
|
|
119641
|
+
while (remaining.size > 0) {
|
|
119642
|
+
const phase = [];
|
|
119643
|
+
for (const name of remaining) {
|
|
119644
|
+
const node = graph.nodes.get(name);
|
|
119645
|
+
if (!node) {
|
|
119646
|
+
phase.push(name);
|
|
119647
|
+
continue;
|
|
119648
|
+
}
|
|
119649
|
+
const inScopeHard = node.hardDeps.filter((d74) => requested.has(d74));
|
|
119650
|
+
if (inScopeHard.every((d74) => placed.has(d74))) phase.push(name);
|
|
119651
|
+
}
|
|
119652
|
+
if (phase.length === 0) {
|
|
119653
|
+
warnings.push(`Could not resolve dependency ordering for: ${[...remaining].join(", ")}. Placing in final phase.`);
|
|
119654
|
+
phases.push([...remaining]);
|
|
119655
|
+
break;
|
|
119656
|
+
}
|
|
119657
|
+
phases.push(phase);
|
|
119658
|
+
for (const a37 of phase) {
|
|
119659
|
+
placed.add(a37);
|
|
119660
|
+
remaining.delete(a37);
|
|
119661
|
+
}
|
|
119662
|
+
remaining = /* @__PURE__ */ new Set([...remaining]);
|
|
119663
|
+
}
|
|
119664
|
+
return { phases, unsatisfiedHardDeps, warnings };
|
|
119665
|
+
}
|
|
119666
|
+
var init_agent_dependency_graph = __esm({
|
|
119667
|
+
"src/routing/agent-dependency-graph.ts"() {
|
|
119668
|
+
"use strict";
|
|
119669
|
+
}
|
|
119670
|
+
});
|
|
119671
|
+
|
|
119097
119672
|
// src/coordination/agent-teams/types.ts
|
|
119098
119673
|
var DEFAULT_AGENT_TEAMS_CONFIG;
|
|
119099
119674
|
var init_types9 = __esm({
|
|
@@ -123757,8 +124332,8 @@ var init_cross_phase_memory = __esm({
|
|
|
123757
124332
|
});
|
|
123758
124333
|
|
|
123759
124334
|
// src/hooks/cross-phase-hooks.ts
|
|
123760
|
-
import { readFileSync as
|
|
123761
|
-
import { join as
|
|
124335
|
+
import { readFileSync as readFileSync11, existsSync as existsSync13 } from "fs";
|
|
124336
|
+
import { join as join18 } from "path";
|
|
123762
124337
|
import { parse as parseYaml } from "yaml";
|
|
123763
124338
|
function getCrossPhaseHookExecutor(configPath) {
|
|
123764
124339
|
if (!executor) {
|
|
@@ -123777,19 +124352,19 @@ var init_cross_phase_hooks = __esm({
|
|
|
123777
124352
|
configPath;
|
|
123778
124353
|
listeners = /* @__PURE__ */ new Map();
|
|
123779
124354
|
constructor(configPath) {
|
|
123780
|
-
this.configPath = configPath ||
|
|
124355
|
+
this.configPath = configPath || join18(process.cwd(), ".claude/hooks/cross-phase-memory.yaml");
|
|
123781
124356
|
this.memory = getCrossPhaseMemory();
|
|
123782
124357
|
}
|
|
123783
124358
|
// ---------------------------------------------------------------------------
|
|
123784
124359
|
// Initialization
|
|
123785
124360
|
// ---------------------------------------------------------------------------
|
|
123786
124361
|
async initialize() {
|
|
123787
|
-
if (!
|
|
124362
|
+
if (!existsSync13(this.configPath)) {
|
|
123788
124363
|
console.warn(`[CrossPhaseHooks] Config not found: ${this.configPath}`);
|
|
123789
124364
|
return false;
|
|
123790
124365
|
}
|
|
123791
124366
|
try {
|
|
123792
|
-
const content =
|
|
124367
|
+
const content = readFileSync11(this.configPath, "utf-8");
|
|
123793
124368
|
this.config = parseYaml(content);
|
|
123794
124369
|
if (!this.config.enabled) {
|
|
123795
124370
|
console.log("[CrossPhaseHooks] Hooks disabled in config");
|
|
@@ -124620,6 +125195,17 @@ async function handleTaskCompletionCallback(ctx, result) {
|
|
|
124620
125195
|
ctx.auditLogger.logFail(result.taskId, execution.assignedAgents[0], result.error || "Unknown error");
|
|
124621
125196
|
}
|
|
124622
125197
|
ctx.runningTaskCounter = Math.max(0, ctx.runningTaskCounter - 1);
|
|
125198
|
+
if (ctx.coExecutionRepo && execution.assignedAgents.length >= 2) {
|
|
125199
|
+
try {
|
|
125200
|
+
ctx.coExecutionRepo.recordSwarmCoExecution(
|
|
125201
|
+
execution.assignedAgents,
|
|
125202
|
+
execution.assignedDomain || "unknown",
|
|
125203
|
+
result.success,
|
|
125204
|
+
execution.task.type
|
|
125205
|
+
);
|
|
125206
|
+
} catch {
|
|
125207
|
+
}
|
|
125208
|
+
}
|
|
124623
125209
|
for (const agentId of execution.assignedAgents) {
|
|
124624
125210
|
await ctx.agentCoordinator.stop(agentId);
|
|
124625
125211
|
}
|
|
@@ -124851,6 +125437,9 @@ var init_queen_coordinator = __esm({
|
|
|
124851
125437
|
init_queen_integration();
|
|
124852
125438
|
init_shared_singleton();
|
|
124853
125439
|
init_queen_integration2();
|
|
125440
|
+
init_co_execution_repository();
|
|
125441
|
+
init_agent_mcp_validator();
|
|
125442
|
+
init_agent_dependency_graph();
|
|
124854
125443
|
init_governance();
|
|
124855
125444
|
init_agent_teams();
|
|
124856
125445
|
init_domain_team_manager();
|
|
@@ -124936,6 +125525,10 @@ var init_queen_coordinator = __esm({
|
|
|
124936
125525
|
hypothesisManager = null;
|
|
124937
125526
|
federationMailbox = null;
|
|
124938
125527
|
dynamicScaler = null;
|
|
125528
|
+
// Issue #342: Dependency intelligence
|
|
125529
|
+
coExecutionRepo = null;
|
|
125530
|
+
dependencyGraph = null;
|
|
125531
|
+
availableMcpServers = [];
|
|
124939
125532
|
// ============================================================================
|
|
124940
125533
|
// Lifecycle
|
|
124941
125534
|
// ============================================================================
|
|
@@ -124976,6 +125569,28 @@ var init_queen_coordinator = __esm({
|
|
|
124976
125569
|
logger10.warn("Governance initialization failed (continuing)", { error: govError });
|
|
124977
125570
|
}
|
|
124978
125571
|
this.initializeSubsystems();
|
|
125572
|
+
try {
|
|
125573
|
+
const { join: join41 } = await import("path");
|
|
125574
|
+
const agentsDir = join41(process.cwd(), ".claude", "agents", "v3");
|
|
125575
|
+
this.dependencyGraph = buildDependencyGraph(agentsDir);
|
|
125576
|
+
this.availableMcpServers = getAvailableMcpServers(process.cwd());
|
|
125577
|
+
const { getUnifiedMemory: getUnifiedMemory2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
|
|
125578
|
+
const unifiedMemory = getUnifiedMemory2();
|
|
125579
|
+
await unifiedMemory.initialize();
|
|
125580
|
+
this.coExecutionRepo = getCoExecutionRepository();
|
|
125581
|
+
this.coExecutionRepo.initialize(unifiedMemory.getDatabase());
|
|
125582
|
+
if (this.dependencyGraph.warnings.length > 0) {
|
|
125583
|
+
logger10.warn(`Dependency graph: ${this.dependencyGraph.warnings.length} warning(s)`, {
|
|
125584
|
+
warnings: this.dependencyGraph.warnings.slice(0, 5)
|
|
125585
|
+
});
|
|
125586
|
+
}
|
|
125587
|
+
logger10.info("Dependency intelligence initialized", {
|
|
125588
|
+
agents: this.dependencyGraph.nodes.size,
|
|
125589
|
+
mcpServers: this.availableMcpServers.length
|
|
125590
|
+
});
|
|
125591
|
+
} catch (depError) {
|
|
125592
|
+
logger10.warn("Dependency intelligence initialization failed (continuing)", { error: depError });
|
|
125593
|
+
}
|
|
124979
125594
|
await this.publishEvent("QueenInitialized", {
|
|
124980
125595
|
timestamp: /* @__PURE__ */ new Date(),
|
|
124981
125596
|
config: this.config,
|
|
@@ -125154,6 +125769,23 @@ var init_queen_coordinator = __esm({
|
|
|
125154
125769
|
return ALL_DOMAINS.filter((domain) => this.getDomainLoad(domain) > this.config.workStealing.loadThreshold);
|
|
125155
125770
|
}
|
|
125156
125771
|
// ============================================================================
|
|
125772
|
+
// Issue #342 Item 2: Dependency-Aware Spawn Planning
|
|
125773
|
+
// ============================================================================
|
|
125774
|
+
/**
|
|
125775
|
+
* Get a phased spawn plan that respects hard agent dependencies.
|
|
125776
|
+
* Use this when spawning multiple agents for a swarm task.
|
|
125777
|
+
*/
|
|
125778
|
+
getSpawnPlan(agentNames) {
|
|
125779
|
+
if (!this.dependencyGraph) return { phases: [agentNames], warnings: [], unsatisfiedHardDeps: [] };
|
|
125780
|
+
return createSpawnPlan(agentNames, this.dependencyGraph);
|
|
125781
|
+
}
|
|
125782
|
+
/**
|
|
125783
|
+
* Get the dependency graph for the agent fleet.
|
|
125784
|
+
*/
|
|
125785
|
+
getDependencyGraph() {
|
|
125786
|
+
return this.dependencyGraph;
|
|
125787
|
+
}
|
|
125788
|
+
// ============================================================================
|
|
125157
125789
|
// Work Stealing
|
|
125158
125790
|
// ============================================================================
|
|
125159
125791
|
enableWorkStealing() {
|
|
@@ -125187,6 +125819,24 @@ var init_queen_coordinator = __esm({
|
|
|
125187
125819
|
if (!this.agentCoordinator.canSpawn()) {
|
|
125188
125820
|
return err(new Error("Maximum concurrent agents reached (15)"));
|
|
125189
125821
|
}
|
|
125822
|
+
if (this.dependencyGraph && this.availableMcpServers.length > 0) {
|
|
125823
|
+
try {
|
|
125824
|
+
for (const [, node] of this.dependencyGraph.nodes) {
|
|
125825
|
+
const mcpDeps = node.dependencies.mcpServers;
|
|
125826
|
+
if (!mcpDeps || mcpDeps.length === 0) continue;
|
|
125827
|
+
const missing = mcpDeps.filter((s70) => s70.required && !this.availableMcpServers.includes(s70.name));
|
|
125828
|
+
if (missing.length > 0) {
|
|
125829
|
+
logger10.warn(`Pre-spawn MCP advisory: ${node.agentName} needs ${missing.map((m74) => m74.name).join(", ")}`, {
|
|
125830
|
+
agent: node.agentName,
|
|
125831
|
+
domain,
|
|
125832
|
+
missing: missing.map((m74) => m74.name)
|
|
125833
|
+
});
|
|
125834
|
+
break;
|
|
125835
|
+
}
|
|
125836
|
+
}
|
|
125837
|
+
} catch {
|
|
125838
|
+
}
|
|
125839
|
+
}
|
|
125190
125840
|
const result = await this.agentCoordinator.spawn({
|
|
125191
125841
|
name: `${domain}-${type}-${Date.now()}`,
|
|
125192
125842
|
domain,
|
|
@@ -125596,6 +126246,9 @@ var init_queen_coordinator = __esm({
|
|
|
125596
126246
|
return self.traceCollector;
|
|
125597
126247
|
},
|
|
125598
126248
|
taskTraceContexts: self.taskTraceContexts,
|
|
126249
|
+
get coExecutionRepo() {
|
|
126250
|
+
return self.coExecutionRepo;
|
|
126251
|
+
},
|
|
125599
126252
|
requestAgentSpawn: (d74, t50, c70) => self.requestAgentSpawn(d74, t50, c70),
|
|
125600
126253
|
publishEvent: (t50, p74) => self.publishEvent(t50, p74),
|
|
125601
126254
|
getDomainLoad: (d74) => self.getDomainLoad(d74),
|
|
@@ -127072,8 +127725,8 @@ var init_transforms = __esm({
|
|
|
127072
127725
|
});
|
|
127073
127726
|
|
|
127074
127727
|
// src/integrations/agentic-flow/pattern-loader.ts
|
|
127075
|
-
import { existsSync as
|
|
127076
|
-
import { join as
|
|
127728
|
+
import { existsSync as existsSync14, readFileSync as readFileSync12 } from "node:fs";
|
|
127729
|
+
import { join as join20, dirname as dirname3 } from "node:path";
|
|
127077
127730
|
import { fileURLToPath } from "node:url";
|
|
127078
127731
|
function getPatternLoader() {
|
|
127079
127732
|
return PatternLoader.getInstance();
|
|
@@ -127139,10 +127792,10 @@ var init_pattern_loader = __esm({
|
|
|
127139
127792
|
const currentFileUrl = import.meta.url;
|
|
127140
127793
|
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
127141
127794
|
const currentDir = dirname3(currentFilePath);
|
|
127142
|
-
const projectRoot =
|
|
127143
|
-
return
|
|
127795
|
+
const projectRoot = join20(currentDir, "..", "..", "..");
|
|
127796
|
+
return join20(projectRoot, "assets", "patterns");
|
|
127144
127797
|
} catch {
|
|
127145
|
-
return
|
|
127798
|
+
return join20(process.cwd(), "assets", "patterns");
|
|
127146
127799
|
}
|
|
127147
127800
|
}
|
|
127148
127801
|
/**
|
|
@@ -127188,9 +127841,9 @@ var init_pattern_loader = __esm({
|
|
|
127188
127841
|
* Load a JSON file from the patterns directory
|
|
127189
127842
|
*/
|
|
127190
127843
|
loadJsonFile(filename) {
|
|
127191
|
-
const filePath =
|
|
127844
|
+
const filePath = join20(this.config.basePath, filename);
|
|
127192
127845
|
try {
|
|
127193
|
-
if (!
|
|
127846
|
+
if (!existsSync14(filePath)) {
|
|
127194
127847
|
const errorMsg = `Pattern file not found: ${filePath}`;
|
|
127195
127848
|
this.patterns.errors.push(errorMsg);
|
|
127196
127849
|
if (this.config.throwOnMissing) {
|
|
@@ -127198,7 +127851,7 @@ var init_pattern_loader = __esm({
|
|
|
127198
127851
|
}
|
|
127199
127852
|
return null;
|
|
127200
127853
|
}
|
|
127201
|
-
const content =
|
|
127854
|
+
const content = readFileSync12(filePath, "utf-8");
|
|
127202
127855
|
return safeJsonParse(content);
|
|
127203
127856
|
} catch (error) {
|
|
127204
127857
|
if (error instanceof PatternLoaderError) {
|
|
@@ -128540,6 +129193,22 @@ var init_sqlite_persistence = __esm({
|
|
|
128540
129193
|
FOREIGN KEY (pattern_id) REFERENCES qe_patterns(id) ON DELETE CASCADE
|
|
128541
129194
|
);
|
|
128542
129195
|
|
|
129196
|
+
-- Agent co-execution tracking (Issue #342 Item 3)
|
|
129197
|
+
CREATE TABLE IF NOT EXISTS qe_agent_co_execution (
|
|
129198
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
129199
|
+
agent_a TEXT NOT NULL,
|
|
129200
|
+
agent_b TEXT NOT NULL,
|
|
129201
|
+
domain TEXT NOT NULL,
|
|
129202
|
+
success INTEGER NOT NULL DEFAULT 0,
|
|
129203
|
+
task_description TEXT,
|
|
129204
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
129205
|
+
);
|
|
129206
|
+
|
|
129207
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_agents
|
|
129208
|
+
ON qe_agent_co_execution(agent_a, agent_b);
|
|
129209
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_domain
|
|
129210
|
+
ON qe_agent_co_execution(domain);
|
|
129211
|
+
|
|
128543
129212
|
-- Unique constraint to prevent duplicate patterns
|
|
128544
129213
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_patterns_unique_name_domain_type
|
|
128545
129214
|
ON qe_patterns(name, qe_domain, pattern_type);
|
|
@@ -138032,8 +138701,8 @@ var init_qe_agent_registry = __esm({
|
|
|
138032
138701
|
});
|
|
138033
138702
|
|
|
138034
138703
|
// src/context/sources/memory-source.ts
|
|
138035
|
-
import { existsSync as
|
|
138036
|
-
import { join as
|
|
138704
|
+
import { existsSync as existsSync15 } from "fs";
|
|
138705
|
+
import { join as join21 } from "path";
|
|
138037
138706
|
var MemoryContextSource;
|
|
138038
138707
|
var init_memory_source = __esm({
|
|
138039
138708
|
"src/context/sources/memory-source.ts"() {
|
|
@@ -138046,12 +138715,12 @@ var init_memory_source = __esm({
|
|
|
138046
138715
|
async gather(request) {
|
|
138047
138716
|
const fragments = [];
|
|
138048
138717
|
try {
|
|
138049
|
-
const dbPath =
|
|
138050
|
-
if (!
|
|
138718
|
+
const dbPath = join21(process.cwd(), ".agentic-qe", "memory.db");
|
|
138719
|
+
if (!existsSync15(dbPath)) {
|
|
138051
138720
|
return this.fallbackGather(request);
|
|
138052
138721
|
}
|
|
138053
|
-
const
|
|
138054
|
-
const db =
|
|
138722
|
+
const { openDatabase: openDatabase2 } = await Promise.resolve().then(() => (init_safe_db(), safe_db_exports));
|
|
138723
|
+
const db = openDatabase2(dbPath, { readonly: true });
|
|
138055
138724
|
try {
|
|
138056
138725
|
const domainKeywords = this.extractDomainKeywords(request.taskDescription);
|
|
138057
138726
|
if (domainKeywords.length > 0) {
|
|
@@ -138166,8 +138835,8 @@ ${log}`;
|
|
|
138166
138835
|
});
|
|
138167
138836
|
|
|
138168
138837
|
// src/context/sources/test-source.ts
|
|
138169
|
-
import { existsSync as
|
|
138170
|
-
import { basename as
|
|
138838
|
+
import { existsSync as existsSync16, readFileSync as readFileSync13 } from "fs";
|
|
138839
|
+
import { basename as basename4, dirname as dirname4, join as join22 } from "path";
|
|
138171
138840
|
var TestContextSource;
|
|
138172
138841
|
var init_test_source = __esm({
|
|
138173
138842
|
"src/context/sources/test-source.ts"() {
|
|
@@ -138182,16 +138851,16 @@ var init_test_source = __esm({
|
|
|
138182
138851
|
for (const file of request.targetFiles.slice(0, 3)) {
|
|
138183
138852
|
const testPaths = this.findTestPaths(file);
|
|
138184
138853
|
for (const testPath of testPaths) {
|
|
138185
|
-
if (
|
|
138854
|
+
if (existsSync16(testPath)) {
|
|
138186
138855
|
try {
|
|
138187
|
-
const content =
|
|
138856
|
+
const content = readFileSync13(testPath, "utf-8");
|
|
138188
138857
|
const testNames = content.match(/(?:it|test|describe)\s*\(\s*['"`]([^'"`]+)['"`]/g) || [];
|
|
138189
138858
|
if (testNames.length > 0) {
|
|
138190
|
-
const summary = `Tests for ${
|
|
138859
|
+
const summary = `Tests for ${basename4(file)} (${testPath}):
|
|
138191
138860
|
${testNames.join("\n")}`;
|
|
138192
138861
|
fragments.push({
|
|
138193
138862
|
sourceId: this.id,
|
|
138194
|
-
title: `Tests: ${
|
|
138863
|
+
title: `Tests: ${basename4(file)}`,
|
|
138195
138864
|
content: summary,
|
|
138196
138865
|
estimatedTokens: Math.ceil(summary.length / 3.5),
|
|
138197
138866
|
relevance: 0.8
|
|
@@ -138205,14 +138874,14 @@ ${testNames.join("\n")}`;
|
|
|
138205
138874
|
return fragments;
|
|
138206
138875
|
}
|
|
138207
138876
|
findTestPaths(filePath) {
|
|
138208
|
-
const base =
|
|
138877
|
+
const base = basename4(filePath).replace(/\.(ts|js|tsx|jsx)$/, "");
|
|
138209
138878
|
const dir = dirname4(filePath);
|
|
138210
138879
|
const extensions = [".test.ts", ".spec.ts", ".test.js", ".spec.js"];
|
|
138211
138880
|
const paths = [];
|
|
138212
138881
|
for (const ext of extensions) {
|
|
138213
|
-
paths.push(
|
|
138214
|
-
paths.push(
|
|
138215
|
-
paths.push(
|
|
138882
|
+
paths.push(join22(dir, `${base}${ext}`));
|
|
138883
|
+
paths.push(join22(dir, "__tests__", `${base}${ext}`));
|
|
138884
|
+
paths.push(join22(dir, "..", "tests", `${base}${ext}`));
|
|
138216
138885
|
}
|
|
138217
138886
|
return paths;
|
|
138218
138887
|
}
|
|
@@ -138221,8 +138890,8 @@ ${testNames.join("\n")}`;
|
|
|
138221
138890
|
});
|
|
138222
138891
|
|
|
138223
138892
|
// src/context/sources/coverage-source.ts
|
|
138224
|
-
import { existsSync as
|
|
138225
|
-
import { join as
|
|
138893
|
+
import { existsSync as existsSync17, readFileSync as readFileSync14 } from "fs";
|
|
138894
|
+
import { join as join23, basename as basename5 } from "path";
|
|
138226
138895
|
var CoverageContextSource;
|
|
138227
138896
|
var init_coverage_source = __esm({
|
|
138228
138897
|
"src/context/sources/coverage-source.ts"() {
|
|
@@ -138235,18 +138904,18 @@ var init_coverage_source = __esm({
|
|
|
138235
138904
|
async gather(request) {
|
|
138236
138905
|
const fragments = [];
|
|
138237
138906
|
const coveragePaths = [
|
|
138238
|
-
|
|
138239
|
-
|
|
138240
|
-
|
|
138907
|
+
join23(process.cwd(), "coverage", "coverage-summary.json"),
|
|
138908
|
+
join23(process.cwd(), "coverage", "coverage-final.json"),
|
|
138909
|
+
join23(process.cwd(), ".coverage", "coverage-summary.json")
|
|
138241
138910
|
];
|
|
138242
138911
|
for (const coveragePath of coveragePaths) {
|
|
138243
|
-
if (!
|
|
138912
|
+
if (!existsSync17(coveragePath)) continue;
|
|
138244
138913
|
try {
|
|
138245
|
-
const raw =
|
|
138914
|
+
const raw = readFileSync14(coveragePath, "utf-8");
|
|
138246
138915
|
const data = JSON.parse(raw);
|
|
138247
138916
|
const targetCoverage = [];
|
|
138248
138917
|
for (const targetFile of request.targetFiles) {
|
|
138249
|
-
const fileName =
|
|
138918
|
+
const fileName = basename5(targetFile);
|
|
138250
138919
|
for (const [filePath, metrics] of Object.entries(data)) {
|
|
138251
138920
|
if (filePath.includes(fileName) && metrics && typeof metrics === "object") {
|
|
138252
138921
|
const m74 = metrics;
|
|
@@ -138295,8 +138964,8 @@ ${targetCoverage.join("\n")}`;
|
|
|
138295
138964
|
});
|
|
138296
138965
|
|
|
138297
138966
|
// src/context/sources/requirements-source.ts
|
|
138298
|
-
import { existsSync as
|
|
138299
|
-
import { join as
|
|
138967
|
+
import { existsSync as existsSync18 } from "fs";
|
|
138968
|
+
import { join as join24 } from "path";
|
|
138300
138969
|
var RequirementsContextSource;
|
|
138301
138970
|
var init_requirements_source = __esm({
|
|
138302
138971
|
"src/context/sources/requirements-source.ts"() {
|
|
@@ -138309,12 +138978,12 @@ var init_requirements_source = __esm({
|
|
|
138309
138978
|
async gather(request) {
|
|
138310
138979
|
const fragments = [];
|
|
138311
138980
|
try {
|
|
138312
|
-
const dbPath =
|
|
138313
|
-
if (!
|
|
138981
|
+
const dbPath = join24(process.cwd(), ".agentic-qe", "memory.db");
|
|
138982
|
+
if (!existsSync18(dbPath)) {
|
|
138314
138983
|
return this.fallbackGather(request);
|
|
138315
138984
|
}
|
|
138316
|
-
const
|
|
138317
|
-
const db =
|
|
138985
|
+
const { openDatabase: openDatabase2 } = await Promise.resolve().then(() => (init_safe_db(), safe_db_exports));
|
|
138986
|
+
const db = openDatabase2(dbPath, { readonly: true });
|
|
138318
138987
|
try {
|
|
138319
138988
|
const tableCheck = db.prepare(
|
|
138320
138989
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='qe_patterns'"
|
|
@@ -138433,8 +139102,8 @@ ${content}`,
|
|
|
138433
139102
|
});
|
|
138434
139103
|
|
|
138435
139104
|
// src/context/sources/defect-source.ts
|
|
138436
|
-
import { existsSync as
|
|
138437
|
-
import { join as
|
|
139105
|
+
import { existsSync as existsSync19 } from "fs";
|
|
139106
|
+
import { join as join25 } from "path";
|
|
138438
139107
|
var DefectContextSource;
|
|
138439
139108
|
var init_defect_source = __esm({
|
|
138440
139109
|
"src/context/sources/defect-source.ts"() {
|
|
@@ -138447,12 +139116,12 @@ var init_defect_source = __esm({
|
|
|
138447
139116
|
async gather(request) {
|
|
138448
139117
|
const fragments = [];
|
|
138449
139118
|
try {
|
|
138450
|
-
const dbPath =
|
|
138451
|
-
if (!
|
|
139119
|
+
const dbPath = join25(process.cwd(), ".agentic-qe", "memory.db");
|
|
139120
|
+
if (!existsSync19(dbPath)) {
|
|
138452
139121
|
return [];
|
|
138453
139122
|
}
|
|
138454
|
-
const
|
|
138455
|
-
const db =
|
|
139123
|
+
const { openDatabase: openDatabase2 } = await Promise.resolve().then(() => (init_safe_db(), safe_db_exports));
|
|
139124
|
+
const db = openDatabase2(dbPath, { readonly: true });
|
|
138456
139125
|
try {
|
|
138457
139126
|
const tableCheck = db.prepare(
|
|
138458
139127
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='qe_patterns'"
|
|
@@ -140663,17 +141332,19 @@ function createTaskExecutor(kernel, config) {
|
|
|
140663
141332
|
}
|
|
140664
141333
|
async function resetServiceCaches() {
|
|
140665
141334
|
}
|
|
140666
|
-
var DomainTaskExecutor;
|
|
141335
|
+
var logger13, DomainTaskExecutor;
|
|
140667
141336
|
var init_task_executor = __esm({
|
|
140668
141337
|
"src/coordination/task-executor.ts"() {
|
|
140669
141338
|
"use strict";
|
|
140670
141339
|
init_esm_node();
|
|
140671
141340
|
init_error_utils();
|
|
140672
141341
|
init_result_saver();
|
|
141342
|
+
init_logger_factory();
|
|
140673
141343
|
init_agent_booster();
|
|
140674
141344
|
init_task_router();
|
|
140675
141345
|
init_domain_service_registry();
|
|
140676
141346
|
init_handlers();
|
|
141347
|
+
logger13 = createLogger("TaskExecutor");
|
|
140677
141348
|
DomainTaskExecutor = class {
|
|
140678
141349
|
constructor(kernel, eventBus, config) {
|
|
140679
141350
|
this.kernel = kernel;
|
|
@@ -140891,7 +141562,8 @@ var init_task_executor = __esm({
|
|
|
140891
141562
|
if (routingTier === 0 || useAgentBooster) {
|
|
140892
141563
|
const boosterResult = await this.executeWithAgentBooster(task, startTime, domain);
|
|
140893
141564
|
if (boosterResult) {
|
|
140894
|
-
this.recordOutcome(task, 0, true, Date.now() - startTime).catch(() => {
|
|
141565
|
+
this.recordOutcome(task, 0, true, Date.now() - startTime).catch((e20) => {
|
|
141566
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140895
141567
|
});
|
|
140896
141568
|
await this.publishTaskCompleted(task.id, boosterResult.data, domain);
|
|
140897
141569
|
return boosterResult;
|
|
@@ -140907,7 +141579,8 @@ var init_task_executor = __esm({
|
|
|
140907
141579
|
duration: Date.now() - startTime,
|
|
140908
141580
|
domain
|
|
140909
141581
|
};
|
|
140910
|
-
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch(() => {
|
|
141582
|
+
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch((e20) => {
|
|
141583
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140911
141584
|
});
|
|
140912
141585
|
return result2;
|
|
140913
141586
|
}
|
|
@@ -140918,7 +141591,8 @@ var init_task_executor = __esm({
|
|
|
140918
141591
|
if (!result.success) {
|
|
140919
141592
|
const errorMsg = "error" in result ? result.error.message : "Unknown error";
|
|
140920
141593
|
await this.publishTaskFailed(task.id, errorMsg, domain);
|
|
140921
|
-
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch(() => {
|
|
141594
|
+
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch((e20) => {
|
|
141595
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140922
141596
|
});
|
|
140923
141597
|
return {
|
|
140924
141598
|
taskId: task.id,
|
|
@@ -140929,7 +141603,8 @@ var init_task_executor = __esm({
|
|
|
140929
141603
|
};
|
|
140930
141604
|
}
|
|
140931
141605
|
await this.publishTaskCompleted(task.id, result.value, domain);
|
|
140932
|
-
this.recordOutcome(task, routingTier, true, Date.now() - startTime).catch(() => {
|
|
141606
|
+
this.recordOutcome(task, routingTier, true, Date.now() - startTime).catch((e20) => {
|
|
141607
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140933
141608
|
});
|
|
140934
141609
|
let savedFiles;
|
|
140935
141610
|
if (this._config.saveResults) {
|
|
@@ -140964,7 +141639,8 @@ var init_task_executor = __esm({
|
|
|
140964
141639
|
} catch (error) {
|
|
140965
141640
|
const errorMessage = toErrorMessage(error);
|
|
140966
141641
|
await this.publishTaskFailed(task.id, errorMessage, domain);
|
|
140967
|
-
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch(() => {
|
|
141642
|
+
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch((e20) => {
|
|
141643
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140968
141644
|
});
|
|
140969
141645
|
return {
|
|
140970
141646
|
taskId: task.id,
|
|
@@ -144385,7 +145061,7 @@ var init_pattern_store = __esm({
|
|
|
144385
145061
|
function createQEReasoningBank(memory, eventBus, config, coherenceService) {
|
|
144386
145062
|
return new QEReasoningBank(memory, eventBus, config, coherenceService);
|
|
144387
145063
|
}
|
|
144388
|
-
var
|
|
145064
|
+
var logger14, DEFAULT_QE_REASONING_BANK_CONFIG, QEReasoningBank;
|
|
144389
145065
|
var init_qe_reasoning_bank = __esm({
|
|
144390
145066
|
"src/learning/qe-reasoning-bank.ts"() {
|
|
144391
145067
|
"use strict";
|
|
@@ -144399,7 +145075,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144399
145075
|
init_witness_chain();
|
|
144400
145076
|
init_qe_patterns();
|
|
144401
145077
|
init_qe_guidance();
|
|
144402
|
-
|
|
145078
|
+
logger14 = LoggerFactory.create("QEReasoningBank");
|
|
144403
145079
|
DEFAULT_QE_REASONING_BANK_CONFIG = {
|
|
144404
145080
|
enableLearning: true,
|
|
144405
145081
|
enableGuidance: true,
|
|
@@ -144444,7 +145120,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144444
145120
|
if (!this.sqliteStore) {
|
|
144445
145121
|
this.sqliteStore = createSQLitePatternStore();
|
|
144446
145122
|
this.sqliteStore.initialize().catch((e20) => {
|
|
144447
|
-
|
|
145123
|
+
logger14.warn("SQLitePatternStore init failed", { error: toErrorMessage(e20) });
|
|
144448
145124
|
});
|
|
144449
145125
|
}
|
|
144450
145126
|
return this.sqliteStore;
|
|
@@ -144532,7 +145208,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144532
145208
|
await store.initialize();
|
|
144533
145209
|
this.patternStore.setSqliteStore(store);
|
|
144534
145210
|
} catch (e20) {
|
|
144535
|
-
|
|
145211
|
+
logger14.warn("Failed to wire SQLitePatternStore into PatternStore", { error: toErrorMessage(e20) });
|
|
144536
145212
|
}
|
|
144537
145213
|
await this.loadPretrainedPatterns();
|
|
144538
145214
|
this.initialized = true;
|
|
@@ -144544,12 +145220,12 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144544
145220
|
await this.seedCrossDomainPatterns();
|
|
144545
145221
|
} else {
|
|
144546
145222
|
const stats = await this.patternStore.getStats();
|
|
144547
|
-
|
|
145223
|
+
logger14.info("Cross-domain transfer already complete", { totalPatterns: stats.totalPatterns });
|
|
144548
145224
|
}
|
|
144549
145225
|
} catch (error) {
|
|
144550
|
-
|
|
145226
|
+
logger14.warn("Cross-domain seeding failed (non-fatal)", { error });
|
|
144551
145227
|
}
|
|
144552
|
-
|
|
145228
|
+
logger14.info("Initialized");
|
|
144553
145229
|
}
|
|
144554
145230
|
/**
|
|
144555
145231
|
* Load pre-trained patterns for common QE scenarios
|
|
@@ -144557,7 +145233,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144557
145233
|
async loadPretrainedPatterns() {
|
|
144558
145234
|
const stats = await this.patternStore.getStats();
|
|
144559
145235
|
if (stats.totalPatterns > 0) {
|
|
144560
|
-
|
|
145236
|
+
logger14.info("Found existing patterns", { totalPatterns: stats.totalPatterns });
|
|
144561
145237
|
return;
|
|
144562
145238
|
}
|
|
144563
145239
|
const foundationalPatterns = [
|
|
@@ -145275,10 +145951,10 @@ On promotion:
|
|
|
145275
145951
|
try {
|
|
145276
145952
|
await this.patternStore.create(options);
|
|
145277
145953
|
} catch (error) {
|
|
145278
|
-
|
|
145954
|
+
logger14.warn("Failed to load pattern", { name: options.name, error });
|
|
145279
145955
|
}
|
|
145280
145956
|
}
|
|
145281
|
-
|
|
145957
|
+
logger14.info("Loaded foundational patterns", { count: foundationalPatterns.length });
|
|
145282
145958
|
}
|
|
145283
145959
|
/**
|
|
145284
145960
|
* Seed cross-domain patterns by transferring generalizable patterns
|
|
@@ -145361,7 +146037,7 @@ On promotion:
|
|
|
145361
146037
|
}
|
|
145362
146038
|
}
|
|
145363
146039
|
}
|
|
145364
|
-
|
|
146040
|
+
logger14.info("Cross-domain transfer complete", { transferred, skipped });
|
|
145365
146041
|
return { transferred, skipped };
|
|
145366
146042
|
}
|
|
145367
146043
|
/**
|
|
@@ -145382,13 +146058,14 @@ On promotion:
|
|
|
145382
146058
|
}
|
|
145383
146059
|
const result = await this.patternStore.create(options);
|
|
145384
146060
|
if (result.success) {
|
|
145385
|
-
getWitnessChain().then((wc) => wc.append("PATTERN_CREATE", { patternId: result.value.id, domain: result.value.qeDomain, confidence: result.value.confidence, name: result.value.name }, "reasoning-bank")).catch(() => {
|
|
146061
|
+
getWitnessChain().then((wc) => wc.append("PATTERN_CREATE", { patternId: result.value.id, domain: result.value.qeDomain, confidence: result.value.confidence, name: result.value.name }, "reasoning-bank")).catch((e20) => {
|
|
146062
|
+
logger14.warn("Witness chain PATTERN_CREATE failed", { error: toErrorMessage(e20) });
|
|
145386
146063
|
});
|
|
145387
146064
|
if (this.rvfDualWriter && result.value.embedding && result.value.embedding.length > 0) {
|
|
145388
146065
|
try {
|
|
145389
146066
|
this.rvfDualWriter.writePattern(result.value.id, result.value.embedding);
|
|
145390
146067
|
} catch (rvfErr) {
|
|
145391
|
-
|
|
146068
|
+
logger14.warn("RVF dual-write failed (non-fatal)", { patternId: result.value.id, error: toErrorMessage(rvfErr) });
|
|
145392
146069
|
}
|
|
145393
146070
|
}
|
|
145394
146071
|
}
|
|
@@ -145452,19 +146129,20 @@ On promotion:
|
|
|
145452
146129
|
outcome.feedback
|
|
145453
146130
|
);
|
|
145454
146131
|
} catch (persistError) {
|
|
145455
|
-
|
|
146132
|
+
logger14.warn("SQLite pattern usage persist failed", { error: toErrorMessage(persistError) });
|
|
145456
146133
|
}
|
|
145457
146134
|
if (result.success) {
|
|
145458
146135
|
this.stats.learningOutcomes++;
|
|
145459
146136
|
if (outcome.success) {
|
|
145460
146137
|
this.stats.successfulOutcomes++;
|
|
145461
146138
|
}
|
|
145462
|
-
getWitnessChain().then((wc) => wc.append("PATTERN_UPDATE", { patternId: outcome.patternId, success: outcome.success }, "reasoning-bank")).catch(() => {
|
|
146139
|
+
getWitnessChain().then((wc) => wc.append("PATTERN_UPDATE", { patternId: outcome.patternId, success: outcome.success }, "reasoning-bank")).catch((e20) => {
|
|
146140
|
+
logger14.warn("Witness chain PATTERN_UPDATE failed", { error: toErrorMessage(e20) });
|
|
145463
146141
|
});
|
|
145464
146142
|
const pattern = await this.getPattern(outcome.patternId);
|
|
145465
146143
|
if (pattern && await this.checkPatternPromotionWithCoherence(pattern)) {
|
|
145466
146144
|
await this.promotePattern(outcome.patternId);
|
|
145467
|
-
|
|
146145
|
+
logger14.info("Pattern promoted to long-term", { name: pattern.name });
|
|
145468
146146
|
}
|
|
145469
146147
|
}
|
|
145470
146148
|
return result;
|
|
@@ -145511,7 +146189,7 @@ On promotion:
|
|
|
145511
146189
|
payload: event
|
|
145512
146190
|
});
|
|
145513
146191
|
}
|
|
145514
|
-
|
|
146192
|
+
logger14.info("Pattern promotion blocked due to coherence violation", {
|
|
145515
146193
|
name: pattern.name,
|
|
145516
146194
|
energy: coherenceResult.energy
|
|
145517
146195
|
});
|
|
@@ -145540,7 +146218,7 @@ On promotion:
|
|
|
145540
146218
|
try {
|
|
145541
146219
|
this.getSqliteStore().promotePattern(patternId);
|
|
145542
146220
|
} catch (e20) {
|
|
145543
|
-
|
|
146221
|
+
logger14.warn("SQLite pattern promotion persist failed", { error: toErrorMessage(e20) });
|
|
145544
146222
|
}
|
|
145545
146223
|
if (this.rvfDualWriter) {
|
|
145546
146224
|
try {
|
|
@@ -145549,12 +146227,13 @@ On promotion:
|
|
|
145549
146227
|
this.rvfDualWriter.writePattern(patternId, promoted.embedding);
|
|
145550
146228
|
}
|
|
145551
146229
|
} catch (rvfErr) {
|
|
145552
|
-
|
|
146230
|
+
logger14.warn("RVF dual-write on promote failed (non-fatal)", { patternId, error: toErrorMessage(rvfErr) });
|
|
145553
146231
|
}
|
|
145554
146232
|
}
|
|
145555
|
-
getWitnessChain().then((wc) => wc.append("PATTERN_PROMOTE", { patternId }, "reasoning-bank")).catch(() => {
|
|
146233
|
+
getWitnessChain().then((wc) => wc.append("PATTERN_PROMOTE", { patternId }, "reasoning-bank")).catch((e20) => {
|
|
146234
|
+
logger14.warn("Witness chain PATTERN_PROMOTE failed", { error: toErrorMessage(e20) });
|
|
145556
146235
|
});
|
|
145557
|
-
|
|
146236
|
+
logger14.info("Promoted pattern to long-term", { patternId });
|
|
145558
146237
|
if (this.eventBus) {
|
|
145559
146238
|
await this.eventBus.publish({
|
|
145560
146239
|
id: `pattern-promoted-${patternId}`,
|
|
@@ -145565,7 +146244,7 @@ On promotion:
|
|
|
145565
146244
|
});
|
|
145566
146245
|
}
|
|
145567
146246
|
} else {
|
|
145568
|
-
|
|
146247
|
+
logger14.error("Failed to promote pattern", result.error, { patternId });
|
|
145569
146248
|
}
|
|
145570
146249
|
}
|
|
145571
146250
|
/**
|
|
@@ -145691,7 +146370,7 @@ On promotion:
|
|
|
145691
146370
|
return embedding;
|
|
145692
146371
|
} catch (error) {
|
|
145693
146372
|
if (process.env.DEBUG) {
|
|
145694
|
-
|
|
146373
|
+
logger14.warn("ONNX embeddings unavailable, using hash fallback", {
|
|
145695
146374
|
error: toErrorMessage(error)
|
|
145696
146375
|
});
|
|
145697
146376
|
}
|
|
@@ -145813,8 +146492,8 @@ On promotion:
|
|
|
145813
146492
|
});
|
|
145814
146493
|
|
|
145815
146494
|
// src/adapters/claude-flow/detect.ts
|
|
145816
|
-
import { existsSync as
|
|
145817
|
-
import { join as
|
|
146495
|
+
import { existsSync as existsSync21, readFileSync as readFileSync16 } from "node:fs";
|
|
146496
|
+
import { join as join29 } from "node:path";
|
|
145818
146497
|
import { execSync as execSync7 } from "node:child_process";
|
|
145819
146498
|
function detectClaudeFlow(projectRoot) {
|
|
145820
146499
|
if (cachedResult && Date.now() - cacheTimestamp < CACHE_TTL_MS2) {
|
|
@@ -145835,20 +146514,20 @@ function doDetection(projectRoot) {
|
|
|
145835
146514
|
return { available: false };
|
|
145836
146515
|
}
|
|
145837
146516
|
function checkMCPConfig(projectRoot) {
|
|
145838
|
-
const mcpJsonPath =
|
|
145839
|
-
if (
|
|
146517
|
+
const mcpJsonPath = join29(projectRoot, ".claude", "mcp.json");
|
|
146518
|
+
if (existsSync21(mcpJsonPath)) {
|
|
145840
146519
|
try {
|
|
145841
|
-
const config = safeJsonParse(
|
|
146520
|
+
const config = safeJsonParse(readFileSync16(mcpJsonPath, "utf-8"));
|
|
145842
146521
|
if (config.mcpServers?.["claude-flow"]) {
|
|
145843
146522
|
return { available: true, method: "mcp-config" };
|
|
145844
146523
|
}
|
|
145845
146524
|
} catch {
|
|
145846
146525
|
}
|
|
145847
146526
|
}
|
|
145848
|
-
const settingsPath =
|
|
145849
|
-
if (
|
|
146527
|
+
const settingsPath = join29(projectRoot, ".claude", "settings.json");
|
|
146528
|
+
if (existsSync21(settingsPath)) {
|
|
145850
146529
|
try {
|
|
145851
|
-
const settings = safeJsonParse(
|
|
146530
|
+
const settings = safeJsonParse(readFileSync16(settingsPath, "utf-8"));
|
|
145852
146531
|
const servers = settings.mcpServers || settings.mcp?.servers || {};
|
|
145853
146532
|
if (servers["claude-flow"] || servers["@anthropic/claude-flow"]) {
|
|
145854
146533
|
return { available: true, method: "mcp-config" };
|
|
@@ -145859,10 +146538,10 @@ function checkMCPConfig(projectRoot) {
|
|
|
145859
146538
|
return null;
|
|
145860
146539
|
}
|
|
145861
146540
|
function checkPackageJson(projectRoot) {
|
|
145862
|
-
const packageJsonPath =
|
|
145863
|
-
if (!
|
|
146541
|
+
const packageJsonPath = join29(projectRoot, "package.json");
|
|
146542
|
+
if (!existsSync21(packageJsonPath)) return null;
|
|
145864
146543
|
try {
|
|
145865
|
-
const pkg2 = safeJsonParse(
|
|
146544
|
+
const pkg2 = safeJsonParse(readFileSync16(packageJsonPath, "utf-8"));
|
|
145866
146545
|
const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
|
|
145867
146546
|
if (deps["@claude-flow/cli"] || deps["claude-flow"]) {
|
|
145868
146547
|
return { available: true, method: "npm-dependency" };
|
|
@@ -145929,10 +146608,14 @@ var init_trajectory_bridge = __esm({
|
|
|
145929
146608
|
const id = `trajectory-${randomUUID18()}`;
|
|
145930
146609
|
if (this.claudeFlowAvailable) {
|
|
145931
146610
|
try {
|
|
145932
|
-
const {
|
|
145933
|
-
const
|
|
145934
|
-
|
|
145935
|
-
|
|
146611
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146612
|
+
const args = ["--no-install", "@claude-flow/cli", "hooks", "intelligence", "trajectory-start", "--task", task];
|
|
146613
|
+
if (agent) {
|
|
146614
|
+
args.push("--agent", agent);
|
|
146615
|
+
}
|
|
146616
|
+
const result = execFileSync2(
|
|
146617
|
+
"npx",
|
|
146618
|
+
args,
|
|
145936
146619
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
145937
146620
|
);
|
|
145938
146621
|
const match = result.match(/trajectoryId[:\s]+["']?([^"'\s,}]+)/i);
|
|
@@ -145958,11 +146641,17 @@ var init_trajectory_bridge = __esm({
|
|
|
145958
146641
|
async recordStep(trajectoryId, action, result, quality) {
|
|
145959
146642
|
if (this.claudeFlowAvailable) {
|
|
145960
146643
|
try {
|
|
145961
|
-
const {
|
|
145962
|
-
const
|
|
145963
|
-
|
|
145964
|
-
|
|
145965
|
-
|
|
146644
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146645
|
+
const args = ["--no-install", "@claude-flow/cli", "hooks", "intelligence", "trajectory-step", "--trajectory-id", trajectoryId, "--action", action];
|
|
146646
|
+
if (result) {
|
|
146647
|
+
args.push("--result", result);
|
|
146648
|
+
}
|
|
146649
|
+
if (quality !== void 0) {
|
|
146650
|
+
args.push("--quality", String(quality));
|
|
146651
|
+
}
|
|
146652
|
+
execFileSync2(
|
|
146653
|
+
"npx",
|
|
146654
|
+
args,
|
|
145966
146655
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
145967
146656
|
);
|
|
145968
146657
|
return;
|
|
@@ -145987,10 +146676,14 @@ var init_trajectory_bridge = __esm({
|
|
|
145987
146676
|
async endTrajectory(trajectoryId, success, feedback) {
|
|
145988
146677
|
if (this.claudeFlowAvailable) {
|
|
145989
146678
|
try {
|
|
145990
|
-
const {
|
|
145991
|
-
const
|
|
145992
|
-
|
|
145993
|
-
|
|
146679
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146680
|
+
const args = ["--no-install", "@claude-flow/cli", "hooks", "intelligence", "trajectory-end", "--trajectory-id", trajectoryId, "--success", String(success)];
|
|
146681
|
+
if (feedback) {
|
|
146682
|
+
args.push("--feedback", feedback);
|
|
146683
|
+
}
|
|
146684
|
+
execFileSync2(
|
|
146685
|
+
"npx",
|
|
146686
|
+
args,
|
|
145994
146687
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
145995
146688
|
);
|
|
145996
146689
|
} catch {
|
|
@@ -146023,14 +146716,14 @@ var init_trajectory_bridge = __esm({
|
|
|
146023
146716
|
*/
|
|
146024
146717
|
async persistTrajectory(trajectory) {
|
|
146025
146718
|
try {
|
|
146026
|
-
const { join:
|
|
146027
|
-
const { existsSync:
|
|
146719
|
+
const { join: join41 } = await import("path");
|
|
146720
|
+
const { existsSync: existsSync30, mkdirSync: mkdirSync7 } = await import("fs");
|
|
146028
146721
|
const { createRequire: createRequire13 } = await import("module");
|
|
146029
146722
|
const require3 = createRequire13(import.meta.url);
|
|
146030
146723
|
const { openDatabase: openDatabase2 } = require3("../../shared/safe-db.js");
|
|
146031
|
-
const dbPath =
|
|
146032
|
-
const dir =
|
|
146033
|
-
if (!
|
|
146724
|
+
const dbPath = join41(this.options.projectRoot, ".agentic-qe", "trajectories.db");
|
|
146725
|
+
const dir = join41(this.options.projectRoot, ".agentic-qe");
|
|
146726
|
+
if (!existsSync30(dir)) {
|
|
146034
146727
|
mkdirSync7(dir, { recursive: true });
|
|
146035
146728
|
}
|
|
146036
146729
|
const db = openDatabase2(dbPath);
|
|
@@ -146066,15 +146759,6 @@ var init_trajectory_bridge = __esm({
|
|
|
146066
146759
|
console.debug("[TrajectoryBridge] Trajectory persistence failed:", error instanceof Error ? error.message : error);
|
|
146067
146760
|
}
|
|
146068
146761
|
}
|
|
146069
|
-
/**
|
|
146070
|
-
* Escape shell argument using $'...' syntax for complete safety
|
|
146071
|
-
* This ANSI-C quoting handles ALL special characters including backslashes
|
|
146072
|
-
* CodeQL: js/incomplete-sanitization - Fixed by escaping backslashes AND quotes
|
|
146073
|
-
*/
|
|
146074
|
-
escapeArg(arg) {
|
|
146075
|
-
const escaped = arg.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
146076
|
-
return "$'" + escaped + "'";
|
|
146077
|
-
}
|
|
146078
146762
|
};
|
|
146079
146763
|
}
|
|
146080
146764
|
});
|
|
@@ -146136,9 +146820,10 @@ var init_model_router_bridge = __esm({
|
|
|
146136
146820
|
async routeTask(task) {
|
|
146137
146821
|
if (this.claudeFlowAvailable) {
|
|
146138
146822
|
try {
|
|
146139
|
-
const {
|
|
146140
|
-
const result =
|
|
146141
|
-
|
|
146823
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146824
|
+
const result = execFileSync2(
|
|
146825
|
+
"npx",
|
|
146826
|
+
["--no-install", "@claude-flow/cli", "hooks", "model-route", "--task", task],
|
|
146142
146827
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
146143
146828
|
);
|
|
146144
146829
|
const modelMatch = result.match(/model[:\s]+["']?(haiku|sonnet|opus)/i);
|
|
@@ -146167,9 +146852,10 @@ var init_model_router_bridge = __esm({
|
|
|
146167
146852
|
}
|
|
146168
146853
|
if (this.claudeFlowAvailable) {
|
|
146169
146854
|
try {
|
|
146170
|
-
const {
|
|
146171
|
-
|
|
146172
|
-
|
|
146855
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146856
|
+
execFileSync2(
|
|
146857
|
+
"npx",
|
|
146858
|
+
["--no-install", "@claude-flow/cli", "hooks", "model-outcome", "--task", outcome.task, "--model", outcome.model, "--outcome", outcome.outcome],
|
|
146173
146859
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
146174
146860
|
);
|
|
146175
146861
|
} catch (error) {
|
|
@@ -146248,15 +146934,6 @@ var init_model_router_bridge = __esm({
|
|
|
146248
146934
|
reasoning: "Medium complexity task - using sonnet for balance"
|
|
146249
146935
|
};
|
|
146250
146936
|
}
|
|
146251
|
-
/**
|
|
146252
|
-
* Escape shell argument using $'...' syntax for complete safety
|
|
146253
|
-
* This ANSI-C quoting handles ALL special characters including backslashes
|
|
146254
|
-
* CodeQL: js/incomplete-sanitization - Fixed by escaping backslashes AND quotes
|
|
146255
|
-
*/
|
|
146256
|
-
escapeArg(arg) {
|
|
146257
|
-
const escaped = arg.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
146258
|
-
return "$'" + escaped + "'";
|
|
146259
|
-
}
|
|
146260
146937
|
};
|
|
146261
146938
|
}
|
|
146262
146939
|
});
|
|
@@ -146299,9 +146976,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146299
146976
|
}
|
|
146300
146977
|
if (this.claudeFlowAvailable) {
|
|
146301
146978
|
try {
|
|
146302
|
-
const {
|
|
146303
|
-
const result =
|
|
146304
|
-
|
|
146979
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146980
|
+
const result = execFileSync2(
|
|
146981
|
+
"npx",
|
|
146982
|
+
["--no-install", "@claude-flow/cli", "hooks", "pretrain", "--path", targetPath, "--depth", depth],
|
|
146305
146983
|
{ encoding: "utf-8", timeout: 12e4, cwd: this.options.projectRoot }
|
|
146306
146984
|
);
|
|
146307
146985
|
try {
|
|
@@ -146334,9 +147012,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146334
147012
|
async generateAgentConfigs(format = "yaml") {
|
|
146335
147013
|
if (this.claudeFlowAvailable) {
|
|
146336
147014
|
try {
|
|
146337
|
-
const {
|
|
146338
|
-
const result =
|
|
146339
|
-
|
|
147015
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
147016
|
+
const result = execFileSync2(
|
|
147017
|
+
"npx",
|
|
147018
|
+
["--no-install", "@claude-flow/cli", "hooks", "build-agents", "--format", format],
|
|
146340
147019
|
{ encoding: "utf-8", timeout: 6e4, cwd: this.options.projectRoot }
|
|
146341
147020
|
);
|
|
146342
147021
|
try {
|
|
@@ -146357,9 +147036,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146357
147036
|
async transferPatterns(sourcePath, minConfidence = 0.7) {
|
|
146358
147037
|
if (this.claudeFlowAvailable) {
|
|
146359
147038
|
try {
|
|
146360
|
-
const {
|
|
146361
|
-
const result =
|
|
146362
|
-
|
|
147039
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
147040
|
+
const result = execFileSync2(
|
|
147041
|
+
"npx",
|
|
147042
|
+
["--no-install", "@claude-flow/cli", "hooks", "transfer", "--source-path", sourcePath, "--min-confidence", String(minConfidence)],
|
|
146363
147043
|
{ encoding: "utf-8", timeout: 6e4, cwd: this.options.projectRoot }
|
|
146364
147044
|
);
|
|
146365
147045
|
const transferredMatch = result.match(/transferred[:\s]+(\d+)/i);
|
|
@@ -146380,23 +147060,14 @@ var init_pretrain_bridge = __esm({
|
|
|
146380
147060
|
isClaudeFlowAvailable() {
|
|
146381
147061
|
return this.claudeFlowAvailable;
|
|
146382
147062
|
}
|
|
146383
|
-
/**
|
|
146384
|
-
* Escape shell argument using $'...' syntax for complete safety
|
|
146385
|
-
* This ANSI-C quoting handles ALL special characters including backslashes
|
|
146386
|
-
* CodeQL: js/incomplete-sanitization - Fixed by escaping backslashes AND quotes
|
|
146387
|
-
*/
|
|
146388
|
-
escapeArg(arg) {
|
|
146389
|
-
const escaped = arg.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
146390
|
-
return "$'" + escaped + "'";
|
|
146391
|
-
}
|
|
146392
147063
|
/**
|
|
146393
147064
|
* Local analysis using file system scanning
|
|
146394
147065
|
*/
|
|
146395
147066
|
async localAnalyze(targetPath, depth) {
|
|
146396
147067
|
try {
|
|
146397
147068
|
const glob = await import("fast-glob");
|
|
146398
|
-
const { existsSync:
|
|
146399
|
-
const { join:
|
|
147069
|
+
const { existsSync: existsSync30, readFileSync: readFileSync23 } = await import("fs");
|
|
147070
|
+
const { join: join41 } = await import("path");
|
|
146400
147071
|
const patterns = depth === "shallow" ? ["*.ts", "*.js", "*.json"] : depth === "medium" ? ["**/*.ts", "**/*.js", "**/*.json", "**/*.py"] : ["**/*"];
|
|
146401
147072
|
const ignore = ["node_modules/**", "dist/**", "coverage/**", ".git/**"];
|
|
146402
147073
|
const files = await glob.default(patterns, {
|
|
@@ -146413,10 +147084,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146413
147084
|
if (file.endsWith(".go")) languages.add("go");
|
|
146414
147085
|
if (file.endsWith(".rs")) languages.add("rust");
|
|
146415
147086
|
}
|
|
146416
|
-
const packageJsonPath =
|
|
146417
|
-
if (
|
|
147087
|
+
const packageJsonPath = join41(targetPath, "package.json");
|
|
147088
|
+
if (existsSync30(packageJsonPath)) {
|
|
146418
147089
|
try {
|
|
146419
|
-
const pkg2 = safeJsonParse(
|
|
147090
|
+
const pkg2 = safeJsonParse(readFileSync23(packageJsonPath, "utf-8"));
|
|
146420
147091
|
const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
|
|
146421
147092
|
if (deps.react) frameworks.add("react");
|
|
146422
147093
|
if (deps.vue) frameworks.add("vue");
|
|
@@ -146563,7 +147234,7 @@ function computeBinaryReward(outcome) {
|
|
|
146563
147234
|
function createExperienceCaptureService(memory, patternStore, eventBus, config) {
|
|
146564
147235
|
return new ExperienceCaptureService(memory, patternStore, eventBus, config);
|
|
146565
147236
|
}
|
|
146566
|
-
var
|
|
147237
|
+
var logger15, TEST_OUTCOME_REWARDS, VALID_TEST_OUTCOMES, DEFAULT_EXPERIENCE_CONFIG, ExperienceCaptureService;
|
|
146567
147238
|
var init_experience_capture = __esm({
|
|
146568
147239
|
"src/learning/experience-capture.ts"() {
|
|
146569
147240
|
"use strict";
|
|
@@ -146571,7 +147242,7 @@ var init_experience_capture = __esm({
|
|
|
146571
147242
|
init_types();
|
|
146572
147243
|
init_logging();
|
|
146573
147244
|
init_qe_patterns();
|
|
146574
|
-
|
|
147245
|
+
logger15 = LoggerFactory.create("experience-capture");
|
|
146575
147246
|
TEST_OUTCOME_REWARDS = {
|
|
146576
147247
|
"catches-bug": 1,
|
|
146577
147248
|
"flaky": -1,
|
|
@@ -146737,7 +147408,7 @@ var init_experience_capture = __esm({
|
|
|
146737
147408
|
this.activeExperiences.delete(id);
|
|
146738
147409
|
flushed++;
|
|
146739
147410
|
}
|
|
146740
|
-
|
|
147411
|
+
logger15.info(`Flushed ${flushed} pending experiences before compaction`);
|
|
146741
147412
|
return flushed;
|
|
146742
147413
|
}
|
|
146743
147414
|
/**
|
|
@@ -147161,7 +147832,7 @@ Duration: ${experience.durationMs}ms`;
|
|
|
147161
147832
|
this.stats.byDomain = new Map(savedStats.byDomain);
|
|
147162
147833
|
}
|
|
147163
147834
|
} catch (e20) {
|
|
147164
|
-
|
|
147835
|
+
logger15.debug("Stats restoration failed, starting fresh", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
147165
147836
|
}
|
|
147166
147837
|
}
|
|
147167
147838
|
/**
|
|
@@ -150029,8 +150700,8 @@ var init_prime_radiant_advanced_wasm = __esm({
|
|
|
150029
150700
|
// src/integrations/coherence/wasm-loader.ts
|
|
150030
150701
|
import { createRequire as createRequire10 } from "node:module";
|
|
150031
150702
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
150032
|
-
import { dirname as dirname5, join as
|
|
150033
|
-
import { readFileSync as
|
|
150703
|
+
import { dirname as dirname5, join as join30 } from "node:path";
|
|
150704
|
+
import { readFileSync as readFileSync17, existsSync as existsSync22 } from "node:fs";
|
|
150034
150705
|
var FALLBACK_RETRY_DELAYS_MS, WasmLoader, wasmLoader;
|
|
150035
150706
|
var init_wasm_loader = __esm({
|
|
150036
150707
|
"src/integrations/coherence/wasm-loader.ts"() {
|
|
@@ -150294,15 +150965,15 @@ var init_wasm_loader = __esm({
|
|
|
150294
150965
|
(() => {
|
|
150295
150966
|
try {
|
|
150296
150967
|
const modulePath = require3.resolve("prime-radiant-advanced-wasm");
|
|
150297
|
-
return
|
|
150968
|
+
return join30(dirname5(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
|
|
150298
150969
|
} catch {
|
|
150299
150970
|
return null;
|
|
150300
150971
|
}
|
|
150301
150972
|
})(),
|
|
150302
|
-
|
|
150973
|
+
join30(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
|
|
150303
150974
|
].filter((p74) => p74 !== null);
|
|
150304
150975
|
for (const path31 of wasmPaths) {
|
|
150305
|
-
if (
|
|
150976
|
+
if (existsSync22(path31)) {
|
|
150306
150977
|
return true;
|
|
150307
150978
|
}
|
|
150308
150979
|
}
|
|
@@ -150553,19 +151224,19 @@ var init_wasm_loader = __esm({
|
|
|
150553
151224
|
(() => {
|
|
150554
151225
|
try {
|
|
150555
151226
|
const modulePath = require3.resolve("prime-radiant-advanced-wasm");
|
|
150556
|
-
return
|
|
151227
|
+
return join30(dirname5(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
|
|
150557
151228
|
} catch {
|
|
150558
151229
|
return null;
|
|
150559
151230
|
}
|
|
150560
151231
|
})(),
|
|
150561
151232
|
// Direct node_modules path from current file
|
|
150562
|
-
|
|
151233
|
+
join30(dirname5(fileURLToPath2(import.meta.url)), "../../../../node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm"),
|
|
150563
151234
|
// Workspace root
|
|
150564
|
-
|
|
151235
|
+
join30(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
|
|
150565
151236
|
].filter((p74) => p74 !== null);
|
|
150566
151237
|
let wasmPath = null;
|
|
150567
151238
|
for (const path31 of wasmPaths) {
|
|
150568
|
-
if (
|
|
151239
|
+
if (existsSync22(path31)) {
|
|
150569
151240
|
wasmPath = path31;
|
|
150570
151241
|
break;
|
|
150571
151242
|
}
|
|
@@ -150577,7 +151248,7 @@ ${wasmPaths.join("\n")}
|
|
|
150577
151248
|
Ensure prime-radiant-advanced-wasm is installed.`
|
|
150578
151249
|
);
|
|
150579
151250
|
}
|
|
150580
|
-
const wasmBytes =
|
|
151251
|
+
const wasmBytes = readFileSync17(wasmPath);
|
|
150581
151252
|
if (wasmModule2.initSync && typeof wasmModule2.initSync === "function") {
|
|
150582
151253
|
wasmModule2.initSync({ module: wasmBytes });
|
|
150583
151254
|
} else {
|
|
@@ -150775,7 +151446,7 @@ __export(rvf_native_adapter_exports, {
|
|
|
150775
151446
|
openRvfStore: () => openRvfStore,
|
|
150776
151447
|
openRvfStoreReadonly: () => openRvfStoreReadonly
|
|
150777
151448
|
});
|
|
150778
|
-
import { readFileSync as
|
|
151449
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync2, copyFileSync as copyFileSync2, existsSync as existsSync23 } from "fs";
|
|
150779
151450
|
function getNative() {
|
|
150780
151451
|
if (_nativeChecked) return _native;
|
|
150781
151452
|
_nativeChecked = true;
|
|
@@ -150798,9 +151469,9 @@ function loadIdMap(rvfPath) {
|
|
|
150798
151469
|
const strToNum = /* @__PURE__ */ new Map();
|
|
150799
151470
|
const numToStr = /* @__PURE__ */ new Map();
|
|
150800
151471
|
let nextLabel = 1;
|
|
150801
|
-
if (
|
|
151472
|
+
if (existsSync23(p74)) {
|
|
150802
151473
|
try {
|
|
150803
|
-
const raw = JSON.parse(
|
|
151474
|
+
const raw = JSON.parse(readFileSync18(p74, "utf-8"));
|
|
150804
151475
|
nextLabel = raw.nextLabel;
|
|
150805
151476
|
for (const [str, num] of raw.entries) {
|
|
150806
151477
|
strToNum.set(str, num);
|
|
@@ -152477,8 +153148,8 @@ var init_aqe_learning_engine = __esm({
|
|
|
152477
153148
|
async localAnalyze(targetPath, depth) {
|
|
152478
153149
|
try {
|
|
152479
153150
|
const glob = await import("fast-glob");
|
|
152480
|
-
const { existsSync:
|
|
152481
|
-
const { join:
|
|
153151
|
+
const { existsSync: existsSync30, readFileSync: readFileSync23 } = await import("fs");
|
|
153152
|
+
const { join: join41 } = await import("path");
|
|
152482
153153
|
const patterns = depth === "shallow" ? ["*.ts", "*.js", "*.json"] : depth === "medium" ? ["**/*.ts", "**/*.js", "**/*.json", "**/*.py"] : ["**/*"];
|
|
152483
153154
|
const ignore = ["node_modules/**", "dist/**", "coverage/**", ".git/**"];
|
|
152484
153155
|
const files = await glob.default(patterns, {
|
|
@@ -152495,10 +153166,10 @@ var init_aqe_learning_engine = __esm({
|
|
|
152495
153166
|
if (file.endsWith(".go")) languages.add("go");
|
|
152496
153167
|
if (file.endsWith(".rs")) languages.add("rust");
|
|
152497
153168
|
}
|
|
152498
|
-
const packageJsonPath =
|
|
152499
|
-
if (
|
|
153169
|
+
const packageJsonPath = join41(targetPath, "package.json");
|
|
153170
|
+
if (existsSync30(packageJsonPath)) {
|
|
152500
153171
|
try {
|
|
152501
|
-
const pkg2 = safeJsonParse(
|
|
153172
|
+
const pkg2 = safeJsonParse(readFileSync23(packageJsonPath, "utf-8"));
|
|
152502
153173
|
const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
|
|
152503
153174
|
if (deps.react) frameworks.add("react");
|
|
152504
153175
|
if (deps.vue) frameworks.add("vue");
|
|
@@ -154478,13 +155149,15 @@ ${parts.join(" | ")}`;
|
|
|
154478
155149
|
function formatCostUsd(cost) {
|
|
154479
155150
|
return `$${cost.toFixed(2)}`;
|
|
154480
155151
|
}
|
|
154481
|
-
var DEFAULT_COST_CONFIG, DEFAULT_PERSISTENCE_CONFIG2, TokenMetricsCollectorImpl, TokenMetricsCollector;
|
|
155152
|
+
var ttLogger, DEFAULT_COST_CONFIG, DEFAULT_PERSISTENCE_CONFIG2, TokenMetricsCollectorImpl, TokenMetricsCollector;
|
|
154482
155153
|
var init_token_tracker = __esm({
|
|
154483
155154
|
"src/learning/token-tracker.ts"() {
|
|
154484
155155
|
"use strict";
|
|
154485
155156
|
init_unified_memory();
|
|
154486
155157
|
init_error_utils();
|
|
154487
155158
|
init_safe_json();
|
|
155159
|
+
init_logger_factory();
|
|
155160
|
+
ttLogger = createLogger("TokenTracker");
|
|
154488
155161
|
DEFAULT_COST_CONFIG = {
|
|
154489
155162
|
costPerInputToken: 3e-3 / 1e3,
|
|
154490
155163
|
// $3 per 1M input tokens
|
|
@@ -154537,7 +155210,8 @@ var init_token_tracker = __esm({
|
|
|
154537
155210
|
if (config) {
|
|
154538
155211
|
this.costConfig = { ...DEFAULT_COST_CONFIG, ...config };
|
|
154539
155212
|
}
|
|
154540
|
-
this.initializeDb().catch(() => {
|
|
155213
|
+
this.initializeDb().catch((e20) => {
|
|
155214
|
+
ttLogger.warn("DB initialization failed", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
154541
155215
|
});
|
|
154542
155216
|
this.startAutoSave();
|
|
154543
155217
|
}
|
|
@@ -155017,7 +155691,8 @@ var init_token_tracker = __esm({
|
|
|
155017
155691
|
this.kvPersistCount++;
|
|
155018
155692
|
if (this.kvPersistCount >= _TokenMetricsCollectorImpl.KV_PERSIST_INTERVAL) {
|
|
155019
155693
|
this.kvPersistCount = 0;
|
|
155020
|
-
this.persistToKv().catch(() => {
|
|
155694
|
+
this.persistToKv().catch((e20) => {
|
|
155695
|
+
ttLogger.warn("KV persist failed", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
155021
155696
|
});
|
|
155022
155697
|
}
|
|
155023
155698
|
}
|
|
@@ -156166,11 +156841,11 @@ async function parseJSONCoverage(jsonPath, projectRoot) {
|
|
|
156166
156841
|
}
|
|
156167
156842
|
async function parseCoverage(coveragePath, projectRoot) {
|
|
156168
156843
|
const ext = path24.extname(coveragePath).toLowerCase();
|
|
156169
|
-
const
|
|
156170
|
-
if (ext === ".json" ||
|
|
156844
|
+
const basename10 = path24.basename(coveragePath).toLowerCase();
|
|
156845
|
+
if (ext === ".json" || basename10.includes("coverage-final")) {
|
|
156171
156846
|
return parseJSONCoverage(coveragePath, projectRoot);
|
|
156172
156847
|
}
|
|
156173
|
-
if (
|
|
156848
|
+
if (basename10 === "lcov.info" || ext === ".info" || basename10.includes("lcov")) {
|
|
156174
156849
|
return parseLCOV(coveragePath, projectRoot);
|
|
156175
156850
|
}
|
|
156176
156851
|
const content = await fs24.readFile(coveragePath, "utf-8");
|
|
@@ -157630,8 +158305,8 @@ var init_types20 = __esm({
|
|
|
157630
158305
|
});
|
|
157631
158306
|
|
|
157632
158307
|
// src/domains/requirements-validation/services/quality-criteria/quality-criteria-service.ts
|
|
157633
|
-
import { existsSync as
|
|
157634
|
-
import { join as
|
|
158308
|
+
import { existsSync as existsSync25, readFileSync as readFileSync19 } from "fs";
|
|
158309
|
+
import { join as join33 } from "path";
|
|
157635
158310
|
function createQualityCriteriaService(config) {
|
|
157636
158311
|
return new QualityCriteriaService(config);
|
|
157637
158312
|
}
|
|
@@ -157657,14 +158332,14 @@ var init_quality_criteria_service = __esm({
|
|
|
157657
158332
|
findTemplatePath() {
|
|
157658
158333
|
const possiblePaths = [
|
|
157659
158334
|
// Relative to v3 package
|
|
157660
|
-
|
|
158335
|
+
join33(process.cwd(), ".claude/helpers/v3/quality-criteria/quality-criteria-reference-template.html"),
|
|
157661
158336
|
// In node_modules
|
|
157662
|
-
|
|
158337
|
+
join33(process.cwd(), "node_modules/agentic-qe/assets/agents/v3/helpers/quality-criteria/quality-criteria-reference-template.html"),
|
|
157663
158338
|
// Development path
|
|
157664
|
-
|
|
158339
|
+
join33(__dirname, "../../../../../assets/agents/v3/helpers/quality-criteria/quality-criteria-reference-template.html")
|
|
157665
158340
|
];
|
|
157666
158341
|
for (const path31 of possiblePaths) {
|
|
157667
|
-
if (
|
|
158342
|
+
if (existsSync25(path31)) {
|
|
157668
158343
|
return path31;
|
|
157669
158344
|
}
|
|
157670
158345
|
}
|
|
@@ -157681,8 +158356,8 @@ var init_quality_criteria_service = __esm({
|
|
|
157681
158356
|
*/
|
|
157682
158357
|
analyze(input) {
|
|
157683
158358
|
let epicContent = input.epicContent || "";
|
|
157684
|
-
if (input.epicPath &&
|
|
157685
|
-
epicContent =
|
|
158359
|
+
if (input.epicPath && existsSync25(input.epicPath)) {
|
|
158360
|
+
epicContent = readFileSync19(input.epicPath, "utf-8");
|
|
157686
158361
|
}
|
|
157687
158362
|
if (!epicContent && !input.epicPath) {
|
|
157688
158363
|
throw new Error("Either epicPath or epicContent is required for analysis");
|
|
@@ -157848,8 +158523,8 @@ Analyze the requirements above and return the complete QualityCriteriaAnalysis.`
|
|
|
157848
158523
|
* Generate HTML output
|
|
157849
158524
|
*/
|
|
157850
158525
|
generateHTML(analysis) {
|
|
157851
|
-
if (!this.templateCache &&
|
|
157852
|
-
this.templateCache =
|
|
158526
|
+
if (!this.templateCache && existsSync25(this.config.templatePath)) {
|
|
158527
|
+
this.templateCache = readFileSync19(this.config.templatePath, "utf-8");
|
|
157853
158528
|
}
|
|
157854
158529
|
if (!this.templateCache) {
|
|
157855
158530
|
return this.generateFallbackHTML(analysis);
|
|
@@ -157990,7 +158665,7 @@ var init_requirements_validation = __esm({
|
|
|
157990
158665
|
});
|
|
157991
158666
|
|
|
157992
158667
|
// src/mcp/tools/requirements-validation/quality-criteria.ts
|
|
157993
|
-
import { existsSync as
|
|
158668
|
+
import { existsSync as existsSync26, readFileSync as readFileSync20 } from "fs";
|
|
157994
158669
|
var QualityCriteriaTool, QUALITY_CRITERIA_SCHEMA, qualityCriteriaTool;
|
|
157995
158670
|
var init_quality_criteria2 = __esm({
|
|
157996
158671
|
"src/mcp/tools/requirements-validation/quality-criteria.ts"() {
|
|
@@ -158096,8 +158771,8 @@ var init_quality_criteria2 = __esm({
|
|
|
158096
158771
|
message: "Preparing agent invocation for semantic HTSM analysis"
|
|
158097
158772
|
});
|
|
158098
158773
|
let content = epicContent || "";
|
|
158099
|
-
if (epicPath &&
|
|
158100
|
-
content =
|
|
158774
|
+
if (epicPath && existsSync26(epicPath)) {
|
|
158775
|
+
content = readFileSync20(epicPath, "utf-8");
|
|
158101
158776
|
}
|
|
158102
158777
|
if (!content && !epicPath) {
|
|
158103
158778
|
return {
|
|
@@ -165846,19 +166521,6 @@ var init_check = __esm({
|
|
|
165846
166521
|
}
|
|
165847
166522
|
});
|
|
165848
166523
|
|
|
165849
|
-
// src/learning/v2-to-v3-migration.ts
|
|
165850
|
-
var logger15;
|
|
165851
|
-
var init_v2_to_v3_migration = __esm({
|
|
165852
|
-
"src/learning/v2-to-v3-migration.ts"() {
|
|
165853
|
-
"use strict";
|
|
165854
|
-
init_safe_db();
|
|
165855
|
-
init_error_utils();
|
|
165856
|
-
init_safe_json();
|
|
165857
|
-
init_logging();
|
|
165858
|
-
logger15 = LoggerFactory.create("v2-to-v3-migration");
|
|
165859
|
-
}
|
|
165860
|
-
});
|
|
165861
|
-
|
|
165862
166524
|
// src/learning/qe-unified-memory.ts
|
|
165863
166525
|
var logger16, QE_DOMAIN_HNSW_CONFIGS, DEFAULT_QE_UNIFIED_MEMORY_CONFIG;
|
|
165864
166526
|
var init_qe_unified_memory = __esm({
|
|
@@ -165866,7 +166528,6 @@ var init_qe_unified_memory = __esm({
|
|
|
165866
166528
|
"use strict";
|
|
165867
166529
|
init_logging();
|
|
165868
166530
|
init_types();
|
|
165869
|
-
init_v2_to_v3_migration();
|
|
165870
166531
|
init_types2();
|
|
165871
166532
|
init_error_utils();
|
|
165872
166533
|
init_hnsw_index();
|
|
@@ -166399,42 +167060,42 @@ var init_pattern_lifecycle = __esm({
|
|
|
166399
167060
|
// Experience Extraction
|
|
166400
167061
|
// ============================================================================
|
|
166401
167062
|
/**
|
|
166402
|
-
* Get recent experiences from
|
|
167063
|
+
* Get recent experiences from captured_experiences table.
|
|
166403
167064
|
*/
|
|
166404
167065
|
getRecentExperiences(options = {}) {
|
|
166405
167066
|
const minReward = options.minReward ?? this.config.promotionRewardThreshold;
|
|
166406
167067
|
const limit = options.limit ?? 100;
|
|
166407
167068
|
const sinceDays = options.sinceDays ?? 7;
|
|
166408
|
-
const
|
|
166409
|
-
|
|
166410
|
-
|
|
166411
|
-
WHERE type='table' AND name='learning_experiences'
|
|
166412
|
-
`).get();
|
|
167069
|
+
const tableExists2 = this.db.prepare(
|
|
167070
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='captured_experiences'"
|
|
167071
|
+
).get();
|
|
166413
167072
|
if (!tableExists2) {
|
|
166414
|
-
|
|
167073
|
+
logger19.debug("captured_experiences table not found");
|
|
166415
167074
|
return [];
|
|
166416
167075
|
}
|
|
167076
|
+
const sinceDate = new Date(Date.now() - sinceDays * 864e5).toISOString().replace("T", " ").slice(0, 19);
|
|
166417
167077
|
const aggregates = this.db.prepare(`
|
|
166418
167078
|
SELECT
|
|
166419
|
-
task_type,
|
|
167079
|
+
domain as task_type,
|
|
166420
167080
|
COUNT(*) as count,
|
|
166421
|
-
AVG(
|
|
166422
|
-
MAX(
|
|
166423
|
-
MIN(
|
|
166424
|
-
SUM(CASE WHEN
|
|
166425
|
-
GROUP_CONCAT(DISTINCT
|
|
166426
|
-
MAX(
|
|
166427
|
-
FROM
|
|
166428
|
-
WHERE
|
|
166429
|
-
|
|
167081
|
+
AVG(quality) as avg_reward,
|
|
167082
|
+
MAX(quality) as max_reward,
|
|
167083
|
+
MIN(quality) as min_reward,
|
|
167084
|
+
SUM(CASE WHEN quality >= ? THEN 1 ELSE 0 END) as success_count,
|
|
167085
|
+
GROUP_CONCAT(DISTINCT agent) as actions,
|
|
167086
|
+
MAX(started_at) as latest_at
|
|
167087
|
+
FROM captured_experiences
|
|
167088
|
+
WHERE started_at >= ?
|
|
167089
|
+
AND quality >= ?
|
|
167090
|
+
AND agent != 'cli-hook'
|
|
167091
|
+
GROUP BY domain
|
|
166430
167092
|
HAVING COUNT(*) >= ?
|
|
166431
167093
|
ORDER BY avg_reward DESC
|
|
166432
167094
|
LIMIT ?
|
|
166433
167095
|
`).all(
|
|
166434
167096
|
minReward,
|
|
166435
|
-
|
|
167097
|
+
sinceDate,
|
|
166436
167098
|
minReward * 0.5,
|
|
166437
|
-
// Include experiences above half threshold for context
|
|
166438
167099
|
this.config.promotionMinOccurrences,
|
|
166439
167100
|
limit
|
|
166440
167101
|
);
|
|
@@ -167120,7 +167781,6 @@ var init_learning = __esm({
|
|
|
167120
167781
|
init_real_embeddings();
|
|
167121
167782
|
init_sqlite_persistence();
|
|
167122
167783
|
init_qe_unified_memory();
|
|
167123
|
-
init_v2_to_v3_migration();
|
|
167124
167784
|
init_token_tracker();
|
|
167125
167785
|
init_dream();
|
|
167126
167786
|
init_aqe_learning_engine();
|
|
@@ -169621,7 +170281,7 @@ var init_vitest_executor = __esm({
|
|
|
169621
170281
|
|
|
169622
170282
|
// src/test-scheduling/git-aware/test-selector.ts
|
|
169623
170283
|
import { spawn as spawn6 } from "child_process";
|
|
169624
|
-
import { resolve as resolve7, dirname as dirname8, basename as
|
|
170284
|
+
import { resolve as resolve7, dirname as dirname8, basename as basename7 } from "path";
|
|
169625
170285
|
function createTestSelector(config) {
|
|
169626
170286
|
return new GitAwareTestSelector(config);
|
|
169627
170287
|
}
|
|
@@ -169842,7 +170502,7 @@ var init_test_selector = __esm({
|
|
|
169842
170502
|
continue;
|
|
169843
170503
|
}
|
|
169844
170504
|
const relatedTests = impactResult.value.filter(
|
|
169845
|
-
(test) => test.includes(
|
|
170505
|
+
(test) => test.includes(basename7(changedFile.path, ".ts").replace(/\.(tsx?|jsx?)$/, ""))
|
|
169846
170506
|
);
|
|
169847
170507
|
if (relatedTests.length > 0) {
|
|
169848
170508
|
mappings.push({
|
|
@@ -169862,7 +170522,7 @@ var init_test_selector = __esm({
|
|
|
169862
170522
|
return /^(vitest\.config|jest\.config|tsconfig|package\.json)/.test(path31);
|
|
169863
170523
|
}
|
|
169864
170524
|
async findTestsHeuristically(sourcePath) {
|
|
169865
|
-
const baseName =
|
|
170525
|
+
const baseName = basename7(sourcePath, ".ts").replace(/\.(tsx?|jsx?)$/, "");
|
|
169866
170526
|
const dir = dirname8(sourcePath);
|
|
169867
170527
|
const candidates = [
|
|
169868
170528
|
`${dir}/${baseName}.test.ts`,
|
|
@@ -172295,7 +172955,7 @@ var init_visual_security = __esm({
|
|
|
172295
172955
|
|
|
172296
172956
|
// src/workflows/browser/workflow-loader.ts
|
|
172297
172957
|
import { readFile as readFile16, readdir as readdir5 } from "fs/promises";
|
|
172298
|
-
import { join as
|
|
172958
|
+
import { join as join36, basename as basename8 } from "path";
|
|
172299
172959
|
import { parse as parseYaml2 } from "yaml";
|
|
172300
172960
|
function interpolateVariables(template, variables) {
|
|
172301
172961
|
return template.replace(/\{\{([^}]+)\}\}/g, (match, key) => {
|
|
@@ -172329,7 +172989,7 @@ var init_workflow_loader = __esm({
|
|
|
172329
172989
|
templatesDir;
|
|
172330
172990
|
cache = /* @__PURE__ */ new Map();
|
|
172331
172991
|
constructor(templatesDir) {
|
|
172332
|
-
this.templatesDir = templatesDir ||
|
|
172992
|
+
this.templatesDir = templatesDir || join36(__dirname, "templates");
|
|
172333
172993
|
}
|
|
172334
172994
|
/**
|
|
172335
172995
|
* Load a workflow template by name
|
|
@@ -172339,7 +172999,7 @@ var init_workflow_loader = __esm({
|
|
|
172339
172999
|
return this.cache.get(templateName);
|
|
172340
173000
|
}
|
|
172341
173001
|
try {
|
|
172342
|
-
const templatePath =
|
|
173002
|
+
const templatePath = join36(this.templatesDir, `${templateName}.yaml`);
|
|
172343
173003
|
const content = await readFile16(templatePath, "utf-8");
|
|
172344
173004
|
const workflow = parseYaml2(content);
|
|
172345
173005
|
const validation = await this.validate(workflow);
|
|
@@ -172364,7 +173024,7 @@ ${validation.errors.join("\n")}`
|
|
|
172364
173024
|
async list() {
|
|
172365
173025
|
try {
|
|
172366
173026
|
const files = await readdir5(this.templatesDir);
|
|
172367
|
-
return files.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml")).map((file) =>
|
|
173027
|
+
return files.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml")).map((file) => basename8(file, file.endsWith(".yaml") ? ".yaml" : ".yml")).sort();
|
|
172368
173028
|
} catch (error) {
|
|
172369
173029
|
if (error.code === "ENOENT") {
|
|
172370
173030
|
return [];
|
|
@@ -172480,7 +173140,7 @@ ${validation.errors.join("\n")}`
|
|
|
172480
173140
|
*/
|
|
172481
173141
|
async getMetadata(templateName) {
|
|
172482
173142
|
try {
|
|
172483
|
-
const templatePath =
|
|
173143
|
+
const templatePath = join36(this.templatesDir, `${templateName}.yaml`);
|
|
172484
173144
|
const content = await readFile16(templatePath, "utf-8");
|
|
172485
173145
|
const workflow = parseYaml2(content);
|
|
172486
173146
|
return {
|
|
@@ -175214,7 +175874,7 @@ async function handleAQEHealth() {
|
|
|
175214
175874
|
success: true,
|
|
175215
175875
|
data: {
|
|
175216
175876
|
status: healthStatus,
|
|
175217
|
-
version: true ? "3.7.
|
|
175877
|
+
version: true ? "3.7.22" : "3.7.2",
|
|
175218
175878
|
loadedDomains: domainCount,
|
|
175219
175879
|
memory: memoryStats,
|
|
175220
175880
|
hnsw: hnswStats,
|
|
@@ -183855,6 +184515,8 @@ async function handleAgentStatus(params) {
|
|
|
183855
184515
|
init_esm_node();
|
|
183856
184516
|
init_unified_memory();
|
|
183857
184517
|
init_error_utils();
|
|
184518
|
+
init_logger_factory();
|
|
184519
|
+
var ecLogger = createLogger("ExperienceCapture");
|
|
183858
184520
|
var EXPERIENCE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
183859
184521
|
var CLEANUP_INTERVAL_MS = 2 * 60 * 1e3;
|
|
183860
184522
|
var MAX_JSON_SIZE_BYTES = 1024 * 1024;
|
|
@@ -183934,15 +184596,15 @@ async function doInitialize() {
|
|
|
183934
184596
|
).get().cnt > 0;
|
|
183935
184597
|
if (tableExists2) {
|
|
183936
184598
|
const columns = db.prepare("PRAGMA table_info(captured_experiences)").all();
|
|
183937
|
-
const
|
|
183938
|
-
if (!
|
|
184599
|
+
const colNames2 = new Set(columns.map((c70) => c70.name));
|
|
184600
|
+
if (!colNames2.has("success") || !colNames2.has("task")) {
|
|
183939
184601
|
db.exec("ALTER TABLE captured_experiences RENAME TO captured_experiences_v2_backup");
|
|
183940
184602
|
needsCreate = true;
|
|
183941
184603
|
} else {
|
|
183942
|
-
if (!
|
|
184604
|
+
if (!colNames2.has("domain")) {
|
|
183943
184605
|
db.exec("ALTER TABLE captured_experiences ADD COLUMN domain TEXT NOT NULL DEFAULT ''");
|
|
183944
184606
|
}
|
|
183945
|
-
if (!
|
|
184607
|
+
if (!colNames2.has("source")) {
|
|
183946
184608
|
db.exec("ALTER TABLE captured_experiences ADD COLUMN source TEXT DEFAULT 'middleware'");
|
|
183947
184609
|
}
|
|
183948
184610
|
}
|
|
@@ -183976,6 +184638,27 @@ async function doInitialize() {
|
|
|
183976
184638
|
CREATE INDEX IF NOT EXISTS idx_captured_exp_agent ON captured_experiences(agent);
|
|
183977
184639
|
CREATE INDEX IF NOT EXISTS idx_captured_exp_completed ON captured_experiences(completed_at DESC);
|
|
183978
184640
|
`);
|
|
184641
|
+
const colNames = new Set(
|
|
184642
|
+
db.prepare("PRAGMA table_info(captured_experiences)").all().map((c70) => c70.name)
|
|
184643
|
+
);
|
|
184644
|
+
const consolidationCols = [
|
|
184645
|
+
["application_count", "INTEGER DEFAULT 0"],
|
|
184646
|
+
["avg_token_savings", "REAL DEFAULT 0"],
|
|
184647
|
+
["embedding", "BLOB"],
|
|
184648
|
+
["embedding_dimension", "INTEGER"],
|
|
184649
|
+
["tags", "TEXT"],
|
|
184650
|
+
["last_applied_at", "TEXT"],
|
|
184651
|
+
["consolidated_into", "TEXT DEFAULT NULL"],
|
|
184652
|
+
["consolidation_count", "INTEGER DEFAULT 1"],
|
|
184653
|
+
["quality_updated_at", "TEXT DEFAULT NULL"],
|
|
184654
|
+
["reuse_success_count", "INTEGER DEFAULT 0"],
|
|
184655
|
+
["reuse_failure_count", "INTEGER DEFAULT 0"]
|
|
184656
|
+
];
|
|
184657
|
+
for (const [col, def] of consolidationCols) {
|
|
184658
|
+
if (!colNames.has(col)) {
|
|
184659
|
+
db.exec(`ALTER TABLE captured_experiences ADD COLUMN ${col} ${def}`);
|
|
184660
|
+
}
|
|
184661
|
+
}
|
|
183979
184662
|
}
|
|
183980
184663
|
startCleanupTimer();
|
|
183981
184664
|
console.log("[ExperienceCaptureMiddleware] Initialized");
|
|
@@ -184067,7 +184750,8 @@ async function persistExperience(context, outcome) {
|
|
|
184067
184750
|
context.startedAt.toISOString(),
|
|
184068
184751
|
"middleware"
|
|
184069
184752
|
);
|
|
184070
|
-
computeExperienceEmbedding(db, outcome.id, context.task, context.domain).catch(() => {
|
|
184753
|
+
computeExperienceEmbedding(db, outcome.id, context.task, context.domain).catch((e20) => {
|
|
184754
|
+
ecLogger.warn("Embedding computation failed", { error: e20 instanceof Error ? e20.message : String(e20), experienceId: outcome.id, domain: context.domain });
|
|
184071
184755
|
});
|
|
184072
184756
|
} catch (error) {
|
|
184073
184757
|
console.error("[ExperienceCaptureMiddleware] Failed to persist experience:", error);
|
|
@@ -185515,7 +186199,7 @@ async function handlePipelineValidate(params) {
|
|
|
185515
186199
|
}
|
|
185516
186200
|
|
|
185517
186201
|
// src/mcp/handlers/validation-pipeline-handler.ts
|
|
185518
|
-
import { readFileSync as
|
|
186202
|
+
import { readFileSync as readFileSync21, existsSync as existsSync28 } from "fs";
|
|
185519
186203
|
import { resolve as resolve8 } from "path";
|
|
185520
186204
|
|
|
185521
186205
|
// src/validation/pipeline.ts
|
|
@@ -186239,14 +186923,14 @@ async function handleValidationPipeline(params) {
|
|
|
186239
186923
|
content = params.content;
|
|
186240
186924
|
} else if (params.filePath) {
|
|
186241
186925
|
const absPath = resolve8(process.cwd(), params.filePath);
|
|
186242
|
-
if (!
|
|
186926
|
+
if (!existsSync28(absPath)) {
|
|
186243
186927
|
return {
|
|
186244
186928
|
success: false,
|
|
186245
186929
|
error: `File not found: ${params.filePath}`
|
|
186246
186930
|
};
|
|
186247
186931
|
}
|
|
186248
186932
|
try {
|
|
186249
|
-
content =
|
|
186933
|
+
content = readFileSync21(absPath, "utf-8");
|
|
186250
186934
|
} catch (readErr) {
|
|
186251
186935
|
return {
|
|
186252
186936
|
success: false,
|
|
@@ -188147,7 +188831,7 @@ async function quickStart(config) {
|
|
|
188147
188831
|
// src/mcp/http-server.ts
|
|
188148
188832
|
init_safe_json();
|
|
188149
188833
|
import { createServer } from "http";
|
|
188150
|
-
import { join as
|
|
188834
|
+
import { join as join39, dirname as dirname10 } from "path";
|
|
188151
188835
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
188152
188836
|
|
|
188153
188837
|
// src/adapters/a2a/agent-cards/schema.ts
|
|
@@ -191240,7 +191924,7 @@ init_error_utils();
|
|
|
191240
191924
|
// src/adapters/a2a/agent-cards/generator.ts
|
|
191241
191925
|
init_error_utils();
|
|
191242
191926
|
import { readFile as readFile18, readdir as readdir7, stat as stat5 } from "fs/promises";
|
|
191243
|
-
import { join as
|
|
191927
|
+
import { join as join38, basename as basename9 } from "path";
|
|
191244
191928
|
var DEFAULT_GENERATOR_CONFIG = {
|
|
191245
191929
|
baseUrl: "http://localhost:8080",
|
|
191246
191930
|
defaultVersion: "3.0.0",
|
|
@@ -191576,7 +192260,7 @@ var AgentCardGenerator = class {
|
|
|
191576
192260
|
*/
|
|
191577
192261
|
async generateFromFile(filePath) {
|
|
191578
192262
|
const markdown = await readFile18(filePath, "utf-8");
|
|
191579
|
-
const agentId =
|
|
192263
|
+
const agentId = basename9(filePath, ".md");
|
|
191580
192264
|
return this.generateFromMarkdown(markdown, agentId);
|
|
191581
192265
|
}
|
|
191582
192266
|
/**
|
|
@@ -191589,7 +192273,7 @@ var AgentCardGenerator = class {
|
|
|
191589
192273
|
const processDirectory = async (dirPath) => {
|
|
191590
192274
|
const entries = await readdir7(dirPath);
|
|
191591
192275
|
for (const entry of entries) {
|
|
191592
|
-
const fullPath =
|
|
192276
|
+
const fullPath = join38(dirPath, entry);
|
|
191593
192277
|
const stats = await stat5(fullPath);
|
|
191594
192278
|
if (stats.isDirectory() && recursive) {
|
|
191595
192279
|
await processDirectory(fullPath);
|
|
@@ -193049,7 +193733,7 @@ var HTTPServerImpl = class {
|
|
|
193049
193733
|
this.skipCRDTInit = config.skipCRDTInit ?? false;
|
|
193050
193734
|
this.enableWebSocket = config.enableWebSocket ?? true;
|
|
193051
193735
|
const currentDir = dirname10(fileURLToPath3(import.meta.url));
|
|
193052
|
-
this.agentMarkdownDir = config.agentMarkdownDir ??
|
|
193736
|
+
this.agentMarkdownDir = config.agentMarkdownDir ?? join39(currentDir, "../../assets/agents/v3");
|
|
193053
193737
|
this.taskStore = createTaskStore();
|
|
193054
193738
|
this.taskManager = config.taskManager ?? createTaskManager({
|
|
193055
193739
|
storeConfig: {}
|
|
@@ -194935,7 +195619,7 @@ function createInfraHealingOrchestratorSync(options) {
|
|
|
194935
195619
|
init_global_instance();
|
|
194936
195620
|
|
|
194937
195621
|
// src/mcp/entry.ts
|
|
194938
|
-
import { readFileSync as
|
|
195622
|
+
import { readFileSync as readFileSync22 } from "node:fs";
|
|
194939
195623
|
import { resolve as resolve10, dirname as dirname11 } from "node:path";
|
|
194940
195624
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
194941
195625
|
var require2 = createRequire12(import.meta.url);
|
|
@@ -195021,7 +195705,7 @@ async function main() {
|
|
|
195021
195705
|
const playbookPath = resolve10(__dirname2, "../strange-loop/infra-healing/default-playbook.yaml");
|
|
195022
195706
|
let playbookContent;
|
|
195023
195707
|
try {
|
|
195024
|
-
playbookContent =
|
|
195708
|
+
playbookContent = readFileSync22(playbookPath, "utf-8");
|
|
195025
195709
|
} catch {
|
|
195026
195710
|
playbookContent = [
|
|
195027
195711
|
"services:",
|