autosnippet 3.3.2 → 3.3.3

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 (51) hide show
  1. package/dist/bin/cli.js +27 -1
  2. package/dist/lib/cli/KnowledgeSyncService.d.ts +26 -0
  3. package/dist/lib/cli/KnowledgeSyncService.js +33 -1
  4. package/dist/lib/external/mcp/handlers/browse.d.ts +1 -0
  5. package/dist/lib/external/mcp/handlers/browse.js +2 -1
  6. package/dist/lib/external/mcp/handlers/consolidated.d.ts +1 -0
  7. package/dist/lib/external/mcp/handlers/panorama.d.ts +11 -11
  8. package/dist/lib/external/mcp/handlers/panorama.js +20 -20
  9. package/dist/lib/external/mcp/handlers/system.d.ts +1 -1
  10. package/dist/lib/external/mcp/handlers/task.js +2 -1
  11. package/dist/lib/external/mcp/tools.d.ts +12 -12
  12. package/dist/lib/external/mcp/tools.js +120 -118
  13. package/dist/lib/http/middleware/validate.js +7 -3
  14. package/dist/lib/infrastructure/database/drizzle/schema.d.ts +100 -0
  15. package/dist/lib/infrastructure/database/drizzle/schema.js +10 -0
  16. package/dist/lib/infrastructure/database/migrations/005_recipe_source_refs.d.ts +9 -0
  17. package/dist/lib/infrastructure/database/migrations/005_recipe_source_refs.js +24 -0
  18. package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +18 -2
  19. package/dist/lib/injection/ServiceContainer.js +2 -0
  20. package/dist/lib/injection/modules/KnowledgeModule.d.ts +5 -0
  21. package/dist/lib/injection/modules/KnowledgeModule.js +80 -0
  22. package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +45 -0
  23. package/dist/lib/service/bootstrap/UiStartupTasks.js +101 -0
  24. package/dist/lib/service/evolution/ConsolidationAdvisor.js +9 -9
  25. package/dist/lib/service/evolution/ContradictionDetector.js +2 -2
  26. package/dist/lib/service/evolution/RedundancyAnalyzer.js +2 -2
  27. package/dist/lib/service/knowledge/SourceRefReconciler.d.ts +68 -0
  28. package/dist/lib/service/knowledge/SourceRefReconciler.js +309 -0
  29. package/dist/lib/service/panorama/PanoramaService.d.ts +18 -1
  30. package/dist/lib/service/panorama/PanoramaService.js +148 -5
  31. package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
  32. package/dist/lib/service/search/CoarseRanker.d.ts +7 -6
  33. package/dist/lib/service/search/CoarseRanker.js +11 -10
  34. package/dist/lib/service/search/FieldWeightedScorer.d.ts +81 -0
  35. package/dist/lib/service/search/FieldWeightedScorer.js +318 -0
  36. package/dist/lib/service/search/MultiSignalRanker.d.ts +2 -2
  37. package/dist/lib/service/search/MultiSignalRanker.js +1 -1
  38. package/dist/lib/service/search/SearchEngine.d.ts +8 -7
  39. package/dist/lib/service/search/SearchEngine.js +59 -10
  40. package/dist/lib/service/search/SearchTypes.d.ts +23 -3
  41. package/dist/lib/service/search/SearchTypes.js +6 -1
  42. package/dist/lib/service/task/IntentExtractor.d.ts +8 -0
  43. package/dist/lib/service/task/IntentExtractor.js +115 -1
  44. package/dist/lib/service/task/PrimeSearchPipeline.js +39 -24
  45. package/dist/lib/service/vector/VectorService.d.ts +3 -0
  46. package/dist/lib/service/vector/VectorService.js +38 -4
  47. package/package.json +1 -1
  48. package/skills/autosnippet-create/SKILL.md +98 -89
  49. package/skills/autosnippet-devdocs/SKILL.md +55 -60
  50. package/templates/guard-ci.yml +2 -2
  51. package/templates/recipes-setup/_template.md +39 -39
@@ -1,92 +1,87 @@
1
1
  ---
2
2
  name: autosnippet-devdocs
3
- description: Teaches the agent how to save development documents (architecture decisions, debug reports, design docs, research notes) to the AutoSnippet knowledge base using autosnippet_submit_knowledge with knowledgeType 'dev-document'. Use when the agent finishes analysis, debugging, design, or research and wants to persist the findings.
3
+ description: Generate and publish project Wiki documentation using autosnippet_wiki MCP tool (plan write finalize). Use when user says "generate wiki/docs", "write documentation", or agent needs to produce structured project documentation from the knowledge base.
4
4
  ---
5
5
 
6
- # AutoSnippet — Save Development Documents
6
+ # AutoSnippet — Wiki Documentation Generation
7
7
 
8
- This skill tells the agent how to **save development documents** (architecture decisions, debug reports, design docs, research notes) to the AutoSnippet knowledge base, so they can be retrieved by future sessions.
8
+ This skill guides the agent through generating structured **Wiki documentation** from the AutoSnippet knowledge base using the `autosnippet_wiki` MCP tool.
9
9
 
10
10
  ## When to use this skill
11
11
 
12
- - After finishing a **debug/troubleshooting session** save the root cause analysis
13
- - After making an **architecture or design decision** save the ADR (Architecture Decision Record)
14
- - After completing a **research or investigation** save findings and conclusions
15
- - After a **performance analysis** — save the benchmark results and optimization notes
16
- - When the user says "保存这个分析" / "记录一下" / "save this to KB"
12
+ - User asks to **generate project documentation** or **wiki**
13
+ - After a **cold-start bootstrap** completesproduce docs from newly captured knowledge
14
+ - When the user says "generate docs" / "write wiki" / "create documentation"
15
+ - After significant **knowledge base changes** — refresh documentation
17
16
 
18
- ## MCP Tool
17
+ ## MCP Tools
19
18
 
20
- | Tool | Description |
21
- |------|-------------|
22
- | `autosnippet_submit_knowledge` | Unified knowledge submission. For documents, set item `knowledgeType: 'dev-document'` only needs `title` + `markdown`. Auto-published, no review needed. |
23
- | `autosnippet_search` | Search saved documents by keyword or semantic query. |
19
+ | Tool | Operation | Description |
20
+ |------|-----------|-------------|
21
+ | `autosnippet_wiki` | `plan` | Plan topics + data packages (returns topic list + per-topic data for writing) |
22
+ | `autosnippet_wiki` | `finalize` | Complete generation (write meta.json, dedup check, validate completeness) |
23
+ | `autosnippet_search` | — | Search knowledge for additional context during writing |
24
+ | `autosnippet_knowledge` | `get` | Retrieve full Recipe content for reference |
24
25
 
25
- ## How to save a document
26
+ ## Workflow
26
27
 
27
- Call `autosnippet_submit_knowledge` with an `items` array containing one document entry:
28
+ ### Step 1: Plan topics
28
29
 
29
30
  ```json
30
31
  {
31
- "items": [{
32
- "title": "BiliDemo 冷启动性能分析",
33
- "markdown": "## 问题背景\n\n冷启动耗时 8s...\n\n## 根因分析\n\n...\n\n## 解决方案\n\n...",
34
- "knowledgeType": "dev-document",
35
- "description": "冷启动耗时 8s 的根因分析和优化方案",
36
- "tags": ["debug-report", "performance"],
37
- "scope": "project-specific"
38
- }]
32
+ "operation": "plan",
33
+ "language": "en"
39
34
  }
40
35
  ```
41
36
 
42
- ### Required fields
37
+ Returns:
38
+ - **topics[]** — Recommended documentation topics based on knowledge base content
39
+ - **dataPackages** — Per-topic data bundles (related Recipes, code patterns, architecture info)
40
+ - **sessionId** — Session identifier for the finalize step
43
41
 
44
- | Field | Description |
45
- |-------|-------------|
46
- | `title` | Document title (Chinese or English) |
47
- | `markdown` | Full Markdown content |
48
-
49
- ### Optional fields
50
-
51
- | Field | Default | Description |
52
- |-------|---------|-------------|
53
- | `description` | `""` | One-line summary |
54
- | `tags` | `[]` | Labels for filtering: `adr`, `debug-report`, `design-doc`, `research`, `performance`, `refactoring` |
55
- | `scope` | `project-specific` | `universal` or `project-specific` |
42
+ ### Step 2: Write articles
56
43
 
57
- ## Recommended tags
44
+ For each topic in the plan:
45
+ 1. Read the **dataPackage** for that topic
46
+ 2. Write a well-structured Markdown article to the wiki directory (`AutoSnippet/wiki/`)
47
+ 3. Use Recipe content as source of truth — cite Recipe titles
48
+ 4. Follow the structure: Overview → Details → Code Examples → Related Topics
58
49
 
59
- | Tag | Use case |
60
- |-----|----------|
61
- | `adr` | Architecture Decision Record |
62
- | `debug-report` | Bug investigation / root cause analysis |
63
- | `design-doc` | Module/feature design document |
64
- | `research` | Technology research or investigation |
65
- | `performance` | Benchmark results, profiling analysis |
66
- | `refactoring` | Refactoring plan or post-mortem |
67
- | `migration` | Migration guide or plan |
68
- | `meeting-notes` | Technical meeting summary |
50
+ ### Step 3: Finalize
69
51
 
70
- ## How documents are delivered to Cursor
71
-
72
- Documents are stored as `knowledgeType: 'dev-document'` in the knowledge DB. They follow a dedicated delivery path:
52
+ ```json
53
+ {
54
+ "operation": "finalize",
55
+ "sessionId": "<from plan>",
56
+ "articlesWritten": ["AutoSnippet/wiki/topic-1.md", "AutoSnippet/wiki/topic-2.md"]
57
+ }
58
+ ```
73
59
 
74
- 1. **NOT compressed** into Cursor Rules (Channel A/B skip dev-documents)
75
- 2. **Full text** written to `.cursor/skills/autosnippet-devdocs/references/*.md` (Channel D)
76
- 3. **Searchable** via `autosnippet_search("your query")` full-text search hits documents
60
+ This triggers:
61
+ - **meta.json** generation topic index with cross-references
62
+ - **Dedup check** — detect overlapping articles
63
+ - **Completeness validation** — ensure all planned topics are covered
77
64
 
78
- ## Document format tips
65
+ ## Writing guidelines
79
66
 
80
67
  - Use **clear headings** (`##`, `###`) — helps search and scanning
81
- - Include a **summary section** at the top
68
+ - Include a **summary section** at the top of each article
82
69
  - Reference **file paths** and **class names** concretely — improves search relevance
83
- - For ADRs, use the structure: Context Decision → Consequences
84
- - For debug reports: SymptomInvestigationRoot Cause Fix
70
+ - Cite **Recipe triggers** (e.g., `@bilidili-feature-url-routing`) as knowledge sources
71
+ - For architecture docs: ContextDesignImplementationTrade-offs
72
+ - For pattern docs: When to Use → How to Use → Code Example → Anti-patterns
73
+
74
+ ## Language parameter
75
+
76
+ | Value | Effect |
77
+ |-------|--------|
78
+ | `"en"` | English documentation (default) |
79
+ | `"zh"` | Chinese documentation |
85
80
 
86
81
  ## Related Skills
87
82
 
88
83
  | Skill | When to use |
89
84
  |-------|-------------|
90
- | `autosnippet-create` | Saving **code patterns/recipes** (needs trigger, doClause, etc.) |
91
- | `autosnippet-devdocs` (this) | Saving **prose documents** (only needs title + markdown) |
92
- | `autosnippet-recipes` | Looking up existing knowledge |
85
+ | `autosnippet-create` | Submitting **code patterns/recipes** to KB (not documents) |
86
+ | `autosnippet-devdocs` (this) | Generating **Wiki documentation** from KB |
87
+ | `autosnippet-recipes` | Looking up existing knowledge for reference |
@@ -1,8 +1,8 @@
1
1
  # AutoSnippet Guard CI/CD Check
2
2
  # Auto-generated by AutoSnippet. Do not edit manually.
3
- # push PR 时自动运行 Guard 合规检查
3
+ # Automatically runs Guard compliance checks on push and PR.
4
4
  #
5
- # 使用方法:将此文件复制到项目的 .github/workflows/ 目录
5
+ # Usage: Copy this file to your project's .github/workflows/ directory.
6
6
 
7
7
  name: AutoSnippet Guard Check
8
8
 
@@ -1,42 +1,42 @@
1
1
  ---
2
- # 必填字段
2
+ # Required Fields
3
3
  title: Your Recipe Title Here (English, ≤50 chars, verb-based)
4
4
  trigger: @my_trigger
5
5
  category: Network # MUST be one of: View, Service, Tool, Model, Network, Storage, UI, Utility
6
6
  language: swift # swift, objectivec, go, python, java, kotlin, javascript, typescript, dart, rust
7
- summary_cn: 中文概述,≤100 字,描述该 Recipe 的用途
7
+ summary_cn: Chinese summary, ≤100 chars
8
8
  summary_en: English summary, ≤100 words
9
- headers: ["import Foundation"] # 完整 import 语句数组
9
+ headers: ["import Foundation"] # Complete import statement array
10
10
  knowledgeType: code-pattern # code-pattern, architecture, best-practice, code-standard, code-style, code-relation, data-flow, event-and-data-flow, module-dependency, boundary-constraint, solution, anti-pattern
11
11
 
12
- # V3 Cursor Delivery 必填字段
13
- kind: pattern # rule = 强制约束 | pattern = 可复用模式 | fact = 项目事实
14
- doClause: "Use dependency injection via constructor" # 英文祈使句,以动词开头,≤60 tokens
15
- dontClause: "Don't instantiate services with new directly" # 英文反向约束
16
- whenClause: "When creating a new service class" # 英文触发场景
12
+ # V3 Cursor Delivery Required Fields
13
+ kind: pattern # rule = mandatory constraint | pattern = reusable pattern | fact = project fact
14
+ doClause: "Use dependency injection via constructor" # English imperative, verb-first, ≤60 tokens
15
+ dontClause: "Don't instantiate services with new directly" # English negative constraint
16
+ whenClause: "When creating a new service class" # English trigger scenario
17
17
  coreCode: |
18
18
  class MyService {
19
19
  constructor(private db: Database) {}
20
20
  }
21
21
  usageGuide: |
22
- ### 何时使用
23
- 创建新 Service 类时
24
- ### 规范
25
- 统一使用构造器注入
22
+ ### When to Use
23
+ When creating a new Service class
24
+ ### Convention
25
+ Always use constructor injection
26
26
 
27
- # 可选字段(推荐)
28
- keywords: ["关键词1", "关键词2", "关键词3"]
27
+ # Optional Fields (recommended)
28
+ keywords: ["keyword1", "keyword2", "keyword3"]
29
29
  tags: [tag1, tag2]
30
30
  whenToUse: |
31
- - 适用场景 1
32
- - 适用场景 2
33
- - 适用场景 3
31
+ - Applicable scenario 1
32
+ - Applicable scenario 2
33
+ - Applicable scenario 3
34
34
  whenNotToUse: |
35
- - 不应使用的场景 1
36
- - 不应使用的场景 2
35
+ - Scenario to avoid 1
36
+ - Scenario to avoid 2
37
37
  difficulty: beginner # beginner, intermediate, advanced
38
38
  authority: 1 # 1~5
39
- relatedRecipes: ["@相关Recipe的trigger"]
39
+ relatedRecipes: ["@related_recipe_trigger"]
40
40
  version: "1.0.0"
41
41
  updatedAt: 1706515200
42
42
  author: team_name
@@ -46,38 +46,38 @@ deprecated: false
46
46
  ## Snippet / Code Reference
47
47
 
48
48
  ```
49
- // 在此粘贴或编写代码片段(建议可运行、含必要错误处理与注释)
49
+ // Paste or write code snippet here (ideally runnable, with error handling and comments)
50
50
  ```
51
51
 
52
52
  ## AI Context / Usage Guide
53
53
 
54
- ### 什么时候用
54
+ ### When to Use
55
55
 
56
- - 适用场景说明
57
- - 典型业务或技术情境
58
- - 典型使用者角色
56
+ - Applicable scenario description
57
+ - Typical business or technical context
58
+ - Typical user role
59
59
 
60
- ### 何时不用
60
+ ### When Not to Use
61
61
 
62
- - 排除场景、易误用情况
63
- - 何时应用替代方案
62
+ - Exclusion scenarios, easy-to-misuse cases
63
+ - When to apply alternatives
64
64
 
65
- ### 使用步骤
65
+ ### Steps
66
66
 
67
- 1. 第一步:准备或前置条件
68
- 2. 第二步:主体逻辑
69
- 3. 第三步:结果处理或后续
67
+ 1. Step 1: Preparation or prerequisites
68
+ 2. Step 2: Core logic
69
+ 3. Step 3: Result handling or follow-up
70
70
 
71
- ### 关键点
71
+ ### Key Points
72
72
 
73
- - 易错点、容易忽略的细节
74
- - 线程/内存/生命周期约束
75
- - 性能特征或限制
73
+ - Error-prone areas, easily overlooked details
74
+ - Thread/memory/lifecycle constraints
75
+ - Performance characteristics or limitations
76
76
 
77
- ### 依赖与前置条件
77
+ ### Dependencies & Prerequisites
78
78
 
79
- - 需导入的模块/框架
80
- - 最低系统/API 版本
79
+ - Required modules/frameworks to import
80
+ - Minimum system/API version
81
81
  - 权限、配置或环境要求
82
82
 
83
83
  ### 错误处理