labs-claude 0.8.0 → 0.8.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 +1 -1
- package/src/statusline.js +69 -12
package/package.json
CHANGED
package/src/statusline.js
CHANGED
|
@@ -1,39 +1,96 @@
|
|
|
1
|
-
// Installs
|
|
1
|
+
// Installs an 11/10 LABS Signature Powerbar statusline (`~/.labs/statusline.js`) into `~/.claude/settings.json`.
|
|
2
|
+
// Theme-synced with `labs dash`, shows: LABS badge · Qwen4-35B-A3B · folder/git · live context gauge bar · clock.
|
|
2
3
|
const fs = require('fs');
|
|
3
4
|
const os = require('os');
|
|
4
5
|
const path = require('path');
|
|
5
6
|
const { LABS_DIR } = require('./config');
|
|
6
7
|
|
|
7
8
|
const STATUSLINE_SCRIPT = `#!/usr/bin/env node
|
|
8
|
-
//
|
|
9
|
+
// LABS Signature Powerbar for Claude Code (theme-synced with labs dash)
|
|
9
10
|
const { execSync } = require('child_process');
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const os = require('os');
|
|
10
13
|
const path = require('path');
|
|
11
14
|
|
|
15
|
+
const THEMES = {
|
|
16
|
+
ocean: [[56, 189, 248], [52, 211, 153]],
|
|
17
|
+
sunset: [[251, 191, 36], [251, 113, 133]],
|
|
18
|
+
cyber: [[167, 139, 250], [56, 189, 248]],
|
|
19
|
+
emerald: [[52, 211, 153], [163, 230, 53]],
|
|
20
|
+
mono: [[248, 250, 252], [148, 163, 184]],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getTheme() {
|
|
24
|
+
try {
|
|
25
|
+
const p = path.join(os.homedir(), '.labs', 'config.json');
|
|
26
|
+
if (fs.existsSync(p)) {
|
|
27
|
+
const name = JSON.parse(fs.readFileSync(p, 'utf8')).theme;
|
|
28
|
+
if (THEMES[name]) return THEMES[name];
|
|
29
|
+
}
|
|
30
|
+
} catch {}
|
|
31
|
+
return THEMES.ocean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function grad(text, from, to) {
|
|
35
|
+
const chars = [...text];
|
|
36
|
+
const len = Math.max(1, chars.length - 1);
|
|
37
|
+
return chars.map((ch, i) => {
|
|
38
|
+
const t = i / len;
|
|
39
|
+
const r = Math.round(from[0] + (to[0] - from[0]) * t);
|
|
40
|
+
const g = Math.round(from[1] + (to[1] - from[1]) * t);
|
|
41
|
+
const b = Math.round(from[2] + (to[2] - from[2]) * t);
|
|
42
|
+
return \`\\x1b[1;38;2;\${r};\${g};\${b}m\${ch}\`;
|
|
43
|
+
}).join('') + '\\x1b[0m';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const rgb = (r, g, b, s) => \`\\x1b[38;2;\${r};\${g};\${b}m\${s}\\x1b[0m\`;
|
|
47
|
+
const dim = s => \`\\x1b[2m\${s}\\x1b[0m\`;
|
|
48
|
+
|
|
12
49
|
let raw = '';
|
|
13
50
|
process.stdin.setEncoding('utf8');
|
|
14
51
|
process.stdin.on('data', d => { raw += d; });
|
|
15
52
|
process.stdin.on('end', () => {
|
|
16
53
|
let data = {};
|
|
17
54
|
try { data = JSON.parse(raw || '{}'); } catch {}
|
|
18
|
-
const
|
|
55
|
+
const [from, to] = getTheme();
|
|
56
|
+
|
|
57
|
+
const rawModel = data.model?.display_name || data.model?.id || 'qwen-normal';
|
|
58
|
+
const model = /qwen/i.test(rawModel)
|
|
59
|
+
? (rawModel.includes('uncensored') ? 'Qwen4-35B (uncensored)' : 'Qwen4-35B-A3B')
|
|
60
|
+
: rawModel;
|
|
61
|
+
|
|
19
62
|
const cwd = data.workspace?.current_dir || process.cwd();
|
|
20
63
|
const folder = path.basename(cwd);
|
|
21
|
-
|
|
64
|
+
|
|
22
65
|
let branch = '';
|
|
66
|
+
let dirty = false;
|
|
23
67
|
try {
|
|
24
|
-
branch = execSync('git rev-parse --abbrev-ref HEAD', { cwd, stdio: ['ignore', 'pipe', 'ignore'], timeout:
|
|
68
|
+
branch = execSync('git rev-parse --abbrev-ref HEAD', { cwd, stdio: ['ignore', 'pipe', 'ignore'], timeout: 350 }).toString().trim();
|
|
69
|
+
const st = execSync('git status --porcelain', { cwd, stdio: ['ignore', 'pipe', 'ignore'], timeout: 350 }).toString().trim();
|
|
70
|
+
dirty = Boolean(st);
|
|
25
71
|
} catch {}
|
|
26
|
-
|
|
72
|
+
|
|
73
|
+
const pct = data.context_window?.used_percentage;
|
|
74
|
+
const sep = dim(' · ');
|
|
27
75
|
const parts = [
|
|
28
|
-
|
|
29
|
-
|
|
76
|
+
grad('✦ LABS', from, to),
|
|
77
|
+
rgb(from[0], from[1], from[2], model),
|
|
78
|
+
rgb(248, 250, 252, folder) + (branch ? ' ' + rgb(167, 139, 250, branch) + (dirty ? rgb(251, 191, 36, ' ●') : '') : ''),
|
|
30
79
|
];
|
|
31
|
-
|
|
80
|
+
|
|
32
81
|
if (pct != null) {
|
|
33
|
-
const
|
|
34
|
-
|
|
82
|
+
const p = Math.max(0, Math.min(100, Math.round(pct)));
|
|
83
|
+
const filled = Math.max(p > 0 ? 1 : 0, Math.round(p / 12.5));
|
|
84
|
+
const barColor = p > 75 ? [251, 113, 133] : p > 45 ? [251, 191, 36] : [52, 211, 153];
|
|
85
|
+
const bar = rgb(barColor[0], barColor[1], barColor[2], '▓'.repeat(filled)) + dim('░'.repeat(Math.max(0, 8 - filled)));
|
|
86
|
+
parts.push(\`\${bar} \${rgb(barColor[0], barColor[1], barColor[2], p + '%')}\`);
|
|
35
87
|
}
|
|
36
|
-
|
|
88
|
+
|
|
89
|
+
const now = new Date();
|
|
90
|
+
const hhmm = String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0');
|
|
91
|
+
parts.push(dim(hhmm));
|
|
92
|
+
|
|
93
|
+
process.stdout.write(' ' + parts.join(sep) + '\\n');
|
|
37
94
|
});
|
|
38
95
|
`;
|
|
39
96
|
|