labs-claude 0.8.0 → 0.9.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
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const axios = require('axios');
3
3
  const { spawn } = require('child_process');
4
4
  const { randomUUID } = require('crypto');
@@ -345,9 +345,9 @@ async function main() {
345
345
  launchClaude(launch.claudeArgs, launch.env);
346
346
  });
347
347
  }
348
- if (args[0] === 'statusline') {
349
- const { scriptPath } = require('../src/statusline').installStatusline();
350
- return console.log(` ${c.mint('✔')} Cute Claude Code statusline installed (${c.dim(scriptPath)}). Reopen labs to see it!`);
348
+ if (args[0] === 'statusline' || args[0] === 'modpack') {
349
+ const res = require('../src/modpack').installModPack();
350
+ return console.log(` ${c.mint('✔')} LABS Opus Mod Pack installed:\n - auto-verify hook (${c.dim(res.hookPath)})\n - subagents: architect, builder, gatekeeper\n - context7 live docs mcp\n - LABS signature powerbar statusline\n Reopen labs to activate!`);
351
351
  }
352
352
  if (args[0] === 'paint') return require('../src/image-mcp').paintFromCli(args.slice(1));
353
353
  if (args[0] === 'admin-token') return makeAdminToken(args[1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labs-claude",
3
- "version": "0.8.0",
3
+ "version": "0.9.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 CHANGED
@@ -110,7 +110,7 @@ async function runSettings(ask, askHidden) {
110
110
  `${c.cyan('2')} theme ${c.violet(theme.name)} ${c.dim('(ocean / sunset / cyber / emerald / mono)')}`,
111
111
  `${c.cyan('3')} chrome mcp ${chrome} ${c.dim('(real browser control)')}`,
112
112
  `${c.cyan('4')} brave key ${brave} ${c.dim('(free 2k searches/mo)')}`,
113
- `${c.cyan('5')} statusline ${bar} ${c.dim('(model · repo · git · ctx%)')}`,
113
+ `${c.cyan('5')} opus pack ${bar} ${c.dim('(auto-verify hooks · context7 · agents · bar)')}`,
114
114
  `${c.cyan('6')} api key ${cfg.gatewayKey ? c.mint('saved') : c.rose('missing')} ${c.dim('(update or rotate)')}`,
115
115
  '---',
116
116
  `${c.dim('enter / b back to dash')}`,
@@ -150,7 +150,7 @@ async function runSettings(ask, askHidden) {
150
150
  const bk = await askMasked(centerLine(c.dim('brave api key: '), cols));
151
151
  if (bk) saveConfig({ ...storedConfig(), braveKey: bk });
152
152
  } else if (pick === '5') {
153
- try { require('./statusline').installStatusline(); } catch { /* ignore */ }
153
+ try { require('./modpack').installModPack(); } catch { /* ignore */ }
154
154
  } else if (pick === '6') {
155
155
  console.log('\n' + centerLine(c.dim('paste new lk_ key (or press Enter / Esc to go back)'), cols));
156
156
  const newKey = await askMasked(centerLine(c.amber('key: '), cols));
package/src/modpack.js ADDED
@@ -0,0 +1,141 @@
1
+ // LABS Opus-Level Mod Pack installer:
2
+ // 1) Auto-verify PostToolUse hook (~/.labs/hooks/auto-verify.js) -> instant syntax check on .js/.py/.json edits
3
+ // 2) Role-split subagents (~/.claude/agents/{architect,builder,gatekeeper}.md)
4
+ // 3) Context7 Live Docs MCP (~/.claude.json) -> up-to-date library docs so Qwen4 never guesses APIs
5
+ // 4) LABS Signature Powerbar Statusline (~/.labs/statusline.js)
6
+ const fs = require('fs');
7
+ const os = require('os');
8
+ const path = require('path');
9
+ const { LABS_DIR } = require('./config');
10
+ const { installStatusline } = require('./statusline');
11
+
12
+ const AUTO_VERIFY_HOOK = `#!/usr/bin/env node
13
+ // LABS Auto-Verify PostToolUse hook: catches syntax errors in <0.2s right after Edit/Write.
14
+ const { spawnSync } = require('child_process');
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ let raw = '';
19
+ process.stdin.setEncoding('utf8');
20
+ process.stdin.on('data', d => { raw += d; });
21
+ process.stdin.on('end', () => {
22
+ try {
23
+ const ev = JSON.parse(raw || '{}');
24
+ const file = ev.tool_input?.file_path || ev.tool_input?.path;
25
+ if (!file || !fs.existsSync(file)) return process.exit(0);
26
+ const ext = path.extname(file).toLowerCase();
27
+
28
+ if (['.js', '.mjs', '.cjs'].includes(ext)) {
29
+ const r = spawnSync(process.execPath, ['--check', file], { encoding: 'utf8', timeout: 3000 });
30
+ if (r.status !== 0) {
31
+ process.stderr.write(\`[LABS auto-verify] JS syntax error in \${file}:\\n\${(r.stderr || r.stdout || '').slice(0, 800)}\\n\`);
32
+ return process.exit(2);
33
+ }
34
+ } else if (ext === '.json') {
35
+ try { JSON.parse(fs.readFileSync(file, 'utf8')); }
36
+ catch (err) {
37
+ process.stderr.write(\`[LABS auto-verify] Invalid JSON in \${file}: \${err.message}\\n\`);
38
+ return process.exit(2);
39
+ }
40
+ } else if (ext === '.py') {
41
+ const py = process.platform === 'win32' ? 'python' : 'python3';
42
+ const r = spawnSync(py, ['-m', 'py_compile', file], { encoding: 'utf8', timeout: 4000 });
43
+ if (r.status !== 0) {
44
+ process.stderr.write(\`[LABS auto-verify] Python syntax error in \${file}:\\n\${(r.stderr || r.stdout || '').slice(0, 800)}\\n\`);
45
+ return process.exit(2);
46
+ }
47
+ }
48
+ } catch {}
49
+ process.exit(0);
50
+ });
51
+ `;
52
+
53
+ const AGENTS = {
54
+ 'architect.md': `---
55
+ name: architect
56
+ description: Deep systems planner. Audits the codebase and produces a minimal, file-exact plan before any code is edited.
57
+ ---
58
+ You are the Architect. Read the real files first, never guess signatures or paths, identify edge cases and failure modes, and output a crisp step-by-step plan with exact file paths and verification commands. Do not edit files unless explicitly asked.
59
+ `,
60
+ 'builder.md': `---
61
+ name: builder
62
+ description: Fast surgical implementer. Executes an approved plan cleanly with minimal diff and zero unrequested churn.
63
+ ---
64
+ You are the Builder. Implement the exact requested changes cleanly, keep edits surgical, preserve existing behavior and tests, and run syntax/unit checks before finishing. Never fabricate test output.
65
+ `,
66
+ 'gatekeeper.md': `---
67
+ name: gatekeeper
68
+ description: Independent verifier and code auditor. Runs real tests, inspects git diff, and rejects unproven claims.
69
+ ---
70
+ You are the Gatekeeper. Never trust claims from earlier steps—run the actual test suite, inspect git diff, check edge cases and security/secret hygiene, and report PASS only with exact observed command receipts.
71
+ `,
72
+ };
73
+
74
+ function installAutoVerifyHook() {
75
+ const hooksDir = path.join(LABS_DIR, 'hooks');
76
+ fs.mkdirSync(hooksDir, { recursive: true });
77
+ const hookPath = path.join(hooksDir, 'auto-verify.js');
78
+ fs.writeFileSync(hookPath, AUTO_VERIFY_HOOK, { mode: 0o755 });
79
+
80
+ const claudeDir = path.join(os.homedir(), '.claude');
81
+ const settingsPath = path.join(claudeDir, 'settings.json');
82
+ fs.mkdirSync(claudeDir, { recursive: true });
83
+ let settings = {};
84
+ if (fs.existsSync(settingsPath)) {
85
+ try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch { settings = {}; }
86
+ }
87
+ settings.hooks = settings.hooks || {};
88
+ const existing = Array.isArray(settings.hooks.PostToolUse) ? settings.hooks.PostToolUse : [];
89
+ const cmd = `node "${hookPath}"`;
90
+ const already = existing.some(entry => JSON.stringify(entry).includes('auto-verify.js'));
91
+ if (!already) {
92
+ existing.push({
93
+ matcher: 'Edit|Write|MultiEdit',
94
+ hooks: [{ type: 'command', command: cmd }],
95
+ });
96
+ settings.hooks.PostToolUse = existing;
97
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
98
+ }
99
+ return hookPath;
100
+ }
101
+
102
+ function installAgents() {
103
+ const agentsDir = path.join(os.homedir(), '.claude', 'agents');
104
+ fs.mkdirSync(agentsDir, { recursive: true });
105
+ const installed = [];
106
+ for (const [filename, content] of Object.entries(AGENTS)) {
107
+ const target = path.join(agentsDir, filename);
108
+ if (!fs.existsSync(target)) {
109
+ fs.writeFileSync(target, content, 'utf8');
110
+ installed.push(filename);
111
+ }
112
+ }
113
+ return { agentsDir, installed };
114
+ }
115
+
116
+ function installContext7Mcp() {
117
+ const claudeJson = path.join(os.homedir(), '.claude.json');
118
+ let cfg = {};
119
+ if (fs.existsSync(claudeJson)) {
120
+ try { cfg = JSON.parse(fs.readFileSync(claudeJson, 'utf8')); } catch { cfg = {}; }
121
+ }
122
+ cfg.mcpServers = cfg.mcpServers || {};
123
+ if (!cfg.mcpServers.context7) {
124
+ cfg.mcpServers.context7 = process.platform === 'win32'
125
+ ? { command: 'cmd', args: ['/c', 'npx', '-y', '@upstash/context7-mcp'] }
126
+ : { command: 'npx', args: ['-y', '@upstash/context7-mcp'] };
127
+ fs.writeFileSync(claudeJson, JSON.stringify(cfg, null, 2) + '\n', 'utf8');
128
+ return true;
129
+ }
130
+ return false;
131
+ }
132
+
133
+ function installModPack() {
134
+ const hookPath = installAutoVerifyHook();
135
+ const agents = installAgents();
136
+ const addedContext7 = installContext7Mcp();
137
+ const status = installStatusline();
138
+ return { hookPath, agents, addedContext7, status };
139
+ }
140
+
141
+ module.exports = { installModPack, installAutoVerifyHook, installAgents, installContext7Mcp };
package/src/statusline.js CHANGED
@@ -1,39 +1,96 @@
1
- // Installs a clean, cute, zero-lag Claude Code statusline (`~/.labs/statusline.js`) into `~/.claude/settings.json`.
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
- // Cute cracked-engineer Claude Code statusline (installed by labs setup)
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 model = data.model?.display_name || data.model?.id || 'Qwen4-35B-A3B';
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
- const pct = data.context_window?.used_percentage;
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: 400 }).toString().trim();
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
- const c = (rgb, s) => \`\\x1b[38;2;\${rgb}m\${s}\\x1b[0m\`;
72
+
73
+ const pct = data.context_window?.used_percentage;
74
+ const sep = dim(' · ');
27
75
  const parts = [
28
- c('52;211;153', '✦ ' + model),
29
- c('56;189;248', '📁 ' + folder),
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
- if (branch) parts.push(c('167;139;250', '🌿 ' + branch));
80
+
32
81
  if (pct != null) {
33
- const color = pct > 75 ? '251;113;133' : pct > 45 ? '251;191;36' : '52;211;153';
34
- parts.push(c(color, '🧠 ' + Math.round(pct) + '%'));
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
- process.stdout.write(parts.join(c('100;116;139', ' · ')) + '\\n');
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