@stackmemoryai/stackmemory 0.5.58 → 0.5.59

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 (596) hide show
  1. package/dist/cli/commands/search.js +20 -3
  2. package/dist/cli/commands/search.js.map +2 -2
  3. package/dist/core/database/sqlite-adapter.js +13 -3
  4. package/dist/core/database/sqlite-adapter.js.map +2 -2
  5. package/dist/core/errors/error-utils.js +208 -0
  6. package/dist/core/errors/error-utils.js.map +7 -0
  7. package/dist/core/errors/index.js +13 -4
  8. package/dist/core/errors/index.js.map +2 -2
  9. package/dist/core/merge/unified-merge-resolver.js +303 -0
  10. package/dist/core/merge/unified-merge-resolver.js.map +7 -0
  11. package/dist/core/monitoring/logger.js +61 -9
  12. package/dist/core/monitoring/logger.js.map +2 -2
  13. package/dist/core/security/index.js +35 -0
  14. package/dist/core/security/index.js.map +7 -0
  15. package/dist/core/security/input-sanitizer.js +321 -0
  16. package/dist/core/security/input-sanitizer.js.map +7 -0
  17. package/dist/integrations/linear/client.js +5 -1
  18. package/dist/integrations/linear/client.js.map +2 -2
  19. package/dist/integrations/mcp/remote-server.js +27 -36
  20. package/dist/integrations/mcp/remote-server.js.map +2 -2
  21. package/dist/integrations/mcp/server.js +44 -29
  22. package/dist/integrations/mcp/server.js.map +3 -3
  23. package/dist/scripts/benchmark-performance.js +48 -0
  24. package/dist/scripts/benchmark-performance.js.map +7 -0
  25. package/dist/scripts/check-redis.js +42 -0
  26. package/dist/scripts/check-redis.js.map +7 -0
  27. package/dist/scripts/initialize.js +116 -0
  28. package/dist/scripts/initialize.js.map +7 -0
  29. package/dist/scripts/list-linear-tasks.js +124 -0
  30. package/dist/scripts/list-linear-tasks.js.map +7 -0
  31. package/dist/scripts/measure-handoff-impact.js +340 -0
  32. package/dist/scripts/measure-handoff-impact.js.map +7 -0
  33. package/dist/scripts/query-chromadb.js +160 -0
  34. package/dist/scripts/query-chromadb.js.map +7 -0
  35. package/dist/scripts/show-linear-summary.js +119 -0
  36. package/dist/scripts/show-linear-summary.js.map +7 -0
  37. package/dist/scripts/simple-swarm-demo.js +90 -0
  38. package/dist/scripts/simple-swarm-demo.js.map +7 -0
  39. package/dist/scripts/status.js +155 -0
  40. package/dist/scripts/status.js.map +7 -0
  41. package/dist/scripts/test-chromadb-sync.js +192 -0
  42. package/dist/scripts/test-chromadb-sync.js.map +7 -0
  43. package/dist/scripts/test-ralph-iteration-fix.js +86 -0
  44. package/dist/scripts/test-ralph-iteration-fix.js.map +7 -0
  45. package/dist/scripts/test-ralph-iterations.js +121 -0
  46. package/dist/scripts/test-ralph-iterations.js.map +7 -0
  47. package/dist/scripts/test-redis-storage.js +389 -0
  48. package/dist/scripts/test-redis-storage.js.map +7 -0
  49. package/dist/scripts/test-simple-ralph-state-sync.js +115 -0
  50. package/dist/scripts/test-simple-ralph-state-sync.js.map +7 -0
  51. package/dist/scripts/test-swarm-fixes.js +125 -0
  52. package/dist/scripts/test-swarm-fixes.js.map +7 -0
  53. package/dist/scripts/test-swarm-tui.js +23 -0
  54. package/dist/scripts/test-swarm-tui.js.map +7 -0
  55. package/dist/scripts/test-tui-shortcuts.js +52 -0
  56. package/dist/scripts/test-tui-shortcuts.js.map +7 -0
  57. package/dist/scripts/validate-tui-shortcuts.js +60 -0
  58. package/dist/scripts/validate-tui-shortcuts.js.map +7 -0
  59. package/dist/src/agents/core/agent-task-manager.js +527 -0
  60. package/dist/src/agents/core/agent-task-manager.js.map +7 -0
  61. package/dist/src/agents/verifiers/base-verifier.js +133 -0
  62. package/dist/src/agents/verifiers/base-verifier.js.map +7 -0
  63. package/dist/src/agents/verifiers/formatter-verifier.js +130 -0
  64. package/dist/src/agents/verifiers/formatter-verifier.js.map +7 -0
  65. package/dist/src/agents/verifiers/llm-judge.js +252 -0
  66. package/dist/src/agents/verifiers/llm-judge.js.map +7 -0
  67. package/dist/src/cli/auto-detect.js +321 -0
  68. package/dist/src/cli/auto-detect.js.map +7 -0
  69. package/dist/src/cli/claude-sm-danger.js +21 -0
  70. package/dist/src/cli/claude-sm-danger.js.map +7 -0
  71. package/dist/src/cli/claude-sm.js +1156 -0
  72. package/dist/src/cli/claude-sm.js.map +7 -0
  73. package/dist/src/cli/codex-sm-danger.js +21 -0
  74. package/dist/src/cli/codex-sm-danger.js.map +7 -0
  75. package/dist/src/cli/codex-sm.js +349 -0
  76. package/dist/src/cli/codex-sm.js.map +7 -0
  77. package/dist/src/cli/commands/api.js +232 -0
  78. package/dist/src/cli/commands/api.js.map +7 -0
  79. package/dist/src/cli/commands/auto-background.js +180 -0
  80. package/dist/src/cli/commands/auto-background.js.map +7 -0
  81. package/dist/src/cli/commands/cleanup-processes.js +68 -0
  82. package/dist/src/cli/commands/cleanup-processes.js.map +7 -0
  83. package/dist/src/cli/commands/clear.js +202 -0
  84. package/dist/src/cli/commands/clear.js.map +7 -0
  85. package/dist/src/cli/commands/config.js +445 -0
  86. package/dist/src/cli/commands/config.js.map +7 -0
  87. package/dist/src/cli/commands/context-rehydrate.js +751 -0
  88. package/dist/src/cli/commands/context-rehydrate.js.map +7 -0
  89. package/dist/src/cli/commands/context.js +343 -0
  90. package/dist/src/cli/commands/context.js.map +7 -0
  91. package/dist/src/cli/commands/daemon.js +392 -0
  92. package/dist/src/cli/commands/daemon.js.map +7 -0
  93. package/dist/src/cli/commands/dashboard.js +210 -0
  94. package/dist/src/cli/commands/dashboard.js.map +7 -0
  95. package/dist/src/cli/commands/db.js +147 -0
  96. package/dist/src/cli/commands/db.js.map +7 -0
  97. package/dist/src/cli/commands/decision.js +266 -0
  98. package/dist/src/cli/commands/decision.js.map +7 -0
  99. package/dist/src/cli/commands/discovery.js +279 -0
  100. package/dist/src/cli/commands/discovery.js.map +7 -0
  101. package/dist/src/cli/commands/handoff.js +624 -0
  102. package/dist/src/cli/commands/handoff.js.map +7 -0
  103. package/dist/src/cli/commands/hooks.js +298 -0
  104. package/dist/src/cli/commands/hooks.js.map +7 -0
  105. package/dist/src/cli/commands/linear.js +529 -0
  106. package/dist/src/cli/commands/linear.js.map +7 -0
  107. package/dist/src/cli/commands/log.js +169 -0
  108. package/dist/src/cli/commands/log.js.map +7 -0
  109. package/dist/src/cli/commands/login.js +172 -0
  110. package/dist/src/cli/commands/login.js.map +7 -0
  111. package/dist/src/cli/commands/migrate.js +240 -0
  112. package/dist/src/cli/commands/migrate.js.map +7 -0
  113. package/dist/src/cli/commands/model.js +533 -0
  114. package/dist/src/cli/commands/model.js.map +7 -0
  115. package/dist/src/cli/commands/onboard.js +536 -0
  116. package/dist/src/cli/commands/onboard.js.map +7 -0
  117. package/dist/src/cli/commands/projects.js +199 -0
  118. package/dist/src/cli/commands/projects.js.map +7 -0
  119. package/dist/src/cli/commands/ralph.js +909 -0
  120. package/dist/src/cli/commands/ralph.js.map +7 -0
  121. package/dist/src/cli/commands/retrieval.js +248 -0
  122. package/dist/src/cli/commands/retrieval.js.map +7 -0
  123. package/dist/src/cli/commands/search.js +173 -0
  124. package/dist/src/cli/commands/search.js.map +7 -0
  125. package/dist/src/cli/commands/service.js +749 -0
  126. package/dist/src/cli/commands/service.js.map +7 -0
  127. package/dist/src/cli/commands/session.js +200 -0
  128. package/dist/src/cli/commands/session.js.map +7 -0
  129. package/dist/src/cli/commands/settings.js +306 -0
  130. package/dist/src/cli/commands/settings.js.map +7 -0
  131. package/dist/src/cli/commands/setup.js +701 -0
  132. package/dist/src/cli/commands/setup.js.map +7 -0
  133. package/dist/src/cli/commands/shell.js +249 -0
  134. package/dist/src/cli/commands/shell.js.map +7 -0
  135. package/dist/src/cli/commands/signup.js +50 -0
  136. package/dist/src/cli/commands/signup.js.map +7 -0
  137. package/dist/src/cli/commands/skills.js +470 -0
  138. package/dist/src/cli/commands/skills.js.map +7 -0
  139. package/dist/src/cli/commands/sms-notify.js +795 -0
  140. package/dist/src/cli/commands/sms-notify.js.map +7 -0
  141. package/dist/src/cli/commands/storage-tier.js +183 -0
  142. package/dist/src/cli/commands/storage-tier.js.map +7 -0
  143. package/dist/src/cli/commands/sweep.js +249 -0
  144. package/dist/src/cli/commands/sweep.js.map +7 -0
  145. package/dist/src/cli/commands/tasks.js +213 -0
  146. package/dist/src/cli/commands/tasks.js.map +7 -0
  147. package/dist/src/cli/commands/worktree.js +319 -0
  148. package/dist/src/cli/commands/worktree.js.map +7 -0
  149. package/dist/src/cli/index.js +594 -0
  150. package/dist/src/cli/index.js.map +7 -0
  151. package/dist/src/cli/opencode-sm.js +448 -0
  152. package/dist/src/cli/opencode-sm.js.map +7 -0
  153. package/dist/src/cli/utils/viewer.js +96 -0
  154. package/dist/src/cli/utils/viewer.js.map +7 -0
  155. package/dist/src/core/config/config-manager.js +398 -0
  156. package/dist/src/core/config/config-manager.js.map +7 -0
  157. package/dist/src/core/config/feature-flags.js +76 -0
  158. package/dist/src/core/config/feature-flags.js.map +7 -0
  159. package/dist/src/core/config/storage-config.js +115 -0
  160. package/dist/src/core/config/storage-config.js.map +7 -0
  161. package/dist/src/core/config/types.js +144 -0
  162. package/dist/src/core/config/types.js.map +7 -0
  163. package/dist/src/core/context/auto-context.js +80 -0
  164. package/dist/src/core/context/auto-context.js.map +7 -0
  165. package/dist/src/core/context/dual-stack-manager.js +870 -0
  166. package/dist/src/core/context/dual-stack-manager.js.map +7 -0
  167. package/dist/src/core/context/enhanced-rehydration.js +994 -0
  168. package/dist/src/core/context/enhanced-rehydration.js.map +7 -0
  169. package/dist/src/core/context/frame-database.js +479 -0
  170. package/dist/src/core/context/frame-database.js.map +7 -0
  171. package/dist/src/core/context/frame-digest.js +250 -0
  172. package/dist/src/core/context/frame-digest.js.map +7 -0
  173. package/dist/src/core/context/frame-handoff-manager.js +778 -0
  174. package/dist/src/core/context/frame-handoff-manager.js.map +7 -0
  175. package/dist/src/core/context/frame-lifecycle-hooks.js +119 -0
  176. package/dist/src/core/context/frame-lifecycle-hooks.js.map +7 -0
  177. package/dist/src/core/context/frame-recovery.js +302 -0
  178. package/dist/src/core/context/frame-recovery.js.map +7 -0
  179. package/dist/src/core/context/frame-stack.js +314 -0
  180. package/dist/src/core/context/frame-stack.js.map +7 -0
  181. package/dist/src/core/context/frame-types.js +5 -0
  182. package/dist/src/core/context/frame-types.js.map +7 -0
  183. package/dist/src/core/context/index.js +25 -0
  184. package/dist/src/core/context/index.js.map +7 -0
  185. package/dist/src/core/context/permission-manager.js +185 -0
  186. package/dist/src/core/context/permission-manager.js.map +7 -0
  187. package/dist/src/core/context/recursive-context-manager.js +592 -0
  188. package/dist/src/core/context/recursive-context-manager.js.map +7 -0
  189. package/dist/src/core/context/refactored-frame-manager.js +754 -0
  190. package/dist/src/core/context/refactored-frame-manager.js.map +7 -0
  191. package/dist/src/core/context/shared-context-layer.js +621 -0
  192. package/dist/src/core/context/shared-context-layer.js.map +7 -0
  193. package/dist/src/core/context/stack-merge-resolver.js +749 -0
  194. package/dist/src/core/context/stack-merge-resolver.js.map +7 -0
  195. package/dist/src/core/context/validation.js +130 -0
  196. package/dist/src/core/context/validation.js.map +7 -0
  197. package/dist/src/core/database/batch-operations.js +384 -0
  198. package/dist/src/core/database/batch-operations.js.map +7 -0
  199. package/dist/src/core/database/connection-pool.js +330 -0
  200. package/dist/src/core/database/connection-pool.js.map +7 -0
  201. package/dist/src/core/database/database-adapter.js +60 -0
  202. package/dist/src/core/database/database-adapter.js.map +7 -0
  203. package/dist/src/core/database/migration-manager.js +614 -0
  204. package/dist/src/core/database/migration-manager.js.map +7 -0
  205. package/dist/src/core/database/query-cache.js +298 -0
  206. package/dist/src/core/database/query-cache.js.map +7 -0
  207. package/dist/src/core/database/query-router.js +430 -0
  208. package/dist/src/core/database/query-router.js.map +7 -0
  209. package/dist/src/core/database/sqlite-adapter.js +738 -0
  210. package/dist/src/core/database/sqlite-adapter.js.map +7 -0
  211. package/dist/src/core/digest/enhanced-hybrid-digest.js +277 -0
  212. package/dist/src/core/digest/enhanced-hybrid-digest.js.map +7 -0
  213. package/dist/src/core/digest/frame-digest-integration.js +176 -0
  214. package/dist/src/core/digest/frame-digest-integration.js.map +7 -0
  215. package/dist/src/core/digest/hybrid-digest-generator.js +553 -0
  216. package/dist/src/core/digest/hybrid-digest-generator.js.map +7 -0
  217. package/dist/src/core/digest/index.js +9 -0
  218. package/dist/src/core/digest/index.js.map +7 -0
  219. package/dist/src/core/digest/types.js +25 -0
  220. package/dist/src/core/digest/types.js.map +7 -0
  221. package/dist/src/core/errors/error-utils.js +208 -0
  222. package/dist/src/core/errors/error-utils.js.map +7 -0
  223. package/dist/src/core/errors/index.js +521 -0
  224. package/dist/src/core/errors/index.js.map +7 -0
  225. package/dist/src/core/errors/recovery.js +269 -0
  226. package/dist/src/core/errors/recovery.js.map +7 -0
  227. package/dist/src/core/execution/parallel-executor.js +258 -0
  228. package/dist/src/core/execution/parallel-executor.js.map +7 -0
  229. package/dist/src/core/frame/workflow-templates.js +319 -0
  230. package/dist/src/core/frame/workflow-templates.js.map +7 -0
  231. package/dist/src/core/merge/conflict-detector.js +431 -0
  232. package/dist/src/core/merge/conflict-detector.js.map +7 -0
  233. package/dist/src/core/merge/index.js +9 -0
  234. package/dist/src/core/merge/index.js.map +7 -0
  235. package/dist/src/core/merge/resolution-engine.js +558 -0
  236. package/dist/src/core/merge/resolution-engine.js.map +7 -0
  237. package/dist/src/core/merge/stack-diff.js +532 -0
  238. package/dist/src/core/merge/stack-diff.js.map +7 -0
  239. package/dist/src/core/merge/types.js +5 -0
  240. package/dist/src/core/merge/types.js.map +7 -0
  241. package/dist/src/core/merge/unified-merge-resolver.js +303 -0
  242. package/dist/src/core/merge/unified-merge-resolver.js.map +7 -0
  243. package/dist/src/core/models/fallback-monitor.js +232 -0
  244. package/dist/src/core/models/fallback-monitor.js.map +7 -0
  245. package/dist/src/core/models/model-router.js +340 -0
  246. package/dist/src/core/models/model-router.js.map +7 -0
  247. package/dist/src/core/monitoring/error-handler.js +49 -0
  248. package/dist/src/core/monitoring/error-handler.js.map +7 -0
  249. package/dist/src/core/monitoring/logger.js +202 -0
  250. package/dist/src/core/monitoring/logger.js.map +7 -0
  251. package/dist/src/core/monitoring/metrics.js +172 -0
  252. package/dist/src/core/monitoring/metrics.js.map +7 -0
  253. package/dist/src/core/monitoring/progress-tracker.js +189 -0
  254. package/dist/src/core/monitoring/progress-tracker.js.map +7 -0
  255. package/dist/src/core/monitoring/session-monitor.js +300 -0
  256. package/dist/src/core/monitoring/session-monitor.js.map +7 -0
  257. package/dist/src/core/performance/context-cache.js +273 -0
  258. package/dist/src/core/performance/context-cache.js.map +7 -0
  259. package/dist/src/core/performance/index.js +11 -0
  260. package/dist/src/core/performance/index.js.map +7 -0
  261. package/dist/src/core/performance/lazy-context-loader.js +327 -0
  262. package/dist/src/core/performance/lazy-context-loader.js.map +7 -0
  263. package/dist/src/core/performance/monitor.js +221 -0
  264. package/dist/src/core/performance/monitor.js.map +7 -0
  265. package/dist/src/core/performance/optimized-frame-context.js +345 -0
  266. package/dist/src/core/performance/optimized-frame-context.js.map +7 -0
  267. package/dist/src/core/performance/performance-benchmark.js +277 -0
  268. package/dist/src/core/performance/performance-benchmark.js.map +7 -0
  269. package/dist/src/core/performance/performance-profiler.js +370 -0
  270. package/dist/src/core/performance/performance-profiler.js.map +7 -0
  271. package/dist/src/core/performance/streaming-jsonl-parser.js +195 -0
  272. package/dist/src/core/performance/streaming-jsonl-parser.js.map +7 -0
  273. package/dist/src/core/persistence/postgres-adapter.js +349 -0
  274. package/dist/src/core/persistence/postgres-adapter.js.map +7 -0
  275. package/dist/src/core/projects/project-isolation.js +201 -0
  276. package/dist/src/core/projects/project-isolation.js.map +7 -0
  277. package/dist/src/core/projects/project-manager.js +697 -0
  278. package/dist/src/core/projects/project-manager.js.map +7 -0
  279. package/dist/src/core/query/query-parser.js +370 -0
  280. package/dist/src/core/query/query-parser.js.map +7 -0
  281. package/dist/src/core/query/query-templates.js +321 -0
  282. package/dist/src/core/query/query-templates.js.map +7 -0
  283. package/dist/src/core/retrieval/context-retriever.js +479 -0
  284. package/dist/src/core/retrieval/context-retriever.js.map +7 -0
  285. package/dist/src/core/retrieval/index.js +8 -0
  286. package/dist/src/core/retrieval/index.js.map +7 -0
  287. package/dist/src/core/retrieval/llm-context-retrieval.js +613 -0
  288. package/dist/src/core/retrieval/llm-context-retrieval.js.map +7 -0
  289. package/dist/src/core/retrieval/llm-provider.js +151 -0
  290. package/dist/src/core/retrieval/llm-provider.js.map +7 -0
  291. package/dist/src/core/retrieval/retrieval-audit.js +236 -0
  292. package/dist/src/core/retrieval/retrieval-audit.js.map +7 -0
  293. package/dist/src/core/retrieval/summary-generator.js +589 -0
  294. package/dist/src/core/retrieval/summary-generator.js.map +7 -0
  295. package/dist/src/core/retrieval/types.js +21 -0
  296. package/dist/src/core/retrieval/types.js.map +7 -0
  297. package/dist/src/core/security/index.js +35 -0
  298. package/dist/src/core/security/index.js.map +7 -0
  299. package/dist/src/core/security/input-sanitizer.js +321 -0
  300. package/dist/src/core/security/input-sanitizer.js.map +7 -0
  301. package/dist/src/core/session/clear-survival.js +465 -0
  302. package/dist/src/core/session/clear-survival.js.map +7 -0
  303. package/dist/src/core/session/enhanced-handoff.js +792 -0
  304. package/dist/src/core/session/enhanced-handoff.js.map +7 -0
  305. package/dist/src/core/session/handoff-generator.js +343 -0
  306. package/dist/src/core/session/handoff-generator.js.map +7 -0
  307. package/dist/src/core/session/index.js +15 -0
  308. package/dist/src/core/session/index.js.map +7 -0
  309. package/dist/src/core/session/session-manager.js +347 -0
  310. package/dist/src/core/session/session-manager.js.map +7 -0
  311. package/dist/src/core/skills/index.js +7 -0
  312. package/dist/src/core/skills/index.js.map +7 -0
  313. package/dist/src/core/skills/skill-storage.js +764 -0
  314. package/dist/src/core/skills/skill-storage.js.map +7 -0
  315. package/dist/src/core/skills/types.js +193 -0
  316. package/dist/src/core/skills/types.js.map +7 -0
  317. package/dist/src/core/storage/chromadb-adapter.js +354 -0
  318. package/dist/src/core/storage/chromadb-adapter.js.map +7 -0
  319. package/dist/src/core/storage/infinite-storage.js +510 -0
  320. package/dist/src/core/storage/infinite-storage.js.map +7 -0
  321. package/dist/src/core/storage/remote-storage.js +489 -0
  322. package/dist/src/core/storage/remote-storage.js.map +7 -0
  323. package/dist/src/core/storage/two-tier-storage.js +766 -0
  324. package/dist/src/core/storage/two-tier-storage.js.map +7 -0
  325. package/dist/src/core/trace/cli-trace-wrapper.js +132 -0
  326. package/dist/src/core/trace/cli-trace-wrapper.js.map +7 -0
  327. package/dist/src/core/trace/db-trace-wrapper.js +247 -0
  328. package/dist/src/core/trace/db-trace-wrapper.js.map +7 -0
  329. package/dist/src/core/trace/debug-trace.js +417 -0
  330. package/dist/src/core/trace/debug-trace.js.map +7 -0
  331. package/dist/src/core/trace/index.js +109 -0
  332. package/dist/src/core/trace/index.js.map +7 -0
  333. package/dist/src/core/trace/linear-api-wrapper.js +178 -0
  334. package/dist/src/core/trace/linear-api-wrapper.js.map +7 -0
  335. package/dist/src/core/trace/trace-detector.js +528 -0
  336. package/dist/src/core/trace/trace-detector.js.map +7 -0
  337. package/dist/src/core/trace/trace-store.js +345 -0
  338. package/dist/src/core/trace/trace-store.js.map +7 -0
  339. package/dist/src/core/trace/types.js +77 -0
  340. package/dist/src/core/trace/types.js.map +7 -0
  341. package/dist/src/core/types.js +5 -0
  342. package/dist/src/core/types.js.map +7 -0
  343. package/dist/src/core/utils/async-mutex.js +114 -0
  344. package/dist/src/core/utils/async-mutex.js.map +7 -0
  345. package/dist/src/core/utils/compression.js +83 -0
  346. package/dist/src/core/utils/compression.js.map +7 -0
  347. package/dist/src/core/utils/update-checker.js +218 -0
  348. package/dist/src/core/utils/update-checker.js.map +7 -0
  349. package/dist/src/core/worktree/worktree-manager.js +465 -0
  350. package/dist/src/core/worktree/worktree-manager.js.map +7 -0
  351. package/dist/src/daemon/daemon-config.js +149 -0
  352. package/dist/src/daemon/daemon-config.js.map +7 -0
  353. package/dist/src/daemon/services/context-service.js +122 -0
  354. package/dist/src/daemon/services/context-service.js.map +7 -0
  355. package/dist/src/daemon/services/linear-service.js +136 -0
  356. package/dist/src/daemon/services/linear-service.js.map +7 -0
  357. package/dist/src/daemon/session-daemon.js +312 -0
  358. package/dist/src/daemon/session-daemon.js.map +7 -0
  359. package/dist/src/daemon/unified-daemon.js +276 -0
  360. package/dist/src/daemon/unified-daemon.js.map +7 -0
  361. package/dist/src/features/analytics/api/analytics-api.js +287 -0
  362. package/dist/src/features/analytics/api/analytics-api.js.map +7 -0
  363. package/dist/src/features/analytics/core/analytics-service.js +282 -0
  364. package/dist/src/features/analytics/core/analytics-service.js.map +7 -0
  365. package/dist/src/features/analytics/index.js +18 -0
  366. package/dist/src/features/analytics/index.js.map +7 -0
  367. package/dist/src/features/analytics/queries/metrics-queries.js +277 -0
  368. package/dist/src/features/analytics/queries/metrics-queries.js.map +7 -0
  369. package/dist/src/features/analytics/types/metrics.js +5 -0
  370. package/dist/src/features/analytics/types/metrics.js.map +7 -0
  371. package/dist/src/features/browser/browser-mcp.js +492 -0
  372. package/dist/src/features/browser/browser-mcp.js.map +7 -0
  373. package/dist/src/features/sweep/index.js +20 -0
  374. package/dist/src/features/sweep/index.js.map +7 -0
  375. package/dist/src/features/sweep/prediction-client.js +155 -0
  376. package/dist/src/features/sweep/prediction-client.js.map +7 -0
  377. package/dist/src/features/sweep/prompt-builder.js +85 -0
  378. package/dist/src/features/sweep/prompt-builder.js.map +7 -0
  379. package/dist/src/features/sweep/pty-wrapper.js +171 -0
  380. package/dist/src/features/sweep/pty-wrapper.js.map +7 -0
  381. package/dist/src/features/sweep/state-watcher.js +87 -0
  382. package/dist/src/features/sweep/state-watcher.js.map +7 -0
  383. package/dist/src/features/sweep/status-bar.js +88 -0
  384. package/dist/src/features/sweep/status-bar.js.map +7 -0
  385. package/dist/src/features/sweep/sweep-server-manager.js +226 -0
  386. package/dist/src/features/sweep/sweep-server-manager.js.map +7 -0
  387. package/dist/src/features/sweep/tab-interceptor.js +38 -0
  388. package/dist/src/features/sweep/tab-interceptor.js.map +7 -0
  389. package/dist/src/features/sweep/types.js +18 -0
  390. package/dist/src/features/sweep/types.js.map +7 -0
  391. package/dist/src/features/tasks/linear-task-manager.js +487 -0
  392. package/dist/src/features/tasks/linear-task-manager.js.map +7 -0
  393. package/dist/src/features/tasks/task-aware-context.js +410 -0
  394. package/dist/src/features/tasks/task-aware-context.js.map +7 -0
  395. package/dist/src/features/tui/simple-monitor.js +116 -0
  396. package/dist/src/features/tui/simple-monitor.js.map +7 -0
  397. package/dist/src/features/tui/swarm-monitor.js +648 -0
  398. package/dist/src/features/tui/swarm-monitor.js.map +7 -0
  399. package/dist/src/features/web/client/stores/task-store.js +26 -0
  400. package/dist/src/features/web/client/stores/task-store.js.map +7 -0
  401. package/dist/src/features/web/server/index.js +194 -0
  402. package/dist/src/features/web/server/index.js.map +7 -0
  403. package/dist/src/hooks/auto-background.js +151 -0
  404. package/dist/src/hooks/auto-background.js.map +7 -0
  405. package/dist/src/hooks/claude-code-whatsapp-hook.js +197 -0
  406. package/dist/src/hooks/claude-code-whatsapp-hook.js.map +7 -0
  407. package/dist/src/hooks/config.js +150 -0
  408. package/dist/src/hooks/config.js.map +7 -0
  409. package/dist/src/hooks/daemon.js +364 -0
  410. package/dist/src/hooks/daemon.js.map +7 -0
  411. package/dist/src/hooks/events.js +58 -0
  412. package/dist/src/hooks/events.js.map +7 -0
  413. package/dist/src/hooks/index.js +12 -0
  414. package/dist/src/hooks/index.js.map +7 -0
  415. package/dist/src/hooks/linear-task-picker.js +186 -0
  416. package/dist/src/hooks/linear-task-picker.js.map +7 -0
  417. package/dist/src/hooks/schemas.js +197 -0
  418. package/dist/src/hooks/schemas.js.map +7 -0
  419. package/dist/src/hooks/secure-fs.js +49 -0
  420. package/dist/src/hooks/secure-fs.js.map +7 -0
  421. package/dist/src/hooks/security-logger.js +155 -0
  422. package/dist/src/hooks/security-logger.js.map +7 -0
  423. package/dist/src/hooks/session-summary.js +222 -0
  424. package/dist/src/hooks/session-summary.js.map +7 -0
  425. package/dist/src/hooks/sms-action-runner.js +371 -0
  426. package/dist/src/hooks/sms-action-runner.js.map +7 -0
  427. package/dist/src/hooks/sms-notify.js +506 -0
  428. package/dist/src/hooks/sms-notify.js.map +7 -0
  429. package/dist/src/hooks/sms-watcher.js +93 -0
  430. package/dist/src/hooks/sms-watcher.js.map +7 -0
  431. package/dist/src/hooks/sms-webhook.js +555 -0
  432. package/dist/src/hooks/sms-webhook.js.map +7 -0
  433. package/dist/src/hooks/whatsapp-commands.js +479 -0
  434. package/dist/src/hooks/whatsapp-commands.js.map +7 -0
  435. package/dist/src/hooks/whatsapp-scheduler.js +317 -0
  436. package/dist/src/hooks/whatsapp-scheduler.js.map +7 -0
  437. package/dist/src/hooks/whatsapp-sync.js +409 -0
  438. package/dist/src/hooks/whatsapp-sync.js.map +7 -0
  439. package/dist/src/index.js +25 -0
  440. package/dist/src/index.js.map +7 -0
  441. package/dist/src/integrations/anthropic/client.js +263 -0
  442. package/dist/src/integrations/anthropic/client.js.map +7 -0
  443. package/dist/src/integrations/claude-code/agent-bridge.js +768 -0
  444. package/dist/src/integrations/claude-code/agent-bridge.js.map +7 -0
  445. package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js +459 -0
  446. package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js.map +7 -0
  447. package/dist/src/integrations/claude-code/lifecycle-hooks.js +254 -0
  448. package/dist/src/integrations/claude-code/lifecycle-hooks.js.map +7 -0
  449. package/dist/src/integrations/claude-code/post-task-hooks.js +545 -0
  450. package/dist/src/integrations/claude-code/post-task-hooks.js.map +7 -0
  451. package/dist/src/integrations/claude-code/subagent-client-stub.js +20 -0
  452. package/dist/src/integrations/claude-code/subagent-client-stub.js.map +7 -0
  453. package/dist/src/integrations/claude-code/subagent-client.js +511 -0
  454. package/dist/src/integrations/claude-code/subagent-client.js.map +7 -0
  455. package/dist/src/integrations/claude-code/task-coordinator.js +360 -0
  456. package/dist/src/integrations/claude-code/task-coordinator.js.map +7 -0
  457. package/dist/src/integrations/linear/auth.js +337 -0
  458. package/dist/src/integrations/linear/auth.js.map +7 -0
  459. package/dist/src/integrations/linear/auto-sync.js +258 -0
  460. package/dist/src/integrations/linear/auto-sync.js.map +7 -0
  461. package/dist/src/integrations/linear/client.js +634 -0
  462. package/dist/src/integrations/linear/client.js.map +7 -0
  463. package/dist/src/integrations/linear/config.js +130 -0
  464. package/dist/src/integrations/linear/config.js.map +7 -0
  465. package/dist/src/integrations/linear/migration.js +361 -0
  466. package/dist/src/integrations/linear/migration.js.map +7 -0
  467. package/dist/src/integrations/linear/oauth-server.js +454 -0
  468. package/dist/src/integrations/linear/oauth-server.js.map +7 -0
  469. package/dist/src/integrations/linear/rest-client.js +213 -0
  470. package/dist/src/integrations/linear/rest-client.js.map +7 -0
  471. package/dist/src/integrations/linear/sync-manager.js +236 -0
  472. package/dist/src/integrations/linear/sync-manager.js.map +7 -0
  473. package/dist/src/integrations/linear/sync-service.js +231 -0
  474. package/dist/src/integrations/linear/sync-service.js.map +7 -0
  475. package/dist/src/integrations/linear/sync.js +782 -0
  476. package/dist/src/integrations/linear/sync.js.map +7 -0
  477. package/dist/src/integrations/linear/types.js +5 -0
  478. package/dist/src/integrations/linear/types.js.map +7 -0
  479. package/dist/src/integrations/linear/unified-sync.js +589 -0
  480. package/dist/src/integrations/linear/unified-sync.js.map +7 -0
  481. package/dist/src/integrations/linear/webhook-handler.js +219 -0
  482. package/dist/src/integrations/linear/webhook-handler.js.map +7 -0
  483. package/dist/src/integrations/linear/webhook-server.js +218 -0
  484. package/dist/src/integrations/linear/webhook-server.js.map +7 -0
  485. package/dist/src/integrations/linear/webhook.js +291 -0
  486. package/dist/src/integrations/linear/webhook.js.map +7 -0
  487. package/dist/src/integrations/mcp/handlers/code-execution-handlers.js +266 -0
  488. package/dist/src/integrations/mcp/handlers/code-execution-handlers.js.map +7 -0
  489. package/dist/src/integrations/mcp/handlers/context-handlers.js +257 -0
  490. package/dist/src/integrations/mcp/handlers/context-handlers.js.map +7 -0
  491. package/dist/src/integrations/mcp/handlers/discovery-handlers.js +497 -0
  492. package/dist/src/integrations/mcp/handlers/discovery-handlers.js.map +7 -0
  493. package/dist/src/integrations/mcp/handlers/index.js +166 -0
  494. package/dist/src/integrations/mcp/handlers/index.js.map +7 -0
  495. package/dist/src/integrations/mcp/handlers/linear-handlers.js +247 -0
  496. package/dist/src/integrations/mcp/handlers/linear-handlers.js.map +7 -0
  497. package/dist/src/integrations/mcp/handlers/skill-handlers.js +529 -0
  498. package/dist/src/integrations/mcp/handlers/skill-handlers.js.map +7 -0
  499. package/dist/src/integrations/mcp/handlers/task-handlers.js +239 -0
  500. package/dist/src/integrations/mcp/handlers/task-handlers.js.map +7 -0
  501. package/dist/src/integrations/mcp/handlers/trace-handlers.js +308 -0
  502. package/dist/src/integrations/mcp/handlers/trace-handlers.js.map +7 -0
  503. package/dist/src/integrations/mcp/index.js +23 -0
  504. package/dist/src/integrations/mcp/index.js.map +7 -0
  505. package/dist/src/integrations/mcp/middleware/tool-scoring.js +356 -0
  506. package/dist/src/integrations/mcp/middleware/tool-scoring.js.map +7 -0
  507. package/dist/src/integrations/mcp/refactored-server.js +374 -0
  508. package/dist/src/integrations/mcp/refactored-server.js.map +7 -0
  509. package/dist/src/integrations/mcp/remote-server.js +682 -0
  510. package/dist/src/integrations/mcp/remote-server.js.map +7 -0
  511. package/dist/src/integrations/mcp/schemas.js +147 -0
  512. package/dist/src/integrations/mcp/schemas.js.map +7 -0
  513. package/dist/src/integrations/mcp/server.js +1975 -0
  514. package/dist/src/integrations/mcp/server.js.map +7 -0
  515. package/dist/src/integrations/mcp/tool-definitions-code.js +125 -0
  516. package/dist/src/integrations/mcp/tool-definitions-code.js.map +7 -0
  517. package/dist/src/integrations/mcp/tool-definitions.js +702 -0
  518. package/dist/src/integrations/mcp/tool-definitions.js.map +7 -0
  519. package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +860 -0
  520. package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +7 -0
  521. package/dist/src/integrations/ralph/context/context-budget-manager.js +301 -0
  522. package/dist/src/integrations/ralph/context/context-budget-manager.js.map +7 -0
  523. package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +360 -0
  524. package/dist/src/integrations/ralph/context/stackmemory-context-loader.js.map +7 -0
  525. package/dist/src/integrations/ralph/coordination/enhanced-coordination.js +410 -0
  526. package/dist/src/integrations/ralph/coordination/enhanced-coordination.js.map +7 -0
  527. package/dist/src/integrations/ralph/index.js +18 -0
  528. package/dist/src/integrations/ralph/index.js.map +7 -0
  529. package/dist/src/integrations/ralph/learning/pattern-learner.js +401 -0
  530. package/dist/src/integrations/ralph/learning/pattern-learner.js.map +7 -0
  531. package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +448 -0
  532. package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js.map +7 -0
  533. package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +294 -0
  534. package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js.map +7 -0
  535. package/dist/src/integrations/ralph/monitoring/swarm-registry.js +108 -0
  536. package/dist/src/integrations/ralph/monitoring/swarm-registry.js.map +7 -0
  537. package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +463 -0
  538. package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +7 -0
  539. package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +400 -0
  540. package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js.map +7 -0
  541. package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +473 -0
  542. package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js.map +7 -0
  543. package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +388 -0
  544. package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js.map +7 -0
  545. package/dist/src/integrations/ralph/performance/performance-optimizer.js +358 -0
  546. package/dist/src/integrations/ralph/performance/performance-optimizer.js.map +7 -0
  547. package/dist/src/integrations/ralph/recovery/crash-recovery.js +462 -0
  548. package/dist/src/integrations/ralph/recovery/crash-recovery.js.map +7 -0
  549. package/dist/src/integrations/ralph/state/state-reconciler.js +404 -0
  550. package/dist/src/integrations/ralph/state/state-reconciler.js.map +7 -0
  551. package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +428 -0
  552. package/dist/src/integrations/ralph/swarm/git-workflow-manager.js.map +7 -0
  553. package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +996 -0
  554. package/dist/src/integrations/ralph/swarm/swarm-coordinator.js.map +7 -0
  555. package/dist/src/integrations/ralph/types.js +5 -0
  556. package/dist/src/integrations/ralph/types.js.map +7 -0
  557. package/dist/src/integrations/ralph/visualization/ralph-debugger.js +585 -0
  558. package/dist/src/integrations/ralph/visualization/ralph-debugger.js.map +7 -0
  559. package/dist/src/mcp/stackmemory-mcp-server.js +554 -0
  560. package/dist/src/mcp/stackmemory-mcp-server.js.map +7 -0
  561. package/dist/src/middleware/exponential-rate-limiter.js +289 -0
  562. package/dist/src/middleware/exponential-rate-limiter.js.map +7 -0
  563. package/dist/src/models/user.model.js +358 -0
  564. package/dist/src/models/user.model.js.map +7 -0
  565. package/dist/src/servers/production/auth-middleware.js +528 -0
  566. package/dist/src/servers/production/auth-middleware.js.map +7 -0
  567. package/dist/src/services/config-service.js +65 -0
  568. package/dist/src/services/config-service.js.map +7 -0
  569. package/dist/src/services/context-service.js +194 -0
  570. package/dist/src/services/context-service.js.map +7 -0
  571. package/dist/src/skills/api-discovery.js +354 -0
  572. package/dist/src/skills/api-discovery.js.map +7 -0
  573. package/dist/src/skills/api-skill.js +475 -0
  574. package/dist/src/skills/api-skill.js.map +7 -0
  575. package/dist/src/skills/claude-skills.js +1061 -0
  576. package/dist/src/skills/claude-skills.js.map +7 -0
  577. package/dist/src/skills/dashboard-launcher.js +216 -0
  578. package/dist/src/skills/dashboard-launcher.js.map +7 -0
  579. package/dist/src/skills/recursive-agent-orchestrator.js +575 -0
  580. package/dist/src/skills/recursive-agent-orchestrator.js.map +7 -0
  581. package/dist/src/skills/repo-ingestion-skill.js +609 -0
  582. package/dist/src/skills/repo-ingestion-skill.js.map +7 -0
  583. package/dist/src/skills/unified-rlm-orchestrator.js +404 -0
  584. package/dist/src/skills/unified-rlm-orchestrator.js.map +7 -0
  585. package/dist/src/types/task.js +5 -0
  586. package/dist/src/types/task.js.map +7 -0
  587. package/dist/src/utils/env.js +50 -0
  588. package/dist/src/utils/env.js.map +7 -0
  589. package/dist/src/utils/formatting.js +62 -0
  590. package/dist/src/utils/formatting.js.map +7 -0
  591. package/dist/src/utils/process-cleanup.js +136 -0
  592. package/dist/src/utils/process-cleanup.js.map +7 -0
  593. package/package.json +3 -3
  594. package/scripts/initialize.ts +16 -7
  595. package/scripts/install.sh +14 -62
  596. package/scripts/status.ts +111 -46
@@ -0,0 +1,795 @@
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 { Command } from "commander";
6
+ import chalk from "chalk";
7
+ import { execSync } from "child_process";
8
+ import { join } from "path";
9
+ import { existsSync, readFileSync, unlinkSync } from "fs";
10
+ import {
11
+ loadSMSConfig,
12
+ saveSMSConfig,
13
+ sendNotification,
14
+ sendSMSNotification,
15
+ notifyReviewReady,
16
+ notifyWithYesNo,
17
+ notifyTaskComplete,
18
+ cleanupExpiredPrompts
19
+ } from "../../hooks/sms-notify.js";
20
+ import {
21
+ loadActionQueue,
22
+ processAllPendingActions,
23
+ cleanupOldActions,
24
+ startActionWatcher
25
+ } from "../../hooks/sms-action-runner.js";
26
+ import {
27
+ syncContext,
28
+ syncFrame,
29
+ enableAutoSync,
30
+ disableAutoSync,
31
+ isAutoSyncEnabled,
32
+ loadSyncOptions
33
+ } from "../../hooks/whatsapp-sync.js";
34
+ import {
35
+ loadCommandsConfig,
36
+ enableCommands,
37
+ disableCommands,
38
+ getAvailableCommands
39
+ } from "../../hooks/whatsapp-commands.js";
40
+ import {
41
+ listSchedules,
42
+ cancelSchedule,
43
+ scheduleDailyDigest,
44
+ scheduleHourlyDigest,
45
+ scheduleIntervalDigest,
46
+ startScheduler,
47
+ stopScheduler,
48
+ isSchedulerRunning,
49
+ runScheduledDigest
50
+ } from "../../hooks/whatsapp-scheduler.js";
51
+ function createSMSNotifyCommand() {
52
+ const cmd = new Command("notify").description(
53
+ "SMS/WhatsApp notifications with context sync and scheduled digests"
54
+ ).addHelpText(
55
+ "after",
56
+ `
57
+ Setup:
58
+ 1. Create Twilio account at https://twilio.com
59
+ 2. Set environment variables:
60
+ export TWILIO_ACCOUNT_SID=your_sid
61
+ export TWILIO_AUTH_TOKEN=your_token
62
+ export TWILIO_WHATSAPP_FROM=+1234567890
63
+ export TWILIO_WHATSAPP_TO=+1234567890
64
+ 3. Enable: stackmemory notify enable
65
+
66
+ Basic Commands:
67
+ stackmemory notify status Check configuration
68
+ stackmemory notify enable Enable notifications
69
+ stackmemory notify channel whatsapp Switch to WhatsApp (default)
70
+ stackmemory notify channel sms Switch to SMS
71
+ stackmemory notify test Send test message
72
+ stackmemory notify send "message" Send custom message
73
+ stackmemory notify review "PR #123" Send review notification
74
+ stackmemory notify ask "Deploy?" Send yes/no prompt
75
+
76
+ Context Sync:
77
+ Pushes development context (active frames, decisions, files) to WhatsApp.
78
+ stackmemory notify sync Push current context now
79
+ stackmemory notify sync --frame <id> Sync specific frame
80
+ stackmemory notify sync --auto Enable auto-sync on frame close
81
+ stackmemory notify sync --no-auto Disable auto-sync
82
+ stackmemory notify sync-status Show sync configuration
83
+
84
+ Scheduled Digests:
85
+ Automatically sends context summaries at configured intervals.
86
+ stackmemory notify schedule list List all schedules
87
+ stackmemory notify schedule daily 09:00 Daily digest at 9 AM
88
+ stackmemory notify schedule hourly Every hour
89
+ stackmemory notify schedule interval 30 Every 30 minutes
90
+ stackmemory notify schedule cancel <id> Remove a schedule
91
+ stackmemory notify schedule run <id> Run schedule now
92
+ stackmemory notify schedule start Start scheduler daemon
93
+ stackmemory notify schedule stop Stop scheduler daemon
94
+
95
+ Inbound Commands:
96
+ Enable command processing to respond to WhatsApp messages.
97
+ stackmemory notify commands List available commands
98
+ stackmemory notify commands --enable Enable command processing
99
+ stackmemory notify commands --disable Disable command processing
100
+
101
+ Supported WhatsApp commands:
102
+ status - Get current session status
103
+ frames - List active frames
104
+ tasks - Show pending tasks
105
+ digest - Request full context digest
106
+ pause - Pause notifications
107
+ resume - Resume notifications
108
+ `
109
+ );
110
+ cmd.command("status").description("Show notification configuration status").action(() => {
111
+ const config = loadSMSConfig();
112
+ console.log(chalk.blue("Notification Status:"));
113
+ console.log();
114
+ const hasCreds = config.accountSid && config.authToken;
115
+ const channel = config.channel || "whatsapp";
116
+ const hasWhatsApp = config.whatsappFromNumber || config.fromNumber || config.whatsappToNumber || config.toNumber;
117
+ const hasSMS = config.smsFromNumber || config.fromNumber || config.smsToNumber || config.toNumber;
118
+ const hasNumbers = channel === "whatsapp" ? hasWhatsApp : hasSMS;
119
+ console.log(
120
+ ` ${chalk.gray("Enabled:")} ${config.enabled ? chalk.green("yes") : chalk.red("no")}`
121
+ );
122
+ console.log(
123
+ ` ${chalk.gray("Channel:")} ${channel === "whatsapp" ? chalk.cyan("WhatsApp") : chalk.blue("SMS")}`
124
+ );
125
+ console.log(
126
+ ` ${chalk.gray("Configured:")} ${hasCreds && hasNumbers ? chalk.green("yes") : chalk.yellow("no (set env vars)")}`
127
+ );
128
+ console.log();
129
+ console.log(chalk.blue("Numbers:"));
130
+ if (channel === "whatsapp") {
131
+ const from = config.whatsappFromNumber || config.fromNumber;
132
+ const to = config.whatsappToNumber || config.toNumber;
133
+ if (from) {
134
+ console.log(` ${chalk.gray("WhatsApp From:")} ${maskPhone(from)}`);
135
+ }
136
+ if (to) {
137
+ console.log(` ${chalk.gray("WhatsApp To:")} ${maskPhone(to)}`);
138
+ }
139
+ } else {
140
+ const from = config.smsFromNumber || config.fromNumber;
141
+ const to = config.smsToNumber || config.toNumber;
142
+ if (from) {
143
+ console.log(` ${chalk.gray("SMS From:")} ${maskPhone(from)}`);
144
+ }
145
+ if (to) {
146
+ console.log(` ${chalk.gray("SMS To:")} ${maskPhone(to)}`);
147
+ }
148
+ }
149
+ console.log();
150
+ console.log(chalk.blue("Notify On:"));
151
+ console.log(
152
+ ` ${chalk.gray("Task Complete:")} ${config.notifyOn.taskComplete ? "yes" : "no"}`
153
+ );
154
+ console.log(
155
+ ` ${chalk.gray("Review Ready:")} ${config.notifyOn.reviewReady ? "yes" : "no"}`
156
+ );
157
+ console.log(
158
+ ` ${chalk.gray("Errors:")} ${config.notifyOn.error ? "yes" : "no"}`
159
+ );
160
+ if (config.quietHours?.enabled) {
161
+ console.log();
162
+ console.log(
163
+ chalk.blue(
164
+ `Quiet Hours: ${config.quietHours.start} - ${config.quietHours.end}`
165
+ )
166
+ );
167
+ }
168
+ console.log();
169
+ console.log(
170
+ ` ${chalk.gray("Pending Prompts:")} ${config.pendingPrompts.length}`
171
+ );
172
+ console.log(
173
+ ` ${chalk.gray("Response Timeout:")} ${config.responseTimeout}s`
174
+ );
175
+ if (!hasCreds || !hasNumbers) {
176
+ console.log();
177
+ console.log(
178
+ chalk.yellow("To configure, set these environment variables:")
179
+ );
180
+ console.log(chalk.gray(" export TWILIO_ACCOUNT_SID=your_sid"));
181
+ console.log(chalk.gray(" export TWILIO_AUTH_TOKEN=your_token"));
182
+ console.log();
183
+ console.log(chalk.gray(" For WhatsApp (recommended):"));
184
+ console.log(chalk.gray(" export TWILIO_WHATSAPP_FROM=+1234567890"));
185
+ console.log(chalk.gray(" export TWILIO_WHATSAPP_TO=+1234567890"));
186
+ console.log();
187
+ console.log(chalk.gray(" For SMS:"));
188
+ console.log(chalk.gray(" export TWILIO_SMS_FROM=+1234567890"));
189
+ console.log(chalk.gray(" export TWILIO_SMS_TO=+1234567890"));
190
+ }
191
+ });
192
+ cmd.command("enable").description("Enable SMS notifications").action(() => {
193
+ const config = loadSMSConfig();
194
+ config.enabled = true;
195
+ saveSMSConfig(config);
196
+ console.log(chalk.green("SMS notifications enabled"));
197
+ const hasCreds = config.accountSid && config.authToken && config.fromNumber && config.toNumber;
198
+ if (!hasCreds) {
199
+ console.log(
200
+ chalk.yellow(
201
+ "Note: Set Twilio environment variables to send messages"
202
+ )
203
+ );
204
+ }
205
+ });
206
+ cmd.command("disable").description("Disable SMS notifications").action(() => {
207
+ const config = loadSMSConfig();
208
+ config.enabled = false;
209
+ saveSMSConfig(config);
210
+ console.log(chalk.yellow("SMS notifications disabled"));
211
+ });
212
+ cmd.command("channel <type>").description("Set notification channel (whatsapp|sms)").action((type) => {
213
+ const validChannels = ["whatsapp", "sms"];
214
+ const channel = type.toLowerCase();
215
+ if (!validChannels.includes(channel)) {
216
+ console.log(
217
+ chalk.red(`Invalid channel. Use: ${validChannels.join(", ")}`)
218
+ );
219
+ return;
220
+ }
221
+ const config = loadSMSConfig();
222
+ config.channel = channel;
223
+ saveSMSConfig(config);
224
+ const label = channel === "whatsapp" ? "WhatsApp" : "SMS";
225
+ console.log(chalk.green(`Notification channel set to ${label}`));
226
+ if (channel === "whatsapp") {
227
+ const hasNumbers = config.whatsappFromNumber || config.fromNumber;
228
+ if (!hasNumbers) {
229
+ console.log(
230
+ chalk.yellow("Set TWILIO_WHATSAPP_FROM and TWILIO_WHATSAPP_TO")
231
+ );
232
+ }
233
+ } else {
234
+ const hasNumbers = config.smsFromNumber || config.fromNumber;
235
+ if (!hasNumbers) {
236
+ console.log(chalk.yellow("Set TWILIO_SMS_FROM and TWILIO_SMS_TO"));
237
+ }
238
+ }
239
+ });
240
+ cmd.command("test").description("Send a test notification").option("--sms", "Force SMS channel").option("--whatsapp", "Force WhatsApp channel").action(async (options) => {
241
+ const config = loadSMSConfig();
242
+ const channelOverride = options.sms ? "sms" : options.whatsapp ? "whatsapp" : void 0;
243
+ const channelLabel = channelOverride || config.channel === "whatsapp" ? "WhatsApp" : "SMS";
244
+ console.log(
245
+ chalk.blue(`Sending test notification via ${channelLabel}...`)
246
+ );
247
+ const result = await sendNotification(
248
+ {
249
+ type: "custom",
250
+ title: "StackMemory Test",
251
+ message: "This is a test notification from StackMemory."
252
+ },
253
+ channelOverride
254
+ );
255
+ if (result.success) {
256
+ const usedChannel = result.channel === "whatsapp" ? "WhatsApp" : "SMS";
257
+ console.log(chalk.green(`Test message sent via ${usedChannel}!`));
258
+ } else {
259
+ console.log(chalk.red(`Failed: ${result.error}`));
260
+ }
261
+ });
262
+ cmd.command("send <message>").description("Send a custom notification").option("-t, --title <title>", "Message title", "StackMemory Alert").action(async (message, options) => {
263
+ const result = await sendSMSNotification({
264
+ type: "custom",
265
+ title: options.title,
266
+ message
267
+ });
268
+ if (result.success) {
269
+ console.log(chalk.green("Message sent!"));
270
+ } else {
271
+ console.log(chalk.red(`Failed: ${result.error}`));
272
+ }
273
+ });
274
+ cmd.command("review <title>").description("Send review-ready notification with options").option("-m, --message <msg>", "Description", "Ready for your review").option(
275
+ "-o, --options <opts>",
276
+ "Comma-separated options",
277
+ "Approve,Request Changes,Skip"
278
+ ).action(
279
+ async (title, options) => {
280
+ const opts = options.options.split(",").map((o) => ({
281
+ label: o.trim()
282
+ }));
283
+ console.log(chalk.blue("Sending review notification..."));
284
+ const result = await notifyReviewReady(title, options.message, opts);
285
+ if (result.success) {
286
+ console.log(chalk.green("Review notification sent!"));
287
+ if (result.promptId) {
288
+ console.log(chalk.gray(`Prompt ID: ${result.promptId}`));
289
+ }
290
+ } else {
291
+ console.log(chalk.red(`Failed: ${result.error}`));
292
+ }
293
+ }
294
+ );
295
+ cmd.command("ask <question>").description("Send a yes/no prompt").option("-t, --title <title>", "Message title", "StackMemory").action(async (question, options) => {
296
+ console.log(chalk.blue("Sending yes/no prompt..."));
297
+ const result = await notifyWithYesNo(options.title, question);
298
+ if (result.success) {
299
+ console.log(chalk.green("Prompt sent!"));
300
+ if (result.promptId) {
301
+ console.log(chalk.gray(`Prompt ID: ${result.promptId}`));
302
+ }
303
+ } else {
304
+ console.log(chalk.red(`Failed: ${result.error}`));
305
+ }
306
+ });
307
+ cmd.command("complete <task>").description("Send task completion notification").option("-s, --summary <text>", "Task summary", "").action(async (task, options) => {
308
+ const result = await notifyTaskComplete(
309
+ task,
310
+ options.summary || `Task "${task}" has been completed.`
311
+ );
312
+ if (result.success) {
313
+ console.log(chalk.green("Completion notification sent!"));
314
+ } else {
315
+ console.log(chalk.red(`Failed: ${result.error}`));
316
+ }
317
+ });
318
+ cmd.command("quiet").description("Configure quiet hours").option("--enable", "Enable quiet hours").option("--disable", "Disable quiet hours").option("--start <time>", "Start time (HH:MM)", "22:00").option("--end <time>", "End time (HH:MM)", "08:00").action(
319
+ (options) => {
320
+ const config = loadSMSConfig();
321
+ if (!config.quietHours) {
322
+ config.quietHours = { enabled: false, start: "22:00", end: "08:00" };
323
+ }
324
+ if (options.enable) {
325
+ config.quietHours.enabled = true;
326
+ } else if (options.disable) {
327
+ config.quietHours.enabled = false;
328
+ }
329
+ if (options.start) {
330
+ config.quietHours.start = options.start;
331
+ }
332
+ if (options.end) {
333
+ config.quietHours.end = options.end;
334
+ }
335
+ saveSMSConfig(config);
336
+ if (config.quietHours.enabled) {
337
+ console.log(
338
+ chalk.green(
339
+ `Quiet hours enabled: ${config.quietHours.start} - ${config.quietHours.end}`
340
+ )
341
+ );
342
+ } else {
343
+ console.log(chalk.yellow("Quiet hours disabled"));
344
+ }
345
+ }
346
+ );
347
+ cmd.command("toggle <type>").description(
348
+ "Toggle notification type (taskComplete|reviewReady|error|custom)"
349
+ ).action((type) => {
350
+ const config = loadSMSConfig();
351
+ const validTypes = ["taskComplete", "reviewReady", "error", "custom"];
352
+ if (!validTypes.includes(type)) {
353
+ console.log(chalk.red(`Invalid type. Use: ${validTypes.join(", ")}`));
354
+ return;
355
+ }
356
+ const key = type;
357
+ config.notifyOn[key] = !config.notifyOn[key];
358
+ saveSMSConfig(config);
359
+ console.log(
360
+ chalk.green(
361
+ `${type} notifications ${config.notifyOn[key] ? "enabled" : "disabled"}`
362
+ )
363
+ );
364
+ });
365
+ cmd.command("check").description(
366
+ "Check for new SMS/WhatsApp responses (use in Claude sessions)"
367
+ ).action(() => {
368
+ const responsePath = join(
369
+ process.env["HOME"] || "~",
370
+ ".stackmemory",
371
+ "sms-latest-response.json"
372
+ );
373
+ try {
374
+ if (existsSync(responsePath)) {
375
+ const data = JSON.parse(readFileSync(responsePath, "utf8"));
376
+ const age = Date.now() - new Date(data.timestamp).getTime();
377
+ if (age < 5 * 60 * 1e3) {
378
+ console.log(chalk.green.bold("\n*** NEW SMS RESPONSE ***"));
379
+ console.log(` Response: "${data.response}"`);
380
+ console.log(` Prompt ID: ${data.promptId}`);
381
+ console.log(` Received: ${Math.round(age / 1e3)}s ago
382
+ `);
383
+ unlinkSync(responsePath);
384
+ return;
385
+ }
386
+ }
387
+ } catch {
388
+ }
389
+ console.log(chalk.gray("No new responses"));
390
+ });
391
+ cmd.command("pending").description("List pending prompts awaiting response").action(() => {
392
+ const config = loadSMSConfig();
393
+ if (config.pendingPrompts.length === 0) {
394
+ console.log(chalk.gray("No pending prompts"));
395
+ return;
396
+ }
397
+ console.log(chalk.blue("Pending Prompts:"));
398
+ config.pendingPrompts.forEach((p) => {
399
+ const expires = new Date(p.expiresAt);
400
+ const remaining = Math.round((expires.getTime() - Date.now()) / 1e3);
401
+ console.log();
402
+ console.log(` ${chalk.gray("ID:")} ${p.id}`);
403
+ console.log(` ${chalk.gray("Type:")} ${p.type}`);
404
+ console.log(
405
+ ` ${chalk.gray("Message:")} ${p.message.substring(0, 50)}...`
406
+ );
407
+ console.log(
408
+ ` ${chalk.gray("Expires:")} ${remaining > 0 ? `${remaining}s` : chalk.red("expired")}`
409
+ );
410
+ });
411
+ });
412
+ cmd.command("cleanup").description("Remove expired pending prompts").action(() => {
413
+ const removed = cleanupExpiredPrompts();
414
+ console.log(chalk.green(`Removed ${removed} expired prompt(s)`));
415
+ });
416
+ cmd.command("timeout <seconds>").description("Set response timeout for prompts").action((seconds) => {
417
+ const config = loadSMSConfig();
418
+ const timeout = parseInt(seconds, 10);
419
+ if (isNaN(timeout) || timeout < 30) {
420
+ console.log(chalk.red("Timeout must be at least 30 seconds"));
421
+ return;
422
+ }
423
+ config.responseTimeout = timeout;
424
+ saveSMSConfig(config);
425
+ console.log(chalk.green(`Response timeout set to ${timeout} seconds`));
426
+ });
427
+ cmd.command("actions").description("List queued actions from SMS responses").action(() => {
428
+ const queue = loadActionQueue();
429
+ if (queue.actions.length === 0) {
430
+ console.log(chalk.gray("No actions in queue"));
431
+ return;
432
+ }
433
+ console.log(chalk.blue("Action Queue:"));
434
+ queue.actions.forEach((a) => {
435
+ const statusColor = a.status === "completed" ? chalk.green : a.status === "failed" ? chalk.red : a.status === "running" ? chalk.yellow : chalk.gray;
436
+ console.log();
437
+ console.log(` ${chalk.gray("ID:")} ${a.id}`);
438
+ console.log(` ${chalk.gray("Status:")} ${statusColor(a.status)}`);
439
+ console.log(
440
+ ` ${chalk.gray("Action:")} ${a.action.substring(0, 60)}...`
441
+ );
442
+ console.log(` ${chalk.gray("Response:")} ${a.response}`);
443
+ if (a.error) {
444
+ console.log(` ${chalk.gray("Error:")} ${chalk.red(a.error)}`);
445
+ }
446
+ });
447
+ });
448
+ cmd.command("run-actions").description("Execute all pending actions from SMS responses").action(() => {
449
+ console.log(chalk.blue("Processing pending actions..."));
450
+ const result = processAllPendingActions();
451
+ console.log(
452
+ chalk.green(
453
+ `Processed ${result.processed} action(s): ${result.succeeded} succeeded, ${result.failed} failed`
454
+ )
455
+ );
456
+ });
457
+ cmd.command("watch").description("Watch for and execute SMS response actions").option("-i, --interval <ms>", "Check interval in milliseconds", "5000").action((options) => {
458
+ const interval = parseInt(options.interval, 10);
459
+ console.log(chalk.blue(`Watching for actions (interval: ${interval}ms)`));
460
+ console.log(chalk.gray("Press Ctrl+C to stop"));
461
+ startActionWatcher(interval);
462
+ });
463
+ cmd.command("cleanup-actions").description("Remove old completed actions").action(() => {
464
+ const removed = cleanupOldActions();
465
+ console.log(chalk.green(`Removed ${removed} old action(s)`));
466
+ });
467
+ cmd.command("watch-responses").description("Watch for incoming SMS/WhatsApp responses and notify").option("-i, --interval <ms>", "Check interval in milliseconds", "2000").action(async (options) => {
468
+ const { startResponseWatcher } = await import("../../hooks/sms-watcher.js");
469
+ const interval = parseInt(options.interval, 10);
470
+ startResponseWatcher(interval);
471
+ });
472
+ cmd.command("install-hook").description("Install Claude Code notification hook").action(() => {
473
+ try {
474
+ const scriptPath = join(
475
+ __dirname,
476
+ "../../../scripts/install-notify-hook.sh"
477
+ );
478
+ execSync(`bash "${scriptPath}"`, { stdio: "inherit" });
479
+ } catch {
480
+ console.error(chalk.red("Failed to install hook"));
481
+ }
482
+ });
483
+ cmd.command("install-response-hook").description("Install Claude Code response handler hook").action(() => {
484
+ try {
485
+ const hooksDir = join(process.env["HOME"] || "~", ".claude", "hooks");
486
+ const hookSrc = join(
487
+ __dirname,
488
+ "../../../templates/claude-hooks/sms-response-handler.js"
489
+ );
490
+ const hookDest = join(hooksDir, "sms-response-handler.js");
491
+ execSync(`mkdir -p "${hooksDir}"`, { stdio: "inherit" });
492
+ execSync(`cp "${hookSrc}" "${hookDest}"`, { stdio: "inherit" });
493
+ execSync(`chmod +x "${hookDest}"`, { stdio: "inherit" });
494
+ console.log(chalk.green("Response handler hook installed!"));
495
+ console.log(chalk.gray(`Location: ${hookDest}`));
496
+ console.log();
497
+ console.log(chalk.blue("Add to ~/.claude/settings.json:"));
498
+ console.log(
499
+ chalk.gray(` "hooks": { "pre_tool_use": ["node ${hookDest}"] }`)
500
+ );
501
+ } catch {
502
+ console.error(chalk.red("Failed to install response hook"));
503
+ }
504
+ });
505
+ cmd.command("webhook").description("Start SMS webhook server for receiving responses").option("-p, --port <port>", "Port to listen on", "3456").action(async (options) => {
506
+ const { startWebhookServer } = await import("../../hooks/sms-webhook.js");
507
+ const port = parseInt(options.port, 10);
508
+ startWebhookServer(port);
509
+ });
510
+ cmd.command("sync").description("Push current context to WhatsApp").option("--frame <id>", "Sync specific frame by ID").option("--auto", "Enable auto-sync on frame close").option("--no-auto", "Disable auto-sync").action(async (options) => {
511
+ if (options.auto === true) {
512
+ enableAutoSync();
513
+ console.log(chalk.green("Auto-sync enabled"));
514
+ return;
515
+ }
516
+ if (options.auto === false) {
517
+ disableAutoSync();
518
+ console.log(chalk.yellow("Auto-sync disabled"));
519
+ return;
520
+ }
521
+ console.log(chalk.blue("Syncing context..."));
522
+ const result = options.frame ? await syncFrame(options.frame) : await syncContext();
523
+ if (result.success) {
524
+ console.log(
525
+ chalk.green(
526
+ `Context synced via ${result.channel} (${result.digestLength} chars)`
527
+ )
528
+ );
529
+ } else {
530
+ console.log(chalk.red(`Sync failed: ${result.error}`));
531
+ }
532
+ });
533
+ cmd.command("sync-status").description("Show sync configuration status").action(() => {
534
+ const options = loadSyncOptions();
535
+ const autoEnabled = isAutoSyncEnabled();
536
+ console.log(chalk.blue("Sync Configuration:"));
537
+ console.log();
538
+ console.log(
539
+ ` ${chalk.gray("Auto-sync on close:")} ${autoEnabled ? chalk.green("enabled") : chalk.yellow("disabled")}`
540
+ );
541
+ console.log(
542
+ ` ${chalk.gray("Min frame duration:")} ${options.minFrameDuration}s`
543
+ );
544
+ console.log(
545
+ ` ${chalk.gray("Max digest length:")} ${options.maxDigestLength} chars`
546
+ );
547
+ console.log(
548
+ ` ${chalk.gray("Include decisions:")} ${options.includeDecisions ? "yes" : "no"}`
549
+ );
550
+ console.log(
551
+ ` ${chalk.gray("Include files:")} ${options.includeFiles ? "yes" : "no"}`
552
+ );
553
+ console.log(
554
+ ` ${chalk.gray("Include tests:")} ${options.includeTests ? "yes" : "no"}`
555
+ );
556
+ });
557
+ cmd.command("schedule").description("Manage scheduled digests").argument("[action]", "Action: daily, hourly, interval, list, cancel, run").argument(
558
+ "[value]",
559
+ "Time (HH:MM) for daily, minutes for interval, or schedule ID"
560
+ ).action(async (action, value) => {
561
+ if (!action || action === "list") {
562
+ const schedules = listSchedules();
563
+ if (schedules.length === 0) {
564
+ console.log(chalk.gray("No scheduled digests"));
565
+ return;
566
+ }
567
+ console.log(chalk.blue("Scheduled Digests:"));
568
+ schedules.forEach((s) => {
569
+ const status = s.enabled ? chalk.green("active") : chalk.yellow("paused");
570
+ const nextRun = s.nextRun ? new Date(s.nextRun).toLocaleString() : "N/A";
571
+ console.log();
572
+ console.log(` ${chalk.gray("ID:")} ${s.id}`);
573
+ console.log(` ${chalk.gray("Type:")} ${s.config.type}`);
574
+ console.log(` ${chalk.gray("Status:")} ${status}`);
575
+ console.log(` ${chalk.gray("Next run:")} ${nextRun}`);
576
+ if (s.lastRun) {
577
+ console.log(
578
+ ` ${chalk.gray("Last run:")} ${new Date(s.lastRun).toLocaleString()}`
579
+ );
580
+ }
581
+ });
582
+ return;
583
+ }
584
+ switch (action) {
585
+ case "daily": {
586
+ const time = value || "09:00";
587
+ try {
588
+ const id = scheduleDailyDigest(time);
589
+ console.log(chalk.green(`Daily digest scheduled at ${time}`));
590
+ console.log(chalk.gray(`Schedule ID: ${id}`));
591
+ } catch (err) {
592
+ console.log(
593
+ chalk.red(
594
+ `Error: ${err instanceof Error ? err.message : String(err)}`
595
+ )
596
+ );
597
+ }
598
+ break;
599
+ }
600
+ case "hourly": {
601
+ const id = scheduleHourlyDigest();
602
+ console.log(chalk.green("Hourly digest scheduled"));
603
+ console.log(chalk.gray(`Schedule ID: ${id}`));
604
+ break;
605
+ }
606
+ case "interval": {
607
+ const minutes = parseInt(value || "60", 10);
608
+ if (isNaN(minutes) || minutes < 5) {
609
+ console.log(chalk.red("Interval must be at least 5 minutes"));
610
+ return;
611
+ }
612
+ try {
613
+ const id = scheduleIntervalDigest(minutes);
614
+ console.log(
615
+ chalk.green(`Digest scheduled every ${minutes} minutes`)
616
+ );
617
+ console.log(chalk.gray(`Schedule ID: ${id}`));
618
+ } catch (err) {
619
+ console.log(
620
+ chalk.red(
621
+ `Error: ${err instanceof Error ? err.message : String(err)}`
622
+ )
623
+ );
624
+ }
625
+ break;
626
+ }
627
+ case "cancel": {
628
+ if (!value) {
629
+ console.log(chalk.red("Schedule ID required"));
630
+ return;
631
+ }
632
+ const cancelled = cancelSchedule(value);
633
+ if (cancelled) {
634
+ console.log(chalk.green(`Schedule ${value} cancelled`));
635
+ } else {
636
+ console.log(chalk.red(`Schedule not found: ${value}`));
637
+ }
638
+ break;
639
+ }
640
+ case "run": {
641
+ if (!value) {
642
+ console.log(chalk.red("Schedule ID required"));
643
+ return;
644
+ }
645
+ console.log(chalk.blue(`Running schedule ${value}...`));
646
+ const result = await runScheduledDigest(value);
647
+ if (result.success) {
648
+ if (result.sent) {
649
+ console.log(chalk.green(result.message));
650
+ } else {
651
+ console.log(chalk.yellow(result.message));
652
+ }
653
+ } else {
654
+ console.log(chalk.red(`Error: ${result.error}`));
655
+ }
656
+ break;
657
+ }
658
+ case "start": {
659
+ if (isSchedulerRunning()) {
660
+ console.log(chalk.yellow("Scheduler already running"));
661
+ } else {
662
+ startScheduler();
663
+ console.log(chalk.green("Scheduler started"));
664
+ }
665
+ break;
666
+ }
667
+ case "stop": {
668
+ if (!isSchedulerRunning()) {
669
+ console.log(chalk.yellow("Scheduler not running"));
670
+ } else {
671
+ stopScheduler();
672
+ console.log(chalk.green("Scheduler stopped"));
673
+ }
674
+ break;
675
+ }
676
+ default:
677
+ console.log(chalk.red(`Unknown action: ${action}`));
678
+ console.log(
679
+ chalk.gray(
680
+ "Available: daily, hourly, interval, list, cancel, run, start, stop"
681
+ )
682
+ );
683
+ }
684
+ });
685
+ cmd.command("commands").description("Manage inbound WhatsApp command processing").option("--enable", "Enable command processing").option("--disable", "Disable command processing").action((options) => {
686
+ if (options.enable) {
687
+ enableCommands();
688
+ console.log(chalk.green("Command processing enabled"));
689
+ return;
690
+ }
691
+ if (options.disable) {
692
+ disableCommands();
693
+ console.log(chalk.yellow("Command processing disabled"));
694
+ return;
695
+ }
696
+ const config = loadCommandsConfig();
697
+ const commands = getAvailableCommands();
698
+ console.log(chalk.blue("WhatsApp Commands:"));
699
+ console.log();
700
+ console.log(
701
+ ` ${chalk.gray("Processing:")} ${config.enabled ? chalk.green("enabled") : chalk.yellow("disabled")}`
702
+ );
703
+ console.log();
704
+ console.log(chalk.gray("Available commands:"));
705
+ commands.forEach((cmd2) => {
706
+ const argHint = cmd2.requiresArg ? " <arg>" : "";
707
+ console.log(` ${chalk.cyan(cmd2.name)}${argHint} - ${cmd2.description}`);
708
+ });
709
+ console.log();
710
+ console.log(chalk.gray("Users can send these as WhatsApp messages"));
711
+ });
712
+ cmd.command("install-whatsapp-hook").description("Install WhatsApp integration hook for Claude Code").action(async () => {
713
+ const {
714
+ writeFileSync,
715
+ mkdirSync,
716
+ existsSync: fsExists
717
+ } = await import("fs");
718
+ const { join: pathJoin } = await import("path");
719
+ const homeDir = process.env["HOME"] || "~";
720
+ const claudeDir = pathJoin(homeDir, ".claude");
721
+ const settingsPath = pathJoin(claudeDir, "settings.json");
722
+ const hookPath = pathJoin(
723
+ __dirname,
724
+ "../hooks/claude-code-whatsapp-hook.js"
725
+ );
726
+ console.log(chalk.blue("Installing WhatsApp hook for Claude Code..."));
727
+ if (!fsExists(claudeDir)) {
728
+ mkdirSync(claudeDir, { recursive: true });
729
+ }
730
+ let settings = {};
731
+ if (fsExists(settingsPath)) {
732
+ try {
733
+ settings = JSON.parse(readFileSync(settingsPath, "utf8"));
734
+ } catch {
735
+ }
736
+ }
737
+ const hooks = settings["hooks"] || {};
738
+ hooks["Stop"] = ["node", hookPath, "stop"];
739
+ settings["hooks"] = hooks;
740
+ console.log();
741
+ console.log(chalk.yellow("Add to ~/.claude/settings.json:"));
742
+ console.log(chalk.gray(JSON.stringify({ hooks }, null, 2)));
743
+ console.log();
744
+ console.log(chalk.gray("Hook will:"));
745
+ console.log(
746
+ chalk.gray(" - Send session digest to WhatsApp when Claude exits")
747
+ );
748
+ console.log(
749
+ chalk.gray(" - Check for incoming WhatsApp messages during session")
750
+ );
751
+ console.log();
752
+ console.log(
753
+ chalk.green("Manual setup required - copy the hooks config above")
754
+ );
755
+ });
756
+ cmd.command("fallback-status").description("Show auto-fallback status for Claude -> Qwen").action(async () => {
757
+ const { getFallbackStatus } = await import("../../core/models/model-router.js");
758
+ const status = getFallbackStatus();
759
+ console.log(chalk.blue("Auto-Fallback Status:"));
760
+ console.log();
761
+ console.log(
762
+ ` ${chalk.gray("Enabled:")} ${status.enabled ? chalk.green("yes") : chalk.yellow("no")}`
763
+ );
764
+ console.log(
765
+ ` ${chalk.gray("Fallback provider:")} ${status.provider || "none"}`
766
+ );
767
+ console.log(
768
+ ` ${chalk.gray("API key ready:")} ${status.hasApiKey ? chalk.green("yes") : chalk.red("no")}`
769
+ );
770
+ console.log(
771
+ ` ${chalk.gray("Currently in fallback:")} ${status.inFallback ? chalk.yellow("YES") : "no"}`
772
+ );
773
+ if (status.reason) {
774
+ console.log(` ${chalk.gray("Fallback reason:")} ${status.reason}`);
775
+ }
776
+ console.log();
777
+ console.log(
778
+ chalk.gray(
779
+ "When Claude fails (rate limit, errors), Qwen takes over automatically."
780
+ )
781
+ );
782
+ console.log(
783
+ chalk.gray("Configure with: stackmemory model fallback --enable")
784
+ );
785
+ });
786
+ return cmd;
787
+ }
788
+ function maskPhone(phone) {
789
+ if (phone.length < 8) return phone;
790
+ return phone.substring(0, 4) + "****" + phone.substring(phone.length - 2);
791
+ }
792
+ export {
793
+ createSMSNotifyCommand
794
+ };
795
+ //# sourceMappingURL=sms-notify.js.map