@alint-js/core 0.3.1 → 0.4.0
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/index.d.mts +1 -0
- package/dist/index.mjs +25 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -602,7 +602,7 @@ function recordMissingLanguages(into, rules, registry, path) {
|
|
|
602
602
|
}
|
|
603
603
|
//#endregion
|
|
604
604
|
//#region package.json
|
|
605
|
-
var version = "0.
|
|
605
|
+
var version = "0.4.0";
|
|
606
606
|
//#endregion
|
|
607
607
|
//#region src/core/cache/types.ts
|
|
608
608
|
const CACHE_MAGIC = "ALINT_CACHE";
|
|
@@ -1381,6 +1381,14 @@ function terminalCount(execution) {
|
|
|
1381
1381
|
}
|
|
1382
1382
|
//#endregion
|
|
1383
1383
|
//#region src/models/resolve.ts
|
|
1384
|
+
var UnknownModelError = class extends Error {
|
|
1385
|
+
request;
|
|
1386
|
+
constructor(request) {
|
|
1387
|
+
super(`Unknown model "${request}".`);
|
|
1388
|
+
this.name = "UnknownModelError";
|
|
1389
|
+
this.request = request;
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1384
1392
|
function resolveModel(registry, options = {}) {
|
|
1385
1393
|
const candidates = flattenModels(registry);
|
|
1386
1394
|
const ruleId = options.ruleId ?? "<unknown>";
|
|
@@ -1400,7 +1408,7 @@ function resolveModel(registry, options = {}) {
|
|
|
1400
1408
|
}
|
|
1401
1409
|
const duplicateIdentity = [...matchesByCanonical].find(([, matches]) => matches.length > 1)?.[0];
|
|
1402
1410
|
if (duplicateIdentity !== void 0) throw duplicateDefinitionError(duplicateIdentity);
|
|
1403
|
-
if (matchingCandidates.length === 0) throw new
|
|
1411
|
+
if (matchingCandidates.length === 0) throw new UnknownModelError(request);
|
|
1404
1412
|
if (matchingCandidates.length > 1) {
|
|
1405
1413
|
const choices = [...matchesByCanonical.keys()];
|
|
1406
1414
|
throw new Error(`Ambiguous model "${request}".\nSpecify a provider-qualified model:\n${choices.map((choice) => ` ${choice}`).join("\n")}`);
|
|
@@ -1521,13 +1529,21 @@ function createRuleRuntimes(options) {
|
|
|
1521
1529
|
}
|
|
1522
1530
|
} },
|
|
1523
1531
|
model: async (selector) => {
|
|
1524
|
-
const
|
|
1532
|
+
const explicitRequest = options.runOptions.modelOverride ?? (typeof selector === "string" ? selector : void 0);
|
|
1533
|
+
const fallbackRequest = explicitRequest === void 0 && selector === void 0 && enabledRule.rule.model === void 0 ? options.runOptions.defaultModel : void 0;
|
|
1534
|
+
const request = explicitRequest ?? fallbackRequest;
|
|
1525
1535
|
const requirement = mergeModelRequirement(enabledRule.rule.model, typeof selector === "string" ? void 0 : selector);
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1536
|
+
let resolvedModel;
|
|
1537
|
+
try {
|
|
1538
|
+
resolvedModel = resolveModel(options.setupConfig, {
|
|
1539
|
+
request,
|
|
1540
|
+
requirement,
|
|
1541
|
+
ruleId: enabledRule.id
|
|
1542
|
+
});
|
|
1543
|
+
} catch (error) {
|
|
1544
|
+
if (fallbackRequest !== void 0 && error instanceof UnknownModelError) throw new Error(`Default model "${fallbackRequest}" is not configured. Configure a system default model or select a model for this project.`, { cause: error });
|
|
1545
|
+
throw error;
|
|
1546
|
+
}
|
|
1531
1547
|
const state = executionState.getStore();
|
|
1532
1548
|
if (state && !state.sealed) state.currentModel = toDiagnosticModel(resolvedModel, request);
|
|
1533
1549
|
return resolvedModel;
|
|
@@ -2429,6 +2445,7 @@ async function runAlint(options = {}) {
|
|
|
2429
2445
|
readOnly: options.cacheOnly
|
|
2430
2446
|
});
|
|
2431
2447
|
const cacheContext = { modelHash: stableHash({
|
|
2448
|
+
defaultModel: options.modelOverride === void 0 ? options.defaultModel : void 0,
|
|
2432
2449
|
modelOverride: options.modelOverride,
|
|
2433
2450
|
outputLanguage: options.outputLanguage,
|
|
2434
2451
|
setupConfig
|