deepseek-coder-agent-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/README.md +58 -0
  2. package/dist/bin/cliMode.d.ts +8 -0
  3. package/dist/bin/cliMode.d.ts.map +1 -0
  4. package/dist/bin/cliMode.js +20 -0
  5. package/dist/bin/cliMode.js.map +1 -0
  6. package/dist/bin/deepseek.d.ts +6 -0
  7. package/dist/bin/deepseek.d.ts.map +1 -0
  8. package/dist/bin/deepseek.js +136 -0
  9. package/dist/bin/deepseek.js.map +1 -0
  10. package/dist/config.d.ts +25 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +155 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/contracts/agent-profiles.schema.json +43 -0
  15. package/dist/contracts/agent-schemas.json +460 -0
  16. package/dist/contracts/models.schema.json +9 -0
  17. package/dist/contracts/module-schema.json +419 -0
  18. package/dist/contracts/schemas/agent-profile.schema.json +157 -0
  19. package/dist/contracts/schemas/agent-rules.schema.json +238 -0
  20. package/dist/contracts/schemas/agent-schemas.schema.json +528 -0
  21. package/dist/contracts/schemas/agent.schema.json +90 -0
  22. package/dist/contracts/schemas/tool-selection.schema.json +174 -0
  23. package/dist/contracts/tools.schema.json +82 -0
  24. package/dist/contracts/unified-schema.json +750 -0
  25. package/dist/contracts/v1/agent.d.ts +179 -0
  26. package/dist/contracts/v1/agent.d.ts.map +1 -0
  27. package/dist/contracts/v1/agent.js +8 -0
  28. package/dist/contracts/v1/agent.js.map +1 -0
  29. package/dist/contracts/v1/agentProfileManifest.d.ts +60 -0
  30. package/dist/contracts/v1/agentProfileManifest.d.ts.map +1 -0
  31. package/dist/contracts/v1/agentProfileManifest.js +9 -0
  32. package/dist/contracts/v1/agentProfileManifest.js.map +1 -0
  33. package/dist/contracts/v1/agentRules.d.ts +60 -0
  34. package/dist/contracts/v1/agentRules.d.ts.map +1 -0
  35. package/dist/contracts/v1/agentRules.js +10 -0
  36. package/dist/contracts/v1/agentRules.js.map +1 -0
  37. package/dist/contracts/v1/provider.d.ts +149 -0
  38. package/dist/contracts/v1/provider.d.ts.map +1 -0
  39. package/dist/contracts/v1/provider.js +7 -0
  40. package/dist/contracts/v1/provider.js.map +1 -0
  41. package/dist/contracts/v1/tool.d.ts +136 -0
  42. package/dist/contracts/v1/tool.d.ts.map +1 -0
  43. package/dist/contracts/v1/tool.js +7 -0
  44. package/dist/contracts/v1/tool.js.map +1 -0
  45. package/dist/contracts/v1/toolAccess.d.ts +43 -0
  46. package/dist/contracts/v1/toolAccess.d.ts.map +1 -0
  47. package/dist/contracts/v1/toolAccess.js +9 -0
  48. package/dist/contracts/v1/toolAccess.js.map +1 -0
  49. package/dist/core/agent.d.ts +287 -0
  50. package/dist/core/agent.d.ts.map +1 -0
  51. package/dist/core/agent.js +1563 -0
  52. package/dist/core/agent.js.map +1 -0
  53. package/dist/core/agentProfileManifest.d.ts +3 -0
  54. package/dist/core/agentProfileManifest.d.ts.map +1 -0
  55. package/dist/core/agentProfileManifest.js +188 -0
  56. package/dist/core/agentProfileManifest.js.map +1 -0
  57. package/dist/core/agentProfiles.d.ts +22 -0
  58. package/dist/core/agentProfiles.d.ts.map +1 -0
  59. package/dist/core/agentProfiles.js +35 -0
  60. package/dist/core/agentProfiles.js.map +1 -0
  61. package/dist/core/agentRulebook.d.ts +11 -0
  62. package/dist/core/agentRulebook.d.ts.map +1 -0
  63. package/dist/core/agentRulebook.js +136 -0
  64. package/dist/core/agentRulebook.js.map +1 -0
  65. package/dist/core/agentSchemaLoader.d.ts +131 -0
  66. package/dist/core/agentSchemaLoader.d.ts.map +1 -0
  67. package/dist/core/agentSchemaLoader.js +235 -0
  68. package/dist/core/agentSchemaLoader.js.map +1 -0
  69. package/dist/core/agiCore.d.ts +290 -0
  70. package/dist/core/agiCore.d.ts.map +1 -0
  71. package/dist/core/agiCore.js +1348 -0
  72. package/dist/core/agiCore.js.map +1 -0
  73. package/dist/core/aiErrorFixer.d.ts +57 -0
  74. package/dist/core/aiErrorFixer.d.ts.map +1 -0
  75. package/dist/core/aiErrorFixer.js +214 -0
  76. package/dist/core/aiErrorFixer.js.map +1 -0
  77. package/dist/core/antiTermination.d.ts +226 -0
  78. package/dist/core/antiTermination.d.ts.map +1 -0
  79. package/dist/core/antiTermination.js +713 -0
  80. package/dist/core/antiTermination.js.map +1 -0
  81. package/dist/core/bashCommandGuidance.d.ts +16 -0
  82. package/dist/core/bashCommandGuidance.d.ts.map +1 -0
  83. package/dist/core/bashCommandGuidance.js +40 -0
  84. package/dist/core/bashCommandGuidance.js.map +1 -0
  85. package/dist/core/constants.d.ts +31 -0
  86. package/dist/core/constants.d.ts.map +1 -0
  87. package/dist/core/constants.js +62 -0
  88. package/dist/core/constants.js.map +1 -0
  89. package/dist/core/contextManager.d.ts +271 -0
  90. package/dist/core/contextManager.d.ts.map +1 -0
  91. package/dist/core/contextManager.js +1073 -0
  92. package/dist/core/contextManager.js.map +1 -0
  93. package/dist/core/contextWindow.d.ts +42 -0
  94. package/dist/core/contextWindow.d.ts.map +1 -0
  95. package/dist/core/contextWindow.js +123 -0
  96. package/dist/core/contextWindow.js.map +1 -0
  97. package/dist/core/customCommands.d.ts +19 -0
  98. package/dist/core/customCommands.d.ts.map +1 -0
  99. package/dist/core/customCommands.js +85 -0
  100. package/dist/core/customCommands.js.map +1 -0
  101. package/dist/core/deepBugAnalyzer.d.ts +25 -0
  102. package/dist/core/deepBugAnalyzer.d.ts.map +1 -0
  103. package/dist/core/deepBugAnalyzer.js +44 -0
  104. package/dist/core/deepBugAnalyzer.js.map +1 -0
  105. package/dist/core/dualTournament.d.ts +110 -0
  106. package/dist/core/dualTournament.d.ts.map +1 -0
  107. package/dist/core/dualTournament.js +270 -0
  108. package/dist/core/dualTournament.js.map +1 -0
  109. package/dist/core/dynamicGuardrails.d.ts +207 -0
  110. package/dist/core/dynamicGuardrails.d.ts.map +1 -0
  111. package/dist/core/dynamicGuardrails.js +516 -0
  112. package/dist/core/dynamicGuardrails.js.map +1 -0
  113. package/dist/core/embeddingProviders.d.ts +80 -0
  114. package/dist/core/embeddingProviders.d.ts.map +1 -0
  115. package/dist/core/embeddingProviders.js +241 -0
  116. package/dist/core/embeddingProviders.js.map +1 -0
  117. package/dist/core/episodicMemory.d.ts +259 -0
  118. package/dist/core/episodicMemory.d.ts.map +1 -0
  119. package/dist/core/episodicMemory.js +833 -0
  120. package/dist/core/episodicMemory.js.map +1 -0
  121. package/dist/core/errors/apiKeyErrors.d.ts +11 -0
  122. package/dist/core/errors/apiKeyErrors.d.ts.map +1 -0
  123. package/dist/core/errors/apiKeyErrors.js +159 -0
  124. package/dist/core/errors/apiKeyErrors.js.map +1 -0
  125. package/dist/core/errors/errorTypes.d.ts +111 -0
  126. package/dist/core/errors/errorTypes.d.ts.map +1 -0
  127. package/dist/core/errors/errorTypes.js +345 -0
  128. package/dist/core/errors/errorTypes.js.map +1 -0
  129. package/dist/core/errors/index.d.ts +50 -0
  130. package/dist/core/errors/index.d.ts.map +1 -0
  131. package/dist/core/errors/index.js +156 -0
  132. package/dist/core/errors/index.js.map +1 -0
  133. package/dist/core/errors/networkErrors.d.ts +14 -0
  134. package/dist/core/errors/networkErrors.d.ts.map +1 -0
  135. package/dist/core/errors/networkErrors.js +53 -0
  136. package/dist/core/errors/networkErrors.js.map +1 -0
  137. package/dist/core/errors/safetyValidator.d.ts +115 -0
  138. package/dist/core/errors/safetyValidator.d.ts.map +1 -0
  139. package/dist/core/errors/safetyValidator.js +302 -0
  140. package/dist/core/errors/safetyValidator.js.map +1 -0
  141. package/dist/core/errors.d.ts +4 -0
  142. package/dist/core/errors.d.ts.map +1 -0
  143. package/dist/core/errors.js +33 -0
  144. package/dist/core/errors.js.map +1 -0
  145. package/dist/core/finalResponseFormatter.d.ts +10 -0
  146. package/dist/core/finalResponseFormatter.d.ts.map +1 -0
  147. package/dist/core/finalResponseFormatter.js +14 -0
  148. package/dist/core/finalResponseFormatter.js.map +1 -0
  149. package/dist/core/flowProtection.d.ts +154 -0
  150. package/dist/core/flowProtection.d.ts.map +1 -0
  151. package/dist/core/flowProtection.js +436 -0
  152. package/dist/core/flowProtection.js.map +1 -0
  153. package/dist/core/gitWorktreeManager.d.ts +126 -0
  154. package/dist/core/gitWorktreeManager.d.ts.map +1 -0
  155. package/dist/core/gitWorktreeManager.js +403 -0
  156. package/dist/core/gitWorktreeManager.js.map +1 -0
  157. package/dist/core/guardrails.d.ts +150 -0
  158. package/dist/core/guardrails.d.ts.map +1 -0
  159. package/dist/core/guardrails.js +360 -0
  160. package/dist/core/guardrails.js.map +1 -0
  161. package/dist/core/hallucinationGuard.d.ts +57 -0
  162. package/dist/core/hallucinationGuard.d.ts.map +1 -0
  163. package/dist/core/hallucinationGuard.js +237 -0
  164. package/dist/core/hallucinationGuard.js.map +1 -0
  165. package/dist/core/hitlEnforcement.d.ts +143 -0
  166. package/dist/core/hitlEnforcement.d.ts.map +1 -0
  167. package/dist/core/hitlEnforcement.js +583 -0
  168. package/dist/core/hitlEnforcement.js.map +1 -0
  169. package/dist/core/hooks.d.ts +113 -0
  170. package/dist/core/hooks.d.ts.map +1 -0
  171. package/dist/core/hooks.js +364 -0
  172. package/dist/core/hooks.js.map +1 -0
  173. package/dist/core/hotReload.d.ts +154 -0
  174. package/dist/core/hotReload.d.ts.map +1 -0
  175. package/dist/core/hotReload.js +451 -0
  176. package/dist/core/hotReload.js.map +1 -0
  177. package/dist/core/hypothesisEngine.d.ts +27 -0
  178. package/dist/core/hypothesisEngine.d.ts.map +1 -0
  179. package/dist/core/hypothesisEngine.js +58 -0
  180. package/dist/core/hypothesisEngine.js.map +1 -0
  181. package/dist/core/index.d.ts +26 -0
  182. package/dist/core/index.d.ts.map +1 -0
  183. package/dist/core/index.js +54 -0
  184. package/dist/core/index.js.map +1 -0
  185. package/dist/core/inputProtection.d.ts +122 -0
  186. package/dist/core/inputProtection.d.ts.map +1 -0
  187. package/dist/core/inputProtection.js +421 -0
  188. package/dist/core/inputProtection.js.map +1 -0
  189. package/dist/core/liveGCPVerification.d.ts +41 -0
  190. package/dist/core/liveGCPVerification.d.ts.map +1 -0
  191. package/dist/core/liveGCPVerification.js +745 -0
  192. package/dist/core/liveGCPVerification.js.map +1 -0
  193. package/dist/core/modelDiscovery.d.ts +105 -0
  194. package/dist/core/modelDiscovery.d.ts.map +1 -0
  195. package/dist/core/modelDiscovery.js +740 -0
  196. package/dist/core/modelDiscovery.js.map +1 -0
  197. package/dist/core/multilinePasteHandler.d.ts +35 -0
  198. package/dist/core/multilinePasteHandler.d.ts.map +1 -0
  199. package/dist/core/multilinePasteHandler.js +80 -0
  200. package/dist/core/multilinePasteHandler.js.map +1 -0
  201. package/dist/core/parallel.d.ts +85 -0
  202. package/dist/core/parallel.d.ts.map +1 -0
  203. package/dist/core/parallel.js +150 -0
  204. package/dist/core/parallel.js.map +1 -0
  205. package/dist/core/parallelCoordinator.d.ts +21 -0
  206. package/dist/core/parallelCoordinator.d.ts.map +1 -0
  207. package/dist/core/parallelCoordinator.js +42 -0
  208. package/dist/core/parallelCoordinator.js.map +1 -0
  209. package/dist/core/parallelExecutor.d.ts +215 -0
  210. package/dist/core/parallelExecutor.d.ts.map +1 -0
  211. package/dist/core/parallelExecutor.js +584 -0
  212. package/dist/core/parallelExecutor.js.map +1 -0
  213. package/dist/core/platformSecurityIntegration.d.ts +133 -0
  214. package/dist/core/platformSecurityIntegration.d.ts.map +1 -0
  215. package/dist/core/platformSecurityIntegration.js +419 -0
  216. package/dist/core/platformSecurityIntegration.js.map +1 -0
  217. package/dist/core/preferences.d.ts +71 -0
  218. package/dist/core/preferences.d.ts.map +1 -0
  219. package/dist/core/preferences.js +341 -0
  220. package/dist/core/preferences.js.map +1 -0
  221. package/dist/core/productTestHarness.d.ts +46 -0
  222. package/dist/core/productTestHarness.d.ts.map +1 -0
  223. package/dist/core/productTestHarness.js +128 -0
  224. package/dist/core/productTestHarness.js.map +1 -0
  225. package/dist/core/providerKeys.d.ts +20 -0
  226. package/dist/core/providerKeys.d.ts.map +1 -0
  227. package/dist/core/providerKeys.js +40 -0
  228. package/dist/core/providerKeys.js.map +1 -0
  229. package/dist/core/realityScore.d.ts +159 -0
  230. package/dist/core/realityScore.d.ts.map +1 -0
  231. package/dist/core/realityScore.js +734 -0
  232. package/dist/core/realityScore.js.map +1 -0
  233. package/dist/core/repoUpgradeOrchestrator.d.ts +223 -0
  234. package/dist/core/repoUpgradeOrchestrator.d.ts.map +1 -0
  235. package/dist/core/repoUpgradeOrchestrator.js +1003 -0
  236. package/dist/core/repoUpgradeOrchestrator.js.map +1 -0
  237. package/dist/core/resultVerification.d.ts +47 -0
  238. package/dist/core/resultVerification.d.ts.map +1 -0
  239. package/dist/core/resultVerification.js +126 -0
  240. package/dist/core/resultVerification.js.map +1 -0
  241. package/dist/core/revenueEnvValidator.d.ts +30 -0
  242. package/dist/core/revenueEnvValidator.d.ts.map +1 -0
  243. package/dist/core/revenueEnvValidator.js +241 -0
  244. package/dist/core/revenueEnvValidator.js.map +1 -0
  245. package/dist/core/schemaValidator.d.ts +49 -0
  246. package/dist/core/schemaValidator.d.ts.map +1 -0
  247. package/dist/core/schemaValidator.js +234 -0
  248. package/dist/core/schemaValidator.js.map +1 -0
  249. package/dist/core/secretStore.d.ts +48 -0
  250. package/dist/core/secretStore.d.ts.map +1 -0
  251. package/dist/core/secretStore.js +295 -0
  252. package/dist/core/secretStore.js.map +1 -0
  253. package/dist/core/securityTournament.d.ts +83 -0
  254. package/dist/core/securityTournament.d.ts.map +1 -0
  255. package/dist/core/securityTournament.js +357 -0
  256. package/dist/core/securityTournament.js.map +1 -0
  257. package/dist/core/selfUpgrade.d.ts +253 -0
  258. package/dist/core/selfUpgrade.d.ts.map +1 -0
  259. package/dist/core/selfUpgrade.js +669 -0
  260. package/dist/core/selfUpgrade.js.map +1 -0
  261. package/dist/core/sessionStorage.d.ts +10 -0
  262. package/dist/core/sessionStorage.d.ts.map +1 -0
  263. package/dist/core/sessionStorage.js +46 -0
  264. package/dist/core/sessionStorage.js.map +1 -0
  265. package/dist/core/sessionStore.d.ts +35 -0
  266. package/dist/core/sessionStore.d.ts.map +1 -0
  267. package/dist/core/sessionStore.js +191 -0
  268. package/dist/core/sessionStore.js.map +1 -0
  269. package/dist/core/taskCompletionDetector.d.ts +112 -0
  270. package/dist/core/taskCompletionDetector.d.ts.map +1 -0
  271. package/dist/core/taskCompletionDetector.js +469 -0
  272. package/dist/core/taskCompletionDetector.js.map +1 -0
  273. package/dist/core/toolPreconditions.d.ts +34 -0
  274. package/dist/core/toolPreconditions.d.ts.map +1 -0
  275. package/dist/core/toolPreconditions.js +242 -0
  276. package/dist/core/toolPreconditions.js.map +1 -0
  277. package/dist/core/toolRuntime.d.ts +185 -0
  278. package/dist/core/toolRuntime.d.ts.map +1 -0
  279. package/dist/core/toolRuntime.js +412 -0
  280. package/dist/core/toolRuntime.js.map +1 -0
  281. package/dist/core/tournamentStrategy.d.ts +12 -0
  282. package/dist/core/tournamentStrategy.d.ts.map +1 -0
  283. package/dist/core/tournamentStrategy.js +41 -0
  284. package/dist/core/tournamentStrategy.js.map +1 -0
  285. package/dist/core/types/utilityTypes.d.ts +192 -0
  286. package/dist/core/types/utilityTypes.d.ts.map +1 -0
  287. package/dist/core/types/utilityTypes.js +272 -0
  288. package/dist/core/types/utilityTypes.js.map +1 -0
  289. package/dist/core/types.d.ts +334 -0
  290. package/dist/core/types.d.ts.map +1 -0
  291. package/dist/core/types.js +76 -0
  292. package/dist/core/types.js.map +1 -0
  293. package/dist/core/unifiedOrchestrator.d.ts +47 -0
  294. package/dist/core/unifiedOrchestrator.d.ts.map +1 -0
  295. package/dist/core/unifiedOrchestrator.js +103 -0
  296. package/dist/core/unifiedOrchestrator.js.map +1 -0
  297. package/dist/core/universalSecurityAudit.d.ts +104 -0
  298. package/dist/core/universalSecurityAudit.d.ts.map +1 -0
  299. package/dist/core/universalSecurityAudit.js +2190 -0
  300. package/dist/core/universalSecurityAudit.js.map +1 -0
  301. package/dist/core/updateChecker.d.ts +148 -0
  302. package/dist/core/updateChecker.d.ts.map +1 -0
  303. package/dist/core/updateChecker.js +593 -0
  304. package/dist/core/updateChecker.js.map +1 -0
  305. package/dist/core/variantExecution.d.ts +23 -0
  306. package/dist/core/variantExecution.d.ts.map +1 -0
  307. package/dist/core/variantExecution.js +58 -0
  308. package/dist/core/variantExecution.js.map +1 -0
  309. package/dist/core/verificationFirst.d.ts +110 -0
  310. package/dist/core/verificationFirst.d.ts.map +1 -0
  311. package/dist/core/verificationFirst.js +312 -0
  312. package/dist/core/verificationFirst.js.map +1 -0
  313. package/dist/core/winnerStrategy.d.ts +15 -0
  314. package/dist/core/winnerStrategy.d.ts.map +1 -0
  315. package/dist/core/winnerStrategy.js +18 -0
  316. package/dist/core/winnerStrategy.js.map +1 -0
  317. package/dist/core/zeroDayDiscovery.d.ts +96 -0
  318. package/dist/core/zeroDayDiscovery.d.ts.map +1 -0
  319. package/dist/core/zeroDayDiscovery.js +358 -0
  320. package/dist/core/zeroDayDiscovery.js.map +1 -0
  321. package/dist/headless/interactiveShell.d.ts +22 -0
  322. package/dist/headless/interactiveShell.d.ts.map +1 -0
  323. package/dist/headless/interactiveShell.js +3832 -0
  324. package/dist/headless/interactiveShell.js.map +1 -0
  325. package/dist/headless/quickMode.d.ts +26 -0
  326. package/dist/headless/quickMode.d.ts.map +1 -0
  327. package/dist/headless/quickMode.js +226 -0
  328. package/dist/headless/quickMode.js.map +1 -0
  329. package/dist/providers/baseProvider.d.ts +148 -0
  330. package/dist/providers/baseProvider.d.ts.map +1 -0
  331. package/dist/providers/baseProvider.js +284 -0
  332. package/dist/providers/baseProvider.js.map +1 -0
  333. package/dist/providers/deepseekReasonerProvider.d.ts +57 -0
  334. package/dist/providers/deepseekReasonerProvider.d.ts.map +1 -0
  335. package/dist/providers/deepseekReasonerProvider.js +87 -0
  336. package/dist/providers/deepseekReasonerProvider.js.map +1 -0
  337. package/dist/providers/openaiChatCompletionsProvider.d.ts +64 -0
  338. package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
  339. package/dist/providers/openaiChatCompletionsProvider.js +1000 -0
  340. package/dist/providers/openaiChatCompletionsProvider.js.map +1 -0
  341. package/dist/providers/providerFactory.d.ts +24 -0
  342. package/dist/providers/providerFactory.d.ts.map +1 -0
  343. package/dist/providers/providerFactory.js +27 -0
  344. package/dist/providers/providerFactory.js.map +1 -0
  345. package/dist/providers/resilientProvider.d.ts +103 -0
  346. package/dist/providers/resilientProvider.d.ts.map +1 -0
  347. package/dist/providers/resilientProvider.js +462 -0
  348. package/dist/providers/resilientProvider.js.map +1 -0
  349. package/dist/runtime/agentController.d.ts +114 -0
  350. package/dist/runtime/agentController.d.ts.map +1 -0
  351. package/dist/runtime/agentController.js +693 -0
  352. package/dist/runtime/agentController.js.map +1 -0
  353. package/dist/runtime/agentHost.d.ts +61 -0
  354. package/dist/runtime/agentHost.d.ts.map +1 -0
  355. package/dist/runtime/agentHost.js +157 -0
  356. package/dist/runtime/agentHost.js.map +1 -0
  357. package/dist/runtime/agentSession.d.ts +45 -0
  358. package/dist/runtime/agentSession.d.ts.map +1 -0
  359. package/dist/runtime/agentSession.js +214 -0
  360. package/dist/runtime/agentSession.js.map +1 -0
  361. package/dist/runtime/agentWorkerPool.d.ts +167 -0
  362. package/dist/runtime/agentWorkerPool.d.ts.map +1 -0
  363. package/dist/runtime/agentWorkerPool.js +435 -0
  364. package/dist/runtime/agentWorkerPool.js.map +1 -0
  365. package/dist/runtime/node.d.ts +7 -0
  366. package/dist/runtime/node.d.ts.map +1 -0
  367. package/dist/runtime/node.js +18 -0
  368. package/dist/runtime/node.js.map +1 -0
  369. package/dist/runtime/universal.d.ts +18 -0
  370. package/dist/runtime/universal.d.ts.map +1 -0
  371. package/dist/runtime/universal.js +21 -0
  372. package/dist/runtime/universal.js.map +1 -0
  373. package/dist/ui/PromptController.d.ts +174 -0
  374. package/dist/ui/PromptController.d.ts.map +1 -0
  375. package/dist/ui/PromptController.js +351 -0
  376. package/dist/ui/PromptController.js.map +1 -0
  377. package/dist/ui/UnifiedUIRenderer.d.ts +779 -0
  378. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -0
  379. package/dist/ui/UnifiedUIRenderer.js +5458 -0
  380. package/dist/ui/UnifiedUIRenderer.js.map +1 -0
  381. package/dist/ui/animatedStatus.d.ts +140 -0
  382. package/dist/ui/animatedStatus.d.ts.map +1 -0
  383. package/dist/ui/animatedStatus.js +480 -0
  384. package/dist/ui/animatedStatus.js.map +1 -0
  385. package/dist/ui/animation/AnimationScheduler.d.ts +197 -0
  386. package/dist/ui/animation/AnimationScheduler.d.ts.map +1 -0
  387. package/dist/ui/animation/AnimationScheduler.js +440 -0
  388. package/dist/ui/animation/AnimationScheduler.js.map +1 -0
  389. package/dist/ui/codeHighlighter.d.ts +6 -0
  390. package/dist/ui/codeHighlighter.d.ts.map +1 -0
  391. package/dist/ui/codeHighlighter.js +855 -0
  392. package/dist/ui/codeHighlighter.js.map +1 -0
  393. package/dist/ui/designSystem.d.ts +26 -0
  394. package/dist/ui/designSystem.d.ts.map +1 -0
  395. package/dist/ui/designSystem.js +114 -0
  396. package/dist/ui/designSystem.js.map +1 -0
  397. package/dist/ui/errorFormatter.d.ts +64 -0
  398. package/dist/ui/errorFormatter.d.ts.map +1 -0
  399. package/dist/ui/errorFormatter.js +316 -0
  400. package/dist/ui/errorFormatter.js.map +1 -0
  401. package/dist/ui/globalWriteLock.d.ts +63 -0
  402. package/dist/ui/globalWriteLock.d.ts.map +1 -0
  403. package/dist/ui/globalWriteLock.js +173 -0
  404. package/dist/ui/globalWriteLock.js.map +1 -0
  405. package/dist/ui/index.d.ts +32 -0
  406. package/dist/ui/index.d.ts.map +1 -0
  407. package/dist/ui/index.js +54 -0
  408. package/dist/ui/index.js.map +1 -0
  409. package/dist/ui/interrupts/InterruptManager.d.ts +157 -0
  410. package/dist/ui/interrupts/InterruptManager.d.ts.map +1 -0
  411. package/dist/ui/interrupts/InterruptManager.js +501 -0
  412. package/dist/ui/interrupts/InterruptManager.js.map +1 -0
  413. package/dist/ui/layout.d.ts +27 -0
  414. package/dist/ui/layout.d.ts.map +1 -0
  415. package/dist/ui/layout.js +184 -0
  416. package/dist/ui/layout.js.map +1 -0
  417. package/dist/ui/maxOffensiveUkraineUI.d.ts +94 -0
  418. package/dist/ui/maxOffensiveUkraineUI.d.ts.map +1 -0
  419. package/dist/ui/maxOffensiveUkraineUI.js +316 -0
  420. package/dist/ui/maxOffensiveUkraineUI.js.map +1 -0
  421. package/dist/ui/outputMode.d.ts +44 -0
  422. package/dist/ui/outputMode.d.ts.map +1 -0
  423. package/dist/ui/outputMode.js +123 -0
  424. package/dist/ui/outputMode.js.map +1 -0
  425. package/dist/ui/overlay/OverlayManager.d.ts +105 -0
  426. package/dist/ui/overlay/OverlayManager.d.ts.map +1 -0
  427. package/dist/ui/overlay/OverlayManager.js +291 -0
  428. package/dist/ui/overlay/OverlayManager.js.map +1 -0
  429. package/dist/ui/premiumComponents.d.ts +54 -0
  430. package/dist/ui/premiumComponents.d.ts.map +1 -0
  431. package/dist/ui/premiumComponents.js +241 -0
  432. package/dist/ui/premiumComponents.js.map +1 -0
  433. package/dist/ui/richText.d.ts +13 -0
  434. package/dist/ui/richText.d.ts.map +1 -0
  435. package/dist/ui/richText.js +444 -0
  436. package/dist/ui/richText.js.map +1 -0
  437. package/dist/ui/telemetry/ResponseTracker.d.ts +22 -0
  438. package/dist/ui/telemetry/ResponseTracker.d.ts.map +1 -0
  439. package/dist/ui/telemetry/ResponseTracker.js +60 -0
  440. package/dist/ui/telemetry/ResponseTracker.js.map +1 -0
  441. package/dist/ui/telemetry/UITelemetry.d.ts +181 -0
  442. package/dist/ui/telemetry/UITelemetry.d.ts.map +1 -0
  443. package/dist/ui/telemetry/UITelemetry.js +446 -0
  444. package/dist/ui/telemetry/UITelemetry.js.map +1 -0
  445. package/dist/ui/textHighlighter.d.ts +83 -0
  446. package/dist/ui/textHighlighter.d.ts.map +1 -0
  447. package/dist/ui/textHighlighter.js +267 -0
  448. package/dist/ui/textHighlighter.js.map +1 -0
  449. package/dist/ui/theme.d.ts +364 -0
  450. package/dist/ui/theme.d.ts.map +1 -0
  451. package/dist/ui/theme.js +471 -0
  452. package/dist/ui/theme.js.map +1 -0
  453. package/dist/ui/toolDisplay.d.ts +221 -0
  454. package/dist/ui/toolDisplay.d.ts.map +1 -0
  455. package/dist/ui/toolDisplay.js +1654 -0
  456. package/dist/ui/toolDisplay.js.map +1 -0
  457. package/dist/ui/uiConstants.d.ts +288 -0
  458. package/dist/ui/uiConstants.d.ts.map +1 -0
  459. package/dist/ui/uiConstants.js +472 -0
  460. package/dist/ui/uiConstants.js.map +1 -0
  461. package/dist/utils/askUserPrompt.d.ts +21 -0
  462. package/dist/utils/askUserPrompt.d.ts.map +1 -0
  463. package/dist/utils/askUserPrompt.js +87 -0
  464. package/dist/utils/askUserPrompt.js.map +1 -0
  465. package/dist/utils/asyncUtils.d.ts +95 -0
  466. package/dist/utils/asyncUtils.d.ts.map +1 -0
  467. package/dist/utils/asyncUtils.js +286 -0
  468. package/dist/utils/asyncUtils.js.map +1 -0
  469. package/dist/utils/debugLogger.d.ts +6 -0
  470. package/dist/utils/debugLogger.d.ts.map +1 -0
  471. package/dist/utils/debugLogger.js +39 -0
  472. package/dist/utils/debugLogger.js.map +1 -0
  473. package/dist/utils/errorUtils.d.ts +12 -0
  474. package/dist/utils/errorUtils.d.ts.map +1 -0
  475. package/dist/utils/errorUtils.js +83 -0
  476. package/dist/utils/errorUtils.js.map +1 -0
  477. package/dist/utils/frontmatter.d.ts +10 -0
  478. package/dist/utils/frontmatter.d.ts.map +1 -0
  479. package/dist/utils/frontmatter.js +78 -0
  480. package/dist/utils/frontmatter.js.map +1 -0
  481. package/dist/utils/packageInfo.d.ts +14 -0
  482. package/dist/utils/packageInfo.d.ts.map +1 -0
  483. package/dist/utils/packageInfo.js +45 -0
  484. package/dist/utils/packageInfo.js.map +1 -0
  485. package/dist/utils/planFormatter.d.ts +34 -0
  486. package/dist/utils/planFormatter.d.ts.map +1 -0
  487. package/dist/utils/planFormatter.js +141 -0
  488. package/dist/utils/planFormatter.js.map +1 -0
  489. package/dist/utils/securityUtils.d.ts +132 -0
  490. package/dist/utils/securityUtils.d.ts.map +1 -0
  491. package/dist/utils/securityUtils.js +324 -0
  492. package/dist/utils/securityUtils.js.map +1 -0
  493. package/dist/workspace.d.ts +8 -0
  494. package/dist/workspace.d.ts.map +1 -0
  495. package/dist/workspace.js +134 -0
  496. package/dist/workspace.js.map +1 -0
  497. package/dist/workspace.validator.d.ts +49 -0
  498. package/dist/workspace.validator.d.ts.map +1 -0
  499. package/dist/workspace.validator.js +215 -0
  500. package/dist/workspace.validator.js.map +1 -0
  501. package/package.json +60 -0
@@ -0,0 +1,1348 @@
1
+ /**
2
+ * AGI Core - Unified Autonomous General Intelligence for Software Engineering
3
+ *
4
+ * This is the central intelligence module that provides:
5
+ * 1. Unified prompt understanding and routing
6
+ * 2. Real task decomposition and planning
7
+ * 3. Persistent learning and memory
8
+ * 4. Autonomous execution with verification
9
+ *
10
+ * NO SIMULATIONS - All operations execute real tools
11
+ */
12
+ import * as fs from 'fs';
13
+ import * as path from 'path';
14
+ import { EventEmitter } from 'events';
15
+ import { getEpisodicMemory } from './episodicMemory.js';
16
+ import { getSelfUpgrade, SelfUpgrade } from './selfUpgrade.js';
17
+ import { getHotReload } from './hotReload.js';
18
+ // ============================================================================
19
+ // AGI CORE CLASS
20
+ // ============================================================================
21
+ export class AGICore extends EventEmitter {
22
+ context;
23
+ memoryPath;
24
+ episodicMemory;
25
+ currentEpisodeId = null;
26
+ selfUpgrade;
27
+ hotReload;
28
+ upgradeCheckPromise = null;
29
+ constructor(workingDir) {
30
+ super();
31
+ const dir = workingDir || process.cwd();
32
+ this.memoryPath = path.join(dir, '.agi', 'agi-memory.json');
33
+ this.context = {
34
+ workingDir: dir,
35
+ sessionId: `agi-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
36
+ startTime: Date.now(),
37
+ memory: this.loadMemory(),
38
+ };
39
+ // Initialize episodic memory system
40
+ this.episodicMemory = getEpisodicMemory();
41
+ // Initialize self-upgrade system
42
+ this.selfUpgrade = getSelfUpgrade({
43
+ workingDir: dir,
44
+ autoRestart: true,
45
+ logger: (msg) => this.emit('upgrade:log', msg),
46
+ });
47
+ // Initialize hot-reload system
48
+ this.hotReload = getHotReload({
49
+ workingDir: dir,
50
+ autoCheck: true,
51
+ checkInterval: 5 * 60 * 1000, // Check every 5 minutes
52
+ logger: (msg) => this.emit('hotReload:log', msg),
53
+ });
54
+ // Forward upgrade events
55
+ this.selfUpgrade.on('upgrade', (event) => this.emit('upgrade', event));
56
+ this.hotReload.on('hotReload', (event) => this.emit('hotReload', event));
57
+ // Check for upgrade on initialization (non-blocking)
58
+ this.upgradeCheckPromise = this.checkForUpgradeOnStart();
59
+ // Analyze project on initialization
60
+ this.analyzeProject();
61
+ }
62
+ /**
63
+ * Non-blocking upgrade check on startup
64
+ */
65
+ async checkForUpgradeOnStart() {
66
+ try {
67
+ const versionInfo = await this.selfUpgrade.checkForUpdates();
68
+ if (versionInfo.updateAvailable) {
69
+ this.emit('upgrade:available', {
70
+ current: versionInfo.current,
71
+ latest: versionInfo.latest,
72
+ });
73
+ }
74
+ }
75
+ catch {
76
+ // Non-blocking, ignore errors
77
+ }
78
+ }
79
+ // ==========================================================================
80
+ // MEMORY MANAGEMENT - Real Persistent Learning
81
+ // ==========================================================================
82
+ loadMemory() {
83
+ try {
84
+ if (fs.existsSync(this.memoryPath)) {
85
+ const data = fs.readFileSync(this.memoryPath, 'utf-8');
86
+ return JSON.parse(data);
87
+ }
88
+ }
89
+ catch {
90
+ // Start fresh if memory is corrupted
91
+ }
92
+ return this.createEmptyMemory();
93
+ }
94
+ createEmptyMemory() {
95
+ return {
96
+ patterns: [],
97
+ recentOps: [],
98
+ projectKnowledge: {
99
+ type: 'unknown',
100
+ buildSystem: null,
101
+ testCommand: null,
102
+ lintCommand: null,
103
+ entryPoints: [],
104
+ dependencies: {},
105
+ lastAnalyzed: 0,
106
+ },
107
+ };
108
+ }
109
+ saveMemory() {
110
+ try {
111
+ const dir = path.dirname(this.memoryPath);
112
+ if (!fs.existsSync(dir)) {
113
+ fs.mkdirSync(dir, { recursive: true });
114
+ }
115
+ fs.writeFileSync(this.memoryPath, JSON.stringify(this.context.memory, null, 2));
116
+ }
117
+ catch (error) {
118
+ this.emit('warning', `Failed to save memory: ${error}`);
119
+ }
120
+ }
121
+ /**
122
+ * Learn from a successful operation
123
+ */
124
+ learnFromSuccess(prompt, approach, tools) {
125
+ const existingPattern = this.context.memory.patterns.find(p => this.normalizePrompt(p.trigger) === this.normalizePrompt(prompt));
126
+ if (existingPattern) {
127
+ existingPattern.successCount++;
128
+ existingPattern.lastUsed = Date.now();
129
+ existingPattern.successfulApproach = approach;
130
+ existingPattern.tools = tools;
131
+ }
132
+ else {
133
+ this.context.memory.patterns.push({
134
+ id: `pattern-${Date.now()}`,
135
+ trigger: prompt,
136
+ successfulApproach: approach,
137
+ tools,
138
+ successCount: 1,
139
+ lastUsed: Date.now(),
140
+ });
141
+ }
142
+ // Keep only most useful patterns (limit to 100)
143
+ this.context.memory.patterns = this.context.memory.patterns
144
+ .sort((a, b) => (b.successCount * 0.7 + (b.lastUsed - a.lastUsed) / 86400000 * 0.3) -
145
+ (a.successCount * 0.7 + (a.lastUsed - b.lastUsed) / 86400000 * 0.3))
146
+ .slice(0, 100);
147
+ this.saveMemory();
148
+ }
149
+ /**
150
+ * Record an operation for context
151
+ */
152
+ recordOperation(op) {
153
+ this.context.memory.recentOps.unshift(op);
154
+ // Keep last 50 operations
155
+ this.context.memory.recentOps = this.context.memory.recentOps.slice(0, 50);
156
+ this.saveMemory();
157
+ }
158
+ /**
159
+ * Get learned approach for similar prompts
160
+ */
161
+ getLearnedApproach(prompt) {
162
+ const normalized = this.normalizePrompt(prompt);
163
+ return this.context.memory.patterns.find(p => this.normalizePrompt(p.trigger) === normalized ||
164
+ this.promptSimilarity(p.trigger, prompt) > 0.7) || null;
165
+ }
166
+ normalizePrompt(prompt) {
167
+ return prompt.toLowerCase().trim().replace(/[^\w\s]/g, '');
168
+ }
169
+ promptSimilarity(a, b) {
170
+ const wordsA = new Set(this.normalizePrompt(a).split(/\s+/));
171
+ const wordsB = new Set(this.normalizePrompt(b).split(/\s+/));
172
+ const intersection = new Set([...wordsA].filter(x => wordsB.has(x)));
173
+ const union = new Set([...wordsA, ...wordsB]);
174
+ return intersection.size / union.size;
175
+ }
176
+ // ==========================================================================
177
+ // PROJECT ANALYSIS - Understand the Codebase
178
+ // ==========================================================================
179
+ analyzeProject() {
180
+ const knowledge = this.context.memory.projectKnowledge;
181
+ const dir = this.context.workingDir;
182
+ // Check for package.json (Node.js)
183
+ const packageJsonPath = path.join(dir, 'package.json');
184
+ if (fs.existsSync(packageJsonPath)) {
185
+ try {
186
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
187
+ knowledge.type = 'node';
188
+ knowledge.dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
189
+ if (pkg.scripts) {
190
+ knowledge.testCommand = pkg.scripts.test ? 'npm test' : null;
191
+ knowledge.lintCommand = pkg.scripts.lint ? 'npm run lint' : null;
192
+ knowledge.buildSystem = pkg.scripts.build ? 'npm run build' : null;
193
+ }
194
+ if (pkg.main) {
195
+ knowledge.entryPoints.push(pkg.main);
196
+ }
197
+ }
198
+ catch {
199
+ // Ignore parse errors
200
+ }
201
+ }
202
+ // Check for pyproject.toml or setup.py (Python)
203
+ if (fs.existsSync(path.join(dir, 'pyproject.toml')) ||
204
+ fs.existsSync(path.join(dir, 'setup.py'))) {
205
+ knowledge.type = 'python';
206
+ knowledge.testCommand = 'pytest';
207
+ knowledge.lintCommand = 'ruff check .';
208
+ }
209
+ // Check for Cargo.toml (Rust)
210
+ if (fs.existsSync(path.join(dir, 'Cargo.toml'))) {
211
+ knowledge.type = 'rust';
212
+ knowledge.testCommand = 'cargo test';
213
+ knowledge.lintCommand = 'cargo clippy';
214
+ knowledge.buildSystem = 'cargo build';
215
+ }
216
+ // Check for go.mod (Go)
217
+ if (fs.existsSync(path.join(dir, 'go.mod'))) {
218
+ knowledge.type = 'go';
219
+ knowledge.testCommand = 'go test ./...';
220
+ knowledge.lintCommand = 'golangci-lint run';
221
+ knowledge.buildSystem = 'go build';
222
+ }
223
+ knowledge.lastAnalyzed = Date.now();
224
+ this.saveMemory();
225
+ }
226
+ // ==========================================================================
227
+ // PROMPT UNDERSTANDING - Parse and Interpret User Requests
228
+ // ==========================================================================
229
+ /**
230
+ * Analyze a user prompt and produce a comprehensive execution plan
231
+ */
232
+ analyzePrompt(prompt) {
233
+ const lower = prompt.toLowerCase().trim();
234
+ // Check for learned patterns first
235
+ const learned = this.getLearnedApproach(prompt);
236
+ if (learned && learned.successCount >= 2) {
237
+ return this.createFromLearnedPattern(prompt, learned);
238
+ }
239
+ // Determine intent
240
+ const intent = this.determineIntent(lower);
241
+ const category = this.determineCategory(intent);
242
+ // Generate tasks based on intent
243
+ const tasks = this.generateTasks(prompt, intent);
244
+ // Check for ambiguity
245
+ const clarificationNeeded = this.checkAmbiguity(prompt, intent);
246
+ return {
247
+ originalPrompt: prompt,
248
+ interpretation: this.generateInterpretation(prompt, intent),
249
+ intent,
250
+ category,
251
+ confidence: clarificationNeeded.length === 0 ? 0.9 : 0.6,
252
+ tasks,
253
+ clarificationNeeded,
254
+ };
255
+ }
256
+ determineIntent(lower) {
257
+ // Order matters! More specific patterns first.
258
+ // =========================================================================
259
+ // NON-SWE DOMAINS (check first for domain-specific keywords)
260
+ // =========================================================================
261
+ // Legal/Litigation (sue, lawsuit, court, legal action)
262
+ if (/\bsue\b|lawsuit|litigation|legal\s+action|\bcourt\b|attorney|lawyer|complaint|motion|brief/i.test(lower)) {
263
+ return 'legal_research';
264
+ }
265
+ // Financial/Accounting (accounting, bookkeeping, tax, financial)
266
+ if (/accounting|bookkeeping|financ|tax\b|ledger|balance\s*sheet|invoice|payroll|budget|forecast/i.test(lower)) {
267
+ return 'financial_analysis';
268
+ }
269
+ // Scientific Research (cure, research, experiment, hypothesis, study)
270
+ if (/\bcure\b|research|experiment|hypothesis|scientific|laboratory|clinical|biomedical|genome|molecular/i.test(lower)) {
271
+ return 'research';
272
+ }
273
+ // Data Analysis/Science (data analysis, ML, statistics, visualization)
274
+ if (/data\s+(?:analysis|science|engineer)|statistic|machine\s+learning|\bml\b|\bai\b|neural|dataset/i.test(lower)) {
275
+ return 'data_analysis';
276
+ }
277
+ // Engineering/Science (engineering, physics, chemistry, simulation)
278
+ if (/engineer(?:ing)?|physic|chemist|simulat|cad\b|finite\s+element|signal\s+process/i.test(lower)) {
279
+ return 'scientific_computing';
280
+ }
281
+ // Business Analysis (business, strategy, market, competitor)
282
+ if (/business|strateg|\bmarket\b|competitor|swot|business\s+plan/i.test(lower)) {
283
+ return 'business_analysis';
284
+ }
285
+ // Automation/Operations (automate, workflow, schedule, cron)
286
+ // Note: "pipeline" without "CI" or "CD" context - those go to setup
287
+ if (/\bautomat|\bworkflow|\bschedule|\bcron\b|batch\s+process/i.test(lower)) {
288
+ return 'automate';
289
+ }
290
+ // Data pipeline (ETL, data pipeline) - separate from CI/CD
291
+ if (/(?:data|etl)\s+pipeline/i.test(lower)) {
292
+ return 'automate';
293
+ }
294
+ // Monitoring (monitor, alert, dashboard, metrics, observability)
295
+ if (/\bmonitor|alert|dashboard|metric|observab|logging|trace/i.test(lower)) {
296
+ return 'monitor';
297
+ }
298
+ // =========================================================================
299
+ // SOFTWARE ENGINEERING DOMAINS
300
+ // =========================================================================
301
+ // Security audit (check before general 'audit')
302
+ if (/security|vulnerab|pentest|secure/i.test(lower)) {
303
+ return 'security_audit';
304
+ }
305
+ // Optimization (check before 'improve' which could be refactor)
306
+ if (/optim|faster|performance|speed\s*up|slow/i.test(lower)) {
307
+ return 'optimize';
308
+ }
309
+ // Explanation (check before 'document' - "explain" is for understanding, not writing docs)
310
+ if (/\bwhat\b|\bhow\b.*work|\bwhy\b|\bexplain\b|\bunderstand/i.test(lower)) {
311
+ return 'explain';
312
+ }
313
+ // Bug fixing
314
+ if (/fix|bug|error|issue|broken|crash|fail/i.test(lower)) {
315
+ return 'fix_bugs';
316
+ }
317
+ // Setup/Configuration (check before 'add' - configure is setup, not adding)
318
+ if (/setup|install|configure|init/i.test(lower)) {
319
+ return 'setup';
320
+ }
321
+ // Feature addition
322
+ if (/add|create|implement|build|new|feature/i.test(lower)) {
323
+ return 'add_feature';
324
+ }
325
+ // Refactoring (check 'improve' here after optimization is handled)
326
+ if (/refactor|clean|improve|reorganize|restructure/i.test(lower)) {
327
+ return 'refactor';
328
+ }
329
+ // Testing
330
+ if (/test|spec|coverage|verify/i.test(lower)) {
331
+ return 'test';
332
+ }
333
+ // Documentation
334
+ if (/document|readme|comment|doc\b/i.test(lower)) {
335
+ return 'document';
336
+ }
337
+ // Deployment
338
+ if (/deploy|release|publish|ship/i.test(lower)) {
339
+ return 'deploy';
340
+ }
341
+ // Analysis (general analysis, after security)
342
+ if (/analyze|review|audit|check|inspect/i.test(lower)) {
343
+ return 'analyze';
344
+ }
345
+ // Migration
346
+ if (/migrate|upgrade|update|version/i.test(lower)) {
347
+ return 'migrate';
348
+ }
349
+ return 'generic_task';
350
+ }
351
+ determineCategory(intent) {
352
+ const mapping = {
353
+ // Software Engineering
354
+ 'fix_bugs': 'code_modification',
355
+ 'add_feature': 'code_modification',
356
+ 'refactor': 'code_modification',
357
+ 'test': 'testing',
358
+ 'document': 'documentation',
359
+ 'deploy': 'infrastructure',
360
+ 'analyze': 'code_analysis',
361
+ 'explain': 'research',
362
+ 'optimize': 'code_modification',
363
+ 'security_audit': 'code_analysis',
364
+ 'setup': 'infrastructure',
365
+ 'migrate': 'code_modification',
366
+ // Research & Science
367
+ 'research': 'scientific',
368
+ 'data_analysis': 'scientific',
369
+ 'scientific_computing': 'scientific',
370
+ // Business & Legal
371
+ 'legal_research': 'legal',
372
+ 'business_analysis': 'business',
373
+ 'financial_analysis': 'financial',
374
+ // Automation & Operations
375
+ 'automate': 'automation',
376
+ 'monitor': 'operations',
377
+ // Generic
378
+ 'generic_task': 'general_coding',
379
+ };
380
+ return mapping[intent];
381
+ }
382
+ generateInterpretation(prompt, intent) {
383
+ const interpretations = {
384
+ // Software Engineering
385
+ 'fix_bugs': `Identify and fix bugs/errors in the codebase based on: "${prompt}"`,
386
+ 'add_feature': `Implement new functionality: "${prompt}"`,
387
+ 'refactor': `Improve code structure and quality: "${prompt}"`,
388
+ 'test': `Create or run tests: "${prompt}"`,
389
+ 'document': `Create or update documentation: "${prompt}"`,
390
+ 'deploy': `Prepare and execute deployment: "${prompt}"`,
391
+ 'analyze': `Analyze and review: "${prompt}"`,
392
+ 'explain': `Explain and clarify: "${prompt}"`,
393
+ 'optimize': `Improve performance: "${prompt}"`,
394
+ 'security_audit': `Security review and hardening: "${prompt}"`,
395
+ 'setup': `Set up and configure: "${prompt}"`,
396
+ 'migrate': `Migrate or upgrade: "${prompt}"`,
397
+ // Research & Science
398
+ 'research': `Build research tools and analysis pipeline for: "${prompt}"`,
399
+ 'data_analysis': `Create data analysis pipeline and visualizations for: "${prompt}"`,
400
+ 'scientific_computing': `Build scientific computing tools for: "${prompt}"`,
401
+ // Business & Legal
402
+ 'legal_research': `Legal research and document automation for: "${prompt}"`,
403
+ 'business_analysis': `Business analysis and strategy tools for: "${prompt}"`,
404
+ 'financial_analysis': `Financial analysis and reporting tools for: "${prompt}"`,
405
+ // Automation & Operations
406
+ 'automate': `Build automation workflow for: "${prompt}"`,
407
+ 'monitor': `Create monitoring and alerting system for: "${prompt}"`,
408
+ // Generic
409
+ 'generic_task': `Execute task: "${prompt}"`,
410
+ };
411
+ return interpretations[intent];
412
+ }
413
+ generateTasks(prompt, intent) {
414
+ const tasks = [];
415
+ const knowledge = this.context.memory.projectKnowledge;
416
+ switch (intent) {
417
+ case 'fix_bugs':
418
+ // First: analyze the codebase
419
+ tasks.push({
420
+ id: 'analyze-errors',
421
+ description: 'Run type checker and linter to identify issues',
422
+ category: 'execution',
423
+ tools: ['Bash'],
424
+ dependencies: [],
425
+ status: 'pending',
426
+ });
427
+ if (knowledge.testCommand) {
428
+ tasks.push({
429
+ id: 'run-tests',
430
+ description: 'Run test suite to find failing tests',
431
+ category: 'execution',
432
+ tools: ['Bash'],
433
+ dependencies: [],
434
+ status: 'pending',
435
+ });
436
+ }
437
+ tasks.push({
438
+ id: 'search-issues',
439
+ description: 'Search for TODO/FIXME comments and known issues',
440
+ category: 'search',
441
+ tools: ['Grep'],
442
+ dependencies: [],
443
+ status: 'pending',
444
+ });
445
+ tasks.push({
446
+ id: 'analyze-findings',
447
+ description: 'Analyze all findings and prioritize fixes',
448
+ category: 'analysis',
449
+ tools: ['Read'],
450
+ dependencies: ['analyze-errors', 'search-issues'],
451
+ status: 'pending',
452
+ });
453
+ tasks.push({
454
+ id: 'fix-issues',
455
+ description: 'Apply fixes to identified issues',
456
+ category: 'modification',
457
+ tools: ['Edit'],
458
+ dependencies: ['analyze-findings'],
459
+ status: 'pending',
460
+ });
461
+ tasks.push({
462
+ id: 'verify-fixes',
463
+ description: 'Verify fixes by re-running checks',
464
+ category: 'verification',
465
+ tools: ['Bash'],
466
+ dependencies: ['fix-issues'],
467
+ status: 'pending',
468
+ });
469
+ break;
470
+ case 'add_feature':
471
+ tasks.push({
472
+ id: 'understand-codebase',
473
+ description: 'Analyze existing code structure',
474
+ category: 'analysis',
475
+ tools: ['Glob', 'Read'],
476
+ dependencies: [],
477
+ status: 'pending',
478
+ });
479
+ tasks.push({
480
+ id: 'plan-implementation',
481
+ description: 'Plan the implementation approach',
482
+ category: 'analysis',
483
+ tools: ['Read'],
484
+ dependencies: ['understand-codebase'],
485
+ status: 'pending',
486
+ });
487
+ tasks.push({
488
+ id: 'implement-feature',
489
+ description: 'Write the feature code',
490
+ category: 'modification',
491
+ tools: ['Edit', 'Write'],
492
+ dependencies: ['plan-implementation'],
493
+ status: 'pending',
494
+ });
495
+ tasks.push({
496
+ id: 'add-tests',
497
+ description: 'Add tests for the new feature',
498
+ category: 'modification',
499
+ tools: ['Edit', 'Write'],
500
+ dependencies: ['implement-feature'],
501
+ status: 'pending',
502
+ });
503
+ tasks.push({
504
+ id: 'verify-feature',
505
+ description: 'Run tests and verify feature works',
506
+ category: 'verification',
507
+ tools: ['Bash'],
508
+ dependencies: ['add-tests'],
509
+ status: 'pending',
510
+ });
511
+ break;
512
+ case 'analyze':
513
+ case 'explain':
514
+ tasks.push({
515
+ id: 'explore-structure',
516
+ description: 'Explore project structure',
517
+ category: 'search',
518
+ tools: ['Glob', 'Bash'],
519
+ dependencies: [],
520
+ status: 'pending',
521
+ });
522
+ tasks.push({
523
+ id: 'read-key-files',
524
+ description: 'Read and understand key files',
525
+ category: 'analysis',
526
+ tools: ['Read'],
527
+ dependencies: ['explore-structure'],
528
+ status: 'pending',
529
+ });
530
+ tasks.push({
531
+ id: 'summarize-findings',
532
+ description: 'Summarize and explain findings',
533
+ category: 'communication',
534
+ tools: [],
535
+ dependencies: ['read-key-files'],
536
+ status: 'pending',
537
+ });
538
+ break;
539
+ case 'test':
540
+ if (knowledge.testCommand) {
541
+ tasks.push({
542
+ id: 'run-existing-tests',
543
+ description: 'Run existing test suite',
544
+ category: 'execution',
545
+ tools: ['Bash'],
546
+ dependencies: [],
547
+ status: 'pending',
548
+ });
549
+ }
550
+ tasks.push({
551
+ id: 'analyze-coverage',
552
+ description: 'Analyze test coverage',
553
+ category: 'analysis',
554
+ tools: ['Bash', 'Read'],
555
+ dependencies: [],
556
+ status: 'pending',
557
+ });
558
+ tasks.push({
559
+ id: 'identify-gaps',
560
+ description: 'Identify testing gaps',
561
+ category: 'analysis',
562
+ tools: ['Grep', 'Read'],
563
+ dependencies: ['analyze-coverage'],
564
+ status: 'pending',
565
+ });
566
+ tasks.push({
567
+ id: 'write-tests',
568
+ description: 'Write new tests for uncovered code',
569
+ category: 'modification',
570
+ tools: ['Edit', 'Write'],
571
+ dependencies: ['identify-gaps'],
572
+ status: 'pending',
573
+ });
574
+ break;
575
+ case 'security_audit':
576
+ tasks.push({
577
+ id: 'dependency-audit',
578
+ description: 'Audit dependencies for known vulnerabilities',
579
+ category: 'execution',
580
+ tools: ['Bash'],
581
+ dependencies: [],
582
+ status: 'pending',
583
+ });
584
+ tasks.push({
585
+ id: 'code-patterns',
586
+ description: 'Search for insecure code patterns',
587
+ category: 'search',
588
+ tools: ['Grep'],
589
+ dependencies: [],
590
+ status: 'pending',
591
+ });
592
+ tasks.push({
593
+ id: 'analyze-security',
594
+ description: 'Analyze security findings',
595
+ category: 'analysis',
596
+ tools: ['Read'],
597
+ dependencies: ['dependency-audit', 'code-patterns'],
598
+ status: 'pending',
599
+ });
600
+ tasks.push({
601
+ id: 'report-findings',
602
+ description: 'Report security findings with recommendations',
603
+ category: 'communication',
604
+ tools: [],
605
+ dependencies: ['analyze-security'],
606
+ status: 'pending',
607
+ });
608
+ break;
609
+ // =====================================================================
610
+ // NON-SWE DOMAIN TASKS
611
+ // =====================================================================
612
+ case 'research':
613
+ // Scientific/Medical Research (e.g., "cure cancer")
614
+ tasks.push({
615
+ id: 'define-scope',
616
+ description: 'Define research scope and objectives',
617
+ category: 'analysis',
618
+ tools: ['Read'],
619
+ dependencies: [],
620
+ status: 'pending',
621
+ });
622
+ tasks.push({
623
+ id: 'gather-data',
624
+ description: 'Gather relevant data and research materials',
625
+ category: 'research',
626
+ tools: ['Bash', 'Read'],
627
+ dependencies: ['define-scope'],
628
+ status: 'pending',
629
+ });
630
+ tasks.push({
631
+ id: 'build-pipeline',
632
+ description: 'Build data processing and analysis pipeline',
633
+ category: 'generation',
634
+ tools: ['Edit', 'Write', 'Bash'],
635
+ dependencies: ['gather-data'],
636
+ status: 'pending',
637
+ });
638
+ tasks.push({
639
+ id: 'implement-analysis',
640
+ description: 'Implement analysis algorithms and models',
641
+ category: 'generation',
642
+ tools: ['Edit', 'Write'],
643
+ dependencies: ['build-pipeline'],
644
+ status: 'pending',
645
+ });
646
+ tasks.push({
647
+ id: 'generate-report',
648
+ description: 'Generate analysis report with findings',
649
+ category: 'communication',
650
+ tools: ['Edit', 'Write'],
651
+ dependencies: ['implement-analysis'],
652
+ status: 'pending',
653
+ });
654
+ break;
655
+ case 'data_analysis':
656
+ tasks.push({
657
+ id: 'explore-data',
658
+ description: 'Explore and understand the data',
659
+ category: 'analysis',
660
+ tools: ['Read', 'Bash'],
661
+ dependencies: [],
662
+ status: 'pending',
663
+ });
664
+ tasks.push({
665
+ id: 'clean-data',
666
+ description: 'Clean and preprocess data',
667
+ category: 'execution',
668
+ tools: ['Bash', 'Edit'],
669
+ dependencies: ['explore-data'],
670
+ status: 'pending',
671
+ });
672
+ tasks.push({
673
+ id: 'analyze-patterns',
674
+ description: 'Analyze patterns and statistics',
675
+ category: 'computation',
676
+ tools: ['Bash', 'Edit'],
677
+ dependencies: ['clean-data'],
678
+ status: 'pending',
679
+ });
680
+ tasks.push({
681
+ id: 'create-visualizations',
682
+ description: 'Create visualizations and charts',
683
+ category: 'generation',
684
+ tools: ['Edit', 'Bash'],
685
+ dependencies: ['analyze-patterns'],
686
+ status: 'pending',
687
+ });
688
+ tasks.push({
689
+ id: 'summarize-insights',
690
+ description: 'Summarize insights and recommendations',
691
+ category: 'communication',
692
+ tools: ['Edit'],
693
+ dependencies: ['create-visualizations'],
694
+ status: 'pending',
695
+ });
696
+ break;
697
+ case 'scientific_computing':
698
+ tasks.push({
699
+ id: 'define-problem',
700
+ description: 'Define the scientific problem and requirements',
701
+ category: 'analysis',
702
+ tools: ['Read'],
703
+ dependencies: [],
704
+ status: 'pending',
705
+ });
706
+ tasks.push({
707
+ id: 'design-algorithm',
708
+ description: 'Design computational algorithm',
709
+ category: 'analysis',
710
+ tools: ['Read', 'Edit'],
711
+ dependencies: ['define-problem'],
712
+ status: 'pending',
713
+ });
714
+ tasks.push({
715
+ id: 'implement-computation',
716
+ description: 'Implement computational solution',
717
+ category: 'generation',
718
+ tools: ['Edit', 'Write'],
719
+ dependencies: ['design-algorithm'],
720
+ status: 'pending',
721
+ });
722
+ tasks.push({
723
+ id: 'validate-results',
724
+ description: 'Validate and verify results',
725
+ category: 'verification',
726
+ tools: ['Bash', 'Read'],
727
+ dependencies: ['implement-computation'],
728
+ status: 'pending',
729
+ });
730
+ break;
731
+ case 'legal_research':
732
+ // Legal/Litigation (e.g., "sue google in fed court")
733
+ tasks.push({
734
+ id: 'identify-claims',
735
+ description: 'Identify legal claims and causes of action',
736
+ category: 'research',
737
+ tools: ['Read'],
738
+ dependencies: [],
739
+ status: 'pending',
740
+ });
741
+ tasks.push({
742
+ id: 'research-law',
743
+ description: 'Research applicable laws and precedents',
744
+ category: 'research',
745
+ tools: ['Read', 'Bash'],
746
+ dependencies: ['identify-claims'],
747
+ status: 'pending',
748
+ });
749
+ tasks.push({
750
+ id: 'gather-evidence',
751
+ description: 'Gather and organize evidence',
752
+ category: 'search',
753
+ tools: ['Glob', 'Grep', 'Read'],
754
+ dependencies: [],
755
+ status: 'pending',
756
+ });
757
+ tasks.push({
758
+ id: 'draft-documents',
759
+ description: 'Draft legal documents (complaint, motion, brief)',
760
+ category: 'generation',
761
+ tools: ['Edit', 'Write'],
762
+ dependencies: ['research-law', 'gather-evidence'],
763
+ status: 'pending',
764
+ });
765
+ tasks.push({
766
+ id: 'prepare-filing',
767
+ description: 'Prepare filing package and procedures',
768
+ category: 'generation',
769
+ tools: ['Edit', 'Write'],
770
+ dependencies: ['draft-documents'],
771
+ status: 'pending',
772
+ });
773
+ break;
774
+ case 'business_analysis':
775
+ tasks.push({
776
+ id: 'gather-business-data',
777
+ description: 'Gather business data and market information',
778
+ category: 'research',
779
+ tools: ['Read', 'Bash'],
780
+ dependencies: [],
781
+ status: 'pending',
782
+ });
783
+ tasks.push({
784
+ id: 'analyze-market',
785
+ description: 'Analyze market and competitive landscape',
786
+ category: 'analysis',
787
+ tools: ['Read', 'Edit'],
788
+ dependencies: ['gather-business-data'],
789
+ status: 'pending',
790
+ });
791
+ tasks.push({
792
+ id: 'build-models',
793
+ description: 'Build financial/business models',
794
+ category: 'computation',
795
+ tools: ['Edit', 'Write'],
796
+ dependencies: ['analyze-market'],
797
+ status: 'pending',
798
+ });
799
+ tasks.push({
800
+ id: 'generate-strategy',
801
+ description: 'Generate strategy recommendations',
802
+ category: 'communication',
803
+ tools: ['Edit'],
804
+ dependencies: ['build-models'],
805
+ status: 'pending',
806
+ });
807
+ break;
808
+ case 'financial_analysis':
809
+ // Accounting/Finance (e.g., "do accounting")
810
+ tasks.push({
811
+ id: 'gather-financial-data',
812
+ description: 'Gather financial data and records',
813
+ category: 'search',
814
+ tools: ['Glob', 'Read'],
815
+ dependencies: [],
816
+ status: 'pending',
817
+ });
818
+ tasks.push({
819
+ id: 'organize-transactions',
820
+ description: 'Organize and categorize transactions',
821
+ category: 'analysis',
822
+ tools: ['Read', 'Edit'],
823
+ dependencies: ['gather-financial-data'],
824
+ status: 'pending',
825
+ });
826
+ tasks.push({
827
+ id: 'calculate-financials',
828
+ description: 'Calculate financial metrics and statements',
829
+ category: 'computation',
830
+ tools: ['Edit', 'Bash'],
831
+ dependencies: ['organize-transactions'],
832
+ status: 'pending',
833
+ });
834
+ tasks.push({
835
+ id: 'generate-reports',
836
+ description: 'Generate financial reports',
837
+ category: 'generation',
838
+ tools: ['Edit', 'Write'],
839
+ dependencies: ['calculate-financials'],
840
+ status: 'pending',
841
+ });
842
+ tasks.push({
843
+ id: 'prepare-tax',
844
+ description: 'Prepare tax calculations and filings',
845
+ category: 'generation',
846
+ tools: ['Edit', 'Write'],
847
+ dependencies: ['calculate-financials'],
848
+ status: 'pending',
849
+ });
850
+ break;
851
+ case 'automate':
852
+ tasks.push({
853
+ id: 'analyze-workflow',
854
+ description: 'Analyze current workflow and processes',
855
+ category: 'analysis',
856
+ tools: ['Read', 'Glob'],
857
+ dependencies: [],
858
+ status: 'pending',
859
+ });
860
+ tasks.push({
861
+ id: 'design-automation',
862
+ description: 'Design automation solution',
863
+ category: 'analysis',
864
+ tools: ['Read'],
865
+ dependencies: ['analyze-workflow'],
866
+ status: 'pending',
867
+ });
868
+ tasks.push({
869
+ id: 'implement-automation',
870
+ description: 'Implement automation scripts',
871
+ category: 'generation',
872
+ tools: ['Edit', 'Write', 'Bash'],
873
+ dependencies: ['design-automation'],
874
+ status: 'pending',
875
+ });
876
+ tasks.push({
877
+ id: 'test-automation',
878
+ description: 'Test automation workflow',
879
+ category: 'verification',
880
+ tools: ['Bash'],
881
+ dependencies: ['implement-automation'],
882
+ status: 'pending',
883
+ });
884
+ break;
885
+ case 'monitor':
886
+ tasks.push({
887
+ id: 'identify-metrics',
888
+ description: 'Identify key metrics to monitor',
889
+ category: 'analysis',
890
+ tools: ['Read'],
891
+ dependencies: [],
892
+ status: 'pending',
893
+ });
894
+ tasks.push({
895
+ id: 'setup-collection',
896
+ description: 'Set up metric collection',
897
+ category: 'execution',
898
+ tools: ['Edit', 'Bash'],
899
+ dependencies: ['identify-metrics'],
900
+ status: 'pending',
901
+ });
902
+ tasks.push({
903
+ id: 'create-dashboard',
904
+ description: 'Create monitoring dashboard',
905
+ category: 'generation',
906
+ tools: ['Edit', 'Write'],
907
+ dependencies: ['setup-collection'],
908
+ status: 'pending',
909
+ });
910
+ tasks.push({
911
+ id: 'configure-alerts',
912
+ description: 'Configure alerting rules',
913
+ category: 'generation',
914
+ tools: ['Edit', 'Write'],
915
+ dependencies: ['create-dashboard'],
916
+ status: 'pending',
917
+ });
918
+ break;
919
+ default:
920
+ // Generic task decomposition
921
+ tasks.push({
922
+ id: 'understand-request',
923
+ description: 'Understand the request and context',
924
+ category: 'analysis',
925
+ tools: ['Glob', 'Read'],
926
+ dependencies: [],
927
+ status: 'pending',
928
+ });
929
+ tasks.push({
930
+ id: 'execute-task',
931
+ description: 'Execute the requested task',
932
+ category: 'execution',
933
+ tools: ['Bash', 'Edit'],
934
+ dependencies: ['understand-request'],
935
+ status: 'pending',
936
+ });
937
+ tasks.push({
938
+ id: 'verify-completion',
939
+ description: 'Verify task completion',
940
+ category: 'verification',
941
+ tools: ['Bash', 'Read'],
942
+ dependencies: ['execute-task'],
943
+ status: 'pending',
944
+ });
945
+ break;
946
+ }
947
+ return tasks;
948
+ }
949
+ checkAmbiguity(prompt, intent) {
950
+ const questions = [];
951
+ const lower = prompt.toLowerCase();
952
+ // Vague scope
953
+ if (/all|everything|entire|whole/i.test(lower)) {
954
+ questions.push('The request has broad scope. Should I focus on specific areas first?');
955
+ }
956
+ // Missing target
957
+ if (intent === 'fix_bugs' && !/specific|file|function|module/i.test(lower)) {
958
+ questions.push('Are there specific files or modules to prioritize?');
959
+ }
960
+ // Unclear priority
961
+ if (/important|priority|critical/i.test(lower) && !/high|low|medium/i.test(lower)) {
962
+ questions.push('What priority level should I focus on?');
963
+ }
964
+ return questions;
965
+ }
966
+ createFromLearnedPattern(prompt, pattern) {
967
+ return {
968
+ originalPrompt: prompt,
969
+ interpretation: `Using learned approach: ${pattern.successfulApproach}`,
970
+ intent: 'generic_task',
971
+ category: 'automation',
972
+ confidence: 0.95,
973
+ tasks: pattern.tools.map((tool, i) => ({
974
+ id: `learned-${i}`,
975
+ description: `Execute ${tool} based on learned pattern`,
976
+ category: 'execution',
977
+ tools: [tool],
978
+ dependencies: i > 0 ? [`learned-${i - 1}`] : [],
979
+ status: 'pending',
980
+ })),
981
+ clarificationNeeded: [],
982
+ };
983
+ }
984
+ // ==========================================================================
985
+ // EXECUTION - Run Tasks with Real Tools
986
+ // ==========================================================================
987
+ /**
988
+ * Generate tool calls for a given analysis
989
+ * Returns explicit tool call specifications ready for execution
990
+ */
991
+ generateToolCalls(analysis) {
992
+ const calls = [];
993
+ const knowledge = this.context.memory.projectKnowledge;
994
+ for (const task of analysis.tasks) {
995
+ switch (task.category) {
996
+ case 'execution':
997
+ if (task.tools.includes('Bash')) {
998
+ // Generate appropriate commands based on task
999
+ if (task.id.includes('lint') || task.id.includes('errors')) {
1000
+ if (knowledge.lintCommand) {
1001
+ calls.push({
1002
+ tool: 'Bash',
1003
+ args: { command: knowledge.lintCommand + ' 2>&1 || true', description: task.description },
1004
+ description: task.description,
1005
+ taskId: task.id,
1006
+ });
1007
+ }
1008
+ if (knowledge.type === 'node') {
1009
+ calls.push({
1010
+ tool: 'Bash',
1011
+ args: { command: 'npx tsc --noEmit 2>&1 || true', description: 'Type check' },
1012
+ description: 'Run TypeScript type checker',
1013
+ taskId: task.id,
1014
+ });
1015
+ }
1016
+ }
1017
+ if (task.id.includes('test')) {
1018
+ if (knowledge.testCommand) {
1019
+ calls.push({
1020
+ tool: 'Bash',
1021
+ args: { command: knowledge.testCommand + ' 2>&1 || true', description: task.description },
1022
+ description: task.description,
1023
+ taskId: task.id,
1024
+ });
1025
+ }
1026
+ }
1027
+ if (task.id.includes('dependency') || task.id.includes('audit')) {
1028
+ if (knowledge.type === 'node') {
1029
+ calls.push({
1030
+ tool: 'Bash',
1031
+ args: { command: 'npm audit 2>&1 || true', description: 'Security audit' },
1032
+ description: 'Audit npm dependencies for vulnerabilities',
1033
+ taskId: task.id,
1034
+ });
1035
+ }
1036
+ }
1037
+ }
1038
+ break;
1039
+ case 'search':
1040
+ if (task.tools.includes('Grep')) {
1041
+ if (task.id.includes('issues') || task.id.includes('todo')) {
1042
+ calls.push({
1043
+ tool: 'Grep',
1044
+ args: { pattern: 'TODO|FIXME|BUG|HACK|XXX', output_mode: 'content' },
1045
+ description: 'Find TODO/FIXME comments',
1046
+ taskId: task.id,
1047
+ });
1048
+ }
1049
+ if (task.id.includes('security') || task.id.includes('patterns')) {
1050
+ calls.push({
1051
+ tool: 'Grep',
1052
+ args: { pattern: 'eval\\(|exec\\(|innerHTML|dangerouslySetInnerHTML', output_mode: 'content' },
1053
+ description: 'Find potentially unsafe patterns',
1054
+ taskId: task.id,
1055
+ });
1056
+ }
1057
+ }
1058
+ if (task.tools.includes('Glob')) {
1059
+ calls.push({
1060
+ tool: 'Glob',
1061
+ args: { pattern: 'src/**/*.{ts,js,tsx,jsx}' },
1062
+ description: 'Find source files',
1063
+ taskId: task.id,
1064
+ });
1065
+ }
1066
+ break;
1067
+ case 'analysis':
1068
+ // Analysis typically involves reading files
1069
+ if (task.tools.includes('Read')) {
1070
+ calls.push({
1071
+ tool: 'Read',
1072
+ args: { file_path: 'package.json' },
1073
+ description: 'Read project configuration',
1074
+ taskId: task.id,
1075
+ });
1076
+ }
1077
+ break;
1078
+ }
1079
+ }
1080
+ return calls;
1081
+ }
1082
+ // ==========================================================================
1083
+ // PUBLIC API
1084
+ // ==========================================================================
1085
+ /**
1086
+ * Get the current AGI context
1087
+ */
1088
+ getContext() {
1089
+ return this.context;
1090
+ }
1091
+ /**
1092
+ * Get project knowledge
1093
+ */
1094
+ getProjectKnowledge() {
1095
+ return this.context.memory.projectKnowledge;
1096
+ }
1097
+ /**
1098
+ * Get recent operations
1099
+ */
1100
+ getRecentOperations(limit = 10) {
1101
+ return this.context.memory.recentOps.slice(0, limit);
1102
+ }
1103
+ /**
1104
+ * Get learned patterns
1105
+ */
1106
+ getLearnedPatterns() {
1107
+ return this.context.memory.patterns;
1108
+ }
1109
+ /**
1110
+ * Force project re-analysis
1111
+ */
1112
+ refreshProjectKnowledge() {
1113
+ this.analyzeProject();
1114
+ return this.context.memory.projectKnowledge;
1115
+ }
1116
+ // ==========================================================================
1117
+ // EPISODIC MEMORY - Cross-session learning with semantic search
1118
+ // ==========================================================================
1119
+ /**
1120
+ * Start tracking a new episode (task/conversation unit)
1121
+ */
1122
+ startEpisode(intent) {
1123
+ this.currentEpisodeId = this.episodicMemory.startEpisode(intent, this.context.sessionId);
1124
+ this.emit('episode:start', { id: this.currentEpisodeId, intent });
1125
+ return this.currentEpisodeId;
1126
+ }
1127
+ /**
1128
+ * Record tool usage within the current episode
1129
+ */
1130
+ recordEpisodeToolUse(toolName) {
1131
+ if (this.currentEpisodeId) {
1132
+ this.episodicMemory.recordToolUse(toolName);
1133
+ }
1134
+ }
1135
+ /**
1136
+ * Record file modification within the current episode
1137
+ */
1138
+ recordEpisodeFileModification(filePath) {
1139
+ if (this.currentEpisodeId) {
1140
+ this.episodicMemory.recordFileModification(filePath);
1141
+ }
1142
+ }
1143
+ /**
1144
+ * End the current episode and save to memory
1145
+ */
1146
+ async endEpisode(success, summary) {
1147
+ if (!this.currentEpisodeId)
1148
+ return null;
1149
+ const episode = await this.episodicMemory.endEpisode(success, summary);
1150
+ this.emit('episode:end', { episode, success });
1151
+ this.currentEpisodeId = null;
1152
+ return episode;
1153
+ }
1154
+ /**
1155
+ * Abort the current episode without saving
1156
+ */
1157
+ abortEpisode() {
1158
+ if (this.currentEpisodeId) {
1159
+ this.episodicMemory.abortEpisode();
1160
+ this.emit('episode:abort', { id: this.currentEpisodeId });
1161
+ this.currentEpisodeId = null;
1162
+ }
1163
+ }
1164
+ /**
1165
+ * Search episodic memory for similar past work
1166
+ */
1167
+ async searchMemory(query, options) {
1168
+ return this.episodicMemory.search({
1169
+ query,
1170
+ limit: options?.limit ?? 5,
1171
+ successOnly: options?.successOnly,
1172
+ since: options?.since,
1173
+ });
1174
+ }
1175
+ /**
1176
+ * Get learned approach from episodic memory
1177
+ */
1178
+ async getEpisodicApproach(intent) {
1179
+ const learned = await this.episodicMemory.getApproach(intent);
1180
+ if (!learned)
1181
+ return null;
1182
+ return {
1183
+ approach: learned.approach,
1184
+ tools: learned.tools,
1185
+ successRate: learned.successRate,
1186
+ };
1187
+ }
1188
+ /**
1189
+ * Get recent episodes for context
1190
+ */
1191
+ getRecentEpisodes(limit = 5) {
1192
+ return this.episodicMemory.getRecentEpisodes(limit, this.context.sessionId);
1193
+ }
1194
+ /**
1195
+ * Get episodic memory statistics
1196
+ */
1197
+ getEpisodicMemoryStats() {
1198
+ return this.episodicMemory.getStats();
1199
+ }
1200
+ /**
1201
+ * Get the episodic memory instance for direct access
1202
+ */
1203
+ getEpisodicMemory() {
1204
+ return this.episodicMemory;
1205
+ }
1206
+ /**
1207
+ * Check if there's an active episode
1208
+ */
1209
+ hasActiveEpisode() {
1210
+ return this.currentEpisodeId !== null;
1211
+ }
1212
+ /**
1213
+ * Get current episode ID
1214
+ */
1215
+ getCurrentEpisodeId() {
1216
+ return this.currentEpisodeId;
1217
+ }
1218
+ // ==========================================================================
1219
+ // SELF-UPGRADE SYSTEM - Automatic updates and hot-reload
1220
+ // ==========================================================================
1221
+ /**
1222
+ * Check for available updates
1223
+ */
1224
+ async checkForUpdates() {
1225
+ const info = await this.selfUpgrade.checkForUpdates();
1226
+ return {
1227
+ available: info.updateAvailable,
1228
+ current: info.current,
1229
+ latest: info.latest,
1230
+ };
1231
+ }
1232
+ /**
1233
+ * Perform self-upgrade to latest version
1234
+ * Saves session state and restarts CLI automatically
1235
+ */
1236
+ async performSelfUpgrade(options = {}) {
1237
+ // Save current session state if requested
1238
+ if (options.preserveSession !== false) {
1239
+ const sessionState = {
1240
+ workingDir: this.context.workingDir,
1241
+ fromVersion: (await this.selfUpgrade.checkForUpdates()).current,
1242
+ timestamp: Date.now(),
1243
+ pendingTasks: this.context.memory.recentOps.slice(0, 5).map(op => op.prompt),
1244
+ contextSummary: `Session ${this.context.sessionId}, ${this.context.memory.recentOps.length} recent operations`,
1245
+ };
1246
+ // Include RL context if in an active episode
1247
+ if (this.currentEpisodeId) {
1248
+ sessionState.rlContext = {
1249
+ iteration: 1,
1250
+ variant: 'primary',
1251
+ objective: 'Continue from episode ' + this.currentEpisodeId,
1252
+ currentScore: 0,
1253
+ filesModified: [],
1254
+ };
1255
+ }
1256
+ this.selfUpgrade.saveSessionState(sessionState);
1257
+ }
1258
+ // Perform upgrade
1259
+ const result = await this.selfUpgrade.npmInstallFresh(options.version);
1260
+ return {
1261
+ success: result.success,
1262
+ fromVersion: result.fromVersion,
1263
+ toVersion: result.toVersion,
1264
+ error: result.error,
1265
+ };
1266
+ }
1267
+ /**
1268
+ * Perform self-upgrade with build and test verification
1269
+ */
1270
+ async performVerifiedUpgrade(options = {}) {
1271
+ const result = await this.selfUpgrade.upgradeWithFullVerification(options.version, options.buildCommand || this.context.memory.projectKnowledge.buildSystem || 'npm run build', options.testCommand || this.context.memory.projectKnowledge.testCommand || 'npm test');
1272
+ return {
1273
+ success: result.success,
1274
+ buildSuccess: result.buildSuccess,
1275
+ testsPassed: result.testState.passed,
1276
+ testsFailed: result.testState.failed,
1277
+ fromVersion: result.fromVersion,
1278
+ toVersion: result.toVersion,
1279
+ };
1280
+ }
1281
+ /**
1282
+ * Trigger hot-reload if update is available
1283
+ */
1284
+ async triggerHotReload(options = {}) {
1285
+ // Include RL context if applicable
1286
+ const rlContext = this.currentEpisodeId ? {
1287
+ iteration: 1,
1288
+ variant: 'primary',
1289
+ objective: 'Hot-reload continuation',
1290
+ currentScore: 0,
1291
+ filesModified: options.activeEdits || [],
1292
+ } : undefined;
1293
+ return this.hotReload.performHotReload({
1294
+ preserveState: options.preserveState,
1295
+ rlContext,
1296
+ activeEdits: options.activeEdits,
1297
+ });
1298
+ }
1299
+ /**
1300
+ * Resume from previous upgrade session
1301
+ */
1302
+ resumeFromUpgrade() {
1303
+ const state = this.selfUpgrade.loadSessionState();
1304
+ if (state) {
1305
+ this.selfUpgrade.clearSessionState();
1306
+ this.emit('upgrade:resumed', state);
1307
+ }
1308
+ return state;
1309
+ }
1310
+ /**
1311
+ * Get the self-upgrade instance for direct access
1312
+ */
1313
+ getSelfUpgrade() {
1314
+ return this.selfUpgrade;
1315
+ }
1316
+ /**
1317
+ * Get the hot-reload instance for direct access
1318
+ */
1319
+ getHotReload() {
1320
+ return this.hotReload;
1321
+ }
1322
+ /**
1323
+ * Check if this session was started after an upgrade
1324
+ */
1325
+ wasUpgraded() {
1326
+ return SelfUpgrade.wasUpgraded();
1327
+ }
1328
+ /**
1329
+ * Get version we upgraded from (if applicable)
1330
+ */
1331
+ getUpgradeFromVersion() {
1332
+ return SelfUpgrade.getUpgradeFromVersion();
1333
+ }
1334
+ }
1335
+ // ============================================================================
1336
+ // SINGLETON EXPORT
1337
+ // ============================================================================
1338
+ let agiInstance = null;
1339
+ export function getAGI(workingDir) {
1340
+ if (!agiInstance || (workingDir && workingDir !== agiInstance.getContext().workingDir)) {
1341
+ agiInstance = new AGICore(workingDir);
1342
+ }
1343
+ return agiInstance;
1344
+ }
1345
+ export function resetAGI() {
1346
+ agiInstance = null;
1347
+ }
1348
+ //# sourceMappingURL=agiCore.js.map