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
package/dist/bin/hook.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var IZ=Object.defineProperty;var AZ=(Q)=>Q;function DZ(Q,Z){this[Q]=AZ.bind(null,Z)}var zQ=(Q,Z)=>{for(var $ in Z)IZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:DZ.bind(Z,$)})};var w=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);import{existsSync as T,mkdirSync as XQ,readdirSync as bZ,readFileSync as R,rmSync as fZ,writeFileSync as y}from"fs";import{basename as EZ,dirname as fQ,join as B}from"path";function EQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function yQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=B(Q,".claude","plugins");if(!T(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let q=B(V,".claude-plugin","plugin.json");try{if(T(q)&&JSON.parse(R(q,"utf8")).name==="beacon")return V}catch{}try{for(let W of bZ(V,{withFileTypes:!0}))if(W.isDirectory())Y.push(B(V,W.name))}catch{}}$=Y}return null}function kQ(Q){return yQ(Q)!==null}function yZ(Q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(Q)}function v(){let Q=process.env.BEACON_CLI_PATH;if(Q)return Q;if(T(bQ))return bQ;return"beacon"}function UQ(Q){let Z=Q.indexOf(" ");return Z===-1?Q:Q.slice(0,Z)}function k(Q){let Z=v();if(Z==="beacon")return Q;return Q.replace(/^beacon(\s|$)/,`${Z}$1`)}function K(Q){let Z=UQ(Q);return EZ(Z)+Q.slice(Z.length)}function kZ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;try{let Z=JSON.parse(R(B(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 _(Q){try{return JSON.parse(R(Q,"utf8"))}catch{return{}}}function LQ(Q,Z){XQ(fQ(Q),{recursive:!0}),y(Q,JSON.stringify(Z,null,2)+`
4
- `)}function S(Q,Z){let $=_(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((q)=>K(q.command)===K(Z.command))))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),LQ(Q,$),!0}function h(Q,Z){return(_(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>K(V.command)===K(Z.command)))}function _Q(Q,Z){let J=_(Q).hooks?.[Z.event]??[];for(let Y of J)for(let V of Y.hooks??[])if(K(V.command)===K(Z.command))return V.command;return null}function p(Q,Z){let $=_(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((q)=>{let W=q.hooks?.length??0,z=(q.hooks??[]).filter((U)=>K(U.command)!==K(Z.command));if(z.length!==W)Y=!0;return{...q,hooks:z}}).filter((q)=>(q.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 LQ(Q,$),!0}function m(Q,Z,$,J){let Y=`${Z}
3
+ var DZ=Object.defineProperty;var fZ=(Q)=>Q;function yZ(Q,Z){this[Q]=fZ.bind(null,Z)}var WQ=(Q,Z)=>{for(var $ in Z)DZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:yZ.bind(Z,$)})};var R=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);import{existsSync as g,mkdirSync as HQ,readdirSync as bZ,readFileSync as F,rmSync as EZ,writeFileSync as S}from"fs";import{basename as IZ,dirname as LQ,join as P}from"path";function kQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function _Q(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=P(Q,".claude","plugins");if(!g(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let q=P(V,".claude-plugin","plugin.json");try{if(g(q)&&JSON.parse(F(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of bZ(V,{withFileTypes:!0}))if(X.isDirectory())Y.push(P(V,X.name))}catch{}}$=Y}return null}function SQ(Q){return _Q(Q)!==null}function LZ(Q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(Q)}function M(){let Q=process.env.BEACON_CLI_PATH;if(Q)return Q;if(g(IQ))return IQ;return"beacon"}function jQ(Q){let Z=Q.indexOf(" ");return Z===-1?Q:Q.slice(0,Z)}function O(Q){let Z=M();if(Z==="beacon")return Q;return Q.replace(/^beacon(\s|$)/,`${Z}$1`)}function G(Q){let Z=jQ(Q);return IZ(Z)+Q.slice(Z.length)}function kZ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;try{let Z=JSON.parse(F(P(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 A(Q){try{return JSON.parse(F(Q,"utf8"))}catch{return{}}}function GQ(Q,Z){HQ(LQ(Q),{recursive:!0}),S(Q,JSON.stringify(Z,null,2)+`
4
+ `)}function p(Q,Z,$={}){let J=A(Q);J.hooks=J.hooks??{},J.hooks[Z.event]=J.hooks[Z.event]??[];let Y=J.hooks[Z.event];if(Y.some((q)=>q.hooks?.some((X)=>G(X.command)===G(Z.command)&&($.matchAnyMatcher||q.matcher===Z.matcher))))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),GQ(Q,J),!0}function hQ(Q,Z){let $=A(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=J.flatMap((X,z)=>(X.hooks??[]).flatMap((U,j)=>G(U.command)===G(Z.command)?[{matcherIndex:z,hookIndex:j,preferred:X.matcher===Z.matcher}]:[]));if(Y.length<2)return!1;let V=Y.find((X)=>X.preferred)??Y[0],q=new Set(Y.filter((X)=>X!==V).map((X)=>`${X.matcherIndex}:${X.hookIndex}`));return $.hooks[Z.event]=J.map((X,z)=>({...X,hooks:(X.hooks??[]).filter((U,j)=>!q.has(`${z}:${j}`))})).filter((X)=>(X.hooks??[]).length>0),GQ(Q,$),!0}function m(Q,Z){return(A(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>G(V.command)===G(Z.command)))}function pQ(Q,Z){let J=A(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 c(Q,Z){let $=A(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((U)=>G(U.command)!==G(Z.command));if(z.length!==X)Y=!0;return{...q,hooks:z}}).filter((q)=>(q.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 GQ(Q,$),!0}function l(Q,Z,$,J){let Y=`${Z}
5
5
  ${J.trim()}
6
- ${$}`,V="";try{V=R(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
6
+ ${$}`,V="";try{V=F(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
7
7
 
8
8
  ${Y}
9
9
  `:`${Y}
10
- `,XQ(fQ(Q),{recursive:!0}),y(Q,V.endsWith(`
10
+ `,HQ(LQ(Q),{recursive:!0}),S(Q,V.endsWith(`
11
11
  `)?V:`${V}
12
- `)}function g(Q,Z){try{return R(Q,"utf8").includes(Z)}catch{return!1}}function c(Q,Z,$){let J="";try{J=R(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 D(Q,Z){try{return F(Q,"utf8").includes(Z)}catch{return!1}}function s(Q,Z,$){let J="";try{J=F(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 y(Q,V),!0}function l(Q,Z,$){let J=B(Q,Z);XQ(J,{recursive:!0});let Y=B(J,"SKILL.md");return y(Y,$),Y}function O(Q,Z){return T(B(Q,Z,"SKILL.md"))}function d(Q,Z){let $=B(Q,Z);if(!T($))return!1;return fZ($,{recursive:!0,force:!0}),!0}var N,bQ="/Applications/Beacon.app/Contents/Resources/bin/beacon",L=`## Beacon (visual planning panel)
14
+ `).trimStart();return S(Q,V),!0}function d(Q,Z,$){let J=P(Q,Z);HQ(J,{recursive:!0});let Y=P(J,"SKILL.md");return S(Y,$),Y}function f(Q,Z){return g(P(Q,Z,"SKILL.md"))}function t(Q,Z){let $=P(Q,Z);if(!g($))return!1;return EZ($,{recursive:!0,force:!0}),!0}var v,IQ="/Applications/Beacon.app/Contents/Resources/bin/beacon",h=`## 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 s=w(()=>{N=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var z1=1500,X1=480000,U1=1800000,t=3600000,W1=3000;var SQ=()=>{};var xQ={};zQ(xQ,{stripAgentsPointer:()=>cQ,repoMcpCliTarget:()=>dZ,removeRepoAssets:()=>tZ,installRefreshSkill:()=>_Z,installPlanSkill:()=>SZ,installInitSkill:()=>LZ,installExplainSkill:()=>hZ,installCodexRepoSkills:()=>mZ,ensureWorkflowDoc:()=>cZ,ensureMcp:()=>lZ,contextDocTargets:()=>GQ,auditRepo:()=>sZ,REFRESH_SKILL:()=>HQ,PLAN_SKILL:()=>pQ,INIT_SKILL:()=>WQ,EXPLAIN_SKILL:()=>mQ});import{existsSync as j,mkdirSync as I,readFileSync as G,rmSync as n,writeFileSync as H}from"fs";import{join as X}from"path";function LZ(Q){let Z=X(Q,".claude","skills","beacon-init");I(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,WQ),$}function _Z(Q){let Z=X(Q,".claude","skills","beacon-refresh");I(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,HQ),$}function SZ(Q){let Z=X(Q,".claude","skills","beacon-plan");I(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,pQ),$}function hZ(Q){let Z=X(Q,".claude","skills","beacon-explain");I(Z,{recursive:!0});let $=X(Z,"SKILL.md");return H($,mQ),$}function mZ(Q){let Z=[];for(let $ of pZ){let J=X(Q,".agents","skills",$.name);I(J,{recursive:!0});let Y=X(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function GQ(Q){let Z=X(Q,"AGENTS.md"),$=X(Q,"CLAUDE.md"),J=j(Z),Y=j($);if(!J&&!Y)return[Z,$];let V=[];if(J)V.push(Z);if(Y)V.push($);return V}function cQ(Q){let Z=X(Q,"CLAUDE.md");if(!j(Z))return;let $=G(Z,"utf8"),J=$.split(`
38
+ verbatim. Do NOT implement until the tool returns approval.`;var r=R(()=>{v=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var U1=1500,W1=480000,H1=1800000,a=3600000,j1=3000;var mQ=()=>{};var vQ={};WQ(vQ,{stripAgentsPointer:()=>dQ,repoMcpCliTarget:()=>dZ,removeRepoAssets:()=>rZ,installRefreshSkill:()=>SZ,installPlanSkill:()=>hZ,installInitSkill:()=>_Z,installExplainSkill:()=>pZ,installCodexRepoSkills:()=>cZ,ensureWorkflowDoc:()=>lZ,ensureMcp:()=>sZ,contextDocTargets:()=>PQ,auditRepo:()=>tZ,REFRESH_SKILL:()=>KQ,PLAN_SKILL:()=>lQ,INIT_SKILL:()=>BQ,EXPLAIN_SKILL:()=>sQ});import{existsSync as B,mkdirSync as y,readFileSync as K,rmSync as n,writeFileSync as H}from"fs";import{join as W}from"path";function _Z(Q){let Z=W(Q,".claude","skills","beacon-init");y(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,BQ),$}function SZ(Q){let Z=W(Q,".claude","skills","beacon-refresh");y(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,KQ),$}function hZ(Q){let Z=W(Q,".claude","skills","beacon-plan");y(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,lQ),$}function pZ(Q){let Z=W(Q,".claude","skills","beacon-explain");y(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,sQ),$}function cZ(Q){let Z=[];for(let $ of mZ){let J=W(Q,".agents","skills",$.name);y(J,{recursive:!0});let Y=W(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function PQ(Q){let Z=W(Q,"AGENTS.md"),$=W(Q,"CLAUDE.md"),J=B(Z),Y=B($);if(!J&&!Y)return[Z,$];let V=[];if(J)V.push(Z);if(Y)V.push($);return V}function dQ(Q){let Z=W(Q,"CLAUDE.md");if(!B(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 cZ(Q){let Z=new RegExp(`${r}[\\s\\S]*?${jQ}`);for(let $ of GQ(Q)){let J="";try{J=G($,"utf8")}catch{}J=Z.test(J)?J.replace(Z,hQ):`${J.trim()}
41
+ `)}function lZ(Q){let Z=new RegExp(`${o}[\\s\\S]*?${NQ}`);for(let $ of PQ(Q)){let J="";try{J=K($,"utf8")}catch{}J=Z.test(J)?J.replace(Z,cQ):`${J.trim()}
42
42
 
43
- ${hQ}
43
+ ${cQ}
44
44
  `.trimStart(),H($,J.endsWith(`
45
45
  `)?J:`${J}
46
- `)}cQ(Q)}function lZ(Q){let Z=X(Q,".mcp.json"),$={};try{$=JSON.parse(G(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<t)return J.timeout=t,H(Z,JSON.stringify($,null,2)+`
47
- `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:v(),args:["mcp"],timeout:t},H(Z,JSON.stringify($,null,2)+`
48
- `),{path:Z,added:!0,updated:!1}}function dZ(Q){try{return JSON.parse(G(X(Q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function sZ(Q){let Z=X(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let J=GQ(Q).some((Y)=>{try{return G(Y,"utf8").includes(r)}catch{return!1}});return{repo:Q,mcpRegistered:$,workflowBlock:J,skills:{"beacon-init":j(X(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":j(X(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":j(X(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":j(X(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function tZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let U=X(Q,".claude","skills",z);if(j(U))n(U,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let U=X(Q,".agents","skills",z);if(j(U))n(U,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=X(Q,".mcp.json");try{let z=JSON.parse(G(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)n(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
49
- `)}}catch{}let Y=!1,V=new RegExp(`\\n?${r}[\\s\\S]*?${jQ}\\n?`);for(let z of[X(Q,"AGENTS.md"),X(Q,"CLAUDE.md")])try{let U=G(z,"utf8");if(V.test(U)){let qQ=U.replace(V,`
46
+ `)}dQ(Q)}function sZ(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<a)return J.timeout=a,H(Z,JSON.stringify($,null,2)+`
47
+ `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:M(),args:["mcp"],timeout:a},H(Z,JSON.stringify($,null,2)+`
48
+ `),{path:Z,added:!0,updated:!1}}function dZ(Q){try{return JSON.parse(K(W(Q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function tZ(Q){let Z=W(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(K(Z,"utf8")).mcpServers?.beacon}catch{}let J=PQ(Q).some((Y)=>{try{return K(Y,"utf8").includes(o)}catch{return!1}});return{repo:Q,mcpRegistered:$,workflowBlock:J,skills:{"beacon-init":B(W(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":B(W(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":B(W(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":B(W(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function rZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let U=W(Q,".claude","skills",z);if(B(U))n(U,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let U=W(Q,".agents","skills",z);if(B(U))n(U,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=W(Q,".mcp.json");try{let z=JSON.parse(K(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)n(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
49
+ `)}}catch{}let Y=!1,V=new RegExp(`\\n?${o}[\\s\\S]*?${NQ}\\n?`);for(let z of[W(Q,"AGENTS.md"),W(Q,"CLAUDE.md")])try{let U=K(z,"utf8");if(V.test(U)){let j=U.replace(V,`
50
50
  `).replace(/\n{3,}/g,`
51
51
 
52
- `).trimStart();H(z,qQ.endsWith(`
53
- `)?qQ:`${qQ}
54
- `),Y=!0}}catch{}let q=!1,W=X(Q,"CLAUDE.md");try{let z=G(W,"utf8"),U=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(U!==z){if(!U.trim())n(W,{force:!0});else H(W,U);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var WQ=`---
52
+ `).trimStart();H(z,j.endsWith(`
53
+ `)?j:`${j}
54
+ `),Y=!0}}catch{}let q=!1,X=W(Q,"CLAUDE.md");try{let z=K(X,"utf8"),U=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(U!==z){if(!U.trim())n(X,{force:!0});else H(X,U);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var BQ=`---
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
- `,HQ=`---
101
+ `,KQ=`---
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
- `,pQ=`---
148
+ `,lQ=`---
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
- `,mQ=`---
197
+ `,sQ=`---
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
- `,pZ,r="<!-- beacon:workflow:start -->",jQ="<!-- beacon:workflow:end -->",hQ;var BQ=w(()=>{s();SQ();pZ=[{name:"beacon-init",body:()=>WQ},{name:"beacon-refresh",body:()=>HQ}];hQ=`${r}
267
+ `,mZ,o="<!-- beacon:workflow:start -->",NQ="<!-- beacon:workflow:end -->",cQ;var MQ=R(()=>{r();mQ();mZ=[{name:"beacon-init",body:()=>BQ},{name:"beacon-refresh",body:()=>KQ}];cQ=`${o}
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,19 +336,21 @@ 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
- ${jQ}`});import{mkdirSync as nZ,renameSync as rZ,rmSync as aZ,writeFileSync as oZ}from"fs";import{dirname as iZ}from"path";function a(Q,Z){nZ(iZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{oZ($,Z),rZ($,Q)}catch(J){throw aZ($,{force:!0}),J}}function P1(Q,Z,$=!1){a(Q,JSON.stringify(Z,null,$?2:void 0))}var lQ=()=>{};var ZZ={};zQ(ZZ,{setupCodexAssets:()=>z0,removeCodexMcp:()=>QZ,removeCodexArtifacts:()=>U0,parseTomlBeacon:()=>iQ,nodeWhich:()=>tQ,hasCodexMcp:()=>vQ,ensureCodexMcp:()=>eQ,commandExists:()=>nQ,codexMcpProblem:()=>V0,codexMcpCliTarget:()=>q0,codexDetected:()=>rQ,auditCodex:()=>X0,CODEX_HOOKS:()=>QQ});import{accessSync as eZ,constants as Q0,readFileSync as D}from"fs";import{homedir as Z0}from"os";import{delimiter as $0,join as C}from"path";function dQ(){return process.env.HOME||process.env.USERPROFILE||Z0()}function tQ(Q,Z=process.env.PATH||"",$=J0){if(!Q)return null;for(let J of Z.split($0)){if(!J)continue;let Y=C(J,Q);if($(Y))return Y}return null}function J0(Q){try{return eZ(Q,Q0.X_OK),!0}catch{return!1}}function nQ(Q){if(typeof Bun<"u"&&typeof Bun.which==="function")return Bun.which(Q)!==null;return tQ(Q)!==null}function rQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(KQ===void 0)KQ=nQ("codex");return KQ}function iQ(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 q=/^command\s*=\s*["']([^"']*)["']/.exec(Y);if(q)Z.mcp_servers.beacon.command=q[1]}}return Z}function F(Q){try{if(typeof Bun<"u"&&Bun.TOML?.parse)return Bun.TOML.parse(Q);return iQ(Q)}catch{return null}}function vQ(){try{return Boolean(F(D(M(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function V0(){let Q="";try{Q=D(M(),"utf8")}catch{return null}let Z=F(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${A}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${A}`;return null}function eQ(){let Q="",Z=!1;try{Q=D(M(),"utf8"),Z=!0}catch{}if(Z){let V=F(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${A}`};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 ${A}`}}let $=!Q?"":Q.endsWith(`
339
+ ${NQ}`});import{mkdirSync as aZ,renameSync as nZ,rmSync as oZ,writeFileSync as iZ}from"fs";import{dirname as eZ}from"path";function b(Q,Z){aZ(eZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{iZ($,Z),nZ($,Q)}catch(J){throw oZ($,{force:!0}),J}}function u1(Q,Z,$=!1){b(Q,JSON.stringify(Z,null,$?2:void 0))}var tQ=()=>{};var $Z={};WQ($Z,{setupCodexAssets:()=>U0,removeCodexMcp:()=>ZZ,removeCodexArtifacts:()=>H0,parseTomlBeacon:()=>eQ,nodeWhich:()=>nQ,hasCodexMcp:()=>xQ,ensureCodexMcp:()=>QZ,commandExists:()=>oQ,codexMcpProblem:()=>q0,codexMcpCliTarget:()=>X0,codexDetected:()=>iQ,auditCodex:()=>W0,CODEX_HOOKS:()=>YQ});import{accessSync as Q0,constants as Z0,readFileSync as I}from"fs";import{homedir as $0}from"os";import{delimiter as J0,join as T}from"path";function rQ(){return process.env.HOME||process.env.USERPROFILE||$0()}function nQ(Q,Z=process.env.PATH||"",$=Y0){if(!Q)return null;for(let J of Z.split(J0)){if(!J)continue;let Y=T(J,Q);if($(Y))return Y}return null}function Y0(Q){try{return Q0(Q,Z0.X_OK),!0}catch{return!1}}function oQ(Q){if(typeof Bun<"u"&&typeof Bun.which==="function")return Bun.which(Q)!==null;return nQ(Q)!==null}function iQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(uQ===void 0)uQ=oQ("codex");return uQ}function eQ(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 q=/^command\s*=\s*["']([^"']*)["']/.exec(Y);if(q)Z.mcp_servers.beacon.command=q[1]}}return Z}function C(Q){try{if(typeof Bun<"u"&&Bun.TOML?.parse)return Bun.TOML.parse(Q);return eQ(Q)}catch{return null}}function xQ(){try{return Boolean(C(I(u(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function q0(){let Q="";try{Q=I(u(),"utf8")}catch{return null}let Z=C(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${E}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${E}`;return null}function z0(Q){let Z=Q.split(`
341
+ `),$=Z.indexOf($Q),J=Z.indexOf(JQ,$);if($===-1||J===-1)return null;let Y=Z.findIndex((X,z)=>z>$&&z<J&&X.trim()==="[mcp_servers.beacon]");if(Y===-1)return null;let V=Y+1;while(V<J&&!/^\s*\[/.test(Z[V]))V++;let q=Z.findIndex((X,z)=>z>Y&&z<V&&/^\s*command\s*=/.test(X));if(q===-1)return null;return Z[q]=`command = ${JSON.stringify(M())}`,Z.join(`
342
+ `)}function QZ(){let Q="",Z=!1;try{Q=I(u(),"utf8"),Z=!0}catch{}if(Z){let V=C(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${E}`};if(V.mcp_servers?.beacon){let q=z0(Q);if(q&&q!==Q)b(u(),q);return{added:!1}}if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${E}`}}let $=!Q?"":Q.endsWith(`
341
343
  `)?`
342
344
  `:`
343
345
 
344
- `,J=Q+$+Y0();if(F(J)?.mcp_servers?.beacon?.command!==v())return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${A}`};return a(M(),J),{added:!0}}function q0(){try{return F(D(M(),"utf8"))?.mcp_servers?.beacon?.command??null}catch{return null}}function QZ(){let Q="";try{Q=D(M(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
345
- `),$=Z.indexOf(aQ);if($===-1)return{removed:!1,skipped:vQ()};let J=Z.indexOf(oQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
346
+ `,J=Q+$+V0();if(C(J)?.mcp_servers?.beacon?.command!==M())return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${E}`};return b(u(),J),{added:!0}}function X0(){try{return C(I(u(),"utf8"))?.mcp_servers?.beacon?.command??null}catch{return null}}function ZZ(){let Q="";try{Q=I(u(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
347
+ `),$=Z.indexOf($Q);if($===-1)return{removed:!1,skipped:xQ()};let J=Z.indexOf(JQ,$);if(J===-1)return{removed:!1,skipped:!0};let Y=Z.findIndex((X,z)=>z>$&&z<J&&X.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(JQ),1),Z.splice(Z.indexOf($Q),1);let q=Z.join(`
346
348
  `).replace(/\n{3,}/g,`
347
349
 
348
- `).replace(/^\n+/,"");if(F(Y)===null)return{removed:!1,skipped:!0};return a(M(),Y),{removed:!0}}async function z0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (BQ(),xQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let U of N){if(!O(i(),U))V.push(U);l(i(),U,Y[U])}let q=0;for(let U of QQ)if(S(PQ(),{event:U.event,matcher:U.matcher,command:k(U.command)}))q++;let W=g(o(),e);m(o(),e,sQ,L);let z=eQ();return{skillsAdded:V,hooksAdded:q,agentsMdBlockTouched:!W,mcp:z}}function X0(){let Q={};for(let $ of N)Q[$]=O(i(),$);let Z={};for(let $ of QQ)Z[$.event]=h(PQ(),{event:$.event,command:$.command});return{detected:rQ(),skills:Q,hooks:Z,agentsMdBlock:g(o(),e),mcp:vQ()}}function U0(){let Q=[];for(let Y of N)if(d(i(),Y))Q.push(Y);let Z=0;for(let Y of QQ)if(p(PQ(),{event:Y.event,command:Y.command}))Z++;let $=c(o(),e,sQ),J=QZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var NQ=()=>C(dQ(),".codex"),PQ=()=>C(NQ(),"hooks.json"),M=()=>C(NQ(),"config.toml"),o=()=>C(NQ(),"AGENTS.md"),i=()=>C(dQ(),".agents","skills"),e="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->",QQ,KQ,aQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",oQ="# beacon:end",Y0=()=>`${aQ}
350
+ `).replace(/^\n+/,"");if(C(q)===null)return{removed:!1,skipped:!0};return b(u(),q),{removed:!0}}async function U0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (MQ(),vQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let U of v){if(!f(QQ(),U))V.push(U);d(QQ(),U,Y[U])}let q=0;for(let U of YQ){let j=U.event==="UserPromptSubmit"||U.event==="Stop";if(j)hQ(i(),{event:U.event,matcher:U.matcher,command:O(U.command)});if(p(i(),{event:U.event,matcher:U.matcher,command:O(U.command)},{matchAnyMatcher:j}))q++}let X=D(e(),ZQ);l(e(),ZQ,aQ,h);let z=QZ();return{skillsAdded:V,hooksAdded:q,agentsMdBlockTouched:!X,mcp:z}}function W0(){let Q={};for(let $ of v)Q[$]=f(QQ(),$);let Z={};for(let $ of YQ)Z[$.event]=m(i(),{event:$.event,command:$.command});return{detected:iQ(),skills:Q,hooks:Z,agentsMdBlock:D(e(),ZQ),mcp:xQ()}}function H0(){let Q=[];for(let Y of v)if(t(QQ(),Y))Q.push(Y);let Z=0;for(let Y of YQ)if(c(i(),{event:Y.event,command:Y.command}))Z++;let $=s(e(),ZQ,aQ),J=ZZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var wQ=()=>T(rQ(),".codex"),i=()=>T(wQ(),"hooks.json"),u=()=>T(wQ(),"config.toml"),e=()=>T(wQ(),"AGENTS.md"),QQ=()=>T(rQ(),".agents","skills"),ZQ="<!-- beacon:global:start -->",aQ="<!-- beacon:global:end -->",YQ,uQ,$Q="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",JQ="# beacon:end",V0=()=>`${$Q}
349
351
  [mcp_servers.beacon]
350
- command = "${v()}"
352
+ command = "${M()}"
351
353
  args = ["mcp"]
352
- ${oQ}
353
- `,A="add it manually: codex mcp add beacon -- beacon mcp";var $Z=w(()=>{s();lQ();QQ=[{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 XZ={};zQ(XZ,{provisionDb:()=>E0});import{createClient as R0}from"@libsql/client";import{drizzle as F0}from"drizzle-orm/libsql";import{migrate as C0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as T0}from"drizzle-orm/migrator";import{dirname as FQ,join as g0}from"path";import{fileURLToPath as O0}from"url";async function YQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function b0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function zZ(Q){if(!await YQ(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 f0(Q){for(let[Z,$]of Object.entries(D0)){if(!await YQ(Q,Z))continue;let J=await b0(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 E0(Q,Z=A0){let $=R0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await YQ($,"__drizzle_migrations"),Y=await YQ($,"Node"),V=!1;if(Y&&!J){let W=T0({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 q=await zZ($);if(await C0(F0($),{migrationsFolder:Z}),await zZ($)>q)V=!0;return await f0($),{migrated:V}}finally{$.close()}}var I0,A0,D0;var UZ=w(async()=>{I0=FQ(FQ(FQ(O0(import.meta.url)))),A0=process.env.BEACON_MIGRATIONS_DIR||g0(I0,"drizzle"),D0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});s();import{existsSync as W0}from"fs";import{homedir as H0}from"os";import{join as ZQ}from"path";function j0(){return process.env.HOME||process.env.USERPROFILE||H0()}var $Q=()=>ZQ(j0(),".claude"),MQ=()=>ZQ($Q(),"skills"),JQ=()=>ZQ($Q(),"settings.json"),uQ=()=>ZQ($Q(),"CLAUDE.md"),wQ="<!-- beacon:global:start -->",JZ="<!-- beacon:global:end -->";var G0=L,RQ=[{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 l(MQ(),Q,Z)}function YZ(Q){return O(MQ(),Q)}function B0(Q){return d(MQ(),Q)}function K0(Q){return S(JQ(),Q)}function N0(Q){return h(JQ(),Q)}function P0(Q){return p(JQ(),Q)}function v0(Q){m(uQ(),wQ,JZ,Q)}function VZ(){return g(uQ(),wQ)}function M0(){return c(uQ(),wQ,JZ)}function I1(){let Q={};for(let $ of N)Q[$]=YZ($);let Z={};for(let $ of RQ)Z[$.event]=N0({event:$.event,command:$.command});return{homeExists:W0($Q()),skills:Q,hooks:Z,claudeMdBlock:VZ()}}function A1(){let Q=_Q(JQ(),{event:"PostToolUse",command:"beacon hook"});return Q?UQ(Q):null}async function u0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (BQ(),xQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let z of N){if(!YZ(z))V.push(z);x0(z,Y[z])}let q=0;for(let z of RQ)if(K0({event:z.event,matcher:z.matcher,command:k(z.command)}))q++;let W=VZ();return v0(G0),{skillsAdded:V,hooksAdded:q,claudeMdBlockTouched:!W}}async function qZ(){if(EQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(kQ()){try{w0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await u0()}}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(() => ($Z(),ZZ));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 w0(){let Q=[];for(let J of N)if(B0(J))Q.push(J);let Z=0;for(let J of RQ)if(P0(J))Z++;let $=M0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as y0}from"async_hooks";import{spawnSync as k0}from"child_process";import{createHash as L0}from"crypto";import{existsSync as HZ,mkdirSync as f,readFileSync as TQ,writeFileSync as gQ}from"fs";import{homedir as jZ}from"os";import{basename as _0,join as P,parse as S0,resolve as WZ}from"path";function x(){return process.env.BEACON_HOME||P(jZ(),".beacon")}function OQ(){return P(x(),"workspaces.json")}function b(Q){return L0("sha256").update(Q).digest("hex").slice(0,12)}function h0(Q=process.cwd()){let Z=k0("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=WZ(Q);return Z!==WZ(jZ())&&Z!==S0(Z).root}function xZ(){return P(x(),"deleted.json")}function IQ(){try{let Q=JSON.parse(TQ(xZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function BZ(Q){f(x(),{recursive:!0}),gQ(xZ(),JSON.stringify(Q,null,2))}function KZ(Q){return IQ().includes(Q)}function l1(Q){let Z=IQ();if(!Z.includes(Q))BZ([...Z,Q])}function p0(Q){let Z=IQ();if(Z.includes(Q))BZ(Z.filter(($)=>$!==Q))}function VQ(Q){return P(x(),Q)}function m0(Q){return`file:${P(VQ(Q),"db.sqlite")}`}function E(){try{let Q=JSON.parse(TQ(OQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function AQ(Q){f(x(),{recursive:!0}),gQ(OQ(),JSON.stringify(Q,null,2))}function NZ(){return E().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function u(Q){return E().find((Z)=>Z.id===Q)??null}function PZ(Q,Z,$=new Date().toISOString()){if(!GZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=b(Q);if(KZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=E(),V=Y.find((z)=>z.id===J),q={id:J,path:Q,name:Z||V?.name||_0(Q),lastOpenedAt:$},W=[q,...Y.filter((z)=>z.id!==J)];return f(VQ(J),{recursive:!0}),AQ(W),q}function d1(Q,Z){return p0(b(Q)),PZ(Q,Z)}function s1(Q,Z=new Date().toISOString()){let $=E(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,AQ($)}function t1(Q){if(AQ(E().filter((Z)=>Z.id!==Q)),DQ()===Q)c0(NZ()[0]?.id??null)}function vZ(){return P(x(),"active")}function DQ(){try{return TQ(vZ(),"utf8").trim()||null}catch{return null}}function c0(Q){f(x(),{recursive:!0}),gQ(vZ(),Q??"")}function n1(){let Q=DQ();return Q?u(Q):null}function r1(){let Q=d0()??DQ();return Q?u(Q):null}function a1(Q){return u(Q)?.path??null}function o1(){return HZ(OQ())}var MZ="beacon_ws";function uZ(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 i1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=uZ(Q,MZ);if($&&u($))return $;return l0()}function l0(){let Q=NZ();return Q.length===1?Q[0].id:null}var wZ="x-beacon-workspace-path";function RZ(Q=process.cwd()){let Z=h0(Q);return{"x-beacon-workspace":b(Z),[wZ]:Z}}async function e1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=Q.headers.get(wZ);if($&&GZ($)&&!KZ(b($))&&(!Z||b($)===Z)){let Y=PZ($);return await s0(Y.id),Y.id}let J=uZ(Q,MZ);if(J&&u(J))return J;return null}var FZ=new y0;function Q2(Q,Z){return Q?FZ.run(Q,Z):Z()}function d0(){return FZ.getStore()??null}var CQ=new Set;function Z2(Q){CQ.delete(P(VQ(Q),"db.sqlite"))}async function s0(Q){let Z=VQ(Q),$=P(Z,"db.sqlite"),J=HZ($);if(J&&CQ.has($))return{ok:!0,created:!1,migrated:!1};try{f(Z,{recursive:!0});let{provisionDb:Y}=await UZ().then(() => XZ),V=await Y(m0(Q));return CQ.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)}}}import{connect as t0}from"net";var CZ=4319;function n0(Q,Z,$=400){return new Promise((J)=>{let Y=t0({host:Q,port:Z}),V=!1,q=(W)=>{if(V)return;V=!0,Y.destroy(),J(W)};Y.once("connect",()=>q(!0)),Y.once("error",()=>q(!1)),Y.setTimeout($,()=>q(!1))})}async function r0(Q){for(let Z of["127.0.0.1","::1"])if(await n0(Z,Q))return!1;return!0}async function Y2(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await r0($))return $;return Q}import{resolve as a0}from"path";var o0="*** Begin Patch",i0=/^\*\*\* (Update File|Add File|Move to): (.+)$/;function e0(Q){let Z=[];for(let $ of Q.split(`
354
- `)){let J=i0.exec($.trim());if(!J)continue;let Y=J[2].trim();if(J[1]==="Move to")Z.pop();Z.push(Y)}return Z}function TZ(Q){let Z=Q.tool_input;if(Z===null||typeof Z!=="object")return[];let $=Z,J=[];if(typeof $.file_path==="string")J.push($.file_path);if(typeof $.path==="string")J.push($.path);if(Array.isArray($.files))for(let V of $.files){let q=V?.file_path;if(typeof q==="string")J.push(q)}if(J.length)return J;let Y=typeof Q.cwd==="string"?Q.cwd:process.cwd();for(let V of Object.values($)){if(typeof V!=="string"||!V.includes(o0))continue;return e0(V).map((q)=>a0(Y,q))}return[]}import{readFileSync as Q1}from"fs";import{join as Z1}from"path";function $1(){try{return JSON.parse(Q1(Z1(x(),"server.json"),"utf8"))}catch{return null}}function gZ(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${$1()?.port||process.env.PORT||CZ}`}await qZ();var OZ="";for await(let Q of process.stdin)OZ+=Q;try{let Q=JSON.parse(OZ||"{}"),Z=TZ(Q);if(Z.length)await fetch(`${gZ()}/api/map/touch-active`,{method:"POST",headers:{"content-type":"application/json",...RZ(typeof Q.cwd==="string"?Q.cwd:void 0)},body:JSON.stringify({files:Z,session:typeof Q.session_id==="string"?Q.session_id:void 0})}).catch(()=>{})}catch{}process.exit(0);
354
+ ${JQ}
355
+ `,E="add it manually: codex mcp add beacon -- beacon mcp";var JZ=R(()=>{r();tQ();YQ=[{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 UZ={};WQ(UZ,{provisionDb:()=>L0});import{createClient as C0}from"@libsql/client";import{drizzle as T0}from"drizzle-orm/libsql";import{migrate as g0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as O0}from"drizzle-orm/migrator";import{dirname as gQ,join as A0}from"path";import{fileURLToPath as D0}from"url";async function XQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function E0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function XZ(Q){if(!await XQ(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 I0(Q){for(let[Z,$]of Object.entries(b0)){if(!await XQ(Q,Z))continue;let J=await E0(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 L0(Q,Z=y0){let $=C0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await XQ($,"__drizzle_migrations"),Y=await XQ($,"Node"),V=!1;if(Y&&!J){let X=O0({migrationsFolder:Z})[0];if(X)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:[X.hash,X.folderMillis]}),V=!0}let q=await XZ($);if(await g0(T0($),{migrationsFolder:Z}),await XZ($)>q)V=!0;return await I0($),{migrated:V}}finally{$.close()}}var f0,y0,b0;var WZ=R(async()=>{f0=gQ(gQ(gQ(D0(import.meta.url)))),y0=process.env.BEACON_MIGRATIONS_DIR||A0(f0,"drizzle"),b0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});r();import{existsSync as j0}from"fs";import{homedir as G0}from"os";import{join as VQ}from"path";function B0(){return process.env.HOME||process.env.USERPROFILE||G0()}var qQ=()=>VQ(B0(),".claude"),RQ=()=>VQ(qQ(),"skills"),zQ=()=>VQ(qQ(),"settings.json"),FQ=()=>VQ(qQ(),"CLAUDE.md"),CQ="<!-- beacon:global:start -->",YZ="<!-- beacon:global:end -->";var K0=h,TQ=[{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 N0(Q,Z){return d(RQ(),Q,Z)}function VZ(Q){return f(RQ(),Q)}function P0(Q){return t(RQ(),Q)}function v0(Q){return p(zQ(),Q)}function M0(Q){return m(zQ(),Q)}function u0(Q){return c(zQ(),Q)}function w0(Q){l(FQ(),CQ,YZ,Q)}function qZ(){return D(FQ(),CQ)}function x0(){return s(FQ(),CQ,YZ)}function f1(){let Q={};for(let $ of v)Q[$]=VZ($);let Z={};for(let $ of TQ)Z[$.event]=M0({event:$.event,command:$.command});return{homeExists:j0(qQ()),skills:Q,hooks:Z,claudeMdBlock:qZ()}}function y1(){let Q=pQ(zQ(),{event:"PostToolUse",command:"beacon hook"});return Q?jQ(Q):null}async function R0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (MQ(),vQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let z of v){if(!VZ(z))V.push(z);N0(z,Y[z])}let q=0;for(let z of TQ)if(v0({event:z.event,matcher:z.matcher,command:O(z.command)}))q++;let X=qZ();return w0(K0),{skillsAdded:V,hooksAdded:q,claudeMdBlockTouched:!X}}async function zZ(){if(kQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(SQ()){try{F0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await R0()}}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(() => (JZ(),$Z));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 F0(){let Q=[];for(let J of v)if(P0(J))Q.push(J);let Z=0;for(let J of TQ)if(u0(J))Z++;let $=x0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as k0}from"async_hooks";import{spawnSync as _0}from"child_process";import{createHash as S0}from"crypto";import{existsSync as jZ,mkdirSync as k,readFileSync as AQ,writeFileSync as DQ}from"fs";import{homedir as GZ}from"os";import{basename as h0,join as w,parse as p0,resolve as HZ}from"path";function N(){return process.env.BEACON_HOME||w(GZ(),".beacon")}function fQ(){return w(N(),"workspaces.json")}function L(Q){return S0("sha256").update(Q).digest("hex").slice(0,12)}function m0(Q=process.cwd()){let Z=_0("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 BZ(Q){let Z=HZ(Q);return Z!==HZ(GZ())&&Z!==p0(Z).root}function KZ(){return w(N(),"deleted.json")}function yQ(){try{let Q=JSON.parse(AQ(KZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function NZ(Q){k(N(),{recursive:!0}),DQ(KZ(),JSON.stringify(Q,null,2))}function PZ(Q){return yQ().includes(Q)}function d1(Q){let Z=yQ();if(!Z.includes(Q))NZ([...Z,Q])}function c0(Q){let Z=yQ();if(Z.includes(Q))NZ(Z.filter(($)=>$!==Q))}function UQ(Q){return w(N(),Q)}function l0(Q){return`file:${w(UQ(Q),"db.sqlite")}`}function _(){try{let Q=JSON.parse(AQ(fQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function bQ(Q){k(N(),{recursive:!0}),DQ(fQ(),JSON.stringify(Q,null,2))}function vZ(){return _().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function x(Q){return _().find((Z)=>Z.id===Q)??null}function MZ(Q,Z,$=new Date().toISOString()){if(!BZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=L(Q);if(PZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=_(),V=Y.find((z)=>z.id===J),q={id:J,path:Q,name:Z||V?.name||h0(Q),lastOpenedAt:$},X=[q,...Y.filter((z)=>z.id!==J)];return k(UQ(J),{recursive:!0}),bQ(X),q}function t1(Q,Z){return c0(L(Q)),MZ(Q,Z)}function r1(Q,Z=new Date().toISOString()){let $=_(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,bQ($)}function a1(Q){if(bQ(_().filter((Z)=>Z.id!==Q)),EQ()===Q)s0(vZ()[0]?.id??null)}function uZ(){return w(N(),"active")}function EQ(){try{return AQ(uZ(),"utf8").trim()||null}catch{return null}}function s0(Q){k(N(),{recursive:!0}),DQ(uZ(),Q??"")}function n1(){let Q=EQ();return Q?x(Q):null}function o1(){let Q=t0()??EQ();return Q?x(Q):null}function i1(Q){return x(Q)?.path??null}function e1(){return jZ(fQ())}var wZ="beacon_ws";function xZ(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&&x(Z))return Z;let $=xZ(Q,wZ);if($&&x($))return $;return d0()}function d0(){let Q=vZ();return Q.length===1?Q[0].id:null}var RZ="x-beacon-workspace-path";function FZ(Q=process.cwd()){let Z=m0(Q);return{"x-beacon-workspace":L(Z),[RZ]:Z}}async function Z2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&x(Z))return Z;let $=Q.headers.get(RZ);if($&&BZ($)&&!PZ(L($))&&(!Z||L($)===Z)){let Y=MZ($);return await r0(Y.id),Y.id}let J=xZ(Q,wZ);if(J&&x(J))return J;return null}var CZ=new k0;function $2(Q,Z){return Q?CZ.run(Q,Z):Z()}function t0(){return CZ.getStore()??null}var OQ=new Set;function J2(Q){OQ.delete(w(UQ(Q),"db.sqlite"))}async function r0(Q){let Z=UQ(Q),$=w(Z,"db.sqlite"),J=jZ($);if(J&&OQ.has($))return{ok:!0,created:!1,migrated:!1};try{k(Z,{recursive:!0});let{provisionDb:Y}=await WZ().then(() => UZ),V=await Y(l0(Q));return OQ.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)}}}import{connect as a0}from"net";var TZ=4319;function n0(Q,Z,$=400){return new Promise((J)=>{let Y=a0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,Y.destroy(),J(X)};Y.once("connect",()=>q(!0)),Y.once("error",()=>q(!1)),Y.setTimeout($,()=>q(!1))})}async function o0(Q){for(let Z of["127.0.0.1","::1"])if(await n0(Z,Q))return!1;return!0}async function q2(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await o0($))return $;return Q}import{resolve as i0}from"path";var e0="*** Begin Patch",Q1=/^\*\*\* (Update File|Add File|Move to): (.+)$/;function Z1(Q){let Z=[];for(let $ of Q.split(`
356
+ `)){let J=Q1.exec($.trim());if(!J)continue;let Y=J[2].trim();if(J[1]==="Move to")Z.pop();Z.push(Y)}return Z}function gZ(Q){let Z=Q.tool_input;if(Z===null||typeof Z!=="object")return[];let $=Z,J=[];if(typeof $.file_path==="string")J.push($.file_path);if(typeof $.path==="string")J.push($.path);if(Array.isArray($.files))for(let V of $.files){let q=V?.file_path;if(typeof q==="string")J.push(q)}if(J.length)return J;let Y=typeof Q.cwd==="string"?Q.cwd:process.cwd();for(let V of Object.values($)){if(typeof V!=="string"||!V.includes(e0))continue;return Z1(V).map((q)=>i0(Y,q))}return[]}import{readFileSync as $1}from"fs";import{join as J1}from"path";function Y1(){try{return JSON.parse($1(J1(N(),"server.json"),"utf8"))}catch{return null}}function OZ(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${Y1()?.port||process.env.PORT||TZ}`}await zZ();var AZ="";for await(let Q of process.stdin)AZ+=Q;try{let Q=JSON.parse(AZ||"{}"),Z=gZ(Q);if(Z.length)await fetch(`${OZ()}/api/map/touch-active`,{method:"POST",headers:{"content-type":"application/json",...FZ(typeof Q.cwd==="string"?Q.cwd:void 0)},signal:AbortSignal.timeout(2500),body:JSON.stringify({files:Z,session:typeof Q.session_id==="string"?Q.session_id:void 0})}).catch(()=>{})}catch{}process.exit(0);