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,240 @@
1
+ /**
2
+ * ShitScore 評分計算器
3
+ * 負責計算三大維度的垃圾度評分並計算總分
4
+ */
5
+ /**
6
+ * 評分計算器
7
+ */
8
+ export class ScoreCalculator {
9
+ /**
10
+ * 計算總分(四個維度)
11
+ */
12
+ calculate(complexity, maintainability, architecture, qualityAssurance) {
13
+ const complexityScore = this.calculateComplexityShit(complexity);
14
+ const maintainabilityScore = this.calculateMaintainabilityShit(maintainability);
15
+ const architectureScore = this.calculateArchitectureShit(architecture);
16
+ const qualityAssuranceScore = this.calculateQualityAssuranceShit(qualityAssurance);
17
+ const totalScore = this.calculateTotalScore(complexityScore, maintainabilityScore, architectureScore, qualityAssuranceScore);
18
+ return {
19
+ complexityScore,
20
+ maintainabilityScore,
21
+ architectureScore,
22
+ qualityAssuranceScore,
23
+ totalScore,
24
+ };
25
+ }
26
+ /**
27
+ * 計算複雜度垃圾(30%)
28
+ * complexityShit = (
29
+ * highComplexityRatio * 0.4 +
30
+ * longFunctionRatio * 0.25 +
31
+ * deepNestingRatio * 0.2 +
32
+ * tooManyParamsRatio * 0.15
33
+ * ) * 100
34
+ */
35
+ calculateComplexityShit(data) {
36
+ const total = data.totalFunctions;
37
+ if (total === 0) {
38
+ return {
39
+ dimension: 'complexity',
40
+ score: 0,
41
+ weight: 0.3,
42
+ weightedScore: 0,
43
+ breakdown: {
44
+ highComplexity: 0,
45
+ longFunction: 0,
46
+ deepNesting: 0,
47
+ tooManyParams: 0,
48
+ },
49
+ };
50
+ }
51
+ const highComplexityRatio = data.highComplexityCount / total;
52
+ const longFunctionRatio = data.longFunctionCount / total;
53
+ const deepNestingRatio = data.deepNestingCount / total;
54
+ const tooManyParamsRatio = data.tooManyParamsCount / total;
55
+ const score = this.round((highComplexityRatio * 0.4 +
56
+ longFunctionRatio * 0.25 +
57
+ deepNestingRatio * 0.2 +
58
+ tooManyParamsRatio * 0.15) *
59
+ 100);
60
+ return {
61
+ dimension: 'complexity',
62
+ score,
63
+ weight: 0.3,
64
+ weightedScore: this.round(score * 0.3),
65
+ breakdown: {
66
+ highComplexity: this.round(highComplexityRatio * 100),
67
+ longFunction: this.round(longFunctionRatio * 100),
68
+ deepNesting: this.round(deepNestingRatio * 100),
69
+ tooManyParams: this.round(tooManyParamsRatio * 100),
70
+ },
71
+ };
72
+ }
73
+ /**
74
+ * 計算維護性垃圾(30%)
75
+ * maintainabilityShit = (
76
+ * deadCodeRatio * 0.35 +
77
+ * largeFileRatio * 0.2 +
78
+ * duplicateCodeRatio * 0.2 +
79
+ * patternDuplicationRatio * 0.25
80
+ * ) * 100
81
+ */
82
+ calculateMaintainabilityShit(data) {
83
+ const total = data.totalFiles;
84
+ if (total === 0) {
85
+ return {
86
+ dimension: 'maintainability',
87
+ score: 0,
88
+ weight: 0.3,
89
+ weightedScore: 0,
90
+ breakdown: {
91
+ deadCode: 0,
92
+ largeFile: 0,
93
+ duplicateCode: 0,
94
+ patternDuplication: 0,
95
+ },
96
+ };
97
+ }
98
+ // 原始比例(可能超過 100%,用於 breakdown 顯示)
99
+ const deadCodeRatio = data.deadCodeCount / total;
100
+ const largeFileRatio = data.largeFileCount / total;
101
+ const duplicateCodeRatio = data.duplicateCodeCount / total;
102
+ const patternDuplicationRatio = data.patternDuplicationCount / total;
103
+ // 限制比例上限為 100%,用於計算分數
104
+ const deadCodeRatioCapped = Math.min(deadCodeRatio, 1);
105
+ const largeFileRatioCapped = Math.min(largeFileRatio, 1);
106
+ const duplicateCodeRatioCapped = Math.min(duplicateCodeRatio, 1);
107
+ const patternDuplicationRatioCapped = Math.min(patternDuplicationRatio, 1);
108
+ const score = this.round((deadCodeRatioCapped * 0.35 +
109
+ largeFileRatioCapped * 0.2 +
110
+ duplicateCodeRatioCapped * 0.2 +
111
+ patternDuplicationRatioCapped * 0.25) *
112
+ 100);
113
+ return {
114
+ dimension: 'maintainability',
115
+ score,
116
+ weight: 0.3,
117
+ weightedScore: this.round(score * 0.3),
118
+ breakdown: {
119
+ deadCode: this.round(deadCodeRatio * 100),
120
+ largeFile: this.round(largeFileRatio * 100),
121
+ duplicateCode: this.round(duplicateCodeRatio * 100),
122
+ patternDuplication: this.round(patternDuplicationRatio * 100),
123
+ },
124
+ };
125
+ }
126
+ /**
127
+ * 計算架構垃圾(30%)
128
+ * architectureShit = (
129
+ * min(cyclicDependencies * 10, 100) * 0.6 +
130
+ * orphanFileRatio * 0.25 +
131
+ * highCouplingRatio * 0.15
132
+ * )
133
+ */
134
+ calculateArchitectureShit(data) {
135
+ const total = data.totalFiles;
136
+ if (total === 0) {
137
+ return {
138
+ dimension: 'architecture',
139
+ score: 0,
140
+ weight: 0.3,
141
+ weightedScore: 0,
142
+ breakdown: {
143
+ circularDependency: 0,
144
+ orphanFile: 0,
145
+ highCoupling: 0,
146
+ },
147
+ };
148
+ }
149
+ const cyclicScore = Math.min(data.circularDependencyCount * 10, 100);
150
+ const orphanFileRatio = data.orphanFileCount / total;
151
+ const highCouplingRatio = data.highCouplingCount / total;
152
+ const score = this.round(cyclicScore * 0.6 + orphanFileRatio * 0.25 * 100 + highCouplingRatio * 0.15 * 100);
153
+ return {
154
+ dimension: 'architecture',
155
+ score,
156
+ weight: 0.3,
157
+ weightedScore: this.round(score * 0.3),
158
+ breakdown: {
159
+ circularDependency: cyclicScore,
160
+ orphanFile: this.round(orphanFileRatio * 100),
161
+ highCoupling: this.round(highCouplingRatio * 100),
162
+ },
163
+ };
164
+ }
165
+ /**
166
+ * 計算品質保證垃圾(20%)
167
+ * qualityAssuranceShit = (
168
+ * typeSafetyScore * 0.3 +
169
+ * testCoverageScore * 0.25 +
170
+ * errorHandlingScore * 0.2 +
171
+ * namingScore * 0.15 +
172
+ * securityScore * 0.1
173
+ * ) * 100
174
+ */
175
+ calculateQualityAssuranceShit(data) {
176
+ const total = data.totalFiles;
177
+ if (total === 0) {
178
+ return {
179
+ dimension: 'qualityAssurance',
180
+ score: 0,
181
+ weight: 0.2,
182
+ weightedScore: 0,
183
+ breakdown: {
184
+ typeSafety: 0,
185
+ testCoverage: 0,
186
+ errorHandling: 0,
187
+ naming: 0,
188
+ security: 0,
189
+ },
190
+ };
191
+ }
192
+ // 1. 型別安全評分(30%)
193
+ const typeSafetyScore = Math.min((data.typeSafetyIssues / total) * 100, 100);
194
+ // 2. 測試覆蓋率評分(25%)- 反向評分
195
+ const testCoverageScore = (1 - data.testCoverageRatio) * 100;
196
+ // 3. 錯誤處理評分(20%)
197
+ const errorHandlingScore = Math.min((data.errorHandlingIssues / total) * 100, 100);
198
+ // 4. 命名規範評分(15%)
199
+ const namingScore = Math.min((data.namingIssues / total) * 100, 100);
200
+ // 5. 安全性評分(10%)
201
+ const securityScore = Math.min((data.securityIssues / total) * 100, 100);
202
+ const score = this.round(typeSafetyScore * 0.3 +
203
+ testCoverageScore * 0.25 +
204
+ errorHandlingScore * 0.2 +
205
+ namingScore * 0.15 +
206
+ securityScore * 0.1);
207
+ return {
208
+ dimension: 'qualityAssurance',
209
+ score,
210
+ weight: 0.2,
211
+ weightedScore: this.round(score * 0.2),
212
+ breakdown: {
213
+ typeSafety: this.round(typeSafetyScore),
214
+ testCoverage: this.round(testCoverageScore),
215
+ errorHandling: this.round(errorHandlingScore),
216
+ naming: this.round(namingScore),
217
+ security: this.round(securityScore),
218
+ },
219
+ };
220
+ }
221
+ /**
222
+ * 計算總分
223
+ * shitScore = (
224
+ * complexityShit * 0.3 +
225
+ * maintainabilityShit * 0.3 +
226
+ * architectureShit * 0.3 +
227
+ * qualityAssuranceShit * 0.2
228
+ * )
229
+ */
230
+ calculateTotalScore(complexity, maintainability, architecture, qualityAssurance) {
231
+ return this.round(complexity.weightedScore + maintainability.weightedScore + architecture.weightedScore + qualityAssurance.weightedScore);
232
+ }
233
+ /**
234
+ * 四捨五入到小數點後 2 位
235
+ */
236
+ round(value) {
237
+ return Math.round(value * 100) / 100;
238
+ }
239
+ }
240
+ //# sourceMappingURL=score-calculator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score-calculator.js","sourceRoot":"","sources":["../../../src/core/shit-score/score-calculator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACH,SAAS,CAAC,UAA0B,EAAE,eAAoC,EAAE,YAA8B,EAAE,gBAAsC;QAOhJ,MAAM,eAAe,GAAG,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,oBAAoB,GAAG,IAAI,CAAC,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAChF,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;QACvE,MAAM,qBAAqB,GAAG,IAAI,CAAC,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;QAE7H,OAAO;YACL,eAAe;YACf,oBAAoB;YACpB,iBAAiB;YACjB,qBAAqB;YACrB,UAAU;SACX,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,uBAAuB,CAAC,IAAoB;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC;QAElC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,OAAO;gBACL,SAAS,EAAE,YAAY;gBACvB,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,GAAG;gBACX,aAAa,EAAE,CAAC;gBAChB,SAAS,EAAE;oBACT,cAAc,EAAE,CAAC;oBACjB,YAAY,EAAE,CAAC;oBACf,WAAW,EAAE,CAAC;oBACd,aAAa,EAAE,CAAC;iBACj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,IAAI;YAClB,aAAa,GAAG,GAAG,CACtB,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,kBAAkB;YAC7B,KAAK;YACL,MAAM,EAAE,GAAG;YACX,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC;YACtC,SAAS,EAAE;gBACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;gBACvC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;gBAC3C,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;gBAC7C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;gBAC/B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,mBAAmB,CAAC,UAA0B,EAAE,eAA+B,EAAE,YAA4B,EAAE,gBAAgC;QAC7I,OAAO,IAAI,CAAC,KAAK,CACf,UAAU,CAAC,aAAa,GAAG,eAAe,CAAC,aAAa,GAAG,YAAY,CAAC,aAAa,GAAG,gBAAgB,CAAC,aAAa,CACvH,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,KAAa;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * ShitScore 分析器
3
+ * 主服務類別,整合所有分析功能(通過 ParserPlugin)
4
+ */
5
+ import type { ParserRegistry } from '../../infrastructure/parser/registry.js';
6
+ import type { ShitScoreResult, ShitScoreOptions } from './types.js';
7
+ /**
8
+ * ShitScore 錯誤
9
+ */
10
+ export declare class ShitScoreError extends Error {
11
+ readonly score: number;
12
+ readonly maxAllowed: number;
13
+ constructor(message: string, score: number, maxAllowed: number);
14
+ }
15
+ /**
16
+ * ShitScore 分析器
17
+ */
18
+ export declare class ShitScoreAnalyzer {
19
+ private readonly calculator;
20
+ private readonly grading;
21
+ private readonly parserRegistry;
22
+ constructor(parserRegistry: ParserRegistry);
23
+ /**
24
+ * 分析專案的垃圾度
25
+ */
26
+ analyze(projectPath: string, options: Partial<ShitScoreOptions>): Promise<ShitScoreResult>;
27
+ /**
28
+ * 收集專案檔案
29
+ */
30
+ private collectFiles;
31
+ /**
32
+ * 建立檔案分析快取(解析 AST 和提取 symbols)
33
+ */
34
+ private buildFileCache;
35
+ /**
36
+ * 收集複雜度資料(使用 parser.analyzeComplexity)
37
+ */
38
+ private collectComplexityData;
39
+ /**
40
+ * 收集維護性資料(使用 parser 方法)
41
+ */
42
+ private collectMaintainabilityData;
43
+ /**
44
+ * 檢測代碼重複(簡化版 DuplicationDetector)
45
+ */
46
+ private detectDuplication;
47
+ /**
48
+ * 收集架構資料
49
+ */
50
+ private collectArchitectureData;
51
+ /**
52
+ * 收集品質保證資料(使用 parser checker 方法)
53
+ */
54
+ private collectQualityAssuranceData;
55
+ /**
56
+ * 檢查 tsconfig.json 的 strict 設定
57
+ */
58
+ private checkTsConfigStrict;
59
+ /**
60
+ * 建立詳細結果
61
+ */
62
+ private buildDetailedResult;
63
+ /**
64
+ * 提取最嚴重的垃圾項目
65
+ */
66
+ private extractTopShit;
67
+ /**
68
+ * 收集詳細檔案列表
69
+ */
70
+ private collectDetailedFiles;
71
+ /**
72
+ * 檢測循環依賴
73
+ */
74
+ private detectCycles;
75
+ /**
76
+ * 計算孤立檔案數量
77
+ */
78
+ private countOrphans;
79
+ /**
80
+ * 計算高耦合檔案數量
81
+ */
82
+ private countHighCoupling;
83
+ }
84
+ //# sourceMappingURL=shit-score-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shit-score-analyzer.d.ts","sourceRoot":"","sources":["../../../src/core/shit-score/shit-score-analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAI9E,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAQjB,MAAM,YAAY,CAAC;AAIpB;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;aACM,KAAK,EAAE,MAAM;aAAkB,UAAU,EAAE,MAAM;gBAAlF,OAAO,EAAE,MAAM,EAAkB,KAAK,EAAE,MAAM,EAAkB,UAAU,EAAE,MAAM;CAI/F;AAYD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;gBAEpC,cAAc,EAAE,cAAc;IAM1C;;OAEG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAmDhG;;OAEG;YACW,YAAY;IA8B1B;;OAEG;YACW,cAAc;IAuB5B;;OAEG;YACW,qBAAqB;IA8CnC;;OAEG;YACW,0BAA0B;IAwDxC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA6BzB;;OAEG;YACW,uBAAuB;IAkCrC;;OAEG;YACW,2BAA2B;IAuDzC;;OAEG;YACW,mBAAmB;IAejC;;OAEG;YACW,mBAAmB;IAuCjC;;OAEG;YACW,cAAc;IA0F5B;;OAEG;YACW,oBAAoB;IA+FlC;;OAEG;IACH,OAAO,CAAC,YAAY;IAcpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBpB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAS1B"}