trybeacon 0.1.63 → 0.1.65
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 +16 -16
- 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 +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_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +16 -16
- package/.next/server/chunks/2813.js +1 -0
- package/.next/server/chunks/3174.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/1909-98243a0473be2aae.js +1 -0
- package/.next/static/chunks/4491-0cd79f4195f4b111.js +1 -0
- package/.next/static/chunks/app/map/{page-af4a5a1f12413f4d.js → page-66ec4b62a4153de8.js} +1 -1
- package/.next/static/chunks/app/{page-6f46e6682942af3a.js → page-d08947a671077569.js} +1 -1
- package/.next/static/chunks/app/plan/{page-6213cdfdbee97ad6.js → page-008565f9049d55c9.js} +1 -1
- package/.next/static/chunks/app/s/[token]/{page-5c21314106b5ae91.js → page-1c10b26b300faffc.js} +1 -1
- package/.next/static/css/53e84df868515cf7.css +1 -0
- package/.next/static/css/f871d81e526502c1.css +1 -0
- package/.next/trace +42 -42
- package/.next/trace-build +1 -1
- package/LICENSE +201 -0
- package/README.md +40 -8
- package/bun.lock +2274 -0
- package/dist/bin/beacon.js +14 -14
- package/dist/bin/boot.js +4 -0
- package/dist/bin/doctor.js +32 -28
- package/dist/bin/hook.js +28 -24
- package/dist/bin/mcp.js +34 -30
- package/dist/bin/plan.js +29 -25
- package/dist/bin/uninstall.js +31 -27
- package/dist/lib/assets.js +4 -0
- package/dist/lib/codex-install.js +29 -25
- package/dist/lib/global-install.js +28 -24
- 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/2343.js +0 -1
- package/.next/server/chunks/2942.js +0 -1
- package/.next/static/chunks/5780-fd253c7329871c77.js +0 -1
- package/.next/static/chunks/874-c750840a8644deb1.js +0 -1
- package/.next/static/css/e63457bec0b3ee27.css +0 -1
- package/.next/static/css/f86b3e50f4e93bc8.css +0 -1
- /package/.next/static/{kt65bLHd8wfwQxMb3ivew → fwNWsob4GcVUD5_xV0f1h}/_buildManifest.js +0 -0
- /package/.next/static/{kt65bLHd8wfwQxMb3ivew → fwNWsob4GcVUD5_xV0f1h}/_ssgManifest.js +0 -0
package/dist/bin/plan.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var AZ=Object.defineProperty;var fZ=(Q)=>Q;function EZ(Q,Z){this[Q]=fZ.bind(null,Z)}var VQ=(Q,Z)=>{for(var $ in Z)AZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:EZ.bind(Z,$)})};var C=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var yQ=1500,LQ=480000,G1=1800000,E=3600000,K1=3000;var zQ=()=>{};var WQ={};VQ(WQ,{removeRepoAssets:()=>hZ,installRefreshSkill:()=>OZ,installPlanSkill:()=>bZ,installInitSkill:()=>IZ,installCodexRepoSkills:()=>LZ,ensureWorkflowDoc:()=>kZ,ensureMcp:()=>_Z,auditRepo:()=>SZ,REFRESH_SKILL:()=>XQ,PLAN_SKILL:()=>_Q,INIT_SKILL:()=>qQ});import{existsSync as M,mkdirSync as O,readFileSync as G,rmSync as I,writeFileSync as B}from"fs";import{join as U}from"path";function IZ(Q){let Z=U(Q,".claude","skills","beacon-init");O(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,qQ),$}function OZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");O(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,XQ),$}function bZ(Q){let Z=U(Q,".claude","skills","beacon-plan");O(Z,{recursive:!0});let $=U(Z,"SKILL.md");return B($,_Q),$}function LZ(Q){let Z=[];for(let $ of yZ){let Y=U(Q,".agents","skills",$.name);O(Y,{recursive:!0});let J=U(Y,"SKILL.md");B(J,$.body()),Z.push(J)}return Z}function kZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=G(Z,"utf8")}catch{}let Y=new RegExp(`${b}[\\s\\S]*?${UQ}`);$=Y.test($)?$.replace(Y,kQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${kQ}
|
|
6
6
|
`.trimStart(),B(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
8
|
`);let J=U(Q,"CLAUDE.md"),V="";try{V=G(J,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))B(J,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!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 J=!1,V=U(Q,"AGENTS.md");try{let z=G(V,"utf8"),W=new RegExp(`\\n?${
|
|
11
|
+
`)}function _Z(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(G(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let Y=$.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<E)return Y.timeout=E,B(Z,JSON.stringify($,null,2)+`
|
|
12
|
+
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:E},B(Z,JSON.stringify($,null,2)+`
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function SZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=G(U(Q,"AGENTS.md"),"utf8").includes(b)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(G(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":M(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":M(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":M(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":M(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function hZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(M(W))I(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(M(W))I(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=U(Q,".mcp.json");try{let z=JSON.parse(G(Y,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)I(Y,{force:!0});else B(Y,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let J=!1,V=U(Q,"AGENTS.md");try{let z=G(V,"utf8"),W=new RegExp(`\\n?${b}[\\s\\S]*?${UQ}\\n?`);if(W.test(z)){let H=z.replace(W,`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
17
|
`).trimStart();B(V,H.endsWith(`
|
|
18
18
|
`)?H:`${H}
|
|
19
|
-
`),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())
|
|
19
|
+
`),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())I(X,{force:!0});else B(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:q}}var qQ=`---
|
|
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
|
---
|
|
@@ -63,7 +63,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
|
|
|
63
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
64
|
|
|
65
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
|
-
`,
|
|
66
|
+
`,XQ=`---
|
|
67
67
|
name: beacon-refresh
|
|
68
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.
|
|
69
69
|
---
|
|
@@ -110,7 +110,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
110
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.
|
|
111
111
|
|
|
112
112
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
113
|
-
`,
|
|
113
|
+
`,_Q=`---
|
|
114
114
|
name: beacon-plan
|
|
115
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.
|
|
116
116
|
---
|
|
@@ -158,7 +158,7 @@ If it returns feedback, revise and call it again.
|
|
|
158
158
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
159
159
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
160
160
|
run \`beacon\` in this repo once.
|
|
161
|
-
`,
|
|
161
|
+
`,yZ,b="<!-- beacon:workflow:start -->",UQ="<!-- beacon:workflow:end -->",kQ;var HQ=C(()=>{zQ();yZ=[{name:"beacon-init",body:()=>qQ},{name:"beacon-refresh",body:()=>XQ}];kQ=`${b}
|
|
162
162
|
## Beacon \u2014 feature workflow
|
|
163
163
|
|
|
164
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:
|
|
@@ -215,6 +215,10 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
215
215
|
|
|
216
216
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
217
217
|
|
|
218
|
+
### 2c. Mark the files you mention \u2014 write repo-relative paths in backticks
|
|
219
|
+
|
|
220
|
+
When a plan, feature, or architecture-component description mentions a source file, write its **repo-relative path inside backticks** \u2014 \`app/api/plan/route.ts\`, not "the plan route". On the /plan canvas Beacon turns every backticked token that matches a REAL repo file into a clickable mention that opens it in the user's editor; a bare filename matching several files (e.g. \`route.ts\`) opens a pick-one dropdown of the same-named candidates. The match is deterministic against the live code graph, so a path that isn't a real file just stays plain text \u2014 there's no special syntax to learn and no downside to over-marking: always name files by their real path so the reader can jump straight to the code.
|
|
221
|
+
|
|
218
222
|
### 3. At the end, register the work \u2014 in ONE call
|
|
219
223
|
|
|
220
224
|
Call \`beacon_feature({ action: "done" })\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** \u2014 including its sub-tasks (the cascade completes every PENDING/IN_PROGRESS child; a sub-task you did NOT finish must be set BLOCKED or CANCELLED before registering, so it survives visibly) \u2014 and keeps \`beacon_context_for_feature\` accurate for the next session.
|
|
@@ -226,18 +230,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
226
230
|
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.
|
|
227
231
|
|
|
228
232
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
229
|
-
${
|
|
230
|
-
`)}function
|
|
233
|
+
${UQ}`});import{existsSync as y,mkdirSync as BQ,readdirSync as mZ,readFileSync as F,rmSync as pZ,writeFileSync as L}from"fs";import{dirname as SQ,join as N}from"path";function hQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function mQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=N(Q,".claude","plugins");if(!y(Z))return null;let $=[Z];for(let Y=0;Y<3&&$.length;Y++){let J=[];for(let V of $){let q=N(V,".claude-plugin","plugin.json");try{if(y(q)&&JSON.parse(F(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of mZ(V,{withFileTypes:!0}))if(X.isDirectory())J.push(N(V,X.name))}catch{}}$=J}return null}function pQ(Q){return mQ(Q)!==null}function jQ(Q){try{return JSON.parse(F(Q,"utf8"))}catch{return{}}}function cQ(Q,Z){BQ(SQ(Q),{recursive:!0}),L(Q,JSON.stringify(Z,null,2)+`
|
|
234
|
+
`)}function _(Q,Z){let $=jQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),cQ(Q,$),!0}function S(Q,Z){return(jQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function h(Q,Z){let $=jQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==X)J=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!J)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return cQ(Q,$),!0}function m(Q,Z,$,Y){let J=`${Z}
|
|
231
235
|
${Y.trim()}
|
|
232
|
-
${$}`,V="";try{V=
|
|
236
|
+
${$}`,V="";try{V=F(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
|
|
233
237
|
|
|
234
238
|
${J}
|
|
235
239
|
`:`${J}
|
|
236
|
-
`,
|
|
240
|
+
`,BQ(SQ(Q),{recursive:!0}),L(Q,V.endsWith(`
|
|
237
241
|
`)?V:`${V}
|
|
238
|
-
`)}function
|
|
242
|
+
`)}function R(Q,Z){try{return F(Q,"utf8").includes(Z)}catch{return!1}}function p(Q,Z,$){let Y="";try{Y=F(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
|
|
239
243
|
|
|
240
|
-
`).trimStart();return
|
|
244
|
+
`).trimStart();return L(Q,V),!0}function c(Q,Z,$){let Y=N(Q,Z);BQ(Y,{recursive:!0});let J=N(Y,"SKILL.md");return L(J,$),J}function w(Q,Z){return y(N(Q,Z,"SKILL.md"))}function l(Q,Z){let $=N(Q,Z);if(!y($))return!1;return pZ($,{recursive:!0,force:!0}),!0}var K,k=`## Beacon (visual planning panel)
|
|
241
245
|
|
|
242
246
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
243
247
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -258,24 +262,24 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
258
262
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
259
263
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
260
264
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
261
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
265
|
+
verbatim. Do NOT implement until the tool returns approval.`;var GQ=C(()=>{K=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as cZ,renameSync as lZ,rmSync as dZ,writeFileSync as aZ}from"fs";import{dirname as nZ}from"path";function d(Q,Z){cZ(nZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{aZ($,Z),lZ($,Q)}catch(Y){throw dZ($,{force:!0}),Y}}function w1(Q,Z,$=!1){d(Q,JSON.stringify(Z,null,$?2:void 0))}var lQ=()=>{};var iQ={};VQ(iQ,{setupCodexAssets:()=>oZ,removeCodexMcp:()=>oQ,removeCodexArtifacts:()=>eZ,hasCodexMcp:()=>PQ,ensureCodexMcp:()=>rQ,codexMcpProblem:()=>rZ,codexDetected:()=>nQ,auditCodex:()=>iZ,CODEX_HOOKS:()=>r});import{readFileSync as s}from"fs";import{homedir as tZ}from"os";import{join as D}from"path";function dQ(){return process.env.HOME||process.env.USERPROFILE||tZ()}function nQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(KQ===void 0)KQ=Bun.which("codex")!==null;return KQ}function g(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function PQ(){try{return Boolean(g(s(T(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function rZ(){let Q="";try{Q=s(T(),"utf8")}catch{return null}let Z=g(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${u}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${u}`;return null}function rQ(){let Q="",Z=!1;try{Q=s(T(),"utf8"),Z=!0}catch{}if(Z){let V=g(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${u}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${u}`}}let $=!Q?"":Q.endsWith(`
|
|
262
266
|
`)?`
|
|
263
267
|
`:`
|
|
264
268
|
|
|
265
|
-
`,Y=Q+$+
|
|
266
|
-
`),$=Z.indexOf(
|
|
269
|
+
`,Y=Q+$+sZ;if(g(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${u}`};return d(T(),Y),{added:!0}}function oQ(){let Q="";try{Q=s(T(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
270
|
+
`),$=Z.indexOf(tQ);if($===-1)return{removed:!1,skipped:PQ()};let Y=Z.indexOf(sQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
|
|
267
271
|
`).replace(/\n{3,}/g,`
|
|
268
272
|
|
|
269
|
-
`).replace(/^\n+/,"");if(g(J)===null)return{removed:!1,skipped:!0};return
|
|
273
|
+
`).replace(/^\n+/,"");if(g(J)===null)return{removed:!1,skipped:!0};return d(T(),J),{removed:!0}}async function oZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (HQ(),WQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of K){if(!w(n(),z))J.push(z);c(n(),z,Y[z])}let V=0;for(let z of r)if(_(NQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=R(a(),t);m(a(),t,aQ,k);let X=rQ();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function iZ(){let Q={};for(let $ of K)Q[$]=w(n(),$);let Z={};for(let $ of r)Z[$.event]=S(NQ(),{event:$.event,command:$.command});return{detected:nQ(),skills:Q,hooks:Z,agentsMdBlock:R(a(),t),mcp:PQ()}}function eZ(){let Q=[];for(let J of K)if(l(n(),J))Q.push(J);let Z=0;for(let J of r)if(h(NQ(),{event:J.event,command:J.command}))Z++;let $=p(a(),t,aQ),Y=oQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var xQ=()=>D(dQ(),".codex"),NQ=()=>D(xQ(),"hooks.json"),T=()=>D(xQ(),"config.toml"),a=()=>D(xQ(),"AGENTS.md"),n=()=>D(dQ(),".agents","skills"),t="<!-- beacon:global:start -->",aQ="<!-- beacon:global:end -->",r,KQ,tQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",sQ="# beacon:end",sZ,u="add it manually: codex mcp add beacon -- beacon mcp";var eQ=C(()=>{GQ();lQ();r=[{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."}];sZ=`${tQ}
|
|
270
274
|
[mcp_servers.beacon]
|
|
271
275
|
command = "beacon"
|
|
272
276
|
args = ["mcp"]
|
|
273
|
-
${
|
|
274
|
-
`});var $Z={};JQ($Z,{provisionDb:()=>v0});import{createClient as X0}from"@libsql/client";import{drizzle as U0}from"drizzle-orm/libsql";import{migrate as W0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as H0}from"drizzle-orm/migrator";import{dirname as FQ,join as B0}from"path";import{fileURLToPath as j0}from"url";async function i(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function P0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function ZZ(Q){if(!await i(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function N0(Q){for(let[Z,$]of Object.entries(K0)){if(!await i(Q,Z))continue;let Y=await P0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function v0(Q,Z=x0){let $=X0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await i($,"__drizzle_migrations"),J=await i($,"Node"),V=!1;if(J&&!Y){let X=H0({migrationsFolder:Z})[0];if(X)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),V=!0}let q=await ZZ($);if(await W0(U0($),{migrationsFolder:Z}),await ZZ($)>q)V=!0;return await N0($),{migrated:V}}finally{$.close()}}var G0,x0,K0;var YZ=v(async()=>{G0=FQ(FQ(FQ(j0(import.meta.url)))),x0=process.env.BEACON_MIGRATIONS_DIR||B0(G0,"drizzle"),K0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});jQ();import{existsSync as rZ}from"fs";import{homedir as oZ}from"os";import{join as r}from"path";function iZ(){return process.env.HOME||process.env.USERPROFILE||oZ()}var o=()=>r(iZ(),".claude"),NQ=()=>r(o(),"skills"),vQ=()=>r(o(),"settings.json"),CQ=()=>r(o(),"CLAUDE.md"),MQ="<!-- beacon:global:start -->",oQ="<!-- beacon:global:end -->";var eZ=L,TQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function Q0(Q,Z){return p(NQ(),Q,Z)}function iQ(Q){return F(NQ(),Q)}function Z0(Q){return c(NQ(),Q)}function $0(Q){return k(vQ(),Q)}function Y0(Q){return _(vQ(),Q)}function J0(Q){return S(vQ(),Q)}function V0(Q){h(CQ(),MQ,oQ,Q)}function eQ(){return T(CQ(),MQ)}function z0(){return m(CQ(),MQ,oQ)}function I1(){let Q={};for(let $ of x)Q[$]=iQ($);let Z={};for(let $ of TQ)Z[$.event]=Y0({event:$.event,command:$.command});return{homeExists:rZ(o()),skills:Q,hooks:Z,claudeMdBlock:eQ()}}async function q0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (WQ(),UQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of x){if(!iQ(X))J.push(X);Q0(X,Y[X])}let V=0;for(let X of TQ)if($0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=eQ();return V0(eZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function QZ(){let Q;try{Q={ok:!0,...await q0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (rQ(),sQ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function E1(){let Q=[];for(let Y of x)if(Z0(Y))Q.push(Y);let Z=0;for(let Y of TQ)if(J0(Y))Z++;let $=z0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as C0}from"async_hooks";import{spawnSync as M0}from"child_process";import{createHash as T0}from"crypto";import{existsSync as VZ,mkdirSync as w,readFileSync as gQ,writeFileSync as uQ}from"fs";import{homedir as zZ}from"os";import{basename as F0,join as K,parse as R0,resolve as JZ}from"path";function j(){return process.env.BEACON_HOME||K(zZ(),".beacon")}function wQ(){return K(j(),"workspaces.json")}function e(Q){return T0("sha256").update(Q).digest("hex").slice(0,12)}function n1(Q=process.cwd()){let Z=M0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function qZ(Q){let Z=JZ(Q);return Z!==JZ(zZ())&&Z!==R0(Z).root}function XZ(){return K(j(),"deleted.json")}function fQ(){try{let Q=JSON.parse(gQ(XZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function UZ(Q){w(j(),{recursive:!0}),uQ(XZ(),JSON.stringify(Q,null,2))}function WZ(Q){return fQ().includes(Q)}function a1(Q){let Z=fQ();if(!Z.includes(Q))UZ([...Z,Q])}function g0(Q){let Z=fQ();if(Z.includes(Q))UZ(Z.filter(($)=>$!==Q))}function QQ(Q){return K(j(),Q)}function u0(Q){return`file:${K(QQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(gQ(wQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function DQ(Q){w(j(),{recursive:!0}),uQ(wQ(),JSON.stringify(Q,null,2))}function HZ(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function P(Q){return f().find((Z)=>Z.id===Q)??null}function BZ(Q,Z,$=new Date().toISOString()){if(!qZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=e(Q);if(WZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=f(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||F0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return w(QQ(Y),{recursive:!0}),DQ(X),q}function t1(Q,Z){return g0(e(Q)),BZ(Q,Z)}function s1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,DQ($)}function r1(Q){if(DQ(f().filter((Z)=>Z.id!==Q)),AQ()===Q)w0(HZ()[0]?.id??null)}function jZ(){return K(j(),"active")}function AQ(){try{return gQ(jZ(),"utf8").trim()||null}catch{return null}}function w0(Q){w(j(),{recursive:!0}),uQ(jZ(),Q??"")}function o1(){let Q=AQ();return Q?P(Q):null}function i1(){let Q=A0()??AQ();return Q?P(Q):null}function e1(Q){return P(Q)?.path??null}function Q2(){return VZ(wQ())}var GZ="beacon_ws";function xZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function Z2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=xZ(Q,GZ);if($&&P($))return $;return f0()}function f0(){let Q=HZ();return Q.length===1?Q[0].id:null}var D0="x-beacon-workspace-path";async function $2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=Q.headers.get(D0);if($&&qZ($)&&!WZ(e($))&&(!Z||e($)===Z)){let J=BZ($);return await I0(J.id),J.id}let Y=xZ(Q,GZ);if(Y&&P(Y))return Y;return null}var KZ=new C0;function Y2(Q,Z){return Q?KZ.run(Q,Z):Z()}function A0(){return KZ.getStore()??null}var RQ=new Set;function J2(Q){RQ.delete(K(QQ(Q),"db.sqlite"))}async function I0(Q){let Z=QQ(Q),$=K(Z,"db.sqlite"),Y=VZ($);if(Y&&RQ.has($))return{ok:!0,created:!1,migrated:!1};try{w(Z,{recursive:!0});let{provisionDb:J}=await YZ().then(() => $Z),V=await J(u0(Q));return RQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as E0}from"net";var q2=4319;function b0(Q,Z,$=400){return new Promise((Y)=>{let J=E0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function O0(Q){for(let Z of["127.0.0.1","::1"])if(await b0(Z,Q))return!1;return!0}async function PZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await O0($))return $;return Q}import{execSync as p0,spawn as c0}from"child_process";import{mkdirSync as l0,openSync as d0,readFileSync as n0,writeFileSync as a0}from"fs";import{homedir as t0}from"os";import{dirname as s0,join as $Q}from"path";import{fileURLToPath as r0}from"url";import{createHash as o0}from"crypto";VQ();import{mkdirSync as L0,readFileSync as k0,writeFileSync as _0}from"fs";import{join as S0}from"path";var y0=["default","acceptEdits","bypassPermissions","auto"];function NZ(Q){return typeof Q==="string"&&y0.includes(Q)}function vZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function CZ(){return S0(j(),"preferences.json")}function IQ(){try{let Q=JSON.parse(k0(CZ(),"utf8"));return{planApprovalMode:NZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function G2(Q){let Z={...IQ(),...Q};return L0(j(),{recursive:!0}),_0(CZ(),JSON.stringify(Z,null,2)),Z}function MZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
277
|
+
${sQ}
|
|
278
|
+
`});var VZ={};VQ(VZ,{provisionDb:()=>R0});import{createClient as j0}from"@libsql/client";import{drizzle as G0}from"drizzle-orm/libsql";import{migrate as K0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as x0}from"drizzle-orm/migrator";import{dirname as RQ,join as N0}from"path";import{fileURLToPath as P0}from"url";async function e(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function T0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function JZ(Q){if(!await e(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 F0(Q){for(let[Z,$]of Object.entries(M0)){if(!await e(Q,Z))continue;let Y=await T0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function R0(Q,Z=C0){let $=j0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await e($,"__drizzle_migrations"),J=await e($,"Node"),V=!1;if(J&&!Y){let X=x0({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 JZ($);if(await K0(G0($),{migrationsFolder:Z}),await JZ($)>q)V=!0;return await F0($),{migrated:V}}finally{$.close()}}var v0,C0,M0;var zZ=C(async()=>{v0=RQ(RQ(RQ(P0(import.meta.url)))),C0=process.env.BEACON_MIGRATIONS_DIR||N0(v0,"drizzle"),M0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});GQ();import{existsSync as Q0}from"fs";import{homedir as Z0}from"os";import{join as o}from"path";function $0(){return process.env.HOME||process.env.USERPROFILE||Z0()}var i=()=>o($0(),".claude"),vQ=()=>o(i(),"skills"),CQ=()=>o(i(),"settings.json"),MQ=()=>o(i(),"CLAUDE.md"),TQ="<!-- beacon:global:start -->",QZ="<!-- beacon:global:end -->";var Y0=k,FQ=[{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 J0(Q,Z){return c(vQ(),Q,Z)}function ZZ(Q){return w(vQ(),Q)}function V0(Q){return l(vQ(),Q)}function z0(Q){return _(CQ(),Q)}function q0(Q){return S(CQ(),Q)}function X0(Q){return h(CQ(),Q)}function U0(Q){m(MQ(),TQ,QZ,Q)}function $Z(){return R(MQ(),TQ)}function W0(){return p(MQ(),TQ,QZ)}function L1(){let Q={};for(let $ of K)Q[$]=ZZ($);let Z={};for(let $ of FQ)Z[$.event]=q0({event:$.event,command:$.command});return{homeExists:Q0(i()),skills:Q,hooks:Z,claudeMdBlock:$Z()}}async function H0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (HQ(),WQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of K){if(!ZZ(X))J.push(X);J0(X,Y[X])}let V=0;for(let X of FQ)if(z0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=$Z();return U0(Y0),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function YZ(){if(hQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(pQ()){try{B0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await H0()}}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(),iQ));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 B0(){let Q=[];for(let Y of K)if(V0(Y))Q.push(Y);let Z=0;for(let Y of FQ)if(X0(Y))Z++;let $=W0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as w0}from"async_hooks";import{spawnSync as u0}from"child_process";import{createHash as g0}from"crypto";import{existsSync as XZ,mkdirSync as A,readFileSync as uQ,writeFileSync as gQ}from"fs";import{homedir as UZ}from"os";import{basename as D0,join as x,parse as A0,resolve as qZ}from"path";function j(){return process.env.BEACON_HOME||x(UZ(),".beacon")}function DQ(){return x(j(),"workspaces.json")}function QQ(Q){return g0("sha256").update(Q).digest("hex").slice(0,12)}function r1(Q=process.cwd()){let Z=u0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function WZ(Q){let Z=qZ(Q);return Z!==qZ(UZ())&&Z!==A0(Z).root}function HZ(){return x(j(),"deleted.json")}function AQ(){try{let Q=JSON.parse(uQ(HZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function BZ(Q){A(j(),{recursive:!0}),gQ(HZ(),JSON.stringify(Q,null,2))}function jZ(Q){return AQ().includes(Q)}function o1(Q){let Z=AQ();if(!Z.includes(Q))BZ([...Z,Q])}function f0(Q){let Z=AQ();if(Z.includes(Q))BZ(Z.filter(($)=>$!==Q))}function ZQ(Q){return x(j(),Q)}function E0(Q){return`file:${x(ZQ(Q),"db.sqlite")}`}function f(){try{let Q=JSON.parse(uQ(DQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function fQ(Q){A(j(),{recursive:!0}),gQ(DQ(),JSON.stringify(Q,null,2))}function GZ(){return f().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function P(Q){return f().find((Z)=>Z.id===Q)??null}function KZ(Q,Z,$=new Date().toISOString()){if(!WZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=QQ(Q);if(jZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=f(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||D0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return A(ZQ(Y),{recursive:!0}),fQ(X),q}function i1(Q,Z){return f0(QQ(Q)),KZ(Q,Z)}function e1(Q,Z=new Date().toISOString()){let $=f(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,fQ($)}function Q2(Q){if(fQ(f().filter((Z)=>Z.id!==Q)),EQ()===Q)I0(GZ()[0]?.id??null)}function xZ(){return x(j(),"active")}function EQ(){try{return uQ(xZ(),"utf8").trim()||null}catch{return null}}function I0(Q){A(j(),{recursive:!0}),gQ(xZ(),Q??"")}function Z2(){let Q=EQ();return Q?P(Q):null}function $2(){let Q=y0()??EQ();return Q?P(Q):null}function Y2(Q){return P(Q)?.path??null}function J2(){return XZ(DQ())}var NZ="beacon_ws";function PZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function V2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=PZ(Q,NZ);if($&&P($))return $;return O0()}function O0(){let Q=GZ();return Q.length===1?Q[0].id:null}var b0="x-beacon-workspace-path";async function z2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=Q.headers.get(b0);if($&&WZ($)&&!jZ(QQ($))&&(!Z||QQ($)===Z)){let J=KZ($);return await L0(J.id),J.id}let Y=PZ(Q,NZ);if(Y&&P(Y))return Y;return null}var vZ=new w0;function q2(Q,Z){return Q?vZ.run(Q,Z):Z()}function y0(){return vZ.getStore()??null}var wQ=new Set;function X2(Q){wQ.delete(x(ZQ(Q),"db.sqlite"))}async function L0(Q){let Z=ZQ(Q),$=x(Z,"db.sqlite"),Y=XZ($);if(Y&&wQ.has($))return{ok:!0,created:!1,migrated:!1};try{A(Z,{recursive:!0});let{provisionDb:J}=await zZ().then(() => VZ),V=await J(E0(Q));return wQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as k0}from"net";var H2=4319;function _0(Q,Z,$=400){return new Promise((Y)=>{let J=k0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function S0(Q){for(let Z of["127.0.0.1","::1"])if(await _0(Z,Q))return!1;return!0}async function CZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await S0($))return $;return Q}import{execSync as n0,spawn as t0}from"child_process";import{mkdirSync as s0,openSync as r0,readFileSync as o0,writeFileSync as i0}from"fs";import{homedir as e0}from"os";import{dirname as Q1,join as YQ}from"path";import{fileURLToPath as Z1}from"url";import{createHash as $1}from"crypto";zQ();import{mkdirSync as m0,readFileSync as p0,writeFileSync as c0}from"fs";import{join as l0}from"path";var h0=["default","acceptEdits","bypassPermissions","auto"];function MZ(Q){return typeof Q==="string"&&h0.includes(Q)}function TZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function FZ(){return l0(j(),"preferences.json")}function IQ(){try{let Q=JSON.parse(p0(FZ(),"utf8"));return{planApprovalMode:MZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function P2(Q){let Z={...IQ(),...Q};return m0(j(),{recursive:!0}),c0(FZ(),JSON.stringify(Z,null,2)),Z}function RZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
275
279
|
|
|
276
280
|
This plan created these roadmap feature(s):
|
|
277
281
|
`+Z.join(`
|
|
278
|
-
`)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{execSync as
|
|
279
|
-
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let H=await X.json().catch(()=>({}));
|
|
282
|
+
`)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{execSync as d0}from"child_process";import{platform as wZ}from"os";function a0(Q){if(process.env.BEACON_NO_OPEN)return;let Z=wZ()==="darwin"?"open":wZ()==="win32"?"start":"xdg-open";try{d0(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}async function uZ(Q,Z){if(await fetch(`${Q}/api/plan/presence`,{headers:{"x-beacon-workspace":Z}}).then((J)=>J.json()).then((J)=>!!J?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Z}`);a0(`${Q}/api/workspace/activate?id=${Z}&redirect=${Y}`)}var Y1=YQ(Q1(Z1(import.meta.url)),".."),bQ=process.env.BEACON_HOME||YQ(e0(),".beacon"),gZ=YQ(bQ,"server.json"),J1=process.env.PORT||"4319";function V1(Q){try{return process.kill(Q,0),!0}catch{return!1}}function z1(Q){try{return JSON.parse(o0(Q,"utf8"))}catch{return null}}async function DZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function q1(Q,Z=60){for(let $=0;$<Z;$++){if(await DZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function X1(Q){s0(bQ,{recursive:!0});let Z=r0(YQ(bQ,"server.log"),"a"),$={...process.env,PORT:Q,BEACON_NO_OPEN:"1"};delete $.BEACON_REPO,delete $.BEACON_DATA_DIR,delete $.DATABASE_URL;let Y=t0("bun",["run","dev"],{cwd:Y1,env:$,detached:!0,stdio:["ignore",Z,Z]});Y.unref();let J={pid:Y.pid??0,port:Q};return i0(gZ,JSON.stringify(J)),J}async function U1(){let Q=z1(gZ);if(Q&&V1(Q.pid)&&await DZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let Z=String(await CZ(Number(J1))),{port:$}=X1(Z);return await q1(`http://localhost:${$}/api/workspace`),$}function W1(){try{return n0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function H1(Q){return $1("sha256").update(Q).digest("hex").slice(0,12)}async function B1(){if(process.stdin.isTTY)return null;let Q=[];for await(let $ of process.stdin)Q.push($);let Z=Buffer.concat(Q).toString("utf8").trim();if(!Z)return null;try{return JSON.parse(Z)}catch{return null}}function OQ(Q,Z){return TZ(Q,Z)}function $Q(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function v(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await YZ();let Z=(await B1())?.tool_input?.plan;if(!Z||!Z.trim())v(OQ());let Y=`http://localhost:${await U1()}`,J=W1()||process.cwd(),V=H1(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let q=Z.split(`
|
|
283
|
+
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let H=await X.json().catch(()=>({}));v($Q(H.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!X.ok)v(OQ());await uZ(Y,V);let z=Date.now()+LQ,W=(H)=>new Promise((JQ)=>setTimeout(JQ,H));while(Date.now()<z){await W(yQ);let H=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((JQ)=>JQ.json()).catch(()=>null);if(!H)continue;if(H.kind==="approved")v(OQ(IQ().planApprovalMode,RZ(H.features)));if(H.kind==="discarded")v($Q("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(H.kind==="feedback")v($Q(`The user left feedback on the plan in Beacon (inline comments and/or edits on the /map and /db boards). Revise the plan based on the feedback below, then re-present (call ExitPlanMode again):
|
|
280
284
|
|
|
281
|
-
`+H.feedback))}
|
|
285
|
+
`+H.feedback))}v($Q("\u23F3 Still awaiting your review in Beacon \u2014 the plan is open on /plan and nothing was lost. "+"Claude Code caps a single plan-review hook at ~10 minutes, so to keep waiting you MUST call ExitPlanMode again now with the SAME plan. Re-presenting resumes the same review (your in-progress annotations and any decision are preserved). Do NOT implement, and do "+"NOT ask in the terminal \u2014 just re-present."))})();
|
package/dist/bin/uninstall.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var gZ=Object.defineProperty;var EZ=(Q)=>Q;function IZ(Q,Z){this[Q]=EZ.bind(null,Z)}var PQ=(Q,Z)=>{for(var $ in Z)gZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:IZ.bind(Z,$)})};var M=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var _0=1500,k0=480000,S0=1800000,k=3600000,h0=3000;var cQ=()=>{};var xQ={};PQ(xQ,{removeRepoAssets:()=>vQ,installRefreshSkill:()=>AZ,installPlanSkill:()=>bZ,installInitSkill:()=>DZ,installCodexRepoSkills:()=>yZ,ensureWorkflowDoc:()=>LZ,ensureMcp:()=>_Z,auditRepo:()=>kZ,REFRESH_SKILL:()=>NQ,PLAN_SKILL:()=>nQ,INIT_SKILL:()=>BQ});import{existsSync as T,mkdirSync as h,readFileSync as N,rmSync as S,writeFileSync as H}from"fs";import{join as U}from"path";function DZ(Q){let Z=U(Q,".claude","skills","beacon-init");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,BQ),$}function AZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,NQ),$}function bZ(Q){let Z=U(Q,".claude","skills","beacon-plan");h(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,nQ),$}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");H(Y,$.body()),Z.push(Y)}return Z}function LZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=N(Z,"utf8")}catch{}let J=new RegExp(`${m}[\\s\\S]*?${GQ}`);$=J.test($)?$.replace(J,lQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${lQ}
|
|
6
6
|
`.trimStart(),H(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
|
-
`);let Y=
|
|
8
|
+
`);let Y=U(Q,"CLAUDE.md"),V="";try{V=N(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:!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 _Z(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(N(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<k)return J.timeout=k,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:k},H(Z,JSON.stringify($,null,2)+`
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function kZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(N(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=N(U(Q,"AGENTS.md"),"utf8").includes(m)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(N(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":T(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":T(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":T(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":T(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function vQ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(T(W))S(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(T(W))S(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=U(Q,".mcp.json");try{let z=JSON.parse(N(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 H(J,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let Y=!1,V=U(Q,"AGENTS.md");try{let z=N(V,"utf8"),W=new RegExp(`\\n?${m}[\\s\\S]*?${GQ}\\n?`);if(W.test(z)){let jQ=z.replace(W,`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
|
-
`).trimStart();H(V,
|
|
18
|
-
`)?
|
|
19
|
-
`),Y=!0}}catch{}let
|
|
17
|
+
`).trimStart();H(V,jQ.endsWith(`
|
|
18
|
+
`)?jQ:`${jQ}
|
|
19
|
+
`),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=N(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())S(X,{force:!0});else H(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var BQ=`---
|
|
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
|
---
|
|
@@ -63,7 +63,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
|
|
|
63
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
64
|
|
|
65
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
|
-
`,
|
|
66
|
+
`,NQ=`---
|
|
67
67
|
name: beacon-refresh
|
|
68
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.
|
|
69
69
|
---
|
|
@@ -110,7 +110,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
110
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.
|
|
111
111
|
|
|
112
112
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
113
|
-
`,
|
|
113
|
+
`,nQ=`---
|
|
114
114
|
name: beacon-plan
|
|
115
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.
|
|
116
116
|
---
|
|
@@ -158,7 +158,7 @@ If it returns feedback, revise and call it again.
|
|
|
158
158
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
159
159
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
160
160
|
run \`beacon\` in this repo once.
|
|
161
|
-
`,
|
|
161
|
+
`,OZ,m="<!-- beacon:workflow:start -->",GQ="<!-- beacon:workflow:end -->",lQ;var p=M(()=>{cQ();OZ=[{name:"beacon-init",body:()=>BQ},{name:"beacon-refresh",body:()=>NQ}];lQ=`${m}
|
|
162
162
|
## Beacon \u2014 feature workflow
|
|
163
163
|
|
|
164
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:
|
|
@@ -215,6 +215,10 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
215
215
|
|
|
216
216
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
217
217
|
|
|
218
|
+
### 2c. Mark the files you mention \u2014 write repo-relative paths in backticks
|
|
219
|
+
|
|
220
|
+
When a plan, feature, or architecture-component description mentions a source file, write its **repo-relative path inside backticks** \u2014 \`app/api/plan/route.ts\`, not "the plan route". On the /plan canvas Beacon turns every backticked token that matches a REAL repo file into a clickable mention that opens it in the user's editor; a bare filename matching several files (e.g. \`route.ts\`) opens a pick-one dropdown of the same-named candidates. The match is deterministic against the live code graph, so a path that isn't a real file just stays plain text \u2014 there's no special syntax to learn and no downside to over-marking: always name files by their real path so the reader can jump straight to the code.
|
|
221
|
+
|
|
218
222
|
### 3. At the end, register the work \u2014 in ONE call
|
|
219
223
|
|
|
220
224
|
Call \`beacon_feature({ action: "done" })\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** \u2014 including its sub-tasks (the cascade completes every PENDING/IN_PROGRESS child; a sub-task you did NOT finish must be set BLOCKED or CANCELLED before registering, so it survives visibly) \u2014 and keeps \`beacon_context_for_feature\` accurate for the next session.
|
|
@@ -226,18 +230,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
226
230
|
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.
|
|
227
231
|
|
|
228
232
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
229
|
-
${
|
|
230
|
-
`)}function
|
|
233
|
+
${GQ}`});import{existsSync as c,mkdirSync as KQ,readdirSync as SZ,readFileSync as g,rmSync as hZ,writeFileSync as l}from"fs";import{dirname as tQ,join as K}from"path";function dQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function aQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=K(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=K(V,".claude-plugin","plugin.json");try{if(c(q)&&JSON.parse(g(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of SZ(V,{withFileTypes:!0}))if(X.isDirectory())Y.push(K(V,X.name))}catch{}}$=Y}return null}function sQ(Q){return aQ(Q)!==null}function uQ(Q){try{return JSON.parse(g(Q,"utf8"))}catch{return{}}}function rQ(Q,Z){KQ(tQ(Q),{recursive:!0}),l(Q,JSON.stringify(Z,null,2)+`
|
|
234
|
+
`)}function t(Q,Z){let $=uQ(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}]}),rQ(Q,$),!0}function d(Q,Z){return(uQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function a(Q,Z){let $=uQ(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 rQ(Q,$),!0}function s(Q,Z,$,J){let Y=`${Z}
|
|
231
235
|
${J.trim()}
|
|
232
|
-
${$}`,V="";try{V=
|
|
236
|
+
${$}`,V="";try{V=g(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
|
|
233
237
|
|
|
234
238
|
${Y}
|
|
235
239
|
`:`${Y}
|
|
236
|
-
`,
|
|
240
|
+
`,KQ(tQ(Q),{recursive:!0}),l(Q,V.endsWith(`
|
|
237
241
|
`)?V:`${V}
|
|
238
|
-
`)}function
|
|
242
|
+
`)}function E(Q,Z){try{return g(Q,"utf8").includes(Z)}catch{return!1}}function r(Q,Z,$){let J="";try{J=g(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,`
|
|
239
243
|
|
|
240
|
-
`).trimStart();return
|
|
244
|
+
`).trimStart();return l(Q,V),!0}function o(Q,Z,$){let J=K(Q,Z);KQ(J,{recursive:!0});let Y=K(J,"SKILL.md");return l(Y,$),Y}function I(Q,Z){return c(K(Q,Z,"SKILL.md"))}function i(Q,Z){let $=K(Q,Z);if(!c($))return!1;return hZ($,{recursive:!0,force:!0}),!0}var j,n=`## Beacon (visual planning panel)
|
|
241
245
|
|
|
242
246
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
243
247
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -258,20 +262,20 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
258
262
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
259
263
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
260
264
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
261
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
265
|
+
verbatim. Do NOT implement until the tool returns approval.`;var CQ=M(()=>{j=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as mZ,renameSync as pZ,rmSync as cZ,writeFileSync as lZ}from"fs";import{dirname as nZ}from"path";function e(Q,Z){mZ(nZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{lZ($,Z),pZ($,Q)}catch(J){throw cZ($,{force:!0}),J}}function r0(Q,Z,$=!1){e(Q,JSON.stringify(Z,null,$?2:void 0))}var oQ=()=>{};var VZ={};PQ(VZ,{setupCodexAssets:()=>sZ,removeCodexMcp:()=>YZ,removeCodexArtifacts:()=>FQ,hasCodexMcp:()=>wQ,ensureCodexMcp:()=>JZ,codexMcpProblem:()=>aZ,codexDetected:()=>QZ,auditCodex:()=>RQ,CODEX_HOOKS:()=>R});import{readFileSync as JQ}from"fs";import{homedir as tZ}from"os";import{join as b}from"path";function iQ(){return process.env.HOME||process.env.USERPROFILE||tZ()}function QZ(){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 wQ(){try{return Boolean(A(JQ(w(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function aZ(){let Q="";try{Q=JQ(w(),"utf8")}catch{return null}let Z=A(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${D}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${D}`;return null}function JZ(){let Q="",Z=!1;try{Q=JQ(w(),"utf8"),Z=!0}catch{}if(Z){let V=A(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${D}`};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 ${D}`}}let $=!Q?"":Q.endsWith(`
|
|
262
266
|
`)?`
|
|
263
267
|
`:`
|
|
264
268
|
|
|
265
|
-
`,J=Q+$+
|
|
266
|
-
`),$=Z.indexOf(
|
|
269
|
+
`,J=Q+$+dZ;if(A(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${D}`};return e(w(),J),{added:!0}}function YZ(){let Q="";try{Q=JQ(w(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
270
|
+
`),$=Z.indexOf(ZZ);if($===-1)return{removed:!1,skipped:wQ()};let J=Z.indexOf($Z,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
|
|
267
271
|
`).replace(/\n{3,}/g,`
|
|
268
272
|
|
|
269
|
-
`).replace(/^\n+/,"");if(
|
|
273
|
+
`).replace(/^\n+/,"");if(A(Y)===null)return{removed:!1,skipped:!0};return e(w(),Y),{removed:!0}}async function sZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (p(),xQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of j){if(!I(ZQ(),z))Y.push(z);o(ZQ(),z,J[z])}let V=0;for(let z of R)if(t(TQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=E(QQ(),$Q);s(QQ(),$Q,eQ,n);let X=JZ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function RQ(){let Q={};for(let $ of j)Q[$]=I(ZQ(),$);let Z={};for(let $ of R)Z[$.event]=d(TQ(),{event:$.event,command:$.command});return{detected:QZ(),skills:Q,hooks:Z,agentsMdBlock:E(QQ(),$Q),mcp:wQ()}}function FQ(){let Q=[];for(let Y of j)if(i(ZQ(),Y))Q.push(Y);let Z=0;for(let Y of R)if(a(TQ(),{event:Y.event,command:Y.command}))Z++;let $=r(QQ(),$Q,eQ),J=YZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var MQ=()=>b(iQ(),".codex"),TQ=()=>b(MQ(),"hooks.json"),w=()=>b(MQ(),"config.toml"),QQ=()=>b(MQ(),"AGENTS.md"),ZQ=()=>b(iQ(),".agents","skills"),$Q="<!-- beacon:global:start -->",eQ="<!-- beacon:global:end -->",R,fQ,ZZ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",$Z="# beacon:end",dZ,D="add it manually: codex mcp add beacon -- beacon mcp";var gQ=M(()=>{CQ();oQ();R=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}];dZ=`${ZZ}
|
|
270
274
|
[mcp_servers.beacon]
|
|
271
275
|
command = "beacon"
|
|
272
276
|
args = ["mcp"]
|
|
273
|
-
${
|
|
274
|
-
`});var
|
|
275
|
-
\x1B[1m${Q}\x1B[0m`,
|
|
276
|
-
`),process.exit(0);console.log(f("Applying\u2026"));var F=
|
|
277
|
+
${$Z}
|
|
278
|
+
`});var HZ={};PQ(HZ,{provisionDb:()=>K0});import{createClient as X0}from"@libsql/client";import{drizzle as U0}from"drizzle-orm/libsql";import{migrate as W0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as H0}from"drizzle-orm/migrator";import{dirname as OQ,join as j0}from"path";import{fileURLToPath as P0}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 v0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function WZ(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 x0(Q){for(let[Z,$]of Object.entries(G0)){if(!await zQ(Q,Z))continue;let J=await v0(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 K0(Q,Z=N0){let $=X0({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 X=H0({migrationsFolder:Z})[0];if(X)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),V=!0}let q=await WZ($);if(await W0(U0($),{migrationsFolder:Z}),await WZ($)>q)V=!0;return await x0($),{migrated:V}}finally{$.close()}}var B0,N0,G0;var jZ=M(async()=>{B0=OQ(OQ(OQ(P0(import.meta.url)))),N0=process.env.BEACON_MIGRATIONS_DIR||j0(B0,"drizzle"),G0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});CQ();import{existsSync as rZ}from"fs";import{homedir as oZ}from"os";import{join as YQ}from"path";function iZ(){return process.env.HOME||process.env.USERPROFILE||oZ()}var VQ=()=>YQ(iZ(),".claude"),EQ=()=>YQ(VQ(),"skills"),IQ=()=>YQ(VQ(),"settings.json"),DQ=()=>YQ(VQ(),"CLAUDE.md"),AQ="<!-- beacon:global:start -->",zZ="<!-- beacon:global:end -->";var eZ=n,O=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function Q0(Q,Z){return o(EQ(),Q,Z)}function qZ(Q){return I(EQ(),Q)}function Z0(Q){return i(EQ(),Q)}function $0(Q){return t(IQ(),Q)}function J0(Q){return d(IQ(),Q)}function Y0(Q){return a(IQ(),Q)}function V0(Q){s(DQ(),AQ,zZ,Q)}function XZ(){return E(DQ(),AQ)}function z0(){return r(DQ(),AQ,zZ)}function UZ(){let Q={};for(let $ of j)Q[$]=qZ($);let Z={};for(let $ of O)Z[$.event]=J0({event:$.event,command:$.command});return{homeExists:rZ(VQ()),skills:Q,hooks:Z,claudeMdBlock:XZ()}}async function q0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (p(),xQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let X of j){if(!qZ(X))Y.push(X);Q0(X,J[X])}let V=0;for(let X of O)if($0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=XZ();return V0(eZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!q}}async function q1(){if(dQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(sQ()){try{bQ()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else 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(() => (gQ(),VZ));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 bQ(){let Q=[];for(let J of j)if(Z0(J))Q.push(J);let Z=0;for(let J of O)if(Y0(J))Z++;let $=z0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as u0}from"async_hooks";import{spawnSync as C0}from"child_process";import{createHash as f0}from"crypto";import{existsSync as BZ,mkdirSync as y,readFileSync as LQ,writeFileSync as _Q}from"fs";import{homedir as NZ}from"os";import{basename as M0,join as v,parse as T0,resolve as PZ}from"path";function G(){return process.env.BEACON_HOME||v(NZ(),".beacon")}function kQ(){return v(G(),"workspaces.json")}function qQ(Q){return f0("sha256").update(Q).digest("hex").slice(0,12)}function C1(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 GZ(Q){let Z=PZ(Q);return Z!==PZ(NZ())&&Z!==T0(Z).root}function vZ(){return v(G(),"deleted.json")}function SQ(){try{let Q=JSON.parse(LQ(vZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function xZ(Q){y(G(),{recursive:!0}),_Q(vZ(),JSON.stringify(Q,null,2))}function KZ(Q){return SQ().includes(Q)}function f1(Q){let Z=SQ();if(!Z.includes(Q))xZ([...Z,Q])}function w0(Q){let Z=SQ();if(Z.includes(Q))xZ(Z.filter(($)=>$!==Q))}function XQ(Q){return v(G(),Q)}function R0(Q){return`file:${v(XQ(Q),"db.sqlite")}`}function L(){try{let Q=JSON.parse(LQ(kQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function hQ(Q){y(G(),{recursive:!0}),_Q(kQ(),JSON.stringify(Q,null,2))}function UQ(){return L().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function u(Q){return L().find((Z)=>Z.id===Q)??null}function uZ(Q,Z,$=new Date().toISOString()){if(!GZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=qQ(Q);if(KZ(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||M0(Q),lastOpenedAt:$},X=[q,...Y.filter((z)=>z.id!==J)];return y(XQ(J),{recursive:!0}),hQ(X),q}function M1(Q,Z){return w0(qQ(Q)),uZ(Q,Z)}function T1(Q,Z=new Date().toISOString()){let $=L(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,hQ($)}function w1(Q){if(hQ(L().filter((Z)=>Z.id!==Q)),mQ()===Q)F0(UQ()[0]?.id??null)}function CZ(){return v(G(),"active")}function mQ(){try{return LQ(CZ(),"utf8").trim()||null}catch{return null}}function F0(Q){y(G(),{recursive:!0}),_Q(CZ(),Q??"")}function R1(){let Q=mQ();return Q?u(Q):null}function F1(){let Q=I0()??mQ();return Q?u(Q):null}function g1(Q){return u(Q)?.path??null}function E1(){return BZ(kQ())}var fZ="beacon_ws";function MZ(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 I1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=MZ(Q,fZ);if($&&u($))return $;return g0()}function g0(){let Q=UQ();return Q.length===1?Q[0].id:null}var E0="x-beacon-workspace-path";async function D1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&u(Z))return Z;let $=Q.headers.get(E0);if($&&GZ($)&&!KZ(qQ($))&&(!Z||qQ($)===Z)){let Y=uZ($);return await D0(Y.id),Y.id}let J=MZ(Q,fZ);if(J&&u(J))return J;return null}var TZ=new u0;function A1(Q,Z){return Q?TZ.run(Q,Z):Z()}function I0(){return TZ.getStore()??null}var yQ=new Set;function b1(Q){yQ.delete(v(XQ(Q),"db.sqlite"))}async function D0(Q){let Z=XQ(Q),$=v(Z,"db.sqlite"),J=BZ($);if(J&&yQ.has($))return{ok:!0,created:!1,migrated:!1};try{y(Z,{recursive:!0});let{provisionDb:Y}=await jZ().then(() => HZ),V=await Y(R0(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)}}}p();gQ();import{existsSync as WQ,readFileSync as A0,rmSync as b0}from"fs";import{join as O0}from"path";var wZ=process.argv.slice(3),RZ=wZ.includes("--yes")||wZ.includes("-y"),B=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,P=(Q)=>`\x1B[2m${Q}\x1B[0m`,f=(Q)=>`
|
|
279
|
+
\x1B[1m${Q}\x1B[0m`,FZ=(Q)=>`\x1B[33m!\x1B[0m ${Q}`,C=G(),_=UQ(),pQ=UZ();console.log(f(RZ?"Beacon \xB7 uninstall":"Beacon \xB7 uninstall (dry run)"));console.log(f("Global"));console.log(` ${WQ(C)?`wipe ${C} (${_.length} workspaces)`:`${P(`${C} \u2014 already gone`)}`}`);for(let Q of j)console.log(` ${pQ.skills[Q]?`remove ~/.claude/skills/${Q}/`:P(`skill ${Q} \u2014 already gone`)}`);for(let Q of O)console.log(` ${pQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command}`:P(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${pQ.claudeMdBlock?"strip Beacon block from ~/.claude/CLAUDE.md":P("global CLAUDE.md block \u2014 already gone")}`);var HQ=RQ();console.log(f("Codex"));for(let Q of j)console.log(` ${HQ.skills[Q]?`remove ~/.agents/skills/${Q}/`:P(`skill ${Q} \u2014 already gone`)}`);for(let Q of R)console.log(` ${HQ.hooks[Q.event]?`remove hook ${Q.event} \u2192 ${Q.command} from ~/.codex/hooks.json`:P(`hook ${Q.event} \u2192 ${Q.command} \u2014 already gone`)}`);console.log(` ${HQ.agentsMdBlock?"strip Beacon block from ~/.codex/AGENTS.md":P("global ~/.codex/AGENTS.md block \u2014 already gone")}`);console.log(` ${HQ.mcp?"strip [mcp_servers.beacon] from ~/.codex/config.toml (if Beacon wrote it)":P("config.toml beacon entry \u2014 already gone")}`);if(_.length){console.log(f(`Per-repo (${_.length})`));for(let Q of _){if(!WQ(Q.path)){console.log(` ${P(`${Q.path} \u2014 repo no longer on disk, skipping`)}`);continue}console.log(` ${Q.path}`),console.log(` ${P("strip beacon entry from .mcp.json, workflow block from AGENTS.md, skills, CLAUDE.md @-import")}`)}}if(!RZ)console.log(f("Nothing was changed.")),console.log(" Run \x1B[1mbeacon uninstall --yes\x1B[0m to apply."),console.log(` The \x1B[1mbeacon\x1B[0m binary itself (the cloned source + your PATH symlink) is NOT removed by this \u2014 your install script handles that.
|
|
280
|
+
`),process.exit(0);console.log(f("Applying\u2026"));var F=bQ();if(F.skillsRemoved.length)console.log(` ${B(`removed skills: ${F.skillsRemoved.join(", ")}`)}`);if(F.hooksRemoved)console.log(` ${B(`removed ${F.hooksRemoved} hook${F.hooksRemoved===1?"":"s"} from ~/.claude/settings.json`)}`);if(F.claudeMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.claude/CLAUDE.md")}`);var x=FQ();if(x.skillsRemoved.length)console.log(` ${B(`removed ~/.agents/skills: ${x.skillsRemoved.join(", ")}`)}`);if(x.hooksRemoved)console.log(` ${B(`removed ${x.hooksRemoved} hook${x.hooksRemoved===1?"":"s"} from ~/.codex/hooks.json`)}`);if(x.agentsMdBlockRemoved)console.log(` ${B("stripped Beacon block from ~/.codex/AGENTS.md")}`);if(x.mcpRemoved)console.log(` ${B("stripped [mcp_servers.beacon] from ~/.codex/config.toml")}`);if(x.mcpSkipped)console.log(` ${FZ("left [mcp_servers.beacon] in ~/.codex/config.toml \u2014 it wasn't written by Beacon (remove with: codex mcp remove beacon)")}`);for(let Q of _){if(!WQ(Q.path))continue;let Z=vQ(Q.path),$=[];if(Z.skillsRemoved.length)$.push(`skills(${Z.skillsRemoved.length})`);if(Z.mcpUnregistered)$.push(".mcp.json");if(Z.agentsBlockRemoved)$.push("AGENTS.md");if(Z.claudeImportRemoved)$.push("CLAUDE.md");if($.length)console.log(` ${B(`${Q.path} \u2192 ${$.join(", ")}`)}`)}var y0=O0(C,"server.json");try{let{pid:Q}=JSON.parse(A0(y0,"utf8"));if(Q)try{process.kill(Q),console.log(` ${B(`stopped daemon (pid ${Q})`)}`)}catch{}}catch{}if(WQ(C))b0(C,{recursive:!0,force:!0}),console.log(` ${B(`removed ${C}`)}`);console.log(f("Done."));console.log(` ${FZ("The `beacon` binary on your PATH is still there \u2014 run the matching uninstall step from your installer to remove it.")}
|
|
277
281
|
`);
|
package/dist/lib/assets.js
CHANGED
|
@@ -214,6 +214,10 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
214
214
|
|
|
215
215
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
216
216
|
|
|
217
|
+
### 2c. Mark the files you mention \u2014 write repo-relative paths in backticks
|
|
218
|
+
|
|
219
|
+
When a plan, feature, or architecture-component description mentions a source file, write its **repo-relative path inside backticks** \u2014 \`app/api/plan/route.ts\`, not "the plan route". On the /plan canvas Beacon turns every backticked token that matches a REAL repo file into a clickable mention that opens it in the user's editor; a bare filename matching several files (e.g. \`route.ts\`) opens a pick-one dropdown of the same-named candidates. The match is deterministic against the live code graph, so a path that isn't a real file just stays plain text \u2014 there's no special syntax to learn and no downside to over-marking: always name files by their real path so the reader can jump straight to the code.
|
|
220
|
+
|
|
217
221
|
### 3. At the end, register the work \u2014 in ONE call
|
|
218
222
|
|
|
219
223
|
Call \`beacon_feature({ action: "done" })\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** \u2014 including its sub-tasks (the cascade completes every PENDING/IN_PROGRESS child; a sub-task you did NOT finish must be set BLOCKED or CANCELLED before registering, so it survives visibly) \u2014 and keeps \`beacon_context_for_feature\` accurate for the next session.
|