trybeacon 0.1.90 → 0.1.92

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 (154) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.next/BUILD_ID +1 -1
  3. package/.next/app-path-routes-manifest.json +19 -19
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +3 -3
  6. package/.next/server/app/@modal/(.)settings/page.js +1 -1
  7. package/.next/server/app/@modal/(.)settings/page.js.nft.json +1 -1
  8. package/.next/server/app/@modal/(.)settings/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/_global-error.html +1 -1
  11. package/.next/server/app/_global-error.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  17. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/.next/server/app/_not-found/page.js +1 -1
  19. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  20. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/.next/server/app/_not-found.html +1 -1
  22. package/.next/server/app/_not-found.rsc +3 -3
  23. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  24. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  26. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  27. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  28. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  29. package/.next/server/app/api/context/route.js +1 -1
  30. package/.next/server/app/api/ingest/route.js +1 -1
  31. package/.next/server/app/api/linear/route.js +1 -17
  32. package/.next/server/app/api/linear/route.js.nft.json +1 -1
  33. package/.next/server/app/api/linear/scopes/route.js +1 -17
  34. package/.next/server/app/api/linear/scopes/route.js.nft.json +1 -1
  35. package/.next/server/app/api/linear/sync/route.js +1 -17
  36. package/.next/server/app/api/linear/sync/route.js.nft.json +1 -1
  37. package/.next/server/app/api/plan/approve/route.js +1 -1
  38. package/.next/server/app/api/share/create/route.js +1 -1
  39. package/.next/server/app/docs/page.js +1 -1
  40. package/.next/server/app/docs/page.js.nft.json +1 -1
  41. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  42. package/.next/server/app/docs.html +1 -1
  43. package/.next/server/app/docs.rsc +4 -4
  44. package/.next/server/app/docs.segments/@modal/__DEFAULT__.segment.rsc +1 -1
  45. package/.next/server/app/docs.segments/_full.segment.rsc +4 -4
  46. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  47. package/.next/server/app/docs.segments/_index.segment.rsc +3 -3
  48. package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  49. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +2 -2
  50. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  51. package/.next/server/app/help/page.js +2 -2
  52. package/.next/server/app/help/page.js.nft.json +1 -1
  53. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/help.html +1 -1
  55. package/.next/server/app/help.rsc +4 -4
  56. package/.next/server/app/help.segments/@modal/__DEFAULT__.segment.rsc +1 -1
  57. package/.next/server/app/help.segments/_full.segment.rsc +4 -4
  58. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  59. package/.next/server/app/help.segments/_index.segment.rsc +3 -3
  60. package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
  61. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +2 -2
  62. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  63. package/.next/server/app/index.html +1 -1
  64. package/.next/server/app/index.rsc +3 -3
  65. package/.next/server/app/index.segments/@modal/__DEFAULT__.segment.rsc +1 -1
  66. package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  67. package/.next/server/app/index.segments/_full.segment.rsc +3 -3
  68. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  69. package/.next/server/app/index.segments/_index.segment.rsc +3 -3
  70. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  71. package/.next/server/app/learn/page.js +3 -3
  72. package/.next/server/app/learn/page.js.nft.json +1 -1
  73. package/.next/server/app/learn/page_client-reference-manifest.js +1 -1
  74. package/.next/server/app/map/page.js +2 -2
  75. package/.next/server/app/map/page.js.nft.json +1 -1
  76. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  77. package/.next/server/app/page.js +1 -1
  78. package/.next/server/app/page.js.nft.json +1 -1
  79. package/.next/server/app/page_client-reference-manifest.js +1 -1
  80. package/.next/server/app/parked/page.js +1 -1
  81. package/.next/server/app/parked/page.js.nft.json +1 -1
  82. package/.next/server/app/parked/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/plan/page.js +3 -3
  84. package/.next/server/app/plan/page.js.nft.json +1 -1
  85. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  86. package/.next/server/app/s/[token]/page.js +2 -2
  87. package/.next/server/app/s/[token]/page.js.nft.json +1 -1
  88. package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
  89. package/.next/server/app/settings/page.js +1 -1
  90. package/.next/server/app/settings/page.js.nft.json +1 -1
  91. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  92. package/.next/server/app-paths-manifest.json +19 -19
  93. package/.next/server/chunks/1130.js +1 -1
  94. package/.next/server/chunks/1495.js +18 -0
  95. package/.next/server/chunks/{7436.js → 1898.js} +3 -3
  96. package/.next/server/chunks/2031.js +1 -1
  97. package/.next/server/chunks/2644.js +1 -0
  98. package/.next/server/chunks/3825.js +1 -1
  99. package/.next/server/chunks/4378.js +1 -1
  100. package/.next/server/chunks/{5332.js → 473.js} +3 -3
  101. package/.next/server/chunks/5623.js +1 -1
  102. package/.next/server/chunks/8227.js +1 -1
  103. package/.next/server/chunks/8709.js +8 -7
  104. package/.next/server/chunks/9683.js +1 -1
  105. package/.next/server/middleware-build-manifest.js +1 -1
  106. package/.next/server/pages/404.html +1 -1
  107. package/.next/server/pages/500.html +1 -1
  108. package/.next/server/server-reference-manifest.js +1 -1
  109. package/.next/server/server-reference-manifest.json +1 -1
  110. package/.next/static/chunks/2149-6eac4575d8a8281c.js +1 -0
  111. package/.next/static/chunks/{6283-20a6abe3453496ae.js → 3729-99f9edd66d1473ac.js} +3 -3
  112. package/.next/static/chunks/569-c70eb3d6c88282dc.js +1 -0
  113. package/.next/static/chunks/6818-051146427620d0f9.js +1 -0
  114. package/.next/static/chunks/8653-27d42df759159788.js +1 -0
  115. package/.next/static/chunks/app/@modal/(.)settings/page-77639f97e58859de.js +1 -0
  116. package/.next/static/chunks/app/docs/page-574e48b1b9519c80.js +1 -0
  117. package/.next/static/chunks/app/layout-6f04d1687adcd16e.js +1 -0
  118. package/.next/static/chunks/app/learn/{page-49bdcae5bf2a7a49.js → page-53c201dbfd759610.js} +1 -1
  119. package/.next/static/chunks/app/map/{page-6e32f55c7b69bfa0.js → page-147befd24a412e04.js} +1 -1
  120. package/.next/static/chunks/app/plan/{page-b8b89d7171a582ce.js → page-a35f98b97c750679.js} +2 -2
  121. package/.next/static/chunks/app/s/[token]/{page-7ebe66049fae02ce.js → page-db7be755d871820e.js} +1 -1
  122. package/.next/static/chunks/app/settings/page-c15764e1c2f54c5a.js +1 -0
  123. package/.next/static/css/b6c71ada5fa39830.css +1 -0
  124. package/.next/trace +47 -47
  125. package/.next/trace-build +1 -1
  126. package/dist/bin/ask.js +2 -2
  127. package/dist/bin/doctor.js +32 -30
  128. package/dist/bin/hook.js +31 -29
  129. package/dist/bin/mcp.js +41 -39
  130. package/dist/bin/plan.js +32 -30
  131. package/dist/bin/prompt.js +2 -2
  132. package/dist/bin/remove.js +3 -3
  133. package/dist/bin/stop-hook.js +4 -4
  134. package/dist/bin/uninstall.js +31 -29
  135. package/dist/lib/assets.js +20 -20
  136. package/dist/lib/codex-install.js +30 -28
  137. package/dist/lib/daemon-boot.js +11 -11
  138. package/dist/lib/global-install.js +31 -29
  139. package/drizzle/0013_quick_brother_voodoo.sql +1 -0
  140. package/drizzle/meta/0013_snapshot.json +1953 -0
  141. package/drizzle/meta/_journal.json +7 -0
  142. package/package.json +1 -1
  143. package/.next/server/chunks/2806.js +0 -1
  144. package/.next/static/chunks/2114-74736df56930b46c.js +0 -1
  145. package/.next/static/chunks/569-bfdcec83011428d3.js +0 -1
  146. package/.next/static/chunks/6818-85b9a09bb74062ef.js +0 -1
  147. package/.next/static/chunks/6930-1231a4681af2ad3f.js +0 -1
  148. package/.next/static/chunks/app/@modal/(.)settings/page-58f068e66bf2fdf6.js +0 -1
  149. package/.next/static/chunks/app/docs/page-126c0e42c71731b2.js +0 -1
  150. package/.next/static/chunks/app/layout-a8bb07fb86893add.js +0 -1
  151. package/.next/static/chunks/app/settings/page-435bfb2ac6f01744.js +0 -1
  152. package/.next/static/css/56890131dbc6daff.css +0 -1
  153. /package/.next/static/{l2BAGl1tReuc34hH3NvPZ → Ced4ZzirE-x-xhZEP02do}/_buildManifest.js +0 -0
  154. /package/.next/static/{l2BAGl1tReuc34hH3NvPZ → Ced4ZzirE-x-xhZEP02do}/_ssgManifest.js +0 -0
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var pZ=Object.defineProperty;var mZ=(Q)=>Q;function cZ(Q,Z){this[Q]=mZ.bind(null,Z)}var xQ=(Q,Z)=>{for(var $ in Z)pZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:cZ.bind(Z,$)})};var C=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);import{existsSync as E,mkdirSync as MQ,readdirSync as lZ,readFileSync as g,rmSync as tZ,writeFileSync as l}from"fs";import{basename as sZ,dirname as nQ,join as K}from"path";function aQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function oQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=K(Q,".claude","plugins");if(!E(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let z=K(V,".claude-plugin","plugin.json");try{if(E(z)&&JSON.parse(g(z,"utf8")).name==="beacon")return V}catch{}try{for(let W of lZ(V,{withFileTypes:!0}))if(W.isDirectory())Y.push(K(V,W.name))}catch{}}$=Y}return null}function iQ(Q){return oQ(Q)!==null}function dZ(Q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(Q)}function R(){let Q=process.env.BEACON_CLI_PATH;if(Q)return Q;if(E(rQ))return rQ;return"beacon"}function uQ(Q){let Z=Q.indexOf(" ");return Z===-1?Q:Q.slice(0,Z)}function t(Q){let Z=R();if(Z==="beacon")return Q;return Q.replace(/^beacon(\s|$)/,`${Z}$1`)}function x(Q){let Z=uQ(Q);return sZ(Z)+Q.slice(Z.length)}function rZ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;try{let Z=JSON.parse(g(K(Q,".claude","plugins","installed_plugins.json"),"utf8"));for(let $ of Object.keys(Z.plugins??{}))if(/^beacon@/.test($))return{key:$,marketplace:$.split("@")[1]??""}}catch{}return null}function d(Q){try{return JSON.parse(g(Q,"utf8"))}catch{return{}}}function eQ(Q,Z){MQ(nQ(Q),{recursive:!0}),l(Q,JSON.stringify(Z,null,2)+`
4
- `)}function r(Q,Z){let $=d(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let J=$.hooks[Z.event];if(J.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((z)=>x(z.command)===x(Z.command))))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),eQ(Q,$),!0}function n(Q,Z){return(d(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>x(V.command)===x(Z.command)))}function QZ(Q,Z){let J=d(Q).hooks?.[Z.event]??[];for(let Y of J)for(let V of Y.hooks??[])if(x(V.command)===x(Z.command))return V.command;return null}function a(Q,Z){let $=d(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((z)=>{let W=z.hooks?.length??0,q=(z.hooks??[]).filter((U)=>x(U.command)!==x(Z.command));if(q.length!==W)Y=!0;return{...z,hooks:q}}).filter((z)=>(z.hooks??[]).length>0);if(!Y)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return eQ(Q,$),!0}function o(Q,Z,$,J){let Y=`${Z}
3
+ var mZ=Object.defineProperty;var lZ=(Q)=>Q;function cZ(Q,Z){this[Q]=lZ.bind(null,Z)}var wQ=(Q,Z)=>{for(var $ in Z)mZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:cZ.bind(Z,$)})};var g=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);import{existsSync as b,mkdirSync as fQ,readdirSync as sZ,readFileSync as O,rmSync as tZ,writeFileSync as d}from"fs";import{basename as rZ,dirname as iQ,join as M}from"path";function eQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function QZ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=M(Q,".claude","plugins");if(!b(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let z=M(V,".claude-plugin","plugin.json");try{if(b(z)&&JSON.parse(O(z,"utf8")).name==="beacon")return V}catch{}try{for(let U of sZ(V,{withFileTypes:!0}))if(U.isDirectory())Y.push(M(V,U.name))}catch{}}$=Y}return null}function ZZ(Q){return QZ(Q)!==null}function dZ(Q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(Q)}function R(){let Q=process.env.BEACON_CLI_PATH;if(Q)return Q;if(b(oQ))return oQ;return"beacon"}function FQ(Q){let Z=Q.indexOf(" ");return Z===-1?Q:Q.slice(0,Z)}function I(Q){let Z=R();if(Z==="beacon")return Q;return Q.replace(/^beacon(\s|$)/,`${Z}$1`)}function G(Q){let Z=FQ(Q);return rZ(Z)+Q.slice(Z.length)}function aZ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;try{let Z=JSON.parse(O(M(Q,".claude","plugins","installed_plugins.json"),"utf8"));for(let $ of Object.keys(Z.plugins??{}))if(/^beacon@/.test($))return{key:$,marketplace:$.split("@")[1]??""}}catch{}return null}function L(Q){try{return JSON.parse(O(Q,"utf8"))}catch{return{}}}function xQ(Q,Z){fQ(iQ(Q),{recursive:!0}),d(Q,JSON.stringify(Z,null,2)+`
4
+ `)}function n(Q,Z,$={}){let J=L(Q);J.hooks=J.hooks??{},J.hooks[Z.event]=J.hooks[Z.event]??[];let Y=J.hooks[Z.event];if(Y.some((z)=>z.hooks?.some((U)=>G(U.command)===G(Z.command)&&($.matchAnyMatcher||z.matcher===Z.matcher))))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),xQ(Q,J),!0}function $Z(Q,Z){let $=L(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=J.flatMap((U,q)=>(U.hooks??[]).flatMap((X,v)=>G(X.command)===G(Z.command)?[{matcherIndex:q,hookIndex:v,preferred:U.matcher===Z.matcher}]:[]));if(Y.length<2)return!1;let V=Y.find((U)=>U.preferred)??Y[0],z=new Set(Y.filter((U)=>U!==V).map((U)=>`${U.matcherIndex}:${U.hookIndex}`));return $.hooks[Z.event]=J.map((U,q)=>({...U,hooks:(U.hooks??[]).filter((X,v)=>!z.has(`${q}:${v}`))})).filter((U)=>(U.hooks??[]).length>0),xQ(Q,$),!0}function o(Q,Z){return(L(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>G(V.command)===G(Z.command)))}function JZ(Q,Z){let J=L(Q).hooks?.[Z.event]??[];for(let Y of J)for(let V of Y.hooks??[])if(G(V.command)===G(Z.command))return V.command;return null}function i(Q,Z){let $=L(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((z)=>{let U=z.hooks?.length??0,q=(z.hooks??[]).filter((X)=>G(X.command)!==G(Z.command));if(q.length!==U)Y=!0;return{...z,hooks:q}}).filter((z)=>(z.hooks??[]).length>0);if(!Y)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return xQ(Q,$),!0}function e(Q,Z,$,J){let Y=`${Z}
5
5
  ${J.trim()}
6
- ${$}`,V="";try{V=g(Q,"utf8")}catch{}let z=new RegExp(`${Z}[\\s\\S]*?${$}`);V=z.test(V)?V.replace(z,Y):V.trim()?`${V.trim()}
6
+ ${$}`,V="";try{V=O(Q,"utf8")}catch{}let z=new RegExp(`${Z}[\\s\\S]*?${$}`);V=z.test(V)?V.replace(z,Y):V.trim()?`${V.trim()}
7
7
 
8
8
  ${Y}
9
9
  `:`${Y}
10
- `,MQ(nQ(Q),{recursive:!0}),l(Q,V.endsWith(`
10
+ `,fQ(iQ(Q),{recursive:!0}),d(Q,V.endsWith(`
11
11
  `)?V:`${V}
12
- `)}function b(Q,Z){try{return g(Q,"utf8").includes(Z)}catch{return!1}}function i(Q,Z,$){let J="";try{J=g(Q,"utf8")}catch{return!1}let Y=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!Y.test(J))return!1;let V=J.replace(Y,"").replace(/\n{3,}/g,`
12
+ `)}function k(Q,Z){try{return O(Q,"utf8").includes(Z)}catch{return!1}}function QQ(Q,Z,$){let J="";try{J=O(Q,"utf8")}catch{return!1}let Y=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!Y.test(J))return!1;let V=J.replace(Y,"").replace(/\n{3,}/g,`
13
13
 
14
- `).trimStart();return l(Q,V),!0}function e(Q,Z,$){let J=K(Q,Z);MQ(J,{recursive:!0});let Y=K(J,"SKILL.md");return l(Y,$),Y}function y(Q,Z){return E(K(Q,Z,"SKILL.md"))}function QQ(Q,Z){let $=K(Q,Z);if(!E($))return!1;return tZ($,{recursive:!0,force:!0}),!0}var j,rQ="/Applications/Beacon.app/Contents/Resources/bin/beacon",s=`## Beacon (visual planning panel)
14
+ `).trimStart();return d(Q,V),!0}function ZQ(Q,Z,$){let J=M(Q,Z);fQ(J,{recursive:!0});let Y=M(J,"SKILL.md");return d(Y,$),Y}function _(Q,Z){return b(M(Q,Z,"SKILL.md"))}function $Q(Q,Z){let $=M(Q,Z);if(!b($))return!1;return tZ($,{recursive:!0,force:!0}),!0}var j,oQ="/Applications/Beacon.app/Contents/Resources/bin/beacon",a=`## Beacon (visual planning panel)
15
15
 
16
16
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
17
17
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -35,23 +35,23 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
35
35
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
36
36
  on the /map and /db boards (added features, attached subtasks, edited columns, new
37
37
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
38
- verbatim. Do NOT implement until the tool returns approval.`;var ZQ=C(()=>{j=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var U1=1500,W1=480000,H1=1800000,$Q=3600000,j1=3000;var ZZ=()=>{};var CQ={};xQ(CQ,{stripAgentsPointer:()=>VZ,repoMcpCliTarget:()=>J0,removeRepoAssets:()=>FQ,installRefreshSkill:()=>aZ,installPlanSkill:()=>oZ,installInitSkill:()=>nZ,installExplainSkill:()=>iZ,installCodexRepoSkills:()=>Q0,ensureWorkflowDoc:()=>Z0,ensureMcp:()=>$0,contextDocTargets:()=>TQ,auditRepo:()=>Y0,REFRESH_SKILL:()=>wQ,PLAN_SKILL:()=>JZ,INIT_SKILL:()=>RQ,EXPLAIN_SKILL:()=>YZ});import{existsSync as N,mkdirSync as L,readFileSync as P,rmSync as JQ,writeFileSync as H}from"fs";import{join as X}from"path";function nZ(Q){let Z=X(Q,".claude","skills","beacon-init");L(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,RQ),$}function aZ(Q){let Z=X(Q,".claude","skills","beacon-refresh");L(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,wQ),$}function oZ(Q){let Z=X(Q,".claude","skills","beacon-plan");L(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,JZ),$}function iZ(Q){let Z=X(Q,".claude","skills","beacon-explain");L(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,YZ),$}function Q0(Q){let Z=[];for(let $ of eZ){let J=X(Q,".agents","skills",$.name);L(J,{recursive:!0});let Y=X(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function TQ(Q){let Z=X(Q,"AGENTS.md"),$=X(Q,"CLAUDE.md"),J=N(Z),Y=N($);if(!J&&!Y)return[Z,$];let V=[];if(J)V.push(Z);if(Y)V.push($);return V}function VZ(Q){let Z=X(Q,"CLAUDE.md");if(!N(Z))return;let $=P(Z,"utf8"),J=$.split(`
38
+ verbatim. Do NOT implement until the tool returns approval.`;var JQ=g(()=>{j=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var H1=1500,j1=480000,v1=1800000,YQ=3600000,G1=3000;var YZ=()=>{};var DQ={};wQ(DQ,{stripAgentsPointer:()=>UZ,repoMcpCliTarget:()=>Y0,removeRepoAssets:()=>AQ,installRefreshSkill:()=>oZ,installPlanSkill:()=>iZ,installInitSkill:()=>nZ,installExplainSkill:()=>eZ,installCodexRepoSkills:()=>Z0,ensureWorkflowDoc:()=>$0,ensureMcp:()=>J0,contextDocTargets:()=>OQ,auditRepo:()=>V0,REFRESH_SKILL:()=>CQ,PLAN_SKILL:()=>qZ,INIT_SKILL:()=>TQ,EXPLAIN_SKILL:()=>zZ});import{existsSync as N,mkdirSync as S,readFileSync as K,rmSync as VQ,writeFileSync as H}from"fs";import{join as W}from"path";function nZ(Q){let Z=W(Q,".claude","skills","beacon-init");S(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,TQ),$}function oZ(Q){let Z=W(Q,".claude","skills","beacon-refresh");S(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,CQ),$}function iZ(Q){let Z=W(Q,".claude","skills","beacon-plan");S(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,qZ),$}function eZ(Q){let Z=W(Q,".claude","skills","beacon-explain");S(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,zZ),$}function Z0(Q){let Z=[];for(let $ of Q0){let J=W(Q,".agents","skills",$.name);S(J,{recursive:!0});let Y=W(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function OQ(Q){let Z=W(Q,"AGENTS.md"),$=W(Q,"CLAUDE.md"),J=N(Z),Y=N($);if(!J&&!Y)return[Z,$];let V=[];if(J)V.push(Z);if(Y)V.push($);return V}function UZ(Q){let Z=W(Q,"CLAUDE.md");if(!N(Z))return;let $=K(Z,"utf8"),J=$.split(`
39
39
  `).filter((Y)=>!/^\s*@\.?\/?AGENTS\.md\s*$/.test(Y)).join(`
40
40
  `).trim();if(J&&J!==$.trim())H(Z,`${J}
41
- `)}function Z0(Q){let Z=new RegExp(`${YQ}[\\s\\S]*?${fQ}`);for(let $ of TQ(Q)){let J="";try{J=P($,"utf8")}catch{}J=Z.test(J)?J.replace(Z,$Z):`${J.trim()}
41
+ `)}function $0(Q){let Z=new RegExp(`${qQ}[\\s\\S]*?${gQ}`);for(let $ of OQ(Q)){let J="";try{J=K($,"utf8")}catch{}J=Z.test(J)?J.replace(Z,VZ):`${J.trim()}
42
42
 
43
- ${$Z}
43
+ ${VZ}
44
44
  `.trimStart(),H($,J.endsWith(`
45
45
  `)?J:`${J}
46
- `)}VZ(Q)}function $0(Q){let Z=X(Q,".mcp.json"),$={};try{$=JSON.parse(P(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<$Q)return J.timeout=$Q,H(Z,JSON.stringify($,null,2)+`
47
- `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:R(),args:["mcp"],timeout:$Q},H(Z,JSON.stringify($,null,2)+`
48
- `),{path:Z,added:!0,updated:!1}}function J0(Q){try{return JSON.parse(P(X(Q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function Y0(Q){let Z=X(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(P(Z,"utf8")).mcpServers?.beacon}catch{}let J=TQ(Q).some((Y)=>{try{return P(Y,"utf8").includes(YQ)}catch{return!1}});return{repo:Q,mcpRegistered:$,workflowBlock:J,skills:{"beacon-init":N(X(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":N(X(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":N(X(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":N(X(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function FQ(Q){let Z=[];for(let q of["beacon-init","beacon-refresh","beacon-db-design"]){let U=X(Q,".claude","skills",q);if(N(U))JQ(U,{recursive:!0,force:!0}),Z.push(q)}for(let q of["beacon-init","beacon-refresh"]){let U=X(Q,".agents","skills",q);if(N(U))JQ(U,{recursive:!0,force:!0}),Z.push(`codex:${q}`)}let $=!1,J=X(Q,".mcp.json");try{let q=JSON.parse(P(J,"utf8"));if(q.mcpServers?.beacon){if(delete q.mcpServers.beacon,$=!0,q.mcpServers&&Object.keys(q.mcpServers).length===0)delete q.mcpServers;if(Object.keys(q).length===0)JQ(J,{force:!0});else H(J,JSON.stringify(q,null,2)+`
49
- `)}}catch{}let Y=!1,V=new RegExp(`\\n?${YQ}[\\s\\S]*?${fQ}\\n?`);for(let q of[X(Q,"AGENTS.md"),X(Q,"CLAUDE.md")])try{let U=P(q,"utf8");if(V.test(U)){let KQ=U.replace(V,`
46
+ `)}UZ(Q)}function J0(Q){let Z=W(Q,".mcp.json"),$={};try{$=JSON.parse(K(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<YQ)return J.timeout=YQ,H(Z,JSON.stringify($,null,2)+`
47
+ `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:R(),args:["mcp"],timeout:YQ},H(Z,JSON.stringify($,null,2)+`
48
+ `),{path:Z,added:!0,updated:!1}}function Y0(Q){try{return JSON.parse(K(W(Q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function V0(Q){let Z=W(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(K(Z,"utf8")).mcpServers?.beacon}catch{}let J=OQ(Q).some((Y)=>{try{return K(Y,"utf8").includes(qQ)}catch{return!1}});return{repo:Q,mcpRegistered:$,workflowBlock:J,skills:{"beacon-init":N(W(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":N(W(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":N(W(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":N(W(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function AQ(Q){let Z=[];for(let q of["beacon-init","beacon-refresh","beacon-db-design"]){let X=W(Q,".claude","skills",q);if(N(X))VQ(X,{recursive:!0,force:!0}),Z.push(q)}for(let q of["beacon-init","beacon-refresh"]){let X=W(Q,".agents","skills",q);if(N(X))VQ(X,{recursive:!0,force:!0}),Z.push(`codex:${q}`)}let $=!1,J=W(Q,".mcp.json");try{let q=JSON.parse(K(J,"utf8"));if(q.mcpServers?.beacon){if(delete q.mcpServers.beacon,$=!0,q.mcpServers&&Object.keys(q.mcpServers).length===0)delete q.mcpServers;if(Object.keys(q).length===0)VQ(J,{force:!0});else H(J,JSON.stringify(q,null,2)+`
49
+ `)}}catch{}let Y=!1,V=new RegExp(`\\n?${qQ}[\\s\\S]*?${gQ}\\n?`);for(let q of[W(Q,"AGENTS.md"),W(Q,"CLAUDE.md")])try{let X=K(q,"utf8");if(V.test(X)){let v=X.replace(V,`
50
50
  `).replace(/\n{3,}/g,`
51
51
 
52
- `).trimStart();H(q,KQ.endsWith(`
53
- `)?KQ:`${KQ}
54
- `),Y=!0}}catch{}let z=!1,W=X(Q,"CLAUDE.md");try{let q=P(W,"utf8"),U=q.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(U!==q){if(!U.trim())JQ(W,{force:!0});else H(W,U);z=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:z}}var RQ=`---
52
+ `).trimStart();H(q,v.endsWith(`
53
+ `)?v:`${v}
54
+ `),Y=!0}}catch{}let z=!1,U=W(Q,"CLAUDE.md");try{let q=K(U,"utf8"),X=q.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(X!==q){if(!X.trim())VQ(U,{force:!0});else H(U,X);z=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:z}}var TQ=`---
55
55
  name: beacon-init
56
56
  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.
57
57
  ---
@@ -98,7 +98,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
98
98
  That one command wires the repo (writes \`.mcp.json\` + skills so your NEXT session gets the \`beacon_*\` tools natively, heals the global install), starts the Beacon daemon if it isn't running, registers + provisions this workspace, and POSTs your analysis to the same \`/api/init\` endpoint the MCP tool uses \u2014 so init completes in THIS session. Read the counts it prints and report them.
99
99
 
100
100
  After the tool (or \`beacon init-persist\`) returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
101
- `,wQ=`---
101
+ `,CQ=`---
102
102
  name: beacon-refresh
103
103
  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.
104
104
  ---
@@ -145,7 +145,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
145
145
  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.
146
146
 
147
147
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
148
- `,JZ=`---
148
+ `,qZ=`---
149
149
  name: beacon-plan
150
150
  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.
151
151
  ---
@@ -194,7 +194,7 @@ If it returns feedback, revise and call it again.
194
194
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
195
195
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
196
196
  run \`beacon\` in this repo once.
197
- `,YZ=`---
197
+ `,zZ=`---
198
198
  name: beacon-explain
199
199
  description: Teach the user part of THIS codebase as an interactive visual lesson on Beacon's /learn page \u2014 a concept map + plain-English narrative they can question \u2014 instead of a wall of text. Use when the user says "explain", "teach me", "walk me through", "how does X work", or "help me understand the Y category".
200
200
  ---
@@ -264,7 +264,7 @@ so the learner sees the table IN CONTEXT, wired to the code that uses it.
264
264
  Every answer must ADD understanding (rationale, trade-off) \u2014 never just restate the question. Expand
265
265
  the narrative or add nodes where it helps. Keep looping until the tool reports the user saved or closed
266
266
  the lesson.
267
- `,eZ,YQ="<!-- beacon:workflow:start -->",fQ="<!-- beacon:workflow:end -->",$Z;var VQ=C(()=>{ZQ();ZZ();eZ=[{name:"beacon-init",body:()=>RQ},{name:"beacon-refresh",body:()=>wQ}];$Z=`${YQ}
267
+ `,Q0,qQ="<!-- beacon:workflow:start -->",gQ="<!-- beacon:workflow:end -->",VZ;var zQ=g(()=>{JQ();YZ();Q0=[{name:"beacon-init",body:()=>TQ},{name:"beacon-refresh",body:()=>CQ}];VZ=`${qQ}
268
268
  ## Beacon \u2014 feature workflow
269
269
 
270
270
  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:
@@ -336,21 +336,23 @@ Register them all in that single batched call. If a plan added five features, th
336
336
  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.
337
337
 
338
338
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
339
- ${fQ}`});import{mkdirSync as V0,renameSync as q0,rmSync as z0,writeFileSync as X0}from"fs";import{dirname as U0}from"path";function qQ(Q,Z){V0(U0(Q),{recursive:!0});let $=`${Q}.tmp`;try{X0($,Z),q0($,Q)}catch(J){throw z0($,{force:!0}),J}}function M1(Q,Z,$=!1){qQ(Q,JSON.stringify(Z,null,$?2:void 0))}var qZ=()=>{};var BZ={};xQ(BZ,{setupCodexAssets:()=>K0,removeCodexMcp:()=>PZ,removeCodexArtifacts:()=>EQ,parseTomlBeacon:()=>vZ,nodeWhich:()=>UZ,hasCodexMcp:()=>DQ,ensureCodexMcp:()=>NZ,commandExists:()=>WZ,codexMcpProblem:()=>P0,codexMcpCliTarget:()=>B0,codexDetected:()=>HZ,auditCodex:()=>AQ,CODEX_HOOKS:()=>D});import{accessSync as W0,constants as H0,readFileSync as _}from"fs";import{homedir as j0}from"os";import{delimiter as G0,join as I}from"path";function zZ(){return process.env.HOME||process.env.USERPROFILE||j0()}function UZ(Q,Z=process.env.PATH||"",$=v0){if(!Q)return null;for(let J of Z.split(G0)){if(!J)continue;let Y=I(J,Q);if($(Y))return Y}return null}function v0(Q){try{return W0(Q,H0.X_OK),!0}catch{return!1}}function WZ(Q){if(typeof Bun<"u"&&typeof Bun.which==="function")return Bun.which(Q)!==null;return UZ(Q)!==null}function HZ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(gQ===void 0)gQ=WZ("codex");return gQ}function vZ(Q){let Z={},$=!1;for(let J of Q.split(`
340
- `)){let Y=J.trim();if(!Y||Y.startsWith("#"))continue;let V=/^\[([^\]]+)\]/.exec(Y);if(V){if($=V[1].trim()==="mcp_servers.beacon",$)Z.mcp_servers=Z.mcp_servers??{},Z.mcp_servers.beacon=Z.mcp_servers.beacon??{};continue}if($){let z=/^command\s*=\s*["']([^"']*)["']/.exec(Y);if(z)Z.mcp_servers.beacon.command=z[1]}}return Z}function O(Q){try{if(typeof Bun<"u"&&Bun.TOML?.parse)return Bun.TOML.parse(Q);return vZ(Q)}catch{return null}}function DQ(){try{return Boolean(O(_(w(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function P0(){let Q="";try{Q=_(w(),"utf8")}catch{return null}let Z=O(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${k}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${k}`;return null}function NZ(){let Q="",Z=!1;try{Q=_(w(),"utf8"),Z=!0}catch{}if(Z){let V=O(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${k}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${k}`}}let $=!Q?"":Q.endsWith(`
339
+ ${gQ}`});import{mkdirSync as q0,renameSync as z0,rmSync as U0,writeFileSync as X0}from"fs";import{dirname as W0}from"path";function h(Q,Z){q0(W0(Q),{recursive:!0});let $=`${Q}.tmp`;try{X0($,Z),z0($,Q)}catch(J){throw U0($,{force:!0}),J}}function w1(Q,Z,$=!1){h(Q,JSON.stringify(Z,null,$?2:void 0))}var XZ=()=>{};var KZ={};wQ(KZ,{setupCodexAssets:()=>M0,removeCodexMcp:()=>NZ,removeCodexArtifacts:()=>LQ,parseTomlBeacon:()=>PZ,nodeWhich:()=>jZ,hasCodexMcp:()=>bQ,ensureCodexMcp:()=>BZ,commandExists:()=>vZ,codexMcpProblem:()=>N0,codexMcpCliTarget:()=>u0,codexDetected:()=>GZ,auditCodex:()=>IQ,CODEX_HOOKS:()=>E});import{accessSync as H0,constants as j0,readFileSync as m}from"fs";import{homedir as v0}from"os";import{delimiter as G0,join as D}from"path";function WZ(){return process.env.HOME||process.env.USERPROFILE||v0()}function jZ(Q,Z=process.env.PATH||"",$=P0){if(!Q)return null;for(let J of Z.split(G0)){if(!J)continue;let Y=D(J,Q);if($(Y))return Y}return null}function P0(Q){try{return H0(Q,j0.X_OK),!0}catch{return!1}}function vZ(Q){if(typeof Bun<"u"&&typeof Bun.which==="function")return Bun.which(Q)!==null;return jZ(Q)!==null}function GZ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(EQ===void 0)EQ=vZ("codex");return EQ}function PZ(Q){let Z={},$=!1;for(let J of Q.split(`
340
+ `)){let Y=J.trim();if(!Y||Y.startsWith("#"))continue;let V=/^\[([^\]]+)\]/.exec(Y);if(V){if($=V[1].trim()==="mcp_servers.beacon",$)Z.mcp_servers=Z.mcp_servers??{},Z.mcp_servers.beacon=Z.mcp_servers.beacon??{};continue}if($){let z=/^command\s*=\s*["']([^"']*)["']/.exec(Y);if(z)Z.mcp_servers.beacon.command=z[1]}}return Z}function A(Q){try{if(typeof Bun<"u"&&Bun.TOML?.parse)return Bun.TOML.parse(Q);return PZ(Q)}catch{return null}}function bQ(){try{return Boolean(A(m(w(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function N0(){let Q="";try{Q=m(w(),"utf8")}catch{return null}let Z=A(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${p}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${p}`;return null}function K0(Q){let Z=Q.split(`
341
+ `),$=Z.indexOf(jQ),J=Z.indexOf(vQ,$);if($===-1||J===-1)return null;let Y=Z.findIndex((U,q)=>q>$&&q<J&&U.trim()==="[mcp_servers.beacon]");if(Y===-1)return null;let V=Y+1;while(V<J&&!/^\s*\[/.test(Z[V]))V++;let z=Z.findIndex((U,q)=>q>Y&&q<V&&/^\s*command\s*=/.test(U));if(z===-1)return null;return Z[z]=`command = ${JSON.stringify(R())}`,Z.join(`
342
+ `)}function BZ(){let Q="",Z=!1;try{Q=m(w(),"utf8"),Z=!0}catch{}if(Z){let V=A(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${p}`};if(V.mcp_servers?.beacon){let z=K0(Q);if(z&&z!==Q)h(w(),z);return{added:!1}}if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${p}`}}let $=!Q?"":Q.endsWith(`
341
343
  `)?`
342
344
  `:`
343
345
 
344
- `,J=Q+$+N0();if(O(J)?.mcp_servers?.beacon?.command!==R())return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${k}`};return qQ(w(),J),{added:!0}}function B0(){try{return O(_(w(),"utf8"))?.mcp_servers?.beacon?.command??null}catch{return null}}function PZ(){let Q="";try{Q=_(w(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
345
- `),$=Z.indexOf(jZ);if($===-1)return{removed:!1,skipped:DQ()};let J=Z.indexOf(GZ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
346
+ `,J=Q+$+B0();if(A(J)?.mcp_servers?.beacon?.command!==R())return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${p}`};return h(w(),J),{added:!0}}function u0(){try{return A(m(w(),"utf8"))?.mcp_servers?.beacon?.command??null}catch{return null}}function NZ(){let Q="";try{Q=m(w(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
347
+ `),$=Z.indexOf(jQ);if($===-1)return{removed:!1,skipped:bQ()};let J=Z.indexOf(vQ,$);if(J===-1)return{removed:!1,skipped:!0};let Y=Z.findIndex((U,q)=>q>$&&q<J&&U.trim()==="[mcp_servers.beacon]");if(Y===-1)return{removed:!1,skipped:!0};let V=Y+1;while(V<J&&!/^\s*\[/.test(Z[V]))V++;Z.splice(Y,V-Y),Z.splice(Z.indexOf(vQ),1),Z.splice(Z.indexOf(jQ),1);let z=Z.join(`
346
348
  `).replace(/\n{3,}/g,`
347
349
 
348
- `).replace(/^\n+/,"");if(O(Y)===null)return{removed:!1,skipped:!0};return qQ(w(),Y),{removed:!0}}async function K0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (VQ(),CQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let U of j){if(!y(XQ(),U))V.push(U);e(XQ(),U,Y[U])}let z=0;for(let U of D)if(r(IQ(),{event:U.event,matcher:U.matcher,command:t(U.command)}))z++;let W=b(zQ(),UQ);o(zQ(),UQ,XZ,s);let q=NZ();return{skillsAdded:V,hooksAdded:z,agentsMdBlockTouched:!W,mcp:q}}function AQ(){let Q={};for(let $ of j)Q[$]=y(XQ(),$);let Z={};for(let $ of D)Z[$.event]=n(IQ(),{event:$.event,command:$.command});return{detected:HZ(),skills:Q,hooks:Z,agentsMdBlock:b(zQ(),UQ),mcp:DQ()}}function EQ(){let Q=[];for(let Y of j)if(QQ(XQ(),Y))Q.push(Y);let Z=0;for(let Y of D)if(a(IQ(),{event:Y.event,command:Y.command}))Z++;let $=i(zQ(),UQ,XZ),J=PZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var OQ=()=>I(zZ(),".codex"),IQ=()=>I(OQ(),"hooks.json"),w=()=>I(OQ(),"config.toml"),zQ=()=>I(OQ(),"AGENTS.md"),XQ=()=>I(zZ(),".agents","skills"),UQ="<!-- beacon:global:start -->",XZ="<!-- beacon:global:end -->",D,gQ,jZ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",GZ="# beacon:end",N0=()=>`${jZ}
350
+ `).replace(/^\n+/,"");if(A(z)===null)return{removed:!1,skipped:!0};return h(w(),z),{removed:!0}}async function M0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (zQ(),DQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let X of j){if(!_(WQ(),X))V.push(X);ZQ(WQ(),X,Y[X])}let z=0;for(let X of E){let v=X.event==="UserPromptSubmit"||X.event==="Stop";if(v)$Z(UQ(),{event:X.event,matcher:X.matcher,command:I(X.command)});if(n(UQ(),{event:X.event,matcher:X.matcher,command:I(X.command)},{matchAnyMatcher:v}))z++}let U=k(XQ(),HQ);e(XQ(),HQ,HZ,a);let q=BZ();return{skillsAdded:V,hooksAdded:z,agentsMdBlockTouched:!U,mcp:q}}function IQ(){let Q={};for(let $ of j)Q[$]=_(WQ(),$);let Z={};for(let $ of E)Z[$.event]=o(UQ(),{event:$.event,command:$.command});return{detected:GZ(),skills:Q,hooks:Z,agentsMdBlock:k(XQ(),HQ),mcp:bQ()}}function LQ(){let Q=[];for(let Y of j)if($Q(WQ(),Y))Q.push(Y);let Z=0;for(let Y of E)if(i(UQ(),{event:Y.event,command:Y.command}))Z++;let $=QQ(XQ(),HQ,HZ),J=NZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var yQ=()=>D(WZ(),".codex"),UQ=()=>D(yQ(),"hooks.json"),w=()=>D(yQ(),"config.toml"),XQ=()=>D(yQ(),"AGENTS.md"),WQ=()=>D(WZ(),".agents","skills"),HQ="<!-- beacon:global:start -->",HZ="<!-- beacon:global:end -->",E,EQ,jQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",vQ="# beacon:end",B0=()=>`${jQ}
349
351
  [mcp_servers.beacon]
350
352
  command = "${R()}"
351
353
  args = ["mcp"]
352
- ${GZ}
353
- `,k="add it manually: codex mcp add beacon -- beacon mcp";var bQ=C(()=>{ZQ();qZ();D=[{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."}]});var wZ={};xQ(wZ,{provisionDb:()=>m0});import{createClient as D0}from"@libsql/client";import{drizzle as A0}from"drizzle-orm/libsql";import{migrate as E0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as b0}from"drizzle-orm/migrator";import{dirname as SQ,join as y0}from"path";import{fileURLToPath as L0}from"url";async function GQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function h0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function RZ(Q){if(!await GQ(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function p0(Q){for(let[Z,$]of Object.entries(S0)){if(!await GQ(Q,Z))continue;let J=await h0(Q,Z);for(let Y of $){if(!J.has(Y))continue;await Q.execute(`UPDATE "${Z}" SET "${Y}" = CAST((julianday("${Y}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${Y}") = 'text'`)}}}async function m0(Q,Z=_0){let $=D0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await GQ($,"__drizzle_migrations"),Y=await GQ($,"Node"),V=!1;if(Y&&!J){let W=b0({migrationsFolder:Z})[0];if(W)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[W.hash,W.folderMillis]}),V=!0}let z=await RZ($);if(await E0(A0($),{migrationsFolder:Z}),await RZ($)>z)V=!0;return await p0($),{migrated:V}}finally{$.close()}}var k0,_0,S0;var fZ=C(async()=>{k0=SQ(SQ(SQ(L0(import.meta.url)))),_0=process.env.BEACON_MIGRATIONS_DIR||y0(k0,"drizzle"),S0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});ZQ();import{existsSync as x0}from"fs";import{homedir as M0}from"os";import{join as WQ}from"path";function u0(){return process.env.HOME||process.env.USERPROFILE||M0()}var HQ=()=>WQ(u0(),".claude"),yQ=()=>WQ(HQ(),"skills"),jQ=()=>WQ(HQ(),"settings.json"),LQ=()=>WQ(HQ(),"CLAUDE.md"),kQ="<!-- beacon:global:start -->",KZ="<!-- beacon:global:end -->";var R0=s,S=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract: in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. Fail-open when there's no active contract."},{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:"PreToolUse",matcher:"AskUserQuestion",command:"beacon ask",description:"Surface the agent's AskUserQuestion in Beacon's modal; your pick flows back as the answer (falls through to the terminal if Beacon isn't open)."},{event:"PermissionRequest",matcher:"Edit|Write|MultiEdit|Bash|NotebookEdit",command:"beacon ask",description:"Surface edit/create/run approvals in Beacon's modal; your allow/deny flows back (falls through to the terminal prompt if Beacon isn't open)."},{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 w0(Q,Z){return e(yQ(),Q,Z)}function xZ(Q){return y(yQ(),Q)}function f0(Q){return QQ(yQ(),Q)}function T0(Q){return r(jQ(),Q)}function F0(Q){return n(jQ(),Q)}function C0(Q){return a(jQ(),Q)}function g0(Q){o(LQ(),kQ,KZ,Q)}function MZ(){return b(LQ(),kQ)}function O0(){return i(LQ(),kQ,KZ)}function uZ(){let Q={};for(let $ of j)Q[$]=xZ($);let Z={};for(let $ of S)Z[$.event]=F0({event:$.event,command:$.command});return{homeExists:x0(HQ()),skills:Q,hooks:Z,claudeMdBlock:MZ()}}function D1(){let Q=QZ(jQ(),{event:"PostToolUse",command:"beacon hook"});return Q?uQ(Q):null}async function I0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (VQ(),CQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let q of j){if(!xZ(q))V.push(q);w0(q,Y[q])}let z=0;for(let q of S)if(T0({event:q.event,matcher:q.matcher,command:t(q.command)}))z++;let W=MZ();return g0(R0),{skillsAdded:V,hooksAdded:z,claudeMdBlockTouched:!W}}async function A1(){if(aQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(iQ()){try{_Q()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await I0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (bQ(),BZ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function _Q(){let Q=[];for(let J of j)if(f0(J))Q.push(J);let Z=0;for(let J of S)if(C0(J))Z++;let $=O0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as c0}from"async_hooks";import{spawnSync as l0}from"child_process";import{createHash as t0}from"crypto";import{existsSync as FZ,mkdirSync as p,readFileSync as pQ,writeFileSync as mQ}from"fs";import{homedir as CZ}from"os";import{basename as s0,join as M,parse as d0,resolve as TZ}from"path";function B(){return process.env.BEACON_HOME||M(CZ(),".beacon")}function cQ(){return M(B(),"workspaces.json")}function h(Q){return t0("sha256").update(Q).digest("hex").slice(0,12)}function r0(Q=process.cwd()){let Z=l0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function gZ(Q){let Z=TZ(Q);return Z!==TZ(CZ())&&Z!==d0(Z).root}function OZ(){return M(B(),"deleted.json")}function lQ(){try{let Q=JSON.parse(pQ(OZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function IZ(Q){p(B(),{recursive:!0}),mQ(OZ(),JSON.stringify(Q,null,2))}function DZ(Q){return lQ().includes(Q)}function s1(Q){let Z=lQ();if(!Z.includes(Q))IZ([...Z,Q])}function n0(Q){let Z=lQ();if(Z.includes(Q))IZ(Z.filter(($)=>$!==Q))}function vQ(Q){return M(B(),Q)}function a0(Q){return`file:${M(vQ(Q),"db.sqlite")}`}function m(){try{let Q=JSON.parse(pQ(cQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function tQ(Q){p(B(),{recursive:!0}),mQ(cQ(),JSON.stringify(Q,null,2))}function NQ(){return m().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function f(Q){return m().find((Z)=>Z.id===Q)??null}function AZ(Q,Z,$=new Date().toISOString()){if(!gZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=h(Q);if(DZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=m(),V=Y.find((q)=>q.id===J),z={id:J,path:Q,name:Z||V?.name||s0(Q),lastOpenedAt:$},W=[z,...Y.filter((q)=>q.id!==J)];return p(vQ(J),{recursive:!0}),tQ(W),z}function d1(Q,Z){return n0(h(Q)),AZ(Q,Z)}function r1(Q,Z=new Date().toISOString()){let $=m(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,tQ($)}function n1(Q){if(tQ(m().filter((Z)=>Z.id!==Q)),sQ()===Q)o0(NQ()[0]?.id??null)}function EZ(){return M(B(),"active")}function sQ(){try{return pQ(EZ(),"utf8").trim()||null}catch{return null}}function o0(Q){p(B(),{recursive:!0}),mQ(EZ(),Q??"")}function a1(){let Q=sQ();return Q?f(Q):null}function o1(){let Q=e0()??sQ();return Q?f(Q):null}function i1(Q){return f(Q)?.path??null}function e1(){return FZ(cQ())}var bZ="beacon_ws";function yZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let J of $.split(";")){let Y=J.indexOf("=");if(Y===-1)continue;if(J.slice(0,Y).trim()===Z)return decodeURIComponent(J.slice(Y+1).trim())}return null}function Q2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&f(Z))return Z;let $=yZ(Q,bZ);if($&&f($))return $;return i0()}function i0(){let Q=NQ();return Q.length===1?Q[0].id:null}var LZ="x-beacon-workspace-path";function Z2(Q=process.cwd()){let Z=r0(Q);return{"x-beacon-workspace":h(Z),[LZ]:Z}}async function $2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&f(Z))return Z;let $=Q.headers.get(LZ);if($&&gZ($)&&!DZ(h($))&&(!Z||h($)===Z)){let Y=AZ($);return await Q1(Y.id),Y.id}let J=yZ(Q,bZ);if(J&&f(J))return J;return null}var kZ=new c0;function J2(Q,Z){return Q?kZ.run(Q,Z):Z()}function e0(){return kZ.getStore()??null}var hQ=new Set;function Y2(Q){hQ.delete(M(vQ(Q),"db.sqlite"))}async function Q1(Q){let Z=vQ(Q),$=M(Z,"db.sqlite"),J=FZ($);if(J&&hQ.has($))return{ok:!0,created:!1,migrated:!1};try{p(Z,{recursive:!0});let{provisionDb:Y}=await fZ().then(() => wZ),V=await Y(a0(Q));return hQ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}VQ();bQ();import{existsSync as PQ,readFileSync as Z1,rmSync as $1}from"fs";import{join as J1}from"path";var _Z=process.argv.slice(3),SZ=_Z.includes("--yes")||_Z.includes("-y"),v=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,G=(Q)=>`\x1B[2m${Q}\x1B[0m`,F=(Q)=>`
354
- \x1B[1m${Q}\x1B[0m`,hZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,T=B(),c=NQ(),dQ=uZ();console.log(F(SZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(F("Global"));console.log(` ${PQ(T)?`wipe ${T} (${c.length} workspaces)`:`${G(`${T} \u2014 already gone`)}`}`);for(let Q of j)console.log(` ${dQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:G(`skill ${Q} \u2014 already gone`)}`);for(let Q of S)console.log(` ${dQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:G(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${dQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":G("global CLAUDE.md block \u2014 already gone")}`);var BQ=AQ();console.log(F("Codex"));for(let Q of j)console.log(` ${BQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:G(`skill ${Q} \u2014 already gone`)}`);for(let Q of D)console.log(` ${BQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command} from ~/.codex/hooks.json`:G(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${BQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":G("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${BQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":G("config.toml beacon entry \u2014 already gone")}`);if(c.length){console.log(F(`Per-repo (${c.length})`));for(let Q of c){if(!PQ(Q.path)){console.log(` ${G(`${Q.path} \u2014 repo no longer on disk, skipping`)}`);continue}console.log(` ${Q.path}`),console.log(` ${G("strip beacon entry from .mcp.json, workflow block from AGENTS.md, skills, CLAUDE.md @-import")}`)}}if(!SZ)console.log(F("Nothing was changed.")),console.log(" Run \x1B[1mbeacon uninstall --yes\x1B[0m to apply."),console.log(` The \x1B[1mbeacon\x1B[0m binary itself (the cloned source + your PATH symlink) is NOT removed by this \u2014 your install script handles that.
355
- `),process.exit(0);console.log(F("Applying\u2026"));var A=_Q();if(A.skillsRemoved.length)console.log(` ${v(`removed skills: ${A.skillsRemoved.join(", ")}`)}`);if(A.hooksRemoved)console.log(` ${v(`removed ${A.hooksRemoved} hook${A.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(A.claudeMdBlockRemoved)console.log(` ${v("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var u=EQ();if(u.skillsRemoved.length)console.log(` ${v(`removed ~/.agents/skills: ${u.skillsRemoved.join(", ")}`)}`);if(u.hooksRemoved)console.log(` ${v(`removed ${u.hooksRemoved} hook${u.hooksRemoved===1?"":"s"} from ~/.codex/hooks.json`)}`);if(u.agentsMdBlockRemoved)console.log(` ${v("stripped Beacon block from ~/.codex/AGENTS.md")}`);if(u.mcpRemoved)console.log(` ${v("stripped [mcp_servers.beacon] from ~/.codex/config.toml")}`);if(u.mcpSkipped)console.log(` ${hZ("left [mcp_servers.beacon] in ~/.codex/config.toml \u2014 it wasn't written by Beacon (remove with: codex mcp remove beacon)")}`);for(let Q of c){if(!PQ(Q.path))continue;let Z=FQ(Q.path),$=[];if(Z.skillsRemoved.length)$.push(`skills(${Z.skillsRemoved.length})`);if(Z.mcpUnregistered)$.push(".mcp.json");if(Z.agentsBlockRemoved)$.push("AGENTS.md");if(Z.claudeImportRemoved)$.push("CLAUDE.md");if($.length)console.log(` ${v(`${Q.path} \u2192 ${$.join(", ")}`)}`)}var Y1=J1(T,"server.json");try{let{pid:Q}=JSON.parse(Z1(Y1,"utf8"));if(Q)try{process.kill(Q),console.log(` ${v(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(PQ(T))$1(T,{recursive:!0,force:!0}),console.log(` ${v(`removed ${T}`)}`);console.log(F("Done."));console.log(` ${hZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
354
+ ${vQ}
355
+ `,p="add it manually: codex mcp add beacon -- beacon mcp";var kQ=g(()=>{JQ();XZ();E=[{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."}]});var FZ={};wQ(FZ,{provisionDb:()=>c0});import{createClient as y0}from"@libsql/client";import{drizzle as b0}from"drizzle-orm/libsql";import{migrate as I0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as L0}from"drizzle-orm/migrator";import{dirname as mQ,join as k0}from"path";import{fileURLToPath as _0}from"url";async function NQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function m0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function fZ(Q){if(!await NQ(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function l0(Q){for(let[Z,$]of Object.entries(p0)){if(!await NQ(Q,Z))continue;let J=await m0(Q,Z);for(let Y of $){if(!J.has(Y))continue;await Q.execute(`UPDATE "${Z}" SET "${Y}" = CAST((julianday("${Y}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${Y}") = 'text'`)}}}async function c0(Q,Z=h0){let $=y0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await NQ($,"__drizzle_migrations"),Y=await NQ($,"Node"),V=!1;if(Y&&!J){let U=L0({migrationsFolder:Z})[0];if(U)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[U.hash,U.folderMillis]}),V=!0}let z=await fZ($);if(await I0(b0($),{migrationsFolder:Z}),await fZ($)>z)V=!0;return await l0($),{migrated:V}}finally{$.close()}}var S0,h0,p0;var xZ=g(async()=>{S0=mQ(mQ(mQ(_0(import.meta.url)))),h0=process.env.BEACON_MIGRATIONS_DIR||k0(S0,"drizzle"),p0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});JQ();import{existsSync as R0}from"fs";import{homedir as w0}from"os";import{join as GQ}from"path";function f0(){return process.env.HOME||process.env.USERPROFILE||w0()}var PQ=()=>GQ(f0(),".claude"),_Q=()=>GQ(PQ(),"skills"),BQ=()=>GQ(PQ(),"settings.json"),SQ=()=>GQ(PQ(),"CLAUDE.md"),hQ="<!-- beacon:global:start -->",uZ="<!-- beacon:global:end -->";var F0=a,l=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract: in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. Fail-open when there's no active contract."},{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:"PreToolUse",matcher:"AskUserQuestion",command:"beacon ask",description:"Surface the agent's AskUserQuestion in Beacon's modal; your pick flows back as the answer (falls through to the terminal if Beacon isn't open)."},{event:"PermissionRequest",matcher:"Edit|Write|MultiEdit|Bash|NotebookEdit",command:"beacon ask",description:"Surface edit/create/run approvals in Beacon's modal; your allow/deny flows back (falls through to the terminal prompt if Beacon isn't open)."},{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 x0(Q,Z){return ZQ(_Q(),Q,Z)}function MZ(Q){return _(_Q(),Q)}function T0(Q){return $Q(_Q(),Q)}function C0(Q){return n(BQ(),Q)}function g0(Q){return o(BQ(),Q)}function O0(Q){return i(BQ(),Q)}function A0(Q){e(SQ(),hQ,uZ,Q)}function RZ(){return k(SQ(),hQ)}function D0(){return QQ(SQ(),hQ,uZ)}function wZ(){let Q={};for(let $ of j)Q[$]=MZ($);let Z={};for(let $ of l)Z[$.event]=g0({event:$.event,command:$.command});return{homeExists:R0(PQ()),skills:Q,hooks:Z,claudeMdBlock:RZ()}}function y1(){let Q=JZ(BQ(),{event:"PostToolUse",command:"beacon hook"});return Q?FQ(Q):null}async function E0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (zQ(),DQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let q of j){if(!MZ(q))V.push(q);x0(q,Y[q])}let z=0;for(let q of l)if(C0({event:q.event,matcher:q.matcher,command:I(q.command)}))z++;let U=RZ();return A0(F0),{skillsAdded:V,hooksAdded:z,claudeMdBlockTouched:!U}}async function b1(){if(eQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(ZZ()){try{pQ()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await E0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (kQ(),KZ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function pQ(){let Q=[];for(let J of j)if(T0(J))Q.push(J);let Z=0;for(let J of l)if(O0(J))Z++;let $=D0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as s0}from"async_hooks";import{spawnSync as t0}from"child_process";import{createHash as r0}from"crypto";import{existsSync as CZ,mkdirSync as s,readFileSync as cQ,writeFileSync as sQ}from"fs";import{homedir as gZ}from"os";import{basename as d0,join as f,parse as a0,resolve as TZ}from"path";function u(){return process.env.BEACON_HOME||f(gZ(),".beacon")}function tQ(){return f(u(),"workspaces.json")}function c(Q){return r0("sha256").update(Q).digest("hex").slice(0,12)}function n0(Q=process.cwd()){let Z=t0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function OZ(Q){let Z=TZ(Q);return Z!==TZ(gZ())&&Z!==a0(Z).root}function AZ(){return f(u(),"deleted.json")}function rQ(){try{let Q=JSON.parse(cQ(AZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function DZ(Q){s(u(),{recursive:!0}),sQ(AZ(),JSON.stringify(Q,null,2))}function EZ(Q){return rQ().includes(Q)}function d1(Q){let Z=rQ();if(!Z.includes(Q))DZ([...Z,Q])}function o0(Q){let Z=rQ();if(Z.includes(Q))DZ(Z.filter(($)=>$!==Q))}function KQ(Q){return f(u(),Q)}function i0(Q){return`file:${f(KQ(Q),"db.sqlite")}`}function t(){try{let Q=JSON.parse(cQ(tQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function dQ(Q){s(u(),{recursive:!0}),sQ(tQ(),JSON.stringify(Q,null,2))}function uQ(){return t().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function x(Q){return t().find((Z)=>Z.id===Q)??null}function yZ(Q,Z,$=new Date().toISOString()){if(!OZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=c(Q);if(EZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=t(),V=Y.find((q)=>q.id===J),z={id:J,path:Q,name:Z||V?.name||d0(Q),lastOpenedAt:$},U=[z,...Y.filter((q)=>q.id!==J)];return s(KQ(J),{recursive:!0}),dQ(U),z}function a1(Q,Z){return o0(c(Q)),yZ(Q,Z)}function n1(Q,Z=new Date().toISOString()){let $=t(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,dQ($)}function o1(Q){if(dQ(t().filter((Z)=>Z.id!==Q)),aQ()===Q)e0(uQ()[0]?.id??null)}function bZ(){return f(u(),"active")}function aQ(){try{return cQ(bZ(),"utf8").trim()||null}catch{return null}}function e0(Q){s(u(),{recursive:!0}),sQ(bZ(),Q??"")}function i1(){let Q=aQ();return Q?x(Q):null}function e1(){let Q=Z1()??aQ();return Q?x(Q):null}function Q2(Q){return x(Q)?.path??null}function Z2(){return CZ(tQ())}var IZ="beacon_ws";function LZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let J of $.split(";")){let Y=J.indexOf("=");if(Y===-1)continue;if(J.slice(0,Y).trim()===Z)return decodeURIComponent(J.slice(Y+1).trim())}return null}function $2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&x(Z))return Z;let $=LZ(Q,IZ);if($&&x($))return $;return Q1()}function Q1(){let Q=uQ();return Q.length===1?Q[0].id:null}var kZ="x-beacon-workspace-path";function J2(Q=process.cwd()){let Z=n0(Q);return{"x-beacon-workspace":c(Z),[kZ]:Z}}async function Y2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&x(Z))return Z;let $=Q.headers.get(kZ);if($&&OZ($)&&!EZ(c($))&&(!Z||c($)===Z)){let Y=yZ($);return await $1(Y.id),Y.id}let J=LZ(Q,IZ);if(J&&x(J))return J;return null}var _Z=new s0;function V2(Q,Z){return Q?_Z.run(Q,Z):Z()}function Z1(){return _Z.getStore()??null}var lQ=new Set;function q2(Q){lQ.delete(f(KQ(Q),"db.sqlite"))}async function $1(Q){let Z=KQ(Q),$=f(Z,"db.sqlite"),J=CZ($);if(J&&lQ.has($))return{ok:!0,created:!1,migrated:!1};try{s(Z,{recursive:!0});let{provisionDb:Y}=await xZ().then(() => FZ),V=await Y(i0(Q));return lQ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}zQ();kQ();import{existsSync as MQ,readFileSync as J1,rmSync as Y1}from"fs";import{join as V1}from"path";var SZ=process.argv.slice(3),hZ=SZ.includes("--yes")||SZ.includes("-y"),B=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,P=(Q)=>`\x1B[2m${Q}\x1B[0m`,C=(Q)=>`
356
+ \x1B[1m${Q}\x1B[0m`,pZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,T=u(),r=uQ(),nQ=wZ();console.log(C(hZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(C("Global"));console.log(` ${MQ(T)?`wipe ${T} (${r.length} workspaces)`:`${P(`${T} \u2014 already gone`)}`}`);for(let Q of j)console.log(` ${nQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:P(`skill ${Q} \u2014 already gone`)}`);for(let Q of l)console.log(` ${nQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:P(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${nQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":P("global CLAUDE.md block \u2014 already gone")}`);var RQ=IQ();console.log(C("Codex"));for(let Q of j)console.log(` ${RQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:P(`skill ${Q} \u2014 already gone`)}`);for(let Q of E)console.log(` ${RQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command} from ~/.codex/hooks.json`:P(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${RQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":P("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${RQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":P("config.toml beacon entry \u2014 already gone")}`);if(r.length){console.log(C(`Per-repo (${r.length})`));for(let Q of r){if(!MQ(Q.path)){console.log(` ${P(`${Q.path} \u2014 repo no longer on disk, skipping`)}`);continue}console.log(` ${Q.path}`),console.log(` ${P("strip beacon entry from .mcp.json, workflow block from AGENTS.md, skills, CLAUDE.md @-import")}`)}}if(!hZ)console.log(C("Nothing was changed.")),console.log(" Run \x1B[1mbeacon uninstall --yes\x1B[0m to apply."),console.log(` The \x1B[1mbeacon\x1B[0m binary itself (the cloned source + your PATH symlink) is NOT removed by this \u2014 your install script handles that.
357
+ `),process.exit(0);console.log(C("Applying\u2026"));var y=pQ();if(y.skillsRemoved.length)console.log(` ${B(`removed skills: ${y.skillsRemoved.join(", ")}`)}`);if(y.hooksRemoved)console.log(` ${B(`removed ${y.hooksRemoved} hook${y.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(y.claudeMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var F=LQ();if(F.skillsRemoved.length)console.log(` ${B(`removed ~/.agents/skills: ${F.skillsRemoved.join(", ")}`)}`);if(F.hooksRemoved)console.log(` ${B(`removed ${F.hooksRemoved} hook${F.hooksRemoved===1?"":"s"} from ~/.codex/hooks.json`)}`);if(F.agentsMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.codex/AGENTS.md")}`);if(F.mcpRemoved)console.log(` ${B("stripped [mcp_servers.beacon] from ~/.codex/config.toml")}`);if(F.mcpSkipped)console.log(` ${pZ("left [mcp_servers.beacon] in ~/.codex/config.toml \u2014 it wasn't written by Beacon (remove with: codex mcp remove beacon)")}`);for(let Q of r){if(!MQ(Q.path))continue;let Z=AQ(Q.path),$=[];if(Z.skillsRemoved.length)$.push(`skills(${Z.skillsRemoved.length})`);if(Z.mcpUnregistered)$.push(".mcp.json");if(Z.agentsBlockRemoved)$.push("AGENTS.md");if(Z.claudeImportRemoved)$.push("CLAUDE.md");if($.length)console.log(` ${B(`${Q.path} \u2192 ${$.join(", ")}`)}`)}var q1=V1(T,"server.json");try{let{pid:Q}=JSON.parse(J1(q1,"utf8"));if(Q)try{process.kill(Q),console.log(` ${B(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(MQ(T))Y1(T,{recursive:!0,force:!0}),console.log(` ${B(`removed ${T}`)}`);console.log(C("Done."));console.log(` ${pZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
356
358
  `);
@@ -1,16 +1,16 @@
1
1
  // @bun
2
- var p=Object.defineProperty;var l=(q)=>q;function t(q,J){this[q]=l.bind(null,J)}var m=(q,J)=>{for(var Q in J)p(q,Q,{get:J[Q],enumerable:!0,configurable:!0,set:t.bind(J,Q)})};var K=(q,J)=>()=>(q&&(J=q(q=0)),J);import{existsSync as P,mkdirSync as E,readdirSync as s,readFileSync as W,rmSync as a,writeFileSync as I}from"fs";import{basename as d,dirname as R,join as v}from"path";function Nq(){return!!process.env.CLAUDE_PLUGIN_ROOT}function c(q=process.env.HOME||process.env.USERPROFILE||""){if(!q)return null;let J=v(q,".claude","plugins");if(!P(J))return null;let Q=[J];for(let V=0;V<3&&Q.length;V++){let Y=[];for(let Z of Q){let X=v(Z,".claude-plugin","plugin.json");try{if(P(X)&&JSON.parse(W(X,"utf8")).name==="beacon")return Z}catch{}try{for(let N of s(Z,{withFileTypes:!0}))if(N.isDirectory())Y.push(v(Z,N.name))}catch{}}Q=Y}return null}function vq(q){return c(q)!==null}function Mq(q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(q)}function O(){let q=process.env.BEACON_CLI_PATH;if(q)return q;if(P(k))return k;return"beacon"}function n(q){let J=q.indexOf(" ");return J===-1?q:q.slice(0,J)}function Wq(q){let J=O();if(J==="beacon")return q;return q.replace(/^beacon(\s|$)/,`${J}$1`)}function M(q){let J=n(q);return d(J)+q.slice(J.length)}function Pq(q=process.env.HOME||process.env.USERPROFILE||""){if(!q)return null;try{let J=JSON.parse(W(v(q,".claude","plugins","installed_plugins.json"),"utf8"));for(let Q of Object.keys(J.plugins??{}))if(/^beacon@/.test(Q))return{key:Q,marketplace:Q.split("@")[1]??""}}catch{}return null}function u(q){try{return JSON.parse(W(q,"utf8"))}catch{return{}}}function _(q,J){E(R(q),{recursive:!0}),I(q,JSON.stringify(J,null,2)+`
3
- `)}function Iq(q,J){let Q=u(q);Q.hooks=Q.hooks??{},Q.hooks[J.event]=Q.hooks[J.event]??[];let V=Q.hooks[J.event];if(V.some((Z)=>Z.matcher===J.matcher&&Z.hooks?.some((X)=>M(X.command)===M(J.command))))return!1;return V.push({matcher:J.matcher,hooks:[{type:"command",command:J.command}]}),_(q,Q),!0}function uq(q,J){return(u(q).hooks?.[J.event]??[]).some((Y)=>Y.hooks?.some((Z)=>M(Z.command)===M(J.command)))}function xq(q,J){let V=u(q).hooks?.[J.event]??[];for(let Y of V)for(let Z of Y.hooks??[])if(M(Z.command)===M(J.command))return Z.command;return null}function Aq(q,J){let Q=u(q),V=Q.hooks?.[J.event];if(!V)return!1;let Y=!1,Z=V.map((X)=>{let N=X.hooks?.length??0,G=(X.hooks??[]).filter((z)=>M(z.command)!==M(J.command));if(G.length!==N)Y=!0;return{...X,hooks:G}}).filter((X)=>(X.hooks??[]).length>0);if(!Y)return!1;if(Z.length)Q.hooks[J.event]=Z;else delete Q.hooks[J.event];if(Q.hooks&&Object.keys(Q.hooks).length===0)delete Q.hooks;return _(q,Q),!0}function wq(q,J,Q,V){let Y=`${J}
2
+ var l=Object.defineProperty;var p=(q)=>q;function s(q,J){this[q]=p.bind(null,J)}var t=(q,J)=>{for(var Q in J)l(q,Q,{get:J[Q],enumerable:!0,configurable:!0,set:s.bind(J,Q)})};var O=(q,J)=>()=>(q&&(J=q(q=0)),J);import{existsSync as T,mkdirSync as I,readdirSync as m,readFileSync as P,rmSync as d,writeFileSync as w}from"fs";import{basename as a,dirname as g,join as M}from"path";function Nq(){return!!process.env.CLAUDE_PLUGIN_ROOT}function n(q=process.env.HOME||process.env.USERPROFILE||""){if(!q)return null;let J=M(q,".claude","plugins");if(!T(J))return null;let Q=[J];for(let V=0;V<3&&Q.length;V++){let Y=[];for(let Z of Q){let U=M(Z,".claude-plugin","plugin.json");try{if(T(U)&&JSON.parse(P(U,"utf8")).name==="beacon")return Z}catch{}try{for(let X of m(Z,{withFileTypes:!0}))if(X.isDirectory())Y.push(M(Z,X.name))}catch{}}Q=Y}return null}function vq(q){return n(q)!==null}function Mq(q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(q)}function D(){let q=process.env.BEACON_CLI_PATH;if(q)return q;if(T(_))return _;return"beacon"}function c(q){let J=q.indexOf(" ");return J===-1?q:q.slice(0,J)}function Wq(q){let J=D();if(J==="beacon")return q;return q.replace(/^beacon(\s|$)/,`${J}$1`)}function B(q){let J=c(q);return a(J)+q.slice(J.length)}function Pq(q=process.env.HOME||process.env.USERPROFILE||""){if(!q)return null;try{let J=JSON.parse(P(M(q,".claude","plugins","installed_plugins.json"),"utf8"));for(let Q of Object.keys(J.plugins??{}))if(/^beacon@/.test(Q))return{key:Q,marketplace:Q.split("@")[1]??""}}catch{}return null}function u(q){try{return JSON.parse(P(q,"utf8"))}catch{return{}}}function x(q,J){I(g(q),{recursive:!0}),w(q,JSON.stringify(J,null,2)+`
3
+ `)}function uq(q,J,Q={}){let V=u(q);V.hooks=V.hooks??{},V.hooks[J.event]=V.hooks[J.event]??[];let Y=V.hooks[J.event];if(Y.some((U)=>U.hooks?.some((X)=>B(X.command)===B(J.command)&&(Q.matchAnyMatcher||U.matcher===J.matcher))))return!1;return Y.push({matcher:J.matcher,hooks:[{type:"command",command:J.command}]}),x(q,V),!0}function Aq(q,J){let Q=u(q),V=Q.hooks?.[J.event];if(!V)return!1;let Y=V.flatMap((X,$)=>(X.hooks??[]).flatMap((z,W)=>B(z.command)===B(J.command)?[{matcherIndex:$,hookIndex:W,preferred:X.matcher===J.matcher}]:[]));if(Y.length<2)return!1;let Z=Y.find((X)=>X.preferred)??Y[0],U=new Set(Y.filter((X)=>X!==Z).map((X)=>`${X.matcherIndex}:${X.hookIndex}`));return Q.hooks[J.event]=V.map((X,$)=>({...X,hooks:(X.hooks??[]).filter((z,W)=>!U.has(`${$}:${W}`))})).filter((X)=>(X.hooks??[]).length>0),x(q,Q),!0}function wq(q,J){return(u(q).hooks?.[J.event]??[]).some((Y)=>Y.hooks?.some((Z)=>B(Z.command)===B(J.command)))}function Kq(q,J){let V=u(q).hooks?.[J.event]??[];for(let Y of V)for(let Z of Y.hooks??[])if(B(Z.command)===B(J.command))return Z.command;return null}function Cq(q,J){let Q=u(q),V=Q.hooks?.[J.event];if(!V)return!1;let Y=!1,Z=V.map((U)=>{let X=U.hooks?.length??0,$=(U.hooks??[]).filter((z)=>B(z.command)!==B(J.command));if($.length!==X)Y=!0;return{...U,hooks:$}}).filter((U)=>(U.hooks??[]).length>0);if(!Y)return!1;if(Z.length)Q.hooks[J.event]=Z;else delete Q.hooks[J.event];if(Q.hooks&&Object.keys(Q.hooks).length===0)delete Q.hooks;return x(q,Q),!0}function Eq(q,J,Q,V){let Y=`${J}
4
4
  ${V.trim()}
5
- ${Q}`,Z="";try{Z=W(q,"utf8")}catch{}let X=new RegExp(`${J}[\\s\\S]*?${Q}`);Z=X.test(Z)?Z.replace(X,Y):Z.trim()?`${Z.trim()}
5
+ ${Q}`,Z="";try{Z=P(q,"utf8")}catch{}let U=new RegExp(`${J}[\\s\\S]*?${Q}`);Z=U.test(Z)?Z.replace(U,Y):Z.trim()?`${Z.trim()}
6
6
 
7
7
  ${Y}
8
8
  `:`${Y}
9
- `,E(R(q),{recursive:!0}),I(q,Z.endsWith(`
9
+ `,I(g(q),{recursive:!0}),w(q,Z.endsWith(`
10
10
  `)?Z:`${Z}
11
- `)}function Cq(q,J){try{return W(q,"utf8").includes(J)}catch{return!1}}function Kq(q,J,Q){let V="";try{V=W(q,"utf8")}catch{return!1}let Y=new RegExp(`${J}[\\s\\S]*?${Q}\\n?`);if(!Y.test(V))return!1;let Z=V.replace(Y,"").replace(/\n{3,}/g,`
11
+ `)}function Oq(q,J){try{return P(q,"utf8").includes(J)}catch{return!1}}function Iq(q,J,Q){let V="";try{V=P(q,"utf8")}catch{return!1}let Y=new RegExp(`${J}[\\s\\S]*?${Q}\\n?`);if(!Y.test(V))return!1;let Z=V.replace(Y,"").replace(/\n{3,}/g,`
12
12
 
13
- `).trimStart();return I(q,Z),!0}function Eq(q,J,Q){let V=v(q,J);E(V,{recursive:!0});let Y=v(V,"SKILL.md");return I(Y,Q),Y}function Oq(q,J){return P(v(q,J,"SKILL.md"))}function Dq(q,J){let Q=v(q,J);if(!P(Q))return!1;return a(Q,{recursive:!0,force:!0}),!0}var Bq,k="/Applications/Beacon.app/Contents/Resources/bin/beacon",Tq=`## Beacon (visual planning panel)
13
+ `).trimStart();return w(q,Z),!0}function Dq(q,J,Q){let V=M(q,J);I(V,{recursive:!0});let Y=M(V,"SKILL.md");return w(Y,Q),Y}function xq(q,J){return T(M(q,J,"SKILL.md"))}function Lq(q,J){let Q=M(q,J);if(!T(Q))return!1;return d(Q,{recursive:!0,force:!0}),!0}var Bq,_="/Applications/Beacon.app/Contents/Resources/bin/beacon",Tq=`## Beacon (visual planning panel)
14
14
 
15
15
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
16
16
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -34,23 +34,23 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
34
34
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
35
35
  on the /map and /db boards (added features, attached subtasks, edited columns, new
36
36
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
37
- verbatim. Do NOT implement until the tool returns approval.`;var g=K(()=>{Bq=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var bq=1500,jq=480000,kq=1800000,x=3600000,Rq=3000;var F=()=>{};var Gq={};m(Gq,{stripAgentsPointer:()=>y,repoMcpCliTarget:()=>Yq,removeRepoAssets:()=>$q,installRefreshSkill:()=>o,installPlanSkill:()=>i,installInitSkill:()=>r,installExplainSkill:()=>e,installCodexRepoSkills:()=>Jq,ensureWorkflowDoc:()=>Qq,ensureMcp:()=>Vq,contextDocTargets:()=>j,auditRepo:()=>Zq,REFRESH_SKILL:()=>L,PLAN_SKILL:()=>h,INIT_SKILL:()=>D,EXPLAIN_SKILL:()=>S});import{existsSync as U,mkdirSync as T,readFileSync as B,rmSync as A,writeFileSync as H}from"fs";import{join as $}from"path";function r(q){let J=$(q,".claude","skills","beacon-init");T(J,{recursive:!0});let Q=$(J,"SKILL.md");return H(Q,D),Q}function o(q){let J=$(q,".claude","skills","beacon-refresh");T(J,{recursive:!0});let Q=$(J,"SKILL.md");return H(Q,L),Q}function i(q){let J=$(q,".claude","skills","beacon-plan");T(J,{recursive:!0});let Q=$(J,"SKILL.md");return H(Q,h),Q}function e(q){let J=$(q,".claude","skills","beacon-explain");T(J,{recursive:!0});let Q=$(J,"SKILL.md");return H(Q,S),Q}function Jq(q){let J=[];for(let Q of qq){let V=$(q,".agents","skills",Q.name);T(V,{recursive:!0});let Y=$(V,"SKILL.md");H(Y,Q.body()),J.push(Y)}return J}function j(q){let J=$(q,"AGENTS.md"),Q=$(q,"CLAUDE.md"),V=U(J),Y=U(Q);if(!V&&!Y)return[J,Q];let Z=[];if(V)Z.push(J);if(Y)Z.push(Q);return Z}function y(q){let J=$(q,"CLAUDE.md");if(!U(J))return;let Q=B(J,"utf8"),V=Q.split(`
37
+ verbatim. Do NOT implement until the tool returns approval.`;var F=O(()=>{Bq=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var jq=1500,Rq=480000,_q=1800000,K=3600000,gq=3000;var k=()=>{};var Gq={};t(Gq,{stripAgentsPointer:()=>h,repoMcpCliTarget:()=>Yq,removeRepoAssets:()=>$q,installRefreshSkill:()=>i,installPlanSkill:()=>o,installInitSkill:()=>r,installExplainSkill:()=>e,installCodexRepoSkills:()=>Jq,ensureWorkflowDoc:()=>Qq,ensureMcp:()=>Vq,contextDocTargets:()=>R,auditRepo:()=>Zq,REFRESH_SKILL:()=>b,PLAN_SKILL:()=>S,INIT_SKILL:()=>L,EXPLAIN_SKILL:()=>y});import{existsSync as N,mkdirSync as A,readFileSync as v,rmSync as C,writeFileSync as H}from"fs";import{join as G}from"path";function r(q){let J=G(q,".claude","skills","beacon-init");A(J,{recursive:!0});let Q=G(J,"SKILL.md");return H(Q,L),Q}function i(q){let J=G(q,".claude","skills","beacon-refresh");A(J,{recursive:!0});let Q=G(J,"SKILL.md");return H(Q,b),Q}function o(q){let J=G(q,".claude","skills","beacon-plan");A(J,{recursive:!0});let Q=G(J,"SKILL.md");return H(Q,S),Q}function e(q){let J=G(q,".claude","skills","beacon-explain");A(J,{recursive:!0});let Q=G(J,"SKILL.md");return H(Q,y),Q}function Jq(q){let J=[];for(let Q of qq){let V=G(q,".agents","skills",Q.name);A(V,{recursive:!0});let Y=G(V,"SKILL.md");H(Y,Q.body()),J.push(Y)}return J}function R(q){let J=G(q,"AGENTS.md"),Q=G(q,"CLAUDE.md"),V=N(J),Y=N(Q);if(!V&&!Y)return[J,Q];let Z=[];if(V)Z.push(J);if(Y)Z.push(Q);return Z}function h(q){let J=G(q,"CLAUDE.md");if(!N(J))return;let Q=v(J,"utf8"),V=Q.split(`
38
38
  `).filter((Y)=>!/^\s*@\.?\/?AGENTS\.md\s*$/.test(Y)).join(`
39
39
  `).trim();if(V&&V!==Q.trim())H(J,`${V}
40
- `)}function Qq(q){let J=new RegExp(`${w}[\\s\\S]*?${b}`);for(let Q of j(q)){let V="";try{V=B(Q,"utf8")}catch{}V=J.test(V)?V.replace(J,f):`${V.trim()}
40
+ `)}function Qq(q){let J=new RegExp(`${E}[\\s\\S]*?${j}`);for(let Q of R(q)){let V="";try{V=v(Q,"utf8")}catch{}V=J.test(V)?V.replace(J,f):`${V.trim()}
41
41
 
42
42
  ${f}
43
43
  `.trimStart(),H(Q,V.endsWith(`
44
44
  `)?V:`${V}
45
- `)}y(q)}function Vq(q){let J=$(q,".mcp.json"),Q={};try{Q=JSON.parse(B(J,"utf8"))}catch{}Q.mcpServers=Q.mcpServers??{};let V=Q.mcpServers.beacon;if(V){if(!V.timeout||V.timeout<x)return V.timeout=x,H(J,JSON.stringify(Q,null,2)+`
46
- `),{path:J,added:!1,updated:!0};return{path:J,added:!1,updated:!1}}return Q.mcpServers.beacon={command:O(),args:["mcp"],timeout:x},H(J,JSON.stringify(Q,null,2)+`
47
- `),{path:J,added:!0,updated:!1}}function Yq(q){try{return JSON.parse(B($(q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function Zq(q){let J=$(q,".mcp.json"),Q=!1;try{Q=!!JSON.parse(B(J,"utf8")).mcpServers?.beacon}catch{}let V=j(q).some((Y)=>{try{return B(Y,"utf8").includes(w)}catch{return!1}});return{repo:q,mcpRegistered:Q,workflowBlock:V,skills:{"beacon-init":U($(q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":U($(q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":U($(q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":U($(q,".agents","skills","beacon-refresh","SKILL.md"))}}}function $q(q){let J=[];for(let G of["beacon-init","beacon-refresh","beacon-db-design"]){let z=$(q,".claude","skills",G);if(U(z))A(z,{recursive:!0,force:!0}),J.push(G)}for(let G of["beacon-init","beacon-refresh"]){let z=$(q,".agents","skills",G);if(U(z))A(z,{recursive:!0,force:!0}),J.push(`codex:${G}`)}let Q=!1,V=$(q,".mcp.json");try{let G=JSON.parse(B(V,"utf8"));if(G.mcpServers?.beacon){if(delete G.mcpServers.beacon,Q=!0,G.mcpServers&&Object.keys(G.mcpServers).length===0)delete G.mcpServers;if(Object.keys(G).length===0)A(V,{force:!0});else H(V,JSON.stringify(G,null,2)+`
48
- `)}}catch{}let Y=!1,Z=new RegExp(`\\n?${w}[\\s\\S]*?${b}\\n?`);for(let G of[$(q,"AGENTS.md"),$(q,"CLAUDE.md")])try{let z=B(G,"utf8");if(Z.test(z)){let C=z.replace(Z,`
45
+ `)}h(q)}function Vq(q){let J=G(q,".mcp.json"),Q={};try{Q=JSON.parse(v(J,"utf8"))}catch{}Q.mcpServers=Q.mcpServers??{};let V=Q.mcpServers.beacon;if(V){if(!V.timeout||V.timeout<K)return V.timeout=K,H(J,JSON.stringify(Q,null,2)+`
46
+ `),{path:J,added:!1,updated:!0};return{path:J,added:!1,updated:!1}}return Q.mcpServers.beacon={command:D(),args:["mcp"],timeout:K},H(J,JSON.stringify(Q,null,2)+`
47
+ `),{path:J,added:!0,updated:!1}}function Yq(q){try{return JSON.parse(v(G(q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function Zq(q){let J=G(q,".mcp.json"),Q=!1;try{Q=!!JSON.parse(v(J,"utf8")).mcpServers?.beacon}catch{}let V=R(q).some((Y)=>{try{return v(Y,"utf8").includes(E)}catch{return!1}});return{repo:q,mcpRegistered:Q,workflowBlock:V,skills:{"beacon-init":N(G(q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":N(G(q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":N(G(q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":N(G(q,".agents","skills","beacon-refresh","SKILL.md"))}}}function $q(q){let J=[];for(let $ of["beacon-init","beacon-refresh","beacon-db-design"]){let z=G(q,".claude","skills",$);if(N(z))C(z,{recursive:!0,force:!0}),J.push($)}for(let $ of["beacon-init","beacon-refresh"]){let z=G(q,".agents","skills",$);if(N(z))C(z,{recursive:!0,force:!0}),J.push(`codex:${$}`)}let Q=!1,V=G(q,".mcp.json");try{let $=JSON.parse(v(V,"utf8"));if($.mcpServers?.beacon){if(delete $.mcpServers.beacon,Q=!0,$.mcpServers&&Object.keys($.mcpServers).length===0)delete $.mcpServers;if(Object.keys($).length===0)C(V,{force:!0});else H(V,JSON.stringify($,null,2)+`
48
+ `)}}catch{}let Y=!1,Z=new RegExp(`\\n?${E}[\\s\\S]*?${j}\\n?`);for(let $ of[G(q,"AGENTS.md"),G(q,"CLAUDE.md")])try{let z=v($,"utf8");if(Z.test(z)){let W=z.replace(Z,`
49
49
  `).replace(/\n{3,}/g,`
50
50
 
51
- `).trimStart();H(G,C.endsWith(`
52
- `)?C:`${C}
53
- `),Y=!0}}catch{}let X=!1,N=$(q,"CLAUDE.md");try{let G=B(N,"utf8"),z=G.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(z!==G){if(!z.trim())A(N,{force:!0});else H(N,z);X=!0}}catch{}return{skillsRemoved:J,mcpUnregistered:Q,agentsBlockRemoved:Y,claudeImportRemoved:X}}var D=`---
51
+ `).trimStart();H($,W.endsWith(`
52
+ `)?W:`${W}
53
+ `),Y=!0}}catch{}let U=!1,X=G(q,"CLAUDE.md");try{let $=v(X,"utf8"),z=$.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(z!==$){if(!z.trim())C(X,{force:!0});else H(X,z);U=!0}}catch{}return{skillsRemoved:J,mcpUnregistered:Q,agentsBlockRemoved:Y,claudeImportRemoved:U}}var L=`---
54
54
  name: beacon-init
55
55
  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.
56
56
  ---
@@ -97,7 +97,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
97
97
  That one command wires the repo (writes \`.mcp.json\` + skills so your NEXT session gets the \`beacon_*\` tools natively, heals the global install), starts the Beacon daemon if it isn't running, registers + provisions this workspace, and POSTs your analysis to the same \`/api/init\` endpoint the MCP tool uses \u2014 so init completes in THIS session. Read the counts it prints and report them.
98
98
 
99
99
  After the tool (or \`beacon init-persist\`) returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
100
- `,L=`---
100
+ `,b=`---
101
101
  name: beacon-refresh
102
102
  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.
103
103
  ---
@@ -144,7 +144,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
144
144
  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.
145
145
 
146
146
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
147
- `,h=`---
147
+ `,S=`---
148
148
  name: beacon-plan
149
149
  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.
150
150
  ---
@@ -193,7 +193,7 @@ If it returns feedback, revise and call it again.
193
193
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
194
194
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
195
195
  run \`beacon\` in this repo once.
196
- `,S=`---
196
+ `,y=`---
197
197
  name: beacon-explain
198
198
  description: Teach the user part of THIS codebase as an interactive visual lesson on Beacon's /learn page \u2014 a concept map + plain-English narrative they can question \u2014 instead of a wall of text. Use when the user says "explain", "teach me", "walk me through", "how does X work", or "help me understand the Y category".
199
199
  ---
@@ -263,7 +263,7 @@ so the learner sees the table IN CONTEXT, wired to the code that uses it.
263
263
  Every answer must ADD understanding (rationale, trade-off) \u2014 never just restate the question. Expand
264
264
  the narrative or add nodes where it helps. Keep looping until the tool reports the user saved or closed
265
265
  the lesson.
266
- `,qq,w="<!-- beacon:workflow:start -->",b="<!-- beacon:workflow:end -->",f;var Xq=K(()=>{g();F();qq=[{name:"beacon-init",body:()=>D},{name:"beacon-refresh",body:()=>L}];f=`${w}
266
+ `,qq,E="<!-- beacon:workflow:start -->",j="<!-- beacon:workflow:end -->",f;var Xq=O(()=>{F();k();qq=[{name:"beacon-init",body:()=>L},{name:"beacon-refresh",body:()=>b}];f=`${E}
267
267
  ## Beacon \u2014 feature workflow
268
268
 
269
269
  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:
@@ -335,4 +335,4 @@ Register them all in that single batched call. If a plan added five features, th
335
335
  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.
336
336
 
337
337
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
338
- ${b}`});Xq();export{y as stripAgentsPointer,Yq as repoMcpCliTarget,$q as removeRepoAssets,o as installRefreshSkill,i as installPlanSkill,r as installInitSkill,e as installExplainSkill,Jq as installCodexRepoSkills,Qq as ensureWorkflowDoc,Vq as ensureMcp,j as contextDocTargets,Zq as auditRepo,L as REFRESH_SKILL,h as PLAN_SKILL,D as INIT_SKILL,S as EXPLAIN_SKILL};
338
+ ${j}`});Xq();export{h as stripAgentsPointer,Yq as repoMcpCliTarget,$q as removeRepoAssets,i as installRefreshSkill,o as installPlanSkill,r as installInitSkill,e as installExplainSkill,Jq as installCodexRepoSkills,Qq as ensureWorkflowDoc,Vq as ensureMcp,R as contextDocTargets,Zq as auditRepo,b as REFRESH_SKILL,S as PLAN_SKILL,L as INIT_SKILL,y as EXPLAIN_SKILL};