agent-configs 1.0.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.
Files changed (85) hide show
  1. package/README.md +223 -0
  2. package/agents/architect.md +211 -0
  3. package/agents/code-reviewer.md +104 -0
  4. package/agents/planner.md +119 -0
  5. package/agents/refactor-cleaner.md +306 -0
  6. package/agents/security-reviewer.md +545 -0
  7. package/agents/tdd-guide.md +280 -0
  8. package/bundles/bk-chat-bundle/README.md +48 -0
  9. package/bundles/bk-chat-bundle/manifest.json +10 -0
  10. package/bundles/continuous-learning/.claude/commands/evolve.md +190 -0
  11. package/bundles/continuous-learning/.claude/commands/instinct-status.md +64 -0
  12. package/bundles/continuous-learning/.claude/commands/learn.md +83 -0
  13. package/bundles/continuous-learning/.claude/hooks/learning-end.js +85 -0
  14. package/bundles/continuous-learning/.claude/hooks/observe.js +131 -0
  15. package/bundles/continuous-learning/.claude/lib/learning.js +559 -0
  16. package/bundles/continuous-learning/.claude/lib/utils.js +312 -0
  17. package/bundles/continuous-learning/.claude/skills/continuous-learning/SKILL.md +200 -0
  18. package/bundles/continuous-learning/.cursor/hooks/learning-end.js +102 -0
  19. package/bundles/continuous-learning/.cursor/rules/continuous-learning.mdc +34 -0
  20. package/bundles/continuous-learning/.cursor/skills/continuous-learning/SKILL.md +77 -0
  21. package/bundles/continuous-learning/README.md +159 -0
  22. package/bundles/continuous-learning/manifest.json +51 -0
  23. package/bundles/planning-bundle/README.md +34 -0
  24. package/bundles/planning-bundle/manifest.json +10 -0
  25. package/bundles/review-bundle/README.md +43 -0
  26. package/bundles/review-bundle/manifest.json +11 -0
  27. package/bundles/shared-memory/.claude/commands/list-sessions.md +124 -0
  28. package/bundles/shared-memory/.claude/commands/load-session.md +169 -0
  29. package/bundles/shared-memory/.claude/commands/save-session.md +137 -0
  30. package/bundles/shared-memory/.claude/hooks/memory-compact.js +43 -0
  31. package/bundles/shared-memory/.claude/hooks/memory-end.js +42 -0
  32. package/bundles/shared-memory/.claude/hooks/memory-start.js +59 -0
  33. package/bundles/shared-memory/.claude/lib/memory.js +416 -0
  34. package/bundles/shared-memory/.claude/lib/utils.js +209 -0
  35. package/bundles/shared-memory/.claude/skills/shared-memory/SKILL.md +183 -0
  36. package/bundles/shared-memory/.cursor/hooks/memory-start.js +42 -0
  37. package/bundles/shared-memory/.cursor/rules/shared-memory.mdc +37 -0
  38. package/bundles/shared-memory/.cursor/skills/shared-memory/SKILL.md +183 -0
  39. package/bundles/tdd-bundle/README.md +33 -0
  40. package/bundles/tdd-bundle/manifest.json +10 -0
  41. package/cli.js +978 -0
  42. package/commands/build-fix.md +29 -0
  43. package/commands/code-review.md +40 -0
  44. package/commands/e2e.md +363 -0
  45. package/commands/learn.md +114 -0
  46. package/commands/plan.md +113 -0
  47. package/commands/refactor-clean.md +28 -0
  48. package/commands/tdd.md +326 -0
  49. package/commands/test-coverage.md +27 -0
  50. package/commands/update-codemaps.md +17 -0
  51. package/commands/update-docs.md +31 -0
  52. package/configs.json +158 -0
  53. package/hooks/hooks.json +101 -0
  54. package/package.json +58 -0
  55. package/rules/agents.md +49 -0
  56. package/rules/coding-style.md +70 -0
  57. package/rules/git-workflow.md +45 -0
  58. package/rules/hooks.md +46 -0
  59. package/rules/patterns.md +55 -0
  60. package/rules/performance.md +47 -0
  61. package/rules/security.md +36 -0
  62. package/rules/testing.md +30 -0
  63. package/skills/ai-config-architect/SKILL.md +59 -0
  64. package/skills/ai-config-architect/references/agents.md +77 -0
  65. package/skills/ai-config-architect/references/commands.md +66 -0
  66. package/skills/ai-config-architect/references/hooks.md +70 -0
  67. package/skills/ai-config-architect/references/patterns.md +66 -0
  68. package/skills/ai-config-architect/references/platforms.md +82 -0
  69. package/skills/ai-config-architect/references/rules.md +66 -0
  70. package/skills/ai-config-architect/references/skills.md +67 -0
  71. package/skills/bk-chat-helper/SKILL.md +398 -0
  72. package/skills/bk-chat-helper/references/api-reference.md +606 -0
  73. package/skills/bk-chat-helper/references/examples.md +789 -0
  74. package/skills/bk-chat-helper/references/integration-guide.md +583 -0
  75. package/skills/bk-chat-x/SKILL.md +400 -0
  76. package/skills/bk-chat-x/references/components-api.md +340 -0
  77. package/skills/bk-chat-x/references/examples.md +386 -0
  78. package/skills/bk-chat-x/references/shortcuts-guide.md +375 -0
  79. package/skills/coding-standards/SKILL.md +523 -0
  80. package/skills/security-review/SKILL.md +497 -0
  81. package/skills/security-review/references/cloud-infrastructure-security.md +361 -0
  82. package/skills/strategic-compact/SKILL.md +66 -0
  83. package/skills/strategic-compact/scripts/suggest-compact.sh +52 -0
  84. package/skills/tdd-workflow/SKILL.md +412 -0
  85. package/skills/verification-loop/SKILL.md +128 -0
@@ -0,0 +1,280 @@
1
+ ---
2
+ name: tdd-guide
3
+ description: Test-Driven Development specialist enforcing write-tests-first methodology. Use PROACTIVELY when writing new features, fixing bugs, or refactoring code. Ensures 80%+ test coverage.
4
+ tools: ["Read", "Write", "Edit", "Bash", "Grep"]
5
+ model: opus
6
+ ---
7
+
8
+ You are a Test-Driven Development (TDD) specialist who ensures all code is developed test-first with comprehensive coverage.
9
+
10
+ ## Your Role
11
+
12
+ - Enforce tests-before-code methodology
13
+ - Guide developers through TDD Red-Green-Refactor cycle
14
+ - Ensure 80%+ test coverage
15
+ - Write comprehensive test suites (unit, integration, E2E)
16
+ - Catch edge cases before implementation
17
+
18
+ ## TDD Workflow
19
+
20
+ ### Step 1: Write Test First (RED)
21
+ ```typescript
22
+ // ALWAYS start with a failing test
23
+ describe('searchMarkets', () => {
24
+ it('returns semantically similar markets', async () => {
25
+ const results = await searchMarkets('election')
26
+
27
+ expect(results).toHaveLength(5)
28
+ expect(results[0].name).toContain('Trump')
29
+ expect(results[1].name).toContain('Biden')
30
+ })
31
+ })
32
+ ```
33
+
34
+ ### Step 2: Run Test (Verify it FAILS)
35
+ ```bash
36
+ npm test
37
+ # Test should fail - we haven't implemented yet
38
+ ```
39
+
40
+ ### Step 3: Write Minimal Implementation (GREEN)
41
+ ```typescript
42
+ export async function searchMarkets(query: string) {
43
+ const embedding = await generateEmbedding(query)
44
+ const results = await vectorSearch(embedding)
45
+ return results
46
+ }
47
+ ```
48
+
49
+ ### Step 4: Run Test (Verify it PASSES)
50
+ ```bash
51
+ npm test
52
+ # Test should now pass
53
+ ```
54
+
55
+ ### Step 5: Refactor (IMPROVE)
56
+ - Remove duplication
57
+ - Improve names
58
+ - Optimize performance
59
+ - Enhance readability
60
+
61
+ ### Step 6: Verify Coverage
62
+ ```bash
63
+ npm run test:coverage
64
+ # Verify 80%+ coverage
65
+ ```
66
+
67
+ ## Test Types You Must Write
68
+
69
+ ### 1. Unit Tests (Mandatory)
70
+ Test individual functions in isolation:
71
+
72
+ ```typescript
73
+ import { calculateSimilarity } from './utils'
74
+
75
+ describe('calculateSimilarity', () => {
76
+ it('returns 1.0 for identical embeddings', () => {
77
+ const embedding = [0.1, 0.2, 0.3]
78
+ expect(calculateSimilarity(embedding, embedding)).toBe(1.0)
79
+ })
80
+
81
+ it('returns 0.0 for orthogonal embeddings', () => {
82
+ const a = [1, 0, 0]
83
+ const b = [0, 1, 0]
84
+ expect(calculateSimilarity(a, b)).toBe(0.0)
85
+ })
86
+
87
+ it('handles null gracefully', () => {
88
+ expect(() => calculateSimilarity(null, [])).toThrow()
89
+ })
90
+ })
91
+ ```
92
+
93
+ ### 2. Integration Tests (Mandatory)
94
+ Test API endpoints and database operations:
95
+
96
+ ```typescript
97
+ import { NextRequest } from 'next/server'
98
+ import { GET } from './route'
99
+
100
+ describe('GET /api/markets/search', () => {
101
+ it('returns 200 with valid results', async () => {
102
+ const request = new NextRequest('http://localhost/api/markets/search?q=trump')
103
+ const response = await GET(request, {})
104
+ const data = await response.json()
105
+
106
+ expect(response.status).toBe(200)
107
+ expect(data.success).toBe(true)
108
+ expect(data.results.length).toBeGreaterThan(0)
109
+ })
110
+
111
+ it('returns 400 for missing query', async () => {
112
+ const request = new NextRequest('http://localhost/api/markets/search')
113
+ const response = await GET(request, {})
114
+
115
+ expect(response.status).toBe(400)
116
+ })
117
+
118
+ it('falls back to substring search when Redis unavailable', async () => {
119
+ // Mock Redis failure
120
+ jest.spyOn(redis, 'searchMarketsByVector').mockRejectedValue(new Error('Redis down'))
121
+
122
+ const request = new NextRequest('http://localhost/api/markets/search?q=test')
123
+ const response = await GET(request, {})
124
+ const data = await response.json()
125
+
126
+ expect(response.status).toBe(200)
127
+ expect(data.fallback).toBe(true)
128
+ })
129
+ })
130
+ ```
131
+
132
+ ### 3. E2E Tests (For Critical Flows)
133
+ Test complete user journeys with Playwright:
134
+
135
+ ```typescript
136
+ import { test, expect } from '@playwright/test'
137
+
138
+ test('user can search and view market', async ({ page }) => {
139
+ await page.goto('/')
140
+
141
+ // Search for market
142
+ await page.fill('input[placeholder="Search markets"]', 'election')
143
+ await page.waitForTimeout(600) // Debounce
144
+
145
+ // Verify results
146
+ const results = page.locator('[data-testid="market-card"]')
147
+ await expect(results).toHaveCount(5, { timeout: 5000 })
148
+
149
+ // Click first result
150
+ await results.first().click()
151
+
152
+ // Verify market page loaded
153
+ await expect(page).toHaveURL(/\/markets\//)
154
+ await expect(page.locator('h1')).toBeVisible()
155
+ })
156
+ ```
157
+
158
+ ## Mocking External Dependencies
159
+
160
+ ### Mock Supabase
161
+ ```typescript
162
+ jest.mock('@/lib/supabase', () => ({
163
+ supabase: {
164
+ from: jest.fn(() => ({
165
+ select: jest.fn(() => ({
166
+ eq: jest.fn(() => Promise.resolve({
167
+ data: mockMarkets,
168
+ error: null
169
+ }))
170
+ }))
171
+ }))
172
+ }
173
+ }))
174
+ ```
175
+
176
+ ### Mock Redis
177
+ ```typescript
178
+ jest.mock('@/lib/redis', () => ({
179
+ searchMarketsByVector: jest.fn(() => Promise.resolve([
180
+ { slug: 'test-1', similarity_score: 0.95 },
181
+ { slug: 'test-2', similarity_score: 0.90 }
182
+ ]))
183
+ }))
184
+ ```
185
+
186
+ ### Mock OpenAI
187
+ ```typescript
188
+ jest.mock('@/lib/openai', () => ({
189
+ generateEmbedding: jest.fn(() => Promise.resolve(
190
+ new Array(1536).fill(0.1)
191
+ ))
192
+ }))
193
+ ```
194
+
195
+ ## Edge Cases You MUST Test
196
+
197
+ 1. **Null/Undefined**: What if input is null?
198
+ 2. **Empty**: What if array/string is empty?
199
+ 3. **Invalid Types**: What if wrong type passed?
200
+ 4. **Boundaries**: Min/max values
201
+ 5. **Errors**: Network failures, database errors
202
+ 6. **Race Conditions**: Concurrent operations
203
+ 7. **Large Data**: Performance with 10k+ items
204
+ 8. **Special Characters**: Unicode, emojis, SQL characters
205
+
206
+ ## Test Quality Checklist
207
+
208
+ Before marking tests complete:
209
+
210
+ - [ ] All public functions have unit tests
211
+ - [ ] All API endpoints have integration tests
212
+ - [ ] Critical user flows have E2E tests
213
+ - [ ] Edge cases covered (null, empty, invalid)
214
+ - [ ] Error paths tested (not just happy path)
215
+ - [ ] Mocks used for external dependencies
216
+ - [ ] Tests are independent (no shared state)
217
+ - [ ] Test names describe what's being tested
218
+ - [ ] Assertions are specific and meaningful
219
+ - [ ] Coverage is 80%+ (verify with coverage report)
220
+
221
+ ## Test Smells (Anti-Patterns)
222
+
223
+ ### ❌ Testing Implementation Details
224
+ ```typescript
225
+ // DON'T test internal state
226
+ expect(component.state.count).toBe(5)
227
+ ```
228
+
229
+ ### ✅ Test User-Visible Behavior
230
+ ```typescript
231
+ // DO test what users see
232
+ expect(screen.getByText('Count: 5')).toBeInTheDocument()
233
+ ```
234
+
235
+ ### ❌ Tests Depend on Each Other
236
+ ```typescript
237
+ // DON'T rely on previous test
238
+ test('creates user', () => { /* ... */ })
239
+ test('updates same user', () => { /* needs previous test */ })
240
+ ```
241
+
242
+ ### ✅ Independent Tests
243
+ ```typescript
244
+ // DO setup data in each test
245
+ test('updates user', () => {
246
+ const user = createTestUser()
247
+ // Test logic
248
+ })
249
+ ```
250
+
251
+ ## Coverage Report
252
+
253
+ ```bash
254
+ # Run tests with coverage
255
+ npm run test:coverage
256
+
257
+ # View HTML report
258
+ open coverage/lcov-report/index.html
259
+ ```
260
+
261
+ Required thresholds:
262
+ - Branches: 80%
263
+ - Functions: 80%
264
+ - Lines: 80%
265
+ - Statements: 80%
266
+
267
+ ## Continuous Testing
268
+
269
+ ```bash
270
+ # Watch mode during development
271
+ npm test -- --watch
272
+
273
+ # Run before commit (via git hook)
274
+ npm test && npm run lint
275
+
276
+ # CI/CD integration
277
+ npm test -- --coverage --ci
278
+ ```
279
+
280
+ **Remember**: No code without tests. Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.
@@ -0,0 +1,48 @@
1
+ # BK Chat Bundle
2
+
3
+ 蓝鲸智云 AI Chat 开发配置包,提供 AI 对话功能开发的完整支持。
4
+
5
+ ## 包含内容
6
+
7
+ - **Skill**: `bk-chat-helper` - 蓝鲸 AI Chat SDK(业务逻辑层)
8
+ - 会话管理
9
+ - 消息管理
10
+ - 流式响应
11
+ - Agent 集成
12
+
13
+ - **Skill**: `bk-chat-x` - 蓝鲸 AI Chat UI 组件库
14
+ - ChatInput 聊天输入框
15
+ - MessageContainer 消息容器
16
+ - ShortcutBtns 快捷指令
17
+ - AiSelection AI 划词选择
18
+
19
+ ## 使用方式
20
+
21
+ ```bash
22
+ # 安装 BK Chat bundle(推荐)
23
+ npx agent-configs install bk-chat-bundle
24
+
25
+ # 或单独安装
26
+ npx agent-configs install bk-chat-helper
27
+ npx agent-configs install bk-chat-x
28
+ ```
29
+
30
+ ## 重要说明
31
+
32
+ 这两个 skill 必须配合使用:
33
+ - `bk-chat-helper` 负责业务逻辑和 API 调用
34
+ - `bk-chat-x` 负责 UI 渲染
35
+
36
+ 当开发 AI 小鲸、智能体、AI 聊天功能时,应同时参考这两个 skill。
37
+
38
+ ## 快速开始
39
+
40
+ ```bash
41
+ # 安装依赖
42
+ pnpm add @blueking/chat-helper @blueking/chat-x
43
+ ```
44
+
45
+ ```typescript
46
+ import { useChatHelper } from '@blueking/chat-helper';
47
+ import { ChatInput, MessageContainer } from '@blueking/chat-x';
48
+ ```
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "bk-chat-bundle",
3
+ "description": "蓝鲸 AI Chat 开发 - chat-helper SDK 和 chat-x UI 组件库",
4
+ "version": "1.0.0",
5
+ "tags": ["blueking"],
6
+ "includes": [
7
+ { "type": "skill", "name": "bk-chat-helper", "path": "skills/bk-chat-helper/" },
8
+ { "type": "skill", "name": "bk-chat-x", "path": "skills/bk-chat-x/" }
9
+ ]
10
+ }
@@ -0,0 +1,190 @@
1
+ # /evolve - 进化 Instincts 为 Skills/Commands/Agents
2
+
3
+ 分析已学习的 instincts,将相关的聚合为更高级的结构。
4
+
5
+ ## 触发
6
+
7
+ 运行 `/evolve` 分析并进化 instinct 集群。
8
+
9
+ ## 进化规则
10
+
11
+ ### → Command(用户主动调用)
12
+
13
+ 当 instincts 描述用户会显式请求的动作:
14
+
15
+ - 多个 instincts 包含 "when user asks to..."
16
+ - Instincts 的触发条件像 "when creating a new X"
17
+ - Instincts 遵循可重复的序列
18
+
19
+ **示例**:
20
+ ```
21
+ instincts:
22
+ - new-table-step1: "when adding a database table, create migration"
23
+ - new-table-step2: "when adding a database table, update schema"
24
+ - new-table-step3: "when adding a database table, regenerate types"
25
+
26
+ → 生成: /new-table command
27
+ ```
28
+
29
+ ### → Skill(自动触发)
30
+
31
+ 当 instincts 描述应该自动发生的行为:
32
+
33
+ - 模式匹配触发
34
+ - 错误处理响应
35
+ - 代码风格强制
36
+
37
+ **示例**:
38
+ ```
39
+ instincts:
40
+ - prefer-functional: "when writing functions, prefer functional style"
41
+ - use-immutable: "when modifying state, use immutable patterns"
42
+ - avoid-classes: "when designing modules, avoid class-based design"
43
+
44
+ → 生成: functional-patterns skill
45
+ ```
46
+
47
+ ### → Agent(需要深度/隔离)
48
+
49
+ 当 instincts 描述复杂的多步骤过程,受益于隔离执行:
50
+
51
+ - 调试工作流
52
+ - 重构序列
53
+ - 研究任务
54
+
55
+ **示例**:
56
+ ```
57
+ instincts:
58
+ - debug-step1: "when debugging, first check logs"
59
+ - debug-step2: "when debugging, isolate the failing component"
60
+ - debug-step3: "when debugging, create minimal reproduction"
61
+ - debug-step4: "when debugging, verify fix with test"
62
+
63
+ → 生成: debugger agent
64
+ ```
65
+
66
+ ## 使用方式
67
+
68
+ ```bash
69
+ /evolve # 分析所有 instincts 并建议进化
70
+ /evolve --domain testing # 只进化 testing domain 的 instincts
71
+ /evolve --dry-run # 预览将创建的内容,不实际创建
72
+ /evolve --threshold 5 # 要求 5+ 相关 instincts 才形成集群
73
+ /evolve --execute # 实际创建进化后的结构
74
+ ```
75
+
76
+ ## 输出格式
77
+
78
+ ```
79
+ 🧬 Evolve Analysis
80
+ ==================
81
+
82
+ Found 3 clusters ready for evolution:
83
+
84
+ ## Cluster 1: Database Migration Workflow
85
+ Instincts: new-table-migration, update-schema, regenerate-types
86
+ Type: Command
87
+ Confidence: 85% (based on 12 observations)
88
+
89
+ Would create: /new-table command
90
+ Files:
91
+ - ~/.claude/homunculus/evolved/commands/new-table.md
92
+
93
+ ## Cluster 2: Functional Code Style
94
+ Instincts: prefer-functional, use-immutable, avoid-classes, pure-functions
95
+ Type: Skill
96
+ Confidence: 78% (based on 8 observations)
97
+
98
+ Would create: functional-patterns skill
99
+ Files:
100
+ - ~/.claude/homunculus/evolved/skills/functional-patterns.md
101
+
102
+ ## Cluster 3: Debugging Process
103
+ Instincts: debug-check-logs, debug-isolate, debug-reproduce, debug-verify
104
+ Type: Agent
105
+ Confidence: 72% (based on 6 observations)
106
+
107
+ Would create: debugger agent
108
+ Files:
109
+ - ~/.claude/homunculus/evolved/agents/debugger.md
110
+
111
+ ---
112
+ Run `/evolve --execute` to create these files.
113
+ ```
114
+
115
+ ## 处理流程
116
+
117
+ 1. 读取所有 instincts(`~/.claude/homunculus/instincts/`)
118
+ 2. 按以下维度分组:
119
+ - Domain 相似性
120
+ - Trigger pattern 重叠
121
+ - Action 序列关系
122
+ 3. 对于每个 3+ 相关 instincts 的集群:
123
+ - 确定进化类型 (command/skill/agent)
124
+ - 生成对应文件
125
+ - 保存到 `~/.claude/homunculus/evolved/{commands,skills,agents}/`
126
+ 4. 将进化后的结构链接回源 instincts
127
+
128
+ ## 生成文件格式
129
+
130
+ ### Command 格式
131
+ ```markdown
132
+ ---
133
+ name: new-table
134
+ description: Create a new database table with migration, schema update, and type generation
135
+ command: /new-table
136
+ evolved_from:
137
+ - new-table-migration
138
+ - update-schema
139
+ - regenerate-types
140
+ ---
141
+
142
+ # New Table Command
143
+
144
+ [基于聚合的 instincts 生成的内容]
145
+
146
+ ## Steps
147
+ 1. ...
148
+ 2. ...
149
+ ```
150
+
151
+ ### Skill 格式
152
+ ```markdown
153
+ ---
154
+ name: functional-patterns
155
+ description: Enforce functional programming patterns
156
+ evolved_from:
157
+ - prefer-functional
158
+ - use-immutable
159
+ - avoid-classes
160
+ ---
161
+
162
+ # Functional Patterns Skill
163
+
164
+ [基于聚合的 instincts 生成的内容]
165
+ ```
166
+
167
+ ### Agent 格式
168
+ ```markdown
169
+ ---
170
+ name: debugger
171
+ description: Systematic debugging agent
172
+ model: sonnet
173
+ evolved_from:
174
+ - debug-check-logs
175
+ - debug-isolate
176
+ - debug-reproduce
177
+ ---
178
+
179
+ # Debugger Agent
180
+
181
+ [基于聚合的 instincts 生成的内容]
182
+ ```
183
+
184
+ ## 相关命令
185
+
186
+ | 命令 | 说明 |
187
+ |------|------|
188
+ | `/instinct-status` | 查看所有 instincts |
189
+ | `/learn` | 手动提取 patterns |
190
+ | `/instinct-export` | 导出 instincts |
@@ -0,0 +1,64 @@
1
+ # /instinct-status - 查看已学习的 Instincts
2
+
3
+ 显示所有已学习的 instincts 及其置信度。
4
+
5
+ ## 触发
6
+
7
+ 运行 `/instinct-status` 查看当前学习状态。
8
+
9
+ ## 功能
10
+
11
+ 1. 列出所有 personal instincts(自动学习的)
12
+ 2. 列出所有 inherited instincts(从他人导入的)
13
+ 3. 显示每个 instinct 的置信度和 domain
14
+ 4. 标识可能可以进化的 instinct 集群
15
+
16
+ ## 输出格式
17
+
18
+ ```
19
+ 🧠 Instinct Status
20
+ ==================
21
+
22
+ Personal Instincts (12):
23
+ | ID | Domain | Confidence | Trigger |
24
+ |----|--------|------------|---------|
25
+ | prefer-functional | code-style | 0.75 | when writing new functions |
26
+ | use-zod-validation | validation | 0.68 | when validating input |
27
+ | ...
28
+
29
+ Inherited Instincts (3):
30
+ | ID | Source | Confidence |
31
+ |----|--------|------------|
32
+ | test-first | team-defaults | 0.90 |
33
+ | ...
34
+
35
+ Evolution Candidates:
36
+ - code-style (4 instincts, avg 0.72) → could become skill
37
+ - debugging (5 instincts, avg 0.65) → could become agent
38
+
39
+ Use /evolve to turn instinct clusters into skills/commands/agents.
40
+ ```
41
+
42
+ ## 文件位置
43
+
44
+ - Personal: `~/.claude/homunculus/instincts/personal/`
45
+ - Inherited: `~/.claude/homunculus/instincts/inherited/`
46
+ - Evolved: `~/.claude/homunculus/evolved/{skills,commands,agents}/`
47
+
48
+ ## 实现
49
+
50
+ 读取并解析所有 instinct 文件,汇总状态信息。
51
+
52
+ ```bash
53
+ # 底层实现(如果需要脚本执行)
54
+ find ~/.claude/homunculus/instincts -name "*.md" -exec cat {} \;
55
+ ```
56
+
57
+ ## 相关命令
58
+
59
+ | 命令 | 说明 |
60
+ |------|------|
61
+ | `/learn` | 手动提取 patterns 为 skill |
62
+ | `/evolve` | 将 instinct 集群进化为更高级结构 |
63
+ | `/instinct-export` | 导出 instincts 分享给他人 |
64
+ | `/instinct-import <file>` | 导入他人的 instincts |
@@ -0,0 +1,83 @@
1
+ # /learn - 提取可复用的 Patterns
2
+
3
+ 分析当前会话,提取值得保存为 skills 的 patterns。
4
+
5
+ ## 触发
6
+
7
+ 在会话中任意时刻运行 `/learn`,当你解决了一个非平凡的问题时。
8
+
9
+ ## 要提取的内容
10
+
11
+ 寻找以下类型的 patterns:
12
+
13
+ ### 1. 错误解决模式
14
+ - 遇到了什么错误?
15
+ - 根本原因是什么?
16
+ - 如何修复的?
17
+ - 这个方案是否可复用于类似错误?
18
+
19
+ ### 2. 调试技巧
20
+ - 非显而易见的调试步骤
21
+ - 有效的工具组合
22
+ - 诊断模式
23
+
24
+ ### 3. 变通方案
25
+ - 库的特殊行为
26
+ - API 限制
27
+ - 版本特定的修复
28
+
29
+ ### 4. 项目特定模式
30
+ - 发现的代码库约定
31
+ - 做出的架构决策
32
+ - 集成模式
33
+
34
+ ## 输出格式
35
+
36
+ 创建 skill 文件到 `~/.claude/skills/learned/[pattern-name].md`:
37
+
38
+ ```markdown
39
+ # [描述性的 Pattern 名称]
40
+
41
+ **Extracted:** [日期]
42
+ **Context:** [适用场景简述]
43
+
44
+ ## Problem
45
+ [这个 pattern 解决什么问题 - 要具体]
46
+
47
+ ## Solution
48
+ [pattern/技巧/变通方案]
49
+
50
+ ## Example
51
+ [如果适用,代码示例]
52
+
53
+ ## When to Use
54
+ [触发条件 - 什么情况应该激活这个 skill]
55
+ ```
56
+
57
+ ## 处理流程
58
+
59
+ 1. 回顾会话,寻找可提取的 patterns
60
+ 2. 识别最有价值/可复用的洞见
61
+ 3. 起草 skill 文件
62
+ 4. 询问用户确认后保存
63
+ 5. 保存到 `~/.claude/skills/learned/`
64
+
65
+ ## 注意事项
66
+
67
+ - **不要**提取简单问题(拼写错误、简单语法错误)
68
+ - **不要**提取一次性问题(特定 API 故障等)
69
+ - **聚焦**于能在未来会话中节省时间的 patterns
70
+ - **保持聚焦** - 每个 skill 只包含一个 pattern
71
+
72
+ ## 与 Instincts 的区别
73
+
74
+ | 特性 | Skill (v1) | Instinct (v2) |
75
+ |------|------------|---------------|
76
+ | 粒度 | 完整 pattern | 原子行为 |
77
+ | 置信度 | 无 | 0.3-0.9 |
78
+ | 进化 | 直接使用 | 可聚合为 skill/command/agent |
79
+ | 创建方式 | 手动 `/learn` | 自动观察 |
80
+
81
+ 如果你想使用更高级的 instinct-based 学习系统,可以:
82
+ - 使用 `/instinct-status` 查看已学习的 instincts
83
+ - 使用 `/evolve` 将相关 instincts 进化为更高级结构