PRIX / lib /src /options.js
yamxxx1's picture
Upload 117 files
a2fe16e verified
Raw
History Blame
6.68 kB
"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;
static HEAVY_MODELS = [
'openai/gpt-oss-120b',
'moonshotai/kimi-k2-instruct-0905',
'qwen/qwen3-32b',
'deepseek-r1-distill-llama-70b',
'llama-3.3-70b-versatile',
'openai/gpt-oss-20b',
'meta-llama/llama-4-scout-17b-16e-instruct'
];
static LIGHT_MODELS = [
'llama-3.1-8b-instant',
'groq/compound',
'groq/compound-mini',
'llama-3.2-11b-vision-preview'
];
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 = 'llama-3.1-8b-instant', heavyModel = 'llama-3.3-70b-versatile', modelTemperature = '0.0', retries = '3', timeoutMS = '120000', concurrencyLimit = '6', githubConcurrencyLimit = '6', apiBaseUrl = 'https://api.groq.com/openai/v1', language = 'en-US', createRemedyPR = false, minimumSeverity = 'minor', minConfidence = '0', denseMode = 'false', showImpactAnalysis = 'true') {
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.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}`);
}
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 = 'llama-3.1-8b-instant', 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