@stackmemoryai/stackmemory 0.5.59 → 0.5.62

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 (652) hide show
  1. package/README.md +105 -1
  2. package/dist/scripts/initialize.js +68 -1
  3. package/dist/scripts/initialize.js.map +2 -2
  4. package/dist/src/cli/claude-sm.js +130 -50
  5. package/dist/src/cli/claude-sm.js.map +2 -2
  6. package/dist/src/cli/index.js +18 -3
  7. package/dist/src/cli/index.js.map +3 -3
  8. package/dist/src/core/extensions/custom-tools.js +567 -0
  9. package/dist/src/core/extensions/custom-tools.js.map +7 -0
  10. package/dist/src/core/extensions/index.js +55 -0
  11. package/dist/src/core/extensions/index.js.map +7 -0
  12. package/dist/src/core/extensions/loader.js +709 -0
  13. package/dist/src/core/extensions/loader.js.map +7 -0
  14. package/dist/src/core/extensions/plugin-system.js +506 -0
  15. package/dist/src/core/extensions/plugin-system.js.map +7 -0
  16. package/dist/src/core/extensions/provider-adapter.js +617 -0
  17. package/dist/src/core/extensions/provider-adapter.js.map +7 -0
  18. package/dist/src/core/extensions/sandbox-runtime.js +664 -0
  19. package/dist/src/core/extensions/sandbox-runtime.js.map +7 -0
  20. package/dist/src/core/retrieval/index.js +2 -0
  21. package/dist/src/core/retrieval/index.js.map +2 -2
  22. package/dist/src/core/retrieval/privacy-filter.js +129 -0
  23. package/dist/src/core/retrieval/privacy-filter.js.map +7 -0
  24. package/dist/src/core/retrieval/unified-context-assembler.js +273 -0
  25. package/dist/src/core/retrieval/unified-context-assembler.js.map +7 -0
  26. package/dist/src/core/storage/chromadb-adapter.js +32 -6
  27. package/dist/src/core/storage/chromadb-adapter.js.map +2 -2
  28. package/dist/src/hooks/diffmem-hooks.js +377 -0
  29. package/dist/src/hooks/diffmem-hooks.js.map +7 -0
  30. package/dist/src/integrations/diffmem/client.js +209 -0
  31. package/dist/src/integrations/diffmem/client.js.map +7 -0
  32. package/dist/src/integrations/diffmem/config.js +15 -0
  33. package/dist/src/integrations/diffmem/config.js.map +7 -0
  34. package/dist/{core/session → src/integrations/diffmem}/index.js +5 -8
  35. package/dist/src/integrations/diffmem/index.js.map +7 -0
  36. package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +456 -0
  37. package/dist/src/integrations/mcp/handlers/diffmem-handlers.js.map +7 -0
  38. package/dist/src/integrations/mcp/server.js +121 -0
  39. package/dist/src/integrations/mcp/server.js.map +2 -2
  40. package/dist/src/skills/repo-ingestion-skill.js +35 -12
  41. package/dist/src/skills/repo-ingestion-skill.js.map +2 -2
  42. package/package.json +13 -7
  43. package/scripts/background-sync-manager.js +145 -83
  44. package/scripts/claude-sm-autostart.js +17 -12
  45. package/scripts/gepa/README.md +275 -0
  46. package/scripts/gepa/config.json +53 -0
  47. package/scripts/gepa/evals/coding-tasks.jsonl +5 -0
  48. package/scripts/gepa/evals/fixtures/buggy-loop.js +18 -0
  49. package/scripts/gepa/evals/fixtures/callback-hell.js +53 -0
  50. package/scripts/gepa/generations/gen-000/baseline.md +124 -0
  51. package/scripts/gepa/hooks/auto-optimize.js +494 -0
  52. package/scripts/gepa/hooks/eval-tracker.js +203 -0
  53. package/scripts/gepa/hooks/reflect.js +311 -0
  54. package/scripts/gepa/optimize.js +611 -0
  55. package/scripts/gepa/state.json +14 -0
  56. package/scripts/initialize.ts +83 -1
  57. package/scripts/test-pre-publish-quick.sh +1 -1
  58. package/dist/agents/core/agent-task-manager.js +0 -527
  59. package/dist/agents/core/agent-task-manager.js.map +0 -7
  60. package/dist/agents/testing-agent.js +0 -614
  61. package/dist/agents/testing-agent.js.map +0 -7
  62. package/dist/agents/verifiers/base-verifier.js +0 -133
  63. package/dist/agents/verifiers/base-verifier.js.map +0 -7
  64. package/dist/agents/verifiers/formatter-verifier.js +0 -130
  65. package/dist/agents/verifiers/formatter-verifier.js.map +0 -7
  66. package/dist/agents/verifiers/llm-judge.js +0 -252
  67. package/dist/agents/verifiers/llm-judge.js.map +0 -7
  68. package/dist/cli/auto-detect.js +0 -321
  69. package/dist/cli/auto-detect.js.map +0 -7
  70. package/dist/cli/browser-test.js +0 -33
  71. package/dist/cli/browser-test.js.map +0 -7
  72. package/dist/cli/claude-sm-danger.js +0 -21
  73. package/dist/cli/claude-sm-danger.js.map +0 -7
  74. package/dist/cli/claude-sm.js +0 -1156
  75. package/dist/cli/claude-sm.js.map +0 -7
  76. package/dist/cli/codex-sm-danger.js +0 -21
  77. package/dist/cli/codex-sm-danger.js.map +0 -7
  78. package/dist/cli/codex-sm.js +0 -349
  79. package/dist/cli/codex-sm.js.map +0 -7
  80. package/dist/cli/commands/api.js +0 -232
  81. package/dist/cli/commands/api.js.map +0 -7
  82. package/dist/cli/commands/auto-background.js +0 -180
  83. package/dist/cli/commands/auto-background.js.map +0 -7
  84. package/dist/cli/commands/cleanup-processes.js +0 -68
  85. package/dist/cli/commands/cleanup-processes.js.map +0 -7
  86. package/dist/cli/commands/clear.js +0 -202
  87. package/dist/cli/commands/clear.js.map +0 -7
  88. package/dist/cli/commands/config.js +0 -445
  89. package/dist/cli/commands/config.js.map +0 -7
  90. package/dist/cli/commands/context-rehydrate.js +0 -751
  91. package/dist/cli/commands/context-rehydrate.js.map +0 -7
  92. package/dist/cli/commands/context.js +0 -343
  93. package/dist/cli/commands/context.js.map +0 -7
  94. package/dist/cli/commands/daemon.js +0 -392
  95. package/dist/cli/commands/daemon.js.map +0 -7
  96. package/dist/cli/commands/dashboard.js +0 -210
  97. package/dist/cli/commands/dashboard.js.map +0 -7
  98. package/dist/cli/commands/db.js +0 -147
  99. package/dist/cli/commands/db.js.map +0 -7
  100. package/dist/cli/commands/decision.js +0 -266
  101. package/dist/cli/commands/decision.js.map +0 -7
  102. package/dist/cli/commands/discovery.js +0 -279
  103. package/dist/cli/commands/discovery.js.map +0 -7
  104. package/dist/cli/commands/handoff.js +0 -624
  105. package/dist/cli/commands/handoff.js.map +0 -7
  106. package/dist/cli/commands/hooks.js +0 -298
  107. package/dist/cli/commands/hooks.js.map +0 -7
  108. package/dist/cli/commands/linear-unified.js +0 -353
  109. package/dist/cli/commands/linear-unified.js.map +0 -7
  110. package/dist/cli/commands/linear.js +0 -529
  111. package/dist/cli/commands/linear.js.map +0 -7
  112. package/dist/cli/commands/log.js +0 -169
  113. package/dist/cli/commands/log.js.map +0 -7
  114. package/dist/cli/commands/login.js +0 -172
  115. package/dist/cli/commands/login.js.map +0 -7
  116. package/dist/cli/commands/migrate.js +0 -240
  117. package/dist/cli/commands/migrate.js.map +0 -7
  118. package/dist/cli/commands/model.js +0 -533
  119. package/dist/cli/commands/model.js.map +0 -7
  120. package/dist/cli/commands/monitor.js +0 -313
  121. package/dist/cli/commands/monitor.js.map +0 -7
  122. package/dist/cli/commands/onboard.js +0 -536
  123. package/dist/cli/commands/onboard.js.map +0 -7
  124. package/dist/cli/commands/projects.js +0 -199
  125. package/dist/cli/commands/projects.js.map +0 -7
  126. package/dist/cli/commands/quality.js +0 -413
  127. package/dist/cli/commands/quality.js.map +0 -7
  128. package/dist/cli/commands/ralph.js +0 -909
  129. package/dist/cli/commands/ralph.js.map +0 -7
  130. package/dist/cli/commands/retrieval.js +0 -248
  131. package/dist/cli/commands/retrieval.js.map +0 -7
  132. package/dist/cli/commands/search.js +0 -173
  133. package/dist/cli/commands/search.js.map +0 -7
  134. package/dist/cli/commands/service.js +0 -749
  135. package/dist/cli/commands/service.js.map +0 -7
  136. package/dist/cli/commands/session.js +0 -200
  137. package/dist/cli/commands/session.js.map +0 -7
  138. package/dist/cli/commands/settings.js +0 -306
  139. package/dist/cli/commands/settings.js.map +0 -7
  140. package/dist/cli/commands/setup.js +0 -701
  141. package/dist/cli/commands/setup.js.map +0 -7
  142. package/dist/cli/commands/shell.js +0 -249
  143. package/dist/cli/commands/shell.js.map +0 -7
  144. package/dist/cli/commands/signup.js +0 -50
  145. package/dist/cli/commands/signup.js.map +0 -7
  146. package/dist/cli/commands/skills.js +0 -470
  147. package/dist/cli/commands/skills.js.map +0 -7
  148. package/dist/cli/commands/sms-notify.js +0 -795
  149. package/dist/cli/commands/sms-notify.js.map +0 -7
  150. package/dist/cli/commands/storage-tier.js +0 -183
  151. package/dist/cli/commands/storage-tier.js.map +0 -7
  152. package/dist/cli/commands/storage.js +0 -360
  153. package/dist/cli/commands/storage.js.map +0 -7
  154. package/dist/cli/commands/sweep.js +0 -249
  155. package/dist/cli/commands/sweep.js.map +0 -7
  156. package/dist/cli/commands/tasks.js +0 -213
  157. package/dist/cli/commands/tasks.js.map +0 -7
  158. package/dist/cli/commands/test.js +0 -286
  159. package/dist/cli/commands/test.js.map +0 -7
  160. package/dist/cli/commands/workflow.js +0 -142
  161. package/dist/cli/commands/workflow.js.map +0 -7
  162. package/dist/cli/commands/worktree.js +0 -319
  163. package/dist/cli/commands/worktree.js.map +0 -7
  164. package/dist/cli/index.js +0 -594
  165. package/dist/cli/index.js.map +0 -7
  166. package/dist/cli/opencode-sm.js +0 -448
  167. package/dist/cli/opencode-sm.js.map +0 -7
  168. package/dist/cli/utils/viewer.js +0 -96
  169. package/dist/cli/utils/viewer.js.map +0 -7
  170. package/dist/core/analytics/team-analytics.js +0 -378
  171. package/dist/core/analytics/team-analytics.js.map +0 -7
  172. package/dist/core/config/config-manager.js +0 -398
  173. package/dist/core/config/config-manager.js.map +0 -7
  174. package/dist/core/config/feature-flags.js +0 -76
  175. package/dist/core/config/feature-flags.js.map +0 -7
  176. package/dist/core/config/storage-config.js +0 -115
  177. package/dist/core/config/storage-config.js.map +0 -7
  178. package/dist/core/config/types.js +0 -144
  179. package/dist/core/config/types.js.map +0 -7
  180. package/dist/core/context/auto-context.js +0 -80
  181. package/dist/core/context/auto-context.js.map +0 -7
  182. package/dist/core/context/dual-stack-manager.js +0 -870
  183. package/dist/core/context/dual-stack-manager.js.map +0 -7
  184. package/dist/core/context/enhanced-rehydration.js +0 -994
  185. package/dist/core/context/enhanced-rehydration.js.map +0 -7
  186. package/dist/core/context/frame-database.js +0 -479
  187. package/dist/core/context/frame-database.js.map +0 -7
  188. package/dist/core/context/frame-digest.js +0 -250
  189. package/dist/core/context/frame-digest.js.map +0 -7
  190. package/dist/core/context/frame-handoff-manager.js +0 -778
  191. package/dist/core/context/frame-handoff-manager.js.map +0 -7
  192. package/dist/core/context/frame-lifecycle-hooks.js +0 -119
  193. package/dist/core/context/frame-lifecycle-hooks.js.map +0 -7
  194. package/dist/core/context/frame-manager.js +0 -1069
  195. package/dist/core/context/frame-manager.js.map +0 -7
  196. package/dist/core/context/frame-recovery.js +0 -302
  197. package/dist/core/context/frame-recovery.js.map +0 -7
  198. package/dist/core/context/frame-stack.js +0 -314
  199. package/dist/core/context/frame-stack.js.map +0 -7
  200. package/dist/core/context/frame-types.js +0 -5
  201. package/dist/core/context/frame-types.js.map +0 -7
  202. package/dist/core/context/incremental-gc.js +0 -290
  203. package/dist/core/context/incremental-gc.js.map +0 -7
  204. package/dist/core/context/index.js +0 -25
  205. package/dist/core/context/index.js.map +0 -7
  206. package/dist/core/context/model-aware-compaction.js +0 -623
  207. package/dist/core/context/model-aware-compaction.js.map +0 -7
  208. package/dist/core/context/permission-manager.js +0 -185
  209. package/dist/core/context/permission-manager.js.map +0 -7
  210. package/dist/core/context/recursive-context-manager.js +0 -592
  211. package/dist/core/context/recursive-context-manager.js.map +0 -7
  212. package/dist/core/context/refactored-frame-manager.js +0 -754
  213. package/dist/core/context/refactored-frame-manager.js.map +0 -7
  214. package/dist/core/context/shared-context-layer.js +0 -621
  215. package/dist/core/context/shared-context-layer.js.map +0 -7
  216. package/dist/core/context/stack-merge-resolver.js +0 -749
  217. package/dist/core/context/stack-merge-resolver.js.map +0 -7
  218. package/dist/core/context/validation.js +0 -130
  219. package/dist/core/context/validation.js.map +0 -7
  220. package/dist/core/database/batch-operations.js +0 -384
  221. package/dist/core/database/batch-operations.js.map +0 -7
  222. package/dist/core/database/connection-pool.js +0 -330
  223. package/dist/core/database/connection-pool.js.map +0 -7
  224. package/dist/core/database/database-adapter.js +0 -60
  225. package/dist/core/database/database-adapter.js.map +0 -7
  226. package/dist/core/database/migration-manager.js +0 -614
  227. package/dist/core/database/migration-manager.js.map +0 -7
  228. package/dist/core/database/paradedb-adapter.js +0 -990
  229. package/dist/core/database/paradedb-adapter.js.map +0 -7
  230. package/dist/core/database/query-cache.js +0 -298
  231. package/dist/core/database/query-cache.js.map +0 -7
  232. package/dist/core/database/query-router.js +0 -430
  233. package/dist/core/database/query-router.js.map +0 -7
  234. package/dist/core/database/sqlite-adapter.js +0 -738
  235. package/dist/core/database/sqlite-adapter.js.map +0 -7
  236. package/dist/core/digest/enhanced-hybrid-digest.js +0 -277
  237. package/dist/core/digest/enhanced-hybrid-digest.js.map +0 -7
  238. package/dist/core/digest/frame-digest-integration.js +0 -176
  239. package/dist/core/digest/frame-digest-integration.js.map +0 -7
  240. package/dist/core/digest/hybrid-digest-generator.js +0 -553
  241. package/dist/core/digest/hybrid-digest-generator.js.map +0 -7
  242. package/dist/core/digest/index.js +0 -9
  243. package/dist/core/digest/index.js.map +0 -7
  244. package/dist/core/digest/types.js +0 -25
  245. package/dist/core/digest/types.js.map +0 -7
  246. package/dist/core/errors/error-utils.js +0 -208
  247. package/dist/core/errors/error-utils.js.map +0 -7
  248. package/dist/core/errors/index.js +0 -521
  249. package/dist/core/errors/index.js.map +0 -7
  250. package/dist/core/errors/recovery.js +0 -269
  251. package/dist/core/errors/recovery.js.map +0 -7
  252. package/dist/core/execution/parallel-executor.js +0 -258
  253. package/dist/core/execution/parallel-executor.js.map +0 -7
  254. package/dist/core/frame/workflow-templates.js +0 -319
  255. package/dist/core/frame/workflow-templates.js.map +0 -7
  256. package/dist/core/merge/conflict-detector.js +0 -431
  257. package/dist/core/merge/conflict-detector.js.map +0 -7
  258. package/dist/core/merge/index.js +0 -9
  259. package/dist/core/merge/index.js.map +0 -7
  260. package/dist/core/merge/resolution-engine.js +0 -558
  261. package/dist/core/merge/resolution-engine.js.map +0 -7
  262. package/dist/core/merge/stack-diff.js +0 -532
  263. package/dist/core/merge/stack-diff.js.map +0 -7
  264. package/dist/core/merge/unified-merge-resolver.js +0 -303
  265. package/dist/core/merge/unified-merge-resolver.js.map +0 -7
  266. package/dist/core/models/fallback-monitor.js +0 -232
  267. package/dist/core/models/fallback-monitor.js.map +0 -7
  268. package/dist/core/models/model-router.js +0 -340
  269. package/dist/core/models/model-router.js.map +0 -7
  270. package/dist/core/monitoring/error-handler.js +0 -49
  271. package/dist/core/monitoring/error-handler.js.map +0 -7
  272. package/dist/core/monitoring/logger.js +0 -202
  273. package/dist/core/monitoring/logger.js.map +0 -7
  274. package/dist/core/monitoring/metrics.js +0 -172
  275. package/dist/core/monitoring/metrics.js.map +0 -7
  276. package/dist/core/monitoring/progress-tracker.js +0 -189
  277. package/dist/core/monitoring/progress-tracker.js.map +0 -7
  278. package/dist/core/monitoring/session-monitor.js +0 -300
  279. package/dist/core/monitoring/session-monitor.js.map +0 -7
  280. package/dist/core/performance/context-cache.js +0 -273
  281. package/dist/core/performance/context-cache.js.map +0 -7
  282. package/dist/core/performance/index.js +0 -11
  283. package/dist/core/performance/index.js.map +0 -7
  284. package/dist/core/performance/lazy-context-loader.js +0 -327
  285. package/dist/core/performance/lazy-context-loader.js.map +0 -7
  286. package/dist/core/performance/monitor.js +0 -221
  287. package/dist/core/performance/monitor.js.map +0 -7
  288. package/dist/core/performance/optimized-frame-context.js +0 -345
  289. package/dist/core/performance/optimized-frame-context.js.map +0 -7
  290. package/dist/core/performance/performance-benchmark.js +0 -277
  291. package/dist/core/performance/performance-benchmark.js.map +0 -7
  292. package/dist/core/performance/performance-profiler.js +0 -370
  293. package/dist/core/performance/performance-profiler.js.map +0 -7
  294. package/dist/core/performance/streaming-jsonl-parser.js +0 -195
  295. package/dist/core/performance/streaming-jsonl-parser.js.map +0 -7
  296. package/dist/core/persistence/postgres-adapter.js +0 -349
  297. package/dist/core/persistence/postgres-adapter.js.map +0 -7
  298. package/dist/core/projects/project-isolation.js +0 -201
  299. package/dist/core/projects/project-isolation.js.map +0 -7
  300. package/dist/core/projects/project-manager.js +0 -697
  301. package/dist/core/projects/project-manager.js.map +0 -7
  302. package/dist/core/query/query-parser.js +0 -370
  303. package/dist/core/query/query-parser.js.map +0 -7
  304. package/dist/core/query/query-templates.js +0 -321
  305. package/dist/core/query/query-templates.js.map +0 -7
  306. package/dist/core/retrieval/context-retriever.js +0 -479
  307. package/dist/core/retrieval/context-retriever.js.map +0 -7
  308. package/dist/core/retrieval/graph-retrieval.js +0 -662
  309. package/dist/core/retrieval/graph-retrieval.js.map +0 -7
  310. package/dist/core/retrieval/hierarchical-retrieval.js +0 -656
  311. package/dist/core/retrieval/hierarchical-retrieval.js.map +0 -7
  312. package/dist/core/retrieval/index.js +0 -8
  313. package/dist/core/retrieval/index.js.map +0 -7
  314. package/dist/core/retrieval/llm-context-retrieval.js +0 -613
  315. package/dist/core/retrieval/llm-context-retrieval.js.map +0 -7
  316. package/dist/core/retrieval/llm-provider.js +0 -151
  317. package/dist/core/retrieval/llm-provider.js.map +0 -7
  318. package/dist/core/retrieval/retrieval-audit.js +0 -236
  319. package/dist/core/retrieval/retrieval-audit.js.map +0 -7
  320. package/dist/core/retrieval/retrieval-benchmarks.js +0 -521
  321. package/dist/core/retrieval/retrieval-benchmarks.js.map +0 -7
  322. package/dist/core/retrieval/summary-generator.js +0 -589
  323. package/dist/core/retrieval/summary-generator.js.map +0 -7
  324. package/dist/core/retrieval/types.js +0 -21
  325. package/dist/core/retrieval/types.js.map +0 -7
  326. package/dist/core/security/index.js +0 -35
  327. package/dist/core/security/index.js.map +0 -7
  328. package/dist/core/security/input-sanitizer.js +0 -321
  329. package/dist/core/security/input-sanitizer.js.map +0 -7
  330. package/dist/core/session/clear-survival.js +0 -465
  331. package/dist/core/session/clear-survival.js.map +0 -7
  332. package/dist/core/session/enhanced-handoff.js +0 -792
  333. package/dist/core/session/enhanced-handoff.js.map +0 -7
  334. package/dist/core/session/handoff-generator.js +0 -343
  335. package/dist/core/session/handoff-generator.js.map +0 -7
  336. package/dist/core/session/index.js.map +0 -7
  337. package/dist/core/session/session-manager.js +0 -347
  338. package/dist/core/session/session-manager.js.map +0 -7
  339. package/dist/core/skills/index.js +0 -7
  340. package/dist/core/skills/index.js.map +0 -7
  341. package/dist/core/skills/skill-storage.js +0 -764
  342. package/dist/core/skills/skill-storage.js.map +0 -7
  343. package/dist/core/skills/types.js +0 -193
  344. package/dist/core/skills/types.js.map +0 -7
  345. package/dist/core/storage/chromadb-adapter.js +0 -354
  346. package/dist/core/storage/chromadb-adapter.js.map +0 -7
  347. package/dist/core/storage/infinite-storage.js +0 -510
  348. package/dist/core/storage/infinite-storage.js.map +0 -7
  349. package/dist/core/storage/railway-optimized-storage.js +0 -591
  350. package/dist/core/storage/railway-optimized-storage.js.map +0 -7
  351. package/dist/core/storage/remote-storage.js +0 -489
  352. package/dist/core/storage/remote-storage.js.map +0 -7
  353. package/dist/core/storage/two-tier-storage.js +0 -766
  354. package/dist/core/storage/two-tier-storage.js.map +0 -7
  355. package/dist/core/trace/cli-trace-wrapper.js +0 -132
  356. package/dist/core/trace/cli-trace-wrapper.js.map +0 -7
  357. package/dist/core/trace/db-trace-wrapper.js +0 -247
  358. package/dist/core/trace/db-trace-wrapper.js.map +0 -7
  359. package/dist/core/trace/debug-trace.js +0 -417
  360. package/dist/core/trace/debug-trace.js.map +0 -7
  361. package/dist/core/trace/index.js +0 -109
  362. package/dist/core/trace/index.js.map +0 -7
  363. package/dist/core/trace/linear-api-wrapper.js +0 -178
  364. package/dist/core/trace/linear-api-wrapper.js.map +0 -7
  365. package/dist/core/trace/trace-demo.js +0 -154
  366. package/dist/core/trace/trace-demo.js.map +0 -7
  367. package/dist/core/trace/trace-detector.demo.js +0 -142
  368. package/dist/core/trace/trace-detector.demo.js.map +0 -7
  369. package/dist/core/trace/trace-detector.js +0 -528
  370. package/dist/core/trace/trace-detector.js.map +0 -7
  371. package/dist/core/trace/trace-store.js +0 -345
  372. package/dist/core/trace/trace-store.js.map +0 -7
  373. package/dist/core/trace/types.js +0 -77
  374. package/dist/core/trace/types.js.map +0 -7
  375. package/dist/core/utils/async-mutex.js +0 -114
  376. package/dist/core/utils/async-mutex.js.map +0 -7
  377. package/dist/core/utils/compression.js +0 -83
  378. package/dist/core/utils/compression.js.map +0 -7
  379. package/dist/core/utils/update-checker.js +0 -218
  380. package/dist/core/utils/update-checker.js.map +0 -7
  381. package/dist/core/worktree/worktree-manager.js +0 -465
  382. package/dist/core/worktree/worktree-manager.js.map +0 -7
  383. package/dist/daemon/daemon-config.js +0 -149
  384. package/dist/daemon/daemon-config.js.map +0 -7
  385. package/dist/daemon/services/context-service.js +0 -122
  386. package/dist/daemon/services/context-service.js.map +0 -7
  387. package/dist/daemon/services/linear-service.js +0 -136
  388. package/dist/daemon/services/linear-service.js.map +0 -7
  389. package/dist/daemon/session-daemon.js +0 -312
  390. package/dist/daemon/session-daemon.js.map +0 -7
  391. package/dist/daemon/unified-daemon.js +0 -276
  392. package/dist/daemon/unified-daemon.js.map +0 -7
  393. package/dist/features/analytics/api/analytics-api.js +0 -287
  394. package/dist/features/analytics/api/analytics-api.js.map +0 -7
  395. package/dist/features/analytics/core/analytics-service.js +0 -282
  396. package/dist/features/analytics/core/analytics-service.js.map +0 -7
  397. package/dist/features/analytics/index.js +0 -18
  398. package/dist/features/analytics/index.js.map +0 -7
  399. package/dist/features/analytics/queries/metrics-queries.js +0 -277
  400. package/dist/features/analytics/queries/metrics-queries.js.map +0 -7
  401. package/dist/features/analytics/types/metrics.js +0 -5
  402. package/dist/features/analytics/types/metrics.js.map +0 -7
  403. package/dist/features/browser/browser-mcp.js +0 -492
  404. package/dist/features/browser/browser-mcp.js.map +0 -7
  405. package/dist/features/sweep/index.js +0 -20
  406. package/dist/features/sweep/index.js.map +0 -7
  407. package/dist/features/sweep/prediction-client.js +0 -155
  408. package/dist/features/sweep/prediction-client.js.map +0 -7
  409. package/dist/features/sweep/prompt-builder.js +0 -85
  410. package/dist/features/sweep/prompt-builder.js.map +0 -7
  411. package/dist/features/sweep/pty-wrapper.js +0 -171
  412. package/dist/features/sweep/pty-wrapper.js.map +0 -7
  413. package/dist/features/sweep/state-watcher.js +0 -87
  414. package/dist/features/sweep/state-watcher.js.map +0 -7
  415. package/dist/features/sweep/status-bar.js +0 -88
  416. package/dist/features/sweep/status-bar.js.map +0 -7
  417. package/dist/features/sweep/sweep-server-manager.js +0 -226
  418. package/dist/features/sweep/sweep-server-manager.js.map +0 -7
  419. package/dist/features/sweep/tab-interceptor.js +0 -38
  420. package/dist/features/sweep/tab-interceptor.js.map +0 -7
  421. package/dist/features/sweep/types.js +0 -18
  422. package/dist/features/sweep/types.js.map +0 -7
  423. package/dist/features/tasks/linear-task-manager.js +0 -487
  424. package/dist/features/tasks/linear-task-manager.js.map +0 -7
  425. package/dist/features/tasks/task-aware-context.js +0 -410
  426. package/dist/features/tasks/task-aware-context.js.map +0 -7
  427. package/dist/features/tui/simple-monitor.js +0 -116
  428. package/dist/features/tui/simple-monitor.js.map +0 -7
  429. package/dist/features/tui/swarm-monitor.js +0 -648
  430. package/dist/features/tui/swarm-monitor.js.map +0 -7
  431. package/dist/features/web/client/stores/task-store.js +0 -26
  432. package/dist/features/web/client/stores/task-store.js.map +0 -7
  433. package/dist/features/web/server/index.js +0 -194
  434. package/dist/features/web/server/index.js.map +0 -7
  435. package/dist/hooks/auto-background.js +0 -151
  436. package/dist/hooks/auto-background.js.map +0 -7
  437. package/dist/hooks/claude-code-whatsapp-hook.js +0 -197
  438. package/dist/hooks/claude-code-whatsapp-hook.js.map +0 -7
  439. package/dist/hooks/config.js +0 -150
  440. package/dist/hooks/config.js.map +0 -7
  441. package/dist/hooks/daemon.js +0 -364
  442. package/dist/hooks/daemon.js.map +0 -7
  443. package/dist/hooks/events.js +0 -58
  444. package/dist/hooks/events.js.map +0 -7
  445. package/dist/hooks/index.js +0 -12
  446. package/dist/hooks/index.js.map +0 -7
  447. package/dist/hooks/linear-task-picker.js +0 -186
  448. package/dist/hooks/linear-task-picker.js.map +0 -7
  449. package/dist/hooks/schemas.js +0 -197
  450. package/dist/hooks/schemas.js.map +0 -7
  451. package/dist/hooks/secure-fs.js +0 -49
  452. package/dist/hooks/secure-fs.js.map +0 -7
  453. package/dist/hooks/security-logger.js +0 -155
  454. package/dist/hooks/security-logger.js.map +0 -7
  455. package/dist/hooks/session-summary.js +0 -222
  456. package/dist/hooks/session-summary.js.map +0 -7
  457. package/dist/hooks/sms-action-runner.js +0 -371
  458. package/dist/hooks/sms-action-runner.js.map +0 -7
  459. package/dist/hooks/sms-notify.js +0 -506
  460. package/dist/hooks/sms-notify.js.map +0 -7
  461. package/dist/hooks/sms-watcher.js +0 -93
  462. package/dist/hooks/sms-watcher.js.map +0 -7
  463. package/dist/hooks/sms-webhook.js +0 -555
  464. package/dist/hooks/sms-webhook.js.map +0 -7
  465. package/dist/hooks/whatsapp-commands.js +0 -479
  466. package/dist/hooks/whatsapp-commands.js.map +0 -7
  467. package/dist/hooks/whatsapp-scheduler.js +0 -317
  468. package/dist/hooks/whatsapp-scheduler.js.map +0 -7
  469. package/dist/hooks/whatsapp-sync.js +0 -409
  470. package/dist/hooks/whatsapp-sync.js.map +0 -7
  471. package/dist/index.js +0 -25
  472. package/dist/index.js.map +0 -7
  473. package/dist/integrations/anthropic/client.js +0 -263
  474. package/dist/integrations/anthropic/client.js.map +0 -7
  475. package/dist/integrations/claude-code/agent-bridge.js +0 -768
  476. package/dist/integrations/claude-code/agent-bridge.js.map +0 -7
  477. package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js +0 -459
  478. package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js.map +0 -7
  479. package/dist/integrations/claude-code/lifecycle-hooks.js +0 -254
  480. package/dist/integrations/claude-code/lifecycle-hooks.js.map +0 -7
  481. package/dist/integrations/claude-code/post-task-hooks.js +0 -545
  482. package/dist/integrations/claude-code/post-task-hooks.js.map +0 -7
  483. package/dist/integrations/claude-code/subagent-client-stub.js +0 -20
  484. package/dist/integrations/claude-code/subagent-client-stub.js.map +0 -7
  485. package/dist/integrations/claude-code/subagent-client.js +0 -511
  486. package/dist/integrations/claude-code/subagent-client.js.map +0 -7
  487. package/dist/integrations/claude-code/task-coordinator.js +0 -360
  488. package/dist/integrations/claude-code/task-coordinator.js.map +0 -7
  489. package/dist/integrations/linear/auth.js +0 -337
  490. package/dist/integrations/linear/auth.js.map +0 -7
  491. package/dist/integrations/linear/auto-sync.js +0 -258
  492. package/dist/integrations/linear/auto-sync.js.map +0 -7
  493. package/dist/integrations/linear/client.js +0 -634
  494. package/dist/integrations/linear/client.js.map +0 -7
  495. package/dist/integrations/linear/config.js +0 -130
  496. package/dist/integrations/linear/config.js.map +0 -7
  497. package/dist/integrations/linear/migration.js +0 -361
  498. package/dist/integrations/linear/migration.js.map +0 -7
  499. package/dist/integrations/linear/oauth-server.js +0 -454
  500. package/dist/integrations/linear/oauth-server.js.map +0 -7
  501. package/dist/integrations/linear/rest-client.js +0 -213
  502. package/dist/integrations/linear/rest-client.js.map +0 -7
  503. package/dist/integrations/linear/sync-manager.js +0 -236
  504. package/dist/integrations/linear/sync-manager.js.map +0 -7
  505. package/dist/integrations/linear/sync-service.js +0 -231
  506. package/dist/integrations/linear/sync-service.js.map +0 -7
  507. package/dist/integrations/linear/sync.js +0 -782
  508. package/dist/integrations/linear/sync.js.map +0 -7
  509. package/dist/integrations/linear/types.js +0 -5
  510. package/dist/integrations/linear/types.js.map +0 -7
  511. package/dist/integrations/linear/unified-sync.js +0 -589
  512. package/dist/integrations/linear/unified-sync.js.map +0 -7
  513. package/dist/integrations/linear/webhook-handler.js +0 -219
  514. package/dist/integrations/linear/webhook-handler.js.map +0 -7
  515. package/dist/integrations/linear/webhook-server.js +0 -218
  516. package/dist/integrations/linear/webhook-server.js.map +0 -7
  517. package/dist/integrations/linear/webhook.js +0 -291
  518. package/dist/integrations/linear/webhook.js.map +0 -7
  519. package/dist/integrations/mcp/handlers/code-execution-handlers.js +0 -266
  520. package/dist/integrations/mcp/handlers/code-execution-handlers.js.map +0 -7
  521. package/dist/integrations/mcp/handlers/context-handlers.js +0 -257
  522. package/dist/integrations/mcp/handlers/context-handlers.js.map +0 -7
  523. package/dist/integrations/mcp/handlers/discovery-handlers.js +0 -497
  524. package/dist/integrations/mcp/handlers/discovery-handlers.js.map +0 -7
  525. package/dist/integrations/mcp/handlers/index.js +0 -166
  526. package/dist/integrations/mcp/handlers/index.js.map +0 -7
  527. package/dist/integrations/mcp/handlers/linear-handlers.js +0 -247
  528. package/dist/integrations/mcp/handlers/linear-handlers.js.map +0 -7
  529. package/dist/integrations/mcp/handlers/skill-handlers.js +0 -529
  530. package/dist/integrations/mcp/handlers/skill-handlers.js.map +0 -7
  531. package/dist/integrations/mcp/handlers/task-handlers.js +0 -239
  532. package/dist/integrations/mcp/handlers/task-handlers.js.map +0 -7
  533. package/dist/integrations/mcp/handlers/trace-handlers.js +0 -308
  534. package/dist/integrations/mcp/handlers/trace-handlers.js.map +0 -7
  535. package/dist/integrations/mcp/index.js +0 -23
  536. package/dist/integrations/mcp/index.js.map +0 -7
  537. package/dist/integrations/mcp/middleware/tool-scoring.js +0 -356
  538. package/dist/integrations/mcp/middleware/tool-scoring.js.map +0 -7
  539. package/dist/integrations/mcp/refactored-server.js +0 -374
  540. package/dist/integrations/mcp/refactored-server.js.map +0 -7
  541. package/dist/integrations/mcp/remote-server.js +0 -682
  542. package/dist/integrations/mcp/remote-server.js.map +0 -7
  543. package/dist/integrations/mcp/schemas.js +0 -147
  544. package/dist/integrations/mcp/schemas.js.map +0 -7
  545. package/dist/integrations/mcp/server.js +0 -1975
  546. package/dist/integrations/mcp/server.js.map +0 -7
  547. package/dist/integrations/mcp/tool-definitions-code.js +0 -125
  548. package/dist/integrations/mcp/tool-definitions-code.js.map +0 -7
  549. package/dist/integrations/mcp/tool-definitions.js +0 -702
  550. package/dist/integrations/mcp/tool-definitions.js.map +0 -7
  551. package/dist/integrations/mcp/trace-test.js +0 -48
  552. package/dist/integrations/mcp/trace-test.js.map +0 -7
  553. package/dist/integrations/pg-aiguide/embedding-provider.js +0 -189
  554. package/dist/integrations/pg-aiguide/embedding-provider.js.map +0 -7
  555. package/dist/integrations/pg-aiguide/semantic-search.js +0 -187
  556. package/dist/integrations/pg-aiguide/semantic-search.js.map +0 -7
  557. package/dist/integrations/pg-aiguide/timescale-analytics.js +0 -224
  558. package/dist/integrations/pg-aiguide/timescale-analytics.js.map +0 -7
  559. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -860
  560. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +0 -7
  561. package/dist/integrations/ralph/context/context-budget-manager.js +0 -301
  562. package/dist/integrations/ralph/context/context-budget-manager.js.map +0 -7
  563. package/dist/integrations/ralph/context/stackmemory-context-loader.js +0 -360
  564. package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +0 -7
  565. package/dist/integrations/ralph/coordination/enhanced-coordination.js +0 -410
  566. package/dist/integrations/ralph/coordination/enhanced-coordination.js.map +0 -7
  567. package/dist/integrations/ralph/index.js +0 -18
  568. package/dist/integrations/ralph/index.js.map +0 -7
  569. package/dist/integrations/ralph/learning/pattern-learner.js +0 -401
  570. package/dist/integrations/ralph/learning/pattern-learner.js.map +0 -7
  571. package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
  572. package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +0 -7
  573. package/dist/integrations/ralph/monitoring/swarm-dashboard.js +0 -294
  574. package/dist/integrations/ralph/monitoring/swarm-dashboard.js.map +0 -7
  575. package/dist/integrations/ralph/monitoring/swarm-registry.js +0 -108
  576. package/dist/integrations/ralph/monitoring/swarm-registry.js.map +0 -7
  577. package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -463
  578. package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +0 -7
  579. package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -400
  580. package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js.map +0 -7
  581. package/dist/integrations/ralph/patterns/extended-coherence-sessions.js +0 -473
  582. package/dist/integrations/ralph/patterns/extended-coherence-sessions.js.map +0 -7
  583. package/dist/integrations/ralph/patterns/oracle-worker-pattern.js +0 -388
  584. package/dist/integrations/ralph/patterns/oracle-worker-pattern.js.map +0 -7
  585. package/dist/integrations/ralph/performance/performance-optimizer.js +0 -358
  586. package/dist/integrations/ralph/performance/performance-optimizer.js.map +0 -7
  587. package/dist/integrations/ralph/ralph-integration-demo.js +0 -182
  588. package/dist/integrations/ralph/ralph-integration-demo.js.map +0 -7
  589. package/dist/integrations/ralph/recovery/crash-recovery.js +0 -462
  590. package/dist/integrations/ralph/recovery/crash-recovery.js.map +0 -7
  591. package/dist/integrations/ralph/state/state-reconciler.js +0 -404
  592. package/dist/integrations/ralph/state/state-reconciler.js.map +0 -7
  593. package/dist/integrations/ralph/swarm/git-workflow-manager.js +0 -428
  594. package/dist/integrations/ralph/swarm/git-workflow-manager.js.map +0 -7
  595. package/dist/integrations/ralph/swarm/swarm-coordinator.js +0 -996
  596. package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +0 -7
  597. package/dist/integrations/ralph/types.js +0 -5
  598. package/dist/integrations/ralph/types.js.map +0 -7
  599. package/dist/integrations/ralph/visualization/ralph-debugger.js +0 -585
  600. package/dist/integrations/ralph/visualization/ralph-debugger.js.map +0 -7
  601. package/dist/mcp/stackmemory-mcp-server.js +0 -554
  602. package/dist/mcp/stackmemory-mcp-server.js.map +0 -7
  603. package/dist/middleware/exponential-rate-limiter.js +0 -289
  604. package/dist/middleware/exponential-rate-limiter.js.map +0 -7
  605. package/dist/models/user.model.js +0 -358
  606. package/dist/models/user.model.js.map +0 -7
  607. package/dist/servers/production/auth-middleware.js +0 -528
  608. package/dist/servers/production/auth-middleware.js.map +0 -7
  609. package/dist/servers/railway/config.js +0 -55
  610. package/dist/servers/railway/config.js.map +0 -7
  611. package/dist/servers/railway/index-enhanced.js +0 -160
  612. package/dist/servers/railway/index-enhanced.js.map +0 -7
  613. package/dist/servers/railway/index.js +0 -1349
  614. package/dist/servers/railway/index.js.map +0 -7
  615. package/dist/servers/railway/simple.js +0 -64
  616. package/dist/servers/railway/simple.js.map +0 -7
  617. package/dist/servers/railway/storage-test.js +0 -459
  618. package/dist/servers/railway/storage-test.js.map +0 -7
  619. package/dist/services/config-service.js +0 -65
  620. package/dist/services/config-service.js.map +0 -7
  621. package/dist/services/context-service.js +0 -194
  622. package/dist/services/context-service.js.map +0 -7
  623. package/dist/skills/api-discovery.js +0 -354
  624. package/dist/skills/api-discovery.js.map +0 -7
  625. package/dist/skills/api-skill.js +0 -475
  626. package/dist/skills/api-skill.js.map +0 -7
  627. package/dist/skills/claude-skills.js +0 -1061
  628. package/dist/skills/claude-skills.js.map +0 -7
  629. package/dist/skills/dashboard-launcher.js +0 -216
  630. package/dist/skills/dashboard-launcher.js.map +0 -7
  631. package/dist/skills/recursive-agent-orchestrator.js +0 -575
  632. package/dist/skills/recursive-agent-orchestrator.js.map +0 -7
  633. package/dist/skills/repo-ingestion-skill.js +0 -609
  634. package/dist/skills/repo-ingestion-skill.js.map +0 -7
  635. package/dist/skills/security-secrets-scanner.js +0 -284
  636. package/dist/skills/security-secrets-scanner.js.map +0 -7
  637. package/dist/skills/unified-rlm-orchestrator.js +0 -404
  638. package/dist/skills/unified-rlm-orchestrator.js.map +0 -7
  639. package/dist/types/task.js +0 -5
  640. package/dist/types/task.js.map +0 -7
  641. package/dist/utils/env.js +0 -50
  642. package/dist/utils/env.js.map +0 -7
  643. package/dist/utils/formatting.js +0 -62
  644. package/dist/utils/formatting.js.map +0 -7
  645. package/dist/utils/process-cleanup.js +0 -136
  646. package/dist/utils/process-cleanup.js.map +0 -7
  647. package/dist/validation/schemas.js +0 -222
  648. package/dist/validation/schemas.js.map +0 -7
  649. /package/dist/{core/merge → src/core/extensions}/types.js +0 -0
  650. /package/dist/{core/merge → src/core/extensions}/types.js.map +0 -0
  651. /package/dist/{core → src/integrations/diffmem}/types.js +0 -0
  652. /package/dist/{core → src/integrations/diffmem}/types.js.map +0 -0
@@ -0,0 +1,494 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * GEPA Auto-Optimizer
4
+ *
5
+ * Watches CLAUDE.md for changes and automatically runs optimization.
6
+ * Shows before/after comparison with metrics.
7
+ *
8
+ * Usage:
9
+ * node auto-optimize.js watch [path] # Watch and auto-optimize
10
+ * node auto-optimize.js compare [a] [b] # Compare two versions
11
+ * node auto-optimize.js report # Show optimization report
12
+ */
13
+
14
+ import fs from 'fs';
15
+ import path from 'path';
16
+ import { fileURLToPath } from 'url';
17
+ import { execSync, spawn } from 'child_process';
18
+ import crypto from 'crypto';
19
+
20
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
21
+ const GEPA_DIR = path.join(__dirname, '..');
22
+ const GENERATIONS_DIR = path.join(GEPA_DIR, 'generations');
23
+ const RESULTS_DIR = path.join(GEPA_DIR, 'results');
24
+
25
+ // ANSI colors
26
+ const c = {
27
+ reset: '\x1b[0m',
28
+ bold: '\x1b[1m',
29
+ dim: '\x1b[2m',
30
+ red: '\x1b[31m',
31
+ green: '\x1b[32m',
32
+ yellow: '\x1b[33m',
33
+ blue: '\x1b[34m',
34
+ magenta: '\x1b[35m',
35
+ cyan: '\x1b[36m',
36
+ bgGreen: '\x1b[42m',
37
+ bgRed: '\x1b[41m',
38
+ bgYellow: '\x1b[43m',
39
+ };
40
+
41
+ /**
42
+ * Calculate content hash for change detection
43
+ */
44
+ function hashContent(content) {
45
+ return crypto.createHash('md5').update(content).digest('hex').slice(0, 8);
46
+ }
47
+
48
+ /**
49
+ * Analyze markdown structure
50
+ */
51
+ function analyzeMarkdown(content) {
52
+ const lines = content.split('\n');
53
+
54
+ return {
55
+ totalLines: lines.length,
56
+ totalChars: content.length,
57
+ estimatedTokens: Math.ceil(content.length / 4),
58
+
59
+ // Structure
60
+ h1Count: (content.match(/^# /gm) || []).length,
61
+ h2Count: (content.match(/^## /gm) || []).length,
62
+ h3Count: (content.match(/^### /gm) || []).length,
63
+
64
+ // Content types
65
+ codeBlocks: (content.match(/```/g) || []).length / 2,
66
+ bulletPoints: (content.match(/^[-*] /gm) || []).length,
67
+ numberedLists: (content.match(/^\d+\. /gm) || []).length,
68
+
69
+ // Keywords (instruction density)
70
+ mustCount: (content.match(/\bMUST\b/gi) || []).length,
71
+ neverCount: (content.match(/\bNEVER\b/gi) || []).length,
72
+ alwaysCount: (content.match(/\bALWAYS\b/gi) || []).length,
73
+ importantCount: (content.match(/\bIMPORTANT\b/gi) || []).length,
74
+
75
+ // Sections
76
+ sections: [...content.matchAll(/^##+ (.+)$/gm)].map((m) => m[1]),
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Format comparison table
82
+ */
83
+ function formatComparison(before, after, label = 'Metric') {
84
+ const metrics = [
85
+ ['Lines', before.totalLines, after.totalLines],
86
+ ['Characters', before.totalChars, after.totalChars],
87
+ ['Est. Tokens', before.estimatedTokens, after.estimatedTokens],
88
+ ['H2 Sections', before.h2Count, after.h2Count],
89
+ ['Code Blocks', before.codeBlocks, after.codeBlocks],
90
+ ['Bullet Points', before.bulletPoints, after.bulletPoints],
91
+ ['MUST rules', before.mustCount, after.mustCount],
92
+ ['NEVER rules', before.neverCount, after.neverCount],
93
+ ['ALWAYS rules', before.alwaysCount, after.alwaysCount],
94
+ ];
95
+
96
+ console.log(
97
+ `\n${c.bold}${c.cyan}╔════════════════════════════════════════════════════════════╗${c.reset}`
98
+ );
99
+ console.log(
100
+ `${c.bold}${c.cyan}║${c.reset} ${c.bold}BEFORE / AFTER COMPARISON${c.reset} ${c.cyan}║${c.reset}`
101
+ );
102
+ console.log(
103
+ `${c.cyan}╠════════════════════════════════════════════════════════════╣${c.reset}`
104
+ );
105
+ console.log(
106
+ `${c.cyan}║${c.reset} ${c.dim}Metric${c.reset} ${c.dim}Before${c.reset} ${c.dim}After${c.reset} ${c.dim}Change${c.reset} ${c.cyan}║${c.reset}`
107
+ );
108
+ console.log(
109
+ `${c.cyan}╠════════════════════════════════════════════════════════════╣${c.reset}`
110
+ );
111
+
112
+ metrics.forEach(([name, b, a]) => {
113
+ const diff = a - b;
114
+ const pct = b > 0 ? ((diff / b) * 100).toFixed(0) : '∞';
115
+ const sign = diff > 0 ? '+' : '';
116
+ const color = diff > 0 ? c.green : diff < 0 ? c.red : c.dim;
117
+
118
+ const nameStr = name.padEnd(18);
119
+ const beforeStr = String(b).padStart(8);
120
+ const afterStr = String(a).padStart(8);
121
+ const changeStr = `${sign}${diff} (${sign}${pct}%)`.padStart(12);
122
+
123
+ console.log(
124
+ `${c.cyan}║${c.reset} ${nameStr} ${beforeStr} ${c.bold}${afterStr}${c.reset} ${color}${changeStr}${c.reset} ${c.cyan}║${c.reset}`
125
+ );
126
+ });
127
+
128
+ console.log(
129
+ `${c.cyan}╚════════════════════════════════════════════════════════════╝${c.reset}`
130
+ );
131
+ }
132
+
133
+ /**
134
+ * Show section diff
135
+ */
136
+ function showSectionDiff(before, after) {
137
+ const beforeSections = new Set(before.sections);
138
+ const afterSections = new Set(after.sections);
139
+
140
+ const added = after.sections.filter((s) => !beforeSections.has(s));
141
+ const removed = before.sections.filter((s) => !afterSections.has(s));
142
+ const kept = before.sections.filter((s) => afterSections.has(s));
143
+
144
+ if (added.length || removed.length) {
145
+ console.log(`\n${c.bold}Section Changes:${c.reset}`);
146
+
147
+ if (removed.length) {
148
+ console.log(`${c.red} Removed:${c.reset}`);
149
+ removed.forEach((s) => console.log(`${c.red} - ${s}${c.reset}`));
150
+ }
151
+
152
+ if (added.length) {
153
+ console.log(`${c.green} Added:${c.reset}`);
154
+ added.forEach((s) => console.log(`${c.green} + ${s}${c.reset}`));
155
+ }
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Show inline diff (simplified)
161
+ */
162
+ function showInlineDiff(beforeContent, afterContent) {
163
+ const beforeLines = beforeContent.split('\n');
164
+ const afterLines = afterContent.split('\n');
165
+
166
+ console.log(`\n${c.bold}Key Changes (first 20 diffs):${c.reset}`);
167
+ console.log(c.dim + '─'.repeat(60) + c.reset);
168
+
169
+ let diffCount = 0;
170
+ const maxDiffs = 20;
171
+
172
+ // Simple line-by-line diff
173
+ const maxLen = Math.max(beforeLines.length, afterLines.length);
174
+
175
+ for (let i = 0; i < maxLen && diffCount < maxDiffs; i++) {
176
+ const b = beforeLines[i] || '';
177
+ const a = afterLines[i] || '';
178
+
179
+ if (b !== a) {
180
+ if (b && !a) {
181
+ console.log(
182
+ `${c.red}- L${i + 1}: ${b.slice(0, 70)}${b.length > 70 ? '...' : ''}${c.reset}`
183
+ );
184
+ } else if (!b && a) {
185
+ console.log(
186
+ `${c.green}+ L${i + 1}: ${a.slice(0, 70)}${a.length > 70 ? '...' : ''}${c.reset}`
187
+ );
188
+ } else if (b.trim() !== a.trim()) {
189
+ console.log(`${c.yellow}~ L${i + 1}:${c.reset}`);
190
+ console.log(
191
+ `${c.red} - ${b.slice(0, 60)}${b.length > 60 ? '...' : ''}${c.reset}`
192
+ );
193
+ console.log(
194
+ `${c.green} + ${a.slice(0, 60)}${a.length > 60 ? '...' : ''}${c.reset}`
195
+ );
196
+ }
197
+ diffCount++;
198
+ }
199
+ }
200
+
201
+ if (diffCount >= maxDiffs) {
202
+ console.log(`${c.dim} ... and more changes${c.reset}`);
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Compare two versions
208
+ */
209
+ function compare(pathA, pathB) {
210
+ const contentA = fs.readFileSync(pathA, 'utf8');
211
+ const contentB = fs.readFileSync(pathB, 'utf8');
212
+
213
+ const analysisA = analyzeMarkdown(contentA);
214
+ const analysisB = analyzeMarkdown(contentB);
215
+
216
+ console.log(`\n${c.bold}${c.magenta}GEPA Comparison Report${c.reset}`);
217
+ console.log(`${c.dim}Before: ${pathA}${c.reset}`);
218
+ console.log(`${c.dim}After: ${pathB}${c.reset}`);
219
+
220
+ formatComparison(analysisA, analysisB);
221
+ showSectionDiff(analysisA, analysisB);
222
+ showInlineDiff(contentA, contentB);
223
+
224
+ // Score summary
225
+ const tokenChange = analysisB.estimatedTokens - analysisA.estimatedTokens;
226
+ const ruleChange =
227
+ analysisB.mustCount +
228
+ analysisB.neverCount +
229
+ analysisB.alwaysCount -
230
+ (analysisA.mustCount + analysisA.neverCount + analysisA.alwaysCount);
231
+
232
+ console.log(`\n${c.bold}Summary:${c.reset}`);
233
+ console.log(
234
+ ` Token budget: ${tokenChange >= 0 ? c.yellow + '+' : c.green}${tokenChange}${c.reset} tokens`
235
+ );
236
+ console.log(
237
+ ` Rule density: ${ruleChange >= 0 ? c.green + '+' : c.red}${ruleChange}${c.reset} explicit rules`
238
+ );
239
+ }
240
+
241
+ /**
242
+ * Watch for changes and auto-optimize
243
+ */
244
+ async function watch(targetPath) {
245
+ const claudeMdPath = targetPath || path.join(process.cwd(), 'CLAUDE.md');
246
+
247
+ if (!fs.existsSync(claudeMdPath)) {
248
+ console.error(`${c.red}Error: ${claudeMdPath} not found${c.reset}`);
249
+ process.exit(1);
250
+ }
251
+
252
+ let lastHash = hashContent(fs.readFileSync(claudeMdPath, 'utf8'));
253
+ let isOptimizing = false;
254
+ let optimizeQueue = false;
255
+
256
+ console.log(`${c.bold}${c.cyan}GEPA Auto-Optimizer${c.reset}`);
257
+ console.log(`${c.dim}Watching: ${claudeMdPath}${c.reset}`);
258
+ console.log(`${c.dim}Press Ctrl+C to stop${c.reset}\n`);
259
+
260
+ // Initial analysis
261
+ const initial = analyzeMarkdown(fs.readFileSync(claudeMdPath, 'utf8'));
262
+ console.log(`${c.bold}Current state:${c.reset}`);
263
+ console.log(
264
+ ` ${initial.totalLines} lines, ~${initial.estimatedTokens} tokens`
265
+ );
266
+ console.log(
267
+ ` ${initial.h2Count} sections, ${initial.mustCount + initial.neverCount + initial.alwaysCount} explicit rules\n`
268
+ );
269
+
270
+ // Watch loop
271
+ const checkInterval = setInterval(async () => {
272
+ try {
273
+ const content = fs.readFileSync(claudeMdPath, 'utf8');
274
+ const currentHash = hashContent(content);
275
+
276
+ if (currentHash !== lastHash) {
277
+ console.log(
278
+ `\n${c.yellow}⚡ Change detected!${c.reset} (${new Date().toLocaleTimeString()})`
279
+ );
280
+
281
+ // Save before state
282
+ const beforePath = path.join(GEPA_DIR, '.before-optimize.md');
283
+ const statePath = path.join(GEPA_DIR, 'state.json');
284
+
285
+ if (fs.existsSync(statePath)) {
286
+ const state = JSON.parse(fs.readFileSync(statePath, 'utf8'));
287
+ const currentBest = path.join(
288
+ GENERATIONS_DIR,
289
+ `gen-${String(state.currentGeneration).padStart(3, '0')}`,
290
+ `${state.bestVariant}.md`
291
+ );
292
+ if (fs.existsSync(currentBest)) {
293
+ fs.copyFileSync(currentBest, beforePath);
294
+ }
295
+ }
296
+
297
+ lastHash = currentHash;
298
+
299
+ if (isOptimizing) {
300
+ optimizeQueue = true;
301
+ console.log(
302
+ `${c.dim} Optimization in progress, queued for next run${c.reset}`
303
+ );
304
+ return;
305
+ }
306
+
307
+ isOptimizing = true;
308
+
309
+ // Run quick optimization (1 generation)
310
+ console.log(`${c.cyan} Running GEPA optimization...${c.reset}`);
311
+
312
+ try {
313
+ // Re-init with new content
314
+ execSync(
315
+ `node ${path.join(GEPA_DIR, 'optimize.js')} init ${claudeMdPath}`,
316
+ {
317
+ stdio: 'pipe',
318
+ }
319
+ );
320
+
321
+ // Quick mutate + score
322
+ execSync(`node ${path.join(GEPA_DIR, 'optimize.js')} mutate`, {
323
+ stdio: 'pipe',
324
+ });
325
+
326
+ execSync(`node ${path.join(GEPA_DIR, 'optimize.js')} score`, {
327
+ stdio: 'pipe',
328
+ });
329
+
330
+ // Show comparison
331
+ const afterPath = path.join(GENERATIONS_DIR, 'current');
332
+ if (fs.existsSync(beforePath) && fs.existsSync(afterPath)) {
333
+ const resolvedAfter = fs.realpathSync(afterPath);
334
+ compare(beforePath, resolvedAfter);
335
+ }
336
+
337
+ // Load state for summary
338
+ const state = JSON.parse(fs.readFileSync(statePath, 'utf8'));
339
+ console.log(`\n${c.green}✓ Optimization complete${c.reset}`);
340
+ console.log(
341
+ ` Best variant: ${c.bold}${state.bestVariant}${c.reset}`
342
+ );
343
+ console.log(
344
+ ` Score: ${c.bold}${(state.bestScore * 100).toFixed(1)}%${c.reset}`
345
+ );
346
+ console.log(
347
+ `\n${c.dim} To apply: cp ${path.join(GENERATIONS_DIR, 'current')} ${claudeMdPath}${c.reset}`
348
+ );
349
+ } catch (e) {
350
+ console.error(
351
+ `${c.red} Optimization failed: ${e.message}${c.reset}`
352
+ );
353
+ }
354
+
355
+ isOptimizing = false;
356
+
357
+ // Process queue
358
+ if (optimizeQueue) {
359
+ optimizeQueue = false;
360
+ lastHash = ''; // Force re-check
361
+ }
362
+ }
363
+ } catch (e) {
364
+ // File might be temporarily unavailable during write
365
+ }
366
+ }, 2000); // Check every 2 seconds
367
+
368
+ // Handle shutdown
369
+ process.on('SIGINT', () => {
370
+ clearInterval(checkInterval);
371
+ console.log(`\n${c.dim}Watcher stopped${c.reset}`);
372
+ process.exit(0);
373
+ });
374
+ }
375
+
376
+ /**
377
+ * Generate optimization report
378
+ */
379
+ function report() {
380
+ const statePath = path.join(GEPA_DIR, 'state.json');
381
+
382
+ if (!fs.existsSync(statePath)) {
383
+ console.error(`${c.red}No GEPA state found. Run 'init' first.${c.reset}`);
384
+ return;
385
+ }
386
+
387
+ const state = JSON.parse(fs.readFileSync(statePath, 'utf8'));
388
+
389
+ console.log(
390
+ `\n${c.bold}${c.magenta}═══════════════════════════════════════════════════════════${c.reset}`
391
+ );
392
+ console.log(
393
+ `${c.bold}${c.magenta} GEPA OPTIMIZATION REPORT ${c.reset}`
394
+ );
395
+ console.log(
396
+ `${c.bold}${c.magenta}═══════════════════════════════════════════════════════════${c.reset}\n`
397
+ );
398
+
399
+ console.log(`${c.bold}Current State:${c.reset}`);
400
+ console.log(` Generation: ${c.cyan}${state.currentGeneration}${c.reset}`);
401
+ console.log(` Best Variant: ${c.green}${state.bestVariant}${c.reset}`);
402
+ console.log(
403
+ ` Best Score: ${c.bold}${(state.bestScore * 100).toFixed(1)}%${c.reset}`
404
+ );
405
+ console.log(` Target File: ${c.dim}${state.targetPath}${c.reset}`);
406
+
407
+ // History summary
408
+ if (state.history && state.history.length > 0) {
409
+ console.log(`\n${c.bold}Evolution History:${c.reset}`);
410
+
411
+ const scoreHistory = state.history
412
+ .filter((h) => h.action === 'select' && h.scores)
413
+ .map((h) => ({
414
+ gen: h.generation,
415
+ best: h.best,
416
+ score: h.scores.find((s) => s.variant === h.best)?.score || 0,
417
+ }));
418
+
419
+ if (scoreHistory.length > 0) {
420
+ // ASCII chart
421
+ const maxScore = Math.max(...scoreHistory.map((h) => h.score));
422
+ const chartWidth = 40;
423
+
424
+ scoreHistory.forEach((h) => {
425
+ const barLen = Math.round((h.score / maxScore) * chartWidth);
426
+ const bar = '█'.repeat(barLen) + '░'.repeat(chartWidth - barLen);
427
+ const pct = (h.score * 100).toFixed(0).padStart(3);
428
+ console.log(
429
+ ` Gen ${String(h.gen).padStart(2)}: ${c.green}${bar}${c.reset} ${pct}% (${h.best})`
430
+ );
431
+ });
432
+
433
+ // Improvement
434
+ if (scoreHistory.length > 1) {
435
+ const first = scoreHistory[0].score;
436
+ const last = scoreHistory[scoreHistory.length - 1].score;
437
+ const improvement = (((last - first) / first) * 100).toFixed(1);
438
+ console.log(
439
+ `\n ${c.bold}Total improvement: ${improvement >= 0 ? c.green + '+' : c.red}${improvement}%${c.reset}`
440
+ );
441
+ }
442
+ }
443
+ }
444
+
445
+ // Show before/after if available
446
+ const beforePath = path.join(GEPA_DIR, '.before-optimize.md');
447
+ const currentPath = path.join(GENERATIONS_DIR, 'current');
448
+
449
+ if (fs.existsSync(beforePath) && fs.existsSync(currentPath)) {
450
+ console.log(`\n${c.bold}Latest Optimization:${c.reset}`);
451
+ compare(beforePath, fs.realpathSync(currentPath));
452
+ }
453
+
454
+ console.log(
455
+ `\n${c.dim}Run 'node auto-optimize.js watch' to auto-optimize on changes${c.reset}\n`
456
+ );
457
+ }
458
+
459
+ // CLI
460
+ const command = process.argv[2];
461
+ const arg1 = process.argv[3];
462
+ const arg2 = process.argv[4];
463
+
464
+ switch (command) {
465
+ case 'watch':
466
+ watch(arg1);
467
+ break;
468
+ case 'compare':
469
+ if (!arg1 || !arg2) {
470
+ console.error('Usage: compare <before.md> <after.md>');
471
+ process.exit(1);
472
+ }
473
+ compare(arg1, arg2);
474
+ break;
475
+ case 'report':
476
+ report();
477
+ break;
478
+ default:
479
+ console.log(`
480
+ ${c.bold}GEPA Auto-Optimizer${c.reset}
481
+
482
+ Usage:
483
+ node auto-optimize.js watch [path] Watch CLAUDE.md and auto-optimize
484
+ node auto-optimize.js compare <a> <b> Compare two versions
485
+ node auto-optimize.js report Show optimization report
486
+
487
+ Examples:
488
+ node auto-optimize.js watch ./CLAUDE.md
489
+ node auto-optimize.js compare gen-000/baseline.md gen-001/variant-a.md
490
+ node auto-optimize.js report
491
+ `);
492
+ }
493
+
494
+ export { compare, analyzeMarkdown, watch, report };
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * GEPA Eval Tracker Hook
4
+ *
5
+ * Captures agent behavior during sessions for evaluation.
6
+ * Install in ~/.claude/settings.json under hooks.
7
+ */
8
+
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+
12
+ const GEPA_DIR =
13
+ process.env.GEPA_DIR || path.join(process.env.HOME, '.claude', 'gepa');
14
+ const RESULTS_DIR = path.join(GEPA_DIR, 'results');
15
+ const SESSIONS_DIR = path.join(RESULTS_DIR, 'sessions');
16
+
17
+ // Ensure directories exist
18
+ [RESULTS_DIR, SESSIONS_DIR].forEach((dir) => {
19
+ if (!fs.existsSync(dir)) {
20
+ fs.mkdirSync(dir, { recursive: true });
21
+ }
22
+ });
23
+
24
+ /**
25
+ * Session tracking state
26
+ */
27
+ class SessionTracker {
28
+ constructor() {
29
+ this.sessionId = process.env.CLAUDE_SESSION_ID || `session-${Date.now()}`;
30
+ this.variant = process.env.GEPA_VARIANT || 'baseline';
31
+ this.generation = parseInt(process.env.GEPA_GENERATION || '0');
32
+
33
+ this.data = {
34
+ sessionId: this.sessionId,
35
+ variant: this.variant,
36
+ generation: this.generation,
37
+ startTime: new Date().toISOString(),
38
+ endTime: null,
39
+ toolCalls: [],
40
+ errors: [],
41
+ userFeedback: [],
42
+ tokenUsage: { input: 0, output: 0 },
43
+ metrics: {},
44
+ };
45
+ }
46
+
47
+ trackToolCall(tool, input, output, duration) {
48
+ this.data.toolCalls.push({
49
+ tool,
50
+ input: this.sanitize(input),
51
+ output: this.summarize(output),
52
+ duration,
53
+ timestamp: new Date().toISOString(),
54
+ success: !output?.error,
55
+ });
56
+ }
57
+
58
+ trackError(error, context) {
59
+ this.data.errors.push({
60
+ error: error.message || String(error),
61
+ context,
62
+ timestamp: new Date().toISOString(),
63
+ });
64
+ }
65
+
66
+ trackFeedback(type, value) {
67
+ this.data.userFeedback.push({
68
+ type, // 'thumbs_up', 'thumbs_down', 'correction', 'retry'
69
+ value,
70
+ timestamp: new Date().toISOString(),
71
+ });
72
+ }
73
+
74
+ trackTokens(input, output) {
75
+ this.data.tokenUsage.input += input;
76
+ this.data.tokenUsage.output += output;
77
+ }
78
+
79
+ sanitize(obj) {
80
+ // Remove sensitive data
81
+ if (typeof obj !== 'object') return obj;
82
+ const sanitized = { ...obj };
83
+ const sensitiveKeys = ['apiKey', 'token', 'password', 'secret', 'key'];
84
+ for (const key of Object.keys(sanitized)) {
85
+ if (sensitiveKeys.some((s) => key.toLowerCase().includes(s))) {
86
+ sanitized[key] = '[REDACTED]';
87
+ }
88
+ }
89
+ return sanitized;
90
+ }
91
+
92
+ summarize(output) {
93
+ // Truncate long outputs
94
+ const str = typeof output === 'string' ? output : JSON.stringify(output);
95
+ return str.length > 1000 ? str.slice(0, 1000) + '...[truncated]' : str;
96
+ }
97
+
98
+ finalize() {
99
+ this.data.endTime = new Date().toISOString();
100
+ this.data.duration =
101
+ new Date(this.data.endTime) - new Date(this.data.startTime);
102
+
103
+ // Calculate basic metrics
104
+ this.data.metrics = {
105
+ totalToolCalls: this.data.toolCalls.length,
106
+ successfulToolCalls: this.data.toolCalls.filter((t) => t.success).length,
107
+ errorCount: this.data.errors.length,
108
+ avgToolDuration:
109
+ this.data.toolCalls.length > 0
110
+ ? this.data.toolCalls.reduce((sum, t) => sum + (t.duration || 0), 0) /
111
+ this.data.toolCalls.length
112
+ : 0,
113
+ positiveFeeback: this.data.userFeedback.filter(
114
+ (f) => f.type === 'thumbs_up'
115
+ ).length,
116
+ negativeFeeback: this.data.userFeedback.filter(
117
+ (f) => f.type === 'thumbs_down'
118
+ ).length,
119
+ };
120
+
121
+ return this.data;
122
+ }
123
+
124
+ save() {
125
+ const data = this.finalize();
126
+ const filename = `${this.generation}-${this.variant}-${this.sessionId}.json`;
127
+ const filepath = path.join(SESSIONS_DIR, filename);
128
+ fs.writeFileSync(filepath, JSON.stringify(data, null, 2));
129
+
130
+ // Also append to scores.jsonl for quick analysis
131
+ const scoreLine = {
132
+ sessionId: this.sessionId,
133
+ variant: this.variant,
134
+ generation: this.generation,
135
+ metrics: data.metrics,
136
+ timestamp: data.endTime,
137
+ };
138
+ fs.appendFileSync(
139
+ path.join(RESULTS_DIR, 'scores.jsonl'),
140
+ JSON.stringify(scoreLine) + '\n'
141
+ );
142
+
143
+ return filepath;
144
+ }
145
+ }
146
+
147
+ // Global tracker instance
148
+ let tracker = null;
149
+
150
+ /**
151
+ * Hook handlers
152
+ */
153
+ export function onSessionStart(context) {
154
+ tracker = new SessionTracker();
155
+ console.error(
156
+ `[GEPA] Tracking session: ${tracker.sessionId} (gen=${tracker.generation}, variant=${tracker.variant})`
157
+ );
158
+ }
159
+
160
+ export function onToolCall(tool, input) {
161
+ if (!tracker) return;
162
+ tracker._currentTool = { tool, input, startTime: Date.now() };
163
+ }
164
+
165
+ export function onToolResult(tool, result) {
166
+ if (!tracker || !tracker._currentTool) return;
167
+ const duration = Date.now() - tracker._currentTool.startTime;
168
+ tracker.trackToolCall(tool, tracker._currentTool.input, result, duration);
169
+ tracker._currentTool = null;
170
+ }
171
+
172
+ export function onError(error, context) {
173
+ if (!tracker) return;
174
+ tracker.trackError(error, context);
175
+ }
176
+
177
+ export function onUserFeedback(type, value) {
178
+ if (!tracker) return;
179
+ tracker.trackFeedback(type, value);
180
+ }
181
+
182
+ export function onSessionEnd() {
183
+ if (!tracker) return;
184
+ const filepath = tracker.save();
185
+ console.error(`[GEPA] Session data saved to: ${filepath}`);
186
+ tracker = null;
187
+ }
188
+
189
+ // CLI interface for testing
190
+ if (process.argv[1] === import.meta.url.replace('file://', '')) {
191
+ const command = process.argv[2];
192
+
193
+ if (command === 'test') {
194
+ onSessionStart({});
195
+ onToolCall('Read', { file: '/test/file.ts' });
196
+ onToolResult('Read', { content: 'test content...' });
197
+ onToolCall('Edit', { file: '/test/file.ts', changes: '...' });
198
+ onToolResult('Edit', { success: true });
199
+ onUserFeedback('thumbs_up', 'good job');
200
+ onSessionEnd();
201
+ console.log('Test session recorded');
202
+ }
203
+ }