@alint-js/cli 0.0.34 → 0.0.35
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/bin/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import Gitignore from "gitignore-fs";
|
|
|
16
16
|
import { Minimatch, minimatch } from "minimatch";
|
|
17
17
|
import { errorMessageFrom as errorMessageFrom$1 } from "@moeru/std";
|
|
18
18
|
//#region package.json
|
|
19
|
-
var version = "0.0.
|
|
19
|
+
var version = "0.0.35";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/cli/commands/command.ts
|
|
22
22
|
function defineCommand(node) {
|
|
@@ -2366,6 +2366,47 @@ function formatTokens(value) {
|
|
|
2366
2366
|
return value.toLocaleString("en-US");
|
|
2367
2367
|
}
|
|
2368
2368
|
//#endregion
|
|
2369
|
+
//#region src/cli/commands/stats/chart.ts
|
|
2370
|
+
const BAR_WIDTH = 32;
|
|
2371
|
+
const FULL_BLOCK = "█";
|
|
2372
|
+
const PARTIAL_BLOCKS = [
|
|
2373
|
+
"",
|
|
2374
|
+
"▏",
|
|
2375
|
+
"▎",
|
|
2376
|
+
"▍",
|
|
2377
|
+
"▌",
|
|
2378
|
+
"▋",
|
|
2379
|
+
"▊",
|
|
2380
|
+
"▉"
|
|
2381
|
+
];
|
|
2382
|
+
function formatStatsChart(aggregate, options = {}) {
|
|
2383
|
+
const paint = (text, style) => options.color === true ? style(text) : text;
|
|
2384
|
+
const runLabel = aggregate.totalRuns === 1 ? "run" : "runs";
|
|
2385
|
+
const lines = [`${aggregate.totalRuns} ${runLabel} — ${formatTokens(aggregate.totalIn)} in / ${formatTokens(aggregate.totalOut)} out / ${paint(`${formatTokens(aggregate.totalTok)} total`, colors.cyan)}`, ""];
|
|
2386
|
+
if (aggregate.rows.length === 0) {
|
|
2387
|
+
lines.push("No stats recorded yet.");
|
|
2388
|
+
return `${lines.join("\n")}\n`;
|
|
2389
|
+
}
|
|
2390
|
+
const maxTok = Math.max(...aggregate.rows.map((row) => row.totalTok));
|
|
2391
|
+
const label = DIMENSION_LABEL[aggregate.dimension];
|
|
2392
|
+
const keyWidth = Math.max(label.length, ...aggregate.rows.map((row) => row.key.length));
|
|
2393
|
+
const values = aggregate.rows.map((row) => formatTokens(row.totalTok));
|
|
2394
|
+
const valueWidth = Math.max(5, ...values.map((value) => value.length));
|
|
2395
|
+
lines.push(paint(`${label.padEnd(keyWidth)} ${" ".repeat(BAR_WIDTH)} ${"total".padStart(valueWidth)} share`, colors.bold));
|
|
2396
|
+
aggregate.rows.forEach((row, index) => {
|
|
2397
|
+
const bar = renderBar(maxTok === 0 ? 0 : row.totalTok / maxTok);
|
|
2398
|
+
const share = aggregate.totalTok === 0 ? 0 : row.totalTok / aggregate.totalTok * 100;
|
|
2399
|
+
lines.push(`${row.key.padEnd(keyWidth)} ${paint(bar, colors.cyan)} ${values[index].padStart(valueWidth)} ${share.toFixed(1).padStart(5)}%`);
|
|
2400
|
+
});
|
|
2401
|
+
return `${lines.join("\n")}\n`;
|
|
2402
|
+
}
|
|
2403
|
+
function renderBar(fraction) {
|
|
2404
|
+
const eighths = fraction <= 0 ? 0 : Math.max(1, Math.round(fraction * BAR_WIDTH * 8));
|
|
2405
|
+
const full = Math.floor(eighths / 8);
|
|
2406
|
+
const remainder = eighths % 8;
|
|
2407
|
+
return `${FULL_BLOCK.repeat(full)}${PARTIAL_BLOCKS[remainder]}`.padEnd(BAR_WIDTH);
|
|
2408
|
+
}
|
|
2409
|
+
//#endregion
|
|
2369
2410
|
//#region src/cli/commands/stats/stats.ts
|
|
2370
2411
|
const DIMENSIONS = /* @__PURE__ */ new Set([
|
|
2371
2412
|
"dir",
|
|
@@ -2382,7 +2423,7 @@ async function runStatsCommand(options, io) {
|
|
|
2382
2423
|
cwd: options.here === true ? io.cwd : options.cwd,
|
|
2383
2424
|
since: options.since
|
|
2384
2425
|
});
|
|
2385
|
-
io.stdout.write(
|
|
2426
|
+
io.stdout.write(render(aggregate, options, io.stdout.isTTY === true));
|
|
2386
2427
|
return 0;
|
|
2387
2428
|
} catch (error) {
|
|
2388
2429
|
io.stderr.write(`${errorMessageFrom$1(error) ?? "Failed to read stats."}\n`);
|
|
@@ -2394,6 +2435,11 @@ function parseDimension(value) {
|
|
|
2394
2435
|
if (DIMENSIONS.has(value)) return value;
|
|
2395
2436
|
throw new Error(`Invalid --by "${value}": use rule, operation, model, or dir.`);
|
|
2396
2437
|
}
|
|
2438
|
+
function render(aggregate, options, color) {
|
|
2439
|
+
if (options.json === true) return `${JSON.stringify(aggregate, null, 2)}\n`;
|
|
2440
|
+
if (options.chart === true) return formatStatsChart(aggregate, { color });
|
|
2441
|
+
return formatStatsAggregate(aggregate, { color });
|
|
2442
|
+
}
|
|
2397
2443
|
function statsLocation(stats) {
|
|
2398
2444
|
return typeof stats === "object" ? stats.location : void 0;
|
|
2399
2445
|
}
|
|
@@ -2425,6 +2471,10 @@ const commandTree = [
|
|
|
2425
2471
|
description: "Only include runs from the current directory",
|
|
2426
2472
|
flags: "--here"
|
|
2427
2473
|
},
|
|
2474
|
+
{
|
|
2475
|
+
description: "Render grouped rows as a bar chart",
|
|
2476
|
+
flags: "--chart"
|
|
2477
|
+
},
|
|
2428
2478
|
{
|
|
2429
2479
|
description: "Output JSON",
|
|
2430
2480
|
flags: "--json"
|
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-
|
|
1
|
+
import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-CZbrV2gX.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.
|
|
4
|
+
"version": "0.0.35",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"pathe": "^2.0.3",
|
|
28
28
|
"table": "^6.9.0",
|
|
29
29
|
"tinyrainbow": "^3.1.0",
|
|
30
|
-
"@alint-js/
|
|
31
|
-
"@alint-js/
|
|
30
|
+
"@alint-js/core": "0.0.35",
|
|
31
|
+
"@alint-js/config": "0.0.35"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@pnpm/find-workspace-dir": "^1000.1.5",
|