trybeacon 0.1.13 → 0.1.15
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 +6 -6
- 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 +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- 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 +1 -1
- package/.next/server/app/api/draft/approve/route.js +1 -1
- package/.next/server/app/api/draft/route.js +1 -1
- package/.next/server/app/api/map/describe/route.js +1 -1
- package/.next/server/app/api/plan/approve/route.js +1 -1
- package/.next/server/app/api/plan/verdict/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 +1 -1
- package/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- 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 +1 -1
- package/.next/server/app/feedback.segments/_full.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_tree.segment.rsc +1 -1
- 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 +1 -1
- package/.next/server/app/help.segments/_full.segment.rsc +1 -1
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +1 -1
- package/.next/server/app/help.segments/_tree.segment.rsc +1 -1
- 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 +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- 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 +2 -2
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +6 -6
- package/.next/server/chunks/1130.js +1 -1
- package/.next/server/chunks/8815.js +1 -1
- package/.next/server/chunks/9159.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/5354-31b73f8e3dfd92b7.js +1 -0
- package/.next/static/chunks/app/map/{page-7772ad291b0b70d4.js → page-3fe31101c63d9668.js} +1 -1
- package/.next/static/chunks/app/plan/{page-0c3346e8159470b3.js → page-51bc3f04374541b9.js} +1 -1
- package/.next/trace +37 -37
- package/.next/trace-build +1 -1
- package/dist/bin/doctor.js +5 -3
- package/dist/bin/hook.js +5 -3
- package/dist/bin/mcp.js +30 -28
- package/dist/bin/plan.js +28 -22
- package/dist/bin/uninstall.js +5 -3
- package/dist/lib/assets.js +5 -3
- package/dist/lib/global-install.js +5 -3
- package/package.json +1 -1
- package/.next/server/chunks/418.js +0 -1
- package/.next/static/chunks/5245-0a27d37da2f23876.js +0 -1
- /package/.next/static/{Omt9Zf0gT00hlkC7wb3US → ct96P0zTV3e7YqJ2NLI_X}/_buildManifest.js +0 -0
- /package/.next/static/{Omt9Zf0gT00hlkC7wb3US → ct96P0zTV3e7YqJ2NLI_X}/_ssgManifest.js +0 -0
package/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-webpack","duration":
|
|
1
|
+
[{"name":"run-webpack","duration":6416965,"timestamp":243150438370,"id":14,"parentId":1,"tags":{},"startTime":1781057870222,"traceId":"82dcfe922a3850b3"},{"name":"run-typescript","duration":2875623,"timestamp":243156856306,"id":3910,"parentId":1,"tags":{},"startTime":1781057876639,"traceId":"82dcfe922a3850b3"},{"name":"static-check","duration":283919,"timestamp":243159746944,"id":3913,"parentId":1,"tags":{},"startTime":1781057879530,"traceId":"82dcfe922a3850b3"},{"name":"static-generation","duration":954860,"timestamp":243160378442,"id":4047,"parentId":1,"tags":{},"startTime":1781057880161,"traceId":"82dcfe922a3850b3"},{"name":"collect-build-traces","duration":3305530,"timestamp":243160032226,"id":4044,"parentId":1,"tags":{},"startTime":1781057879815,"traceId":"82dcfe922a3850b3"},{"name":"telemetry-flush","duration":17,"timestamp":243163339148,"id":4056,"parentId":1,"tags":{},"startTime":1781057883122,"traceId":"82dcfe922a3850b3"},{"name":"next-build","duration":12936854,"timestamp":243150402315,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1781057870185,"traceId":"82dcfe922a3850b3"}]
|
package/dist/bin/doctor.js
CHANGED
|
@@ -181,11 +181,13 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
181
181
|
|
|
182
182
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
183
183
|
|
|
184
|
-
### 3. At the end, register the work
|
|
184
|
+
### 3. At the end, register the work \u2014 in ONE call
|
|
185
185
|
|
|
186
|
-
Call \`beacon_describe_feature\`
|
|
186
|
+
Call \`beacon_describe_feature\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** and keeps \`beacon_context_for_feature\` accurate for the next session.
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
Key each entry by its node \`id\`: the ids are handed back to you when the plan is approved (in the approval message / additionalContext), so you don't fuzzy-match titles or pay a disambiguation round-trip. If you don't have an id, \`title\` still works.
|
|
189
|
+
|
|
190
|
+
Register them all in that single batched call. If a plan added five features, that's ONE \`beacon_describe_feature\` call with five entries \u2014 NOT five calls, and NOT just an umbrella ("Harden auth"), which leaves the individual features stuck on **Pending**.
|
|
189
191
|
|
|
190
192
|
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.
|
|
191
193
|
|
package/dist/bin/hook.js
CHANGED
|
@@ -181,11 +181,13 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
181
181
|
|
|
182
182
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
183
183
|
|
|
184
|
-
### 3. At the end, register the work
|
|
184
|
+
### 3. At the end, register the work \u2014 in ONE call
|
|
185
185
|
|
|
186
|
-
Call \`beacon_describe_feature\`
|
|
186
|
+
Call \`beacon_describe_feature\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** and keeps \`beacon_context_for_feature\` accurate for the next session.
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
Key each entry by its node \`id\`: the ids are handed back to you when the plan is approved (in the approval message / additionalContext), so you don't fuzzy-match titles or pay a disambiguation round-trip. If you don't have an id, \`title\` still works.
|
|
189
|
+
|
|
190
|
+
Register them all in that single batched call. If a plan added five features, that's ONE \`beacon_describe_feature\` call with five entries \u2014 NOT five calls, and NOT just an umbrella ("Harden auth"), which leaves the individual features stuck on **Pending**.
|
|
189
191
|
|
|
190
192
|
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.
|
|
191
193
|
|
package/dist/bin/mcp.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var S5=Object.defineProperty;var y5=($)=>$;function h5($,Q){this[$]=y5.bind(null,Q)}var e=($,Q)=>{for(var Z in Q)S5($,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:h5.bind(Q,Z)})};var b0=($,Q)=>()=>($&&(Q=$($=0)),Q);var s0={};e(s0,{removeRepoAssets:()=>m5,installRefreshSkill:()=>g5,installPlanSkill:()=>f5,installInitSkill:()=>x5,ensureWorkflowDoc:()=>z5,ensureMcp:()=>u5,auditRepo:()=>b5,REFRESH_SKILL:()=>c0,PLAN_SKILL:()=>l0,INIT_SKILL:()=>p0});import{existsSync as N0,mkdirSync as K0,readFileSync as _,rmSync as j0,writeFileSync as L}from"fs";import{join as O}from"path";function x5($){let Q=O($,".claude","skills","beacon-init");K0(Q,{recursive:!0});let Z=O(Q,"SKILL.md");return L(Z,p0),Z}function g5($){let Q=O($,".claude","skills","beacon-refresh");K0(Q,{recursive:!0});let Z=O(Q,"SKILL.md");return L(Z,c0),Z}function f5($){let Q=O($,".claude","skills","beacon-plan");K0(Q,{recursive:!0});let Z=O(Q,"SKILL.md");return L(Z,l0),Z}function z5($){let Q=O($,"AGENTS.md"),Z="";try{Z=_(Q,"utf8")}catch{}let X=new RegExp(`${$0}[\\s\\S]*?${M0}`);Z=X.test(Z)?Z.replace(X,m0):`${Z.trim()}
|
|
4
4
|
|
|
5
5
|
${m0}
|
|
6
6
|
`.trimStart(),L(Q,Z.endsWith(`
|
|
7
7
|
`)?Z:`${Z}
|
|
8
|
-
`);let V=
|
|
8
|
+
`);let V=O($,"CLAUDE.md"),H="";try{H=_(V,"utf8")}catch{}if(!/@AGENTS\.md/.test(H))L(V,`${H?`${H.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function u5($){let Q=
|
|
12
|
-
`),{path:Q,added:!0}}function
|
|
13
|
-
`)}}catch{}let V=!1,H=
|
|
11
|
+
`)}function u5($){let Q=O($,".mcp.json"),Z={};try{Z=JSON.parse(_(Q,"utf8"))}catch{}if(Z.mcpServers=Z.mcpServers??{},Z.mcpServers.beacon)return{path:Q,added:!1};return Z.mcpServers.beacon={command:"beacon",args:["mcp"]},L(Q,JSON.stringify(Z,null,2)+`
|
|
12
|
+
`),{path:Q,added:!0}}function b5($){let Q=O($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(_(Q,"utf8")).mcpServers?.beacon}catch{}let X=!1;try{X=_(O($,"AGENTS.md"),"utf8").includes($0)}catch{}let V=!1;try{V=/@AGENTS\.md/.test(_(O($,"CLAUDE.md"),"utf8"))}catch{}return{repo:$,mcpRegistered:Z,agentsMdBlock:X,claudeMdImport:V,skills:{"beacon-init":N0(O($,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":N0(O($,".claude","skills","beacon-refresh","SKILL.md"))}}}function m5($){let Q=[];for(let K of["beacon-init","beacon-refresh","beacon-db-design"]){let C=O($,".claude","skills",K);if(N0(C))j0(C,{recursive:!0,force:!0}),Q.push(K)}let Z=!1,X=O($,".mcp.json");try{let K=JSON.parse(_(X,"utf8"));if(K.mcpServers?.beacon){if(delete K.mcpServers.beacon,Z=!0,K.mcpServers&&Object.keys(K.mcpServers).length===0)delete K.mcpServers;if(Object.keys(K).length===0)j0(X,{force:!0});else L(X,JSON.stringify(K,null,2)+`
|
|
13
|
+
`)}}catch{}let V=!1,H=O($,"AGENTS.md");try{let K=_(H,"utf8"),C=new RegExp(`\\n?${$0}[\\s\\S]*?${M0}\\n?`);if(C.test(K)){let l=K.replace(C,`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
16
|
`).trimStart();L(H,l.endsWith(`
|
|
17
17
|
`)?l:`${l}
|
|
18
|
-
`),V=!0}}catch{}let
|
|
18
|
+
`),V=!0}}catch{}let G=!1,N=O($,"CLAUDE.md");try{let K=_(N,"utf8"),C=K.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(C!==K){if(!C.trim())j0(N,{force:!0});else L(N,C);G=!0}}catch{}return{skillsRemoved:Q,mcpUnregistered:Z,agentsBlockRemoved:V,claudeImportRemoved:G}}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
|
---
|
|
@@ -140,7 +140,7 @@ If it returns feedback, revise and call it again.
|
|
|
140
140
|
|
|
141
141
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to presenting via
|
|
142
142
|
ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\` in this repo once.
|
|
143
|
-
`,$0="<!-- beacon:workflow:start -->",
|
|
143
|
+
`,$0="<!-- beacon:workflow:start -->",M0="<!-- beacon:workflow:end -->",m0;var d0=b0(()=>{m0=`${$0}
|
|
144
144
|
## Beacon \u2014 feature workflow
|
|
145
145
|
|
|
146
146
|
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:
|
|
@@ -181,16 +181,18 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
181
181
|
|
|
182
182
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
183
183
|
|
|
184
|
-
### 3. At the end, register the work
|
|
184
|
+
### 3. At the end, register the work \u2014 in ONE call
|
|
185
185
|
|
|
186
|
-
Call \`beacon_describe_feature\`
|
|
186
|
+
Call \`beacon_describe_feature\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** and keeps \`beacon_context_for_feature\` accurate for the next session.
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
Key each entry by its node \`id\`: the ids are handed back to you when the plan is approved (in the approval message / additionalContext), so you don't fuzzy-match titles or pay a disambiguation round-trip. If you don't have an id, \`title\` still works.
|
|
189
|
+
|
|
190
|
+
Register them all in that single batched call. If a plan added five features, that's ONE \`beacon_describe_feature\` call with five entries \u2014 NOT five calls, and NOT just an umbrella ("Harden auth"), which leaves the individual features stuck on **Pending**.
|
|
189
191
|
|
|
190
192
|
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.
|
|
191
193
|
|
|
192
194
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
193
|
-
${
|
|
195
|
+
${M0}`});var e0={};e(e0,{provisionDb:()=>N9});import{createClient as $9}from"@libsql/client";import{drizzle as Q9}from"drizzle-orm/libsql";import{migrate as Z9}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as J9}from"drizzle-orm/migrator";import{dirname as D0,join as X9}from"path";import{fileURLToPath as Y9}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 B9($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((X)=>String(X.name)))}async function t0($){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 j9($){for(let[Q,Z]of Object.entries(G9)){if(!await X0($,Q))continue;let X=await B9($,Q);for(let V of Z){if(!X.has(V))continue;await $.execute(`UPDATE "${Q}" SET "${V}" = CAST((julianday("${V}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${V}") = 'text'`)}}}async function N9($,Q=H9){let Z=$9({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;");let X=await X0(Z,"__drizzle_migrations"),V=await X0(Z,"Node"),H=!1;if(V&&!X){let N=J9({migrationsFolder:Q})[0];if(N)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:[N.hash,N.folderMillis]}),H=!0}let G=await t0(Z);if(await Z9(Q9(Z),{migrationsFolder:Q}),await t0(Z)>G)H=!0;return await j9(Z),{migrated:H}}finally{Z.close()}}var V9,H9,G9;var $5=b0(async()=>{V9=D0(D0(D0(Y9(import.meta.url)))),H9=process.env.BEACON_MIGRATIONS_DIR||X9(V9,"drizzle"),G9={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{existsSync as U0,mkdirSync as P0,readFileSync as Z0,rmSync as p5,writeFileSync as J0}from"fs";import{homedir as c5}from"os";import{join as T}from"path";function l5(){return process.env.HOME||process.env.USERPROFILE||c5()}var u=()=>T(l5(),".claude"),O0=()=>T(u(),"skills"),o0=()=>T(u(),"settings.json"),s=()=>T(u(),"CLAUDE.md"),Q0="<!-- beacon:global:start -->",W0="<!-- beacon:global:end -->",C0=["beacon-init","beacon-refresh","beacon-plan"],w0=[{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."}],s5=`## Beacon (visual planning panel)
|
|
194
196
|
|
|
195
197
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
196
198
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -211,37 +213,37 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
211
213
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
212
214
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
213
215
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
214
|
-
verbatim. Do NOT implement until the tool returns approval.`;function
|
|
215
|
-
`)}function
|
|
216
|
+
verbatim. Do NOT implement until the tool returns approval.`;function d5($,Q){let Z=T(O0(),$);P0(Z,{recursive:!0});let X=T(Z,"SKILL.md");return J0(X,Q),X}function n0($){return U0(T(O0(),$,"SKILL.md"))}function o5($){let Q=T(O0(),$);if(!U0(Q))return!1;return p5(Q,{recursive:!0,force:!0}),!0}function q0(){try{return JSON.parse(Z0(o0(),"utf8"))}catch{return{}}}function a0($){P0(u(),{recursive:!0}),J0(o0(),JSON.stringify($,null,2)+`
|
|
217
|
+
`)}function n5($){let Q=q0();Q.hooks=Q.hooks??{},Q.hooks[$.event]=Q.hooks[$.event]??[];let Z=Q.hooks[$.event];if(Z.some((V)=>V.matcher===$.matcher&&V.hooks?.some((H)=>H.command===$.command)))return!1;return Z.push({matcher:$.matcher,hooks:[{type:"command",command:$.command}]}),a0(Q),!0}function a5($){return(q0().hooks?.[$.event]??[]).some((X)=>X.hooks?.some((V)=>V.command===$.command))}function r5($){let Q=q0(),Z=Q.hooks?.[$.event];if(!Z)return!1;let X=!1,V=Z.map((H)=>{let G=H.hooks?.length??0,N=(H.hooks??[]).filter((K)=>K.command!==$.command);if(N.length!==G)X=!0;return{...H,hooks:N}}).filter((H)=>(H.hooks??[]).length>0);if(!X)return!1;if(V.length)Q.hooks[$.event]=V;else delete Q.hooks[$.event];if(Q.hooks&&Object.keys(Q.hooks).length===0)delete Q.hooks;return a0(Q),!0}function i5($){let Q=`${Q0}
|
|
216
218
|
${$.trim()}
|
|
217
|
-
${
|
|
219
|
+
${W0}`,Z="";try{Z=Z0(s(),"utf8")}catch{}let X=new RegExp(`${Q0}[\\s\\S]*?${W0}`);Z=X.test(Z)?Z.replace(X,Q):Z.trim()?`${Z.trim()}
|
|
218
220
|
|
|
219
221
|
${Q}
|
|
220
222
|
`:`${Q}
|
|
221
|
-
`,
|
|
223
|
+
`,P0(u(),{recursive:!0}),J0(s(),Z.endsWith(`
|
|
222
224
|
`)?Z:`${Z}
|
|
223
|
-
`)}function r0(){try{return Z0(s(),"utf8").includes(Q0)}catch{return!1}}function
|
|
225
|
+
`)}function r0(){try{return Z0(s(),"utf8").includes(Q0)}catch{return!1}}function t5(){let $="";try{$=Z0(s(),"utf8")}catch{return!1}let Q=new RegExp(`${Q0}[\\s\\S]*?${W0}\\n?`);if(!Q.test($))return!1;let Z=$.replace(Q,"").replace(/\n{3,}/g,`
|
|
224
226
|
|
|
225
|
-
`).trimStart();return J0(s(),Z),!0}function H$(){let $={};for(let Z of w0)$[Z]=n0(Z);let Q={};for(let Z of q0)Q[Z.event]=n5({event:Z.event,command:Z.command});return{homeExists:P0(z()),skills:$,hooks:Q,claudeMdBlock:r0()}}async function t5(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),X={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},V=[];for(let N of w0){if(!n0(N))V.push(N);s5(N,X[N])}let H=0;for(let N of q0)if(o5({event:N.event,matcher:N.matcher,command:N.command}))H++;let j=r0();return r5(l5),{skillsAdded:V,hooksAdded:H,claudeMdBlockTouched:!j}}async function i0(){try{return{ok:!0,...await t5()}}catch($){return{ok:!1,error:$ instanceof Error?$.message:String($),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}}function G$(){let $=[];for(let X of w0)if(d5(X))$.push(X);let Q=0;for(let X of q0)if(a5(X))Q++;let Z=i5();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as N9}from"async_hooks";import{spawnSync as K9}from"child_process";import{createHash as M9}from"crypto";import{existsSync as Z5,mkdirSync as Y0,readFileSync as J5,writeFileSync as X5}from"fs";import{homedir as W9}from"os";import{basename as U9,join as b}from"path";function d(){return process.env.BEACON_HOME||b(W9(),".beacon")}function v0(){return b(d(),"workspaces.json")}function V0($){return M9("sha256").update($).digest("hex").slice(0,12)}function Y5($=process.cwd()){let Q=K9("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 A0($){return b(d(),$)}function R0($){return`file:${b(A0($),"db.sqlite")}`}function o(){try{let $=JSON.parse(J5(v0(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function E0($){Y0(d(),{recursive:!0}),X5(v0(),JSON.stringify($,null,2))}function P9(){return o().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function h($){return o().find((Q)=>Q.id===$)??null}function _0($,Q,Z=new Date().toISOString()){let X=V0($),V=o(),H=V.find((K)=>K.id===X),j={id:X,path:$,name:Q||H?.name||U9($),lastOpenedAt:Z},N=[j,...V.filter((K)=>K.id!==X)];return Y0(A0(X),{recursive:!0}),E0(N),j}function F$($,Q=new Date().toISOString()){let Z=o(),X=Z.find((V)=>V.id===$);if(!X)return;X.lastOpenedAt=Q,E0(Z)}function v$($){if(E0(o().filter((Q)=>Q.id!==$)),n()===$)C9(P9()[0]?.id??null)}function V5(){return b(d(),"active")}function n(){try{return J5(V5(),"utf8").trim()||null}catch{return null}}function C9($){Y0(d(),{recursive:!0}),X5(V5(),$??"")}function A$(){let $=n();return $?h($):null}function R$(){let $=I0()??n();return $?h($):null}function E$($){return h($)?.path??null}function _$(){return Z5(v0())}var H5="beacon_ws";function G5($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let X of Z.split(";")){let V=X.indexOf("=");if(V===-1)continue;if(X.slice(0,V).trim()===Q)return decodeURIComponent(X.slice(V+1).trim())}return null}function L$($){let Q=$.headers.get("x-beacon-workspace");if(Q&&h(Q))return Q;let Z=G5($,H5);if(Z&&h(Z))return Z;return null}var L0="x-beacon-workspace-path";async function I$($){let Q=$.headers.get("x-beacon-workspace");if(Q&&h(Q))return Q;let Z=$.headers.get(L0);if(Z&&(!Q||V0(Z)===Q)){let V=_0(Z);return await k0(V.id),V.id}let X=G5($,H5);if(X&&h(X))return X;return null}var B5=new N9;function O9($,Q){return $?B5.run($,Q):Q()}function I0(){return B5.getStore()??null}var Q5=new Set;async function k0($){let Q=A0($),Z=b(Q,"db.sqlite"),X=Z5(Z);if(X&&Q5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Y0(Q,{recursive:!0});let{provisionDb:V}=await $5().then(() => e0),H=await V(R0($));return Q5.add(Z),{ok:!0,created:!X,migrated:X&&H.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{McpServer as e9,ResourceTemplate as f0}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as $$}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as G}from"zod";var w9=new Set(["GET","HEAD","OPTIONS"]);function j5($){return w9.has($.trim().toUpperCase())?"read":"write"}var q9=G.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},G.object({name:G.string().trim().min(1),type:G.string().trim().min(1),isPk:G.boolean().optional(),isFk:G.boolean().optional(),nullable:G.boolean().optional(),note:G.string().nullish()})),N5=G.object({name:G.string().trim().min(1),domain:G.string().nullish(),description:G.string().nullish(),columns:G.array(q9).default([])}),K5=G.object({fromTable:G.string(),fromColumn:G.string(),toTable:G.string(),toColumn:G.string(),label:G.string().nullish()}),M5=G.object({method:G.string().trim().min(1),path:G.string().trim().min(1),domain:G.string().nullish(),description:G.string().nullish(),uses:G.array(G.object({table:G.string().trim().min(1),access:G.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??j5($.method)}))})),y$=G.object({tables:G.array(N5).default([]),relations:G.array(K5).default([]),endpoints:G.array(M5).default([])});import{z as R}from"zod";import{and as QQ,eq as ZQ,inArray as JQ}from"drizzle-orm";import{drizzle as c9}from"drizzle-orm/libsql";import{createClient as l9}from"@libsql/client";var T0={};e(T0,{tag:()=>m,syncState:()=>R9,projectMeta:()=>_9,note:()=>v9,nodeTags:()=>y,nodeFile:()=>a,node:()=>U,endpointTable:()=>g,endpoint:()=>p,edge:()=>S,draftTable:()=>A,draftRelation:()=>f,draftColumn:()=>i,dbTable:()=>w,dbRelation:()=>x,dbColumn:()=>r,codeFileEdge:()=>u,codeFile:()=>I,boardAnnotation:()=>A9,appSetting:()=>E9});import{sqliteTable as P,index as W,foreignKey as D9,text as Y,integer as B,real as F,uniqueIndex as k,primaryKey as F9}from"drizzle-orm/sqlite-core";import{createId as v}from"@paralleldrive/cuid2";var U=P("Node",{id:Y().primaryKey().$defaultFn(()=>v()),view:Y().notNull(),cluster:Y(),title:Y().notNull(),role:Y(),plain:Y(),status:Y().default("PENDING").notNull(),priority:B().default(2).notNull(),progress:B().default(0).notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),sourceRef:Y(),externalId:Y(),source:Y().default("MANUAL").notNull(),parentId:Y(),createdAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date),embedding:Y()},($)=>[W("Node_cluster_idx").on($.cluster),W("Node_parentId_idx").on($.parentId),W("Node_view_idx").on($.view),D9(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),a=P("NodeFile",{id:Y().primaryKey().$defaultFn(()=>v()),nodeId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),path:Y().notNull()},($)=>[k("NodeFile_nodeId_path_key").on($.nodeId,$.path),W("NodeFile_nodeId_idx").on($.nodeId)]),m=P("Tag",{id:Y().primaryKey().$defaultFn(()=>v()),label:Y().notNull(),color:Y()},($)=>[k("Tag_label_key").on($.label)]),S=P("Edge",{id:Y().primaryKey().$defaultFn(()=>v()),fromId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:Y().default("DEPENDS").notNull(),label:Y(),sourceHandle:Y(),targetHandle:Y()},($)=>[k("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),W("Edge_toId_idx").on($.toId),W("Edge_fromId_idx").on($.fromId)]),y=P("_NodeTags",{a:Y("A").notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),b:Y("B").notNull().references(()=>m.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[k("_NodeTags_AB_unique").on($.a,$.b),W("_NodeTags_B_index").on($.b)]),v9=P("Note",{id:Y().primaryKey().$defaultFn(()=>v()),title:Y().default("Untitled").notNull(),body:Y().default("").notNull(),ord:F().default(0).notNull(),pinned:B({mode:"boolean"}).default(!1).notNull(),createdAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("Note_updatedAt_idx").on($.updatedAt)]),A9=P("BoardAnnotation",{id:Y().primaryKey().$defaultFn(()=>v()),targetKind:Y().notNull(),targetId:Y().notNull(),columnName:Y(),body:Y().default("").notNull(),x:F(),y:F(),createdAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("BoardAnnotation_target_idx").on($.targetId)]),w=P("DbTable",{id:Y().primaryKey().$defaultFn(()=>v()),name:Y().notNull(),domain:Y(),description:Y(),source:Y().default("MANUAL").notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("DbTable_domain_idx").on($.domain),k("DbTable_name_key").on($.name)]),r=P("DbColumn",{id:Y().primaryKey().$defaultFn(()=>v()),tableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),name:Y().notNull(),type:Y().notNull(),isPk:B({mode:"boolean"}).default(!1).notNull(),isFk:B({mode:"boolean"}).default(!1).notNull(),nullable:B({mode:"boolean"}).default(!0).notNull(),note:Y(),ord:B().default(0).notNull()},($)=>[k("DbColumn_tableId_name_key").on($.tableId,$.name),W("DbColumn_tableId_idx").on($.tableId)]),x=P("DbRelation",{id:Y().primaryKey().$defaultFn(()=>v()),fromTableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:Y().notNull(),toColumn:Y().notNull(),label:Y()},($)=>[W("DbRelation_toTableId_idx").on($.toTableId),W("DbRelation_fromTableId_idx").on($.fromTableId)]),p=P("Endpoint",{id:Y().primaryKey().$defaultFn(()=>v()),method:Y().notNull(),path:Y().notNull(),domain:Y(),description:Y(),source:Y().default("MANUAL").notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("Endpoint_method_path_key").on($.method,$.path),W("Endpoint_domain_idx").on($.domain)]),g=P("EndpointTable",{id:Y().primaryKey().$defaultFn(()=>v()),endpointId:Y().notNull().references(()=>p.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),access:Y().default("read").notNull()},($)=>[k("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),W("EndpointTable_tableId_idx").on($.tableId)]),A=P("DraftTable",{id:Y().primaryKey().$defaultFn(()=>v()),name:Y().notNull(),domain:Y(),description:Y(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[k("DraftTable_name_key").on($.name)]),i=P("DraftColumn",{id:Y().primaryKey().$defaultFn(()=>v()),tableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:Y().notNull(),type:Y().notNull(),isPk:B({mode:"boolean"}).default(!1).notNull(),isFk:B({mode:"boolean"}).default(!1).notNull(),nullable:B({mode:"boolean"}).default(!0).notNull(),note:Y(),ord:B().default(0).notNull()},($)=>[W("DraftColumn_tableId_idx").on($.tableId)]),f=P("DraftRelation",{id:Y().primaryKey().$defaultFn(()=>v()),fromTableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:Y().notNull(),toColumn:Y().notNull(),label:Y()},($)=>[W("DraftRelation_toTableId_idx").on($.toTableId),W("DraftRelation_fromTableId_idx").on($.fromTableId)]),I=P("CodeFile",{path:Y().primaryKey(),root:Y(),lang:Y(),x:F().default(0).notNull(),y:F().default(0).notNull(),mtimeMs:F(),size:B(),inDegree:B().default(0).notNull(),outDegree:B().default(0).notNull(),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=P("CodeFileEdge",{fromPath:Y().notNull().references(()=>I.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:Y().notNull().references(()=>I.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:B({mode:"boolean"}).default(!1).notNull()},($)=>[W("CodeFileEdge_circular_idx").on($.circular),W("CodeFileEdge_toPath_idx").on($.toPath),W("CodeFileEdge_fromPath_idx").on($.fromPath),F9({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),R9=P("SyncState",{id:Y().primaryKey().default("singleton"),version:B().default(0).notNull(),codeGraphSyncedAt:B({mode:"timestamp_ms"}),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),E9=P("AppSetting",{id:Y().primaryKey().default("singleton"),intelModel:Y().default("claude-haiku-4-5").notNull(),intelProvider:Y().default("auto").notNull(),editor:Y().default("auto").notNull(),currentFeatureId:Y(),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),_9=P("ProjectMeta",{id:Y().primaryKey().default("singleton"),overview:Y(),conventions:Y().default("[]").notNull(),updatedAt:B({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var S0={};e(S0,{tagRelations:()=>k9,nodeTagsRelations:()=>T9,nodeRelations:()=>L9,nodeFileRelations:()=>I9,endpointTableRelations:()=>f9,endpointRelations:()=>g9,edgeRelations:()=>S9,draftTableRelations:()=>u9,draftRelationRelations:()=>b9,draftColumnRelations:()=>z9,dbTableRelations:()=>h9,dbRelationRelations:()=>x9,dbColumnRelations:()=>y9,codeFileRelations:()=>m9,codeFileEdgeRelations:()=>p9});import{relations as q}from"drizzle-orm";var L9=q(U,({one:$,many:Q})=>({files:Q(a),nodeTags:Q(y),edgesOut:Q(S,{relationName:"EdgeFrom"}),edgesIn:Q(S,{relationName:"EdgeTo"}),parent:$(U,{fields:[U.parentId],references:[U.id],relationName:"NodeTree"}),children:Q(U,{relationName:"NodeTree"})})),I9=q(a,({one:$})=>({node:$(U,{fields:[a.nodeId],references:[U.id]})})),k9=q(m,({many:$})=>({nodeTags:$(y)})),T9=q(y,({one:$})=>({node:$(U,{fields:[y.a],references:[U.id]}),tag:$(m,{fields:[y.b],references:[m.id]})})),S9=q(S,({one:$})=>({from:$(U,{fields:[S.fromId],references:[U.id],relationName:"EdgeFrom"}),to:$(U,{fields:[S.toId],references:[U.id],relationName:"EdgeTo"})})),h9=q(w,({many:$})=>({columns:$(r),fksOut:$(x,{relationName:"FkFrom"}),fksIn:$(x,{relationName:"FkTo"}),usages:$(g)})),y9=q(r,({one:$})=>({table:$(w,{fields:[r.tableId],references:[w.id]})})),x9=q(x,({one:$})=>({fromTable:$(w,{fields:[x.fromTableId],references:[w.id],relationName:"FkFrom"}),toTable:$(w,{fields:[x.toTableId],references:[w.id],relationName:"FkTo"})})),g9=q(p,({many:$})=>({tables:$(g)})),f9=q(g,({one:$})=>({endpoint:$(p,{fields:[g.endpointId],references:[p.id]}),table:$(w,{fields:[g.tableId],references:[w.id]})})),u9=q(A,({many:$})=>({columns:$(i),fksOut:$(f,{relationName:"DraftFkFrom"}),fksIn:$(f,{relationName:"DraftFkTo"})})),z9=q(i,({one:$})=>({table:$(A,{fields:[i.tableId],references:[A.id]})})),b9=q(f,({one:$})=>({fromTable:$(A,{fields:[f.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[f.toTableId],references:[A.id],relationName:"DraftFkTo"})})),m9=q(I,({many:$})=>({edgesOut:$(u,{relationName:"CFEFrom"}),edgesIn:$(u,{relationName:"CFETo"})})),p9=q(u,({one:$})=>({fromFile:$(I,{fields:[u.fromPath],references:[I.path],relationName:"CFEFrom"}),toFile:$(I,{fields:[u.toPath],references:[I.path],relationName:"CFETo"})}));var s9={...T0,...S0};function d9(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var o9=d9();function U5($){let Q=l9({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),c9(Q,{schema:s9})}var y0=globalThis,h0=y0.dzDefault??U5(o9);y0.dzDefault=h0;var W5=y0.dzByUrl??=new Map;function n9($){let Q=W5.get($);if(!Q)Q=U5($),W5.set($,Q);return Q}function a9(){if(process.env.BEACON_REPO)return h0;let $=I0()??n();if(!$)return h0;return n9(R0($))}var r9=new Proxy({},{get($,Q){let Z=a9(),X=Z[Q];return typeof X==="function"?X.bind(Z):X}});import{forceCenter as d$,forceCollide as o$,forceLink as n$,forceManyBody as a$,forceSimulation as r$}from"d3-force";var P5=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(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,...X})=>({...X,cluster:X.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z)))})),HQ=R.object({features:R.array(P5).default([])});var i9=/(\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 C5($){return!!$&&i9.test($)}function t9($){return $.cluster??$.category??$.domain??null}function O5($){let Q=$.map((Z)=>{let X=[],V=t9(Z);if(!V||!V.trim())X.push("category");if(Z.priority==null)X.push("priority");return X.length?` \u2022 "${Z.title?.trim()||"(untitled)"}" \u2014 missing ${X.join(" + ")}`:null}).filter((Z)=>Z!==null);if(Q.length===0)return null;return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+`on the board, and the user shouldn't have to add them by hand. Missing:
|
|
227
|
+
`).trimStart();return J0(s(),Z),!0}function G$(){let $={};for(let Z of C0)$[Z]=n0(Z);let Q={};for(let Z of w0)Q[Z.event]=a5({event:Z.event,command:Z.command});return{homeExists:U0(u()),skills:$,hooks:Q,claudeMdBlock:r0()}}async function e5(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),X={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},V=[];for(let N of C0){if(!n0(N))V.push(N);d5(N,X[N])}let H=0;for(let N of w0)if(n5({event:N.event,matcher:N.matcher,command:N.command}))H++;let G=r0();return i5(s5),{skillsAdded:V,hooksAdded:H,claudeMdBlockTouched:!G}}async function i0(){try{return{ok:!0,...await e5()}}catch($){return{ok:!1,error:$ instanceof Error?$.message:String($),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}}function B$(){let $=[];for(let X of C0)if(o5(X))$.push(X);let Q=0;for(let X of w0)if(r5(X))Q++;let Z=t5();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as K9}from"async_hooks";import{spawnSync as M9}from"child_process";import{createHash as W9}from"crypto";import{existsSync as Z5,mkdirSync as Y0,readFileSync as J5,writeFileSync as X5}from"fs";import{homedir as U9}from"os";import{basename as P9,join as b}from"path";function d(){return process.env.BEACON_HOME||b(U9(),".beacon")}function F0(){return b(d(),"workspaces.json")}function V0($){return W9("sha256").update($).digest("hex").slice(0,12)}function Y5($=process.cwd()){let Q=M9("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 v0($){return b(d(),$)}function A0($){return`file:${b(v0($),"db.sqlite")}`}function o(){try{let $=JSON.parse(J5(F0(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function R0($){Y0(d(),{recursive:!0}),X5(F0(),JSON.stringify($,null,2))}function O9(){return o().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function y($){return o().find((Q)=>Q.id===$)??null}function E0($,Q,Z=new Date().toISOString()){let X=V0($),V=o(),H=V.find((K)=>K.id===X),G={id:X,path:$,name:Q||H?.name||P9($),lastOpenedAt:Z},N=[G,...V.filter((K)=>K.id!==X)];return Y0(v0(X),{recursive:!0}),R0(N),G}function v$($,Q=new Date().toISOString()){let Z=o(),X=Z.find((V)=>V.id===$);if(!X)return;X.lastOpenedAt=Q,R0(Z)}function A$($){if(R0(o().filter((Q)=>Q.id!==$)),n()===$)C9(O9()[0]?.id??null)}function V5(){return b(d(),"active")}function n(){try{return J5(V5(),"utf8").trim()||null}catch{return null}}function C9($){Y0(d(),{recursive:!0}),X5(V5(),$??"")}function R$(){let $=n();return $?y($):null}function E$(){let $=L0()??n();return $?y($):null}function _$($){return y($)?.path??null}function L$(){return Z5(F0())}var H5="beacon_ws";function G5($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let X of Z.split(";")){let V=X.indexOf("=");if(V===-1)continue;if(X.slice(0,V).trim()===Q)return decodeURIComponent(X.slice(V+1).trim())}return null}function I$($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=G5($,H5);if(Z&&y(Z))return Z;return null}var _0="x-beacon-workspace-path";async function k$($){let Q=$.headers.get("x-beacon-workspace");if(Q&&y(Q))return Q;let Z=$.headers.get(_0);if(Z&&(!Q||V0(Z)===Q)){let V=E0(Z);return await I0(V.id),V.id}let X=G5($,H5);if(X&&y(X))return X;return null}var B5=new K9;function w9($,Q){return $?B5.run($,Q):Q()}function L0(){return B5.getStore()??null}var Q5=new Set;async function I0($){let Q=v0($),Z=b(Q,"db.sqlite"),X=Z5(Z);if(X&&Q5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Y0(Q,{recursive:!0});let{provisionDb:V}=await $5().then(() => e0),H=await V(A0($));return Q5.add(Z),{ok:!0,created:!X,migrated:X&&H.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{McpServer as $$,ResourceTemplate as f0}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Q$}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var q9=new Set(["GET","HEAD","OPTIONS"]);function j5($){return q9.has($.trim().toUpperCase())?"read":"write"}var D9=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()})),N5=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(D9).default([])}),K5=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),M5=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??j5($.method)}))})),x$=B.object({tables:B.array(N5).default([]),relations:B.array(K5).default([]),endpoints:B.array(M5).default([])});import{z as R}from"zod";import{and as ZQ,eq as JQ,inArray as XQ}from"drizzle-orm";import{drizzle as l9}from"drizzle-orm/libsql";import{createClient as s9}from"@libsql/client";var k0={};e(k0,{tag:()=>m,syncState:()=>E9,projectMeta:()=>L9,note:()=>A9,nodeTags:()=>h,nodeFile:()=>a,node:()=>U,endpointTable:()=>g,endpoint:()=>p,edge:()=>S,draftTable:()=>A,draftRelation:()=>f,draftColumn:()=>i,dbTable:()=>w,dbRelation:()=>x,dbColumn:()=>r,codeFileEdge:()=>z,codeFile:()=>I,boardAnnotation:()=>R9,appSetting:()=>_9});import{sqliteTable as P,index as W,foreignKey as F9,text as Y,integer as j,real as F,uniqueIndex as k,primaryKey as v9}from"drizzle-orm/sqlite-core";import{createId as v}from"@paralleldrive/cuid2";var U=P("Node",{id:Y().primaryKey().$defaultFn(()=>v()),view:Y().notNull(),cluster:Y(),title:Y().notNull(),role:Y(),plain:Y(),status:Y().default("PENDING").notNull(),priority:j().default(2).notNull(),progress:j().default(0).notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),sourceRef:Y(),externalId:Y(),source:Y().default("MANUAL").notNull(),parentId:Y(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date),embedding:Y()},($)=>[W("Node_cluster_idx").on($.cluster),W("Node_parentId_idx").on($.parentId),W("Node_view_idx").on($.view),F9(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),a=P("NodeFile",{id:Y().primaryKey().$defaultFn(()=>v()),nodeId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),path:Y().notNull()},($)=>[k("NodeFile_nodeId_path_key").on($.nodeId,$.path),W("NodeFile_nodeId_idx").on($.nodeId)]),m=P("Tag",{id:Y().primaryKey().$defaultFn(()=>v()),label:Y().notNull(),color:Y()},($)=>[k("Tag_label_key").on($.label)]),S=P("Edge",{id:Y().primaryKey().$defaultFn(()=>v()),fromId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:Y().default("DEPENDS").notNull(),label:Y(),sourceHandle:Y(),targetHandle:Y()},($)=>[k("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),W("Edge_toId_idx").on($.toId),W("Edge_fromId_idx").on($.fromId)]),h=P("_NodeTags",{a:Y("A").notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),b:Y("B").notNull().references(()=>m.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[k("_NodeTags_AB_unique").on($.a,$.b),W("_NodeTags_B_index").on($.b)]),A9=P("Note",{id:Y().primaryKey().$defaultFn(()=>v()),title:Y().default("Untitled").notNull(),body:Y().default("").notNull(),ord:F().default(0).notNull(),pinned:j({mode:"boolean"}).default(!1).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("Note_updatedAt_idx").on($.updatedAt)]),R9=P("BoardAnnotation",{id:Y().primaryKey().$defaultFn(()=>v()),targetKind:Y().notNull(),targetId:Y().notNull(),columnName:Y(),body:Y().default("").notNull(),x:F(),y:F(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("BoardAnnotation_target_idx").on($.targetId)]),w=P("DbTable",{id:Y().primaryKey().$defaultFn(()=>v()),name:Y().notNull(),domain:Y(),description:Y(),source:Y().default("MANUAL").notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("DbTable_domain_idx").on($.domain),k("DbTable_name_key").on($.name)]),r=P("DbColumn",{id:Y().primaryKey().$defaultFn(()=>v()),tableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),name:Y().notNull(),type:Y().notNull(),isPk:j({mode:"boolean"}).default(!1).notNull(),isFk:j({mode:"boolean"}).default(!1).notNull(),nullable:j({mode:"boolean"}).default(!0).notNull(),note:Y(),ord:j().default(0).notNull()},($)=>[k("DbColumn_tableId_name_key").on($.tableId,$.name),W("DbColumn_tableId_idx").on($.tableId)]),x=P("DbRelation",{id:Y().primaryKey().$defaultFn(()=>v()),fromTableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:Y().notNull(),toColumn:Y().notNull(),label:Y()},($)=>[W("DbRelation_toTableId_idx").on($.toTableId),W("DbRelation_fromTableId_idx").on($.fromTableId)]),p=P("Endpoint",{id:Y().primaryKey().$defaultFn(()=>v()),method:Y().notNull(),path:Y().notNull(),domain:Y(),description:Y(),source:Y().default("MANUAL").notNull(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("Endpoint_method_path_key").on($.method,$.path),W("Endpoint_domain_idx").on($.domain)]),g=P("EndpointTable",{id:Y().primaryKey().$defaultFn(()=>v()),endpointId:Y().notNull().references(()=>p.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),access:Y().default("read").notNull()},($)=>[k("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),W("EndpointTable_tableId_idx").on($.tableId)]),A=P("DraftTable",{id:Y().primaryKey().$defaultFn(()=>v()),name:Y().notNull(),domain:Y(),description:Y(),x:F().default(0).notNull(),y:F().default(0).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[k("DraftTable_name_key").on($.name)]),i=P("DraftColumn",{id:Y().primaryKey().$defaultFn(()=>v()),tableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:Y().notNull(),type:Y().notNull(),isPk:j({mode:"boolean"}).default(!1).notNull(),isFk:j({mode:"boolean"}).default(!1).notNull(),nullable:j({mode:"boolean"}).default(!0).notNull(),note:Y(),ord:j().default(0).notNull()},($)=>[W("DraftColumn_tableId_idx").on($.tableId)]),f=P("DraftRelation",{id:Y().primaryKey().$defaultFn(()=>v()),fromTableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:Y().notNull(),toColumn:Y().notNull(),label:Y()},($)=>[W("DraftRelation_toTableId_idx").on($.toTableId),W("DraftRelation_fromTableId_idx").on($.fromTableId)]),I=P("CodeFile",{path:Y().primaryKey(),root:Y(),lang:Y(),x:F().default(0).notNull(),y:F().default(0).notNull(),mtimeMs:F(),size:j(),inDegree:j().default(0).notNull(),outDegree:j().default(0).notNull(),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),z=P("CodeFileEdge",{fromPath:Y().notNull().references(()=>I.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:Y().notNull().references(()=>I.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:j({mode:"boolean"}).default(!1).notNull()},($)=>[W("CodeFileEdge_circular_idx").on($.circular),W("CodeFileEdge_toPath_idx").on($.toPath),W("CodeFileEdge_fromPath_idx").on($.fromPath),v9({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),E9=P("SyncState",{id:Y().primaryKey().default("singleton"),version:j().default(0).notNull(),codeGraphSyncedAt:j({mode:"timestamp_ms"}),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),_9=P("AppSetting",{id:Y().primaryKey().default("singleton"),intelModel:Y().default("claude-haiku-4-5").notNull(),intelProvider:Y().default("auto").notNull(),editor:Y().default("auto").notNull(),currentFeatureId:Y(),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),L9=P("ProjectMeta",{id:Y().primaryKey().default("singleton"),overview:Y(),conventions:Y().default("[]").notNull(),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var T0={};e(T0,{tagRelations:()=>T9,nodeTagsRelations:()=>S9,nodeRelations:()=>I9,nodeFileRelations:()=>k9,endpointTableRelations:()=>z9,endpointRelations:()=>f9,edgeRelations:()=>y9,draftTableRelations:()=>u9,draftRelationRelations:()=>m9,draftColumnRelations:()=>b9,dbTableRelations:()=>h9,dbRelationRelations:()=>g9,dbColumnRelations:()=>x9,codeFileRelations:()=>p9,codeFileEdgeRelations:()=>c9});import{relations as q}from"drizzle-orm";var I9=q(U,({one:$,many:Q})=>({files:Q(a),nodeTags:Q(h),edgesOut:Q(S,{relationName:"EdgeFrom"}),edgesIn:Q(S,{relationName:"EdgeTo"}),parent:$(U,{fields:[U.parentId],references:[U.id],relationName:"NodeTree"}),children:Q(U,{relationName:"NodeTree"})})),k9=q(a,({one:$})=>({node:$(U,{fields:[a.nodeId],references:[U.id]})})),T9=q(m,({many:$})=>({nodeTags:$(h)})),S9=q(h,({one:$})=>({node:$(U,{fields:[h.a],references:[U.id]}),tag:$(m,{fields:[h.b],references:[m.id]})})),y9=q(S,({one:$})=>({from:$(U,{fields:[S.fromId],references:[U.id],relationName:"EdgeFrom"}),to:$(U,{fields:[S.toId],references:[U.id],relationName:"EdgeTo"})})),h9=q(w,({many:$})=>({columns:$(r),fksOut:$(x,{relationName:"FkFrom"}),fksIn:$(x,{relationName:"FkTo"}),usages:$(g)})),x9=q(r,({one:$})=>({table:$(w,{fields:[r.tableId],references:[w.id]})})),g9=q(x,({one:$})=>({fromTable:$(w,{fields:[x.fromTableId],references:[w.id],relationName:"FkFrom"}),toTable:$(w,{fields:[x.toTableId],references:[w.id],relationName:"FkTo"})})),f9=q(p,({many:$})=>({tables:$(g)})),z9=q(g,({one:$})=>({endpoint:$(p,{fields:[g.endpointId],references:[p.id]}),table:$(w,{fields:[g.tableId],references:[w.id]})})),u9=q(A,({many:$})=>({columns:$(i),fksOut:$(f,{relationName:"DraftFkFrom"}),fksIn:$(f,{relationName:"DraftFkTo"})})),b9=q(i,({one:$})=>({table:$(A,{fields:[i.tableId],references:[A.id]})})),m9=q(f,({one:$})=>({fromTable:$(A,{fields:[f.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[f.toTableId],references:[A.id],relationName:"DraftFkTo"})})),p9=q(I,({many:$})=>({edgesOut:$(z,{relationName:"CFEFrom"}),edgesIn:$(z,{relationName:"CFETo"})})),c9=q(z,({one:$})=>({fromFile:$(I,{fields:[z.fromPath],references:[I.path],relationName:"CFEFrom"}),toFile:$(I,{fields:[z.toPath],references:[I.path],relationName:"CFETo"})}));var d9={...k0,...T0};function o9(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var n9=o9();function U5($){let Q=s9({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),l9(Q,{schema:d9})}var y0=globalThis,S0=y0.dzDefault??U5(n9);y0.dzDefault=S0;var W5=y0.dzByUrl??=new Map;function a9($){let Q=W5.get($);if(!Q)Q=U5($),W5.set($,Q);return Q}function r9(){if(process.env.BEACON_REPO)return S0;let $=L0()??n();if(!$)return S0;return a9(A0($))}var i9=new Proxy({},{get($,Q){let Z=r9(),X=Z[Q];return typeof X==="function"?X.bind(Z):X}});import{forceCenter as o$,forceCollide as n$,forceLink as a$,forceManyBody as r$,forceSimulation as i$}from"d3-force";var P5=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(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,...X})=>({...X,cluster:X.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z)))})),GQ=R.object({features:R.array(P5).default([])});var t9=/(\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 O5($){return!!$&&t9.test($)}function e9($){return $.cluster??$.category??$.domain??null}function C5($){let Q=$.map((Z)=>{let X=[],V=e9(Z);if(!V||!V.trim())X.push("category");if(Z.priority==null)X.push("priority");return X.length?` \u2022 "${Z.title?.trim()||"(untitled)"}" \u2014 missing ${X.join(" + ")}`:null}).filter((Z)=>Z!==null);if(Q.length===0)return null;return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+`on the board, and the user shouldn't have to add them by hand. Missing:
|
|
226
228
|
`+Q.join(`
|
|
227
|
-
`)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low). Set BOTH on EVERY feature; don't rely on defaults."}
|
|
228
|
-
`)}await i0();var u0=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,z0=Y5(),B0=V0(z0);try{_0(z0);let $=await k0(B0);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",B0),Z.set(L0,z0);let X=await fetch(`${u0}${$}`,{...Q,headers:Z}),V=await X.text();if(!X.ok)throw Error(`Beacon ${$} -> ${X.status} ${V}`);return V?JSON.parse(V):null}function c($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function R5($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let X=JSON.parse(Z[0]);if(X?.error)return{content:[{type:"text",text:X.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var D=new e9({name:"beacon",version:"0.1.0"});D.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($,null,2)}]}});D.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.")}},async({title:$,id:Q,front:Z,detail:X,category:V})=>{try{let H=await c("/api/map/start",{title:$,id:Q,front:Z,detail:X,category:V});return{content:[{type:"text",text:JSON.stringify(H)}]}}catch(H){return R5(H)}});D.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")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let X=await c("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(X,null,2)}]}}catch(X){return R5(X)}});D.registerTool("beacon_describe_feature",{description:"Call ONCE at the end of a feature: marks status=DONE, records the files you touched (kept on the FEATURE for context), and replaces the node's description with `description` markdown. Subsumes touch_files + finish_feature. If the feature added or materially changed a REAL architectural component (a subsystem \u2014 never a file), also pass `architecture` to keep the Architecture map accurate.",inputSchema:{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"),id:J.string().optional().describe("node id from beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),architecture:J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file")}},async({description:$,files:Q,id:Z,title:X,architecture:V})=>{let H=await c("/api/map/describe",{description:$,files:Q,id:Z,title:X,architecture:V});return{content:[{type:"text",text:JSON.stringify(H)}]}});D.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on")})).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")})).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 c("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});D.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 X=new URLSearchParams;if($)X.set("id",$);if(Q)X.set("title",Q);if(Z)X.set("query",Z);let V=await E(`/api/context/feature?${X.toString()}`);return{content:[{type:"text",text:JSON.stringify(V,null,2)}]}});D.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 X=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(X,null,2)}]}});D.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,null,2)}]}});D.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 the tool REJECTS a plan whose features omit either, so set both on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards")})).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:X,endpoints:V})=>{let H=(M)=>new Promise((j0)=>setTimeout(j0,M)),j=(M)=>({content:[{type:"text",text:M}]}),N=(Z?.length??0)>0,K=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
|
|
229
|
-
`),O=(V?.length??0)>0||C5(`${$}
|
|
230
|
-
${K}`);if(!N&&O)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=O5(Q);if(M)return j(M)}let l=(Z?.length??0)+(V?.length??0)>0;await c("/api/plan",{description:$,draft:l?{tables:Z??[],relations:X??[],endpoints:V??[]}:void 0,features:Q?.length?Q:void 0}),await fetch(`${u0}/api/workspace/activate?id=${B0}`).catch(()=>{});let I5=Date.now()+g0;while(Date.now()<I5){await H(x0);let M=await E("/api/plan/verdict").catch(()=>null);if(!M)continue;if(M.kind==="feedback")return j("\uD83D\uDCAC The user left feedback on the plan in Beacon \u2014 text comments and/or edits they "+"made directly on the /map and /db boards. Read everything below, revise the plan accordingly (matching the board changes verbatim), and call `beacon_propose_plan` "+`again with the revised version \u2014 DO NOT implement yet:
|
|
229
|
+
`)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low). Set BOTH on EVERY feature; don't rely on defaults."}function h0($){if(!$?.length)return"";let Q=$.map((X)=>X.id?` \u2022 ${X.title} \u2014 id: ${X.id}`:` \u2022 ${X.title}`),Z=$.some((X)=>X.id);return`
|
|
231
230
|
|
|
232
|
-
|
|
231
|
+
This plan created these roadmap feature(s):
|
|
232
|
+
`+Q.join(`
|
|
233
|
+
`)+"\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 x0=1500,CQ=345600000,g0=1800000,w5=3000;function t($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function q5($){return`${t($.title)}-${$.id.slice(-6)}`}function D5($){return{resources:$.map((Q)=>({uri:`note://${q5(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function F5($,Q){return $.find((Z)=>q5(Z)===Q)}function v5($){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(`
|
|
234
|
+
`)}await i0();var z0=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,u0=Y5(),B0=V0(u0);try{E0(u0);let $=await I0(B0);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",B0),Z.set(_0,u0);let X=await fetch(`${z0}${$}`,{...Q,headers:Z}),V=await X.text();if(!X.ok)throw Error(`Beacon ${$} -> ${X.status} ${V}`);return V?JSON.parse(V):null}function c($,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 X=JSON.parse(Z[0]);if(X?.error)return{content:[{type:"text",text:X.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var D=new $$({name:"beacon",version:"0.1.0"});D.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($)}]}});D.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.")}},async({title:$,id:Q,front:Z,detail:X,category:V})=>{try{let H=await c("/api/map/start",{title:$,id:Q,front:Z,detail:X,category:V});return{content:[{type:"text",text:JSON.stringify(H)}]}}catch(H){return E5(H)}});D.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")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let X=await c("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(X)}]}}catch(X){return E5(X)}});var A5=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");D.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. 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:A5})).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:A5}},async({features:$,description:Q,files:Z,id:X,title:V,architecture:H})=>{let G=$?.length?{features:$}:{description:Q,files:Z,id:X,title:V,architecture:H},N=await c("/api/map/describe",G);return{content:[{type:"text",text:JSON.stringify(N)}]}});D.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on")})).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")})).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 c("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});D.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 X=new URLSearchParams;if($)X.set("id",$);if(Q)X.set("title",Q);if(Z)X.set("query",Z);let V=await E(`/api/context/feature?${X.toString()}`);return{content:[{type:"text",text:JSON.stringify(V)}]}});D.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 X=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});D.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)}]}});D.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 the tool REJECTS a plan whose features omit either, so set both on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards")})).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:X,endpoints:V})=>{let H=(M)=>new Promise((T5)=>setTimeout(T5,M)),G=(M)=>({content:[{type:"text",text:M}]}),N=(Z?.length??0)>0,K=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
|
|
235
|
+
`),C=(V?.length??0)>0||O5(`${$}
|
|
236
|
+
${K}`);if(!N&&C)return G("\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=C5(Q);if(M)return G(M)}let l=(Z?.length??0)+(V?.length??0)>0;await c("/api/plan",{description:$,draft:l?{tables:Z??[],relations:X??[],endpoints:V??[]}:void 0,features:Q?.length?Q:void 0}),await fetch(`${z0}/api/workspace/activate?id=${B0}`).catch(()=>{});let k5=Date.now()+g0;while(Date.now()<k5){await H(x0);let M=await E("/api/plan/verdict").catch(()=>null);if(!M)continue;if(M.kind==="feedback")return G("\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:
|
|
233
237
|
|
|
234
|
-
|
|
235
|
-
`+M.features.map((k5)=>` \u2022 ${k5}`).join(`
|
|
236
|
-
`)+"\n\nAs you SHIP each one, call `beacon_describe_feature` for it BY ITS EXACT TITLE (with the files you touched + a short summary) so it flips to Done. Do this per "+"feature \u2014 do NOT register only the umbrella, or the rest stay Pending on the map.":"";return j(`\u2705 Plan approved by the user. ${M.summary}`+(M.detail?`
|
|
238
|
+
`+M.feedback);if(M.kind==="approved")return G(`\u2705 Plan approved by the user. ${M.summary}`+(M.detail?`
|
|
237
239
|
|
|
238
240
|
Implement EXACTLY the schema below (migrations + code) \u2014 the user may have `+`edited columns on the canvas:
|
|
239
241
|
|
|
240
|
-
`+M.detail:"")+
|
|
242
|
+
`+M.detail:"")+h0(M.features));if(M.kind==="discarded")return G(`\u274C The user discarded the plan in Beacon. ${M.summary} Ask what they want to adjust before proposing again.`)}return G("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.")});D.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((G)=>setTimeout(G,H)),X=(H)=>({content:[{type:"text",text:H}]});await c("/api/plan",{description:$,markdown:Q}),await fetch(`${z0}/api/workspace/activate?id=${B0}`).catch(()=>{});let V=Date.now()+g0;while(Date.now()<V){await Z(x0);let H=await E("/api/plan/verdict").catch(()=>null);if(!H)continue;if(H.kind==="feedback")return X("\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:
|
|
241
243
|
|
|
242
244
|
`+H.feedback);if(H.kind==="approved")return X(`\u2705 Plan approved by the user. ${H.summary??""}`.trim()+(H.detail?`
|
|
243
245
|
|
|
244
246
|
Implement exactly what's on the board:
|
|
245
247
|
|
|
246
|
-
${H.detail}`:""));if(H.kind==="discarded")return X(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return X("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
|
|
247
|
-
`)}]}}D.registerResource("beacon-feature",new f0("feature://{slug}",{list:async()=>
|
|
248
|
+
${H.detail}`:"")+h0(H.features));if(H.kind==="discarded")return X(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return X("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 _5=($)=>Array.isArray($)?$[0]:$;async function G0($){return(await E(`/api/entities?kind=${$}`)).items}function L5($,Q){return{resources:$.map((Z)=>({uri:`${Q}${t(Z.title)}`,name:Z.title,description:`${Z.title}${Z.cluster?` \xB7 ${Z.cluster}`:""} \xB7 ${Z.status}`,mimeType:"text/markdown"}))}}async function I5($,Q,Z){let X=(await G0(Z)).find((N)=>t(N.title)===_5(Q));if(!X)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await E("/api/entities?kind=tables")).items??[]).map((N)=>N.name),G=[`# ${X.title}`];if(X.cluster)G.push(`*Domain:* \`${X.cluster}\``);if(X.status)G.push(`*Status:* \`${X.status}\``);if(G.push(""),G.push(X.plain?.trim()||"(this node has no description yet \u2014 add one on Beacon's /map page)"),G.push("","## Existing DB tables in this project"),G.push(H.length?H.join(", "):"(none yet)"),Z==="features"){let N=await G0("features"),K=[...new Set(N.map((C)=>C.cluster?.trim()).filter((C)=>!!C))].sort();G.push("","## Existing feature categories \u2014 reuse one before inventing a new one"),G.push(K.length?K.join(", "):"(none yet)"),G.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:G.join(`
|
|
249
|
+
`)}]}}D.registerResource("beacon-feature",new f0("feature://{slug}",{list:async()=>L5(await G0("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})=>I5($,Q,"features"));D.registerResource("beacon-component",new f0("component://{slug}",{list:async()=>L5(await G0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>I5($,Q,"architecture"));async function R5(){return await E("/api/notes")}D.registerResource("beacon-note",new f0("note://{slug}",{list:async()=>D5(await R5())}),{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=F5(await R5(),_5(Q)),X=Z?v5(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:X}]}});await D.connect(new Q$);var H0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(H0===-1)H0=$;else if($!==H0)H0=$,D.sendResourceListChanged()}catch{}},w5);
|