agent-ide 0.1.9 → 0.2.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 (227) hide show
  1. package/README.md +103 -17
  2. package/dist/application/services/module-coordinator.service.d.ts +0 -1
  3. package/dist/application/services/module-coordinator.service.d.ts.map +1 -1
  4. package/dist/application/services/module-coordinator.service.js +2 -8
  5. package/dist/application/services/module-coordinator.service.js.map +1 -1
  6. package/dist/core/analysis/index.d.ts +1 -4
  7. package/dist/core/analysis/index.d.ts.map +1 -1
  8. package/dist/core/analysis/index.js +1 -7
  9. package/dist/core/analysis/index.js.map +1 -1
  10. package/dist/core/dependency/dependency-analyzer.d.ts.map +1 -1
  11. package/dist/core/dependency/dependency-analyzer.js +10 -0
  12. package/dist/core/dependency/dependency-analyzer.js.map +1 -1
  13. package/dist/core/indexing/index-engine.d.ts +4 -0
  14. package/dist/core/indexing/index-engine.d.ts.map +1 -1
  15. package/dist/core/indexing/index-engine.js +25 -1
  16. package/dist/core/indexing/index-engine.js.map +1 -1
  17. package/dist/core/indexing/symbol-index.d.ts +4 -0
  18. package/dist/core/indexing/symbol-index.d.ts.map +1 -1
  19. package/dist/core/indexing/symbol-index.js +17 -0
  20. package/dist/core/indexing/symbol-index.js.map +1 -1
  21. package/dist/core/move/import-resolver.d.ts.map +1 -1
  22. package/dist/core/move/import-resolver.js +8 -0
  23. package/dist/core/move/import-resolver.js.map +1 -1
  24. package/dist/core/move/move-service.js +7 -7
  25. package/dist/core/move/move-service.js.map +1 -1
  26. package/dist/core/refactor/swift-extractor.d.ts +98 -0
  27. package/dist/core/refactor/swift-extractor.d.ts.map +1 -0
  28. package/dist/core/refactor/swift-extractor.js +283 -0
  29. package/dist/core/refactor/swift-extractor.js.map +1 -0
  30. package/dist/core/rename/reference-updater.d.ts.map +1 -1
  31. package/dist/core/rename/reference-updater.js +16 -8
  32. package/dist/core/rename/reference-updater.js.map +1 -1
  33. package/dist/core/search/engines/text-engine.js +1 -1
  34. package/dist/core/search/engines/text-engine.js.map +1 -1
  35. package/dist/core/shit-score/grading.d.ts +39 -0
  36. package/dist/core/shit-score/grading.d.ts.map +1 -0
  37. package/dist/core/shit-score/grading.js +253 -0
  38. package/dist/core/shit-score/grading.js.map +1 -0
  39. package/dist/core/shit-score/index.d.ts +9 -0
  40. package/dist/core/shit-score/index.d.ts.map +1 -0
  41. package/dist/core/shit-score/index.js +8 -0
  42. package/dist/core/shit-score/index.js.map +1 -0
  43. package/dist/core/shit-score/score-calculator.d.ts +75 -0
  44. package/dist/core/shit-score/score-calculator.d.ts.map +1 -0
  45. package/dist/core/shit-score/score-calculator.js +240 -0
  46. package/dist/core/shit-score/score-calculator.js.map +1 -0
  47. package/dist/core/shit-score/shit-score-analyzer.d.ts +84 -0
  48. package/dist/core/shit-score/shit-score-analyzer.d.ts.map +1 -0
  49. package/dist/core/shit-score/shit-score-analyzer.js +595 -0
  50. package/dist/core/shit-score/shit-score-analyzer.js.map +1 -0
  51. package/dist/core/shit-score/types.d.ts +231 -0
  52. package/dist/core/shit-score/types.d.ts.map +1 -0
  53. package/dist/core/shit-score/types.js +73 -0
  54. package/dist/core/shit-score/types.js.map +1 -0
  55. package/dist/core/snapshot/code-compressor.d.ts +39 -0
  56. package/dist/core/snapshot/code-compressor.d.ts.map +1 -0
  57. package/dist/core/snapshot/code-compressor.js +211 -0
  58. package/dist/core/snapshot/code-compressor.js.map +1 -0
  59. package/dist/core/snapshot/config.d.ts +60 -0
  60. package/dist/core/snapshot/config.d.ts.map +1 -0
  61. package/dist/core/snapshot/config.js +136 -0
  62. package/dist/core/snapshot/config.js.map +1 -0
  63. package/dist/core/snapshot/index.d.ts +23 -0
  64. package/dist/core/snapshot/index.d.ts.map +1 -0
  65. package/dist/core/snapshot/index.js +27 -0
  66. package/dist/core/snapshot/index.js.map +1 -0
  67. package/dist/core/snapshot/snapshot-differ.d.ts +54 -0
  68. package/dist/core/snapshot/snapshot-differ.d.ts.map +1 -0
  69. package/dist/core/snapshot/snapshot-differ.js +262 -0
  70. package/dist/core/snapshot/snapshot-differ.js.map +1 -0
  71. package/dist/core/snapshot/snapshot-engine.d.ts +94 -0
  72. package/dist/core/snapshot/snapshot-engine.d.ts.map +1 -0
  73. package/dist/core/snapshot/snapshot-engine.js +492 -0
  74. package/dist/core/snapshot/snapshot-engine.js.map +1 -0
  75. package/dist/core/snapshot/types.d.ts +216 -0
  76. package/dist/core/snapshot/types.d.ts.map +1 -0
  77. package/dist/core/snapshot/types.js +79 -0
  78. package/dist/core/snapshot/types.js.map +1 -0
  79. package/dist/infrastructure/parser/analysis-types.d.ts +198 -0
  80. package/dist/infrastructure/parser/analysis-types.d.ts.map +1 -0
  81. package/dist/infrastructure/parser/analysis-types.js +6 -0
  82. package/dist/infrastructure/parser/analysis-types.js.map +1 -0
  83. package/dist/infrastructure/parser/base.d.ts +36 -0
  84. package/dist/infrastructure/parser/base.d.ts.map +1 -1
  85. package/dist/infrastructure/parser/base.js +72 -0
  86. package/dist/infrastructure/parser/base.js.map +1 -1
  87. package/dist/infrastructure/parser/index.d.ts +1 -0
  88. package/dist/infrastructure/parser/index.d.ts.map +1 -1
  89. package/dist/infrastructure/parser/index.js.map +1 -1
  90. package/dist/infrastructure/parser/interface.d.ts +63 -0
  91. package/dist/infrastructure/parser/interface.d.ts.map +1 -1
  92. package/dist/infrastructure/parser/interface.js +11 -1
  93. package/dist/infrastructure/parser/interface.js.map +1 -1
  94. package/dist/interfaces/cli/cli.d.ts +24 -0
  95. package/dist/interfaces/cli/cli.d.ts.map +1 -1
  96. package/dist/interfaces/cli/cli.js +1483 -157
  97. package/dist/interfaces/cli/cli.js.map +1 -1
  98. package/dist/plugins/javascript/parser.d.ts +41 -0
  99. package/dist/plugins/javascript/parser.d.ts.map +1 -1
  100. package/dist/plugins/javascript/parser.js +284 -0
  101. package/dist/plugins/javascript/parser.js.map +1 -1
  102. package/dist/plugins/swift/analyzers/complexity-analyzer.d.ts +41 -0
  103. package/dist/plugins/swift/analyzers/complexity-analyzer.d.ts.map +1 -0
  104. package/dist/plugins/swift/analyzers/complexity-analyzer.js +206 -0
  105. package/dist/plugins/swift/analyzers/complexity-analyzer.js.map +1 -0
  106. package/dist/plugins/swift/analyzers/duplication-detector.d.ts +89 -0
  107. package/dist/plugins/swift/analyzers/duplication-detector.d.ts.map +1 -0
  108. package/dist/plugins/swift/analyzers/duplication-detector.js +271 -0
  109. package/dist/plugins/swift/analyzers/duplication-detector.js.map +1 -0
  110. package/dist/plugins/swift/analyzers/error-handling-checker.d.ts +34 -0
  111. package/dist/plugins/swift/analyzers/error-handling-checker.d.ts.map +1 -0
  112. package/dist/plugins/swift/analyzers/error-handling-checker.js +135 -0
  113. package/dist/plugins/swift/analyzers/error-handling-checker.js.map +1 -0
  114. package/dist/plugins/swift/analyzers/naming-checker.d.ts +47 -0
  115. package/dist/plugins/swift/analyzers/naming-checker.d.ts.map +1 -0
  116. package/dist/plugins/swift/analyzers/naming-checker.js +161 -0
  117. package/dist/plugins/swift/analyzers/naming-checker.js.map +1 -0
  118. package/dist/plugins/swift/analyzers/pattern-detector.d.ts +78 -0
  119. package/dist/plugins/swift/analyzers/pattern-detector.d.ts.map +1 -0
  120. package/dist/plugins/swift/analyzers/pattern-detector.js +247 -0
  121. package/dist/plugins/swift/analyzers/pattern-detector.js.map +1 -0
  122. package/dist/plugins/swift/analyzers/security-checker.d.ts +38 -0
  123. package/dist/plugins/swift/analyzers/security-checker.d.ts.map +1 -0
  124. package/dist/plugins/swift/analyzers/security-checker.js +135 -0
  125. package/dist/plugins/swift/analyzers/security-checker.js.map +1 -0
  126. package/dist/plugins/swift/analyzers/test-coverage-checker.d.ts +26 -0
  127. package/dist/plugins/swift/analyzers/test-coverage-checker.d.ts.map +1 -0
  128. package/dist/plugins/swift/analyzers/test-coverage-checker.js +63 -0
  129. package/dist/plugins/swift/analyzers/test-coverage-checker.js.map +1 -0
  130. package/dist/plugins/swift/analyzers/type-safety-checker.d.ts +41 -0
  131. package/dist/plugins/swift/analyzers/type-safety-checker.d.ts.map +1 -0
  132. package/dist/plugins/swift/analyzers/type-safety-checker.js +121 -0
  133. package/dist/plugins/swift/analyzers/type-safety-checker.js.map +1 -0
  134. package/dist/plugins/swift/analyzers/unused-symbol-detector.d.ts +38 -0
  135. package/dist/plugins/swift/analyzers/unused-symbol-detector.d.ts.map +1 -0
  136. package/dist/plugins/swift/analyzers/unused-symbol-detector.js +211 -0
  137. package/dist/plugins/swift/analyzers/unused-symbol-detector.js.map +1 -0
  138. package/dist/plugins/swift/dependency-analyzer.d.ts +33 -0
  139. package/dist/plugins/swift/dependency-analyzer.d.ts.map +1 -0
  140. package/dist/plugins/swift/dependency-analyzer.js +95 -0
  141. package/dist/plugins/swift/dependency-analyzer.js.map +1 -0
  142. package/dist/plugins/swift/index.d.ts +14 -0
  143. package/dist/plugins/swift/index.d.ts.map +1 -0
  144. package/dist/plugins/swift/index.js +19 -0
  145. package/dist/plugins/swift/index.js.map +1 -0
  146. package/dist/plugins/swift/parser.d.ts +160 -0
  147. package/dist/plugins/swift/parser.d.ts.map +1 -0
  148. package/dist/plugins/swift/parser.js +670 -0
  149. package/dist/plugins/swift/parser.js.map +1 -0
  150. package/dist/plugins/swift/swift-bridge/swift-parser +0 -0
  151. package/dist/plugins/swift/symbol-extractor.d.ts +46 -0
  152. package/dist/plugins/swift/symbol-extractor.d.ts.map +1 -0
  153. package/dist/plugins/swift/symbol-extractor.js +187 -0
  154. package/dist/plugins/swift/symbol-extractor.js.map +1 -0
  155. package/dist/plugins/swift/types.d.ts +137 -0
  156. package/dist/plugins/swift/types.d.ts.map +1 -0
  157. package/dist/plugins/swift/types.js +212 -0
  158. package/dist/plugins/swift/types.js.map +1 -0
  159. package/dist/plugins/typescript/analyzers/complexity-analyzer.d.ts +39 -0
  160. package/dist/plugins/typescript/analyzers/complexity-analyzer.d.ts.map +1 -0
  161. package/dist/plugins/typescript/analyzers/complexity-analyzer.js +196 -0
  162. package/dist/plugins/typescript/analyzers/complexity-analyzer.js.map +1 -0
  163. package/dist/{core/analysis → plugins/typescript/analyzers}/duplication-detector.d.ts +34 -3
  164. package/dist/plugins/typescript/analyzers/duplication-detector.d.ts.map +1 -0
  165. package/dist/plugins/typescript/analyzers/duplication-detector.js +695 -0
  166. package/dist/plugins/typescript/analyzers/duplication-detector.js.map +1 -0
  167. package/dist/plugins/typescript/analyzers/error-handling-checker.d.ts +26 -0
  168. package/dist/plugins/typescript/analyzers/error-handling-checker.d.ts.map +1 -0
  169. package/dist/plugins/typescript/analyzers/error-handling-checker.js +84 -0
  170. package/dist/plugins/typescript/analyzers/error-handling-checker.js.map +1 -0
  171. package/dist/plugins/typescript/analyzers/naming-checker.d.ts +30 -0
  172. package/dist/plugins/typescript/analyzers/naming-checker.d.ts.map +1 -0
  173. package/dist/plugins/typescript/analyzers/naming-checker.js +116 -0
  174. package/dist/plugins/typescript/analyzers/naming-checker.js.map +1 -0
  175. package/dist/plugins/typescript/analyzers/pattern-detector.d.ts +80 -0
  176. package/dist/plugins/typescript/analyzers/pattern-detector.d.ts.map +1 -0
  177. package/dist/plugins/typescript/analyzers/pattern-detector.js +267 -0
  178. package/dist/plugins/typescript/analyzers/pattern-detector.js.map +1 -0
  179. package/dist/plugins/typescript/analyzers/security-checker.d.ts +34 -0
  180. package/dist/plugins/typescript/analyzers/security-checker.d.ts.map +1 -0
  181. package/dist/plugins/typescript/analyzers/security-checker.js +126 -0
  182. package/dist/plugins/typescript/analyzers/security-checker.js.map +1 -0
  183. package/dist/plugins/typescript/analyzers/test-coverage-checker.d.ts +22 -0
  184. package/dist/plugins/typescript/analyzers/test-coverage-checker.d.ts.map +1 -0
  185. package/dist/plugins/typescript/analyzers/test-coverage-checker.js +62 -0
  186. package/dist/plugins/typescript/analyzers/test-coverage-checker.js.map +1 -0
  187. package/dist/plugins/typescript/analyzers/type-safety-checker.d.ts +32 -0
  188. package/dist/plugins/typescript/analyzers/type-safety-checker.d.ts.map +1 -0
  189. package/dist/plugins/typescript/analyzers/type-safety-checker.js +86 -0
  190. package/dist/plugins/typescript/analyzers/type-safety-checker.js.map +1 -0
  191. package/dist/plugins/typescript/analyzers/unused-symbol-detector.d.ts +47 -0
  192. package/dist/plugins/typescript/analyzers/unused-symbol-detector.d.ts.map +1 -0
  193. package/dist/plugins/typescript/analyzers/unused-symbol-detector.js +152 -0
  194. package/dist/plugins/typescript/analyzers/unused-symbol-detector.js.map +1 -0
  195. package/dist/plugins/typescript/parser.d.ts +41 -0
  196. package/dist/plugins/typescript/parser.d.ts.map +1 -1
  197. package/dist/plugins/typescript/parser.js +336 -0
  198. package/dist/plugins/typescript/parser.js.map +1 -1
  199. package/dist/shared/types/symbol.d.ts +7 -1
  200. package/dist/shared/types/symbol.d.ts.map +1 -1
  201. package/dist/shared/types/symbol.js +8 -2
  202. package/dist/shared/types/symbol.js.map +1 -1
  203. package/package.json +17 -7
  204. package/bin/mcp-server.js +0 -20
  205. package/dist/core/analysis/complexity-analyzer.d.ts +0 -81
  206. package/dist/core/analysis/complexity-analyzer.d.ts.map +0 -1
  207. package/dist/core/analysis/complexity-analyzer.js +0 -255
  208. package/dist/core/analysis/complexity-analyzer.js.map +0 -1
  209. package/dist/core/analysis/dead-code-detector.d.ts +0 -152
  210. package/dist/core/analysis/dead-code-detector.d.ts.map +0 -1
  211. package/dist/core/analysis/dead-code-detector.js +0 -351
  212. package/dist/core/analysis/dead-code-detector.js.map +0 -1
  213. package/dist/core/analysis/duplication-detector.d.ts.map +0 -1
  214. package/dist/core/analysis/duplication-detector.js +0 -433
  215. package/dist/core/analysis/duplication-detector.js.map +0 -1
  216. package/dist/interfaces/mcp/index.d.ts +0 -7
  217. package/dist/interfaces/mcp/index.d.ts.map +0 -1
  218. package/dist/interfaces/mcp/index.js +0 -6
  219. package/dist/interfaces/mcp/index.js.map +0 -1
  220. package/dist/interfaces/mcp/mcp-server.d.ts +0 -34
  221. package/dist/interfaces/mcp/mcp-server.d.ts.map +0 -1
  222. package/dist/interfaces/mcp/mcp-server.js +0 -162
  223. package/dist/interfaces/mcp/mcp-server.js.map +0 -1
  224. package/dist/interfaces/mcp/mcp.d.ts +0 -52
  225. package/dist/interfaces/mcp/mcp.d.ts.map +0 -1
  226. package/dist/interfaces/mcp/mcp.js +0 -843
  227. package/dist/interfaces/mcp/mcp.js.map +0 -1
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Swift 命名規範檢查器
3
+ * 檢測命名規範:Types 用 PascalCase、variables/functions 用 camelCase、Constants 用 camelCase 或 UPPER_CASE
4
+ * 禁止底線開頭(除了 private)
5
+ */
6
+ /**
7
+ * Swift 命名規範檢查器
8
+ */
9
+ export class NamingChecker {
10
+ /**
11
+ * 檢查檔案的命名規範問題
12
+ */
13
+ async check(files, fileContents) {
14
+ let totalIssues = 0;
15
+ for (const file of files) {
16
+ if (!this.isSwiftFile(file)) {
17
+ continue;
18
+ }
19
+ // 檢查檔案命名
20
+ totalIssues += this.checkFileName(file);
21
+ const content = fileContents.get(file);
22
+ if (!content) {
23
+ continue;
24
+ }
25
+ // 檢查程式碼命名
26
+ totalIssues += this.checkCodeNaming(content);
27
+ }
28
+ return totalIssues;
29
+ }
30
+ /**
31
+ * 檢查檔案命名(Swift 檔案應該是 PascalCase)
32
+ */
33
+ checkFileName(file) {
34
+ const basename = file.split('/').pop() || '';
35
+ const nameWithoutExt = basename.replace('.swift', '');
36
+ // 排除特殊檔案
37
+ if (this.isSpecialFile(basename)) {
38
+ return 0;
39
+ }
40
+ // Swift 檔案名應該是 PascalCase
41
+ const isPascalCase = /^[A-Z][a-zA-Z0-9]*$/.test(nameWithoutExt);
42
+ if (!isPascalCase) {
43
+ return 1.5; // 權重 1.5
44
+ }
45
+ return 0;
46
+ }
47
+ /**
48
+ * 檢查程式碼命名規範
49
+ */
50
+ checkCodeNaming(content) {
51
+ let count = 0;
52
+ // 檢查 Type 命名(class, struct, protocol, enum)
53
+ count += this.checkTypeNaming(content);
54
+ // 檢查變數和函式命名
55
+ count += this.checkVariableAndFunctionNaming(content);
56
+ // 檢查底線開頭(非 private)
57
+ count += this.checkUnderscorePrefix(content);
58
+ return count;
59
+ }
60
+ /**
61
+ * 檢查 Type 命名(應該是 PascalCase)
62
+ */
63
+ checkTypeNaming(content) {
64
+ let count = 0;
65
+ const typePatterns = [
66
+ /class\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
67
+ /struct\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
68
+ /protocol\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
69
+ /enum\s+([a-zA-Z_][a-zA-Z0-9_]*)/g
70
+ ];
71
+ for (const pattern of typePatterns) {
72
+ let match;
73
+ while ((match = pattern.exec(content)) !== null) {
74
+ const typeName = match[1];
75
+ // 檢查是否為 PascalCase
76
+ if (!/^[A-Z][a-zA-Z0-9]*$/.test(typeName)) {
77
+ count++;
78
+ }
79
+ }
80
+ }
81
+ return count;
82
+ }
83
+ /**
84
+ * 檢查變數和函式命名(應該是 camelCase)
85
+ */
86
+ checkVariableAndFunctionNaming(content) {
87
+ let count = 0;
88
+ // 函式命名
89
+ const funcRegex = /func\s+([a-zA-Z_][a-zA-Z0-9_]*)/g;
90
+ let match;
91
+ while ((match = funcRegex.exec(content)) !== null) {
92
+ const funcName = match[1];
93
+ // 檢查是否為 camelCase(首字母小寫)
94
+ if (!/^[a-z][a-zA-Z0-9]*$/.test(funcName)) {
95
+ count++;
96
+ }
97
+ }
98
+ // 變數命名(let、var)
99
+ const varRegex = /(let|var)\s+([a-zA-Z_][a-zA-Z0-9_]*)/g;
100
+ while ((match = varRegex.exec(content)) !== null) {
101
+ const varName = match[2];
102
+ // 允許 UPPER_CASE 常數
103
+ const isUpperCase = /^[A-Z][A-Z0-9_]*$/.test(varName);
104
+ const isCamelCase = /^[a-z][a-zA-Z0-9]*$/.test(varName);
105
+ if (!isUpperCase && !isCamelCase) {
106
+ count++;
107
+ }
108
+ }
109
+ return count;
110
+ }
111
+ /**
112
+ * 檢查底線開頭(非 private 不應該底線開頭)
113
+ */
114
+ checkUnderscorePrefix(content) {
115
+ let count = 0;
116
+ const lines = content.split('\n');
117
+ for (const line of lines) {
118
+ // 跳過 private 宣告(允許底線開頭)
119
+ if (/\bprivate\b/.test(line)) {
120
+ continue;
121
+ }
122
+ // 檢測底線開頭的變數或函式
123
+ const underscorePatterns = [
124
+ /(let|var)\s+_[a-zA-Z]/g,
125
+ /func\s+_[a-zA-Z]/g
126
+ ];
127
+ for (const pattern of underscorePatterns) {
128
+ const matches = line.match(pattern);
129
+ if (matches) {
130
+ count += matches.length * 2; // 權重 x2
131
+ }
132
+ }
133
+ }
134
+ return count;
135
+ }
136
+ /**
137
+ * 判斷是否為特殊檔案
138
+ */
139
+ isSpecialFile(filename) {
140
+ const specialFiles = [
141
+ 'Package.swift',
142
+ 'README.md',
143
+ 'LICENSE'
144
+ ];
145
+ return specialFiles.includes(filename);
146
+ }
147
+ /**
148
+ * 判斷是否為 Swift 檔案
149
+ */
150
+ isSwiftFile(file) {
151
+ return file.endsWith('.swift');
152
+ }
153
+ }
154
+ /**
155
+ * 預設導出檢查函式
156
+ */
157
+ export default async function checkNaming(files, fileContents) {
158
+ const checker = new NamingChecker();
159
+ return checker.check(files, fileContents);
160
+ }
161
+ //# sourceMappingURL=naming-checker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming-checker.js","sourceRoot":"","sources":["../../../../src/plugins/swift/analyzers/naming-checker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,KAAe,EAAE,YAAiC;QAC5D,IAAI,WAAW,GAAG,CAAC,CAAC;QAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,SAAS;YACX,CAAC;YAED,SAAS;YACT,WAAW,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,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AO,CAAC,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Swift 設計模式檢測器
3
+ * 檢測 Swift 設計模式和 SwiftUI 樣板
4
+ */
5
+ /**
6
+ * 模式類型
7
+ */
8
+ export declare enum PatternType {
9
+ Singleton = "singleton",
10
+ Factory = "factory",
11
+ Coordinator = "coordinator",
12
+ MVVM = "mvvm",
13
+ ProtocolWitness = "protocol-witness",
14
+ ViewBuilder = "view-builder",
15
+ StateManagement = "state-management"
16
+ }
17
+ /**
18
+ * 模式匹配結果
19
+ */
20
+ export interface PatternMatch {
21
+ readonly type: PatternType;
22
+ readonly file: string;
23
+ readonly startLine: number;
24
+ readonly endLine: number;
25
+ readonly code: string;
26
+ readonly similarity: number;
27
+ }
28
+ /**
29
+ * 模式群組
30
+ */
31
+ export interface PatternGroup {
32
+ readonly type: PatternType;
33
+ readonly instances: readonly PatternMatch[];
34
+ readonly count: number;
35
+ readonly recommendation: string;
36
+ }
37
+ /**
38
+ * Swift 模式檢測器
39
+ */
40
+ export declare class PatternDetector {
41
+ /**
42
+ * 檢測所有模式
43
+ */
44
+ detectAll(files: string[], fileContents: Map<string, string>): Promise<Map<PatternType, PatternGroup>>;
45
+ /**
46
+ * 檢測 Singleton 模式
47
+ */
48
+ private detectSingleton;
49
+ /**
50
+ * 檢測 Factory 模式
51
+ */
52
+ private detectFactory;
53
+ /**
54
+ * 檢測 MVVM 模式
55
+ */
56
+ private detectMVVM;
57
+ /**
58
+ * 檢測 ViewBuilder 模式
59
+ */
60
+ private detectViewBuilder;
61
+ /**
62
+ * 檢測 State Management 模式
63
+ */
64
+ private detectStateManagement;
65
+ /**
66
+ * 分組相似的模式
67
+ */
68
+ private groupSimilarPatterns;
69
+ /**
70
+ * 取得行號
71
+ */
72
+ private getLineNumber;
73
+ }
74
+ /**
75
+ * 預設導出檢測函式
76
+ */
77
+ export default function detectPatterns(files: string[], fileContents: Map<string, string>): Promise<Map<PatternType, PatternGroup>>;
78
+ //# sourceMappingURL=pattern-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-detector.d.ts","sourceRoot":"","sources":["../../../../src/plugins/swift/analyzers/pattern-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,WAAW;IACrB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,eAAe,qBAAqB;IACpC,WAAW,iBAAiB;IAC5B,eAAe,qBAAqB;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IA6D5G;;OAEG;YACW,eAAe;IA4B7B;;OAEG;YACW,aAAa;IA4B3B;;OAEG;YACW,UAAU;IA4BxB;;OAEG;YACW,iBAAiB;IA4B/B;;OAEG;YACW,qBAAqB;IAqCnC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;OAEG;IACH,OAAO,CAAC,aAAa;CAGtB;AAED;;GAEG;AACH,wBAA8B,cAAc,CAC1C,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAGzC"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Swift 設計模式檢測器
3
+ * 檢測 Swift 設計模式和 SwiftUI 樣板
4
+ */
5
+ /**
6
+ * 模式類型
7
+ */
8
+ export var PatternType;
9
+ (function (PatternType) {
10
+ PatternType["Singleton"] = "singleton";
11
+ PatternType["Factory"] = "factory";
12
+ PatternType["Coordinator"] = "coordinator";
13
+ PatternType["MVVM"] = "mvvm";
14
+ PatternType["ProtocolWitness"] = "protocol-witness";
15
+ PatternType["ViewBuilder"] = "view-builder";
16
+ PatternType["StateManagement"] = "state-management";
17
+ })(PatternType || (PatternType = {}));
18
+ /**
19
+ * Swift 模式檢測器
20
+ */
21
+ export class PatternDetector {
22
+ /**
23
+ * 檢測所有模式
24
+ */
25
+ async detectAll(files, fileContents) {
26
+ const results = new Map();
27
+ // Singleton 模式
28
+ const singletonMatches = await this.detectSingleton(files, fileContents);
29
+ if (singletonMatches.length > 0) {
30
+ results.set(PatternType.Singleton, {
31
+ type: PatternType.Singleton,
32
+ instances: singletonMatches,
33
+ count: singletonMatches.length,
34
+ recommendation: 'Singleton 模式適合全域共用資源,但要注意測試困難度'
35
+ });
36
+ }
37
+ // Factory 模式
38
+ const factoryMatches = await this.detectFactory(files, fileContents);
39
+ if (factoryMatches.length > 0) {
40
+ results.set(PatternType.Factory, {
41
+ type: PatternType.Factory,
42
+ instances: factoryMatches,
43
+ count: factoryMatches.length,
44
+ recommendation: 'Factory 模式良好分離物件創建邏輯'
45
+ });
46
+ }
47
+ // MVVM 模式
48
+ const mvvmMatches = await this.detectMVVM(files, fileContents);
49
+ if (mvvmMatches.length > 0) {
50
+ results.set(PatternType.MVVM, {
51
+ type: PatternType.MVVM,
52
+ instances: mvvmMatches,
53
+ count: mvvmMatches.length,
54
+ recommendation: 'MVVM 是 SwiftUI 推薦架構'
55
+ });
56
+ }
57
+ // SwiftUI ViewBuilder
58
+ const viewBuilderMatches = await this.detectViewBuilder(files, fileContents);
59
+ if (viewBuilderMatches.length > 0) {
60
+ results.set(PatternType.ViewBuilder, {
61
+ type: PatternType.ViewBuilder,
62
+ instances: viewBuilderMatches,
63
+ count: viewBuilderMatches.length,
64
+ recommendation: '@ViewBuilder 用於建構複雜 View 層級'
65
+ });
66
+ }
67
+ // State Management
68
+ const stateMatches = await this.detectStateManagement(files, fileContents);
69
+ if (stateMatches.length > 0) {
70
+ results.set(PatternType.StateManagement, {
71
+ type: PatternType.StateManagement,
72
+ instances: stateMatches,
73
+ count: stateMatches.length,
74
+ recommendation: '使用適當的 property wrapper 管理狀態'
75
+ });
76
+ }
77
+ return results;
78
+ }
79
+ /**
80
+ * 檢測 Singleton 模式
81
+ */
82
+ async detectSingleton(files, fileContents) {
83
+ const matches = [];
84
+ const singletonRegex = /static\s+let\s+shared\s*=\s*\w+\s*\(\)/g;
85
+ for (const file of files) {
86
+ const content = fileContents.get(file);
87
+ if (!content) {
88
+ continue;
89
+ }
90
+ let match;
91
+ while ((match = singletonRegex.exec(content)) !== null) {
92
+ const lineNumber = this.getLineNumber(content, match.index);
93
+ matches.push({
94
+ type: PatternType.Singleton,
95
+ file,
96
+ startLine: lineNumber,
97
+ endLine: lineNumber,
98
+ code: match[0],
99
+ similarity: 0.95
100
+ });
101
+ }
102
+ }
103
+ return this.groupSimilarPatterns(matches);
104
+ }
105
+ /**
106
+ * 檢測 Factory 模式
107
+ */
108
+ async detectFactory(files, fileContents) {
109
+ const matches = [];
110
+ const factoryRegex = /func\s+make\w+\s*\([^)]*\)\s*->\s*\w+/g;
111
+ for (const file of files) {
112
+ const content = fileContents.get(file);
113
+ if (!content) {
114
+ continue;
115
+ }
116
+ let match;
117
+ while ((match = factoryRegex.exec(content)) !== null) {
118
+ const lineNumber = this.getLineNumber(content, match.index);
119
+ matches.push({
120
+ type: PatternType.Factory,
121
+ file,
122
+ startLine: lineNumber,
123
+ endLine: lineNumber,
124
+ code: match[0],
125
+ similarity: 0.9
126
+ });
127
+ }
128
+ }
129
+ return this.groupSimilarPatterns(matches);
130
+ }
131
+ /**
132
+ * 檢測 MVVM 模式
133
+ */
134
+ async detectMVVM(files, fileContents) {
135
+ const matches = [];
136
+ const viewModelRegex = /class\s+\w+ViewModel\s*:\s*ObservableObject/g;
137
+ for (const file of files) {
138
+ const content = fileContents.get(file);
139
+ if (!content) {
140
+ continue;
141
+ }
142
+ let match;
143
+ while ((match = viewModelRegex.exec(content)) !== null) {
144
+ const lineNumber = this.getLineNumber(content, match.index);
145
+ matches.push({
146
+ type: PatternType.MVVM,
147
+ file,
148
+ startLine: lineNumber,
149
+ endLine: lineNumber,
150
+ code: match[0],
151
+ similarity: 0.95
152
+ });
153
+ }
154
+ }
155
+ return this.groupSimilarPatterns(matches);
156
+ }
157
+ /**
158
+ * 檢測 ViewBuilder 模式
159
+ */
160
+ async detectViewBuilder(files, fileContents) {
161
+ const matches = [];
162
+ const viewBuilderRegex = /@ViewBuilder\s+(var|func)/g;
163
+ for (const file of files) {
164
+ const content = fileContents.get(file);
165
+ if (!content) {
166
+ continue;
167
+ }
168
+ let match;
169
+ while ((match = viewBuilderRegex.exec(content)) !== null) {
170
+ const lineNumber = this.getLineNumber(content, match.index);
171
+ matches.push({
172
+ type: PatternType.ViewBuilder,
173
+ file,
174
+ startLine: lineNumber,
175
+ endLine: lineNumber,
176
+ code: match[0],
177
+ similarity: 1.0
178
+ });
179
+ }
180
+ }
181
+ return this.groupSimilarPatterns(matches);
182
+ }
183
+ /**
184
+ * 檢測 State Management 模式
185
+ */
186
+ async detectStateManagement(files, fileContents) {
187
+ const matches = [];
188
+ const statePatterns = [
189
+ /@State\s+/g,
190
+ /@Published\s+/g,
191
+ /@Binding\s+/g,
192
+ /@ObservedObject\s+/g,
193
+ /@StateObject\s+/g,
194
+ /@EnvironmentObject\s+/g
195
+ ];
196
+ for (const file of files) {
197
+ const content = fileContents.get(file);
198
+ if (!content) {
199
+ continue;
200
+ }
201
+ for (const pattern of statePatterns) {
202
+ let match;
203
+ while ((match = pattern.exec(content)) !== null) {
204
+ const lineNumber = this.getLineNumber(content, match.index);
205
+ matches.push({
206
+ type: PatternType.StateManagement,
207
+ file,
208
+ startLine: lineNumber,
209
+ endLine: lineNumber,
210
+ code: match[0],
211
+ similarity: 0.9
212
+ });
213
+ }
214
+ }
215
+ }
216
+ return this.groupSimilarPatterns(matches);
217
+ }
218
+ /**
219
+ * 分組相似的模式
220
+ */
221
+ groupSimilarPatterns(matches) {
222
+ const seen = new Set();
223
+ const grouped = [];
224
+ for (const match of matches) {
225
+ const key = `${match.file}:${match.startLine}`;
226
+ if (!seen.has(key)) {
227
+ seen.add(key);
228
+ grouped.push(match);
229
+ }
230
+ }
231
+ return grouped;
232
+ }
233
+ /**
234
+ * 取得行號
235
+ */
236
+ getLineNumber(content, index) {
237
+ return content.substring(0, index).split('\n').length;
238
+ }
239
+ }
240
+ /**
241
+ * 預設導出檢測函式
242
+ */
243
+ export default async function detectPatterns(files, fileContents) {
244
+ const detector = new PatternDetector();
245
+ return detector.detectAll(files, fileContents);
246
+ }
247
+ //# sourceMappingURL=pattern-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-detector.js","sourceRoot":"","sources":["../../../../src/plugins/swift/analyzers/pattern-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,kCAAmB,CAAA;IACnB,0CAA2B,CAAA;IAC3B,4BAAa,CAAA;IACb,mDAAoC,CAAA;IACpC,2CAA4B,CAAA;IAC5B,mDA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* Swift 安全性檢查器
7
+ */
8
+ export declare class SecurityChecker {
9
+ /**
10
+ * 檢查檔案的安全性問題
11
+ */
12
+ check(files: string[], fileContents: Map<string, string>): Promise<number>;
13
+ /**
14
+ * 檢測硬編碼的密碼和 API Key
15
+ */
16
+ private checkHardcodedSecrets;
17
+ /**
18
+ * 檢測 UserDefaults 儲存敏感資料
19
+ */
20
+ private checkUserDefaultsSecrets;
21
+ /**
22
+ * 檢測不安全的 HTTP 請求(非 HTTPS)
23
+ */
24
+ private checkInsecureHTTP;
25
+ /**
26
+ * 檢測 print 包含敏感資訊
27
+ */
28
+ private checkPrintSecrets;
29
+ /**
30
+ * 判斷是否為 Swift 檔案
31
+ */
32
+ private isSwiftFile;
33
+ }
34
+ /**
35
+ * 預設導出檢查函式
36
+ */
37
+ export default function checkSecurity(files: string[], fileContents: Map<string, string>): Promise<number>;
38
+ //# sourceMappingURL=security-checker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-checker.d.ts","sourceRoot":"","sources":["../../../../src/plugins/swift/analyzers/security-checker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAgChF;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA4B7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAqBzB;;OAEG;IACH,OAAO,CAAC,WAAW;CAGpB;AAED;;GAEG;AACH,wBAA8B,aAAa,CACzC,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAGjB"}