@trazum/cli 2.2.1 → 2.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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +52 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trazum/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Trazum CLI: find where your LLM bill goes, price every finding per month, and enforce token budgets in CI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Mu\u00f1oz Rey",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"prepublishOnly": "npm run build && npm test"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@trazum/core": "2.
|
|
44
|
+
"@trazum/core": "2.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^26.2.0",
|
package/src/index.ts
CHANGED
|
@@ -125,6 +125,7 @@ import {
|
|
|
125
125
|
positionAt,
|
|
126
126
|
positionReport,
|
|
127
127
|
PRICING_LAST_REVIEWED,
|
|
128
|
+
reviewedForModels,
|
|
128
129
|
PROVIDER_REVIEWED,
|
|
129
130
|
STALE_PRICING_DAYS,
|
|
130
131
|
profilePrompt,
|
|
@@ -9970,6 +9971,8 @@ async function commandProfile(
|
|
|
9970
9971
|
}
|
|
9971
9972
|
const windowed = sinceMs !== undefined || untilMs !== undefined;
|
|
9972
9973
|
|
|
9974
|
+
const report = profileUsage(raw, { catalogue: pricing, label: onlyLabel, sinceMs, untilMs });
|
|
9975
|
+
|
|
9973
9976
|
/**
|
|
9974
9977
|
* How old the price table behind every dollar below is. Stated only when it
|
|
9975
9978
|
* is old enough to matter: `models` and `doctor` always print the date, but
|
|
@@ -9978,14 +9981,26 @@ async function commandProfile(
|
|
|
9978
9981
|
* The threshold is in the sentence, and the number behind it is
|
|
9979
9982
|
* `STALE_PRICING_DAYS` — shared with the MCP report and the browser's bill,
|
|
9980
9983
|
* which used to keep their own copies of it.
|
|
9984
|
+
*
|
|
9985
|
+
* **The date is this report's, not the catalogue's**, and it is computed
|
|
9986
|
+
* after the report for that reason rather than before it as it used to be.
|
|
9987
|
+
* `PRICING_LAST_REVIEWED` is the oldest provider's, so a log of Claude and
|
|
9988
|
+
* OpenAI calls was told its prices were 68 days old on a morning when both
|
|
9989
|
+
* halves had been read that week — by a sentence that says, in these words,
|
|
9990
|
+
* that the table behind *every dollar here* was reviewed then. It was not.
|
|
9991
|
+
* `reviewedForModels` answers for the providers that actually priced this
|
|
9992
|
+
* report and falls back to the catalogue's own date wherever it cannot.
|
|
9981
9993
|
*/
|
|
9982
|
-
const
|
|
9994
|
+
const reportReviewed = reviewedForModels(
|
|
9995
|
+
report.byModel.map((row) => row.model),
|
|
9996
|
+
pricing,
|
|
9997
|
+
);
|
|
9998
|
+
const pricingAgeDays = reviewAgeDays(reportReviewed, new Date());
|
|
9983
9999
|
const pricingStale =
|
|
9984
10000
|
pricingAgeDays !== null && pricingAgeDays > STALE_PRICING_DAYS
|
|
9985
|
-
? { date:
|
|
10001
|
+
? { date: reportReviewed, days: pricingAgeDays }
|
|
9986
10002
|
: null;
|
|
9987
10003
|
|
|
9988
|
-
const report = profileUsage(raw, { catalogue: pricing, label: onlyLabel, sinceMs, untilMs });
|
|
9989
10004
|
if (report.total.calls === 0 && report.unpriced.calls === 0) {
|
|
9990
10005
|
if (onlyLabel !== undefined || windowed) {
|
|
9991
10006
|
// Diagnose against the log without the failed filter, so the error can
|
|
@@ -10208,8 +10223,32 @@ async function commandProfile(
|
|
|
10208
10223
|
label: r.label,
|
|
10209
10224
|
cache: cacheEconomics(r.breakdown),
|
|
10210
10225
|
})),
|
|
10211
|
-
|
|
10212
|
-
|
|
10226
|
+
/*
|
|
10227
|
+
The provenance of every dollar above, in two parts that are not the
|
|
10228
|
+
same question.
|
|
10229
|
+
|
|
10230
|
+
`lastReviewed` and `ageDays` are the **table's**: its oldest
|
|
10231
|
+
provider, which is what "how old is this catalogue" means and what
|
|
10232
|
+
these two keys have always carried. Unchanged, because a key cannot
|
|
10233
|
+
change meaning under a minor and a consumer branching on them keeps
|
|
10234
|
+
working.
|
|
10235
|
+
|
|
10236
|
+
`reportReviewed` and `reportAgeDays` are **these figures'**: the
|
|
10237
|
+
oldest provider among the models actually priced here, which is the
|
|
10238
|
+
pair the staleness warning is decided from. They are new keys, and
|
|
10239
|
+
new keys are additions the contract allows.
|
|
10240
|
+
|
|
10241
|
+
The two differ exactly when a report uses none of the models
|
|
10242
|
+
holding the table back — which was the whole defect: a log of
|
|
10243
|
+
Claude and OpenAI calls was told its prices were 68 days old on a
|
|
10244
|
+
morning both halves had been read that week.
|
|
10245
|
+
*/
|
|
10246
|
+
pricing: {
|
|
10247
|
+
lastReviewed: pricing.lastReviewed,
|
|
10248
|
+
ageDays: reviewAgeDays(pricing.lastReviewed, new Date()),
|
|
10249
|
+
reportReviewed,
|
|
10250
|
+
reportAgeDays: pricingAgeDays,
|
|
10251
|
+
},
|
|
10213
10252
|
levers: billLevers(report, { catalogue: pricing }),
|
|
10214
10253
|
// Present only when --against was passed: null delta means the
|
|
10215
10254
|
// previous log had nothing priced, which is a different answer from
|
|
@@ -12849,11 +12888,14 @@ function printDoctor(
|
|
|
12849
12888
|
console.log(
|
|
12850
12889
|
c.dim(t.doctor.subheading(model?.displayName ?? usage.model, n(usage.callsPerMonth))),
|
|
12851
12890
|
);
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12891
|
+
/*
|
|
12892
|
+
This prompt's own model, not the catalogue's oldest provider. `doctor`
|
|
12893
|
+
reports on one model and one bill, so the date that qualifies it is the
|
|
12894
|
+
date that model's provider was read — the catalogue-wide answer named a
|
|
12895
|
+
provider this prompt does not use.
|
|
12896
|
+
*/
|
|
12897
|
+
const reviewed = reviewedForModels([usage.model], pricing);
|
|
12898
|
+
console.log(c.dim(t.doctor.pricesReviewed(reviewed, reviewAgeDays(reviewed, new Date()))));
|
|
12857
12899
|
|
|
12858
12900
|
// Budgets first. Everything below is money; this is whether anything is
|
|
12859
12901
|
// watching at all, and an unwatched prompt is how the money got there.
|