trybeacon 0.1.80 → 0.1.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +18 -18
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +2 -2
- package/.next/server/app/_not-found/page.js.nft.json +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 +26 -25
- package/.next/server/app/_not-found.segments/_full.segment.rsc +26 -25
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +15 -14
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs/page.js +2 -2
- package/.next/server/app/docs/page.js.nft.json +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 +27 -26
- package/.next/server/app/docs.segments/_full.segment.rsc +27 -26
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +15 -14
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/help/page.js +2 -2
- package/.next/server/app/help/page.js.nft.json +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +35 -34
- package/.next/server/app/help.segments/_full.segment.rsc +35 -34
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +15 -14
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +25 -24
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +25 -24
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +15 -14
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/learn/page.js +4 -4
- package/.next/server/app/learn/page.js.nft.json +1 -1
- package/.next/server/app/learn/page_client-reference-manifest.js +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.js +2 -2
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +3 -3
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/s/[token]/page.js +2 -2
- package/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +2 -2
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +18 -18
- package/.next/server/chunks/{7720.js → 141.js} +4 -4
- package/.next/server/chunks/2025.js +1 -1
- package/.next/server/chunks/2455.js +1 -0
- package/.next/server/chunks/3174.js +1 -1
- package/.next/server/chunks/3179.js +1 -0
- package/.next/server/chunks/6469.js +2 -2
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/1909-0f500ebe4df09208.js +1 -0
- package/.next/static/chunks/{3908-80efc60050779adf.js → 3908-2ba88cd8ba5dfa2e.js} +1 -1
- package/.next/static/chunks/{2059-fba06ba63ba64522.js → 4674-31ad596c3e856647.js} +3 -3
- package/.next/static/chunks/4752-81a4fc25de32efa2.js +1 -0
- package/.next/static/chunks/4853-43350f60d0d9135b.js +1 -0
- package/.next/static/chunks/6639-f0b63e1e7d03a20a.js +1 -0
- package/.next/static/chunks/9784-880aab43467bf1e0.js +1 -0
- package/.next/static/chunks/app/layout-ef1edf5ed5839b01.js +1 -0
- package/.next/static/chunks/app/learn/page-6459c292421bec82.js +7 -0
- package/.next/static/chunks/app/map/page-602309791f192143.js +1 -0
- package/.next/static/chunks/app/page-32a051917fc57795.js +1 -0
- package/.next/static/chunks/app/plan/page-920d4fecdd6dde34.js +11 -0
- package/.next/static/chunks/app/s/[token]/page-1df7929974ceeb5a.js +1 -0
- package/.next/static/chunks/app/settings/page-f128ae102e013087.js +1 -0
- package/.next/static/css/9301599114d42898.css +1 -0
- package/.next/trace +47 -46
- package/.next/trace-build +1 -1
- package/dist/bin/beacon.js +16 -15
- package/dist/bin/doctor.js +61 -60
- package/dist/bin/hook.js +58 -57
- package/dist/bin/mcp.js +70 -69
- package/dist/bin/plan.js +61 -60
- package/dist/bin/uninstall.js +59 -58
- package/dist/lib/assets.js +55 -20
- package/dist/lib/codex-install.js +62 -61
- package/dist/lib/daemon-boot.js +37 -0
- package/dist/lib/global-install.js +62 -61
- package/package.json +1 -1
- package/.next/server/chunks/5295.js +0 -1
- package/.next/server/chunks/7652.js +0 -1
- package/.next/static/chunks/1909-98243a0473be2aae.js +0 -1
- package/.next/static/chunks/4477-cda153702c7812d2.js +0 -1
- package/.next/static/chunks/4607-a668ea431c41e60e.js +0 -1
- package/.next/static/chunks/4853-0082a1e1b820a293.js +0 -1
- package/.next/static/chunks/5520-32e29b8bbff59f44.js +0 -1
- package/.next/static/chunks/app/layout-e728d45f193e3b95.js +0 -1
- package/.next/static/chunks/app/learn/page-fc0bf8bce602526b.js +0 -7
- package/.next/static/chunks/app/map/page-847b374e7dfed924.js +0 -1
- package/.next/static/chunks/app/page-ec00130a7a249f14.js +0 -1
- package/.next/static/chunks/app/plan/page-1108bdf804b8a1bd.js +0 -11
- package/.next/static/chunks/app/s/[token]/page-2fc7806fc2f205a5.js +0 -1
- package/.next/static/chunks/app/settings/page-7e86fd456b92c248.js +0 -1
- package/.next/static/css/6eabb17c2a2081f2.css +0 -1
- /package/.next/static/{zI2f5SCpeUG4MfjJNbXnf → ms-hAcPFSz7LxuiDMzzcP}/_buildManifest.js +0 -0
- /package/.next/static/{zI2f5SCpeUG4MfjJNbXnf → ms-hAcPFSz7LxuiDMzzcP}/_ssgManifest.js +0 -0
package/dist/bin/plan.js
CHANGED
|
@@ -1,22 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var pZ=Object.defineProperty;var cZ=(Q)=>Q;function lZ(Q,Z){this[Q]=cZ.bind(null,Z)}var HQ=(Q,Z)=>{for(var $ in Z)pZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:lZ.bind(Z,$)})};var C=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);import{existsSync as D,mkdirSync as GQ,readdirSync as dZ,readFileSync as w,rmSync as sZ,writeFileSync as k}from"fs";import{basename as tZ,dirname as mQ,join as N}from"path";function pQ(){return!!process.env.CLAUDE_PLUGIN_ROOT}function cQ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;let Z=N(Q,".claude","plugins");if(!D(Z))return null;let $=[Z];for(let Y=0;Y<3&&$.length;Y++){let J=[];for(let V of $){let q=N(V,".claude-plugin","plugin.json");try{if(D(q)&&JSON.parse(w(q,"utf8")).name==="beacon")return V}catch{}try{for(let W of dZ(V,{withFileTypes:!0}))if(W.isDirectory())J.push(N(V,W.name))}catch{}}$=J}return null}function lQ(Q){return cQ(Q)!==null}function aZ(Q){return/[\\/]\.claude[\\/]plugins[\\/]/.test(Q)}function M(){let Q=process.env.BEACON_CLI_PATH;if(Q)return Q;if(D(hQ))return hQ;return"beacon"}function jQ(Q){let Z=Q.indexOf(" ");return Z===-1?Q:Q.slice(0,Z)}function _(Q){let Z=M();if(Z==="beacon")return Q;return Q.replace(/^beacon(\s|$)/,`${Z}$1`)}function x(Q){let Z=jQ(Q);return tZ(Z)+Q.slice(Z.length)}function rZ(Q=process.env.HOME||process.env.USERPROFILE||""){if(!Q)return null;try{let Z=JSON.parse(w(N(Q,".claude","plugins","installed_plugins.json"),"utf8"));for(let $ of Object.keys(Z.plugins??{}))if(/^beacon@/.test($))return{key:$,marketplace:$.split("@")[1]??""}}catch{}return null}function h(Q){try{return JSON.parse(w(Q,"utf8"))}catch{return{}}}function dQ(Q,Z){GQ(mQ(Q),{recursive:!0}),k(Q,JSON.stringify(Z,null,2)+`
|
|
4
|
+
`)}function m(Q,Z){let $=h(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>x(q.command)===x(Z.command))))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),dQ(Q,$),!0}function p(Q,Z){return(h(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>x(V.command)===x(Z.command)))}function sQ(Q,Z){let Y=h(Q).hooks?.[Z.event]??[];for(let J of Y)for(let V of J.hooks??[])if(x(V.command)===x(Z.command))return V.command;return null}function c(Q,Z){let $=h(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((q)=>{let W=q.hooks?.length??0,z=(q.hooks??[]).filter((U)=>x(U.command)!==x(Z.command));if(z.length!==W)J=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!J)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return dQ(Q,$),!0}function l(Q,Z,$,Y){let J=`${Z}
|
|
5
|
+
${Y.trim()}
|
|
6
|
+
${$}`,V="";try{V=w(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
|
|
7
|
+
|
|
8
|
+
${J}
|
|
9
|
+
`:`${J}
|
|
10
|
+
`,GQ(mQ(Q),{recursive:!0}),k(Q,V.endsWith(`
|
|
11
|
+
`)?V:`${V}
|
|
12
|
+
`)}function A(Q,Z){try{return w(Q,"utf8").includes(Z)}catch{return!1}}function d(Q,Z,$){let Y="";try{Y=w(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
|
|
13
|
+
|
|
14
|
+
`).trimStart();return k(Q,V),!0}function s(Q,Z,$){let Y=N(Q,Z);GQ(Y,{recursive:!0});let J=N(Y,"SKILL.md");return k(J,$),J}function u(Q,Z){return D(N(Q,Z,"SKILL.md"))}function t(Q,Z){let $=N(Q,Z);if(!D($))return!1;return sZ($,{recursive:!0,force:!0}),!0}var P,hQ="/Applications/Beacon.app/Contents/Resources/bin/beacon",S=`## Beacon (visual planning panel)
|
|
15
|
+
|
|
16
|
+
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
17
|
+
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
18
|
+
the user reviews on a canvas at /plan, and feedback flows back as the next round.
|
|
19
|
+
|
|
20
|
+
**When to invoke**
|
|
21
|
+
- User asks to "plan a feature" / "design a schema" \u2192 if the \`beacon_propose_plan\`
|
|
22
|
+
MCP tool is available, design the plan and call it. If it is NOT available, the panel
|
|
23
|
+
isn't wired in this repo \u2014 run \`beacon\` here once, then retry.
|
|
24
|
+
- User asks to "set up Beacon" / "map this repo" \u2192 invoke the \`beacon-init\` skill.
|
|
25
|
+
- User asks to "refresh Beacon" / "update the map" / "bring Beacon up to date" \u2192 invoke
|
|
26
|
+
the \`beacon-refresh\` skill. Re-surveys the repo and updates init-derived nodes while
|
|
27
|
+
preserving anything the user added by hand.
|
|
28
|
+
- User asks to "explain" / "teach me" / "walk me through" / "how does X work" \u2192 if the
|
|
29
|
+
\`beacon_explain\` MCP tool is available, author an interactive Lesson (a concept map +
|
|
30
|
+
plain-English narrative on /learn the user questions back) via the \`beacon-explain\` skill.
|
|
31
|
+
- Run \`beacon doctor\` to audit what's wired (global hooks, repo's .mcp.json, AGENTS.md block).
|
|
32
|
+
|
|
33
|
+
**The plan feedback loop**
|
|
34
|
+
\`beacon_propose_plan\` BLOCKS until the user clicks Approve / Discard / submits feedback.
|
|
35
|
+
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
36
|
+
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
37
|
+
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
38
|
+
verbatim. Do NOT implement until the tool returns approval.`;var a=C(()=>{P=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});var tQ=1500,aQ=480000,h1=1800000,r=3600000,m1=3000;var KQ=()=>{};var vQ={};HQ(vQ,{stripAgentsPointer:()=>iQ,repoMcpCliTarget:()=>J0,removeRepoAssets:()=>z0,installRefreshSkill:()=>oZ,installPlanSkill:()=>iZ,installInitSkill:()=>nZ,installExplainSkill:()=>eZ,installCodexRepoSkills:()=>Z0,ensureWorkflowDoc:()=>$0,ensureMcp:()=>Y0,contextDocTargets:()=>PQ,auditRepo:()=>V0,REFRESH_SKILL:()=>NQ,PLAN_SKILL:()=>nQ,INIT_SKILL:()=>BQ,EXPLAIN_SKILL:()=>oQ});import{existsSync as K,mkdirSync as f,readFileSync as B,rmSync as n,writeFileSync as G}from"fs";import{join as X}from"path";function nZ(Q){let Z=X(Q,".claude","skills","beacon-init");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return G($,BQ),$}function oZ(Q){let Z=X(Q,".claude","skills","beacon-refresh");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return G($,NQ),$}function iZ(Q){let Z=X(Q,".claude","skills","beacon-plan");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return G($,nQ),$}function eZ(Q){let Z=X(Q,".claude","skills","beacon-explain");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return G($,oQ),$}function Z0(Q){let Z=[];for(let $ of Q0){let Y=X(Q,".agents","skills",$.name);f(Y,{recursive:!0});let J=X(Y,"SKILL.md");G(J,$.body()),Z.push(J)}return Z}function PQ(Q){let Z=X(Q,"AGENTS.md"),$=X(Q,"CLAUDE.md"),Y=K(Z),J=K($);if(!Y&&!J)return[Z,$];let V=[];if(Y)V.push(Z);if(J)V.push($);return V}function iQ(Q){let Z=X(Q,"CLAUDE.md");if(!K(Z))return;let $=B(Z,"utf8"),Y=$.split(`
|
|
4
39
|
`).filter((J)=>!/^\s*@\.?\/?AGENTS\.md\s*$/.test(J)).join(`
|
|
5
|
-
`).trim();if(Y&&Y!==$.trim())
|
|
6
|
-
`)}function
|
|
40
|
+
`).trim();if(Y&&Y!==$.trim())G(Z,`${Y}
|
|
41
|
+
`)}function $0(Q){let Z=new RegExp(`${o}[\\s\\S]*?${xQ}`);for(let $ of PQ(Q)){let Y="";try{Y=B($,"utf8")}catch{}Y=Z.test(Y)?Y.replace(Z,rQ):`${Y.trim()}
|
|
7
42
|
|
|
8
|
-
${
|
|
9
|
-
`.trimStart(),
|
|
43
|
+
${rQ}
|
|
44
|
+
`.trimStart(),G($,Y.endsWith(`
|
|
10
45
|
`)?Y:`${Y}
|
|
11
|
-
`)}
|
|
12
|
-
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:
|
|
13
|
-
`),{path:Z,added:!0,updated:!1}}function
|
|
14
|
-
`)}}catch{}let J=!1,V=new RegExp(`\\n?${
|
|
46
|
+
`)}iQ(Q)}function Y0(Q){let Z=X(Q,".mcp.json"),$={};try{$=JSON.parse(B(Z,"utf8"))}catch{}$.mcpServers=$.mcpServers??{};let Y=$.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<r)return Y.timeout=r,G(Z,JSON.stringify($,null,2)+`
|
|
47
|
+
`),{path:Z,added:!1,updated:!0};return{path:Z,added:!1,updated:!1}}return $.mcpServers.beacon={command:M(),args:["mcp"],timeout:r},G(Z,JSON.stringify($,null,2)+`
|
|
48
|
+
`),{path:Z,added:!0,updated:!1}}function J0(Q){try{return JSON.parse(B(X(Q,".mcp.json"),"utf8")).mcpServers?.beacon?.command??null}catch{return null}}function V0(Q){let Z=X(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(B(Z,"utf8")).mcpServers?.beacon}catch{}let Y=PQ(Q).some((J)=>{try{return B(J,"utf8").includes(o)}catch{return!1}});return{repo:Q,mcpRegistered:$,workflowBlock:Y,skills:{"beacon-init":K(X(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":K(X(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":K(X(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":K(X(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function z0(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let U=X(Q,".claude","skills",z);if(K(U))n(U,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let U=X(Q,".agents","skills",z);if(K(U))n(U,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=X(Q,".mcp.json");try{let z=JSON.parse(B(Y,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)n(Y,{force:!0});else G(Y,JSON.stringify(z,null,2)+`
|
|
49
|
+
`)}}catch{}let J=!1,V=new RegExp(`\\n?${o}[\\s\\S]*?${xQ}\\n?`);for(let z of[X(Q,"AGENTS.md"),X(Q,"CLAUDE.md")])try{let U=B(z,"utf8");if(V.test(U)){let H=U.replace(V,`
|
|
15
50
|
`).replace(/\n{3,}/g,`
|
|
16
51
|
|
|
17
|
-
`).trimStart();
|
|
52
|
+
`).trimStart();G(z,H.endsWith(`
|
|
18
53
|
`)?H:`${H}
|
|
19
|
-
`),J=!0}}catch{}let q=!1,W=
|
|
54
|
+
`),J=!0}}catch{}let q=!1,W=X(Q,"CLAUDE.md");try{let z=B(W,"utf8"),U=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(U!==z){if(!U.trim())n(W,{force:!0});else G(W,U);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:q}}var BQ=`---
|
|
20
55
|
name: beacon-init
|
|
21
56
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
22
57
|
---
|
|
@@ -63,7 +98,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
|
|
|
63
98
|
That one command wires the repo (writes \`.mcp.json\` + skills so your NEXT session gets the \`beacon_*\` tools natively, heals the global install), starts the Beacon daemon if it isn't running, registers + provisions this workspace, and POSTs your analysis to the same \`/api/init\` endpoint the MCP tool uses \u2014 so init completes in THIS session. Read the counts it prints and report them.
|
|
64
99
|
|
|
65
100
|
After the tool (or \`beacon init-persist\`) returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
|
|
66
|
-
`,
|
|
101
|
+
`,NQ=`---
|
|
67
102
|
name: beacon-refresh
|
|
68
103
|
description: Re-survey the repo and update Beacon's architecture / schema / endpoints map after /beacon-init was already run \u2014 picks up new components, removed ones, schema changes, and new routes. Use when the user runs /beacon-refresh or asks to "refresh", "update", "re-sync", or "bring Beacon up to date" with the current code.
|
|
69
104
|
---
|
|
@@ -110,7 +145,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
110
145
|
If \`beacon_entities\` or \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-refresh.
|
|
111
146
|
|
|
112
147
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
113
|
-
`,
|
|
148
|
+
`,nQ=`---
|
|
114
149
|
name: beacon-plan
|
|
115
150
|
description: Present your current plan or approach to the user on Beacon's /plan canvas for review \u2014 instead of asking for approval in prose. Use when the user says "present the plan", "show me the plan", "let me see it / the plan", or whenever you are about to end a turn asking whether to proceed with a plan, design, or approach.
|
|
116
151
|
---
|
|
@@ -159,7 +194,7 @@ If it returns feedback, revise and call it again.
|
|
|
159
194
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
160
195
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
161
196
|
run \`beacon\` in this repo once.
|
|
162
|
-
`,
|
|
197
|
+
`,oQ=`---
|
|
163
198
|
name: beacon-explain
|
|
164
199
|
description: Teach the user part of THIS codebase as an interactive visual lesson on Beacon's /learn page \u2014 a concept map + plain-English narrative they can question \u2014 instead of a wall of text. Use when the user says "explain", "teach me", "walk me through", "how does X work", or "help me understand the Y category".
|
|
165
200
|
---
|
|
@@ -229,7 +264,7 @@ so the learner sees the table IN CONTEXT, wired to the code that uses it.
|
|
|
229
264
|
Every answer must ADD understanding (rationale, trade-off) \u2014 never just restate the question. Expand
|
|
230
265
|
the narrative or add nodes where it helps. Keep looping until the tool reports the user saved or closed
|
|
231
266
|
the lesson.
|
|
232
|
-
`,
|
|
267
|
+
`,Q0,o="<!-- beacon:workflow:start -->",xQ="<!-- beacon:workflow:end -->",rQ;var MQ=C(()=>{a();KQ();Q0=[{name:"beacon-init",body:()=>BQ},{name:"beacon-refresh",body:()=>NQ}];rQ=`${o}
|
|
233
268
|
## Beacon \u2014 feature workflow
|
|
234
269
|
|
|
235
270
|
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:
|
|
@@ -301,59 +336,25 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
301
336
|
If the feature added or materially changed a REAL architectural component (a subsystem \u2014 NOT a file), also pass \`architecture: [{ title, domain, role, \u2026 }]\` so the Architecture map stays accurate. It upserts curated components by title; never list files as components. If you found a bug or something worth investigating in a component's code, add \`bugs: [{ note }]\` to its architecture entry \u2014 it renders as a bug flag on the node (attributed to the agent); identical open flags are not duplicated. Only flag what you actually saw in the code.
|
|
302
337
|
|
|
303
338
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
304
|
-
${
|
|
305
|
-
`)
|
|
306
|
-
${Y.trim()}
|
|
307
|
-
${$}`,V="";try{V=T(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
|
|
308
|
-
|
|
309
|
-
${J}
|
|
310
|
-
`:`${J}
|
|
311
|
-
`,GQ(pQ(Q),{recursive:!0}),k(Q,V.endsWith(`
|
|
312
|
-
`)?V:`${V}
|
|
313
|
-
`)}function w(Q,Z){try{return T(Q,"utf8").includes(Z)}catch{return!1}}function c(Q,Z,$){let Y="";try{Y=T(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
|
|
314
|
-
|
|
315
|
-
`).trimStart();return k(Q,V),!0}function l(Q,Z,$){let Y=x(Q,Z);GQ(Y,{recursive:!0});let J=x(Y,"SKILL.md");return k(J,$),J}function g(Q,Z){return L(x(Q,Z,"SKILL.md"))}function d(Q,Z){let $=x(Q,Z);if(!L($))return!1;return nZ($,{recursive:!0,force:!0}),!0}var N,_=`## Beacon (visual planning panel)
|
|
316
|
-
|
|
317
|
-
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
318
|
-
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
319
|
-
the user reviews on a canvas at /plan, and feedback flows back as the next round.
|
|
320
|
-
|
|
321
|
-
**When to invoke**
|
|
322
|
-
- User asks to "plan a feature" / "design a schema" \u2192 if the \`beacon_propose_plan\`
|
|
323
|
-
MCP tool is available, design the plan and call it. If it is NOT available, the panel
|
|
324
|
-
isn't wired in this repo \u2014 run \`beacon\` here once, then retry.
|
|
325
|
-
- User asks to "set up Beacon" / "map this repo" \u2192 invoke the \`beacon-init\` skill.
|
|
326
|
-
- User asks to "refresh Beacon" / "update the map" / "bring Beacon up to date" \u2192 invoke
|
|
327
|
-
the \`beacon-refresh\` skill. Re-surveys the repo and updates init-derived nodes while
|
|
328
|
-
preserving anything the user added by hand.
|
|
329
|
-
- User asks to "explain" / "teach me" / "walk me through" / "how does X work" \u2192 if the
|
|
330
|
-
\`beacon_explain\` MCP tool is available, author an interactive Lesson (a concept map +
|
|
331
|
-
plain-English narrative on /learn the user questions back) via the \`beacon-explain\` skill.
|
|
332
|
-
- Run \`beacon doctor\` to audit what's wired (global hooks, repo's .mcp.json, AGENTS.md block).
|
|
333
|
-
|
|
334
|
-
**The plan feedback loop**
|
|
335
|
-
\`beacon_propose_plan\` BLOCKS until the user clicks Approve / Discard / submits feedback.
|
|
336
|
-
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
337
|
-
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
338
|
-
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
339
|
-
verbatim. Do NOT implement until the tool returns approval.`;var KQ=M(()=>{N=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});import{mkdirSync as rZ,renameSync as oZ,rmSync as iZ,writeFileSync as eZ}from"fs";import{dirname as Q0}from"path";function a(Q,Z){rZ(Q0(Q),{recursive:!0});let $=`${Q}.tmp`;try{eZ($,Z),oZ($,Q)}catch(Y){throw iZ($,{force:!0}),Y}}function b1(Q,Z,$=!1){a(Q,JSON.stringify(Z,null,$?2:void 0))}var nQ=()=>{};var ZZ={};VQ(ZZ,{setupCodexAssets:()=>J0,removeCodexMcp:()=>QZ,removeCodexArtifacts:()=>z0,hasCodexMcp:()=>vQ,ensureCodexMcp:()=>eQ,codexMcpProblem:()=>Y0,codexDetected:()=>rQ,auditCodex:()=>V0,CODEX_HOOKS:()=>o});import{readFileSync as r}from"fs";import{homedir as Z0}from"os";import{join as f}from"path";function sQ(){return process.env.HOME||process.env.USERPROFILE||Z0()}function rQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(xQ===void 0)xQ=Bun.which("codex")!==null;return xQ}function O(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function vQ(){try{return Boolean(O(r(F(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function Y0(){let Q="";try{Q=r(F(),"utf8")}catch{return null}let Z=O(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${D}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${D}`;return null}function eQ(){let Q="",Z=!1;try{Q=r(F(),"utf8"),Z=!0}catch{}if(Z){let V=O(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${D}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${D}`}}let $=!Q?"":Q.endsWith(`
|
|
339
|
+
${xQ}`});import{mkdirSync as q0,renameSync as X0,rmSync as U0,writeFileSync as W0}from"fs";import{dirname as H0}from"path";function i(Q,Z){q0(H0(Q),{recursive:!0});let $=`${Q}.tmp`;try{W0($,Z),X0($,Q)}catch(Y){throw U0($,{force:!0}),Y}}function r1(Q,Z,$=!1){i(Q,JSON.stringify(Z,null,$?2:void 0))}var eQ=()=>{};var WZ={};HQ(WZ,{setupCodexAssets:()=>M0,removeCodexMcp:()=>UZ,removeCodexArtifacts:()=>T0,parseTomlBeacon:()=>qZ,nodeWhich:()=>$Z,hasCodexMcp:()=>CQ,ensureCodexMcp:()=>XZ,commandExists:()=>YZ,codexMcpProblem:()=>P0,codexMcpCliTarget:()=>v0,codexDetected:()=>JZ,auditCodex:()=>R0,CODEX_HOOKS:()=>$Q});import{accessSync as G0,constants as j0,readFileSync as I}from"fs";import{homedir as K0}from"os";import{delimiter as B0,join as O}from"path";function QZ(){return process.env.HOME||process.env.USERPROFILE||K0()}function $Z(Q,Z=process.env.PATH||"",$=N0){if(!Q)return null;for(let Y of Z.split(B0)){if(!Y)continue;let J=O(Y,Q);if($(J))return J}return null}function N0(Q){try{return G0(Q,j0.X_OK),!0}catch{return!1}}function YZ(Q){if(typeof Bun<"u"&&typeof Bun.which==="function")return Bun.which(Q)!==null;return $Z(Q)!==null}function JZ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(RQ===void 0)RQ=YZ("codex");return RQ}function qZ(Q){let Z={},$=!1;for(let Y of Q.split(`
|
|
340
|
+
`)){let J=Y.trim();if(!J||J.startsWith("#"))continue;let V=/^\[([^\]]+)\]/.exec(J);if(V){if($=V[1].trim()==="mcp_servers.beacon",$)Z.mcp_servers=Z.mcp_servers??{},Z.mcp_servers.beacon=Z.mcp_servers.beacon??{};continue}if($){let q=/^command\s*=\s*["']([^"']*)["']/.exec(J);if(q)Z.mcp_servers.beacon.command=q[1]}}return Z}function g(Q){try{if(typeof Bun<"u"&&Bun.TOML?.parse)return Bun.TOML.parse(Q);return qZ(Q)}catch{return null}}function CQ(){try{return Boolean(g(I(R(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function P0(){let Q="";try{Q=I(R(),"utf8")}catch{return null}let Z=g(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${E}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${E}`;return null}function XZ(){let Q="",Z=!1;try{Q=I(R(),"utf8"),Z=!0}catch{}if(Z){let V=g(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${E}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${E}`}}let $=!Q?"":Q.endsWith(`
|
|
340
341
|
`)?`
|
|
341
342
|
`:`
|
|
342
343
|
|
|
343
|
-
`,Y=Q
|
|
344
|
-
`),$=Z.indexOf(
|
|
344
|
+
`,Y=Q+$+x0();if(g(Y)?.mcp_servers?.beacon?.command!==M())return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${E}`};return i(R(),Y),{added:!0}}function v0(){try{return g(I(R(),"utf8"))?.mcp_servers?.beacon?.command??null}catch{return null}}function UZ(){let Q="";try{Q=I(R(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
345
|
+
`),$=Z.indexOf(VZ);if($===-1)return{removed:!1,skipped:CQ()};let Y=Z.indexOf(zZ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
|
|
345
346
|
`).replace(/\n{3,}/g,`
|
|
346
347
|
|
|
347
|
-
`).replace(/^\n+/,"");if(
|
|
348
|
+
`).replace(/^\n+/,"");if(g(J)===null)return{removed:!1,skipped:!0};return i(R(),J),{removed:!0}}async function M0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:Y}=await Promise.resolve().then(() => (MQ(),vQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":Y},V=[];for(let U of P){if(!u(QQ(),U))V.push(U);s(QQ(),U,J[U])}let q=0;for(let U of $Q)if(m(FQ(),{event:U.event,matcher:U.matcher,command:_(U.command)}))q++;let W=A(e(),ZQ);l(e(),ZQ,ZZ,S);let z=XZ();return{skillsAdded:V,hooksAdded:q,agentsMdBlockTouched:!W,mcp:z}}function R0(){let Q={};for(let $ of P)Q[$]=u(QQ(),$);let Z={};for(let $ of $Q)Z[$.event]=p(FQ(),{event:$.event,command:$.command});return{detected:JZ(),skills:Q,hooks:Z,agentsMdBlock:A(e(),ZQ),mcp:CQ()}}function T0(){let Q=[];for(let J of P)if(t(QQ(),J))Q.push(J);let Z=0;for(let J of $Q)if(c(FQ(),{event:J.event,command:J.command}))Z++;let $=d(e(),ZQ,ZZ),Y=UZ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var TQ=()=>O(QZ(),".codex"),FQ=()=>O(TQ(),"hooks.json"),R=()=>O(TQ(),"config.toml"),e=()=>O(TQ(),"AGENTS.md"),QQ=()=>O(QZ(),".agents","skills"),ZQ="<!-- beacon:global:start -->",ZZ="<!-- beacon:global:end -->",$Q,RQ,VZ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",zZ="# beacon:end",x0=()=>`${VZ}
|
|
348
349
|
[mcp_servers.beacon]
|
|
349
|
-
command = "
|
|
350
|
+
command = "${M()}"
|
|
350
351
|
args = ["mcp"]
|
|
351
|
-
${
|
|
352
|
-
`});var XZ={};VQ(XZ,{provisionDb:()=>E0});import{createClient as C0}from"@libsql/client";import{drizzle as M0}from"drizzle-orm/libsql";import{migrate as T0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as F0}from"drizzle-orm/migrator";import{dirname as wQ,join as R0}from"path";import{fileURLToPath as w0}from"url";async function QQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function f0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function qZ(Q){if(!await QQ(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function u0(Q){for(let[Z,$]of Object.entries(O0)){if(!await QQ(Q,Z))continue;let Y=await f0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function E0(Q,Z=D0){let $=C0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await QQ($,"__drizzle_migrations"),J=await QQ($,"Node"),V=!1;if(J&&!Y){let W=F0({migrationsFolder:Z})[0];if(W)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[W.hash,W.folderMillis]}),V=!0}let q=await qZ($);if(await T0(M0($),{migrationsFolder:Z}),await qZ($)>q)V=!0;return await u0($),{migrated:V}}finally{$.close()}}var g0,D0,O0;var UZ=M(async()=>{g0=wQ(wQ(wQ(w0(import.meta.url)))),D0=process.env.BEACON_MIGRATIONS_DIR||R0(g0,"drizzle"),O0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});KQ();import{existsSync as q0}from"fs";import{homedir as X0}from"os";import{join as i}from"path";function U0(){return process.env.HOME||process.env.USERPROFILE||X0()}var e=()=>i(U0(),".claude"),CQ=()=>i(e(),"skills"),MQ=()=>i(e(),"settings.json"),TQ=()=>i(e(),"CLAUDE.md"),FQ="<!-- beacon:global:start -->",YZ="<!-- beacon:global:end -->";var W0=_,RQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract: in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. Fail-open when there's no active contract."},{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:"PreToolUse",matcher:"AskUserQuestion",command:"beacon ask",description:"Surface the agent's AskUserQuestion in Beacon's modal; your pick flows back as the answer (falls through to the terminal if Beacon isn't open)."},{event:"PermissionRequest",matcher:"Edit|Write|MultiEdit|Bash|NotebookEdit",command:"beacon ask",description:"Surface edit/create/run approvals in Beacon's modal; your allow/deny flows back (falls through to the terminal prompt if Beacon isn't open)."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function H0(Q,Z){return l(CQ(),Q,Z)}function JZ(Q){return g(CQ(),Q)}function B0(Q){return d(CQ(),Q)}function G0(Q){return S(MQ(),Q)}function j0(Q){return h(MQ(),Q)}function K0(Q){return m(MQ(),Q)}function x0(Q){p(TQ(),FQ,YZ,Q)}function VZ(){return w(TQ(),FQ)}function N0(){return c(TQ(),FQ,YZ)}function c1(){let Q={};for(let $ of N)Q[$]=JZ($);let Z={};for(let $ of RQ)Z[$.event]=j0({event:$.event,command:$.command});return{homeExists:q0(e()),skills:Q,hooks:Z,claudeMdBlock:VZ()}}async function P0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:Y}=await Promise.resolve().then(() => (BQ(),HQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":Y},V=[];for(let z of N){if(!JZ(z))V.push(z);H0(z,J[z])}let q=0;for(let z of RQ)if(G0({event:z.event,matcher:z.matcher,command:z.command}))q++;let W=VZ();return x0(W0),{skillsAdded:V,hooksAdded:q,claudeMdBlockTouched:!W}}async function zZ(){if(cQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(dQ()){try{v0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await P0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => ($Z(),ZZ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function v0(){let Q=[];for(let Y of N)if(B0(Y))Q.push(Y);let Z=0;for(let Y of RQ)if(K0(Y))Z++;let $=N0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as b0}from"async_hooks";import{spawnSync as A0}from"child_process";import{createHash as I0}from"crypto";import{existsSync as HZ,mkdirSync as E,readFileSync as DQ,writeFileSync as OQ}from"fs";import{homedir as BZ}from"os";import{basename as y0,join as P,parse as L0,resolve as WZ}from"path";function G(){return process.env.BEACON_HOME||P(BZ(),".beacon")}function fQ(){return P(G(),"workspaces.json")}function u(Q){return I0("sha256").update(Q).digest("hex").slice(0,12)}function k0(Q=process.cwd()){let Z=A0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function GZ(Q){let Z=WZ(Q);return Z!==WZ(BZ())&&Z!==L0(Z).root}function jZ(){return P(G(),"deleted.json")}function uQ(){try{let Q=JSON.parse(DQ(jZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function KZ(Q){E(G(),{recursive:!0}),OQ(jZ(),JSON.stringify(Q,null,2))}function xZ(Q){return uQ().includes(Q)}function Y2(Q){let Z=uQ();if(!Z.includes(Q))KZ([...Z,Q])}function _0(Q){let Z=uQ();if(Z.includes(Q))KZ(Z.filter(($)=>$!==Q))}function ZQ(Q){return P(G(),Q)}function S0(Q){return`file:${P(ZQ(Q),"db.sqlite")}`}function b(){try{let Q=JSON.parse(DQ(fQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function EQ(Q){E(G(),{recursive:!0}),OQ(fQ(),JSON.stringify(Q,null,2))}function NZ(){return b().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function v(Q){return b().find((Z)=>Z.id===Q)??null}function PZ(Q,Z,$=new Date().toISOString()){if(!GZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=u(Q);if(xZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=b(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||y0(Q),lastOpenedAt:$},W=[q,...J.filter((z)=>z.id!==Y)];return E(ZQ(Y),{recursive:!0}),EQ(W),q}function J2(Q,Z){return _0(u(Q)),PZ(Q,Z)}function V2(Q,Z=new Date().toISOString()){let $=b(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,EQ($)}function z2(Q){if(EQ(b().filter((Z)=>Z.id!==Q)),bQ()===Q)h0(NZ()[0]?.id??null)}function vZ(){return P(G(),"active")}function bQ(){try{return DQ(vZ(),"utf8").trim()||null}catch{return null}}function h0(Q){E(G(),{recursive:!0}),OQ(vZ(),Q??"")}function q2(){let Q=bQ();return Q?v(Q):null}function X2(){let Q=p0()??bQ();return Q?v(Q):null}function U2(Q){return v(Q)?.path??null}function W2(){return HZ(fQ())}var CZ="beacon_ws";function MZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function H2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&v(Z))return Z;let $=MZ(Q,CZ);if($&&v($))return $;return m0()}function m0(){let Q=NZ();return Q.length===1?Q[0].id:null}var TZ="x-beacon-workspace-path";function B2(Q=process.cwd()){let Z=k0(Q);return{"x-beacon-workspace":u(Z),[TZ]:Z}}async function G2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&v(Z))return Z;let $=Q.headers.get(TZ);if($&&GZ($)&&!xZ(u($))&&(!Z||u($)===Z)){let J=PZ($);return await c0(J.id),J.id}let Y=MZ(Q,CZ);if(Y&&v(Y))return Y;return null}var FZ=new b0;function j2(Q,Z){return Q?FZ.run(Q,Z):Z()}function p0(){return FZ.getStore()??null}var gQ=new Set;function K2(Q){gQ.delete(P(ZQ(Q),"db.sqlite"))}async function c0(Q){let Z=ZQ(Q),$=P(Z,"db.sqlite"),Y=HZ($);if(Y&&gQ.has($))return{ok:!0,created:!1,migrated:!1};try{E(Z,{recursive:!0});let{provisionDb:J}=await UZ().then(() => XZ),V=await J(S0(Q));return gQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as l0}from"net";var P2=4319;function d0(Q,Z,$=400){return new Promise((Y)=>{let J=l0({host:Q,port:Z}),V=!1,q=(W)=>{if(V)return;V=!0,J.destroy(),Y(W)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function a0(Q){for(let Z of["127.0.0.1","::1"])if(await d0(Z,Q))return!1;return!0}async function RZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await a0($))return $;return Q}import{execSync as Q1,spawn as Z1}from"child_process";import{mkdirSync as $1,openSync as Y1,readFileSync as J1,writeFileSync as V1}from"fs";import{homedir as z1}from"os";import{dirname as q1,join as YQ}from"path";import{fileURLToPath as X1}from"url";import{createHash as U1}from"crypto";zQ();import{mkdirSync as s0,readFileSync as t0,writeFileSync as r0}from"fs";import{join as o0}from"path";var n0=["default","acceptEdits","bypassPermissions","auto"];function wZ(Q){return typeof Q==="string"&&n0.includes(Q)}function gZ(Q,Z,$){let Y={behavior:"allow"};if($&&Object.keys($).length>0)Y.updatedInput=$;if(Q)Y.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let J={hookEventName:"PermissionRequest",decision:Y};if(Z?.trim())J.additionalContext=Z;return{hookSpecificOutput:J}}function DZ(){return o0(G(),"preferences.json")}function AQ(){try{let Q=JSON.parse(t0(DZ(),"utf8"));return{planApprovalMode:wZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function w2(Q){let Z={...AQ(),...Q};return s0(G(),{recursive:!0}),r0(DZ(),JSON.stringify(Z,null,2)),Z}function OZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
352
|
+
${zZ}
|
|
353
|
+
`,E="add it manually: codex mcp add beacon -- beacon mcp";var HZ=C(()=>{a();eQ();$Q=[{event:"PostToolUse",matcher:"apply_patch",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose, nudge it to present the plan on Beacon's /plan canvas."}]});var xZ={};HQ(xZ,{provisionDb:()=>t0});import{createClient as L0}from"@libsql/client";import{drizzle as k0}from"drizzle-orm/libsql";import{migrate as _0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as S0}from"drizzle-orm/migrator";import{dirname as AQ,join as h0}from"path";import{fileURLToPath as m0}from"url";async function zQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function d0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function NZ(Q){if(!await zQ(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function s0(Q){for(let[Z,$]of Object.entries(l0)){if(!await zQ(Q,Z))continue;let Y=await d0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function t0(Q,Z=c0){let $=L0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await zQ($,"__drizzle_migrations"),J=await zQ($,"Node"),V=!1;if(J&&!Y){let W=S0({migrationsFolder:Z})[0];if(W)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[W.hash,W.folderMillis]}),V=!0}let q=await NZ($);if(await _0(k0($),{migrationsFolder:Z}),await NZ($)>q)V=!0;return await s0($),{migrated:V}}finally{$.close()}}var p0,c0,l0;var PZ=C(async()=>{p0=AQ(AQ(AQ(m0(import.meta.url)))),c0=process.env.BEACON_MIGRATIONS_DIR||h0(p0,"drizzle"),l0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});a();import{existsSync as F0}from"fs";import{homedir as C0}from"os";import{join as YQ}from"path";function w0(){return process.env.HOME||process.env.USERPROFILE||C0()}var JQ=()=>YQ(w0(),".claude"),wQ=()=>YQ(JQ(),"skills"),VQ=()=>YQ(JQ(),"settings.json"),gQ=()=>YQ(JQ(),"CLAUDE.md"),OQ="<!-- beacon:global:start -->",GZ="<!-- beacon:global:end -->";var g0=S,DQ=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract: in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. Fail-open when there's no active contract."},{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:"PreToolUse",matcher:"AskUserQuestion",command:"beacon ask",description:"Surface the agent's AskUserQuestion in Beacon's modal; your pick flows back as the answer (falls through to the terminal if Beacon isn't open)."},{event:"PermissionRequest",matcher:"Edit|Write|MultiEdit|Bash|NotebookEdit",command:"beacon ask",description:"Surface edit/create/run approvals in Beacon's modal; your allow/deny flows back (falls through to the terminal prompt if Beacon isn't open)."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function O0(Q,Z){return s(wQ(),Q,Z)}function jZ(Q){return u(wQ(),Q)}function D0(Q){return t(wQ(),Q)}function A0(Q){return m(VQ(),Q)}function u0(Q){return p(VQ(),Q)}function f0(Q){return c(VQ(),Q)}function E0(Q){l(gQ(),OQ,GZ,Q)}function KZ(){return A(gQ(),OQ)}function I0(){return d(gQ(),OQ,GZ)}function z2(){let Q={};for(let $ of P)Q[$]=jZ($);let Z={};for(let $ of DQ)Z[$.event]=u0({event:$.event,command:$.command});return{homeExists:F0(JQ()),skills:Q,hooks:Z,claudeMdBlock:KZ()}}function q2(){let Q=sQ(VQ(),{event:"PostToolUse",command:"beacon hook"});return Q?jQ(Q):null}async function b0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$,EXPLAIN_SKILL:Y}=await Promise.resolve().then(() => (MQ(),vQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$,"beacon-explain":Y},V=[];for(let z of P){if(!jZ(z))V.push(z);O0(z,J[z])}let q=0;for(let z of DQ)if(A0({event:z.event,matcher:z.matcher,command:_(z.command)}))q++;let W=KZ();return E0(g0),{skillsAdded:V,hooksAdded:q,claudeMdBlockTouched:!W}}async function BZ(){if(pQ())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let Q;if(lQ()){try{y0()}catch{}Q={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{Q={ok:!0,...await b0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (HZ(),WZ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function y0(){let Q=[];for(let Y of P)if(D0(Y))Q.push(Y);let Z=0;for(let Y of DQ)if(f0(Y))Z++;let $=I0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as a0}from"async_hooks";import{spawnSync as r0}from"child_process";import{createHash as n0}from"crypto";import{existsSync as MZ,mkdirSync as y,readFileSync as fQ,writeFileSync as EQ}from"fs";import{homedir as RZ}from"os";import{basename as o0,join as v,parse as i0,resolve as vZ}from"path";function j(){return process.env.BEACON_HOME||v(RZ(),".beacon")}function IQ(){return v(j(),"workspaces.json")}function b(Q){return n0("sha256").update(Q).digest("hex").slice(0,12)}function e0(Q=process.cwd()){let Z=r0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function TZ(Q){let Z=vZ(Q);return Z!==vZ(RZ())&&Z!==i0(Z).root}function FZ(){return v(j(),"deleted.json")}function bQ(){try{let Q=JSON.parse(fQ(FZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function CZ(Q){y(j(),{recursive:!0}),EQ(FZ(),JSON.stringify(Q,null,2))}function wZ(Q){return bQ().includes(Q)}function R2(Q){let Z=bQ();if(!Z.includes(Q))CZ([...Z,Q])}function Q1(Q){let Z=bQ();if(Z.includes(Q))CZ(Z.filter(($)=>$!==Q))}function qQ(Q){return v(j(),Q)}function Z1(Q){return`file:${v(qQ(Q),"db.sqlite")}`}function L(){try{let Q=JSON.parse(fQ(IQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function yQ(Q){y(j(),{recursive:!0}),EQ(IQ(),JSON.stringify(Q,null,2))}function gZ(){return L().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function T(Q){return L().find((Z)=>Z.id===Q)??null}function OZ(Q,Z,$=new Date().toISOString()){if(!TZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=b(Q);if(wZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=L(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||o0(Q),lastOpenedAt:$},W=[q,...J.filter((z)=>z.id!==Y)];return y(qQ(Y),{recursive:!0}),yQ(W),q}function T2(Q,Z){return Q1(b(Q)),OZ(Q,Z)}function F2(Q,Z=new Date().toISOString()){let $=L(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,yQ($)}function C2(Q){if(yQ(L().filter((Z)=>Z.id!==Q)),LQ()===Q)$1(gZ()[0]?.id??null)}function DZ(){return v(j(),"active")}function LQ(){try{return fQ(DZ(),"utf8").trim()||null}catch{return null}}function $1(Q){y(j(),{recursive:!0}),EQ(DZ(),Q??"")}function w2(){let Q=LQ();return Q?T(Q):null}function g2(){let Q=J1()??LQ();return Q?T(Q):null}function O2(Q){return T(Q)?.path??null}function D2(){return MZ(IQ())}var AZ="beacon_ws";function uZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function A2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&T(Z))return Z;let $=uZ(Q,AZ);if($&&T($))return $;return Y1()}function Y1(){let Q=gZ();return Q.length===1?Q[0].id:null}var fZ="x-beacon-workspace-path";function u2(Q=process.cwd()){let Z=e0(Q);return{"x-beacon-workspace":b(Z),[fZ]:Z}}async function f2(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&T(Z))return Z;let $=Q.headers.get(fZ);if($&&TZ($)&&!wZ(b($))&&(!Z||b($)===Z)){let J=OZ($);return await V1(J.id),J.id}let Y=uZ(Q,AZ);if(Y&&T(Y))return Y;return null}var EZ=new a0;function E2(Q,Z){return Q?EZ.run(Q,Z):Z()}function J1(){return EZ.getStore()??null}var uQ=new Set;function I2(Q){uQ.delete(v(qQ(Q),"db.sqlite"))}async function V1(Q){let Z=qQ(Q),$=v(Z,"db.sqlite"),Y=MZ($);if(Y&&uQ.has($))return{ok:!0,created:!1,migrated:!1};try{y(Z,{recursive:!0});let{provisionDb:J}=await PZ().then(() => xZ),V=await J(Z1(Q));return uQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as z1}from"net";var L2=4319;function q1(Q,Z,$=400){return new Promise((Y)=>{let J=z1({host:Q,port:Z}),V=!1,q=(W)=>{if(V)return;V=!0,J.destroy(),Y(W)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function X1(Q){for(let Z of["127.0.0.1","::1"])if(await q1(Z,Q))return!1;return!0}async function IZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await X1($))return $;return Q}import{execSync as N1,spawn as x1}from"child_process";import{mkdirSync as P1,openSync as v1,readFileSync as M1,writeFileSync as R1}from"fs";import{homedir as T1}from"os";import{dirname as F1,join as UQ}from"path";import{fileURLToPath as C1}from"url";import{createHash as w1}from"crypto";KQ();import{mkdirSync as W1,readFileSync as H1,writeFileSync as G1}from"fs";import{join as j1}from"path";var U1=["default","acceptEdits","bypassPermissions","auto"];function bZ(Q){return typeof Q==="string"&&U1.includes(Q)}function yZ(Q,Z,$){let Y={behavior:"allow"};if($&&Object.keys($).length>0)Y.updatedInput=$;if(Q)Y.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let J={hookEventName:"PermissionRequest",decision:Y};if(Z?.trim())J.additionalContext=Z;return{hookSpecificOutput:J}}function LZ(){return j1(j(),"preferences.json")}function kQ(){try{let Q=JSON.parse(H1(LZ(),"utf8"));return{planApprovalMode:bZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function c2(Q){let Z={...kQ(),...Q};return W1(j(),{recursive:!0}),G1(LZ(),JSON.stringify(Z,null,2)),Z}function kZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
353
354
|
|
|
354
355
|
This plan created these roadmap feature(s):
|
|
355
356
|
`+Z.join(`
|
|
356
|
-
`)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{execSync as
|
|
357
|
-
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",W=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(W.status===422){let H=await W.json().catch(()=>({}));
|
|
357
|
+
`)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{execSync as K1}from"child_process";import{platform as _Z}from"os";function B1(Q){if(process.env.BEACON_NO_OPEN)return;let Z=_Z()==="darwin"?"open":_Z()==="win32"?"start":"xdg-open";try{K1(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}async function SZ(Q,Z){if(await fetch(`${Q}/api/plan/presence`,{headers:{"x-beacon-workspace":Z}}).then((J)=>J.json()).then((J)=>!!J?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Z}`);B1(`${Q}/api/workspace/activate?id=${Z}&redirect=${Y}`)}var g1=UQ(F1(C1(import.meta.url)),".."),SQ=process.env.BEACON_HOME||UQ(T1(),".beacon"),hZ=UQ(SQ,"server.json"),O1=process.env.PORT||"4319";function D1(Q){try{return process.kill(Q,0),!0}catch{return!1}}function A1(Q){try{return JSON.parse(M1(Q,"utf8"))}catch{return null}}async function mZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function u1(Q,Z=60){for(let $=0;$<Z;$++){if(await mZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function f1(Q){P1(SQ,{recursive:!0});let Z=v1(UQ(SQ,"server.log"),"a"),$={...process.env,PORT:Q,BEACON_NO_OPEN:"1"};delete $.BEACON_REPO,delete $.BEACON_DATA_DIR,delete $.DATABASE_URL;let Y=x1("bun",["run","dev"],{cwd:g1,env:$,detached:!0,stdio:["ignore",Z,Z]});Y.unref();let J={pid:Y.pid??0,port:Q};return R1(hZ,JSON.stringify(J)),J}async function E1(){let Q=A1(hZ);if(Q&&D1(Q.pid)&&await mZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let Z=String(await IZ(Number(O1))),{port:$}=f1(Z);return await u1(`http://localhost:${$}/api/workspace`),$}function I1(){try{return N1("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function b1(Q){return w1("sha256").update(Q).digest("hex").slice(0,12)}async function y1(){if(process.stdin.isTTY)return null;let Q=[];for await(let $ of process.stdin)Q.push($);let Z=Buffer.concat(Q).toString("utf8").trim();if(!Z)return null;try{return JSON.parse(Z)}catch{return null}}function _Q(Q,Z,$){return yZ(Q,Z,$)}function XQ(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function F(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await BZ();let Z=(await y1())?.tool_input?.plan;if(!Z||!Z.trim())F(_Q());let Y=`http://localhost:${await E1()}`,J=I1()||process.cwd(),V=b1(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let q=Z.split(`
|
|
358
|
+
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",W=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(W.status===422){let H=await W.json().catch(()=>({}));F(XQ(H.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!W.ok)F(_Q());await SZ(Y,V);let z=Date.now()+aQ,U=(H)=>new Promise((WQ)=>setTimeout(WQ,H));while(Date.now()<z){await U(tQ);let H=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((WQ)=>WQ.json()).catch(()=>null);if(!H)continue;if(H.kind==="approved")F(_Q(kQ().planApprovalMode,kZ(H.features),{plan:Z}));if(H.kind==="discarded")F(XQ("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(H.kind==="feedback")F(XQ(`The user left feedback on the plan in Beacon (inline comments and/or edits on the /map and /db boards). Revise the plan based on the feedback below, then re-present (call ExitPlanMode again):
|
|
358
359
|
|
|
359
|
-
`+H.feedback))}
|
|
360
|
+
`+H.feedback))}F(XQ("\u23F3 Still awaiting your review in Beacon \u2014 the plan is open on /plan and nothing was lost. "+"Claude Code caps a single plan-review hook at ~10 minutes, so to keep waiting you MUST call ExitPlanMode again now with the SAME plan. Re-presenting resumes the same review (your in-progress annotations and any decision are preserved). Do NOT implement, and do "+"NOT ask in the terminal \u2014 just re-present."))})();
|