rules-enforcer 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 +58 -0
- package/detector/README.md +212 -0
- package/detector/decision-engine/README.md +203 -0
- package/detector/decision-engine/conflict-resolver.js +336 -0
- package/detector/decision-engine/de-verify.js +461 -0
- package/detector/decision-engine/index.js +204 -0
- package/detector/decision-engine/optimizer.js +325 -0
- package/detector/decision-engine/scorer.js +359 -0
- package/detector/knowledge-base/README.md +140 -0
- package/detector/knowledge-base/agent-knowledge.json +62 -0
- package/detector/knowledge-base/index.js +332 -0
- package/detector/knowledge-base/kb-verify.js +287 -0
- package/detector/knowledge-base/mcp-knowledge.json +135 -0
- package/detector/knowledge-base/rules-knowledge.json +184 -0
- package/detector/mcp-server.js +157 -0
- package/detector/mcp-service.js +118 -0
- package/detector/package.json +13 -0
- package/detector/plugin.json +122 -0
- package/detector/project-detector.js +710 -0
- package/detector/render-engine/ag-config-render.js +195 -0
- package/detector/render-engine/index.js +124 -0
- package/detector/render-engine/render-core.js +200 -0
- package/detector/render-engine/render-verify.js +282 -0
- package/detector/render-engine/rule-render.js +231 -0
- package/detector/test-exceptions.js +366 -0
- package/detector/verify-plugin.js +233 -0
- package/hooks/chain-invoker.js +98 -0
- package/hooks/custom-hook-server.js +312 -0
- package/hooks/mcp-hooks.js +153 -0
- package/hooks/validate-chain.js +147 -0
- package/package.json +35 -0
- package/rules-server.js +350 -0
- package/test/test-mcp-full.js +193 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Base Verification Script
|
|
3
|
+
* 知识库自检脚本:文件完整性、JSON格式、接口可用性、跨插件调用
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
class KBVerifier {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.kbDir = path.join(__dirname);
|
|
12
|
+
this.results = [];
|
|
13
|
+
this.passed = 0;
|
|
14
|
+
this.failed = 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 记录测试结果
|
|
19
|
+
*/
|
|
20
|
+
log(type, message, status) {
|
|
21
|
+
const icon = status === 'PASS' ? '✅' : '❌';
|
|
22
|
+
const log = `${icon} [${type}] ${message}`;
|
|
23
|
+
this.results.push({ type, message, status });
|
|
24
|
+
console.log(log);
|
|
25
|
+
if (status === 'PASS') this.passed++;
|
|
26
|
+
else this.failed++;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 验证1: 文件完整性
|
|
31
|
+
*/
|
|
32
|
+
verifyFileIntegrity() {
|
|
33
|
+
console.log('\n[1] 验证文件完整性...');
|
|
34
|
+
|
|
35
|
+
const requiredFiles = [
|
|
36
|
+
'mcp-knowledge.json',
|
|
37
|
+
'agent-knowledge.json',
|
|
38
|
+
'rules-knowledge.json',
|
|
39
|
+
'index.js'
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
for (const file of requiredFiles) {
|
|
43
|
+
const filePath = path.join(this.kbDir, file);
|
|
44
|
+
if (fs.existsSync(filePath)) {
|
|
45
|
+
const stats = fs.statSync(filePath);
|
|
46
|
+
this.log('FILE', `${file} 存在 (${stats.size} bytes)`, 'PASS');
|
|
47
|
+
} else {
|
|
48
|
+
this.log('FILE', `${file} 不存在`, 'FAIL');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 验证2: JSON格式
|
|
55
|
+
*/
|
|
56
|
+
verifyJsonFormat() {
|
|
57
|
+
console.log('\n[2] 验证JSON格式...');
|
|
58
|
+
|
|
59
|
+
const jsonFiles = [
|
|
60
|
+
'mcp-knowledge.json',
|
|
61
|
+
'agent-knowledge.json',
|
|
62
|
+
'rules-knowledge.json'
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
for (const file of jsonFiles) {
|
|
66
|
+
const filePath = path.join(this.kbDir, file);
|
|
67
|
+
|
|
68
|
+
if (!fs.existsSync(filePath)) {
|
|
69
|
+
this.log('JSON', `${file} 不存在`, 'FAIL');
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
75
|
+
JSON.parse(content);
|
|
76
|
+
this.log('JSON', `${file} 格式正确`, 'PASS');
|
|
77
|
+
} catch (e) {
|
|
78
|
+
this.log('JSON', `${file} 格式错误: ${e.message}`, 'FAIL');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 验证3: 接口可用性
|
|
85
|
+
*/
|
|
86
|
+
verifyInterface() {
|
|
87
|
+
console.log('\n[3] 验证接口可用性...');
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const { KnowledgeBase } = require('./index.js');
|
|
91
|
+
const kb = new KnowledgeBase(this.kbDir);
|
|
92
|
+
|
|
93
|
+
// 测试load
|
|
94
|
+
kb.load();
|
|
95
|
+
this.log('INTERFACE', 'load() 方法可用', 'PASS');
|
|
96
|
+
|
|
97
|
+
// 测试getMetadata
|
|
98
|
+
const metadata = kb.getMetadata();
|
|
99
|
+
if (metadata && metadata.mcp && metadata.agent && metadata.rules) {
|
|
100
|
+
this.log('INTERFACE', 'getMetadata() 返回有效数据', 'PASS');
|
|
101
|
+
} else {
|
|
102
|
+
this.log('INTERFACE', 'getMetadata() 返回数据无效', 'FAIL');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 测试listMcpServices
|
|
106
|
+
const mcpList = kb.listMcpServices();
|
|
107
|
+
if (Array.isArray(mcpList) && mcpList.length > 0) {
|
|
108
|
+
this.log('INTERFACE', `listMcpServices() 返回 ${mcpList.length} 个服务`, 'PASS');
|
|
109
|
+
} else {
|
|
110
|
+
this.log('INTERFACE', 'listMcpServices() 返回空数组', 'FAIL');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 测试listRules
|
|
114
|
+
const rulesList = kb.listRules();
|
|
115
|
+
if (Array.isArray(rulesList) && rulesList.length > 0) {
|
|
116
|
+
this.log('INTERFACE', `listRules() 返回 ${rulesList.length} 条规则`, 'PASS');
|
|
117
|
+
} else {
|
|
118
|
+
this.log('INTERFACE', 'listRules() 返回空数组', 'FAIL');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 测试getMcpService
|
|
122
|
+
const mcpService = kb.getMcpService('rules-enforcer');
|
|
123
|
+
if (mcpService && mcpService.name) {
|
|
124
|
+
this.log('INTERFACE', `getMcpService('rules-enforcer') 返回: ${mcpService.name}`, 'PASS');
|
|
125
|
+
} else {
|
|
126
|
+
this.log('INTERFACE', "getMcpService('rules-enforcer') 返回无效", 'FAIL');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 测试getRule
|
|
130
|
+
const rule = kb.getRule('L1-user-rules');
|
|
131
|
+
if (rule && rule.name) {
|
|
132
|
+
this.log('INTERFACE', `getRule('L1-user-rules') 返回: ${rule.name}`, 'PASS');
|
|
133
|
+
} else {
|
|
134
|
+
this.log('INTERFACE', "getRule('L1-user-rules') 返回无效", 'FAIL');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
} catch (e) {
|
|
138
|
+
this.log('INTERFACE', `接口测试失败: ${e.message}`, 'FAIL');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 验证4: 跨插件调用
|
|
144
|
+
*/
|
|
145
|
+
verifyCrossPlugin() {
|
|
146
|
+
console.log('\n[4] 验证跨插件调用...');
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
// 测试与project-detector的对接
|
|
150
|
+
const { ProjectDetector } = require('../project-detector.js');
|
|
151
|
+
const { KnowledgeBase } = require('./index.js');
|
|
152
|
+
|
|
153
|
+
const detector = new ProjectDetector(process.cwd());
|
|
154
|
+
detector.scan();
|
|
155
|
+
|
|
156
|
+
const kb = new KnowledgeBase(this.kbDir);
|
|
157
|
+
const report = detector.getReport();
|
|
158
|
+
|
|
159
|
+
// 生成推荐
|
|
160
|
+
const recommendations = kb.generateRecommendations(report);
|
|
161
|
+
|
|
162
|
+
if (recommendations && recommendations.recommendations) {
|
|
163
|
+
this.log('CROSS', 'generateRecommendations() 调用成功', 'PASS');
|
|
164
|
+
|
|
165
|
+
if (recommendations.recommendations.newMcpServices) {
|
|
166
|
+
this.log('CROSS', `推荐MCP数量: ${recommendations.recommendations.newMcpServices.length}`, 'PASS');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (recommendations.recommendations.newRules) {
|
|
170
|
+
this.log('CROSS', `推荐规则数量: ${recommendations.recommendations.newRules.length}`, 'PASS');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (recommendations.recommendations.agentProfile) {
|
|
174
|
+
this.log('CROSS', `Agent推荐: ${recommendations.recommendations.agentProfile.name}`, 'PASS');
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
this.log('CROSS', 'generateRecommendations() 返回无效', 'FAIL');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// 测试recommendMCP
|
|
181
|
+
const mcpRec = kb.recommendMCP(['Node.js', 'Express.js']);
|
|
182
|
+
if (mcpRec && mcpRec.length > 0) {
|
|
183
|
+
this.log('CROSS', `recommendMCP(['Node.js', 'Express.js']) 返回 ${mcpRec.length} 个推荐`, 'PASS');
|
|
184
|
+
} else {
|
|
185
|
+
this.log('CROSS', 'recommendMCP() 返回空数组', 'FAIL');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 测试recommendRules
|
|
189
|
+
const rulesRec = kb.recommendRules('medium', []);
|
|
190
|
+
if (rulesRec && rulesRec.length > 0) {
|
|
191
|
+
this.log('CROSS', `recommendRules('medium') 返回 ${rulesRec.length} 个推荐`, 'PASS');
|
|
192
|
+
} else {
|
|
193
|
+
this.log('CROSS', 'recommendRules() 返回空数组', 'FAIL');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 测试recommendAgent
|
|
197
|
+
const agentRec = kb.recommendAgent(['Node.js', 'Express.js']);
|
|
198
|
+
if (agentRec) {
|
|
199
|
+
this.log('CROSS', `recommendAgent() 返回: ${agentRec.name}`, 'PASS');
|
|
200
|
+
} else {
|
|
201
|
+
this.log('CROSS', 'recommendAgent() 返回null', 'FAIL');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
} catch (e) {
|
|
205
|
+
this.log('CROSS', `跨插件调用失败: ${e.message}`, 'FAIL');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 验证5: 数据一致性
|
|
211
|
+
*/
|
|
212
|
+
verifyDataConsistency() {
|
|
213
|
+
console.log('\n[5] 验证数据一致性...');
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
const { KnowledgeBase } = require('./index.js');
|
|
217
|
+
const kb = new KnowledgeBase(this.kbDir);
|
|
218
|
+
kb.load();
|
|
219
|
+
|
|
220
|
+
// 检查MCP服务是否包含必要字段
|
|
221
|
+
const mcpServices = kb.mcpKnowledge.mcpServices;
|
|
222
|
+
for (const [id, service] of Object.entries(mcpServices)) {
|
|
223
|
+
const required = ['id', 'name', 'type', 'features', 'techStackMatch'];
|
|
224
|
+
for (const field of required) {
|
|
225
|
+
if (!service[field]) {
|
|
226
|
+
this.log('CONSISTENCY', `MCP服务 ${id} 缺少字段: ${field}`, 'FAIL');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
this.log('CONSISTENCY', `MCP服务数据结构一致 (${Object.keys(mcpServices).length} 个服务)`, 'PASS');
|
|
231
|
+
|
|
232
|
+
// 检查规则是否包含必要字段
|
|
233
|
+
const rules = kb.rulesKnowledge.rules;
|
|
234
|
+
for (const [id, rule] of Object.entries(rules)) {
|
|
235
|
+
const required = ['id', 'name', 'level', 'type'];
|
|
236
|
+
for (const field of required) {
|
|
237
|
+
if (!rule[field]) {
|
|
238
|
+
this.log('CONSISTENCY', `规则 ${id} 缺少字段: ${field}`, 'FAIL');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
this.log('CONSISTENCY', `规则数据结构一致 (${Object.keys(rules).length} 条规则)`, 'PASS');
|
|
243
|
+
|
|
244
|
+
// 检查metadata
|
|
245
|
+
const metadata = kb.getMetadata();
|
|
246
|
+
if (metadata.mcp.totalServices === Object.keys(mcpServices).length) {
|
|
247
|
+
this.log('CONSISTENCY', 'MCP metadata.totalServices 一致', 'PASS');
|
|
248
|
+
} else {
|
|
249
|
+
this.log('CONSISTENCY', 'MCP metadata.totalServices 不一致', 'FAIL');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
} catch (e) {
|
|
253
|
+
this.log('CONSISTENCY', `数据一致性检查失败: ${e.message}`, 'FAIL');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 执行全部验证
|
|
259
|
+
*/
|
|
260
|
+
verifyAll() {
|
|
261
|
+
console.log('===========================================');
|
|
262
|
+
console.log(' Knowledge Base Verification');
|
|
263
|
+
console.log('===========================================');
|
|
264
|
+
|
|
265
|
+
this.verifyFileIntegrity();
|
|
266
|
+
this.verifyJsonFormat();
|
|
267
|
+
this.verifyInterface();
|
|
268
|
+
this.verifyCrossPlugin();
|
|
269
|
+
this.verifyDataConsistency();
|
|
270
|
+
|
|
271
|
+
console.log('\n===========================================');
|
|
272
|
+
console.log(` 验证结果: ${this.passed} 通过, ${this.failed} 失败`);
|
|
273
|
+
console.log('===========================================');
|
|
274
|
+
|
|
275
|
+
if (this.failed > 0) {
|
|
276
|
+
console.log('\n❌ 知识库验证未全部通过,请检查上述失败项');
|
|
277
|
+
process.exit(1);
|
|
278
|
+
} else {
|
|
279
|
+
console.log('\n✅ 知识库验证全部通过!');
|
|
280
|
+
process.exit(0);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// 执行验证
|
|
286
|
+
const verifier = new KBVerifier();
|
|
287
|
+
verifier.verifyAll();
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServices": {
|
|
3
|
+
"rules-enforcer": {
|
|
4
|
+
"id": "rules-enforcer",
|
|
5
|
+
"name": "Rules Enforcer",
|
|
6
|
+
"type": "rules-engine",
|
|
7
|
+
"description": "规则引擎校验服务,提供规则加载、验证、执行能力",
|
|
8
|
+
"features": [
|
|
9
|
+
"rule-loading",
|
|
10
|
+
"validation",
|
|
11
|
+
"rule-execution",
|
|
12
|
+
"attention-optimization",
|
|
13
|
+
"l1-rules",
|
|
14
|
+
"l2-rules",
|
|
15
|
+
"l3-rules"
|
|
16
|
+
],
|
|
17
|
+
"techStackMatch": [
|
|
18
|
+
"javascript",
|
|
19
|
+
"typescript",
|
|
20
|
+
"node.js",
|
|
21
|
+
"express.js"
|
|
22
|
+
],
|
|
23
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
24
|
+
"dependencies": [],
|
|
25
|
+
"configPatterns": {
|
|
26
|
+
"entryPoint": "src/mcp/rules-server.js",
|
|
27
|
+
"configFile": ".trae/mcp/mcp.json"
|
|
28
|
+
},
|
|
29
|
+
"keywords": ["rules", "validation", "enforcement", "attention", "optimization"]
|
|
30
|
+
},
|
|
31
|
+
"custom-hooks": {
|
|
32
|
+
"id": "custom-hooks",
|
|
33
|
+
"name": "Custom Hooks",
|
|
34
|
+
"type": "hook-gateway",
|
|
35
|
+
"description": "MCP网关钩子服务,提供自定义钩子执行能力",
|
|
36
|
+
"features": [
|
|
37
|
+
"hook-execution",
|
|
38
|
+
"pre-processing",
|
|
39
|
+
"post-processing",
|
|
40
|
+
"mcp-gateway"
|
|
41
|
+
],
|
|
42
|
+
"techStackMatch": [
|
|
43
|
+
"javascript",
|
|
44
|
+
"typescript",
|
|
45
|
+
"node.js"
|
|
46
|
+
],
|
|
47
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
48
|
+
"dependencies": [],
|
|
49
|
+
"configPatterns": {
|
|
50
|
+
"entryPoint": ".trae/mcp/custom_hook/custom-hook-server.js",
|
|
51
|
+
"configFile": ".trae/mcp/mcp.json"
|
|
52
|
+
},
|
|
53
|
+
"keywords": ["hooks", "gateway", "custom", "mcp"]
|
|
54
|
+
},
|
|
55
|
+
"context7": {
|
|
56
|
+
"id": "context7",
|
|
57
|
+
"name": "Context7",
|
|
58
|
+
"type": "context-management",
|
|
59
|
+
"description": "上下文管理服务,提供文档检索和上下文管理",
|
|
60
|
+
"features": [
|
|
61
|
+
"context-retrieval",
|
|
62
|
+
"document-search",
|
|
63
|
+
"context-window"
|
|
64
|
+
],
|
|
65
|
+
"techStackMatch": [
|
|
66
|
+
"javascript",
|
|
67
|
+
"typescript",
|
|
68
|
+
"python",
|
|
69
|
+
"any"
|
|
70
|
+
],
|
|
71
|
+
"projectSizeRange": ["medium", "large"],
|
|
72
|
+
"dependencies": [],
|
|
73
|
+
"configPatterns": {
|
|
74
|
+
"configFile": ".trae/mcp/mcp.json"
|
|
75
|
+
},
|
|
76
|
+
"keywords": ["context", "retrieval", "documents", "search"]
|
|
77
|
+
},
|
|
78
|
+
"sequential-thinking": {
|
|
79
|
+
"id": "sequential-thinking",
|
|
80
|
+
"name": "Sequential Thinking",
|
|
81
|
+
"type": "thinking-chain",
|
|
82
|
+
"description": "链式思维服务,提供顺序推理和思考链管理",
|
|
83
|
+
"features": [
|
|
84
|
+
"thinking-chain",
|
|
85
|
+
"sequential-reasoning",
|
|
86
|
+
"problem-solving"
|
|
87
|
+
],
|
|
88
|
+
"techStackMatch": [
|
|
89
|
+
"javascript",
|
|
90
|
+
"typescript",
|
|
91
|
+
"any"
|
|
92
|
+
],
|
|
93
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
94
|
+
"dependencies": [],
|
|
95
|
+
"configPatterns": {
|
|
96
|
+
"configFile": ".trae/mcp/mcp.json"
|
|
97
|
+
},
|
|
98
|
+
"keywords": ["thinking", "reasoning", "chain", "sequential"]
|
|
99
|
+
},
|
|
100
|
+
"project-detector": {
|
|
101
|
+
"id": "project-detector",
|
|
102
|
+
"name": "Project Detector",
|
|
103
|
+
"type": "project-scanner",
|
|
104
|
+
"description": "项目探测工具,扫描技术栈、目录拓扑、已有组件",
|
|
105
|
+
"features": [
|
|
106
|
+
"tech-stack-detection",
|
|
107
|
+
"directory-topology",
|
|
108
|
+
"component-scan",
|
|
109
|
+
"complexity-assessment"
|
|
110
|
+
],
|
|
111
|
+
"techStackMatch": [
|
|
112
|
+
"javascript",
|
|
113
|
+
"typescript",
|
|
114
|
+
"node.js",
|
|
115
|
+
"python",
|
|
116
|
+
"go",
|
|
117
|
+
"rust",
|
|
118
|
+
"java",
|
|
119
|
+
"any"
|
|
120
|
+
],
|
|
121
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
122
|
+
"dependencies": [],
|
|
123
|
+
"configPatterns": {
|
|
124
|
+
"entryPoint": ".trae/plugins/project-detector/project-detector.js",
|
|
125
|
+
"configFile": ".trae/plugins/project-detector/plugin.json"
|
|
126
|
+
},
|
|
127
|
+
"keywords": ["project", "detector", "scan", "tech-stack", "topology"]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"metadata": {
|
|
131
|
+
"version": "1.0.0",
|
|
132
|
+
"lastUpdated": "2026-06-05",
|
|
133
|
+
"totalServices": 5
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": {
|
|
3
|
+
"L1-user-rules": {
|
|
4
|
+
"id": "L1-user-rules",
|
|
5
|
+
"name": "User Rules (L1)",
|
|
6
|
+
"level": "L1",
|
|
7
|
+
"type": "global-behavior",
|
|
8
|
+
"description": "用户全局行为约束,定义代码生成、调试、沟通风格等基础规则",
|
|
9
|
+
"appliesTo": ["all-projects"],
|
|
10
|
+
"techStackMatch": ["any"],
|
|
11
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
12
|
+
"keywords": ["global", "behavior", "coding", "style"],
|
|
13
|
+
"priority": 100
|
|
14
|
+
},
|
|
15
|
+
"L2-project-rules": {
|
|
16
|
+
"id": "L2-project-rules",
|
|
17
|
+
"name": "Project Rules (L2)",
|
|
18
|
+
"level": "L2",
|
|
19
|
+
"type": "project-specific",
|
|
20
|
+
"description": "项目特定规则,定义目录结构、命名规范、技术栈约束",
|
|
21
|
+
"appliesTo": ["current-project"],
|
|
22
|
+
"techStackMatch": ["node.js", "typescript", "express.js"],
|
|
23
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
24
|
+
"keywords": ["project", "structure", "naming", "convention"],
|
|
25
|
+
"priority": 200
|
|
26
|
+
},
|
|
27
|
+
"L3-RZero-agents": {
|
|
28
|
+
"id": "L3-RZero-agents",
|
|
29
|
+
"name": "RZero Agent Configuration",
|
|
30
|
+
"level": "L3",
|
|
31
|
+
"module": "RZero",
|
|
32
|
+
"type": "agent-config",
|
|
33
|
+
"description": "R-Zero双Agent博弈架构配置,定义Challenger和Solver角色",
|
|
34
|
+
"appliesTo": ["self-evolution"],
|
|
35
|
+
"techStackMatch": ["any"],
|
|
36
|
+
"projectSizeRange": ["medium", "large"],
|
|
37
|
+
"keywords": ["R-Zero", "agent", "challenger", "solver", "self-evolution"],
|
|
38
|
+
"priority": 300
|
|
39
|
+
},
|
|
40
|
+
"L3-RZero-base-split": {
|
|
41
|
+
"id": "L3-RZero-base-split",
|
|
42
|
+
"name": "RZero Base Split",
|
|
43
|
+
"level": "L3",
|
|
44
|
+
"module": "RZero",
|
|
45
|
+
"type": "problem-split",
|
|
46
|
+
"description": "问题空间划分策略,控制同源基座拆分初始化",
|
|
47
|
+
"appliesTo": ["problem-generation"],
|
|
48
|
+
"techStackMatch": ["any"],
|
|
49
|
+
"projectSizeRange": ["medium", "large"],
|
|
50
|
+
"keywords": ["R-Zero", "base-split", "problem-space"],
|
|
51
|
+
"priority": 301
|
|
52
|
+
},
|
|
53
|
+
"L3-RZero-challenger": {
|
|
54
|
+
"id": "L3-RZero-challenger",
|
|
55
|
+
"name": "RZero Challenger Rule",
|
|
56
|
+
"level": "L3",
|
|
57
|
+
"module": "RZero",
|
|
58
|
+
"type": "challenge-generation",
|
|
59
|
+
"description": "挑战者Agent规则,动态调整问题难度维持45%-55%正确率",
|
|
60
|
+
"appliesTo": ["difficulty-control"],
|
|
61
|
+
"techStackMatch": ["any"],
|
|
62
|
+
"projectSizeRange": ["medium", "large"],
|
|
63
|
+
"keywords": ["R-Zero", "challenger", "difficulty", "45-55"],
|
|
64
|
+
"priority": 302
|
|
65
|
+
},
|
|
66
|
+
"L3-RZero-solver": {
|
|
67
|
+
"id": "L3-RZero-solver",
|
|
68
|
+
"name": "RZero Solver Rule",
|
|
69
|
+
"level": "L3",
|
|
70
|
+
"module": "RZero",
|
|
71
|
+
"type": "problem-solving",
|
|
72
|
+
"description": "解题者Agent规则,执行推理与多答自一致性生成伪标签",
|
|
73
|
+
"appliesTo": ["self-solving"],
|
|
74
|
+
"techStackMatch": ["any"],
|
|
75
|
+
"projectSizeRange": ["medium", "large"],
|
|
76
|
+
"keywords": ["R-Zero", "solver", "reasoning", "self-consistency"],
|
|
77
|
+
"priority": 303
|
|
78
|
+
},
|
|
79
|
+
"L3-RZero-evolve": {
|
|
80
|
+
"id": "L3-RZero-evolve",
|
|
81
|
+
"name": "RZero Evolve Loop",
|
|
82
|
+
"level": "L3",
|
|
83
|
+
"module": "RZero",
|
|
84
|
+
"type": "evolution-loop",
|
|
85
|
+
"description": "进化循环规则,定义零标注自进化完整闭环",
|
|
86
|
+
"appliesTo": ["self-evolution"],
|
|
87
|
+
"techStackMatch": ["any"],
|
|
88
|
+
"projectSizeRange": ["medium", "large"],
|
|
89
|
+
"keywords": ["R-Zero", "evolution", "loop", "zero-data"],
|
|
90
|
+
"priority": 304
|
|
91
|
+
},
|
|
92
|
+
"L3-RZero-mcp": {
|
|
93
|
+
"id": "L3-RZero-mcp",
|
|
94
|
+
"name": "RZero MCP Config",
|
|
95
|
+
"level": "L3",
|
|
96
|
+
"module": "RZero",
|
|
97
|
+
"type": "mcp-integration",
|
|
98
|
+
"description": "MCP持久化配置,定义R-Zero与MCP网关的集成策略",
|
|
99
|
+
"appliesTo": ["mcp-integration"],
|
|
100
|
+
"techStackMatch": ["any"],
|
|
101
|
+
"projectSizeRange": ["medium", "large"],
|
|
102
|
+
"keywords": ["R-Zero", "mcp", "persistence", "storage"],
|
|
103
|
+
"priority": 305
|
|
104
|
+
},
|
|
105
|
+
"L3-custom-agent-constraints": {
|
|
106
|
+
"id": "L3-custom-agent-constraints",
|
|
107
|
+
"name": "Agent Constraints",
|
|
108
|
+
"level": "L3",
|
|
109
|
+
"module": "custom_config",
|
|
110
|
+
"type": "agent-constraint",
|
|
111
|
+
"description": "Agent行为约束配置,定义Agent工作边界和安全策略",
|
|
112
|
+
"appliesTo": ["agent-behavior"],
|
|
113
|
+
"techStackMatch": ["any"],
|
|
114
|
+
"projectSizeRange": ["medium", "large"],
|
|
115
|
+
"keywords": ["agent", "constraints", "behavior", "security"],
|
|
116
|
+
"priority": 310
|
|
117
|
+
},
|
|
118
|
+
"L3-custom-rules-config": {
|
|
119
|
+
"id": "L3-custom-rules-config",
|
|
120
|
+
"name": "Rules Engine Config",
|
|
121
|
+
"level": "L3",
|
|
122
|
+
"module": "custom_config",
|
|
123
|
+
"type": "engine-config",
|
|
124
|
+
"description": "规则引擎配置,注册注意力优化等自定义规则",
|
|
125
|
+
"appliesTo": ["rule-loading"],
|
|
126
|
+
"techStackMatch": ["any"],
|
|
127
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
128
|
+
"keywords": ["rules", "engine", "attention", "optimization"],
|
|
129
|
+
"priority": 311
|
|
130
|
+
},
|
|
131
|
+
"L3-custom-security": {
|
|
132
|
+
"id": "L3-custom-security",
|
|
133
|
+
"name": "Security Constraints",
|
|
134
|
+
"level": "L3",
|
|
135
|
+
"module": "custom_config",
|
|
136
|
+
"type": "security-rule",
|
|
137
|
+
"description": "安全约束规则,定义代码安全检查和漏洞防范",
|
|
138
|
+
"appliesTo": ["security-check"],
|
|
139
|
+
"techStackMatch": ["any"],
|
|
140
|
+
"projectSizeRange": ["small", "medium", "large"],
|
|
141
|
+
"keywords": ["security", "vulnerability", "check", "prevention"],
|
|
142
|
+
"priority": 312
|
|
143
|
+
},
|
|
144
|
+
"custom-attention-optimization": {
|
|
145
|
+
"id": "custom-attention-optimization",
|
|
146
|
+
"name": "Attention Optimization Rule",
|
|
147
|
+
"level": "custom",
|
|
148
|
+
"module": "attention-optimization",
|
|
149
|
+
"type": "optimization-rule",
|
|
150
|
+
"description": "注意力优化规则,管控稀疏注意力、GQA、PagedAttention等优化方案的启用边界",
|
|
151
|
+
"appliesTo": ["attention-optimization"],
|
|
152
|
+
"techStackMatch": ["javascript", "typescript", "node.js"],
|
|
153
|
+
"projectSizeRange": ["medium", "large"],
|
|
154
|
+
"keywords": ["attention", "optimization", "sparse", "GQA", "PagedAttention"],
|
|
155
|
+
"priority": 400
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"ruleRecommendations": {
|
|
159
|
+
"simple-project": {
|
|
160
|
+
"description": "简单项目推荐配置",
|
|
161
|
+
"rules": ["L1-user-rules", "L2-project-rules"],
|
|
162
|
+
"mcp": ["rules-enforcer"]
|
|
163
|
+
},
|
|
164
|
+
"complex-project": {
|
|
165
|
+
"description": "复杂项目推荐配置",
|
|
166
|
+
"rules": ["L1-user-rules", "L2-project-rules", "L3-RZero-evolve", "L3-custom-security"],
|
|
167
|
+
"mcp": ["rules-enforcer", "context7", "sequential-thinking"]
|
|
168
|
+
},
|
|
169
|
+
"self-evolution": {
|
|
170
|
+
"description": "自进化项目配置",
|
|
171
|
+
"rules": ["L1-user-rules", "L2-project-rules", "L3-RZero-agents", "L3-RZero-challenger", "L3-RZero-solver"],
|
|
172
|
+
"mcp": ["rules-enforcer", "sequential-thinking"]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"metadata": {
|
|
176
|
+
"version": "1.0.0",
|
|
177
|
+
"lastUpdated": "2026-06-05",
|
|
178
|
+
"totalRules": 12,
|
|
179
|
+
"l1Count": 1,
|
|
180
|
+
"l2Count": 1,
|
|
181
|
+
"l3Count": 9,
|
|
182
|
+
"customCount": 1
|
|
183
|
+
}
|
|
184
|
+
}
|