@trazum/cli 2.5.2 → 2.7.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.
Files changed (50) hide show
  1. package/README.md +4 -2
  2. package/dist/filter.d.ts.map +1 -1
  3. package/dist/filter.js +43 -7
  4. package/dist/filter.js.map +1 -1
  5. package/dist/i18n/en.d.ts.map +1 -1
  6. package/dist/i18n/en.js +66 -7
  7. package/dist/i18n/en.js.map +1 -1
  8. package/dist/i18n/es.d.ts.map +1 -1
  9. package/dist/i18n/es.js +67 -7
  10. package/dist/i18n/es.js.map +1 -1
  11. package/dist/i18n/types.d.ts +22 -1
  12. package/dist/i18n/types.d.ts.map +1 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +271 -20
  15. package/dist/index.js.map +1 -1
  16. package/dist/serve-import-schema.d.ts +34 -0
  17. package/dist/serve-import-schema.d.ts.map +1 -0
  18. package/dist/serve-import-schema.js +32 -0
  19. package/dist/serve-import-schema.js.map +1 -0
  20. package/dist/serve-import.d.ts +49 -0
  21. package/dist/serve-import.d.ts.map +1 -0
  22. package/dist/serve-import.js +52 -0
  23. package/dist/serve-import.js.map +1 -0
  24. package/dist/serve-schema.d.ts +70 -0
  25. package/dist/serve-schema.d.ts.map +1 -1
  26. package/dist/serve-schema.js +9 -0
  27. package/dist/serve-schema.js.map +1 -1
  28. package/dist/serve.d.ts.map +1 -1
  29. package/dist/serve.js +9 -2
  30. package/dist/serve.js.map +1 -1
  31. package/dist/task-files.d.ts +9 -0
  32. package/dist/task-files.d.ts.map +1 -0
  33. package/dist/task-files.js +136 -0
  34. package/dist/task-files.js.map +1 -0
  35. package/dist/task.d.ts +2 -0
  36. package/dist/task.d.ts.map +1 -0
  37. package/dist/task.js +137 -0
  38. package/dist/task.js.map +1 -0
  39. package/package.json +7 -4
  40. package/src/filter.ts +46 -10
  41. package/src/i18n/en.ts +72 -7
  42. package/src/i18n/es.ts +75 -7
  43. package/src/i18n/types.ts +23 -1
  44. package/src/index.ts +259 -16
  45. package/src/serve-import-schema.ts +32 -0
  46. package/src/serve-import.ts +60 -0
  47. package/src/serve-schema.ts +9 -0
  48. package/src/serve.ts +9 -2
  49. package/src/task-files.ts +114 -0
  50. package/src/task.ts +119 -0
package/dist/task.js ADDED
@@ -0,0 +1,137 @@
1
+ import { analyzeTask, compareTasks, parseTaskReport, taskPolicy, MAX_INPUT_CHARS } from '@trazum/core';
2
+ import { changeTaskInstructions, readTaskText, writeTaskText } from './task-files.js';
3
+ const HELP = `Usage:
4
+ trazum task analyze --id <id> --type <type> --criterion <text>
5
+ --claude-code <file> [--codex <file>] [--claude-code <file> ...]
6
+ [--outcome accepted|rejected|unknown --assessor <label>]
7
+ [--policy baseline|repeat-review-v1] [-o <new-report.json>]
8
+ trazum task policy <report.json> [-o <new-policy.md>]
9
+ trazum task apply <report.json> --instructions <existing-file>
10
+ trazum task revert --instructions <existing-file>
11
+ trazum task compare <before.json> <after.json> [-o <new-comparison.json>]
12
+
13
+ Analyze explicit, complete task sources from Claude Code and Codex locally.
14
+ Repeat the source flags to include sessions from both harnesses. No home scan,
15
+ network access, provider call, hook installation or command execution occurs.
16
+ Up to 16 sources and ${MAX_INPUT_CHARS} characters combined. Do not split one
17
+ session across sources or import the same session more than once.
18
+ Reports and comparisons are JSON by default (--json is also accepted).
19
+ Outcome and assessor are caller declarations, never inferred from usage.
20
+ Policy application adds a small, optional managed block to the file you choose.
21
+ Review the diff and run a comparable task yourself before comparing reports.
22
+ Revert removes only the exact unchanged block. Close other editors while applying
23
+ or reverting. Existing output reports are never overwritten; new files use 0600.
24
+ Repeated tool results may be intentional. A paired comparison is an observation,
25
+ not proof of causal savings, task quality or remaining subscription allowance.
26
+ `;
27
+ const ALLOWED = {
28
+ analyze: ['id', 'type', 'criterion', 'outcome', 'assessor', 'policy', 'claude-code', 'codex', 'out', 'json'],
29
+ policy: ['out'],
30
+ apply: ['instructions'],
31
+ revert: ['instructions'],
32
+ compare: ['out', 'json'],
33
+ };
34
+ function parse(action, args) {
35
+ const allowed = ALLOWED[action];
36
+ if (!allowed)
37
+ throw new Error('Unknown task action. Run trazum task --help.');
38
+ const flags = new Map();
39
+ const sources = [];
40
+ const paths = [];
41
+ for (let index = 0; index < args.length; index++) {
42
+ const arg = args[index];
43
+ if (!arg.startsWith('-')) {
44
+ paths.push(arg);
45
+ continue;
46
+ }
47
+ const name = arg === '-o' ? 'out' : arg.startsWith('--') ? arg.slice(2) : '';
48
+ if (!allowed.includes(name))
49
+ throw new Error('Unsupported task option. Run trazum task --help.');
50
+ if (flags.has(name))
51
+ throw new Error('Task options cannot be repeated except source flags.');
52
+ if (name === 'json') {
53
+ flags.set(name, 'true');
54
+ continue;
55
+ }
56
+ const value = args[++index];
57
+ if (value === undefined || value.trim() === '' || value.startsWith('-'))
58
+ throw new Error('A task option is missing its value.');
59
+ if (name === 'claude-code' || name === 'codex') {
60
+ sources.push({ format: name, path: value });
61
+ if (sources.length > 16)
62
+ throw new Error('At most 16 task sources are accepted.');
63
+ }
64
+ else
65
+ flags.set(name, value);
66
+ }
67
+ return { flags, sources, paths };
68
+ }
69
+ function required(flags, name) {
70
+ const value = flags.get(name);
71
+ if (value === undefined)
72
+ throw new Error(`Missing --${name}. Run trazum task --help.`);
73
+ return value;
74
+ }
75
+ async function emit(value, output) {
76
+ let text = `${typeof value === 'string' ? value : JSON.stringify(value, null, 2)}\n`;
77
+ if (text.length > MAX_INPUT_CHARS && typeof value !== 'string')
78
+ text = `${JSON.stringify(value)}\n`;
79
+ if (text.length > MAX_INPUT_CHARS)
80
+ throw new Error('Task output exceeds the report limit; use a smaller complete task source.');
81
+ if (output !== undefined)
82
+ await writeTaskText(output, text);
83
+ else
84
+ process.stdout.write(text);
85
+ }
86
+ export async function runTask(args) {
87
+ if (args.length === 0 || (args.length === 1 && ['--help', '-h'].includes(args[0])) ||
88
+ (args.length === 2 && Object.hasOwn(ALLOWED, args[0]) && ['--help', '-h'].includes(args[1]))) {
89
+ process.stdout.write(HELP);
90
+ return;
91
+ }
92
+ const action = args[0];
93
+ const { flags, sources, paths } = parse(action, args.slice(1));
94
+ const expectedPaths = action === 'compare' ? 2 : action === 'policy' || action === 'apply' ? 1 : 0;
95
+ if (paths.length !== expectedPaths)
96
+ throw new Error('Wrong number of task input files. Run trazum task --help.');
97
+ if (action === 'analyze') {
98
+ const taskId = required(flags, 'id');
99
+ const taskType = required(flags, 'type');
100
+ const criterion = required(flags, 'criterion');
101
+ if (sources.length === 0)
102
+ throw new Error('Provide at least one --claude-code or --codex file.');
103
+ const contents = [];
104
+ let total = 0;
105
+ for (const source of sources) {
106
+ const text = await readTaskText(source.path, MAX_INPUT_CHARS - total);
107
+ total += text.length;
108
+ contents.push({ format: source.format, text });
109
+ }
110
+ const report = analyzeTask({ taskId, taskType, criterion, sources: contents,
111
+ ...(flags.has('outcome') ? { outcome: flags.get('outcome') } : {}),
112
+ ...(flags.has('assessor') ? { assessor: flags.get('assessor') } : {}),
113
+ ...(flags.has('policy') ? { policyId: flags.get('policy') } : {}),
114
+ });
115
+ await emit(report, flags.get('out'));
116
+ }
117
+ else if (action === 'compare') {
118
+ const before = parseTaskReport(await readTaskText(paths[0]));
119
+ const after = parseTaskReport(await readTaskText(paths[1]));
120
+ await emit(compareTasks(before, after), flags.get('out'));
121
+ }
122
+ else if (action === 'policy' || action === 'apply') {
123
+ const report = parseTaskReport(await readTaskText(paths[0]));
124
+ const policy = taskPolicy(report);
125
+ if (action === 'policy')
126
+ await emit(policy.instructions, flags.get('out'));
127
+ else {
128
+ const changed = await changeTaskInstructions(required(flags, 'instructions'), 'apply');
129
+ await emit({ version: 1, kind: 'trazum-task-policy', policyId: policy.id, applied: true, changed });
130
+ }
131
+ }
132
+ else if (action === 'revert') {
133
+ const changed = await changeTaskInstructions(required(flags, 'instructions'), 'revert');
134
+ await emit({ version: 1, kind: 'trazum-task-policy', policyId: 'repeat-review-v1', applied: false, changed });
135
+ }
136
+ }
137
+ //# sourceMappingURL=task.js.map
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C,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,QAAQ;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;aACtE,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;YACvF,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACtG,CAAC;IACH,CAAC;SAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,QAAQ,CAAC,CAAC;QACxF,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAChH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trazum/cli",
3
- "version": "2.5.2",
4
- "description": "What your AI agents cost, per project, offline: prices Claude Code sessions and Anthropic, OpenAI, OpenRouter, OTel and LiteLLM usage, writes the bill as PDF, HTML or CSV, and enforces budgets in CI.",
3
+ "version": "2.7.0",
4
+ "description": "What your AI agents cost, per project, offline: one bill across Claude Code, Codex and Gemini CLI sessions, plus Anthropic, OpenAI, Gemini, OpenRouter, OTel and LiteLLM usage, written as PDF, HTML or CSV, with budgets enforced in CI.",
5
5
  "license": "MIT",
6
6
  "author": "David Mu\u00f1oz Rey",
7
7
  "repository": {
@@ -15,9 +15,12 @@
15
15
  },
16
16
  "keywords": [
17
17
  "claude-code",
18
+ "codex",
19
+ "gemini-cli",
18
20
  "claude",
19
21
  "anthropic",
20
22
  "openai",
23
+ "gemini",
21
24
  "llm",
22
25
  "ai-agents",
23
26
  "cost",
@@ -50,10 +53,10 @@
50
53
  "prepublishOnly": "npm run build && npm test"
51
54
  },
52
55
  "dependencies": {
53
- "@trazum/core": "2.5.2"
56
+ "@trazum/core": "2.7.0"
54
57
  },
55
58
  "devDependencies": {
56
- "@types/node": "^26.6.3",
59
+ "@types/node": "^26.6.6",
57
60
  "typescript": "^7.0.2"
58
61
  },
59
62
  "engines": {
package/src/filter.ts CHANGED
@@ -4,11 +4,11 @@ import { mkdir, lstat, open } from 'node:fs/promises';
4
4
  import { createHash } from 'node:crypto';
5
5
  import { resolve, join } from 'node:path';
6
6
  import { once } from 'node:events';
7
- import { compactToolOutput, EFFICIENT_OUTPUT_INSTRUCTIONS } from '@trazum/core';
7
+ import { compactToolOutput, EFFICIENT_OUTPUT_INSTRUCTIONS, type ToolOutputView } from '@trazum/core';
8
8
 
9
9
  const MAX_BYTES = 1024 * 1024;
10
10
  const HELP = `Usage:
11
- trazum filter compact --recovery-dir <private-directory> read a tool log from stdin
11
+ trazum filter compact --recovery-dir <private-directory> [--stats]
12
12
  trazum filter restore <sha256> --recovery-dir <private-directory>
13
13
  trazum filter instructions print optional output guidance
14
14
 
@@ -18,8 +18,25 @@ Use Bash pipefail to preserve the producing command's failure status.
18
18
  Original logs may contain sensitive data: --recovery-dir explicitly opts into local
19
19
  retention. Delete that directory when the originals are no longer needed.
20
20
  Token counts are estimates, not billing or subscription-quota measurements.
21
+ --stats writes one JSON record to stderr, without log content or recovery paths.
21
22
  `;
22
23
 
24
+ /** Report only the view actually emitted, including recovery-instruction overhead. */
25
+ function reportStats(inputBytes: number, outputBytes: number, view: ToolOutputView | null,
26
+ reason: string, applied = false): void {
27
+ const before = view?.estimatedTokensBefore ?? null;
28
+ const after = applied ? view?.estimatedTokensAfter ?? null : before;
29
+ const saved = before === null || after === null ? null : before - after;
30
+ process.stderr.write(`${JSON.stringify({
31
+ schemaVersion: 1, kind: 'trazum-tool-filter', estimateOnly: true, applied, reason,
32
+ inputBytes, outputBytes, estimatedTokensBefore: before, estimatedTokensAfter: after,
33
+ estimatedTokensSaved: saved,
34
+ estimatedReductionPercent: saved === null || before === null ? null
35
+ : before === 0 ? 0 : Math.round(saved / before * 10000) / 100,
36
+ repeatedLines: applied ? view?.repeatedLines ?? 0 : 0,
37
+ })}\n`);
38
+ }
39
+
23
40
  const digest = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex');
24
41
  const quote = (text: string) => `'${text.replaceAll("'", "'\\''")}'`;
25
42
  async function emit(bytes: Buffer | string): Promise<void> {
@@ -34,7 +51,8 @@ async function privateDirectory(path: string, create: boolean): Promise<void> {
34
51
  }
35
52
  }
36
53
  async function readOriginal(store: string, key: string): Promise<Buffer> {
37
- const file = await open(join(store, `${key}.log`), constants.O_RDONLY | constants.O_NOFOLLOW);
54
+ // Opening a FIFO must not block before the regular-file check can reject it.
55
+ const file = await open(join(store, `${key}.log`), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
38
56
  try {
39
57
  const stat = await file.stat();
40
58
  if (!stat.isFile() || stat.size > MAX_BYTES) throw new Error('Invalid recovery file.');
@@ -56,14 +74,14 @@ async function saveOriginal(store: string, key: string, bytes: Buffer): Promise<
56
74
  try { await file.writeFile(bytes); await file.sync(); }
57
75
  finally { await file.close(); }
58
76
  }
59
- async function compact(store: string): Promise<void> {
77
+ async function compact(store: string, stats: boolean): Promise<void> {
60
78
  const chunks: Buffer[] = [];
61
79
  let size = 0;
62
80
  let passthrough = false;
63
81
  for await (const value of process.stdin) {
64
82
  const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
65
- if (passthrough) { await emit(chunk); continue; }
66
83
  size += chunk.length;
84
+ if (passthrough) { await emit(chunk); continue; }
67
85
  if (size > MAX_BYTES) {
68
86
  passthrough = true;
69
87
  for (const buffered of chunks) await emit(buffered);
@@ -71,24 +89,42 @@ async function compact(store: string): Promise<void> {
71
89
  await emit(chunk);
72
90
  } else { chunks.push(chunk); }
73
91
  }
74
- if (passthrough) return;
92
+ if (passthrough) {
93
+ if (stats) reportStats(size, size, null, 'stream-limit');
94
+ return;
95
+ }
75
96
  const bytes = Buffer.concat(chunks);
76
97
  const input = bytes.toString('utf8');
77
98
  // Invalid UTF-8 must pass byte-for-byte rather than acquire replacement chars.
78
- if (!Buffer.from(input).equals(bytes)) { await emit(bytes); return; }
99
+ if (!Buffer.from(input).equals(bytes)) {
100
+ await emit(bytes);
101
+ if (stats) reportStats(size, size, null, 'invalid-utf8');
102
+ return;
103
+ }
79
104
  const key = digest(bytes);
80
105
  const view = compactToolOutput(input, `trazum filter restore ${key} --recovery-dir ${quote(store)}`);
81
- if (!view.applied) { await emit(bytes); return; }
106
+ if (!view.applied) {
107
+ await emit(bytes);
108
+ if (stats) reportStats(size, size, view, view.reason);
109
+ return;
110
+ }
82
111
  try { await saveOriginal(store, key, bytes); }
83
112
  catch {
84
113
  // A filter must not swallow a tool's output because local persistence failed.
85
- process.stderr.write('Trazum: original could not be retained; passing log through unchanged.\n');
114
+ if (!stats) process.stderr.write('Trazum: original could not be retained; passing log through unchanged.\n');
86
115
  await emit(bytes);
116
+ if (stats) reportStats(size, size, view, 'storage-failed');
87
117
  return;
88
118
  }
89
119
  await emit(view.text);
120
+ if (stats) reportStats(size, Buffer.byteLength(view.text), view, view.reason, true);
90
121
  }
91
122
  export async function runFilter(args: string[]): Promise<void> {
123
+ let stats = false;
124
+ if (args[0] === 'compact' && args.length === 4) {
125
+ const index = args[1] === '--stats' ? 1 : args[3] === '--stats' ? 3 : -1;
126
+ if (index !== -1) { stats = true; args = args.filter((_, i) => i !== index); }
127
+ }
92
128
  if (args.length === 0 || (args.length === 1 && ['--help', '-h'].includes(args[0]!))) {
93
129
  await emit(HELP); return;
94
130
  }
@@ -109,6 +145,6 @@ export async function runFilter(args: string[]): Promise<void> {
109
145
  await emit(await readOriginal(store, key));
110
146
  } else {
111
147
  if (process.stdin.isTTY) throw new Error('Pipe a tool log into stdin; interactive tools are not supported.');
112
- await compact(store);
148
+ await compact(store, stats);
113
149
  }
114
150
  }
package/src/i18n/en.ts CHANGED
@@ -30,7 +30,13 @@ export const en: CliMessages = {
30
30
  locale: 'en',
31
31
  numberLocale: 'en-US',
32
32
 
33
- help: (d, bold) => `${bold('trazum')}, cut the cost of your prompts without losing what they ask for.
33
+ help: (d, bold) => `${bold('trazum')}, what your AI agents and API calls cost, read from logs on this machine.
34
+
35
+ ${bold('START HERE')}
36
+ trazum bill Every Claude Code, Codex and Gemini CLI session on
37
+ this machine, by agent, project and model
38
+ trazum bill <log|dir> Any usage log or provider export it recognises
39
+ trazum bill --by month The same bill, month by month (or day, week)
34
40
 
35
41
  ${bold('USAGE')}
36
42
  trazum init [dir] [--dry-run | --yes]
@@ -61,9 +67,10 @@ ${bold('USAGE')}
61
67
  trazum position <usage.jsonl>
62
68
  trazum receipt <usage.jsonl|dir> [--stamp] [--since <when>] [--until <when>] [-o <file>]
63
69
  trazum bill [<file|dir>...] [--label <name>] [--no-label-from-project] [--receipt|--table] [--stamp] [-o <file>]
64
- [--since <when>] [--until <when>] [--pdf-out|--html-out|--markdown-out|--csv-out <file>]
70
+ [--since <when>] [--until <when>] [--by day|week|month] [--pdf-out|--html-out|--markdown-out|--csv-out <file>]
65
71
  trazum from-claude-code <file|dir> [--label <name>] [-o <file>]
66
72
  trazum from-codex <file|dir> [--label <name>] [-o <file>]
73
+ trazum from-gemini-cli <file|dir> [--label <name>] [-o <file>]
67
74
  trazum from-otel <file|dir> [--label-from-service] [-o <file>]
68
75
  trazum from-litellm <file|dir> [-o <file>]
69
76
  trazum from-anthropic <usage.json> [--label <name>] [--label-by-workspace <file>] [-o <file>]
@@ -89,6 +96,7 @@ ${bold('USAGE')}
89
96
  trazum ladder <log>
90
97
  trazum feedback
91
98
  trazum filter compact|restore|instructions [--recovery-dir <directory>]
99
+ trazum task analyze|policy|apply|revert|compare [--help]
92
100
  trazum --version
93
101
 
94
102
  ${bold('OPTIONS FOR init')}
@@ -234,11 +242,19 @@ ${bold('OPTIONS FOR bill')}
234
242
  means the whole of it. Calls with no timestamp
235
243
  cannot be placed and are left out, counted on
236
244
  the receipt as a gap, never dropped silently.
245
+ --by <day|week|month> Split the statement by UTC day, ISO week (Monday
246
+ to Sunday) or month. Without it, a bill spanning
247
+ two months or more is split by month.
237
248
  --stamp Stamp the receipt with the time it was written.
238
249
  -o, --out <file> Write the receipt there instead of stdout.
239
250
 
251
+ With no path, reads every coding agent's own session folders it finds:
252
+ Claude Code (~/.claude/projects), Codex ($CODEX_HOME/sessions and
253
+ archived_sessions) and Gemini CLI (~/.gemini/tmp/*/chats), each named on
254
+ stderr, and adds a By agent table once more than one spent money.
255
+
240
256
  One door. Reads a file or a directory, tells each file's shape from its own
241
- text - a Claude Code transcript, OTel spans, a LiteLLM, Helicone or LangSmith
257
+ text - a Claude Code, Codex or Gemini CLI session, OTel spans, a LiteLLM, Helicone or LangSmith
242
258
  export, an Anthropic, OpenAI or OpenRouter report, or a plain usage log -
243
259
  converts it with the same converter the dedicated command uses, prices it,
244
260
  and ends on the receipt. A file no shape claims is named, not guessed; a
@@ -316,6 +332,17 @@ ${bold('OPTIONS FOR from-codex')}
316
332
  Conversion gaps are reported on stderr. Prices are API equivalents,
317
333
  never your subscription invoice. Prompt content is discarded.
318
334
 
335
+ ${bold('OPTIONS FOR from-gemini-cli')}
336
+ --label <name> Stamp every record with one label.
337
+ -o, --out <file> Write normalized usage instead of stdout.
338
+
339
+ Read Gemini CLI session files (~/.gemini/tmp/<project>/chats, .jsonl, and
340
+ the older single-document .json), locally. One record per reply that
341
+ carried token counts; a reply the recorder rewrote is read once. Reasoning
342
+ tokens are priced as output and tool results fed back as input, as Google
343
+ bills them. Prices are API equivalents, not a free-tier or plan invoice.
344
+ Prompts, replies, thoughts and tool content are discarded.
345
+
319
346
  ${bold('OPTIONS FOR from-claude-code')}
320
347
  --label <name> Stamp every record with one label.
321
348
  --label-from-project Label each record with its transcript's project
@@ -428,8 +455,23 @@ ${bold('OPTIONS FOR rules')}
428
455
  "Inert" is always said about the corpus. A rule that finds nothing in these
429
456
  files has not been shown to find nothing anywhere.
430
457
 
458
+ ${bold('OPTIONS FOR task')}
459
+ --id <id> --type <type> Identify a task and its comparable task type.
460
+ --criterion <text> Declare the acceptance criterion before a change.
461
+ --claude-code <file> Add an explicit Claude Code task transcript; repeatable.
462
+ --codex <file> Add an explicit Codex task transcript; repeatable.
463
+ --outcome <value> accepted, rejected or unknown (default unknown).
464
+ --assessor <label> Required for a declared accepted or rejected outcome.
465
+ --policy <id> baseline (default) or repeat-review-v1.
466
+ --instructions <file> Existing local instruction file for apply or revert.
467
+ -o, --out <new-file> Create a private report or policy; never overwrite.
468
+ --json Reports and comparisons are already JSON by default.
469
+ Run task --help for analyze, policy, apply, revert and compare syntax.
470
+ Sources total at most 400,000 characters. Task success is never inferred.
471
+
431
472
  ${bold('OPTIONS FOR filter')}
432
473
  --recovery-dir <directory> Private recovery directory; required for compact/restore.
474
+ --stats Compact only: emit net estimated savings as JSON on stderr.
433
475
  Run trazum filter --help for the opt-in stdin log-filter workflow.
434
476
 
435
477
  ${bold('OPTIONS FOR feedback')}
@@ -1918,6 +1960,22 @@ ${bold('EXAMPLES')}
1918
1960
  written: (file) => `Wrote normalized usage to ${file}`,
1919
1961
  },
1920
1962
 
1963
+ fromGeminiCli: {
1964
+ noPath: () => 'from-gemini-cli needs a session file or a directory: trazum from-gemini-cli ~/.gemini/tmp',
1965
+ notFound: (path) => `Cannot read ${path}`,
1966
+ noFiles: (path) => `No Gemini CLI session files (.jsonl or .json) in ${path}`,
1967
+ noUsage: () => 'No Gemini CLI reply carried token counts. Inspect the named gaps; no zero-cost log was written.',
1968
+ summary: (files, records, repeats) =>
1969
+ `${files} Gemini CLI file(s), ${records} reply record(s) with token counts, ${repeats} rewritten line(s) read once.`,
1970
+ gaps: (missingModel, unsupported, unparseable) =>
1971
+ `Gemini CLI gaps: ${missingModel} reply(ies) without a model, ${unsupported} with impossible token counts, ${unparseable} unreadable line(s). These are not zero-cost calls.`,
1972
+ remainder: (replies) =>
1973
+ `${replies} Gemini CLI reply(ies) from an older recorder kept a total larger than its parts; the remainder is priced as output, the dearer side, rather than dropped.`,
1974
+ caveat: () =>
1975
+ 'Gemini CLI sessions are priced at catalogue API rates. On a free tier or a Code Assist plan that is an equivalent, not what you paid. Reasoning tokens are priced as output and tool results fed back as input, as Google bills them.',
1976
+ written: (file) => `Wrote normalized usage to ${file}`,
1977
+ },
1978
+
1921
1979
  fromOtel: {
1922
1980
  noPath: () => 'from-otel needs an OTLP file or directory: trazum from-otel spans.json',
1923
1981
  notFound: (path) => `${path}: not found`,
@@ -2042,10 +2100,10 @@ ${bold('EXAMPLES')}
2042
2100
 
2043
2101
  bill: {
2044
2102
  noPath: (tried) =>
2045
- `bill needs a file or a directory to read, and found no Claude Code folder at ${tried}. Name one: trazum bill ~/.claude/projects, or trazum bill usage.jsonl.`,
2046
- defaultPath: (dirs) => `No path given, so reading Claude Code's own folder: ${dirs}`,
2103
+ `bill needs a file or a directory to read, and found no Claude Code, Codex or Gemini CLI sessions at ${tried}. Name one: trazum bill ~/.claude/projects, or trazum bill usage.jsonl.`,
2104
+ defaultPathFor: (agent, dir) => `No path given, so reading ${agent}'s own folder: ${dir}`,
2047
2105
  labelledByProject: (files) =>
2048
- `${files} Claude Code transcript(s) labelled by their project folder. --label sets one label instead, --no-label-from-project leaves them unlabelled.`,
2106
+ `${files} session file(s) labelled by their project folder. --label sets one label instead, --no-label-from-project leaves them unlabelled.`,
2049
2107
  unknownMore: (count) => `${count} more file(s) no shape claims, not guessed at and not in the bill.`,
2050
2108
  shapeSummary: (shape, files, records, leftOut) =>
2051
2109
  `${files} file(s): ${shape}${records === null ? ', read as they are' : `, ${records} record(s)`}${leftOut > 0 ? `, ${leftOut} row(s) left out. trazum from-${shape} on a file says why.` : '.'}`,
@@ -2054,6 +2112,13 @@ ${bold('EXAMPLES')}
2054
2112
  colProject: () => 'project',
2055
2113
  colWorkload: () => 'workload',
2056
2114
  colModel: () => 'model',
2115
+ colAgent: () => 'agent',
2116
+ colPeriod: (unit) => unit,
2117
+ earlierPeriods: (count, unit) => `… and ${count} earlier ${unit}(s)`,
2118
+ periodsUndated: (calls, usd, unit) =>
2119
+ `${usd} from ${calls} call(s) with no timestamp is in the total and in no ${unit}.`,
2120
+ periodHint: (since, until, unit) => `One ${unit} on its own: --since ${since} --until ${until}.`,
2121
+ badBy: (value) => `--by takes day, week or month, not "${value}".`,
2057
2122
  colCalls: () => 'calls',
2058
2123
  colShare: () => 'share',
2059
2124
  moreRows: (count) => `… and ${count} more`,
@@ -2082,7 +2147,7 @@ ${bold('EXAMPLES')}
2082
2147
  pricingLiveHint: (count) =>
2083
2148
  `${count} unpriced model id(s) carry a provider prefix, the way OpenRouter and LiteLLM name models, and the bundled catalogue does not carry those. Run again with --pricing-live to price OpenRouter's slugs from its own list.`,
2084
2149
  apiEquivalent: () =>
2085
- 'Claude Code and Codex transcripts are priced at catalogue API rates. On a subscription you paid the plan, not this API-equivalent estimate; missing telemetry and custom rates can change the result.',
2150
+ 'Agent sessions (Claude Code, Codex, Gemini CLI) are priced at catalogue API rates. On a subscription you paid the plan, not this API-equivalent estimate; missing telemetry and custom rates can change the result.',
2086
2151
  prefixedKnown: (ids) =>
2087
2152
  `${ids}: the model after the slash is priced here under its own name. The prefix is not stripped for you, because the same model through a router can bill differently. If those calls went straight to the provider, log the model without the prefix.`,
2088
2153
  windowMatchesNothing: (from, to) =>
package/src/i18n/es.ts CHANGED
@@ -17,7 +17,13 @@ export const es: CliMessages = {
17
17
  locale: 'es',
18
18
  numberLocale: 'es-ES',
19
19
 
20
- help: (d, bold) => `${bold('trazum')}: reduce el coste de tus prompts sin perder lo que piden.
20
+ help: (d, bold) => `${bold('trazum')}: lo que cuestan tus agentes de IA y tus llamadas a la API, leído de los logs de esta máquina.
21
+
22
+ ${bold('EMPIEZA AQUÍ')}
23
+ trazum bill Cada sesión de Claude Code, Codex y Gemini CLI de
24
+ esta máquina, por agente, proyecto y modelo
25
+ trazum bill <log|dir> Cualquier log de uso o export de proveedor que reconozca
26
+ trazum bill --by month La misma factura, mes a mes (o día, semana)
21
27
 
22
28
  ${bold('USO')}
23
29
  trazum init [dir] [--dry-run | --yes]
@@ -48,9 +54,10 @@ ${bold('USO')}
48
54
  trazum position <uso.jsonl>
49
55
  trazum receipt <uso.jsonl|dir> [--stamp] [--since <cuándo>] [--until <cuándo>] [-o <fichero>]
50
56
  trazum bill [<fichero|dir>...] [--label <nombre>] [--no-label-from-project] [--receipt|--table] [--stamp] [-o <fichero>]
51
- [--since <cuándo>] [--until <cuándo>] [--pdf-out|--html-out|--markdown-out|--csv-out <fichero>]
57
+ [--since <cuándo>] [--until <cuándo>] [--by day|week|month] [--pdf-out|--html-out|--markdown-out|--csv-out <fichero>]
52
58
  trazum from-claude-code <fichero|dir> [--label <nombre>] [-o <fichero>]
53
59
  trazum from-codex <fichero|dir> [--label <nombre>] [-o <fichero>]
60
+ trazum from-gemini-cli <fichero|dir> [--label <nombre>] [-o <fichero>]
54
61
  trazum from-otel <fichero|dir> [--label-from-service] [-o <fichero>]
55
62
  trazum from-litellm <fichero|dir> [-o <fichero>]
56
63
  trazum from-anthropic <usage.json> [--label <name>] [--label-by-workspace <file>] [-o <file>]
@@ -76,6 +83,7 @@ ${bold('USO')}
76
83
  trazum ladder <log>
77
84
  trazum feedback
78
85
  trazum filter compact|restore|instructions [--recovery-dir <directory>]
86
+ trazum task analyze|policy|apply|revert|compare [--help]
79
87
  trazum --version
80
88
 
81
89
  ${bold('OPCIONES DE init')}
@@ -266,11 +274,19 @@ ${bold('OPCIONES DE bill')}
266
274
  marca de tiempo no se pueden situar y quedan
267
275
  fuera, contadas en el recibo como hueco, nunca
268
276
  tiradas en silencio.
277
+ --by <day|week|month> Reparte el extracto por día UTC, semana ISO (de
278
+ lunes a domingo) o mes. Sin él, una factura que
279
+ abarca dos meses o más se reparte por mes.
269
280
  --stamp Sella el recibo con la hora en que se escribió.
270
281
  -o, --out <archivo> Escribe el recibo ahí en vez de en stdout.
271
282
 
283
+ Sin ruta, lee las carpetas de sesiones de cada agente que encuentra:
284
+ Claude Code (~/.claude/projects), Codex ($CODEX_HOME/sessions y
285
+ archived_sessions) y Gemini CLI (~/.gemini/tmp/*/chats), cada una nombrada
286
+ en stderr, y añade una tabla por agente cuando gastó más de uno.
287
+
272
288
  Una sola puerta. Lee un archivo o un directorio, reconoce la forma de cada
273
- archivo por su propio texto - una transcripción de Claude Code, spans OTel,
289
+ archivo por su propio texto - una sesión de Claude Code, Codex o Gemini CLI, spans OTel,
274
290
  un export de LiteLLM, Helicone o LangSmith, un informe de Anthropic, OpenAI
275
291
  u OpenRouter, o un log de uso plano - lo convierte con el mismo conversor
276
292
  que usa el comando dedicado, lo cobra y termina en el recibo. Un archivo
@@ -355,6 +371,18 @@ ${bold('OPCIONES DE from-codex')}
355
371
  Los huecos se indican en stderr. Los precios son equivalentes API,
356
372
  nunca tu factura de suscripción. El contenido de prompts se descarta.
357
373
 
374
+ ${bold('OPCIONES DE from-gemini-cli')}
375
+ --label <nombre> Marca cada registro con una etiqueta.
376
+ -o, --out <fichero> Escribe el uso normalizado en vez de stdout.
377
+
378
+ Lee archivos de sesión de Gemini CLI (~/.gemini/tmp/<proyecto>/chats, .jsonl,
379
+ y el .json antiguo de un solo documento), en local. Un registro por
380
+ respuesta que traía tokens; una respuesta reescrita se lee una vez. Los
381
+ tokens de razonamiento se valoran como salida y los resultados de
382
+ herramientas como entrada, como los factura Google. Los precios son
383
+ equivalentes API, no la factura de un nivel gratuito o un plan. Prompts,
384
+ respuestas, razonamientos y contenido de herramientas se descartan.
385
+
358
386
  ${bold('OPCIONES DE from-claude-code')}
359
387
  --label <nombre> Marca cada registro con una etiqueta.
360
388
  --label-from-project Etiqueta cada registro con el nombre del
@@ -432,8 +460,23 @@ ${bold('OPCIONES DE rules')}
432
460
  "Inerte" se dice siempre sobre el corpus. Una regla que no encuentra nada en
433
461
  estos ficheros no ha demostrado no encontrar nada en ninguna parte.
434
462
 
463
+ ${bold('OPCIONES DE task')}
464
+ --id <id> --type <tipo> Identifica una tarea y su tipo comparable.
465
+ --criterion <texto> Declara el criterio de aceptación antes del cambio.
466
+ --claude-code <archivo> Añade una sesión explícita de Claude Code; repetible.
467
+ --codex <archivo> Añade una sesión explícita de Codex; repetible.
468
+ --outcome <valor> accepted, rejected o unknown (por defecto unknown).
469
+ --assessor <etiqueta> Obligatorio para un resultado accepted o rejected.
470
+ --policy <id> baseline (por defecto) o repeat-review-v1.
471
+ --instructions <archivo> Archivo local existente para apply o revert.
472
+ -o, --out <archivo-nuevo> Crea un informe o política privados; no sobrescribe.
473
+ --json Los informes y comparaciones ya usan JSON por defecto.
474
+ Consulta task --help para analyze, policy, apply, revert y compare.
475
+ Máximo 400.000 caracteres entre fuentes. Nunca se infiere el éxito de la tarea.
476
+
435
477
  ${bold('OPCIONES DE filter')}
436
478
  --recovery-dir <directorio> Directorio privado; obligatorio para compact/restore.
479
+ --stats Solo compact: emite ahorro neto estimado en JSON por stderr.
437
480
  trazum filter --help explica el filtro opcional (ayuda en inglés).
438
481
 
439
482
  ${bold('OPCIONES DE feedback')}
@@ -1947,6 +1990,22 @@ ${bold('EJEMPLOS')}
1947
1990
  written: (file) => `Registro normalizado escrito en ${file}`,
1948
1991
  },
1949
1992
 
1993
+ fromGeminiCli: {
1994
+ noPath: () => 'from-gemini-cli necesita un archivo de sesión o un directorio: trazum from-gemini-cli ~/.gemini/tmp',
1995
+ notFound: (path) => `No se puede leer ${path}`,
1996
+ noFiles: (path) => `No hay archivos de sesión de Gemini CLI (.jsonl o .json) en ${path}`,
1997
+ noUsage: () => 'Ninguna respuesta de Gemini CLI traía recuento de tokens. Revisa los huecos indicados; no se escribió un registro a coste cero.',
1998
+ summary: (files, records, repeats) =>
1999
+ `${files} archivo(s) de Gemini CLI, ${records} registro(s) de respuesta con tokens, ${repeats} línea(s) reescrita(s) leída(s) una sola vez.`,
2000
+ gaps: (missingModel, unsupported, unparseable) =>
2001
+ `Huecos de Gemini CLI: ${missingModel} respuesta(s) sin modelo, ${unsupported} con recuentos imposibles, ${unparseable} línea(s) ilegible(s). No son llamadas a coste cero.`,
2002
+ remainder: (replies) =>
2003
+ `${replies} respuesta(s) de Gemini CLI de un grabador antiguo guardaban un total mayor que sus partes; el resto se valora como salida, el lado más caro, en vez de descartarse.`,
2004
+ caveat: () =>
2005
+ 'Las sesiones de Gemini CLI se valoran a tarifas API del catálogo. Con el nivel gratuito o un plan de Code Assist es un equivalente, no lo que pagaste. Los tokens de razonamiento se valoran como salida y los resultados de herramientas como entrada, como los factura Google.',
2006
+ written: (file) => `Registro de uso normalizado escrito en ${file}`,
2007
+ },
2008
+
1950
2009
  fromOtel: {
1951
2010
  noPath: () => 'from-otel necesita un archivo o directorio OTLP: trazum from-otel spans.json',
1952
2011
  notFound: (path) => `${path}: no existe`,
@@ -2071,10 +2130,10 @@ ${bold('EJEMPLOS')}
2071
2130
 
2072
2131
  bill: {
2073
2132
  noPath: (tried) =>
2074
- `bill necesita un archivo o un directorio que leer, y no encontró ninguna carpeta de Claude Code en ${tried}. Indica una: trazum bill ~/.claude/projects, o trazum bill uso.jsonl.`,
2075
- defaultPath: (dirs) => `Sin ruta, así que leo la carpeta propia de Claude Code: ${dirs}`,
2133
+ `bill necesita un archivo o un directorio que leer, y no encontró sesiones de Claude Code, Codex ni Gemini CLI en ${tried}. Indica una: trazum bill ~/.claude/projects, o trazum bill uso.jsonl.`,
2134
+ defaultPathFor: (agent, dir) => `Sin ruta, así que leo la carpeta propia de ${agent}: ${dir}`,
2076
2135
  labelledByProject: (files) =>
2077
- `${files} transcripción(es) de Claude Code etiquetada(s) por su carpeta de proyecto. --label pone una sola etiqueta, --no-label-from-project las deja sin etiqueta.`,
2136
+ `${files} archivo(s) de sesión etiquetado(s) por su carpeta de proyecto. --label pone una sola etiqueta, --no-label-from-project los deja sin etiqueta.`,
2078
2137
  unknownMore: (count) => `${count} archivo(s) más que ninguna forma reclama, sin adivinar y fuera de la factura.`,
2079
2138
  shapeSummary: (shape, files, records, leftOut) =>
2080
2139
  `${files} archivo(s): ${shape}${records === null ? ', leídos tal cual' : `, ${records} registro(s)`}${leftOut > 0 ? `, ${leftOut} fila(s) fuera. trazum from-${shape} sobre un archivo dice por qué.` : '.'}`,
@@ -2083,6 +2142,15 @@ ${bold('EJEMPLOS')}
2083
2142
  colProject: () => 'proyecto',
2084
2143
  colWorkload: () => 'carga',
2085
2144
  colModel: () => 'modelo',
2145
+ colAgent: () => 'agente',
2146
+ colPeriod: (unit) => (unit === 'day' ? 'día' : unit === 'week' ? 'semana' : 'mes'),
2147
+ earlierPeriods: (count, unit) =>
2148
+ `… y ${count} ${unit === 'day' ? 'día(s)' : unit === 'week' ? 'semana(s)' : 'mes(es)'} anterior(es)`,
2149
+ periodsUndated: (calls, usd, unit) =>
2150
+ `${usd} de ${calls} llamada(s) sin marca de tiempo está en el total y en ${unit === 'day' ? 'ningún día' : unit === 'week' ? 'ninguna semana' : 'ningún mes'}.`,
2151
+ periodHint: (since, until, unit) =>
2152
+ `${unit === 'day' ? 'Un día' : unit === 'week' ? 'Una semana' : 'Un mes'} por separado: --since ${since} --until ${until}.`,
2153
+ badBy: (value) => `--by admite day, week o month, no "${value}".`,
2086
2154
  colCalls: () => 'llamadas',
2087
2155
  colShare: () => 'parte',
2088
2156
  moreRows: (count) => `… y ${count} más`,
@@ -2111,7 +2179,7 @@ ${bold('EJEMPLOS')}
2111
2179
  pricingLiveHint: (count) =>
2112
2180
  `${count} id(s) de modelo sin precio llevan prefijo de proveedor, como nombran los modelos OpenRouter y LiteLLM, y el catálogo incluido no los trae. Vuelve a ejecutar con --pricing-live para cobrar los slugs de OpenRouter desde su propia lista.`,
2113
2181
  apiEquivalent: () =>
2114
- 'Las sesiones de Claude Code y Codex se valoran a tarifas API del catálogo. Si pagas una suscripción, pagaste el plan, no esta estimación equivalente; los datos ausentes y las tarifas propias pueden cambiar el resultado.',
2182
+ 'Las sesiones de agentes (Claude Code, Codex, Gemini CLI) se valoran a tarifas API del catálogo. Si pagas una suscripción, pagaste el plan, no esta estimación equivalente; los datos ausentes y las tarifas propias pueden cambiar el resultado.',
2115
2183
  prefixedKnown: (ids) =>
2116
2184
  `${ids}: el modelo tras la barra tiene precio aquí con su propio nombre. El prefijo no se quita por ti, porque el mismo modelo a través de un router puede facturarse distinto. Si esas llamadas fueron directas al proveedor, registra el modelo sin el prefijo.`,
2117
2185
  windowMatchesNothing: (from, to) =>