erosolar-cli 1.7.415 → 1.7.417

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 (972) hide show
  1. package/dist/StringUtils.d.ts +8 -0
  2. package/dist/StringUtils.d.ts.map +1 -0
  3. package/dist/StringUtils.js +11 -0
  4. package/dist/StringUtils.js.map +1 -0
  5. package/dist/adapters/browser/index.d.ts +12 -0
  6. package/dist/adapters/browser/index.d.ts.map +1 -0
  7. package/dist/adapters/browser/index.js +11 -0
  8. package/dist/adapters/browser/index.js.map +1 -0
  9. package/dist/adapters/node/index.d.ts +17 -0
  10. package/dist/adapters/node/index.d.ts.map +1 -0
  11. package/dist/adapters/node/index.js +35 -0
  12. package/dist/adapters/node/index.js.map +1 -0
  13. package/dist/adapters/remote/index.d.ts +13 -0
  14. package/dist/adapters/remote/index.d.ts.map +1 -0
  15. package/dist/adapters/remote/index.js +20 -0
  16. package/dist/adapters/remote/index.js.map +1 -0
  17. package/dist/adapters/types.d.ts +14 -0
  18. package/dist/adapters/types.d.ts.map +1 -0
  19. package/dist/adapters/types.js +2 -0
  20. package/dist/adapters/types.js.map +1 -0
  21. package/dist/bin/erosolar.d.ts +9 -0
  22. package/dist/bin/erosolar.d.ts.map +1 -0
  23. package/dist/bin/erosolar.js +93 -0
  24. package/dist/bin/erosolar.js.map +1 -0
  25. package/dist/bin/selfTest.d.ts +14 -0
  26. package/dist/bin/selfTest.d.ts.map +1 -0
  27. package/dist/bin/selfTest.js +304 -0
  28. package/dist/bin/selfTest.js.map +1 -0
  29. package/dist/browser/BrowserSessionManager.d.ts +307 -0
  30. package/dist/browser/BrowserSessionManager.d.ts.map +1 -0
  31. package/dist/browser/BrowserSessionManager.js +713 -0
  32. package/dist/browser/BrowserSessionManager.js.map +1 -0
  33. package/dist/capabilities/advancedTestGenerationCapability.d.ts +17 -0
  34. package/dist/capabilities/advancedTestGenerationCapability.d.ts.map +1 -0
  35. package/dist/capabilities/advancedTestGenerationCapability.js +28 -0
  36. package/dist/capabilities/advancedTestGenerationCapability.js.map +1 -0
  37. package/dist/capabilities/agentSpawningCapability.d.ts +6 -0
  38. package/dist/capabilities/agentSpawningCapability.d.ts.map +1 -0
  39. package/dist/capabilities/agentSpawningCapability.js +168 -0
  40. package/dist/capabilities/agentSpawningCapability.js.map +1 -0
  41. package/dist/capabilities/askUserCapability.d.ts +21 -0
  42. package/dist/capabilities/askUserCapability.d.ts.map +1 -0
  43. package/dist/capabilities/askUserCapability.js +155 -0
  44. package/dist/capabilities/askUserCapability.js.map +1 -0
  45. package/dist/capabilities/bashCapability.d.ts +13 -0
  46. package/dist/capabilities/bashCapability.d.ts.map +1 -0
  47. package/dist/capabilities/bashCapability.js +24 -0
  48. package/dist/capabilities/bashCapability.js.map +1 -0
  49. package/dist/capabilities/browserAutomationCapability.d.ts +37 -0
  50. package/dist/capabilities/browserAutomationCapability.d.ts.map +1 -0
  51. package/dist/capabilities/browserAutomationCapability.js +49 -0
  52. package/dist/capabilities/browserAutomationCapability.js.map +1 -0
  53. package/dist/capabilities/buildCapability.d.ts +24 -0
  54. package/dist/capabilities/buildCapability.d.ts.map +1 -0
  55. package/dist/capabilities/buildCapability.js +25 -0
  56. package/dist/capabilities/buildCapability.js.map +1 -0
  57. package/dist/capabilities/cloudCapability.d.ts +13 -0
  58. package/dist/capabilities/cloudCapability.d.ts.map +1 -0
  59. package/dist/capabilities/cloudCapability.js +38 -0
  60. package/dist/capabilities/cloudCapability.js.map +1 -0
  61. package/dist/capabilities/codeAnalysisCapability.d.ts +13 -0
  62. package/dist/capabilities/codeAnalysisCapability.d.ts.map +1 -0
  63. package/dist/capabilities/codeAnalysisCapability.js +24 -0
  64. package/dist/capabilities/codeAnalysisCapability.js.map +1 -0
  65. package/dist/capabilities/codeGenerationCapability.d.ts +13 -0
  66. package/dist/capabilities/codeGenerationCapability.d.ts.map +1 -0
  67. package/dist/capabilities/codeGenerationCapability.js +25 -0
  68. package/dist/capabilities/codeGenerationCapability.js.map +1 -0
  69. package/dist/capabilities/codeQualityCapability.d.ts +13 -0
  70. package/dist/capabilities/codeQualityCapability.d.ts.map +1 -0
  71. package/dist/capabilities/codeQualityCapability.js +25 -0
  72. package/dist/capabilities/codeQualityCapability.js.map +1 -0
  73. package/dist/capabilities/dependencySecurityCapability.d.ts +13 -0
  74. package/dist/capabilities/dependencySecurityCapability.d.ts.map +1 -0
  75. package/dist/capabilities/dependencySecurityCapability.js +24 -0
  76. package/dist/capabilities/dependencySecurityCapability.js.map +1 -0
  77. package/dist/capabilities/devCapability.d.ts +13 -0
  78. package/dist/capabilities/devCapability.d.ts.map +1 -0
  79. package/dist/capabilities/devCapability.js +24 -0
  80. package/dist/capabilities/devCapability.js.map +1 -0
  81. package/dist/capabilities/editCapability.d.ts +17 -0
  82. package/dist/capabilities/editCapability.d.ts.map +1 -0
  83. package/dist/capabilities/editCapability.js +27 -0
  84. package/dist/capabilities/editCapability.js.map +1 -0
  85. package/dist/capabilities/emailCapability.d.ts +12 -0
  86. package/dist/capabilities/emailCapability.d.ts.map +1 -0
  87. package/dist/capabilities/emailCapability.js +22 -0
  88. package/dist/capabilities/emailCapability.js.map +1 -0
  89. package/dist/capabilities/enhancedCodeIntelligenceCapability.d.ts +17 -0
  90. package/dist/capabilities/enhancedCodeIntelligenceCapability.d.ts.map +1 -0
  91. package/dist/capabilities/enhancedCodeIntelligenceCapability.js +28 -0
  92. package/dist/capabilities/enhancedCodeIntelligenceCapability.js.map +1 -0
  93. package/dist/capabilities/enhancedDevWorkflowCapability.d.ts +17 -0
  94. package/dist/capabilities/enhancedDevWorkflowCapability.d.ts.map +1 -0
  95. package/dist/capabilities/enhancedDevWorkflowCapability.js +28 -0
  96. package/dist/capabilities/enhancedDevWorkflowCapability.js.map +1 -0
  97. package/dist/capabilities/enhancedGitCapability.d.ts +7 -0
  98. package/dist/capabilities/enhancedGitCapability.d.ts.map +1 -0
  99. package/dist/capabilities/enhancedGitCapability.js +220 -0
  100. package/dist/capabilities/enhancedGitCapability.js.map +1 -0
  101. package/dist/capabilities/filesystemCapability.d.ts +13 -0
  102. package/dist/capabilities/filesystemCapability.d.ts.map +1 -0
  103. package/dist/capabilities/filesystemCapability.js +24 -0
  104. package/dist/capabilities/filesystemCapability.js.map +1 -0
  105. package/dist/capabilities/frontendTestingCapability.d.ts +13 -0
  106. package/dist/capabilities/frontendTestingCapability.d.ts.map +1 -0
  107. package/dist/capabilities/frontendTestingCapability.js +28 -0
  108. package/dist/capabilities/frontendTestingCapability.js.map +1 -0
  109. package/dist/capabilities/globCapability.d.ts +17 -0
  110. package/dist/capabilities/globCapability.d.ts.map +1 -0
  111. package/dist/capabilities/globCapability.js +27 -0
  112. package/dist/capabilities/globCapability.js.map +1 -0
  113. package/dist/capabilities/index.d.ts +26 -0
  114. package/dist/capabilities/index.d.ts.map +1 -0
  115. package/dist/capabilities/index.js +26 -0
  116. package/dist/capabilities/index.js.map +1 -0
  117. package/dist/capabilities/interactionCapability.d.ts +12 -0
  118. package/dist/capabilities/interactionCapability.d.ts.map +1 -0
  119. package/dist/capabilities/interactionCapability.js +22 -0
  120. package/dist/capabilities/interactionCapability.js.map +1 -0
  121. package/dist/capabilities/learnCapability.d.ts +22 -0
  122. package/dist/capabilities/learnCapability.d.ts.map +1 -0
  123. package/dist/capabilities/learnCapability.js +37 -0
  124. package/dist/capabilities/learnCapability.js.map +1 -0
  125. package/dist/capabilities/mcpCapability.d.ts +6 -0
  126. package/dist/capabilities/mcpCapability.d.ts.map +1 -0
  127. package/dist/capabilities/mcpCapability.js +19 -0
  128. package/dist/capabilities/mcpCapability.js.map +1 -0
  129. package/dist/capabilities/notebookCapability.d.ts +17 -0
  130. package/dist/capabilities/notebookCapability.d.ts.map +1 -0
  131. package/dist/capabilities/notebookCapability.js +27 -0
  132. package/dist/capabilities/notebookCapability.js.map +1 -0
  133. package/dist/capabilities/performanceMonitoringCapability.d.ts +108 -0
  134. package/dist/capabilities/performanceMonitoringCapability.d.ts.map +1 -0
  135. package/dist/capabilities/performanceMonitoringCapability.js +176 -0
  136. package/dist/capabilities/performanceMonitoringCapability.js.map +1 -0
  137. package/dist/capabilities/planningCapability.d.ts +16 -0
  138. package/dist/capabilities/planningCapability.d.ts.map +1 -0
  139. package/dist/capabilities/planningCapability.js +26 -0
  140. package/dist/capabilities/planningCapability.js.map +1 -0
  141. package/dist/capabilities/refactoringCapability.d.ts +13 -0
  142. package/dist/capabilities/refactoringCapability.d.ts.map +1 -0
  143. package/dist/capabilities/refactoringCapability.js +25 -0
  144. package/dist/capabilities/refactoringCapability.js.map +1 -0
  145. package/dist/capabilities/repoChecksCapability.d.ts +10 -0
  146. package/dist/capabilities/repoChecksCapability.d.ts.map +1 -0
  147. package/dist/capabilities/repoChecksCapability.js +24 -0
  148. package/dist/capabilities/repoChecksCapability.js.map +1 -0
  149. package/dist/capabilities/searchCapability.d.ts +13 -0
  150. package/dist/capabilities/searchCapability.d.ts.map +1 -0
  151. package/dist/capabilities/searchCapability.js +24 -0
  152. package/dist/capabilities/searchCapability.js.map +1 -0
  153. package/dist/capabilities/skillCapability.d.ts +3 -0
  154. package/dist/capabilities/skillCapability.d.ts.map +1 -0
  155. package/dist/capabilities/skillCapability.js +77 -0
  156. package/dist/capabilities/skillCapability.js.map +1 -0
  157. package/dist/capabilities/taskManagementCapability.d.ts +12 -0
  158. package/dist/capabilities/taskManagementCapability.d.ts.map +1 -0
  159. package/dist/capabilities/taskManagementCapability.js +22 -0
  160. package/dist/capabilities/taskManagementCapability.js.map +1 -0
  161. package/dist/capabilities/testingCapability.d.ts +13 -0
  162. package/dist/capabilities/testingCapability.d.ts.map +1 -0
  163. package/dist/capabilities/testingCapability.js +25 -0
  164. package/dist/capabilities/testingCapability.js.map +1 -0
  165. package/dist/capabilities/todoCapability.d.ts +19 -0
  166. package/dist/capabilities/todoCapability.d.ts.map +1 -0
  167. package/dist/capabilities/todoCapability.js +169 -0
  168. package/dist/capabilities/todoCapability.js.map +1 -0
  169. package/dist/capabilities/toolManifest.d.ts +3 -0
  170. package/dist/capabilities/toolManifest.d.ts.map +1 -0
  171. package/dist/capabilities/toolManifest.js +160 -0
  172. package/dist/capabilities/toolManifest.js.map +1 -0
  173. package/dist/capabilities/toolRegistry.d.ts +24 -0
  174. package/dist/capabilities/toolRegistry.d.ts.map +1 -0
  175. package/dist/capabilities/toolRegistry.js +150 -0
  176. package/dist/capabilities/toolRegistry.js.map +1 -0
  177. package/dist/capabilities/validationCapability.d.ts +13 -0
  178. package/dist/capabilities/validationCapability.d.ts.map +1 -0
  179. package/dist/capabilities/validationCapability.js +24 -0
  180. package/dist/capabilities/validationCapability.js.map +1 -0
  181. package/dist/capabilities/webCapability.d.ts +12 -0
  182. package/dist/capabilities/webCapability.d.ts.map +1 -0
  183. package/dist/capabilities/webCapability.js +22 -0
  184. package/dist/capabilities/webCapability.js.map +1 -0
  185. package/dist/config.d.ts +25 -0
  186. package/dist/config.d.ts.map +1 -0
  187. package/dist/config.js +140 -0
  188. package/dist/config.js.map +1 -0
  189. package/dist/contracts/v1/agent.d.ts +147 -0
  190. package/dist/contracts/v1/agent.d.ts.map +1 -0
  191. package/dist/contracts/v1/agent.js +8 -0
  192. package/dist/contracts/v1/agent.js.map +1 -0
  193. package/dist/contracts/v1/agentProfileManifest.d.ts +60 -0
  194. package/dist/contracts/v1/agentProfileManifest.d.ts.map +1 -0
  195. package/dist/contracts/v1/agentProfileManifest.js +9 -0
  196. package/dist/contracts/v1/agentProfileManifest.js.map +1 -0
  197. package/dist/contracts/v1/agentRules.d.ts +60 -0
  198. package/dist/contracts/v1/agentRules.d.ts.map +1 -0
  199. package/dist/contracts/v1/agentRules.js +10 -0
  200. package/dist/contracts/v1/agentRules.js.map +1 -0
  201. package/dist/contracts/v1/provider.d.ts +149 -0
  202. package/dist/contracts/v1/provider.d.ts.map +1 -0
  203. package/dist/contracts/v1/provider.js +7 -0
  204. package/dist/contracts/v1/provider.js.map +1 -0
  205. package/dist/contracts/v1/tool.d.ts +136 -0
  206. package/dist/contracts/v1/tool.d.ts.map +1 -0
  207. package/dist/contracts/v1/tool.js +7 -0
  208. package/dist/contracts/v1/tool.js.map +1 -0
  209. package/dist/contracts/v1/toolAccess.d.ts +43 -0
  210. package/dist/contracts/v1/toolAccess.d.ts.map +1 -0
  211. package/dist/contracts/v1/toolAccess.js +9 -0
  212. package/dist/contracts/v1/toolAccess.js.map +1 -0
  213. package/dist/core/LazyLoader.d.ts +129 -0
  214. package/dist/core/LazyLoader.d.ts.map +1 -0
  215. package/dist/core/LazyLoader.js +240 -0
  216. package/dist/core/LazyLoader.js.map +1 -0
  217. package/dist/core/agent.d.ts +153 -0
  218. package/dist/core/agent.d.ts.map +1 -0
  219. package/dist/core/agent.js +881 -0
  220. package/dist/core/agent.js.map +1 -0
  221. package/dist/core/agentProfileManifest.d.ts +3 -0
  222. package/dist/core/agentProfileManifest.d.ts.map +1 -0
  223. package/dist/core/agentProfileManifest.js +188 -0
  224. package/dist/core/agentProfileManifest.js.map +1 -0
  225. package/dist/core/agentProfiles.d.ts +22 -0
  226. package/dist/core/agentProfiles.d.ts.map +1 -0
  227. package/dist/core/agentProfiles.js +35 -0
  228. package/dist/core/agentProfiles.js.map +1 -0
  229. package/dist/core/agentRulebook.d.ts +11 -0
  230. package/dist/core/agentRulebook.d.ts.map +1 -0
  231. package/dist/core/agentRulebook.js +136 -0
  232. package/dist/core/agentRulebook.js.map +1 -0
  233. package/dist/core/agentSchemaLoader.d.ts +131 -0
  234. package/dist/core/agentSchemaLoader.d.ts.map +1 -0
  235. package/dist/core/agentSchemaLoader.js +234 -0
  236. package/dist/core/agentSchemaLoader.js.map +1 -0
  237. package/dist/core/aiErrorFixer.d.ts +70 -0
  238. package/dist/core/aiErrorFixer.d.ts.map +1 -0
  239. package/dist/core/aiErrorFixer.js +402 -0
  240. package/dist/core/aiErrorFixer.js.map +1 -0
  241. package/dist/core/alphaZeroEngine.d.ts +269 -0
  242. package/dist/core/alphaZeroEngine.d.ts.map +1 -0
  243. package/dist/core/alphaZeroEngine.js +523 -0
  244. package/dist/core/alphaZeroEngine.js.map +1 -0
  245. package/dist/core/alphaZeroModular.d.ts +186 -0
  246. package/dist/core/alphaZeroModular.d.ts.map +1 -0
  247. package/dist/core/alphaZeroModular.js +755 -0
  248. package/dist/core/alphaZeroModular.js.map +1 -0
  249. package/dist/core/alphaZeroOrchestrator.d.ts +140 -0
  250. package/dist/core/alphaZeroOrchestrator.d.ts.map +1 -0
  251. package/dist/core/alphaZeroOrchestrator.js +418 -0
  252. package/dist/core/alphaZeroOrchestrator.js.map +1 -0
  253. package/dist/core/checkpoint.d.ts +76 -0
  254. package/dist/core/checkpoint.d.ts.map +1 -0
  255. package/dist/core/checkpoint.js +278 -0
  256. package/dist/core/checkpoint.js.map +1 -0
  257. package/dist/core/cliTestHarness.d.ts +200 -0
  258. package/dist/core/cliTestHarness.d.ts.map +1 -0
  259. package/dist/core/cliTestHarness.js +549 -0
  260. package/dist/core/cliTestHarness.js.map +1 -0
  261. package/dist/core/contextManager.d.ts +265 -0
  262. package/dist/core/contextManager.d.ts.map +1 -0
  263. package/dist/core/contextManager.js +1060 -0
  264. package/dist/core/contextManager.js.map +1 -0
  265. package/dist/core/contextWindow.d.ts +42 -0
  266. package/dist/core/contextWindow.d.ts.map +1 -0
  267. package/dist/core/contextWindow.js +123 -0
  268. package/dist/core/contextWindow.js.map +1 -0
  269. package/dist/core/costTracker.d.ts +87 -0
  270. package/dist/core/costTracker.d.ts.map +1 -0
  271. package/dist/core/costTracker.js +285 -0
  272. package/dist/core/costTracker.js.map +1 -0
  273. package/dist/core/customCommands.d.ts +19 -0
  274. package/dist/core/customCommands.d.ts.map +1 -0
  275. package/dist/core/customCommands.js +84 -0
  276. package/dist/core/customCommands.js.map +1 -0
  277. package/dist/core/errors/apiKeyErrors.d.ts +11 -0
  278. package/dist/core/errors/apiKeyErrors.d.ts.map +1 -0
  279. package/dist/core/errors/apiKeyErrors.js +159 -0
  280. package/dist/core/errors/apiKeyErrors.js.map +1 -0
  281. package/dist/core/errors/errorTypes.d.ts +111 -0
  282. package/dist/core/errors/errorTypes.d.ts.map +1 -0
  283. package/dist/core/errors/errorTypes.js +348 -0
  284. package/dist/core/errors/errorTypes.js.map +1 -0
  285. package/dist/core/errors/errorUtils.d.ts +87 -0
  286. package/dist/core/errors/errorUtils.d.ts.map +1 -0
  287. package/dist/core/errors/errorUtils.js +158 -0
  288. package/dist/core/errors/errorUtils.js.map +1 -0
  289. package/dist/core/errors/safetyValidator.d.ts +71 -0
  290. package/dist/core/errors/safetyValidator.d.ts.map +1 -0
  291. package/dist/core/errors/safetyValidator.js +302 -0
  292. package/dist/core/errors/safetyValidator.js.map +1 -0
  293. package/dist/core/errors.d.ts +4 -0
  294. package/dist/core/errors.d.ts.map +1 -0
  295. package/dist/core/errors.js +33 -0
  296. package/dist/core/errors.js.map +1 -0
  297. package/dist/core/failureRecovery.d.ts +122 -0
  298. package/dist/core/failureRecovery.d.ts.map +1 -0
  299. package/dist/core/failureRecovery.js +477 -0
  300. package/dist/core/failureRecovery.js.map +1 -0
  301. package/dist/core/hooks.d.ts +113 -0
  302. package/dist/core/hooks.d.ts.map +1 -0
  303. package/dist/core/hooks.js +267 -0
  304. package/dist/core/hooks.js.map +1 -0
  305. package/dist/core/intelligentTestFlows.d.ts +126 -0
  306. package/dist/core/intelligentTestFlows.d.ts.map +1 -0
  307. package/dist/core/intelligentTestFlows.js +678 -0
  308. package/dist/core/intelligentTestFlows.js.map +1 -0
  309. package/dist/core/isolatedVerifier.d.ts +40 -0
  310. package/dist/core/isolatedVerifier.d.ts.map +1 -0
  311. package/dist/core/isolatedVerifier.js +129 -0
  312. package/dist/core/isolatedVerifier.js.map +1 -0
  313. package/dist/core/learningPersistence.d.ts +145 -0
  314. package/dist/core/learningPersistence.d.ts.map +1 -0
  315. package/dist/core/learningPersistence.js +477 -0
  316. package/dist/core/learningPersistence.js.map +1 -0
  317. package/dist/core/memorySystem.d.ts +67 -0
  318. package/dist/core/memorySystem.d.ts.map +1 -0
  319. package/dist/core/memorySystem.js +334 -0
  320. package/dist/core/memorySystem.js.map +1 -0
  321. package/dist/core/metricsTracker.d.ts +157 -0
  322. package/dist/core/metricsTracker.d.ts.map +1 -0
  323. package/dist/core/metricsTracker.js +273 -0
  324. package/dist/core/metricsTracker.js.map +1 -0
  325. package/dist/core/modelDiscovery.d.ts +101 -0
  326. package/dist/core/modelDiscovery.d.ts.map +1 -0
  327. package/dist/core/modelDiscovery.js +780 -0
  328. package/dist/core/modelDiscovery.js.map +1 -0
  329. package/dist/core/multilinePasteHandler.d.ts +35 -0
  330. package/dist/core/multilinePasteHandler.d.ts.map +1 -0
  331. package/dist/core/multilinePasteHandler.js +80 -0
  332. package/dist/core/multilinePasteHandler.js.map +1 -0
  333. package/dist/core/offsecAlphaZero.d.ts +56 -0
  334. package/dist/core/offsecAlphaZero.d.ts.map +1 -0
  335. package/dist/core/offsecAlphaZero.js +395 -0
  336. package/dist/core/offsecAlphaZero.js.map +1 -0
  337. package/dist/core/outputStyles.d.ts +48 -0
  338. package/dist/core/outputStyles.d.ts.map +1 -0
  339. package/dist/core/outputStyles.js +270 -0
  340. package/dist/core/outputStyles.js.map +1 -0
  341. package/dist/core/performanceMonitor.d.ts +124 -0
  342. package/dist/core/performanceMonitor.d.ts.map +1 -0
  343. package/dist/core/performanceMonitor.js +192 -0
  344. package/dist/core/performanceMonitor.js.map +1 -0
  345. package/dist/core/preferences.d.ts +67 -0
  346. package/dist/core/preferences.d.ts.map +1 -0
  347. package/dist/core/preferences.js +314 -0
  348. package/dist/core/preferences.js.map +1 -0
  349. package/dist/core/responseVerifier.d.ts +98 -0
  350. package/dist/core/responseVerifier.d.ts.map +1 -0
  351. package/dist/core/responseVerifier.js +509 -0
  352. package/dist/core/responseVerifier.js.map +1 -0
  353. package/dist/core/resultVerification.d.ts +141 -0
  354. package/dist/core/resultVerification.d.ts.map +1 -0
  355. package/dist/core/resultVerification.js +482 -0
  356. package/dist/core/resultVerification.js.map +1 -0
  357. package/dist/core/schemaValidator.d.ts +44 -0
  358. package/dist/core/schemaValidator.d.ts.map +1 -0
  359. package/dist/core/schemaValidator.js +155 -0
  360. package/dist/core/schemaValidator.js.map +1 -0
  361. package/dist/core/secretStore.d.ts +48 -0
  362. package/dist/core/secretStore.d.ts.map +1 -0
  363. package/dist/core/secretStore.js +367 -0
  364. package/dist/core/secretStore.js.map +1 -0
  365. package/dist/core/securityAssessment.d.ts +91 -0
  366. package/dist/core/securityAssessment.d.ts.map +1 -0
  367. package/dist/core/securityAssessment.js +580 -0
  368. package/dist/core/securityAssessment.js.map +1 -0
  369. package/dist/core/selfEvolution.d.ts +155 -0
  370. package/dist/core/selfEvolution.d.ts.map +1 -0
  371. package/dist/core/selfEvolution.js +1000 -0
  372. package/dist/core/selfEvolution.js.map +1 -0
  373. package/dist/core/selfImprovement.d.ts +141 -0
  374. package/dist/core/selfImprovement.d.ts.map +1 -0
  375. package/dist/core/selfImprovement.js +700 -0
  376. package/dist/core/selfImprovement.js.map +1 -0
  377. package/dist/core/sessionStore.d.ts +35 -0
  378. package/dist/core/sessionStore.d.ts.map +1 -0
  379. package/dist/core/sessionStore.js +189 -0
  380. package/dist/core/sessionStore.js.map +1 -0
  381. package/dist/core/testUtils.d.ts +121 -0
  382. package/dist/core/testUtils.d.ts.map +1 -0
  383. package/dist/core/testUtils.js +235 -0
  384. package/dist/core/testUtils.js.map +1 -0
  385. package/dist/core/types/utilityTypes.d.ts +192 -0
  386. package/dist/core/types/utilityTypes.d.ts.map +1 -0
  387. package/dist/core/types/utilityTypes.js +272 -0
  388. package/dist/core/types/utilityTypes.js.map +1 -0
  389. package/dist/core/types.d.ts +306 -0
  390. package/dist/core/types.d.ts.map +1 -0
  391. package/dist/core/types.js +76 -0
  392. package/dist/core/types.js.map +1 -0
  393. package/dist/core/validationRunner.d.ts +106 -0
  394. package/dist/core/validationRunner.d.ts.map +1 -0
  395. package/dist/core/validationRunner.js +888 -0
  396. package/dist/core/validationRunner.js.map +1 -0
  397. package/dist/core/verification.d.ts +137 -0
  398. package/dist/core/verification.d.ts.map +1 -0
  399. package/dist/core/verification.js +323 -0
  400. package/dist/core/verification.js.map +1 -0
  401. package/dist/headless/headlessApp.d.ts +5 -0
  402. package/dist/headless/headlessApp.d.ts.map +1 -0
  403. package/dist/headless/headlessApp.js +210 -0
  404. package/dist/headless/headlessApp.js.map +1 -0
  405. package/dist/intelligence/codeIntelligence.d.ts +118 -0
  406. package/dist/intelligence/codeIntelligence.d.ts.map +1 -0
  407. package/dist/intelligence/codeIntelligence.js +552 -0
  408. package/dist/intelligence/codeIntelligence.js.map +1 -0
  409. package/dist/intelligence/docGenerator.d.ts +86 -0
  410. package/dist/intelligence/docGenerator.d.ts.map +1 -0
  411. package/dist/intelligence/docGenerator.js +564 -0
  412. package/dist/intelligence/docGenerator.js.map +1 -0
  413. package/dist/intelligence/index.d.ts +51 -0
  414. package/dist/intelligence/index.d.ts.map +1 -0
  415. package/dist/intelligence/index.js +253 -0
  416. package/dist/intelligence/index.js.map +1 -0
  417. package/dist/intelligence/refactoring.d.ts +50 -0
  418. package/dist/intelligence/refactoring.d.ts.map +1 -0
  419. package/dist/intelligence/refactoring.js +354 -0
  420. package/dist/intelligence/refactoring.js.map +1 -0
  421. package/dist/intelligence/testGenerator.d.ts +74 -0
  422. package/dist/intelligence/testGenerator.d.ts.map +1 -0
  423. package/dist/intelligence/testGenerator.js +483 -0
  424. package/dist/intelligence/testGenerator.js.map +1 -0
  425. package/dist/mcp/config.d.ts +8 -0
  426. package/dist/mcp/config.d.ts.map +1 -0
  427. package/dist/mcp/config.js +252 -0
  428. package/dist/mcp/config.js.map +1 -0
  429. package/dist/mcp/sseClient.d.ts +34 -0
  430. package/dist/mcp/sseClient.d.ts.map +1 -0
  431. package/dist/mcp/sseClient.js +327 -0
  432. package/dist/mcp/sseClient.js.map +1 -0
  433. package/dist/mcp/stdioClient.d.ts +24 -0
  434. package/dist/mcp/stdioClient.d.ts.map +1 -0
  435. package/dist/mcp/stdioClient.js +179 -0
  436. package/dist/mcp/stdioClient.js.map +1 -0
  437. package/dist/mcp/toolBridge.d.ts +12 -0
  438. package/dist/mcp/toolBridge.d.ts.map +1 -0
  439. package/dist/mcp/toolBridge.js +117 -0
  440. package/dist/mcp/toolBridge.js.map +1 -0
  441. package/dist/mcp/types.d.ts +60 -0
  442. package/dist/mcp/types.d.ts.map +1 -0
  443. package/dist/mcp/types.js +2 -0
  444. package/dist/mcp/types.js.map +1 -0
  445. package/dist/plugins/index.d.ts +49 -0
  446. package/dist/plugins/index.d.ts.map +1 -0
  447. package/dist/plugins/index.js +114 -0
  448. package/dist/plugins/index.js.map +1 -0
  449. package/dist/plugins/providers/anthropic/index.d.ts +11 -0
  450. package/dist/plugins/providers/anthropic/index.d.ts.map +1 -0
  451. package/dist/plugins/providers/anthropic/index.js +38 -0
  452. package/dist/plugins/providers/anthropic/index.js.map +1 -0
  453. package/dist/plugins/providers/deepseek/index.d.ts +11 -0
  454. package/dist/plugins/providers/deepseek/index.d.ts.map +1 -0
  455. package/dist/plugins/providers/deepseek/index.js +52 -0
  456. package/dist/plugins/providers/deepseek/index.js.map +1 -0
  457. package/dist/plugins/providers/google/index.d.ts +11 -0
  458. package/dist/plugins/providers/google/index.d.ts.map +1 -0
  459. package/dist/plugins/providers/google/index.js +40 -0
  460. package/dist/plugins/providers/google/index.js.map +1 -0
  461. package/dist/plugins/providers/index.d.ts +2 -0
  462. package/dist/plugins/providers/index.d.ts.map +1 -0
  463. package/dist/plugins/providers/index.js +20 -0
  464. package/dist/plugins/providers/index.js.map +1 -0
  465. package/dist/plugins/providers/ollama/index.d.ts +21 -0
  466. package/dist/plugins/providers/ollama/index.d.ts.map +1 -0
  467. package/dist/plugins/providers/ollama/index.js +69 -0
  468. package/dist/plugins/providers/ollama/index.js.map +1 -0
  469. package/dist/plugins/providers/openai/index.d.ts +12 -0
  470. package/dist/plugins/providers/openai/index.d.ts.map +1 -0
  471. package/dist/plugins/providers/openai/index.js +39 -0
  472. package/dist/plugins/providers/openai/index.js.map +1 -0
  473. package/dist/plugins/providers/xai/index.d.ts +11 -0
  474. package/dist/plugins/providers/xai/index.d.ts.map +1 -0
  475. package/dist/plugins/providers/xai/index.js +39 -0
  476. package/dist/plugins/providers/xai/index.js.map +1 -0
  477. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts +3 -0
  478. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts.map +1 -0
  479. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js +9 -0
  480. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js.map +1 -0
  481. package/dist/plugins/tools/bash/localBashPlugin.d.ts +3 -0
  482. package/dist/plugins/tools/bash/localBashPlugin.d.ts.map +1 -0
  483. package/dist/plugins/tools/bash/localBashPlugin.js +14 -0
  484. package/dist/plugins/tools/bash/localBashPlugin.js.map +1 -0
  485. package/dist/plugins/tools/browser/browserAutomationPlugin.d.ts +14 -0
  486. package/dist/plugins/tools/browser/browserAutomationPlugin.d.ts.map +1 -0
  487. package/dist/plugins/tools/browser/browserAutomationPlugin.js +26 -0
  488. package/dist/plugins/tools/browser/browserAutomationPlugin.js.map +1 -0
  489. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts +3 -0
  490. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts.map +1 -0
  491. package/dist/plugins/tools/checks/localRepoChecksPlugin.js +14 -0
  492. package/dist/plugins/tools/checks/localRepoChecksPlugin.js.map +1 -0
  493. package/dist/plugins/tools/cloud/cloudPlugin.d.ts +3 -0
  494. package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +1 -0
  495. package/dist/plugins/tools/cloud/cloudPlugin.js +14 -0
  496. package/dist/plugins/tools/cloud/cloudPlugin.js.map +1 -0
  497. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts +3 -0
  498. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts.map +1 -0
  499. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +14 -0
  500. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js.map +1 -0
  501. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts +3 -0
  502. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts.map +1 -0
  503. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js +14 -0
  504. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js.map +1 -0
  505. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts +3 -0
  506. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts.map +1 -0
  507. package/dist/plugins/tools/dependency/dependencyPlugin.js +12 -0
  508. package/dist/plugins/tools/dependency/dependencyPlugin.js.map +1 -0
  509. package/dist/plugins/tools/development/devPlugin.d.ts +3 -0
  510. package/dist/plugins/tools/development/devPlugin.d.ts.map +1 -0
  511. package/dist/plugins/tools/development/devPlugin.js +14 -0
  512. package/dist/plugins/tools/development/devPlugin.js.map +1 -0
  513. package/dist/plugins/tools/edit/editPlugin.d.ts +9 -0
  514. package/dist/plugins/tools/edit/editPlugin.d.ts.map +1 -0
  515. package/dist/plugins/tools/edit/editPlugin.js +15 -0
  516. package/dist/plugins/tools/edit/editPlugin.js.map +1 -0
  517. package/dist/plugins/tools/email/emailPlugin.d.ts +3 -0
  518. package/dist/plugins/tools/email/emailPlugin.d.ts.map +1 -0
  519. package/dist/plugins/tools/email/emailPlugin.js +12 -0
  520. package/dist/plugins/tools/email/emailPlugin.js.map +1 -0
  521. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts +3 -0
  522. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts.map +1 -0
  523. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js +9 -0
  524. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js.map +1 -0
  525. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts +3 -0
  526. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts.map +1 -0
  527. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js +14 -0
  528. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js.map +1 -0
  529. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.d.ts +3 -0
  530. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.d.ts.map +1 -0
  531. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.js +14 -0
  532. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.js.map +1 -0
  533. package/dist/plugins/tools/glob/globPlugin.d.ts +9 -0
  534. package/dist/plugins/tools/glob/globPlugin.d.ts.map +1 -0
  535. package/dist/plugins/tools/glob/globPlugin.js +15 -0
  536. package/dist/plugins/tools/glob/globPlugin.js.map +1 -0
  537. package/dist/plugins/tools/index.d.ts +3 -0
  538. package/dist/plugins/tools/index.d.ts.map +1 -0
  539. package/dist/plugins/tools/index.js +3 -0
  540. package/dist/plugins/tools/index.js.map +1 -0
  541. package/dist/plugins/tools/interaction/interactionPlugin.d.ts +3 -0
  542. package/dist/plugins/tools/interaction/interactionPlugin.d.ts.map +1 -0
  543. package/dist/plugins/tools/interaction/interactionPlugin.js +12 -0
  544. package/dist/plugins/tools/interaction/interactionPlugin.js.map +1 -0
  545. package/dist/plugins/tools/learn/learnPlugin.d.ts +3 -0
  546. package/dist/plugins/tools/learn/learnPlugin.d.ts.map +1 -0
  547. package/dist/plugins/tools/learn/learnPlugin.js +14 -0
  548. package/dist/plugins/tools/learn/learnPlugin.js.map +1 -0
  549. package/dist/plugins/tools/mcp/mcpPlugin.d.ts +3 -0
  550. package/dist/plugins/tools/mcp/mcpPlugin.d.ts.map +1 -0
  551. package/dist/plugins/tools/mcp/mcpPlugin.js +9 -0
  552. package/dist/plugins/tools/mcp/mcpPlugin.js.map +1 -0
  553. package/dist/plugins/tools/nodeDefaults.d.ts +2 -0
  554. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -0
  555. package/dist/plugins/tools/nodeDefaults.js +65 -0
  556. package/dist/plugins/tools/nodeDefaults.js.map +1 -0
  557. package/dist/plugins/tools/notebook/notebookPlugin.d.ts +9 -0
  558. package/dist/plugins/tools/notebook/notebookPlugin.d.ts.map +1 -0
  559. package/dist/plugins/tools/notebook/notebookPlugin.js +15 -0
  560. package/dist/plugins/tools/notebook/notebookPlugin.js.map +1 -0
  561. package/dist/plugins/tools/planning/planningPlugin.d.ts +9 -0
  562. package/dist/plugins/tools/planning/planningPlugin.d.ts.map +1 -0
  563. package/dist/plugins/tools/planning/planningPlugin.js +15 -0
  564. package/dist/plugins/tools/planning/planningPlugin.js.map +1 -0
  565. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts +3 -0
  566. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts.map +1 -0
  567. package/dist/plugins/tools/refactoring/refactoringPlugin.js +12 -0
  568. package/dist/plugins/tools/refactoring/refactoringPlugin.js.map +1 -0
  569. package/dist/plugins/tools/registry.d.ts +22 -0
  570. package/dist/plugins/tools/registry.d.ts.map +1 -0
  571. package/dist/plugins/tools/registry.js +58 -0
  572. package/dist/plugins/tools/registry.js.map +1 -0
  573. package/dist/plugins/tools/search/localSearchPlugin.d.ts +3 -0
  574. package/dist/plugins/tools/search/localSearchPlugin.d.ts.map +1 -0
  575. package/dist/plugins/tools/search/localSearchPlugin.js +14 -0
  576. package/dist/plugins/tools/search/localSearchPlugin.js.map +1 -0
  577. package/dist/plugins/tools/skills/skillPlugin.d.ts +3 -0
  578. package/dist/plugins/tools/skills/skillPlugin.d.ts.map +1 -0
  579. package/dist/plugins/tools/skills/skillPlugin.js +9 -0
  580. package/dist/plugins/tools/skills/skillPlugin.js.map +1 -0
  581. package/dist/plugins/tools/taskManagement/taskManagementPlugin.d.ts +3 -0
  582. package/dist/plugins/tools/taskManagement/taskManagementPlugin.d.ts.map +1 -0
  583. package/dist/plugins/tools/taskManagement/taskManagementPlugin.js +12 -0
  584. package/dist/plugins/tools/taskManagement/taskManagementPlugin.js.map +1 -0
  585. package/dist/plugins/tools/testing/testingPlugin.d.ts +3 -0
  586. package/dist/plugins/tools/testing/testingPlugin.d.ts.map +1 -0
  587. package/dist/plugins/tools/testing/testingPlugin.js +12 -0
  588. package/dist/plugins/tools/testing/testingPlugin.js.map +1 -0
  589. package/dist/plugins/tools/validation/validationPlugin.d.ts +3 -0
  590. package/dist/plugins/tools/validation/validationPlugin.d.ts.map +1 -0
  591. package/dist/plugins/tools/validation/validationPlugin.js +14 -0
  592. package/dist/plugins/tools/validation/validationPlugin.js.map +1 -0
  593. package/dist/plugins/tools/web/webPlugin.d.ts +3 -0
  594. package/dist/plugins/tools/web/webPlugin.d.ts.map +1 -0
  595. package/dist/plugins/tools/web/webPlugin.js +12 -0
  596. package/dist/plugins/tools/web/webPlugin.js.map +1 -0
  597. package/dist/providers/anthropicProvider.d.ts +41 -0
  598. package/dist/providers/anthropicProvider.d.ts.map +1 -0
  599. package/dist/providers/anthropicProvider.js +446 -0
  600. package/dist/providers/anthropicProvider.js.map +1 -0
  601. package/dist/providers/googleProvider.d.ts +36 -0
  602. package/dist/providers/googleProvider.d.ts.map +1 -0
  603. package/dist/providers/googleProvider.js +312 -0
  604. package/dist/providers/googleProvider.js.map +1 -0
  605. package/dist/providers/openaiChatCompletionsProvider.d.ts +43 -0
  606. package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
  607. package/dist/providers/openaiChatCompletionsProvider.js +475 -0
  608. package/dist/providers/openaiChatCompletionsProvider.js.map +1 -0
  609. package/dist/providers/openaiResponsesProvider.d.ts +38 -0
  610. package/dist/providers/openaiResponsesProvider.d.ts.map +1 -0
  611. package/dist/providers/openaiResponsesProvider.js +364 -0
  612. package/dist/providers/openaiResponsesProvider.js.map +1 -0
  613. package/dist/providers/providerFactory.d.ts +18 -0
  614. package/dist/providers/providerFactory.d.ts.map +1 -0
  615. package/dist/providers/providerFactory.js +25 -0
  616. package/dist/providers/providerFactory.js.map +1 -0
  617. package/dist/providers/resilientProvider.d.ts +94 -0
  618. package/dist/providers/resilientProvider.d.ts.map +1 -0
  619. package/dist/providers/resilientProvider.js +370 -0
  620. package/dist/providers/resilientProvider.js.map +1 -0
  621. package/dist/runtime/agentController.d.ts +65 -0
  622. package/dist/runtime/agentController.d.ts.map +1 -0
  623. package/dist/runtime/agentController.js +353 -0
  624. package/dist/runtime/agentController.js.map +1 -0
  625. package/dist/runtime/agentHost.d.ts +61 -0
  626. package/dist/runtime/agentHost.d.ts.map +1 -0
  627. package/dist/runtime/agentHost.js +156 -0
  628. package/dist/runtime/agentHost.js.map +1 -0
  629. package/dist/runtime/agentSession.d.ts +40 -0
  630. package/dist/runtime/agentSession.d.ts.map +1 -0
  631. package/dist/runtime/agentSession.js +205 -0
  632. package/dist/runtime/agentSession.js.map +1 -0
  633. package/dist/runtime/browser.d.ts +7 -0
  634. package/dist/runtime/browser.d.ts.map +1 -0
  635. package/dist/runtime/browser.js +10 -0
  636. package/dist/runtime/browser.js.map +1 -0
  637. package/dist/runtime/cloud.d.ts +7 -0
  638. package/dist/runtime/cloud.d.ts.map +1 -0
  639. package/dist/runtime/cloud.js +10 -0
  640. package/dist/runtime/cloud.js.map +1 -0
  641. package/dist/runtime/node.d.ts +8 -0
  642. package/dist/runtime/node.d.ts.map +1 -0
  643. package/dist/runtime/node.js +11 -0
  644. package/dist/runtime/node.js.map +1 -0
  645. package/dist/runtime/universal.d.ts +21 -0
  646. package/dist/runtime/universal.d.ts.map +1 -0
  647. package/dist/runtime/universal.js +29 -0
  648. package/dist/runtime/universal.js.map +1 -0
  649. package/dist/shell/autoExecutor.d.ts +70 -0
  650. package/dist/shell/autoExecutor.d.ts.map +1 -0
  651. package/dist/shell/autoExecutor.js +288 -0
  652. package/dist/shell/autoExecutor.js.map +1 -0
  653. package/dist/shell/composableMessage.d.ts +183 -0
  654. package/dist/shell/composableMessage.d.ts.map +1 -0
  655. package/dist/shell/composableMessage.js +420 -0
  656. package/dist/shell/composableMessage.js.map +1 -0
  657. package/dist/shell/fileChangeTracker.d.ts +39 -0
  658. package/dist/shell/fileChangeTracker.d.ts.map +1 -0
  659. package/dist/shell/fileChangeTracker.js +64 -0
  660. package/dist/shell/fileChangeTracker.js.map +1 -0
  661. package/dist/shell/interactiveShell.d.ts.map +1 -1
  662. package/dist/shell/interactiveShell.js +18 -9
  663. package/dist/shell/interactiveShell.js.map +1 -1
  664. package/dist/shell/liveStatus.d.ts +30 -0
  665. package/dist/shell/liveStatus.d.ts.map +1 -0
  666. package/dist/shell/liveStatus.js +102 -0
  667. package/dist/shell/liveStatus.js.map +1 -0
  668. package/dist/shell/shellApp.d.ts +19 -0
  669. package/dist/shell/shellApp.d.ts.map +1 -0
  670. package/dist/shell/shellApp.js +408 -0
  671. package/dist/shell/shellApp.js.map +1 -0
  672. package/dist/shell/taskCompletionDetector.d.ts +106 -0
  673. package/dist/shell/taskCompletionDetector.d.ts.map +1 -0
  674. package/dist/shell/taskCompletionDetector.js +402 -0
  675. package/dist/shell/taskCompletionDetector.js.map +1 -0
  676. package/dist/shell/terminalInput.d.ts +620 -0
  677. package/dist/shell/terminalInput.d.ts.map +1 -0
  678. package/dist/shell/terminalInput.js +2647 -0
  679. package/dist/shell/terminalInput.js.map +1 -0
  680. package/dist/shell/terminalInputAdapter.d.ts +266 -0
  681. package/dist/shell/terminalInputAdapter.d.ts.map +1 -0
  682. package/dist/shell/terminalInputAdapter.js +406 -0
  683. package/dist/shell/terminalInputAdapter.js.map +1 -0
  684. package/dist/shell/vimMode.d.ts +66 -0
  685. package/dist/shell/vimMode.d.ts.map +1 -0
  686. package/dist/shell/vimMode.js +434 -0
  687. package/dist/shell/vimMode.js.map +1 -0
  688. package/dist/skills/skillRepository.d.ts +103 -0
  689. package/dist/skills/skillRepository.d.ts.map +1 -0
  690. package/dist/skills/skillRepository.js +237 -0
  691. package/dist/skills/skillRepository.js.map +1 -0
  692. package/dist/skills/types.d.ts +37 -0
  693. package/dist/skills/types.d.ts.map +1 -0
  694. package/dist/skills/types.js +2 -0
  695. package/dist/skills/types.js.map +1 -0
  696. package/dist/subagents/agentConfig.d.ts +27 -0
  697. package/dist/subagents/agentConfig.d.ts.map +1 -0
  698. package/dist/subagents/agentConfig.js +89 -0
  699. package/dist/subagents/agentConfig.js.map +1 -0
  700. package/dist/subagents/agentRegistry.d.ts +33 -0
  701. package/dist/subagents/agentRegistry.d.ts.map +1 -0
  702. package/dist/subagents/agentRegistry.js +162 -0
  703. package/dist/subagents/agentRegistry.js.map +1 -0
  704. package/dist/subagents/parallelAgentManager.d.ts +99 -0
  705. package/dist/subagents/parallelAgentManager.d.ts.map +1 -0
  706. package/dist/subagents/parallelAgentManager.js +248 -0
  707. package/dist/subagents/parallelAgentManager.js.map +1 -0
  708. package/dist/subagents/taskRunner.d.ts +34 -0
  709. package/dist/subagents/taskRunner.d.ts.map +1 -0
  710. package/dist/subagents/taskRunner.js +459 -0
  711. package/dist/subagents/taskRunner.js.map +1 -0
  712. package/dist/tools/advancedTestGenerationTools.d.ts +21 -0
  713. package/dist/tools/advancedTestGenerationTools.d.ts.map +1 -0
  714. package/dist/tools/advancedTestGenerationTools.js +301 -0
  715. package/dist/tools/advancedTestGenerationTools.js.map +1 -0
  716. package/dist/tools/backgroundBashTools.d.ts +21 -0
  717. package/dist/tools/backgroundBashTools.d.ts.map +1 -0
  718. package/dist/tools/backgroundBashTools.js +215 -0
  719. package/dist/tools/backgroundBashTools.js.map +1 -0
  720. package/dist/tools/browserAutomationTools.d.ts +23 -0
  721. package/dist/tools/browserAutomationTools.d.ts.map +1 -0
  722. package/dist/tools/browserAutomationTools.js +916 -0
  723. package/dist/tools/browserAutomationTools.js.map +1 -0
  724. package/dist/tools/buildTools.d.ts +9 -0
  725. package/dist/tools/buildTools.d.ts.map +1 -0
  726. package/dist/tools/buildTools.js +344 -0
  727. package/dist/tools/buildTools.js.map +1 -0
  728. package/dist/tools/cloudTools.d.ts +49 -0
  729. package/dist/tools/cloudTools.d.ts.map +1 -0
  730. package/dist/tools/cloudTools.js +1258 -0
  731. package/dist/tools/cloudTools.js.map +1 -0
  732. package/dist/tools/code-quality-dashboard.d.ts +57 -0
  733. package/dist/tools/code-quality-dashboard.d.ts.map +1 -0
  734. package/dist/tools/code-quality-dashboard.js +218 -0
  735. package/dist/tools/code-quality-dashboard.js.map +1 -0
  736. package/dist/tools/codeAnalysisTools.d.ts +74 -0
  737. package/dist/tools/codeAnalysisTools.d.ts.map +1 -0
  738. package/dist/tools/codeAnalysisTools.js +664 -0
  739. package/dist/tools/codeAnalysisTools.js.map +1 -0
  740. package/dist/tools/codeGenerationTools.d.ts +3 -0
  741. package/dist/tools/codeGenerationTools.d.ts.map +1 -0
  742. package/dist/tools/codeGenerationTools.js +439 -0
  743. package/dist/tools/codeGenerationTools.js.map +1 -0
  744. package/dist/tools/codeQualityTools.d.ts +3 -0
  745. package/dist/tools/codeQualityTools.d.ts.map +1 -0
  746. package/dist/tools/codeQualityTools.js +296 -0
  747. package/dist/tools/codeQualityTools.js.map +1 -0
  748. package/dist/tools/dependencyTools.d.ts +3 -0
  749. package/dist/tools/dependencyTools.d.ts.map +1 -0
  750. package/dist/tools/dependencyTools.js +283 -0
  751. package/dist/tools/dependencyTools.js.map +1 -0
  752. package/dist/tools/devTools.d.ts +10 -0
  753. package/dist/tools/devTools.d.ts.map +1 -0
  754. package/dist/tools/devTools.js +2125 -0
  755. package/dist/tools/devTools.js.map +1 -0
  756. package/dist/tools/diffUtils.d.ts +36 -0
  757. package/dist/tools/diffUtils.d.ts.map +1 -0
  758. package/dist/tools/diffUtils.js +528 -0
  759. package/dist/tools/diffUtils.js.map +1 -0
  760. package/dist/tools/editTools.d.ts +29 -0
  761. package/dist/tools/editTools.d.ts.map +1 -0
  762. package/dist/tools/editTools.js +419 -0
  763. package/dist/tools/editTools.js.map +1 -0
  764. package/dist/tools/emailTools.d.ts +21 -0
  765. package/dist/tools/emailTools.d.ts.map +1 -0
  766. package/dist/tools/emailTools.js +449 -0
  767. package/dist/tools/emailTools.js.map +1 -0
  768. package/dist/tools/enhancedCodeIntelligenceTools.d.ts +27 -0
  769. package/dist/tools/enhancedCodeIntelligenceTools.d.ts.map +1 -0
  770. package/dist/tools/enhancedCodeIntelligenceTools.js +418 -0
  771. package/dist/tools/enhancedCodeIntelligenceTools.js.map +1 -0
  772. package/dist/tools/enhancedDevWorkflowTools.d.ts +15 -0
  773. package/dist/tools/enhancedDevWorkflowTools.d.ts.map +1 -0
  774. package/dist/tools/enhancedDevWorkflowTools.js +303 -0
  775. package/dist/tools/enhancedDevWorkflowTools.js.map +1 -0
  776. package/dist/tools/fileTools.d.ts +3 -0
  777. package/dist/tools/fileTools.d.ts.map +1 -0
  778. package/dist/tools/fileTools.js +334 -0
  779. package/dist/tools/fileTools.js.map +1 -0
  780. package/dist/tools/frontendTestingTools.d.ts +35 -0
  781. package/dist/tools/frontendTestingTools.d.ts.map +1 -0
  782. package/dist/tools/frontendTestingTools.js +1254 -0
  783. package/dist/tools/frontendTestingTools.js.map +1 -0
  784. package/dist/tools/globTools.d.ts +15 -0
  785. package/dist/tools/globTools.d.ts.map +1 -0
  786. package/dist/tools/globTools.js +174 -0
  787. package/dist/tools/globTools.js.map +1 -0
  788. package/dist/tools/grepTools.d.ts +19 -0
  789. package/dist/tools/grepTools.d.ts.map +1 -0
  790. package/dist/tools/grepTools.js +358 -0
  791. package/dist/tools/grepTools.js.map +1 -0
  792. package/dist/tools/interactionTools.d.ts +13 -0
  793. package/dist/tools/interactionTools.d.ts.map +1 -0
  794. package/dist/tools/interactionTools.js +171 -0
  795. package/dist/tools/interactionTools.js.map +1 -0
  796. package/dist/tools/learnTools.d.ts +164 -0
  797. package/dist/tools/learnTools.d.ts.map +1 -0
  798. package/dist/tools/learnTools.js +2102 -0
  799. package/dist/tools/learnTools.js.map +1 -0
  800. package/dist/tools/localExplore.d.ts +225 -0
  801. package/dist/tools/localExplore.d.ts.map +1 -0
  802. package/dist/tools/localExplore.js +1291 -0
  803. package/dist/tools/localExplore.js.map +1 -0
  804. package/dist/tools/notebookEditTools.d.ts +15 -0
  805. package/dist/tools/notebookEditTools.d.ts.map +1 -0
  806. package/dist/tools/notebookEditTools.js +197 -0
  807. package/dist/tools/notebookEditTools.js.map +1 -0
  808. package/dist/tools/planningTools.d.ts +21 -0
  809. package/dist/tools/planningTools.d.ts.map +1 -0
  810. package/dist/tools/planningTools.js +185 -0
  811. package/dist/tools/planningTools.js.map +1 -0
  812. package/dist/tools/refactoringTools.d.ts +3 -0
  813. package/dist/tools/refactoringTools.d.ts.map +1 -0
  814. package/dist/tools/refactoringTools.js +294 -0
  815. package/dist/tools/refactoringTools.js.map +1 -0
  816. package/dist/tools/repoChecksTools.d.ts +3 -0
  817. package/dist/tools/repoChecksTools.d.ts.map +1 -0
  818. package/dist/tools/repoChecksTools.js +161 -0
  819. package/dist/tools/repoChecksTools.js.map +1 -0
  820. package/dist/tools/searchTools.d.ts +3 -0
  821. package/dist/tools/searchTools.d.ts.map +1 -0
  822. package/dist/tools/searchTools.js +241 -0
  823. package/dist/tools/searchTools.js.map +1 -0
  824. package/dist/tools/skillTools.d.ts +8 -0
  825. package/dist/tools/skillTools.d.ts.map +1 -0
  826. package/dist/tools/skillTools.js +178 -0
  827. package/dist/tools/skillTools.js.map +1 -0
  828. package/dist/tools/softwareEngineeringTools.d.ts +7 -0
  829. package/dist/tools/softwareEngineeringTools.d.ts.map +1 -0
  830. package/dist/tools/softwareEngineeringTools.js +338 -0
  831. package/dist/tools/softwareEngineeringTools.js.map +1 -0
  832. package/dist/tools/taskManagementTools.d.ts +10 -0
  833. package/dist/tools/taskManagementTools.d.ts.map +1 -0
  834. package/dist/tools/taskManagementTools.js +157 -0
  835. package/dist/tools/taskManagementTools.js.map +1 -0
  836. package/dist/tools/testingTools.d.ts +3 -0
  837. package/dist/tools/testingTools.d.ts.map +1 -0
  838. package/dist/tools/testingTools.js +233 -0
  839. package/dist/tools/testingTools.js.map +1 -0
  840. package/dist/tools/validationTools.d.ts +7 -0
  841. package/dist/tools/validationTools.d.ts.map +1 -0
  842. package/dist/tools/validationTools.js +344 -0
  843. package/dist/tools/validationTools.js.map +1 -0
  844. package/dist/tools/webTools.d.ts +3 -0
  845. package/dist/tools/webTools.d.ts.map +1 -0
  846. package/dist/tools/webTools.js +502 -0
  847. package/dist/tools/webTools.js.map +1 -0
  848. package/dist/ui/ShellUIAdapter.d.ts +194 -0
  849. package/dist/ui/ShellUIAdapter.d.ts.map +1 -0
  850. package/dist/ui/ShellUIAdapter.js +1069 -0
  851. package/dist/ui/ShellUIAdapter.js.map +1 -0
  852. package/dist/ui/UnifiedUIController.d.ts +82 -0
  853. package/dist/ui/UnifiedUIController.d.ts.map +1 -0
  854. package/dist/ui/UnifiedUIController.js +207 -0
  855. package/dist/ui/UnifiedUIController.js.map +1 -0
  856. package/dist/ui/animation/AnimationScheduler.d.ts +192 -0
  857. package/dist/ui/animation/AnimationScheduler.d.ts.map +1 -0
  858. package/dist/ui/animation/AnimationScheduler.js +432 -0
  859. package/dist/ui/animation/AnimationScheduler.js.map +1 -0
  860. package/dist/ui/codeHighlighter.d.ts +6 -0
  861. package/dist/ui/codeHighlighter.d.ts.map +1 -0
  862. package/dist/ui/codeHighlighter.js +855 -0
  863. package/dist/ui/codeHighlighter.js.map +1 -0
  864. package/dist/ui/compactRenderer.d.ts +139 -0
  865. package/dist/ui/compactRenderer.d.ts.map +1 -0
  866. package/dist/ui/compactRenderer.js +398 -0
  867. package/dist/ui/compactRenderer.js.map +1 -0
  868. package/dist/ui/designSystem.d.ts +26 -0
  869. package/dist/ui/designSystem.d.ts.map +1 -0
  870. package/dist/ui/designSystem.js +122 -0
  871. package/dist/ui/designSystem.js.map +1 -0
  872. package/dist/ui/display.d.ts +324 -0
  873. package/dist/ui/display.d.ts.map +1 -0
  874. package/dist/ui/display.js +1328 -0
  875. package/dist/ui/display.js.map +1 -0
  876. package/dist/ui/errorFormatter.d.ts +54 -0
  877. package/dist/ui/errorFormatter.d.ts.map +1 -0
  878. package/dist/ui/errorFormatter.js +251 -0
  879. package/dist/ui/errorFormatter.js.map +1 -0
  880. package/dist/ui/globalWriteLock.d.ts +38 -0
  881. package/dist/ui/globalWriteLock.d.ts.map +1 -0
  882. package/dist/ui/globalWriteLock.js +54 -0
  883. package/dist/ui/globalWriteLock.js.map +1 -0
  884. package/dist/ui/inPlaceUpdater.d.ts +181 -0
  885. package/dist/ui/inPlaceUpdater.d.ts.map +1 -0
  886. package/dist/ui/inPlaceUpdater.js +515 -0
  887. package/dist/ui/inPlaceUpdater.js.map +1 -0
  888. package/dist/ui/interrupts/InterruptManager.d.ts +142 -0
  889. package/dist/ui/interrupts/InterruptManager.d.ts.map +1 -0
  890. package/dist/ui/interrupts/InterruptManager.js +439 -0
  891. package/dist/ui/interrupts/InterruptManager.js.map +1 -0
  892. package/dist/ui/layout.d.ts +17 -0
  893. package/dist/ui/layout.d.ts.map +1 -0
  894. package/dist/ui/layout.js +140 -0
  895. package/dist/ui/layout.js.map +1 -0
  896. package/dist/ui/orchestration/StatusOrchestrator.d.ts +156 -0
  897. package/dist/ui/orchestration/StatusOrchestrator.d.ts.map +1 -0
  898. package/dist/ui/orchestration/StatusOrchestrator.js +406 -0
  899. package/dist/ui/orchestration/StatusOrchestrator.js.map +1 -0
  900. package/dist/ui/orchestration/UIUpdateCoordinator.d.ts +77 -0
  901. package/dist/ui/orchestration/UIUpdateCoordinator.d.ts.map +1 -0
  902. package/dist/ui/orchestration/UIUpdateCoordinator.js +265 -0
  903. package/dist/ui/orchestration/UIUpdateCoordinator.js.map +1 -0
  904. package/dist/ui/outputMode.d.ts +22 -0
  905. package/dist/ui/outputMode.d.ts.map +1 -0
  906. package/dist/ui/outputMode.js +40 -0
  907. package/dist/ui/outputMode.js.map +1 -0
  908. package/dist/ui/richText.d.ts +6 -0
  909. package/dist/ui/richText.d.ts.map +1 -0
  910. package/dist/ui/richText.js +391 -0
  911. package/dist/ui/richText.js.map +1 -0
  912. package/dist/ui/shortcutsHelp.d.ts +39 -0
  913. package/dist/ui/shortcutsHelp.d.ts.map +1 -0
  914. package/dist/ui/shortcutsHelp.js +152 -0
  915. package/dist/ui/shortcutsHelp.js.map +1 -0
  916. package/dist/ui/streamingFormatter.d.ts +22 -0
  917. package/dist/ui/streamingFormatter.d.ts.map +1 -0
  918. package/dist/ui/streamingFormatter.js +98 -0
  919. package/dist/ui/streamingFormatter.js.map +1 -0
  920. package/dist/ui/telemetry/ResponseTracker.d.ts +22 -0
  921. package/dist/ui/telemetry/ResponseTracker.d.ts.map +1 -0
  922. package/dist/ui/telemetry/ResponseTracker.js +60 -0
  923. package/dist/ui/telemetry/ResponseTracker.js.map +1 -0
  924. package/dist/ui/telemetry/UITelemetry.d.ts +181 -0
  925. package/dist/ui/telemetry/UITelemetry.d.ts.map +1 -0
  926. package/dist/ui/telemetry/UITelemetry.js +446 -0
  927. package/dist/ui/telemetry/UITelemetry.js.map +1 -0
  928. package/dist/ui/textHighlighter.d.ts +83 -0
  929. package/dist/ui/textHighlighter.d.ts.map +1 -0
  930. package/dist/ui/textHighlighter.js +267 -0
  931. package/dist/ui/textHighlighter.js.map +1 -0
  932. package/dist/ui/theme.d.ts +208 -0
  933. package/dist/ui/theme.d.ts.map +1 -0
  934. package/dist/ui/theme.js +249 -0
  935. package/dist/ui/theme.js.map +1 -0
  936. package/dist/ui/unified/index.d.ts +50 -0
  937. package/dist/ui/unified/index.d.ts.map +1 -0
  938. package/dist/ui/unified/index.js +77 -0
  939. package/dist/ui/unified/index.js.map +1 -0
  940. package/dist/ui/unified/layout.d.ts +12 -0
  941. package/dist/ui/unified/layout.d.ts.map +1 -0
  942. package/dist/ui/unified/layout.js +96 -0
  943. package/dist/ui/unified/layout.js.map +1 -0
  944. package/dist/ui/writeLock.d.ts +65 -0
  945. package/dist/ui/writeLock.d.ts.map +1 -0
  946. package/dist/ui/writeLock.js +114 -0
  947. package/dist/ui/writeLock.js.map +1 -0
  948. package/dist/utils/asyncUtils.d.ts +95 -0
  949. package/dist/utils/asyncUtils.d.ts.map +1 -0
  950. package/dist/utils/asyncUtils.js +286 -0
  951. package/dist/utils/asyncUtils.js.map +1 -0
  952. package/dist/utils/errorUtils.d.ts +16 -0
  953. package/dist/utils/errorUtils.d.ts.map +1 -0
  954. package/dist/utils/errorUtils.js +66 -0
  955. package/dist/utils/errorUtils.js.map +1 -0
  956. package/dist/utils/frontmatter.d.ts +10 -0
  957. package/dist/utils/frontmatter.d.ts.map +1 -0
  958. package/dist/utils/frontmatter.js +78 -0
  959. package/dist/utils/frontmatter.js.map +1 -0
  960. package/dist/utils/planFormatter.d.ts +34 -0
  961. package/dist/utils/planFormatter.d.ts.map +1 -0
  962. package/dist/utils/planFormatter.js +140 -0
  963. package/dist/utils/planFormatter.js.map +1 -0
  964. package/dist/workspace.d.ts +8 -0
  965. package/dist/workspace.d.ts.map +1 -0
  966. package/dist/workspace.js +107 -0
  967. package/dist/workspace.js.map +1 -0
  968. package/dist/workspace.validator.d.ts +49 -0
  969. package/dist/workspace.validator.d.ts.map +1 -0
  970. package/dist/workspace.validator.js +214 -0
  971. package/dist/workspace.validator.js.map +1 -0
  972. package/package.json +1 -1
@@ -0,0 +1,2102 @@
1
+ /**
2
+ * Learn Tools - Codebase exploration and learning tools for understanding codebases.
3
+ *
4
+ * These tools enable deep codebase exploration without requiring external API calls
5
+ * for the core analysis. The AI can use these tools to build a comprehensive
6
+ * understanding of any codebase's architecture, patterns, and conventions.
7
+ *
8
+ * Features:
9
+ * - Codebase structure analysis
10
+ * - Pattern detection and learning
11
+ * - Architecture understanding
12
+ * - File relationship mapping
13
+ * - Topic-based exploration
14
+ */
15
+ import { createHash } from 'node:crypto';
16
+ import { readFileSync, existsSync, readdirSync, statSync } from 'node:fs';
17
+ import { homedir } from 'node:os';
18
+ import { join, relative, extname, basename } from 'node:path';
19
+ import { buildError } from '../core/errors.js';
20
+ // =====================================================
21
+ // Constants
22
+ // =====================================================
23
+ const IGNORED_DIRS = new Set([
24
+ 'node_modules',
25
+ '.git',
26
+ '.svn',
27
+ '.hg',
28
+ 'dist',
29
+ 'build',
30
+ 'out',
31
+ '.next',
32
+ '.nuxt',
33
+ '.output',
34
+ 'coverage',
35
+ '.nyc_output',
36
+ '.cache',
37
+ '.turbo',
38
+ '.vercel',
39
+ '.netlify',
40
+ '__pycache__',
41
+ '.pytest_cache',
42
+ '.mypy_cache',
43
+ '.ruff_cache',
44
+ 'venv',
45
+ '.venv',
46
+ 'env',
47
+ '.env',
48
+ 'target',
49
+ 'vendor',
50
+ '.idea',
51
+ '.vscode',
52
+ ]);
53
+ const LANGUAGE_MAP = {
54
+ '.ts': 'TypeScript',
55
+ '.tsx': 'TypeScript React',
56
+ '.js': 'JavaScript',
57
+ '.jsx': 'JavaScript React',
58
+ '.mjs': 'JavaScript (ESM)',
59
+ '.cjs': 'JavaScript (CJS)',
60
+ '.py': 'Python',
61
+ '.pyw': 'Python',
62
+ '.pyi': 'Python Stub',
63
+ '.rs': 'Rust',
64
+ '.go': 'Go',
65
+ '.java': 'Java',
66
+ '.kt': 'Kotlin',
67
+ '.kts': 'Kotlin Script',
68
+ '.scala': 'Scala',
69
+ '.rb': 'Ruby',
70
+ '.php': 'PHP',
71
+ '.cs': 'C#',
72
+ '.fs': 'F#',
73
+ '.cpp': 'C++',
74
+ '.cc': 'C++',
75
+ '.cxx': 'C++',
76
+ '.c': 'C',
77
+ '.h': 'C/C++ Header',
78
+ '.hpp': 'C++ Header',
79
+ '.swift': 'Swift',
80
+ '.m': 'Objective-C',
81
+ '.mm': 'Objective-C++',
82
+ '.vue': 'Vue',
83
+ '.svelte': 'Svelte',
84
+ '.elm': 'Elm',
85
+ '.ex': 'Elixir',
86
+ '.exs': 'Elixir Script',
87
+ '.erl': 'Erlang',
88
+ '.hs': 'Haskell',
89
+ '.ml': 'OCaml',
90
+ '.mli': 'OCaml Interface',
91
+ '.lua': 'Lua',
92
+ '.pl': 'Perl',
93
+ '.pm': 'Perl Module',
94
+ '.sh': 'Shell',
95
+ '.bash': 'Bash',
96
+ '.zsh': 'Zsh',
97
+ '.fish': 'Fish',
98
+ '.ps1': 'PowerShell',
99
+ '.sql': 'SQL',
100
+ '.json': 'JSON',
101
+ '.yaml': 'YAML',
102
+ '.yml': 'YAML',
103
+ '.toml': 'TOML',
104
+ '.xml': 'XML',
105
+ '.md': 'Markdown',
106
+ '.mdx': 'MDX',
107
+ '.html': 'HTML',
108
+ '.htm': 'HTML',
109
+ '.css': 'CSS',
110
+ '.scss': 'SCSS',
111
+ '.sass': 'Sass',
112
+ '.less': 'Less',
113
+ '.styl': 'Stylus',
114
+ };
115
+ const CONFIG_FILES = {
116
+ 'package.json': { type: 'npm', purpose: 'Node.js package configuration and dependencies' },
117
+ 'tsconfig.json': { type: 'typescript', purpose: 'TypeScript compiler configuration' },
118
+ 'pyproject.toml': { type: 'python', purpose: 'Python project configuration (PEP 517/518)' },
119
+ 'setup.py': { type: 'python', purpose: 'Python package setup (legacy)' },
120
+ 'requirements.txt': { type: 'python', purpose: 'Python dependencies' },
121
+ 'Cargo.toml': { type: 'rust', purpose: 'Rust package manifest' },
122
+ 'go.mod': { type: 'go', purpose: 'Go module definition' },
123
+ 'pom.xml': { type: 'maven', purpose: 'Maven project configuration' },
124
+ 'build.gradle': { type: 'gradle', purpose: 'Gradle build configuration' },
125
+ 'build.gradle.kts': { type: 'gradle', purpose: 'Gradle Kotlin build configuration' },
126
+ 'Gemfile': { type: 'ruby', purpose: 'Ruby dependencies (Bundler)' },
127
+ 'composer.json': { type: 'php', purpose: 'PHP Composer dependencies' },
128
+ '.eslintrc.json': { type: 'linting', purpose: 'ESLint configuration' },
129
+ '.eslintrc.js': { type: 'linting', purpose: 'ESLint configuration' },
130
+ '.prettierrc': { type: 'formatting', purpose: 'Prettier configuration' },
131
+ 'prettier.config.js': { type: 'formatting', purpose: 'Prettier configuration' },
132
+ '.gitignore': { type: 'git', purpose: 'Git ignore patterns' },
133
+ '.dockerignore': { type: 'docker', purpose: 'Docker ignore patterns' },
134
+ 'Dockerfile': { type: 'docker', purpose: 'Docker image definition' },
135
+ 'docker-compose.yml': { type: 'docker', purpose: 'Docker Compose services' },
136
+ 'docker-compose.yaml': { type: 'docker', purpose: 'Docker Compose services' },
137
+ 'Makefile': { type: 'build', purpose: 'Make build automation' },
138
+ '.env.example': { type: 'config', purpose: 'Environment variable template' },
139
+ 'jest.config.js': { type: 'testing', purpose: 'Jest test configuration' },
140
+ 'vitest.config.ts': { type: 'testing', purpose: 'Vitest test configuration' },
141
+ 'webpack.config.js': { type: 'bundler', purpose: 'Webpack bundler configuration' },
142
+ 'vite.config.ts': { type: 'bundler', purpose: 'Vite build tool configuration' },
143
+ 'rollup.config.js': { type: 'bundler', purpose: 'Rollup bundler configuration' },
144
+ 'next.config.js': { type: 'framework', purpose: 'Next.js configuration' },
145
+ 'nuxt.config.ts': { type: 'framework', purpose: 'Nuxt.js configuration' },
146
+ 'tailwind.config.js': { type: 'css', purpose: 'Tailwind CSS configuration' },
147
+ '.github/workflows': { type: 'ci', purpose: 'GitHub Actions workflows' },
148
+ '.gitlab-ci.yml': { type: 'ci', purpose: 'GitLab CI/CD configuration' },
149
+ 'Jenkinsfile': { type: 'ci', purpose: 'Jenkins pipeline definition' },
150
+ };
151
+ const ARCHITECTURE_PATTERNS = [
152
+ {
153
+ name: 'MVC (Model-View-Controller)',
154
+ indicators: ['models', 'views', 'controllers', 'routes'],
155
+ type: 'architectural',
156
+ },
157
+ {
158
+ name: 'Clean Architecture',
159
+ indicators: ['domain', 'application', 'infrastructure', 'presentation', 'entities', 'use-cases', 'usecases'],
160
+ type: 'architectural',
161
+ },
162
+ {
163
+ name: 'Hexagonal Architecture',
164
+ indicators: ['ports', 'adapters', 'domain', 'application'],
165
+ type: 'architectural',
166
+ },
167
+ {
168
+ name: 'Feature-based Structure',
169
+ indicators: ['features', 'modules'],
170
+ type: 'structural',
171
+ },
172
+ {
173
+ name: 'Component-based',
174
+ indicators: ['components', 'shared', 'common'],
175
+ type: 'structural',
176
+ },
177
+ {
178
+ name: 'Layered Architecture',
179
+ indicators: ['api', 'services', 'repositories', 'data', 'business'],
180
+ type: 'architectural',
181
+ },
182
+ {
183
+ name: 'Microservices',
184
+ indicators: ['services', 'gateway', 'docker-compose'],
185
+ type: 'architectural',
186
+ },
187
+ {
188
+ name: 'Monorepo',
189
+ indicators: ['packages', 'apps', 'libs', 'workspace'],
190
+ type: 'structural',
191
+ },
192
+ {
193
+ name: 'Plugin Architecture',
194
+ indicators: ['plugins', 'extensions', 'addons'],
195
+ type: 'architectural',
196
+ },
197
+ {
198
+ name: 'Event-Driven',
199
+ indicators: ['events', 'handlers', 'listeners', 'subscribers', 'publishers'],
200
+ type: 'architectural',
201
+ },
202
+ ];
203
+ // =====================================================
204
+ // Tool Creation
205
+ // =====================================================
206
+ export function createLearnTools(workingDir) {
207
+ return [
208
+ createLearnCodebaseTool(workingDir),
209
+ createLearnFileTool(workingDir),
210
+ createLearnTopicTool(workingDir),
211
+ createLearnSummaryTool(workingDir),
212
+ ];
213
+ }
214
+ // =====================================================
215
+ // learn_codebase Tool
216
+ // =====================================================
217
+ function createLearnCodebaseTool(workingDir) {
218
+ return {
219
+ name: 'learn_codebase',
220
+ description: `Last-resort deep dive of the codebase (similar to explore) that returns a concise digest by default.
221
+ Use this only when targeted tools (explore, grep, summaries) are insufficient. Detailed mode is opt-in and heavier.`,
222
+ parameters: {
223
+ type: 'object',
224
+ properties: {
225
+ depth: {
226
+ type: 'number',
227
+ description: 'Maximum directory depth to analyze (default: 5)',
228
+ },
229
+ includeHidden: {
230
+ type: 'boolean',
231
+ description: 'Include hidden files/directories in analysis (default: false)',
232
+ },
233
+ focusPath: {
234
+ type: 'string',
235
+ description: 'Focus analysis on a specific subdirectory',
236
+ },
237
+ mode: {
238
+ type: 'string',
239
+ enum: ['concise', 'detailed'],
240
+ description: 'Output mode: concise (default, context-safe) or detailed (full report)',
241
+ },
242
+ },
243
+ additionalProperties: false,
244
+ },
245
+ cacheable: true,
246
+ handler: async (args) => {
247
+ try {
248
+ const requestedDepth = typeof args['depth'] === 'number' ? args['depth'] : 5;
249
+ const includeHidden = args['includeHidden'] === true;
250
+ const focusPath = args['focusPath'];
251
+ const mode = args['mode'] === 'detailed' ? 'detailed' : 'concise';
252
+ const guardrails = createAnalysisGuardrails(requestedDepth, includeHidden, mode);
253
+ const targetDir = focusPath ? resolveFilePath(workingDir, focusPath) : workingDir;
254
+ if (!existsSync(targetDir)) {
255
+ return `Error: Directory not found: ${targetDir}`;
256
+ }
257
+ const indexSnapshot = getRecentExploreIndexSnapshot(workingDir);
258
+ if (mode === 'concise' && !focusPath && indexSnapshot?.fresh) {
259
+ return formatIndexPreflight(indexSnapshot);
260
+ }
261
+ // Deep analysis with progressive output (concise by default to protect context)
262
+ const analysis = await analyzeCodebaseDeep(targetDir, workingDir, guardrails.maxDepth, guardrails.includeHidden, guardrails);
263
+ return mode === 'detailed'
264
+ ? formatCodebaseAnalysis(analysis)
265
+ : formatConciseCodebaseAnalysis(analysis);
266
+ }
267
+ catch (error) {
268
+ return buildError('analyzing codebase', error, { workingDir });
269
+ }
270
+ },
271
+ };
272
+ }
273
+ // =====================================================
274
+ // learn_file Tool
275
+ // =====================================================
276
+ function createLearnFileTool(workingDir) {
277
+ return {
278
+ name: 'learn_file',
279
+ description: `Deep-learn a specific file's purpose, structure, patterns, and relationships.
280
+ This tool provides detailed analysis of a single file including:
281
+ - File purpose and responsibilities
282
+ - Imports and dependencies
283
+ - Exports and public interface
284
+ - Functions and classes with their purposes
285
+ - Complexity metrics
286
+ - Relationships to other files`,
287
+ parameters: {
288
+ type: 'object',
289
+ properties: {
290
+ path: {
291
+ type: 'string',
292
+ description: 'Path to the file to analyze',
293
+ },
294
+ includeRelationships: {
295
+ type: 'boolean',
296
+ description: 'Analyze relationships to other files (default: true)',
297
+ },
298
+ },
299
+ required: ['path'],
300
+ additionalProperties: false,
301
+ },
302
+ cacheable: true,
303
+ handler: async (args) => {
304
+ try {
305
+ const filePath = resolveFilePath(workingDir, args['path']);
306
+ const includeRelationships = args['includeRelationships'] !== false;
307
+ if (!existsSync(filePath)) {
308
+ return `Error: File not found: ${filePath}`;
309
+ }
310
+ const stat = statSync(filePath);
311
+ if (stat.isDirectory()) {
312
+ return `Error: Path is a directory, not a file: ${filePath}`;
313
+ }
314
+ const analysis = analyzeFile(filePath, workingDir, includeRelationships);
315
+ return formatFileAnalysis(analysis);
316
+ }
317
+ catch (error) {
318
+ return buildError('analyzing file', error, { path: String(args['path']) });
319
+ }
320
+ },
321
+ };
322
+ }
323
+ // =====================================================
324
+ // learn_topic Tool
325
+ // =====================================================
326
+ function createLearnTopicTool(workingDir) {
327
+ return {
328
+ name: 'learn_topic',
329
+ description: `Learn about a specific topic, pattern, or concept within the codebase.
330
+ Use this to understand how specific patterns are implemented, such as:
331
+ - Authentication/authorization patterns
332
+ - Error handling conventions
333
+ - Data validation approaches
334
+ - API design patterns
335
+ - State management
336
+ - Testing patterns
337
+ - Any custom pattern or convention`,
338
+ parameters: {
339
+ type: 'object',
340
+ properties: {
341
+ topic: {
342
+ type: 'string',
343
+ description: 'The topic or pattern to learn about (e.g., "authentication", "error handling", "api routes")',
344
+ },
345
+ maxFiles: {
346
+ type: 'number',
347
+ description: 'Maximum number of relevant files to analyze (default: 10)',
348
+ },
349
+ maxExamples: {
350
+ type: 'number',
351
+ description: 'Maximum number of code examples to include (default: 5)',
352
+ },
353
+ },
354
+ required: ['topic'],
355
+ additionalProperties: false,
356
+ },
357
+ cacheable: true,
358
+ handler: async (args) => {
359
+ try {
360
+ const topic = args['topic'];
361
+ const maxFiles = typeof args['maxFiles'] === 'number' ? args['maxFiles'] : 10;
362
+ const maxExamples = typeof args['maxExamples'] === 'number' ? args['maxExamples'] : 5;
363
+ if (!topic || !topic.trim()) {
364
+ return 'Error: topic must be a non-empty string';
365
+ }
366
+ const analysis = analyzeTopic(workingDir, topic.trim(), maxFiles, maxExamples);
367
+ return formatTopicAnalysis(analysis);
368
+ }
369
+ catch (error) {
370
+ return buildError('analyzing topic', error, { topic: String(args['topic']) });
371
+ }
372
+ },
373
+ };
374
+ }
375
+ // =====================================================
376
+ // learn_summary Tool
377
+ // =====================================================
378
+ function createLearnSummaryTool(workingDir) {
379
+ return {
380
+ name: 'learn_summary',
381
+ description: `Generate a learning summary for the codebase suitable for onboarding.
382
+ This creates a comprehensive summary including:
383
+ - Quick start guide
384
+ - Key concepts and terminology
385
+ - Architecture overview
386
+ - Important files and their purposes
387
+ - Common patterns and conventions
388
+ - Development workflow suggestions`,
389
+ parameters: {
390
+ type: 'object',
391
+ properties: {
392
+ format: {
393
+ type: 'string',
394
+ description: 'Output format: "markdown" (default) or "text"',
395
+ enum: ['markdown', 'text'],
396
+ },
397
+ focus: {
398
+ type: 'string',
399
+ description: 'Focus area for the summary (e.g., "frontend", "backend", "api")',
400
+ },
401
+ },
402
+ additionalProperties: false,
403
+ },
404
+ cacheable: true,
405
+ handler: async (args) => {
406
+ try {
407
+ const format = args['format'] || 'markdown';
408
+ const focus = args['focus'];
409
+ const analysis = analyzeCodebase(workingDir, workingDir, 4, false);
410
+ return formatLearningSummary(analysis, format, focus);
411
+ }
412
+ catch (error) {
413
+ return buildError('generating learning summary', error, { workingDir });
414
+ }
415
+ },
416
+ };
417
+ }
418
+ // =====================================================
419
+ // Analysis Functions
420
+ // =====================================================
421
+ /**
422
+ * Deep codebase analysis with thorough exploration.
423
+ * Does actual file content analysis for better insights.
424
+ */
425
+ async function analyzeCodebaseDeep(targetDir, workingDir, maxDepth, includeHidden, guardrails) {
426
+ const files = [];
427
+ const directories = [];
428
+ const configFiles = [];
429
+ const limits = guardrails ?? createAnalysisGuardrails(maxDepth, includeHidden, 'detailed');
430
+ // Phase 1: Directory structure traversal
431
+ const structure = buildDirectoryTree(targetDir, workingDir, 0, limits.maxDepth, limits.includeHidden, files, directories, configFiles, limits);
432
+ // Phase 2: File type detection and language breakdown
433
+ const languageCounts = new Map();
434
+ for (const file of files) {
435
+ const lang = LANGUAGE_MAP[file.ext] || 'Other';
436
+ const existing = languageCounts.get(lang) || { ext: file.ext, count: 0 };
437
+ existing.count++;
438
+ languageCounts.set(lang, existing);
439
+ }
440
+ const totalFiles = files.length;
441
+ const languages = Array.from(languageCounts.entries())
442
+ .map(([language, data]) => ({
443
+ language,
444
+ extension: data.ext,
445
+ fileCount: data.count,
446
+ percentage: totalFiles > 0 ? (data.count / totalFiles) * 100 : 0,
447
+ }))
448
+ .sort((a, b) => b.fileCount - a.fileCount);
449
+ // Phase 3: Architecture pattern detection
450
+ const dirNames = directories.map((d) => basename(d).toLowerCase());
451
+ const patterns = detectPatterns(dirNames, files.map((f) => f.path));
452
+ // Phase 4: Configuration file analysis with deep inspection
453
+ const configDetails = analyzeConfigFilesDeep(configFiles, targetDir);
454
+ // Phase 5: Dependency analysis
455
+ const dependencies = analyzeDependencies(targetDir);
456
+ // Phase 6: Entry point identification
457
+ const entryPoints = findEntryPoints(files.map((f) => f.path), configFiles);
458
+ // Phase 7: Component and layer mapping
459
+ const architecture = buildArchitectureInsights(patterns, dirNames, targetDir, workingDir);
460
+ // Phase 8: Deep source file analysis for patterns and complexity
461
+ const keyFiles = files
462
+ .filter(f => LANGUAGE_MAP[f.ext] && f.size < 100000)
463
+ .slice(0, 50);
464
+ const codePatterns = new Map();
465
+ let totalComplexity = 0;
466
+ let analyzedFiles = 0;
467
+ for (const file of keyFiles) {
468
+ try {
469
+ const fullPath = join(workingDir, file.path);
470
+ const content = readFileSync(fullPath, 'utf-8');
471
+ const filePatterns = detectCodePatterns(content, file.ext);
472
+ // Accumulate pattern counts
473
+ for (const pattern of filePatterns) {
474
+ codePatterns.set(pattern, (codePatterns.get(pattern) || 0) + 1);
475
+ }
476
+ // Calculate complexity metrics
477
+ const complexity = calculateComplexity(content);
478
+ totalComplexity += complexity.cyclomaticComplexity;
479
+ analyzedFiles++;
480
+ }
481
+ catch {
482
+ // Skip unreadable files
483
+ }
484
+ }
485
+ // Add detected code patterns to the patterns list
486
+ for (const [patternName, count] of codePatterns.entries()) {
487
+ if (count >= 3) { // Only include patterns found in multiple files
488
+ patterns.push({
489
+ name: patternName,
490
+ type: 'design',
491
+ description: `Found ${patternName} pattern in ${count} files`,
492
+ evidence: [`Detected in ${count} source files`],
493
+ confidence: count >= 10 ? 'high' : count >= 5 ? 'medium' : 'low',
494
+ });
495
+ }
496
+ }
497
+ return {
498
+ rootDir: relative(workingDir, targetDir) || '.',
499
+ totalFiles,
500
+ totalDirectories: directories.length,
501
+ languages,
502
+ structure,
503
+ patterns,
504
+ architecture,
505
+ entryPoints,
506
+ configFiles: configDetails,
507
+ dependencies,
508
+ guardrails: limits,
509
+ };
510
+ }
511
+ function analyzeConfigFilesDeep(configs, targetDir) {
512
+ // Enhance config info with actual content analysis where useful
513
+ return configs.map(config => {
514
+ try {
515
+ const fullPath = join(targetDir, config.path);
516
+ if (config.name === 'package.json' && existsSync(fullPath)) {
517
+ const content = JSON.parse(readFileSync(fullPath, 'utf-8'));
518
+ const scripts = Object.keys(content.scripts || {}).slice(0, 5);
519
+ if (scripts.length > 0) {
520
+ return {
521
+ ...config,
522
+ purpose: `${config.purpose} (scripts: ${scripts.join(', ')})`,
523
+ };
524
+ }
525
+ }
526
+ }
527
+ catch {
528
+ // Keep original
529
+ }
530
+ return config;
531
+ });
532
+ }
533
+ function analyzeCodebase(targetDir, workingDir, maxDepth, includeHidden, guardrails) {
534
+ const files = [];
535
+ const directories = [];
536
+ const configFiles = [];
537
+ const limits = guardrails ?? createAnalysisGuardrails(maxDepth, includeHidden, 'concise');
538
+ // Build directory tree and collect files
539
+ const structure = buildDirectoryTree(targetDir, workingDir, 0, limits.maxDepth, limits.includeHidden, files, directories, configFiles, limits);
540
+ // Calculate language breakdown
541
+ const languageCounts = new Map();
542
+ for (const file of files) {
543
+ const lang = LANGUAGE_MAP[file.ext] || 'Other';
544
+ const existing = languageCounts.get(lang) || { ext: file.ext, count: 0 };
545
+ existing.count++;
546
+ languageCounts.set(lang, existing);
547
+ }
548
+ const totalFiles = files.length;
549
+ const languages = Array.from(languageCounts.entries())
550
+ .map(([language, data]) => ({
551
+ language,
552
+ extension: data.ext,
553
+ fileCount: data.count,
554
+ percentage: totalFiles > 0 ? (data.count / totalFiles) * 100 : 0,
555
+ }))
556
+ .sort((a, b) => b.fileCount - a.fileCount);
557
+ // Detect architecture patterns
558
+ const dirNames = directories.map((d) => basename(d).toLowerCase());
559
+ const patterns = detectPatterns(dirNames, files.map((f) => f.path));
560
+ // Build architecture insights
561
+ const architecture = buildArchitectureInsights(patterns, dirNames, targetDir, workingDir);
562
+ // Find entry points
563
+ const entryPoints = findEntryPoints(files.map((f) => f.path), configFiles);
564
+ // Analyze dependencies
565
+ const dependencies = analyzeDependencies(targetDir);
566
+ return {
567
+ rootDir: relative(workingDir, targetDir) || '.',
568
+ totalFiles,
569
+ totalDirectories: directories.length,
570
+ languages,
571
+ structure,
572
+ patterns,
573
+ architecture,
574
+ entryPoints,
575
+ configFiles,
576
+ dependencies,
577
+ guardrails: limits,
578
+ };
579
+ }
580
+ function buildDirectoryTree(dir, workingDir, depth, maxDepth, includeHidden, files, directories, configFiles, guardrails) {
581
+ const name = basename(dir) || dir;
582
+ const relPath = relative(workingDir, dir) || '.';
583
+ const node = {
584
+ name,
585
+ path: relPath,
586
+ type: 'directory',
587
+ children: [],
588
+ };
589
+ if (depth >= maxDepth) {
590
+ return node;
591
+ }
592
+ try {
593
+ const entries = readdirSync(dir, { withFileTypes: true });
594
+ for (const entry of entries) {
595
+ if (guardrails.truncated) {
596
+ break;
597
+ }
598
+ // Skip hidden files/dirs if not requested
599
+ if (!includeHidden && entry.name.startsWith('.')) {
600
+ continue;
601
+ }
602
+ // Skip ignored directories
603
+ if (IGNORED_DIRS.has(entry.name)) {
604
+ continue;
605
+ }
606
+ const fullPath = join(dir, entry.name);
607
+ const entryRelPath = relative(workingDir, fullPath);
608
+ if (entry.isDirectory()) {
609
+ if (!consumeGuardrailSlot(guardrails, 'node_limit'))
610
+ break;
611
+ directories.push(fullPath);
612
+ const childNode = buildDirectoryTree(fullPath, workingDir, depth + 1, maxDepth, includeHidden, files, directories, configFiles, guardrails);
613
+ node.children.push(childNode);
614
+ }
615
+ else if (entry.isFile()) {
616
+ if (!consumeGuardrailSlot(guardrails, 'node_limit'))
617
+ break;
618
+ try {
619
+ const stat = statSync(fullPath);
620
+ const ext = extname(entry.name).toLowerCase();
621
+ const language = LANGUAGE_MAP[ext];
622
+ files.push({ path: entryRelPath, ext, size: stat.size });
623
+ // Check if it's a config file
624
+ const configInfo = CONFIG_FILES[entry.name];
625
+ if (configInfo) {
626
+ configFiles.push({
627
+ name: entry.name,
628
+ path: entryRelPath,
629
+ type: configInfo.type,
630
+ purpose: configInfo.purpose,
631
+ });
632
+ }
633
+ node.children.push({
634
+ name: entry.name,
635
+ path: entryRelPath,
636
+ type: 'file',
637
+ size: stat.size,
638
+ language,
639
+ });
640
+ }
641
+ catch {
642
+ // Skip files we can't stat
643
+ }
644
+ }
645
+ }
646
+ }
647
+ catch {
648
+ // Skip directories we can't read
649
+ }
650
+ return node;
651
+ }
652
+ function consumeGuardrailSlot(guardrails, reason) {
653
+ if (guardrails.nodeCount >= guardrails.nodeLimit) {
654
+ guardrails.truncated = true;
655
+ guardrails.truncatedReason = guardrails.truncatedReason ?? reason;
656
+ return false;
657
+ }
658
+ guardrails.nodeCount += 1;
659
+ return true;
660
+ }
661
+ function detectPatterns(dirNames, filePaths) {
662
+ const patterns = [];
663
+ const dirNameSet = new Set(dirNames);
664
+ const filePathsLower = filePaths.map((p) => p.toLowerCase());
665
+ for (const pattern of ARCHITECTURE_PATTERNS) {
666
+ const matches = pattern.indicators.filter((ind) => dirNameSet.has(ind));
667
+ if (matches.length >= 2 || (matches.length >= 1 && pattern.indicators.length <= 2)) {
668
+ const confidence = matches.length >= 3 ? 'high' : matches.length >= 2 ? 'medium' : 'low';
669
+ patterns.push({
670
+ name: pattern.name,
671
+ type: pattern.type,
672
+ description: `Detected ${pattern.name} pattern based on directory structure`,
673
+ evidence: matches.map((m) => `Found "${m}" directory`),
674
+ confidence,
675
+ });
676
+ }
677
+ }
678
+ // Detect naming conventions
679
+ const hasKebabCase = filePathsLower.some((p) => /[a-z]+-[a-z]+/.test(basename(p)));
680
+ const hasCamelCase = filePaths.some((p) => /[a-z]+[A-Z][a-z]+/.test(basename(p)));
681
+ const hasPascalCase = filePaths.some((p) => /^[A-Z][a-z]+[A-Z]/.test(basename(p)));
682
+ const hasSnakeCase = filePathsLower.some((p) => /[a-z]+_[a-z]+/.test(basename(p)));
683
+ const namingConventions = [];
684
+ if (hasKebabCase)
685
+ namingConventions.push('kebab-case');
686
+ if (hasCamelCase)
687
+ namingConventions.push('camelCase');
688
+ if (hasPascalCase)
689
+ namingConventions.push('PascalCase');
690
+ if (hasSnakeCase)
691
+ namingConventions.push('snake_case');
692
+ if (namingConventions.length > 0) {
693
+ patterns.push({
694
+ name: 'File Naming Convention',
695
+ type: 'naming',
696
+ description: `Uses ${namingConventions.join(', ')} naming convention(s)`,
697
+ evidence: namingConventions.map((n) => `Detected ${n} pattern in filenames`),
698
+ confidence: 'medium',
699
+ });
700
+ }
701
+ // Detect test patterns
702
+ const hasTestDir = dirNameSet.has('test') || dirNameSet.has('tests') || dirNameSet.has('__tests__');
703
+ const hasSpecFiles = filePathsLower.some((p) => p.includes('.spec.') || p.includes('.test.'));
704
+ if (hasTestDir || hasSpecFiles) {
705
+ patterns.push({
706
+ name: 'Testing Structure',
707
+ type: 'structural',
708
+ description: hasTestDir
709
+ ? 'Uses dedicated test directory'
710
+ : 'Uses co-located test files (.spec/.test)',
711
+ evidence: hasTestDir
712
+ ? ['Found test/tests/__tests__ directory']
713
+ : ['Found .spec or .test files alongside source'],
714
+ confidence: 'high',
715
+ });
716
+ }
717
+ return patterns;
718
+ }
719
+ function buildArchitectureInsights(patterns, dirNames, targetDir, workingDir) {
720
+ const archPattern = patterns.find((p) => p.type === 'architectural');
721
+ const type = archPattern?.name || 'Custom/Unknown';
722
+ const layers = [];
723
+ const components = [];
724
+ // Identify layers based on common directory names
725
+ const layerDirs = ['api', 'routes', 'controllers', 'services', 'models', 'views', 'components', 'utils', 'lib', 'core'];
726
+ for (const layer of layerDirs) {
727
+ if (dirNames.includes(layer)) {
728
+ layers.push(layer);
729
+ }
730
+ }
731
+ // Build component info from top-level directories
732
+ try {
733
+ const entries = readdirSync(targetDir, { withFileTypes: true });
734
+ for (const entry of entries) {
735
+ if (entry.isDirectory() && !IGNORED_DIRS.has(entry.name) && !entry.name.startsWith('.')) {
736
+ const componentPath = relative(workingDir, join(targetDir, entry.name));
737
+ components.push({
738
+ name: entry.name,
739
+ type: inferComponentType(entry.name),
740
+ path: componentPath,
741
+ responsibilities: inferResponsibilities(entry.name),
742
+ });
743
+ }
744
+ }
745
+ }
746
+ catch {
747
+ // Ignore errors
748
+ }
749
+ const dataFlow = inferDataFlow(layers, type);
750
+ return {
751
+ type,
752
+ layers,
753
+ components,
754
+ dataFlow,
755
+ };
756
+ }
757
+ function inferComponentType(name) {
758
+ const lower = name.toLowerCase();
759
+ if (['api', 'routes', 'controllers', 'handlers'].includes(lower))
760
+ return 'API Layer';
761
+ if (['services', 'business', 'domain'].includes(lower))
762
+ return 'Business Logic';
763
+ if (['models', 'entities', 'schemas'].includes(lower))
764
+ return 'Data Models';
765
+ if (['views', 'pages', 'screens'].includes(lower))
766
+ return 'Presentation';
767
+ if (['components', 'ui'].includes(lower))
768
+ return 'UI Components';
769
+ if (['utils', 'helpers', 'lib', 'common', 'shared'].includes(lower))
770
+ return 'Utilities';
771
+ if (['config', 'configs', 'settings'].includes(lower))
772
+ return 'Configuration';
773
+ if (['test', 'tests', '__tests__', 'spec'].includes(lower))
774
+ return 'Testing';
775
+ if (['types', 'interfaces', 'contracts'].includes(lower))
776
+ return 'Type Definitions';
777
+ if (['middleware', 'middlewares'].includes(lower))
778
+ return 'Middleware';
779
+ if (['plugins', 'extensions', 'addons'].includes(lower))
780
+ return 'Extensions';
781
+ return 'Module';
782
+ }
783
+ function inferResponsibilities(name) {
784
+ const lower = name.toLowerCase();
785
+ const responsibilities = [];
786
+ if (['api', 'routes'].includes(lower)) {
787
+ responsibilities.push('HTTP request handling', 'Route definitions', 'Request/response processing');
788
+ }
789
+ else if (lower === 'controllers') {
790
+ responsibilities.push('Request handling', 'Input validation', 'Response formatting');
791
+ }
792
+ else if (lower === 'services') {
793
+ responsibilities.push('Business logic', 'Data orchestration', 'External integrations');
794
+ }
795
+ else if (lower === 'models') {
796
+ responsibilities.push('Data structures', 'Database schemas', 'Data validation');
797
+ }
798
+ else if (['views', 'pages'].includes(lower)) {
799
+ responsibilities.push('UI rendering', 'Page composition', 'Layout management');
800
+ }
801
+ else if (lower === 'components') {
802
+ responsibilities.push('Reusable UI elements', 'Component logic', 'State management');
803
+ }
804
+ else if (['utils', 'helpers'].includes(lower)) {
805
+ responsibilities.push('Utility functions', 'Common helpers', 'Shared logic');
806
+ }
807
+ return responsibilities.length > 0 ? responsibilities : ['Module functionality'];
808
+ }
809
+ function inferDataFlow(layers, archType) {
810
+ if (archType.includes('MVC')) {
811
+ return ['Request → Controller → Model → View → Response'];
812
+ }
813
+ if (archType.includes('Clean')) {
814
+ return [
815
+ 'External → Controllers → Use Cases → Entities',
816
+ 'Entities → Use Cases → Presenters → External',
817
+ ];
818
+ }
819
+ if (archType.includes('Layered')) {
820
+ return ['API → Services → Repositories → Database'];
821
+ }
822
+ if (layers.length > 0) {
823
+ return [`Request → ${layers.join(' → ')} → Response`];
824
+ }
825
+ return ['Standard request/response flow'];
826
+ }
827
+ function findEntryPoints(filePaths, configFiles) {
828
+ const entryPoints = [];
829
+ // Check for common entry point patterns
830
+ const entryPatterns = [
831
+ 'index.ts',
832
+ 'index.js',
833
+ 'main.ts',
834
+ 'main.js',
835
+ 'app.ts',
836
+ 'app.js',
837
+ 'server.ts',
838
+ 'server.js',
839
+ 'cli.ts',
840
+ 'cli.js',
841
+ '__main__.py',
842
+ 'main.py',
843
+ 'app.py',
844
+ 'manage.py',
845
+ 'main.go',
846
+ 'main.rs',
847
+ 'lib.rs',
848
+ ];
849
+ for (const pattern of entryPatterns) {
850
+ const match = filePaths.find((p) => basename(p) === pattern || p.endsWith(`/src/${pattern}`) || p.endsWith(`/bin/${pattern}`));
851
+ if (match) {
852
+ entryPoints.push(match);
853
+ }
854
+ }
855
+ // Check package.json for main/bin
856
+ const pkgJson = configFiles.find((c) => c.name === 'package.json');
857
+ if (pkgJson) {
858
+ entryPoints.push(`${pkgJson.path} (see "main" or "bin" fields)`);
859
+ }
860
+ return [...new Set(entryPoints)];
861
+ }
862
+ function analyzeDependencies(dir) {
863
+ const result = {
864
+ dependencies: [],
865
+ devDependencies: [],
866
+ hasDependencyFile: false,
867
+ };
868
+ // Check package.json
869
+ const pkgPath = join(dir, 'package.json');
870
+ if (existsSync(pkgPath)) {
871
+ try {
872
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
873
+ result.packageManager = 'npm';
874
+ result.hasDependencyFile = true;
875
+ result.dependencies = Object.keys(pkg.dependencies || {}).slice(0, 20);
876
+ result.devDependencies = Object.keys(pkg.devDependencies || {}).slice(0, 20);
877
+ }
878
+ catch {
879
+ // Ignore parse errors
880
+ }
881
+ }
882
+ // Check pyproject.toml
883
+ const pyprojectPath = join(dir, 'pyproject.toml');
884
+ if (existsSync(pyprojectPath)) {
885
+ result.packageManager = result.packageManager || 'pip';
886
+ result.hasDependencyFile = true;
887
+ // Basic TOML parsing for dependencies
888
+ try {
889
+ const content = readFileSync(pyprojectPath, 'utf-8');
890
+ const depMatch = content.match(/dependencies\s*=\s*\[([\s\S]*?)\]/);
891
+ if (depMatch && depMatch[1]) {
892
+ const deps = depMatch[1].match(/"([^"]+)"/g) || [];
893
+ result.dependencies = deps.map((d) => d.replace(/"/g, '').split(/[<>=!]/)[0]?.trim() ?? '').slice(0, 20);
894
+ }
895
+ }
896
+ catch {
897
+ // Ignore parse errors
898
+ }
899
+ }
900
+ // Check Cargo.toml
901
+ const cargoPath = join(dir, 'Cargo.toml');
902
+ if (existsSync(cargoPath)) {
903
+ result.packageManager = 'cargo';
904
+ result.hasDependencyFile = true;
905
+ }
906
+ // Check go.mod
907
+ const goModPath = join(dir, 'go.mod');
908
+ if (existsSync(goModPath)) {
909
+ result.packageManager = 'go modules';
910
+ result.hasDependencyFile = true;
911
+ }
912
+ return result;
913
+ }
914
+ function analyzeFile(filePath, workingDir, includeRelationships) {
915
+ const content = readFileSync(filePath, 'utf-8');
916
+ const lines = content.split('\n');
917
+ const ext = extname(filePath).toLowerCase();
918
+ const language = LANGUAGE_MAP[ext] || 'Unknown';
919
+ const relPath = relative(workingDir, filePath);
920
+ const imports = extractImports(content, ext);
921
+ const exports = extractExports(content, ext);
922
+ const functions = extractFunctions(content, ext);
923
+ const classes = extractClasses(content, ext);
924
+ const patterns = detectCodePatterns(content, ext);
925
+ const complexity = calculateComplexity(content);
926
+ const purpose = inferFilePurpose(basename(filePath), content, imports, exports, functions, classes);
927
+ const relationships = [];
928
+ if (includeRelationships) {
929
+ // Build relationships from imports
930
+ for (const imp of imports) {
931
+ if (imp.isRelative) {
932
+ relationships.push({
933
+ targetFile: imp.resolvedPath || imp.source,
934
+ type: 'imports',
935
+ symbols: imp.specifiers,
936
+ });
937
+ }
938
+ }
939
+ }
940
+ return {
941
+ path: relPath,
942
+ language,
943
+ size: content.length,
944
+ lineCount: lines.length,
945
+ purpose,
946
+ imports,
947
+ exports,
948
+ functions,
949
+ classes,
950
+ patterns,
951
+ relationships,
952
+ complexity,
953
+ };
954
+ }
955
+ function extractImports(content, ext) {
956
+ const imports = [];
957
+ if (['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].includes(ext)) {
958
+ // ES6 imports
959
+ const importRegex = /import\s+(?:(\*\s+as\s+\w+)|(\{[^}]+\})|(\w+)(?:\s*,\s*\{([^}]+)\})?)\s+from\s+['"]([^'"]+)['"]/g;
960
+ let match;
961
+ while ((match = importRegex.exec(content)) !== null) {
962
+ const source = match[5] || '';
963
+ let specifiers = [];
964
+ if (match[1]) {
965
+ // namespace import
966
+ specifiers = [match[1].trim()];
967
+ }
968
+ else if (match[2]) {
969
+ // named imports
970
+ specifiers = match[2]
971
+ .replace(/[{}]/g, '')
972
+ .split(',')
973
+ .map((s) => s.trim())
974
+ .filter(Boolean);
975
+ }
976
+ else if (match[3]) {
977
+ // default import
978
+ specifiers = [match[3]];
979
+ if (match[4]) {
980
+ // additional named imports
981
+ specifiers.push(...match[4]
982
+ .split(',')
983
+ .map((s) => s.trim())
984
+ .filter(Boolean));
985
+ }
986
+ }
987
+ imports.push({
988
+ source,
989
+ specifiers,
990
+ isRelative: source.startsWith('.') || source.startsWith('/'),
991
+ });
992
+ }
993
+ // CommonJS requires
994
+ const requireRegex = /(?:const|let|var)\s+(?:(\{[^}]+\})|(\w+))\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
995
+ while ((match = requireRegex.exec(content)) !== null) {
996
+ const source = match[3] || '';
997
+ let specifiers = [];
998
+ if (match[1]) {
999
+ specifiers = match[1]
1000
+ .replace(/[{}]/g, '')
1001
+ .split(',')
1002
+ .map((s) => s.trim())
1003
+ .filter(Boolean);
1004
+ }
1005
+ else if (match[2]) {
1006
+ specifiers = [match[2]];
1007
+ }
1008
+ imports.push({
1009
+ source,
1010
+ specifiers,
1011
+ isRelative: source.startsWith('.') || source.startsWith('/'),
1012
+ });
1013
+ }
1014
+ }
1015
+ else if (ext === '.py') {
1016
+ // Python imports
1017
+ const fromImportRegex = /from\s+([^\s]+)\s+import\s+(.+)/g;
1018
+ let match;
1019
+ while ((match = fromImportRegex.exec(content)) !== null) {
1020
+ const source = match[1] ?? '';
1021
+ const specifiers = (match[2] ?? '')
1022
+ .split(',')
1023
+ .map((s) => s.trim().split(' as ')[0]?.trim() ?? '')
1024
+ .filter(Boolean);
1025
+ imports.push({
1026
+ source,
1027
+ specifiers,
1028
+ isRelative: source.startsWith('.'),
1029
+ });
1030
+ }
1031
+ const importRegex = /^import\s+([^\s,]+(?:\s*,\s*[^\s,]+)*)/gm;
1032
+ while ((match = importRegex.exec(content)) !== null) {
1033
+ const modules = (match[1] ?? '').split(',').map((s) => s.trim().split(' as ')[0]?.trim() ?? '');
1034
+ for (const mod of modules) {
1035
+ if (mod) {
1036
+ imports.push({
1037
+ source: mod,
1038
+ specifiers: [mod],
1039
+ isRelative: mod.startsWith('.'),
1040
+ });
1041
+ }
1042
+ }
1043
+ }
1044
+ }
1045
+ return imports;
1046
+ }
1047
+ function extractExports(content, ext) {
1048
+ const exports = [];
1049
+ if (['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].includes(ext)) {
1050
+ // Export default
1051
+ const defaultMatch = content.match(/export\s+default\s+(?:class|function)?\s*(\w+)?/);
1052
+ if (defaultMatch) {
1053
+ exports.push({
1054
+ name: defaultMatch[1] || 'default',
1055
+ type: 'default',
1056
+ });
1057
+ }
1058
+ // Named exports
1059
+ const namedExportRegex = /export\s+(?:const|let|var|function|class|interface|type|enum)\s+(\w+)/g;
1060
+ let match;
1061
+ while ((match = namedExportRegex.exec(content)) !== null) {
1062
+ const name = match[1] || '';
1063
+ const line = content.substring(0, match.index).split('\n').length;
1064
+ const lineContent = content.split('\n')[line - 1] || '';
1065
+ let type = 'named';
1066
+ if (lineContent.includes('interface'))
1067
+ type = 'interface';
1068
+ else if (lineContent.includes('type'))
1069
+ type = 'type';
1070
+ else if (lineContent.includes('class'))
1071
+ type = 'class';
1072
+ else if (lineContent.includes('function'))
1073
+ type = 'function';
1074
+ exports.push({ name, type });
1075
+ }
1076
+ // Re-exports
1077
+ const reExportRegex = /export\s+\{([^}]+)\}\s+from/g;
1078
+ while ((match = reExportRegex.exec(content)) !== null) {
1079
+ const names = (match[1] ?? '').split(',').map((s) => s.trim().split(' as ')[0]?.trim() ?? '');
1080
+ for (const name of names) {
1081
+ if (name) {
1082
+ exports.push({ name, type: 'named' });
1083
+ }
1084
+ }
1085
+ }
1086
+ }
1087
+ else if (ext === '.py') {
1088
+ // Python __all__
1089
+ const allMatch = content.match(/__all__\s*=\s*\[([\s\S]*?)\]/);
1090
+ if (allMatch && allMatch[1]) {
1091
+ const names = (allMatch[1].match(/['"]([^'"]+)['"]/g) || []).map((s) => s.replace(/['"]/g, ''));
1092
+ for (const name of names) {
1093
+ exports.push({ name, type: 'named' });
1094
+ }
1095
+ }
1096
+ // Public functions/classes (not starting with _)
1097
+ const defRegex = /^(?:def|class)\s+([a-zA-Z][a-zA-Z0-9_]*)/gm;
1098
+ let match;
1099
+ while ((match = defRegex.exec(content)) !== null) {
1100
+ const name = match[1] || '';
1101
+ if (!name.startsWith('_')) {
1102
+ const lineContent = content.split('\n')[content.substring(0, match.index).split('\n').length - 1] || '';
1103
+ exports.push({
1104
+ name,
1105
+ type: lineContent.startsWith('class') ? 'class' : 'function',
1106
+ });
1107
+ }
1108
+ }
1109
+ }
1110
+ return exports;
1111
+ }
1112
+ function extractFunctions(content, ext) {
1113
+ const functions = [];
1114
+ if (['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].includes(ext)) {
1115
+ // Regular functions
1116
+ const funcRegex = /(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*([^{]+))?\s*\{/g;
1117
+ let match;
1118
+ while ((match = funcRegex.exec(content)) !== null) {
1119
+ const name = match[1] || '';
1120
+ const params = (match[2] || '').split(',').map((p) => p.trim().split(':')[0]?.trim() ?? '').filter(Boolean);
1121
+ const returnType = (match[3] || '').trim() || undefined;
1122
+ const line = content.substring(0, match.index).split('\n').length;
1123
+ const isAsync = content.substring(match.index - 20, match.index).includes('async');
1124
+ const isExported = content.substring(match.index - 20, match.index).includes('export');
1125
+ functions.push({
1126
+ name,
1127
+ line,
1128
+ parameters: params,
1129
+ returnType,
1130
+ isAsync,
1131
+ isExported,
1132
+ complexity: 1,
1133
+ });
1134
+ }
1135
+ // Arrow functions
1136
+ const arrowRegex = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(?([^)=]*)\)?\s*(?::\s*([^=]+))?\s*=>/g;
1137
+ while ((match = arrowRegex.exec(content)) !== null) {
1138
+ const name = match[1] || '';
1139
+ const params = (match[2] || '').split(',').map((p) => p.trim().split(':')[0]?.trim() ?? '').filter(Boolean);
1140
+ const returnType = (match[3] || '').trim() || undefined;
1141
+ const line = content.substring(0, match.index).split('\n').length;
1142
+ const isAsync = content.substring(match.index, match.index + 50).includes('async');
1143
+ const isExported = content.substring(match.index - 20, match.index).includes('export');
1144
+ functions.push({
1145
+ name,
1146
+ line,
1147
+ parameters: params,
1148
+ returnType,
1149
+ isAsync,
1150
+ isExported,
1151
+ complexity: 1,
1152
+ });
1153
+ }
1154
+ }
1155
+ else if (ext === '.py') {
1156
+ const defRegex = /(?:async\s+)?def\s+(\w+)\s*\(([^)]*)\)(?:\s*->\s*([^:]+))?\s*:/g;
1157
+ let match;
1158
+ while ((match = defRegex.exec(content)) !== null) {
1159
+ const name = match[1] ?? '';
1160
+ const params = (match[2] ?? '')
1161
+ .split(',')
1162
+ .map((p) => (p.trim().split(':')[0]?.split('=')[0]?.trim()) ?? '')
1163
+ .filter((p) => p && p !== 'self' && p !== 'cls');
1164
+ const returnType = (match[3] || '').trim() || undefined;
1165
+ const line = content.substring(0, match.index).split('\n').length;
1166
+ const isAsync = content.substring(match.index - 10, match.index).includes('async');
1167
+ functions.push({
1168
+ name,
1169
+ line,
1170
+ parameters: params,
1171
+ returnType,
1172
+ isAsync,
1173
+ isExported: !name.startsWith('_'),
1174
+ complexity: 1,
1175
+ });
1176
+ }
1177
+ }
1178
+ return functions;
1179
+ }
1180
+ function extractClasses(content, ext) {
1181
+ const classes = [];
1182
+ if (['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].includes(ext)) {
1183
+ const classRegex = /(?:export\s+)?class\s+(\w+)(?:\s+extends\s+(\w+))?(?:\s+implements\s+([^{]+))?\s*\{/g;
1184
+ let match;
1185
+ while ((match = classRegex.exec(content)) !== null) {
1186
+ const name = match[1] || '';
1187
+ const line = content.substring(0, match.index).split('\n').length;
1188
+ const extendsClass = match[2];
1189
+ const implementsList = match[3]
1190
+ ? match[3]
1191
+ .split(',')
1192
+ .map((s) => s.trim())
1193
+ .filter(Boolean)
1194
+ : undefined;
1195
+ const isExported = content.substring(match.index - 20, match.index).includes('export');
1196
+ // Find class body and extract methods/properties
1197
+ const classStart = match.index + match[0].length;
1198
+ let braceCount = 1;
1199
+ let classEnd = classStart;
1200
+ for (let i = classStart; i < content.length && braceCount > 0; i++) {
1201
+ if (content[i] === '{')
1202
+ braceCount++;
1203
+ if (content[i] === '}')
1204
+ braceCount--;
1205
+ classEnd = i;
1206
+ }
1207
+ const classBody = content.substring(classStart, classEnd);
1208
+ const methods = [];
1209
+ const properties = [];
1210
+ // Extract methods
1211
+ const methodRegex = /(?:async\s+)?(?:public|private|protected)?\s*(\w+)\s*\([^)]*\)/g;
1212
+ let methodMatch;
1213
+ while ((methodMatch = methodRegex.exec(classBody)) !== null) {
1214
+ if (methodMatch[1] && methodMatch[1] !== 'constructor') {
1215
+ methods.push(methodMatch[1]);
1216
+ }
1217
+ }
1218
+ // Extract properties
1219
+ const propRegex = /(?:public|private|protected|readonly)?\s+(\w+)\s*[:=]/g;
1220
+ let propMatch;
1221
+ while ((propMatch = propRegex.exec(classBody)) !== null) {
1222
+ if (propMatch[1]) {
1223
+ properties.push(propMatch[1]);
1224
+ }
1225
+ }
1226
+ classes.push({
1227
+ name,
1228
+ line,
1229
+ methods,
1230
+ properties,
1231
+ extends: extendsClass,
1232
+ implements: implementsList,
1233
+ isExported,
1234
+ });
1235
+ }
1236
+ }
1237
+ else if (ext === '.py') {
1238
+ const classRegex = /class\s+(\w+)(?:\s*\(([^)]*)\))?\s*:/g;
1239
+ let match;
1240
+ while ((match = classRegex.exec(content)) !== null) {
1241
+ const name = match[1] || '';
1242
+ const line = content.substring(0, match.index).split('\n').length;
1243
+ const parentClasses = match[2]
1244
+ ? match[2]
1245
+ .split(',')
1246
+ .map((s) => s.trim())
1247
+ .filter(Boolean)
1248
+ : [];
1249
+ classes.push({
1250
+ name,
1251
+ line,
1252
+ methods: [],
1253
+ properties: [],
1254
+ extends: parentClasses[0],
1255
+ implements: parentClasses.slice(1),
1256
+ isExported: !name.startsWith('_'),
1257
+ });
1258
+ }
1259
+ }
1260
+ return classes;
1261
+ }
1262
+ function detectCodePatterns(content, _ext) {
1263
+ const patterns = [];
1264
+ // Common patterns detection
1265
+ if (/async\s+function|async\s+\(|await\s+/.test(content)) {
1266
+ patterns.push('Async/Await');
1267
+ }
1268
+ if (/Promise\.all|Promise\.race|Promise\.allSettled/.test(content)) {
1269
+ patterns.push('Promise Combinators');
1270
+ }
1271
+ if (/try\s*\{[\s\S]*?\}\s*catch/.test(content)) {
1272
+ patterns.push('Try-Catch Error Handling');
1273
+ }
1274
+ if (/\.map\s*\(|\.filter\s*\(|\.reduce\s*\(/.test(content)) {
1275
+ patterns.push('Functional Array Methods');
1276
+ }
1277
+ if (/Object\.freeze|Object\.seal|readonly\s+/.test(content)) {
1278
+ patterns.push('Immutability');
1279
+ }
1280
+ if (/interface\s+\w+|type\s+\w+\s*=/.test(content)) {
1281
+ patterns.push('TypeScript Types');
1282
+ }
1283
+ if (/\bclass\s+\w+/.test(content)) {
1284
+ patterns.push('Object-Oriented');
1285
+ }
1286
+ if (/export\s+default|export\s+\{|module\.exports/.test(content)) {
1287
+ patterns.push('Module Pattern');
1288
+ }
1289
+ if (/\.test\(|\.spec\.|describe\s*\(|it\s*\(|expect\s*\(/.test(content)) {
1290
+ patterns.push('Testing');
1291
+ }
1292
+ if (/console\.(log|error|warn|debug)/.test(content)) {
1293
+ patterns.push('Console Logging');
1294
+ }
1295
+ if (/@decorator|@\w+\s*\(|@\w+\s*\n/.test(content)) {
1296
+ patterns.push('Decorators');
1297
+ }
1298
+ if (/useEffect|useState|useCallback|useMemo/.test(content)) {
1299
+ patterns.push('React Hooks');
1300
+ }
1301
+ if (/createSlice|createReducer|createAction/.test(content)) {
1302
+ patterns.push('Redux Toolkit');
1303
+ }
1304
+ return patterns;
1305
+ }
1306
+ function calculateComplexity(content) {
1307
+ const lines = content.split('\n');
1308
+ const linesOfCode = lines.filter((l) => l.trim() && !l.trim().startsWith('//')).length;
1309
+ const linesOfComments = lines.filter((l) => l.trim().startsWith('//')).length;
1310
+ // Simple cyclomatic complexity estimation
1311
+ let cyclomaticComplexity = 1;
1312
+ const controlFlowPatterns = /\bif\b|\belse\b|\bfor\b|\bwhile\b|\bcase\b|\bcatch\b|\b\?\s*:/g;
1313
+ const matches = content.match(controlFlowPatterns);
1314
+ if (matches) {
1315
+ cyclomaticComplexity += matches.length;
1316
+ }
1317
+ // Cognitive complexity (simplified)
1318
+ let cognitiveComplexity = cyclomaticComplexity;
1319
+ const nestedPatterns = /\{\s*\{|\bif\b.*\bif\b/g;
1320
+ const nestedMatches = content.match(nestedPatterns);
1321
+ if (nestedMatches) {
1322
+ cognitiveComplexity += nestedMatches.length * 2;
1323
+ }
1324
+ // Maintainability index (simplified, 0-100 scale)
1325
+ const maintainabilityIndex = Math.max(0, Math.min(100, 171 - 5.2 * Math.log(linesOfCode + 1) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(linesOfCode / (linesOfComments + 1) + 1)));
1326
+ return {
1327
+ cyclomaticComplexity,
1328
+ cognitiveComplexity,
1329
+ maintainabilityIndex: Math.round(maintainabilityIndex),
1330
+ linesOfCode,
1331
+ linesOfComments,
1332
+ };
1333
+ }
1334
+ function inferFilePurpose(filename, _content, _imports, exports, functions, classes) {
1335
+ const lower = filename.toLowerCase();
1336
+ // Check filename patterns
1337
+ if (lower.includes('test') || lower.includes('spec')) {
1338
+ return 'Test file for unit/integration testing';
1339
+ }
1340
+ if (lower === 'index.ts' || lower === 'index.js') {
1341
+ return 'Module entry point and public API exports';
1342
+ }
1343
+ if (lower.includes('config')) {
1344
+ return 'Configuration settings and constants';
1345
+ }
1346
+ if (lower.includes('type') || lower.includes('interface')) {
1347
+ return 'Type definitions and interfaces';
1348
+ }
1349
+ if (lower.includes('util') || lower.includes('helper')) {
1350
+ return 'Utility functions and helpers';
1351
+ }
1352
+ if (lower.includes('hook')) {
1353
+ return 'Custom React hooks';
1354
+ }
1355
+ if (lower.includes('context')) {
1356
+ return 'React context provider';
1357
+ }
1358
+ if (lower.includes('store') || lower.includes('reducer')) {
1359
+ return 'State management';
1360
+ }
1361
+ if (lower.includes('service')) {
1362
+ return 'Business logic and service layer';
1363
+ }
1364
+ if (lower.includes('api') || lower.includes('client')) {
1365
+ return 'API client and HTTP requests';
1366
+ }
1367
+ if (lower.includes('route')) {
1368
+ return 'Route definitions and handlers';
1369
+ }
1370
+ if (lower.includes('middleware')) {
1371
+ return 'Middleware functions';
1372
+ }
1373
+ if (lower.includes('model') || lower.includes('entity')) {
1374
+ return 'Data models and entities';
1375
+ }
1376
+ if (lower.includes('schema')) {
1377
+ return 'Schema definitions and validation';
1378
+ }
1379
+ if (lower.includes('component')) {
1380
+ return 'UI component';
1381
+ }
1382
+ // Infer from content
1383
+ if (classes.length > 0 && functions.length === 0) {
1384
+ return `Class definitions: ${classes.map((c) => c.name).join(', ')}`;
1385
+ }
1386
+ if (functions.length > 0 && classes.length === 0) {
1387
+ const exportedFuncs = functions.filter((f) => f.isExported);
1388
+ if (exportedFuncs.length > 0) {
1389
+ return `Function library: ${exportedFuncs.map((f) => f.name).slice(0, 3).join(', ')}${exportedFuncs.length > 3 ? '...' : ''}`;
1390
+ }
1391
+ }
1392
+ if (exports.length > 0) {
1393
+ return `Module exporting: ${exports.map((e) => e.name).slice(0, 3).join(', ')}${exports.length > 3 ? '...' : ''}`;
1394
+ }
1395
+ return 'General module';
1396
+ }
1397
+ function analyzeTopic(workingDir, topic, maxFiles, maxExamples) {
1398
+ const topicLower = topic.toLowerCase();
1399
+ const relevantFiles = [];
1400
+ const patterns = new Map();
1401
+ const examples = [];
1402
+ // Keywords to search for based on topic
1403
+ const keywords = generateTopicKeywords(topicLower);
1404
+ // Search through files
1405
+ const allFiles = collectAllFiles(workingDir, 4);
1406
+ for (const filePath of allFiles) {
1407
+ try {
1408
+ const content = readFileSync(filePath, 'utf-8');
1409
+ const lines = content.split('\n');
1410
+ const relPath = relative(workingDir, filePath);
1411
+ // Calculate relevance score
1412
+ let relevance = 0;
1413
+ const snippets = [];
1414
+ for (const keyword of keywords) {
1415
+ const regex = new RegExp(keyword, 'gi');
1416
+ const matches = content.match(regex);
1417
+ if (matches) {
1418
+ relevance += matches.length;
1419
+ // Find snippets containing the keyword
1420
+ for (let i = 0; i < lines.length && snippets.length < 3; i++) {
1421
+ if (lines[i]?.toLowerCase().includes(keyword)) {
1422
+ const snippet = lines.slice(Math.max(0, i - 1), Math.min(lines.length, i + 3)).join('\n');
1423
+ if (!snippets.includes(snippet)) {
1424
+ snippets.push(snippet);
1425
+ // Add to patterns
1426
+ const patternName = identifyPattern(lines[i] ?? '', keyword);
1427
+ if (patternName) {
1428
+ const existing = patterns.get(patternName) || { count: 0, locations: [] };
1429
+ existing.count++;
1430
+ if (!existing.locations.includes(relPath)) {
1431
+ existing.locations.push(relPath);
1432
+ }
1433
+ patterns.set(patternName, existing);
1434
+ }
1435
+ // Add to examples
1436
+ if (examples.length < maxExamples) {
1437
+ examples.push({
1438
+ file: relPath,
1439
+ line: i + 1,
1440
+ code: snippet,
1441
+ explanation: `Example of ${topic} usage`,
1442
+ });
1443
+ }
1444
+ }
1445
+ }
1446
+ }
1447
+ }
1448
+ }
1449
+ if (relevance > 0) {
1450
+ relevantFiles.push({
1451
+ path: relPath,
1452
+ relevance,
1453
+ snippets,
1454
+ });
1455
+ }
1456
+ }
1457
+ catch {
1458
+ // Skip files we can't read
1459
+ }
1460
+ }
1461
+ // Sort by relevance and limit
1462
+ relevantFiles.sort((a, b) => b.relevance - a.relevance);
1463
+ const topFiles = relevantFiles.slice(0, maxFiles);
1464
+ // Convert patterns map to array
1465
+ const topicPatterns = Array.from(patterns.entries())
1466
+ .map(([name, data]) => ({
1467
+ name,
1468
+ occurrences: data.count,
1469
+ locations: data.locations,
1470
+ }))
1471
+ .sort((a, b) => b.occurrences - a.occurrences);
1472
+ // Generate summary
1473
+ const summary = generateTopicSummary(topic, topFiles, topicPatterns, examples);
1474
+ return {
1475
+ topic,
1476
+ relevantFiles: topFiles,
1477
+ patterns: topicPatterns,
1478
+ examples: examples.slice(0, maxExamples),
1479
+ summary,
1480
+ };
1481
+ }
1482
+ function generateTopicKeywords(topic) {
1483
+ const keywords = [topic];
1484
+ // Add related keywords
1485
+ const relatedKeywords = {
1486
+ auth: ['authentication', 'authorize', 'login', 'logout', 'session', 'token', 'jwt', 'oauth', 'passport'],
1487
+ error: ['error', 'exception', 'catch', 'throw', 'try', 'finally', 'fail', 'handle'],
1488
+ api: ['api', 'route', 'endpoint', 'handler', 'request', 'response', 'http', 'rest', 'graphql'],
1489
+ test: ['test', 'spec', 'describe', 'it', 'expect', 'mock', 'jest', 'vitest', 'pytest'],
1490
+ database: ['database', 'db', 'sql', 'query', 'model', 'schema', 'migration', 'orm', 'prisma', 'mongoose'],
1491
+ validation: ['validate', 'validation', 'schema', 'zod', 'yup', 'joi', 'check', 'verify'],
1492
+ state: ['state', 'store', 'reducer', 'action', 'dispatch', 'context', 'redux', 'zustand', 'recoil'],
1493
+ cache: ['cache', 'memoize', 'memo', 'redis', 'memcached', 'ttl', 'invalidate'],
1494
+ logging: ['log', 'logger', 'logging', 'debug', 'trace', 'info', 'warn', 'error', 'console'],
1495
+ config: ['config', 'configuration', 'settings', 'env', 'environment', 'options'],
1496
+ };
1497
+ for (const [key, related] of Object.entries(relatedKeywords)) {
1498
+ if (topic.includes(key)) {
1499
+ keywords.push(...related);
1500
+ }
1501
+ }
1502
+ return [...new Set(keywords)];
1503
+ }
1504
+ function identifyPattern(line, _keyword) {
1505
+ const lower = line.toLowerCase();
1506
+ if (lower.includes('try') && lower.includes('catch'))
1507
+ return 'Try-Catch Pattern';
1508
+ if (lower.includes('async') && lower.includes('await'))
1509
+ return 'Async/Await Pattern';
1510
+ if (lower.includes('export') && lower.includes('default'))
1511
+ return 'Default Export';
1512
+ if (lower.includes('import') && lower.includes('from'))
1513
+ return 'ES6 Import';
1514
+ if (lower.includes('class') && lower.includes('extends'))
1515
+ return 'Class Inheritance';
1516
+ if (lower.includes('interface') || lower.includes('type'))
1517
+ return 'Type Definition';
1518
+ if (/\.(map|filter|reduce)\s*\(/.test(lower))
1519
+ return 'Functional Methods';
1520
+ if (lower.includes('usestate') || lower.includes('useeffect'))
1521
+ return 'React Hooks';
1522
+ if (lower.includes('describe') && lower.includes('it'))
1523
+ return 'Test Structure';
1524
+ return null;
1525
+ }
1526
+ function generateTopicSummary(topic, files, patterns, examples) {
1527
+ const parts = [];
1528
+ parts.push(`Analysis of "${topic}" in this codebase:\n`);
1529
+ if (files.length === 0) {
1530
+ parts.push(`No files found directly related to "${topic}". Consider searching for related terms.`);
1531
+ }
1532
+ else {
1533
+ parts.push(`Found ${files.length} relevant file(s).`);
1534
+ if (patterns.length > 0) {
1535
+ parts.push(`\nDetected patterns:`);
1536
+ for (const pattern of patterns.slice(0, 5)) {
1537
+ parts.push(`- ${pattern.name}: ${pattern.occurrences} occurrence(s)`);
1538
+ }
1539
+ }
1540
+ if (examples.length > 0) {
1541
+ parts.push(`\n${examples.length} code example(s) available.`);
1542
+ }
1543
+ parts.push(`\nMost relevant files:`);
1544
+ for (const file of files.slice(0, 5)) {
1545
+ parts.push(`- ${file.path} (relevance: ${file.relevance})`);
1546
+ }
1547
+ }
1548
+ return parts.join('\n');
1549
+ }
1550
+ function collectAllFiles(dir, maxDepth, depth = 0) {
1551
+ const files = [];
1552
+ if (depth >= maxDepth)
1553
+ return files;
1554
+ try {
1555
+ const entries = readdirSync(dir, { withFileTypes: true });
1556
+ for (const entry of entries) {
1557
+ if (entry.name.startsWith('.') || IGNORED_DIRS.has(entry.name)) {
1558
+ continue;
1559
+ }
1560
+ const fullPath = join(dir, entry.name);
1561
+ if (entry.isDirectory()) {
1562
+ files.push(...collectAllFiles(fullPath, maxDepth, depth + 1));
1563
+ }
1564
+ else if (entry.isFile()) {
1565
+ const ext = extname(entry.name).toLowerCase();
1566
+ if (LANGUAGE_MAP[ext]) {
1567
+ files.push(fullPath);
1568
+ }
1569
+ }
1570
+ }
1571
+ }
1572
+ catch {
1573
+ // Skip directories we can't read
1574
+ }
1575
+ return files;
1576
+ }
1577
+ function createAnalysisGuardrails(requestedDepth, includeHidden, mode) {
1578
+ const normalizedDepth = Number.isFinite(requestedDepth) ? requestedDepth : 5;
1579
+ const maxDepth = Math.min(8, Math.max(1, Math.floor(normalizedDepth)));
1580
+ const allowHidden = mode === 'detailed' && includeHidden;
1581
+ return {
1582
+ maxDepth,
1583
+ requestedDepth: normalizedDepth,
1584
+ includeHidden: allowHidden,
1585
+ hiddenRequestBlocked: includeHidden && !allowHidden,
1586
+ nodeLimit: mode === 'detailed' ? 12000 : 6000,
1587
+ nodeCount: 0,
1588
+ truncated: false,
1589
+ };
1590
+ }
1591
+ function getRecentExploreIndexSnapshot(workingDir) {
1592
+ try {
1593
+ const hash = createHash('md5').update(workingDir).digest('hex').slice(0, 12);
1594
+ const indexPath = join(homedir(), '.erosolar', 'explore-cache', `index-${hash}.json`);
1595
+ const stats = statSync(indexPath);
1596
+ const ageMs = Date.now() - stats.mtimeMs;
1597
+ const ageMinutes = Math.max(1, Math.round(ageMs / 60000));
1598
+ const payload = JSON.parse(readFileSync(indexPath, 'utf-8'));
1599
+ const fileCount = Array.isArray(payload?.files) ? payload.files.length : undefined;
1600
+ const freshnessWindowMs = 6 * 60 * 60 * 1000;
1601
+ return {
1602
+ fileCount,
1603
+ fresh: ageMs <= freshnessWindowMs,
1604
+ ageMinutes,
1605
+ };
1606
+ }
1607
+ catch {
1608
+ return null;
1609
+ }
1610
+ }
1611
+ function formatIndexPreflight(snapshot) {
1612
+ const lines = [];
1613
+ lines.push('# learn_codebase guardrail');
1614
+ lines.push(`Recent explore index detected${snapshot.fileCount ? ` (${snapshot.fileCount} files)` : ''}, ~${snapshot.ageMinutes}m old.`);
1615
+ lines.push('Reuse it via `explore` / `explore_index status` before running a fresh deep dive.');
1616
+ lines.push('If you truly need a scan, rerun with mode "detailed" or set a focused path to narrow scope.');
1617
+ return lines.join('\n');
1618
+ }
1619
+ function formatGuardrailSummary(guardrails) {
1620
+ if (!guardrails)
1621
+ return [];
1622
+ const parts = [
1623
+ `depth<=${guardrails.maxDepth}${guardrails.maxDepth < guardrails.requestedDepth ? ` (was ${guardrails.requestedDepth})` : ''}`,
1624
+ `hidden:${guardrails.includeHidden ? 'on' : 'off'}`,
1625
+ `node cap:${guardrails.nodeLimit}`,
1626
+ ];
1627
+ const lines = [`Guardrails: ${parts.join(' | ')}`];
1628
+ if (guardrails.hiddenRequestBlocked) {
1629
+ lines.push('Hidden files scan disabled in concise mode; rerun in detailed mode to include them.');
1630
+ }
1631
+ if (guardrails.truncated) {
1632
+ lines.push(`Traversal stopped early after ${guardrails.nodeCount} items${guardrails.truncatedReason ? ` (${guardrails.truncatedReason})` : ''}.`);
1633
+ }
1634
+ return lines;
1635
+ }
1636
+ // =====================================================
1637
+ // Formatting Functions
1638
+ // =====================================================
1639
+ function formatConciseCodebaseAnalysis(analysis) {
1640
+ const lines = [];
1641
+ const topLanguages = analysis.languages.slice(0, 3).map((lang) => `${lang.language} (${lang.fileCount} files)`);
1642
+ const topPatterns = analysis.patterns.slice(0, 5).map((pattern) => `${pattern.name} (${pattern.confidence})`);
1643
+ const keyComponents = analysis.architecture.components.slice(0, 5).map((comp) => `${comp.name} - ${comp.path}`);
1644
+ const keyDirs = (analysis.structure.children ?? [])
1645
+ .filter((child) => child.type === 'directory')
1646
+ .slice(0, 5)
1647
+ .map((child) => `${child.name}/`);
1648
+ const keyConfigs = analysis.configFiles.slice(0, 5).map((config) => `${config.name}: ${config.purpose}`);
1649
+ const keyDependencies = analysis.dependencies.dependencies.slice(0, 8);
1650
+ const keyDevDependencies = analysis.dependencies.devDependencies.slice(0, 5);
1651
+ lines.push(`# Context-safe repo deep-learn: ${analysis.rootDir}`);
1652
+ lines.push('Use only when targeted explore/grep tools are insufficient.');
1653
+ const guardrailLines = formatGuardrailSummary(analysis.guardrails);
1654
+ if (guardrailLines.length > 0) {
1655
+ lines.push(...guardrailLines);
1656
+ }
1657
+ lines.push('');
1658
+ lines.push('## Overview');
1659
+ lines.push(`- Files: ${analysis.totalFiles} • Directories: ${analysis.totalDirectories}`);
1660
+ lines.push(`- Primary languages: ${topLanguages.length ? topLanguages.join('; ') : 'Unknown'}`);
1661
+ lines.push(`- Architecture: ${analysis.architecture.type || 'Unknown'}`);
1662
+ if (analysis.entryPoints.length > 0) {
1663
+ lines.push(`- Entry points: ${analysis.entryPoints.slice(0, 5).join(', ')}`);
1664
+ }
1665
+ lines.push('');
1666
+ if (topPatterns.length > 0) {
1667
+ lines.push('## Patterns & conventions');
1668
+ lines.push(`- ${topPatterns.join('; ')}`);
1669
+ lines.push('');
1670
+ }
1671
+ if (keyComponents.length > 0 || keyDirs.length > 0) {
1672
+ lines.push('## Key areas to inspect next');
1673
+ if (keyComponents.length > 0) {
1674
+ lines.push(`- Components: ${keyComponents.join('; ')}`);
1675
+ }
1676
+ if (keyDirs.length > 0) {
1677
+ lines.push(`- Important directories: ${keyDirs.join(', ')}`);
1678
+ }
1679
+ lines.push('');
1680
+ }
1681
+ if (keyConfigs.length > 0) {
1682
+ lines.push('## Configuration');
1683
+ lines.push(`- ${keyConfigs.join('; ')}`);
1684
+ lines.push('');
1685
+ }
1686
+ if (analysis.dependencies.hasDependencyFile && (keyDependencies.length > 0 || keyDevDependencies.length > 0)) {
1687
+ lines.push('## Dependencies snapshot');
1688
+ if (keyDependencies.length > 0) {
1689
+ lines.push(`- Dependencies: ${keyDependencies.join(', ')}${analysis.dependencies.dependencies.length > keyDependencies.length ? ' ...' : ''}`);
1690
+ }
1691
+ if (keyDevDependencies.length > 0) {
1692
+ lines.push(`- Dev dependencies: ${keyDevDependencies.join(', ')}${analysis.dependencies.devDependencies.length > keyDevDependencies.length ? ' ...' : ''}`);
1693
+ }
1694
+ lines.push('');
1695
+ }
1696
+ if (analysis.entryPoints.length > 0) {
1697
+ lines.push('## Suggested probes');
1698
+ const entryProbe = analysis.entryPoints.slice(0, 2).map((entry) => `- Check routing/boot flow around ${entry}`);
1699
+ lines.push(...entryProbe);
1700
+ }
1701
+ lines.push('- Run `explore_index status` to reuse the cached index, or `explore_index rebuild` after large file changes.');
1702
+ lines.push('- Use `explore` queries or `Grep` with `head_limit` to target follow-up investigations.');
1703
+ lines.push('');
1704
+ lines.push('Context guard: concise mode trims output to keep the session responsive. Use learn_codebase as a last resort; set mode to "detailed" only if you truly need the full tree and metrics.');
1705
+ return lines.join('\n');
1706
+ }
1707
+ function formatCodebaseAnalysis(analysis) {
1708
+ const output = [];
1709
+ // Show analysis phases completed
1710
+ output.push('# Codebase Analysis: ' + analysis.rootDir);
1711
+ output.push('Use only when targeted explore/grep tools are insufficient.');
1712
+ const guardrailLines = formatGuardrailSummary(analysis.guardrails);
1713
+ if (guardrailLines.length > 0) {
1714
+ output.push(...guardrailLines);
1715
+ }
1716
+ output.push('');
1717
+ output.push('## Analysis Phases Completed');
1718
+ output.push('✓ Directory structure traversal');
1719
+ output.push('✓ File type detection and language breakdown');
1720
+ output.push('✓ Architecture pattern detection');
1721
+ output.push('✓ Configuration file analysis');
1722
+ output.push('✓ Dependency analysis');
1723
+ output.push('✓ Entry point identification');
1724
+ output.push('✓ Component and layer mapping');
1725
+ output.push('');
1726
+ // Overview
1727
+ output.push('## Overview');
1728
+ output.push(`- Total files analyzed: ${analysis.totalFiles}`);
1729
+ output.push(`- Total directories scanned: ${analysis.totalDirectories}`);
1730
+ output.push(`- Patterns detected: ${analysis.patterns.length}`);
1731
+ output.push(`- Config files found: ${analysis.configFiles.length}`);
1732
+ output.push('');
1733
+ // Languages
1734
+ output.push('## Languages');
1735
+ for (const lang of analysis.languages.slice(0, 10)) {
1736
+ output.push(`- ${lang.language}: ${lang.fileCount} files (${lang.percentage.toFixed(1)}%)`);
1737
+ }
1738
+ output.push('');
1739
+ // Architecture
1740
+ output.push('## Architecture');
1741
+ output.push(`- Type: ${analysis.architecture.type}`);
1742
+ if (analysis.architecture.layers.length > 0) {
1743
+ output.push(`- Layers: ${analysis.architecture.layers.join(', ')}`);
1744
+ }
1745
+ if (analysis.architecture.dataFlow.length > 0) {
1746
+ output.push('- Data Flow:');
1747
+ for (const flow of analysis.architecture.dataFlow) {
1748
+ output.push(` - ${flow}`);
1749
+ }
1750
+ }
1751
+ output.push('');
1752
+ // Detected Patterns
1753
+ if (analysis.patterns.length > 0) {
1754
+ output.push('## Detected Patterns');
1755
+ for (const pattern of analysis.patterns) {
1756
+ output.push(`- **${pattern.name}** (${pattern.confidence} confidence)`);
1757
+ output.push(` ${pattern.description}`);
1758
+ }
1759
+ output.push('');
1760
+ }
1761
+ // Key Components
1762
+ if (analysis.architecture.components.length > 0) {
1763
+ output.push('## Key Components');
1764
+ for (const comp of analysis.architecture.components.slice(0, 15)) {
1765
+ output.push(`- **${comp.name}** (${comp.type}): ${comp.path}`);
1766
+ if (comp.responsibilities.length > 0) {
1767
+ output.push(` Responsibilities: ${comp.responsibilities.join(', ')}`);
1768
+ }
1769
+ }
1770
+ output.push('');
1771
+ }
1772
+ // Entry Points
1773
+ if (analysis.entryPoints.length > 0) {
1774
+ output.push('## Entry Points');
1775
+ for (const entry of analysis.entryPoints) {
1776
+ output.push(`- ${entry}`);
1777
+ }
1778
+ output.push('');
1779
+ }
1780
+ // Configuration Files
1781
+ if (analysis.configFiles.length > 0) {
1782
+ output.push('## Configuration Files');
1783
+ for (const config of analysis.configFiles.slice(0, 10)) {
1784
+ output.push(`- **${config.name}** (${config.type}): ${config.purpose}`);
1785
+ }
1786
+ output.push('');
1787
+ }
1788
+ // Dependencies
1789
+ if (analysis.dependencies.hasDependencyFile) {
1790
+ output.push('## Dependencies');
1791
+ output.push(`- Package Manager: ${analysis.dependencies.packageManager || 'Unknown'}`);
1792
+ if (analysis.dependencies.dependencies.length > 0) {
1793
+ output.push(`- Dependencies: ${analysis.dependencies.dependencies.slice(0, 10).join(', ')}${analysis.dependencies.dependencies.length > 10 ? '...' : ''}`);
1794
+ }
1795
+ if (analysis.dependencies.devDependencies.length > 0) {
1796
+ output.push(`- Dev Dependencies: ${analysis.dependencies.devDependencies.slice(0, 10).join(', ')}${analysis.dependencies.devDependencies.length > 10 ? '...' : ''}`);
1797
+ }
1798
+ output.push('');
1799
+ }
1800
+ // Directory Structure (simplified)
1801
+ output.push('## Directory Structure');
1802
+ output.push(formatDirectoryTree(analysis.structure, 0, 3));
1803
+ return output.join('\n');
1804
+ }
1805
+ function formatDirectoryTree(node, depth, maxDepth) {
1806
+ const indent = ' '.repeat(depth);
1807
+ const lines = [];
1808
+ if (node.type === 'directory') {
1809
+ lines.push(`${indent}${node.name}/`);
1810
+ if (node.children && depth < maxDepth) {
1811
+ for (const child of node.children.slice(0, 15)) {
1812
+ lines.push(formatDirectoryTree(child, depth + 1, maxDepth));
1813
+ }
1814
+ if (node.children.length > 15) {
1815
+ lines.push(`${indent} ... (${node.children.length - 15} more)`);
1816
+ }
1817
+ }
1818
+ }
1819
+ else {
1820
+ const langSuffix = node.language ? ` [${node.language}]` : '';
1821
+ lines.push(`${indent}${node.name}${langSuffix}`);
1822
+ }
1823
+ return lines.join('\n');
1824
+ }
1825
+ function formatFileAnalysis(analysis) {
1826
+ const output = [];
1827
+ output.push(`# File Analysis: ${analysis.path}`);
1828
+ output.push('');
1829
+ // Overview
1830
+ output.push('## Overview');
1831
+ output.push(`- Language: ${analysis.language}`);
1832
+ output.push(`- Lines: ${analysis.lineCount}`);
1833
+ output.push(`- Size: ${(analysis.size / 1024).toFixed(2)} KB`);
1834
+ output.push(`- Purpose: ${analysis.purpose}`);
1835
+ output.push('');
1836
+ // Complexity
1837
+ output.push('## Complexity Metrics');
1838
+ output.push(`- Cyclomatic Complexity: ${analysis.complexity.cyclomaticComplexity}`);
1839
+ output.push(`- Cognitive Complexity: ${analysis.complexity.cognitiveComplexity}`);
1840
+ output.push(`- Maintainability Index: ${analysis.complexity.maintainabilityIndex}/100`);
1841
+ output.push(`- Lines of Code: ${analysis.complexity.linesOfCode}`);
1842
+ output.push(`- Lines of Comments: ${analysis.complexity.linesOfComments}`);
1843
+ output.push('');
1844
+ // Imports
1845
+ if (analysis.imports.length > 0) {
1846
+ output.push('## Imports');
1847
+ for (const imp of analysis.imports.slice(0, 15)) {
1848
+ const type = imp.isRelative ? '(relative)' : '(external)';
1849
+ output.push(`- ${imp.source} ${type}`);
1850
+ if (imp.specifiers.length > 0) {
1851
+ output.push(` Imports: ${imp.specifiers.join(', ')}`);
1852
+ }
1853
+ }
1854
+ if (analysis.imports.length > 15) {
1855
+ output.push(`- ... and ${analysis.imports.length - 15} more imports`);
1856
+ }
1857
+ output.push('');
1858
+ }
1859
+ // Exports
1860
+ if (analysis.exports.length > 0) {
1861
+ output.push('## Exports');
1862
+ for (const exp of analysis.exports) {
1863
+ output.push(`- ${exp.name} (${exp.type})`);
1864
+ }
1865
+ output.push('');
1866
+ }
1867
+ // Functions
1868
+ if (analysis.functions.length > 0) {
1869
+ output.push('## Functions');
1870
+ for (const func of analysis.functions.slice(0, 20)) {
1871
+ const async = func.isAsync ? 'async ' : '';
1872
+ const exported = func.isExported ? 'export ' : '';
1873
+ const params = func.parameters.join(', ');
1874
+ const ret = func.returnType ? `: ${func.returnType}` : '';
1875
+ output.push(`- Line ${func.line}: ${exported}${async}${func.name}(${params})${ret}`);
1876
+ }
1877
+ if (analysis.functions.length > 20) {
1878
+ output.push(`- ... and ${analysis.functions.length - 20} more functions`);
1879
+ }
1880
+ output.push('');
1881
+ }
1882
+ // Classes
1883
+ if (analysis.classes.length > 0) {
1884
+ output.push('## Classes');
1885
+ for (const cls of analysis.classes) {
1886
+ const exported = cls.isExported ? 'export ' : '';
1887
+ const ext = cls.extends ? ` extends ${cls.extends}` : '';
1888
+ const impl = cls.implements?.length ? ` implements ${cls.implements.join(', ')}` : '';
1889
+ output.push(`- Line ${cls.line}: ${exported}class ${cls.name}${ext}${impl}`);
1890
+ if (cls.methods.length > 0) {
1891
+ output.push(` Methods: ${cls.methods.join(', ')}`);
1892
+ }
1893
+ if (cls.properties.length > 0) {
1894
+ output.push(` Properties: ${cls.properties.join(', ')}`);
1895
+ }
1896
+ }
1897
+ output.push('');
1898
+ }
1899
+ // Patterns
1900
+ if (analysis.patterns.length > 0) {
1901
+ output.push('## Detected Patterns');
1902
+ output.push(analysis.patterns.join(', '));
1903
+ output.push('');
1904
+ }
1905
+ // Relationships
1906
+ if (analysis.relationships.length > 0) {
1907
+ output.push('## File Relationships');
1908
+ for (const rel of analysis.relationships) {
1909
+ output.push(`- ${rel.type}: ${rel.targetFile}`);
1910
+ if (rel.symbols.length > 0) {
1911
+ output.push(` Symbols: ${rel.symbols.join(', ')}`);
1912
+ }
1913
+ }
1914
+ output.push('');
1915
+ }
1916
+ return output.join('\n');
1917
+ }
1918
+ function formatTopicAnalysis(analysis) {
1919
+ const output = [];
1920
+ output.push(`# Topic Analysis: "${analysis.topic}"`);
1921
+ output.push('');
1922
+ output.push(analysis.summary);
1923
+ output.push('');
1924
+ // Patterns
1925
+ if (analysis.patterns.length > 0) {
1926
+ output.push('## Patterns Found');
1927
+ for (const pattern of analysis.patterns) {
1928
+ output.push(`### ${pattern.name}`);
1929
+ output.push(`- Occurrences: ${pattern.occurrences}`);
1930
+ output.push(`- Found in: ${pattern.locations.slice(0, 5).join(', ')}${pattern.locations.length > 5 ? '...' : ''}`);
1931
+ output.push('');
1932
+ }
1933
+ }
1934
+ // Relevant Files
1935
+ if (analysis.relevantFiles.length > 0) {
1936
+ output.push('## Relevant Files');
1937
+ for (const file of analysis.relevantFiles) {
1938
+ output.push(`### ${file.path}`);
1939
+ output.push(`Relevance Score: ${file.relevance}`);
1940
+ if (file.snippets.length > 0) {
1941
+ output.push('');
1942
+ output.push('Relevant snippets:');
1943
+ for (const snippet of file.snippets.slice(0, 2)) {
1944
+ output.push('```');
1945
+ output.push(snippet);
1946
+ output.push('```');
1947
+ }
1948
+ }
1949
+ output.push('');
1950
+ }
1951
+ }
1952
+ // Code Examples
1953
+ if (analysis.examples.length > 0) {
1954
+ output.push('## Code Examples');
1955
+ for (const example of analysis.examples) {
1956
+ output.push(`### ${example.file}:${example.line}`);
1957
+ output.push(example.explanation);
1958
+ output.push('```');
1959
+ output.push(example.code);
1960
+ output.push('```');
1961
+ output.push('');
1962
+ }
1963
+ }
1964
+ return output.join('\n');
1965
+ }
1966
+ function formatLearningSummary(analysis, format, _focus) {
1967
+ const output = [];
1968
+ const isMarkdown = format === 'markdown';
1969
+ const h1 = (text) => (isMarkdown ? `# ${text}` : text.toUpperCase());
1970
+ const h2 = (text) => (isMarkdown ? `## ${text}` : `\n${text}`);
1971
+ const bullet = isMarkdown ? '-' : '*';
1972
+ output.push(h1('Codebase Learning Summary'));
1973
+ output.push('');
1974
+ // Quick Start
1975
+ output.push(h2('Quick Start'));
1976
+ output.push('');
1977
+ const mainLang = analysis.languages[0];
1978
+ if (mainLang) {
1979
+ output.push(`This is primarily a **${mainLang.language}** project.`);
1980
+ }
1981
+ if (analysis.dependencies.packageManager) {
1982
+ output.push(`Package manager: **${analysis.dependencies.packageManager}**`);
1983
+ }
1984
+ if (analysis.entryPoints.length > 0) {
1985
+ output.push(`Main entry point: \`${analysis.entryPoints[0]}\``);
1986
+ }
1987
+ output.push('');
1988
+ // Architecture Overview
1989
+ output.push(h2('Architecture Overview'));
1990
+ output.push('');
1991
+ output.push(`Architecture Type: **${analysis.architecture.type}**`);
1992
+ if (analysis.architecture.layers.length > 0) {
1993
+ output.push(`Layers: ${analysis.architecture.layers.join(' → ')}`);
1994
+ }
1995
+ for (const flow of analysis.architecture.dataFlow) {
1996
+ output.push(`${bullet} ${flow}`);
1997
+ }
1998
+ output.push('');
1999
+ // Key Concepts
2000
+ output.push(h2('Key Concepts'));
2001
+ output.push('');
2002
+ for (const pattern of analysis.patterns.slice(0, 5)) {
2003
+ output.push(`${bullet} **${pattern.name}**: ${pattern.description}`);
2004
+ }
2005
+ output.push('');
2006
+ // Important Files
2007
+ output.push(h2('Important Files'));
2008
+ output.push('');
2009
+ for (const config of analysis.configFiles.slice(0, 5)) {
2010
+ output.push(`${bullet} \`${config.path}\`: ${config.purpose}`);
2011
+ }
2012
+ if (analysis.entryPoints.length > 0) {
2013
+ output.push('');
2014
+ output.push('Entry points:');
2015
+ for (const entry of analysis.entryPoints) {
2016
+ output.push(`${bullet} \`${entry}\``);
2017
+ }
2018
+ }
2019
+ output.push('');
2020
+ // Directory Guide
2021
+ output.push(h2('Directory Guide'));
2022
+ output.push('');
2023
+ for (const comp of analysis.architecture.components.slice(0, 10)) {
2024
+ output.push(`${bullet} **${comp.name}/** (${comp.type})`);
2025
+ if (comp.responsibilities.length > 0) {
2026
+ output.push(` ${comp.responsibilities.slice(0, 2).join(', ')}`);
2027
+ }
2028
+ }
2029
+ output.push('');
2030
+ // Common Patterns
2031
+ if (analysis.patterns.length > 0) {
2032
+ output.push(h2('Common Patterns'));
2033
+ output.push('');
2034
+ for (const pattern of analysis.patterns.filter((p) => p.confidence === 'high').slice(0, 5)) {
2035
+ output.push(`${bullet} **${pattern.name}**`);
2036
+ for (const evidence of pattern.evidence.slice(0, 2)) {
2037
+ output.push(` ${bullet} ${evidence}`);
2038
+ }
2039
+ }
2040
+ output.push('');
2041
+ }
2042
+ // Development Workflow
2043
+ output.push(h2('Development Workflow'));
2044
+ output.push('');
2045
+ const hasTest = analysis.configFiles.some((c) => c.type === 'testing');
2046
+ const hasLint = analysis.configFiles.some((c) => c.type === 'linting');
2047
+ const hasBundler = analysis.configFiles.some((c) => c.type === 'bundler');
2048
+ if (analysis.dependencies.packageManager === 'npm') {
2049
+ output.push('```bash');
2050
+ output.push('# Install dependencies');
2051
+ output.push('npm install');
2052
+ output.push('');
2053
+ if (hasBundler) {
2054
+ output.push('# Build project');
2055
+ output.push('npm run build');
2056
+ output.push('');
2057
+ }
2058
+ if (hasTest) {
2059
+ output.push('# Run tests');
2060
+ output.push('npm test');
2061
+ output.push('');
2062
+ }
2063
+ if (hasLint) {
2064
+ output.push('# Lint code');
2065
+ output.push('npm run lint');
2066
+ }
2067
+ output.push('```');
2068
+ }
2069
+ else if (analysis.dependencies.packageManager === 'pip') {
2070
+ output.push('```bash');
2071
+ output.push('# Install dependencies');
2072
+ output.push('pip install -e .');
2073
+ output.push('');
2074
+ if (hasTest) {
2075
+ output.push('# Run tests');
2076
+ output.push('pytest');
2077
+ }
2078
+ output.push('```');
2079
+ }
2080
+ output.push('');
2081
+ // Next Steps
2082
+ output.push(h2('Suggested Next Steps'));
2083
+ output.push('');
2084
+ output.push(`1. Read the entry point: \`${analysis.entryPoints[0] || 'index file'}\``);
2085
+ if (analysis.configFiles.some((c) => c.name === 'package.json')) {
2086
+ output.push('2. Review `package.json` for available scripts');
2087
+ }
2088
+ output.push('3. Explore the main directories to understand the structure');
2089
+ if (hasTest) {
2090
+ output.push('4. Run the test suite to verify setup');
2091
+ }
2092
+ output.push('5. Use `learn_topic` to explore specific features');
2093
+ return output.join('\n');
2094
+ }
2095
+ // =====================================================
2096
+ // Utilities
2097
+ // =====================================================
2098
+ function resolveFilePath(workingDir, path) {
2099
+ const normalized = path.trim();
2100
+ return normalized.startsWith('/') ? normalized : join(workingDir, normalized);
2101
+ }
2102
+ //# sourceMappingURL=learnTools.js.map