@probelabs/visor 0.1.81 → 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.
@@ -1549,7 +1549,7 @@ var PRReviewer = class {
1549
1549
  async reviewPR(owner, repo, prNumber, prInfo, options = {}) {
1550
1550
  const { debug = false, config, checks } = options;
1551
1551
  if (config && checks && checks.length > 0) {
1552
- const { CheckExecutionEngine: CheckExecutionEngine2 } = await import("./check-execution-engine-47OZJFUV.mjs");
1552
+ const { CheckExecutionEngine: CheckExecutionEngine2 } = await import("./check-execution-engine-PO5XKTHP.mjs");
1553
1553
  const engine = new CheckExecutionEngine2();
1554
1554
  const { results } = await engine.executeGroupedChecks(
1555
1555
  prInfo,
@@ -7055,172 +7055,187 @@ ${expr}
7055
7055
  let finalResult;
7056
7056
  if (isForEachDependent && forEachParentName) {
7057
7057
  this.recordForEachPreview(checkName, forEachItems);
7058
- if (debug) {
7059
- log2(
7060
- `\u{1F504} Debug: Check "${checkName}" depends on forEach check "${forEachParentName}", executing ${forEachItems.length} times`
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}"...`
7061
7079
  );
7062
- }
7063
- logger.info(
7064
- ` forEach: processing ${forEachItems.length} items from "${forEachParentName}"...`
7065
- );
7066
- const allIssues = [];
7067
- const allOutputs = [];
7068
- const aggregatedContents = [];
7069
- const itemTasks = forEachItems.map((item, itemIndex) => async () => {
7070
- const forEachDependencyResults = /* @__PURE__ */ new Map();
7071
- for (const [depName, depResult] of dependencyResults) {
7072
- if (forEachParents.includes(depName)) {
7073
- const depForEachResult = depResult;
7074
- if (Array.isArray(depForEachResult.output) && depForEachResult.output[itemIndex] !== void 0) {
7075
- const modifiedResult = {
7076
- issues: [],
7077
- output: depForEachResult.output[itemIndex]
7078
- };
7079
- forEachDependencyResults.set(depName, modifiedResult);
7080
- const rawResult = {
7081
- issues: [],
7082
- output: depForEachResult.output
7083
- };
7084
- 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
+ }
7085
7102
  } else {
7086
7103
  forEachDependencyResults.set(depName, depResult);
7087
7104
  }
7088
- } else {
7089
- forEachDependencyResults.set(depName, depResult);
7090
7105
  }
7091
- }
7092
- if (checkConfig.if) {
7093
- const conditionResults = new Map(results);
7094
- for (const [depName, depResult] of forEachDependencyResults) {
7095
- conditionResults.set(depName, depResult);
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
+ }
7096
7130
  }
7097
- const shouldRun = await this.evaluateCheckCondition(
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(
7098
7138
  checkName,
7099
- checkConfig.if,
7139
+ checkConfig,
7140
+ provider,
7141
+ providerConfig,
7100
7142
  prInfo,
7101
- conditionResults,
7102
- debug
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
+ }
7103
7155
  );
7104
- if (!shouldRun) {
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
+ });
7105
7200
  if (debug) {
7106
7201
  log2(
7107
- `\u{1F504} Debug: Skipping forEach item ${itemIndex + 1} for check "${checkName}" (if condition evaluated to false)`
7202
+ `\u{1F504} Debug: forEach iteration for check "${checkName}" failed: ${errorMessage}`
7108
7203
  );
7109
7204
  }
7110
- return {
7111
- index: itemIndex,
7112
- itemResult: { issues: [] },
7113
- skipped: true
7114
- };
7205
+ continue;
7115
7206
  }
7116
- }
7117
- if (debug) {
7118
- log2(
7119
- `\u{1F504} Debug: Executing check "${checkName}" for item ${itemIndex + 1}/${forEachItems.length}`
7120
- );
7121
- }
7122
- const iterationStart = this.recordIterationStart(checkName);
7123
- const itemResult = await this.executeWithRouting(
7124
- checkName,
7125
- checkConfig,
7126
- provider,
7127
- providerConfig,
7128
- prInfo,
7129
- forEachDependencyResults,
7130
- sessionInfo,
7131
- config,
7132
- dependencyGraph,
7133
- debug,
7134
- results,
7135
- /*foreachContext*/
7136
- {
7137
- index: itemIndex,
7138
- total: forEachItems.length,
7139
- parent: forEachParentName
7207
+ if (result.value.skipped) {
7208
+ continue;
7140
7209
  }
7141
- );
7142
- const hadFatalError = (itemResult.issues || []).some((issue) => {
7143
- const id = issue.ruleId || "";
7144
- 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");
7145
- });
7146
- const iterationDuration = (Date.now() - iterationStart) / 1e3;
7147
- this.recordIterationComplete(
7148
- checkName,
7149
- iterationStart,
7150
- !hadFatalError,
7151
- // Success if no fatal errors
7152
- itemResult.issues || [],
7153
- itemResult.output
7154
- );
7155
- logger.info(
7156
- ` \u2714 ${itemIndex + 1}/${forEachItems.length} (${iterationDuration.toFixed(1)}s)`
7157
- );
7158
- return { index: itemIndex, itemResult };
7159
- });
7160
- const forEachConcurrency = Math.max(
7161
- 1,
7162
- Math.min(forEachItems.length, effectiveMaxParallelism)
7163
- );
7164
- if (debug && forEachConcurrency > 1) {
7165
- log2(
7166
- `\u{1F504} Debug: Limiting forEach concurrency for check "${checkName}" to ${forEachConcurrency}`
7167
- );
7168
- }
7169
- const forEachResults = await this.executeWithLimitedParallelism(
7170
- itemTasks,
7171
- forEachConcurrency,
7172
- false
7173
- );
7174
- for (const result of forEachResults) {
7175
- if (result.status === "rejected") {
7176
- const error = result.reason;
7177
- const errorMessage = error instanceof Error ? error.message : String(error);
7178
- allIssues.push({
7179
- ruleId: `${checkName}/forEach/iteration_error`,
7180
- severity: "error",
7181
- category: "logic",
7182
- message: `forEach iteration failed: ${errorMessage}`,
7183
- file: "",
7184
- line: 0
7185
- });
7186
- if (debug) {
7187
- log2(
7188
- `\u{1F504} Debug: forEach iteration for check "${checkName}" failed: ${errorMessage}`
7189
- );
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());
7190
7221
  }
7191
- continue;
7192
- }
7193
- if (result.value.skipped) {
7194
- continue;
7195
- }
7196
- const { itemResult } = result.value;
7197
- if (itemResult.issues) {
7198
- allIssues.push(...itemResult.issues);
7199
7222
  }
7200
- const resultWithOutput = itemResult;
7201
- if (resultWithOutput.output !== void 0) {
7202
- allOutputs.push(resultWithOutput.output);
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;
7203
7231
  }
7204
- const itemContent = resultWithOutput.content;
7205
- if (typeof itemContent === "string" && itemContent.trim()) {
7206
- aggregatedContents.push(itemContent.trim());
7232
+ if (aggregatedContents.length > 0) {
7233
+ finalResult.content = aggregatedContents.join("\n");
7207
7234
  }
7235
+ log2(
7236
+ `\u{1F504} Debug: Completed forEach execution for check "${checkName}", total issues: ${allIssues.length}`
7237
+ );
7208
7238
  }
7209
- const finalOutput = allOutputs.length > 0 ? allOutputs : void 0;
7210
- finalResult = {
7211
- issues: allIssues,
7212
- ...finalOutput !== void 0 ? { output: finalOutput } : {}
7213
- };
7214
- if (allOutputs.length > 0) {
7215
- finalResult.isForEach = true;
7216
- finalResult.forEachItems = allOutputs;
7217
- }
7218
- if (aggregatedContents.length > 0) {
7219
- finalResult.content = aggregatedContents.join("\n");
7220
- }
7221
- log2(
7222
- `\u{1F504} Debug: Completed forEach execution for check "${checkName}", total issues: ${allIssues.length}`
7223
- );
7224
7239
  } else {
7225
7240
  if (checkConfig.if) {
7226
7241
  const shouldRun = await this.evaluateCheckCondition(
@@ -8633,4 +8648,4 @@ export {
8633
8648
  logger,
8634
8649
  CheckExecutionEngine
8635
8650
  };
8636
- //# sourceMappingURL=chunk-V5PUTL5N.mjs.map
8651
+ //# sourceMappingURL=chunk-G24UL45Z.mjs.map