erosolar-cli 1.7.333 → 1.7.334

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 (323) hide show
  1. package/README.md +148 -24
  2. package/dist/alpha-zero/agentWrapper.d.ts +84 -0
  3. package/dist/alpha-zero/agentWrapper.d.ts.map +1 -0
  4. package/dist/alpha-zero/agentWrapper.js +171 -0
  5. package/dist/alpha-zero/agentWrapper.js.map +1 -0
  6. package/dist/alpha-zero/codeEvaluator.d.ts +25 -0
  7. package/dist/alpha-zero/codeEvaluator.d.ts.map +1 -0
  8. package/dist/alpha-zero/codeEvaluator.js +273 -0
  9. package/dist/alpha-zero/codeEvaluator.js.map +1 -0
  10. package/dist/alpha-zero/competitiveRunner.d.ts +66 -0
  11. package/dist/alpha-zero/competitiveRunner.d.ts.map +1 -0
  12. package/dist/alpha-zero/competitiveRunner.js +224 -0
  13. package/dist/alpha-zero/competitiveRunner.js.map +1 -0
  14. package/dist/alpha-zero/index.d.ts +67 -0
  15. package/dist/alpha-zero/index.d.ts.map +1 -0
  16. package/dist/alpha-zero/index.js +99 -0
  17. package/dist/alpha-zero/index.js.map +1 -0
  18. package/dist/alpha-zero/introspection.d.ts +128 -0
  19. package/dist/alpha-zero/introspection.d.ts.map +1 -0
  20. package/dist/alpha-zero/introspection.js +300 -0
  21. package/dist/alpha-zero/introspection.js.map +1 -0
  22. package/dist/alpha-zero/metricsTracker.d.ts +71 -0
  23. package/dist/alpha-zero/metricsTracker.d.ts.map +1 -0
  24. package/dist/{core → alpha-zero}/metricsTracker.js +5 -2
  25. package/dist/alpha-zero/metricsTracker.js.map +1 -0
  26. package/dist/alpha-zero/security/core.d.ts +125 -0
  27. package/dist/alpha-zero/security/core.d.ts.map +1 -0
  28. package/dist/alpha-zero/security/core.js +271 -0
  29. package/dist/alpha-zero/security/core.js.map +1 -0
  30. package/dist/alpha-zero/security/google.d.ts +125 -0
  31. package/dist/alpha-zero/security/google.d.ts.map +1 -0
  32. package/dist/alpha-zero/security/google.js +311 -0
  33. package/dist/alpha-zero/security/google.js.map +1 -0
  34. package/dist/alpha-zero/security/googleLoader.d.ts +17 -0
  35. package/dist/alpha-zero/security/googleLoader.d.ts.map +1 -0
  36. package/dist/alpha-zero/security/googleLoader.js +41 -0
  37. package/dist/alpha-zero/security/googleLoader.js.map +1 -0
  38. package/dist/alpha-zero/security/index.d.ts +29 -0
  39. package/dist/alpha-zero/security/index.d.ts.map +1 -0
  40. package/dist/alpha-zero/security/index.js +32 -0
  41. package/dist/alpha-zero/security/index.js.map +1 -0
  42. package/dist/alpha-zero/security/simulation.d.ts +124 -0
  43. package/dist/alpha-zero/security/simulation.d.ts.map +1 -0
  44. package/dist/alpha-zero/security/simulation.js +277 -0
  45. package/dist/alpha-zero/security/simulation.js.map +1 -0
  46. package/dist/alpha-zero/selfModification.d.ts +109 -0
  47. package/dist/alpha-zero/selfModification.d.ts.map +1 -0
  48. package/dist/alpha-zero/selfModification.js +233 -0
  49. package/dist/alpha-zero/selfModification.js.map +1 -0
  50. package/dist/alpha-zero/types.d.ts +170 -0
  51. package/dist/alpha-zero/types.d.ts.map +1 -0
  52. package/dist/alpha-zero/types.js +31 -0
  53. package/dist/alpha-zero/types.js.map +1 -0
  54. package/dist/bin/erosolar.js +21 -5
  55. package/dist/bin/erosolar.js.map +1 -1
  56. package/dist/capabilities/agentSpawningCapability.d.ts.map +1 -1
  57. package/dist/capabilities/agentSpawningCapability.js +31 -56
  58. package/dist/capabilities/agentSpawningCapability.js.map +1 -1
  59. package/dist/capabilities/securityTestingCapability.d.ts +13 -0
  60. package/dist/capabilities/securityTestingCapability.d.ts.map +1 -0
  61. package/dist/capabilities/securityTestingCapability.js +25 -0
  62. package/dist/capabilities/securityTestingCapability.js.map +1 -0
  63. package/dist/contracts/agent-schemas.json +15 -0
  64. package/dist/contracts/tools.schema.json +9 -0
  65. package/dist/core/agent.d.ts +2 -2
  66. package/dist/core/agent.d.ts.map +1 -1
  67. package/dist/core/agent.js.map +1 -1
  68. package/dist/core/aiFlowOptimizer.d.ts +26 -0
  69. package/dist/core/aiFlowOptimizer.d.ts.map +1 -0
  70. package/dist/core/aiFlowOptimizer.js +31 -0
  71. package/dist/core/aiFlowOptimizer.js.map +1 -0
  72. package/dist/core/aiOptimizationEngine.d.ts +158 -0
  73. package/dist/core/aiOptimizationEngine.d.ts.map +1 -0
  74. package/dist/core/aiOptimizationEngine.js +428 -0
  75. package/dist/core/aiOptimizationEngine.js.map +1 -0
  76. package/dist/core/aiOptimizationIntegration.d.ts +93 -0
  77. package/dist/core/aiOptimizationIntegration.d.ts.map +1 -0
  78. package/dist/core/aiOptimizationIntegration.js +250 -0
  79. package/dist/core/aiOptimizationIntegration.js.map +1 -0
  80. package/dist/core/customCommands.d.ts +0 -1
  81. package/dist/core/customCommands.d.ts.map +1 -1
  82. package/dist/core/customCommands.js +0 -3
  83. package/dist/core/customCommands.js.map +1 -1
  84. package/dist/core/enhancedErrorRecovery.d.ts +100 -0
  85. package/dist/core/enhancedErrorRecovery.d.ts.map +1 -0
  86. package/dist/core/enhancedErrorRecovery.js +345 -0
  87. package/dist/core/enhancedErrorRecovery.js.map +1 -0
  88. package/dist/core/hooksSystem.d.ts +65 -0
  89. package/dist/core/hooksSystem.d.ts.map +1 -0
  90. package/dist/core/hooksSystem.js +273 -0
  91. package/dist/core/hooksSystem.js.map +1 -0
  92. package/dist/core/memorySystem.d.ts +48 -0
  93. package/dist/core/memorySystem.d.ts.map +1 -0
  94. package/dist/core/memorySystem.js +271 -0
  95. package/dist/core/memorySystem.js.map +1 -0
  96. package/dist/core/toolPreconditions.d.ts.map +1 -1
  97. package/dist/core/toolPreconditions.js +14 -0
  98. package/dist/core/toolPreconditions.js.map +1 -1
  99. package/dist/core/toolRuntime.d.ts +1 -22
  100. package/dist/core/toolRuntime.d.ts.map +1 -1
  101. package/dist/core/toolRuntime.js +5 -0
  102. package/dist/core/toolRuntime.js.map +1 -1
  103. package/dist/core/toolValidation.d.ts.map +1 -1
  104. package/dist/core/toolValidation.js +3 -14
  105. package/dist/core/toolValidation.js.map +1 -1
  106. package/dist/core/unified/errors.d.ts +189 -0
  107. package/dist/core/unified/errors.d.ts.map +1 -0
  108. package/dist/core/unified/errors.js +497 -0
  109. package/dist/core/unified/errors.js.map +1 -0
  110. package/dist/core/unified/index.d.ts +19 -0
  111. package/dist/core/unified/index.d.ts.map +1 -0
  112. package/dist/core/unified/index.js +68 -0
  113. package/dist/core/unified/index.js.map +1 -0
  114. package/dist/core/unified/schema.d.ts +101 -0
  115. package/dist/core/unified/schema.d.ts.map +1 -0
  116. package/dist/core/unified/schema.js +350 -0
  117. package/dist/core/unified/schema.js.map +1 -0
  118. package/dist/core/unified/toolRuntime.d.ts +179 -0
  119. package/dist/core/unified/toolRuntime.d.ts.map +1 -0
  120. package/dist/core/unified/toolRuntime.js +517 -0
  121. package/dist/core/unified/toolRuntime.js.map +1 -0
  122. package/dist/core/unified/tools.d.ts +127 -0
  123. package/dist/core/unified/tools.d.ts.map +1 -0
  124. package/dist/core/unified/tools.js +1333 -0
  125. package/dist/core/unified/tools.js.map +1 -0
  126. package/dist/core/unified/types.d.ts +352 -0
  127. package/dist/core/unified/types.d.ts.map +1 -0
  128. package/dist/core/unified/types.js +12 -0
  129. package/dist/core/unified/types.js.map +1 -0
  130. package/dist/core/unified/version.d.ts +209 -0
  131. package/dist/core/unified/version.d.ts.map +1 -0
  132. package/dist/core/unified/version.js +454 -0
  133. package/dist/core/unified/version.js.map +1 -0
  134. package/dist/core/validationRunner.d.ts +3 -1
  135. package/dist/core/validationRunner.d.ts.map +1 -1
  136. package/dist/core/validationRunner.js.map +1 -1
  137. package/dist/headless/headlessApp.d.ts.map +1 -1
  138. package/dist/headless/headlessApp.js +0 -21
  139. package/dist/headless/headlessApp.js.map +1 -1
  140. package/dist/mcp/sseClient.d.ts.map +1 -1
  141. package/dist/mcp/sseClient.js +18 -9
  142. package/dist/mcp/sseClient.js.map +1 -1
  143. package/dist/plugins/tools/build/buildPlugin.d.ts +6 -0
  144. package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -1
  145. package/dist/plugins/tools/build/buildPlugin.js +10 -4
  146. package/dist/plugins/tools/build/buildPlugin.js.map +1 -1
  147. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  148. package/dist/plugins/tools/nodeDefaults.js +2 -0
  149. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  150. package/dist/plugins/tools/security/securityPlugin.d.ts +3 -0
  151. package/dist/plugins/tools/security/securityPlugin.d.ts.map +1 -0
  152. package/dist/plugins/tools/security/securityPlugin.js +12 -0
  153. package/dist/plugins/tools/security/securityPlugin.js.map +1 -0
  154. package/dist/runtime/agentSession.d.ts +2 -2
  155. package/dist/runtime/agentSession.d.ts.map +1 -1
  156. package/dist/runtime/agentSession.js +2 -2
  157. package/dist/runtime/agentSession.js.map +1 -1
  158. package/dist/security/active-stack-security.d.ts +112 -0
  159. package/dist/security/active-stack-security.d.ts.map +1 -0
  160. package/dist/security/active-stack-security.js +296 -0
  161. package/dist/security/active-stack-security.js.map +1 -0
  162. package/dist/security/advanced-persistence-research.d.ts +92 -0
  163. package/dist/security/advanced-persistence-research.d.ts.map +1 -0
  164. package/dist/security/advanced-persistence-research.js +195 -0
  165. package/dist/security/advanced-persistence-research.js.map +1 -0
  166. package/dist/security/advanced-targeting.d.ts +119 -0
  167. package/dist/security/advanced-targeting.d.ts.map +1 -0
  168. package/dist/security/advanced-targeting.js +233 -0
  169. package/dist/security/advanced-targeting.js.map +1 -0
  170. package/dist/security/assessment/vulnerabilityAssessment.d.ts +104 -0
  171. package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +1 -0
  172. package/dist/security/assessment/vulnerabilityAssessment.js +315 -0
  173. package/dist/security/assessment/vulnerabilityAssessment.js.map +1 -0
  174. package/dist/security/authorization/securityAuthorization.d.ts +88 -0
  175. package/dist/security/authorization/securityAuthorization.d.ts.map +1 -0
  176. package/dist/security/authorization/securityAuthorization.js +172 -0
  177. package/dist/security/authorization/securityAuthorization.js.map +1 -0
  178. package/dist/security/comprehensive-targeting.d.ts +85 -0
  179. package/dist/security/comprehensive-targeting.d.ts.map +1 -0
  180. package/dist/security/comprehensive-targeting.js +438 -0
  181. package/dist/security/comprehensive-targeting.js.map +1 -0
  182. package/dist/security/global-security-integration.d.ts +91 -0
  183. package/dist/security/global-security-integration.d.ts.map +1 -0
  184. package/dist/security/global-security-integration.js +218 -0
  185. package/dist/security/global-security-integration.js.map +1 -0
  186. package/dist/security/index.d.ts +38 -0
  187. package/dist/security/index.d.ts.map +1 -0
  188. package/dist/security/index.js +47 -0
  189. package/dist/security/index.js.map +1 -0
  190. package/dist/security/persistence-analyzer.d.ts +56 -0
  191. package/dist/security/persistence-analyzer.d.ts.map +1 -0
  192. package/dist/security/persistence-analyzer.js +187 -0
  193. package/dist/security/persistence-analyzer.js.map +1 -0
  194. package/dist/security/persistence-cli.d.ts +36 -0
  195. package/dist/security/persistence-cli.d.ts.map +1 -0
  196. package/dist/security/persistence-cli.js +160 -0
  197. package/dist/security/persistence-cli.js.map +1 -0
  198. package/dist/security/persistence-research.d.ts +92 -0
  199. package/dist/security/persistence-research.d.ts.map +1 -0
  200. package/dist/security/persistence-research.js +364 -0
  201. package/dist/security/persistence-research.js.map +1 -0
  202. package/dist/security/research/persistenceResearch.d.ts +97 -0
  203. package/dist/security/research/persistenceResearch.d.ts.map +1 -0
  204. package/dist/security/research/persistenceResearch.js +282 -0
  205. package/dist/security/research/persistenceResearch.js.map +1 -0
  206. package/dist/security/security-integration.d.ts +74 -0
  207. package/dist/security/security-integration.d.ts.map +1 -0
  208. package/dist/security/security-integration.js +137 -0
  209. package/dist/security/security-integration.js.map +1 -0
  210. package/dist/security/security-testing-framework.d.ts +112 -0
  211. package/dist/security/security-testing-framework.d.ts.map +1 -0
  212. package/dist/security/security-testing-framework.js +364 -0
  213. package/dist/security/security-testing-framework.js.map +1 -0
  214. package/dist/security/simulation/attackSimulation.d.ts +93 -0
  215. package/dist/security/simulation/attackSimulation.d.ts.map +1 -0
  216. package/dist/security/simulation/attackSimulation.js +341 -0
  217. package/dist/security/simulation/attackSimulation.js.map +1 -0
  218. package/dist/security/strategic-operations.d.ts +100 -0
  219. package/dist/security/strategic-operations.d.ts.map +1 -0
  220. package/dist/security/strategic-operations.js +276 -0
  221. package/dist/security/strategic-operations.js.map +1 -0
  222. package/dist/security/tool-security-wrapper.d.ts +58 -0
  223. package/dist/security/tool-security-wrapper.d.ts.map +1 -0
  224. package/dist/security/tool-security-wrapper.js +156 -0
  225. package/dist/security/tool-security-wrapper.js.map +1 -0
  226. package/dist/shell/claudeCodeStreamHandler.d.ts +145 -0
  227. package/dist/shell/claudeCodeStreamHandler.d.ts.map +1 -0
  228. package/dist/shell/claudeCodeStreamHandler.js +322 -0
  229. package/dist/shell/claudeCodeStreamHandler.js.map +1 -0
  230. package/dist/shell/inputQueueManager.d.ts +144 -0
  231. package/dist/shell/inputQueueManager.d.ts.map +1 -0
  232. package/dist/shell/inputQueueManager.js +290 -0
  233. package/dist/shell/inputQueueManager.js.map +1 -0
  234. package/dist/shell/interactiveShell.d.ts +7 -16
  235. package/dist/shell/interactiveShell.d.ts.map +1 -1
  236. package/dist/shell/interactiveShell.js +166 -235
  237. package/dist/shell/interactiveShell.js.map +1 -1
  238. package/dist/shell/metricsTracker.d.ts +60 -0
  239. package/dist/shell/metricsTracker.d.ts.map +1 -0
  240. package/dist/shell/metricsTracker.js +119 -0
  241. package/dist/shell/metricsTracker.js.map +1 -0
  242. package/dist/shell/shellApp.d.ts +0 -2
  243. package/dist/shell/shellApp.d.ts.map +1 -1
  244. package/dist/shell/shellApp.js +9 -40
  245. package/dist/shell/shellApp.js.map +1 -1
  246. package/dist/shell/streamingOutputManager.d.ts +115 -0
  247. package/dist/shell/streamingOutputManager.d.ts.map +1 -0
  248. package/dist/shell/streamingOutputManager.js +225 -0
  249. package/dist/shell/streamingOutputManager.js.map +1 -0
  250. package/dist/shell/systemPrompt.d.ts.map +1 -1
  251. package/dist/shell/systemPrompt.js +4 -1
  252. package/dist/shell/systemPrompt.js.map +1 -1
  253. package/dist/shell/terminalInput.d.ts +118 -149
  254. package/dist/shell/terminalInput.d.ts.map +1 -1
  255. package/dist/shell/terminalInput.js +532 -689
  256. package/dist/shell/terminalInput.js.map +1 -1
  257. package/dist/shell/terminalInputAdapter.d.ts +21 -79
  258. package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
  259. package/dist/shell/terminalInputAdapter.js +30 -99
  260. package/dist/shell/terminalInputAdapter.js.map +1 -1
  261. package/dist/subagents/taskRunner.d.ts +1 -7
  262. package/dist/subagents/taskRunner.d.ts.map +1 -1
  263. package/dist/subagents/taskRunner.js +47 -180
  264. package/dist/subagents/taskRunner.js.map +1 -1
  265. package/dist/tools/securityTools.d.ts +22 -0
  266. package/dist/tools/securityTools.d.ts.map +1 -0
  267. package/dist/tools/securityTools.js +448 -0
  268. package/dist/tools/securityTools.js.map +1 -0
  269. package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
  270. package/dist/ui/ShellUIAdapter.js +12 -13
  271. package/dist/ui/ShellUIAdapter.js.map +1 -1
  272. package/dist/ui/display.d.ts +45 -24
  273. package/dist/ui/display.d.ts.map +1 -1
  274. package/dist/ui/display.js +259 -140
  275. package/dist/ui/display.js.map +1 -1
  276. package/dist/ui/persistentPrompt.d.ts +50 -0
  277. package/dist/ui/persistentPrompt.d.ts.map +1 -0
  278. package/dist/ui/persistentPrompt.js +92 -0
  279. package/dist/ui/persistentPrompt.js.map +1 -0
  280. package/dist/ui/terminalUISchema.d.ts +195 -0
  281. package/dist/ui/terminalUISchema.d.ts.map +1 -0
  282. package/dist/ui/terminalUISchema.js +113 -0
  283. package/dist/ui/terminalUISchema.js.map +1 -0
  284. package/dist/ui/theme.d.ts.map +1 -1
  285. package/dist/ui/theme.js +8 -6
  286. package/dist/ui/theme.js.map +1 -1
  287. package/dist/ui/toolDisplay.d.ts +158 -0
  288. package/dist/ui/toolDisplay.d.ts.map +1 -1
  289. package/dist/ui/toolDisplay.js +348 -0
  290. package/dist/ui/toolDisplay.js.map +1 -1
  291. package/dist/ui/unified/layout.d.ts +0 -1
  292. package/dist/ui/unified/layout.d.ts.map +1 -1
  293. package/dist/ui/unified/layout.js +25 -15
  294. package/dist/ui/unified/layout.js.map +1 -1
  295. package/package.json +4 -4
  296. package/scripts/deploy-security-capabilities.js +178 -0
  297. package/dist/core/hooks.d.ts +0 -113
  298. package/dist/core/hooks.d.ts.map +0 -1
  299. package/dist/core/hooks.js +0 -267
  300. package/dist/core/hooks.js.map +0 -1
  301. package/dist/core/metricsTracker.d.ts +0 -122
  302. package/dist/core/metricsTracker.d.ts.map +0 -1
  303. package/dist/core/metricsTracker.js.map +0 -1
  304. package/dist/core/securityAssessment.d.ts +0 -91
  305. package/dist/core/securityAssessment.d.ts.map +0 -1
  306. package/dist/core/securityAssessment.js +0 -580
  307. package/dist/core/securityAssessment.js.map +0 -1
  308. package/dist/core/verification.d.ts +0 -137
  309. package/dist/core/verification.d.ts.map +0 -1
  310. package/dist/core/verification.js +0 -323
  311. package/dist/core/verification.js.map +0 -1
  312. package/dist/subagents/agentConfig.d.ts +0 -27
  313. package/dist/subagents/agentConfig.d.ts.map +0 -1
  314. package/dist/subagents/agentConfig.js +0 -89
  315. package/dist/subagents/agentConfig.js.map +0 -1
  316. package/dist/subagents/agentRegistry.d.ts +0 -33
  317. package/dist/subagents/agentRegistry.d.ts.map +0 -1
  318. package/dist/subagents/agentRegistry.js +0 -162
  319. package/dist/subagents/agentRegistry.js.map +0 -1
  320. package/dist/utils/frontmatter.d.ts +0 -10
  321. package/dist/utils/frontmatter.d.ts.map +0 -1
  322. package/dist/utils/frontmatter.js +0 -78
  323. package/dist/utils/frontmatter.js.map +0 -1
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Hooks System - Event-driven automation for tool execution
3
+ *
4
+ * Implements a Claude Code-style hooks system that runs shell commands
5
+ * in response to tool execution events:
6
+ *
7
+ * - beforeToolExecution: Runs before any tool starts
8
+ * - afterToolExecution: Runs after any tool completes
9
+ * - beforeFileEdit: Runs before a file is modified
10
+ * - afterFileEdit: Runs after a file is modified
11
+ * - beforeBashCommand: Runs before a bash command executes
12
+ * - afterBashCommand: Runs after a bash command completes
13
+ *
14
+ * Hooks are configured in EROSOLAR.md or settings.json
15
+ */
16
+ import { exec } from 'node:child_process';
17
+ import { existsSync, readFileSync } from 'node:fs';
18
+ import { join } from 'node:path';
19
+ import { homedir } from 'node:os';
20
+ import { promisify } from 'node:util';
21
+ const execAsync = promisify(exec);
22
+ const DEFAULT_HOOK_TIMEOUT = 30000; // 30 seconds
23
+ /**
24
+ * Load hooks from EROSOLAR.md or settings.json
25
+ */
26
+ export function loadHooks(workingDir) {
27
+ const configs = loadHooksConfigs(workingDir);
28
+ return configs.flatMap((c) => c.hooks);
29
+ }
30
+ function loadHooksConfigs(workingDir) {
31
+ const configs = [];
32
+ // 1. User-level hooks from ~/.erosolar/hooks.json
33
+ const userHooksPath = join(homedir(), '.erosolar', 'hooks.json');
34
+ if (existsSync(userHooksPath)) {
35
+ const hooks = tryLoadHooksJson(userHooksPath);
36
+ if (hooks.length > 0) {
37
+ configs.push({ hooks, source: userHooksPath });
38
+ }
39
+ }
40
+ // 2. Project-level hooks from .erosolar/hooks.json
41
+ const projectHooksPath = join(workingDir, '.erosolar', 'hooks.json');
42
+ if (existsSync(projectHooksPath)) {
43
+ const hooks = tryLoadHooksJson(projectHooksPath);
44
+ if (hooks.length > 0) {
45
+ configs.push({ hooks, source: projectHooksPath });
46
+ }
47
+ }
48
+ // 3. Parse hooks from EROSOLAR.md YAML frontmatter
49
+ const memoryPaths = [
50
+ join(workingDir, 'EROSOLAR.md'),
51
+ join(workingDir, '.erosolar', 'EROSOLAR.md'),
52
+ ];
53
+ for (const memoryPath of memoryPaths) {
54
+ if (existsSync(memoryPath)) {
55
+ const hooks = tryParseHooksFromMarkdown(memoryPath);
56
+ if (hooks.length > 0) {
57
+ configs.push({ hooks, source: memoryPath });
58
+ }
59
+ }
60
+ }
61
+ return configs;
62
+ }
63
+ function tryLoadHooksJson(filePath) {
64
+ try {
65
+ const content = readFileSync(filePath, 'utf-8');
66
+ const parsed = JSON.parse(content);
67
+ if (Array.isArray(parsed)) {
68
+ return parsed.filter(isValidHook);
69
+ }
70
+ if (parsed.hooks && Array.isArray(parsed.hooks)) {
71
+ return parsed.hooks.filter(isValidHook);
72
+ }
73
+ return [];
74
+ }
75
+ catch {
76
+ return [];
77
+ }
78
+ }
79
+ function tryParseHooksFromMarkdown(filePath) {
80
+ try {
81
+ const content = readFileSync(filePath, 'utf-8');
82
+ // Look for hooks in YAML-like format within the markdown
83
+ const hooksMatch = content.match(/```(?:yaml|yml)?\nhooks:\s*\n([\s\S]*?)```/);
84
+ if (!hooksMatch) {
85
+ return [];
86
+ }
87
+ // Simple YAML-like parsing for hooks
88
+ const hooksYaml = hooksMatch[1] ?? '';
89
+ const hooks = [];
90
+ let currentHook = null;
91
+ let inThenBlock = false;
92
+ const thenCommands = [];
93
+ for (const line of hooksYaml.split('\n')) {
94
+ const trimmed = line.trim();
95
+ if (trimmed.startsWith('- when:')) {
96
+ // Save previous hook
97
+ if (currentHook && currentHook.when) {
98
+ if (thenCommands.length > 0) {
99
+ currentHook.then = [...thenCommands];
100
+ }
101
+ if (currentHook.then && currentHook.then.length > 0) {
102
+ hooks.push(currentHook);
103
+ }
104
+ }
105
+ // Start new hook
106
+ const whenValue = trimmed.replace('- when:', '').trim().replace(/['"]/g, '');
107
+ currentHook = { when: whenValue };
108
+ thenCommands.length = 0;
109
+ inThenBlock = false;
110
+ }
111
+ else if (trimmed.startsWith('if:') && currentHook) {
112
+ currentHook.if = trimmed.replace('if:', '').trim().replace(/['"]/g, '');
113
+ }
114
+ else if (trimmed.startsWith('then:')) {
115
+ inThenBlock = true;
116
+ }
117
+ else if (inThenBlock && trimmed.startsWith('- ')) {
118
+ const cmd = trimmed.slice(2).replace(/['"]/g, '');
119
+ thenCommands.push(cmd);
120
+ }
121
+ else if (trimmed.startsWith('timeout:') && currentHook) {
122
+ const timeout = parseInt(trimmed.replace('timeout:', '').trim(), 10);
123
+ if (!isNaN(timeout)) {
124
+ currentHook.timeout = timeout;
125
+ }
126
+ }
127
+ }
128
+ // Save last hook
129
+ if (currentHook && currentHook.when) {
130
+ if (thenCommands.length > 0) {
131
+ currentHook.then = [...thenCommands];
132
+ }
133
+ if (currentHook.then && currentHook.then.length > 0) {
134
+ hooks.push(currentHook);
135
+ }
136
+ }
137
+ return hooks;
138
+ }
139
+ catch {
140
+ return [];
141
+ }
142
+ }
143
+ function isValidHook(hook) {
144
+ if (!hook || typeof hook !== 'object') {
145
+ return false;
146
+ }
147
+ const h = hook;
148
+ const when = h['when'];
149
+ const then = h['then'];
150
+ return (typeof when === 'string' &&
151
+ Array.isArray(then) &&
152
+ then.length > 0 &&
153
+ then.every((cmd) => typeof cmd === 'string'));
154
+ }
155
+ /**
156
+ * Match a condition against context
157
+ */
158
+ function matchCondition(condition, context) {
159
+ if (!condition) {
160
+ return true; // No condition means always match
161
+ }
162
+ // Match tool name
163
+ if (context.tool && context.tool.toLowerCase().includes(condition.toLowerCase())) {
164
+ return true;
165
+ }
166
+ // Match file pattern (simple glob)
167
+ if (context.file) {
168
+ if (condition.includes('*')) {
169
+ const regex = new RegExp('^' + condition.replace(/\./g, '\\.').replace(/\*\*/g, '.*').replace(/\*/g, '[^/]*') + '$');
170
+ return regex.test(context.file);
171
+ }
172
+ return context.file.includes(condition);
173
+ }
174
+ // Match command pattern
175
+ if (context.command && context.command.includes(condition)) {
176
+ return true;
177
+ }
178
+ return false;
179
+ }
180
+ /**
181
+ * Execute a hook's commands
182
+ */
183
+ async function executeHookCommands(hook, context) {
184
+ const output = [];
185
+ const errors = [];
186
+ let abort = false;
187
+ const timeout = hook.timeout ?? DEFAULT_HOOK_TIMEOUT;
188
+ for (const command of hook.then) {
189
+ // Handle special commands
190
+ if (command.toLowerCase() === 'abort') {
191
+ abort = true;
192
+ continue;
193
+ }
194
+ if (command.toLowerCase().startsWith('message:')) {
195
+ output.push(command.slice(8).trim());
196
+ continue;
197
+ }
198
+ // Execute shell command
199
+ try {
200
+ const controller = new AbortController();
201
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
202
+ const { stdout, stderr } = await execAsync(command, {
203
+ cwd: context.workingDir,
204
+ timeout,
205
+ signal: controller.signal,
206
+ env: {
207
+ ...process.env,
208
+ EROSOLAR_TOOL: context.tool ?? '',
209
+ EROSOLAR_FILE: context.file ?? '',
210
+ EROSOLAR_COMMAND: context.command ?? '',
211
+ },
212
+ });
213
+ clearTimeout(timeoutId);
214
+ if (stdout.trim()) {
215
+ output.push(stdout.trim());
216
+ }
217
+ if (stderr.trim()) {
218
+ errors.push(stderr.trim());
219
+ }
220
+ }
221
+ catch (error) {
222
+ const errMsg = error instanceof Error ? error.message : String(error);
223
+ errors.push(`Hook command failed: ${command}\n${errMsg}`);
224
+ }
225
+ }
226
+ return { output, errors, abort };
227
+ }
228
+ /**
229
+ * Run hooks for a specific trigger
230
+ */
231
+ export async function runHooks(trigger, context, hooks) {
232
+ const allHooks = hooks ?? loadHooks(context.workingDir);
233
+ const matchingHooks = allHooks.filter((hook) => hook.when === trigger && matchCondition(hook.if, context));
234
+ if (matchingHooks.length === 0) {
235
+ return { triggered: false, output: [], errors: [], abort: false };
236
+ }
237
+ const result = {
238
+ triggered: true,
239
+ output: [],
240
+ errors: [],
241
+ abort: false,
242
+ };
243
+ for (const hook of matchingHooks) {
244
+ const { output, errors, abort } = await executeHookCommands(hook, context);
245
+ result.output.push(...output);
246
+ result.errors.push(...errors);
247
+ if (abort) {
248
+ result.abort = true;
249
+ break; // Stop processing if abort is requested
250
+ }
251
+ }
252
+ return result;
253
+ }
254
+ /**
255
+ * Create a hooks runner bound to a specific working directory
256
+ */
257
+ export function createHooksRunner(workingDir) {
258
+ let cachedHooks = null;
259
+ const getHooks = () => {
260
+ if (cachedHooks === null) {
261
+ cachedHooks = loadHooks(workingDir);
262
+ }
263
+ return cachedHooks;
264
+ };
265
+ return {
266
+ runBefore: (trigger, context) => runHooks(trigger, { ...context, workingDir }, getHooks()),
267
+ runAfter: (trigger, context) => runHooks(trigger, { ...context, workingDir }, getHooks()),
268
+ reload: () => {
269
+ cachedHooks = null;
270
+ },
271
+ };
272
+ }
273
+ //# sourceMappingURL=hooksSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooksSystem.js","sourceRoot":"","sources":["../../src/core/hooksSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAsB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAkDlC,MAAM,oBAAoB,GAAG,KAAK,CAAC,CAAC,aAAa;AAEjD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,UAAkB;IAC1C,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAkB;IAC1C,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,kDAAkD;IAClD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACjE,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC9C,IAAI,K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IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;YACpB,MAAM,CAAC,wCAAwC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAKlD,IAAI,WAAW,GAA4B,IAAI,CAAC;IAEhD,MAAM,QAAQ,GAAG,GAAqB,EAAE;QACtC,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAC9B,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC3D,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAC7B,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC3D,MAAM,EAAE,GAAG,EAAE;YACX,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Memory System - Hierarchical persistent memory for AI context
3
+ *
4
+ * Implements a Claude Code-style memory system that loads persistent context
5
+ * from markdown files at multiple levels:
6
+ *
7
+ * 1. Enterprise Policy: /etc/erosolar/EROSOLAR.md (Linux), managed settings
8
+ * 2. User Memory: ~/.erosolar/EROSOLAR.md
9
+ * 3. Project Memory: ./EROSOLAR.md or ./.erosolar/EROSOLAR.md
10
+ *
11
+ * Supports @imports for including external files recursively (max 5 levels).
12
+ */
13
+ interface MemorySource {
14
+ level: 'enterprise' | 'user' | 'project' | 'local';
15
+ path: string;
16
+ content: string;
17
+ }
18
+ export interface LoadedMemory {
19
+ sources: MemorySource[];
20
+ combinedContent: string;
21
+ importedPaths: string[];
22
+ }
23
+ /**
24
+ * Load all memory from the hierarchy
25
+ */
26
+ export declare function loadMemory(workingDir: string): LoadedMemory;
27
+ /**
28
+ * Get memory content formatted for system prompt injection
29
+ */
30
+ export declare function getMemoryForPrompt(workingDir: string): string;
31
+ /**
32
+ * List all memory file paths and their status
33
+ */
34
+ export declare function listMemoryPaths(workingDir: string): Array<{
35
+ level: string;
36
+ path: string;
37
+ exists: boolean;
38
+ }>;
39
+ /**
40
+ * Get the default path for creating a new project memory file
41
+ */
42
+ export declare function getDefaultProjectMemoryPath(workingDir: string): string;
43
+ /**
44
+ * Get the user memory path for editing
45
+ */
46
+ export declare function getUserMemoryEditPath(): string;
47
+ export {};
48
+ //# sourceMappingURL=memorySystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memorySystem.d.ts","sourceRoot":"","sources":["../../src/core/memorySystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,UAAU,YAAY;IACpB,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAmKD;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CA6D3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAc7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC,CAmCD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C"}
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Memory System - Hierarchical persistent memory for AI context
3
+ *
4
+ * Implements a Claude Code-style memory system that loads persistent context
5
+ * from markdown files at multiple levels:
6
+ *
7
+ * 1. Enterprise Policy: /etc/erosolar/EROSOLAR.md (Linux), managed settings
8
+ * 2. User Memory: ~/.erosolar/EROSOLAR.md
9
+ * 3. Project Memory: ./EROSOLAR.md or ./.erosolar/EROSOLAR.md
10
+ *
11
+ * Supports @imports for including external files recursively (max 5 levels).
12
+ */
13
+ import { existsSync, readFileSync } from 'node:fs';
14
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
15
+ import { homedir, platform } from 'node:os';
16
+ const MAX_IMPORT_DEPTH = 5;
17
+ const MEMORY_FILE_NAMES = ['EROSOLAR.md', 'CLAUDE.md'];
18
+ const DATA_DIR_NAME = '.erosolar';
19
+ /**
20
+ * Get the path to the enterprise policy memory file
21
+ */
22
+ function getEnterprisePolicyPath() {
23
+ const plat = platform();
24
+ if (plat === 'darwin') {
25
+ return '/Library/Application Support/Erosolar/EROSOLAR.md';
26
+ }
27
+ if (plat === 'linux') {
28
+ return '/etc/erosolar/EROSOLAR.md';
29
+ }
30
+ if (plat === 'win32') {
31
+ const programData = process.env['PROGRAMDATA'] || 'C:\\ProgramData';
32
+ return join(programData, 'Erosolar', 'EROSOLAR.md');
33
+ }
34
+ return null;
35
+ }
36
+ /**
37
+ * Get the path to the user memory file
38
+ */
39
+ function getUserMemoryPath() {
40
+ return join(homedir(), DATA_DIR_NAME, 'EROSOLAR.md');
41
+ }
42
+ /**
43
+ * Find project memory file in the workspace
44
+ */
45
+ function findProjectMemoryPath(workingDir) {
46
+ // Check root level first
47
+ for (const name of MEMORY_FILE_NAMES) {
48
+ const rootPath = join(workingDir, name);
49
+ if (existsSync(rootPath)) {
50
+ return rootPath;
51
+ }
52
+ }
53
+ // Check .erosolar directory
54
+ for (const name of MEMORY_FILE_NAMES) {
55
+ const nestedPath = join(workingDir, DATA_DIR_NAME, name);
56
+ if (existsSync(nestedPath)) {
57
+ return nestedPath;
58
+ }
59
+ }
60
+ // Check .claude directory for compatibility
61
+ for (const name of MEMORY_FILE_NAMES) {
62
+ const claudePath = join(workingDir, '.claude', name);
63
+ if (existsSync(claudePath)) {
64
+ return claudePath;
65
+ }
66
+ }
67
+ return null;
68
+ }
69
+ /**
70
+ * Parse @imports from a memory file content
71
+ */
72
+ function parseImports(content) {
73
+ const imports = [];
74
+ const lines = content.split('\n');
75
+ for (const line of lines) {
76
+ const trimmed = line.trim();
77
+ // Match @path/to/file.md or @~/path/to/file.md
78
+ if (trimmed.startsWith('@') && !trimmed.startsWith('@{')) {
79
+ const importPath = trimmed.slice(1).trim();
80
+ if (importPath) {
81
+ imports.push(importPath);
82
+ }
83
+ }
84
+ }
85
+ return imports;
86
+ }
87
+ /**
88
+ * Remove @import lines from content (they're processed, not displayed)
89
+ */
90
+ function removeImportLines(content) {
91
+ return content
92
+ .split('\n')
93
+ .filter((line) => {
94
+ const trimmed = line.trim();
95
+ return !trimmed.startsWith('@') || trimmed.startsWith('@{');
96
+ })
97
+ .join('\n')
98
+ .trim();
99
+ }
100
+ /**
101
+ * Resolve an import path relative to the source file
102
+ */
103
+ function resolveImportPath(importPath, sourceDir) {
104
+ // Handle ~ for home directory
105
+ if (importPath.startsWith('~/') || importPath.startsWith('~\\')) {
106
+ return join(homedir(), importPath.slice(2));
107
+ }
108
+ // Handle absolute paths
109
+ if (isAbsolute(importPath)) {
110
+ return importPath;
111
+ }
112
+ // Relative to source file directory
113
+ return resolve(sourceDir, importPath);
114
+ }
115
+ /**
116
+ * Load a memory file and process its imports recursively
117
+ */
118
+ function loadMemoryFileWithImports(filePath, depth, visitedPaths, importedPaths) {
119
+ if (depth > MAX_IMPORT_DEPTH) {
120
+ return `<!-- Import depth exceeded (max ${MAX_IMPORT_DEPTH}) for: ${filePath} -->`;
121
+ }
122
+ const normalizedPath = resolve(filePath);
123
+ if (visitedPaths.has(normalizedPath)) {
124
+ return `<!-- Circular import detected: ${filePath} -->`;
125
+ }
126
+ if (!existsSync(filePath)) {
127
+ return `<!-- Import not found: ${filePath} -->`;
128
+ }
129
+ visitedPaths.add(normalizedPath);
130
+ importedPaths.push(normalizedPath);
131
+ let content;
132
+ try {
133
+ content = readFileSync(filePath, 'utf-8');
134
+ }
135
+ catch (error) {
136
+ return `<!-- Failed to read: ${filePath} -->`;
137
+ }
138
+ const sourceDir = dirname(normalizedPath);
139
+ const imports = parseImports(content);
140
+ // Process imports and replace with their content
141
+ let processedContent = removeImportLines(content);
142
+ for (const importPath of imports) {
143
+ const resolvedPath = resolveImportPath(importPath, sourceDir);
144
+ const importedContent = loadMemoryFileWithImports(resolvedPath, depth + 1, visitedPaths, importedPaths);
145
+ processedContent += '\n\n' + importedContent;
146
+ }
147
+ return processedContent.trim();
148
+ }
149
+ /**
150
+ * Load all memory from the hierarchy
151
+ */
152
+ export function loadMemory(workingDir) {
153
+ const sources = [];
154
+ const allImportedPaths = [];
155
+ const visitedPaths = new Set();
156
+ // 1. Enterprise policy (highest priority, but loaded first so it can be overridden)
157
+ const enterprisePath = getEnterprisePolicyPath();
158
+ if (enterprisePath && existsSync(enterprisePath)) {
159
+ const content = loadMemoryFileWithImports(enterprisePath, 0, visitedPaths, allImportedPaths);
160
+ if (content.trim()) {
161
+ sources.push({
162
+ level: 'enterprise',
163
+ path: enterprisePath,
164
+ content,
165
+ });
166
+ }
167
+ }
168
+ // 2. User memory
169
+ const userPath = getUserMemoryPath();
170
+ if (existsSync(userPath)) {
171
+ const content = loadMemoryFileWithImports(userPath, 0, visitedPaths, allImportedPaths);
172
+ if (content.trim()) {
173
+ sources.push({
174
+ level: 'user',
175
+ path: userPath,
176
+ content,
177
+ });
178
+ }
179
+ }
180
+ // 3. Project memory
181
+ const projectPath = findProjectMemoryPath(workingDir);
182
+ if (projectPath) {
183
+ const content = loadMemoryFileWithImports(projectPath, 0, visitedPaths, allImportedPaths);
184
+ if (content.trim()) {
185
+ sources.push({
186
+ level: 'project',
187
+ path: projectPath,
188
+ content,
189
+ });
190
+ }
191
+ }
192
+ // Combine all memory with headers
193
+ const sections = [];
194
+ for (const source of sources) {
195
+ const levelLabel = source.level === 'enterprise'
196
+ ? 'Enterprise Policy'
197
+ : source.level === 'user'
198
+ ? 'User Guidelines'
199
+ : 'Project Guidelines';
200
+ sections.push(`## ${levelLabel}\n\n${source.content}`);
201
+ }
202
+ return {
203
+ sources,
204
+ combinedContent: sections.join('\n\n---\n\n'),
205
+ importedPaths: allImportedPaths,
206
+ };
207
+ }
208
+ /**
209
+ * Get memory content formatted for system prompt injection
210
+ */
211
+ export function getMemoryForPrompt(workingDir) {
212
+ const memory = loadMemory(workingDir);
213
+ if (!memory.combinedContent.trim()) {
214
+ return '';
215
+ }
216
+ return `
217
+ <persistent-memory>
218
+ The following persistent context has been loaded from memory files.
219
+ Follow these guidelines when working in this workspace.
220
+
221
+ ${memory.combinedContent}
222
+ </persistent-memory>
223
+ `;
224
+ }
225
+ /**
226
+ * List all memory file paths and their status
227
+ */
228
+ export function listMemoryPaths(workingDir) {
229
+ const paths = [];
230
+ const enterprisePath = getEnterprisePolicyPath();
231
+ if (enterprisePath) {
232
+ paths.push({
233
+ level: 'enterprise',
234
+ path: enterprisePath,
235
+ exists: existsSync(enterprisePath),
236
+ });
237
+ }
238
+ const userPath = getUserMemoryPath();
239
+ paths.push({
240
+ level: 'user',
241
+ path: userPath,
242
+ exists: existsSync(userPath),
243
+ });
244
+ const projectMemoryLocations = [
245
+ join(workingDir, 'EROSOLAR.md'),
246
+ join(workingDir, 'CLAUDE.md'),
247
+ join(workingDir, DATA_DIR_NAME, 'EROSOLAR.md'),
248
+ join(workingDir, '.claude', 'CLAUDE.md'),
249
+ ];
250
+ for (const path of projectMemoryLocations) {
251
+ paths.push({
252
+ level: 'project',
253
+ path,
254
+ exists: existsSync(path),
255
+ });
256
+ }
257
+ return paths;
258
+ }
259
+ /**
260
+ * Get the default path for creating a new project memory file
261
+ */
262
+ export function getDefaultProjectMemoryPath(workingDir) {
263
+ return join(workingDir, 'EROSOLAR.md');
264
+ }
265
+ /**
266
+ * Get the user memory path for editing
267
+ */
268
+ export function getUserMemoryEditPath() {
269
+ return getUserMemoryPath();
270
+ }
271
+ //# sourceMappingURL=memorySystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memorySystem.js","sourceRoot":"","sources":["../../src/core/memorySystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,iBAAiB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AACvD,MAAM,aAAa,GAAG,WAAW,CAAC;AAclC;;GAEG;AACH,SAAS,uBAAuB;IAC9B,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAC;IACxB,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,mDAAmD,CAAC;IAC7D,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,2BAA2B,CAAC;IACrC,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,iBAAiB,CAAC;QACpE,OAAO,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACtD,CAAC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I,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,gBAAgB,EAAE,CAsKpB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAAE,GAC1E,gBAAgB,EAAE,CAqEpB"}
1
+ {"version":3,"file":"toolPreconditions.d.ts","sourceRoot":"","sources":["../../src/core/toolPreconditions.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;IACnD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAGD,eAAO,MAAM,2BAA2B;;;;;;;;;;CA+B9B,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,gBAAgB,EAAE,CAsKpB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAAE,GAC1E,gBAAgB,EAAE,CAsFpB"}
@@ -197,6 +197,20 @@ export function validateToolPreconditions(toolName, args) {
197
197
  export function validateAIFlowPatterns(toolName, args, toolHistory) {
198
198
  const warnings = [];
199
199
  const toolLower = toolName.toLowerCase();
200
+ // Pattern: Sequential file reads without parallel execution
201
+ if (toolLower === 'read' || toolLower === 'read_file') {
202
+ const currentFile = (args['file_path'] || args['path']);
203
+ // Get recent read operations (last 5 in history)
204
+ const recentReads = toolHistory
205
+ .slice(-5)
206
+ .filter((call) => {
207
+ const callLower = call.toolName.toLowerCase();
208
+ return callLower === 'read' || callLower === 'read_file';
209
+ });
210
+ // Sequential read optimization warning disabled - too noisy and not actionable
211
+ // The AI can decide when parallel reads are appropriate without constant reminders
212
+ void recentReads; // Suppress unused variable warning
213
+ }
200
214
  // Pattern: Edit without prior Read
201
215
  if (toolLower === 'edit') {
202
216
  const oldString = typeof args['old_string'] === 'string' ? args['old_string'] : undefined;