autosnippet 2.9.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +12 -12
  2. package/bin/cli.js +53 -40
  3. package/config/constitution.yaml +9 -2
  4. package/dashboard/dist/assets/{icons-CH-H9x0E.js → icons-D4IWpDIk.js} +105 -100
  5. package/dashboard/dist/assets/index-CWBNcF9z.css +1 -0
  6. package/dashboard/dist/assets/index-DHtzhbuG.js +120 -0
  7. package/dashboard/dist/index.html +3 -3
  8. package/lib/cli/AiScanService.js +35 -36
  9. package/lib/cli/KnowledgeSyncService.js +345 -0
  10. package/lib/cli/SetupService.js +8 -26
  11. package/lib/cli/UpgradeService.js +28 -0
  12. package/lib/core/gateway/GatewayActionRegistry.js +48 -58
  13. package/lib/domain/index.js +16 -11
  14. package/lib/domain/knowledge/KnowledgeEntry.js +289 -0
  15. package/lib/domain/knowledge/KnowledgeRepository.js +123 -0
  16. package/lib/domain/knowledge/Lifecycle.js +99 -0
  17. package/lib/domain/knowledge/index.js +27 -0
  18. package/lib/domain/knowledge/values/Constraints.js +128 -0
  19. package/lib/domain/knowledge/values/Content.js +69 -0
  20. package/lib/domain/knowledge/values/Quality.js +81 -0
  21. package/lib/domain/knowledge/values/Reasoning.js +70 -0
  22. package/lib/domain/knowledge/values/Relations.js +142 -0
  23. package/lib/domain/knowledge/values/Stats.js +72 -0
  24. package/lib/domain/knowledge/values/index.js +9 -0
  25. package/lib/external/ai/AiProvider.js +85 -11
  26. package/lib/external/mcp/McpServer.js +7 -5
  27. package/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +18 -2
  28. package/lib/external/mcp/handlers/bootstrap.js +116 -11
  29. package/lib/external/mcp/handlers/browse.js +76 -73
  30. package/lib/external/mcp/handlers/candidate.js +26 -275
  31. package/lib/external/mcp/handlers/guard.js +2 -0
  32. package/lib/external/mcp/handlers/knowledge.js +267 -0
  33. package/lib/external/mcp/handlers/structure.js +25 -23
  34. package/lib/external/mcp/handlers/system.js +10 -12
  35. package/lib/external/mcp/tools.js +134 -140
  36. package/lib/http/HttpServer.js +14 -8
  37. package/lib/http/routes/ai.js +4 -3
  38. package/lib/http/routes/extract.js +48 -4
  39. package/lib/http/routes/knowledge.js +246 -0
  40. package/lib/http/routes/search.js +12 -17
  41. package/lib/infrastructure/database/migrations/016_unified_knowledge_entries.js +395 -0
  42. package/lib/infrastructure/database/migrations/017_camelcase_knowledge_entries.js +107 -0
  43. package/lib/infrastructure/external/XcodeAutomation.js +187 -103
  44. package/lib/injection/ServiceContainer.js +69 -60
  45. package/lib/repository/knowledge/KnowledgeRepository.impl.js +338 -0
  46. package/lib/service/automation/DirectiveDetector.js +2 -3
  47. package/lib/service/automation/FileWatcher.js +59 -28
  48. package/lib/service/automation/XcodeIntegration.js +931 -156
  49. package/lib/service/automation/handlers/AlinkHandler.js +5 -4
  50. package/lib/service/automation/handlers/CreateHandler.js +53 -19
  51. package/lib/service/automation/handlers/DraftHandler.js +1 -1
  52. package/lib/service/automation/handlers/GuardHandler.js +183 -20
  53. package/lib/service/automation/handlers/SearchHandler.js +25 -22
  54. package/lib/service/candidate/SimilarityService.js +2 -2
  55. package/lib/service/chat/AnalystAgent.js +9 -0
  56. package/lib/service/chat/CandidateGuardrail.js +22 -11
  57. package/lib/service/chat/ChatAgent.js +132 -54
  58. package/lib/service/chat/ContextWindow.js +5 -5
  59. package/lib/service/chat/HandoffProtocol.js +1 -0
  60. package/lib/service/chat/ProducerAgent.js +40 -13
  61. package/lib/service/chat/ReasoningLayer.js +854 -0
  62. package/lib/service/chat/ReasoningTrace.js +329 -0
  63. package/lib/service/chat/tools.js +308 -205
  64. package/lib/service/cursor/CursorDeliveryPipeline.js +279 -0
  65. package/lib/service/cursor/KnowledgeCompressor.js +87 -0
  66. package/lib/service/cursor/RulesGenerator.js +168 -0
  67. package/lib/service/cursor/SkillsSyncer.js +268 -0
  68. package/lib/service/cursor/TokenBudget.js +58 -0
  69. package/lib/service/cursor/TopicClassifier.js +141 -0
  70. package/lib/service/guard/GuardCheckEngine.js +99 -10
  71. package/lib/service/guard/GuardService.js +57 -46
  72. package/lib/service/knowledge/ConfidenceRouter.js +159 -0
  73. package/lib/service/knowledge/KnowledgeFileWriter.js +595 -0
  74. package/lib/service/knowledge/KnowledgeService.js +802 -0
  75. package/lib/service/recipe/RecipeParser.js +3 -12
  76. package/lib/service/search/SearchEngine.js +67 -22
  77. package/lib/service/skills/SignalCollector.js +14 -9
  78. package/lib/service/skills/SkillAdvisor.js +13 -11
  79. package/lib/service/snippet/SnippetFactory.js +5 -5
  80. package/lib/service/spm/SpmService.js +15 -48
  81. package/lib/shared/RecipeReadinessChecker.js +6 -11
  82. package/package.json +1 -1
  83. package/scripts/install-cursor-skill.js +0 -6
  84. package/scripts/migrate-md-to-knowledge.mjs +364 -0
  85. package/skills/autosnippet-analysis/SKILL.md +15 -7
  86. package/skills/autosnippet-candidates/SKILL.md +8 -8
  87. package/skills/autosnippet-coldstart/SKILL.md +8 -4
  88. package/skills/autosnippet-concepts/SKILL.md +7 -6
  89. package/skills/autosnippet-create/SKILL.md +13 -13
  90. package/skills/autosnippet-intent/SKILL.md +3 -2
  91. package/skills/autosnippet-lifecycle/SKILL.md +5 -5
  92. package/skills/autosnippet-recipes/SKILL.md +18 -6
  93. package/templates/constitution.yaml +1 -1
  94. package/templates/copilot-instructions.md +6 -6
  95. package/templates/recipes-setup/README.md +3 -3
  96. package/dashboard/dist/assets/index-CqJRvYRL.js +0 -197
  97. package/dashboard/dist/assets/index-DICm9PNa.css +0 -1
  98. package/lib/cli/CandidateSyncService.js +0 -261
  99. package/lib/cli/SyncService.js +0 -356
  100. package/lib/domain/candidate/Candidate.js +0 -196
  101. package/lib/domain/candidate/CandidateRepository.js +0 -107
  102. package/lib/domain/candidate/Reasoning.js +0 -52
  103. package/lib/domain/recipe/Recipe.js +0 -421
  104. package/lib/domain/recipe/RecipeRepository.js +0 -54
  105. package/lib/domain/types/CandidateStatus.js +0 -52
  106. package/lib/http/routes/candidates.js +0 -559
  107. package/lib/http/routes/recipes.js +0 -397
  108. package/lib/repository/candidate/CandidateRepository.impl.js +0 -230
  109. package/lib/repository/recipe/RecipeRepository.impl.js +0 -498
  110. package/lib/service/candidate/CandidateAggregator.js +0 -52
  111. package/lib/service/candidate/CandidateFileWriter.js +0 -383
  112. package/lib/service/candidate/CandidateService.js +0 -1001
  113. package/lib/service/recipe/RecipeFileWriter.js +0 -514
  114. package/lib/service/recipe/RecipeService.js +0 -786
  115. package/lib/service/recipe/RecipeStatsTracker.js +0 -148
@@ -37,9 +37,9 @@ This skill documents the Recipe lifecycle and clarifies what Agent can and canno
37
37
  ## Agent Role: What You CAN Do
38
38
 
39
39
  ### 1. Submit Candidates
40
- - `autosnippet_submit_candidate` - single structured candidate
41
- - `autosnippet_submit_candidates` - batch structured candidates
42
- - `autosnippet_submit_draft_recipes` - submit .md files as candidates
40
+ - `autosnippet_submit_knowledge` - single structured candidate
41
+ - `autosnippet_submit_knowledge_batch` - batch structured candidates
42
+ - `autosnippet_submit_knowledge_batch` - submit .md files as candidates
43
43
 
44
44
  ### 2. Validate and Enhance Candidates
45
45
  - `autosnippet_validate_candidate` - pre-validate quality
@@ -81,7 +81,7 @@ This skill documents the Recipe lifecycle and clarifies what Agent can and canno
81
81
  2. Generate structured candidate with rationale, steps, etc.
82
82
  3. `autosnippet_check_duplicate` - verify no duplicate exists
83
83
  4. `autosnippet_validate_candidate` - pre-validate quality
84
- 5. `autosnippet_submit_candidate` - submit to candidate pool
84
+ 5. `autosnippet_submit_knowledge` - submit to candidate pool
85
85
  6. Tell user: "Candidate submitted. Review in Dashboard Candidates page."
86
86
 
87
87
  ### Workflow 2: User asks about an existing Recipe
@@ -94,7 +94,7 @@ This skill documents the Recipe lifecycle and clarifies what Agent can and canno
94
94
  1. Explain: "I cannot modify Recipes directly. I can submit an improved version as a new candidate."
95
95
  2. `autosnippet_get_recipe` to read current content
96
96
  3. Generate improved candidate based on user's feedback
97
- 4. `autosnippet_submit_candidate` - submit improved version
97
+ 4. `autosnippet_submit_knowledge` - submit improved version
98
98
  5. Tell user: "Improved version submitted as candidate. Update the Recipe in Dashboard."
99
99
 
100
100
  ---
@@ -27,9 +27,9 @@ Recipe creation, review, publish, update, deprecate, delete are **human-only via
27
27
 
28
28
  ---
29
29
 
30
- ## V2 Recipe Model
30
+ ## V3 Recipe Model
31
31
 
32
- Recipe is the core knowledge unit. V2 uses a unified structured model:
32
+ Recipe is the core knowledge unit. V3 uses a unified structured model:
33
33
 
34
34
  - **kind**: rule (mandatory norm, Guard enforced) | pattern (best practice) | fact (structural knowledge)
35
35
  - **knowledgeType**: code-pattern | architecture | best-practice | naming | error-handling | performance | security | testing | api-usage | workflow | dependency | rule
@@ -78,7 +78,7 @@ Recipe is the core knowledge unit. V2 uses a unified structured model:
78
78
 
79
79
  ---
80
80
 
81
- ## MCP Tools Reference (31 tools)
81
+ ## MCP Tools Reference (38 tools)
82
82
 
83
83
  ### Query (Agent can freely use)
84
84
 
@@ -109,9 +109,9 @@ Recipe is the core knowledge unit. V2 uses a unified structured model:
109
109
 
110
110
  | Tool | Description |
111
111
  |------|-------------|
112
- | autosnippet_submit_candidate | Submit single candidate (supports structured content) |
113
- | autosnippet_submit_candidates | Batch submit candidates |
114
- | autosnippet_submit_draft_recipes | Submit draft .md files as candidates |
112
+ | autosnippet_submit_knowledge | Submit single candidate (supports structured content) |
113
+ | autosnippet_submit_knowledge_batch | Batch submit candidates |
114
+ | autosnippet_submit_knowledge_batch | Submit draft .md files as candidates |
115
115
  | autosnippet_validate_candidate | Validate candidate quality |
116
116
  | autosnippet_check_duplicate | Dedup check |
117
117
  | autosnippet_enrich_candidates | AI semantic field enrichment for candidates |
@@ -124,6 +124,18 @@ Recipe is the core knowledge unit. V2 uses a unified structured model:
124
124
  | autosnippet_guard_audit_files | Multi-file batch Guard audit |
125
125
  | autosnippet_scan_project | Lightweight project scan + Guard audit |
126
126
  | autosnippet_bootstrap_knowledge | Cold-start knowledge base initialization (9 dimensions) |
127
+ | autosnippet_bootstrap_refine | AI refinement of bootstrap candidates (Phase 6) |
128
+
129
+ ### Skills Management
130
+
131
+ | Tool | Description |
132
+ |------|-------------|
133
+ | autosnippet_list_skills | List all available Agent Skills |
134
+ | autosnippet_load_skill | Load Skill document for domain guidance |
135
+ | autosnippet_create_skill | Create project-level Skill |
136
+ | autosnippet_update_skill | Update project-level Skill |
137
+ | autosnippet_delete_skill | Delete project-level Skill |
138
+ | autosnippet_suggest_skills | AI-powered Skill creation suggestions |
127
139
 
128
140
  ### Usage Telemetry
129
141
 
@@ -48,7 +48,7 @@ roles:
48
48
  - "read:recipes"
49
49
  - "read:guard_rules"
50
50
  - "create:candidates"
51
- - "submit:candidates"
51
+ - "submit:knowledge"
52
52
  - "read:audit_logs:self"
53
53
  - "knowledge:bootstrap"
54
54
  - "create:skills"
@@ -23,7 +23,7 @@
23
23
 
24
24
  ## 强制规则(必须遵守)
25
25
  1. **禁止直接修改** 知识库目录内容(`AutoSnippet/recipes/`、`.autosnippet/` 等)。
26
- 2. 创建或入库必须走 **Dashboard** 或 MCP 工具流程(`autosnippet_submit_candidate`、`autosnippet_submit_candidates`)。
26
+ 2. 创建或入库必须走 **Dashboard** 或 MCP 工具流程(`autosnippet_submit_knowledge`、`autosnippet_submit_knowledge_batch`)。
27
27
  3. **优先使用 Recipe** 作为项目标准;源代码仅作补充。
28
28
  4. MCP 检索优先:使用 `autosnippet_search` 或 `autosnippet_context_search` 获取语义检索结果。
29
29
  5. MCP 调用失败时,**不要在同一轮重复重试**,回退到已读文档或静态上下文。
@@ -47,9 +47,9 @@
47
47
  ### 候选提交 & 校验
48
48
  - `autosnippet_validate_candidate` — 提交前预校验(5 层)
49
49
  - `autosnippet_check_duplicate` — 相似度检测
50
- - `autosnippet_submit_candidate` — 单条提交(reasoning 必填)
51
- - `autosnippet_submit_candidates` — 批量提交(含去重 + 限流)
52
- - `autosnippet_submit_draft_recipes` — 解析草稿 Markdown 文件
50
+ - `autosnippet_submit_knowledge` — 单条提交(reasoning 必填)
51
+ - `autosnippet_submit_knowledge_batch` — 批量提交(含去重 + 限流)
52
+ - `autosnippet_submit_knowledge_batch` — 解析草稿 Markdown 文件
53
53
  - `autosnippet_enrich_candidates` — AI 补全缺失语义字段
54
54
 
55
55
  ### 项目扫描 & 冷启动
@@ -85,8 +85,8 @@
85
85
 
86
86
  ## 推荐工作流
87
87
  - **查找**:`autosnippet_search`(推荐)或 `autosnippet_context_search`(上下文感知)。
88
- - **产出候选**:`autosnippet_validate_candidate` 预校验 → `autosnippet_submit_candidate` 提交。
89
- - **冷启动**:`autosnippet_bootstrap_knowledge` → `autosnippet_enrich_candidates` → `autosnippet_bootstrap_refine` → 逐 Target 深入 → `autosnippet_submit_candidates`。
88
+ - **产出候选**:`autosnippet_validate_candidate` 预校验 → `autosnippet_submit_knowledge` 提交。
89
+ - **冷启动**:`autosnippet_bootstrap_knowledge` → `autosnippet_enrich_candidates` → `autosnippet_bootstrap_refine` → 逐 Target 深入 → `autosnippet_submit_knowledge_batch`。
90
90
  - **Skills 创建**:`autosnippet_suggest_skills` 分析 → `autosnippet_create_skill` 固化知识。
91
91
  - **采纳反馈**:`autosnippet_confirm_usage`(记录使用量影响排序权重)。
92
92
 
@@ -160,9 +160,9 @@ V2 知识库中的 Recipe 按 `knowledgeType` 自动归入三类 kind,影响
160
160
  | `autosnippet_search` | 统合搜索(BM25 + 语义融合) |
161
161
  | `autosnippet_context_search` | 智能上下文检索 |
162
162
  | `autosnippet_validate_candidate` | 候选结构化预校验 |
163
- | `autosnippet_submit_candidate` | 单条候选提交(reasoning 必填) |
164
- | `autosnippet_submit_candidates` | 批量候选提交 |
165
- | `autosnippet_submit_draft_recipes` | 解析草稿 Markdown 为候选 |
163
+ | `autosnippet_submit_knowledge` | 单条候选提交(reasoning 必填) |
164
+ | `autosnippet_submit_knowledge_batch` | 批量候选提交 |
165
+ | `autosnippet_submit_knowledge_batch` | 解析草稿 Markdown 为候选 |
166
166
  | `autosnippet_confirm_usage` | 确认 Recipe 被采纳/应用 |
167
167
  | `autosnippet_recipe_insights` | 获取 Recipe 质量洞察(只读) |
168
168