@trazum/cli 1.62.1 → 1.64.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/html.d.ts +42 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +250 -0
- package/dist/html.js.map +1 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +36 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +38 -1
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +24 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.js +97 -25
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/html.ts +343 -0
- package/src/i18n/en.ts +40 -1
- package/src/i18n/es.ts +42 -1
- package/src/i18n/types.ts +25 -0
- package/src/index.ts +109 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trazum/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.64.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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build && npm test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@trazum/core": "1.
|
|
40
|
+
"@trazum/core": "1.64.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26.2.0",
|
package/src/html.ts
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { UNLABELLED, formatUsd, sharesOf } from '@trazum/core';
|
|
2
|
+
import type { RollupDocument, UsageBreakdown } from '@trazum/core';
|
|
3
|
+
import type { CliMessages } from './i18n/index.js';
|
|
4
|
+
import type { ProfileMarkdownInput } from './markdown.js';
|
|
5
|
+
import { dayOf, spanDays } from './time.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* HTML for the person who does not run CLIs.
|
|
9
|
+
*
|
|
10
|
+
* One self-contained file: inline CSS, no scripts, no external assets — a
|
|
11
|
+
* mail client, a wiki upload and a double-click all render it the same. It
|
|
12
|
+
* is a **projection of the document `--json` prints**, taking the exact same
|
|
13
|
+
* input object as the Markdown renderer: no second computation exists to
|
|
14
|
+
* disagree with the first, and the parity guard in the suite walks every
|
|
15
|
+
* figure here back to that document.
|
|
16
|
+
*
|
|
17
|
+
* The design rule this repository applies to its terminal output is applied
|
|
18
|
+
* here where a designer would be tempted to grey it out: **the caveats are
|
|
19
|
+
* furniture, not footnotes.** Unpriced models, skipped lines and the absent
|
|
20
|
+
* fields render inside a bordered block ahead of the detail tables, at the
|
|
21
|
+
* same visual weight as the totals they qualify — a forwarded report whose
|
|
22
|
+
* limits can be cropped out is a lie by omission wearing this tool's name.
|
|
23
|
+
*
|
|
24
|
+
* Escaping is not optional politeness: labels, model ids and file paths come
|
|
25
|
+
* from somebody's log, and a label is exactly where `<script>` would arrive.
|
|
26
|
+
* Everything interpolated goes through `esc()`, tested with hostile labels.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export function esc(value: string): string {
|
|
30
|
+
return value
|
|
31
|
+
.replaceAll('&', '&')
|
|
32
|
+
.replaceAll('<', '<')
|
|
33
|
+
.replaceAll('>', '>')
|
|
34
|
+
.replaceAll('"', '"')
|
|
35
|
+
.replaceAll("'", ''');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A single committed look, print-first: explicit colours on everything, a
|
|
40
|
+
* caveat block that a printer and a dark-mode mail client both keep legible.
|
|
41
|
+
* No media-query theming — this file's job is to look the same everywhere,
|
|
42
|
+
* including on paper.
|
|
43
|
+
*/
|
|
44
|
+
const STYLE = `
|
|
45
|
+
:root { color-scheme: light; }
|
|
46
|
+
body { margin: 0; padding: 2.5rem 1.25rem; background: #f7f6f3; color: #1f2328;
|
|
47
|
+
font: 16px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
|
|
48
|
+
main { max-width: 860px; margin: 0 auto; background: #ffffff; border: 1px solid #d9d5cc;
|
|
49
|
+
border-radius: 6px; padding: 2.25rem 2.5rem; }
|
|
50
|
+
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
|
|
51
|
+
h2 { font-size: 1.05rem; margin: 2rem 0 .5rem; border-bottom: 1px solid #e4e0d8; padding-bottom: .3rem; }
|
|
52
|
+
.headline { font-size: 1.8rem; font-weight: 700; margin: .75rem 0 .1rem; font-variant-numeric: tabular-nums; }
|
|
53
|
+
.muted { color: #59606a; }
|
|
54
|
+
.gate-fail { border: 2px solid #b42318; background: #fdf1f0; color: #7a1a12;
|
|
55
|
+
padding: .7rem 1rem; border-radius: 6px; margin: 1rem 0; font-weight: 600; }
|
|
56
|
+
.gate-pass { color: #365f37; margin: 1rem 0; }
|
|
57
|
+
.caveats { border: 2px solid #8a6d1a; background: #fbf6e9; border-radius: 6px;
|
|
58
|
+
padding: 1rem 1.25rem; margin: 1.5rem 0; }
|
|
59
|
+
.caveats h2 { margin: 0 0 .5rem; border: 0; padding: 0; font-size: 1.05rem; color: #6d5510; }
|
|
60
|
+
.caveats ul { margin: 0; padding-left: 1.2rem; }
|
|
61
|
+
.caveats li { margin: .3rem 0; }
|
|
62
|
+
table { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; font-variant-numeric: tabular-nums; }
|
|
63
|
+
th { text-align: left; font-weight: 600; border-bottom: 2px solid #d9d5cc; padding: .35rem .6rem .35rem 0; }
|
|
64
|
+
td { border-bottom: 1px solid #ece9e2; padding: .35rem .6rem .35rem 0; }
|
|
65
|
+
td.n, th.n { text-align: right; }
|
|
66
|
+
ul.findings { padding-left: 1.2rem; } ul.findings li { margin: .35rem 0; }
|
|
67
|
+
footer { margin-top: 2rem; padding-top: .75rem; border-top: 1px solid #e4e0d8;
|
|
68
|
+
font-size: .85rem; color: #59606a; }
|
|
69
|
+
@media print { body { background: #ffffff; padding: 0; } main { border: 0; padding: 0; } }
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
interface Row {
|
|
73
|
+
name: string;
|
|
74
|
+
breakdown: UsageBreakdown;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function breakdownTable(rows: Row[], totalUsd: number, t: ProfileMarkdownInput['t'], nameHeading: string): string {
|
|
78
|
+
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
79
|
+
const body = rows
|
|
80
|
+
.map(({ name, breakdown: b }) => {
|
|
81
|
+
const share = totalUsd > 0 ? `${((b.totalUsd / totalUsd) * 100).toFixed(1)}%` : '—';
|
|
82
|
+
return `<tr><td>${esc(name)}</td><td class="n">${n(b.calls)}</td><td class="n">${n(b.inputTokens)}</td><td class="n">${n(b.cacheReadTokens)}</td><td class="n">${n(b.cacheWriteTokens)}</td><td class="n">${n(b.outputTokens)}</td><td class="n">${esc(formatUsd(b.totalUsd))}</td><td class="n">${share}</td></tr>`;
|
|
83
|
+
})
|
|
84
|
+
.join('\n');
|
|
85
|
+
return `<table><thead><tr><th>${esc(nameHeading)}</th><th class="n">${esc(t.html.colCalls())}</th><th class="n">${esc(t.html.colInput())}</th><th class="n">${esc(t.html.colCacheRead())}</th><th class="n">${esc(t.html.colCacheWrite())}</th><th class="n">${esc(t.html.colOutput())}</th><th class="n">USD</th><th class="n">%</th></tr></thead><tbody>\n${body}\n</tbody></table>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The profile as one self-contained page. Same input as the Markdown door. */
|
|
89
|
+
export function renderProfileHtml(input: ProfileMarkdownInput): string {
|
|
90
|
+
const { report, levers, cache, t, gates, window, stalePricing } = input;
|
|
91
|
+
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
92
|
+
const pct = (share: number): string => `${(share * 100).toFixed(1)}%`;
|
|
93
|
+
const showLabel = (label: string): string => (label === UNLABELLED ? t.profile.unlabelled() : label);
|
|
94
|
+
const shares = sharesOf(report.total);
|
|
95
|
+
const parts: string[] = [];
|
|
96
|
+
|
|
97
|
+
parts.push(`<h1>${esc(t.profile.heading())}</h1>`);
|
|
98
|
+
parts.push(
|
|
99
|
+
`<p class="headline">${esc(t.profile.spent(t.profile.calls(report.total.calls), formatUsd(report.total.totalUsd)))}</p>`,
|
|
100
|
+
);
|
|
101
|
+
if (report.span !== null) {
|
|
102
|
+
parts.push(
|
|
103
|
+
`<p class="muted">${esc(t.profile.spanLine(dayOf(report.span.fromMs), dayOf(report.span.toMs), spanDays(report.span.fromMs, report.span.toMs)))}</p>`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (window !== undefined) {
|
|
107
|
+
parts.push(`<p class="muted">${esc(t.profile.windowLine(window.since, window.until))}</p>`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (gates !== undefined && gates.lines.length > 0) {
|
|
111
|
+
const box = gates.failed ? 'gate-fail' : 'gate-pass';
|
|
112
|
+
parts.push(`<div class="${box}">${gates.lines.map((line) => esc(line)).join('<br>')}</div>`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The caveats, ahead of every detail table. What this report cannot say is
|
|
117
|
+
* part of what it says, and it renders before the part a skimmer stops at.
|
|
118
|
+
*/
|
|
119
|
+
const caveats: string[] = [];
|
|
120
|
+
if (report.unpricedModels.length > 0) {
|
|
121
|
+
caveats.push(esc(t.profile.unpriced(report.unpricedModels.join(', '), report.unpriced.calls)));
|
|
122
|
+
}
|
|
123
|
+
if (report.skippedLines.length > 0) {
|
|
124
|
+
const shown = report.skippedLines.slice(0, 5).join(', ');
|
|
125
|
+
caveats.push(
|
|
126
|
+
esc(t.profile.skipped(report.skippedLines.length, report.skippedLines.length > 5 ? `${shown}…` : shown)),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (report.span === null) caveats.push(esc(t.html.noClock()));
|
|
130
|
+
if (!report.hasSessions) caveats.push(esc(t.html.noSessions()));
|
|
131
|
+
if (report.total.assumedWriteTtlCalls > 0) {
|
|
132
|
+
caveats.push(
|
|
133
|
+
esc(
|
|
134
|
+
t.profile.cacheTtlUnsettled(
|
|
135
|
+
report.total.assumedWriteTtlCalls,
|
|
136
|
+
formatUsd(-cache.deltaUsd),
|
|
137
|
+
formatUsd(cache.worstCaseDeltaUsd),
|
|
138
|
+
),
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (stalePricing !== undefined) {
|
|
143
|
+
caveats.push(esc(t.profile.pricesStale(stalePricing.date, stalePricing.days)));
|
|
144
|
+
}
|
|
145
|
+
if (caveats.length > 0) {
|
|
146
|
+
parts.push(
|
|
147
|
+
`<div class="caveats"><h2>${esc(t.html.caveatsHeading())}</h2><ul>${caveats
|
|
148
|
+
.map((caveat) => `<li>${caveat}</li>`)
|
|
149
|
+
.join('')}</ul></div>`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
parts.push(`<h2>${esc(t.html.byLabelHeading())}</h2>`);
|
|
154
|
+
parts.push(
|
|
155
|
+
breakdownTable(
|
|
156
|
+
report.byLabel.map((row) => ({ name: showLabel(row.label), breakdown: row.breakdown })),
|
|
157
|
+
report.total.totalUsd,
|
|
158
|
+
t,
|
|
159
|
+
t.html.colLabel(),
|
|
160
|
+
),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
parts.push(`<h2>${esc(t.html.byModelHeading())}</h2>`);
|
|
164
|
+
parts.push(
|
|
165
|
+
breakdownTable(
|
|
166
|
+
report.byModel.map((row) => ({ name: row.model, breakdown: row.breakdown })),
|
|
167
|
+
report.total.totalUsd,
|
|
168
|
+
t,
|
|
169
|
+
t.html.colModel(),
|
|
170
|
+
),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// The findings, as the sentences the terminal already says — the copy is
|
|
174
|
+
// the product's, not this file's, so the two surfaces cannot drift apart.
|
|
175
|
+
const findings: string[] = [];
|
|
176
|
+
for (const lever of levers.slices.slice(0, 5)) {
|
|
177
|
+
findings.push(
|
|
178
|
+
esc(t.profile.leverSlice(showLabel(lever.label), lever.modelName, formatUsd(lever.combinedUsd), pct(lever.shareOfBill))),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (report.total.cacheReadTokens + report.total.cacheWriteTokens > 0) {
|
|
182
|
+
if (cache.deltaUsd > 0) {
|
|
183
|
+
findings.push(
|
|
184
|
+
esc(t.profile.cacheLost(formatUsd(cache.deltaUsd), n(report.total.cacheWriteTokens), n(report.total.cacheReadTokens))),
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
findings.push(esc(t.profile.cachePaidOff(formatUsd(-cache.deltaUsd))));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (findings.length > 0) {
|
|
191
|
+
parts.push(`<h2>${esc(t.html.findingsHeading())}</h2>`);
|
|
192
|
+
parts.push(`<ul class="findings">${findings.map((finding) => `<li>${finding}</li>`).join('')}</ul>`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
parts.push(
|
|
196
|
+
`<p class="muted">${esc(t.html.sharesLine(pct(shares.input), pct(shares.cacheRead), pct(shares.cacheWrite), pct(shares.output)))}</p>`,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
parts.push(`<footer>${esc(t.html.footer())}</footer>`);
|
|
200
|
+
|
|
201
|
+
return page(t.profile.heading(), t.locale, parts);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The shared skeleton: both documents are the same file to a mail client. */
|
|
205
|
+
function page(title: string, locale: string, parts: string[]): string {
|
|
206
|
+
return [
|
|
207
|
+
'<!doctype html>',
|
|
208
|
+
`<html lang="${esc(locale)}">`,
|
|
209
|
+
'<head>',
|
|
210
|
+
'<meta charset="utf-8">',
|
|
211
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
212
|
+
`<title>${esc(title)}</title>`,
|
|
213
|
+
`<style>${STYLE}</style>`,
|
|
214
|
+
'</head>',
|
|
215
|
+
'<body>',
|
|
216
|
+
'<main>',
|
|
217
|
+
...parts,
|
|
218
|
+
'</main>',
|
|
219
|
+
'</body>',
|
|
220
|
+
'</html>',
|
|
221
|
+
'',
|
|
222
|
+
].join('\n');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The roll-up as one self-contained page — the team-facing document, for
|
|
227
|
+
* exactly the person who does not run CLIs.
|
|
228
|
+
*
|
|
229
|
+
* The same discipline as the profile door: the input is the roll-up document
|
|
230
|
+
* itself, the one `--json` prints and `conform` checks, so the page cannot
|
|
231
|
+
* disagree with the data. Two things this page refuses to soften, because
|
|
232
|
+
* they are the roll-up's whole honesty: **each contributor's gaps stay under
|
|
233
|
+
* that contributor** — summing them away is the averaging this command
|
|
234
|
+
* exists to refuse — and **the `cannotSay` caveats render in the caveat
|
|
235
|
+
* block**, overlap-invisible included, so the one thing no merge can measure
|
|
236
|
+
* cannot be cropped out of the forwarded copy.
|
|
237
|
+
*/
|
|
238
|
+
export function renderRollupHtml(document: RollupDocument, t: CliMessages): string {
|
|
239
|
+
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
240
|
+
const parts: string[] = [];
|
|
241
|
+
|
|
242
|
+
parts.push(`<h1>${esc(t.rollup.heading(document.contributors.length, formatUsd(document.total.totalUsd), document.total.calls))}</h1>`);
|
|
243
|
+
parts.push(`<p class="headline">${esc(formatUsd(document.total.totalUsd))}</p>`);
|
|
244
|
+
if (document.span !== null) {
|
|
245
|
+
parts.push(`<p class="muted">${esc(t.rollup.span(dayOf(document.span.fromMs), dayOf(document.span.toMs)))}</p>`);
|
|
246
|
+
} else {
|
|
247
|
+
parts.push(`<p class="muted">${esc(t.rollup.noSpan())}</p>`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// The caveat block, ahead of every table: what the merge cannot say, what
|
|
251
|
+
// was rejected by name, and which contributions arrived twice.
|
|
252
|
+
const caveats: string[] = [];
|
|
253
|
+
for (const code of document.cannotSay) caveats.push(esc(t.rollup.caveat(code)));
|
|
254
|
+
for (const rejection of document.rejected) {
|
|
255
|
+
caveats.push(
|
|
256
|
+
esc(
|
|
257
|
+
rejection.via === null
|
|
258
|
+
? t.rollup.rejected(rejection.name, rejection.because)
|
|
259
|
+
: t.rollup.rejectedVia(rejection.name, rejection.via, rejection.because),
|
|
260
|
+
),
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
if (document.repeatedContributors.length > 0) {
|
|
264
|
+
caveats.push(esc(t.rollup.repeated(document.repeatedContributors.join(', '))));
|
|
265
|
+
}
|
|
266
|
+
for (const group of document.identicalContributions.groups) {
|
|
267
|
+
caveats.push(esc(t.rollup.identical(group.join(', '))));
|
|
268
|
+
}
|
|
269
|
+
if (document.identicalContributions.usd > 0) {
|
|
270
|
+
caveats.push(esc(t.rollup.identicalUsd(formatUsd(document.identicalContributions.usd))));
|
|
271
|
+
}
|
|
272
|
+
if (document.unpricedModels.length > 0) {
|
|
273
|
+
caveats.push(esc(t.profile.unpriced(document.unpricedModels.join(', '), document.unpriced.calls)));
|
|
274
|
+
}
|
|
275
|
+
if (caveats.length > 0) {
|
|
276
|
+
parts.push(
|
|
277
|
+
`<div class="caveats"><h2>${esc(t.rollup.cannotSayHeading())}</h2><ul>${caveats
|
|
278
|
+
.map((caveat) => `<li>${caveat}</li>`)
|
|
279
|
+
.join('')}</ul></div>`,
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// One contributor, one row — and that contributor's own gaps directly
|
|
284
|
+
// beneath its name, never pooled.
|
|
285
|
+
parts.push(`<h2>${esc(t.rollup.contributorsHeading())}</h2>`);
|
|
286
|
+
const contributorRows = document.contributors
|
|
287
|
+
.map((contributor) => {
|
|
288
|
+
const gapItems = contributor.gaps
|
|
289
|
+
.map((gap) => `<li>${esc(gap.detail)}${gap.usd !== null ? ` — ${esc(formatUsd(gap.usd))}` : ''}</li>`)
|
|
290
|
+
.join('');
|
|
291
|
+
const gaps = gapItems === '' ? '' : `<ul class="findings">${gapItems}</ul>`;
|
|
292
|
+
return `<tr><td>${esc(contributor.name)}</td><td class="n">${n(contributor.calls)}</td><td class="n">${esc(formatUsd(contributor.totalUsd))}</td><td class="n">${contributor.spanDays === null ? '—' : n(contributor.spanDays)}</td></tr>${
|
|
293
|
+
gaps === '' ? '' : `<tr><td colspan="4">${gaps}</td></tr>`
|
|
294
|
+
}`;
|
|
295
|
+
})
|
|
296
|
+
.join('\n');
|
|
297
|
+
parts.push(
|
|
298
|
+
`<table><thead><tr><th>${esc(t.html.colContributor())}</th><th class="n">${esc(t.html.colCalls())}</th><th class="n">USD</th><th class="n">${esc(t.html.colSpanDays())}</th></tr></thead><tbody>\n${contributorRows}\n</tbody></table>`,
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
parts.push(`<h2>${esc(t.rollup.byLabelHeading())}</h2>`);
|
|
302
|
+
parts.push(
|
|
303
|
+
breakdownTable(
|
|
304
|
+
document.byLabel.map((row) => ({
|
|
305
|
+
name: row.label === UNLABELLED ? t.profile.unlabelled() : row.label,
|
|
306
|
+
breakdown: row.breakdown,
|
|
307
|
+
})),
|
|
308
|
+
document.total.totalUsd,
|
|
309
|
+
t,
|
|
310
|
+
t.html.colLabel(),
|
|
311
|
+
),
|
|
312
|
+
);
|
|
313
|
+
parts.push(`<h2>${esc(t.html.byModelHeading())}</h2>`);
|
|
314
|
+
parts.push(
|
|
315
|
+
breakdownTable(
|
|
316
|
+
document.byModel.map((row) => ({ name: row.model, breakdown: row.breakdown })),
|
|
317
|
+
document.total.totalUsd,
|
|
318
|
+
t,
|
|
319
|
+
t.html.colModel(),
|
|
320
|
+
),
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
// Findings that did not merge are named with the contributors that have
|
|
324
|
+
// them — reported as prose, exactly as the terminal says it.
|
|
325
|
+
if (document.notMerged.length > 0) {
|
|
326
|
+
parts.push(`<h2>${esc(t.rollup.notMergedHeading())}</h2>`);
|
|
327
|
+
parts.push(
|
|
328
|
+
`<ul class="findings">${document.notMerged
|
|
329
|
+
.map(
|
|
330
|
+
(entry) =>
|
|
331
|
+
`<li>${esc(t.rollup.notMerged(entry.finding, entry.because))} ${esc(t.rollup.presentIn(entry.presentIn.join(', ')))}</li>`,
|
|
332
|
+
)
|
|
333
|
+
.join('')}</ul>`,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
parts.push(`<footer>${esc(t.html.footer())}</footer>`);
|
|
338
|
+
return page(
|
|
339
|
+
t.rollup.heading(document.contributors.length, formatUsd(document.total.totalUsd), document.total.calls),
|
|
340
|
+
t.locale,
|
|
341
|
+
parts,
|
|
342
|
+
);
|
|
343
|
+
}
|
package/src/i18n/en.ts
CHANGED
|
@@ -56,7 +56,7 @@ ${bold('USAGE')}
|
|
|
56
56
|
trazum prune <file> --cases <file> --yes
|
|
57
57
|
trazum where [file]
|
|
58
58
|
trazum conform <file|-> [--contract <name>]
|
|
59
|
-
trazum rollup <document...|dir> [--json]
|
|
59
|
+
trazum rollup <document...|dir> [--json] [--html-out <file>]
|
|
60
60
|
trazum pulse [--max-stale-hours <n>]
|
|
61
61
|
trazum bench [--workload <id>] [--record <file>] [--against <file> --max-ratio <n>] [--json]
|
|
62
62
|
trazum write [--answers <file>] [--json] [-o <file>]
|
|
@@ -104,6 +104,11 @@ ${bold('OPTIONS FOR conform')}
|
|
|
104
104
|
|
|
105
105
|
${bold('OPTIONS FOR rollup')}
|
|
106
106
|
--json The roll-up document as data. See docs/format.md.
|
|
107
|
+
--html-out <file> Also write the roll-up as one self-contained HTML
|
|
108
|
+
file — the team-facing report, for whoever pays
|
|
109
|
+
the bill. Each contributor's gaps stay under that
|
|
110
|
+
contributor, and what no merge can measure is in
|
|
111
|
+
the caveat block, impossible to crop.
|
|
107
112
|
|
|
108
113
|
Several people's bills, one roll-up. Each contributor runs
|
|
109
114
|
\`trazum profile --json\` where their traffic already is; this merges the
|
|
@@ -405,6 +410,10 @@ ${bold('OPTIONS FOR optimize')}
|
|
|
405
410
|
--diff Show the line-by-line diff.
|
|
406
411
|
--json Dump the full report as JSON.
|
|
407
412
|
--locale <${d.locales.join('|')}> Language of the report. Default: the system language.
|
|
413
|
+
--max-input <chars> Raise (or lower) the prompt-input ceiling, per run.
|
|
414
|
+
Above it a prompt door refuses with the size and
|
|
415
|
+
the limit named rather than grinding. Logs and
|
|
416
|
+
documents are never held to it.
|
|
408
417
|
-o, --out <file> Write the optimised prompt to a file.
|
|
409
418
|
-h, --help This help.
|
|
410
419
|
--clear-suggestion-cache Empty the --cache-suggestions cache and say how much
|
|
@@ -512,6 +521,10 @@ ${bold('OPTIONS FOR profile')}
|
|
|
512
521
|
are named as impossible, not priced as cheap.
|
|
513
522
|
--markdown-out <file> Also write the report as Markdown, for a CI job
|
|
514
523
|
summary or a pull request comment.
|
|
524
|
+
--html-out <file> Also write the report as one self-contained HTML
|
|
525
|
+
file — the one to email to whoever pays the bill.
|
|
526
|
+
Same figures as --json, caveats rendered as
|
|
527
|
+
prominently as the totals they qualify.
|
|
515
528
|
--csv-shape <shape> Which table --csv-out writes: slice (default),
|
|
516
529
|
day, hour, or model-day (one row per day and
|
|
517
530
|
model — charts the mix moving). One row shape
|
|
@@ -881,6 +894,9 @@ ${bold('EXAMPLES')}
|
|
|
881
894
|
optionNeedsValue: (name) => `Option --${name} needs a value.`,
|
|
882
895
|
mustBeNonNegative: (name, raw) =>
|
|
883
896
|
`--${name} must be a non-negative number (received: "${raw}").`,
|
|
897
|
+
inputTooLarge: (source, size, limit) =>
|
|
898
|
+
`${source} is ${count(size)} characters, past the ${count(limit)}-character ceiling for a prompt. Raise it deliberately with --max-input <chars> if this input really is one.`,
|
|
899
|
+
badMaxInput: (raw) => `--max-input must be a positive number of characters (received: "${raw}").`,
|
|
884
900
|
fractionFlag: (name, raw) =>
|
|
885
901
|
`--${name} is a fraction between 0 and 1 (received: ${raw}). The config refuses the same value the same way.`,
|
|
886
902
|
badLevel: (received) => `--level must be "safe" or "aggressive" (received: "${received}").`,
|
|
@@ -1569,6 +1585,29 @@ ${bold('EXAMPLES')}
|
|
|
1569
1585
|
'This command runs nothing and hosts nothing. Something has to notice, and the something is your CI: a step that runs this on the schedule you already have turns a dead cron into a red build, without Trazum holding anybody\'s metrics. How far the measurements reach is reported and never judged — that is a provider reporting on its own schedule, not a job that failed.',
|
|
1570
1586
|
},
|
|
1571
1587
|
|
|
1588
|
+
html: {
|
|
1589
|
+
caveatsHeading: () => 'What this report cannot say',
|
|
1590
|
+
noClock: () => 'No record carried a timestamp, so days, rates and drift are not in this report — a total is still a total.',
|
|
1591
|
+
noSessions: () => 'No record carried a session, so conversation growth and per-conversation costs are not in this report.',
|
|
1592
|
+
byLabelHeading: () => 'By workload',
|
|
1593
|
+
byModelHeading: () => 'By model',
|
|
1594
|
+
findingsHeading: () => 'What would move this bill',
|
|
1595
|
+
colLabel: () => 'workload',
|
|
1596
|
+
colModel: () => 'model',
|
|
1597
|
+
colContributor: () => 'contributor',
|
|
1598
|
+
colSpanDays: () => 'days',
|
|
1599
|
+
colCalls: () => 'calls',
|
|
1600
|
+
colInput: () => 'input',
|
|
1601
|
+
colCacheRead: () => 'cache reads',
|
|
1602
|
+
colCacheWrite: () => 'cache writes',
|
|
1603
|
+
colOutput: () => 'output',
|
|
1604
|
+
sharesLine: (input, cacheRead, cacheWrite, output) =>
|
|
1605
|
+
`Where the money goes: ${input} plain input, ${cacheRead} cache reads, ${cacheWrite} cache writes, ${output} output.`,
|
|
1606
|
+
footer: () =>
|
|
1607
|
+
'Generated by trazum from a usage log, offline. Every figure derives from that log and the pricing table the run named; nothing here was sent anywhere to be computed.',
|
|
1608
|
+
written: (path) => `HTML report written to ${path}.`,
|
|
1609
|
+
},
|
|
1610
|
+
|
|
1572
1611
|
bench: {
|
|
1573
1612
|
heading: () => 'This machine, measured',
|
|
1574
1613
|
machine: (node, platform, cpuCount, cpuModel) =>
|
package/src/i18n/es.ts
CHANGED
|
@@ -43,7 +43,7 @@ ${bold('USO')}
|
|
|
43
43
|
trazum prune <fichero> --cases <fichero> --yes
|
|
44
44
|
trazum where [fichero]
|
|
45
45
|
trazum conform <fichero|-> [--contract <nombre>]
|
|
46
|
-
trazum rollup <documento...|dir> [--json]
|
|
46
|
+
trazum rollup <documento...|dir> [--json] [--html-out <fichero>]
|
|
47
47
|
trazum pulse [--max-stale-hours <n>]
|
|
48
48
|
trazum bench [--workload <id>] [--record <fichero>] [--against <fichero> --max-ratio <n>] [--json]
|
|
49
49
|
trazum write [--answers <fichero>] [--json] [-o <fichero>]
|
|
@@ -92,6 +92,12 @@ ${bold('OPCIONES DE conform')}
|
|
|
92
92
|
${bold('OPCIONES DE rollup')}
|
|
93
93
|
--json El documento de agregación como datos. Ver
|
|
94
94
|
docs/format.md.
|
|
95
|
+
--html-out <fichero> Escribe además el roll-up como un único HTML
|
|
96
|
+
autocontenido — el informe de equipo, para quien
|
|
97
|
+
paga la factura. Los huecos de cada contribuyente
|
|
98
|
+
se quedan bajo ese contribuyente, y lo que ninguna
|
|
99
|
+
fusión puede medir va en la caja de salvedades,
|
|
100
|
+
imposible de recortar.
|
|
95
101
|
|
|
96
102
|
Las facturas de varias personas, una sola agregación. Cada contribuyente
|
|
97
103
|
ejecuta \`trazum profile --json\` donde ya está su tráfico; esto fusiona los
|
|
@@ -404,6 +410,10 @@ ${bold('OPCIONES DE optimize')}
|
|
|
404
410
|
--diff Muestra el diff línea a línea.
|
|
405
411
|
--json Vuelca el informe completo en JSON.
|
|
406
412
|
--locale <${d.locales.join('|')}> Idioma del informe. Por defecto: el del sistema.
|
|
413
|
+
--max-input <caracteres> Sube (o baja) el techo de entrada de prompts, por
|
|
414
|
+
ejecución. Por encima, una puerta de prompt rechaza
|
|
415
|
+
nombrando el tamaño y el límite en vez de arrastrarse.
|
|
416
|
+
Los logs y documentos nunca se sujetan a él.
|
|
407
417
|
-o, --out <fichero> Escribe el prompt optimizado a un fichero.
|
|
408
418
|
-h, --help Esta ayuda.
|
|
409
419
|
--clear-suggestion-cache Vacía la caché de --cache-suggestions y dice cuánto
|
|
@@ -519,6 +529,11 @@ ${bold('OPCIONES DE profile')}
|
|
|
519
529
|
imposibles, no se cobran como baratas.
|
|
520
530
|
--markdown-out <fichero> Escribe además el informe en Markdown, para el
|
|
521
531
|
resumen de un job de CI o un comentario de PR.
|
|
532
|
+
--html-out <fichero> Escribe además el informe como un único HTML
|
|
533
|
+
autocontenido — el que se envía por correo a
|
|
534
|
+
quien paga la factura. Las mismas cifras que
|
|
535
|
+
--json, con las salvedades tan visibles como
|
|
536
|
+
los totales a los que acompañan.
|
|
522
537
|
--csv-shape <forma> Qué tabla escribe --csv-out: slice (por defecto),
|
|
523
538
|
day, hour o model-day (una fila por día y
|
|
524
539
|
modelo — dibuja la mezcla moviéndose). Una sola
|
|
@@ -907,6 +922,9 @@ ${bold('EJEMPLOS')}
|
|
|
907
922
|
optionNeedsValue: (name) => `La opción --${name} necesita un valor.`,
|
|
908
923
|
mustBeNonNegative: (name, raw) =>
|
|
909
924
|
`--${name} debe ser un número no negativo (recibido: "${raw}").`,
|
|
925
|
+
inputTooLarge: (source, size, limit) =>
|
|
926
|
+
`${source} tiene ${count(size)} caracteres, por encima del techo de ${count(limit)} para un prompt. Súbelo deliberadamente con --max-input <caracteres> si esta entrada de verdad lo es.`,
|
|
927
|
+
badMaxInput: (raw) => `--max-input debe ser un número positivo de caracteres (recibido: "${raw}").`,
|
|
910
928
|
fractionFlag: (name, raw) =>
|
|
911
929
|
`--${name} es una fracción entre 0 y 1 (recibido: ${raw}). La configuración rechaza el mismo valor de la misma forma.`,
|
|
912
930
|
badLevel: (received) => `--level debe ser "safe" o "aggressive" (recibido: "${received}").`,
|
|
@@ -1579,6 +1597,29 @@ ${bold('EJEMPLOS')}
|
|
|
1579
1597
|
'Este comando no ejecuta nada y no aloja nada. Algo tiene que darse cuenta, y ese algo es tu CI: un paso que ejecute esto con el horario que ya tienes convierte un cron muerto en una build roja, sin que Trazum guarde las métricas de nadie. Hasta dónde llegan las mediciones se informa y nunca se juzga — eso es un proveedor informando a su ritmo, no un trabajo que falló.',
|
|
1580
1598
|
},
|
|
1581
1599
|
|
|
1600
|
+
html: {
|
|
1601
|
+
caveatsHeading: () => 'Lo que este informe no puede decir',
|
|
1602
|
+
noClock: () => 'Ningún registro traía marca de tiempo, así que días, ritmos y deriva no están en este informe — un total sigue siendo un total.',
|
|
1603
|
+
noSessions: () => 'Ningún registro traía sesión, así que el crecimiento de conversación y los costes por conversación no están en este informe.',
|
|
1604
|
+
byLabelHeading: () => 'Por carga de trabajo',
|
|
1605
|
+
byModelHeading: () => 'Por modelo',
|
|
1606
|
+
findingsHeading: () => 'Qué movería esta factura',
|
|
1607
|
+
colLabel: () => 'carga',
|
|
1608
|
+
colModel: () => 'modelo',
|
|
1609
|
+
colContributor: () => 'contribuyente',
|
|
1610
|
+
colSpanDays: () => 'días',
|
|
1611
|
+
colCalls: () => 'llamadas',
|
|
1612
|
+
colInput: () => 'entrada',
|
|
1613
|
+
colCacheRead: () => 'lecturas de caché',
|
|
1614
|
+
colCacheWrite: () => 'escrituras de caché',
|
|
1615
|
+
colOutput: () => 'salida',
|
|
1616
|
+
sharesLine: (input, cacheRead, cacheWrite, output) =>
|
|
1617
|
+
`A dónde va el dinero: ${input} entrada normal, ${cacheRead} lecturas de caché, ${cacheWrite} escrituras de caché, ${output} salida.`,
|
|
1618
|
+
footer: () =>
|
|
1619
|
+
'Generado por trazum a partir de un log de uso, sin conexión. Cada cifra deriva de ese log y de la tabla de precios que la ejecución nombró; nada de esto se envió a ninguna parte para calcularse.',
|
|
1620
|
+
written: (path) => `Informe HTML escrito en ${path}.`,
|
|
1621
|
+
},
|
|
1622
|
+
|
|
1582
1623
|
bench: {
|
|
1583
1624
|
heading: () => 'Esta máquina, medida',
|
|
1584
1625
|
machine: (node, platform, cpuCount, cpuModel) =>
|
package/src/i18n/types.ts
CHANGED
|
@@ -84,6 +84,9 @@ export interface CliMessages {
|
|
|
84
84
|
livePricingFailed: (url: string, detail: string) => string;
|
|
85
85
|
optionNeedsValue(name: string): string;
|
|
86
86
|
mustBeNonNegative(name: string, raw: string): string;
|
|
87
|
+
/** The refusal ceiling: an input past the limit is named, never ground through. */
|
|
88
|
+
inputTooLarge(source: string, size: number, limit: number): string;
|
|
89
|
+
badMaxInput(raw: string): string;
|
|
87
90
|
/** A flag that is a fraction of a whole: over 1 is refused, like the config. */
|
|
88
91
|
fractionFlag(name: string, raw: string): string;
|
|
89
92
|
badLevel(received: string): string;
|
|
@@ -526,6 +529,28 @@ export interface CliMessages {
|
|
|
526
529
|
notAService(): string;
|
|
527
530
|
};
|
|
528
531
|
|
|
532
|
+
/** The HTML report: the one surface for a reader with an inbox, not a terminal. */
|
|
533
|
+
html: {
|
|
534
|
+
caveatsHeading(): string;
|
|
535
|
+
noClock(): string;
|
|
536
|
+
noSessions(): string;
|
|
537
|
+
byLabelHeading(): string;
|
|
538
|
+
byModelHeading(): string;
|
|
539
|
+
findingsHeading(): string;
|
|
540
|
+
colLabel(): string;
|
|
541
|
+
colModel(): string;
|
|
542
|
+
colContributor(): string;
|
|
543
|
+
colSpanDays(): string;
|
|
544
|
+
colCalls(): string;
|
|
545
|
+
colInput(): string;
|
|
546
|
+
colCacheRead(): string;
|
|
547
|
+
colCacheWrite(): string;
|
|
548
|
+
colOutput(): string;
|
|
549
|
+
sharesLine(input: string, cacheRead: string, cacheWrite: string, output: string): string;
|
|
550
|
+
footer(): string;
|
|
551
|
+
written(path: string): string;
|
|
552
|
+
};
|
|
553
|
+
|
|
529
554
|
bench: {
|
|
530
555
|
heading(): string;
|
|
531
556
|
machine(node: string, platform: string, cpuCount: number, cpuModel: string | null): string;
|