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.
- package/README.md +223 -0
- package/agents/architect.md +211 -0
- package/agents/code-reviewer.md +104 -0
- package/agents/planner.md +119 -0
- package/agents/refactor-cleaner.md +306 -0
- package/agents/security-reviewer.md +545 -0
- package/agents/tdd-guide.md +280 -0
- package/bundles/bk-chat-bundle/README.md +48 -0
- package/bundles/bk-chat-bundle/manifest.json +10 -0
- package/bundles/continuous-learning/.claude/commands/evolve.md +190 -0
- package/bundles/continuous-learning/.claude/commands/instinct-status.md +64 -0
- package/bundles/continuous-learning/.claude/commands/learn.md +83 -0
- package/bundles/continuous-learning/.claude/hooks/learning-end.js +85 -0
- package/bundles/continuous-learning/.claude/hooks/observe.js +131 -0
- package/bundles/continuous-learning/.claude/lib/learning.js +559 -0
- package/bundles/continuous-learning/.claude/lib/utils.js +312 -0
- package/bundles/continuous-learning/.claude/skills/continuous-learning/SKILL.md +200 -0
- package/bundles/continuous-learning/.cursor/hooks/learning-end.js +102 -0
- package/bundles/continuous-learning/.cursor/rules/continuous-learning.mdc +34 -0
- package/bundles/continuous-learning/.cursor/skills/continuous-learning/SKILL.md +77 -0
- package/bundles/continuous-learning/README.md +159 -0
- package/bundles/continuous-learning/manifest.json +51 -0
- package/bundles/planning-bundle/README.md +34 -0
- package/bundles/planning-bundle/manifest.json +10 -0
- package/bundles/review-bundle/README.md +43 -0
- package/bundles/review-bundle/manifest.json +11 -0
- package/bundles/shared-memory/.claude/commands/list-sessions.md +124 -0
- package/bundles/shared-memory/.claude/commands/load-session.md +169 -0
- package/bundles/shared-memory/.claude/commands/save-session.md +137 -0
- package/bundles/shared-memory/.claude/hooks/memory-compact.js +43 -0
- package/bundles/shared-memory/.claude/hooks/memory-end.js +42 -0
- package/bundles/shared-memory/.claude/hooks/memory-start.js +59 -0
- package/bundles/shared-memory/.claude/lib/memory.js +416 -0
- package/bundles/shared-memory/.claude/lib/utils.js +209 -0
- package/bundles/shared-memory/.claude/skills/shared-memory/SKILL.md +183 -0
- package/bundles/shared-memory/.cursor/hooks/memory-start.js +42 -0
- package/bundles/shared-memory/.cursor/rules/shared-memory.mdc +37 -0
- package/bundles/shared-memory/.cursor/skills/shared-memory/SKILL.md +183 -0
- package/bundles/tdd-bundle/README.md +33 -0
- package/bundles/tdd-bundle/manifest.json +10 -0
- package/cli.js +978 -0
- package/commands/build-fix.md +29 -0
- package/commands/code-review.md +40 -0
- package/commands/e2e.md +363 -0
- package/commands/learn.md +114 -0
- package/commands/plan.md +113 -0
- package/commands/refactor-clean.md +28 -0
- package/commands/tdd.md +326 -0
- package/commands/test-coverage.md +27 -0
- package/commands/update-codemaps.md +17 -0
- package/commands/update-docs.md +31 -0
- package/configs.json +158 -0
- package/hooks/hooks.json +101 -0
- package/package.json +58 -0
- package/rules/agents.md +49 -0
- package/rules/coding-style.md +70 -0
- package/rules/git-workflow.md +45 -0
- package/rules/hooks.md +46 -0
- package/rules/patterns.md +55 -0
- package/rules/performance.md +47 -0
- package/rules/security.md +36 -0
- package/rules/testing.md +30 -0
- package/skills/ai-config-architect/SKILL.md +59 -0
- package/skills/ai-config-architect/references/agents.md +77 -0
- package/skills/ai-config-architect/references/commands.md +66 -0
- package/skills/ai-config-architect/references/hooks.md +70 -0
- package/skills/ai-config-architect/references/patterns.md +66 -0
- package/skills/ai-config-architect/references/platforms.md +82 -0
- package/skills/ai-config-architect/references/rules.md +66 -0
- package/skills/ai-config-architect/references/skills.md +67 -0
- package/skills/bk-chat-helper/SKILL.md +398 -0
- package/skills/bk-chat-helper/references/api-reference.md +606 -0
- package/skills/bk-chat-helper/references/examples.md +789 -0
- package/skills/bk-chat-helper/references/integration-guide.md +583 -0
- package/skills/bk-chat-x/SKILL.md +400 -0
- package/skills/bk-chat-x/references/components-api.md +340 -0
- package/skills/bk-chat-x/references/examples.md +386 -0
- package/skills/bk-chat-x/references/shortcuts-guide.md +375 -0
- package/skills/coding-standards/SKILL.md +523 -0
- package/skills/security-review/SKILL.md +497 -0
- package/skills/security-review/references/cloud-infrastructure-security.md +361 -0
- package/skills/strategic-compact/SKILL.md +66 -0
- package/skills/strategic-compact/scripts/suggest-compact.sh +52 -0
- package/skills/tdd-workflow/SKILL.md +412 -0
- package/skills/verification-loop/SKILL.md +128 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Continuous Learning - Stop Hook
|
|
4
|
+
*
|
|
5
|
+
* 触发时机:会话结束 (Stop hook)
|
|
6
|
+
* 功能:评估会话是否包含值得提取的 patterns
|
|
7
|
+
*
|
|
8
|
+
* 为什么使用 Stop hook 而非 UserPromptSubmit:
|
|
9
|
+
* - Stop 只在会话结束时运行一次(轻量)
|
|
10
|
+
* - UserPromptSubmit 在每条消息时运行(增加延迟)
|
|
11
|
+
* - Stop 时有完整的会话上下文
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const path = require('path');
|
|
15
|
+
|
|
16
|
+
// 使用本地 lib
|
|
17
|
+
const libPath = path.join(__dirname, '..', 'lib');
|
|
18
|
+
const { log, debug, getDateString } = require(path.join(libPath, 'utils'));
|
|
19
|
+
const {
|
|
20
|
+
DEFAULT_CONFIG,
|
|
21
|
+
shouldEvaluateSession,
|
|
22
|
+
getLearningStatus,
|
|
23
|
+
ensureLearningDirs
|
|
24
|
+
} = require(path.join(libPath, 'learning'));
|
|
25
|
+
|
|
26
|
+
async function main() {
|
|
27
|
+
try {
|
|
28
|
+
// 确保目录存在
|
|
29
|
+
ensureLearningDirs();
|
|
30
|
+
|
|
31
|
+
// 获取会话信息
|
|
32
|
+
const transcriptPath = process.env.CLAUDE_TRANSCRIPT_PATH || '';
|
|
33
|
+
const sessionId = process.env.CLAUDE_SESSION_ID || '';
|
|
34
|
+
|
|
35
|
+
if (!transcriptPath) {
|
|
36
|
+
// 没有 transcript 信息,静默退出
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 尝试读取 transcript 获取消息数
|
|
41
|
+
let messageCount = 0;
|
|
42
|
+
try {
|
|
43
|
+
const fs = require('fs');
|
|
44
|
+
if (fs.existsSync(transcriptPath)) {
|
|
45
|
+
const content = fs.readFileSync(transcriptPath, 'utf8');
|
|
46
|
+
// 简单计数 user 消息
|
|
47
|
+
const userMessages = (content.match(/"type"\s*:\s*"user"/g) || []).length;
|
|
48
|
+
messageCount = userMessages;
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
// 无法读取 transcript
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 检查是否应该评估
|
|
55
|
+
if (!shouldEvaluateSession(messageCount)) {
|
|
56
|
+
debug(`[ContinuousLearning] 会话较短 (${messageCount} 条消息),跳过评估`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 获取当前学习状态
|
|
61
|
+
const status = getLearningStatus();
|
|
62
|
+
|
|
63
|
+
// 输出提示信息
|
|
64
|
+
log(`[ContinuousLearning] 会话包含 ${messageCount} 条消息`);
|
|
65
|
+
log(`[ContinuousLearning] 当前已学习: ${status.v1.learnedSkillsCount} 个 skills, ${status.v2.instinctsCount} 个 instincts`);
|
|
66
|
+
|
|
67
|
+
// 如果有可进化的集群,提示用户
|
|
68
|
+
if (status.v2.evolvableClusters.length > 0) {
|
|
69
|
+
log(`[ContinuousLearning] 发现 ${status.v2.evolvableClusters.length} 个可进化的 instinct 集群`);
|
|
70
|
+
log(`[ContinuousLearning] 使用 /evolve 查看详情`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 提示用户可以使用 /learn 提取 patterns
|
|
74
|
+
log(`[ContinuousLearning] 如果本次会话有值得保存的 patterns,可以运行 /learn`);
|
|
75
|
+
|
|
76
|
+
} catch (err) {
|
|
77
|
+
debug(`[ContinuousLearning] Error: ${err.message}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main().catch(() => {
|
|
84
|
+
process.exit(0);
|
|
85
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Continuous Learning v2 - Observation Hook
|
|
4
|
+
*
|
|
5
|
+
* 触发时机:PreToolUse / PostToolUse
|
|
6
|
+
* 功能:捕获工具使用事件,用于 pattern 分析
|
|
7
|
+
*
|
|
8
|
+
* 为什么使用 hooks 而非 skills 进行观察:
|
|
9
|
+
* - Skills 是概率性的(~50-80% 触发率)
|
|
10
|
+
* - Hooks 是确定性的(100% 触发)
|
|
11
|
+
* - 这确保了不会遗漏任何 patterns
|
|
12
|
+
*
|
|
13
|
+
* Hook 配置 (在 settings.json 中):
|
|
14
|
+
* {
|
|
15
|
+
* "hooks": {
|
|
16
|
+
* "PreToolUse": [{
|
|
17
|
+
* "matcher": "*",
|
|
18
|
+
* "hooks": [{ "type": "command", "command": "node .claude/hooks/observe.js pre" }]
|
|
19
|
+
* }],
|
|
20
|
+
* "PostToolUse": [{
|
|
21
|
+
* "matcher": "*",
|
|
22
|
+
* "hooks": [{ "type": "command", "command": "node .claude/hooks/observe.js post" }]
|
|
23
|
+
* }]
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const path = require('path');
|
|
29
|
+
|
|
30
|
+
// 使用本地 lib
|
|
31
|
+
const libPath = path.join(__dirname, '..', 'lib');
|
|
32
|
+
const { debug, truncate } = require(path.join(libPath, 'utils'));
|
|
33
|
+
const {
|
|
34
|
+
DEFAULT_CONFIG,
|
|
35
|
+
recordObservation,
|
|
36
|
+
ensureLearningDirs
|
|
37
|
+
} = require(path.join(libPath, 'learning'));
|
|
38
|
+
|
|
39
|
+
// 获取 hook 类型参数
|
|
40
|
+
const hookType = process.argv[2] || 'unknown';
|
|
41
|
+
|
|
42
|
+
async function main() {
|
|
43
|
+
try {
|
|
44
|
+
// 确保目录存在
|
|
45
|
+
ensureLearningDirs();
|
|
46
|
+
|
|
47
|
+
// 读取 stdin (Claude Code 通过 stdin 传递 hook 数据)
|
|
48
|
+
let inputData = '';
|
|
49
|
+
|
|
50
|
+
// 设置超时,避免无限等待
|
|
51
|
+
const timeout = setTimeout(() => {
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}, 1000);
|
|
54
|
+
|
|
55
|
+
process.stdin.setEncoding('utf8');
|
|
56
|
+
|
|
57
|
+
for await (const chunk of process.stdin) {
|
|
58
|
+
inputData += chunk;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
clearTimeout(timeout);
|
|
62
|
+
|
|
63
|
+
if (!inputData.trim()) {
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 解析输入
|
|
68
|
+
let hookData;
|
|
69
|
+
try {
|
|
70
|
+
hookData = JSON.parse(inputData);
|
|
71
|
+
} catch {
|
|
72
|
+
debug('[ContinuousLearning] 无法解析 hook 数据');
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 提取相关字段
|
|
77
|
+
const toolName = hookData.tool_name || hookData.tool || 'unknown';
|
|
78
|
+
const toolInput = hookData.tool_input || hookData.input || {};
|
|
79
|
+
const toolOutput = hookData.tool_output || hookData.output || '';
|
|
80
|
+
const sessionId = hookData.session_id || process.env.CLAUDE_SESSION_ID || 'unknown';
|
|
81
|
+
|
|
82
|
+
// 检查是否应该忽略此工具
|
|
83
|
+
const config = DEFAULT_CONFIG.v2;
|
|
84
|
+
if (config.observation.ignore_tools.includes(toolName)) {
|
|
85
|
+
// 透传原始数据
|
|
86
|
+
console.log(inputData);
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 构建观察记录
|
|
91
|
+
const eventType = hookType === 'pre' ? 'tool_start' : 'tool_complete';
|
|
92
|
+
|
|
93
|
+
const observation = {
|
|
94
|
+
event: eventType,
|
|
95
|
+
tool: toolName,
|
|
96
|
+
session: sessionId
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// 添加输入/输出(截断过长内容)
|
|
100
|
+
if (eventType === 'tool_start' && toolInput) {
|
|
101
|
+
observation.input = truncate(
|
|
102
|
+
typeof toolInput === 'string' ? toolInput : JSON.stringify(toolInput),
|
|
103
|
+
5000
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (eventType === 'tool_complete' && toolOutput) {
|
|
108
|
+
observation.output = truncate(
|
|
109
|
+
typeof toolOutput === 'string' ? toolOutput : JSON.stringify(toolOutput),
|
|
110
|
+
5000
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 记录观察
|
|
115
|
+
recordObservation(observation);
|
|
116
|
+
|
|
117
|
+
// 透传原始数据(不阻塞 hook 链)
|
|
118
|
+
console.log(inputData);
|
|
119
|
+
|
|
120
|
+
} catch (err) {
|
|
121
|
+
debug(`[ContinuousLearning] Observe error: ${err.message}`);
|
|
122
|
+
// 确保在错误时也透传数据
|
|
123
|
+
process.stdout.write(process.stdin.read() || '');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
process.exit(0);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
main().catch(() => {
|
|
130
|
+
process.exit(0);
|
|
131
|
+
});
|