trybeacon 0.1.63 → 0.1.64

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 (113) hide show
  1. package/.claude-plugin/plugin.json +19 -0
  2. package/.next/BUILD_ID +1 -1
  3. package/.next/app-path-routes-manifest.json +13 -13
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +3 -3
  6. package/.next/required-server-files.js +1 -1
  7. package/.next/required-server-files.json +1 -1
  8. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/_global-error.html +1 -1
  10. package/.next/server/app/_global-error.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/_not-found.html +1 -1
  19. package/.next/server/app/_not-found.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  21. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  23. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  26. package/.next/server/app/api/share/create/route.js +1 -1
  27. package/.next/server/app/api/share/route.js +1 -1
  28. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app/docs.html +1 -1
  30. package/.next/server/app/docs.rsc +3 -3
  31. package/.next/server/app/docs.segments/_full.segment.rsc +3 -3
  32. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  33. package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
  34. package/.next/server/app/docs.segments/_tree.segment.rsc +3 -3
  35. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +2 -2
  36. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  37. package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
  38. package/.next/server/app/feedback.html +1 -1
  39. package/.next/server/app/feedback.rsc +2 -2
  40. package/.next/server/app/feedback.segments/_full.segment.rsc +2 -2
  41. package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
  42. package/.next/server/app/feedback.segments/_index.segment.rsc +2 -2
  43. package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
  44. package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
  45. package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
  46. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app/help.html +1 -1
  48. package/.next/server/app/help.rsc +2 -2
  49. package/.next/server/app/help.segments/_full.segment.rsc +2 -2
  50. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  51. package/.next/server/app/help.segments/_index.segment.rsc +2 -2
  52. package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
  53. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
  54. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  55. package/.next/server/app/index.html +1 -1
  56. package/.next/server/app/index.rsc +4 -4
  57. package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  58. package/.next/server/app/index.segments/_full.segment.rsc +4 -4
  59. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  60. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  61. package/.next/server/app/index.segments/_tree.segment.rsc +3 -3
  62. package/.next/server/app/map/page.js +1 -1
  63. package/.next/server/app/map/page.js.nft.json +1 -1
  64. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/page.js +1 -1
  66. package/.next/server/app/page_client-reference-manifest.js +1 -1
  67. package/.next/server/app/plan/page.js +2 -2
  68. package/.next/server/app/plan/page.js.nft.json +1 -1
  69. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  70. package/.next/server/app/s/[token]/page.js +1 -1
  71. package/.next/server/app/s/[token]/page.js.nft.json +1 -1
  72. package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  74. package/.next/server/app-paths-manifest.json +13 -13
  75. package/.next/server/chunks/{2343.js → 4384.js} +1 -1
  76. package/.next/server/middleware-build-manifest.js +1 -1
  77. package/.next/server/pages/404.html +1 -1
  78. package/.next/server/pages/500.html +1 -1
  79. package/.next/server/server-reference-manifest.js +1 -1
  80. package/.next/server/server-reference-manifest.json +1 -1
  81. package/.next/static/chunks/3415-05007c2bd98125c7.js +1 -0
  82. package/.next/static/chunks/app/map/{page-af4a5a1f12413f4d.js → page-491d4767dbc4e954.js} +1 -1
  83. package/.next/static/chunks/app/{page-6f46e6682942af3a.js → page-d08947a671077569.js} +1 -1
  84. package/.next/static/chunks/app/plan/{page-6213cdfdbee97ad6.js → page-a90e0981499546e3.js} +1 -1
  85. package/.next/static/chunks/app/s/[token]/{page-5c21314106b5ae91.js → page-5c8f260e75758b02.js} +1 -1
  86. package/.next/static/css/490566ec68a48e1a.css +1 -0
  87. package/.next/static/css/53e84df868515cf7.css +1 -0
  88. package/.next/trace +42 -42
  89. package/.next/trace-build +1 -1
  90. package/LICENSE +201 -0
  91. package/README.md +39 -8
  92. package/bun.lock +2274 -0
  93. package/dist/bin/beacon.js +14 -14
  94. package/dist/bin/boot.js +4 -0
  95. package/dist/bin/doctor.js +28 -28
  96. package/dist/bin/hook.js +24 -24
  97. package/dist/bin/mcp.js +30 -30
  98. package/dist/bin/plan.js +25 -25
  99. package/dist/bin/uninstall.js +27 -27
  100. package/dist/lib/codex-install.js +25 -25
  101. package/dist/lib/global-install.js +24 -24
  102. package/package.json +16 -3
  103. package/plugin/commands/beacon.md +11 -0
  104. package/plugin/hooks.json +70 -0
  105. package/plugin/mcp.json +10 -0
  106. package/plugin/skills/beacon-init/SKILL.md +47 -0
  107. package/plugin/skills/beacon-plan/SKILL.md +48 -0
  108. package/plugin/skills/beacon-refresh/SKILL.md +47 -0
  109. package/.next/static/chunks/5780-fd253c7329871c77.js +0 -1
  110. package/.next/static/css/e63457bec0b3ee27.css +0 -1
  111. package/.next/static/css/f86b3e50f4e93bc8.css +0 -1
  112. /package/.next/static/{kt65bLHd8wfwQxMb3ivew → qoq7TibU72duRZATxeVnT}/_buildManifest.js +0 -0
  113. /package/.next/static/{kt65bLHd8wfwQxMb3ivew → qoq7TibU72duRZATxeVnT}/_ssgManifest.js +0 -0
package/dist/bin/plan.js CHANGED
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var uZ=Object.defineProperty;var wZ=(Q)=>Q;function fZ(Q,Z){this[Q]=wZ.bind(null,Z)}var JQ=(Q,Z)=>{for(var $ in Z)uZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:fZ.bind(Z,$)})};var v=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var OQ=1500,yQ=480000,U1=1800000,D=3600000,W1=3000;var VQ=()=>{};var UQ={};JQ(UQ,{removeRepoAssets:()=>kZ,installRefreshSkill:()=>AZ,installPlanSkill:()=>IZ,installInitSkill:()=>DZ,installCodexRepoSkills:()=>bZ,ensureWorkflowDoc:()=>OZ,ensureMcp:()=>yZ,auditRepo:()=>LZ,REFRESH_SKILL:()=>qQ,PLAN_SKILL:()=>kQ,INIT_SKILL:()=>zQ});import{existsSync as C,mkdirSync as I,readFileSync as G,rmSync as A,writeFileSync as B}from"fs";import{join as U}from"path";function DZ(Q){let Z=U(Q,".claude","skills","beacon-init");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,zQ),$}function AZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,qQ),$}function IZ(Q){let Z=U(Q,".claude","skills","beacon-plan");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,kQ),$}function bZ(Q){let Z=[];for(let $ of EZ){let Y=U(Q,".agents","skills",$.name);I(Y,{recursive:!0});let J=U(Y,"SKILL.md");B(J,$.body()),Z.push(J)}return Z}function OZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=G(Z,"utf8")}catch{}let Y=new RegExp(`${E}[\\s\\S]*?${XQ}`);$=Y.test($)?$.replace(Y,LQ):`${$.trim()}
3
+ var AZ=Object.defineProperty;var fZ=(Q)=>Q;function EZ(Q,Z){this[Q]=fZ.bind(null,Z)}var VQ=(Q,Z)=>{for(var $ in Z)AZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:EZ.bind(Z,$)})};var C=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var yQ=1500,LQ=480000,G1=1800000,E=3600000,K1=3000;var zQ=()=>{};var WQ={};VQ(WQ,{removeRepoAssets:()=>hZ,installRefreshSkill:()=>OZ,installPlanSkill:()=>bZ,installInitSkill:()=>IZ,installCodexRepoSkills:()=>LZ,ensureWorkflowDoc:()=>kZ,ensureMcp:()=>_Z,auditRepo:()=>SZ,REFRESH_SKILL:()=>XQ,PLAN_SKILL:()=>_Q,INIT_SKILL:()=>qQ});import{existsSync as M,mkdirSync as O,readFileSync as G,rmSync as I,writeFileSync as B}from"fs";import{join as U}from"path";function IZ(Q){let Z=U(Q,".claude","skills","beacon-init");O(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,qQ),$}function OZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");O(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,XQ),$}function bZ(Q){let Z=U(Q,".claude","skills","beacon-plan");O(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,_Q),$}function LZ(Q){let Z=[];for(let $ of yZ){let Y=U(Q,".agents","skills",$.name);O(Y,{recursive:!0});let J=U(Y,"SKILL.md");B(J,$.body()),Z.push(J)}return Z}function kZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=G(Z,"utf8")}catch{}let Y=new RegExp(`${b}[\\s\\S]*?${UQ}`);$=Y.test($)?$.replace(Y,kQ):`${$.trim()}
4
4
 
5
- ${LQ}
5
+ ${kQ}
6
6
  `.trimStart(),B(Z,$.endsWith(`
7
7
  `)?$:`${$}
8
8
  `);let J=U(Q,"CLAUDE.md"),V="";try{V=G(J,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))B(J,`${V?`${V.trim()}
9
9
 
10
10
  `:""}@AGENTS.md
11
- `)}function yZ(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(G(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let Y=$.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<D)return Y.timeout=D,B(Z,JSON.stringify($,null,2)+`
12
- `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:D},B(Z,JSON.stringify($,null,2)+`
13
- `),{path:Z,added:!0,updated:!1}}function LZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=G(U(Q,"AGENTS.md"),"utf8").includes(E)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(G(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":C(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":C(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":C(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":C(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function kZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(C(W))A(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(C(W))A(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=U(Q,".mcp.json");try{let z=JSON.parse(G(Y,"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)A(Y,{force:!0});else B(Y,JSON.stringify(z,null,2)+`
14
- `)}}catch{}let J=!1,V=U(Q,"AGENTS.md");try{let z=G(V,"utf8"),W=new RegExp(`\\n?${E}[\\s\\S]*?${XQ}\\n?`);if(W.test(z)){let H=z.replace(W,`
11
+ `)}function _Z(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(G(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let Y=$.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<E)return Y.timeout=E,B(Z,JSON.stringify($,null,2)+`
12
+ `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:E},B(Z,JSON.stringify($,null,2)+`
13
+ `),{path:Z,added:!0,updated:!1}}function SZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=G(U(Q,"AGENTS.md"),"utf8").includes(b)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(G(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":M(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":M(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":M(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":M(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function hZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(M(W))I(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(M(W))I(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=U(Q,".mcp.json");try{let z=JSON.parse(G(Y,"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)I(Y,{force:!0});else B(Y,JSON.stringify(z,null,2)+`
14
+ `)}}catch{}let J=!1,V=U(Q,"AGENTS.md");try{let z=G(V,"utf8"),W=new RegExp(`\\n?${b}[\\s\\S]*?${UQ}\\n?`);if(W.test(z)){let H=z.replace(W,`
15
15
  `).replace(/\n{3,}/g,`
16
16
 
17
17
  `).trimStart();B(V,H.endsWith(`
18
18
  `)?H:`${H}
19
- `),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())A(X,{force:!0});else B(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:q}}var zQ=`---
19
+ `),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())I(X,{force:!0});else B(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:q}}var qQ=`---
20
20
  name: beacon-init
21
21
  description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
22
22
  ---
@@ -63,7 +63,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
63
63
  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.
64
64
 
65
65
  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.
66
- `,qQ=`---
66
+ `,XQ=`---
67
67
  name: beacon-refresh
68
68
  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.
69
69
  ---
@@ -110,7 +110,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
110
110
  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.
111
111
 
112
112
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
113
- `,kQ=`---
113
+ `,_Q=`---
114
114
  name: beacon-plan
115
115
  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.
116
116
  ---
@@ -158,7 +158,7 @@ If it returns feedback, revise and call it again.
158
158
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
159
159
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
160
160
  run \`beacon\` in this repo once.
161
- `,EZ,E="<!-- beacon:workflow:start -->",XQ="<!-- beacon:workflow:end -->",LQ;var WQ=v(()=>{VQ();EZ=[{name:"beacon-init",body:()=>zQ},{name:"beacon-refresh",body:()=>qQ}];LQ=`${E}
161
+ `,yZ,b="<!-- beacon:workflow:start -->",UQ="<!-- beacon:workflow:end -->",kQ;var HQ=C(()=>{zQ();yZ=[{name:"beacon-init",body:()=>qQ},{name:"beacon-refresh",body:()=>XQ}];kQ=`${b}
162
162
  ## Beacon \u2014 feature workflow
163
163
 
164
164
  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:
@@ -226,18 +226,18 @@ Register them all in that single batched call. If a plan added five features, th
226
226
  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.
227
227
 
228
228
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
229
- ${XQ}`});import{existsSync as _Q,mkdirSync as HQ,readFileSync as O,rmSync as _Z,writeFileSync as y}from"fs";import{dirname as SQ,join as b}from"path";function BQ(Q){try{return JSON.parse(O(Q,"utf8"))}catch{return{}}}function hQ(Q,Z){HQ(SQ(Q),{recursive:!0}),y(Q,JSON.stringify(Z,null,2)+`
230
- `)}function k(Q,Z){let $=BQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),hQ(Q,$),!0}function _(Q,Z){return(BQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function S(Q,Z){let $=BQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==X)J=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!J)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return hQ(Q,$),!0}function h(Q,Z,$,Y){let J=`${Z}
229
+ ${UQ}`});import{existsSync as y,mkdirSync as BQ,readdirSync as mZ,readFileSync as F,rmSync as pZ,writeFileSync as L}from"fs";import{dirname as SQ,join as N}from"path";function hQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function mQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=N(Q,".claude","plugins");if(!y(Z))return null;let $=[Z];for(let Y=0;Y<3&&$.length;Y++){let J=[];for(let V of $){let q=N(V,".claude-plugin","plugin.json");try{if(y(q)&&JSON.parse(F(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of mZ(V,{withFileTypes:!0}))if(X.isDirectory())J.push(N(V,X.name))}catch{}}$=J}return null}function pQ(Q){return mQ(Q)!==null}function jQ(Q){try{return JSON.parse(F(Q,"utf8"))}catch{return{}}}function cQ(Q,Z){BQ(SQ(Q),{recursive:!0}),L(Q,JSON.stringify(Z,null,2)+`
230
+ `)}function _(Q,Z){let $=jQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),cQ(Q,$),!0}function S(Q,Z){return(jQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function h(Q,Z){let $=jQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==X)J=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!J)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return cQ(Q,$),!0}function m(Q,Z,$,Y){let J=`${Z}
231
231
  ${Y.trim()}
232
- ${$}`,V="";try{V=O(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
232
+ ${$}`,V="";try{V=F(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
233
233
 
234
234
  ${J}
235
235
  `:`${J}
236
- `,HQ(SQ(Q),{recursive:!0}),y(Q,V.endsWith(`
236
+ `,BQ(SQ(Q),{recursive:!0}),L(Q,V.endsWith(`
237
237
  `)?V:`${V}
238
- `)}function T(Q,Z){try{return O(Q,"utf8").includes(Z)}catch{return!1}}function m(Q,Z,$){let Y="";try{Y=O(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
238
+ `)}function R(Q,Z){try{return F(Q,"utf8").includes(Z)}catch{return!1}}function p(Q,Z,$){let Y="";try{Y=F(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
239
239
 
240
- `).trimStart();return y(Q,V),!0}function p(Q,Z,$){let Y=b(Q,Z);HQ(Y,{recursive:!0});let J=b(Y,"SKILL.md");return y(J,$),J}function F(Q,Z){return _Q(b(Q,Z,"SKILL.md"))}function c(Q,Z){let $=b(Q,Z);if(!_Q($))return!1;return _Z($,{recursive:!0,force:!0}),!0}var x,L=`## Beacon (visual planning panel)
240
+ `).trimStart();return L(Q,V),!0}function c(Q,Z,$){let Y=N(Q,Z);BQ(Y,{recursive:!0});let J=N(Y,"SKILL.md");return L(J,$),J}function w(Q,Z){return y(N(Q,Z,"SKILL.md"))}function l(Q,Z){let $=N(Q,Z);if(!y($))return!1;return pZ($,{recursive:!0,force:!0}),!0}var K,k=`## Beacon (visual planning panel)
241
241
 
242
242
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
243
243
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -258,24 +258,24 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
258
258
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
259
259
  on the /map and /db boards (added features, attached subtasks, edited columns, new
260
260
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
261
- verbatim. Do NOT implement until the tool returns approval.`;var jQ=v(()=>{x=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as SZ,renameSync as hZ,rmSync as mZ,writeFileSync as pZ}from"fs";import{dirname as cZ}from"path";function l(Q,Z){SZ(cZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{pZ($,Z),hZ($,Q)}catch(Y){throw mZ($,{force:!0}),Y}}function C1(Q,Z,$=!1){l(Q,JSON.stringify(Z,null,$?2:void 0))}var mQ=()=>{};var sQ={};JQ(sQ,{setupCodexAssets:()=>aZ,removeCodexMcp:()=>tQ,removeCodexArtifacts:()=>sZ,hasCodexMcp:()=>PQ,ensureCodexMcp:()=>aQ,codexMcpProblem:()=>nZ,codexDetected:()=>lQ,auditCodex:()=>tZ,CODEX_HOOKS:()=>s});import{readFileSync as t}from"fs";import{homedir as lZ}from"os";import{join as u}from"path";function pQ(){return process.env.HOME||process.env.USERPROFILE||lZ()}function lQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(GQ===void 0)GQ=Bun.which("codex")!==null;return GQ}function g(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function PQ(){try{return Boolean(g(t(M(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function nZ(){let Q="";try{Q=t(M(),"utf8")}catch{return null}let Z=g(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${R}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${R}`;return null}function aQ(){let Q="",Z=!1;try{Q=t(M(),"utf8"),Z=!0}catch{}if(Z){let V=g(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${R}`};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 ${R}`}}let $=!Q?"":Q.endsWith(`
261
+ verbatim. Do NOT implement until the tool returns approval.`;var GQ=C(()=>{K=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as cZ,renameSync as lZ,rmSync as dZ,writeFileSync as aZ}from"fs";import{dirname as nZ}from"path";function d(Q,Z){cZ(nZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{aZ($,Z),lZ($,Q)}catch(Y){throw dZ($,{force:!0}),Y}}function w1(Q,Z,$=!1){d(Q,JSON.stringify(Z,null,$?2:void 0))}var lQ=()=>{};var iQ={};VQ(iQ,{setupCodexAssets:()=>oZ,removeCodexMcp:()=>oQ,removeCodexArtifacts:()=>eZ,hasCodexMcp:()=>PQ,ensureCodexMcp:()=>rQ,codexMcpProblem:()=>rZ,codexDetected:()=>nQ,auditCodex:()=>iZ,CODEX_HOOKS:()=>r});import{readFileSync as s}from"fs";import{homedir as tZ}from"os";import{join as D}from"path";function dQ(){return process.env.HOME||process.env.USERPROFILE||tZ()}function nQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(KQ===void 0)KQ=Bun.which("codex")!==null;return KQ}function g(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function PQ(){try{return Boolean(g(s(T(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function rZ(){let Q="";try{Q=s(T(),"utf8")}catch{return null}let Z=g(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${u}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${u}`;return null}function rQ(){let Q="",Z=!1;try{Q=s(T(),"utf8"),Z=!0}catch{}if(Z){let V=g(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${u}`};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 ${u}`}}let $=!Q?"":Q.endsWith(`
262
262
  `)?`
263
263
  `:`
264
264
 
265
- `,Y=Q+$+dZ;if(g(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${R}`};return l(M(),Y),{added:!0}}function tQ(){let Q="";try{Q=t(M(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
266
- `),$=Z.indexOf(dQ);if($===-1)return{removed:!1,skipped:PQ()};let Y=Z.indexOf(nQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
265
+ `,Y=Q+$+sZ;if(g(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${u}`};return d(T(),Y),{added:!0}}function oQ(){let Q="";try{Q=s(T(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
266
+ `),$=Z.indexOf(tQ);if($===-1)return{removed:!1,skipped:PQ()};let Y=Z.indexOf(sQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
267
267
  `).replace(/\n{3,}/g,`
268
268
 
269
- `).replace(/^\n+/,"");if(g(J)===null)return{removed:!1,skipped:!0};return l(M(),J),{removed:!0}}async function aZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (WQ(),UQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of x){if(!F(n(),z))J.push(z);p(n(),z,Y[z])}let V=0;for(let z of s)if(k(KQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=T(d(),a);h(d(),a,cQ,L);let X=aQ();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function tZ(){let Q={};for(let $ of x)Q[$]=F(n(),$);let Z={};for(let $ of s)Z[$.event]=_(KQ(),{event:$.event,command:$.command});return{detected:lQ(),skills:Q,hooks:Z,agentsMdBlock:T(d(),a),mcp:PQ()}}function sZ(){let Q=[];for(let J of x)if(c(n(),J))Q.push(J);let Z=0;for(let J of s)if(S(KQ(),{event:J.event,command:J.command}))Z++;let $=m(d(),a,cQ),Y=tQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var xQ=()=>u(pQ(),".codex"),KQ=()=>u(xQ(),"hooks.json"),M=()=>u(xQ(),"config.toml"),d=()=>u(xQ(),"AGENTS.md"),n=()=>u(pQ(),".agents","skills"),a="<!-- beacon:global:start -->",cQ="<!-- beacon:global:end -->",s,GQ,dQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",nQ="# beacon:end",dZ,R="add it manually: codex mcp add beacon -- beacon mcp";var rQ=v(()=>{jQ();mQ();s=[{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."}];dZ=`${dQ}
269
+ `).replace(/^\n+/,"");if(g(J)===null)return{removed:!1,skipped:!0};return d(T(),J),{removed:!0}}async function oZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (HQ(),WQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of K){if(!w(n(),z))J.push(z);c(n(),z,Y[z])}let V=0;for(let z of r)if(_(NQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=R(a(),t);m(a(),t,aQ,k);let X=rQ();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function iZ(){let Q={};for(let $ of K)Q[$]=w(n(),$);let Z={};for(let $ of r)Z[$.event]=S(NQ(),{event:$.event,command:$.command});return{detected:nQ(),skills:Q,hooks:Z,agentsMdBlock:R(a(),t),mcp:PQ()}}function eZ(){let Q=[];for(let J of K)if(l(n(),J))Q.push(J);let Z=0;for(let J of r)if(h(NQ(),{event:J.event,command:J.command}))Z++;let $=p(a(),t,aQ),Y=oQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var xQ=()=>D(dQ(),".codex"),NQ=()=>D(xQ(),"hooks.json"),T=()=>D(xQ(),"config.toml"),a=()=>D(xQ(),"AGENTS.md"),n=()=>D(dQ(),".agents","skills"),t="<!-- beacon:global:start -->",aQ="<!-- beacon:global:end -->",r,KQ,tQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",sQ="# beacon:end",sZ,u="add it manually: codex mcp add beacon -- beacon mcp";var eQ=C(()=>{GQ();lQ();r=[{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."}];sZ=`${tQ}
270
270
  [mcp_servers.beacon]
271
271
  command = "beacon"
272
272
  args = ["mcp"]
273
- ${nQ}
274
- `});var $Z={};JQ($Z,{provisionDb:()=>v0});import{createClient as X0}from"@libsql/client";import{drizzle as U0}from"drizzle-orm/libsql";import{migrate as W0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as H0}from"drizzle-orm/migrator";import{dirname as FQ,join as B0}from"path";import{fileURLToPath as j0}from"url";async function i(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function P0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function ZZ(Q){if(!await i(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 N0(Q){for(let[Z,$]of Object.entries(K0)){if(!await i(Q,Z))continue;let Y=await P0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function v0(Q,Z=x0){let $=X0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await i($,"__drizzle_migrations"),J=await i($,"Node"),V=!1;if(J&&!Y){let X=H0({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 ZZ($);if(await W0(U0($),{migrationsFolder:Z}),await ZZ($)>q)V=!0;return await N0($),{migrated:V}}finally{$.close()}}var G0,x0,K0;var YZ=v(async()=>{G0=FQ(FQ(FQ(j0(import.meta.url)))),x0=process.env.BEACON_MIGRATIONS_DIR||B0(G0,"drizzle"),K0={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 rZ}from"fs";import{homedir as oZ}from"os";import{join as r}from"path";function iZ(){return process.env.HOME||process.env.USERPROFILE||oZ()}var o=()=>r(iZ(),".claude"),NQ=()=>r(o(),"skills"),vQ=()=>r(o(),"settings.json"),CQ=()=>r(o(),"CLAUDE.md"),MQ="<!-- beacon:global:start -->",oQ="<!-- beacon:global:end -->";var eZ=L,TQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function Q0(Q,Z){return p(NQ(),Q,Z)}function iQ(Q){return F(NQ(),Q)}function Z0(Q){return c(NQ(),Q)}function $0(Q){return k(vQ(),Q)}function Y0(Q){return _(vQ(),Q)}function J0(Q){return S(vQ(),Q)}function V0(Q){h(CQ(),MQ,oQ,Q)}function eQ(){return T(CQ(),MQ)}function z0(){return m(CQ(),MQ,oQ)}function I1(){let Q={};for(let $ of x)Q[$]=iQ($);let Z={};for(let $ of TQ)Z[$.event]=Y0({event:$.event,command:$.command});return{homeExists:rZ(o()),skills:Q,hooks:Z,claudeMdBlock:eQ()}}async function q0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (WQ(),UQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of x){if(!iQ(X))J.push(X);Q0(X,Y[X])}let V=0;for(let X of TQ)if($0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=eQ();return V0(eZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function QZ(){let Q;try{Q={ok:!0,...await q0()}}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(() => (rQ(),sQ));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 E1(){let Q=[];for(let Y of x)if(Z0(Y))Q.push(Y);let Z=0;for(let Y of TQ)if(J0(Y))Z++;let $=z0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as C0}from"async_hooks";import{spawnSync as M0}from"child_process";import{createHash as T0}from"crypto";import{existsSync as VZ,mkdirSync as w,readFileSync as gQ,writeFileSync as uQ}from"fs";import{homedir as zZ}from"os";import{basename as F0,join as K,parse as R0,resolve as JZ}from"path";function j(){return process.env.BEACON_HOME||K(zZ(),".beacon")}function wQ(){return K(j(),"workspaces.json")}function e(Q){return T0("sha256").update(Q).digest("hex").slice(0,12)}function n1(Q=process.cwd()){let Z=M0("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 qZ(Q){let Z=JZ(Q);return Z!==JZ(zZ())&&Z!==R0(Z).root}function XZ(){return K(j(),"deleted.json")}function fQ(){try{let Q=JSON.parse(gQ(XZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function UZ(Q){w(j(),{recursive:!0}),uQ(XZ(),JSON.stringify(Q,null,2))}function WZ(Q){return fQ().includes(Q)}function a1(Q){let Z=fQ();if(!Z.includes(Q))UZ([...Z,Q])}function g0(Q){let Z=fQ();if(Z.includes(Q))UZ(Z.filter(($)=>$!==Q))}function QQ(Q){return K(j(),Q)}function u0(Q){return`file:${K(QQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(gQ(wQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function DQ(Q){w(j(),{recursive:!0}),uQ(wQ(),JSON.stringify(Q,null,2))}function HZ(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function P(Q){return f().find((Z)=>Z.id===Q)??null}function BZ(Q,Z,$=new Date().toISOString()){if(!qZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=e(Q);if(WZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=f(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||F0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return w(QQ(Y),{recursive:!0}),DQ(X),q}function t1(Q,Z){return g0(e(Q)),BZ(Q,Z)}function s1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,DQ($)}function r1(Q){if(DQ(f().filter((Z)=>Z.id!==Q)),AQ()===Q)w0(HZ()[0]?.id??null)}function jZ(){return K(j(),"active")}function AQ(){try{return gQ(jZ(),"utf8").trim()||null}catch{return null}}function w0(Q){w(j(),{recursive:!0}),uQ(jZ(),Q??"")}function o1(){let Q=AQ();return Q?P(Q):null}function i1(){let Q=A0()??AQ();return Q?P(Q):null}function e1(Q){return P(Q)?.path??null}function Q2(){return VZ(wQ())}var GZ="beacon_ws";function xZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function Z2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=xZ(Q,GZ);if($&&P($))return $;return f0()}function f0(){let Q=HZ();return Q.length===1?Q[0].id:null}var D0="x-beacon-workspace-path";async function $2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=Q.headers.get(D0);if($&&qZ($)&&!WZ(e($))&&(!Z||e($)===Z)){let J=BZ($);return await I0(J.id),J.id}let Y=xZ(Q,GZ);if(Y&&P(Y))return Y;return null}var KZ=new C0;function Y2(Q,Z){return Q?KZ.run(Q,Z):Z()}function A0(){return KZ.getStore()??null}var RQ=new Set;function J2(Q){RQ.delete(K(QQ(Q),"db.sqlite"))}async function I0(Q){let Z=QQ(Q),$=K(Z,"db.sqlite"),Y=VZ($);if(Y&&RQ.has($))return{ok:!0,created:!1,migrated:!1};try{w(Z,{recursive:!0});let{provisionDb:J}=await YZ().then(() => $Z),V=await J(u0(Q));return RQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as E0}from"net";var q2=4319;function b0(Q,Z,$=400){return new Promise((Y)=>{let J=E0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function O0(Q){for(let Z of["127.0.0.1","::1"])if(await b0(Z,Q))return!1;return!0}async function PZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await O0($))return $;return Q}import{execSync as p0,spawn as c0}from"child_process";import{mkdirSync as l0,openSync as d0,readFileSync as n0,writeFileSync as a0}from"fs";import{homedir as t0}from"os";import{dirname as s0,join as $Q}from"path";import{fileURLToPath as r0}from"url";import{createHash as o0}from"crypto";VQ();import{mkdirSync as L0,readFileSync as k0,writeFileSync as _0}from"fs";import{join as S0}from"path";var y0=["default","acceptEdits","bypassPermissions","auto"];function NZ(Q){return typeof Q==="string"&&y0.includes(Q)}function vZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function CZ(){return S0(j(),"preferences.json")}function IQ(){try{let Q=JSON.parse(k0(CZ(),"utf8"));return{planApprovalMode:NZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function G2(Q){let Z={...IQ(),...Q};return L0(j(),{recursive:!0}),_0(CZ(),JSON.stringify(Z,null,2)),Z}function MZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
273
+ ${sQ}
274
+ `});var VZ={};VQ(VZ,{provisionDb:()=>R0});import{createClient as j0}from"@libsql/client";import{drizzle as G0}from"drizzle-orm/libsql";import{migrate as K0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as x0}from"drizzle-orm/migrator";import{dirname as RQ,join as N0}from"path";import{fileURLToPath as P0}from"url";async function e(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function T0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function JZ(Q){if(!await e(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(M0)){if(!await e(Q,Z))continue;let Y=await T0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function R0(Q,Z=C0){let $=j0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await e($,"__drizzle_migrations"),J=await e($,"Node"),V=!1;if(J&&!Y){let X=x0({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 JZ($);if(await K0(G0($),{migrationsFolder:Z}),await JZ($)>q)V=!0;return await F0($),{migrated:V}}finally{$.close()}}var v0,C0,M0;var zZ=C(async()=>{v0=RQ(RQ(RQ(P0(import.meta.url)))),C0=process.env.BEACON_MIGRATIONS_DIR||N0(v0,"drizzle"),M0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});GQ();import{existsSync as Q0}from"fs";import{homedir as Z0}from"os";import{join as o}from"path";function $0(){return process.env.HOME||process.env.USERPROFILE||Z0()}var i=()=>o($0(),".claude"),vQ=()=>o(i(),"skills"),CQ=()=>o(i(),"settings.json"),MQ=()=>o(i(),"CLAUDE.md"),TQ="<!-- beacon:global:start -->",QZ="<!-- beacon:global:end -->";var Y0=k,FQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function J0(Q,Z){return c(vQ(),Q,Z)}function ZZ(Q){return w(vQ(),Q)}function V0(Q){return l(vQ(),Q)}function z0(Q){return _(CQ(),Q)}function q0(Q){return S(CQ(),Q)}function X0(Q){return h(CQ(),Q)}function U0(Q){m(MQ(),TQ,QZ,Q)}function $Z(){return R(MQ(),TQ)}function W0(){return p(MQ(),TQ,QZ)}function L1(){let Q={};for(let $ of K)Q[$]=ZZ($);let Z={};for(let $ of FQ)Z[$.event]=q0({event:$.event,command:$.command});return{homeExists:Q0(i()),skills:Q,hooks:Z,claudeMdBlock:$Z()}}async function H0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (HQ(),WQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of K){if(!ZZ(X))J.push(X);J0(X,Y[X])}let V=0;for(let X of FQ)if(z0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=$Z();return U0(Y0),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function YZ(){if(hQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(pQ()){try{B0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await H0()}}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(() => (eQ(),iQ));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 B0(){let Q=[];for(let Y of K)if(V0(Y))Q.push(Y);let Z=0;for(let Y of FQ)if(X0(Y))Z++;let $=W0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as w0}from"async_hooks";import{spawnSync as u0}from"child_process";import{createHash as g0}from"crypto";import{existsSync as XZ,mkdirSync as A,readFileSync as uQ,writeFileSync as gQ}from"fs";import{homedir as UZ}from"os";import{basename as D0,join as x,parse as A0,resolve as qZ}from"path";function j(){return process.env.BEACON_HOME||x(UZ(),".beacon")}function DQ(){return x(j(),"workspaces.json")}function QQ(Q){return g0("sha256").update(Q).digest("hex").slice(0,12)}function r1(Q=process.cwd()){let Z=u0("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 WZ(Q){let Z=qZ(Q);return Z!==qZ(UZ())&&Z!==A0(Z).root}function HZ(){return x(j(),"deleted.json")}function AQ(){try{let Q=JSON.parse(uQ(HZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function BZ(Q){A(j(),{recursive:!0}),gQ(HZ(),JSON.stringify(Q,null,2))}function jZ(Q){return AQ().includes(Q)}function o1(Q){let Z=AQ();if(!Z.includes(Q))BZ([...Z,Q])}function f0(Q){let Z=AQ();if(Z.includes(Q))BZ(Z.filter(($)=>$!==Q))}function ZQ(Q){return x(j(),Q)}function E0(Q){return`file:${x(ZQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(uQ(DQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function fQ(Q){A(j(),{recursive:!0}),gQ(DQ(),JSON.stringify(Q,null,2))}function GZ(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function P(Q){return f().find((Z)=>Z.id===Q)??null}function KZ(Q,Z,$=new Date().toISOString()){if(!WZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=QQ(Q);if(jZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=f(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||D0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return A(ZQ(Y),{recursive:!0}),fQ(X),q}function i1(Q,Z){return f0(QQ(Q)),KZ(Q,Z)}function e1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,fQ($)}function Q2(Q){if(fQ(f().filter((Z)=>Z.id!==Q)),EQ()===Q)I0(GZ()[0]?.id??null)}function xZ(){return x(j(),"active")}function EQ(){try{return uQ(xZ(),"utf8").trim()||null}catch{return null}}function I0(Q){A(j(),{recursive:!0}),gQ(xZ(),Q??"")}function Z2(){let Q=EQ();return Q?P(Q):null}function $2(){let Q=y0()??EQ();return Q?P(Q):null}function Y2(Q){return P(Q)?.path??null}function J2(){return XZ(DQ())}var NZ="beacon_ws";function PZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function V2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=PZ(Q,NZ);if($&&P($))return $;return O0()}function O0(){let Q=GZ();return Q.length===1?Q[0].id:null}var b0="x-beacon-workspace-path";async function z2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=Q.headers.get(b0);if($&&WZ($)&&!jZ(QQ($))&&(!Z||QQ($)===Z)){let J=KZ($);return await L0(J.id),J.id}let Y=PZ(Q,NZ);if(Y&&P(Y))return Y;return null}var vZ=new w0;function q2(Q,Z){return Q?vZ.run(Q,Z):Z()}function y0(){return vZ.getStore()??null}var wQ=new Set;function X2(Q){wQ.delete(x(ZQ(Q),"db.sqlite"))}async function L0(Q){let Z=ZQ(Q),$=x(Z,"db.sqlite"),Y=XZ($);if(Y&&wQ.has($))return{ok:!0,created:!1,migrated:!1};try{A(Z,{recursive:!0});let{provisionDb:J}=await zZ().then(() => VZ),V=await J(E0(Q));return wQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as k0}from"net";var H2=4319;function _0(Q,Z,$=400){return new Promise((Y)=>{let J=k0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function S0(Q){for(let Z of["127.0.0.1","::1"])if(await _0(Z,Q))return!1;return!0}async function CZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await S0($))return $;return Q}import{execSync as n0,spawn as t0}from"child_process";import{mkdirSync as s0,openSync as r0,readFileSync as o0,writeFileSync as i0}from"fs";import{homedir as e0}from"os";import{dirname as Q1,join as YQ}from"path";import{fileURLToPath as Z1}from"url";import{createHash as $1}from"crypto";zQ();import{mkdirSync as m0,readFileSync as p0,writeFileSync as c0}from"fs";import{join as l0}from"path";var h0=["default","acceptEdits","bypassPermissions","auto"];function MZ(Q){return typeof Q==="string"&&h0.includes(Q)}function TZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function FZ(){return l0(j(),"preferences.json")}function IQ(){try{let Q=JSON.parse(p0(FZ(),"utf8"));return{planApprovalMode:MZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function P2(Q){let Z={...IQ(),...Q};return m0(j(),{recursive:!0}),c0(FZ(),JSON.stringify(Z,null,2)),Z}function RZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
275
275
 
276
276
  This plan created these roadmap feature(s):
277
277
  `+Z.join(`
278
- `)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{execSync as h0}from"child_process";import{platform as TZ}from"os";function m0(Q){if(process.env.BEACON_NO_OPEN)return;let Z=TZ()==="darwin"?"open":TZ()==="win32"?"start":"xdg-open";try{h0(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}async function FZ(Q,Z){if(await fetch(`${Q}/api/plan/presence`,{headers:{"x-beacon-workspace":Z}}).then((J)=>J.json()).then((J)=>!!J?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Z}`);m0(`${Q}/api/workspace/activate?id=${Z}&redirect=${Y}`)}var i0=$Q(s0(r0(import.meta.url)),".."),bQ=process.env.BEACON_HOME||$Q(t0(),".beacon"),RZ=$Q(bQ,"server.json"),e0=process.env.PORT||"4319";function Q1(Q){try{return process.kill(Q,0),!0}catch{return!1}}function Z1(Q){try{return JSON.parse(n0(Q,"utf8"))}catch{return null}}async function gZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function $1(Q,Z=60){for(let $=0;$<Z;$++){if(await gZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function Y1(Q){l0(bQ,{recursive:!0});let Z=d0($Q(bQ,"server.log"),"a"),$={...process.env,PORT:Q,BEACON_NO_OPEN:"1"};delete $.BEACON_REPO,delete $.BEACON_DATA_DIR,delete $.DATABASE_URL;let Y=c0("bun",["run","dev"],{cwd:i0,env:$,detached:!0,stdio:["ignore",Z,Z]});Y.unref();let J={pid:Y.pid??0,port:Q};return a0(RZ,JSON.stringify(J)),J}async function J1(){let Q=Z1(RZ);if(Q&&Q1(Q.pid)&&await gZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let Z=String(await PZ(Number(e0))),{port:$}=Y1(Z);return await $1(`http://localhost:${$}/api/workspace`),$}function V1(){try{return p0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function z1(Q){return o0("sha256").update(Q).digest("hex").slice(0,12)}async function q1(){if(process.stdin.isTTY)return null;let Q=[];for await(let $ of process.stdin)Q.push($);let Z=Buffer.concat(Q).toString("utf8").trim();if(!Z)return null;try{return JSON.parse(Z)}catch{return null}}function EQ(Q,Z){return vZ(Q,Z)}function ZQ(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function N(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await QZ();let Z=(await q1())?.tool_input?.plan;if(!Z||!Z.trim())N(EQ());let Y=`http://localhost:${await J1()}`,J=V1()||process.cwd(),V=z1(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let q=Z.split(`
279
- `,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let H=await X.json().catch(()=>({}));N(ZQ(H.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!X.ok)N(EQ());await FZ(Y,V);let z=Date.now()+yQ,W=(H)=>new Promise((YQ)=>setTimeout(YQ,H));while(Date.now()<z){await W(OQ);let H=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((YQ)=>YQ.json()).catch(()=>null);if(!H)continue;if(H.kind==="approved")N(EQ(IQ().planApprovalMode,MZ(H.features)));if(H.kind==="discarded")N(ZQ("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(H.kind==="feedback")N(ZQ(`The user left feedback on the plan in Beacon (inline comments and/or edits on the /map and /db boards). Revise the plan based on the feedback below, then re-present (call ExitPlanMode again):
278
+ `)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{execSync as d0}from"child_process";import{platform as wZ}from"os";function a0(Q){if(process.env.BEACON_NO_OPEN)return;let Z=wZ()==="darwin"?"open":wZ()==="win32"?"start":"xdg-open";try{d0(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}async function uZ(Q,Z){if(await fetch(`${Q}/api/plan/presence`,{headers:{"x-beacon-workspace":Z}}).then((J)=>J.json()).then((J)=>!!J?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Z}`);a0(`${Q}/api/workspace/activate?id=${Z}&redirect=${Y}`)}var Y1=YQ(Q1(Z1(import.meta.url)),".."),bQ=process.env.BEACON_HOME||YQ(e0(),".beacon"),gZ=YQ(bQ,"server.json"),J1=process.env.PORT||"4319";function V1(Q){try{return process.kill(Q,0),!0}catch{return!1}}function z1(Q){try{return JSON.parse(o0(Q,"utf8"))}catch{return null}}async function DZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function q1(Q,Z=60){for(let $=0;$<Z;$++){if(await DZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function X1(Q){s0(bQ,{recursive:!0});let Z=r0(YQ(bQ,"server.log"),"a"),$={...process.env,PORT:Q,BEACON_NO_OPEN:"1"};delete $.BEACON_REPO,delete $.BEACON_DATA_DIR,delete $.DATABASE_URL;let Y=t0("bun",["run","dev"],{cwd:Y1,env:$,detached:!0,stdio:["ignore",Z,Z]});Y.unref();let J={pid:Y.pid??0,port:Q};return i0(gZ,JSON.stringify(J)),J}async function U1(){let Q=z1(gZ);if(Q&&V1(Q.pid)&&await DZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let Z=String(await CZ(Number(J1))),{port:$}=X1(Z);return await q1(`http://localhost:${$}/api/workspace`),$}function W1(){try{return n0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function H1(Q){return $1("sha256").update(Q).digest("hex").slice(0,12)}async function B1(){if(process.stdin.isTTY)return null;let Q=[];for await(let $ of process.stdin)Q.push($);let Z=Buffer.concat(Q).toString("utf8").trim();if(!Z)return null;try{return JSON.parse(Z)}catch{return null}}function OQ(Q,Z){return TZ(Q,Z)}function $Q(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function v(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await YZ();let Z=(await B1())?.tool_input?.plan;if(!Z||!Z.trim())v(OQ());let Y=`http://localhost:${await U1()}`,J=W1()||process.cwd(),V=H1(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let q=Z.split(`
279
+ `,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let H=await X.json().catch(()=>({}));v($Q(H.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!X.ok)v(OQ());await uZ(Y,V);let z=Date.now()+LQ,W=(H)=>new Promise((JQ)=>setTimeout(JQ,H));while(Date.now()<z){await W(yQ);let H=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((JQ)=>JQ.json()).catch(()=>null);if(!H)continue;if(H.kind==="approved")v(OQ(IQ().planApprovalMode,RZ(H.features)));if(H.kind==="discarded")v($Q("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(H.kind==="feedback")v($Q(`The user left feedback on the plan in Beacon (inline comments and/or edits on the /map and /db boards). Revise the plan based on the feedback below, then re-present (call ExitPlanMode again):
280
280
 
281
- `+H.feedback))}N(ZQ("\u23F3 Still awaiting your review in Beacon \u2014 the plan is open on /plan and nothing was lost. "+"Claude Code caps a single plan-review hook at ~10 minutes, so to keep waiting you MUST call ExitPlanMode again now with the SAME plan. Re-presenting resumes the same review (your in-progress annotations and any decision are preserved). Do NOT implement, and do "+"NOT ask in the terminal \u2014 just re-present."))})();
281
+ `+H.feedback))}v($Q("\u23F3 Still awaiting your review in Beacon \u2014 the plan is open on /plan and nothing was lost. "+"Claude Code caps a single plan-review hook at ~10 minutes, so to keep waiting you MUST call ExitPlanMode again now with the SAME plan. Re-presenting resumes the same review (your in-progress annotations and any decision are preserved). Do NOT implement, and do "+"NOT ask in the terminal \u2014 just re-present."))})();
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var wZ=Object.defineProperty;var FZ=(Q)=>Q;function RZ(Q,Z){this[Q]=FZ.bind(null,Z)}var PQ=(Q,Z)=>{for(var $ in Z)wZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:RZ.bind(Z,$)})};var C=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var A0=1500,O0=480000,y0=1800000,L=3600000,L0=3000;var mQ=()=>{};var NQ={};PQ(NQ,{removeRepoAssets:()=>xQ,installRefreshSkill:()=>IZ,installPlanSkill:()=>EZ,installInitSkill:()=>gZ,installCodexRepoSkills:()=>DZ,ensureWorkflowDoc:()=>AZ,ensureMcp:()=>OZ,auditRepo:()=>yZ,REFRESH_SKILL:()=>BQ,PLAN_SKILL:()=>cQ,INIT_SKILL:()=>jQ});import{existsSync as M,mkdirSync as k,readFileSync as v,rmSync as _,writeFileSync as H}from"fs";import{join as q}from"path";function gZ(Q){let Z=q(Q,".claude","skills","beacon-init");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return H($,jQ),$}function IZ(Q){let Z=q(Q,".claude","skills","beacon-refresh");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return H($,BQ),$}function EZ(Q){let Z=q(Q,".claude","skills","beacon-plan");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return H($,cQ),$}function DZ(Q){let Z=[];for(let $ of bZ){let J=q(Q,".agents","skills",$.name);k(J,{recursive:!0});let Y=q(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function AZ(Q){let Z=q(Q,"AGENTS.md"),$="";try{$=v(Z,"utf8")}catch{}let J=new RegExp(`${S}[\\s\\S]*?${vQ}`);$=J.test($)?$.replace(J,pQ):`${$.trim()}
3
+ var gZ=Object.defineProperty;var EZ=(Q)=>Q;function IZ(Q,Z){this[Q]=EZ.bind(null,Z)}var PQ=(Q,Z)=>{for(var $ in Z)gZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:IZ.bind(Z,$)})};var M=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var _0=1500,k0=480000,S0=1800000,k=3600000,h0=3000;var cQ=()=>{};var xQ={};PQ(xQ,{removeRepoAssets:()=>vQ,installRefreshSkill:()=>AZ,installPlanSkill:()=>bZ,installInitSkill:()=>DZ,installCodexRepoSkills:()=>yZ,ensureWorkflowDoc:()=>LZ,ensureMcp:()=>_Z,auditRepo:()=>kZ,REFRESH_SKILL:()=>NQ,PLAN_SKILL:()=>nQ,INIT_SKILL:()=>BQ});import{existsSync as T,mkdirSync as h,readFileSync as N,rmSync as S,writeFileSync as H}from"fs";import{join as U}from"path";function DZ(Q){let Z=U(Q,".claude","skills","beacon-init");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,BQ),$}function AZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,NQ),$}function bZ(Q){let Z=U(Q,".claude","skills","beacon-plan");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,nQ),$}function yZ(Q){let Z=[];for(let $ of OZ){let J=U(Q,".agents","skills",$.name);h(J,{recursive:!0});let Y=U(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function LZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=N(Z,"utf8")}catch{}let J=new RegExp(`${m}[\\s\\S]*?${GQ}`);$=J.test($)?$.replace(J,lQ):`${$.trim()}
4
4
 
5
- ${pQ}
5
+ ${lQ}
6
6
  `.trimStart(),H(Z,$.endsWith(`
7
7
  `)?$:`${$}
8
- `);let Y=q(Q,"CLAUDE.md"),V="";try{V=v(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))H(Y,`${V?`${V.trim()}
8
+ `);let Y=U(Q,"CLAUDE.md"),V="";try{V=N(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))H(Y,`${V?`${V.trim()}
9
9
 
10
10
  `:""}@AGENTS.md
11
- `)}function OZ(Q){let Z=q(Q,".mcp.json"),$={};try{$=JSON.parse(v(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<L)return J.timeout=L,H(Z,JSON.stringify($,null,2)+`
12
- `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:L},H(Z,JSON.stringify($,null,2)+`
13
- `),{path:Z,added:!0,updated:!1}}function yZ(Q){let Z=q(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(v(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=v(q(Q,"AGENTS.md"),"utf8").includes(S)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(v(q(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":M(q(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":M(q(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":M(q(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":M(q(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function xQ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=q(Q,".claude","skills",z);if(M(W))_(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=q(Q,".agents","skills",z);if(M(W))_(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=q(Q,".mcp.json");try{let z=JSON.parse(v(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)_(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
14
- `)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=v(V,"utf8"),W=new RegExp(`\\n?${S}[\\s\\S]*?${vQ}\\n?`);if(W.test(z)){let HQ=z.replace(W,`
11
+ `)}function _Z(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(N(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<k)return J.timeout=k,H(Z,JSON.stringify($,null,2)+`
12
+ `),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:k},H(Z,JSON.stringify($,null,2)+`
13
+ `),{path:Z,added:!0,updated:!1}}function kZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(N(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=N(U(Q,"AGENTS.md"),"utf8").includes(m)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(N(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":T(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":T(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":T(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":T(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function vQ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(T(W))S(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(T(W))S(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=U(Q,".mcp.json");try{let z=JSON.parse(N(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)S(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
14
+ `)}}catch{}let Y=!1,V=U(Q,"AGENTS.md");try{let z=N(V,"utf8"),W=new RegExp(`\\n?${m}[\\s\\S]*?${GQ}\\n?`);if(W.test(z)){let jQ=z.replace(W,`
15
15
  `).replace(/\n{3,}/g,`
16
16
 
17
- `).trimStart();H(V,HQ.endsWith(`
18
- `)?HQ:`${HQ}
19
- `),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=v(U,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())_(U,{force:!0});else H(U,W);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:X}}var jQ=`---
17
+ `).trimStart();H(V,jQ.endsWith(`
18
+ `)?jQ:`${jQ}
19
+ `),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=N(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())S(X,{force:!0});else H(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var BQ=`---
20
20
  name: beacon-init
21
21
  description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
22
22
  ---
@@ -63,7 +63,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
63
63
  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.
64
64
 
65
65
  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.
66
- `,BQ=`---
66
+ `,NQ=`---
67
67
  name: beacon-refresh
68
68
  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.
69
69
  ---
@@ -110,7 +110,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
110
110
  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.
111
111
 
112
112
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
113
- `,cQ=`---
113
+ `,nQ=`---
114
114
  name: beacon-plan
115
115
  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.
116
116
  ---
@@ -158,7 +158,7 @@ If it returns feedback, revise and call it again.
158
158
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
159
159
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
160
160
  run \`beacon\` in this repo once.
161
- `,bZ,S="<!-- beacon:workflow:start -->",vQ="<!-- beacon:workflow:end -->",pQ;var h=C(()=>{mQ();bZ=[{name:"beacon-init",body:()=>jQ},{name:"beacon-refresh",body:()=>BQ}];pQ=`${S}
161
+ `,OZ,m="<!-- beacon:workflow:start -->",GQ="<!-- beacon:workflow:end -->",lQ;var p=M(()=>{cQ();OZ=[{name:"beacon-init",body:()=>BQ},{name:"beacon-refresh",body:()=>NQ}];lQ=`${m}
162
162
  ## Beacon \u2014 feature workflow
163
163
 
164
164
  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:
@@ -226,18 +226,18 @@ Register them all in that single batched call. If a plan added five features, th
226
226
  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.
227
227
 
228
228
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
229
- ${vQ}`});import{existsSync as lQ,mkdirSync as GQ,readFileSync as p,rmSync as LZ,writeFileSync as c}from"fs";import{dirname as nQ,join as m}from"path";function uQ(Q){try{return JSON.parse(p(Q,"utf8"))}catch{return{}}}function tQ(Q,Z){GQ(nQ(Q),{recursive:!0}),c(Q,JSON.stringify(Z,null,2)+`
230
- `)}function n(Q,Z){let $=uQ(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((X)=>X.command===Z.command)))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),tQ(Q,$),!0}function t(Q,Z){return(uQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function d(Q,Z){let $=uQ(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((X)=>{let U=X.hooks?.length??0,z=(X.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==U)Y=!0;return{...X,hooks:z}}).filter((X)=>(X.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 tQ(Q,$),!0}function a(Q,Z,$,J){let Y=`${Z}
229
+ ${GQ}`});import{existsSync as c,mkdirSync as KQ,readdirSync as SZ,readFileSync as g,rmSync as hZ,writeFileSync as l}from"fs";import{dirname as tQ,join as K}from"path";function dQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function aQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=K(Q,".claude","plugins");if(!c(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let q=K(V,".claude-plugin","plugin.json");try{if(c(q)&&JSON.parse(g(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of SZ(V,{withFileTypes:!0}))if(X.isDirectory())Y.push(K(V,X.name))}catch{}}$=Y}return null}function sQ(Q){return aQ(Q)!==null}function uQ(Q){try{return JSON.parse(g(Q,"utf8"))}catch{return{}}}function rQ(Q,Z){KQ(tQ(Q),{recursive:!0}),l(Q,JSON.stringify(Z,null,2)+`
230
+ `)}function t(Q,Z){let $=uQ(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)=>q.command===Z.command)))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),rQ(Q,$),!0}function d(Q,Z){return(uQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function a(Q,Z){let $=uQ(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((W)=>W.command!==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 rQ(Q,$),!0}function s(Q,Z,$,J){let Y=`${Z}
231
231
  ${J.trim()}
232
- ${$}`,V="";try{V=p(Q,"utf8")}catch{}let X=new RegExp(`${Z}[\\s\\S]*?${$}`);V=X.test(V)?V.replace(X,Y):V.trim()?`${V.trim()}
232
+ ${$}`,V="";try{V=g(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
233
233
 
234
234
  ${Y}
235
235
  `:`${Y}
236
- `,GQ(nQ(Q),{recursive:!0}),c(Q,V.endsWith(`
236
+ `,KQ(tQ(Q),{recursive:!0}),l(Q,V.endsWith(`
237
237
  `)?V:`${V}
238
- `)}function R(Q,Z){try{return p(Q,"utf8").includes(Z)}catch{return!1}}function s(Q,Z,$){let J="";try{J=p(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,`
238
+ `)}function E(Q,Z){try{return g(Q,"utf8").includes(Z)}catch{return!1}}function r(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,`
239
239
 
240
- `).trimStart();return c(Q,V),!0}function r(Q,Z,$){let J=m(Q,Z);GQ(J,{recursive:!0});let Y=m(J,"SKILL.md");return c(Y,$),Y}function g(Q,Z){return lQ(m(Q,Z,"SKILL.md"))}function o(Q,Z){let $=m(Q,Z);if(!lQ($))return!1;return LZ($,{recursive:!0,force:!0}),!0}var P,l=`## Beacon (visual planning panel)
240
+ `).trimStart();return l(Q,V),!0}function o(Q,Z,$){let J=K(Q,Z);KQ(J,{recursive:!0});let Y=K(J,"SKILL.md");return l(Y,$),Y}function I(Q,Z){return c(K(Q,Z,"SKILL.md"))}function i(Q,Z){let $=K(Q,Z);if(!c($))return!1;return hZ($,{recursive:!0,force:!0}),!0}var j,n=`## Beacon (visual planning panel)
241
241
 
242
242
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
243
243
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -258,20 +258,20 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
258
258
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
259
259
  on the /map and /db boards (added features, attached subtasks, edited columns, new
260
260
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
261
- verbatim. Do NOT implement until the tool returns approval.`;var KQ=C(()=>{P=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as _Z,renameSync as kZ,rmSync as SZ,writeFileSync as hZ}from"fs";import{dirname as mZ}from"path";function i(Q,Z){_Z(mZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{hZ($,Z),kZ($,Q)}catch(J){throw SZ($,{force:!0}),J}}function t0(Q,Z,$=!1){i(Q,JSON.stringify(Z,null,$?2:void 0))}var dQ=()=>{};var ZZ={};PQ(ZZ,{setupCodexAssets:()=>nZ,removeCodexMcp:()=>QZ,removeCodexArtifacts:()=>FQ,hasCodexMcp:()=>TQ,ensureCodexMcp:()=>eQ,codexMcpProblem:()=>lZ,codexDetected:()=>rQ,auditCodex:()=>wQ,CODEX_HOOKS:()=>w});import{readFileSync as $Q}from"fs";import{homedir as pZ}from"os";import{join as b}from"path";function aQ(){return process.env.HOME||process.env.USERPROFILE||pZ()}function rQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(fQ===void 0)fQ=Bun.which("codex")!==null;return fQ}function E(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function TQ(){try{return Boolean(E($Q(T(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function lZ(){let Q="";try{Q=$Q(T(),"utf8")}catch{return null}let Z=E(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${I}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${I}`;return null}function eQ(){let Q="",Z=!1;try{Q=$Q(T(),"utf8"),Z=!0}catch{}if(Z){let V=E(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${I}`};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 ${I}`}}let $=!Q?"":Q.endsWith(`
261
+ verbatim. Do NOT implement until the tool returns approval.`;var CQ=M(()=>{j=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as mZ,renameSync as pZ,rmSync as cZ,writeFileSync as lZ}from"fs";import{dirname as nZ}from"path";function e(Q,Z){mZ(nZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{lZ($,Z),pZ($,Q)}catch(J){throw cZ($,{force:!0}),J}}function r0(Q,Z,$=!1){e(Q,JSON.stringify(Z,null,$?2:void 0))}var oQ=()=>{};var VZ={};PQ(VZ,{setupCodexAssets:()=>sZ,removeCodexMcp:()=>YZ,removeCodexArtifacts:()=>FQ,hasCodexMcp:()=>wQ,ensureCodexMcp:()=>JZ,codexMcpProblem:()=>aZ,codexDetected:()=>QZ,auditCodex:()=>RQ,CODEX_HOOKS:()=>R});import{readFileSync as JQ}from"fs";import{homedir as tZ}from"os";import{join as b}from"path";function iQ(){return process.env.HOME||process.env.USERPROFILE||tZ()}function QZ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(fQ===void 0)fQ=Bun.which("codex")!==null;return fQ}function A(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function wQ(){try{return Boolean(A(JQ(w(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function aZ(){let Q="";try{Q=JQ(w(),"utf8")}catch{return null}let Z=A(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${D}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${D}`;return null}function JZ(){let Q="",Z=!1;try{Q=JQ(w(),"utf8"),Z=!0}catch{}if(Z){let V=A(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${D}`};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 ${D}`}}let $=!Q?"":Q.endsWith(`
262
262
  `)?`
263
263
  `:`
264
264
 
265
- `,J=Q+$+cZ;if(E(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${I}`};return i(T(),J),{added:!0}}function QZ(){let Q="";try{Q=$Q(T(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
266
- `),$=Z.indexOf(oQ);if($===-1)return{removed:!1,skipped:TQ()};let J=Z.indexOf(iQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
265
+ `,J=Q+$+dZ;if(A(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${D}`};return e(w(),J),{added:!0}}function YZ(){let Q="";try{Q=JQ(w(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
266
+ `),$=Z.indexOf(ZZ);if($===-1)return{removed:!1,skipped:wQ()};let J=Z.indexOf($Z,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
267
267
  `).replace(/\n{3,}/g,`
268
268
 
269
- `).replace(/^\n+/,"");if(E(Y)===null)return{removed:!1,skipped:!0};return i(T(),Y),{removed:!0}}async function nZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (h(),NQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of P){if(!g(QQ(),z))Y.push(z);r(QQ(),z,J[z])}let V=0;for(let z of w)if(n(MQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=R(e(),ZQ);a(e(),ZQ,sQ,l);let U=eQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!X,mcp:U}}function wQ(){let Q={};for(let $ of P)Q[$]=g(QQ(),$);let Z={};for(let $ of w)Z[$.event]=t(MQ(),{event:$.event,command:$.command});return{detected:rQ(),skills:Q,hooks:Z,agentsMdBlock:R(e(),ZQ),mcp:TQ()}}function FQ(){let Q=[];for(let Y of P)if(o(QQ(),Y))Q.push(Y);let Z=0;for(let Y of w)if(d(MQ(),{event:Y.event,command:Y.command}))Z++;let $=s(e(),ZQ,sQ),J=QZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var CQ=()=>b(aQ(),".codex"),MQ=()=>b(CQ(),"hooks.json"),T=()=>b(CQ(),"config.toml"),e=()=>b(CQ(),"AGENTS.md"),QQ=()=>b(aQ(),".agents","skills"),ZQ="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->",w,fQ,oQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",iQ="# beacon:end",cZ,I="add it manually: codex mcp add beacon -- beacon mcp";var RQ=C(()=>{KQ();dQ();w=[{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."}];cZ=`${oQ}
269
+ `).replace(/^\n+/,"");if(A(Y)===null)return{removed:!1,skipped:!0};return e(w(),Y),{removed:!0}}async function sZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (p(),xQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of j){if(!I(ZQ(),z))Y.push(z);o(ZQ(),z,J[z])}let V=0;for(let z of R)if(t(TQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=E(QQ(),$Q);s(QQ(),$Q,eQ,n);let X=JZ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function RQ(){let Q={};for(let $ of j)Q[$]=I(ZQ(),$);let Z={};for(let $ of R)Z[$.event]=d(TQ(),{event:$.event,command:$.command});return{detected:QZ(),skills:Q,hooks:Z,agentsMdBlock:E(QQ(),$Q),mcp:wQ()}}function FQ(){let Q=[];for(let Y of j)if(i(ZQ(),Y))Q.push(Y);let Z=0;for(let Y of R)if(a(TQ(),{event:Y.event,command:Y.command}))Z++;let $=r(QQ(),$Q,eQ),J=YZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var MQ=()=>b(iQ(),".codex"),TQ=()=>b(MQ(),"hooks.json"),w=()=>b(MQ(),"config.toml"),QQ=()=>b(MQ(),"AGENTS.md"),ZQ=()=>b(iQ(),".agents","skills"),$Q="<!-- beacon:global:start -->",eQ="<!-- beacon:global:end -->",R,fQ,ZZ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",$Z="# beacon:end",dZ,D="add it manually: codex mcp add beacon -- beacon mcp";var gQ=M(()=>{CQ();oQ();R=[{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."}];dZ=`${ZZ}
270
270
  [mcp_servers.beacon]
271
271
  command = "beacon"
272
272
  args = ["mcp"]
273
- ${iQ}
274
- `});var XZ={};PQ(XZ,{provisionDb:()=>v0});import{createClient as Y0}from"@libsql/client";import{drizzle as V0}from"drizzle-orm/libsql";import{migrate as z0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as q0}from"drizzle-orm/migrator";import{dirname as DQ,join as X0}from"path";import{fileURLToPath as U0}from"url";async function VQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function j0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function qZ(Q){if(!await VQ(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 B0(Q){for(let[Z,$]of Object.entries(P0)){if(!await VQ(Q,Z))continue;let J=await j0(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 v0(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 VQ($,"__drizzle_migrations"),Y=await VQ($,"Node"),V=!1;if(Y&&!J){let U=q0({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 X=await qZ($);if(await z0(V0($),{migrationsFolder:Z}),await qZ($)>X)V=!0;return await B0($),{migrated:V}}finally{$.close()}}var W0,H0,P0;var UZ=C(async()=>{W0=DQ(DQ(DQ(U0(import.meta.url)))),H0=process.env.BEACON_MIGRATIONS_DIR||X0(W0,"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"]}});KQ();import{existsSync as tZ}from"fs";import{homedir as dZ}from"os";import{join as JQ}from"path";function aZ(){return process.env.HOME||process.env.USERPROFILE||dZ()}var YQ=()=>JQ(aZ(),".claude"),gQ=()=>JQ(YQ(),"skills"),IQ=()=>JQ(YQ(),"settings.json"),EQ=()=>JQ(YQ(),"CLAUDE.md"),bQ="<!-- beacon:global:start -->",$Z="<!-- beacon:global:end -->";var sZ=l,D=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function rZ(Q,Z){return r(gQ(),Q,Z)}function JZ(Q){return g(gQ(),Q)}function oZ(Q){return o(gQ(),Q)}function iZ(Q){return n(IQ(),Q)}function eZ(Q){return t(IQ(),Q)}function Q0(Q){return d(IQ(),Q)}function Z0(Q){a(EQ(),bQ,$Z,Q)}function YZ(){return R(EQ(),bQ)}function $0(){return s(EQ(),bQ,$Z)}function VZ(){let Q={};for(let $ of P)Q[$]=JZ($);let Z={};for(let $ of D)Z[$.event]=eZ({event:$.event,command:$.command});return{homeExists:tZ(YQ()),skills:Q,hooks:Z,claudeMdBlock:YZ()}}async function J0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (h(),NQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let U of P){if(!JZ(U))Y.push(U);rZ(U,J[U])}let V=0;for(let U of D)if(iZ({event:U.event,matcher:U.matcher,command:U.command}))V++;let X=YZ();return Z0(sZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!X}}async function J1(){let Q;try{Q={ok:!0,...await J0()}}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(() => (RQ(),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 zZ(){let Q=[];for(let J of P)if(oZ(J))Q.push(J);let Z=0;for(let J of D)if(Q0(J))Z++;let $=$0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as x0}from"async_hooks";import{spawnSync as N0}from"child_process";import{createHash as G0}from"crypto";import{existsSync as HZ,mkdirSync as A,readFileSync as OQ,writeFileSync as yQ}from"fs";import{homedir as PZ}from"os";import{basename as u0,join as N,parse as K0,resolve as WZ}from"path";function x(){return process.env.BEACON_HOME||N(PZ(),".beacon")}function LQ(){return N(x(),"workspaces.json")}function zQ(Q){return G0("sha256").update(Q).digest("hex").slice(0,12)}function N1(Q=process.cwd()){let Z=N0("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 jZ(Q){let Z=WZ(Q);return Z!==WZ(PZ())&&Z!==K0(Z).root}function BZ(){return N(x(),"deleted.json")}function _Q(){try{let Q=JSON.parse(OQ(BZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function vZ(Q){A(x(),{recursive:!0}),yQ(BZ(),JSON.stringify(Q,null,2))}function xZ(Q){return _Q().includes(Q)}function G1(Q){let Z=_Q();if(!Z.includes(Q))vZ([...Z,Q])}function f0(Q){let Z=_Q();if(Z.includes(Q))vZ(Z.filter(($)=>$!==Q))}function qQ(Q){return N(x(),Q)}function C0(Q){return`file:${N(qQ(Q),"db.sqlite")}`}function O(){try{let Q=JSON.parse(OQ(LQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function kQ(Q){A(x(),{recursive:!0}),yQ(LQ(),JSON.stringify(Q,null,2))}function XQ(){return O().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function u(Q){return O().find((Z)=>Z.id===Q)??null}function NZ(Q,Z,$=new Date().toISOString()){if(!jZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=zQ(Q);if(xZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=O(),V=Y.find((z)=>z.id===J),X={id:J,path:Q,name:Z||V?.name||u0(Q),lastOpenedAt:$},U=[X,...Y.filter((z)=>z.id!==J)];return A(qQ(J),{recursive:!0}),kQ(U),X}function u1(Q,Z){return f0(zQ(Q)),NZ(Q,Z)}function K1(Q,Z=new Date().toISOString()){let $=O(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,kQ($)}function f1(Q){if(kQ(O().filter((Z)=>Z.id!==Q)),SQ()===Q)M0(XQ()[0]?.id??null)}function GZ(){return N(x(),"active")}function SQ(){try{return OQ(GZ(),"utf8").trim()||null}catch{return null}}function M0(Q){A(x(),{recursive:!0}),yQ(GZ(),Q??"")}function C1(){let Q=SQ();return Q?u(Q):null}function M1(){let Q=F0()??SQ();return Q?u(Q):null}function T1(Q){return u(Q)?.path??null}function w1(){return HZ(LQ())}var uZ="beacon_ws";function KZ(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 F1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=KZ(Q,uZ);if($&&u($))return $;return T0()}function T0(){let Q=XQ();return Q.length===1?Q[0].id:null}var w0="x-beacon-workspace-path";async function R1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=Q.headers.get(w0);if($&&jZ($)&&!xZ(zQ($))&&(!Z||zQ($)===Z)){let Y=NZ($);return await R0(Y.id),Y.id}let J=KZ(Q,uZ);if(J&&u(J))return J;return null}var fZ=new x0;function g1(Q,Z){return Q?fZ.run(Q,Z):Z()}function F0(){return fZ.getStore()??null}var AQ=new Set;function I1(Q){AQ.delete(N(qQ(Q),"db.sqlite"))}async function R0(Q){let Z=qQ(Q),$=N(Z,"db.sqlite"),J=HZ($);if(J&&AQ.has($))return{ok:!0,created:!1,migrated:!1};try{A(Z,{recursive:!0});let{provisionDb:Y}=await UZ().then(() => XZ),V=await Y(C0(Q));return AQ.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)}}}h();RQ();import{existsSync as UQ,readFileSync as g0,rmSync as I0}from"fs";import{join as E0}from"path";var CZ=process.argv.slice(3),MZ=CZ.includes("--yes")||CZ.includes("-y"),B=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,j=(Q)=>`\x1B[2m${Q}\x1B[0m`,f=(Q)=>`
275
- \x1B[1m${Q}\x1B[0m`,TZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,K=x(),y=XQ(),hQ=VZ();console.log(f(MZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(f("Global"));console.log(` ${UQ(K)?`wipe ${K} (${y.length} workspaces)`:`${j(`${K} \u2014 already gone`)}`}`);for(let Q of P)console.log(` ${hQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:j(`skill ${Q} \u2014 already gone`)}`);for(let Q of D)console.log(` ${hQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:j(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${hQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":j("global CLAUDE.md block \u2014 already gone")}`);var WQ=wQ();console.log(f("Codex"));for(let Q of P)console.log(` ${WQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:j(`skill ${Q} \u2014 already gone`)}`);for(let Q of w)console.log(` ${WQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command} from ~/.codex/hooks.json`:j(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${WQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":j("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${WQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":j("config.toml beacon entry \u2014 already gone")}`);if(y.length){console.log(f(`Per-repo (${y.length})`));for(let Q of y){if(!UQ(Q.path)){console.log(` ${j(`${Q.path} \u2014 repo no longer on disk, skipping`)}`);continue}console.log(` ${Q.path}`),console.log(` ${j("strip beacon entry from .mcp.json, workflow block from AGENTS.md, skills, CLAUDE.md @-import")}`)}}if(!MZ)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.
276
- `),process.exit(0);console.log(f("Applying\u2026"));var F=zZ();if(F.skillsRemoved.length)console.log(` ${B(`removed skills: ${F.skillsRemoved.join(", ")}`)}`);if(F.hooksRemoved)console.log(` ${B(`removed ${F.hooksRemoved} hook${F.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(F.claudeMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var G=FQ();if(G.skillsRemoved.length)console.log(` ${B(`removed ~/.agents/skills: ${G.skillsRemoved.join(", ")}`)}`);if(G.hooksRemoved)console.log(` ${B(`removed ${G.hooksRemoved} hook${G.hooksRemoved===1?"":"s"} from ~/.codex/hooks.json`)}`);if(G.agentsMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.codex/AGENTS.md")}`);if(G.mcpRemoved)console.log(` ${B("stripped [mcp_servers.beacon] from ~/.codex/config.toml")}`);if(G.mcpSkipped)console.log(` ${TZ("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 y){if(!UQ(Q.path))continue;let Z=xQ(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 b0=E0(K,"server.json");try{let{pid:Q}=JSON.parse(g0(b0,"utf8"));if(Q)try{process.kill(Q),console.log(` ${B(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(UQ(K))I0(K,{recursive:!0,force:!0}),console.log(` ${B(`removed ${K}`)}`);console.log(f("Done."));console.log(` ${TZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
273
+ ${$Z}
274
+ `});var HZ={};PQ(HZ,{provisionDb:()=>K0});import{createClient as X0}from"@libsql/client";import{drizzle as U0}from"drizzle-orm/libsql";import{migrate as W0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as H0}from"drizzle-orm/migrator";import{dirname as OQ,join as j0}from"path";import{fileURLToPath as P0}from"url";async function zQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function v0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function WZ(Q){if(!await zQ(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 x0(Q){for(let[Z,$]of Object.entries(G0)){if(!await zQ(Q,Z))continue;let J=await v0(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 K0(Q,Z=N0){let $=X0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await zQ($,"__drizzle_migrations"),Y=await zQ($,"Node"),V=!1;if(Y&&!J){let X=H0({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 WZ($);if(await W0(U0($),{migrationsFolder:Z}),await WZ($)>q)V=!0;return await x0($),{migrated:V}}finally{$.close()}}var B0,N0,G0;var jZ=M(async()=>{B0=OQ(OQ(OQ(P0(import.meta.url)))),N0=process.env.BEACON_MIGRATIONS_DIR||j0(B0,"drizzle"),G0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});CQ();import{existsSync as rZ}from"fs";import{homedir as oZ}from"os";import{join as YQ}from"path";function iZ(){return process.env.HOME||process.env.USERPROFILE||oZ()}var VQ=()=>YQ(iZ(),".claude"),EQ=()=>YQ(VQ(),"skills"),IQ=()=>YQ(VQ(),"settings.json"),DQ=()=>YQ(VQ(),"CLAUDE.md"),AQ="<!-- beacon:global:start -->",zZ="<!-- beacon:global:end -->";var eZ=n,O=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function Q0(Q,Z){return o(EQ(),Q,Z)}function qZ(Q){return I(EQ(),Q)}function Z0(Q){return i(EQ(),Q)}function $0(Q){return t(IQ(),Q)}function J0(Q){return d(IQ(),Q)}function Y0(Q){return a(IQ(),Q)}function V0(Q){s(DQ(),AQ,zZ,Q)}function XZ(){return E(DQ(),AQ)}function z0(){return r(DQ(),AQ,zZ)}function UZ(){let Q={};for(let $ of j)Q[$]=qZ($);let Z={};for(let $ of O)Z[$.event]=J0({event:$.event,command:$.command});return{homeExists:rZ(VQ()),skills:Q,hooks:Z,claudeMdBlock:XZ()}}async function q0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (p(),xQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let X of j){if(!qZ(X))Y.push(X);Q0(X,J[X])}let V=0;for(let X of O)if($0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=XZ();return V0(eZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!q}}async function q1(){if(dQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(sQ()){try{bQ()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await q0()}}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(() => (gQ(),VZ));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 bQ(){let Q=[];for(let J of j)if(Z0(J))Q.push(J);let Z=0;for(let J of O)if(Y0(J))Z++;let $=z0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as u0}from"async_hooks";import{spawnSync as C0}from"child_process";import{createHash as f0}from"crypto";import{existsSync as BZ,mkdirSync as y,readFileSync as LQ,writeFileSync as _Q}from"fs";import{homedir as NZ}from"os";import{basename as M0,join as v,parse as T0,resolve as PZ}from"path";function G(){return process.env.BEACON_HOME||v(NZ(),".beacon")}function kQ(){return v(G(),"workspaces.json")}function qQ(Q){return f0("sha256").update(Q).digest("hex").slice(0,12)}function C1(Q=process.cwd()){let Z=C0("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=PZ(Q);return Z!==PZ(NZ())&&Z!==T0(Z).root}function vZ(){return v(G(),"deleted.json")}function SQ(){try{let Q=JSON.parse(LQ(vZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function xZ(Q){y(G(),{recursive:!0}),_Q(vZ(),JSON.stringify(Q,null,2))}function KZ(Q){return SQ().includes(Q)}function f1(Q){let Z=SQ();if(!Z.includes(Q))xZ([...Z,Q])}function w0(Q){let Z=SQ();if(Z.includes(Q))xZ(Z.filter(($)=>$!==Q))}function XQ(Q){return v(G(),Q)}function R0(Q){return`file:${v(XQ(Q),"db.sqlite")}`}function L(){try{let Q=JSON.parse(LQ(kQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function hQ(Q){y(G(),{recursive:!0}),_Q(kQ(),JSON.stringify(Q,null,2))}function UQ(){return L().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function u(Q){return L().find((Z)=>Z.id===Q)??null}function uZ(Q,Z,$=new Date().toISOString()){if(!GZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=qQ(Q);if(KZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=L(),V=Y.find((z)=>z.id===J),q={id:J,path:Q,name:Z||V?.name||M0(Q),lastOpenedAt:$},X=[q,...Y.filter((z)=>z.id!==J)];return y(XQ(J),{recursive:!0}),hQ(X),q}function M1(Q,Z){return w0(qQ(Q)),uZ(Q,Z)}function T1(Q,Z=new Date().toISOString()){let $=L(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,hQ($)}function w1(Q){if(hQ(L().filter((Z)=>Z.id!==Q)),mQ()===Q)F0(UQ()[0]?.id??null)}function CZ(){return v(G(),"active")}function mQ(){try{return LQ(CZ(),"utf8").trim()||null}catch{return null}}function F0(Q){y(G(),{recursive:!0}),_Q(CZ(),Q??"")}function R1(){let Q=mQ();return Q?u(Q):null}function F1(){let Q=I0()??mQ();return Q?u(Q):null}function g1(Q){return u(Q)?.path??null}function E1(){return BZ(kQ())}var fZ="beacon_ws";function MZ(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 $=MZ(Q,fZ);if($&&u($))return $;return g0()}function g0(){let Q=UQ();return Q.length===1?Q[0].id:null}var E0="x-beacon-workspace-path";async function D1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=Q.headers.get(E0);if($&&GZ($)&&!KZ(qQ($))&&(!Z||qQ($)===Z)){let Y=uZ($);return await D0(Y.id),Y.id}let J=MZ(Q,fZ);if(J&&u(J))return J;return null}var TZ=new u0;function A1(Q,Z){return Q?TZ.run(Q,Z):Z()}function I0(){return TZ.getStore()??null}var yQ=new Set;function b1(Q){yQ.delete(v(XQ(Q),"db.sqlite"))}async function D0(Q){let Z=XQ(Q),$=v(Z,"db.sqlite"),J=BZ($);if(J&&yQ.has($))return{ok:!0,created:!1,migrated:!1};try{y(Z,{recursive:!0});let{provisionDb:Y}=await jZ().then(() => HZ),V=await Y(R0(Q));return yQ.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)}}}p();gQ();import{existsSync as WQ,readFileSync as A0,rmSync as b0}from"fs";import{join as O0}from"path";var wZ=process.argv.slice(3),RZ=wZ.includes("--yes")||wZ.includes("-y"),B=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,P=(Q)=>`\x1B[2m${Q}\x1B[0m`,f=(Q)=>`
275
+ \x1B[1m${Q}\x1B[0m`,FZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,C=G(),_=UQ(),pQ=UZ();console.log(f(RZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(f("Global"));console.log(` ${WQ(C)?`wipe ${C} (${_.length} workspaces)`:`${P(`${C} \u2014 already gone`)}`}`);for(let Q of j)console.log(` ${pQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:P(`skill ${Q} \u2014 already gone`)}`);for(let Q of O)console.log(` ${pQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:P(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${pQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":P("global CLAUDE.md block \u2014 already gone")}`);var HQ=RQ();console.log(f("Codex"));for(let Q of j)console.log(` ${HQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:P(`skill ${Q} \u2014 already gone`)}`);for(let Q of R)console.log(` ${HQ.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(` ${HQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":P("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${HQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":P("config.toml beacon entry \u2014 already gone")}`);if(_.length){console.log(f(`Per-repo (${_.length})`));for(let Q of _){if(!WQ(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(!RZ)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.
276
+ `),process.exit(0);console.log(f("Applying\u2026"));var F=bQ();if(F.skillsRemoved.length)console.log(` ${B(`removed skills: ${F.skillsRemoved.join(", ")}`)}`);if(F.hooksRemoved)console.log(` ${B(`removed ${F.hooksRemoved} hook${F.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(F.claudeMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var x=FQ();if(x.skillsRemoved.length)console.log(` ${B(`removed ~/.agents/skills: ${x.skillsRemoved.join(", ")}`)}`);if(x.hooksRemoved)console.log(` ${B(`removed ${x.hooksRemoved} hook${x.hooksRemoved===1?"":"s"} from ~/.codex/hooks.json`)}`);if(x.agentsMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.codex/AGENTS.md")}`);if(x.mcpRemoved)console.log(` ${B("stripped [mcp_servers.beacon] from ~/.codex/config.toml")}`);if(x.mcpSkipped)console.log(` ${FZ("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 _){if(!WQ(Q.path))continue;let Z=vQ(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 y0=O0(C,"server.json");try{let{pid:Q}=JSON.parse(A0(y0,"utf8"));if(Q)try{process.kill(Q),console.log(` ${B(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(WQ(C))b0(C,{recursive:!0,force:!0}),console.log(` ${B(`removed ${C}`)}`);console.log(f("Done."));console.log(` ${FZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
277
277
  `);