@noorm/marie-cli 0.1.17 → 0.1.25

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 (299) hide show
  1. package/README.md +7 -15
  2. package/SENTINEL.md +4 -7
  3. package/dist/cli-new/components/AgenticSpinner.js +28 -0
  4. package/dist/cli-new/components/AgenticSpinner.js.map +1 -0
  5. package/dist/cli-new/components/App.js +16 -63
  6. package/dist/cli-new/components/App.js.map +1 -1
  7. package/dist/cli-new/components/ApprovalDialog.js +3 -2
  8. package/dist/cli-new/components/ApprovalDialog.js.map +1 -1
  9. package/dist/cli-new/components/Banner.js +16 -5
  10. package/dist/cli-new/components/Banner.js.map +1 -1
  11. package/dist/cli-new/components/ChatArea.js +6 -7
  12. package/dist/cli-new/components/ChatArea.js.map +1 -1
  13. package/dist/cli-new/components/Header.js +14 -8
  14. package/dist/cli-new/components/Header.js.map +1 -1
  15. package/dist/cli-new/components/InputArea.js +98 -31
  16. package/dist/cli-new/components/InputArea.js.map +1 -1
  17. package/dist/cli-new/components/MessageBubble.js +28 -19
  18. package/dist/cli-new/components/MessageBubble.js.map +1 -1
  19. package/dist/cli-new/components/SessionSwitcher.js +6 -9
  20. package/dist/cli-new/components/SessionSwitcher.js.map +1 -1
  21. package/dist/cli-new/components/SetupWizard.js +80 -257
  22. package/dist/cli-new/components/SetupWizard.js.map +1 -1
  23. package/dist/cli-new/components/ToolCallDisplay.js +20 -5
  24. package/dist/cli-new/components/ToolCallDisplay.js.map +1 -1
  25. package/dist/cli-new/components/WizardSteps.js +22 -0
  26. package/dist/cli-new/components/WizardSteps.js.map +1 -0
  27. package/dist/cli-new/constants/SetupConstants.js +42 -0
  28. package/dist/cli-new/constants/SetupConstants.js.map +1 -0
  29. package/dist/cli-new/hooks/useGit.js +19 -62
  30. package/dist/cli-new/hooks/useGit.js.map +1 -1
  31. package/dist/cli-new/hooks/useMarie.js +26 -18
  32. package/dist/cli-new/hooks/useMarie.js.map +1 -1
  33. package/dist/cli-new/hooks/useSessions.js +1 -1
  34. package/dist/cli-new/hooks/useSessions.js.map +1 -1
  35. package/dist/cli-new/hooks/useSetupWizard.js +88 -0
  36. package/dist/cli-new/hooks/useSetupWizard.js.map +1 -0
  37. package/dist/cli-new/hooks/useUpdateCheck.js +4 -3
  38. package/dist/cli-new/hooks/useUpdateCheck.js.map +1 -1
  39. package/dist/cli-new/index.js +2 -4
  40. package/dist/cli-new/index.js.map +1 -1
  41. package/dist/cli-new/services/CommandService.js +104 -0
  42. package/dist/cli-new/services/CommandService.js.map +1 -0
  43. package/dist/cli-new/services/GitService.js +91 -0
  44. package/dist/cli-new/services/GitService.js.map +1 -0
  45. package/dist/cli-new/services/MarieService.js +77 -0
  46. package/dist/cli-new/services/MarieService.js.map +1 -0
  47. package/dist/cli-new/services/auth-server.js +128 -0
  48. package/dist/cli-new/services/auth-server.js.map +1 -0
  49. package/dist/cli-new/styles/theme.js +17 -17
  50. package/dist/cli-new/styles/theme.js.map +1 -1
  51. package/dist/cli-new/utils/version.js +24 -0
  52. package/dist/cli-new/utils/version.js.map +1 -0
  53. package/dist/monolith/adapters/CliMarieAdapter.js +19 -18
  54. package/dist/monolith/adapters/CliMarieAdapter.js.map +1 -1
  55. package/dist/monolith/cli/CliFileSystemPort.js +17 -3
  56. package/dist/monolith/cli/CliFileSystemPort.js.map +1 -1
  57. package/dist/monolith/cli/MarieToolDefinitionsCLI.js +44 -33
  58. package/dist/monolith/cli/MarieToolDefinitionsCLI.js.map +1 -1
  59. package/dist/monolith/cli/index.js +11 -20
  60. package/dist/monolith/cli/index.js.map +1 -1
  61. package/dist/monolith/cli/services/JoyAutomationServiceCLI.js +15 -62
  62. package/dist/monolith/cli/services/JoyAutomationServiceCLI.js.map +1 -1
  63. package/dist/monolith/cli/storage.js +154 -65
  64. package/dist/monolith/cli/storage.js.map +1 -1
  65. package/dist/monolith/domain/joy/RitualService.js +44 -46
  66. package/dist/monolith/domain/joy/RitualService.js.map +1 -1
  67. package/dist/monolith/domain/marie/MarieCortex.js +148 -0
  68. package/dist/monolith/domain/marie/MarieCortex.js.map +1 -0
  69. package/dist/monolith/domain/marie/PersonalityRenderer.js +97 -0
  70. package/dist/monolith/domain/marie/PersonalityRenderer.js.map +1 -0
  71. package/dist/monolith/infrastructure/Configuration.js +68 -0
  72. package/dist/monolith/infrastructure/Configuration.js.map +1 -0
  73. package/dist/monolith/infrastructure/CoreInfrastructure.js +204 -0
  74. package/dist/monolith/infrastructure/CoreInfrastructure.js.map +1 -0
  75. package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js +3 -3
  76. package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js.map +1 -1
  77. package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js +51 -57
  78. package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js.map +1 -1
  79. package/dist/monolith/infrastructure/ai/context/ContextManager.js +142 -98
  80. package/dist/monolith/infrastructure/ai/context/ContextManager.js.map +1 -1
  81. package/dist/monolith/infrastructure/ai/core/MarieEngine.js +104 -556
  82. package/dist/monolith/infrastructure/ai/core/MarieEngine.js.map +1 -1
  83. package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js +1 -37
  84. package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js.map +1 -1
  85. package/dist/monolith/infrastructure/ai/core/MarieLockManager.js +30 -5
  86. package/dist/monolith/infrastructure/ai/core/MarieLockManager.js.map +1 -1
  87. package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js +176 -196
  88. package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js.map +1 -1
  89. package/dist/monolith/infrastructure/ai/core/MariePulseService.js +41 -7
  90. package/dist/monolith/infrastructure/ai/core/MariePulseService.js.map +1 -1
  91. package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js +303 -63
  92. package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js.map +1 -1
  93. package/dist/monolith/infrastructure/ai/core/MarieSemaphore.js +47 -4
  94. package/dist/monolith/infrastructure/ai/core/MarieSemaphore.js.map +1 -1
  95. package/dist/monolith/infrastructure/ai/core/MarieSession.js +95 -15
  96. package/dist/monolith/infrastructure/ai/core/MarieSession.js.map +1 -1
  97. package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js +21 -0
  98. package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js.map +1 -1
  99. package/dist/monolith/infrastructure/ai/core/MarieToolMender.js +12 -0
  100. package/dist/monolith/infrastructure/ai/core/MarieToolMender.js.map +1 -1
  101. package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js +339 -481
  102. package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js.map +1 -1
  103. package/dist/monolith/infrastructure/ai/core/MarieVitality.js +238 -0
  104. package/dist/monolith/infrastructure/ai/core/MarieVitality.js.map +1 -0
  105. package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js +23 -12
  106. package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js.map +1 -1
  107. package/dist/monolith/infrastructure/ai/core/SessionLogService.js +9 -2
  108. package/dist/monolith/infrastructure/ai/core/SessionLogService.js.map +1 -1
  109. package/dist/monolith/infrastructure/ai/providers/AIProvider.js +402 -1
  110. package/dist/monolith/infrastructure/ai/providers/AIProvider.js.map +1 -1
  111. package/dist/monolith/infrastructure/ai/providers/DreamBeesProvider.js +114 -0
  112. package/dist/monolith/infrastructure/ai/providers/DreamBeesProvider.js.map +1 -0
  113. package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js +426 -370
  114. package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js.map +1 -1
  115. package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js +235 -241
  116. package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js.map +1 -1
  117. package/dist/monolith/infrastructure/ai/workerAi.js +185 -0
  118. package/dist/monolith/infrastructure/ai/workerAi.js.map +1 -0
  119. package/dist/monolith/infrastructure/config/ConfigService.js +216 -359
  120. package/dist/monolith/infrastructure/config/ConfigService.js.map +1 -1
  121. package/dist/monolith/infrastructure/joy/CognitiveRituals.js +8 -0
  122. package/dist/monolith/infrastructure/joy/CognitiveRituals.js.map +1 -0
  123. package/dist/monolith/infrastructure/joy/JoyTools.js +23 -43
  124. package/dist/monolith/infrastructure/joy/JoyTools.js.map +1 -1
  125. package/dist/monolith/infrastructure/persistence/MarieMindAutonomics.js +4 -0
  126. package/dist/monolith/infrastructure/persistence/MarieMindAutonomics.js.map +1 -0
  127. package/dist/monolith/infrastructure/persistence/MarieMindEngine.js +11 -0
  128. package/dist/monolith/infrastructure/persistence/MarieMindEngine.js.map +1 -0
  129. package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js +135 -0
  130. package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js.map +1 -0
  131. package/dist/monolith/infrastructure/persistence/NoormmeEngine.js +523 -0
  132. package/dist/monolith/infrastructure/persistence/NoormmeEngine.js.map +1 -0
  133. package/dist/monolith/infrastructure/persistence/NoormmeSchema.js +179 -0
  134. package/dist/monolith/infrastructure/persistence/NoormmeSchema.js.map +1 -0
  135. package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js +94 -0
  136. package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js.map +1 -0
  137. package/dist/monolith/infrastructure/persistence/NoormmeTools.js +371 -0
  138. package/dist/monolith/infrastructure/persistence/NoormmeTools.js.map +1 -0
  139. package/dist/monolith/infrastructure/services/MarieMemoryStore.js +133 -134
  140. package/dist/monolith/infrastructure/services/MarieMemoryStore.js.map +1 -1
  141. package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js +6 -1578
  142. package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js.map +1 -1
  143. package/dist/monolith/infrastructure/tools/PureStreamParser.js +68 -80
  144. package/dist/monolith/infrastructure/tools/PureStreamParser.js.map +1 -1
  145. package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js +12 -11
  146. package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js.map +1 -1
  147. package/dist/monolith/infrastructure/tools/SovereignTools.js +326 -0
  148. package/dist/monolith/infrastructure/tools/SovereignTools.js.map +1 -0
  149. package/dist/monolith/infrastructure/tools/ToolRegistry.js +45 -26
  150. package/dist/monolith/infrastructure/tools/ToolRegistry.js.map +1 -1
  151. package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js +232 -0
  152. package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js.map +1 -0
  153. package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js +274 -0
  154. package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js.map +1 -0
  155. package/dist/monolith/infrastructure/tools/definitions/ContextTools.js +71 -0
  156. package/dist/monolith/infrastructure/tools/definitions/ContextTools.js.map +1 -0
  157. package/dist/monolith/infrastructure/tools/definitions/CoreTools.js +37 -0
  158. package/dist/monolith/infrastructure/tools/definitions/CoreTools.js.map +1 -0
  159. package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js +154 -0
  160. package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js.map +1 -0
  161. package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js +197 -0
  162. package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js.map +1 -0
  163. package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js +300 -0
  164. package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js.map +1 -0
  165. package/dist/monolith/plumbing/Plumbing.js +238 -0
  166. package/dist/monolith/plumbing/Plumbing.js.map +1 -0
  167. package/dist/monolith/plumbing/PlumbingAnalysis.js +109 -0
  168. package/dist/monolith/plumbing/PlumbingAnalysis.js.map +1 -0
  169. package/dist/monolith/plumbing/PlumbingSystem.js +169 -0
  170. package/dist/monolith/plumbing/PlumbingSystem.js.map +1 -0
  171. package/dist/monolith/plumbing/analysis/ComplexityService.js +30 -34
  172. package/dist/monolith/plumbing/analysis/ComplexityService.js.map +1 -1
  173. package/dist/monolith/plumbing/analysis/DependencyService.js +55 -44
  174. package/dist/monolith/plumbing/analysis/DependencyService.js.map +1 -1
  175. package/dist/monolith/plumbing/analysis/DiscoveryService.js +40 -42
  176. package/dist/monolith/plumbing/analysis/DiscoveryService.js.map +1 -1
  177. package/dist/monolith/plumbing/analysis/JoyMapService.js +52 -56
  178. package/dist/monolith/plumbing/analysis/JoyMapService.js.map +1 -1
  179. package/dist/monolith/plumbing/analysis/LintService.js +118 -118
  180. package/dist/monolith/plumbing/analysis/LintService.js.map +1 -1
  181. package/dist/monolith/plumbing/analysis/MarieSentinelService.js +278 -269
  182. package/dist/monolith/plumbing/analysis/MarieSentinelService.js.map +1 -1
  183. package/dist/monolith/plumbing/analysis/QualityGuardrailService.js +116 -114
  184. package/dist/monolith/plumbing/analysis/QualityGuardrailService.js.map +1 -1
  185. package/dist/monolith/plumbing/analysis/SurgicalMender.js +57 -59
  186. package/dist/monolith/plumbing/analysis/SurgicalMender.js.map +1 -1
  187. package/dist/monolith/plumbing/analysis/TestService.js +89 -89
  188. package/dist/monolith/plumbing/analysis/TestService.js.map +1 -1
  189. package/dist/monolith/plumbing/filesystem/FileService.js +123 -195
  190. package/dist/monolith/plumbing/filesystem/FileService.js.map +1 -1
  191. package/dist/monolith/plumbing/filesystem/PathResolver.js +7 -8
  192. package/dist/monolith/plumbing/filesystem/PathResolver.js.map +1 -1
  193. package/dist/monolith/plumbing/git/GitService.js +4 -4
  194. package/dist/monolith/plumbing/git/GitService.js.map +1 -1
  195. package/dist/monolith/plumbing/lsp/SymbolService.js +5 -34
  196. package/dist/monolith/plumbing/lsp/SymbolService.js.map +1 -1
  197. package/dist/monolith/plumbing/terminal/ProcessRegistry.js +20 -22
  198. package/dist/monolith/plumbing/terminal/ProcessRegistry.js.map +1 -1
  199. package/dist/monolith/plumbing/terminal/TerminalService.js +127 -136
  200. package/dist/monolith/plumbing/terminal/TerminalService.js.map +1 -1
  201. package/dist/monolith/plumbing/utils/EnvironmentUtils.js +3 -23
  202. package/dist/monolith/plumbing/utils/EnvironmentUtils.js.map +1 -1
  203. package/dist/monolith/plumbing/utils/JsonUtils.js +252 -311
  204. package/dist/monolith/plumbing/utils/JsonUtils.js.map +1 -1
  205. package/dist/monolith/plumbing/utils/MutexUtils.js.map +1 -1
  206. package/dist/monolith/plumbing/utils/PlumbingCore.js +549 -0
  207. package/dist/monolith/plumbing/utils/PlumbingCore.js.map +1 -0
  208. package/dist/monolith/plumbing/utils/PrefixTree.js +61 -114
  209. package/dist/monolith/plumbing/utils/PrefixTree.js.map +1 -1
  210. package/dist/monolith/plumbing/utils/StreamTagDetector.js +89 -127
  211. package/dist/monolith/plumbing/utils/StreamTagDetector.js.map +1 -1
  212. package/dist/monolith/plumbing/utils/StringUtils.js +87 -89
  213. package/dist/monolith/plumbing/utils/StringUtils.js.map +1 -1
  214. package/dist/monolith/runtime/MarieRuntime.js +76 -417
  215. package/dist/monolith/runtime/MarieRuntime.js.map +1 -1
  216. package/dist/monolith/runtime/RuntimeAdapterBase.js +1 -1
  217. package/dist/monolith/runtime/RuntimeAdapterBase.js.map +1 -1
  218. package/dist/monolith/runtime/providerFactory.js +1 -7
  219. package/dist/monolith/runtime/providerFactory.js.map +1 -1
  220. package/dist/monolith/services/HealthService.js +29 -32
  221. package/dist/monolith/services/HealthService.js.map +1 -1
  222. package/dist/monolith/services/JoyAutomationService.js +58 -95
  223. package/dist/monolith/services/JoyAutomationService.js.map +1 -1
  224. package/dist/monolith/services/MarieAutomationService.js +59 -0
  225. package/dist/monolith/services/MarieAutomationService.js.map +1 -0
  226. package/dist/monolith/services/MarieGhostService.js +46 -161
  227. package/dist/monolith/services/MarieGhostService.js.map +1 -1
  228. package/dist/monolith/services/MarieServices.js +102 -0
  229. package/dist/monolith/services/MarieServices.js.map +1 -0
  230. package/dist/monolith/services/MarieTypes.js +2 -0
  231. package/dist/monolith/services/MarieTypes.js.map +1 -0
  232. package/dist/monolith/services/UpdateService.js +47 -49
  233. package/dist/monolith/services/UpdateService.js.map +1 -1
  234. package/dist/prompts.js +11 -5
  235. package/dist/prompts.js.map +1 -1
  236. package/dist/test_prefix_tree.js +9 -9
  237. package/dist/test_prefix_tree.js.map +1 -1
  238. package/package.json +18 -88
  239. package/run_test.js +5 -0
  240. package/.marie_visual_verify_1771225696548/progress_bar_check.txt +0 -1
  241. package/dist/extension.cjs +0 -635
  242. package/dist/extension.js +0 -473
  243. package/dist/extension.js.map +0 -1
  244. package/dist/monolith/adapters/VscodeMarieAdapter.js +0 -81
  245. package/dist/monolith/adapters/VscodeMarieAdapter.js.map +0 -1
  246. package/dist/monolith/domain/joy/JoyTools.js +0 -535
  247. package/dist/monolith/domain/joy/JoyTools.js.map +0 -1
  248. package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js +0 -207
  249. package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js.map +0 -1
  250. package/dist/monolith/infrastructure/ai/core/GhostPort.js +0 -2
  251. package/dist/monolith/infrastructure/ai/core/GhostPort.js.map +0 -1
  252. package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js +0 -2
  253. package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js.map +0 -1
  254. package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js +0 -33
  255. package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js.map +0 -1
  256. package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js +0 -148
  257. package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js.map +0 -1
  258. package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js +0 -208
  259. package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js.map +0 -1
  260. package/dist/monolith/plumbing/ui/DecorationService.js +0 -54
  261. package/dist/monolith/plumbing/ui/DecorationService.js.map +0 -1
  262. package/dist/monolith/services/JoyLogService.js +0 -48
  263. package/dist/monolith/services/JoyLogService.js.map +0 -1
  264. package/dist/monolith/services/JoyService.js +0 -209
  265. package/dist/monolith/services/JoyService.js.map +0 -1
  266. package/dist/monolith/services/MarieSCMProvider.js +0 -41
  267. package/dist/monolith/services/MarieSCMProvider.js.map +0 -1
  268. package/dist/test_agent_stream_control_plane.js +0 -170
  269. package/dist/test_agent_stream_control_plane.js.map +0 -1
  270. package/dist/test_strategy_integration.js +0 -114
  271. package/dist/test_strategy_integration.js.map +0 -1
  272. package/dist/test_streaming_fragility.js +0 -191
  273. package/dist/test_streaming_fragility.js.map +0 -1
  274. package/dist/webview-ui/App.js +0 -16
  275. package/dist/webview-ui/App.js.map +0 -1
  276. package/dist/webview-ui/Providers.js +0 -6
  277. package/dist/webview-ui/Providers.js.map +0 -1
  278. package/dist/webview-ui/components/ApprovalPanel.js +0 -8
  279. package/dist/webview-ui/components/ApprovalPanel.js.map +0 -1
  280. package/dist/webview-ui/components/ChatPanel.js +0 -19
  281. package/dist/webview-ui/components/ChatPanel.js.map +0 -1
  282. package/dist/webview-ui/components/Composer.js +0 -19
  283. package/dist/webview-ui/components/Composer.js.map +0 -1
  284. package/dist/webview-ui/components/HeaderBar.js +0 -5
  285. package/dist/webview-ui/components/HeaderBar.js.map +0 -1
  286. package/dist/webview-ui/components/SessionList.js +0 -14
  287. package/dist/webview-ui/components/SessionList.js.map +0 -1
  288. package/dist/webview-ui/context/WebviewStateContext.js +0 -146
  289. package/dist/webview-ui/context/WebviewStateContext.js.map +0 -1
  290. package/dist/webview-ui/main.css +0 -1
  291. package/dist/webview-ui/main.js +0 -108
  292. package/dist/webview-ui/main.js.map +0 -1
  293. package/dist/webview-ui/types.js +0 -2
  294. package/dist/webview-ui/types.js.map +0 -1
  295. package/dist/webview-ui/vscode.js +0 -4
  296. package/dist/webview-ui/vscode.js.map +0 -1
  297. package/lint_output.txt +0 -705
  298. package/lint_output_v2.txt +0 -711
  299. package/marie-coder-0.1.16.vsix +0 -0
@@ -1,118 +1,162 @@
1
- import * as vscode from "vscode";
2
- import { ConfigService } from "../../config/ConfigService.js";
1
+ import { getModel, getMaxContextTokens, getKeepRecentMessages, getTokensPerChar, } from "../../config/ConfigService.js";
3
2
  import { SUMMARIZATION_SYSTEM_PROMPT, SUMMARIZATION_USER_PROMPT, } from "../../../../prompts.js";
4
3
  import { getErrorMessage } from "../../../plumbing/utils/ErrorUtils.js";
5
- import { StringUtils } from "../../../plumbing/utils/StringUtils.js";
6
- export class ContextManager {
7
- static estimateTokens(text, tokensPerChar) {
8
- return Math.ceil(text.length * tokensPerChar);
9
- }
10
- /**
11
- * Recursively estimates tokens in an object without JSON.stringify serialization.
12
- * Prevents massive GC spikes for large objects (e.g. file content).
13
- */
14
- static estimateObjectTokens(obj, tokensPerChar, depth = 0) {
15
- if (!obj || depth > 10)
16
- return 0;
17
- if (typeof obj === "string")
18
- return this.estimateTokens(obj, tokensPerChar);
19
- if (typeof obj === "number" || typeof obj === "boolean")
20
- return 1;
21
- let total = 0;
4
+ import { extractText } from "../../../plumbing/utils/StringUtils.js";
5
+ import { safeSpread, safeGetKeys, safeGetEntries, } from "../core/MarieSanitizer.js";
6
+ function estimateTokens(text, tokensPerChar) {
7
+ return Math.ceil(text.length * tokensPerChar);
8
+ }
9
+ /**
10
+ * Recursively estimates tokens in an object without JSON.stringify serialization.
11
+ * Prevents massive GC spikes for large objects (e.g. file content).
12
+ */
13
+ function estimateObjectTokens(obj, tokensPerChar, depth = 0) {
14
+ if (!obj || depth > 10)
15
+ return 0;
16
+ if (typeof obj === "string")
17
+ return estimateTokens(obj, tokensPerChar);
18
+ if (typeof obj === "number" || typeof obj === "boolean")
19
+ return 1;
20
+ let total = 0;
21
+ try {
22
22
  if (Array.isArray(obj)) {
23
- for (const item of obj) {
24
- total += this.estimateObjectTokens(item, tokensPerChar, depth + 1);
23
+ // Limit array breadth for estimation
24
+ const limitedArr = obj.slice(0, 100);
25
+ for (const item of limitedArr) {
26
+ total += estimateObjectTokens(item, tokensPerChar, depth + 1);
25
27
  }
26
28
  }
27
29
  else if (typeof obj === "object") {
28
- for (const key in obj) {
29
- total += this.estimateTokens(key, tokensPerChar); // Key tokens
30
- total += this.estimateObjectTokens(obj[key], tokensPerChar, depth + 1); // Value tokens
30
+ const safeObj = safeSpread(obj);
31
+ // Use safeGetKeys to avoid engine-level enumeration explosion
32
+ const keys = safeGetKeys(safeObj, 100);
33
+ for (const key of keys) {
34
+ total += estimateTokens(key, tokensPerChar); // Key tokens
35
+ total += estimateObjectTokens(safeObj[key], tokensPerChar, depth + 1); // Value tokens
31
36
  }
32
37
  }
33
- return total;
34
38
  }
35
- static getMessageTokens(message, tokensPerChar) {
36
- if (typeof message.content === "string") {
37
- return this.estimateTokens(message.content, tokensPerChar);
38
- }
39
- else if (Array.isArray(message.content)) {
40
- return message.content.reduce((acc, block) => {
41
- if (block.type === "text") {
42
- return acc + this.estimateTokens(block.text, tokensPerChar);
43
- }
44
- if (block.type === "tool_use") {
45
- return acc + this.estimateObjectTokens(block.input, tokensPerChar, 0);
46
- }
47
- if (block.type === "tool_result") {
48
- // optimized: avoid JSON.stringify if content is string
49
- if (typeof block.content === "string") {
50
- return acc + this.estimateTokens(block.content, tokensPerChar);
51
- }
52
- return (acc + this.estimateObjectTokens(block.content, tokensPerChar, 0));
39
+ catch (e) {
40
+ // Ignore enumeration errors during estimation
41
+ }
42
+ return total;
43
+ }
44
+ function getMessageTokens(message, tokensPerChar) {
45
+ if (typeof message.content === "string") {
46
+ return estimateTokens(message.content, tokensPerChar);
47
+ }
48
+ else if (Array.isArray(message.content)) {
49
+ return message.content.reduce((acc, block) => {
50
+ if (block.type === "text") {
51
+ return acc + estimateTokens(block.text, tokensPerChar);
52
+ }
53
+ if (block.type === "tool_use") {
54
+ return acc + estimateObjectTokens(block.input, tokensPerChar, 0);
55
+ }
56
+ if (block.type === "tool_result") {
57
+ // optimized: avoid JSON.stringify if content is string
58
+ if (typeof block.content === "string") {
59
+ return acc + estimateTokens(block.content, tokensPerChar);
53
60
  }
54
- return acc;
55
- }, 0);
56
- }
57
- return 0;
61
+ return acc + estimateObjectTokens(block.content, tokensPerChar, 0);
62
+ }
63
+ return acc;
64
+ }, 0);
58
65
  }
59
- static getTotalTokens(messages, tokensPerChar) {
60
- return messages.reduce((acc, msg) => acc + this.getMessageTokens(msg, tokensPerChar), 0);
66
+ return 0;
67
+ }
68
+ function getTotalTokens(messages, tokensPerChar) {
69
+ return messages.reduce((acc, msg) => acc + getMessageTokens(msg, tokensPerChar), 0);
70
+ }
71
+ export async function manageContext(messages, provider, state) {
72
+ const maxTokens = getMaxContextTokens();
73
+ const tokensPerChar = getTokensPerChar(); // Hoisted config access
74
+ const currentTokens = getTotalTokens(messages, tokensPerChar);
75
+ // PROACTIVE PRUNING: Summarize at 90% capacity to ensure zero 400 errors
76
+ if (currentTokens >= maxTokens * 0.9) {
77
+ messages = await summarizeHistory(messages, provider, state, tokensPerChar, currentTokens);
61
78
  }
62
- static async manage(messages, provider, state) {
63
- const maxTokens = ConfigService.getMaxContextTokens();
64
- const tokensPerChar = ConfigService.getTokensPerChar(); // Hoisted config access
65
- const currentTokens = this.getTotalTokens(messages, tokensPerChar);
66
- // PROACTIVE PRUNING: Summarize at 90% capacity to ensure zero 400 errors
67
- if (currentTokens < maxTokens * 0.9) {
79
+ // SPECTRAL MEMORY INJECTION: Retrieve relevant long-term memories
80
+ return await injectSpectralMemories(messages, provider);
81
+ }
82
+ async function injectSpectralMemories(messages, provider) {
83
+ try {
84
+ const lastUserMsg = messages
85
+ .slice()
86
+ .reverse()
87
+ .find((m) => m.role === "user" && typeof m.content === "string");
88
+ if (!lastUserMsg)
68
89
  return messages;
69
- }
70
- vscode.window.showInformationMessage(`Marie is tidying up conversation history (${currentTokens} tokens)...`);
71
- const keepRecent = ConfigService.getKeepRecentMessages();
72
- if (messages.length <= keepRecent) {
90
+ const { getInstance } = await import("../../persistence/NoormmeEngine.js");
91
+ const db = await getInstance();
92
+ if (!db.agent.cortex.vectors)
73
93
  return messages;
74
- }
75
- const olderMessages = messages.slice(0, messages.length - keepRecent);
76
- const recentMessages = messages.slice(messages.length - keepRecent);
77
- try {
78
- const summaryResponse = await provider.createMessage({
79
- model: ConfigService.getModel(),
80
- max_tokens: 1024,
81
- messages: olderMessages.concat({
82
- role: "user",
83
- content: SUMMARIZATION_USER_PROMPT,
84
- }),
85
- system: SUMMARIZATION_SYSTEM_PROMPT,
94
+ const embedding = await provider.createEmbedding(lastUserMsg.content);
95
+ const memories = await db.agent.cortex.vectors.search(embedding, {
96
+ limit: 3,
97
+ });
98
+ if (memories.length > 0) {
99
+ const memoryContext = memories
100
+ .map((m) => `- ${m.content} (Similarity: ${(m.similarity * 100).toFixed(1)}%)`)
101
+ .join("\n");
102
+ const injectedMessages = [...messages];
103
+ injectedMessages.splice(messages.length - 1, 0, {
104
+ role: "user",
105
+ content: `[SPECTRAL MEMORIES - STRATEGIC CONTEXT]\n${memoryContext}\n\n(Use these memories to inform your response if relevant. Do not mention "Spectral Memories" to the user unless they ask.)`,
106
+ virtual: true,
86
107
  });
87
- const summaryText = StringUtils.extractText(summaryResponse.content) ||
88
- "Summary unavailable.";
89
- // Ascension Preservation: Prepend state snapshot to the summary so it survives compression
90
- let ascensionNote = "";
91
- if (state) {
92
- const hotspots = Object.entries(state.errorHotspots)
93
- .filter(([_, c]) => c >= 2)
94
- .map(([f, c]) => `${f}(${c}x)`)
95
- .join(", ");
96
- const strategy = state.lastDecree?.strategy || "EXECUTE";
97
- const strategyReason = state.lastDecree?.reason || "None";
98
- ascensionNote = `[ASCENSION STATE] Strategy: ${strategy}, Mood: ${state.mood}, Spirit Pressure (Flow): ${state.spiritPressure}/100, Victory Streak: ${state.victoryStreak}${hotspots ? `, Hotspots: ${hotspots}` : ""}, Last Intent: ${strategyReason}\n\n`;
99
- }
100
- const newHistory = [
101
- {
102
- role: "user",
103
- content: `[System Note: Previous conversation summary]\n${ascensionNote}${summaryText}`,
104
- },
105
- ...recentMessages,
106
- ];
107
- vscode.window.showInformationMessage(`Marie finished tidying. Tokens reduced from ${currentTokens} to ${this.getTotalTokens(newHistory, tokensPerChar)}.`);
108
- return newHistory;
108
+ return injectedMessages;
109
109
  }
110
- catch (error) {
111
- const message = getErrorMessage(error);
112
- console.error("Context summarization failed:", message);
113
- vscode.window.showErrorMessage(`Failed to summarize conversation: ${message}. Continuing with full history.`);
114
- return messages;
110
+ }
111
+ catch (e) {
112
+ console.warn("[ContextManager] Failed to inject spectral memories", e);
113
+ }
114
+ return messages;
115
+ }
116
+ async function summarizeHistory(messages, provider, state, tokensPerChar, currentTokens) {
117
+ console.log(`[Marie] Tidying up conversation history (${currentTokens} tokens)...`);
118
+ const keepRecent = getKeepRecentMessages();
119
+ if (messages.length <= keepRecent) {
120
+ return messages;
121
+ }
122
+ const olderMessages = messages.slice(0, messages.length - keepRecent);
123
+ const recentMessages = messages.slice(messages.length - keepRecent);
124
+ try {
125
+ const summaryResponse = await provider.createMessage({
126
+ model: getModel(),
127
+ max_tokens: 1024,
128
+ messages: olderMessages.concat({
129
+ role: "user",
130
+ content: SUMMARIZATION_USER_PROMPT,
131
+ }),
132
+ system: SUMMARIZATION_SYSTEM_PROMPT,
133
+ });
134
+ const summaryText = extractText(summaryResponse.content) || "Summary unavailable.";
135
+ // Ascension Preservation: Prepend state snapshot to the summary so it survives compression
136
+ let ascensionNote = "";
137
+ if (state) {
138
+ const hotspots = safeGetEntries(safeSpread(state.errorHotspots), 20)
139
+ .filter(([_, c]) => c >= 2)
140
+ .map(([f, c]) => `${f}(${c}x)`)
141
+ .join(", ");
142
+ const strategy = state.lastDecree?.strategy || "EXECUTE";
143
+ const strategyReason = state.lastDecree?.reason || "None";
144
+ ascensionNote = `[ASCENSION STATE] Strategy: ${strategy}, Mood: ${state.mood}, Transcendence Level: ${state.spiritPressure}/100, Victory Streak: ${state.victoryStreak}${hotspots ? `, Hotspots: ${hotspots}` : ""}, Last Intent: ${strategyReason}\n\n`;
115
145
  }
146
+ const newHistory = [
147
+ {
148
+ role: "user",
149
+ content: `[System Note: Previous conversation summary]\n${ascensionNote}${summaryText}`,
150
+ },
151
+ ...recentMessages,
152
+ ];
153
+ console.log(`[Marie] Finished tidying. Tokens reduced from ${currentTokens} to ${getTotalTokens(newHistory, tokensPerChar)}.`);
154
+ return newHistory;
155
+ }
156
+ catch (error) {
157
+ const message = getErrorMessage(error);
158
+ console.error("[Marie] Context summarization failed:", message);
159
+ return messages;
116
160
  }
117
161
  }
118
162
  //# sourceMappingURL=ContextManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../../../../src/monolith/infrastructure/ai/context/ContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAGrE,MAAM,OAAO,cAAc;IACjB,MAAM,CAAC,cAAc,CAAC,IAAY,EAAE,aAAqB;QAC/D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,oBAAoB,CACjC,GAAQ,EACR,aAAqB,EACrB,QAAgB,CAAC;QAEjB,IAAI,CAAC,GAAG,IAAI,KAAK,GAAG,EAAE;YAAE,OAAO,CAAC,CAAC;QACjC,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAC5E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QAElE,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;gBAC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AI,6BAA6B,KAAK,CAAC,cAAc,yBAAyB,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,eAAe,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,kBAAkB,cAAc,MAAM,CAAC;YAC9P,CAAC;YAED,MAAM,UAAU,GAAU;gBACxB;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,iDAAiD,aAAa,GAAG,WAAW,EAAE;iBACxF;gBACD,GAAG,cAAc;aAClB,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAClC,+CAA+C,aAAa,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,CACrH,CAAC;YACF,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;YACvC,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;YACxD,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAC5B,qCAAqC,OAAO,iCAAiC,CAC9E,CAAC;YACF,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../../../../src/monolith/infrastructure/ai/context/ContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,OAAO,EACL,UAAU,EAEV,WAAW,EACX,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,SAAS,cAAc,CAAC,IAAY,EAAE,aAA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