trybeacon 0.1.35 → 0.1.37
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 +10 -10
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/context/route.js +1 -1
- package/.next/server/app/api/ingest/route.js +1 -1
- package/.next/server/app/api/init/route.js +1 -1
- package/.next/server/app/api/project-meta/route.js +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +2 -2
- package/.next/server/app/docs.segments/_full.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
- package/.next/server/app/feedback.html +1 -1
- package/.next/server/app/feedback.rsc +2 -2
- package/.next/server/app/feedback.segments/_full.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +2 -2
- package/.next/server/app/help.segments/_full.segment.rsc +2 -2
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +2 -2
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +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 +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +1 -1
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +10 -10
- package/.next/server/chunks/1130.js +1 -1
- package/.next/server/chunks/1341.js +1 -1
- package/.next/server/chunks/1957.js +1 -0
- package/.next/server/chunks/249.js +1 -1
- package/.next/server/chunks/2933.js +1 -1
- package/.next/server/chunks/9213.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/4851-a062f2295be1bf51.js +1 -0
- package/.next/static/chunks/app/map/page-8a0fbf35bb338b5f.js +1 -0
- package/.next/static/chunks/app/plan/{page-af54cdc9fb6058a3.js → page-51d95294906a3249.js} +1 -1
- package/.next/static/css/4cddafb96f165148.css +1 -0
- package/.next/trace +38 -38
- package/.next/trace-build +1 -1
- package/dist/bin/doctor.js +2 -2
- package/dist/bin/hook.js +2 -2
- package/dist/bin/mcp.js +29 -29
- package/dist/bin/plan.js +2 -2
- package/dist/bin/remove.js +3 -3
- package/dist/bin/uninstall.js +2 -2
- package/dist/lib/assets.js +2 -2
- package/dist/lib/codex-install.js +2 -2
- package/dist/lib/global-install.js +2 -2
- package/package.json +1 -1
- package/.next/server/chunks/7154.js +0 -1
- package/.next/static/chunks/1551-c19a41da7732c31e.js +0 -1
- package/.next/static/chunks/app/map/page-8417d6e5dc33e7fb.js +0 -1
- package/.next/static/css/496162fa86c30a1d.css +0 -1
- /package/.next/static/{p7RuAgL_wa-K9PsrN1Js0 → W1vjncv08yTEtdbheb7cY}/_buildManifest.js +0 -0
- /package/.next/static/{p7RuAgL_wa-K9PsrN1Js0 → W1vjncv08yTEtdbheb7cY}/_ssgManifest.js +0 -0
package/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-webpack","duration":
|
|
1
|
+
[{"name":"run-webpack","duration":28980844,"timestamp":59702692,"id":14,"parentId":1,"tags":{},"startTime":1781212813494,"traceId":"cab7a44f3e29235a"},{"name":"run-typescript","duration":12471619,"timestamp":88686736,"id":3993,"parentId":1,"tags":{},"startTime":1781212842478,"traceId":"cab7a44f3e29235a"},{"name":"static-check","duration":701872,"timestamp":101244760,"id":3996,"parentId":1,"tags":{},"startTime":1781212855037,"traceId":"cab7a44f3e29235a"},{"name":"static-generation","duration":4616862,"timestamp":102573451,"id":4138,"parentId":1,"tags":{},"startTime":1781212856365,"traceId":"cab7a44f3e29235a"},{"name":"collect-build-traces","duration":13583918,"timestamp":101949653,"id":4135,"parentId":1,"tags":{},"startTime":1781212855741,"traceId":"cab7a44f3e29235a"},{"name":"telemetry-flush","duration":62,"timestamp":115537352,"id":4147,"parentId":1,"tags":{},"startTime":1781212869329,"traceId":"cab7a44f3e29235a"},{"name":"next-build","duration":55965889,"timestamp":59571536,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1781212813363,"traceId":"cab7a44f3e29235a"}]
|
package/dist/bin/doctor.js
CHANGED
|
@@ -69,9 +69,9 @@ Beacon was already initialized in this repo (\`/beacon-init\` ran at some point)
|
|
|
69
69
|
|
|
70
70
|
## What gets preserved vs replaced
|
|
71
71
|
|
|
72
|
-
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`).
|
|
72
|
+
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`). A curated architecture node (created by \`beacon_describe_feature\` or by hand) whose title matches a component in your refreshed analysis is **merged in place** \u2014 your fresh \`domain\`/\`role\`/\`plain\`/\`layer\`/\`files\` land on it, but it keeps its source, position, status, and bug flags, and no duplicate INIT node is created. Curated nodes your analysis does NOT mention survive untouched, as do hand-edited tables, custom positions, notes, and draft feature plans. So you can re-run this freely.
|
|
73
73
|
|
|
74
|
-
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
74
|
+
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist \u2014 and a renamed node no longer title-matches, so it survives as its own card. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
75
75
|
|
|
76
76
|
## How to do it
|
|
77
77
|
|
package/dist/bin/hook.js
CHANGED
|
@@ -69,9 +69,9 @@ Beacon was already initialized in this repo (\`/beacon-init\` ran at some point)
|
|
|
69
69
|
|
|
70
70
|
## What gets preserved vs replaced
|
|
71
71
|
|
|
72
|
-
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`).
|
|
72
|
+
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`). A curated architecture node (created by \`beacon_describe_feature\` or by hand) whose title matches a component in your refreshed analysis is **merged in place** \u2014 your fresh \`domain\`/\`role\`/\`plain\`/\`layer\`/\`files\` land on it, but it keeps its source, position, status, and bug flags, and no duplicate INIT node is created. Curated nodes your analysis does NOT mention survive untouched, as do hand-edited tables, custom positions, notes, and draft feature plans. So you can re-run this freely.
|
|
73
73
|
|
|
74
|
-
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
74
|
+
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist \u2014 and a renamed node no longer title-matches, so it survives as its own card. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
75
75
|
|
|
76
76
|
## How to do it
|
|
77
77
|
|
package/dist/bin/mcp.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var A9=Object.defineProperty;var
|
|
3
|
+
var A9=Object.defineProperty;var I9=($)=>$;function E9($,Q){this[$]=I9.bind(null,Q)}var a=($,Q)=>{for(var Z in Q)A9($,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:E9.bind(Q,Z)})};var r=($,Q)=>()=>($&&(Q=$($=0)),Q);var s0={};a(s0,{removeRepoAssets:()=>S9,installRefreshSkill:()=>_9,installPlanSkill:()=>k9,installInitSkill:()=>T9,installCodexRepoSkills:()=>g9,ensureWorkflowDoc:()=>x9,ensureMcp:()=>y9,auditRepo:()=>z9,REFRESH_SKILL:()=>c0,PLAN_SKILL:()=>T5,INIT_SKILL:()=>p0});import{existsSync as m,mkdirSync as K0,readFileSync as T,rmSync as B0,writeFileSync as E}from"fs";import{join as K}from"path";function T9($){let Q=K($,".claude","skills","beacon-init");K0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return E(Z,p0),Z}function _9($){let Q=K($,".claude","skills","beacon-refresh");K0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return E(Z,c0),Z}function k9($){let Q=K($,".claude","skills","beacon-plan");K0(Q,{recursive:!0});let Z=K(Q,"SKILL.md");return E(Z,T5),Z}function g9($){let Q=[];for(let Z of L9){let Y=K($,".agents","skills",Z.name);K0(Y,{recursive:!0});let X=K(Y,"SKILL.md");E(X,Z.body()),Q.push(X)}return Q}function x9($){let Q=K($,"AGENTS.md"),Z="";try{Z=T(Q,"utf8")}catch{}let Y=new RegExp(`${P0}[\\s\\S]*?${l0}`);Z=Y.test(Z)?Z.replace(Y,E5):`${Z.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
`.trimStart(),
|
|
5
|
+
${E5}
|
|
6
|
+
`.trimStart(),E(Q,Z.endsWith(`
|
|
7
7
|
`)?Z:`${Z}
|
|
8
|
-
`);let X=K($,"CLAUDE.md"),H="";try{H=
|
|
8
|
+
`);let X=K($,"CLAUDE.md"),H="";try{H=T(X,"utf8")}catch{}if(!/@AGENTS\.md/.test(H))E(X,`${H?`${H.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function y9($){let Q=K($,".mcp.json"),Z={};try{Z=JSON.parse(
|
|
12
|
-
`),{path:Q,added:!0}}function z9($){let Q=K($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(
|
|
13
|
-
`)}}catch{}let X=!1,H=K($,"AGENTS.md");try{let U=
|
|
11
|
+
`)}function y9($){let Q=K($,".mcp.json"),Z={};try{Z=JSON.parse(T(Q,"utf8"))}catch{}if(Z.mcpServers=Z.mcpServers??{},Z.mcpServers.beacon)return{path:Q,added:!1};return Z.mcpServers.beacon={command:"beacon",args:["mcp"]},E(Q,JSON.stringify(Z,null,2)+`
|
|
12
|
+
`),{path:Q,added:!0}}function z9($){let Q=K($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(T(Q,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=T(K($,"AGENTS.md"),"utf8").includes(P0)}catch{}let X=!1;try{X=/@AGENTS\.md/.test(T(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 S9($){let Q=[];for(let U of["beacon-init","beacon-refresh","beacon-db-design"]){let w=K($,".claude","skills",U);if(m(w))B0(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))B0(w,{recursive:!0,force:!0}),Q.push(`codex:${U}`)}let Z=!1,Y=K($,".mcp.json");try{let U=JSON.parse(T(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)B0(Y,{force:!0});else E(Y,JSON.stringify(U,null,2)+`
|
|
13
|
+
`)}}catch{}let X=!1,H=K($,"AGENTS.md");try{let U=T(H,"utf8"),w=new RegExp(`\\n?${P0}[\\s\\S]*?${l0}\\n?`);if(w.test(U)){let n=U.replace(w,`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
|
-
`).trimStart();
|
|
16
|
+
`).trimStart();E(H,n.endsWith(`
|
|
17
17
|
`)?n:`${n}
|
|
18
|
-
`),X=!0}}catch{}let j=!1,W=K($,"CLAUDE.md");try{let U=
|
|
18
|
+
`),X=!0}}catch{}let j=!1,W=K($,"CLAUDE.md");try{let U=T(W,"utf8"),w=U.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(w!==U){if(!w.trim())B0(W,{force:!0});else E(W,w);j=!0}}catch{}return{skillsRemoved:Q,mcpUnregistered:Z,agentsBlockRemoved:X,claudeImportRemoved:j}}var p0=`---
|
|
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
|
---
|
|
@@ -69,9 +69,9 @@ Beacon was already initialized in this repo (\`/beacon-init\` ran at some point)
|
|
|
69
69
|
|
|
70
70
|
## What gets preserved vs replaced
|
|
71
71
|
|
|
72
|
-
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`).
|
|
72
|
+
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`). A curated architecture node (created by \`beacon_describe_feature\` or by hand) whose title matches a component in your refreshed analysis is **merged in place** \u2014 your fresh \`domain\`/\`role\`/\`plain\`/\`layer\`/\`files\` land on it, but it keeps its source, position, status, and bug flags, and no duplicate INIT node is created. Curated nodes your analysis does NOT mention survive untouched, as do hand-edited tables, custom positions, notes, and draft feature plans. So you can re-run this freely.
|
|
73
73
|
|
|
74
|
-
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
74
|
+
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist \u2014 and a renamed node no longer title-matches, so it survives as its own card. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
75
75
|
|
|
76
76
|
## How to do it
|
|
77
77
|
|
|
@@ -100,7 +100,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
100
100
|
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.
|
|
101
101
|
|
|
102
102
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
103
|
-
`,
|
|
103
|
+
`,T5=`---
|
|
104
104
|
name: beacon-plan
|
|
105
105
|
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.
|
|
106
106
|
---
|
|
@@ -142,7 +142,7 @@ If it returns feedback, revise and call it again.
|
|
|
142
142
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
143
143
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
144
144
|
run \`beacon\` in this repo once.
|
|
145
|
-
`,
|
|
145
|
+
`,L9,P0="<!-- beacon:workflow:start -->",l0="<!-- beacon:workflow:end -->",E5;var d0=r(()=>{L9=[{name:"beacon-init",body:()=>p0},{name:"beacon-refresh",body:()=>c0}];E5=`${P0}
|
|
146
146
|
## Beacon \u2014 feature workflow
|
|
147
147
|
|
|
148
148
|
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:
|
|
@@ -200,18 +200,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
200
200
|
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.
|
|
201
201
|
|
|
202
202
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
203
|
-
${l0}`});import{existsSync as
|
|
204
|
-
`)}function C0($,Q){let Z=n0($);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}]}),
|
|
203
|
+
${l0}`});import{existsSync as _5,mkdirSync as o0,readFileSync as N0,rmSync as h9,writeFileSync as q0}from"fs";import{dirname as k5,join as M0}from"path";function n0($){try{return JSON.parse(N0($,"utf8"))}catch{return{}}}function L5($,Q){o0(k5($),{recursive:!0}),q0($,JSON.stringify(Q,null,2)+`
|
|
204
|
+
`)}function C0($,Q){let Z=n0($);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 v0($,Q){return(n0($).hooks?.[Q.event]??[]).some((X)=>X.hooks?.some((H)=>H.command===Q.command))}function F0($,Q){let Z=n0($),Y=Z.hooks?.[Q.event];if(!Y)return!1;let X=!1,H=Y.map((j)=>{let W=j.hooks?.length??0,U=(j.hooks??[]).filter((w)=>w.command!==Q.command);if(U.length!==W)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}
|
|
205
205
|
${Y.trim()}
|
|
206
206
|
${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()}
|
|
207
207
|
|
|
208
208
|
${X}
|
|
209
209
|
`:`${X}
|
|
210
|
-
`,o0(
|
|
210
|
+
`,o0(k5($),{recursive:!0}),q0($,H.endsWith(`
|
|
211
211
|
`)?H:`${H}
|
|
212
|
-
`)}function i($,Q){try{return N0($,"utf8").includes(Q)}catch{return!1}}function
|
|
212
|
+
`)}function i($,Q){try{return N0($,"utf8").includes(Q)}catch{return!1}}function D0($,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,`
|
|
213
213
|
|
|
214
|
-
`).trimStart();return q0($,H),!0}function
|
|
214
|
+
`).trimStart();return q0($,H),!0}function R0($,Q,Z){let Y=M0($,Q);o0(Y,{recursive:!0});let X=M0(Y,"SKILL.md");return q0(X,Z),X}function t($,Q){return _5(M0($,Q,"SKILL.md"))}function A0($,Q){let Z=M0($,Q);if(!_5(Z))return!1;return h9(Z,{recursive:!0,force:!0}),!0}var L,w0=`## Beacon (visual planning panel)
|
|
215
215
|
|
|
216
216
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
217
217
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -232,39 +232,39 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
232
232
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
233
233
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
234
234
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
235
|
-
verbatim. Do NOT implement until the tool returns approval.`;var a0=r(()=>{
|
|
235
|
+
verbatim. Do NOT implement until the tool returns approval.`;var a0=r(()=>{L=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as f9,renameSync as u9,rmSync as b9,writeFileSync as m9}from"fs";import{dirname as p9}from"path";function r0($,Q){f9(p9($),{recursive:!0});let Z=`${$}.tmp`;try{m9(Z,Q),u9(Z,$)}catch(Y){throw b9(Z,{force:!0}),Y}}var g5=()=>{};var b5={};a(b5,{setupCodexAssets:()=>d9,removeCodexMcp:()=>u5,removeCodexArtifacts:()=>n9,hasCodexMcp:()=>$5,ensureCodexMcp:()=>f5,codexMcpProblem:()=>s9,codexDetected:()=>z5,auditCodex:()=>o9,CODEX_HOOKS:()=>k0});import{readFileSync as _0}from"fs";import{homedir as c9}from"os";import{join as Q0}from"path";function x5(){return process.env.HOME||process.env.USERPROFILE||c9()}function z5(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(i0===void 0)i0=Bun.which("codex")!==null;return i0}function $0($){try{return Bun.TOML.parse($)}catch{return null}}function $5(){try{return Boolean($0(_0(p(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function s9(){let $="";try{$=_0(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 f5(){let $="",Q=!1;try{$=_0(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(`
|
|
236
236
|
`)?`
|
|
237
237
|
`:`
|
|
238
238
|
|
|
239
|
-
`,Y=$+Z+l9;if($0(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${e}`};return r0(p(),Y),{added:!0}}function u5(){let $="";try{$=
|
|
239
|
+
`,Y=$+Z+l9;if($0(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${e}`};return r0(p(),Y),{added:!0}}function u5(){let $="";try{$=_0(p(),"utf8")}catch{return{removed:!1}}let Q=$.split(`
|
|
240
240
|
`),Z=Q.indexOf(S5);if(Z===-1)return{removed:!1,skipped:$5()};let Y=Q.indexOf(h5,Z);if(Y===-1)return{removed:!1,skipped:!0};Q.splice(Z,Y-Z+1);let X=Q.join(`
|
|
241
241
|
`).replace(/\n{3,}/g,`
|
|
242
242
|
|
|
243
|
-
`).replace(/^\n+/,"");if($0(X)===null)return{removed:!1,skipped:!0};return r0(p(),X),{removed:!0}}async function d9(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let U of
|
|
243
|
+
`).replace(/^\n+/,"");if($0(X)===null)return{removed:!1,skipped:!0};return r0(p(),X),{removed:!0}}async function d9(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let U of L){if(!t(E0(),U))X.push(U);R0(E0(),U,Y[U])}let H=0;for(let U of k0)if(C0(e0(),{event:U.event,matcher:U.matcher,command:U.command}))H++;let j=i(I0(),T0);O0(I0(),T0,y5,w0);let W=f5();return{skillsAdded:X,hooksAdded:H,agentsMdBlockTouched:!j,mcp:W}}function o9(){let $={};for(let Z of L)$[Z]=t(E0(),Z);let Q={};for(let Z of k0)Q[Z.event]=v0(e0(),{event:Z.event,command:Z.command});return{detected:z5(),skills:$,hooks:Q,agentsMdBlock:i(I0(),T0),mcp:$5()}}function n9(){let $=[];for(let X of L)if(A0(E0(),X))$.push(X);let Q=0;for(let X of k0)if(F0(e0(),{event:X.event,command:X.command}))Q++;let Z=D0(I0(),T0,y5),Y=u5();return{skillsRemoved:$,hooksRemoved:Q,agentsMdBlockRemoved:Z,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var t0=()=>Q0(x5(),".codex"),e0=()=>Q0(t0(),"hooks.json"),p=()=>Q0(t0(),"config.toml"),I0=()=>Q0(t0(),"AGENTS.md"),E0=()=>Q0(x5(),".agents","skills"),T0="<!-- beacon:global:start -->",y5="<!-- beacon:global:end -->",k0,i0,S5="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",h5="# beacon:end",l9,e="add it manually: codex mcp add beacon -- beacon mcp";var m5=r(()=>{a0();g5();k0=[{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."}];l9=`${S5}
|
|
244
244
|
[mcp_servers.beacon]
|
|
245
245
|
command = "beacon"
|
|
246
246
|
args = ["mcp"]
|
|
247
247
|
${h5}
|
|
248
|
-
`});var o5={};a(o5,{provisionDb:()=>w$});import{createClient as H$}from"@libsql/client";import{drizzle as j$}from"drizzle-orm/libsql";import{migrate as U$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as W$}from"drizzle-orm/migrator";import{dirname as X5,join as G$}from"path";import{fileURLToPath as B$}from"url";async function x0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function N$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function d5($){if(!await x0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function q$($){for(let[Q,Z]of Object.entries(M$)){if(!await x0($,Q))continue;let Y=await N$($,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 w$($,Q=P$){let Z=H$({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 x0(Z,"__drizzle_migrations"),X=await x0(Z,"Node"),H=!1;if(X&&!Y){let W=W$({migrationsFolder:Q})[0];if(W)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:[W.hash,W.folderMillis]}),H=!0}let j=await d5(Z);if(await U$(j$(Z),{migrationsFolder:Q}),await d5(Z)>j)H=!0;return await q$(Z),{migrated:H}}finally{Z.close()}}var K$,P$,M$;var n5=r(async()=>{K$=X5(X5(X5(B$(import.meta.url)))),P$=process.env.BEACON_MIGRATIONS_DIR||G$(K$,"drizzle"),M$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});a0();import{existsSync as a9}from"fs";import{homedir as r9}from"os";import{join as k0}from"path";function i9(){return process.env.HOME||process.env.USERPROFILE||r9()}var g0=()=>k0(i9(),".claude"),Q5=()=>k0(g0(),"skills"),Z5=()=>k0(g0(),"settings.json"),J5=()=>k0(g0(),"CLAUDE.md"),Y5="<!-- beacon:global:start -->",p5="<!-- beacon:global:end -->";var t9=w0,V5=[{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 e9($,Q){return D0(Q5(),$,Q)}function c5($){return t(Q5(),$)}function $$($){return A0(Q5(),$)}function Q$($){return C0(Z5(),$)}function Z$($){return v0(Z5(),$)}function J$($){return O0(Z5(),$)}function Y$($){F0(J5(),Y5,p5,$)}function l5(){return i(J5(),Y5)}function V$(){return R0(J5(),Y5,p5)}function kQ(){let $={};for(let Z of k)$[Z]=c5(Z);let Q={};for(let Z of V5)Q[Z.event]=Z$({event:Z.event,command:Z.command});return{homeExists:a9(g0()),skills:$,hooks:Q,claudeMdBlock:l5()}}async function X$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let W of k){if(!c5(W))X.push(W);e9(W,Y[W])}let H=0;for(let W of V5)if(Q$({event:W.event,matcher:W.matcher,command:W.command}))H++;let j=l5();return Y$(t9),{skillsAdded:X,hooksAdded:H,claudeMdBlockTouched:!j}}async function s5(){let $;try{$={ok:!0,...await X$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (m5(),b5));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 gQ(){let $=[];for(let Y of k)if($$(Y))$.push(Y);let Q=0;for(let Y of V5)if(J$(Y))Q++;let Z=V$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as C$}from"async_hooks";import{spawnSync as v$}from"child_process";import{createHash as O$}from"crypto";import{existsSync as r5,mkdirSync as Z0,readFileSync as j5,writeFileSync as U5}from"fs";import{homedir as i5}from"os";import{basename as F$,join as g,parse as R$,resolve as a5}from"path";function z(){return process.env.BEACON_HOME||g(i5(),".beacon")}function W5(){return g(z(),"workspaces.json")}function c($){return O$("sha256").update($).digest("hex").slice(0,12)}function t5($=process.cwd()){let Q=v$("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=a5($);return Q!==a5(i5())&&Q!==R$(Q).root}function e5(){return g(z(),"deleted.json")}function G5(){try{let $=JSON.parse(j5(e5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function $9($){Z0(z(),{recursive:!0}),U5(e5(),JSON.stringify($,null,2))}function z0($){return G5().includes($)}function dQ($){let Q=G5();if(!Q.includes($))$9([...Q,$])}function D$($){let Q=G5();if(Q.includes($))$9(Q.filter((Z)=>Z!==$))}function S0($){return g(z(),$)}function B5($){return`file:${g(S0($),"db.sqlite")}`}function J0(){try{let $=JSON.parse(j5(W5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function K5($){Z0(z(),{recursive:!0}),U5(W5(),JSON.stringify($,null,2))}function A$(){return J0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function y($){return J0().find((Q)=>Q.id===$)??null}function h0($,Q,Z=new Date().toISOString()){if(!y0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=c($);if(z0(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||F$($),lastOpenedAt:Z},W=[j,...X.filter((U)=>U.id!==Y)];return Z0(S0(Y),{recursive:!0}),K5(W),j}function oQ($,Q){return D$(c($)),h0($,Q)}function nQ($,Q=new Date().toISOString()){let Z=J0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,K5(Z)}function aQ($){if(K5(J0().filter((Q)=>Q.id!==$)),Y0()===$)E$(A$()[0]?.id??null)}function Q9(){return g(z(),"active")}function Y0(){try{return j5(Q9(),"utf8").trim()||null}catch{return null}}function E$($){Z0(z(),{recursive:!0}),U5(Q9(),$??"")}function rQ(){let $=Y0();return $?y($):null}function iQ(){let $=M5()??Y0();return $?y($):null}function tQ($){return y($)?.path??null}function eQ(){return r5(W5())}var Z9="beacon_ws";function J9($,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 $Z($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=J9($,Z9);if(Z&&y(Z))return Z;return null}var P5="x-beacon-workspace-path";async function QZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=$.headers.get(P5);if(Z&&y0(Z)&&!z0(c(Z))&&(!Q||c(Z)===Q)){let X=h0(Z);return await N5(X.id),X.id}let Y=J9($,Z9);if(Y&&y(Y))return Y;return null}var Y9=new C$;function I$($,Q){return $?Y9.run($,Q):Q()}function M5(){return Y9.getStore()??null}var H5=new Set;function ZZ($){H5.delete(g(S0($),"db.sqlite"))}async function N5($){let Q=S0($),Z=g(Q,"db.sqlite"),Y=r5(Z);if(Y&&H5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Z0(Q,{recursive:!0});let{provisionDb:X}=await n5().then(() => o5),H=await X(B5($));return H5.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 GQ,ResourceTemplate as D5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as BQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var L$=new Set(["GET","HEAD","OPTIONS"]);function V9($){return L$.has($.trim().toUpperCase())?"read":"write"}var T$=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()})),X9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(T$).default([])}),H9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),j9=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??V9($.method)}))})),HZ=B.object({tables:B.array(X9).default([]),relations:B.array(H9).default([]),endpoints:B.array(j9).default([])});import{z as D}from"zod";import{and as _Z,eq as kZ,inArray as gZ}from"drizzle-orm";import{drizzle as e$}from"drizzle-orm/libsql";import{createClient as $Q}from"@libsql/client";var q5={};a(q5,{tag:()=>l,syncState:()=>y$,projectMeta:()=>S$,note:()=>g$,nodeTags:()=>S,nodeFile:()=>V0,node:()=>P,endpointTable:()=>f,endpoint:()=>s,edge:()=>x,draftTable:()=>A,draftRelation:()=>u,draftColumn:()=>j0,dbTable:()=>v,dbRelation:()=>h,dbColumn:()=>H0,codeFileEdge:()=>b,codeFile:()=>T,bugFlag:()=>X0,boardAnnotation:()=>x$,appSetting:()=>z$});import{sqliteTable as q,index as N,foreignKey as _$,text as V,integer as G,real as R,uniqueIndex as _,primaryKey as k$}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(),layer:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:G().default(2).notNull(),progress:G().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:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({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),_$(()=>({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)]),x=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)]),g$=q("Note",{id:V().primaryKey().$defaultFn(()=>O()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:R().default(0).notNull(),pinned:G({mode:"boolean"}).default(!1).notNull(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Note_updatedAt_idx").on($.updatedAt)]),x$=q("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>O()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:R(),y:R(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({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:G({mode:"timestamp_ms"}),createdAt:G({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:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({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:G({mode:"boolean"}).default(!1).notNull(),isFk:G({mode:"boolean"}).default(!1).notNull(),nullable:G({mode:"boolean"}).default(!0).notNull(),note:V(),ord:G().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:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({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:G({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:G({mode:"boolean"}).default(!1).notNull(),isFk:G({mode:"boolean"}).default(!1).notNull(),nullable:G({mode:"boolean"}).default(!0).notNull(),note:V(),ord:G().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:G(),inDegree:G().default(0).notNull(),outDegree:G().default(0).notNull(),updatedAt:G({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:G({mode:"boolean"}).default(!1).notNull()},($)=>[N("CodeFileEdge_circular_idx").on($.circular),N("CodeFileEdge_toPath_idx").on($.toPath),N("CodeFileEdge_fromPath_idx").on($.fromPath),k$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),y$=q("SyncState",{id:V().primaryKey().default("singleton"),version:G().default(0).notNull(),codeGraphSyncedAt:G({mode:"timestamp_ms"}),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),z$=q("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),S$=q("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),hasFrontend:G({mode:"boolean"}),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var w5={};a(w5,{tagRelations:()=>b$,nodeTagsRelations:()=>m$,nodeRelations:()=>h$,nodeFileRelations:()=>f$,endpointTableRelations:()=>o$,endpointRelations:()=>d$,edgeRelations:()=>p$,draftTableRelations:()=>n$,draftRelationRelations:()=>r$,draftColumnRelations:()=>a$,dbTableRelations:()=>c$,dbRelationRelations:()=>s$,dbColumnRelations:()=>l$,codeFileRelations:()=>i$,codeFileEdgeRelations:()=>t$,bugFlagRelations:()=>u$});import{relations as C}from"drizzle-orm";var h$=C(P,({one:$,many:Q})=>({files:Q(V0),bugFlags:Q(X0),nodeTags:Q(S),edgesOut:Q(x,{relationName:"EdgeFrom"}),edgesIn:Q(x,{relationName:"EdgeTo"}),parent:$(P,{fields:[P.parentId],references:[P.id],relationName:"NodeTree"}),children:Q(P,{relationName:"NodeTree"})})),f$=C(V0,({one:$})=>({node:$(P,{fields:[V0.nodeId],references:[P.id]})})),u$=C(X0,({one:$})=>({node:$(P,{fields:[X0.nodeId],references:[P.id]})})),b$=C(l,({many:$})=>({nodeTags:$(S)})),m$=C(S,({one:$})=>({node:$(P,{fields:[S.a],references:[P.id]}),tag:$(l,{fields:[S.b],references:[l.id]})})),p$=C(x,({one:$})=>({from:$(P,{fields:[x.fromId],references:[P.id],relationName:"EdgeFrom"}),to:$(P,{fields:[x.toId],references:[P.id],relationName:"EdgeTo"})})),c$=C(v,({many:$})=>({columns:$(H0),fksOut:$(h,{relationName:"FkFrom"}),fksIn:$(h,{relationName:"FkTo"}),usages:$(f)})),l$=C(H0,({one:$})=>({table:$(v,{fields:[H0.tableId],references:[v.id]})})),s$=C(h,({one:$})=>({fromTable:$(v,{fields:[h.fromTableId],references:[v.id],relationName:"FkFrom"}),toTable:$(v,{fields:[h.toTableId],references:[v.id],relationName:"FkTo"})})),d$=C(s,({many:$})=>({tables:$(f)})),o$=C(f,({one:$})=>({endpoint:$(s,{fields:[f.endpointId],references:[s.id]}),table:$(v,{fields:[f.tableId],references:[v.id]})})),n$=C(A,({many:$})=>({columns:$(j0),fksOut:$(u,{relationName:"DraftFkFrom"}),fksIn:$(u,{relationName:"DraftFkTo"})})),a$=C(j0,({one:$})=>({table:$(A,{fields:[j0.tableId],references:[A.id]})})),r$=C(u,({one:$})=>({fromTable:$(A,{fields:[u.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[u.toTableId],references:[A.id],relationName:"DraftFkTo"})})),i$=C(T,({many:$})=>({edgesOut:$(b,{relationName:"CFEFrom"}),edgesIn:$(b,{relationName:"CFETo"})})),t$=C(b,({one:$})=>({fromFile:$(T,{fields:[b.fromPath],references:[T.path],relationName:"CFEFrom"}),toFile:$(T,{fields:[b.toPath],references:[T.path],relationName:"CFETo"})}));var QQ={...q5,...w5};function ZQ(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var JQ=ZQ();function U9($){let Q=$Q({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),e$(Q,{schema:QQ})}var v5=globalThis,C5=v5.dzDefault??U9(JQ);v5.dzDefault=C5;var f0=v5.dzByUrl??=new Map;function YQ($){let Q=f0.get($);if(!Q)Q=U9($),f0.set($,Q);return Q}function NZ($){let Q=f0.get($);f0.delete($);try{Q?.$client?.close?.()}catch{}}function VQ(){if(process.env.BEACON_REPO)return C5;let $=M5()??Y0();if(!$)return C5;return YQ(B5($))}var XQ=new Proxy({},{get($,Q){let Z=VQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});var HQ=["frontend","backend","fullstack"],jQ={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function u0($){let Q=($??"").trim().toLowerCase();if(!Q)return null;if(HQ.includes(Q))return Q;return jQ[Q]??null}import{forceCenter as OZ,forceCollide as FZ,forceLink as RZ,forceManyBody as DZ,forceSimulation as AZ}from"d3-force";var W9=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(),layer:D.string().nullish(),dependsOn:D.array(D.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,layer:X,...H})=>({...H,cluster:H.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE",layer:u0(X)})),hZ=D.object({features:D.array(W9).default([])});var UQ=/(\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 G9($){return!!$&&UQ.test($)}function WQ($){return $.cluster??$.category??$.domain??null}function B9($,Q){let Z=Q?.requireLayer??!1,Y=$.map((H)=>{let j=[],W=WQ(H);if(!W||!W.trim())j.push("category");if(H.priority==null)j.push("priority");if(Z&&!u0(H.layer))j.push("layer");return j.length?` \u2022 "${H.title?.trim()||"(untitled)"}" \u2014 missing ${j.join(" + ")}`:null}).filter((H)=>H!==null);if(Y.length===0)return null;let X=Z?" This workspace has a frontend surface, so every feature must also carry `layer`: "+'"frontend" | "backend" | "fullstack" \u2014 which side of the stack the work lands on.':"";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."+X+` Missing:
|
|
248
|
+
`});var o5={};a(o5,{provisionDb:()=>w$});import{createClient as H$}from"@libsql/client";import{drizzle as j$}from"drizzle-orm/libsql";import{migrate as U$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as W$}from"drizzle-orm/migrator";import{dirname as X5,join as G$}from"path";import{fileURLToPath as B$}from"url";async function x0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function N$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function d5($){if(!await x0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function q$($){for(let[Q,Z]of Object.entries(M$)){if(!await x0($,Q))continue;let Y=await N$($,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 w$($,Q=P$){let Z=H$({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 x0(Z,"__drizzle_migrations"),X=await x0(Z,"Node"),H=!1;if(X&&!Y){let W=W$({migrationsFolder:Q})[0];if(W)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:[W.hash,W.folderMillis]}),H=!0}let j=await d5(Z);if(await U$(j$(Z),{migrationsFolder:Q}),await d5(Z)>j)H=!0;return await q$(Z),{migrated:H}}finally{Z.close()}}var K$,P$,M$;var n5=r(async()=>{K$=X5(X5(X5(B$(import.meta.url)))),P$=process.env.BEACON_MIGRATIONS_DIR||G$(K$,"drizzle"),M$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});a0();import{existsSync as a9}from"fs";import{homedir as r9}from"os";import{join as L0}from"path";function i9(){return process.env.HOME||process.env.USERPROFILE||r9()}var g0=()=>L0(i9(),".claude"),Q5=()=>L0(g0(),"skills"),Z5=()=>L0(g0(),"settings.json"),J5=()=>L0(g0(),"CLAUDE.md"),Y5="<!-- beacon:global:start -->",p5="<!-- beacon:global:end -->";var t9=w0,V5=[{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 e9($,Q){return R0(Q5(),$,Q)}function c5($){return t(Q5(),$)}function $$($){return A0(Q5(),$)}function Q$($){return C0(Z5(),$)}function Z$($){return v0(Z5(),$)}function J$($){return F0(Z5(),$)}function Y$($){O0(J5(),Y5,p5,$)}function l5(){return i(J5(),Y5)}function V$(){return D0(J5(),Y5,p5)}function LQ(){let $={};for(let Z of L)$[Z]=c5(Z);let Q={};for(let Z of V5)Q[Z.event]=Z$({event:Z.event,command:Z.command});return{homeExists:a9(g0()),skills:$,hooks:Q,claudeMdBlock:l5()}}async function X$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let W of L){if(!c5(W))X.push(W);e9(W,Y[W])}let H=0;for(let W of V5)if(Q$({event:W.event,matcher:W.matcher,command:W.command}))H++;let j=l5();return Y$(t9),{skillsAdded:X,hooksAdded:H,claudeMdBlockTouched:!j}}async function s5(){let $;try{$={ok:!0,...await X$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (m5(),b5));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 gQ(){let $=[];for(let Y of L)if($$(Y))$.push(Y);let Q=0;for(let Y of V5)if(J$(Y))Q++;let Z=V$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as C$}from"async_hooks";import{spawnSync as v$}from"child_process";import{createHash as F$}from"crypto";import{existsSync as r5,mkdirSync as Z0,readFileSync as j5,writeFileSync as U5}from"fs";import{homedir as i5}from"os";import{basename as O$,join as g,parse as D$,resolve as a5}from"path";function z(){return process.env.BEACON_HOME||g(i5(),".beacon")}function W5(){return g(z(),"workspaces.json")}function c($){return F$("sha256").update($).digest("hex").slice(0,12)}function t5($=process.cwd()){let Q=v$("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=a5($);return Q!==a5(i5())&&Q!==D$(Q).root}function e5(){return g(z(),"deleted.json")}function G5(){try{let $=JSON.parse(j5(e5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function $9($){Z0(z(),{recursive:!0}),U5(e5(),JSON.stringify($,null,2))}function z0($){return G5().includes($)}function dQ($){let Q=G5();if(!Q.includes($))$9([...Q,$])}function R$($){let Q=G5();if(Q.includes($))$9(Q.filter((Z)=>Z!==$))}function S0($){return g(z(),$)}function B5($){return`file:${g(S0($),"db.sqlite")}`}function J0(){try{let $=JSON.parse(j5(W5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function K5($){Z0(z(),{recursive:!0}),U5(W5(),JSON.stringify($,null,2))}function A$(){return J0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function y($){return J0().find((Q)=>Q.id===$)??null}function h0($,Q,Z=new Date().toISOString()){if(!y0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=c($);if(z0(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||O$($),lastOpenedAt:Z},W=[j,...X.filter((U)=>U.id!==Y)];return Z0(S0(Y),{recursive:!0}),K5(W),j}function oQ($,Q){return R$(c($)),h0($,Q)}function nQ($,Q=new Date().toISOString()){let Z=J0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,K5(Z)}function aQ($){if(K5(J0().filter((Q)=>Q.id!==$)),Y0()===$)I$(A$()[0]?.id??null)}function Q9(){return g(z(),"active")}function Y0(){try{return j5(Q9(),"utf8").trim()||null}catch{return null}}function I$($){Z0(z(),{recursive:!0}),U5(Q9(),$??"")}function rQ(){let $=Y0();return $?y($):null}function iQ(){let $=M5()??Y0();return $?y($):null}function tQ($){return y($)?.path??null}function eQ(){return r5(W5())}var Z9="beacon_ws";function J9($,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 $Z($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=J9($,Z9);if(Z&&y(Z))return Z;return null}var P5="x-beacon-workspace-path";async function QZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=$.headers.get(P5);if(Z&&y0(Z)&&!z0(c(Z))&&(!Q||c(Z)===Q)){let X=h0(Z);return await N5(X.id),X.id}let Y=J9($,Z9);if(Y&&y(Y))return Y;return null}var Y9=new C$;function E$($,Q){return $?Y9.run($,Q):Q()}function M5(){return Y9.getStore()??null}var H5=new Set;function ZZ($){H5.delete(g(S0($),"db.sqlite"))}async function N5($){let Q=S0($),Z=g(Q,"db.sqlite"),Y=r5(Z);if(Y&&H5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Z0(Q,{recursive:!0});let{provisionDb:X}=await n5().then(() => o5),H=await X(B5($));return H5.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 GQ,ResourceTemplate as R5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as BQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var T$=new Set(["GET","HEAD","OPTIONS"]);function V9($){return T$.has($.trim().toUpperCase())?"read":"write"}var _$=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()})),X9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(_$).default([])}),H9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),j9=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??V9($.method)}))})),HZ=B.object({tables:B.array(X9).default([]),relations:B.array(H9).default([]),endpoints:B.array(j9).default([])});import{z as R}from"zod";import{and as kZ,eq as LZ,inArray as gZ}from"drizzle-orm";import{drizzle as e$}from"drizzle-orm/libsql";import{createClient as $Q}from"@libsql/client";var q5={};a(q5,{tag:()=>l,syncState:()=>y$,projectMeta:()=>S$,note:()=>g$,nodeTags:()=>S,nodeFile:()=>V0,node:()=>P,endpointTable:()=>f,endpoint:()=>s,edge:()=>x,draftTable:()=>A,draftRelation:()=>u,draftColumn:()=>j0,dbTable:()=>v,dbRelation:()=>h,dbColumn:()=>H0,codeFileEdge:()=>b,codeFile:()=>_,bugFlag:()=>X0,boardAnnotation:()=>x$,appSetting:()=>z$});import{sqliteTable as q,index as N,foreignKey as k$,text as V,integer as G,real as D,uniqueIndex as k,primaryKey as L$}from"drizzle-orm/sqlite-core";import{createId as F}from"@paralleldrive/cuid2";var P=q("Node",{id:V().primaryKey().$defaultFn(()=>F()),view:V().notNull(),kind:V().default("FEATURE").notNull(),cluster:V(),layer:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:G().default(2).notNull(),progress:G().default(0).notNull(),x:D().default(0).notNull(),y:D().default(0).notNull(),sourceRef:V(),externalId:V(),source:V().default("MANUAL").notNull(),planId:V(),parentId:V(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({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),k$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),V0=q("NodeFile",{id:V().primaryKey().$defaultFn(()=>F()),nodeId:V().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),path:V().notNull()},($)=>[k("NodeFile_nodeId_path_key").on($.nodeId,$.path),N("NodeFile_nodeId_idx").on($.nodeId)]),l=q("Tag",{id:V().primaryKey().$defaultFn(()=>F()),label:V().notNull(),color:V()},($)=>[k("Tag_label_key").on($.label)]),x=q("Edge",{id:V().primaryKey().$defaultFn(()=>F()),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()},($)=>[k("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"})},($)=>[k("_NodeTags_AB_unique").on($.a,$.b),N("_NodeTags_B_index").on($.b)]),g$=q("Note",{id:V().primaryKey().$defaultFn(()=>F()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:D().default(0).notNull(),pinned:G({mode:"boolean"}).default(!1).notNull(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Note_updatedAt_idx").on($.updatedAt)]),x$=q("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>F()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:D(),y:D(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("BoardAnnotation_target_idx").on($.targetId)]),X0=q("BugFlag",{id:V().primaryKey().$defaultFn(()=>F()),nodeId:V().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),by:V().notNull(),note:V().notNull(),resolvedAt:G({mode:"timestamp_ms"}),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[N("BugFlag_nodeId_idx").on($.nodeId)]),v=q("DbTable",{id:V().primaryKey().$defaultFn(()=>F()),name:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:D().default(0).notNull(),y:D().default(0).notNull(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("DbTable_domain_idx").on($.domain),k("DbTable_name_key").on($.name)]),H0=q("DbColumn",{id:V().primaryKey().$defaultFn(()=>F()),tableId:V().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:G({mode:"boolean"}).default(!1).notNull(),isFk:G({mode:"boolean"}).default(!1).notNull(),nullable:G({mode:"boolean"}).default(!0).notNull(),note:V(),ord:G().default(0).notNull()},($)=>[k("DbColumn_tableId_name_key").on($.tableId,$.name),N("DbColumn_tableId_idx").on($.tableId)]),h=q("DbRelation",{id:V().primaryKey().$defaultFn(()=>F()),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(()=>F()),method:V().notNull(),path:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:D().default(0).notNull(),y:D().default(0).notNull(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("Endpoint_method_path_key").on($.method,$.path),N("Endpoint_domain_idx").on($.domain)]),f=q("EndpointTable",{id:V().primaryKey().$defaultFn(()=>F()),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()},($)=>[k("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),N("EndpointTable_tableId_idx").on($.tableId)]),A=q("DraftTable",{id:V().primaryKey().$defaultFn(()=>F()),name:V().notNull(),domain:V(),description:V(),x:D().default(0).notNull(),y:D().default(0).notNull(),createdAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[k("DraftTable_name_key").on($.name)]),j0=q("DraftColumn",{id:V().primaryKey().$defaultFn(()=>F()),tableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:G({mode:"boolean"}).default(!1).notNull(),isFk:G({mode:"boolean"}).default(!1).notNull(),nullable:G({mode:"boolean"}).default(!0).notNull(),note:V(),ord:G().default(0).notNull()},($)=>[N("DraftColumn_tableId_idx").on($.tableId)]),u=q("DraftRelation",{id:V().primaryKey().$defaultFn(()=>F()),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)]),_=q("CodeFile",{path:V().primaryKey(),root:V(),lang:V(),x:D().default(0).notNull(),y:D().default(0).notNull(),mtimeMs:D(),size:G(),inDegree:G().default(0).notNull(),outDegree:G().default(0).notNull(),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),b=q("CodeFileEdge",{fromPath:V().notNull().references(()=>_.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:V().notNull().references(()=>_.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:G({mode:"boolean"}).default(!1).notNull()},($)=>[N("CodeFileEdge_circular_idx").on($.circular),N("CodeFileEdge_toPath_idx").on($.toPath),N("CodeFileEdge_fromPath_idx").on($.fromPath),L$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),y$=q("SyncState",{id:V().primaryKey().default("singleton"),version:G().default(0).notNull(),codeGraphSyncedAt:G({mode:"timestamp_ms"}),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),z$=q("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),S$=q("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),hasFrontend:G({mode:"boolean"}),updatedAt:G({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var w5={};a(w5,{tagRelations:()=>b$,nodeTagsRelations:()=>m$,nodeRelations:()=>h$,nodeFileRelations:()=>f$,endpointTableRelations:()=>o$,endpointRelations:()=>d$,edgeRelations:()=>p$,draftTableRelations:()=>n$,draftRelationRelations:()=>r$,draftColumnRelations:()=>a$,dbTableRelations:()=>c$,dbRelationRelations:()=>s$,dbColumnRelations:()=>l$,codeFileRelations:()=>i$,codeFileEdgeRelations:()=>t$,bugFlagRelations:()=>u$});import{relations as C}from"drizzle-orm";var h$=C(P,({one:$,many:Q})=>({files:Q(V0),bugFlags:Q(X0),nodeTags:Q(S),edgesOut:Q(x,{relationName:"EdgeFrom"}),edgesIn:Q(x,{relationName:"EdgeTo"}),parent:$(P,{fields:[P.parentId],references:[P.id],relationName:"NodeTree"}),children:Q(P,{relationName:"NodeTree"})})),f$=C(V0,({one:$})=>({node:$(P,{fields:[V0.nodeId],references:[P.id]})})),u$=C(X0,({one:$})=>({node:$(P,{fields:[X0.nodeId],references:[P.id]})})),b$=C(l,({many:$})=>({nodeTags:$(S)})),m$=C(S,({one:$})=>({node:$(P,{fields:[S.a],references:[P.id]}),tag:$(l,{fields:[S.b],references:[l.id]})})),p$=C(x,({one:$})=>({from:$(P,{fields:[x.fromId],references:[P.id],relationName:"EdgeFrom"}),to:$(P,{fields:[x.toId],references:[P.id],relationName:"EdgeTo"})})),c$=C(v,({many:$})=>({columns:$(H0),fksOut:$(h,{relationName:"FkFrom"}),fksIn:$(h,{relationName:"FkTo"}),usages:$(f)})),l$=C(H0,({one:$})=>({table:$(v,{fields:[H0.tableId],references:[v.id]})})),s$=C(h,({one:$})=>({fromTable:$(v,{fields:[h.fromTableId],references:[v.id],relationName:"FkFrom"}),toTable:$(v,{fields:[h.toTableId],references:[v.id],relationName:"FkTo"})})),d$=C(s,({many:$})=>({tables:$(f)})),o$=C(f,({one:$})=>({endpoint:$(s,{fields:[f.endpointId],references:[s.id]}),table:$(v,{fields:[f.tableId],references:[v.id]})})),n$=C(A,({many:$})=>({columns:$(j0),fksOut:$(u,{relationName:"DraftFkFrom"}),fksIn:$(u,{relationName:"DraftFkTo"})})),a$=C(j0,({one:$})=>({table:$(A,{fields:[j0.tableId],references:[A.id]})})),r$=C(u,({one:$})=>({fromTable:$(A,{fields:[u.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[u.toTableId],references:[A.id],relationName:"DraftFkTo"})})),i$=C(_,({many:$})=>({edgesOut:$(b,{relationName:"CFEFrom"}),edgesIn:$(b,{relationName:"CFETo"})})),t$=C(b,({one:$})=>({fromFile:$(_,{fields:[b.fromPath],references:[_.path],relationName:"CFEFrom"}),toFile:$(_,{fields:[b.toPath],references:[_.path],relationName:"CFETo"})}));var QQ={...q5,...w5};function ZQ(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var JQ=ZQ();function U9($){let Q=$Q({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),e$(Q,{schema:QQ})}var v5=globalThis,C5=v5.dzDefault??U9(JQ);v5.dzDefault=C5;var f0=v5.dzByUrl??=new Map;function YQ($){let Q=f0.get($);if(!Q)Q=U9($),f0.set($,Q);return Q}function NZ($){let Q=f0.get($);f0.delete($);try{Q?.$client?.close?.()}catch{}}function VQ(){if(process.env.BEACON_REPO)return C5;let $=M5()??Y0();if(!$)return C5;return YQ(B5($))}var XQ=new Proxy({},{get($,Q){let Z=VQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});var HQ=["frontend","backend","fullstack"],jQ={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function u0($){let Q=($??"").trim().toLowerCase();if(!Q)return null;if(HQ.includes(Q))return Q;return jQ[Q]??null}import{forceCenter as FZ,forceCollide as OZ,forceLink as DZ,forceManyBody as RZ,forceSimulation as AZ}from"d3-force";var W9=R.object({title:R.string().trim().min(1),role:R.string().nullish(),plain:R.string().nullish(),cluster:R.string().nullish(),category:R.string().nullish(),domain:R.string().nullish(),priority:R.number().nullish(),kind:R.string().nullish(),layer:R.string().nullish(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,layer:X,...H})=>({...H,cluster:H.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE",layer:u0(X)})),hZ=R.object({features:R.array(W9).default([])});var UQ=/(\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 G9($){return!!$&&UQ.test($)}function WQ($){return $.cluster??$.category??$.domain??null}function B9($,Q){let Z=Q?.requireLayer??!1,Y=$.map((H)=>{let j=[],W=WQ(H);if(!W||!W.trim())j.push("category");if(H.priority==null)j.push("priority");if(Z&&!u0(H.layer))j.push("layer");return j.length?` \u2022 "${H.title?.trim()||"(untitled)"}" \u2014 missing ${j.join(" + ")}`:null}).filter((H)=>H!==null);if(Y.length===0)return null;let X=Z?" This workspace has a frontend surface, so every feature must also carry `layer`: "+'"frontend" | "backend" | "fullstack" \u2014 which side of the stack the work lands on.':"";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."+X+` Missing:
|
|
249
249
|
`+Y.join(`
|
|
250
|
-
`)+"\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)."+(Z?" Set `layer` on EVERY feature too.":"")+" Don't rely on defaults."}function
|
|
250
|
+
`)+"\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)."+(Z?" Set `layer` on EVERY feature too.":"")+" Don't rely on defaults."}function F5($){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`
|
|
251
251
|
|
|
252
252
|
This plan created these roadmap feature(s):
|
|
253
253
|
`+Q.join(`
|
|
254
|
-
`)+"\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
|
|
255
|
-
`)}await s5();var A5=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,d=t5(),W0=c(d);if(!y0(d))console.error(`[beacon mcp] not registering ${d} \u2014 home/non-repo dir.`);else if(z0(W0))console.error(`[beacon mcp] not registering ${d} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{h0(d);let $=await N5(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(P5,d);let Y=await fetch(`${A5}${$}`,{...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 E5($){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 GQ({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."),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack a NEW feature lands on. REQUIRED for a new top-level feature when the workspace has a frontend; a feature nested under a `front` inherits the parent's. Omit in pure-backend repos.")}},async({title:$,id:Q,front:Z,detail:Y,category:X,kind:H,layer:j})=>{try{let W=await o("/api/map/start",{title:$,id:Q,front:Z,detail:Y,category:X,kind:H,layer:j});return{content:[{type:"text",text:JSON.stringify(W)}]}}catch(W){return E5(W)}});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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the sub-task lands on; defaults to the parent's layer")})).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 E5(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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on (only when the repo has a frontend); omitting it on an update keeps the prior value"),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: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 j=$?.length?{features:$}:{description:Q,files:Z,id:Y,title:X,architecture:H},W=await o("/api/map/describe",j);return{content:[{type:"text",text:JSON.stringify(W)}]}});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"),hasFrontend:J.boolean().optional().describe("Whether this repo has a frontend surface (UI code) \u2014 you just read the repo, so you know. Gates the per-item `layer` requirement + the layer UI on the boards. Set it explicitly (true or false); omitting leaves Beacon to detect it from the code graph."),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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on \u2014 set it when hasFrontend is true"),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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the item lands on \u2014 set it when hasFrontend is true")})).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 and, when the workspace has a frontend, `layer` (frontend | backend | fullstack). The tool REJECTS a plan whose features omit any required field, so set them 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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack the work lands on. REQUIRED on every feature when the workspace has a frontend (the tool rejects the plan otherwise); omit in pure-backend repos.")})).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((G0)=>setTimeout(G0,M)),j=(M)=>({content:[{type:"text",text:M}]}),W=(Z?.length??0)>0,U=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
|
|
254
|
+
`)+"\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 O5=1500,nZ=345600000,D5=1800000,K9=3000;function U0($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function P9($){return`${U0($.title)}-${$.id.slice(-6)}`}function M9($){return{resources:$.map((Q)=>({uri:`note://${P9(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function N9($,Q){return $.find((Z)=>P9(Z)===Q)}function q9($){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(`
|
|
255
|
+
`)}await s5();var A5=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,d=t5(),W0=c(d);if(!y0(d))console.error(`[beacon mcp] not registering ${d} \u2014 home/non-repo dir.`);else if(z0(W0))console.error(`[beacon mcp] not registering ${d} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{h0(d);let $=await N5(W0);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function I($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",W0),Z.set(P5,d);let Y=await fetch(`${A5}${$}`,{...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 I($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function I5($){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 O=new GQ({name:"beacon",version:"0.1.0"});O.registerTool("beacon_map",{description:"List existing features on the roadmap. Call before starting work."},async()=>{let $=await I("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});O.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."),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack a NEW feature lands on. REQUIRED for a new top-level feature when the workspace has a frontend; a feature nested under a `front` inherits the parent's. Omit in pure-backend repos.")}},async({title:$,id:Q,front:Z,detail:Y,category:X,kind:H,layer:j})=>{try{let W=await o("/api/map/start",{title:$,id:Q,front:Z,detail:Y,category:X,kind:H,layer:j});return{content:[{type:"text",text:JSON.stringify(W)}]}}catch(W){return I5(W)}});O.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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the sub-task lands on; defaults to the parent's layer")})).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 I5(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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on (only when the repo has a frontend); omitting it on an update keeps the prior value"),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");O.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 j=$?.length?{features:$}:{description:Q,files:Z,id:Y,title:X,architecture:H},W=await o("/api/map/describe",j);return{content:[{type:"text",text:JSON.stringify(W)}]}});O.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"),hasFrontend:J.boolean().optional().describe("Whether this repo has a frontend surface (UI code) \u2014 you just read the repo, so you know. Gates the per-item `layer` requirement + the layer UI on the boards. Set it explicitly (true or false); omitting leaves Beacon to detect it from the code graph."),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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on \u2014 set it when hasFrontend is true"),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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the item lands on \u2014 set it when hasFrontend is true")})).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)}]}});O.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 I(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});O.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 I(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});O.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 I(`/api/entities?kind=${$}`);return{content:[{type:"text",text:JSON.stringify(Q)}]}});O.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 and, when the workspace has a frontend, `layer` (frontend | backend | fullstack). The tool REJECTS a plan whose features omit any required field, so set them 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"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack the work lands on. REQUIRED on every feature when the workspace has a frontend (the tool rejects the plan otherwise); omit in pure-backend repos.")})).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((G0)=>setTimeout(G0,M)),j=(M)=>({content:[{type:"text",text:M}]}),W=(Z?.length??0)>0,U=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
|
|
256
256
|
`),w=(X?.length??0)>0||G9(`${$}
|
|
257
|
-
${U}`);if(!W&&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=await
|
|
257
|
+
${U}`);if(!W&&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=await I("/api/project-meta").then((R9)=>!!R9?.hasFrontend).catch(()=>!1),G0=B9(Q,{requireLayer:M});if(G0)return j(G0)}let n=(Z?.length??0)+(X?.length??0)>0;try{await o("/api/plan",{description:$,draft:n?{tables:Z??[],relations:Y??[],endpoints:X??[]}:void 0,features:Q?.length?Q:void 0})}catch(M){return I5(M)}await fetch(`${A5}/api/workspace/activate?id=${W0}`).catch(()=>{});let D9=Date.now()+D5;while(Date.now()<D9){await H(O5);let M=await I("/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:
|
|
258
258
|
|
|
259
259
|
`+M.feedback);if(M.kind==="approved")return j(`\u2705 Plan approved by the user. ${M.summary}`+(M.detail?`
|
|
260
260
|
|
|
261
261
|
Implement EXACTLY the schema below (migrations + code) \u2014 the user may have `+`edited columns on the canvas:
|
|
262
262
|
|
|
263
|
-
`+M.detail:"")+
|
|
263
|
+
`+M.detail:"")+F5(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.")});O.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(`${A5}/api/workspace/activate?id=${W0}`).catch(()=>{});let X=Date.now()+D5;while(Date.now()<X){await Z(O5);let H=await I("/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:
|
|
264
264
|
|
|
265
265
|
`+H.feedback);if(H.kind==="approved")return Y(`\u2705 Plan approved by the user. ${H.summary??""}`.trim()+(H.detail?`
|
|
266
266
|
|
|
267
267
|
Implement exactly what's on the board:
|
|
268
268
|
|
|
269
|
-
${H.detail}`:"")+
|
|
270
|
-
`)}]}}
|
|
269
|
+
${H.detail}`:"")+F5(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 v9=($)=>Array.isArray($)?$[0]:$;async function m0($){return(await I(`/api/entities?kind=${$}`)).items}function F9($,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 O9($,Q,Z){let Y=(await m0(Z)).find((W)=>U0(W.title)===v9(Q));if(!Y)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await I("/api/entities?kind=tables")).items??[]).map((W)=>W.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 W=await m0("features"),U=[...new Set(W.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(`
|
|
270
|
+
`)}]}}O.registerResource("beacon-feature",new R5("feature://{slug}",{list:async()=>F9(await m0("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})=>O9($,Q,"features"));O.registerResource("beacon-component",new R5("component://{slug}",{list:async()=>F9(await m0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>O9($,Q,"architecture"));async function C9(){return await I("/api/notes")}O.registerResource("beacon-note",new R5("note://{slug}",{list:async()=>M9(await C9())}),{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=N9(await C9(),v9(Q)),Y=Z?q9(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:Y}]}});await O.connect(new BQ);var b0=-1;setInterval(async()=>{try{let{version:$}=await I("/api/version");if(b0===-1)b0=$;else if($!==b0)b0=$,O.sendResourceListChanged()}catch{}},K9);
|
package/dist/bin/plan.js
CHANGED
|
@@ -69,9 +69,9 @@ Beacon was already initialized in this repo (\`/beacon-init\` ran at some point)
|
|
|
69
69
|
|
|
70
70
|
## What gets preserved vs replaced
|
|
71
71
|
|
|
72
|
-
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`).
|
|
72
|
+
The \`beacon_init_persist\` tool **replaces only init-derived nodes** (\`source=INIT\`). A curated architecture node (created by \`beacon_describe_feature\` or by hand) whose title matches a component in your refreshed analysis is **merged in place** \u2014 your fresh \`domain\`/\`role\`/\`plain\`/\`layer\`/\`files\` land on it, but it keeps its source, position, status, and bug flags, and no duplicate INIT node is created. Curated nodes your analysis does NOT mention survive untouched, as do hand-edited tables, custom positions, notes, and draft feature plans. So you can re-run this freely.
|
|
73
73
|
|
|
74
|
-
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
74
|
+
The one caveat: if the user manually edited an INIT-source node on the canvas (e.g., renamed it, rewrote its role), that edit IS overwritten when you re-persist \u2014 and a renamed node no longer title-matches, so it survives as its own card. If the user mentions hand-curated INIT nodes, ask whether they want those carried into the new analysis verbatim.
|
|
75
75
|
|
|
76
76
|
## How to do it
|
|
77
77
|
|