toktrack 1.1.2 → 1.2.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/bin/run.js CHANGED
@@ -1,26 +1,47 @@
1
1
  #!/usr/bin/env node
2
2
  const { execFileSync } = require('child_process');
3
+ const fs = require('fs');
3
4
  const path = require('path');
4
5
  const os = require('os');
5
6
 
6
7
  const platform = os.platform();
7
8
  const arch = os.arch();
8
9
 
10
+ function isMusl() {
11
+ if (platform !== 'linux') return false;
12
+ try {
13
+ // Check for musl dynamic linker
14
+ const files = fs.readdirSync('/lib');
15
+ if (files.some(f => f.startsWith('ld-musl-'))) return true;
16
+ } catch {}
17
+ try {
18
+ const lddOutput = execFileSync('ldd', ['--version'], { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] });
19
+ if (lddOutput.toLowerCase().includes('musl')) return true;
20
+ } catch (e) {
21
+ // ldd --version writes to stderr on musl systems
22
+ if (e.stderr && e.stderr.toString().toLowerCase().includes('musl')) return true;
23
+ }
24
+ return false;
25
+ }
26
+
9
27
  // Platform mapping to binary names
10
28
  const platformMap = {
11
29
  'darwin-arm64': 'toktrack-darwin-arm64',
12
30
  'darwin-x64': 'toktrack-darwin-x64',
13
31
  'linux-x64': 'toktrack-linux-x64',
14
32
  'linux-arm64': 'toktrack-linux-arm64',
33
+ 'linux-musl-x64': 'toktrack-linux-musl-x64',
34
+ 'linux-musl-arm64': 'toktrack-linux-musl-arm64',
15
35
  'win32-x64': 'toktrack-win32-x64.exe',
16
36
  };
17
37
 
18
- const key = `${platform}-${arch}`;
38
+ const libc = isMusl() ? 'musl-' : '';
39
+ const key = `${platform}-${libc}${arch}`;
19
40
  const binaryName = platformMap[key];
20
41
 
21
42
  if (!binaryName) {
22
- console.error(`Unsupported platform: ${platform}-${arch}`);
23
- console.error('Supported platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64, win32-x64');
43
+ console.error(`Unsupported platform: ${key}`);
44
+ console.error('Supported platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64, linux-musl-x64, linux-musl-arm64, win32-x64');
24
45
  process.exit(1);
25
46
  }
26
47
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toktrack",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Ultra-fast token & cost tracker for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "bin": {
6
6
  "toktrack": "./bin/run.js"