autosnippet 2.0.1 → 2.1.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 (47) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.js +65 -1
  3. package/dashboard/dist/assets/{icons-BwUGzNFH.js → icons-B5rs8uNb.js} +121 -81
  4. package/dashboard/dist/assets/index-0YzLw2ga.css +1 -0
  5. package/dashboard/dist/assets/index-DbkbX1c-.js +154 -0
  6. package/dashboard/dist/index.html +3 -3
  7. package/lib/cli/AiScanService.js +238 -0
  8. package/lib/cli/SetupService.js +30 -1
  9. package/lib/cli/SyncService.js +36 -6
  10. package/lib/core/AstAnalyzer.js +994 -0
  11. package/lib/external/ai/AiProvider.js +281 -33
  12. package/lib/external/mcp/McpServer.js +6 -1
  13. package/lib/external/mcp/handlers/bootstrap.js +1721 -390
  14. package/lib/external/mcp/handlers/candidate.js +9 -90
  15. package/lib/external/mcp/handlers/skill.js +187 -0
  16. package/lib/external/mcp/tools.js +83 -11
  17. package/lib/http/HttpServer.js +2 -2
  18. package/lib/http/routes/candidates.js +124 -0
  19. package/lib/http/routes/commands.js +58 -3
  20. package/lib/http/routes/recipes.js +100 -7
  21. package/lib/http/routes/search.js +59 -1
  22. package/lib/http/routes/spm.js +91 -0
  23. package/lib/infrastructure/external/XcodeAutomation.js +0 -71
  24. package/lib/injection/ServiceContainer.js +3 -0
  25. package/lib/repository/recipe/RecipeRepository.impl.js +43 -2
  26. package/lib/service/automation/XcodeIntegration.js +158 -943
  27. package/lib/service/automation/handlers/SearchHandler.js +3 -1
  28. package/lib/service/candidate/CandidateService.js +358 -1
  29. package/lib/service/chat/ChatAgent.js +257 -20
  30. package/lib/service/chat/TaskPipeline.js +337 -0
  31. package/lib/service/chat/tools.js +158 -15
  32. package/lib/service/guard/GuardCheckEngine.js +155 -2
  33. package/lib/service/knowledge/KnowledgeGraphService.js +27 -5
  34. package/lib/service/recipe/RecipeFileWriter.js +44 -1
  35. package/lib/service/recipe/RecipeService.js +4 -1
  36. package/lib/service/spm/SpmService.js +221 -82
  37. package/lib/shared/RecipeReadinessChecker.js +99 -0
  38. package/package.json +15 -1
  39. package/skills/autosnippet-coldstart/SKILL.md +140 -0
  40. package/skills/autosnippet-reference-jsts/SKILL.md +440 -0
  41. package/skills/autosnippet-reference-objc/SKILL.md +427 -0
  42. package/skills/autosnippet-reference-swift/SKILL.md +461 -0
  43. package/templates/recipes-setup/seed-error-handling.md +58 -0
  44. package/templates/recipes-setup/seed-naming-convention.md +62 -0
  45. package/templates/recipes-setup/seed-thread-safety.md +65 -0
  46. package/dashboard/dist/assets/index-DKEqY8Zj.css +0 -1
  47. package/dashboard/dist/assets/index-DfqN0qFu.js +0 -143
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # AutoSnippet
1
+ # AutoSnippet — Project Knowledge Engine
2
2
 
3
3
  连接开发者、AI 与项目知识库:人工审核沉淀标准,知识库存储 Recipe + Snippet,AI 按规范生成代码。基于 SPM,打通 Xcode 补全与 Cursor 按需检索。
4
4
 
@@ -50,7 +50,7 @@ asd ui # 启动 Dashboard + watch
50
50
 
51
51
  `asd ui` 会启动 Web 管理后台并后台 watch;首次运行若前端不存在会自动构建。浏览器会自动打开 Dashboard。
52
52
 
53
- ![Dashboard 概览](https://cdn.jsdelivr.net/gh/GxFn/blog-images@main/2026-02-09-autosnippet-manual/20260205232116_66_167.png)
53
+ ![Dashboard 概览](https://cdn.jsdelivr.net/gh/GxFn/blog-images@main/autosnippet-manual/20260205232116_66_167.png)
54
54
 
55
55
 
56
56
  ## 核心流程
package/bin/cli.js CHANGED
@@ -5,6 +5,7 @@
5
5
  *
6
6
  * Usage:
7
7
  * asd setup - 初始化项目
8
+ * asd ais [Target] - AI 扫描 Target → Candidates
8
9
  * asd search <query> - 搜索知识库
9
10
  * asd guard <file> - Guard 检查
10
11
  * asd watch - 文件监控
@@ -38,9 +39,10 @@ program
38
39
  .description('初始化项目工作空间:目录结构、数据库、IDE 集成、模板')
39
40
  .option('-d, --dir <path>', '项目目录', '.')
40
41
  .option('--force', '强制覆盖已有配置')
42
+ .option('--seed', '预置示例 Recipe(冷启动推荐)')
41
43
  .action(async (opts) => {
42
44
  const { SetupService } = await import('../lib/cli/SetupService.js');
43
- const service = new SetupService({ projectRoot: resolve(opts.dir), force: opts.force });
45
+ const service = new SetupService({ projectRoot: resolve(opts.dir), force: opts.force, seed: opts.seed });
44
46
 
45
47
  console.log(`\n🚀 AutoSnippet V2 — 初始化工作空间`);
46
48
  console.log(` 项目: ${service.projectName}`);
@@ -50,6 +52,68 @@ program
50
52
  service.printSummary();
51
53
  });
52
54
 
55
+ // ─────────────────────────────────────────────────────
56
+ // ais 命令 (AI Scan)
57
+ // ─────────────────────────────────────────────────────
58
+ program
59
+ .command('ais [target]')
60
+ .description('AI 扫描 Target 源码 → 提取 Candidates(需配置 AI Provider)')
61
+ .option('-d, --dir <path>', '项目目录', '.')
62
+ .option('-m, --max-files <n>', '最大扫描文件数', '200')
63
+ .option('--dry-run', '仅预览,不创建 Candidate')
64
+ .option('--json', '以 JSON 格式输出')
65
+ .action(async (target, opts) => {
66
+ const projectRoot = resolve(opts.dir);
67
+ console.log(`\n🔬 AutoSnippet AI Scan`);
68
+ console.log(` 项目: ${basename(projectRoot)}`);
69
+ if (target) console.log(` Target: ${target}`);
70
+ console.log(` 最大文件数: ${opts.maxFiles}`);
71
+ if (opts.dryRun) console.log(' 模式: dry-run(仅预览)');
72
+ console.log('');
73
+
74
+ try {
75
+ const { bootstrap, container } = await initContainer({ projectRoot });
76
+
77
+ const { AiScanService } = await import('../lib/cli/AiScanService.js');
78
+ const scanner = new AiScanService({ container, projectRoot });
79
+
80
+ const ora = (await import('ora')).default;
81
+ const spinner = ora('正在扫描源文件并提取候选...').start();
82
+
83
+ const report = await scanner.scan(target || null, {
84
+ maxFiles: parseInt(opts.maxFiles, 10),
85
+ dryRun: opts.dryRun,
86
+ });
87
+
88
+ spinner.stop();
89
+
90
+ if (opts.json) {
91
+ console.log(JSON.stringify(report, null, 2));
92
+ } else {
93
+ console.log(`\n✅ AI 扫描完成`);
94
+ console.log(` 扫描文件: ${report.files}`);
95
+ console.log(` 跳过: ${report.skipped}`);
96
+ console.log(` 提取候选: ${report.candidates}`);
97
+ if (report.errors.length > 0) {
98
+ console.log(`\n⚠️ ${report.errors.length} 个错误:`);
99
+ for (const err of report.errors.slice(0, 10)) {
100
+ console.log(` - ${err}`);
101
+ }
102
+ if (report.errors.length > 10) console.log(` ... 及其他 ${report.errors.length - 10} 个`);
103
+ }
104
+ if (!opts.dryRun && report.candidates > 0) {
105
+ console.log(`\n📋 候选已创建,请运行 asd ui 打开 Dashboard 审核`);
106
+ }
107
+ }
108
+
109
+ await bootstrap.shutdown();
110
+ } catch (err) {
111
+ console.error(`\n❌ ${err.message}`);
112
+ if (process.env.ASD_DEBUG === '1') console.error(err.stack);
113
+ process.exit(1);
114
+ }
115
+ });
116
+
53
117
  // ─────────────────────────────────────────────────────
54
118
  // search 命令
55
119
  // ─────────────────────────────────────────────────────