autosnippet 2.19.8 → 3.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 +26 -18
- package/dashboard/dist/assets/{index-BwISScUw.js → index-_Sk_Dmg3.js} +41 -41
- package/dashboard/dist/index.html +1 -1
- package/lib/external/mcp/McpServer.js +54 -65
- package/lib/external/mcp/handlers/bootstrap.js +7 -7
- package/lib/external/mcp/handlers/consolidated.js +290 -0
- package/lib/external/mcp/handlers/guard.js +5 -5
- package/lib/external/mcp/handlers/knowledge.js +23 -8
- package/lib/external/mcp/handlers/skill.js +4 -4
- package/lib/external/mcp/handlers/structure.js +16 -16
- package/lib/external/mcp/handlers/system.js +37 -40
- package/lib/external/mcp/tools.js +250 -646
- package/lib/service/cursor/RulesGenerator.js +2 -2
- package/lib/service/skills/SkillAdvisor.js +1 -1
- package/package.json +1 -1
- package/scripts/install-cursor-skill.js +10 -10
- package/skills/autosnippet-analysis/SKILL.md +23 -18
- package/skills/autosnippet-candidates/SKILL.md +38 -39
- package/skills/autosnippet-coldstart/SKILL.md +11 -14
- package/skills/autosnippet-concepts/SKILL.md +26 -31
- package/skills/autosnippet-create/SKILL.md +4 -6
- package/skills/autosnippet-guard/SKILL.md +14 -17
- package/skills/autosnippet-intent/SKILL.md +10 -11
- package/skills/autosnippet-lifecycle/SKILL.md +13 -18
- package/skills/autosnippet-recipes/SKILL.md +29 -62
- package/skills/autosnippet-structure/SKILL.md +19 -19
- package/templates/copilot-instructions.md +42 -41
- package/templates/recipes-setup/README.md +4 -7
|
@@ -1,777 +1,381 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP
|
|
2
|
+
* MCP 工具定义 — V3 整合版 (12 agent + 4 admin = 16 工具)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 从 39 → 16 工具(参数路由合并同类工具)。
|
|
5
|
+
* 每个工具声明增加 tier 字段(agent / admin)。
|
|
6
|
+
* tools.js 只包含 JSON Schema 声明 + Gateway 映射,不含业务逻辑。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
// ─── Tier 定义 ──────────────────────────────────────────────
|
|
10
|
+
export const TIER_ORDER = { agent: 0, admin: 1 };
|
|
11
|
+
|
|
12
|
+
// ─── Gateway 映射(仅写操作需要 gating) ────────────────────
|
|
13
|
+
|
|
13
14
|
export const TOOL_GATEWAY_MAP = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
15
|
+
// bootstrap 写操作 — 动态路由
|
|
16
|
+
autosnippet_bootstrap: {
|
|
17
|
+
resolver: (args) => ({
|
|
18
|
+
knowledge: { action: 'knowledge:bootstrap', resource: 'knowledge' },
|
|
19
|
+
refine: { action: 'knowledge:update', resource: 'knowledge' },
|
|
20
|
+
scan: { action: 'guard_rule:check_code', resource: 'guard_rules' },
|
|
21
|
+
})[args?.operation] || null,
|
|
22
|
+
},
|
|
23
|
+
// guard 写操作(仅 files 模式)
|
|
24
|
+
autosnippet_guard: {
|
|
25
|
+
resolver: (args) => (args?.files && Array.isArray(args.files))
|
|
26
|
+
? { action: 'guard_rule:check_code', resource: 'guard_rules' }
|
|
27
|
+
: null, // code 模式只读,跳过 Gateway
|
|
28
|
+
},
|
|
29
|
+
// skill 写操作(create/update/delete)
|
|
30
|
+
autosnippet_skill: {
|
|
31
|
+
resolver: (args) => ({
|
|
32
|
+
create: { action: 'create:skills', resource: 'skills' },
|
|
33
|
+
update: { action: 'update:skills', resource: 'skills' },
|
|
34
|
+
delete: { action: 'delete:skills', resource: 'skills' },
|
|
35
|
+
})[args?.operation] || null, // list/load/suggest 只读
|
|
36
|
+
},
|
|
37
|
+
// 知识提交
|
|
38
|
+
autosnippet_submit_knowledge: { action: 'knowledge:create', resource: 'knowledge' },
|
|
24
39
|
autosnippet_submit_knowledge_batch: { action: 'knowledge:create', resource: 'knowledge' },
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
autosnippet_save_document: { action: 'knowledge:create', resource: 'knowledge' },
|
|
41
|
+
// admin 工具
|
|
42
|
+
autosnippet_enrich_candidates: { action: 'knowledge:update', resource: 'knowledge' },
|
|
43
|
+
autosnippet_knowledge_lifecycle: { action: 'knowledge:update', resource: 'knowledge' },
|
|
27
44
|
};
|
|
28
45
|
|
|
46
|
+
// ─── 工具声明 ────────────────────────────────────────────────
|
|
47
|
+
|
|
29
48
|
export const TOOLS = [
|
|
49
|
+
|
|
50
|
+
// ══════════════════════════════════════════════════════
|
|
51
|
+
// Tier: agent — 外部 Agent 核心工具集 (12 个)
|
|
52
|
+
// ══════════════════════════════════════════════════════
|
|
53
|
+
|
|
30
54
|
// 1. 健康检查
|
|
31
55
|
{
|
|
32
56
|
name: 'autosnippet_health',
|
|
33
|
-
|
|
57
|
+
tier: 'agent',
|
|
58
|
+
description: '检查服务健康状态与知识库统计。total=0 时表示需要冷启动。',
|
|
34
59
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
35
60
|
},
|
|
36
|
-
|
|
61
|
+
|
|
62
|
+
// 2. 统合搜索(4 → 1)
|
|
37
63
|
{
|
|
38
64
|
name: 'autosnippet_search',
|
|
39
|
-
|
|
65
|
+
tier: 'agent',
|
|
66
|
+
description: '统合搜索入口。支持 4 种模式(mode 参数),返回 byKind 分组结果。',
|
|
40
67
|
inputSchema: {
|
|
41
68
|
type: 'object',
|
|
42
69
|
properties: {
|
|
43
|
-
query:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
limit:
|
|
70
|
+
query: { type: 'string', description: '搜索查询' },
|
|
71
|
+
mode: { type: 'string', enum: ['auto', 'keyword', 'bm25', 'semantic', 'context'], default: 'auto', description: 'auto=BM25+semantic 融合 | keyword=SQL LIKE 精确 | semantic=向量语义 | context=4层漏斗+会话感知' },
|
|
72
|
+
kind: { type: 'string', enum: ['all', 'rule', 'pattern', 'fact'], default: 'all', description: '按知识类型过滤' },
|
|
73
|
+
limit: { type: 'number', default: 10 },
|
|
74
|
+
language: { type: 'string', description: '当前编程语言(mode=context 时用于重排)' },
|
|
75
|
+
sessionId: { type: 'string', description: '会话 ID(mode=context 连续对话)' },
|
|
76
|
+
sessionHistory: { type: 'array', items: { type: 'object' }, description: '会话历史(mode=context 启用 Layer 4)' },
|
|
47
77
|
},
|
|
48
78
|
required: ['query'],
|
|
49
79
|
},
|
|
50
80
|
},
|
|
51
|
-
|
|
81
|
+
|
|
82
|
+
// 3. 知识浏览(7 → 1)
|
|
52
83
|
{
|
|
53
|
-
name: '
|
|
54
|
-
|
|
84
|
+
name: 'autosnippet_knowledge',
|
|
85
|
+
tier: 'agent',
|
|
86
|
+
description: '知识浏览与使用确认。list=列表过滤 | get=单条详情 | insights=质量洞察 | confirm_usage=记录采纳。',
|
|
55
87
|
inputSchema: {
|
|
56
88
|
type: 'object',
|
|
57
89
|
properties: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
operation: { type: 'string', enum: ['list', 'get', 'insights', 'confirm_usage'], default: 'list', description: 'list=列表过滤 | get=获取详情 | insights=质量洞察 | confirm_usage=确认采纳' },
|
|
91
|
+
id: { type: 'string', description: 'Recipe ID(get/insights/confirm_usage 必填)' },
|
|
92
|
+
kind: { type: 'string', enum: ['all', 'rule', 'pattern', 'fact'], description: '按知识类型过滤(list)' },
|
|
93
|
+
language: { type: 'string', description: '语言过滤' },
|
|
94
|
+
category: { type: 'string', description: '分类过滤' },
|
|
95
|
+
knowledgeType: { type: 'string', description: '知识类型过滤' },
|
|
96
|
+
status: { type: 'string', description: '状态过滤:active/draft/deprecated' },
|
|
97
|
+
complexity: { type: 'string', description: '复杂度过滤' },
|
|
98
|
+
limit: { type: 'number', default: 20 },
|
|
99
|
+
usageType: { type: 'string', enum: ['adoption', 'application'], description: '使用类型(confirm_usage)' },
|
|
100
|
+
feedback: { type: 'string', description: '使用反馈(confirm_usage)' },
|
|
61
101
|
},
|
|
62
|
-
required: [
|
|
102
|
+
required: [],
|
|
63
103
|
},
|
|
64
104
|
},
|
|
65
|
-
|
|
105
|
+
|
|
106
|
+
// 4. 项目结构(3 → 1)
|
|
66
107
|
{
|
|
67
|
-
name: '
|
|
68
|
-
|
|
108
|
+
name: 'autosnippet_structure',
|
|
109
|
+
tier: 'agent',
|
|
110
|
+
description: '项目结构探查。targets=目标列表 | files=文件列表 | metadata=元数据与依赖。',
|
|
69
111
|
inputSchema: {
|
|
70
112
|
type: 'object',
|
|
71
113
|
properties: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
114
|
+
operation: { type: 'string', enum: ['targets', 'files', 'metadata'], default: 'targets', description: 'targets=目标列表 | files=文件列表 | metadata=元数据' },
|
|
115
|
+
targetName: { type: 'string', description: 'Target 名称(files/metadata 必填)' },
|
|
116
|
+
includeSummary: { type: 'boolean', default: true, description: '附带摘要统计(targets)' },
|
|
117
|
+
includeContent: { type: 'boolean', default: false, description: '返回文件内容(files)' },
|
|
118
|
+
contentMaxLines: { type: 'number', default: 100, description: '截断行数(files)' },
|
|
119
|
+
maxFiles: { type: 'number', default: 500, description: '最大文件数(files)' },
|
|
78
120
|
},
|
|
79
|
-
required: [
|
|
121
|
+
required: [],
|
|
80
122
|
},
|
|
81
123
|
},
|
|
82
|
-
|
|
124
|
+
|
|
125
|
+
// 5. 知识图谱(4 → 1)
|
|
83
126
|
{
|
|
84
|
-
name: '
|
|
85
|
-
|
|
127
|
+
name: 'autosnippet_graph',
|
|
128
|
+
tier: 'agent',
|
|
129
|
+
description: '知识图谱查询。query=节点关系 | impact=影响分析 | path=路径查找 | stats=全局统计。',
|
|
86
130
|
inputSchema: {
|
|
87
131
|
type: 'object',
|
|
88
132
|
properties: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
133
|
+
operation: { type: 'string', enum: ['query', 'impact', 'path', 'stats'], description: 'query=节点关系 | impact=影响分析 | path=路径查找 | stats=全局统计' },
|
|
134
|
+
nodeId: { type: 'string', description: '节点 ID(query/impact)' },
|
|
135
|
+
nodeType: { type: 'string', default: 'recipe' },
|
|
136
|
+
fromId: { type: 'string', description: '起始节点(path)' },
|
|
137
|
+
toId: { type: 'string', description: '目标节点(path)' },
|
|
138
|
+
direction: { type: 'string', enum: ['out', 'in', 'both'], default: 'both', description: '关系方向(query)' },
|
|
139
|
+
maxDepth: { type: 'number', default: 3, description: '最大深度' },
|
|
140
|
+
relation: { type: 'string', description: '关系类型过滤' },
|
|
93
141
|
},
|
|
94
|
-
required: [],
|
|
142
|
+
required: ['operation'],
|
|
95
143
|
},
|
|
96
144
|
},
|
|
97
|
-
|
|
145
|
+
|
|
146
|
+
// 6. Guard 检查(2 → 1)
|
|
98
147
|
{
|
|
99
|
-
name: '
|
|
100
|
-
|
|
148
|
+
name: 'autosnippet_guard',
|
|
149
|
+
tier: 'agent',
|
|
150
|
+
description: '代码规范检查。传 code=单文件检查,传 files[]=多文件批量审计(自动路由)。',
|
|
101
151
|
inputSchema: {
|
|
102
152
|
type: 'object',
|
|
103
153
|
properties: {
|
|
104
|
-
|
|
105
|
-
language: { type: 'string' },
|
|
106
|
-
|
|
154
|
+
code: { type: 'string', description: '待检查代码(单文件模式,与 files 二选一)' },
|
|
155
|
+
language: { type: 'string', description: '编程语言' },
|
|
156
|
+
filePath: { type: 'string', description: '文件路径(单文件模式)' },
|
|
157
|
+
files: { type: 'array', items: { type: 'object', properties: { path: { type: 'string' }, content: { type: 'string' } }, required: ['path'] }, description: '文件列表(批量模式,与 code 二选一)' },
|
|
158
|
+
scope: { type: 'string', enum: ['file', 'target', 'project'], default: 'project', description: '审计范围(批量模式)' },
|
|
107
159
|
},
|
|
108
160
|
required: [],
|
|
109
161
|
},
|
|
110
162
|
},
|
|
111
|
-
|
|
163
|
+
|
|
164
|
+
// 7. 提交知识(严格前置校验 + 去重检测)
|
|
112
165
|
{
|
|
113
|
-
name: '
|
|
114
|
-
|
|
166
|
+
name: 'autosnippet_submit_knowledge',
|
|
167
|
+
tier: 'agent',
|
|
168
|
+
description:
|
|
169
|
+
'提交单条知识到知识库(V3 统一实体)。严格前置校验,缺少必要字段将被直接拒绝(不入库)。\n' +
|
|
170
|
+
'所有必填字段必须在单次调用中一次性提供,不要分步提交。\n' +
|
|
171
|
+
'必填: title, language, content(pattern或markdown + rationale), kind, doClause, category, trigger, description, headers, usageGuide, knowledgeType',
|
|
115
172
|
inputSchema: {
|
|
116
173
|
type: 'object',
|
|
117
174
|
properties: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
175
|
+
// ── 必填 ──
|
|
176
|
+
title: { type: 'string', description: '中文标题(≤20字)' },
|
|
177
|
+
language: { type: 'string', description: '编程语言(小写)' },
|
|
178
|
+
content: { type: 'object', description: '内容值对象(必须有 pattern 或 markdown + rationale)', properties: { pattern: { type: 'string' }, markdown: { type: 'string' }, rationale: { type: 'string', description: '设计原理说明(必填)' }, steps: { type: 'array', items: { type: 'object' } }, codeChanges: { type: 'array', items: { type: 'object' } }, verification: { type: 'object' } } },
|
|
179
|
+
kind: { type: 'string', enum: ['rule', 'pattern', 'fact'], description: 'rule=规则 | pattern=模板 | fact=参考' },
|
|
180
|
+
doClause: { type: 'string', description: '正向指令(英文祈使句 ≤60 tokens)' },
|
|
181
|
+
category: { type: 'string', description: '分类(必填): View/Service/Tool/Model/Network/Storage/UI/Utility' },
|
|
182
|
+
trigger: { type: 'string', description: '触发关键词(必填,@前缀,如 @video-cover-cell)' },
|
|
183
|
+
description: { type: 'string', description: '中文简述(必填)≤80 字' },
|
|
184
|
+
headers: { type: 'array', items: { type: 'string' }, description: '完整 import/include 语句数组(必填)' },
|
|
185
|
+
usageGuide: { type: 'string', description: '使用指南(必填,Markdown ### 章节格式,描述何时/如何使用此知识)' },
|
|
186
|
+
knowledgeType: { type: 'string', description: '知识维度(必填,如 code-pattern/architecture/best-practice/naming-convention 等)' },
|
|
187
|
+
// ── Cursor Delivery ──
|
|
188
|
+
dontClause: { type: 'string', description: '反向约束' },
|
|
189
|
+
whenClause: { type: 'string', description: '触发场景' },
|
|
190
|
+
topicHint: { type: 'string', description: '主题分组' },
|
|
191
|
+
coreCode: { type: 'string', description: '精华代码骨架(3-8行)' },
|
|
192
|
+
// ── 可选 ──
|
|
193
|
+
complexity: { type: 'string', enum: ['beginner', 'intermediate', 'advanced'] },
|
|
194
|
+
scope: { type: 'string', enum: ['universal', 'project-specific', 'target-specific'] },
|
|
195
|
+
difficulty: { type: 'string' },
|
|
196
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
197
|
+
constraints: { type: 'object', description: '约束' },
|
|
198
|
+
relations: { type: 'object', description: '关系' },
|
|
199
|
+
reasoning: { type: 'object', description: '推理依据 {whyStandard, sources[], confidence}', properties: { whyStandard: { type: 'string' }, sources: { type: 'array', items: { type: 'string' } }, confidence: { type: 'number' }, qualitySignals: { type: 'object' }, alternatives: { type: 'array', items: { type: 'string' } } } },
|
|
200
|
+
headerPaths: { type: 'array', items: { type: 'string' } },
|
|
201
|
+
moduleName: { type: 'string' },
|
|
202
|
+
includeHeaders: { type: 'boolean' },
|
|
203
|
+
source: { type: 'string', description: '来源标识' },
|
|
204
|
+
client_id: { type: 'string', description: '客户端标识' },
|
|
205
|
+
// ── 增强控制 ──
|
|
206
|
+
skipDuplicateCheck: { type: 'boolean', default: false, description: '跳过去重检测' },
|
|
121
207
|
},
|
|
122
|
-
required: ['
|
|
208
|
+
required: ['title', 'language', 'content', 'kind', 'doClause', 'category', 'trigger', 'description', 'headers', 'usageGuide', 'knowledgeType'],
|
|
123
209
|
},
|
|
124
210
|
},
|
|
125
|
-
|
|
211
|
+
|
|
212
|
+
// 8. 批量知识提交
|
|
126
213
|
{
|
|
127
|
-
name: '
|
|
128
|
-
|
|
214
|
+
name: 'autosnippet_submit_knowledge_batch',
|
|
215
|
+
tier: 'agent',
|
|
216
|
+
description: '批量提交知识条目(V3 统一实体)。每条须含 kind/doClause。支持去重。',
|
|
129
217
|
inputSchema: {
|
|
130
218
|
type: 'object',
|
|
131
219
|
properties: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
220
|
+
target_name: { type: 'string', description: 'Target 名称' },
|
|
221
|
+
items: { type: 'array', description: '知识条目数组,每项字段同 submit_knowledge', items: { type: 'object' } },
|
|
222
|
+
source: { type: 'string', default: 'cursor-scan' },
|
|
223
|
+
deduplicate: { type: 'boolean', default: true },
|
|
224
|
+
client_id: { type: 'string' },
|
|
135
225
|
},
|
|
136
|
-
required: ['
|
|
226
|
+
required: ['target_name', 'items'],
|
|
137
227
|
},
|
|
138
228
|
},
|
|
139
|
-
|
|
229
|
+
|
|
230
|
+
// 9. 保存开发文档
|
|
140
231
|
{
|
|
141
|
-
name: '
|
|
142
|
-
|
|
232
|
+
name: 'autosnippet_save_document',
|
|
233
|
+
tier: 'agent',
|
|
234
|
+
description: '保存开发文档(设计文档、排查报告、ADR 等)。仅需 title + markdown,自动以 dev-document 存储。',
|
|
143
235
|
inputSchema: {
|
|
144
236
|
type: 'object',
|
|
145
237
|
properties: {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
238
|
+
title: { type: 'string', description: '文档标题' },
|
|
239
|
+
markdown: { type: 'string', description: 'Markdown 全文' },
|
|
240
|
+
description: { type: 'string', description: '一句话摘要' },
|
|
241
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
242
|
+
scope: { type: 'string', enum: ['universal', 'project-specific'], default: 'project-specific' },
|
|
243
|
+
source: { type: 'string' },
|
|
150
244
|
},
|
|
151
|
-
required: ['
|
|
245
|
+
required: ['title', 'markdown'],
|
|
152
246
|
},
|
|
153
247
|
},
|
|
154
|
-
|
|
248
|
+
|
|
249
|
+
// 10. Skill 管理(6 → 1)
|
|
155
250
|
{
|
|
156
|
-
name: '
|
|
157
|
-
|
|
251
|
+
name: 'autosnippet_skill',
|
|
252
|
+
tier: 'agent',
|
|
253
|
+
description: 'Skill 管理。list=列表 | load=加载 | create=创建 | update=更新 | delete=删除 | suggest=AI推荐。',
|
|
158
254
|
inputSchema: {
|
|
159
255
|
type: 'object',
|
|
160
256
|
properties: {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
257
|
+
operation: { type: 'string', enum: ['list', 'load', 'create', 'update', 'delete', 'suggest'], description: 'list=列表 | load=加载 | create=创建 | update=更新 | delete=删除 | suggest=推荐' },
|
|
258
|
+
name: { type: 'string', description: 'Skill 名称(load/create/update/delete)' },
|
|
259
|
+
skillName: { type: 'string', description: 'Skill 名称(load 的别名,兼容旧调用)' },
|
|
260
|
+
section: { type: 'string', description: '章节过滤(load)' },
|
|
261
|
+
description: { type: 'string', description: '描述(create/update)' },
|
|
262
|
+
content: { type: 'string', description: 'Markdown 正文(create/update)' },
|
|
263
|
+
overwrite: { type: 'boolean', default: false, description: '覆盖已存在(create)' },
|
|
264
|
+
createdBy: { type: 'string', enum: ['manual', 'user-ai', 'system-ai', 'external-ai'], default: 'external-ai' },
|
|
164
265
|
},
|
|
165
|
-
required: ['
|
|
266
|
+
required: ['operation'],
|
|
166
267
|
},
|
|
167
268
|
},
|
|
168
|
-
|
|
269
|
+
|
|
270
|
+
// 11. 冷启动 & 扫描(3 → 1)
|
|
169
271
|
{
|
|
170
|
-
name: '
|
|
171
|
-
|
|
272
|
+
name: 'autosnippet_bootstrap',
|
|
273
|
+
tier: 'agent',
|
|
274
|
+
description: '冷启动与项目扫描。knowledge=初始化知识库9维度 | refine=AI润色候选 | scan=轻量探查。',
|
|
172
275
|
inputSchema: {
|
|
173
276
|
type: 'object',
|
|
174
277
|
properties: {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
278
|
+
operation: { type: 'string', enum: ['knowledge', 'refine', 'scan'], description: 'knowledge=冷启动 | refine=AI润色 | scan=轻量探查' },
|
|
279
|
+
maxFiles: { type: 'number', default: 500, description: '最大扫描文件数(knowledge/scan)' },
|
|
280
|
+
contentMaxLines: { type: 'number', default: 120, description: '每文件最大行数(knowledge/scan)' },
|
|
281
|
+
skipGuard: { type: 'boolean', default: false, description: '跳过 Guard 审计(knowledge)' },
|
|
282
|
+
loadSkills: { type: 'boolean', default: true, description: '加载 Skills 增强维度(knowledge)' },
|
|
283
|
+
includeContent: { type: 'boolean', default: false, description: '返回文件内容(scan)' },
|
|
284
|
+
candidateIds: { type: 'array', items: { type: 'string' }, description: '候选 ID(refine)' },
|
|
285
|
+
userPrompt: { type: 'string', description: '润色提示词(refine)' },
|
|
286
|
+
dryRun: { type: 'boolean', default: false, description: '预览模式(refine)' },
|
|
180
287
|
},
|
|
181
|
-
required: ['
|
|
288
|
+
required: ['operation'],
|
|
182
289
|
},
|
|
183
290
|
},
|
|
184
|
-
|
|
291
|
+
|
|
292
|
+
// 12. 能力声明(Agent 自发现)
|
|
185
293
|
{
|
|
186
|
-
name: '
|
|
187
|
-
|
|
294
|
+
name: 'autosnippet_capabilities',
|
|
295
|
+
tier: 'agent',
|
|
296
|
+
description: '列出所有可用 MCP 工具的概览,供 Agent 自发现服务能力。',
|
|
188
297
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
189
298
|
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
properties: {
|
|
197
|
-
includeSummary: { type: 'boolean', default: true, description: '是否附带文件数与语言统计摘要(默认 true)' },
|
|
198
|
-
},
|
|
199
|
-
required: [],
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
// 14. 获取 Target 源码文件
|
|
299
|
+
|
|
300
|
+
// ══════════════════════════════════════════════════════
|
|
301
|
+
// Tier: admin — 管理员/CI 工具 (额外 +4)
|
|
302
|
+
// ══════════════════════════════════════════════════════
|
|
303
|
+
|
|
304
|
+
// 13. 候选字段诊断
|
|
203
305
|
{
|
|
204
|
-
name: '
|
|
205
|
-
|
|
306
|
+
name: 'autosnippet_enrich_candidates',
|
|
307
|
+
tier: 'admin',
|
|
308
|
+
description: '候选字段完整性诊断(不使用 AI)。返回 missingFields 列表,Agent 自行补全。',
|
|
206
309
|
inputSchema: {
|
|
207
310
|
type: 'object',
|
|
208
311
|
properties: {
|
|
209
|
-
|
|
210
|
-
includeContent: { type: 'boolean', default: false, description: '是否返回文件内容' },
|
|
211
|
-
contentMaxLines: { type: 'number', default: 100, description: '每文件最大返回行数(需 includeContent=true)' },
|
|
212
|
-
maxFiles: { type: 'number', default: 500, description: '最大文件数' },
|
|
312
|
+
candidateIds: { type: 'array', items: { type: 'string' }, description: '候选 ID 列表(最多20条)' },
|
|
213
313
|
},
|
|
214
|
-
required: ['
|
|
314
|
+
required: ['candidateIds'],
|
|
215
315
|
},
|
|
216
316
|
},
|
|
217
|
-
|
|
317
|
+
|
|
318
|
+
// 14. 知识条目生命周期
|
|
218
319
|
{
|
|
219
|
-
name: '
|
|
220
|
-
|
|
320
|
+
name: 'autosnippet_knowledge_lifecycle',
|
|
321
|
+
tier: 'admin',
|
|
322
|
+
description: '知识条目生命周期操作:submit/approve/reject/publish/deprecate/reactivate/fast_track。',
|
|
221
323
|
inputSchema: {
|
|
222
324
|
type: 'object',
|
|
223
325
|
properties: {
|
|
224
|
-
|
|
326
|
+
id: { type: 'string', description: '知识条目 ID' },
|
|
327
|
+
action: { type: 'string', enum: ['submit', 'approve', 'reject', 'publish', 'deprecate', 'reactivate', 'to_draft', 'fast_track'] },
|
|
328
|
+
reason: { type: 'string', description: 'reject/deprecate 原因' },
|
|
225
329
|
},
|
|
226
|
-
required: ['
|
|
330
|
+
required: ['id', 'action'],
|
|
227
331
|
},
|
|
228
332
|
},
|
|
229
|
-
|
|
333
|
+
|
|
334
|
+
// 15. 独立候选校验(调试)
|
|
230
335
|
{
|
|
231
336
|
name: 'autosnippet_validate_candidate',
|
|
232
|
-
|
|
337
|
+
tier: 'admin',
|
|
338
|
+
description: '对候选做结构化预校验(5层),调试用(Agent 层的 submit_knowledge 已内置校验)。',
|
|
233
339
|
inputSchema: {
|
|
234
340
|
type: 'object',
|
|
235
341
|
properties: {
|
|
236
342
|
candidate: {
|
|
237
343
|
type: 'object',
|
|
238
|
-
description: '
|
|
344
|
+
description: '候选结构',
|
|
239
345
|
properties: {
|
|
240
|
-
title: { type: 'string',
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
category: { type: 'string', description: '分类:View/Service/Tool/Model/Network/Storage/UI/Utility' },
|
|
244
|
-
knowledgeType: { type: 'string', description: '知识维度:code-pattern|architecture|best-practice|boundary-constraint 等' },
|
|
245
|
-
complexity: { type: 'string', enum: ['beginner', 'intermediate', 'advanced'], description: '复杂度' },
|
|
346
|
+
title: { type: 'string' }, code: { type: 'string' }, language: { type: 'string' },
|
|
347
|
+
category: { type: 'string' }, knowledgeType: { type: 'string' },
|
|
348
|
+
complexity: { type: 'string', enum: ['beginner', 'intermediate', 'advanced'] },
|
|
246
349
|
scope: { type: 'string', enum: ['universal', 'project-specific', 'target-specific'] },
|
|
247
350
|
tags: { type: 'array', items: { type: 'string' } },
|
|
248
|
-
description: { type: 'string',
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
codeChanges: { type: 'array', items: { type: 'object' }, description: '代码变更 [{file, before, after, explanation}]' },
|
|
256
|
-
constraints: { type: 'object', description: '约束 {boundaries[], preconditions[], sideEffects[], guards[]}' },
|
|
257
|
-
reasoning: {
|
|
258
|
-
type: 'object',
|
|
259
|
-
description: '推理依据(强烈建议提供):{whyStandard, sources[], confidence}',
|
|
260
|
-
properties: {
|
|
261
|
-
whyStandard: { type: 'string' },
|
|
262
|
-
sources: { type: 'array', items: { type: 'string' } },
|
|
263
|
-
confidence: { type: 'number', description: '0-1' },
|
|
264
|
-
},
|
|
265
|
-
},
|
|
351
|
+
description: { type: 'string' }, trigger: { type: 'string' },
|
|
352
|
+
usageGuide: { type: 'string' }, rationale: { type: 'string' },
|
|
353
|
+
headers: { type: 'array', items: { type: 'string' } },
|
|
354
|
+
steps: { type: 'array', items: { type: 'object' } },
|
|
355
|
+
codeChanges: { type: 'array', items: { type: 'object' } },
|
|
356
|
+
constraints: { type: 'object' },
|
|
357
|
+
reasoning: { type: 'object', properties: { whyStandard: { type: 'string' }, sources: { type: 'array', items: { type: 'string' } }, confidence: { type: 'number' } } },
|
|
266
358
|
},
|
|
267
359
|
},
|
|
268
|
-
strict: { type: 'boolean', default: false
|
|
360
|
+
strict: { type: 'boolean', default: false },
|
|
269
361
|
},
|
|
270
362
|
required: ['candidate'],
|
|
271
363
|
},
|
|
272
364
|
},
|
|
273
|
-
|
|
365
|
+
|
|
366
|
+
// 16. 独立去重检测(调试)
|
|
274
367
|
{
|
|
275
368
|
name: 'autosnippet_check_duplicate',
|
|
276
|
-
|
|
369
|
+
tier: 'admin',
|
|
370
|
+
description: '相似度检测(调试用,Agent 层的 submit_knowledge 已内置去重)。',
|
|
277
371
|
inputSchema: {
|
|
278
372
|
type: 'object',
|
|
279
373
|
properties: {
|
|
280
|
-
candidate: {
|
|
281
|
-
type: 'object',
|
|
282
|
-
properties: { title: { type: 'string' }, summary: { type: 'string' }, usageGuide: { type: 'string' }, code: { type: 'string' } },
|
|
283
|
-
},
|
|
374
|
+
candidate: { type: 'object', properties: { title: { type: 'string' }, summary: { type: 'string' }, usageGuide: { type: 'string' }, code: { type: 'string' } } },
|
|
284
375
|
threshold: { type: 'number', default: 0.7 },
|
|
285
|
-
topK:
|
|
376
|
+
topK: { type: 'number', default: 5 },
|
|
286
377
|
},
|
|
287
378
|
required: ['candidate'],
|
|
288
379
|
},
|
|
289
380
|
},
|
|
290
|
-
// 18-20: [已移除] 旧 submit_candidate / submit_candidates / submit_draft_recipes
|
|
291
|
-
// 统一使用 V3 submit_knowledge / submit_knowledge_batch / knowledge_lifecycle
|
|
292
|
-
// 21. 能力声明
|
|
293
|
-
{
|
|
294
|
-
name: 'autosnippet_capabilities',
|
|
295
|
-
description: '列出所有可用 MCP 工具的概览。',
|
|
296
|
-
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
297
|
-
},
|
|
298
|
-
// 22. 列出 Recipes(通用,支持多条件组合过滤)
|
|
299
|
-
{
|
|
300
|
-
name: 'autosnippet_list_recipes',
|
|
301
|
-
description: '列出 Recipe 列表(支持 kind/language/category/knowledgeType/status/complexity/tags 多条件组合过滤)。',
|
|
302
|
-
inputSchema: {
|
|
303
|
-
type: 'object',
|
|
304
|
-
properties: {
|
|
305
|
-
kind: { type: 'string', description: 'kind 过滤:rule/pattern/fact' },
|
|
306
|
-
language: { type: 'string' },
|
|
307
|
-
category: { type: 'string' },
|
|
308
|
-
knowledgeType: { type: 'string', description: '知识类型过滤' },
|
|
309
|
-
status: { type: 'string', description: '状态过滤:active/draft/deprecated' },
|
|
310
|
-
complexity: { type: 'string', description: '复杂度过滤' },
|
|
311
|
-
limit: { type: 'number', default: 20 },
|
|
312
|
-
},
|
|
313
|
-
required: [],
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
// 23. 获取单个 Recipe
|
|
317
|
-
{
|
|
318
|
-
name: 'autosnippet_get_recipe',
|
|
319
|
-
description: '按 ID 获取单个 Recipe 详细信息。',
|
|
320
|
-
inputSchema: {
|
|
321
|
-
type: 'object',
|
|
322
|
-
properties: { id: { type: 'string' } },
|
|
323
|
-
required: ['id'],
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
// 24. 合规报告
|
|
327
|
-
{
|
|
328
|
-
name: 'autosnippet_compliance_report',
|
|
329
|
-
description: '获取合规评估报告,可按时间范围过滤。',
|
|
330
|
-
inputSchema: {
|
|
331
|
-
type: 'object',
|
|
332
|
-
properties: {
|
|
333
|
-
period: { type: 'string', enum: ['all', 'daily', 'weekly', 'monthly'], default: 'all', description: '评估时间范围' },
|
|
334
|
-
},
|
|
335
|
-
required: [],
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
// 25. 确认使用 Recipe
|
|
339
|
-
{
|
|
340
|
-
name: 'autosnippet_confirm_usage',
|
|
341
|
-
description: '确认 Recipe 被采纳或应用,记录使用统计。',
|
|
342
|
-
inputSchema: {
|
|
343
|
-
type: 'object',
|
|
344
|
-
properties: {
|
|
345
|
-
recipeId: { type: 'string', description: 'Recipe ID' },
|
|
346
|
-
usageType: { type: 'string', enum: ['adoption', 'application'], default: 'adoption', description: 'adoption=采纳, application=应用' },
|
|
347
|
-
feedback: { type: 'string', description: '可选反馈' },
|
|
348
|
-
},
|
|
349
|
-
required: ['recipeId'],
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
// 26. 列出结构性知识 (kind=fact)
|
|
353
|
-
{
|
|
354
|
-
name: 'autosnippet_list_facts',
|
|
355
|
-
description: '列出知识库中的结构性知识(kind=fact,包括代码关联、继承、调用链、数据流等)。',
|
|
356
|
-
inputSchema: {
|
|
357
|
-
type: 'object',
|
|
358
|
-
properties: {
|
|
359
|
-
limit: { type: 'number', default: 20 },
|
|
360
|
-
status: { type: 'string', description: '按状态过滤:active/draft/deprecated' },
|
|
361
|
-
language: { type: 'string', description: '按语言过滤' },
|
|
362
|
-
category: { type: 'string', description: '按分类过滤' },
|
|
363
|
-
},
|
|
364
|
-
required: [],
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
// 27. Recipe 洞察 (只读聚合)
|
|
368
|
-
{
|
|
369
|
-
name: 'autosnippet_recipe_insights',
|
|
370
|
-
description: '获取指定 Recipe 的质量洞察:质量分数、采纳/应用统计、关联关系摘要、约束条件概览。只读工具,不修改任何数据。',
|
|
371
|
-
inputSchema: {
|
|
372
|
-
type: 'object',
|
|
373
|
-
properties: {
|
|
374
|
-
id: { type: 'string', description: 'Recipe ID' },
|
|
375
|
-
},
|
|
376
|
-
required: ['id'],
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
// 28. 全项目扫描(轻量探查:收集文件 + Guard 审计,不写数据库)
|
|
380
|
-
{
|
|
381
|
-
name: 'autosnippet_scan_project',
|
|
382
|
-
description: '轻量项目探查:收集所有 SPM Target 的源文件列表 + 运行 Guard 规则审计。返回文件清单和 Guard 违规统计。Guard 审计结果会自动记录到 ViolationsStore(Dashboard Guard 页面可见)。' +
|
|
383
|
-
'适用场景:了解项目结构、检查 Guard 状态、快速看一下有多少文件。' +
|
|
384
|
-
'如果要做完整的知识库初始化(冷启动),请使用 autosnippet_bootstrap_knowledge。',
|
|
385
|
-
inputSchema: {
|
|
386
|
-
type: 'object',
|
|
387
|
-
properties: {
|
|
388
|
-
maxFiles: { type: 'number', default: 200, description: '最大文件数(避免超大项目卡死)' },
|
|
389
|
-
includeContent: { type: 'boolean', default: false, description: '是否在结果中包含文件内容(用于 Agent 后续分析)' },
|
|
390
|
-
contentMaxLines: { type: 'number', default: 100, description: '每个文件返回的最大行数(当 includeContent=true)' },
|
|
391
|
-
},
|
|
392
|
-
required: [],
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
// 29. Guard 批量审计(多文件)
|
|
396
|
-
{
|
|
397
|
-
name: 'autosnippet_guard_audit_files',
|
|
398
|
-
description: '对多个文件批量运行 Guard 规则审计。传入文件路径列表,返回每个文件的违反详情。结果会自动记录到 ViolationsStore(Dashboard Guard 页面可见)。',
|
|
399
|
-
inputSchema: {
|
|
400
|
-
type: 'object',
|
|
401
|
-
properties: {
|
|
402
|
-
files: {
|
|
403
|
-
type: 'array',
|
|
404
|
-
items: {
|
|
405
|
-
type: 'object',
|
|
406
|
-
properties: {
|
|
407
|
-
path: { type: 'string', description: '文件绝对路径' },
|
|
408
|
-
content: { type: 'string', description: '文件内容(如不提供则从磁盘读取)' },
|
|
409
|
-
},
|
|
410
|
-
required: ['path'],
|
|
411
|
-
},
|
|
412
|
-
description: '待审计的文件列表',
|
|
413
|
-
},
|
|
414
|
-
scope: { type: 'string', enum: ['file', 'target', 'project'], default: 'project', description: '审计范围' },
|
|
415
|
-
},
|
|
416
|
-
required: ['files'],
|
|
417
|
-
},
|
|
418
|
-
},
|
|
419
|
-
// 30. ① 结构补齐:候选字段完整性诊断(不使用内置 AI)
|
|
420
|
-
{
|
|
421
|
-
name: 'autosnippet_enrich_candidates',
|
|
422
|
-
description:
|
|
423
|
-
'① 结构补齐(诊断模式)— 检查候选的字段完整性,返回缺失清单。\n' +
|
|
424
|
-
'检查两层:\n' +
|
|
425
|
-
' • Recipe 必填:category、trigger(@开头)、description、headers\n' +
|
|
426
|
-
' • 语义字段:rationale、knowledgeType、complexity、scope、steps、constraints\n' +
|
|
427
|
-
'不调用内置 AI,仅做诊断。返回每条候选的 missingFields 列表。\n' +
|
|
428
|
-
'\n' +
|
|
429
|
-
'⚠️ 调用方职责:拿到 missingFields 后,你必须根据代码内容和项目上下文自行填充缺失字段,然后重新提交更新。\n' +
|
|
430
|
-
'建议在 autosnippet_bootstrap_refine(② 内容润色)之前调用。',
|
|
431
|
-
inputSchema: {
|
|
432
|
-
type: 'object',
|
|
433
|
-
properties: {
|
|
434
|
-
candidateIds: {
|
|
435
|
-
type: 'array',
|
|
436
|
-
items: { type: 'string' },
|
|
437
|
-
description: '要诊断的候选 ID 列表(最多 20 条)',
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
required: ['candidateIds'],
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
// 31. 冷启动知识库初始化(自动创建 9 维度 Candidate + 4 个 Project Skills)
|
|
444
|
-
{
|
|
445
|
-
name: 'autosnippet_bootstrap_knowledge',
|
|
446
|
-
description:
|
|
447
|
-
'项目冷启动:一键初始化知识库(纯启发式,不使用 AI)。覆盖 9 大知识维度。\n' +
|
|
448
|
-
'自动为每个维度创建 N 条 Candidate(PENDING 状态),基于启发式规则从扫描文件中提取代表性代码。\n' +
|
|
449
|
-
'Phase 5.5 自动为 4 个宏观维度(code-standard, architecture, project-profile, agent-guidelines)生成 Project Skills,写入 AutoSnippet/skills/。\n' +
|
|
450
|
-
'返回 filesByTarget、dependencyGraph、bootstrapCandidates、projectSkills、analysisFramework。\n' +
|
|
451
|
-
'\n' +
|
|
452
|
-
'💡 建议:调用前先加载 autosnippet-coldstart Skill(autosnippet_load_skill),获取完整的 9 维度分析指南和最佳实践。\n' +
|
|
453
|
-
'\n' +
|
|
454
|
-
'⚠️ 产出为启发式初稿,必须执行后续步骤提升质量:\n' +
|
|
455
|
-
' Step 1: autosnippet_enrich_candidates — 诊断字段缺失,逐条补全必填字段\n' +
|
|
456
|
-
' Step 2: autosnippet_bootstrap_refine — AI 润色 summary/insight/relations/confidence\n' +
|
|
457
|
-
' Step 3: 逐 Target 深入分析,补充更细粒度知识条目(autosnippet_submit_knowledge_batch)\n' +
|
|
458
|
-
' Step 4: 对新候选重复 Step 1-2\n' +
|
|
459
|
-
'\n' +
|
|
460
|
-
'质量标准:每条必须包含 title/code/language/category/trigger/description/headers/reasoning。',
|
|
461
|
-
inputSchema: {
|
|
462
|
-
type: 'object',
|
|
463
|
-
properties: {
|
|
464
|
-
maxFiles: { type: 'number', default: 500, description: '最大扫描文件数(防止超大项目超时)' },
|
|
465
|
-
contentMaxLines: { type: 'number', default: 120, description: '每个文件返回的最大行数(过大可能超出 Token 限制)' },
|
|
466
|
-
skipGuard: { type: 'boolean', default: false, description: '跳过 Guard 审计' },
|
|
467
|
-
loadSkills: { type: 'boolean', default: true, description: '加载 Skills 增强分析维度(推荐)。自动加载 coldstart Skill + 语言参考 Skill,增强 9 维度的 guide 定义。' },
|
|
468
|
-
},
|
|
469
|
-
required: [],
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
// 32. Skills 发现:列出所有可用 Agent Skill 及其适用场景
|
|
473
|
-
{
|
|
474
|
-
name: 'autosnippet_list_skills',
|
|
475
|
-
description:
|
|
476
|
-
'列出所有可用的 Agent Skill 文档及其适用场景摘要。\n' +
|
|
477
|
-
'Skills 是 AutoSnippet 的领域知识文档,指导你如何高质量地完成各类任务。\n' +
|
|
478
|
-
'每个 Skill 包含:name(名称)、summary(摘要)、useCase(适用场景)。\n' +
|
|
479
|
-
'\n' +
|
|
480
|
-
'使用建议:\n' +
|
|
481
|
-
' • 首次使用 AutoSnippet 时调用此工具了解能力全景\n' +
|
|
482
|
-
' • 不确定该怎么做时,先加载 autosnippet-intent(意图路由 Skill)\n' +
|
|
483
|
-
' • 执行具体任务前,加载对应的 Skill 获取操作指南和最佳实践',
|
|
484
|
-
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
485
|
-
},
|
|
486
|
-
// 33. Skills 加载:按需获取指定 Skill 的完整操作指南
|
|
487
|
-
{
|
|
488
|
-
name: 'autosnippet_load_skill',
|
|
489
|
-
description:
|
|
490
|
-
'加载指定的 Agent Skill 文档,获取领域操作指南和最佳实践参考。\n' +
|
|
491
|
-
'返回 Skill 的完整 Markdown 内容、适用场景说明、以及相关 Skill 推荐。\n' +
|
|
492
|
-
'\n' +
|
|
493
|
-
'核心 Skills 推荐:\n' +
|
|
494
|
-
' • autosnippet-intent — 意图路由,不确定该用哪个 Skill 时先加载它\n' +
|
|
495
|
-
' • autosnippet-coldstart — 冷启动全流程指南(9 维度分析)\n' +
|
|
496
|
-
' • autosnippet-analysis — 深度项目分析(扫描 + 语义补齐)\n' +
|
|
497
|
-
' • autosnippet-candidates — 高质量候选生成(V2 全字段)\n' +
|
|
498
|
-
' • autosnippet-guard — Guard 代码规范审计\n' +
|
|
499
|
-
' • autosnippet-recipes — 项目标准查询(Recipe 上下文)\n' +
|
|
500
|
-
' • autosnippet-reference-{swift,objc,jsts} — 语言最佳实践参考',
|
|
501
|
-
inputSchema: {
|
|
502
|
-
type: 'object',
|
|
503
|
-
properties: {
|
|
504
|
-
skillName: { type: 'string', description: 'Skill 名称(如 autosnippet-coldstart)。调用 autosnippet_list_skills 可获取完整列表。' },
|
|
505
|
-
section: { type: 'string', description: '可选:只返回指定章节(匹配 ## 标题关键词),减少 Token 消耗' },
|
|
506
|
-
},
|
|
507
|
-
required: ['skillName'],
|
|
508
|
-
},
|
|
509
|
-
},
|
|
510
|
-
// 34. 创建项目级 Skill
|
|
511
|
-
{
|
|
512
|
-
name: 'autosnippet_create_skill',
|
|
513
|
-
description:
|
|
514
|
-
'创建一个项目级 Skill 文档,写入 AutoSnippet/skills/<name>/SKILL.md。\n' +
|
|
515
|
-
'Skill 是 Agent 的领域知识增强文档,帮助 Agent 正确执行特定任务。\n' +
|
|
516
|
-
'创建后自动更新编辑器索引(.cursor/rules/autosnippet-skills.mdc),使 Skill 被 AI Agent 被动发现。\n' +
|
|
517
|
-
'\n' +
|
|
518
|
-
'使用场景:\n' +
|
|
519
|
-
' • 将反复出现的操作指南/架构决策/编码规范固化为 Skill\n' +
|
|
520
|
-
' • 为特定 Target/模块创建定制化开发指南\n' +
|
|
521
|
-
' • 记录项目私有的最佳实践(不适合放入通用知识库)\n' +
|
|
522
|
-
'\n' +
|
|
523
|
-
'⚠️ 注意:Skill 名称建议使用 kebab-case,如 my-auth-guide',
|
|
524
|
-
inputSchema: {
|
|
525
|
-
type: 'object',
|
|
526
|
-
properties: {
|
|
527
|
-
name: {
|
|
528
|
-
type: 'string',
|
|
529
|
-
description: 'Skill 名称(kebab-case,如 my-auth-guide)。将作为目录名。',
|
|
530
|
-
},
|
|
531
|
-
description: {
|
|
532
|
-
type: 'string',
|
|
533
|
-
description: 'Skill 一句话描述(写入 SKILL.md frontmatter)',
|
|
534
|
-
},
|
|
535
|
-
content: {
|
|
536
|
-
type: 'string',
|
|
537
|
-
description: 'Skill 正文内容(Markdown 格式,不含 frontmatter)',
|
|
538
|
-
},
|
|
539
|
-
overwrite: {
|
|
540
|
-
type: 'boolean',
|
|
541
|
-
default: false,
|
|
542
|
-
description: '如果同名 Skill 已存在,是否覆盖(默认 false)',
|
|
543
|
-
},
|
|
544
|
-
createdBy: {
|
|
545
|
-
type: 'string',
|
|
546
|
-
enum: ['manual', 'user-ai', 'system-ai', 'external-ai'],
|
|
547
|
-
default: 'external-ai',
|
|
548
|
-
description: '创建者类型:manual=用户手动 | user-ai=用户调用AI | system-ai=系统自动 | external-ai=外部AI Agent',
|
|
549
|
-
},
|
|
550
|
-
},
|
|
551
|
-
required: ['name', 'description', 'content'],
|
|
552
|
-
},
|
|
553
|
-
},
|
|
554
|
-
// 35. Skill 推荐:基于使用模式分析,推荐创建 Skill
|
|
555
|
-
{
|
|
556
|
-
name: 'autosnippet_suggest_skills',
|
|
557
|
-
description:
|
|
558
|
-
'基于项目使用模式分析,推荐创建 Skill。\n' +
|
|
559
|
-
'分析 4 个维度:Guard 违规模式、Memory 偏好积累、Recipe 分布缺口、候选积压率。\n' +
|
|
560
|
-
'返回推荐列表(含 name / description / rationale / priority),Agent 可据此直接调用 autosnippet_create_skill 创建。\n' +
|
|
561
|
-
'\n' +
|
|
562
|
-
'使用时机:\n' +
|
|
563
|
-
' • 项目使用一段时间后,定期调用检查是否有新的 Skill 需求\n' +
|
|
564
|
-
' • 用户反复说"我们项目不用…"、"以后都…"等偏好表述时\n' +
|
|
565
|
-
' • Guard 违规频繁出现同一规则时\n' +
|
|
566
|
-
' • 候选被大量驳回时',
|
|
567
|
-
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
568
|
-
},
|
|
569
|
-
// 36. 删除项目级 Skill
|
|
570
|
-
{
|
|
571
|
-
name: 'autosnippet_delete_skill',
|
|
572
|
-
description:
|
|
573
|
-
'删除一个项目级 Skill 及其目录。\n' +
|
|
574
|
-
'⚠️ 内置 Skill 不可删除。删除后自动更新编辑器索引。\n' +
|
|
575
|
-
'\n' +
|
|
576
|
-
'使用场景:\n' +
|
|
577
|
-
' • 清理不再需要的自定义 Skill\n' +
|
|
578
|
-
' • 移除过时或错误的操作指南',
|
|
579
|
-
inputSchema: {
|
|
580
|
-
type: 'object',
|
|
581
|
-
properties: {
|
|
582
|
-
name: {
|
|
583
|
-
type: 'string',
|
|
584
|
-
description: 'Skill 名称(如 my-auth-guide)',
|
|
585
|
-
},
|
|
586
|
-
},
|
|
587
|
-
required: ['name'],
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
// 37. 更新项目级 Skill
|
|
591
|
-
{
|
|
592
|
-
name: 'autosnippet_update_skill',
|
|
593
|
-
description:
|
|
594
|
-
'更新已存在的项目级 Skill 的描述或内容。\n' +
|
|
595
|
-
'⚠️ 内置 Skill 不可更新。更新后自动刷新编辑器索引。\n' +
|
|
596
|
-
'\n' +
|
|
597
|
-
'使用场景:\n' +
|
|
598
|
-
' • 迭代改进已有 Skill 的操作指南\n' +
|
|
599
|
-
' • 更新过时的最佳实践内容\n' +
|
|
600
|
-
' • 修正 Skill 描述或补充新章节',
|
|
601
|
-
inputSchema: {
|
|
602
|
-
type: 'object',
|
|
603
|
-
properties: {
|
|
604
|
-
name: {
|
|
605
|
-
type: 'string',
|
|
606
|
-
description: 'Skill 名称(必须已存在于项目级 Skills 中)',
|
|
607
|
-
},
|
|
608
|
-
description: {
|
|
609
|
-
type: 'string',
|
|
610
|
-
description: '新的一句话描述(可选,不传则保持原值)',
|
|
611
|
-
},
|
|
612
|
-
content: {
|
|
613
|
-
type: 'string',
|
|
614
|
-
description: '新的正文内容(Markdown 格式,不含 frontmatter)。不传则保持原值',
|
|
615
|
-
},
|
|
616
|
-
},
|
|
617
|
-
required: ['name'],
|
|
618
|
-
},
|
|
619
|
-
},
|
|
620
|
-
// 38. ② 内容润色:Bootstrap 候选 AI 精炼(Phase 6)
|
|
621
|
-
{
|
|
622
|
-
name: 'autosnippet_bootstrap_refine',
|
|
623
|
-
description:
|
|
624
|
-
'② 内容润色 — 使用项目内 AI 逐条精炼 Bootstrap 候选的内容质量。\n' +
|
|
625
|
-
'改善 summary 描述(从模板化 → 精准自然语言)、补充架构 insight 洞察、推断 relations 关联、调整 confidence 评分、丰富 tags。\n' +
|
|
626
|
-
'\n' +
|
|
627
|
-
'⚠️ 必须在 autosnippet_enrich_candidates 之后调用(确保字段完整后再润色)。\n' +
|
|
628
|
-
'建议流程:autosnippet_bootstrap_knowledge → autosnippet_enrich_candidates → 本工具。\n' +
|
|
629
|
-
'需要项目内 AI Provider 已配置。如未配置,请直接用你自己的 AI 能力分析并更新候选。',
|
|
630
|
-
inputSchema: {
|
|
631
|
-
type: 'object',
|
|
632
|
-
properties: {
|
|
633
|
-
candidateIds: { type: 'array', items: { type: 'string' }, description: '指定候选 ID 列表(可选,默认全部 bootstrap 候选)' },
|
|
634
|
-
userPrompt: { type: 'string', description: '用户自定义润色提示词,指导 AI 润色方向(如"侧重描述线程安全注意事项")' },
|
|
635
|
-
dryRun: { type: 'boolean', default: false, description: '仅预览 AI 润色结果,不写入数据库' },
|
|
636
|
-
},
|
|
637
|
-
required: [],
|
|
638
|
-
},
|
|
639
|
-
},
|
|
640
|
-
// ═══ V3 知识条目(统一实体) ═══════════════════════════════
|
|
641
|
-
// 36. 单条知识提交(V3 wire format 直通)
|
|
642
|
-
{
|
|
643
|
-
name: 'autosnippet_submit_knowledge',
|
|
644
|
-
description:
|
|
645
|
-
'提交单条知识条目到 AutoSnippet 知识库(V3 统一实体)。\n' +
|
|
646
|
-
'参数即 wire format — 直接构造 KnowledgeEntry。\n' +
|
|
647
|
-
'⚠️ Cursor Delivery 字段(kind/doClause/topicHint)直接影响 .mdc 规则文件生成质量,请务必填写。\n' +
|
|
648
|
-
'\n' +
|
|
649
|
-
'核心必填: title + language + content(pattern 或 markdown) + kind + doClause\n' +
|
|
650
|
-
'推荐填写: trigger, topicHint, whenClause, dontClause, coreCode, reasoning, tags\n' +
|
|
651
|
-
'\n' +
|
|
652
|
-
'根据 ConfidenceRouter 自动路由:高置信度自动入库(active),低置信度待审核(pending)。',
|
|
653
|
-
inputSchema: {
|
|
654
|
-
type: 'object',
|
|
655
|
-
properties: {
|
|
656
|
-
// ── 必填 ──
|
|
657
|
-
title: { type: 'string', description: '中文标题(≤20字)' },
|
|
658
|
-
language: { type: 'string', description: '编程语言(swift/objectivec/javascript/typescript/python,小写)' },
|
|
659
|
-
content: {
|
|
660
|
-
type: 'object',
|
|
661
|
-
description: '内容值对象(必须有 pattern 或 markdown)',
|
|
662
|
-
properties: {
|
|
663
|
-
pattern: { type: 'string', description: '完整代码片段(函数/方法/类实现)' },
|
|
664
|
-
markdown: { type: 'string', description: '项目特写 Markdown(技术说明文档)' },
|
|
665
|
-
rationale: { type: 'string', description: '设计原理(英文)' },
|
|
666
|
-
steps: { type: 'array', items: { type: 'object', properties: {
|
|
667
|
-
title: { type: 'string' }, description: { type: 'string' }, code: { type: 'string' },
|
|
668
|
-
}}},
|
|
669
|
-
codeChanges: { type: 'array', items: { type: 'object' } },
|
|
670
|
-
verification: { type: 'object' },
|
|
671
|
-
},
|
|
672
|
-
},
|
|
673
|
-
// ── Cursor Delivery(关键字段,影响 .mdc 规则生成) ──
|
|
674
|
-
kind: { type: 'string', enum: ['rule', 'pattern', 'fact'], description: '知识类型: rule=必须遵守的规则, pattern=可复用代码模板, fact=参考信息' },
|
|
675
|
-
doClause: { type: 'string', description: '正向指令: 英文祈使句 ≤60 tokens(e.g. "Use dependency injection via constructor")' },
|
|
676
|
-
dontClause: { type: 'string', description: '反向约束: 英文(不以 Don\'t 开头),e.g. "Instantiate services with new directly"' },
|
|
677
|
-
whenClause: { type: 'string', description: '触发场景: 英文描述何时应用此知识(e.g. "When creating a new ViewController subclass")' },
|
|
678
|
-
topicHint: { type: 'string', description: '主题分组标签,用于 .mdc 文件归类(e.g. "networking", "ui-layout", "error-handling", "data-model")' },
|
|
679
|
-
coreCode: { type: 'string', description: '3-8 行精华代码骨架,可直接复制使用(无 Markdown 格式)' },
|
|
680
|
-
trigger: { type: 'string', description: '触发关键词(@前缀 kebab-case,e.g. "@json-parse")' },
|
|
681
|
-
// ── 分类 ──
|
|
682
|
-
category: { type: 'string', description: '分类: View/Service/Tool/Model/Network/Storage/UI/Utility' },
|
|
683
|
-
knowledgeType: { type: 'string', description: '知识维度: code-pattern|architecture|best-practice|boundary-constraint|...' },
|
|
684
|
-
complexity: { type: 'string', enum: ['beginner', 'intermediate', 'advanced'] },
|
|
685
|
-
scope: { type: 'string', enum: ['universal', 'project-specific', 'target-specific'] },
|
|
686
|
-
difficulty: { type: 'string' },
|
|
687
|
-
tags: { type: 'array', items: { type: 'string' } },
|
|
688
|
-
// ── 描述 ──
|
|
689
|
-
description: { type: 'string', description: '中文简述 ≤80 字(引用真实类名/方法名)' },
|
|
690
|
-
// ── 约束与关系 ──
|
|
691
|
-
constraints: { type: 'object', description: '约束 {guards[], boundaries[], preconditions[], sideEffects[]}' },
|
|
692
|
-
relations: { type: 'object', description: '关系分桶 {inherits[], extends[], depends_on[], conflicts[], related[], ...}' },
|
|
693
|
-
// ── 推理 ──
|
|
694
|
-
reasoning: {
|
|
695
|
-
type: 'object',
|
|
696
|
-
description: '推理依据',
|
|
697
|
-
properties: {
|
|
698
|
-
whyStandard: { type: 'string', description: '为什么值得沉淀为知识' },
|
|
699
|
-
sources: { type: 'array', items: { type: 'string' }, description: '来源文件列表' },
|
|
700
|
-
confidence: { type: 'number', description: '置信度 0-1' },
|
|
701
|
-
qualitySignals: { type: 'object' },
|
|
702
|
-
alternatives: { type: 'array', items: { type: 'string' } },
|
|
703
|
-
},
|
|
704
|
-
},
|
|
705
|
-
// ── 头文件 ──
|
|
706
|
-
headers: { type: 'array', items: { type: 'string' }, description: '完整 import/include 语句' },
|
|
707
|
-
headerPaths: { type: 'array', items: { type: 'string' } },
|
|
708
|
-
moduleName: { type: 'string' },
|
|
709
|
-
includeHeaders: { type: 'boolean' },
|
|
710
|
-
// ── 控制 ──
|
|
711
|
-
source: { type: 'string', description: '来源标识(默认 mcp)' },
|
|
712
|
-
client_id: { type: 'string', description: '客户端标识(用于限流)' },
|
|
713
|
-
},
|
|
714
|
-
required: ['title', 'language', 'content', 'kind', 'doClause'],
|
|
715
|
-
},
|
|
716
|
-
},
|
|
717
|
-
// 37. 批量知识提交
|
|
718
|
-
{
|
|
719
|
-
name: 'autosnippet_submit_knowledge_batch',
|
|
720
|
-
description:
|
|
721
|
-
'批量提交知识条目到知识库(V3 统一实体)。\n' +
|
|
722
|
-
'每条 item 使用与 autosnippet_submit_knowledge 相同的 wire format。\n' +
|
|
723
|
-
'每条 item 必须包含 Cursor Delivery 字段(kind/doClause),否则生成的 .mdc 规则质量低。\n' +
|
|
724
|
-
'支持去重。返回逐条结果与 recipeReadyHints。',
|
|
725
|
-
inputSchema: {
|
|
726
|
-
type: 'object',
|
|
727
|
-
properties: {
|
|
728
|
-
target_name: { type: 'string', description: 'Target 名称' },
|
|
729
|
-
items: { type: 'array', description: '知识条目数组,每项字段同 submit_knowledge(必须含 kind/doClause)', items: { type: 'object' } },
|
|
730
|
-
source: { type: 'string', default: 'cursor-scan', description: '来源标识' },
|
|
731
|
-
deduplicate: { type: 'boolean', default: true, description: '是否去重' },
|
|
732
|
-
client_id: { type: 'string', description: '客户端标识(用于限流)' },
|
|
733
|
-
},
|
|
734
|
-
required: ['target_name', 'items'],
|
|
735
|
-
},
|
|
736
|
-
},
|
|
737
|
-
// 38. 知识条目生命周期操作
|
|
738
|
-
{
|
|
739
|
-
name: 'autosnippet_knowledge_lifecycle',
|
|
740
|
-
description:
|
|
741
|
-
'知识条目生命周期操作。\n' +
|
|
742
|
-
'可用操作: submit(draft→pending), approve(pending→approved), reject(pending→rejected),\n' +
|
|
743
|
-
'publish(approved→active), deprecate(active→deprecated), reactivate(deprecated→active),\n' +
|
|
744
|
-
'to_draft(rejected→draft), fast_track(draft→active 一键发布)。',
|
|
745
|
-
inputSchema: {
|
|
746
|
-
type: 'object',
|
|
747
|
-
properties: {
|
|
748
|
-
id: { type: 'string', description: '知识条目 ID' },
|
|
749
|
-
action: { type: 'string', enum: ['submit', 'approve', 'reject', 'publish', 'deprecate', 'reactivate', 'to_draft', 'fast_track'], description: '生命周期操作' },
|
|
750
|
-
reason: { type: 'string', description: 'reject/deprecate 时必须提供原因' },
|
|
751
|
-
},
|
|
752
|
-
required: ['id', 'action'],
|
|
753
|
-
},
|
|
754
|
-
},
|
|
755
|
-
// 39. 保存开发文档
|
|
756
|
-
{
|
|
757
|
-
name: 'autosnippet_save_document',
|
|
758
|
-
description:
|
|
759
|
-
'保存开发文档到知识库(架构设计、排查报告、决策记录、调研笔记等)。\n' +
|
|
760
|
-
'仅需 title + markdown,无需填写 kind/doClause/trigger 等 Cursor Delivery 字段。\n' +
|
|
761
|
-
'文档自动以 dev-document 类型存储,不参与 Cursor Rules 压缩,保持原文完整性。\n' +
|
|
762
|
-
'交付路径: Channel D → .cursor/skills/autosnippet-devdocs/references/*.md。\n' +
|
|
763
|
-
'Agent 可通过 autosnippet_search 全文检索已保存的文档。',
|
|
764
|
-
inputSchema: {
|
|
765
|
-
type: 'object',
|
|
766
|
-
properties: {
|
|
767
|
-
title: { type: 'string', description: '文档标题(中英文皆可)' },
|
|
768
|
-
markdown: { type: 'string', description: '文档 Markdown 全文' },
|
|
769
|
-
description: { type: 'string', description: '一句话摘要(可选)' },
|
|
770
|
-
tags: { type: 'array', items: { type: 'string' }, description: '标签列表,如 ["adr", "debug-report", "design-doc", "research"]' },
|
|
771
|
-
scope: { type: 'string', enum: ['universal', 'project-specific'], default: 'project-specific', description: '适用范围' },
|
|
772
|
-
source: { type: 'string', description: '来源标识(默认 agent)' },
|
|
773
|
-
},
|
|
774
|
-
required: ['title', 'markdown'],
|
|
775
|
-
},
|
|
776
|
-
},
|
|
777
381
|
];
|