autosnippet 2.19.7 → 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/{icons-C7FN32VL.js → icons-CEfgGaZi.js} +1 -1
- package/dashboard/dist/assets/{index-B5dbY-cS.js → index-_Sk_Dmg3.js} +42 -42
- package/dashboard/dist/assets/{vendor-Ba1BZjav.js → vendor-CEnWn7aV.js} +384 -380
- package/dashboard/dist/index.html +3 -5
- 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
- package/dashboard/dist/assets/react-markdown-Dc1U8Kko.js +0 -1
- package/dashboard/dist/assets/syntax-highlighter-BkDyUteW.js +0 -5
|
@@ -129,8 +129,8 @@ export class RulesGenerator {
|
|
|
129
129
|
...ruleLines,
|
|
130
130
|
'',
|
|
131
131
|
'For detailed patterns and recipes, AutoSnippet MCP tools are available:',
|
|
132
|
-
'- `autosnippet_search(query)` — search knowledge base',
|
|
133
|
-
'- `
|
|
132
|
+
'- `autosnippet_search({ query })` — search knowledge base (auto mode: BM25 + semantic)',
|
|
133
|
+
'- `autosnippet_search({ query, mode: "context" })` — context-aware search with history',
|
|
134
134
|
];
|
|
135
135
|
return lines.join('\n') + '\n';
|
|
136
136
|
}
|
|
@@ -98,7 +98,7 @@ export class SkillAdvisor {
|
|
|
98
98
|
existingProjectSkills: [...existingSkills],
|
|
99
99
|
analysisContext,
|
|
100
100
|
hint: suggestions.length > 0
|
|
101
|
-
? `发现 ${suggestions.length} 个 Skill 创建建议。你可以使用
|
|
101
|
+
? `发现 ${suggestions.length} 个 Skill 创建建议。你可以使用 autosnippet_skill({ operation: "create" }) 直接创建,也可以根据 rationale 自行判断是否需要。`
|
|
102
102
|
: '当前项目使用模式暂无明确的 Skill 创建建议。继续使用后会积累更多信号。',
|
|
103
103
|
};
|
|
104
104
|
}
|
package/package.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* 将 AutoSnippet 自带的 Agent Skills 安装到「当前项目根」的 Cursor 环境(项目根/.cursor/skills/)。
|
|
5
5
|
* 项目根:从当前工作目录向上查找含 AutoSnippet.boxspec.json 的目录的父级;未找到则用当前目录。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* V3 策略:静态索引 + MCP 按需检索
|
|
8
8
|
* - project-recipes-context.md:轻量索引(title | trigger | category | summary),不再塞全文
|
|
9
|
-
* - Agent 需要详情时调用 MCP:
|
|
10
|
-
* - guard-context.md:同为轻量索引(fallback 用),Guard 主路径走 MCP
|
|
9
|
+
* - Agent 需要详情时调用 MCP: autosnippet_knowledge({ operation: "get" }) / autosnippet_search
|
|
10
|
+
* - guard-context.md:同为轻量索引(fallback 用),Guard 主路径走 MCP autosnippet_guard
|
|
11
11
|
*
|
|
12
12
|
* 运行方式:在项目根目录执行 npm run install:cursor-skill,或 asd install:cursor-skill,或 node scripts/install-cursor-skill.js
|
|
13
13
|
*/
|
|
@@ -148,7 +148,7 @@ function extractFrontmatterFields(content) {
|
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* V2: 生成轻量 Recipe 索引(title | trigger | category | summary)
|
|
151
|
-
* Agent 需要详情时调用 MCP:
|
|
151
|
+
* Agent 需要详情时调用 MCP: autosnippet_knowledge({ operation: "get" }) / autosnippet_search
|
|
152
152
|
*/
|
|
153
153
|
function buildProjectRecipesContext(projectRoot) {
|
|
154
154
|
const recipesDir = getRecipesDir(projectRoot);
|
|
@@ -159,7 +159,7 @@ function buildProjectRecipesContext(projectRoot) {
|
|
|
159
159
|
const lines = [
|
|
160
160
|
'# Project Recipes Index\n\n',
|
|
161
161
|
'Generated by `asd install:cursor-skill`. **轻量索引** — 只含摘要信息。\n',
|
|
162
|
-
'Agent 需要 Recipe 全文时请调用 MCP: `
|
|
162
|
+
'Agent 需要 Recipe 全文时请调用 MCP: `autosnippet_knowledge({ operation: "get", id })` / `autosnippet_search(query)`\n\n',
|
|
163
163
|
`Total: ${mdFiles.length} recipes\n\n`,
|
|
164
164
|
'| # | File | Title | Trigger | Category | Language | Kind | Summary |\n',
|
|
165
165
|
'|---|------|-------|---------|----------|----------|------|---------|\n',
|
|
@@ -200,10 +200,10 @@ function buildProjectRecipesContext(projectRoot) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
lines.push('\n## Usage Tips\n\n');
|
|
203
|
-
lines.push('- 查找 Recipe: `autosnippet_search(query)` 或 `
|
|
204
|
-
lines.push('- 获取详情: `
|
|
205
|
-
lines.push('- 按类型浏览: `
|
|
206
|
-
lines.push('- Guard 检查: `
|
|
203
|
+
lines.push('- 查找 Recipe: `autosnippet_search({ query })` 或 `autosnippet_search({ query, mode: "context" })`\n');
|
|
204
|
+
lines.push('- 获取详情: `autosnippet_knowledge({ operation: "get", id })` — 返回完整 Recipe 内容、关系、约束\n');
|
|
205
|
+
lines.push('- 按类型浏览: `autosnippet_knowledge({ operation: "list", kind: "rule" })` / `kind: "pattern"` / `kind: "fact"`\n');
|
|
206
|
+
lines.push('- Guard 检查: `autosnippet_guard({ code })` / `autosnippet_guard({ files })`\n');
|
|
207
207
|
|
|
208
208
|
return lines.join('');
|
|
209
209
|
}
|
|
@@ -307,7 +307,7 @@ if (fs.existsSync(cursorRulesSource)) {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
// 可选:写入 MCP 配置,使
|
|
310
|
+
// 可选:写入 MCP 配置,使 autosnippet_search 等工具可用(连接层封装在此)
|
|
311
311
|
const mcpPath = path.join(projectRoot, '.cursor', 'mcp.json');
|
|
312
312
|
const mcpServerScript = path.join(autoSnippetRoot, 'bin', 'mcp-server.js');
|
|
313
313
|
const addMcp = process.argv.includes('--mcp');
|
|
@@ -5,11 +5,13 @@ description: Deep project analysis — full scan + semantic field enrichment + g
|
|
|
5
5
|
|
|
6
6
|
# AutoSnippet — Deep Project Analysis & Semantic Enrichment
|
|
7
7
|
|
|
8
|
-
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 autosnippet_health
|
|
8
|
+
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 `autosnippet_health`;失败时不在同一轮重试,转用静态上下文或缩小范围后再试。
|
|
9
9
|
|
|
10
10
|
## Core Principle
|
|
11
11
|
|
|
12
|
-
**MCP 工具负责数据采集 + 静态检查;你(Agent
|
|
12
|
+
**MCP 工具负责数据采集 + 静态检查;你(Agent)负责语义理解;Agent 直接填写完整字段后通过 `autosnippet_submit_knowledge` 提交。**
|
|
13
|
+
|
|
14
|
+
**⚠️ 严格提交规则**:`autosnippet_submit_knowledge` 实施严格前置校验——缺少必要字段的提交将被**直接拒绝(不入库)**。必须在单次调用中一次性提供所有必填字段(title, language, content, kind, doClause, category, trigger, description, headers, usageGuide, knowledgeType, content.rationale)。不要分步提交或先提交再补全。
|
|
13
15
|
|
|
14
16
|
---
|
|
15
17
|
|
|
@@ -24,7 +26,7 @@ description: Deep project analysis — full scan + semantic field enrichment + g
|
|
|
24
26
|
### Workflow
|
|
25
27
|
|
|
26
28
|
#### Phase 1: Collect & Baseline
|
|
27
|
-
1. 调用 `
|
|
29
|
+
1. 调用 `autosnippet_bootstrap(operation=scan)` 获取文件列表 + Guard 审计基线
|
|
28
30
|
2. 审视 Guard 违规 — 静态规则问题 (命名/API 使用/废弃 API)
|
|
29
31
|
3. 确定高优先级文件 (核心模块/共享工具/Service 层)
|
|
30
32
|
|
|
@@ -48,13 +50,21 @@ description: Deep project analysis — full scan + semantic field enrichment + g
|
|
|
48
50
|
```json
|
|
49
51
|
{
|
|
50
52
|
"title": "网络层统一错误处理模式",
|
|
51
|
-
"
|
|
53
|
+
"content": {
|
|
54
|
+
"pattern": "<实际代码模式>",
|
|
55
|
+
"rationale": "统一错误处理避免分散的 try-catch,便于日志收集和错误上报"
|
|
56
|
+
},
|
|
52
57
|
"language": "swift",
|
|
58
|
+
"kind": "pattern",
|
|
59
|
+
"doClause": "Use centralized error handling via APIClient.request() for all network calls",
|
|
53
60
|
"category": "Network",
|
|
61
|
+
"trigger": "@network-error-handling",
|
|
62
|
+
"description": "网络层统一错误处理——所有请求通过 APIClient.request() 封装,统一 catch + 日志上报",
|
|
63
|
+
"headers": ["import Combine", "import Foundation"],
|
|
64
|
+
"usageGuide": "### 何时使用\n发起网络请求时统一通过 APIClient\n### 如何使用\n1. 创建 NetworkError 枚举 2. 调用 APIClient.request()",
|
|
54
65
|
"knowledgeType": "code-pattern",
|
|
55
66
|
"complexity": "intermediate",
|
|
56
67
|
"scope": "project-specific",
|
|
57
|
-
"rationale": "统一错误处理避免分散的 try-catch,便于日志收集和错误上报",
|
|
58
68
|
"steps": [
|
|
59
69
|
{ "title": "创建 Error 枚举", "description": "在 Network/ 下创建 NetworkError.swift", "code": "enum NetworkError: Error { ... }" },
|
|
60
70
|
{ "title": "封装请求方法", "description": "所有请求统一通过 APIClient.request()", "code": "" }
|
|
@@ -76,7 +86,7 @@ description: Deep project analysis — full scan + semantic field enrichment + g
|
|
|
76
86
|
Use `autosnippet_submit_knowledge_batch` for batch submission.
|
|
77
87
|
|
|
78
88
|
#### Phase 4: Guard Deep Audit (Optional)
|
|
79
|
-
对特定文件调用 `
|
|
89
|
+
对特定文件调用 `autosnippet_guard` (files[]) 做深度规范审计。
|
|
80
90
|
|
|
81
91
|
---
|
|
82
92
|
|
|
@@ -104,17 +114,13 @@ Use `autosnippet_submit_knowledge_batch` for batch submission.
|
|
|
104
114
|
在分析代码时,直接填写所有 6 个语义字段到 `autosnippet_submit_knowledge` 调用中。
|
|
105
115
|
|
|
106
116
|
**方式 B: 对已有候选调用 AI 补全**
|
|
107
|
-
|
|
108
|
-
autosnippet_enrich_candidates({ candidateIds: ["id1", "id2", ...] })
|
|
109
|
-
```
|
|
110
|
-
AI 会分析每条候选的代码,自动填充缺失字段(已有字段不会被覆盖)。
|
|
117
|
+
> 注:`autosnippet_enrich_candidates` 已移入 admin 层级,Agent 推荐使用方式 A 直接填写完整字段。
|
|
111
118
|
|
|
112
119
|
**方式 C: Bootstrap 候选 AI 润色**
|
|
113
120
|
```
|
|
114
|
-
|
|
121
|
+
autosnippet_bootstrap(operation=refine, candidateIds: ["id1", "id2", ...])
|
|
115
122
|
```
|
|
116
123
|
使用 AI 对 Bootstrap 候选做内容润色(改善 summary、补充 insight、推断 relations、调整 confidence)。
|
|
117
|
-
必须在 `autosnippet_enrich_candidates` 之后调用(确保字段完整后再润色)。
|
|
118
124
|
|
|
119
125
|
---
|
|
120
126
|
|
|
@@ -126,12 +132,11 @@ autosnippet_bootstrap_refine({ candidateIds: ["id1", "id2", ...] })
|
|
|
126
132
|
|
|
127
133
|
### Workflow
|
|
128
134
|
|
|
129
|
-
1.
|
|
130
|
-
2. 调用 `
|
|
131
|
-
3.
|
|
132
|
-
4.
|
|
133
|
-
5.
|
|
134
|
-
6. 如缺失字段 AI 无法填充,提示用户手动补充
|
|
135
|
+
1. 对目标候选做结构补齐(确保所有字段完整)
|
|
136
|
+
2. 调用 `autosnippet_bootstrap(operation=refine)` 对候选做 AI 润色(summary/insight/relations)
|
|
137
|
+
3. 提交时使用 `autosnippet_submit_knowledge`(内置自动校验 + 去重检查)
|
|
138
|
+
4. 报告补全情况 + 缺失字段 + 重复风险
|
|
139
|
+
5. 如缺失字段 AI 无法填充,提示用户手动补充
|
|
135
140
|
|
|
136
141
|
### Recipe 必备字段检查清单
|
|
137
142
|
|
|
@@ -5,7 +5,7 @@ description: Generate Recipe candidates with full V3 structured information. Sin
|
|
|
5
5
|
|
|
6
6
|
# AutoSnippet - Generate Candidates with Structured Content (v3.1)
|
|
7
7
|
|
|
8
|
-
> Self-check and Fallback: MCP tools return unified JSON Envelope. Before heavy ops call autosnippet_health
|
|
8
|
+
> Self-check and Fallback: MCP tools return unified JSON Envelope. Before heavy ops call `autosnippet_health`. On failure do not retry in same turn; use static context or narrow scope.
|
|
9
9
|
|
|
10
10
|
## Core Rule: Agent Permission Boundary
|
|
11
11
|
|
|
@@ -18,33 +18,37 @@ Recipe creation, review, publish, update, deprecate, delete are **human-only via
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
## ⚠️ Recipe-Ready Checklist (CRITICAL)
|
|
21
|
+
## ⚠️ Recipe-Ready Checklist (CRITICAL — STRICT ENFORCEMENT)
|
|
22
22
|
|
|
23
|
-
**MCP 不再使用项目内 AI**——外部 Agent
|
|
23
|
+
**MCP 不再使用项目内 AI**——外部 Agent 必须自行提供所有字段。**缺少必要字段的提交将被直接拒绝(不入库)**,不会降级处理。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
**严格规则**:
|
|
26
|
+
- 所有必填字段必须在**单次调用**中一次性提供
|
|
27
|
+
- 缺字段的提交会返回 `errorCode: INCOMPLETE_SUBMISSION`,不会创建任何记录
|
|
28
|
+
- **禁止**先提交不完整数据再补全重新提交 — 这会浪费 Token 和时间
|
|
29
|
+
- 提交前自行确认所有字段齐全,一次通过
|
|
26
30
|
|
|
27
31
|
| 字段 | 级别 | 要求 | 示例 |
|
|
28
32
|
|------|------|------|------|
|
|
29
33
|
| `title` | 必填 | 中文简短标题(≤20字) | "视频封面 Cell 16:9 布局与时长格式化" |
|
|
30
|
-
| `
|
|
34
|
+
| `content.pattern` / `content.markdown` | 必填 | 代码片段或 Markdown 正文 | 完整可运行的使用示例 |
|
|
35
|
+
| `content.rationale` | 必填 | 设计原理说明 | "统一封面布局避免手动计算" |
|
|
31
36
|
| `language` | 必填 | `swift` / `objectivec` | 小写,不要用 `objc` |
|
|
37
|
+
| `kind` | 必填 | `rule` / `pattern` / `fact` | 知识类型 |
|
|
38
|
+
| `doClause` | 必填 | 英文祈使句正向指令(≤60 tokens) | "Use AspectRatioContainer for 16:9 layout" |
|
|
32
39
|
| `category` | 必填 | 8 选 1 | View/Service/Tool/Model/Network/Storage/UI/Utility |
|
|
33
40
|
| `trigger` | 必填 | @ 开头小写 | `@video-cover-cell` |
|
|
34
|
-
| `
|
|
35
|
-
| `summary_en` | 强烈建议 | 英文摘要 ≤100 words | "Cover image 16:9 adaptive layout…" |
|
|
41
|
+
| `description` | 必填 | 中文摘要 ≤80字 | "封面图片 16:9 自适应布局…" |
|
|
36
42
|
| `headers` | 必填 | 完整 import 语句数组 | `["#import <UIKit/UIKit.h>"]` |
|
|
37
|
-
| `usageGuide` |
|
|
38
|
-
| `
|
|
39
|
-
| `reasoning` |
|
|
40
|
-
| `knowledgeType` | 强烈建议 | 12 维度之一 | `code-pattern` |
|
|
41
|
-
| `rationale` | 强烈廚议 | 设计原理 | "统一封面布局避免手动计算" |
|
|
43
|
+
| `usageGuide` | 必填 | Markdown ### 章节格式 | 描述何时/如何使用此知识 |
|
|
44
|
+
| `knowledgeType` | 必填 | 知识维度 | `code-pattern` / `architecture` / `best-practice` 等 |
|
|
45
|
+
| `reasoning` | 强烈建议 | whyStandard + sources + confidence | 见 Layer 6 |
|
|
42
46
|
|
|
43
47
|
**工作流程**:
|
|
44
|
-
1. Agent
|
|
45
|
-
2.
|
|
46
|
-
3.
|
|
47
|
-
4.
|
|
48
|
+
1. Agent 提取候选时**一次性填写全部必填字段**
|
|
49
|
+
2. 调用 `autosnippet_submit_knowledge` 提交
|
|
50
|
+
3. 若返回 `INCOMPLETE_SUBMISSION` → 检查 `missingFields`,补齐后重新提交
|
|
51
|
+
4. 提交成功 = 候选可直接审核为 Recipe
|
|
48
52
|
|
|
49
53
|
---
|
|
50
54
|
|
|
@@ -58,8 +62,8 @@ Recipe creation, review, publish, update, deprecate, delete are **human-only via
|
|
|
58
62
|
5. Score and rank -> submit Candidates
|
|
59
63
|
|
|
60
64
|
**Scenario 2: User says "batch scan Target"**
|
|
61
|
-
1. Call `
|
|
62
|
-
2. Call `
|
|
65
|
+
1. Call `autosnippet_structure(operation=targets)` -> select targetName
|
|
66
|
+
2. Call `autosnippet_structure(operation=files, targetName)`
|
|
63
67
|
3. Batch extract candidates (parallel)
|
|
64
68
|
4. Dedup, score, similarity mark -> submit Candidates
|
|
65
69
|
|
|
@@ -218,14 +222,13 @@ Severity: `error` (must fix) | `warning` (should fix) | `info` (suggestion)
|
|
|
218
222
|
## Single File / Module Scan Flow
|
|
219
223
|
1. Read file → find public classes/functions/common patterns
|
|
220
224
|
2. Per-file checklist extraction (10 dimensions above)
|
|
221
|
-
3. Call `
|
|
222
|
-
4.
|
|
223
|
-
5. (Optional) `autosnippet_check_duplicate` dedup hint
|
|
225
|
+
3. Call `autosnippet_search(mode=context)` to mark similarity and fill `relations`
|
|
226
|
+
4. `autosnippet_submit_knowledge` submit single (built-in auto-validate + dedup)
|
|
224
227
|
6. `autosnippet_submit_knowledge` or `autosnippet_submit_knowledge_batch` to submit
|
|
225
228
|
|
|
226
229
|
## Batch Target Scan Flow
|
|
227
|
-
1. `
|
|
228
|
-
2. `
|
|
230
|
+
1. `autosnippet_structure(operation=targets)` → select targetName
|
|
231
|
+
2. `autosnippet_structure(operation=files, targetName)`
|
|
229
232
|
3. Parallel scan → per-file checklist extraction → aggregate / dedup / score
|
|
230
233
|
4. `autosnippet_submit_knowledge_batch` batch submit — **all V3 fields are preserved**
|
|
231
234
|
|
|
@@ -241,15 +244,12 @@ Severity: `error` (must fix) | `warning` (should fix) | `info` (suggestion)
|
|
|
241
244
|
|
|
242
245
|
| Tool | Usage |
|
|
243
246
|
|------|-------|
|
|
244
|
-
| `
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `autosnippet_check_duplicate` | Cosine similarity dedup check |
|
|
250
|
-
| `autosnippet_submit_knowledge` | Submit single candidate (**all V3 fields**) |
|
|
247
|
+
| `autosnippet_structure(operation=targets)` | List project Targets for batch scan |
|
|
248
|
+
| `autosnippet_structure(operation=files)` | Get files for a Target |
|
|
249
|
+
| `autosnippet_structure(operation=metadata)` | Get Target metadata (dependencies, path) |
|
|
250
|
+
| `autosnippet_search(mode=context)` | Find similar existing Recipes → fill `relations` |
|
|
251
|
+
| `autosnippet_submit_knowledge` | Submit single candidate (**all V3 fields**, built-in auto-validate + dedup) |
|
|
251
252
|
| `autosnippet_submit_knowledge_batch` | Batch submit candidates (**all V3 fields preserved**) |
|
|
252
|
-
| `autosnippet_submit_knowledge_batch` | Submit .md draft files as candidates |
|
|
253
253
|
|
|
254
254
|
---
|
|
255
255
|
|
|
@@ -304,16 +304,15 @@ Recommended sections: When to use / When not to use / Key points / Dependencies
|
|
|
304
304
|
|
|
305
305
|
### 备选:二次补全流程
|
|
306
306
|
|
|
307
|
-
Step 1: 提交基本字段(title, code, language)→ 获得 candidate ID
|
|
308
|
-
Step 2:
|
|
309
|
-
Step 3:
|
|
310
|
-
Step 4: 重新提交完整候选
|
|
307
|
+
Step 1: 提交基本字段(title, code, language)→ 获得 candidate ID(`autosnippet_submit_knowledge` 内置自动校验 + 去重检查)
|
|
308
|
+
Step 2: 根据提交返回的校验结果补全缺失字段
|
|
309
|
+
Step 3: 重新提交完整候选
|
|
311
310
|
|
|
312
|
-
|
|
313
|
-
- **语义字段** (missingFields): rationale, knowledgeType, complexity, scope, steps, constraints
|
|
314
|
-
- **Recipe 必填** (recipeReadyMissing): category, trigger, summary_cn, summary_en, headers, usageGuide
|
|
311
|
+
> 注:`autosnippet_enrich_candidates` / `autosnippet_validate_candidate` / `autosnippet_check_duplicate` 已移入 admin 层级。Agent 层级的 `autosnippet_submit_knowledge` 已内置自动校验 + 去重,无需额外调用。
|
|
315
312
|
|
|
316
|
-
|
|
313
|
+
需要补全的两层字段:
|
|
314
|
+
- **语义字段**: rationale, knowledgeType, complexity, scope, steps, constraints
|
|
315
|
+
- **Recipe 必填**: category, trigger, summary_cn, summary_en, headers, usageGuide
|
|
317
316
|
|
|
318
317
|
---
|
|
319
318
|
|
|
@@ -16,13 +16,13 @@ description: Cold-start knowledge base initialization. Full 9-dimension analysis
|
|
|
16
16
|
| 已有知识库,查/用 Recipe | → autosnippet-recipes |
|
|
17
17
|
| 只扫描单个文件/模块 | → autosnippet-candidates |
|
|
18
18
|
| 只做 Guard 审计 | → autosnippet-guard |
|
|
19
|
-
| 快速看看项目结构 | → autosnippet-structure(用
|
|
19
|
+
| 快速看看项目结构 | → autosnippet-structure(用 `autosnippet_bootstrap(operation=scan)`) |
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
23
|
## Phase 0: 启动扫描
|
|
24
24
|
|
|
25
|
-
调用 `
|
|
25
|
+
调用 `autosnippet_bootstrap(operation=knowledge)` 收集项目结构化数据:
|
|
26
26
|
|
|
27
27
|
```json
|
|
28
28
|
{ "aiMode": "external", "maxFiles": 500, "contentMaxLines": 150 }
|
|
@@ -226,7 +226,7 @@ description: Cold-start knowledge base initialization. Full 9-dimension analysis
|
|
|
226
226
|
|
|
227
227
|
## Phase 5: 批量提交
|
|
228
228
|
|
|
229
|
-
将所有分析结果通过 `autosnippet_submit_knowledge_batch`
|
|
229
|
+
将所有分析结果通过 `autosnippet_submit_knowledge_batch` 批量提交(内置自动校验 + 去重):
|
|
230
230
|
|
|
231
231
|
```json
|
|
232
232
|
{
|
|
@@ -283,7 +283,7 @@ description: Cold-start knowledge base initialization. Full 9-dimension analysis
|
|
|
283
283
|
|
|
284
284
|
## scan_project vs bootstrap_knowledge
|
|
285
285
|
|
|
286
|
-
| |
|
|
286
|
+
| | `bootstrap(op=scan)` | `bootstrap(op=knowledge)` |
|
|
287
287
|
|---|---|---|
|
|
288
288
|
| **用途** | 快速结构探查(不写库) | 完整知识库初始化(写 knowledge_edges) |
|
|
289
289
|
| **SPM 图谱写入** | ❌ | ✅ |
|
|
@@ -447,17 +447,14 @@ description: Cold-start knowledge base initialization. Full 9-dimension analysis
|
|
|
447
447
|
|
|
448
448
|
| Tool | 用途 |
|
|
449
449
|
|------|------|
|
|
450
|
-
| `
|
|
451
|
-
| `
|
|
452
|
-
| `
|
|
450
|
+
| `autosnippet_bootstrap(operation=knowledge)` | 启动冷启动扫描(本 Skill 核心工具) |
|
|
451
|
+
| `autosnippet_bootstrap(operation=refine)` | AI 精炼候选质量(summary/insight/relations) |
|
|
452
|
+
| `autosnippet_bootstrap(operation=scan)` | 轻量探查(不写库) |
|
|
453
453
|
| `autosnippet_submit_knowledge_batch` | 批量提交候选 |
|
|
454
|
-
| `autosnippet_submit_knowledge` |
|
|
455
|
-
| `
|
|
456
|
-
| `
|
|
457
|
-
| `
|
|
458
|
-
| `autosnippet_scan_project` | 轻量探查(不写库) |
|
|
459
|
-
| `autosnippet_list_skills` | 列出可用 Skill 列表 |
|
|
460
|
-
| `autosnippet_load_skill` | 加载指定 Skill 文档获取指引 |
|
|
454
|
+
| `autosnippet_submit_knowledge` | 提交单条候选(内置自动校验 + 去重检查) |
|
|
455
|
+
| `autosnippet_search(mode=context)` | 查找已有知识(避免重复) |
|
|
456
|
+
| `autosnippet_skill(operation=list)` | 列出可用 Skill 列表 |
|
|
457
|
+
| `autosnippet_skill(operation=load)` | 加载指定 Skill 文档获取指引 |
|
|
461
458
|
|
|
462
459
|
## Related Skills
|
|
463
460
|
|
|
@@ -15,7 +15,7 @@ This skill explains [AutoSnippet](https://github.com/GxFn/AutoSnippet)'s **knowl
|
|
|
15
15
|
4. For **project structure** (targets/dep graph), use **autosnippet-structure**.
|
|
16
16
|
|
|
17
17
|
5. **Self-check & Fallback (统一 Envelope)**
|
|
18
|
-
- Before heavy operations, call `autosnippet_health
|
|
18
|
+
- Before heavy operations, call `autosnippet_health`.
|
|
19
19
|
- All MCP tools return a JSON Envelope: `{ success, errorCode?, message?, data?, meta }`.
|
|
20
20
|
- On failure or empty results, do NOT retry within the same cycle; fall back to static context or ask user for minimal confirmation, then continue with reduced scope.
|
|
21
21
|
|
|
@@ -36,12 +36,12 @@ In AutoSnippet, the **知识库** is the set of project-owned artifacts under **
|
|
|
36
36
|
|
|
37
37
|
## Context Storage and Vector Store
|
|
38
38
|
|
|
39
|
-
The knowledge base has **context storage** capability: Recipes, docs, etc. are embedded and support semantic search. The agent queries on demand via MCP tool `
|
|
39
|
+
The knowledge base has **context storage** capability: Recipes, docs, etc. are embedded and support semantic search. The agent queries on demand via MCP tool `autosnippet_search(mode=context)` without preloading all content.
|
|
40
40
|
|
|
41
41
|
**Safety and role statement**:
|
|
42
42
|
- Context storage and vector store are **safe** external storage; they only hold project knowledge (Recipes, docs, etc.), with no user privacy or sensitive data exposure risk.
|
|
43
43
|
- **Skills express semantics** (when to query, what to query, how to use); **MCP provides capability** (connection, retrieval, response).
|
|
44
|
-
- **Cursor can use Context storage and vector store as external context**: call `
|
|
44
|
+
- **Cursor can use Context storage and vector store as external context**: call `autosnippet_search(mode=context)` on demand to fetch relevant chunks instead of loading all knowledge into the conversation, thus **saving context space** (tokens/context window).
|
|
45
45
|
|
|
46
46
|
| Item | Description |
|
|
47
47
|
|------|-------------|
|
|
@@ -49,12 +49,12 @@ The knowledge base has **context storage** capability: Recipes, docs, etc. are e
|
|
|
49
49
|
| **Build command** | Run `asd embed` from project root |
|
|
50
50
|
| **Index sources** | `recipe` (AutoSnippet/recipes/*.md), `doc` (docs dir), `target-readme` (SPM target READMEs) |
|
|
51
51
|
| **Storage adapter** | Default `json` |
|
|
52
|
-
| **Usage** | With `asd ui` running, MCP tool `
|
|
52
|
+
| **Usage** | With `asd ui` running, MCP tool `autosnippet_search(mode=context)` takes `query`, `limit?` for semantic search |
|
|
53
53
|
| **Use cases** | On-demand lookup of relevant Recipe/docs; Guard review against knowledge base; Dashboard semantic search |
|
|
54
54
|
|
|
55
55
|
**Prerequisites**: `asd embed` run, `asd ui` started, MCP configured.
|
|
56
56
|
|
|
57
|
-
**Usage guidance for Cursor**: Assume `asd ui` is kept running when calling MCP tools (`
|
|
57
|
+
**Usage guidance for Cursor**: Assume `asd ui` is kept running when calling MCP tools (`autosnippet_search`, etc.). If a call fails (e.g. connection refused, API error), do **not** retry within the current agent cycle; fall back to static index (`references/project-recipes-context.md` 轻量索引) or in-context lookup instead.
|
|
58
58
|
|
|
59
59
|
**Envelope reading guidance**:
|
|
60
60
|
- Parse Envelope fields:
|
|
@@ -67,7 +67,6 @@ The knowledge base has **context storage** capability: Recipes, docs, etc. are e
|
|
|
67
67
|
|
|
68
68
|
**Self-check & safety**:
|
|
69
69
|
- Use `autosnippet_health` to verify UI and service availability before heavy operations.
|
|
70
|
-
- Use `autosnippet_capabilities` to list available tools and inputs/outputs.
|
|
71
70
|
- Authentication and HTTP wiring live in MCP, not in Skills. Do not hardcode URLs/HTTP in Skills.
|
|
72
71
|
|
|
73
72
|
---
|
|
@@ -78,24 +77,20 @@ This is a conceptual map. Skills stay semantic; MCP provides capability.
|
|
|
78
77
|
|
|
79
78
|
| Intent | Primary tool(s) |
|
|
80
79
|
|---|---|
|
|
81
|
-
| 统合搜索 | `autosnippet_search`(auto
|
|
82
|
-
| 语义检索 | `
|
|
83
|
-
| 精确检索 | `
|
|
84
|
-
| 向量搜索 | `
|
|
85
|
-
| 知识浏览 | `
|
|
86
|
-
| 结构发现 | `
|
|
87
|
-
| 知识图谱 | `
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
| 项目扫描 | `autosnippet_scan_project` |
|
|
96
|
-
| 冷启动 | `autosnippet_bootstrap_knowledge`, `autosnippet_bootstrap_refine` |
|
|
97
|
-
| Skills 管理 | `autosnippet_list_skills`, `autosnippet_load_skill`, `autosnippet_create_skill`, `autosnippet_update_skill`, `autosnippet_delete_skill`, `autosnippet_suggest_skills` |
|
|
98
|
-
| 自检/能力 | `autosnippet_health`, `autosnippet_capabilities` |
|
|
80
|
+
| 统合搜索 | `autosnippet_search`(mode=auto 融合 BM25+语义) |
|
|
81
|
+
| 语义检索 | `autosnippet_search(mode=context)` |
|
|
82
|
+
| 精确检索 | `autosnippet_search(mode=keyword)` |
|
|
83
|
+
| 向量搜索 | `autosnippet_search(mode=semantic)` |
|
|
84
|
+
| 知识浏览 | `autosnippet_knowledge(operation=list/get/insights)` |
|
|
85
|
+
| 结构发现 | `autosnippet_structure(operation=targets/files/metadata)` |
|
|
86
|
+
| 知识图谱 | `autosnippet_graph(operation=query/impact/path/stats)` |
|
|
87
|
+
| 候选提交 | `autosnippet_submit_knowledge`, `autosnippet_submit_knowledge_batch` |
|
|
88
|
+
| Guard 检查 | `autosnippet_guard`(code 单条 / files[] 批量 — 自动路由) |
|
|
89
|
+
| 使用确认 | `autosnippet_knowledge(operation=confirm_usage)` |
|
|
90
|
+
| 项目扫描 | `autosnippet_bootstrap(operation=scan)` |
|
|
91
|
+
| 冷启动 | `autosnippet_bootstrap(operation=knowledge/refine)` |
|
|
92
|
+
| Skills 管理 | `autosnippet_skill(operation=list/load/create/update/delete/suggest)` |
|
|
93
|
+
| 自检 | `autosnippet_health` |
|
|
99
94
|
|
|
100
95
|
### Failure Handling (Examples)
|
|
101
96
|
- 检索失败(`SEARCH_FAILED`):改用静态 Recipe 目录或缩小关键词后再试(下一轮)。
|
|
@@ -367,7 +362,7 @@ When both Recipe and project source code have relevant implementations, **prefer
|
|
|
367
362
|
## On-Demand Context (when asd ui is running)
|
|
368
363
|
|
|
369
364
|
When `asd ui` is running in the project root, use the HTTP API for on-demand semantic search:
|
|
370
|
-
- MCP tool `
|
|
365
|
+
- MCP tool `autosnippet_search(mode=context)` (pass `query`, `limit?`) → returns relevant Recipe/docs
|
|
371
366
|
- Used to fetch Recipe/docs relevant to the current task dynamically instead of loading all at once.
|
|
372
367
|
|
|
373
368
|
---
|
|
@@ -376,13 +371,13 @@ When `asd ui` is running in the project root, use the HTTP API for on-demand sem
|
|
|
376
371
|
|
|
377
372
|
| Capability | Description | Skill |
|
|
378
373
|
|------------|-------------|-------|
|
|
379
|
-
| **Recipe lookup** | Read `references/project-recipes-context.md` 轻量索引,需全文调 MCP `
|
|
374
|
+
| **Recipe lookup** | Read `references/project-recipes-context.md` 轻量索引,需全文调 MCP `autosnippet_knowledge(operation=get, id)` / `autosnippet_search(mode=context)`. Recipe over source | autosnippet-recipes |
|
|
380
375
|
| **Create Recipe** | Dashboard New Recipe; or write to `_draft_recipe.md` and watch auto-adds; or MCP `autosnippet_submit_knowledge_batch` | autosnippet-create |
|
|
381
376
|
| **Search & insert** | `ass` shortcut or `// as:search`, `asd search`, Dashboard search | autosnippet-search |
|
|
382
377
|
| **Audit review** | `// as:audit`; watch runs AI review against knowledge base | autosnippet-guard |
|
|
383
378
|
| **Dependency graph** | `AutoSnippet/AutoSnippet.spmmap.json`; `asd spm-map` to update; MCP graph tools for querying | autosnippet-structure |
|
|
384
|
-
| **Vector store** | Built by `asd embed`; `
|
|
385
|
-
| **MCP tools** | `autosnippet_search` (统合搜索), `
|
|
379
|
+
| **Vector store** | Built by `asd embed`; `autosnippet_search(mode=context)` for on-demand lookup. Use as context storage to save space | autosnippet-concepts / autosnippet-recipes |
|
|
380
|
+
| **MCP tools** | `autosnippet_search` (统合搜索), `autosnippet_guard` (Guard 检查) | — |
|
|
386
381
|
|
|
387
382
|
**Principles**: Recipe is project standard, over project implementation; do not modify AutoSnippet/ directly, submit via Dashboard or MCP candidate submission. Context storage is safe; Skills express semantics, MCP provides capability; Cursor calls on demand to save space.
|
|
388
383
|
|
|
@@ -600,9 +595,9 @@ authority: 3
|
|
|
600
595
|
|
|
601
596
|
### How to use knowledge once it’s in the base
|
|
602
597
|
|
|
603
|
-
- **Search**: MCP `
|
|
604
|
-
- **Audit**: `// as:audit` runs Guard against Recipe standards. Or call `
|
|
605
|
-
- **Record adoption**: When the user confirms use, call `
|
|
598
|
+
- **Search**: MCP `autosnippet_search` (mode=context/keyword/semantic/auto), or terminal `asd search`, Dashboard search, `ass` shortcut or `// as:search`.
|
|
599
|
+
- **Audit**: `// as:audit` runs Guard against Recipe standards. Or call `autosnippet_guard` via MCP for on-demand checking (with `code` for single snippet or `files[]` for batch).
|
|
600
|
+
- **Record adoption**: When the user confirms use, call `autosnippet_knowledge(operation=confirm_usage)` to record human usage (affects authority and ranking).
|
|
606
601
|
|
|
607
602
|
---
|
|
608
603
|
|
|
@@ -5,7 +5,7 @@ description: Guides the agent to submit module usage code (designed/written with
|
|
|
5
5
|
|
|
6
6
|
# AutoSnippet Create — Submit to Web, Add to AutoSnippet
|
|
7
7
|
|
|
8
|
-
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 autosnippet_health
|
|
8
|
+
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 `autosnippet_health`;失败时不在同一轮重试,转用静态上下文或缩小范围后再试。
|
|
9
9
|
|
|
10
10
|
This skill tells the agent how to **submit module usage code** (that Cursor has designed or the user has written) to the **AutoSnippet web (Dashboard)** so it is **added to the knowledge base (Recipes)**. For concepts (knowledge base, Recipe), use **autosnippet-concepts**. For looking up existing Recipes, use **autosnippet-recipes**.
|
|
11
11
|
|
|
@@ -50,7 +50,7 @@ This skill tells the agent how to **submit module usage code** (that Cursor has
|
|
|
50
50
|
- 后台自动停止,前台自动恢复
|
|
51
51
|
```
|
|
52
52
|
- See [templates/recipes-setup/README.md](../../templates/recipes-setup/README.md) for detailed format guide & examples.
|
|
53
|
-
7. **Auto-fill headers from project context**: Before submitting, **check `references/project-recipes-context.md`** (轻量索引) to find similar Recipes by title/trigger/category, then call MCP **`
|
|
53
|
+
7. **Auto-fill headers from project context**: Before submitting, **check `references/project-recipes-context.md`** (轻量索引) to find similar Recipes by title/trigger/category, then call MCP **`autosnippet_knowledge(operation=get, id)`** to get full content including headers. Copy the exact import format for `headers` field. If needed, call MCP **`autosnippet_search(mode=context)`** with the module name to find similar Recipes and extract their header patterns. This ensures consistency and correctness.
|
|
54
54
|
8. **Primary flow (MCP preferred)**: Code is ready → Agent writes to `_draft_recipe.md` or calls `autosnippet_submit_knowledge_batch` / `autosnippet_submit_knowledge_batch` → candidates appear in Dashboard Candidates → user reviews and approves → Recipe is added to the knowledge base.
|
|
55
55
|
9. **Alternative (Dashboard browser)**: Code is ready → user opens Dashboard (`asd ui` running) → **New Recipe** → **Use Copied Code** (paste the code) → AI fills title/summary/trigger/headers → **user reviews and approves** → saved to knowledge base.
|
|
56
56
|
10. **Alternative (in editor)**: User adds **`// as:create`** in the source file, copies the code, saves → **watch** (from `asd watch` or `asd ui`) auto-adds to Candidates → user opens Dashboard **Candidates** to review and save.
|
|
@@ -161,13 +161,11 @@ Watch parses all such blocks and adds each as a separate candidate; prompt may s
|
|
|
161
161
|
|
|
162
162
|
| Tool | Use |
|
|
163
163
|
|------|-----|
|
|
164
|
-
| `
|
|
164
|
+
| `autosnippet_search(mode=context)` | On-demand semantic search of knowledge base; pass `query`, `limit?` |
|
|
165
165
|
| `autosnippet_submit_knowledge_batch` | Submit draft .md as candidates: prefer draft folder + multiple files (not one big file); supports intro-only docs (no code—no Snippet). Pass `filePaths`, optional `targetName`, `deleteAfterSubmit`. **Delete the draft folder after submit** (e.g. `deleteAfterSubmit: true` or `rm -rf .autosnippet-drafts`). |
|
|
166
166
|
| `autosnippet_submit_knowledge_batch` | Submit structured items (title, summary, trigger, language, code, usageGuide) for batch scan, etc. |
|
|
167
|
-
| `autosnippet_submit_knowledge` | Submit single structured candidate with full V3 fields. |
|
|
167
|
+
| `autosnippet_submit_knowledge` | Submit single structured candidate with full V3 fields. **严格前置校验**——缺少必要字段(title, language, content, kind, doClause, category, trigger, description, headers, usageGuide, knowledgeType, content.rationale)的提交将被直接拒绝,不入库。必须一次性提供所有字段。 |
|
|
168
168
|
| `autosnippet_save_document` | Save a development document (design doc, debug report, ADR) — only needs title + markdown. See **autosnippet-devdocs** skill. |
|
|
169
|
-
| `autosnippet_validate_candidate` | Pre-validate candidate quality before submission. |
|
|
170
|
-
| `autosnippet_check_duplicate` | Check for duplicate Recipes before submission. |
|
|
171
169
|
|
|
172
170
|
**Fallback when Dashboard not open**: Agent can always use `autosnippet_submit_knowledge_batch` or `autosnippet_submit_knowledge_batch` directly via MCP — no browser needed.
|
|
173
171
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autosnippet-guard
|
|
3
|
-
description: Guard checks code against project Recipe standards. Passive (// as:audit + watch) or active (MCP
|
|
3
|
+
description: Guard checks code against project Recipe standards. Passive (// as:audit + watch) or active (MCP tool autosnippet_guard — auto-routes by code/files params). Use when the user wants to audit, lint, or verify code compliance.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AutoSnippet Guard — Code Compliance Checking
|
|
7
7
|
|
|
8
|
-
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 autosnippet_health
|
|
8
|
+
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 `autosnippet_health`;失败时不在同一轮重试,转用静态上下文或缩小范围后再试。
|
|
9
9
|
|
|
10
10
|
**Use this skill when**: The user wants to **check** whether code meets **project standards** (规范 / Audit / Guard / Lint).
|
|
11
11
|
|
|
@@ -26,7 +26,7 @@ When the user wants **quick inline audit**:
|
|
|
26
26
|
|
|
27
27
|
Agent can directly invoke Guard checks via MCP:
|
|
28
28
|
|
|
29
|
-
#### Single Code Check: `
|
|
29
|
+
#### Single Code Check: `autosnippet_guard` (with `code` param)
|
|
30
30
|
Check a code snippet against Guard rules. Best for quick inline checks.
|
|
31
31
|
|
|
32
32
|
```json
|
|
@@ -44,7 +44,7 @@ Returns: List of violations with `{ ruleId, severity, message, line, pattern }`.
|
|
|
44
44
|
- Agent is reviewing code before suggesting changes
|
|
45
45
|
- Quick single-file compliance check
|
|
46
46
|
|
|
47
|
-
#### Multi-file Audit: `
|
|
47
|
+
#### Multi-file Audit: `autosnippet_guard` (with `files[]` param)
|
|
48
48
|
Batch audit multiple files against Guard rules. Results are automatically recorded to ViolationsStore (visible in Dashboard Guard page).
|
|
49
49
|
|
|
50
50
|
```json
|
|
@@ -80,31 +80,28 @@ Guard uses the **same Recipe content** in `AutoSnippet/recipes/` as the standard
|
|
|
80
80
|
|
|
81
81
|
| Tool | Purpose | Input |
|
|
82
82
|
|------|---------|-------|
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `autosnippet_compliance_report` | Compliance assessment report | `period` (all/daily/weekly/monthly) |
|
|
87
|
-
| `autosnippet_list_rules` | List all Guard rules (kind=rule) | `limit`, `status`, `language`, `category` |
|
|
83
|
+
| `autosnippet_guard` | Code Guard check (single or batch — auto-routed by params) | `code` for single, `files[]` for batch, `language`, `filePath`, `scope` |
|
|
84
|
+
| `autosnippet_bootstrap(operation=scan)` | Full project scan + Guard audit | `maxFiles`, `includeContent` |
|
|
85
|
+
| `autosnippet_knowledge(operation=list, kind=rule)` | List all Guard rules (kind=rule) | `limit`, `status`, `language`, `category` |
|
|
88
86
|
|
|
89
87
|
---
|
|
90
88
|
|
|
91
89
|
## Typical Agent Workflow
|
|
92
90
|
|
|
93
91
|
### Quick Check (user asks "检查这段代码")
|
|
94
|
-
1. Call `
|
|
92
|
+
1. Call `autosnippet_guard` with the code
|
|
95
93
|
2. Present violations to user with severity and fix suggestions
|
|
96
|
-
3. If user adopts fixes, optionally `
|
|
94
|
+
3. If user adopts fixes, optionally `autosnippet_knowledge(operation=confirm_usage)` for the relevant Recipe
|
|
97
95
|
|
|
98
96
|
### Module Audit (user asks "审查网络模块")
|
|
99
|
-
1. Call `
|
|
100
|
-
2. Call `
|
|
97
|
+
1. Call `autosnippet_structure(operation=files)` to get file list
|
|
98
|
+
2. Call `autosnippet_guard` with the file paths
|
|
101
99
|
3. Summarize violations grouped by severity
|
|
102
100
|
4. Suggest fixes based on Recipe standards
|
|
103
101
|
|
|
104
102
|
### Project-wide Compliance
|
|
105
|
-
1. Call `
|
|
106
|
-
2.
|
|
107
|
-
3. Present high-severity findings first
|
|
103
|
+
1. Call `autosnippet_bootstrap(operation=scan)` for full project scan
|
|
104
|
+
2. Present high-severity findings first
|
|
108
105
|
|
|
109
106
|
---
|
|
110
107
|
|
|
@@ -120,6 +117,6 @@ Guard uses the **same Recipe content** in `AutoSnippet/recipes/` as the standard
|
|
|
120
117
|
|
|
121
118
|
- **autosnippet-recipes**: Recipe content IS the Guard standard. Use for looking up what the standard says.
|
|
122
119
|
- **autosnippet-intent**: General router; may route Guard-related intents here.
|
|
123
|
-
- **autosnippet-analysis**: Deep project scan + Guard baseline via `
|
|
120
|
+
- **autosnippet-analysis**: Deep project scan + Guard baseline via `autosnippet_bootstrap(operation=scan)`.
|
|
124
121
|
|
|
125
122
|
```
|