homunculus-code 0.1.0 → 0.3.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/ARCHITECTURE.md +211 -0
- package/README.md +57 -17
- package/bin/cli.js +36 -0
- package/bin/init.js +28 -203
- package/bin/night.js +292 -0
- package/commands/hm-night.md +86 -0
- package/commands/hm-setup.md +65 -0
- package/commands/hm-status.md +47 -0
- package/examples/reference/README.md +13 -1
- package/examples/reference/evolved-skills/claude-code-reference/ch01-extensions.md +98 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch02-agents.md +90 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch03-hooks.md +104 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch04-mcp.md +78 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch05-ui.md +161 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch06-rules-security.md +301 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch07-model-memory.md +203 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch08-workflows.md +148 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch09-integrations.md +502 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch10-cli-sdk.md +269 -0
- package/examples/reference/evolved-skills/claude-code-reference/ch11-output-versions.md +172 -0
- package/examples/reference/evolved-skills/claude-code-reference/index.md +134 -0
- package/package.json +2 -2
package/bin/night.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// homunculus night — Run one evolution cycle
|
|
3
|
+
// Simulates what the nightly agent does: health check → evolve → research → report
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { execSync } = require('child_process');
|
|
8
|
+
|
|
9
|
+
const projectDir = process.cwd();
|
|
10
|
+
const HOMUNCULUS_DIR = path.join(projectDir, 'homunculus');
|
|
11
|
+
const ARCH_FILE = path.join(projectDir, 'architecture.yaml');
|
|
12
|
+
const INSTINCTS_DIR = path.join(HOMUNCULUS_DIR, 'instincts', 'personal');
|
|
13
|
+
const ARCHIVED_DIR = path.join(HOMUNCULUS_DIR, 'instincts', 'archived');
|
|
14
|
+
const SKILLS_DIR = path.join(HOMUNCULUS_DIR, 'evolved', 'skills');
|
|
15
|
+
const EVALS_DIR = path.join(HOMUNCULUS_DIR, 'evolved', 'evals');
|
|
16
|
+
const OBS_FILE = path.join(HOMUNCULUS_DIR, 'observations.jsonl');
|
|
17
|
+
const SCRIPTS_DIR = path.join(projectDir, 'scripts');
|
|
18
|
+
|
|
19
|
+
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
20
|
+
const bold = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
21
|
+
const green = (s) => `\x1b[32m${s}\x1b[0m`;
|
|
22
|
+
const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
|
|
23
|
+
const red = (s) => `\x1b[31m${s}\x1b[0m`;
|
|
24
|
+
const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
|
|
25
|
+
|
|
26
|
+
function countFiles(dir, ext = '.md') {
|
|
27
|
+
try {
|
|
28
|
+
return fs.readdirSync(dir).filter(f => f.endsWith(ext)).length;
|
|
29
|
+
} catch { return 0; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function countLines(file) {
|
|
33
|
+
try {
|
|
34
|
+
return fs.readFileSync(file, 'utf8').trim().split('\n').filter(Boolean).length;
|
|
35
|
+
} catch { return 0; }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function sleep(ms) {
|
|
39
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function parseGoals(yamlContent) {
|
|
43
|
+
const goals = [];
|
|
44
|
+
const lines = yamlContent.split('\n');
|
|
45
|
+
let currentGoal = null;
|
|
46
|
+
let indent = 0;
|
|
47
|
+
|
|
48
|
+
for (const line of lines) {
|
|
49
|
+
// Match top-level goals (direct children of "goals:")
|
|
50
|
+
const goalMatch = line.match(/^ (\w+):$/);
|
|
51
|
+
if (goalMatch && !line.includes('purpose') && !line.includes('metrics') &&
|
|
52
|
+
!line.includes('health_check') && !line.includes('realized_by') &&
|
|
53
|
+
!line.includes('goals:') && !line.includes('command') &&
|
|
54
|
+
!line.includes('expected') && !line.includes('healthy') &&
|
|
55
|
+
!line.includes('name:') && !line.includes('source')) {
|
|
56
|
+
currentGoal = goalMatch[1];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const purposeMatch = line.match(/purpose:\s*"(.+)"/);
|
|
60
|
+
if (purposeMatch && currentGoal) {
|
|
61
|
+
goals.push({ name: currentGoal, purpose: purposeMatch[1] });
|
|
62
|
+
currentGoal = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return goals;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function main() {
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log(` ${bold('🌙 Homunculus — Evolution Cycle')}`);
|
|
71
|
+
console.log(` ${dim(new Date().toISOString().replace('T', ' ').slice(0, 19))}`);
|
|
72
|
+
console.log('');
|
|
73
|
+
|
|
74
|
+
// Check if initialized
|
|
75
|
+
if (!fs.existsSync(HOMUNCULUS_DIR)) {
|
|
76
|
+
console.log(` ${red('✗')} Not initialized. Run ${bold('npx homunculus-code init')} first.`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ─────────────────────────────────────────
|
|
81
|
+
// Phase 1: Health Check
|
|
82
|
+
// ─────────────────────────────────────────
|
|
83
|
+
console.log(` ${bold('[1/5] Health Check')}`);
|
|
84
|
+
await sleep(300);
|
|
85
|
+
|
|
86
|
+
if (fs.existsSync(ARCH_FILE)) {
|
|
87
|
+
const yaml = fs.readFileSync(ARCH_FILE, 'utf8');
|
|
88
|
+
const goals = parseGoals(yaml);
|
|
89
|
+
|
|
90
|
+
if (goals.length > 0) {
|
|
91
|
+
for (const goal of goals) {
|
|
92
|
+
// Simple heuristic: if realized_by exists and points to real file = healthy
|
|
93
|
+
const status = yellow('○ no data yet');
|
|
94
|
+
console.log(` ${goal.name}: ${status}`);
|
|
95
|
+
console.log(` ${dim(goal.purpose)}`);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
console.log(` ${yellow('○')} No goals defined in architecture.yaml`);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.log(` ${red('✗')} architecture.yaml not found`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.log('');
|
|
105
|
+
await sleep(200);
|
|
106
|
+
|
|
107
|
+
// ─────────────────────────────────────────
|
|
108
|
+
// Phase 2: Scan Instincts
|
|
109
|
+
// ─────────────────────────────────────────
|
|
110
|
+
console.log(` ${bold('[2/5] Scan Instincts')}`);
|
|
111
|
+
await sleep(300);
|
|
112
|
+
|
|
113
|
+
const activeInstincts = countFiles(INSTINCTS_DIR);
|
|
114
|
+
const archivedInstincts = countFiles(ARCHIVED_DIR);
|
|
115
|
+
const observations = countLines(OBS_FILE);
|
|
116
|
+
|
|
117
|
+
if (activeInstincts > 0) {
|
|
118
|
+
console.log(` ${green('✓')} ${activeInstincts} active instincts (${archivedInstincts} archived)`);
|
|
119
|
+
|
|
120
|
+
// Run prune check
|
|
121
|
+
try {
|
|
122
|
+
const pruneScript = path.join(SCRIPTS_DIR, 'prune-instincts.js');
|
|
123
|
+
if (fs.existsSync(pruneScript)) {
|
|
124
|
+
const result = execSync(`node "${pruneScript}"`, {
|
|
125
|
+
encoding: 'utf8', timeout: 10000, cwd: projectDir
|
|
126
|
+
});
|
|
127
|
+
const candidateMatch = result.match(/Candidates:\s*(\d+)/);
|
|
128
|
+
if (candidateMatch && parseInt(candidateMatch[1]) > 0) {
|
|
129
|
+
console.log(` ${yellow('△')} ${candidateMatch[1]} instincts eligible for archival`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch {}
|
|
133
|
+
} else if (observations > 0) {
|
|
134
|
+
console.log(` ${yellow('○')} ${observations} observations recorded, no instincts extracted yet`);
|
|
135
|
+
console.log(` ${dim('Tip: instincts are extracted at session end when enough patterns emerge')}`);
|
|
136
|
+
} else {
|
|
137
|
+
console.log(` ${yellow('○')} No instincts yet — use Claude Code normally, patterns will emerge`);
|
|
138
|
+
console.log(` ${dim('The observation hook is watching. Keep using Claude Code.')}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
console.log('');
|
|
142
|
+
await sleep(200);
|
|
143
|
+
|
|
144
|
+
// ─────────────────────────────────────────
|
|
145
|
+
// Phase 3: Eval Skills
|
|
146
|
+
// ─────────────────────────────────────────
|
|
147
|
+
console.log(` ${bold('[3/5] Eval Skills')}`);
|
|
148
|
+
await sleep(300);
|
|
149
|
+
|
|
150
|
+
const skillCount = countFiles(SKILLS_DIR);
|
|
151
|
+
const evalCount = countFiles(EVALS_DIR, '.yaml');
|
|
152
|
+
|
|
153
|
+
if (skillCount > 0) {
|
|
154
|
+
console.log(` ${green('✓')} ${skillCount} evolved skills found`);
|
|
155
|
+
|
|
156
|
+
// List skills
|
|
157
|
+
try {
|
|
158
|
+
const skills = fs.readdirSync(SKILLS_DIR).filter(f => f.endsWith('.md'));
|
|
159
|
+
for (const skill of skills) {
|
|
160
|
+
const name = skill.replace('.md', '');
|
|
161
|
+
const hasEval = fs.existsSync(path.join(EVALS_DIR, `${name}.eval.yaml`));
|
|
162
|
+
if (hasEval) {
|
|
163
|
+
console.log(` ${green('✓')} ${name} — has eval spec`);
|
|
164
|
+
} else {
|
|
165
|
+
console.log(` ${yellow('○')} ${name} — no eval spec yet`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch {}
|
|
169
|
+
|
|
170
|
+
if (evalCount > 0) {
|
|
171
|
+
console.log(` ${dim(`Run 'claude "/eval-skill"' to evaluate, or let the nightly agent handle it`)}`);
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
console.log(` ${yellow('○')} No skills yet — instincts converge into skills over time`);
|
|
175
|
+
console.log(` ${dim(`Once you have 3+ related instincts, run 'claude "/evolve"'`)}`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
console.log('');
|
|
179
|
+
await sleep(200);
|
|
180
|
+
|
|
181
|
+
// ─────────────────────────────────────────
|
|
182
|
+
// Phase 4: Research
|
|
183
|
+
// ─────────────────────────────────────────
|
|
184
|
+
console.log(` ${bold('[4/5] Research')}`);
|
|
185
|
+
await sleep(300);
|
|
186
|
+
|
|
187
|
+
// Check Claude Code version
|
|
188
|
+
try {
|
|
189
|
+
const version = execSync('claude --version 2>/dev/null', {
|
|
190
|
+
encoding: 'utf8', timeout: 5000
|
|
191
|
+
}).trim();
|
|
192
|
+
console.log(` ${green('✓')} Claude Code ${version}`);
|
|
193
|
+
} catch {
|
|
194
|
+
console.log(` ${yellow('○')} Claude Code version check skipped`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Check Node version
|
|
198
|
+
const nodeVersion = process.version;
|
|
199
|
+
console.log(` ${green('✓')} Node.js ${nodeVersion}`);
|
|
200
|
+
|
|
201
|
+
// Check architecture health
|
|
202
|
+
if (fs.existsSync(ARCH_FILE)) {
|
|
203
|
+
const yaml = fs.readFileSync(ARCH_FILE, 'utf8');
|
|
204
|
+
const goalCount = (yaml.match(/purpose:/g) || []).length;
|
|
205
|
+
const healthChecks = (yaml.match(/health_check:/g) || []).length;
|
|
206
|
+
const realizedBy = (yaml.match(/realized_by:/g) || []).length;
|
|
207
|
+
|
|
208
|
+
if (healthChecks < goalCount / 2) {
|
|
209
|
+
console.log(` ${yellow('△')} ${healthChecks}/${goalCount} goals have health checks — add more for better evolution`);
|
|
210
|
+
}
|
|
211
|
+
if (realizedBy < goalCount / 2) {
|
|
212
|
+
console.log(` ${yellow('△')} ${realizedBy}/${goalCount} goals have implementations — some are waiting to evolve`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
console.log('');
|
|
217
|
+
await sleep(200);
|
|
218
|
+
|
|
219
|
+
// ─────────────────────────────────────────
|
|
220
|
+
// Phase 5: Report
|
|
221
|
+
// ─────────────────────────────────────────
|
|
222
|
+
console.log(` ${bold('[5/5] Report')}`);
|
|
223
|
+
await sleep(300);
|
|
224
|
+
|
|
225
|
+
const reportDate = new Date().toISOString().slice(0, 10);
|
|
226
|
+
const reportLines = [];
|
|
227
|
+
|
|
228
|
+
console.log('');
|
|
229
|
+
console.log(` ┌${'─'.repeat(52)}┐`);
|
|
230
|
+
console.log(` │ ${bold(` Evolution Report — ${reportDate}`)} │`);
|
|
231
|
+
console.log(` ├${'─'.repeat(52)}┤`);
|
|
232
|
+
|
|
233
|
+
// Summary
|
|
234
|
+
const goalCount = fs.existsSync(ARCH_FILE)
|
|
235
|
+
? (fs.readFileSync(ARCH_FILE, 'utf8').match(/purpose:/g) || []).length
|
|
236
|
+
: 0;
|
|
237
|
+
|
|
238
|
+
console.log(` │ │`);
|
|
239
|
+
console.log(` │ ${cyan('Goals:')} ${String(goalCount).padStart(3)} │`);
|
|
240
|
+
console.log(` │ ${cyan('Instincts:')} ${String(activeInstincts).padStart(3)} active / ${String(archivedInstincts).padStart(3)} archived │`);
|
|
241
|
+
console.log(` │ ${cyan('Skills:')} ${String(skillCount).padStart(3)} (${evalCount} with eval specs) │`);
|
|
242
|
+
console.log(` │ ${cyan('Observations:')} ${String(observations).padStart(5)} │`);
|
|
243
|
+
console.log(` │ │`);
|
|
244
|
+
|
|
245
|
+
if (activeInstincts === 0 && skillCount === 0) {
|
|
246
|
+
console.log(` │ ${bold('Status:')} Fresh install — ready to evolve │`);
|
|
247
|
+
console.log(` │ │`);
|
|
248
|
+
console.log(` │ ${dim('Next steps:')} │`);
|
|
249
|
+
console.log(` │ ${dim('1. Use Claude Code on your project')} │`);
|
|
250
|
+
console.log(` │ ${dim('2. Patterns will be auto-extracted')} │`);
|
|
251
|
+
console.log(` │ ${dim('3. Run this command again to see progress')} │`);
|
|
252
|
+
} else if (skillCount === 0) {
|
|
253
|
+
console.log(` │ ${bold('Status:')} Collecting patterns... │`);
|
|
254
|
+
console.log(` │ │`);
|
|
255
|
+
console.log(` │ ${dim('You have instincts! When 3+ are related,')} │`);
|
|
256
|
+
console.log(` │ ${dim('run claude "/evolve" to create your first skill.')} │`);
|
|
257
|
+
} else {
|
|
258
|
+
console.log(` │ ${bold('Status:')} ${green('Evolving')} │`);
|
|
259
|
+
console.log(` │ │`);
|
|
260
|
+
console.log(` │ ${dim('Run claude "/eval-skill" to check quality,')} │`);
|
|
261
|
+
console.log(` │ ${dim('or set up the nightly agent for autonomy.')} │`);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
console.log(` │ │`);
|
|
265
|
+
console.log(` └${'─'.repeat(52)}┘`);
|
|
266
|
+
console.log('');
|
|
267
|
+
|
|
268
|
+
// Save report to file
|
|
269
|
+
const reportDir = path.join(HOMUNCULUS_DIR, 'reports');
|
|
270
|
+
if (!fs.existsSync(reportDir)) fs.mkdirSync(reportDir, { recursive: true });
|
|
271
|
+
|
|
272
|
+
const reportContent = [
|
|
273
|
+
`# Evolution Report — ${reportDate}`,
|
|
274
|
+
'',
|
|
275
|
+
'## Summary',
|
|
276
|
+
`- Goals: ${goalCount}`,
|
|
277
|
+
`- Instincts: ${activeInstincts} active / ${archivedInstincts} archived`,
|
|
278
|
+
`- Skills: ${skillCount} (${evalCount} with eval specs)`,
|
|
279
|
+
`- Observations: ${observations}`,
|
|
280
|
+
'',
|
|
281
|
+
`Generated by \`npx homunculus-code night\``,
|
|
282
|
+
].join('\n');
|
|
283
|
+
|
|
284
|
+
fs.writeFileSync(path.join(reportDir, `${reportDate}.md`), reportContent + '\n');
|
|
285
|
+
console.log(` ${dim(`Report saved to homunculus/reports/${reportDate}.md`)}`);
|
|
286
|
+
console.log('');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
main().catch(err => {
|
|
290
|
+
console.error('Error:', err.message);
|
|
291
|
+
process.exit(1);
|
|
292
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# /hm-night — Run One Evolution Cycle
|
|
2
|
+
|
|
3
|
+
Run the full evolution pipeline: health check → instincts → skills → research → report.
|
|
4
|
+
|
|
5
|
+
## Behavior
|
|
6
|
+
|
|
7
|
+
You are the Homunculus nightly evolution agent. Run through all 5 phases systematically.
|
|
8
|
+
|
|
9
|
+
### Phase 1: Health Check
|
|
10
|
+
|
|
11
|
+
1. Read `architecture.yaml`
|
|
12
|
+
2. For each goal with a `health_check.command`, run it and report pass/fail
|
|
13
|
+
3. For goals without health checks, check if `realized_by` points to an existing file
|
|
14
|
+
4. Report:
|
|
15
|
+
```
|
|
16
|
+
[1/5] Health Check
|
|
17
|
+
code_quality: ✅ healthy (tests passing)
|
|
18
|
+
productivity: ⚠️ no health check defined
|
|
19
|
+
knowledge: ✅ healthy
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Phase 2: Scan Instincts
|
|
23
|
+
|
|
24
|
+
1. Count files in `homunculus/instincts/personal/` and `homunculus/instincts/archived/`
|
|
25
|
+
2. If instincts exist, check for pruning candidates (run `node scripts/prune-instincts.js` if it exists)
|
|
26
|
+
3. Report count and any archival suggestions
|
|
27
|
+
```
|
|
28
|
+
[2/5] Instincts
|
|
29
|
+
12 active / 5 archived
|
|
30
|
+
△ 2 candidates for archival (low confidence)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Phase 3: Eval Skills
|
|
34
|
+
|
|
35
|
+
1. List files in `homunculus/evolved/skills/`
|
|
36
|
+
2. For each skill, check if an eval spec exists in `homunculus/evolved/evals/`
|
|
37
|
+
3. If eval specs exist, run `/eval-skill` on each
|
|
38
|
+
4. Report pass rates
|
|
39
|
+
```
|
|
40
|
+
[3/5] Skills
|
|
41
|
+
✓ tdd-workflow: 100% (8/8 scenarios)
|
|
42
|
+
△ debugging-patterns: 85% (6/7) — needs improvement
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Phase 4: Research
|
|
46
|
+
|
|
47
|
+
1. Check Claude Code version
|
|
48
|
+
2. Scan `architecture.yaml` for goals with no `realized_by` — these are opportunities
|
|
49
|
+
3. Look for goals with failing health checks — these need attention
|
|
50
|
+
4. Suggest improvements:
|
|
51
|
+
```
|
|
52
|
+
[4/5] Research
|
|
53
|
+
✓ Claude Code v2.1.81
|
|
54
|
+
△ 2 goals have no implementation yet
|
|
55
|
+
→ Suggestion: code_quality.review could use a pre-commit hook
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Phase 5: Report
|
|
59
|
+
|
|
60
|
+
Generate a summary report and save to `homunculus/reports/YYYY-MM-DD.md`:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
[5/5] Evolution Report — 2026-03-22
|
|
64
|
+
┌──────────────────────────────────────────┐
|
|
65
|
+
│ Goals: 5 (3 healthy, 2 need work) │
|
|
66
|
+
│ Instincts: 12 active / 5 archived │
|
|
67
|
+
│ Skills: 3 (2 at 100%, 1 at 85%) │
|
|
68
|
+
│ │
|
|
69
|
+
│ Actions taken: │
|
|
70
|
+
│ - Pruned 2 outdated instincts │
|
|
71
|
+
│ - Improved debugging-patterns to v1.2 │
|
|
72
|
+
│ │
|
|
73
|
+
│ Suggestions: │
|
|
74
|
+
│ - Add health check to productivity goal │
|
|
75
|
+
│ - Review could use a pre-commit hook │
|
|
76
|
+
└──────────────────────────────────────────┘
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Important
|
|
80
|
+
|
|
81
|
+
- Actually RUN health check commands (don't just read them)
|
|
82
|
+
- Actually RUN eval-skill if eval specs exist (don't skip)
|
|
83
|
+
- If a skill fails eval, attempt `/improve-skill` (max 2 rounds)
|
|
84
|
+
- Save the report to `homunculus/reports/`
|
|
85
|
+
- Be concise — this should feel like a progress dashboard, not an essay
|
|
86
|
+
- If the system is fresh (no instincts/skills), give encouraging guidance
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# /hm-setup — Set Up Your Goal Tree
|
|
2
|
+
|
|
3
|
+
Guide the user through defining their goals and generate `architecture.yaml`.
|
|
4
|
+
|
|
5
|
+
## Behavior
|
|
6
|
+
|
|
7
|
+
You are helping the user set up Homunculus — a self-evolving AI assistant. Your job is to understand their project and goals, then generate a goal tree.
|
|
8
|
+
|
|
9
|
+
### Step 1: Understand the Project
|
|
10
|
+
|
|
11
|
+
Ask the user (conversationally, not a form):
|
|
12
|
+
- What is this project? (e.g., SaaS app, CLI tool, personal project)
|
|
13
|
+
- What do they spend most time on? (e.g., debugging, writing tests, deploying)
|
|
14
|
+
- What frustrates them? (e.g., regressions, slow CI, repetitive tasks)
|
|
15
|
+
- What would they improve if they had infinite time?
|
|
16
|
+
|
|
17
|
+
Keep it natural — 2-3 questions max, adapt based on answers.
|
|
18
|
+
|
|
19
|
+
### Step 2: Propose Goals
|
|
20
|
+
|
|
21
|
+
Based on their answers, propose 3-5 goals with sub-goals. Present them clearly:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Based on what you told me, here's your goal tree:
|
|
25
|
+
|
|
26
|
+
🎯 [Project Name]
|
|
27
|
+
├── code_quality — Ship fewer bugs
|
|
28
|
+
│ ├── testing — Every change has tests
|
|
29
|
+
│ └── review — Catch issues before merge
|
|
30
|
+
├── productivity — Move faster
|
|
31
|
+
│ ├── automation — Automate repetitive work
|
|
32
|
+
│ └── debugging — Find root causes faster
|
|
33
|
+
└── knowledge — Stay up to date
|
|
34
|
+
└── tool_updates — Track useful updates
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Ask: "Does this look right? Want to add, remove, or change anything?"
|
|
38
|
+
|
|
39
|
+
### Step 3: Generate architecture.yaml
|
|
40
|
+
|
|
41
|
+
Once confirmed, generate `architecture.yaml` with:
|
|
42
|
+
- `purpose` for every goal
|
|
43
|
+
- `metrics` where measurable (use reasonable defaults)
|
|
44
|
+
- `health_check` where possible (shell commands that exit 0 = healthy)
|
|
45
|
+
- `realized_by: # will evolve` for all implementations (the system will fill these in)
|
|
46
|
+
|
|
47
|
+
Write the file using the Write tool.
|
|
48
|
+
|
|
49
|
+
### Step 4: Confirm
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
✅ architecture.yaml created with N goals!
|
|
53
|
+
|
|
54
|
+
Your system is ready to evolve. Use Claude Code normally —
|
|
55
|
+
patterns will be auto-extracted. Run /hm-night anytime to
|
|
56
|
+
trigger an evolution cycle.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Important
|
|
60
|
+
|
|
61
|
+
- Keep the conversation SHORT (under 5 back-and-forth)
|
|
62
|
+
- Generate PRACTICAL goals, not abstract ones
|
|
63
|
+
- Use the project's actual tech stack for health checks (e.g., `npm test`, `pytest`, `go test`)
|
|
64
|
+
- Don't overwhelm — 3-5 top-level goals is ideal for a start
|
|
65
|
+
- Goals can always be refined later
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# /hm-status — Evolution Status Dashboard
|
|
2
|
+
|
|
3
|
+
Show the current state of the Homunculus evolution system.
|
|
4
|
+
|
|
5
|
+
## Behavior
|
|
6
|
+
|
|
7
|
+
Gather and display all evolution metrics in a compact dashboard.
|
|
8
|
+
|
|
9
|
+
### Data to Collect
|
|
10
|
+
|
|
11
|
+
1. **Goal Tree**: Read `architecture.yaml`, count goals and sub-goals
|
|
12
|
+
2. **Instincts**: Count files in `homunculus/instincts/personal/` and `archived/`
|
|
13
|
+
3. **Skills**: Count files in `homunculus/evolved/skills/`, note versions
|
|
14
|
+
4. **Agents**: Count files in `homunculus/evolved/agents/`
|
|
15
|
+
5. **Eval Specs**: Count files in `homunculus/evolved/evals/`
|
|
16
|
+
6. **Observations**: Count lines in `homunculus/observations.jsonl`
|
|
17
|
+
7. **Experiments**: Count files in `homunculus/experiments/`
|
|
18
|
+
8. **Reports**: List recent reports in `homunculus/reports/`
|
|
19
|
+
|
|
20
|
+
### Output Format
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
🧬 Homunculus Status
|
|
24
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
25
|
+
|
|
26
|
+
Goal Tree: 5 goals / 12 sub-goals
|
|
27
|
+
Instincts: 24 active / 8 archived
|
|
28
|
+
Skills: 3 evolved (all 100% eval)
|
|
29
|
+
Agents: 1 specialized
|
|
30
|
+
Observations: 1,247 recorded
|
|
31
|
+
Experiments: 2 completed / 1 queued
|
|
32
|
+
|
|
33
|
+
Recent Skills:
|
|
34
|
+
✓ tdd-workflow v1.2 — 100% (11 scenarios)
|
|
35
|
+
✓ debugging-patterns v1.1 — 100% (8 scenarios)
|
|
36
|
+
✓ shell-automation v1.0 — 100% (6 scenarios)
|
|
37
|
+
|
|
38
|
+
Last Evolution: 2026-03-22
|
|
39
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Important
|
|
43
|
+
|
|
44
|
+
- Use actual file counts, not hardcoded numbers
|
|
45
|
+
- Keep output compact — one screen max
|
|
46
|
+
- If the system is fresh, show zeros and next steps
|
|
47
|
+
- Don't run any evaluations — just report current state
|
|
@@ -10,7 +10,19 @@ reference/
|
|
|
10
10
|
├── evolved-skills/ # 7 evolved skills (all 100% eval pass)
|
|
11
11
|
│ ├── api-system-diagnosis.md
|
|
12
12
|
│ ├── assistant-system-management.md
|
|
13
|
-
│ ├── claude-code-reference
|
|
13
|
+
│ ├── claude-code-reference/ # Split into index + 11 chapters (95% context reduction)
|
|
14
|
+
│ │ ├── index.md # Routing table — loads chapters on demand
|
|
15
|
+
│ │ ├── ch01-extensions.md
|
|
16
|
+
│ │ ├── ch02-agents.md
|
|
17
|
+
│ │ ├── ch03-hooks.md
|
|
18
|
+
│ │ ├── ch04-mcp.md
|
|
19
|
+
│ │ ├── ch05-ui.md
|
|
20
|
+
│ │ ├── ch06-rules-security.md
|
|
21
|
+
│ │ ├── ch07-model-memory.md
|
|
22
|
+
│ │ ├── ch08-workflows.md
|
|
23
|
+
│ │ ├── ch09-integrations.md
|
|
24
|
+
│ │ ├── ch10-cli-sdk.md
|
|
25
|
+
│ │ └── ch11-output-versions.md
|
|
14
26
|
│ ├── development-verification-patterns.md
|
|
15
27
|
│ ├── multi-agent-design-patterns.md
|
|
16
28
|
│ ├── shell-automation-patterns.md
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# ch01: 擴展系統 + Built-in Tools + Skills 系統
|
|
2
|
+
|
|
3
|
+
## 用途
|
|
4
|
+
|
|
5
|
+
這個 skill 是 Claude Code 進階功能的快速參考。
|
|
6
|
+
適用於設計自動化系統、設定助理架構、或討論 Claude Code 最佳實踐時。
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. 擴展系統:優先順序
|
|
11
|
+
|
|
12
|
+
| 功能 | 適用情境 | Context 成本 |
|
|
13
|
+
|------|----------|-------------|
|
|
14
|
+
| CLAUDE.md | 永遠適用的規則(build commands、conventions)| 每次請求都載入 |
|
|
15
|
+
| Skills | 按需知識、可觸發工作流(`/<name>`)| 低(描述每次;內容按需)|
|
|
16
|
+
| Subagents | 隔離執行、平行任務、專用工作者 | 與主 session 隔離 |
|
|
17
|
+
| Agent Teams | 多 session 協同(需互相溝通)| 高(每個 teammate 獨立費用)|
|
|
18
|
+
| MCP | 外部服務連接(DB、Slack、browser)| 每次請求(工具定義)|
|
|
19
|
+
| Hooks | 確定性腳本(lint、format、log)| **零**(外部執行,不進 context)|
|
|
20
|
+
| Plugins | 跨專案打包分享(skills + hooks + MCP)| 同各組件 |
|
|
21
|
+
|
|
22
|
+
**CLAUDE.md 大小指南**:目標 < 200 行(最多 ~500 行)。超過就把參考資料移到 Skills(按需載入)。
|
|
23
|
+
|
|
24
|
+
**Skills `disable-model-invocation: true`**:完全隱藏於 Claude,context 成本為零,直到你手動 `/invoke` — 適合有副作用或只想自己觸發的 skill。
|
|
25
|
+
|
|
26
|
+
**MCP 靜默斷線**:MCP server 中途斷線不會報警,工具直接消失。若發現 MCP 工具突然不可用 → 執行 `/mcp` 確認連線狀態。
|
|
27
|
+
|
|
28
|
+
## Built-in Tools 分類
|
|
29
|
+
|
|
30
|
+
| 類別 | 工具 |
|
|
31
|
+
|------|------|
|
|
32
|
+
| 檔案操作 | Read, Edit, Write(Create/Rename)|
|
|
33
|
+
| 搜尋 | Glob(按名稱)、Grep(按內容)|
|
|
34
|
+
| 執行 | Bash、Git |
|
|
35
|
+
| Web | WebSearch、WebFetch |
|
|
36
|
+
| Code Intelligence | Type errors、Go to definition、Find references(需 IDE 插件)|
|
|
37
|
+
|
|
38
|
+
**Agentic Loop**:Gather Context → Take Action → Verify Results(反覆迴圈,工具輸出形成下一步輸入)
|
|
39
|
+
|
|
40
|
+
**Context 自動清理三層**:(1) 清除舊工具輸出 → (2) 壓縮對話 → (3) 保留請求與關鍵程式碼
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Skills 系統
|
|
45
|
+
|
|
46
|
+
> **Skills vs Hooks 核心差異**:Skills 是**用戶主動呼叫**的命令(`/skill-name`),不會自動觸發。
|
|
47
|
+
> 若要在工具執行後自動執行邏輯,應使用 **Hooks**(PostToolUse 類型),不是 Skills。
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
# .claude/skills/fix-issue/SKILL.md
|
|
51
|
+
---
|
|
52
|
+
name: fix-issue
|
|
53
|
+
description: Fix a GitHub issue (disable-model-invocation = user only)
|
|
54
|
+
disable-model-invocation: true # 只能手動觸發
|
|
55
|
+
context: fork # 在獨立 subagent 中執行
|
|
56
|
+
agent: Explore
|
|
57
|
+
allowed-tools: Read, Grep, Bash
|
|
58
|
+
model: claude-sonnet-4-6
|
|
59
|
+
---
|
|
60
|
+
用 `gh issue view $ARGUMENTS` 取得 issue,分析並修復,
|
|
61
|
+
跑測試確認,提交 commit,開 PR。
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**動態注入**(在 Claude 看到前就執行):
|
|
65
|
+
```markdown
|
|
66
|
+
Git status: !`git status --short`
|
|
67
|
+
Branch: !`git branch --show-current`
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**變數**:`$ARGUMENTS`, `$ARGUMENTS[N]`, `$0`..., `${CLAUDE_SESSION_ID}`, `${CLAUDE_SKILL_DIR}`
|
|
71
|
+
|
|
72
|
+
**Bundled Skills(內建)**:
|
|
73
|
+
|
|
74
|
+
| 指令 | 功能 |
|
|
75
|
+
|------|------|
|
|
76
|
+
| `/simplify [focus]` | 平行 spawn 3 個 review agents(reuse/quality/efficiency),找問題後自動修復 |
|
|
77
|
+
| `/batch <instruction>` | 超大規模變更:分析→分解 5-30 個任務→每個獨立 worktree + PR(需 git)|
|
|
78
|
+
| `/debug [desc]` | 讀取 session debug log,診斷 Claude Code 問題 |
|
|
79
|
+
| `/claude-api` | 載入 Claude API/SDK 參考(偵測到 `anthropic` import 自動啟用)|
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
/batch migrate src/ from React class components to functional components
|
|
83
|
+
/batch add JSDoc comments to all exported functions
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**進階 frontmatter**:
|
|
87
|
+
```yaml
|
|
88
|
+
user-invocable: false # 背景知識:Claude 自動載入,用戶不能 /invoke
|
|
89
|
+
argument-hint: "[issue]" # autocomplete 提示
|
|
90
|
+
Skill(deploy *) # permissions deny 中禁用特定 skills
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**環境**:`SLASH_COMMAND_TOOL_CHAR_BUDGET`(skill context 預算,預設 context window 2%)
|
|
94
|
+
|
|
95
|
+
**多檔 Skill**:`SKILL.md`(主)+ `reference.md`(按需)+ `scripts/helper.py`(可執行)
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|