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,326 @@
1
+ ---
2
+ description: Enforce test-driven development workflow. Scaffold interfaces, generate tests FIRST, then implement minimal code to pass. Ensure 80%+ coverage.
3
+ ---
4
+
5
+ # TDD Command
6
+
7
+ This command invokes the **tdd-guide** agent to enforce test-driven development methodology.
8
+
9
+ ## What This Command Does
10
+
11
+ 1. **Scaffold Interfaces** - Define types/interfaces first
12
+ 2. **Generate Tests First** - Write failing tests (RED)
13
+ 3. **Implement Minimal Code** - Write just enough to pass (GREEN)
14
+ 4. **Refactor** - Improve code while keeping tests green (REFACTOR)
15
+ 5. **Verify Coverage** - Ensure 80%+ test coverage
16
+
17
+ ## When to Use
18
+
19
+ Use `/tdd` when:
20
+ - Implementing new features
21
+ - Adding new functions/components
22
+ - Fixing bugs (write test that reproduces bug first)
23
+ - Refactoring existing code
24
+ - Building critical business logic
25
+
26
+ ## How It Works
27
+
28
+ The tdd-guide agent will:
29
+
30
+ 1. **Define interfaces** for inputs/outputs
31
+ 2. **Write tests that will FAIL** (because code doesn't exist yet)
32
+ 3. **Run tests** and verify they fail for the right reason
33
+ 4. **Write minimal implementation** to make tests pass
34
+ 5. **Run tests** and verify they pass
35
+ 6. **Refactor** code while keeping tests green
36
+ 7. **Check coverage** and add more tests if below 80%
37
+
38
+ ## TDD Cycle
39
+
40
+ ```
41
+ RED → GREEN → REFACTOR → REPEAT
42
+
43
+ RED: Write a failing test
44
+ GREEN: Write minimal code to pass
45
+ REFACTOR: Improve code, keep tests passing
46
+ REPEAT: Next feature/scenario
47
+ ```
48
+
49
+ ## Example Usage
50
+
51
+ ```
52
+ User: /tdd I need a function to calculate market liquidity score
53
+
54
+ Agent (tdd-guide):
55
+ # TDD Session: Market Liquidity Score Calculator
56
+
57
+ ## Step 1: Define Interface (SCAFFOLD)
58
+
59
+ ```typescript
60
+ // lib/liquidity.ts
61
+ export interface MarketData {
62
+ totalVolume: number
63
+ bidAskSpread: number
64
+ activeTraders: number
65
+ lastTradeTime: Date
66
+ }
67
+
68
+ export function calculateLiquidityScore(market: MarketData): number {
69
+ // TODO: Implementation
70
+ throw new Error('Not implemented')
71
+ }
72
+ ```
73
+
74
+ ## Step 2: Write Failing Test (RED)
75
+
76
+ ```typescript
77
+ // lib/liquidity.test.ts
78
+ import { calculateLiquidityScore } from './liquidity'
79
+
80
+ describe('calculateLiquidityScore', () => {
81
+ it('should return high score for liquid market', () => {
82
+ const market = {
83
+ totalVolume: 100000,
84
+ bidAskSpread: 0.01,
85
+ activeTraders: 500,
86
+ lastTradeTime: new Date()
87
+ }
88
+
89
+ const score = calculateLiquidityScore(market)
90
+
91
+ expect(score).toBeGreaterThan(80)
92
+ expect(score).toBeLessThanOrEqual(100)
93
+ })
94
+
95
+ it('should return low score for illiquid market', () => {
96
+ const market = {
97
+ totalVolume: 100,
98
+ bidAskSpread: 0.5,
99
+ activeTraders: 2,
100
+ lastTradeTime: new Date(Date.now() - 86400000) // 1 day ago
101
+ }
102
+
103
+ const score = calculateLiquidityScore(market)
104
+
105
+ expect(score).toBeLessThan(30)
106
+ expect(score).toBeGreaterThanOrEqual(0)
107
+ })
108
+
109
+ it('should handle edge case: zero volume', () => {
110
+ const market = {
111
+ totalVolume: 0,
112
+ bidAskSpread: 0,
113
+ activeTraders: 0,
114
+ lastTradeTime: new Date()
115
+ }
116
+
117
+ const score = calculateLiquidityScore(market)
118
+
119
+ expect(score).toBe(0)
120
+ })
121
+ })
122
+ ```
123
+
124
+ ## Step 3: Run Tests - Verify FAIL
125
+
126
+ ```bash
127
+ npm test lib/liquidity.test.ts
128
+
129
+ FAIL lib/liquidity.test.ts
130
+ ✕ should return high score for liquid market (2 ms)
131
+ Error: Not implemented
132
+
133
+ 1 test failed, 0 passed
134
+ ```
135
+
136
+ ✅ Tests fail as expected. Ready to implement.
137
+
138
+ ## Step 4: Implement Minimal Code (GREEN)
139
+
140
+ ```typescript
141
+ // lib/liquidity.ts
142
+ export function calculateLiquidityScore(market: MarketData): number {
143
+ // Handle zero volume edge case
144
+ if (market.totalVolume === 0) {
145
+ return 0
146
+ }
147
+
148
+ // Calculate component scores (0-100 scale)
149
+ const volumeScore = Math.min(market.totalVolume / 1000, 100)
150
+ const spreadScore = Math.max(100 - (market.bidAskSpread * 1000), 0)
151
+ const traderScore = Math.min(market.activeTraders / 10, 100)
152
+
153
+ // Recent activity bonus
154
+ const hoursSinceLastTrade = (Date.now() - market.lastTradeTime.getTime()) / (1000 * 60 * 60)
155
+ const recencyScore = Math.max(100 - (hoursSinceLastTrade * 10), 0)
156
+
157
+ // Weighted average
158
+ const score = (
159
+ volumeScore * 0.4 +
160
+ spreadScore * 0.3 +
161
+ traderScore * 0.2 +
162
+ recencyScore * 0.1
163
+ )
164
+
165
+ return Math.min(Math.max(score, 0), 100) // Clamp to 0-100
166
+ }
167
+ ```
168
+
169
+ ## Step 5: Run Tests - Verify PASS
170
+
171
+ ```bash
172
+ npm test lib/liquidity.test.ts
173
+
174
+ PASS lib/liquidity.test.ts
175
+ ✓ should return high score for liquid market (3 ms)
176
+ ✓ should return low score for illiquid market (2 ms)
177
+ ✓ should handle edge case: zero volume (1 ms)
178
+
179
+ 3 tests passed
180
+ ```
181
+
182
+ ✅ All tests passing!
183
+
184
+ ## Step 6: Refactor (IMPROVE)
185
+
186
+ ```typescript
187
+ // lib/liquidity.ts - Refactored with constants and better readability
188
+ const WEIGHTS = {
189
+ VOLUME: 0.4,
190
+ SPREAD: 0.3,
191
+ TRADERS: 0.2,
192
+ RECENCY: 0.1,
193
+ } as const
194
+
195
+ const SCALE_FACTORS = {
196
+ VOLUME: 1000,
197
+ SPREAD: 1000,
198
+ TRADERS: 10,
199
+ RECENCY_PENALTY: 10,
200
+ } as const
201
+
202
+ function clamp(value: number, min: number, max: number): number {
203
+ return Math.min(Math.max(value, min), max)
204
+ }
205
+
206
+ export function calculateLiquidityScore(market: MarketData): number {
207
+ if (market.totalVolume === 0) return 0
208
+
209
+ const volumeScore = Math.min(market.totalVolume / SCALE_FACTORS.VOLUME, 100)
210
+ const spreadScore = clamp(100 - (market.bidAskSpread * SCALE_FACTORS.SPREAD), 0, 100)
211
+ const traderScore = Math.min(market.activeTraders / SCALE_FACTORS.TRADERS, 100)
212
+
213
+ const hoursSinceLastTrade = (Date.now() - market.lastTradeTime.getTime()) / (1000 * 60 * 60)
214
+ const recencyScore = clamp(100 - (hoursSinceLastTrade * SCALE_FACTORS.RECENCY_PENALTY), 0, 100)
215
+
216
+ const weightedScore =
217
+ volumeScore * WEIGHTS.VOLUME +
218
+ spreadScore * WEIGHTS.SPREAD +
219
+ traderScore * WEIGHTS.TRADERS +
220
+ recencyScore * WEIGHTS.RECENCY
221
+
222
+ return clamp(weightedScore, 0, 100)
223
+ }
224
+ ```
225
+
226
+ ## Step 7: Verify Tests Still Pass
227
+
228
+ ```bash
229
+ npm test lib/liquidity.test.ts
230
+
231
+ PASS lib/liquidity.test.ts
232
+ ✓ should return high score for liquid market (3 ms)
233
+ ✓ should return low score for illiquid market (2 ms)
234
+ ✓ should handle edge case: zero volume (1 ms)
235
+
236
+ 3 tests passed
237
+ ```
238
+
239
+ ✅ Refactoring complete, tests still passing!
240
+
241
+ ## Step 8: Check Coverage
242
+
243
+ ```bash
244
+ npm test -- --coverage lib/liquidity.test.ts
245
+
246
+ File | % Stmts | % Branch | % Funcs | % Lines
247
+ ---------------|---------|----------|---------|--------
248
+ liquidity.ts | 100 | 100 | 100 | 100
249
+
250
+ Coverage: 100% ✅ (Target: 80%)
251
+ ```
252
+
253
+ ✅ TDD session complete!
254
+ ```
255
+
256
+ ## TDD Best Practices
257
+
258
+ **DO:**
259
+ - ✅ Write the test FIRST, before any implementation
260
+ - ✅ Run tests and verify they FAIL before implementing
261
+ - ✅ Write minimal code to make tests pass
262
+ - ✅ Refactor only after tests are green
263
+ - ✅ Add edge cases and error scenarios
264
+ - ✅ Aim for 80%+ coverage (100% for critical code)
265
+
266
+ **DON'T:**
267
+ - ❌ Write implementation before tests
268
+ - ❌ Skip running tests after each change
269
+ - ❌ Write too much code at once
270
+ - ❌ Ignore failing tests
271
+ - ❌ Test implementation details (test behavior)
272
+ - ❌ Mock everything (prefer integration tests)
273
+
274
+ ## Test Types to Include
275
+
276
+ **Unit Tests** (Function-level):
277
+ - Happy path scenarios
278
+ - Edge cases (empty, null, max values)
279
+ - Error conditions
280
+ - Boundary values
281
+
282
+ **Integration Tests** (Component-level):
283
+ - API endpoints
284
+ - Database operations
285
+ - External service calls
286
+ - React components with hooks
287
+
288
+ **E2E Tests** (use `/e2e` command):
289
+ - Critical user flows
290
+ - Multi-step processes
291
+ - Full stack integration
292
+
293
+ ## Coverage Requirements
294
+
295
+ - **80% minimum** for all code
296
+ - **100% required** for:
297
+ - Financial calculations
298
+ - Authentication logic
299
+ - Security-critical code
300
+ - Core business logic
301
+
302
+ ## Important Notes
303
+
304
+ **MANDATORY**: Tests must be written BEFORE implementation. The TDD cycle is:
305
+
306
+ 1. **RED** - Write failing test
307
+ 2. **GREEN** - Implement to pass
308
+ 3. **REFACTOR** - Improve code
309
+
310
+ Never skip the RED phase. Never write code before tests.
311
+
312
+ ## Integration with Other Commands
313
+
314
+ - Use `/plan` first to understand what to build
315
+ - Use `/tdd` to implement with tests
316
+ - Use `/build-and-fix` if build errors occur
317
+ - Use `/code-review` to review implementation
318
+ - Use `/test-coverage` to verify coverage
319
+
320
+ ## Related Agents
321
+
322
+ This command invokes the `tdd-guide` agent located at:
323
+ `~/.claude/agents/tdd-guide.md`
324
+
325
+ And can reference the `tdd-workflow` skill at:
326
+ `~/.claude/skills/tdd-workflow/`
@@ -0,0 +1,27 @@
1
+ # Test Coverage
2
+
3
+ Analyze test coverage and generate missing tests:
4
+
5
+ 1. Run tests with coverage: npm test --coverage or pnpm test --coverage
6
+
7
+ 2. Analyze coverage report (coverage/coverage-summary.json)
8
+
9
+ 3. Identify files below 80% coverage threshold
10
+
11
+ 4. For each under-covered file:
12
+ - Analyze untested code paths
13
+ - Generate unit tests for functions
14
+ - Generate integration tests for APIs
15
+ - Generate E2E tests for critical flows
16
+
17
+ 5. Verify new tests pass
18
+
19
+ 6. Show before/after coverage metrics
20
+
21
+ 7. Ensure project reaches 80%+ overall coverage
22
+
23
+ Focus on:
24
+ - Happy path scenarios
25
+ - Error handling
26
+ - Edge cases (null, undefined, empty)
27
+ - Boundary conditions
@@ -0,0 +1,17 @@
1
+ # Update Codemaps
2
+
3
+ Analyze the codebase structure and update architecture documentation:
4
+
5
+ 1. Scan all source files for imports, exports, and dependencies
6
+ 2. Generate token-lean codemaps in the following format:
7
+ - codemaps/architecture.md - Overall architecture
8
+ - codemaps/backend.md - Backend structure
9
+ - codemaps/frontend.md - Frontend structure
10
+ - codemaps/data.md - Data models and schemas
11
+
12
+ 3. Calculate diff percentage from previous version
13
+ 4. If changes > 30%, request user approval before updating
14
+ 5. Add freshness timestamp to each codemap
15
+ 6. Save reports to .reports/codemap-diff.txt
16
+
17
+ Use TypeScript/Node.js for analysis. Focus on high-level structure, not implementation details.
@@ -0,0 +1,31 @@
1
+ # Update Documentation
2
+
3
+ Sync documentation from source-of-truth:
4
+
5
+ 1. Read package.json scripts section
6
+ - Generate scripts reference table
7
+ - Include descriptions from comments
8
+
9
+ 2. Read .env.example
10
+ - Extract all environment variables
11
+ - Document purpose and format
12
+
13
+ 3. Generate docs/CONTRIB.md with:
14
+ - Development workflow
15
+ - Available scripts
16
+ - Environment setup
17
+ - Testing procedures
18
+
19
+ 4. Generate docs/RUNBOOK.md with:
20
+ - Deployment procedures
21
+ - Monitoring and alerts
22
+ - Common issues and fixes
23
+ - Rollback procedures
24
+
25
+ 5. Identify obsolete documentation:
26
+ - Find docs not modified in 90+ days
27
+ - List for manual review
28
+
29
+ 6. Show diff summary
30
+
31
+ Single source of truth: package.json and .env.example
package/configs.json ADDED
@@ -0,0 +1,158 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "defaultPlatform": "cursor",
4
+ "defaultScope": "project",
5
+ "categories": [
6
+ {
7
+ "id": "commands",
8
+ "name": "Commands",
9
+ "description": "斜杠命令,快速执行常用操作",
10
+ "platforms": ["claude", "cursor"],
11
+ "target": {
12
+ "claude": { "global": "~/.claude/commands/", "project": ".claude/commands/" },
13
+ "cursor": { "global": "~/.cursor/commands/", "project": ".cursor/commands/" }
14
+ },
15
+ "items": [
16
+ { "name": "plan", "description": "规划实现方案,WAIT 用户确认后执行", "path": "commands/plan.md", "featured": true },
17
+ { "name": "code-review", "description": "代码安全和质量审查", "path": "commands/code-review.md", "featured": true },
18
+ { "name": "tdd", "description": "TDD 工作流,测试先行", "path": "commands/tdd.md" },
19
+ { "name": "learn", "description": "提取可复用 patterns 为 skills", "path": "commands/learn.md" },
20
+ { "name": "refactor-clean", "description": "清理死代码和冗余文件", "path": "commands/refactor-clean.md" },
21
+ { "name": "e2e", "description": "Playwright E2E 测试", "path": "commands/e2e.md" },
22
+ { "name": "build-fix", "description": "构建错误自动修复", "path": "commands/build-fix.md" },
23
+ { "name": "test-coverage", "description": "测试覆盖率检查", "path": "commands/test-coverage.md" },
24
+ { "name": "update-docs", "description": "同步文档", "path": "commands/update-docs.md" },
25
+ { "name": "update-codemaps", "description": "更新架构文档", "path": "commands/update-codemaps.md" }
26
+ ]
27
+ },
28
+ {
29
+ "id": "skills",
30
+ "name": "Skills",
31
+ "description": "工作流定义和领域知识",
32
+ "platforms": ["claude", "cursor"],
33
+ "target": {
34
+ "claude": { "global": "~/.claude/skills/", "project": ".claude/skills/" },
35
+ "cursor": { "global": "~/.cursor/skills/", "project": ".cursor/skills/" }
36
+ },
37
+ "items": [
38
+ { "name": "ai-config-architect", "description": "AI 配置架构师 - 生成 rules/skills/commands/hooks/agents 配置,支持 Claude/Cursor 双平台", "path": "skills/ai-config-architect/", "featured": true },
39
+
40
+ { "name": "security-review", "description": "安全审查检查清单", "path": "skills/security-review/" },
41
+ { "name": "coding-standards", "description": "编码规范和风格指南", "path": "skills/coding-standards/" },
42
+ { "name": "verification-loop", "description": "验证循环模式", "path": "skills/verification-loop/" },
43
+ { "name": "strategic-compact", "description": "策略性上下文压缩", "path": "skills/strategic-compact/" },
44
+ { "name": "bk-chat-helper", "description": "蓝鲸 AI Chat SDK(业务逻辑层)", "path": "skills/bk-chat-helper/", "tags": ["blueking"] },
45
+ { "name": "bk-chat-x", "description": "蓝鲸 AI Chat UI 组件库", "path": "skills/bk-chat-x/", "tags": ["blueking"] },
46
+ { "name": "tdd-workflow", "description": "TDD 完整工作流和最佳实践", "path": "skills/tdd-workflow/" }
47
+ ]
48
+ },
49
+ {
50
+ "id": "rules",
51
+ "name": "Rules",
52
+ "description": "编码规范和最佳实践(仅 Cursor 项目级别)",
53
+ "platforms": ["cursor"],
54
+ "target": {
55
+ "cursor": { "project": ".cursor/rules/" }
56
+ },
57
+ "items": [
58
+ { "name": "security", "description": "安全检查清单", "path": "rules/security.md", "featured": true },
59
+ { "name": "coding-style", "description": "编码风格(不可变性、文件组织)", "path": "rules/coding-style.md" },
60
+ { "name": "testing", "description": "TDD、80% 覆盖率要求", "path": "rules/testing.md" },
61
+ { "name": "git-workflow", "description": "Git 提交规范", "path": "rules/git-workflow.md" },
62
+ { "name": "agents", "description": "子代理使用规范", "path": "rules/agents.md" },
63
+ { "name": "patterns", "description": "API 响应格式规范", "path": "rules/patterns.md" },
64
+ { "name": "performance", "description": "模型选择和上下文管理", "path": "rules/performance.md" },
65
+ { "name": "hooks", "description": "Hook 使用文档", "path": "rules/hooks.md" }
66
+ ]
67
+ },
68
+ {
69
+ "id": "agents",
70
+ "name": "Agents",
71
+ "description": "子代理定义",
72
+ "platforms": ["claude", "cursor"],
73
+ "target": {
74
+ "claude": { "global": "~/.claude/agents/", "project": ".claude/agents/" },
75
+ "cursor": { "global": "~/.cursor/agents/", "project": ".cursor/agents/" }
76
+ },
77
+ "items": [
78
+ { "name": "planner", "description": "功能规划专家", "path": "agents/planner.md", "featured": true },
79
+ { "name": "code-reviewer", "description": "代码审查专家", "path": "agents/code-reviewer.md", "featured": true },
80
+ { "name": "tdd-guide", "description": "TDD 指导专家", "path": "agents/tdd-guide.md" },
81
+ { "name": "architect", "description": "系统架构专家", "path": "agents/architect.md" },
82
+ { "name": "security-reviewer", "description": "安全审查专家", "path": "agents/security-reviewer.md" },
83
+ { "name": "refactor-cleaner", "description": "重构清理专家", "path": "agents/refactor-cleaner.md" }
84
+ ]
85
+ },
86
+ {
87
+ "id": "hooks",
88
+ "name": "Hooks",
89
+ "description": "自动化钩子配置",
90
+ "platforms": ["claude", "cursor"],
91
+ "isSpecial": true,
92
+ "items": [
93
+ {
94
+ "name": "hooks",
95
+ "description": "完整 hooks 配置(PreToolUse, PostToolUse, Stop)",
96
+ "files": {
97
+ "claude": [{ "source": "hooks/hooks.json", "target": ".claude/settings.json", "merge": true }],
98
+ "cursor": [{ "source": "hooks/hooks.json", "target": ".cursor/hooks.json", "merge": true }]
99
+ }
100
+ }
101
+ ]
102
+ },
103
+ {
104
+ "id": "bundles",
105
+ "name": "Bundles",
106
+ "description": "配置组合包",
107
+ "isBundle": true,
108
+ "items": [
109
+ {
110
+ "name": "shared-memory",
111
+ "description": "跨会话记忆管理系统",
112
+ "hasFiles": true,
113
+ "path": "bundles/shared-memory/",
114
+ "featured": true
115
+ },
116
+ {
117
+ "name": "tdd-bundle",
118
+ "description": "TDD 完整工作流",
119
+ "includes": ["commands/tdd", "skills/tdd-workflow", "agents/tdd-guide"],
120
+ "path": "bundles/tdd-bundle/"
121
+ },
122
+ {
123
+ "name": "review-bundle",
124
+ "description": "代码审查全套",
125
+ "includes": ["commands/code-review", "skills/security-review", "agents/code-reviewer", "agents/security-reviewer"],
126
+ "path": "bundles/review-bundle/",
127
+ "featured": true
128
+ },
129
+ {
130
+ "name": "planning-bundle",
131
+ "description": "规划和架构设计",
132
+ "includes": ["commands/plan", "agents/planner", "agents/architect"],
133
+ "path": "bundles/planning-bundle/",
134
+ "featured": true
135
+ },
136
+ {
137
+ "name": "bk-chat-bundle",
138
+ "description": "蓝鲸 AI Chat 开发",
139
+ "includes": ["skills/bk-chat-helper", "skills/bk-chat-x"],
140
+ "path": "bundles/bk-chat-bundle/",
141
+ "tags": ["blueking"]
142
+ },
143
+ {
144
+ "name": "continuous-learning",
145
+ "description": "持续学习 - 从会话中自动提取 patterns,保存为 skills/instincts",
146
+ "hasFiles": true,
147
+ "path": "bundles/continuous-learning/",
148
+ "featured": true
149
+ }
150
+ ]
151
+ }
152
+ ],
153
+ "presets": {
154
+ "minimal": ["commands/plan", "commands/code-review", "rules/security"],
155
+ "recommended": ["bundles/review-bundle", "bundles/planning-bundle", "rules/*"],
156
+ "full": ["*"]
157
+ }
158
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/claude-code-settings.json",
3
+ "hooks": {
4
+ "PreToolUse": [
5
+ {
6
+ "matcher": "tool == \"Bash\" && tool_input.command matches \"(npm run dev|pnpm( run)? dev|yarn dev|bun run dev)\"",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "node -e \"console.error('[Hook] BLOCKED: Dev server must run in tmux for log access');console.error('[Hook] Use: tmux new-session -d -s dev \\\"npm run dev\\\"');console.error('[Hook] Then: tmux attach -t dev');process.exit(1)\""
11
+ }
12
+ ],
13
+ "description": "Block dev servers outside tmux - ensures you can access logs"
14
+ },
15
+ {
16
+ "matcher": "tool == \"Bash\" && tool_input.command matches \"(npm (install|test)|pnpm (install|test)|yarn (install|test)?|bun (install|test)|cargo build|make|docker|pytest|vitest|playwright)\"",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "node -e \"if(!process.env.TMUX){console.error('[Hook] Consider running in tmux for session persistence');console.error('[Hook] tmux new -s dev | tmux attach -t dev')}\""
21
+ }
22
+ ],
23
+ "description": "Reminder to use tmux for long-running commands"
24
+ },
25
+ {
26
+ "matcher": "tool == \"Bash\" && tool_input.command matches \"git push\"",
27
+ "hooks": [
28
+ {
29
+ "type": "command",
30
+ "command": "node -e \"console.error('[Hook] Review changes before push...');console.error('[Hook] Continuing with push (remove this hook to add interactive review)')\""
31
+ }
32
+ ],
33
+ "description": "Reminder before git push to review changes"
34
+ },
35
+ {
36
+ "matcher": "tool == \"Write\" && tool_input.file_path matches \"\\\\.(md|txt)$\" && !(tool_input.file_path matches \"README\\\\.md|CLAUDE\\\\.md|AGENTS\\\\.md|CONTRIBUTING\\\\.md\")",
37
+ "hooks": [
38
+ {
39
+ "type": "command",
40
+ "command": "node -e \"const fs=require('fs');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const i=JSON.parse(d);const p=i.tool_input?.file_path||'';if(/\\.(md|txt)$/.test(p)&&!/(README|CLAUDE|AGENTS|CONTRIBUTING)\\.md$/.test(p)){console.error('[Hook] BLOCKED: Unnecessary documentation file creation');console.error('[Hook] File: '+p);console.error('[Hook] Use README.md for documentation instead');process.exit(1)}console.log(d)})\""
41
+ }
42
+ ],
43
+ "description": "Block creation of random .md files - keeps docs consolidated"
44
+ }
45
+ ],
46
+ "PostToolUse": [
47
+ {
48
+ "matcher": "tool == \"Bash\"",
49
+ "hooks": [
50
+ {
51
+ "type": "command",
52
+ "command": "node -e \"let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const i=JSON.parse(d);const cmd=i.tool_input?.command||'';if(/gh pr create/.test(cmd)){const out=i.tool_output?.output||'';const m=out.match(/https:\\/\\/github.com\\/[^/]+\\/[^/]+\\/pull\\/\\d+/);if(m){console.error('[Hook] PR created: '+m[0]);const repo=m[0].replace(/https:\\/\\/github.com\\/([^/]+\\/[^/]+)\\/pull\\/\\d+/,'$1');const pr=m[0].replace(/.*\\/pull\\/(\\d+)/,'$1');console.error('[Hook] To review: gh pr review '+pr+' --repo '+repo)}}console.log(d)})\""
53
+ }
54
+ ],
55
+ "description": "Log PR URL and provide review command after PR creation"
56
+ },
57
+ {
58
+ "matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx|js|jsx)$\"",
59
+ "hooks": [
60
+ {
61
+ "type": "command",
62
+ "command": "node -e \"const{execSync}=require('child_process');const fs=require('fs');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const i=JSON.parse(d);const p=i.tool_input?.file_path;if(p&&fs.existsSync(p)){try{execSync('npx prettier --write \"'+p+'\"',{stdio:['pipe','pipe','pipe']})}catch(e){}}console.log(d)})\""
63
+ }
64
+ ],
65
+ "description": "Auto-format JS/TS files with Prettier after edits"
66
+ },
67
+ {
68
+ "matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx)$\"",
69
+ "hooks": [
70
+ {
71
+ "type": "command",
72
+ "command": "node -e \"const{execSync}=require('child_process');const fs=require('fs');const path=require('path');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const i=JSON.parse(d);const p=i.tool_input?.file_path;if(p&&fs.existsSync(p)){let dir=path.dirname(p);while(dir!==path.dirname(dir)&&!fs.existsSync(path.join(dir,'tsconfig.json'))){dir=path.dirname(dir)}if(fs.existsSync(path.join(dir,'tsconfig.json'))){try{const r=execSync('npx tsc --noEmit --pretty false 2>&1',{cwd:dir,encoding:'utf8',stdio:['pipe','pipe','pipe']});const lines=r.split('\\n').filter(l=>l.includes(p)).slice(0,10);if(lines.length)console.error(lines.join('\\n'))}catch(e){const lines=(e.stdout||'').split('\\n').filter(l=>l.includes(p)).slice(0,10);if(lines.length)console.error(lines.join('\\n'))}}}console.log(d)})\""
73
+ }
74
+ ],
75
+ "description": "TypeScript check after editing .ts/.tsx files"
76
+ },
77
+ {
78
+ "matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx|js|jsx)$\"",
79
+ "hooks": [
80
+ {
81
+ "type": "command",
82
+ "command": "node -e \"const fs=require('fs');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const i=JSON.parse(d);const p=i.tool_input?.file_path;if(p&&fs.existsSync(p)){const c=fs.readFileSync(p,'utf8');const lines=c.split('\\n');const matches=[];lines.forEach((l,idx)=>{if(/console\\.log/.test(l))matches.push((idx+1)+': '+l.trim())});if(matches.length){console.error('[Hook] WARNING: console.log found in '+p);matches.slice(0,5).forEach(m=>console.error(m));console.error('[Hook] Remove console.log before committing')}}console.log(d)})\""
83
+ }
84
+ ],
85
+ "description": "Warn about console.log statements after edits"
86
+ }
87
+ ],
88
+ "Stop": [
89
+ {
90
+ "matcher": "*",
91
+ "hooks": [
92
+ {
93
+ "type": "command",
94
+ "command": "node -e \"const{execSync}=require('child_process');try{const r=execSync('git diff --name-only HEAD 2>/dev/null',{encoding:'utf8'});const files=r.split('\\n').filter(f=>/\\.(ts|tsx|js|jsx)$/.test(f));let found=[];for(const f of files){try{const c=require('fs').readFileSync(f,'utf8');const lines=c.split('\\n');lines.forEach((l,i)=>{if(/console\\.log/.test(l))found.push(f+':'+(i+1))});}catch(e){}}if(found.length){console.error('[Hook] WARNING: console.log found in modified files:');found.slice(0,5).forEach(m=>console.error(' '+m));}}catch(e){}\""
95
+ }
96
+ ],
97
+ "description": "Check for console.log in modified files after each response"
98
+ }
99
+ ]
100
+ }
101
+ }