visual-living-plan 0.1.0 → 2.32.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 (608) hide show
  1. package/DESIGN.md +213 -0
  2. package/README.md +155 -28
  3. package/dist/AuthScreen.d.ts +9 -0
  4. package/dist/AuthScreen.js +7 -0
  5. package/dist/DesktopModeSwitch.d.ts +13 -0
  6. package/dist/DesktopModeSwitch.js +14 -0
  7. package/dist/OAuthMark.d.ts +6 -0
  8. package/dist/OAuthMark.js +8 -0
  9. package/dist/accountInitials.d.ts +5 -0
  10. package/dist/accountInitials.js +20 -0
  11. package/dist/accountLinking.d.ts +26 -0
  12. package/dist/accountLinking.js +46 -0
  13. package/dist/agentEvents.d.ts +31 -0
  14. package/dist/agentEvents.js +260 -0
  15. package/dist/agentPresence.d.ts +42 -0
  16. package/dist/agentPresence.js +69 -0
  17. package/dist/agentSkills.d.ts +35 -0
  18. package/dist/agentSkills.js +89 -0
  19. package/dist/agentStream.d.ts +35 -0
  20. package/dist/agentStream.js +133 -0
  21. package/dist/appearanceDom.d.ts +13 -0
  22. package/dist/appearanceDom.js +24 -0
  23. package/dist/appearanceSettings.d.ts +29 -0
  24. package/dist/appearanceSettings.js +293 -0
  25. package/dist/assets.d.ts +14 -0
  26. package/dist/assets.js +72 -0
  27. package/dist/authSearch.d.ts +11 -0
  28. package/dist/authSearch.js +30 -0
  29. package/dist/changelog.d.ts +11 -0
  30. package/dist/changelog.js +63 -0
  31. package/dist/changelogParse.d.ts +53 -0
  32. package/dist/changelogParse.js +226 -0
  33. package/dist/cli.d.ts +2 -0
  34. package/dist/cli.js +1684 -0
  35. package/dist/cliLauncher.d.ts +40 -0
  36. package/dist/cliLauncher.js +170 -0
  37. package/dist/cliToken.d.ts +11 -0
  38. package/dist/cliToken.js +15 -0
  39. package/dist/client/.vite/manifest.json +1780 -0
  40. package/dist/client/assets/BarChart-DtV3dIq4.js +1 -0
  41. package/dist/client/assets/BlockEditor-BklSUBjk.js +168 -0
  42. package/dist/client/assets/BlockEditor-K5h6xc4_.css +1 -0
  43. package/dist/client/assets/CodeBlock-BbI08MlQ.js +1 -0
  44. package/dist/client/assets/CodeBlock-BxRMnldw.js +175 -0
  45. package/dist/client/assets/LineChart-CQYMEbD6.js +1 -0
  46. package/dist/client/assets/Mermaid-Ciu9eIoG.js +1 -0
  47. package/dist/client/assets/Mermaid-jPWLXX7e.js +1 -0
  48. package/dist/client/assets/Popover-DbE4vUPG.js +1 -0
  49. package/dist/client/assets/ReactFlowExecutionCanvas-BhVs-adc.js +7 -0
  50. package/dist/client/assets/ReactFlowExecutionCanvas-DLioOiRN.css +1 -0
  51. package/dist/client/assets/StatusIcon-C_-Lm9b4.js +1 -0
  52. package/dist/client/assets/Workflow-C92OpLyf.js +1 -0
  53. package/dist/client/assets/agentPresence-D8asHrTp.js +1 -0
  54. package/dist/client/assets/andromeeda-DW8vo71h.js +1 -0
  55. package/dist/client/assets/andromeeda-vGVdxbeo.js +1 -0
  56. package/dist/client/assets/arrow-up-CEVVOXD5.js +1 -0
  57. package/dist/client/assets/arrow-up-down-BSjnQK2I.js +1 -0
  58. package/dist/client/assets/aurora-x-CDeNXAV0.js +1 -0
  59. package/dist/client/assets/aurora-x-rMvKqtYI.js +1 -0
  60. package/dist/client/assets/ayu-dark-CwczpL8O.js +1 -0
  61. package/dist/client/assets/ayu-dark-DluEY0Gj.js +1 -0
  62. package/dist/client/assets/ayu-light-C3h-C4tm.js +1 -0
  63. package/dist/client/assets/ayu-light-DSh22xiD.js +1 -0
  64. package/dist/client/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  65. package/dist/client/assets/ayu-mirage-JE6hAyHG.js +1 -0
  66. package/dist/client/assets/browserStore-BDGKYoJj.js +435 -0
  67. package/dist/client/assets/button-BI07wqbi.css +1 -0
  68. package/dist/client/assets/button-DJWAGApe.js +1 -0
  69. package/dist/client/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
  70. package/dist/client/assets/catppuccin-frappe-pyXErRRU.js +1 -0
  71. package/dist/client/assets/catppuccin-latte-BILSUICr.js +1 -0
  72. package/dist/client/assets/catppuccin-latte-CtsyrtPq.js +1 -0
  73. package/dist/client/assets/catppuccin-macchiato-Ck60ZZQE.js +1 -0
  74. package/dist/client/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
  75. package/dist/client/assets/catppuccin-mocha-C_2G67cS.js +1 -0
  76. package/dist/client/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
  77. package/dist/client/assets/ccount-nzzEXTrh.js +1 -0
  78. package/dist/client/assets/chartRows-CNjjLsAH.js +2 -0
  79. package/dist/client/assets/circle-x-BLGxA3gi.js +1 -0
  80. package/dist/client/assets/client-BsE_buVT.js +9 -0
  81. package/dist/client/assets/constants-CmGPilXJ.js +1 -0
  82. package/dist/client/assets/dark-plus-CHgc6GYj.js +1 -0
  83. package/dist/client/assets/dark-plus-Cs2F2srj.js +1 -0
  84. package/dist/client/assets/default-5FplaXL4.js +7 -0
  85. package/dist/client/assets/diffsTheme-PJJTu2Rq.js +1 -0
  86. package/dist/client/assets/dracula-BHWKrbxM.js +1 -0
  87. package/dist/client/assets/dracula-Cf1PG3MT.js +1 -0
  88. package/dist/client/assets/dracula-soft-5eyTD99u.js +1 -0
  89. package/dist/client/assets/dracula-soft-DXuNm1Kq.js +1 -0
  90. package/dist/client/assets/editSource-DQfw4nRm.js +1 -0
  91. package/dist/client/assets/editSource-U5AoD-Wo.js +14 -0
  92. package/dist/client/assets/engine-CLTPZlti.js +1 -0
  93. package/dist/client/assets/engine-DUyaiAMV.js +2 -0
  94. package/dist/client/assets/everforest-dark-CjdfwUBe.js +1 -0
  95. package/dist/client/assets/everforest-dark-sB-x3p7T.js +1 -0
  96. package/dist/client/assets/everforest-light-CfVwwCBP.js +1 -0
  97. package/dist/client/assets/everforest-light-Df2xbC6M.js +1 -0
  98. package/dist/client/assets/forgetDocuments-CIUBitCs.js +1 -0
  99. package/dist/client/assets/formatCSSVariablePrefix-KRh9vnZf.js +1 -0
  100. package/dist/client/assets/github-dark-BL6HSl_n.js +1 -0
  101. package/dist/client/assets/github-dark-C-LZuMrd.js +1 -0
  102. package/dist/client/assets/github-dark-default-DXG-b-1a.js +1 -0
  103. package/dist/client/assets/github-dark-default-zacuWV-M.js +1 -0
  104. package/dist/client/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  105. package/dist/client/assets/github-dark-dimmed-Mc0P9idi.js +1 -0
  106. package/dist/client/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  107. package/dist/client/assets/github-dark-high-contrast-IMKX2AVF.js +1 -0
  108. package/dist/client/assets/github-light-EUqPIrTm.js +1 -0
  109. package/dist/client/assets/github-light-default-BXViO-2h.js +1 -0
  110. package/dist/client/assets/github-light-default-DVlCqP3X.js +1 -0
  111. package/dist/client/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  112. package/dist/client/assets/github-light-high-contrast-Dj6zTyWR.js +1 -0
  113. package/dist/client/assets/github-light-mYhEBkPo.js +1 -0
  114. package/dist/client/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  115. package/dist/client/assets/gruvbox-dark-hard-QTgQQZn-.js +1 -0
  116. package/dist/client/assets/gruvbox-dark-medium-9d5YdCTx.js +1 -0
  117. package/dist/client/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  118. package/dist/client/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  119. package/dist/client/assets/gruvbox-dark-soft-XCkqeBhR.js +1 -0
  120. package/dist/client/assets/gruvbox-light-hard--5-nXqNp.js +1 -0
  121. package/dist/client/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  122. package/dist/client/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  123. package/dist/client/assets/gruvbox-light-medium-COA1PZW2.js +1 -0
  124. package/dist/client/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  125. package/dist/client/assets/gruvbox-light-soft-CIJpzjAO.js +1 -0
  126. package/dist/client/assets/hastToHtml-Dj8rXue9.js +11 -0
  127. package/dist/client/assets/highlight-cB-PkhyE.js +1 -0
  128. package/dist/client/assets/highlights-LLBF1DTm.js +1 -0
  129. package/dist/client/assets/horizon-Ba2cwkSy.js +1 -0
  130. package/dist/client/assets/horizon-CE9ld1lL.js +1 -0
  131. package/dist/client/assets/horizon-bright-DSNQnXHK.js +1 -0
  132. package/dist/client/assets/horizon-bright-DaEDgBmR.js +1 -0
  133. package/dist/client/assets/houston-B6x0XVpU.js +1 -0
  134. package/dist/client/assets/houston-CsvMBhTu.js +1 -0
  135. package/dist/client/assets/jsx-runtime-DKj5X9O4.js +1 -0
  136. package/dist/client/assets/kanagawa-dragon-Bozd7klA.js +1 -0
  137. package/dist/client/assets/kanagawa-dragon-DhTFvBMT.js +1 -0
  138. package/dist/client/assets/kanagawa-lotus--m8sdOxn.js +1 -0
  139. package/dist/client/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
  140. package/dist/client/assets/kanagawa-wave-BML5mF2J.js +1 -0
  141. package/dist/client/assets/kanagawa-wave-D-tTv4k2.js +1 -0
  142. package/dist/client/assets/laserwave-C_8bwKvT.js +1 -0
  143. package/dist/client/assets/laserwave-HSLx0L75.js +1 -0
  144. package/dist/client/assets/lib-COgu-QLX.js +33 -0
  145. package/dist/client/assets/lib-CdRiGVUZ.js +1 -0
  146. package/dist/client/assets/light-plus-CUjWrTSi.js +1 -0
  147. package/dist/client/assets/light-plus-DVQuIRkW.js +1 -0
  148. package/dist/client/assets/loader-CjL04K29.js +1 -0
  149. package/dist/client/assets/main-BGMX_GnZ.js +2 -0
  150. package/dist/client/assets/main-BTko4EvJ.css +1 -0
  151. package/dist/client/assets/material-theme-Bm3Qr25_.js +1 -0
  152. package/dist/client/assets/material-theme-CnthUGfg.js +1 -0
  153. package/dist/client/assets/material-theme-darker-2IIEA8gg.js +1 -0
  154. package/dist/client/assets/material-theme-darker-DUi03Qre.js +1 -0
  155. package/dist/client/assets/material-theme-lighter-D2-qr5Vw.js +1 -0
  156. package/dist/client/assets/material-theme-lighter-uhdI0v04.js +1 -0
  157. package/dist/client/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  158. package/dist/client/assets/material-theme-ocean-CWR-LogA.js +1 -0
  159. package/dist/client/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  160. package/dist/client/assets/material-theme-palenight-Cnv8m1ra.js +1 -0
  161. package/dist/client/assets/mdxEntries-BNTMP8ct.css +1 -0
  162. package/dist/client/assets/mdxEntries-L-V7bB6i.js +1 -0
  163. package/dist/client/assets/mermaid-Bjhs-krb.js +1 -0
  164. package/dist/client/assets/mermaid-Di4j-zgD.js +146 -0
  165. package/dist/client/assets/min-dark-BSWPekZh.js +1 -0
  166. package/dist/client/assets/min-dark-EXoM-6Xo.js +1 -0
  167. package/dist/client/assets/min-light-DDpmG2fV.js +1 -0
  168. package/dist/client/assets/min-light-DVOTDhnA.js +1 -0
  169. package/dist/client/assets/monokai-BscAjiQZ.js +1 -0
  170. package/dist/client/assets/monokai-DkggTbGy.js +1 -0
  171. package/dist/client/assets/mountChrome-BVWpsDCy.js +122 -0
  172. package/dist/client/assets/mountChrome-DhTDH3YM.css +1 -0
  173. package/dist/client/assets/night-owl-Bdcs0PMi.js +1 -0
  174. package/dist/client/assets/night-owl-DhmEMT88.js +1 -0
  175. package/dist/client/assets/night-owl-light-RoU30LE0.js +1 -0
  176. package/dist/client/assets/night-owl-light-eJ-hLW7d.js +1 -0
  177. package/dist/client/assets/noShiki-DB8hQ_W3.js +1 -0
  178. package/dist/client/assets/noShiki-GTG3tT8x.js +1 -0
  179. package/dist/client/assets/nord-Cb4Vim4T.js +1 -0
  180. package/dist/client/assets/nord-u7hMircQ.js +1 -0
  181. package/dist/client/assets/offlineSync-Cv3FVIlJ.js +1 -0
  182. package/dist/client/assets/one-dark-pro-08PdtLzi.js +1 -0
  183. package/dist/client/assets/one-dark-pro-C6YyR8OD.js +1 -0
  184. package/dist/client/assets/one-light-D7Lr4KcI.js +1 -0
  185. package/dist/client/assets/one-light-DgvUEtgI.js +1 -0
  186. package/dist/client/assets/opfs-worker-DuTOCgWR.js +5919 -0
  187. package/dist/client/assets/pierre-dark-B2jZWvHG.js +1 -0
  188. package/dist/client/assets/pierre-dark-CpLgRqie.js +1 -0
  189. package/dist/client/assets/pierre-dark-protanopia-deuteranopia-B35FxJx-.js +1 -0
  190. package/dist/client/assets/pierre-dark-protanopia-deuteranopia-CebgQdRf.js +1 -0
  191. package/dist/client/assets/pierre-dark-soft-DdE7dyP3.js +1 -0
  192. package/dist/client/assets/pierre-dark-soft-kZQmAZld.js +1 -0
  193. package/dist/client/assets/pierre-dark-tritanopia-CXimiT7X.js +1 -0
  194. package/dist/client/assets/pierre-dark-tritanopia-CpjhbsIL.js +1 -0
  195. package/dist/client/assets/pierre-dark-vibrant-CpQYzh95.js +1 -0
  196. package/dist/client/assets/pierre-dark-vibrant-DzBsxHvQ.js +1 -0
  197. package/dist/client/assets/pierre-light-CoaEpmwp.js +1 -0
  198. package/dist/client/assets/pierre-light-Vf__O3ev.js +1 -0
  199. package/dist/client/assets/pierre-light-protanopia-deuteranopia-0fSaH845.js +1 -0
  200. package/dist/client/assets/pierre-light-protanopia-deuteranopia-BUtWcCQC.js +1 -0
  201. package/dist/client/assets/pierre-light-soft-C3QCXKvN.js +1 -0
  202. package/dist/client/assets/pierre-light-soft-lWLdNTOI.js +1 -0
  203. package/dist/client/assets/pierre-light-tritanopia-CEbqgOJL.js +1 -0
  204. package/dist/client/assets/pierre-light-tritanopia-CKLy6XvA.js +1 -0
  205. package/dist/client/assets/pierre-light-vibrant-D80Fkn33.js +1 -0
  206. package/dist/client/assets/pierre-light-vibrant-DDuTEIhH.js +1 -0
  207. package/dist/client/assets/planEditButton-CbWGczbi.js +45 -0
  208. package/dist/client/assets/planEvents-cuzv9ELr.js +1 -0
  209. package/dist/client/assets/planMdx-Db1ze_nN.js +110 -0
  210. package/dist/client/assets/plastic-B8mE6BxX.js +1 -0
  211. package/dist/client/assets/plastic-DQwYfKfQ.js +1 -0
  212. package/dist/client/assets/poimandres-DRFjx7u4.js +1 -0
  213. package/dist/client/assets/poimandres-DUFjrgxT.js +1 -0
  214. package/dist/client/assets/preload-helper-Dx0-lKy1.js +1 -0
  215. package/dist/client/assets/queryClient-Bs5tSUJh.js +1 -0
  216. package/dist/client/assets/react-dom-DpzJPrWF.js +1 -0
  217. package/dist/client/assets/rebaseDraft-B2--cj1c.js +19 -0
  218. package/dist/client/assets/red-BJvdDEUx.js +1 -0
  219. package/dist/client/assets/red-CYlAq2b0.js +1 -0
  220. package/dist/client/assets/register-hZEIk3A9.css +1 -0
  221. package/dist/client/assets/register-htm5s8o9.js +1 -0
  222. package/dist/client/assets/rolldown-runtime-Dd_uD5pT.js +1 -0
  223. package/dist/client/assets/rose-pine-BSqRqUae.js +1 -0
  224. package/dist/client/assets/rose-pine-aMsaMD1D.js +1 -0
  225. package/dist/client/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
  226. package/dist/client/assets/rose-pine-dawn-U6TBE82u.js +1 -0
  227. package/dist/client/assets/rose-pine-moon-CAU7u1h4.js +1 -0
  228. package/dist/client/assets/rose-pine-moon-DO-qXg-I.js +1 -0
  229. package/dist/client/assets/routeEdges-B2z8v0di.js +24 -0
  230. package/dist/client/assets/selector-CDsXW7SO.css +1 -0
  231. package/dist/client/assets/selector-tlBGWtQl.js +1 -0
  232. package/dist/client/assets/settingsChrome-NGUDtEIp.js +1 -0
  233. package/dist/client/assets/shiki-BOXJeUHI.js +2 -0
  234. package/dist/client/assets/slack-dark-CMu0smFa.js +1 -0
  235. package/dist/client/assets/slack-dark-DnToyrRv.js +1 -0
  236. package/dist/client/assets/slack-ochin-B2OO5cIa.js +1 -0
  237. package/dist/client/assets/slack-ochin-BBne7cjw.js +1 -0
  238. package/dist/client/assets/snazzy-light-4G7pJPwS.js +1 -0
  239. package/dist/client/assets/snazzy-light-CV8HUEmk.js +1 -0
  240. package/dist/client/assets/solarized-dark-CmYmhSgI.js +1 -0
  241. package/dist/client/assets/solarized-dark-b97czJOk.js +1 -0
  242. package/dist/client/assets/solarized-light-CjLLwxRp.js +1 -0
  243. package/dist/client/assets/solarized-light-DFPxpIYQ.js +1 -0
  244. package/dist/client/assets/stampPlanParts-DVXYCykw.js +15 -0
  245. package/dist/client/assets/stampPlanParts-ctZzxWdw.css +1 -0
  246. package/dist/client/assets/stream-tokenizer-C3n8hi1h.js +4 -0
  247. package/dist/client/assets/synthwave-84-nFMaYfgc.js +1 -0
  248. package/dist/client/assets/synthwave-84-wQeDKbzQ.js +1 -0
  249. package/dist/client/assets/textChildren-ZDSs1dod.js +1 -0
  250. package/dist/client/assets/themes-CdTJhjZf.js +2 -0
  251. package/dist/client/assets/tokyo-night-D4ZgDiA7.js +1 -0
  252. package/dist/client/assets/tokyo-night-oM2G3aXe.js +1 -0
  253. package/dist/client/assets/triangle-alert-C9Sgr3jF.js +1 -0
  254. package/dist/client/assets/unwrapDefault-ByDmBtHB.js +1 -0
  255. package/dist/client/assets/utils-C9Glzetk.js +2 -0
  256. package/dist/client/assets/versionView-zkSROPw7.js +1 -0
  257. package/dist/client/assets/vesper-DdrHHSXu.js +1 -0
  258. package/dist/client/assets/vesper-sUHevyKv.js +1 -0
  259. package/dist/client/assets/vitesse-black-CfklMpOb.js +1 -0
  260. package/dist/client/assets/vitesse-black-fwtXNY1n.js +1 -0
  261. package/dist/client/assets/vitesse-dark-BZCL-v6S.js +1 -0
  262. package/dist/client/assets/vitesse-dark-CJkzwmKT.js +1 -0
  263. package/dist/client/assets/vitesse-light-BxMp8E1Y.js +1 -0
  264. package/dist/client/assets/vitesse-light-VbXTXTou.js +1 -0
  265. package/dist/client/assets/wa-sqlite-Ba70bhIr.wasm +0 -0
  266. package/dist/client/assets/warmPlans-CYFrLwcX.js +1 -0
  267. package/dist/client/assets/with-selector-HIcjK0_d.js +1 -0
  268. package/dist/client/assets/workflowSource-LMsRuqF_.js +3 -0
  269. package/dist/client/favicon.png +0 -0
  270. package/dist/client/icons/apple-touch-icon-180x180.png +0 -0
  271. package/dist/client/icons/favicon.ico +0 -0
  272. package/dist/client/icons/maskable-icon-192x192.png +0 -0
  273. package/dist/client/icons/maskable-icon-512x512.png +0 -0
  274. package/dist/client/icons/pwa-16x16.png +0 -0
  275. package/dist/client/icons/pwa-192x192.png +0 -0
  276. package/dist/client/icons/pwa-32x32.png +0 -0
  277. package/dist/client/icons/pwa-512x512.png +0 -0
  278. package/dist/client/icons/pwa-64x64.png +0 -0
  279. package/dist/clientLog.d.ts +5 -0
  280. package/dist/clientLog.js +64 -0
  281. package/dist/cloudClient.d.ts +38 -0
  282. package/dist/cloudClient.js +185 -0
  283. package/dist/cloudCommand.d.ts +23 -0
  284. package/dist/cloudCommand.js +159 -0
  285. package/dist/cloudFrontmatter.d.ts +4 -0
  286. package/dist/cloudFrontmatter.js +30 -0
  287. package/dist/cloudStore.d.ts +28 -0
  288. package/dist/cloudStore.js +70 -0
  289. package/dist/cloudWatch.d.ts +12 -0
  290. package/dist/cloudWatch.js +103 -0
  291. package/dist/commentReply.d.ts +25 -0
  292. package/dist/commentReply.js +17 -0
  293. package/dist/configHome.d.ts +34 -0
  294. package/dist/configHome.js +136 -0
  295. package/dist/dashboard.d.ts +67 -0
  296. package/dist/dashboard.js +86 -0
  297. package/dist/dashboardClientScript.d.ts +2 -0
  298. package/dist/dashboardClientScript.js +1006 -0
  299. package/dist/dashboardDocument.d.ts +13 -0
  300. package/dist/dashboardDocument.js +40 -0
  301. package/dist/dashboardFormat.d.ts +98 -0
  302. package/dist/dashboardFormat.js +199 -0
  303. package/dist/dashboardLoading.d.ts +19 -0
  304. package/dist/dashboardLoading.js +94 -0
  305. package/dist/dashboardOverview.d.ts +28 -0
  306. package/dist/dashboardOverview.js +333 -0
  307. package/dist/dashboardPage.d.ts +2 -0
  308. package/dist/dashboardPage.js +11 -0
  309. package/dist/dashboardParts.d.ts +4 -0
  310. package/dist/dashboardParts.js +367 -0
  311. package/dist/dashboardSearchView.d.ts +38 -0
  312. package/dist/dashboardSearchView.js +255 -0
  313. package/dist/desktopApp.d.ts +23 -0
  314. package/dist/desktopApp.js +110 -0
  315. package/dist/desktopBridge.d.ts +21 -0
  316. package/dist/desktopBridge.js +78 -0
  317. package/dist/desktopCommand.d.ts +61 -0
  318. package/dist/desktopCommand.js +172 -0
  319. package/dist/desktopConfig.d.ts +54 -0
  320. package/dist/desktopConfig.js +164 -0
  321. package/dist/desktopNotices.d.ts +105 -0
  322. package/dist/desktopNotices.js +427 -0
  323. package/dist/diff.d.ts +2 -0
  324. package/dist/diff.js +46 -0
  325. package/dist/diffsTheme.d.ts +51 -0
  326. package/dist/diffsTheme.js +86 -0
  327. package/dist/diffsThemeCatalog.d.ts +3 -0
  328. package/dist/diffsThemeCatalog.js +78 -0
  329. package/dist/elkRuntime.node.d.ts +7 -0
  330. package/dist/elkRuntime.node.js +63 -0
  331. package/dist/execution.d.ts +78 -0
  332. package/dist/execution.js +139 -0
  333. package/dist/expectedWorkflow.d.ts +11 -0
  334. package/dist/expectedWorkflow.js +99 -0
  335. package/dist/favicon.d.ts +4 -0
  336. package/dist/favicon.js +40 -0
  337. package/dist/favicon.png +0 -0
  338. package/dist/faviconBase64.d.ts +1 -0
  339. package/dist/faviconBase64.js +1 -0
  340. package/dist/fileVersion.d.ts +8 -0
  341. package/dist/fileVersion.js +20 -0
  342. package/dist/formatBytes.d.ts +2 -0
  343. package/dist/formatBytes.js +13 -0
  344. package/dist/gitStatus.d.ts +12 -0
  345. package/dist/gitStatus.js +88 -0
  346. package/dist/hostToolbar.d.ts +38 -0
  347. package/dist/hostToolbar.js +249 -0
  348. package/dist/http.d.ts +8 -0
  349. package/dist/http.js +38 -0
  350. package/dist/httpServer.d.ts +13 -0
  351. package/dist/httpServer.js +40 -0
  352. package/dist/icons/apple-touch-icon-180x180.png +0 -0
  353. package/dist/icons/favicon.ico +0 -0
  354. package/dist/icons/maskable-icon-192x192.png +0 -0
  355. package/dist/icons/maskable-icon-512x512.png +0 -0
  356. package/dist/icons/pwa-16x16.png +0 -0
  357. package/dist/icons/pwa-192x192.png +0 -0
  358. package/dist/icons/pwa-32x32.png +0 -0
  359. package/dist/icons/pwa-512x512.png +0 -0
  360. package/dist/icons/pwa-64x64.png +0 -0
  361. package/dist/lanAccess.d.ts +31 -0
  362. package/dist/lanAccess.js +110 -0
  363. package/dist/lanAddress.d.ts +24 -0
  364. package/dist/lanAddress.js +174 -0
  365. package/dist/lanCommand.d.ts +25 -0
  366. package/dist/lanCommand.js +159 -0
  367. package/dist/lanConfig.d.ts +40 -0
  368. package/dist/lanConfig.js +130 -0
  369. package/dist/lanFirewall.d.ts +17 -0
  370. package/dist/lanFirewall.js +221 -0
  371. package/dist/layoutGraph.d.ts +13 -0
  372. package/dist/layoutGraph.js +55 -0
  373. package/dist/localName.d.ts +9 -0
  374. package/dist/localName.js +28 -0
  375. package/dist/lockBanner.d.ts +2 -0
  376. package/dist/lockBanner.js +2 -0
  377. package/dist/mdnsPacket.d.ts +44 -0
  378. package/dist/mdnsPacket.js +384 -0
  379. package/dist/mdnsPublish.d.ts +12 -0
  380. package/dist/mdnsPublish.js +290 -0
  381. package/dist/offlineSync.d.ts +249 -0
  382. package/dist/offlineSync.js +477 -0
  383. package/dist/openUrl.d.ts +40 -0
  384. package/dist/openUrl.js +147 -0
  385. package/dist/openedPages.d.ts +14 -0
  386. package/dist/openedPages.js +48 -0
  387. package/dist/pageEditPull.d.ts +9 -0
  388. package/dist/pageEditPull.js +29 -0
  389. package/dist/pageRoutes.d.ts +3 -0
  390. package/dist/pageRoutes.js +34 -0
  391. package/dist/parse.d.ts +7 -0
  392. package/dist/parse.js +100 -0
  393. package/dist/pid.d.ts +2 -0
  394. package/dist/pid.js +13 -0
  395. package/dist/planArchive.d.ts +4 -0
  396. package/dist/planArchive.js +28 -0
  397. package/dist/planEntries.d.ts +12 -0
  398. package/dist/planEntries.js +117 -0
  399. package/dist/planHost.d.ts +31 -0
  400. package/dist/planHost.js +286 -0
  401. package/dist/planId.d.ts +2 -0
  402. package/dist/planId.js +6 -0
  403. package/dist/planMdx/blockEdit.d.ts +41 -0
  404. package/dist/planMdx/blockEdit.js +60 -0
  405. package/dist/planMdx/cellPart.d.ts +14 -0
  406. package/dist/planMdx/cellPart.js +26 -0
  407. package/dist/planMdx/compilePlanMdx.d.ts +3 -0
  408. package/dist/planMdx/compilePlanMdx.js +22 -0
  409. package/dist/planMdx/editSource.d.ts +39 -0
  410. package/dist/planMdx/editSource.js +327 -0
  411. package/dist/planMdx/frontmatter.d.ts +5 -0
  412. package/dist/planMdx/frontmatter.js +15 -0
  413. package/dist/planMdx/markdown.d.ts +6 -0
  414. package/dist/planMdx/markdown.js +470 -0
  415. package/dist/planMdx/outline.d.ts +8 -0
  416. package/dist/planMdx/outline.js +548 -0
  417. package/dist/planMdx/payload.d.ts +4 -0
  418. package/dist/planMdx/payload.js +18 -0
  419. package/dist/planMdx/rebaseDraft.d.ts +54 -0
  420. package/dist/planMdx/rebaseDraft.js +675 -0
  421. package/dist/planMdx/recmaPlanComponents.d.ts +18 -0
  422. package/dist/planMdx/recmaPlanComponents.js +52 -0
  423. package/dist/planMdx/remarkBlockRanges.d.ts +104 -0
  424. package/dist/planMdx/remarkBlockRanges.js +275 -0
  425. package/dist/planMdx/remarkCodeMeta.d.ts +16 -0
  426. package/dist/planMdx/remarkCodeMeta.js +25 -0
  427. package/dist/planMdx/remarkGfmTable.d.ts +5 -0
  428. package/dist/planMdx/remarkGfmTable.js +15 -0
  429. package/dist/planMdx/remarkGfmTaskList.d.ts +5 -0
  430. package/dist/planMdx/remarkGfmTaskList.js +15 -0
  431. package/dist/planMdx/remarkMermaid.d.ts +16 -0
  432. package/dist/planMdx/remarkMermaid.js +56 -0
  433. package/dist/planMdx/source.d.ts +11 -0
  434. package/dist/planMdx/source.js +131 -0
  435. package/dist/planMdx/titleEdit.d.ts +35 -0
  436. package/dist/planMdx/titleEdit.js +112 -0
  437. package/dist/planPage.css +2125 -0
  438. package/dist/planProgress.d.ts +17 -0
  439. package/dist/planProgress.js +78 -0
  440. package/dist/planReady.d.ts +8 -0
  441. package/dist/planReady.js +20 -0
  442. package/dist/planRefNavigation.d.ts +4 -0
  443. package/dist/planRefNavigation.js +8 -0
  444. package/dist/planRoutes.d.ts +12 -0
  445. package/dist/planRoutes.js +141 -0
  446. package/dist/planSearch.d.ts +166 -0
  447. package/dist/planSearch.js +462 -0
  448. package/dist/planSession.d.ts +130 -0
  449. package/dist/planSession.js +1182 -0
  450. package/dist/planSnapshots.d.ts +34 -0
  451. package/dist/planSnapshots.js +113 -0
  452. package/dist/planStatus.d.ts +26 -0
  453. package/dist/planStatus.js +46 -0
  454. package/dist/planStepHeading.d.ts +16 -0
  455. package/dist/planStepHeading.js +34 -0
  456. package/dist/planTarget.d.ts +16 -0
  457. package/dist/planTarget.js +92 -0
  458. package/dist/planToc.d.ts +24 -0
  459. package/dist/planToc.js +258 -0
  460. package/dist/planVersionMenu.d.ts +12 -0
  461. package/dist/planVersionMenu.js +23 -0
  462. package/dist/processRecord.d.ts +108 -0
  463. package/dist/processRecord.js +68 -0
  464. package/dist/processesPanel.d.ts +7 -0
  465. package/dist/processesPanel.js +636 -0
  466. package/dist/pwaIconFile.d.ts +2 -0
  467. package/dist/pwaIconFile.js +42 -0
  468. package/dist/pwaIcons.d.ts +28 -0
  469. package/dist/pwaIcons.js +46 -0
  470. package/dist/registerServiceWorker.d.ts +25 -0
  471. package/dist/registerServiceWorker.js +26 -0
  472. package/dist/registryClient.d.ts +94 -0
  473. package/dist/registryClient.js +490 -0
  474. package/dist/registryConstants.d.ts +9 -0
  475. package/dist/registryConstants.js +9 -0
  476. package/dist/registryLock.d.ts +19 -0
  477. package/dist/registryLock.js +48 -0
  478. package/dist/registryPage.d.ts +2 -0
  479. package/dist/registryPage.js +284 -0
  480. package/dist/registryService.d.ts +21 -0
  481. package/dist/registryService.js +562 -0
  482. package/dist/registryStore.d.ts +63 -0
  483. package/dist/registryStore.js +398 -0
  484. package/dist/releaseNotes.d.ts +35 -0
  485. package/dist/releaseNotes.js +62 -0
  486. package/dist/render.d.ts +50 -0
  487. package/dist/render.js +1506 -0
  488. package/dist/requestGuard.d.ts +21 -0
  489. package/dist/requestGuard.js +42 -0
  490. package/dist/reviewRound.d.ts +12 -0
  491. package/dist/reviewRound.js +19 -0
  492. package/dist/runFollow.d.ts +28 -0
  493. package/dist/runFollow.js +33 -0
  494. package/dist/searchMatch.d.ts +35 -0
  495. package/dist/searchMatch.js +270 -0
  496. package/dist/server.d.ts +24 -0
  497. package/dist/server.js +114 -0
  498. package/dist/serviceLog.d.ts +56 -0
  499. package/dist/serviceLog.js +481 -0
  500. package/dist/shellCache.d.ts +69 -0
  501. package/dist/shellCache.js +289 -0
  502. package/dist/shellWorker.js +322 -0
  503. package/dist/shellWorkerResponse.d.ts +4 -0
  504. package/dist/shellWorkerResponse.js +15 -0
  505. package/dist/startServer.d.ts +2 -0
  506. package/dist/startServer.js +2 -0
  507. package/dist/store/meta.d.ts +53 -0
  508. package/dist/store/meta.js +140 -0
  509. package/dist/store/migrate.d.ts +3 -0
  510. package/dist/store/migrate.js +408 -0
  511. package/dist/store/rows.d.ts +4 -0
  512. package/dist/store/rows.js +100 -0
  513. package/dist/store/schema.d.ts +5 -0
  514. package/dist/store/schema.js +5 -0
  515. package/dist/store/sqlite.d.ts +19 -0
  516. package/dist/store/sqlite.js +57 -0
  517. package/dist/store/tables.d.ts +1892 -0
  518. package/dist/store/tables.js +136 -0
  519. package/dist/theme.d.ts +174 -0
  520. package/dist/theme.js +444 -0
  521. package/dist/themeBootstrap.d.ts +2 -0
  522. package/dist/themeBootstrap.js +11 -0
  523. package/dist/tui/DashboardApp.d.ts +19 -0
  524. package/dist/tui/DashboardApp.js +237 -0
  525. package/dist/tui/PaletteProvider.d.ts +12 -0
  526. package/dist/tui/PaletteProvider.js +36 -0
  527. package/dist/tui/PlanActions.d.ts +7 -0
  528. package/dist/tui/PlanActions.js +9 -0
  529. package/dist/tui/PlanCard.d.ts +13 -0
  530. package/dist/tui/PlanCard.js +31 -0
  531. package/dist/tui/PlanRow.d.ts +13 -0
  532. package/dist/tui/PlanRow.js +31 -0
  533. package/dist/tui/PlanTable.d.ts +13 -0
  534. package/dist/tui/PlanTable.js +24 -0
  535. package/dist/tui/ProcessCard.d.ts +9 -0
  536. package/dist/tui/ProcessCard.js +24 -0
  537. package/dist/tui/ProcessList.d.ts +9 -0
  538. package/dist/tui/ProcessList.js +12 -0
  539. package/dist/tui/SegmentButton.d.ts +7 -0
  540. package/dist/tui/SegmentButton.js +18 -0
  541. package/dist/tui/StatCard.d.ts +6 -0
  542. package/dist/tui/StatCard.js +17 -0
  543. package/dist/tui/dashboardView.d.ts +45 -0
  544. package/dist/tui/dashboardView.js +192 -0
  545. package/dist/tui/openExternal.d.ts +2 -0
  546. package/dist/tui/openExternal.js +5 -0
  547. package/dist/tui/palette.d.ts +27 -0
  548. package/dist/tui/palette.js +66 -0
  549. package/dist/tui/planColumns.d.ts +38 -0
  550. package/dist/tui/planColumns.js +14 -0
  551. package/dist/tui/readDashboard.d.ts +3 -0
  552. package/dist/tui/readDashboard.js +15 -0
  553. package/dist/tui/readProcesses.d.ts +3 -0
  554. package/dist/tui/readProcesses.js +23 -0
  555. package/dist/tui/registryView.d.ts +11 -0
  556. package/dist/tui/registryView.js +56 -0
  557. package/dist/tui/runTui.d.ts +21 -0
  558. package/dist/tui/runTui.js +86 -0
  559. package/dist/tui/systemTheme.d.ts +28 -0
  560. package/dist/tui/systemTheme.js +141 -0
  561. package/dist/types.d.ts +191 -0
  562. package/dist/types.js +0 -0
  563. package/dist/webManifest.d.ts +39 -0
  564. package/dist/webManifest.js +48 -0
  565. package/dist/workflow.d.ts +8 -0
  566. package/dist/workflow.js +42 -0
  567. package/dist/workflowLayoutShared.d.ts +25 -0
  568. package/dist/workflowLayoutShared.js +33 -0
  569. package/dist/workflowSource.d.ts +31 -0
  570. package/dist/workflowSource.js +90 -0
  571. package/docs/changelogs/changelog-2026-10-27.md +203 -0
  572. package/docs/changelogs/changelog-2026-10-28.md +181 -0
  573. package/docs/changelogs/changelog-2026-10-29.md +349 -0
  574. package/docs/changelogs/changelog-2026-10-30.md +303 -0
  575. package/docs/changelogs/changelog-2026-10-31.md +129 -0
  576. package/docs/changelogs/changelog-2026-11-01.md +155 -0
  577. package/docs/changelogs/changelog-2026-11-02.md +195 -0
  578. package/docs/changelogs/changelog-2026-11-03.md +209 -0
  579. package/docs/changelogs/changelog-2026-11-04.md +243 -0
  580. package/docs/changelogs/changelog-2026-11-05.md +172 -0
  581. package/docs/changelogs/changelog-2026-11-06.md +123 -0
  582. package/docs/changelogs/changelog-2026-11-07.md +138 -0
  583. package/docs/changelogs/changelog-2026-11-08.md +47 -0
  584. package/docs/changelogs/changelog-2026-11-10.md +219 -0
  585. package/docs/changelogs/changelog-2026-11-11.md +205 -0
  586. package/docs/changelogs/changelog-2026-11-12.md +44 -0
  587. package/docs/changelogs/changelog-2026-11-13.md +48 -0
  588. package/docs/changelogs/changelog-2026-11-14.md +116 -0
  589. package/docs/changelogs/changelog-2026-11-15.md +31 -0
  590. package/docs/changelogs/changelog-2026-11-16.md +41 -0
  591. package/docs/changelogs/changelog-2026-11-17.md +25 -0
  592. package/docs/changelogs/changelog-2026-11-18.md +71 -0
  593. package/docs/changelogs/changelog-2026-11-19.md +19 -0
  594. package/examples/cloud-showcase.plan.md +181 -0
  595. package/examples/component-showcase.plan.md +378 -0
  596. package/examples/component-tour.plan.md +168 -0
  597. package/examples/data-table.plan.md +917 -0
  598. package/examples/execution-graph.json +15 -5
  599. package/examples/form-controls.plan.md +51 -0
  600. package/examples/live-plan.config.json +5 -0
  601. package/examples/rate-limit.plan.md +110 -78
  602. package/examples/submission-delivery-runbook.md +122 -0
  603. package/examples/submission-delivery.plan.md +107 -0
  604. package/examples/tables.plan.md +61 -0
  605. package/package.json +86 -15
  606. package/skills/live-plan/SKILL.md +381 -0
  607. package/skills/live-plan/primitives.md +738 -0
  608. package/skills/living-plan/SKILL.md +0 -71
package/dist/cli.js ADDED
@@ -0,0 +1,1684 @@
1
+ #!/usr/bin/env bun
2
+ import { spawn } from 'node:child_process';
3
+ import { planNotReadyReason } from './planReady';
4
+ import { writeSync } from 'node:fs';
5
+ import { access, readFile, writeFile, mkdir } from 'node:fs/promises';
6
+ import { dirname, resolve } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { loadClientAssets } from './assets';
9
+ import { parsePlan } from './parse';
10
+ import { formatSearchResponse } from './planSearch';
11
+ import { formatDashboardSearch } from './dashboardSearchView';
12
+ import { pullPageEdit } from './pageEditPull';
13
+ import { ackPlanEvents, AgentStreamRefused, pendingFromHello, planApiUrl, planIdFromPlanUrl, submissionEvent, } from './agentEvents';
14
+ import { followAgentEvents } from './agentStream';
15
+ import { startLivingPlanServer } from './server';
16
+ import { applyExecutionChange } from './execution';
17
+ import { cwdThemeConfigPath, globalThemeConfigPath } from './configHome';
18
+ import { configPathBesidePlan, DEFAULT_ACCENT, loadThemeConfig, normalizeAccent, saveThemeConfig, themePayload, } from './theme';
19
+ import { planToExpectedGraph, workflowRequirementError } from './workflow';
20
+ import { closeHostedPlan, defaultRegistryHome, ensureRegistry, listProcesses, localServiceUrl, readPackageVersion, readRegistryLock, registerHostedPlan, registryBindUrl, registryHealthy, reviveRegistry, rewriteToBindUrl, } from './registryClient';
21
+ import { isPidAlive } from './pid';
22
+ import { DEFAULT_REGISTRY_HOST, DEFAULT_REGISTRY_PORT } from './registryConstants';
23
+ import { formatServiceLogLines, isLogDay, listLogs, recordLog } from './serviceLog';
24
+ import { closeCloudPlan } from './cloudClient';
25
+ import { cloudFlagConflict, prepareCloudPlan, requireCloudAccount, runCloudWatch, signInToCloud, signInWithToken, spawnCloudWatch, stopCloudWatch, syncCloudUrl, } from './cloudCommand';
26
+ import { cloudCredential, normalizeBase, planRecordForUrl, readCloudFile, writeCloudFile } from './cloudStore';
27
+ import { CLI_TOKEN_PATH } from './cliToken';
28
+ import { choosePlanOpen, rememberPageOpened } from './openedPages';
29
+ import { openInBrowser, openUrl } from './openUrl';
30
+ import { readIteration } from './reviewRound';
31
+ import { resolvePlanUrl } from './planTarget';
32
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
33
+ if (process.env.LIVE_PLAN_DAEMON === '1' && process.platform !== 'win32') {
34
+ process.on('SIGHUP', () => {
35
+ // Started detached. The process stays up when the client's terminal closes.
36
+ });
37
+ process.on('SIGPIPE', () => {
38
+ // The parent CLI closes its pipes when it exits after Iterate.
39
+ });
40
+ }
41
+ function printHelp() {
42
+ console.log(`live-plan — agent-authored plans humans can interact with
43
+
44
+ Usage (a plan command takes the plan file, or --url <plan-url>):
45
+ live-plan check <file.plan.md>
46
+ live-plan serve <file.plan.md> [--cloud] [--port N] [--host HOST] [--config file] [--no-open|--open] [--listen]
47
+ live-plan events <file.plan.md> [--follow] [--token TOKEN]
48
+ live-plan mode <watch|comment|review> <file.plan.md> [--iteration N]
49
+ live-plan reply <comment-id> <file.plan.md> --text "..." [--outcome implemented|errored|issues] [--keep-open]
50
+ live-plan close <file.plan.md>
51
+
52
+ live-plan execution start|push|stop <file.plan.md> [--step TEXT] [--detail TEXT] [--graph file.json] [--scene file.json]
53
+ live-plan search --query TERMS [--query TERMS] [--version live|all] [--any] [--fuzzy] [--json] [--cloud]
54
+ live-plan search <file.plan.md> --query TERMS [--query TERMS] [--version live|N|all] [--any] [--fuzzy] [--json] [--token TOKEN]
55
+ live-plan theme get|set [--accent #hex] [--url <plan-url>] [--config file] [--plan file.plan.md]
56
+ live-plan dump <file.plan.md>
57
+ live-plan processes
58
+ live-plan logs [--level error|warn|log] [--url <plan-url>] [--day YYYY-MM-DD] [--limit N]
59
+ live-plan dashboard [--no-open] [--json] [--any-version]
60
+ live-plan tui [--period day|week|month] [--registry-port N] [--registry-host HOST]
61
+ live-plan registry [--port N] [--host HOST]
62
+ live-plan lan on|off|status
63
+ live-plan account login --url https://host [--headless | --token <token>]
64
+ live-plan skills list|install [--harness <id>]... [--all] [--json]
65
+ live-plan desktop state|configure --json '{...}'|install-cli
66
+ live-plan --version
67
+
68
+ Shortcuts, kept for agents and scripts that use them:
69
+ live-plan review <file.plan.md> [--cloud] [--iteration N] [--timeout 30m] [--out file]
70
+ live-plan watch <file.plan.md>
71
+ live-plan wait <id> <file.plan.md> [--timeout 30m]
72
+ live-plan addressing <comment-id> <file.plan.md>
73
+ live-plan address <comment-id> <file.plan.md> [--outcome implemented|errored|issues]
74
+
75
+ Requires Bun (https://bun.sh). Invoke with \`bunx visual-living-plan <command>\` when the \`live-plan\` command is not installed. \`living-plan\` is the same binary.
76
+
77
+ Plan commands:
78
+ check Print plan summary. Exits 1 when the required workflow block is missing.
79
+ serve Register the plan (on this machine, or the signed-in host with --cloud), print its URL, and return. The page stays up. --listen also waits for the next submissions, as events does.
80
+ events The one listener. Print undelivered submissions as JSON lines, ack them, then exit; start it again after it exits. --follow stays running instead, and also prints a mode line on every mode change, so one process serves the whole plan.
81
+ mode Switch the open session between watch, comment, and review. The open tab follows. --iteration N sets the review round. A verdict then arrives on events as a review line. Review is refused while the person's last verdict has not reached an agent.
82
+ reply Answer a comment and mark it answered. The page already shows the comment in progress once events printed it. --outcome errored or issues records the result. --keep-open leaves it open.
83
+ close Drop a plan from the service.
84
+ execution Optional. After an approval the run follows the plan file: a phase marked active starts it, every step done or one failed ends it. start, push, and stop are for a plan without a review, a custom graph, or ending a run by hand.
85
+
86
+ Shortcuts:
87
+ review serve, mode review, and wait for the verdict in one command. Exits 0 approve, 1 deny, 2 iterate, 3 timeout, 4 the stream was refused or never connected.
88
+ watch mode watch, then events --follow.
89
+ wait Block until one interaction id is answered. Exits 3 on timeout, 4 when the stream was refused or never connected.
90
+ addressing Mark one comment in progress by hand.
91
+ address Mark one comment answered without a reply.
92
+
93
+ Other commands:
94
+ search Find terms across every plan on this machine's service, or every plan on the hosted account with --cloud. A plan file or --url searches one plan instead. Live text only unless --version all (or --version N for one plan). Every term must be in one block unless --any. Across plans the plan title counts toward every block. --fuzzy also matches word starts and small typos. Exits 0 with hits, 2 with none.
95
+ account Sign in to the hosted service. \`account login --url https://host\`. On a machine with no browser, \`--headless\` prints a page that shows a token, then \`--token <token>\` saves it.
96
+ theme Read or write the accent color in live-plan.config.json (or via a running server).
97
+ processes List plans hosted by the service. \`ps\` is the same command.
98
+ logs Print the development log saved under ~/.config/living-plan/logs. Not shown on the page. --day reads one registry day (today when omitted). --url reads one plan.
99
+ dashboard Open the control dashboard (running and executed plans, by day, week, or month). --json prints {"url","service","version"} on one line and opens nothing. --any-version uses a running service of another version instead of restarting it; the desktop app passes both.
100
+ tui The registry in the terminal: running plans, and the day, week, and month dashboard. Starts the plan service when it is not already running. Quitting leaves that service up. Active plans are listed first. Click a control, or use Tab, arrows, p, d, and the number keys.
101
+ registry Run the plan service in the foreground. serve and review start it on their own.
102
+ lan Publish this machine's plan service on the local network. Off until \`lan on\`.
103
+ skills Copy the live-plan skill into agent harnesses: claude-code, codex, cursor, gemini, opencode, agents. \`skills install\` with no --harness uses every harness found on this machine. \`skills list\` shows where it is installed.
104
+ desktop What the desktop app's setup screen runs. \`state\` prints its config as one JSON line. \`configure --json\` changes it: mode (local or cloud), cloudUrl, colorMode, accent, diffsTheme. \`install-cli\` puts live-plan on the PATH from the app.
105
+
106
+ A plan file names the plan for every plan command: its hosted URL when this machine served it with --cloud, otherwise its URL on this machine's service. --url <plan-url> still works, and is needed for a plan served from another machine.
107
+ Every plan includes a \`workflow\` block. That block is the execution path the Workflow tab draws.
108
+ Per-plan accent color is saved in live-plan.config.json beside the plan (override with --config). A plan with no file beside it starts from the machine-wide one.
109
+ Without --plan or --config, theme get/set uses ~/.config/living-plan/live-plan.config.json.
110
+ Service state and diagnostic logs live under ~/.config/living-plan (LIVE_PLAN_HOME / LIVE_PLAN_LOG_HOME override).
111
+ --no-open skips launching a browser.
112
+ Pages open in the Living Plan Mac app when it is installed and the page is a plan or the dashboard on this machine's service (living-plan://plans/<id>) or on the hosted app it is set up with (living-plan://cloud/plans/<id>). Otherwise they open in the installed Living Plan web app (Chrome, Edge, Brave, or Chromium) for that host, and in a browser tab when there is none. LIVE_PLAN_DESKTOP=0 skips the Mac app. LIVE_PLAN_OPEN=browser always uses a tab.
113
+ serve and review open a plan page only the first time on this machine. Resuming the same plan leaves the open tab alone. --open opens it again.
114
+ --version prints the package version and exits. -v is the short flag.
115
+ --detach is accepted and does nothing: serve returns by default.
116
+ events prints a submission that arrived while it was stopped immediately, then exits. Start it again after every comment, denial, or approval so a pending event is not left on the server.
117
+ serve --listen, events, watch, wait, and review reconnect by themselves after a dropped stream, a service restart, or a network change. Submissions sent meanwhile wait on the server and print after the reconnect. A local service that crashed is started again. They stop only on a refusal a retry cannot fix, their own --timeout, or when they never connected.
118
+ The machine service keeps running after serve, events, wait, review, dashboard, and tui exit.
119
+ --no-registry serves this plan in its own process instead of the machine service.
120
+ --port sets that private process port. With the service, --port is used only when the service is not already running.
121
+ --registry-port and --registry-host choose the service (default ${DEFAULT_REGISTRY_HOST}:${DEFAULT_REGISTRY_PORT}).
122
+ The printed URL uses that address. On loopback it is http://127.0.0.1:${DEFAULT_REGISTRY_PORT}/plans/<id>/. --host other than loopback is the address a cloud agent shares.
123
+ LAN publishing is off on a fresh install. \`lan on\` listens on all interfaces, advertises living-plan.local, and prints a LAN URL for other devices. \`serve\` and \`review\` still print the loopback plan URL. The CLI dials 127.0.0.1 and does not resolve *.local.
124
+ --token authorizes the agent event stream. Omitted, the local service token is used.
125
+ --cloud hosts the plan on the signed-in service. It does not start the local registry, and it does not fall back to loopback.
126
+ account login stores the session in ~/.config/living-plan/cloud.json. --token - reads the token from stdin, so it stays out of shell history. LIVE_PLAN_CLOUD_URL sets the host when --url is omitted.
127
+ `);
128
+ }
129
+ function parseTimeout(raw, fallbackMs) {
130
+ if (!raw)
131
+ return fallbackMs;
132
+ const match = raw.trim().match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);
133
+ if (!match) {
134
+ throw new Error(`Invalid timeout: ${raw}`);
135
+ }
136
+ const amount = Number(match[1]);
137
+ const unit = match[2] ?? 'ms';
138
+ const factor = unit === 'h' ? 3_600_000 : unit === 'm' ? 60_000 : unit === 's' ? 1_000 : 1;
139
+ return Math.round(amount * factor);
140
+ }
141
+ function getFlag(args, name) {
142
+ const index = args.indexOf(name);
143
+ if (index === -1)
144
+ return undefined;
145
+ return args[index + 1];
146
+ }
147
+ async function readStdin() {
148
+ const chunks = [];
149
+ for await (const chunk of process.stdin)
150
+ chunks.push(Buffer.from(chunk));
151
+ return Buffer.concat(chunks).toString('utf8').trim();
152
+ }
153
+ /** Every value given for a flag that may repeat, under any of its names. */
154
+ function getFlags(args, ...names) {
155
+ const values = [];
156
+ for (let index = 0; index < args.length - 1; index += 1) {
157
+ if (names.includes(args[index] ?? ''))
158
+ values.push(args[index + 1] ?? '');
159
+ }
160
+ return values;
161
+ }
162
+ function hasFlag(args, name) {
163
+ return args.includes(name);
164
+ }
165
+ /** Open `url` in the Living Plan Mac app or the installed web app when there is one, else a browser tab. */
166
+ async function openBrowser(url) {
167
+ if (hasFlag(process.argv.slice(2), '--no-open'))
168
+ return;
169
+ await openUrl(url);
170
+ }
171
+ /**
172
+ * Open a plan page only the first time. A resumed `serve` or `review` reuses
173
+ * the tab the person already has. `--open` forces it, `--no-open` skips it.
174
+ */
175
+ async function openPlanPage(url) {
176
+ const argv = process.argv.slice(2);
177
+ const choice = await choosePlanOpen(url, {
178
+ noOpen: hasFlag(argv, '--no-open'),
179
+ forceOpen: hasFlag(argv, '--open'),
180
+ }).catch(() => 'open');
181
+ if (choice === 'skip') {
182
+ if (!hasFlag(argv, '--no-open'))
183
+ console.log('Page already opened before. Not opening it again (pass --open to reopen).');
184
+ return;
185
+ }
186
+ await openBrowser(url);
187
+ await rememberPageOpened(url).catch(() => undefined);
188
+ }
189
+ async function ensureClientBuild() {
190
+ const assets = await loadClientAssets();
191
+ if (assets?.mermaidHref && assets.highlightHref && assets.selectorHref && assets.planMdxHref)
192
+ return;
193
+ console.log('Building execution client (vite)...');
194
+ await new Promise((resolveBuild, reject) => {
195
+ const child = spawn(process.execPath, ['x', 'vite', 'build', '--config', 'vite.client.config.ts'], {
196
+ cwd: packageRoot,
197
+ stdio: 'inherit',
198
+ shell: process.platform === 'win32',
199
+ });
200
+ child.on('exit', (code) => {
201
+ if (code === 0)
202
+ resolveBuild();
203
+ else
204
+ reject(new Error(`vite build failed with code ${code}`));
205
+ });
206
+ });
207
+ }
208
+ async function readJsonFile(path) {
209
+ return JSON.parse(await readFile(resolve(path), 'utf8'));
210
+ }
211
+ async function resolveAgentToken(args, planUrl) {
212
+ const explicit = getFlag(args, '--token');
213
+ if (explicit)
214
+ return explicit;
215
+ if (planUrl) {
216
+ const credential = cloudCredential(await readCloudFile(), planUrl);
217
+ if (credential?.kind === 'plan')
218
+ return credential.token;
219
+ if (credential?.kind === 'account')
220
+ return undefined;
221
+ }
222
+ const lock = await readRegistryLock(defaultRegistryHome());
223
+ return lock?.token;
224
+ }
225
+ /** Write one JSON line to stdout without waiting for a block buffer. Agents read this pipe live. */
226
+ function printJsonLine(value) {
227
+ writeSync(1, `${JSON.stringify(value)}\n`);
228
+ }
229
+ /**
230
+ * Record that the CLI printed these submissions. A short outage is retried. A failed ack leaves them
231
+ * pending on the server: a running listener acks them on its next connect, and the next start prints them.
232
+ */
233
+ async function acknowledgeSubmissions(url, token, ids) {
234
+ if (ids.length === 0)
235
+ return true;
236
+ let last;
237
+ for (let attempt = 0; attempt < ACK_TRIES; attempt += 1) {
238
+ if (attempt > 0)
239
+ await new Promise((resolveDelay) => setTimeout(resolveDelay, 500 * 2 ** (attempt - 1)));
240
+ try {
241
+ await ackPlanEvents(url, token, ids);
242
+ return true;
243
+ }
244
+ catch (error) {
245
+ last = error;
246
+ }
247
+ }
248
+ console.error(`Could not mark ${ids.length === 1 ? 'a submission' : `${ids.length} submissions`} delivered: ${last instanceof Error ? last.message : last}. It stays pending on the server.`);
249
+ return false;
250
+ }
251
+ const ACK_TRIES = 3;
252
+ /** True for a URL on this machine's plan service. Only that service can be started again by a client. */
253
+ function onLocalService(url) {
254
+ try {
255
+ const parsed = new URL(url);
256
+ const loopback = ['127.0.0.1', 'localhost', '[::1]'].includes(parsed.hostname);
257
+ return loopback && planIdFromPlanUrl(url) !== null;
258
+ }
259
+ catch {
260
+ return false;
261
+ }
262
+ }
263
+ /**
264
+ * What a listening command tells the agent while its stream is down, and how it recovers: a local
265
+ * service that crashed is started again, and a 401 after a service restart re-reads the service token.
266
+ * stdout stays JSON lines. These notes go to stderr.
267
+ */
268
+ function streamNotices(url, args) {
269
+ return {
270
+ lost(reason, delayMs, wasConnected) {
271
+ const wait = Math.max(1, Math.round(delayMs / 1000));
272
+ console.error(wasConnected
273
+ ? `Lost the plan stream (${reason}). Reconnecting in ${wait}s, and retrying until it is back. Submissions wait on the server meanwhile.`
274
+ : `Could not reach the plan stream (${reason}). Trying again in ${wait}s.`);
275
+ },
276
+ restored() {
277
+ console.error('Reconnected to the plan stream.');
278
+ },
279
+ revive: onLocalService(url)
280
+ ? async () => {
281
+ if (cloudCredential(await readCloudFile(), url))
282
+ return;
283
+ if (await reviveRegistry({ entryFile: fileURLToPath(import.meta.url) })) {
284
+ console.error('The plan service had stopped without shutting down. Started it again.');
285
+ }
286
+ }
287
+ : undefined,
288
+ retoken: () => resolveAgentToken(args, url),
289
+ };
290
+ }
291
+ /** The session moved to another mode. Printed by a listener that stays running; it has no id and needs no ack. */
292
+ function modeLine(data) {
293
+ if (!data || typeof data !== 'object')
294
+ return null;
295
+ const { mode, iteration } = data;
296
+ if (mode !== 'watch' && mode !== 'comment' && mode !== 'review')
297
+ return null;
298
+ return typeof iteration === 'number' && Number.isFinite(iteration) ? { mode, iteration } : { mode };
299
+ }
300
+ /**
301
+ * Print submissions the server has not marked delivered.
302
+ * With `once`, a waiting batch is printed immediately and the process exits; otherwise this waits for the next one and then exits.
303
+ * Without `once`, each batch is printed and the process stays up until it is stopped. It also prints a
304
+ * `mode` line each time the session moves to another mode, so one process can follow watch, comment, and review.
305
+ *
306
+ * Either way the stream is reconnected after a drop, a service restart, or a network change. The hello
307
+ * on each connect carries what was submitted meanwhile, so nothing is skipped.
308
+ */
309
+ async function listenForSubmissions(url, token, once = true, args = []) {
310
+ const controller = new AbortController();
311
+ const stop = () => controller.abort();
312
+ process.once('SIGINT', stop);
313
+ process.once('SIGTERM', stop);
314
+ const bearer = { current: token };
315
+ const printed = new Set();
316
+ const acked = new Set();
317
+ let ackFailed = false;
318
+ let connected = false;
319
+ let seen = null;
320
+ let ackChain = Promise.resolve();
321
+ const later = (work) => {
322
+ ackChain = ackChain.then(work);
323
+ };
324
+ const take = (incoming) => {
325
+ const waiting = incoming
326
+ .filter((submission) => submission.deliveredAt == null)
327
+ .sort((left, right) => left.seq - right.seq);
328
+ const fresh = waiting.filter((submission) => !printed.has(submission.id));
329
+ // Printed before, but the ack never landed. Ack it again without printing it twice.
330
+ const unacked = waiting.filter((submission) => printed.has(submission.id) && !acked.has(submission.id));
331
+ if (fresh.length === 0 && unacked.length === 0)
332
+ return;
333
+ for (const submission of fresh)
334
+ printed.add(submission.id);
335
+ const ids = [...unacked, ...fresh].map((submission) => submission.id);
336
+ later(async () => {
337
+ for (const submission of fresh) {
338
+ // A page edit on a hosted plan lands in the plan file before the agent reads the line.
339
+ if (submission.event === 'edit') {
340
+ const written = await pullPageEdit(url, submission.data).catch((error) => {
341
+ console.error(`Could not write the page edit into the plan file: ${error instanceof Error ? error.message : error}`);
342
+ return null;
343
+ });
344
+ if (written)
345
+ console.error(`Wrote the page edit into ${written}`);
346
+ }
347
+ printJsonLine({ event: submission.event, id: submission.id, seq: submission.seq, data: printableData(submission) });
348
+ }
349
+ if (await acknowledgeSubmissions(url, bearer.current, ids))
350
+ for (const id of ids)
351
+ acked.add(id);
352
+ else
353
+ ackFailed = true;
354
+ });
355
+ if (once && fresh.length > 0)
356
+ controller.abort();
357
+ };
358
+ // The first hello sets the mode. A later change, or one missed while reconnecting, prints a line.
359
+ const followMode = (data) => {
360
+ const line = modeLine(data);
361
+ if (!line)
362
+ return;
363
+ const iteration = line.iteration ?? seen?.iteration;
364
+ const next = iteration === undefined ? { mode: line.mode } : { mode: line.mode, iteration };
365
+ const changed = !seen || seen.mode !== next.mode || seen.iteration !== next.iteration;
366
+ const first = seen === null;
367
+ seen = next;
368
+ if (changed && !first && !once)
369
+ later(() => printJsonLine({ event: 'mode', data: next }));
370
+ };
371
+ let code = 0;
372
+ try {
373
+ await followAgentEvents(url, bearer, (event) => {
374
+ if (event.event === 'hello') {
375
+ connected = true;
376
+ take(pendingFromHello(event.data));
377
+ followMode(event.data);
378
+ return;
379
+ }
380
+ if (event.event === 'mode') {
381
+ followMode(event.data);
382
+ return;
383
+ }
384
+ if (event.event !== 'notice')
385
+ return;
386
+ const submission = submissionEvent(event.data);
387
+ if (submission)
388
+ take([submission]);
389
+ }, controller.signal, streamNotices(url, args));
390
+ }
391
+ catch (error) {
392
+ if (!once && connected && error instanceof AgentStreamRefused && error.status === 404) {
393
+ console.error('The plan is no longer on the service. It was closed. Stopping.');
394
+ }
395
+ else {
396
+ console.error(error instanceof Error ? error.message : error);
397
+ code = 1;
398
+ }
399
+ }
400
+ process.off('SIGINT', stop);
401
+ process.off('SIGTERM', stop);
402
+ await ackChain;
403
+ if (code)
404
+ return code;
405
+ if (once && ackFailed)
406
+ return 1;
407
+ return 0;
408
+ }
409
+ /** The source in a hosted `edit` is already in the plan file. The printed line stays short. */
410
+ function printableData(submission) {
411
+ if (submission.event !== 'edit' || !submission.data || typeof submission.data !== 'object')
412
+ return submission.data;
413
+ const { source: _source, ...rest } = submission.data;
414
+ return rest;
415
+ }
416
+ /** Print the next undelivered submissions for one hosted plan, then exit. The page stays up. */
417
+ async function followPlan(url, token, args) {
418
+ console.log('Listening for submissions. This command prints them and exits. The page stays up.');
419
+ return listenForSubmissions(url, token, true, args);
420
+ }
421
+ async function cloudRequestHeaders(url, args) {
422
+ const credential = cloudCredential(await readCloudFile(), url);
423
+ if (!credential)
424
+ return {};
425
+ const token = await resolveAgentToken(args, url);
426
+ if (!token)
427
+ throw new Error('No plan token for that hosted URL. Pass --token, or serve the plan from this machine.');
428
+ return { authorization: `Bearer ${token}` };
429
+ }
430
+ async function executionRequest(url, path, init) {
431
+ const planId = planIdFromPlanUrl(url) ?? undefined;
432
+ try {
433
+ const headers = {
434
+ 'content-type': 'application/json',
435
+ ...(await cloudRequestHeaders(url, process.argv.slice(2))),
436
+ };
437
+ return await fetch(planApiUrl(url, path), {
438
+ method: init.method,
439
+ headers,
440
+ body: init.body === undefined ? undefined : JSON.stringify(init.body),
441
+ });
442
+ }
443
+ catch (error) {
444
+ const message = error instanceof Error ? error.message : 'Execution request failed';
445
+ await recordLog({
446
+ level: 'error',
447
+ message: `Execution request failed: ${message}`,
448
+ source: 'execution',
449
+ planId,
450
+ echo: false,
451
+ }).catch(() => undefined);
452
+ throw error;
453
+ }
454
+ }
455
+ async function executionFailure(url, response) {
456
+ const text = await response.text();
457
+ await recordLog({
458
+ level: 'error',
459
+ message: `Execution request failed: ${text || response.status}`,
460
+ source: 'execution',
461
+ planId: planIdFromPlanUrl(url) ?? undefined,
462
+ echo: false,
463
+ }).catch(() => undefined);
464
+ return new Error(text || `Execution request failed (${response.status})`);
465
+ }
466
+ async function readExecution(url) {
467
+ const response = await executionRequest(url, '/api/execution', { method: 'GET' });
468
+ if (!response.ok)
469
+ throw await executionFailure(url, response);
470
+ return (await response.json());
471
+ }
472
+ async function putExecution(url, body) {
473
+ const response = await executionRequest(url, '/api/execution', { method: 'PUT', body });
474
+ if (!response.ok)
475
+ throw await executionFailure(url, response);
476
+ const payload = (await response.json());
477
+ return payload.execution;
478
+ }
479
+ /**
480
+ * Start, push, or stop the run. The host merges the fields it is sent into the run it has,
481
+ * so the agent never has to read the run first. A host without that route gets the older
482
+ * read and replace.
483
+ */
484
+ async function changeExecution(url, action, patch) {
485
+ const response = await executionRequest(url, `/api/execution/${action}`, { method: 'POST', body: patch });
486
+ if (response.ok) {
487
+ const payload = (await response.json());
488
+ return payload.execution;
489
+ }
490
+ if (response.status !== 404 && response.status !== 405)
491
+ throw await executionFailure(url, response);
492
+ await response.body?.cancel().catch(() => undefined);
493
+ const current = action === 'start' ? null : await readExecution(url);
494
+ return putExecution(url, applyExecutionChange(current, action, patch));
495
+ }
496
+ async function cmdCheck(file) {
497
+ const source = await readFile(resolve(file), 'utf8');
498
+ const plan = parsePlan(source, file);
499
+ // The same check the watchers run before a change reaches the page: it must compile as MDX.
500
+ const workflowError = workflowRequirementError(plan) ?? (await planNotReadyReason(source));
501
+ const workflow = workflowError ? undefined : planToExpectedGraph(plan);
502
+ console.log(JSON.stringify({
503
+ title: plan.title,
504
+ summary: plan.summary,
505
+ agent: plan.agent,
506
+ blocks: plan.blocks.map((block) => block.type),
507
+ interactionIds: plan.interactionIds,
508
+ workflow: workflow
509
+ ? {
510
+ title: workflow.title,
511
+ nodes: workflow.nodes.map((node) => ({
512
+ id: node.id,
513
+ planRef: node.planRef,
514
+ status: node.status,
515
+ })),
516
+ }
517
+ : null,
518
+ ...(workflowError ? { error: workflowError } : {}),
519
+ }, null, 2));
520
+ if (workflowError) {
521
+ await recordLog({
522
+ level: 'error',
523
+ message: workflowError,
524
+ source: 'parse',
525
+ echo: false,
526
+ }).catch(() => undefined);
527
+ console.error(workflowError);
528
+ return 1;
529
+ }
530
+ return 0;
531
+ }
532
+ async function cmdDump(file) {
533
+ const source = await readFile(resolve(file), 'utf8');
534
+ const plan = parsePlan(source, file);
535
+ console.log(JSON.stringify(plan, null, 2));
536
+ return 0;
537
+ }
538
+ async function openRegistry(args, options) {
539
+ if (hasFlag(args, '--no-registry'))
540
+ return null;
541
+ const portFlag = getFlag(args, '--registry-port') ?? getFlag(args, '--port');
542
+ const port = portFlag ? Number(portFlag) : undefined;
543
+ const host = getFlag(args, '--registry-host') ?? getFlag(args, '--host');
544
+ try {
545
+ return await ensureRegistry({
546
+ entryFile: fileURLToPath(import.meta.url),
547
+ port: port !== undefined && Number.isFinite(port) && port > 0 ? port : undefined,
548
+ host,
549
+ anyVersion: options?.anyVersion,
550
+ });
551
+ }
552
+ catch (error) {
553
+ console.error(`Registry unavailable: ${error instanceof Error ? error.message : error}`);
554
+ return null;
555
+ }
556
+ }
557
+ async function cmdCloudServe(file, args, mode) {
558
+ const conflict = cloudFlagConflict(true, hasFlag(args, '--no-registry'));
559
+ if (conflict) {
560
+ console.error(conflict);
561
+ return 1;
562
+ }
563
+ try {
564
+ const round = mode === 'review' ? readIterationFlag(args) : undefined;
565
+ const record = await prepareCloudPlan({
566
+ planPath: resolve(file),
567
+ mode,
568
+ iteration: round === 'invalid' ? undefined : round,
569
+ });
570
+ console.log(`Living Plan (${mode}): ${record.url}`);
571
+ console.log(`Plan file: ${resolve(file)}`);
572
+ console.log('Hosted plan. The local registry was not started.');
573
+ await openPlanPage(record.url);
574
+ // `serve` registers and returns. `--listen` also waits for the next submissions, as `events` does.
575
+ if (mode === 'watch' && !hasFlag(args, '--listen')) {
576
+ const pid = spawnCloudWatch(fileURLToPath(import.meta.url), record);
577
+ const stored = await readCloudFile();
578
+ const current = stored.plans[record.id];
579
+ if (current) {
580
+ stored.plans[record.id] = { ...current, watchPid: pid };
581
+ await writeCloudFile(stored);
582
+ }
583
+ printListenHint(file);
584
+ return 0;
585
+ }
586
+ const stop = await syncCloudUrl(record.url);
587
+ try {
588
+ if (mode === 'review') {
589
+ const timeoutMs = parseTimeout(getFlag(args, '--timeout'), 4 * 60 * 60 * 1000);
590
+ let held;
591
+ try {
592
+ held = await readReviewEvent(record.url, record.token, timeoutMs, args);
593
+ }
594
+ catch (error) {
595
+ return reviewFailure(error);
596
+ }
597
+ await writeReviewOutput(args, held.review);
598
+ await acknowledgeSubmissions(record.url, held.token, held.eventIds);
599
+ return reviewExitCode(held.review.decision);
600
+ }
601
+ return await followPlan(record.url, record.token, args);
602
+ }
603
+ finally {
604
+ stop();
605
+ }
606
+ }
607
+ catch (error) {
608
+ console.error(error instanceof Error ? error.message : error);
609
+ return 1;
610
+ }
611
+ }
612
+ /** What to run next. The plan file names the plan for every later command. */
613
+ function printListenHint(file) {
614
+ const quoted = /\s/.test(file) ? JSON.stringify(file) : file;
615
+ console.log(`Listen: live-plan events ${quoted} (--follow keeps it running)`);
616
+ }
617
+ async function cmdServe(file, args) {
618
+ if (hasFlag(args, '--cloud'))
619
+ return cmdCloudServe(file, args, 'watch');
620
+ await ensureClientBuild();
621
+ const planPath = resolve(file);
622
+ const configPath = getFlag(args, '--config');
623
+ const registry = await openRegistry(args);
624
+ if (registry) {
625
+ const hosted = await registerHostedPlan(registryBindUrl(registry), registry.token, {
626
+ planPath,
627
+ mode: 'watch',
628
+ cwd: process.cwd(),
629
+ configPath,
630
+ });
631
+ console.log(`Living Plan (watch): ${hosted.url}`);
632
+ console.log(`Plan file: ${planPath}`);
633
+ console.log(`Service: ${registry.url}`);
634
+ console.log('Tabs: Plan (status/forms), Workflow (expected plan, then live React Flow canvas), and Settings (accent, page width).');
635
+ await openPlanPage(hosted.url);
636
+ // `serve` registers and returns. `--listen` also waits for the next submissions, as `events` does.
637
+ if (!hasFlag(args, '--listen')) {
638
+ printListenHint(file);
639
+ return 0;
640
+ }
641
+ return followPlan(rewriteToBindUrl(registry, hosted.url), hosted.token, args);
642
+ }
643
+ const port = Number(getFlag(args, '--port') ?? 0);
644
+ const host = getFlag(args, '--host') ?? '127.0.0.1';
645
+ const server = await startLivingPlanServer({
646
+ planPath,
647
+ mode: 'watch',
648
+ port: Number.isFinite(port) ? port : 0,
649
+ host,
650
+ configPath,
651
+ });
652
+ console.log(`Living Plan (watch): ${server.url}`);
653
+ console.log(`Plan file: ${planPath}`);
654
+ console.log(`Theme config: ${server.getState().theme.configPath}`);
655
+ console.log('Tabs: Plan (status/forms), Workflow (expected plan, then live React Flow canvas), and Settings (accent, page width).');
656
+ await openPlanPage(server.url);
657
+ console.log('Listening for the next submission. This command exits when one arrives.');
658
+ const code = await listenForSubmissions(server.url, undefined, true, args);
659
+ await server.close();
660
+ return code;
661
+ }
662
+ function reviewExitCode(decision) {
663
+ if (decision === 'approve')
664
+ return 0;
665
+ if (decision === 'deny')
666
+ return 1;
667
+ return 2;
668
+ }
669
+ async function writeReviewOutput(args, review) {
670
+ const payload = JSON.stringify(review, null, 2);
671
+ const outPath = getFlag(args, '--out');
672
+ if (outPath) {
673
+ const absolute = resolve(outPath);
674
+ await mkdir(dirname(absolute), { recursive: true });
675
+ await writeFile(absolute, `${payload}\n`, 'utf8');
676
+ }
677
+ console.log(payload);
678
+ }
679
+ /** The command's own `--timeout` ran out. Every other failure of a waiting command is the stream being refused or unreachable. */
680
+ class WaitTimedOut extends Error {
681
+ constructor(message) {
682
+ super(message);
683
+ this.name = 'WaitTimedOut';
684
+ }
685
+ }
686
+ /** `review` exits 3 when its timeout runs out and 4 when the plan stream could not be reached or was refused. */
687
+ function reviewFailure(error) {
688
+ console.error(error instanceof Error ? error.message : error);
689
+ return error instanceof WaitTimedOut ? 3 : 4;
690
+ }
691
+ /**
692
+ * Wait for the review verdict. The stream is reconnected until `timeoutMs` runs out, so a service
693
+ * restart or a dropped connection does not end the review. A verdict sent while it was down arrives
694
+ * in the next hello.
695
+ */
696
+ async function readReviewEvent(url, token, timeoutMs, args = []) {
697
+ const controller = new AbortController();
698
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
699
+ const bearer = { current: token };
700
+ let review;
701
+ let eventIds = [];
702
+ try {
703
+ await followAgentEvents(url, bearer, ({ event, data }) => {
704
+ if (review)
705
+ return;
706
+ if (event === 'hello') {
707
+ const hello = data;
708
+ if (hello.review?.decision) {
709
+ review = hello.review;
710
+ eventIds = pendingFromHello(data)
711
+ .filter((submission) => submission.event === 'review')
712
+ .map((submission) => submission.id);
713
+ controller.abort();
714
+ }
715
+ }
716
+ if (event === 'notice') {
717
+ const submission = submissionEvent(data);
718
+ if (submission?.event === 'review') {
719
+ review = submission.data;
720
+ eventIds = [submission.id];
721
+ controller.abort();
722
+ }
723
+ }
724
+ }, controller.signal, streamNotices(url, args));
725
+ }
726
+ finally {
727
+ clearTimeout(timer);
728
+ }
729
+ if (!review)
730
+ throw new WaitTimedOut('Timed out waiting for review decision');
731
+ return { review, eventIds, token: bearer.current };
732
+ }
733
+ async function readHeldUrl(child) {
734
+ const stdout = child.stdout;
735
+ if (!stdout)
736
+ throw new Error('Review server did not report its URL');
737
+ return await new Promise((resolveUrl, reject) => {
738
+ let buffer = '';
739
+ const timer = setTimeout(() => {
740
+ cleanup();
741
+ reject(new Error('Timed out waiting for the review server'));
742
+ }, 15_000);
743
+ const onData = (chunk) => {
744
+ buffer += typeof chunk === 'string' ? chunk : chunk.toString('utf8');
745
+ const match = buffer.match(/LIVING_PLAN_URL (\S+)/);
746
+ const url = match?.[1];
747
+ if (!url)
748
+ return;
749
+ cleanup();
750
+ resolveUrl(url);
751
+ };
752
+ const onExit = (code) => {
753
+ cleanup();
754
+ reject(new Error(`Review server exited before it was ready (${code ?? 'unknown'})`));
755
+ };
756
+ const cleanup = () => {
757
+ clearTimeout(timer);
758
+ stdout.off('data', onData);
759
+ child.off('exit', onExit);
760
+ };
761
+ stdout.on('data', onData);
762
+ child.on('exit', onExit);
763
+ child.on('error', (error) => {
764
+ cleanup();
765
+ reject(error);
766
+ });
767
+ });
768
+ }
769
+ async function holdPrivateReview(file, args) {
770
+ const iteration = Number(getFlag(args, '--iteration') ?? 1);
771
+ const timeoutMs = parseTimeout(getFlag(args, '--timeout'), 4 * 60 * 60 * 1000);
772
+ const planPath = resolve(file);
773
+ const configPath = getFlag(args, '--config');
774
+ const port = Number(getFlag(args, '--port') ?? 0);
775
+ const host = getFlag(args, '--host') ?? '127.0.0.1';
776
+ const server = await startLivingPlanServer({
777
+ planPath,
778
+ mode: 'review',
779
+ port: Number.isFinite(port) ? port : 0,
780
+ host,
781
+ iteration: Number.isFinite(iteration) ? iteration : 1,
782
+ configPath,
783
+ });
784
+ writeSync(1, `LIVING_PLAN_URL ${server.url}\n`);
785
+ try {
786
+ const review = await server.waitForReview(timeoutMs);
787
+ if (review.decision === 'iterate') {
788
+ await new Promise(() => { });
789
+ }
790
+ return reviewExitCode(review.decision);
791
+ }
792
+ finally {
793
+ await server.close();
794
+ }
795
+ }
796
+ async function privateReview(file, args) {
797
+ const timeoutMs = parseTimeout(getFlag(args, '--timeout'), 4 * 60 * 60 * 1000);
798
+ const planPath = resolve(file);
799
+ const entry = fileURLToPath(import.meta.url);
800
+ const child = spawn(process.execPath, [entry, ...process.argv.slice(2)], {
801
+ detached: true,
802
+ stdio: ['ignore', 'pipe', 'ignore'],
803
+ env: { ...process.env, LIVE_PLAN_REVIEW_HOLD: '1', LIVE_PLAN_DAEMON: '1' },
804
+ });
805
+ try {
806
+ const url = await readHeldUrl(child);
807
+ child.unref();
808
+ const stdout = child.stdout;
809
+ if (stdout && 'unref' in stdout)
810
+ stdout.unref();
811
+ console.log(`Living Plan (review): ${url}`);
812
+ console.log(`Plan file: ${planPath}`);
813
+ await openPlanPage(url);
814
+ const held = await readReviewEvent(url, undefined, timeoutMs, args);
815
+ await writeReviewOutput(args, held.review);
816
+ await acknowledgeSubmissions(url, held.token, held.eventIds);
817
+ return reviewExitCode(held.review.decision);
818
+ }
819
+ catch (error) {
820
+ if (child.exitCode == null && !child.killed)
821
+ child.kill();
822
+ return reviewFailure(error);
823
+ }
824
+ }
825
+ async function cmdReview(file, args) {
826
+ if (process.env.LIVE_PLAN_REVIEW_HOLD === '1')
827
+ return holdPrivateReview(file, args);
828
+ if (hasFlag(args, '--cloud'))
829
+ return cmdCloudServe(file, args, 'review');
830
+ await ensureClientBuild();
831
+ const iteration = Number(getFlag(args, '--iteration') ?? 1);
832
+ const timeoutMs = parseTimeout(getFlag(args, '--timeout'), 4 * 60 * 60 * 1000);
833
+ const planPath = resolve(file);
834
+ const configPath = getFlag(args, '--config');
835
+ const registry = await openRegistry(args);
836
+ if (registry) {
837
+ const hosted = await registerHostedPlan(registryBindUrl(registry), registry.token, {
838
+ planPath,
839
+ mode: 'review',
840
+ iteration: Number.isFinite(iteration) ? iteration : 1,
841
+ cwd: process.cwd(),
842
+ configPath,
843
+ });
844
+ console.log(`Living Plan (review): ${hosted.url}`);
845
+ console.log(`Plan file: ${planPath}`);
846
+ console.log(`Service: ${registry.url}`);
847
+ await openPlanPage(hosted.url);
848
+ try {
849
+ const apiUrl = rewriteToBindUrl(registry, hosted.url);
850
+ const held = await readReviewEvent(apiUrl, hosted.token, timeoutMs, args);
851
+ await writeReviewOutput(args, held.review);
852
+ await acknowledgeSubmissions(apiUrl, held.token, held.eventIds);
853
+ return reviewExitCode(held.review.decision);
854
+ }
855
+ catch (error) {
856
+ return reviewFailure(error);
857
+ }
858
+ }
859
+ return privateReview(file, args);
860
+ }
861
+ async function cmdWait(id, args) {
862
+ const published = await planUrlArg(args, 'Usage: live-plan wait <id> <plan-file|--url plan-url> [--timeout 30m]');
863
+ if (!published)
864
+ return 1;
865
+ const url = await localServiceUrl(published);
866
+ const timeoutMs = parseTimeout(getFlag(args, '--timeout'), 4 * 60 * 60 * 1000);
867
+ const bearer = { current: await resolveAgentToken(args, url) };
868
+ const stop = await syncCloudUrl(url);
869
+ const controller = new AbortController();
870
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
871
+ let printed = false;
872
+ let eventIds = [];
873
+ try {
874
+ // Reconnects until the timeout, so a service restart while the person answers does not end the wait.
875
+ await followAgentEvents(url, bearer, ({ event, data }) => {
876
+ if (printed)
877
+ return;
878
+ if (event === 'hello') {
879
+ const responses = data.responses;
880
+ const found = responses?.[id];
881
+ if (found) {
882
+ console.log(JSON.stringify(found, null, 2));
883
+ printed = true;
884
+ eventIds = pendingFromHello(data)
885
+ .filter((submission) => submission.event === 'interaction' && submission.data.id === id)
886
+ .map((submission) => submission.id);
887
+ controller.abort();
888
+ }
889
+ }
890
+ if (event === 'notice') {
891
+ const submission = submissionEvent(data);
892
+ const response = submission?.data;
893
+ if (submission?.event === 'interaction' && response?.id === id) {
894
+ console.log(JSON.stringify(submission.data, null, 2));
895
+ printed = true;
896
+ eventIds = [submission.id];
897
+ controller.abort();
898
+ }
899
+ }
900
+ }, controller.signal, streamNotices(url, args));
901
+ }
902
+ catch (error) {
903
+ if (!printed) {
904
+ console.error(error instanceof Error ? error.message : error);
905
+ return 4;
906
+ }
907
+ }
908
+ finally {
909
+ clearTimeout(timer);
910
+ stop();
911
+ }
912
+ if (!printed) {
913
+ console.error(`Timed out waiting for interaction: ${id}`);
914
+ return 3;
915
+ }
916
+ await acknowledgeSubmissions(url, bearer.current, eventIds);
917
+ return 0;
918
+ }
919
+ async function cmdEvents(args) {
920
+ const published = await planUrlArg(args, 'Usage: live-plan events <plan-file|--url plan-url> [--follow]');
921
+ if (!published)
922
+ return 1;
923
+ const url = await localServiceUrl(published);
924
+ const token = await resolveAgentToken(args, url);
925
+ const follow = args.includes('--follow');
926
+ console.error(follow
927
+ ? 'Listening for submissions. Each one prints as it arrives. This command stays running until it is stopped.'
928
+ : 'Listening for the next submission.');
929
+ const stop = await syncCloudUrl(url);
930
+ try {
931
+ return await listenForSubmissions(url, token, !follow, args);
932
+ }
933
+ finally {
934
+ stop();
935
+ }
936
+ }
937
+ async function cmdWatch(args) {
938
+ const published = await planUrlArg(args, 'Usage: live-plan watch <plan-file|--url plan-url>');
939
+ if (!published)
940
+ return 1;
941
+ const url = await localServiceUrl(published);
942
+ const token = await resolveAgentToken(args, url);
943
+ const headers = {
944
+ 'content-type': 'application/json',
945
+ ...(await cloudRequestHeaders(url, args)),
946
+ };
947
+ const response = await fetch(planApiUrl(url, '/api/mode'), {
948
+ method: 'POST',
949
+ headers,
950
+ body: JSON.stringify({ mode: 'watch' }),
951
+ });
952
+ if (!response.ok) {
953
+ console.error(await response.text());
954
+ return 1;
955
+ }
956
+ console.error('Watching plan execution. This command stays running. Stop it when execution is finished.');
957
+ const stop = await syncCloudUrl(url);
958
+ try {
959
+ return await listenForSubmissions(url, token, false, args);
960
+ }
961
+ finally {
962
+ stop();
963
+ }
964
+ }
965
+ /** `--iteration N` as a review round. Omitted keeps the round. */
966
+ function readIterationFlag(args) {
967
+ if (!hasFlag(args, '--iteration'))
968
+ return undefined;
969
+ return readIteration(getFlag(args, '--iteration') ?? '');
970
+ }
971
+ async function cmdMode(args) {
972
+ const mode = args[0];
973
+ if (mode !== 'watch' && mode !== 'comment' && mode !== 'review') {
974
+ console.error('Usage: live-plan mode <watch|comment|review> <plan-file|--url plan-url> [--iteration N]');
975
+ return 1;
976
+ }
977
+ const published = await planUrlArg(args, 'Usage: live-plan mode <watch|comment|review> <plan-file|--url plan-url> [--iteration N]');
978
+ if (!published)
979
+ return 1;
980
+ const iteration = readIterationFlag(args);
981
+ if (iteration === 'invalid') {
982
+ console.error('--iteration takes a whole number of 1 or more');
983
+ return 1;
984
+ }
985
+ const url = await localServiceUrl(published);
986
+ const headers = {
987
+ 'content-type': 'application/json',
988
+ ...(await cloudRequestHeaders(url, args)),
989
+ };
990
+ const response = await fetch(planApiUrl(url, '/api/mode'), {
991
+ method: 'POST',
992
+ headers,
993
+ body: JSON.stringify(iteration === undefined ? { mode } : { mode, iteration }),
994
+ });
995
+ if (!response.ok) {
996
+ console.error(await response.text());
997
+ return 1;
998
+ }
999
+ console.log(JSON.stringify(await response.json(), null, 2));
1000
+ return 0;
1001
+ }
1002
+ /** The plan URL from `--url`, or from the plan file. Prints `usage` when the command was given neither. */
1003
+ async function planUrlArg(args, usage) {
1004
+ try {
1005
+ const url = await resolvePlanUrl(args);
1006
+ if (!url)
1007
+ console.error(usage);
1008
+ return url;
1009
+ }
1010
+ catch (error) {
1011
+ console.error(error instanceof Error ? error.message : error);
1012
+ return null;
1013
+ }
1014
+ }
1015
+ async function postPlan(published, apiPath, body, options = {}) {
1016
+ const url = await localServiceUrl(published);
1017
+ const headers = {
1018
+ ...(body === undefined ? {} : { 'content-type': 'application/json' }),
1019
+ ...(await cloudRequestHeaders(url, process.argv.slice(2))),
1020
+ };
1021
+ const response = await fetch(planApiUrl(url, apiPath), {
1022
+ method: 'POST',
1023
+ headers,
1024
+ body: body === undefined ? undefined : JSON.stringify(body),
1025
+ });
1026
+ if (!response.ok) {
1027
+ console.error(await response.text());
1028
+ return 1;
1029
+ }
1030
+ const payload = await response.json();
1031
+ if (!options.quiet)
1032
+ console.log(JSON.stringify(payload, null, 2));
1033
+ return 0;
1034
+ }
1035
+ function commentIdFrom(args) {
1036
+ const commentId = args[0];
1037
+ if (!commentId || commentId.startsWith('--'))
1038
+ return undefined;
1039
+ return commentId;
1040
+ }
1041
+ /**
1042
+ * Answer a comment in one command: write the reply and mark it answered. The page already shows the
1043
+ * comment in progress once a listener printed it. `--keep-open` writes the reply and leaves it open.
1044
+ */
1045
+ async function cmdReply(args) {
1046
+ const usage = 'Usage: live-plan reply <comment-id> <plan-file|--url plan-url> --text "..." [--outcome implemented|errored|issues] [--keep-open]';
1047
+ const commentId = commentIdFrom(args);
1048
+ const text = getFlag(args, '--text');
1049
+ const outcome = getFlag(args, '--outcome');
1050
+ if (!commentId || text == null) {
1051
+ console.error(usage);
1052
+ return 1;
1053
+ }
1054
+ if (hasFlag(args, '--outcome') && outcome !== 'implemented' && outcome !== 'errored' && outcome !== 'issues') {
1055
+ console.error(usage);
1056
+ return 1;
1057
+ }
1058
+ if (hasFlag(args, '--outcome') && hasFlag(args, '--keep-open')) {
1059
+ console.error('--outcome closes the comment. Leave it out with --keep-open.');
1060
+ return 1;
1061
+ }
1062
+ const published = await planUrlArg(args, usage);
1063
+ if (!published)
1064
+ return 1;
1065
+ const path = `/api/comments/${encodeURIComponent(commentId)}`;
1066
+ if (hasFlag(args, '--keep-open'))
1067
+ return postPlan(published, `${path}/reply`, { text });
1068
+ const replied = await postPlan(published, `${path}/reply`, { text }, { quiet: true });
1069
+ if (replied !== 0)
1070
+ return replied;
1071
+ return postPlan(published, `${path}/address`, outcome ? { outcome } : undefined);
1072
+ }
1073
+ /** Optional: mark a comment in progress before a listener printed it. */
1074
+ async function cmdAddressing(args) {
1075
+ const usage = 'Usage: live-plan addressing <comment-id> <plan-file|--url plan-url>';
1076
+ const commentId = commentIdFrom(args);
1077
+ if (!commentId) {
1078
+ console.error(usage);
1079
+ return 1;
1080
+ }
1081
+ const published = await planUrlArg(args, usage);
1082
+ if (!published)
1083
+ return 1;
1084
+ return postPlan(published, `/api/comments/${encodeURIComponent(commentId)}/addressing`);
1085
+ }
1086
+ /** Mark a comment answered without a reply. `reply` does this too. */
1087
+ async function cmdAddress(args) {
1088
+ const usage = 'Usage: live-plan address <comment-id> <plan-file|--url plan-url> [--outcome implemented|errored|issues]';
1089
+ const commentId = commentIdFrom(args);
1090
+ const outcome = getFlag(args, '--outcome');
1091
+ if (!commentId) {
1092
+ console.error(usage);
1093
+ return 1;
1094
+ }
1095
+ if (hasFlag(args, '--outcome') && outcome !== 'implemented' && outcome !== 'errored' && outcome !== 'issues') {
1096
+ console.error(usage);
1097
+ return 1;
1098
+ }
1099
+ const published = await planUrlArg(args, usage);
1100
+ if (!published)
1101
+ return 1;
1102
+ return postPlan(published, `/api/comments/${encodeURIComponent(commentId)}/address`, outcome ? { outcome } : undefined);
1103
+ }
1104
+ async function cmdSearch(args) {
1105
+ const usage = [
1106
+ 'Usage: live-plan search --query TERMS [--query TERMS] [--version live|all] [--any] [--fuzzy] [--json] [--cloud]',
1107
+ ' live-plan search <plan-file|--url plan-url> --query TERMS [--version live|N|all] [--any] [--fuzzy] [--json] [--token TOKEN]',
1108
+ ].join('\n');
1109
+ let published;
1110
+ try {
1111
+ published = await resolvePlanUrl(args);
1112
+ }
1113
+ catch (error) {
1114
+ console.error(error instanceof Error ? error.message : error);
1115
+ return 1;
1116
+ }
1117
+ const queries = getFlags(args, '--query', '-q').filter((value) => value.trim());
1118
+ const version = getFlag(args, '--version');
1119
+ if (queries.length === 0 || (hasFlag(args, '--version') && !version) || (hasFlag(args, '--url') && !published)) {
1120
+ console.error(usage);
1121
+ return 1;
1122
+ }
1123
+ if (published && hasFlag(args, '--cloud')) {
1124
+ console.error('--cloud searches all plans on the account. Leave it out with --url: the URL already names the host.');
1125
+ return 1;
1126
+ }
1127
+ const params = new URLSearchParams({ q: queries.join(' ') });
1128
+ if (version && version !== 'live')
1129
+ params.set('version', version);
1130
+ if (hasFlag(args, '--any'))
1131
+ params.set('match', 'any');
1132
+ if (hasFlag(args, '--fuzzy'))
1133
+ params.set('fuzzy', 'on');
1134
+ if (!published)
1135
+ return searchAllPlans(args, params);
1136
+ const url = await localServiceUrl(published);
1137
+ const response = await fetch(planApiUrl(url, `/api/search?${params}`), {
1138
+ headers: await cloudRequestHeaders(url, args),
1139
+ });
1140
+ if (!response.ok) {
1141
+ console.error((await response.text()) || `Search failed with HTTP ${response.status}`);
1142
+ return 1;
1143
+ }
1144
+ const result = (await response.json());
1145
+ if (hasFlag(args, '--json'))
1146
+ console.log(JSON.stringify(result, null, 2));
1147
+ else
1148
+ console.log(formatSearchResponse(result));
1149
+ return result.versions.some((entry) => entry.hits.length > 0) ? 0 : 2;
1150
+ }
1151
+ /** `search` without `--url`: every plan on this machine's service, or with `--cloud` every plan on the account. */
1152
+ async function searchAllPlans(args, params) {
1153
+ if (/^\d+$/.test(params.get('version') ?? '')) {
1154
+ console.error('A version number applies to one plan. Pass --url <plan-url> with it, or use --version all.');
1155
+ return 1;
1156
+ }
1157
+ let endpoint;
1158
+ let base;
1159
+ const headers = {};
1160
+ if (hasFlag(args, '--cloud')) {
1161
+ const account = (await readCloudFile()).account;
1162
+ if (!account) {
1163
+ console.error('No hosted account. Run live-plan account login --url https://your-host');
1164
+ return 1;
1165
+ }
1166
+ base = account.baseUrl;
1167
+ endpoint = new URL(`/api/account/search?${params}`, base).href;
1168
+ headers.authorization = `Bearer ${account.token}`;
1169
+ }
1170
+ else {
1171
+ const registry = await openRegistry(args);
1172
+ if (!registry) {
1173
+ console.error('The plan service on this machine is not available.');
1174
+ return 1;
1175
+ }
1176
+ base = registry.url;
1177
+ endpoint = new URL(`/api/dashboard/search?${params}`, registryBindUrl(registry)).href;
1178
+ }
1179
+ let response;
1180
+ try {
1181
+ response = await fetch(endpoint, { headers, cache: 'no-store' });
1182
+ }
1183
+ catch (error) {
1184
+ console.error(`Search failed: ${error instanceof Error ? error.message : error}`);
1185
+ return 1;
1186
+ }
1187
+ if (!response.ok) {
1188
+ const body = await response.text();
1189
+ let message = body;
1190
+ try {
1191
+ message = JSON.parse(body).error ?? body;
1192
+ }
1193
+ catch {
1194
+ // Plain text from the host.
1195
+ }
1196
+ if (response.status === 401)
1197
+ message = 'Sign in required. Run live-plan account login --url ' + base;
1198
+ if (response.status === 404 && hasFlag(args, '--cloud'))
1199
+ message = `${base} does not offer plan search yet. It needs a host deployed with this version.`;
1200
+ console.error(message || `Search failed with HTTP ${response.status}`);
1201
+ return 1;
1202
+ }
1203
+ const result = (await response.json());
1204
+ if (hasFlag(args, '--json'))
1205
+ console.log(JSON.stringify(result, null, 2));
1206
+ else
1207
+ console.log(formatDashboardSearch(result, base));
1208
+ return result.plans.length > 0 ? 0 : 2;
1209
+ }
1210
+ async function cmdClose(args) {
1211
+ const url = await planUrlArg(args, 'Usage: live-plan close <plan-file|--url plan-url>');
1212
+ if (!url)
1213
+ return 1;
1214
+ const stored = await readCloudFile();
1215
+ const hosted = planRecordForUrl(stored, url);
1216
+ if (hosted || cloudCredential(stored, url)) {
1217
+ if (!hosted) {
1218
+ console.error('No plan token for that hosted URL. Pass --token, or serve the plan from this machine.');
1219
+ return 1;
1220
+ }
1221
+ const token = (await resolveAgentToken(args, url)) ?? hosted.token;
1222
+ await closeCloudPlan(hosted.url, token);
1223
+ stopCloudWatch(hosted.watchPid);
1224
+ delete stored.plans[hosted.id];
1225
+ await writeCloudFile(stored);
1226
+ console.log(`Closed ${url}`);
1227
+ return 0;
1228
+ }
1229
+ const id = planIdFromPlanUrl(url);
1230
+ if (!id) {
1231
+ console.error('That URL is not a plan hosted by the service.');
1232
+ return 1;
1233
+ }
1234
+ const token = await resolveAgentToken(args, url);
1235
+ if (!token) {
1236
+ console.error('No service token found. Pass --token.');
1237
+ return 1;
1238
+ }
1239
+ const origin = new URL(await localServiceUrl(url)).origin;
1240
+ await closeHostedPlan(origin, token, id);
1241
+ console.log(`Closed ${url}`);
1242
+ return 0;
1243
+ }
1244
+ async function buildExecutionPatch(args) {
1245
+ const graphPath = getFlag(args, '--graph');
1246
+ const scenePath = getFlag(args, '--scene');
1247
+ const patch = {};
1248
+ const step = getFlag(args, '--step');
1249
+ const detail = getFlag(args, '--detail');
1250
+ if (step)
1251
+ patch.step = step;
1252
+ if (detail)
1253
+ patch.detail = detail;
1254
+ if (graphPath)
1255
+ patch.graph = await readJsonFile(graphPath);
1256
+ if (scenePath)
1257
+ patch.scene = await readJsonFile(scenePath);
1258
+ return patch;
1259
+ }
1260
+ async function cmdExecution(args) {
1261
+ const action = args[0];
1262
+ const rest = args.slice(1);
1263
+ const published = await planUrlArg(rest, 'Usage: live-plan execution start|push|stop <plan-file|--url plan-url> [--step TEXT] [--detail TEXT] [--graph file.json]');
1264
+ if (!published)
1265
+ return 1;
1266
+ const url = await localServiceUrl(published);
1267
+ if (action === 'start' || action === 'push' || action === 'stop') {
1268
+ const execution = await changeExecution(url, action, await buildExecutionPatch(rest));
1269
+ console.log(JSON.stringify(execution, null, 2));
1270
+ return 0;
1271
+ }
1272
+ console.error('Usage: live-plan execution <start|push|stop> --url <server-url>');
1273
+ return 1;
1274
+ }
1275
+ async function cmdProcesses() {
1276
+ const home = defaultRegistryHome();
1277
+ const lock = await readRegistryLock(home);
1278
+ if (!lock || !isPidAlive(lock.pid) || !(await registryHealthy(registryBindUrl(lock)))) {
1279
+ console.log('No live-plan registry is running.');
1280
+ return 0;
1281
+ }
1282
+ const processes = await listProcesses(registryBindUrl(lock));
1283
+ const noun = processes.length === 1 ? 'plan' : 'plans';
1284
+ console.log(`${processes.length} running ${noun} · ${lock.url}`);
1285
+ console.log(`Dashboard: ${new URL('/dashboard', lock.url).href}`);
1286
+ for (const entry of processes) {
1287
+ console.log('');
1288
+ console.log(entry.title);
1289
+ console.log(` ${entry.mode} ${entry.url}`);
1290
+ console.log(` ${entry.directory}`);
1291
+ console.log(` ${entry.git.summary}`);
1292
+ if (entry.executionActive) {
1293
+ console.log(` executing: ${entry.executionStep ?? 'live'}`);
1294
+ }
1295
+ }
1296
+ return 0;
1297
+ }
1298
+ async function cmdLogs(args) {
1299
+ const level = getFlag(args, '--level');
1300
+ if (hasFlag(args, '--level') && !level) {
1301
+ console.error('level must be error, warn, or log');
1302
+ return 1;
1303
+ }
1304
+ if (level && level !== 'error' && level !== 'warn' && level !== 'log') {
1305
+ console.error('level must be error, warn, or log');
1306
+ return 1;
1307
+ }
1308
+ const limitFlag = getFlag(args, '--limit');
1309
+ if (hasFlag(args, '--limit') && !limitFlag) {
1310
+ console.error('limit must be from 1 to 500');
1311
+ return 1;
1312
+ }
1313
+ const limit = limitFlag ? Number(limitFlag) : undefined;
1314
+ if (limitFlag && (!Number.isInteger(limit) || (limit ?? 0) < 1 || (limit ?? 0) > 500)) {
1315
+ console.error('limit must be from 1 to 500');
1316
+ return 1;
1317
+ }
1318
+ const urlFlag = getFlag(args, '--url');
1319
+ if (hasFlag(args, '--url') && !urlFlag) {
1320
+ console.error('live-plan logs --url needs a plan URL');
1321
+ return 1;
1322
+ }
1323
+ let planId;
1324
+ if (urlFlag) {
1325
+ const parsed = planIdFromPlanUrl(urlFlag);
1326
+ if (!parsed) {
1327
+ console.error("That URL has no plan id. Omit --url to read today's registry log.");
1328
+ return 1;
1329
+ }
1330
+ planId = parsed;
1331
+ }
1332
+ else {
1333
+ const day = getFlag(args, '--day');
1334
+ if (hasFlag(args, '--day') && (!day || !isLogDay(day))) {
1335
+ console.error('day must be YYYY-MM-DD');
1336
+ return 1;
1337
+ }
1338
+ const logs = await listLogs({
1339
+ level: level,
1340
+ limit,
1341
+ day,
1342
+ });
1343
+ console.log(formatServiceLogLines(logs));
1344
+ return 0;
1345
+ }
1346
+ const logs = await listLogs({
1347
+ level: level,
1348
+ planId,
1349
+ limit,
1350
+ });
1351
+ console.log(formatServiceLogLines(logs));
1352
+ return 0;
1353
+ }
1354
+ async function cmdDashboard(args) {
1355
+ const registry = await openRegistry(args, { anyVersion: hasFlag(args, '--any-version') });
1356
+ if (!registry) {
1357
+ console.error('Registry unavailable.');
1358
+ return 1;
1359
+ }
1360
+ if (hasFlag(args, '--json')) {
1361
+ // One line for a program such as the desktop app. Both URLs are the address this machine dials.
1362
+ const service = registryBindUrl(registry);
1363
+ console.log(JSON.stringify({ url: new URL('/dashboard', service).href, service, version: registry.version }));
1364
+ return 0;
1365
+ }
1366
+ const url = new URL('/dashboard', registry.url).href;
1367
+ console.log(`Plan dashboard: ${url}`);
1368
+ // Open the address this machine dials: a LAN name would need the LAN secret, and the apps know the loopback one.
1369
+ await openBrowser(new URL('/dashboard', registryBindUrl(registry)).href);
1370
+ return 0;
1371
+ }
1372
+ async function cmdRegistry(args) {
1373
+ const { startRegistryServer } = await import('./registryService');
1374
+ const home = defaultRegistryHome();
1375
+ const portFlag = getFlag(args, '--port');
1376
+ const port = portFlag ? Number(portFlag) : DEFAULT_REGISTRY_PORT;
1377
+ const { chooseBindHost, readLanEnabled } = await import('./lanConfig');
1378
+ const host = chooseBindHost(getFlag(args, '--host'), await readLanEnabled(home));
1379
+ const version = await readPackageVersion(fileURLToPath(import.meta.url));
1380
+ const existing = await readRegistryLock(home);
1381
+ if (existing && existing.version === version && isPidAlive(existing.pid) && (await registryHealthy(registryBindUrl(existing)))) {
1382
+ console.log(`Living Plan service already running: ${existing.url}`);
1383
+ return 0;
1384
+ }
1385
+ if (existing && isPidAlive(existing.pid) && (await registryHealthy(registryBindUrl(existing)))) {
1386
+ try {
1387
+ process.kill(existing.pid, 'SIGTERM');
1388
+ }
1389
+ catch {
1390
+ // The previous service already exited.
1391
+ }
1392
+ const started = Date.now();
1393
+ while (isPidAlive(existing.pid) && Date.now() - started < 1_500) {
1394
+ await new Promise((resolveDelay) => setTimeout(resolveDelay, 50));
1395
+ }
1396
+ }
1397
+ const registryPort = Number.isFinite(port) ? port : DEFAULT_REGISTRY_PORT;
1398
+ const server = await startRegistryServer({
1399
+ home,
1400
+ host,
1401
+ port: registryPort,
1402
+ version,
1403
+ });
1404
+ console.log(`Living Plan service: ${server.url}`);
1405
+ await new Promise((resolveWait) => {
1406
+ const stop = () => resolveWait();
1407
+ process.once('SIGINT', stop);
1408
+ process.once('SIGTERM', stop);
1409
+ });
1410
+ await server.close();
1411
+ return 0;
1412
+ }
1413
+ async function resolveThemeConfigPath(args, options) {
1414
+ const explicit = getFlag(args, '--config');
1415
+ if (explicit)
1416
+ return resolve(explicit);
1417
+ const plan = getFlag(args, '--plan');
1418
+ if (plan)
1419
+ return configPathBesidePlan(plan);
1420
+ const preferred = globalThemeConfigPath();
1421
+ if (options?.forWrite)
1422
+ return preferred;
1423
+ try {
1424
+ await access(preferred);
1425
+ return preferred;
1426
+ }
1427
+ catch {
1428
+ // Older installs wrote a CWD live-plan.config.json when theme ran without --plan.
1429
+ const cwdPath = cwdThemeConfigPath();
1430
+ try {
1431
+ await access(cwdPath);
1432
+ return cwdPath;
1433
+ }
1434
+ catch {
1435
+ return preferred;
1436
+ }
1437
+ }
1438
+ }
1439
+ async function cmdTheme(args) {
1440
+ const action = args[0];
1441
+ const rest = args.slice(1);
1442
+ const published = getFlag(rest, '--url');
1443
+ const url = published ? await localServiceUrl(published) : undefined;
1444
+ if (action === 'get') {
1445
+ if (url) {
1446
+ const response = await fetch(planApiUrl(url, '/api/theme'));
1447
+ if (!response.ok) {
1448
+ console.error(await response.text());
1449
+ return 1;
1450
+ }
1451
+ console.log(JSON.stringify(await response.json(), null, 2));
1452
+ return 0;
1453
+ }
1454
+ const configPath = await resolveThemeConfigPath(rest);
1455
+ const config = await loadThemeConfig(configPath);
1456
+ console.log(JSON.stringify(themePayload(config, configPath), null, 2));
1457
+ return 0;
1458
+ }
1459
+ if (action === 'set') {
1460
+ const accentRaw = getFlag(rest, '--accent') ?? rest.find((arg) => arg.startsWith('#'));
1461
+ const accent = normalizeAccent(accentRaw);
1462
+ if (!accent) {
1463
+ console.error(`Usage: live-plan theme set --accent ${DEFAULT_ACCENT} [--url <server-url>] [--config file] [--plan file.plan.md]`);
1464
+ return 1;
1465
+ }
1466
+ if (url) {
1467
+ const response = await fetch(planApiUrl(url, '/api/theme'), {
1468
+ method: 'PUT',
1469
+ headers: { 'content-type': 'application/json' },
1470
+ body: JSON.stringify({ accent }),
1471
+ });
1472
+ if (!response.ok) {
1473
+ console.error(await response.text());
1474
+ return 1;
1475
+ }
1476
+ console.log(JSON.stringify(await response.json(), null, 2));
1477
+ return 0;
1478
+ }
1479
+ const readPath = await resolveThemeConfigPath(rest);
1480
+ const writePath = await resolveThemeConfigPath(rest, { forWrite: true });
1481
+ const current = await loadThemeConfig(readPath);
1482
+ const saved = await saveThemeConfig(writePath, { ...current, accent });
1483
+ console.log(JSON.stringify(themePayload(saved, writePath), null, 2));
1484
+ return 0;
1485
+ }
1486
+ console.error('Usage: live-plan theme <get|set> [--accent #hex] [--url <server-url>] [--config file]');
1487
+ return 1;
1488
+ }
1489
+ async function main() {
1490
+ const args = process.argv.slice(2);
1491
+ const command = args[0];
1492
+ // `search --version N` picks a saved plan version, so it is not the package version flag there.
1493
+ if (command !== 'search' && (hasFlag(args, '--version') || hasFlag(args, '-v'))) {
1494
+ console.log(await readPackageVersion(fileURLToPath(import.meta.url)));
1495
+ return 0;
1496
+ }
1497
+ if (!command || command === '--help' || command === '-h') {
1498
+ printHelp();
1499
+ return 0;
1500
+ }
1501
+ if (command === 'check') {
1502
+ const file = args[1];
1503
+ if (!file) {
1504
+ console.error('Usage: live-plan check <file.plan.md>');
1505
+ return 1;
1506
+ }
1507
+ return cmdCheck(file);
1508
+ }
1509
+ if (command === 'dump') {
1510
+ const file = args[1];
1511
+ if (!file) {
1512
+ console.error('Usage: live-plan dump <file.plan.md>');
1513
+ return 1;
1514
+ }
1515
+ return cmdDump(file);
1516
+ }
1517
+ if (command === 'serve') {
1518
+ const file = args[1];
1519
+ if (!file) {
1520
+ console.error('Usage: live-plan serve <file.plan.md>');
1521
+ return 1;
1522
+ }
1523
+ return cmdServe(file, args.slice(2));
1524
+ }
1525
+ if (command === 'review') {
1526
+ const file = args[1];
1527
+ if (!file) {
1528
+ console.error('Usage: live-plan review <file.plan.md>');
1529
+ return 1;
1530
+ }
1531
+ return cmdReview(file, args.slice(2));
1532
+ }
1533
+ if (command === 'wait') {
1534
+ const id = args[1];
1535
+ if (!id) {
1536
+ console.error('Usage: live-plan wait <id> --url <plan-url>');
1537
+ return 1;
1538
+ }
1539
+ return cmdWait(id, args.slice(2));
1540
+ }
1541
+ if (command === 'events') {
1542
+ return cmdEvents(args.slice(1));
1543
+ }
1544
+ if (command === 'watch') {
1545
+ return cmdWatch(args.slice(1));
1546
+ }
1547
+ if (command === 'close') {
1548
+ return cmdClose(args.slice(1));
1549
+ }
1550
+ if (command === 'mode') {
1551
+ return cmdMode(args.slice(1));
1552
+ }
1553
+ if (command === 'reply') {
1554
+ return cmdReply(args.slice(1));
1555
+ }
1556
+ if (command === 'search') {
1557
+ return cmdSearch(args.slice(1));
1558
+ }
1559
+ if (command === 'addressing') {
1560
+ return cmdAddressing(args.slice(1));
1561
+ }
1562
+ if (command === 'address') {
1563
+ return cmdAddress(args.slice(1));
1564
+ }
1565
+ if (command === 'execution') {
1566
+ return cmdExecution(args.slice(1));
1567
+ }
1568
+ if (command === 'processes' || command === 'ps') {
1569
+ return cmdProcesses();
1570
+ }
1571
+ if (command === 'logs') {
1572
+ return cmdLogs(args.slice(1));
1573
+ }
1574
+ if (command === 'dashboard') {
1575
+ return cmdDashboard(args.slice(1));
1576
+ }
1577
+ if (command === 'tui') {
1578
+ const { runTui } = await import('./tui/runTui');
1579
+ return runTui(args.slice(1), fileURLToPath(import.meta.url));
1580
+ }
1581
+ if (command === 'registry') {
1582
+ return cmdRegistry(args.slice(1));
1583
+ }
1584
+ if (command === 'lan') {
1585
+ const { lanOff, lanOn, lanStatus } = await import('./lanCommand');
1586
+ const action = args[1];
1587
+ const entry = fileURLToPath(import.meta.url);
1588
+ if (action === 'on')
1589
+ return lanOn(entry);
1590
+ if (action === 'off')
1591
+ return lanOff(entry);
1592
+ if (action === 'status')
1593
+ return lanStatus();
1594
+ console.error('Usage: live-plan lan <on|off|status>');
1595
+ return 1;
1596
+ }
1597
+ if (command === 'account') {
1598
+ const action = args[1];
1599
+ if (action !== 'login') {
1600
+ console.error('Usage: live-plan account login --url https://host [--headless | --token <token>]');
1601
+ return 1;
1602
+ }
1603
+ const base = getFlag(args, '--url') ?? process.env.LIVE_PLAN_CLOUD_URL;
1604
+ if (!base) {
1605
+ console.error('Pass --url https://host or set LIVE_PLAN_CLOUD_URL.');
1606
+ return 1;
1607
+ }
1608
+ const raw = getFlag(args, '--token');
1609
+ const token = raw && (raw === '-' || !raw.startsWith('-')) ? raw : undefined;
1610
+ if (args.includes('--token') && !token) {
1611
+ console.error('Pass the token after --token, or --token - to read it from stdin.');
1612
+ return 1;
1613
+ }
1614
+ if (token && args.includes('--headless')) {
1615
+ console.error('--headless prints the token page. Pass --token on its own once you have one.');
1616
+ return 1;
1617
+ }
1618
+ try {
1619
+ if (args.includes('--headless')) {
1620
+ const page = `${normalizeBase(base)}${CLI_TOKEN_PATH}`;
1621
+ console.log(`Open this page in any browser, on any device. Sign in, or choose Sign up instead to create an account:\n${page}`);
1622
+ console.log('The page shows a command with a token. Paste it here:\n live-plan account login --url <host> --token <token>');
1623
+ return 0;
1624
+ }
1625
+ if (token) {
1626
+ const signed = await signInWithToken(base, token === '-' ? await readStdin() : token);
1627
+ console.log(`Signed in to ${signed.baseUrl} as ${signed.email}`);
1628
+ return 0;
1629
+ }
1630
+ await signInToCloud(base, async (url) => {
1631
+ // Print the link too, so a person can open it when no browser launches.
1632
+ console.log(`Sign in, or choose Sign up instead to create an account:\n${url}`);
1633
+ console.log('No browser on this machine? Run live-plan account login --headless instead.');
1634
+ // Sign-in hands off to a loopback callback, so it stays in a browser tab.
1635
+ if (!hasFlag(process.argv.slice(2), '--no-open'))
1636
+ openInBrowser(url);
1637
+ });
1638
+ const account = await requireCloudAccount();
1639
+ console.log(`Signed in to ${account.baseUrl}`);
1640
+ return 0;
1641
+ }
1642
+ catch (error) {
1643
+ console.error(error instanceof Error ? error.message : error);
1644
+ return 1;
1645
+ }
1646
+ }
1647
+ if (command === 'skills') {
1648
+ const { cmdSkills } = await import('./desktopCommand');
1649
+ return cmdSkills(args.slice(1));
1650
+ }
1651
+ if (command === 'desktop') {
1652
+ const { cmdDesktop } = await import('./desktopCommand');
1653
+ const entry = fileURLToPath(import.meta.url);
1654
+ const { changelogDirectory } = await import('./changelog');
1655
+ return cmdDesktop(args.slice(1), {
1656
+ version: await readPackageVersion(entry),
1657
+ target: { runtime: process.execPath, entry },
1658
+ changelogs: changelogDirectory(entry),
1659
+ });
1660
+ }
1661
+ if (command === 'cloud-watch') {
1662
+ const watchUrl = getFlag(args, '--url');
1663
+ if (!watchUrl) {
1664
+ console.error('cloud-watch requires --url');
1665
+ return 1;
1666
+ }
1667
+ await runCloudWatch(watchUrl);
1668
+ return 0;
1669
+ }
1670
+ if (command === 'theme') {
1671
+ return cmdTheme(args.slice(1));
1672
+ }
1673
+ console.error(`Unknown command: ${command}`);
1674
+ printHelp();
1675
+ return 1;
1676
+ }
1677
+ main()
1678
+ .then((code) => {
1679
+ process.exitCode = code;
1680
+ })
1681
+ .catch((error) => {
1682
+ console.error(error instanceof Error ? error.message : error);
1683
+ process.exitCode = 1;
1684
+ });