@alyibrahim/claude-statusline 1.5.2 → 1.5.3

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/cli.js CHANGED
@@ -13,6 +13,7 @@ claude-statusline <command>
13
13
  Commands:
14
14
  setup Configure ~/.claude/settings.json to use this statusline
15
15
  uninstall Remove this statusline from ~/.claude/settings.json
16
+ download-binary Download the native binary for this platform
16
17
  enable-history Enable tracking session analytics to JSONL (default on setup)
17
18
  disable-history Remove history tracking hooks from Claude settings
18
19
  history Open the session analytics dashboard
@@ -117,6 +118,16 @@ if (cmd === 'setup') {
117
118
  }
118
119
  console.log(`✓ Removed statusline from ${getSettingsPath()}`);
119
120
 
121
+ } else if (cmd === 'download-binary') {
122
+ const { downloadBinary } = require('../scripts/download-binary');
123
+ const result = downloadBinary();
124
+ if (!result.ok) {
125
+ console.error('Error:', result.error);
126
+ process.exit(1);
127
+ }
128
+ console.log(`\n✓ Binary installed at ${result.binaryPath}`);
129
+ console.log(' Run claude-statusline setup to update your settings to use it.\n');
130
+
120
131
  } else if (cmd === 'enable-history') {
121
132
  const result = toggleHistory(true);
122
133
  if (!result.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alyibrahim/claude-statusline",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Rich statusline for Claude Code — model, context bar, real-time token tracking, git branch, rate limits, and session stats. Rust binary, ~5ms startup.",
5
5
  "keywords": [
6
6
  "claude",
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { spawnSync } = require('child_process');
5
+
6
+ const SUPPORTED = ['linux-x64', 'linux-arm64', 'darwin-x64', 'darwin-arm64', 'win32-x64'];
7
+
8
+ function downloadBinary() {
9
+ const platformKey = `${process.platform}-${process.arch}`;
10
+ if (!SUPPORTED.includes(platformKey)) {
11
+ return {
12
+ ok: false,
13
+ error: `No pre-built binary for ${platformKey}. The JS fallback will be used.`
14
+ };
15
+ }
16
+
17
+ const { version } = require('../package.json');
18
+ const packageRoot = path.resolve(__dirname, '..');
19
+ const packageSpec = `@alyibrahim/claude-statusline-${platformKey}@${version}`;
20
+ const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
21
+
22
+ const installResult = spawnSync(npmCmd, ['install', '--no-save', packageSpec], {
23
+ cwd: packageRoot,
24
+ stdio: 'inherit'
25
+ });
26
+
27
+ if (installResult.status !== 0) {
28
+ return {
29
+ ok: false,
30
+ error: `npm install exited with code ${installResult.status}`
31
+ };
32
+ }
33
+
34
+ // Clear cached modules so resolveBinary sees newly installed optional dependency.
35
+ const platformPkg = `claude-statusline-${platformKey}`;
36
+ Object.keys(require.cache).forEach((cacheKey) => {
37
+ if (cacheKey.includes(platformPkg)) {
38
+ delete require.cache[cacheKey];
39
+ }
40
+ });
41
+
42
+ const { resolveBinary } = require('./config');
43
+ const binaryPath = resolveBinary();
44
+ if (!binaryPath) {
45
+ return {
46
+ ok: false,
47
+ error: 'Package installed but binary not found - unexpected layout'
48
+ };
49
+ }
50
+
51
+ if (process.platform !== 'win32') {
52
+ try {
53
+ fs.chmodSync(binaryPath, 0o755);
54
+ } catch (e) {}
55
+ }
56
+
57
+ return { ok: true, binaryPath };
58
+ }
59
+
60
+ module.exports = { downloadBinary };