autosnippet 3.2.18 → 3.2.21
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/LICENSE +1 -1
- package/README.md +73 -104
- package/config/default.json +1 -1
- package/dashboard/dist/assets/{index-CKMy5LY6.js → index-DdvZE4Yd.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/bin/cli.js +45 -10
- package/dist/lib/agent/AgentEventBus.js +3 -3
- package/dist/lib/agent/AgentFactory.d.ts +3 -3
- package/dist/lib/agent/AgentFactory.js +4 -4
- package/dist/lib/agent/AgentMessage.d.ts +8 -8
- package/dist/lib/agent/AgentMessage.js +8 -8
- package/dist/lib/agent/AgentRuntime.js +2 -2
- package/dist/lib/agent/AgentState.js +4 -4
- package/dist/lib/agent/ConversationStore.d.ts +1 -1
- package/dist/lib/agent/ConversationStore.js +1 -1
- package/dist/lib/agent/PipelineStrategy.js +1 -1
- package/dist/lib/agent/context/ContextWindow.d.ts +2 -2
- package/dist/lib/agent/context/ContextWindow.js +7 -7
- package/dist/lib/agent/context/ExplorationTracker.js +9 -9
- package/dist/lib/agent/context/exploration/PlanTracker.js +2 -2
- package/dist/lib/agent/context/exploration/SignalDetector.d.ts +1 -1
- package/dist/lib/agent/context/exploration/SignalDetector.js +1 -1
- package/dist/lib/agent/core/LoopContext.d.ts +21 -21
- package/dist/lib/agent/core/LoopContext.js +21 -21
- package/dist/lib/agent/core/SystemPromptBuilder.js +4 -4
- package/dist/lib/agent/domain/EvidenceCollector.js +5 -5
- package/dist/lib/agent/memory/ActiveContext.js +1 -1
- package/dist/lib/agent/memory/MemoryRetriever.js +1 -1
- package/dist/lib/agent/memory/MemoryStore.js +2 -2
- package/dist/lib/agent/memory/SessionStore.js +3 -3
- package/dist/lib/agent/policies.d.ts +1 -1
- package/dist/lib/agent/policies.js +1 -1
- package/dist/lib/agent/strategies.d.ts +1 -1
- package/dist/lib/agent/strategies.js +4 -4
- package/dist/lib/agent/tools/_shared.d.ts +1 -1
- package/dist/lib/agent/tools/_shared.js +1 -1
- package/dist/lib/agent/tools/infrastructure.js +2 -2
- package/dist/lib/cli/SetupService.d.ts +25 -25
- package/dist/lib/cli/SetupService.js +28 -15
- package/dist/lib/cli/deploy/FileDeployer.d.ts +9 -2
- package/dist/lib/cli/deploy/FileDeployer.js +139 -46
- package/dist/lib/cli/deploy/FileManifest.d.ts +23 -39
- package/dist/lib/cli/deploy/FileManifest.js +22 -33
- package/dist/lib/core/AstAnalyzer.d.ts +2 -2
- package/dist/lib/core/AstAnalyzer.js +2 -2
- package/dist/lib/core/analysis/CallEdgeResolver.d.ts +7 -7
- package/dist/lib/core/analysis/CallEdgeResolver.js +9 -9
- package/dist/lib/core/analysis/CallGraphAnalyzer.d.ts +4 -4
- package/dist/lib/core/analysis/CallGraphAnalyzer.js +2 -2
- package/dist/lib/core/analysis/ImportPathResolver.d.ts +0 -2
- package/dist/lib/core/analysis/ImportPathResolver.js +2 -4
- package/dist/lib/core/ast/ProjectGraph.js +7 -7
- package/dist/lib/core/capability/CapabilityProbe.js +6 -14
- package/dist/lib/domain/knowledge/UnifiedValidator.js +2 -2
- package/dist/lib/domain/knowledge/values/Constraints.js +4 -4
- package/dist/lib/domain/knowledge/values/Content.js +6 -6
- package/dist/lib/domain/knowledge/values/Quality.js +5 -5
- package/dist/lib/domain/knowledge/values/Reasoning.js +5 -5
- package/dist/lib/domain/knowledge/values/Relations.js +1 -1
- package/dist/lib/domain/knowledge/values/Stats.js +6 -6
- package/dist/lib/domain/task/TaskIdGenerator.d.ts +4 -4
- package/dist/lib/domain/task/TaskIdGenerator.js +2 -2
- package/dist/lib/external/lark/LarkTransport.js +4 -4
- package/dist/lib/external/mcp/McpServer.d.ts +3 -7
- package/dist/lib/external/mcp/McpServer.js +9 -13
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +5 -5
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +4 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.d.ts +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.js +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +27 -14
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +6 -0
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +55 -1
- package/dist/lib/external/mcp/handlers/skill.js +9 -31
- package/dist/lib/external/mcp/handlers/system.js +6 -4
- package/dist/lib/external/mcp/handlers/task.js +16 -1
- package/dist/lib/external/mcp/tools.d.ts +12 -10
- package/dist/lib/external/mcp/tools.js +97 -69
- package/dist/lib/http/utils/routeHelpers.d.ts +1 -1
- package/dist/lib/http/utils/routeHelpers.js +1 -1
- package/dist/lib/http/utils/sse-sessions.d.ts +1 -1
- package/dist/lib/http/utils/sse-sessions.js +1 -1
- package/dist/lib/infrastructure/cache/CacheService.js +1 -1
- package/dist/lib/infrastructure/logging/Logger.js +1 -1
- package/dist/lib/infrastructure/monitoring/ErrorTracker.js +1 -1
- package/dist/lib/infrastructure/vector/AsyncPersistence.js +8 -8
- package/dist/lib/infrastructure/vector/BatchEmbedder.d.ts +1 -1
- package/dist/lib/infrastructure/vector/BatchEmbedder.js +2 -2
- package/dist/lib/infrastructure/vector/HnswIndex.d.ts +4 -4
- package/dist/lib/infrastructure/vector/HnswIndex.js +5 -5
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +8 -8
- package/dist/lib/infrastructure/vector/ScalarQuantizer.d.ts +1 -1
- package/dist/lib/infrastructure/vector/ScalarQuantizer.js +4 -4
- package/dist/lib/infrastructure/vector/VectorStore.d.ts +1 -1
- package/dist/lib/infrastructure/vector/VectorStore.js +1 -1
- package/dist/lib/injection/ServiceContainer.d.ts +1 -1
- package/dist/lib/injection/ServiceContainer.js +1 -1
- package/dist/lib/injection/modules/KnowledgeModule.js +4 -5
- package/dist/lib/platform/NativeUi.d.ts +1 -1
- package/dist/lib/platform/NativeUi.js +1 -1
- package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +1 -1
- package/dist/lib/platform/ios/spm/DependencyGraph.js +1 -1
- package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +1 -1
- package/dist/lib/platform/ios/spm/PolicyEngine.js +1 -1
- package/dist/lib/platform/ios/spm/SpmDiscoverer.js +1 -1
- package/dist/lib/platform/ios/spm/SpmHelper.js +3 -3
- package/dist/lib/platform/ios/xcode/SaveEventFilter.js +2 -2
- package/dist/lib/platform/ios/xcode/XcodeIntegration.js +1 -1
- package/dist/lib/repository/base/BaseRepository.js +1 -1
- package/dist/lib/repository/task/TaskRepository.impl.d.ts +2 -2
- package/dist/lib/repository/task/TaskRepository.impl.js +1 -1
- package/dist/lib/repository/token/TokenUsageStore.js +1 -1
- package/dist/lib/service/automation/ActionPipeline.d.ts +1 -1
- package/dist/lib/service/automation/ActionPipeline.js +1 -1
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +2 -2
- package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +1 -1
- package/dist/lib/service/bootstrap/BootstrapTaskManager.js +2 -2
- package/dist/lib/service/bootstrap/DimensionCopyRegistry.d.ts +2 -2
- package/dist/lib/service/bootstrap/DimensionCopyRegistry.js +2 -2
- package/dist/lib/service/delivery/AgentInstructionsGenerator.d.ts +6 -15
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +53 -189
- package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +6 -16
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +14 -19
- package/dist/lib/service/delivery/KnowledgeCompressor.d.ts +1 -1
- package/dist/lib/service/delivery/KnowledgeCompressor.js +1 -1
- package/dist/lib/service/delivery/RulesGenerator.d.ts +10 -3
- package/dist/lib/service/delivery/RulesGenerator.js +43 -3
- package/dist/lib/service/delivery/SkillsSyncer.d.ts +21 -7
- package/dist/lib/service/delivery/SkillsSyncer.js +46 -10
- package/dist/lib/service/delivery/TopicClassifier.d.ts +3 -6
- package/dist/lib/service/delivery/TopicClassifier.js +0 -3
- package/dist/lib/service/guard/ExclusionManager.d.ts +1 -1
- package/dist/lib/service/guard/ExclusionManager.js +1 -1
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +3 -3
- package/dist/lib/service/guard/GuardCheckEngine.js +5 -5
- package/dist/lib/service/guard/GuardCrossFileChecks.d.ts +1 -1
- package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -3
- package/dist/lib/service/guard/GuardFeedbackLoop.js +3 -3
- package/dist/lib/service/guard/GuardPatternUtils.js +1 -1
- package/dist/lib/service/guard/GuardService.d.ts +1 -15
- package/dist/lib/service/guard/GuardService.js +0 -1
- package/dist/lib/service/guard/RuleLearner.d.ts +1 -1
- package/dist/lib/service/guard/RuleLearner.js +1 -1
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +3 -3
- package/dist/lib/service/knowledge/CodeEntityGraph.js +3 -3
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +0 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +0 -1
- package/dist/lib/service/module/ModuleService.d.ts +1 -1
- package/dist/lib/service/module/ModuleService.js +2 -2
- package/dist/lib/service/search/HybridRetriever.d.ts +2 -2
- package/dist/lib/service/search/HybridRetriever.js +2 -2
- package/dist/lib/service/search/SearchEngine.d.ts +1 -3
- package/dist/lib/service/search/SearchEngine.js +1 -3
- package/dist/lib/service/search/contextBoost.d.ts +1 -1
- package/dist/lib/service/skills/EventAggregator.js +2 -2
- package/dist/lib/service/skills/SignalCollector.js +1 -1
- package/dist/lib/service/snippet/codecs/VSCodeCodec.js +1 -1
- package/dist/lib/service/task/TaskGraphService.d.ts +0 -3
- package/dist/lib/service/task/TaskGraphService.js +0 -3
- package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +8 -27
- package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -8
- package/dist/lib/service/task/TaskReadyEngine.d.ts +1 -2
- package/dist/lib/service/task/TaskReadyEngine.js +0 -1
- package/dist/lib/service/wiki/WikiRenderers.js +0 -1
- package/dist/lib/service/wiki/WikiUtils.js +2 -7
- package/dist/lib/shared/PathGuard.js +6 -6
- package/dist/lib/shared/schemas/config.js +1 -1
- package/dist/lib/shared/schemas/mcp-tools.js +84 -43
- package/dist/scripts/install-vscode-copilot.js +14 -4
- package/package.json +1 -1
- package/skills/autosnippet-create/SKILL.md +131 -131
- package/skills/autosnippet-devdocs/SKILL.md +1 -2
- package/skills/autosnippet-guard/SKILL.md +20 -89
- package/skills/autosnippet-recipes/SKILL.md +35 -117
- package/skills/autosnippet-structure/SKILL.md +23 -55
- package/templates/cursor-rules/autosnippet-skills.mdc +17 -33
- package/templates/instructions/agent-static.md +24 -0
- package/templates/instructions/conventions.md +42 -0
- package/skills/autosnippet-analysis/SKILL.md +0 -169
- package/skills/autosnippet-candidates/SKILL.md +0 -367
- package/skills/autosnippet-coldstart/SKILL.md +0 -988
- package/skills/autosnippet-concepts/SKILL.md +0 -630
- package/skills/autosnippet-intent/SKILL.md +0 -55
- package/skills/autosnippet-lifecycle/SKILL.md +0 -100
- package/templates/copilot-instructions.md +0 -66
- package/templates/cursor-rules/autosnippet-conventions.mdc +0 -172
- package/templates/cursor-rules/autosnippet-workflow.mdc +0 -76
|
@@ -1,180 +1,180 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autosnippet-create
|
|
3
|
-
description:
|
|
3
|
+
description: Submit knowledge to AutoSnippet. Covers single/batch MCP submission, V3 field requirements, quality validation, and lifecycle. Use when user says "提交知识/加入知识库/create recipe" or agent needs to persist code patterns, rules, or facts.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# AutoSnippet Create —
|
|
7
|
-
|
|
8
|
-
>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
1. **Goal**: When you (Cursor) have **finished writing or refining** module usage code, or the user says "把这段提交到 web / 加入知识库", guide them to **submit that code to the Dashboard** so it becomes a **Recipe** in `AutoSnippet/recipes/`.
|
|
15
|
-
2. **Draft workflow**: Prefer **creating a draft folder** (e.g. `.autosnippet-drafts`), **one .md file per Recipe**, multiple draft files—**do not use one big file**. Call MCP **`autosnippet_submit_knowledge_batch`** with filePaths (the .md files in the draft folder) to submit to Candidates. **After submit, delete the draft folder** (use `deleteAfterSubmit: true` or run `rm -rf .autosnippet-drafts`). Single-item flow can use `_draft_recipe.md` and watch will auto-add to Candidates.
|
|
16
|
-
3. **When user asks for "candidates"**: Use MCP **`autosnippet_submit_knowledge_batch`** for structured items (title/summary/trigger/code/usageGuide); use **`autosnippet_submit_knowledge_batch`** for Markdown draft files (prefer draft folder + multiple files; delete draft folder after submit).
|
|
17
|
-
4. **One Recipe = one scenario**: If you are drafting content, **split** into multiple Recipes by scenario. Never combine multiple usage patterns into one Recipe file or one candidate.
|
|
18
|
-
5. **Recipe candidates can be intro-only**: Intro-only docs (no code block) can be submitted as candidates; after approval they become Recipes and **do not generate a Snippet**—used only for search and Guard context.
|
|
19
|
-
6. **MUST follow V3 Recipe format**: Include all required fields: `title`, `trigger`, `category` (one of 8 standard values), `language`, `kind` (rule/pattern/fact), `doClause`, `dontClause`, `whenClause`, `coreCode`, `description`, `content` (object with markdown, pattern, rationale), `headers` (complete import statements), `usageGuide` (Markdown ### 章节), `knowledgeType`, `reasoning` (whyStandard + sources + confidence).
|
|
20
|
-
- **MCP 不再使用项目内 AI**: 外部 Agent 必须自行填写所有字段。提交后检查返回值中的 `recipeReadyHints`,缺失字段需补全后重新提交。
|
|
21
|
-
- **禁止使用旧字段**: 不要使用 `code`、`summary_cn`、`summary_en`,改用 V3 `content` 对象 + `description`。
|
|
22
|
-
- **Placeholders**: Use IDE-appropriate placeholders in snippets — Xcode format `<#URL#>`, `<#Token#>` (auto-converted to VSCode `${N:...}` on install). Explain each placeholder in the Usage Guide.
|
|
23
|
-
- **Usage Guide structure (强制格式要求)**:
|
|
24
|
-
* **MUST use structured format with clear section headings** (### heading name):**NEVER put all content in one continuous line**
|
|
25
|
-
* **MUST use newlines (`\n`) to separate sections and bullet points** — at least 2-3 newlines between major sections
|
|
26
|
-
* **MUST use bullet lists (`-` or `*`)** for multi-item sections; avoid long paragraphs
|
|
27
|
-
* Recommended sections (按需包含):
|
|
28
|
-
- **什么时候用** (必填):3~5 条适用场景,用 `-` 列表,每行一条
|
|
29
|
-
- **何时不用** (推荐):排除场景、易误用情况,用 `-` 列表
|
|
30
|
-
- **使用步骤** (推荐):1~3 步操作手册,用 `1.` `2.` `3.` 列表
|
|
31
|
-
- **关键点** (推荐):易错点、约束条件、版本限制,用 `-` 列表
|
|
32
|
-
- **依赖与前置条件** (推荐):模块、权限、最低版本,用 `-` 列表
|
|
33
|
-
- **错误处理** (推荐):常见失败场景、重试/降级策略
|
|
34
|
-
- **性能与资源** (可选):缓存、线程安全、内存
|
|
35
|
-
- **安全与合规** (可选):敏感信息、日志脱敏
|
|
36
|
-
- **常见误用** (可选):反例(❌)与规避方式(✅)
|
|
37
|
-
- **最佳实践** (可选):推荐做法、设计模式
|
|
38
|
-
- **替代方案** (可选):其他 Recipe 或方案对比
|
|
39
|
-
- **相关 Recipe** (推荐):关联 trigger 或补充模式
|
|
40
|
-
* **BAD Example** (❌ 禁止这样写,AI生成会导致格式混乱):`何时用:在需要…时;与…配合;或…时。关键点:…内部…;…支持…;…需…。`
|
|
41
|
-
* **GOOD Example** (✅ 应该这样写,清晰的多行结构):
|
|
42
|
-
```
|
|
43
|
-
### 何时用
|
|
44
|
-
- App 启动时需持续监测网络状态
|
|
45
|
-
- 在应用生命周期管理类中统一启停
|
|
46
|
-
|
|
47
|
-
### 关键点
|
|
48
|
-
- 单例 sharedMonitor,线程安全
|
|
49
|
-
- startMonitoring 开始,stopMonitoring 停止
|
|
50
|
-
- 后台自动停止,前台自动恢复
|
|
51
|
-
```
|
|
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 **`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
|
-
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
|
-
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
|
-
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.
|
|
57
|
-
9. **Draft & clipboard auto-add**: When you write to **`_draft_recipe.md`** (project root) or user uses **`// as:create`** with clipboard content, **watch** automatically reads the draft/clipboard, adds it to **Candidates** (target `_draft` or `_watch`), and shows a **friendly prompt** (e.g. "已创建候选「xxx」,请在 Candidates 页审核" in notification and console). User only needs to open Dashboard **Candidates** to review and save — no manual copy-paste required.
|
|
58
|
-
10. **Multiple recipes**: Prefer **one .md file per Recipe** in a draft folder (e.g. `.autosnippet-drafts/`), call **`autosnippet_submit_knowledge_batch`** with the list of file paths, then **delete the draft folder** after submit. Do not use one big file for many Recipes.
|
|
59
|
-
11. **Project root** = directory with `AutoSnippet/AutoSnippet.boxspec.json`. All commands run from the project root.
|
|
6
|
+
# AutoSnippet Create — 知识提交
|
|
7
|
+
|
|
8
|
+
> 前置:MCP 工具返回统一 JSON Envelope `{ success, errorCode?, message?, data?, meta }`。操作前调用 `autosnippet_health` 确认服务可用。
|
|
9
|
+
|
|
10
|
+
本 Skill 指导 Agent 将代码模式、规则、事实提交到 AutoSnippet 知识库。提交后的条目进入 **Candidates**(pending 状态),用户在 Dashboard 审核后发布。
|
|
11
|
+
|
|
12
|
+
关联 Skill:**autosnippet-recipes**(检索已有知识)。
|
|
60
13
|
|
|
61
14
|
---
|
|
62
15
|
|
|
63
|
-
##
|
|
16
|
+
## 提交路径
|
|
64
17
|
|
|
65
|
-
|
|
18
|
+
| 路径 | 工具 | 适用场景 |
|
|
19
|
+
|------|------|----------|
|
|
20
|
+
| **单条提交** | `autosnippet_submit_knowledge` | Agent 精心构造一条完整知识 |
|
|
21
|
+
| **批量提交** | `autosnippet_submit_knowledge_batch` | 冷启动维度分析、批量扫描 |
|
|
22
|
+
| **Dashboard** | 浏览器 `http://localhost:3000` | 用户手动粘贴/扫描文件 |
|
|
66
23
|
|
|
67
|
-
|
|
24
|
+
**Agent 首选 MCP 提交**,无需浏览器。
|
|
68
25
|
|
|
69
|
-
|
|
70
|
-
...rated a full Recipe (frontmatter, Snippet, Usage Guide), **prefer writing to draft file** `_draft_recipe.md` at project root. On save, **watch automatically reads the draft**, adds it to **Candidates** (target `_draft`), and shows a **friendly prompt** ("已创建候选「xxx」,请在 Candidates 页审核"). User opens Dashboard **Candidates** to review and save — no manual copy needed. Or output in copyable format in chat and guide user to copy → Dashboard → Use Copied Code → paste → review → save. **Do not write to `AutoSnippet/recipes/` or `AutoSnippet/snippets/`.**
|
|
71
|
-
- **Candidate output rule**: When the user asks for candidates, **do not create files under `AutoSnippet/`**. Use **`autosnippet_submit_knowledge_batch`** for structured items; use **`autosnippet_submit_knowledge_batch`** for draft .md files (prefer draft folder + multiple files; delete draft folder after submit).
|
|
26
|
+
---
|
|
72
27
|
|
|
73
|
-
|
|
28
|
+
## 单条提交 — autosnippet_submit_knowledge
|
|
74
29
|
|
|
75
|
-
|
|
76
|
-
- **Manual fallback**: User opens **`http://localhost:3000`** in browser (Dashboard 需已运行;若未运行,先执行 `asd ui`).
|
|
30
|
+
一次提交一条完整的 V3 知识条目。即使部分字段校验未通过也会入库,返回中附带 `recipeReadyHints` 提示缺失字段。
|
|
77
31
|
|
|
78
|
-
###
|
|
32
|
+
### V3 必填字段(16 个)
|
|
79
33
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
34
|
+
| 字段 | 类型 | 说明 |
|
|
35
|
+
|------|------|------|
|
|
36
|
+
| `title` | string | 知识标题,简洁明确 |
|
|
37
|
+
| `description` | string | 一句话描述用途 |
|
|
38
|
+
| `trigger` | string | 触发关键词,如 `@NetworkMonitor` |
|
|
39
|
+
| `language` | string | 编程语言,如 `typescript`、`swift` |
|
|
40
|
+
| `kind` | enum | `rule`(规范)/ `pattern`(模式)/ `fact`(事实) |
|
|
41
|
+
| `category` | string | `View`/`Service`/`Tool`/`Model`/`Network`/`Storage`/`UI`/`Utility` |
|
|
42
|
+
| `knowledgeType` | string | 知识类型标识 |
|
|
43
|
+
| `doClause` | string | ✅ 应该做什么(Channel A+B 硬依赖) |
|
|
44
|
+
| `dontClause` | string | ❌ 不应该做什么 |
|
|
45
|
+
| `whenClause` | string | 何时适用(Channel B 硬依赖) |
|
|
46
|
+
| `coreCode` | string | 核心代码片段 |
|
|
47
|
+
| `headers` | string[] | 完整 import 语句列表 |
|
|
48
|
+
| `usageGuide` | string | 使用指南(Markdown,见下方格式要求) |
|
|
49
|
+
| `content` | object | `{ markdown: string, rationale: string }` 至少提供 markdown |
|
|
50
|
+
| `reasoning` | object | `{ whyStandard: string, sources: string[], confidence: number }` |
|
|
86
51
|
|
|
87
|
-
###
|
|
52
|
+
### 可选字段
|
|
88
53
|
|
|
89
|
-
|
|
54
|
+
`topicHint`、`complexity`(beginner/intermediate/advanced)、`scope`(universal/project-specific/target-specific)、`tags`(string[])、`constraints`、`relations`、`skipDuplicateCheck`(默认 false)
|
|
90
55
|
|
|
91
|
-
|
|
56
|
+
### usageGuide 格式要求
|
|
92
57
|
|
|
93
|
-
|
|
58
|
+
**必须**使用 Markdown 分节,禁止写成一行长文本。
|
|
94
59
|
|
|
95
|
-
|
|
60
|
+
```markdown
|
|
61
|
+
### 何时用
|
|
62
|
+
- 场景 A
|
|
63
|
+
- 场景 B
|
|
96
64
|
|
|
97
|
-
|
|
65
|
+
### 何时不用
|
|
66
|
+
- 排除场景
|
|
98
67
|
|
|
99
|
-
|
|
68
|
+
### 使用步骤
|
|
69
|
+
1. 第一步
|
|
70
|
+
2. 第二步
|
|
100
71
|
|
|
101
|
-
|
|
72
|
+
### 关键点
|
|
73
|
+
- 注意事项 A
|
|
74
|
+
- 注意事项 B
|
|
75
|
+
```
|
|
102
76
|
|
|
103
|
-
|
|
77
|
+
可选章节:依赖与前置条件、错误处理、性能与资源、安全与合规、常见误用、替代方案、相关知识。
|
|
104
78
|
|
|
105
|
-
|
|
106
|
-
|-----|-------------|
|
|
107
|
-
| **New Recipe → Scan File** | Code is already in a project file; user enters relative path (e.g. `Sources/MyMod/Foo.m`) → Scan File → AI extracts → save in Dashboard. |
|
|
108
|
-
| **Module Explorer** | Mine usage from a module Target: select Target → scan → review in Dashboard → save as Recipe (or Snippet + Recipe). |
|
|
109
|
-
| **Candidates** | Batch: run **`asd ais <Target>`** or **`asd ais --all`** → open Dashboard **Candidates** → approve items → saved to knowledge base. |
|
|
79
|
+
---
|
|
110
80
|
|
|
111
|
-
|
|
81
|
+
## 批量提交 — autosnippet_submit_knowledge_batch
|
|
112
82
|
|
|
113
|
-
|
|
83
|
+
一次提交多条知识。每条单独校验,不通过的拒绝但不阻塞其他。
|
|
114
84
|
|
|
115
|
-
|
|
85
|
+
### 参数
|
|
116
86
|
|
|
117
|
-
|
|
87
|
+
| 字段 | 必填 | 类型 | 说明 |
|
|
88
|
+
|------|------|------|------|
|
|
89
|
+
| `target_name` | ✅ | string | 批量来源标识(如 `network-module-scan`) |
|
|
90
|
+
| `items` | ✅ | object[] | 知识条目数组,每条结构同单条提交的字段 |
|
|
91
|
+
| `source` | | string | 来源标记,默认 `cursor-scan` |
|
|
92
|
+
| `deduplicate` | | boolean | 基于 title 去重,默认 `true` |
|
|
118
93
|
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
---
|
|
122
|
-
title: Recipe A
|
|
123
|
-
trigger: @foo
|
|
124
|
-
...
|
|
125
|
-
---
|
|
94
|
+
### 返回值
|
|
126
95
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"count": 3,
|
|
99
|
+
"total": 5,
|
|
100
|
+
"ids": ["id1", "id2", "id3"],
|
|
101
|
+
"errors": ["item[2]: missing doClause"],
|
|
102
|
+
"rejectedItems": [2, 4],
|
|
103
|
+
"rejectedSummary": { "commonMissingFields": ["doClause", "reasoning"] }
|
|
104
|
+
}
|
|
130
105
|
```
|
|
131
106
|
|
|
132
|
-
|
|
133
|
-
usage A
|
|
107
|
+
**批量提交校验更严格**:单条提交校验不通过仍入库(附 hints),**批量提交校验不通过直接拒绝**。
|
|
134
108
|
|
|
135
109
|
---
|
|
136
|
-
title: Recipe B
|
|
137
|
-
...
|
|
138
|
-
---
|
|
139
110
|
|
|
140
|
-
##
|
|
141
|
-
|
|
111
|
+
## 提交工作流
|
|
112
|
+
|
|
113
|
+
### 标准流程(Agent 通过 MCP)
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
1. 分析代码 → 构造 V3 字段
|
|
117
|
+
2. autosnippet_submit_knowledge / _batch → 入库为 pending
|
|
118
|
+
3. 检查返回值:
|
|
119
|
+
- 成功 → 告知用户"已提交,请在 Dashboard Candidates 审核"
|
|
120
|
+
- 有 rejectedItems → 根据 rejectedSummary.commonMissingFields 补全后重试
|
|
121
|
+
4. [可选] autosnippet_enrich_candidates → 诊断候选字段完整性
|
|
142
122
|
```
|
|
143
|
-
|
|
123
|
+
|
|
124
|
+
### 一条知识一个场景
|
|
125
|
+
|
|
126
|
+
拆分原则:不同使用场景、不同 API 入口、不同配置方式→各自一条知识。禁止将多个模式合并为一条。
|
|
144
127
|
|
|
145
128
|
---
|
|
146
129
|
|
|
147
|
-
##
|
|
130
|
+
## 提交后管理
|
|
148
131
|
|
|
149
|
-
|
|
|
150
|
-
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
| Agent 起草内容无法完整复制 | Write to `_draft_recipe.md` → save → **watch 自动读取草稿、加入候选并友好提示** → 用户打开 **Candidates** 审核保存。 |
|
|
156
|
-
| Batch from Target | **`asd ais <Target>`** → 打开 **`http://localhost:3000`** → **Candidates** → approve. |
|
|
132
|
+
| 需求 | 工具 |
|
|
133
|
+
|------|------|
|
|
134
|
+
| 查看候选状态 | `autosnippet_knowledge(operation=list)` |
|
|
135
|
+
| 诊断缺失字段 | `autosnippet_enrich_candidates` |
|
|
136
|
+
| 审核/发布 | `autosnippet_knowledge_lifecycle(operation=approve/publish/fast_track)` |
|
|
137
|
+
| 搜索已有知识避免重复 | `autosnippet_search(mode=context, query=...)` |
|
|
157
138
|
|
|
158
139
|
---
|
|
159
140
|
|
|
160
|
-
##
|
|
141
|
+
## kind 路由与管线影响
|
|
161
142
|
|
|
162
|
-
|
|
|
163
|
-
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `autosnippet_submit_knowledge` | Submit single structured candidate with full V3 fields. **严格前置校验**——缺少必要字段(title, language, content, kind, doClause, dontClause, whenClause, coreCode, category, trigger, description, headers, usageGuide, knowledgeType, reasoning, content.rationale)的提交将被直接拒绝,不入库。必须一次性提供所有字段。 |
|
|
168
|
-
| `autosnippet_save_document` | Save a development document (design doc, debug report, ADR) — only needs title + markdown. See **autosnippet-devdocs** skill. |
|
|
143
|
+
| kind | 用途 | 管线产出 |
|
|
144
|
+
|------|------|----------|
|
|
145
|
+
| `rule` | 编码规范、约束 | → Channel A(.mdc 规则文件) |
|
|
146
|
+
| `pattern` | 代码模式、用法 | → Channel B(.mdc 模式文件 + Snippet) |
|
|
147
|
+
| `fact` | 项目事实、架构决策 | → 搜索/Guard 上下文,不直接产出文件 |
|
|
169
148
|
|
|
170
|
-
|
|
149
|
+
`doClause` 是 Channel A+B 的**硬依赖**——缺少此字段则完全无法生成 .mdc 文件。
|
|
171
150
|
|
|
172
151
|
---
|
|
173
152
|
|
|
174
|
-
##
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
153
|
+
## 示例:提交一条知识
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"title": "Network Monitor — 网络状态监听",
|
|
158
|
+
"description": "使用 NWPathMonitor 监听网络连通性变化",
|
|
159
|
+
"trigger": "@NetworkMonitor",
|
|
160
|
+
"language": "swift",
|
|
161
|
+
"kind": "pattern",
|
|
162
|
+
"category": "Network",
|
|
163
|
+
"knowledgeType": "api-usage",
|
|
164
|
+
"doClause": "使用 NWPathMonitor 监听网络状态变化,在主队列回调更新 UI",
|
|
165
|
+
"dontClause": "不要用 Reachability 旧库,不要在后台线程直接更新 UI",
|
|
166
|
+
"whenClause": "需要实时感知网络连通性变化时",
|
|
167
|
+
"coreCode": "let monitor = NWPathMonitor()\nmonitor.pathUpdateHandler = { path in\n DispatchQueue.main.async {\n self.isConnected = path.status == .satisfied\n }\n}\nmonitor.start(queue: DispatchQueue.global())",
|
|
168
|
+
"headers": ["import Network"],
|
|
169
|
+
"usageGuide": "### 何时用\n- App 需要实时网络状态\n- 启动时初始化一次\n\n### 关键点\n- 单例模式访问 sharedMonitor\n- start() 开始监听,cancel() 停止\n- 回调在 global queue,更新 UI 需切主线程",
|
|
170
|
+
"content": {
|
|
171
|
+
"markdown": "NWPathMonitor 是 iOS 12+ 推荐的网络状态监听方案,替代废弃的 Reachability。",
|
|
172
|
+
"rationale": "Apple 官方推荐,线程安全,支持蜂窝/WiFi/有线判断。"
|
|
173
|
+
},
|
|
174
|
+
"reasoning": {
|
|
175
|
+
"whyStandard": "Apple Developer Documentation 推荐方案,替代 SCNetworkReachability",
|
|
176
|
+
"sources": ["Apple Developer Documentation - NWPathMonitor"],
|
|
177
|
+
"confidence": 0.95
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
180
|
```
|
|
@@ -80,11 +80,10 @@ Documents are stored as `knowledgeType: 'dev-document'` in the knowledge DB. The
|
|
|
80
80
|
- For ADRs, use the structure: Context → Decision → Consequences
|
|
81
81
|
- For debug reports: Symptom → Investigation → Root Cause → Fix
|
|
82
82
|
|
|
83
|
-
##
|
|
83
|
+
## Related Skills
|
|
84
84
|
|
|
85
85
|
| Skill | When to use |
|
|
86
86
|
|-------|-------------|
|
|
87
87
|
| `autosnippet-create` | Saving **code patterns/recipes** (needs trigger, doClause, etc.) |
|
|
88
88
|
| `autosnippet-devdocs` (this) | Saving **prose documents** (only needs title + markdown) |
|
|
89
89
|
| `autosnippet-recipes` | Looking up existing knowledge |
|
|
90
|
-
| `autosnippet-concepts` | Understanding AutoSnippet concepts |
|
|
@@ -1,122 +1,53 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autosnippet-guard
|
|
3
|
-
description: Guard checks code against project Recipe standards
|
|
3
|
+
description: Guard checks code against project Recipe standards via 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`;失败时不在同一轮重试,转用静态上下文或缩小范围后再试。
|
|
9
|
-
|
|
10
8
|
**Use this skill when**: The user wants to **check** whether code meets **project standards** (规范 / Audit / Guard / Lint).
|
|
11
9
|
|
|
12
10
|
---
|
|
13
11
|
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
### Mode 1: Passive — `// as:audit` trigger (requires `asd watch` or `asd ui`)
|
|
17
|
-
|
|
18
|
-
When the user wants **quick inline audit**:
|
|
19
|
-
1. Add `// as:audit` (or `// as:audit keyword`) in the file
|
|
20
|
-
2. Save the file → watch detects the save → runs AI review against Recipe standards
|
|
21
|
-
3. Results output to terminal / notification
|
|
22
|
-
|
|
23
|
-
**Recommendation wording**: "在文件中加 `// as:audit`,保存后 watch 会用知识库标准审查代码,结果输出到终端。"
|
|
24
|
-
|
|
25
|
-
### Mode 2: Active — MCP tools (Agent-driven, no watch needed)
|
|
26
|
-
|
|
27
|
-
Agent can directly invoke Guard checks via MCP:
|
|
28
|
-
|
|
29
|
-
#### Single Code Check: `autosnippet_guard` (with `code` param)
|
|
30
|
-
Check a code snippet against Guard rules. Best for quick inline checks.
|
|
12
|
+
## MCP Tool: `autosnippet_guard`
|
|
31
13
|
|
|
14
|
+
**Single code check** (`code` param):
|
|
32
15
|
```json
|
|
33
|
-
{
|
|
34
|
-
"code": "URLSession.shared.dataTask(with: url) { ... }",
|
|
35
|
-
"language": "objc",
|
|
36
|
-
"filePath": "Sources/Network/OldAPI.m"
|
|
37
|
-
}
|
|
16
|
+
{ "code": "URLSession.shared.dataTask(with: url) { ... }", "language": "objc", "filePath": "Sources/Network/OldAPI.m" }
|
|
38
17
|
```
|
|
39
18
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
**When to use**:
|
|
43
|
-
- User pastes code and asks "这段符合规范吗?"
|
|
44
|
-
- Agent is reviewing code before suggesting changes
|
|
45
|
-
- Quick single-file compliance check
|
|
46
|
-
|
|
47
|
-
#### Multi-file Audit: `autosnippet_guard` (with `files[]` param)
|
|
48
|
-
Batch audit multiple files against Guard rules. Results are automatically recorded to ViolationsStore (visible in Dashboard Guard page).
|
|
49
|
-
|
|
19
|
+
**Multi-file audit** (`files[]` param):
|
|
50
20
|
```json
|
|
51
|
-
{
|
|
52
|
-
"files": [
|
|
53
|
-
{ "path": "/path/to/Sources/Network/APIClient.m" },
|
|
54
|
-
{ "path": "/path/to/Sources/Network/RequestManager.m", "content": "..." }
|
|
55
|
-
],
|
|
56
|
-
"scope": "project"
|
|
57
|
-
}
|
|
21
|
+
{ "files": [{ "path": "Sources/Network/APIClient.m" }, { "path": "Sources/Network/RequestManager.m" }], "scope": "project" }
|
|
58
22
|
```
|
|
59
23
|
|
|
60
|
-
Returns
|
|
61
|
-
|
|
62
|
-
**When to use**:
|
|
63
|
-
- User says "审查一下网络模块" / "检查这几个文件"
|
|
64
|
-
- After batch code changes, verify compliance
|
|
65
|
-
- Periodic module-level audit
|
|
24
|
+
Returns violations with `{ ruleId, severity, message, line, pattern }`. Batch results auto-recorded to ViolationsStore.
|
|
66
25
|
|
|
67
26
|
---
|
|
68
27
|
|
|
69
28
|
## Guard Knowledge Source
|
|
70
29
|
|
|
71
|
-
Guard uses
|
|
72
|
-
- **kind=rule**
|
|
73
|
-
- **kind=pattern**
|
|
74
|
-
-
|
|
75
|
-
- No separate config needed — Recipe IS the Guard standard
|
|
30
|
+
Guard uses **Recipe content** as the standard — no separate config:
|
|
31
|
+
- **kind=rule** → enforced as Guard rules (severity: error/warning/info)
|
|
32
|
+
- **kind=pattern** → best-practice references
|
|
33
|
+
- `constraints.guards[].pattern` → regex patterns for automated detection
|
|
76
34
|
|
|
77
35
|
---
|
|
78
36
|
|
|
79
|
-
##
|
|
37
|
+
## Agent Workflow
|
|
80
38
|
|
|
81
|
-
|
|
82
|
-
|
|
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` | Full project scan + Guard audit (no params, returns Mission Briefing) | — |
|
|
85
|
-
| `autosnippet_knowledge(operation=list, kind=rule)` | List all Guard rules (kind=rule) | `limit`, `status`, `language`, `category` |
|
|
39
|
+
### Quick Check ("检查这段代码")
|
|
40
|
+
1. `autosnippet_guard` with code → present violations + fix suggestions
|
|
86
41
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
### Quick Check (user asks "检查这段代码")
|
|
92
|
-
1. Call `autosnippet_guard` with the code
|
|
93
|
-
2. Present violations to user with severity and fix suggestions
|
|
94
|
-
3. If user adopts fixes, optionally `autosnippet_knowledge(operation=confirm_usage)` for the relevant Recipe
|
|
95
|
-
|
|
96
|
-
### Module Audit (user asks "审查网络模块")
|
|
97
|
-
1. Call `autosnippet_structure(operation=files)` to get file list
|
|
98
|
-
2. Call `autosnippet_guard` with the file paths
|
|
99
|
-
3. Summarize violations grouped by severity
|
|
100
|
-
4. Suggest fixes based on Recipe standards
|
|
101
|
-
|
|
102
|
-
### Project-wide Compliance
|
|
103
|
-
1. Call `autosnippet_bootstrap` (no params) for full project scan
|
|
104
|
-
2. Present high-severity findings first
|
|
42
|
+
### Module Audit ("审查网络模块")
|
|
43
|
+
1. `autosnippet_structure(operation=files)` → get file list
|
|
44
|
+
2. `autosnippet_guard` with file paths → summarize by severity
|
|
105
45
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
## Audit trigger syntax
|
|
109
|
-
|
|
110
|
-
- `// as:audit` — audit entire file against all rules
|
|
111
|
-
- `// as:audit keyword` — audit with specific keyword focus
|
|
112
|
-
- `// as:lint` — **deprecated**, use `// as:audit`
|
|
46
|
+
### Project-wide
|
|
47
|
+
1. `autosnippet_bootstrap` → full project scan including Guard audit
|
|
113
48
|
|
|
114
49
|
---
|
|
115
50
|
|
|
116
51
|
## Related Skills
|
|
117
52
|
|
|
118
|
-
- **autosnippet-recipes**: Recipe content IS the Guard standard
|
|
119
|
-
- **autosnippet-intent**: General router; may route Guard-related intents here.
|
|
120
|
-
- **autosnippet-analysis**: Deep project scan + Guard baseline via `autosnippet_bootstrap`.
|
|
121
|
-
|
|
122
|
-
```
|
|
53
|
+
- **autosnippet-recipes**: Recipe content IS the Guard standard
|