@trazum/cli 1.76.0 → 1.77.1

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.76.0",
3
+ "version": "1.77.1",
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.76.0"
40
+ "@trazum/core": "1.77.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^26.2.0",
package/src/i18n/en.ts CHANGED
@@ -1715,6 +1715,8 @@ ${bold('EXAMPLES')}
1715
1715
  streamed: (count) => `${count} call(s) were written while still streaming; the final line's counts stood.`,
1716
1716
  disagreements: (count) => `${count} call(s) had lines that disagreed beyond streaming growth — a count shrank, or another field changed. The last line stood, but that is a finding: worth a look at the transcript.`,
1717
1717
  noRequestId: (count) => `${count} call(s) carried no request id, so nothing could be collapsed against them; each is priced as recorded.`,
1718
+ synthetic: (count) => `${count} turn(s) Claude Code wrote itself (model "<synthetic>") are not in the output: no provider ever billed them, so they are not calls.`,
1719
+ labelled: () => 'Labelled by project folder. Pass --no-label-from-project to leave the label off, or --label <name> to set one.',
1718
1720
  skipped: (other, unparseable, withoutUsage) => `Passed over: ${other} non-assistant line(s) (the transcript's other business), ${unparseable} unparseable, ${withoutUsage} assistant line(s) without usage.`,
1719
1721
  written: (file) => `Wrote ${file}.`,
1720
1722
  },
package/src/i18n/es.ts CHANGED
@@ -1733,6 +1733,8 @@ ${bold('EJEMPLOS')}
1733
1733
  streamed: (count) => `${count} llamada(s) se escribieron aún en streaming; quedaron los recuentos de la línea final.`,
1734
1734
  disagreements: (count) => `${count} llamada(s) tenían líneas en desacuerdo más allá del crecimiento del streaming — un recuento encogió, u otro campo cambió. Se quedó la última línea, pero es un hallazgo: merece un vistazo al transcript.`,
1735
1735
  noRequestId: (count) => `${count} llamada(s) sin id de petición, así que nada pudo colapsarse contra ellas; cada una se tasa tal como quedó registrada.`,
1736
+ synthetic: (count) => `${count} turno(s) que Claude Code escribió por su cuenta (modelo «<synthetic>») quedan fuera de la salida: ningún proveedor los facturó, así que no son llamadas.`,
1737
+ labelled: () => 'Etiquetado por carpeta de proyecto. Usa --no-label-from-project para dejarlo sin etiqueta, o --label <nombre> para poner una.',
1736
1738
  skipped: (other, unparseable, withoutUsage) => `Omitidas: ${other} línea(s) no-assistant (el resto del negocio del transcript), ${unparseable} imparseables, ${withoutUsage} línea(s) assistant sin usage.`,
1737
1739
  written: (file) => `Escrito ${file}.`,
1738
1740
  },
package/src/i18n/types.ts CHANGED
@@ -585,6 +585,8 @@ export interface CliMessages {
585
585
  /** Lines of one request disagreed beyond streaming growth. A finding. */
586
586
  disagreements(count: number): string;
587
587
  noRequestId(count: number): string;
588
+ synthetic(count: number): string;
589
+ labelled(): string;
588
590
  skipped(other: number, unparseable: number, withoutUsage: number): string;
589
591
  written(file: string): string;
590
592
  };
package/src/index.ts CHANGED
@@ -699,7 +699,10 @@ const COMMAND_FLAGS: Record<string, string[]> = {
699
699
  function rejectUnknownFlags(args: Args, t: CliMessages): void {
700
700
  const known = COMMAND_FLAGS[args.command];
701
701
  if (!known) return;
702
- const allowed = [...known, ...GLOBAL_FLAGS];
702
+ // Deduplicated: a command that declares a flag the globals also carry
703
+ // (`--json`, `--pricing`, `--pricing-live`) listed it twice in the error,
704
+ // and a refusal that stutters reads like the tool is unsure what it takes.
705
+ const allowed = [...new Set([...known, ...GLOBAL_FLAGS])];
703
706
 
704
707
  for (const name of args.flags.keys()) {
705
708
  // `out` is stored under its long name even when given as `-o`, and a
@@ -2571,6 +2574,32 @@ async function commandWrite(args: Args, t: CliMessages): Promise<void> {
2571
2574
  * `cwd`, no branch name crosses the conversion; the suite plants one of
2572
2575
  * each in a fixture and greps the whole output for them.
2573
2576
  */
2577
+ /**
2578
+ * The workload name inside a Claude Code project folder.
2579
+ *
2580
+ * Claude Code names those folders by encoding the project's absolute path
2581
+ * with `/` replaced by `-`: `~/.claude/projects/-Users-mac-Trazum`. **That
2582
+ * encoding cannot be undone.** Both `/` and `-` map to `-`, so nothing in
2583
+ * the folder name says which dashes were separators, and 1.77.0 shipped a
2584
+ * decoder that guessed the last segment and was wrong on every project
2585
+ * whose own name contains a hyphen — real examples from the run that found
2586
+ * it: `-Users-mac-ai-job-search-ai-job-search` labelled `search`, and
2587
+ * `-Users-mac-Desktop-Pulse-Coffee-pulse-coffee` labelled `coffee`. Two
2588
+ * different projects, both renamed to a word that was never their name.
2589
+ *
2590
+ * So the folder name stands as it is, minus the leading separator. It is
2591
+ * longer than a tidy guess and it is the one thing here that is certainly
2592
+ * true: a reader can find the folder it names. Presenting a decoding as a
2593
+ * fact when the encoding cannot support one is the failure this product
2594
+ * exists to refuse, and it does not get an exception for being convenient.
2595
+ */
2596
+ function projectLabelFor(file: string): string | undefined {
2597
+ const folder = dirname(resolvePath(file)).split('/').pop();
2598
+ if (folder === undefined || folder === '') return undefined;
2599
+ const trimmed = folder.replace(/^-+/, '');
2600
+ return trimmed !== '' ? trimmed : folder;
2601
+ }
2602
+
2574
2603
  async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void> {
2575
2604
  const target = args.positional[0];
2576
2605
  if (target === undefined) throw new Error(t.fromClaudeCode.noPath());
@@ -2596,7 +2625,20 @@ async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void>
2596
2625
  }
2597
2626
 
2598
2627
  const label = stringFlag(args, 'label');
2599
- const labelFromProject = boolFlag(args, 'label-from-project');
2628
+ /**
2629
+ * A folder of projects is a folder of workloads — the 1.77 default.
2630
+ *
2631
+ * The flag has existed since the folder walk did, and nobody found it: a
2632
+ * real forty-day run produced `label` on 0 of 10,393 records, and the
2633
+ * report could then only describe a mixture, which is exactly what it
2634
+ * said. The web app's folder drop has labelled by project since 1.70, so
2635
+ * the two surfaces disagreed about the same gesture.
2636
+ *
2637
+ * Default-on for a directory, `--no-label-from-project` to decline. A
2638
+ * single file is untouched: one file is one workload only if the caller
2639
+ * says so.
2640
+ */
2641
+ const labelFromProject = boolFlag(args, 'label-from-project', info.isDirectory());
2600
2642
  const lines: string[] = [];
2601
2643
  let records = 0;
2602
2644
  let collapsed = 0;
@@ -2606,9 +2648,10 @@ async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void>
2606
2648
  let withoutUsage = 0;
2607
2649
  let streamed = 0;
2608
2650
  let disagreements = 0;
2651
+ let synthetic = 0;
2609
2652
  for (const file of files) {
2610
2653
  const text = await readFile(file, 'utf8');
2611
- const projectLabel = labelFromProject ? dirname(resolvePath(file)).split('/').pop() : undefined;
2654
+ const projectLabel = labelFromProject ? projectLabelFor(file) : undefined;
2612
2655
  const conversion = claudeCodeRecords(text, {
2613
2656
  ...(label !== undefined
2614
2657
  ? { label }
@@ -2625,6 +2668,7 @@ async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void>
2625
2668
  withoutUsage += conversion.assistantWithoutUsage;
2626
2669
  streamed += conversion.streamed;
2627
2670
  disagreements += conversion.disagreements;
2671
+ synthetic += conversion.synthetic;
2628
2672
  }
2629
2673
 
2630
2674
  const out = stringFlag(args, 'out') ?? stringFlag(args, 'o');
@@ -2640,6 +2684,8 @@ async function commandFromClaudeCode(args: Args, t: CliMessages): Promise<void>
2640
2684
  if (streamed > 0) console.error(t.fromClaudeCode.streamed(streamed));
2641
2685
  if (disagreements > 0) console.error(t.fromClaudeCode.disagreements(disagreements));
2642
2686
  if (noRequestId > 0) console.error(t.fromClaudeCode.noRequestId(noRequestId));
2687
+ if (synthetic > 0) console.error(t.fromClaudeCode.synthetic(synthetic));
2688
+ if (labelFromProject && label === undefined) console.error(t.fromClaudeCode.labelled());
2643
2689
  console.error(t.fromClaudeCode.skipped(otherLines, unparseable, withoutUsage));
2644
2690
  }
2645
2691
 
@@ -2696,7 +2742,10 @@ async function commandSwitch(args: Args, pricing: PricingCatalogue, t: CliMessag
2696
2742
  savingUsd >= 0
2697
2743
  ? t.switchCmd.saves(formatUsd(reprice.currentUsd), formatUsd(reprice.targetUsd), formatUsd(savingUsd))
2698
2744
  : t.switchCmd.costs(formatUsd(reprice.currentUsd), formatUsd(reprice.targetUsd), formatUsd(-savingUsd));
2699
- console.log(` ${savingUsd >= 0 ? c.green('->') : c.red('->')} ${wrap(line, 72, ' ')}`);
2745
+ // The same arrow the levers use. `switch` shipped with an ASCII `->`
2746
+ // in 1.74 and the 1.75 arc gave every report one visual vocabulary;
2747
+ // two glyphs for one meaning is the reader doing translation work.
2748
+ console.log(` ${savingUsd >= 0 ? c.green('\u2192') : c.red('\u2192')} ${wrap(line, 72, ' ')}`);
2700
2749
  const movableCalls = reprice.slices.reduce((sum, slice) => sum + slice.calls, 0);
2701
2750
  console.log(` ${wrap(t.switchCmd.movable(movableCalls, reprice.slices.length), 74, ' ')}`);
2702
2751
  }