@probelabs/visor 0.1.80 → 0.1.82
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/dist/check-execution-engine.d.ts.map +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +276 -265
- package/dist/providers/ai-check-provider.d.ts +0 -4
- package/dist/providers/ai-check-provider.d.ts.map +1 -1
- package/dist/providers/claude-code-check-provider.d.ts +0 -4
- package/dist/providers/claude-code-check-provider.d.ts.map +1 -1
- package/dist/sdk/{check-execution-engine-2EQWRXWI.mjs → check-execution-engine-PO5XKTHP.mjs} +2 -2
- package/dist/sdk/{chunk-GNA5GPF7.mjs → chunk-G24UL45Z.mjs} +246 -275
- package/dist/sdk/chunk-G24UL45Z.mjs.map +1 -0
- package/dist/sdk/sdk.js +247 -277
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +1 -1
- package/dist/session-registry.d.ts +5 -0
- package/dist/session-registry.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/sdk/chunk-GNA5GPF7.mjs.map +0 -1
- /package/dist/sdk/{check-execution-engine-2EQWRXWI.mjs.map → check-execution-engine-PO5XKTHP.mjs.map} +0 -0
|
@@ -20,7 +20,9 @@ var init_session_registry = __esm({
|
|
|
20
20
|
SessionRegistry = class _SessionRegistry {
|
|
21
21
|
static instance;
|
|
22
22
|
sessions = /* @__PURE__ */ new Map();
|
|
23
|
+
exitHandlerRegistered = false;
|
|
23
24
|
constructor() {
|
|
25
|
+
this.registerExitHandlers();
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Get the singleton instance of SessionRegistry
|
|
@@ -54,7 +56,15 @@ var init_session_registry = __esm({
|
|
|
54
56
|
unregisterSession(sessionId) {
|
|
55
57
|
if (this.sessions.has(sessionId)) {
|
|
56
58
|
console.error(`\u{1F5D1}\uFE0F Unregistering AI session: ${sessionId}`);
|
|
59
|
+
const agent = this.sessions.get(sessionId);
|
|
57
60
|
this.sessions.delete(sessionId);
|
|
61
|
+
if (agent && typeof agent.cleanup === "function") {
|
|
62
|
+
try {
|
|
63
|
+
agent.cleanup();
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(`\u26A0\uFE0F Warning: Failed to cleanup ProbeAgent: ${error}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
/**
|
|
@@ -62,6 +72,14 @@ var init_session_registry = __esm({
|
|
|
62
72
|
*/
|
|
63
73
|
clearAllSessions() {
|
|
64
74
|
console.error(`\u{1F9F9} Clearing all AI sessions (${this.sessions.size} sessions)`);
|
|
75
|
+
for (const [, agent] of this.sessions.entries()) {
|
|
76
|
+
if (agent && typeof agent.cleanup === "function") {
|
|
77
|
+
try {
|
|
78
|
+
agent.cleanup();
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
65
83
|
this.sessions.clear();
|
|
66
84
|
}
|
|
67
85
|
/**
|
|
@@ -76,6 +94,44 @@ var init_session_registry = __esm({
|
|
|
76
94
|
hasSession(sessionId) {
|
|
77
95
|
return this.sessions.has(sessionId);
|
|
78
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Register process exit handlers to cleanup sessions on exit
|
|
99
|
+
*/
|
|
100
|
+
registerExitHandlers() {
|
|
101
|
+
if (this.exitHandlerRegistered) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const cleanupAndExit = (signal) => {
|
|
105
|
+
if (this.sessions.size > 0) {
|
|
106
|
+
console.error(`
|
|
107
|
+
\u{1F9F9} [${signal}] Cleaning up ${this.sessions.size} active AI sessions...`);
|
|
108
|
+
this.clearAllSessions();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
process.on("exit", () => {
|
|
112
|
+
if (this.sessions.size > 0) {
|
|
113
|
+
console.error(`\u{1F9F9} [exit] Cleaning up ${this.sessions.size} active AI sessions...`);
|
|
114
|
+
for (const [, agent] of this.sessions.entries()) {
|
|
115
|
+
if (agent && typeof agent.cleanup === "function") {
|
|
116
|
+
try {
|
|
117
|
+
agent.cleanup();
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
this.sessions.clear();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
process.on("SIGINT", () => {
|
|
126
|
+
cleanupAndExit("SIGINT");
|
|
127
|
+
process.exit(0);
|
|
128
|
+
});
|
|
129
|
+
process.on("SIGTERM", () => {
|
|
130
|
+
cleanupAndExit("SIGTERM");
|
|
131
|
+
process.exit(0);
|
|
132
|
+
});
|
|
133
|
+
this.exitHandlerRegistered = true;
|
|
134
|
+
}
|
|
79
135
|
};
|
|
80
136
|
}
|
|
81
137
|
});
|
|
@@ -1493,7 +1549,7 @@ var PRReviewer = class {
|
|
|
1493
1549
|
async reviewPR(owner, repo, prNumber, prInfo, options = {}) {
|
|
1494
1550
|
const { debug = false, config, checks } = options;
|
|
1495
1551
|
if (config && checks && checks.length > 0) {
|
|
1496
|
-
const { CheckExecutionEngine: CheckExecutionEngine2 } = await import("./check-execution-engine-
|
|
1552
|
+
const { CheckExecutionEngine: CheckExecutionEngine2 } = await import("./check-execution-engine-PO5XKTHP.mjs");
|
|
1497
1553
|
const engine = new CheckExecutionEngine2();
|
|
1498
1554
|
const { results } = await engine.executeGroupedChecks(
|
|
1499
1555
|
prInfo,
|
|
@@ -2141,17 +2197,6 @@ var IssueFilter = class {
|
|
|
2141
2197
|
// src/providers/ai-check-provider.ts
|
|
2142
2198
|
import fs3 from "fs/promises";
|
|
2143
2199
|
import path3 from "path";
|
|
2144
|
-
|
|
2145
|
-
// src/providers/claude-code-types.ts
|
|
2146
|
-
async function safeImport(moduleName) {
|
|
2147
|
-
try {
|
|
2148
|
-
return await import(moduleName);
|
|
2149
|
-
} catch {
|
|
2150
|
-
return null;
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
// src/providers/ai-check-provider.ts
|
|
2155
2200
|
var AICheckProvider = class extends CheckProvider {
|
|
2156
2201
|
aiReviewService;
|
|
2157
2202
|
liquidEngine;
|
|
@@ -2429,54 +2474,6 @@ var AICheckProvider = class extends CheckProvider {
|
|
|
2429
2474
|
);
|
|
2430
2475
|
}
|
|
2431
2476
|
}
|
|
2432
|
-
/**
|
|
2433
|
-
* Setup MCP tools based on AI configuration
|
|
2434
|
-
*/
|
|
2435
|
-
async setupMcpTools(aiConfig) {
|
|
2436
|
-
const tools = [];
|
|
2437
|
-
if (aiConfig.mcpServers) {
|
|
2438
|
-
try {
|
|
2439
|
-
const mcpModule = await safeImport("@modelcontextprotocol/sdk");
|
|
2440
|
-
if (!mcpModule) {
|
|
2441
|
-
console.warn("@modelcontextprotocol/sdk package not found. MCP servers disabled.");
|
|
2442
|
-
return tools;
|
|
2443
|
-
}
|
|
2444
|
-
const createSdkMcpServer = mcpModule.createSdkMcpServer || mcpModule.default?.createSdkMcpServer;
|
|
2445
|
-
if (typeof createSdkMcpServer === "function") {
|
|
2446
|
-
for (const [serverName, serverConfig] of Object.entries(aiConfig.mcpServers)) {
|
|
2447
|
-
try {
|
|
2448
|
-
const server = await createSdkMcpServer({
|
|
2449
|
-
name: serverName,
|
|
2450
|
-
command: serverConfig.command,
|
|
2451
|
-
args: serverConfig.args || [],
|
|
2452
|
-
env: { ...process.env, ...serverConfig.env }
|
|
2453
|
-
});
|
|
2454
|
-
const serverTools = await server.listTools();
|
|
2455
|
-
tools.push(
|
|
2456
|
-
...serverTools.map((tool) => ({
|
|
2457
|
-
name: tool.name,
|
|
2458
|
-
server: serverName
|
|
2459
|
-
}))
|
|
2460
|
-
);
|
|
2461
|
-
} catch (serverError) {
|
|
2462
|
-
console.warn(
|
|
2463
|
-
`Failed to setup MCP server ${serverName}: ${serverError instanceof Error ? serverError.message : "Unknown error"}`
|
|
2464
|
-
);
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
|
-
} else {
|
|
2468
|
-
console.warn(
|
|
2469
|
-
"createSdkMcpServer function not found in @modelcontextprotocol/sdk. MCP servers disabled."
|
|
2470
|
-
);
|
|
2471
|
-
}
|
|
2472
|
-
} catch (error) {
|
|
2473
|
-
console.warn(
|
|
2474
|
-
`Failed to import MCP SDK: ${error instanceof Error ? error.message : "Unknown error"}. MCP servers disabled.`
|
|
2475
|
-
);
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
return tools;
|
|
2479
|
-
}
|
|
2480
2477
|
async execute(prInfo, config, _dependencyResults, sessionInfo) {
|
|
2481
2478
|
if (config.env) {
|
|
2482
2479
|
const result = EnvironmentResolver.withTemporaryEnv(config.env, () => {
|
|
@@ -2533,11 +2530,9 @@ var AICheckProvider = class extends CheckProvider {
|
|
|
2533
2530
|
}
|
|
2534
2531
|
if (Object.keys(mcpServers).length > 0) {
|
|
2535
2532
|
aiConfig.mcpServers = mcpServers;
|
|
2536
|
-
const mcpConfig = { mcpServers };
|
|
2537
|
-
const mcpTools = await this.setupMcpTools(mcpConfig);
|
|
2538
2533
|
if (aiConfig.debug) {
|
|
2539
2534
|
console.error(
|
|
2540
|
-
`\u{1F527} Debug: AI check MCP configured with ${Object.keys(mcpServers).length} servers
|
|
2535
|
+
`\u{1F527} Debug: AI check MCP configured with ${Object.keys(mcpServers).length} servers`
|
|
2541
2536
|
);
|
|
2542
2537
|
}
|
|
2543
2538
|
}
|
|
@@ -3367,6 +3362,17 @@ var LogCheckProvider = class extends CheckProvider {
|
|
|
3367
3362
|
// src/providers/claude-code-check-provider.ts
|
|
3368
3363
|
import fs4 from "fs/promises";
|
|
3369
3364
|
import path4 from "path";
|
|
3365
|
+
|
|
3366
|
+
// src/providers/claude-code-types.ts
|
|
3367
|
+
async function safeImport(moduleName) {
|
|
3368
|
+
try {
|
|
3369
|
+
return await import(moduleName);
|
|
3370
|
+
} catch {
|
|
3371
|
+
return null;
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3375
|
+
// src/providers/claude-code-check-provider.ts
|
|
3370
3376
|
function isClaudeCodeConstructor(value) {
|
|
3371
3377
|
return typeof value === "function";
|
|
3372
3378
|
}
|
|
@@ -3468,59 +3474,6 @@ var ClaudeCodeCheckProvider = class extends CheckProvider {
|
|
|
3468
3474
|
);
|
|
3469
3475
|
}
|
|
3470
3476
|
}
|
|
3471
|
-
/**
|
|
3472
|
-
* Setup MCP tools based on configuration
|
|
3473
|
-
*/
|
|
3474
|
-
async setupMcpTools(config) {
|
|
3475
|
-
const tools = [];
|
|
3476
|
-
if (config.allowedTools) {
|
|
3477
|
-
for (const toolName of config.allowedTools) {
|
|
3478
|
-
tools.push({ name: toolName });
|
|
3479
|
-
}
|
|
3480
|
-
}
|
|
3481
|
-
if (config.mcpServers) {
|
|
3482
|
-
try {
|
|
3483
|
-
const mcpModule = await safeImport("@modelcontextprotocol/sdk");
|
|
3484
|
-
if (!mcpModule) {
|
|
3485
|
-
console.warn("@modelcontextprotocol/sdk package not found. MCP servers disabled.");
|
|
3486
|
-
return tools;
|
|
3487
|
-
}
|
|
3488
|
-
const createSdkMcpServer = mcpModule.createSdkMcpServer || mcpModule.default?.createSdkMcpServer;
|
|
3489
|
-
if (typeof createSdkMcpServer === "function") {
|
|
3490
|
-
for (const [serverName, serverConfig] of Object.entries(config.mcpServers)) {
|
|
3491
|
-
try {
|
|
3492
|
-
const server = await createSdkMcpServer({
|
|
3493
|
-
name: serverName,
|
|
3494
|
-
command: serverConfig.command,
|
|
3495
|
-
args: serverConfig.args || [],
|
|
3496
|
-
env: { ...process.env, ...serverConfig.env }
|
|
3497
|
-
});
|
|
3498
|
-
const serverTools = await server.listTools();
|
|
3499
|
-
tools.push(
|
|
3500
|
-
...serverTools.map((tool) => ({
|
|
3501
|
-
name: tool.name,
|
|
3502
|
-
server: serverName
|
|
3503
|
-
}))
|
|
3504
|
-
);
|
|
3505
|
-
} catch (serverError) {
|
|
3506
|
-
console.warn(
|
|
3507
|
-
`Failed to setup MCP server ${serverName}: ${serverError instanceof Error ? serverError.message : "Unknown error"}`
|
|
3508
|
-
);
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
} else {
|
|
3512
|
-
console.warn(
|
|
3513
|
-
"createSdkMcpServer function not found in @modelcontextprotocol/sdk. MCP servers disabled."
|
|
3514
|
-
);
|
|
3515
|
-
}
|
|
3516
|
-
} catch (error) {
|
|
3517
|
-
console.warn(
|
|
3518
|
-
`Failed to import MCP SDK: ${error instanceof Error ? error.message : "Unknown error"}. MCP servers disabled.`
|
|
3519
|
-
);
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
|
-
return tools;
|
|
3523
|
-
}
|
|
3524
3477
|
/**
|
|
3525
3478
|
* Group files by their file extension for template context
|
|
3526
3479
|
*/
|
|
@@ -3751,14 +3704,18 @@ var ClaudeCodeCheckProvider = class extends CheckProvider {
|
|
|
3751
3704
|
const startTime = Date.now();
|
|
3752
3705
|
try {
|
|
3753
3706
|
const client = await this.initializeClaudeCodeClient();
|
|
3754
|
-
const tools = await this.setupMcpTools(claudeCodeConfig);
|
|
3755
3707
|
const query = {
|
|
3756
3708
|
query: processedPrompt,
|
|
3757
|
-
tools: tools.length > 0 ? tools : void 0,
|
|
3758
3709
|
maxTurns: claudeCodeConfig.maxTurns || 5,
|
|
3759
3710
|
systemPrompt: claudeCodeConfig.systemPrompt,
|
|
3760
3711
|
subagent: claudeCodeConfig.subagent
|
|
3761
3712
|
};
|
|
3713
|
+
if (claudeCodeConfig.allowedTools && claudeCodeConfig.allowedTools.length > 0) {
|
|
3714
|
+
query.tools = claudeCodeConfig.allowedTools.map((name) => ({ name }));
|
|
3715
|
+
}
|
|
3716
|
+
if (claudeCodeConfig.mcpServers && Object.keys(claudeCodeConfig.mcpServers).length > 0) {
|
|
3717
|
+
query.mcpServers = claudeCodeConfig.mcpServers;
|
|
3718
|
+
}
|
|
3762
3719
|
let response;
|
|
3763
3720
|
if (sessionInfo?.reuseSession && sessionInfo.parentSessionId) {
|
|
3764
3721
|
response = await client.query({
|
|
@@ -3786,8 +3743,7 @@ var ClaudeCodeCheckProvider = class extends CheckProvider {
|
|
|
3786
3743
|
// Claude Code specific debug info
|
|
3787
3744
|
sessionId: response.session_id,
|
|
3788
3745
|
turnCount: response.turn_count,
|
|
3789
|
-
usage: response.usage
|
|
3790
|
-
toolsUsed: tools.map((t) => t.name)
|
|
3746
|
+
usage: response.usage
|
|
3791
3747
|
};
|
|
3792
3748
|
const suppressionEnabled = config.suppressionEnabled !== false;
|
|
3793
3749
|
const issueFilter = new IssueFilter(suppressionEnabled);
|
|
@@ -7099,172 +7055,187 @@ ${expr}
|
|
|
7099
7055
|
let finalResult;
|
|
7100
7056
|
if (isForEachDependent && forEachParentName) {
|
|
7101
7057
|
this.recordForEachPreview(checkName, forEachItems);
|
|
7102
|
-
if (
|
|
7103
|
-
|
|
7104
|
-
|
|
7058
|
+
if (forEachItems.length === 0) {
|
|
7059
|
+
if (debug) {
|
|
7060
|
+
log2(
|
|
7061
|
+
`\u{1F504} Debug: Skipping check "${checkName}" - forEach check "${forEachParentName}" returned 0 items`
|
|
7062
|
+
);
|
|
7063
|
+
}
|
|
7064
|
+
logger.info(` forEach: no items from "${forEachParentName}", skipping check...`);
|
|
7065
|
+
finalResult = {
|
|
7066
|
+
issues: [],
|
|
7067
|
+
output: []
|
|
7068
|
+
};
|
|
7069
|
+
finalResult.isForEach = true;
|
|
7070
|
+
finalResult.forEachItems = [];
|
|
7071
|
+
} else {
|
|
7072
|
+
if (debug) {
|
|
7073
|
+
log2(
|
|
7074
|
+
`\u{1F504} Debug: Check "${checkName}" depends on forEach check "${forEachParentName}", executing ${forEachItems.length} times`
|
|
7075
|
+
);
|
|
7076
|
+
}
|
|
7077
|
+
logger.info(
|
|
7078
|
+
` forEach: processing ${forEachItems.length} items from "${forEachParentName}"...`
|
|
7105
7079
|
);
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
}
|
|
7128
|
-
forEachDependencyResults.set(`${depName}-raw`, rawResult);
|
|
7080
|
+
const allIssues = [];
|
|
7081
|
+
const allOutputs = [];
|
|
7082
|
+
const aggregatedContents = [];
|
|
7083
|
+
const itemTasks = forEachItems.map((item, itemIndex) => async () => {
|
|
7084
|
+
const forEachDependencyResults = /* @__PURE__ */ new Map();
|
|
7085
|
+
for (const [depName, depResult] of dependencyResults) {
|
|
7086
|
+
if (forEachParents.includes(depName)) {
|
|
7087
|
+
const depForEachResult = depResult;
|
|
7088
|
+
if (Array.isArray(depForEachResult.output) && depForEachResult.output[itemIndex] !== void 0) {
|
|
7089
|
+
const modifiedResult = {
|
|
7090
|
+
issues: [],
|
|
7091
|
+
output: depForEachResult.output[itemIndex]
|
|
7092
|
+
};
|
|
7093
|
+
forEachDependencyResults.set(depName, modifiedResult);
|
|
7094
|
+
const rawResult = {
|
|
7095
|
+
issues: [],
|
|
7096
|
+
output: depForEachResult.output
|
|
7097
|
+
};
|
|
7098
|
+
forEachDependencyResults.set(`${depName}-raw`, rawResult);
|
|
7099
|
+
} else {
|
|
7100
|
+
forEachDependencyResults.set(depName, depResult);
|
|
7101
|
+
}
|
|
7129
7102
|
} else {
|
|
7130
7103
|
forEachDependencyResults.set(depName, depResult);
|
|
7131
7104
|
}
|
|
7132
|
-
} else {
|
|
7133
|
-
forEachDependencyResults.set(depName, depResult);
|
|
7134
7105
|
}
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7106
|
+
if (checkConfig.if) {
|
|
7107
|
+
const conditionResults = new Map(results);
|
|
7108
|
+
for (const [depName, depResult] of forEachDependencyResults) {
|
|
7109
|
+
conditionResults.set(depName, depResult);
|
|
7110
|
+
}
|
|
7111
|
+
const shouldRun = await this.evaluateCheckCondition(
|
|
7112
|
+
checkName,
|
|
7113
|
+
checkConfig.if,
|
|
7114
|
+
prInfo,
|
|
7115
|
+
conditionResults,
|
|
7116
|
+
debug
|
|
7117
|
+
);
|
|
7118
|
+
if (!shouldRun) {
|
|
7119
|
+
if (debug) {
|
|
7120
|
+
log2(
|
|
7121
|
+
`\u{1F504} Debug: Skipping forEach item ${itemIndex + 1} for check "${checkName}" (if condition evaluated to false)`
|
|
7122
|
+
);
|
|
7123
|
+
}
|
|
7124
|
+
return {
|
|
7125
|
+
index: itemIndex,
|
|
7126
|
+
itemResult: { issues: [] },
|
|
7127
|
+
skipped: true
|
|
7128
|
+
};
|
|
7129
|
+
}
|
|
7140
7130
|
}
|
|
7141
|
-
|
|
7131
|
+
if (debug) {
|
|
7132
|
+
log2(
|
|
7133
|
+
`\u{1F504} Debug: Executing check "${checkName}" for item ${itemIndex + 1}/${forEachItems.length}`
|
|
7134
|
+
);
|
|
7135
|
+
}
|
|
7136
|
+
const iterationStart = this.recordIterationStart(checkName);
|
|
7137
|
+
const itemResult = await this.executeWithRouting(
|
|
7142
7138
|
checkName,
|
|
7143
|
-
checkConfig
|
|
7139
|
+
checkConfig,
|
|
7140
|
+
provider,
|
|
7141
|
+
providerConfig,
|
|
7144
7142
|
prInfo,
|
|
7145
|
-
|
|
7146
|
-
|
|
7143
|
+
forEachDependencyResults,
|
|
7144
|
+
sessionInfo,
|
|
7145
|
+
config,
|
|
7146
|
+
dependencyGraph,
|
|
7147
|
+
debug,
|
|
7148
|
+
results,
|
|
7149
|
+
/*foreachContext*/
|
|
7150
|
+
{
|
|
7151
|
+
index: itemIndex,
|
|
7152
|
+
total: forEachItems.length,
|
|
7153
|
+
parent: forEachParentName
|
|
7154
|
+
}
|
|
7147
7155
|
);
|
|
7148
|
-
|
|
7156
|
+
const hadFatalError = (itemResult.issues || []).some((issue) => {
|
|
7157
|
+
const id = issue.ruleId || "";
|
|
7158
|
+
return id === "command/execution_error" || id.endsWith("/command/execution_error") || id === "command/transform_js_error" || id.endsWith("/command/transform_js_error") || id === "command/transform_error" || id.endsWith("/command/transform_error");
|
|
7159
|
+
});
|
|
7160
|
+
const iterationDuration = (Date.now() - iterationStart) / 1e3;
|
|
7161
|
+
this.recordIterationComplete(
|
|
7162
|
+
checkName,
|
|
7163
|
+
iterationStart,
|
|
7164
|
+
!hadFatalError,
|
|
7165
|
+
// Success if no fatal errors
|
|
7166
|
+
itemResult.issues || [],
|
|
7167
|
+
itemResult.output
|
|
7168
|
+
);
|
|
7169
|
+
logger.info(
|
|
7170
|
+
` \u2714 ${itemIndex + 1}/${forEachItems.length} (${iterationDuration.toFixed(1)}s)`
|
|
7171
|
+
);
|
|
7172
|
+
return { index: itemIndex, itemResult };
|
|
7173
|
+
});
|
|
7174
|
+
const forEachConcurrency = Math.max(
|
|
7175
|
+
1,
|
|
7176
|
+
Math.min(forEachItems.length, effectiveMaxParallelism)
|
|
7177
|
+
);
|
|
7178
|
+
if (debug && forEachConcurrency > 1) {
|
|
7179
|
+
log2(
|
|
7180
|
+
`\u{1F504} Debug: Limiting forEach concurrency for check "${checkName}" to ${forEachConcurrency}`
|
|
7181
|
+
);
|
|
7182
|
+
}
|
|
7183
|
+
const forEachResults = await this.executeWithLimitedParallelism(
|
|
7184
|
+
itemTasks,
|
|
7185
|
+
forEachConcurrency,
|
|
7186
|
+
false
|
|
7187
|
+
);
|
|
7188
|
+
for (const result of forEachResults) {
|
|
7189
|
+
if (result.status === "rejected") {
|
|
7190
|
+
const error = result.reason;
|
|
7191
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7192
|
+
allIssues.push({
|
|
7193
|
+
ruleId: `${checkName}/forEach/iteration_error`,
|
|
7194
|
+
severity: "error",
|
|
7195
|
+
category: "logic",
|
|
7196
|
+
message: `forEach iteration failed: ${errorMessage}`,
|
|
7197
|
+
file: "",
|
|
7198
|
+
line: 0
|
|
7199
|
+
});
|
|
7149
7200
|
if (debug) {
|
|
7150
7201
|
log2(
|
|
7151
|
-
`\u{1F504} Debug:
|
|
7202
|
+
`\u{1F504} Debug: forEach iteration for check "${checkName}" failed: ${errorMessage}`
|
|
7152
7203
|
);
|
|
7153
7204
|
}
|
|
7154
|
-
|
|
7155
|
-
index: itemIndex,
|
|
7156
|
-
itemResult: { issues: [] },
|
|
7157
|
-
skipped: true
|
|
7158
|
-
};
|
|
7205
|
+
continue;
|
|
7159
7206
|
}
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
log2(
|
|
7163
|
-
`\u{1F504} Debug: Executing check "${checkName}" for item ${itemIndex + 1}/${forEachItems.length}`
|
|
7164
|
-
);
|
|
7165
|
-
}
|
|
7166
|
-
const iterationStart = this.recordIterationStart(checkName);
|
|
7167
|
-
const itemResult = await this.executeWithRouting(
|
|
7168
|
-
checkName,
|
|
7169
|
-
checkConfig,
|
|
7170
|
-
provider,
|
|
7171
|
-
providerConfig,
|
|
7172
|
-
prInfo,
|
|
7173
|
-
forEachDependencyResults,
|
|
7174
|
-
sessionInfo,
|
|
7175
|
-
config,
|
|
7176
|
-
dependencyGraph,
|
|
7177
|
-
debug,
|
|
7178
|
-
results,
|
|
7179
|
-
/*foreachContext*/
|
|
7180
|
-
{
|
|
7181
|
-
index: itemIndex,
|
|
7182
|
-
total: forEachItems.length,
|
|
7183
|
-
parent: forEachParentName
|
|
7207
|
+
if (result.value.skipped) {
|
|
7208
|
+
continue;
|
|
7184
7209
|
}
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
itemResult.issues || [],
|
|
7197
|
-
itemResult.output
|
|
7198
|
-
);
|
|
7199
|
-
logger.info(
|
|
7200
|
-
` \u2714 ${itemIndex + 1}/${forEachItems.length} (${iterationDuration.toFixed(1)}s)`
|
|
7201
|
-
);
|
|
7202
|
-
return { index: itemIndex, itemResult };
|
|
7203
|
-
});
|
|
7204
|
-
const forEachConcurrency = Math.max(
|
|
7205
|
-
1,
|
|
7206
|
-
Math.min(forEachItems.length, effectiveMaxParallelism)
|
|
7207
|
-
);
|
|
7208
|
-
if (debug && forEachConcurrency > 1) {
|
|
7209
|
-
log2(
|
|
7210
|
-
`\u{1F504} Debug: Limiting forEach concurrency for check "${checkName}" to ${forEachConcurrency}`
|
|
7211
|
-
);
|
|
7212
|
-
}
|
|
7213
|
-
const forEachResults = await this.executeWithLimitedParallelism(
|
|
7214
|
-
itemTasks,
|
|
7215
|
-
forEachConcurrency,
|
|
7216
|
-
false
|
|
7217
|
-
);
|
|
7218
|
-
for (const result of forEachResults) {
|
|
7219
|
-
if (result.status === "rejected") {
|
|
7220
|
-
const error = result.reason;
|
|
7221
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7222
|
-
allIssues.push({
|
|
7223
|
-
ruleId: `${checkName}/forEach/iteration_error`,
|
|
7224
|
-
severity: "error",
|
|
7225
|
-
category: "logic",
|
|
7226
|
-
message: `forEach iteration failed: ${errorMessage}`,
|
|
7227
|
-
file: "",
|
|
7228
|
-
line: 0
|
|
7229
|
-
});
|
|
7230
|
-
if (debug) {
|
|
7231
|
-
log2(
|
|
7232
|
-
`\u{1F504} Debug: forEach iteration for check "${checkName}" failed: ${errorMessage}`
|
|
7233
|
-
);
|
|
7210
|
+
const { itemResult } = result.value;
|
|
7211
|
+
if (itemResult.issues) {
|
|
7212
|
+
allIssues.push(...itemResult.issues);
|
|
7213
|
+
}
|
|
7214
|
+
const resultWithOutput = itemResult;
|
|
7215
|
+
if (resultWithOutput.output !== void 0) {
|
|
7216
|
+
allOutputs.push(resultWithOutput.output);
|
|
7217
|
+
}
|
|
7218
|
+
const itemContent = resultWithOutput.content;
|
|
7219
|
+
if (typeof itemContent === "string" && itemContent.trim()) {
|
|
7220
|
+
aggregatedContents.push(itemContent.trim());
|
|
7234
7221
|
}
|
|
7235
|
-
continue;
|
|
7236
|
-
}
|
|
7237
|
-
if (result.value.skipped) {
|
|
7238
|
-
continue;
|
|
7239
|
-
}
|
|
7240
|
-
const { itemResult } = result.value;
|
|
7241
|
-
if (itemResult.issues) {
|
|
7242
|
-
allIssues.push(...itemResult.issues);
|
|
7243
7222
|
}
|
|
7244
|
-
const
|
|
7245
|
-
|
|
7246
|
-
|
|
7223
|
+
const finalOutput = allOutputs.length > 0 ? allOutputs : void 0;
|
|
7224
|
+
finalResult = {
|
|
7225
|
+
issues: allIssues,
|
|
7226
|
+
...finalOutput !== void 0 ? { output: finalOutput } : {}
|
|
7227
|
+
};
|
|
7228
|
+
if (allOutputs.length > 0) {
|
|
7229
|
+
finalResult.isForEach = true;
|
|
7230
|
+
finalResult.forEachItems = allOutputs;
|
|
7247
7231
|
}
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
aggregatedContents.push(itemContent.trim());
|
|
7232
|
+
if (aggregatedContents.length > 0) {
|
|
7233
|
+
finalResult.content = aggregatedContents.join("\n");
|
|
7251
7234
|
}
|
|
7235
|
+
log2(
|
|
7236
|
+
`\u{1F504} Debug: Completed forEach execution for check "${checkName}", total issues: ${allIssues.length}`
|
|
7237
|
+
);
|
|
7252
7238
|
}
|
|
7253
|
-
const finalOutput = allOutputs.length > 0 ? allOutputs : void 0;
|
|
7254
|
-
finalResult = {
|
|
7255
|
-
issues: allIssues,
|
|
7256
|
-
...finalOutput !== void 0 ? { output: finalOutput } : {}
|
|
7257
|
-
};
|
|
7258
|
-
if (allOutputs.length > 0) {
|
|
7259
|
-
finalResult.isForEach = true;
|
|
7260
|
-
finalResult.forEachItems = allOutputs;
|
|
7261
|
-
}
|
|
7262
|
-
if (aggregatedContents.length > 0) {
|
|
7263
|
-
finalResult.content = aggregatedContents.join("\n");
|
|
7264
|
-
}
|
|
7265
|
-
log2(
|
|
7266
|
-
`\u{1F504} Debug: Completed forEach execution for check "${checkName}", total issues: ${allIssues.length}`
|
|
7267
|
-
);
|
|
7268
7239
|
} else {
|
|
7269
7240
|
if (checkConfig.if) {
|
|
7270
7241
|
const shouldRun = await this.evaluateCheckCondition(
|
|
@@ -7493,14 +7464,6 @@ ${expr}
|
|
|
7493
7464
|
}
|
|
7494
7465
|
}
|
|
7495
7466
|
}
|
|
7496
|
-
const executionStatistics = this.buildExecutionStatistics();
|
|
7497
|
-
if (logFn === console.log) {
|
|
7498
|
-
this.logExecutionSummary(executionStatistics);
|
|
7499
|
-
}
|
|
7500
|
-
if (shouldStopExecution) {
|
|
7501
|
-
logger.info("");
|
|
7502
|
-
logger.warn(`\u26A0\uFE0F Execution stopped early due to fail-fast`);
|
|
7503
|
-
}
|
|
7504
7467
|
if (debug) {
|
|
7505
7468
|
if (shouldStopExecution) {
|
|
7506
7469
|
log2(
|
|
@@ -7521,6 +7484,14 @@ ${expr}
|
|
|
7521
7484
|
}
|
|
7522
7485
|
}
|
|
7523
7486
|
}
|
|
7487
|
+
const executionStatistics = this.buildExecutionStatistics();
|
|
7488
|
+
if (logFn === console.log) {
|
|
7489
|
+
this.logExecutionSummary(executionStatistics);
|
|
7490
|
+
}
|
|
7491
|
+
if (shouldStopExecution) {
|
|
7492
|
+
logger.info("");
|
|
7493
|
+
logger.warn(`\u26A0\uFE0F Execution stopped early due to fail-fast`);
|
|
7494
|
+
}
|
|
7524
7495
|
return this.aggregateDependencyAwareResults(
|
|
7525
7496
|
results,
|
|
7526
7497
|
dependencyGraph,
|
|
@@ -8677,4 +8648,4 @@ export {
|
|
|
8677
8648
|
logger,
|
|
8678
8649
|
CheckExecutionEngine
|
|
8679
8650
|
};
|
|
8680
|
-
//# sourceMappingURL=chunk-
|
|
8651
|
+
//# sourceMappingURL=chunk-G24UL45Z.mjs.map
|