autosnippet 3.0.11 → 3.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 (120) hide show
  1. package/bin/api-server.js +2 -0
  2. package/bin/cli.js +84 -16
  3. package/config/default.json +10 -1
  4. package/dashboard/dist/assets/{index-I2ySoCmF.js → index-Bnm26ulL.js} +47 -47
  5. package/dashboard/dist/index.html +1 -1
  6. package/lib/bootstrap.js +4 -4
  7. package/lib/cli/SetupService.js +116 -29
  8. package/lib/cli/UpgradeService.js +16 -6
  9. package/lib/core/AstAnalyzer.js +1 -1
  10. package/lib/core/ast/ensure-grammars.js +1 -1
  11. package/lib/core/ast/index.js +62 -11
  12. package/lib/core/ast/lang-dart.js +27 -21
  13. package/lib/core/ast/lang-go.js +6 -20
  14. package/lib/core/ast/lang-rust.js +53 -28
  15. package/lib/core/ast/parser-init.js +9 -5
  16. package/lib/core/discovery/DartDiscoverer.js +4 -10
  17. package/lib/core/discovery/GenericDiscoverer.js +4 -28
  18. package/lib/core/discovery/GoDiscoverer.js +45 -25
  19. package/lib/core/discovery/NodeDiscoverer.js +1 -3
  20. package/lib/core/discovery/PythonDiscoverer.js +7 -1
  21. package/lib/core/discovery/RustDiscoverer.js +111 -38
  22. package/lib/core/discovery/index.js +2 -2
  23. package/lib/core/enhancement/django-enhancement.js +10 -4
  24. package/lib/core/enhancement/fastapi-enhancement.js +16 -9
  25. package/lib/core/enhancement/go-grpc-enhancement.js +2 -1
  26. package/lib/core/enhancement/go-web-enhancement.js +3 -6
  27. package/lib/core/enhancement/ml-enhancement.js +6 -3
  28. package/lib/core/enhancement/nextjs-enhancement.js +17 -7
  29. package/lib/core/enhancement/node-server-enhancement.js +4 -2
  30. package/lib/core/enhancement/react-enhancement.js +6 -3
  31. package/lib/core/enhancement/rust-tokio-enhancement.js +6 -2
  32. package/lib/core/enhancement/rust-web-enhancement.js +13 -7
  33. package/lib/core/enhancement/vue-enhancement.js +10 -5
  34. package/lib/external/ai/AiFactory.js +3 -1
  35. package/lib/external/ai/AiProvider.js +3 -1
  36. package/lib/external/mcp/McpServer.js +2 -0
  37. package/lib/external/mcp/handlers/bootstrap/base-dimensions.js +245 -0
  38. package/lib/external/mcp/handlers/bootstrap/pipeline/checkpoint.js +86 -0
  39. package/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +275 -0
  40. package/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +629 -0
  41. package/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +131 -348
  42. package/lib/external/mcp/handlers/bootstrap/refine.js +364 -0
  43. package/lib/external/mcp/handlers/bootstrap.js +7 -597
  44. package/lib/external/mcp/handlers/browse.js +123 -9
  45. package/lib/external/mcp/handlers/guard.js +29 -6
  46. package/lib/external/mcp/handlers/search.js +56 -24
  47. package/lib/external/mcp/handlers/skill.js +6 -2
  48. package/lib/http/HttpServer.js +1 -1
  49. package/lib/http/routes/candidates.js +3 -1
  50. package/lib/http/routes/extract.js +4 -5
  51. package/lib/http/routes/guardRules.js +9 -17
  52. package/lib/http/routes/modules.js +9 -3
  53. package/lib/http/routes/skills.js +54 -6
  54. package/lib/http/routes/violations.js +4 -3
  55. package/lib/infrastructure/external/ClipboardManager.js +24 -7
  56. package/lib/infrastructure/external/NativeUi.js +3 -1
  57. package/lib/infrastructure/external/OpenBrowser.js +1 -0
  58. package/lib/infrastructure/external/XcodeAutomation.js +5 -5
  59. package/lib/infrastructure/vector/IndexingPipeline.js +14 -5
  60. package/lib/injection/ServiceContainer.js +45 -13
  61. package/lib/platform/ios/index.js +20 -25
  62. package/lib/platform/ios/routes/spm.js +6 -3
  63. package/lib/platform/ios/snippet/PlaceholderConverter.js +6 -2
  64. package/lib/platform/ios/snippet/XcodeCodec.js +4 -2
  65. package/lib/platform/ios/spm/SpmDiscoverer.js +1 -1
  66. package/lib/platform/ios/spm/SpmService.js +3 -1
  67. package/lib/platform/ios/xcode/XcodeImportResolver.js +434 -0
  68. package/lib/platform/ios/xcode/XcodeIntegration.js +43 -664
  69. package/lib/platform/ios/xcode/XcodeWriteUtils.js +225 -0
  70. package/lib/service/automation/FileWatcher.js +1 -3
  71. package/lib/service/automation/handlers/CreateHandler.js +3 -5
  72. package/lib/service/automation/handlers/GuardHandler.js +11 -32
  73. package/lib/service/automation/handlers/SearchHandler.js +9 -9
  74. package/lib/service/chat/CandidateGuardrail.js +11 -6
  75. package/lib/service/chat/ChatAgent.js +51 -421
  76. package/lib/service/chat/ChatAgentPrompts.js +149 -0
  77. package/lib/service/chat/ChatAgentTasks.js +297 -0
  78. package/lib/service/chat/HandoffProtocol.js +5 -2
  79. package/lib/service/chat/tools/_shared.js +61 -0
  80. package/lib/service/chat/tools/ai-analysis.js +284 -0
  81. package/lib/service/chat/tools/ast-graph.js +681 -0
  82. package/lib/service/chat/tools/composite.js +497 -0
  83. package/lib/service/chat/tools/guard.js +265 -0
  84. package/lib/service/chat/tools/index.js +239 -0
  85. package/lib/service/chat/tools/infrastructure.js +227 -0
  86. package/lib/service/chat/tools/knowledge-graph.js +234 -0
  87. package/lib/service/chat/tools/lifecycle.js +486 -0
  88. package/lib/service/chat/tools/project-access.js +919 -0
  89. package/lib/service/chat/tools/query.js +264 -0
  90. package/lib/service/chat/tools.js +13 -3994
  91. package/lib/service/cursor/AgentInstructionsGenerator.js +413 -0
  92. package/lib/service/cursor/CursorDeliveryPipeline.js +71 -11
  93. package/lib/service/cursor/FileProtection.js +116 -0
  94. package/lib/service/cursor/KnowledgeCompressor.js +70 -11
  95. package/lib/service/cursor/SkillsSyncer.js +5 -3
  96. package/lib/service/cursor/TopicClassifier.js +19 -3
  97. package/lib/service/guard/ComplianceReporter.js +5 -2
  98. package/lib/service/guard/ExclusionManager.js +26 -2
  99. package/lib/service/guard/GuardCheckEngine.js +83 -388
  100. package/lib/service/guard/GuardCodeChecks.js +391 -0
  101. package/lib/service/guard/GuardCrossFileChecks.js +326 -0
  102. package/lib/service/guard/GuardPatternUtils.js +187 -0
  103. package/lib/service/guard/GuardService.js +80 -38
  104. package/lib/service/module/ModuleService.js +181 -56
  105. package/lib/service/recipe/RecipeCandidateValidator.js +11 -8
  106. package/lib/service/search/SearchEngine.js +10 -2
  107. package/lib/service/snippet/SnippetFactory.js +3 -3
  108. package/lib/service/snippet/SnippetInstaller.js +35 -11
  109. package/lib/service/snippet/codecs/VSCodeCodec.js +2 -2
  110. package/lib/service/wiki/WikiGenerator.js +247 -1535
  111. package/lib/service/wiki/WikiRenderers.js +1903 -0
  112. package/lib/service/wiki/WikiUtils.js +1044 -0
  113. package/lib/shared/LanguageService.js +359 -2
  114. package/lib/shared/PathGuard.js +0 -8
  115. package/package.json +3 -9
  116. package/scripts/bench-real-projects.mjs +29 -29
  117. package/scripts/generate-recipe-drafts.js +17 -27
  118. package/scripts/init-snippets.js +43 -24
  119. package/scripts/install-vscode-copilot.js +3 -19
  120. package/scripts/setup-mcp-config.js +0 -4
package/bin/api-server.js CHANGED
@@ -44,6 +44,8 @@ async function main() {
44
44
  auditLogger: components.auditLogger,
45
45
  gateway: components.gateway,
46
46
  constitution: components.constitution,
47
+ config: components.config,
48
+ skillHooks: components.skillHooks,
47
49
  projectRoot,
48
50
  });
49
51
  logger.info('Service container initialized successfully');
package/bin/cli.js CHANGED
@@ -14,9 +14,10 @@
14
14
  * asd server - 启动 API 服务
15
15
  * asd status - 环境状态
16
16
  * asd ui - 启动 Dashboard UI
17
+ * asd mirror - 镜像 .cursor/ → .qoder/ .trae/
17
18
  */
18
19
 
19
- import { existsSync, readFileSync, readdirSync } from 'node:fs';
20
+ import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
20
21
  import { dirname, join, resolve } from 'node:path';
21
22
  import { fileURLToPath } from 'node:url';
22
23
  import { Command } from 'commander';
@@ -647,25 +648,29 @@ program
647
648
  // ── Level 1: 项目配置文件(确定性高)──
648
649
  const hasAppleConfig = entries.some(
649
650
  (e) =>
650
- e.name === 'Package.swift' || // SPM
651
- e.name === 'Podfile' || // CocoaPods
652
- e.name === 'Cartfile' || // Carthage
653
- e.name === 'project.yml' || // XcodeGen
654
- e.name.endsWith('.xcodeproj') || // Xcode project
655
- e.name.endsWith('.xcworkspace') // Xcode workspace
651
+ e.name === 'Package.swift' || // SPM
652
+ e.name === 'Podfile' || // CocoaPods
653
+ e.name === 'Cartfile' || // Carthage
654
+ e.name === 'project.yml' || // XcodeGen
655
+ e.name.endsWith('.xcodeproj') || // Xcode project
656
+ e.name.endsWith('.xcworkspace') // Xcode workspace
656
657
  );
657
- if (hasAppleConfig) return true;
658
+ if (hasAppleConfig) {
659
+ return true;
660
+ }
658
661
 
659
662
  // ── Level 2: 目录结构特征 ──
660
663
  const hasAppleDir = entries.some(
661
664
  (e) =>
662
665
  e.isDirectory() &&
663
- (e.name === 'Tuist' || // Tuist 项目
664
- e.name === 'Pods' || // CocoaPods 产物
665
- e.name === 'Carthage' || // Carthage 产物
666
- e.name === 'DerivedData') // Xcode 构建产物
666
+ (e.name === 'Tuist' || // Tuist 项目
667
+ e.name === 'Pods' || // CocoaPods 产物
668
+ e.name === 'Carthage' || // Carthage 产物
669
+ e.name === 'DerivedData') // Xcode 构建产物
667
670
  );
668
- if (hasAppleDir) return true;
671
+ if (hasAppleDir) {
672
+ return true;
673
+ }
669
674
 
670
675
  // ── Level 3: 向下扫一层(处理 monorepo 或 Sources/ 下有 .swift 的情况)──
671
676
  const APPLE_EXTS = new Set(['.swift', '.m', '.mm', '.h']);
@@ -682,7 +687,9 @@ program
682
687
  if (subEntries.some((f) => APPLE_EXTS.has(f.slice(f.lastIndexOf('.'))))) {
683
688
  return true;
684
689
  }
685
- } catch { /* 读取失败忽略 */ }
690
+ } catch {
691
+ /* 读取失败忽略 */
692
+ }
686
693
  }
687
694
  }
688
695
 
@@ -709,7 +716,8 @@ program
709
716
  ? `http://127.0.0.1:${port}`
710
717
  : `http://localhost:5173`;
711
718
  } else {
712
- process.env.ASD_DASHBOARD_URL = process.env.ASD_DASHBOARD_URL || `http://${host}:${port}`;
719
+ process.env.ASD_DASHBOARD_URL =
720
+ process.env.ASD_DASHBOARD_URL || `http://${host}:${port}`;
713
721
  }
714
722
 
715
723
  const { FileWatcher } = await import('../lib/service/automation/FileWatcher.js');
@@ -724,7 +732,6 @@ program
724
732
  }
725
733
  }
726
734
  } else if (process.env.ASD_DEBUG === '1') {
727
- console.log('ℹ️ Non-Apple project — file watcher skipped (use VSCode extension instead)');
728
735
  }
729
736
  } catch (err) {
730
737
  console.error(`❌ API server failed to start: ${err.message}`);
@@ -854,6 +861,65 @@ program
854
861
  }
855
862
  });
856
863
 
864
+ // ─────────────────────────────────────────────────────
865
+ // mirror 命令
866
+ // ─────────────────────────────────────────────────────
867
+ program
868
+ .command('mirror')
869
+ .description('镜像 .cursor/ 交付物料到其他兼容 IDE 目录(Qoder / Trae)')
870
+ .option('-d, --dir <path>', '项目目录', '.')
871
+ .option('--target <ide>', '目标 IDE:qoder, trae, all(默认 all)', 'all')
872
+ .action(async (opts) => {
873
+ const projectRoot = resolve(opts.dir);
874
+ const targets = opts.target === 'all' ? ['.qoder', '.trae'] : [`.${opts.target}`];
875
+
876
+ const cursorDir = join(projectRoot, '.cursor');
877
+ if (!existsSync(cursorDir)) {
878
+ console.error('❌ 未找到 .cursor/ 目录,请先运行 asd setup 或 asd cursor-rules');
879
+ process.exit(1);
880
+ }
881
+
882
+ for (const target of targets) {
883
+ const cursorRulesDir = join(cursorDir, 'rules');
884
+ if (existsSync(cursorRulesDir)) {
885
+ const targetRulesDir = join(projectRoot, target, 'rules');
886
+ mkdirSync(targetRulesDir, { recursive: true });
887
+ const files = readdirSync(cursorRulesDir).filter(
888
+ (f) => f.startsWith('autosnippet-') && (f.endsWith('.mdc') || f.endsWith('.md'))
889
+ );
890
+ for (const file of files) {
891
+ const destName = file.endsWith('.mdc') ? file.replace(/\.mdc$/, '.md') : file;
892
+ copyFileSync(join(cursorRulesDir, file), join(targetRulesDir, destName));
893
+ }
894
+ }
895
+
896
+ const cursorSkillsDir = join(cursorDir, 'skills');
897
+ if (existsSync(cursorSkillsDir)) {
898
+ const targetSkillsDir = join(projectRoot, target, 'skills');
899
+ const skillDirs = readdirSync(cursorSkillsDir, { withFileTypes: true }).filter(
900
+ (d) => d.isDirectory() && d.name.startsWith('autosnippet-')
901
+ );
902
+ for (const dir of skillDirs) {
903
+ _copyDirRecursive(join(cursorSkillsDir, dir.name), join(targetSkillsDir, dir.name));
904
+ }
905
+ }
906
+ }
907
+ });
908
+
909
+ /** @private 递归复制目录(mirror 命令用) */
910
+ function _copyDirRecursive(src, dest) {
911
+ mkdirSync(dest, { recursive: true });
912
+ for (const entry of readdirSync(src, { withFileTypes: true })) {
913
+ const srcPath = join(src, entry.name);
914
+ const destPath = join(dest, entry.name);
915
+ if (entry.isDirectory()) {
916
+ _copyDirRecursive(srcPath, destPath);
917
+ } else {
918
+ copyFileSync(srcPath, destPath);
919
+ }
920
+ }
921
+ }
922
+
857
923
  // ─────────────────────────────────────────────────────
858
924
  // sync 命令
859
925
  // ─────────────────────────────────────────────────────
@@ -941,6 +1007,8 @@ async function initContainer(opts = {}) {
941
1007
  auditLogger: bootstrap.components.auditLogger,
942
1008
  gateway: bootstrap.components.gateway,
943
1009
  constitution: bootstrap.components.constitution,
1010
+ config: bootstrap.components.config,
1011
+ skillHooks: bootstrap.components.skillHooks,
944
1012
  projectRoot,
945
1013
  });
946
1014
  return { bootstrap, container };
@@ -45,12 +45,21 @@
45
45
  },
46
46
  "vector": {
47
47
  "enabled": true,
48
- "dimensions": 1536,
48
+ "dimensions": 768,
49
49
  "indexPath": "./data/vector-index"
50
50
  },
51
51
  "qualityGate": {
52
52
  "maxErrors": 0,
53
53
  "maxWarnings": 20,
54
54
  "minScore": 70
55
+ },
56
+ "guard": {
57
+ "disabledRules": [],
58
+ "codeLevelThresholds": {
59
+ "swift-excessive-force-unwrap": 5,
60
+ "rust-excessive-unwrap": 3,
61
+ "rust-excessive-unsafe": 3,
62
+ "dart-excessive-late": 3
63
+ }
55
64
  }
56
65
  }