trybeacon 0.1.48 → 0.1.49
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 +8 -8
- 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 +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- 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 +2 -2
- package/.next/server/app/api/db/arrange/route.js +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 +2 -2
- package/.next/server/app/docs.segments/_full.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- 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 +2 -2
- package/.next/server/app/feedback.segments/_full.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
- 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 +2 -2
- package/.next/server/app/help.segments/_full.segment.rsc +2 -2
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +2 -2
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- 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 +3 -3
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- 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.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 +8 -8
- package/.next/server/chunks/1341.js +1 -1
- package/.next/server/chunks/2933.js +1 -1
- package/.next/server/chunks/{7208.js → 2999.js} +3 -3
- package/.next/server/chunks/7331.js +1 -0
- package/.next/server/chunks/9734.js +1 -1
- 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/3343-af1292b51a276724.js +1 -0
- package/.next/static/chunks/7323-480fb88e9d24f9e9.js +1 -0
- package/.next/static/chunks/app/map/page-66d71744ae3363d7.js +1 -0
- package/.next/static/chunks/app/page-541e900d67f17dae.js +1 -0
- package/.next/static/chunks/app/plan/page-e7d16fa2a3713a92.js +1 -0
- package/.next/static/css/629ab377241de9ca.css +1 -0
- package/.next/trace +39 -39
- package/.next/trace-build +1 -1
- package/dist/bin/beacon.js +7 -7
- package/dist/bin/doctor.js +27 -26
- package/dist/bin/hook.js +27 -26
- package/dist/bin/mcp.js +34 -33
- package/dist/bin/plan.js +29 -28
- package/dist/bin/remove.js +7 -7
- package/dist/bin/uninstall.js +26 -25
- package/dist/lib/assets.js +14 -13
- package/dist/lib/codex-install.js +24 -23
- package/dist/lib/global-install.js +24 -23
- package/package.json +1 -1
- package/.next/server/chunks/805.js +0 -1
- package/.next/static/chunks/8074-a6b2725786399e2c.js +0 -1
- package/.next/static/chunks/85-82015ecb44b65d3e.js +0 -1
- package/.next/static/chunks/app/map/page-c06fcf30d8172f82.js +0 -1
- package/.next/static/chunks/app/page-968dd5a6f667bff9.js +0 -1
- package/.next/static/chunks/app/plan/page-257d486640eadd7f.js +0 -1
- package/.next/static/css/5a58d83133d25695.css +0 -1
- /package/.next/static/{gNMdQmtkjPn6XQhRMDoMg → qeqVD-yeoYO_3C0pw9kHg}/_buildManifest.js +0 -0
- /package/.next/static/{gNMdQmtkjPn6XQhRMDoMg → qeqVD-yeoYO_3C0pw9kHg}/_ssgManifest.js +0 -0
package/dist/bin/plan.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var gZ=Object.defineProperty;var wZ=(Q)=>Q;function fZ(Q,Z){this[Q]=wZ.bind(null,Z)}var JQ=(Q,Z)=>{for(var $ in Z)gZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:fZ.bind(Z,$)})};var v=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var OQ=1500,yQ=480000,U1=1800000,D=3600000,W1=3000;var VQ=()=>{};var UQ={};JQ(UQ,{removeRepoAssets:()=>kZ,installRefreshSkill:()=>AZ,installPlanSkill:()=>IZ,installInitSkill:()=>DZ,installCodexRepoSkills:()=>bZ,ensureWorkflowDoc:()=>OZ,ensureMcp:()=>yZ,auditRepo:()=>LZ,REFRESH_SKILL:()=>qQ,PLAN_SKILL:()=>kQ,INIT_SKILL:()=>zQ});import{existsSync as C,mkdirSync as I,readFileSync as G,rmSync as A,writeFileSync as B}from"fs";import{join as U}from"path";function DZ(Q){let Z=U(Q,".claude","skills","beacon-init");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,zQ),$}function AZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,qQ),$}function IZ(Q){let Z=U(Q,".claude","skills","beacon-plan");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,kQ),$}function bZ(Q){let Z=[];for(let $ of EZ){let Y=U(Q,".agents","skills",$.name);I(Y,{recursive:!0});let J=U(Y,"SKILL.md");B(J,$.body()),Z.push(J)}return Z}function OZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=G(Z,"utf8")}catch{}let Y=new RegExp(`${E}[\\s\\S]*?${XQ}`);$=Y.test($)?$.replace(Y,LQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
`.trimStart(),
|
|
5
|
+
${LQ}
|
|
6
|
+
`.trimStart(),B(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
|
-
`);let J=U(Q,"CLAUDE.md"),V="";try{V=G(J,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))
|
|
8
|
+
`);let J=U(Q,"CLAUDE.md"),V="";try{V=G(J,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))B(J,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!0}
|
|
13
|
-
`)}}catch{}let
|
|
11
|
+
`)}function yZ(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(G(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let Y=$.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<D)return Y.timeout=D,B(Z,JSON.stringify($,null,2)+`
|
|
12
|
+
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:D},B(Z,JSON.stringify($,null,2)+`
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function LZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=G(U(Q,"AGENTS.md"),"utf8").includes(E)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(G(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":C(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":C(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":C(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":C(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function kZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(C(W))A(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(C(W))A(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=U(Q,".mcp.json");try{let z=JSON.parse(G(Y,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)A(Y,{force:!0});else B(Y,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let J=!1,V=U(Q,"AGENTS.md");try{let z=G(V,"utf8"),W=new RegExp(`\\n?${E}[\\s\\S]*?${XQ}\\n?`);if(W.test(z)){let H=z.replace(W,`
|
|
14
15
|
`).replace(/\n{3,}/g,`
|
|
15
16
|
|
|
16
|
-
`).trimStart();
|
|
17
|
-
`)?
|
|
18
|
-
`),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())
|
|
17
|
+
`).trimStart();B(V,H.endsWith(`
|
|
18
|
+
`)?H:`${H}
|
|
19
|
+
`),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())A(X,{force:!0});else B(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:q}}var zQ=`---
|
|
19
20
|
name: beacon-init
|
|
20
21
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
21
22
|
---
|
|
@@ -54,7 +55,7 @@ A single \`beacon_init_persist\` MCP tool call with:
|
|
|
54
55
|
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.
|
|
55
56
|
|
|
56
57
|
After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
|
|
57
|
-
`,
|
|
58
|
+
`,qQ=`---
|
|
58
59
|
name: beacon-refresh
|
|
59
60
|
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.
|
|
60
61
|
---
|
|
@@ -101,7 +102,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
101
102
|
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.
|
|
102
103
|
|
|
103
104
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
104
|
-
`,
|
|
105
|
+
`,kQ=`---
|
|
105
106
|
name: beacon-plan
|
|
106
107
|
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.
|
|
107
108
|
---
|
|
@@ -149,7 +150,7 @@ If it returns feedback, revise and call it again.
|
|
|
149
150
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
150
151
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
151
152
|
run \`beacon\` in this repo once.
|
|
152
|
-
`,
|
|
153
|
+
`,EZ,E="<!-- beacon:workflow:start -->",XQ="<!-- beacon:workflow:end -->",LQ;var WQ=v(()=>{VQ();EZ=[{name:"beacon-init",body:()=>zQ},{name:"beacon-refresh",body:()=>qQ}];LQ=`${E}
|
|
153
154
|
## Beacon \u2014 feature workflow
|
|
154
155
|
|
|
155
156
|
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:
|
|
@@ -207,18 +208,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
207
208
|
If the feature added or materially changed a REAL architectural component (a subsystem \u2014 NOT a file), also pass \`architecture: [{ title, domain, role, \u2026 }]\` so the Architecture map stays accurate. It upserts curated components by title; never list files as components. If you found a bug or something worth investigating in a component's code, add \`bugs: [{ note }]\` to its architecture entry \u2014 it renders as a bug flag on the node (attributed to the agent); identical open flags are not duplicated. Only flag what you actually saw in the code.
|
|
208
209
|
|
|
209
210
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
210
|
-
${
|
|
211
|
-
`)}function
|
|
211
|
+
${XQ}`});import{existsSync as _Q,mkdirSync as HQ,readFileSync as O,rmSync as _Z,writeFileSync as y}from"fs";import{dirname as SQ,join as b}from"path";function BQ(Q){try{return JSON.parse(O(Q,"utf8"))}catch{return{}}}function hQ(Q,Z){HQ(SQ(Q),{recursive:!0}),y(Q,JSON.stringify(Z,null,2)+`
|
|
212
|
+
`)}function k(Q,Z){let $=BQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),hQ(Q,$),!0}function _(Q,Z){return(BQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function S(Q,Z){let $=BQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==X)J=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!J)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return hQ(Q,$),!0}function h(Q,Z,$,Y){let J=`${Z}
|
|
212
213
|
${Y.trim()}
|
|
213
|
-
${$}`,V="";try{V=
|
|
214
|
+
${$}`,V="";try{V=O(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
|
|
214
215
|
|
|
215
216
|
${J}
|
|
216
217
|
`:`${J}
|
|
217
|
-
`,
|
|
218
|
+
`,HQ(SQ(Q),{recursive:!0}),y(Q,V.endsWith(`
|
|
218
219
|
`)?V:`${V}
|
|
219
|
-
`)}function T(Q,Z){try{return
|
|
220
|
+
`)}function T(Q,Z){try{return O(Q,"utf8").includes(Z)}catch{return!1}}function m(Q,Z,$){let Y="";try{Y=O(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
|
|
220
221
|
|
|
221
|
-
`).trimStart();return
|
|
222
|
+
`).trimStart();return y(Q,V),!0}function p(Q,Z,$){let Y=b(Q,Z);HQ(Y,{recursive:!0});let J=b(Y,"SKILL.md");return y(J,$),J}function F(Q,Z){return _Q(b(Q,Z,"SKILL.md"))}function c(Q,Z){let $=b(Q,Z);if(!_Q($))return!1;return _Z($,{recursive:!0,force:!0}),!0}var x,L=`## Beacon (visual planning panel)
|
|
222
223
|
|
|
223
224
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
224
225
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -239,24 +240,24 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
239
240
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
240
241
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
241
242
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
242
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
243
|
+
verbatim. Do NOT implement until the tool returns approval.`;var jQ=v(()=>{x=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as SZ,renameSync as hZ,rmSync as mZ,writeFileSync as pZ}from"fs";import{dirname as cZ}from"path";function l(Q,Z){SZ(cZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{pZ($,Z),hZ($,Q)}catch(Y){throw mZ($,{force:!0}),Y}}function C1(Q,Z,$=!1){l(Q,JSON.stringify(Z,null,$?2:void 0))}var mQ=()=>{};var sQ={};JQ(sQ,{setupCodexAssets:()=>aZ,removeCodexMcp:()=>tQ,removeCodexArtifacts:()=>sZ,hasCodexMcp:()=>PQ,ensureCodexMcp:()=>aQ,codexMcpProblem:()=>nZ,codexDetected:()=>lQ,auditCodex:()=>tZ,CODEX_HOOKS:()=>s});import{readFileSync as t}from"fs";import{homedir as lZ}from"os";import{join as g}from"path";function pQ(){return process.env.HOME||process.env.USERPROFILE||lZ()}function lQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(GQ===void 0)GQ=Bun.which("codex")!==null;return GQ}function R(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function PQ(){try{return Boolean(R(t(M(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function nZ(){let Q="";try{Q=t(M(),"utf8")}catch{return null}let Z=R(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${u}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${u}`;return null}function aQ(){let Q="",Z=!1;try{Q=t(M(),"utf8"),Z=!0}catch{}if(Z){let V=R(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${u}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${u}`}}let $=!Q?"":Q.endsWith(`
|
|
243
244
|
`)?`
|
|
244
245
|
`:`
|
|
245
246
|
|
|
246
|
-
`,Y=Q+$+
|
|
247
|
-
`),$=Z.indexOf(
|
|
247
|
+
`,Y=Q+$+dZ;if(R(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${u}`};return l(M(),Y),{added:!0}}function tQ(){let Q="";try{Q=t(M(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
248
|
+
`),$=Z.indexOf(dQ);if($===-1)return{removed:!1,skipped:PQ()};let Y=Z.indexOf(nQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
|
|
248
249
|
`).replace(/\n{3,}/g,`
|
|
249
250
|
|
|
250
|
-
`).replace(/^\n+/,"");if(R(J)===null)return{removed:!1,skipped:!0};return
|
|
251
|
+
`).replace(/^\n+/,"");if(R(J)===null)return{removed:!1,skipped:!0};return l(M(),J),{removed:!0}}async function aZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (WQ(),UQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of x){if(!F(n(),z))J.push(z);p(n(),z,Y[z])}let V=0;for(let z of s)if(k(KQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=T(d(),a);h(d(),a,cQ,L);let X=aQ();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function tZ(){let Q={};for(let $ of x)Q[$]=F(n(),$);let Z={};for(let $ of s)Z[$.event]=_(KQ(),{event:$.event,command:$.command});return{detected:lQ(),skills:Q,hooks:Z,agentsMdBlock:T(d(),a),mcp:PQ()}}function sZ(){let Q=[];for(let J of x)if(c(n(),J))Q.push(J);let Z=0;for(let J of s)if(S(KQ(),{event:J.event,command:J.command}))Z++;let $=m(d(),a,cQ),Y=tQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var xQ=()=>g(pQ(),".codex"),KQ=()=>g(xQ(),"hooks.json"),M=()=>g(xQ(),"config.toml"),d=()=>g(xQ(),"AGENTS.md"),n=()=>g(pQ(),".agents","skills"),a="<!-- beacon:global:start -->",cQ="<!-- beacon:global:end -->",s,GQ,dQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",nQ="# beacon:end",dZ,u="add it manually: codex mcp add beacon -- beacon mcp";var rQ=v(()=>{jQ();mQ();s=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}];dZ=`${dQ}
|
|
251
252
|
[mcp_servers.beacon]
|
|
252
253
|
command = "beacon"
|
|
253
254
|
args = ["mcp"]
|
|
254
|
-
${
|
|
255
|
-
`});var iQ={};YQ(iQ,{provisionDb:()=>K0});import{createClient as z0}from"@libsql/client";import{drizzle as q0}from"drizzle-orm/libsql";import{migrate as X0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as U0}from"drizzle-orm/migrator";import{dirname as MQ,join as W0}from"path";import{fileURLToPath as B0}from"url";async function o(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function x0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function oQ(Q){if(!await o(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function P0(Q){for(let[Z,$]of Object.entries(G0)){if(!await o(Q,Z))continue;let Y=await x0(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 K0(Q,Z=j0){let $=z0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await o($,"__drizzle_migrations"),J=await o($,"Node"),V=!1;if(J&&!Y){let X=U0({migrationsFolder:Z})[0];if(X)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),V=!0}let q=await oQ($);if(await X0(q0($),{migrationsFolder:Z}),await oQ($)>q)V=!0;return await P0($),{migrated:V}}finally{$.close()}}var H0,j0,G0;var eQ=M(async()=>{H0=MQ(MQ(MQ(B0(import.meta.url)))),j0=process.env.BEACON_MIGRATIONS_DIR||W0(H0,"drizzle"),G0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});BQ();import{existsSync as sZ}from"fs";import{homedir as tZ}from"os";import{join as t}from"path";function rZ(){return process.env.HOME||process.env.USERPROFILE||tZ()}var r=()=>t(rZ(),".claude"),PQ=()=>t(r(),"skills"),KQ=()=>t(r(),"settings.json"),NQ=()=>t(r(),"CLAUDE.md"),vQ="<!-- beacon:global:start -->",aQ="<!-- beacon:global:end -->";var oZ=y,CQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function iZ(Q,Z){return m(PQ(),Q,Z)}function sQ(Q){return g(PQ(),Q)}function eZ(Q){return p(PQ(),Q)}function Q0(Q){return L(KQ(),Q)}function Z0(Q){return k(KQ(),Q)}function $0(Q){return _(KQ(),Q)}function Y0(Q){S(NQ(),vQ,aQ,Q)}function tQ(){return T(NQ(),vQ)}function J0(){return h(NQ(),vQ,aQ)}function R1(){let Q={};for(let $ of x)Q[$]=sQ($);let Z={};for(let $ of CQ)Z[$.event]=Z0({event:$.event,command:$.command});return{homeExists:sZ(r()),skills:Q,hooks:Z,claudeMdBlock:tQ()}}async function V0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (XQ(),qQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of x){if(!sQ(X))J.push(X);iZ(X,Y[X])}let V=0;for(let X of CQ)if(Q0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=tQ();return Y0(oZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function rQ(){let Q;try{Q={ok:!0,...await V0()}}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(() => (nQ(),dQ));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 u1(){let Q=[];for(let Y of x)if(eZ(Y))Q.push(Y);let Z=0;for(let Y of CQ)if($0(Y))Z++;let $=J0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as N0}from"async_hooks";import{spawnSync as v0}from"child_process";import{createHash as C0}from"crypto";import{existsSync as ZZ,mkdirSync as w,readFileSync as gQ,writeFileSync as FQ}from"fs";import{homedir as $Z}from"os";import{basename as M0,join as P,parse as T0,resolve as QZ}from"path";function j(){return process.env.BEACON_HOME||P($Z(),".beacon")}function RQ(){return P(j(),"workspaces.json")}function i(Q){return C0("sha256").update(Q).digest("hex").slice(0,12)}function h1(Q=process.cwd()){let Z=v0("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 YZ(Q){let Z=QZ(Q);return Z!==QZ($Z())&&Z!==T0(Z).root}function JZ(){return P(j(),"deleted.json")}function uQ(){try{let Q=JSON.parse(gQ(JZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function VZ(Q){w(j(),{recursive:!0}),FQ(JZ(),JSON.stringify(Q,null,2))}function zZ(Q){return uQ().includes(Q)}function m1(Q){let Z=uQ();if(!Z.includes(Q))VZ([...Z,Q])}function g0(Q){let Z=uQ();if(Z.includes(Q))VZ(Z.filter(($)=>$!==Q))}function e(Q){return P(j(),Q)}function F0(Q){return`file:${P(e(Q),"db.sqlite")}`}function A(){try{let Q=JSON.parse(gQ(RQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function wQ(Q){w(j(),{recursive:!0}),FQ(RQ(),JSON.stringify(Q,null,2))}function qZ(){return A().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function K(Q){return A().find((Z)=>Z.id===Q)??null}function XZ(Q,Z,$=new Date().toISOString()){if(!YZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=i(Q);if(zZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=A(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||M0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return w(e(Y),{recursive:!0}),wQ(X),q}function p1(Q,Z){return g0(i(Q)),XZ(Q,Z)}function c1(Q,Z=new Date().toISOString()){let $=A(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,wQ($)}function l1(Q){if(wQ(A().filter((Z)=>Z.id!==Q)),AQ()===Q)R0(qZ()[0]?.id??null)}function UZ(){return P(j(),"active")}function AQ(){try{return gQ(UZ(),"utf8").trim()||null}catch{return null}}function R0(Q){w(j(),{recursive:!0}),FQ(UZ(),Q??"")}function d1(){let Q=AQ();return Q?K(Q):null}function n1(){let Q=A0()??AQ();return Q?K(Q):null}function a1(Q){return K(Q)?.path??null}function s1(){return ZZ(RQ())}var WZ="beacon_ws";function BZ(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 t1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&K(Z))return Z;let $=BZ(Q,WZ);if($&&K($))return $;return u0()}function u0(){let Q=qZ();return Q.length===1?Q[0].id:null}var w0="x-beacon-workspace-path";async function r1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&K(Z))return Z;let $=Q.headers.get(w0);if($&&YZ($)&&!zZ(i($))&&(!Z||i($)===Z)){let J=XZ($);return await E0(J.id),J.id}let Y=BZ(Q,WZ);if(Y&&K(Y))return Y;return null}var HZ=new N0;function o1(Q,Z){return Q?HZ.run(Q,Z):Z()}function A0(){return HZ.getStore()??null}var TQ=new Set;function i1(Q){TQ.delete(P(e(Q),"db.sqlite"))}async function E0(Q){let Z=e(Q),$=P(Z,"db.sqlite"),Y=ZZ($);if(Y&&TQ.has($))return{ok:!0,created:!1,migrated:!1};try{w(Z,{recursive:!0});let{provisionDb:J}=await eQ().then(() => iQ),V=await J(F0(Q));return TQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as f0}from"net";var Z2=4319;function D0(Q,Z,$=400){return new Promise((Y)=>{let J=f0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function O0(Q){for(let Z of["127.0.0.1","::1"])if(await D0(Z,Q))return!1;return!0}async function jZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await O0($))return $;return Q}import{execSync as h0,spawn as m0}from"child_process";import{mkdirSync as p0,openSync as c0,readFileSync as l0,writeFileSync as d0}from"fs";import{homedir as n0}from"os";import{dirname as a0,join as ZQ}from"path";import{fileURLToPath as s0}from"url";import{createHash as t0}from"crypto";var GZ=1500,xZ=345600000,Y2=1800000,J2=3000;import{mkdirSync as b0,readFileSync as y0,writeFileSync as L0}from"fs";import{join as k0}from"path";var I0=["default","acceptEdits","bypassPermissions","auto"];function PZ(Q){return typeof Q==="string"&&I0.includes(Q)}function KZ(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 NZ(){return k0(j(),"preferences.json")}function EQ(){try{let Q=JSON.parse(y0(NZ(),"utf8"));return{planApprovalMode:PZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function B2(Q){let Z={...EQ(),...Q};return b0(j(),{recursive:!0}),L0(NZ(),JSON.stringify(Z,null,2)),Z}function vZ(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`
|
|
255
|
+
${nQ}
|
|
256
|
+
`});var $Z={};JQ($Z,{provisionDb:()=>v0});import{createClient as X0}from"@libsql/client";import{drizzle as U0}from"drizzle-orm/libsql";import{migrate as W0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as H0}from"drizzle-orm/migrator";import{dirname as FQ,join as B0}from"path";import{fileURLToPath as j0}from"url";async function i(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function P0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function ZZ(Q){if(!await i(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function N0(Q){for(let[Z,$]of Object.entries(K0)){if(!await i(Q,Z))continue;let Y=await P0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function v0(Q,Z=x0){let $=X0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await i($,"__drizzle_migrations"),J=await i($,"Node"),V=!1;if(J&&!Y){let X=H0({migrationsFolder:Z})[0];if(X)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),V=!0}let q=await ZZ($);if(await W0(U0($),{migrationsFolder:Z}),await ZZ($)>q)V=!0;return await N0($),{migrated:V}}finally{$.close()}}var G0,x0,K0;var YZ=v(async()=>{G0=FQ(FQ(FQ(j0(import.meta.url)))),x0=process.env.BEACON_MIGRATIONS_DIR||B0(G0,"drizzle"),K0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});jQ();import{existsSync as rZ}from"fs";import{homedir as oZ}from"os";import{join as r}from"path";function iZ(){return process.env.HOME||process.env.USERPROFILE||oZ()}var o=()=>r(iZ(),".claude"),NQ=()=>r(o(),"skills"),vQ=()=>r(o(),"settings.json"),CQ=()=>r(o(),"CLAUDE.md"),MQ="<!-- beacon:global:start -->",oQ="<!-- beacon:global:end -->";var eZ=L,TQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function Q0(Q,Z){return p(NQ(),Q,Z)}function iQ(Q){return F(NQ(),Q)}function Z0(Q){return c(NQ(),Q)}function $0(Q){return k(vQ(),Q)}function Y0(Q){return _(vQ(),Q)}function J0(Q){return S(vQ(),Q)}function V0(Q){h(CQ(),MQ,oQ,Q)}function eQ(){return T(CQ(),MQ)}function z0(){return m(CQ(),MQ,oQ)}function I1(){let Q={};for(let $ of x)Q[$]=iQ($);let Z={};for(let $ of TQ)Z[$.event]=Y0({event:$.event,command:$.command});return{homeExists:rZ(o()),skills:Q,hooks:Z,claudeMdBlock:eQ()}}async function q0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (WQ(),UQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of x){if(!iQ(X))J.push(X);Q0(X,Y[X])}let V=0;for(let X of TQ)if($0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=eQ();return V0(eZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function QZ(){let Q;try{Q={ok:!0,...await q0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (rQ(),sQ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function E1(){let Q=[];for(let Y of x)if(Z0(Y))Q.push(Y);let Z=0;for(let Y of TQ)if(J0(Y))Z++;let $=z0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as C0}from"async_hooks";import{spawnSync as M0}from"child_process";import{createHash as T0}from"crypto";import{existsSync as VZ,mkdirSync as w,readFileSync as RQ,writeFileSync as gQ}from"fs";import{homedir as zZ}from"os";import{basename as F0,join as K,parse as u0,resolve as JZ}from"path";function j(){return process.env.BEACON_HOME||K(zZ(),".beacon")}function wQ(){return K(j(),"workspaces.json")}function e(Q){return T0("sha256").update(Q).digest("hex").slice(0,12)}function n1(Q=process.cwd()){let Z=M0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function qZ(Q){let Z=JZ(Q);return Z!==JZ(zZ())&&Z!==u0(Z).root}function XZ(){return K(j(),"deleted.json")}function fQ(){try{let Q=JSON.parse(RQ(XZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function UZ(Q){w(j(),{recursive:!0}),gQ(XZ(),JSON.stringify(Q,null,2))}function WZ(Q){return fQ().includes(Q)}function a1(Q){let Z=fQ();if(!Z.includes(Q))UZ([...Z,Q])}function R0(Q){let Z=fQ();if(Z.includes(Q))UZ(Z.filter(($)=>$!==Q))}function QQ(Q){return K(j(),Q)}function g0(Q){return`file:${K(QQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(RQ(wQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function DQ(Q){w(j(),{recursive:!0}),gQ(wQ(),JSON.stringify(Q,null,2))}function HZ(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function P(Q){return f().find((Z)=>Z.id===Q)??null}function BZ(Q,Z,$=new Date().toISOString()){if(!qZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=e(Q);if(WZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=f(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||F0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return w(QQ(Y),{recursive:!0}),DQ(X),q}function t1(Q,Z){return R0(e(Q)),BZ(Q,Z)}function s1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,DQ($)}function r1(Q){if(DQ(f().filter((Z)=>Z.id!==Q)),AQ()===Q)w0(HZ()[0]?.id??null)}function jZ(){return K(j(),"active")}function AQ(){try{return RQ(jZ(),"utf8").trim()||null}catch{return null}}function w0(Q){w(j(),{recursive:!0}),gQ(jZ(),Q??"")}function o1(){let Q=AQ();return Q?P(Q):null}function i1(){let Q=A0()??AQ();return Q?P(Q):null}function e1(Q){return P(Q)?.path??null}function Q2(){return VZ(wQ())}var GZ="beacon_ws";function xZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function Z2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=xZ(Q,GZ);if($&&P($))return $;return f0()}function f0(){let Q=HZ();return Q.length===1?Q[0].id:null}var D0="x-beacon-workspace-path";async function $2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=Q.headers.get(D0);if($&&qZ($)&&!WZ(e($))&&(!Z||e($)===Z)){let J=BZ($);return await I0(J.id),J.id}let Y=xZ(Q,GZ);if(Y&&P(Y))return Y;return null}var KZ=new C0;function Y2(Q,Z){return Q?KZ.run(Q,Z):Z()}function A0(){return KZ.getStore()??null}var uQ=new Set;function J2(Q){uQ.delete(K(QQ(Q),"db.sqlite"))}async function I0(Q){let Z=QQ(Q),$=K(Z,"db.sqlite"),Y=VZ($);if(Y&&uQ.has($))return{ok:!0,created:!1,migrated:!1};try{w(Z,{recursive:!0});let{provisionDb:J}=await YZ().then(() => $Z),V=await J(g0(Q));return uQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as E0}from"net";var q2=4319;function b0(Q,Z,$=400){return new Promise((Y)=>{let J=E0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function O0(Q){for(let Z of["127.0.0.1","::1"])if(await b0(Z,Q))return!1;return!0}async function PZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await O0($))return $;return Q}import{execSync as p0,spawn as c0}from"child_process";import{mkdirSync as l0,openSync as d0,readFileSync as n0,writeFileSync as a0}from"fs";import{homedir as t0}from"os";import{dirname as s0,join as $Q}from"path";import{fileURLToPath as r0}from"url";import{createHash as o0}from"crypto";VQ();import{mkdirSync as L0,readFileSync as k0,writeFileSync as _0}from"fs";import{join as S0}from"path";var y0=["default","acceptEdits","bypassPermissions","auto"];function NZ(Q){return typeof Q==="string"&&y0.includes(Q)}function vZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function CZ(){return S0(j(),"preferences.json")}function IQ(){try{let Q=JSON.parse(k0(CZ(),"utf8"));return{planApprovalMode:NZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function G2(Q){let Z={...IQ(),...Q};return L0(j(),{recursive:!0}),_0(CZ(),JSON.stringify(Z,null,2)),Z}function MZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
256
257
|
|
|
257
258
|
This plan created these roadmap feature(s):
|
|
258
259
|
`+Z.join(`
|
|
259
|
-
`)+"\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."}import{execSync as
|
|
260
|
-
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let
|
|
260
|
+
`)+"\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."}import{execSync as h0}from"child_process";import{platform as TZ}from"os";function m0(Q){if(process.env.BEACON_NO_OPEN)return;let Z=TZ()==="darwin"?"open":TZ()==="win32"?"start":"xdg-open";try{h0(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}async function FZ(Q,Z){if(await fetch(`${Q}/api/plan/presence`,{headers:{"x-beacon-workspace":Z}}).then((J)=>J.json()).then((J)=>!!J?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Z}`);m0(`${Q}/api/workspace/activate?id=${Z}&redirect=${Y}`)}var i0=$Q(s0(r0(import.meta.url)),".."),bQ=process.env.BEACON_HOME||$Q(t0(),".beacon"),uZ=$Q(bQ,"server.json"),e0=process.env.PORT||"4319";function Q1(Q){try{return process.kill(Q,0),!0}catch{return!1}}function Z1(Q){try{return JSON.parse(n0(Q,"utf8"))}catch{return null}}async function RZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function $1(Q,Z=60){for(let $=0;$<Z;$++){if(await RZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function Y1(Q){l0(bQ,{recursive:!0});let Z=d0($Q(bQ,"server.log"),"a"),$={...process.env,PORT:Q,BEACON_NO_OPEN:"1"};delete $.BEACON_REPO,delete $.BEACON_DATA_DIR,delete $.DATABASE_URL;let Y=c0("bun",["run","dev"],{cwd:i0,env:$,detached:!0,stdio:["ignore",Z,Z]});Y.unref();let J={pid:Y.pid??0,port:Q};return a0(uZ,JSON.stringify(J)),J}async function J1(){let Q=Z1(uZ);if(Q&&Q1(Q.pid)&&await RZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let Z=String(await PZ(Number(e0))),{port:$}=Y1(Z);return await $1(`http://localhost:${$}/api/workspace`),$}function V1(){try{return p0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function z1(Q){return o0("sha256").update(Q).digest("hex").slice(0,12)}async function q1(){if(process.stdin.isTTY)return null;let Q=[];for await(let $ of process.stdin)Q.push($);let Z=Buffer.concat(Q).toString("utf8").trim();if(!Z)return null;try{return JSON.parse(Z)}catch{return null}}function EQ(Q,Z){return vZ(Q,Z)}function ZQ(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function N(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await QZ();let Z=(await q1())?.tool_input?.plan;if(!Z||!Z.trim())N(EQ());let Y=`http://localhost:${await J1()}`,J=V1()||process.cwd(),V=z1(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let q=Z.split(`
|
|
261
|
+
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let H=await X.json().catch(()=>({}));N(ZQ(H.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!X.ok)N(EQ());await FZ(Y,V);let z=Date.now()+yQ,W=(H)=>new Promise((YQ)=>setTimeout(YQ,H));while(Date.now()<z){await W(OQ);let H=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((YQ)=>YQ.json()).catch(()=>null);if(!H)continue;if(H.kind==="approved")N(EQ(IQ().planApprovalMode,MZ(H.features)));if(H.kind==="discarded")N(ZQ("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(H.kind==="feedback")N(ZQ(`The user left feedback on the plan in Beacon (inline comments and/or edits on the /map and /db boards). Revise the plan based on the feedback below, then re-present (call ExitPlanMode again):
|
|
261
262
|
|
|
262
|
-
`+
|
|
263
|
+
`+H.feedback))}N(ZQ("\u23F3 Still awaiting your review in Beacon \u2014 the plan is open on /plan and nothing was lost. "+"Claude Code caps a single plan-review hook at ~10 minutes, so to keep waiting you MUST call ExitPlanMode again now with the SAME plan. Re-presenting resumes the same review (your in-progress annotations and any decision are preserved). Do NOT implement, and do "+"NOT ask in the terminal \u2014 just re-present."))})();
|