@trazum/cli 1.50.9 → 1.50.10
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/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +29 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +29 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +19 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.js +114 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/en.ts +36 -0
- package/src/i18n/es.ts +36 -0
- package/src/i18n/types.ts +15 -0
- package/src/index.ts +145 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trazum/cli",
|
|
3
|
-
"version": "1.50.
|
|
3
|
+
"version": "1.50.10",
|
|
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.50.
|
|
40
|
+
"@trazum/core": "1.50.10"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26.2.0",
|
package/src/i18n/en.ts
CHANGED
|
@@ -61,6 +61,7 @@ ${bold('USAGE')}
|
|
|
61
61
|
trazum experiment <log> --a <label> --b <label> --min-outcomes <n>
|
|
62
62
|
trazum quality <log> --label <name> --at <iso> [--gate]
|
|
63
63
|
trazum semantic <prompt> [--yes]
|
|
64
|
+
trazum owners <log>
|
|
64
65
|
trazum ladder <log>
|
|
65
66
|
trazum feedback
|
|
66
67
|
trazum --version
|
|
@@ -638,6 +639,12 @@ ${bold('CONFIG FILE')}
|
|
|
638
639
|
spend { "maxUsd": 200, "byLabel": { "chat": 40 } } — money budgets for
|
|
639
640
|
"trazum profile", in dollars. A budgeted label with no calls in
|
|
640
641
|
the log is reported as not measured, never as a pass
|
|
642
|
+
owners { "patterns": { "payments": ["billing-*"] },
|
|
643
|
+
"shared": { "search": { "payments": 0.6, "support": 0.4 } },
|
|
644
|
+
"budgets": { "payments": 400 } } — whose budget each workload
|
|
645
|
+
lands on. Spend matching no owner is its own line and is NEVER
|
|
646
|
+
divided between the others; a shared split must sum to 1, and the
|
|
647
|
+
rule travels with the report so the argument is about the rule
|
|
641
648
|
ladders { "support": { "tiers": ["claude-haiku-4-5", "claude-opus-5"],
|
|
642
649
|
"escalateOn": ["escalated"] } } — cheap model first, escalate a
|
|
643
650
|
recorded failure to a dearer one. Both fields required.
|
|
@@ -1004,6 +1011,35 @@ ${bold('EXAMPLES')}
|
|
|
1004
1011
|
`${path} exists and could not be parsed, so nothing was written over it. Fix or move it first.`,
|
|
1005
1012
|
},
|
|
1006
1013
|
|
|
1014
|
+
owners: {
|
|
1015
|
+
heading: () => 'Whose money',
|
|
1016
|
+
noOwners: () =>
|
|
1017
|
+
'No owners configured. Add "owners" to trazum.config.json to attribute spend, for example {"patterns": {"payments": ["billing-*"]}, "budgets": {"payments": 400}}.',
|
|
1018
|
+
columns: { owner: 'owner', spend: 'spend', budget: 'budget', calls: 'calls' },
|
|
1019
|
+
verdict: (kind) =>
|
|
1020
|
+
kind === 'over' ? 'over' : kind === 'within' ? 'within' : kind === 'not-measured' ? 'not measured' : '\u2014',
|
|
1021
|
+
unallocated: (usd, share, labels) =>
|
|
1022
|
+
`Unallocated: ${usd} (${share} of the bill), from ${labels}.`,
|
|
1023
|
+
neverSpread: () =>
|
|
1024
|
+
'It is not divided between the owners above, and it never will be. Spreading unattributed spend proportionally is the most common lie in cost reporting: it makes every line add up and every team\u2019s number wrong by an amount nobody can see \u2014 hardest on whoever instruments best, because their known spend is largest and they absorb the biggest share of somebody else\u2019s mystery. Claim it with a pattern.',
|
|
1025
|
+
nothingUnallocated: () => 'Every workload in this log has an owner.',
|
|
1026
|
+
sharedHeading: () => 'Shared, by a rule somebody wrote',
|
|
1027
|
+
sharedRule: (label, rule) => `${label}: ${rule}`,
|
|
1028
|
+
problemsHeading: () => 'This ownership config will not do what it looks like it does',
|
|
1029
|
+
problem: (kind, detail) =>
|
|
1030
|
+
kind === 'split-does-not-sum'
|
|
1031
|
+
? `${detail} \u2014 a split that does not sum to 1 loses money or invents it, silently. That workload is left whole in the unallocated line until this is fixed.`
|
|
1032
|
+
: kind === 'split-names-unknown-owner'
|
|
1033
|
+
? `${detail} names an owner that "owners.patterns" does not declare.`
|
|
1034
|
+
: kind === 'split-has-one-owner'
|
|
1035
|
+
? `${detail} is "shared" with one owner \u2014 that is a pattern written the long way, and reading it as a share invites a second owner to be added without the first being adjusted.`
|
|
1036
|
+
: kind === 'negative-share'
|
|
1037
|
+
? `${detail} has a negative share.`
|
|
1038
|
+
: `${detail} has a budget but no patterns, so nothing can ever land on it.`,
|
|
1039
|
+
notMeasured: (owner) =>
|
|
1040
|
+
`${owner} has a budget and no measured calls. That is NOT under budget \u2014 a team whose logs never arrived passes every budget it has, forever, and a green tick beside their name says the opposite of the truth.`,
|
|
1041
|
+
},
|
|
1042
|
+
|
|
1007
1043
|
semantic: {
|
|
1008
1044
|
heading: (path) => `Semantic pass on ${path}`,
|
|
1009
1045
|
willCost: (usd, input, output, model) =>
|
package/src/i18n/es.ts
CHANGED
|
@@ -48,6 +48,7 @@ ${bold('USO')}
|
|
|
48
48
|
trazum experiment <log> --a <label> --b <label> --min-outcomes <n>
|
|
49
49
|
trazum quality <log> --label <name> --at <iso> [--gate]
|
|
50
50
|
trazum semantic <prompt> [--yes]
|
|
51
|
+
trazum owners <log>
|
|
51
52
|
trazum ladder <log>
|
|
52
53
|
trazum feedback
|
|
53
54
|
trazum --version
|
|
@@ -658,6 +659,12 @@ ${bold('FICHERO DE CONFIGURACIÓN')}
|
|
|
658
659
|
spend { "maxUsd": 200, "byLabel": { "chat": 40 } } — presupuestos en
|
|
659
660
|
dólares para "trazum profile". Una etiqueta con presupuesto y sin
|
|
660
661
|
llamadas se informa como no medida, nunca como aprobada
|
|
662
|
+
owners { "patterns": { "payments": ["billing-*"] },
|
|
663
|
+
"shared": { "search": { "payments": 0.6, "support": 0.4 } },
|
|
664
|
+
"budgets": { "payments": 400 } } — de quién es el presupuesto de
|
|
665
|
+
cada carga. El gasto sin propietario es su propia línea y NUNCA se
|
|
666
|
+
reparte entre los demás; un reparto compartido debe sumar 1, y la
|
|
667
|
+
regla viaja con el informe para que se discuta la regla
|
|
661
668
|
ladders { "support": { "tiers": ["claude-haiku-4-5", "claude-opus-5"],
|
|
662
669
|
"escalateOn": ["escalated"] } } — modelo barato primero, escalar
|
|
663
670
|
un fallo registrado a uno más caro. Los dos campos obligatorios.
|
|
@@ -1040,6 +1047,35 @@ ${bold('EJEMPLOS')}
|
|
|
1040
1047
|
`${path} existe y no se pudo interpretar, así que no se escribió nada encima. Arréglalo o muévelo primero.`,
|
|
1041
1048
|
},
|
|
1042
1049
|
|
|
1050
|
+
owners: {
|
|
1051
|
+
heading: () => 'De qui\u00e9n es el dinero',
|
|
1052
|
+
noOwners: () =>
|
|
1053
|
+
'No hay propietarios configurados. A\u00f1ade "owners" a trazum.config.json para atribuir gasto, por ejemplo {"patterns": {"payments": ["billing-*"]}, "budgets": {"payments": 400}}.',
|
|
1054
|
+
columns: { owner: 'propietario', spend: 'gasto', budget: 'presupuesto', calls: 'llamadas' },
|
|
1055
|
+
verdict: (kind) =>
|
|
1056
|
+
kind === 'over' ? 'pasado' : kind === 'within' ? 'dentro' : kind === 'not-measured' ? 'sin medir' : '\u2014',
|
|
1057
|
+
unallocated: (usd, share, labels) =>
|
|
1058
|
+
`Sin asignar: ${usd} (${share} de la factura), de ${labels}.`,
|
|
1059
|
+
neverSpread: () =>
|
|
1060
|
+
'No se reparte entre los propietarios de arriba, y nunca se har\u00e1. Repartir el gasto sin atribuir de forma proporcional es la mentira m\u00e1s com\u00fan en informes de coste: hace que todas las l\u00edneas cuadren y que el n\u00famero de cada equipo est\u00e9 mal en una cantidad que nadie puede ver \u2014 y castiga m\u00e1s a quien mejor instrumenta, porque su gasto conocido es el mayor y absorbe la mayor parte del misterio ajeno. Recl\u00e1malo con un patr\u00f3n.',
|
|
1061
|
+
nothingUnallocated: () => 'Todas las cargas de este log tienen propietario.',
|
|
1062
|
+
sharedHeading: () => 'Compartido, por una regla que escribi\u00f3 alguien',
|
|
1063
|
+
sharedRule: (label, rule) => `${label}: ${rule}`,
|
|
1064
|
+
problemsHeading: () => 'Esta configuraci\u00f3n de propiedad no va a hacer lo que parece',
|
|
1065
|
+
problem: (kind, detail) =>
|
|
1066
|
+
kind === 'split-does-not-sum'
|
|
1067
|
+
? `${detail} \u2014 un reparto que no suma 1 pierde dinero o lo inventa, en silencio. Esa carga se deja entera en la l\u00ednea sin asignar hasta que se arregle.`
|
|
1068
|
+
: kind === 'split-names-unknown-owner'
|
|
1069
|
+
? `${detail} nombra un propietario que "owners.patterns" no declara.`
|
|
1070
|
+
: kind === 'split-has-one-owner'
|
|
1071
|
+
? `${detail} est\u00e1 "compartido" con un solo propietario \u2014 eso es un patr\u00f3n escrito largo, y leerlo como reparto invita a a\u00f1adir un segundo sin ajustar el primero.`
|
|
1072
|
+
: kind === 'negative-share'
|
|
1073
|
+
? `${detail} tiene un reparto negativo.`
|
|
1074
|
+
: `${detail} tiene presupuesto pero no patrones, as\u00ed que nunca podr\u00e1 caerle nada.`,
|
|
1075
|
+
notMeasured: (owner) =>
|
|
1076
|
+
`${owner} tiene presupuesto y ninguna llamada medida. Eso NO es estar dentro del presupuesto \u2014 un equipo cuyos logs nunca llegaron pasa todos sus presupuestos, siempre, y un tic verde junto a su nombre dice lo contrario de la verdad.`,
|
|
1077
|
+
},
|
|
1078
|
+
|
|
1043
1079
|
semantic: {
|
|
1044
1080
|
heading: (path) => `Pase sem\u00e1ntico sobre ${path}`,
|
|
1045
1081
|
willCost: (usd, input, output, model) =>
|
package/src/i18n/types.ts
CHANGED
|
@@ -268,6 +268,21 @@ export interface CliMessages {
|
|
|
268
268
|
* The ladder. Every line here exists to stop somebody reading "we route to
|
|
269
269
|
* the cheap model first" as a saving without the number that decides it.
|
|
270
270
|
*/
|
|
271
|
+
owners: {
|
|
272
|
+
heading(): string;
|
|
273
|
+
noOwners(): string;
|
|
274
|
+
columns: { owner: string; spend: string; budget: string; calls: string };
|
|
275
|
+
verdict(kind: string): string;
|
|
276
|
+
unallocated(usd: string, share: string, labels: string): string;
|
|
277
|
+
neverSpread(): string;
|
|
278
|
+
nothingUnallocated(): string;
|
|
279
|
+
sharedHeading(): string;
|
|
280
|
+
sharedRule(label: string, rule: string): string;
|
|
281
|
+
problemsHeading(): string;
|
|
282
|
+
problem(kind: string, detail: string): string;
|
|
283
|
+
notMeasured(owner: string): string;
|
|
284
|
+
};
|
|
285
|
+
|
|
271
286
|
semantic: {
|
|
272
287
|
heading(path: string): string;
|
|
273
288
|
willCost(usd: string, input: string, output: string, model: string): string;
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
budgetPositions,
|
|
41
41
|
conform,
|
|
42
42
|
BREAK_EVEN_BAND,
|
|
43
|
+
allocate,
|
|
43
44
|
runExperiment,
|
|
44
45
|
qualityGate,
|
|
45
46
|
semanticPassCost,
|
|
@@ -589,6 +590,7 @@ const COMMAND_FLAGS: Record<string, string[]> = {
|
|
|
589
590
|
experiment: ['a', 'b', 'min-outcomes', 'pricing', 'pricing-live'],
|
|
590
591
|
quality: ['label', 'at', 'gate', 'pricing', 'pricing-live'],
|
|
591
592
|
semantic: ['yes', 'model', 'pricing', 'pricing-live'],
|
|
593
|
+
owners: ['pricing', 'pricing-live', 'since', 'until'],
|
|
592
594
|
where: [],
|
|
593
595
|
rules: [],
|
|
594
596
|
blame: ['limit', 'model', 'calls', 'output-tokens', 'batch', 'prompt', 'markdown-out'],
|
|
@@ -2734,6 +2736,146 @@ async function commandSemantic(
|
|
|
2734
2736
|
console.log();
|
|
2735
2737
|
}
|
|
2736
2738
|
|
|
2739
|
+
/**
|
|
2740
|
+
* `trazum owners <log>` — whose budget each workload lands on.
|
|
2741
|
+
*
|
|
2742
|
+
* The fleet answered *which service* in 1.37. This answers *whose money*,
|
|
2743
|
+
* which is the question that decides whether anything on the list gets done: a
|
|
2744
|
+
* report saying "the bill is $40,000 and here is $9,000 of savings" is read by
|
|
2745
|
+
* four people who each assume it is one of the other three's problem.
|
|
2746
|
+
*
|
|
2747
|
+
* **The unallocated is its own line and is never spread.** See `owners.ts` for
|
|
2748
|
+
* why that is worth breaking a module over.
|
|
2749
|
+
*/
|
|
2750
|
+
async function commandOwners(
|
|
2751
|
+
args: Args,
|
|
2752
|
+
config: TrazumConfig,
|
|
2753
|
+
pricing: PricingCatalogue,
|
|
2754
|
+
t: CliMessages,
|
|
2755
|
+
): Promise<void> {
|
|
2756
|
+
const path = args.positional[0];
|
|
2757
|
+
if (path === undefined) throw new Error(t.errors.missingInputFile());
|
|
2758
|
+
|
|
2759
|
+
console.log();
|
|
2760
|
+
console.log(c.bold(t.owners.heading()));
|
|
2761
|
+
if (config.owners === undefined) {
|
|
2762
|
+
console.log(` ${c.dim(wrap(t.owners.noOwners(), 74, ' '))}`);
|
|
2763
|
+
console.log();
|
|
2764
|
+
return;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
const report = profileUsage(await readUsageLog(path, t), { catalogue: pricing });
|
|
2768
|
+
const result = allocate(
|
|
2769
|
+
report.byLabel.map((entry) => ({
|
|
2770
|
+
label: entry.label,
|
|
2771
|
+
usd: entry.breakdown.totalUsd,
|
|
2772
|
+
calls: entry.breakdown.calls,
|
|
2773
|
+
})),
|
|
2774
|
+
config.owners,
|
|
2775
|
+
);
|
|
2776
|
+
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
2777
|
+
const pct = (value: number): string => `${(value * 100).toFixed(1)}%`;
|
|
2778
|
+
|
|
2779
|
+
/**
|
|
2780
|
+
* Problems first, before any figure.
|
|
2781
|
+
*
|
|
2782
|
+
* A split that does not sum to one sends a whole workload to unallocated,
|
|
2783
|
+
* and a reader who saw the table before the explanation would go looking for
|
|
2784
|
+
* a bug in their logs.
|
|
2785
|
+
*/
|
|
2786
|
+
if (result.problems.length > 0) {
|
|
2787
|
+
console.log();
|
|
2788
|
+
console.log(` ${c.red('✗')} ${c.bold(t.owners.problemsHeading())}`);
|
|
2789
|
+
for (const problem of result.problems) {
|
|
2790
|
+
const detail =
|
|
2791
|
+
problem.kind === 'budget-for-unknown-owner'
|
|
2792
|
+
? problem.owner
|
|
2793
|
+
: problem.kind === 'split-does-not-sum'
|
|
2794
|
+
? `"${problem.label}" sums to ${problem.total}`
|
|
2795
|
+
: problem.kind === 'negative-share' || problem.kind === 'split-names-unknown-owner'
|
|
2796
|
+
? `"${problem.label}" → ${problem.owner}`
|
|
2797
|
+
: `"${problem.label}"`;
|
|
2798
|
+
console.log(` ${wrap(t.owners.problem(problem.kind, detail), 70, ' ')}`);
|
|
2799
|
+
}
|
|
2800
|
+
process.exitCode = 1;
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
console.log();
|
|
2804
|
+
const col = t.owners.columns;
|
|
2805
|
+
const rows = result.owners.map((line) => ({
|
|
2806
|
+
owner: line.owner,
|
|
2807
|
+
spend: formatUsd(line.usd),
|
|
2808
|
+
budget: line.budgetUsd === null ? '—' : formatUsd(line.budgetUsd),
|
|
2809
|
+
calls: n(Math.round(line.calls)),
|
|
2810
|
+
verdict: t.owners.verdict(line.verdict),
|
|
2811
|
+
kind: line.verdict,
|
|
2812
|
+
}));
|
|
2813
|
+
const w = {
|
|
2814
|
+
owner: Math.max(...rows.map((r) => r.owner.length), col.owner.length),
|
|
2815
|
+
spend: Math.max(...rows.map((r) => r.spend.length), col.spend.length),
|
|
2816
|
+
budget: Math.max(...rows.map((r) => r.budget.length), col.budget.length),
|
|
2817
|
+
calls: Math.max(...rows.map((r) => r.calls.length), col.calls.length),
|
|
2818
|
+
};
|
|
2819
|
+
console.log(
|
|
2820
|
+
c.dim(
|
|
2821
|
+
` ${col.owner.padEnd(w.owner)} ${col.spend.padStart(w.spend)} ` +
|
|
2822
|
+
`${col.budget.padStart(w.budget)} ${col.calls.padStart(w.calls)}`,
|
|
2823
|
+
),
|
|
2824
|
+
);
|
|
2825
|
+
for (const row of rows) {
|
|
2826
|
+
const tint = row.kind === 'over' ? c.red : row.kind === 'not-measured' ? c.yellow : c.dim;
|
|
2827
|
+
console.log(
|
|
2828
|
+
` ${row.owner.padEnd(w.owner)} ${row.spend.padStart(w.spend)} ` +
|
|
2829
|
+
`${row.budget.padStart(w.budget)} ${row.calls.padStart(w.calls)} ${tint(row.verdict)}`,
|
|
2830
|
+
);
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
// The 1.37 refusal, applied to people, said in full for each owner it hits.
|
|
2834
|
+
for (const line of result.owners) {
|
|
2835
|
+
if (line.verdict === 'not-measured') {
|
|
2836
|
+
console.log();
|
|
2837
|
+
console.log(` ${c.yellow('!')} ${wrap(t.owners.notMeasured(line.owner), 74, ' ')}`);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
console.log();
|
|
2842
|
+
if (result.unallocated.usd > 0) {
|
|
2843
|
+
console.log(
|
|
2844
|
+
` ${c.yellow('!')} ${wrap(
|
|
2845
|
+
t.owners.unallocated(
|
|
2846
|
+
formatUsd(result.unallocated.usd),
|
|
2847
|
+
report.total.totalUsd > 0 ? pct(result.unallocated.usd / report.total.totalUsd) : '—',
|
|
2848
|
+
result.unallocated.labels.slice(0, 6).join(', '),
|
|
2849
|
+
),
|
|
2850
|
+
74,
|
|
2851
|
+
' ',
|
|
2852
|
+
)}`,
|
|
2853
|
+
);
|
|
2854
|
+
console.log(` ${c.dim(wrap(t.owners.neverSpread(), 72, ' '))}`);
|
|
2855
|
+
} else {
|
|
2856
|
+
console.log(` ${c.dim(t.owners.nothingUnallocated())}`);
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
/**
|
|
2860
|
+
* The shared rules, printed with the report.
|
|
2861
|
+
*
|
|
2862
|
+
* The whole design: the argument then happens about the rule — "why is
|
|
2863
|
+
* search 60/40?" — rather than about the number, which is an argument nobody
|
|
2864
|
+
* can win because nobody can see where the number came from.
|
|
2865
|
+
*/
|
|
2866
|
+
if (result.sharedApplied.length > 0) {
|
|
2867
|
+
console.log();
|
|
2868
|
+
console.log(` ${c.bold(t.owners.sharedHeading())}`);
|
|
2869
|
+
for (const { label, split } of result.sharedApplied) {
|
|
2870
|
+
const rule = Object.entries(split)
|
|
2871
|
+
.map(([owner, share]) => `${owner} ${pct(share)}`)
|
|
2872
|
+
.join(', ');
|
|
2873
|
+
console.log(` ${c.dim(t.owners.sharedRule(label, rule))}`);
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
console.log();
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2737
2879
|
function commandModels(t: CliMessages, pricing: PricingCatalogue): void {
|
|
2738
2880
|
const n = (value: number): string => value.toLocaleString(t.numberLocale);
|
|
2739
2881
|
const col = t.models.columns;
|
|
@@ -8934,6 +9076,9 @@ async function main(): Promise<void> {
|
|
|
8934
9076
|
case 'models':
|
|
8935
9077
|
commandModels(t, pricing);
|
|
8936
9078
|
break;
|
|
9079
|
+
case 'owners':
|
|
9080
|
+
await commandOwners(args, config, pricing, t);
|
|
9081
|
+
break;
|
|
8937
9082
|
case 'semantic':
|
|
8938
9083
|
await commandSemantic(args, config, pricing, t);
|
|
8939
9084
|
break;
|