autosnippet 3.2.18 → 3.2.20

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.
Files changed (183) hide show
  1. package/README.md +73 -104
  2. package/dashboard/dist/assets/{index-CKMy5LY6.js → index-DdvZE4Yd.js} +1 -1
  3. package/dashboard/dist/index.html +1 -1
  4. package/dist/bin/cli.js +45 -10
  5. package/dist/lib/agent/AgentEventBus.js +3 -3
  6. package/dist/lib/agent/AgentFactory.d.ts +3 -3
  7. package/dist/lib/agent/AgentFactory.js +4 -4
  8. package/dist/lib/agent/AgentMessage.d.ts +8 -8
  9. package/dist/lib/agent/AgentMessage.js +8 -8
  10. package/dist/lib/agent/AgentRuntime.js +2 -2
  11. package/dist/lib/agent/AgentState.js +4 -4
  12. package/dist/lib/agent/ConversationStore.d.ts +1 -1
  13. package/dist/lib/agent/ConversationStore.js +1 -1
  14. package/dist/lib/agent/PipelineStrategy.js +1 -1
  15. package/dist/lib/agent/context/ContextWindow.d.ts +2 -2
  16. package/dist/lib/agent/context/ContextWindow.js +7 -7
  17. package/dist/lib/agent/context/ExplorationTracker.js +9 -9
  18. package/dist/lib/agent/context/exploration/PlanTracker.js +2 -2
  19. package/dist/lib/agent/context/exploration/SignalDetector.d.ts +1 -1
  20. package/dist/lib/agent/context/exploration/SignalDetector.js +1 -1
  21. package/dist/lib/agent/core/LoopContext.d.ts +21 -21
  22. package/dist/lib/agent/core/LoopContext.js +21 -21
  23. package/dist/lib/agent/core/SystemPromptBuilder.js +4 -4
  24. package/dist/lib/agent/domain/EvidenceCollector.js +5 -5
  25. package/dist/lib/agent/memory/ActiveContext.js +1 -1
  26. package/dist/lib/agent/memory/MemoryRetriever.js +1 -1
  27. package/dist/lib/agent/memory/MemoryStore.js +2 -2
  28. package/dist/lib/agent/memory/SessionStore.js +3 -3
  29. package/dist/lib/agent/policies.d.ts +1 -1
  30. package/dist/lib/agent/policies.js +1 -1
  31. package/dist/lib/agent/strategies.d.ts +1 -1
  32. package/dist/lib/agent/strategies.js +4 -4
  33. package/dist/lib/agent/tools/_shared.d.ts +1 -1
  34. package/dist/lib/agent/tools/_shared.js +1 -1
  35. package/dist/lib/agent/tools/infrastructure.js +2 -2
  36. package/dist/lib/cli/SetupService.d.ts +25 -25
  37. package/dist/lib/cli/SetupService.js +28 -15
  38. package/dist/lib/cli/deploy/FileDeployer.d.ts +9 -2
  39. package/dist/lib/cli/deploy/FileDeployer.js +139 -46
  40. package/dist/lib/cli/deploy/FileManifest.d.ts +23 -39
  41. package/dist/lib/cli/deploy/FileManifest.js +22 -27
  42. package/dist/lib/core/AstAnalyzer.d.ts +2 -2
  43. package/dist/lib/core/AstAnalyzer.js +2 -2
  44. package/dist/lib/core/analysis/CallEdgeResolver.d.ts +7 -7
  45. package/dist/lib/core/analysis/CallEdgeResolver.js +9 -9
  46. package/dist/lib/core/analysis/CallGraphAnalyzer.d.ts +4 -4
  47. package/dist/lib/core/analysis/CallGraphAnalyzer.js +2 -2
  48. package/dist/lib/core/analysis/ImportPathResolver.d.ts +0 -2
  49. package/dist/lib/core/analysis/ImportPathResolver.js +2 -4
  50. package/dist/lib/core/ast/ProjectGraph.js +7 -7
  51. package/dist/lib/core/capability/CapabilityProbe.js +6 -14
  52. package/dist/lib/domain/knowledge/UnifiedValidator.js +2 -2
  53. package/dist/lib/domain/knowledge/values/Constraints.js +4 -4
  54. package/dist/lib/domain/knowledge/values/Content.js +6 -6
  55. package/dist/lib/domain/knowledge/values/Quality.js +5 -5
  56. package/dist/lib/domain/knowledge/values/Reasoning.js +5 -5
  57. package/dist/lib/domain/knowledge/values/Relations.js +1 -1
  58. package/dist/lib/domain/knowledge/values/Stats.js +6 -6
  59. package/dist/lib/domain/task/TaskIdGenerator.d.ts +4 -4
  60. package/dist/lib/domain/task/TaskIdGenerator.js +2 -2
  61. package/dist/lib/external/lark/LarkTransport.js +4 -4
  62. package/dist/lib/external/mcp/McpServer.d.ts +3 -7
  63. package/dist/lib/external/mcp/McpServer.js +9 -13
  64. package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +5 -5
  65. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +4 -3
  66. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.d.ts +3 -3
  67. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +3 -3
  68. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.d.ts +1 -1
  69. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +1 -1
  70. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.js +3 -3
  71. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +27 -14
  72. package/dist/lib/external/mcp/handlers/bootstrap-external.js +6 -0
  73. package/dist/lib/external/mcp/handlers/dimension-complete-external.js +55 -1
  74. package/dist/lib/external/mcp/handlers/skill.js +9 -31
  75. package/dist/lib/external/mcp/handlers/system.js +2 -2
  76. package/dist/lib/external/mcp/handlers/task.js +16 -1
  77. package/dist/lib/external/mcp/tools.d.ts +12 -10
  78. package/dist/lib/external/mcp/tools.js +97 -69
  79. package/dist/lib/http/utils/routeHelpers.d.ts +1 -1
  80. package/dist/lib/http/utils/routeHelpers.js +1 -1
  81. package/dist/lib/http/utils/sse-sessions.d.ts +1 -1
  82. package/dist/lib/http/utils/sse-sessions.js +1 -1
  83. package/dist/lib/infrastructure/cache/CacheService.js +1 -1
  84. package/dist/lib/infrastructure/vector/AsyncPersistence.js +8 -8
  85. package/dist/lib/infrastructure/vector/BatchEmbedder.d.ts +1 -1
  86. package/dist/lib/infrastructure/vector/BatchEmbedder.js +2 -2
  87. package/dist/lib/infrastructure/vector/HnswIndex.d.ts +4 -4
  88. package/dist/lib/infrastructure/vector/HnswIndex.js +5 -5
  89. package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +8 -8
  90. package/dist/lib/infrastructure/vector/ScalarQuantizer.d.ts +1 -1
  91. package/dist/lib/infrastructure/vector/ScalarQuantizer.js +4 -4
  92. package/dist/lib/infrastructure/vector/VectorStore.d.ts +1 -1
  93. package/dist/lib/infrastructure/vector/VectorStore.js +1 -1
  94. package/dist/lib/injection/ServiceContainer.d.ts +1 -1
  95. package/dist/lib/injection/ServiceContainer.js +1 -1
  96. package/dist/lib/platform/NativeUi.d.ts +1 -1
  97. package/dist/lib/platform/NativeUi.js +1 -1
  98. package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +1 -1
  99. package/dist/lib/platform/ios/spm/DependencyGraph.js +1 -1
  100. package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +1 -1
  101. package/dist/lib/platform/ios/spm/PolicyEngine.js +1 -1
  102. package/dist/lib/platform/ios/spm/SpmDiscoverer.js +1 -1
  103. package/dist/lib/platform/ios/spm/SpmHelper.js +3 -3
  104. package/dist/lib/platform/ios/xcode/SaveEventFilter.js +2 -2
  105. package/dist/lib/platform/ios/xcode/XcodeIntegration.js +1 -1
  106. package/dist/lib/repository/base/BaseRepository.js +1 -1
  107. package/dist/lib/repository/task/TaskRepository.impl.d.ts +2 -2
  108. package/dist/lib/repository/task/TaskRepository.impl.js +1 -1
  109. package/dist/lib/repository/token/TokenUsageStore.js +1 -1
  110. package/dist/lib/service/automation/ActionPipeline.d.ts +1 -1
  111. package/dist/lib/service/automation/ActionPipeline.js +1 -1
  112. package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +2 -2
  113. package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +1 -1
  114. package/dist/lib/service/bootstrap/BootstrapTaskManager.js +2 -2
  115. package/dist/lib/service/bootstrap/DimensionCopyRegistry.d.ts +2 -2
  116. package/dist/lib/service/bootstrap/DimensionCopyRegistry.js +2 -2
  117. package/dist/lib/service/delivery/AgentInstructionsGenerator.d.ts +6 -15
  118. package/dist/lib/service/delivery/AgentInstructionsGenerator.js +53 -189
  119. package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +6 -16
  120. package/dist/lib/service/delivery/CursorDeliveryPipeline.js +14 -19
  121. package/dist/lib/service/delivery/KnowledgeCompressor.d.ts +1 -1
  122. package/dist/lib/service/delivery/KnowledgeCompressor.js +1 -1
  123. package/dist/lib/service/delivery/RulesGenerator.d.ts +10 -3
  124. package/dist/lib/service/delivery/RulesGenerator.js +43 -3
  125. package/dist/lib/service/delivery/SkillsSyncer.d.ts +21 -7
  126. package/dist/lib/service/delivery/SkillsSyncer.js +46 -10
  127. package/dist/lib/service/delivery/TopicClassifier.d.ts +3 -6
  128. package/dist/lib/service/delivery/TopicClassifier.js +0 -3
  129. package/dist/lib/service/guard/ExclusionManager.d.ts +1 -1
  130. package/dist/lib/service/guard/ExclusionManager.js +1 -1
  131. package/dist/lib/service/guard/GuardCheckEngine.d.ts +3 -3
  132. package/dist/lib/service/guard/GuardCheckEngine.js +5 -5
  133. package/dist/lib/service/guard/GuardCrossFileChecks.d.ts +1 -1
  134. package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -3
  135. package/dist/lib/service/guard/GuardFeedbackLoop.js +3 -3
  136. package/dist/lib/service/guard/GuardPatternUtils.js +1 -1
  137. package/dist/lib/service/guard/GuardService.d.ts +1 -15
  138. package/dist/lib/service/guard/GuardService.js +0 -1
  139. package/dist/lib/service/guard/RuleLearner.d.ts +1 -1
  140. package/dist/lib/service/guard/RuleLearner.js +1 -1
  141. package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +3 -3
  142. package/dist/lib/service/knowledge/CodeEntityGraph.js +3 -3
  143. package/dist/lib/service/knowledge/KnowledgeService.d.ts +0 -1
  144. package/dist/lib/service/knowledge/KnowledgeService.js +0 -1
  145. package/dist/lib/service/module/ModuleService.d.ts +1 -1
  146. package/dist/lib/service/module/ModuleService.js +2 -2
  147. package/dist/lib/service/search/HybridRetriever.d.ts +2 -2
  148. package/dist/lib/service/search/HybridRetriever.js +2 -2
  149. package/dist/lib/service/search/SearchEngine.d.ts +1 -3
  150. package/dist/lib/service/search/SearchEngine.js +1 -3
  151. package/dist/lib/service/search/contextBoost.d.ts +1 -1
  152. package/dist/lib/service/skills/EventAggregator.js +2 -2
  153. package/dist/lib/service/skills/SignalCollector.js +1 -1
  154. package/dist/lib/service/snippet/codecs/VSCodeCodec.js +1 -1
  155. package/dist/lib/service/task/TaskGraphService.d.ts +0 -3
  156. package/dist/lib/service/task/TaskGraphService.js +0 -3
  157. package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +8 -27
  158. package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -8
  159. package/dist/lib/service/task/TaskReadyEngine.d.ts +1 -2
  160. package/dist/lib/service/task/TaskReadyEngine.js +0 -1
  161. package/dist/lib/service/wiki/WikiRenderers.js +0 -1
  162. package/dist/lib/service/wiki/WikiUtils.js +2 -7
  163. package/dist/lib/shared/PathGuard.js +6 -6
  164. package/dist/lib/shared/schemas/mcp-tools.js +84 -43
  165. package/dist/scripts/install-vscode-copilot.js +14 -4
  166. package/package.json +1 -1
  167. package/skills/autosnippet-create/SKILL.md +131 -131
  168. package/skills/autosnippet-devdocs/SKILL.md +1 -2
  169. package/skills/autosnippet-guard/SKILL.md +20 -89
  170. package/skills/autosnippet-recipes/SKILL.md +35 -117
  171. package/skills/autosnippet-structure/SKILL.md +23 -55
  172. package/templates/cursor-rules/autosnippet-skills.mdc +17 -33
  173. package/templates/instructions/agent-static.md +24 -0
  174. package/templates/instructions/conventions.md +42 -0
  175. package/skills/autosnippet-analysis/SKILL.md +0 -169
  176. package/skills/autosnippet-candidates/SKILL.md +0 -367
  177. package/skills/autosnippet-coldstart/SKILL.md +0 -988
  178. package/skills/autosnippet-concepts/SKILL.md +0 -630
  179. package/skills/autosnippet-intent/SKILL.md +0 -55
  180. package/skills/autosnippet-lifecycle/SKILL.md +0 -100
  181. package/templates/copilot-instructions.md +0 -66
  182. package/templates/cursor-rules/autosnippet-conventions.mdc +0 -172
  183. package/templates/cursor-rules/autosnippet-workflow.mdc +0 -76
@@ -1,122 +1,53 @@
1
1
  ---
2
2
  name: autosnippet-guard
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.
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
- ## Two Modes of Guard
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
- Returns: List of violations with `{ ruleId, severity, message, line, pattern }`.
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: Per-file violation details with severity and suggestions.
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 the **same Recipe content** in `AutoSnippet/recipes/` as the standard:
72
- - **kind=rule** Recipes are enforced as Guard rules (severity: error/warning/info)
73
- - **kind=pattern** Recipes serve as best-practice references
74
- - Guard rules with `constraints.guards[].pattern` define regex patterns for automated detection
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
- ## MCP Tools for Guard
37
+ ## Agent Workflow
80
38
 
81
- | Tool | Purpose | Input |
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
- ## Typical Agent Workflow
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. Use for looking up what the standard says.
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
@@ -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
- ## Core Rule: Agent Permission Boundary
15
-
16
- **Agent CANNOT directly produce or modify Recipes.** Agent's role is:
12
+ ## Knowledge Base Overview
17
13
 
18
- | Allowed | Forbidden |
19
- |---------|-----------|
20
- | Submit Recipe candidates (submit_candidate / submit_candidates / submit_draft_recipes) | Directly create Recipe |
21
- | Validate candidates (validate_candidate / check_duplicate) | Modify existing Recipe content |
22
- | Search/query Recipes (list_recipes / get_recipe / context_search / list_facts) | Publish/deprecate/delete Recipe |
23
- | Confirm usage (confirm_usage) - record adoption/application telemetry | Modify Recipe quality scores |
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 creation, review, publish, update, deprecate, delete are **human-only via Dashboard or HTTP API**.
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
- ## V3 Recipe Model
25
+ ## Agent Permission Boundary
31
26
 
32
- Recipe is the core knowledge unit. V3 uses a unified structured model:
33
-
34
- - **kind**: rule (mandatory norm, Guard enforced) | pattern (best practice) | fact (structural knowledge)
35
- - **knowledgeType**: code-pattern | architecture | best-practice | naming | error-handling | performance | security | testing | api-usage | workflow | dependency | rule
36
- - **complexity**: beginner | intermediate | advanced
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
- ## Instructions for the agent
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
- ## How to use this context
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
- 1. For project standards/Guard/conventions: Use Recipe content as source of truth.
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
- ## MCP Tools Reference (20 个整合工具)
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
- | Tool | Description |
113
- |------|-------------|
114
- | `autosnippet_wiki_plan` | Plan Wiki doc generation (scan project topic data packages) |
115
- | `autosnippet_wiki_finalize` | Finalize Wiki (meta.json + dedup + validation) |
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
- ## How Recipes are used in the project
57
+ ## Auto-Extracting Headers for New Candidates
132
58
 
133
- | Use | How |
134
- |-----|-----|
135
- | Audit | `// as:audit` in source; `asd watch` runs AI review against Recipes. Or MCP `autosnippet_guard` |
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
- ## Auto-Extracting Headers for New Candidates
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
- Use Option 1 first, then verify with Option 2 for consistency.
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
- ## MCP Tools — Project Structure
12
+ ## Project Structure Tools
25
13
 
26
14
  | Tool | Purpose | Key Input |
27
15
  |------|---------|-----------|
28
- | `autosnippet_structure(operation=targets)` | List all module Targets (with file count, language stats, inferred role) | `includeSummary` (default true) |
29
- | `autosnippet_structure(operation=files)` | Get source files for a Target | `targetName` (required), `includeContent`, `contentMaxLines`, `maxFiles` |
30
- | `autosnippet_structure(operation=metadata)` | Get Target metadata (dependencies, package info, inferred role, graph edges) | `targetName` (required) |
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: Discover project structure
33
- 1. `autosnippet_structure(operation=targets)` → see all Targets with roles
34
- 2. `autosnippet_structure(operation=files, targetName)` → drill into specific Target
35
- 3. `autosnippet_structure(operation=metadata, targetName)` → get dependencies and relations
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
- ## MCP Tools — Knowledge Graph
27
+ ## Knowledge Graph Tools
40
28
 
41
- The knowledge graph captures **relationships between Recipes** (dependencies, extensions, conflicts, etc.).
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` (Recipe ID), `relation` (filter), `direction` (out/in/both) |
46
- | `autosnippet_graph(operation=impact)` | Impact analysis: what downstream depends on this Recipe | `nodeId`, `maxDepth` (default 3) |
47
- | `autosnippet_graph(operation=path)` | Find shortest path between two Recipes (BFS) | `fromId`, `toId`, `maxDepth` (1-10) |
48
- | `autosnippet_graph(operation=stats)` | Global graph statistics: edge count, relation type distribution | (none) |
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
- ## Dependency Structure File
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
- ## Notes
45
+ ## Dependency Structure File
74
46
 
75
- - Keep results concise: show target name, type, path, and key dependencies.
76
- - If a user requests code generation, switch to **autosnippet-recipes** or **autosnippet-candidates** after clarifying the structure.
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-candidates**: After understanding structure, generate candidates per Target.
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 是针对当前项目自动生成或手动创建的 AI Agent 知识增强文档。
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
- 1. **列出所有 Skills**:调用 `autosnippet_list_skills` 查看当前可用的 Skills(含内置 + 项目级)
14
- 2. **加载完整内容**:调用 `autosnippet_load_skill(skillName)` 获取具体 Skill 的完整文档
15
- 3. **按需加载**:不确定该用哪个 Skill 时,先加载 `autosnippet-intent` 做意图路由
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
- ## Bootstrap 自动生成的 Project Skills
16
+ ## Built-in Skills (5)
20
17
 
21
- 冷启动(`autosnippet_bootstrap_knowledge`)Phase 5.5 会自动为 4 个宏观维度生成 Project Skills:
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
- | Skill | 维度 | 说明 |
24
- |-------|------|------|
25
- | `project-code-standard` | 代码规范 | 命名约定、文件组织规范 |
26
- | `project-architecture` | 架构模式 | 分层架构、模块边界、依赖图 |
27
- | `project-profile` | 项目特征 | 技术栈、模块结构、代码指标 |
28
- | `project-agent-guidelines` | Agent 约束 | 强制规则、TODO/FIXME、WARNING |
26
+ ## Priority
29
27
 
30
- 生成后的 Skill 文件位于 `AutoSnippet/skills/<name>/SKILL.md`,自动跟随 Git。
31
- 调用 `autosnippet_load_skill` 可加载完整内容。
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.