@alint-js/cli 0.0.20 → 0.0.21

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as executeCli } from "../cli-CGvIT3NA.mjs";
2
+ import { t as executeCli } from "../cli-Dey9TSc8.mjs";
3
3
  import process from "node:process";
4
4
  //#region src/bin/index.ts
5
5
  executeCli(process.argv, {
@@ -14,7 +14,7 @@ import Gitignore from "gitignore-fs";
14
14
  import { Minimatch, minimatch } from "minimatch";
15
15
  import { errorMessageFrom as errorMessageFrom$1 } from "@moeru/std";
16
16
  //#region package.json
17
- var version = "0.0.20";
17
+ var version = "0.0.21";
18
18
  //#endregion
19
19
  //#region src/cli/commands/command.ts
20
20
  function defineCommand(node) {
@@ -226,13 +226,39 @@ async function runConfigInspectCommand(file, configPath, io) {
226
226
  }
227
227
  //#endregion
228
228
  //#region src/cli/provider-registry.ts
229
+ const providerSetupSources = [
230
+ {
231
+ defaultEndpoint: "http://127.0.0.1:8317/v1",
232
+ defaultProviderId: "CLIProxyAPI",
233
+ label: "CLIProxyAPI",
234
+ probeModels: true,
235
+ value: "cliProxyApi"
236
+ },
237
+ {
238
+ label: "Custom OpenAI-compatible provider",
239
+ probeModels: true,
240
+ value: "custom"
241
+ },
242
+ {
243
+ defaultEndpoint: "http://localhost:11434/v1",
244
+ label: "Ollama",
245
+ probeModels: true,
246
+ value: "ollama"
247
+ },
248
+ {
249
+ label: "Manual model entry",
250
+ probeModels: false,
251
+ value: "manual"
252
+ }
253
+ ];
229
254
  function buildModelsUrl(endpoint) {
230
255
  return new URL("models", endpoint.endsWith("/") ? endpoint : `${endpoint}/`).toString();
231
256
  }
232
257
  function createProviderId(endpoint, existingIds) {
233
258
  let base = "provider";
234
259
  try {
235
- base = new URL(endpoint).hostname.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "").toLowerCase() || "provider";
260
+ const url = new URL(endpoint);
261
+ base = findProviderSetupSourceByEndpoint(url)?.defaultProviderId ?? (url.hostname.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "").toLowerCase() || "provider");
236
262
  } catch {
237
263
  base = "provider";
238
264
  }
@@ -245,6 +271,13 @@ function createProviderId(endpoint, existingIds) {
245
271
  function findModel(config, request) {
246
272
  return flattenModels(config).find(({ model }) => model.id === request || model.name === request || (model.aliases ?? []).includes(request));
247
273
  }
274
+ function findProviderSetupSource(value) {
275
+ return providerSetupSources.find((source) => source.value === value);
276
+ }
277
+ function findProviderSetupSourceByEndpoint(endpoint) {
278
+ const normalizedEndpoint = endpoint instanceof URL ? endpoint.toString() : new URL(endpoint).toString();
279
+ return providerSetupSources.find((source) => source.defaultEndpoint !== void 0 && new URL(source.defaultEndpoint).toString() === normalizedEndpoint);
280
+ }
248
281
  function flattenModels(config) {
249
282
  return config.providers.flatMap((provider) => provider.models.map((model) => ({
250
283
  model,
@@ -1722,20 +1755,10 @@ async function runInteractiveSetup(io) {
1722
1755
  if (step === "source") {
1723
1756
  const source = await prompts.select({
1724
1757
  message: "Choose provider setup mode.",
1725
- options: withBackOption([
1726
- {
1727
- label: "Custom OpenAI-compatible provider",
1728
- value: "custom"
1729
- },
1730
- {
1731
- label: "Ollama",
1732
- value: "ollama"
1733
- },
1734
- {
1735
- label: "Manual model entry",
1736
- value: "manual"
1737
- }
1738
- ])
1758
+ options: withBackOption(providerSetupSources.map(({ label, value }) => ({
1759
+ label,
1760
+ value
1761
+ })))
1739
1762
  });
1740
1763
  if (prompts.isCancel(source)) return cancelPrompt();
1741
1764
  if (source === backValue) {
@@ -1747,7 +1770,9 @@ async function runInteractiveSetup(io) {
1747
1770
  continue;
1748
1771
  }
1749
1772
  if (step === "endpoint") {
1750
- const endpoint = await promptEndpoint(prompts, draft.source ?? "custom");
1773
+ const setupSource = findProviderSetupSource(draft.source ?? "custom");
1774
+ if (setupSource === void 0) return cancelPrompt();
1775
+ const endpoint = await promptEndpoint(prompts, setupSource);
1751
1776
  if (prompts.isCancel(endpoint)) return cancelPrompt();
1752
1777
  if (typeof endpoint !== "string") return cancelPrompt();
1753
1778
  if (isBackInput(endpoint)) {
@@ -1799,7 +1824,7 @@ async function runInteractiveSetup(io) {
1799
1824
  }
1800
1825
  draft.headerInput = headerInput;
1801
1826
  draft.headers = parseHeaderList(splitHeaderInput(headerInput));
1802
- draft.discoveredModels = draft.source === "manual" ? [] : await probeModelsWithSpinner(prompts, draft.endpoint ?? "", draft.headers);
1827
+ draft.discoveredModels = findProviderSetupSource(draft.source ?? "custom")?.probeModels === false ? [] : await probeModelsWithSpinner(prompts, draft.endpoint ?? "", draft.headers);
1803
1828
  step = "models";
1804
1829
  continue;
1805
1830
  }
@@ -1902,9 +1927,9 @@ async function probeModelsWithSpinner(prompts, endpoint, headers) {
1902
1927
  }
1903
1928
  async function promptEndpoint(prompts, source) {
1904
1929
  return prompts.text({
1905
- defaultValue: source === "ollama" ? "http://localhost:11434/v1" : void 0,
1930
+ defaultValue: source.defaultEndpoint,
1906
1931
  message: "Provider endpoint",
1907
- placeholder: source === "ollama" ? "http://localhost:11434/v1; type .. to go back" : "https://example.test/v1; type .. to go back",
1932
+ placeholder: `${source.defaultEndpoint ?? "https://example.test/v1"}; type .. to go back`,
1908
1933
  validate: (value) => isBackInput(value ?? "") || (value ?? "").trim().length > 0 ? void 0 : "Provider endpoint is required."
1909
1934
  });
1910
1935
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-CGvIT3NA.mjs";
1
+ import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-Dey9TSc8.mjs";
2
2
  import { ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated } from "@alint-js/config";
3
3
  import { defineConfig } from "@alint-js/core";
4
4
  export { defineConfig, executeCli, formatDiagnostics, formatJson, formatStylish, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/cli",
3
3
  "type": "module",
4
- "version": "0.0.20",
4
+ "version": "0.0.21",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",
@@ -25,8 +25,8 @@
25
25
  "pathe": "^2.0.3",
26
26
  "table": "^6.9.0",
27
27
  "tinyrainbow": "^3.1.0",
28
- "@alint-js/core": "0.0.20",
29
- "@alint-js/config": "0.0.20"
28
+ "@alint-js/config": "0.0.21",
29
+ "@alint-js/core": "0.0.21"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@pnpm/find-workspace-dir": "^1000.1.5",