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/hook.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var NZ=Object.defineProperty;var PZ=(Q)=>Q;function KZ(Q,Z){this[Q]=PZ.bind(null,Z)}var ZQ=(Q,Z)=>{for(var $ in Z)NZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:KZ.bind(Z,$)})};var K=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var y0=1500,L0=480000,k0=1800000,f=3600000,_0=3000;var FQ=()=>{};var VQ={};ZQ(VQ,{removeRepoAssets:()=>FZ,installRefreshSkill:()=>CZ,installPlanSkill:()=>uZ,installInitSkill:()=>vZ,installCodexRepoSkills:()=>wZ,ensureWorkflowDoc:()=>RZ,ensureMcp:()=>TZ,auditRepo:()=>gZ,REFRESH_SKILL:()=>JQ,PLAN_SKILL:()=>bQ,INIT_SKILL:()=>$Q});import{existsSync as v,mkdirSync as A,readFileSync as x,rmSync as I,writeFileSync as H}from"fs";import{join as U}from"path";function vZ(Q){let Z=U(Q,".claude","skills","beacon-init");A(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,$Q),$}function CZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");A(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,JQ),$}function uZ(Q){let Z=U(Q,".claude","skills","beacon-plan");A(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,bQ),$}function wZ(Q){let Z=[];for(let $ of MZ){let J=U(Q,".agents","skills",$.name);A(J,{recursive:!0});let Y=U(J,"SKILL.md");H(Y,$.body()),Z.push(Y)}return Z}function RZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=x(Z,"utf8")}catch{}let J=new RegExp(`${E}[\\s\\S]*?${YQ}`);$=J.test($)?$.replace(J,OQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${OQ}
|
|
6
6
|
`.trimStart(),H(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
8
|
`);let Y=U(Q,"CLAUDE.md"),V="";try{V=x(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))H(Y,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
11
|
+
`)}function TZ(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(x(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let J=$.mcpServers.beacon;if(J){if(!J.timeout||J.timeout<f)return J.timeout=f,H(Z,JSON.stringify($,null,2)+`
|
|
12
12
|
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:f},H(Z,JSON.stringify($,null,2)+`
|
|
13
|
-
`),{path:Z,added:!0,updated:!1}}function
|
|
14
|
-
`)}}catch{}let Y=!1,V=U(Q,"AGENTS.md");try{let z=x(V,"utf8"),W=new RegExp(`\\n?${
|
|
13
|
+
`),{path:Z,added:!0,updated:!1}}function gZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(x(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=x(U(Q,"AGENTS.md"),"utf8").includes(E)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(x(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":v(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":v(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":v(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":v(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function FZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(v(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(v(W))I(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=U(Q,".mcp.json");try{let z=JSON.parse(x(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)I(J,{force:!0});else H(J,JSON.stringify(z,null,2)+`
|
|
14
|
+
`)}}catch{}let Y=!1,V=U(Q,"AGENTS.md");try{let z=x(V,"utf8"),W=new RegExp(`\\n?${E}[\\s\\S]*?${YQ}\\n?`);if(W.test(z)){let QQ=z.replace(W,`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
|
-
`).trimStart();H(V,
|
|
18
|
-
`)?
|
|
19
|
-
`),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=x(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())
|
|
17
|
+
`).trimStart();H(V,QQ.endsWith(`
|
|
18
|
+
`)?QQ:`${QQ}
|
|
19
|
+
`),Y=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=x(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())I(X,{force:!0});else H(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var $Q=`---
|
|
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
|
+
`,JQ=`---
|
|
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
|
+
`,bQ=`---
|
|
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
|
+
`,MZ,E="<!-- beacon:workflow:start -->",YQ="<!-- beacon:workflow:end -->",OQ;var zQ=K(()=>{FQ();MZ=[{name:"beacon-init",body:()=>$Q},{name:"beacon-refresh",body:()=>JQ}];OQ=`${E}
|
|
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
|
+
${YQ}`});import{existsSync as D,mkdirSync as qQ,readdirSync as OZ,readFileSync as M,rmSync as bZ,writeFileSync as y}from"fs";import{dirname as fQ,join as N}from"path";function IQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function AQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=N(Q,".claude","plugins");if(!D(Z))return null;let $=[Z];for(let J=0;J<3&&$.length;J++){let Y=[];for(let V of $){let q=N(V,".claude-plugin","plugin.json");try{if(D(q)&&JSON.parse(M(q,"utf8")).name==="beacon")return V}catch{}try{for(let X of OZ(V,{withFileTypes:!0}))if(X.isDirectory())Y.push(N(V,X.name))}catch{}}$=Y}return null}function EQ(Q){return AQ(Q)!==null}function XQ(Q){try{return JSON.parse(M(Q,"utf8"))}catch{return{}}}function DQ(Q,Z){qQ(fQ(Q),{recursive:!0}),y(Q,JSON.stringify(Z,null,2)+`
|
|
234
|
+
`)}function k(Q,Z){let $=XQ(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}]}),DQ(Q,$),!0}function _(Q,Z){return(XQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function S(Q,Z){let $=XQ(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 DQ(Q,$),!0}function h(Q,Z,$,J){let Y=`${Z}
|
|
231
235
|
${J.trim()}
|
|
232
|
-
${$}`,V="";try{V=
|
|
236
|
+
${$}`,V="";try{V=M(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
|
+
`,qQ(fQ(Q),{recursive:!0}),y(Q,V.endsWith(`
|
|
237
241
|
`)?V:`${V}
|
|
238
|
-
`)}function
|
|
242
|
+
`)}function w(Q,Z){try{return M(Q,"utf8").includes(Z)}catch{return!1}}function m(Q,Z,$){let J="";try{J=M(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 y(Q,V),!0}function p(Q,Z,$){let J=N(Q,Z);qQ(J,{recursive:!0});let Y=N(J,"SKILL.md");return y(Y,$),Y}function R(Q,Z){return D(N(Q,Z,"SKILL.md"))}function c(Q,Z){let $=N(Q,Z);if(!D($))return!1;return bZ($,{recursive:!0,force:!0}),!0}var j,L=`## 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,18 +262,18 @@ 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 UQ=K(()=>{j=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as fZ,renameSync as IZ,rmSync as AZ,writeFileSync as EZ}from"fs";import{dirname as DZ}from"path";function n(Q,Z){fZ(DZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{EZ($,Z),IZ($,Q)}catch(J){throw AZ($,{force:!0}),J}}function s0(Q,Z,$=!1){n(Q,JSON.stringify(Z,null,$?2:void 0))}var yQ=()=>{};var cQ={};ZQ(cQ,{setupCodexAssets:()=>_Z,removeCodexMcp:()=>pQ,removeCodexArtifacts:()=>hZ,hasCodexMcp:()=>BQ,ensureCodexMcp:()=>mQ,codexMcpProblem:()=>kZ,codexDetected:()=>_Q,auditCodex:()=>SZ,CODEX_HOOKS:()=>t});import{readFileSync as s}from"fs";import{homedir as yZ}from"os";import{join as F}from"path";function LQ(){return process.env.HOME||process.env.USERPROFILE||yZ()}function _Q(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(WQ===void 0)WQ=Bun.which("codex")!==null;return WQ}function g(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function BQ(){try{return Boolean(g(s(C(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function kZ(){let Q="";try{Q=s(C(),"utf8")}catch{return null}let Z=g(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${T}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${T}`;return null}function mQ(){let Q="",Z=!1;try{Q=s(C(),"utf8"),Z=!0}catch{}if(Z){let V=g(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${T}`};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 ${T}`}}let $=!Q?"":Q.endsWith(`
|
|
262
266
|
`)?`
|
|
263
267
|
`:`
|
|
264
268
|
|
|
265
|
-
`,J=Q+$+
|
|
266
|
-
`),$=Z.indexOf(
|
|
269
|
+
`,J=Q+$+LZ;if(g(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${T}`};return n(C(),J),{added:!0}}function pQ(){let Q="";try{Q=s(C(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
270
|
+
`),$=Z.indexOf(SQ);if($===-1)return{removed:!1,skipped:BQ()};let J=Z.indexOf(hQ,$);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(g(Y)===null)return{removed:!1,skipped:!0};return
|
|
273
|
+
`).replace(/^\n+/,"");if(g(Y)===null)return{removed:!1,skipped:!0};return n(C(),Y),{removed:!0}}async function _Z(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (zQ(),VQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of j){if(!R(d(),z))Y.push(z);p(d(),z,J[z])}let V=0;for(let z of t)if(k(xQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=w(l(),a);h(l(),a,kQ,L);let X=mQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function SZ(){let Q={};for(let $ of j)Q[$]=R(d(),$);let Z={};for(let $ of t)Z[$.event]=_(xQ(),{event:$.event,command:$.command});return{detected:_Q(),skills:Q,hooks:Z,agentsMdBlock:w(l(),a),mcp:BQ()}}function hZ(){let Q=[];for(let Y of j)if(c(d(),Y))Q.push(Y);let Z=0;for(let Y of t)if(S(xQ(),{event:Y.event,command:Y.command}))Z++;let $=m(l(),a,kQ),J=pQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var HQ=()=>F(LQ(),".codex"),xQ=()=>F(HQ(),"hooks.json"),C=()=>F(HQ(),"config.toml"),l=()=>F(HQ(),"AGENTS.md"),d=()=>F(LQ(),".agents","skills"),a="<!-- beacon:global:start -->",kQ="<!-- beacon:global:end -->",t,WQ,SQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",hQ="# beacon:end",LZ,T="add it manually: codex mcp add beacon -- beacon mcp";var nQ=K(()=>{UQ();yQ();t=[{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."}];LZ=`${SQ}
|
|
270
274
|
[mcp_servers.beacon]
|
|
271
275
|
command = "beacon"
|
|
272
276
|
args = ["mcp"]
|
|
273
|
-
${
|
|
274
|
-
`});var
|
|
275
|
-
`)){let J=
|
|
277
|
+
${hQ}
|
|
278
|
+
`});var rQ={};ZQ(rQ,{provisionDb:()=>H0});import{createClient as Q0}from"@libsql/client";import{drizzle as Z0}from"drizzle-orm/libsql";import{migrate as $0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as J0}from"drizzle-orm/migrator";import{dirname as vQ,join as Y0}from"path";import{fileURLToPath as V0}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 U0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function tQ(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 W0(Q){for(let[Z,$]of Object.entries(X0)){if(!await i(Q,Z))continue;let J=await U0(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 H0(Q,Z=q0){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 i($,"__drizzle_migrations"),Y=await i($,"Node"),V=!1;if(Y&&!J){let X=J0({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 tQ($);if(await $0(Z0($),{migrationsFolder:Z}),await tQ($)>q)V=!0;return await W0($),{migrated:V}}finally{$.close()}}var z0,q0,X0;var oQ=K(async()=>{z0=vQ(vQ(vQ(V0(import.meta.url)))),q0=process.env.BEACON_MIGRATIONS_DIR||Y0(z0,"drizzle"),X0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});UQ();import{existsSync as mZ}from"fs";import{homedir as pZ}from"os";import{join as r}from"path";function cZ(){return process.env.HOME||process.env.USERPROFILE||pZ()}var o=()=>r(cZ(),".claude"),jQ=()=>r(o(),"skills"),GQ=()=>r(o(),"settings.json"),NQ=()=>r(o(),"CLAUDE.md"),PQ="<!-- beacon:global:start -->",lQ="<!-- beacon:global:end -->";var nZ=L,KQ=[{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 lZ(Q,Z){return p(jQ(),Q,Z)}function dQ(Q){return R(jQ(),Q)}function dZ(Q){return c(jQ(),Q)}function aZ(Q){return k(GQ(),Q)}function sZ(Q){return _(GQ(),Q)}function tZ(Q){return S(GQ(),Q)}function rZ(Q){h(NQ(),PQ,lQ,Q)}function aQ(){return w(NQ(),PQ)}function oZ(){return m(NQ(),PQ,lQ)}function V1(){let Q={};for(let $ of j)Q[$]=dQ($);let Z={};for(let $ of KQ)Z[$.event]=sZ({event:$.event,command:$.command});return{homeExists:mZ(o()),skills:Q,hooks:Z,claudeMdBlock:aQ()}}async function iZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (zQ(),VQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let X of j){if(!dQ(X))Y.push(X);lZ(X,J[X])}let V=0;for(let X of KQ)if(aZ({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=aQ();return rZ(nZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!q}}async function sQ(){if(IQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(EQ()){try{eZ()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await iZ()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (nQ(),cQ));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 eZ(){let Q=[];for(let J of j)if(dZ(J))Q.push(J);let Z=0;for(let J of KQ)if(tZ(J))Z++;let $=oZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as x0}from"async_hooks";import{spawnSync as B0}from"child_process";import{createHash as j0}from"crypto";import{existsSync as eQ,mkdirSync as O,readFileSync as uQ,writeFileSync as MQ}from"fs";import{homedir as QZ}from"os";import{basename as G0,join as G,parse as N0,resolve as iQ}from"path";function B(){return process.env.BEACON_HOME||G(QZ(),".beacon")}function wQ(){return G(B(),"workspaces.json")}function u(Q){return j0("sha256").update(Q).digest("hex").slice(0,12)}function ZZ(Q=process.cwd()){let Z=B0("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 $Z(Q){let Z=iQ(Q);return Z!==iQ(QZ())&&Z!==N0(Z).root}function JZ(){return G(B(),"deleted.json")}function RQ(){try{let Q=JSON.parse(uQ(JZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function YZ(Q){O(B(),{recursive:!0}),MQ(JZ(),JSON.stringify(Q,null,2))}function VZ(Q){return RQ().includes(Q)}function v1(Q){let Z=RQ();if(!Z.includes(Q))YZ([...Z,Q])}function P0(Q){let Z=RQ();if(Z.includes(Q))YZ(Z.filter(($)=>$!==Q))}function e(Q){return G(B(),Q)}function K0(Q){return`file:${G(e(Q),"db.sqlite")}`}function b(){try{let Q=JSON.parse(uQ(wQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function TQ(Q){O(B(),{recursive:!0}),MQ(wQ(),JSON.stringify(Q,null,2))}function zZ(){return b().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function P(Q){return b().find((Z)=>Z.id===Q)??null}function qZ(Q,Z,$=new Date().toISOString()){if(!$Z(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let J=u(Q);if(VZ(J))throw Error(`beacon: workspace ${J} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let Y=b(),V=Y.find((z)=>z.id===J),q={id:J,path:Q,name:Z||V?.name||G0(Q),lastOpenedAt:$},X=[q,...Y.filter((z)=>z.id!==J)];return O(e(J),{recursive:!0}),TQ(X),q}function C1(Q,Z){return P0(u(Q)),qZ(Q,Z)}function u1(Q,Z=new Date().toISOString()){let $=b(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,TQ($)}function M1(Q){if(TQ(b().filter((Z)=>Z.id!==Q)),gQ()===Q)v0(zZ()[0]?.id??null)}function XZ(){return G(B(),"active")}function gQ(){try{return uQ(XZ(),"utf8").trim()||null}catch{return null}}function v0(Q){O(B(),{recursive:!0}),MQ(XZ(),Q??"")}function w1(){let Q=gQ();return Q?P(Q):null}function R1(){let Q=M0()??gQ();return Q?P(Q):null}function T1(Q){return P(Q)?.path??null}function g1(){return eQ(wQ())}var UZ="beacon_ws";function WZ(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 F1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=WZ(Q,UZ);if($&&P($))return $;return C0()}function C0(){let Q=zZ();return Q.length===1?Q[0].id:null}var u0="x-beacon-workspace-path";async function O1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&P(Z))return Z;let $=Q.headers.get(u0);if($&&$Z($)&&!VZ(u($))&&(!Z||u($)===Z)){let Y=qZ($);return await w0(Y.id),Y.id}let J=WZ(Q,UZ);if(J&&P(J))return J;return null}var HZ=new x0;function b1(Q,Z){return Q?HZ.run(Q,Z):Z()}function M0(){return HZ.getStore()??null}var CQ=new Set;function f1(Q){CQ.delete(G(e(Q),"db.sqlite"))}async function w0(Q){let Z=e(Q),$=G(Z,"db.sqlite"),J=eQ($);if(J&&CQ.has($))return{ok:!0,created:!1,migrated:!1};try{O(Z,{recursive:!0});let{provisionDb:Y}=await oQ().then(() => rQ),V=await Y(K0(Q));return CQ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}import{connect as R0}from"net";var xZ=4319;function T0(Q,Z,$=400){return new Promise((J)=>{let Y=R0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,Y.destroy(),J(X)};Y.once("connect",()=>q(!0)),Y.once("error",()=>q(!1)),Y.setTimeout($,()=>q(!1))})}async function g0(Q){for(let Z of["127.0.0.1","::1"])if(await T0(Z,Q))return!1;return!0}async function E1(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await g0($))return $;return Q}import{resolve as F0}from"path";var O0="*** Begin Patch",b0=/^\*\*\* (Update File|Add File|Move to): (.+)$/;function f0(Q){let Z=[];for(let $ of Q.split(`
|
|
279
|
+
`)){let J=b0.exec($.trim());if(!J)continue;let Y=J[2].trim();if(J[1]==="Move to")Z.pop();Z.push(Y)}return Z}function BZ(Q){let Z=Q.tool_input;if(Z===null||typeof Z!=="object")return[];let $=Z,J=[];if(typeof $.file_path==="string")J.push($.file_path);if(typeof $.path==="string")J.push($.path);if(Array.isArray($.files))for(let V of $.files){let q=V?.file_path;if(typeof q==="string")J.push(q)}if(J.length)return J;let Y=typeof Q.cwd==="string"?Q.cwd:process.cwd();for(let V of Object.values($)){if(typeof V!=="string"||!V.includes(O0))continue;return f0(V).map((q)=>F0(Y,q))}return[]}import{readFileSync as I0}from"fs";import{join as A0}from"path";function E0(){try{return JSON.parse(I0(A0(B(),"server.json"),"utf8"))}catch{return null}}function jZ(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${E0()?.port||process.env.PORT||xZ}`}await sQ();var GZ="";for await(let Q of process.stdin)GZ+=Q;try{let Q=JSON.parse(GZ||"{}"),Z=BZ(Q);if(Z.length){let $=u(ZZ(typeof Q.cwd==="string"?Q.cwd:void 0));await fetch(`${jZ()}/api/map/touch-active`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":$},body:JSON.stringify({files:Z})}).catch(()=>{})}}catch{}process.exit(0);
|