erosolar-cli 1.5.2 → 1.5.4

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 (346) hide show
  1. package/config/security-deployment.json +54 -0
  2. package/dist/bin/adapters/node/index.js +33 -0
  3. package/dist/bin/adapters/types.js +1 -0
  4. package/dist/bin/alpha-zero/agentWrapper.js +165 -0
  5. package/dist/bin/alpha-zero/codeEvaluator.js +272 -0
  6. package/dist/bin/alpha-zero/competitiveRunner.js +219 -0
  7. package/dist/bin/alpha-zero/index.js +98 -0
  8. package/dist/bin/alpha-zero/introspection.js +298 -0
  9. package/dist/bin/alpha-zero/metricsTracker.js +207 -0
  10. package/dist/bin/alpha-zero/security/core.js +269 -0
  11. package/dist/bin/alpha-zero/security/google.js +308 -0
  12. package/dist/bin/alpha-zero/security/googleLoader.js +40 -0
  13. package/dist/bin/alpha-zero/security/index.js +31 -0
  14. package/dist/bin/alpha-zero/security/simulation.js +274 -0
  15. package/dist/bin/alpha-zero/selfModification.js +231 -0
  16. package/dist/bin/alpha-zero/types.js +30 -0
  17. package/dist/bin/bin/erosolar-optimized.js +205 -0
  18. package/dist/bin/capabilities/agentSpawningCapability.js +116 -0
  19. package/dist/bin/capabilities/bashCapability.js +22 -0
  20. package/dist/bin/capabilities/cloudCapability.js +36 -0
  21. package/dist/bin/capabilities/codeAnalysisCapability.js +22 -0
  22. package/dist/bin/capabilities/codeQualityCapability.js +23 -0
  23. package/dist/bin/capabilities/dependencySecurityCapability.js +22 -0
  24. package/dist/bin/capabilities/devCapability.js +22 -0
  25. package/dist/bin/capabilities/editCapability.js +28 -0
  26. package/dist/bin/capabilities/emailCapability.js +20 -0
  27. package/dist/bin/capabilities/enhancedGitCapability.js +221 -0
  28. package/dist/bin/capabilities/filesystemCapability.js +22 -0
  29. package/dist/bin/capabilities/globCapability.js +28 -0
  30. package/dist/bin/capabilities/interactionCapability.js +20 -0
  31. package/dist/bin/capabilities/learnCapability.js +22 -0
  32. package/dist/bin/capabilities/mcpCapability.js +20 -0
  33. package/dist/bin/capabilities/notebookCapability.js +28 -0
  34. package/dist/bin/capabilities/planningCapability.js +27 -0
  35. package/dist/bin/capabilities/refactoringCapability.js +23 -0
  36. package/dist/bin/capabilities/repoChecksCapability.js +22 -0
  37. package/dist/bin/capabilities/searchCapability.js +22 -0
  38. package/dist/bin/capabilities/skillCapability.js +76 -0
  39. package/dist/bin/capabilities/taskManagementCapability.js +20 -0
  40. package/dist/bin/capabilities/testingCapability.js +23 -0
  41. package/dist/bin/capabilities/toolManifest.js +159 -0
  42. package/dist/bin/capabilities/toolRegistry.js +114 -0
  43. package/dist/bin/capabilities/webCapability.js +20 -0
  44. package/dist/bin/config.js +139 -0
  45. package/dist/bin/contracts/v1/agent.js +7 -0
  46. package/dist/bin/contracts/v1/agentProfileManifest.js +8 -0
  47. package/dist/bin/contracts/v1/agentRules.js +9 -0
  48. package/dist/bin/contracts/v1/toolAccess.js +8 -0
  49. package/dist/bin/core/agent.js +362 -0
  50. package/dist/bin/core/agentProfileManifest.js +187 -0
  51. package/dist/bin/core/agentProfiles.js +34 -0
  52. package/dist/bin/core/agentRulebook.js +135 -0
  53. package/dist/bin/core/agentSchemaLoader.js +233 -0
  54. package/dist/bin/core/contextManager.js +412 -0
  55. package/dist/bin/core/contextWindow.js +122 -0
  56. package/dist/bin/core/customCommands.js +80 -0
  57. package/dist/bin/core/errors/apiKeyErrors.js +114 -0
  58. package/dist/bin/core/errors/errorTypes.js +340 -0
  59. package/dist/bin/core/errors/safetyValidator.js +304 -0
  60. package/dist/bin/core/errors.js +32 -0
  61. package/dist/bin/core/modelDiscovery.js +755 -0
  62. package/dist/bin/core/preferences.js +224 -0
  63. package/dist/bin/core/schemaValidator.js +92 -0
  64. package/dist/bin/core/secretStore.js +199 -0
  65. package/dist/bin/core/sessionStore.js +187 -0
  66. package/dist/bin/core/toolRuntime.js +290 -0
  67. package/dist/bin/core/types.js +1 -0
  68. package/dist/bin/erosolar-optimized.d.ts +12 -0
  69. package/dist/bin/erosolar-optimized.d.ts.map +1 -0
  70. package/dist/bin/erosolar-optimized.js +239 -0
  71. package/dist/bin/erosolar-optimized.js.map +1 -0
  72. package/dist/bin/erosolar.js +14 -0
  73. package/dist/bin/erosolar.js.map +1 -1
  74. package/dist/bin/headless/headlessApp.js +172 -0
  75. package/dist/bin/mcp/config.js +202 -0
  76. package/dist/bin/mcp/stdioClient.js +172 -0
  77. package/dist/bin/mcp/toolBridge.js +104 -0
  78. package/dist/bin/mcp/types.js +1 -0
  79. package/dist/bin/plugins/index.js +113 -0
  80. package/dist/bin/plugins/providers/anthropic/index.js +25 -0
  81. package/dist/bin/plugins/providers/deepseek/index.js +24 -0
  82. package/dist/bin/plugins/providers/google/index.js +26 -0
  83. package/dist/bin/plugins/providers/index.js +19 -0
  84. package/dist/bin/plugins/providers/ollama/index.js +59 -0
  85. package/dist/bin/plugins/providers/openai/index.js +26 -0
  86. package/dist/bin/plugins/providers/xai/index.js +24 -0
  87. package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +8 -0
  88. package/dist/bin/plugins/tools/bash/localBashPlugin.js +13 -0
  89. package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +13 -0
  90. package/dist/bin/plugins/tools/cloud/cloudPlugin.js +13 -0
  91. package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +13 -0
  92. package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +13 -0
  93. package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +11 -0
  94. package/dist/bin/plugins/tools/development/devPlugin.js +13 -0
  95. package/dist/bin/plugins/tools/edit/editPlugin.js +14 -0
  96. package/dist/bin/plugins/tools/email/emailPlugin.js +11 -0
  97. package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +8 -0
  98. package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +13 -0
  99. package/dist/bin/plugins/tools/glob/globPlugin.js +14 -0
  100. package/dist/bin/plugins/tools/index.js +2 -0
  101. package/dist/bin/plugins/tools/interaction/interactionPlugin.js +11 -0
  102. package/dist/bin/plugins/tools/learn/learnPlugin.js +13 -0
  103. package/dist/bin/plugins/tools/mcp/mcpPlugin.js +8 -0
  104. package/dist/bin/plugins/tools/nodeDefaults.js +56 -0
  105. package/dist/bin/plugins/tools/notebook/notebookPlugin.js +14 -0
  106. package/dist/bin/plugins/tools/planning/planningPlugin.js +14 -0
  107. package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +11 -0
  108. package/dist/bin/plugins/tools/registry.js +57 -0
  109. package/dist/bin/plugins/tools/search/localSearchPlugin.js +13 -0
  110. package/dist/bin/plugins/tools/skills/skillPlugin.js +8 -0
  111. package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +11 -0
  112. package/dist/bin/plugins/tools/testing/testingPlugin.js +11 -0
  113. package/dist/bin/plugins/tools/web/webPlugin.js +11 -0
  114. package/dist/bin/providers/anthropicProvider.js +329 -0
  115. package/dist/bin/providers/googleProvider.js +203 -0
  116. package/dist/bin/providers/openaiChatCompletionsProvider.js +208 -0
  117. package/dist/bin/providers/openaiResponsesProvider.js +249 -0
  118. package/dist/bin/providers/providerFactory.js +24 -0
  119. package/dist/bin/runtime/agentController.js +321 -0
  120. package/dist/bin/runtime/agentHost.js +153 -0
  121. package/dist/bin/runtime/agentSession.js +195 -0
  122. package/dist/bin/runtime/node.js +10 -0
  123. package/dist/bin/runtime/universal.js +28 -0
  124. package/dist/bin/shell/bracketedPasteManager.js +350 -0
  125. package/dist/bin/shell/fileChangeTracker.js +65 -0
  126. package/dist/bin/shell/interactiveShell.js +2908 -0
  127. package/dist/bin/shell/liveStatus.js +78 -0
  128. package/dist/bin/shell/shellApp.js +290 -0
  129. package/dist/bin/shell/systemPrompt.js +60 -0
  130. package/dist/bin/shell/updateManager.js +108 -0
  131. package/dist/bin/skills/skillRepository.js +236 -0
  132. package/dist/bin/skills/types.js +1 -0
  133. package/dist/bin/subagents/taskRunner.js +269 -0
  134. package/dist/bin/tools/backgroundBashTools.js +211 -0
  135. package/dist/bin/tools/bashTools.js +159 -0
  136. package/dist/bin/tools/cloudTools.js +864 -0
  137. package/dist/bin/tools/codeAnalysisTools.js +641 -0
  138. package/dist/bin/tools/codeQualityTools.js +294 -0
  139. package/dist/bin/tools/dependencyTools.js +282 -0
  140. package/dist/bin/tools/devTools.js +238 -0
  141. package/dist/bin/tools/diffUtils.js +137 -0
  142. package/dist/bin/tools/editTools.js +134 -0
  143. package/dist/bin/tools/emailTools.js +448 -0
  144. package/dist/bin/tools/fileTools.js +282 -0
  145. package/dist/bin/tools/globTools.js +173 -0
  146. package/dist/bin/tools/grepTools.js +332 -0
  147. package/dist/bin/tools/interactionTools.js +170 -0
  148. package/dist/bin/tools/learnTools.js +1818 -0
  149. package/dist/bin/tools/notebookEditTools.js +196 -0
  150. package/dist/bin/tools/planningTools.js +46 -0
  151. package/dist/bin/tools/refactoringTools.js +293 -0
  152. package/dist/bin/tools/repoChecksTools.js +160 -0
  153. package/dist/bin/tools/searchTools.js +206 -0
  154. package/dist/bin/tools/skillTools.js +177 -0
  155. package/dist/bin/tools/taskManagementTools.js +156 -0
  156. package/dist/bin/tools/testingTools.js +232 -0
  157. package/dist/bin/tools/webTools.js +480 -0
  158. package/dist/bin/ui/ShellUIAdapter.js +459 -0
  159. package/dist/bin/ui/UnifiedUIController.js +183 -0
  160. package/dist/bin/ui/animation/AnimationScheduler.js +430 -0
  161. package/dist/bin/ui/codeHighlighter.js +854 -0
  162. package/dist/bin/ui/designSystem.js +121 -0
  163. package/dist/bin/ui/display.js +1222 -0
  164. package/dist/bin/ui/interrupts/InterruptManager.js +437 -0
  165. package/dist/bin/ui/layout.js +139 -0
  166. package/dist/bin/ui/orchestration/StatusOrchestrator.js +403 -0
  167. package/dist/bin/ui/outputMode.js +38 -0
  168. package/dist/bin/ui/persistentPrompt.js +183 -0
  169. package/dist/bin/ui/richText.js +338 -0
  170. package/dist/bin/ui/shortcutsHelp.js +87 -0
  171. package/dist/bin/ui/telemetry/UITelemetry.js +443 -0
  172. package/dist/bin/ui/textHighlighter.js +210 -0
  173. package/dist/bin/ui/theme.js +116 -0
  174. package/dist/bin/ui/toolDisplay.js +423 -0
  175. package/dist/bin/ui/toolDisplayAdapter.js +357 -0
  176. package/dist/bin/workspace.js +106 -0
  177. package/dist/bin/workspace.validator.js +213 -0
  178. package/dist/capabilities/cloudCapability.d.ts +13 -0
  179. package/dist/capabilities/cloudCapability.d.ts.map +1 -0
  180. package/dist/capabilities/cloudCapability.js +38 -0
  181. package/dist/capabilities/cloudCapability.js.map +1 -0
  182. package/dist/capabilities/index.d.ts +1 -0
  183. package/dist/capabilities/index.d.ts.map +1 -1
  184. package/dist/capabilities/index.js +1 -0
  185. package/dist/capabilities/index.js.map +1 -1
  186. package/dist/capabilities/offensiveSecurityCapability.d.ts +26 -0
  187. package/dist/capabilities/offensiveSecurityCapability.d.ts.map +1 -0
  188. package/dist/capabilities/offensiveSecurityCapability.js +58 -0
  189. package/dist/capabilities/offensiveSecurityCapability.js.map +1 -0
  190. package/dist/capabilities/realSecurityCapability.d.ts +26 -0
  191. package/dist/capabilities/realSecurityCapability.d.ts.map +1 -0
  192. package/dist/capabilities/realSecurityCapability.js +53 -0
  193. package/dist/capabilities/realSecurityCapability.js.map +1 -0
  194. package/dist/capabilities/securityCapability.d.ts +32 -0
  195. package/dist/capabilities/securityCapability.d.ts.map +1 -0
  196. package/dist/capabilities/securityCapability.js +57 -0
  197. package/dist/capabilities/securityCapability.js.map +1 -0
  198. package/dist/capabilities/ultimateSecurityCapability.d.ts +42 -0
  199. package/dist/capabilities/ultimateSecurityCapability.d.ts.map +1 -0
  200. package/dist/capabilities/ultimateSecurityCapability.js +96 -0
  201. package/dist/capabilities/ultimateSecurityCapability.js.map +1 -0
  202. package/dist/core/LazyLoader.d.ts +129 -0
  203. package/dist/core/LazyLoader.d.ts.map +1 -0
  204. package/dist/core/LazyLoader.js +240 -0
  205. package/dist/core/LazyLoader.js.map +1 -0
  206. package/dist/core/intelligenceTools.d.ts +19 -0
  207. package/dist/core/intelligenceTools.d.ts.map +1 -0
  208. package/dist/core/intelligenceTools.js +453 -0
  209. package/dist/core/intelligenceTools.js.map +1 -0
  210. package/dist/core/operationalTools.d.ts +19 -0
  211. package/dist/core/operationalTools.d.ts.map +1 -0
  212. package/dist/core/operationalTools.js +467 -0
  213. package/dist/core/operationalTools.js.map +1 -0
  214. package/dist/offensive/core/offensive-engine.d.ts +171 -0
  215. package/dist/offensive/core/offensive-engine.d.ts.map +1 -0
  216. package/dist/offensive/core/offensive-engine.js +345 -0
  217. package/dist/offensive/core/offensive-engine.js.map +1 -0
  218. package/dist/offensive/core/offensive-integration.d.ts +129 -0
  219. package/dist/offensive/core/offensive-integration.d.ts.map +1 -0
  220. package/dist/offensive/core/offensive-integration.js +364 -0
  221. package/dist/offensive/core/offensive-integration.js.map +1 -0
  222. package/dist/offensive/core/offensive-tools.d.ts +55 -0
  223. package/dist/offensive/core/offensive-tools.d.ts.map +1 -0
  224. package/dist/offensive/core/offensive-tools.js +438 -0
  225. package/dist/offensive/core/offensive-tools.js.map +1 -0
  226. package/dist/offensive/offensive-cli.d.ts +48 -0
  227. package/dist/offensive/offensive-cli.d.ts.map +1 -0
  228. package/dist/offensive/offensive-cli.js +233 -0
  229. package/dist/offensive/offensive-cli.js.map +1 -0
  230. package/dist/plugins/index.d.ts +1 -1
  231. package/dist/plugins/index.d.ts.map +1 -1
  232. package/dist/plugins/index.js +2 -0
  233. package/dist/plugins/index.js.map +1 -1
  234. package/dist/plugins/tools/cloud/cloudPlugin.d.ts +3 -0
  235. package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +1 -0
  236. package/dist/plugins/tools/cloud/cloudPlugin.js +14 -0
  237. package/dist/plugins/tools/cloud/cloudPlugin.js.map +1 -0
  238. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  239. package/dist/plugins/tools/nodeDefaults.js +2 -0
  240. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  241. package/dist/security/advanced-persistence-research.d.ts +92 -0
  242. package/dist/security/advanced-persistence-research.d.ts.map +1 -0
  243. package/dist/security/advanced-persistence-research.js +195 -0
  244. package/dist/security/advanced-persistence-research.js.map +1 -0
  245. package/dist/security/apt-simulation-cli.d.ts +57 -0
  246. package/dist/security/apt-simulation-cli.d.ts.map +1 -0
  247. package/dist/security/apt-simulation-cli.js +278 -0
  248. package/dist/security/apt-simulation-cli.js.map +1 -0
  249. package/dist/security/apt-simulation-engine-complete.d.ts +97 -0
  250. package/dist/security/apt-simulation-engine-complete.d.ts.map +1 -0
  251. package/dist/security/apt-simulation-engine-complete.js +441 -0
  252. package/dist/security/apt-simulation-engine-complete.js.map +1 -0
  253. package/dist/security/apt-simulation-engine.d.ts +97 -0
  254. package/dist/security/apt-simulation-engine.d.ts.map +1 -0
  255. package/dist/security/apt-simulation-engine.js +441 -0
  256. package/dist/security/apt-simulation-engine.js.map +1 -0
  257. package/dist/security/assessment/vulnerabilityAssessment.d.ts +104 -0
  258. package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +1 -0
  259. package/dist/security/assessment/vulnerabilityAssessment.js +315 -0
  260. package/dist/security/assessment/vulnerabilityAssessment.js.map +1 -0
  261. package/dist/security/authorization/securityAuthorization.d.ts +88 -0
  262. package/dist/security/authorization/securityAuthorization.d.ts.map +1 -0
  263. package/dist/security/authorization/securityAuthorization.js +172 -0
  264. package/dist/security/authorization/securityAuthorization.js.map +1 -0
  265. package/dist/security/authorization.d.ts +45 -0
  266. package/dist/security/authorization.d.ts.map +1 -0
  267. package/dist/security/authorization.js +128 -0
  268. package/dist/security/authorization.js.map +1 -0
  269. package/dist/security/comprehensive-security-research.d.ts +84 -0
  270. package/dist/security/comprehensive-security-research.d.ts.map +1 -0
  271. package/dist/security/comprehensive-security-research.js +211 -0
  272. package/dist/security/comprehensive-security-research.js.map +1 -0
  273. package/dist/security/offensive/exploitationEngine.d.ts +54 -0
  274. package/dist/security/offensive/exploitationEngine.d.ts.map +1 -0
  275. package/dist/security/offensive/exploitationEngine.js +263 -0
  276. package/dist/security/offensive/exploitationEngine.js.map +1 -0
  277. package/dist/security/persistence-analyzer.d.ts +56 -0
  278. package/dist/security/persistence-analyzer.d.ts.map +1 -0
  279. package/dist/security/persistence-analyzer.js +187 -0
  280. package/dist/security/persistence-analyzer.js.map +1 -0
  281. package/dist/security/persistence-cli.d.ts +36 -0
  282. package/dist/security/persistence-cli.d.ts.map +1 -0
  283. package/dist/security/persistence-cli.js +160 -0
  284. package/dist/security/persistence-cli.js.map +1 -0
  285. package/dist/security/persistence-research.d.ts +100 -0
  286. package/dist/security/persistence-research.d.ts.map +1 -0
  287. package/dist/security/persistence-research.js +372 -0
  288. package/dist/security/persistence-research.js.map +1 -0
  289. package/dist/security/real/networkExploitation.d.ts +92 -0
  290. package/dist/security/real/networkExploitation.d.ts.map +1 -0
  291. package/dist/security/real/networkExploitation.js +316 -0
  292. package/dist/security/real/networkExploitation.js.map +1 -0
  293. package/dist/security/real/persistenceImplementation.d.ts +62 -0
  294. package/dist/security/real/persistenceImplementation.d.ts.map +1 -0
  295. package/dist/security/real/persistenceImplementation.js +323 -0
  296. package/dist/security/real/persistenceImplementation.js.map +1 -0
  297. package/dist/security/real/vulnerabilityScanner.d.ts +73 -0
  298. package/dist/security/real/vulnerabilityScanner.d.ts.map +1 -0
  299. package/dist/security/real/vulnerabilityScanner.js +341 -0
  300. package/dist/security/real/vulnerabilityScanner.js.map +1 -0
  301. package/dist/security/research/persistenceResearch.d.ts +97 -0
  302. package/dist/security/research/persistenceResearch.d.ts.map +1 -0
  303. package/dist/security/research/persistenceResearch.js +282 -0
  304. package/dist/security/research/persistenceResearch.js.map +1 -0
  305. package/dist/security/security-testing-framework.d.ts +120 -0
  306. package/dist/security/security-testing-framework.d.ts.map +1 -0
  307. package/dist/security/security-testing-framework.js +372 -0
  308. package/dist/security/security-testing-framework.js.map +1 -0
  309. package/dist/security/simulation/attackSimulation.d.ts +93 -0
  310. package/dist/security/simulation/attackSimulation.d.ts.map +1 -0
  311. package/dist/security/simulation/attackSimulation.js +341 -0
  312. package/dist/security/simulation/attackSimulation.js.map +1 -0
  313. package/dist/shell/bracketedPasteManager.d.ts +76 -0
  314. package/dist/shell/bracketedPasteManager.d.ts.map +1 -1
  315. package/dist/shell/bracketedPasteManager.js +267 -9
  316. package/dist/shell/bracketedPasteManager.js.map +1 -1
  317. package/dist/shell/interactiveShell.d.ts +34 -1
  318. package/dist/shell/interactiveShell.d.ts.map +1 -1
  319. package/dist/shell/interactiveShell.js +304 -24
  320. package/dist/shell/interactiveShell.js.map +1 -1
  321. package/dist/shell/taskCompletionDetector.d.ts +101 -0
  322. package/dist/shell/taskCompletionDetector.d.ts.map +1 -0
  323. package/dist/shell/taskCompletionDetector.js +343 -0
  324. package/dist/shell/taskCompletionDetector.js.map +1 -0
  325. package/dist/tools/cloudTools.d.ts +57 -0
  326. package/dist/tools/cloudTools.d.ts.map +1 -0
  327. package/dist/tools/cloudTools.js +865 -0
  328. package/dist/tools/cloudTools.js.map +1 -0
  329. package/dist/tools/enhancedSecurityTools.d.ts +19 -0
  330. package/dist/tools/enhancedSecurityTools.d.ts.map +1 -0
  331. package/dist/tools/enhancedSecurityTools.js +215 -0
  332. package/dist/tools/enhancedSecurityTools.js.map +1 -0
  333. package/dist/tools/offensiveSecurityTools.d.ts +16 -0
  334. package/dist/tools/offensiveSecurityTools.d.ts.map +1 -0
  335. package/dist/tools/offensiveSecurityTools.js +285 -0
  336. package/dist/tools/offensiveSecurityTools.js.map +1 -0
  337. package/dist/tools/realSecurityTools.d.ts +18 -0
  338. package/dist/tools/realSecurityTools.d.ts.map +1 -0
  339. package/dist/tools/realSecurityTools.js +468 -0
  340. package/dist/tools/realSecurityTools.js.map +1 -0
  341. package/dist/tools/securityTools.d.ts +20 -0
  342. package/dist/tools/securityTools.d.ts.map +1 -0
  343. package/dist/tools/securityTools.js +449 -0
  344. package/dist/tools/securityTools.js.map +1 -0
  345. package/package.json +27 -12
  346. package/scripts/deploy-security-capabilities.js +178 -0
@@ -0,0 +1,641 @@
1
+ import { readFileSync, existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import ts from 'typescript';
4
+ export function createCodeAnalysisTools(workingDir) {
5
+ return [
6
+ {
7
+ name: 'analyze_code_structure',
8
+ description: 'Analyze TypeScript/JavaScript file structure and extract functions, classes, interfaces, imports, and exports',
9
+ parameters: {
10
+ type: 'object',
11
+ properties: {
12
+ path: {
13
+ type: 'string',
14
+ description: 'Path to the TypeScript/JavaScript file to analyze',
15
+ },
16
+ },
17
+ required: ['path'],
18
+ additionalProperties: false,
19
+ },
20
+ handler: async (args) => {
21
+ try {
22
+ const filePath = resolveFilePath(workingDir, args['path']);
23
+ if (!existsSync(filePath)) {
24
+ return `Error: File not found: ${filePath}`;
25
+ }
26
+ const content = readFileSync(filePath, 'utf-8');
27
+ const analysis = analyzeTypeScriptFile(content, filePath);
28
+ return formatAnalysisResults(analysis);
29
+ }
30
+ catch (error) {
31
+ return formatHandlerError('analyzing file', error);
32
+ }
33
+ },
34
+ },
35
+ {
36
+ name: 'find_dependencies',
37
+ description: 'Find all dependencies and imports in a TypeScript/JavaScript file',
38
+ parameters: {
39
+ type: 'object',
40
+ properties: {
41
+ path: {
42
+ type: 'string',
43
+ description: 'Path to the TypeScript/JavaScript file',
44
+ },
45
+ },
46
+ required: ['path'],
47
+ additionalProperties: false,
48
+ },
49
+ handler: async (args) => {
50
+ try {
51
+ const filePath = resolveFilePath(workingDir, args['path']);
52
+ if (!existsSync(filePath)) {
53
+ return `Error: File not found: ${filePath}`;
54
+ }
55
+ const content = readFileSync(filePath, 'utf-8');
56
+ const analysis = analyzeTypeScriptFile(content, filePath);
57
+ return formatDependencies(analysis);
58
+ }
59
+ catch (error) {
60
+ return formatHandlerError('analyzing dependencies', error);
61
+ }
62
+ },
63
+ },
64
+ {
65
+ name: 'check_code_complexity',
66
+ description: 'Analyze code complexity metrics (function length, parameter count, etc.)',
67
+ parameters: {
68
+ type: 'object',
69
+ properties: {
70
+ path: {
71
+ type: 'string',
72
+ description: 'Path to the TypeScript/JavaScript file',
73
+ },
74
+ },
75
+ required: ['path'],
76
+ additionalProperties: false,
77
+ },
78
+ handler: async (args) => {
79
+ try {
80
+ const filePath = resolveFilePath(workingDir, args['path']);
81
+ if (!existsSync(filePath)) {
82
+ return `Error: File not found: ${filePath}`;
83
+ }
84
+ const content = readFileSync(filePath, 'utf-8');
85
+ const analysis = analyzeTypeScriptFile(content, filePath);
86
+ return formatComplexityMetrics(analysis);
87
+ }
88
+ catch (error) {
89
+ return formatHandlerError('analyzing complexity', error);
90
+ }
91
+ },
92
+ },
93
+ {
94
+ name: 'advanced_ast_analysis',
95
+ description: 'Perform AST-based analysis with cyclomatic complexity scoring, call graph construction, and potential hotspot detection.',
96
+ parameters: {
97
+ type: 'object',
98
+ properties: {
99
+ path: {
100
+ type: 'string',
101
+ description: 'Path to the TypeScript/JavaScript file to inspect',
102
+ },
103
+ },
104
+ required: ['path'],
105
+ additionalProperties: false,
106
+ },
107
+ handler: async (args) => {
108
+ try {
109
+ const filePath = resolveFilePath(workingDir, args['path']);
110
+ if (!existsSync(filePath)) {
111
+ return `Error: File not found: ${filePath}`;
112
+ }
113
+ const content = readFileSync(filePath, 'utf-8');
114
+ const analysis = performAdvancedAstAnalysis(content, filePath);
115
+ return formatAstAnalysis(analysis);
116
+ }
117
+ catch (error) {
118
+ return formatHandlerError('performing AST analysis', error);
119
+ }
120
+ },
121
+ },
122
+ ];
123
+ }
124
+ function resolveFilePath(workingDir, path) {
125
+ const normalized = validatePathArg(path);
126
+ return normalized.startsWith('/') ? normalized : join(workingDir, normalized);
127
+ }
128
+ function validatePathArg(path) {
129
+ if (typeof path !== 'string' || !path.trim()) {
130
+ throw new Error('Path must be a non-empty string.');
131
+ }
132
+ return path.trim();
133
+ }
134
+ export function analyzeTypeScriptFile(content, filePath) {
135
+ const lines = content.split('\n');
136
+ const result = {
137
+ file: filePath,
138
+ functions: [],
139
+ classes: [],
140
+ interfaces: [],
141
+ imports: [],
142
+ exports: [],
143
+ };
144
+ lines.forEach((line, index) => {
145
+ const lineNumber = index + 1;
146
+ const trimmed = line.trim();
147
+ // Parse imports
148
+ if (trimmed.startsWith('import')) {
149
+ const importInfo = parseImportStatement(trimmed, lineNumber);
150
+ if (importInfo) {
151
+ result.imports.push(importInfo);
152
+ }
153
+ }
154
+ // Parse exports
155
+ if (trimmed.startsWith('export')) {
156
+ const exportInfo = parseExportStatement(trimmed, lineNumber);
157
+ if (exportInfo) {
158
+ result.exports.push(exportInfo);
159
+ }
160
+ }
161
+ // Parse functions
162
+ const functionMatch = trimmed.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)/);
163
+ if (functionMatch) {
164
+ const fnName = functionMatch[1] ?? '';
165
+ const fnParams = functionMatch[2] ?? '';
166
+ result.functions.push({
167
+ name: fnName,
168
+ line: lineNumber,
169
+ parameters: parseParameters(fnParams),
170
+ });
171
+ }
172
+ // Parse arrow functions
173
+ const arrowFunctionMatch = trimmed.match(/^(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(?:\(([^)]*)\)|(\w+))\s*=>/);
174
+ if (arrowFunctionMatch) {
175
+ const name = arrowFunctionMatch[1] ?? '';
176
+ const params = arrowFunctionMatch[2] || arrowFunctionMatch[3] || '';
177
+ result.functions.push({
178
+ name,
179
+ line: lineNumber,
180
+ parameters: parseParameters(params),
181
+ });
182
+ }
183
+ // Parse classes
184
+ const classMatch = trimmed.match(/^(?:export\s+)?class\s+(\w+)/);
185
+ if (classMatch) {
186
+ const className = classMatch[1] ?? '';
187
+ result.classes.push({
188
+ name: className,
189
+ line: lineNumber,
190
+ methods: [],
191
+ properties: [],
192
+ });
193
+ }
194
+ // Parse interfaces
195
+ const interfaceMatch = trimmed.match(/^(?:export\s+)?interface\s+(\w+)/);
196
+ if (interfaceMatch) {
197
+ const interfaceName = interfaceMatch[1] ?? '';
198
+ result.interfaces.push({
199
+ name: interfaceName,
200
+ line: lineNumber,
201
+ properties: [],
202
+ methods: [],
203
+ });
204
+ }
205
+ // Parse class methods and properties (simplified)
206
+ if (trimmed.match(/^(?:public|private|protected|readonly)?\s*\w+\s*\([^)]*\)/)) {
207
+ const methodMatch = trimmed.match(/^(?:public|private|protected)?\s*(\w+)\s*\(([^)]*)\)/);
208
+ if (methodMatch && result.classes.length > 0) {
209
+ const currentClass = result.classes[result.classes.length - 1];
210
+ if (currentClass) {
211
+ currentClass.methods.push({
212
+ name: methodMatch[1] ?? '',
213
+ line: lineNumber,
214
+ parameters: parseParameters(methodMatch[2] ?? ''),
215
+ });
216
+ }
217
+ }
218
+ }
219
+ // Parse interface properties
220
+ if (trimmed.match(/^\w+\s*:/) && result.interfaces.length > 0) {
221
+ const propMatch = trimmed.match(/^(\w+)\s*:/);
222
+ if (propMatch) {
223
+ const currentInterface = result.interfaces[result.interfaces.length - 1];
224
+ if (currentInterface) {
225
+ currentInterface.properties.push({
226
+ name: propMatch[1] ?? '',
227
+ line: lineNumber,
228
+ });
229
+ }
230
+ }
231
+ }
232
+ });
233
+ return result;
234
+ }
235
+ export function performAdvancedAstAnalysis(content, filePath) {
236
+ const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
237
+ const symbols = [];
238
+ const callGraph = new Map();
239
+ const issues = [];
240
+ const symbolStack = [];
241
+ const recordCall = (callee) => {
242
+ if (!callee) {
243
+ return;
244
+ }
245
+ const caller = symbolStack[symbolStack.length - 1];
246
+ if (!caller) {
247
+ return;
248
+ }
249
+ if (!callGraph.has(caller)) {
250
+ callGraph.set(caller, new Map());
251
+ }
252
+ const targets = callGraph.get(caller);
253
+ targets.set(callee, (targets.get(callee) ?? 0) + 1);
254
+ };
255
+ const registerSymbol = (info) => {
256
+ symbols.push(info);
257
+ if (info.statementCount > 50) {
258
+ issues.push(`Large function detected: ${info.name} spans ${info.statementCount} statements.`);
259
+ }
260
+ if (info.cyclomaticComplexity > 10) {
261
+ issues.push(`High complexity function: ${info.name} cyclomatic complexity is ${info.cyclomaticComplexity}.`);
262
+ }
263
+ };
264
+ const visit = (node) => {
265
+ if (ts.isFunctionDeclaration(node) && node.name) {
266
+ const info = buildFunctionSymbol(node, node.name.text, 'function', sourceFile);
267
+ registerSymbol(info);
268
+ symbolStack.push(info.name);
269
+ ts.forEachChild(node, visit);
270
+ symbolStack.pop();
271
+ return;
272
+ }
273
+ if (ts.isClassDeclaration(node) && node.name) {
274
+ const info = buildClassSymbol(node, sourceFile);
275
+ registerSymbol(info);
276
+ ts.forEachChild(node, visit);
277
+ return;
278
+ }
279
+ if ((ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)) &&
280
+ ts.isClassLike(node.parent)) {
281
+ const className = (node.parent.name && node.parent.name.getText(sourceFile)) || 'anonymous-class';
282
+ const methodName = ts.isIdentifier(node.name) ? node.name.getText(sourceFile) : 'anonymous-method';
283
+ const info = buildFunctionSymbol(node, `${className}.${methodName}`, 'method', sourceFile);
284
+ registerSymbol(info);
285
+ symbolStack.push(info.name);
286
+ ts.forEachChild(node, visit);
287
+ symbolStack.pop();
288
+ return;
289
+ }
290
+ if (ts.isConstructorDeclaration(node) && ts.isClassLike(node.parent)) {
291
+ const className = (node.parent.name && node.parent.name.getText(sourceFile)) || 'anonymous-class';
292
+ const info = buildFunctionSymbol(node, `${className}.constructor`, 'method', sourceFile);
293
+ registerSymbol(info);
294
+ symbolStack.push(info.name);
295
+ ts.forEachChild(node, visit);
296
+ symbolStack.pop();
297
+ return;
298
+ }
299
+ if (ts.isVariableDeclaration(node) &&
300
+ node.initializer &&
301
+ (ts.isArrowFunction(node.initializer) || ts.isFunctionExpression(node.initializer)) &&
302
+ ts.isIdentifier(node.name)) {
303
+ const kind = ts.isArrowFunction(node.initializer) ? 'arrow-function' : 'function';
304
+ const info = buildFunctionSymbol(node.initializer, node.name.text, kind, sourceFile);
305
+ registerSymbol(info);
306
+ symbolStack.push(info.name);
307
+ ts.forEachChild(node.initializer, visit);
308
+ symbolStack.pop();
309
+ return;
310
+ }
311
+ if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
312
+ const callee = extractCalleeName(node.expression);
313
+ recordCall(callee);
314
+ }
315
+ ts.forEachChild(node, visit);
316
+ };
317
+ visit(sourceFile);
318
+ const callGraphList = [];
319
+ for (const [from, targets] of callGraph.entries()) {
320
+ for (const [to, count] of targets.entries()) {
321
+ callGraphList.push({ from, to, count });
322
+ }
323
+ }
324
+ const totalCyclomaticComplexity = symbols.reduce((sum, symbol) => sum + symbol.cyclomaticComplexity, 0);
325
+ return {
326
+ file: filePath,
327
+ symbols,
328
+ callGraph: callGraphList,
329
+ totalCyclomaticComplexity,
330
+ issues,
331
+ };
332
+ }
333
+ function buildFunctionSymbol(node, name, kind, sourceFile) {
334
+ const startLine = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;
335
+ const endLine = sourceFile.getLineAndCharacterOfPosition(node.end).line + 1;
336
+ const statementCount = countStatements(node);
337
+ const cyclomaticComplexity = estimateCyclomaticComplexity(node);
338
+ const parameters = node.parameters?.map((param) => param.name.getText(sourceFile)) ?? [];
339
+ return {
340
+ name,
341
+ kind,
342
+ startLine,
343
+ endLine,
344
+ parameters,
345
+ statementCount,
346
+ cyclomaticComplexity,
347
+ };
348
+ }
349
+ function buildClassSymbol(node, sourceFile) {
350
+ const name = (node.name && node.name.getText(sourceFile)) || 'AnonymousClass';
351
+ const startLine = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;
352
+ const endLine = sourceFile.getLineAndCharacterOfPosition(node.end).line + 1;
353
+ const statementCount = node.members.length;
354
+ const cyclomaticComplexity = node.members.reduce((sum, member) => {
355
+ if (ts.isMethodDeclaration(member) ||
356
+ ts.isConstructorDeclaration(member) ||
357
+ ts.isGetAccessorDeclaration(member) ||
358
+ ts.isSetAccessorDeclaration(member)) {
359
+ return sum + estimateCyclomaticComplexity(member);
360
+ }
361
+ return sum;
362
+ }, 1);
363
+ return {
364
+ name,
365
+ kind: 'class',
366
+ startLine,
367
+ endLine,
368
+ parameters: [],
369
+ statementCount,
370
+ cyclomaticComplexity,
371
+ };
372
+ }
373
+ function countStatements(node) {
374
+ const body = node.body;
375
+ if (!body) {
376
+ return 0;
377
+ }
378
+ if (ts.isBlock(body)) {
379
+ return body.statements.length;
380
+ }
381
+ return 1;
382
+ }
383
+ function estimateCyclomaticComplexity(node) {
384
+ let complexity = 1;
385
+ const visit = (child) => {
386
+ if (ts.isIfStatement(child) ||
387
+ ts.isForStatement(child) ||
388
+ ts.isWhileStatement(child) ||
389
+ ts.isForOfStatement(child) ||
390
+ ts.isForInStatement(child) ||
391
+ ts.isCaseClause(child) ||
392
+ ts.isCatchClause(child)) {
393
+ complexity += 1;
394
+ }
395
+ else if (ts.isConditionalExpression(child)) {
396
+ complexity += 1;
397
+ }
398
+ else if (ts.isBinaryExpression(child) &&
399
+ (child.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken ||
400
+ child.operatorToken.kind === ts.SyntaxKind.BarBarToken)) {
401
+ complexity += 1;
402
+ }
403
+ ts.forEachChild(child, visit);
404
+ };
405
+ ts.forEachChild(node, visit);
406
+ return complexity;
407
+ }
408
+ function extractCalleeName(expression) {
409
+ if (!expression) {
410
+ return null;
411
+ }
412
+ if (ts.isIdentifier(expression)) {
413
+ return expression.text;
414
+ }
415
+ if (ts.isPropertyAccessExpression(expression)) {
416
+ return expression.name.text;
417
+ }
418
+ return null;
419
+ }
420
+ function formatAstAnalysis(result) {
421
+ const output = [];
422
+ output.push(`# Advanced AST Analysis: ${result.file}`);
423
+ output.push('');
424
+ output.push('## Symbol Metrics');
425
+ if (result.symbols.length === 0) {
426
+ output.push('No functions or classes detected.');
427
+ }
428
+ else {
429
+ const sorted = [...result.symbols].sort((a, b) => b.cyclomaticComplexity - a.cyclomaticComplexity);
430
+ for (const symbol of sorted) {
431
+ output.push(`- ${symbol.name} (${symbol.kind}) lines ${symbol.startLine}-${symbol.endLine} | statements: ${symbol.statementCount} | CC: ${symbol.cyclomaticComplexity} | params: ${symbol.parameters.join(', ') || 'none'}`);
432
+ }
433
+ }
434
+ output.push('');
435
+ output.push('## Call Graph');
436
+ if (result.callGraph.length === 0) {
437
+ output.push('No function-to-function calls detected.');
438
+ }
439
+ else {
440
+ for (const edge of result.callGraph) {
441
+ output.push(`- ${edge.from} → ${edge.to} (x${edge.count})`);
442
+ }
443
+ }
444
+ output.push('');
445
+ output.push('## Hotspot Alerts');
446
+ if (result.issues.length === 0) {
447
+ output.push('No hotspots detected.');
448
+ }
449
+ else {
450
+ for (const issue of result.issues) {
451
+ output.push(`- ${issue}`);
452
+ }
453
+ }
454
+ output.push('');
455
+ const averageComplexity = result.symbols.length === 0 ? 0 : result.totalCyclomaticComplexity / result.symbols.length;
456
+ output.push('## Aggregate Metrics');
457
+ output.push(`- Total symbols analyzed: ${result.symbols.length}`);
458
+ output.push(`- Total cyclomatic complexity: ${result.totalCyclomaticComplexity}`);
459
+ output.push(`- Average cyclomatic complexity: ${averageComplexity.toFixed(2)}`);
460
+ return output.join('\n');
461
+ }
462
+ function formatHandlerError(task, error) {
463
+ const message = error instanceof Error ? error.message : String(error);
464
+ return `Error ${task}: ${message}`;
465
+ }
466
+ function parseImportStatement(line, lineNumber) {
467
+ // Simple import parsing - can be enhanced with proper AST parsing
468
+ const importMatch = line.match(/import\s+(?:\*\s+as\s+(\w+)|\{([^}]+)\}|(\w+))\s+from\s+['"]([^'"]+)['"]/);
469
+ if (importMatch) {
470
+ let specifiers = [];
471
+ if (importMatch[1]) {
472
+ // namespace import
473
+ specifiers = [`* as ${importMatch[1]}`];
474
+ }
475
+ else if (importMatch[2]) {
476
+ // named imports
477
+ specifiers = importMatch[2].split(',').map(s => s.trim()).filter(Boolean);
478
+ }
479
+ else if (importMatch[3]) {
480
+ // default import
481
+ specifiers = [importMatch[3]];
482
+ }
483
+ return {
484
+ source: importMatch[4] ?? '',
485
+ specifiers,
486
+ line: lineNumber,
487
+ };
488
+ }
489
+ return null;
490
+ }
491
+ function parseExportStatement(line, lineNumber) {
492
+ if (line.includes('export default')) {
493
+ const defaultMatch = line.match(/export\s+default\s+(\w+)/);
494
+ if (defaultMatch) {
495
+ return {
496
+ name: defaultMatch[1] ?? '',
497
+ type: 'default',
498
+ line: lineNumber,
499
+ };
500
+ }
501
+ }
502
+ else if (line.includes('export {')) {
503
+ const namedMatch = line.match(/export\s+\{\s*([^}]+)\s*\}/);
504
+ if (namedMatch) {
505
+ return {
506
+ name: namedMatch[1] ?? '',
507
+ type: 'named',
508
+ line: lineNumber,
509
+ };
510
+ }
511
+ }
512
+ else {
513
+ const exportMatch = line.match(/export\s+(?:class|function|interface|const|let|var)\s+(\w+)/);
514
+ if (exportMatch) {
515
+ return {
516
+ name: exportMatch[1] ?? '',
517
+ type: 'named',
518
+ line: lineNumber,
519
+ };
520
+ }
521
+ }
522
+ return null;
523
+ }
524
+ function parseParameters(paramString) {
525
+ return paramString
526
+ .split(',')
527
+ .map((p) => p.trim())
528
+ .filter((p) => p.length > 0)
529
+ .map((p) => {
530
+ // Extract parameter name (ignore types for now)
531
+ const nameMatch = p.match(/^(\w+)(?:\s*:\s*[^,]+)?$/);
532
+ return nameMatch?.[1] ?? p;
533
+ });
534
+ }
535
+ function formatAnalysisResults(analysis) {
536
+ const output = [];
537
+ output.push(`# Code Analysis: ${analysis.file}`);
538
+ output.push('');
539
+ if (analysis.imports.length > 0) {
540
+ output.push('## Imports');
541
+ analysis.imports.forEach(imp => {
542
+ output.push(`- Line ${imp.line}: from "${imp.source}"`);
543
+ if (imp.specifiers.length > 0) {
544
+ output.push(` ${imp.specifiers.join(', ')}`);
545
+ }
546
+ });
547
+ output.push('');
548
+ }
549
+ if (analysis.exports.length > 0) {
550
+ output.push('## Exports');
551
+ analysis.exports.forEach(exp => {
552
+ output.push(`- Line ${exp.line}: ${exp.type} ${exp.name}`);
553
+ });
554
+ output.push('');
555
+ }
556
+ if (analysis.functions.length > 0) {
557
+ output.push('## Functions');
558
+ analysis.functions.forEach(func => {
559
+ output.push(`- Line ${func.line}: ${func.name}(${func.parameters.join(', ')})`);
560
+ });
561
+ output.push('');
562
+ }
563
+ if (analysis.classes.length > 0) {
564
+ output.push('## Classes');
565
+ analysis.classes.forEach(cls => {
566
+ output.push(`- Line ${cls.line}: ${cls.name}`);
567
+ if (cls.methods.length > 0) {
568
+ output.push(` Methods: ${cls.methods.map(m => m.name).join(', ')}`);
569
+ }
570
+ if (cls.properties.length > 0) {
571
+ output.push(` Properties: ${cls.properties.map(p => p.name).join(', ')}`);
572
+ }
573
+ });
574
+ output.push('');
575
+ }
576
+ if (analysis.interfaces.length > 0) {
577
+ output.push('## Interfaces');
578
+ analysis.interfaces.forEach(intf => {
579
+ output.push(`- Line ${intf.line}: ${intf.name}`);
580
+ if (intf.properties.length > 0) {
581
+ output.push(` Properties: ${intf.properties.map(p => p.name).join(', ')}`);
582
+ }
583
+ if (intf.methods.length > 0) {
584
+ output.push(` Methods: ${intf.methods.map(m => m.name).join(', ')}`);
585
+ }
586
+ });
587
+ output.push('');
588
+ }
589
+ return output.join('\n');
590
+ }
591
+ function formatDependencies(analysis) {
592
+ const output = [];
593
+ output.push(`# Dependencies: ${analysis.file}`);
594
+ output.push('');
595
+ if (analysis.imports.length > 0) {
596
+ output.push('## Imported Modules');
597
+ analysis.imports.forEach(imp => {
598
+ output.push(`- ${imp.source}`);
599
+ if (imp.specifiers.length > 0) {
600
+ output.push(` Used: ${imp.specifiers.join(', ')}`);
601
+ }
602
+ });
603
+ }
604
+ else {
605
+ output.push('No imports found.');
606
+ }
607
+ return output.join('\n');
608
+ }
609
+ function formatComplexityMetrics(analysis) {
610
+ const output = [];
611
+ output.push(`# Code Complexity: ${analysis.file}`);
612
+ output.push('');
613
+ // Function complexity
614
+ if (analysis.functions.length > 0) {
615
+ output.push('## Function Complexity');
616
+ analysis.functions.forEach(func => {
617
+ const paramCount = func.parameters.length;
618
+ const complexity = paramCount > 3 ? 'High' : paramCount > 1 ? 'Medium' : 'Low';
619
+ output.push(`- ${func.name}: ${paramCount} parameters (${complexity})`);
620
+ });
621
+ }
622
+ // Class complexity
623
+ if (analysis.classes.length > 0) {
624
+ output.push('## Class Complexity');
625
+ analysis.classes.forEach(cls => {
626
+ const methodCount = cls.methods.length;
627
+ const propCount = cls.properties.length;
628
+ const complexity = methodCount + propCount > 5 ? 'High' : methodCount + propCount > 2 ? 'Medium' : 'Low';
629
+ output.push(`- ${cls.name}: ${methodCount} methods, ${propCount} properties (${complexity})`);
630
+ });
631
+ }
632
+ // Overall metrics
633
+ output.push('');
634
+ output.push('## Overall Metrics');
635
+ output.push(`- Total functions: ${analysis.functions.length}`);
636
+ output.push(`- Total classes: ${analysis.classes.length}`);
637
+ output.push(`- Total interfaces: ${analysis.interfaces.length}`);
638
+ output.push(`- Total imports: ${analysis.imports.length}`);
639
+ output.push(`- Total exports: ${analysis.exports.length}`);
640
+ return output.join('\n');
641
+ }