@trazum/cli 1.61.1 → 1.62.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trazum/cli",
3
- "version": "1.61.1",
3
+ "version": "1.62.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.61.1"
40
+ "@trazum/core": "1.62.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^26.2.0",
package/src/i18n/en.ts CHANGED
@@ -857,6 +857,8 @@ ${bold('EXAMPLES')}
857
857
  optionNeedsValue: (name) => `Option --${name} needs a value.`,
858
858
  mustBeNonNegative: (name, raw) =>
859
859
  `--${name} must be a non-negative number (received: "${raw}").`,
860
+ fractionFlag: (name, raw) =>
861
+ `--${name} is a fraction between 0 and 1 (received: ${raw}). The config refuses the same value the same way.`,
860
862
  badLevel: (received) => `--level must be "safe" or "aggressive" (received: "${received}").`,
861
863
  allLabelsNeedsLog: () =>
862
864
  '--all-labels ranks prompts by measured traffic, so it needs --from-log <usage.jsonl>. Without a log every saving would be multiplied by the same typed guess, which ranks prompts by length and calls it a priority.',
package/src/i18n/es.ts CHANGED
@@ -883,6 +883,8 @@ ${bold('EJEMPLOS')}
883
883
  optionNeedsValue: (name) => `La opción --${name} necesita un valor.`,
884
884
  mustBeNonNegative: (name, raw) =>
885
885
  `--${name} debe ser un número no negativo (recibido: "${raw}").`,
886
+ fractionFlag: (name, raw) =>
887
+ `--${name} es una fracción entre 0 y 1 (recibido: ${raw}). La configuración rechaza el mismo valor de la misma forma.`,
886
888
  badLevel: (received) => `--level debe ser "safe" o "aggressive" (recibido: "${received}").`,
887
889
  allLabelsNeedsLog: () =>
888
890
  '--all-labels ordena los prompts por tráfico medido, así que necesita --from-log <usage.jsonl>. Sin registro cada ahorro se multiplicaría por la misma suposición tecleada, lo que ordena los prompts por longitud y lo llama prioridad.',
package/src/i18n/types.ts CHANGED
@@ -84,6 +84,8 @@ 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
+ /** A flag that is a fraction of a whole: over 1 is refused, like the config. */
88
+ fractionFlag(name: string, raw: string): string;
87
89
  badLevel(received: string): string;
88
90
  /** `--from-log`'s refusals: contradiction, missing label, ambiguity, emptiness. */
89
91
  allLabelsNeedsLog(): string;
package/src/index.ts CHANGED
@@ -382,6 +382,15 @@ function parseArgs(argv: string[], t: CliMessages): Args {
382
382
  * `flags.has(name)` is the wrong test once negation exists: `--no-batch` stores
383
383
  * the key with the value `false`, and `has` would report it as set.
384
384
  */
385
+ /** A numberFlag that is also a fraction: the config's own 0-to-1 rule. */
386
+ function fractionFlag(args: Args, name: string, fallback: number, t: CliMessages): number {
387
+ const value = numberFlag(args, name, fallback, t);
388
+ if (value > 1) {
389
+ throw new Error(t.errors.fractionFlag(name, String(args.flags.get(name))));
390
+ }
391
+ return value;
392
+ }
393
+
385
394
  function boolFlag(args: Args, name: string, fallback = false): boolean {
386
395
  const raw = args.flags.get(name);
387
396
  return typeof raw === 'boolean' ? raw : fallback;
@@ -480,7 +489,15 @@ function usageFrom(
480
489
  fromConfig.avgOutputTokens ?? DEFAULT_USAGE.avgOutputTokens,
481
490
  t,
482
491
  ),
483
- cacheHitRate: numberFlag(
492
+ /*
493
+ Bounded above as well as below, because the config already is.
494
+
495
+ `usage.cacheHitRate: 2` in trazum.config.json is refused as "a fraction
496
+ between 0 and 1"; `--cache-hit-rate 2` on the command line was accepted
497
+ and quietly skewed the caching advisory. Two doors to the same value
498
+ cannot disagree about what fits through.
499
+ */
500
+ cacheHitRate: fractionFlag(
484
501
  args,
485
502
  'cache-hit-rate',
486
503
  fromConfig.cacheHitRate ?? DEFAULT_USAGE.cacheHitRate,