Spaces:
Paused
Paused
File size: 6,764 Bytes
440cddf 5cb7295 440cddf 9284ad7 440cddf 9284ad7 440cddf 9284ad7 440cddf 5cb7295 440cddf 5cb7295 440cddf 5cb7295 440cddf 9284ad7 440cddf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AIOptions = exports.PathFilter = exports.Options = void 0;
const minimatch_1 = require("minimatch");
const limits_1 = require("./limits");
const info = console.log;
class Options {
debug;
disableReview;
disableReleaseNotes;
maxFiles;
reviewSimpleChanges;
reviewCommentLGTM;
pathFilters;
systemMessage;
lightModel;
heavyModel;
modelTemperature;
retries;
timeoutMS;
concurrencyLimit;
githubConcurrencyLimit;
lightTokenLimits;
heavyTokenLimits;
apiBaseUrl;
language;
createRemedyPR;
minimumSeverity;
minConfidence;
denseMode;
showImpactAnalysis;
enableAutoPR;
static HEAVY_MODELS = [
'llama-3.3-70b-versatile',
'meta-llama/llama-4-scout-17b-16e-instruct',
'deepseek-r1-distill-llama-70b',
'openai/gpt-oss-120b',
'qwen/qwen3-32b'
];
static LIGHT_MODELS = [
'meta-llama/llama-4-scout-17b-16e-instruct',
'llama-3.1-8b-instant',
'groq/compound'
];
static SECURITY_MODELS = [
'openai/gpt-oss-safeguard-20b',
'meta-llama/llama-guard-4-12b',
'meta-llama/llama-prompt-guard-2-86m',
'meta-llama/llama-prompt-guard-2-22m'
];
constructor(debug, disableReview, disableReleaseNotes, maxFiles = '0', reviewSimpleChanges = false, reviewCommentLGTM = false, pathFilters = null, systemMessage = '', lightModel = 'meta-llama/llama-4-scout-17b-16e-instruct', heavyModel = 'llama-3.3-70b-versatile', modelTemperature = '0.0', retries = '3', timeoutMS = '120000', concurrencyLimit = '3', githubConcurrencyLimit = '10', apiBaseUrl = 'https://api.groq.com/openai/v1', language = 'en-US', createRemedyPR = true, minimumSeverity = 'minor', minConfidence = '0', denseMode = 'false', showImpactAnalysis = 'true', enableAutoPR = false) {
this.debug = debug;
this.disableReview = disableReview;
this.disableReleaseNotes = disableReleaseNotes;
this.maxFiles = parseInt(maxFiles);
this.reviewSimpleChanges = reviewSimpleChanges;
this.reviewCommentLGTM = reviewCommentLGTM;
this.pathFilters = new PathFilter(pathFilters);
this.systemMessage = systemMessage;
this.lightModel = lightModel;
this.heavyModel = heavyModel;
this.modelTemperature = parseFloat(modelTemperature);
this.retries = parseInt(retries);
this.timeoutMS = parseInt(timeoutMS);
this.concurrencyLimit = parseInt(concurrencyLimit);
this.githubConcurrencyLimit = parseInt(githubConcurrencyLimit);
this.apiBaseUrl = apiBaseUrl;
this.language = language;
this.createRemedyPR = createRemedyPR;
this.minimumSeverity = minimumSeverity;
this.minConfidence = parseInt(minConfidence);
this.denseMode = denseMode === 'true';
this.showImpactAnalysis = showImpactAnalysis === 'true';
this.enableAutoPR = enableAutoPR;
this.lightTokenLimits = new limits_1.TokenLimits(this.lightModel);
this.heavyTokenLimits = new limits_1.TokenLimits(this.heavyModel);
}
// print all options using core.info
print() {
info(`debug: ${this.debug}`);
info(`disable_review: ${this.disableReview}`);
info(`disable_release_notes: ${this.disableReleaseNotes}`);
info(`max_files: ${this.maxFiles}`);
info(`review_simple_changes: ${this.reviewSimpleChanges}`);
info(`review_comment_lgtm: ${this.reviewCommentLGTM}`);
info(`path_filters: ${this.pathFilters}`);
info(`system_message: ${this.systemMessage}`);
info(`light_model: ${this.lightModel}`);
info(`heavy_model: ${this.heavyModel}`);
info(`model_temperature: ${this.modelTemperature}`);
info(`retries: ${this.retries}`);
info(`timeout_ms: ${this.timeoutMS}`);
info(`concurrency_limit: ${this.concurrencyLimit}`);
info(`github_concurrency_limit: ${this.githubConcurrencyLimit}`);
info(`summary_token_limits: ${this.lightTokenLimits.string()}`);
info(`review_token_limits: ${this.heavyTokenLimits.string()}`);
info(`api_base_url: ${this.apiBaseUrl}`);
info(`language: ${this.language}`);
info(`create_remedy_pr: ${this.createRemedyPR}`);
info(`enable_auto_pr: ${this.enableAutoPR}`);
}
checkPath(path) {
const ok = this.pathFilters.check(path);
info(`checking path: ${path} => ${ok}`);
return ok;
}
static SEVERITY_ORDER = [
'critical',
'major',
'minor',
'info'
];
meetsMinimumSeverity(findingSeverity) {
const minIndex = Options.SEVERITY_ORDER.indexOf(this.minimumSeverity);
const findingIndex = Options.SEVERITY_ORDER.indexOf(findingSeverity);
return findingIndex >= minIndex;
}
meetsConfidenceThreshold(confidence) {
return confidence >= this.minConfidence;
}
}
exports.Options = Options;
class PathFilter {
rules;
constructor(rules = null) {
this.rules = [];
if (rules != null) {
for (const rule of rules) {
const trimmed = rule?.trim();
if (trimmed) {
if (trimmed.startsWith('!')) {
this.rules.push([trimmed.substring(1).trim(), true]);
}
else {
this.rules.push([trimmed, false]);
}
}
}
}
}
check(path) {
if (this.rules.length === 0) {
return true;
}
let included = false;
let excluded = false;
let inclusionRuleExists = false;
for (const [rule, exclude] of this.rules) {
if ((0, minimatch_1.minimatch)(path, rule)) {
if (exclude) {
excluded = true;
}
else {
included = true;
}
}
if (!exclude) {
inclusionRuleExists = true;
}
}
return (!inclusionRuleExists || included) && !excluded;
}
}
exports.PathFilter = PathFilter;
class AIOptions {
model;
tokenLimits;
temperature;
constructor(model = 'meta-llama/llama-4-scout-17b-16e-instruct', tokenLimits = null, temperature = 0.0) {
this.model = model;
this.temperature = temperature;
if (tokenLimits != null) {
this.tokenLimits = tokenLimits;
}
else {
this.tokenLimits = new limits_1.TokenLimits(model);
}
}
}
exports.AIOptions = AIOptions;
//# sourceMappingURL=options.js.map |