trybeacon 0.1.62 → 0.1.64
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 +19 -0
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +11 -11
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +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_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/share/create/route.js +1 -1
- package/.next/server/app/api/share/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 +3 -3
- package/.next/server/app/docs.segments/_full.segment.rsc +3 -3
- 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 +3 -3
- 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/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 +4 -4
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +4 -4
- 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 +3 -3
- package/.next/server/app/map/page.js +1 -1
- 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 +2 -2
- 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/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/s/[token]/page.js +1 -1
- 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 +11 -11
- package/.next/server/chunks/2994.js +2 -0
- package/.next/server/chunks/3284.js +154 -0
- package/.next/server/chunks/4384.js +1 -0
- package/.next/server/chunks/5719.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{2980-07afca8f83adfcea.js → 3415-05007c2bd98125c7.js} +1 -1
- package/.next/static/chunks/{3021-ed52ee7b3f02e2cd.js → 5957-83f611fcd5a08b45.js} +1 -1
- package/.next/static/chunks/766-242213d211df0afd.js +1 -0
- package/.next/static/chunks/{5847-9e0d59eaaa2ed4e0.js → 8915-fa61a860c63a7c85.js} +3 -3
- package/.next/static/chunks/app/map/{page-756355c41278dd07.js → page-491d4767dbc4e954.js} +1 -1
- package/.next/static/chunks/app/page-d08947a671077569.js +1 -0
- package/.next/static/chunks/app/plan/{page-71925c6a12eb1180.js → page-a90e0981499546e3.js} +1 -1
- package/.next/static/chunks/app/s/[token]/{page-6d7e15718d081a4a.js → page-5c8f260e75758b02.js} +1 -1
- package/.next/static/chunks/app/settings/page-7e176d120b1effa9.js +1 -0
- package/.next/static/css/490566ec68a48e1a.css +1 -0
- package/.next/static/css/53e84df868515cf7.css +1 -0
- package/.next/trace +42 -42
- package/.next/trace-build +1 -1
- package/LICENSE +201 -0
- package/README.md +39 -8
- package/bun.lock +2274 -0
- package/dist/bin/beacon.js +14 -13
- package/dist/bin/boot.js +4 -0
- package/dist/bin/doctor.js +38 -30
- package/dist/bin/hook.js +34 -26
- package/dist/bin/mcp.js +40 -32
- package/dist/bin/plan.js +35 -27
- package/dist/bin/uninstall.js +37 -29
- package/dist/lib/assets.js +10 -2
- package/dist/lib/codex-install.js +35 -27
- package/dist/lib/global-install.js +34 -26
- package/package.json +16 -3
- package/plugin/commands/beacon.md +11 -0
- package/plugin/hooks.json +70 -0
- package/plugin/mcp.json +10 -0
- package/plugin/skills/beacon-init/SKILL.md +47 -0
- package/plugin/skills/beacon-plan/SKILL.md +48 -0
- package/plugin/skills/beacon-refresh/SKILL.md +47 -0
- package/.next/server/chunks/1988.js +0 -154
- package/.next/server/chunks/6192.js +0 -1
- package/.next/server/chunks/8035.js +0 -1
- package/.next/server/chunks/8846.js +0 -2
- package/.next/static/chunks/6638-4e53879181b1df75.js +0 -1
- package/.next/static/chunks/app/page-a229992616b3a3de.js +0 -1
- package/.next/static/chunks/app/settings/page-323bfcf32d1e7fc8.js +0 -1
- package/.next/static/css/5a3abd6d2c9dd5a8.css +0 -1
- package/.next/static/css/e63457bec0b3ee27.css +0 -1
- /package/.next/static/{dFKft-kT3vVI6erpmcYuN → qoq7TibU72duRZATxeVnT}/_buildManifest.js +0 -0
- /package/.next/static/{dFKft-kT3vVI6erpmcYuN → qoq7TibU72duRZATxeVnT}/_ssgManifest.js +0 -0
package/dist/bin/beacon.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{execSync as
|
|
4
|
-
\u25C9 Beacon setup \xB7 ${z}`),console.log(` \u2713 skill: ${
|
|
5
|
-
`)}return{initSkill:
|
|
6
|
-
`+" cd into a repo (or run `git init` there) and try again."),process.exit(1);let
|
|
3
|
+
import{execSync as C,spawn as c}from"child_process";import{existsSync as k,mkdirSync as d,openSync as p,readFileSync as f,writeFileSync as l}from"fs";import{homedir as t,platform as _}from"os";import{basename as n,dirname as L,join as B}from"path";import{fileURLToPath as a}from"url";var w=L(a(import.meta.url)),P=n(L(w))==="dist",j=P?L(L(w)):L(w),y=process.cwd(),A=process.env.BEACON_HOME||B(t(),".beacon"),R=B(A,"server.json"),T=process.env.PORT||"4319";if(!process.env.CLAUDE_PLUGIN_ROOT&&k(B(j,".claude-plugin","plugin.json")))process.env.CLAUDE_PLUGIN_ROOT=j;if(!process.env.BEACON_MIGRATIONS_DIR)process.env.BEACON_MIGRATIONS_DIR=B(j,"drizzle");function $(z){if(!P)return B(j,z);return B(j,"dist",z.replace(/\.ts$/,".js"))}var q=process.argv[2];if(q==="mcp")await import($("bin/mcp.ts"));else if(q==="hook")await import($("bin/hook.ts"));else if(q==="guard")await import($("bin/guard.ts"));else if(q==="plan")await import($("bin/plan.ts"));else if(q==="prompt")await import($("bin/prompt.ts"));else if(q==="stop-hook")await import($("bin/stop-hook.ts"));else if(q==="stop")m();else if(q==="remove")await import($("bin/remove.ts"));else if(q==="setup")await x(O()||y);else if(q==="ensure")await e();else if(q==="init-persist")await s(process.argv[3]);else if(q==="doctor")await import($("bin/doctor.ts"));else if(q==="uninstall")await import($("bin/uninstall.ts"));else if(q==="update")await Zz(process.argv.includes("--force")||process.argv.includes("-f"));else if(q==="telemetry")await Xz(process.argv[3]);else if(q==="version"||q==="--version"||q==="-v")console.log(S());else await zz();async function x(z,X=!1){let{installInitSkill:Z,installRefreshSkill:J,installCodexRepoSkills:K,ensureMcp:Q,ensureWorkflowDoc:G}=await import($("lib/assets.ts")),{selfHealGlobal:M,isPluginManaged:I}=await import($("lib/global-install.ts")),{codexDetected:N}=await import($("lib/codex-install.ts")),Y=await M();if(I())return{initSkill:"",refreshSkill:"",mcp:{path:"",added:!1,updated:!1},codexSkills:[],heal:Y};let W=Z(z),H=J(z);G(z);let V=Q(z),F=N()?K(z):[];if(X){if(V.added||V.updated)console.log(`[beacon] ${V.added?"registered":"updated"} Beacon MCP in ${V.path} \u2014 restart your agent CLI`+(V.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: ${W}`),console.log(` \u2713 skill: ${H}`);for(let v of F)console.log(` \u2713 skill: ${v}`);console.log(` ${V.added?"\u2713 added ":"\xB7 kept "} Beacon MCP in ${V.path}`),console.log(` \u2192 in this repo, run /beacon-init in your agent (Claude Code or Codex) to map the repo.
|
|
5
|
+
`)}return{initSkill:W,refreshSkill:H,mcp:V,codexSkills:F,heal:Y}}async function s(z){let X=O()||y,{idForPath:Z,isRegistrableWorkspacePath:J,BEACON_WS_PATH_HEADER:K}=await import($("lib/workspaces.ts"));if(!J(X))console.error(`[beacon] refusing to init ${X} \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 Q="";try{Q=f(z??0,"utf8").trim()}catch(Y){console.error(`[beacon] could not read the init analysis ${z?`from ${z}`:"from stdin"}: ${Y instanceof Error?Y.message:Y}`),process.exit(1)}if(!Q)console.error("[beacon] empty init analysis \u2014 pass the JSON as a file argument (`beacon init-persist analysis.json`) or on stdin."),process.exit(1);await x(X,!0);let G=await D(),M=Z(X),I;try{I=await fetch(`http://localhost:${G}/api/init`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":M,[K]:X},body:Q})}catch(Y){console.error(`[beacon] could not reach the Beacon daemon on port ${G}: ${Y instanceof Error?Y.message:Y}`),process.exit(1)}let N=await I.text();if(!I.ok)console.error(`[beacon] init failed (HTTP ${I.status}): ${N}`),process.exit(1);console.log(`[beacon] mapped ${X} into Beacon: ${N}`),console.log(`[beacon] open the panel \u2192 http://localhost:${G}/map`)}function O(){try{return C("git rev-parse --show-toplevel",{cwd:y,stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function h(z){try{return process.kill(z,0),!0}catch{return!1}}function E(z){try{return JSON.parse(f(z,"utf8"))}catch{return null}}async function b(z){try{return(await fetch(z)).ok}catch{return!1}}async function i(z,X=60){for(let Z=0;Z<X;Z++){if(await b(z))return!0;await new Promise((J)=>setTimeout(J,500))}return!1}function o(z){d(A,{recursive:!0});let X=p(B(A,"server.log"),"a"),Z={...process.env,PORT:z,BEACON_NO_OPEN:"1",BEACON_MIGRATIONS_DIR:B(j,"drizzle")};delete Z.BEACON_REPO,delete Z.BEACON_DATA_DIR,delete Z.DATABASE_URL;let K=c("bun",P?["run","start"]:["run","dev"],{cwd:j,env:Z,detached:!0,stdio:["ignore",X,X]});K.unref();let Q={pid:K.pid??0,port:z};return l(R,JSON.stringify(Q)),Q}async function D(){let z=E(R);if(z&&h(z.pid)&&await b(`http://localhost:${z.port}/api/workspace`))return z.port;let{findAvailablePort:X}=await import($("lib/daemon-port.ts")),Z=String(await X(Number(T)));console.log(Z===T?"[beacon] starting the Beacon server\u2026":`[beacon] port ${T} is busy \u2014 starting the Beacon server on port ${Z}\u2026`);let{port:J}=o(Z);if(!await i(`http://localhost:${J}/api/workspace`))console.log("[beacon] (server is taking a while \u2014 it may still be compiling)");return J}function r(z){if(process.env.BEACON_NO_OPEN)return;let X=_()==="darwin"?"open":_()==="win32"?"start":"xdg-open";try{C(`${X} "${z}"`,{stdio:"ignore"})}catch{}}async function e(){let z=O()||y,{registerWorkspaceExplicit:X,idForPath:Z,ensureWorkspaceDb:J,isRegistrableWorkspacePath:K}=await import($("lib/workspaces.ts"));if(!K(z))return;let Q=Z(z);await J(Q),X(z);let G=await D();console.log(`[beacon] ready \u2192 http://localhost:${G}/map?ws=${Q}`)}async function zz(){let z=O()||y,{registerWorkspaceExplicit:X,idForPath:Z,dataDirFor:J,ensureWorkspaceDb:K,isRegistrableWorkspacePath:Q}=await import($("lib/workspaces.ts"));if(!Q(z))console.error(`[beacon] refusing to open Beacon in ${z} \u2014 that's your home directory, not a project.
|
|
7
|
+
`+" cd into a repo (or run `git init` there) and try again."),process.exit(1);let G=Z(z),M=J(G),I=!k(B(M,"db.sqlite"));if(I)console.log(`[beacon] first run for ${z} \u2014 creating database\u2026`);let N=await K(G);if(!N.ok)console.error(`[beacon] failed to provision database: ${N.error}`);if(I)console.log("[beacon] tip: already have code here? run `/beacon-init` in your agent (Claude Code or Codex) to map the project.");let{heal:Y}=await x(z,!0),W=[];if(Y.skillsAdded.length)W.push(`skills ${Y.skillsAdded.join(", ")}`);if(Y.hooksAdded)W.push(`${Y.hooksAdded} Claude Code hook${Y.hooksAdded===1?"":"s"}`);if(Y.claudeMdBlockTouched)W.push("global CLAUDE.md block");if(W.length)console.log(`[beacon] wired into ~/.claude/: ${W.join(" + ")}.`);let H=Y.codex;if(H){let U=[];if(H.skillsAdded.length)U.push(`skills ${H.skillsAdded.join(", ")}`);if(H.hooksAdded)U.push(`${H.hooksAdded} Codex hook${H.hooksAdded===1?"":"s"}`);if(H.agentsMdBlockTouched)U.push("global AGENTS.md block");if(H.mcp.added)U.push("MCP entry in config.toml");if(U.length)console.log(`[beacon] wired into ~/.codex/: ${U.join(" + ")}.`);if(H.mcp.error)console.log(`[beacon] codex MCP not wired: ${H.mcp.error}`)}try{let U=await import($("lib/telemetry.ts"));if(!U.telemetryStatus().machineId){let g=U.telemetryStatus().enabled;console.log(`[beacon] telemetry: Beacon sends an anonymous heartbeat (random machine id, version, OS,
|
|
7
8
|
`+` architecture \u2014 never repo names, paths, or code) at most every 12h to count
|
|
8
9
|
`+` active installs. Opt out: \`beacon telemetry off\`, BEACON_TELEMETRY_DISABLED=1,
|
|
9
|
-
or DO_NOT_TRACK=1. Details: beacon telemetry status.${
|
|
10
|
+
or DO_NOT_TRACK=1. Details: beacon telemetry status.${g?"":" (currently disabled by your env)"}`),U.ensureTelemetryId()}}catch{}X(z);let F=`http://localhost:${await D()}`,v=`/map?ws=${G}`,u=`${F}/api/workspace/activate?id=${G}&redirect=${encodeURIComponent(v)}`;if(console.log(`
|
|
10
11
|
\u25C9 Beacon
|
|
11
12
|
repo: ${z}
|
|
12
|
-
data: ${
|
|
13
|
-
url: ${
|
|
14
|
-
`),console.log(" (the server keeps running in the background \u2014 `beacon stop` to stop it)\n"),await fetch(`${
|
|
15
|
-
`);else
|
|
16
|
-
\u25C9 Beacon telemetry: ${
|
|
17
|
-
`+" toggle: `beacon telemetry on|off` \xB7 env: BEACON_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1\n")}async function
|
|
18
|
-
npm i -g trybeacon@latest`);return}let K=null;try{let
|
|
19
|
-
${
|
|
13
|
+
data: ${M}
|
|
14
|
+
url: ${F}
|
|
15
|
+
`),console.log(" (the server keeps running in the background \u2014 `beacon stop` to stop it)\n"),await fetch(`${F}/api/tab/presence`,{headers:{"x-beacon-workspace":G}}).then((U)=>U.json()).then((U)=>!!U?.live).catch(()=>!1))await fetch(`${F}/api/tab/nav`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":G},body:JSON.stringify({path:v})}).catch(()=>{}),console.log(` \u21BB reusing your open Beacon tab \u2014 switch to your browser.
|
|
16
|
+
`);else r(u)}function S(){return E(B(j,"package.json"))?.version??"0.0.0"}async function Xz(z){let X=await import($("lib/telemetry.ts"));if(z==="on"||z==="off"){X.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 Z=X.telemetryStatus(),J=Z.reason==="env:BEACON_TELEMETRY_DISABLED"?" (BEACON_TELEMETRY_DISABLED=1)":Z.reason==="env:DO_NOT_TRACK"?" (DO_NOT_TRACK)":Z.reason==="preference"?" (beacon telemetry off)":"";if(console.log(`
|
|
17
|
+
\u25C9 Beacon telemetry: ${Z.enabled?"enabled":"disabled"}${J}`),console.log(` machine id: ${Z.machineId??"(not generated yet \u2014 created on first `beacon` run)"}`),Z.machineId)console.log(` payload: ${JSON.stringify(X.heartbeatPayload(S()))}`);console.log(` sent at most every 12h while the daemon runs \u2014 never repo names, paths, or code.
|
|
18
|
+
`+" toggle: `beacon telemetry on|off` \xB7 env: BEACON_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1\n")}async function Zz(z){let X=S(),{INSTALL_COMMAND:Z,NPM_LATEST_URL:J}=await import($("lib/release.ts"));if(_()==="win32"){console.log(`[beacon] current version v${X}.`),console.log(`[beacon] on Windows, update with your package manager:
|
|
19
|
+
npm i -g trybeacon@latest`);return}let K=null;try{let Q=await fetch(J);if(Q.ok)K=(await Q.json()).version??null}catch{}if(K&&!z){let{isNewerVersion:Q}=await import($("lib/semver.ts"));if(!Q(K,X)){console.log(`[beacon] already on the latest version (v${X}).`),console.log(" run `beacon update --force` to reinstall anyway.");return}}console.log(K?`[beacon] updating Beacon v${X} \u2192 v${K}\u2026`:`[beacon] reinstalling Beacon (current v${X})\u2026`);try{C(Z,{stdio:"inherit"})}catch{console.error(`[beacon] update failed. Run it manually:
|
|
20
|
+
${Z}`),process.exitCode=1;return}m(),console.log("[beacon] updated. Run `beacon` to relaunch on the new version.")}function m(){let z=E(R);if(z&&h(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/boot.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
import{spawnSync as E}from"child_process";import{existsSync as G}from"fs";import{dirname as z,join as A}from"path";import{fileURLToPath as I}from"url";var H=z(I(import.meta.url)),q=z(z(H)),K=A(H,"beacon.js"),N=process.argv.slice(2),B=(F)=>process.stderr.write(`[beacon] ${F}
|
|
4
|
+
`);if(E("bun",["--version"],{stdio:"ignore"}).status!==0)B("Bun is required to run Beacon. Install it from https://bun.sh, then restart your session."),process.exit(0);if(!G(A(q,"node_modules"))){if(B("first run \u2014 installing Beacon's dependencies (one time, this can take a moment)\u2026"),E("bun",["install","--production"],{cwd:q,stdio:["ignore","ignore","inherit"]}).status!==0||!G(A(q,"node_modules")))B(`dependency install failed \u2014 run \`bun install\` in ${q} and retry.`),process.exit(0)}var O={...process.env,CLAUDE_PLUGIN_ROOT:process.env.CLAUDE_PLUGIN_ROOT||q},Q=E("bun",[K,...N],{stdio:"inherit",env:O});process.exit(Q.status??0);
|
package/dist/bin/doctor.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var uZ=Object.defineProperty;var RZ=(Q)=>Q;function gZ(Q,Z){this[Q]=RZ.bind(null,Z)}var BQ=(Q,Z)=>{for(var $ in Z)uZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:gZ.bind(Z,$)})};var F=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var m0=1500,p0=480000,c0=1800000,k=3600000,l0=3000;var pQ=()=>{};var KQ={};BQ(KQ,{removeRepoAssets:()=>_Z,installRefreshSkill:()=>IZ,installPlanSkill:()=>DZ,installInitSkill:()=>EZ,installCodexRepoSkills:()=>yZ,ensureWorkflowDoc:()=>AZ,ensureMcp:()=>bZ,auditRepo:()=>xQ,REFRESH_SKILL:()=>PQ,PLAN_SKILL:()=>lQ,INIT_SKILL:()=>NQ});import{existsSync as u,mkdirSync as h,readFileSync as K,rmSync as S,writeFileSync as P}from"fs";import{join as U}from"path";function EZ(Q){let Z=U(Q,".claude","skills","beacon-init");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return P($,NQ),$}function IZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return P($,PQ),$}function DZ(Q){let Z=U(Q,".claude","skills","beacon-plan");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return P($,lQ),$}function yZ(Q){let Z=[];for(let $ of OZ){let J=U(Q,".agents","skills",$.name);h(J,{recursive:!0});let Y=U(J,"SKILL.md");P(Y,$.body()),Z.push(Y)}return Z}function AZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=K(Z,"utf8")}catch{}let J=new RegExp(`${m}[\\s\\S]*?${GQ}`);$=J.test($)?$.replace(J,cQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
`.trimStart(),
|
|
5
|
+
${cQ}
|
|
6
|
+
`.trimStart(),P(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
|
-
`);let Y=
|
|
8
|
+
`);let Y=U(Q,"CLAUDE.md"),V="";try{V=K(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))P(Y,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:
|
|
13
|
-
`),{path:Z,added:!0,updated:!1}}function
|
|
14
|
-
`)}}catch{}let Y=!1,V=
|
|
11
|
+
`)}function bZ(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(K(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<k)return J.timeout=k,P(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:k},P(Z,JSON.stringify($,null,2)+`
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function xQ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(K(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=K(U(Q,"AGENTS.md"),"utf8").includes(m)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(K(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":u(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":u(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":u(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":u(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function _Z(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let v=U(Q,".claude","skills",z);if(u(v))S(v,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let v=U(Q,".agents","skills",z);if(u(v))S(v,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=U(Q,".mcp.json");try{let z=JSON.parse(K(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)S(J,{force:!0});else P(J,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let Y=!1,V=U(Q,"AGENTS.md");try{let z=K(V,"utf8"),v=new RegExp(`\\n?${m}[\\s\\S]*?${GQ}\\n?`);if(v.test(z)){let vQ=z.replace(v,`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
|
-
`).trimStart();
|
|
18
|
-
`)?
|
|
19
|
-
`),Y=!0}}catch{}let
|
|
17
|
+
`).trimStart();P(V,vQ.endsWith(`
|
|
18
|
+
`)?vQ:`${vQ}
|
|
19
|
+
`),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=K(X,"utf8"),v=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(v!==z){if(!v.trim())S(X,{force:!0});else P(X,v);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var NQ=`---
|
|
20
20
|
name: beacon-init
|
|
21
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.
|
|
22
22
|
---
|
|
@@ -52,10 +52,18 @@ A single \`beacon_init_persist\` MCP tool call with:
|
|
|
52
52
|
- Don't fabricate tables/endpoints. If you can't find the schema source, omit \`snapshot\`.
|
|
53
53
|
- Don't ask the user to confirm before persisting. The user invoked /beacon-init \u2014 that's the confirmation.
|
|
54
54
|
|
|
55
|
-
If \`beacon_init_persist\`
|
|
55
|
+
## If \`beacon_init_persist\` is NOT in your tools (or the call can't reach the daemon)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
That happens when this repo was never opened with \`beacon\`: there's no \`.mcp.json\`, so the Beacon MCP server isn't in this session \u2014 and MCP tools can't be added mid-session. (It also covers a wired repo whose daemon is down, so the tool call errors.) **Do NOT stop and tell the user to run \`beacon\` first.** /beacon-init bootstraps itself: write the EXACT analysis object you'd have passed to \`beacon_init_persist\` to a temp JSON file, then persist it through the CLI:
|
|
58
|
+
|
|
59
|
+
\`\`\`bash
|
|
60
|
+
beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/beacon-init.json
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
`,PQ=`---
|
|
59
67
|
name: beacon-refresh
|
|
60
68
|
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.
|
|
61
69
|
---
|
|
@@ -102,7 +110,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
102
110
|
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.
|
|
103
111
|
|
|
104
112
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
105
|
-
`,
|
|
113
|
+
`,lQ=`---
|
|
106
114
|
name: beacon-plan
|
|
107
115
|
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.
|
|
108
116
|
---
|
|
@@ -150,7 +158,7 @@ If it returns feedback, revise and call it again.
|
|
|
150
158
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
151
159
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
152
160
|
run \`beacon\` in this repo once.
|
|
153
|
-
`,
|
|
161
|
+
`,OZ,m="<!-- beacon:workflow:start -->",GQ="<!-- beacon:workflow:end -->",cQ;var p=F(()=>{pQ();OZ=[{name:"beacon-init",body:()=>NQ},{name:"beacon-refresh",body:()=>PQ}];cQ=`${m}
|
|
154
162
|
## Beacon \u2014 feature workflow
|
|
155
163
|
|
|
156
164
|
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:
|
|
@@ -218,18 +226,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
218
226
|
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.
|
|
219
227
|
|
|
220
228
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
221
|
-
${
|
|
222
|
-
`)}function
|
|
229
|
+
${GQ}`});import{existsSync as c,mkdirSync as CQ,readdirSync as LZ,readFileSync as I,rmSync as kZ,writeFileSync as l}from"fs";import{dirname as nQ,join as w}from"path";function sQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function n(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=w(Q,".claude","plugins");if(!c(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let q=w(V,".claude-plugin","plugin.json");try{if(c(q)&&JSON.parse(I(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of LZ(V,{withFileTypes:!0}))if(X.isDirectory())Y.push(w(V,X.name))}catch{}}$=Y}return null}function tQ(Q){return n(Q)!==null}function MQ(Q){try{return JSON.parse(I(Q,"utf8"))}catch{return{}}}function aQ(Q,Z){CQ(nQ(Q),{recursive:!0}),l(Q,JSON.stringify(Z,null,2)+`
|
|
230
|
+
`)}function t(Q,Z){let $=MQ(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}]}),aQ(Q,$),!0}function a(Q,Z){return(MQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function d(Q,Z){let $=MQ(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((v)=>v.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 aQ(Q,$),!0}function r(Q,Z,$,J){let Y=`${Z}
|
|
223
231
|
${J.trim()}
|
|
224
|
-
${$}`,V="";try{V=
|
|
232
|
+
${$}`,V="";try{V=I(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
|
|
225
233
|
|
|
226
234
|
${Y}
|
|
227
235
|
`:`${Y}
|
|
228
|
-
`,
|
|
236
|
+
`,CQ(nQ(Q),{recursive:!0}),l(Q,V.endsWith(`
|
|
229
237
|
`)?V:`${V}
|
|
230
|
-
`)}function
|
|
238
|
+
`)}function D(Q,Z){try{return I(Q,"utf8").includes(Z)}catch{return!1}}function o(Q,Z,$){let J="";try{J=I(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,`
|
|
231
239
|
|
|
232
|
-
`).trimStart();return
|
|
240
|
+
`).trimStart();return l(Q,V),!0}function i(Q,Z,$){let J=w(Q,Z);CQ(J,{recursive:!0});let Y=w(J,"SKILL.md");return l(Y,$),Y}function O(Q,Z){return c(w(Q,Z,"SKILL.md"))}function e(Q,Z){let $=w(Q,Z);if(!c($))return!1;return kZ($,{recursive:!0,force:!0}),!0}var B,s=`## Beacon (visual planning panel)
|
|
233
241
|
|
|
234
242
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
235
243
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -250,19 +258,19 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
250
258
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
251
259
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
252
260
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
253
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
261
|
+
verbatim. Do NOT implement until the tool returns approval.`;var wQ=F(()=>{B=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as SZ,renameSync as hZ,rmSync as mZ,writeFileSync as pZ}from"fs";import{dirname as cZ}from"path";function QQ(Q,Z){SZ(cZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{pZ($,Z),hZ($,Q)}catch(J){throw mZ($,{force:!0}),J}}function Q1(Q,Z,$=!1){QQ(Q,JSON.stringify(Z,null,$?2:void 0))}var dQ=()=>{};var $Z={};BQ($Z,{setupCodexAssets:()=>sZ,removeCodexMcp:()=>ZZ,removeCodexArtifacts:()=>tZ,hasCodexMcp:()=>uQ,ensureCodexMcp:()=>QZ,codexMcpProblem:()=>RQ,codexDetected:()=>VQ,auditCodex:()=>gQ,CODEX_HOOKS:()=>f});import{readFileSync as YQ}from"fs";import{homedir as lZ}from"os";import{join as b}from"path";function rQ(){return process.env.HOME||process.env.USERPROFILE||lZ()}function VQ(){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 A(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function uQ(){try{return Boolean(A(YQ(R(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function RQ(){let Q="";try{Q=YQ(R(),"utf8")}catch{return null}let Z=A(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${y}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${y}`;return null}function QZ(){let Q="",Z=!1;try{Q=YQ(R(),"utf8"),Z=!0}catch{}if(Z){let V=A(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${y}`};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 ${y}`}}let $=!Q?"":Q.endsWith(`
|
|
254
262
|
`)?`
|
|
255
263
|
`:`
|
|
256
264
|
|
|
257
|
-
`,J=Q+$+
|
|
258
|
-
`),$=Z.indexOf(
|
|
265
|
+
`,J=Q+$+nZ;if(A(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${y}`};return QQ(R(),J),{added:!0}}function ZZ(){let Q="";try{Q=YQ(R(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
266
|
+
`),$=Z.indexOf(iQ);if($===-1)return{removed:!1,skipped:uQ()};let J=Z.indexOf(eQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
|
|
259
267
|
`).replace(/\n{3,}/g,`
|
|
260
268
|
|
|
261
|
-
`).replace(/^\n+/,"");if(
|
|
269
|
+
`).replace(/^\n+/,"");if(A(Y)===null)return{removed:!1,skipped:!0};return QQ(R(),Y),{removed:!0}}async function sZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (p(),KQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of B){if(!O($Q(),z))Y.push(z);i($Q(),z,J[z])}let V=0;for(let z of f)if(t(FQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=D(ZQ(),JQ);r(ZQ(),JQ,oQ,s);let X=QZ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function gQ(){let Q={};for(let $ of B)Q[$]=O($Q(),$);let Z={};for(let $ of f)Z[$.event]=a(FQ(),{event:$.event,command:$.command});return{detected:VQ(),skills:Q,hooks:Z,agentsMdBlock:D(ZQ(),JQ),mcp:uQ()}}function tZ(){let Q=[];for(let Y of B)if(e($Q(),Y))Q.push(Y);let Z=0;for(let Y of f)if(d(FQ(),{event:Y.event,command:Y.command}))Z++;let $=o(ZQ(),JQ,oQ),J=ZZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var TQ=()=>b(rQ(),".codex"),FQ=()=>b(TQ(),"hooks.json"),R=()=>b(TQ(),"config.toml"),ZQ=()=>b(TQ(),"AGENTS.md"),$Q=()=>b(rQ(),".agents","skills"),JQ="<!-- beacon:global:start -->",oQ="<!-- beacon:global:end -->",f,fQ,iQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",eQ="# beacon:end",nZ,y="add it manually: codex mcp add beacon -- beacon mcp";var EQ=F(()=>{wQ();dQ();f=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}];nZ=`${iQ}
|
|
262
270
|
[mcp_servers.beacon]
|
|
263
271
|
command = "beacon"
|
|
264
272
|
args = ["mcp"]
|
|
265
|
-
${
|
|
266
|
-
`});var
|
|
267
|
-
\x1B[1m${Q}\x1B[0m`;function
|
|
268
|
-
${
|
|
273
|
+
${eQ}
|
|
274
|
+
`});var XZ={};BQ(XZ,{provisionDb:()=>x0});import{createClient as q0}from"@libsql/client";import{drizzle as X0}from"drizzle-orm/libsql";import{migrate as U0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as W0}from"drizzle-orm/migrator";import{dirname as AQ,join as H0}from"path";import{fileURLToPath as j0}from"url";async function XQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function P0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function qZ(Q){if(!await XQ(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 G0(Q){for(let[Z,$]of Object.entries(N0)){if(!await XQ(Q,Z))continue;let J=await P0(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 x0(Q,Z=B0){let $=q0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let J=await XQ($,"__drizzle_migrations"),Y=await XQ($,"Node"),V=!1;if(Y&&!J){let X=W0({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 qZ($);if(await U0(X0($),{migrationsFolder:Z}),await qZ($)>q)V=!0;return await G0($),{migrated:V}}finally{$.close()}}var v0,B0,N0;var UZ=F(async()=>{v0=AQ(AQ(AQ(j0(import.meta.url)))),B0=process.env.BEACON_MIGRATIONS_DIR||H0(v0,"drizzle"),N0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});wQ();import{existsSync as aZ}from"fs";import{homedir as dZ}from"os";import{join as zQ}from"path";function rZ(){return process.env.HOME||process.env.USERPROFILE||dZ()}var qQ=()=>zQ(rZ(),".claude"),IQ=()=>zQ(qQ(),"skills"),DQ=()=>zQ(qQ(),"settings.json"),OQ=()=>zQ(qQ(),"CLAUDE.md"),yQ="<!-- beacon:global:start -->",JZ="<!-- beacon:global:end -->";var oZ=s,g=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function iZ(Q,Z){return i(IQ(),Q,Z)}function YZ(Q){return O(IQ(),Q)}function eZ(Q){return e(IQ(),Q)}function Q0(Q){return t(DQ(),Q)}function Z0(Q){return a(DQ(),Q)}function $0(Q){return d(DQ(),Q)}function J0(Q){r(OQ(),yQ,JZ,Q)}function VZ(){return D(OQ(),yQ)}function Y0(){return o(OQ(),yQ,JZ)}function zZ(){let Q={};for(let $ of B)Q[$]=YZ($);let Z={};for(let $ of g)Z[$.event]=Z0({event:$.event,command:$.command});return{homeExists:aZ(qQ()),skills:Q,hooks:Z,claudeMdBlock:VZ()}}async function V0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (p(),KQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let X of B){if(!YZ(X))Y.push(X);iZ(X,J[X])}let V=0;for(let X of g)if(Q0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=VZ();return J0(oZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!q}}async function H1(){if(sQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(tQ()){try{z0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await V0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (EQ(),$Z));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 z0(){let Q=[];for(let J of B)if(eZ(J))Q.push(J);let Z=0;for(let J of g)if($0(J))Z++;let $=Y0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as K0}from"async_hooks";import{spawnSync as C0}from"child_process";import{createHash as M0}from"crypto";import{existsSync as HZ,mkdirSync as _,readFileSync as _Q,writeFileSync as LQ}from"fs";import{homedir as jZ}from"os";import{basename as w0,join as C,parse as f0,resolve as WZ}from"path";function G(){return process.env.BEACON_HOME||C(jZ(),".beacon")}function kQ(){return C(G(),"workspaces.json")}function UQ(Q){return M0("sha256").update(Q).digest("hex").slice(0,12)}function F1(Q=process.cwd()){let Z=C0("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 vZ(Q){let Z=WZ(Q);return Z!==WZ(jZ())&&Z!==f0(Z).root}function BZ(){return C(G(),"deleted.json")}function SQ(){try{let Q=JSON.parse(_Q(BZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function NZ(Q){_(G(),{recursive:!0}),LQ(BZ(),JSON.stringify(Q,null,2))}function PZ(Q){return SQ().includes(Q)}function u1(Q){let Z=SQ();if(!Z.includes(Q))NZ([...Z,Q])}function T0(Q){let Z=SQ();if(Z.includes(Q))NZ(Z.filter(($)=>$!==Q))}function WQ(Q){return C(G(),Q)}function F0(Q){return`file:${C(WQ(Q),"db.sqlite")}`}function L(){try{let Q=JSON.parse(_Q(kQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function hQ(Q){_(G(),{recursive:!0}),LQ(kQ(),JSON.stringify(Q,null,2))}function HQ(){return L().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function T(Q){return L().find((Z)=>Z.id===Q)??null}function GZ(Q,Z,$=new Date().toISOString()){if(!vZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=UQ(Q);if(PZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=L(),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 _(WQ(J),{recursive:!0}),hQ(X),q}function R1(Q,Z){return T0(UQ(Q)),GZ(Q,Z)}function g1(Q,Z=new Date().toISOString()){let $=L(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,hQ($)}function E1(Q){if(hQ(L().filter((Z)=>Z.id!==Q)),mQ()===Q)u0(HQ()[0]?.id??null)}function xZ(){return C(G(),"active")}function mQ(){try{return _Q(xZ(),"utf8").trim()||null}catch{return null}}function u0(Q){_(G(),{recursive:!0}),LQ(xZ(),Q??"")}function I1(){let Q=mQ();return Q?T(Q):null}function D1(){let Q=E0()??mQ();return Q?T(Q):null}function O1(Q){return T(Q)?.path??null}function y1(){return HZ(kQ())}var KZ="beacon_ws";function CZ(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 A1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&T(Z))return Z;let $=CZ(Q,KZ);if($&&T($))return $;return R0()}function R0(){let Q=HQ();return Q.length===1?Q[0].id:null}var g0="x-beacon-workspace-path";async function b1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&T(Z))return Z;let $=Q.headers.get(g0);if($&&vZ($)&&!PZ(UQ($))&&(!Z||UQ($)===Z)){let Y=GZ($);return await I0(Y.id),Y.id}let J=CZ(Q,KZ);if(J&&T(J))return J;return null}var MZ=new K0;function _1(Q,Z){return Q?MZ.run(Q,Z):Z()}function E0(){return MZ.getStore()??null}var bQ=new Set;function L1(Q){bQ.delete(C(WQ(Q),"db.sqlite"))}async function I0(Q){let Z=WQ(Q),$=C(Z,"db.sqlite"),J=HZ($);if(J&&bQ.has($))return{ok:!0,created:!1,migrated:!1};try{_(Z,{recursive:!0});let{provisionDb:Y}=await UZ().then(() => XZ),V=await Y(F0(Q));return bQ.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)}}}p();EQ();import{execSync as D0,spawnSync as fZ}from"child_process";import{existsSync as O0,readFileSync as y0}from"fs";import{join as TZ}from"path";var W=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,H=(Q)=>`\x1B[31m\u2717\x1B[0m ${Q}`,x=(Q)=>`\x1B[2m${Q}\x1B[0m`,E=(Q)=>`
|
|
275
|
+
\x1B[1m${Q}\x1B[0m`;function A0(){try{return D0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function b0(){let Q=TZ(G(),"server.json");try{let Z=JSON.parse(y0(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 _0(){let Q=fZ("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 L0(){return A0()||process.cwd()}var jQ=L0(),M=zZ(),FZ=HQ(),k0=FZ.some((Q)=>Q.path===jQ),j=k0||O0(TZ(jQ,".mcp.json"))?xQ(jQ):null;console.log(E("Beacon \xB7 doctor"));console.log(E("Runtime"));console.log(` ${_0()}`);console.log(` ${b0()}`);console.log(` ${W(`home: ${G()}`)}`);console.log(` ${W(`workspaces registered: ${FZ.length}`)}`);console.log(E("Global (~/.claude/)"));for(let Q of B)console.log(` ${M.skills[Q]?W(`skill ${Q}`):H(`skill ${Q} \u2014 missing`)}`);for(let Q of g)console.log(` ${M.hooks[Q.event]?W(`hook ${Q.event} \u2192 ${Q.command}`):H(`hook ${Q.event} \u2192 ${Q.command} \u2014 missing`)} ${x(Q.description)}`);console.log(` ${M.claudeMdBlock?W("global CLAUDE.md block"):H("global CLAUDE.md block \u2014 missing (every Claude session won't auto-discover Beacon)")}`);console.log(E("Plugin (Claude Code)"));var wZ=n();if(wZ)if(console.log(` ${W(`installed as a Claude Code plugin \u2192 ${wZ}`)}`),console.log(` ${x("the plugin owns the Claude-side skills/hooks/MCP")}`),M.hooks.PostToolUse||B.some((Q)=>M.skills[Q]))console.log(` ${x("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(` ${W("npm-global ~/.claude layer stepped aside \u2014 no double-registration")}`);else console.log(` ${x("not installed as a Claude Code plugin (using the npm `trybeacon` CLI).")}`);console.log(E("Codex (~/.codex/ + ~/.agents/)"));var N=VQ()?gQ():null;if(!N)console.log(` ${x("codex not on PATH \u2014 Codex integration inactive (wires automatically once codex is installed)")}`);else{let Q=fZ("codex",["--version"],{stdio:["ignore","pipe","ignore"]});console.log(` ${Q.status===0?W(`codex ${Q.stdout.toString().trim()}`):x("codex version unavailable (BEACON_CODEX override?)")}`);for(let $ of B)console.log(` ${N.skills[$]?W(`skill ${$} (~/.agents/skills)`):H(`skill ${$} (~/.agents/skills) \u2014 missing`)}`);for(let $ of f)console.log(` ${N.hooks[$.event]?W(`hook ${$.event} \u2192 ${$.command}`):H(`hook ${$.event} \u2192 ${$.command} \u2014 missing`)} ${x($.description)}`);console.log(` ${N.agentsMdBlock?W("global ~/.codex/AGENTS.md block"):H("global ~/.codex/AGENTS.md block \u2014 missing")}`);let Z=RQ();console.log(` ${N.mcp?W("config.toml has [mcp_servers.beacon]"):H(`config.toml missing [mcp_servers.beacon]${Z?` \u2014 ${Z}`:""}`)}`)}console.log(E(`Current repo (${jQ})`));if(!j)console.log(` ${x("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")}`),N)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 S0=B.some((Q)=>!M.skills[Q])||g.some((Q)=>!M.hooks[Q.event])||!M.claudeMdBlock||(N?B.some((Q)=>!N.skills[Q])||f.some((Q)=>!N.hooks[Q.event])||!N.agentsMdBlock||!N.mcp:!1)||(j?!j.mcpRegistered||!j.agentsMdBlock||!j.claudeMdImport||!j.skills["beacon-init"]||!j.skills["beacon-refresh"]||(N?!j.codexSkills["beacon-init"]||!j.codexSkills["beacon-refresh"]:!1):!1);if(S0)console.log(`
|
|
276
|
+
${x("Fix everything marked \u2717 by running")} \x1B[1mbeacon\x1B[0m ${x("in this repo.")}`);console.log();
|