@alint-js/cli 0.1.5 → 0.3.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.
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as executeCli } from "../cli-B0jEUKYS.mjs";
2
+ import { t as executeCli } from "../cli-C-ZS6d3a.mjs";
3
3
  import process from "node:process";
4
4
  //#region src/bin/index.ts
5
5
  executeCli(process.argv, {
@@ -12,11 +12,12 @@ import cliSpinners from "cli-spinners";
12
12
  import fastStringWidth from "fast-string-width";
13
13
  import { relative as relative$1 } from "node:path";
14
14
  import fastStringTruncatedWidth from "fast-string-truncated-width";
15
+ import { formatDuration, intervalToDuration } from "date-fns";
15
16
  import Gitignore from "gitignore-fs";
16
17
  import { Minimatch, minimatch } from "minimatch";
17
18
  import { errorMessageFrom as errorMessageFrom$1 } from "@moeru/std";
18
19
  //#region package.json
19
- var version = "0.1.5";
20
+ var version = "0.3.0";
20
21
  //#endregion
21
22
  //#region src/cli/output.ts
22
23
  function escapeLineValue(value) {
@@ -592,8 +593,8 @@ function benchmarkRow(modelId, modelName, providerId, benchmark, color) {
592
593
  modelId,
593
594
  providerId,
594
595
  modelName,
595
- benchmark.error === void 0 ? formatDuration$1(benchmark.repeatMs) : errored,
596
- benchmark.error === void 0 ? formatDuration$1(benchmark.nonRepeatMs) : errored,
596
+ benchmark.error === void 0 ? formatDuration$2(benchmark.repeatMs) : errored,
597
+ benchmark.error === void 0 ? formatDuration$2(benchmark.nonRepeatMs) : errored,
597
598
  benchmark.error === void 0 ? formatThroughput(benchmark.throughput) : errored,
598
599
  `${benchmark.success.completed}/${benchmark.success.attempted}`
599
600
  ];
@@ -612,7 +613,7 @@ function formatBenchmarkTable(rows, columns) {
612
613
  "success"
613
614
  ], ...rows], columns);
614
615
  }
615
- function formatDuration$1(durationMs) {
616
+ function formatDuration$2(durationMs) {
616
617
  if (durationMs === void 0) return "n/a";
617
618
  if (durationMs < 1e3) return `${Math.round(durationMs)}ms`;
618
619
  return `${stripTrailingZeros((durationMs / 1e3).toFixed(2))}s`;
@@ -968,7 +969,8 @@ async function runPruneModelsCommand(context, options, confirm = confirmPruneMod
968
969
  }
969
970
  if (await confirm() !== "confirmed") return 1;
970
971
  }
971
- await writeSetupConfig(path, applyPlans(config, plans));
972
+ const nextConfig = applyPlans(config, plans);
973
+ await writeSetupConfig(path, nextConfig);
972
974
  return hadFailure ? 2 : 0;
973
975
  }
974
976
  function applyPlans(config, plans) {
@@ -1118,7 +1120,8 @@ async function runRemoveModelCommand(context, request, options) {
1118
1120
  context.io.stderr.write(`cannot remove default model "${escapeLineValue(target.provider.id)}/${escapeLineValue(target.model.id)}". select another default first.\n`);
1119
1121
  return 2;
1120
1122
  }
1121
- await writeSetupConfig(path, removeProviderModels(config, target.provider.id, /* @__PURE__ */ new Set([target.model.id])));
1123
+ const nextConfig = removeProviderModels(config, target.provider.id, /* @__PURE__ */ new Set([target.model.id]));
1124
+ await writeSetupConfig(path, nextConfig);
1122
1125
  context.io.stdout.write(`removed model: ${escapeLineValue(target.provider.id)}/${escapeLineValue(target.model.id)}\nscope: ${scope}\n`);
1123
1126
  return 0;
1124
1127
  }
@@ -1342,7 +1345,8 @@ async function runUnsetProviderCommand(context, key, options) {
1342
1345
  context.io.stderr.write("invalid provider header name. expected an HTTP field-name token.\n");
1343
1346
  return 2;
1344
1347
  }
1345
- await writeSetupConfig(path, unsetProviderHeader(config, providerId, headerName));
1348
+ const nextConfig = unsetProviderHeader(config, providerId, headerName);
1349
+ await writeSetupConfig(path, nextConfig);
1346
1350
  context.io.stdout.write(`provider: ${escapeLineValue(providerId)}\nkey: ${escapeLineValue(key)}\nscope: ${scope}\n`);
1347
1351
  return 0;
1348
1352
  }
@@ -1887,7 +1891,10 @@ async function runNonInteractiveUpdate(context, options, providerEndpoint, exist
1887
1891
  context.io.stderr.write(`failed to probe provider: ${errorMessageFrom(error) ?? "Unknown error."}\n`);
1888
1892
  return 2;
1889
1893
  }
1890
- await writeSetupConfig(path, addProviderModels(addProviderModels(replaceSetupProvider(config, draft), draft.id, remoteModelIds), draft.id, toArray$1(options.providerModel)));
1894
+ const replaced = replaceSetupProvider(config, draft);
1895
+ const withRemoteModels = addProviderModels(replaced, draft.id, remoteModelIds);
1896
+ const nextConfig = addProviderModels(withRemoteModels, draft.id, toArray$1(options.providerModel));
1897
+ await writeSetupConfig(path, nextConfig);
1891
1898
  return 0;
1892
1899
  }
1893
1900
  /**
@@ -1937,7 +1944,8 @@ async function runUpdateProviderCommand(context, options) {
1937
1944
  });
1938
1945
  if (result.status !== "confirmed") return 0;
1939
1946
  const replaced = replaceSetupProvider(config, result.provider);
1940
- await writeSetupConfig(path, result.defaultAliasTarget === void 0 ? replaced : applyDefaultAlias(replaced, result.defaultAliasTarget));
1947
+ const nextConfig = result.defaultAliasTarget === void 0 ? replaced : applyDefaultAlias(replaced, result.defaultAliasTarget);
1948
+ await writeSetupConfig(path, nextConfig);
1941
1949
  return 0;
1942
1950
  }
1943
1951
  function scalarOption(value, flag) {
@@ -2348,7 +2356,7 @@ function createRuleGroups(state) {
2348
2356
  }
2349
2357
  function estimateEta(durationMs, terminal, planned) {
2350
2358
  if (terminal <= 0 || planned <= 0 || durationMs <= 0) return "eta ?";
2351
- return `eta ~${formatDuration(durationMs * (planned - terminal) / terminal)}`;
2359
+ return `eta ~${formatDuration$1(durationMs * (planned - terminal) / terminal)}`;
2352
2360
  }
2353
2361
  function fitRow(row, columns) {
2354
2362
  if (columns <= 0) return "";
@@ -2402,8 +2410,13 @@ function formatContentRows(groups, state, options, now, contentBudget) {
2402
2410
  }
2403
2411
  return rows;
2404
2412
  }
2405
- function formatDuration(ms) {
2406
- return `${(Math.max(ms, 0) / 1e3).toFixed(1)}s`;
2413
+ function formatDuration$1(ms) {
2414
+ const durationMs = Math.max(ms, 0);
2415
+ if (durationMs < 6e4) return `${(durationMs / 1e3).toFixed(1)}s`;
2416
+ return formatDuration(intervalToDuration({
2417
+ end: durationMs,
2418
+ start: 0
2419
+ }));
2407
2420
  }
2408
2421
  function formatFooters(state, options, now) {
2409
2422
  const terminal = terminalCount(state.execution);
@@ -2413,7 +2426,7 @@ function formatFooters(state, options, now) {
2413
2426
  const projectedTokens = state.progress.planningComplete && terminal > 0 && state.execution.planned > 0 ? Math.ceil((state.totalTokens + state.cachedTokens) * state.execution.planned / terminal) : void 0;
2414
2427
  const discovering = state.progress.planningComplete ? "" : " jobs (discovering)";
2415
2428
  return [
2416
- fitRow(`${terminal}/${state.execution.planned}${discovering}${progressBar} ${formatDuration(elapsed)} -> ${eta === "eta ?" ? "~?" : eta.replace("eta ", "")}`, options.columns),
2429
+ fitRow(`${terminal}/${state.execution.planned}${discovering}${progressBar} ${formatDuration$1(elapsed)} -> ${eta === "eta ?" ? "~?" : eta.replace("eta ", "")}`, options.columns),
2417
2430
  fitRow(`${state.execution.running} concurrency / ${state.execution.queued} queued / ${state.execution.cached} cached / ${state.execution.failed} failed`, options.columns),
2418
2431
  fitRow(`${state.totalTokens.toLocaleString("en-US")} tokens (${state.cachedTokens.toLocaleString("en-US")} cached) -> ${projectedTokens === void 0 ? "~?" : `~${projectedTokens.toLocaleString("en-US")} tokens`}`, options.columns)
2419
2432
  ];
@@ -2444,7 +2457,7 @@ function formatTargetRow(jobState, options, now, last) {
2444
2457
  const inputPath = options.cwd ? relative$1(options.cwd, jobState.job.inputPath) || "." : jobState.job.inputPath;
2445
2458
  const target = jobState.job.target.name ? `${jobState.job.target.kind} ${jobState.job.target.name}` : jobState.job.target.kind;
2446
2459
  const startedAt = jobState.retry?.startedAt ?? jobState.startedAt ?? now;
2447
- return fitRow(`${last ? " └─" : " ├─"} ${inputPath} > ${target} ${jobState.retry ? `${jobState.retry.attempt}/${jobState.retry.maxAttempts} retrying elapsed ${formatDuration(now - startedAt)}` : `running ${formatDuration(now - startedAt)}`}`, options.columns);
2460
+ return fitRow(`${last ? " └─" : " ├─"} ${inputPath} > ${target} ${jobState.retry ? `${jobState.retry.attempt}/${jobState.retry.maxAttempts} retrying elapsed ${formatDuration$1(now - startedAt)}` : `running ${formatDuration$1(now - startedAt)}`}`, options.columns);
2448
2461
  }
2449
2462
  function styleRow(row, state, warnCount, errorCount, options) {
2450
2463
  let styledRow = row;
@@ -2813,6 +2826,10 @@ function formatFailureGroups(groups, color) {
2813
2826
  for (const failure of group) {
2814
2827
  lines.push(` ${formatTarget(failure)}`);
2815
2828
  lines.push(` [${failure.kind}] ${failure.message}`);
2829
+ for (const cause of failure.causes) {
2830
+ const code = cause.code === void 0 ? "" : `[${cause.code}] `;
2831
+ lines.push(` Caused by: ${code}${cause.message}`);
2832
+ }
2816
2833
  }
2817
2834
  lines.push("");
2818
2835
  }
@@ -2929,7 +2946,7 @@ const UNIT_MS = {
2929
2946
  h: HOUR_MS,
2930
2947
  m: 720 * HOUR_MS,
2931
2948
  w: 168 * HOUR_MS,
2932
- y: 365 * 24 * HOUR_MS
2949
+ y: 8760 * HOUR_MS
2933
2950
  };
2934
2951
  function parseSince(time, now) {
2935
2952
  if (time === void 0 || time === "") return;
@@ -3684,7 +3701,8 @@ async function runInteractiveSetup(io) {
3684
3701
  providers: [result.provider],
3685
3702
  version: 1
3686
3703
  });
3687
- await writeSetupConfig(configPath, result.defaultAliasTarget === void 0 ? merged : applyDefaultAlias(merged, result.defaultAliasTarget));
3704
+ const nextConfig = result.defaultAliasTarget === void 0 ? merged : applyDefaultAlias(merged, result.defaultAliasTarget);
3705
+ await writeSetupConfig(configPath, nextConfig);
3688
3706
  prompts.outro(`Wrote ${configPath}`);
3689
3707
  return 0;
3690
3708
  }
@@ -3764,7 +3782,9 @@ async function runSetupCommand(options, io) {
3764
3782
  return 2;
3765
3783
  }
3766
3784
  const setupConfigPath = options.local ? getProjectSetupConfigPath(io.cwd) : getGlobalSetupConfigPath(io.env ?? process.env);
3767
- await writeSetupConfig(setupConfigPath, mergeSetupConfigs(await loadSetupConfig(setupConfigPath), createSetupConfig(options.providerId, options.providerEndpoint, options)));
3785
+ const existingConfig = await loadSetupConfig(setupConfigPath);
3786
+ const nextConfig = mergeSetupConfigs(existingConfig, createSetupConfig(options.providerId, options.providerEndpoint, options));
3787
+ await writeSetupConfig(setupConfigPath, nextConfig);
3768
3788
  return 0;
3769
3789
  }
3770
3790
  function toArray(value) {
@@ -3963,13 +3983,13 @@ function renderVertical(buckets, values, maxValue, axisWidth, ctx) {
3963
3983
  });
3964
3984
  const gutter = " ".repeat(axisWidth);
3965
3985
  const lines = [];
3966
- for (let row = CHART_HEIGHT - 1; row >= 0; row -= 1) {
3986
+ for (let row = 5; row >= 0; row -= 1) {
3967
3987
  const cells = Array.from({ length: chartWidth }).fill(" ");
3968
3988
  eighths.forEach((total, index) => {
3969
3989
  cells[columnAt(index)] = VERTICAL_BLOCKS[Math.max(0, Math.min(8, total - row * 8))];
3970
3990
  });
3971
- const label = row === CHART_HEIGHT - 1 ? formatMetricValue(maxValue, ctx.metric, ctx.exact).padStart(axisWidth) : gutter;
3972
- const axis = row === CHART_HEIGHT - 1 ? "┤" : "│";
3991
+ const label = row === 5 ? formatMetricValue(maxValue, ctx.metric, ctx.exact).padStart(axisWidth) : gutter;
3992
+ const axis = row === 5 ? "┤" : "│";
3973
3993
  lines.push(`${label} ${axis}${ctx.paint(cells.join("").replace(/\s+$/u, ""), colors.cyan)}`);
3974
3994
  }
3975
3995
  const baseline = Array.from({ length: chartWidth }).fill("─");
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-B0jEUKYS.mjs";
1
+ import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-C-ZS6d3a.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.1.5",
4
+ "version": "0.3.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",
@@ -20,15 +20,16 @@
20
20
  "@moeru/std": "^0.1.0-beta.20",
21
21
  "cac": "^7.0.0",
22
22
  "cli-spinners": "^3.4.0",
23
+ "date-fns": "^4.4.0",
23
24
  "fast-string-truncated-width": "^3.0.3",
24
25
  "fast-string-width": "^3.0.2",
25
26
  "gitignore-fs": "^2.2.3",
26
- "minimatch": "^10.2.5",
27
+ "minimatch": "^10.2.6",
27
28
  "pathe": "^2.0.3",
28
29
  "table": "^6.9.0",
29
- "tinyrainbow": "^3.1.0",
30
- "@alint-js/config": "0.1.5",
31
- "@alint-js/core": "0.1.5"
30
+ "tinyrainbow": "^3.1.1",
31
+ "@alint-js/core": "0.3.0",
32
+ "@alint-js/config": "0.3.0"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@pnpm/find-workspace-dir": "^1000.1.5",