trybeacon 0.1.18 → 0.1.20
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 +12 -12
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +2 -2
- package/.next/server/app/docs.segments/_full.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
- package/.next/server/app/feedback.html +1 -1
- package/.next/server/app/feedback.rsc +2 -2
- package/.next/server/app/feedback.segments/_full.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +2 -2
- package/.next/server/app/help.segments/_full.segment.rsc +2 -2
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +2 -2
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/map/page.js +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +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 +12 -12
- package/.next/server/chunks/9419.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/8207-ec49c6e4ab8a4bab.js +1 -0
- package/.next/static/chunks/app/map/{page-8a50ebc7430720f9.js → page-d7c8e5236784398e.js} +1 -1
- package/.next/static/chunks/app/plan/{page-8c84c74359ee2ea0.js → page-64a53d9f43b74c26.js} +1 -1
- package/.next/static/css/13ab752f24b58903.css +1 -0
- package/.next/trace +37 -37
- package/.next/trace-build +1 -1
- package/dist/bin/doctor.js +24 -24
- package/dist/bin/hook.js +24 -24
- package/dist/bin/mcp.js +30 -30
- package/dist/bin/plan.js +25 -25
- package/dist/bin/uninstall.js +26 -26
- package/dist/lib/codex-install.js +25 -25
- package/dist/lib/global-install.js +242 -0
- package/package.json +1 -1
- package/.next/server/chunks/7604.js +0 -1
- package/.next/static/chunks/9185-2dc95ca34d3ed35e.js +0 -1
- package/.next/static/css/f0c8ee0772c6d74d.css +0 -1
- /package/.next/static/{zLC93esTvoKLzicL2UsF6 → gS_xE1cqbYifs05Z7A-hH}/_buildManifest.js +0 -0
- /package/.next/static/{zLC93esTvoKLzicL2UsF6 → gS_xE1cqbYifs05Z7A-hH}/_ssgManifest.js +0 -0
package/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-webpack","duration":
|
|
1
|
+
[{"name":"run-webpack","duration":28513958,"timestamp":107206191,"id":14,"parentId":1,"tags":{},"startTime":1781118307432,"traceId":"66bdd438ce4c764a"},{"name":"run-typescript","duration":11623132,"timestamp":135722677,"id":3923,"parentId":1,"tags":{},"startTime":1781118335948,"traceId":"66bdd438ce4c764a"},{"name":"static-check","duration":728297,"timestamp":147382822,"id":3926,"parentId":1,"tags":{},"startTime":1781118347609,"traceId":"66bdd438ce4c764a"},{"name":"static-generation","duration":4442484,"timestamp":148695981,"id":4062,"parentId":1,"tags":{},"startTime":1781118348922,"traceId":"66bdd438ce4c764a"},{"name":"collect-build-traces","duration":12967678,"timestamp":148113915,"id":4059,"parentId":1,"tags":{},"startTime":1781118348340,"traceId":"66bdd438ce4c764a"},{"name":"telemetry-flush","duration":59,"timestamp":161085131,"id":4071,"parentId":1,"tags":{},"startTime":1781118361311,"traceId":"66bdd438ce4c764a"},{"name":"next-build","duration":53997118,"timestamp":107088083,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1781118307314,"traceId":"66bdd438ce4c764a"}]
|
package/dist/bin/doctor.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var HZ=Object.defineProperty;var jZ=(Q)=>Q;function vZ(Q,Z){this[Q]=jZ.bind(null,Z)}var qQ=(Q,Z)=>{for(var $ in Z)HZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:vZ.bind(Z,$)})};var g=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var HQ={};qQ(HQ,{removeRepoAssets:()=>fZ,installRefreshSkill:()=>NZ,installPlanSkill:()=>xZ,installInitSkill:()=>BZ,installCodexRepoSkills:()=>KZ,ensureWorkflowDoc:()=>CZ,ensureMcp:()=>MZ,auditRepo:()=>PQ,REFRESH_SKILL:()=>UQ,PLAN_SKILL:()=>bQ,INIT_SKILL:()=>XQ});import{existsSync as f,mkdirSync as _,readFileSync as x,rmSync as b,writeFileSync as N}from"fs";import{join as q}from"path";function BZ(Q){let Z=q(Q,".claude","skills","beacon-init");_(Z,{recursive:!0});let $=q(Z,"SKILL.md");return N($,XQ),$}function NZ(Q){let Z=q(Q,".claude","skills","beacon-refresh");_(Z,{recursive:!0});let $=q(Z,"SKILL.md");return N($,UQ),$}function xZ(Q){let Z=q(Q,".claude","skills","beacon-plan");_(Z,{recursive:!0});let $=q(Z,"SKILL.md");return N($,bQ),$}function KZ(Q){let Z=[];for(let $ of GZ){let J=q(Q,".agents","skills",$.name);_(J,{recursive:!0});let Y=q(J,"SKILL.md");N(Y,$.body()),Z.push(Y)}return Z}function CZ(Q){let Z=q(Q,"AGENTS.md"),$="";try{$=x(Z,"utf8")}catch{}let J=new RegExp(`${k}[\\s\\S]*?${WQ}`);$=J.test($)?$.replace(J,AQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${AQ}
|
|
6
6
|
`.trimStart(),N(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
|
-
`);let Y=q(Q,"CLAUDE.md"),V="";try{V=
|
|
8
|
+
`);let Y=q(Q,"CLAUDE.md"),V="";try{V=x(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))N(Y,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!0}}function
|
|
13
|
-
`)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=
|
|
11
|
+
`)}function MZ(Q){let Z=q(Q,".mcp.json"),$={};try{$=JSON.parse(x(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},N(Z,JSON.stringify($,null,2)+`
|
|
12
|
+
`),{path:Z,added:!0}}function PQ(Q){let Z=q(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(x(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=x(q(Q,"AGENTS.md"),"utf8").includes(k)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(x(q(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":f(q(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":f(q(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":f(q(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":f(q(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function fZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let j=q(Q,".claude","skills",z);if(f(j))b(j,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let j=q(Q,".agents","skills",z);if(f(j))b(j,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=q(Q,".mcp.json");try{let z=JSON.parse(x(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)b(J,{force:!0});else N(J,JSON.stringify(z,null,2)+`
|
|
13
|
+
`)}}catch{}let Y=!1,V=q(Q,"AGENTS.md");try{let z=x(V,"utf8"),j=new RegExp(`\\n?${k}[\\s\\S]*?${WQ}\\n?`);if(j.test(z)){let zQ=z.replace(j,`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
|
-
`).trimStart();N(V,
|
|
17
|
-
`)?
|
|
18
|
-
`),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=
|
|
16
|
+
`).trimStart();N(V,zQ.endsWith(`
|
|
17
|
+
`)?zQ:`${zQ}
|
|
18
|
+
`),Y=!0}}catch{}let X=!1,U=q(Q,"CLAUDE.md");try{let z=x(U,"utf8"),j=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(j!==z){if(!j.trim())b(U,{force:!0});else N(U,j);X=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:X}}var XQ=`---
|
|
19
19
|
name: beacon-init
|
|
20
20
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
21
21
|
---
|
|
@@ -52,7 +52,7 @@ A single \`beacon_init_persist\` MCP tool call with:
|
|
|
52
52
|
If \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-init.
|
|
53
53
|
|
|
54
54
|
After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
|
|
55
|
-
`,
|
|
55
|
+
`,UQ=`---
|
|
56
56
|
name: beacon-refresh
|
|
57
57
|
description: Re-survey the repo and update Beacon's architecture / schema / endpoints map after /beacon-init was already run \u2014 picks up new components, removed ones, schema changes, and new routes. Use when the user runs /beacon-refresh or asks to "refresh", "update", "re-sync", or "bring Beacon up to date" with the current code.
|
|
58
58
|
---
|
|
@@ -99,7 +99,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
99
99
|
If \`beacon_entities\` or \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-refresh.
|
|
100
100
|
|
|
101
101
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
102
|
-
`,
|
|
102
|
+
`,bQ=`---
|
|
103
103
|
name: beacon-plan
|
|
104
104
|
description: Present your current plan or approach to the user on Beacon's /plan canvas for review \u2014 instead of asking for approval in prose. Use when the user says "present the plan", "show me the plan", "let me see it / the plan", or whenever you are about to end a turn asking whether to proceed with a plan, design, or approach.
|
|
105
105
|
---
|
|
@@ -141,7 +141,7 @@ If it returns feedback, revise and call it again.
|
|
|
141
141
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
142
142
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
143
143
|
run \`beacon\` in this repo once.
|
|
144
|
-
`,
|
|
144
|
+
`,GZ,k="<!-- beacon:workflow:start -->",WQ="<!-- beacon:workflow:end -->",AQ;var L=g(()=>{GZ=[{name:"beacon-init",body:()=>XQ},{name:"beacon-refresh",body:()=>UQ}];AQ=`${k}
|
|
145
145
|
## Beacon \u2014 feature workflow
|
|
146
146
|
|
|
147
147
|
This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
|
|
@@ -195,18 +195,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
195
195
|
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.
|
|
196
196
|
|
|
197
197
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
198
|
-
${
|
|
199
|
-
`)}function
|
|
198
|
+
${WQ}`});import{existsSync as _Q,mkdirSync as jQ,readFileSync as S,rmSync as wZ,writeFileSync as m}from"fs";import{dirname as kQ,join as h}from"path";function vQ(Q){try{return JSON.parse(S(Q,"utf8"))}catch{return{}}}function LQ(Q,Z){jQ(kQ(Q),{recursive:!0}),m(Q,JSON.stringify(Z,null,2)+`
|
|
199
|
+
`)}function c(Q,Z){let $=vQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let J=$.hooks[Z.event];if(J.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((X)=>X.command===Z.command)))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),LQ(Q,$),!0}function l(Q,Z){return(vQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function n(Q,Z){let $=vQ(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((X)=>{let U=X.hooks?.length??0,z=(X.hooks??[]).filter((j)=>j.command!==Z.command);if(z.length!==U)Y=!0;return{...X,hooks:z}}).filter((X)=>(X.hooks??[]).length>0);if(!Y)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return LQ(Q,$),!0}function t(Q,Z,$,J){let Y=`${Z}
|
|
200
200
|
${J.trim()}
|
|
201
201
|
${$}`,V="";try{V=S(Q,"utf8")}catch{}let X=new RegExp(`${Z}[\\s\\S]*?${$}`);V=X.test(V)?V.replace(X,Y):V.trim()?`${V.trim()}
|
|
202
202
|
|
|
203
203
|
${Y}
|
|
204
204
|
`:`${Y}
|
|
205
|
-
`,
|
|
205
|
+
`,jQ(kQ(Q),{recursive:!0}),m(Q,V.endsWith(`
|
|
206
206
|
`)?V:`${V}
|
|
207
|
-
`)}function R(Q,Z){try{return S(Q,"utf8").includes(Z)}catch{return!1}}function
|
|
207
|
+
`)}function R(Q,Z){try{return S(Q,"utf8").includes(Z)}catch{return!1}}function s(Q,Z,$){let J="";try{J=S(Q,"utf8")}catch{return!1}let Y=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!Y.test(J))return!1;let V=J.replace(Y,"").replace(/\n{3,}/g,`
|
|
208
208
|
|
|
209
|
-
`).trimStart();return m(Q,V),!0}function
|
|
209
|
+
`).trimStart();return m(Q,V),!0}function a(Q,Z,$){let J=h(Q,Z);jQ(J,{recursive:!0});let Y=h(J,"SKILL.md");return m(Y,$),Y}function E(Q,Z){return _Q(h(Q,Z,"SKILL.md"))}function d(Q,Z){let $=h(Q,Z);if(!_Q($))return!1;return wZ($,{recursive:!0,force:!0}),!0}var v,p=`## Beacon (visual planning panel)
|
|
210
210
|
|
|
211
211
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
212
212
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -227,19 +227,19 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
227
227
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
228
228
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
229
229
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
230
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
230
|
+
verbatim. Do NOT implement until the tool returns approval.`;var BQ=g(()=>{v=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as uZ,renameSync as TZ,rmSync as FZ,writeFileSync as gZ}from"fs";import{dirname as RZ}from"path";function NQ(Q,Z){uZ(RZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{gZ($,Z),TZ($,Q)}catch(J){throw FZ($,{force:!0}),J}}var hQ=()=>{};var tQ={};qQ(tQ,{setupCodexAssets:()=>IZ,removeCodexMcp:()=>nQ,removeCodexArtifacts:()=>OZ,hasCodexMcp:()=>CQ,ensureCodexMcp:()=>lQ,codexMcpProblem:()=>MQ,codexDetected:()=>QQ,auditCodex:()=>fQ,CODEX_HOOKS:()=>K});import{readFileSync as e}from"fs";import{homedir as EZ}from"os";import{join as O}from"path";function SQ(){return process.env.HOME||process.env.USERPROFILE||EZ()}function QQ(){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 I(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function CQ(){try{return Boolean(I(e(w(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function MQ(){let Q="";try{Q=e(w(),"utf8")}catch{return null}let Z=I(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 lQ(){let Q="",Z=!1;try{Q=e(w(),"utf8"),Z=!0}catch{}if(Z){let V=I(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(`
|
|
231
231
|
`)?`
|
|
232
232
|
`:`
|
|
233
233
|
|
|
234
|
-
`,J=Q+$+
|
|
235
|
-
`),$=Z.indexOf(
|
|
234
|
+
`,J=Q+$+DZ;if(I(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${D}`};return NQ(w(),J),{added:!0}}function nQ(){let Q="";try{Q=e(w(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
235
|
+
`),$=Z.indexOf(pQ);if($===-1)return{removed:!1,skipped:CQ()};let J=Z.indexOf(cQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
|
|
236
236
|
`).replace(/\n{3,}/g,`
|
|
237
237
|
|
|
238
|
-
`).replace(/^\n+/,"");if(
|
|
238
|
+
`).replace(/^\n+/,"");if(I(Y)===null)return{removed:!1,skipped:!0};return NQ(w(),Y),{removed:!0}}async function IZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (L(),HQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of v){if(!E(i(),z))Y.push(z);a(i(),z,J[z])}let V=0;for(let z of K)if(c(KQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let X=R(r(),o);t(r(),o,mQ,p);let U=lQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!X,mcp:U}}function fQ(){let Q={};for(let $ of v)Q[$]=E(i(),$);let Z={};for(let $ of K)Z[$.event]=l(KQ(),{event:$.event,command:$.command});return{detected:QQ(),skills:Q,hooks:Z,agentsMdBlock:R(r(),o),mcp:CQ()}}function OZ(){let Q=[];for(let Y of v)if(d(i(),Y))Q.push(Y);let Z=0;for(let Y of K)if(n(KQ(),{event:Y.event,command:Y.command}))Z++;let $=s(r(),o,mQ),J=nQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var GQ=()=>O(SQ(),".codex"),KQ=()=>O(GQ(),"hooks.json"),w=()=>O(GQ(),"config.toml"),r=()=>O(GQ(),"AGENTS.md"),i=()=>O(SQ(),".agents","skills"),o="<!-- beacon:global:start -->",mQ="<!-- beacon:global:end -->",K,xQ,pQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",cQ="# beacon:end",DZ,D="add it manually: codex mcp add beacon -- beacon mcp";var wQ=g(()=>{BQ();hQ();K=[{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."}];DZ=`${pQ}
|
|
239
239
|
[mcp_servers.beacon]
|
|
240
240
|
command = "beacon"
|
|
241
241
|
args = ["mcp"]
|
|
242
|
-
${
|
|
243
|
-
`});var
|
|
244
|
-
\x1B[1m${Q}\x1B[0m`;function
|
|
242
|
+
${cQ}
|
|
243
|
+
`});var oQ={};qQ(oQ,{provisionDb:()=>$0});import{createClient as nZ}from"@libsql/client";import{drizzle as tZ}from"drizzle-orm/libsql";import{migrate as sZ}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as aZ}from"drizzle-orm/migrator";import{dirname as RQ,join as dZ}from"path";import{fileURLToPath as rZ}from"url";async function JQ(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function Q0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function iQ(Q){if(!await JQ(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 Z0(Q){for(let[Z,$]of Object.entries(eZ)){if(!await JQ(Q,Z))continue;let J=await Q0(Q,Z);for(let Y of $){if(!J.has(Y))continue;await Q.execute(`UPDATE "${Z}" SET "${Y}" = CAST((julianday("${Y}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${Y}") = 'text'`)}}}async function $0(Q,Z=oZ){let $=nZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;");let J=await JQ($,"__drizzle_migrations"),Y=await JQ($,"Node"),V=!1;if(Y&&!J){let U=aZ({migrationsFolder:Z})[0];if(U)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:[U.hash,U.folderMillis]}),V=!0}let X=await iQ($);if(await sZ(tZ($),{migrationsFolder:Z}),await iQ($)>X)V=!0;return await Z0($),{migrated:V}}finally{$.close()}}var iZ,oZ,eZ;var eQ=g(async()=>{iZ=RQ(RQ(RQ(rZ(import.meta.url)))),oZ=process.env.BEACON_MIGRATIONS_DIR||dZ(iZ,"drizzle"),eZ={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});BQ();import{existsSync as yZ}from"fs";import{homedir as AZ}from"os";import{join as ZQ}from"path";function bZ(){return process.env.HOME||process.env.USERPROFILE||AZ()}var $Q=()=>ZQ(bZ(),".claude"),uQ=()=>ZQ($Q(),"skills"),TQ=()=>ZQ($Q(),"settings.json"),FQ=()=>ZQ($Q(),"CLAUDE.md"),gQ="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->";var _Z=p,u=[{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function kZ(Q,Z){return a(uQ(),Q,Z)}function aQ(Q){return E(uQ(),Q)}function LZ(Q){return d(uQ(),Q)}function hZ(Q){return c(TQ(),Q)}function SZ(Q){return l(TQ(),Q)}function mZ(Q){return n(TQ(),Q)}function pZ(Q){t(FQ(),gQ,sQ,Q)}function dQ(){return R(FQ(),gQ)}function cZ(){return s(FQ(),gQ,sQ)}function rQ(){let Q={};for(let $ of v)Q[$]=aQ($);let Z={};for(let $ of u)Z[$.event]=SZ({event:$.event,command:$.command});return{homeExists:yZ($Q()),skills:Q,hooks:Z,claudeMdBlock:dQ()}}async function lZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (L(),HQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let U of v){if(!aQ(U))Y.push(U);kZ(U,J[U])}let V=0;for(let U of u)if(hZ({event:U.event,matcher:U.matcher,command:U.command}))V++;let X=dQ();return pZ(_Z),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!X}}async function m0(){let Q;try{Q={ok:!0,...await lZ()}}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(() => (wQ(),tQ));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 p0(){let Q=[];for(let J of v)if(LZ(J))Q.push(J);let Z=0;for(let J of u)if(mZ(J))Z++;let $=cZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as J0}from"async_hooks";import{spawnSync as Y0}from"child_process";import{createHash as V0}from"crypto";import{existsSync as ZZ,mkdirSync as YQ,readFileSync as $Z,writeFileSync as JZ}from"fs";import{homedir as z0}from"os";import{basename as q0,join as T}from"path";function G(){return process.env.BEACON_HOME||T(z0(),".beacon")}function EQ(){return T(G(),"workspaces.json")}function YZ(Q){return V0("sha256").update(Q).digest("hex").slice(0,12)}function $1(Q=process.cwd()){let Z=Y0("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 DQ(Q){return T(G(),Q)}function X0(Q){return`file:${T(DQ(Q),"db.sqlite")}`}function y(){try{let Q=JSON.parse($Z(EQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function IQ(Q){YQ(G(),{recursive:!0}),JZ(EQ(),JSON.stringify(Q,null,2))}function OQ(){return y().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function C(Q){return y().find((Z)=>Z.id===Q)??null}function U0(Q,Z,$=new Date().toISOString()){let J=YZ(Q),Y=y(),V=Y.find((z)=>z.id===J),X={id:J,path:Q,name:Z||V?.name||q0(Q),lastOpenedAt:$},U=[X,...Y.filter((z)=>z.id!==J)];return YQ(DQ(J),{recursive:!0}),IQ(U),X}function J1(Q,Z=new Date().toISOString()){let $=y(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,IQ($)}function Y1(Q){if(IQ(y().filter((Z)=>Z.id!==Q)),yQ()===Q)W0(OQ()[0]?.id??null)}function VZ(){return T(G(),"active")}function yQ(){try{return $Z(VZ(),"utf8").trim()||null}catch{return null}}function W0(Q){YQ(G(),{recursive:!0}),JZ(VZ(),Q??"")}function V1(){let Q=yQ();return Q?C(Q):null}function z1(){let Q=H0()??yQ();return Q?C(Q):null}function q1(Q){return C(Q)?.path??null}function X1(){return ZZ(EQ())}var zZ="beacon_ws";function qZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let J of $.split(";")){let Y=J.indexOf("=");if(Y===-1)continue;if(J.slice(0,Y).trim()===Z)return decodeURIComponent(J.slice(Y+1).trim())}return null}function U1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&C(Z))return Z;let $=qZ(Q,zZ);if($&&C($))return $;return null}var P0="x-beacon-workspace-path";async function W1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&C(Z))return Z;let $=Q.headers.get(P0);if($&&(!Z||YZ($)===Z)){let Y=U0($);return await j0(Y.id),Y.id}let J=qZ(Q,zZ);if(J&&C(J))return J;return null}var XZ=new J0;function P1(Q,Z){return Q?XZ.run(Q,Z):Z()}function H0(){return XZ.getStore()??null}var QZ=new Set;async function j0(Q){let Z=DQ(Q),$=T(Z,"db.sqlite"),J=ZZ($);if(J&&QZ.has($))return{ok:!0,created:!1,migrated:!1};try{YQ(Z,{recursive:!0});let{provisionDb:Y}=await eQ().then(() => oQ),V=await Y(X0(Q));return QZ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}L();wQ();import{execSync as v0,spawnSync as UZ}from"child_process";import{existsSync as B0,readFileSync as N0}from"fs";import{join as WZ}from"path";var W=(Q)=>`\x1B[32m\u2713\x1B[0m ${Q}`,P=(Q)=>`\x1B[31m\u2717\x1B[0m ${Q}`,M=(Q)=>`\x1B[2m${Q}\x1B[0m`,A=(Q)=>`
|
|
244
|
+
\x1B[1m${Q}\x1B[0m`;function x0(){try{return v0("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function G0(){let Q=WZ(G(),"server.json");try{let Z=JSON.parse(N0(Q,"utf8"));if(!Z.pid)return P("daemon: no server.json yet");try{return process.kill(Z.pid,0),W(`daemon running (pid ${Z.pid}, port ${Z.port??"?"})`)}catch{return P(`daemon NOT running (server.json stale: pid ${Z.pid})`)}}catch{return P("daemon: no server.json (never started)")}}function K0(){let Q=UZ("bun",["--version"],{stdio:["ignore","pipe","ignore"]});if(Q.status===0)return W(`bun ${Q.stdout.toString().trim()}`);return P("bun NOT found on PATH (required to run Beacon)")}function C0(){return x0()||process.cwd()}var VQ=C0(),F=rQ(),PZ=OQ(),M0=PZ.some((Q)=>Q.path===VQ),H=M0||B0(WZ(VQ,".mcp.json"))?PQ(VQ):null;console.log(A("Beacon \xB7 doctor"));console.log(A("Runtime"));console.log(` ${K0()}`);console.log(` ${G0()}`);console.log(` ${W(`home: ${G()}`)}`);console.log(` ${W(`workspaces registered: ${PZ.length}`)}`);console.log(A("Global (~/.claude/)"));for(let Q of v)console.log(` ${F.skills[Q]?W(`skill ${Q}`):P(`skill ${Q} \u2014 missing`)}`);for(let Q of u)console.log(` ${F.hooks[Q.event]?W(`hook ${Q.event} \u2192 ${Q.command}`):P(`hook ${Q.event} \u2192 ${Q.command} \u2014 missing`)} ${M(Q.description)}`);console.log(` ${F.claudeMdBlock?W("global CLAUDE.md block"):P("global CLAUDE.md block \u2014 missing (every Claude session won't auto-discover Beacon)")}`);console.log(A("Codex (~/.codex/ + ~/.agents/)"));var B=QQ()?fQ():null;if(!B)console.log(` ${M("codex not on PATH \u2014 Codex integration inactive (wires automatically once codex is installed)")}`);else{let Q=UZ("codex",["--version"],{stdio:["ignore","pipe","ignore"]});console.log(` ${Q.status===0?W(`codex ${Q.stdout.toString().trim()}`):M("codex version unavailable (BEACON_CODEX override?)")}`);for(let $ of v)console.log(` ${B.skills[$]?W(`skill ${$} (~/.agents/skills)`):P(`skill ${$} (~/.agents/skills) \u2014 missing`)}`);for(let $ of K)console.log(` ${B.hooks[$.event]?W(`hook ${$.event} \u2192 ${$.command}`):P(`hook ${$.event} \u2192 ${$.command} \u2014 missing`)} ${M($.description)}`);console.log(` ${B.agentsMdBlock?W("global ~/.codex/AGENTS.md block"):P("global ~/.codex/AGENTS.md block \u2014 missing")}`);let Z=MQ();console.log(` ${B.mcp?W("config.toml has [mcp_servers.beacon]"):P(`config.toml missing [mcp_servers.beacon]${Z?` \u2014 ${Z}`:""}`)}`)}console.log(A(`Current repo (${VQ})`));if(!H)console.log(` ${M("not registered with Beacon and no .mcp.json \u2014 run `beacon` here to wire it.")}`);else if(console.log(` ${H.mcpRegistered?W(".mcp.json has beacon entry"):P(".mcp.json missing beacon entry")}`),console.log(` ${H.agentsMdBlock?W("AGENTS.md has Beacon workflow block"):P("AGENTS.md missing Beacon workflow block")}`),console.log(` ${H.claudeMdImport?W("CLAUDE.md @-imports AGENTS.md"):P("CLAUDE.md does NOT @-import AGENTS.md")}`),console.log(` ${H.skills["beacon-init"]?W("skill beacon-init (repo)"):P("skill beacon-init (repo) \u2014 missing")}`),console.log(` ${H.skills["beacon-refresh"]?W("skill beacon-refresh (repo)"):P("skill beacon-refresh (repo) \u2014 missing")}`),B)console.log(` ${H.codexSkills["beacon-init"]?W("skill beacon-init (.agents/skills)"):P("skill beacon-init (.agents/skills) \u2014 missing")}`),console.log(` ${H.codexSkills["beacon-refresh"]?W("skill beacon-refresh (.agents/skills)"):P("skill beacon-refresh (.agents/skills) \u2014 missing")}`);var f0=v.some((Q)=>!F.skills[Q])||u.some((Q)=>!F.hooks[Q.event])||!F.claudeMdBlock||(B?v.some((Q)=>!B.skills[Q])||K.some((Q)=>!B.hooks[Q.event])||!B.agentsMdBlock||!B.mcp:!1)||(H?!H.mcpRegistered||!H.agentsMdBlock||!H.claudeMdImport||!H.skills["beacon-init"]||!H.skills["beacon-refresh"]||(B?!H.codexSkills["beacon-init"]||!H.codexSkills["beacon-refresh"]:!1):!1);if(f0)console.log(`
|
|
245
245
|
${M("Fix everything marked \u2717 by running")} \x1B[1mbeacon\x1B[0m ${M("in this repo.")}`);console.log();
|
package/dist/bin/hook.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var QZ=Object.defineProperty;var ZZ=(Q)=>Q;function $Z(Q,Z){this[Q]=ZZ.bind(null,Z)}var o=(Q,Z)=>{for(var $ in Z)QZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:$Z.bind(Z,$)})};var K=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var ZQ={};o(ZQ,{removeRepoAssets:()=>PZ,installRefreshSkill:()=>YZ,installPlanSkill:()=>VZ,installInitSkill:()=>JZ,installCodexRepoSkills:()=>qZ,ensureWorkflowDoc:()=>XZ,ensureMcp:()=>UZ,auditRepo:()=>WZ,REFRESH_SKILL:()=>e,PLAN_SKILL:()=>MQ,INIT_SKILL:()=>i});import{existsSync as B,mkdirSync as f,readFileSync as x,rmSync as F,writeFileSync as P}from"fs";import{join as X}from"path";function JZ(Q){let Z=X(Q,".claude","skills","beacon-init");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return P($,i),$}function YZ(Q){let Z=X(Q,".claude","skills","beacon-refresh");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return P($,e),$}function VZ(Q){let Z=X(Q,".claude","skills","beacon-plan");f(Z,{recursive:!0});let $=X(Z,"SKILL.md");return P($,MQ),$}function qZ(Q){let Z=[];for(let $ of zZ){let J=X(Q,".agents","skills",$.name);f(J,{recursive:!0});let Y=X(J,"SKILL.md");P(Y,$.body()),Z.push(Y)}return Z}function XZ(Q){let Z=X(Q,"AGENTS.md"),$="";try{$=x(Z,"utf8")}catch{}let J=new RegExp(`${R}[\\s\\S]*?${QQ}`);$=J.test($)?$.replace(J,CQ):`${$.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${CQ}
|
|
6
6
|
`.trimStart(),P(Z,$.endsWith(`
|
|
7
7
|
`)?$:`${$}
|
|
8
8
|
`);let Y=X(Q,"CLAUDE.md"),V="";try{V=x(Y,"utf8")}catch{}if(!/@AGENTS\.md/.test(V))P(Y,`${V?`${V.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Z,added:!0}}function
|
|
13
|
-
`)}}catch{}let Y=!1,V=X(Q,"AGENTS.md");try{let z=x(V,"utf8"),W=new RegExp(`\\n?${R}[\\s\\S]*?${
|
|
11
|
+
`)}function UZ(Q){let Z=X(Q,".mcp.json"),$={};try{$=JSON.parse(x(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},P(Z,JSON.stringify($,null,2)+`
|
|
12
|
+
`),{path:Z,added:!0}}function WZ(Q){let Z=X(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(x(Z,"utf8")).mcpServers?.beacon}catch{}let J=!1;try{J=x(X(Q,"AGENTS.md"),"utf8").includes(R)}catch{}let Y=!1;try{Y=/@AGENTS\.md/.test(x(X(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:J,claudeMdImport:Y,skills:{"beacon-init":B(X(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":B(X(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":B(X(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":B(X(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function PZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=X(Q,".claude","skills",z);if(B(W))F(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=X(Q,".agents","skills",z);if(B(W))F(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,J=X(Q,".mcp.json");try{let z=JSON.parse(x(J,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)F(J,{force:!0});else P(J,JSON.stringify(z,null,2)+`
|
|
13
|
+
`)}}catch{}let Y=!1,V=X(Q,"AGENTS.md");try{let z=x(V,"utf8"),W=new RegExp(`\\n?${R}[\\s\\S]*?${QQ}\\n?`);if(W.test(z)){let r=z.replace(W,`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
|
-
`).trimStart();P(V,
|
|
17
|
-
`)?
|
|
18
|
-
`),Y=!0}}catch{}let q=!1,U=X(Q,"CLAUDE.md");try{let z=x(U,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())F(U,{force:!0});else P(U,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var
|
|
16
|
+
`).trimStart();P(V,r.endsWith(`
|
|
17
|
+
`)?r:`${r}
|
|
18
|
+
`),Y=!0}}catch{}let q=!1,U=X(Q,"CLAUDE.md");try{let z=x(U,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())F(U,{force:!0});else P(U,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:Y,claudeImportRemoved:q}}var i=`---
|
|
19
19
|
name: beacon-init
|
|
20
20
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
21
21
|
---
|
|
@@ -52,7 +52,7 @@ A single \`beacon_init_persist\` MCP tool call with:
|
|
|
52
52
|
If \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-init.
|
|
53
53
|
|
|
54
54
|
After the tool returns, tell the user the counts (components / roadmap / tables / endpoints) and point them at the running Beacon panel.
|
|
55
|
-
`,
|
|
55
|
+
`,e=`---
|
|
56
56
|
name: beacon-refresh
|
|
57
57
|
description: Re-survey the repo and update Beacon's architecture / schema / endpoints map after /beacon-init was already run \u2014 picks up new components, removed ones, schema changes, and new routes. Use when the user runs /beacon-refresh or asks to "refresh", "update", "re-sync", or "bring Beacon up to date" with the current code.
|
|
58
58
|
---
|
|
@@ -99,7 +99,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
99
99
|
If \`beacon_entities\` or \`beacon_init_persist\` isn't available, the Beacon panel isn't running in this repo. Tell the user to run \`beacon\` here first, then re-invoke /beacon-refresh.
|
|
100
100
|
|
|
101
101
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
102
|
-
`,
|
|
102
|
+
`,MQ=`---
|
|
103
103
|
name: beacon-plan
|
|
104
104
|
description: Present your current plan or approach to the user on Beacon's /plan canvas for review \u2014 instead of asking for approval in prose. Use when the user says "present the plan", "show me the plan", "let me see it / the plan", or whenever you are about to end a turn asking whether to proceed with a plan, design, or approach.
|
|
105
105
|
---
|
|
@@ -141,7 +141,7 @@ If it returns feedback, revise and call it again.
|
|
|
141
141
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
142
142
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
143
143
|
run \`beacon\` in this repo once.
|
|
144
|
-
`,
|
|
144
|
+
`,zZ,R="<!-- beacon:workflow:start -->",QQ="<!-- beacon:workflow:end -->",CQ;var $Q=K(()=>{zZ=[{name:"beacon-init",body:()=>i},{name:"beacon-refresh",body:()=>e}];CQ=`${R}
|
|
145
145
|
## Beacon \u2014 feature workflow
|
|
146
146
|
|
|
147
147
|
This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
|
|
@@ -195,18 +195,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
195
195
|
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.
|
|
196
196
|
|
|
197
197
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
198
|
-
${
|
|
199
|
-
`)}function
|
|
198
|
+
${QQ}`});import{existsSync as wQ,mkdirSync as JQ,readFileSync as D,rmSync as xZ,writeFileSync as I}from"fs";import{dirname as gQ,join as b}from"path";function YQ(Q){try{return JSON.parse(D(Q,"utf8"))}catch{return{}}}function TQ(Q,Z){JQ(gQ(Q),{recursive:!0}),I(Q,JSON.stringify(Z,null,2)+`
|
|
199
|
+
`)}function E(Q,Z){let $=YQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let J=$.hooks[Z.event];if(J.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return J.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),TQ(Q,$),!0}function A(Q,Z){return(YQ(Q).hooks?.[Z.event]??[]).some((Y)=>Y.hooks?.some((V)=>V.command===Z.command))}function y(Q,Z){let $=YQ(Q),J=$.hooks?.[Z.event];if(!J)return!1;let Y=!1,V=J.map((q)=>{let U=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==U)Y=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!Y)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return TQ(Q,$),!0}function k(Q,Z,$,J){let Y=`${Z}
|
|
200
200
|
${J.trim()}
|
|
201
|
-
${$}`,V="";try{V=
|
|
201
|
+
${$}`,V="";try{V=D(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,Y):V.trim()?`${V.trim()}
|
|
202
202
|
|
|
203
203
|
${Y}
|
|
204
204
|
`:`${Y}
|
|
205
|
-
|
|
205
|
+
`,JQ(gQ(Q),{recursive:!0}),I(Q,V.endsWith(`
|
|
206
206
|
`)?V:`${V}
|
|
207
|
-
`)}function u(Q,Z){try{return
|
|
207
|
+
`)}function u(Q,Z){try{return D(Q,"utf8").includes(Z)}catch{return!1}}function L(Q,Z,$){let J="";try{J=D(Q,"utf8")}catch{return!1}let Y=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!Y.test(J))return!1;let V=J.replace(Y,"").replace(/\n{3,}/g,`
|
|
208
208
|
|
|
209
|
-
`).trimStart();return I(Q,V),!0}function
|
|
209
|
+
`).trimStart();return I(Q,V),!0}function _(Q,Z,$){let J=b(Q,Z);JQ(J,{recursive:!0});let Y=b(J,"SKILL.md");return I(Y,$),Y}function v(Q,Z){return wQ(b(Q,Z,"SKILL.md"))}function h(Q,Z){let $=b(Q,Z);if(!wQ($))return!1;return xZ($,{recursive:!0,force:!0}),!0}var H,O=`## Beacon (visual planning panel)
|
|
210
210
|
|
|
211
211
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
212
212
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -227,18 +227,18 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
227
227
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
228
228
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
229
229
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
230
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
230
|
+
verbatim. Do NOT implement until the tool returns approval.`;var VQ=K(()=>{H=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as HZ,renameSync as jZ,rmSync as BZ,writeFileSync as GZ}from"fs";import{dirname as NZ}from"path";function zQ(Q,Z){HZ(NZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{GZ($,Z),jZ($,Q)}catch(J){throw BZ($,{force:!0}),J}}var FQ=()=>{};var AQ={};o(AQ,{setupCodexAssets:()=>CZ,removeCodexMcp:()=>EQ,removeCodexArtifacts:()=>wZ,hasCodexMcp:()=>WQ,ensureCodexMcp:()=>OQ,codexMcpProblem:()=>vZ,codexDetected:()=>bQ,auditCodex:()=>MZ,CODEX_HOOKS:()=>n});import{readFileSync as c}from"fs";import{homedir as KZ}from"os";import{join as w}from"path";function fQ(){return process.env.HOME||process.env.USERPROFILE||KZ()}function bQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(qQ===void 0)qQ=Bun.which("codex")!==null;return qQ}function M(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function WQ(){try{return Boolean(M(c(G(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function vZ(){let Q="";try{Q=c(G(),"utf8")}catch{return null}let Z=M(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${C}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${C}`;return null}function OQ(){let Q="",Z=!1;try{Q=c(G(),"utf8"),Z=!0}catch{}if(Z){let V=M(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${C}`};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 ${C}`}}let $=!Q?"":Q.endsWith(`
|
|
231
231
|
`)?`
|
|
232
232
|
`:`
|
|
233
233
|
|
|
234
|
-
`,J=Q+$+
|
|
235
|
-
`),$=Z.indexOf(
|
|
234
|
+
`,J=Q+$+uZ;if(M(J)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${C}`};return zQ(G(),J),{added:!0}}function EQ(){let Q="";try{Q=c(G(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
235
|
+
`),$=Z.indexOf(DQ);if($===-1)return{removed:!1,skipped:WQ()};let J=Z.indexOf(IQ,$);if(J===-1)return{removed:!1,skipped:!0};Z.splice($,J-$+1);let Y=Z.join(`
|
|
236
236
|
`).replace(/\n{3,}/g,`
|
|
237
237
|
|
|
238
|
-
`).replace(/^\n+/,"");if(M(Y)===null)return{removed:!1,skipped:!0};return
|
|
238
|
+
`).replace(/^\n+/,"");if(M(Y)===null)return{removed:!1,skipped:!0};return zQ(G(),Y),{removed:!0}}async function CZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => ($Q(),ZQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let z of H){if(!v(m(),z))Y.push(z);_(m(),z,J[z])}let V=0;for(let z of n)if(E(UQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=u(S(),p);k(S(),p,RQ,O);let U=OQ();return{skillsAdded:Y,hooksAdded:V,agentsMdBlockTouched:!q,mcp:U}}function MZ(){let Q={};for(let $ of H)Q[$]=v(m(),$);let Z={};for(let $ of n)Z[$.event]=A(UQ(),{event:$.event,command:$.command});return{detected:bQ(),skills:Q,hooks:Z,agentsMdBlock:u(S(),p),mcp:WQ()}}function wZ(){let Q=[];for(let Y of H)if(h(m(),Y))Q.push(Y);let Z=0;for(let Y of n)if(y(UQ(),{event:Y.event,command:Y.command}))Z++;let $=L(S(),p,RQ),J=EQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:J.removed,mcpSkipped:J.skipped}}var XQ=()=>w(fQ(),".codex"),UQ=()=>w(XQ(),"hooks.json"),G=()=>w(XQ(),"config.toml"),S=()=>w(XQ(),"AGENTS.md"),m=()=>w(fQ(),".agents","skills"),p="<!-- beacon:global:start -->",RQ="<!-- beacon:global:end -->",n,qQ,DQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",IQ="# beacon:end",uZ,C="add it manually: codex mcp add beacon -- beacon mcp";var yQ=K(()=>{VQ();FQ();n=[{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."}];uZ=`${DQ}
|
|
239
239
|
[mcp_servers.beacon]
|
|
240
240
|
command = "beacon"
|
|
241
241
|
args = ["mcp"]
|
|
242
|
-
${
|
|
243
|
-
`});var
|
|
244
|
-
`)){let J=X0.exec($.trim());if(!J)continue;let Y=J[2].trim();if(J[1]==="Move to")Z.pop();Z.push(Y)}return Z}function
|
|
242
|
+
${IQ}
|
|
243
|
+
`});var mQ={};o(mQ,{provisionDb:()=>lZ});import{createClient as kZ}from"@libsql/client";import{drizzle as LZ}from"drizzle-orm/libsql";import{migrate as _Z}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as hZ}from"drizzle-orm/migrator";import{dirname as GQ,join as SZ}from"path";import{fileURLToPath as mZ}from"url";async function l(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function aZ(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((J)=>String(J.name)))}async function SQ(Q){if(!await l(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 dZ(Q){for(let[Z,$]of Object.entries(nZ)){if(!await l(Q,Z))continue;let J=await aZ(Q,Z);for(let Y of $){if(!J.has(Y))continue;await Q.execute(`UPDATE "${Z}" SET "${Y}" = CAST((julianday("${Y}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${Y}") = 'text'`)}}}async function lZ(Q,Z=cZ){let $=kZ({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;");let J=await l($,"__drizzle_migrations"),Y=await l($,"Node"),V=!1;if(Y&&!J){let U=hZ({migrationsFolder:Z})[0];if(U)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:[U.hash,U.folderMillis]}),V=!0}let q=await SQ($);if(await _Z(LZ($),{migrationsFolder:Z}),await SQ($)>q)V=!0;return await dZ($),{migrated:V}}finally{$.close()}}var pZ,cZ,nZ;var pQ=K(async()=>{pZ=GQ(GQ(GQ(mZ(import.meta.url)))),cZ=process.env.BEACON_MIGRATIONS_DIR||SZ(pZ,"drizzle"),nZ={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});VQ();import{existsSync as gZ}from"fs";import{homedir as TZ}from"os";import{join as a}from"path";function FZ(){return process.env.HOME||process.env.USERPROFILE||TZ()}var d=()=>a(FZ(),".claude"),PQ=()=>a(d(),"skills"),xQ=()=>a(d(),"settings.json"),HQ=()=>a(d(),"CLAUDE.md"),jQ="<!-- beacon:global:start -->",kQ="<!-- beacon:global:end -->";var fZ=O,BQ=[{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon hook",description:"Report file edits to Beacon's active feature so the map stays fresh."},{event:"PermissionRequest",matcher:"ExitPlanMode",command:"beacon plan",description:"Pipe the agent's plan markdown into Beacon's /plan canvas for review."},{event:"UserPromptSubmit",matcher:"*",command:"beacon prompt",description:"On feature-y prompts in a Beacon-wired repo, remind the agent to run the context\u2192propose\u2192describe loop (no-op otherwise)."},{event:"Stop",matcher:"*",command:"beacon stop-hook",description:"When the agent ends a turn asking for plan approval in prose (instead of presenting it), nudge it to present the plan on Beacon's /plan canvas. Bounded by stop_hook_active \u2014 at most one nudge."}];function RZ(Q,Z){return _(PQ(),Q,Z)}function LQ(Q){return v(PQ(),Q)}function bZ(Q){return h(PQ(),Q)}function DZ(Q){return E(xQ(),Q)}function IZ(Q){return A(xQ(),Q)}function OZ(Q){return y(xQ(),Q)}function EZ(Q){k(HQ(),jQ,kQ,Q)}function _Q(){return u(HQ(),jQ)}function AZ(){return L(HQ(),jQ,kQ)}function b0(){let Q={};for(let $ of H)Q[$]=LQ($);let Z={};for(let $ of BQ)Z[$.event]=IZ({event:$.event,command:$.command});return{homeExists:gZ(d()),skills:Q,hooks:Z,claudeMdBlock:_Q()}}async function yZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => ($Q(),ZQ)),J={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},Y=[];for(let U of H){if(!LQ(U))Y.push(U);RZ(U,J[U])}let V=0;for(let U of BQ)if(DZ({event:U.event,matcher:U.matcher,command:U.command}))V++;let q=_Q();return EZ(fZ),{skillsAdded:Y,hooksAdded:V,claudeMdBlockTouched:!q}}async function hQ(){let Q;try{Q={ok:!0,...await yZ()}}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(() => (yQ(),AQ));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 D0(){let Q=[];for(let J of H)if(bZ(J))Q.push(J);let Z=0;for(let J of BQ)if(OZ(J))Z++;let $=AZ();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as sZ}from"async_hooks";import{spawnSync as tZ}from"child_process";import{createHash as rZ}from"crypto";import{existsSync as nQ,mkdirSync as s,readFileSync as aQ,writeFileSync as dQ}from"fs";import{homedir as oZ}from"os";import{basename as iZ,join as N}from"path";function g(){return process.env.BEACON_HOME||N(oZ(),".beacon")}function NQ(){return N(g(),"workspaces.json")}function t(Q){return rZ("sha256").update(Q).digest("hex").slice(0,12)}function lQ(Q=process.cwd()){let Z=tZ("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 KQ(Q){return N(g(),Q)}function eZ(Q){return`file:${N(KQ(Q),"db.sqlite")}`}function T(){try{let Q=JSON.parse(aQ(NQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function uQ(Q){s(g(),{recursive:!0}),dQ(NQ(),JSON.stringify(Q,null,2))}function Q0(){return T().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function j(Q){return T().find((Z)=>Z.id===Q)??null}function Z0(Q,Z,$=new Date().toISOString()){let J=t(Q),Y=T(),V=Y.find((z)=>z.id===J),q={id:J,path:Q,name:Z||V?.name||iZ(Q),lastOpenedAt:$},U=[q,...Y.filter((z)=>z.id!==J)];return s(KQ(J),{recursive:!0}),uQ(U),q}function n0(Q,Z=new Date().toISOString()){let $=T(),J=$.find((Y)=>Y.id===Q);if(!J)return;J.lastOpenedAt=Z,uQ($)}function a0(Q){if(uQ(T().filter((Z)=>Z.id!==Q)),vQ()===Q)$0(Q0()[0]?.id??null)}function sQ(){return N(g(),"active")}function vQ(){try{return aQ(sQ(),"utf8").trim()||null}catch{return null}}function $0(Q){s(g(),{recursive:!0}),dQ(sQ(),Q??"")}function d0(){let Q=vQ();return Q?j(Q):null}function l0(){let Q=Y0()??vQ();return Q?j(Q):null}function s0(Q){return j(Q)?.path??null}function t0(){return nQ(NQ())}var tQ="beacon_ws";function rQ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let J of $.split(";")){let Y=J.indexOf("=");if(Y===-1)continue;if(J.slice(0,Y).trim()===Z)return decodeURIComponent(J.slice(Y+1).trim())}return null}function r0(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&j(Z))return Z;let $=rQ(Q,tQ);if($&&j($))return $;return null}var J0="x-beacon-workspace-path";async function o0(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&j(Z))return Z;let $=Q.headers.get(J0);if($&&(!Z||t($)===Z)){let Y=Z0($);return await V0(Y.id),Y.id}let J=rQ(Q,tQ);if(J&&j(J))return J;return null}var oQ=new sZ;function i0(Q,Z){return Q?oQ.run(Q,Z):Z()}function Y0(){return oQ.getStore()??null}var cQ=new Set;async function V0(Q){let Z=KQ(Q),$=N(Z,"db.sqlite"),J=nQ($);if(J&&cQ.has($))return{ok:!0,created:!1,migrated:!1};try{s(Z,{recursive:!0});let{provisionDb:Y}=await pQ().then(() => mQ),V=await Y(eZ(Q));return cQ.add($),{ok:!0,created:!J,migrated:J&&V.migrated}}catch(Y){return{ok:!1,created:!1,migrated:!1,error:Y instanceof Error?Y.message:String(Y)}}}import{resolve as z0}from"path";var q0="*** Begin Patch",X0=/^\*\*\* (Update File|Add File|Move to): (.+)$/;function U0(Q){let Z=[];for(let $ of Q.split(`
|
|
244
|
+
`)){let J=X0.exec($.trim());if(!J)continue;let Y=J[2].trim();if(J[1]==="Move to")Z.pop();Z.push(Y)}return Z}function iQ(Q){let Z=Q.tool_input;if(Z===null||typeof Z!=="object")return[];let $=Z,J=[];if(typeof $.file_path==="string")J.push($.file_path);if(typeof $.path==="string")J.push($.path);if(Array.isArray($.files))for(let V of $.files){let q=V?.file_path;if(typeof q==="string")J.push(q)}if(J.length)return J;let Y=typeof Q.cwd==="string"?Q.cwd:process.cwd();for(let V of Object.values($)){if(typeof V!=="string"||!V.includes(q0))continue;return U0(V).map((q)=>z0(Y,q))}return[]}var W0=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`;await hQ();var eQ="";for await(let Q of process.stdin)eQ+=Q;try{let Q=JSON.parse(eQ||"{}"),Z=iQ(Q);if(Z.length){let $=t(lQ(typeof Q.cwd==="string"?Q.cwd:void 0));await fetch(`${W0}/api/map/touch-active`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":$},body:JSON.stringify({files:Z})}).catch(()=>{})}}catch{}process.exit(0);
|