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/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-webpack","duration":
|
|
1
|
+
[{"name":"run-webpack","duration":28440334,"timestamp":173139511,"id":14,"parentId":1,"tags":{},"startTime":1781573958524,"traceId":"63ef3eb53f233cfc"},{"name":"run-typescript","duration":12434254,"timestamp":201582356,"id":4126,"parentId":1,"tags":{},"startTime":1781573986967,"traceId":"63ef3eb53f233cfc"},{"name":"static-check","duration":713209,"timestamp":214103113,"id":4129,"parentId":1,"tags":{},"startTime":1781573999488,"traceId":"63ef3eb53f233cfc"},{"name":"static-generation","duration":4631988,"timestamp":215436526,"id":4283,"parentId":1,"tags":{},"startTime":1781574000822,"traceId":"63ef3eb53f233cfc"},{"name":"collect-build-traces","duration":13341573,"timestamp":214819506,"id":4280,"parentId":1,"tags":{},"startTime":1781574000204,"traceId":"63ef3eb53f233cfc"},{"name":"telemetry-flush","duration":60,"timestamp":228164787,"id":4292,"parentId":1,"tags":{},"startTime":1781574013550,"traceId":"63ef3eb53f233cfc"},{"name":"next-build","duration":55402341,"timestamp":172762516,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1781573958147,"traceId":"63ef3eb53f233cfc"}]
|
package/dist/bin/beacon.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{execSync as _,spawn as m}from"child_process";import{existsSync as u,mkdirSync as g,openSync as c,readFileSync as
|
|
4
|
-
\u25C9 Beacon setup \xB7 ${z}`),console.log(` \u2713 skill: ${H}`),console.log(` \u2713 skill: ${B}`);for(let I of y)console.log(` \u2713 skill: ${I}`);console.log(` ${
|
|
5
|
-
`)}return{initSkill:H,refreshSkill:B,mcp
|
|
6
|
-
`+" cd into a repo (or run `git init` there) and try again."),process.exit(1);let W=X(z),F=J(W),M=!u(U(F,"db.sqlite"));if(M)console.log(`[beacon] first run for ${z} \u2014 creating database\u2026`);let N=await K(W);if(!N.ok)console.error(`[beacon] failed to provision database: ${N.error}`);if(M)console.log("[beacon] tip: already have code here? run `/beacon-init` in your agent (Claude Code or Codex) to map the project.");let{heal:H}=await E(z,!0),B=[];if(H.skillsAdded.length)B.push(`skills ${H.skillsAdded.join(", ")}`);if(H.hooksAdded)B.push(`${H.hooksAdded} Claude Code hook${H.hooksAdded===1?"":"s"}`);if(H.claudeMdBlockTouched)B.push("global CLAUDE.md block");if(B.length)console.log(`[beacon] wired into ~/.claude/: ${B.join(" + ")}.`);let
|
|
3
|
+
import{execSync as _,spawn as m}from"child_process";import{existsSync as u,mkdirSync as g,openSync as c,readFileSync as d,writeFileSync as p}from"fs";import{homedir as t,platform as L}from"os";import{basename as l,dirname as j,join as U}from"path";import{fileURLToPath as a}from"url";var T=j(a(import.meta.url)),O=l(j(T))==="dist",V=O?j(j(T)):j(T),P=process.cwd(),v=process.env.BEACON_HOME||U(t(),".beacon"),A=U(v,"server.json"),w=process.env.PORT||"4319";if(!process.env.BEACON_MIGRATIONS_DIR)process.env.BEACON_MIGRATIONS_DIR=U(V,"drizzle");function Q(z){if(!O)return U(V,z);return U(V,"dist",z.replace(/\.ts$/,".js"))}var Y=process.argv[2];if(Y==="mcp")await import(Q("bin/mcp.ts"));else if(Y==="hook")await import(Q("bin/hook.ts"));else if(Y==="guard")await import(Q("bin/guard.ts"));else if(Y==="plan")await import(Q("bin/plan.ts"));else if(Y==="prompt")await import(Q("bin/prompt.ts"));else if(Y==="stop-hook")await import(Q("bin/stop-hook.ts"));else if(Y==="stop")f();else if(Y==="remove")await import(Q("bin/remove.ts"));else if(Y==="setup")await E(D()||P);else if(Y==="doctor")await import(Q("bin/doctor.ts"));else if(Y==="uninstall")await import(Q("bin/uninstall.ts"));else if(Y==="update")await zz(process.argv.includes("--force")||process.argv.includes("-f"));else if(Y==="telemetry")await e(process.argv[3]);else if(Y==="version"||Y==="--version"||Y==="-v")console.log(x());else await r();async function E(z,Z=!1){let{installInitSkill:X,installRefreshSkill:J,installCodexRepoSkills:K,ensureMcp:G,ensureWorkflowDoc:W}=await import(Q("lib/assets.ts")),{selfHealGlobal:F}=await import(Q("lib/global-install.ts")),{codexDetected:M}=await import(Q("lib/codex-install.ts")),N=await F(),H=X(z),B=J(z);W(z);let $=G(z),y=M()?K(z):[];if(Z){if($.added||$.updated)console.log(`[beacon] ${$.added?"registered":"updated"} Beacon MCP in ${$.path} \u2014 restart your agent CLI`+($.updated?" to apply the longer plan-review timeout.":" to use @beacon mentions."))}else{console.log(`
|
|
4
|
+
\u25C9 Beacon setup \xB7 ${z}`),console.log(` \u2713 skill: ${H}`),console.log(` \u2713 skill: ${B}`);for(let I of y)console.log(` \u2713 skill: ${I}`);console.log(` ${$.added?"\u2713 added ":"\xB7 kept "} Beacon MCP in ${$.path}`),console.log(` \u2192 in this repo, run /beacon-init in your agent (Claude Code or Codex) to map the repo.
|
|
5
|
+
`)}return{initSkill:H,refreshSkill:B,mcp:$,codexSkills:y,heal:N}}function D(){try{return _("git rev-parse --show-toplevel",{cwd:P,stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function k(z){try{return process.kill(z,0),!0}catch{return!1}}function R(z){try{return JSON.parse(d(z,"utf8"))}catch{return null}}async function S(z){try{return(await fetch(z)).ok}catch{return!1}}async function n(z,Z=60){for(let X=0;X<Z;X++){if(await S(z))return!0;await new Promise((J)=>setTimeout(J,500))}return!1}function i(z){g(v,{recursive:!0});let Z=c(U(v,"server.log"),"a"),X={...process.env,PORT:z,BEACON_NO_OPEN:"1",BEACON_MIGRATIONS_DIR:U(V,"drizzle")};delete X.BEACON_REPO,delete X.BEACON_DATA_DIR,delete X.DATABASE_URL;let K=m("bun",O?["run","start"]:["run","dev"],{cwd:V,env:X,detached:!0,stdio:["ignore",Z,Z]});K.unref();let G={pid:K.pid??0,port:z};return p(A,JSON.stringify(G)),G}async function s(){let z=R(A);if(z&&k(z.pid)&&await S(`http://localhost:${z.port}/api/workspace`))return z.port;let{findAvailablePort:Z}=await import(Q("lib/daemon-port.ts")),X=String(await Z(Number(w)));console.log(X===w?"[beacon] starting the Beacon server\u2026":`[beacon] port ${w} is busy \u2014 starting the Beacon server on port ${X}\u2026`);let{port:J}=i(X);if(!await n(`http://localhost:${J}/api/workspace`))console.log("[beacon] (server is taking a while \u2014 it may still be compiling)");return J}function o(z){if(process.env.BEACON_NO_OPEN)return;let Z=L()==="darwin"?"open":L()==="win32"?"start":"xdg-open";try{_(`${Z} "${z}"`,{stdio:"ignore"})}catch{}}async function r(){let z=D()||P,{registerWorkspaceExplicit:Z,idForPath:X,dataDirFor:J,ensureWorkspaceDb:K,isRegistrableWorkspacePath:G}=await import(Q("lib/workspaces.ts"));if(!G(z))console.error(`[beacon] refusing to open Beacon in ${z} \u2014 that's your home directory, not a project.
|
|
6
|
+
`+" cd into a repo (or run `git init` there) and try again."),process.exit(1);let W=X(z),F=J(W),M=!u(U(F,"db.sqlite"));if(M)console.log(`[beacon] first run for ${z} \u2014 creating database\u2026`);let N=await K(W);if(!N.ok)console.error(`[beacon] failed to provision database: ${N.error}`);if(M)console.log("[beacon] tip: already have code here? run `/beacon-init` in your agent (Claude Code or Codex) to map the project.");let{heal:H}=await E(z,!0),B=[];if(H.skillsAdded.length)B.push(`skills ${H.skillsAdded.join(", ")}`);if(H.hooksAdded)B.push(`${H.hooksAdded} Claude Code hook${H.hooksAdded===1?"":"s"}`);if(H.claudeMdBlockTouched)B.push("global CLAUDE.md block");if(B.length)console.log(`[beacon] wired into ~/.claude/: ${B.join(" + ")}.`);let $=H.codex;if($){let q=[];if($.skillsAdded.length)q.push(`skills ${$.skillsAdded.join(", ")}`);if($.hooksAdded)q.push(`${$.hooksAdded} Codex hook${$.hooksAdded===1?"":"s"}`);if($.agentsMdBlockTouched)q.push("global AGENTS.md block");if($.mcp.added)q.push("MCP entry in config.toml");if(q.length)console.log(`[beacon] wired into ~/.codex/: ${q.join(" + ")}.`);if($.mcp.error)console.log(`[beacon] codex MCP not wired: ${$.mcp.error}`)}try{let q=await import(Q("lib/telemetry.ts"));if(!q.telemetryStatus().machineId){let b=q.telemetryStatus().enabled;console.log(`[beacon] telemetry: Beacon sends an anonymous heartbeat (random machine id, version, OS,
|
|
7
7
|
`+` architecture \u2014 never repo names, paths, or code) at most every 12h to count
|
|
8
8
|
`+` active installs. Opt out: \`beacon telemetry off\`, BEACON_TELEMETRY_DISABLED=1,
|
|
9
9
|
or DO_NOT_TRACK=1. Details: beacon telemetry status.${b?"":" (currently disabled by your env)"}`),q.ensureTelemetryId()}}catch{}Z(z);let I=`http://localhost:${await s()}`,C=`/map?ws=${W}`,h=`${I}/api/workspace/activate?id=${W}&redirect=${encodeURIComponent(C)}`;if(console.log(`
|
|
@@ -12,8 +12,8 @@ import{execSync as _,spawn as m}from"child_process";import{existsSync as u,mkdir
|
|
|
12
12
|
data: ${F}
|
|
13
13
|
url: ${I}
|
|
14
14
|
`),console.log(" (the server keeps running in the background \u2014 `beacon stop` to stop it)\n"),await fetch(`${I}/api/tab/presence`,{headers:{"x-beacon-workspace":W}}).then((q)=>q.json()).then((q)=>!!q?.live).catch(()=>!1))await fetch(`${I}/api/tab/nav`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":W},body:JSON.stringify({path:C})}).catch(()=>{}),console.log(` \u21BB reusing your open Beacon tab \u2014 switch to your browser.
|
|
15
|
-
`);else o(h)}function x(){return R(U(V,"package.json"))?.version??"0.0.0"}async function e(z){let Z=await import(
|
|
15
|
+
`);else o(h)}function x(){return R(U(V,"package.json"))?.version??"0.0.0"}async function e(z){let Z=await import(Q("lib/telemetry.ts"));if(z==="on"||z==="off"){Z.setTelemetryEnabled(z==="on"),console.log(`[beacon] telemetry ${z==="on"?"enabled":"disabled"}.`);return}if(z&&z!=="status")console.error("usage: beacon telemetry [on|off|status]"),process.exit(1);let X=Z.telemetryStatus(),J=X.reason==="env:BEACON_TELEMETRY_DISABLED"?" (BEACON_TELEMETRY_DISABLED=1)":X.reason==="env:DO_NOT_TRACK"?" (DO_NOT_TRACK)":X.reason==="preference"?" (beacon telemetry off)":"";if(console.log(`
|
|
16
16
|
\u25C9 Beacon telemetry: ${X.enabled?"enabled":"disabled"}${J}`),console.log(` machine id: ${X.machineId??"(not generated yet \u2014 created on first `beacon` run)"}`),X.machineId)console.log(` payload: ${JSON.stringify(Z.heartbeatPayload(x()))}`);console.log(` sent at most every 12h while the daemon runs \u2014 never repo names, paths, or code.
|
|
17
|
-
`+" toggle: `beacon telemetry on|off` \xB7 env: BEACON_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1\n")}async function zz(z){let Z=x(),{INSTALL_COMMAND:X,NPM_LATEST_URL:J}=await import(
|
|
18
|
-
npm i -g trybeacon@latest`);return}let K=null;try{let G=await fetch(J);if(G.ok)K=(await G.json()).version??null}catch{}if(K&&!z){let{isNewerVersion:G}=await import(
|
|
17
|
+
`+" toggle: `beacon telemetry on|off` \xB7 env: BEACON_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1\n")}async function zz(z){let Z=x(),{INSTALL_COMMAND:X,NPM_LATEST_URL:J}=await import(Q("lib/release.ts"));if(L()==="win32"){console.log(`[beacon] current version v${Z}.`),console.log(`[beacon] on Windows, update with your package manager:
|
|
18
|
+
npm i -g trybeacon@latest`);return}let K=null;try{let G=await fetch(J);if(G.ok)K=(await G.json()).version??null}catch{}if(K&&!z){let{isNewerVersion:G}=await import(Q("lib/semver.ts"));if(!G(K,Z)){console.log(`[beacon] already on the latest version (v${Z}).`),console.log(" run `beacon update --force` to reinstall anyway.");return}}console.log(K?`[beacon] updating Beacon v${Z} \u2192 v${K}\u2026`:`[beacon] reinstalling Beacon (current v${Z})\u2026`);try{_(X,{stdio:"inherit"})}catch{console.error(`[beacon] update failed. Run it manually:
|
|
19
19
|
${X}`),process.exitCode=1;return}f(),console.log("[beacon] updated. Run `beacon` to relaunch on the new version.")}function f(){let z=R(A);if(z&&k(z.pid))try{try{process.kill(-z.pid)}catch{process.kill(z.pid)}console.log(`[beacon] stopped the server (pid ${z.pid}).`)}catch{console.log("[beacon] could not stop the server.")}else console.log("[beacon] no server running.")}
|
package/dist/bin/doctor.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var MZ=Object.defineProperty;var uZ=(Q)=>Q;function wZ(Q,Z){this[Q]=uZ.bind(null,Z)}var jQ=(Q,Z)=>{for(var $ in Z)MZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:wZ.bind(Z,$)})};var u=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var b0=1500,L0=480000,_0=1800000,L=3600000,k0=3000;var hQ=()=>{};var GQ={};jQ(GQ,{removeRepoAssets:()=>OZ,installRefreshSkill:()=>TZ,installPlanSkill:()=>RZ,installInitSkill:()=>FZ,installCodexRepoSkills:()=>EZ,ensureWorkflowDoc:()=>IZ,ensureMcp:()=>DZ,auditRepo:()=>NQ,REFRESH_SKILL:()=>vQ,PLAN_SKILL:()=>pQ,INIT_SKILL:()=>PQ});import{existsSync as w,mkdirSync as k,readFileSync as x,rmSync as _,writeFileSync as N}from"fs";import{join as q}from"path";function FZ(Q){let Z=q(Q,".claude","skills","beacon-init");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return N($,PQ),$}function TZ(Q){let Z=q(Q,".claude","skills","beacon-refresh");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return N($,vQ),$}function RZ(Q){let Z=q(Q,".claude","skills","beacon-plan");k(Z,{recursive:!0});let $=q(Z,"SKILL.md");return N($,pQ),$}function EZ(Q){let Z=[];for(let $ of gZ){let J=q(Q,".agents","skills",$.name);k(J,{recursive:!0});let Y=q(J,"SKILL.md");N(Y,$.body()),Z.push(Y)}return Z}function IZ(Q){let Z=q(Q,"AGENTS.md"),$="";try{$=x(Z,"utf8")}catch{}let J=new RegExp(`${S}[\\s\\S]*?${BQ}`);$=J.test($)?$.replace(J,mQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${mQ}
|
|
6
6
|
`.trimStart(),N(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
|
-
`);let Y=q(Q,"CLAUDE.md"),V="";try{V=
|
|
8
|
+
`);let Y=q(Q,"CLAUDE.md"),V="";try{V=x(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))N(Y,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!0}
|
|
13
|
-
`)}}catch{}let
|
|
11
|
+
`)}function DZ(Q){let Z=q(Q,".mcp.json"),$={};try{$=JSON.parse(x(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<L)return J.timeout=L,N(Z,JSON.stringify($,null,2)+`
|
|
12
|
+
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:L},N(Z,JSON.stringify($,null,2)+`
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function NQ(Q){let Z=q(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(x(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=x(q(Q,"AGENTS.md"),"utf8").includes(S)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(x(q(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":w(q(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":w(q(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":w(q(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":w(q(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function OZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let P=q(Q,".claude","skills",z);if(w(P))_(P,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let P=q(Q,".agents","skills",z);if(w(P))_(P,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=q(Q,".mcp.json");try{let z=JSON.parse(x(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)_(J,{force:!0});else N(J,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=x(V,"utf8"),P=new RegExp(`\\n?${S}[\\s\\S]*?${BQ}\\n?`);if(P.test(z)){let HQ=z.replace(P,`
|
|
14
15
|
`).replace(/\n{3,}/g,`
|
|
15
16
|
|
|
16
|
-
`).trimStart();N(V,
|
|
17
|
-
`)?
|
|
18
|
-
`),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=
|
|
17
|
+
`).trimStart();N(V,HQ.endsWith(`
|
|
18
|
+
`)?HQ:`${HQ}
|
|
19
|
+
`),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=x(U,"utf8"),P=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(P!==z){if(!P.trim())_(U,{force:!0});else N(U,P);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:X}}var PQ=`---
|
|
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
|
+
`,vQ=`---
|
|
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
|
+
`,pQ=`---
|
|
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
|
+
`,gZ,S="<!-- beacon:workflow:start -->",BQ="<!-- beacon:workflow:end -->",mQ;var h=u(()=>{hQ();gZ=[{name:"beacon-init",body:()=>PQ},{name:"beacon-refresh",body:()=>vQ}];mQ=`${S}
|
|
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
|
-
${BQ}`});import{existsSync as
|
|
211
|
-
`)}function
|
|
211
|
+
${BQ}`});import{existsSync as cQ,mkdirSync as xQ,readFileSync as p,rmSync as yZ,writeFileSync as c}from"fs";import{dirname as nQ,join as m}from"path";function KQ(Q){try{return JSON.parse(p(Q,"utf8"))}catch{return{}}}function lQ(Q,Z){xQ(nQ(Q),{recursive:!0}),c(Q,JSON.stringify(Z,null,2)+`
|
|
212
|
+
`)}function l(Q,Z){let $=KQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let J=$.hooks[Z.event];if(J.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((X)=>X.command===Z.command)))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),lQ(Q,$),!0}function s(Q,Z){return(KQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function t(Q,Z){let $=KQ(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((X)=>{let U=X.hooks?.length??0,z=(X.hooks??[]).filter((P)=>P.command!==Z.command);if(z.length!==U)Y=!0;return{...X,hooks:z}}).filter((X)=>(X.hooks??[]).length>0);if(!Y)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return lQ(Q,$),!0}function a(Q,Z,$,J){let Y=`${Z}
|
|
212
213
|
${J.trim()}
|
|
213
|
-
${$}`,V="";try{V=
|
|
214
|
+
${$}`,V="";try{V=p(Q,"utf8")}catch{}let X=new RegExp(`${Z}[\\s\\S]*?${$}`);V=X.test(V)?V.replace(X,Y):V.trim()?`${V.trim()}
|
|
214
215
|
|
|
215
216
|
${Y}
|
|
216
217
|
`:`${Y}
|
|
217
|
-
`,xQ(
|
|
218
|
+
`,xQ(nQ(Q),{recursive:!0}),c(Q,V.endsWith(`
|
|
218
219
|
`)?V:`${V}
|
|
219
|
-
`)}function
|
|
220
|
+
`)}function g(Q,Z){try{return p(Q,"utf8").includes(Z)}catch{return!1}}function d(Q,Z,$){let J="";try{J=p(Q,"utf8")}catch{return!1}let Y=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!Y.test(J))return!1;let V=J.replace(Y,"").replace(/\n{3,}/g,`
|
|
220
221
|
|
|
221
|
-
`).trimStart();return
|
|
222
|
+
`).trimStart();return c(Q,V),!0}function r(Q,Z,$){let J=m(Q,Z);xQ(J,{recursive:!0});let Y=m(J,"SKILL.md");return c(Y,$),Y}function E(Q,Z){return cQ(m(Q,Z,"SKILL.md"))}function o(Q,Z){let $=m(Q,Z);if(!cQ($))return!1;return yZ($,{recursive:!0,force:!0}),!0}var v,n=`## 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,19 +240,19 @@ 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 CQ=u(()=>{v=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as AZ,renameSync as bZ,rmSync as LZ,writeFileSync as _Z}from"fs";import{dirname as kZ}from"path";function i(Q,Z){AZ(kZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{_Z($,Z),bZ($,Q)}catch(J){throw LZ($,{force:!0}),J}}function a0(Q,Z,$=!1){i(Q,JSON.stringify(Z,null,$?2:void 0))}var sQ=()=>{};var eQ={};jQ(eQ,{setupCodexAssets:()=>mZ,removeCodexMcp:()=>iQ,removeCodexArtifacts:()=>pZ,hasCodexMcp:()=>wQ,ensureCodexMcp:()=>oQ,codexMcpProblem:()=>FQ,codexDetected:()=>JQ,auditCodex:()=>TQ,CODEX_HOOKS:()=>C});import{readFileSync as $Q}from"fs";import{homedir as SZ}from"os";import{join as O}from"path";function tQ(){return process.env.HOME||process.env.USERPROFILE||SZ()}function JQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(fQ===void 0)fQ=Bun.which("codex")!==null;return fQ}function D(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function wQ(){try{return Boolean(D($Q(F(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function FQ(){let Q="";try{Q=$Q(F(),"utf8")}catch{return null}let Z=D(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${I}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${I}`;return null}function oQ(){let Q="",Z=!1;try{Q=$Q(F(),"utf8"),Z=!0}catch{}if(Z){let V=D(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${I}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${I}`}}let $=!Q?"":Q.endsWith(`
|
|
243
244
|
`)?`
|
|
244
245
|
`:`
|
|
245
246
|
|
|
246
|
-
`,J=Q+$+
|
|
247
|
-
`),$=Z.indexOf(
|
|
247
|
+
`,J=Q+$+hZ;if(D(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${I}`};return i(F(),J),{added:!0}}function iQ(){let Q="";try{Q=$Q(F(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
248
|
+
`),$=Z.indexOf(dQ);if($===-1)return{removed:!1,skipped:wQ()};let J=Z.indexOf(rQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
|
|
248
249
|
`).replace(/\n{3,}/g,`
|
|
249
250
|
|
|
250
|
-
`).replace(/^\n+/,"");if(D(Y)===null)return{removed:!1,skipped:!0};return i(
|
|
251
|
+
`).replace(/^\n+/,"");if(D(Y)===null)return{removed:!1,skipped:!0};return i(F(),Y),{removed:!0}}async function mZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (h(),GQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of v){if(!E(QQ(),z))Y.push(z);r(QQ(),z,J[z])}let V=0;for(let z of C)if(l(uQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=g(e(),ZQ);a(e(),ZQ,aQ,n);let U=oQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!X,mcp:U}}function TQ(){let Q={};for(let $ of v)Q[$]=E(QQ(),$);let Z={};for(let $ of C)Z[$.event]=s(uQ(),{event:$.event,command:$.command});return{detected:JQ(),skills:Q,hooks:Z,agentsMdBlock:g(e(),ZQ),mcp:wQ()}}function pZ(){let Q=[];for(let Y of v)if(o(QQ(),Y))Q.push(Y);let Z=0;for(let Y of C)if(t(uQ(),{event:Y.event,command:Y.command}))Z++;let $=d(e(),ZQ,aQ),J=iQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var MQ=()=>O(tQ(),".codex"),uQ=()=>O(MQ(),"hooks.json"),F=()=>O(MQ(),"config.toml"),e=()=>O(MQ(),"AGENTS.md"),QQ=()=>O(tQ(),".agents","skills"),ZQ="<!-- beacon:global:start -->",aQ="<!-- beacon:global:end -->",C,fQ,dQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",rQ="# beacon:end",hZ,I="add it manually: codex mcp add beacon -- beacon mcp";var RQ=u(()=>{CQ();sQ();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."}];hZ=`${dQ}
|
|
251
252
|
[mcp_servers.beacon]
|
|
252
253
|
command = "beacon"
|
|
253
254
|
args = ["mcp"]
|
|
254
|
-
${
|
|
255
|
-
`});var
|
|
256
|
-
\x1B[1m${Q}\x1B[0m`;function
|
|
257
|
-
${
|
|
255
|
+
${rQ}
|
|
256
|
+
`});var VZ={};jQ(VZ,{provisionDb:()=>j0});import{createClient as Z0}from"@libsql/client";import{drizzle as $0}from"drizzle-orm/libsql";import{migrate as J0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as Y0}from"drizzle-orm/migrator";import{dirname as OQ,join as V0}from"path";import{fileURLToPath as z0}from"url";async function zQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function W0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function YZ(Q){if(!await zQ(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function H0(Q){for(let[Z,$]of Object.entries(U0)){if(!await zQ(Q,Z))continue;let J=await W0(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 j0(Q,Z=X0){let $=Z0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await zQ($,"__drizzle_migrations"),Y=await zQ($,"Node"),V=!1;if(Y&&!J){let U=Y0({migrationsFolder:Z})[0];if(U)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[U.hash,U.folderMillis]}),V=!0}let X=await YZ($);if(await J0($0($),{migrationsFolder:Z}),await YZ($)>X)V=!0;return await H0($),{migrated:V}}finally{$.close()}}var q0,X0,U0;var zZ=u(async()=>{q0=OQ(OQ(OQ(z0(import.meta.url)))),X0=process.env.BEACON_MIGRATIONS_DIR||V0(q0,"drizzle"),U0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});CQ();import{existsSync as cZ}from"fs";import{homedir as nZ}from"os";import{join as YQ}from"path";function lZ(){return process.env.HOME||process.env.USERPROFILE||nZ()}var VQ=()=>YQ(lZ(),".claude"),gQ=()=>YQ(VQ(),"skills"),EQ=()=>YQ(VQ(),"settings.json"),IQ=()=>YQ(VQ(),"CLAUDE.md"),DQ="<!-- beacon:global:start -->",QZ="<!-- beacon:global:end -->";var sZ=n,T=[{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 tZ(Q,Z){return r(gQ(),Q,Z)}function ZZ(Q){return E(gQ(),Q)}function aZ(Q){return o(gQ(),Q)}function dZ(Q){return l(EQ(),Q)}function rZ(Q){return s(EQ(),Q)}function oZ(Q){return t(EQ(),Q)}function iZ(Q){a(IQ(),DQ,QZ,Q)}function $Z(){return g(IQ(),DQ)}function eZ(){return d(IQ(),DQ,QZ)}function JZ(){let Q={};for(let $ of v)Q[$]=ZZ($);let Z={};for(let $ of T)Z[$.event]=rZ({event:$.event,command:$.command});return{homeExists:cZ(VQ()),skills:Q,hooks:Z,claudeMdBlock:$Z()}}async function Q0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (h(),GQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let U of v){if(!ZZ(U))Y.push(U);tZ(U,J[U])}let V=0;for(let U of T)if(dZ({event:U.event,matcher:U.matcher,command:U.command}))V++;let X=$Z();return iZ(sZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!X}}async function V1(){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(),eQ));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 z1(){let Q=[];for(let J of v)if(aZ(J))Q.push(J);let Z=0;for(let J of T)if(oZ(J))Z++;let $=eZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as P0}from"async_hooks";import{spawnSync as v0}from"child_process";import{createHash as B0}from"crypto";import{existsSync as XZ,mkdirSync as y,readFileSync as AQ,writeFileSync as bQ}from"fs";import{homedir as UZ}from"os";import{basename as N0,join as K,parse as G0,resolve as qZ}from"path";function G(){return process.env.BEACON_HOME||K(UZ(),".beacon")}function LQ(){return K(G(),"workspaces.json")}function qQ(Q){return B0("sha256").update(Q).digest("hex").slice(0,12)}function C1(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 WZ(Q){let Z=qZ(Q);return Z!==qZ(UZ())&&Z!==G0(Z).root}function HZ(){return K(G(),"deleted.json")}function _Q(){try{let Q=JSON.parse(AQ(HZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function jZ(Q){y(G(),{recursive:!0}),bQ(HZ(),JSON.stringify(Q,null,2))}function PZ(Q){return _Q().includes(Q)}function f1(Q){let Z=_Q();if(!Z.includes(Q))jZ([...Z,Q])}function x0(Q){let Z=_Q();if(Z.includes(Q))jZ(Z.filter(($)=>$!==Q))}function XQ(Q){return K(G(),Q)}function K0(Q){return`file:${K(XQ(Q),"db.sqlite")}`}function A(){try{let Q=JSON.parse(AQ(LQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function kQ(Q){y(G(),{recursive:!0}),bQ(LQ(),JSON.stringify(Q,null,2))}function UQ(){return A().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function f(Q){return A().find((Z)=>Z.id===Q)??null}function vZ(Q,Z,$=new Date().toISOString()){if(!WZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=qQ(Q);if(PZ(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((z)=>z.id===J),X={id:J,path:Q,name:Z||V?.name||N0(Q),lastOpenedAt:$},U=[X,...Y.filter((z)=>z.id!==J)];return y(XQ(J),{recursive:!0}),kQ(U),X}function M1(Q,Z){return x0(qQ(Q)),vZ(Q,Z)}function u1(Q,Z=new Date().toISOString()){let $=A(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,kQ($)}function w1(Q){if(kQ(A().filter((Z)=>Z.id!==Q)),SQ()===Q)C0(UQ()[0]?.id??null)}function BZ(){return K(G(),"active")}function SQ(){try{return AQ(BZ(),"utf8").trim()||null}catch{return null}}function C0(Q){y(G(),{recursive:!0}),bQ(BZ(),Q??"")}function F1(){let Q=SQ();return Q?f(Q):null}function T1(){let Q=u0()??SQ();return Q?f(Q):null}function R1(Q){return f(Q)?.path??null}function g1(){return XZ(LQ())}var NZ="beacon_ws";function GZ(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 E1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&f(Z))return Z;let $=GZ(Q,NZ);if($&&f($))return $;return f0()}function f0(){let Q=UQ();return Q.length===1?Q[0].id:null}var M0="x-beacon-workspace-path";async function I1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&f(Z))return Z;let $=Q.headers.get(M0);if($&&WZ($)&&!PZ(qQ($))&&(!Z||qQ($)===Z)){let Y=vZ($);return await w0(Y.id),Y.id}let J=GZ(Q,NZ);if(J&&f(J))return J;return null}var xZ=new P0;function D1(Q,Z){return Q?xZ.run(Q,Z):Z()}function u0(){return xZ.getStore()??null}var yQ=new Set;function O1(Q){yQ.delete(K(XQ(Q),"db.sqlite"))}async function w0(Q){let Z=XQ(Q),$=K(Z,"db.sqlite"),J=XZ($);if(J&&yQ.has($))return{ok:!0,created:!1,migrated:!1};try{y(Z,{recursive:!0});let{provisionDb:Y}=await zZ().then(() => VZ),V=await Y(K0(Q));return yQ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}h();RQ();import{execSync as F0,spawnSync as KZ}from"child_process";import{existsSync as T0,readFileSync as R0}from"fs";import{join as CZ}from"path";var W=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,H=(Q)=>`\x1B[31m\u2717\x1B[0m ${Q}`,M=(Q)=>`\x1B[2m${Q}\x1B[0m`,b=(Q)=>`
|
|
257
|
+
\x1B[1m${Q}\x1B[0m`;function g0(){try{return F0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function E0(){let Q=CZ(G(),"server.json");try{let Z=JSON.parse(R0(Q,"utf8"));if(!Z.pid)return H("daemon: no server.json yet");try{return process.kill(Z.pid,0),W(`daemon running (pid ${Z.pid}, port ${Z.port??"?"})`)}catch{return H(`daemon NOT running (server.json stale: pid ${Z.pid})`)}}catch{return H("daemon: no server.json (never started)")}}function I0(){let Q=KZ("bun",["--version"],{stdio:["ignore","pipe","ignore"]});if(Q.status===0)return W(`bun ${Q.stdout.toString().trim()}`);return H("bun NOT found on PATH (required to run Beacon)")}function D0(){return g0()||process.cwd()}var WQ=D0(),R=JZ(),fZ=UQ(),O0=fZ.some((Q)=>Q.path===WQ),j=O0||T0(CZ(WQ,".mcp.json"))?NQ(WQ):null;console.log(b("Beacon \xB7 doctor"));console.log(b("Runtime"));console.log(` ${I0()}`);console.log(` ${E0()}`);console.log(` ${W(`home: ${G()}`)}`);console.log(` ${W(`workspaces registered: ${fZ.length}`)}`);console.log(b("Global (~/.claude/)"));for(let Q of v)console.log(` ${R.skills[Q]?W(`skill ${Q}`):H(`skill ${Q} \u2014 missing`)}`);for(let Q of T)console.log(` ${R.hooks[Q.event]?W(`hook ${Q.event} \u2192 ${Q.command}`):H(`hook ${Q.event} \u2192 ${Q.command} \u2014 missing`)} ${M(Q.description)}`);console.log(` ${R.claudeMdBlock?W("global CLAUDE.md block"):H("global CLAUDE.md block \u2014 missing (every Claude session won't auto-discover Beacon)")}`);console.log(b("Codex (~/.codex/ + ~/.agents/)"));var B=JQ()?TQ():null;if(!B)console.log(` ${M("codex not on PATH \u2014 Codex integration inactive (wires automatically once codex is installed)")}`);else{let Q=KZ("codex",["--version"],{stdio:["ignore","pipe","ignore"]});console.log(` ${Q.status===0?W(`codex ${Q.stdout.toString().trim()}`):M("codex version unavailable (BEACON_CODEX override?)")}`);for(let $ of v)console.log(` ${B.skills[$]?W(`skill ${$} (~/.agents/skills)`):H(`skill ${$} (~/.agents/skills) \u2014 missing`)}`);for(let $ of C)console.log(` ${B.hooks[$.event]?W(`hook ${$.event} \u2192 ${$.command}`):H(`hook ${$.event} \u2192 ${$.command} \u2014 missing`)} ${M($.description)}`);console.log(` ${B.agentsMdBlock?W("global ~/.codex/AGENTS.md block"):H("global ~/.codex/AGENTS.md block \u2014 missing")}`);let Z=FQ();console.log(` ${B.mcp?W("config.toml has [mcp_servers.beacon]"):H(`config.toml missing [mcp_servers.beacon]${Z?` \u2014 ${Z}`:""}`)}`)}console.log(b(`Current repo (${WQ})`));if(!j)console.log(` ${M("not registered with Beacon and no .mcp.json \u2014 run `beacon` here to wire it.")}`);else if(console.log(` ${j.mcpRegistered?W(".mcp.json has beacon entry"):H(".mcp.json missing beacon entry")}`),console.log(` ${j.agentsMdBlock?W("AGENTS.md has Beacon workflow block"):H("AGENTS.md missing Beacon workflow block")}`),console.log(` ${j.claudeMdImport?W("CLAUDE.md @-imports AGENTS.md"):H("CLAUDE.md does NOT @-import AGENTS.md")}`),console.log(` ${j.skills["beacon-init"]?W("skill beacon-init (repo)"):H("skill beacon-init (repo) \u2014 missing")}`),console.log(` ${j.skills["beacon-refresh"]?W("skill beacon-refresh (repo)"):H("skill beacon-refresh (repo) \u2014 missing")}`),B)console.log(` ${j.codexSkills["beacon-init"]?W("skill beacon-init (.agents/skills)"):H("skill beacon-init (.agents/skills) \u2014 missing")}`),console.log(` ${j.codexSkills["beacon-refresh"]?W("skill beacon-refresh (.agents/skills)"):H("skill beacon-refresh (.agents/skills) \u2014 missing")}`);var y0=v.some((Q)=>!R.skills[Q])||T.some((Q)=>!R.hooks[Q.event])||!R.claudeMdBlock||(B?v.some((Q)=>!B.skills[Q])||C.some((Q)=>!B.hooks[Q.event])||!B.agentsMdBlock||!B.mcp:!1)||(j?!j.mcpRegistered||!j.agentsMdBlock||!j.claudeMdImport||!j.skills["beacon-init"]||!j.skills["beacon-refresh"]||(B?!j.codexSkills["beacon-init"]||!j.codexSkills["beacon-refresh"]:!1):!1);if(y0)console.log(`
|
|
258
|
+
${M("Fix everything marked \u2717 by running")} \x1B[1mbeacon\x1B[0m ${M("in this repo.")}`);console.log();
|
package/dist/bin/hook.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var BZ=Object.defineProperty;var jZ=(Q)=>Q;function PZ(Q,Z){this[Q]=jZ.bind(null,Z)}var QQ=(Q,Z)=>{for(var $ in Z)BZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:PZ.bind(Z,$)})};var N=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var I0=1500,O0=480000,A0=1800000,f=3600000,D0=3000;var TQ=()=>{};var YQ={};QQ(YQ,{removeRepoAssets:()=>gZ,installRefreshSkill:()=>NZ,installPlanSkill:()=>KZ,installInitSkill:()=>GZ,installCodexRepoSkills:()=>uZ,ensureWorkflowDoc:()=>CZ,ensureMcp:()=>MZ,auditRepo:()=>wZ,REFRESH_SKILL:()=>$Q,PLAN_SKILL:()=>fQ,INIT_SKILL:()=>ZQ});import{existsSync as K,mkdirSync as I,readFileSync as x,rmSync as b,writeFileSync as H}from"fs";import{join as U}from"path";function GZ(Q){let Z=U(Q,".claude","skills","beacon-init");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,ZQ),$}function NZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,$Q),$}function KZ(Q){let Z=U(Q,".claude","skills","beacon-plan");I(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,fQ),$}function uZ(Q){let Z=[];for(let $ of vZ){let J=U(Q,".agents","skills",$.name);I(J,{recursive:!0});let Y=U(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function CZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=x(Z,"utf8")}catch{}let J=new RegExp(`${O}[\\s\\S]*?${JQ}`);$=J.test($)?$.replace(J,FQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
`.trimStart(),
|
|
5
|
+
${FQ}
|
|
6
|
+
`.trimStart(),H(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
|
-
`);let Y=U(Q,"CLAUDE.md"),V="";try{V=
|
|
8
|
+
`);let Y=U(Q,"CLAUDE.md"),V="";try{V=x(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))H(Y,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!0}
|
|
13
|
-
`)}}catch{}let
|
|
11
|
+
`)}function MZ(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(x(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<f)return J.timeout=f,H(Z,JSON.stringify($,null,2)+`
|
|
12
|
+
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:f},H(Z,JSON.stringify($,null,2)+`
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function wZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(x(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=x(U(Q,"AGENTS.md"),"utf8").includes(O)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(x(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":K(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":K(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":K(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":K(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function gZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(K(W))b(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(K(W))b(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=U(Q,".mcp.json");try{let z=JSON.parse(x(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)b(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let Y=!1,V=U(Q,"AGENTS.md");try{let z=x(V,"utf8"),W=new RegExp(`\\n?${O}[\\s\\S]*?${JQ}\\n?`);if(W.test(z)){let e=z.replace(W,`
|
|
14
15
|
`).replace(/\n{3,}/g,`
|
|
15
16
|
|
|
16
|
-
`).trimStart();
|
|
17
|
-
`)?
|
|
18
|
-
`),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=
|
|
17
|
+
`).trimStart();H(V,e.endsWith(`
|
|
18
|
+
`)?e:`${e}
|
|
19
|
+
`),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=x(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())b(X,{force:!0});else H(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,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
|
+
`,$Q=`---
|
|
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
|
+
`,fQ=`---
|
|
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
|
+
`,vZ,O="<!-- beacon:workflow:start -->",JQ="<!-- beacon:workflow:end -->",FQ;var VQ=N(()=>{TQ();vZ=[{name:"beacon-init",body:()=>ZQ},{name:"beacon-refresh",body:()=>$Q}];FQ=`${O}
|
|
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
|
+
${JQ}`});import{existsSync as bQ,mkdirSync as zQ,readFileSync as D,rmSync as RZ,writeFileSync as E}from"fs";import{dirname as IQ,join as A}from"path";function qQ(Q){try{return JSON.parse(D(Q,"utf8"))}catch{return{}}}function OQ(Q,Z){zQ(IQ(Q),{recursive:!0}),E(Q,JSON.stringify(Z,null,2)+`
|
|
212
|
+
`)}function L(Q,Z){let $=qQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let J=$.hooks[Z.event];if(J.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),OQ(Q,$),!0}function k(Q,Z){return(qQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function _(Q,Z){let $=qQ(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==X)Y=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!Y)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return OQ(Q,$),!0}function S(Q,Z,$,J){let Y=`${Z}
|
|
212
213
|
${J.trim()}
|
|
213
|
-
${$}`,V="";try{V=
|
|
214
|
+
${$}`,V="";try{V=D(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
|
|
214
215
|
|
|
215
216
|
${Y}
|
|
216
217
|
`:`${Y}
|
|
217
|
-
`,
|
|
218
|
+
`,zQ(IQ(Q),{recursive:!0}),E(Q,V.endsWith(`
|
|
218
219
|
`)?V:`${V}
|
|
219
|
-
`)}function C(Q,Z){try{return
|
|
220
|
+
`)}function C(Q,Z){try{return D(Q,"utf8").includes(Z)}catch{return!1}}function h(Q,Z,$){let J="";try{J=D(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,`
|
|
220
221
|
|
|
221
|
-
`).trimStart();return
|
|
222
|
+
`).trimStart();return E(Q,V),!0}function m(Q,Z,$){let J=A(Q,Z);zQ(J,{recursive:!0});let Y=A(J,"SKILL.md");return E(Y,$),Y}function M(Q,Z){return bQ(A(Q,Z,"SKILL.md"))}function p(Q,Z){let $=A(Q,Z);if(!bQ($))return!1;return RZ($,{recursive:!0,force:!0}),!0}var j,y=`## Beacon (visual planning panel)
|
|
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,18 +240,18 @@ 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 XQ=N(()=>{j=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as TZ,renameSync as FZ,rmSync as fZ,writeFileSync as bZ}from"fs";import{dirname as IZ}from"path";function c(Q,Z){TZ(IZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{bZ($,Z),FZ($,Q)}catch(J){throw fZ($,{force:!0}),J}}function c0(Q,Z,$=!1){c(Q,JSON.stringify(Z,null,$?2:void 0))}var AQ=()=>{};var hQ={};QQ(hQ,{setupCodexAssets:()=>EZ,removeCodexMcp:()=>SQ,removeCodexArtifacts:()=>LZ,hasCodexMcp:()=>xQ,ensureCodexMcp:()=>_Q,codexMcpProblem:()=>DZ,codexDetected:()=>yQ,auditCodex:()=>yZ,CODEX_HOOKS:()=>s});import{readFileSync as a}from"fs";import{homedir as OZ}from"os";import{join as R}from"path";function DQ(){return process.env.HOME||process.env.USERPROFILE||OZ()}function yQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(UQ===void 0)UQ=Bun.which("codex")!==null;return UQ}function g(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function xQ(){try{return Boolean(g(a(v(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function DZ(){let Q="";try{Q=a(v(),"utf8")}catch{return null}let Z=g(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${w}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${w}`;return null}function _Q(){let Q="",Z=!1;try{Q=a(v(),"utf8"),Z=!0}catch{}if(Z){let V=g(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${w}`};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 ${w}`}}let $=!Q?"":Q.endsWith(`
|
|
243
244
|
`)?`
|
|
244
245
|
`:`
|
|
245
246
|
|
|
246
|
-
`,J=Q+$+
|
|
247
|
-
`),$=Z.indexOf(
|
|
247
|
+
`,J=Q+$+AZ;if(g(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${w}`};return c(v(),J),{added:!0}}function SQ(){let Q="";try{Q=a(v(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
248
|
+
`),$=Z.indexOf(LQ);if($===-1)return{removed:!1,skipped:xQ()};let J=Z.indexOf(kQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
|
|
248
249
|
`).replace(/\n{3,}/g,`
|
|
249
250
|
|
|
250
|
-
`).replace(/^\n+/,"");if(g(Y)===null)return{removed:!1,skipped:!0};return
|
|
251
|
+
`).replace(/^\n+/,"");if(g(Y)===null)return{removed:!1,skipped:!0};return c(v(),Y),{removed:!0}}async function EZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (VQ(),YQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of j){if(!M(l(),z))Y.push(z);m(l(),z,J[z])}let V=0;for(let z of s)if(L(HQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=C(n(),d);S(n(),d,EQ,y);let X=_Q();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function yZ(){let Q={};for(let $ of j)Q[$]=M(l(),$);let Z={};for(let $ of s)Z[$.event]=k(HQ(),{event:$.event,command:$.command});return{detected:yQ(),skills:Q,hooks:Z,agentsMdBlock:C(n(),d),mcp:xQ()}}function LZ(){let Q=[];for(let Y of j)if(p(l(),Y))Q.push(Y);let Z=0;for(let Y of s)if(_(HQ(),{event:Y.event,command:Y.command}))Z++;let $=h(n(),d,EQ),J=SQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var WQ=()=>R(DQ(),".codex"),HQ=()=>R(WQ(),"hooks.json"),v=()=>R(WQ(),"config.toml"),n=()=>R(WQ(),"AGENTS.md"),l=()=>R(DQ(),".agents","skills"),d="<!-- beacon:global:start -->",EQ="<!-- beacon:global:end -->",s,UQ,LQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",kQ="# beacon:end",AZ,w="add it manually: codex mcp add beacon -- beacon mcp";var mQ=N(()=>{XQ();AQ();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."}];AZ=`${LQ}
|
|
251
252
|
[mcp_servers.beacon]
|
|
252
253
|
command = "beacon"
|
|
253
254
|
args = ["mcp"]
|
|
254
|
-
${
|
|
255
|
-
`});var
|
|
256
|
-
`)){let J=
|
|
255
|
+
${kQ}
|
|
256
|
+
`});var aQ={};QQ(aQ,{provisionDb:()=>z0});import{createClient as tZ}from"@libsql/client";import{drizzle as rZ}from"drizzle-orm/libsql";import{migrate as oZ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as iZ}from"drizzle-orm/migrator";import{dirname as KQ,join as eZ}from"path";import{fileURLToPath as Q0}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 Y0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function dQ(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 V0(Q){for(let[Z,$]of Object.entries(J0)){if(!await o(Q,Z))continue;let J=await Y0(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 z0(Q,Z=$0){let $=tZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await o($,"__drizzle_migrations"),Y=await o($,"Node"),V=!1;if(Y&&!J){let X=iZ({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 dQ($);if(await oZ(rZ($),{migrationsFolder:Z}),await dQ($)>q)V=!0;return await V0($),{migrated:V}}finally{$.close()}}var Z0,$0,J0;var sQ=N(async()=>{Z0=KQ(KQ(KQ(Q0(import.meta.url)))),$0=process.env.BEACON_MIGRATIONS_DIR||eZ(Z0,"drizzle"),J0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});XQ();import{existsSync as kZ}from"fs";import{homedir as _Z}from"os";import{join as t}from"path";function SZ(){return process.env.HOME||process.env.USERPROFILE||_Z()}var r=()=>t(SZ(),".claude"),BQ=()=>t(r(),"skills"),jQ=()=>t(r(),"settings.json"),PQ=()=>t(r(),"CLAUDE.md"),GQ="<!-- beacon:global:start -->",pQ="<!-- beacon:global:end -->";var hZ=y,NQ=[{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 mZ(Q,Z){return m(BQ(),Q,Z)}function cQ(Q){return M(BQ(),Q)}function pZ(Q){return p(BQ(),Q)}function cZ(Q){return L(jQ(),Q)}function nZ(Q){return k(jQ(),Q)}function lZ(Q){return _(jQ(),Q)}function dZ(Q){S(PQ(),GQ,pQ,Q)}function nQ(){return C(PQ(),GQ)}function aZ(){return h(PQ(),GQ,pQ)}function Q1(){let Q={};for(let $ of j)Q[$]=cQ($);let Z={};for(let $ of NQ)Z[$.event]=nZ({event:$.event,command:$.command});return{homeExists:kZ(r()),skills:Q,hooks:Z,claudeMdBlock:nQ()}}async function sZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (VQ(),YQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let X of j){if(!cQ(X))Y.push(X);mZ(X,J[X])}let V=0;for(let X of NQ)if(cZ({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=nQ();return dZ(hZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!q}}async function lQ(){let Q;try{Q={ok:!0,...await sZ()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (mQ(),hQ));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 Z1(){let Q=[];for(let J of j)if(pZ(J))Q.push(J);let Z=0;for(let J of NQ)if(lZ(J))Z++;let $=aZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as q0}from"async_hooks";import{spawnSync as X0}from"child_process";import{createHash as U0}from"crypto";import{existsSync as rQ,mkdirSync as T,readFileSync as uQ,writeFileSync as CQ}from"fs";import{homedir as oQ}from"os";import{basename as W0,join as P,parse as H0,resolve as tQ}from"path";function B(){return process.env.BEACON_HOME||P(oQ(),".beacon")}function MQ(){return P(B(),"workspaces.json")}function u(Q){return U0("sha256").update(Q).digest("hex").slice(0,12)}function iQ(Q=process.cwd()){let Z=X0("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 eQ(Q){let Z=tQ(Q);return Z!==tQ(oQ())&&Z!==H0(Z).root}function QZ(){return P(B(),"deleted.json")}function wQ(){try{let Q=JSON.parse(uQ(QZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function ZZ(Q){T(B(),{recursive:!0}),CQ(QZ(),JSON.stringify(Q,null,2))}function $Z(Q){return wQ().includes(Q)}function P1(Q){let Z=wQ();if(!Z.includes(Q))ZZ([...Z,Q])}function x0(Q){let Z=wQ();if(Z.includes(Q))ZZ(Z.filter(($)=>$!==Q))}function i(Q){return P(B(),Q)}function B0(Q){return`file:${P(i(Q),"db.sqlite")}`}function F(){try{let Q=JSON.parse(uQ(MQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function gQ(Q){T(B(),{recursive:!0}),CQ(MQ(),JSON.stringify(Q,null,2))}function JZ(){return F().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function G(Q){return F().find((Z)=>Z.id===Q)??null}function YZ(Q,Z,$=new Date().toISOString()){if(!eQ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=u(Q);if($Z(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=F(),V=Y.find((z)=>z.id===J),q={id:J,path:Q,name:Z||V?.name||W0(Q),lastOpenedAt:$},X=[q,...Y.filter((z)=>z.id!==J)];return T(i(J),{recursive:!0}),gQ(X),q}function G1(Q,Z){return x0(u(Q)),YZ(Q,Z)}function N1(Q,Z=new Date().toISOString()){let $=F(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,gQ($)}function K1(Q){if(gQ(F().filter((Z)=>Z.id!==Q)),RQ()===Q)j0(JZ()[0]?.id??null)}function VZ(){return P(B(),"active")}function RQ(){try{return uQ(VZ(),"utf8").trim()||null}catch{return null}}function j0(Q){T(B(),{recursive:!0}),CQ(VZ(),Q??"")}function v1(){let Q=RQ();return Q?G(Q):null}function u1(){let Q=N0()??RQ();return Q?G(Q):null}function C1(Q){return G(Q)?.path??null}function M1(){return rQ(MQ())}var zZ="beacon_ws";function qZ(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 w1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&G(Z))return Z;let $=qZ(Q,zZ);if($&&G($))return $;return P0()}function P0(){let Q=JZ();return Q.length===1?Q[0].id:null}var G0="x-beacon-workspace-path";async function g1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&G(Z))return Z;let $=Q.headers.get(G0);if($&&eQ($)&&!$Z(u($))&&(!Z||u($)===Z)){let Y=YZ($);return await K0(Y.id),Y.id}let J=qZ(Q,zZ);if(J&&G(J))return J;return null}var XZ=new q0;function R1(Q,Z){return Q?XZ.run(Q,Z):Z()}function N0(){return XZ.getStore()??null}var vQ=new Set;function T1(Q){vQ.delete(P(i(Q),"db.sqlite"))}async function K0(Q){let Z=i(Q),$=P(Z,"db.sqlite"),J=rQ($);if(J&&vQ.has($))return{ok:!0,created:!1,migrated:!1};try{T(Z,{recursive:!0});let{provisionDb:Y}=await sQ().then(() => aQ),V=await Y(B0(Q));return vQ.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)}}}import{connect as v0}from"net";var UZ=4319;function u0(Q,Z,$=400){return new Promise((J)=>{let Y=v0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,Y.destroy(),J(X)};Y.once("connect",()=>q(!0)),Y.once("error",()=>q(!1)),Y.setTimeout($,()=>q(!1))})}async function C0(Q){for(let Z of["127.0.0.1","::1"])if(await u0(Z,Q))return!1;return!0}async function b1(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await C0($))return $;return Q}import{resolve as M0}from"path";var w0="*** Begin Patch",g0=/^\*\*\* (Update File|Add File|Move to): (.+)$/;function R0(Q){let Z=[];for(let $ of Q.split(`
|
|
257
|
+
`)){let J=g0.exec($.trim());if(!J)continue;let Y=J[2].trim();if(J[1]==="Move to")Z.pop();Z.push(Y)}return Z}function WZ(Q){let Z=Q.tool_input;if(Z===null||typeof Z!=="object")return[];let $=Z,J=[];if(typeof $.file_path==="string")J.push($.file_path);if(typeof $.path==="string")J.push($.path);if(Array.isArray($.files))for(let V of $.files){let q=V?.file_path;if(typeof q==="string")J.push(q)}if(J.length)return J;let Y=typeof Q.cwd==="string"?Q.cwd:process.cwd();for(let V of Object.values($)){if(typeof V!=="string"||!V.includes(w0))continue;return R0(V).map((q)=>M0(Y,q))}return[]}import{readFileSync as T0}from"fs";import{join as F0}from"path";function f0(){try{return JSON.parse(T0(F0(B(),"server.json"),"utf8"))}catch{return null}}function HZ(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${f0()?.port||process.env.PORT||UZ}`}await lQ();var xZ="";for await(let Q of process.stdin)xZ+=Q;try{let Q=JSON.parse(xZ||"{}"),Z=WZ(Q);if(Z.length){let $=u(iQ(typeof Q.cwd==="string"?Q.cwd:void 0));await fetch(`${HZ()}/api/map/touch-active`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":$},body:JSON.stringify({files:Z})}).catch(()=>{})}}catch{}process.exit(0);
|