trybeacon 0.1.18 → 0.1.19

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 (87) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +11 -11
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/_not-found.html +1 -1
  16. package/.next/server/app/_not-found.rsc +1 -1
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/docs.html +1 -1
  25. package/.next/server/app/docs.rsc +1 -1
  26. package/.next/server/app/docs.segments/_full.segment.rsc +1 -1
  27. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  28. package/.next/server/app/docs.segments/_index.segment.rsc +1 -1
  29. package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
  30. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  31. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  32. package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
  33. package/.next/server/app/feedback.html +1 -1
  34. package/.next/server/app/feedback.rsc +1 -1
  35. package/.next/server/app/feedback.segments/_full.segment.rsc +1 -1
  36. package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
  37. package/.next/server/app/feedback.segments/_index.segment.rsc +1 -1
  38. package/.next/server/app/feedback.segments/_tree.segment.rsc +1 -1
  39. package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
  40. package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
  41. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  42. package/.next/server/app/help.html +1 -1
  43. package/.next/server/app/help.rsc +1 -1
  44. package/.next/server/app/help.segments/_full.segment.rsc +1 -1
  45. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  46. package/.next/server/app/help.segments/_index.segment.rsc +1 -1
  47. package/.next/server/app/help.segments/_tree.segment.rsc +1 -1
  48. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
  49. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  50. package/.next/server/app/index.html +1 -1
  51. package/.next/server/app/index.rsc +1 -1
  52. package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  53. package/.next/server/app/index.segments/_full.segment.rsc +1 -1
  54. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  55. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  56. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  57. package/.next/server/app/map/page.js +2 -2
  58. package/.next/server/app/map/page.js.nft.json +1 -1
  59. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  60. package/.next/server/app/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/plan/page.js +2 -2
  62. package/.next/server/app/plan/page.js.nft.json +1 -1
  63. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  64. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app-paths-manifest.json +11 -11
  66. package/.next/server/chunks/7263.js +1 -0
  67. package/.next/server/middleware-build-manifest.js +1 -1
  68. package/.next/server/pages/404.html +1 -1
  69. package/.next/server/pages/500.html +1 -1
  70. package/.next/server/server-reference-manifest.js +1 -1
  71. package/.next/server/server-reference-manifest.json +1 -1
  72. package/.next/static/chunks/{9185-2dc95ca34d3ed35e.js → 9005-8ce19752fc3ddd2c.js} +1 -1
  73. package/.next/static/chunks/app/map/{page-8a50ebc7430720f9.js → page-2d506579d74725fe.js} +1 -1
  74. package/.next/static/chunks/app/plan/{page-8c84c74359ee2ea0.js → page-d6b31633d9630a26.js} +1 -1
  75. package/.next/trace +37 -37
  76. package/.next/trace-build +1 -1
  77. package/dist/bin/doctor.js +24 -24
  78. package/dist/bin/hook.js +24 -24
  79. package/dist/bin/mcp.js +30 -30
  80. package/dist/bin/plan.js +25 -25
  81. package/dist/bin/uninstall.js +26 -26
  82. package/dist/lib/codex-install.js +25 -25
  83. package/dist/lib/global-install.js +242 -0
  84. package/package.json +1 -1
  85. package/.next/server/chunks/7604.js +0 -1
  86. /package/.next/static/{zLC93esTvoKLzicL2UsF6 → zkOVrPg9gaBl1KxEF44lf}/_buildManifest.js +0 -0
  87. /package/.next/static/{zLC93esTvoKLzicL2UsF6 → zkOVrPg9gaBl1KxEF44lf}/_ssgManifest.js +0 -0
package/dist/bin/plan.js CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var xZ=Object.defineProperty;var KZ=(Q)=>Q;function NZ(Q,Z){this[Q]=KZ.bind(null,Z)}var QQ=(Q,Z)=>{for(var $ in Z)xZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:NZ.bind(Z,$)})};var N=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var JQ={};QQ(JQ,{removeRepoAssets:()=>RZ,installRefreshSkill:()=>CZ,installPlanSkill:()=>MZ,installInitSkill:()=>vZ,installCodexRepoSkills:()=>wZ,ensureWorkflowDoc:()=>gZ,ensureMcp:()=>FZ,auditRepo:()=>uZ,REFRESH_SKILL:()=>$Q,PLAN_SKILL:()=>bQ,INIT_SKILL:()=>ZQ});import{existsSync as v,mkdirSync as I,readFileSync as P,rmSync as b,writeFileSync as H}from"fs";import{join as W}from"path";function vZ(Q){let Z=W(Q,".claude","skills","beacon-init");I(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,ZQ),$}function CZ(Q){let Z=W(Q,".claude","skills","beacon-refresh");I(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,$Q),$}function MZ(Q){let Z=W(Q,".claude","skills","beacon-plan");I(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,bQ),$}function wZ(Q){let Z=[];for(let $ of TZ){let Y=W(Q,".agents","skills",$.name);I(Y,{recursive:!0});let J=W(Y,"SKILL.md");H(J,$.body()),Z.push(J)}return Z}function gZ(Q){let Z=W(Q,"AGENTS.md"),$="";try{$=P(Z,"utf8")}catch{}let Y=new RegExp(`${A}[\\s\\S]*?${YQ}`);$=Y.test($)?$.replace(Y,fQ):`${$.trim()}
3
+ var xZ=Object.defineProperty;var GZ=(Q)=>Q;function KZ(Q,Z){this[Q]=GZ.bind(null,Z)}var ZQ=(Q,Z)=>{for(var $ in Z)xZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:KZ.bind(Z,$)})};var T=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var VQ={};ZQ(VQ,{removeRepoAssets:()=>uZ,installRefreshSkill:()=>vZ,installPlanSkill:()=>CZ,installInitSkill:()=>NZ,installCodexRepoSkills:()=>TZ,ensureWorkflowDoc:()=>gZ,ensureMcp:()=>wZ,auditRepo:()=>FZ,REFRESH_SKILL:()=>YQ,PLAN_SKILL:()=>fQ,INIT_SKILL:()=>$Q});import{existsSync as N,mkdirSync as D,readFileSync as P,rmSync as b,writeFileSync as H}from"fs";import{join as W}from"path";function NZ(Q){let Z=W(Q,".claude","skills","beacon-init");D(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,$Q),$}function vZ(Q){let Z=W(Q,".claude","skills","beacon-refresh");D(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,YQ),$}function CZ(Q){let Z=W(Q,".claude","skills","beacon-plan");D(Z,{recursive:!0});let $=W(Z,"SKILL.md");return H($,fQ),$}function TZ(Q){let Z=[];for(let $ of MZ){let Y=W(Q,".agents","skills",$.name);D(Y,{recursive:!0});let J=W(Y,"SKILL.md");H(J,$.body()),Z.push(J)}return Z}function gZ(Q){let Z=W(Q,"AGENTS.md"),$="";try{$=P(Z,"utf8")}catch{}let Y=new RegExp(`${I}[\\s\\S]*?${JQ}`);$=Y.test($)?$.replace(Y,RQ):`${$.trim()}
4
4
 
5
- ${fQ}
5
+ ${RQ}
6
6
  `.trimStart(),H(Z,$.endsWith(`
7
7
  `)?$:`${$}
8
8
  `);let J=W(Q,"CLAUDE.md"),V="";try{V=P(J,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))H(J,`${V?`${V.trim()}
9
9
 
10
10
  `:""}@AGENTS.md
11
- `)}function FZ(Q){let Z=W(Q,".mcp.json"),$={};try{$=JSON.parse(P(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},H(Z,JSON.stringify($,null,2)+`
12
- `),{path:Z,added:!0}}function uZ(Q){let Z=W(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(P(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=P(W(Q,"AGENTS.md"),"utf8").includes(A)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(P(W(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":v(W(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":v(W(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":v(W(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":v(W(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function RZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let U=W(Q,".claude","skills",z);if(v(U))b(U,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let U=W(Q,".agents","skills",z);if(v(U))b(U,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=W(Q,".mcp.json");try{let z=JSON.parse(P(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)b(Y,{force:!0});else H(Y,JSON.stringify(z,null,2)+`
13
- `)}}catch{}let J=!1,V=W(Q,"AGENTS.md");try{let z=P(V,"utf8"),U=new RegExp(`\\n?${A}[\\s\\S]*?${YQ}\\n?`);if(U.test(z)){let T=z.replace(U,`
11
+ `)}function wZ(Q){let Z=W(Q,".mcp.json"),$={};try{$=JSON.parse(P(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},H(Z,JSON.stringify($,null,2)+`
12
+ `),{path:Z,added:!0}}function FZ(Q){let Z=W(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(P(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=P(W(Q,"AGENTS.md"),"utf8").includes(I)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(P(W(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":N(W(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":N(W(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":N(W(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":N(W(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function uZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let U=W(Q,".claude","skills",z);if(N(U))b(U,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let U=W(Q,".agents","skills",z);if(N(U))b(U,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=W(Q,".mcp.json");try{let z=JSON.parse(P(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)b(Y,{force:!0});else H(Y,JSON.stringify(z,null,2)+`
13
+ `)}}catch{}let J=!1,V=W(Q,"AGENTS.md");try{let z=P(V,"utf8"),U=new RegExp(`\\n?${I}[\\s\\S]*?${JQ}\\n?`);if(U.test(z)){let M=z.replace(U,`
14
14
  `).replace(/\n{3,}/g,`
15
15
 
16
- `).trimStart();H(V,T.endsWith(`
17
- `)?T:`${T}
18
- `),J=!0}}catch{}let X=!1,q=W(Q,"CLAUDE.md");try{let z=P(q,"utf8"),U=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(U!==z){if(!U.trim())b(q,{force:!0});else H(q,U);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:X}}var ZQ=`---
16
+ `).trimStart();H(V,M.endsWith(`
17
+ `)?M:`${M}
18
+ `),J=!0}}catch{}let X=!1,q=W(Q,"CLAUDE.md");try{let z=P(q,"utf8"),U=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(U!==z){if(!U.trim())b(q,{force:!0});else H(q,U);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:X}}var $Q=`---
19
19
  name: beacon-init
20
20
  description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
21
21
  ---
@@ -52,7 +52,7 @@ A single \`beacon_init_persist\` MCP tool call with:
52
52
  If \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-init.
53
53
 
54
54
  After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
55
- `,$Q=`---
55
+ `,YQ=`---
56
56
  name: beacon-refresh
57
57
  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.
58
58
  ---
@@ -99,7 +99,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
99
99
  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.
100
100
 
101
101
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
102
- `,bQ=`---
102
+ `,fQ=`---
103
103
  name: beacon-plan
104
104
  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.
105
105
  ---
@@ -141,7 +141,7 @@ If it returns feedback, revise and call it again.
141
141
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
142
142
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
143
143
  run \`beacon\` in this repo once.
144
- `,TZ,A="<!-- beacon:workflow:start -->",YQ="<!-- beacon:workflow:end -->",fQ;var VQ=N(()=>{TZ=[{name:"beacon-init",body:()=>ZQ},{name:"beacon-refresh",body:()=>$Q}];fQ=`${A}
144
+ `,MZ,I="<!-- beacon:workflow:start -->",JQ="<!-- beacon:workflow:end -->",RQ;var zQ=T(()=>{MZ=[{name:"beacon-init",body:()=>$Q},{name:"beacon-refresh",body:()=>YQ}];RQ=`${I}
145
145
  ## Beacon \u2014 feature workflow
146
146
 
147
147
  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:
@@ -195,18 +195,18 @@ Register them all in that single batched call. If a plan added five features, th
195
195
  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.
196
196
 
197
197
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
198
- ${YQ}`});import{existsSync as IQ,mkdirSync as zQ,readFileSync as E,rmSync as fZ,writeFileSync as O}from"fs";import{dirname as AQ,join as D}from"path";function qQ(Q){try{return JSON.parse(E(Q,"utf8"))}catch{return{}}}function DQ(Q,Z){zQ(AQ(Q),{recursive:!0}),O(Q,JSON.stringify(Z,null,2)+`
199
- `)}function y(Q,Z){let $=qQ(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((X)=>X.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),DQ(Q,$),!0}function k(Q,Z){return(qQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function L(Q,Z){let $=qQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((X)=>{let q=X.hooks?.length??0,z=(X.hooks??[]).filter((U)=>U.command!==Z.command);if(z.length!==q)J=!0;return{...X,hooks:z}}).filter((X)=>(X.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 DQ(Q,$),!0}function _(Q,Z,$,Y){let J=`${Z}
198
+ ${JQ}`});import{existsSync as bQ,mkdirSync as qQ,readFileSync as E,rmSync as RZ,writeFileSync as O}from"fs";import{dirname as DQ,join as A}from"path";function XQ(Q){try{return JSON.parse(E(Q,"utf8"))}catch{return{}}}function IQ(Q,Z){qQ(DQ(Q),{recursive:!0}),O(Q,JSON.stringify(Z,null,2)+`
199
+ `)}function k(Q,Z){let $=XQ(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((X)=>X.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),IQ(Q,$),!0}function L(Q,Z){return(XQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function _(Q,Z){let $=XQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((X)=>{let q=X.hooks?.length??0,z=(X.hooks??[]).filter((U)=>U.command!==Z.command);if(z.length!==q)J=!0;return{...X,hooks:z}}).filter((X)=>(X.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 IQ(Q,$),!0}function h(Q,Z,$,Y){let J=`${Z}
200
200
  ${Y.trim()}
201
201
  ${$}`,V="";try{V=E(Q,"utf8")}catch{}let X=new RegExp(`${Z}[\\s\\S]*?${$}`);V=X.test(V)?V.replace(X,J):V.trim()?`${V.trim()}
202
202
 
203
203
  ${J}
204
204
  `:`${J}
205
- `,zQ(AQ(Q),{recursive:!0}),O(Q,V.endsWith(`
205
+ `,qQ(DQ(Q),{recursive:!0}),O(Q,V.endsWith(`
206
206
  `)?V:`${V}
207
- `)}function w(Q,Z){try{return E(Q,"utf8").includes(Z)}catch{return!1}}function h(Q,Z,$){let Y="";try{Y=E(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,`
207
+ `)}function g(Q,Z){try{return E(Q,"utf8").includes(Z)}catch{return!1}}function S(Q,Z,$){let Y="";try{Y=E(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,`
208
208
 
209
- `).trimStart();return O(Q,V),!0}function S(Q,Z,$){let Y=D(Q,Z);zQ(Y,{recursive:!0});let J=D(Y,"SKILL.md");return O(J,$),J}function g(Q,Z){return IQ(D(Q,Z,"SKILL.md"))}function m(Q,Z){let $=D(Q,Z);if(!IQ($))return!1;return fZ($,{recursive:!0,force:!0}),!0}var XQ=()=>{};import{mkdirSync as bZ,renameSync as IZ,rmSync as AZ,writeFileSync as DZ}from"fs";import{dirname as EZ}from"path";function WQ(Q,Z){bZ(EZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{DZ($,Z),IZ($,Q)}catch(Y){throw AZ($,{force:!0}),Y}}var EQ=()=>{};import{existsSync as OZ}from"fs";import{homedir as yZ}from"os";import{join as p}from"path";function kZ(){return process.env.HOME||process.env.USERPROFILE||yZ()}function LZ(Q,Z){return S(UQ(),Q,Z)}function LQ(Q){return g(UQ(),Q)}function _Z(Q){return m(UQ(),Q)}function hZ(Q){return y(BQ(),Q)}function SZ(Q){return k(BQ(),Q)}function mZ(Q){return L(BQ(),Q)}function pZ(Q){_(HQ(),PQ,kQ,Q)}function _Q(){return w(HQ(),PQ)}function cZ(){return h(HQ(),PQ,kQ)}function Y1(){let Q={};for(let $ of j)Q[$]=LQ($);let Z={};for(let $ of jQ)Z[$.event]=SZ({event:$.event,command:$.command});return{homeExists:OZ(c()),skills:Q,hooks:Z,claudeMdBlock:_Q()}}async function dZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (VQ(),JQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let q of j){if(!LQ(q))J.push(q);LZ(q,Y[q])}let V=0;for(let q of jQ)if(hZ({event:q.event,matcher:q.matcher,command:q.command}))V++;let X=_Q();return pZ(GQ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!X}}async function hQ(){let Q;try{Q={ok:!0,...await dZ()}}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(() => (yQ(),OQ));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 J1(){let Q=[];for(let Y of j)if(_Z(Y))Q.push(Y);let Z=0;for(let Y of jQ)if(mZ(Y))Z++;let $=cZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}var c=()=>p(kZ(),".claude"),UQ=()=>p(c(),"skills"),BQ=()=>p(c(),"settings.json"),HQ=()=>p(c(),"CLAUDE.md"),PQ="<!-- beacon:global:start -->",kQ="<!-- beacon:global:end -->",j,jQ,GQ=`## Beacon (visual planning panel)
209
+ `).trimStart();return O(Q,V),!0}function m(Q,Z,$){let Y=A(Q,Z);qQ(Y,{recursive:!0});let J=A(Y,"SKILL.md");return O(J,$),J}function w(Q,Z){return bQ(A(Q,Z,"SKILL.md"))}function p(Q,Z){let $=A(Q,Z);if(!bQ($))return!1;return RZ($,{recursive:!0,force:!0}),!0}var j,y=`## Beacon (visual planning panel)
210
210
 
211
211
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
212
212
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -227,24 +227,24 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
227
227
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
228
228
  on the /map and /db boards (added features, attached subtasks, edited columns, new
229
229
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
230
- verbatim. Do NOT implement until the tool returns approval.`;var xQ=N(()=>{XQ();j=["beacon-init","beacon-refresh","beacon-plan"],jQ=[{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."}]});var OQ={};QQ(OQ,{setupCodexAssets:()=>tZ,removeCodexMcp:()=>aQ,removeCodexArtifacts:()=>rZ,hasCodexMcp:()=>CQ,ensureCodexMcp:()=>lQ,codexMcpProblem:()=>nZ,codexDetected:()=>pQ,auditCodex:()=>sZ,CODEX_HOOKS:()=>t});import{readFileSync as n}from"fs";import{homedir as lZ}from"os";import{join as R}from"path";function SQ(){return process.env.HOME||process.env.USERPROFILE||lZ()}function pQ(){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 u(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function CQ(){try{return Boolean(u(n(C(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function nZ(){let Q="";try{Q=n(C(),"utf8")}catch{return null}let Z=u(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${F}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${F}`;return null}function lQ(){let Q="",Z=!1;try{Q=n(C(),"utf8"),Z=!0}catch{}if(Z){let V=u(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${F}`};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 ${F}`}}let $=!Q?"":Q.endsWith(`
230
+ verbatim. Do NOT implement until the tool returns approval.`;var WQ=T(()=>{j=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as fZ,renameSync as bZ,rmSync as DZ,writeFileSync as IZ}from"fs";import{dirname as AZ}from"path";function UQ(Q,Z){fZ(AZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{IZ($,Z),bZ($,Q)}catch(Y){throw DZ($,{force:!0}),Y}}var AQ=()=>{};var SQ={};ZQ(SQ,{setupCodexAssets:()=>kZ,removeCodexMcp:()=>hQ,removeCodexArtifacts:()=>_Z,hasCodexMcp:()=>jQ,ensureCodexMcp:()=>_Q,codexMcpProblem:()=>yZ,codexDetected:()=>yQ,auditCodex:()=>LZ,CODEX_HOOKS:()=>n});import{readFileSync as a}from"fs";import{homedir as EZ}from"os";import{join as R}from"path";function EQ(){return process.env.HOME||process.env.USERPROFILE||EZ()}function yQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(BQ===void 0)BQ=Bun.which("codex")!==null;return BQ}function u(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function jQ(){try{return Boolean(u(a(v(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function yZ(){let Q="";try{Q=a(v(),"utf8")}catch{return null}let Z=u(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${F}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${F}`;return null}function _Q(){let Q="",Z=!1;try{Q=a(v(),"utf8"),Z=!0}catch{}if(Z){let V=u(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${F}`};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 ${F}`}}let $=!Q?"":Q.endsWith(`
231
231
  `)?`
232
232
  `:`
233
233
 
234
- `,Y=Q+$+aZ;if(u(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${F}`};return WQ(C(),Y),{added:!0}}function aQ(){let Q="";try{Q=n(C(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
235
- `),$=Z.indexOf(cQ);if($===-1)return{removed:!1,skipped:CQ()};let Y=Z.indexOf(dQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
234
+ `,Y=Q+$+OZ;if(u(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${F}`};return UQ(v(),Y),{added:!0}}function hQ(){let Q="";try{Q=a(v(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
235
+ `),$=Z.indexOf(kQ);if($===-1)return{removed:!1,skipped:jQ()};let Y=Z.indexOf(LQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
236
236
  `).replace(/\n{3,}/g,`
237
237
 
238
- `).replace(/^\n+/,"");if(u(J)===null)return{removed:!1,skipped:!0};return WQ(C(),J),{removed:!0}}async function tZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (VQ(),JQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of j){if(!g(l(),z))J.push(z);S(l(),z,Y[z])}let V=0;for(let z of t)if(y(vQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=w(d(),a);_(d(),a,mQ,GQ);let q=lQ();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!X,mcp:q}}function sZ(){let Q={};for(let $ of j)Q[$]=g(l(),$);let Z={};for(let $ of t)Z[$.event]=k(vQ(),{event:$.event,command:$.command});return{detected:pQ(),skills:Q,hooks:Z,agentsMdBlock:w(d(),a),mcp:CQ()}}function rZ(){let Q=[];for(let J of j)if(m(l(),J))Q.push(J);let Z=0;for(let J of t)if(L(vQ(),{event:J.event,command:J.command}))Z++;let $=h(d(),a,mQ),Y=aQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var NQ=()=>R(SQ(),".codex"),vQ=()=>R(NQ(),"hooks.json"),C=()=>R(NQ(),"config.toml"),d=()=>R(NQ(),"AGENTS.md"),l=()=>R(SQ(),".agents","skills"),a="<!-- beacon:global:start -->",mQ="<!-- beacon:global:end -->",t,KQ,cQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",dQ="# beacon:end",aZ,F="add it manually: codex mcp add beacon -- beacon mcp";var yQ=N(()=>{XQ();EQ();xQ();t=[{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."}];aZ=`${cQ}
238
+ `).replace(/^\n+/,"");if(u(J)===null)return{removed:!1,skipped:!0};return UQ(v(),J),{removed:!0}}async function kZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (zQ(),VQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of j){if(!w(d(),z))J.push(z);m(d(),z,Y[z])}let V=0;for(let z of n)if(k(PQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=g(c(),l);h(c(),l,OQ,y);let q=_Q();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!X,mcp:q}}function LZ(){let Q={};for(let $ of j)Q[$]=w(d(),$);let Z={};for(let $ of n)Z[$.event]=L(PQ(),{event:$.event,command:$.command});return{detected:yQ(),skills:Q,hooks:Z,agentsMdBlock:g(c(),l),mcp:jQ()}}function _Z(){let Q=[];for(let J of j)if(p(d(),J))Q.push(J);let Z=0;for(let J of n)if(_(PQ(),{event:J.event,command:J.command}))Z++;let $=S(c(),l,OQ),Y=hQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var HQ=()=>R(EQ(),".codex"),PQ=()=>R(HQ(),"hooks.json"),v=()=>R(HQ(),"config.toml"),c=()=>R(HQ(),"AGENTS.md"),d=()=>R(EQ(),".agents","skills"),l="<!-- beacon:global:start -->",OQ="<!-- beacon:global:end -->",n,BQ,kQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",LQ="# beacon:end",OZ,F="add it manually: codex mcp add beacon -- beacon mcp";var mQ=T(()=>{WQ();AQ();n=[{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."}];OZ=`${kQ}
239
239
  [mcp_servers.beacon]
240
240
  command = "beacon"
241
241
  args = ["mcp"]
242
- ${dQ}
243
- `});var tQ={};QQ(tQ,{provisionDb:()=>X0});import{createClient as oZ}from"@libsql/client";import{drizzle as iZ}from"drizzle-orm/libsql";import{migrate as eZ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as Q0}from"drizzle-orm/migrator";import{dirname as MQ,join as Z0}from"path";import{fileURLToPath as $0}from"url";async function s(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function z0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function nQ(Q){if(!await s(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 q0(Q){for(let[Z,$]of Object.entries(V0)){if(!await s(Q,Z))continue;let Y=await z0(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 X0(Q,Z=J0){let $=oZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;");let Y=await s($,"__drizzle_migrations"),J=await s($,"Node"),V=!1;if(J&&!Y){let q=Q0({migrationsFolder:Z})[0];if(q)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:[q.hash,q.folderMillis]}),V=!0}let X=await nQ($);if(await eZ(iZ($),{migrationsFolder:Z}),await nQ($)>X)V=!0;return await q0($),{migrated:V}}finally{$.close()}}var Y0,J0,V0;var sQ=N(async()=>{Y0=MQ(MQ(MQ($0(import.meta.url)))),J0=process.env.BEACON_MIGRATIONS_DIR||Z0(Y0,"drizzle"),V0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{AsyncLocalStorage as W0}from"async_hooks";import{spawnSync as U0}from"child_process";import{createHash as B0}from"crypto";import{existsSync as oQ,mkdirSync as r,readFileSync as iQ,writeFileSync as eQ}from"fs";import{homedir as H0}from"os";import{basename as P0,join as M}from"path";function x(){return process.env.BEACON_HOME||M(H0(),".beacon")}function TQ(){return M(x(),"workspaces.json")}function QZ(Q){return B0("sha256").update(Q).digest("hex").slice(0,12)}function g1(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 wQ(Q){return M(x(),Q)}function j0(Q){return`file:${M(wQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(iQ(TQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function gQ(Q){r(x(),{recursive:!0}),eQ(TQ(),JSON.stringify(Q,null,2))}function G0(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function G(Q){return f().find((Z)=>Z.id===Q)??null}function x0(Q,Z,$=new Date().toISOString()){let Y=QZ(Q),J=f(),V=J.find((z)=>z.id===Y),X={id:Y,path:Q,name:Z||V?.name||P0(Q),lastOpenedAt:$},q=[X,...J.filter((z)=>z.id!==Y)];return r(wQ(Y),{recursive:!0}),gQ(q),X}function F1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,gQ($)}function u1(Q){if(gQ(f().filter((Z)=>Z.id!==Q)),FQ()===Q)K0(G0()[0]?.id??null)}function ZZ(){return M(x(),"active")}function FQ(){try{return iQ(ZZ(),"utf8").trim()||null}catch{return null}}function K0(Q){r(x(),{recursive:!0}),eQ(ZZ(),Q??"")}function R1(){let Q=FQ();return Q?G(Q):null}function f1(){let Q=v0()??FQ();return Q?G(Q):null}function b1(Q){return G(Q)?.path??null}function I1(){return oQ(TQ())}var $Z="beacon_ws";function YZ(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 A1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&G(Z))return Z;let $=YZ(Q,$Z);if($&&G($))return $;return null}var N0="x-beacon-workspace-path";async function D1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&G(Z))return Z;let $=Q.headers.get(N0);if($&&(!Z||QZ($)===Z)){let J=x0($);return await C0(J.id),J.id}let Y=YZ(Q,$Z);if(Y&&G(Y))return Y;return null}var JZ=new W0;function E1(Q,Z){return Q?JZ.run(Q,Z):Z()}function v0(){return JZ.getStore()??null}var rQ=new Set;async function C0(Q){let Z=wQ(Q),$=M(Z,"db.sqlite"),Y=oQ($);if(Y&&rQ.has($))return{ok:!0,created:!1,migrated:!1};try{r(Z,{recursive:!0});let{provisionDb:J}=await sQ().then(() => tQ),V=await J(j0(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)}}}xQ();import{execSync as PZ,spawn as F0}from"child_process";import{mkdirSync as u0,openSync as R0,readFileSync as f0,writeFileSync as b0}from"fs";import{homedir as I0,platform as BZ}from"os";import{dirname as A0,join as i}from"path";import{fileURLToPath as D0}from"url";import{createHash as E0}from"crypto";var VZ=1500,zZ=345600000,y1=1800000,k1=3000;import{mkdirSync as S1,readFileSync as T0,writeFileSync as m1}from"fs";import{join as w0}from"path";var M0=["default","acceptEdits","bypassPermissions","auto"];function qZ(Q){return typeof Q==="string"&&M0.includes(Q)}function XZ(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 g0(){return w0(x(),"preferences.json")}function WZ(){try{let Q=JSON.parse(T0(g0(),"utf8"));return{planApprovalMode:qZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0}}catch{return{}}}function UZ(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`
242
+ ${LQ}
243
+ `});var nQ={};ZQ(nQ,{provisionDb:()=>X0});import{createClient as oZ}from"@libsql/client";import{drizzle as iZ}from"drizzle-orm/libsql";import{migrate as eZ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as Q0}from"drizzle-orm/migrator";import{dirname as CQ,join as Z0}from"path";import{fileURLToPath as $0}from"url";async function r(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function z0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function aQ(Q){if(!await r(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 q0(Q){for(let[Z,$]of Object.entries(V0)){if(!await r(Q,Z))continue;let Y=await z0(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 X0(Q,Z=J0){let $=oZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;");let Y=await r($,"__drizzle_migrations"),J=await r($,"Node"),V=!1;if(J&&!Y){let q=Q0({migrationsFolder:Z})[0];if(q)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:[q.hash,q.folderMillis]}),V=!0}let X=await aQ($);if(await eZ(iZ($),{migrationsFolder:Z}),await aQ($)>X)V=!0;return await q0($),{migrated:V}}finally{$.close()}}var Y0,J0,V0;var tQ=T(async()=>{Y0=CQ(CQ(CQ($0(import.meta.url)))),J0=process.env.BEACON_MIGRATIONS_DIR||Z0(Y0,"drizzle"),V0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});WQ();import{existsSync as hZ}from"fs";import{homedir as SZ}from"os";import{join as t}from"path";function mZ(){return process.env.HOME||process.env.USERPROFILE||SZ()}var s=()=>t(mZ(),".claude"),xQ=()=>t(s(),"skills"),GQ=()=>t(s(),"settings.json"),KQ=()=>t(s(),"CLAUDE.md"),NQ="<!-- beacon:global:start -->",pQ="<!-- beacon:global:end -->";var pZ=y,vQ=[{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 cZ(Q,Z){return m(xQ(),Q,Z)}function cQ(Q){return w(xQ(),Q)}function dZ(Q){return p(xQ(),Q)}function lZ(Q){return k(GQ(),Q)}function aZ(Q){return L(GQ(),Q)}function nZ(Q){return _(GQ(),Q)}function tZ(Q){h(KQ(),NQ,pQ,Q)}function dQ(){return g(KQ(),NQ)}function sZ(){return S(KQ(),NQ,pQ)}function X1(){let Q={};for(let $ of j)Q[$]=cQ($);let Z={};for(let $ of vQ)Z[$.event]=aZ({event:$.event,command:$.command});return{homeExists:hZ(s()),skills:Q,hooks:Z,claudeMdBlock:dQ()}}async function rZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (zQ(),VQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let q of j){if(!cQ(q))J.push(q);cZ(q,Y[q])}let V=0;for(let q of vQ)if(lZ({event:q.event,matcher:q.matcher,command:q.command}))V++;let X=dQ();return tZ(pZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!X}}async function lQ(){let Q;try{Q={ok:!0,...await rZ()}}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(() => (mQ(),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 W1(){let Q=[];for(let Y of j)if(dZ(Y))Q.push(Y);let Z=0;for(let Y of vQ)if(nZ(Y))Z++;let $=sZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as W0}from"async_hooks";import{spawnSync as U0}from"child_process";import{createHash as B0}from"crypto";import{existsSync as rQ,mkdirSync as o,readFileSync as oQ,writeFileSync as iQ}from"fs";import{homedir as H0}from"os";import{basename as P0,join as C}from"path";function G(){return process.env.BEACON_HOME||C(H0(),".beacon")}function MQ(){return C(G(),"workspaces.json")}function eQ(Q){return B0("sha256").update(Q).digest("hex").slice(0,12)}function g1(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 TQ(Q){return C(G(),Q)}function j0(Q){return`file:${C(TQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(oQ(MQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function gQ(Q){o(G(),{recursive:!0}),iQ(MQ(),JSON.stringify(Q,null,2))}function x0(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function x(Q){return f().find((Z)=>Z.id===Q)??null}function G0(Q,Z,$=new Date().toISOString()){let Y=eQ(Q),J=f(),V=J.find((z)=>z.id===Y),X={id:Y,path:Q,name:Z||V?.name||P0(Q),lastOpenedAt:$},q=[X,...J.filter((z)=>z.id!==Y)];return o(TQ(Y),{recursive:!0}),gQ(q),X}function w1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,gQ($)}function F1(Q){if(gQ(f().filter((Z)=>Z.id!==Q)),wQ()===Q)K0(x0()[0]?.id??null)}function QZ(){return C(G(),"active")}function wQ(){try{return oQ(QZ(),"utf8").trim()||null}catch{return null}}function K0(Q){o(G(),{recursive:!0}),iQ(QZ(),Q??"")}function u1(){let Q=wQ();return Q?x(Q):null}function R1(){let Q=v0()??wQ();return Q?x(Q):null}function f1(Q){return x(Q)?.path??null}function b1(){return rQ(MQ())}var ZZ="beacon_ws";function $Z(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 D1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&x(Z))return Z;let $=$Z(Q,ZZ);if($&&x($))return $;return null}var N0="x-beacon-workspace-path";async function I1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&x(Z))return Z;let $=Q.headers.get(N0);if($&&(!Z||eQ($)===Z)){let J=G0($);return await C0(J.id),J.id}let Y=$Z(Q,ZZ);if(Y&&x(Y))return Y;return null}var YZ=new W0;function A1(Q,Z){return Q?YZ.run(Q,Z):Z()}function v0(){return YZ.getStore()??null}var sQ=new Set;async function C0(Q){let Z=TQ(Q),$=C(Z,"db.sqlite"),Y=rQ($);if(Y&&sQ.has($))return{ok:!0,created:!1,migrated:!1};try{o(Z,{recursive:!0});let{provisionDb:J}=await tQ().then(() => nQ),V=await J(j0(Q));return sQ.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{execSync as HZ,spawn as F0}from"child_process";import{mkdirSync as u0,openSync as R0,readFileSync as f0,writeFileSync as b0}from"fs";import{homedir as D0,platform as UZ}from"os";import{dirname as I0,join as e}from"path";import{fileURLToPath as A0}from"url";import{createHash as E0}from"crypto";var JZ=1500,VZ=345600000,O1=1800000,y1=3000;import{mkdirSync as h1,readFileSync as T0,writeFileSync as S1}from"fs";import{join as g0}from"path";var M0=["default","acceptEdits","bypassPermissions","auto"];function zZ(Q){return typeof Q==="string"&&M0.includes(Q)}function qZ(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 w0(){return g0(G(),"preferences.json")}function XZ(){try{let Q=JSON.parse(T0(w0(),"utf8"));return{planApprovalMode:zZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0}}catch{return{}}}function WZ(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`
244
244
 
245
245
  This plan created these roadmap feature(s):
246
246
  `+Z.join(`
247
- `)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` 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."}var O0=i(A0(D0(import.meta.url)),".."),RQ=process.env.BEACON_HOME||i(I0(),".beacon"),jZ=i(RQ,"server.json"),HZ=process.env.PORT||"4319";function y0(Q){try{return process.kill(Q,0),!0}catch{return!1}}function k0(Q){try{return JSON.parse(f0(Q,"utf8"))}catch{return null}}async function GZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function L0(Q,Z=60){for(let $=0;$<Z;$++){if(await GZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function _0(){u0(RQ,{recursive:!0});let Q=R0(i(RQ,"server.log"),"a"),Z={...process.env,PORT:HZ,BEACON_NO_OPEN:"1"};delete Z.BEACON_REPO,delete Z.BEACON_DATA_DIR,delete Z.DATABASE_URL;let $=F0("bun",["run","dev"],{cwd:O0,env:Z,detached:!0,stdio:["ignore",Q,Q]});$.unref();let Y={pid:$.pid??0,port:HZ};return b0(jZ,JSON.stringify(Y)),Y}async function h0(){let Q=k0(jZ);if(Q&&y0(Q.pid)&&await GZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let{port:Z}=_0();return await L0(`http://localhost:${Z}/api/workspace`),Z}function S0(Q){if(process.env.BEACON_NO_OPEN)return;let Z=BZ()==="darwin"?"open":BZ()==="win32"?"start":"xdg-open";try{PZ(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}function m0(){try{return PZ("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function p0(Q){return E0("sha256").update(Q).digest("hex").slice(0,12)}async function c0(){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 uQ(Q,Z){return XZ(Q,Z)}function o(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function K(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await hQ();let Z=(await c0())?.tool_input?.plan;if(!Z||!Z.trim())K(uQ());let Y=`http://localhost:${await h0()}`,J=m0()||process.cwd(),V=p0(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let X=Z.split(`
248
- `,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",q=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:X,markdown:Z})});if(q.status===422){let B=await q.json().catch(()=>({}));K(o(B.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!q.ok)K(uQ());if(!await fetch(`${Y}/api/plan/presence`,{headers:{"x-beacon-workspace":V}}).then((B)=>B.json()).then((B)=>!!B?.live).catch(()=>!1)){let B=encodeURIComponent(`/plan?ws=${V}`);S0(`${Y}/api/workspace/activate?id=${V}&redirect=${B}`)}let U=Date.now()+zZ,T=(B)=>new Promise((e)=>setTimeout(e,B));while(Date.now()<U){await T(VZ);let B=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((e)=>e.json()).catch(()=>null);if(!B)continue;if(B.kind==="approved")K(uQ(WZ().planApprovalMode,UZ(B.features)));if(B.kind==="discarded")K(o("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(B.kind==="feedback")K(o(`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):
247
+ `)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` 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."}var O0=e(I0(A0(import.meta.url)),".."),uQ=process.env.BEACON_HOME||e(D0(),".beacon"),PZ=e(uQ,"server.json"),BZ=process.env.PORT||"4319";function y0(Q){try{return process.kill(Q,0),!0}catch{return!1}}function k0(Q){try{return JSON.parse(f0(Q,"utf8"))}catch{return null}}async function jZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function L0(Q,Z=60){for(let $=0;$<Z;$++){if(await jZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function _0(){u0(uQ,{recursive:!0});let Q=R0(e(uQ,"server.log"),"a"),Z={...process.env,PORT:BZ,BEACON_NO_OPEN:"1"};delete Z.BEACON_REPO,delete Z.BEACON_DATA_DIR,delete Z.DATABASE_URL;let $=F0("bun",["run","dev"],{cwd:O0,env:Z,detached:!0,stdio:["ignore",Q,Q]});$.unref();let Y={pid:$.pid??0,port:BZ};return b0(PZ,JSON.stringify(Y)),Y}async function h0(){let Q=k0(PZ);if(Q&&y0(Q.pid)&&await jZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let{port:Z}=_0();return await L0(`http://localhost:${Z}/api/workspace`),Z}function S0(Q){if(process.env.BEACON_NO_OPEN)return;let Z=UZ()==="darwin"?"open":UZ()==="win32"?"start":"xdg-open";try{HZ(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}function m0(){try{return HZ("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function p0(Q){return E0("sha256").update(Q).digest("hex").slice(0,12)}async function c0(){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 FQ(Q,Z){return qZ(Q,Z)}function i(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function K(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await lQ();let Z=(await c0())?.tool_input?.plan;if(!Z||!Z.trim())K(FQ());let Y=`http://localhost:${await h0()}`,J=m0()||process.cwd(),V=p0(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let X=Z.split(`
248
+ `,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",q=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:X,markdown:Z})});if(q.status===422){let B=await q.json().catch(()=>({}));K(i(B.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!q.ok)K(FQ());if(!await fetch(`${Y}/api/plan/presence`,{headers:{"x-beacon-workspace":V}}).then((B)=>B.json()).then((B)=>!!B?.live).catch(()=>!1)){let B=encodeURIComponent(`/plan?ws=${V}`);S0(`${Y}/api/workspace/activate?id=${V}&redirect=${B}`)}let U=Date.now()+VZ,M=(B)=>new Promise((QQ)=>setTimeout(QQ,B));while(Date.now()<U){await M(JZ);let B=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((QQ)=>QQ.json()).catch(()=>null);if(!B)continue;if(B.kind==="approved")K(FQ(XZ().planApprovalMode,WZ(B.features)));if(B.kind==="discarded")K(i("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(B.kind==="feedback")K(i(`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):
249
249
 
250
- `+B.feedback))}K(o("Beacon plan review timed out without a verdict. Re-present the plan and ask the user to review it."))})();
250
+ `+B.feedback))}K(i("Beacon plan review timed out without a verdict. Re-present the plan and ask the user to review it."))})();
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var xZ=Object.defineProperty;var NZ=(Q)=>Q;function GZ(Q,Z){this[Q]=NZ.bind(null,Z)}var zQ=(Q,Z)=>{for(var $ in Z)xZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:GZ.bind(Z,$)})};var C=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var WQ={};zQ(WQ,{removeRepoAssets:()=>PQ,installRefreshSkill:()=>KZ,installPlanSkill:()=>CZ,installInitSkill:()=>uZ,installCodexRepoSkills:()=>fZ,ensureWorkflowDoc:()=>TZ,ensureMcp:()=>wZ,auditRepo:()=>FZ,REFRESH_SKILL:()=>XQ,PLAN_SKILL:()=>_Q,INIT_SKILL:()=>qQ});import{existsSync as M,mkdirSync as L,readFileSync as v,rmSync as y,writeFileSync as W}from"fs";import{join as q}from"path";function uZ(Q){let Z=q(Q,".claude","skills","beacon-init");L(Z,{recursive:!0});let $=q(Z,"SKILL.md");return W($,qQ),$}function KZ(Q){let Z=q(Q,".claude","skills","beacon-refresh");L(Z,{recursive:!0});let $=q(Z,"SKILL.md");return W($,XQ),$}function CZ(Q){let Z=q(Q,".claude","skills","beacon-plan");L(Z,{recursive:!0});let $=q(Z,"SKILL.md");return W($,_Q),$}function fZ(Q){let Z=[];for(let $ of MZ){let J=q(Q,".agents","skills",$.name);L(J,{recursive:!0});let Y=q(J,"SKILL.md");W(Y,$.body()),Z.push(Y)}return Z}function TZ(Q){let Z=q(Q,"AGENTS.md"),$="";try{$=v(Z,"utf8")}catch{}let J=new RegExp(`${_}[\\s\\S]*?${UQ}`);$=J.test($)?$.replace(J,LQ):`${$.trim()}
3
+ var vZ=Object.defineProperty;var xZ=(Q)=>Q;function NZ(Q,Z){this[Q]=xZ.bind(null,Z)}var qQ=(Q,Z)=>{for(var $ in Z)vZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:NZ.bind(Z,$)})};var F=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var HQ={};qQ(HQ,{removeRepoAssets:()=>WQ,installRefreshSkill:()=>GZ,installPlanSkill:()=>KZ,installInitSkill:()=>uZ,installCodexRepoSkills:()=>MZ,ensureWorkflowDoc:()=>fZ,ensureMcp:()=>TZ,auditRepo:()=>wZ,REFRESH_SKILL:()=>UQ,PLAN_SKILL:()=>kQ,INIT_SKILL:()=>XQ});import{existsSync as C,mkdirSync as k,readFileSync as v,rmSync as y,writeFileSync as H}from"fs";import{join as q}from"path";function uZ(Q){let Z=q(Q,".claude","skills","beacon-init");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return H($,XQ),$}function GZ(Q){let Z=q(Q,".claude","skills","beacon-refresh");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return H($,UQ),$}function KZ(Q){let Z=q(Q,".claude","skills","beacon-plan");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return H($,kQ),$}function MZ(Q){let Z=[];for(let $ of CZ){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 fZ(Q){let Z=q(Q,"AGENTS.md"),$="";try{$=v(Z,"utf8")}catch{}let J=new RegExp(`${_}[\\s\\S]*?${PQ}`);$=J.test($)?$.replace(J,yQ):`${$.trim()}
4
4
 
5
- ${LQ}
6
- `.trimStart(),W(Z,$.endsWith(`
5
+ ${yQ}
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))W(Y,`${V?`${V.trim()}
8
+ `);let Y=q(Q,"CLAUDE.md"),V="";try{V=v(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))H(Y,`${V?`${V.trim()}
9
9
 
10
10
  `:""}@AGENTS.md
11
- `)}function wZ(Q){let Z=q(Q,".mcp.json"),$={};try{$=JSON.parse(v(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},W(Z,JSON.stringify($,null,2)+`
12
- `),{path:Z,added:!0}}function FZ(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(_)}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 PQ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let P=q(Q,".claude","skills",z);if(M(P))y(P,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let P=q(Q,".agents","skills",z);if(M(P))y(P,{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)y(J,{force:!0});else W(J,JSON.stringify(z,null,2)+`
13
- `)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=v(V,"utf8"),P=new RegExp(`\\n?${_}[\\s\\S]*?${UQ}\\n?`);if(P.test(z)){let VQ=z.replace(P,`
11
+ `)}function TZ(Q){let Z=q(Q,".mcp.json"),$={};try{$=JSON.parse(v(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},H(Z,JSON.stringify($,null,2)+`
12
+ `),{path:Z,added:!0}}function wZ(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(_)}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":C(q(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":C(q(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":C(q(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":C(q(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function WQ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let P=q(Q,".claude","skills",z);if(C(P))y(P,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let P=q(Q,".agents","skills",z);if(C(P))y(P,{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)y(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
13
+ `)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=v(V,"utf8"),P=new RegExp(`\\n?${_}[\\s\\S]*?${PQ}\\n?`);if(P.test(z)){let zQ=z.replace(P,`
14
14
  `).replace(/\n{3,}/g,`
15
15
 
16
- `).trimStart();W(V,VQ.endsWith(`
17
- `)?VQ:`${VQ}
18
- `),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=v(U,"utf8"),P=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(P!==z){if(!P.trim())y(U,{force:!0});else W(U,P);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:X}}var qQ=`---
16
+ `).trimStart();H(V,zQ.endsWith(`
17
+ `)?zQ:`${zQ}
18
+ `),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=v(U,"utf8"),P=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(P!==z){if(!P.trim())y(U,{force:!0});else H(U,P);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:X}}var XQ=`---
19
19
  name: beacon-init
20
20
  description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
21
21
  ---
@@ -52,7 +52,7 @@ A single \`beacon_init_persist\` MCP tool call with:
52
52
  If \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-init.
53
53
 
54
54
  After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
55
- `,XQ=`---
55
+ `,UQ=`---
56
56
  name: beacon-refresh
57
57
  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.
58
58
  ---
@@ -99,7 +99,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
99
99
  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.
100
100
 
101
101
  After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
102
- `,_Q=`---
102
+ `,kQ=`---
103
103
  name: beacon-plan
104
104
  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.
105
105
  ---
@@ -141,7 +141,7 @@ If it returns feedback, revise and call it again.
141
141
  If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
142
142
  with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
143
143
  run \`beacon\` in this repo once.
144
- `,MZ,_="<!-- beacon:workflow:start -->",UQ="<!-- beacon:workflow:end -->",LQ;var k=C(()=>{MZ=[{name:"beacon-init",body:()=>qQ},{name:"beacon-refresh",body:()=>XQ}];LQ=`${_}
144
+ `,CZ,_="<!-- beacon:workflow:start -->",PQ="<!-- beacon:workflow:end -->",yQ;var L=F(()=>{CZ=[{name:"beacon-init",body:()=>XQ},{name:"beacon-refresh",body:()=>UQ}];yQ=`${_}
145
145
  ## Beacon \u2014 feature workflow
146
146
 
147
147
  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:
@@ -195,18 +195,18 @@ Register them all in that single batched call. If a plan added five features, th
195
195
  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.
196
196
 
197
197
  Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
198
- ${UQ}`});import{existsSync as kQ,mkdirSync as HQ,readFileSync as S,rmSync as gZ,writeFileSync as p}from"fs";import{dirname as hQ,join as h}from"path";function BQ(Q){try{return JSON.parse(S(Q,"utf8"))}catch{return{}}}function SQ(Q,Z){HQ(hQ(Q),{recursive:!0}),p(Q,JSON.stringify(Z,null,2)+`
199
- `)}function m(Q,Z){let $=BQ(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}]}),SQ(Q,$),!0}function c(Q,Z){return(BQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function l(Q,Z){let $=BQ(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((P)=>P.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 SQ(Q,$),!0}function t(Q,Z,$,J){let Y=`${Z}
198
+ ${PQ}`});import{existsSync as _Q,mkdirSync as jQ,readFileSync as S,rmSync as FZ,writeFileSync as p}from"fs";import{dirname as LQ,join as h}from"path";function BQ(Q){try{return JSON.parse(S(Q,"utf8"))}catch{return{}}}function hQ(Q,Z){jQ(LQ(Q),{recursive:!0}),p(Q,JSON.stringify(Z,null,2)+`
199
+ `)}function c(Q,Z){let $=BQ(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}]}),hQ(Q,$),!0}function l(Q,Z){return(BQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function t(Q,Z){let $=BQ(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((P)=>P.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 hQ(Q,$),!0}function n(Q,Z,$,J){let Y=`${Z}
200
200
  ${J.trim()}
201
201
  ${$}`,V="";try{V=S(Q,"utf8")}catch{}let X=new RegExp(`${Z}[\\s\\S]*?${$}`);V=X.test(V)?V.replace(X,Y):V.trim()?`${V.trim()}
202
202
 
203
203
  ${Y}
204
204
  `:`${Y}
205
- `,HQ(hQ(Q),{recursive:!0}),p(Q,V.endsWith(`
205
+ `,jQ(LQ(Q),{recursive:!0}),p(Q,V.endsWith(`
206
206
  `)?V:`${V}
207
- `)}function g(Q,Z){try{return S(Q,"utf8").includes(Z)}catch{return!1}}function n(Q,Z,$){let J="";try{J=S(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,`
207
+ `)}function g(Q,Z){try{return S(Q,"utf8").includes(Z)}catch{return!1}}function d(Q,Z,$){let J="";try{J=S(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,`
208
208
 
209
- `).trimStart();return p(Q,V),!0}function d(Q,Z,$){let J=h(Q,Z);HQ(J,{recursive:!0});let Y=h(J,"SKILL.md");return p(Y,$),Y}function R(Q,Z){return kQ(h(Q,Z,"SKILL.md"))}function a(Q,Z){let $=h(Q,Z);if(!kQ($))return!1;return gZ($,{recursive:!0,force:!0}),!0}var jQ=()=>{};import{mkdirSync as RZ,renameSync as EZ,rmSync as IZ,writeFileSync as bZ}from"fs";import{dirname as DZ}from"path";function vQ(Q,Z){RZ(DZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{bZ($,Z),EZ($,Q)}catch(J){throw IZ($,{force:!0}),J}}var pQ=()=>{};import{existsSync as OZ}from"fs";import{homedir as AZ}from"os";import{join as s}from"path";function yZ(){return process.env.HOME||process.env.USERPROFILE||AZ()}function LZ(Q,Z){return d(NQ(),Q,Z)}function lQ(Q){return R(NQ(),Q)}function _Z(Q){return a(NQ(),Q)}function kZ(Q){return m(GQ(),Q)}function hZ(Q){return c(GQ(),Q)}function SZ(Q){return l(GQ(),Q)}function pZ(Q){t(uQ(),KQ,cQ,Q)}function tQ(){return g(uQ(),KQ)}function mZ(){return n(uQ(),KQ,cQ)}function nQ(){let Q={};for(let $ of H)Q[$]=lQ($);let Z={};for(let $ of E)Z[$.event]=hZ({event:$.event,command:$.command});return{homeExists:OZ(r()),skills:Q,hooks:Z,claudeMdBlock:tQ()}}async function cZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (k(),WQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let U of H){if(!lQ(U))Y.push(U);LZ(U,J[U])}let V=0;for(let U of E)if(kZ({event:U.event,matcher:U.matcher,command:U.command}))V++;let X=tQ();return pZ(CQ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!X}}async function A0(){let Q;try{Q={ok:!0,...await cZ()}}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(() => (xQ(),mQ));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 dQ(){let Q=[];for(let J of H)if(_Z(J))Q.push(J);let Z=0;for(let J of E)if(SZ(J))Z++;let $=mZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}var r=()=>s(yZ(),".claude"),NQ=()=>s(r(),"skills"),GQ=()=>s(r(),"settings.json"),uQ=()=>s(r(),"CLAUDE.md"),KQ="<!-- beacon:global:start -->",cQ="<!-- beacon:global:end -->",H,E,CQ=`## Beacon (visual planning panel)
209
+ `).trimStart();return p(Q,V),!0}function a(Q,Z,$){let J=h(Q,Z);jQ(J,{recursive:!0});let Y=h(J,"SKILL.md");return p(Y,$),Y}function R(Q,Z){return _Q(h(Q,Z,"SKILL.md"))}function s(Q,Z){let $=h(Q,Z);if(!_Q($))return!1;return FZ($,{recursive:!0,force:!0}),!0}var W,m=`## Beacon (visual planning panel)
210
210
 
211
211
  This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
212
212
  agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
@@ -227,20 +227,20 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
227
227
  Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
228
228
  on the /map and /db boards (added features, attached subtasks, edited columns, new
229
229
  endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
230
- verbatim. Do NOT implement until the tool returns approval.`;var MQ=C(()=>{jQ();H=["beacon-init","beacon-refresh","beacon-plan"],E=[{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."}]});var mQ={};zQ(mQ,{setupCodexAssets:()=>dZ,removeCodexMcp:()=>QZ,removeCodexArtifacts:()=>RQ,hasCodexMcp:()=>FQ,ensureCodexMcp:()=>eQ,codexMcpProblem:()=>nZ,codexDetected:()=>rQ,auditCodex:()=>gQ,CODEX_HOOKS:()=>T});import{readFileSync as QQ}from"fs";import{homedir as lZ}from"os";import{join as D}from"path";function aQ(){return process.env.HOME||process.env.USERPROFILE||lZ()}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 b(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function FQ(){try{return Boolean(b(QQ(f(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function nZ(){let Q="";try{Q=QQ(f(),"utf8")}catch{return null}let Z=b(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=QQ(f(),"utf8"),Z=!0}catch{}if(Z){let V=b(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(`
230
+ verbatim. Do NOT implement until the tool returns approval.`;var vQ=F(()=>{W=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as gZ,renameSync as RZ,rmSync as EZ,writeFileSync as IZ}from"fs";import{dirname as bZ}from"path";function xQ(Q,Z){gZ(bZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{IZ($,Z),RZ($,Q)}catch(J){throw EZ($,{force:!0}),J}}var SQ=()=>{};var aQ={};qQ(aQ,{setupCodexAssets:()=>yZ,removeCodexMcp:()=>dQ,removeCodexArtifacts:()=>MQ,hasCodexMcp:()=>KQ,ensureCodexMcp:()=>nQ,codexMcpProblem:()=>AZ,codexDetected:()=>cQ,auditCodex:()=>CQ,CODEX_HOOKS:()=>f});import{readFileSync as e}from"fs";import{homedir as DZ}from"os";import{join as b}from"path";function pQ(){return process.env.HOME||process.env.USERPROFILE||DZ()}function cQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(NQ===void 0)NQ=Bun.which("codex")!==null;return NQ}function I(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function KQ(){try{return Boolean(I(e(M(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function AZ(){let Q="";try{Q=e(M(),"utf8")}catch{return null}let Z=I(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${E}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${E}`;return null}function nQ(){let Q="",Z=!1;try{Q=e(M(),"utf8"),Z=!0}catch{}if(Z){let V=I(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${E}`};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 ${E}`}}let $=!Q?"":Q.endsWith(`
231
231
  `)?`
232
232
  `:`
233
233
 
234
- `,J=Q+$+tZ;if(b(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${I}`};return vQ(f(),J),{added:!0}}function QZ(){let Q="";try{Q=QQ(f(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
235
- `),$=Z.indexOf(oQ);if($===-1)return{removed:!1,skipped:FQ()};let J=Z.indexOf(iQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
234
+ `,J=Q+$+OZ;if(I(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${E}`};return xQ(M(),J),{added:!0}}function dQ(){let Q="";try{Q=e(M(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
235
+ `),$=Z.indexOf(lQ);if($===-1)return{removed:!1,skipped:KQ()};let J=Z.indexOf(tQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
236
236
  `).replace(/\n{3,}/g,`
237
237
 
238
- `).replace(/^\n+/,"");if(b(Y)===null)return{removed:!1,skipped:!0};return vQ(f(),Y),{removed:!0}}async function dZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (k(),WQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of H){if(!R(i(),z))Y.push(z);d(i(),z,J[z])}let V=0;for(let z of T)if(m(wQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=g(o(),e);t(o(),e,sQ,CQ);let U=eQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!X,mcp:U}}function gQ(){let Q={};for(let $ of H)Q[$]=R(i(),$);let Z={};for(let $ of T)Z[$.event]=c(wQ(),{event:$.event,command:$.command});return{detected:rQ(),skills:Q,hooks:Z,agentsMdBlock:g(o(),e),mcp:FQ()}}function RQ(){let Q=[];for(let Y of H)if(a(i(),Y))Q.push(Y);let Z=0;for(let Y of T)if(l(wQ(),{event:Y.event,command:Y.command}))Z++;let $=n(o(),e,sQ),J=QZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var TQ=()=>D(aQ(),".codex"),wQ=()=>D(TQ(),"hooks.json"),f=()=>D(TQ(),"config.toml"),o=()=>D(TQ(),"AGENTS.md"),i=()=>D(aQ(),".agents","skills"),e="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->",T,fQ,oQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",iQ="# beacon:end",tZ,I="add it manually: codex mcp add beacon -- beacon mcp";var xQ=C(()=>{jQ();pQ();MQ();T=[{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."}];tZ=`${oQ}
238
+ `).replace(/^\n+/,"");if(I(Y)===null)return{removed:!1,skipped:!0};return xQ(M(),Y),{removed:!0}}async function yZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (L(),HQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of W){if(!R(o(),z))Y.push(z);a(o(),z,J[z])}let V=0;for(let z of f)if(c(GQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=g(r(),i);n(r(),i,mQ,m);let U=nQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!X,mcp:U}}function CQ(){let Q={};for(let $ of W)Q[$]=R(o(),$);let Z={};for(let $ of f)Z[$.event]=l(GQ(),{event:$.event,command:$.command});return{detected:cQ(),skills:Q,hooks:Z,agentsMdBlock:g(r(),i),mcp:KQ()}}function MQ(){let Q=[];for(let Y of W)if(s(o(),Y))Q.push(Y);let Z=0;for(let Y of f)if(t(GQ(),{event:Y.event,command:Y.command}))Z++;let $=d(r(),i,mQ),J=dQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var uQ=()=>b(pQ(),".codex"),GQ=()=>b(uQ(),"hooks.json"),M=()=>b(uQ(),"config.toml"),r=()=>b(uQ(),"AGENTS.md"),o=()=>b(pQ(),".agents","skills"),i="<!-- beacon:global:start -->",mQ="<!-- beacon:global:end -->",f,NQ,lQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",tQ="# beacon:end",OZ,E="add it manually: codex mcp add beacon -- beacon mcp";var fQ=F(()=>{vQ();SQ();f=[{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."}];OZ=`${lQ}
239
239
  [mcp_servers.beacon]
240
240
  command = "beacon"
241
241
  args = ["mcp"]
242
- ${iQ}
243
- `});var $Z={};zQ($Z,{provisionDb:()=>V0});import{createClient as aZ}from"@libsql/client";import{drizzle as sZ}from"drizzle-orm/libsql";import{migrate as rZ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as oZ}from"drizzle-orm/migrator";import{dirname as EQ,join as iZ}from"path";import{fileURLToPath as eZ}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 J0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function ZZ(Q){if(!await 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 Y0(Q){for(let[Z,$]of Object.entries($0)){if(!await ZQ(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=Z0){let $=aZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;");let J=await ZQ($,"__drizzle_migrations"),Y=await ZQ($,"Node"),V=!1;if(Y&&!J){let U=oZ({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 ZZ($);if(await rZ(sZ($),{migrationsFolder:Z}),await ZZ($)>X)V=!0;return await Y0($),{migrated:V}}finally{$.close()}}var Q0,Z0,$0;var JZ=C(async()=>{Q0=EQ(EQ(EQ(eZ(import.meta.url)))),Z0=process.env.BEACON_MIGRATIONS_DIR||iZ(Q0,"drizzle"),$0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{AsyncLocalStorage as z0}from"async_hooks";import{spawnSync as q0}from"child_process";import{createHash as X0}from"crypto";import{existsSync as VZ,mkdirSync as $Q,readFileSync as zZ,writeFileSync as qZ}from"fs";import{homedir as U0}from"os";import{basename as P0,join as w}from"path";function G(){return process.env.BEACON_HOME||w(U0(),".beacon")}function IQ(){return w(G(),"workspaces.json")}function XZ(Q){return X0("sha256").update(Q).digest("hex").slice(0,12)}function Q1(Q=process.cwd()){let Z=q0("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 bQ(Q){return w(G(),Q)}function W0(Q){return`file:${w(bQ(Q),"db.sqlite")}`}function O(){try{let Q=JSON.parse(zZ(IQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function DQ(Q){$Q(G(),{recursive:!0}),qZ(IQ(),JSON.stringify(Q,null,2))}function OQ(){return O().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function N(Q){return O().find((Z)=>Z.id===Q)??null}function H0(Q,Z,$=new Date().toISOString()){let J=XZ(Q),Y=O(),V=Y.find((z)=>z.id===J),X={id:J,path:Q,name:Z||V?.name||P0(Q),lastOpenedAt:$},U=[X,...Y.filter((z)=>z.id!==J)];return $Q(bQ(J),{recursive:!0}),DQ(U),X}function Z1(Q,Z=new Date().toISOString()){let $=O(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,DQ($)}function $1(Q){if(DQ(O().filter((Z)=>Z.id!==Q)),AQ()===Q)B0(OQ()[0]?.id??null)}function UZ(){return w(G(),"active")}function AQ(){try{return zZ(UZ(),"utf8").trim()||null}catch{return null}}function B0(Q){$Q(G(),{recursive:!0}),qZ(UZ(),Q??"")}function J1(){let Q=AQ();return Q?N(Q):null}function Y1(){let Q=v0()??AQ();return Q?N(Q):null}function V1(Q){return N(Q)?.path??null}function z1(){return VZ(IQ())}var PZ="beacon_ws";function WZ(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 q1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&N(Z))return Z;let $=WZ(Q,PZ);if($&&N($))return $;return null}var j0="x-beacon-workspace-path";async function X1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&N(Z))return Z;let $=Q.headers.get(j0);if($&&(!Z||XZ($)===Z)){let Y=H0($);return await x0(Y.id),Y.id}let J=WZ(Q,PZ);if(J&&N(J))return J;return null}var HZ=new z0;function U1(Q,Z){return Q?HZ.run(Q,Z):Z()}function v0(){return HZ.getStore()??null}var YZ=new Set;async function x0(Q){let Z=bQ(Q),$=w(Z,"db.sqlite"),J=VZ($);if(J&&YZ.has($))return{ok:!0,created:!1,migrated:!1};try{$Q(Z,{recursive:!0});let{provisionDb:Y}=await JZ().then(() => $Z),V=await Y(W0(Q));return YZ.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)}}}k();xQ();MQ();import{existsSync as JQ,readFileSync as N0,rmSync as G0}from"fs";import{join as u0}from"path";var BZ=process.argv.slice(3),jZ=BZ.includes("--yes")||BZ.includes("-y"),j=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,B=(Q)=>`\x1B[2m${Q}\x1B[0m`,K=(Q)=>`
244
- \x1B[1m${Q}\x1B[0m`,vZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,u=G(),A=OQ(),yQ=nQ();console.log(K(jZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(K("Global"));console.log(` ${JQ(u)?`wipe ${u} (${A.length} workspaces)`:`${B(`${u} \u2014 already gone`)}`}`);for(let Q of H)console.log(` ${yQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:B(`skill ${Q} \u2014 already gone`)}`);for(let Q of E)console.log(` ${yQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:B(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${yQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":B("global CLAUDE.md block \u2014 already gone")}`);var YQ=gQ();console.log(K("Codex"));for(let Q of H)console.log(` ${YQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:B(`skill ${Q} \u2014 already gone`)}`);for(let Q of T)console.log(` ${YQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command} from ~/.codex/hooks.json`:B(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${YQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":B("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${YQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":B("config.toml beacon entry \u2014 already gone")}`);if(A.length){console.log(K(`Per-repo (${A.length})`));for(let Q of A){if(!JQ(Q.path)){console.log(` ${B(`${Q.path} \u2014 repo no longer on disk, skipping`)}`);continue}console.log(` ${Q.path}`),console.log(` ${B("strip beacon entry from .mcp.json, workflow block from AGENTS.md, skills, CLAUDE.md @-import")}`)}}if(!jZ)console.log(K("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.
245
- `),process.exit(0);console.log(K("Applying\u2026"));var F=dQ();if(F.skillsRemoved.length)console.log(` ${j(`removed skills: ${F.skillsRemoved.join(", ")}`)}`);if(F.hooksRemoved)console.log(` ${j(`removed ${F.hooksRemoved} hook${F.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(F.claudeMdBlockRemoved)console.log(` ${j("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var x=RQ();if(x.skillsRemoved.length)console.log(` ${j(`removed ~/.agents/skills: ${x.skillsRemoved.join(", ")}`)}`);if(x.hooksRemoved)console.log(` ${j(`removed ${x.hooksRemoved} hook${x.hooksRemoved===1?"":"s"} from ~/.codex/hooks.json`)}`);if(x.agentsMdBlockRemoved)console.log(` ${j("stripped Beacon block from ~/.codex/AGENTS.md")}`);if(x.mcpRemoved)console.log(` ${j("stripped [mcp_servers.beacon] from ~/.codex/config.toml")}`);if(x.mcpSkipped)console.log(` ${vZ("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 A){if(!JQ(Q.path))continue;let Z=PQ(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(` ${j(`${Q.path} \u2192 ${$.join(", ")}`)}`)}var K0=u0(u,"server.json");try{let{pid:Q}=JSON.parse(N0(K0,"utf8"));if(Q)try{process.kill(Q),console.log(` ${j(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(JQ(u))G0(u,{recursive:!0,force:!0}),console.log(` ${j(`removed ${u}`)}`);console.log(K("Done."));console.log(` ${vZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
242
+ ${tQ}
243
+ `});var ZZ={};qQ(ZZ,{provisionDb:()=>V0});import{createClient as aZ}from"@libsql/client";import{drizzle as sZ}from"drizzle-orm/libsql";import{migrate as rZ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as oZ}from"drizzle-orm/migrator";import{dirname as RQ,join as iZ}from"path";import{fileURLToPath as eZ}from"url";async function $Q(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 $Q(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 Y0(Q){for(let[Z,$]of Object.entries($0)){if(!await $Q(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=Z0){let $=aZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;");let J=await $Q($,"__drizzle_migrations"),Y=await $Q($,"Node"),V=!1;if(Y&&!J){let U=oZ({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 rZ(sZ($),{migrationsFolder:Z}),await QZ($)>X)V=!0;return await Y0($),{migrated:V}}finally{$.close()}}var Q0,Z0,$0;var $Z=F(async()=>{Q0=RQ(RQ(RQ(eZ(import.meta.url)))),Z0=process.env.BEACON_MIGRATIONS_DIR||iZ(Q0,"drizzle"),$0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});vQ();import{existsSync as kZ}from"fs";import{homedir as _Z}from"os";import{join as QQ}from"path";function LZ(){return process.env.HOME||process.env.USERPROFILE||_Z()}var ZQ=()=>QQ(LZ(),".claude"),TQ=()=>QQ(ZQ(),"skills"),wQ=()=>QQ(ZQ(),"settings.json"),FQ=()=>QQ(ZQ(),"CLAUDE.md"),gQ="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->";var hZ=m,D=[{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 SZ(Q,Z){return a(TQ(),Q,Z)}function rQ(Q){return R(TQ(),Q)}function pZ(Q){return s(TQ(),Q)}function mZ(Q){return c(wQ(),Q)}function cZ(Q){return l(wQ(),Q)}function lZ(Q){return t(wQ(),Q)}function tZ(Q){n(FQ(),gQ,sQ,Q)}function oQ(){return g(FQ(),gQ)}function nZ(){return d(FQ(),gQ,sQ)}function iQ(){let Q={};for(let $ of W)Q[$]=rQ($);let Z={};for(let $ of D)Z[$.event]=cZ({event:$.event,command:$.command});return{homeExists:kZ(ZQ()),skills:Q,hooks:Z,claudeMdBlock:oQ()}}async function dZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (L(),HQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let U of W){if(!rQ(U))Y.push(U);SZ(U,J[U])}let V=0;for(let U of D)if(mZ({event:U.event,matcher:U.matcher,command:U.command}))V++;let X=oQ();return tZ(hZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!X}}async function h0(){let Q;try{Q={ok:!0,...await dZ()}}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(() => (fQ(),aQ));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 eQ(){let Q=[];for(let J of W)if(pZ(J))Q.push(J);let Z=0;for(let J of D)if(lZ(J))Z++;let $=nZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as z0}from"async_hooks";import{spawnSync as q0}from"child_process";import{createHash as X0}from"crypto";import{existsSync as YZ,mkdirSync as JQ,readFileSync as VZ,writeFileSync as zZ}from"fs";import{homedir as U0}from"os";import{basename as P0,join as T}from"path";function u(){return process.env.BEACON_HOME||T(U0(),".beacon")}function EQ(){return T(u(),"workspaces.json")}function qZ(Q){return X0("sha256").update(Q).digest("hex").slice(0,12)}function e0(Q=process.cwd()){let Z=q0("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 IQ(Q){return T(u(),Q)}function W0(Q){return`file:${T(IQ(Q),"db.sqlite")}`}function O(){try{let Q=JSON.parse(VZ(EQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function bQ(Q){JQ(u(),{recursive:!0}),zZ(EQ(),JSON.stringify(Q,null,2))}function DQ(){return O().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function N(Q){return O().find((Z)=>Z.id===Q)??null}function H0(Q,Z,$=new Date().toISOString()){let J=qZ(Q),Y=O(),V=Y.find((z)=>z.id===J),X={id:J,path:Q,name:Z||V?.name||P0(Q),lastOpenedAt:$},U=[X,...Y.filter((z)=>z.id!==J)];return JQ(IQ(J),{recursive:!0}),bQ(U),X}function Q1(Q,Z=new Date().toISOString()){let $=O(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,bQ($)}function Z1(Q){if(bQ(O().filter((Z)=>Z.id!==Q)),OQ()===Q)j0(DQ()[0]?.id??null)}function XZ(){return T(u(),"active")}function OQ(){try{return VZ(XZ(),"utf8").trim()||null}catch{return null}}function j0(Q){JQ(u(),{recursive:!0}),zZ(XZ(),Q??"")}function $1(){let Q=OQ();return Q?N(Q):null}function J1(){let Q=v0()??OQ();return Q?N(Q):null}function Y1(Q){return N(Q)?.path??null}function V1(){return YZ(EQ())}var UZ="beacon_ws";function PZ(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 z1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&N(Z))return Z;let $=PZ(Q,UZ);if($&&N($))return $;return null}var B0="x-beacon-workspace-path";async function q1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&N(Z))return Z;let $=Q.headers.get(B0);if($&&(!Z||qZ($)===Z)){let Y=H0($);return await x0(Y.id),Y.id}let J=PZ(Q,UZ);if(J&&N(J))return J;return null}var WZ=new z0;function X1(Q,Z){return Q?WZ.run(Q,Z):Z()}function v0(){return WZ.getStore()??null}var JZ=new Set;async function x0(Q){let Z=IQ(Q),$=T(Z,"db.sqlite"),J=YZ($);if(J&&JZ.has($))return{ok:!0,created:!1,migrated:!1};try{JQ(Z,{recursive:!0});let{provisionDb:Y}=await $Z().then(() => ZZ),V=await Y(W0(Q));return JZ.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)}}}L();fQ();import{existsSync as YQ,readFileSync as N0,rmSync as u0}from"fs";import{join as G0}from"path";var HZ=process.argv.slice(3),jZ=HZ.includes("--yes")||HZ.includes("-y"),B=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,j=(Q)=>`\x1B[2m${Q}\x1B[0m`,K=(Q)=>`
244
+ \x1B[1m${Q}\x1B[0m`,BZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,G=u(),A=DQ(),AQ=iQ();console.log(K(jZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(K("Global"));console.log(` ${YQ(G)?`wipe ${G} (${A.length} workspaces)`:`${j(`${G} \u2014 already gone`)}`}`);for(let Q of W)console.log(` ${AQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:j(`skill ${Q} \u2014 already gone`)}`);for(let Q of D)console.log(` ${AQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:j(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${AQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":j("global CLAUDE.md block \u2014 already gone")}`);var VQ=CQ();console.log(K("Codex"));for(let Q of W)console.log(` ${VQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:j(`skill ${Q} \u2014 already gone`)}`);for(let Q of f)console.log(` ${VQ.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(` ${VQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":j("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${VQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":j("config.toml beacon entry \u2014 already gone")}`);if(A.length){console.log(K(`Per-repo (${A.length})`));for(let Q of A){if(!YQ(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(!jZ)console.log(K("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.
245
+ `),process.exit(0);console.log(K("Applying\u2026"));var w=eQ();if(w.skillsRemoved.length)console.log(` ${B(`removed skills: ${w.skillsRemoved.join(", ")}`)}`);if(w.hooksRemoved)console.log(` ${B(`removed ${w.hooksRemoved} hook${w.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(w.claudeMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var x=MQ();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(` ${BZ("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 A){if(!YQ(Q.path))continue;let Z=WQ(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 K0=G0(G,"server.json");try{let{pid:Q}=JSON.parse(N0(K0,"utf8"));if(Q)try{process.kill(Q),console.log(` ${B(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(YQ(G))u0(G,{recursive:!0,force:!0}),console.log(` ${B(`removed ${G}`)}`);console.log(K("Done."));console.log(` ${BZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
246
246
  `);