agent-ide 0.2.0 → 0.4.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 (543) hide show
  1. package/README.md +29 -355
  2. package/dist/application/events/event-bus.d.ts.map +1 -1
  3. package/dist/application/events/event-bus.js.map +1 -1
  4. package/dist/application/index.d.ts +3 -1
  5. package/dist/application/index.d.ts.map +1 -1
  6. package/dist/application/index.js +10 -5
  7. package/dist/application/index.js.map +1 -1
  8. package/dist/application/services/cache-coordinator.service.d.ts.map +1 -1
  9. package/dist/application/services/cache-coordinator.service.js.map +1 -1
  10. package/dist/application/services/error-handler.service.d.ts.map +1 -1
  11. package/dist/application/services/error-handler.service.js.map +1 -1
  12. package/dist/application/services/module-coordinator.service.d.ts +5 -14
  13. package/dist/application/services/module-coordinator.service.d.ts.map +1 -1
  14. package/dist/application/services/module-coordinator.service.js +15 -108
  15. package/dist/application/services/module-coordinator.service.js.map +1 -1
  16. package/dist/application/services/session-manager.service.d.ts.map +1 -1
  17. package/dist/application/services/session-manager.service.js.map +1 -1
  18. package/dist/application/services/workflow-engine.service.d.ts +1 -1
  19. package/dist/application/services/workflow-engine.service.d.ts.map +1 -1
  20. package/dist/application/services/workflow-engine.service.js.map +1 -1
  21. package/dist/application/state/state-manager.d.ts +3 -3
  22. package/dist/application/state/state-manager.d.ts.map +1 -1
  23. package/dist/application/state/state-manager.js +3 -3
  24. package/dist/application/state/state-manager.js.map +1 -1
  25. package/dist/application/types.d.ts.map +1 -1
  26. package/dist/application/workflows/analysis-workflow.d.ts +1 -1
  27. package/dist/application/workflows/analysis-workflow.d.ts.map +1 -1
  28. package/dist/application/workflows/analysis-workflow.js +1 -1
  29. package/dist/application/workflows/analysis-workflow.js.map +1 -1
  30. package/dist/application/workflows/base-workflow.d.ts.map +1 -1
  31. package/dist/application/workflows/base-workflow.js.map +1 -1
  32. package/dist/application/workflows/index.d.ts +2 -2
  33. package/dist/application/workflows/index.d.ts.map +1 -1
  34. package/dist/application/workflows/index.js +2 -2
  35. package/dist/application/workflows/index.js.map +1 -1
  36. package/dist/application/workflows/refactor-workflow.d.ts +1 -1
  37. package/dist/application/workflows/refactor-workflow.d.ts.map +1 -1
  38. package/dist/application/workflows/refactor-workflow.js +1 -1
  39. package/dist/application/workflows/refactor-workflow.js.map +1 -1
  40. package/dist/core/change-signature/change-signature-service.d.ts +94 -0
  41. package/dist/core/change-signature/change-signature-service.d.ts.map +1 -0
  42. package/dist/core/change-signature/change-signature-service.js +544 -0
  43. package/dist/core/change-signature/change-signature-service.js.map +1 -0
  44. package/dist/core/change-signature/index.d.ts +10 -0
  45. package/dist/core/change-signature/index.d.ts.map +1 -0
  46. package/dist/core/change-signature/index.js +12 -0
  47. package/dist/core/change-signature/index.js.map +1 -0
  48. package/dist/core/change-signature/signature-parser.d.ts +76 -0
  49. package/dist/core/change-signature/signature-parser.d.ts.map +1 -0
  50. package/dist/core/change-signature/signature-parser.js +387 -0
  51. package/dist/core/change-signature/signature-parser.js.map +1 -0
  52. package/dist/core/change-signature/types.d.ts +244 -0
  53. package/dist/core/change-signature/types.d.ts.map +1 -0
  54. package/dist/core/change-signature/types.js +73 -0
  55. package/dist/core/change-signature/types.js.map +1 -0
  56. package/dist/core/dependency/cycle-detector.d.ts +1 -1
  57. package/dist/core/dependency/cycle-detector.d.ts.map +1 -1
  58. package/dist/core/dependency/cycle-detector.js +1 -1
  59. package/dist/core/dependency/cycle-detector.js.map +1 -1
  60. package/dist/core/dependency/dependency-analyzer.d.ts +3 -1
  61. package/dist/core/dependency/dependency-analyzer.d.ts.map +1 -1
  62. package/dist/core/dependency/dependency-analyzer.js +25 -24
  63. package/dist/core/dependency/dependency-analyzer.js.map +1 -1
  64. package/dist/core/dependency/types.d.ts.map +1 -1
  65. package/dist/core/indexing/file-index.d.ts.map +1 -1
  66. package/dist/core/indexing/file-index.js +1 -1
  67. package/dist/core/indexing/file-index.js.map +1 -1
  68. package/dist/core/indexing/index-engine.d.ts +3 -1
  69. package/dist/core/indexing/index-engine.d.ts.map +1 -1
  70. package/dist/core/indexing/index-engine.js +25 -17
  71. package/dist/core/indexing/index-engine.js.map +1 -1
  72. package/dist/core/indexing/index.d.ts +1 -9
  73. package/dist/core/indexing/index.d.ts.map +1 -1
  74. package/dist/core/indexing/index.js +2 -12
  75. package/dist/core/indexing/index.js.map +1 -1
  76. package/dist/core/indexing/symbol-index.d.ts.map +1 -1
  77. package/dist/core/indexing/types.d.ts +12 -0
  78. package/dist/core/indexing/types.d.ts.map +1 -1
  79. package/dist/core/indexing/types.js +12 -0
  80. package/dist/core/indexing/types.js.map +1 -1
  81. package/dist/core/move-file/import-resolver.d.ts.map +1 -0
  82. package/dist/core/{move → move-file}/import-resolver.js +9 -10
  83. package/dist/core/move-file/import-resolver.js.map +1 -0
  84. package/dist/core/{move → move-file}/index.d.ts +2 -2
  85. package/dist/core/move-file/index.d.ts.map +1 -0
  86. package/dist/core/{move → move-file}/index.js +2 -2
  87. package/dist/core/move-file/index.js.map +1 -0
  88. package/dist/core/{move → move-file}/move-service.d.ts +3 -1
  89. package/dist/core/move-file/move-service.d.ts.map +1 -0
  90. package/dist/core/{move → move-file}/move-service.js +66 -84
  91. package/dist/core/move-file/move-service.js.map +1 -0
  92. package/dist/core/move-file/types.d.ts.map +1 -0
  93. package/dist/core/move-file/types.js.map +1 -0
  94. package/dist/core/move-member/index.d.ts +10 -0
  95. package/dist/core/move-member/index.d.ts.map +1 -0
  96. package/dist/core/move-member/index.js +12 -0
  97. package/dist/core/move-member/index.js.map +1 -0
  98. package/dist/core/move-member/member-extractor.d.ts +96 -0
  99. package/dist/core/move-member/member-extractor.d.ts.map +1 -0
  100. package/dist/core/move-member/member-extractor.js +439 -0
  101. package/dist/core/move-member/member-extractor.js.map +1 -0
  102. package/dist/core/move-member/move-member-service.d.ts +87 -0
  103. package/dist/core/move-member/move-member-service.d.ts.map +1 -0
  104. package/dist/core/move-member/move-member-service.js +412 -0
  105. package/dist/core/move-member/move-member-service.js.map +1 -0
  106. package/dist/core/move-member/types.d.ts +182 -0
  107. package/dist/core/move-member/types.d.ts.map +1 -0
  108. package/dist/core/move-member/types.js +75 -0
  109. package/dist/core/move-member/types.js.map +1 -0
  110. package/dist/core/rename/index.d.ts +3 -3
  111. package/dist/core/rename/index.d.ts.map +1 -1
  112. package/dist/core/rename/index.js +5 -3
  113. package/dist/core/rename/index.js.map +1 -1
  114. package/dist/core/rename/reference-updater.d.ts +3 -1
  115. package/dist/core/rename/reference-updater.d.ts.map +1 -1
  116. package/dist/core/rename/reference-updater.js +9 -6
  117. package/dist/core/rename/reference-updater.js.map +1 -1
  118. package/dist/core/rename/rename-engine.d.ts +3 -1
  119. package/dist/core/rename/rename-engine.d.ts.map +1 -1
  120. package/dist/core/rename/rename-engine.js +8 -5
  121. package/dist/core/rename/rename-engine.js.map +1 -1
  122. package/dist/core/rename/scope-analyzer.d.ts.map +1 -1
  123. package/dist/core/rename/scope-analyzer.js.map +1 -1
  124. package/dist/core/rename/types.d.ts.map +1 -1
  125. package/dist/core/shared/call-hierarchy-analyzer.d.ts +102 -0
  126. package/dist/core/shared/call-hierarchy-analyzer.d.ts.map +1 -0
  127. package/dist/core/shared/call-hierarchy-analyzer.js +328 -0
  128. package/dist/core/shared/call-hierarchy-analyzer.js.map +1 -0
  129. package/dist/core/shared/index.d.ts +7 -0
  130. package/dist/core/shared/index.d.ts.map +1 -0
  131. package/dist/core/shared/index.js +7 -0
  132. package/dist/core/shared/index.js.map +1 -0
  133. package/dist/core/shared/symbol-finder.d.ts +154 -0
  134. package/dist/core/shared/symbol-finder.d.ts.map +1 -0
  135. package/dist/core/shared/symbol-finder.js +433 -0
  136. package/dist/core/shared/symbol-finder.js.map +1 -0
  137. package/dist/core/snapshot/index.d.ts +3 -19
  138. package/dist/core/snapshot/index.d.ts.map +1 -1
  139. package/dist/core/snapshot/index.js +2 -23
  140. package/dist/core/snapshot/index.js.map +1 -1
  141. package/dist/core/snapshot/snapshot-generator.d.ts +66 -0
  142. package/dist/core/snapshot/snapshot-generator.d.ts.map +1 -0
  143. package/dist/core/snapshot/snapshot-generator.js +258 -0
  144. package/dist/core/snapshot/snapshot-generator.js.map +1 -0
  145. package/dist/core/snapshot/types.d.ts +41 -190
  146. package/dist/core/snapshot/types.d.ts.map +1 -1
  147. package/dist/core/snapshot/types.js +13 -67
  148. package/dist/core/snapshot/types.js.map +1 -1
  149. package/dist/infrastructure/cache/cache-manager.d.ts +1 -1
  150. package/dist/infrastructure/cache/cache-manager.d.ts.map +1 -1
  151. package/dist/infrastructure/cache/cache-manager.js +1 -1
  152. package/dist/infrastructure/cache/cache-manager.js.map +1 -1
  153. package/dist/infrastructure/cache/memory-cache.js +1 -1
  154. package/dist/infrastructure/cache/memory-cache.js.map +1 -1
  155. package/dist/infrastructure/cache/strategies.d.ts +1 -1
  156. package/dist/infrastructure/cache/strategies.d.ts.map +1 -1
  157. package/dist/infrastructure/cache/strategies.js +1 -1
  158. package/dist/infrastructure/cache/strategies.js.map +1 -1
  159. package/dist/infrastructure/formatters/diff-generator.d.ts +11 -0
  160. package/dist/infrastructure/formatters/diff-generator.d.ts.map +1 -0
  161. package/dist/infrastructure/formatters/diff-generator.js +227 -0
  162. package/dist/infrastructure/formatters/diff-generator.js.map +1 -0
  163. package/dist/infrastructure/formatters/index.d.ts +11 -0
  164. package/dist/infrastructure/formatters/index.d.ts.map +1 -0
  165. package/dist/infrastructure/formatters/index.js +13 -0
  166. package/dist/infrastructure/formatters/index.js.map +1 -0
  167. package/dist/infrastructure/formatters/preview-converter.d.ts +85 -0
  168. package/dist/infrastructure/formatters/preview-converter.d.ts.map +1 -0
  169. package/dist/infrastructure/formatters/preview-converter.js +209 -0
  170. package/dist/infrastructure/formatters/preview-converter.js.map +1 -0
  171. package/dist/infrastructure/formatters/preview-formatter.d.ts +61 -0
  172. package/dist/infrastructure/formatters/preview-formatter.d.ts.map +1 -0
  173. package/dist/infrastructure/formatters/preview-formatter.js +208 -0
  174. package/dist/infrastructure/formatters/preview-formatter.js.map +1 -0
  175. package/dist/infrastructure/formatters/query-formatter.d.ts +83 -0
  176. package/dist/infrastructure/formatters/query-formatter.d.ts.map +1 -0
  177. package/dist/infrastructure/formatters/query-formatter.js +349 -0
  178. package/dist/infrastructure/formatters/query-formatter.js.map +1 -0
  179. package/dist/infrastructure/formatters/query-types.d.ts +238 -0
  180. package/dist/infrastructure/formatters/query-types.d.ts.map +1 -0
  181. package/dist/infrastructure/formatters/query-types.js +29 -0
  182. package/dist/infrastructure/formatters/query-types.js.map +1 -0
  183. package/dist/infrastructure/formatters/types.d.ts +163 -0
  184. package/dist/infrastructure/formatters/types.d.ts.map +1 -0
  185. package/dist/infrastructure/formatters/types.js +27 -0
  186. package/dist/infrastructure/formatters/types.js.map +1 -0
  187. package/dist/infrastructure/parser/base.d.ts +1 -33
  188. package/dist/infrastructure/parser/base.d.ts.map +1 -1
  189. package/dist/infrastructure/parser/base.js +1 -65
  190. package/dist/infrastructure/parser/base.js.map +1 -1
  191. package/dist/infrastructure/parser/index.d.ts +0 -2
  192. package/dist/infrastructure/parser/index.d.ts.map +1 -1
  193. package/dist/infrastructure/parser/index.js +1 -2
  194. package/dist/infrastructure/parser/index.js.map +1 -1
  195. package/dist/infrastructure/parser/interface.d.ts +2 -59
  196. package/dist/infrastructure/parser/interface.d.ts.map +1 -1
  197. package/dist/infrastructure/parser/interface.js +1 -11
  198. package/dist/infrastructure/parser/interface.js.map +1 -1
  199. package/dist/infrastructure/parser/registry.d.ts +1 -1
  200. package/dist/infrastructure/parser/registry.d.ts.map +1 -1
  201. package/dist/infrastructure/parser/registry.js +1 -1
  202. package/dist/infrastructure/parser/registry.js.map +1 -1
  203. package/dist/infrastructure/parser/types.d.ts.map +1 -1
  204. package/dist/infrastructure/storage/file-system.d.ts +2 -1
  205. package/dist/infrastructure/storage/file-system.d.ts.map +1 -1
  206. package/dist/infrastructure/storage/file-system.interface.d.ts +69 -0
  207. package/dist/infrastructure/storage/file-system.interface.d.ts.map +1 -0
  208. package/dist/infrastructure/storage/file-system.interface.js +6 -0
  209. package/dist/infrastructure/storage/file-system.interface.js.map +1 -0
  210. package/dist/infrastructure/storage/file-system.js.map +1 -1
  211. package/dist/infrastructure/storage/index.d.ts +2 -4
  212. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  213. package/dist/infrastructure/storage/index.js +1 -8
  214. package/dist/infrastructure/storage/index.js.map +1 -1
  215. package/dist/infrastructure/storage/mem-file-system.d.ts +44 -0
  216. package/dist/infrastructure/storage/mem-file-system.d.ts.map +1 -0
  217. package/dist/infrastructure/storage/mem-file-system.js +105 -0
  218. package/dist/infrastructure/storage/mem-file-system.js.map +1 -0
  219. package/dist/interfaces/cli/cli.d.ts +13 -94
  220. package/dist/interfaces/cli/cli.d.ts.map +1 -1
  221. package/dist/interfaces/cli/cli.js +47 -2450
  222. package/dist/interfaces/cli/cli.js.map +1 -1
  223. package/dist/interfaces/cli/commands/call-hierarchy.command.d.ts +11 -0
  224. package/dist/interfaces/cli/commands/call-hierarchy.command.d.ts.map +1 -0
  225. package/dist/interfaces/cli/commands/call-hierarchy.command.js +161 -0
  226. package/dist/interfaces/cli/commands/call-hierarchy.command.js.map +1 -0
  227. package/dist/interfaces/cli/commands/change-signature.command.d.ts +11 -0
  228. package/dist/interfaces/cli/commands/change-signature.command.d.ts.map +1 -0
  229. package/dist/interfaces/cli/commands/change-signature.command.js +290 -0
  230. package/dist/interfaces/cli/commands/change-signature.command.js.map +1 -0
  231. package/dist/interfaces/cli/commands/cycles.command.d.ts +11 -0
  232. package/dist/interfaces/cli/commands/cycles.command.d.ts.map +1 -0
  233. package/dist/interfaces/cli/commands/cycles.command.js +87 -0
  234. package/dist/interfaces/cli/commands/cycles.command.js.map +1 -0
  235. package/dist/interfaces/cli/commands/find-references.command.d.ts +11 -0
  236. package/dist/interfaces/cli/commands/find-references.command.d.ts.map +1 -0
  237. package/dist/interfaces/cli/commands/find-references.command.js +122 -0
  238. package/dist/interfaces/cli/commands/find-references.command.js.map +1 -0
  239. package/dist/interfaces/cli/commands/impact.command.d.ts +11 -0
  240. package/dist/interfaces/cli/commands/impact.command.d.ts.map +1 -0
  241. package/dist/interfaces/cli/commands/impact.command.js +98 -0
  242. package/dist/interfaces/cli/commands/impact.command.js.map +1 -0
  243. package/dist/interfaces/cli/commands/index.d.ts +14 -0
  244. package/dist/interfaces/cli/commands/index.d.ts.map +1 -0
  245. package/dist/interfaces/cli/commands/index.js +15 -0
  246. package/dist/interfaces/cli/commands/index.js.map +1 -0
  247. package/dist/interfaces/cli/commands/move-member.command.d.ts +11 -0
  248. package/dist/interfaces/cli/commands/move-member.command.d.ts.map +1 -0
  249. package/dist/interfaces/cli/commands/move-member.command.js +185 -0
  250. package/dist/interfaces/cli/commands/move-member.command.js.map +1 -0
  251. package/dist/interfaces/cli/commands/move.command.d.ts +11 -0
  252. package/dist/interfaces/cli/commands/move.command.d.ts.map +1 -0
  253. package/dist/interfaces/cli/commands/move.command.js +212 -0
  254. package/dist/interfaces/cli/commands/move.command.js.map +1 -0
  255. package/dist/interfaces/cli/commands/rename.command.d.ts +11 -0
  256. package/dist/interfaces/cli/commands/rename.command.d.ts.map +1 -0
  257. package/dist/interfaces/cli/commands/rename.command.js +258 -0
  258. package/dist/interfaces/cli/commands/rename.command.js.map +1 -0
  259. package/dist/interfaces/cli/commands/snapshot.command.d.ts +11 -0
  260. package/dist/interfaces/cli/commands/snapshot.command.d.ts.map +1 -0
  261. package/dist/interfaces/cli/commands/snapshot.command.js +68 -0
  262. package/dist/interfaces/cli/commands/snapshot.command.js.map +1 -0
  263. package/dist/interfaces/cli/commands/types.d.ts +18 -0
  264. package/dist/interfaces/cli/commands/types.d.ts.map +1 -0
  265. package/dist/interfaces/cli/commands/types.js +5 -0
  266. package/dist/interfaces/cli/commands/types.js.map +1 -0
  267. package/dist/interfaces/cli/index.d.ts +1 -1
  268. package/dist/interfaces/cli/index.d.ts.map +1 -1
  269. package/dist/interfaces/cli/index.js +1 -1
  270. package/dist/interfaces/cli/index.js.map +1 -1
  271. package/dist/interfaces/cli/preview-output-handler.d.ts +53 -0
  272. package/dist/interfaces/cli/preview-output-handler.d.ts.map +1 -0
  273. package/dist/interfaces/cli/preview-output-handler.js +73 -0
  274. package/dist/interfaces/cli/preview-output-handler.js.map +1 -0
  275. package/dist/interfaces/cli/unified-output-handler.d.ts +79 -0
  276. package/dist/interfaces/cli/unified-output-handler.d.ts.map +1 -0
  277. package/dist/interfaces/cli/unified-output-handler.js +149 -0
  278. package/dist/interfaces/cli/unified-output-handler.js.map +1 -0
  279. package/dist/plugins/javascript/index.d.ts +2 -2
  280. package/dist/plugins/javascript/index.d.ts.map +1 -1
  281. package/dist/plugins/javascript/index.js +1 -1
  282. package/dist/plugins/javascript/index.js.map +1 -1
  283. package/dist/plugins/javascript/types.d.ts.map +1 -1
  284. package/dist/plugins/javascript/types.js.map +1 -1
  285. package/dist/plugins/python/dependency-analyzer.d.ts +86 -0
  286. package/dist/plugins/python/dependency-analyzer.d.ts.map +1 -0
  287. package/dist/plugins/python/dependency-analyzer.js +252 -0
  288. package/dist/plugins/python/dependency-analyzer.js.map +1 -0
  289. package/dist/plugins/python/index.d.ts +9 -0
  290. package/dist/plugins/python/index.d.ts.map +1 -0
  291. package/dist/plugins/python/index.js +14 -0
  292. package/dist/plugins/python/index.js.map +1 -0
  293. package/dist/plugins/python/parser.d.ts +117 -0
  294. package/dist/plugins/python/parser.d.ts.map +1 -0
  295. package/dist/plugins/python/parser.js +414 -0
  296. package/dist/plugins/python/parser.js.map +1 -0
  297. package/dist/plugins/python/symbol-extractor.d.ts +108 -0
  298. package/dist/plugins/python/symbol-extractor.d.ts.map +1 -0
  299. package/dist/plugins/python/symbol-extractor.js +389 -0
  300. package/dist/plugins/python/symbol-extractor.js.map +1 -0
  301. package/dist/plugins/python/tree-sitter-bridge.d.ts +57 -0
  302. package/dist/plugins/python/tree-sitter-bridge.d.ts.map +1 -0
  303. package/dist/plugins/python/tree-sitter-bridge.js +267 -0
  304. package/dist/plugins/python/tree-sitter-bridge.js.map +1 -0
  305. package/dist/plugins/python/types.d.ts +179 -0
  306. package/dist/plugins/python/types.d.ts.map +1 -0
  307. package/dist/plugins/python/types.js +252 -0
  308. package/dist/plugins/python/types.js.map +1 -0
  309. package/dist/plugins/swift/dependency-analyzer.d.ts +1 -1
  310. package/dist/plugins/swift/dependency-analyzer.d.ts.map +1 -1
  311. package/dist/plugins/swift/dependency-analyzer.js +1 -1
  312. package/dist/plugins/swift/dependency-analyzer.js.map +1 -1
  313. package/dist/plugins/swift/parser.d.ts +4 -0
  314. package/dist/plugins/swift/parser.d.ts.map +1 -1
  315. package/dist/plugins/swift/parser.js +24 -6
  316. package/dist/plugins/swift/parser.js.map +1 -1
  317. package/dist/plugins/swift/symbol-extractor.d.ts +1 -1
  318. package/dist/plugins/swift/symbol-extractor.d.ts.map +1 -1
  319. package/dist/plugins/swift/symbol-extractor.js.map +1 -1
  320. package/dist/plugins/swift/types.d.ts.map +1 -1
  321. package/dist/plugins/swift/types.js.map +1 -1
  322. package/dist/plugins/typescript/parser.d.ts +4 -37
  323. package/dist/plugins/typescript/parser.d.ts.map +1 -1
  324. package/dist/plugins/typescript/parser.js +29 -331
  325. package/dist/plugins/typescript/parser.js.map +1 -1
  326. package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -1
  327. package/dist/plugins/typescript/symbol-extractor.js +12 -0
  328. package/dist/plugins/typescript/symbol-extractor.js.map +1 -1
  329. package/dist/plugins/typescript/types.d.ts.map +1 -1
  330. package/dist/plugins/typescript/types.js +10 -0
  331. package/dist/plugins/typescript/types.js.map +1 -1
  332. package/dist/shared/errors/config-error.d.ts +1 -1
  333. package/dist/shared/errors/config-error.d.ts.map +1 -1
  334. package/dist/shared/errors/config-error.js +1 -1
  335. package/dist/shared/errors/config-error.js.map +1 -1
  336. package/dist/shared/errors/file-error.d.ts +1 -1
  337. package/dist/shared/errors/file-error.d.ts.map +1 -1
  338. package/dist/shared/errors/file-error.js +1 -1
  339. package/dist/shared/errors/file-error.js.map +1 -1
  340. package/dist/shared/errors/index.d.ts +1 -1
  341. package/dist/shared/errors/index.d.ts.map +1 -1
  342. package/dist/shared/errors/index.js +4 -4
  343. package/dist/shared/errors/index.js.map +1 -1
  344. package/dist/shared/errors/parser-error.d.ts +1 -1
  345. package/dist/shared/errors/parser-error.d.ts.map +1 -1
  346. package/dist/shared/errors/parser-error.js +1 -1
  347. package/dist/shared/errors/parser-error.js.map +1 -1
  348. package/dist/shared/errors/validation-error.d.ts +1 -1
  349. package/dist/shared/errors/validation-error.d.ts.map +1 -1
  350. package/dist/shared/errors/validation-error.js +1 -1
  351. package/dist/shared/errors/validation-error.js.map +1 -1
  352. package/dist/shared/types/ast.d.ts +1 -1
  353. package/dist/shared/types/ast.d.ts.map +1 -1
  354. package/dist/shared/types/ast.js +1 -1
  355. package/dist/shared/types/ast.js.map +1 -1
  356. package/dist/shared/types/symbol.d.ts +3 -2
  357. package/dist/shared/types/symbol.d.ts.map +1 -1
  358. package/dist/shared/types/symbol.js +1 -0
  359. package/dist/shared/types/symbol.js.map +1 -1
  360. package/dist/shared/utils/index.d.ts +5 -5
  361. package/dist/shared/utils/index.d.ts.map +1 -1
  362. package/dist/shared/utils/index.js +5 -5
  363. package/dist/shared/utils/index.js.map +1 -1
  364. package/package.json +9 -8
  365. package/dist/core/analysis/index.d.ts +0 -6
  366. package/dist/core/analysis/index.d.ts.map +0 -1
  367. package/dist/core/analysis/index.js +0 -7
  368. package/dist/core/analysis/index.js.map +0 -1
  369. package/dist/core/analysis/quality-metrics.d.ts +0 -158
  370. package/dist/core/analysis/quality-metrics.d.ts.map +0 -1
  371. package/dist/core/analysis/quality-metrics.js +0 -442
  372. package/dist/core/analysis/quality-metrics.js.map +0 -1
  373. package/dist/core/indexing/file-watcher.d.ts +0 -110
  374. package/dist/core/indexing/file-watcher.d.ts.map +0 -1
  375. package/dist/core/indexing/file-watcher.js +0 -280
  376. package/dist/core/indexing/file-watcher.js.map +0 -1
  377. package/dist/core/move/import-resolver.d.ts.map +0 -1
  378. package/dist/core/move/import-resolver.js.map +0 -1
  379. package/dist/core/move/index.d.ts.map +0 -1
  380. package/dist/core/move/index.js.map +0 -1
  381. package/dist/core/move/move-service.d.ts.map +0 -1
  382. package/dist/core/move/move-service.js.map +0 -1
  383. package/dist/core/move/types.d.ts.map +0 -1
  384. package/dist/core/move/types.js.map +0 -1
  385. package/dist/core/refactor/design-patterns.d.ts +0 -178
  386. package/dist/core/refactor/design-patterns.d.ts.map +0 -1
  387. package/dist/core/refactor/design-patterns.js +0 -656
  388. package/dist/core/refactor/design-patterns.js.map +0 -1
  389. package/dist/core/refactor/extract-function.d.ts +0 -197
  390. package/dist/core/refactor/extract-function.d.ts.map +0 -1
  391. package/dist/core/refactor/extract-function.js +0 -730
  392. package/dist/core/refactor/extract-function.js.map +0 -1
  393. package/dist/core/refactor/index.d.ts +0 -8
  394. package/dist/core/refactor/index.d.ts.map +0 -1
  395. package/dist/core/refactor/index.js +0 -11
  396. package/dist/core/refactor/index.js.map +0 -1
  397. package/dist/core/refactor/inline-function.d.ts +0 -175
  398. package/dist/core/refactor/inline-function.d.ts.map +0 -1
  399. package/dist/core/refactor/inline-function.js +0 -425
  400. package/dist/core/refactor/inline-function.js.map +0 -1
  401. package/dist/core/refactor/swift-extractor.d.ts +0 -98
  402. package/dist/core/refactor/swift-extractor.d.ts.map +0 -1
  403. package/dist/core/refactor/swift-extractor.js +0 -283
  404. package/dist/core/refactor/swift-extractor.js.map +0 -1
  405. package/dist/core/search/engines/text-engine.d.ts +0 -52
  406. package/dist/core/search/engines/text-engine.d.ts.map +0 -1
  407. package/dist/core/search/engines/text-engine.js +0 -376
  408. package/dist/core/search/engines/text-engine.js.map +0 -1
  409. package/dist/core/search/index.d.ts +0 -10
  410. package/dist/core/search/index.d.ts.map +0 -1
  411. package/dist/core/search/index.js +0 -11
  412. package/dist/core/search/index.js.map +0 -1
  413. package/dist/core/search/service.d.ts +0 -105
  414. package/dist/core/search/service.d.ts.map +0 -1
  415. package/dist/core/search/service.js +0 -384
  416. package/dist/core/search/service.js.map +0 -1
  417. package/dist/core/search/types.d.ts +0 -357
  418. package/dist/core/search/types.d.ts.map +0 -1
  419. package/dist/core/search/types.js +0 -47
  420. package/dist/core/search/types.js.map +0 -1
  421. package/dist/core/shit-score/grading.d.ts +0 -39
  422. package/dist/core/shit-score/grading.d.ts.map +0 -1
  423. package/dist/core/shit-score/grading.js +0 -253
  424. package/dist/core/shit-score/grading.js.map +0 -1
  425. package/dist/core/shit-score/index.d.ts +0 -9
  426. package/dist/core/shit-score/index.d.ts.map +0 -1
  427. package/dist/core/shit-score/index.js +0 -8
  428. package/dist/core/shit-score/index.js.map +0 -1
  429. package/dist/core/shit-score/score-calculator.d.ts +0 -75
  430. package/dist/core/shit-score/score-calculator.d.ts.map +0 -1
  431. package/dist/core/shit-score/score-calculator.js +0 -240
  432. package/dist/core/shit-score/score-calculator.js.map +0 -1
  433. package/dist/core/shit-score/shit-score-analyzer.d.ts +0 -84
  434. package/dist/core/shit-score/shit-score-analyzer.d.ts.map +0 -1
  435. package/dist/core/shit-score/shit-score-analyzer.js +0 -595
  436. package/dist/core/shit-score/shit-score-analyzer.js.map +0 -1
  437. package/dist/core/shit-score/types.d.ts +0 -231
  438. package/dist/core/shit-score/types.d.ts.map +0 -1
  439. package/dist/core/shit-score/types.js +0 -73
  440. package/dist/core/shit-score/types.js.map +0 -1
  441. package/dist/core/snapshot/code-compressor.d.ts +0 -39
  442. package/dist/core/snapshot/code-compressor.d.ts.map +0 -1
  443. package/dist/core/snapshot/code-compressor.js +0 -211
  444. package/dist/core/snapshot/code-compressor.js.map +0 -1
  445. package/dist/core/snapshot/config.d.ts +0 -60
  446. package/dist/core/snapshot/config.d.ts.map +0 -1
  447. package/dist/core/snapshot/config.js +0 -136
  448. package/dist/core/snapshot/config.js.map +0 -1
  449. package/dist/core/snapshot/snapshot-differ.d.ts +0 -54
  450. package/dist/core/snapshot/snapshot-differ.d.ts.map +0 -1
  451. package/dist/core/snapshot/snapshot-differ.js +0 -262
  452. package/dist/core/snapshot/snapshot-differ.js.map +0 -1
  453. package/dist/core/snapshot/snapshot-engine.d.ts +0 -94
  454. package/dist/core/snapshot/snapshot-engine.d.ts.map +0 -1
  455. package/dist/core/snapshot/snapshot-engine.js +0 -492
  456. package/dist/core/snapshot/snapshot-engine.js.map +0 -1
  457. package/dist/infrastructure/parser/factory.d.ts +0 -141
  458. package/dist/infrastructure/parser/factory.d.ts.map +0 -1
  459. package/dist/infrastructure/parser/factory.js +0 -306
  460. package/dist/infrastructure/parser/factory.js.map +0 -1
  461. package/dist/infrastructure/storage/file-watcher.d.ts +0 -84
  462. package/dist/infrastructure/storage/file-watcher.d.ts.map +0 -1
  463. package/dist/infrastructure/storage/file-watcher.js +0 -249
  464. package/dist/infrastructure/storage/file-watcher.js.map +0 -1
  465. package/dist/infrastructure/storage/path-utils.d.ts +0 -96
  466. package/dist/infrastructure/storage/path-utils.d.ts.map +0 -1
  467. package/dist/infrastructure/storage/path-utils.js +0 -272
  468. package/dist/infrastructure/storage/path-utils.js.map +0 -1
  469. package/dist/plugins/swift/analyzers/complexity-analyzer.d.ts +0 -41
  470. package/dist/plugins/swift/analyzers/complexity-analyzer.d.ts.map +0 -1
  471. package/dist/plugins/swift/analyzers/complexity-analyzer.js +0 -206
  472. package/dist/plugins/swift/analyzers/complexity-analyzer.js.map +0 -1
  473. package/dist/plugins/swift/analyzers/duplication-detector.d.ts +0 -89
  474. package/dist/plugins/swift/analyzers/duplication-detector.d.ts.map +0 -1
  475. package/dist/plugins/swift/analyzers/duplication-detector.js +0 -271
  476. package/dist/plugins/swift/analyzers/duplication-detector.js.map +0 -1
  477. package/dist/plugins/swift/analyzers/error-handling-checker.d.ts +0 -34
  478. package/dist/plugins/swift/analyzers/error-handling-checker.d.ts.map +0 -1
  479. package/dist/plugins/swift/analyzers/error-handling-checker.js +0 -135
  480. package/dist/plugins/swift/analyzers/error-handling-checker.js.map +0 -1
  481. package/dist/plugins/swift/analyzers/naming-checker.d.ts +0 -47
  482. package/dist/plugins/swift/analyzers/naming-checker.d.ts.map +0 -1
  483. package/dist/plugins/swift/analyzers/naming-checker.js +0 -161
  484. package/dist/plugins/swift/analyzers/naming-checker.js.map +0 -1
  485. package/dist/plugins/swift/analyzers/pattern-detector.d.ts +0 -78
  486. package/dist/plugins/swift/analyzers/pattern-detector.d.ts.map +0 -1
  487. package/dist/plugins/swift/analyzers/pattern-detector.js +0 -247
  488. package/dist/plugins/swift/analyzers/pattern-detector.js.map +0 -1
  489. package/dist/plugins/swift/analyzers/security-checker.d.ts +0 -38
  490. package/dist/plugins/swift/analyzers/security-checker.d.ts.map +0 -1
  491. package/dist/plugins/swift/analyzers/security-checker.js +0 -135
  492. package/dist/plugins/swift/analyzers/security-checker.js.map +0 -1
  493. package/dist/plugins/swift/analyzers/test-coverage-checker.d.ts +0 -26
  494. package/dist/plugins/swift/analyzers/test-coverage-checker.d.ts.map +0 -1
  495. package/dist/plugins/swift/analyzers/test-coverage-checker.js +0 -63
  496. package/dist/plugins/swift/analyzers/test-coverage-checker.js.map +0 -1
  497. package/dist/plugins/swift/analyzers/type-safety-checker.d.ts +0 -41
  498. package/dist/plugins/swift/analyzers/type-safety-checker.d.ts.map +0 -1
  499. package/dist/plugins/swift/analyzers/type-safety-checker.js +0 -121
  500. package/dist/plugins/swift/analyzers/type-safety-checker.js.map +0 -1
  501. package/dist/plugins/swift/analyzers/unused-symbol-detector.d.ts +0 -38
  502. package/dist/plugins/swift/analyzers/unused-symbol-detector.d.ts.map +0 -1
  503. package/dist/plugins/swift/analyzers/unused-symbol-detector.js +0 -211
  504. package/dist/plugins/swift/analyzers/unused-symbol-detector.js.map +0 -1
  505. package/dist/plugins/typescript/analyzers/complexity-analyzer.d.ts +0 -39
  506. package/dist/plugins/typescript/analyzers/complexity-analyzer.d.ts.map +0 -1
  507. package/dist/plugins/typescript/analyzers/complexity-analyzer.js +0 -196
  508. package/dist/plugins/typescript/analyzers/complexity-analyzer.js.map +0 -1
  509. package/dist/plugins/typescript/analyzers/duplication-detector.d.ts +0 -181
  510. package/dist/plugins/typescript/analyzers/duplication-detector.d.ts.map +0 -1
  511. package/dist/plugins/typescript/analyzers/duplication-detector.js +0 -695
  512. package/dist/plugins/typescript/analyzers/duplication-detector.js.map +0 -1
  513. package/dist/plugins/typescript/analyzers/error-handling-checker.d.ts +0 -26
  514. package/dist/plugins/typescript/analyzers/error-handling-checker.d.ts.map +0 -1
  515. package/dist/plugins/typescript/analyzers/error-handling-checker.js +0 -84
  516. package/dist/plugins/typescript/analyzers/error-handling-checker.js.map +0 -1
  517. package/dist/plugins/typescript/analyzers/naming-checker.d.ts +0 -30
  518. package/dist/plugins/typescript/analyzers/naming-checker.d.ts.map +0 -1
  519. package/dist/plugins/typescript/analyzers/naming-checker.js +0 -116
  520. package/dist/plugins/typescript/analyzers/naming-checker.js.map +0 -1
  521. package/dist/plugins/typescript/analyzers/pattern-detector.d.ts +0 -80
  522. package/dist/plugins/typescript/analyzers/pattern-detector.d.ts.map +0 -1
  523. package/dist/plugins/typescript/analyzers/pattern-detector.js +0 -267
  524. package/dist/plugins/typescript/analyzers/pattern-detector.js.map +0 -1
  525. package/dist/plugins/typescript/analyzers/security-checker.d.ts +0 -34
  526. package/dist/plugins/typescript/analyzers/security-checker.d.ts.map +0 -1
  527. package/dist/plugins/typescript/analyzers/security-checker.js +0 -126
  528. package/dist/plugins/typescript/analyzers/security-checker.js.map +0 -1
  529. package/dist/plugins/typescript/analyzers/test-coverage-checker.d.ts +0 -22
  530. package/dist/plugins/typescript/analyzers/test-coverage-checker.d.ts.map +0 -1
  531. package/dist/plugins/typescript/analyzers/test-coverage-checker.js +0 -62
  532. package/dist/plugins/typescript/analyzers/test-coverage-checker.js.map +0 -1
  533. package/dist/plugins/typescript/analyzers/type-safety-checker.d.ts +0 -32
  534. package/dist/plugins/typescript/analyzers/type-safety-checker.d.ts.map +0 -1
  535. package/dist/plugins/typescript/analyzers/type-safety-checker.js +0 -86
  536. package/dist/plugins/typescript/analyzers/type-safety-checker.js.map +0 -1
  537. package/dist/plugins/typescript/analyzers/unused-symbol-detector.d.ts +0 -47
  538. package/dist/plugins/typescript/analyzers/unused-symbol-detector.d.ts.map +0 -1
  539. package/dist/plugins/typescript/analyzers/unused-symbol-detector.js +0 -152
  540. package/dist/plugins/typescript/analyzers/unused-symbol-detector.js.map +0 -1
  541. /package/dist/core/{move → move-file}/import-resolver.d.ts +0 -0
  542. /package/dist/core/{move → move-file}/types.d.ts +0 -0
  543. /package/dist/core/{move → move-file}/types.js +0 -0
@@ -1,84 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,595 +0,0 @@
1
- /**
2
- * ShitScore 分析器
3
- * 主服務類別,整合所有分析功能(通過 ParserPlugin)
4
- */
5
- import * as fs from 'fs/promises';
6
- import * as path from 'path';
7
- import { ScoreCalculator } from './score-calculator.js';
8
- import { Grading } from './grading.js';
9
- import { createDefaultShitScoreOptions } from './types.js';
10
- import { ShitType, SeverityLevel } from './types.js';
11
- /**
12
- * ShitScore 錯誤
13
- */
14
- export class ShitScoreError extends Error {
15
- score;
16
- maxAllowed;
17
- constructor(message, score, maxAllowed) {
18
- super(message);
19
- this.score = score;
20
- this.maxAllowed = maxAllowed;
21
- this.name = 'ShitScoreError';
22
- }
23
- }
24
- /**
25
- * ShitScore 分析器
26
- */
27
- export class ShitScoreAnalyzer {
28
- calculator;
29
- grading;
30
- parserRegistry;
31
- constructor(parserRegistry) {
32
- this.calculator = new ScoreCalculator();
33
- this.grading = new Grading();
34
- this.parserRegistry = parserRegistry;
35
- }
36
- /**
37
- * 分析專案的垃圾度
38
- */
39
- async analyze(projectPath, options) {
40
- const fullOptions = { ...createDefaultShitScoreOptions(), ...options };
41
- const files = await this.collectFiles(projectPath, fullOptions);
42
- // 建立檔案分析快取(解析 AST 和 symbols)
43
- const fileCache = await this.buildFileCache(files);
44
- const complexityData = await this.collectComplexityData(fileCache);
45
- const maintainabilityData = await this.collectMaintainabilityData(fileCache);
46
- const architectureData = await this.collectArchitectureData(files);
47
- const qualityAssuranceData = await this.collectQualityAssuranceData(fileCache, projectPath);
48
- const { complexityScore, maintainabilityScore, architectureScore, qualityAssuranceScore, totalScore } = this.calculator.calculate(complexityData, maintainabilityData, architectureData, qualityAssuranceData);
49
- const gradeInfo = this.grading.getGrade(totalScore);
50
- if (fullOptions.maxAllowed !== undefined && totalScore > fullOptions.maxAllowed) {
51
- throw new ShitScoreError(`ShitScore ${totalScore} exceeds maximum allowed ${fullOptions.maxAllowed}`, totalScore, fullOptions.maxAllowed);
52
- }
53
- const result = {
54
- shitScore: totalScore,
55
- grade: gradeInfo.level,
56
- gradeInfo,
57
- dimensions: {
58
- complexity: complexityScore,
59
- maintainability: maintainabilityScore,
60
- architecture: architectureScore,
61
- qualityAssurance: qualityAssuranceScore,
62
- },
63
- summary: {
64
- totalFiles: files.length,
65
- analyzedFiles: files.length,
66
- totalShit: 0,
67
- },
68
- analyzedAt: new Date(),
69
- };
70
- if (fullOptions.detailed || fullOptions.showFiles) {
71
- return await this.buildDetailedResult(result, fullOptions, fileCache, complexityData, maintainabilityData, architectureData, qualityAssuranceData);
72
- }
73
- return result;
74
- }
75
- /**
76
- * 收集專案檔案
77
- */
78
- async collectFiles(projectPath, options) {
79
- const files = [];
80
- async function walk(dir) {
81
- try {
82
- const entries = await fs.readdir(dir, { withFileTypes: true });
83
- for (const entry of entries) {
84
- const fullPath = path.join(dir, entry.name);
85
- if (entry.isDirectory()) {
86
- if (!options.excludePatterns?.some((pattern) => fullPath.includes(pattern))) {
87
- await walk(fullPath);
88
- }
89
- }
90
- else if (entry.isFile()) {
91
- const ext = path.extname(entry.name);
92
- if (['.ts', '.js', '.tsx', '.jsx'].includes(ext)) {
93
- files.push(fullPath);
94
- }
95
- }
96
- }
97
- }
98
- catch {
99
- // 忽略無法讀取的目錄
100
- }
101
- }
102
- await walk(projectPath);
103
- return files;
104
- }
105
- /**
106
- * 建立檔案分析快取(解析 AST 和提取 symbols)
107
- */
108
- async buildFileCache(files) {
109
- const cache = new Map();
110
- for (const file of files) {
111
- try {
112
- const parser = this.parserRegistry.getParser(path.extname(file));
113
- if (!parser) {
114
- continue;
115
- }
116
- const content = await fs.readFile(file, 'utf-8');
117
- const ast = await parser.parse(content, file);
118
- const symbols = await parser.extractSymbols(ast);
119
- cache.set(file, { ast, parser, symbols, content });
120
- }
121
- catch {
122
- // 忽略無法解析的檔案
123
- }
124
- }
125
- return cache;
126
- }
127
- /**
128
- * 收集複雜度資料(使用 parser.analyzeComplexity)
129
- */
130
- async collectComplexityData(fileCache) {
131
- let totalFunctions = 0;
132
- let highComplexityCount = 0;
133
- let longFunctionCount = 0;
134
- let deepNestingCount = 0;
135
- const tooManyParamsCount = 0;
136
- for (const { ast, parser, content } of fileCache.values()) {
137
- try {
138
- const metrics = await parser.analyzeComplexity(content, ast);
139
- totalFunctions += metrics.functionCount;
140
- if (metrics.maxComplexity > 10) {
141
- highComplexityCount++;
142
- }
143
- // 簡化實作:根據平均複雜度估計長函式和深層巢狀
144
- if (metrics.averageComplexity > 5) {
145
- longFunctionCount++;
146
- }
147
- if (metrics.cognitiveComplexity > 15) {
148
- deepNestingCount++;
149
- }
150
- // 參數計數需要從 symbols 中推算(簡化實作)
151
- const functions = (await parser.extractSymbols(ast)).filter(s => s.type === 'function');
152
- for (const func of functions) {
153
- // 簡化實作:假設沒有參數資訊
154
- // 實際應從 AST 中提取參數數量
155
- }
156
- }
157
- catch {
158
- // 忽略無法分析的檔案
159
- }
160
- }
161
- return {
162
- totalFunctions,
163
- highComplexityCount,
164
- longFunctionCount,
165
- deepNestingCount,
166
- tooManyParamsCount,
167
- };
168
- }
169
- /**
170
- * 收集維護性資料(使用 parser 方法)
171
- */
172
- async collectMaintainabilityData(fileCache) {
173
- let deadCodeCount = 0;
174
- let largeFileCount = 0;
175
- const allFragments = [];
176
- for (const [file, { ast, parser, content }] of fileCache.entries()) {
177
- try {
178
- const lines = content.split('\n').length;
179
- if (lines > 500) {
180
- largeFileCount++;
181
- }
182
- // 使用 parser.detectUnusedSymbols 檢測死代碼
183
- const allSymbols = await parser.extractSymbols(ast);
184
- const unusedSymbols = await parser.detectUnusedSymbols(ast, allSymbols);
185
- if (unusedSymbols.length > 0) {
186
- deadCodeCount++;
187
- }
188
- // 收集代碼片段用於重複檢測
189
- const fragments = await parser.extractCodeFragments(content, file);
190
- allFragments.push(...fragments);
191
- }
192
- catch {
193
- // 忽略無法讀取的檔案
194
- }
195
- }
196
- // 檢測重複代碼(Type-1, Type-2, Type-3)
197
- const duplicateCodeCount = this.detectDuplication(allFragments, {
198
- minLines: 3,
199
- minTokens: 5,
200
- similarityThreshold: 0.7,
201
- });
202
- // 檢測模式重複
203
- let patternDuplicationCount = 0;
204
- for (const { ast, parser, content } of fileCache.values()) {
205
- try {
206
- const patterns = await parser.detectPatterns(content, ast);
207
- patternDuplicationCount += patterns.length;
208
- }
209
- catch {
210
- // 忽略無法分析的檔案
211
- }
212
- }
213
- return {
214
- totalFiles: fileCache.size,
215
- deadCodeCount,
216
- largeFileCount,
217
- duplicateCodeCount,
218
- patternDuplicationCount,
219
- };
220
- }
221
- /**
222
- * 檢測代碼重複(簡化版 DuplicationDetector)
223
- */
224
- detectDuplication(fragments, options) {
225
- let duplicateCount = 0;
226
- // Type-1: 完全相同
227
- const contentMap = new Map();
228
- for (const fragment of fragments) {
229
- const normalized = fragment.code.trim();
230
- if (normalized.split('\n').length < options.minLines) {
231
- continue;
232
- }
233
- const existing = contentMap.get(normalized) || [];
234
- existing.push(fragment);
235
- contentMap.set(normalized, existing);
236
- }
237
- for (const group of contentMap.values()) {
238
- if (group.length > 1) {
239
- // 過濾掉同檔案的重複(避免誤判方法內的重複)
240
- const uniqueFiles = new Set(group.map(f => f.location.filePath));
241
- if (uniqueFiles.size > 1) {
242
- duplicateCount += group.length - 1;
243
- }
244
- }
245
- }
246
- return duplicateCount;
247
- }
248
- /**
249
- * 收集架構資料
250
- */
251
- async collectArchitectureData(files) {
252
- const dependencies = new Map();
253
- for (const file of files) {
254
- try {
255
- const content = await fs.readFile(file, 'utf-8');
256
- const imports = content.match(/import\s+.*from\s+['"](.+)['"]/g) || [];
257
- const deps = new Set();
258
- for (const imp of imports) {
259
- const match = imp.match(/from\s+['"](.+)['"]/);
260
- if (match && match[1].startsWith('.')) {
261
- deps.add(match[1]);
262
- }
263
- }
264
- dependencies.set(file, deps);
265
- }
266
- catch {
267
- // 忽略無法讀取的檔案
268
- }
269
- }
270
- const cycles = this.detectCycles(dependencies);
271
- const orphanCount = this.countOrphans(dependencies);
272
- const highCouplingCount = this.countHighCoupling(dependencies);
273
- return {
274
- totalFiles: files.length,
275
- circularDependencyCount: cycles,
276
- orphanFileCount: orphanCount,
277
- highCouplingCount,
278
- };
279
- }
280
- /**
281
- * 收集品質保證資料(使用 parser checker 方法)
282
- */
283
- async collectQualityAssuranceData(fileCache, projectPath) {
284
- let typeSafetyIssues = 0;
285
- let errorHandlingIssues = 0;
286
- let namingIssues = 0;
287
- let securityIssues = 0;
288
- const testFiles = new Set();
289
- const sourceFiles = new Set();
290
- for (const [file, { ast, parser, symbols, content }] of fileCache.entries()) {
291
- try {
292
- // 型別安全檢查
293
- const typeSafetyProblems = await parser.checkTypeSafety(content, ast);
294
- typeSafetyIssues += typeSafetyProblems.length;
295
- // 錯誤處理檢查
296
- const errorHandlingProblems = await parser.checkErrorHandling(content, ast);
297
- errorHandlingIssues += errorHandlingProblems.length;
298
- // 命名規範檢查
299
- const namingProblems = await parser.checkNamingConventions(symbols, file);
300
- namingIssues += namingProblems.length;
301
- // 安全性檢查
302
- const securityProblems = await parser.checkSecurity(content, ast);
303
- securityIssues += securityProblems.length;
304
- // 測試覆蓋率統計
305
- if (parser.isTestFile(file)) {
306
- testFiles.add(file);
307
- }
308
- else {
309
- sourceFiles.add(file);
310
- }
311
- }
312
- catch {
313
- // 忽略無法分析的檔案
314
- }
315
- }
316
- const testCoverageRatio = sourceFiles.size > 0 ? testFiles.size / sourceFiles.size : 0;
317
- // 檢查 tsconfig.json 的 strict 模式
318
- const { strictModeEnabled, strictNullChecksEnabled } = await this.checkTsConfigStrict(projectPath);
319
- return {
320
- totalFiles: fileCache.size,
321
- typeSafetyIssues,
322
- testCoverageRatio,
323
- errorHandlingIssues,
324
- namingIssues,
325
- securityIssues,
326
- strictModeEnabled,
327
- strictNullChecksEnabled,
328
- };
329
- }
330
- /**
331
- * 檢查 tsconfig.json 的 strict 設定
332
- */
333
- async checkTsConfigStrict(projectPath) {
334
- try {
335
- const tsconfigPath = path.join(projectPath, 'tsconfig.json');
336
- const content = await fs.readFile(tsconfigPath, 'utf-8');
337
- const config = JSON.parse(content);
338
- const strictModeEnabled = config.compilerOptions?.strict === true;
339
- const strictNullChecksEnabled = config.compilerOptions?.strictNullChecks === true || strictModeEnabled;
340
- return { strictModeEnabled, strictNullChecksEnabled };
341
- }
342
- catch {
343
- return { strictModeEnabled: false, strictNullChecksEnabled: false };
344
- }
345
- }
346
- /**
347
- * 建立詳細結果
348
- */
349
- async buildDetailedResult(baseResult, options, fileCache, complexity, maintainability, architecture, qualityAssurance) {
350
- const files = Array.from(fileCache.keys());
351
- const topShit = await this.extractTopShit(fileCache, complexity, maintainability, architecture, qualityAssurance, options.topCount);
352
- const recommendations = this.grading.generateRecommendations(baseResult.dimensions.complexity, baseResult.dimensions.maintainability, baseResult.dimensions.architecture, baseResult.dimensions.qualityAssurance);
353
- const result = {
354
- ...baseResult,
355
- topShit,
356
- recommendations,
357
- summary: {
358
- ...baseResult.summary,
359
- totalShit: topShit.length,
360
- },
361
- };
362
- if (options.showFiles) {
363
- const detailedFiles = await this.collectDetailedFiles(fileCache);
364
- return {
365
- ...result,
366
- detailedFiles,
367
- };
368
- }
369
- return result;
370
- }
371
- /**
372
- * 提取最嚴重的垃圾項目
373
- */
374
- async extractTopShit(fileCache, complexity, maintainability, architecture, qualityAssurance, topCount) {
375
- const items = [];
376
- // 從實際分析結果中提取垃圾項目
377
- for (const [file, { ast, parser, content, symbols }] of fileCache.entries()) {
378
- try {
379
- // 複雜度問題
380
- const complexityMetrics = await parser.analyzeComplexity(content, ast);
381
- if (complexityMetrics.maxComplexity > 10) {
382
- items.push({
383
- filePath: file,
384
- type: ShitType.HighComplexity,
385
- severity: SeverityLevel.High,
386
- score: Math.min(100, complexityMetrics.maxComplexity * 5),
387
- description: `函式複雜度過高 (${complexityMetrics.maxComplexity})`,
388
- });
389
- }
390
- // 型別安全問題
391
- const typeSafetyIssues = await parser.checkTypeSafety(content, ast);
392
- if (typeSafetyIssues.length > 0) {
393
- const anyCount = typeSafetyIssues.filter(i => i.type === 'any-type').length;
394
- const ignoreCount = typeSafetyIssues.filter(i => i.type === 'ignore-directive').length;
395
- const castCount = typeSafetyIssues.filter(i => i.type === 'unsafe-cast').length;
396
- const details = [];
397
- if (anyCount > 0) {
398
- details.push(`any 型別 ${anyCount} 處`);
399
- }
400
- if (ignoreCount > 0) {
401
- details.push(`@ts-ignore ${ignoreCount} 處`);
402
- }
403
- if (castCount > 0) {
404
- details.push(`as any ${castCount} 處`);
405
- }
406
- items.push({
407
- filePath: file,
408
- type: ShitType.TypeSafety,
409
- severity: SeverityLevel.High,
410
- score: 75,
411
- description: details.join('、'),
412
- });
413
- }
414
- // 錯誤處理問題
415
- const errorHandlingIssues = await parser.checkErrorHandling(content, ast);
416
- if (errorHandlingIssues.length > 0) {
417
- items.push({
418
- filePath: file,
419
- type: ShitType.PoorErrorHandling,
420
- severity: SeverityLevel.High,
421
- score: 70,
422
- description: `錯誤處理問題 (${errorHandlingIssues.length} 處)`,
423
- });
424
- }
425
- // 安全性問題
426
- const securityIssues = await parser.checkSecurity(content, ast);
427
- if (securityIssues.length > 0) {
428
- items.push({
429
- filePath: file,
430
- type: ShitType.SecurityRisk,
431
- severity: SeverityLevel.Critical,
432
- score: 95,
433
- description: `安全性風險 (${securityIssues.length} 處)`,
434
- });
435
- }
436
- // 命名規範問題
437
- const namingIssues = await parser.checkNamingConventions(symbols, file);
438
- if (namingIssues.length > 0) {
439
- items.push({
440
- filePath: file,
441
- type: ShitType.NamingViolation,
442
- severity: SeverityLevel.Low,
443
- score: 50,
444
- description: `命名規範違反 (${namingIssues.length} 處)`,
445
- });
446
- }
447
- }
448
- catch {
449
- // 忽略無法分析的檔案
450
- }
451
- }
452
- // 按分數排序並取前 N 個
453
- return items.sort((a, b) => b.score - a.score).slice(0, topCount);
454
- }
455
- /**
456
- * 收集詳細檔案列表
457
- */
458
- async collectDetailedFiles(fileCache) {
459
- const typeSafetyFiles = [];
460
- const testCoverageFiles = [];
461
- const errorHandlingFiles = [];
462
- const namingViolationFiles = [];
463
- const securityRiskFiles = [];
464
- const duplicateCodeFiles = [];
465
- for (const [file, { ast, parser, content, symbols }] of fileCache.entries()) {
466
- try {
467
- const lines = content.split('\n').length;
468
- // 型別安全問題
469
- const typeSafetyIssues = await parser.checkTypeSafety(content, ast);
470
- if (typeSafetyIssues.length > 0) {
471
- const anyCount = typeSafetyIssues.filter(i => i.type === 'any-type').length;
472
- const tsIgnoreCount = typeSafetyIssues.filter(i => i.type === 'ignore-directive').length;
473
- typeSafetyFiles.push({
474
- path: file,
475
- lines,
476
- anyTypeCount: anyCount,
477
- tsIgnoreCount: tsIgnoreCount,
478
- });
479
- }
480
- // 錯誤處理問題
481
- const errorHandlingIssues = await parser.checkErrorHandling(content, ast);
482
- if (errorHandlingIssues.length > 0) {
483
- errorHandlingFiles.push({
484
- path: file,
485
- lines,
486
- emptyCatchCount: errorHandlingIssues.filter(i => i.type === 'empty-catch').length,
487
- });
488
- }
489
- // 命名問題
490
- const namingIssues = await parser.checkNamingConventions(symbols, file);
491
- if (namingIssues.length > 0) {
492
- namingViolationFiles.push({
493
- path: file,
494
- lines,
495
- namingIssues: namingIssues.length,
496
- });
497
- }
498
- // 安全問題
499
- const securityIssues = await parser.checkSecurity(content, ast);
500
- if (securityIssues.length > 0) {
501
- securityRiskFiles.push({
502
- path: file,
503
- lines,
504
- securityIssues: securityIssues.length,
505
- });
506
- }
507
- // 測試覆蓋率
508
- if (!parser.isTestFile(file)) {
509
- testCoverageFiles.push({
510
- path: file,
511
- testCoverageRatio: 0, // 簡化實作:標記為無測試
512
- });
513
- }
514
- }
515
- catch {
516
- // 忽略無法讀取的檔案
517
- }
518
- }
519
- return {
520
- complexity: {
521
- highComplexity: [],
522
- longFunction: [],
523
- deepNesting: [],
524
- tooManyParams: [],
525
- },
526
- maintainability: {
527
- deadCode: [],
528
- largeFile: [],
529
- duplicateCode: duplicateCodeFiles,
530
- },
531
- architecture: {
532
- orphanFile: [],
533
- highCoupling: [],
534
- circularDependency: [],
535
- },
536
- qualityAssurance: {
537
- typeSafety: typeSafetyFiles,
538
- testCoverage: testCoverageFiles,
539
- errorHandling: errorHandlingFiles,
540
- namingViolation: namingViolationFiles,
541
- securityRisk: securityRiskFiles,
542
- },
543
- };
544
- }
545
- /**
546
- * 檢測循環依賴
547
- */
548
- detectCycles(dependencies) {
549
- // 簡化實作:檢查互相引用
550
- let cycles = 0;
551
- for (const [file, deps] of dependencies.entries()) {
552
- for (const dep of deps) {
553
- const depDeps = dependencies.get(dep);
554
- if (depDeps && depDeps.has(file)) {
555
- cycles++;
556
- }
557
- }
558
- }
559
- return Math.floor(cycles / 2); // 除以 2 因為每個循環被計算了兩次
560
- }
561
- /**
562
- * 計算孤立檔案數量
563
- */
564
- countOrphans(dependencies) {
565
- let orphans = 0;
566
- for (const [file, deps] of dependencies.entries()) {
567
- if (deps.size === 0) {
568
- let isDependent = false;
569
- for (const [, otherDeps] of dependencies.entries()) {
570
- if (otherDeps.has(file)) {
571
- isDependent = true;
572
- break;
573
- }
574
- }
575
- if (!isDependent) {
576
- orphans++;
577
- }
578
- }
579
- }
580
- return orphans;
581
- }
582
- /**
583
- * 計算高耦合檔案數量
584
- */
585
- countHighCoupling(dependencies) {
586
- let highCoupling = 0;
587
- for (const [, deps] of dependencies.entries()) {
588
- if (deps.size > 10) {
589
- highCoupling++;
590
- }
591
- }
592
- return highCoupling;
593
- }
594
- }
595
- //# sourceMappingURL=shit-score-analyzer.js.map