trybeacon 0.1.47 → 0.1.49

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 (335) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +14 -12
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +12 -0
  6. package/.next/server/app/_global-error/page.js +3 -3
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found/page.js +2 -2
  17. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/_not-found.html +1 -1
  19. package/.next/server/app/_not-found.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  21. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  23. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  26. package/.next/server/app/api/board-annotations/[id]/route.js +1 -1
  27. package/.next/server/app/api/board-annotations/route.js +1 -1
  28. package/.next/server/app/api/board-layout/route.js +1 -1
  29. package/.next/server/app/api/bug-flags/[id]/route.js +1 -1
  30. package/.next/server/app/api/bug-flags/route.js +1 -1
  31. package/.next/server/app/api/code-graph/position/route.js +1 -1
  32. package/.next/server/app/api/code-graph/route.js +1 -1
  33. package/.next/server/app/api/context/feature/route.js +1 -1
  34. package/.next/server/app/api/context/file/route.js +1 -1
  35. package/.next/server/app/api/context/route.js +2 -2
  36. package/.next/server/app/api/db/arrange/route.js +1 -1
  37. package/.next/server/app/api/db/backfill-access/route.js +1 -1
  38. package/.next/server/app/api/db/position/route.js +1 -1
  39. package/.next/server/app/api/db/prune-planned/route.js +1 -1
  40. package/.next/server/app/api/db/reconcile-endpoints/route.js +1 -1
  41. package/.next/server/app/api/db/relations/[id]/route.js +1 -1
  42. package/.next/server/app/api/db/tables/[id]/route.js +1 -1
  43. package/.next/server/app/api/draft/approve/route.js +1 -1
  44. package/.next/server/app/api/draft/route.js +1 -1
  45. package/.next/server/app/api/draft/status/route.js +1 -1
  46. package/.next/server/app/api/edges/[id]/route.js +1 -1
  47. package/.next/server/app/api/edges/route.js +1 -1
  48. package/.next/server/app/api/endpoints/[id]/route.js +1 -1
  49. package/.next/server/app/api/entities/route.js +1 -1
  50. package/.next/server/app/api/feedback/[id]/route.js +1 -1
  51. package/.next/server/app/api/feedback/[id]/vote/route.js +1 -1
  52. package/.next/server/app/api/feedback/route.js +1 -1
  53. package/.next/server/app/api/flags/route.js +1 -0
  54. package/.next/server/app/api/flags/route.js.nft.json +1 -0
  55. package/.next/server/app/api/flags/route_client-reference-manifest.js +1 -0
  56. package/.next/server/app/api/ingest/route.js +2 -2
  57. package/.next/server/app/api/init/route.js +1 -1
  58. package/.next/server/app/api/map/describe/route.js +2 -2
  59. package/.next/server/app/api/map/files/route.js +1 -1
  60. package/.next/server/app/api/map/finish/route.js +1 -1
  61. package/.next/server/app/api/map/route.js +1 -1
  62. package/.next/server/app/api/map/start/route.js +1 -1
  63. package/.next/server/app/api/map/touch-active/route.js +1 -1
  64. package/.next/server/app/api/nodes/[id]/position/route.js +1 -1
  65. package/.next/server/app/api/nodes/[id]/route.js +1 -1
  66. package/.next/server/app/api/nodes/positions/route.js +1 -1
  67. package/.next/server/app/api/nodes/route.js +1 -1
  68. package/.next/server/app/api/nodes/subtasks/route.js +1 -1
  69. package/.next/server/app/api/notes/[id]/route.js +1 -1
  70. package/.next/server/app/api/notes/route.js +1 -1
  71. package/.next/server/app/api/open/route.js +1 -1
  72. package/.next/server/app/api/plan/annotations/route.js +3 -3
  73. package/.next/server/app/api/plan/approve/route.js +2 -2
  74. package/.next/server/app/api/plan/history/route.js +1 -1
  75. package/.next/server/app/api/plan/markdown/route.js +1 -1
  76. package/.next/server/app/api/plan/presence/route.js +1 -1
  77. package/.next/server/app/api/plan/route.js +1 -1
  78. package/.next/server/app/api/plan/verdict/route.js +1 -1
  79. package/.next/server/app/api/preferences/route.js +1 -1
  80. package/.next/server/app/api/project-meta/route.js +1 -1
  81. package/.next/server/app/api/reset/route.js +1 -1
  82. package/.next/server/app/api/scope-guard/check/route.js +1 -0
  83. package/.next/server/app/api/scope-guard/check/route.js.nft.json +1 -0
  84. package/.next/server/app/api/scope-guard/check/route_client-reference-manifest.js +1 -0
  85. package/.next/server/app/api/stream/route.js +2 -2
  86. package/.next/server/app/api/tab/nav/route.js +1 -1
  87. package/.next/server/app/api/tab/presence/route.js +1 -1
  88. package/.next/server/app/api/telemetry/route.js +1 -1
  89. package/.next/server/app/api/telemetry/stats/route.js +1 -1
  90. package/.next/server/app/api/version/route.js +1 -1
  91. package/.next/server/app/api/workspace/activate/route.js +1 -1
  92. package/.next/server/app/api/workspace/route.js +1 -1
  93. package/.next/server/app/apple-icon.png/route.js +1 -1
  94. package/.next/server/app/docs/page.js +2 -2
  95. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  96. package/.next/server/app/docs.html +1 -1
  97. package/.next/server/app/docs.rsc +2 -2
  98. package/.next/server/app/docs.segments/_full.segment.rsc +2 -2
  99. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  100. package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
  101. package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  102. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  103. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  104. package/.next/server/app/feedback/page.js +2 -2
  105. package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
  106. package/.next/server/app/feedback.html +1 -1
  107. package/.next/server/app/feedback.rsc +2 -2
  108. package/.next/server/app/feedback.segments/_full.segment.rsc +2 -2
  109. package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
  110. package/.next/server/app/feedback.segments/_index.segment.rsc +2 -2
  111. package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
  112. package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
  113. package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
  114. package/.next/server/app/help/page.js +2 -2
  115. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  116. package/.next/server/app/help.html +1 -1
  117. package/.next/server/app/help.rsc +2 -2
  118. package/.next/server/app/help.segments/_full.segment.rsc +2 -2
  119. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  120. package/.next/server/app/help.segments/_index.segment.rsc +2 -2
  121. package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
  122. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
  123. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  124. package/.next/server/app/icon.svg/route.js +1 -1
  125. package/.next/server/app/index.html +1 -1
  126. package/.next/server/app/index.rsc +3 -3
  127. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  128. package/.next/server/app/index.segments/_full.segment.rsc +3 -3
  129. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  130. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  131. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  132. package/.next/server/app/map/page.js +2 -2
  133. package/.next/server/app/map/page.js.nft.json +1 -1
  134. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  135. package/.next/server/app/page.js +2 -2
  136. package/.next/server/app/page_client-reference-manifest.js +1 -1
  137. package/.next/server/app/plan/page.js +2 -2
  138. package/.next/server/app/plan/page.js.nft.json +1 -1
  139. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  140. package/.next/server/app/settings/page.js +2 -2
  141. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app-paths-manifest.json +14 -12
  143. package/.next/server/chunks/1341.js +1 -1
  144. package/.next/server/chunks/249.js +1 -1
  145. package/.next/server/chunks/2933.js +1 -1
  146. package/.next/server/chunks/{7208.js → 2999.js} +3 -3
  147. package/.next/server/chunks/3221.js +2 -2
  148. package/.next/server/chunks/3622.js +1 -1
  149. package/.next/server/chunks/4378.js +1 -1
  150. package/.next/server/chunks/4940.js +1 -1
  151. package/.next/server/chunks/7331.js +1 -0
  152. package/.next/server/chunks/9213.js +1 -1
  153. package/.next/server/chunks/9683.js +1 -1
  154. package/.next/server/chunks/9734.js +1 -1
  155. package/.next/server/middleware-build-manifest.js +1 -1
  156. package/.next/server/pages/404.html +1 -1
  157. package/.next/server/pages/500.html +1 -1
  158. package/.next/server/server-reference-manifest.js +1 -1
  159. package/.next/server/server-reference-manifest.json +1 -1
  160. package/.next/static/chunks/3343-af1292b51a276724.js +1 -0
  161. package/.next/static/chunks/7323-480fb88e9d24f9e9.js +1 -0
  162. package/.next/static/chunks/app/_global-error/page-dc3f0f4fd9e88c4e.js +1 -0
  163. package/.next/static/chunks/app/api/board-annotations/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  164. package/.next/static/chunks/app/api/board-annotations/route-dc3f0f4fd9e88c4e.js +1 -0
  165. package/.next/static/chunks/app/api/board-layout/route-dc3f0f4fd9e88c4e.js +1 -0
  166. package/.next/static/chunks/app/api/bug-flags/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  167. package/.next/static/chunks/app/api/bug-flags/route-dc3f0f4fd9e88c4e.js +1 -0
  168. package/.next/static/chunks/app/api/code-graph/position/route-dc3f0f4fd9e88c4e.js +1 -0
  169. package/.next/static/chunks/app/api/code-graph/route-dc3f0f4fd9e88c4e.js +1 -0
  170. package/.next/static/chunks/app/api/context/feature/route-dc3f0f4fd9e88c4e.js +1 -0
  171. package/.next/static/chunks/app/api/context/file/route-dc3f0f4fd9e88c4e.js +1 -0
  172. package/.next/static/chunks/app/api/context/route-dc3f0f4fd9e88c4e.js +1 -0
  173. package/.next/static/chunks/app/api/db/arrange/route-dc3f0f4fd9e88c4e.js +1 -0
  174. package/.next/static/chunks/app/api/db/backfill-access/route-dc3f0f4fd9e88c4e.js +1 -0
  175. package/.next/static/chunks/app/api/db/position/route-dc3f0f4fd9e88c4e.js +1 -0
  176. package/.next/static/chunks/app/api/db/prune-planned/route-dc3f0f4fd9e88c4e.js +1 -0
  177. package/.next/static/chunks/app/api/db/reconcile-endpoints/route-dc3f0f4fd9e88c4e.js +1 -0
  178. package/.next/static/chunks/app/api/db/relations/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  179. package/.next/static/chunks/app/api/db/tables/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  180. package/.next/static/chunks/app/api/draft/approve/route-dc3f0f4fd9e88c4e.js +1 -0
  181. package/.next/static/chunks/app/api/draft/route-dc3f0f4fd9e88c4e.js +1 -0
  182. package/.next/static/chunks/app/api/draft/status/route-dc3f0f4fd9e88c4e.js +1 -0
  183. package/.next/static/chunks/app/api/edges/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  184. package/.next/static/chunks/app/api/edges/route-dc3f0f4fd9e88c4e.js +1 -0
  185. package/.next/static/chunks/app/api/endpoints/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  186. package/.next/static/chunks/app/api/entities/route-dc3f0f4fd9e88c4e.js +1 -0
  187. package/.next/static/chunks/app/api/feedback/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  188. package/.next/static/chunks/app/api/feedback/[id]/vote/route-dc3f0f4fd9e88c4e.js +1 -0
  189. package/.next/static/chunks/app/api/feedback/route-dc3f0f4fd9e88c4e.js +1 -0
  190. package/.next/static/chunks/app/api/flags/route-dc3f0f4fd9e88c4e.js +1 -0
  191. package/.next/static/chunks/app/api/ingest/route-dc3f0f4fd9e88c4e.js +1 -0
  192. package/.next/static/chunks/app/api/init/route-dc3f0f4fd9e88c4e.js +1 -0
  193. package/.next/static/chunks/app/api/map/describe/route-dc3f0f4fd9e88c4e.js +1 -0
  194. package/.next/static/chunks/app/api/map/files/route-dc3f0f4fd9e88c4e.js +1 -0
  195. package/.next/static/chunks/app/api/map/finish/route-dc3f0f4fd9e88c4e.js +1 -0
  196. package/.next/static/chunks/app/api/map/route-dc3f0f4fd9e88c4e.js +1 -0
  197. package/.next/static/chunks/app/api/map/start/route-dc3f0f4fd9e88c4e.js +1 -0
  198. package/.next/static/chunks/app/api/map/touch-active/route-dc3f0f4fd9e88c4e.js +1 -0
  199. package/.next/static/chunks/app/api/nodes/[id]/position/route-dc3f0f4fd9e88c4e.js +1 -0
  200. package/.next/static/chunks/app/api/nodes/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  201. package/.next/static/chunks/app/api/nodes/positions/route-dc3f0f4fd9e88c4e.js +1 -0
  202. package/.next/static/chunks/app/api/nodes/route-dc3f0f4fd9e88c4e.js +1 -0
  203. package/.next/static/chunks/app/api/nodes/subtasks/route-dc3f0f4fd9e88c4e.js +1 -0
  204. package/.next/static/chunks/app/api/notes/[id]/route-dc3f0f4fd9e88c4e.js +1 -0
  205. package/.next/static/chunks/app/api/notes/route-dc3f0f4fd9e88c4e.js +1 -0
  206. package/.next/static/chunks/app/api/open/route-dc3f0f4fd9e88c4e.js +1 -0
  207. package/.next/static/chunks/app/api/plan/annotations/route-dc3f0f4fd9e88c4e.js +1 -0
  208. package/.next/static/chunks/app/api/plan/approve/route-dc3f0f4fd9e88c4e.js +1 -0
  209. package/.next/static/chunks/app/api/plan/history/route-dc3f0f4fd9e88c4e.js +1 -0
  210. package/.next/static/chunks/app/api/plan/markdown/route-dc3f0f4fd9e88c4e.js +1 -0
  211. package/.next/static/chunks/app/api/plan/presence/route-dc3f0f4fd9e88c4e.js +1 -0
  212. package/.next/static/chunks/app/api/plan/route-dc3f0f4fd9e88c4e.js +1 -0
  213. package/.next/static/chunks/app/api/plan/verdict/route-dc3f0f4fd9e88c4e.js +1 -0
  214. package/.next/static/chunks/app/api/preferences/route-dc3f0f4fd9e88c4e.js +1 -0
  215. package/.next/static/chunks/app/api/project-meta/route-dc3f0f4fd9e88c4e.js +1 -0
  216. package/.next/static/chunks/app/api/reset/route-dc3f0f4fd9e88c4e.js +1 -0
  217. package/.next/static/chunks/app/api/scope-guard/check/route-dc3f0f4fd9e88c4e.js +1 -0
  218. package/.next/static/chunks/app/api/stream/route-dc3f0f4fd9e88c4e.js +1 -0
  219. package/.next/static/chunks/app/api/tab/nav/route-dc3f0f4fd9e88c4e.js +1 -0
  220. package/.next/static/chunks/app/api/tab/presence/route-dc3f0f4fd9e88c4e.js +1 -0
  221. package/.next/static/chunks/app/api/telemetry/route-dc3f0f4fd9e88c4e.js +1 -0
  222. package/.next/static/chunks/app/api/telemetry/stats/route-dc3f0f4fd9e88c4e.js +1 -0
  223. package/.next/static/chunks/app/api/version/route-dc3f0f4fd9e88c4e.js +1 -0
  224. package/.next/static/chunks/app/api/workspace/activate/route-dc3f0f4fd9e88c4e.js +1 -0
  225. package/.next/static/chunks/app/api/workspace/route-dc3f0f4fd9e88c4e.js +1 -0
  226. package/.next/static/chunks/app/map/page-66d71744ae3363d7.js +1 -0
  227. package/.next/static/chunks/app/page-541e900d67f17dae.js +1 -0
  228. package/.next/static/chunks/app/plan/page-e7d16fa2a3713a92.js +1 -0
  229. package/.next/static/chunks/app/settings/page-7e176d120b1effa9.js +1 -0
  230. package/.next/static/chunks/next/dist/client/components/builtin/app-error-dc3f0f4fd9e88c4e.js +1 -0
  231. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-dc3f0f4fd9e88c4e.js +1 -0
  232. package/.next/static/chunks/next/dist/client/components/builtin/not-found-dc3f0f4fd9e88c4e.js +1 -0
  233. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-dc3f0f4fd9e88c4e.js +1 -0
  234. package/.next/static/css/629ab377241de9ca.css +1 -0
  235. package/.next/static/qeqVD-yeoYO_3C0pw9kHg/_buildManifest.js +1 -0
  236. package/.next/trace +39 -39
  237. package/.next/trace-build +1 -1
  238. package/.next/types/app/api/flags/route.ts +351 -0
  239. package/.next/types/app/api/scope-guard/check/route.ts +351 -0
  240. package/.next/types/routes.d.ts +3 -1
  241. package/.next/types/validator.ts +18 -0
  242. package/dist/bin/beacon.js +7 -7
  243. package/dist/bin/doctor.js +33 -26
  244. package/dist/bin/guard.js +3 -0
  245. package/dist/bin/hook.js +33 -26
  246. package/dist/bin/mcp.js +42 -35
  247. package/dist/bin/plan.js +34 -27
  248. package/dist/bin/remove.js +7 -6
  249. package/dist/bin/uninstall.js +33 -26
  250. package/dist/lib/assets.js +20 -13
  251. package/dist/lib/codex-install.js +30 -23
  252. package/dist/lib/global-install.js +30 -23
  253. package/dist/lib/telemetry.js +1 -1
  254. package/dist/lib/workspaces.js +1 -1
  255. package/drizzle/0008_good_lucky_pierre.sql +21 -0
  256. package/drizzle/meta/0008_snapshot.json +1904 -0
  257. package/drizzle/meta/_journal.json +7 -0
  258. package/package.json +1 -1
  259. package/public/install.sh +37 -6
  260. package/.next/server/chunks/142.js +0 -1
  261. package/.next/static/OO5fwNXOYFYnu4W91Z44C/_buildManifest.js +0 -1
  262. package/.next/static/chunks/5811-4d1f942c37146b40.js +0 -1
  263. package/.next/static/chunks/8074-a6b2725786399e2c.js +0 -1
  264. package/.next/static/chunks/app/_global-error/page-16ca2ed05a1d74d1.js +0 -1
  265. package/.next/static/chunks/app/api/board-annotations/[id]/route-16ca2ed05a1d74d1.js +0 -1
  266. package/.next/static/chunks/app/api/board-annotations/route-16ca2ed05a1d74d1.js +0 -1
  267. package/.next/static/chunks/app/api/board-layout/route-16ca2ed05a1d74d1.js +0 -1
  268. package/.next/static/chunks/app/api/bug-flags/[id]/route-16ca2ed05a1d74d1.js +0 -1
  269. package/.next/static/chunks/app/api/bug-flags/route-16ca2ed05a1d74d1.js +0 -1
  270. package/.next/static/chunks/app/api/code-graph/position/route-16ca2ed05a1d74d1.js +0 -1
  271. package/.next/static/chunks/app/api/code-graph/route-16ca2ed05a1d74d1.js +0 -1
  272. package/.next/static/chunks/app/api/context/feature/route-16ca2ed05a1d74d1.js +0 -1
  273. package/.next/static/chunks/app/api/context/file/route-16ca2ed05a1d74d1.js +0 -1
  274. package/.next/static/chunks/app/api/context/route-16ca2ed05a1d74d1.js +0 -1
  275. package/.next/static/chunks/app/api/db/arrange/route-16ca2ed05a1d74d1.js +0 -1
  276. package/.next/static/chunks/app/api/db/backfill-access/route-16ca2ed05a1d74d1.js +0 -1
  277. package/.next/static/chunks/app/api/db/position/route-16ca2ed05a1d74d1.js +0 -1
  278. package/.next/static/chunks/app/api/db/prune-planned/route-16ca2ed05a1d74d1.js +0 -1
  279. package/.next/static/chunks/app/api/db/reconcile-endpoints/route-16ca2ed05a1d74d1.js +0 -1
  280. package/.next/static/chunks/app/api/db/relations/[id]/route-16ca2ed05a1d74d1.js +0 -1
  281. package/.next/static/chunks/app/api/db/tables/[id]/route-16ca2ed05a1d74d1.js +0 -1
  282. package/.next/static/chunks/app/api/draft/approve/route-16ca2ed05a1d74d1.js +0 -1
  283. package/.next/static/chunks/app/api/draft/route-16ca2ed05a1d74d1.js +0 -1
  284. package/.next/static/chunks/app/api/draft/status/route-16ca2ed05a1d74d1.js +0 -1
  285. package/.next/static/chunks/app/api/edges/[id]/route-16ca2ed05a1d74d1.js +0 -1
  286. package/.next/static/chunks/app/api/edges/route-16ca2ed05a1d74d1.js +0 -1
  287. package/.next/static/chunks/app/api/endpoints/[id]/route-16ca2ed05a1d74d1.js +0 -1
  288. package/.next/static/chunks/app/api/entities/route-16ca2ed05a1d74d1.js +0 -1
  289. package/.next/static/chunks/app/api/feedback/[id]/route-16ca2ed05a1d74d1.js +0 -1
  290. package/.next/static/chunks/app/api/feedback/[id]/vote/route-16ca2ed05a1d74d1.js +0 -1
  291. package/.next/static/chunks/app/api/feedback/route-16ca2ed05a1d74d1.js +0 -1
  292. package/.next/static/chunks/app/api/ingest/route-16ca2ed05a1d74d1.js +0 -1
  293. package/.next/static/chunks/app/api/init/route-16ca2ed05a1d74d1.js +0 -1
  294. package/.next/static/chunks/app/api/map/describe/route-16ca2ed05a1d74d1.js +0 -1
  295. package/.next/static/chunks/app/api/map/files/route-16ca2ed05a1d74d1.js +0 -1
  296. package/.next/static/chunks/app/api/map/finish/route-16ca2ed05a1d74d1.js +0 -1
  297. package/.next/static/chunks/app/api/map/route-16ca2ed05a1d74d1.js +0 -1
  298. package/.next/static/chunks/app/api/map/start/route-16ca2ed05a1d74d1.js +0 -1
  299. package/.next/static/chunks/app/api/map/touch-active/route-16ca2ed05a1d74d1.js +0 -1
  300. package/.next/static/chunks/app/api/nodes/[id]/position/route-16ca2ed05a1d74d1.js +0 -1
  301. package/.next/static/chunks/app/api/nodes/[id]/route-16ca2ed05a1d74d1.js +0 -1
  302. package/.next/static/chunks/app/api/nodes/positions/route-16ca2ed05a1d74d1.js +0 -1
  303. package/.next/static/chunks/app/api/nodes/route-16ca2ed05a1d74d1.js +0 -1
  304. package/.next/static/chunks/app/api/nodes/subtasks/route-16ca2ed05a1d74d1.js +0 -1
  305. package/.next/static/chunks/app/api/notes/[id]/route-16ca2ed05a1d74d1.js +0 -1
  306. package/.next/static/chunks/app/api/notes/route-16ca2ed05a1d74d1.js +0 -1
  307. package/.next/static/chunks/app/api/open/route-16ca2ed05a1d74d1.js +0 -1
  308. package/.next/static/chunks/app/api/plan/annotations/route-16ca2ed05a1d74d1.js +0 -1
  309. package/.next/static/chunks/app/api/plan/approve/route-16ca2ed05a1d74d1.js +0 -1
  310. package/.next/static/chunks/app/api/plan/history/route-16ca2ed05a1d74d1.js +0 -1
  311. package/.next/static/chunks/app/api/plan/markdown/route-16ca2ed05a1d74d1.js +0 -1
  312. package/.next/static/chunks/app/api/plan/presence/route-16ca2ed05a1d74d1.js +0 -1
  313. package/.next/static/chunks/app/api/plan/route-16ca2ed05a1d74d1.js +0 -1
  314. package/.next/static/chunks/app/api/plan/verdict/route-16ca2ed05a1d74d1.js +0 -1
  315. package/.next/static/chunks/app/api/preferences/route-16ca2ed05a1d74d1.js +0 -1
  316. package/.next/static/chunks/app/api/project-meta/route-16ca2ed05a1d74d1.js +0 -1
  317. package/.next/static/chunks/app/api/reset/route-16ca2ed05a1d74d1.js +0 -1
  318. package/.next/static/chunks/app/api/stream/route-16ca2ed05a1d74d1.js +0 -1
  319. package/.next/static/chunks/app/api/tab/nav/route-16ca2ed05a1d74d1.js +0 -1
  320. package/.next/static/chunks/app/api/tab/presence/route-16ca2ed05a1d74d1.js +0 -1
  321. package/.next/static/chunks/app/api/telemetry/route-16ca2ed05a1d74d1.js +0 -1
  322. package/.next/static/chunks/app/api/telemetry/stats/route-16ca2ed05a1d74d1.js +0 -1
  323. package/.next/static/chunks/app/api/version/route-16ca2ed05a1d74d1.js +0 -1
  324. package/.next/static/chunks/app/api/workspace/activate/route-16ca2ed05a1d74d1.js +0 -1
  325. package/.next/static/chunks/app/api/workspace/route-16ca2ed05a1d74d1.js +0 -1
  326. package/.next/static/chunks/app/map/page-a0bcd15b8dbfb3d3.js +0 -1
  327. package/.next/static/chunks/app/page-968dd5a6f667bff9.js +0 -1
  328. package/.next/static/chunks/app/plan/page-376f36858e187c73.js +0 -1
  329. package/.next/static/chunks/app/settings/page-67cab634be8bfef2.js +0 -1
  330. package/.next/static/chunks/next/dist/client/components/builtin/app-error-16ca2ed05a1d74d1.js +0 -1
  331. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-16ca2ed05a1d74d1.js +0 -1
  332. package/.next/static/chunks/next/dist/client/components/builtin/not-found-16ca2ed05a1d74d1.js +0 -1
  333. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-16ca2ed05a1d74d1.js +0 -1
  334. package/.next/static/css/2d019ca6e0582481.css +0 -1
  335. /package/.next/static/{OO5fwNXOYFYnu4W91Z44C → qeqVD-yeoYO_3C0pw9kHg}/_ssgManifest.js +0 -0
package/dist/bin/mcp.js CHANGED
@@ -1,21 +1,22 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var T9=Object.defineProperty;var _9=($)=>$;function L9($,Q){this[$]=_9.bind(null,Q)}var r=($,Q)=>{for(var Z in Q)T9($,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:L9.bind(Q,Z)})};var t=($,Q)=>()=>($&&(Q=$($=0)),Q);var o0={};r(o0,{removeRepoAssets:()=>f9,installRefreshSkill:()=>g9,installPlanSkill:()=>x9,installInitSkill:()=>k9,installCodexRepoSkills:()=>z9,ensureWorkflowDoc:()=>S9,ensureMcp:()=>h9,auditRepo:()=>u9,REFRESH_SKILL:()=>d0,PLAN_SKILL:()=>_5,INIT_SKILL:()=>l0});import{existsSync as p,mkdirSync as M0,readFileSync as T,rmSync as K0,writeFileSync as I}from"fs";import{join as K}from"path";function k9($){let Q=K($,".claude","skills","beacon-init");M0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,l0),Z}function g9($){let Q=K($,".claude","skills","beacon-refresh");M0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,d0),Z}function x9($){let Q=K($,".claude","skills","beacon-plan");M0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,_5),Z}function z9($){let Q=[];for(let Z of y9){let Y=K($,".agents","skills",Z.name);M0(Y,{recursive:!0});let V=K(Y,"SKILL.md");I(V,Z.body()),Q.push(V)}return Q}function S9($){let Q=K($,"AGENTS.md"),Z="";try{Z=T(Q,"utf8")}catch{}let Y=new RegExp(`${N0}[\\s\\S]*?${s0}`);Z=Y.test(Z)?Z.replace(Y,T5):`${Z.trim()}
3
+ var g9=Object.defineProperty;var y9=($)=>$;function x9($,Q){this[$]=y9.bind(null,Q)}var t=($,Q)=>{for(var Z in Q)g9($,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:x9.bind(Q,Z)})};var c=($,Q)=>()=>($&&(Q=$($=0)),Q);var s0=1500,kQ=480000,o0=1800000,K0=3600000,k5=3000;var n0=()=>{};var t0={};t(t0,{removeRepoAssets:()=>c9,installRefreshSkill:()=>S9,installPlanSkill:()=>h9,installInitSkill:()=>z9,installCodexRepoSkills:()=>f9,ensureWorkflowDoc:()=>b9,ensureMcp:()=>m9,auditRepo:()=>p9,REFRESH_SKILL:()=>i0,PLAN_SKILL:()=>y5,INIT_SKILL:()=>a0});import{existsSync as l,mkdirSync as M0,readFileSync as T,rmSync as N0,writeFileSync as I}from"fs";import{join as K}from"path";function z9($){let Q=K($,".claude","skills","beacon-init");M0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,a0),Z}function S9($){let Q=K($,".claude","skills","beacon-refresh");M0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,i0),Z}function h9($){let Q=K($,".claude","skills","beacon-plan");M0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,y5),Z}function f9($){let Q=[];for(let Z of u9){let Y=K($,".agents","skills",Z.name);M0(Y,{recursive:!0});let X=K(Y,"SKILL.md");I(X,Z.body()),Q.push(X)}return Q}function b9($){let Q=K($,"AGENTS.md"),Z="";try{Z=T(Q,"utf8")}catch{}let Y=new RegExp(`${P0}[\\s\\S]*?${r0}`);Z=Y.test(Z)?Z.replace(Y,g5):`${Z.trim()}
4
4
 
5
- ${T5}
5
+ ${g5}
6
6
  `.trimStart(),I(Q,Z.endsWith(`
7
7
  `)?Z:`${Z}
8
- `);let V=K($,"CLAUDE.md"),H="";try{H=T(V,"utf8")}catch{}if(!/@AGENTS\.md/.test(H))I(V,`${H?`${H.trim()}
8
+ `);let X=K($,"CLAUDE.md"),H="";try{H=T(X,"utf8")}catch{}if(!/@AGENTS\.md/.test(H))I(X,`${H?`${H.trim()}
9
9
 
10
10
  `:""}@AGENTS.md
11
- `)}function h9($){let Q=K($,".mcp.json"),Z={};try{Z=JSON.parse(T(Q,"utf8"))}catch{}if(Z.mcpServers=Z.mcpServers??{},Z.mcpServers.beacon)return{path:Q,added:!1};return Z.mcpServers.beacon={command:"beacon",args:["mcp"]},I(Q,JSON.stringify(Z,null,2)+`
12
- `),{path:Q,added:!0}}function u9($){let Q=K($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(T(Q,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=T(K($,"AGENTS.md"),"utf8").includes(N0)}catch{}let V=!1;try{V=/@AGENTS\.md/.test(T(K($,"CLAUDE.md"),"utf8"))}catch{}return{repo:$,mcpRegistered:Z,agentsMdBlock:Y,claudeMdImport:V,skills:{"beacon-init":p(K($,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":p(K($,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":p(K($,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":p(K($,".agents","skills","beacon-refresh","SKILL.md"))}}}function f9($){let Q=[];for(let W of["beacon-init","beacon-refresh","beacon-db-design"]){let w=K($,".claude","skills",W);if(p(w))K0(w,{recursive:!0,force:!0}),Q.push(W)}for(let W of["beacon-init","beacon-refresh"]){let w=K($,".agents","skills",W);if(p(w))K0(w,{recursive:!0,force:!0}),Q.push(`codex:${W}`)}let Z=!1,Y=K($,".mcp.json");try{let W=JSON.parse(T(Y,"utf8"));if(W.mcpServers?.beacon){if(delete W.mcpServers.beacon,Z=!0,W.mcpServers&&Object.keys(W.mcpServers).length===0)delete W.mcpServers;if(Object.keys(W).length===0)K0(Y,{force:!0});else I(Y,JSON.stringify(W,null,2)+`
13
- `)}}catch{}let V=!1,H=K($,"AGENTS.md");try{let W=T(H,"utf8"),w=new RegExp(`\\n?${N0}[\\s\\S]*?${s0}\\n?`);if(w.test(W)){let i=W.replace(w,`
11
+ `)}function m9($){let Q=K($,".mcp.json"),Z={};try{Z=JSON.parse(T(Q,"utf8"))}catch{}Z.mcpServers=Z.mcpServers??{};let Y=Z.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<K0)return Y.timeout=K0,I(Q,JSON.stringify(Z,null,2)+`
12
+ `),{path:Q,added:!1,updated:!0};return{path:Q,added:!1,updated:!1}}return Z.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:K0},I(Q,JSON.stringify(Z,null,2)+`
13
+ `),{path:Q,added:!0,updated:!1}}function p9($){let Q=K($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(T(Q,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=T(K($,"AGENTS.md"),"utf8").includes(P0)}catch{}let X=!1;try{X=/@AGENTS\.md/.test(T(K($,"CLAUDE.md"),"utf8"))}catch{}return{repo:$,mcpRegistered:Z,agentsMdBlock:Y,claudeMdImport:X,skills:{"beacon-init":l(K($,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":l(K($,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":l(K($,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":l(K($,".agents","skills","beacon-refresh","SKILL.md"))}}}function c9($){let Q=[];for(let W of["beacon-init","beacon-refresh","beacon-db-design"]){let w=K($,".claude","skills",W);if(l(w))N0(w,{recursive:!0,force:!0}),Q.push(W)}for(let W of["beacon-init","beacon-refresh"]){let w=K($,".agents","skills",W);if(l(w))N0(w,{recursive:!0,force:!0}),Q.push(`codex:${W}`)}let Z=!1,Y=K($,".mcp.json");try{let W=JSON.parse(T(Y,"utf8"));if(W.mcpServers?.beacon){if(delete W.mcpServers.beacon,Z=!0,W.mcpServers&&Object.keys(W.mcpServers).length===0)delete W.mcpServers;if(Object.keys(W).length===0)N0(Y,{force:!0});else I(Y,JSON.stringify(W,null,2)+`
14
+ `)}}catch{}let X=!1,H=K($,"AGENTS.md");try{let W=T(H,"utf8"),w=new RegExp(`\\n?${P0}[\\s\\S]*?${r0}\\n?`);if(w.test(W)){let r=W.replace(w,`
14
15
  `).replace(/\n{3,}/g,`
15
16
 
16
- `).trimStart();I(H,i.endsWith(`
17
- `)?i:`${i}
18
- `),V=!0}}catch{}let j=!1,G=K($,"CLAUDE.md");try{let W=T(G,"utf8"),w=W.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(w!==W){if(!w.trim())K0(G,{force:!0});else I(G,w);j=!0}}catch{}return{skillsRemoved:Q,mcpUnregistered:Z,agentsBlockRemoved:V,claudeImportRemoved:j}}var l0=`---
17
+ `).trimStart();I(H,r.endsWith(`
18
+ `)?r:`${r}
19
+ `),X=!0}}catch{}let j=!1,G=K($,"CLAUDE.md");try{let W=T(G,"utf8"),w=W.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(w!==W){if(!w.trim())N0(G,{force:!0});else I(G,w);j=!0}}catch{}return{skillsRemoved:Q,mcpUnregistered:Z,agentsBlockRemoved:X,claudeImportRemoved:j}}var a0=`---
19
20
  name: beacon-init
20
21
  description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
21
22
  ---
@@ -54,7 +55,7 @@ A single \`beacon_init_persist\` MCP tool call with:
54
55
  If \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-init.
55
56
 
56
57
  After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
57
- `,d0=`---
58
+ `,i0=`---
58
59
  name: beacon-refresh
59
60
  description: Re-survey the repo and update Beacon's architecture / schema / endpoints map after /beacon-init was already run \u2014 picks up new components, removed ones, schema changes, and new routes. Use when the user runs /beacon-refresh or asks to "refresh", "update", "re-sync", or "bring Beacon up to date" with the current code.
60
61
  ---
@@ -101,7 +102,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
101
102
  If \`beacon_entities\` or \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-refresh.
102
103
 
103
104
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
104
- `,_5=`---
105
+ `,y5=`---
105
106
  name: beacon-plan
106
107
  description: Present your current plan or approach to the user on Beacon's /plan canvas for review \u2014 instead of asking for approval in prose. Use when the user says "present the plan", "show me the plan", "let me see it / the plan", or whenever you are about to end a turn asking whether to proceed with a plan, design, or approach.
107
108
  ---
@@ -129,6 +130,12 @@ Beacon extracts that block deterministically, strips it from the prose, and rend
129
130
  board on /plan. The board is built ONLY from the block \u2014 prose is never parsed \u2014 so mirror EVERY
130
131
  table/endpoint/feature you mention in the prose into the block, or that board will be empty.
131
132
 
133
+ - **Declare your scope.** List the repo-relative files this plan will touch in a top-level
134
+ \`"contract"\` array in the block (or the \`contract\` arg of \`beacon_propose_plan\`). When the user
135
+ has the plan scope-guard enabled, those files are frozen at approval and you're held to them while
136
+ implementing \u2014 editing an undeclared file pauses for the user's authorization (which then adds it
137
+ to the contract). Harmless when the guard is off. Declare the files you genuinely expect to edit.
138
+
132
139
  \`beacon_present_plan\` opens /plan and BLOCKS until the user clicks Approve / Discard / submits
133
140
  feedback, then returns their verdict. Implement code or migrations ONLY after it returns approval.
134
141
  If it returns feedback, revise and call it again.
@@ -143,7 +150,7 @@ If it returns feedback, revise and call it again.
143
150
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
144
151
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
145
152
  run \`beacon\` in this repo once.
146
- `,y9,N0="<!-- beacon:workflow:start -->",s0="<!-- beacon:workflow:end -->",T5;var n0=t(()=>{y9=[{name:"beacon-init",body:()=>l0},{name:"beacon-refresh",body:()=>d0}];T5=`${N0}
153
+ `,u9,P0="<!-- beacon:workflow:start -->",r0="<!-- beacon:workflow:end -->",g5;var e0=c(()=>{n0();u9=[{name:"beacon-init",body:()=>a0},{name:"beacon-refresh",body:()=>i0}];g5=`${P0}
147
154
  ## Beacon \u2014 feature workflow
148
155
 
149
156
  This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
@@ -201,18 +208,18 @@ Register them all in that single batched call. If a plan added five features, th
201
208
  If the feature added or materially changed a REAL architectural component (a subsystem \u2014 NOT a file), also pass \`architecture: [{ title, domain, role, \u2026 }]\` so the Architecture map stays accurate. It upserts curated components by title; never list files as components. If you found a bug or something worth investigating in a component's code, add \`bugs: [{ note }]\` to its architecture entry \u2014 it renders as a bug flag on the node (attributed to the agent); identical open flags are not duplicated. Only flag what you actually saw in the code.
202
209
 
203
210
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
204
- ${s0}`});import{existsSync as L5,mkdirSync as a0,readFileSync as q0,rmSync as b9,writeFileSync as w0}from"fs";import{dirname as k5,join as P0}from"path";function i0($){try{return JSON.parse(q0($,"utf8"))}catch{return{}}}function g5($,Q){a0(k5($),{recursive:!0}),w0($,JSON.stringify(Q,null,2)+`
205
- `)}function v0($,Q){let Z=i0($);Z.hooks=Z.hooks??{},Z.hooks[Q.event]=Z.hooks[Q.event]??[];let Y=Z.hooks[Q.event];if(Y.some((H)=>H.matcher===Q.matcher&&H.hooks?.some((j)=>j.command===Q.command)))return!1;return Y.push({matcher:Q.matcher,hooks:[{type:"command",command:Q.command}]}),g5($,Z),!0}function F0($,Q){return(i0($).hooks?.[Q.event]??[]).some((V)=>V.hooks?.some((H)=>H.command===Q.command))}function O0($,Q){let Z=i0($),Y=Z.hooks?.[Q.event];if(!Y)return!1;let V=!1,H=Y.map((j)=>{let G=j.hooks?.length??0,W=(j.hooks??[]).filter((w)=>w.command!==Q.command);if(W.length!==G)V=!0;return{...j,hooks:W}}).filter((j)=>(j.hooks??[]).length>0);if(!V)return!1;if(H.length)Z.hooks[Q.event]=H;else delete Z.hooks[Q.event];if(Z.hooks&&Object.keys(Z.hooks).length===0)delete Z.hooks;return g5($,Z),!0}function D0($,Q,Z,Y){let V=`${Q}
211
+ ${r0}`});import{existsSync as x5,mkdirSync as $5,readFileSync as w0,rmSync as l9,writeFileSync as C0}from"fs";import{dirname as z5,join as q0}from"path";function Q5($){try{return JSON.parse(w0($,"utf8"))}catch{return{}}}function S5($,Q){$5(z5($),{recursive:!0}),C0($,JSON.stringify(Q,null,2)+`
212
+ `)}function F0($,Q){let Z=Q5($);Z.hooks=Z.hooks??{},Z.hooks[Q.event]=Z.hooks[Q.event]??[];let Y=Z.hooks[Q.event];if(Y.some((H)=>H.matcher===Q.matcher&&H.hooks?.some((j)=>j.command===Q.command)))return!1;return Y.push({matcher:Q.matcher,hooks:[{type:"command",command:Q.command}]}),S5($,Z),!0}function D0($,Q){return(Q5($).hooks?.[Q.event]??[]).some((X)=>X.hooks?.some((H)=>H.command===Q.command))}function O0($,Q){let Z=Q5($),Y=Z.hooks?.[Q.event];if(!Y)return!1;let X=!1,H=Y.map((j)=>{let G=j.hooks?.length??0,W=(j.hooks??[]).filter((w)=>w.command!==Q.command);if(W.length!==G)X=!0;return{...j,hooks:W}}).filter((j)=>(j.hooks??[]).length>0);if(!X)return!1;if(H.length)Z.hooks[Q.event]=H;else delete Z.hooks[Q.event];if(Z.hooks&&Object.keys(Z.hooks).length===0)delete Z.hooks;return S5($,Z),!0}function R0($,Q,Z,Y){let X=`${Q}
206
213
  ${Y.trim()}
207
- ${Z}`,H="";try{H=q0($,"utf8")}catch{}let j=new RegExp(`${Q}[\\s\\S]*?${Z}`);H=j.test(H)?H.replace(j,V):H.trim()?`${H.trim()}
214
+ ${Z}`,H="";try{H=w0($,"utf8")}catch{}let j=new RegExp(`${Q}[\\s\\S]*?${Z}`);H=j.test(H)?H.replace(j,X):H.trim()?`${H.trim()}
208
215
 
209
- ${V}
210
- `:`${V}
211
- `,a0(k5($),{recursive:!0}),w0($,H.endsWith(`
216
+ ${X}
217
+ `:`${X}
218
+ `,$5(z5($),{recursive:!0}),C0($,H.endsWith(`
212
219
  `)?H:`${H}
213
- `)}function e($,Q){try{return q0($,"utf8").includes(Q)}catch{return!1}}function R0($,Q,Z){let Y="";try{Y=q0($,"utf8")}catch{return!1}let V=new RegExp(`${Q}[\\s\\S]*?${Z}\\n?`);if(!V.test(Y))return!1;let H=Y.replace(V,"").replace(/\n{3,}/g,`
220
+ `)}function e($,Q){try{return w0($,"utf8").includes(Q)}catch{return!1}}function A0($,Q,Z){let Y="";try{Y=w0($,"utf8")}catch{return!1}let X=new RegExp(`${Q}[\\s\\S]*?${Z}\\n?`);if(!X.test(Y))return!1;let H=Y.replace(X,"").replace(/\n{3,}/g,`
214
221
 
215
- `).trimStart();return w0($,H),!0}function A0($,Q,Z){let Y=P0($,Q);a0(Y,{recursive:!0});let V=P0(Y,"SKILL.md");return w0(V,Z),V}function $0($,Q){return L5(P0($,Q,"SKILL.md"))}function E0($,Q){let Z=P0($,Q);if(!L5(Z))return!1;return b9(Z,{recursive:!0,force:!0}),!0}var g,C0=`## Beacon (visual planning panel)
222
+ `).trimStart();return C0($,H),!0}function E0($,Q,Z){let Y=q0($,Q);$5(Y,{recursive:!0});let X=q0(Y,"SKILL.md");return C0(X,Z),X}function $0($,Q){return x5(q0($,Q,"SKILL.md"))}function I0($,Q){let Z=q0($,Q);if(!x5(Z))return!1;return l9(Z,{recursive:!0,force:!0}),!0}var g,v0=`## Beacon (visual planning panel)
216
223
 
217
224
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
218
225
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -233,39 +240,39 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
233
240
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
234
241
  on the /map and /db boards (added features, attached subtasks, edited columns, new
235
242
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
236
- verbatim. Do NOT implement until the tool returns approval.`;var r0=t(()=>{g=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as m9,renameSync as p9,rmSync as c9,writeFileSync as l9}from"fs";import{dirname as d9}from"path";function I0($,Q){m9(d9($),{recursive:!0});let Z=`${$}.tmp`;try{l9(Z,Q),p9(Z,$)}catch(Y){throw c9(Z,{force:!0}),Y}}function gQ($,Q,Z=!1){I0($,JSON.stringify(Q,null,Z?2:void 0))}var x5=()=>{};var m5={};r(m5,{setupCodexAssets:()=>a9,removeCodexMcp:()=>b5,removeCodexArtifacts:()=>r9,hasCodexMcp:()=>Q5,ensureCodexMcp:()=>f5,codexMcpProblem:()=>n9,codexDetected:()=>S5,auditCodex:()=>i9,CODEX_HOOKS:()=>g0});import{readFileSync as k0}from"fs";import{homedir as s9}from"os";import{join as J0}from"path";function y5(){return process.env.HOME||process.env.USERPROFILE||s9()}function S5(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(t0===void 0)t0=Bun.which("codex")!==null;return t0}function Z0($){try{return Bun.TOML.parse($)}catch{return null}}function Q5(){try{return Boolean(Z0(k0(c(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function n9(){let $="";try{$=k0(c(),"utf8")}catch{return null}let Q=Z0($);if(!Q)return`~/.codex/config.toml does not parse \u2014 ${Q0}`;if(Q.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test($))return`mcp_servers is an inline table \u2014 ${Q0}`;return null}function f5(){let $="",Q=!1;try{$=k0(c(),"utf8"),Q=!0}catch{}if(Q){let H=Z0($);if(!H)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${Q0}`};if(H.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test($))return{added:!1,error:`mcp_servers is an inline table \u2014 ${Q0}`}}let Z=!$?"":$.endsWith(`
243
+ verbatim. Do NOT implement until the tool returns approval.`;var Z5=c(()=>{g=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as d9,renameSync as s9,rmSync as o9,writeFileSync as n9}from"fs";import{dirname as a9}from"path";function L0($,Q){d9(a9($),{recursive:!0});let Z=`${$}.tmp`;try{n9(Z,Q),s9(Z,$)}catch(Y){throw o9(Z,{force:!0}),Y}}function mQ($,Q,Z=!1){L0($,JSON.stringify(Q,null,Z?2:void 0))}var h5=()=>{};var d5={};t(d5,{setupCodexAssets:()=>e9,removeCodexMcp:()=>l5,removeCodexArtifacts:()=>Q$,hasCodexMcp:()=>X5,ensureCodexMcp:()=>c5,codexMcpProblem:()=>t9,codexDetected:()=>b5,auditCodex:()=>$$,CODEX_HOOKS:()=>y0});import{readFileSync as g0}from"fs";import{homedir as i9}from"os";import{join as J0}from"path";function u5(){return process.env.HOME||process.env.USERPROFILE||i9()}function b5(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(J5===void 0)J5=Bun.which("codex")!==null;return J5}function Z0($){try{return Bun.TOML.parse($)}catch{return null}}function X5(){try{return Boolean(Z0(g0(d(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function t9(){let $="";try{$=g0(d(),"utf8")}catch{return null}let Q=Z0($);if(!Q)return`~/.codex/config.toml does not parse \u2014 ${Q0}`;if(Q.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test($))return`mcp_servers is an inline table \u2014 ${Q0}`;return null}function c5(){let $="",Q=!1;try{$=g0(d(),"utf8"),Q=!0}catch{}if(Q){let H=Z0($);if(!H)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${Q0}`};if(H.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test($))return{added:!1,error:`mcp_servers is an inline table \u2014 ${Q0}`}}let Z=!$?"":$.endsWith(`
237
244
  `)?`
238
245
  `:`
239
246
 
240
- `,Y=$+Z+o9;if(Z0(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${Q0}`};return I0(c(),Y),{added:!0}}function b5(){let $="";try{$=k0(c(),"utf8")}catch{return{removed:!1}}let Q=$.split(`
241
- `),Z=Q.indexOf(h5);if(Z===-1)return{removed:!1,skipped:Q5()};let Y=Q.indexOf(u5,Z);if(Y===-1)return{removed:!1,skipped:!0};Q.splice(Z,Y-Z+1);let V=Q.join(`
247
+ `,Y=$+Z+r9;if(Z0(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${Q0}`};return L0(d(),Y),{added:!0}}function l5(){let $="";try{$=g0(d(),"utf8")}catch{return{removed:!1}}let Q=$.split(`
248
+ `),Z=Q.indexOf(m5);if(Z===-1)return{removed:!1,skipped:X5()};let Y=Q.indexOf(p5,Z);if(Y===-1)return{removed:!1,skipped:!0};Q.splice(Z,Y-Z+1);let X=Q.join(`
242
249
  `).replace(/\n{3,}/g,`
243
250
 
244
- `).replace(/^\n+/,"");if(Z0(V)===null)return{removed:!1,skipped:!0};return I0(c(),V),{removed:!0}}async function a9(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (n0(),o0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},V=[];for(let W of g){if(!$0(_0(),W))V.push(W);A0(_0(),W,Y[W])}let H=0;for(let W of g0)if(v0($5(),{event:W.event,matcher:W.matcher,command:W.command}))H++;let j=e(T0(),L0);D0(T0(),L0,z5,C0);let G=f5();return{skillsAdded:V,hooksAdded:H,agentsMdBlockTouched:!j,mcp:G}}function i9(){let $={};for(let Z of g)$[Z]=$0(_0(),Z);let Q={};for(let Z of g0)Q[Z.event]=F0($5(),{event:Z.event,command:Z.command});return{detected:S5(),skills:$,hooks:Q,agentsMdBlock:e(T0(),L0),mcp:Q5()}}function r9(){let $=[];for(let V of g)if(E0(_0(),V))$.push(V);let Q=0;for(let V of g0)if(O0($5(),{event:V.event,command:V.command}))Q++;let Z=R0(T0(),L0,z5),Y=b5();return{skillsRemoved:$,hooksRemoved:Q,agentsMdBlockRemoved:Z,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var e0=()=>J0(y5(),".codex"),$5=()=>J0(e0(),"hooks.json"),c=()=>J0(e0(),"config.toml"),T0=()=>J0(e0(),"AGENTS.md"),_0=()=>J0(y5(),".agents","skills"),L0="<!-- beacon:global:start -->",z5="<!-- beacon:global:end -->",g0,t0,h5="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",u5="# beacon:end",o9,Q0="add it manually: codex mcp add beacon -- beacon mcp";var p5=t(()=>{r0();x5();g0=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}];o9=`${h5}
251
+ `).replace(/^\n+/,"");if(Z0(X)===null)return{removed:!1,skipped:!0};return L0(d(),X),{removed:!0}}async function e9(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (e0(),t0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let W of g){if(!$0(_0(),W))X.push(W);E0(_0(),W,Y[W])}let H=0;for(let W of y0)if(F0(V5(),{event:W.event,matcher:W.matcher,command:W.command}))H++;let j=e(T0(),k0);R0(T0(),k0,f5,v0);let G=c5();return{skillsAdded:X,hooksAdded:H,agentsMdBlockTouched:!j,mcp:G}}function $$(){let $={};for(let Z of g)$[Z]=$0(_0(),Z);let Q={};for(let Z of y0)Q[Z.event]=D0(V5(),{event:Z.event,command:Z.command});return{detected:b5(),skills:$,hooks:Q,agentsMdBlock:e(T0(),k0),mcp:X5()}}function Q$(){let $=[];for(let X of g)if(I0(_0(),X))$.push(X);let Q=0;for(let X of y0)if(O0(V5(),{event:X.event,command:X.command}))Q++;let Z=A0(T0(),k0,f5),Y=l5();return{skillsRemoved:$,hooksRemoved:Q,agentsMdBlockRemoved:Z,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var Y5=()=>J0(u5(),".codex"),V5=()=>J0(Y5(),"hooks.json"),d=()=>J0(Y5(),"config.toml"),T0=()=>J0(Y5(),"AGENTS.md"),_0=()=>J0(u5(),".agents","skills"),k0="<!-- beacon:global:start -->",f5="<!-- beacon:global:end -->",y0,J5,m5="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",p5="# beacon:end",r9,Q0="add it manually: codex mcp add beacon -- beacon mcp";var s5=c(()=>{Z5();h5();y0=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}];r9=`${m5}
245
252
  [mcp_servers.beacon]
246
253
  command = "beacon"
247
254
  args = ["mcp"]
248
- ${u5}
249
- `});var n5={};r(n5,{provisionDb:()=>F$});import{createClient as W$}from"@libsql/client";import{drizzle as U$}from"drizzle-orm/libsql";import{migrate as B$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as K$}from"drizzle-orm/migrator";import{dirname as H5,join as M$}from"path";import{fileURLToPath as N$}from"url";async function z0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function C$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function o5($){if(!await z0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function v$($){for(let[Q,Z]of Object.entries(w$)){if(!await z0($,Q))continue;let Y=await C$($,Q);for(let V of Z){if(!Y.has(V))continue;await $.execute(`UPDATE "${Q}" SET "${V}" = CAST((julianday("${V}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${V}") = 'text'`)}}}async function F$($,Q=q$){let Z=W$({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let Y=await z0(Z,"__drizzle_migrations"),V=await z0(Z,"Node"),H=!1;if(V&&!Y){let G=K$({migrationsFolder:Q})[0];if(G)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[G.hash,G.folderMillis]}),H=!0}let j=await o5(Z);if(await B$(U$(Z),{migrationsFolder:Q}),await o5(Z)>j)H=!0;return await v$(Z),{migrated:H}}finally{Z.close()}}var P$,q$,w$;var a5=t(async()=>{P$=H5(H5(H5(N$(import.meta.url)))),q$=process.env.BEACON_MIGRATIONS_DIR||M$(P$,"drizzle"),w$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});r0();import{existsSync as t9}from"fs";import{homedir as e9}from"os";import{join as x0}from"path";function $$(){return process.env.HOME||process.env.USERPROFILE||e9()}var y0=()=>x0($$(),".claude"),Z5=()=>x0(y0(),"skills"),J5=()=>x0(y0(),"settings.json"),Y5=()=>x0(y0(),"CLAUDE.md"),V5="<!-- beacon:global:start -->",c5="<!-- beacon:global:end -->";var Q$=C0,X5=[{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function Z$($,Q){return A0(Z5(),$,Q)}function l5($){return $0(Z5(),$)}function J$($){return E0(Z5(),$)}function Y$($){return v0(J5(),$)}function V$($){return F0(J5(),$)}function X$($){return O0(J5(),$)}function H$($){D0(Y5(),V5,c5,$)}function d5(){return e(Y5(),V5)}function j$(){return R0(Y5(),V5,c5)}function cQ(){let $={};for(let Z of g)$[Z]=l5(Z);let Q={};for(let Z of X5)Q[Z.event]=V$({event:Z.event,command:Z.command});return{homeExists:t9(y0()),skills:$,hooks:Q,claudeMdBlock:d5()}}async function G$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (n0(),o0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},V=[];for(let G of g){if(!l5(G))V.push(G);Z$(G,Y[G])}let H=0;for(let G of X5)if(Y$({event:G.event,matcher:G.matcher,command:G.command}))H++;let j=d5();return H$(Q$),{skillsAdded:V,hooksAdded:H,claudeMdBlockTouched:!j}}async function s5(){let $;try{$={ok:!0,...await G$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (p5(),m5));if(Q.codexDetected())$.codex={ok:!0,...await Q.setupCodexAssets()}}catch(Q){$.codex={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return $}function lQ(){let $=[];for(let Y of g)if(J$(Y))$.push(Y);let Q=0;for(let Y of X5)if(X$(Y))Q++;let Z=j$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as O$}from"async_hooks";import{spawnSync as D$}from"child_process";import{createHash as R$}from"crypto";import{existsSync as r5,mkdirSync as Y0,readFileSync as G5,writeFileSync as W5}from"fs";import{homedir as t5}from"os";import{basename as A$,join as x,parse as E$,resolve as i5}from"path";function _(){return process.env.BEACON_HOME||x(t5(),".beacon")}function U5(){return x(_(),"workspaces.json")}function l($){return R$("sha256").update($).digest("hex").slice(0,12)}function e5($=process.cwd()){let Q=D$("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function S0($){let Q=i5($);return Q!==i5(t5())&&Q!==E$(Q).root}function $9(){return x(_(),"deleted.json")}function B5(){try{let $=JSON.parse(G5($9(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function Q9($){Y0(_(),{recursive:!0}),W5($9(),JSON.stringify($,null,2))}function h0($){return B5().includes($)}function YZ($){let Q=B5();if(!Q.includes($))Q9([...Q,$])}function I$($){let Q=B5();if(Q.includes($))Q9(Q.filter((Z)=>Z!==$))}function u0($){return x(_(),$)}function K5($){return`file:${x(u0($),"db.sqlite")}`}function V0(){try{let $=JSON.parse(G5(U5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function M5($){Y0(_(),{recursive:!0}),W5(U5(),JSON.stringify($,null,2))}function T$(){return V0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function z($){return V0().find((Q)=>Q.id===$)??null}function f0($,Q,Z=new Date().toISOString()){if(!S0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=l($);if(h0(Y))throw Error(`beacon: workspace ${Y} (${$}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let V=V0(),H=V.find((W)=>W.id===Y),j={id:Y,path:$,name:Q||H?.name||A$($),lastOpenedAt:Z},G=[j,...V.filter((W)=>W.id!==Y)];return Y0(u0(Y),{recursive:!0}),M5(G),j}function VZ($,Q){return I$(l($)),f0($,Q)}function XZ($,Q=new Date().toISOString()){let Z=V0(),Y=Z.find((V)=>V.id===$);if(!Y)return;Y.lastOpenedAt=Q,M5(Z)}function HZ($){if(M5(V0().filter((Q)=>Q.id!==$)),X0()===$)_$(T$()[0]?.id??null)}function Z9(){return x(_(),"active")}function X0(){try{return G5(Z9(),"utf8").trim()||null}catch{return null}}function _$($){Y0(_(),{recursive:!0}),W5(Z9(),$??"")}function jZ(){let $=X0();return $?z($):null}function GZ(){let $=P5()??X0();return $?z($):null}function WZ($){return z($)?.path??null}function UZ(){return r5(U5())}var J9="beacon_ws";function Y9($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let Y of Z.split(";")){let V=Y.indexOf("=");if(V===-1)continue;if(Y.slice(0,V).trim()===Q)return decodeURIComponent(Y.slice(V+1).trim())}return null}function BZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&z(Q))return Q;let Z=Y9($,J9);if(Z&&z(Z))return Z;return null}var N5="x-beacon-workspace-path";async function KZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&z(Q))return Q;let Z=$.headers.get(N5);if(Z&&S0(Z)&&!h0(l(Z))&&(!Q||l(Z)===Q)){let V=f0(Z);return await q5(V.id),V.id}let Y=Y9($,J9);if(Y&&z(Y))return Y;return null}var V9=new O$;function L$($,Q){return $?V9.run($,Q):Q()}function P5(){return V9.getStore()??null}var j5=new Set;function MZ($){j5.delete(x(u0($),"db.sqlite"))}async function q5($){let Q=u0($),Z=x(Q,"db.sqlite"),Y=r5(Z);if(Y&&j5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Y0(Q,{recursive:!0});let{provisionDb:V}=await a5().then(() => n5),H=await V(K5($));return j5.add(Z),{ok:!0,created:!Y,migrated:Y&&H.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{connect as k$}from"net";var X9=4319;function g$($,Q,Z=400){return new Promise((Y)=>{let V=k$({host:$,port:Q}),H=!1,j=(G)=>{if(H)return;H=!0,V.destroy(),Y(G)};V.once("connect",()=>j(!0)),V.once("error",()=>j(!1)),V.setTimeout(Z,()=>j(!1))})}async function x$($){for(let Q of["127.0.0.1","::1"])if(await g$(Q,$))return!1;return!0}async function qZ($,Q=20){for(let Z=$;Z<$+Q;Z++)if(await x$(Z))return Z;return $}import{McpServer as OQ,ResourceTemplate as E5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as DQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var y$=new Set(["GET","HEAD","OPTIONS"]);function H9($){return y$.has($.trim().toUpperCase())?"read":"write"}var z$=B.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},B.object({name:B.string().trim().min(1),type:B.string().trim().min(1),isPk:B.boolean().optional(),isFk:B.boolean().optional(),nullable:B.boolean().optional(),note:B.string().nullish()})),j9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(z$).default([])}),G9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),W9=B.object({method:B.string().trim().min(1),path:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),uses:B.array(B.object({table:B.string().trim().min(1),access:B.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??H9($.method)}))})),OZ=B.object({tables:B.array(j9).default([]),relations:B.array(G9).default([]),endpoints:B.array(W9).default([])});import{z as R}from"zod";import{and as dZ,eq as sZ,inArray as oZ}from"drizzle-orm";import{drizzle as VQ}from"drizzle-orm/libsql";import{createClient as XQ}from"@libsql/client";var w5={};r(w5,{tag:()=>d,syncState:()=>b$,projectMeta:()=>p$,note:()=>u$,nodeTags:()=>S,nodeFile:()=>H0,node:()=>M,endpointTable:()=>u,endpoint:()=>s,edge:()=>y,draftTable:()=>A,draftRelation:()=>f,draftColumn:()=>W0,dbTable:()=>v,dbRelation:()=>h,dbColumn:()=>G0,codeFileEdge:()=>b,codeFile:()=>L,bugFlag:()=>j0,boardAnnotation:()=>f$,appSetting:()=>m$});import{sqliteTable as q,index as P,foreignKey as S$,text as X,integer as U,real as D,uniqueIndex as k,primaryKey as h$}from"drizzle-orm/sqlite-core";import{createId as F}from"@paralleldrive/cuid2";var M=q("Node",{id:X().primaryKey().$defaultFn(()=>F()),view:X().notNull(),kind:X().default("FEATURE").notNull(),cluster:X(),layer:X(),title:X().notNull(),role:X(),plain:X(),status:X().default("PENDING").notNull(),priority:U().default(2).notNull(),progress:U().default(0).notNull(),x:D().default(0).notNull(),y:D().default(0).notNull(),sourceRef:X(),externalId:X(),source:X().default("MANUAL").notNull(),planId:X(),parentId:X(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[P("Node_cluster_idx").on($.cluster),P("Node_parentId_idx").on($.parentId),P("Node_view_idx").on($.view),S$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),H0=q("NodeFile",{id:X().primaryKey().$defaultFn(()=>F()),nodeId:X().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),path:X().notNull()},($)=>[k("NodeFile_nodeId_path_key").on($.nodeId,$.path),P("NodeFile_nodeId_idx").on($.nodeId)]),d=q("Tag",{id:X().primaryKey().$defaultFn(()=>F()),label:X().notNull(),color:X()},($)=>[k("Tag_label_key").on($.label)]),y=q("Edge",{id:X().primaryKey().$defaultFn(()=>F()),fromId:X().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:X().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:X().default("DEPENDS").notNull(),label:X(),sourceHandle:X(),targetHandle:X()},($)=>[k("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),P("Edge_toId_idx").on($.toId),P("Edge_fromId_idx").on($.fromId)]),S=q("_NodeTags",{a:X("A").notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),b:X("B").notNull().references(()=>d.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[k("_NodeTags_AB_unique").on($.a,$.b),P("_NodeTags_B_index").on($.b)]),u$=q("Note",{id:X().primaryKey().$defaultFn(()=>F()),title:X().default("Untitled").notNull(),body:X().default("").notNull(),ord:D().default(0).notNull(),pinned:U({mode:"boolean"}).default(!1).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[P("Note_updatedAt_idx").on($.updatedAt)]),f$=q("BoardAnnotation",{id:X().primaryKey().$defaultFn(()=>F()),targetKind:X().notNull(),targetId:X().notNull(),columnName:X(),body:X().default("").notNull(),x:D(),y:D(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[P("BoardAnnotation_target_idx").on($.targetId)]),j0=q("BugFlag",{id:X().primaryKey().$defaultFn(()=>F()),nodeId:X().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),by:X().notNull(),note:X().notNull(),resolvedAt:U({mode:"timestamp_ms"}),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[P("BugFlag_nodeId_idx").on($.nodeId)]),v=q("DbTable",{id:X().primaryKey().$defaultFn(()=>F()),name:X().notNull(),domain:X(),description:X(),source:X().default("MANUAL").notNull(),planId:X(),x:D().default(0).notNull(),y:D().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[P("DbTable_domain_idx").on($.domain),k("DbTable_name_key").on($.name)]),G0=q("DbColumn",{id:X().primaryKey().$defaultFn(()=>F()),tableId:X().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),name:X().notNull(),type:X().notNull(),isPk:U({mode:"boolean"}).default(!1).notNull(),isFk:U({mode:"boolean"}).default(!1).notNull(),nullable:U({mode:"boolean"}).default(!0).notNull(),note:X(),ord:U().default(0).notNull()},($)=>[k("DbColumn_tableId_name_key").on($.tableId,$.name),P("DbColumn_tableId_idx").on($.tableId)]),h=q("DbRelation",{id:X().primaryKey().$defaultFn(()=>F()),fromTableId:X().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:X().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:X().notNull(),toColumn:X().notNull(),label:X()},($)=>[P("DbRelation_toTableId_idx").on($.toTableId),P("DbRelation_fromTableId_idx").on($.fromTableId)]),s=q("Endpoint",{id:X().primaryKey().$defaultFn(()=>F()),method:X().notNull(),path:X().notNull(),domain:X(),description:X(),source:X().default("MANUAL").notNull(),planId:X(),x:D().default(0).notNull(),y:D().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("Endpoint_method_path_key").on($.method,$.path),P("Endpoint_domain_idx").on($.domain)]),u=q("EndpointTable",{id:X().primaryKey().$defaultFn(()=>F()),endpointId:X().notNull().references(()=>s.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:X().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),access:X().default("read").notNull()},($)=>[k("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),P("EndpointTable_tableId_idx").on($.tableId)]),A=q("DraftTable",{id:X().primaryKey().$defaultFn(()=>F()),name:X().notNull(),domain:X(),description:X(),x:D().default(0).notNull(),y:D().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[k("DraftTable_name_key").on($.name)]),W0=q("DraftColumn",{id:X().primaryKey().$defaultFn(()=>F()),tableId:X().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:X().notNull(),type:X().notNull(),isPk:U({mode:"boolean"}).default(!1).notNull(),isFk:U({mode:"boolean"}).default(!1).notNull(),nullable:U({mode:"boolean"}).default(!0).notNull(),note:X(),ord:U().default(0).notNull()},($)=>[P("DraftColumn_tableId_idx").on($.tableId)]),f=q("DraftRelation",{id:X().primaryKey().$defaultFn(()=>F()),fromTableId:X().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:X().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:X().notNull(),toColumn:X().notNull(),label:X()},($)=>[P("DraftRelation_toTableId_idx").on($.toTableId),P("DraftRelation_fromTableId_idx").on($.fromTableId)]),L=q("CodeFile",{path:X().primaryKey(),root:X(),lang:X(),x:D().default(0).notNull(),y:D().default(0).notNull(),mtimeMs:D(),size:U(),inDegree:U().default(0).notNull(),outDegree:U().default(0).notNull(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),b=q("CodeFileEdge",{fromPath:X().notNull().references(()=>L.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:X().notNull().references(()=>L.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:U({mode:"boolean"}).default(!1).notNull()},($)=>[P("CodeFileEdge_circular_idx").on($.circular),P("CodeFileEdge_toPath_idx").on($.toPath),P("CodeFileEdge_fromPath_idx").on($.fromPath),h$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),b$=q("SyncState",{id:X().primaryKey().default("singleton"),version:U().default(0).notNull(),codeGraphSyncedAt:U({mode:"timestamp_ms"}),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),m$=q("AppSetting",{id:X().primaryKey().default("singleton"),editor:X().default("auto").notNull(),currentFeatureId:X(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),p$=q("ProjectMeta",{id:X().primaryKey().default("singleton"),overview:X(),conventions:X().default("[]").notNull(),hasFrontend:U({mode:"boolean"}),classificationRoots:X().default("[]").notNull(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var C5={};r(C5,{tagRelations:()=>s$,nodeTagsRelations:()=>o$,nodeRelations:()=>c$,nodeFileRelations:()=>l$,endpointTableRelations:()=>e$,endpointRelations:()=>t$,edgeRelations:()=>n$,draftTableRelations:()=>$Q,draftRelationRelations:()=>ZQ,draftColumnRelations:()=>QQ,dbTableRelations:()=>a$,dbRelationRelations:()=>r$,dbColumnRelations:()=>i$,codeFileRelations:()=>JQ,codeFileEdgeRelations:()=>YQ,bugFlagRelations:()=>d$});import{relations as C}from"drizzle-orm";var c$=C(M,({one:$,many:Q})=>({files:Q(H0),bugFlags:Q(j0),nodeTags:Q(S),edgesOut:Q(y,{relationName:"EdgeFrom"}),edgesIn:Q(y,{relationName:"EdgeTo"}),parent:$(M,{fields:[M.parentId],references:[M.id],relationName:"NodeTree"}),children:Q(M,{relationName:"NodeTree"})})),l$=C(H0,({one:$})=>({node:$(M,{fields:[H0.nodeId],references:[M.id]})})),d$=C(j0,({one:$})=>({node:$(M,{fields:[j0.nodeId],references:[M.id]})})),s$=C(d,({many:$})=>({nodeTags:$(S)})),o$=C(S,({one:$})=>({node:$(M,{fields:[S.a],references:[M.id]}),tag:$(d,{fields:[S.b],references:[d.id]})})),n$=C(y,({one:$})=>({from:$(M,{fields:[y.fromId],references:[M.id],relationName:"EdgeFrom"}),to:$(M,{fields:[y.toId],references:[M.id],relationName:"EdgeTo"})})),a$=C(v,({many:$})=>({columns:$(G0),fksOut:$(h,{relationName:"FkFrom"}),fksIn:$(h,{relationName:"FkTo"}),usages:$(u)})),i$=C(G0,({one:$})=>({table:$(v,{fields:[G0.tableId],references:[v.id]})})),r$=C(h,({one:$})=>({fromTable:$(v,{fields:[h.fromTableId],references:[v.id],relationName:"FkFrom"}),toTable:$(v,{fields:[h.toTableId],references:[v.id],relationName:"FkTo"})})),t$=C(s,({many:$})=>({tables:$(u)})),e$=C(u,({one:$})=>({endpoint:$(s,{fields:[u.endpointId],references:[s.id]}),table:$(v,{fields:[u.tableId],references:[v.id]})})),$Q=C(A,({many:$})=>({columns:$(W0),fksOut:$(f,{relationName:"DraftFkFrom"}),fksIn:$(f,{relationName:"DraftFkTo"})})),QQ=C(W0,({one:$})=>({table:$(A,{fields:[W0.tableId],references:[A.id]})})),ZQ=C(f,({one:$})=>({fromTable:$(A,{fields:[f.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[f.toTableId],references:[A.id],relationName:"DraftFkTo"})})),JQ=C(L,({many:$})=>({edgesOut:$(b,{relationName:"CFEFrom"}),edgesIn:$(b,{relationName:"CFETo"})})),YQ=C(b,({one:$})=>({fromFile:$(L,{fields:[b.fromPath],references:[L.path],relationName:"CFEFrom"}),toFile:$(L,{fields:[b.toPath],references:[L.path],relationName:"CFETo"})}));var HQ={...w5,...C5};function jQ(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var GQ=jQ();function U9($){let Q=XQ({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),VQ(Q,{schema:HQ})}var F5=globalThis,v5=F5.dzDefault??U9(GQ);F5.dzDefault=v5;var b0=F5.dzByUrl??=new Map;function WQ($){let Q=b0.get($);if(!Q)Q=U9($),b0.set($,Q);return Q}function kZ($){let Q=b0.get($);b0.delete($);try{Q?.$client?.close?.()}catch{}}function UQ(){if(process.env.BEACON_REPO)return v5;let $=P5()??X0();if(!$)return v5;return WQ(K5($))}var BQ=new Proxy({},{get($,Q){let Z=UQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});var KQ=["frontend","backend","fullstack"],MQ={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function m0($){let Q=($??"").trim().toLowerCase();if(!Q)return null;if(KQ.includes(Q))return Q;return MQ[Q]??null}import{forceCenter as SZ,forceCollide as hZ,forceLink as uZ,forceManyBody as fZ,forceSimulation as bZ}from"d3-force";var B9=R.object({title:R.string().trim().min(1),role:R.string().nullish(),plain:R.string().nullish(),cluster:R.string().nullish(),category:R.string().nullish(),domain:R.string().nullish(),priority:R.number().nullish(),kind:R.string().nullish(),layer:R.string().nullish(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,layer:V,...H})=>({...H,cluster:H.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE",layer:m0(V)})),tZ=R.object({features:R.array(B9).default([])});var NQ=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function K9($){return!!$&&NQ.test($)}function PQ($){return $.cluster??$.category??$.domain??null}function M9($,Q){let Z=Q?.requireLayer??!1,Y=$.map((H)=>{let j=[],G=PQ(H);if(!G||!G.trim())j.push("category");if(H.priority==null)j.push("priority");if(Z&&!m0(H.layer))j.push("layer");return j.length?` \u2022 "${H.title?.trim()||"(untitled)"}" \u2014 missing ${j.join(" + ")}`:null}).filter((H)=>H!==null);if(Y.length===0)return null;let V=Z?" This workspace has a frontend surface, so every feature must also carry `layer`: "+'"frontend" | "backend" | "fullstack" \u2014 which side of the stack the work lands on.':"";return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+"on the board, and the user shouldn't have to add them by hand."+V+` Missing:
255
+ ${p5}
256
+ `});var t5={};t(t5,{provisionDb:()=>A$});import{createClient as N$}from"@libsql/client";import{drizzle as M$}from"drizzle-orm/libsql";import{migrate as P$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as q$}from"drizzle-orm/migrator";import{dirname as B5,join as w$}from"path";import{fileURLToPath as C$}from"url";async function S0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function O$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function r5($){if(!await S0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function R$($){for(let[Q,Z]of Object.entries(D$)){if(!await S0($,Q))continue;let Y=await O$($,Q);for(let X of Z){if(!Y.has(X))continue;await $.execute(`UPDATE "${Q}" SET "${X}" = CAST((julianday("${X}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${X}") = 'text'`)}}}async function A$($,Q=F$){let Z=N$({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let Y=await S0(Z,"__drizzle_migrations"),X=await S0(Z,"Node"),H=!1;if(X&&!Y){let G=q$({migrationsFolder:Q})[0];if(G)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[G.hash,G.folderMillis]}),H=!0}let j=await r5(Z);if(await P$(M$(Z),{migrationsFolder:Q}),await r5(Z)>j)H=!0;return await R$(Z),{migrated:H}}finally{Z.close()}}var v$,F$,D$;var e5=c(async()=>{v$=B5(B5(B5(C$(import.meta.url)))),F$=process.env.BEACON_MIGRATIONS_DIR||w$(v$,"drizzle"),D$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});Z5();import{existsSync as Z$}from"fs";import{homedir as J$}from"os";import{join as x0}from"path";function Y$(){return process.env.HOME||process.env.USERPROFILE||J$()}var z0=()=>x0(Y$(),".claude"),H5=()=>x0(z0(),"skills"),j5=()=>x0(z0(),"settings.json"),G5=()=>x0(z0(),"CLAUDE.md"),W5="<!-- beacon:global:start -->",o5="<!-- beacon:global:end -->";var V$=v0,U5=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function X$($,Q){return E0(H5(),$,Q)}function n5($){return $0(H5(),$)}function H$($){return I0(H5(),$)}function j$($){return F0(j5(),$)}function G$($){return D0(j5(),$)}function W$($){return O0(j5(),$)}function U$($){R0(G5(),W5,o5,$)}function a5(){return e(G5(),W5)}function B$(){return A0(G5(),W5,o5)}function tQ(){let $={};for(let Z of g)$[Z]=n5(Z);let Q={};for(let Z of U5)Q[Z.event]=G$({event:Z.event,command:Z.command});return{homeExists:Z$(z0()),skills:$,hooks:Q,claudeMdBlock:a5()}}async function K$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (e0(),t0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let G of g){if(!n5(G))X.push(G);X$(G,Y[G])}let H=0;for(let G of U5)if(j$({event:G.event,matcher:G.matcher,command:G.command}))H++;let j=a5();return U$(V$),{skillsAdded:X,hooksAdded:H,claudeMdBlockTouched:!j}}async function i5(){let $;try{$={ok:!0,...await K$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (s5(),d5));if(Q.codexDetected())$.codex={ok:!0,...await Q.setupCodexAssets()}}catch(Q){$.codex={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return $}function eQ(){let $=[];for(let Y of g)if(H$(Y))$.push(Y);let Q=0;for(let Y of U5)if(W$(Y))Q++;let Z=B$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as E$}from"async_hooks";import{spawnSync as I$}from"child_process";import{createHash as L$}from"crypto";import{existsSync as Q9,mkdirSync as Y0,readFileSync as N5,writeFileSync as M5}from"fs";import{homedir as Z9}from"os";import{basename as T$,join as y,parse as _$,resolve as $9}from"path";function _(){return process.env.BEACON_HOME||y(Z9(),".beacon")}function P5(){return y(_(),"workspaces.json")}function s($){return L$("sha256").update($).digest("hex").slice(0,12)}function J9($=process.cwd()){let Q=I$("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function h0($){let Q=$9($);return Q!==$9(Z9())&&Q!==_$(Q).root}function Y9(){return y(_(),"deleted.json")}function q5(){try{let $=JSON.parse(N5(Y9(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function V9($){Y0(_(),{recursive:!0}),M5(Y9(),JSON.stringify($,null,2))}function u0($){return q5().includes($)}function KZ($){let Q=q5();if(!Q.includes($))V9([...Q,$])}function k$($){let Q=q5();if(Q.includes($))V9(Q.filter((Z)=>Z!==$))}function f0($){return y(_(),$)}function w5($){return`file:${y(f0($),"db.sqlite")}`}function V0(){try{let $=JSON.parse(N5(P5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function C5($){Y0(_(),{recursive:!0}),M5(P5(),JSON.stringify($,null,2))}function b0(){return V0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function S($){return V0().find((Q)=>Q.id===$)??null}function m0($,Q,Z=new Date().toISOString()){if(!h0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=s($);if(u0(Y))throw Error(`beacon: workspace ${Y} (${$}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let X=V0(),H=X.find((W)=>W.id===Y),j={id:Y,path:$,name:Q||H?.name||T$($),lastOpenedAt:Z},G=[j,...X.filter((W)=>W.id!==Y)];return Y0(f0(Y),{recursive:!0}),C5(G),j}function NZ($,Q){return k$(s($)),m0($,Q)}function MZ($,Q=new Date().toISOString()){let Z=V0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,C5(Z)}function PZ($){if(C5(V0().filter((Q)=>Q.id!==$)),X0()===$)g$(b0()[0]?.id??null)}function X9(){return y(_(),"active")}function X0(){try{return N5(X9(),"utf8").trim()||null}catch{return null}}function g$($){Y0(_(),{recursive:!0}),M5(X9(),$??"")}function qZ(){let $=X0();return $?S($):null}function wZ(){let $=F5()??X0();return $?S($):null}function CZ($){return S($)?.path??null}function vZ(){return Q9(P5())}var H9="beacon_ws";function j9($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let Y of Z.split(";")){let X=Y.indexOf("=");if(X===-1)continue;if(Y.slice(0,X).trim()===Q)return decodeURIComponent(Y.slice(X+1).trim())}return null}function FZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&S(Q))return Q;let Z=j9($,H9);if(Z&&S(Z))return Z;return y$()}function y$(){let $=b0();return $.length===1?$[0].id:null}var v5="x-beacon-workspace-path";async function DZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&S(Q))return Q;let Z=$.headers.get(v5);if(Z&&h0(Z)&&!u0(s(Z))&&(!Q||s(Z)===Q)){let X=m0(Z);return await D5(X.id),X.id}let Y=j9($,H9);if(Y&&S(Y))return Y;return null}var G9=new E$;function x$($,Q){return $?G9.run($,Q):Q()}function F5(){return G9.getStore()??null}var K5=new Set;function OZ($){K5.delete(y(f0($),"db.sqlite"))}async function D5($){let Q=f0($),Z=y(Q,"db.sqlite"),Y=Q9(Z);if(Y&&K5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Y0(Q,{recursive:!0});let{provisionDb:X}=await e5().then(() => t5),H=await X(w5($));return K5.add(Z),{ok:!0,created:!Y,migrated:Y&&H.migrated}}catch(X){return{ok:!1,created:!1,migrated:!1,error:X instanceof Error?X.message:String(X)}}}import{connect as z$}from"net";var W9=4319;function S$($,Q,Z=400){return new Promise((Y)=>{let X=z$({host:$,port:Q}),H=!1,j=(G)=>{if(H)return;H=!0,X.destroy(),Y(G)};X.once("connect",()=>j(!0)),X.once("error",()=>j(!1)),X.setTimeout(Z,()=>j(!1))})}async function h$($){for(let Q of["127.0.0.1","::1"])if(await S$(Q,$))return!1;return!0}async function EZ($,Q=20){for(let Z=$;Z<$+Q;Z++)if(await h$(Z))return Z;return $}import{McpServer as LQ,ResourceTemplate as T5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as TQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var u$=new Set(["GET","HEAD","OPTIONS"]);function U9($){return u$.has($.trim().toUpperCase())?"read":"write"}var f$=B.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},B.object({name:B.string().trim().min(1),type:B.string().trim().min(1),isPk:B.boolean().optional(),isFk:B.boolean().optional(),nullable:B.boolean().optional(),note:B.string().nullish()})),B9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(f$).default([])}),K9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),N9=B.object({method:B.string().trim().min(1),path:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),uses:B.array(B.object({table:B.string().trim().min(1),access:B.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??U9($.method)}))})),kZ=B.object({tables:B.array(B9).default([]),relations:B.array(K9).default([]),endpoints:B.array(N9).default([])});import{z as R}from"zod";import{and as $1,eq as Q1,inArray as Z1}from"drizzle-orm";import{drizzle as UQ}from"drizzle-orm/libsql";import{createClient as BQ}from"@libsql/client";var O5={};t(O5,{workspaceFlag:()=>o$,tag:()=>o,syncState:()=>l$,projectMeta:()=>s$,planContract:()=>n$,note:()=>p$,nodeTags:()=>h,nodeFile:()=>H0,node:()=>M,endpointTable:()=>f,endpoint:()=>n,edge:()=>x,draftTable:()=>A,draftRelation:()=>b,draftColumn:()=>W0,dbTable:()=>F,dbRelation:()=>u,dbColumn:()=>G0,codeFileEdge:()=>m,codeFile:()=>k,bugFlag:()=>j0,boardAnnotation:()=>c$,appSetting:()=>d$});import{sqliteTable as P,index as N,foreignKey as b$,text as V,integer as U,real as O,uniqueIndex as L,primaryKey as m$}from"drizzle-orm/sqlite-core";import{createId as C}from"@paralleldrive/cuid2";var M=P("Node",{id:V().primaryKey().$defaultFn(()=>C()),view:V().notNull(),kind:V().default("FEATURE").notNull(),cluster:V(),layer:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:U().default(2).notNull(),progress:U().default(0).notNull(),x:O().default(0).notNull(),y:O().default(0).notNull(),sourceRef:V(),externalId:V(),source:V().default("MANUAL").notNull(),planId:V(),parentId:V(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Node_cluster_idx").on($.cluster),N("Node_parentId_idx").on($.parentId),N("Node_view_idx").on($.view),b$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),H0=P("NodeFile",{id:V().primaryKey().$defaultFn(()=>C()),nodeId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),path:V().notNull()},($)=>[L("NodeFile_nodeId_path_key").on($.nodeId,$.path),N("NodeFile_nodeId_idx").on($.nodeId)]),o=P("Tag",{id:V().primaryKey().$defaultFn(()=>C()),label:V().notNull(),color:V()},($)=>[L("Tag_label_key").on($.label)]),x=P("Edge",{id:V().primaryKey().$defaultFn(()=>C()),fromId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:V().default("DEPENDS").notNull(),label:V(),sourceHandle:V(),targetHandle:V()},($)=>[L("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),N("Edge_toId_idx").on($.toId),N("Edge_fromId_idx").on($.fromId)]),h=P("_NodeTags",{a:V("A").notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),b:V("B").notNull().references(()=>o.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[L("_NodeTags_AB_unique").on($.a,$.b),N("_NodeTags_B_index").on($.b)]),p$=P("Note",{id:V().primaryKey().$defaultFn(()=>C()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:O().default(0).notNull(),pinned:U({mode:"boolean"}).default(!1).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Note_updatedAt_idx").on($.updatedAt)]),c$=P("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>C()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:O(),y:O(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("BoardAnnotation_target_idx").on($.targetId)]),j0=P("BugFlag",{id:V().primaryKey().$defaultFn(()=>C()),nodeId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),by:V().notNull(),note:V().notNull(),resolvedAt:U({mode:"timestamp_ms"}),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[N("BugFlag_nodeId_idx").on($.nodeId)]),F=P("DbTable",{id:V().primaryKey().$defaultFn(()=>C()),name:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("DbTable_domain_idx").on($.domain),L("DbTable_name_key").on($.name)]),G0=P("DbColumn",{id:V().primaryKey().$defaultFn(()=>C()),tableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:U({mode:"boolean"}).default(!1).notNull(),isFk:U({mode:"boolean"}).default(!1).notNull(),nullable:U({mode:"boolean"}).default(!0).notNull(),note:V(),ord:U().default(0).notNull()},($)=>[L("DbColumn_tableId_name_key").on($.tableId,$.name),N("DbColumn_tableId_idx").on($.tableId)]),u=P("DbRelation",{id:V().primaryKey().$defaultFn(()=>C()),fromTableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DbRelation_toTableId_idx").on($.toTableId),N("DbRelation_fromTableId_idx").on($.fromTableId)]),n=P("Endpoint",{id:V().primaryKey().$defaultFn(()=>C()),method:V().notNull(),path:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[L("Endpoint_method_path_key").on($.method,$.path),N("Endpoint_domain_idx").on($.domain)]),f=P("EndpointTable",{id:V().primaryKey().$defaultFn(()=>C()),endpointId:V().notNull().references(()=>n.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),access:V().default("read").notNull()},($)=>[L("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),N("EndpointTable_tableId_idx").on($.tableId)]),A=P("DraftTable",{id:V().primaryKey().$defaultFn(()=>C()),name:V().notNull(),domain:V(),description:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[L("DraftTable_name_key").on($.name)]),W0=P("DraftColumn",{id:V().primaryKey().$defaultFn(()=>C()),tableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:U({mode:"boolean"}).default(!1).notNull(),isFk:U({mode:"boolean"}).default(!1).notNull(),nullable:U({mode:"boolean"}).default(!0).notNull(),note:V(),ord:U().default(0).notNull()},($)=>[N("DraftColumn_tableId_idx").on($.tableId)]),b=P("DraftRelation",{id:V().primaryKey().$defaultFn(()=>C()),fromTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DraftRelation_toTableId_idx").on($.toTableId),N("DraftRelation_fromTableId_idx").on($.fromTableId)]),k=P("CodeFile",{path:V().primaryKey(),root:V(),lang:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),mtimeMs:O(),size:U(),inDegree:U().default(0).notNull(),outDegree:U().default(0).notNull(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),m=P("CodeFileEdge",{fromPath:V().notNull().references(()=>k.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:V().notNull().references(()=>k.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:U({mode:"boolean"}).default(!1).notNull()},($)=>[N("CodeFileEdge_circular_idx").on($.circular),N("CodeFileEdge_toPath_idx").on($.toPath),N("CodeFileEdge_fromPath_idx").on($.fromPath),m$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),l$=P("SyncState",{id:V().primaryKey().default("singleton"),version:U().default(0).notNull(),codeGraphSyncedAt:U({mode:"timestamp_ms"}),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),d$=P("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),s$=P("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),hasFrontend:U({mode:"boolean"}),classificationRoots:V().default("[]").notNull(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),o$=P("WorkspaceFlag",{id:V().primaryKey().$defaultFn(()=>C()),key:V().notNull(),enabled:U({mode:"boolean"}).default(!1).notNull(),config:V(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[L("WorkspaceFlag_key_key").on($.key)]),n$=P("PlanContract",{id:V().primaryKey().$defaultFn(()=>C()),planId:V().notNull(),declaredFiles:V().default("[]").notNull(),authorizedExtras:V().default("[]").notNull(),active:U({mode:"boolean"}).default(!1).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[L("PlanContract_planId_key").on($.planId),N("PlanContract_active_idx").on($.active)]);var R5={};t(R5,{tagRelations:()=>t$,nodeTagsRelations:()=>e$,nodeRelations:()=>a$,nodeFileRelations:()=>i$,endpointTableRelations:()=>VQ,endpointRelations:()=>YQ,edgeRelations:()=>$Q,draftTableRelations:()=>XQ,draftRelationRelations:()=>jQ,draftColumnRelations:()=>HQ,dbTableRelations:()=>QQ,dbRelationRelations:()=>JQ,dbColumnRelations:()=>ZQ,codeFileRelations:()=>GQ,codeFileEdgeRelations:()=>WQ,bugFlagRelations:()=>r$});import{relations as v}from"drizzle-orm";var a$=v(M,({one:$,many:Q})=>({files:Q(H0),bugFlags:Q(j0),nodeTags:Q(h),edgesOut:Q(x,{relationName:"EdgeFrom"}),edgesIn:Q(x,{relationName:"EdgeTo"}),parent:$(M,{fields:[M.parentId],references:[M.id],relationName:"NodeTree"}),children:Q(M,{relationName:"NodeTree"})})),i$=v(H0,({one:$})=>({node:$(M,{fields:[H0.nodeId],references:[M.id]})})),r$=v(j0,({one:$})=>({node:$(M,{fields:[j0.nodeId],references:[M.id]})})),t$=v(o,({many:$})=>({nodeTags:$(h)})),e$=v(h,({one:$})=>({node:$(M,{fields:[h.a],references:[M.id]}),tag:$(o,{fields:[h.b],references:[o.id]})})),$Q=v(x,({one:$})=>({from:$(M,{fields:[x.fromId],references:[M.id],relationName:"EdgeFrom"}),to:$(M,{fields:[x.toId],references:[M.id],relationName:"EdgeTo"})})),QQ=v(F,({many:$})=>({columns:$(G0),fksOut:$(u,{relationName:"FkFrom"}),fksIn:$(u,{relationName:"FkTo"}),usages:$(f)})),ZQ=v(G0,({one:$})=>({table:$(F,{fields:[G0.tableId],references:[F.id]})})),JQ=v(u,({one:$})=>({fromTable:$(F,{fields:[u.fromTableId],references:[F.id],relationName:"FkFrom"}),toTable:$(F,{fields:[u.toTableId],references:[F.id],relationName:"FkTo"})})),YQ=v(n,({many:$})=>({tables:$(f)})),VQ=v(f,({one:$})=>({endpoint:$(n,{fields:[f.endpointId],references:[n.id]}),table:$(F,{fields:[f.tableId],references:[F.id]})})),XQ=v(A,({many:$})=>({columns:$(W0),fksOut:$(b,{relationName:"DraftFkFrom"}),fksIn:$(b,{relationName:"DraftFkTo"})})),HQ=v(W0,({one:$})=>({table:$(A,{fields:[W0.tableId],references:[A.id]})})),jQ=v(b,({one:$})=>({fromTable:$(A,{fields:[b.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[b.toTableId],references:[A.id],relationName:"DraftFkTo"})})),GQ=v(k,({many:$})=>({edgesOut:$(m,{relationName:"CFEFrom"}),edgesIn:$(m,{relationName:"CFETo"})})),WQ=v(m,({one:$})=>({fromFile:$(k,{fields:[m.fromPath],references:[k.path],relationName:"CFEFrom"}),toFile:$(k,{fields:[m.toPath],references:[k.path],relationName:"CFETo"})}));var KQ={...O5,...R5};function NQ(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var MQ=NQ();function M9($){let Q=BQ({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),UQ(Q,{schema:KQ})}var E5=globalThis,A5=E5.dzDefault??M9(MQ);E5.dzDefault=A5;var p0=E5.dzByUrl??=new Map;function PQ($){let Q=p0.get($);if(!Q)Q=M9($),p0.set($,Q);return Q}function bZ($){let Q=p0.get($);p0.delete($);try{Q?.$client?.close?.()}catch{}}function qQ(){if(process.env.BEACON_REPO)return A5;let $=F5()??X0();if(!$)return A5;return PQ(w5($))}var wQ=new Proxy({},{get($,Q){let Z=qQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});var CQ=["frontend","backend","fullstack"],vQ={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function c0($){let Q=($??"").trim().toLowerCase();if(!Q)return null;if(CQ.includes(Q))return Q;return vQ[Q]??null}import{forceCenter as dZ,forceCollide as sZ,forceLink as oZ,forceManyBody as nZ,forceSimulation as aZ}from"d3-force";var P9=R.object({title:R.string().trim().min(1),role:R.string().nullish(),plain:R.string().nullish(),cluster:R.string().nullish(),category:R.string().nullish(),domain:R.string().nullish(),priority:R.number().nullish(),kind:R.string().nullish(),layer:R.string().nullish(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,layer:X,...H})=>({...H,cluster:H.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE",layer:c0(X)})),H1=R.object({features:R.array(P9).default([])});var FQ=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function q9($){return!!$&&FQ.test($)}function DQ($){return $.cluster??$.category??$.domain??null}function w9($,Q){let Z=Q?.requireLayer??!1,Y=$.map((H)=>{let j=[],G=DQ(H);if(!G||!G.trim())j.push("category");if(H.priority==null)j.push("priority");if(Z&&!c0(H.layer))j.push("layer");return j.length?` \u2022 "${H.title?.trim()||"(untitled)"}" \u2014 missing ${j.join(" + ")}`:null}).filter((H)=>H!==null);if(Y.length===0)return null;let X=Z?" This workspace has a frontend surface, so every feature must also carry `layer`: "+'"frontend" | "backend" | "fullstack" \u2014 which side of the stack the work lands on.':"";return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+"on the board, and the user shouldn't have to add them by hand."+X+` Missing:
250
257
  `+Y.join(`
251
- `)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low)."+(Z?" Set `layer` on EVERY feature too.":"")+" Don't rely on defaults."}function O5($){if(!$?.length)return"";let Q=$.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),Z=$.some((Y)=>Y.id);return`
258
+ `)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low)."+(Z?" Set `layer` on EVERY feature too.":"")+" Don't rely on defaults."}function I5($){if(!$?.length)return"";let Q=$.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),Z=$.some((Y)=>Y.id);return`
252
259
 
253
260
  This plan created these roadmap feature(s):
254
261
  `+Q.join(`
255
- `)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` with a "+"`features` array \u2014 one entry per feature"+(Z?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{readFileSync as qQ}from"fs";import{join as wQ}from"path";function CQ(){try{return JSON.parse(qQ(wQ(_(),"server.json"),"utf8"))}catch{return null}}function o(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${CQ()?.port||process.env.PORT||X9}`}import{execSync as vQ}from"child_process";import{platform as N9}from"os";function FQ($){if(process.env.BEACON_NO_OPEN)return;let Q=N9()==="darwin"?"open":N9()==="win32"?"start":"xdg-open";try{vQ(`${Q} "${$}"`,{stdio:"ignore"})}catch{}}async function D5($,Q){if(await fetch(`${$}/api/plan/presence`,{headers:{"x-beacon-workspace":Q}}).then((V)=>V.json()).then((V)=>!!V?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Q}`);FQ(`${$}/api/workspace/activate?id=${Q}&redirect=${Y}`)}var R5=1500,q1=345600000,A5=1800000,P9=3000;function U0($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function q9($){return`${U0($.title)}-${$.id.slice(-6)}`}function w9($){return{resources:$.map((Q)=>({uri:`note://${q9(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function C9($,Q){return $.find((Z)=>q9(Z)===Q)}function v9($){let Q=$.body.trim()||"(this note is empty)";return[`# ${$.title||"Untitled"}`,"","_User note from Beacon. To turn it into roadmap work, call `beacon_propose_plan` \u2014"+" checkbox `- [ ]` / `- [x]` items become subtasks, and order the features with `dependsOn`. Do NOT implement until it returns approval._","","---","",Q].join(`
256
- `)}await s5();var n=e5(),m=l(n);if(!S0(n))console.error(`[beacon mcp] not registering ${n} \u2014 home/non-repo dir.`);else if(h0(m))console.error(`[beacon mcp] not registering ${n} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{f0(n);let $=await q5(m);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",m),Z.set(N5,n);let Y=await fetch(`${o()}${$}`,{...Q,headers:Z}),V=await Y.text();if(!Y.ok)throw Error(`Beacon ${$} -> ${Y.status} ${V}`);return V?JSON.parse(V):null}function a($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function I5($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let Y=JSON.parse(Z[0]);if(Y?.error)return{content:[{type:"text",text:Y.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var O=new OQ({name:"beacon",version:"0.1.0"});O.registerTool("beacon_map",{description:"List existing features on the roadmap. Call before starting work."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});O.registerTool("beacon_start_feature",{description:"Flag that you're working on a feature. If the title matches an existing feature it just marks it IN_PROGRESS (no category needed); if it's NEW it creates the node \u2014 and a new feature REQUIRES a `category`. Call beacon_map first so you reuse an existing feature/category instead of duplicating one.",inputSchema:{title:J.string(),id:J.string().optional().describe("node id from beacon_map (preferred)"),category:J.string().optional().describe("Domain lane for a NEW feature: AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 REQUIRED when this creates a new top-level feature; reuse a category already on the board. Ignored when flagging an existing feature or nesting under a `front` (inherits the parent's)."),front:J.string().optional().describe("Title of an EXISTING parent feature to nest this under (draws the parent \u2192 child edge). It must match a real feature \u2014 it is NOT a domain tag (use `category` for the domain). A `front` that matches nothing is REJECTED; create the parent first via beacon_propose_plan."),detail:J.string().optional().describe("One-line plain-language description shown on the canvas card. Replaced later by beacon_describe_feature's markdown when the work is done."),kind:J.enum(["FEATURE","BUG"]).optional().describe("Card type when this CREATES a new node: BUG renders a typed bug card on the roadmap (use when the user is starting work on a bug, not a feature). Defaults to FEATURE; ignored when flagging an existing node."),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack a NEW feature lands on. REQUIRED for a new top-level feature when the workspace has a frontend; a feature nested under a `front` inherits the parent's. Omit in pure-backend repos.")}},async({title:$,id:Q,front:Z,detail:Y,category:V,kind:H,layer:j})=>{try{let G=await a("/api/map/start",{title:$,id:Q,front:Z,detail:Y,category:V,kind:H,layer:j});return{content:[{type:"text",text:JSON.stringify(G)}]}}catch(G){return I5(G)}});O.registerTool("beacon_add_subtasks",{description:"Add N sub-tasks under an existing feature in one call. Use when the user says 'add these as subtasks to <feature>' or you want to record follow-ups discovered during work. Parent resolves by `parentId` (preferred \u2014 get it from beacon_map / beacon_entities) or by `parentTitle` (fuzzy-matched against top-level features). Children inherit the parent's view and cluster and land in a row beneath it; bumps the sync version so an open /map canvas refreshes.",inputSchema:{parentId:J.string().optional().describe("node id of the parent feature (preferred)"),parentTitle:J.string().optional().describe("fuzzy title of the parent feature; ignored if parentId is provided"),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG for a bug discovered during work \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the sub-task lands on; defaults to the parent's layer")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let Y=await a("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(Y)}]}}catch(Y){return I5(Y)}});var F9=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on (only when the repo has a frontend); omitting it on an update keeps the prior value"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found in this component's code \u2014 flagged on the node (by=agent); identical open flags are not duplicated")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");O.registerTool("beacon_describe_feature",{description:"Register shipped feature(s) at the end of the work: marks status=DONE, records the files touched (kept on the FEATURE for context), and replaces each node's description with your markdown. Subsumes touch_files + finish_feature. A feature's unfinished SUB-TASKS are completed along with it (cascade; reported as `subtasksCompleted`) \u2014 if a sub-task is genuinely NOT done, set it BLOCKED or CANCELLED via the nodes API/board FIRST, those are left alone (`subtasksBlocked` lists what stayed). REGISTER ALL FEATURES A PLAN CREATED IN ONE CALL via the `features` array (one entry per feature) \u2014 do NOT call this once per feature. Pass each feature's `id` (returned to you at plan approval) so no title-matching is needed. For a single feature you may pass the top-level fields instead. Pass `architecture` only when a feature added/changed a REAL subsystem (never a file).",inputSchema:{features:J.array(J.object({id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),architecture:F9})).optional().describe("Register many features at once \u2014 one entry per feature, each id-keyed. Use this instead of N separate calls."),description:J.string().optional().describe("Single-feature markdown (omit when using `features`): ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches (single form)"),id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),architecture:F9}},async({features:$,description:Q,files:Z,id:Y,title:V,architecture:H})=>{let j=$?.length?{features:$}:{description:Q,files:Z,id:Y,title:V,architecture:H},G=await a("/api/map/describe",j);return{content:[{type:"text",text:JSON.stringify(G)}]}});O.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),hasFrontend:J.boolean().optional().describe("Whether this repo has a frontend surface (UI code) \u2014 you just read the repo, so you know. Gates the per-item `layer` requirement + the layer UI on the boards. Set it explicitly (true or false); omitting leaves Beacon to detect it from the code graph."),classificationRoots:J.array(J.string()).optional().describe("Top-level dirs whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. ['frontend','backend/app']. The canvas groups files ONE level below each (so 'frontend' \u2192 'frontend/components', 'frontend/app', \u2026). Pick the dir sitting directly ABOVE the real package dirs (use 'frontend/src' if there's a src/ wrapper). Not every dir \u2014 just where grouping should start. Omit for a simple single-root repo (the canvas auto-groups)."),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on \u2014 set it when hasFrontend is true"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found while examining this component \u2014 flagged on the node (by=agent)")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when the survey found a concrete bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the item lands on \u2014 set it when hasFrontend is true")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await a("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});O.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let Y=new URLSearchParams;if($)Y.set("id",$);if(Q)Y.set("title",Q);if(Z)Y.set("query",Z);let V=await E(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(V)}]}});O.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let Y=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});O.registerTool("beacon_entities",{description:"Read planning data. `features` = roadmap, `architecture` = components, `tables`/`endpoints` = DB map.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"])}},async({kind:$})=>{let Q=await E(`/api/entities?kind=${$}`);return{content:[{type:"text",text:JSON.stringify(Q)}]}});O.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 and, when the workspace has a frontend, `layer` (frontend | backend | fullstack). The tool REJECTS a plan whose features omit any required field, so set them on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when this roadmap item is a bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack the work lands on. REQUIRED on every feature when the workspace has a frontend (the tool rejects the plan otherwise); omit in pure-backend repos.")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}},async({description:$,features:Q,tables:Z,relations:Y,endpoints:V})=>{let H=(N)=>new Promise((B0)=>setTimeout(B0,N)),j=(N)=>({content:[{type:"text",text:N}]}),G=(Z?.length??0)>0,W=(Q??[]).map((N)=>`${N.title} ${N.role??""} ${N.plain??""}`).join(`
257
- `),w=(V?.length??0)>0||K9(`${$}
258
- ${W}`);if(!G&&w)return j("\u26D4 This plan touches the database \u2014 it declares endpoints and/or its text describes "+"models/tables/migrations \u2014 but you passed NO `tables`. Beacon's schema board renders "+"ONLY from structured `tables`; prose is never parsed, so the /db tab would be empty and nothing would persist on approve.\n\nRe-call `beacon_propose_plan` with every table in `tables` (each with its `columns`), the `relations` (FKs), and keep the `endpoints` (each with `uses:[{table,access}]`). Mirror EVERY database entity your plan mentions into the structured fields.");if(Q?.length){let N=await E("/api/project-meta").then((I9)=>!!I9?.hasFrontend).catch(()=>!1),B0=M9(Q,{requireLayer:N});if(B0)return j(B0)}let i=(Z?.length??0)+(V?.length??0)>0;try{await a("/api/plan",{description:$,draft:i?{tables:Z??[],relations:Y??[],endpoints:V??[]}:void 0,features:Q?.length?Q:void 0})}catch(N){return I5(N)}await fetch(`${o()}/api/workspace/activate?id=${m}`).catch(()=>{}),await D5(o(),m);let E9=Date.now()+A5;while(Date.now()<E9){await H(R5);let N=await E("/api/plan/verdict").catch(()=>null);if(!N)continue;if(N.kind==="feedback")return j("\uD83D\uDCAC The user left feedback on the plan in Beacon \u2014 text comments and/or edits they "+"made directly on the /map and /db boards. Read everything below, revise the plan accordingly (matching the board changes verbatim), and call `beacon_propose_plan` "+`again with the revised version \u2014 DO NOT implement yet:
262
+ `)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` with a "+"`features` array \u2014 one entry per feature"+(Z?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{readFileSync as OQ}from"fs";import{join as RQ}from"path";function AQ(){try{return JSON.parse(OQ(RQ(_(),"server.json"),"utf8"))}catch{return null}}function a(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${AQ()?.port||process.env.PORT||W9}`}import{execSync as EQ}from"child_process";import{platform as C9}from"os";function IQ($){if(process.env.BEACON_NO_OPEN)return;let Q=C9()==="darwin"?"open":C9()==="win32"?"start":"xdg-open";try{EQ(`${Q} "${$}"`,{stdio:"ignore"})}catch{}}async function L5($,Q){if(await fetch(`${$}/api/plan/presence`,{headers:{"x-beacon-workspace":Q}}).then((X)=>X.json()).then((X)=>!!X?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Q}`);IQ(`${$}/api/workspace/activate?id=${Q}&redirect=${Y}`)}n0();function U0($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function v9($){return`${U0($.title)}-${$.id.slice(-6)}`}function F9($){return{resources:$.map((Q)=>({uri:`note://${v9(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function D9($,Q){return $.find((Z)=>v9(Z)===Q)}function O9($){let Q=$.body.trim()||"(this note is empty)";return[`# ${$.title||"Untitled"}`,"","_User note from Beacon. To turn it into roadmap work, call `beacon_propose_plan` \u2014"+" checkbox `- [ ]` / `- [x]` items become subtasks, and order the features with `dependsOn`. Do NOT implement until it returns approval._","","---","",Q].join(`
263
+ `)}await i5();var z=J9(),p=s(z);if(!h0(z)){let $=b0();if($.length===1)console.error(`[beacon mcp] cwd ${z} isn't a registered repo \u2014 falling back to your only Beacon workspace "${$[0].name}".`);else if($.length>1)console.error(`[beacon mcp] cwd ${z} isn't a registered repo and you have ${$.length} Beacon workspaces \u2014 can't auto-detect which. Run /beacon-init in this repo, or name the project explicitly in your request.`);else console.error(`[beacon mcp] not registering ${z} \u2014 home/non-repo dir.`)}else if(u0(p))console.error(`[beacon mcp] not registering ${z} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{m0(z);let $=await D5(p);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",p),Z.set(v5,z);let Y=await fetch(`${a()}${$}`,{...Q,headers:Z}),X=await Y.text();if(!Y.ok)throw Error(`Beacon ${$} -> ${Y.status} ${X}`);return X?JSON.parse(X):null}function i($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function _5($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let Y=JSON.parse(Z[0]);if(Y?.error)return{content:[{type:"text",text:Y.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var D=new LQ({name:"beacon",version:"0.1.0"});D.registerTool("beacon_map",{description:"List existing features on the roadmap. Call before starting work."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});D.registerTool("beacon_start_feature",{description:"Flag that you're working on a feature. If the title matches an existing feature it just marks it IN_PROGRESS (no category needed); if it's NEW it creates the node \u2014 and a new feature REQUIRES a `category`. Call beacon_map first so you reuse an existing feature/category instead of duplicating one.",inputSchema:{title:J.string(),id:J.string().optional().describe("node id from beacon_map (preferred)"),category:J.string().optional().describe("Domain lane for a NEW feature: AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 REQUIRED when this creates a new top-level feature; reuse a category already on the board. Ignored when flagging an existing feature or nesting under a `front` (inherits the parent's)."),front:J.string().optional().describe("Title of an EXISTING parent feature to nest this under (draws the parent \u2192 child edge). It must match a real feature \u2014 it is NOT a domain tag (use `category` for the domain). A `front` that matches nothing is REJECTED; create the parent first via beacon_propose_plan."),detail:J.string().optional().describe("One-line plain-language description shown on the canvas card. Replaced later by beacon_describe_feature's markdown when the work is done."),kind:J.enum(["FEATURE","BUG"]).optional().describe("Card type when this CREATES a new node: BUG renders a typed bug card on the roadmap (use when the user is starting work on a bug, not a feature). Defaults to FEATURE; ignored when flagging an existing node."),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack a NEW feature lands on. REQUIRED for a new top-level feature when the workspace has a frontend; a feature nested under a `front` inherits the parent's. Omit in pure-backend repos.")}},async({title:$,id:Q,front:Z,detail:Y,category:X,kind:H,layer:j})=>{try{let G=await i("/api/map/start",{title:$,id:Q,front:Z,detail:Y,category:X,kind:H,layer:j});return{content:[{type:"text",text:JSON.stringify(G)}]}}catch(G){return _5(G)}});D.registerTool("beacon_add_subtasks",{description:"Add N sub-tasks under an existing feature in one call. Use when the user says 'add these as subtasks to <feature>' or you want to record follow-ups discovered during work. Parent resolves by `parentId` (preferred \u2014 get it from beacon_map / beacon_entities) or by `parentTitle` (fuzzy-matched against top-level features). Children inherit the parent's view and cluster and land in a row beneath it; bumps the sync version so an open /map canvas refreshes.",inputSchema:{parentId:J.string().optional().describe("node id of the parent feature (preferred)"),parentTitle:J.string().optional().describe("fuzzy title of the parent feature; ignored if parentId is provided"),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG for a bug discovered during work \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the sub-task lands on; defaults to the parent's layer")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let Y=await i("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(Y)}]}}catch(Y){return _5(Y)}});var R9=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on (only when the repo has a frontend); omitting it on an update keeps the prior value"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found in this component's code \u2014 flagged on the node (by=agent); identical open flags are not duplicated")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");D.registerTool("beacon_describe_feature",{description:"Register shipped feature(s) at the end of the work: marks status=DONE, records the files touched (kept on the FEATURE for context), and replaces each node's description with your markdown. Subsumes touch_files + finish_feature. A feature's unfinished SUB-TASKS are completed along with it (cascade; reported as `subtasksCompleted`) \u2014 if a sub-task is genuinely NOT done, set it BLOCKED or CANCELLED via the nodes API/board FIRST, those are left alone (`subtasksBlocked` lists what stayed). REGISTER ALL FEATURES A PLAN CREATED IN ONE CALL via the `features` array (one entry per feature) \u2014 do NOT call this once per feature. Pass each feature's `id` (returned to you at plan approval) so no title-matching is needed. For a single feature you may pass the top-level fields instead. Pass `architecture` only when a feature added/changed a REAL subsystem (never a file).",inputSchema:{features:J.array(J.object({id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),architecture:R9})).optional().describe("Register many features at once \u2014 one entry per feature, each id-keyed. Use this instead of N separate calls."),description:J.string().optional().describe("Single-feature markdown (omit when using `features`): ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches (single form)"),id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),architecture:R9}},async({features:$,description:Q,files:Z,id:Y,title:X,architecture:H})=>{let j=$?.length?{features:$}:{description:Q,files:Z,id:Y,title:X,architecture:H},G=await i("/api/map/describe",j);return{content:[{type:"text",text:JSON.stringify(G)}]}});D.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),hasFrontend:J.boolean().optional().describe("Whether this repo has a frontend surface (UI code) \u2014 you just read the repo, so you know. Gates the per-item `layer` requirement + the layer UI on the boards. Set it explicitly (true or false); omitting leaves Beacon to detect it from the code graph."),classificationRoots:J.array(J.string()).optional().describe("Top-level dirs whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. ['frontend','backend/app']. The canvas groups files ONE level below each (so 'frontend' \u2192 'frontend/components', 'frontend/app', \u2026). Pick the dir sitting directly ABOVE the real package dirs (use 'frontend/src' if there's a src/ wrapper). Not every dir \u2014 just where grouping should start. Omit for a simple single-root repo (the canvas auto-groups)."),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on \u2014 set it when hasFrontend is true"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found while examining this component \u2014 flagged on the node (by=agent)")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when the survey found a concrete bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the item lands on \u2014 set it when hasFrontend is true")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await i("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});D.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let Y=new URLSearchParams;if($)Y.set("id",$);if(Q)Y.set("title",Q);if(Z)Y.set("query",Z);let X=await E(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});D.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let Y=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});D.registerTool("beacon_entities",{description:"Read planning data. `features` = roadmap, `architecture` = components, `tables`/`endpoints` = DB map.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"])}},async({kind:$})=>{let Q=await E(`/api/entities?kind=${$}`);return{content:[{type:"text",text:JSON.stringify(Q)}]}});D.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 and, when the workspace has a frontend, `layer` (frontend | backend | fullstack). The tool REJECTS a plan whose features omit any required field, so set them on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when this roadmap item is a bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack the work lands on. REQUIRED on every feature when the workspace has a frontend (the tool rejects the plan otherwise); omit in pure-backend repos.")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional(),contract:J.array(J.string()).optional().describe("Repo-relative files THIS plan will touch \u2014 the scope contract. When the user has the plan scope-guard enabled, these are frozen at approval and you are held to them while implementing: editing an undeclared file pauses for the user's authorization (which adds it to the contract). Safe to always include; ignored when the guard is off.")}},async({description:$,features:Q,tables:Z,relations:Y,endpoints:X,contract:H})=>{let j=(q)=>new Promise((B0)=>setTimeout(B0,q)),G=(q)=>({content:[{type:"text",text:q}]}),W=(Z?.length??0)>0,w=(Q??[]).map((q)=>`${q.title} ${q.role??""} ${q.plain??""}`).join(`
264
+ `),r=(X?.length??0)>0||q9(`${$}
265
+ ${w}`);if(!W&&r)return G("\u26D4 This plan touches the database \u2014 it declares endpoints and/or its text describes "+"models/tables/migrations \u2014 but you passed NO `tables`. Beacon's schema board renders "+"ONLY from structured `tables`; prose is never parsed, so the /db tab would be empty and nothing would persist on approve.\n\nRe-call `beacon_propose_plan` with every table in `tables` (each with its `columns`), the `relations` (FKs), and keep the `endpoints` (each with `uses:[{table,access}]`). Mirror EVERY database entity your plan mentions into the structured fields.");if(Q?.length){let q=await E("/api/project-meta").then((k9)=>!!k9?.hasFrontend).catch(()=>!1),B0=w9(Q,{requireLayer:q});if(B0)return G(B0)}let T9=(Z?.length??0)+(X?.length??0)>0;try{await i("/api/plan",{description:$,draft:T9?{tables:Z??[],relations:Y??[],endpoints:X??[]}:void 0,features:Q?.length?Q:void 0,contract:H?.length?H:void 0})}catch(q){return _5(q)}await fetch(`${a()}/api/workspace/activate?id=${p}`).catch(()=>{}),await L5(a(),p);let _9=Date.now()+o0;while(Date.now()<_9){await j(s0);let q=await E("/api/plan/verdict").catch(()=>null);if(!q)continue;if(q.kind==="feedback")return G("\uD83D\uDCAC The user left feedback on the plan in Beacon \u2014 text comments and/or edits they "+"made directly on the /map and /db boards. Read everything below, revise the plan accordingly (matching the board changes verbatim), and call `beacon_propose_plan` "+`again with the revised version \u2014 DO NOT implement yet:
259
266
 
260
- `+N.feedback);if(N.kind==="approved")return j(`\u2705 Plan approved by the user. ${N.summary}`+(N.detail?`
267
+ `+q.feedback);if(q.kind==="approved")return G(`\u2705 Plan approved by the user. ${q.summary}`+(q.detail?`
261
268
 
262
269
  Implement EXACTLY the schema below (migrations + code) \u2014 the user may have `+`edited columns on the canvas:
263
270
 
264
- `+N.detail:"")+O5(N.features));if(N.kind==="discarded")return j(`\u274C The user discarded the plan in Beacon. ${N.summary} Ask what they want to adjust before proposing again.`)}return j("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_propose_plan` again with the SAME plan to resume (the verdict is picked up immediately if they've since decided), or ask whether they've reviewed it.")});O.registerTool("beacon_present_plan",{description:"BLOCKS until the user reviews. Pushes ANY plan (as markdown) to Beacon's /plan page so the user reviews it on the canvas instead of in the terminal \u2014 use this whenever you'd otherwise end a turn asking 'does this look right / should I proceed?'. Embed ONE fenced ```beacon block of JSON ({tables,relations,endpoints,features}) for any DB/roadmap entities so they render as an editable board. Returns the verdict (approved / discarded / feedback). Do NOT implement until it returns approval; on feedback, revise and call again. (For a pure schema+features plan, beacon_propose_plan is the structured alternative.)",inputSchema:{description:J.string().describe("One-line summary shown in the review header"),markdown:J.string().describe("The full plan as markdown. Embed a ```beacon block for tables/endpoints/features.")}},async({description:$,markdown:Q})=>{let Z=(H)=>new Promise((j)=>setTimeout(j,H)),Y=(H)=>({content:[{type:"text",text:H}]});await a("/api/plan",{description:$,markdown:Q}),await fetch(`${o()}/api/workspace/activate?id=${m}`).catch(()=>{}),await D5(o(),m);let V=Date.now()+A5;while(Date.now()<V){await Z(R5);let H=await E("/api/plan/verdict").catch(()=>null);if(!H)continue;if(H.kind==="feedback")return Y("\uD83D\uDCAC The user left feedback on the plan in Beacon (inline comments and/or edits on the "+"/map and /db boards). Revise the plan accordingly and call `beacon_present_plan` "+`again \u2014 do NOT implement yet:
271
+ `+q.detail:"")+I5(q.features));if(q.kind==="discarded")return G(`\u274C The user discarded the plan in Beacon. ${q.summary} Ask what they want to adjust before proposing again.`)}return G("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_propose_plan` again with the SAME plan to resume (the verdict is picked up immediately if they've since decided), or ask whether they've reviewed it.")});D.registerTool("beacon_present_plan",{description:"BLOCKS until the user reviews. Pushes ANY plan (as markdown) to Beacon's /plan page so the user reviews it on the canvas instead of in the terminal \u2014 use this whenever you'd otherwise end a turn asking 'does this look right / should I proceed?'. Embed ONE fenced ```beacon block of JSON ({tables,relations,endpoints,features}) for any DB/roadmap entities so they render as an editable board. Returns the verdict (approved / discarded / feedback). Do NOT implement until it returns approval; on feedback, revise and call again. (For a pure schema+features plan, beacon_propose_plan is the structured alternative.)",inputSchema:{description:J.string().describe("One-line summary shown in the review header"),markdown:J.string().describe("The full plan as markdown. Embed a ```beacon block for tables/endpoints/features.")}},async({description:$,markdown:Q})=>{let Z=(H)=>new Promise((j)=>setTimeout(j,H)),Y=(H)=>({content:[{type:"text",text:H}]});await i("/api/plan",{description:$,markdown:Q}),await fetch(`${a()}/api/workspace/activate?id=${p}`).catch(()=>{}),await L5(a(),p);let X=Date.now()+o0;while(Date.now()<X){await Z(s0);let H=await E("/api/plan/verdict").catch(()=>null);if(!H)continue;if(H.kind==="feedback")return Y("\uD83D\uDCAC The user left feedback on the plan in Beacon (inline comments and/or edits on the "+"/map and /db boards). Revise the plan accordingly and call `beacon_present_plan` "+`again \u2014 do NOT implement yet:
265
272
 
266
273
  `+H.feedback);if(H.kind==="approved")return Y(`\u2705 Plan approved by the user. ${H.summary??""}`.trim()+(H.detail?`
267
274
 
268
275
  Implement exactly what's on the board:
269
276
 
270
- ${H.detail}`:"")+O5(H.features));if(H.kind==="discarded")return Y(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return Y("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_present_plan` again with the SAME plan to resume, or ask whether they've reviewed it.")});var D9=($)=>Array.isArray($)?$[0]:$;async function c0($){return(await E(`/api/entities?kind=${$}`)).items}function R9($,Q){return{resources:$.map((Z)=>({uri:`${Q}${U0(Z.title)}`,name:Z.title,description:`${Z.title}${Z.cluster?` \xB7 ${Z.cluster}`:""} \xB7 ${Z.status}`,mimeType:"text/markdown"}))}}async function A9($,Q,Z){let Y=(await c0(Z)).find((G)=>U0(G.title)===D9(Q));if(!Y)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await E("/api/entities?kind=tables")).items??[]).map((G)=>G.name),j=[`# ${Y.title}`];if(Y.cluster)j.push(`*Domain:* \`${Y.cluster}\``);if(Y.status)j.push(`*Status:* \`${Y.status}\``);if(j.push(""),j.push(Y.plain?.trim()||"(this node has no description yet \u2014 add one on Beacon's /map page)"),j.push("","## Existing DB tables in this project"),j.push(H.length?H.join(", "):"(none yet)"),Z==="features"){let G=await c0("features"),W=[...new Set(G.map((w)=>w.cluster?.trim()).filter((w)=>!!w))].sort();j.push("","## Existing feature categories \u2014 reuse one before inventing a new one"),j.push(W.length?W.join(", "):"(none yet)"),j.push("","## Beacon feature loop \u2014 follow IN ORDER (do not jump to Glob/Grep/Read)","1. **Load context FIRST.** Call `beacon_context_for_feature({ title })` for this feature BEFORE any Glob/Grep/Read. It returns the attached files, 1-hop import blast radius, the domain's endpoints + tables + FK relations, sibling components, and the project conventions \u2014 and marks this feature active so your edits attach to it. That bundle replaces the discovery phase; Glob is a last resort.","2. **Design data before code.** Identify the tables this feature needs. If ANY are missing from the list above, design the schema and call `beacon_propose_plan` (tables + relations + endpoints, each endpoint with `uses:[{table,access}]`). It BLOCKS until the user approves on /plan \u2014 do NOT write migrations or code until it returns approval.","3. **Register at the end \u2014 in ONE call.** When the work is done, call `beacon_describe_feature` ONCE with a `features` array (one entry per feature the plan created, each keyed by the `id` you got back at approval, with the files you touched + a short markdown summary). Don't make one call per feature, and don't register only the umbrella \u2014 that leaves the rest Pending.")}return{contents:[{uri:$.href,mimeType:"text/markdown",text:j.join(`
271
- `)}]}}O.registerResource("beacon-feature",new E5("feature://{slug}",{list:async()=>R9(await c0("features"),"feature://")}),{title:"Beacon: features",description:"Roadmap features \u2014 picking one imports the node's description plus existing-DB context.",mimeType:"text/markdown"},($,{slug:Q})=>A9($,Q,"features"));O.registerResource("beacon-component",new E5("component://{slug}",{list:async()=>R9(await c0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>A9($,Q,"architecture"));async function O9(){return await E("/api/notes")}O.registerResource("beacon-note",new E5("note://{slug}",{list:async()=>w9(await O9())}),{title:"Beacon: notes",description:"Your Beacon notes \u2014 picking one imports its markdown verbatim so you can turn it into features.",mimeType:"text/markdown"},async($,{slug:Q})=>{let Z=C9(await O9(),D9(Q)),Y=Z?v9(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:Y}]}});await O.connect(new DQ);var p0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(p0===-1)p0=$;else if($!==p0)p0=$,O.sendResourceListChanged()}catch{}},P9);
277
+ ${H.detail}`:"")+I5(H.features));if(H.kind==="discarded")return Y(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return Y("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_present_plan` again with the SAME plan to resume, or ask whether they've reviewed it.")});var E9=($)=>Array.isArray($)?$[0]:$;async function d0($){return(await E(`/api/entities?kind=${$}`)).items}function I9($,Q){return{resources:$.map((Z)=>({uri:`${Q}${U0(Z.title)}`,name:Z.title,description:`${Z.title}${Z.cluster?` \xB7 ${Z.cluster}`:""} \xB7 ${Z.status}`,mimeType:"text/markdown"}))}}async function L9($,Q,Z){let Y=(await d0(Z)).find((G)=>U0(G.title)===E9(Q));if(!Y)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await E("/api/entities?kind=tables")).items??[]).map((G)=>G.name),j=[`# ${Y.title}`];if(Y.cluster)j.push(`*Domain:* \`${Y.cluster}\``);if(Y.status)j.push(`*Status:* \`${Y.status}\``);if(j.push(""),j.push(Y.plain?.trim()||"(this node has no description yet \u2014 add one on Beacon's /map page)"),j.push("","## Existing DB tables in this project"),j.push(H.length?H.join(", "):"(none yet)"),Z==="features"){let G=await d0("features"),W=[...new Set(G.map((w)=>w.cluster?.trim()).filter((w)=>!!w))].sort();j.push("","## Existing feature categories \u2014 reuse one before inventing a new one"),j.push(W.length?W.join(", "):"(none yet)"),j.push("","## Beacon feature loop \u2014 follow IN ORDER (do not jump to Glob/Grep/Read)","1. **Load context FIRST.** Call `beacon_context_for_feature({ title })` for this feature BEFORE any Glob/Grep/Read. It returns the attached files, 1-hop import blast radius, the domain's endpoints + tables + FK relations, sibling components, and the project conventions \u2014 and marks this feature active so your edits attach to it. That bundle replaces the discovery phase; Glob is a last resort.","2. **Design data before code.** Identify the tables this feature needs. If ANY are missing from the list above, design the schema and call `beacon_propose_plan` (tables + relations + endpoints, each endpoint with `uses:[{table,access}]`). It BLOCKS until the user approves on /plan \u2014 do NOT write migrations or code until it returns approval.","3. **Register at the end \u2014 in ONE call.** When the work is done, call `beacon_describe_feature` ONCE with a `features` array (one entry per feature the plan created, each keyed by the `id` you got back at approval, with the files you touched + a short markdown summary). Don't make one call per feature, and don't register only the umbrella \u2014 that leaves the rest Pending.")}return{contents:[{uri:$.href,mimeType:"text/markdown",text:j.join(`
278
+ `)}]}}D.registerResource("beacon-feature",new T5("feature://{slug}",{list:async()=>I9(await d0("features"),"feature://")}),{title:"Beacon: features",description:"Roadmap features \u2014 picking one imports the node's description plus existing-DB context.",mimeType:"text/markdown"},($,{slug:Q})=>L9($,Q,"features"));D.registerResource("beacon-component",new T5("component://{slug}",{list:async()=>I9(await d0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>L9($,Q,"architecture"));async function A9(){return await E("/api/notes")}D.registerResource("beacon-note",new T5("note://{slug}",{list:async()=>F9(await A9())}),{title:"Beacon: notes",description:"Your Beacon notes \u2014 picking one imports its markdown verbatim so you can turn it into features.",mimeType:"text/markdown"},async($,{slug:Q})=>{let Z=D9(await A9(),E9(Q)),Y=Z?O9(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:Y}]}});await D.connect(new TQ);var l0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(l0===-1)l0=$;else if($!==l0)l0=$,D.sendResourceListChanged()}catch{}},k5);