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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +11 -11
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +1 -1
- package/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
- package/.next/server/app/feedback.html +1 -1
- package/.next/server/app/feedback.rsc +1 -1
- package/.next/server/app/feedback.segments/_full.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +1 -1
- package/.next/server/app/help.segments/_full.segment.rsc +1 -1
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +1 -1
- package/.next/server/app/help.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/map/page.js +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +2 -2
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +11 -11
- package/.next/server/chunks/7263.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{9185-2dc95ca34d3ed35e.js → 9005-8ce19752fc3ddd2c.js} +1 -1
- package/.next/static/chunks/app/map/{page-8a50ebc7430720f9.js → page-2d506579d74725fe.js} +1 -1
- package/.next/static/chunks/app/plan/{page-8c84c74359ee2ea0.js → page-d6b31633d9630a26.js} +1 -1
- package/.next/trace +37 -37
- package/.next/trace-build +1 -1
- package/dist/bin/doctor.js +24 -24
- package/dist/bin/hook.js +24 -24
- package/dist/bin/mcp.js +30 -30
- package/dist/bin/plan.js +25 -25
- package/dist/bin/uninstall.js +26 -26
- package/dist/lib/codex-install.js +25 -25
- package/dist/lib/global-install.js +242 -0
- package/package.json +1 -1
- package/.next/server/chunks/7604.js +0 -1
- /package/.next/static/{zLC93esTvoKLzicL2UsF6 → zkOVrPg9gaBl1KxEF44lf}/_buildManifest.js +0 -0
- /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
|
|
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
|
-
${
|
|
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
|
|
12
|
-
`),{path:Z,added:!0}}function
|
|
13
|
-
`)}}catch{}let J=!1,V=W(Q,"AGENTS.md");try{let z=P(V,"utf8"),U=new RegExp(`\\n?${
|
|
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,
|
|
17
|
-
`)?
|
|
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
|
|
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
|
-
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
${
|
|
199
|
-
`)}function
|
|
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
|
-
`,
|
|
205
|
+
`,qQ(DQ(Q),{recursive:!0}),O(Q,V.endsWith(`
|
|
206
206
|
`)?V:`${V}
|
|
207
|
-
`)}function
|
|
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
|
|
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
|
|
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+$+
|
|
235
|
-
`),$=Z.indexOf(
|
|
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
|
|
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
|
-
${
|
|
243
|
-
`});var
|
|
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=
|
|
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(
|
|
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(
|
|
250
|
+
`+B.feedback))}K(i("Beacon plan review timed out without a verdict. Re-present the plan and ask the user to review it."))})();
|
package/dist/bin/uninstall.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
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
|
-
${
|
|
6
|
-
`.trimStart(),
|
|
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))
|
|
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
|
|
12
|
-
`),{path:Z,added:!0}}function
|
|
13
|
-
`)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=v(V,"utf8"),P=new RegExp(`\\n?${_}[\\s\\S]*?${
|
|
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();
|
|
17
|
-
`)?
|
|
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
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
${
|
|
199
|
-
`)}function
|
|
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
|
-
`,
|
|
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
|
|
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
|
|
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
|
|
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+$+
|
|
235
|
-
`),$=Z.indexOf(
|
|
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(
|
|
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
|
-
${
|
|
243
|
-
`});var
|
|
244
|
-
\x1B[1m${Q}\x1B[0m`,
|
|
245
|
-
`),process.exit(0);console.log(K("Applying\u2026"));var
|
|
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
|
`);
|