@trazum/cli 1.74.0 → 1.76.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/README.md +4 -0
- package/dist/index.js +69 -79
- package/dist/index.js.map +1 -1
- package/dist/style.d.ts +68 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +88 -0
- package/dist/style.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +72 -86
- package/src/style.ts +108 -0
package/src/index.ts
CHANGED
|
@@ -255,15 +255,11 @@ import type { CliMessages } from './i18n/index.js';
|
|
|
255
255
|
// Presentation
|
|
256
256
|
// --------------------------------------------------------------------------
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
red: (s: string) => (useColor ? `\u001b[31m${s}\u001b[39m` : s),
|
|
264
|
-
yellow: (s: string) => (useColor ? `\u001b[33m${s}\u001b[39m` : s),
|
|
265
|
-
cyan: (s: string) => (useColor ? `\u001b[36m${s}\u001b[39m` : s),
|
|
266
|
-
};
|
|
258
|
+
// The painters, the ANSI-aware measurer, the one table renderer, the
|
|
259
|
+
// proportion bar and the heading rule — the 1.75 style module. The guard in
|
|
260
|
+
// style.test.js holds the contract: stripped colour output is byte-identical
|
|
261
|
+
// to plain output, and a pipe stays plain.
|
|
262
|
+
import { bar, c, sectionHeading, table } from './style.js';
|
|
267
263
|
|
|
268
264
|
// --------------------------------------------------------------------------
|
|
269
265
|
// Argument parsing
|
|
@@ -928,7 +924,7 @@ function printReport(
|
|
|
928
924
|
// above already told them nothing changed.
|
|
929
925
|
if (reorder !== null && (reorder.moved.length > 0 || reorder.declined.length > 0)) {
|
|
930
926
|
console.log();
|
|
931
|
-
console.log(
|
|
927
|
+
console.log(sectionHeading(t.report.reorderHeading()));
|
|
932
928
|
if (reorder.moved.length === 0) {
|
|
933
929
|
console.log(` ${c.dim(t.report.reorderNothing())}`);
|
|
934
930
|
} else {
|
|
@@ -1240,7 +1236,7 @@ function printTokensOnly(
|
|
|
1240
1236
|
const saved = result.tokensBefore - result.tokensAfter;
|
|
1241
1237
|
|
|
1242
1238
|
console.log();
|
|
1243
|
-
console.log(
|
|
1239
|
+
console.log(sectionHeading(t.report.tokensOnlyHeading(host.displayName)));
|
|
1244
1240
|
// Only claim the host bills by subscription when it does. Forced with the
|
|
1245
1241
|
// flag on GitHub Actions, the first version said "GitHub Actions bills by
|
|
1246
1242
|
// subscription", which is simply false.
|
|
@@ -1724,7 +1720,7 @@ function renderInit(proposal: InitProposal, ctx: InitRenderContext): void {
|
|
|
1724
1720
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
1725
1721
|
|
|
1726
1722
|
console.log();
|
|
1727
|
-
console.log(
|
|
1723
|
+
console.log(sectionHeading(t.init.heading()));
|
|
1728
1724
|
console.log();
|
|
1729
1725
|
|
|
1730
1726
|
// 1. Where this is running.
|
|
@@ -1752,7 +1748,7 @@ function renderInit(proposal: InitProposal, ctx: InitRenderContext): void {
|
|
|
1752
1748
|
console.log();
|
|
1753
1749
|
|
|
1754
1750
|
// 4. What the config would say, and what it will not.
|
|
1755
|
-
console.log(
|
|
1751
|
+
console.log(sectionHeading(t.init.configHeading()));
|
|
1756
1752
|
if (proposal.justified.length === 0) {
|
|
1757
1753
|
console.log(` ${c.dim(t.init.nothingJustified())}`);
|
|
1758
1754
|
}
|
|
@@ -1769,7 +1765,7 @@ function renderInit(proposal: InitProposal, ctx: InitRenderContext): void {
|
|
|
1769
1765
|
console.log();
|
|
1770
1766
|
|
|
1771
1767
|
// 5. The single most valuable thing found — arithmetic first.
|
|
1772
|
-
console.log(
|
|
1768
|
+
console.log(sectionHeading(t.init.findingHeading()));
|
|
1773
1769
|
if (proposal.headline === null) {
|
|
1774
1770
|
console.log(` ${c.dim(t.init.noFinding(proposal.noHeadline ?? 'nothing-measured'))}`);
|
|
1775
1771
|
console.log();
|
|
@@ -2151,7 +2147,7 @@ async function commandConform(args: Args, t: CliMessages): Promise<void> {
|
|
|
2151
2147
|
|
|
2152
2148
|
if (report.unavailable.length > 0) {
|
|
2153
2149
|
console.log();
|
|
2154
|
-
console.log(
|
|
2150
|
+
console.log(sectionHeading(t.conform.unavailableHeading()));
|
|
2155
2151
|
for (const gap of report.unavailable) {
|
|
2156
2152
|
console.log(` ${c.dim(wrap(t.conform.unavailable(gap.finding, gap.because, gap.unlockedBy), 74, ' '))}`);
|
|
2157
2153
|
}
|
|
@@ -2290,7 +2286,7 @@ async function commandRollup(args: Args, t: CliMessages): Promise<void> {
|
|
|
2290
2286
|
}
|
|
2291
2287
|
|
|
2292
2288
|
console.log();
|
|
2293
|
-
console.log(
|
|
2289
|
+
console.log(sectionHeading(t.rollup.contributorsHeading()));
|
|
2294
2290
|
for (const contributor of document.contributors) {
|
|
2295
2291
|
console.log(
|
|
2296
2292
|
` ${t.rollup.contributor(
|
|
@@ -2338,7 +2334,7 @@ async function commandRollup(args: Args, t: CliMessages): Promise<void> {
|
|
|
2338
2334
|
|
|
2339
2335
|
if (document.rejected.length > 0) {
|
|
2340
2336
|
console.log();
|
|
2341
|
-
console.log(
|
|
2337
|
+
console.log(sectionHeading(t.rollup.rejectedHeading()));
|
|
2342
2338
|
for (const rejection of document.rejected) {
|
|
2343
2339
|
// The roll-up it arrived through, when it came through one: a rejection
|
|
2344
2340
|
// whose origin got lost is a machine nobody knows to go and fix.
|
|
@@ -2366,7 +2362,7 @@ async function commandRollup(args: Args, t: CliMessages): Promise<void> {
|
|
|
2366
2362
|
|
|
2367
2363
|
if (document.byLabel.length > 0) {
|
|
2368
2364
|
console.log();
|
|
2369
|
-
console.log(
|
|
2365
|
+
console.log(sectionHeading(t.rollup.byLabelHeading()));
|
|
2370
2366
|
for (const row of document.byLabel.slice(0, 8)) {
|
|
2371
2367
|
console.log(` ${t.rollup.labelRow(row.label, formatUsd(row.breakdown.totalUsd), row.breakdown.calls)}`);
|
|
2372
2368
|
}
|
|
@@ -2374,7 +2370,7 @@ async function commandRollup(args: Args, t: CliMessages): Promise<void> {
|
|
|
2374
2370
|
|
|
2375
2371
|
if (document.notMerged.length > 0) {
|
|
2376
2372
|
console.log();
|
|
2377
|
-
console.log(
|
|
2373
|
+
console.log(sectionHeading(t.rollup.notMergedHeading()));
|
|
2378
2374
|
for (const finding of document.notMerged) {
|
|
2379
2375
|
console.log(` ${wrap(t.rollup.notMerged(finding.finding, finding.because), 72, ' ')}`);
|
|
2380
2376
|
if (finding.presentIn.length > 0) {
|
|
@@ -2385,7 +2381,7 @@ async function commandRollup(args: Args, t: CliMessages): Promise<void> {
|
|
|
2385
2381
|
|
|
2386
2382
|
if (document.cannotSay.length > 0) {
|
|
2387
2383
|
console.log();
|
|
2388
|
-
console.log(
|
|
2384
|
+
console.log(sectionHeading(t.rollup.cannotSayHeading()));
|
|
2389
2385
|
for (const caveat of document.cannotSay) {
|
|
2390
2386
|
console.log(` ${c.dim(wrap(t.rollup.caveat(caveat), 72, ' '))}`);
|
|
2391
2387
|
}
|
|
@@ -2692,7 +2688,7 @@ async function commandSwitch(args: Args, pricing: PricingCatalogue, t: CliMessag
|
|
|
2692
2688
|
|
|
2693
2689
|
const { reprice, savingUsd, measuredDays, breakEven, evalCost } = analysis;
|
|
2694
2690
|
console.log();
|
|
2695
|
-
console.log(
|
|
2691
|
+
console.log(sectionHeading(t.switchCmd.heading(reprice.target.displayName)));
|
|
2696
2692
|
if (reprice.slices.length === 0) {
|
|
2697
2693
|
console.log(` ${wrap(t.switchCmd.nothingMovable(), 74, ' ')}`);
|
|
2698
2694
|
} else {
|
|
@@ -2899,7 +2895,7 @@ async function commandPosition(
|
|
|
2899
2895
|
: t.position.scopeLabel(position.label ?? '');
|
|
2900
2896
|
|
|
2901
2897
|
console.log();
|
|
2902
|
-
console.log(
|
|
2898
|
+
console.log(sectionHeading(t.position.heading(document.month.id)));
|
|
2903
2899
|
for (const position of document.positions) {
|
|
2904
2900
|
const name = scopeName(position);
|
|
2905
2901
|
if (position.verdict === 'cannot-tell') {
|
|
@@ -3004,7 +3000,7 @@ async function commandPulse(args: Args, t: CliMessages): Promise<void> {
|
|
|
3004
3000
|
const when = (ms: number): string => new Date(ms).toISOString().replace('T', ' ').slice(0, 16);
|
|
3005
3001
|
|
|
3006
3002
|
console.log();
|
|
3007
|
-
console.log(
|
|
3003
|
+
console.log(sectionHeading(t.pulse.heading()));
|
|
3008
3004
|
for (const heartbeat of report.beats) {
|
|
3009
3005
|
const name = t.pulse.kind(heartbeat.kind);
|
|
3010
3006
|
if (heartbeat.lastMs === null) {
|
|
@@ -3297,7 +3293,7 @@ function printBenchTable(measurements: BenchMeasurement[], t: CliMessages, machi
|
|
|
3297
3293
|
const idWidth = Math.max(...measurements.map((m) => m.id.length), t.bench.colWorkload().length);
|
|
3298
3294
|
|
|
3299
3295
|
console.log();
|
|
3300
|
-
console.log(
|
|
3296
|
+
console.log(sectionHeading(t.bench.heading()));
|
|
3301
3297
|
if (machine !== undefined) {
|
|
3302
3298
|
console.log(` ${c.dim(t.bench.machine(machine.node, machine.platform, machine.cpus, machine.cpuModel))}`);
|
|
3303
3299
|
}
|
|
@@ -3500,11 +3496,11 @@ function commandFeedback(t: CliMessages): void {
|
|
|
3500
3496
|
`${FEEDBACK_REPO}/issues/new?body=${encodeURIComponent(body)}`;
|
|
3501
3497
|
|
|
3502
3498
|
console.log();
|
|
3503
|
-
console.log(
|
|
3499
|
+
console.log(sectionHeading(t.feedback.heading()));
|
|
3504
3500
|
console.log(` ${c.dim(wrap(t.feedback.sendsNothing(), 74, ' '))}`);
|
|
3505
3501
|
console.log();
|
|
3506
3502
|
|
|
3507
|
-
console.log(
|
|
3503
|
+
console.log(sectionHeading(t.feedback.whereHeading()));
|
|
3508
3504
|
console.log(` ${t.feedback.wrongOptimisation()}`);
|
|
3509
3505
|
console.log(` ${c.dim(`${FEEDBACK_REPO}/issues/new?template=wrong_optimisation.yml`)}`);
|
|
3510
3506
|
console.log(` ${t.feedback.bug()}`);
|
|
@@ -3515,12 +3511,12 @@ function commandFeedback(t: CliMessages): void {
|
|
|
3515
3511
|
console.log(` ${c.dim(`${FEEDBACK_REPO}/security/advisories/new`)}`);
|
|
3516
3512
|
console.log();
|
|
3517
3513
|
|
|
3518
|
-
console.log(
|
|
3514
|
+
console.log(sectionHeading(t.feedback.environmentHeading()));
|
|
3519
3515
|
for (const line of environment) console.log(` ${line}`);
|
|
3520
3516
|
console.log(` ${c.dim(wrap(t.feedback.environmentOnly(), 74, ' '))}`);
|
|
3521
3517
|
console.log();
|
|
3522
3518
|
|
|
3523
|
-
console.log(
|
|
3519
|
+
console.log(sectionHeading(t.feedback.linkHeading()));
|
|
3524
3520
|
console.log(` ${url}`);
|
|
3525
3521
|
console.log();
|
|
3526
3522
|
}
|
|
@@ -3716,7 +3712,7 @@ async function commandLadder(
|
|
|
3716
3712
|
const pct = (value: number): string => `${(value * 100).toFixed(1)}%`;
|
|
3717
3713
|
|
|
3718
3714
|
console.log();
|
|
3719
|
-
console.log(
|
|
3715
|
+
console.log(sectionHeading(t.ladder.heading()));
|
|
3720
3716
|
if (Object.keys(ladders).length === 0) {
|
|
3721
3717
|
console.log(` ${c.dim(wrap(t.ladder.noLadders(), 74, ' '))}`);
|
|
3722
3718
|
console.log();
|
|
@@ -3870,7 +3866,7 @@ async function commandExperiment(
|
|
|
3870
3866
|
);
|
|
3871
3867
|
|
|
3872
3868
|
console.log();
|
|
3873
|
-
console.log(
|
|
3869
|
+
console.log(sectionHeading(t.experiment.heading(aName, bName)));
|
|
3874
3870
|
console.log();
|
|
3875
3871
|
for (const side of [result.a, result.b]) {
|
|
3876
3872
|
console.log(
|
|
@@ -4009,7 +4005,7 @@ async function commandQuality(
|
|
|
4009
4005
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
4010
4006
|
|
|
4011
4007
|
console.log();
|
|
4012
|
-
console.log(
|
|
4008
|
+
console.log(sectionHeading(t.quality.heading(label)));
|
|
4013
4009
|
console.log(` ${c.dim(wrap(t.quality.notRandomised(), 74, ' '))}`);
|
|
4014
4010
|
console.log();
|
|
4015
4011
|
console.log(
|
|
@@ -4120,7 +4116,7 @@ async function commandSemantic(
|
|
|
4120
4116
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
4121
4117
|
|
|
4122
4118
|
console.log();
|
|
4123
|
-
console.log(
|
|
4119
|
+
console.log(sectionHeading(t.semantic.heading(args.positional[0] ?? '-')));
|
|
4124
4120
|
console.log();
|
|
4125
4121
|
console.log(
|
|
4126
4122
|
` ${wrap(
|
|
@@ -4236,7 +4232,7 @@ async function commandOwners(
|
|
|
4236
4232
|
if (path === undefined) throw new Error(t.errors.missingInputFile());
|
|
4237
4233
|
|
|
4238
4234
|
console.log();
|
|
4239
|
-
console.log(
|
|
4235
|
+
console.log(sectionHeading(t.owners.heading()));
|
|
4240
4236
|
if (config.owners === undefined) {
|
|
4241
4237
|
console.log(` ${c.dim(wrap(t.owners.noOwners(), 74, ' '))}`);
|
|
4242
4238
|
console.log();
|
|
@@ -4426,7 +4422,7 @@ async function commandCommitment(
|
|
|
4426
4422
|
const pct = (value: number): string => `${(value * 100).toFixed(0)}%`;
|
|
4427
4423
|
|
|
4428
4424
|
console.log();
|
|
4429
|
-
console.log(
|
|
4425
|
+
console.log(sectionHeading(t.commitment.heading(formatUsd(floor), pct(discount), n(months))));
|
|
4430
4426
|
console.log(` ${c.dim(wrap(t.commitment.asIf(), 74, ' '))}`);
|
|
4431
4427
|
console.log();
|
|
4432
4428
|
|
|
@@ -4601,7 +4597,7 @@ async function commandReport(
|
|
|
4601
4597
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
4602
4598
|
|
|
4603
4599
|
console.log();
|
|
4604
|
-
console.log(
|
|
4600
|
+
console.log(sectionHeading(t.annual.heading(year)));
|
|
4605
4601
|
console.log();
|
|
4606
4602
|
console.log(
|
|
4607
4603
|
` ${t.annual.spent(formatUsd(record.totalUsd), n(record.totalCalls), n(record.months.length))}`,
|
|
@@ -4662,7 +4658,7 @@ function commandModels(t: CliMessages, pricing: PricingCatalogue): void {
|
|
|
4662
4658
|
const col = t.models.columns;
|
|
4663
4659
|
|
|
4664
4660
|
console.log();
|
|
4665
|
-
console.log(
|
|
4661
|
+
console.log(sectionHeading(`${t.models.title()}${t.models.unit()}`));
|
|
4666
4662
|
console.log(
|
|
4667
4663
|
c.dim(t.models.reviewedOn(pricing.lastReviewed, reviewAgeDays(pricing.lastReviewed, new Date()))),
|
|
4668
4664
|
);
|
|
@@ -4677,27 +4673,17 @@ function commandModels(t: CliMessages, pricing: PricingCatalogue): void {
|
|
|
4677
4673
|
// "caches from the first token" — and it is the wrong one.
|
|
4678
4674
|
cache: m.cacheMinTokens === null ? '—' : n(m.cacheMinTokens),
|
|
4679
4675
|
}));
|
|
4680
|
-
const
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
`${col.output.padStart(widths.output)} ${col.context.padStart(widths.context)} ` +
|
|
4692
|
-
`${col.cacheMin.padStart(widths.cache)}`,
|
|
4693
|
-
),
|
|
4694
|
-
);
|
|
4695
|
-
for (const row of rows) {
|
|
4696
|
-
console.log(
|
|
4697
|
-
` ${row.id.padEnd(widths.id)} ${row.input.padStart(widths.input)} ` +
|
|
4698
|
-
`${row.output.padStart(widths.output)} ${row.context.padStart(widths.context)} ` +
|
|
4699
|
-
`${row.cache.padStart(widths.cache)}`,
|
|
4700
|
-
);
|
|
4676
|
+
for (const line of table(
|
|
4677
|
+
[
|
|
4678
|
+
{ header: col.model, align: 'left' },
|
|
4679
|
+
{ header: col.input, align: 'right' },
|
|
4680
|
+
{ header: col.output, align: 'right' },
|
|
4681
|
+
{ header: col.context, align: 'right' },
|
|
4682
|
+
{ header: col.cacheMin, align: 'right' },
|
|
4683
|
+
],
|
|
4684
|
+
rows.map((row) => [row.id, row.input, row.output, row.context, row.cache]),
|
|
4685
|
+
)) {
|
|
4686
|
+
console.log(line);
|
|
4701
4687
|
}
|
|
4702
4688
|
|
|
4703
4689
|
console.log();
|
|
@@ -4713,7 +4699,7 @@ function commandRules(t: CliMessages, locale: Locale): void {
|
|
|
4713
4699
|
const copy = getMessages(locale).rules;
|
|
4714
4700
|
|
|
4715
4701
|
console.log();
|
|
4716
|
-
console.log(
|
|
4702
|
+
console.log(sectionHeading(t.rules.title()));
|
|
4717
4703
|
console.log(c.dim(t.rules.disableHint()));
|
|
4718
4704
|
console.log();
|
|
4719
4705
|
for (const rule of RULES) {
|
|
@@ -4791,7 +4777,7 @@ async function commandRulesMeasure(
|
|
|
4791
4777
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
4792
4778
|
|
|
4793
4779
|
console.log();
|
|
4794
|
-
console.log(
|
|
4780
|
+
console.log(sectionHeading(t.rules.measureHeading(root, report.prompts, level)));
|
|
4795
4781
|
console.log(` ${c.dim(t.rules.measureTotals(n(report.tokensBefore), n(report.tokensSaved), n(report.floor)))}`);
|
|
4796
4782
|
console.log();
|
|
4797
4783
|
|
|
@@ -4942,7 +4928,7 @@ async function commandOptimize(
|
|
|
4942
4928
|
rows.sort((a, b) => b.savingUsd - a.savingUsd);
|
|
4943
4929
|
|
|
4944
4930
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
4945
|
-
console.log(
|
|
4931
|
+
console.log(sectionHeading(t.report.allLabelsHeading(n(rows.length))));
|
|
4946
4932
|
for (const row of rows) {
|
|
4947
4933
|
const saving = row.periodOnly
|
|
4948
4934
|
? t.report.allLabelsRowPeriod(formatUsd(row.savingUsd))
|
|
@@ -5622,7 +5608,7 @@ async function checkEmbedded(
|
|
|
5622
5608
|
}
|
|
5623
5609
|
|
|
5624
5610
|
console.log();
|
|
5625
|
-
console.log(
|
|
5611
|
+
console.log(sectionHeading(t.check.embeddedHeading(path, extraction.prompts.length)));
|
|
5626
5612
|
|
|
5627
5613
|
for (const verdict of verdicts) {
|
|
5628
5614
|
const over = isOverBudget(verdict);
|
|
@@ -6205,7 +6191,7 @@ function renderBudget(report: BudgetReport, t: CliMessages, n: (value: number) =
|
|
|
6205
6191
|
}
|
|
6206
6192
|
|
|
6207
6193
|
console.log();
|
|
6208
|
-
console.log(
|
|
6194
|
+
console.log(sectionHeading(t.store.budgetHeading(standing.period.id)));
|
|
6209
6195
|
|
|
6210
6196
|
if (standing.coverage === 'none') {
|
|
6211
6197
|
// Nothing measured is never rendered as nothing spent. A dead store and a
|
|
@@ -6963,7 +6949,7 @@ async function commandPlan(
|
|
|
6963
6949
|
return;
|
|
6964
6950
|
}
|
|
6965
6951
|
|
|
6966
|
-
console.log(
|
|
6952
|
+
console.log(sectionHeading(t.plan.heading(n(actions.length), formatUsd(plan.totalUsd))));
|
|
6967
6953
|
console.log(
|
|
6968
6954
|
` ${wrap(t.plan.totals(formatUsd(stamped.projectedSavingUsd), formatUsd(stamped.measuredStakeUsd)), 74, ' ')}`,
|
|
6969
6955
|
);
|
|
@@ -7208,7 +7194,7 @@ async function commandProfile(
|
|
|
7208
7194
|
),
|
|
7209
7195
|
);
|
|
7210
7196
|
} else {
|
|
7211
|
-
console.log(
|
|
7197
|
+
console.log(sectionHeading(t.profile.fleetHeading(n(rollup.sources.length), formatUsd(rollup.totalUsd), t.profile.calls(rollup.calls))));
|
|
7212
7198
|
for (const row of rollup.sources) {
|
|
7213
7199
|
const span = row.spanDays === null ? t.profile.fleetNoClock() : t.profile.fleetSpan(row.spanDays.toFixed(1));
|
|
7214
7200
|
console.log(
|
|
@@ -7282,7 +7268,7 @@ async function commandProfile(
|
|
|
7282
7268
|
}
|
|
7283
7269
|
const cov = report.fieldCoverage;
|
|
7284
7270
|
const parsed = cov.parsed;
|
|
7285
|
-
console.log(
|
|
7271
|
+
console.log(sectionHeading(t.profile.dryRunHeading()));
|
|
7286
7272
|
console.log(` ${wrap(t.profile.dryRunParsed(n(parsed), n(report.skippedLines.length)), 74, ' ')}`);
|
|
7287
7273
|
if (report.unpricedModels.length > 0) {
|
|
7288
7274
|
console.log(` ${c.yellow('!')} ${wrap(t.profile.dryRunUnpriced(report.unpricedModels.join(', ')), 74, ' ')}`);
|
|
@@ -8060,7 +8046,7 @@ async function commandProfile(
|
|
|
8060
8046
|
];
|
|
8061
8047
|
|
|
8062
8048
|
console.log();
|
|
8063
|
-
console.log(
|
|
8049
|
+
console.log(sectionHeading(t.profile.heading()));
|
|
8064
8050
|
console.log(` ${t.profile.spent(t.profile.calls(report.total.calls), formatUsd(report.total.totalUsd))}`);
|
|
8065
8051
|
/**
|
|
8066
8052
|
* The period, when the log carries a clock — stated, never extrapolated. A
|
|
@@ -8126,7 +8112,7 @@ async function commandProfile(
|
|
|
8126
8112
|
// Every part, including the zero ones. A row missing because it was zero reads
|
|
8127
8113
|
// as a row somebody forgot, and "you are not caching at all" is a finding.
|
|
8128
8114
|
for (const [name, usd, share, tokens] of parts) {
|
|
8129
|
-
console.log(` ${
|
|
8115
|
+
console.log(` ${bar(share)} ${t.profile.part(name, formatUsd(usd), pct(share), n(tokens))}`);
|
|
8130
8116
|
}
|
|
8131
8117
|
|
|
8132
8118
|
/**
|
|
@@ -8570,7 +8556,7 @@ async function commandProfile(
|
|
|
8570
8556
|
*/
|
|
8571
8557
|
const levers = billLevers(report, { catalogue: pricing });
|
|
8572
8558
|
console.log();
|
|
8573
|
-
console.log(
|
|
8559
|
+
console.log(sectionHeading(t.profile.leversHeading()));
|
|
8574
8560
|
/**
|
|
8575
8561
|
* Every lever below describes a mixture when nothing carries a label.
|
|
8576
8562
|
*
|
|
@@ -8644,7 +8630,7 @@ async function commandProfile(
|
|
|
8644
8630
|
*/
|
|
8645
8631
|
if (whatIf !== null) {
|
|
8646
8632
|
console.log();
|
|
8647
|
-
console.log(
|
|
8633
|
+
console.log(sectionHeading(t.profile.whatIfHeading(whatIf.target.displayName)));
|
|
8648
8634
|
console.log(` ${c.dim(wrap(t.profile.whatIfAssumption(), 74, ' '))}`);
|
|
8649
8635
|
console.log();
|
|
8650
8636
|
if (whatIf.slices.length === 0) {
|
|
@@ -8731,7 +8717,7 @@ async function commandProfile(
|
|
|
8731
8717
|
*/
|
|
8732
8718
|
if (report.conversations.length > 0) {
|
|
8733
8719
|
console.log();
|
|
8734
|
-
console.log(
|
|
8720
|
+
console.log(sectionHeading(t.profile.historyHeading()));
|
|
8735
8721
|
for (const growth of report.conversations.slice(0, 3)) {
|
|
8736
8722
|
const label = growth.label === UNLABELLED ? t.profile.unlabelled() : growth.label;
|
|
8737
8723
|
console.log();
|
|
@@ -8749,7 +8735,7 @@ async function commandProfile(
|
|
|
8749
8735
|
* on the line most likely to be the biggest.
|
|
8750
8736
|
*/
|
|
8751
8737
|
console.log();
|
|
8752
|
-
console.log(
|
|
8738
|
+
console.log(sectionHeading(t.profile.historyHeading()));
|
|
8753
8739
|
console.log(` ${c.dim(wrap(t.profile.historyNoSessions(), 74, ' '))}`);
|
|
8754
8740
|
}
|
|
8755
8741
|
|
|
@@ -8767,7 +8753,7 @@ async function commandProfile(
|
|
|
8767
8753
|
*/
|
|
8768
8754
|
if (report.outputShapes.length > 0) {
|
|
8769
8755
|
console.log();
|
|
8770
|
-
console.log(
|
|
8756
|
+
console.log(sectionHeading(t.profile.outputShapeHeading()));
|
|
8771
8757
|
for (const shape of report.outputShapes.slice(0, 3)) {
|
|
8772
8758
|
const label = shape.label === UNLABELLED ? t.profile.unlabelled() : shape.label;
|
|
8773
8759
|
const isTail = shape.heavyCallShare < 0.25;
|
|
@@ -8813,7 +8799,7 @@ async function commandProfile(
|
|
|
8813
8799
|
*/
|
|
8814
8800
|
if (report.inputShapes.length > 0) {
|
|
8815
8801
|
console.log();
|
|
8816
|
-
console.log(
|
|
8802
|
+
console.log(sectionHeading(t.profile.inputShapeHeading()));
|
|
8817
8803
|
for (const shape of report.inputShapes.slice(0, 3)) {
|
|
8818
8804
|
const label = shape.label === UNLABELLED ? t.profile.unlabelled() : shape.label;
|
|
8819
8805
|
console.log();
|
|
@@ -8877,7 +8863,7 @@ async function commandProfile(
|
|
|
8877
8863
|
{
|
|
8878
8864
|
if (pressures.length > 0) {
|
|
8879
8865
|
console.log();
|
|
8880
|
-
console.log(
|
|
8866
|
+
console.log(sectionHeading(t.profile.pressureHeading()));
|
|
8881
8867
|
for (const row of pressures.slice(0, 3)) {
|
|
8882
8868
|
const label = row.label === UNLABELLED ? t.profile.unlabelled() : row.label;
|
|
8883
8869
|
const line = t.profile.pressureLine(
|
|
@@ -8909,7 +8895,7 @@ async function commandProfile(
|
|
|
8909
8895
|
);
|
|
8910
8896
|
if (moved.length > 0) {
|
|
8911
8897
|
console.log();
|
|
8912
|
-
console.log(
|
|
8898
|
+
console.log(sectionHeading(t.profile.mixDriftHeading()));
|
|
8913
8899
|
for (const m of moved.slice(0, 3)) {
|
|
8914
8900
|
console.log();
|
|
8915
8901
|
console.log(
|
|
@@ -8932,7 +8918,7 @@ async function commandProfile(
|
|
|
8932
8918
|
*/
|
|
8933
8919
|
if (report.repeatedTurns.length > 0) {
|
|
8934
8920
|
console.log();
|
|
8935
|
-
console.log(
|
|
8921
|
+
console.log(sectionHeading(t.profile.repeatsHeading()));
|
|
8936
8922
|
for (const row of report.repeatedTurns.slice(0, 3)) {
|
|
8937
8923
|
const label = row.label === UNLABELLED ? t.profile.unlabelled() : row.label;
|
|
8938
8924
|
console.log();
|
|
@@ -9026,7 +9012,7 @@ async function commandProfile(
|
|
|
9026
9012
|
*/
|
|
9027
9013
|
if (previous !== null) {
|
|
9028
9014
|
console.log();
|
|
9029
|
-
console.log(
|
|
9015
|
+
console.log(sectionHeading(t.profile.againstHeading()));
|
|
9030
9016
|
if (previous.total.calls === 0) {
|
|
9031
9017
|
console.log(` ${c.dim(wrap(t.profile.againstNothingPriced(), 74, ' '))}`);
|
|
9032
9018
|
} else {
|
|
@@ -9133,10 +9119,10 @@ async function commandProfile(
|
|
|
9133
9119
|
] as const) {
|
|
9134
9120
|
if (rows.length <= 1) continue; // One row is the total again, said twice.
|
|
9135
9121
|
console.log();
|
|
9136
|
-
console.log(
|
|
9122
|
+
console.log(sectionHeading(heading));
|
|
9137
9123
|
for (const [name, breakdown] of rows) {
|
|
9138
9124
|
const share = report.total.totalUsd > 0 ? breakdown.totalUsd / report.total.totalUsd : 0;
|
|
9139
|
-
console.log(` ${t.profile.row(name, formatUsd(breakdown.totalUsd), pct(share), t.profile.calls(breakdown.calls))}`);
|
|
9125
|
+
console.log(` ${bar(share)} ${t.profile.row(name, formatUsd(breakdown.totalUsd), pct(share), t.profile.calls(breakdown.calls))}`);
|
|
9140
9126
|
}
|
|
9141
9127
|
}
|
|
9142
9128
|
|
|
@@ -9169,7 +9155,7 @@ async function commandProfile(
|
|
|
9169
9155
|
const outcomes = outcomeReport(report.outcomeTally, config.outcomes ?? null);
|
|
9170
9156
|
if (outcomes.coverage.recorded > 0) {
|
|
9171
9157
|
console.log();
|
|
9172
|
-
console.log(
|
|
9158
|
+
console.log(sectionHeading(t.profile.outcomeHeading()));
|
|
9173
9159
|
|
|
9174
9160
|
const col = t.profile.outcomeColumns;
|
|
9175
9161
|
const rows = [...outcomes.slices, ...outcomes.undeclared].map((slice) => ({
|
|
@@ -9250,7 +9236,7 @@ async function commandProfile(
|
|
|
9250
9236
|
);
|
|
9251
9237
|
if (ranking.byCall.length > 0) {
|
|
9252
9238
|
console.log();
|
|
9253
|
-
console.log(
|
|
9239
|
+
console.log(sectionHeading(t.profile.perOutcomeHeading()));
|
|
9254
9240
|
const pcol = t.profile.perOutcomeColumns;
|
|
9255
9241
|
const prows = ranking.byCall.map((slice) => ({
|
|
9256
9242
|
key: slice.key,
|
|
@@ -9343,7 +9329,7 @@ async function commandProfile(
|
|
|
9343
9329
|
}
|
|
9344
9330
|
if (missing.length > 0) {
|
|
9345
9331
|
console.log();
|
|
9346
|
-
console.log(
|
|
9332
|
+
console.log(sectionHeading(t.profile.coverageHeading()));
|
|
9347
9333
|
for (const line of missing) console.log(` ${c.dim(wrap(line, 74, ' '))}`);
|
|
9348
9334
|
}
|
|
9349
9335
|
}
|
|
@@ -9999,7 +9985,7 @@ async function checkDirectory(
|
|
|
9999
9985
|
);
|
|
10000
9986
|
|
|
10001
9987
|
console.log();
|
|
10002
|
-
console.log(
|
|
9988
|
+
console.log(sectionHeading(t.check.directoryHeading(root, verdicts.length)));
|
|
10003
9989
|
console.log();
|
|
10004
9990
|
|
|
10005
9991
|
for (const verdict of verdicts) {
|
|
@@ -10148,7 +10134,7 @@ async function commandPrune(args: Args, t: CliMessages): Promise<void> {
|
|
|
10148
10134
|
|
|
10149
10135
|
const pct = (value: number): string => `${(value * 100).toFixed(0)}%`;
|
|
10150
10136
|
console.log();
|
|
10151
|
-
console.log(
|
|
10137
|
+
console.log(sectionHeading(t.prune.heading(provider.model)));
|
|
10152
10138
|
console.log(` ${c.dim(t.prune.selfAgreement(pct(report.selfAgreement)))}`);
|
|
10153
10139
|
console.log();
|
|
10154
10140
|
|
|
@@ -10241,7 +10227,7 @@ async function commandEval(
|
|
|
10241
10227
|
|
|
10242
10228
|
const pct = (value: number): string => `${(value * 100).toFixed(0)}%`;
|
|
10243
10229
|
console.log();
|
|
10244
|
-
console.log(
|
|
10230
|
+
console.log(sectionHeading(t.eval.heading()));
|
|
10245
10231
|
console.log(` ${t.eval.selfAgreement(pct(report.selfAgreement))}`);
|
|
10246
10232
|
console.log(` ${t.eval.crossAgreement(pct(report.crossAgreement))}`);
|
|
10247
10233
|
console.log();
|
|
@@ -10443,7 +10429,7 @@ function printComparison(
|
|
|
10443
10429
|
const signed = (value: number): string => `${value > 0 ? '+' : ''}${n(value)}`;
|
|
10444
10430
|
|
|
10445
10431
|
console.log();
|
|
10446
|
-
console.log(
|
|
10432
|
+
console.log(sectionHeading(t.diff.heading(beforePath, afterPath)));
|
|
10447
10433
|
if (optimized) console.log(c.dim(` ${t.diff.measuringOptimised()}`));
|
|
10448
10434
|
console.log();
|
|
10449
10435
|
console.log(
|
package/src/style.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's presentation layer — the 1.75 arc.
|
|
3
|
+
*
|
|
4
|
+
* Six painters, one measurer, one table renderer, one proportion bar, one
|
|
5
|
+
* heading rule. Everything here decorates figures the prose already states;
|
|
6
|
+
* the chapter-four guard strips the paint and asserts nothing was lost and
|
|
7
|
+
* nothing was hiding in it.
|
|
8
|
+
*
|
|
9
|
+
* Colour is on for a TTY unless `NO_COLOR` says otherwise, and on anywhere
|
|
10
|
+
* when `FORCE_COLOR=1` — the door the guard itself walks through, since a
|
|
11
|
+
* test that wants to see what colour does runs under a pipe. A plain pipe
|
|
12
|
+
* stays plain: every `trazum ... | grep` in somebody's script is owed the
|
|
13
|
+
* bytes their script was written against.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const forced = process.env.FORCE_COLOR === '1';
|
|
17
|
+
export const useColor = forced || (process.stdout.isTTY === true && process.env.NO_COLOR === undefined);
|
|
18
|
+
|
|
19
|
+
export const c = {
|
|
20
|
+
bold: (s: string) => (useColor ? `\u001b[1m${s}\u001b[22m` : s),
|
|
21
|
+
dim: (s: string) => (useColor ? `\u001b[2m${s}\u001b[22m` : s),
|
|
22
|
+
green: (s: string) => (useColor ? `\u001b[32m${s}\u001b[39m` : s),
|
|
23
|
+
red: (s: string) => (useColor ? `\u001b[31m${s}\u001b[39m` : s),
|
|
24
|
+
yellow: (s: string) => (useColor ? `\u001b[33m${s}\u001b[39m` : s),
|
|
25
|
+
cyan: (s: string) => (useColor ? `\u001b[36m${s}\u001b[39m` : s),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The report's text column. Headings rule out to it; nothing else needs it. */
|
|
29
|
+
export const REPORT_WIDTH = 74;
|
|
30
|
+
|
|
31
|
+
const ANSI = /\u001b\[[0-9;]*m/g;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A string's width as a terminal draws it — the ANSI codes not counted.
|
|
35
|
+
*
|
|
36
|
+
* Every hand-rolled `padStart` in the CLI miscounted the moment a painted
|
|
37
|
+
* cell reached it, which is why nothing painted ever sat in a column. All
|
|
38
|
+
* padding below measures through this.
|
|
39
|
+
*/
|
|
40
|
+
export function visibleWidth(s: string): number {
|
|
41
|
+
return s.replace(ANSI, '').length;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function padCell(s: string, width: number, align: 'left' | 'right'): string {
|
|
45
|
+
const gap = Math.max(0, width - visibleWidth(s));
|
|
46
|
+
return align === 'right' ? ' '.repeat(gap) + s : s + ' '.repeat(gap);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface TableColumn {
|
|
50
|
+
/** The header cell, already localized. Empty string for a headerless column. */
|
|
51
|
+
header: string;
|
|
52
|
+
align: 'left' | 'right';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The one table renderer, for the eleven layouts that each rebuilt it.
|
|
57
|
+
*
|
|
58
|
+
* Widths come from the content, headers print dimmed, and cells may arrive
|
|
59
|
+
* painted — the measurement ignores the paint. Returns lines; the caller
|
|
60
|
+
* owns the `console.log` and the indent, because some tables live inside a
|
|
61
|
+
* bullet and some at the margin.
|
|
62
|
+
*/
|
|
63
|
+
export function table(columns: TableColumn[], rows: string[][], indent = ' '): string[] {
|
|
64
|
+
const widths = columns.map((col, i) =>
|
|
65
|
+
Math.max(visibleWidth(col.header), ...rows.map((row) => visibleWidth(row[i] ?? ''))),
|
|
66
|
+
);
|
|
67
|
+
const lines: string[] = [];
|
|
68
|
+
if (columns.some((col) => col.header !== '')) {
|
|
69
|
+
lines.push(
|
|
70
|
+
indent +
|
|
71
|
+
columns.map((col, i) => padCell(c.dim(col.header), widths[i] ?? 0, col.align)).join(' ').trimEnd(),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
for (const row of rows) {
|
|
75
|
+
lines.push(
|
|
76
|
+
indent + columns.map((col, i) => padCell(row[i] ?? '', widths[i] ?? 0, col.align)).join(' ').trimEnd(),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return lines;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A share the line already states, readable from further away: `███░░░░░░░`.
|
|
84
|
+
*
|
|
85
|
+
* The bar is content, not paint — it prints in a pipe too, so the stripped
|
|
86
|
+
* and plain outputs stay byte-identical. It never carries information the
|
|
87
|
+
* text does not: the percentage beside it is the number, the bar is the
|
|
88
|
+
* glance. Clamped, because a share over 1 is the caller's bug and a bar
|
|
89
|
+
* wider than asked would make it the layout's.
|
|
90
|
+
*/
|
|
91
|
+
export function bar(share: number, width = 10): string {
|
|
92
|
+
const clamped = Math.max(0, Math.min(1, share));
|
|
93
|
+
const filled = Math.round(clamped * width);
|
|
94
|
+
return c.cyan('█'.repeat(filled)) + c.dim('░'.repeat(width - filled));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A section heading an eye can stop on: the text bold, the line completed
|
|
99
|
+
* with a dim rule out to the report's width.
|
|
100
|
+
*
|
|
101
|
+
* Adónde fue el dinero ─────────────────────────────────────────────
|
|
102
|
+
*
|
|
103
|
+
* The rule is content (it survives the strip); the weight is paint.
|
|
104
|
+
*/
|
|
105
|
+
export function sectionHeading(text: string, width = REPORT_WIDTH): string {
|
|
106
|
+
const room = Math.max(0, width - visibleWidth(text) - 1);
|
|
107
|
+
return `${c.bold(text)} ${c.dim('─'.repeat(room))}`.trimEnd();
|
|
108
|
+
}
|