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
|
@@ -5,147 +5,65 @@ description: Provides this project's Recipe-based context to the agent. Recipes
|
|
|
5
5
|
|
|
6
6
|
# AutoSnippet Recipe Context (Project Context)
|
|
7
7
|
|
|
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
|
-
|
|
10
8
|
This skill provides the agent with this project's context from AutoSnippet Recipes. Recipes are the project's standard knowledge base: code patterns, usage guides, and structured relations.
|
|
11
9
|
|
|
12
10
|
---
|
|
13
11
|
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
**Agent CANNOT directly produce or modify Recipes.** Agent's role is:
|
|
12
|
+
## Knowledge Base Overview
|
|
17
13
|
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
| Enhance candidate info (add rationale/steps/codeChanges etc.) | Bypass candidate review to write to recipes/ |
|
|
14
|
+
| Part | Location | Purpose |
|
|
15
|
+
|------|----------|---------|
|
|
16
|
+
| **Recipes** | `AutoSnippet/recipes/*.md` | Standard code patterns + usage guides; used for AI context, Guard, search |
|
|
17
|
+
| **Snippets** | `AutoSnippet/snippets/*.json` | Code snippets synced to IDE via `asd install` |
|
|
18
|
+
| **Candidates** | `AutoSnippet/.autosnippet/candidates.json` | AI-scanned candidates; review in Dashboard then approve |
|
|
19
|
+
| **Context index** | `AutoSnippet/.autosnippet/context/` | Vector index built by `asd embed`; semantic search via `autosnippet_search(mode=context)` |
|
|
25
20
|
|
|
26
|
-
Recipe
|
|
21
|
+
**Recipe** = one `.md` file = one specific usage pattern or code snippet. **kind**: `rule` (Guard enforced) / `pattern` (best practice) / `fact` (structural knowledge). **Recipe over project code**: When both exist, prefer Recipe as curated standard.
|
|
27
22
|
|
|
28
23
|
---
|
|
29
24
|
|
|
30
|
-
##
|
|
25
|
+
## Agent Permission Boundary
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- **scope**: universal | project-specific | target-specific
|
|
38
|
-
- **content**: { pattern, rationale, steps[], codeChanges[], verification, markdown }
|
|
39
|
-
- **relations**: { inherits[], implements[], calls[], dependsOn[], dataFlow[], conflicts[], extends[], related[] }
|
|
40
|
-
- **constraints**: { boundaries[], preconditions[], sideEffects[], guards[] }
|
|
41
|
-
- **status**: draft -> active -> deprecated
|
|
27
|
+
| Allowed | Forbidden |
|
|
28
|
+
|---------|-----------|
|
|
29
|
+
| Submit candidates (`autosnippet_submit_knowledge` / `_batch`) | Directly create/modify Recipes |
|
|
30
|
+
| Search/query (`autosnippet_search` / `autosnippet_knowledge`) | Publish/deprecate/delete |
|
|
31
|
+
| Confirm usage (`confirm_usage`) | Write to `AutoSnippet/recipes/` |
|
|
42
32
|
|
|
43
33
|
---
|
|
44
34
|
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
1. **Project context**: Read `references/project-recipes-context.md` in this skill folder for **Recipe 轻量索引**(title/trigger/category/summary 表格)。如需 Recipe 全文,调用 MCP `autosnippet_knowledge(operation=get, id)` 或 `autosnippet_search(query)`。索引缺失时,可直接读 `AutoSnippet/recipes/` 目录。
|
|
48
|
-
|
|
49
|
-
2. **Finding code on demand**: Look up matching Recipe by title/summary/usage guide, use its code as standard to suggest. Cite the Recipe title.
|
|
50
|
-
|
|
51
|
-
3. **Recipe over code search**: When both Recipe and code search find matches, prefer Recipe as source of truth.
|
|
52
|
-
|
|
53
|
-
4. **Search - three ways**:
|
|
54
|
-
- In-context: `references/project-recipes-context.md` 轻量索引按 title/trigger/summary 匹配
|
|
55
|
-
- Terminal: `asd search <keyword>` or `asd search --semantic <keyword>`
|
|
56
|
-
- MCP: `autosnippet_search` (mode=auto 或 mode=context) with query and optional limit
|
|
57
|
-
|
|
58
|
-
5. **Browsing Recipes via MCP**:
|
|
59
|
-
- `autosnippet_knowledge(operation=list)` - list with kind/language/category/knowledgeType/status/complexity filters
|
|
60
|
-
- `autosnippet_knowledge(operation=get, id)` - get single Recipe by ID (full content/relations/constraints)
|
|
61
|
-
- `autosnippet_knowledge(operation=list, kind=fact)` - list kind=fact structural knowledge
|
|
62
|
-
|
|
63
|
-
6. **Confirming usage**: Call `autosnippet_knowledge(operation=confirm_usage, id, usageType)` when user adopts a Recipe. Telemetry only.
|
|
64
|
-
|
|
65
|
-
7. **Updating context**: After user changes Recipes, tell them to run `asd install:cursor-skill` to regenerate references.
|
|
66
|
-
|
|
67
|
-
---
|
|
35
|
+
## How to Find Recipes
|
|
68
36
|
|
|
69
|
-
|
|
37
|
+
1. **In-context index**: Read `references/project-recipes-context.md` in this skill folder
|
|
38
|
+
2. **MCP browse**: `autosnippet_knowledge(operation=list)` with kind/language/category filters
|
|
39
|
+
3. **MCP get**: `autosnippet_knowledge(operation=get, id)` for full content
|
|
40
|
+
4. **MCP search**: `autosnippet_search(mode=auto)` for unified BM25+semantic search
|
|
41
|
+
5. **Terminal**: `asd search <keyword>`
|
|
70
42
|
|
|
71
|
-
|
|
72
|
-
2. Recipe priority: Prefer Recipe over codebase implementations. Cite Recipe code.
|
|
73
|
-
3. For "how we do X here": Base answer on Recipe content.
|
|
74
|
-
4. For drafting candidates: Follow autosnippet-candidates flow. Never write to `AutoSnippet/recipes/`.
|
|
75
|
-
5. For Audit/as:audit: Suggestions should match Recipe content.
|
|
76
|
-
6. Usage Guide depth: Include deps, steps, error handling, perf, security, pitfalls, related Recipes.
|
|
77
|
-
7. Placeholders: Prefer Xcode placeholders (e.g. `<#URL#>`, `<#Token#>`).
|
|
43
|
+
**Recipe over code search**: When both find matches, prefer Recipe as source of truth. Cite Recipe title.
|
|
78
44
|
|
|
79
45
|
---
|
|
80
46
|
|
|
81
|
-
##
|
|
82
|
-
|
|
83
|
-
### Query (Agent can freely use)
|
|
84
|
-
|
|
85
|
-
| Tool | Description |
|
|
86
|
-
|------|-------------|
|
|
87
|
-
| `autosnippet_health` | Health check + KB stats |
|
|
88
|
-
| `autosnippet_search` | Unified search (`mode`: auto/context/keyword/semantic) |
|
|
89
|
-
| `autosnippet_knowledge` | Knowledge browse (`operation`: list/get/insights/confirm_usage) |
|
|
90
|
-
| `autosnippet_graph` | Knowledge graph (`operation`: query/impact/path/stats) |
|
|
91
|
-
| `autosnippet_structure` | Project structure (`operation`: targets/files/metadata) |
|
|
92
|
-
| `autosnippet_capabilities` | Service capability discovery |
|
|
93
|
-
|
|
94
|
-
### Candidate Submit (Agent core capability)
|
|
95
|
-
|
|
96
|
-
| Tool | Description |
|
|
97
|
-
|------|-------------|
|
|
98
|
-
| `autosnippet_submit_knowledge` | Submit single candidate (**strict validation** — missing required fields rejected immediately, no fallback). Must provide ALL fields in one call: title, language, content(+rationale), kind, doClause, dontClause, whenClause, coreCode, category, trigger, description, headers, usageGuide, knowledgeType, reasoning |
|
|
99
|
-
| `autosnippet_submit_knowledge_batch` | Batch submit candidates (per-item strict validation + dedup + rate-limit) |
|
|
100
|
-
| `autosnippet_save_document` | Save development document (design doc, debug report, ADR) — title + markdown only |
|
|
101
|
-
|
|
102
|
-
### Guard & Scan & Bootstrap
|
|
103
|
-
|
|
104
|
-
| Tool | Description |
|
|
105
|
-
|------|-------------|
|
|
106
|
-
| `autosnippet_guard` | Code Guard check (`code` single / `files[]` batch — auto-routed) |
|
|
107
|
-
| `autosnippet_bootstrap` | Cold-start Mission Briefing (no params — returns project analysis + dimension tasks) |
|
|
108
|
-
| `autosnippet_dimension_complete` | Dimension analysis completion (dimensionId + analysisText required) |
|
|
109
|
-
|
|
110
|
-
### Wiki
|
|
47
|
+
## How to Use This Context
|
|
111
48
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
### Task Management
|
|
118
|
-
|
|
119
|
-
| Tool | Description |
|
|
120
|
-
|------|-------------|
|
|
121
|
-
| `autosnippet_task` | Unified task & decision management (`operation`: prime/create/claim/close/fail/defer/progress/decompose/record_decision/revise_decision/unpin_decision/list_decisions) |
|
|
122
|
-
|
|
123
|
-
### Skills Management
|
|
124
|
-
|
|
125
|
-
| Tool | Description |
|
|
126
|
-
|------|-------------|
|
|
127
|
-
| `autosnippet_skill` | Skill management (`operation`: list/load/create/update/delete/suggest) |
|
|
49
|
+
1. **Project standards/Guard**: Use Recipe content as source of truth
|
|
50
|
+
2. **"How we do X here"**: Base answer on Recipe content
|
|
51
|
+
3. **Suggesting code**: Cite Recipe's code snippet, not raw search results
|
|
52
|
+
4. **Guard/Audit**: `// as:audit` or MCP `autosnippet_guard` — both use Recipes as standard
|
|
53
|
+
5. **Confirm adoption**: `autosnippet_knowledge(operation=confirm_usage, id, usageType)` when user uses a Recipe
|
|
128
54
|
|
|
129
55
|
---
|
|
130
56
|
|
|
131
|
-
##
|
|
57
|
+
## Auto-Extracting Headers for New Candidates
|
|
132
58
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
| Search | `asd search keyword` or MCP `autosnippet_search` (mode=auto/context/keyword/semantic) |
|
|
137
|
-
| AI Assistant | Dashboard RAG and AI chat use Recipes as context |
|
|
138
|
-
| Xcode | Recipes linked to Snippets; synced to Xcode CodeSnippets |
|
|
139
|
-
| Guard | kind=rule Recipes enforced by Guard checks during audit |
|
|
140
|
-
| Insights | `autosnippet_knowledge(operation=insights, id)` for quality scores, usage stats, and relation summary |
|
|
141
|
-
| Graph | `autosnippet_graph(operation=query/impact/path)` for relationship analysis |
|
|
59
|
+
1. **From code** (Recommended): Extract all import statements from user's code
|
|
60
|
+
2. **From existing Recipes**: Check index for matching modules, then `autosnippet_knowledge(operation=get, id)` for full content
|
|
61
|
+
3. **Via semantic search**: `autosnippet_search(mode=context)` with query like "import ModuleName"
|
|
142
62
|
|
|
143
63
|
---
|
|
144
64
|
|
|
145
|
-
##
|
|
146
|
-
|
|
147
|
-
1. From code (Recommended): Extract all import statements from user's code
|
|
148
|
-
2. From existing Recipes: Check `references/project-recipes-context.md` index for matching modules, then call MCP `autosnippet_knowledge(operation=get, id)` for full content
|
|
149
|
-
3. Via semantic search: Call `autosnippet_search(mode=context)` with query like "import ModuleName headers"
|
|
65
|
+
## Related Skills
|
|
150
66
|
|
|
151
|
-
|
|
67
|
+
- **autosnippet-create**: Submit knowledge candidates (V3 fields, validation, lifecycle)
|
|
68
|
+
- **autosnippet-guard**: Code compliance checking against Recipe standards
|
|
69
|
+
- **autosnippet-structure**: Project structure and knowledge graph
|
|
@@ -5,83 +5,51 @@ description: Discover project structure (targets, files, dependency graph) and b
|
|
|
5
5
|
|
|
6
6
|
# AutoSnippet — Structure & Dependencies & Knowledge Graph
|
|
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 asks about **project structure**, **module targets**, **dependency graph**, or **knowledge graph relationships**.
|
|
11
9
|
|
|
12
|
-
## When to use
|
|
13
|
-
|
|
14
|
-
- "有哪些 Target?"
|
|
15
|
-
- "某个 Target 包含哪些文件?"
|
|
16
|
-
- "依赖关系/谁依赖谁?"
|
|
17
|
-
- "SPM 结构/模块拓扑"
|
|
18
|
-
- "这两个 Recipe 之间有什么关联?"
|
|
19
|
-
- "知识图谱统计 / 关联密度"
|
|
20
|
-
- "修改这个 Recipe 会影响哪些?"
|
|
21
|
-
|
|
22
10
|
---
|
|
23
11
|
|
|
24
|
-
##
|
|
12
|
+
## Project Structure Tools
|
|
25
13
|
|
|
26
14
|
| Tool | Purpose | Key Input |
|
|
27
15
|
|------|---------|-----------|
|
|
28
|
-
| `autosnippet_structure(operation=targets)` | List all module Targets (
|
|
29
|
-
| `autosnippet_structure(operation=files)` | Get source files for a Target | `targetName` (required)
|
|
30
|
-
| `autosnippet_structure(operation=metadata)` |
|
|
16
|
+
| `autosnippet_structure(operation=targets)` | List all module Targets (file count, language stats, inferred role) | `includeSummary` |
|
|
17
|
+
| `autosnippet_structure(operation=files)` | Get source files for a Target | `targetName` (required) |
|
|
18
|
+
| `autosnippet_structure(operation=metadata)` | Target metadata (dependencies, package info, graph edges) | `targetName` (required) |
|
|
31
19
|
|
|
32
|
-
### Workflow
|
|
33
|
-
1. `
|
|
34
|
-
2. `
|
|
35
|
-
3. `
|
|
20
|
+
### Workflow
|
|
21
|
+
1. `targets` → see all Targets with roles
|
|
22
|
+
2. `files` → drill into specific Target
|
|
23
|
+
3. `metadata` → get dependencies and relations
|
|
36
24
|
|
|
37
25
|
---
|
|
38
26
|
|
|
39
|
-
##
|
|
27
|
+
## Knowledge Graph Tools
|
|
40
28
|
|
|
41
|
-
|
|
29
|
+
Captures **relationships between Recipes** (dependencies, extensions, conflicts, etc.).
|
|
42
30
|
|
|
43
31
|
| Tool | Purpose | Key Input |
|
|
44
32
|
|------|---------|-----------|
|
|
45
|
-
| `autosnippet_graph(operation=query)` | Get all relations for a Recipe node | `nodeId
|
|
46
|
-
| `autosnippet_graph(operation=impact)` | Impact analysis:
|
|
47
|
-
| `autosnippet_graph(operation=path)` |
|
|
48
|
-
| `autosnippet_graph(operation=stats)` | Global graph statistics
|
|
49
|
-
|
|
50
|
-
### Workflow: Explore knowledge graph
|
|
51
|
-
1. `autosnippet_graph(operation=stats)` → overview: how many edges, relation types
|
|
52
|
-
2. `autosnippet_graph(operation=query, nodeId)` → see all connections for a specific Recipe
|
|
53
|
-
3. `autosnippet_graph(operation=impact, nodeId)` → before changing a Recipe, check downstream impact
|
|
54
|
-
4. `autosnippet_graph(operation=path, fromId, toId)` → discover indirect relationships between Recipes
|
|
55
|
-
|
|
56
|
-
### When to use graph tools
|
|
57
|
-
- User asks "修改这个 Recipe 会影响什么?" → `autosnippet_graph(operation=impact)`
|
|
58
|
-
- User asks "这两个模块有什么关联?" → `autosnippet_graph(operation=path)`
|
|
59
|
-
- User wants overview of knowledge connections → `autosnippet_graph(operation=stats)`
|
|
60
|
-
- User wants to see all dependencies/extends/conflicts for a Recipe → `autosnippet_graph(operation=query)`
|
|
33
|
+
| `autosnippet_graph(operation=query)` | Get all relations for a Recipe node | `nodeId`, `relation`, `direction` |
|
|
34
|
+
| `autosnippet_graph(operation=impact)` | Impact analysis: downstream dependencies | `nodeId`, `maxDepth` |
|
|
35
|
+
| `autosnippet_graph(operation=path)` | Shortest path between two Recipes (BFS) | `fromId`, `toId` |
|
|
36
|
+
| `autosnippet_graph(operation=stats)` | Global graph statistics | — |
|
|
61
37
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
The SPM dependency structure is stored in `AutoSnippet/AutoSnippet.spmmap.json`:
|
|
67
|
-
- **`graph.packages`**: Package declarations with targets
|
|
68
|
-
- **`graph.edges`**: "from depends on to" relationships
|
|
69
|
-
- **Update**: Run `asd spm-map` from project root to refresh (supports SPM / Node / Go / JVM / Python / Dart / Rust)
|
|
38
|
+
### When to use
|
|
39
|
+
- "修改这个 Recipe 会影响什么?" → `impact`
|
|
40
|
+
- "这两个模块有什么关联?" → `path`
|
|
41
|
+
- "知识图谱统计" → `stats`
|
|
70
42
|
|
|
71
43
|
---
|
|
72
44
|
|
|
73
|
-
##
|
|
45
|
+
## Dependency Structure File
|
|
74
46
|
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
- Use Dashboard dep graph visualization for team presentations (requires `asd ui`).
|
|
47
|
+
SPM dependency structure: `AutoSnippet/AutoSnippet.spmmap.json`
|
|
48
|
+
- Run `asd spm-map` to refresh (supports SPM / Node / Go / JVM / Python / Dart / Rust)
|
|
78
49
|
|
|
79
50
|
---
|
|
80
51
|
|
|
81
52
|
## Related Skills
|
|
82
53
|
|
|
83
|
-
- **autosnippet-recipes**: Recipe content used as project standards
|
|
84
|
-
- **autosnippet-
|
|
85
|
-
- **autosnippet-analysis**: Deep project analysis uses structure + graph tools.
|
|
86
|
-
|
|
87
|
-
```
|
|
54
|
+
- **autosnippet-recipes**: Recipe content used as project standards
|
|
55
|
+
- **autosnippet-create**: After understanding structure, submit knowledge candidates
|
|
@@ -1,45 +1,29 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: AutoSnippet Project Skills —
|
|
2
|
+
description: AutoSnippet Project Skills — knowledge enhancement documents for AI Agent
|
|
3
3
|
alwaysApply: true
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AutoSnippet Project Skills
|
|
7
7
|
|
|
8
|
-
Project Skills
|
|
9
|
-
它们存放在 `AutoSnippet/skills/` 目录下,跟随项目 Git 管理。
|
|
8
|
+
Project Skills are AI knowledge documents in `AutoSnippet/skills/`, tracked in Git.
|
|
10
9
|
|
|
11
|
-
##
|
|
10
|
+
## Discovery & Loading
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
4. **创建 Skill**:调用 `autosnippet_create_skill(name, description, content)` 创建项目级 Skill
|
|
17
|
-
5. **Skill 推荐**:调用 `autosnippet_suggest_skills` 获取基于使用模式的 Skill 创建建议
|
|
12
|
+
- **List**: `autosnippet_skill({ operation: "list" })` — all available Skills (builtin + project)
|
|
13
|
+
- **Load**: `autosnippet_skill({ operation: "load", name: "<skill>" })` — full Skill content
|
|
14
|
+
- **Create**: `autosnippet_skill({ operation: "create", name, description, content })` — new project Skill
|
|
18
15
|
|
|
19
|
-
##
|
|
16
|
+
## Built-in Skills (5)
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
| Skill | Purpose |
|
|
19
|
+
|-------|---------|
|
|
20
|
+
| `autosnippet-create` | Submit knowledge candidates (V3 fields, validation) |
|
|
21
|
+
| `autosnippet-recipes` | Project standard context (Recipe search, retrieval) |
|
|
22
|
+
| `autosnippet-guard` | Code compliance checking against Recipes |
|
|
23
|
+
| `autosnippet-structure` | Project structure discovery & knowledge graph |
|
|
24
|
+
| `autosnippet-devdocs` | Save development documents (ADRs, debug reports) |
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|-------|------|------|
|
|
25
|
-
| `project-code-standard` | 代码规范 | 命名约定、文件组织规范 |
|
|
26
|
-
| `project-architecture` | 架构模式 | 分层架构、模块边界、依赖图 |
|
|
27
|
-
| `project-profile` | 项目特征 | 技术栈、模块结构、代码指标 |
|
|
28
|
-
| `project-agent-guidelines` | Agent 约束 | 强制规则、TODO/FIXME、WARNING |
|
|
26
|
+
## Priority
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## 推荐工作流
|
|
34
|
-
|
|
35
|
-
冷启动完整流程:
|
|
36
|
-
1. `autosnippet_bootstrap_knowledge` — 9 维度分析 + 自动生成 Project Skills
|
|
37
|
-
2. `autosnippet_enrich_candidates` — 补全缺失语义字段
|
|
38
|
-
3. `autosnippet_bootstrap_refine` — AI 润色 summary/insight/relations
|
|
39
|
-
4. 逐 Target 深入分析 → `autosnippet_submit_candidates`
|
|
40
|
-
|
|
41
|
-
## 使用优先级
|
|
42
|
-
|
|
43
|
-
- **Project Skills > 内置 Skills**:同名时项目级覆盖内置
|
|
44
|
-
- **Skill > Recipe**:宏观架构/规范知识优先查 Skill,微观代码模式查 Recipe
|
|
45
|
-
- **Skills 是只读参考**:不要直接修改 SKILL.md,应通过 `autosnippet_create_skill` 工具创建或更新
|
|
28
|
+
- **Project Skills > Built-in Skills** — same name → project overrides builtin
|
|
29
|
+
- **Skills = read-only reference** — load via MCP tool, do not edit SKILL.md directly
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# {{projectName}} — Agent Instructions
|
|
2
|
+
|
|
3
|
+
> Auto-generated by AutoSnippet.
|
|
4
|
+
|
|
5
|
+
This project uses **AutoSnippet** for knowledge management.
|
|
6
|
+
Access the knowledge base through MCP tools.
|
|
7
|
+
|
|
8
|
+
## MCP Tools
|
|
9
|
+
|
|
10
|
+
- `autosnippet_task` — Task & decision management (prime/create/claim/close/record_decision)
|
|
11
|
+
- `autosnippet_search` — Search knowledge (mode: auto/context/keyword/semantic)
|
|
12
|
+
- `autosnippet_knowledge` — Knowledge CRUD (operation: list/get/insights)
|
|
13
|
+
- `autosnippet_submit_knowledge` — Submit knowledge candidate
|
|
14
|
+
- `autosnippet_guard` — Code compliance check
|
|
15
|
+
- `autosnippet_skill` — Skill management (list/load)
|
|
16
|
+
- `autosnippet_structure` — Project structure discovery
|
|
17
|
+
- `autosnippet_bootstrap` — Project cold-start & scan
|
|
18
|
+
- `autosnippet_health` — Service health & KB stats
|
|
19
|
+
|
|
20
|
+
## Constraints
|
|
21
|
+
|
|
22
|
+
1. Do NOT modify knowledge base files directly (`AutoSnippet/recipes/`, `.autosnippet/`).
|
|
23
|
+
2. Prefer Recipes as project standards; source code is supplementary.
|
|
24
|
+
3. Create or update knowledge only through MCP tools.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
## YOU Operate autosnippet_task — The User Doesn't
|
|
2
|
+
|
|
3
|
+
Users speak naturally; you translate to task operations. Never tell users to call autosnippet_task.
|
|
4
|
+
|
|
5
|
+
## Task Rules (MANDATORY)
|
|
6
|
+
|
|
7
|
+
1. **Prime EVERY message** — `autosnippet_task({ operation: "prime" })` FIRST.
|
|
8
|
+
2. **Create task for non-trivial work** — ≥2 files OR ≥10 lines → `create` → `claim` → code → `close`.
|
|
9
|
+
3. **Decision persistence** — User agrees/disagrees → `record_decision` immediately.
|
|
10
|
+
4. **Session end** — Close or defer ALL tasks. Zero in_progress on exit.
|
|
11
|
+
5. **You are the operator** — Never tell users to call autosnippet_task.
|
|
12
|
+
6. **Skip task for**: Quick questions, single-file trivial fixes (<10 lines), code explanation.
|
|
13
|
+
|
|
14
|
+
| User Says | You Run |
|
|
15
|
+
|---|---|
|
|
16
|
+
| "fix bug" / "implement" | `create` → `claim` → code → `close` |
|
|
17
|
+
| "continue" | resume in-progress → `close` |
|
|
18
|
+
| "pause" / "abandon" | `defer` / `fail` |
|
|
19
|
+
| "break down" | `decompose(id, subtasks)` |
|
|
20
|
+
| "what's next" | `ready()` → present |
|
|
21
|
+
| "agreed" | `record_decision(...)` |
|
|
22
|
+
|
|
23
|
+
## Knowledge Rules
|
|
24
|
+
|
|
25
|
+
- **Do NOT modify** `AutoSnippet/recipes/` or `.autosnippet/` directly.
|
|
26
|
+
- **Prefer Recipe** as project standard; source code is supplementary.
|
|
27
|
+
- **Search**: `autosnippet_search({ query: "..." })` — auto mode (BM25 + semantic).
|
|
28
|
+
|
|
29
|
+
## Essential MCP Tools
|
|
30
|
+
|
|
31
|
+
- `autosnippet_task` — Task & decision management (**call `prime` first on every message**)
|
|
32
|
+
- `autosnippet_search` — Search knowledge (mode: auto/context/keyword/semantic)
|
|
33
|
+
- `autosnippet_knowledge` — Browse recipes (operation: list/get/insights)
|
|
34
|
+
- `autosnippet_submit_knowledge` — Submit knowledge candidate
|
|
35
|
+
- `autosnippet_guard` — Code compliance check
|
|
36
|
+
- `autosnippet_skill` — Load project skills (list/load)
|
|
37
|
+
- `autosnippet_health` — Service health & KB stats
|
|
38
|
+
|
|
39
|
+
## Context Pressure
|
|
40
|
+
|
|
41
|
+
- `CONTEXT_PRESSURE:WARNING` → Summarize completed work, continue.
|
|
42
|
+
- `CONTEXT_PRESSURE:CRITICAL` → Call `prime` immediately to restore context.
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: autosnippet-analysis
|
|
3
|
-
description: Deep project analysis — full scan + semantic field enrichment + gap fill before Recipe creation. Both Cursor Agent and internal AI share the same capability set.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# AutoSnippet — Deep Project Analysis & Semantic Enrichment
|
|
7
|
-
|
|
8
|
-
> Self-check & Fallback: MCP 工具返回统一 JSON Envelope({ success, errorCode?, message?, data?, meta })。重操作前调用 `autosnippet_health`;失败时不在同一轮重试,转用静态上下文或缩小范围后再试。
|
|
9
|
-
|
|
10
|
-
## Core Principle
|
|
11
|
-
|
|
12
|
-
**MCP 工具负责数据采集 + 静态检查;你(Agent)负责语义理解;Agent 直接填写完整字段后通过 `autosnippet_submit_knowledge` 提交。**
|
|
13
|
-
|
|
14
|
-
**⚠️ 严格提交规则**:`autosnippet_submit_knowledge` 实施严格前置校验——缺少必要字段的提交将被**直接拒绝(不入库)**。必须在单次调用中一次性提供所有必填字段(title, language, content, kind, doClause, dontClause, whenClause, coreCode, category, trigger, description, headers, usageGuide, knowledgeType, reasoning, content.rationale)。不要分步提交或先提交再补全。
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Capability 1: 全项目扫描 → 提交候选
|
|
19
|
-
|
|
20
|
-
> **首次接入项目?** 使用 **autosnippet-coldstart** Skill — 完整的 9 维度冷启动流程(含架构分析、项目特征、Agent 注意事项),比本 Skill 的扫描流程更全面。
|
|
21
|
-
> 本 Capability 适用于已有知识库后的**增量补充扫描**。
|
|
22
|
-
|
|
23
|
-
### When to Use
|
|
24
|
-
用户说:"全项目扫描"、"分析我的项目"、"提取架构模式"、"生成知识库"。
|
|
25
|
-
|
|
26
|
-
### Workflow
|
|
27
|
-
|
|
28
|
-
#### Phase 1: Collect & Baseline
|
|
29
|
-
1. 调用 `autosnippet_bootstrap`(无参数)获取 Mission Briefing(文件列表 + Guard 审计基线)
|
|
30
|
-
2. 审视 Guard 违规 — 静态规则问题 (命名/API 使用/废弃 API)
|
|
31
|
-
3. 确定高优先级文件 (核心模块/共享工具/Service 层)
|
|
32
|
-
|
|
33
|
-
#### Phase 2: Semantic Deep-Read
|
|
34
|
-
读取代码文件,逐维度分析:
|
|
35
|
-
|
|
36
|
-
| 分析维度 | 寻找什么 | knowledgeType | 对应字段 |
|
|
37
|
-
|---------|---------|---------------|---------|
|
|
38
|
-
| **架构模式** | 分层架构、MVVM/MVC、依赖注入 | `architecture` | rationale: 为什么选这种架构 |
|
|
39
|
-
| **代码模式** | 封装方式、公共 API 设计、工厂/单例 | `code-pattern` | steps: 如何采用该模式 |
|
|
40
|
-
| **代码规范** | 命名规范、文件组织、注释风格 | `code-standard` | constraints.preconditions: 前置条件 |
|
|
41
|
-
| **最佳实践** | 错误处理、并发、内存管理 | `best-practice` | rationale: 为什么这是最佳实践 |
|
|
42
|
-
| **调用链** | 关键业务的调用路径 | `call-chain` | steps: 调用顺序 |
|
|
43
|
-
| **数据流** | 状态管理、模块间数据传递 | `data-flow` | steps: 数据流向 |
|
|
44
|
-
| **模块依赖** | 依赖边界、约束 | `module-dependency` | constraints: 边界约束 |
|
|
45
|
-
| **Bug 修复** | 常见修复模式、defensive coding | `solution` | rationale: 为什么这样修 |
|
|
46
|
-
|
|
47
|
-
#### Phase 3: Submit with Full Semantic Fields
|
|
48
|
-
**每条候选必须填充以下语义字段**(不留空):
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
{
|
|
52
|
-
"title": "网络层统一错误处理模式",
|
|
53
|
-
"content": {
|
|
54
|
-
"pattern": "<实际代码模式>",
|
|
55
|
-
"rationale": "统一错误处理避免分散的 try-catch,便于日志收集和错误上报"
|
|
56
|
-
},
|
|
57
|
-
"language": "swift",
|
|
58
|
-
"kind": "pattern",
|
|
59
|
-
"doClause": "Use centralized error handling via APIClient.request() for all network calls",
|
|
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()",
|
|
65
|
-
"knowledgeType": "code-pattern",
|
|
66
|
-
"complexity": "intermediate",
|
|
67
|
-
"scope": "project-specific",
|
|
68
|
-
"steps": [
|
|
69
|
-
{ "title": "创建 Error 枚举", "description": "在 Network/ 下创建 NetworkError.swift", "code": "enum NetworkError: Error { ... }" },
|
|
70
|
-
{ "title": "封装请求方法", "description": "所有请求统一通过 APIClient.request()", "code": "" }
|
|
71
|
-
],
|
|
72
|
-
"constraints": {
|
|
73
|
-
"preconditions": ["iOS 15+", "需引入 Combine framework"],
|
|
74
|
-
"boundaries": ["不可用于 WebSocket 连接"],
|
|
75
|
-
"sideEffects": []
|
|
76
|
-
},
|
|
77
|
-
"tags": ["networking", "error-handling"],
|
|
78
|
-
"reasoning": {
|
|
79
|
-
"whyStandard": "项目中 15 个网络模块均采用此模式",
|
|
80
|
-
"sources": ["Sources/Network/APIClient.swift", "Sources/Network/ErrorHandler.swift"],
|
|
81
|
-
"confidence": 0.9
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Use `autosnippet_submit_knowledge_batch` for batch submission.
|
|
87
|
-
|
|
88
|
-
#### Phase 4: Guard Deep Audit (Optional)
|
|
89
|
-
对特定文件调用 `autosnippet_guard` (files[]) 做深度规范审计。
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Capability 2: 语义字段补全(需要 AI 理解的字段)
|
|
94
|
-
|
|
95
|
-
### When to Use
|
|
96
|
-
- 候选已有 title/code/language 但缺少深度语义字段
|
|
97
|
-
- 候选要晋升为 Recipe 前,需要补全
|
|
98
|
-
- 用户说:"补全候选字段"、"enrich"、"查漏补缺"
|
|
99
|
-
|
|
100
|
-
### 需要语义理解的 6 个字段
|
|
101
|
-
|
|
102
|
-
| 字段 | 为什么需要 AI | 示例 |
|
|
103
|
-
|------|-------------|------|
|
|
104
|
-
| **rationale** | 需理解设计意图,回答"为什么这样做" | "该模式使用 Builder 而非直接构造,因为参数超过 5 个且多数可选" |
|
|
105
|
-
| **knowledgeType** | 需理解知识本质(规范/模式/事实) | `architecture` vs `code-pattern` vs `best-practice` |
|
|
106
|
-
| **complexity** | 需评估使用难度 | `beginner`(一行调用)vs `advanced`(需理解泛型+协议组合) |
|
|
107
|
-
| **scope** | 需判断适用范围 | `universal`(通用 Singleton)vs `project-specific`(依赖项目 Config) |
|
|
108
|
-
| **steps** | 需拆解实施步骤 | `[{title: "创建协议", description: "...", code: "..."}]` |
|
|
109
|
-
| **constraints.preconditions** | 需理解前置条件 | `["iOS 15+", "需先配置 Firebase", "依赖 NetworkModule"]` |
|
|
110
|
-
|
|
111
|
-
### Workflow for Enrichment
|
|
112
|
-
|
|
113
|
-
**方式 A: 你(Agent)直接补全**
|
|
114
|
-
在分析代码时,直接填写所有 6 个语义字段到 `autosnippet_submit_knowledge` 调用中。
|
|
115
|
-
|
|
116
|
-
**方式 B: 对已有候选调用 AI 补全**
|
|
117
|
-
> 注:`autosnippet_enrich_candidates` 已移入 admin 层级,Agent 推荐使用方式 A 直接填写完整字段。
|
|
118
|
-
|
|
119
|
-
**方式 C: 候选字段诊断**
|
|
120
|
-
```
|
|
121
|
-
autosnippet_enrich_candidates({ candidateIds: ["id1", "id2", ...] })
|
|
122
|
-
```
|
|
123
|
-
诊断候选缺失字段(不使用 AI),Agent 根据诊断结果自行补全。
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
## Capability 3: 候选 → Recipe 查漏补缺
|
|
128
|
-
|
|
129
|
-
### When to Use
|
|
130
|
-
- 用户准备将候选发布为 Recipe
|
|
131
|
-
- 用户说:"准备发布"、"候选检查"、"Recipe 就绪检查"
|
|
132
|
-
|
|
133
|
-
### Workflow
|
|
134
|
-
|
|
135
|
-
1. 对目标候选做结构补齐(确保所有字段完整)
|
|
136
|
-
2. 调用 `autosnippet_enrich_candidates` 诊断候选缺失字段,根据结果自行补全
|
|
137
|
-
3. 提交时使用 `autosnippet_submit_knowledge`(内置自动校验 + 去重检查)
|
|
138
|
-
4. 报告补全情况 + 缺失字段 + 重复风险
|
|
139
|
-
5. 如缺失字段 AI 无法填充,提示用户手动补充
|
|
140
|
-
|
|
141
|
-
### Recipe 必备字段检查清单
|
|
142
|
-
|
|
143
|
-
| 字段 | 重要性 | AI 可填? |
|
|
144
|
-
|------|-------|---------|
|
|
145
|
-
| title | ★★★ 必填 | ✅ |
|
|
146
|
-
| content (markdown+pattern+rationale) | ★★★ 必填 | ✅ |
|
|
147
|
-
| language | ★★★ 必填 | ✅ |
|
|
148
|
-
| kind (rule/pattern/fact) | ★★★ 必填 | ✅ |
|
|
149
|
-
| doClause | ★★★ 必填 | ✅ |
|
|
150
|
-
| category | ★★★ 必填 | ✅ |
|
|
151
|
-
| trigger | ★★★ 必填 | ✅ |
|
|
152
|
-
| description | ★★★ 必填 | ✅ |
|
|
153
|
-
| headers | ★★★ 必填 | ✅ |
|
|
154
|
-
| usageGuide | ★★★ 必填 | ✅ |
|
|
155
|
-
| knowledgeType | ★★★ 必填 | ✅ |
|
|
156
|
-
| reasoning | ★★★ 必填 | Agent 必须自己填 |
|
|
157
|
-
| complexity | ★★☆ 推荐 | ✅ |
|
|
158
|
-
| scope | ★★☆ 推荐 | ✅ |
|
|
159
|
-
| steps | ★★☆ 推荐 | ✅ |
|
|
160
|
-
| constraints.preconditions | ★★☆ 推荐 | ✅ |
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## Related Skills
|
|
165
|
-
|
|
166
|
-
- **autosnippet-candidates**: 完整候选字段模型 + 提交指南
|
|
167
|
-
- **autosnippet-structure**: 项目结构发现 (targets / files / dependencies)
|
|
168
|
-
- **autosnippet-guard**: Guard 触发机制 (`// as:audit`)
|
|
169
|
-
- **autosnippet-recipes**: Recipe 内容与查询
|