trybeacon 0.1.33 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +15 -15
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/db/backfill-access/route.js +1 -1
- package/.next/server/app/api/draft/status/route.js +1 -1
- package/.next/server/app/api/init/route.js +1 -1
- package/.next/server/app/api/plan/annotations/route.js +1 -1
- package/.next/server/app/api/preferences/route.js +1 -1
- package/.next/server/app/api/reset/route.js +1 -1
- package/.next/server/app/api/workspace/route.js +1 -1
- package/.next/server/app/docs/page.js +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +2 -2
- package/.next/server/app/docs.segments/_full.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page.js +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.js +2 -2
- package/.next/server/app/help/page.js.nft.json +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +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 +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/map/page.js +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/settings/page.js +2 -2
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +15 -15
- package/.next/server/chunks/249.js +1 -1
- package/.next/server/chunks/2933.js +1 -1
- package/.next/server/chunks/4378.js +1 -1
- package/.next/server/chunks/4940.js +1 -0
- package/.next/server/chunks/7266.js +1 -0
- package/.next/server/chunks/9213.js +1 -1
- package/.next/server/chunks/9683.js +1 -1
- package/.next/server/chunks/9734.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/6764-ff2754e69d33be8a.js +1 -0
- package/.next/static/chunks/app/map/page-f3aa9e2ca859e0a1.js +1 -0
- package/.next/static/chunks/app/plan/page-056303390782b974.js +1 -0
- package/.next/static/css/496162fa86c30a1d.css +1 -0
- package/.next/trace +38 -38
- package/.next/trace-build +1 -1
- package/dist/bin/beacon.js +9 -6
- package/dist/bin/doctor.js +25 -25
- package/dist/bin/hook.js +22 -22
- package/dist/bin/mcp.js +33 -33
- package/dist/bin/plan.js +25 -25
- package/dist/bin/remove.js +6 -6
- package/dist/bin/uninstall.js +24 -24
- package/dist/lib/release.js +2 -0
- package/dist/lib/semver.js +2 -0
- package/dist/lib/workspaces.js +1 -1
- package/package.json +1 -1
- package/.next/server/chunks/7138.js +0 -1
- package/.next/static/chunks/8252-326851ad274762f5.js +0 -1
- package/.next/static/chunks/app/map/page-ac03f88297a40d47.js +0 -1
- package/.next/static/chunks/app/plan/page-47e880f3e83a2753.js +0 -1
- package/.next/static/css/cb2ba3334a6b2336.css +0 -1
- /package/.next/static/{kJSpkyKRHr2jFBQoOGP8P → OgbjxEMZfqIJgM1cAQ4cs}/_buildManifest.js +0 -0
- /package/.next/static/{kJSpkyKRHr2jFBQoOGP8P → OgbjxEMZfqIJgM1cAQ4cs}/_ssgManifest.js +0 -0
package/dist/bin/mcp.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var R9=Object.defineProperty;var D9=($)=>$;function A9($,Q){this[$]=D9.bind(null,Q)}var a=($,Q)=>{for(var Z in Q)R9($,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:A9.bind(Q,Z)})};var r=($,Q)=>()=>($&&(Q=$($=0)),Q);var c0={};a(c0,{removeRepoAssets:()=>x9,installRefreshSkill:()=>I9,installPlanSkill:()=>L9,installInitSkill:()=>E9,installCodexRepoSkills:()=>_9,ensureWorkflowDoc:()=>k9,ensureMcp:()=>g9,auditRepo:()=>y9,REFRESH_SKILL:()=>m0,PLAN_SKILL:()=>A5,INIT_SKILL:()=>b0});import{existsSync as m,mkdirSync as B0,readFileSync as L,rmSync as G0,writeFileSync as I}from"fs";import{join as K}from"path";function E9($){let Q=K($,".claude","skills","beacon-init");B0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,b0),Z}function I9($){let Q=K($,".claude","skills","beacon-refresh");B0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,m0),Z}function L9($){let Q=K($,".claude","skills","beacon-plan");B0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return I(Z,A5),Z}function _9($){let Q=[];for(let Z of T9){let Y=K($,".agents","skills",Z.name);B0(Y,{recursive:!0});let X=K(Y,"SKILL.md");I(X,Z.body()),Q.push(X)}return Q}function k9($){let Q=K($,"AGENTS.md"),Z="";try{Z=L(Q,"utf8")}catch{}let Y=new RegExp(`${K0}[\\s\\S]*?${p0}`);Z=Y.test(Z)?Z.replace(Y,D5):`${Z.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${D5}
|
|
6
6
|
`.trimStart(),I(Q,Z.endsWith(`
|
|
7
7
|
`)?Z:`${Z}
|
|
8
|
-
`);let X=
|
|
8
|
+
`);let X=K($,"CLAUDE.md"),H="";try{H=L(X,"utf8")}catch{}if(!/@AGENTS\.md/.test(H))I(X,`${H?`${H.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Q,added:!0}}function
|
|
13
|
-
`)}}catch{}let X=!1,H=
|
|
11
|
+
`)}function g9($){let Q=K($,".mcp.json"),Z={};try{Z=JSON.parse(L(Q,"utf8"))}catch{}if(Z.mcpServers=Z.mcpServers??{},Z.mcpServers.beacon)return{path:Q,added:!1};return Z.mcpServers.beacon={command:"beacon",args:["mcp"]},I(Q,JSON.stringify(Z,null,2)+`
|
|
12
|
+
`),{path:Q,added:!0}}function y9($){let Q=K($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(L(Q,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=L(K($,"AGENTS.md"),"utf8").includes(K0)}catch{}let X=!1;try{X=/@AGENTS\.md/.test(L(K($,"CLAUDE.md"),"utf8"))}catch{}return{repo:$,mcpRegistered:Z,agentsMdBlock:Y,claudeMdImport:X,skills:{"beacon-init":m(K($,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":m(K($,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":m(K($,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":m(K($,".agents","skills","beacon-refresh","SKILL.md"))}}}function x9($){let Q=[];for(let U of["beacon-init","beacon-refresh","beacon-db-design"]){let w=K($,".claude","skills",U);if(m(w))G0(w,{recursive:!0,force:!0}),Q.push(U)}for(let U of["beacon-init","beacon-refresh"]){let w=K($,".agents","skills",U);if(m(w))G0(w,{recursive:!0,force:!0}),Q.push(`codex:${U}`)}let Z=!1,Y=K($,".mcp.json");try{let U=JSON.parse(L(Y,"utf8"));if(U.mcpServers?.beacon){if(delete U.mcpServers.beacon,Z=!0,U.mcpServers&&Object.keys(U.mcpServers).length===0)delete U.mcpServers;if(Object.keys(U).length===0)G0(Y,{force:!0});else I(Y,JSON.stringify(U,null,2)+`
|
|
13
|
+
`)}}catch{}let X=!1,H=K($,"AGENTS.md");try{let U=L(H,"utf8"),w=new RegExp(`\\n?${K0}[\\s\\S]*?${p0}\\n?`);if(w.test(U)){let n=U.replace(w,`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
|
-
`).trimStart();I(H,
|
|
17
|
-
`)?
|
|
18
|
-
`),X=!0}}catch{}let
|
|
16
|
+
`).trimStart();I(H,n.endsWith(`
|
|
17
|
+
`)?n:`${n}
|
|
18
|
+
`),X=!0}}catch{}let j=!1,G=K($,"CLAUDE.md");try{let U=L(G,"utf8"),w=U.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(w!==U){if(!w.trim())G0(G,{force:!0});else I(G,w);j=!0}}catch{}return{skillsRemoved:Q,mcpUnregistered:Z,agentsBlockRemoved:X,claudeImportRemoved:j}}var b0=`---
|
|
19
19
|
name: beacon-init
|
|
20
20
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
21
21
|
---
|
|
@@ -52,7 +52,7 @@ A single \`beacon_init_persist\` MCP tool call with:
|
|
|
52
52
|
If \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-init.
|
|
53
53
|
|
|
54
54
|
After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
|
|
55
|
-
`,
|
|
55
|
+
`,m0=`---
|
|
56
56
|
name: beacon-refresh
|
|
57
57
|
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.
|
|
58
58
|
---
|
|
@@ -99,7 +99,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
99
99
|
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.
|
|
100
100
|
|
|
101
101
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
102
|
-
`,
|
|
102
|
+
`,A5=`---
|
|
103
103
|
name: beacon-plan
|
|
104
104
|
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.
|
|
105
105
|
---
|
|
@@ -141,7 +141,7 @@ If it returns feedback, revise and call it again.
|
|
|
141
141
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
142
142
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
143
143
|
run \`beacon\` in this repo once.
|
|
144
|
-
`,
|
|
144
|
+
`,T9,K0="<!-- beacon:workflow:start -->",p0="<!-- beacon:workflow:end -->",D5;var l0=r(()=>{T9=[{name:"beacon-init",body:()=>b0},{name:"beacon-refresh",body:()=>m0}];D5=`${K0}
|
|
145
145
|
## Beacon \u2014 feature workflow
|
|
146
146
|
|
|
147
147
|
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:
|
|
@@ -197,18 +197,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
197
197
|
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.
|
|
198
198
|
|
|
199
199
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
200
|
-
${
|
|
201
|
-
`)}function
|
|
200
|
+
${p0}`});import{existsSync as E5,mkdirSync as s0,readFileSync as N0,rmSync as z9,writeFileSync as M0}from"fs";import{dirname as I5,join as P0}from"path";function d0($){try{return JSON.parse(N0($,"utf8"))}catch{return{}}}function L5($,Q){s0(I5($),{recursive:!0}),M0($,JSON.stringify(Q,null,2)+`
|
|
201
|
+
`)}function w0($,Q){let Z=d0($);Z.hooks=Z.hooks??{},Z.hooks[Q.event]=Z.hooks[Q.event]??[];let Y=Z.hooks[Q.event];if(Y.some((H)=>H.matcher===Q.matcher&&H.hooks?.some((j)=>j.command===Q.command)))return!1;return Y.push({matcher:Q.matcher,hooks:[{type:"command",command:Q.command}]}),L5($,Z),!0}function C0($,Q){return(d0($).hooks?.[Q.event]??[]).some((X)=>X.hooks?.some((H)=>H.command===Q.command))}function v0($,Q){let Z=d0($),Y=Z.hooks?.[Q.event];if(!Y)return!1;let X=!1,H=Y.map((j)=>{let G=j.hooks?.length??0,U=(j.hooks??[]).filter((w)=>w.command!==Q.command);if(U.length!==G)X=!0;return{...j,hooks:U}}).filter((j)=>(j.hooks??[]).length>0);if(!X)return!1;if(H.length)Z.hooks[Q.event]=H;else delete Z.hooks[Q.event];if(Z.hooks&&Object.keys(Z.hooks).length===0)delete Z.hooks;return L5($,Z),!0}function O0($,Q,Z,Y){let X=`${Q}
|
|
202
202
|
${Y.trim()}
|
|
203
|
-
${Z}`,H="";try{H=
|
|
203
|
+
${Z}`,H="";try{H=N0($,"utf8")}catch{}let j=new RegExp(`${Q}[\\s\\S]*?${Z}`);H=j.test(H)?H.replace(j,X):H.trim()?`${H.trim()}
|
|
204
204
|
|
|
205
205
|
${X}
|
|
206
206
|
`:`${X}
|
|
207
|
-
`,
|
|
207
|
+
`,s0(I5($),{recursive:!0}),M0($,H.endsWith(`
|
|
208
208
|
`)?H:`${H}
|
|
209
|
-
`)}function
|
|
209
|
+
`)}function i($,Q){try{return N0($,"utf8").includes(Q)}catch{return!1}}function F0($,Q,Z){let Y="";try{Y=N0($,"utf8")}catch{return!1}let X=new RegExp(`${Q}[\\s\\S]*?${Z}\\n?`);if(!X.test(Y))return!1;let H=Y.replace(X,"").replace(/\n{3,}/g,`
|
|
210
210
|
|
|
211
|
-
`).trimStart();return
|
|
211
|
+
`).trimStart();return M0($,H),!0}function R0($,Q,Z){let Y=P0($,Q);s0(Y,{recursive:!0});let X=P0(Y,"SKILL.md");return M0(X,Z),X}function t($,Q){return E5(P0($,Q,"SKILL.md"))}function D0($,Q){let Z=P0($,Q);if(!E5(Z))return!1;return z9(Z,{recursive:!0,force:!0}),!0}var k,q0=`## Beacon (visual planning panel)
|
|
212
212
|
|
|
213
213
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
214
214
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -229,39 +229,39 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
229
229
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
230
230
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
231
231
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
232
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
232
|
+
verbatim. Do NOT implement until the tool returns approval.`;var o0=r(()=>{k=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as S9,renameSync as h9,rmSync as f9,writeFileSync as u9}from"fs";import{dirname as b9}from"path";function n0($,Q){S9(b9($),{recursive:!0});let Z=`${$}.tmp`;try{u9(Z,Q),h9(Z,$)}catch(Y){throw f9(Z,{force:!0}),Y}}var T5=()=>{};var h5={};a(h5,{setupCodexAssets:()=>l9,removeCodexMcp:()=>S5,removeCodexArtifacts:()=>d9,hasCodexMcp:()=>t0,ensureCodexMcp:()=>z5,codexMcpProblem:()=>c9,codexDetected:()=>g5,auditCodex:()=>s9,CODEX_HOOKS:()=>T0});import{readFileSync as L0}from"fs";import{homedir as m9}from"os";import{join as Q0}from"path";function _5(){return process.env.HOME||process.env.USERPROFILE||m9()}function g5(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(a0===void 0)a0=Bun.which("codex")!==null;return a0}function $0($){try{return Bun.TOML.parse($)}catch{return null}}function t0(){try{return Boolean($0(L0(p(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function c9(){let $="";try{$=L0(p(),"utf8")}catch{return null}let Q=$0($);if(!Q)return`~/.codex/config.toml does not parse \u2014 ${e}`;if(Q.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test($))return`mcp_servers is an inline table \u2014 ${e}`;return null}function z5(){let $="",Q=!1;try{$=L0(p(),"utf8"),Q=!0}catch{}if(Q){let H=$0($);if(!H)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${e}`};if(H.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test($))return{added:!1,error:`mcp_servers is an inline table \u2014 ${e}`}}let Z=!$?"":$.endsWith(`
|
|
233
233
|
`)?`
|
|
234
234
|
`:`
|
|
235
235
|
|
|
236
|
-
`,Y=$+Z+
|
|
237
|
-
`),Z=Q.indexOf(
|
|
236
|
+
`,Y=$+Z+p9;if($0(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${e}`};return n0(p(),Y),{added:!0}}function S5(){let $="";try{$=L0(p(),"utf8")}catch{return{removed:!1}}let Q=$.split(`
|
|
237
|
+
`),Z=Q.indexOf(y5);if(Z===-1)return{removed:!1,skipped:t0()};let Y=Q.indexOf(x5,Z);if(Y===-1)return{removed:!1,skipped:!0};Q.splice(Z,Y-Z+1);let X=Q.join(`
|
|
238
238
|
`).replace(/\n{3,}/g,`
|
|
239
239
|
|
|
240
|
-
`).replace(/^\n+/,"");if(
|
|
240
|
+
`).replace(/^\n+/,"");if($0(X)===null)return{removed:!1,skipped:!0};return n0(p(),X),{removed:!0}}async function l9(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (l0(),c0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let U of k){if(!t(E0(),U))X.push(U);R0(E0(),U,Y[U])}let H=0;for(let U of T0)if(w0(i0(),{event:U.event,matcher:U.matcher,command:U.command}))H++;let j=i(A0(),I0);O0(A0(),I0,k5,q0);let G=z5();return{skillsAdded:X,hooksAdded:H,agentsMdBlockTouched:!j,mcp:G}}function s9(){let $={};for(let Z of k)$[Z]=t(E0(),Z);let Q={};for(let Z of T0)Q[Z.event]=C0(i0(),{event:Z.event,command:Z.command});return{detected:g5(),skills:$,hooks:Q,agentsMdBlock:i(A0(),I0),mcp:t0()}}function d9(){let $=[];for(let X of k)if(D0(E0(),X))$.push(X);let Q=0;for(let X of T0)if(v0(i0(),{event:X.event,command:X.command}))Q++;let Z=F0(A0(),I0,k5),Y=S5();return{skillsRemoved:$,hooksRemoved:Q,agentsMdBlockRemoved:Z,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var r0=()=>Q0(_5(),".codex"),i0=()=>Q0(r0(),"hooks.json"),p=()=>Q0(r0(),"config.toml"),A0=()=>Q0(r0(),"AGENTS.md"),E0=()=>Q0(_5(),".agents","skills"),I0="<!-- beacon:global:start -->",k5="<!-- beacon:global:end -->",T0,a0,y5="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",x5="# beacon:end",p9,e="add it manually: codex mcp add beacon -- beacon mcp";var f5=r(()=>{o0();T5();T0=[{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."}];p9=`${y5}
|
|
241
241
|
[mcp_servers.beacon]
|
|
242
242
|
command = "beacon"
|
|
243
243
|
args = ["mcp"]
|
|
244
|
-
${
|
|
245
|
-
`});var u5={};d(u5,{provisionDb:()=>j$});import{createClient as t9}from"@libsql/client";import{drizzle as e9}from"drizzle-orm/libsql";import{migrate as $$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as Q$}from"drizzle-orm/migrator";import{dirname as $5,join as Z$}from"path";import{fileURLToPath as J$}from"url";async function L0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function H$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function f5($){if(!await L0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function W$($){for(let[Q,Z]of Object.entries(X$)){if(!await L0($,Q))continue;let Y=await H$($,Q);for(let X of Z){if(!Y.has(X))continue;await $.execute(`UPDATE "${Q}" SET "${X}" = CAST((julianday("${X}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${X}") = 'text'`)}}}async function j$($,Q=V$){let Z=t9({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let Y=await L0(Z,"__drizzle_migrations"),X=await L0(Z,"Node"),H=!1;if(X&&!Y){let G=Q$({migrationsFolder:Q})[0];if(G)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[G.hash,G.folderMillis]}),H=!0}let W=await f5(Z);if(await $$(e9(Z),{migrationsFolder:Q}),await f5(Z)>W)H=!0;return await W$(Z),{migrated:H}}finally{Z.close()}}var Y$,V$,X$;var b5=o(async()=>{Y$=$5($5($5(J$(import.meta.url)))),V$=process.env.BEACON_MIGRATIONS_DIR||Z$(Y$,"drizzle"),X$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});c0();import{existsSync as b9}from"fs";import{homedir as m9}from"os";import{join as E0}from"path";function p9(){return process.env.HOME||process.env.USERPROFILE||m9()}var I0=()=>E0(p9(),".claude"),n0=()=>E0(I0(),"skills"),r0=()=>E0(I0(),"settings.json"),i0=()=>E0(I0(),"CLAUDE.md"),t0="<!-- beacon:global:start -->",x5="<!-- beacon:global:end -->";var c9=B0,e0=[{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 l9($,Q){return C0(n0(),$,Q)}function h5($){return n(n0(),$)}function s9($){return v0(n0(),$)}function d9($){return K0(r0(),$)}function o9($){return N0(r0(),$)}function a9($){return M0(r0(),$)}function n9($){q0(i0(),t0,x5,$)}function z5(){return a(i0(),t0)}function r9(){return w0(i0(),t0,x5)}function CQ(){let $={};for(let Z of k)$[Z]=h5(Z);let Q={};for(let Z of e0)Q[Z.event]=o9({event:Z.event,command:Z.command});return{homeExists:b9(I0()),skills:$,hooks:Q,claudeMdBlock:z5()}}async function i9(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (b0(),u0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let G of k){if(!h5(G))X.push(G);l9(G,Y[G])}let H=0;for(let G of e0)if(d9({event:G.event,matcher:G.matcher,command:G.command}))H++;let W=z5();return n9(c9),{skillsAdded:X,hooksAdded:H,claudeMdBlockTouched:!W}}async function S5(){let $;try{$={ok:!0,...await i9()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (y5(),g5));if(Q.codexDetected())$.codex={ok:!0,...await Q.setupCodexAssets()}}catch(Q){$.codex={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return $}function vQ(){let $=[];for(let Y of k)if(s9(Y))$.push(Y);let Q=0;for(let Y of e0)if(a9(Y))Q++;let Z=r9();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as U$}from"async_hooks";import{spawnSync as G$}from"child_process";import{createHash as P$}from"crypto";import{existsSync as m5,mkdirSync as T0,readFileSync as p5,writeFileSync as c5}from"fs";import{homedir as B$}from"os";import{basename as K$,join as x}from"path";function e(){return process.env.BEACON_HOME||x(B$(),".beacon")}function Z5(){return x(e(),"workspaces.json")}function _0($){return P$("sha256").update($).digest("hex").slice(0,12)}function l5($=process.cwd()){let Q=G$("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function k0($){return x(e(),$)}function J5($){return`file:${x(k0($),"db.sqlite")}`}function $0(){try{let $=JSON.parse(p5(Z5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function Y5($){T0(e(),{recursive:!0}),c5(Z5(),JSON.stringify($,null,2))}function N$(){return $0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function y($){return $0().find((Q)=>Q.id===$)??null}function V5($,Q,Z=new Date().toISOString()){let Y=_0($),X=$0(),H=X.find((j)=>j.id===Y),W={id:Y,path:$,name:Q||H?.name||K$($),lastOpenedAt:Z},G=[W,...X.filter((j)=>j.id!==Y)];return T0(k0(Y),{recursive:!0}),Y5(G),W}function xQ($,Q=new Date().toISOString()){let Z=$0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,Y5(Z)}function hQ($){if(Y5($0().filter((Q)=>Q.id!==$)),Q0()===$)M$(N$()[0]?.id??null)}function s5(){return x(e(),"active")}function Q0(){try{return p5(s5(),"utf8").trim()||null}catch{return null}}function M$($){T0(e(),{recursive:!0}),c5(s5(),$??"")}function zQ(){let $=Q0();return $?y($):null}function SQ(){let $=H5()??Q0();return $?y($):null}function fQ($){return y($)?.path??null}function uQ(){return m5(Z5())}var d5="beacon_ws";function o5($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let Y of Z.split(";")){let X=Y.indexOf("=");if(X===-1)continue;if(Y.slice(0,X).trim()===Q)return decodeURIComponent(Y.slice(X+1).trim())}return null}function bQ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=o5($,d5);if(Z&&y(Z))return Z;return null}var X5="x-beacon-workspace-path";async function mQ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=$.headers.get(X5);if(Z&&(!Q||_0(Z)===Q)){let X=V5(Z);return await W5(X.id),X.id}let Y=o5($,d5);if(Y&&y(Y))return Y;return null}var a5=new U$;function q$($,Q){return $?a5.run($,Q):Q()}function H5(){return a5.getStore()??null}var Q5=new Set;function pQ($){Q5.delete(x(k0($),"db.sqlite"))}async function W5($){let Q=k0($),Z=x(Q,"db.sqlite"),Y=m5(Z);if(Y&&Q5.has(Z))return{ok:!0,created:!1,migrated:!1};try{T0(Q,{recursive:!0});let{provisionDb:X}=await b5().then(() => u5),H=await X(J5($));return Q5.add(Z),{ok:!0,created:!Y,migrated:Y&&H.migrated}}catch(X){return{ok:!1,created:!1,migrated:!1,error:X instanceof Error?X.message:String(X)}}}import{McpServer as e$,ResourceTemplate as M5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as $Q}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as P}from"zod";var w$=new Set(["GET","HEAD","OPTIONS"]);function n5($){return w$.has($.trim().toUpperCase())?"read":"write"}var C$=P.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},P.object({name:P.string().trim().min(1),type:P.string().trim().min(1),isPk:P.boolean().optional(),isFk:P.boolean().optional(),nullable:P.boolean().optional(),note:P.string().nullish()})),r5=P.object({name:P.string().trim().min(1),domain:P.string().nullish(),description:P.string().nullish(),columns:P.array(C$).default([])}),i5=P.object({fromTable:P.string(),fromColumn:P.string(),toTable:P.string(),toColumn:P.string(),label:P.string().nullish()}),t5=P.object({method:P.string().trim().min(1),path:P.string().trim().min(1),domain:P.string().nullish(),description:P.string().nullish(),uses:P.array(P.object({table:P.string().trim().min(1),access:P.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??n5($.method)}))})),oQ=P.object({tables:P.array(r5).default([]),relations:P.array(i5).default([]),endpoints:P.array(t5).default([])});import{z as D}from"zod";import{and as NZ,eq as MZ,inArray as qZ}from"drizzle-orm";import{drizzle as c$}from"drizzle-orm/libsql";import{createClient as l$}from"@libsql/client";var j5={};d(j5,{tag:()=>p,syncState:()=>D$,projectMeta:()=>E$,note:()=>R$,nodeTags:()=>h,nodeFile:()=>Z0,node:()=>K,endpointTable:()=>S,endpoint:()=>c,edge:()=>g,draftTable:()=>A,draftRelation:()=>f,draftColumn:()=>V0,dbTable:()=>v,dbRelation:()=>z,dbColumn:()=>Y0,codeFileEdge:()=>u,codeFile:()=>T,bugFlag:()=>J0,boardAnnotation:()=>F$,appSetting:()=>A$});import{sqliteTable as q,index as N,foreignKey as v$,text as V,integer as U,real as F,uniqueIndex as _,primaryKey as O$}from"drizzle-orm/sqlite-core";import{createId as O}from"@paralleldrive/cuid2";var K=q("Node",{id:V().primaryKey().$defaultFn(()=>O()),view:V().notNull(),kind:V().default("FEATURE").notNull(),cluster:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:U().default(2).notNull(),progress:U().default(0).notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),sourceRef:V(),externalId:V(),source:V().default("MANUAL").notNull(),planId:V(),parentId:V(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Node_cluster_idx").on($.cluster),N("Node_parentId_idx").on($.parentId),N("Node_view_idx").on($.view),v$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),Z0=q("NodeFile",{id:V().primaryKey().$defaultFn(()=>O()),nodeId:V().notNull().references(()=>K.id,{onDelete:"cascade",onUpdate:"cascade"}),path:V().notNull()},($)=>[_("NodeFile_nodeId_path_key").on($.nodeId,$.path),N("NodeFile_nodeId_idx").on($.nodeId)]),p=q("Tag",{id:V().primaryKey().$defaultFn(()=>O()),label:V().notNull(),color:V()},($)=>[_("Tag_label_key").on($.label)]),g=q("Edge",{id:V().primaryKey().$defaultFn(()=>O()),fromId:V().notNull().references(()=>K.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:V().notNull().references(()=>K.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:V().default("DEPENDS").notNull(),label:V(),sourceHandle:V(),targetHandle:V()},($)=>[_("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),N("Edge_toId_idx").on($.toId),N("Edge_fromId_idx").on($.fromId)]),h=q("_NodeTags",{a:V("A").notNull().references(()=>K.id,{onDelete:"cascade",onUpdate:"cascade"}),b:V("B").notNull().references(()=>p.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[_("_NodeTags_AB_unique").on($.a,$.b),N("_NodeTags_B_index").on($.b)]),R$=q("Note",{id:V().primaryKey().$defaultFn(()=>O()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:F().default(0).notNull(),pinned:U({mode:"boolean"}).default(!1).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Note_updatedAt_idx").on($.updatedAt)]),F$=q("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>O()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:F(),y:F(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("BoardAnnotation_target_idx").on($.targetId)]),J0=q("BugFlag",{id:V().primaryKey().$defaultFn(()=>O()),nodeId:V().notNull().references(()=>K.id,{onDelete:"cascade",onUpdate:"cascade"}),by:V().notNull(),note:V().notNull(),resolvedAt:U({mode:"timestamp_ms"}),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[N("BugFlag_nodeId_idx").on($.nodeId)]),v=q("DbTable",{id:V().primaryKey().$defaultFn(()=>O()),name:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("DbTable_domain_idx").on($.domain),_("DbTable_name_key").on($.name)]),Y0=q("DbColumn",{id:V().primaryKey().$defaultFn(()=>O()),tableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:U({mode:"boolean"}).default(!1).notNull(),isFk:U({mode:"boolean"}).default(!1).notNull(),nullable:U({mode:"boolean"}).default(!0).notNull(),note:V(),ord:U().default(0).notNull()},($)=>[_("DbColumn_tableId_name_key").on($.tableId,$.name),N("DbColumn_tableId_idx").on($.tableId)]),z=q("DbRelation",{id:V().primaryKey().$defaultFn(()=>O()),fromTableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DbRelation_toTableId_idx").on($.toTableId),N("DbRelation_fromTableId_idx").on($.fromTableId)]),c=q("Endpoint",{id:V().primaryKey().$defaultFn(()=>O()),method:V().notNull(),path:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[_("Endpoint_method_path_key").on($.method,$.path),N("Endpoint_domain_idx").on($.domain)]),S=q("EndpointTable",{id:V().primaryKey().$defaultFn(()=>O()),endpointId:V().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),access:V().default("read").notNull()},($)=>[_("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),N("EndpointTable_tableId_idx").on($.tableId)]),A=q("DraftTable",{id:V().primaryKey().$defaultFn(()=>O()),name:V().notNull(),domain:V(),description:V(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[_("DraftTable_name_key").on($.name)]),V0=q("DraftColumn",{id:V().primaryKey().$defaultFn(()=>O()),tableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:U({mode:"boolean"}).default(!1).notNull(),isFk:U({mode:"boolean"}).default(!1).notNull(),nullable:U({mode:"boolean"}).default(!0).notNull(),note:V(),ord:U().default(0).notNull()},($)=>[N("DraftColumn_tableId_idx").on($.tableId)]),f=q("DraftRelation",{id:V().primaryKey().$defaultFn(()=>O()),fromTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DraftRelation_toTableId_idx").on($.toTableId),N("DraftRelation_fromTableId_idx").on($.fromTableId)]),T=q("CodeFile",{path:V().primaryKey(),root:V(),lang:V(),x:F().default(0).notNull(),y:F().default(0).notNull(),mtimeMs:F(),size:U(),inDegree:U().default(0).notNull(),outDegree:U().default(0).notNull(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=q("CodeFileEdge",{fromPath:V().notNull().references(()=>T.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:V().notNull().references(()=>T.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:U({mode:"boolean"}).default(!1).notNull()},($)=>[N("CodeFileEdge_circular_idx").on($.circular),N("CodeFileEdge_toPath_idx").on($.toPath),N("CodeFileEdge_fromPath_idx").on($.fromPath),O$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),D$=q("SyncState",{id:V().primaryKey().default("singleton"),version:U().default(0).notNull(),codeGraphSyncedAt:U({mode:"timestamp_ms"}),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),A$=q("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),E$=q("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),updatedAt:U({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var U5={};d(U5,{tagRelations:()=>_$,nodeTagsRelations:()=>k$,nodeRelations:()=>I$,nodeFileRelations:()=>L$,endpointTableRelations:()=>S$,endpointRelations:()=>z$,edgeRelations:()=>g$,draftTableRelations:()=>f$,draftRelationRelations:()=>b$,draftColumnRelations:()=>u$,dbTableRelations:()=>y$,dbRelationRelations:()=>h$,dbColumnRelations:()=>x$,codeFileRelations:()=>m$,codeFileEdgeRelations:()=>p$,bugFlagRelations:()=>T$});import{relations as C}from"drizzle-orm";var I$=C(K,({one:$,many:Q})=>({files:Q(Z0),bugFlags:Q(J0),nodeTags:Q(h),edgesOut:Q(g,{relationName:"EdgeFrom"}),edgesIn:Q(g,{relationName:"EdgeTo"}),parent:$(K,{fields:[K.parentId],references:[K.id],relationName:"NodeTree"}),children:Q(K,{relationName:"NodeTree"})})),L$=C(Z0,({one:$})=>({node:$(K,{fields:[Z0.nodeId],references:[K.id]})})),T$=C(J0,({one:$})=>({node:$(K,{fields:[J0.nodeId],references:[K.id]})})),_$=C(p,({many:$})=>({nodeTags:$(h)})),k$=C(h,({one:$})=>({node:$(K,{fields:[h.a],references:[K.id]}),tag:$(p,{fields:[h.b],references:[p.id]})})),g$=C(g,({one:$})=>({from:$(K,{fields:[g.fromId],references:[K.id],relationName:"EdgeFrom"}),to:$(K,{fields:[g.toId],references:[K.id],relationName:"EdgeTo"})})),y$=C(v,({many:$})=>({columns:$(Y0),fksOut:$(z,{relationName:"FkFrom"}),fksIn:$(z,{relationName:"FkTo"}),usages:$(S)})),x$=C(Y0,({one:$})=>({table:$(v,{fields:[Y0.tableId],references:[v.id]})})),h$=C(z,({one:$})=>({fromTable:$(v,{fields:[z.fromTableId],references:[v.id],relationName:"FkFrom"}),toTable:$(v,{fields:[z.toTableId],references:[v.id],relationName:"FkTo"})})),z$=C(c,({many:$})=>({tables:$(S)})),S$=C(S,({one:$})=>({endpoint:$(c,{fields:[S.endpointId],references:[c.id]}),table:$(v,{fields:[S.tableId],references:[v.id]})})),f$=C(A,({many:$})=>({columns:$(V0),fksOut:$(f,{relationName:"DraftFkFrom"}),fksIn:$(f,{relationName:"DraftFkTo"})})),u$=C(V0,({one:$})=>({table:$(A,{fields:[V0.tableId],references:[A.id]})})),b$=C(f,({one:$})=>({fromTable:$(A,{fields:[f.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[f.toTableId],references:[A.id],relationName:"DraftFkTo"})})),m$=C(T,({many:$})=>({edgesOut:$(u,{relationName:"CFEFrom"}),edgesIn:$(u,{relationName:"CFETo"})})),p$=C(u,({one:$})=>({fromFile:$(T,{fields:[u.fromPath],references:[T.path],relationName:"CFEFrom"}),toFile:$(T,{fields:[u.toPath],references:[T.path],relationName:"CFETo"})}));var s$={...j5,...U5};function d$(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var o$=d$();function e5($){let Q=l$({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),c$(Q,{schema:s$})}var P5=globalThis,G5=P5.dzDefault??e5(o$);P5.dzDefault=G5;var g0=P5.dzByUrl??=new Map;function a$($){let Q=g0.get($);if(!Q)Q=e5($),g0.set($,Q);return Q}function ZZ($){let Q=g0.get($);g0.delete($);try{Q?.$client?.close?.()}catch{}}function n$(){if(process.env.BEACON_REPO)return G5;let $=H5()??Q0();if(!$)return G5;return a$(J5($))}var r$=new Proxy({},{get($,Q){let Z=n$(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});import{forceCenter as XZ,forceCollide as HZ,forceLink as WZ,forceManyBody as jZ,forceSimulation as UZ}from"d3-force";var $9=D.object({title:D.string().trim().min(1),role:D.string().nullish(),plain:D.string().nullish(),cluster:D.string().nullish(),category:D.string().nullish(),domain:D.string().nullish(),priority:D.number().nullish(),kind:D.string().nullish(),dependsOn:D.array(D.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,...X})=>({...X,cluster:X.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE"})),OZ=D.object({features:D.array($9).default([])});var i$=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function Q9($){return!!$&&i$.test($)}function t$($){return $.cluster??$.category??$.domain??null}function Z9($){let Q=$.map((Z)=>{let Y=[],X=t$(Z);if(!X||!X.trim())Y.push("category");if(Z.priority==null)Y.push("priority");return Y.length?` \u2022 "${Z.title?.trim()||"(untitled)"}" \u2014 missing ${Y.join(" + ")}`:null}).filter((Z)=>Z!==null);if(Q.length===0)return null;return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+`on the board, and the user shouldn't have to add them by hand. Missing:
|
|
244
|
+
${x5}
|
|
245
|
+
`});var l5={};a(l5,{provisionDb:()=>M$});import{createClient as V$}from"@libsql/client";import{drizzle as X$}from"drizzle-orm/libsql";import{migrate as H$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as j$}from"drizzle-orm/migrator";import{dirname as Y5,join as U$}from"path";import{fileURLToPath as W$}from"url";async function g0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function P$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function c5($){if(!await g0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function N$($){for(let[Q,Z]of Object.entries(K$)){if(!await g0($,Q))continue;let Y=await P$($,Q);for(let X of Z){if(!Y.has(X))continue;await $.execute(`UPDATE "${Q}" SET "${X}" = CAST((julianday("${X}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${X}") = 'text'`)}}}async function M$($,Q=B$){let Z=V$({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let Y=await g0(Z,"__drizzle_migrations"),X=await g0(Z,"Node"),H=!1;if(X&&!Y){let G=j$({migrationsFolder:Q})[0];if(G)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[G.hash,G.folderMillis]}),H=!0}let j=await c5(Z);if(await H$(X$(Z),{migrationsFolder:Q}),await c5(Z)>j)H=!0;return await N$(Z),{migrated:H}}finally{Z.close()}}var G$,B$,K$;var s5=r(async()=>{G$=Y5(Y5(Y5(W$(import.meta.url)))),B$=process.env.BEACON_MIGRATIONS_DIR||U$(G$,"drizzle"),K$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});o0();import{existsSync as o9}from"fs";import{homedir as n9}from"os";import{join as _0}from"path";function a9(){return process.env.HOME||process.env.USERPROFILE||n9()}var k0=()=>_0(a9(),".claude"),e0=()=>_0(k0(),"skills"),$5=()=>_0(k0(),"settings.json"),Q5=()=>_0(k0(),"CLAUDE.md"),Z5="<!-- beacon:global:start -->",u5="<!-- beacon:global:end -->";var r9=q0,J5=[{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 i9($,Q){return R0(e0(),$,Q)}function b5($){return t(e0(),$)}function t9($){return D0(e0(),$)}function e9($){return w0($5(),$)}function $$($){return C0($5(),$)}function Q$($){return v0($5(),$)}function Z$($){O0(Q5(),Z5,u5,$)}function m5(){return i(Q5(),Z5)}function J$(){return F0(Q5(),Z5,u5)}function IQ(){let $={};for(let Z of k)$[Z]=b5(Z);let Q={};for(let Z of J5)Q[Z.event]=$$({event:Z.event,command:Z.command});return{homeExists:o9(k0()),skills:$,hooks:Q,claudeMdBlock:m5()}}async function Y$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (l0(),c0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let G of k){if(!b5(G))X.push(G);i9(G,Y[G])}let H=0;for(let G of J5)if(e9({event:G.event,matcher:G.matcher,command:G.command}))H++;let j=m5();return Z$(r9),{skillsAdded:X,hooksAdded:H,claudeMdBlockTouched:!j}}async function p5(){let $;try{$={ok:!0,...await Y$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (f5(),h5));if(Q.codexDetected())$.codex={ok:!0,...await Q.setupCodexAssets()}}catch(Q){$.codex={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return $}function LQ(){let $=[];for(let Y of k)if(t9(Y))$.push(Y);let Q=0;for(let Y of J5)if(Q$(Y))Q++;let Z=J$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as q$}from"async_hooks";import{spawnSync as w$}from"child_process";import{createHash as C$}from"crypto";import{existsSync as o5,mkdirSync as Z0,readFileSync as X5,writeFileSync as H5}from"fs";import{homedir as n5}from"os";import{basename as v$,join as g,parse as O$,resolve as d5}from"path";function z(){return process.env.BEACON_HOME||g(n5(),".beacon")}function j5(){return g(z(),"workspaces.json")}function c($){return C$("sha256").update($).digest("hex").slice(0,12)}function a5($=process.cwd()){let Q=w$("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function y0($){let Q=d5($);return Q!==d5(n5())&&Q!==O$(Q).root}function r5(){return g(z(),"deleted.json")}function U5(){try{let $=JSON.parse(X5(r5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function i5($){Z0(z(),{recursive:!0}),H5(r5(),JSON.stringify($,null,2))}function x0($){return U5().includes($)}function pQ($){let Q=U5();if(!Q.includes($))i5([...Q,$])}function F$($){let Q=U5();if(Q.includes($))i5(Q.filter((Z)=>Z!==$))}function z0($){return g(z(),$)}function W5($){return`file:${g(z0($),"db.sqlite")}`}function J0(){try{let $=JSON.parse(X5(j5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function G5($){Z0(z(),{recursive:!0}),H5(j5(),JSON.stringify($,null,2))}function R$(){return J0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function x($){return J0().find((Q)=>Q.id===$)??null}function S0($,Q,Z=new Date().toISOString()){if(!y0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=c($);if(x0(Y))throw Error(`beacon: workspace ${Y} (${$}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let X=J0(),H=X.find((U)=>U.id===Y),j={id:Y,path:$,name:Q||H?.name||v$($),lastOpenedAt:Z},G=[j,...X.filter((U)=>U.id!==Y)];return Z0(z0(Y),{recursive:!0}),G5(G),j}function cQ($,Q){return F$(c($)),S0($,Q)}function lQ($,Q=new Date().toISOString()){let Z=J0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,G5(Z)}function sQ($){if(G5(J0().filter((Q)=>Q.id!==$)),Y0()===$)D$(R$()[0]?.id??null)}function t5(){return g(z(),"active")}function Y0(){try{return X5(t5(),"utf8").trim()||null}catch{return null}}function D$($){Z0(z(),{recursive:!0}),H5(t5(),$??"")}function dQ(){let $=Y0();return $?x($):null}function oQ(){let $=K5()??Y0();return $?x($):null}function nQ($){return x($)?.path??null}function aQ(){return o5(j5())}var e5="beacon_ws";function $9($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let Y of Z.split(";")){let X=Y.indexOf("=");if(X===-1)continue;if(Y.slice(0,X).trim()===Q)return decodeURIComponent(Y.slice(X+1).trim())}return null}function rQ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&x(Q))return Q;let Z=$9($,e5);if(Z&&x(Z))return Z;return null}var B5="x-beacon-workspace-path";async function iQ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&x(Q))return Q;let Z=$.headers.get(B5);if(Z&&y0(Z)&&!x0(c(Z))&&(!Q||c(Z)===Q)){let X=S0(Z);return await P5(X.id),X.id}let Y=$9($,e5);if(Y&&x(Y))return Y;return null}var Q9=new q$;function A$($,Q){return $?Q9.run($,Q):Q()}function K5(){return Q9.getStore()??null}var V5=new Set;function tQ($){V5.delete(g(z0($),"db.sqlite"))}async function P5($){let Q=z0($),Z=g(Q,"db.sqlite"),Y=o5(Z);if(Y&&V5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Z0(Q,{recursive:!0});let{provisionDb:X}=await s5().then(() => l5),H=await X(W5($));return V5.add(Z),{ok:!0,created:!Y,migrated:Y&&H.migrated}}catch(X){return{ok:!1,created:!1,migrated:!1,error:X instanceof Error?X.message:String(X)}}}import{McpServer as HQ,ResourceTemplate as F5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as jQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var E$=new Set(["GET","HEAD","OPTIONS"]);function Z9($){return E$.has($.trim().toUpperCase())?"read":"write"}var I$=B.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},B.object({name:B.string().trim().min(1),type:B.string().trim().min(1),isPk:B.boolean().optional(),isFk:B.boolean().optional(),nullable:B.boolean().optional(),note:B.string().nullish()})),J9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(I$).default([])}),Y9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),V9=B.object({method:B.string().trim().min(1),path:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),uses:B.array(B.object({table:B.string().trim().min(1),access:B.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??Z9($.method)}))})),JZ=B.object({tables:B.array(J9).default([]),relations:B.array(Y9).default([]),endpoints:B.array(V9).default([])});import{z as D}from"zod";import{and as AZ,eq as EZ,inArray as IZ}from"drizzle-orm";import{drizzle as i$}from"drizzle-orm/libsql";import{createClient as t$}from"@libsql/client";var N5={};a(N5,{tag:()=>l,syncState:()=>g$,projectMeta:()=>x$,note:()=>_$,nodeTags:()=>S,nodeFile:()=>V0,node:()=>P,endpointTable:()=>f,endpoint:()=>s,edge:()=>y,draftTable:()=>A,draftRelation:()=>u,draftColumn:()=>j0,dbTable:()=>v,dbRelation:()=>h,dbColumn:()=>H0,codeFileEdge:()=>b,codeFile:()=>T,bugFlag:()=>X0,boardAnnotation:()=>k$,appSetting:()=>y$});import{sqliteTable as q,index as N,foreignKey as L$,text as V,integer as W,real as R,uniqueIndex as _,primaryKey as T$}from"drizzle-orm/sqlite-core";import{createId as O}from"@paralleldrive/cuid2";var P=q("Node",{id:V().primaryKey().$defaultFn(()=>O()),view:V().notNull(),kind:V().default("FEATURE").notNull(),cluster:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:W().default(2).notNull(),progress:W().default(0).notNull(),x:R().default(0).notNull(),y:R().default(0).notNull(),sourceRef:V(),externalId:V(),source:V().default("MANUAL").notNull(),planId:V(),parentId:V(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Node_cluster_idx").on($.cluster),N("Node_parentId_idx").on($.parentId),N("Node_view_idx").on($.view),L$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),V0=q("NodeFile",{id:V().primaryKey().$defaultFn(()=>O()),nodeId:V().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),path:V().notNull()},($)=>[_("NodeFile_nodeId_path_key").on($.nodeId,$.path),N("NodeFile_nodeId_idx").on($.nodeId)]),l=q("Tag",{id:V().primaryKey().$defaultFn(()=>O()),label:V().notNull(),color:V()},($)=>[_("Tag_label_key").on($.label)]),y=q("Edge",{id:V().primaryKey().$defaultFn(()=>O()),fromId:V().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:V().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:V().default("DEPENDS").notNull(),label:V(),sourceHandle:V(),targetHandle:V()},($)=>[_("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),N("Edge_toId_idx").on($.toId),N("Edge_fromId_idx").on($.fromId)]),S=q("_NodeTags",{a:V("A").notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),b:V("B").notNull().references(()=>l.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[_("_NodeTags_AB_unique").on($.a,$.b),N("_NodeTags_B_index").on($.b)]),_$=q("Note",{id:V().primaryKey().$defaultFn(()=>O()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:R().default(0).notNull(),pinned:W({mode:"boolean"}).default(!1).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Note_updatedAt_idx").on($.updatedAt)]),k$=q("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>O()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:R(),y:R(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("BoardAnnotation_target_idx").on($.targetId)]),X0=q("BugFlag",{id:V().primaryKey().$defaultFn(()=>O()),nodeId:V().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),by:V().notNull(),note:V().notNull(),resolvedAt:W({mode:"timestamp_ms"}),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[N("BugFlag_nodeId_idx").on($.nodeId)]),v=q("DbTable",{id:V().primaryKey().$defaultFn(()=>O()),name:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:R().default(0).notNull(),y:R().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("DbTable_domain_idx").on($.domain),_("DbTable_name_key").on($.name)]),H0=q("DbColumn",{id:V().primaryKey().$defaultFn(()=>O()),tableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:W({mode:"boolean"}).default(!1).notNull(),isFk:W({mode:"boolean"}).default(!1).notNull(),nullable:W({mode:"boolean"}).default(!0).notNull(),note:V(),ord:W().default(0).notNull()},($)=>[_("DbColumn_tableId_name_key").on($.tableId,$.name),N("DbColumn_tableId_idx").on($.tableId)]),h=q("DbRelation",{id:V().primaryKey().$defaultFn(()=>O()),fromTableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DbRelation_toTableId_idx").on($.toTableId),N("DbRelation_fromTableId_idx").on($.fromTableId)]),s=q("Endpoint",{id:V().primaryKey().$defaultFn(()=>O()),method:V().notNull(),path:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:R().default(0).notNull(),y:R().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[_("Endpoint_method_path_key").on($.method,$.path),N("Endpoint_domain_idx").on($.domain)]),f=q("EndpointTable",{id:V().primaryKey().$defaultFn(()=>O()),endpointId:V().notNull().references(()=>s.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),access:V().default("read").notNull()},($)=>[_("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),N("EndpointTable_tableId_idx").on($.tableId)]),A=q("DraftTable",{id:V().primaryKey().$defaultFn(()=>O()),name:V().notNull(),domain:V(),description:V(),x:R().default(0).notNull(),y:R().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[_("DraftTable_name_key").on($.name)]),j0=q("DraftColumn",{id:V().primaryKey().$defaultFn(()=>O()),tableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:W({mode:"boolean"}).default(!1).notNull(),isFk:W({mode:"boolean"}).default(!1).notNull(),nullable:W({mode:"boolean"}).default(!0).notNull(),note:V(),ord:W().default(0).notNull()},($)=>[N("DraftColumn_tableId_idx").on($.tableId)]),u=q("DraftRelation",{id:V().primaryKey().$defaultFn(()=>O()),fromTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DraftRelation_toTableId_idx").on($.toTableId),N("DraftRelation_fromTableId_idx").on($.fromTableId)]),T=q("CodeFile",{path:V().primaryKey(),root:V(),lang:V(),x:R().default(0).notNull(),y:R().default(0).notNull(),mtimeMs:R(),size:W(),inDegree:W().default(0).notNull(),outDegree:W().default(0).notNull(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),b=q("CodeFileEdge",{fromPath:V().notNull().references(()=>T.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:V().notNull().references(()=>T.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:W({mode:"boolean"}).default(!1).notNull()},($)=>[N("CodeFileEdge_circular_idx").on($.circular),N("CodeFileEdge_toPath_idx").on($.toPath),N("CodeFileEdge_fromPath_idx").on($.fromPath),T$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),g$=q("SyncState",{id:V().primaryKey().default("singleton"),version:W().default(0).notNull(),codeGraphSyncedAt:W({mode:"timestamp_ms"}),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),y$=q("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),x$=q("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var M5={};a(M5,{tagRelations:()=>f$,nodeTagsRelations:()=>u$,nodeRelations:()=>z$,nodeFileRelations:()=>S$,endpointTableRelations:()=>s$,endpointRelations:()=>l$,edgeRelations:()=>b$,draftTableRelations:()=>d$,draftRelationRelations:()=>n$,draftColumnRelations:()=>o$,dbTableRelations:()=>m$,dbRelationRelations:()=>c$,dbColumnRelations:()=>p$,codeFileRelations:()=>a$,codeFileEdgeRelations:()=>r$,bugFlagRelations:()=>h$});import{relations as C}from"drizzle-orm";var z$=C(P,({one:$,many:Q})=>({files:Q(V0),bugFlags:Q(X0),nodeTags:Q(S),edgesOut:Q(y,{relationName:"EdgeFrom"}),edgesIn:Q(y,{relationName:"EdgeTo"}),parent:$(P,{fields:[P.parentId],references:[P.id],relationName:"NodeTree"}),children:Q(P,{relationName:"NodeTree"})})),S$=C(V0,({one:$})=>({node:$(P,{fields:[V0.nodeId],references:[P.id]})})),h$=C(X0,({one:$})=>({node:$(P,{fields:[X0.nodeId],references:[P.id]})})),f$=C(l,({many:$})=>({nodeTags:$(S)})),u$=C(S,({one:$})=>({node:$(P,{fields:[S.a],references:[P.id]}),tag:$(l,{fields:[S.b],references:[l.id]})})),b$=C(y,({one:$})=>({from:$(P,{fields:[y.fromId],references:[P.id],relationName:"EdgeFrom"}),to:$(P,{fields:[y.toId],references:[P.id],relationName:"EdgeTo"})})),m$=C(v,({many:$})=>({columns:$(H0),fksOut:$(h,{relationName:"FkFrom"}),fksIn:$(h,{relationName:"FkTo"}),usages:$(f)})),p$=C(H0,({one:$})=>({table:$(v,{fields:[H0.tableId],references:[v.id]})})),c$=C(h,({one:$})=>({fromTable:$(v,{fields:[h.fromTableId],references:[v.id],relationName:"FkFrom"}),toTable:$(v,{fields:[h.toTableId],references:[v.id],relationName:"FkTo"})})),l$=C(s,({many:$})=>({tables:$(f)})),s$=C(f,({one:$})=>({endpoint:$(s,{fields:[f.endpointId],references:[s.id]}),table:$(v,{fields:[f.tableId],references:[v.id]})})),d$=C(A,({many:$})=>({columns:$(j0),fksOut:$(u,{relationName:"DraftFkFrom"}),fksIn:$(u,{relationName:"DraftFkTo"})})),o$=C(j0,({one:$})=>({table:$(A,{fields:[j0.tableId],references:[A.id]})})),n$=C(u,({one:$})=>({fromTable:$(A,{fields:[u.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[u.toTableId],references:[A.id],relationName:"DraftFkTo"})})),a$=C(T,({many:$})=>({edgesOut:$(b,{relationName:"CFEFrom"}),edgesIn:$(b,{relationName:"CFETo"})})),r$=C(b,({one:$})=>({fromFile:$(T,{fields:[b.fromPath],references:[T.path],relationName:"CFEFrom"}),toFile:$(T,{fields:[b.toPath],references:[T.path],relationName:"CFETo"})}));var e$={...N5,...M5};function $Q(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var QQ=$Q();function X9($){let Q=t$({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),i$(Q,{schema:e$})}var w5=globalThis,q5=w5.dzDefault??X9(QQ);w5.dzDefault=q5;var h0=w5.dzByUrl??=new Map;function ZQ($){let Q=h0.get($);if(!Q)Q=X9($),h0.set($,Q);return Q}function BZ($){let Q=h0.get($);h0.delete($);try{Q?.$client?.close?.()}catch{}}function JQ(){if(process.env.BEACON_REPO)return q5;let $=K5()??Y0();if(!$)return q5;return ZQ(W5($))}var YQ=new Proxy({},{get($,Q){let Z=JQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});import{forceCenter as MZ,forceCollide as qZ,forceLink as wZ,forceManyBody as CZ,forceSimulation as vZ}from"d3-force";var H9=D.object({title:D.string().trim().min(1),role:D.string().nullish(),plain:D.string().nullish(),cluster:D.string().nullish(),category:D.string().nullish(),domain:D.string().nullish(),priority:D.number().nullish(),kind:D.string().nullish(),dependsOn:D.array(D.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,...X})=>({...X,cluster:X.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE"})),kZ=D.object({features:D.array(H9).default([])});var VQ=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function j9($){return!!$&&VQ.test($)}function XQ($){return $.cluster??$.category??$.domain??null}function U9($){let Q=$.map((Z)=>{let Y=[],X=XQ(Z);if(!X||!X.trim())Y.push("category");if(Z.priority==null)Y.push("priority");return Y.length?` \u2022 "${Z.title?.trim()||"(untitled)"}" \u2014 missing ${Y.join(" + ")}`:null}).filter((Z)=>Z!==null);if(Q.length===0)return null;return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+`on the board, and the user shouldn't have to add them by hand. Missing:
|
|
246
246
|
`+Q.join(`
|
|
247
|
-
`)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low). Set BOTH on EVERY feature; don't rely on defaults."}function
|
|
247
|
+
`)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low). Set BOTH on EVERY feature; don't rely on defaults."}function C5($){if(!$?.length)return"";let Q=$.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),Z=$.some((Y)=>Y.id);return`
|
|
248
248
|
|
|
249
249
|
This plan created these roadmap feature(s):
|
|
250
250
|
`+Q.join(`
|
|
251
|
-
`)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` with a "+"`features` array \u2014 one entry per feature"+(Z?", 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."}var
|
|
252
|
-
`)}await S5();var q5=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,w5=l5(),h0=_0(w5);try{V5(w5);let $=await W5(h0);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",h0),Z.set(X5,w5);let Y=await fetch(`${q5}${$}`,{...Q,headers:Z}),X=await Y.text();if(!Y.ok)throw Error(`Beacon ${$} -> ${Y.status} ${X}`);return X?JSON.parse(X):null}function l($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function U9($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let Y=JSON.parse(Z[0]);if(Y?.error)return{content:[{type:"text",text:Y.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var R=new e$({name:"beacon",version:"0.1.0"});R.registerTool("beacon_map",{description:"List existing features on the roadmap. Call before starting work."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});R.registerTool("beacon_start_feature",{description:"Flag that you're working on a feature. If the title matches an existing feature it just marks it IN_PROGRESS (no category needed); if it's NEW it creates the node \u2014 and a new feature REQUIRES a `category`. Call beacon_map first so you reuse an existing feature/category instead of duplicating one.",inputSchema:{title:J.string(),id:J.string().optional().describe("node id from beacon_map (preferred)"),category:J.string().optional().describe("Domain lane for a NEW feature: AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 REQUIRED when this creates a new top-level feature; reuse a category already on the board. Ignored when flagging an existing feature or nesting under a `front` (inherits the parent's)."),front:J.string().optional().describe("Title of an EXISTING parent feature to nest this under (draws the parent \u2192 child edge). It must match a real feature \u2014 it is NOT a domain tag (use `category` for the domain). A `front` that matches nothing is REJECTED; create the parent first via beacon_propose_plan."),detail:J.string().optional().describe("One-line plain-language description shown on the canvas card. Replaced later by beacon_describe_feature's markdown when the work is done."),kind:J.enum(["FEATURE","BUG"]).optional().describe("Card type when this CREATES a new node: BUG renders a typed bug card on the roadmap (use when the user is starting work on a bug, not a feature). Defaults to FEATURE; ignored when flagging an existing node.")}},async({title:$,id:Q,front:Z,detail:Y,category:X,kind:H})=>{try{let W=await l("/api/map/start",{title:$,id:Q,front:Z,detail:Y,category:X,kind:H});return{content:[{type:"text",text:JSON.stringify(W)}]}}catch(W){return U9(W)}});R.registerTool("beacon_add_subtasks",{description:"Add N sub-tasks under an existing feature in one call. Use when the user says 'add these as subtasks to <feature>' or you want to record follow-ups discovered during work. Parent resolves by `parentId` (preferred \u2014 get it from beacon_map / beacon_entities) or by `parentTitle` (fuzzy-matched against top-level features). Children inherit the parent's view and cluster and land in a row beneath it; bumps the sync version so an open /map canvas refreshes.",inputSchema:{parentId:J.string().optional().describe("node id of the parent feature (preferred)"),parentTitle:J.string().optional().describe("fuzzy title of the parent feature; ignored if parentId is provided"),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG for a bug discovered during work \u2014 renders as a typed bug card; defaults to FEATURE")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let Y=await l("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(Y)}]}}catch(Y){return U9(Y)}});var W9=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found in this component's code \u2014 flagged on the node (by=agent); identical open flags are not duplicated")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");R.registerTool("beacon_describe_feature",{description:"Register shipped feature(s) at the end of the work: marks status=DONE, records the files touched (kept on the FEATURE for context), and replaces each node's description with your markdown. Subsumes touch_files + finish_feature. A feature's unfinished SUB-TASKS are completed along with it (cascade; reported as `subtasksCompleted`) \u2014 if a sub-task is genuinely NOT done, set it BLOCKED or CANCELLED via the nodes API/board FIRST, those are left alone (`subtasksBlocked` lists what stayed). REGISTER ALL FEATURES A PLAN CREATED IN ONE CALL via the `features` array (one entry per feature) \u2014 do NOT call this once per feature. Pass each feature's `id` (returned to you at plan approval) so no title-matching is needed. For a single feature you may pass the top-level fields instead. Pass `architecture` only when a feature added/changed a REAL subsystem (never a file).",inputSchema:{features:J.array(J.object({id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),architecture:W9})).optional().describe("Register many features at once \u2014 one entry per feature, each id-keyed. Use this instead of N separate calls."),description:J.string().optional().describe("Single-feature markdown (omit when using `features`): ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches (single form)"),id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),architecture:W9}},async({features:$,description:Q,files:Z,id:Y,title:X,architecture:H})=>{let W=$?.length?{features:$}:{description:Q,files:Z,id:Y,title:X,architecture:H},G=await l("/api/map/describe",W);return{content:[{type:"text",text:JSON.stringify(G)}]}});R.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found while examining this component \u2014 flagged on the node (by=agent)")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when the survey found a concrete bug to fix \u2014 renders as a typed bug card; defaults to FEATURE")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await l("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});R.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let Y=new URLSearchParams;if($)Y.set("id",$);if(Q)Y.set("title",Q);if(Z)Y.set("query",Z);let X=await E(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});R.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let Y=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});R.registerTool("beacon_entities",{description:"Read planning data. `features` = roadmap, `architecture` = components, `tables`/`endpoints` = DB map.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"])}},async({kind:$})=>{let Q=await E(`/api/entities?kind=${$}`);return{content:[{type:"text",text:JSON.stringify(Q)}]}});R.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 the tool REJECTS a plan whose features omit either, so set both on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when this roadmap item is a bug to fix \u2014 renders as a typed bug card; defaults to FEATURE")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}},async({description:$,features:Q,tables:Z,relations:Y,endpoints:X})=>{let H=(M)=>new Promise((N9)=>setTimeout(N9,M)),W=(M)=>({content:[{type:"text",text:M}]}),G=(Z?.length??0)>0,j=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
|
|
253
|
-
`),w=(X?.length??0)>0||
|
|
254
|
-
${
|
|
251
|
+
`)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` with a "+"`features` array \u2014 one entry per feature"+(Z?", 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."}var v5=1500,mZ=345600000,O5=1800000,W9=3000;function U0($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function G9($){return`${U0($.title)}-${$.id.slice(-6)}`}function B9($){return{resources:$.map((Q)=>({uri:`note://${G9(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function K9($,Q){return $.find((Z)=>G9(Z)===Q)}function P9($){let Q=$.body.trim()||"(this note is empty)";return[`# ${$.title||"Untitled"}`,"","_User note from Beacon. To turn it into roadmap work, call `beacon_propose_plan` \u2014"+" checkbox `- [ ]` / `- [x]` items become subtasks, and order the features with `dependsOn`. Do NOT implement until it returns approval._","","---","",Q].join(`
|
|
252
|
+
`)}await p5();var R5=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,d=a5(),W0=c(d);if(!y0(d))console.error(`[beacon mcp] not registering ${d} \u2014 home/non-repo dir.`);else if(x0(W0))console.error(`[beacon mcp] not registering ${d} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{S0(d);let $=await P5(W0);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",W0),Z.set(B5,d);let Y=await fetch(`${R5}${$}`,{...Q,headers:Z}),X=await Y.text();if(!Y.ok)throw Error(`Beacon ${$} -> ${Y.status} ${X}`);return X?JSON.parse(X):null}function o($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function q9($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let Y=JSON.parse(Z[0]);if(Y?.error)return{content:[{type:"text",text:Y.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var F=new HQ({name:"beacon",version:"0.1.0"});F.registerTool("beacon_map",{description:"List existing features on the roadmap. Call before starting work."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});F.registerTool("beacon_start_feature",{description:"Flag that you're working on a feature. If the title matches an existing feature it just marks it IN_PROGRESS (no category needed); if it's NEW it creates the node \u2014 and a new feature REQUIRES a `category`. Call beacon_map first so you reuse an existing feature/category instead of duplicating one.",inputSchema:{title:J.string(),id:J.string().optional().describe("node id from beacon_map (preferred)"),category:J.string().optional().describe("Domain lane for a NEW feature: AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 REQUIRED when this creates a new top-level feature; reuse a category already on the board. Ignored when flagging an existing feature or nesting under a `front` (inherits the parent's)."),front:J.string().optional().describe("Title of an EXISTING parent feature to nest this under (draws the parent \u2192 child edge). It must match a real feature \u2014 it is NOT a domain tag (use `category` for the domain). A `front` that matches nothing is REJECTED; create the parent first via beacon_propose_plan."),detail:J.string().optional().describe("One-line plain-language description shown on the canvas card. Replaced later by beacon_describe_feature's markdown when the work is done."),kind:J.enum(["FEATURE","BUG"]).optional().describe("Card type when this CREATES a new node: BUG renders a typed bug card on the roadmap (use when the user is starting work on a bug, not a feature). Defaults to FEATURE; ignored when flagging an existing node.")}},async({title:$,id:Q,front:Z,detail:Y,category:X,kind:H})=>{try{let j=await o("/api/map/start",{title:$,id:Q,front:Z,detail:Y,category:X,kind:H});return{content:[{type:"text",text:JSON.stringify(j)}]}}catch(j){return q9(j)}});F.registerTool("beacon_add_subtasks",{description:"Add N sub-tasks under an existing feature in one call. Use when the user says 'add these as subtasks to <feature>' or you want to record follow-ups discovered during work. Parent resolves by `parentId` (preferred \u2014 get it from beacon_map / beacon_entities) or by `parentTitle` (fuzzy-matched against top-level features). Children inherit the parent's view and cluster and land in a row beneath it; bumps the sync version so an open /map canvas refreshes.",inputSchema:{parentId:J.string().optional().describe("node id of the parent feature (preferred)"),parentTitle:J.string().optional().describe("fuzzy title of the parent feature; ignored if parentId is provided"),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG for a bug discovered during work \u2014 renders as a typed bug card; defaults to FEATURE")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let Y=await o("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(Y)}]}}catch(Y){return q9(Y)}});var N9=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found in this component's code \u2014 flagged on the node (by=agent); identical open flags are not duplicated")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");F.registerTool("beacon_describe_feature",{description:"Register shipped feature(s) at the end of the work: marks status=DONE, records the files touched (kept on the FEATURE for context), and replaces each node's description with your markdown. Subsumes touch_files + finish_feature. A feature's unfinished SUB-TASKS are completed along with it (cascade; reported as `subtasksCompleted`) \u2014 if a sub-task is genuinely NOT done, set it BLOCKED or CANCELLED via the nodes API/board FIRST, those are left alone (`subtasksBlocked` lists what stayed). REGISTER ALL FEATURES A PLAN CREATED IN ONE CALL via the `features` array (one entry per feature) \u2014 do NOT call this once per feature. Pass each feature's `id` (returned to you at plan approval) so no title-matching is needed. For a single feature you may pass the top-level fields instead. Pass `architecture` only when a feature added/changed a REAL subsystem (never a file).",inputSchema:{features:J.array(J.object({id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),architecture:N9})).optional().describe("Register many features at once \u2014 one entry per feature, each id-keyed. Use this instead of N separate calls."),description:J.string().optional().describe("Single-feature markdown (omit when using `features`): ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches (single form)"),id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),architecture:N9}},async({features:$,description:Q,files:Z,id:Y,title:X,architecture:H})=>{let j=$?.length?{features:$}:{description:Q,files:Z,id:Y,title:X,architecture:H},G=await o("/api/map/describe",j);return{content:[{type:"text",text:JSON.stringify(G)}]}});F.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found while examining this component \u2014 flagged on the node (by=agent)")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when the survey found a concrete bug to fix \u2014 renders as a typed bug card; defaults to FEATURE")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await o("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});F.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let Y=new URLSearchParams;if($)Y.set("id",$);if(Q)Y.set("title",Q);if(Z)Y.set("query",Z);let X=await E(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});F.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let Y=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});F.registerTool("beacon_entities",{description:"Read planning data. `features` = roadmap, `architecture` = components, `tables`/`endpoints` = DB map.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"])}},async({kind:$})=>{let Q=await E(`/api/entities?kind=${$}`);return{content:[{type:"text",text:JSON.stringify(Q)}]}});F.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 the tool REJECTS a plan whose features omit either, so set both on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when this roadmap item is a bug to fix \u2014 renders as a typed bug card; defaults to FEATURE")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}},async({description:$,features:Q,tables:Z,relations:Y,endpoints:X})=>{let H=(M)=>new Promise((F9)=>setTimeout(F9,M)),j=(M)=>({content:[{type:"text",text:M}]}),G=(Z?.length??0)>0,U=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
|
|
253
|
+
`),w=(X?.length??0)>0||j9(`${$}
|
|
254
|
+
${U}`);if(!G&&w)return j("\u26D4 This plan touches the database \u2014 it declares endpoints and/or its text describes "+"models/tables/migrations \u2014 but you passed NO `tables`. Beacon's schema board renders "+"ONLY from structured `tables`; prose is never parsed, so the /db tab would be empty and nothing would persist on approve.\n\nRe-call `beacon_propose_plan` with every table in `tables` (each with its `columns`), the `relations` (FKs), and keep the `endpoints` (each with `uses:[{table,access}]`). Mirror EVERY database entity your plan mentions into the structured fields.");if(Q?.length){let M=U9(Q);if(M)return j(M)}let n=(Z?.length??0)+(X?.length??0)>0;await o("/api/plan",{description:$,draft:n?{tables:Z??[],relations:Y??[],endpoints:X??[]}:void 0,features:Q?.length?Q:void 0}),await fetch(`${R5}/api/workspace/activate?id=${W0}`).catch(()=>{});let O9=Date.now()+O5;while(Date.now()<O9){await H(v5);let M=await E("/api/plan/verdict").catch(()=>null);if(!M)continue;if(M.kind==="feedback")return j("\uD83D\uDCAC The user left feedback on the plan in Beacon \u2014 text comments and/or edits they "+"made directly on the /map and /db boards. Read everything below, revise the plan accordingly (matching the board changes verbatim), and call `beacon_propose_plan` "+`again with the revised version \u2014 DO NOT implement yet:
|
|
255
255
|
|
|
256
|
-
`+M.feedback);if(M.kind==="approved")return
|
|
256
|
+
`+M.feedback);if(M.kind==="approved")return j(`\u2705 Plan approved by the user. ${M.summary}`+(M.detail?`
|
|
257
257
|
|
|
258
258
|
Implement EXACTLY the schema below (migrations + code) \u2014 the user may have `+`edited columns on the canvas:
|
|
259
259
|
|
|
260
|
-
`+M.detail:"")+
|
|
260
|
+
`+M.detail:"")+C5(M.features));if(M.kind==="discarded")return j(`\u274C The user discarded the plan in Beacon. ${M.summary} Ask what they want to adjust before proposing again.`)}return j("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_propose_plan` again with the SAME plan to resume (the verdict is picked up immediately if they've since decided), or ask whether they've reviewed it.")});F.registerTool("beacon_present_plan",{description:"BLOCKS until the user reviews. Pushes ANY plan (as markdown) to Beacon's /plan page so the user reviews it on the canvas instead of in the terminal \u2014 use this whenever you'd otherwise end a turn asking 'does this look right / should I proceed?'. Embed ONE fenced ```beacon block of JSON ({tables,relations,endpoints,features}) for any DB/roadmap entities so they render as an editable board. Returns the verdict (approved / discarded / feedback). Do NOT implement until it returns approval; on feedback, revise and call again. (For a pure schema+features plan, beacon_propose_plan is the structured alternative.)",inputSchema:{description:J.string().describe("One-line summary shown in the review header"),markdown:J.string().describe("The full plan as markdown. Embed a ```beacon block for tables/endpoints/features.")}},async({description:$,markdown:Q})=>{let Z=(H)=>new Promise((j)=>setTimeout(j,H)),Y=(H)=>({content:[{type:"text",text:H}]});await o("/api/plan",{description:$,markdown:Q}),await fetch(`${R5}/api/workspace/activate?id=${W0}`).catch(()=>{});let X=Date.now()+O5;while(Date.now()<X){await Z(v5);let H=await E("/api/plan/verdict").catch(()=>null);if(!H)continue;if(H.kind==="feedback")return Y("\uD83D\uDCAC The user left feedback on the plan in Beacon (inline comments and/or edits on the "+"/map and /db boards). Revise the plan accordingly and call `beacon_present_plan` "+`again \u2014 do NOT implement yet:
|
|
261
261
|
|
|
262
262
|
`+H.feedback);if(H.kind==="approved")return Y(`\u2705 Plan approved by the user. ${H.summary??""}`.trim()+(H.detail?`
|
|
263
263
|
|
|
264
264
|
Implement exactly what's on the board:
|
|
265
265
|
|
|
266
|
-
${H.detail}`:"")+
|
|
267
|
-
`)}]}}
|
|
266
|
+
${H.detail}`:"")+C5(H.features));if(H.kind==="discarded")return Y(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return Y("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_present_plan` again with the SAME plan to resume, or ask whether they've reviewed it.")});var w9=($)=>Array.isArray($)?$[0]:$;async function u0($){return(await E(`/api/entities?kind=${$}`)).items}function C9($,Q){return{resources:$.map((Z)=>({uri:`${Q}${U0(Z.title)}`,name:Z.title,description:`${Z.title}${Z.cluster?` \xB7 ${Z.cluster}`:""} \xB7 ${Z.status}`,mimeType:"text/markdown"}))}}async function v9($,Q,Z){let Y=(await u0(Z)).find((G)=>U0(G.title)===w9(Q));if(!Y)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await E("/api/entities?kind=tables")).items??[]).map((G)=>G.name),j=[`# ${Y.title}`];if(Y.cluster)j.push(`*Domain:* \`${Y.cluster}\``);if(Y.status)j.push(`*Status:* \`${Y.status}\``);if(j.push(""),j.push(Y.plain?.trim()||"(this node has no description yet \u2014 add one on Beacon's /map page)"),j.push("","## Existing DB tables in this project"),j.push(H.length?H.join(", "):"(none yet)"),Z==="features"){let G=await u0("features"),U=[...new Set(G.map((w)=>w.cluster?.trim()).filter((w)=>!!w))].sort();j.push("","## Existing feature categories \u2014 reuse one before inventing a new one"),j.push(U.length?U.join(", "):"(none yet)"),j.push("","## Beacon feature loop \u2014 follow IN ORDER (do not jump to Glob/Grep/Read)","1. **Load context FIRST.** Call `beacon_context_for_feature({ title })` for this feature BEFORE any Glob/Grep/Read. It returns the attached files, 1-hop import blast radius, the domain's endpoints + tables + FK relations, sibling components, and the project conventions \u2014 and marks this feature active so your edits attach to it. That bundle replaces the discovery phase; Glob is a last resort.","2. **Design data before code.** Identify the tables this feature needs. If ANY are missing from the list above, design the schema and call `beacon_propose_plan` (tables + relations + endpoints, each endpoint with `uses:[{table,access}]`). It BLOCKS until the user approves on /plan \u2014 do NOT write migrations or code until it returns approval.","3. **Register at the end \u2014 in ONE call.** When the work is done, call `beacon_describe_feature` ONCE with a `features` array (one entry per feature the plan created, each keyed by the `id` you got back at approval, with the files you touched + a short markdown summary). Don't make one call per feature, and don't register only the umbrella \u2014 that leaves the rest Pending.")}return{contents:[{uri:$.href,mimeType:"text/markdown",text:j.join(`
|
|
267
|
+
`)}]}}F.registerResource("beacon-feature",new F5("feature://{slug}",{list:async()=>C9(await u0("features"),"feature://")}),{title:"Beacon: features",description:"Roadmap features \u2014 picking one imports the node's description plus existing-DB context.",mimeType:"text/markdown"},($,{slug:Q})=>v9($,Q,"features"));F.registerResource("beacon-component",new F5("component://{slug}",{list:async()=>C9(await u0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>v9($,Q,"architecture"));async function M9(){return await E("/api/notes")}F.registerResource("beacon-note",new F5("note://{slug}",{list:async()=>B9(await M9())}),{title:"Beacon: notes",description:"Your Beacon notes \u2014 picking one imports its markdown verbatim so you can turn it into features.",mimeType:"text/markdown"},async($,{slug:Q})=>{let Z=K9(await M9(),w9(Q)),Y=Z?P9(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:Y}]}});await F.connect(new jQ);var f0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(f0===-1)f0=$;else if($!==f0)f0=$,F.sendResourceListChanged()}catch{}},W9);
|