@jungjaehoon/mama-os 0.1.1

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 (356) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +643 -0
  3. package/dist/agent/agent-loop.d.ts +98 -0
  4. package/dist/agent/agent-loop.d.ts.map +1 -0
  5. package/dist/agent/agent-loop.js +417 -0
  6. package/dist/agent/agent-loop.js.map +1 -0
  7. package/dist/agent/auto-recall.d.ts +48 -0
  8. package/dist/agent/auto-recall.d.ts.map +1 -0
  9. package/dist/agent/auto-recall.js +178 -0
  10. package/dist/agent/auto-recall.js.map +1 -0
  11. package/dist/agent/claude-cli-wrapper.d.ts +130 -0
  12. package/dist/agent/claude-cli-wrapper.d.ts.map +1 -0
  13. package/dist/agent/claude-cli-wrapper.js +227 -0
  14. package/dist/agent/claude-cli-wrapper.js.map +1 -0
  15. package/dist/agent/claude-client.d.ts +50 -0
  16. package/dist/agent/claude-client.d.ts.map +1 -0
  17. package/dist/agent/claude-client.js +214 -0
  18. package/dist/agent/claude-client.js.map +1 -0
  19. package/dist/agent/gateway-tool-executor.d.ts +75 -0
  20. package/dist/agent/gateway-tool-executor.d.ts.map +1 -0
  21. package/dist/agent/gateway-tool-executor.js +348 -0
  22. package/dist/agent/gateway-tool-executor.js.map +1 -0
  23. package/dist/agent/index.d.ts +13 -0
  24. package/dist/agent/index.d.ts.map +1 -0
  25. package/dist/agent/index.js +18 -0
  26. package/dist/agent/index.js.map +1 -0
  27. package/dist/agent/mcp-executor.d.ts +75 -0
  28. package/dist/agent/mcp-executor.d.ts.map +1 -0
  29. package/dist/agent/mcp-executor.js +307 -0
  30. package/dist/agent/mcp-executor.js.map +1 -0
  31. package/dist/agent/session-pool.d.ts +148 -0
  32. package/dist/agent/session-pool.d.ts.map +1 -0
  33. package/dist/agent/session-pool.js +272 -0
  34. package/dist/agent/session-pool.js.map +1 -0
  35. package/dist/agent/streaming-callback-manager.d.ts +85 -0
  36. package/dist/agent/streaming-callback-manager.d.ts.map +1 -0
  37. package/dist/agent/streaming-callback-manager.js +103 -0
  38. package/dist/agent/streaming-callback-manager.js.map +1 -0
  39. package/dist/agent/types.d.ts +437 -0
  40. package/dist/agent/types.d.ts.map +1 -0
  41. package/dist/agent/types.js +29 -0
  42. package/dist/agent/types.js.map +1 -0
  43. package/dist/api/cron-handler.d.ts +44 -0
  44. package/dist/api/cron-handler.d.ts.map +1 -0
  45. package/dist/api/cron-handler.js +195 -0
  46. package/dist/api/cron-handler.js.map +1 -0
  47. package/dist/api/error-handler.d.ts +22 -0
  48. package/dist/api/error-handler.d.ts.map +1 -0
  49. package/dist/api/error-handler.js +104 -0
  50. package/dist/api/error-handler.js.map +1 -0
  51. package/dist/api/heartbeat-handler.d.ts +49 -0
  52. package/dist/api/heartbeat-handler.d.ts.map +1 -0
  53. package/dist/api/heartbeat-handler.js +91 -0
  54. package/dist/api/heartbeat-handler.js.map +1 -0
  55. package/dist/api/index.d.ts +61 -0
  56. package/dist/api/index.d.ts.map +1 -0
  57. package/dist/api/index.js +145 -0
  58. package/dist/api/index.js.map +1 -0
  59. package/dist/api/types.d.ts +156 -0
  60. package/dist/api/types.d.ts.map +1 -0
  61. package/dist/api/types.js +62 -0
  62. package/dist/api/types.js.map +1 -0
  63. package/dist/auth/index.d.ts +7 -0
  64. package/dist/auth/index.d.ts.map +1 -0
  65. package/dist/auth/index.js +11 -0
  66. package/dist/auth/index.js.map +1 -0
  67. package/dist/auth/oauth-manager.d.ts +59 -0
  68. package/dist/auth/oauth-manager.d.ts.map +1 -0
  69. package/dist/auth/oauth-manager.js +237 -0
  70. package/dist/auth/oauth-manager.js.map +1 -0
  71. package/dist/auth/types.d.ts +92 -0
  72. package/dist/auth/types.d.ts.map +1 -0
  73. package/dist/auth/types.js +23 -0
  74. package/dist/auth/types.js.map +1 -0
  75. package/dist/cli/commands/init.d.ts +19 -0
  76. package/dist/cli/commands/init.d.ts.map +1 -0
  77. package/dist/cli/commands/init.js +155 -0
  78. package/dist/cli/commands/init.js.map +1 -0
  79. package/dist/cli/commands/run.d.ts +19 -0
  80. package/dist/cli/commands/run.d.ts.map +1 -0
  81. package/dist/cli/commands/run.js +89 -0
  82. package/dist/cli/commands/run.js.map +1 -0
  83. package/dist/cli/commands/setup.d.ts +19 -0
  84. package/dist/cli/commands/setup.d.ts.map +1 -0
  85. package/dist/cli/commands/setup.js +134 -0
  86. package/dist/cli/commands/setup.js.map +1 -0
  87. package/dist/cli/commands/start.d.ts +24 -0
  88. package/dist/cli/commands/start.d.ts.map +1 -0
  89. package/dist/cli/commands/start.js +1073 -0
  90. package/dist/cli/commands/start.js.map +1 -0
  91. package/dist/cli/commands/status.d.ts +10 -0
  92. package/dist/cli/commands/status.d.ts.map +1 -0
  93. package/dist/cli/commands/status.js +85 -0
  94. package/dist/cli/commands/status.js.map +1 -0
  95. package/dist/cli/commands/stop.d.ts +10 -0
  96. package/dist/cli/commands/stop.d.ts.map +1 -0
  97. package/dist/cli/commands/stop.js +65 -0
  98. package/dist/cli/commands/stop.js.map +1 -0
  99. package/dist/cli/config/config-manager.d.ts +51 -0
  100. package/dist/cli/config/config-manager.d.ts.map +1 -0
  101. package/dist/cli/config/config-manager.js +216 -0
  102. package/dist/cli/config/config-manager.js.map +1 -0
  103. package/dist/cli/config/types.d.ts +172 -0
  104. package/dist/cli/config/types.d.ts.map +1 -0
  105. package/dist/cli/config/types.js +48 -0
  106. package/dist/cli/config/types.js.map +1 -0
  107. package/dist/cli/index.d.ts +8 -0
  108. package/dist/cli/index.d.ts.map +1 -0
  109. package/dist/cli/index.js +92 -0
  110. package/dist/cli/index.js.map +1 -0
  111. package/dist/cli/utils/pid-manager.d.ts +66 -0
  112. package/dist/cli/utils/pid-manager.d.ts.map +1 -0
  113. package/dist/cli/utils/pid-manager.js +167 -0
  114. package/dist/cli/utils/pid-manager.js.map +1 -0
  115. package/dist/concurrency/index.d.ts +13 -0
  116. package/dist/concurrency/index.d.ts.map +1 -0
  117. package/dist/concurrency/index.js +22 -0
  118. package/dist/concurrency/index.js.map +1 -0
  119. package/dist/concurrency/lane-manager.d.ts +113 -0
  120. package/dist/concurrency/lane-manager.d.ts.map +1 -0
  121. package/dist/concurrency/lane-manager.js +245 -0
  122. package/dist/concurrency/lane-manager.js.map +1 -0
  123. package/dist/concurrency/session-key.d.ts +41 -0
  124. package/dist/concurrency/session-key.d.ts.map +1 -0
  125. package/dist/concurrency/session-key.js +61 -0
  126. package/dist/concurrency/session-key.js.map +1 -0
  127. package/dist/concurrency/types.d.ts +69 -0
  128. package/dist/concurrency/types.d.ts.map +1 -0
  129. package/dist/concurrency/types.js +16 -0
  130. package/dist/concurrency/types.js.map +1 -0
  131. package/dist/gateways/channel-history.d.ts +102 -0
  132. package/dist/gateways/channel-history.d.ts.map +1 -0
  133. package/dist/gateways/channel-history.js +181 -0
  134. package/dist/gateways/channel-history.js.map +1 -0
  135. package/dist/gateways/context-injector.d.ts +74 -0
  136. package/dist/gateways/context-injector.d.ts.map +1 -0
  137. package/dist/gateways/context-injector.js +121 -0
  138. package/dist/gateways/context-injector.js.map +1 -0
  139. package/dist/gateways/discord.d.ts +122 -0
  140. package/dist/gateways/discord.d.ts.map +1 -0
  141. package/dist/gateways/discord.js +602 -0
  142. package/dist/gateways/discord.js.map +1 -0
  143. package/dist/gateways/index.d.ts +30 -0
  144. package/dist/gateways/index.d.ts.map +1 -0
  145. package/dist/gateways/index.js +49 -0
  146. package/dist/gateways/index.js.map +1 -0
  147. package/dist/gateways/message-router.d.ts +116 -0
  148. package/dist/gateways/message-router.d.ts.map +1 -0
  149. package/dist/gateways/message-router.js +315 -0
  150. package/dist/gateways/message-router.js.map +1 -0
  151. package/dist/gateways/message-splitter.d.ts +54 -0
  152. package/dist/gateways/message-splitter.d.ts.map +1 -0
  153. package/dist/gateways/message-splitter.js +146 -0
  154. package/dist/gateways/message-splitter.js.map +1 -0
  155. package/dist/gateways/plugin-loader.d.ts +76 -0
  156. package/dist/gateways/plugin-loader.d.ts.map +1 -0
  157. package/dist/gateways/plugin-loader.js +221 -0
  158. package/dist/gateways/plugin-loader.js.map +1 -0
  159. package/dist/gateways/session-store.d.ts +77 -0
  160. package/dist/gateways/session-store.d.ts.map +1 -0
  161. package/dist/gateways/session-store.js +233 -0
  162. package/dist/gateways/session-store.js.map +1 -0
  163. package/dist/gateways/slack.d.ts +90 -0
  164. package/dist/gateways/slack.d.ts.map +1 -0
  165. package/dist/gateways/slack.js +281 -0
  166. package/dist/gateways/slack.js.map +1 -0
  167. package/dist/gateways/telegram.d.ts +79 -0
  168. package/dist/gateways/telegram.d.ts.map +1 -0
  169. package/dist/gateways/telegram.js +207 -0
  170. package/dist/gateways/telegram.js.map +1 -0
  171. package/dist/gateways/types.d.ts +340 -0
  172. package/dist/gateways/types.d.ts.map +1 -0
  173. package/dist/gateways/types.js +6 -0
  174. package/dist/gateways/types.js.map +1 -0
  175. package/dist/index.d.ts +7 -0
  176. package/dist/index.d.ts.map +1 -0
  177. package/dist/index.js +26 -0
  178. package/dist/index.js.map +1 -0
  179. package/dist/memory/memory-logger.d.ts +47 -0
  180. package/dist/memory/memory-logger.d.ts.map +1 -0
  181. package/dist/memory/memory-logger.js +126 -0
  182. package/dist/memory/memory-logger.js.map +1 -0
  183. package/dist/onboarding/all-tools.d.ts +18 -0
  184. package/dist/onboarding/all-tools.d.ts.map +1 -0
  185. package/dist/onboarding/all-tools.js +149 -0
  186. package/dist/onboarding/all-tools.js.map +1 -0
  187. package/dist/onboarding/autonomous-discovery-tools.d.ts +13 -0
  188. package/dist/onboarding/autonomous-discovery-tools.d.ts.map +1 -0
  189. package/dist/onboarding/autonomous-discovery-tools.js +268 -0
  190. package/dist/onboarding/autonomous-discovery-tools.js.map +1 -0
  191. package/dist/onboarding/bootstrap-template.d.ts +5 -0
  192. package/dist/onboarding/bootstrap-template.d.ts.map +1 -0
  193. package/dist/onboarding/bootstrap-template.js +142 -0
  194. package/dist/onboarding/bootstrap-template.js.map +1 -0
  195. package/dist/onboarding/complete-autonomous-prompt.d.ts +13 -0
  196. package/dist/onboarding/complete-autonomous-prompt.d.ts.map +1 -0
  197. package/dist/onboarding/complete-autonomous-prompt.js +1220 -0
  198. package/dist/onboarding/complete-autonomous-prompt.js.map +1 -0
  199. package/dist/onboarding/onboarding-state.d.ts +70 -0
  200. package/dist/onboarding/onboarding-state.d.ts.map +1 -0
  201. package/dist/onboarding/onboarding-state.js +184 -0
  202. package/dist/onboarding/onboarding-state.js.map +1 -0
  203. package/dist/onboarding/personality-quiz.d.ts +35 -0
  204. package/dist/onboarding/personality-quiz.d.ts.map +1 -0
  205. package/dist/onboarding/personality-quiz.js +219 -0
  206. package/dist/onboarding/personality-quiz.js.map +1 -0
  207. package/dist/onboarding/phase-5-summary.d.ts +22 -0
  208. package/dist/onboarding/phase-5-summary.d.ts.map +1 -0
  209. package/dist/onboarding/phase-5-summary.js +151 -0
  210. package/dist/onboarding/phase-5-summary.js.map +1 -0
  211. package/dist/onboarding/phase-6-security.d.ts +33 -0
  212. package/dist/onboarding/phase-6-security.d.ts.map +1 -0
  213. package/dist/onboarding/phase-6-security.js +473 -0
  214. package/dist/onboarding/phase-6-security.js.map +1 -0
  215. package/dist/onboarding/phase-7-integrations.d.ts +66 -0
  216. package/dist/onboarding/phase-7-integrations.d.ts.map +1 -0
  217. package/dist/onboarding/phase-7-integrations.js +619 -0
  218. package/dist/onboarding/phase-7-integrations.js.map +1 -0
  219. package/dist/onboarding/phase-8-demo.d.ts +43 -0
  220. package/dist/onboarding/phase-8-demo.d.ts.map +1 -0
  221. package/dist/onboarding/phase-8-demo.js +346 -0
  222. package/dist/onboarding/phase-8-demo.js.map +1 -0
  223. package/dist/onboarding/phase-9-finalization.d.ts +22 -0
  224. package/dist/onboarding/phase-9-finalization.d.ts.map +1 -0
  225. package/dist/onboarding/phase-9-finalization.js +375 -0
  226. package/dist/onboarding/phase-9-finalization.js.map +1 -0
  227. package/dist/onboarding/ritual-prompt.d.ts +2 -0
  228. package/dist/onboarding/ritual-prompt.d.ts.map +1 -0
  229. package/dist/onboarding/ritual-prompt.js +285 -0
  230. package/dist/onboarding/ritual-prompt.js.map +1 -0
  231. package/dist/onboarding/ritual-tools.d.ts +13 -0
  232. package/dist/onboarding/ritual-tools.d.ts.map +1 -0
  233. package/dist/onboarding/ritual-tools.js +93 -0
  234. package/dist/onboarding/ritual-tools.js.map +1 -0
  235. package/dist/runners/cli-runner.d.ts +59 -0
  236. package/dist/runners/cli-runner.d.ts.map +1 -0
  237. package/dist/runners/cli-runner.js +190 -0
  238. package/dist/runners/cli-runner.js.map +1 -0
  239. package/dist/runners/index.d.ts +11 -0
  240. package/dist/runners/index.d.ts.map +1 -0
  241. package/dist/runners/index.js +15 -0
  242. package/dist/runners/index.js.map +1 -0
  243. package/dist/runners/types.d.ts +81 -0
  244. package/dist/runners/types.d.ts.map +1 -0
  245. package/dist/runners/types.js +31 -0
  246. package/dist/runners/types.js.map +1 -0
  247. package/dist/scheduler/cron-scheduler.d.ts +115 -0
  248. package/dist/scheduler/cron-scheduler.d.ts.map +1 -0
  249. package/dist/scheduler/cron-scheduler.js +320 -0
  250. package/dist/scheduler/cron-scheduler.js.map +1 -0
  251. package/dist/scheduler/heartbeat.d.ts +53 -0
  252. package/dist/scheduler/heartbeat.d.ts.map +1 -0
  253. package/dist/scheduler/heartbeat.js +160 -0
  254. package/dist/scheduler/heartbeat.js.map +1 -0
  255. package/dist/scheduler/index.d.ts +22 -0
  256. package/dist/scheduler/index.d.ts.map +1 -0
  257. package/dist/scheduler/index.js +31 -0
  258. package/dist/scheduler/index.js.map +1 -0
  259. package/dist/scheduler/job-lock.d.ts +85 -0
  260. package/dist/scheduler/job-lock.d.ts.map +1 -0
  261. package/dist/scheduler/job-lock.js +137 -0
  262. package/dist/scheduler/job-lock.js.map +1 -0
  263. package/dist/scheduler/recovery.d.ts +78 -0
  264. package/dist/scheduler/recovery.d.ts.map +1 -0
  265. package/dist/scheduler/recovery.js +124 -0
  266. package/dist/scheduler/recovery.js.map +1 -0
  267. package/dist/scheduler/schedule-store.d.ts +112 -0
  268. package/dist/scheduler/schedule-store.d.ts.map +1 -0
  269. package/dist/scheduler/schedule-store.js +259 -0
  270. package/dist/scheduler/schedule-store.js.map +1 -0
  271. package/dist/scheduler/token-keep-alive.d.ts +49 -0
  272. package/dist/scheduler/token-keep-alive.d.ts.map +1 -0
  273. package/dist/scheduler/token-keep-alive.js +102 -0
  274. package/dist/scheduler/token-keep-alive.js.map +1 -0
  275. package/dist/scheduler/types.d.ts +96 -0
  276. package/dist/scheduler/types.d.ts.map +1 -0
  277. package/dist/scheduler/types.js +21 -0
  278. package/dist/scheduler/types.js.map +1 -0
  279. package/dist/setup/setup-prompt.d.ts +2 -0
  280. package/dist/setup/setup-prompt.d.ts.map +1 -0
  281. package/dist/setup/setup-prompt.js +138 -0
  282. package/dist/setup/setup-prompt.js.map +1 -0
  283. package/dist/setup/setup-server.d.ts +8 -0
  284. package/dist/setup/setup-server.d.ts.map +1 -0
  285. package/dist/setup/setup-server.js +71 -0
  286. package/dist/setup/setup-server.js.map +1 -0
  287. package/dist/setup/setup-tools.d.ts +13 -0
  288. package/dist/setup/setup-tools.d.ts.map +1 -0
  289. package/dist/setup/setup-tools.js +103 -0
  290. package/dist/setup/setup-tools.js.map +1 -0
  291. package/dist/setup/setup-websocket.d.ts +6 -0
  292. package/dist/setup/setup-websocket.d.ts.map +1 -0
  293. package/dist/setup/setup-websocket.js +312 -0
  294. package/dist/setup/setup-websocket.js.map +1 -0
  295. package/dist/skills/index.d.ts +10 -0
  296. package/dist/skills/index.d.ts.map +1 -0
  297. package/dist/skills/index.js +26 -0
  298. package/dist/skills/index.js.map +1 -0
  299. package/dist/skills/skill-executor.d.ts +48 -0
  300. package/dist/skills/skill-executor.d.ts.map +1 -0
  301. package/dist/skills/skill-executor.js +483 -0
  302. package/dist/skills/skill-executor.js.map +1 -0
  303. package/dist/skills/skill-loader.d.ts +40 -0
  304. package/dist/skills/skill-loader.d.ts.map +1 -0
  305. package/dist/skills/skill-loader.js +225 -0
  306. package/dist/skills/skill-loader.js.map +1 -0
  307. package/dist/skills/skill-matcher.d.ts +33 -0
  308. package/dist/skills/skill-matcher.d.ts.map +1 -0
  309. package/dist/skills/skill-matcher.js +190 -0
  310. package/dist/skills/skill-matcher.js.map +1 -0
  311. package/dist/skills/types.d.ts +123 -0
  312. package/dist/skills/types.d.ts.map +1 -0
  313. package/dist/skills/types.js +12 -0
  314. package/dist/skills/types.js.map +1 -0
  315. package/dist/tools/browser-tool.d.ts +149 -0
  316. package/dist/tools/browser-tool.d.ts.map +1 -0
  317. package/dist/tools/browser-tool.js +257 -0
  318. package/dist/tools/browser-tool.js.map +1 -0
  319. package/package.json +84 -0
  320. package/public/favicon.ico +0 -0
  321. package/public/setup.html +1026 -0
  322. package/public/viewer/icons/icon-192.png +0 -0
  323. package/public/viewer/icons/icon-512.png +0 -0
  324. package/public/viewer/js/modules/chat.js +1587 -0
  325. package/public/viewer/js/modules/dashboard.js +275 -0
  326. package/public/viewer/js/modules/graph.js +997 -0
  327. package/public/viewer/js/modules/memory.js +353 -0
  328. package/public/viewer/js/modules/settings.js +255 -0
  329. package/public/viewer/js/utils/api.js +169 -0
  330. package/public/viewer/js/utils/dom.js +92 -0
  331. package/public/viewer/js/utils/format.js +192 -0
  332. package/public/viewer/manifest.json +26 -0
  333. package/public/viewer/sw.js +131 -0
  334. package/public/viewer/viewer.css +500 -0
  335. package/public/viewer/viewer.html +1535 -0
  336. package/scripts/postinstall.js +118 -0
  337. package/templates/skills/document-analyze.md +63 -0
  338. package/templates/skills/heartbeat-report.md +75 -0
  339. package/templates/skills/image-translate.md +67 -0
  340. package/templates/workspace/skill-forge/DESIGN.md +115 -0
  341. package/templates/workspace/skill-forge/agents/architect.ts +295 -0
  342. package/templates/workspace/skill-forge/agents/developer.ts +364 -0
  343. package/templates/workspace/skill-forge/agents/qa.ts +313 -0
  344. package/templates/workspace/skill-forge/claude-api.ts +353 -0
  345. package/templates/workspace/skill-forge/discord-ui.ts +580 -0
  346. package/templates/workspace/skill-forge/error-handler.ts +354 -0
  347. package/templates/workspace/skill-forge/mama-integration.ts +357 -0
  348. package/templates/workspace/skill-forge/orchestrator.ts +495 -0
  349. package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/README.md +24 -0
  350. package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/index.ts +79 -0
  351. package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/types.ts +17 -0
  352. package/templates/workspace/skill-forge/package.json +21 -0
  353. package/templates/workspace/skill-forge/state/session.json +132 -0
  354. package/templates/workspace/skill-forge/test-e2e.ts +139 -0
  355. package/templates/workspace/skill-forge/tsconfig.json +20 -0
  356. package/templates/workspace/skill-forge/types.ts +159 -0
@@ -0,0 +1,580 @@
1
+ /**
2
+ * Skill Forge - Discord UI
3
+ *
4
+ * 5초 카운트다운 + 버튼 인터페이스
5
+ * 실시간 메시지 업데이트 지원
6
+ */
7
+
8
+ import { SessionState, SessionPhase, ArchitectOutput, DeveloperOutput, QAOutput } from './types';
9
+
10
+ // ===== Discord Embed Types =====
11
+
12
+ export interface DiscordEmbed {
13
+ title?: string;
14
+ description?: string;
15
+ color?: number; // Decimal color
16
+ fields?: Array<{
17
+ name: string;
18
+ value: string;
19
+ inline?: boolean;
20
+ }>;
21
+ footer?: {
22
+ text: string;
23
+ icon_url?: string;
24
+ };
25
+ timestamp?: string;
26
+ }
27
+
28
+ // Colors
29
+ const COLORS = {
30
+ primary: 0x5865f2, // Discord blurple
31
+ success: 0x57f287, // Green
32
+ warning: 0xfee75c, // Yellow
33
+ danger: 0xed4245, // Red
34
+ architect: 0x3498db, // Blue
35
+ developer: 0x9b59b6, // Purple
36
+ qa: 0x2ecc71, // Emerald
37
+ };
38
+
39
+ // ===== Message Formatters =====
40
+
41
+ export interface DiscordMessage {
42
+ content: string;
43
+ embeds?: DiscordEmbed[];
44
+ components?: DiscordButton[][]; // 버튼 행들
45
+ }
46
+
47
+ export interface DiscordButton {
48
+ type: 'button';
49
+ label: string;
50
+ style: 'primary' | 'secondary' | 'success' | 'danger';
51
+ customId: string;
52
+ emoji?: string;
53
+ disabled?: boolean;
54
+ }
55
+
56
+ // ===== Real-time Update Manager =====
57
+
58
+ export interface MessageUpdateManager {
59
+ messageId: string | null;
60
+ channelId: string;
61
+ lastUpdate: number;
62
+
63
+ update(message: DiscordMessage): Promise<void>;
64
+ send(message: DiscordMessage): Promise<string>;
65
+ }
66
+
67
+ export function createMessageManager(channelId: string): MessageUpdateManager {
68
+ return {
69
+ messageId: null,
70
+ channelId,
71
+ lastUpdate: 0,
72
+
73
+ async update(message: DiscordMessage): Promise<void> {
74
+ // Discord API rate limit: ~5 updates/second
75
+ const now = Date.now();
76
+ if (now - this.lastUpdate < 200) {
77
+ return; // Skip if too fast
78
+ }
79
+ this.lastUpdate = now;
80
+
81
+ if (this.messageId) {
82
+ console.log(`[Discord] Update message ${this.messageId}`);
83
+ // Would call discord_edit here
84
+ }
85
+ },
86
+
87
+ async send(message: DiscordMessage): Promise<string> {
88
+ console.log(`[Discord] Send to ${this.channelId}`);
89
+ // Would call discord_send here
90
+ this.messageId = 'msg_' + Date.now();
91
+ return this.messageId;
92
+ },
93
+ };
94
+ }
95
+
96
+ // ===== Countdown UI =====
97
+
98
+ export function formatCountdownMessage(
99
+ phase: SessionPhase,
100
+ secondsRemaining: number,
101
+ artifacts: SessionState['artifacts']
102
+ ): DiscordMessage {
103
+ let content = '';
104
+
105
+ switch (phase) {
106
+ case 'architect_review':
107
+ content = formatArchitectReview(artifacts.architectOutput!, secondsRemaining);
108
+ break;
109
+ case 'developer_review':
110
+ content = formatDeveloperReview(artifacts.developerOutput!, secondsRemaining);
111
+ break;
112
+ case 'qa_review':
113
+ content = formatQAReview(artifacts.qaOutput!, secondsRemaining);
114
+ break;
115
+ default:
116
+ content = `⏳ 검토 중... (${secondsRemaining}초)`;
117
+ }
118
+
119
+ return {
120
+ content,
121
+ components: [getReviewButtons()],
122
+ };
123
+ }
124
+
125
+ function formatArchitectReview(output: ArchitectOutput, seconds: number): string {
126
+ const complexity = {
127
+ simple: '🟢 Simple',
128
+ medium: '🟡 Medium',
129
+ complex: '🔴 Complex',
130
+ }[output.estimatedComplexity];
131
+
132
+ const workflowSteps = output.workflow
133
+ .map((w) => ` ${w.step}. **${w.action}** - ${w.description}`)
134
+ .join('\n');
135
+
136
+ const files = output.fileStructure.map((f) => ` 📄 \`${f.path}\` - ${f.purpose}`).join('\n');
137
+
138
+ const tools = output.toolsRequired.map((t) => `\`${t}\``).join(', ');
139
+
140
+ return `## 🏗️ Architect 설계 완료
141
+
142
+ **스킬명:** \`${output.skillName}\`
143
+ **목적:** ${output.purpose}
144
+ **복잡도:** ${complexity}
145
+
146
+ ### 📋 워크플로우
147
+ ${workflowSteps}
148
+
149
+ ### 📁 파일 구조
150
+ ${files}
151
+
152
+ ### 🔧 필요 도구
153
+ ${tools}
154
+
155
+ ---
156
+ ⏳ **${seconds}초 후 자동 승인** (Developer 단계로 진행)
157
+
158
+ > 🔘 **Approve** - 이 설계로 진행
159
+ > 🔄 **Revise** - 다시 설계 요청
160
+ > ❌ **Cancel** - 작업 취소`;
161
+ }
162
+
163
+ function formatDeveloperReview(output: DeveloperOutput, seconds: number): string {
164
+ if (!output.files.length) {
165
+ return `## 💻 Developer 작업 완료
166
+
167
+ ⚠️ 아직 파일이 생성되지 않았습니다 (Phase 2에서 구현 예정)
168
+
169
+ ---
170
+ ⏳ **${seconds}초 후 자동 승인** (QA 단계로 진행)`;
171
+ }
172
+
173
+ const fileList = output.files.map((f) => ` 📄 \`${f.path}\` (${f.language})`).join('\n');
174
+
175
+ return `## 💻 Developer 작업 완료
176
+
177
+ ### 📁 생성된 파일
178
+ ${fileList}
179
+
180
+ ### 📦 설치 방법
181
+ ${output.installInstructions.map((i) => `\`\`\`bash\n${i}\n\`\`\``).join('\n') || '없음'}
182
+
183
+ ### 🧪 테스트 명령
184
+ ${output.testCommands.map((c) => `\`${c}\``).join(', ') || '없음'}
185
+
186
+ ---
187
+ ⏳ **${seconds}초 후 자동 승인** (QA 단계로 진행)`;
188
+ }
189
+
190
+ function formatQAReview(output: QAOutput, seconds: number): string {
191
+ const status = output.passed ? '✅ PASSED' : '❌ FAILED';
192
+ const recommendation = {
193
+ approve: '🟢 승인 권장',
194
+ revise: '🟡 수정 권장',
195
+ reject: '🔴 거부 권장',
196
+ }[output.recommendation];
197
+
198
+ const checklist = output.checklist.length
199
+ ? output.checklist
200
+ .map((c) => ` ${c.passed ? '✅' : '❌'} ${c.item}${c.note ? ` - ${c.note}` : ''}`)
201
+ .join('\n')
202
+ : ' (체크리스트 없음)';
203
+
204
+ const issues = output.issues.length
205
+ ? output.issues
206
+ .map((i) => {
207
+ const icon = { critical: '🔴', warning: '🟡', suggestion: '🔵' }[i.severity];
208
+ return ` ${icon} ${i.description}${i.location ? ` @ ${i.location}` : ''}`;
209
+ })
210
+ .join('\n')
211
+ : ' 없음';
212
+
213
+ return `## 🔍 QA 검증 완료
214
+
215
+ **상태:** ${status}
216
+ **권장:** ${recommendation}
217
+
218
+ ### ✅ 체크리스트
219
+ ${checklist}
220
+
221
+ ### ⚠️ 이슈
222
+ ${issues}
223
+
224
+ ---
225
+ ⏳ **${seconds}초 후 자동 완료**`;
226
+ }
227
+
228
+ // ===== Button Definitions =====
229
+
230
+ function getReviewButtons(seconds?: number): DiscordButton[] {
231
+ const isUrgent = seconds !== undefined && seconds <= 2;
232
+
233
+ return [
234
+ {
235
+ type: 'button',
236
+ label: 'Approve',
237
+ style: 'success',
238
+ customId: 'skill_forge_approve',
239
+ emoji: '✅',
240
+ },
241
+ {
242
+ type: 'button',
243
+ label: 'Revise',
244
+ style: 'primary',
245
+ customId: 'skill_forge_revise',
246
+ emoji: '🔄',
247
+ },
248
+ {
249
+ type: 'button',
250
+ label: isUrgent ? '⚡ Extend!' : 'Extend +5s',
251
+ style: isUrgent ? 'danger' : 'secondary',
252
+ customId: 'skill_forge_extend',
253
+ emoji: '⏰',
254
+ },
255
+ {
256
+ type: 'button',
257
+ label: 'Cancel',
258
+ style: 'danger',
259
+ customId: 'skill_forge_cancel',
260
+ emoji: '❌',
261
+ },
262
+ ];
263
+ }
264
+
265
+ // ===== Progress Messages =====
266
+
267
+ export function formatProgressMessage(phase: SessionPhase): string {
268
+ const messages: Record<SessionPhase, string> = {
269
+ idle: '⏸️ 대기 중...',
270
+ architect: '🏗️ **Architect**가 스킬 구조를 설계하고 있습니다...',
271
+ architect_review: '👀 **구조 검토 중** (카운트다운)',
272
+ developer: '💻 **Developer**가 코드를 작성하고 있습니다...',
273
+ developer_review: '👀 **코드 검토 중** (카운트다운)',
274
+ qa: '🔍 **QA**가 품질을 검증하고 있습니다...',
275
+ qa_review: '👀 **검증 결과 검토 중** (카운트다운)',
276
+ completed: '🎉 **스킬 생성 완료!**',
277
+ cancelled: '❌ **작업이 취소되었습니다**',
278
+ };
279
+
280
+ return messages[phase];
281
+ }
282
+
283
+ // ===== Completion Message =====
284
+
285
+ export function formatCompletionMessage(state: SessionState): string {
286
+ const { artifacts, request } = state;
287
+
288
+ if (!artifacts.architectOutput) {
289
+ return '❌ 스킬 생성 실패 - Architect 단계에서 오류 발생';
290
+ }
291
+
292
+ const output = artifacts.architectOutput;
293
+
294
+ return `## 🎉 스킬 생성 완료!
295
+
296
+ **스킬명:** \`${output.skillName}\`
297
+ **목적:** ${output.purpose}
298
+
299
+ ### 📋 요약
300
+ - **워크플로우 단계:** ${output.workflow.length}개
301
+ - **생성된 파일:** ${output.fileStructure.length}개
302
+ - **복잡도:** ${output.estimatedComplexity}
303
+
304
+ ### 🚀 다음 단계
305
+ 1. 생성된 파일을 확인하세요
306
+ 2. 필요시 코드를 수정하세요
307
+ 3. 테스트를 실행하세요
308
+
309
+ ---
310
+ > 💡 **Tip:** \`/forge ${request.name}\`으로 다시 생성할 수 있습니다`;
311
+ }
312
+
313
+ // ===== Error Message =====
314
+
315
+ export function formatErrorMessage(error: string): string {
316
+ return `## ❌ 오류 발생
317
+
318
+ \`\`\`
319
+ ${error}
320
+ \`\`\`
321
+
322
+ 다시 시도해 주세요. 문제가 지속되면 관리자에게 문의하세요.`;
323
+ }
324
+
325
+ // ===== Countdown Timer Display =====
326
+
327
+ export function getCountdownEmoji(seconds: number): string {
328
+ if (seconds > 3) return '🟢';
329
+ if (seconds > 1) return '🟡';
330
+ return '🔴';
331
+ }
332
+
333
+ export function formatCountdownLine(seconds: number): string {
334
+ const emoji = getCountdownEmoji(seconds);
335
+ const bar = '▓'.repeat(seconds) + '░'.repeat(5 - seconds);
336
+ return `${emoji} [${bar}] ${seconds}초`;
337
+ }
338
+
339
+ // ===== Rich Embed Formatters =====
340
+
341
+ export function formatArchitectEmbed(output: ArchitectOutput, seconds?: number): DiscordEmbed {
342
+ const complexity = {
343
+ simple: '🟢 Simple',
344
+ medium: '🟡 Medium',
345
+ complex: '🔴 Complex',
346
+ }[output.estimatedComplexity];
347
+
348
+ const fields = [
349
+ {
350
+ name: '📋 워크플로우',
351
+ value: output.workflow.map((w) => `\`${w.step}.\` ${w.action}`).join('\n') || 'N/A',
352
+ inline: true,
353
+ },
354
+ {
355
+ name: '📁 파일 구조',
356
+ value: output.fileStructure.map((f) => `\`${f.path}\``).join('\n') || 'N/A',
357
+ inline: true,
358
+ },
359
+ {
360
+ name: '🔧 도구',
361
+ value: output.toolsRequired.map((t) => `\`${t}\``).join(', ') || 'N/A',
362
+ inline: false,
363
+ },
364
+ ];
365
+
366
+ return {
367
+ title: `🏗️ Architect: ${output.skillName}`,
368
+ description: `**목적:** ${output.purpose}\n**복잡도:** ${complexity}`,
369
+ color: COLORS.architect,
370
+ fields,
371
+ footer:
372
+ seconds !== undefined ? { text: `⏳ ${seconds}초 후 자동 승인 → Developer` } : undefined,
373
+ };
374
+ }
375
+
376
+ export function formatDeveloperEmbed(output: DeveloperOutput, seconds?: number): DiscordEmbed {
377
+ const fileList = output.files.map((f) => `📄 \`${f.path}\` (${f.language})`).join('\n');
378
+
379
+ return {
380
+ title: '💻 Developer 작업 완료',
381
+ description: `**생성된 파일 ${output.files.length}개**\n\n${fileList}`,
382
+ color: COLORS.developer,
383
+ fields: [
384
+ {
385
+ name: '📦 설치',
386
+ value: output.installInstructions.map((i) => `\`${i}\``).join('\n') || '없음',
387
+ inline: true,
388
+ },
389
+ {
390
+ name: '🧪 테스트',
391
+ value: output.testCommands.map((c) => `\`${c}\``).join('\n') || '없음',
392
+ inline: true,
393
+ },
394
+ ],
395
+ footer: seconds !== undefined ? { text: `⏳ ${seconds}초 후 자동 승인 → QA` } : undefined,
396
+ };
397
+ }
398
+
399
+ export function formatQAEmbed(output: QAOutput, seconds?: number): DiscordEmbed {
400
+ const status = output.passed ? '✅ PASSED' : '❌ FAILED';
401
+ const recommendation = {
402
+ approve: '🟢 승인',
403
+ revise: '🟡 수정 필요',
404
+ reject: '🔴 거부',
405
+ }[output.recommendation];
406
+
407
+ const checklistStr =
408
+ output.checklist.map((c) => `${c.passed ? '✅' : '❌'} ${c.item}`).join('\n') || '없음';
409
+
410
+ const issuesStr = output.issues.length
411
+ ? output.issues
412
+ .map((i) => {
413
+ const icon = { critical: '🔴', warning: '🟡', suggestion: '🔵' }[i.severity];
414
+ return `${icon} ${i.description}`;
415
+ })
416
+ .join('\n')
417
+ : '없음';
418
+
419
+ return {
420
+ title: `🔍 QA 검증 ${status}`,
421
+ description: `**권장:** ${recommendation}`,
422
+ color: output.passed ? COLORS.success : COLORS.danger,
423
+ fields: [
424
+ {
425
+ name: '✅ 체크리스트',
426
+ value: checklistStr,
427
+ inline: false,
428
+ },
429
+ {
430
+ name: '⚠️ 이슈',
431
+ value: issuesStr,
432
+ inline: false,
433
+ },
434
+ ],
435
+ footer: seconds !== undefined ? { text: `⏳ ${seconds}초 후 자동 완료` } : undefined,
436
+ };
437
+ }
438
+
439
+ // ===== Live Countdown Message =====
440
+
441
+ export function formatLiveCountdownMessage(
442
+ phase: SessionPhase,
443
+ secondsRemaining: number,
444
+ artifacts: SessionState['artifacts']
445
+ ): DiscordMessage {
446
+ const embeds: DiscordEmbed[] = [];
447
+
448
+ switch (phase) {
449
+ case 'architect_review':
450
+ if (artifacts.architectOutput) {
451
+ embeds.push(formatArchitectEmbed(artifacts.architectOutput, secondsRemaining));
452
+ }
453
+ break;
454
+ case 'developer_review':
455
+ if (artifacts.developerOutput) {
456
+ embeds.push(formatDeveloperEmbed(artifacts.developerOutput, secondsRemaining));
457
+ }
458
+ break;
459
+ case 'qa_review':
460
+ if (artifacts.qaOutput) {
461
+ embeds.push(formatQAEmbed(artifacts.qaOutput, secondsRemaining));
462
+ }
463
+ break;
464
+ }
465
+
466
+ // Add animated countdown bar
467
+ const bar = formatAnimatedCountdown(secondsRemaining, 5);
468
+
469
+ return {
470
+ content: bar,
471
+ embeds,
472
+ components: [getReviewButtons(secondsRemaining)],
473
+ };
474
+ }
475
+
476
+ function formatAnimatedCountdown(current: number, total: number): string {
477
+ const filled = '█'.repeat(current);
478
+ const empty = '░'.repeat(total - current);
479
+ const emoji = current > 2 ? '🟢' : current > 0 ? '🟡' : '🔴';
480
+ return `${emoji} **${current}s** [${filled}${empty}]`;
481
+ }
482
+
483
+ // ===== Session Summary with Embeds =====
484
+
485
+ export function formatSessionSummaryEmbed(state: SessionState): DiscordEmbed {
486
+ const { artifacts, request } = state;
487
+ const isComplete = state.phase === 'completed';
488
+
489
+ const fields = [];
490
+
491
+ if (artifacts.architectOutput) {
492
+ fields.push({
493
+ name: '🏗️ Architect',
494
+ value: `${artifacts.architectOutput.workflow.length}단계 설계`,
495
+ inline: true,
496
+ });
497
+ }
498
+
499
+ if (artifacts.developerOutput) {
500
+ fields.push({
501
+ name: '💻 Developer',
502
+ value: `${artifacts.developerOutput.files.length}개 파일`,
503
+ inline: true,
504
+ });
505
+ }
506
+
507
+ if (artifacts.qaOutput) {
508
+ const qa = artifacts.qaOutput;
509
+ fields.push({
510
+ name: '🔍 QA',
511
+ value: `${qa.checklist.filter((c) => c.passed).length}/${qa.checklist.length} 통과`,
512
+ inline: true,
513
+ });
514
+ }
515
+
516
+ return {
517
+ title: isComplete ? `🎉 ${request.name} 생성 완료!` : `⏳ ${request.name} 진행 중...`,
518
+ description: request.description,
519
+ color: isComplete ? COLORS.success : COLORS.primary,
520
+ fields,
521
+ timestamp: new Date().toISOString(),
522
+ footer: {
523
+ text: 'Skill Forge 🔥',
524
+ },
525
+ };
526
+ }
527
+
528
+ // ===== Test =====
529
+
530
+ async function runTest() {
531
+ console.log('🖥️ Discord UI Test\n');
532
+
533
+ // Mock architect output
534
+ const mockArchitectOutput: ArchitectOutput = {
535
+ skillName: 'test-skill',
536
+ purpose: '테스트 스킬입니다',
537
+ triggers: ['/test'],
538
+ workflow: [
539
+ { step: 1, action: 'parse', description: '입력 파싱' },
540
+ { step: 2, action: 'execute', description: '실행' },
541
+ ],
542
+ fileStructure: [{ path: 'skills/test/index.ts', purpose: '메인' }],
543
+ toolsRequired: ['Read', 'Write'],
544
+ estimatedComplexity: 'simple',
545
+ };
546
+
547
+ // Test old format
548
+ const message = formatCountdownMessage('architect_review', 5, {
549
+ architectOutput: mockArchitectOutput,
550
+ });
551
+
552
+ console.log('=== Architect Review Message ===\n');
553
+ console.log(message.content);
554
+ console.log('\n=== Buttons ===');
555
+ console.log(JSON.stringify(message.components, null, 2));
556
+
557
+ console.log('\n=== Countdown Line ===');
558
+ for (let i = 5; i >= 0; i--) {
559
+ console.log(formatCountdownLine(i));
560
+ }
561
+
562
+ // Test new embed format
563
+ console.log('\n=== Embed Format ===');
564
+ const embed = formatArchitectEmbed(mockArchitectOutput, 5);
565
+ console.log(JSON.stringify(embed, null, 2));
566
+
567
+ // Test live countdown
568
+ console.log('\n=== Live Countdown Message ===');
569
+ const liveMsg = formatLiveCountdownMessage('architect_review', 3, {
570
+ architectOutput: mockArchitectOutput,
571
+ });
572
+ console.log('Content:', liveMsg.content);
573
+ console.log('Embeds:', liveMsg.embeds?.length || 0);
574
+ }
575
+
576
+ // ESM entry point
577
+ const isMainModule = import.meta.url === `file://${process.argv[1]}`;
578
+ if (isMainModule) {
579
+ runTest();
580
+ }