trybeacon 0.1.64 → 0.1.66
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 +15 -8
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +42 -0
- package/.next/server/app/_global-error/page.js +2 -2
- 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_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +11 -11
- package/.next/server/app/_not-found.segments/_full.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/board-annotations/[id]/route.js +1 -1
- package/.next/server/app/api/board-annotations/route.js +1 -1
- package/.next/server/app/api/board-layout/route.js +1 -1
- package/.next/server/app/api/bug-flags/[id]/route.js +1 -1
- package/.next/server/app/api/bug-flags/route.js +1 -1
- package/.next/server/app/api/code-graph/position/route.js +1 -1
- package/.next/server/app/api/code-graph/route.js +1 -1
- package/.next/server/app/api/context/feature/route.js +1 -1
- package/.next/server/app/api/context/file/route.js +1 -1
- package/.next/server/app/api/context/route.js +1 -1
- package/.next/server/app/api/db/arrange/route.js +1 -1
- package/.next/server/app/api/db/backfill-access/route.js +1 -1
- package/.next/server/app/api/db/position/route.js +1 -1
- package/.next/server/app/api/db/prune-planned/route.js +1 -1
- package/.next/server/app/api/db/reconcile-endpoints/route.js +1 -1
- package/.next/server/app/api/db/relations/[id]/route.js +1 -1
- package/.next/server/app/api/db/tables/[id]/route.js +1 -1
- package/.next/server/app/api/draft/approve/route.js +1 -1
- package/.next/server/app/api/draft/route.js +1 -1
- package/.next/server/app/api/draft/status/route.js +1 -1
- package/.next/server/app/api/edges/[id]/route.js +1 -1
- package/.next/server/app/api/edges/route.js +1 -1
- package/.next/server/app/api/endpoints/[id]/route.js +1 -1
- package/.next/server/app/api/entities/route.js +1 -1
- package/.next/server/app/api/feedback/[id]/route.js +1 -1
- package/.next/server/app/api/feedback/[id]/vote/route.js +1 -1
- package/.next/server/app/api/feedback/route.js +1 -1
- package/.next/server/app/api/flags/route.js +1 -1
- package/.next/server/app/api/ingest/route.js +2 -2
- package/.next/server/app/api/init/route.js +2 -2
- package/.next/server/app/api/lesson/close/route.js +1 -0
- package/.next/server/app/api/lesson/close/route.js.nft.json +1 -0
- package/.next/server/app/api/lesson/close/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/lesson/presence/route.js +1 -0
- package/.next/server/app/api/lesson/presence/route.js.nft.json +1 -0
- package/.next/server/app/api/lesson/presence/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/lesson/questions/route.js +1 -0
- package/.next/server/app/api/lesson/questions/route.js.nft.json +1 -0
- package/.next/server/app/api/lesson/questions/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/lesson/route.js +1 -0
- package/.next/server/app/api/lesson/route.js.nft.json +1 -0
- package/.next/server/app/api/lesson/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/lesson/save/route.js +1 -0
- package/.next/server/app/api/lesson/save/route.js.nft.json +1 -0
- package/.next/server/app/api/lesson/save/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/lesson/verdict/route.js +1 -0
- package/.next/server/app/api/lesson/verdict/route.js.nft.json +1 -0
- package/.next/server/app/api/lesson/verdict/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/map/describe/route.js +2 -2
- package/.next/server/app/api/map/files/route.js +1 -1
- package/.next/server/app/api/map/finish/route.js +1 -1
- package/.next/server/app/api/map/route.js +1 -1
- package/.next/server/app/api/map/start/route.js +1 -1
- package/.next/server/app/api/map/touch-active/route.js +1 -1
- package/.next/server/app/api/mention-search/route.js +1 -1
- package/.next/server/app/api/nodes/[id]/position/route.js +1 -1
- package/.next/server/app/api/nodes/[id]/route.js +1 -1
- package/.next/server/app/api/nodes/positions/route.js +1 -1
- package/.next/server/app/api/nodes/route.js +1 -1
- package/.next/server/app/api/nodes/subtasks/route.js +1 -1
- package/.next/server/app/api/notes/[id]/route.js +1 -1
- package/.next/server/app/api/notes/route.js +1 -1
- package/.next/server/app/api/open/route.js +1 -1
- package/.next/server/app/api/plan/annotations/route.js +3 -3
- package/.next/server/app/api/plan/approve/route.js +2 -2
- package/.next/server/app/api/plan/history/route.js +1 -1
- package/.next/server/app/api/plan/markdown/route.js +1 -1
- package/.next/server/app/api/plan/presence/route.js +1 -1
- package/.next/server/app/api/plan/route.js +1 -1
- package/.next/server/app/api/plan/verdict/route.js +1 -1
- package/.next/server/app/api/preferences/route.js +1 -1
- package/.next/server/app/api/project-meta/route.js +1 -1
- package/.next/server/app/api/reset/route.js +1 -1
- package/.next/server/app/api/scope-guard/check/route.js +1 -1
- package/.next/server/app/api/share/create/route.js +1 -1
- package/.next/server/app/api/share/route.js +1 -1
- package/.next/server/app/api/stream/route.js +2 -2
- package/.next/server/app/api/tab/nav/route.js +1 -1
- package/.next/server/app/api/tab/presence/route.js +1 -1
- package/.next/server/app/api/telemetry/route.js +1 -1
- package/.next/server/app/api/telemetry/stats/route.js +1 -1
- package/.next/server/app/api/version/route.js +1 -1
- package/.next/server/app/api/workspace/activate/route.js +1 -1
- package/.next/server/app/api/workspace/route.js +1 -1
- package/.next/server/app/apple-icon.png/route.js +1 -1
- package/.next/server/app/docs/page.js +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 +11 -11
- package/.next/server/app/docs.segments/_full.segment.rsc +11 -11
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +11 -11
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page.js +2 -2
- 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 +11 -11
- package/.next/server/app/feedback.segments/_full.segment.rsc +11 -11
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +11 -11
- package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page.js +2 -2
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +11 -11
- package/.next/server/app/help.segments/_full.segment.rsc +11 -11
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +11 -11
- 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/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +12 -12
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +12 -12
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +11 -11
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/learn/page.js +6 -0
- package/.next/server/app/learn/page.js.nft.json +1 -0
- package/.next/server/app/learn/page_client-reference-manifest.js +1 -0
- 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 +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/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 +15 -8
- package/.next/server/chunks/2050.js +1 -1
- package/.next/server/chunks/3174.js +1 -0
- package/.next/server/chunks/3584.js +154 -0
- package/.next/server/chunks/4307.js +1 -1
- package/.next/server/chunks/6024.js +2 -0
- package/.next/server/chunks/{4384.js → 7187.js} +1 -1
- package/.next/server/chunks/8035.js +1 -0
- package/.next/server/chunks/9338.js +8 -8
- 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/P3uXQySdS-m6_bxuiezYe/_buildManifest.js +1 -0
- package/.next/static/chunks/1909-98243a0473be2aae.js +1 -0
- package/.next/static/chunks/1936-7fea5225b5bfcfda.js +1 -0
- package/.next/static/chunks/2019-3be80edc82176878.js +1 -0
- package/.next/static/chunks/4549-591415d55ca009a3.js +62 -0
- package/.next/static/chunks/6638-4e53879181b1df75.js +1 -0
- package/.next/static/chunks/{4888-911c0da3c2d785d2.js → 7043-254590cf9891391f.js} +1 -1
- package/.next/static/chunks/7643-6c7ff4b9400f68fc.js +1 -0
- package/.next/static/chunks/app/_global-error/page-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/board-layout/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/code-graph/position/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/code-graph/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/context/feature/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/context/file/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/context/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/arrange/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/backfill-access/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/position/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/prune-planned/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/relations/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/db/tables/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/draft/approve/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/draft/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/draft/status/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/edges/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/edges/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/endpoints/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/entities/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/feedback/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/feedback/[id]/vote/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/feedback/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/flags/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/ingest/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/init/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/lesson/close/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/lesson/presence/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/lesson/questions/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/lesson/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/lesson/save/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/lesson/verdict/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/map/describe/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/map/files/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/map/finish/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/map/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/map/start/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/map/touch-active/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/mention-search/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/position/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/nodes/positions/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/nodes/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/nodes/subtasks/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/notes/[id]/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/notes/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/open/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/annotations/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/approve/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/history/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/markdown/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/presence/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/plan/verdict/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/preferences/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/project-meta/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/reset/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/scope-guard/check/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/share/create/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/share/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/stream/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/tab/nav/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/tab/presence/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/telemetry/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/telemetry/stats/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/version/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/workspace/activate/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/api/workspace/route-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/app/layout-0c993f55d3a798f4.js +1 -0
- package/.next/static/chunks/app/learn/page-797d74e02b98fa88.js +5 -0
- package/.next/static/chunks/app/map/page-634b6d5d98e921b3.js +1 -0
- package/.next/static/chunks/app/page-84dc684d45002cfb.js +1 -0
- package/.next/static/chunks/app/plan/page-df829b2054c40611.js +1 -0
- package/.next/static/chunks/app/s/[token]/page-f97dec75856a7952.js +1 -0
- package/.next/static/chunks/app/settings/page-59d90685cd17fc1f.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-2390ea0e69e5991f.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-2390ea0e69e5991f.js +1 -0
- package/.next/static/css/b3d3212da726bbfb.css +1 -0
- package/.next/trace +43 -42
- package/.next/trace-build +1 -1
- package/.next/types/app/api/lesson/close/route.ts +351 -0
- package/.next/types/app/api/lesson/presence/route.ts +351 -0
- package/.next/types/app/api/lesson/questions/route.ts +351 -0
- package/.next/types/app/api/lesson/route.ts +351 -0
- package/.next/types/app/api/lesson/save/route.ts +351 -0
- package/.next/types/app/api/lesson/verdict/route.ts +351 -0
- package/.next/types/app/learn/page.ts +87 -0
- package/.next/types/routes.d.ts +9 -2
- package/.next/types/validator.ts +63 -0
- package/README.md +2 -1
- package/dist/bin/doctor.js +92 -22
- package/dist/bin/hook.js +91 -21
- package/dist/bin/mcp.js +107 -35
- package/dist/bin/plan.js +92 -22
- package/dist/bin/uninstall.js +95 -25
- package/dist/lib/assets.js +81 -14
- package/dist/lib/codex-install.js +92 -22
- package/dist/lib/global-install.js +93 -23
- package/package.json +1 -1
- package/plugin/skills/beacon-explain/SKILL.md +63 -0
- package/.next/server/chunks/2942.js +0 -1
- package/.next/server/chunks/2994.js +0 -2
- package/.next/server/chunks/3284.js +0 -154
- package/.next/server/chunks/5719.js +0 -1
- package/.next/static/chunks/3415-05007c2bd98125c7.js +0 -1
- package/.next/static/chunks/5957-83f611fcd5a08b45.js +0 -1
- package/.next/static/chunks/766-242213d211df0afd.js +0 -1
- package/.next/static/chunks/874-c750840a8644deb1.js +0 -1
- package/.next/static/chunks/8915-fa61a860c63a7c85.js +0 -62
- package/.next/static/chunks/8997-78a359d0d238622e.js +0 -1
- package/.next/static/chunks/app/_global-error/page-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/board-layout/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/code-graph/position/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/code-graph/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/context/feature/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/context/file/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/context/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/arrange/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/backfill-access/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/position/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/prune-planned/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/relations/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/db/tables/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/draft/approve/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/draft/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/draft/status/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/edges/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/edges/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/endpoints/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/entities/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/feedback/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/feedback/[id]/vote/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/feedback/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/flags/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/ingest/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/init/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/map/describe/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/map/files/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/map/finish/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/map/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/map/start/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/map/touch-active/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/mention-search/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/position/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/nodes/positions/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/nodes/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/nodes/subtasks/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/notes/[id]/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/notes/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/open/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/annotations/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/approve/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/history/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/markdown/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/presence/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/plan/verdict/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/preferences/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/project-meta/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/reset/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/scope-guard/check/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/share/create/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/share/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/stream/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/tab/nav/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/tab/presence/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/telemetry/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/telemetry/stats/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/version/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/workspace/activate/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/api/workspace/route-548a84d85e061550.js +0 -1
- package/.next/static/chunks/app/layout-3115f8503ff00902.js +0 -1
- package/.next/static/chunks/app/map/page-491d4767dbc4e954.js +0 -1
- package/.next/static/chunks/app/page-d08947a671077569.js +0 -1
- package/.next/static/chunks/app/plan/page-a90e0981499546e3.js +0 -1
- package/.next/static/chunks/app/s/[token]/page-5c8f260e75758b02.js +0 -1
- package/.next/static/chunks/app/settings/page-7e176d120b1effa9.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-548a84d85e061550.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-548a84d85e061550.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-548a84d85e061550.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-548a84d85e061550.js +0 -1
- package/.next/static/css/490566ec68a48e1a.css +0 -1
- package/.next/static/qoq7TibU72duRZATxeVnT/_buildManifest.js +0 -1
- /package/.next/static/{qoq7TibU72duRZATxeVnT → P3uXQySdS-m6_bxuiezYe}/_ssgManifest.js +0 -0
package/dist/bin/mcp.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var b9=Object.defineProperty;var m9=($)=>$;function p9($,Q){this[$]=m9.bind(null,Q)}var t=($,Q)=>{for(var Z in Q)b9($,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:p9.bind(Q,Z)})};var o=($,Q)=>()=>($&&(Q=$($=0)),Q);var q0=1500,mQ=480000,P0=1800000,C0=3600000,S5=3000;var r0=()=>{};var $5={};t($5,{removeRepoAssets:()=>t9,installRefreshSkill:()=>l9,installPlanSkill:()=>d9,installInitSkill:()=>c9,installExplainSkill:()=>o9,installCodexRepoSkills:()=>n9,ensureWorkflowDoc:()=>i9,ensureMcp:()=>r9,auditRepo:()=>a9,REFRESH_SKILL:()=>t0,PLAN_SKILL:()=>f5,INIT_SKILL:()=>a0,EXPLAIN_SKILL:()=>h5});import{existsSync as s,mkdirSync as e,readFileSync as _,rmSync as w0,writeFileSync as T}from"fs";import{join as N}from"path";function c9($){let Q=N($,".claude","skills","beacon-init");e(Q,{recursive:!0});let Z=N(Q,"SKILL.md");return T(Z,a0),Z}function l9($){let Q=N($,".claude","skills","beacon-refresh");e(Q,{recursive:!0});let Z=N(Q,"SKILL.md");return T(Z,t0),Z}function d9($){let Q=N($,".claude","skills","beacon-plan");e(Q,{recursive:!0});let Z=N(Q,"SKILL.md");return T(Z,f5),Z}function o9($){let Q=N($,".claude","skills","beacon-explain");e(Q,{recursive:!0});let Z=N(Q,"SKILL.md");return T(Z,h5),Z}function n9($){let Q=[];for(let Z of s9){let Y=N($,".agents","skills",Z.name);e(Y,{recursive:!0});let X=N(Y,"SKILL.md");T(X,Z.body()),Q.push(X)}return Q}function i9($){let Q=N($,"AGENTS.md"),Z="";try{Z=_(Q,"utf8")}catch{}let Y=new RegExp(`${F0}[\\s\\S]*?${e0}`);Z=Y.test(Z)?Z.replace(Y,z5):`${Z.trim()}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
`.trimStart(),
|
|
5
|
+
${z5}
|
|
6
|
+
`.trimStart(),T(Q,Z.endsWith(`
|
|
7
7
|
`)?Z:`${Z}
|
|
8
|
-
`);let X=
|
|
8
|
+
`);let X=N($,"CLAUDE.md"),H="";try{H=_(X,"utf8")}catch{}if(!/@AGENTS\.md/.test(H))T(X,`${H?`${H.trim()}
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
|
-
`)}function
|
|
12
|
-
`),{path:Q,added:!1,updated:!0};return{path:Q,added:!1,updated:!1}}return Z.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:
|
|
13
|
-
`),{path:Q,added:!0,updated:!1}}function
|
|
14
|
-
`)}}catch{}let X=!1,H=
|
|
11
|
+
`)}function r9($){let Q=N($,".mcp.json"),Z={};try{Z=JSON.parse(_(Q,"utf8"))}catch{}Z.mcpServers=Z.mcpServers??{};let Y=Z.mcpServers.beacon;if(Y){if(!Y.timeout||Y.timeout<C0)return Y.timeout=C0,T(Q,JSON.stringify(Z,null,2)+`
|
|
12
|
+
`),{path:Q,added:!1,updated:!0};return{path:Q,added:!1,updated:!1}}return Z.mcpServers.beacon={command:"beacon",args:["mcp"],timeout:C0},T(Q,JSON.stringify(Z,null,2)+`
|
|
13
|
+
`),{path:Q,added:!0,updated:!1}}function a9($){let Q=N($,".mcp.json"),Z=!1;try{Z=!!JSON.parse(_(Q,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=_(N($,"AGENTS.md"),"utf8").includes(F0)}catch{}let X=!1;try{X=/@AGENTS\.md/.test(_(N($,"CLAUDE.md"),"utf8"))}catch{}return{repo:$,mcpRegistered:Z,agentsMdBlock:Y,claudeMdImport:X,skills:{"beacon-init":s(N($,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":s(N($,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":s(N($,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":s(N($,".agents","skills","beacon-refresh","SKILL.md"))}}}function t9($){let Q=[];for(let j of["beacon-init","beacon-refresh","beacon-db-design"]){let K=N($,".claude","skills",j);if(s(K))w0(K,{recursive:!0,force:!0}),Q.push(j)}for(let j of["beacon-init","beacon-refresh"]){let K=N($,".agents","skills",j);if(s(K))w0(K,{recursive:!0,force:!0}),Q.push(`codex:${j}`)}let Z=!1,Y=N($,".mcp.json");try{let j=JSON.parse(_(Y,"utf8"));if(j.mcpServers?.beacon){if(delete j.mcpServers.beacon,Z=!0,j.mcpServers&&Object.keys(j.mcpServers).length===0)delete j.mcpServers;if(Object.keys(j).length===0)w0(Y,{force:!0});else T(Y,JSON.stringify(j,null,2)+`
|
|
14
|
+
`)}}catch{}let X=!1,H=N($,"AGENTS.md");try{let j=_(H,"utf8"),K=new RegExp(`\\n?${F0}[\\s\\S]*?${e0}\\n?`);if(K.test(j)){let w=j.replace(K,`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
|
-
`).trimStart();
|
|
18
|
-
`)?
|
|
19
|
-
`),X=!0}}catch{}let G=!1,
|
|
17
|
+
`).trimStart();T(H,w.endsWith(`
|
|
18
|
+
`)?w:`${w}
|
|
19
|
+
`),X=!0}}catch{}let G=!1,U=N($,"CLAUDE.md");try{let j=_(U,"utf8"),K=j.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(K!==j){if(!K.trim())w0(U,{force:!0});else T(U,K);G=!0}}catch{}return{skillsRemoved:Q,mcpUnregistered:Z,agentsBlockRemoved:X,claudeImportRemoved:G}}var a0=`---
|
|
20
20
|
name: beacon-init
|
|
21
21
|
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
22
|
---
|
|
@@ -63,7 +63,7 @@ beacon init-persist /tmp/beacon-init.json # or: beacon init-persist < /tmp/bea
|
|
|
63
63
|
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
64
|
|
|
65
65
|
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
|
-
`,
|
|
66
|
+
`,t0=`---
|
|
67
67
|
name: beacon-refresh
|
|
68
68
|
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
69
|
---
|
|
@@ -110,7 +110,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
110
110
|
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
111
|
|
|
112
112
|
After the tool returns, report the final counts plus a one-line summary of the diff you surfaced.
|
|
113
|
-
`,
|
|
113
|
+
`,f5=`---
|
|
114
114
|
name: beacon-plan
|
|
115
115
|
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
116
|
---
|
|
@@ -158,7 +158,70 @@ If it returns feedback, revise and call it again.
|
|
|
158
158
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
159
159
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
160
160
|
run \`beacon\` in this repo once.
|
|
161
|
-
`,
|
|
161
|
+
`,h5=`---
|
|
162
|
+
name: beacon-explain
|
|
163
|
+
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".
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
# Explain the codebase visually (/beacon-explain)
|
|
167
|
+
|
|
168
|
+
When the user wants to UNDERSTAND part of the code (not build something), don't dump prose in the
|
|
169
|
+
terminal and don't open a plan \u2014 plans are for building. Author an interactive **Lesson** and push it
|
|
170
|
+
with the \`beacon_explain\` MCP tool: a curated concept map (boxes + labeled arrows) beside a
|
|
171
|
+
plain-English narrative on Beacon's /learn page. The tool BLOCKS while the user reads, highlights text
|
|
172
|
+
to ask questions, and drops question notes; it returns their questions, you ANSWER and re-push, looping
|
|
173
|
+
until they Save the lesson. There is NO approve/discard \u2014 understanding, not building.
|
|
174
|
+
|
|
175
|
+
## 1. Load context first \u2014 don't explain blind
|
|
176
|
+
|
|
177
|
+
Before writing, call \`beacon_context_for_feature\` / \`beacon_map\` and read the relevant files so the
|
|
178
|
+
lesson is accurate. Name real files, functions, tables, and endpoints \u2014 never vague descriptions.
|
|
179
|
+
|
|
180
|
+
## 2. Write like a great teacher \u2014 the house style (this is the whole point)
|
|
181
|
+
|
|
182
|
+
Every lesson must read like a patient senior engineer explaining to a sharp newcomer:
|
|
183
|
+
|
|
184
|
+
- **Plain English, always.** Define any term the first time it appears. No unexplained jargon, no
|
|
185
|
+
wall of nouns.
|
|
186
|
+
- **Problem-first.** Open each component with the PROBLEM it solves \u2014 a concrete human scenario, the
|
|
187
|
+
tension that forced the design, then the decision and what it means. (e.g. "When a salesperson
|
|
188
|
+
confirms an order it must also land in the ERP \u2014 but the ERP can be slow or down, and you do *not*
|
|
189
|
+
want confirmation to hang. So the sync is *decoupled*: confirming succeeds immediately and the push
|
|
190
|
+
happens in the background, with retries.")
|
|
191
|
+
- **Concrete step-by-step flow.** Walk the real path as a numbered list. Each step is ONE clear
|
|
192
|
+
action and names the real identifier in backticks \u2014 file (\`order-placed-sync-erp.ts\`), function
|
|
193
|
+
(\`syncOrderToErpWorkflow\`), event (\`order.placed\`), column (\`erp_sync_record\`), value
|
|
194
|
+
(\`requires_human_action\`). Enumerate the cases (success / retryable / rejected / \u2026) with the plain
|
|
195
|
+
meaning of each.
|
|
196
|
+
- **Anticipate-and-answer "Why X?".** After the flow, add short sections that answer the confusions a
|
|
197
|
+
reader will actually have ("Why two status columns?", "Why is the ledger append-only?"). ALWAYS
|
|
198
|
+
explain why the alternative is worse ("claiming success could hide a real failure; claiming hard
|
|
199
|
+
failure could cause a duplicate order later").
|
|
200
|
+
- **A worked example with real data.** Show the mechanism running on one concrete case \u2014 ideally a
|
|
201
|
+
small markdown table of state transitions \u2014 and land the insight ("that's 8 rows for one order, and
|
|
202
|
+
that's the point").
|
|
203
|
+
- **Typographic discipline.** **Bold** the decisions, *italic* the concepts being introduced, and put
|
|
204
|
+
\`inline code\` around every real identifier \u2014 on /learn, backticked real file paths become clickable
|
|
205
|
+
to open in the user's editor.
|
|
206
|
+
|
|
207
|
+
## 3. Map the prose to the board
|
|
208
|
+
|
|
209
|
+
Every component/flow you NAME in the narrative becomes a \`node\` (title + a one-line \`summary\` for its
|
|
210
|
+
face + a fuller \`detail\` + the real \`files\` it maps to). Every "A does X to B" becomes an \`edge\` with
|
|
211
|
+
a relationship VERB \u2014 one of: imports, calls, persists to, reads from, writes to, routes to, depends
|
|
212
|
+
on, emits, returns, contains, extends \u2014 never a bare line. Keep the resting set small (~4\u20137 nodes);
|
|
213
|
+
push depth into \`detail\`, not the node face. Supply \`steps\` for the guided walkthrough: the first step
|
|
214
|
+
is the overview (empty \`focusIds\`), then teach one node (or a few) per step in order, each with its
|
|
215
|
+
\`focusIds\`.
|
|
216
|
+
|
|
217
|
+
## 4. Answer in the loop \u2014 don't stop after one round
|
|
218
|
+
|
|
219
|
+
\`beacon_explain\` returns the user's questions, each tagged \`[q:ID]\`. Answer EACH by calling
|
|
220
|
+
\`beacon_explain\` AGAIN with the SAME lesson plus \`answers: [{ questionId, answer }]\` (keyed by the id).
|
|
221
|
+
Every answer must ADD understanding (rationale, trade-off) \u2014 never just restate the question. Expand
|
|
222
|
+
the narrative or add nodes where it helps. Keep looping until the tool reports the user saved or closed
|
|
223
|
+
the lesson.
|
|
224
|
+
`,s9,F0="<!-- beacon:workflow:start -->",e0="<!-- beacon:workflow:end -->",z5;var Q5=o(()=>{r0();s9=[{name:"beacon-init",body:()=>a0},{name:"beacon-refresh",body:()=>t0}];z5=`${F0}
|
|
162
225
|
## Beacon \u2014 feature workflow
|
|
163
226
|
|
|
164
227
|
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:
|
|
@@ -215,6 +278,10 @@ Beacon extracts it deterministically and **strips the block from the prose** (it
|
|
|
215
278
|
|
|
216
279
|
**The board is built ONLY from the block \u2014 prose is NOT parsed.** If your plan describes ANY database models/tables/columns in the prose (e.g. "Model \`legal_precedent.py\` \u2014 natural key (court, \u2026)"), you MUST also put them in the block's \`tables\` array (with \`columns\`), or the /db tab will be empty for that plan. Same for endpoints (\`endpoints\` with \`uses:[{table,access}]\`) and features (\`features\`). A plan that lists five tables in prose but ships a block with only \`features\` renders an empty database board \u2014 exactly the "I described models but the DB tab is empty" failure. Mirror every DB entity you mention into the block.
|
|
217
280
|
|
|
281
|
+
### 2c. Mark the files you mention \u2014 write repo-relative paths in backticks
|
|
282
|
+
|
|
283
|
+
When a plan, feature, or architecture-component description mentions a source file, write its **repo-relative path inside backticks** \u2014 \`app/api/plan/route.ts\`, not "the plan route". On the /plan canvas Beacon turns every backticked token that matches a REAL repo file into a clickable mention that opens it in the user's editor; a bare filename matching several files (e.g. \`route.ts\`) opens a pick-one dropdown of the same-named candidates. The match is deterministic against the live code graph, so a path that isn't a real file just stays plain text \u2014 there's no special syntax to learn and no downside to over-marking: always name files by their real path so the reader can jump straight to the code.
|
|
284
|
+
|
|
218
285
|
### 3. At the end, register the work \u2014 in ONE call
|
|
219
286
|
|
|
220
287
|
Call \`beacon_feature({ action: "done" })\` **ONCE** with a \`features\` array \u2014 one entry per feature the plan created \u2014 each with the files you touched and a short markdown description. This flips each one to **Done** \u2014 including its sub-tasks (the cascade completes every PENDING/IN_PROGRESS child; a sub-task you did NOT finish must be set BLOCKED or CANCELLED before registering, so it survives visibly) \u2014 and keeps \`beacon_context_for_feature\` accurate for the next session.
|
|
@@ -226,18 +293,18 @@ Register them all in that single batched call. If a plan added five features, th
|
|
|
226
293
|
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.
|
|
227
294
|
|
|
228
295
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
229
|
-
${
|
|
230
|
-
`)}function
|
|
296
|
+
${e0}`});import{existsSync as v0,mkdirSync as Z5,readdirSync as e9,readFileSync as $0,rmSync as $$,writeFileSync as D0}from"fs";import{dirname as u5,join as g}from"path";function g5(){return!!process.env.CLAUDE_PLUGIN_ROOT}function b5($=process.env.HOME||process.env.USERPROFILE||""){if(!$)return null;let Q=g($,".claude","plugins");if(!v0(Q))return null;let Z=[Q];for(let Y=0;Y<3&&Z.length;Y++){let X=[];for(let H of Z){let G=g(H,".claude-plugin","plugin.json");try{if(v0(G)&&JSON.parse($0(G,"utf8")).name==="beacon")return H}catch{}try{for(let U of e9(H,{withFileTypes:!0}))if(U.isDirectory())X.push(g(H,U.name))}catch{}}Z=X}return null}function m5($){return b5($)!==null}function J5($){try{return JSON.parse($0($,"utf8"))}catch{return{}}}function p5($,Q){Z5(u5($),{recursive:!0}),D0($,JSON.stringify(Q,null,2)+`
|
|
297
|
+
`)}function R0($,Q){let Z=J5($);Z.hooks=Z.hooks??{},Z.hooks[Q.event]=Z.hooks[Q.event]??[];let Y=Z.hooks[Q.event];if(Y.some((H)=>H.matcher===Q.matcher&&H.hooks?.some((G)=>G.command===Q.command)))return!1;return Y.push({matcher:Q.matcher,hooks:[{type:"command",command:Q.command}]}),p5($,Z),!0}function A0($,Q){return(J5($).hooks?.[Q.event]??[]).some((X)=>X.hooks?.some((H)=>H.command===Q.command))}function E0($,Q){let Z=J5($),Y=Z.hooks?.[Q.event];if(!Y)return!1;let X=!1,H=Y.map((G)=>{let U=G.hooks?.length??0,j=(G.hooks??[]).filter((K)=>K.command!==Q.command);if(j.length!==U)X=!0;return{...G,hooks:j}}).filter((G)=>(G.hooks??[]).length>0);if(!X)return!1;if(H.length)Z.hooks[Q.event]=H;else delete Z.hooks[Q.event];if(Z.hooks&&Object.keys(Z.hooks).length===0)delete Z.hooks;return p5($,Z),!0}function T0($,Q,Z,Y){let X=`${Q}
|
|
231
298
|
${Y.trim()}
|
|
232
|
-
${Z}`,H="";try{H
|
|
299
|
+
${Z}`,H="";try{H=$0($,"utf8")}catch{}let G=new RegExp(`${Q}[\\s\\S]*?${Z}`);H=G.test(H)?H.replace(G,X):H.trim()?`${H.trim()}
|
|
233
300
|
|
|
234
301
|
${X}
|
|
235
302
|
`:`${X}
|
|
236
|
-
`,
|
|
303
|
+
`,Z5(u5($),{recursive:!0}),D0($,H.endsWith(`
|
|
237
304
|
`)?H:`${H}
|
|
238
|
-
`)}function
|
|
305
|
+
`)}function Q0($,Q){try{return $0($,"utf8").includes(Q)}catch{return!1}}function I0($,Q,Z){let Y="";try{Y=$0($,"utf8")}catch{return!1}let X=new RegExp(`${Q}[\\s\\S]*?${Z}\\n?`);if(!X.test(Y))return!1;let H=Y.replace(X,"").replace(/\n{3,}/g,`
|
|
239
306
|
|
|
240
|
-
`).trimStart();return
|
|
307
|
+
`).trimStart();return D0($,H),!0}function k0($,Q,Z){let Y=g($,Q);Z5(Y,{recursive:!0});let X=g(Y,"SKILL.md");return D0(X,Z),X}function Z0($,Q){return v0(g($,Q,"SKILL.md"))}function _0($,Q){let Z=g($,Q);if(!v0(Z))return!1;return $$(Z,{recursive:!0,force:!0}),!0}var S,O0=`## Beacon (visual planning panel)
|
|
241
308
|
|
|
242
309
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
243
310
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -251,6 +318,9 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
251
318
|
- User asks to "refresh Beacon" / "update the map" / "bring Beacon up to date" \u2192 invoke
|
|
252
319
|
the \`beacon-refresh\` skill. Re-surveys the repo and updates init-derived nodes while
|
|
253
320
|
preserving anything the user added by hand.
|
|
321
|
+
- User asks to "explain" / "teach me" / "walk me through" / "how does X work" \u2192 if the
|
|
322
|
+
\`beacon_explain\` MCP tool is available, author an interactive Lesson (a concept map +
|
|
323
|
+
plain-English narrative on /learn the user questions back) via the \`beacon-explain\` skill.
|
|
254
324
|
- Run \`beacon doctor\` to audit what's wired (global hooks, repo's .mcp.json, AGENTS.md block).
|
|
255
325
|
|
|
256
326
|
**The plan feedback loop**
|
|
@@ -258,39 +328,41 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
258
328
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
259
329
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
260
330
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
261
|
-
verbatim. Do NOT implement until the tool returns approval.`;var
|
|
331
|
+
verbatim. Do NOT implement until the tool returns approval.`;var Y5=o(()=>{S=["beacon-init","beacon-refresh","beacon-plan","beacon-explain"]});import{mkdirSync as Q$,renameSync as Z$,rmSync as J$,writeFileSync as Y$}from"fs";import{dirname as V$}from"path";function L0($,Q){Q$(V$($),{recursive:!0});let Z=`${$}.tmp`;try{Y$(Z,Q),Z$(Z,$)}catch(Y){throw J$(Z,{force:!0}),Y}}function aQ($,Q,Z=!1){L0($,JSON.stringify(Q,null,Z?2:void 0))}var c5=()=>{};var a5={};t(a5,{setupCodexAssets:()=>j$,removeCodexMcp:()=>r5,removeCodexArtifacts:()=>U$,hasCodexMcp:()=>G5,ensureCodexMcp:()=>i5,codexMcpProblem:()=>G$,codexDetected:()=>o5,auditCodex:()=>W$,CODEX_HOOKS:()=>f0});import{readFileSync as z0}from"fs";import{homedir as X$}from"os";import{join as V0}from"path";function l5(){return process.env.HOME||process.env.USERPROFILE||X$()}function o5(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(V5===void 0)V5=Bun.which("codex")!==null;return V5}function Y0($){try{return Bun.TOML.parse($)}catch{return null}}function G5(){try{return Boolean(Y0(z0(n(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function G$(){let $="";try{$=z0(n(),"utf8")}catch{return null}let Q=Y0($);if(!Q)return`~/.codex/config.toml does not parse \u2014 ${J0}`;if(Q.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test($))return`mcp_servers is an inline table \u2014 ${J0}`;return null}function i5(){let $="",Q=!1;try{$=z0(n(),"utf8"),Q=!0}catch{}if(Q){let H=Y0($);if(!H)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${J0}`};if(H.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test($))return{added:!1,error:`mcp_servers is an inline table \u2014 ${J0}`}}let Z=!$?"":$.endsWith(`
|
|
262
332
|
`)?`
|
|
263
333
|
`:`
|
|
264
334
|
|
|
265
|
-
`,Y=$+Z+
|
|
266
|
-
`),Z=Q.indexOf(
|
|
335
|
+
`,Y=$+Z+H$;if(Y0(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${J0}`};return L0(n(),Y),{added:!0}}function r5(){let $="";try{$=z0(n(),"utf8")}catch{return{removed:!1}}let Q=$.split(`
|
|
336
|
+
`),Z=Q.indexOf(s5);if(Z===-1)return{removed:!1,skipped:G5()};let Y=Q.indexOf(n5,Z);if(Y===-1)return{removed:!1,skipped:!0};Q.splice(Z,Y-Z+1);let X=Q.join(`
|
|
267
337
|
`).replace(/\n{3,}/g,`
|
|
268
338
|
|
|
269
|
-
`).replace(/^\n+/,"");if(
|
|
339
|
+
`).replace(/^\n+/,"");if(Y0(X)===null)return{removed:!1,skipped:!0};return L0(n(),X),{removed:!0}}async function j$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z,EXPLAIN_SKILL:Y}=await Promise.resolve().then(() => (Q5(),$5)),X={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z,"beacon-explain":Y},H=[];for(let K of S){if(!Z0(x0(),K))H.push(K);k0(x0(),K,X[K])}let G=0;for(let K of f0)if(R0(H5(),{event:K.event,matcher:K.matcher,command:K.command}))G++;let U=Q0(y0(),S0);T0(y0(),S0,d5,O0);let j=i5();return{skillsAdded:H,hooksAdded:G,agentsMdBlockTouched:!U,mcp:j}}function W$(){let $={};for(let Z of S)$[Z]=Z0(x0(),Z);let Q={};for(let Z of f0)Q[Z.event]=A0(H5(),{event:Z.event,command:Z.command});return{detected:o5(),skills:$,hooks:Q,agentsMdBlock:Q0(y0(),S0),mcp:G5()}}function U$(){let $=[];for(let X of S)if(_0(x0(),X))$.push(X);let Q=0;for(let X of f0)if(E0(H5(),{event:X.event,command:X.command}))Q++;let Z=I0(y0(),S0,d5),Y=r5();return{skillsRemoved:$,hooksRemoved:Q,agentsMdBlockRemoved:Z,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var X5=()=>V0(l5(),".codex"),H5=()=>V0(X5(),"hooks.json"),n=()=>V0(X5(),"config.toml"),y0=()=>V0(X5(),"AGENTS.md"),x0=()=>V0(l5(),".agents","skills"),S0="<!-- beacon:global:start -->",d5="<!-- beacon:global:end -->",f0,V5,s5="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",n5="# beacon:end",H$,J0="add it manually: codex mcp add beacon -- beacon mcp";var t5=o(()=>{Y5();c5();f0=[{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."}];H$=`${s5}
|
|
270
340
|
[mcp_servers.beacon]
|
|
271
341
|
command = "beacon"
|
|
272
342
|
args = ["mcp"]
|
|
273
|
-
${
|
|
274
|
-
`});var $9={};t($9,{provisionDb:()=>k$});import{createClient as v$}from"@libsql/client";import{drizzle as F$}from"drizzle-orm/libsql";import{migrate as O$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as D$}from"drizzle-orm/migrator";import{dirname as K5,join as R$}from"path";import{fileURLToPath as A$}from"url";async function h0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function L$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function e5($){if(!await h0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function _$($){for(let[Q,Z]of Object.entries(T$)){if(!await h0($,Q))continue;let Y=await L$($,Q);for(let X of Z){if(!Y.has(X))continue;await $.execute(`UPDATE "${Q}" SET "${X}" = CAST((julianday("${X}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${X}") = 'text'`)}}}async function k$($,Q=I$){let Z=v$({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let Y=await h0(Z,"__drizzle_migrations"),X=await h0(Z,"Node"),H=!1;if(X&&!Y){let j=D$({migrationsFolder:Q})[0];if(j)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[j.hash,j.folderMillis]}),H=!0}let G=await e5(Z);if(await O$(F$(Z),{migrationsFolder:Q}),await e5(Z)>G)H=!0;return await _$(Z),{migrated:H}}finally{Z.close()}}var E$,I$,T$;var Q9=l(async()=>{E$=K5(K5(K5(A$(import.meta.url)))),I$=process.env.BEACON_MIGRATIONS_DIR||R$(E$,"drizzle"),T$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});J5();import{existsSync as H$}from"fs";import{homedir as G$}from"os";import{join as z0}from"path";function j$(){return process.env.HOME||process.env.USERPROFILE||G$()}var S0=()=>z0(j$(),".claude"),G5=()=>z0(S0(),"skills"),j5=()=>z0(S0(),"settings.json"),U5=()=>z0(S0(),"CLAUDE.md"),W5="<!-- beacon:global:start -->",i5="<!-- beacon:global:end -->";var U$=v0,B5=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{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 W$($,Q){return E0(G5(),$,Q)}function r5($){return Q0(G5(),$)}function B$($){return I0(G5(),$)}function K$($){return F0(j5(),$)}function N$($){return O0(j5(),$)}function M$($){return D0(j5(),$)}function q$($){R0(U5(),W5,i5,$)}function a5(){return $0(U5(),W5)}function P$(){return A0(U5(),W5,i5)}function YZ(){let $={};for(let Z of y)$[Z]=r5(Z);let Q={};for(let Z of B5)Q[Z.event]=N$({event:Z.event,command:Z.command});return{homeExists:H$(S0()),skills:$,hooks:Q,claudeMdBlock:a5()}}async function w$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => ($5(),e0)),Y={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},X=[];for(let j of y){if(!r5(j))X.push(j);W$(j,Y[j])}let H=0;for(let j of B5)if(K$({event:j.event,matcher:j.matcher,command:j.command}))H++;let G=a5();return q$(U$),{skillsAdded:X,hooksAdded:H,claudeMdBlockTouched:!G}}async function t5(){if(S5())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let $;if(f5()){try{C$()}catch{}$={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{$={ok:!0,...await w$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (n5(),o5));if(Q.codexDetected())$.codex={ok:!0,...await Q.setupCodexAssets()}}catch(Q){$.codex={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return $}function C$(){let $=[];for(let Y of y)if(B$(Y))$.push(Y);let Q=0;for(let Y of B5)if(M$(Y))Q++;let Z=P$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as y$}from"async_hooks";import{spawnSync as x$}from"child_process";import{createHash as z$}from"crypto";import{existsSync as J9,mkdirSync as V0,readFileSync as M5,writeFileSync as q5}from"fs";import{homedir as Y9}from"os";import{basename as S$,join as x,parse as h$,resolve as Z9}from"path";function _(){return process.env.BEACON_HOME||x(Y9(),".beacon")}function P5(){return x(_(),"workspaces.json")}function o($){return z$("sha256").update($).digest("hex").slice(0,12)}function V9($=process.cwd()){let Q=x$("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function f0($){let Q=Z9($);return Q!==Z9(Y9())&&Q!==h$(Q).root}function X9(){return x(_(),"deleted.json")}function w5(){try{let $=JSON.parse(M5(X9(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function H9($){V0(_(),{recursive:!0}),q5(X9(),JSON.stringify($,null,2))}function g0($){return w5().includes($)}function wZ($){let Q=w5();if(!Q.includes($))H9([...Q,$])}function f$($){let Q=w5();if(Q.includes($))H9(Q.filter((Z)=>Z!==$))}function u0($){return x(_(),$)}function C5($){return`file:${x(u0($),"db.sqlite")}`}function X0(){try{let $=JSON.parse(M5(P5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function v5($){V0(_(),{recursive:!0}),q5(P5(),JSON.stringify($,null,2))}function b0(){return X0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function f($){return X0().find((Q)=>Q.id===$)??null}function m0($,Q,Z=new Date().toISOString()){if(!f0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=o($);if(g0(Y))throw Error(`beacon: workspace ${Y} (${$}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let X=X0(),H=X.find((U)=>U.id===Y),G={id:Y,path:$,name:Q||H?.name||S$($),lastOpenedAt:Z},j=[G,...X.filter((U)=>U.id!==Y)];return V0(u0(Y),{recursive:!0}),v5(j),G}function CZ($,Q){return f$(o($)),m0($,Q)}function vZ($,Q=new Date().toISOString()){let Z=X0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,v5(Z)}function FZ($){if(v5(X0().filter((Q)=>Q.id!==$)),H0()===$)g$(b0()[0]?.id??null)}function G9(){return x(_(),"active")}function H0(){try{return M5(G9(),"utf8").trim()||null}catch{return null}}function g$($){V0(_(),{recursive:!0}),q5(G9(),$??"")}function OZ(){let $=H0();return $?f($):null}function DZ(){let $=O5()??H0();return $?f($):null}function RZ($){return f($)?.path??null}function AZ(){return J9(P5())}var j9="beacon_ws";function U9($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let Y of Z.split(";")){let X=Y.indexOf("=");if(X===-1)continue;if(Y.slice(0,X).trim()===Q)return decodeURIComponent(Y.slice(X+1).trim())}return null}function EZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&f(Q))return Q;let Z=U9($,j9);if(Z&&f(Z))return Z;return u$()}function u$(){let $=b0();return $.length===1?$[0].id:null}var F5="x-beacon-workspace-path";async function IZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&f(Q))return Q;let Z=$.headers.get(F5);if(Z&&f0(Z)&&!g0(o(Z))&&(!Q||o(Z)===Q)){let X=m0(Z);return await D5(X.id),X.id}let Y=U9($,j9);if(Y&&f(Y))return Y;return null}var W9=new y$;function b$($,Q){return $?W9.run($,Q):Q()}function O5(){return W9.getStore()??null}var N5=new Set;function TZ($){N5.delete(x(u0($),"db.sqlite"))}async function D5($){let Q=u0($),Z=x(Q,"db.sqlite"),Y=J9(Z);if(Y&&N5.has(Z))return{ok:!0,created:!1,migrated:!1};try{V0(Q,{recursive:!0});let{provisionDb:X}=await Q9().then(() => $9),H=await X(C5($));return N5.add(Z),{ok:!0,created:!Y,migrated:Y&&H.migrated}}catch(X){return{ok:!1,created:!1,migrated:!1,error:X instanceof Error?X.message:String(X)}}}import{connect as m$}from"net";var B9=4319;function p$($,Q,Z=400){return new Promise((Y)=>{let X=m$({host:$,port:Q}),H=!1,G=(j)=>{if(H)return;H=!0,X.destroy(),Y(j)};X.once("connect",()=>G(!0)),X.once("error",()=>G(!1)),X.setTimeout(Z,()=>G(!1))})}async function c$($){for(let Q of["127.0.0.1","::1"])if(await p$(Q,$))return!1;return!0}async function kZ($,Q=20){for(let Z=$;Z<$+Q;Z++)if(await c$(Z))return Z;return $}import{McpServer as zQ,ResourceTemplate as _5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as SQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var l$=new Set(["GET","HEAD","OPTIONS"]);function K9($){return l$.has($.trim().toUpperCase())?"read":"write"}var d$=B.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},B.object({name:B.string().trim().min(1),type:B.string().trim().min(1),isPk:B.boolean().optional(),isFk:B.boolean().optional(),nullable:B.boolean().optional(),note:B.string().nullish()})),N9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(d$).default([])}),M9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),q9=B.object({method:B.string().trim().min(1),path:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),uses:B.array(B.object({table:B.string().trim().min(1),access:B.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??K9($.method)}))})),hZ=B.object({tables:B.array(N9).default([]),relations:B.array(M9).default([]),endpoints:B.array(q9).default([])});import{z as D}from"zod";import{and as V1,eq as X1,inArray as H1}from"drizzle-orm";import{drizzle as PQ}from"drizzle-orm/libsql";import{createClient as wQ}from"@libsql/client";var R5={};t(R5,{workspaceFlag:()=>e$,tag:()=>n,syncState:()=>r$,projectMeta:()=>t$,planContract:()=>$Q,note:()=>n$,nodeTags:()=>g,nodeFile:()=>G0,node:()=>M,endpointTable:()=>b,endpoint:()=>i,edge:()=>z,draftTable:()=>A,draftRelation:()=>m,draftColumn:()=>W0,dbTable:()=>F,dbRelation:()=>u,dbColumn:()=>U0,codeFileEdge:()=>p,codeFile:()=>k,bugFlag:()=>j0,boardAnnotation:()=>i$,appSetting:()=>a$});import{sqliteTable as q,index as N,foreignKey as s$,text as V,integer as W,real as O,uniqueIndex as T,primaryKey as o$}from"drizzle-orm/sqlite-core";import{createId as C}from"@paralleldrive/cuid2";var M=q("Node",{id:V().primaryKey().$defaultFn(()=>C()),view:V().notNull(),kind:V().default("FEATURE").notNull(),cluster:V(),layer:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:W().default(2).notNull(),progress:W().default(0).notNull(),x:O().default(0).notNull(),y:O().default(0).notNull(),sourceRef:V(),externalId:V(),source:V().default("MANUAL").notNull(),planId:V(),parentId:V(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Node_cluster_idx").on($.cluster),N("Node_parentId_idx").on($.parentId),N("Node_view_idx").on($.view),s$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),G0=q("NodeFile",{id:V().primaryKey().$defaultFn(()=>C()),nodeId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),path:V().notNull()},($)=>[T("NodeFile_nodeId_path_key").on($.nodeId,$.path),N("NodeFile_nodeId_idx").on($.nodeId)]),n=q("Tag",{id:V().primaryKey().$defaultFn(()=>C()),label:V().notNull(),color:V()},($)=>[T("Tag_label_key").on($.label)]),z=q("Edge",{id:V().primaryKey().$defaultFn(()=>C()),fromId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:V().default("DEPENDS").notNull(),label:V(),sourceHandle:V(),targetHandle:V()},($)=>[T("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),N("Edge_toId_idx").on($.toId),N("Edge_fromId_idx").on($.fromId)]),g=q("_NodeTags",{a:V("A").notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),b:V("B").notNull().references(()=>n.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[T("_NodeTags_AB_unique").on($.a,$.b),N("_NodeTags_B_index").on($.b)]),n$=q("Note",{id:V().primaryKey().$defaultFn(()=>C()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:O().default(0).notNull(),pinned:W({mode:"boolean"}).default(!1).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("Note_updatedAt_idx").on($.updatedAt)]),i$=q("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>C()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:O(),y:O(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("BoardAnnotation_target_idx").on($.targetId)]),j0=q("BugFlag",{id:V().primaryKey().$defaultFn(()=>C()),nodeId:V().notNull().references(()=>M.id,{onDelete:"cascade",onUpdate:"cascade"}),by:V().notNull(),note:V().notNull(),resolvedAt:W({mode:"timestamp_ms"}),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[N("BugFlag_nodeId_idx").on($.nodeId)]),F=q("DbTable",{id:V().primaryKey().$defaultFn(()=>C()),name:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[N("DbTable_domain_idx").on($.domain),T("DbTable_name_key").on($.name)]),U0=q("DbColumn",{id:V().primaryKey().$defaultFn(()=>C()),tableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:W({mode:"boolean"}).default(!1).notNull(),isFk:W({mode:"boolean"}).default(!1).notNull(),nullable:W({mode:"boolean"}).default(!0).notNull(),note:V(),ord:W().default(0).notNull()},($)=>[T("DbColumn_tableId_name_key").on($.tableId,$.name),N("DbColumn_tableId_idx").on($.tableId)]),u=q("DbRelation",{id:V().primaryKey().$defaultFn(()=>C()),fromTableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DbRelation_toTableId_idx").on($.toTableId),N("DbRelation_fromTableId_idx").on($.fromTableId)]),i=q("Endpoint",{id:V().primaryKey().$defaultFn(()=>C()),method:V().notNull(),path:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[T("Endpoint_method_path_key").on($.method,$.path),N("Endpoint_domain_idx").on($.domain)]),b=q("EndpointTable",{id:V().primaryKey().$defaultFn(()=>C()),endpointId:V().notNull().references(()=>i.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:V().notNull().references(()=>F.id,{onDelete:"cascade",onUpdate:"cascade"}),access:V().default("read").notNull()},($)=>[T("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),N("EndpointTable_tableId_idx").on($.tableId)]),A=q("DraftTable",{id:V().primaryKey().$defaultFn(()=>C()),name:V().notNull(),domain:V(),description:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[T("DraftTable_name_key").on($.name)]),W0=q("DraftColumn",{id:V().primaryKey().$defaultFn(()=>C()),tableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:W({mode:"boolean"}).default(!1).notNull(),isFk:W({mode:"boolean"}).default(!1).notNull(),nullable:W({mode:"boolean"}).default(!0).notNull(),note:V(),ord:W().default(0).notNull()},($)=>[N("DraftColumn_tableId_idx").on($.tableId)]),m=q("DraftRelation",{id:V().primaryKey().$defaultFn(()=>C()),fromTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[N("DraftRelation_toTableId_idx").on($.toTableId),N("DraftRelation_fromTableId_idx").on($.fromTableId)]),k=q("CodeFile",{path:V().primaryKey(),root:V(),lang:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),mtimeMs:O(),size:W(),inDegree:W().default(0).notNull(),outDegree:W().default(0).notNull(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),p=q("CodeFileEdge",{fromPath:V().notNull().references(()=>k.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:V().notNull().references(()=>k.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:W({mode:"boolean"}).default(!1).notNull()},($)=>[N("CodeFileEdge_circular_idx").on($.circular),N("CodeFileEdge_toPath_idx").on($.toPath),N("CodeFileEdge_fromPath_idx").on($.fromPath),o$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),r$=q("SyncState",{id:V().primaryKey().default("singleton"),version:W().default(0).notNull(),codeGraphSyncedAt:W({mode:"timestamp_ms"}),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),a$=q("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),t$=q("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),hasFrontend:W({mode:"boolean"}),classificationRoots:V().default("[]").notNull(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),e$=q("WorkspaceFlag",{id:V().primaryKey().$defaultFn(()=>C()),key:V().notNull(),enabled:W({mode:"boolean"}).default(!1).notNull(),config:V(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[T("WorkspaceFlag_key_key").on($.key)]),$Q=q("PlanContract",{id:V().primaryKey().$defaultFn(()=>C()),planId:V().notNull(),declaredFiles:V().default("[]").notNull(),authorizedExtras:V().default("[]").notNull(),active:W({mode:"boolean"}).default(!1).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[T("PlanContract_planId_key").on($.planId),N("PlanContract_active_idx").on($.active)]);var A5={};t(A5,{tagRelations:()=>YQ,nodeTagsRelations:()=>VQ,nodeRelations:()=>QQ,nodeFileRelations:()=>ZQ,endpointTableRelations:()=>WQ,endpointRelations:()=>UQ,edgeRelations:()=>XQ,draftTableRelations:()=>BQ,draftRelationRelations:()=>NQ,draftColumnRelations:()=>KQ,dbTableRelations:()=>HQ,dbRelationRelations:()=>jQ,dbColumnRelations:()=>GQ,codeFileRelations:()=>MQ,codeFileEdgeRelations:()=>qQ,bugFlagRelations:()=>JQ});import{relations as v}from"drizzle-orm";var QQ=v(M,({one:$,many:Q})=>({files:Q(G0),bugFlags:Q(j0),nodeTags:Q(g),edgesOut:Q(z,{relationName:"EdgeFrom"}),edgesIn:Q(z,{relationName:"EdgeTo"}),parent:$(M,{fields:[M.parentId],references:[M.id],relationName:"NodeTree"}),children:Q(M,{relationName:"NodeTree"})})),ZQ=v(G0,({one:$})=>({node:$(M,{fields:[G0.nodeId],references:[M.id]})})),JQ=v(j0,({one:$})=>({node:$(M,{fields:[j0.nodeId],references:[M.id]})})),YQ=v(n,({many:$})=>({nodeTags:$(g)})),VQ=v(g,({one:$})=>({node:$(M,{fields:[g.a],references:[M.id]}),tag:$(n,{fields:[g.b],references:[n.id]})})),XQ=v(z,({one:$})=>({from:$(M,{fields:[z.fromId],references:[M.id],relationName:"EdgeFrom"}),to:$(M,{fields:[z.toId],references:[M.id],relationName:"EdgeTo"})})),HQ=v(F,({many:$})=>({columns:$(U0),fksOut:$(u,{relationName:"FkFrom"}),fksIn:$(u,{relationName:"FkTo"}),usages:$(b)})),GQ=v(U0,({one:$})=>({table:$(F,{fields:[U0.tableId],references:[F.id]})})),jQ=v(u,({one:$})=>({fromTable:$(F,{fields:[u.fromTableId],references:[F.id],relationName:"FkFrom"}),toTable:$(F,{fields:[u.toTableId],references:[F.id],relationName:"FkTo"})})),UQ=v(i,({many:$})=>({tables:$(b)})),WQ=v(b,({one:$})=>({endpoint:$(i,{fields:[b.endpointId],references:[i.id]}),table:$(F,{fields:[b.tableId],references:[F.id]})})),BQ=v(A,({many:$})=>({columns:$(W0),fksOut:$(m,{relationName:"DraftFkFrom"}),fksIn:$(m,{relationName:"DraftFkTo"})})),KQ=v(W0,({one:$})=>({table:$(A,{fields:[W0.tableId],references:[A.id]})})),NQ=v(m,({one:$})=>({fromTable:$(A,{fields:[m.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[m.toTableId],references:[A.id],relationName:"DraftFkTo"})})),MQ=v(k,({many:$})=>({edgesOut:$(p,{relationName:"CFEFrom"}),edgesIn:$(p,{relationName:"CFETo"})})),qQ=v(p,({one:$})=>({fromFile:$(k,{fields:[p.fromPath],references:[k.path],relationName:"CFEFrom"}),toFile:$(k,{fields:[p.toPath],references:[k.path],relationName:"CFETo"})}));var CQ={...R5,...A5};function vQ(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var FQ=vQ();function P9($){let Q=wQ({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),PQ(Q,{schema:CQ})}var I5=globalThis,E5=I5.dzDefault??P9(FQ);I5.dzDefault=E5;var p0=I5.dzByUrl??=new Map;function OQ($){let Q=p0.get($);if(!Q)Q=P9($),p0.set($,Q);return Q}function dZ($){let Q=p0.get($);p0.delete($);try{Q?.$client?.close?.()}catch{}}function DQ(){if(process.env.BEACON_REPO)return E5;let $=O5()??H0();if(!$)return E5;return OQ(C5($))}var RQ=new Proxy({},{get($,Q){let Z=DQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});var AQ=["frontend","backend","fullstack"],EQ={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function c0($){let Q=($??"").trim().toLowerCase();if(!Q)return null;if(AQ.includes(Q))return Q;return EQ[Q]??null}import{forceCenter as rZ,forceCollide as aZ,forceLink as tZ,forceManyBody as eZ,forceSimulation as $1}from"d3-force";var w9=D.object({title:D.string().trim().min(1),role:D.string().nullish(),plain:D.string().nullish(),cluster:D.string().nullish(),category:D.string().nullish(),domain:D.string().nullish(),priority:D.number().nullish(),kind:D.string().nullish(),layer:D.string().nullish(),dependsOn:D.array(D.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,layer:X,...H})=>({...H,cluster:H.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE",layer:c0(X)})),B1=D.object({features:D.array(w9).default([])});var IQ=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function C9($){return!!$&&IQ.test($)}function v9($,Q){switch($){case"add":return{path:"/api/map/start",body:{title:Q.title,id:Q.id,front:Q.front,detail:Q.detail,category:Q.category,priority:Q.priority,kind:Q.kind,layer:Q.layer,status:Q.status??"backlog",flagExisting:!1}};case"start":return{path:"/api/map/start",body:{title:Q.title,id:Q.id,front:Q.front,detail:Q.detail,category:Q.category,priority:Q.priority,kind:Q.kind,layer:Q.layer,status:"active",flagExisting:!0}};case"subtasks":return{path:"/api/nodes/subtasks",body:{parentId:Q.parentId,parentTitle:Q.parentTitle,items:Q.items}};case"done":return{path:"/api/map/describe",body:Q.features?.length?{features:Q.features}:{description:Q.description,files:Q.files,id:Q.id,title:Q.title,architecture:Q.architecture}};default:throw Error(`unknown beacon_feature action "${$}"`)}}function TQ($){return $.cluster??$.category??$.domain??null}function F9($,Q){let Z=Q?.requireLayer??!1,Y=$.map((H)=>{let G=[],j=TQ(H);if(!j||!j.trim())G.push("category");if(H.priority==null)G.push("priority");if(Z&&!c0(H.layer))G.push("layer");return G.length?` \u2022 "${H.title?.trim()||"(untitled)"}" \u2014 missing ${G.join(" + ")}`:null}).filter((H)=>H!==null);if(Y.length===0)return null;let X=Z?" This workspace has a frontend surface, so every feature must also carry `layer`: "+'"frontend" | "backend" | "fullstack" \u2014 which side of the stack the work lands on.':"";return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+"on the board, and the user shouldn't have to add them by hand."+X+` Missing:
|
|
343
|
+
${n5}
|
|
344
|
+
`});var Y9={};t(Y9,{provisionDb:()=>f$});import{createClient as A$}from"@libsql/client";import{drizzle as E$}from"drizzle-orm/libsql";import{migrate as T$}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as I$}from"drizzle-orm/migrator";import{dirname as N5,join as k$}from"path";import{fileURLToPath as _$}from"url";async function g0($,Q){return(await $.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Q]})).rows.length>0}async function S$($,Q){let Z=await $.execute(`PRAGMA table_info("${Q}")`);return new Set(Z.rows.map((Y)=>String(Y.name)))}async function J9($){if(!await g0($,"__drizzle_migrations"))return 0;let Q=await $.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Q.rows[0]?.n??0)}async function z$($){for(let[Q,Z]of Object.entries(x$)){if(!await g0($,Q))continue;let Y=await S$($,Q);for(let X of Z){if(!Y.has(X))continue;await $.execute(`UPDATE "${Q}" SET "${X}" = CAST((julianday("${X}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${X}") = 'text'`)}}}async function f$($,Q=y$){let Z=A$({url:$});try{await Z.execute("PRAGMA journal_mode = WAL;"),await Z.execute("PRAGMA foreign_keys = ON;"),await Z.execute("PRAGMA busy_timeout = 5000;");let Y=await g0(Z,"__drizzle_migrations"),X=await g0(Z,"Node"),H=!1;if(X&&!Y){let U=I$({migrationsFolder:Q})[0];if(U)await Z.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Z.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[U.hash,U.folderMillis]}),H=!0}let G=await J9(Z);if(await T$(E$(Z),{migrationsFolder:Q}),await J9(Z)>G)H=!0;return await z$(Z),{migrated:H}}finally{Z.close()}}var L$,y$,x$;var V9=o(async()=>{L$=N5(N5(N5(_$(import.meta.url)))),y$=process.env.BEACON_MIGRATIONS_DIR||k$(L$,"drizzle"),x$={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});Y5();import{existsSync as B$}from"fs";import{homedir as K$}from"os";import{join as h0}from"path";function N$(){return process.env.HOME||process.env.USERPROFILE||K$()}var u0=()=>h0(N$(),".claude"),j5=()=>h0(u0(),"skills"),W5=()=>h0(u0(),"settings.json"),U5=()=>h0(u0(),"CLAUDE.md"),B5="<!-- beacon:global:start -->",e5="<!-- beacon:global:end -->";var M$=O0,K5=[{event:"PreToolUse",matcher:"Edit|Write|MultiEdit",command:"beacon guard",description:"Gate edits against the active plan's scope contract (when the scope-guard flag is on): in-scope \u2192 allow, off-scope \u2192 ask the user to authorize. No-op + fail-open otherwise."},{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 q$($,Q){return k0(j5(),$,Q)}function $9($){return Z0(j5(),$)}function P$($){return _0(j5(),$)}function C$($){return R0(W5(),$)}function w$($){return A0(W5(),$)}function F$($){return E0(W5(),$)}function v$($){T0(U5(),B5,e5,$)}function Q9(){return Q0(U5(),B5)}function D$(){return I0(U5(),B5,e5)}function GZ(){let $={};for(let Z of S)$[Z]=$9(Z);let Q={};for(let Z of K5)Q[Z.event]=w$({event:Z.event,command:Z.command});return{homeExists:B$(u0()),skills:$,hooks:Q,claudeMdBlock:Q9()}}async function O$(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z,EXPLAIN_SKILL:Y}=await Promise.resolve().then(() => (Q5(),$5)),X={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z,"beacon-explain":Y},H=[];for(let j of S){if(!$9(j))H.push(j);q$(j,X[j])}let G=0;for(let j of K5)if(C$({event:j.event,matcher:j.matcher,command:j.command}))G++;let U=Q9();return v$(M$),{skillsAdded:H,hooksAdded:G,claudeMdBlockTouched:!U}}async function Z9(){if(g5())return{ok:!0,skipped:"plugin",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1};let $;if(m5()){try{R$()}catch{}$={ok:!0,skipped:"plugin-present",skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}else try{$={ok:!0,...await O$()}}catch(Q){$={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Q=await Promise.resolve().then(() => (t5(),a5));if(Q.codexDetected())$.codex={ok:!0,...await Q.setupCodexAssets()}}catch(Q){$.codex={ok:!1,error:Q instanceof Error?Q.message:String(Q),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return $}function R$(){let $=[];for(let Y of S)if(P$(Y))$.push(Y);let Q=0;for(let Y of K5)if(F$(Y))Q++;let Z=D$();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as h$}from"async_hooks";import{spawnSync as u$}from"child_process";import{createHash as g$}from"crypto";import{existsSync as H9,mkdirSync as X0,readFileSync as q5,writeFileSync as P5}from"fs";import{homedir as G9}from"os";import{basename as b$,join as z,parse as m$,resolve as X9}from"path";function L(){return process.env.BEACON_HOME||z(G9(),".beacon")}function C5(){return z(L(),"workspaces.json")}function i($){return g$("sha256").update($).digest("hex").slice(0,12)}function j9($=process.cwd()){let Q=u$("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function b0($){let Q=X9($);return Q!==X9(G9())&&Q!==m$(Q).root}function W9(){return z(L(),"deleted.json")}function w5(){try{let $=JSON.parse(q5(W9(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function U9($){X0(L(),{recursive:!0}),P5(W9(),JSON.stringify($,null,2))}function m0($){return w5().includes($)}function DZ($){let Q=w5();if(!Q.includes($))U9([...Q,$])}function p$($){let Q=w5();if(Q.includes($))U9(Q.filter((Z)=>Z!==$))}function p0($){return z(L(),$)}function F5($){return`file:${z(p0($),"db.sqlite")}`}function H0(){try{let $=JSON.parse(q5(C5(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function v5($){X0(L(),{recursive:!0}),P5(C5(),JSON.stringify($,null,2))}function c0(){return H0().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function b($){return H0().find((Q)=>Q.id===$)??null}function l0($,Q,Z=new Date().toISOString()){if(!b0($))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${$}`);let Y=i($);if(m0(Y))throw Error(`beacon: workspace ${Y} (${$}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let X=H0(),H=X.find((j)=>j.id===Y),G={id:Y,path:$,name:Q||H?.name||b$($),lastOpenedAt:Z},U=[G,...X.filter((j)=>j.id!==Y)];return X0(p0(Y),{recursive:!0}),v5(U),G}function OZ($,Q){return p$(i($)),l0($,Q)}function RZ($,Q=new Date().toISOString()){let Z=H0(),Y=Z.find((X)=>X.id===$);if(!Y)return;Y.lastOpenedAt=Q,v5(Z)}function AZ($){if(v5(H0().filter((Q)=>Q.id!==$)),G0()===$)c$(c0()[0]?.id??null)}function B9(){return z(L(),"active")}function G0(){try{return q5(B9(),"utf8").trim()||null}catch{return null}}function c$($){X0(L(),{recursive:!0}),P5(B9(),$??"")}function EZ(){let $=G0();return $?b($):null}function TZ(){let $=O5()??G0();return $?b($):null}function IZ($){return b($)?.path??null}function kZ(){return H9(C5())}var K9="beacon_ws";function N9($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let Y of Z.split(";")){let X=Y.indexOf("=");if(X===-1)continue;if(Y.slice(0,X).trim()===Q)return decodeURIComponent(Y.slice(X+1).trim())}return null}function _Z($){let Q=$.headers.get("x-beacon-workspace");if(Q&&b(Q))return Q;let Z=N9($,K9);if(Z&&b(Z))return Z;return l$()}function l$(){let $=c0();return $.length===1?$[0].id:null}var D5="x-beacon-workspace-path";async function LZ($){let Q=$.headers.get("x-beacon-workspace");if(Q&&b(Q))return Q;let Z=$.headers.get(D5);if(Z&&b0(Z)&&!m0(i(Z))&&(!Q||i(Z)===Q)){let X=l0(Z);return await R5(X.id),X.id}let Y=N9($,K9);if(Y&&b(Y))return Y;return null}var M9=new h$;function d$($,Q){return $?M9.run($,Q):Q()}function O5(){return M9.getStore()??null}var M5=new Set;function yZ($){M5.delete(z(p0($),"db.sqlite"))}async function R5($){let Q=p0($),Z=z(Q,"db.sqlite"),Y=H9(Z);if(Y&&M5.has(Z))return{ok:!0,created:!1,migrated:!1};try{X0(Q,{recursive:!0});let{provisionDb:X}=await V9().then(() => Y9),H=await X(F5($));return M5.add(Z),{ok:!0,created:!Y,migrated:Y&&H.migrated}}catch(X){return{ok:!1,created:!1,migrated:!1,error:X instanceof Error?X.message:String(X)}}}import{connect as o$}from"net";var q9=4319;function s$($,Q,Z=400){return new Promise((Y)=>{let X=o$({host:$,port:Q}),H=!1,G=(U)=>{if(H)return;H=!0,X.destroy(),Y(U)};X.once("connect",()=>G(!0)),X.once("error",()=>G(!1)),X.setTimeout(Z,()=>G(!1))})}async function n$($){for(let Q of["127.0.0.1","::1"])if(await s$(Q,$))return!1;return!0}async function zZ($,Q=20){for(let Z=$;Z<$+Q;Z++)if(await n$(Z))return Z;return $}import{McpServer as uQ,ResourceTemplate as y5}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as gQ}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as B}from"zod";var i$=new Set(["GET","HEAD","OPTIONS"]);function P9($){return i$.has($.trim().toUpperCase())?"read":"write"}var r$=B.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},B.object({name:B.string().trim().min(1),type:B.string().trim().min(1),isPk:B.boolean().optional(),isFk:B.boolean().optional(),nullable:B.boolean().optional(),note:B.string().nullish()})),C9=B.object({name:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),columns:B.array(r$).default([])}),w9=B.object({fromTable:B.string(),fromColumn:B.string(),toTable:B.string(),toColumn:B.string(),label:B.string().nullish()}),F9=B.object({method:B.string().trim().min(1),path:B.string().trim().min(1),domain:B.string().nullish(),description:B.string().nullish(),uses:B.array(B.object({table:B.string().trim().min(1),access:B.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??P9($.method)}))})),bZ=B.object({tables:B.array(C9).default([]),relations:B.array(w9).default([]),endpoints:B.array(F9).default([])});import{z as R}from"zod";import{and as j1,eq as W1,inArray as U1}from"drizzle-orm";import{drizzle as DQ}from"drizzle-orm/libsql";import{createClient as OQ}from"@libsql/client";var A5={};t(A5,{workspaceFlag:()=>YQ,tag:()=>r,syncState:()=>QQ,projectMeta:()=>JQ,planContract:()=>VQ,note:()=>e$,nodeTags:()=>m,nodeFile:()=>j0,node:()=>q,endpointTable:()=>c,endpoint:()=>a,edge:()=>f,draftTable:()=>I,draftRelation:()=>l,draftColumn:()=>B0,dbTable:()=>D,dbRelation:()=>p,dbColumn:()=>U0,codeFileEdge:()=>d,codeFile:()=>y,bugFlag:()=>W0,boardAnnotation:()=>$Q,appSetting:()=>ZQ});import{sqliteTable as P,index as M,foreignKey as a$,text as V,integer as W,real as O,uniqueIndex as k,primaryKey as t$}from"drizzle-orm/sqlite-core";import{createId as F}from"@paralleldrive/cuid2";var q=P("Node",{id:V().primaryKey().$defaultFn(()=>F()),view:V().notNull(),kind:V().default("FEATURE").notNull(),cluster:V(),layer:V(),title:V().notNull(),role:V(),plain:V(),status:V().default("PENDING").notNull(),priority:W().default(2).notNull(),progress:W().default(0).notNull(),x:O().default(0).notNull(),y:O().default(0).notNull(),sourceRef:V(),externalId:V(),source:V().default("MANUAL").notNull(),planId:V(),parentId:V(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[M("Node_cluster_idx").on($.cluster),M("Node_parentId_idx").on($.parentId),M("Node_view_idx").on($.view),a$(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),j0=P("NodeFile",{id:V().primaryKey().$defaultFn(()=>F()),nodeId:V().notNull().references(()=>q.id,{onDelete:"cascade",onUpdate:"cascade"}),path:V().notNull()},($)=>[k("NodeFile_nodeId_path_key").on($.nodeId,$.path),M("NodeFile_nodeId_idx").on($.nodeId)]),r=P("Tag",{id:V().primaryKey().$defaultFn(()=>F()),label:V().notNull(),color:V()},($)=>[k("Tag_label_key").on($.label)]),f=P("Edge",{id:V().primaryKey().$defaultFn(()=>F()),fromId:V().notNull().references(()=>q.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:V().notNull().references(()=>q.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:V().default("DEPENDS").notNull(),label:V(),sourceHandle:V(),targetHandle:V()},($)=>[k("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),M("Edge_toId_idx").on($.toId),M("Edge_fromId_idx").on($.fromId)]),m=P("_NodeTags",{a:V("A").notNull().references(()=>q.id,{onDelete:"cascade",onUpdate:"cascade"}),b:V("B").notNull().references(()=>r.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[k("_NodeTags_AB_unique").on($.a,$.b),M("_NodeTags_B_index").on($.b)]),e$=P("Note",{id:V().primaryKey().$defaultFn(()=>F()),title:V().default("Untitled").notNull(),body:V().default("").notNull(),ord:O().default(0).notNull(),pinned:W({mode:"boolean"}).default(!1).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[M("Note_updatedAt_idx").on($.updatedAt)]),$Q=P("BoardAnnotation",{id:V().primaryKey().$defaultFn(()=>F()),targetKind:V().notNull(),targetId:V().notNull(),columnName:V(),body:V().default("").notNull(),x:O(),y:O(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[M("BoardAnnotation_target_idx").on($.targetId)]),W0=P("BugFlag",{id:V().primaryKey().$defaultFn(()=>F()),nodeId:V().notNull().references(()=>q.id,{onDelete:"cascade",onUpdate:"cascade"}),by:V().notNull(),note:V().notNull(),resolvedAt:W({mode:"timestamp_ms"}),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[M("BugFlag_nodeId_idx").on($.nodeId)]),D=P("DbTable",{id:V().primaryKey().$defaultFn(()=>F()),name:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[M("DbTable_domain_idx").on($.domain),k("DbTable_name_key").on($.name)]),U0=P("DbColumn",{id:V().primaryKey().$defaultFn(()=>F()),tableId:V().notNull().references(()=>D.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:W({mode:"boolean"}).default(!1).notNull(),isFk:W({mode:"boolean"}).default(!1).notNull(),nullable:W({mode:"boolean"}).default(!0).notNull(),note:V(),ord:W().default(0).notNull()},($)=>[k("DbColumn_tableId_name_key").on($.tableId,$.name),M("DbColumn_tableId_idx").on($.tableId)]),p=P("DbRelation",{id:V().primaryKey().$defaultFn(()=>F()),fromTableId:V().notNull().references(()=>D.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>D.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[M("DbRelation_toTableId_idx").on($.toTableId),M("DbRelation_fromTableId_idx").on($.fromTableId)]),a=P("Endpoint",{id:V().primaryKey().$defaultFn(()=>F()),method:V().notNull(),path:V().notNull(),domain:V(),description:V(),source:V().default("MANUAL").notNull(),planId:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("Endpoint_method_path_key").on($.method,$.path),M("Endpoint_domain_idx").on($.domain)]),c=P("EndpointTable",{id:V().primaryKey().$defaultFn(()=>F()),endpointId:V().notNull().references(()=>a.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:V().notNull().references(()=>D.id,{onDelete:"cascade",onUpdate:"cascade"}),access:V().default("read").notNull()},($)=>[k("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),M("EndpointTable_tableId_idx").on($.tableId)]),I=P("DraftTable",{id:V().primaryKey().$defaultFn(()=>F()),name:V().notNull(),domain:V(),description:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[k("DraftTable_name_key").on($.name)]),B0=P("DraftColumn",{id:V().primaryKey().$defaultFn(()=>F()),tableId:V().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),name:V().notNull(),type:V().notNull(),isPk:W({mode:"boolean"}).default(!1).notNull(),isFk:W({mode:"boolean"}).default(!1).notNull(),nullable:W({mode:"boolean"}).default(!0).notNull(),note:V(),ord:W().default(0).notNull()},($)=>[M("DraftColumn_tableId_idx").on($.tableId)]),l=P("DraftRelation",{id:V().primaryKey().$defaultFn(()=>F()),fromTableId:V().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:V().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:V().notNull(),toColumn:V().notNull(),label:V()},($)=>[M("DraftRelation_toTableId_idx").on($.toTableId),M("DraftRelation_fromTableId_idx").on($.fromTableId)]),y=P("CodeFile",{path:V().primaryKey(),root:V(),lang:V(),x:O().default(0).notNull(),y:O().default(0).notNull(),mtimeMs:O(),size:W(),inDegree:W().default(0).notNull(),outDegree:W().default(0).notNull(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),d=P("CodeFileEdge",{fromPath:V().notNull().references(()=>y.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:V().notNull().references(()=>y.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:W({mode:"boolean"}).default(!1).notNull()},($)=>[M("CodeFileEdge_circular_idx").on($.circular),M("CodeFileEdge_toPath_idx").on($.toPath),M("CodeFileEdge_fromPath_idx").on($.fromPath),t$({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),QQ=P("SyncState",{id:V().primaryKey().default("singleton"),version:W().default(0).notNull(),codeGraphSyncedAt:W({mode:"timestamp_ms"}),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),ZQ=P("AppSetting",{id:V().primaryKey().default("singleton"),editor:V().default("auto").notNull(),currentFeatureId:V(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),JQ=P("ProjectMeta",{id:V().primaryKey().default("singleton"),overview:V(),conventions:V().default("[]").notNull(),hasFrontend:W({mode:"boolean"}),classificationRoots:V().default("[]").notNull(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),YQ=P("WorkspaceFlag",{id:V().primaryKey().$defaultFn(()=>F()),key:V().notNull(),enabled:W({mode:"boolean"}).default(!1).notNull(),config:V(),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("WorkspaceFlag_key_key").on($.key)]),VQ=P("PlanContract",{id:V().primaryKey().$defaultFn(()=>F()),planId:V().notNull(),declaredFiles:V().default("[]").notNull(),authorizedExtras:V().default("[]").notNull(),active:W({mode:"boolean"}).default(!1).notNull(),createdAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:W({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("PlanContract_planId_key").on($.planId),M("PlanContract_active_idx").on($.active)]);var E5={};t(E5,{tagRelations:()=>jQ,nodeTagsRelations:()=>WQ,nodeRelations:()=>XQ,nodeFileRelations:()=>HQ,endpointTableRelations:()=>qQ,endpointRelations:()=>MQ,edgeRelations:()=>UQ,draftTableRelations:()=>PQ,draftRelationRelations:()=>wQ,draftColumnRelations:()=>CQ,dbTableRelations:()=>BQ,dbRelationRelations:()=>NQ,dbColumnRelations:()=>KQ,codeFileRelations:()=>FQ,codeFileEdgeRelations:()=>vQ,bugFlagRelations:()=>GQ});import{relations as v}from"drizzle-orm";var XQ=v(q,({one:$,many:Q})=>({files:Q(j0),bugFlags:Q(W0),nodeTags:Q(m),edgesOut:Q(f,{relationName:"EdgeFrom"}),edgesIn:Q(f,{relationName:"EdgeTo"}),parent:$(q,{fields:[q.parentId],references:[q.id],relationName:"NodeTree"}),children:Q(q,{relationName:"NodeTree"})})),HQ=v(j0,({one:$})=>({node:$(q,{fields:[j0.nodeId],references:[q.id]})})),GQ=v(W0,({one:$})=>({node:$(q,{fields:[W0.nodeId],references:[q.id]})})),jQ=v(r,({many:$})=>({nodeTags:$(m)})),WQ=v(m,({one:$})=>({node:$(q,{fields:[m.a],references:[q.id]}),tag:$(r,{fields:[m.b],references:[r.id]})})),UQ=v(f,({one:$})=>({from:$(q,{fields:[f.fromId],references:[q.id],relationName:"EdgeFrom"}),to:$(q,{fields:[f.toId],references:[q.id],relationName:"EdgeTo"})})),BQ=v(D,({many:$})=>({columns:$(U0),fksOut:$(p,{relationName:"FkFrom"}),fksIn:$(p,{relationName:"FkTo"}),usages:$(c)})),KQ=v(U0,({one:$})=>({table:$(D,{fields:[U0.tableId],references:[D.id]})})),NQ=v(p,({one:$})=>({fromTable:$(D,{fields:[p.fromTableId],references:[D.id],relationName:"FkFrom"}),toTable:$(D,{fields:[p.toTableId],references:[D.id],relationName:"FkTo"})})),MQ=v(a,({many:$})=>({tables:$(c)})),qQ=v(c,({one:$})=>({endpoint:$(a,{fields:[c.endpointId],references:[a.id]}),table:$(D,{fields:[c.tableId],references:[D.id]})})),PQ=v(I,({many:$})=>({columns:$(B0),fksOut:$(l,{relationName:"DraftFkFrom"}),fksIn:$(l,{relationName:"DraftFkTo"})})),CQ=v(B0,({one:$})=>({table:$(I,{fields:[B0.tableId],references:[I.id]})})),wQ=v(l,({one:$})=>({fromTable:$(I,{fields:[l.fromTableId],references:[I.id],relationName:"DraftFkFrom"}),toTable:$(I,{fields:[l.toTableId],references:[I.id],relationName:"DraftFkTo"})})),FQ=v(y,({many:$})=>({edgesOut:$(d,{relationName:"CFEFrom"}),edgesIn:$(d,{relationName:"CFETo"})})),vQ=v(d,({one:$})=>({fromFile:$(y,{fields:[d.fromPath],references:[y.path],relationName:"CFEFrom"}),toFile:$(y,{fields:[d.toPath],references:[y.path],relationName:"CFETo"})}));var RQ={...A5,...E5};function AQ(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var EQ=AQ();function v9($){let Q=OQ({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),Q.execute("PRAGMA busy_timeout = 5000;"),DQ(Q,{schema:RQ})}var I5=globalThis,T5=I5.dzDefault??v9(EQ);I5.dzDefault=T5;var d0=I5.dzByUrl??=new Map;function TQ($){let Q=d0.get($);if(!Q)Q=v9($),d0.set($,Q);return Q}function iZ($){let Q=d0.get($);d0.delete($);try{Q?.$client?.close?.()}catch{}}function IQ(){if(process.env.BEACON_REPO)return T5;let $=O5()??G0();if(!$)return T5;return TQ(F5($))}var kQ=new Proxy({},{get($,Q){let Z=IQ(),Y=Z[Q];return typeof Y==="function"?Y.bind(Z):Y}});var _Q=["frontend","backend","fullstack"],LQ={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function o0($){let Q=($??"").trim().toLowerCase();if(!Q)return null;if(_Q.includes(Q))return Q;return LQ[Q]??null}import{forceCenter as $1,forceCollide as Q1,forceLink as Z1,forceManyBody as J1,forceSimulation as Y1}from"d3-force";var D9=R.object({title:R.string().trim().min(1),role:R.string().nullish(),plain:R.string().nullish(),cluster:R.string().nullish(),category:R.string().nullish(),domain:R.string().nullish(),priority:R.number().nullish(),kind:R.string().nullish(),layer:R.string().nullish(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,kind:Y,layer:X,...H})=>({...H,cluster:H.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z))),kind:Y?.trim().toUpperCase()==="BUG"?"BUG":"FEATURE",layer:o0(X)})),q1=R.object({features:R.array(D9).default([])});var yQ=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function O9($){return!!$&&yQ.test($)}function R9($,Q){switch($){case"add":return{path:"/api/map/start",body:{title:Q.title,id:Q.id,front:Q.front,detail:Q.detail,category:Q.category,priority:Q.priority,kind:Q.kind,layer:Q.layer,status:Q.status??"backlog",flagExisting:!1}};case"start":return{path:"/api/map/start",body:{title:Q.title,id:Q.id,front:Q.front,detail:Q.detail,category:Q.category,priority:Q.priority,kind:Q.kind,layer:Q.layer,status:"active",flagExisting:!0}};case"subtasks":return{path:"/api/nodes/subtasks",body:{parentId:Q.parentId,parentTitle:Q.parentTitle,items:Q.items}};case"done":return{path:"/api/map/describe",body:Q.features?.length?{features:Q.features}:{description:Q.description,files:Q.files,id:Q.id,title:Q.title,architecture:Q.architecture}};default:throw Error(`unknown beacon_feature action "${$}"`)}}function xQ($){return $.cluster??$.category??$.domain??null}function A9($,Q){let Z=Q?.requireLayer??!1,Y=$.map((H)=>{let G=[],U=xQ(H);if(!U||!U.trim())G.push("category");if(H.priority==null)G.push("priority");if(Z&&!o0(H.layer))G.push("layer");return G.length?` \u2022 "${H.title?.trim()||"(untitled)"}" \u2014 missing ${G.join(" + ")}`:null}).filter((H)=>H!==null);if(Y.length===0)return null;let X=Z?" This workspace has a frontend surface, so every feature must also carry `layer`: "+'"frontend" | "backend" | "fullstack" \u2014 which side of the stack the work lands on.':"";return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+"on the board, and the user shouldn't have to add them by hand."+X+` Missing:
|
|
275
345
|
`+Y.join(`
|
|
276
|
-
`)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low)."+(Z?" Set `layer` on EVERY feature too.":"")+" Don't rely on defaults."}function
|
|
346
|
+
`)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low)."+(Z?" Set `layer` on EVERY feature too.":"")+" Don't rely on defaults."}function k5($){if(!$?.length)return"";let Q=$.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),Z=$.some((Y)=>Y.id);return`
|
|
277
347
|
|
|
278
348
|
This plan created these roadmap feature(s):
|
|
279
349
|
`+Q.join(`
|
|
280
|
-
`)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+(Z?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{readFileSync as
|
|
281
|
-
`)}await t5();var S=V9(),c=o(S);if(!f0(S)){let $=b0();if($.length===1)console.error(`[beacon mcp] cwd ${S} isn't a registered repo \u2014 falling back to your only Beacon workspace "${$[0].name}".`);else if($.length>1)console.error(`[beacon mcp] cwd ${S} isn't a registered repo and you have ${$.length} Beacon workspaces \u2014 can't auto-detect which. Run /beacon-init in this repo, or name the project explicitly in your request.`);else console.error(`[beacon mcp] not registering ${S} \u2014 home/non-repo dir.`)}else if(g0(c))console.error(`[beacon mcp] not registering ${S} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{m0(S);let $=await D5(c);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",c),Z.set(F5,S);let Y=await fetch(`${r()}${$}`,{...Q,headers:Z}),X=await Y.text();if(!Y.ok)throw Error(`Beacon ${$} -> ${Y.status} ${X}`);return X?JSON.parse(X):null}function s0($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function L9($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let Y=JSON.parse(Z[0]);if(Y?.error)return{content:[{type:"text",text:Y.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var R=new zQ({name:"beacon",version:"0.1.0"});R.registerTool("beacon_map",{description:"List the roadmap: every feature + its sub-tasks with `category`, `priority`, `layer`, `kind`, and `status`. Call this BEFORE creating anything with `beacon_feature` \u2014 it's the cheap way to learn which categories already exist (reuse one instead of inventing a synonym) and whether a card already exists. You do NOT need `beacon_entities` just to see categories."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});var I9=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on (only when the repo has a frontend); omitting it on an update keeps the prior value"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found in this component's code \u2014 flagged on the node (by=agent); identical open flags are not duplicated")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");R.registerTool("beacon_feature",{description:'Manage a roadmap feature\'s whole lifecycle in ONE tool \u2014 no approval gate (that\'s `beacon_propose_plan`/`beacon_present_plan`). `action:"add"` puts a card on the board, defaulting to BACKLOG/PENDING (pass `status:"active"` to start it now); `"start"` marks an existing card IN_PROGRESS (create-or-flag); `"subtasks"` adds child tasks under a card; `"done"` completes feature(s) and registers the files/architecture touched (marks DONE + cascades to sub-tasks). A NEW card REQUIRES `category` + `priority` (and `layer` when the workspace has a frontend). Call `beacon_map` FIRST \u2014 it lists every card\'s category/priority/layer/status, so reuse a category and avoid an EXACT duplicate (same title + category + layer) \u2014 a same-named card in a different category, or on a different layer (FE/BE/FS), is allowed as its own card. `add` never activates an existing match \u2014 it returns `exists` so you can reuse it.',inputSchema:{action:J.enum(["add","start","subtasks","done"]).describe("add = put a card on the board (defaults to BACKLOG/PENDING); start = mark an existing card IN_PROGRESS; subtasks = add child tasks under a card; done = complete feature(s) + register files/architecture."),title:J.string().optional().describe("card title (add/start); for done's single form, the feature title (id preferred)."),id:J.string().optional().describe("node id from beacon_map (preferred over title) \u2014 start/done, or add to reference a known card."),category:J.string().optional().describe("REQUIRED for a NEW card (add/start): domain lane \u2014 AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 Reuse one from beacon_map; ignored when matching an existing card or nesting under a `front`."),priority:J.number().int().min(0).max(3).optional().describe("priority of a NEW card (add/start): 0=P0 critical .. 3=P3 low. Defaults to P2."),front:J.string().optional().describe("title of an EXISTING parent feature to nest a NEW card under (add/start). NOT a domain tag (use `category`); a `front` matching nothing is REJECTED."),detail:J.string().optional().describe("one-line plain-language description shown on the card (add/start)."),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG renders a typed bug card; defaults to FEATURE (add/start)."),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack a NEW card lands on (add/start). REQUIRED when the workspace has a frontend; a card nested under a `front` inherits the parent's. Omit in pure-backend repos."),status:J.enum(["backlog","active"]).optional().describe(`add only: "backlog" (default) creates a PENDING card you're not working on yet; "active" creates it IN_PROGRESS.`),parentId:J.string().optional().describe("subtasks: node id of the parent card (preferred)."),parentTitle:J.string().optional().describe("subtasks: fuzzy title of the parent card; ignored if parentId is given."),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG for a bug discovered during work; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the sub-task lands on; defaults to the parent's layer")})).optional().describe("subtasks: the child tasks to add under the parent."),features:J.array(J.object({id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),architecture:I9})).optional().describe("done: register MANY features at once \u2014 one entry per feature the plan created, each id-keyed. Use this instead of N separate calls."),description:J.string().optional().describe("done (single form, omit when using `features`): the markdown summary of the shipped feature."),files:J.array(J.string()).optional().describe("done (single form): repo-relative files the feature touched."),architecture:I9}},async($)=>{try{let{path:Q,body:Z}=v9($.action,$),Y=await s0(Q,Z);return{content:[{type:"text",text:JSON.stringify(Y)}]}}catch(Q){return L9(Q)}});R.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),hasFrontend:J.boolean().optional().describe("Whether this repo has a frontend surface (UI code) \u2014 you just read the repo, so you know. Gates the per-item `layer` requirement + the layer UI on the boards. Set it explicitly (true or false); omitting leaves Beacon to detect it from the code graph."),classificationRoots:J.array(J.string()).optional().describe("Top-level dirs whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. ['frontend','backend/app']. The canvas groups files ONE level below each (so 'frontend' \u2192 'frontend/components', 'frontend/app', \u2026). Pick the dir sitting directly ABOVE the real package dirs (use 'frontend/src' if there's a src/ wrapper). Not every dir \u2014 just where grouping should start. Omit for a simple single-root repo (the canvas auto-groups)."),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on \u2014 set it when hasFrontend is true"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found while examining this component \u2014 flagged on the node (by=agent)")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when the survey found a concrete bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the item lands on \u2014 set it when hasFrontend is true")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await s0("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});R.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let Y=new URLSearchParams;if($)Y.set("id",$);if(Q)Y.set("title",Q);if(Z)Y.set("query",Z);let X=await E(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});R.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let Y=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});R.registerTool("beacon_entities",{description:"Read raw planning data: `features` (roadmap), `architecture` (components), `tables`/`endpoints` (DB map). Descriptions are truncated to ~160 chars by default to stay within the tool-result limit \u2014 pass `full:true` for complete text and `limit` to cap rows. For just titles + categories + status, prefer the lighter `beacon_map`.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"]),full:J.boolean().optional().describe("return complete descriptions instead of the truncated default (features/architecture)"),limit:J.number().int().positive().optional().describe("cap the number of rows returned")}},async({kind:$,full:Q,limit:Z})=>{let Y=new URLSearchParams({kind:$});if(Q)Y.set("full","1");if(Z)Y.set("limit",String(Z));let X=await E(`/api/entities?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});R.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 and, when the workspace has a frontend, `layer` (frontend | backend | fullstack). The tool REJECTS a plan whose features omit any required field, so set them on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when this roadmap item is a bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack the work lands on. REQUIRED on every feature when the workspace has a frontend (the tool rejects the plan otherwise); omit in pure-backend repos.")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional(),contract:J.array(J.string()).optional().describe("Repo-relative files THIS plan will touch \u2014 the scope contract. When the user has the plan scope-guard enabled, these are frozen at approval and you are held to them while implementing: editing an undeclared file pauses for the user's authorization (which adds it to the contract). Safe to always include; ignored when the guard is off.")}},async({description:$,features:Q,tables:Z,relations:Y,endpoints:X,contract:H})=>{let G=(P)=>new Promise((K0)=>setTimeout(K0,P)),j=(P)=>({content:[{type:"text",text:P}]}),U=(Z?.length??0)>0,w=(Q??[]).map((P)=>`${P.title} ${P.role??""} ${P.plain??""}`).join(`
|
|
282
|
-
`),
|
|
283
|
-
${
|
|
350
|
+
`)+'\n\nWhen the work ships, register them in ONE call: `beacon_feature({ action: "done" })` with a '+"`features` array \u2014 one entry per feature"+(Z?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}import{readFileSync as SQ}from"fs";import{join as zQ}from"path";function fQ(){try{return JSON.parse(SQ(zQ(L(),"server.json"),"utf8"))}catch{return null}}function h(){if(process.env.BEACON_URL)return process.env.BEACON_URL;return`http://localhost:${fQ()?.port||process.env.PORT||q9}`}import{execSync as hQ}from"child_process";import{platform as E9}from"os";function _5($){if(process.env.BEACON_NO_OPEN)return;let Q=E9()==="darwin"?"open":E9()==="win32"?"start":"xdg-open";try{hQ(`${Q} "${$}"`,{stdio:"ignore"})}catch{}}async function L5($,Q){if(await fetch(`${$}/api/plan/presence`,{headers:{"x-beacon-workspace":Q}}).then((X)=>X.json()).then((X)=>!!X?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/plan?ws=${Q}`);_5(`${$}/api/workspace/activate?id=${Q}&redirect=${Y}`)}async function T9($,Q){if(await fetch(`${$}/api/lesson/presence`,{headers:{"x-beacon-workspace":Q}}).then((X)=>X.json()).then((X)=>!!X?.live).catch(()=>!1))return;let Y=encodeURIComponent(`/learn?ws=${Q}`);_5(`${$}/api/workspace/activate?id=${Q}&redirect=${Y}`)}var I9=["imports","calls","persists to","reads from","writes to","routes to","depends on","emits","returns","contains","extends"];r0();function K0($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function k9($){return`${K0($.title)}-${$.id.slice(-6)}`}function _9($){return{resources:$.map((Q)=>({uri:`note://${k9(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function L9($,Q){return $.find((Z)=>k9(Z)===Q)}function y9($){let Q=$.body.trim()||"(this note is empty)";return[`# ${$.title||"Untitled"}`,"","_User note from Beacon. To turn it into roadmap work, call `beacon_propose_plan` \u2014"+" checkbox `- [ ]` / `- [x]` items become subtasks, and order the features with `dependsOn`. Do NOT implement until it returns approval._","","---","",Q].join(`
|
|
351
|
+
`)}await Z9();var u=j9(),x=i(u);if(!b0(u)){let $=c0();if($.length===1)console.error(`[beacon mcp] cwd ${u} isn't a registered repo \u2014 falling back to your only Beacon workspace "${$[0].name}".`);else if($.length>1)console.error(`[beacon mcp] cwd ${u} isn't a registered repo and you have ${$.length} Beacon workspaces \u2014 can't auto-detect which. Run /beacon-init in this repo, or name the project explicitly in your request.`);else console.error(`[beacon mcp] not registering ${u} \u2014 home/non-repo dir.`)}else if(m0(x))console.error(`[beacon mcp] not registering ${u} \u2014 workspace was deleted; run /beacon-init to re-add it.`);else try{l0(u);let $=await R5(x);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",x),Z.set(D5,u);let Y=await fetch(`${h()}${$}`,{...Q,headers:Z}),X=await Y.text();if(!Y.ok)throw Error(`Beacon ${$} -> ${Y.status} ${X}`);return X?JSON.parse(X):null}function N0($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function x5($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let Y=JSON.parse(Z[0]);if(Y?.error)return{content:[{type:"text",text:Y.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var A=new uQ({name:"beacon",version:"0.1.0"});A.registerTool("beacon_map",{description:"List the roadmap: every feature + its sub-tasks with `category`, `priority`, `layer`, `kind`, and `status`. Call this BEFORE creating anything with `beacon_feature` \u2014 it's the cheap way to learn which categories already exist (reuse one instead of inventing a synonym) and whether a card already exists. You do NOT need `beacon_entities` just to see categories."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($)}]}});var x9=J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on (only when the repo has a frontend); omitting it on an update keeps the prior value"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found in this component's code \u2014 flagged on the node (by=agent); identical open flags are not duplicated")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file");A.registerTool("beacon_feature",{description:'Manage a roadmap feature\'s whole lifecycle in ONE tool \u2014 no approval gate (that\'s `beacon_propose_plan`/`beacon_present_plan`). `action:"add"` puts a card on the board, defaulting to BACKLOG/PENDING (pass `status:"active"` to start it now); `"start"` marks an existing card IN_PROGRESS (create-or-flag); `"subtasks"` adds child tasks under a card; `"done"` completes feature(s) and registers the files/architecture touched (marks DONE + cascades to sub-tasks). A NEW card REQUIRES `category` + `priority` (and `layer` when the workspace has a frontend). Call `beacon_map` FIRST \u2014 it lists every card\'s category/priority/layer/status, so reuse a category and avoid an EXACT duplicate (same title + category + layer) \u2014 a same-named card in a different category, or on a different layer (FE/BE/FS), is allowed as its own card. `add` never activates an existing match \u2014 it returns `exists` so you can reuse it.',inputSchema:{action:J.enum(["add","start","subtasks","done"]).describe("add = put a card on the board (defaults to BACKLOG/PENDING); start = mark an existing card IN_PROGRESS; subtasks = add child tasks under a card; done = complete feature(s) + register files/architecture."),title:J.string().optional().describe("card title (add/start); for done's single form, the feature title (id preferred)."),id:J.string().optional().describe("node id from beacon_map (preferred over title) \u2014 start/done, or add to reference a known card."),category:J.string().optional().describe("REQUIRED for a NEW card (add/start): domain lane \u2014 AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 Reuse one from beacon_map; ignored when matching an existing card or nesting under a `front`."),priority:J.number().int().min(0).max(3).optional().describe("priority of a NEW card (add/start): 0=P0 critical .. 3=P3 low. Defaults to P2."),front:J.string().optional().describe("title of an EXISTING parent feature to nest a NEW card under (add/start). NOT a domain tag (use `category`); a `front` matching nothing is REJECTED."),detail:J.string().optional().describe("one-line plain-language description shown on the card (add/start)."),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG renders a typed bug card; defaults to FEATURE (add/start)."),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack a NEW card lands on (add/start). REQUIRED when the workspace has a frontend; a card nested under a `front` inherits the parent's. Omit in pure-backend repos."),status:J.enum(["backlog","active"]).optional().describe(`add only: "backlog" (default) creates a PENDING card you're not working on yet; "active" creates it IN_PROGRESS.`),parentId:J.string().optional().describe("subtasks: node id of the parent card (preferred)."),parentTitle:J.string().optional().describe("subtasks: fuzzy title of the parent card; ignored if parentId is given."),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG for a bug discovered during work; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the sub-task lands on; defaults to the parent's layer")})).optional().describe("subtasks: the child tasks to add under the parent."),features:J.array(J.object({id:J.string().optional().describe("node id from plan approval / beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),architecture:x9})).optional().describe("done: register MANY features at once \u2014 one entry per feature the plan created, each id-keyed. Use this instead of N separate calls."),description:J.string().optional().describe("done (single form, omit when using `features`): the markdown summary of the shipped feature."),files:J.array(J.string()).optional().describe("done (single form): repo-relative files the feature touched."),architecture:x9}},async($)=>{try{let{path:Q,body:Z}=R9($.action,$),Y=await N0(Q,Z);return{content:[{type:"text",text:JSON.stringify(Y)}]}}catch(Q){return x5(Q)}});A.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),hasFrontend:J.boolean().optional().describe("Whether this repo has a frontend surface (UI code) \u2014 you just read the repo, so you know. Gates the per-item `layer` requirement + the layer UI on the boards. Set it explicitly (true or false); omitting leaves Beacon to detect it from the code graph."),classificationRoots:J.array(J.string()).optional().describe("Top-level dirs whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. ['frontend','backend/app']. The canvas groups files ONE level below each (so 'frontend' \u2192 'frontend/components', 'frontend/app', \u2026). Pick the dir sitting directly ABOVE the real package dirs (use 'frontend/src' if there's a src/ wrapper). Not every dir \u2014 just where grouping should start. Omit for a simple single-root repo (the canvas auto-groups)."),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the component lives on \u2014 set it when hasFrontend is true"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on"),bugs:J.array(J.object({note:J.string().describe("what was found / worth investigating")})).optional().describe("bugs or things worth investigating you found while examining this component \u2014 flagged on the node (by=agent)")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when the survey found a concrete bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("which side of the stack the item lands on \u2014 set it when hasFrontend is true")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await N0("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});A.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let Y=new URLSearchParams;if($)Y.set("id",$);if(Q)Y.set("title",Q);if(Z)Y.set("query",Z);let X=await E(`/api/context/feature?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});A.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let Y=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(Y)}]}});A.registerTool("beacon_entities",{description:"Read raw planning data: `features` (roadmap), `architecture` (components), `tables`/`endpoints` (DB map). Descriptions are truncated to ~160 chars by default to stay within the tool-result limit \u2014 pass `full:true` for complete text and `limit` to cap rows. For just titles + categories + status, prefer the lighter `beacon_map`.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"]),full:J.boolean().optional().describe("return complete descriptions instead of the truncated default (features/architecture)"),limit:J.number().int().positive().optional().describe("cap the number of rows returned")}},async({kind:$,full:Q,limit:Z})=>{let Y=new URLSearchParams({kind:$});if(Q)Y.set("full","1");if(Z)Y.set("limit",String(Z));let X=await E(`/api/entities?${Y.toString()}`);return{content:[{type:"text",text:JSON.stringify(X)}]}});A.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 and, when the workspace has a frontend, `layer` (frontend | backend | fullstack). The tool REJECTS a plan whose features omit any required field, so set them on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header. In any prose (here or a feature's `plain`), write file references as repo-relative paths in `backticks` \u2014 on /plan, paths matching a REAL repo file render clickable to open in the user's editor."),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards"),kind:J.enum(["FEATURE","BUG"]).optional().describe("BUG when this roadmap item is a bug to fix \u2014 renders as a typed bug card; defaults to FEATURE"),layer:J.enum(["frontend","backend","fullstack"]).optional().describe("Which side of the stack the work lands on. REQUIRED on every feature when the workspace has a frontend (the tool rejects the plan otherwise); omit in pure-backend repos.")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional(),contract:J.array(J.string()).optional().describe("Repo-relative files THIS plan will touch \u2014 the scope contract. When the user has the plan scope-guard enabled, these are frozen at approval and you are held to them while implementing: editing an undeclared file pauses for the user's authorization (which adds it to the contract). Safe to always include; ignored when the guard is off.")}},async({description:$,features:Q,tables:Z,relations:Y,endpoints:X,contract:H})=>{let G=(C)=>new Promise((M0)=>setTimeout(M0,C)),U=(C)=>({content:[{type:"text",text:C}]}),j=(Z?.length??0)>0,K=(Q??[]).map((C)=>`${C.title} ${C.role??""} ${C.plain??""}`).join(`
|
|
352
|
+
`),w=(X?.length??0)>0||O9(`${$}
|
|
353
|
+
${K}`);if(!j&&w)return U("\u26D4 This plan touches the database \u2014 it declares endpoints and/or its text describes "+"models/tables/migrations \u2014 but you passed NO `tables`. Beacon's schema board renders "+"ONLY from structured `tables`; prose is never parsed, so the /db tab would be empty and nothing would persist on approve.\n\nRe-call `beacon_propose_plan` with every table in `tables` (each with its `columns`), the `relations` (FKs), and keep the `endpoints` (each with `uses:[{table,access}]`). Mirror EVERY database entity your plan mentions into the structured fields.");if(Q?.length){let C=await E("/api/project-meta").then((g9)=>!!g9?.hasFrontend).catch(()=>!1),M0=A9(Q,{requireLayer:C});if(M0)return U(M0)}let i0=(Z?.length??0)+(X?.length??0)>0;try{await N0("/api/plan",{description:$,draft:i0?{tables:Z??[],relations:Y??[],endpoints:X??[]}:void 0,features:Q?.length?Q:void 0,contract:H?.length?H:void 0})}catch(C){return x5(C)}await fetch(`${h()}/api/workspace/activate?id=${x}`).catch(()=>{}),await L5(h(),x);let u9=Date.now()+P0;while(Date.now()<u9){await G(q0);let C=await E("/api/plan/verdict").catch(()=>null);if(!C)continue;if(C.kind==="feedback")return U("\uD83D\uDCAC The user left feedback on the plan in Beacon \u2014 text comments and/or edits they "+"made directly on the /map and /db boards. Read everything below, revise the plan accordingly (matching the board changes verbatim), and call `beacon_propose_plan` "+`again with the revised version \u2014 DO NOT implement yet:
|
|
284
354
|
|
|
285
|
-
`+
|
|
355
|
+
`+C.feedback);if(C.kind==="approved")return U(`\u2705 Plan approved by the user. ${C.summary}`+(C.detail?`
|
|
286
356
|
|
|
287
357
|
Implement EXACTLY the schema below (migrations + code) \u2014 the user may have `+`edited columns on the canvas:
|
|
288
358
|
|
|
289
|
-
`+
|
|
359
|
+
`+C.detail:"")+k5(C.features));if(C.kind==="discarded")return U(`\u274C The user discarded the plan in Beacon. ${C.summary} Ask what they want to adjust before proposing again.`)}return U("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_propose_plan` again with the SAME plan to resume (the verdict is picked up immediately if they've since decided), or ask whether they've reviewed it.")});A.registerTool("beacon_explain",{description:"BLOCKS until the user is done learning. Use when the user asks you to EXPLAIN / TEACH / walk "+"them through part of the codebase (architecture, a category, how X works) \u2014 NOT to plan a "+"build (that's beacon_propose_plan). Pushes an interactive Lesson to Beacon's /learn page: a curated concept map (nodes + verb-labeled arrows) beside a plain-English narrative. The user highlights text to ask questions and drops question notes; this returns their questions so you ANSWER them and call beacon_explain AGAIN with the same lesson plus `answers:[{questionId,answer}]`, looping until they Save.\n\nWrite like a great teacher (the house style): open each component with the PROBLEM it solves and a concrete scenario; give a numbered step-by-step flow naming every real identifier in `backticks` (files become clickable on /learn); add 'Why X?' sections that explain why the alternative is worse; include a worked example with a small data table; use **bold** for decisions, *italic* for concepts. Map every piece you name to a node, "+"and every 'A does X to B' to a labeled edge. Plain English throughout \u2014 define terms inline.",inputSchema:{title:J.string().describe("the lesson title, e.g. 'How a plan flows to /plan'"),topic:J.string().optional().describe("the user's request, verbatim (shown in the library)"),narrative:J.string().describe("The house-style explanation as markdown (problem-first \u2192 numbered flow \u2192 'Why X?' \u2192 worked example). Write file references as repo-relative paths in `backticks` \u2014 they render clickable on /learn."),nodes:J.array(J.object({id:J.string().describe("a short stable id you assign (e.g. 'n1') \u2014 edges reference it"),title:J.string(),summary:J.string().optional().describe("one-line plain-English summary shown on the node face"),detail:J.string().optional().describe("fuller plain-English explanation, markdown, shown on click"),files:J.array(J.string()).optional().describe("real repo-relative paths this node maps to \u2014 clickable chips"),group:J.string().optional().describe("optional cluster label for landmark regions"),x:J.number().optional(),y:J.number().optional()})).optional().describe("the curated concept-map boxes \u2014 keep the resting set small (~4-7 per view)"),edges:J.array(J.object({fromId:J.string(),toId:J.string(),verb:J.enum(I9).describe("the relationship \u2014 a labeled directional arrow, never a bare line")})).optional(),steps:J.array(J.object({title:J.string(),summary:J.string().optional(),focusIds:J.array(J.string()).optional().describe("node ids to spotlight this step; omit/[] = whole-board overview"),narrativeAnchor:J.string().optional()})).optional().describe("the guided-walkthrough order \u2014 reveal one node/step at a time; first step should be the overview"),answers:J.array(J.object({questionId:J.string(),answer:J.string()})).optional().describe("on a re-push: your answers to the user's questions, keyed by the [q:ID] they came with")}},async({title:$,topic:Q,narrative:Z,nodes:Y,edges:X,steps:H,answers:G})=>{let U=(w)=>new Promise((i0)=>setTimeout(i0,w)),j=(w)=>({content:[{type:"text",text:w}]});try{await N0("/api/lesson",{title:$,topic:Q,narrative:Z,nodes:Y,edges:X,steps:H,answers:G})}catch(w){return x5(w)}await fetch(`${h()}/api/workspace/activate?id=${x}`).catch(()=>{}),await T9(h(),x);let K=Date.now()+P0;while(Date.now()<K){await U(q0);let w=await E("/api/lesson/verdict").catch(()=>null);if(!w)continue;if(w.kind==="questions")return j("\uD83D\uDCAC The user asked questions about the lesson in Beacon. Answer each one, then call "+"`beacon_explain` AGAIN with the SAME lesson plus `answers:[{questionId,answer}]` (keyed by the [q:ID] below). Expand the narrative or add nodes where it helps the explanation. "+`Keep looping until the user saves \u2014 DO NOT stop after one round:
|
|
360
|
+
|
|
361
|
+
`+(w.rendered??""));if(w.kind==="saved")return j(`\u2705 The user saved the lesson to their library. ${w.summary} You're done explaining \u2014 `+"they can reopen it anytime from /learn.");if(w.kind==="closed")return j(`The user closed the lesson without saving. ${w.summary} Stop here; ask if they'd like a different explanation.`)}return j("Still waiting for the user to finish the lesson in Beacon. It's preserved \u2014 call "+"`beacon_explain` again with the SAME lesson to resume.")});A.registerTool("beacon_present_plan",{description:"BLOCKS until the user reviews. Pushes ANY plan (as markdown) to Beacon's /plan page so the user reviews it on the canvas instead of in the terminal \u2014 use this whenever you'd otherwise end a turn asking 'does this look right / should I proceed?'. Embed ONE fenced ```beacon block of JSON ({tables,relations,endpoints,features}) for any DB/roadmap entities so they render as an editable board. Returns the verdict (approved / discarded / feedback). Do NOT implement until it returns approval; on feedback, revise and call again. (For a pure schema+features plan, beacon_propose_plan is the structured alternative.)",inputSchema:{description:J.string().describe("One-line summary shown in the review header"),markdown:J.string().describe("The full plan as markdown. Embed a ```beacon block for tables/endpoints/features. Write file references as repo-relative paths in `backticks` (e.g. `app/api/plan/route.ts`) \u2014 on /plan, paths matching a REAL repo file render clickable to open in the user's editor.")}},async({description:$,markdown:Q})=>{let Z=(H)=>new Promise((G)=>setTimeout(G,H)),Y=(H)=>({content:[{type:"text",text:H}]});await N0("/api/plan",{description:$,markdown:Q}),await fetch(`${h()}/api/workspace/activate?id=${x}`).catch(()=>{}),await L5(h(),x);let X=Date.now()+P0;while(Date.now()<X){await Z(q0);let H=await E("/api/plan/verdict").catch(()=>null);if(!H)continue;if(H.kind==="feedback")return Y("\uD83D\uDCAC The user left feedback on the plan in Beacon (inline comments and/or edits on the "+"/map and /db boards). Revise the plan accordingly and call `beacon_present_plan` "+`again \u2014 do NOT implement yet:
|
|
290
362
|
|
|
291
363
|
`+H.feedback);if(H.kind==="approved")return Y(`\u2705 Plan approved by the user. ${H.summary??""}`.trim()+(H.detail?`
|
|
292
364
|
|
|
293
365
|
Implement exactly what's on the board:
|
|
294
366
|
|
|
295
|
-
${H.detail}`:"")+
|
|
296
|
-
`)}]}}
|
|
367
|
+
${H.detail}`:"")+k5(H.features));if(H.kind==="discarded")return Y(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return Y("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_present_plan` again with the SAME plan to resume, or ask whether they've reviewed it.")});var z9=($)=>Array.isArray($)?$[0]:$;async function n0($){return(await E(`/api/entities?kind=${$}&full=1`)).items}function f9($,Q){return{resources:$.map((Z)=>({uri:`${Q}${K0(Z.title)}`,name:Z.title,description:`${Z.title}${Z.cluster?` \xB7 ${Z.cluster}`:""} \xB7 ${Z.status}`,mimeType:"text/markdown"}))}}async function h9($,Q,Z){let Y=(await n0(Z)).find((U)=>K0(U.title)===z9(Q));if(!Y)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await E("/api/entities?kind=tables")).items??[]).map((U)=>U.name),G=[`# ${Y.title}`];if(Y.cluster)G.push(`*Domain:* \`${Y.cluster}\``);if(Y.status)G.push(`*Status:* \`${Y.status}\``);if(G.push(""),G.push(Y.plain?.trim()||"(this node has no description yet \u2014 add one on Beacon's /map page)"),G.push("","## Existing DB tables in this project"),G.push(H.length?H.join(", "):"(none yet)"),Z==="features"){let U=await n0("features"),j=[...new Set(U.map((K)=>K.cluster?.trim()).filter((K)=>!!K))].sort();G.push("","## Existing feature categories \u2014 reuse one before inventing a new one"),G.push(j.length?j.join(", "):"(none yet)"),G.push("","## Beacon feature loop \u2014 follow IN ORDER (do not jump to Glob/Grep/Read)","1. **Load context FIRST.** Call `beacon_context_for_feature({ title })` for this feature BEFORE any Glob/Grep/Read. It returns the attached files, 1-hop import blast radius, the domain's endpoints + tables + FK relations, sibling components, and the project conventions \u2014 and marks this feature active so your edits attach to it. That bundle replaces the discovery phase; Glob is a last resort.","2. **Design data before code.** Identify the tables this feature needs. If ANY are missing from the list above, design the schema and call `beacon_propose_plan` (tables + relations + endpoints, each endpoint with `uses:[{table,access}]`). It BLOCKS until the user approves on /plan \u2014 do NOT write migrations or code until it returns approval.","3. **Register at the end \u2014 in ONE call.** When the work is done, call `beacon_feature({ action: \"done\" })` ONCE with a `features` array (one entry per feature the plan created, each keyed by the `id` you got back at approval, with the files you touched + a short markdown summary). Don't make one call per feature, and don't register only the umbrella \u2014 that leaves the rest Pending.")}return{contents:[{uri:$.href,mimeType:"text/markdown",text:G.join(`
|
|
368
|
+
`)}]}}A.registerResource("beacon-feature",new y5("feature://{slug}",{list:async()=>f9(await n0("features"),"feature://")}),{title:"Beacon: features",description:"Roadmap features \u2014 picking one imports the node's description plus existing-DB context.",mimeType:"text/markdown"},($,{slug:Q})=>h9($,Q,"features"));A.registerResource("beacon-component",new y5("component://{slug}",{list:async()=>f9(await n0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>h9($,Q,"architecture"));async function S9(){return await E("/api/notes")}A.registerResource("beacon-note",new y5("note://{slug}",{list:async()=>_9(await S9())}),{title:"Beacon: notes",description:"Your Beacon notes \u2014 picking one imports its markdown verbatim so you can turn it into features.",mimeType:"text/markdown"},async($,{slug:Q})=>{let Z=L9(await S9(),z9(Q)),Y=Z?y9(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:Y}]}});await A.connect(new gQ);var s0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(s0===-1)s0=$;else if($!==s0)s0=$,A.sendResourceListChanged()}catch{}},S5);
|