labs-claude 0.9.1 → 0.10.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/package.json +1 -1
- package/src/modpack.js +102 -40
package/package.json
CHANGED
package/src/modpack.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// LABS
|
|
2
|
-
// 1) Auto-verify PostToolUse hook (~/.labs/hooks/auto-verify.js) ->
|
|
3
|
-
// 2)
|
|
4
|
-
// 3)
|
|
5
|
-
// 4)
|
|
1
|
+
// LABS Frontier Brain & Mod Pack installer:
|
|
2
|
+
// 1) Auto-verify PostToolUse hook (~/.labs/hooks/auto-verify.js) -> <0.2s syntax check on .js/.py/.json edits
|
|
3
|
+
// 2) 4 Game-Theory + First-Principles Subagents (~/.claude/agents/{architect,builder,breaker,gatekeeper}.md)
|
|
4
|
+
// 3) 5 Superpower Slash Commands (~/.claude/commands/{arena,plan,debug,verify,ship}.md)
|
|
5
|
+
// 4) Balanced Operating Kernel in ~/.claude/CLAUDE.md (non-destructive, marker-scoped)
|
|
6
|
+
// 5) Context7 Live Docs MCP (~/.claude.json) + LABS Signature Powerbar Statusline (~/.labs/statusline.js)
|
|
6
7
|
const fs = require('fs');
|
|
7
8
|
const os = require('os');
|
|
8
9
|
const path = require('path');
|
|
@@ -10,7 +11,7 @@ const { LABS_DIR } = require('./config');
|
|
|
10
11
|
const { installStatusline } = require('./statusline');
|
|
11
12
|
|
|
12
13
|
const AUTO_VERIFY_HOOK = `#!/usr/bin/env node
|
|
13
|
-
// LABS Auto-Verify PostToolUse hook:
|
|
14
|
+
// LABS Auto-Verify PostToolUse hook: deterministic compiler/linter sensor (<0.2s after Edit/Write).
|
|
14
15
|
const { spawnSync } = require('child_process');
|
|
15
16
|
const fs = require('fs');
|
|
16
17
|
const path = require('path');
|
|
@@ -53,24 +54,82 @@ process.stdin.on('end', () => {
|
|
|
53
54
|
const AGENTS = {
|
|
54
55
|
'architect.md': `---
|
|
55
56
|
name: architect
|
|
56
|
-
description:
|
|
57
|
+
description: First-Principles + Systems Thinking planner. Maps dependencies, minimizes context noise, and outputs the smallest viable atomic plan before editing.
|
|
57
58
|
---
|
|
58
|
-
You are the Architect.
|
|
59
|
+
You are the Architect.
|
|
60
|
+
- First Principles: reason from the actual code and constraints, never copy bad legacy patterns.
|
|
61
|
+
- Information Theory: inspect only the specific functions, types, and interfaces needed—never dump whole repos into context.
|
|
62
|
+
- Systems Thinking: before changing any shared signature or schema, grep all callers and list second-order side effects + invariants that must hold.
|
|
63
|
+
- Occam's Razor: design the smallest viable diff. Output a crisp atomic plan with exact file paths and verification commands. Do not edit files unless asked.
|
|
59
64
|
`,
|
|
60
65
|
'builder.md': `---
|
|
61
66
|
name: builder
|
|
62
|
-
description:
|
|
67
|
+
description: Cybernetic Builder. Executes minimal diffs with Minimax defensive coding and tight test-driven feedback loops.
|
|
63
68
|
---
|
|
64
|
-
You are the Builder.
|
|
69
|
+
You are the Builder.
|
|
70
|
+
- Smallest Viable Diff: touch the fewest lines and files needed; delete dead code before adding abstractions.
|
|
71
|
+
- Minimax Defensive Coding: handle worst-case inputs (nulls, timeouts, malformed payloads, race conditions), not just the happy path.
|
|
72
|
+
- Feedback Control Loop: run syntax/unit tests after changes and self-correct from exact compiler/test output.
|
|
73
|
+
- Anti-Reward-Hacking: NEVER hardcode test outputs, weaken assertions, or swallow errors in empty try/catch blocks.
|
|
74
|
+
`,
|
|
75
|
+
'breaker.md': `---
|
|
76
|
+
name: breaker
|
|
77
|
+
description: Game-Theory Adversary (Red Team). Assumes Builder's code is flawed and tries to break it with edge-case tests, boundary inputs, and failure modes.
|
|
78
|
+
---
|
|
79
|
+
You are the Breaker (Zero-Sum Adversary).
|
|
80
|
+
Your ONLY goal is to uncover bugs the Builder missed. Assume the implementation has hidden flaws:
|
|
81
|
+
- Attack boundary values (0, empty strings, huge payloads, nulls, unicode, Windows/macOS path differences, timeouts, concurrent calls).
|
|
82
|
+
- Check for silent error swallowing, leaked secrets, race conditions, and broken callers.
|
|
83
|
+
- Write or run targeted edge-case tests to prove failures concretely. Report every confirmed flaw with exact reproduction steps.
|
|
65
84
|
`,
|
|
66
85
|
'gatekeeper.md': `---
|
|
67
86
|
name: gatekeeper
|
|
68
|
-
description: Independent
|
|
87
|
+
description: Independent Mechanism-Design Verifier. Runs real tests, audits git diff for reward hacking, and issues a strict PASS/FAIL verdict.
|
|
69
88
|
---
|
|
70
|
-
You are the Gatekeeper. Never trust claims from earlier steps
|
|
89
|
+
You are the Independent Gatekeeper. Never trust claims from earlier steps.
|
|
90
|
+
1. Run the real test suite and syntax checks yourself.
|
|
91
|
+
2. Inspect \`git diff\` to ensure zero reward hacking (no deleted assertions, no bypassed checks, no leaked secrets, no stray temp files).
|
|
92
|
+
3. Grade PASS only with exact observed command receipts and exit code 0; otherwise return FAIL with exact failure lines.
|
|
93
|
+
`,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const COMMANDS = {
|
|
97
|
+
'arena.md': `Run a balanced two-phase Game-Theory Adversarial Loop:
|
|
98
|
+
- Phase 1 (Architect + Builder): Apply First Principles, trace callers, and implement the cleanest, smallest viable diff with defensive edge-case handling.
|
|
99
|
+
- Phase 2 (Breaker + Gatekeeper): Switch roles completely. Assume Phase 1 has bugs. Attack it with edge-case inputs and tests, fix every failure uncovered, and verify the full test suite exits 0 with zero weakened assertions.
|
|
100
|
+
|
|
101
|
+
Task: $ARGUMENTS
|
|
102
|
+
`,
|
|
103
|
+
'plan.md': `Apply First Principles + Systems Thinking + Information Theory:
|
|
104
|
+
1. Read only the relevant files/slices (never guess paths or signatures).
|
|
105
|
+
2. Trace upstream callers, downstream side effects, and system invariants.
|
|
106
|
+
3. Output a crisp atomic plan with the smallest viable diff and exact verification commands. Wait for approval before editing.
|
|
107
|
+
|
|
108
|
+
Task: $ARGUMENTS
|
|
109
|
+
`,
|
|
110
|
+
'debug.md': `Run a closed-loop Feedback Control debugger (zero blind guessing):
|
|
111
|
+
1. Reproduce the exact failure with a real command.
|
|
112
|
+
2. Read the failing code path and isolate the single root cause.
|
|
113
|
+
3. Apply the smallest surgical fix (never swallow errors).
|
|
114
|
+
4. Re-run the reproduction + full test suite and report exact observed output.
|
|
115
|
+
|
|
116
|
+
Bug: $ARGUMENTS
|
|
117
|
+
`,
|
|
118
|
+
'verify.md': `Act as an independent Gatekeeper. Run the real test suite, inspect \`git diff\` for any weakened assertions or regressions, and return PASS or FAIL strictly from observed exit codes and output.
|
|
119
|
+
`,
|
|
120
|
+
'ship.md': `Run the full test suite, inspect \`git status\` and \`git diff\`, confirm zero secrets or temp files remain, and give a concise 3-bullet summary of what is ready to ship.
|
|
71
121
|
`,
|
|
72
122
|
};
|
|
73
123
|
|
|
124
|
+
const BRAIN_KERNEL = `<!-- LABS-BRAIN-START -->
|
|
125
|
+
## LABS Engineering Kernel (First Principles · Cybernetics · Game Theory)
|
|
126
|
+
- **First Principles & Occam's Razor:** Reason from actual code and constraints. Prefer the smallest viable diff; delete dead code before adding new abstractions.
|
|
127
|
+
- **Information Theory:** Read only the specific functions and interfaces needed. Explicitly identify unknowns before multi-file edits.
|
|
128
|
+
- **Systems Thinking:** Before changing any shared signature or schema, search for all callers and preserve system invariants.
|
|
129
|
+
- **Feedback Control Loops:** Never declare a task done until you run the real test suite or verification command and observe exit code 0.
|
|
130
|
+
- **Game Theory (Adversarial Check & Anti-Reward-Hacking):** Think like a Breaker on edge cases (nulls, timeouts, malformed inputs, OS path quirks). Never delete failing assertions, hardcode test outputs, or silence errors with empty catch blocks.
|
|
131
|
+
<!-- LABS-BRAIN-END -->`;
|
|
132
|
+
|
|
74
133
|
function installAutoVerifyHook() {
|
|
75
134
|
const hooksDir = path.join(LABS_DIR, 'hooks');
|
|
76
135
|
fs.mkdirSync(hooksDir, { recursive: true });
|
|
@@ -104,15 +163,38 @@ function installAgents() {
|
|
|
104
163
|
fs.mkdirSync(agentsDir, { recursive: true });
|
|
105
164
|
const installed = [];
|
|
106
165
|
for (const [filename, content] of Object.entries(AGENTS)) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
fs.writeFileSync(target, content, 'utf8');
|
|
110
|
-
installed.push(filename);
|
|
111
|
-
}
|
|
166
|
+
fs.writeFileSync(path.join(agentsDir, filename), content, 'utf8');
|
|
167
|
+
installed.push(filename.replace(/\.md$/, ''));
|
|
112
168
|
}
|
|
113
169
|
return { agentsDir, installed };
|
|
114
170
|
}
|
|
115
171
|
|
|
172
|
+
function installCommands() {
|
|
173
|
+
const cmdDir = path.join(os.homedir(), '.claude', 'commands');
|
|
174
|
+
fs.mkdirSync(cmdDir, { recursive: true });
|
|
175
|
+
const installed = [];
|
|
176
|
+
for (const [filename, content] of Object.entries(COMMANDS)) {
|
|
177
|
+
fs.writeFileSync(path.join(cmdDir, filename), content, 'utf8');
|
|
178
|
+
installed.push('/' + filename.replace(/\.md$/, ''));
|
|
179
|
+
}
|
|
180
|
+
return { cmdDir, installed };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function installBrainKernel() {
|
|
184
|
+
const claudeDir = path.join(os.homedir(), '.claude');
|
|
185
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
186
|
+
const claudeMd = path.join(claudeDir, 'CLAUDE.md');
|
|
187
|
+
let text = fs.existsSync(claudeMd) ? fs.readFileSync(claudeMd, 'utf8') : '';
|
|
188
|
+
const blockRe = /<!-- LABS-BRAIN-START -->[\s\S]*?<!-- LABS-BRAIN-END -->/;
|
|
189
|
+
if (blockRe.test(text)) {
|
|
190
|
+
text = text.replace(blockRe, BRAIN_KERNEL);
|
|
191
|
+
} else {
|
|
192
|
+
text = (text.trim() ? text.trimEnd() + '\n\n' : '') + BRAIN_KERNEL + '\n';
|
|
193
|
+
}
|
|
194
|
+
fs.writeFileSync(claudeMd, text, 'utf8');
|
|
195
|
+
return claudeMd;
|
|
196
|
+
}
|
|
197
|
+
|
|
116
198
|
function installContext7Mcp() {
|
|
117
199
|
const claudeJson = path.join(os.homedir(), '.claude.json');
|
|
118
200
|
let cfg = {};
|
|
@@ -130,34 +212,14 @@ function installContext7Mcp() {
|
|
|
130
212
|
return false;
|
|
131
213
|
}
|
|
132
214
|
|
|
133
|
-
const COMMANDS = {
|
|
134
|
-
'plan.md': `Audit the real files first (never guess paths or APIs), identify edge cases and failure modes, and write a crisp file-by-file plan with verification commands. Wait for approval before editing code.\n\nTask: $ARGUMENTS\n`,
|
|
135
|
-
'debug.md': `Use systematic root-cause debugging (zero blind guessing):\n1. Reproduce the exact error with a real command.\n2. Read the failing code path and isolate the single root cause.\n3. Apply the smallest surgical fix.\n4. Re-run the failing test + full test suite and report exact observed output.\n\nBug: $ARGUMENTS\n`,
|
|
136
|
-
'verify.md': `Act as an independent Gatekeeper. Run the real test suite, inspect \`git diff\`, check for syntax/type/security regressions, and report PASS or FAIL with exact command output only. Never trust earlier claims without re-running.\n`,
|
|
137
|
-
'ship.md': `Run the full test suite, inspect \`git status\` and \`git diff\`, verify no secrets or temp files are left behind, and give a concise 3-bullet summary of what is ready to ship.\n`,
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
function installCommands() {
|
|
141
|
-
const cmdDir = path.join(os.homedir(), '.claude', 'commands');
|
|
142
|
-
fs.mkdirSync(cmdDir, { recursive: true });
|
|
143
|
-
const installed = [];
|
|
144
|
-
for (const [filename, content] of Object.entries(COMMANDS)) {
|
|
145
|
-
const target = path.join(cmdDir, filename);
|
|
146
|
-
if (!fs.existsSync(target)) {
|
|
147
|
-
fs.writeFileSync(target, content, 'utf8');
|
|
148
|
-
installed.push('/' + filename.replace(/\.md$/, ''));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return { cmdDir, installed };
|
|
152
|
-
}
|
|
153
|
-
|
|
154
215
|
function installModPack() {
|
|
155
216
|
const hookPath = installAutoVerifyHook();
|
|
156
217
|
const agents = installAgents();
|
|
157
218
|
const commands = installCommands();
|
|
219
|
+
const brainPath = installBrainKernel();
|
|
158
220
|
const addedContext7 = installContext7Mcp();
|
|
159
221
|
const status = installStatusline();
|
|
160
|
-
return { hookPath, agents, commands, addedContext7, status };
|
|
222
|
+
return { hookPath, agents, commands, brainPath, addedContext7, status };
|
|
161
223
|
}
|
|
162
224
|
|
|
163
|
-
module.exports = { installModPack, installAutoVerifyHook, installAgents, installCommands, installContext7Mcp };
|
|
225
|
+
module.exports = { installModPack, installAutoVerifyHook, installAgents, installCommands, installBrainKernel, installContext7Mcp };
|