jinzd-ai-cli 0.4.183 → 0.4.184
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/{batch-V4KR6ENR.js → batch-ROTBHZ56.js} +2 -2
- package/dist/{chunk-A56C3L4P.js → chunk-2DVGTYZG.js} +1 -1
- package/dist/{chunk-G44XZPNZ.js → chunk-4JWMT7XQ.js} +3 -3
- package/dist/chunk-7D67AR56.js +228 -0
- package/dist/chunk-BLRPRWZX.js +102 -0
- package/dist/{chunk-JWT54N7I.js → chunk-HNSN575P.js} +1 -1
- package/dist/{chunk-2AZX76LV.js → chunk-NVCB6SFZ.js} +1 -1
- package/dist/{chunk-ETGCCZBT.js → chunk-PS6S4IIW.js} +1 -1
- package/dist/{chunk-UCPHXAHM.js → chunk-QLHGIWTT.js} +2 -98
- package/dist/{chunk-M5JHEB35.js → chunk-WGJ7LE6T.js} +1 -1
- package/dist/{chunk-3GZ7RYAP.js → chunk-WLMBMRIA.js} +1 -1
- package/dist/{ci-NS7PR27C.js → ci-Y5JKHJPG.js} +2 -2
- package/dist/{constants-EQ7ULMVF.js → constants-UGNL2FJR.js} +1 -1
- package/dist/{doctor-cli-VWYAVULH.js → doctor-cli-6OZTPWTL.js} +4 -4
- package/dist/electron-server.js +4 -2
- package/dist/{hub-DBGEPDIE.js → hub-UMVOJF26.js} +1 -1
- package/dist/index.js +61 -187
- package/dist/{run-tests-3FJMYYIU.js → run-tests-JHICSWKH.js} +2 -2
- package/dist/{run-tests-UM2YUDTP.js → run-tests-L6773UMG.js} +1 -1
- package/dist/{server-3KIQK257.js → server-D2NQLJBH.js} +11 -9
- package/dist/{server-CESWZS3I.js → server-KUJV27ZT.js} +4 -4
- package/dist/{task-orchestrator-2S5WM7GH.js → task-orchestrator-DTX44RG2.js} +4 -4
- package/dist/usage-4724JLXN.js +80 -0
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CostTracker
|
|
4
|
+
} from "./chunk-7D67AR56.js";
|
|
5
|
+
import {
|
|
6
|
+
formatCost
|
|
7
|
+
} from "./chunk-BLRPRWZX.js";
|
|
8
|
+
import {
|
|
9
|
+
ConfigManager
|
|
10
|
+
} from "./chunk-WLMBMRIA.js";
|
|
11
|
+
import "./chunk-TZQHYZKT.js";
|
|
12
|
+
import "./chunk-2DVGTYZG.js";
|
|
13
|
+
import "./chunk-PDX44BCA.js";
|
|
14
|
+
|
|
15
|
+
// src/cli/usage.ts
|
|
16
|
+
function num(n) {
|
|
17
|
+
return n.toLocaleString("en-US");
|
|
18
|
+
}
|
|
19
|
+
async function runUsageCli(options = {}) {
|
|
20
|
+
const chalk = (await import("chalk")).default;
|
|
21
|
+
const config = new ConfigManager();
|
|
22
|
+
const tracker = new CostTracker(config.getConfigDir());
|
|
23
|
+
const sinceDays = options.days ? Math.max(1, parseInt(options.days, 10) || 0) : void 0;
|
|
24
|
+
const month = options.month?.trim();
|
|
25
|
+
if (month && !/^\d{4}-\d{2}$/.test(month)) {
|
|
26
|
+
console.error(`Invalid --month "${month}". Expected YYYY-MM (e.g. 2026-06).`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
const breakdown = tracker.getUsageBreakdown({ sinceDays, month });
|
|
30
|
+
if (options.json) {
|
|
31
|
+
console.log(JSON.stringify(breakdown, null, 2));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const { rows, totals, fromDate, toDate, dayCount } = breakdown;
|
|
35
|
+
let window;
|
|
36
|
+
if (month) window = month;
|
|
37
|
+
else if (sinceDays) window = `last ${sinceDays} day${sinceDays === 1 ? "" : "s"}`;
|
|
38
|
+
else window = "all tracked history";
|
|
39
|
+
console.log();
|
|
40
|
+
console.log(chalk.bold(" \u{1F4B0} Usage by model") + chalk.dim(` \u2014 ${window}`));
|
|
41
|
+
if (fromDate && toDate) {
|
|
42
|
+
const span = fromDate === toDate ? fromDate : `${fromDate} \u2192 ${toDate}`;
|
|
43
|
+
console.log(chalk.dim(` ${span} (${dayCount} day${dayCount === 1 ? "" : "s"} with activity)`));
|
|
44
|
+
}
|
|
45
|
+
console.log();
|
|
46
|
+
if (rows.length === 0) {
|
|
47
|
+
console.log(chalk.dim(" No usage recorded yet."));
|
|
48
|
+
if (sinceDays || month) console.log(chalk.dim(" Try a wider window, or `aicli usage` for all history."));
|
|
49
|
+
console.log(chalk.dim(" (cost history accrues as you chat in the REPL / Web UI; up to 90 days.)"));
|
|
50
|
+
console.log();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const nameW = Math.min(42, Math.max(20, ...rows.map((r) => label(r).length)));
|
|
54
|
+
const rule = " " + chalk.dim("\u2500".repeat(nameW + 7 + 14 + 14 + 13));
|
|
55
|
+
console.log(
|
|
56
|
+
" " + chalk.bold("Provider / Model".padEnd(nameW)) + chalk.bold("Calls".padStart(7)) + chalk.bold("Input".padStart(14)) + chalk.bold("Output".padStart(14)) + chalk.bold("Cost".padStart(13))
|
|
57
|
+
);
|
|
58
|
+
console.log(rule);
|
|
59
|
+
for (const r of rows) {
|
|
60
|
+
const isFree = r.cost === 0;
|
|
61
|
+
const namePad = r.provider === "(unattributed)" ? chalk.dim("(unattributed, pre-v0.4.184)".padEnd(nameW)) : chalk.cyan(label(r).padEnd(nameW));
|
|
62
|
+
console.log(
|
|
63
|
+
" " + namePad + chalk.white(num(r.calls).padStart(7)) + chalk.white(num(r.inputTokens).padStart(14)) + chalk.white(num(r.outputTokens).padStart(14)) + (isFree ? chalk.dim("$0.00".padStart(13)) : chalk.cyan(formatCost(r.cost).padStart(13)))
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
console.log(rule);
|
|
67
|
+
console.log(
|
|
68
|
+
" " + chalk.bold("Total".padEnd(nameW)) + chalk.bold(num(totals.calls).padStart(7)) + chalk.bold(num(totals.inputTokens).padStart(14)) + chalk.bold(num(totals.outputTokens).padStart(14)) + chalk.bold.cyan(formatCost(totals.cost).padStart(13))
|
|
69
|
+
);
|
|
70
|
+
if (totals.cacheReadTokens > 0) {
|
|
71
|
+
console.log(chalk.dim(` (incl. ${num(totals.cacheReadTokens)} cached-read tokens billed at the cache rate)`));
|
|
72
|
+
}
|
|
73
|
+
console.log();
|
|
74
|
+
}
|
|
75
|
+
function label(r) {
|
|
76
|
+
return r.model ? `${r.provider}/${r.model}` : r.provider;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
runUsageCli
|
|
80
|
+
};
|