trybeacon 0.1.90 → 0.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +19 -19
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/@modal/(.)settings/page.js +1 -1
- package/.next/server/app/@modal/(.)settings/page.js.nft.json +1 -1
- package/.next/server/app/@modal/(.)settings/page_client-reference-manifest.js +1 -1
- 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.js +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +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 +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- 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/context/route.js +1 -1
- package/.next/server/app/api/ingest/route.js +1 -1
- package/.next/server/app/api/linear/route.js +1 -17
- package/.next/server/app/api/linear/route.js.nft.json +1 -1
- package/.next/server/app/api/linear/scopes/route.js +1 -17
- package/.next/server/app/api/linear/scopes/route.js.nft.json +1 -1
- package/.next/server/app/api/linear/sync/route.js +1 -17
- package/.next/server/app/api/linear/sync/route.js.nft.json +1 -1
- package/.next/server/app/api/plan/approve/route.js +1 -1
- package/.next/server/app/api/share/create/route.js +1 -1
- package/.next/server/app/docs/page.js +1 -1
- package/.next/server/app/docs/page.js.nft.json +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 +4 -4
- package/.next/server/app/docs.segments/@modal/__DEFAULT__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_full.segment.rsc +4 -4
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +3 -3
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/help/page.js +2 -2
- package/.next/server/app/help/page.js.nft.json +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 +4 -4
- package/.next/server/app/help.segments/@modal/__DEFAULT__.segment.rsc +1 -1
- package/.next/server/app/help.segments/_full.segment.rsc +4 -4
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +3 -3
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +2 -2
- 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/@modal/__DEFAULT__.segment.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- 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 +3 -3
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/learn/page.js +3 -3
- package/.next/server/app/learn/page.js.nft.json +1 -1
- package/.next/server/app/learn/page_client-reference-manifest.js +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.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/parked/page.js +1 -1
- package/.next/server/app/parked/page.js.nft.json +1 -1
- package/.next/server/app/parked/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +3 -3
- 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/s/[token]/page.js +2 -2
- package/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +1 -1
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +19 -19
- package/.next/server/chunks/1130.js +1 -1
- package/.next/server/chunks/1495.js +18 -0
- package/.next/server/chunks/{7436.js → 1898.js} +3 -3
- package/.next/server/chunks/2031.js +1 -1
- package/.next/server/chunks/2644.js +1 -0
- package/.next/server/chunks/3825.js +1 -1
- package/.next/server/chunks/4378.js +1 -1
- package/.next/server/chunks/{5332.js → 473.js} +3 -3
- package/.next/server/chunks/5623.js +1 -1
- package/.next/server/chunks/8227.js +1 -1
- package/.next/server/chunks/8709.js +8 -7
- package/.next/server/chunks/9683.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/2149-6eac4575d8a8281c.js +1 -0
- package/.next/static/chunks/{6283-20a6abe3453496ae.js → 3729-99f9edd66d1473ac.js} +3 -3
- package/.next/static/chunks/569-c70eb3d6c88282dc.js +1 -0
- package/.next/static/chunks/6818-051146427620d0f9.js +1 -0
- package/.next/static/chunks/8653-27d42df759159788.js +1 -0
- package/.next/static/chunks/app/@modal/(.)settings/page-77639f97e58859de.js +1 -0
- package/.next/static/chunks/app/docs/page-574e48b1b9519c80.js +1 -0
- package/.next/static/chunks/app/layout-6f04d1687adcd16e.js +1 -0
- package/.next/static/chunks/app/learn/{page-49bdcae5bf2a7a49.js → page-53c201dbfd759610.js} +1 -1
- package/.next/static/chunks/app/map/{page-6e32f55c7b69bfa0.js → page-147befd24a412e04.js} +1 -1
- package/.next/static/chunks/app/plan/{page-b8b89d7171a582ce.js → page-a35f98b97c750679.js} +2 -2
- package/.next/static/chunks/app/s/[token]/{page-7ebe66049fae02ce.js → page-db7be755d871820e.js} +1 -1
- package/.next/static/chunks/app/settings/page-c15764e1c2f54c5a.js +1 -0
- package/.next/static/css/b6c71ada5fa39830.css +1 -0
- package/.next/trace +47 -47
- package/.next/trace-build +1 -1
- package/dist/bin/ask.js +2 -2
- package/dist/bin/doctor.js +32 -30
- package/dist/bin/hook.js +31 -29
- package/dist/bin/mcp.js +41 -39
- package/dist/bin/plan.js +32 -30
- package/dist/bin/prompt.js +2 -2
- package/dist/bin/remove.js +3 -3
- package/dist/bin/stop-hook.js +4 -4
- package/dist/bin/uninstall.js +31 -29
- package/dist/lib/assets.js +20 -20
- package/dist/lib/codex-install.js +30 -28
- package/dist/lib/daemon-boot.js +11 -11
- package/dist/lib/global-install.js +31 -29
- package/drizzle/0013_quick_brother_voodoo.sql +1 -0
- package/drizzle/meta/0013_snapshot.json +1953 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/.next/server/chunks/2806.js +0 -1
- package/.next/static/chunks/2114-74736df56930b46c.js +0 -1
- package/.next/static/chunks/569-bfdcec83011428d3.js +0 -1
- package/.next/static/chunks/6818-85b9a09bb74062ef.js +0 -1
- package/.next/static/chunks/6930-1231a4681af2ad3f.js +0 -1
- package/.next/static/chunks/app/@modal/(.)settings/page-58f068e66bf2fdf6.js +0 -1
- package/.next/static/chunks/app/docs/page-126c0e42c71731b2.js +0 -1
- package/.next/static/chunks/app/layout-a8bb07fb86893add.js +0 -1
- package/.next/static/chunks/app/settings/page-435bfb2ac6f01744.js +0 -1
- package/.next/static/css/56890131dbc6daff.css +0 -1
- /package/.next/static/{l2BAGl1tReuc34hH3NvPZ → Ced4ZzirE-x-xhZEP02do}/_buildManifest.js +0 -0
- /package/.next/static/{l2BAGl1tReuc34hH3NvPZ → Ced4ZzirE-x-xhZEP02do}/_ssgManifest.js +0 -0
package/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-webpack","duration":
|
|
1
|
+
[{"name":"run-webpack","duration":30928298,"timestamp":233963513,"id":14,"parentId":1,"tags":{},"startTime":1783647951207,"traceId":"06b44c777b03ff6c"},{"name":"run-typescript","duration":11604046,"timestamp":264893867,"id":5102,"parentId":1,"tags":{},"startTime":1783647982138,"traceId":"06b44c777b03ff6c"},{"name":"static-check","duration":797441,"timestamp":276514481,"id":5105,"parentId":1,"tags":{},"startTime":1783647993758,"traceId":"06b44c777b03ff6c"},{"name":"static-generation","duration":4105937,"timestamp":277802128,"id":5307,"parentId":1,"tags":{},"startTime":1783647995046,"traceId":"06b44c777b03ff6c"},{"name":"collect-build-traces","duration":11052081,"timestamp":277314571,"id":5304,"parentId":1,"tags":{},"startTime":1783647994559,"traceId":"06b44c777b03ff6c"},{"name":"telemetry-flush","duration":59,"timestamp":288370433,"id":5316,"parentId":1,"tags":{},"startTime":1783648005614,"traceId":"06b44c777b03ff6c"},{"name":"next-build","duration":54593895,"timestamp":233776609,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1783647951021,"traceId":"06b44c777b03ff6c"}]
|
package/dist/bin/ask.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var JQ=Object.defineProperty;var UQ=(Q)=>Q;function zQ(Q,X){this[Q]=UQ.bind(null,X)}var NQ=(Q,X)=>{for(var Z in X)JQ(Q,Z,{get:X[Z],enumerable:!0,configurable:!0,set:zQ.bind(X,Z)})};var E=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X);var b={};NQ(b,{provisionDb:()=>_Q});import{createClient as jQ}from"@libsql/client";import{drizzle as CQ}from"drizzle-orm/libsql";import{migrate as LQ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as HQ}from"drizzle-orm/migrator";import{dirname as D,join as MQ}from"path";import{fileURLToPath as TQ}from"url";async function x(Q,X){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[X]})).rows.length>0}async function OQ(Q,X){let Z=await Q.execute(`PRAGMA table_info("${X}")`);return new Set(Z.rows.map(($)=>String($.name)))}async function v(Q){if(!await x(Q,"__drizzle_migrations"))return 0;let X=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(X.rows[0]?.n??0)}async function WQ(Q){for(let[X,Z]of Object.entries(DQ)){if(!await x(Q,X))continue;let $=await OQ(Q,X);for(let Y of Z){if(!$.has(Y))continue;await Q.execute(`UPDATE "${X}" SET "${Y}" = CAST((julianday("${Y}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${Y}") = 'text'`)}}}async function _Q(Q,X=EQ){let Z=jQ({url:Q});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let $=await x(Z,"__drizzle_migrations"),Y=await x(Z,"Node"),G=!1;if(Y&&!$){let J=HQ({migrationsFolder:X})[0];if(J)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[J.hash,J.folderMillis]}),G=!0}let V=await v(Z);if(await LQ(CQ(Z),{migrationsFolder:X}),await v(Z)>V)G=!0;return await WQ(Z),{migrated:G}}finally{Z.close()}}var xQ,EQ,DQ;var k=E(async()=>{xQ=D(D(D(TQ(import.meta.url)))),EQ=process.env.BEACON_MIGRATIONS_DIR||MQ(xQ,"drizzle"),DQ={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{mkdirSync as wQ,renameSync as gQ,rmSync as hQ,writeFileSync as lQ}from"fs";import{dirname as cQ}from"path";function pQ(Q,X){wQ(cQ(Q),{recursive:!0});let Z=`${Q}.tmp`;try{lQ(Z,X),gQ(Z,Q)}catch($){throw hQ(Z,{force:!0}),$}}function y(Q,X,Z=!1){pQ(Q,JSON.stringify(X,null,Z?2:void 0))}var S=()=>{};var QQ=1500,XQ=480000,dX=1800000,nX=3600000,oX=3000;var I=()=>{};import{AsyncLocalStorage as FQ}from"async_hooks";import{spawnSync as RQ}from"child_process";import{createHash as qQ}from"crypto";import{existsSync as m,mkdirSync as H,readFileSync as W,writeFileSync as _}from"fs";import{homedir as w}from"os";import{basename as fQ,join as N,parse as AQ,resolve as u}from"path";function B(){return process.env.BEACON_HOME||N(w(),".beacon")}function F(){return N(B(),"workspaces.json")}function j(Q){return qQ("sha256").update(Q).digest("hex").slice(0,12)}function R(Q=process.cwd()){let X=RQ("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(X.status===0){let Z=X.stdout?.toString().trim();if(Z)return Z}return Q}function g(Q){let X=u(Q);return X!==u(w())&&X!==AQ(X).root}function h(){return N(B(),"deleted.json")}function q(){try{let Q=JSON.parse(W(h(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function l(Q){H(B(),{recursive:!0}),_(h(),JSON.stringify(Q,null,2))}function c(Q){return q().includes(Q)}function DX(Q){let X=q();if(!X.includes(Q))l([...X,Q])}function yQ(Q){let X=q();if(X.includes(Q))l(X.filter((Z)=>Z!==Q))}function C(Q){return N(B(),Q)}function SQ(Q){return`file:${N(C(Q),"db.sqlite")}`}function M(){try{let Q=JSON.parse(W(F(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function f(Q){H(B(),{recursive:!0}),_(F(),JSON.stringify(Q,null,2))}function p(){return M().sort((Q,X)=>X.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function z(Q){return M().find((X)=>X.id===Q)??null}function d(Q,X,Z=new Date().toISOString()){if(!g(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let $=j(Q);if(c($))throw Error(`beacon: workspace ${$} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=M(),G=Y.find((U)=>U.id===$),V={id:$,path:Q,name:X||G?.name||fQ(Q),lastOpenedAt:Z},J=[V,...Y.filter((U)=>U.id!==$)];return H(C($),{recursive:!0}),f(J),V}function OX(Q,X){return yQ(j(Q)),d(Q,X)}function WX(Q,X=new Date().toISOString()){let Z=M(),$=Z.find((Y)=>Y.id===Q);if(!$)return;$.lastOpenedAt=X,f(Z)}function _X(Q){if(f(M().filter((X)=>X.id!==Q)),A()===Q)IQ(p()[0]?.id??null)}function n(){return N(B(),"active")}function A(){try{return W(n(),"utf8").trim()||null}catch{return null}}function IQ(Q){H(B(),{recursive:!0}),_(n(),Q??"")}function PQ(){let Q=A();return Q?z(Q):null}function FX(){let Q=i()??A();return Q?z(Q):null}function RX(Q){return z(Q)?.path??null}function qX(){return m(F())}var o="beacon_ws";function s(Q,X){let Z=Q.headers.get("cookie");if(!Z)return null;for(let $ of Z.split(";")){let Y=$.indexOf("=");if(Y===-1)continue;if($.slice(0,Y).trim()===X)return decodeURIComponent($.slice(Y+1).trim())}return null}function fX(Q){let X=Q.headers.get("x-beacon-workspace");if(X&&z(X))return X;let Z=s(Q,o);if(Z&&z(Z))return Z;return vQ()}function vQ(){let Q=p();return Q.length===1?Q[0].id:null}var a="x-beacon-workspace-path";function AX(Q=process.cwd()){let X=R(Q);return{"x-beacon-workspace":j(X),[a]:X}}async function yX(Q){let X=Q.headers.get("x-beacon-workspace");if(X&&z(X))return X;let Z=Q.headers.get(a);if(Z&&g(Z)&&!c(j(Z))&&(!X||j(Z)===X)){let Y=d(Z);return await bQ(Y.id),Y.id}let $=s(Q,o);if($&&z($))return $;return null}var r=new FQ;function SX(Q,X){return Q?r.run(Q,X):X()}function i(){return r.getStore()??null}var O=new Set;function IX(Q){O.delete(N(C(Q),"db.sqlite"))}async function bQ(Q){let X=C(Q),Z=N(X,"db.sqlite"),$=m(Z);if($&&O.has(Z))return{ok:!0,created:!1,migrated:!1};try{H(X,{recursive:!0});let{provisionDb:Y}=await k().then(() => b),G=await Y(SQ(Q));return O.add(Z),{ok:!0,created:!$,migrated:$&&G.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}import{connect as kQ}from"net";var t=4319;function uQ(Q,X,Z=400){return new Promise(($)=>{let Y=kQ({host:Q,port:X}),G=!1,V=(J)=>{if(G)return;G=!0,Y.destroy(),$(J)};Y.once("connect",()=>V(!0)),Y.once("error",()=>V(!1)),Y.setTimeout(Z,()=>V(!1))})}async function mQ(Q){for(let X of["127.0.0.1","::1"])if(await uQ(X,Q))return!1;return!0}async function bX(Q,X=20){for(let Z=Q;Z<Q+X;Z++)if(await mQ(Z))return Z;return Q}import{execSync as XX}from"child_process";import{createHash as ZX}from"crypto";S();import{readFileSync as dQ}from"fs";import{join as nQ}from"path";var oQ=43200000;function sQ(Q,X){let Z={};for(let[$,Y]of Object.entries(Q?.sessions??{}))if(X.now-Y.ts<oQ)Z[$]=Y;return Z[X.sessionId]={state:X.state,terminalId:X.terminalId,ts:X.now,cwd:X.cwd},{sessions:Z}}function e(Q){return nQ(C(Q),"agent-status.json")}function aQ(Q){try{return JSON.parse(dQ(e(Q),"utf8"))}catch{return null}}function T(Q,X,Z){try{if(!X)return;let $=j(R(Q)),Y=process.env.BEACON_TERMINAL_ID||null,G=sQ(aQ($),{sessionId:X,state:Z,terminalId:Y,cwd:Q,now:Date.now()});y(e($),G)}catch{}}S();I();function ZQ(Q,X){return{kind:"question",question:Q,mode:"mirror",transcriptPath:X}}function rQ(Q,X={}){let Z=typeof X.file_path==="string"?X.file_path:"",$=(Y)=>Y.length>4000?`${Y.slice(0,4000)}
|
|
4
4
|
\u2026 (truncated)`:Y;switch(Q){case"Bash":return{tool:Q,title:"Run command",preview:$(String(X.command??""))};case"Write":return{tool:Q,title:`Write ${Z}`.trim(),preview:$(String(X.content??""))};case"Edit":return{tool:Q,title:`Edit ${Z}`.trim(),preview:$(`- ${String(X.old_string??"")}
|
|
5
|
-
+ ${String(X.new_string??"")}`)};case"MultiEdit":{let Y=Array.isArray(X.edits)?X.edits.length:0;return{tool:Q,title:`Edit ${Z}`.trim(),preview:`${Y} edit(s) to ${Z}`}}case"NotebookEdit":{let Y=typeof X.notebook_path==="string"?X.notebook_path:"";return{tool:Q,title:`Edit ${Y}`.trim(),preview:$(String(X.new_source??""))}}default:return{tool:Q,title:Q,preview:$(JSON.stringify(X))}}}function
|
|
5
|
+
+ ${String(X.new_string??"")}`)};case"MultiEdit":{let Y=Array.isArray(X.edits)?X.edits.length:0;return{tool:Q,title:`Edit ${Z}`.trim(),preview:`${Y} edit(s) to ${Z}`}}case"NotebookEdit":{let Y=typeof X.notebook_path==="string"?X.notebook_path:"";return{tool:Q,title:`Edit ${Y}`.trim(),preview:$(String(X.new_source??""))}}default:return{tool:Q,title:Q,preview:$(JSON.stringify(X))}}}function $Q(Q){let X=Q.tool_name??"";if(Q.hook_event_name==="PreToolUse"&&X==="AskUserQuestion"){let $=Q.tool_input?.questions?.[0];if(!$)return null;return{kind:"question",question:{header:String($.header??""),question:String($.question??""),multiSelect:!!$.multiSelect,options:Array.isArray($.options)?$.options.map((Y)=>{let G=Y;return{label:String(G.label??""),description:G.description?String(G.description):void 0}}):[]}}}if(Q.hook_event_name==="PermissionRequest"&&X&&X!=="ExitPlanMode")return{kind:"approval",approval:rQ(X,Q.tool_input??{})};return null}I();import{readFileSync as iQ}from"fs";import{join as tQ}from"path";function eQ(){try{return JSON.parse(iQ(tQ(B(),"server.json"),"utf8"))}catch{return null}}function YQ(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${eQ()?.port||process.env.PORT||t}`}var QX=["default","acceptEdits","bypassPermissions","auto"];function BZ(Q){return typeof Q==="string"&&QX.includes(Q)}function GQ(Q,X,Z){let $={behavior:"allow"};if(Z&&Object.keys(Z).length>0)$.updatedInput=Z;if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(X?.trim())Y.additionalContext=X;return{hookSpecificOutput:Y}}var $X=(Q)=>new Promise((X)=>setTimeout(X,Q));function P(Q){if(Q!==void 0)process.stdout.write(JSON.stringify(Q));process.exit(0)}function L(){P(void 0)}function YX(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}async function GX(){if(process.stdin.isTTY)return null;let Q="";for await(let X of process.stdin)Q+=X;if(Q=Q.trim(),!Q)return null;try{return JSON.parse(Q)}catch{return null}}function VX(Q){try{return XX("git rev-parse --show-toplevel",{cwd:Q||process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return Q||process.cwd()}}var KX=(Q)=>ZX("sha256").update(Q).digest("hex").slice(0,12);(async()=>{let Q=await GX();if(!Q)L();let X=$Q(Q);if(!X)L();let Z=YQ(),$=KX(VX(Q.cwd)),Y={"content-type":"application/json","x-beacon-workspace":$},G=Q.cwd||process.cwd(),V=Q.session_id||"";if(X.kind==="question"){if(T(G,V,"waiting"),Q.transcript_path)await fetch(`${Z}/api/ask`,{method:"POST",headers:Y,body:JSON.stringify(ZQ(X.question,Q.transcript_path)),signal:AbortSignal.timeout(1500)}).catch(()=>{});L()}if(!await fetch(`${Z}/api/tab/view`,{headers:Y}).then((K)=>K.ok?K.json():null).then((K)=>!!K?.live).catch(()=>!1))L();await fetch(`${Z}/api/workspace/activate?id=${$}`).catch(()=>{});let U=await fetch(`${Z}/api/ask`,{method:"POST",headers:Y,body:JSON.stringify(X)}).then((K)=>K.ok?K.json():null).catch(()=>null);if(!U||U.loop||!U.id)L();let VQ=U.id;T(G,V,"waiting");let KQ=Date.now()+XQ;while(Date.now()<KQ){await $X(QQ);let K=await fetch(`${Z}/api/ask/verdict?id=${encodeURIComponent(VQ)}`,{headers:Y}).then((BQ)=>BQ.json()).catch(()=>null);if(!K||K.status!=="resolved")continue;if(T(G,V,"working"),K.resolution.decision==="deny")P(YX("The user denied this action in Beacon."));P(GQ())}T(G,V,"working"),L()})();
|
package/dist/bin/doctor.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`)}function
|
|
3
|
+
var rZ=Object.defineProperty;var dZ=(Q)=>Q;function nZ(Q,Z){this[Q]=dZ.bind(null,Z)}var fQ=(Q,Z)=>{for(var $ in Z)rZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:nZ.bind(Z,$)})};var E=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);import{existsSync as k,mkdirSync as TQ,readdirSync as aZ,readFileSync as y,rmSync as iZ,writeFileSync as o}from"fs";import{basename as oZ,dirname as ZZ,join as f}from"path";function $Z(){return!!process.env.CLAUDE_PLUGIN_ROOT}function e(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=f(Q,".claude","plugins");if(!k(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let z=f(V,".claude-plugin","plugin.json");try{if(k(z)&&JSON.parse(y(z,"utf8")).name==="beacon")return V}catch{}try{for(let U of aZ(V,{withFileTypes:!0}))if(U.isDirectory())Y.push(f(V,U.name))}catch{}}$=Y}return null}function JZ(Q){return e(Q)!==null}function eZ(Q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(Q)}function M(){let Q=process.env.BEACON_CLI_PATH;if(Q)return Q;if(k(i))return i;return"beacon"}function xQ(Q){let Z=Q.indexOf(" ");return Z===-1?Q:Q.slice(0,Z)}function _(Q){let Z=M();if(Z==="beacon")return Q;return Q.replace(/^beacon(\s|$)/,`${Z}$1`)}function w(Q){let Z=xQ(Q);return oZ(Z)+Q.slice(Z.length)}function Q0(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;try{let Z=JSON.parse(y(f(Q,".claude","plugins","installed_plugins.json"),"utf8"));for(let $ of Object.keys(Z.plugins??{}))if(/^beacon@/.test($))return{key:$,marketplace:$.split("@")[1]??""}}catch{}return null}function S(Q){try{return JSON.parse(y(Q,"utf8"))}catch{return{}}}function CQ(Q,Z){TQ(ZZ(Q),{recursive:!0}),o(Q,JSON.stringify(Z,null,2)+`
|
|
4
|
+
`)}function ZQ(Q,Z,$={}){let J=S(Q);J.hooks=J.hooks??{},J.hooks[Z.event]=J.hooks[Z.event]??[];let Y=J.hooks[Z.event];if(Y.some((z)=>z.hooks?.some((U)=>w(U.command)===w(Z.command)&&($.matchAnyMatcher||z.matcher===Z.matcher))))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),CQ(Q,J),!0}function YZ(Q,Z){let $=S(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=J.flatMap((U,q)=>(U.hooks??[]).flatMap((X,K)=>w(X.command)===w(Z.command)?[{matcherIndex:q,hookIndex:K,preferred:U.matcher===Z.matcher}]:[]));if(Y.length<2)return!1;let V=Y.find((U)=>U.preferred)??Y[0],z=new Set(Y.filter((U)=>U!==V).map((U)=>`${U.matcherIndex}:${U.hookIndex}`));return $.hooks[Z.event]=J.map((U,q)=>({...U,hooks:(U.hooks??[]).filter((X,K)=>!z.has(`${q}:${K}`))})).filter((U)=>(U.hooks??[]).length>0),CQ(Q,$),!0}function $Q(Q,Z){return(S(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>w(V.command)===w(Z.command)))}function VZ(Q,Z){let J=S(Q).hooks?.[Z.event]??[];for(let Y of J)for(let V of Y.hooks??[])if(w(V.command)===w(Z.command))return V.command;return null}function JQ(Q,Z){let $=S(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((z)=>{let U=z.hooks?.length??0,q=(z.hooks??[]).filter((X)=>w(X.command)!==w(Z.command));if(q.length!==U)Y=!0;return{...z,hooks:q}}).filter((z)=>(z.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 CQ(Q,$),!0}function YQ(Q,Z,$,J){let Y=`${Z}
|
|
5
5
|
${J.trim()}
|
|
6
|
-
${$}`,V="";try{V=
|
|
6
|
+
${$}`,V="";try{V=y(Q,"utf8")}catch{}let z=new RegExp(`${Z}[\\s\\S]*?${$}`);V=z.test(V)?V.replace(z,Y):V.trim()?`${V.trim()}
|
|
7
7
|
|
|
8
8
|
${Y}
|
|
9
9
|
`:`${Y}
|
|
10
|
-
`,
|
|
10
|
+
`,TQ(ZZ(Q),{recursive:!0}),o(Q,V.endsWith(`
|
|
11
11
|
`)?V:`${V}
|
|
12
|
-
`)}function
|
|
12
|
+
`)}function h(Q,Z){try{return y(Q,"utf8").includes(Z)}catch{return!1}}function VQ(Q,Z,$){let J="";try{J=y(Q,"utf8")}catch{return!1}let Y=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!Y.test(J))return!1;let V=J.replace(Y,"").replace(/\n{3,}/g,`
|
|
13
13
|
|
|
14
|
-
`).trimStart();return
|
|
14
|
+
`).trimStart();return o(Q,V),!0}function qQ(Q,Z,$){let J=f(Q,Z);TQ(J,{recursive:!0});let Y=f(J,"SKILL.md");return o(Y,$),Y}function p(Q,Z){return k(f(Q,Z,"SKILL.md"))}function zQ(Q,Z){let $=f(Q,Z);if(!k($))return!1;return iZ($,{recursive:!0,force:!0}),!0}var G,i="/Applications/Beacon.app/Contents/Resources/bin/beacon",QQ=`## Beacon (visual planning panel)
|
|
15
15
|
|
|
16
16
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
17
17
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -35,23 +35,23 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
35
35
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
36
36
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
37
37
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
38
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
38
|
+
verbatim. Do NOT implement until the tool returns approval.`;var m=E(()=>{G=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var M1=1500,R1=480000,F1=1800000,UQ=3600000,u1=3000;var qZ=()=>{};var IQ={};fQ(IQ,{stripAgentsPointer:()=>WZ,repoMcpCliTarget:()=>yQ,removeRepoAssets:()=>X0,installRefreshSkill:()=>$0,installPlanSkill:()=>J0,installInitSkill:()=>Z0,installExplainSkill:()=>Y0,installCodexRepoSkills:()=>q0,ensureWorkflowDoc:()=>z0,ensureMcp:()=>U0,contextDocTargets:()=>EQ,auditRepo:()=>AQ,REFRESH_SKILL:()=>OQ,PLAN_SKILL:()=>UZ,INIT_SKILL:()=>gQ,EXPLAIN_SKILL:()=>XZ});import{existsSync as F,mkdirSync as c,readFileSync as u,rmSync as XQ,writeFileSync as B}from"fs";import{join as W}from"path";function Z0(Q){let Z=W(Q,".claude","skills","beacon-init");c(Z,{recursive:!0});let $=W(Z,"SKILL.md");return B($,gQ),$}function $0(Q){let Z=W(Q,".claude","skills","beacon-refresh");c(Z,{recursive:!0});let $=W(Z,"SKILL.md");return B($,OQ),$}function J0(Q){let Z=W(Q,".claude","skills","beacon-plan");c(Z,{recursive:!0});let $=W(Z,"SKILL.md");return B($,UZ),$}function Y0(Q){let Z=W(Q,".claude","skills","beacon-explain");c(Z,{recursive:!0});let $=W(Z,"SKILL.md");return B($,XZ),$}function q0(Q){let Z=[];for(let $ of V0){let J=W(Q,".agents","skills",$.name);c(J,{recursive:!0});let Y=W(J,"SKILL.md");B(Y,$.body()),Z.push(Y)}return Z}function EQ(Q){let Z=W(Q,"AGENTS.md"),$=W(Q,"CLAUDE.md"),J=F(Z),Y=F($);if(!J&&!Y)return[Z,$];let V=[];if(J)V.push(Z);if(Y)V.push($);return V}function WZ(Q){let Z=W(Q,"CLAUDE.md");if(!F(Z))return;let $=u(Z,"utf8"),J=$.split(`
|
|
39
39
|
`).filter((Y)=>!/^\s*@\.?\/?AGENTS\.md\s*$/.test(Y)).join(`
|
|
40
40
|
`).trim();if(J&&J!==$.trim())B(Z,`${J}
|
|
41
|
-
`)}function
|
|
41
|
+
`)}function z0(Q){let Z=new RegExp(`${WQ}[\\s\\S]*?${DQ}`);for(let $ of EQ(Q)){let J="";try{J=u($,"utf8")}catch{}J=Z.test(J)?J.replace(Z,zZ):`${J.trim()}
|
|
42
42
|
|
|
43
|
-
${
|
|
43
|
+
${zZ}
|
|
44
44
|
`.trimStart(),B($,J.endsWith(`
|
|
45
45
|
`)?J:`${J}
|
|
46
|
-
`)}
|
|
47
|
-
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:
|
|
48
|
-
`),{path:Z,added:!0,updated:!1}}function
|
|
49
|
-
`)}}catch{}let Y=!1,V=new RegExp(`\\n?${
|
|
46
|
+
`)}WZ(Q)}function U0(Q){let Z=W(Q,".mcp.json"),$={};try{$=JSON.parse(u(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<UQ)return J.timeout=UQ,B(Z,JSON.stringify($,null,2)+`
|
|
47
|
+
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:M(),args:["mcp"],timeout:UQ},B(Z,JSON.stringify($,null,2)+`
|
|
48
|
+
`),{path:Z,added:!0,updated:!1}}function yQ(Q){try{return JSON.parse(u(W(Q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function AQ(Q){let Z=W(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(u(Z,"utf8")).mcpServers?.beacon}catch{}let J=EQ(Q).some((Y)=>{try{return u(Y,"utf8").includes(WQ)}catch{return!1}});return{repo:Q,mcpRegistered:$,workflowBlock:J,skills:{"beacon-init":F(W(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":F(W(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":F(W(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":F(W(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function X0(Q){let Z=[];for(let q of["beacon-init","beacon-refresh","beacon-db-design"]){let X=W(Q,".claude","skills",q);if(F(X))XQ(X,{recursive:!0,force:!0}),Z.push(q)}for(let q of["beacon-init","beacon-refresh"]){let X=W(Q,".agents","skills",q);if(F(X))XQ(X,{recursive:!0,force:!0}),Z.push(`codex:${q}`)}let $=!1,J=W(Q,".mcp.json");try{let q=JSON.parse(u(J,"utf8"));if(q.mcpServers?.beacon){if(delete q.mcpServers.beacon,$=!0,q.mcpServers&&Object.keys(q.mcpServers).length===0)delete q.mcpServers;if(Object.keys(q).length===0)XQ(J,{force:!0});else B(J,JSON.stringify(q,null,2)+`
|
|
49
|
+
`)}}catch{}let Y=!1,V=new RegExp(`\\n?${WQ}[\\s\\S]*?${DQ}\\n?`);for(let q of[W(Q,"AGENTS.md"),W(Q,"CLAUDE.md")])try{let X=u(q,"utf8");if(V.test(X)){let K=X.replace(V,`
|
|
50
50
|
`).replace(/\n{3,}/g,`
|
|
51
51
|
|
|
52
|
-
`).trimStart();B(q,
|
|
53
|
-
`)?
|
|
54
|
-
`),Y=!0}}catch{}let z=!1,
|
|
52
|
+
`).trimStart();B(q,K.endsWith(`
|
|
53
|
+
`)?K:`${K}
|
|
54
|
+
`),Y=!0}}catch{}let z=!1,U=W(Q,"CLAUDE.md");try{let q=u(U,"utf8"),X=q.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(X!==q){if(!X.trim())XQ(U,{force:!0});else B(U,X);z=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:z}}var gQ=`---
|
|
55
55
|
name: beacon-init
|
|
56
56
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
57
57
|
---
|
|
@@ -98,7 +98,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
|
|
|
98
98
|
That one command wires the repo (writes \`.mcp.json\` + skills so your NEXT session gets the \`beacon_*\` tools natively, heals the global install), starts the Beacon daemon if it isn't running, registers + provisions this workspace, and POSTs your analysis to the same \`/api/init\` endpoint the MCP tool uses \u2014 so init completes in THIS session. Read the counts it prints and report them.
|
|
99
99
|
|
|
100
100
|
After the tool (or \`beacon init-persist\`) returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
|
|
101
|
-
`,
|
|
101
|
+
`,OQ=`---
|
|
102
102
|
name: beacon-refresh
|
|
103
103
|
description: Re-survey the repo and update Beacon's architecture / schema / endpoints map after /beacon-init was already run \u2014 picks up new components, removed ones, schema changes, and new routes. Use when the user runs /beacon-refresh or asks to "refresh", "update", "re-sync", or "bring Beacon up to date" with the current code.
|
|
104
104
|
---
|
|
@@ -145,7 +145,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
145
145
|
If \`beacon_entities\` or \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-refresh.
|
|
146
146
|
|
|
147
147
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
148
|
-
`,
|
|
148
|
+
`,UZ=`---
|
|
149
149
|
name: beacon-plan
|
|
150
150
|
description: Present your current plan or approach to the user on Beacon's /plan canvas for review \u2014 instead of asking for approval in prose. Use when the user says "present the plan", "show me the plan", "let me see it / the plan", or whenever you are about to end a turn asking whether to proceed with a plan, design, or approach.
|
|
151
151
|
---
|
|
@@ -194,7 +194,7 @@ If it returns feedback, revise and call it again.
|
|
|
194
194
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
195
195
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
196
196
|
run \`beacon\` in this repo once.
|
|
197
|
-
`,
|
|
197
|
+
`,XZ=`---
|
|
198
198
|
name: beacon-explain
|
|
199
199
|
description: Teach the user part of THIS codebase as an interactive visual lesson on Beacon's /learn page \u2014 a concept map + plain-English narrative they can question \u2014 instead of a wall of text. Use when the user says "explain", "teach me", "walk me through", "how does X work", or "help me understand the Y category".
|
|
200
200
|
---
|
|
@@ -264,7 +264,7 @@ so the learner sees the table IN CONTEXT, wired to the code that uses it.
|
|
|
264
264
|
Every answer must ADD understanding (rationale, trade-off) \u2014 never just restate the question. Expand
|
|
265
265
|
the narrative or add nodes where it helps. Keep looping until the tool reports the user saved or closed
|
|
266
266
|
the lesson.
|
|
267
|
-
`,
|
|
267
|
+
`,V0,WQ="<!-- beacon:workflow:start -->",DQ="<!-- beacon:workflow:end -->",zZ;var HQ=E(()=>{m();qZ();V0=[{name:"beacon-init",body:()=>gQ},{name:"beacon-refresh",body:()=>OQ}];zZ=`${WQ}
|
|
268
268
|
## Beacon \u2014 feature workflow
|
|
269
269
|
|
|
270
270
|
This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
|
|
@@ -336,20 +336,22 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
336
336
|
If the feature added or materially changed a REAL architectural component (a subsystem \u2014 NOT a file), also pass \`architecture: [{ title, domain, role, \u2026 }]\` so the Architecture map stays accurate. It upserts curated components by title; never list files as components. If you found a bug or something worth investigating in a component's code, add \`bugs: [{ note }]\` to its architecture entry \u2014 it renders as a bug flag on the node (attributed to the agent); identical open flags are not duplicated. Only flag what you actually saw in the code.
|
|
337
337
|
|
|
338
338
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
339
|
-
${
|
|
340
|
-
`)){let Y=J.trim();if(!Y||Y.startsWith("#"))continue;let V=/^\[([^\]]+)\]/.exec(Y);if(V){if($=V[1].trim()==="mcp_servers.beacon",$)Z.mcp_servers=Z.mcp_servers??{},Z.mcp_servers.beacon=Z.mcp_servers.beacon??{};continue}if($){let z=/^command\s*=\s*["']([^"']*)["']/.exec(Y);if(z)Z.mcp_servers.beacon.command=z[1]}}return Z}function
|
|
339
|
+
${DQ}`});import{mkdirSync as W0,renameSync as H0,rmSync as j0,writeFileSync as v0}from"fs";import{dirname as G0}from"path";function l(Q,Z){W0(G0(Q),{recursive:!0});let $=`${Q}.tmp`;try{v0($,Z),H0($,Q)}catch(J){throw j0($,{force:!0}),J}}function E1(Q,Z,$=!1){l(Q,JSON.stringify(Z,null,$?2:void 0))}var HZ=()=>{};var wZ={};fQ(wZ,{setupCodexAssets:()=>F0,removeCodexMcp:()=>KZ,removeCodexArtifacts:()=>u0,parseTomlBeacon:()=>BZ,nodeWhich:()=>GZ,hasCodexMcp:()=>kQ,ensureCodexMcp:()=>PZ,commandExists:()=>NZ,codexMcpProblem:()=>_Q,codexMcpCliTarget:()=>SQ,codexDetected:()=>r,auditCodex:()=>hQ,CODEX_HOOKS:()=>g});import{accessSync as N0,constants as B0,readFileSync as t}from"fs";import{homedir as P0}from"os";import{delimiter as K0,join as I}from"path";function jZ(){return process.env.HOME||process.env.USERPROFILE||P0()}function GZ(Q,Z=process.env.PATH||"",$=w0){if(!Q)return null;for(let J of Z.split(K0)){if(!J)continue;let Y=I(J,Q);if($(Y))return Y}return null}function w0(Q){try{return N0(Q,B0.X_OK),!0}catch{return!1}}function NZ(Q){if(typeof Bun<"u"&&typeof Bun.which==="function")return Bun.which(Q)!==null;return GZ(Q)!==null}function r(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(bQ===void 0)bQ=NZ("codex");return bQ}function BZ(Q){let Z={},$=!1;for(let J of Q.split(`
|
|
340
|
+
`)){let Y=J.trim();if(!Y||Y.startsWith("#"))continue;let V=/^\[([^\]]+)\]/.exec(Y);if(V){if($=V[1].trim()==="mcp_servers.beacon",$)Z.mcp_servers=Z.mcp_servers??{},Z.mcp_servers.beacon=Z.mcp_servers.beacon??{};continue}if($){let z=/^command\s*=\s*["']([^"']*)["']/.exec(Y);if(z)Z.mcp_servers.beacon.command=z[1]}}return Z}function A(Q){try{if(typeof Bun<"u"&&Bun.TOML?.parse)return Bun.TOML.parse(Q);return BZ(Q)}catch{return null}}function kQ(){try{return Boolean(A(t(T(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function _Q(){let Q="";try{Q=t(T(),"utf8")}catch{return null}let Z=A(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${s}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${s}`;return null}function R0(Q){let Z=Q.split(`
|
|
341
|
+
`),$=Z.indexOf(BQ),J=Z.indexOf(PQ,$);if($===-1||J===-1)return null;let Y=Z.findIndex((U,q)=>q>$&&q<J&&U.trim()==="[mcp_servers.beacon]");if(Y===-1)return null;let V=Y+1;while(V<J&&!/^\s*\[/.test(Z[V]))V++;let z=Z.findIndex((U,q)=>q>Y&&q<V&&/^\s*command\s*=/.test(U));if(z===-1)return null;return Z[z]=`command = ${JSON.stringify(M())}`,Z.join(`
|
|
342
|
+
`)}function PZ(){let Q="",Z=!1;try{Q=t(T(),"utf8"),Z=!0}catch{}if(Z){let V=A(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${s}`};if(V.mcp_servers?.beacon){let z=R0(Q);if(z&&z!==Q)l(T(),z);return{added:!1}}if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${s}`}}let $=!Q?"":Q.endsWith(`
|
|
341
343
|
`)?`
|
|
342
344
|
`:`
|
|
343
345
|
|
|
344
|
-
`,J=Q+$+
|
|
345
|
-
`),$=Z.indexOf(
|
|
346
|
+
`,J=Q+$+M0();if(A(J)?.mcp_servers?.beacon?.command!==M())return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${s}`};return l(T(),J),{added:!0}}function SQ(){try{return A(t(T(),"utf8"))?.mcp_servers?.beacon?.command??null}catch{return null}}function KZ(){let Q="";try{Q=t(T(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
347
|
+
`),$=Z.indexOf(BQ);if($===-1)return{removed:!1,skipped:kQ()};let J=Z.indexOf(PQ,$);if(J===-1)return{removed:!1,skipped:!0};let Y=Z.findIndex((U,q)=>q>$&&q<J&&U.trim()==="[mcp_servers.beacon]");if(Y===-1)return{removed:!1,skipped:!0};let V=Y+1;while(V<J&&!/^\s*\[/.test(Z[V]))V++;Z.splice(Y,V-Y),Z.splice(Z.indexOf(PQ),1),Z.splice(Z.indexOf(BQ),1);let z=Z.join(`
|
|
346
348
|
`).replace(/\n{3,}/g,`
|
|
347
349
|
|
|
348
|
-
`).replace(/^\n+/,"");if(
|
|
350
|
+
`).replace(/^\n+/,"");if(A(z)===null)return{removed:!1,skipped:!0};return l(T(),z),{removed:!0}}async function F0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (HQ(),IQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let X of G){if(!p(GQ(),X))V.push(X);qQ(GQ(),X,Y[X])}let z=0;for(let X of g){let K=X.event==="UserPromptSubmit"||X.event==="Stop";if(K)YZ(jQ(),{event:X.event,matcher:X.matcher,command:_(X.command)});if(ZQ(jQ(),{event:X.event,matcher:X.matcher,command:_(X.command)},{matchAnyMatcher:K}))z++}let U=h(vQ(),NQ);YQ(vQ(),NQ,vZ,QQ);let q=PZ();return{skillsAdded:V,hooksAdded:z,agentsMdBlockTouched:!U,mcp:q}}function hQ(){let Q={};for(let $ of G)Q[$]=p(GQ(),$);let Z={};for(let $ of g)Z[$.event]=$Q(jQ(),{event:$.event,command:$.command});return{detected:r(),skills:Q,hooks:Z,agentsMdBlock:h(vQ(),NQ),mcp:kQ()}}function u0(){let Q=[];for(let Y of G)if(zQ(GQ(),Y))Q.push(Y);let Z=0;for(let Y of g)if(JQ(jQ(),{event:Y.event,command:Y.command}))Z++;let $=VQ(vQ(),NQ,vZ),J=KZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var LQ=()=>I(jZ(),".codex"),jQ=()=>I(LQ(),"hooks.json"),T=()=>I(LQ(),"config.toml"),vQ=()=>I(LQ(),"AGENTS.md"),GQ=()=>I(jZ(),".agents","skills"),NQ="<!-- beacon:global:start -->",vZ="<!-- beacon:global:end -->",g,bQ,BQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",PQ="# beacon:end",M0=()=>`${BQ}
|
|
349
351
|
[mcp_servers.beacon]
|
|
350
|
-
command = "${
|
|
352
|
+
command = "${M()}"
|
|
351
353
|
args = ["mcp"]
|
|
352
|
-
${
|
|
353
|
-
`,p="add it manually: codex mcp add beacon -- beacon mcp";var LQ=g(()=>{S();XZ();C=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}]});var uZ={};wQ(uZ,{provisionDb:()=>t0});import{createClient as b0}from"@libsql/client";import{drizzle as k0}from"drizzle-orm/libsql";import{migrate as _0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as L0}from"drizzle-orm/migrator";import{dirname as mQ,join as S0}from"path";import{fileURLToPath as h0}from"url";async function KQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function s0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function fZ(Q){if(!await KQ(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 l0(Q){for(let[Z,$]of Object.entries(c0)){if(!await KQ(Q,Z))continue;let J=await s0(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 t0(Q,Z=m0){let $=b0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await KQ($,"__drizzle_migrations"),Y=await KQ($,"Node"),V=!1;if(Y&&!J){let H=L0({migrationsFolder:Z})[0];if(H)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:[H.hash,H.folderMillis]}),V=!0}let z=await fZ($);if(await _0(k0($),{migrationsFolder:Z}),await fZ($)>z)V=!0;return await l0($),{migrated:V}}finally{$.close()}}var p0,m0,c0;var TZ=g(async()=>{p0=mQ(mQ(mQ(h0(import.meta.url)))),m0=process.env.BEACON_MIGRATIONS_DIR||S0(p0,"drizzle"),c0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});S();import{existsSync as R0}from"fs";import{homedir as F0}from"os";import{join as NQ}from"path";function f0(){return process.env.HOME||process.env.USERPROFILE||F0()}var GQ=()=>NQ(f0(),".claude"),SQ=()=>NQ(GQ(),"skills"),BQ=()=>NQ(GQ(),"settings.json"),hQ=()=>NQ(GQ(),"CLAUDE.md"),pQ="<!-- beacon:global:start -->",xZ="<!-- beacon:global:end -->";var u0=o,y=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract: in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. Fail-open when there's no active contract."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"PreToolUse",matcher:"AskUserQuestion",command:"beacon ask",description:"Surface the agent's AskUserQuestion in Beacon's modal; your pick flows back as the answer (falls through to the terminal if Beacon isn't open)."},{event:"PermissionRequest",matcher:"Edit|Write|MultiEdit|Bash|NotebookEdit",command:"beacon ask",description:"Surface edit/create/run approvals in Beacon's modal; your allow/deny flows back (falls through to the terminal prompt if Beacon isn't open)."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function T0(Q,Z){return YQ(SQ(),Q,Z)}function MZ(Q){return L(SQ(),Q)}function C0(Q){return VQ(SQ(),Q)}function I0(Q){return e(BQ(),Q)}function O0(Q){return QQ(BQ(),Q)}function g0(Q){return ZQ(BQ(),Q)}function E0(Q){$Q(hQ(),pQ,xZ,Q)}function wZ(){return _(hQ(),pQ)}function D0(){return JQ(hQ(),pQ,xZ)}function RZ(){let Q={};for(let $ of N)Q[$]=MZ($);let Z={};for(let $ of y)Z[$.event]=O0({event:$.event,command:$.command});return{homeExists:R0(GQ()),skills:Q,hooks:Z,claudeMdBlock:wZ()}}function FZ(){let Q=$Z(BQ(),{event:"PostToolUse",command:"beacon hook"});return Q?FQ(Q):null}async function A0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (UQ(),gQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let q of N){if(!MZ(q))V.push(q);T0(q,Y[q])}let z=0;for(let q of y)if(I0({event:q.event,matcher:q.matcher,command:a(q.command)}))z++;let H=wZ();return E0(u0),{skillsAdded:V,hooksAdded:z,claudeMdBlockTouched:!H}}async function h1(){if(eQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(QZ()){try{y0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await A0()}}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(() => (LQ(),PZ));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 y0(){let Q=[];for(let J of N)if(C0(J))Q.push(J);let Z=0;for(let J of y)if(g0(J))Z++;let $=D0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as n0}from"async_hooks";import{spawnSync as r0}from"child_process";import{createHash as d0}from"crypto";import{existsSync as IZ,mkdirSync as l,readFileSync as sQ,writeFileSync as lQ}from"fs";import{homedir as OZ}from"os";import{basename as a0,join as f,parse as o0,resolve as CZ}from"path";function P(){return process.env.BEACON_HOME||f(OZ(),".beacon")}function tQ(){return f(P(),"workspaces.json")}function s(Q){return d0("sha256").update(Q).digest("hex").slice(0,12)}function i0(Q=process.cwd()){let Z=r0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function gZ(Q){let Z=CZ(Q);return Z!==CZ(OZ())&&Z!==o0(Z).root}function EZ(){return f(P(),"deleted.json")}function nQ(){try{let Q=JSON.parse(sQ(EZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function DZ(Q){l(P(),{recursive:!0}),lQ(EZ(),JSON.stringify(Q,null,2))}function AZ(Q){return nQ().includes(Q)}function Q2(Q){let Z=nQ();if(!Z.includes(Q))DZ([...Z,Q])}function e0(Q){let Z=nQ();if(Z.includes(Q))DZ(Z.filter(($)=>$!==Q))}function PQ(Q){return f(P(),Q)}function Q1(Q){return`file:${f(PQ(Q),"db.sqlite")}`}function t(){try{let Q=JSON.parse(sQ(tQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function rQ(Q){l(P(),{recursive:!0}),lQ(tQ(),JSON.stringify(Q,null,2))}function xQ(){return t().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function I(Q){return t().find((Z)=>Z.id===Q)??null}function yZ(Q,Z,$=new Date().toISOString()){if(!gZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=s(Q);if(AZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=t(),V=Y.find((q)=>q.id===J),z={id:J,path:Q,name:Z||V?.name||a0(Q),lastOpenedAt:$},H=[z,...Y.filter((q)=>q.id!==J)];return l(PQ(J),{recursive:!0}),rQ(H),z}function Z2(Q,Z){return e0(s(Q)),yZ(Q,Z)}function $2(Q,Z=new Date().toISOString()){let $=t(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,rQ($)}function J2(Q){if(rQ(t().filter((Z)=>Z.id!==Q)),dQ()===Q)Z1(xQ()[0]?.id??null)}function bZ(){return f(P(),"active")}function dQ(){try{return sQ(bZ(),"utf8").trim()||null}catch{return null}}function Z1(Q){l(P(),{recursive:!0}),lQ(bZ(),Q??"")}function Y2(){let Q=dQ();return Q?I(Q):null}function V2(){let Q=J1()??dQ();return Q?I(Q):null}function q2(Q){return I(Q)?.path??null}function z2(){return IZ(tQ())}var kZ="beacon_ws";function _Z(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 X2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&I(Z))return Z;let $=_Z(Q,kZ);if($&&I($))return $;return $1()}function $1(){let Q=xQ();return Q.length===1?Q[0].id:null}var LZ="x-beacon-workspace-path";function U2(Q=process.cwd()){let Z=i0(Q);return{"x-beacon-workspace":s(Z),[LZ]:Z}}async function W2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&I(Z))return Z;let $=Q.headers.get(LZ);if($&&gZ($)&&!AZ(s($))&&(!Z||s($)===Z)){let Y=yZ($);return await Y1(Y.id),Y.id}let J=_Z(Q,kZ);if(J&&I(J))return J;return null}var SZ=new n0;function H2(Q,Z){return Q?SZ.run(Q,Z):Z()}function J1(){return SZ.getStore()??null}var cQ=new Set;function j2(Q){cQ.delete(f(PQ(Q),"db.sqlite"))}async function Y1(Q){let Z=PQ(Q),$=f(Z,"db.sqlite"),J=IZ($);if(J&&cQ.has($))return{ok:!0,created:!1,migrated:!1};try{l(Z,{recursive:!0});let{provisionDb:Y}=await TZ().then(() => uZ),V=await Y(Q1(Q));return cQ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}S();UQ();LQ();import{execSync as V1,spawnSync as pZ}from"child_process";import{existsSync as mZ,readFileSync as q1}from"fs";import{join as cZ}from"path";var W=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,j=(Q)=>`\x1B[31m\u2717\x1B[0m ${Q}`,G=(Q)=>`\x1B[2m${Q}\x1B[0m`,O=(Q)=>`
|
|
354
|
-
\x1B[1m${Q}\x1B[0m`;function
|
|
355
|
-
${
|
|
354
|
+
${PQ}
|
|
355
|
+
`,s="add it manually: codex mcp add beacon -- beacon mcp";var pQ=E(()=>{m();HZ();g=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}]});var xZ={};fQ(xZ,{provisionDb:()=>d0});import{createClient as k0}from"@libsql/client";import{drizzle as _0}from"drizzle-orm/libsql";import{migrate as S0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as h0}from"drizzle-orm/migrator";import{dirname as sQ,join as p0}from"path";import{fileURLToPath as m0}from"url";async function RQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function t0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function TZ(Q){if(!await RQ(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 r0(Q){for(let[Z,$]of Object.entries(s0)){if(!await RQ(Q,Z))continue;let J=await t0(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 d0(Q,Z=l0){let $=k0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await RQ($,"__drizzle_migrations"),Y=await RQ($,"Node"),V=!1;if(Y&&!J){let U=h0({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 z=await TZ($);if(await S0(_0($),{migrationsFolder:Z}),await TZ($)>z)V=!0;return await r0($),{migrated:V}}finally{$.close()}}var c0,l0,s0;var CZ=E(async()=>{c0=sQ(sQ(sQ(m0(import.meta.url)))),l0=process.env.BEACON_MIGRATIONS_DIR||p0(c0,"drizzle"),s0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});m();import{existsSync as f0}from"fs";import{homedir as T0}from"os";import{join as KQ}from"path";function x0(){return process.env.HOME||process.env.USERPROFILE||T0()}var wQ=()=>KQ(x0(),".claude"),mQ=()=>KQ(wQ(),"skills"),MQ=()=>KQ(wQ(),"settings.json"),cQ=()=>KQ(wQ(),"CLAUDE.md"),lQ="<!-- beacon:global:start -->",MZ="<!-- beacon:global:end -->";var C0=QQ,b=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract: in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. Fail-open when there's no active contract."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"PreToolUse",matcher:"AskUserQuestion",command:"beacon ask",description:"Surface the agent's AskUserQuestion in Beacon's modal; your pick flows back as the answer (falls through to the terminal if Beacon isn't open)."},{event:"PermissionRequest",matcher:"Edit|Write|MultiEdit|Bash|NotebookEdit",command:"beacon ask",description:"Surface edit/create/run approvals in Beacon's modal; your allow/deny flows back (falls through to the terminal prompt if Beacon isn't open)."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function g0(Q,Z){return qQ(mQ(),Q,Z)}function RZ(Q){return p(mQ(),Q)}function O0(Q){return zQ(mQ(),Q)}function D0(Q){return ZQ(MQ(),Q)}function E0(Q){return $Q(MQ(),Q)}function y0(Q){return JQ(MQ(),Q)}function A0(Q){YQ(cQ(),lQ,MZ,Q)}function FZ(){return h(cQ(),lQ)}function I0(){return VQ(cQ(),lQ,MZ)}function uZ(){let Q={};for(let $ of G)Q[$]=RZ($);let Z={};for(let $ of b)Z[$.event]=E0({event:$.event,command:$.command});return{homeExists:f0(wQ()),skills:Q,hooks:Z,claudeMdBlock:FZ()}}function fZ(){let Q=VZ(MQ(),{event:"PostToolUse",command:"beacon hook"});return Q?xQ(Q):null}async function b0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:J}=await Promise.resolve().then(() => (HQ(),IQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":J},V=[];for(let q of G){if(!RZ(q))V.push(q);g0(q,Y[q])}let z=0;for(let q of b)if(D0({event:q.event,matcher:q.matcher,command:_(q.command)}))z++;let U=FZ();return A0(C0),{skillsAdded:V,hooksAdded:z,claudeMdBlockTouched:!U}}async function m1(){if($Z())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(JZ()){try{L0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await b0()}}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(() => (pQ(),wZ));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 L0(){let Q=[];for(let J of G)if(O0(J))Q.push(J);let Z=0;for(let J of b)if(y0(J))Z++;let $=I0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as n0}from"async_hooks";import{spawnSync as a0}from"child_process";import{createHash as i0}from"crypto";import{existsSync as OZ,mkdirSync as n,readFileSync as rQ,writeFileSync as dQ}from"fs";import{homedir as DZ}from"os";import{basename as o0,join as x,parse as e0,resolve as gZ}from"path";function R(){return process.env.BEACON_HOME||x(DZ(),".beacon")}function nQ(){return x(R(),"workspaces.json")}function d(Q){return i0("sha256").update(Q).digest("hex").slice(0,12)}function Q1(Q=process.cwd()){let Z=a0("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 EZ(Q){let Z=gZ(Q);return Z!==gZ(DZ())&&Z!==e0(Z).root}function yZ(){return x(R(),"deleted.json")}function aQ(){try{let Q=JSON.parse(rQ(yZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function AZ(Q){n(R(),{recursive:!0}),dQ(yZ(),JSON.stringify(Q,null,2))}function IZ(Q){return aQ().includes(Q)}function $2(Q){let Z=aQ();if(!Z.includes(Q))AZ([...Z,Q])}function Z1(Q){let Z=aQ();if(Z.includes(Q))AZ(Z.filter(($)=>$!==Q))}function FQ(Q){return x(R(),Q)}function $1(Q){return`file:${x(FQ(Q),"db.sqlite")}`}function a(){try{let Q=JSON.parse(rQ(nQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function iQ(Q){n(R(),{recursive:!0}),dQ(nQ(),JSON.stringify(Q,null,2))}function uQ(){return a().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function O(Q){return a().find((Z)=>Z.id===Q)??null}function bZ(Q,Z,$=new Date().toISOString()){if(!EZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=d(Q);if(IZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=a(),V=Y.find((q)=>q.id===J),z={id:J,path:Q,name:Z||V?.name||o0(Q),lastOpenedAt:$},U=[z,...Y.filter((q)=>q.id!==J)];return n(FQ(J),{recursive:!0}),iQ(U),z}function J2(Q,Z){return Z1(d(Q)),bZ(Q,Z)}function Y2(Q,Z=new Date().toISOString()){let $=a(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,iQ($)}function V2(Q){if(iQ(a().filter((Z)=>Z.id!==Q)),oQ()===Q)J1(uQ()[0]?.id??null)}function LZ(){return x(R(),"active")}function oQ(){try{return rQ(LZ(),"utf8").trim()||null}catch{return null}}function J1(Q){n(R(),{recursive:!0}),dQ(LZ(),Q??"")}function q2(){let Q=oQ();return Q?O(Q):null}function z2(){let Q=V1()??oQ();return Q?O(Q):null}function U2(Q){return O(Q)?.path??null}function X2(){return OZ(nQ())}var kZ="beacon_ws";function _Z(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 W2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&O(Z))return Z;let $=_Z(Q,kZ);if($&&O($))return $;return Y1()}function Y1(){let Q=uQ();return Q.length===1?Q[0].id:null}var SZ="x-beacon-workspace-path";function H2(Q=process.cwd()){let Z=Q1(Q);return{"x-beacon-workspace":d(Z),[SZ]:Z}}async function j2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&O(Z))return Z;let $=Q.headers.get(SZ);if($&&EZ($)&&!IZ(d($))&&(!Z||d($)===Z)){let Y=bZ($);return await q1(Y.id),Y.id}let J=_Z(Q,kZ);if(J&&O(J))return J;return null}var hZ=new n0;function v2(Q,Z){return Q?hZ.run(Q,Z):Z()}function V1(){return hZ.getStore()??null}var tQ=new Set;function G2(Q){tQ.delete(x(FQ(Q),"db.sqlite"))}async function q1(Q){let Z=FQ(Q),$=x(Z,"db.sqlite"),J=OZ($);if(J&&tQ.has($))return{ok:!0,created:!1,migrated:!1};try{n(Z,{recursive:!0});let{provisionDb:Y}=await CZ().then(() => xZ),V=await Y($1(Q));return tQ.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)}}}m();HQ();pQ();import{execSync as z1,spawnSync as mZ}from"child_process";import{existsSync as cZ,readFileSync as U1}from"fs";import{join as lZ}from"path";var H=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,j=(Q)=>`\x1B[31m\u2717\x1B[0m ${Q}`,N=(Q)=>`\x1B[2m${Q}\x1B[0m`,D=(Q)=>`
|
|
356
|
+
\x1B[1m${Q}\x1B[0m`;function X1(){try{return z1("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function W1(){let Q=lZ(R(),"server.json");try{let Z=JSON.parse(U1(Q,"utf8"));if(!Z.pid)return j("daemon: no server.json yet");try{return process.kill(Z.pid,0),H(`daemon running (pid ${Z.pid}, port ${Z.port??"?"})`)}catch{return j(`daemon NOT running (server.json stale: pid ${Z.pid})`)}}catch{return j("daemon: no server.json (never started)")}}function H1(){let Q=mZ("bun",["--version"],{stdio:["ignore","pipe","ignore"]});if(Q.status===0)return H(`bun ${Q.stdout.toString().trim()}`);return j("bun NOT found on PATH (required to run Beacon)")}function j1(){return X1()||process.cwd()}var L=j1(),C=uZ(),sZ=uQ(),v1=sZ.some((Q)=>Q.path===L),v=v1||cZ(lZ(L,".mcp.json"))?AQ(L):null;console.log(D("Beacon \xB7 doctor"));console.log(D("Runtime"));console.log(` ${H1()}`);console.log(` ${W1()}`);console.log(` ${H(`home: ${R()}`)}`);console.log(` ${H(`workspaces registered: ${sZ.length}`)}`);console.log(D("Global (~/.claude/)"));for(let Q of G)console.log(` ${C.skills[Q]?H(`skill ${Q}`):j(`skill ${Q} \u2014 missing`)}`);for(let Q of b)console.log(` ${C.hooks[Q.event]?H(`hook ${Q.event} \u2192 ${Q.command}`):j(`hook ${Q.event} \u2192 ${Q.command} \u2014 missing`)} ${N(Q.description)}`);console.log(` ${C.claudeMdBlock?H("global CLAUDE.md block"):j("global CLAUDE.md block \u2014 missing (every Claude session won't auto-discover Beacon)")}`);console.log(D("Plugin (Claude Code)"));var pZ=e();if(pZ)if(console.log(` ${H(`installed as a Claude Code plugin \u2192 ${pZ}`)}`),console.log(` ${N("the plugin owns the Claude-side skills/hooks/MCP")}`),C.hooks.PostToolUse||G.some((Q)=>C.skills[Q]))console.log(` ${N("npm-global ~/.claude entries still present \u2014 they'll be removed automatically on the next `beacon` run (run `beacon` once to deconflict now).")}`);else console.log(` ${H("npm-global ~/.claude layer stepped aside \u2014 no double-registration")}`);else console.log(` ${N("not installed as a Claude Code plugin (using the npm `trybeacon` CLI).")}`);console.log(D("Codex (~/.codex/ + ~/.agents/)"));var P=r()?hQ():null;if(!P)console.log(` ${N("codex not on PATH \u2014 Codex integration inactive (wires automatically once codex is installed)")}`);else{let Q=mZ("codex",["--version"],{stdio:["ignore","pipe","ignore"]});console.log(` ${Q.status===0?H(`codex ${Q.stdout.toString().trim()}`):N("codex version unavailable (BEACON_CODEX override?)")}`);for(let $ of G)console.log(` ${P.skills[$]?H(`skill ${$} (~/.agents/skills)`):j(`skill ${$} (~/.agents/skills) \u2014 missing`)}`);for(let $ of g)console.log(` ${P.hooks[$.event]?H(`hook ${$.event} \u2192 ${$.command}`):j(`hook ${$.event} \u2192 ${$.command} \u2014 missing`)} ${N($.description)}`);console.log(` ${P.agentsMdBlock?H("global ~/.codex/AGENTS.md block"):j("global ~/.codex/AGENTS.md block \u2014 missing")}`);let Z=_Q();console.log(` ${P.mcp?H("config.toml has [mcp_servers.beacon]"):j(`config.toml missing [mcp_servers.beacon]${Z?` \u2014 ${Z}`:""}`)}`)}console.log(D("CLI binding"));var eQ=M(),G1=cZ(i);console.log(` ${H(`fresh installs resolve to: ${eQ}`)} ${N(process.env.BEACON_CLI_PATH?"(BEACON_CLI_PATH override)":G1?"(Beacon.app installed)":"(npm PATH shim)")}`);var QZ=[["~/.claude/settings.json hooks",fZ()]];if(r())QZ.push(["~/.codex/config.toml MCP",SQ()]);if(v)QZ.push([`${L}/.mcp.json`,yQ(L)]);var tZ=!1;for(let[Q,Z]of QZ){if(!Z){console.log(` ${N(`${Q}: not wired`)}`);continue}if(Z===eQ)console.log(` ${H(`${Q} \u2192 ${Z}`)}`);else tZ=!0,console.log(` ${j(`${Q} \u2192 ${Z} \u2014 MISMATCH (fresh installs would use ${eQ})`)}`)}if(tZ)console.log(` ${N("re-point the configs with")} \x1B[1mbeacon uninstall && beacon\x1B[0m ${N("(uninstall clears the old entries regardless of binary; the next `beacon` rewrites them at the resolved path).")}`);console.log(D(`Current repo (${L})`));if(!v)console.log(` ${N("not registered with Beacon and no .mcp.json \u2014 run `beacon` here to wire it.")}`);else if(console.log(` ${v.mcpRegistered?H(".mcp.json has beacon entry"):j(".mcp.json missing beacon entry")}`),console.log(` ${v.workflowBlock?H("AGENTS.md / CLAUDE.md has Beacon workflow block"):j("AGENTS.md / CLAUDE.md missing Beacon workflow block")}`),console.log(` ${v.skills["beacon-init"]?H("skill beacon-init (repo)"):j("skill beacon-init (repo) \u2014 missing")}`),console.log(` ${v.skills["beacon-refresh"]?H("skill beacon-refresh (repo)"):j("skill beacon-refresh (repo) \u2014 missing")}`),P)console.log(` ${v.codexSkills["beacon-init"]?H("skill beacon-init (.agents/skills)"):j("skill beacon-init (.agents/skills) \u2014 missing")}`),console.log(` ${v.codexSkills["beacon-refresh"]?H("skill beacon-refresh (.agents/skills)"):j("skill beacon-refresh (.agents/skills) \u2014 missing")}`);var N1=G.some((Q)=>!C.skills[Q])||b.some((Q)=>!C.hooks[Q.event])||!C.claudeMdBlock||(P?G.some((Q)=>!P.skills[Q])||g.some((Q)=>!P.hooks[Q.event])||!P.agentsMdBlock||!P.mcp:!1)||(v?!v.mcpRegistered||!v.workflowBlock||!v.skills["beacon-init"]||!v.skills["beacon-refresh"]||(P?!v.codexSkills["beacon-init"]||!v.codexSkills["beacon-refresh"]:!1):!1);if(N1)console.log(`
|
|
357
|
+
${N("Fix everything marked \u2717 by running")} \x1B[1mbeacon\x1B[0m ${N("in this repo.")}`);console.log();
|