tokenrace 0.1.5 → 0.1.6

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/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>tokenrace</title>
7
- <script type="module" crossorigin src="/assets/index-BXEI726E.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-18NqIjOk.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-B0dy8dWP.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "tokenrace",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Monitor en tiempo real para Claude Code",
5
5
  "bin": {
6
- "tokenrace": "./bin/cli.js"
6
+ "tokenrace": "bin/cli.js"
7
7
  },
8
8
  "type": "module",
9
9
  "scripts": {
@@ -42,7 +42,7 @@
42
42
  "license": "MIT",
43
43
  "repository": {
44
44
  "type": "git",
45
- "url": "https://github.com/franciscovaleromartin/tokenrace"
45
+ "url": "git+https://github.com/franciscovaleromartin/tokenrace.git"
46
46
  },
47
47
  "homepage": "https://github.com/franciscovaleromartin/tokenrace#readme",
48
48
  "bugs": {
@@ -0,0 +1,38 @@
1
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs'
2
+ import { homedir } from 'node:os'
3
+ import { join } from 'node:path'
4
+
5
+ /**
6
+ * Añade las variables de entorno OTLP al archivo rc de la shell
7
+ * si no están ya presentes.
8
+ *
9
+ * @param {number} port - Puerto en el que corre tokenrace
10
+ * @param {string} [rcPathOverride] - Ruta override para tests
11
+ * @returns {{ added: boolean, rcPath: string }}
12
+ */
13
+ export function ensureEnvVars(port, rcPathOverride) {
14
+ const shell = process.env.SHELL ?? ''
15
+ const defaultRc = shell.includes('zsh')
16
+ ? join(homedir(), '.zshrc')
17
+ : join(homedir(), '.bashrc')
18
+ const rcPath = rcPathOverride ?? defaultRc
19
+
20
+ const marker = 'CLAUDE_CODE_ENABLE_TELEMETRY'
21
+ const existing = existsSync(rcPath) ? readFileSync(rcPath, 'utf8') : ''
22
+
23
+ if (existing.includes(marker)) {
24
+ return { added: false, rcPath }
25
+ }
26
+
27
+ const block = `
28
+ # tokenrace — telemetría Claude Code
29
+ export CLAUDE_CODE_ENABLE_TELEMETRY=1
30
+ export OTEL_METRICS_EXPORTER=otlp
31
+ export OTEL_LOGS_EXPORTER=otlp
32
+ export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
33
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:${port}
34
+ export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
35
+ `
36
+ writeFileSync(rcPath, existing + block, 'utf8')
37
+ return { added: true, rcPath }
38
+ }