labs-claude 0.5.0 → 0.6.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/labs.js CHANGED
@@ -20,6 +20,7 @@ const { c, playMascotIntro, checkUpdateNotice, runSelfUpdate } = require('../src
20
20
  const HELP = `labs ${version} — Run Claude Code on Qwen4-35B-A3B (1M context · Native Vision · Web Search)
21
21
 
22
22
  labs open Claude Code directly on Qwen4-35B-A3B (1M ctx, high effort)
23
+ labs dash personal Apple-clean dashboard (usage, themes, effort, chrome, statusline)
23
24
  labs --model qwen explicitly launch Qwen4-35B-A3B (also: --model qwen-uncensored)
24
25
  labs -p "question" any Claude Code flag works (-p, --resume, --effort max, etc.)
25
26
  labs setup interactive mascot setup (paste lk_... key, choose effort)
@@ -336,6 +337,14 @@ async function main() {
336
337
  // Box users (friends) may have no ElevenLabs account at all, so these never fall into the ElevenLabs setup.
337
338
  if (args[0] === 'key') return saveGatewayKey(askHidden, ask, args[1]);
338
339
  if (args[0] === 'admin') return require('../src/admin-cli').runAdminCli(args.slice(1), ask);
340
+ if (args[0] === 'dash' || args[0] === 'dashboard') {
341
+ return require('../src/dash').runDash(ask, askHidden, async () => {
342
+ const st = storedConfig();
343
+ const launch = await prepareGatewayLaunch(st, ['--model', st.defaultBoxModel || 'qwen'], gatewayModelFrom(['--model', st.defaultBoxModel || 'qwen']));
344
+ console.log(launch.banner);
345
+ launchClaude(launch.claudeArgs, launch.env);
346
+ });
347
+ }
339
348
  if (args[0] === 'statusline') {
340
349
  const { scriptPath } = require('../src/statusline').installStatusline();
341
350
  return console.log(` ${c.mint('✔')} Cute Claude Code statusline installed (${c.dim(scriptPath)}). Reopen labs to see it!`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labs-claude",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Run the real Claude Code CLI on Qwen4 1M (Vision + Web), Gemini 4, Bedrock, or ElevenLabs — with colorful setup and admin token tracking.",
5
5
  "bin": {
6
6
  "labs": "bin/labs.js"
package/src/dash.js ADDED
@@ -0,0 +1,149 @@
1
+ // Apple-clean Personal Command Center (`labs dash`):
2
+ // Zero commands to memorize — see your live token stats, 7-day sparkline, switch effort/theme,
3
+ // connect Playwright Chrome MCP, Brave Search, cute statusline, or jump straight into Claude Code.
4
+ const axios = require('axios');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+ const { saveConfig } = require('./config');
9
+ const { storedConfig, saveGatewayKey } = require('./gateway-client');
10
+ const { c, THEMES, activeTheme, sparkline, randomQuip, playMascotIntro, askMasked, withSpinner, printCard, runSelfUpdate } = require('./ui');
11
+ const { version } = require('../package.json');
12
+
13
+ const DEFAULT_GATEWAY_URL = 'https://labs.instant.uz';
14
+
15
+ function compact(n) {
16
+ const v = Number(n || 0);
17
+ if (v >= 1e9) return `${(v / 1e9).toFixed(2)}B`;
18
+ if (v >= 1e6) return `${(v / 1e6).toFixed(2)}M`;
19
+ if (v >= 1e3) return `${(v / 1e3).toFixed(1)}K`;
20
+ return String(v);
21
+ }
22
+
23
+ function hasChromeMcp() {
24
+ try {
25
+ const p = path.join(os.homedir(), '.claude.json');
26
+ if (!fs.existsSync(p)) return false;
27
+ const data = JSON.parse(fs.readFileSync(p, 'utf8'));
28
+ return Boolean(data.mcpServers?.['labs-browser'] || data.mcpServers?.playwright);
29
+ } catch { return false; }
30
+ }
31
+
32
+ function hasStatusline() {
33
+ try {
34
+ const p = path.join(os.homedir(), '.claude', 'settings.json');
35
+ if (!fs.existsSync(p)) return false;
36
+ const data = JSON.parse(fs.readFileSync(p, 'utf8'));
37
+ return Boolean(data.statusLine?.command);
38
+ } catch { return false; }
39
+ }
40
+
41
+ async function fetchMe(url, key) {
42
+ try {
43
+ const { data } = await axios.get(`${url}/v1/me`, { headers: { 'x-api-key': key }, timeout: 5000 });
44
+ return data;
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ async function runDash(ask, askHidden, launchNow) {
51
+ await playMascotIntro(version, 'personal command center · qwen4 1m');
52
+
53
+ while (true) {
54
+ const cfg = storedConfig();
55
+ const url = (cfg.gatewayUrl || DEFAULT_GATEWAY_URL).replace(/\/+$/, '');
56
+ const theme = activeTheme();
57
+ const me = cfg.gatewayKey
58
+ ? await withSpinner(randomQuip(), () => fetchMe(url, cfg.gatewayKey))
59
+ : null;
60
+
61
+ const keyBadge = cfg.gatewayKey
62
+ ? c.mint(`connected (${cfg.gatewayKey.slice(0, 7)}…${cfg.gatewayKey.slice(-4)})`)
63
+ : c.rose('not set');
64
+ const boxBadge = me ? (me.box_up ? c.mint('ONLINE') : c.rose('SLEEPING')) : c.dim('unknown');
65
+ const chromeBadge = hasChromeMcp() ? c.mint('✔ on') : c.dim('○ off');
66
+ const braveBadge = (cfg.braveKey || process.env.LABS_BRAVE_KEYS || process.env.LABS_BRAVE_KEY) ? c.mint('✔ on') : c.dim('○ free key');
67
+ const statusBadge = hasStatusline() ? c.mint('✔ on') : c.dim('○ off');
68
+
69
+ const rows = [
70
+ `${c.dim('user:')} ${c.bold(c.white(me?.name || 'guest'))} ${c.dim('key:')} ${keyBadge}`,
71
+ `${c.dim('engine:')} ${c.cyan('Qwen4-35B-A3B')} ${c.dim('(1m · vision)')} ${c.dim('box:')} ${boxBadge}`,
72
+ ];
73
+ if (me) {
74
+ rows.push(
75
+ `${c.dim('today:')} ${c.bold(c.mint(compact(me.today_tokens)))} tok ${c.dim('all-time:')} ${c.white(compact(me.total_tokens))} ${c.dim('cache:')} ${c.violet(`${me.cache_hit_pct}%`)}`,
76
+ `${c.dim('7d trend:')} ${sparkline(me.last_7_days)} ${c.dim('calls today:')} ${c.cyan(String(me.today_calls))}`
77
+ );
78
+ }
79
+ rows.push(
80
+ `${c.dim('settings:')} effort ${c.cyan(cfg.defaultEffort || 'high')} · theme ${c.violet(theme.name)}`,
81
+ `${c.dim('addons:')} chrome ${chromeBadge} · brave ${braveBadge} · statusline ${statusBadge}`
82
+ );
83
+
84
+ printCard('LABS DASH', rows);
85
+ console.log(` ${c.bold('what do you want to do?')}`);
86
+ console.log(` ${c.cyan('1.')} start coding now (qwen4 1m) ${c.cyan('5.')} cute claude code statusline`);
87
+ console.log(` ${c.cyan('2.')} change effort (low/high/xhigh) ${c.cyan('6.')} connect chrome mcp / brave key`);
88
+ console.log(` ${c.cyan('3.')} change terminal theme color ${c.cyan('7.')} update / rotate api key`);
89
+ console.log(` ${c.cyan('4.')} check & install labs update ${c.dim('q. quit')}\n`);
90
+
91
+ const pick = (await ask(` ${c.violet('labs>')} `)).trim().toLowerCase();
92
+ if (!pick || pick === 'q' || pick === 'quit' || pick === 'exit') return;
93
+
94
+ if (pick === '1') {
95
+ if (!cfg.gatewayKey) {
96
+ await saveGatewayKey(askHidden, ask, undefined, true);
97
+ }
98
+ return launchNow();
99
+ }
100
+ if (pick === '2') {
101
+ console.log(`\n ${c.cyan('1.')} high ${c.dim('(default)')} ${c.cyan('2.')} xhigh ${c.dim('(max)')} ${c.cyan('3.')} low ${c.dim('(fastest)')}`);
102
+ const e = (await ask(' effort [1]: ')).trim();
103
+ const next = e === '2' ? 'xhigh' : e === '3' ? 'low' : 'high';
104
+ saveConfig({ ...cfg, defaultEffort: next });
105
+ console.log(` ${c.mint('✔')} default effort set to ${c.cyan(next)}.\n`);
106
+ } else if (pick === '3') {
107
+ const names = Object.keys(THEMES);
108
+ console.log('');
109
+ names.forEach((n, i) => console.log(` ${c.cyan(`${i + 1}.`)} ${c.bold(n.padEnd(9))} ${c.dim(THEMES[n].label)}`));
110
+ const t = Number(await ask(' theme [1]: ')) || 1;
111
+ const chosen = names[Math.max(0, Math.min(names.length - 1, t - 1))];
112
+ saveConfig({ ...cfg, theme: chosen });
113
+ console.log(` ${c.mint('✔')} theme switched to ${c.violet(chosen)}!\n`);
114
+ } else if (pick === '4') {
115
+ runSelfUpdate(version);
116
+ return;
117
+ } else if (pick === '5') {
118
+ try {
119
+ require('./statusline').installStatusline();
120
+ console.log(` ${c.mint('✔')} cute statusline installed! reopen labs to see it.\n`);
121
+ } catch (err) {
122
+ console.log(` ${c.rose('✖')} failed: ${err.message}\n`);
123
+ }
124
+ } else if (pick === '6') {
125
+ const { EXTENSION_URL, installBrowserServer } = require('./browser-setup');
126
+ const doChrome = await ask(` ${c.cyan('🌐')} setup real chrome (playwright mcp)? ${c.dim('[y/N]:')} `);
127
+ if (/^y/i.test(doChrome)) {
128
+ console.log(` ${c.dim('install extension:')} ${c.cyan(EXTENSION_URL)}`);
129
+ const tok = (await askMasked(` ${c.amber('🔑')} token ${c.dim('(or enter to skip):')} `)).replace(/^PLAYWRIGHT_MCP_EXTENSION_TOKEN=/, '');
130
+ installBrowserServer(tok);
131
+ console.log(` ${c.mint('✔')} chrome mcp connected!`);
132
+ }
133
+ const doBrave = await ask(` ${c.cyan('🔎')} add free brave search key? ${c.dim('[y/N]:')} `);
134
+ if (/^y/i.test(doBrave)) {
135
+ console.log(` ${c.dim('free key:')} ${c.cyan('https://api.search.brave.com/')}`);
136
+ const bk = await askMasked(` ${c.amber('🔑')} brave api key: `);
137
+ if (bk) {
138
+ saveConfig({ ...storedConfig(), braveKey: bk });
139
+ console.log(` ${c.mint('✔')} brave key saved!`);
140
+ }
141
+ }
142
+ console.log('');
143
+ } else if (pick === '7') {
144
+ await saveGatewayKey(askHidden, ask, undefined, true);
145
+ }
146
+ }
147
+ }
148
+
149
+ module.exports = { runDash };
@@ -25,7 +25,7 @@ const CAPS = 'effort,xhigh_effort,max_effort,thinking,interleaved_thinking';
25
25
  // Whenever a labs key is configured, bare `labs` ALWAYS launches Qwen4 (never falls back into ElevenLabs).
26
26
  function boxOnlyArgs(args, stored) {
27
27
  const named = args.some(a => a === '--model' || a.startsWith('--model='));
28
- const command = ['models', 'usage', 'chat', 'stop', 'setup', 'update', 'admin', 'key', 'console', 'paint'].includes(args[0]);
28
+ const command = ['models', 'usage', 'chat', 'stop', 'setup', 'update', 'admin', 'dash', 'statusline', 'key', 'console', 'paint'].includes(args[0]);
29
29
  const defaultModel = stored.defaultBoxModel || 'qwen';
30
30
  return !named && !command && stored.gatewayKey ? ['--model', defaultModel, ...args] : null;
31
31
  }
@@ -53,9 +53,14 @@ async function saveGatewayKey(askHidden, ask, givenKey, skipIntro = false) {
53
53
  if (!skipIntro) await playMascotIntro(version, 'Qwen4-35B-A3B · 1M Context · Vision · Web');
54
54
  const stored = storedConfig();
55
55
  const url = (stored.gatewayUrl || DEFAULT_GATEWAY_URL).replace(/\/+$/, '');
56
- const key = givenKey
57
- ? String(givenKey).trim()
58
- : await askMasked(` ${c.cyan('[1/3]')} ${c.amber('🔑')} Paste your API key ${c.dim('(lk_...)')}: `);
56
+ let key = givenKey ? String(givenKey).trim() : '';
57
+ if (!key && stored.gatewayKey) {
58
+ const hint = `${stored.gatewayKey.slice(0, 7)}…${stored.gatewayKey.slice(-4)}`;
59
+ const entered = await askMasked(` ${c.cyan('[1/3]')} ${c.amber('🔑')} API key saved ${c.dim(`(${hint})`)} — press Enter to keep, or paste new: `);
60
+ key = entered || stored.gatewayKey;
61
+ } else if (!key) {
62
+ key = await askMasked(` ${c.cyan('[1/3]')} ${c.amber('🔑')} Paste your API key ${c.dim('(lk_...)')}: `);
63
+ }
59
64
  if (!/^lk_[A-Za-z0-9_-]{20,}$/.test(key)) {
60
65
  console.log(key
61
66
  ? ` ${c.rose('✖')} That does not look like a valid labs key (it starts with ${c.bold('lk_')}). Nothing saved.`
package/src/ui.js CHANGED
@@ -19,16 +19,39 @@ const c = {
19
19
  white: s => ansi('38;2;248;250;252', s),
20
20
  };
21
21
 
22
- function gradient(text, from = [56, 189, 248], to = [167, 139, 250]) {
22
+ const THEMES = {
23
+ ocean: { from: [56, 189, 248], to: [52, 211, 153], label: 'ocean (cyan → mint)' },
24
+ sunset: { from: [251, 191, 36], to: [251, 113, 133], label: 'sunset (amber → rose)' },
25
+ cyber: { from: [167, 139, 250], to: [56, 189, 248], label: 'cyber (violet → cyan)' },
26
+ emerald: { from: [52, 211, 153], to: [163, 230, 53], label: 'emerald (mint → lime)' },
27
+ mono: { from: [248, 250, 252], to: [148, 163, 184], label: 'mono (apple silver)' },
28
+ };
29
+
30
+ function activeTheme() {
31
+ try {
32
+ const os = require('os');
33
+ const p = path.join(os.homedir(), '.labs', 'config.json');
34
+ if (fs.existsSync(p)) {
35
+ const name = JSON.parse(fs.readFileSync(p, 'utf8')).theme;
36
+ if (THEMES[name]) return { name, ...THEMES[name] };
37
+ }
38
+ } catch { /* ignore */ }
39
+ return { name: 'ocean', ...THEMES.ocean };
40
+ }
41
+
42
+ function gradient(text, from, to) {
43
+ const th = (!from || !to) ? activeTheme() : { from, to };
44
+ const f = from || th.from;
45
+ const tEnd = to || th.to;
23
46
  if (!USE_COLOR) return String(text);
24
47
  const chars = [...String(text)];
25
48
  const len = Math.max(1, chars.length - 1);
26
49
  return chars.map((ch, i) => {
27
50
  if (ch === ' ') return ' ';
28
51
  const t = i / len;
29
- const r = Math.round(from[0] + (to[0] - from[0]) * t);
30
- const g = Math.round(from[1] + (to[1] - from[1]) * t);
31
- const b = Math.round(from[2] + (to[2] - from[2]) * t);
52
+ const r = Math.round(f[0] + (tEnd[0] - f[0]) * t);
53
+ const g = Math.round(f[1] + (tEnd[1] - f[1]) * t);
54
+ const b = Math.round(f[2] + (tEnd[2] - f[2]) * t);
32
55
  return `\x1b[38;2;${r};${g};${b}m${ch}`;
33
56
  }).join('') + '\x1b[0m';
34
57
  }
@@ -161,8 +184,9 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
161
184
 
162
185
  async function playMascotIntro(version, subtitle = 'Qwen4-35B-A3B · 1M Context · Vision · Web') {
163
186
  const quip = randomQuip();
164
- const wordmark = gradient('█░░ ▄▀█ █▄▄ █▀', [56, 189, 248], [52, 211, 153]);
165
- const wordmark2 = gradient('█▄▄ █▀█ █▄█ ▄█', [167, 139, 250], [56, 189, 248]);
187
+ const th = activeTheme();
188
+ const wordmark = gradient('█░░ ▄▀█ █▄▄ █▀', th.from, th.to);
189
+ const wordmark2 = gradient('█▄▄ █▀█ █▄█ ▄█', th.to, th.from);
166
190
 
167
191
  const paintFrame = (frame, fromRgb, toRgb) => [
168
192
  '',
@@ -387,4 +411,4 @@ function runSelfUpdate(currentVersion) {
387
411
  console.log(`\n ${c.mint('✔')} Updated to latest! Close and reopen any open labs terminals.\n`);
388
412
  }
389
413
 
390
- module.exports = { c, gradient, visibleWidth, sparkline, CHILL_QUIPS, randomQuip, playMascotIntro, askMasked, withSpinner, printCard, isNewerVersion, checkUpdateNotice, runSelfUpdate };
414
+ module.exports = { c, THEMES, activeTheme, gradient, visibleWidth, sparkline, CHILL_QUIPS, randomQuip, playMascotIntro, askMasked, withSpinner, printCard, isNewerVersion, checkUpdateNotice, runSelfUpdate };