@alint-js/config 0.0.38 → 0.1.1
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 +11 -2
- package/dist/index.mjs +98 -8
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlintConfig, AlintConfig as AlintConfig$1, AlintConfigItem, ModelSize, PluginDefinition, ProviderDefinition, ProviderType, RunnerConfig, RunnerStatsConfig, SetupConfig, SetupConfig as SetupConfig$1, SetupModelDefinition } from "@alint-js/core";
|
|
1
|
+
import { AlintConfig, AlintConfig as AlintConfig$1, AlintConfigItem, ModelSize, PluginDefinition, ProviderDefinition, ProviderDefinition as ProviderDefinition$1, ProviderType, RunnerConfig, RunnerStatsConfig, SetupConfig, SetupConfig as SetupConfig$1, SetupModelDefinition } from "@alint-js/core";
|
|
2
2
|
//#region src/plugins/spec.d.ts
|
|
3
3
|
interface DirectoryPluginSpecifier {
|
|
4
4
|
directory: string;
|
|
@@ -237,6 +237,15 @@ declare const emptySetupConfig: SetupConfig$1;
|
|
|
237
237
|
declare function loadSetupConfig(filePath: string): Promise<SetupConfig$1>;
|
|
238
238
|
declare function mergeSetupConfigs(...configs: SetupConfig$1[]): SetupConfig$1;
|
|
239
239
|
//#endregion
|
|
240
|
+
//#region src/setup/mutate.d.ts
|
|
241
|
+
declare function addProviderModels(config: SetupConfig$1, providerId: string, modelIds: readonly string[]): SetupConfig$1;
|
|
242
|
+
declare function pruneProviderModels(config: SetupConfig$1, providerId: string, remoteModelIds: ReadonlySet<string>): SetupConfig$1;
|
|
243
|
+
declare function removeProviderModels(config: SetupConfig$1, providerId: string, modelIds: ReadonlySet<string>): SetupConfig$1;
|
|
244
|
+
declare function replaceSetupProvider(config: SetupConfig$1, replacement: ProviderDefinition$1): SetupConfig$1;
|
|
245
|
+
declare function setProviderEndpoint(config: SetupConfig$1, providerId: string, endpoint: string): SetupConfig$1;
|
|
246
|
+
declare function setProviderHeader(config: SetupConfig$1, providerId: string, name: string, value: string): SetupConfig$1;
|
|
247
|
+
declare function unsetProviderHeader(config: SetupConfig$1, providerId: string, name: string): SetupConfig$1;
|
|
248
|
+
//#endregion
|
|
240
249
|
//#region src/setup/toml.d.ts
|
|
241
250
|
declare function parseSetupConfigToml(toml: string): SetupConfig$1;
|
|
242
251
|
declare function stringifySetupConfigToml(config: SetupConfig$1): string;
|
|
@@ -244,4 +253,4 @@ declare function stringifySetupConfigToml(config: SetupConfig$1): string;
|
|
|
244
253
|
//#region src/setup/write.d.ts
|
|
245
254
|
declare function writeSetupConfig(filePath: string, config: SetupConfig$1): Promise<void>;
|
|
246
255
|
//#endregion
|
|
247
|
-
export { type AlintConfig, BuiltInAgentName, CreateDeclarativePluginOptions, CreateReportScopeOptions, DeclarativeFinding, DeclarativeFindingResponse, DeclarativeRuleDefinition, type DirectoryPluginLockEntry, type GlobalSetupConfigPathOptions, LoadDeclarativeRulesOptions, type ModelSize, type ParseStaticConfigOptions, type ParsedDirectoryPluginLockEntry, type ParsedPluginLockEntry, type ParsedPluginLockFile, type ParsedPluginSpecifier, type ParsedRegistryPluginLockEntry, type ParsedStaticConfig, type ParsedStaticConfigGroup, type PluginLockEntry, type PluginLockFile, type ProviderDefinition, type ProviderType, type RegistryPluginLockEntry, ReportScope, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type StaticConfigInput, type StaticConfigItem, type StaticPluginInstallOptions, type StaticPluginInstallResult, type StaticPluginReference, type StaticPluginResolver, type ToAlintConfigOptions, builtInAgentNames, createDeclarativePlugin, createEmptyPluginLockFile, createReportScope, declarativeFindingResponseSchema, declarativeFindingSchema, declarativeRuleFilePattern, emptySetupConfig, getGlobalSetupConfigPath, getProjectPluginLockPath, getProjectPluginStorePath, getProjectSetupConfigPath, getStatsDir, hasDeclarativeRuleFiles, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated, installStaticPlugins, isBuiltInAgentName, listMissing, listUnresolved, loadAlintConfig, loadDeclarativeRules, loadPluginLockFile, loadSetupConfig, loadStaticConfig, mergeSetupConfigs, parsePluginLockFile, parsePluginSpecifier, parseSetupConfigToml, parseStaticConfig, stringifySetupConfigToml, toAlintConfig, writePluginLockFile, writeSetupConfig };
|
|
256
|
+
export { type AlintConfig, BuiltInAgentName, CreateDeclarativePluginOptions, CreateReportScopeOptions, DeclarativeFinding, DeclarativeFindingResponse, DeclarativeRuleDefinition, type DirectoryPluginLockEntry, type GlobalSetupConfigPathOptions, LoadDeclarativeRulesOptions, type ModelSize, type ParseStaticConfigOptions, type ParsedDirectoryPluginLockEntry, type ParsedPluginLockEntry, type ParsedPluginLockFile, type ParsedPluginSpecifier, type ParsedRegistryPluginLockEntry, type ParsedStaticConfig, type ParsedStaticConfigGroup, type PluginLockEntry, type PluginLockFile, type ProviderDefinition, type ProviderType, type RegistryPluginLockEntry, ReportScope, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type StaticConfigInput, type StaticConfigItem, type StaticPluginInstallOptions, type StaticPluginInstallResult, type StaticPluginReference, type StaticPluginResolver, type ToAlintConfigOptions, addProviderModels, builtInAgentNames, createDeclarativePlugin, createEmptyPluginLockFile, createReportScope, declarativeFindingResponseSchema, declarativeFindingSchema, declarativeRuleFilePattern, emptySetupConfig, getGlobalSetupConfigPath, getProjectPluginLockPath, getProjectPluginStorePath, getProjectSetupConfigPath, getStatsDir, hasDeclarativeRuleFiles, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated, installStaticPlugins, isBuiltInAgentName, listMissing, listUnresolved, loadAlintConfig, loadDeclarativeRules, loadPluginLockFile, loadSetupConfig, loadStaticConfig, mergeSetupConfigs, parsePluginLockFile, parsePluginSpecifier, parseSetupConfigToml, parseStaticConfig, pruneProviderModels, removeProviderModels, replaceSetupProvider, setProviderEndpoint, setProviderHeader, stringifySetupConfigToml, toAlintConfig, unsetProviderHeader, writePluginLockFile, writeSetupConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1448,7 +1448,7 @@ function mergeSetupConfigs(...configs) {
|
|
|
1448
1448
|
for (const provider of config.providers) {
|
|
1449
1449
|
const existingProvider = providersById.get(provider.id);
|
|
1450
1450
|
if (existingProvider === void 0) {
|
|
1451
|
-
const mergedProvider = cloneProvider(provider);
|
|
1451
|
+
const mergedProvider = cloneProvider$1(provider);
|
|
1452
1452
|
providers.push(mergedProvider);
|
|
1453
1453
|
providersById.set(provider.id, mergedProvider);
|
|
1454
1454
|
configProviders.push(mergedProvider);
|
|
@@ -1465,7 +1465,7 @@ function mergeSetupConfigs(...configs) {
|
|
|
1465
1465
|
for (const incomingModel of provider.models) {
|
|
1466
1466
|
const existingModelIndex = existingProvider.models.findIndex((model) => model.id === incomingModel.id);
|
|
1467
1467
|
if (existingModelIndex === -1) {
|
|
1468
|
-
nextModels.push(cloneModel(incomingModel));
|
|
1468
|
+
nextModels.push(cloneModel$1(incomingModel));
|
|
1469
1469
|
continue;
|
|
1470
1470
|
}
|
|
1471
1471
|
const existingModel = existingProvider.models[existingModelIndex];
|
|
@@ -1483,17 +1483,17 @@ function mergeSetupConfigs(...configs) {
|
|
|
1483
1483
|
if (runner !== void 0) mergedConfig.runner = runner;
|
|
1484
1484
|
return mergedConfig;
|
|
1485
1485
|
}
|
|
1486
|
-
function cloneModel(model) {
|
|
1486
|
+
function cloneModel$1(model) {
|
|
1487
1487
|
const clonedModel = { ...model };
|
|
1488
1488
|
if (model.aliases !== void 0) clonedModel.aliases = [...model.aliases];
|
|
1489
1489
|
if (model.capabilities !== void 0) clonedModel.capabilities = [...model.capabilities];
|
|
1490
1490
|
if (model.defaultParams !== void 0) clonedModel.defaultParams = { ...model.defaultParams };
|
|
1491
1491
|
return clonedModel;
|
|
1492
1492
|
}
|
|
1493
|
-
function cloneProvider(provider) {
|
|
1493
|
+
function cloneProvider$1(provider) {
|
|
1494
1494
|
const clonedProvider = {
|
|
1495
1495
|
...provider,
|
|
1496
|
-
models: provider.models.map(cloneModel)
|
|
1496
|
+
models: provider.models.map(cloneModel$1)
|
|
1497
1497
|
};
|
|
1498
1498
|
if (provider.headers !== void 0) clonedProvider.headers = { ...provider.headers };
|
|
1499
1499
|
return clonedProvider;
|
|
@@ -1505,8 +1505,8 @@ function createEmptySetupConfig() {
|
|
|
1505
1505
|
};
|
|
1506
1506
|
}
|
|
1507
1507
|
function mergeModel(existingModel, incomingModel) {
|
|
1508
|
-
const existing = cloneModel(existingModel);
|
|
1509
|
-
const incoming = cloneModel(incomingModel);
|
|
1508
|
+
const existing = cloneModel$1(existingModel);
|
|
1509
|
+
const incoming = cloneModel$1(incomingModel);
|
|
1510
1510
|
return {
|
|
1511
1511
|
...existing,
|
|
1512
1512
|
...incoming,
|
|
@@ -1520,10 +1520,100 @@ function prioritizeProviders(providers, prioritizedProviders) {
|
|
|
1520
1520
|
return [...prioritizedProviders, ...providers.filter((provider) => !prioritizedProviderIds.has(provider.id))];
|
|
1521
1521
|
}
|
|
1522
1522
|
//#endregion
|
|
1523
|
+
//#region src/setup/mutate.ts
|
|
1524
|
+
function addProviderModels(config, providerId, modelIds) {
|
|
1525
|
+
return updateProvider(config, providerId, (provider) => {
|
|
1526
|
+
const knownModelIds = new Set(provider.models.map((model) => model.id));
|
|
1527
|
+
const addedModels = [];
|
|
1528
|
+
for (const modelId of modelIds) {
|
|
1529
|
+
if (knownModelIds.has(modelId)) continue;
|
|
1530
|
+
knownModelIds.add(modelId);
|
|
1531
|
+
addedModels.push({
|
|
1532
|
+
id: modelId,
|
|
1533
|
+
name: modelId
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
return {
|
|
1537
|
+
...provider,
|
|
1538
|
+
models: [...provider.models, ...addedModels]
|
|
1539
|
+
};
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
function pruneProviderModels(config, providerId, remoteModelIds) {
|
|
1543
|
+
return updateProvider(config, providerId, (provider) => ({
|
|
1544
|
+
...provider,
|
|
1545
|
+
models: provider.models.filter((model) => remoteModelIds.has(model.id))
|
|
1546
|
+
}));
|
|
1547
|
+
}
|
|
1548
|
+
function removeProviderModels(config, providerId, modelIds) {
|
|
1549
|
+
return updateProvider(config, providerId, (provider) => ({
|
|
1550
|
+
...provider,
|
|
1551
|
+
models: provider.models.filter((model) => !modelIds.has(model.id))
|
|
1552
|
+
}));
|
|
1553
|
+
}
|
|
1554
|
+
function replaceSetupProvider(config, replacement) {
|
|
1555
|
+
return updateProvider(config, replacement.id, () => cloneProvider(replacement));
|
|
1556
|
+
}
|
|
1557
|
+
function setProviderEndpoint(config, providerId, endpoint) {
|
|
1558
|
+
return updateProvider(config, providerId, (provider) => ({
|
|
1559
|
+
...provider,
|
|
1560
|
+
endpoint
|
|
1561
|
+
}));
|
|
1562
|
+
}
|
|
1563
|
+
function setProviderHeader(config, providerId, name, value) {
|
|
1564
|
+
return updateProvider(config, providerId, (provider) => ({
|
|
1565
|
+
...provider,
|
|
1566
|
+
headers: {
|
|
1567
|
+
...headersWithoutName(provider.headers, name),
|
|
1568
|
+
[name]: value
|
|
1569
|
+
}
|
|
1570
|
+
}));
|
|
1571
|
+
}
|
|
1572
|
+
function unsetProviderHeader(config, providerId, name) {
|
|
1573
|
+
return updateProvider(config, providerId, (provider) => {
|
|
1574
|
+
if (provider.headers === void 0) return provider;
|
|
1575
|
+
const headers = headersWithoutName(provider.headers, name);
|
|
1576
|
+
return {
|
|
1577
|
+
...provider,
|
|
1578
|
+
headers: Object.keys(headers).length === 0 ? void 0 : headers
|
|
1579
|
+
};
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
function cloneModel(model) {
|
|
1583
|
+
return {
|
|
1584
|
+
...model,
|
|
1585
|
+
aliases: model.aliases === void 0 ? void 0 : [...model.aliases],
|
|
1586
|
+
capabilities: model.capabilities === void 0 ? void 0 : [...model.capabilities],
|
|
1587
|
+
defaultParams: model.defaultParams === void 0 ? void 0 : { ...model.defaultParams }
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
function cloneProvider(provider) {
|
|
1591
|
+
return {
|
|
1592
|
+
...provider,
|
|
1593
|
+
headers: provider.headers === void 0 ? void 0 : { ...provider.headers },
|
|
1594
|
+
models: provider.models.map(cloneModel)
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
function headersWithoutName(headers, name) {
|
|
1598
|
+
const normalizedName = name.toLowerCase();
|
|
1599
|
+
return Object.fromEntries(Object.entries(headers ?? {}).filter(([headerName]) => headerName.toLowerCase() !== normalizedName));
|
|
1600
|
+
}
|
|
1601
|
+
function updateProvider(config, providerId, update) {
|
|
1602
|
+
const providerIndex = config.providers.findIndex((provider) => provider.id === providerId);
|
|
1603
|
+
if (providerIndex === -1) throw new Error(`Unknown provider "${providerId}".`);
|
|
1604
|
+
return {
|
|
1605
|
+
...config,
|
|
1606
|
+
providers: config.providers.map((provider, index) => {
|
|
1607
|
+
const clonedProvider = cloneProvider(provider);
|
|
1608
|
+
return providerIndex === index ? update(clonedProvider) : clonedProvider;
|
|
1609
|
+
})
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
//#endregion
|
|
1523
1613
|
//#region src/setup/write.ts
|
|
1524
1614
|
async function writeSetupConfig(filePath, config) {
|
|
1525
1615
|
await mkdir(dirname$1(filePath), { recursive: true });
|
|
1526
1616
|
await writeFile(filePath, stringifySetupConfigToml(config), "utf8");
|
|
1527
1617
|
}
|
|
1528
1618
|
//#endregion
|
|
1529
|
-
export { builtInAgentNames, createDeclarativePlugin, createEmptyPluginLockFile, createReportScope, declarativeFindingResponseSchema, declarativeFindingSchema, declarativeRuleFilePattern, emptySetupConfig, getGlobalSetupConfigPath, getProjectPluginLockPath, getProjectPluginStorePath, getProjectSetupConfigPath, getStatsDir, hasDeclarativeRuleFiles, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated, installStaticPlugins, isBuiltInAgentName, listMissing, listUnresolved, loadAlintConfig, loadDeclarativeRules, loadPluginLockFile, loadSetupConfig, loadStaticConfig, mergeSetupConfigs, parsePluginLockFile, parsePluginSpecifier, parseSetupConfigToml, parseStaticConfig, stringifySetupConfigToml, toAlintConfig, writePluginLockFile, writeSetupConfig };
|
|
1619
|
+
export { addProviderModels, builtInAgentNames, createDeclarativePlugin, createEmptyPluginLockFile, createReportScope, declarativeFindingResponseSchema, declarativeFindingSchema, declarativeRuleFilePattern, emptySetupConfig, getGlobalSetupConfigPath, getProjectPluginLockPath, getProjectPluginStorePath, getProjectSetupConfigPath, getStatsDir, hasDeclarativeRuleFiles, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated, installStaticPlugins, isBuiltInAgentName, listMissing, listUnresolved, loadAlintConfig, loadDeclarativeRules, loadPluginLockFile, loadSetupConfig, loadStaticConfig, mergeSetupConfigs, parsePluginLockFile, parsePluginSpecifier, parseSetupConfigToml, parseStaticConfig, pruneProviderModels, removeProviderModels, replaceSetupProvider, setProviderEndpoint, setProviderHeader, stringifySetupConfigToml, toAlintConfig, unsetProviderHeader, writePluginLockFile, writeSetupConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alint-js/config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"tar-stream": "^3.2.0",
|
|
28
28
|
"valibot": "^1.4.2",
|
|
29
29
|
"xdg-basedir": "^5.1.0",
|
|
30
|
-
"@alint-js/
|
|
31
|
-
"@alint-js/
|
|
30
|
+
"@alint-js/core": "0.1.1",
|
|
31
|
+
"@alint-js/tools-fs": "0.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/tar-stream": "^3.1.4",
|