labs-claude 0.8.1 → 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 +4 -4
- package/package.json +1 -1
- package/src/dash.js +2 -2
- package/src/modpack.js +141 -0
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
|
|
350
|
-
return console.log(` ${c.mint('✔')}
|
|
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
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')}
|
|
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('./
|
|
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 };
|