@code-sentinel-cli/code-sentinel-cli 4.0.14 → 4.0.16
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/bin.js +251 -53
- package/dist/builtin-rules/static/general/function-too-long.rule.js +3 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +251 -53
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -37674,7 +37674,7 @@ Language guard retry: the previous response contained an empty or English explan
|
|
|
37674
37674
|
return { status: "error", vulnerable: false, reason: `L\u1ED7i th\u1EF1c thi LLM: ${message}` };
|
|
37675
37675
|
}
|
|
37676
37676
|
}
|
|
37677
|
-
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, DEFAULT_MAX_RETRIES, DEFAULT_BASE_DELAY_MS, DEFAULT_MAX_DELAY_MS, DEFAULT_RESET_SAFETY_MS, DEFAULT_JITTER_MS, sleep, isRateLimitError, parseProviderRetryDelayMs, rateLimitRetryDelayMs, createRateLimitRetryClient, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, createInMemoryCache, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, renderAuthorizationGuards, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep2, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize2, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf25, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint, checkAiConnection;
|
|
37677
|
+
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, DEFAULT_MAX_RETRIES, DEFAULT_BASE_DELAY_MS, DEFAULT_MAX_DELAY_MS, DEFAULT_RESET_SAFETY_MS, DEFAULT_JITTER_MS, sleep, isRateLimitError, parseProviderRetryDelayMs, rateLimitRetryDelayMs, createRateLimitRetryClient, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, createInMemoryCache, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, renderAuthorizationGuards, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep2, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize2, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf25, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, SEVERITY_ALIASES, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint, checkAiConnection;
|
|
37678
37678
|
var init_dist4 = __esm({
|
|
37679
37679
|
"../ai-engine/dist/index.js"() {
|
|
37680
37680
|
init_dist();
|
|
@@ -40230,7 +40230,27 @@ ${file.content}
|
|
|
40230
40230
|
return parts.join("\n");
|
|
40231
40231
|
};
|
|
40232
40232
|
confidenceLabelSchema = external_exports.enum(["low", "medium", "high"]).optional();
|
|
40233
|
-
|
|
40233
|
+
SEVERITY_ALIASES = {
|
|
40234
|
+
info: "info",
|
|
40235
|
+
low: "info",
|
|
40236
|
+
minor: "info",
|
|
40237
|
+
note: "info",
|
|
40238
|
+
suggestion: "info",
|
|
40239
|
+
warning: "warning",
|
|
40240
|
+
warn: "warning",
|
|
40241
|
+
medium: "warning",
|
|
40242
|
+
moderate: "warning",
|
|
40243
|
+
error: "error",
|
|
40244
|
+
high: "error",
|
|
40245
|
+
major: "error",
|
|
40246
|
+
blocker: "blocker",
|
|
40247
|
+
critical: "blocker",
|
|
40248
|
+
fatal: "blocker"
|
|
40249
|
+
};
|
|
40250
|
+
severitySchema = external_exports.preprocess(
|
|
40251
|
+
(value) => typeof value === "string" ? SEVERITY_ALIASES[value.trim().toLowerCase()] : void 0,
|
|
40252
|
+
external_exports.enum(["info", "warning", "error", "blocker"]).optional()
|
|
40253
|
+
);
|
|
40234
40254
|
groupedResponseSchema = external_exports.object({
|
|
40235
40255
|
ruleResults: external_exports.array(
|
|
40236
40256
|
external_exports.object({
|
|
@@ -59285,6 +59305,8 @@ var init_schema = __esm({
|
|
|
59285
59305
|
minSeverity: severitySchema3.default("info"),
|
|
59286
59306
|
minConfidence: configInt({ min: 0, max: 100, default: 80 }),
|
|
59287
59307
|
applyBaseline: configBool({ default: false }),
|
|
59308
|
+
// Static findings outside the MR's changed lines are dropped by default (report + gate).
|
|
59309
|
+
includeUnchangedLines: configBool({ default: false }),
|
|
59288
59310
|
aiStrategy: prAiStrategySchema.default("smart"),
|
|
59289
59311
|
diffReview: external_exports.object({
|
|
59290
59312
|
enabled: configBool({ default: true }),
|
|
@@ -59425,6 +59447,7 @@ var init_schema = __esm({
|
|
|
59425
59447
|
minSeverity: "info",
|
|
59426
59448
|
minConfidence: 80,
|
|
59427
59449
|
applyBaseline: false,
|
|
59450
|
+
includeUnchangedLines: false,
|
|
59428
59451
|
aiStrategy: "smart",
|
|
59429
59452
|
diffReview: { enabled: true, maxChunkCalls: 8 },
|
|
59430
59453
|
primarySelection: {
|
|
@@ -60364,11 +60387,11 @@ var definedBuildValue = (value, fallback) => typeof value === "string" && value.
|
|
|
60364
60387
|
var getCliBuildMetadata = (version2) => ({
|
|
60365
60388
|
version: version2,
|
|
60366
60389
|
gitSha: definedBuildValue(
|
|
60367
|
-
"
|
|
60390
|
+
"9da49e9424a8" ,
|
|
60368
60391
|
"unknown"
|
|
60369
60392
|
),
|
|
60370
60393
|
buildTimestamp: definedBuildValue(
|
|
60371
|
-
"2026-11-
|
|
60394
|
+
"2026-11-27T06:51:28.365Z" ,
|
|
60372
60395
|
"unknown"
|
|
60373
60396
|
),
|
|
60374
60397
|
configSchemaRange: definedBuildValue(
|
|
@@ -66481,6 +66504,9 @@ var collectPrRuleGroups = (rules, options = {}) => {
|
|
|
66481
66504
|
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
66482
66505
|
};
|
|
66483
66506
|
var classifyRuleApplicability = (rule, profile) => {
|
|
66507
|
+
if (profile.file.language !== void 0 && rule.languages.length > 0 && !rule.languages.includes(profile.file.language)) {
|
|
66508
|
+
return PR_RULE_APPLICABILITY.NOT_APPLICABLE;
|
|
66509
|
+
}
|
|
66484
66510
|
const routing = rule.prRouting;
|
|
66485
66511
|
if (!routing) return PR_RULE_APPLICABILITY.UNKNOWN;
|
|
66486
66512
|
if (routing.targetLayers.length > 0 && !routing.targetLayers.includes(profile.layer)) {
|
|
@@ -66963,6 +66989,31 @@ var createOneShotPhaseLogger = (env = process.env) => {
|
|
|
66963
66989
|
}
|
|
66964
66990
|
};
|
|
66965
66991
|
};
|
|
66992
|
+
|
|
66993
|
+
// src/review-gate.ts
|
|
66994
|
+
init_dist2();
|
|
66995
|
+
init_exit_codes();
|
|
66996
|
+
var resolveGatePolicy = (configGate, override, skipOverride) => ({
|
|
66997
|
+
aiPolicy: override ?? configGate.aiPolicy,
|
|
66998
|
+
aiMinConfidence: configGate.aiMinConfidence,
|
|
66999
|
+
aiSkipPolicy: skipOverride ?? configGate.aiSkipPolicy
|
|
67000
|
+
});
|
|
67001
|
+
var computeGateResult = (findings2, ruleKindById, policy) => {
|
|
67002
|
+
let gatingBlocker = 0;
|
|
67003
|
+
let gatingError = 0;
|
|
67004
|
+
let advisoryErrorPlus = 0;
|
|
67005
|
+
for (const f of findings2) {
|
|
67006
|
+
const source = ruleKindById.get(f.ruleId) === "ai" ? "ai" : "deterministic";
|
|
67007
|
+
if (findingGates(f, source, policy)) {
|
|
67008
|
+
if (f.severity === "blocker") gatingBlocker++;
|
|
67009
|
+
else if (f.severity === "error") gatingError++;
|
|
67010
|
+
} else if (source === "ai" && meetsSeverity(f.severity, "error")) {
|
|
67011
|
+
advisoryErrorPlus++;
|
|
67012
|
+
}
|
|
67013
|
+
}
|
|
67014
|
+
const exitCode = gatingBlocker > 0 ? EXIT.FINDINGS_BLOCKER : gatingError > 0 ? EXIT.FINDINGS_ERROR : EXIT.SUCCESS;
|
|
67015
|
+
return { exitCode, gatingError, gatingBlocker, advisoryErrorPlus };
|
|
67016
|
+
};
|
|
66966
67017
|
var Counters = ({ counts, sourceCounts }) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
66967
67018
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
66968
67019
|
/* @__PURE__ */ jsx(Text, { color: "blue", children: "\u258C" }),
|
|
@@ -67418,8 +67469,17 @@ var dedupePrFindings = (findings2) => {
|
|
|
67418
67469
|
}
|
|
67419
67470
|
return [...byKey.values()];
|
|
67420
67471
|
};
|
|
67421
|
-
var
|
|
67422
|
-
|
|
67472
|
+
var touchesChangedLines = (finding, lineMap) => {
|
|
67473
|
+
const last = Math.max(finding.range.line, finding.range.endLine ?? finding.range.line);
|
|
67474
|
+
for (let line2 = finding.range.line; line2 <= last; line2 += 1) {
|
|
67475
|
+
if (getDiffLinePosition(lineMap, finding.file, line2)) return true;
|
|
67476
|
+
}
|
|
67477
|
+
return false;
|
|
67478
|
+
};
|
|
67479
|
+
var mergePrCandidateFindings = (staticFindings, aiFindings, changedPaths, lineMap, includeUnchangedLines = false) => dedupePrFindings([
|
|
67480
|
+
...staticFindings.filter(
|
|
67481
|
+
(finding) => changedPaths.has(finding.file) && (includeUnchangedLines || touchesChangedLines(finding, lineMap))
|
|
67482
|
+
),
|
|
67423
67483
|
...aiFindings
|
|
67424
67484
|
]);
|
|
67425
67485
|
|
|
@@ -67670,6 +67730,9 @@ var createGitLabClient = (options) => {
|
|
|
67670
67730
|
if (!result.ok) return result;
|
|
67671
67731
|
return toMergeRequest(result.value);
|
|
67672
67732
|
},
|
|
67733
|
+
async fetchCurrentUser() {
|
|
67734
|
+
return request("GET", "/user");
|
|
67735
|
+
},
|
|
67673
67736
|
async listNotes(target) {
|
|
67674
67737
|
return requestAllPages(mrPath(target, "/notes"));
|
|
67675
67738
|
},
|
|
@@ -67698,6 +67761,27 @@ var createGitLabClient = (options) => {
|
|
|
67698
67761
|
});
|
|
67699
67762
|
if (!result.ok) return result;
|
|
67700
67763
|
return ok(void 0);
|
|
67764
|
+
},
|
|
67765
|
+
async listDiscussions(target) {
|
|
67766
|
+
return requestAllPages(mrPath(target, "/discussions"));
|
|
67767
|
+
},
|
|
67768
|
+
async compareCommits(target, from, to) {
|
|
67769
|
+
const query = `from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}&straight=true`;
|
|
67770
|
+
const result = await request(
|
|
67771
|
+
"GET",
|
|
67772
|
+
`/projects/${encodeProjectPath(target.projectPath)}/repository/compare?${query}`
|
|
67773
|
+
);
|
|
67774
|
+
if (!result.ok) return result;
|
|
67775
|
+
return ok(result.value.diffs ?? []);
|
|
67776
|
+
},
|
|
67777
|
+
async resolveDiscussion(target, discussionId) {
|
|
67778
|
+
const result = await request(
|
|
67779
|
+
"PUT",
|
|
67780
|
+
mrPath(target, `/discussions/${encodeURIComponent(discussionId)}`),
|
|
67781
|
+
{ resolved: true }
|
|
67782
|
+
);
|
|
67783
|
+
if (!result.ok) return result;
|
|
67784
|
+
return ok(void 0);
|
|
67701
67785
|
}
|
|
67702
67786
|
};
|
|
67703
67787
|
};
|
|
@@ -67706,9 +67790,13 @@ var createGitLabClient = (options) => {
|
|
|
67706
67790
|
init_dist2();
|
|
67707
67791
|
init_dist5();
|
|
67708
67792
|
init_dist();
|
|
67709
|
-
var
|
|
67793
|
+
var summaryMarker = (kind) => `<!-- code-sentinel:pr-review:${kind} -->`;
|
|
67794
|
+
var LEGACY_SUMMARY_MARKER = "<!-- code-sentinel:pr-review -->";
|
|
67795
|
+
var SUMMARY_MARKER_PATTERN = /<!-- code-sentinel:pr-review(?::(static|ai))? -->/;
|
|
67710
67796
|
var fingerprintMarker = (fingerprint) => `<!-- code-sentinel:finding ${fingerprint} -->`;
|
|
67711
67797
|
var FINDING_MARKER_PATTERN = /code-sentinel:finding\s+([a-f0-9]+)/g;
|
|
67798
|
+
var inlineKindMarker = (kind) => `<!-- code-sentinel:kind ${kind} -->`;
|
|
67799
|
+
var INLINE_KIND_PATTERN = /code-sentinel:kind (static|ai)/;
|
|
67712
67800
|
var SEVERITIES = ["blocker", "error", "warning", "info"];
|
|
67713
67801
|
var escapeTableCell2 = (value) => value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>");
|
|
67714
67802
|
var countBySeverity3 = (findings2) => {
|
|
@@ -67727,9 +67815,10 @@ var renderPrSummary = (options) => {
|
|
|
67727
67815
|
...options.summaryOnly
|
|
67728
67816
|
].sort(compareFindings);
|
|
67729
67817
|
const severityCounts = countBySeverity3(allFindings);
|
|
67818
|
+
const kind = options.reviewKind ?? "static";
|
|
67730
67819
|
const lines = [
|
|
67731
|
-
|
|
67732
|
-
|
|
67820
|
+
summaryMarker(kind),
|
|
67821
|
+
`## Code Sentinel PR Review Report (${kind === "ai" ? "AI + static" : "static"})`,
|
|
67733
67822
|
"",
|
|
67734
67823
|
`**Run**: \`${options.runId}\``,
|
|
67735
67824
|
"",
|
|
@@ -67774,8 +67863,9 @@ var renderPrSummary = (options) => {
|
|
|
67774
67863
|
}
|
|
67775
67864
|
return lines.join("\n");
|
|
67776
67865
|
};
|
|
67777
|
-
var renderInlineComment = (item16) => [
|
|
67866
|
+
var renderInlineComment = (item16, kind) => [
|
|
67778
67867
|
fingerprintMarker(item16.fingerprint),
|
|
67868
|
+
inlineKindMarker(kind),
|
|
67779
67869
|
`**${item16.finding.ruleId}** (${item16.finding.severity})`,
|
|
67780
67870
|
"",
|
|
67781
67871
|
item16.finding.message,
|
|
@@ -67783,7 +67873,92 @@ var renderInlineComment = (item16) => [
|
|
|
67783
67873
|
item16.finding.suggestion ? `
|
|
67784
67874
|
Suggestion: ${item16.finding.suggestion}` : ""
|
|
67785
67875
|
].filter((part) => part.length > 0).join("\n");
|
|
67786
|
-
var isCodeSentinelNote = (body) =>
|
|
67876
|
+
var isCodeSentinelNote = (body) => SUMMARY_MARKER_PATTERN.test(body) || body.includes("code-sentinel:finding");
|
|
67877
|
+
var isOwnNote = (note, currentUserId) => note.author === void 0 ? true : currentUserId !== null && note.author.id === currentUserId;
|
|
67878
|
+
var isOwnSummaryOfKind = (note, kind, currentUserId) => isOwnNote(note, currentUserId) && (note.body.includes(summaryMarker(kind)) || note.body.includes(LEGACY_SUMMARY_MARKER));
|
|
67879
|
+
var touchedOldLines = (diff) => {
|
|
67880
|
+
const touched = /* @__PURE__ */ new Set();
|
|
67881
|
+
let oldLine = 0;
|
|
67882
|
+
for (const line2 of diff.split("\n")) {
|
|
67883
|
+
const hunk = /^@@ -(\d+)(?:,\d+)? \+\d+(?:,\d+)? @@/.exec(line2);
|
|
67884
|
+
if (hunk) {
|
|
67885
|
+
oldLine = Number(hunk[1]);
|
|
67886
|
+
continue;
|
|
67887
|
+
}
|
|
67888
|
+
if (line2.startsWith("-")) {
|
|
67889
|
+
touched.add(oldLine);
|
|
67890
|
+
oldLine++;
|
|
67891
|
+
} else if (line2.startsWith("+") || line2.startsWith("\\")) ; else {
|
|
67892
|
+
oldLine++;
|
|
67893
|
+
}
|
|
67894
|
+
}
|
|
67895
|
+
return touched;
|
|
67896
|
+
};
|
|
67897
|
+
var pruneStaleOwnFindings = async (options, kind, currentUserId) => {
|
|
67898
|
+
const removedNoteIds = /* @__PURE__ */ new Set();
|
|
67899
|
+
const standing = /* @__PURE__ */ new Set();
|
|
67900
|
+
const discussions = await options.client.listDiscussions(options.target);
|
|
67901
|
+
if (!discussions.ok) return discussions;
|
|
67902
|
+
const current = new Set(options.inlineable.map((item16) => item16.fingerprint));
|
|
67903
|
+
const touchedByFrom = /* @__PURE__ */ new Map();
|
|
67904
|
+
const codeChanged = async (head) => {
|
|
67905
|
+
const from = head.position?.head_sha;
|
|
67906
|
+
const path = head.position?.new_path;
|
|
67907
|
+
const line2 = head.position?.new_line;
|
|
67908
|
+
if (!options.headSha || !from || !path || !line2 || from === options.headSha) return ok(false);
|
|
67909
|
+
let byPath = touchedByFrom.get(from);
|
|
67910
|
+
if (!byPath) {
|
|
67911
|
+
const diffs = await options.client.compareCommits(options.target, from, options.headSha);
|
|
67912
|
+
if (!diffs.ok) return diffs;
|
|
67913
|
+
byPath = new Map(diffs.value.map((d) => [d.old_path, touchedOldLines(d.diff)]));
|
|
67914
|
+
touchedByFrom.set(from, byPath);
|
|
67915
|
+
}
|
|
67916
|
+
return ok(byPath.get(path)?.has(line2) ?? false);
|
|
67917
|
+
};
|
|
67918
|
+
let deleted = 0;
|
|
67919
|
+
let resolved = 0;
|
|
67920
|
+
for (const discussion of discussions.value) {
|
|
67921
|
+
const head = discussion.notes[0];
|
|
67922
|
+
if (!head) continue;
|
|
67923
|
+
let prune = false;
|
|
67924
|
+
if (currentUserId !== null && isStaleOwnFinding(head, kind, currentUserId, current)) {
|
|
67925
|
+
const changed = await codeChanged(head);
|
|
67926
|
+
if (!changed.ok) return changed;
|
|
67927
|
+
prune = changed.value;
|
|
67928
|
+
}
|
|
67929
|
+
if (!prune) {
|
|
67930
|
+
const key = standingKey(head);
|
|
67931
|
+
if (key) standing.add(key);
|
|
67932
|
+
continue;
|
|
67933
|
+
}
|
|
67934
|
+
if (discussion.notes.length === 1) {
|
|
67935
|
+
const result = await options.client.deleteNote(options.target, head.id);
|
|
67936
|
+
if (!result.ok) return result;
|
|
67937
|
+
removedNoteIds.add(head.id);
|
|
67938
|
+
deleted++;
|
|
67939
|
+
} else {
|
|
67940
|
+
const result = await options.client.resolveDiscussion(options.target, discussion.id);
|
|
67941
|
+
if (!result.ok) return result;
|
|
67942
|
+
resolved++;
|
|
67943
|
+
}
|
|
67944
|
+
}
|
|
67945
|
+
return ok({ deleted, resolved, removedNoteIds, standing });
|
|
67946
|
+
};
|
|
67947
|
+
var standingKey = (note) => {
|
|
67948
|
+
const ruleId = /\*\*([^*\s]+)\*\*/.exec(note.body)?.[1];
|
|
67949
|
+
const path = note.position?.new_path;
|
|
67950
|
+
const line2 = note.position?.new_line;
|
|
67951
|
+
if (!ruleId || !path || !line2 || !note.body.includes("code-sentinel:finding")) return null;
|
|
67952
|
+
return `${ruleId}|${path}|${line2}`;
|
|
67953
|
+
};
|
|
67954
|
+
var itemKey = (item16) => `${item16.finding.ruleId}|${item16.position.newPath}|${item16.position.newLine ?? ""}`;
|
|
67955
|
+
var isStaleOwnFinding = (head, kind, currentUserId, current) => {
|
|
67956
|
+
if (head.author?.id !== currentUserId || head.resolved === true) return false;
|
|
67957
|
+
const fingerprint = /code-sentinel:finding\s+([a-f0-9]+)/.exec(head.body)?.[1];
|
|
67958
|
+
if (!fingerprint || current.has(fingerprint)) return false;
|
|
67959
|
+
const noteKind = INLINE_KIND_PATTERN.exec(head.body)?.[1];
|
|
67960
|
+
return noteKind === void 0 || noteKind === kind;
|
|
67961
|
+
};
|
|
67787
67962
|
var publishPrReview = async (options) => {
|
|
67788
67963
|
const summaryBody = renderPrSummary(options);
|
|
67789
67964
|
if (options.dryRun) {
|
|
@@ -67792,23 +67967,32 @@ var publishPrReview = async (options) => {
|
|
|
67792
67967
|
inlinePosted: 0,
|
|
67793
67968
|
inlineSkipped: 0,
|
|
67794
67969
|
inlineFailed: 0,
|
|
67795
|
-
deletedExisting: 0
|
|
67970
|
+
deletedExisting: 0,
|
|
67971
|
+
staleDeleted: 0,
|
|
67972
|
+
staleResolved: 0
|
|
67796
67973
|
});
|
|
67797
67974
|
}
|
|
67975
|
+
const kind = options.reviewKind ?? "static";
|
|
67976
|
+
const currentUser = await options.client.fetchCurrentUser();
|
|
67977
|
+
const currentUserId = currentUser.ok ? currentUser.value.id : null;
|
|
67798
67978
|
const notesResult = await options.client.listNotes(options.target);
|
|
67799
67979
|
if (!notesResult.ok) return notesResult;
|
|
67800
67980
|
let activeNotes = notesResult.value;
|
|
67801
67981
|
let deletedExisting = 0;
|
|
67802
67982
|
if (options.cleanupExistingComments) {
|
|
67983
|
+
const kept = [];
|
|
67803
67984
|
for (const note of activeNotes) {
|
|
67804
|
-
if (!isCodeSentinelNote(note.body))
|
|
67985
|
+
if (!isCodeSentinelNote(note.body) || !isOwnNote(note, currentUserId)) {
|
|
67986
|
+
kept.push(note);
|
|
67987
|
+
continue;
|
|
67988
|
+
}
|
|
67805
67989
|
const deleted = await options.client.deleteNote(options.target, note.id);
|
|
67806
67990
|
if (!deleted.ok) return deleted;
|
|
67807
67991
|
deletedExisting++;
|
|
67808
67992
|
}
|
|
67809
|
-
activeNotes =
|
|
67993
|
+
activeNotes = kept;
|
|
67810
67994
|
}
|
|
67811
|
-
const existingSummary = activeNotes.find((note) => note
|
|
67995
|
+
const existingSummary = activeNotes.find((note) => isOwnSummaryOfKind(note, kind, currentUserId));
|
|
67812
67996
|
if (existingSummary) {
|
|
67813
67997
|
const updated = await options.client.updateNote(
|
|
67814
67998
|
options.target,
|
|
@@ -67821,10 +68005,21 @@ var publishPrReview = async (options) => {
|
|
|
67821
68005
|
if (!created.ok) return created;
|
|
67822
68006
|
}
|
|
67823
68007
|
if (options.summaryOnlyMode) {
|
|
67824
|
-
return ok({
|
|
68008
|
+
return ok({
|
|
68009
|
+
summaryBody,
|
|
68010
|
+
inlinePosted: 0,
|
|
68011
|
+
inlineSkipped: 0,
|
|
68012
|
+
inlineFailed: 0,
|
|
68013
|
+
deletedExisting,
|
|
68014
|
+
staleDeleted: 0,
|
|
68015
|
+
staleResolved: 0
|
|
68016
|
+
});
|
|
67825
68017
|
}
|
|
68018
|
+
const pruned = await pruneStaleOwnFindings(options, kind, currentUserId);
|
|
68019
|
+
if (!pruned.ok) return pruned;
|
|
67826
68020
|
const existingFingerprints = /* @__PURE__ */ new Set();
|
|
67827
68021
|
for (const note of activeNotes) {
|
|
68022
|
+
if (pruned.value.removedNoteIds.has(note.id)) continue;
|
|
67828
68023
|
for (const match of note.body.matchAll(FINDING_MARKER_PATTERN)) {
|
|
67829
68024
|
if (match[1]) existingFingerprints.add(match[1]);
|
|
67830
68025
|
}
|
|
@@ -67834,13 +68029,13 @@ var publishPrReview = async (options) => {
|
|
|
67834
68029
|
let inlineSkipped = options.inlineable.length - budgeted.length;
|
|
67835
68030
|
let inlineFailed = 0;
|
|
67836
68031
|
for (const item16 of budgeted) {
|
|
67837
|
-
if (existingFingerprints.has(item16.fingerprint)) {
|
|
68032
|
+
if (existingFingerprints.has(item16.fingerprint) || pruned.value.standing.has(itemKey(item16))) {
|
|
67838
68033
|
inlineSkipped++;
|
|
67839
68034
|
continue;
|
|
67840
68035
|
}
|
|
67841
68036
|
const result = await options.client.createDiscussion(
|
|
67842
68037
|
options.target,
|
|
67843
|
-
renderInlineComment(item16),
|
|
68038
|
+
renderInlineComment(item16, kind),
|
|
67844
68039
|
item16.position
|
|
67845
68040
|
);
|
|
67846
68041
|
if (!result.ok) {
|
|
@@ -67849,7 +68044,15 @@ var publishPrReview = async (options) => {
|
|
|
67849
68044
|
}
|
|
67850
68045
|
inlinePosted++;
|
|
67851
68046
|
}
|
|
67852
|
-
return ok({
|
|
68047
|
+
return ok({
|
|
68048
|
+
summaryBody,
|
|
68049
|
+
inlinePosted,
|
|
68050
|
+
inlineSkipped,
|
|
68051
|
+
inlineFailed,
|
|
68052
|
+
deletedExisting,
|
|
68053
|
+
staleDeleted: pruned.value.deleted,
|
|
68054
|
+
staleResolved: pruned.value.resolved
|
|
68055
|
+
});
|
|
67853
68056
|
};
|
|
67854
68057
|
|
|
67855
68058
|
// src/pr/static-review.ts
|
|
@@ -68395,6 +68598,11 @@ var printDryRunSummary = (target, findings2, reportPaths, codeQualityPath) => {
|
|
|
68395
68598
|
}
|
|
68396
68599
|
console.log(green(` GitLab Code Quality: ${codeQualityPath}`));
|
|
68397
68600
|
};
|
|
68601
|
+
var computePrGate = (findings2, ruleKindById, configGate, aiGatePolicy) => computeGateResult(
|
|
68602
|
+
findings2,
|
|
68603
|
+
new Map([...ruleKindById, ["ai/pr-diff-review", "ai"]]),
|
|
68604
|
+
resolveGatePolicy(configGate, aiGatePolicy)
|
|
68605
|
+
);
|
|
68398
68606
|
var sourceCountsForFindings = (findings2, ruleKindById) => {
|
|
68399
68607
|
const counts = { static: 0, ai: 0 };
|
|
68400
68608
|
for (const finding of findings2) {
|
|
@@ -68924,7 +69132,7 @@ var runPrReview = async (options) => {
|
|
|
68924
69132
|
(finding) => changedPaths.has(finding.file)
|
|
68925
69133
|
);
|
|
68926
69134
|
const staticFindings = staticChangedFileFindings.filter(
|
|
68927
|
-
(finding) =>
|
|
69135
|
+
(finding) => touchesChangedLines(finding, lineMap)
|
|
68928
69136
|
);
|
|
68929
69137
|
const supportFiles = await buildSupportFiles(
|
|
68930
69138
|
staticResult.allSourceFiles,
|
|
@@ -69104,7 +69312,13 @@ var runPrReview = async (options) => {
|
|
|
69104
69312
|
}
|
|
69105
69313
|
const enrichFinding = createFindingContextEnricher(staticResult.allSourceFiles);
|
|
69106
69314
|
const mergedFindings = [
|
|
69107
|
-
...mergePrCandidateFindings(
|
|
69315
|
+
...mergePrCandidateFindings(
|
|
69316
|
+
staticResult.run.findings,
|
|
69317
|
+
aiFindings,
|
|
69318
|
+
changedPaths,
|
|
69319
|
+
lineMap,
|
|
69320
|
+
config.prReview.includeUnchangedLines
|
|
69321
|
+
)
|
|
69108
69322
|
].map(enrichFinding).sort(compareFindings);
|
|
69109
69323
|
const classified = classifyPrFindings(mergedFindings, changedPaths, lineMap);
|
|
69110
69324
|
const aiStats = mergePrAiStats(
|
|
@@ -69247,6 +69461,9 @@ var runPrReview = async (options) => {
|
|
|
69247
69461
|
staticResult.ruleKindById
|
|
69248
69462
|
),
|
|
69249
69463
|
maxInlineComments,
|
|
69464
|
+
// A static-only CI bot and a developer's AI run each keep their own MR summary.
|
|
69465
|
+
reviewKind: (aiStats?.succeeded ?? 0) > 0 ? "ai" : "static",
|
|
69466
|
+
headSha: mr.diffRefs.headSha,
|
|
69250
69467
|
summaryOnlyMode: options.summaryOnly,
|
|
69251
69468
|
cleanupExistingComments: config.prReview.cleanupExistingComments,
|
|
69252
69469
|
dryRun: !options.post
|
|
@@ -69278,7 +69495,7 @@ var runPrReview = async (options) => {
|
|
|
69278
69495
|
console.log(green(`Posted GitLab PR review for ${target.projectPath}!${target.iid}`));
|
|
69279
69496
|
console.log(
|
|
69280
69497
|
gray(
|
|
69281
|
-
` Deleted existing: ${publishResult.value.deletedExisting}; inline posted: ${publishResult.value.inlinePosted}; inline skipped: ${publishResult.value.inlineSkipped}; inline failed: ${publishResult.value.inlineFailed}`
|
|
69498
|
+
` Deleted existing: ${publishResult.value.deletedExisting}; inline posted: ${publishResult.value.inlinePosted}; inline skipped: ${publishResult.value.inlineSkipped}; inline failed: ${publishResult.value.inlineFailed}; stale removed: ${publishResult.value.staleDeleted}; stale resolved: ${publishResult.value.staleResolved}`
|
|
69282
69499
|
)
|
|
69283
69500
|
);
|
|
69284
69501
|
} else if (!options.silent) {
|
|
@@ -69291,16 +69508,17 @@ var runPrReview = async (options) => {
|
|
|
69291
69508
|
);
|
|
69292
69509
|
}
|
|
69293
69510
|
}
|
|
69294
|
-
|
|
69295
|
-
|
|
69296
|
-
|
|
69297
|
-
|
|
69298
|
-
|
|
69299
|
-
|
|
69300
|
-
|
|
69301
|
-
|
|
69302
|
-
|
|
69303
|
-
|
|
69511
|
+
const gate = computePrGate(
|
|
69512
|
+
mergedFindings,
|
|
69513
|
+
staticResult.ruleKindById,
|
|
69514
|
+
config.review.gate,
|
|
69515
|
+
options.aiGatePolicy
|
|
69516
|
+
);
|
|
69517
|
+
phaseLog.info(
|
|
69518
|
+
"quality-gate",
|
|
69519
|
+
`exit_code=${gate.exitCode} gating_blocker=${gate.gatingBlocker} gating_error=${gate.gatingError} advisory_ai_error_plus=${gate.advisoryErrorPlus}`
|
|
69520
|
+
);
|
|
69521
|
+
return gate.exitCode;
|
|
69304
69522
|
} catch (error) {
|
|
69305
69523
|
phaseLog.error(activeReviewPhase, error.message);
|
|
69306
69524
|
const renderer = getInkRenderer();
|
|
@@ -71362,27 +71580,6 @@ var SERVER_RUN_PROGRESS_PREFIX = "cs-progress ";
|
|
|
71362
71580
|
var log2 = (silent, msg) => {
|
|
71363
71581
|
if (!silent) console.log(msg);
|
|
71364
71582
|
};
|
|
71365
|
-
var resolveGatePolicy = (configGate, override, skipOverride) => ({
|
|
71366
|
-
aiPolicy: override ?? configGate.aiPolicy,
|
|
71367
|
-
aiMinConfidence: configGate.aiMinConfidence,
|
|
71368
|
-
aiSkipPolicy: skipOverride ?? configGate.aiSkipPolicy
|
|
71369
|
-
});
|
|
71370
|
-
var computeGateResult = (findings2, ruleKindById, policy) => {
|
|
71371
|
-
let gatingBlocker = 0;
|
|
71372
|
-
let gatingError = 0;
|
|
71373
|
-
let advisoryErrorPlus = 0;
|
|
71374
|
-
for (const f of findings2) {
|
|
71375
|
-
const source = ruleKindById.get(f.ruleId) === "ai" ? "ai" : "deterministic";
|
|
71376
|
-
if (findingGates(f, source, policy)) {
|
|
71377
|
-
if (f.severity === "blocker") gatingBlocker++;
|
|
71378
|
-
else if (f.severity === "error") gatingError++;
|
|
71379
|
-
} else if (source === "ai" && meetsSeverity(f.severity, "error")) {
|
|
71380
|
-
advisoryErrorPlus++;
|
|
71381
|
-
}
|
|
71382
|
-
}
|
|
71383
|
-
const exitCode = gatingBlocker > 0 ? EXIT.FINDINGS_BLOCKER : gatingError > 0 ? EXIT.FINDINGS_ERROR : EXIT.SUCCESS;
|
|
71384
|
-
return { exitCode, gatingError, gatingBlocker, advisoryErrorPlus };
|
|
71385
|
-
};
|
|
71386
71583
|
var escalateExitForCoverage = (baseExit, coverageBlocks) => baseExit === EXIT.SUCCESS && coverageBlocks ? EXIT.RUNTIME : baseExit;
|
|
71387
71584
|
var hasIncompleteQueuedFullCoverage = (isRunnerInvocation, runtimeSinceRef2, aiStats) => isRunnerInvocation && (runtimeSinceRef2 === void 0 || runtimeSinceRef2.length === 0) && aiStats !== void 0 && countRecallRiskSkips(aiStats) > 0;
|
|
71388
71585
|
var rulesToRerun = (aiStats) => {
|
|
@@ -71412,6 +71609,7 @@ var runReview = async (options = {}) => {
|
|
|
71412
71609
|
prWorkspace: options.prWorkspace,
|
|
71413
71610
|
prAiStrategy: options.prAiStrategy,
|
|
71414
71611
|
aiOff: options.aiOff === true,
|
|
71612
|
+
...options.aiGatePolicy !== void 0 ? { aiGatePolicy: options.aiGatePolicy } : {},
|
|
71415
71613
|
mode: options.mode,
|
|
71416
71614
|
...options.scope !== void 0 ? { scope: options.scope } : {},
|
|
71417
71615
|
minSeverity: options.minSeverity,
|
|
@@ -45,7 +45,7 @@ var collectFunctionNodes = (root) => {
|
|
|
45
45
|
var rule = {
|
|
46
46
|
id: "general/function-too-long",
|
|
47
47
|
// v5 (Tree-sitter multi-language refactor): TS/JS + Java support
|
|
48
|
-
version:
|
|
48
|
+
version: 6,
|
|
49
49
|
kind: "static-ts",
|
|
50
50
|
title: "H\xE0m qu\xE1 d\xE0i \u2014 t\xE1ch helper ho\u1EB7c step nh\u1ECF h\u01A1n",
|
|
51
51
|
description: "H\xE0m d\xE0i th\u01B0\u1EDDng g\xE1nh qu\xE1 nhi\u1EC1u tr\xE1ch nhi\u1EC7m. T\xE1ch th\xE0nh helpers nh\u1ECF gi\xFAp \u0111\u1EB7t t\xEAn c\xF3 ngh\u0129a, d\u1EC5 test, d\u1EC5 \u0111\u1ECDc. Threshold m\u1EB7c \u0111\u1ECBnh 80 d\xF2ng \u2014 tune qua `options.maxLines`.",
|
|
@@ -78,7 +78,8 @@ var rule = {
|
|
|
78
78
|
findings.push({
|
|
79
79
|
message: `H\xE0m "${getName(node)}" d\xE0i ${lines} d\xF2ng (gi\u1EDBi h\u1EA1n ${threshold}).`,
|
|
80
80
|
file: ctx.file.path,
|
|
81
|
-
|
|
81
|
+
// `endLine` lets PR review keep this finding when the MR grew the body but not the header.
|
|
82
|
+
range: { line: start, column: node.startPosition.column + 1, endLine: end },
|
|
82
83
|
suggestion: "T\xE1ch th\xE0nh helpers nh\u1ECF \u2014 m\u1ED7i helper \u0111\u1EA3m nhi\u1EC7m m\u1ED9t b\u01B0\u1EDBc r\xF5 r\xE0ng v\xE0 \u0111\u1EB7t t\xEAn c\xF3 ngh\u0129a."
|
|
83
84
|
});
|
|
84
85
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -852,6 +852,7 @@ declare const codeReviewConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
852
852
|
minSeverity: z.ZodDefault<z.ZodEnum<["info", "warning", "error", "blocker"]>>;
|
|
853
853
|
minConfidence: z.ZodUnion<[z.ZodNumber, z.ZodPipeline<z.ZodEffects<z.ZodString, number, string>, z.ZodNumber>]> | z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodPipeline<z.ZodEffects<z.ZodString, number, string>, z.ZodNumber>]>>;
|
|
854
854
|
applyBaseline: z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEnum<["true", "false", "1", "0"]>>, boolean, string>]> | z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEnum<["true", "false", "1", "0"]>>, boolean, string>]>>;
|
|
855
|
+
includeUnchangedLines: z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEnum<["true", "false", "1", "0"]>>, boolean, string>]> | z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEnum<["true", "false", "1", "0"]>>, boolean, string>]>>;
|
|
855
856
|
aiStrategy: z.ZodDefault<z.ZodEnum<["smart", "specialized"]>>;
|
|
856
857
|
diffReview: z.ZodDefault<z.ZodObject<{
|
|
857
858
|
enabled: z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEnum<["true", "false", "1", "0"]>>, boolean, string>]> | z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEnum<["true", "false", "1", "0"]>>, boolean, string>]>>;
|
|
@@ -991,6 +992,7 @@ declare const codeReviewConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
991
992
|
maxInlineComments: number;
|
|
992
993
|
minConfidence: number;
|
|
993
994
|
applyBaseline: boolean;
|
|
995
|
+
includeUnchangedLines: boolean;
|
|
994
996
|
aiStrategy: "smart" | "specialized";
|
|
995
997
|
diffReview: {
|
|
996
998
|
enabled: boolean;
|
|
@@ -1043,6 +1045,7 @@ declare const codeReviewConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1043
1045
|
maxInlineComments?: string | number | undefined;
|
|
1044
1046
|
minConfidence?: string | number | undefined;
|
|
1045
1047
|
applyBaseline?: string | boolean | undefined;
|
|
1048
|
+
includeUnchangedLines?: string | boolean | undefined;
|
|
1046
1049
|
aiStrategy?: "smart" | "specialized" | undefined;
|
|
1047
1050
|
diffReview?: {
|
|
1048
1051
|
enabled?: string | boolean | undefined;
|
|
@@ -1873,6 +1876,7 @@ declare const codeReviewConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1873
1876
|
maxInlineComments: number;
|
|
1874
1877
|
minConfidence: number;
|
|
1875
1878
|
applyBaseline: boolean;
|
|
1879
|
+
includeUnchangedLines: boolean;
|
|
1876
1880
|
aiStrategy: "smart" | "specialized";
|
|
1877
1881
|
diffReview: {
|
|
1878
1882
|
enabled: boolean;
|
|
@@ -2136,6 +2140,7 @@ declare const codeReviewConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2136
2140
|
maxInlineComments?: string | number | undefined;
|
|
2137
2141
|
minConfidence?: string | number | undefined;
|
|
2138
2142
|
applyBaseline?: string | boolean | undefined;
|
|
2143
|
+
includeUnchangedLines?: string | boolean | undefined;
|
|
2139
2144
|
aiStrategy?: "smart" | "specialized" | undefined;
|
|
2140
2145
|
diffReview?: {
|
|
2141
2146
|
enabled?: string | boolean | undefined;
|
|
@@ -2399,6 +2404,7 @@ declare const codeReviewConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2399
2404
|
maxInlineComments: number;
|
|
2400
2405
|
minConfidence: number;
|
|
2401
2406
|
applyBaseline: boolean;
|
|
2407
|
+
includeUnchangedLines: boolean;
|
|
2402
2408
|
aiStrategy: "smart" | "specialized";
|
|
2403
2409
|
diffReview: {
|
|
2404
2410
|
enabled: boolean;
|
|
@@ -3150,6 +3156,7 @@ interface ReviewProgressSession {
|
|
|
3150
3156
|
renderer: InkProgressRenderer | null;
|
|
3151
3157
|
state: ReviewProgressState | null;
|
|
3152
3158
|
}
|
|
3159
|
+
|
|
3153
3160
|
declare const runReview: (options?: ReviewOptions) => Promise<number>;
|
|
3154
3161
|
|
|
3155
3162
|
interface ResultsOptions {
|
package/dist/index.js
CHANGED
|
@@ -37674,7 +37674,7 @@ Language guard retry: the previous response contained an empty or English explan
|
|
|
37674
37674
|
return { status: "error", vulnerable: false, reason: `L\u1ED7i th\u1EF1c thi LLM: ${message}` };
|
|
37675
37675
|
}
|
|
37676
37676
|
}
|
|
37677
|
-
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, DEFAULT_MAX_RETRIES, DEFAULT_BASE_DELAY_MS, DEFAULT_MAX_DELAY_MS, DEFAULT_RESET_SAFETY_MS, DEFAULT_JITTER_MS, sleep, isRateLimitError, parseProviderRetryDelayMs, rateLimitRetryDelayMs, createRateLimitRetryClient, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, createInMemoryCache, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, renderAuthorizationGuards, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep2, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize2, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf25, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint, checkAiConnection;
|
|
37677
|
+
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, DEFAULT_MAX_RETRIES, DEFAULT_BASE_DELAY_MS, DEFAULT_MAX_DELAY_MS, DEFAULT_RESET_SAFETY_MS, DEFAULT_JITTER_MS, sleep, isRateLimitError, parseProviderRetryDelayMs, rateLimitRetryDelayMs, createRateLimitRetryClient, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, createInMemoryCache, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, renderAuthorizationGuards, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep2, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize2, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf25, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, SEVERITY_ALIASES, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint, checkAiConnection;
|
|
37678
37678
|
var init_dist4 = __esm({
|
|
37679
37679
|
"../ai-engine/dist/index.js"() {
|
|
37680
37680
|
init_dist();
|
|
@@ -40230,7 +40230,27 @@ ${file.content}
|
|
|
40230
40230
|
return parts.join("\n");
|
|
40231
40231
|
};
|
|
40232
40232
|
confidenceLabelSchema = external_exports.enum(["low", "medium", "high"]).optional();
|
|
40233
|
-
|
|
40233
|
+
SEVERITY_ALIASES = {
|
|
40234
|
+
info: "info",
|
|
40235
|
+
low: "info",
|
|
40236
|
+
minor: "info",
|
|
40237
|
+
note: "info",
|
|
40238
|
+
suggestion: "info",
|
|
40239
|
+
warning: "warning",
|
|
40240
|
+
warn: "warning",
|
|
40241
|
+
medium: "warning",
|
|
40242
|
+
moderate: "warning",
|
|
40243
|
+
error: "error",
|
|
40244
|
+
high: "error",
|
|
40245
|
+
major: "error",
|
|
40246
|
+
blocker: "blocker",
|
|
40247
|
+
critical: "blocker",
|
|
40248
|
+
fatal: "blocker"
|
|
40249
|
+
};
|
|
40250
|
+
severitySchema = external_exports.preprocess(
|
|
40251
|
+
(value) => typeof value === "string" ? SEVERITY_ALIASES[value.trim().toLowerCase()] : void 0,
|
|
40252
|
+
external_exports.enum(["info", "warning", "error", "blocker"]).optional()
|
|
40253
|
+
);
|
|
40234
40254
|
groupedResponseSchema = external_exports.object({
|
|
40235
40255
|
ruleResults: external_exports.array(
|
|
40236
40256
|
external_exports.object({
|
|
@@ -59285,6 +59305,8 @@ var init_schema = __esm({
|
|
|
59285
59305
|
minSeverity: severitySchema3.default("info"),
|
|
59286
59306
|
minConfidence: configInt({ min: 0, max: 100, default: 80 }),
|
|
59287
59307
|
applyBaseline: configBool({ default: false }),
|
|
59308
|
+
// Static findings outside the MR's changed lines are dropped by default (report + gate).
|
|
59309
|
+
includeUnchangedLines: configBool({ default: false }),
|
|
59288
59310
|
aiStrategy: prAiStrategySchema.default("smart"),
|
|
59289
59311
|
diffReview: external_exports.object({
|
|
59290
59312
|
enabled: configBool({ default: true }),
|
|
@@ -59425,6 +59447,7 @@ var init_schema = __esm({
|
|
|
59425
59447
|
minSeverity: "info",
|
|
59426
59448
|
minConfidence: 80,
|
|
59427
59449
|
applyBaseline: false,
|
|
59450
|
+
includeUnchangedLines: false,
|
|
59428
59451
|
aiStrategy: "smart",
|
|
59429
59452
|
diffReview: { enabled: true, maxChunkCalls: 8 },
|
|
59430
59453
|
primarySelection: {
|
|
@@ -60364,11 +60387,11 @@ var definedBuildValue = (value, fallback) => typeof value === "string" && value.
|
|
|
60364
60387
|
var getCliBuildMetadata = (version2) => ({
|
|
60365
60388
|
version: version2,
|
|
60366
60389
|
gitSha: definedBuildValue(
|
|
60367
|
-
"
|
|
60390
|
+
"9da49e9424a8" ,
|
|
60368
60391
|
"unknown"
|
|
60369
60392
|
),
|
|
60370
60393
|
buildTimestamp: definedBuildValue(
|
|
60371
|
-
"2026-11-
|
|
60394
|
+
"2026-11-27T06:51:28.365Z" ,
|
|
60372
60395
|
"unknown"
|
|
60373
60396
|
),
|
|
60374
60397
|
configSchemaRange: definedBuildValue(
|
|
@@ -66511,6 +66534,9 @@ var collectPrRuleGroups = (rules, options = {}) => {
|
|
|
66511
66534
|
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
66512
66535
|
};
|
|
66513
66536
|
var classifyRuleApplicability = (rule, profile) => {
|
|
66537
|
+
if (profile.file.language !== void 0 && rule.languages.length > 0 && !rule.languages.includes(profile.file.language)) {
|
|
66538
|
+
return PR_RULE_APPLICABILITY.NOT_APPLICABLE;
|
|
66539
|
+
}
|
|
66514
66540
|
const routing = rule.prRouting;
|
|
66515
66541
|
if (!routing) return PR_RULE_APPLICABILITY.UNKNOWN;
|
|
66516
66542
|
if (routing.targetLayers.length > 0 && !routing.targetLayers.includes(profile.layer)) {
|
|
@@ -66993,6 +67019,31 @@ var createOneShotPhaseLogger = (env = process.env) => {
|
|
|
66993
67019
|
}
|
|
66994
67020
|
};
|
|
66995
67021
|
};
|
|
67022
|
+
|
|
67023
|
+
// src/review-gate.ts
|
|
67024
|
+
init_dist2();
|
|
67025
|
+
init_exit_codes();
|
|
67026
|
+
var resolveGatePolicy = (configGate, override, skipOverride) => ({
|
|
67027
|
+
aiPolicy: override ?? configGate.aiPolicy,
|
|
67028
|
+
aiMinConfidence: configGate.aiMinConfidence,
|
|
67029
|
+
aiSkipPolicy: skipOverride ?? configGate.aiSkipPolicy
|
|
67030
|
+
});
|
|
67031
|
+
var computeGateResult = (findings2, ruleKindById, policy) => {
|
|
67032
|
+
let gatingBlocker = 0;
|
|
67033
|
+
let gatingError = 0;
|
|
67034
|
+
let advisoryErrorPlus = 0;
|
|
67035
|
+
for (const f of findings2) {
|
|
67036
|
+
const source = ruleKindById.get(f.ruleId) === "ai" ? "ai" : "deterministic";
|
|
67037
|
+
if (findingGates(f, source, policy)) {
|
|
67038
|
+
if (f.severity === "blocker") gatingBlocker++;
|
|
67039
|
+
else if (f.severity === "error") gatingError++;
|
|
67040
|
+
} else if (source === "ai" && meetsSeverity(f.severity, "error")) {
|
|
67041
|
+
advisoryErrorPlus++;
|
|
67042
|
+
}
|
|
67043
|
+
}
|
|
67044
|
+
const exitCode = gatingBlocker > 0 ? EXIT.FINDINGS_BLOCKER : gatingError > 0 ? EXIT.FINDINGS_ERROR : EXIT.SUCCESS;
|
|
67045
|
+
return { exitCode, gatingError, gatingBlocker, advisoryErrorPlus };
|
|
67046
|
+
};
|
|
66996
67047
|
var Counters = ({ counts, sourceCounts }) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
66997
67048
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
66998
67049
|
/* @__PURE__ */ jsx(Text, { color: "blue", children: "\u258C" }),
|
|
@@ -67448,8 +67499,17 @@ var dedupePrFindings = (findings2) => {
|
|
|
67448
67499
|
}
|
|
67449
67500
|
return [...byKey.values()];
|
|
67450
67501
|
};
|
|
67451
|
-
var
|
|
67452
|
-
|
|
67502
|
+
var touchesChangedLines = (finding, lineMap) => {
|
|
67503
|
+
const last = Math.max(finding.range.line, finding.range.endLine ?? finding.range.line);
|
|
67504
|
+
for (let line2 = finding.range.line; line2 <= last; line2 += 1) {
|
|
67505
|
+
if (getDiffLinePosition(lineMap, finding.file, line2)) return true;
|
|
67506
|
+
}
|
|
67507
|
+
return false;
|
|
67508
|
+
};
|
|
67509
|
+
var mergePrCandidateFindings = (staticFindings, aiFindings, changedPaths, lineMap, includeUnchangedLines = false) => dedupePrFindings([
|
|
67510
|
+
...staticFindings.filter(
|
|
67511
|
+
(finding) => changedPaths.has(finding.file) && (includeUnchangedLines || touchesChangedLines(finding, lineMap))
|
|
67512
|
+
),
|
|
67453
67513
|
...aiFindings
|
|
67454
67514
|
]);
|
|
67455
67515
|
|
|
@@ -67700,6 +67760,9 @@ var createGitLabClient = (options) => {
|
|
|
67700
67760
|
if (!result.ok) return result;
|
|
67701
67761
|
return toMergeRequest(result.value);
|
|
67702
67762
|
},
|
|
67763
|
+
async fetchCurrentUser() {
|
|
67764
|
+
return request("GET", "/user");
|
|
67765
|
+
},
|
|
67703
67766
|
async listNotes(target) {
|
|
67704
67767
|
return requestAllPages(mrPath(target, "/notes"));
|
|
67705
67768
|
},
|
|
@@ -67728,6 +67791,27 @@ var createGitLabClient = (options) => {
|
|
|
67728
67791
|
});
|
|
67729
67792
|
if (!result.ok) return result;
|
|
67730
67793
|
return ok(void 0);
|
|
67794
|
+
},
|
|
67795
|
+
async listDiscussions(target) {
|
|
67796
|
+
return requestAllPages(mrPath(target, "/discussions"));
|
|
67797
|
+
},
|
|
67798
|
+
async compareCommits(target, from, to) {
|
|
67799
|
+
const query = `from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}&straight=true`;
|
|
67800
|
+
const result = await request(
|
|
67801
|
+
"GET",
|
|
67802
|
+
`/projects/${encodeProjectPath(target.projectPath)}/repository/compare?${query}`
|
|
67803
|
+
);
|
|
67804
|
+
if (!result.ok) return result;
|
|
67805
|
+
return ok(result.value.diffs ?? []);
|
|
67806
|
+
},
|
|
67807
|
+
async resolveDiscussion(target, discussionId) {
|
|
67808
|
+
const result = await request(
|
|
67809
|
+
"PUT",
|
|
67810
|
+
mrPath(target, `/discussions/${encodeURIComponent(discussionId)}`),
|
|
67811
|
+
{ resolved: true }
|
|
67812
|
+
);
|
|
67813
|
+
if (!result.ok) return result;
|
|
67814
|
+
return ok(void 0);
|
|
67731
67815
|
}
|
|
67732
67816
|
};
|
|
67733
67817
|
};
|
|
@@ -67736,9 +67820,13 @@ var createGitLabClient = (options) => {
|
|
|
67736
67820
|
init_dist2();
|
|
67737
67821
|
init_dist5();
|
|
67738
67822
|
init_dist();
|
|
67739
|
-
var
|
|
67823
|
+
var summaryMarker = (kind) => `<!-- code-sentinel:pr-review:${kind} -->`;
|
|
67824
|
+
var LEGACY_SUMMARY_MARKER = "<!-- code-sentinel:pr-review -->";
|
|
67825
|
+
var SUMMARY_MARKER_PATTERN = /<!-- code-sentinel:pr-review(?::(static|ai))? -->/;
|
|
67740
67826
|
var fingerprintMarker = (fingerprint) => `<!-- code-sentinel:finding ${fingerprint} -->`;
|
|
67741
67827
|
var FINDING_MARKER_PATTERN = /code-sentinel:finding\s+([a-f0-9]+)/g;
|
|
67828
|
+
var inlineKindMarker = (kind) => `<!-- code-sentinel:kind ${kind} -->`;
|
|
67829
|
+
var INLINE_KIND_PATTERN = /code-sentinel:kind (static|ai)/;
|
|
67742
67830
|
var SEVERITIES = ["blocker", "error", "warning", "info"];
|
|
67743
67831
|
var escapeTableCell2 = (value) => value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>");
|
|
67744
67832
|
var countBySeverity3 = (findings2) => {
|
|
@@ -67757,9 +67845,10 @@ var renderPrSummary = (options) => {
|
|
|
67757
67845
|
...options.summaryOnly
|
|
67758
67846
|
].sort(compareFindings);
|
|
67759
67847
|
const severityCounts = countBySeverity3(allFindings);
|
|
67848
|
+
const kind = options.reviewKind ?? "static";
|
|
67760
67849
|
const lines = [
|
|
67761
|
-
|
|
67762
|
-
|
|
67850
|
+
summaryMarker(kind),
|
|
67851
|
+
`## Code Sentinel PR Review Report (${kind === "ai" ? "AI + static" : "static"})`,
|
|
67763
67852
|
"",
|
|
67764
67853
|
`**Run**: \`${options.runId}\``,
|
|
67765
67854
|
"",
|
|
@@ -67804,8 +67893,9 @@ var renderPrSummary = (options) => {
|
|
|
67804
67893
|
}
|
|
67805
67894
|
return lines.join("\n");
|
|
67806
67895
|
};
|
|
67807
|
-
var renderInlineComment = (item16) => [
|
|
67896
|
+
var renderInlineComment = (item16, kind) => [
|
|
67808
67897
|
fingerprintMarker(item16.fingerprint),
|
|
67898
|
+
inlineKindMarker(kind),
|
|
67809
67899
|
`**${item16.finding.ruleId}** (${item16.finding.severity})`,
|
|
67810
67900
|
"",
|
|
67811
67901
|
item16.finding.message,
|
|
@@ -67813,7 +67903,92 @@ var renderInlineComment = (item16) => [
|
|
|
67813
67903
|
item16.finding.suggestion ? `
|
|
67814
67904
|
Suggestion: ${item16.finding.suggestion}` : ""
|
|
67815
67905
|
].filter((part) => part.length > 0).join("\n");
|
|
67816
|
-
var isCodeSentinelNote = (body) =>
|
|
67906
|
+
var isCodeSentinelNote = (body) => SUMMARY_MARKER_PATTERN.test(body) || body.includes("code-sentinel:finding");
|
|
67907
|
+
var isOwnNote = (note, currentUserId) => note.author === void 0 ? true : currentUserId !== null && note.author.id === currentUserId;
|
|
67908
|
+
var isOwnSummaryOfKind = (note, kind, currentUserId) => isOwnNote(note, currentUserId) && (note.body.includes(summaryMarker(kind)) || note.body.includes(LEGACY_SUMMARY_MARKER));
|
|
67909
|
+
var touchedOldLines = (diff) => {
|
|
67910
|
+
const touched = /* @__PURE__ */ new Set();
|
|
67911
|
+
let oldLine = 0;
|
|
67912
|
+
for (const line2 of diff.split("\n")) {
|
|
67913
|
+
const hunk = /^@@ -(\d+)(?:,\d+)? \+\d+(?:,\d+)? @@/.exec(line2);
|
|
67914
|
+
if (hunk) {
|
|
67915
|
+
oldLine = Number(hunk[1]);
|
|
67916
|
+
continue;
|
|
67917
|
+
}
|
|
67918
|
+
if (line2.startsWith("-")) {
|
|
67919
|
+
touched.add(oldLine);
|
|
67920
|
+
oldLine++;
|
|
67921
|
+
} else if (line2.startsWith("+") || line2.startsWith("\\")) ; else {
|
|
67922
|
+
oldLine++;
|
|
67923
|
+
}
|
|
67924
|
+
}
|
|
67925
|
+
return touched;
|
|
67926
|
+
};
|
|
67927
|
+
var pruneStaleOwnFindings = async (options, kind, currentUserId) => {
|
|
67928
|
+
const removedNoteIds = /* @__PURE__ */ new Set();
|
|
67929
|
+
const standing = /* @__PURE__ */ new Set();
|
|
67930
|
+
const discussions = await options.client.listDiscussions(options.target);
|
|
67931
|
+
if (!discussions.ok) return discussions;
|
|
67932
|
+
const current = new Set(options.inlineable.map((item16) => item16.fingerprint));
|
|
67933
|
+
const touchedByFrom = /* @__PURE__ */ new Map();
|
|
67934
|
+
const codeChanged = async (head) => {
|
|
67935
|
+
const from = head.position?.head_sha;
|
|
67936
|
+
const path = head.position?.new_path;
|
|
67937
|
+
const line2 = head.position?.new_line;
|
|
67938
|
+
if (!options.headSha || !from || !path || !line2 || from === options.headSha) return ok(false);
|
|
67939
|
+
let byPath = touchedByFrom.get(from);
|
|
67940
|
+
if (!byPath) {
|
|
67941
|
+
const diffs = await options.client.compareCommits(options.target, from, options.headSha);
|
|
67942
|
+
if (!diffs.ok) return diffs;
|
|
67943
|
+
byPath = new Map(diffs.value.map((d) => [d.old_path, touchedOldLines(d.diff)]));
|
|
67944
|
+
touchedByFrom.set(from, byPath);
|
|
67945
|
+
}
|
|
67946
|
+
return ok(byPath.get(path)?.has(line2) ?? false);
|
|
67947
|
+
};
|
|
67948
|
+
let deleted = 0;
|
|
67949
|
+
let resolved = 0;
|
|
67950
|
+
for (const discussion of discussions.value) {
|
|
67951
|
+
const head = discussion.notes[0];
|
|
67952
|
+
if (!head) continue;
|
|
67953
|
+
let prune = false;
|
|
67954
|
+
if (currentUserId !== null && isStaleOwnFinding(head, kind, currentUserId, current)) {
|
|
67955
|
+
const changed = await codeChanged(head);
|
|
67956
|
+
if (!changed.ok) return changed;
|
|
67957
|
+
prune = changed.value;
|
|
67958
|
+
}
|
|
67959
|
+
if (!prune) {
|
|
67960
|
+
const key = standingKey(head);
|
|
67961
|
+
if (key) standing.add(key);
|
|
67962
|
+
continue;
|
|
67963
|
+
}
|
|
67964
|
+
if (discussion.notes.length === 1) {
|
|
67965
|
+
const result = await options.client.deleteNote(options.target, head.id);
|
|
67966
|
+
if (!result.ok) return result;
|
|
67967
|
+
removedNoteIds.add(head.id);
|
|
67968
|
+
deleted++;
|
|
67969
|
+
} else {
|
|
67970
|
+
const result = await options.client.resolveDiscussion(options.target, discussion.id);
|
|
67971
|
+
if (!result.ok) return result;
|
|
67972
|
+
resolved++;
|
|
67973
|
+
}
|
|
67974
|
+
}
|
|
67975
|
+
return ok({ deleted, resolved, removedNoteIds, standing });
|
|
67976
|
+
};
|
|
67977
|
+
var standingKey = (note) => {
|
|
67978
|
+
const ruleId = /\*\*([^*\s]+)\*\*/.exec(note.body)?.[1];
|
|
67979
|
+
const path = note.position?.new_path;
|
|
67980
|
+
const line2 = note.position?.new_line;
|
|
67981
|
+
if (!ruleId || !path || !line2 || !note.body.includes("code-sentinel:finding")) return null;
|
|
67982
|
+
return `${ruleId}|${path}|${line2}`;
|
|
67983
|
+
};
|
|
67984
|
+
var itemKey = (item16) => `${item16.finding.ruleId}|${item16.position.newPath}|${item16.position.newLine ?? ""}`;
|
|
67985
|
+
var isStaleOwnFinding = (head, kind, currentUserId, current) => {
|
|
67986
|
+
if (head.author?.id !== currentUserId || head.resolved === true) return false;
|
|
67987
|
+
const fingerprint = /code-sentinel:finding\s+([a-f0-9]+)/.exec(head.body)?.[1];
|
|
67988
|
+
if (!fingerprint || current.has(fingerprint)) return false;
|
|
67989
|
+
const noteKind = INLINE_KIND_PATTERN.exec(head.body)?.[1];
|
|
67990
|
+
return noteKind === void 0 || noteKind === kind;
|
|
67991
|
+
};
|
|
67817
67992
|
var publishPrReview = async (options) => {
|
|
67818
67993
|
const summaryBody = renderPrSummary(options);
|
|
67819
67994
|
if (options.dryRun) {
|
|
@@ -67822,23 +67997,32 @@ var publishPrReview = async (options) => {
|
|
|
67822
67997
|
inlinePosted: 0,
|
|
67823
67998
|
inlineSkipped: 0,
|
|
67824
67999
|
inlineFailed: 0,
|
|
67825
|
-
deletedExisting: 0
|
|
68000
|
+
deletedExisting: 0,
|
|
68001
|
+
staleDeleted: 0,
|
|
68002
|
+
staleResolved: 0
|
|
67826
68003
|
});
|
|
67827
68004
|
}
|
|
68005
|
+
const kind = options.reviewKind ?? "static";
|
|
68006
|
+
const currentUser = await options.client.fetchCurrentUser();
|
|
68007
|
+
const currentUserId = currentUser.ok ? currentUser.value.id : null;
|
|
67828
68008
|
const notesResult = await options.client.listNotes(options.target);
|
|
67829
68009
|
if (!notesResult.ok) return notesResult;
|
|
67830
68010
|
let activeNotes = notesResult.value;
|
|
67831
68011
|
let deletedExisting = 0;
|
|
67832
68012
|
if (options.cleanupExistingComments) {
|
|
68013
|
+
const kept = [];
|
|
67833
68014
|
for (const note of activeNotes) {
|
|
67834
|
-
if (!isCodeSentinelNote(note.body))
|
|
68015
|
+
if (!isCodeSentinelNote(note.body) || !isOwnNote(note, currentUserId)) {
|
|
68016
|
+
kept.push(note);
|
|
68017
|
+
continue;
|
|
68018
|
+
}
|
|
67835
68019
|
const deleted = await options.client.deleteNote(options.target, note.id);
|
|
67836
68020
|
if (!deleted.ok) return deleted;
|
|
67837
68021
|
deletedExisting++;
|
|
67838
68022
|
}
|
|
67839
|
-
activeNotes =
|
|
68023
|
+
activeNotes = kept;
|
|
67840
68024
|
}
|
|
67841
|
-
const existingSummary = activeNotes.find((note) => note
|
|
68025
|
+
const existingSummary = activeNotes.find((note) => isOwnSummaryOfKind(note, kind, currentUserId));
|
|
67842
68026
|
if (existingSummary) {
|
|
67843
68027
|
const updated = await options.client.updateNote(
|
|
67844
68028
|
options.target,
|
|
@@ -67851,10 +68035,21 @@ var publishPrReview = async (options) => {
|
|
|
67851
68035
|
if (!created.ok) return created;
|
|
67852
68036
|
}
|
|
67853
68037
|
if (options.summaryOnlyMode) {
|
|
67854
|
-
return ok({
|
|
68038
|
+
return ok({
|
|
68039
|
+
summaryBody,
|
|
68040
|
+
inlinePosted: 0,
|
|
68041
|
+
inlineSkipped: 0,
|
|
68042
|
+
inlineFailed: 0,
|
|
68043
|
+
deletedExisting,
|
|
68044
|
+
staleDeleted: 0,
|
|
68045
|
+
staleResolved: 0
|
|
68046
|
+
});
|
|
67855
68047
|
}
|
|
68048
|
+
const pruned = await pruneStaleOwnFindings(options, kind, currentUserId);
|
|
68049
|
+
if (!pruned.ok) return pruned;
|
|
67856
68050
|
const existingFingerprints = /* @__PURE__ */ new Set();
|
|
67857
68051
|
for (const note of activeNotes) {
|
|
68052
|
+
if (pruned.value.removedNoteIds.has(note.id)) continue;
|
|
67858
68053
|
for (const match of note.body.matchAll(FINDING_MARKER_PATTERN)) {
|
|
67859
68054
|
if (match[1]) existingFingerprints.add(match[1]);
|
|
67860
68055
|
}
|
|
@@ -67864,13 +68059,13 @@ var publishPrReview = async (options) => {
|
|
|
67864
68059
|
let inlineSkipped = options.inlineable.length - budgeted.length;
|
|
67865
68060
|
let inlineFailed = 0;
|
|
67866
68061
|
for (const item16 of budgeted) {
|
|
67867
|
-
if (existingFingerprints.has(item16.fingerprint)) {
|
|
68062
|
+
if (existingFingerprints.has(item16.fingerprint) || pruned.value.standing.has(itemKey(item16))) {
|
|
67868
68063
|
inlineSkipped++;
|
|
67869
68064
|
continue;
|
|
67870
68065
|
}
|
|
67871
68066
|
const result = await options.client.createDiscussion(
|
|
67872
68067
|
options.target,
|
|
67873
|
-
renderInlineComment(item16),
|
|
68068
|
+
renderInlineComment(item16, kind),
|
|
67874
68069
|
item16.position
|
|
67875
68070
|
);
|
|
67876
68071
|
if (!result.ok) {
|
|
@@ -67879,7 +68074,15 @@ var publishPrReview = async (options) => {
|
|
|
67879
68074
|
}
|
|
67880
68075
|
inlinePosted++;
|
|
67881
68076
|
}
|
|
67882
|
-
return ok({
|
|
68077
|
+
return ok({
|
|
68078
|
+
summaryBody,
|
|
68079
|
+
inlinePosted,
|
|
68080
|
+
inlineSkipped,
|
|
68081
|
+
inlineFailed,
|
|
68082
|
+
deletedExisting,
|
|
68083
|
+
staleDeleted: pruned.value.deleted,
|
|
68084
|
+
staleResolved: pruned.value.resolved
|
|
68085
|
+
});
|
|
67883
68086
|
};
|
|
67884
68087
|
|
|
67885
68088
|
// src/pr/static-review.ts
|
|
@@ -68425,6 +68628,11 @@ var printDryRunSummary = (target, findings2, reportPaths, codeQualityPath) => {
|
|
|
68425
68628
|
}
|
|
68426
68629
|
console.log(green(` GitLab Code Quality: ${codeQualityPath}`));
|
|
68427
68630
|
};
|
|
68631
|
+
var computePrGate = (findings2, ruleKindById, configGate, aiGatePolicy) => computeGateResult(
|
|
68632
|
+
findings2,
|
|
68633
|
+
new Map([...ruleKindById, ["ai/pr-diff-review", "ai"]]),
|
|
68634
|
+
resolveGatePolicy(configGate, aiGatePolicy)
|
|
68635
|
+
);
|
|
68428
68636
|
var sourceCountsForFindings = (findings2, ruleKindById) => {
|
|
68429
68637
|
const counts = { static: 0, ai: 0 };
|
|
68430
68638
|
for (const finding of findings2) {
|
|
@@ -68954,7 +69162,7 @@ var runPrReview = async (options) => {
|
|
|
68954
69162
|
(finding) => changedPaths.has(finding.file)
|
|
68955
69163
|
);
|
|
68956
69164
|
const staticFindings = staticChangedFileFindings.filter(
|
|
68957
|
-
(finding) =>
|
|
69165
|
+
(finding) => touchesChangedLines(finding, lineMap)
|
|
68958
69166
|
);
|
|
68959
69167
|
const supportFiles = await buildSupportFiles(
|
|
68960
69168
|
staticResult.allSourceFiles,
|
|
@@ -69134,7 +69342,13 @@ var runPrReview = async (options) => {
|
|
|
69134
69342
|
}
|
|
69135
69343
|
const enrichFinding = createFindingContextEnricher(staticResult.allSourceFiles);
|
|
69136
69344
|
const mergedFindings = [
|
|
69137
|
-
...mergePrCandidateFindings(
|
|
69345
|
+
...mergePrCandidateFindings(
|
|
69346
|
+
staticResult.run.findings,
|
|
69347
|
+
aiFindings,
|
|
69348
|
+
changedPaths,
|
|
69349
|
+
lineMap,
|
|
69350
|
+
config.prReview.includeUnchangedLines
|
|
69351
|
+
)
|
|
69138
69352
|
].map(enrichFinding).sort(compareFindings);
|
|
69139
69353
|
const classified = classifyPrFindings(mergedFindings, changedPaths, lineMap);
|
|
69140
69354
|
const aiStats = mergePrAiStats(
|
|
@@ -69277,6 +69491,9 @@ var runPrReview = async (options) => {
|
|
|
69277
69491
|
staticResult.ruleKindById
|
|
69278
69492
|
),
|
|
69279
69493
|
maxInlineComments,
|
|
69494
|
+
// A static-only CI bot and a developer's AI run each keep their own MR summary.
|
|
69495
|
+
reviewKind: (aiStats?.succeeded ?? 0) > 0 ? "ai" : "static",
|
|
69496
|
+
headSha: mr.diffRefs.headSha,
|
|
69280
69497
|
summaryOnlyMode: options.summaryOnly,
|
|
69281
69498
|
cleanupExistingComments: config.prReview.cleanupExistingComments,
|
|
69282
69499
|
dryRun: !options.post
|
|
@@ -69308,7 +69525,7 @@ var runPrReview = async (options) => {
|
|
|
69308
69525
|
console.log(green(`Posted GitLab PR review for ${target.projectPath}!${target.iid}`));
|
|
69309
69526
|
console.log(
|
|
69310
69527
|
gray(
|
|
69311
|
-
` Deleted existing: ${publishResult.value.deletedExisting}; inline posted: ${publishResult.value.inlinePosted}; inline skipped: ${publishResult.value.inlineSkipped}; inline failed: ${publishResult.value.inlineFailed}`
|
|
69528
|
+
` Deleted existing: ${publishResult.value.deletedExisting}; inline posted: ${publishResult.value.inlinePosted}; inline skipped: ${publishResult.value.inlineSkipped}; inline failed: ${publishResult.value.inlineFailed}; stale removed: ${publishResult.value.staleDeleted}; stale resolved: ${publishResult.value.staleResolved}`
|
|
69312
69529
|
)
|
|
69313
69530
|
);
|
|
69314
69531
|
} else if (!options.silent) {
|
|
@@ -69321,16 +69538,17 @@ var runPrReview = async (options) => {
|
|
|
69321
69538
|
);
|
|
69322
69539
|
}
|
|
69323
69540
|
}
|
|
69324
|
-
|
|
69325
|
-
|
|
69326
|
-
|
|
69327
|
-
|
|
69328
|
-
|
|
69329
|
-
|
|
69330
|
-
|
|
69331
|
-
|
|
69332
|
-
|
|
69333
|
-
|
|
69541
|
+
const gate = computePrGate(
|
|
69542
|
+
mergedFindings,
|
|
69543
|
+
staticResult.ruleKindById,
|
|
69544
|
+
config.review.gate,
|
|
69545
|
+
options.aiGatePolicy
|
|
69546
|
+
);
|
|
69547
|
+
phaseLog.info(
|
|
69548
|
+
"quality-gate",
|
|
69549
|
+
`exit_code=${gate.exitCode} gating_blocker=${gate.gatingBlocker} gating_error=${gate.gatingError} advisory_ai_error_plus=${gate.advisoryErrorPlus}`
|
|
69550
|
+
);
|
|
69551
|
+
return gate.exitCode;
|
|
69334
69552
|
} catch (error) {
|
|
69335
69553
|
phaseLog.error(activeReviewPhase, error.message);
|
|
69336
69554
|
const renderer = getInkRenderer();
|
|
@@ -71392,27 +71610,6 @@ var SERVER_RUN_PROGRESS_PREFIX = "cs-progress ";
|
|
|
71392
71610
|
var log2 = (silent, msg) => {
|
|
71393
71611
|
if (!silent) console.log(msg);
|
|
71394
71612
|
};
|
|
71395
|
-
var resolveGatePolicy = (configGate, override, skipOverride) => ({
|
|
71396
|
-
aiPolicy: override ?? configGate.aiPolicy,
|
|
71397
|
-
aiMinConfidence: configGate.aiMinConfidence,
|
|
71398
|
-
aiSkipPolicy: skipOverride ?? configGate.aiSkipPolicy
|
|
71399
|
-
});
|
|
71400
|
-
var computeGateResult = (findings2, ruleKindById, policy) => {
|
|
71401
|
-
let gatingBlocker = 0;
|
|
71402
|
-
let gatingError = 0;
|
|
71403
|
-
let advisoryErrorPlus = 0;
|
|
71404
|
-
for (const f of findings2) {
|
|
71405
|
-
const source = ruleKindById.get(f.ruleId) === "ai" ? "ai" : "deterministic";
|
|
71406
|
-
if (findingGates(f, source, policy)) {
|
|
71407
|
-
if (f.severity === "blocker") gatingBlocker++;
|
|
71408
|
-
else if (f.severity === "error") gatingError++;
|
|
71409
|
-
} else if (source === "ai" && meetsSeverity(f.severity, "error")) {
|
|
71410
|
-
advisoryErrorPlus++;
|
|
71411
|
-
}
|
|
71412
|
-
}
|
|
71413
|
-
const exitCode = gatingBlocker > 0 ? EXIT.FINDINGS_BLOCKER : gatingError > 0 ? EXIT.FINDINGS_ERROR : EXIT.SUCCESS;
|
|
71414
|
-
return { exitCode, gatingError, gatingBlocker, advisoryErrorPlus };
|
|
71415
|
-
};
|
|
71416
71613
|
var escalateExitForCoverage = (baseExit, coverageBlocks) => baseExit === EXIT.SUCCESS && coverageBlocks ? EXIT.RUNTIME : baseExit;
|
|
71417
71614
|
var hasIncompleteQueuedFullCoverage = (isRunnerInvocation, runtimeSinceRef2, aiStats) => isRunnerInvocation && (runtimeSinceRef2 === void 0 || runtimeSinceRef2.length === 0) && aiStats !== void 0 && countRecallRiskSkips(aiStats) > 0;
|
|
71418
71615
|
var rulesToRerun = (aiStats) => {
|
|
@@ -71442,6 +71639,7 @@ var runReview = async (options = {}) => {
|
|
|
71442
71639
|
prWorkspace: options.prWorkspace,
|
|
71443
71640
|
prAiStrategy: options.prAiStrategy,
|
|
71444
71641
|
aiOff: options.aiOff === true,
|
|
71642
|
+
...options.aiGatePolicy !== void 0 ? { aiGatePolicy: options.aiGatePolicy } : {},
|
|
71445
71643
|
mode: options.mode,
|
|
71446
71644
|
...options.scope !== void 0 ? { scope: options.scope } : {},
|
|
71447
71645
|
minSeverity: options.minSeverity,
|