erosolar-cli 1.0.2 → 1.0.5

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 (437) hide show
  1. package/README.md +80 -44
  2. package/agents/erosolar-code.rules.json +167 -0
  3. package/agents/general.rules.json +188 -0
  4. package/dist/adapters/browser/index.d.ts +12 -0
  5. package/dist/adapters/browser/index.d.ts.map +1 -0
  6. package/dist/adapters/browser/index.js +1 -0
  7. package/dist/adapters/browser/index.js.map +1 -0
  8. package/dist/adapters/node/index.d.ts +17 -0
  9. package/dist/adapters/node/index.d.ts.map +1 -0
  10. package/dist/adapters/node/index.js +1 -0
  11. package/dist/adapters/node/index.js.map +1 -0
  12. package/dist/adapters/remote/index.d.ts +13 -0
  13. package/dist/adapters/remote/index.d.ts.map +1 -0
  14. package/dist/adapters/remote/index.js +1 -0
  15. package/dist/adapters/remote/index.js.map +1 -0
  16. package/dist/adapters/types.d.ts +14 -0
  17. package/dist/adapters/types.d.ts.map +1 -0
  18. package/dist/adapters/types.js +1 -0
  19. package/dist/adapters/types.js.map +1 -0
  20. package/dist/bin/erosolar.d.ts +3 -0
  21. package/dist/bin/erosolar.d.ts.map +1 -0
  22. package/dist/bin/erosolar.js +1 -0
  23. package/dist/bin/erosolar.js.map +1 -0
  24. package/dist/capabilities/bashCapability.d.ts +13 -0
  25. package/dist/capabilities/bashCapability.d.ts.map +1 -0
  26. package/dist/capabilities/bashCapability.js +1 -0
  27. package/dist/capabilities/bashCapability.js.map +1 -0
  28. package/dist/capabilities/codeAnalysisCapability.d.ts +13 -0
  29. package/dist/capabilities/codeAnalysisCapability.d.ts.map +1 -0
  30. package/dist/capabilities/codeAnalysisCapability.js +24 -0
  31. package/dist/capabilities/codeAnalysisCapability.js.map +1 -0
  32. package/dist/capabilities/codeGenerationCapability.d.ts +13 -0
  33. package/dist/capabilities/codeGenerationCapability.d.ts.map +1 -0
  34. package/dist/capabilities/codeGenerationCapability.js +25 -0
  35. package/dist/capabilities/codeGenerationCapability.js.map +1 -0
  36. package/dist/capabilities/codeQualityCapability.d.ts +13 -0
  37. package/dist/capabilities/codeQualityCapability.d.ts.map +1 -0
  38. package/dist/capabilities/codeQualityCapability.js +25 -0
  39. package/dist/capabilities/codeQualityCapability.js.map +1 -0
  40. package/dist/capabilities/dependencySecurityCapability.d.ts +13 -0
  41. package/dist/capabilities/dependencySecurityCapability.d.ts.map +1 -0
  42. package/dist/capabilities/dependencySecurityCapability.js +24 -0
  43. package/dist/capabilities/dependencySecurityCapability.js.map +1 -0
  44. package/dist/capabilities/devCapability.d.ts +13 -0
  45. package/dist/capabilities/devCapability.d.ts.map +1 -0
  46. package/dist/capabilities/devCapability.js +24 -0
  47. package/dist/capabilities/devCapability.js.map +1 -0
  48. package/dist/capabilities/filesystemCapability.d.ts +13 -0
  49. package/dist/capabilities/filesystemCapability.d.ts.map +1 -0
  50. package/dist/capabilities/filesystemCapability.js +1 -0
  51. package/dist/capabilities/filesystemCapability.js.map +1 -0
  52. package/dist/capabilities/index.d.ts +10 -0
  53. package/dist/capabilities/index.d.ts.map +1 -0
  54. package/dist/capabilities/index.js +7 -0
  55. package/dist/capabilities/index.js.map +1 -0
  56. package/dist/capabilities/refactoringCapability.d.ts +13 -0
  57. package/dist/capabilities/refactoringCapability.d.ts.map +1 -0
  58. package/dist/capabilities/refactoringCapability.js +25 -0
  59. package/dist/capabilities/refactoringCapability.js.map +1 -0
  60. package/dist/capabilities/repoChecksCapability.d.ts +10 -0
  61. package/dist/capabilities/repoChecksCapability.d.ts.map +1 -0
  62. package/dist/capabilities/repoChecksCapability.js +24 -0
  63. package/dist/capabilities/repoChecksCapability.js.map +1 -0
  64. package/dist/capabilities/searchCapability.d.ts +13 -0
  65. package/dist/capabilities/searchCapability.d.ts.map +1 -0
  66. package/dist/capabilities/searchCapability.js +1 -0
  67. package/dist/capabilities/searchCapability.js.map +1 -0
  68. package/dist/capabilities/testingCapability.d.ts +13 -0
  69. package/dist/capabilities/testingCapability.d.ts.map +1 -0
  70. package/dist/capabilities/testingCapability.js +25 -0
  71. package/dist/capabilities/testingCapability.js.map +1 -0
  72. package/dist/capabilities/toolManifest.d.ts +3 -0
  73. package/dist/capabilities/toolManifest.d.ts.map +1 -0
  74. package/dist/capabilities/toolManifest.js +160 -0
  75. package/dist/capabilities/toolManifest.js.map +1 -0
  76. package/dist/capabilities/toolRegistry.d.ts +22 -0
  77. package/dist/capabilities/toolRegistry.d.ts.map +1 -0
  78. package/dist/capabilities/toolRegistry.js +49 -32
  79. package/dist/capabilities/toolRegistry.js.map +1 -0
  80. package/dist/config.d.ts +25 -0
  81. package/dist/config.d.ts.map +1 -0
  82. package/dist/config.js +103 -23
  83. package/dist/config.js.map +1 -0
  84. package/dist/contracts/agent-profiles.schema.json +43 -0
  85. package/dist/contracts/agent-schemas.json +293 -0
  86. package/dist/contracts/schemas/agent-profile.schema.json +157 -0
  87. package/dist/contracts/schemas/agent-rules.schema.json +238 -0
  88. package/dist/contracts/schemas/agent-schemas.schema.json +528 -0
  89. package/dist/contracts/schemas/agent.schema.json +89 -0
  90. package/dist/contracts/schemas/tool-selection.schema.json +174 -0
  91. package/dist/contracts/tools.schema.json +100 -0
  92. package/dist/contracts/v1/agent.d.ts +147 -0
  93. package/dist/contracts/v1/agent.d.ts.map +1 -0
  94. package/dist/contracts/v1/agent.js +1 -0
  95. package/dist/contracts/v1/agent.js.map +1 -0
  96. package/dist/contracts/v1/agentProfileManifest.d.ts +60 -0
  97. package/dist/contracts/v1/agentProfileManifest.d.ts.map +1 -0
  98. package/dist/contracts/v1/agentProfileManifest.js +9 -0
  99. package/dist/contracts/v1/agentProfileManifest.js.map +1 -0
  100. package/dist/contracts/v1/agentRules.d.ts +60 -0
  101. package/dist/contracts/v1/agentRules.d.ts.map +1 -0
  102. package/dist/contracts/v1/agentRules.js +10 -0
  103. package/dist/contracts/v1/agentRules.js.map +1 -0
  104. package/dist/contracts/v1/provider.d.ts +149 -0
  105. package/dist/contracts/v1/provider.d.ts.map +1 -0
  106. package/dist/contracts/v1/provider.js +1 -0
  107. package/dist/contracts/v1/provider.js.map +1 -0
  108. package/dist/contracts/v1/tool.d.ts +136 -0
  109. package/dist/contracts/v1/tool.d.ts.map +1 -0
  110. package/dist/contracts/v1/tool.js +1 -0
  111. package/dist/contracts/v1/tool.js.map +1 -0
  112. package/dist/contracts/v1/toolAccess.d.ts +43 -0
  113. package/dist/contracts/v1/toolAccess.d.ts.map +1 -0
  114. package/dist/contracts/v1/toolAccess.js +9 -0
  115. package/dist/contracts/v1/toolAccess.js.map +1 -0
  116. package/dist/core/agent.d.ts +35 -0
  117. package/dist/core/agent.d.ts.map +1 -0
  118. package/dist/core/agent.js +17 -9
  119. package/dist/core/agent.js.map +1 -0
  120. package/dist/core/agentProfileManifest.d.ts +3 -0
  121. package/dist/core/agentProfileManifest.d.ts.map +1 -0
  122. package/dist/core/agentProfileManifest.js +188 -0
  123. package/dist/core/agentProfileManifest.js.map +1 -0
  124. package/dist/core/agentProfiles.d.ts +22 -0
  125. package/dist/core/agentProfiles.d.ts.map +1 -0
  126. package/dist/core/agentProfiles.js +1 -0
  127. package/dist/core/agentProfiles.js.map +1 -0
  128. package/dist/core/agentRulebook.d.ts +11 -0
  129. package/dist/core/agentRulebook.d.ts.map +1 -0
  130. package/dist/core/agentRulebook.js +136 -0
  131. package/dist/core/agentRulebook.js.map +1 -0
  132. package/dist/core/agentSchemaLoader.d.ts +131 -0
  133. package/dist/core/agentSchemaLoader.d.ts.map +1 -0
  134. package/dist/core/agentSchemaLoader.js +221 -0
  135. package/dist/core/agentSchemaLoader.js.map +1 -0
  136. package/dist/core/contextWindow.d.ts +6 -0
  137. package/dist/core/contextWindow.d.ts.map +1 -0
  138. package/dist/core/contextWindow.js +1 -0
  139. package/dist/core/contextWindow.js.map +1 -0
  140. package/dist/core/errors/apiKeyErrors.d.ts +11 -0
  141. package/dist/core/errors/apiKeyErrors.d.ts.map +1 -0
  142. package/dist/core/errors/apiKeyErrors.js +1 -0
  143. package/dist/core/errors/apiKeyErrors.js.map +1 -0
  144. package/dist/core/errors.d.ts +4 -0
  145. package/dist/core/errors.d.ts.map +1 -0
  146. package/dist/core/errors.js +33 -0
  147. package/dist/core/errors.js.map +1 -0
  148. package/dist/core/preferences.d.ts +21 -0
  149. package/dist/core/preferences.d.ts.map +1 -0
  150. package/dist/core/preferences.js +13 -7
  151. package/dist/core/preferences.js.map +1 -0
  152. package/dist/core/schemaValidator.d.ts +6 -0
  153. package/dist/core/schemaValidator.d.ts.map +1 -0
  154. package/dist/core/schemaValidator.js +93 -0
  155. package/dist/core/schemaValidator.js.map +1 -0
  156. package/dist/core/secretStore.d.ts +20 -0
  157. package/dist/core/secretStore.d.ts.map +1 -0
  158. package/dist/core/secretStore.js +3 -8
  159. package/dist/core/secretStore.js.map +1 -0
  160. package/dist/core/toolRuntime.d.ts +42 -0
  161. package/dist/core/toolRuntime.d.ts.map +1 -0
  162. package/dist/core/toolRuntime.js +25 -10
  163. package/dist/core/toolRuntime.js.map +1 -0
  164. package/dist/core/types.d.ts +86 -0
  165. package/dist/core/types.d.ts.map +1 -0
  166. package/dist/core/types.js +1 -0
  167. package/dist/core/types.js.map +1 -0
  168. package/dist/plugins/providers/anthropic/index.d.ts +2 -0
  169. package/dist/plugins/providers/anthropic/index.d.ts.map +1 -0
  170. package/dist/plugins/providers/anthropic/index.js +6 -4
  171. package/dist/plugins/providers/anthropic/index.js.map +1 -0
  172. package/dist/plugins/providers/deepseek/index.d.ts +2 -0
  173. package/dist/plugins/providers/deepseek/index.d.ts.map +1 -0
  174. package/dist/plugins/providers/deepseek/index.js +1 -0
  175. package/dist/plugins/providers/deepseek/index.js.map +1 -0
  176. package/dist/plugins/providers/google/index.d.ts +2 -0
  177. package/dist/plugins/providers/google/index.d.ts.map +1 -0
  178. package/dist/plugins/providers/google/index.js +6 -4
  179. package/dist/plugins/providers/google/index.js.map +1 -0
  180. package/dist/plugins/providers/index.d.ts +2 -0
  181. package/dist/plugins/providers/index.d.ts.map +1 -0
  182. package/dist/plugins/providers/index.js +1 -0
  183. package/dist/plugins/providers/index.js.map +1 -0
  184. package/dist/plugins/providers/openai/index.d.ts +3 -0
  185. package/dist/plugins/providers/openai/index.d.ts.map +1 -0
  186. package/dist/plugins/providers/openai/index.js +6 -4
  187. package/dist/plugins/providers/openai/index.js.map +1 -0
  188. package/dist/plugins/providers/xai/index.d.ts +2 -0
  189. package/dist/plugins/providers/xai/index.d.ts.map +1 -0
  190. package/dist/plugins/providers/xai/index.js +1 -0
  191. package/dist/plugins/providers/xai/index.js.map +1 -0
  192. package/dist/plugins/tools/bash/localBashPlugin.d.ts +3 -0
  193. package/dist/plugins/tools/bash/localBashPlugin.d.ts.map +1 -0
  194. package/dist/plugins/tools/bash/localBashPlugin.js +1 -0
  195. package/dist/plugins/tools/bash/localBashPlugin.js.map +1 -0
  196. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts +3 -0
  197. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts.map +1 -0
  198. package/dist/plugins/tools/checks/localRepoChecksPlugin.js +14 -0
  199. package/dist/plugins/tools/checks/localRepoChecksPlugin.js.map +1 -0
  200. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts +3 -0
  201. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts.map +1 -0
  202. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +14 -0
  203. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js.map +1 -0
  204. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts +3 -0
  205. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts.map +1 -0
  206. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js +14 -0
  207. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js.map +1 -0
  208. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts +3 -0
  209. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts.map +1 -0
  210. package/dist/plugins/tools/dependency/dependencyPlugin.js +12 -0
  211. package/dist/plugins/tools/dependency/dependencyPlugin.js.map +1 -0
  212. package/dist/plugins/tools/development/devPlugin.d.ts +3 -0
  213. package/dist/plugins/tools/development/devPlugin.d.ts.map +1 -0
  214. package/dist/plugins/tools/development/devPlugin.js +14 -0
  215. package/dist/plugins/tools/development/devPlugin.js.map +1 -0
  216. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts +3 -0
  217. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts.map +1 -0
  218. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js +1 -0
  219. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js.map +1 -0
  220. package/dist/plugins/tools/index.d.ts +3 -0
  221. package/dist/plugins/tools/index.d.ts.map +1 -0
  222. package/dist/plugins/tools/index.js +1 -0
  223. package/dist/plugins/tools/index.js.map +1 -0
  224. package/dist/plugins/tools/nodeDefaults.d.ts +2 -0
  225. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -0
  226. package/dist/plugins/tools/nodeDefaults.js +15 -2
  227. package/dist/plugins/tools/nodeDefaults.js.map +1 -0
  228. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts +3 -0
  229. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts.map +1 -0
  230. package/dist/plugins/tools/refactoring/refactoringPlugin.js +12 -0
  231. package/dist/plugins/tools/refactoring/refactoringPlugin.js.map +1 -0
  232. package/dist/plugins/tools/registry.d.ts +22 -0
  233. package/dist/plugins/tools/registry.d.ts.map +1 -0
  234. package/dist/plugins/tools/registry.js +1 -0
  235. package/dist/plugins/tools/registry.js.map +1 -0
  236. package/dist/plugins/tools/search/localSearchPlugin.d.ts +3 -0
  237. package/dist/plugins/tools/search/localSearchPlugin.d.ts.map +1 -0
  238. package/dist/plugins/tools/search/localSearchPlugin.js +1 -0
  239. package/dist/plugins/tools/search/localSearchPlugin.js.map +1 -0
  240. package/dist/plugins/tools/testing/testingPlugin.d.ts +3 -0
  241. package/dist/plugins/tools/testing/testingPlugin.d.ts.map +1 -0
  242. package/dist/plugins/tools/testing/testingPlugin.js +12 -0
  243. package/dist/plugins/tools/testing/testingPlugin.js.map +1 -0
  244. package/dist/providers/anthropicProvider.d.ts +23 -0
  245. package/dist/providers/anthropicProvider.d.ts.map +1 -0
  246. package/dist/providers/anthropicProvider.js +3 -2
  247. package/dist/providers/anthropicProvider.js.map +1 -0
  248. package/dist/providers/googleProvider.d.ts +19 -0
  249. package/dist/providers/googleProvider.d.ts.map +1 -0
  250. package/dist/providers/googleProvider.js +1 -1
  251. package/dist/providers/googleProvider.js.map +1 -0
  252. package/dist/providers/openaiChatCompletionsProvider.d.ts +16 -0
  253. package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
  254. package/dist/providers/openaiChatCompletionsProvider.js +1 -0
  255. package/dist/providers/openaiChatCompletionsProvider.js.map +1 -0
  256. package/dist/providers/openaiResponsesProvider.d.ts +20 -0
  257. package/dist/providers/openaiResponsesProvider.d.ts.map +1 -0
  258. package/dist/providers/openaiResponsesProvider.js +1 -0
  259. package/dist/providers/openaiResponsesProvider.js.map +1 -0
  260. package/dist/providers/providerFactory.d.ts +18 -0
  261. package/dist/providers/providerFactory.d.ts.map +1 -0
  262. package/dist/providers/providerFactory.js +5 -1
  263. package/dist/providers/providerFactory.js.map +1 -0
  264. package/dist/runtime/agentHost.d.ts +61 -0
  265. package/dist/runtime/agentHost.d.ts.map +1 -0
  266. package/dist/runtime/agentHost.js +5 -1
  267. package/dist/runtime/agentHost.js.map +1 -0
  268. package/dist/runtime/agentSession.d.ts +32 -0
  269. package/dist/runtime/agentSession.d.ts.map +1 -0
  270. package/dist/runtime/agentSession.js +17 -1
  271. package/dist/runtime/agentSession.js.map +1 -0
  272. package/dist/runtime/browser.d.ts +7 -0
  273. package/dist/runtime/browser.d.ts.map +1 -0
  274. package/dist/runtime/browser.js +1 -0
  275. package/dist/runtime/browser.js.map +1 -0
  276. package/dist/runtime/cloud.d.ts +7 -0
  277. package/dist/runtime/cloud.d.ts.map +1 -0
  278. package/dist/runtime/cloud.js +1 -0
  279. package/dist/runtime/cloud.js.map +1 -0
  280. package/dist/runtime/node.d.ts +8 -0
  281. package/dist/runtime/node.d.ts.map +1 -0
  282. package/dist/runtime/node.js +1 -0
  283. package/dist/runtime/node.js.map +1 -0
  284. package/dist/runtime/universal.d.ts +21 -0
  285. package/dist/runtime/universal.d.ts.map +1 -0
  286. package/dist/runtime/universal.js +1 -0
  287. package/dist/runtime/universal.js.map +1 -0
  288. package/dist/shell/bracketedPasteManager.d.ts +23 -0
  289. package/dist/shell/bracketedPasteManager.d.ts.map +1 -0
  290. package/dist/shell/bracketedPasteManager.js +1 -0
  291. package/dist/shell/bracketedPasteManager.js.map +1 -0
  292. package/dist/shell/interactiveShell.d.ts +131 -0
  293. package/dist/shell/interactiveShell.d.ts.map +1 -0
  294. package/dist/shell/interactiveShell.js +325 -262
  295. package/dist/shell/interactiveShell.js.map +1 -0
  296. package/dist/shell/liveStatus.d.ts +29 -0
  297. package/dist/shell/liveStatus.d.ts.map +1 -0
  298. package/dist/shell/liveStatus.js +77 -0
  299. package/dist/shell/liveStatus.js.map +1 -0
  300. package/dist/shell/promptSkin.d.ts +43 -0
  301. package/dist/shell/promptSkin.d.ts.map +1 -0
  302. package/dist/shell/promptSkin.js +330 -0
  303. package/dist/shell/promptSkin.js.map +1 -0
  304. package/dist/shell/shellApp.d.ts +10 -0
  305. package/dist/shell/shellApp.d.ts.map +1 -0
  306. package/dist/shell/shellApp.js +149 -78
  307. package/dist/shell/shellApp.js.map +1 -0
  308. package/dist/shell/systemPrompt.d.ts +3 -0
  309. package/dist/shell/systemPrompt.d.ts.map +1 -0
  310. package/dist/shell/systemPrompt.js +64 -0
  311. package/dist/shell/systemPrompt.js.map +1 -0
  312. package/dist/shell/updateManager.d.ts +2 -0
  313. package/dist/shell/updateManager.d.ts.map +1 -0
  314. package/dist/shell/updateManager.js +109 -0
  315. package/dist/shell/updateManager.js.map +1 -0
  316. package/dist/tools/bashTools.d.ts +8 -0
  317. package/dist/tools/bashTools.d.ts.map +1 -0
  318. package/dist/tools/bashTools.js +18 -15
  319. package/dist/tools/bashTools.js.map +1 -0
  320. package/dist/tools/codeAnalysisTools.d.ts +74 -0
  321. package/dist/tools/codeAnalysisTools.d.ts.map +1 -0
  322. package/dist/tools/codeAnalysisTools.js +642 -0
  323. package/dist/tools/codeAnalysisTools.js.map +1 -0
  324. package/dist/tools/codeGenerationTools.d.ts +3 -0
  325. package/dist/tools/codeGenerationTools.d.ts.map +1 -0
  326. package/dist/tools/codeGenerationTools.js +369 -0
  327. package/dist/tools/codeGenerationTools.js.map +1 -0
  328. package/dist/tools/codeQualityTools.d.ts +3 -0
  329. package/dist/tools/codeQualityTools.d.ts.map +1 -0
  330. package/dist/tools/codeQualityTools.js +295 -0
  331. package/dist/tools/codeQualityTools.js.map +1 -0
  332. package/dist/tools/dependencyTools.d.ts +3 -0
  333. package/dist/tools/dependencyTools.d.ts.map +1 -0
  334. package/dist/tools/dependencyTools.js +283 -0
  335. package/dist/tools/dependencyTools.js.map +1 -0
  336. package/dist/tools/devTools.d.ts +10 -0
  337. package/dist/tools/devTools.d.ts.map +1 -0
  338. package/dist/tools/devTools.js +239 -0
  339. package/dist/tools/devTools.js.map +1 -0
  340. package/dist/tools/diffUtils.d.ts +8 -0
  341. package/dist/tools/diffUtils.d.ts.map +1 -0
  342. package/dist/tools/diffUtils.js +2 -1
  343. package/dist/tools/diffUtils.js.map +1 -0
  344. package/dist/tools/fileTools.d.ts +3 -0
  345. package/dist/tools/fileTools.d.ts.map +1 -0
  346. package/dist/tools/fileTools.js +72 -21
  347. package/dist/tools/fileTools.js.map +1 -0
  348. package/dist/tools/refactoringTools.d.ts +3 -0
  349. package/dist/tools/refactoringTools.d.ts.map +1 -0
  350. package/dist/tools/refactoringTools.js +294 -0
  351. package/dist/tools/refactoringTools.js.map +1 -0
  352. package/dist/tools/repoChecksTools.d.ts +3 -0
  353. package/dist/tools/repoChecksTools.d.ts.map +1 -0
  354. package/dist/tools/repoChecksTools.js +161 -0
  355. package/dist/tools/repoChecksTools.js.map +1 -0
  356. package/dist/tools/searchTools.d.ts +3 -0
  357. package/dist/tools/searchTools.d.ts.map +1 -0
  358. package/dist/tools/searchTools.js +50 -22
  359. package/dist/tools/searchTools.js.map +1 -0
  360. package/dist/tools/testingTools.d.ts +3 -0
  361. package/dist/tools/testingTools.d.ts.map +1 -0
  362. package/dist/tools/testingTools.js +233 -0
  363. package/dist/tools/testingTools.js.map +1 -0
  364. package/dist/ui/ShellUIAdapter.d.ts +96 -0
  365. package/dist/ui/ShellUIAdapter.d.ts.map +1 -0
  366. package/dist/ui/ShellUIAdapter.js +442 -0
  367. package/dist/ui/ShellUIAdapter.js.map +1 -0
  368. package/dist/ui/UnifiedUIController.d.ts +196 -0
  369. package/dist/ui/UnifiedUIController.d.ts.map +1 -0
  370. package/dist/ui/UnifiedUIController.js +640 -0
  371. package/dist/ui/UnifiedUIController.js.map +1 -0
  372. package/dist/ui/animation/AnimationScheduler.d.ts +192 -0
  373. package/dist/ui/animation/AnimationScheduler.d.ts.map +1 -0
  374. package/dist/ui/animation/AnimationScheduler.js +432 -0
  375. package/dist/ui/animation/AnimationScheduler.js.map +1 -0
  376. package/dist/ui/codeHighlighter.d.ts +6 -0
  377. package/dist/ui/codeHighlighter.d.ts.map +1 -0
  378. package/dist/ui/codeHighlighter.js +41 -29
  379. package/dist/ui/codeHighlighter.js.map +1 -0
  380. package/dist/ui/designSystem.d.ts +26 -0
  381. package/dist/ui/designSystem.d.ts.map +1 -0
  382. package/dist/ui/designSystem.js +17 -1
  383. package/dist/ui/designSystem.js.map +1 -0
  384. package/dist/ui/display.d.ts +160 -0
  385. package/dist/ui/display.d.ts.map +1 -0
  386. package/dist/ui/display.js +492 -231
  387. package/dist/ui/display.js.map +1 -0
  388. package/dist/ui/interrupts/InterruptManager.d.ts +142 -0
  389. package/dist/ui/interrupts/InterruptManager.d.ts.map +1 -0
  390. package/dist/ui/interrupts/InterruptManager.js +439 -0
  391. package/dist/ui/interrupts/InterruptManager.js.map +1 -0
  392. package/dist/ui/layout.d.ts +17 -0
  393. package/dist/ui/layout.d.ts.map +1 -0
  394. package/dist/ui/layout.js +12 -7
  395. package/dist/ui/layout.js.map +1 -0
  396. package/dist/ui/orchestration/StatusOrchestrator.d.ts +156 -0
  397. package/dist/ui/orchestration/StatusOrchestrator.d.ts.map +1 -0
  398. package/dist/ui/orchestration/StatusOrchestrator.js +405 -0
  399. package/dist/ui/orchestration/StatusOrchestrator.js.map +1 -0
  400. package/dist/ui/overlay/OverlayManager.d.ts +105 -0
  401. package/dist/ui/overlay/OverlayManager.d.ts.map +1 -0
  402. package/dist/ui/overlay/OverlayManager.js +291 -0
  403. package/dist/ui/overlay/OverlayManager.js.map +1 -0
  404. package/dist/ui/richText.d.ts +6 -0
  405. package/dist/ui/richText.d.ts.map +1 -0
  406. package/dist/ui/richText.js +13 -4
  407. package/dist/ui/richText.js.map +1 -0
  408. package/dist/ui/telemetry/UITelemetry.d.ts +181 -0
  409. package/dist/ui/telemetry/UITelemetry.d.ts.map +1 -0
  410. package/dist/ui/telemetry/UITelemetry.js +446 -0
  411. package/dist/ui/telemetry/UITelemetry.js.map +1 -0
  412. package/dist/ui/theme.d.ts +77 -0
  413. package/dist/ui/theme.d.ts.map +1 -0
  414. package/dist/ui/theme.js +19 -6
  415. package/dist/ui/theme.js.map +1 -0
  416. package/dist/utils/errorUtils.d.ts +16 -0
  417. package/dist/utils/errorUtils.d.ts.map +1 -0
  418. package/dist/utils/errorUtils.js +66 -0
  419. package/dist/utils/errorUtils.js.map +1 -0
  420. package/dist/utils/nodeVersion.d.ts +3 -0
  421. package/dist/utils/nodeVersion.d.ts.map +1 -0
  422. package/dist/utils/nodeVersion.js +51 -0
  423. package/dist/utils/nodeVersion.js.map +1 -0
  424. package/dist/workspace.d.ts +8 -0
  425. package/dist/workspace.d.ts.map +1 -0
  426. package/dist/workspace.js +72 -11
  427. package/dist/workspace.js.map +1 -0
  428. package/package.json +35 -16
  429. package/scripts/health-check.mjs +176 -0
  430. package/ARCHITECTURE.json +0 -157
  431. package/Agents.md +0 -207
  432. package/SOURCE_OF_TRUTH.json +0 -103
  433. package/dist/capabilities/tavilyCapability.js +0 -26
  434. package/dist/plugins/tools/tavily/tavilyPlugin.js +0 -16
  435. package/dist/shell/__tests__/bracketedPasteManager.test.js +0 -35
  436. package/dist/tools/tavilyTools.js +0 -176
  437. package/dist/ui/__tests__/richText.test.js +0 -36
@@ -0,0 +1,642 @@
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
+ }
642
+ //# sourceMappingURL=codeAnalysisTools.js.map