@stackmemoryai/stackmemory 0.5.59 → 0.5.61

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 (632) hide show
  1. package/README.md +105 -1
  2. package/dist/src/cli/claude-sm.js +130 -50
  3. package/dist/src/cli/claude-sm.js.map +2 -2
  4. package/dist/src/cli/index.js +18 -3
  5. package/dist/src/cli/index.js.map +3 -3
  6. package/dist/src/core/extensions/custom-tools.js +567 -0
  7. package/dist/src/core/extensions/custom-tools.js.map +7 -0
  8. package/dist/src/core/extensions/index.js +55 -0
  9. package/dist/src/core/extensions/index.js.map +7 -0
  10. package/dist/src/core/extensions/loader.js +709 -0
  11. package/dist/src/core/extensions/loader.js.map +7 -0
  12. package/dist/src/core/extensions/plugin-system.js +506 -0
  13. package/dist/src/core/extensions/plugin-system.js.map +7 -0
  14. package/dist/src/core/extensions/provider-adapter.js +617 -0
  15. package/dist/src/core/extensions/provider-adapter.js.map +7 -0
  16. package/dist/src/core/extensions/sandbox-runtime.js +664 -0
  17. package/dist/src/core/extensions/sandbox-runtime.js.map +7 -0
  18. package/dist/src/core/storage/chromadb-adapter.js +32 -6
  19. package/dist/src/core/storage/chromadb-adapter.js.map +2 -2
  20. package/dist/src/skills/repo-ingestion-skill.js +35 -12
  21. package/dist/src/skills/repo-ingestion-skill.js.map +2 -2
  22. package/package.json +11 -7
  23. package/scripts/background-sync-manager.js +145 -83
  24. package/scripts/claude-sm-autostart.js +17 -12
  25. package/scripts/gepa/README.md +275 -0
  26. package/scripts/gepa/config.json +53 -0
  27. package/scripts/gepa/evals/coding-tasks.jsonl +5 -0
  28. package/scripts/gepa/evals/fixtures/buggy-loop.js +18 -0
  29. package/scripts/gepa/evals/fixtures/callback-hell.js +53 -0
  30. package/scripts/gepa/generations/gen-000/baseline.md +124 -0
  31. package/scripts/gepa/hooks/auto-optimize.js +494 -0
  32. package/scripts/gepa/hooks/eval-tracker.js +203 -0
  33. package/scripts/gepa/hooks/reflect.js +311 -0
  34. package/scripts/gepa/optimize.js +611 -0
  35. package/scripts/gepa/state.json +14 -0
  36. package/scripts/test-pre-publish-quick.sh +1 -1
  37. package/dist/agents/core/agent-task-manager.js +0 -527
  38. package/dist/agents/core/agent-task-manager.js.map +0 -7
  39. package/dist/agents/testing-agent.js +0 -614
  40. package/dist/agents/testing-agent.js.map +0 -7
  41. package/dist/agents/verifiers/base-verifier.js +0 -133
  42. package/dist/agents/verifiers/base-verifier.js.map +0 -7
  43. package/dist/agents/verifiers/formatter-verifier.js +0 -130
  44. package/dist/agents/verifiers/formatter-verifier.js.map +0 -7
  45. package/dist/agents/verifiers/llm-judge.js +0 -252
  46. package/dist/agents/verifiers/llm-judge.js.map +0 -7
  47. package/dist/cli/auto-detect.js +0 -321
  48. package/dist/cli/auto-detect.js.map +0 -7
  49. package/dist/cli/browser-test.js +0 -33
  50. package/dist/cli/browser-test.js.map +0 -7
  51. package/dist/cli/claude-sm-danger.js +0 -21
  52. package/dist/cli/claude-sm-danger.js.map +0 -7
  53. package/dist/cli/claude-sm.js +0 -1156
  54. package/dist/cli/claude-sm.js.map +0 -7
  55. package/dist/cli/codex-sm-danger.js +0 -21
  56. package/dist/cli/codex-sm-danger.js.map +0 -7
  57. package/dist/cli/codex-sm.js +0 -349
  58. package/dist/cli/codex-sm.js.map +0 -7
  59. package/dist/cli/commands/api.js +0 -232
  60. package/dist/cli/commands/api.js.map +0 -7
  61. package/dist/cli/commands/auto-background.js +0 -180
  62. package/dist/cli/commands/auto-background.js.map +0 -7
  63. package/dist/cli/commands/cleanup-processes.js +0 -68
  64. package/dist/cli/commands/cleanup-processes.js.map +0 -7
  65. package/dist/cli/commands/clear.js +0 -202
  66. package/dist/cli/commands/clear.js.map +0 -7
  67. package/dist/cli/commands/config.js +0 -445
  68. package/dist/cli/commands/config.js.map +0 -7
  69. package/dist/cli/commands/context-rehydrate.js +0 -751
  70. package/dist/cli/commands/context-rehydrate.js.map +0 -7
  71. package/dist/cli/commands/context.js +0 -343
  72. package/dist/cli/commands/context.js.map +0 -7
  73. package/dist/cli/commands/daemon.js +0 -392
  74. package/dist/cli/commands/daemon.js.map +0 -7
  75. package/dist/cli/commands/dashboard.js +0 -210
  76. package/dist/cli/commands/dashboard.js.map +0 -7
  77. package/dist/cli/commands/db.js +0 -147
  78. package/dist/cli/commands/db.js.map +0 -7
  79. package/dist/cli/commands/decision.js +0 -266
  80. package/dist/cli/commands/decision.js.map +0 -7
  81. package/dist/cli/commands/discovery.js +0 -279
  82. package/dist/cli/commands/discovery.js.map +0 -7
  83. package/dist/cli/commands/handoff.js +0 -624
  84. package/dist/cli/commands/handoff.js.map +0 -7
  85. package/dist/cli/commands/hooks.js +0 -298
  86. package/dist/cli/commands/hooks.js.map +0 -7
  87. package/dist/cli/commands/linear-unified.js +0 -353
  88. package/dist/cli/commands/linear-unified.js.map +0 -7
  89. package/dist/cli/commands/linear.js +0 -529
  90. package/dist/cli/commands/linear.js.map +0 -7
  91. package/dist/cli/commands/log.js +0 -169
  92. package/dist/cli/commands/log.js.map +0 -7
  93. package/dist/cli/commands/login.js +0 -172
  94. package/dist/cli/commands/login.js.map +0 -7
  95. package/dist/cli/commands/migrate.js +0 -240
  96. package/dist/cli/commands/migrate.js.map +0 -7
  97. package/dist/cli/commands/model.js +0 -533
  98. package/dist/cli/commands/model.js.map +0 -7
  99. package/dist/cli/commands/monitor.js +0 -313
  100. package/dist/cli/commands/monitor.js.map +0 -7
  101. package/dist/cli/commands/onboard.js +0 -536
  102. package/dist/cli/commands/onboard.js.map +0 -7
  103. package/dist/cli/commands/projects.js +0 -199
  104. package/dist/cli/commands/projects.js.map +0 -7
  105. package/dist/cli/commands/quality.js +0 -413
  106. package/dist/cli/commands/quality.js.map +0 -7
  107. package/dist/cli/commands/ralph.js +0 -909
  108. package/dist/cli/commands/ralph.js.map +0 -7
  109. package/dist/cli/commands/retrieval.js +0 -248
  110. package/dist/cli/commands/retrieval.js.map +0 -7
  111. package/dist/cli/commands/search.js +0 -173
  112. package/dist/cli/commands/search.js.map +0 -7
  113. package/dist/cli/commands/service.js +0 -749
  114. package/dist/cli/commands/service.js.map +0 -7
  115. package/dist/cli/commands/session.js +0 -200
  116. package/dist/cli/commands/session.js.map +0 -7
  117. package/dist/cli/commands/settings.js +0 -306
  118. package/dist/cli/commands/settings.js.map +0 -7
  119. package/dist/cli/commands/setup.js +0 -701
  120. package/dist/cli/commands/setup.js.map +0 -7
  121. package/dist/cli/commands/shell.js +0 -249
  122. package/dist/cli/commands/shell.js.map +0 -7
  123. package/dist/cli/commands/signup.js +0 -50
  124. package/dist/cli/commands/signup.js.map +0 -7
  125. package/dist/cli/commands/skills.js +0 -470
  126. package/dist/cli/commands/skills.js.map +0 -7
  127. package/dist/cli/commands/sms-notify.js +0 -795
  128. package/dist/cli/commands/sms-notify.js.map +0 -7
  129. package/dist/cli/commands/storage-tier.js +0 -183
  130. package/dist/cli/commands/storage-tier.js.map +0 -7
  131. package/dist/cli/commands/storage.js +0 -360
  132. package/dist/cli/commands/storage.js.map +0 -7
  133. package/dist/cli/commands/sweep.js +0 -249
  134. package/dist/cli/commands/sweep.js.map +0 -7
  135. package/dist/cli/commands/tasks.js +0 -213
  136. package/dist/cli/commands/tasks.js.map +0 -7
  137. package/dist/cli/commands/test.js +0 -286
  138. package/dist/cli/commands/test.js.map +0 -7
  139. package/dist/cli/commands/workflow.js +0 -142
  140. package/dist/cli/commands/workflow.js.map +0 -7
  141. package/dist/cli/commands/worktree.js +0 -319
  142. package/dist/cli/commands/worktree.js.map +0 -7
  143. package/dist/cli/index.js +0 -594
  144. package/dist/cli/index.js.map +0 -7
  145. package/dist/cli/opencode-sm.js +0 -448
  146. package/dist/cli/opencode-sm.js.map +0 -7
  147. package/dist/cli/utils/viewer.js +0 -96
  148. package/dist/cli/utils/viewer.js.map +0 -7
  149. package/dist/core/analytics/team-analytics.js +0 -378
  150. package/dist/core/analytics/team-analytics.js.map +0 -7
  151. package/dist/core/config/config-manager.js +0 -398
  152. package/dist/core/config/config-manager.js.map +0 -7
  153. package/dist/core/config/feature-flags.js +0 -76
  154. package/dist/core/config/feature-flags.js.map +0 -7
  155. package/dist/core/config/storage-config.js +0 -115
  156. package/dist/core/config/storage-config.js.map +0 -7
  157. package/dist/core/config/types.js +0 -144
  158. package/dist/core/config/types.js.map +0 -7
  159. package/dist/core/context/auto-context.js +0 -80
  160. package/dist/core/context/auto-context.js.map +0 -7
  161. package/dist/core/context/dual-stack-manager.js +0 -870
  162. package/dist/core/context/dual-stack-manager.js.map +0 -7
  163. package/dist/core/context/enhanced-rehydration.js +0 -994
  164. package/dist/core/context/enhanced-rehydration.js.map +0 -7
  165. package/dist/core/context/frame-database.js +0 -479
  166. package/dist/core/context/frame-database.js.map +0 -7
  167. package/dist/core/context/frame-digest.js +0 -250
  168. package/dist/core/context/frame-digest.js.map +0 -7
  169. package/dist/core/context/frame-handoff-manager.js +0 -778
  170. package/dist/core/context/frame-handoff-manager.js.map +0 -7
  171. package/dist/core/context/frame-lifecycle-hooks.js +0 -119
  172. package/dist/core/context/frame-lifecycle-hooks.js.map +0 -7
  173. package/dist/core/context/frame-manager.js +0 -1069
  174. package/dist/core/context/frame-manager.js.map +0 -7
  175. package/dist/core/context/frame-recovery.js +0 -302
  176. package/dist/core/context/frame-recovery.js.map +0 -7
  177. package/dist/core/context/frame-stack.js +0 -314
  178. package/dist/core/context/frame-stack.js.map +0 -7
  179. package/dist/core/context/frame-types.js +0 -5
  180. package/dist/core/context/frame-types.js.map +0 -7
  181. package/dist/core/context/incremental-gc.js +0 -290
  182. package/dist/core/context/incremental-gc.js.map +0 -7
  183. package/dist/core/context/index.js +0 -25
  184. package/dist/core/context/index.js.map +0 -7
  185. package/dist/core/context/model-aware-compaction.js +0 -623
  186. package/dist/core/context/model-aware-compaction.js.map +0 -7
  187. package/dist/core/context/permission-manager.js +0 -185
  188. package/dist/core/context/permission-manager.js.map +0 -7
  189. package/dist/core/context/recursive-context-manager.js +0 -592
  190. package/dist/core/context/recursive-context-manager.js.map +0 -7
  191. package/dist/core/context/refactored-frame-manager.js +0 -754
  192. package/dist/core/context/refactored-frame-manager.js.map +0 -7
  193. package/dist/core/context/shared-context-layer.js +0 -621
  194. package/dist/core/context/shared-context-layer.js.map +0 -7
  195. package/dist/core/context/stack-merge-resolver.js +0 -749
  196. package/dist/core/context/stack-merge-resolver.js.map +0 -7
  197. package/dist/core/context/validation.js +0 -130
  198. package/dist/core/context/validation.js.map +0 -7
  199. package/dist/core/database/batch-operations.js +0 -384
  200. package/dist/core/database/batch-operations.js.map +0 -7
  201. package/dist/core/database/connection-pool.js +0 -330
  202. package/dist/core/database/connection-pool.js.map +0 -7
  203. package/dist/core/database/database-adapter.js +0 -60
  204. package/dist/core/database/database-adapter.js.map +0 -7
  205. package/dist/core/database/migration-manager.js +0 -614
  206. package/dist/core/database/migration-manager.js.map +0 -7
  207. package/dist/core/database/paradedb-adapter.js +0 -990
  208. package/dist/core/database/paradedb-adapter.js.map +0 -7
  209. package/dist/core/database/query-cache.js +0 -298
  210. package/dist/core/database/query-cache.js.map +0 -7
  211. package/dist/core/database/query-router.js +0 -430
  212. package/dist/core/database/query-router.js.map +0 -7
  213. package/dist/core/database/sqlite-adapter.js +0 -738
  214. package/dist/core/database/sqlite-adapter.js.map +0 -7
  215. package/dist/core/digest/enhanced-hybrid-digest.js +0 -277
  216. package/dist/core/digest/enhanced-hybrid-digest.js.map +0 -7
  217. package/dist/core/digest/frame-digest-integration.js +0 -176
  218. package/dist/core/digest/frame-digest-integration.js.map +0 -7
  219. package/dist/core/digest/hybrid-digest-generator.js +0 -553
  220. package/dist/core/digest/hybrid-digest-generator.js.map +0 -7
  221. package/dist/core/digest/index.js +0 -9
  222. package/dist/core/digest/index.js.map +0 -7
  223. package/dist/core/digest/types.js +0 -25
  224. package/dist/core/digest/types.js.map +0 -7
  225. package/dist/core/errors/error-utils.js +0 -208
  226. package/dist/core/errors/error-utils.js.map +0 -7
  227. package/dist/core/errors/index.js +0 -521
  228. package/dist/core/errors/index.js.map +0 -7
  229. package/dist/core/errors/recovery.js +0 -269
  230. package/dist/core/errors/recovery.js.map +0 -7
  231. package/dist/core/execution/parallel-executor.js +0 -258
  232. package/dist/core/execution/parallel-executor.js.map +0 -7
  233. package/dist/core/frame/workflow-templates.js +0 -319
  234. package/dist/core/frame/workflow-templates.js.map +0 -7
  235. package/dist/core/merge/conflict-detector.js +0 -431
  236. package/dist/core/merge/conflict-detector.js.map +0 -7
  237. package/dist/core/merge/index.js +0 -9
  238. package/dist/core/merge/index.js.map +0 -7
  239. package/dist/core/merge/resolution-engine.js +0 -558
  240. package/dist/core/merge/resolution-engine.js.map +0 -7
  241. package/dist/core/merge/stack-diff.js +0 -532
  242. package/dist/core/merge/stack-diff.js.map +0 -7
  243. package/dist/core/merge/unified-merge-resolver.js +0 -303
  244. package/dist/core/merge/unified-merge-resolver.js.map +0 -7
  245. package/dist/core/models/fallback-monitor.js +0 -232
  246. package/dist/core/models/fallback-monitor.js.map +0 -7
  247. package/dist/core/models/model-router.js +0 -340
  248. package/dist/core/models/model-router.js.map +0 -7
  249. package/dist/core/monitoring/error-handler.js +0 -49
  250. package/dist/core/monitoring/error-handler.js.map +0 -7
  251. package/dist/core/monitoring/logger.js +0 -202
  252. package/dist/core/monitoring/logger.js.map +0 -7
  253. package/dist/core/monitoring/metrics.js +0 -172
  254. package/dist/core/monitoring/metrics.js.map +0 -7
  255. package/dist/core/monitoring/progress-tracker.js +0 -189
  256. package/dist/core/monitoring/progress-tracker.js.map +0 -7
  257. package/dist/core/monitoring/session-monitor.js +0 -300
  258. package/dist/core/monitoring/session-monitor.js.map +0 -7
  259. package/dist/core/performance/context-cache.js +0 -273
  260. package/dist/core/performance/context-cache.js.map +0 -7
  261. package/dist/core/performance/index.js +0 -11
  262. package/dist/core/performance/index.js.map +0 -7
  263. package/dist/core/performance/lazy-context-loader.js +0 -327
  264. package/dist/core/performance/lazy-context-loader.js.map +0 -7
  265. package/dist/core/performance/monitor.js +0 -221
  266. package/dist/core/performance/monitor.js.map +0 -7
  267. package/dist/core/performance/optimized-frame-context.js +0 -345
  268. package/dist/core/performance/optimized-frame-context.js.map +0 -7
  269. package/dist/core/performance/performance-benchmark.js +0 -277
  270. package/dist/core/performance/performance-benchmark.js.map +0 -7
  271. package/dist/core/performance/performance-profiler.js +0 -370
  272. package/dist/core/performance/performance-profiler.js.map +0 -7
  273. package/dist/core/performance/streaming-jsonl-parser.js +0 -195
  274. package/dist/core/performance/streaming-jsonl-parser.js.map +0 -7
  275. package/dist/core/persistence/postgres-adapter.js +0 -349
  276. package/dist/core/persistence/postgres-adapter.js.map +0 -7
  277. package/dist/core/projects/project-isolation.js +0 -201
  278. package/dist/core/projects/project-isolation.js.map +0 -7
  279. package/dist/core/projects/project-manager.js +0 -697
  280. package/dist/core/projects/project-manager.js.map +0 -7
  281. package/dist/core/query/query-parser.js +0 -370
  282. package/dist/core/query/query-parser.js.map +0 -7
  283. package/dist/core/query/query-templates.js +0 -321
  284. package/dist/core/query/query-templates.js.map +0 -7
  285. package/dist/core/retrieval/context-retriever.js +0 -479
  286. package/dist/core/retrieval/context-retriever.js.map +0 -7
  287. package/dist/core/retrieval/graph-retrieval.js +0 -662
  288. package/dist/core/retrieval/graph-retrieval.js.map +0 -7
  289. package/dist/core/retrieval/hierarchical-retrieval.js +0 -656
  290. package/dist/core/retrieval/hierarchical-retrieval.js.map +0 -7
  291. package/dist/core/retrieval/index.js +0 -8
  292. package/dist/core/retrieval/index.js.map +0 -7
  293. package/dist/core/retrieval/llm-context-retrieval.js +0 -613
  294. package/dist/core/retrieval/llm-context-retrieval.js.map +0 -7
  295. package/dist/core/retrieval/llm-provider.js +0 -151
  296. package/dist/core/retrieval/llm-provider.js.map +0 -7
  297. package/dist/core/retrieval/retrieval-audit.js +0 -236
  298. package/dist/core/retrieval/retrieval-audit.js.map +0 -7
  299. package/dist/core/retrieval/retrieval-benchmarks.js +0 -521
  300. package/dist/core/retrieval/retrieval-benchmarks.js.map +0 -7
  301. package/dist/core/retrieval/summary-generator.js +0 -589
  302. package/dist/core/retrieval/summary-generator.js.map +0 -7
  303. package/dist/core/retrieval/types.js +0 -21
  304. package/dist/core/retrieval/types.js.map +0 -7
  305. package/dist/core/security/index.js +0 -35
  306. package/dist/core/security/index.js.map +0 -7
  307. package/dist/core/security/input-sanitizer.js +0 -321
  308. package/dist/core/security/input-sanitizer.js.map +0 -7
  309. package/dist/core/session/clear-survival.js +0 -465
  310. package/dist/core/session/clear-survival.js.map +0 -7
  311. package/dist/core/session/enhanced-handoff.js +0 -792
  312. package/dist/core/session/enhanced-handoff.js.map +0 -7
  313. package/dist/core/session/handoff-generator.js +0 -343
  314. package/dist/core/session/handoff-generator.js.map +0 -7
  315. package/dist/core/session/index.js +0 -15
  316. package/dist/core/session/index.js.map +0 -7
  317. package/dist/core/session/session-manager.js +0 -347
  318. package/dist/core/session/session-manager.js.map +0 -7
  319. package/dist/core/skills/index.js +0 -7
  320. package/dist/core/skills/index.js.map +0 -7
  321. package/dist/core/skills/skill-storage.js +0 -764
  322. package/dist/core/skills/skill-storage.js.map +0 -7
  323. package/dist/core/skills/types.js +0 -193
  324. package/dist/core/skills/types.js.map +0 -7
  325. package/dist/core/storage/chromadb-adapter.js +0 -354
  326. package/dist/core/storage/chromadb-adapter.js.map +0 -7
  327. package/dist/core/storage/infinite-storage.js +0 -510
  328. package/dist/core/storage/infinite-storage.js.map +0 -7
  329. package/dist/core/storage/railway-optimized-storage.js +0 -591
  330. package/dist/core/storage/railway-optimized-storage.js.map +0 -7
  331. package/dist/core/storage/remote-storage.js +0 -489
  332. package/dist/core/storage/remote-storage.js.map +0 -7
  333. package/dist/core/storage/two-tier-storage.js +0 -766
  334. package/dist/core/storage/two-tier-storage.js.map +0 -7
  335. package/dist/core/trace/cli-trace-wrapper.js +0 -132
  336. package/dist/core/trace/cli-trace-wrapper.js.map +0 -7
  337. package/dist/core/trace/db-trace-wrapper.js +0 -247
  338. package/dist/core/trace/db-trace-wrapper.js.map +0 -7
  339. package/dist/core/trace/debug-trace.js +0 -417
  340. package/dist/core/trace/debug-trace.js.map +0 -7
  341. package/dist/core/trace/index.js +0 -109
  342. package/dist/core/trace/index.js.map +0 -7
  343. package/dist/core/trace/linear-api-wrapper.js +0 -178
  344. package/dist/core/trace/linear-api-wrapper.js.map +0 -7
  345. package/dist/core/trace/trace-demo.js +0 -154
  346. package/dist/core/trace/trace-demo.js.map +0 -7
  347. package/dist/core/trace/trace-detector.demo.js +0 -142
  348. package/dist/core/trace/trace-detector.demo.js.map +0 -7
  349. package/dist/core/trace/trace-detector.js +0 -528
  350. package/dist/core/trace/trace-detector.js.map +0 -7
  351. package/dist/core/trace/trace-store.js +0 -345
  352. package/dist/core/trace/trace-store.js.map +0 -7
  353. package/dist/core/trace/types.js +0 -77
  354. package/dist/core/trace/types.js.map +0 -7
  355. package/dist/core/types.js +0 -5
  356. package/dist/core/types.js.map +0 -7
  357. package/dist/core/utils/async-mutex.js +0 -114
  358. package/dist/core/utils/async-mutex.js.map +0 -7
  359. package/dist/core/utils/compression.js +0 -83
  360. package/dist/core/utils/compression.js.map +0 -7
  361. package/dist/core/utils/update-checker.js +0 -218
  362. package/dist/core/utils/update-checker.js.map +0 -7
  363. package/dist/core/worktree/worktree-manager.js +0 -465
  364. package/dist/core/worktree/worktree-manager.js.map +0 -7
  365. package/dist/daemon/daemon-config.js +0 -149
  366. package/dist/daemon/daemon-config.js.map +0 -7
  367. package/dist/daemon/services/context-service.js +0 -122
  368. package/dist/daemon/services/context-service.js.map +0 -7
  369. package/dist/daemon/services/linear-service.js +0 -136
  370. package/dist/daemon/services/linear-service.js.map +0 -7
  371. package/dist/daemon/session-daemon.js +0 -312
  372. package/dist/daemon/session-daemon.js.map +0 -7
  373. package/dist/daemon/unified-daemon.js +0 -276
  374. package/dist/daemon/unified-daemon.js.map +0 -7
  375. package/dist/features/analytics/api/analytics-api.js +0 -287
  376. package/dist/features/analytics/api/analytics-api.js.map +0 -7
  377. package/dist/features/analytics/core/analytics-service.js +0 -282
  378. package/dist/features/analytics/core/analytics-service.js.map +0 -7
  379. package/dist/features/analytics/index.js +0 -18
  380. package/dist/features/analytics/index.js.map +0 -7
  381. package/dist/features/analytics/queries/metrics-queries.js +0 -277
  382. package/dist/features/analytics/queries/metrics-queries.js.map +0 -7
  383. package/dist/features/analytics/types/metrics.js +0 -5
  384. package/dist/features/analytics/types/metrics.js.map +0 -7
  385. package/dist/features/browser/browser-mcp.js +0 -492
  386. package/dist/features/browser/browser-mcp.js.map +0 -7
  387. package/dist/features/sweep/index.js +0 -20
  388. package/dist/features/sweep/index.js.map +0 -7
  389. package/dist/features/sweep/prediction-client.js +0 -155
  390. package/dist/features/sweep/prediction-client.js.map +0 -7
  391. package/dist/features/sweep/prompt-builder.js +0 -85
  392. package/dist/features/sweep/prompt-builder.js.map +0 -7
  393. package/dist/features/sweep/pty-wrapper.js +0 -171
  394. package/dist/features/sweep/pty-wrapper.js.map +0 -7
  395. package/dist/features/sweep/state-watcher.js +0 -87
  396. package/dist/features/sweep/state-watcher.js.map +0 -7
  397. package/dist/features/sweep/status-bar.js +0 -88
  398. package/dist/features/sweep/status-bar.js.map +0 -7
  399. package/dist/features/sweep/sweep-server-manager.js +0 -226
  400. package/dist/features/sweep/sweep-server-manager.js.map +0 -7
  401. package/dist/features/sweep/tab-interceptor.js +0 -38
  402. package/dist/features/sweep/tab-interceptor.js.map +0 -7
  403. package/dist/features/sweep/types.js +0 -18
  404. package/dist/features/sweep/types.js.map +0 -7
  405. package/dist/features/tasks/linear-task-manager.js +0 -487
  406. package/dist/features/tasks/linear-task-manager.js.map +0 -7
  407. package/dist/features/tasks/task-aware-context.js +0 -410
  408. package/dist/features/tasks/task-aware-context.js.map +0 -7
  409. package/dist/features/tui/simple-monitor.js +0 -116
  410. package/dist/features/tui/simple-monitor.js.map +0 -7
  411. package/dist/features/tui/swarm-monitor.js +0 -648
  412. package/dist/features/tui/swarm-monitor.js.map +0 -7
  413. package/dist/features/web/client/stores/task-store.js +0 -26
  414. package/dist/features/web/client/stores/task-store.js.map +0 -7
  415. package/dist/features/web/server/index.js +0 -194
  416. package/dist/features/web/server/index.js.map +0 -7
  417. package/dist/hooks/auto-background.js +0 -151
  418. package/dist/hooks/auto-background.js.map +0 -7
  419. package/dist/hooks/claude-code-whatsapp-hook.js +0 -197
  420. package/dist/hooks/claude-code-whatsapp-hook.js.map +0 -7
  421. package/dist/hooks/config.js +0 -150
  422. package/dist/hooks/config.js.map +0 -7
  423. package/dist/hooks/daemon.js +0 -364
  424. package/dist/hooks/daemon.js.map +0 -7
  425. package/dist/hooks/events.js +0 -58
  426. package/dist/hooks/events.js.map +0 -7
  427. package/dist/hooks/index.js +0 -12
  428. package/dist/hooks/index.js.map +0 -7
  429. package/dist/hooks/linear-task-picker.js +0 -186
  430. package/dist/hooks/linear-task-picker.js.map +0 -7
  431. package/dist/hooks/schemas.js +0 -197
  432. package/dist/hooks/schemas.js.map +0 -7
  433. package/dist/hooks/secure-fs.js +0 -49
  434. package/dist/hooks/secure-fs.js.map +0 -7
  435. package/dist/hooks/security-logger.js +0 -155
  436. package/dist/hooks/security-logger.js.map +0 -7
  437. package/dist/hooks/session-summary.js +0 -222
  438. package/dist/hooks/session-summary.js.map +0 -7
  439. package/dist/hooks/sms-action-runner.js +0 -371
  440. package/dist/hooks/sms-action-runner.js.map +0 -7
  441. package/dist/hooks/sms-notify.js +0 -506
  442. package/dist/hooks/sms-notify.js.map +0 -7
  443. package/dist/hooks/sms-watcher.js +0 -93
  444. package/dist/hooks/sms-watcher.js.map +0 -7
  445. package/dist/hooks/sms-webhook.js +0 -555
  446. package/dist/hooks/sms-webhook.js.map +0 -7
  447. package/dist/hooks/whatsapp-commands.js +0 -479
  448. package/dist/hooks/whatsapp-commands.js.map +0 -7
  449. package/dist/hooks/whatsapp-scheduler.js +0 -317
  450. package/dist/hooks/whatsapp-scheduler.js.map +0 -7
  451. package/dist/hooks/whatsapp-sync.js +0 -409
  452. package/dist/hooks/whatsapp-sync.js.map +0 -7
  453. package/dist/index.js +0 -25
  454. package/dist/index.js.map +0 -7
  455. package/dist/integrations/anthropic/client.js +0 -263
  456. package/dist/integrations/anthropic/client.js.map +0 -7
  457. package/dist/integrations/claude-code/agent-bridge.js +0 -768
  458. package/dist/integrations/claude-code/agent-bridge.js.map +0 -7
  459. package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js +0 -459
  460. package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js.map +0 -7
  461. package/dist/integrations/claude-code/lifecycle-hooks.js +0 -254
  462. package/dist/integrations/claude-code/lifecycle-hooks.js.map +0 -7
  463. package/dist/integrations/claude-code/post-task-hooks.js +0 -545
  464. package/dist/integrations/claude-code/post-task-hooks.js.map +0 -7
  465. package/dist/integrations/claude-code/subagent-client-stub.js +0 -20
  466. package/dist/integrations/claude-code/subagent-client-stub.js.map +0 -7
  467. package/dist/integrations/claude-code/subagent-client.js +0 -511
  468. package/dist/integrations/claude-code/subagent-client.js.map +0 -7
  469. package/dist/integrations/claude-code/task-coordinator.js +0 -360
  470. package/dist/integrations/claude-code/task-coordinator.js.map +0 -7
  471. package/dist/integrations/linear/auth.js +0 -337
  472. package/dist/integrations/linear/auth.js.map +0 -7
  473. package/dist/integrations/linear/auto-sync.js +0 -258
  474. package/dist/integrations/linear/auto-sync.js.map +0 -7
  475. package/dist/integrations/linear/client.js +0 -634
  476. package/dist/integrations/linear/client.js.map +0 -7
  477. package/dist/integrations/linear/config.js +0 -130
  478. package/dist/integrations/linear/config.js.map +0 -7
  479. package/dist/integrations/linear/migration.js +0 -361
  480. package/dist/integrations/linear/migration.js.map +0 -7
  481. package/dist/integrations/linear/oauth-server.js +0 -454
  482. package/dist/integrations/linear/oauth-server.js.map +0 -7
  483. package/dist/integrations/linear/rest-client.js +0 -213
  484. package/dist/integrations/linear/rest-client.js.map +0 -7
  485. package/dist/integrations/linear/sync-manager.js +0 -236
  486. package/dist/integrations/linear/sync-manager.js.map +0 -7
  487. package/dist/integrations/linear/sync-service.js +0 -231
  488. package/dist/integrations/linear/sync-service.js.map +0 -7
  489. package/dist/integrations/linear/sync.js +0 -782
  490. package/dist/integrations/linear/sync.js.map +0 -7
  491. package/dist/integrations/linear/types.js +0 -5
  492. package/dist/integrations/linear/types.js.map +0 -7
  493. package/dist/integrations/linear/unified-sync.js +0 -589
  494. package/dist/integrations/linear/unified-sync.js.map +0 -7
  495. package/dist/integrations/linear/webhook-handler.js +0 -219
  496. package/dist/integrations/linear/webhook-handler.js.map +0 -7
  497. package/dist/integrations/linear/webhook-server.js +0 -218
  498. package/dist/integrations/linear/webhook-server.js.map +0 -7
  499. package/dist/integrations/linear/webhook.js +0 -291
  500. package/dist/integrations/linear/webhook.js.map +0 -7
  501. package/dist/integrations/mcp/handlers/code-execution-handlers.js +0 -266
  502. package/dist/integrations/mcp/handlers/code-execution-handlers.js.map +0 -7
  503. package/dist/integrations/mcp/handlers/context-handlers.js +0 -257
  504. package/dist/integrations/mcp/handlers/context-handlers.js.map +0 -7
  505. package/dist/integrations/mcp/handlers/discovery-handlers.js +0 -497
  506. package/dist/integrations/mcp/handlers/discovery-handlers.js.map +0 -7
  507. package/dist/integrations/mcp/handlers/index.js +0 -166
  508. package/dist/integrations/mcp/handlers/index.js.map +0 -7
  509. package/dist/integrations/mcp/handlers/linear-handlers.js +0 -247
  510. package/dist/integrations/mcp/handlers/linear-handlers.js.map +0 -7
  511. package/dist/integrations/mcp/handlers/skill-handlers.js +0 -529
  512. package/dist/integrations/mcp/handlers/skill-handlers.js.map +0 -7
  513. package/dist/integrations/mcp/handlers/task-handlers.js +0 -239
  514. package/dist/integrations/mcp/handlers/task-handlers.js.map +0 -7
  515. package/dist/integrations/mcp/handlers/trace-handlers.js +0 -308
  516. package/dist/integrations/mcp/handlers/trace-handlers.js.map +0 -7
  517. package/dist/integrations/mcp/index.js +0 -23
  518. package/dist/integrations/mcp/index.js.map +0 -7
  519. package/dist/integrations/mcp/middleware/tool-scoring.js +0 -356
  520. package/dist/integrations/mcp/middleware/tool-scoring.js.map +0 -7
  521. package/dist/integrations/mcp/refactored-server.js +0 -374
  522. package/dist/integrations/mcp/refactored-server.js.map +0 -7
  523. package/dist/integrations/mcp/remote-server.js +0 -682
  524. package/dist/integrations/mcp/remote-server.js.map +0 -7
  525. package/dist/integrations/mcp/schemas.js +0 -147
  526. package/dist/integrations/mcp/schemas.js.map +0 -7
  527. package/dist/integrations/mcp/server.js +0 -1975
  528. package/dist/integrations/mcp/server.js.map +0 -7
  529. package/dist/integrations/mcp/tool-definitions-code.js +0 -125
  530. package/dist/integrations/mcp/tool-definitions-code.js.map +0 -7
  531. package/dist/integrations/mcp/tool-definitions.js +0 -702
  532. package/dist/integrations/mcp/tool-definitions.js.map +0 -7
  533. package/dist/integrations/mcp/trace-test.js +0 -48
  534. package/dist/integrations/mcp/trace-test.js.map +0 -7
  535. package/dist/integrations/pg-aiguide/embedding-provider.js +0 -189
  536. package/dist/integrations/pg-aiguide/embedding-provider.js.map +0 -7
  537. package/dist/integrations/pg-aiguide/semantic-search.js +0 -187
  538. package/dist/integrations/pg-aiguide/semantic-search.js.map +0 -7
  539. package/dist/integrations/pg-aiguide/timescale-analytics.js +0 -224
  540. package/dist/integrations/pg-aiguide/timescale-analytics.js.map +0 -7
  541. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -860
  542. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +0 -7
  543. package/dist/integrations/ralph/context/context-budget-manager.js +0 -301
  544. package/dist/integrations/ralph/context/context-budget-manager.js.map +0 -7
  545. package/dist/integrations/ralph/context/stackmemory-context-loader.js +0 -360
  546. package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +0 -7
  547. package/dist/integrations/ralph/coordination/enhanced-coordination.js +0 -410
  548. package/dist/integrations/ralph/coordination/enhanced-coordination.js.map +0 -7
  549. package/dist/integrations/ralph/index.js +0 -18
  550. package/dist/integrations/ralph/index.js.map +0 -7
  551. package/dist/integrations/ralph/learning/pattern-learner.js +0 -401
  552. package/dist/integrations/ralph/learning/pattern-learner.js.map +0 -7
  553. package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
  554. package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +0 -7
  555. package/dist/integrations/ralph/monitoring/swarm-dashboard.js +0 -294
  556. package/dist/integrations/ralph/monitoring/swarm-dashboard.js.map +0 -7
  557. package/dist/integrations/ralph/monitoring/swarm-registry.js +0 -108
  558. package/dist/integrations/ralph/monitoring/swarm-registry.js.map +0 -7
  559. package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -463
  560. package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +0 -7
  561. package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -400
  562. package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js.map +0 -7
  563. package/dist/integrations/ralph/patterns/extended-coherence-sessions.js +0 -473
  564. package/dist/integrations/ralph/patterns/extended-coherence-sessions.js.map +0 -7
  565. package/dist/integrations/ralph/patterns/oracle-worker-pattern.js +0 -388
  566. package/dist/integrations/ralph/patterns/oracle-worker-pattern.js.map +0 -7
  567. package/dist/integrations/ralph/performance/performance-optimizer.js +0 -358
  568. package/dist/integrations/ralph/performance/performance-optimizer.js.map +0 -7
  569. package/dist/integrations/ralph/ralph-integration-demo.js +0 -182
  570. package/dist/integrations/ralph/ralph-integration-demo.js.map +0 -7
  571. package/dist/integrations/ralph/recovery/crash-recovery.js +0 -462
  572. package/dist/integrations/ralph/recovery/crash-recovery.js.map +0 -7
  573. package/dist/integrations/ralph/state/state-reconciler.js +0 -404
  574. package/dist/integrations/ralph/state/state-reconciler.js.map +0 -7
  575. package/dist/integrations/ralph/swarm/git-workflow-manager.js +0 -428
  576. package/dist/integrations/ralph/swarm/git-workflow-manager.js.map +0 -7
  577. package/dist/integrations/ralph/swarm/swarm-coordinator.js +0 -996
  578. package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +0 -7
  579. package/dist/integrations/ralph/types.js +0 -5
  580. package/dist/integrations/ralph/types.js.map +0 -7
  581. package/dist/integrations/ralph/visualization/ralph-debugger.js +0 -585
  582. package/dist/integrations/ralph/visualization/ralph-debugger.js.map +0 -7
  583. package/dist/mcp/stackmemory-mcp-server.js +0 -554
  584. package/dist/mcp/stackmemory-mcp-server.js.map +0 -7
  585. package/dist/middleware/exponential-rate-limiter.js +0 -289
  586. package/dist/middleware/exponential-rate-limiter.js.map +0 -7
  587. package/dist/models/user.model.js +0 -358
  588. package/dist/models/user.model.js.map +0 -7
  589. package/dist/servers/production/auth-middleware.js +0 -528
  590. package/dist/servers/production/auth-middleware.js.map +0 -7
  591. package/dist/servers/railway/config.js +0 -55
  592. package/dist/servers/railway/config.js.map +0 -7
  593. package/dist/servers/railway/index-enhanced.js +0 -160
  594. package/dist/servers/railway/index-enhanced.js.map +0 -7
  595. package/dist/servers/railway/index.js +0 -1349
  596. package/dist/servers/railway/index.js.map +0 -7
  597. package/dist/servers/railway/simple.js +0 -64
  598. package/dist/servers/railway/simple.js.map +0 -7
  599. package/dist/servers/railway/storage-test.js +0 -459
  600. package/dist/servers/railway/storage-test.js.map +0 -7
  601. package/dist/services/config-service.js +0 -65
  602. package/dist/services/config-service.js.map +0 -7
  603. package/dist/services/context-service.js +0 -194
  604. package/dist/services/context-service.js.map +0 -7
  605. package/dist/skills/api-discovery.js +0 -354
  606. package/dist/skills/api-discovery.js.map +0 -7
  607. package/dist/skills/api-skill.js +0 -475
  608. package/dist/skills/api-skill.js.map +0 -7
  609. package/dist/skills/claude-skills.js +0 -1061
  610. package/dist/skills/claude-skills.js.map +0 -7
  611. package/dist/skills/dashboard-launcher.js +0 -216
  612. package/dist/skills/dashboard-launcher.js.map +0 -7
  613. package/dist/skills/recursive-agent-orchestrator.js +0 -575
  614. package/dist/skills/recursive-agent-orchestrator.js.map +0 -7
  615. package/dist/skills/repo-ingestion-skill.js +0 -609
  616. package/dist/skills/repo-ingestion-skill.js.map +0 -7
  617. package/dist/skills/security-secrets-scanner.js +0 -284
  618. package/dist/skills/security-secrets-scanner.js.map +0 -7
  619. package/dist/skills/unified-rlm-orchestrator.js +0 -404
  620. package/dist/skills/unified-rlm-orchestrator.js.map +0 -7
  621. package/dist/types/task.js +0 -5
  622. package/dist/types/task.js.map +0 -7
  623. package/dist/utils/env.js +0 -50
  624. package/dist/utils/env.js.map +0 -7
  625. package/dist/utils/formatting.js +0 -62
  626. package/dist/utils/formatting.js.map +0 -7
  627. package/dist/utils/process-cleanup.js +0 -136
  628. package/dist/utils/process-cleanup.js.map +0 -7
  629. package/dist/validation/schemas.js +0 -222
  630. package/dist/validation/schemas.js.map +0 -7
  631. /package/dist/{core/merge → src/core/extensions}/types.js +0 -0
  632. /package/dist/{core/merge → src/core/extensions}/types.js.map +0 -0
@@ -1,764 +0,0 @@
1
- import { fileURLToPath as __fileURLToPath } from 'url';
2
- import { dirname as __pathDirname } from 'path';
3
- const __filename = __fileURLToPath(import.meta.url);
4
- const __dirname = __pathDirname(__filename);
5
- import "dotenv/config";
6
- import Redis from "ioredis";
7
- import { v4 as uuidv4 } from "uuid";
8
- import { logger } from "../monitoring/logger.js";
9
- function getEnv(key, defaultValue) {
10
- const value = process.env[key];
11
- if (value === void 0) {
12
- if (defaultValue !== void 0) return defaultValue;
13
- throw new Error(`Environment variable ${key} is required`);
14
- }
15
- return value;
16
- }
17
- function getOptionalEnv(key) {
18
- return process.env[key];
19
- }
20
- import {
21
- REDIS_KEYS,
22
- CACHE_TTL,
23
- calculateSkillTTL,
24
- SkillSchema,
25
- JournalEntrySchema
26
- } from "./types.js";
27
- class SkillStorageService {
28
- redis;
29
- userId;
30
- keyPrefix;
31
- enableMetrics;
32
- // Metrics tracking
33
- metrics = {
34
- cacheHits: 0,
35
- cacheMisses: 0
36
- };
37
- constructor(config) {
38
- this.redis = new Redis(config.redisUrl);
39
- this.userId = config.userId;
40
- this.keyPrefix = config.keyPrefix || "sm:skills";
41
- this.enableMetrics = config.enableMetrics ?? true;
42
- this.redis.on("error", (err) => {
43
- logger.error("Redis connection error in SkillStorage", err);
44
- });
45
- this.redis.on("connect", () => {
46
- logger.info("SkillStorage connected to Redis");
47
- });
48
- logger.info("SkillStorageService initialized", {
49
- userId: this.userId,
50
- keyPrefix: this.keyPrefix,
51
- enableMetrics: this.enableMetrics
52
- });
53
- }
54
- key(pattern) {
55
- return `${this.keyPrefix}:${pattern}`;
56
- }
57
- /**
58
- * Get the current user ID
59
- */
60
- getUserId() {
61
- return this.userId;
62
- }
63
- // ============================================================
64
- // SKILL CRUD OPERATIONS
65
- // ============================================================
66
- /**
67
- * Create a new skill
68
- */
69
- async createSkill(input) {
70
- const now = (/* @__PURE__ */ new Date()).toISOString();
71
- const skill = {
72
- ...input,
73
- id: uuidv4(),
74
- createdAt: now,
75
- updatedAt: now,
76
- validatedCount: 0
77
- };
78
- SkillSchema.parse(skill);
79
- const pipeline = this.redis.pipeline();
80
- const skillKey = this.key(REDIS_KEYS.skill(this.userId, skill.id));
81
- pipeline.setex(
82
- skillKey,
83
- calculateSkillTTL(skill.validatedCount),
84
- JSON.stringify(skill)
85
- );
86
- if (skill.tool) {
87
- pipeline.zadd(
88
- this.key(REDIS_KEYS.skillsByTool(this.userId, skill.tool)),
89
- Date.now(),
90
- skill.id
91
- );
92
- }
93
- pipeline.zadd(
94
- this.key(REDIS_KEYS.skillsByCategory(this.userId, skill.category)),
95
- this.priorityScore(skill.priority),
96
- skill.id
97
- );
98
- for (const tag of skill.tags) {
99
- pipeline.zadd(
100
- this.key(REDIS_KEYS.skillsByTag(this.userId, tag)),
101
- Date.now(),
102
- skill.id
103
- );
104
- }
105
- pipeline.zadd(
106
- this.key(REDIS_KEYS.skillsRecent(this.userId)),
107
- Date.now(),
108
- skill.id
109
- );
110
- pipeline.zremrangebyrank(
111
- this.key(REDIS_KEYS.skillsRecent(this.userId)),
112
- 0,
113
- -1001
114
- );
115
- await pipeline.exec();
116
- logger.info("Created skill", {
117
- userId: this.userId,
118
- id: skill.id,
119
- category: skill.category,
120
- tool: skill.tool
121
- });
122
- return skill;
123
- }
124
- /**
125
- * Get skill by ID
126
- */
127
- async getSkill(id) {
128
- const skillKey = this.key(REDIS_KEYS.skill(this.userId, id));
129
- const data = await this.redis.get(skillKey);
130
- if (!data) {
131
- this.metrics.cacheMisses++;
132
- return null;
133
- }
134
- this.metrics.cacheHits++;
135
- return JSON.parse(data);
136
- }
137
- /**
138
- * Update an existing skill
139
- */
140
- async updateSkill(input) {
141
- const existing = await this.getSkill(input.id);
142
- if (!existing) {
143
- return null;
144
- }
145
- const updated = {
146
- ...existing,
147
- ...input,
148
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
149
- };
150
- SkillSchema.parse(updated);
151
- const skillKey = this.key(REDIS_KEYS.skill(this.userId, updated.id));
152
- await this.redis.setex(
153
- skillKey,
154
- calculateSkillTTL(updated.validatedCount),
155
- JSON.stringify(updated)
156
- );
157
- logger.info("Updated skill", { userId: this.userId, id: updated.id });
158
- return updated;
159
- }
160
- /**
161
- * Validate a skill (increment validation count)
162
- */
163
- async validateSkill(id) {
164
- const skill = await this.getSkill(id);
165
- if (!skill) {
166
- return null;
167
- }
168
- skill.validatedCount++;
169
- skill.lastValidated = (/* @__PURE__ */ new Date()).toISOString();
170
- skill.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
171
- const skillKey = this.key(REDIS_KEYS.skill(this.userId, id));
172
- await this.redis.setex(
173
- skillKey,
174
- calculateSkillTTL(skill.validatedCount),
175
- JSON.stringify(skill)
176
- );
177
- await this.redis.zadd(
178
- this.key(REDIS_KEYS.skillsValidated(this.userId)),
179
- skill.validatedCount,
180
- id
181
- );
182
- if (skill.validatedCount >= 3 && skill.priority !== "critical") {
183
- await this.redis.sadd(
184
- this.key(REDIS_KEYS.promotionCandidates(this.userId)),
185
- id
186
- );
187
- }
188
- logger.info("Validated skill", {
189
- userId: this.userId,
190
- id,
191
- validatedCount: skill.validatedCount
192
- });
193
- return skill;
194
- }
195
- /**
196
- * Delete a skill
197
- */
198
- async deleteSkill(id) {
199
- const skill = await this.getSkill(id);
200
- if (!skill) {
201
- return false;
202
- }
203
- const pipeline = this.redis.pipeline();
204
- const skillKey = this.key(REDIS_KEYS.skill(this.userId, id));
205
- pipeline.del(skillKey);
206
- if (skill.tool) {
207
- pipeline.zrem(
208
- this.key(REDIS_KEYS.skillsByTool(this.userId, skill.tool)),
209
- id
210
- );
211
- }
212
- pipeline.zrem(
213
- this.key(REDIS_KEYS.skillsByCategory(this.userId, skill.category)),
214
- id
215
- );
216
- for (const tag of skill.tags) {
217
- pipeline.zrem(this.key(REDIS_KEYS.skillsByTag(this.userId, tag)), id);
218
- }
219
- pipeline.zrem(this.key(REDIS_KEYS.skillsRecent(this.userId)), id);
220
- pipeline.zrem(this.key(REDIS_KEYS.skillsValidated(this.userId)), id);
221
- pipeline.srem(this.key(REDIS_KEYS.promotionCandidates(this.userId)), id);
222
- await pipeline.exec();
223
- logger.info("Deleted skill", { userId: this.userId, id });
224
- return true;
225
- }
226
- // ============================================================
227
- // SKILL QUERIES
228
- // ============================================================
229
- /**
230
- * Query skills with filters
231
- */
232
- async querySkills(query) {
233
- let skillIds = [];
234
- if (query.tool) {
235
- skillIds = await this.redis.zrevrange(
236
- this.key(REDIS_KEYS.skillsByTool(this.userId, query.tool)),
237
- 0,
238
- -1
239
- );
240
- } else if (query.categories && query.categories.length === 1) {
241
- skillIds = await this.redis.zrevrange(
242
- this.key(REDIS_KEYS.skillsByCategory(this.userId, query.categories[0])),
243
- 0,
244
- -1
245
- );
246
- } else if (query.tags && query.tags.length === 1) {
247
- skillIds = await this.redis.zrevrange(
248
- this.key(REDIS_KEYS.skillsByTag(this.userId, query.tags[0])),
249
- 0,
250
- -1
251
- );
252
- } else {
253
- skillIds = await this.redis.zrevrange(
254
- this.key(REDIS_KEYS.skillsRecent(this.userId)),
255
- 0,
256
- query.limit + query.offset
257
- );
258
- }
259
- if (skillIds.length === 0) {
260
- return [];
261
- }
262
- const pipeline = this.redis.pipeline();
263
- for (const id of skillIds) {
264
- pipeline.get(this.key(REDIS_KEYS.skill(this.userId, id)));
265
- }
266
- const results = await pipeline.exec();
267
- if (!results) {
268
- return [];
269
- }
270
- let skills = results.map(([err, data]) => {
271
- if (err || !data) return null;
272
- try {
273
- return JSON.parse(data);
274
- } catch {
275
- return null;
276
- }
277
- }).filter((s) => s !== null);
278
- if (query.categories && query.categories.length > 0) {
279
- skills = skills.filter((s) => query.categories.includes(s.category));
280
- }
281
- if (query.priorities && query.priorities.length > 0) {
282
- skills = skills.filter((s) => query.priorities.includes(s.priority));
283
- }
284
- if (query.minValidatedCount !== void 0) {
285
- skills = skills.filter(
286
- (s) => s.validatedCount >= query.minValidatedCount
287
- );
288
- }
289
- if (query.language) {
290
- skills = skills.filter((s) => s.language === query.language);
291
- }
292
- if (query.framework) {
293
- skills = skills.filter((s) => s.framework === query.framework);
294
- }
295
- skills.sort((a, b) => {
296
- let aVal, bVal;
297
- switch (query.sortBy) {
298
- case "priority":
299
- aVal = this.priorityScore(a.priority);
300
- bVal = this.priorityScore(b.priority);
301
- break;
302
- case "validatedCount":
303
- aVal = a.validatedCount;
304
- bVal = b.validatedCount;
305
- break;
306
- case "createdAt":
307
- aVal = new Date(a.createdAt).getTime();
308
- bVal = new Date(b.createdAt).getTime();
309
- break;
310
- case "updatedAt":
311
- aVal = new Date(a.updatedAt).getTime();
312
- bVal = new Date(b.updatedAt).getTime();
313
- break;
314
- default:
315
- aVal = this.priorityScore(a.priority);
316
- bVal = this.priorityScore(b.priority);
317
- }
318
- return query.sortOrder === "desc" ? bVal - aVal : aVal - bVal;
319
- });
320
- return skills.slice(query.offset, query.offset + query.limit);
321
- }
322
- /**
323
- * Get skills relevant to current context
324
- */
325
- async getRelevantSkills(context) {
326
- const skills = [];
327
- const seenIds = /* @__PURE__ */ new Set();
328
- const criticalIds = await this.redis.zrevrange(
329
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "correction")),
330
- 0,
331
- -1
332
- );
333
- for (const id of criticalIds) {
334
- const skill = await this.getSkill(id);
335
- if (skill && skill.priority === "critical" && !seenIds.has(id)) {
336
- skills.push(skill);
337
- seenIds.add(id);
338
- }
339
- }
340
- if (context.tool) {
341
- const toolSkills = await this.querySkills({
342
- tool: context.tool,
343
- limit: 20,
344
- offset: 0,
345
- sortBy: "priority",
346
- sortOrder: "desc"
347
- });
348
- for (const skill of toolSkills) {
349
- if (!seenIds.has(skill.id)) {
350
- skills.push(skill);
351
- seenIds.add(skill.id);
352
- }
353
- }
354
- }
355
- const validatedIds = await this.redis.zrevrange(
356
- this.key(REDIS_KEYS.skillsValidated(this.userId)),
357
- 0,
358
- 10
359
- );
360
- for (const id of validatedIds) {
361
- if (!seenIds.has(id)) {
362
- const skill = await this.getSkill(id);
363
- if (skill) {
364
- skills.push(skill);
365
- seenIds.add(id);
366
- }
367
- }
368
- }
369
- return skills.slice(0, 50);
370
- }
371
- // ============================================================
372
- // SESSION JOURNAL
373
- // ============================================================
374
- /**
375
- * Create a journal entry
376
- */
377
- async createJournalEntry(sessionId, type, title, content, context) {
378
- const entry = {
379
- id: uuidv4(),
380
- sessionId,
381
- type,
382
- title,
383
- content,
384
- context,
385
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
386
- };
387
- JournalEntrySchema.parse(entry);
388
- const pipeline = this.redis.pipeline();
389
- pipeline.setex(
390
- this.key(REDIS_KEYS.journalEntry(this.userId, entry.id)),
391
- CACHE_TTL.journal,
392
- JSON.stringify(entry)
393
- );
394
- pipeline.zadd(
395
- this.key(REDIS_KEYS.journalSession(this.userId, sessionId)),
396
- Date.now(),
397
- entry.id
398
- );
399
- pipeline.zadd(
400
- this.key(REDIS_KEYS.journalRecent(this.userId)),
401
- Date.now(),
402
- entry.id
403
- );
404
- pipeline.zremrangebyrank(
405
- this.key(REDIS_KEYS.journalRecent(this.userId)),
406
- 0,
407
- -501
408
- );
409
- await pipeline.exec();
410
- logger.info("Created journal entry", {
411
- userId: this.userId,
412
- id: entry.id,
413
- sessionId,
414
- type,
415
- title
416
- });
417
- return entry;
418
- }
419
- /**
420
- * Get journal entries for a session
421
- */
422
- async getSessionJournal(sessionId) {
423
- const entryIds = await this.redis.zrevrange(
424
- this.key(REDIS_KEYS.journalSession(this.userId, sessionId)),
425
- 0,
426
- -1
427
- );
428
- if (entryIds.length === 0) {
429
- return [];
430
- }
431
- const pipeline = this.redis.pipeline();
432
- for (const id of entryIds) {
433
- pipeline.get(this.key(REDIS_KEYS.journalEntry(this.userId, id)));
434
- }
435
- const results = await pipeline.exec();
436
- if (!results) {
437
- return [];
438
- }
439
- return results.map(([err, data]) => {
440
- if (err || !data) return null;
441
- try {
442
- return JSON.parse(data);
443
- } catch {
444
- return null;
445
- }
446
- }).filter((e) => e !== null);
447
- }
448
- /**
449
- * Promote a journal entry to a skill
450
- */
451
- async promoteToSkill(entryId, category, priority = "medium") {
452
- const entryData = await this.redis.get(
453
- this.key(REDIS_KEYS.journalEntry(this.userId, entryId))
454
- );
455
- if (!entryData) {
456
- return null;
457
- }
458
- const entry = JSON.parse(entryData);
459
- const skill = await this.createSkill({
460
- content: entry.content,
461
- summary: entry.title,
462
- category,
463
- priority,
464
- tags: [],
465
- tool: entry.context?.tool,
466
- source: "observation",
467
- sessionId: entry.sessionId
468
- });
469
- entry.promotedToSkillId = skill.id;
470
- await this.redis.setex(
471
- this.key(REDIS_KEYS.journalEntry(this.userId, entryId)),
472
- CACHE_TTL.journal,
473
- JSON.stringify(entry)
474
- );
475
- logger.info("Promoted journal entry to skill", {
476
- userId: this.userId,
477
- entryId,
478
- skillId: skill.id
479
- });
480
- return skill;
481
- }
482
- // ============================================================
483
- // SESSION MANAGEMENT
484
- // ============================================================
485
- /**
486
- * Start tracking a new session
487
- */
488
- async startSession(sessionId) {
489
- const summary = {
490
- sessionId,
491
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
492
- entriesCount: 0,
493
- correctionsCount: 0,
494
- decisionsCount: 0,
495
- keyLearnings: [],
496
- promotedSkillIds: []
497
- };
498
- await this.redis.setex(
499
- this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId)),
500
- CACHE_TTL.session,
501
- JSON.stringify(summary)
502
- );
503
- await this.redis.sadd(
504
- this.key(REDIS_KEYS.sessionsActive(this.userId)),
505
- sessionId
506
- );
507
- logger.info("Started session tracking", { userId: this.userId, sessionId });
508
- }
509
- /**
510
- * End a session and generate summary
511
- */
512
- async endSession(sessionId) {
513
- const summaryData = await this.redis.get(
514
- this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId))
515
- );
516
- if (!summaryData) {
517
- return null;
518
- }
519
- const summary = JSON.parse(summaryData);
520
- summary.endedAt = (/* @__PURE__ */ new Date()).toISOString();
521
- const entries = await this.getSessionJournal(sessionId);
522
- summary.entriesCount = entries.length;
523
- summary.correctionsCount = entries.filter(
524
- (e) => e.type === "correction"
525
- ).length;
526
- summary.decisionsCount = entries.filter(
527
- (e) => e.type === "decision"
528
- ).length;
529
- summary.keyLearnings = entries.filter((e) => e.type === "correction" || e.type === "resolution").slice(0, 5).map((e) => e.title);
530
- summary.promotedSkillIds = entries.filter((e) => e.promotedToSkillId).map((e) => e.promotedToSkillId);
531
- await this.redis.setex(
532
- this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId)),
533
- CACHE_TTL.session,
534
- JSON.stringify(summary)
535
- );
536
- await this.redis.srem(
537
- this.key(REDIS_KEYS.sessionsActive(this.userId)),
538
- sessionId
539
- );
540
- logger.info("Ended session", {
541
- userId: this.userId,
542
- sessionId,
543
- entriesCount: summary.entriesCount,
544
- keyLearnings: summary.keyLearnings.length
545
- });
546
- return summary;
547
- }
548
- /**
549
- * Get session summary
550
- */
551
- async getSessionSummary(sessionId) {
552
- const data = await this.redis.get(
553
- this.key(REDIS_KEYS.sessionSummary(this.userId, sessionId))
554
- );
555
- if (!data) {
556
- return null;
557
- }
558
- return JSON.parse(data);
559
- }
560
- // ============================================================
561
- // KNOWLEDGE HYGIENE
562
- // ============================================================
563
- /**
564
- * Get skills eligible for promotion
565
- */
566
- async getPromotionCandidates() {
567
- const ids = await this.redis.smembers(
568
- this.key(REDIS_KEYS.promotionCandidates(this.userId))
569
- );
570
- const skills = [];
571
- for (const id of ids) {
572
- const skill = await this.getSkill(id);
573
- if (skill && skill.validatedCount >= 3) {
574
- skills.push(skill);
575
- }
576
- }
577
- return skills;
578
- }
579
- /**
580
- * Promote a skill (increase priority)
581
- */
582
- async promoteSkill(id) {
583
- const skill = await this.getSkill(id);
584
- if (!skill) {
585
- return null;
586
- }
587
- const priorityOrder = [
588
- "low",
589
- "medium",
590
- "high",
591
- "critical"
592
- ];
593
- const currentIndex = priorityOrder.indexOf(skill.priority);
594
- if (currentIndex < priorityOrder.length - 1) {
595
- skill.priority = priorityOrder[currentIndex + 1];
596
- skill.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
597
- await this.redis.setex(
598
- this.key(REDIS_KEYS.skill(this.userId, id)),
599
- calculateSkillTTL(skill.validatedCount),
600
- JSON.stringify(skill)
601
- );
602
- await this.redis.zadd(
603
- this.key(REDIS_KEYS.skillsByCategory(this.userId, skill.category)),
604
- this.priorityScore(skill.priority),
605
- id
606
- );
607
- if (skill.priority === "critical") {
608
- await this.redis.srem(
609
- this.key(REDIS_KEYS.promotionCandidates(this.userId)),
610
- id
611
- );
612
- }
613
- logger.info("Promoted skill", {
614
- userId: this.userId,
615
- id,
616
- newPriority: skill.priority
617
- });
618
- }
619
- return skill;
620
- }
621
- /**
622
- * Archive stale skills (not validated in 90 days)
623
- */
624
- async archiveStaleSkills(daysThreshold = 90) {
625
- const cutoff = Date.now() - daysThreshold * 24 * 60 * 60 * 1e3;
626
- let archivedCount = 0;
627
- const skillIds = await this.redis.zrangebyscore(
628
- this.key(REDIS_KEYS.skillsRecent(this.userId)),
629
- 0,
630
- cutoff
631
- );
632
- for (const id of skillIds) {
633
- const skill = await this.getSkill(id);
634
- if (skill && skill.priority !== "critical") {
635
- if (!skill.lastValidated || new Date(skill.lastValidated).getTime() < cutoff) {
636
- if (skill.priority !== "low") {
637
- skill.priority = "low";
638
- skill.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
639
- await this.redis.setex(
640
- this.key(REDIS_KEYS.skill(this.userId, id)),
641
- calculateSkillTTL(skill.validatedCount),
642
- JSON.stringify(skill)
643
- );
644
- archivedCount++;
645
- }
646
- }
647
- }
648
- }
649
- logger.info("Archived stale skills", {
650
- userId: this.userId,
651
- archivedCount,
652
- daysThreshold
653
- });
654
- return archivedCount;
655
- }
656
- // ============================================================
657
- // METRICS & UTILITIES
658
- // ============================================================
659
- /**
660
- * Get storage metrics
661
- */
662
- async getMetrics() {
663
- const [
664
- skillsTotal,
665
- toolSkills,
666
- workflowSkills,
667
- correctionSkills,
668
- patternSkills,
669
- preferenceSkills,
670
- pitfallSkills,
671
- optimizationSkills,
672
- journalTotal,
673
- sessionsActive
674
- ] = await Promise.all([
675
- this.redis.zcard(this.key(REDIS_KEYS.skillsRecent(this.userId))),
676
- this.redis.zcard(
677
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "tool"))
678
- ),
679
- this.redis.zcard(
680
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "workflow"))
681
- ),
682
- this.redis.zcard(
683
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "correction"))
684
- ),
685
- this.redis.zcard(
686
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "pattern"))
687
- ),
688
- this.redis.zcard(
689
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "preference"))
690
- ),
691
- this.redis.zcard(
692
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "pitfall"))
693
- ),
694
- this.redis.zcard(
695
- this.key(REDIS_KEYS.skillsByCategory(this.userId, "optimization"))
696
- ),
697
- this.redis.zcard(this.key(REDIS_KEYS.journalRecent(this.userId))),
698
- this.redis.scard(this.key(REDIS_KEYS.sessionsActive(this.userId)))
699
- ]);
700
- return {
701
- userId: this.userId,
702
- skillsTotal,
703
- skillsByCategory: {
704
- tool: toolSkills,
705
- workflow: workflowSkills,
706
- correction: correctionSkills,
707
- pattern: patternSkills,
708
- preference: preferenceSkills,
709
- pitfall: pitfallSkills,
710
- optimization: optimizationSkills
711
- },
712
- journalEntriesTotal: journalTotal,
713
- sessionsTracked: sessionsActive,
714
- cacheHits: this.metrics.cacheHits,
715
- cacheMisses: this.metrics.cacheMisses
716
- };
717
- }
718
- /**
719
- * Priority to numeric score for sorting
720
- */
721
- priorityScore(priority) {
722
- const scores = {
723
- critical: 1e3,
724
- high: 100,
725
- medium: 10,
726
- low: 1
727
- };
728
- return scores[priority];
729
- }
730
- /**
731
- * Close Redis connection
732
- */
733
- async close() {
734
- await this.redis.quit();
735
- logger.info("SkillStorageService closed");
736
- }
737
- }
738
- const userStorageInstances = /* @__PURE__ */ new Map();
739
- function getSkillStorage(config) {
740
- const existing = userStorageInstances.get(config.userId);
741
- if (existing) {
742
- return existing;
743
- }
744
- const instance = new SkillStorageService(config);
745
- userStorageInstances.set(config.userId, instance);
746
- return instance;
747
- }
748
- function initializeSkillStorage(userId, redisUrl) {
749
- const url = redisUrl || process.env["REDIS_URL"];
750
- if (!url) {
751
- throw new Error("REDIS_URL environment variable not set");
752
- }
753
- return getSkillStorage({ redisUrl: url, userId });
754
- }
755
- function getDefaultUserId() {
756
- return process.env["STACKMEMORY_USER_ID"] || process.env["USER"] || process.env["USERNAME"] || "default";
757
- }
758
- export {
759
- SkillStorageService,
760
- getDefaultUserId,
761
- getSkillStorage,
762
- initializeSkillStorage
763
- };
764
- //# sourceMappingURL=skill-storage.js.map