trybeacon 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +18 -16
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +12 -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 +9 -9
- package/.next/server/app/_not-found.segments/_full.segment.rsc +9 -9
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +9 -9
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/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 +2 -2
- 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/ingest/route.js +2 -2
- package/.next/server/app/api/init/route.js +2 -2
- 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/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 +2 -2
- 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/stream/route.js +2 -2
- package/.next/server/app/api/tab/nav/route.js +1 -0
- package/.next/server/app/api/tab/nav/route.js.nft.json +1 -0
- package/.next/server/app/api/tab/nav/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/tab/presence/route.js +1 -0
- package/.next/server/app/api/tab/presence/route.js.nft.json +1 -0
- package/.next/server/app/api/tab/presence/route_client-reference-manifest.js +1 -0
- 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 +9 -9
- package/.next/server/app/docs.segments/_full.segment.rsc +9 -9
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +9 -9
- package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page.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 +9 -9
- package/.next/server/app/feedback.segments/_full.segment.rsc +9 -9
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +9 -9
- package/.next/server/app/feedback.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page.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 +9 -9
- package/.next/server/app/help.segments/_full.segment.rsc +9 -9
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +9 -9
- package/.next/server/app/help.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +9 -9
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +9 -9
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +9 -9
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/map/page.js +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +2 -2
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +2 -2
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +18 -16
- package/.next/server/chunks/1341.js +1 -1
- package/.next/server/chunks/3015.js +1 -1
- package/.next/server/chunks/3622.js +1 -1
- package/.next/server/chunks/4378.js +1 -1
- package/.next/server/chunks/6661.js +1 -0
- package/.next/server/chunks/9683.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/6269-ed869632fa2ed0a3.js +1 -0
- package/.next/static/chunks/app/_global-error/page-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/board-layout/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/code-graph/position/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/code-graph/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/context/feature/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/context/file/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/context/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/arrange/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/backfill-access/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/position/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/prune-planned/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/relations/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/db/tables/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/draft/approve/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/draft/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/draft/status/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/edges/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/edges/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/endpoints/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/entities/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/feedback/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/feedback/[id]/vote/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/feedback/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/ingest/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/init/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/map/describe/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/map/files/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/map/finish/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/map/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/map/start/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/map/touch-active/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/position/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/nodes/positions/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/nodes/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/nodes/subtasks/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/notes/[id]/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/notes/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/open/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/annotations/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/approve/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/history/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/markdown/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/presence/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/plan/verdict/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/preferences/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/project-meta/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/reset/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/stream/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/tab/nav/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/tab/presence/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/telemetry/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/telemetry/stats/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/version/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/workspace/activate/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/api/workspace/route-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/app/layout-eaf313d7a87788ee.js +1 -0
- package/.next/static/chunks/app/map/page-5493b33854a8e920.js +1 -0
- package/.next/static/chunks/app/plan/{page-928529a405650444.js → page-b492328272adca00.js} +1 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-16ca2ed05a1d74d1.js +1 -0
- package/.next/static/dHVM8n6V-GGlrfB8gDibz/_buildManifest.js +1 -0
- package/.next/trace +38 -38
- package/.next/trace-build +1 -1
- package/.next/types/app/api/tab/nav/route.ts +351 -0
- package/.next/types/app/api/tab/presence/route.ts +351 -0
- package/.next/types/routes.d.ts +3 -1
- package/.next/types/validator.ts +18 -0
- package/dist/bin/beacon.js +13 -12
- package/dist/bin/doctor.js +2 -1
- package/dist/bin/hook.js +20 -19
- package/dist/bin/mcp.js +33 -32
- package/dist/bin/plan.js +15 -14
- package/dist/bin/remove.js +2 -2
- package/dist/bin/uninstall.js +2 -1
- package/dist/lib/assets.js +2 -1
- package/dist/lib/codex-install.js +2 -1
- package/dist/lib/daemon-port.js +2 -0
- package/dist/lib/global-install.js +2 -1
- package/drizzle/0007_brainy_george_stacy.sql +1 -0
- package/drizzle/meta/0007_snapshot.json +1773 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +7 -2
- package/.next/server/chunks/2713.js +0 -1
- package/.next/static/chunks/8015-9cd5b2ea19e9aa77.js +0 -1
- package/.next/static/chunks/app/_global-error/page-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/board-layout/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/code-graph/position/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/code-graph/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/context/feature/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/context/file/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/context/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/arrange/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/backfill-access/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/position/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/prune-planned/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/relations/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/db/tables/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/draft/approve/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/draft/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/draft/status/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/edges/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/edges/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/endpoints/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/entities/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/feedback/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/feedback/[id]/vote/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/feedback/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/ingest/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/init/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/map/describe/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/map/files/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/map/finish/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/map/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/map/start/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/map/touch-active/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/position/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/nodes/positions/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/nodes/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/nodes/subtasks/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/notes/[id]/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/notes/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/open/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/annotations/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/approve/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/history/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/markdown/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/presence/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/plan/verdict/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/preferences/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/project-meta/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/reset/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/stream/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/telemetry/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/telemetry/stats/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/version/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/workspace/activate/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/api/workspace/route-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/app/layout-9b750c41268879f0.js +0 -1
- package/.next/static/chunks/app/map/page-b51abf8d1c3ec85a.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f0868dfbc3f7bf63.js +0 -1
- package/.next/static/sJAp6c61WGwLy0STzGlio/_buildManifest.js +0 -1
- /package/.next/static/{sJAp6c61WGwLy0STzGlio → dHVM8n6V-GGlrfB8gDibz}/_ssgManifest.js +0 -0
package/dist/bin/plan.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var FZ=Object.defineProperty;var uZ=(Q)=>Q;function RZ(Q,Z){this[Q]=uZ.bind(null,Z)}var JQ=(Q,Z)=>{for(var $ in Z)FZ(Q,$,{get:Z[$],enumerable:!0,configurable:!0,set:RZ.bind(Z,$)})};var T=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var XQ={};JQ(XQ,{removeRepoAssets:()=>yZ,installRefreshSkill:()=>IZ,installPlanSkill:()=>bZ,installInitSkill:()=>wZ,installCodexRepoSkills:()=>AZ,ensureWorkflowDoc:()=>EZ,ensureMcp:()=>DZ,auditRepo:()=>OZ,REFRESH_SKILL:()=>zQ,PLAN_SKILL:()=>OQ,INIT_SKILL:()=>VQ});import{existsSync as v,mkdirSync as A,readFileSync as G,rmSync as f,writeFileSync as H}from"fs";import{join as U}from"path";function wZ(Q){let Z=U(Q,".claude","skills","beacon-init");A(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,VQ),$}function IZ(Q){let Z=U(Q,".claude","skills","beacon-refresh");A(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,zQ),$}function bZ(Q){let Z=U(Q,".claude","skills","beacon-plan");A(Z,{recursive:!0});let $=U(Z,"SKILL.md");return H($,OQ),$}function AZ(Q){let Z=[];for(let $ of fZ){let Y=U(Q,".agents","skills",$.name);A(Y,{recursive:!0});let J=U(Y,"SKILL.md");H(J,$.body()),Z.push(J)}return Z}function EZ(Q){let Z=U(Q,"AGENTS.md"),$="";try{$=G(Z,"utf8")}catch{}let Y=new RegExp(`${E}[\\s\\S]*?${qQ}`);$=Y.test($)?$.replace(Y,DQ):`${$.trim()}
|
|
4
4
|
|
|
5
5
|
${DQ}
|
|
6
6
|
`.trimStart(),H(Z,$.endsWith(`
|
|
@@ -9,13 +9,13 @@ ${DQ}
|
|
|
9
9
|
|
|
10
10
|
`:""}@AGENTS.md
|
|
11
11
|
`)}function DZ(Q){let Z=U(Q,".mcp.json"),$={};try{$=JSON.parse(G(Z,"utf8"))}catch{}if($.mcpServers=$.mcpServers??{},$.mcpServers.beacon)return{path:Z,added:!1};return $.mcpServers.beacon={command:"beacon",args:["mcp"]},H(Z,JSON.stringify($,null,2)+`
|
|
12
|
-
`),{path:Z,added:!0}}function OZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=G(U(Q,"AGENTS.md"),"utf8").includes(E)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(G(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":v(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":v(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":v(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":v(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function yZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(v(W))
|
|
12
|
+
`),{path:Z,added:!0}}function OZ(Q){let Z=U(Q,".mcp.json"),$=!1;try{$=!!JSON.parse(G(Z,"utf8")).mcpServers?.beacon}catch{}let Y=!1;try{Y=G(U(Q,"AGENTS.md"),"utf8").includes(E)}catch{}let J=!1;try{J=/@AGENTS\.md/.test(G(U(Q,"CLAUDE.md"),"utf8"))}catch{}return{repo:Q,mcpRegistered:$,agentsMdBlock:Y,claudeMdImport:J,skills:{"beacon-init":v(U(Q,".claude","skills","beacon-init","SKILL.md")),"beacon-refresh":v(U(Q,".claude","skills","beacon-refresh","SKILL.md"))},codexSkills:{"beacon-init":v(U(Q,".agents","skills","beacon-init","SKILL.md")),"beacon-refresh":v(U(Q,".agents","skills","beacon-refresh","SKILL.md"))}}}function yZ(Q){let Z=[];for(let z of["beacon-init","beacon-refresh","beacon-db-design"]){let W=U(Q,".claude","skills",z);if(v(W))f(W,{recursive:!0,force:!0}),Z.push(z)}for(let z of["beacon-init","beacon-refresh"]){let W=U(Q,".agents","skills",z);if(v(W))f(W,{recursive:!0,force:!0}),Z.push(`codex:${z}`)}let $=!1,Y=U(Q,".mcp.json");try{let z=JSON.parse(G(Y,"utf8"));if(z.mcpServers?.beacon){if(delete z.mcpServers.beacon,$=!0,z.mcpServers&&Object.keys(z.mcpServers).length===0)delete z.mcpServers;if(Object.keys(z).length===0)f(Y,{force:!0});else H(Y,JSON.stringify(z,null,2)+`
|
|
13
13
|
`)}}catch{}let J=!1,V=U(Q,"AGENTS.md");try{let z=G(V,"utf8"),W=new RegExp(`\\n?${E}[\\s\\S]*?${qQ}\\n?`);if(W.test(z)){let M=z.replace(W,`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
16
|
`).trimStart();H(V,M.endsWith(`
|
|
17
17
|
`)?M:`${M}
|
|
18
|
-
`),J=!0}}catch{}let
|
|
18
|
+
`),J=!0}}catch{}let q=!1,X=U(Q,"CLAUDE.md");try{let z=G(X,"utf8"),W=z.replace(/^[ \t]*@AGENTS\.md[ \t]*\n?/m,"");if(W!==z){if(!W.trim())f(X,{force:!0});else H(X,W);q=!0}}catch{}return{skillsRemoved:Z,mcpUnregistered:$,agentsBlockRemoved:J,claudeImportRemoved:q}}var VQ=`---
|
|
19
19
|
name: beacon-init
|
|
20
20
|
description: Read this repository and map its architecture, schema, and roadmap into Beacon (the local visual planning panel). Use when the user runs /beacon-init, asks to "set up Beacon for this repo", or asks to initialize/bootstrap Beacon's map of this codebase.
|
|
21
21
|
---
|
|
@@ -29,6 +29,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
29
29
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
30
30
|
|
|
31
31
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
32
|
+
- **classificationRoots** (optional): the top-level directories 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 root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
32
33
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
33
34
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
34
35
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -88,7 +89,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
88
89
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
89
90
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
90
91
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
91
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
92
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
92
93
|
|
|
93
94
|
## What you should NOT do
|
|
94
95
|
|
|
@@ -142,7 +143,7 @@ If it returns feedback, revise and call it again.
|
|
|
142
143
|
If \`beacon_present_plan\` isn't available, the panel isn't wired here \u2014 fall back to ExitPlanMode
|
|
143
144
|
with the same \`\`\`beacon block (Claude Code only; Codex has no ExitPlanMode), or tell the user to
|
|
144
145
|
run \`beacon\` in this repo once.
|
|
145
|
-
`,
|
|
146
|
+
`,fZ,E="<!-- beacon:workflow:start -->",qQ="<!-- beacon:workflow:end -->",DQ;var UQ=T(()=>{fZ=[{name:"beacon-init",body:()=>VQ},{name:"beacon-refresh",body:()=>zQ}];DQ=`${E}
|
|
146
147
|
## Beacon \u2014 feature workflow
|
|
147
148
|
|
|
148
149
|
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:
|
|
@@ -201,9 +202,9 @@ If the feature added or materially changed a REAL architectural component (a sub
|
|
|
201
202
|
|
|
202
203
|
Pull raw planning data anytime with \`beacon_entities\` (features / architecture / tables / endpoints).
|
|
203
204
|
${qQ}`});import{existsSync as yQ,mkdirSync as WQ,readFileSync as O,rmSync as LZ,writeFileSync as y}from"fs";import{dirname as LQ,join as D}from"path";function BQ(Q){try{return JSON.parse(O(Q,"utf8"))}catch{return{}}}function kQ(Q,Z){WQ(LQ(Q),{recursive:!0}),y(Q,JSON.stringify(Z,null,2)+`
|
|
204
|
-
`)}function k(Q,Z){let $=BQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((
|
|
205
|
+
`)}function k(Q,Z){let $=BQ(Q);$.hooks=$.hooks??{},$.hooks[Z.event]=$.hooks[Z.event]??[];let Y=$.hooks[Z.event];if(Y.some((V)=>V.matcher===Z.matcher&&V.hooks?.some((q)=>q.command===Z.command)))return!1;return Y.push({matcher:Z.matcher,hooks:[{type:"command",command:Z.command}]}),kQ(Q,$),!0}function _(Q,Z){return(BQ(Q).hooks?.[Z.event]??[]).some((J)=>J.hooks?.some((V)=>V.command===Z.command))}function S(Q,Z){let $=BQ(Q),Y=$.hooks?.[Z.event];if(!Y)return!1;let J=!1,V=Y.map((q)=>{let X=q.hooks?.length??0,z=(q.hooks??[]).filter((W)=>W.command!==Z.command);if(z.length!==X)J=!0;return{...q,hooks:z}}).filter((q)=>(q.hooks??[]).length>0);if(!J)return!1;if(V.length)$.hooks[Z.event]=V;else delete $.hooks[Z.event];if($.hooks&&Object.keys($.hooks).length===0)delete $.hooks;return kQ(Q,$),!0}function h(Q,Z,$,Y){let J=`${Z}
|
|
205
206
|
${Y.trim()}
|
|
206
|
-
${$}`,V="";try{V=O(Q,"utf8")}catch{}let
|
|
207
|
+
${$}`,V="";try{V=O(Q,"utf8")}catch{}let q=new RegExp(`${Z}[\\s\\S]*?${$}`);V=q.test(V)?V.replace(q,J):V.trim()?`${V.trim()}
|
|
207
208
|
|
|
208
209
|
${J}
|
|
209
210
|
`:`${J}
|
|
@@ -211,7 +212,7 @@ ${J}
|
|
|
211
212
|
`)?V:`${V}
|
|
212
213
|
`)}function g(Q,Z){try{return O(Q,"utf8").includes(Z)}catch{return!1}}function m(Q,Z,$){let Y="";try{Y=O(Q,"utf8")}catch{return!1}let J=new RegExp(`${Z}[\\s\\S]*?${$}\\n?`);if(!J.test(Y))return!1;let V=Y.replace(J,"").replace(/\n{3,}/g,`
|
|
213
214
|
|
|
214
|
-
`).trimStart();return y(Q,V),!0}function p(Q,Z,$){let Y=D(Q,Z);WQ(Y,{recursive:!0});let J=D(Y,"SKILL.md");return y(J,$),J}function
|
|
215
|
+
`).trimStart();return y(Q,V),!0}function p(Q,Z,$){let Y=D(Q,Z);WQ(Y,{recursive:!0});let J=D(Y,"SKILL.md");return y(J,$),J}function F(Q,Z){return yQ(D(Q,Z,"SKILL.md"))}function c(Q,Z){let $=D(Q,Z);if(!yQ($))return!1;return LZ($,{recursive:!0,force:!0}),!0}var x,L=`## Beacon (visual planning panel)
|
|
215
216
|
|
|
216
217
|
This machine has Beacon installed \u2014 a local visual planning surface for the terminal-side
|
|
217
218
|
agent. Beacon proposes feature plans (roadmap features + DB schema + endpoints) via MCP,
|
|
@@ -232,24 +233,24 @@ the user reviews on a canvas at /plan, and feedback flows back as the next round
|
|
|
232
233
|
Feedback bundles inline annotations on the markdown PLUS any edits the user made directly
|
|
233
234
|
on the /map and /db boards (added features, attached subtasks, edited columns, new
|
|
234
235
|
endpoints). Treat board edits as the user's revision intent \u2014 re-propose matching them
|
|
235
|
-
verbatim. Do NOT implement until the tool returns approval.`;var HQ=T(()=>{x=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as kZ,renameSync as _Z,rmSync as SZ,writeFileSync as hZ}from"fs";import{dirname as mZ}from"path";function l(Q,Z){kZ(mZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{hZ($,Z),_Z($,Q)}catch(Y){throw SZ($,{force:!0}),Y}}function
|
|
236
|
+
verbatim. Do NOT implement until the tool returns approval.`;var HQ=T(()=>{x=["beacon-init","beacon-refresh","beacon-plan"]});import{mkdirSync as kZ,renameSync as _Z,rmSync as SZ,writeFileSync as hZ}from"fs";import{dirname as mZ}from"path";function l(Q,Z){kZ(mZ(Q),{recursive:!0});let $=`${Q}.tmp`;try{hZ($,Z),_Z($,Q)}catch(Y){throw SZ($,{force:!0}),Y}}function H1(Q,Z,$=!1){l(Q,JSON.stringify(Z,null,$?2:void 0))}var _Q=()=>{};var nQ={};JQ(nQ,{setupCodexAssets:()=>dZ,removeCodexMcp:()=>dQ,removeCodexArtifacts:()=>aZ,hasCodexMcp:()=>PQ,ensureCodexMcp:()=>lQ,codexMcpProblem:()=>lZ,codexDetected:()=>mQ,auditCodex:()=>nZ,CODEX_HOOKS:()=>t});import{readFileSync as s}from"fs";import{homedir as pZ}from"os";import{join as w}from"path";function SQ(){return process.env.HOME||process.env.USERPROFILE||pZ()}function mQ(){if(process.env.BEACON_CODEX==="1")return!0;if(process.env.BEACON_CODEX==="0")return!1;if(jQ===void 0)jQ=Bun.which("codex")!==null;return jQ}function R(Q){try{return Bun.TOML.parse(Q)}catch{return null}}function PQ(){try{return Boolean(R(s(C(),"utf8"))?.mcp_servers?.beacon)}catch{return!1}}function lZ(){let Q="";try{Q=s(C(),"utf8")}catch{return null}let Z=R(Q);if(!Z)return`~/.codex/config.toml does not parse \u2014 ${u}`;if(Z.mcp_servers?.beacon)return null;if(/^\s*mcp_servers\s*=/m.test(Q))return`mcp_servers is an inline table \u2014 ${u}`;return null}function lQ(){let Q="",Z=!1;try{Q=s(C(),"utf8"),Z=!0}catch{}if(Z){let V=R(Q);if(!V)return{added:!1,error:`~/.codex/config.toml does not parse \u2014 ${u}`};if(V.mcp_servers?.beacon)return{added:!1};if(/^\s*mcp_servers\s*=/m.test(Q))return{added:!1,error:`mcp_servers is an inline table \u2014 ${u}`}}let $=!Q?"":Q.endsWith(`
|
|
236
237
|
`)?`
|
|
237
238
|
`:`
|
|
238
239
|
|
|
239
|
-
`,Y=Q+$+cZ;if(R(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${
|
|
240
|
+
`,Y=Q+$+cZ;if(R(Y)?.mcp_servers?.beacon?.command!=="beacon")return{added:!1,error:`could not safely append [mcp_servers.beacon] \u2014 ${u}`};return l(C(),Y),{added:!0}}function dQ(){let Q="";try{Q=s(C(),"utf8")}catch{return{removed:!1}}let Z=Q.split(`
|
|
240
241
|
`),$=Z.indexOf(pQ);if($===-1)return{removed:!1,skipped:PQ()};let Y=Z.indexOf(cQ,$);if(Y===-1)return{removed:!1,skipped:!0};Z.splice($,Y-$+1);let J=Z.join(`
|
|
241
242
|
`).replace(/\n{3,}/g,`
|
|
242
243
|
|
|
243
|
-
`).replace(/^\n+/,"");if(R(J)===null)return{removed:!1,skipped:!0};return l(C(),J),{removed:!0}}async function dZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (UQ(),XQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of x){if(!
|
|
244
|
+
`).replace(/^\n+/,"");if(R(J)===null)return{removed:!1,skipped:!0};return l(C(),J),{removed:!0}}async function dZ(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (UQ(),XQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let z of x){if(!F(n(),z))J.push(z);p(n(),z,Y[z])}let V=0;for(let z of t)if(k(xQ(),{event:z.event,matcher:z.matcher,command:z.command}))V++;let q=g(d(),a);h(d(),a,hQ,L);let X=lQ();return{skillsAdded:J,hooksAdded:V,agentsMdBlockTouched:!q,mcp:X}}function nZ(){let Q={};for(let $ of x)Q[$]=F(n(),$);let Z={};for(let $ of t)Z[$.event]=_(xQ(),{event:$.event,command:$.command});return{detected:mQ(),skills:Q,hooks:Z,agentsMdBlock:g(d(),a),mcp:PQ()}}function aZ(){let Q=[];for(let J of x)if(c(n(),J))Q.push(J);let Z=0;for(let J of t)if(S(xQ(),{event:J.event,command:J.command}))Z++;let $=m(d(),a,hQ),Y=dQ();return{skillsRemoved:Q,hooksRemoved:Z,agentsMdBlockRemoved:$,mcpRemoved:Y.removed,mcpSkipped:Y.skipped}}var GQ=()=>w(SQ(),".codex"),xQ=()=>w(GQ(),"hooks.json"),C=()=>w(GQ(),"config.toml"),d=()=>w(GQ(),"AGENTS.md"),n=()=>w(SQ(),".agents","skills"),a="<!-- beacon:global:start -->",hQ="<!-- beacon:global:end -->",t,jQ,pQ="# beacon:start (managed by Beacon \u2014 `beacon uninstall` removes this block)",cQ="# beacon:end",cZ,u="add it manually: codex mcp add beacon -- beacon mcp";var aQ=T(()=>{HQ();_Q();t=[{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."}];cZ=`${pQ}
|
|
244
245
|
[mcp_servers.beacon]
|
|
245
246
|
command = "beacon"
|
|
246
247
|
args = ["mcp"]
|
|
247
248
|
${cQ}
|
|
248
|
-
`});var eQ={};JQ(eQ,{provisionDb:()=>K0});import{createClient as z0}from"@libsql/client";import{drizzle as q0}from"drizzle-orm/libsql";import{migrate as X0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as U0}from"drizzle-orm/migrator";import{dirname as TQ,join as W0}from"path";import{fileURLToPath as B0}from"url";async function i(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function x0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function iQ(Q){if(!await i(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function P0(Q){for(let[Z,$]of Object.entries(G0)){if(!await i(Q,Z))continue;let Y=await x0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function K0(Q,Z=j0){let $=z0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await i($,"__drizzle_migrations"),J=await i($,"Node"),V=!1;if(J&&!Y){let q=U0({migrationsFolder:Z})[0];if(q)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[q.hash,q.folderMillis]}),V=!0}let X=await iQ($);if(await X0(q0($),{migrationsFolder:Z}),await iQ($)>X)V=!0;return await P0($),{migrated:V}}finally{$.close()}}var H0,j0,G0;var QZ=T(async()=>{H0=TQ(TQ(TQ(B0(import.meta.url)))),j0=process.env.BEACON_MIGRATIONS_DIR||W0(H0,"drizzle"),G0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});HQ();import{existsSync as sZ}from"fs";import{homedir as tZ}from"os";import{join as r}from"path";function rZ(){return process.env.HOME||process.env.USERPROFILE||tZ()}var o=()=>r(rZ(),".claude"),KQ=()=>r(o(),"skills"),NQ=()=>r(o(),"settings.json"),vQ=()=>r(o(),"CLAUDE.md"),CQ="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->";var oZ=L,MQ=[{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 iZ(Q,Z){return p(KQ(),Q,Z)}function tQ(Q){return u(KQ(),Q)}function eZ(Q){return c(KQ(),Q)}function Q0(Q){return k(NQ(),Q)}function Z0(Q){return _(NQ(),Q)}function $0(Q){return S(NQ(),Q)}function Y0(Q){h(vQ(),CQ,sQ,Q)}function rQ(){return g(vQ(),CQ)}function J0(){return m(vQ(),CQ,sQ)}function v1(){let Q={};for(let $ of x)Q[$]=tQ($);let Z={};for(let $ of MQ)Z[$.event]=Z0({event:$.event,command:$.command});return{homeExists:sZ(o()),skills:Q,hooks:Z,claudeMdBlock:rQ()}}async function V0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (UQ(),XQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let q of x){if(!tQ(q))J.push(q);iZ(q,Y[q])}let V=0;for(let q of MQ)if(Q0({event:q.event,matcher:q.matcher,command:q.command}))V++;let X=rQ();return Y0(oZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!X}}async function oQ(){let Q;try{Q={ok:!0,...await V0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (aQ(),nQ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function C1(){let Q=[];for(let Y of x)if(eZ(Y))Q.push(Y);let Z=0;for(let Y of MQ)if($0(Y))Z++;let $=J0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as N0}from"async_hooks";import{spawnSync as v0}from"child_process";import{createHash as C0}from"crypto";import{existsSync as $Z,mkdirSync as f,readFileSync as uQ,writeFileSync as FQ}from"fs";import{homedir as YZ}from"os";import{basename as M0,join as P,parse as T0,resolve as ZZ}from"path";function j(){return process.env.BEACON_HOME||P(YZ(),".beacon")}function RQ(){return P(j(),"workspaces.json")}function e(Q){return C0("sha256").update(Q).digest("hex").slice(0,12)}function O1(Q=process.cwd()){let Z=v0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function JZ(Q){let Z=ZZ(Q);return Z!==ZZ(YZ())&&Z!==T0(Z).root}function VZ(){return P(j(),"deleted.json")}function wQ(){try{let Q=JSON.parse(uQ(VZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function zZ(Q){f(j(),{recursive:!0}),FQ(VZ(),JSON.stringify(Q,null,2))}function qZ(Q){return wQ().includes(Q)}function y1(Q){let Z=wQ();if(!Z.includes(Q))zZ([...Z,Q])}function g0(Q){let Z=wQ();if(Z.includes(Q))zZ(Z.filter(($)=>$!==Q))}function QQ(Q){return P(j(),Q)}function u0(Q){return`file:${P(QQ(Q),"db.sqlite")}`}function b(){try{let Q=JSON.parse(uQ(RQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function fQ(Q){f(j(),{recursive:!0}),FQ(RQ(),JSON.stringify(Q,null,2))}function F0(){return b().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function K(Q){return b().find((Z)=>Z.id===Q)??null}function XZ(Q,Z,$=new Date().toISOString()){if(!JZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=e(Q);if(qZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=b(),V=J.find((z)=>z.id===Y),X={id:Y,path:Q,name:Z||V?.name||M0(Q),lastOpenedAt:$},q=[X,...J.filter((z)=>z.id!==Y)];return f(QQ(Y),{recursive:!0}),fQ(q),X}function L1(Q,Z){return g0(e(Q)),XZ(Q,Z)}function k1(Q,Z=new Date().toISOString()){let $=b(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,fQ($)}function _1(Q){if(fQ(b().filter((Z)=>Z.id!==Q)),bQ()===Q)R0(F0()[0]?.id??null)}function UZ(){return P(j(),"active")}function bQ(){try{return uQ(UZ(),"utf8").trim()||null}catch{return null}}function R0(Q){f(j(),{recursive:!0}),FQ(UZ(),Q??"")}function S1(){let Q=bQ();return Q?K(Q):null}function h1(){let Q=f0()??bQ();return Q?K(Q):null}function m1(Q){return K(Q)?.path??null}function p1(){return $Z(RQ())}var WZ="beacon_ws";function BZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function c1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&K(Z))return Z;let $=BZ(Q,WZ);if($&&K($))return $;return null}var w0="x-beacon-workspace-path";async function l1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&K(Z))return Z;let $=Q.headers.get(w0);if($&&JZ($)&&!qZ(e($))&&(!Z||e($)===Z)){let J=XZ($);return await b0(J.id),J.id}let Y=BZ(Q,WZ);if(Y&&K(Y))return Y;return null}var HZ=new N0;function d1(Q,Z){return Q?HZ.run(Q,Z):Z()}function f0(){return HZ.getStore()??null}var gQ=new Set;function n1(Q){gQ.delete(P(QQ(Q),"db.sqlite"))}async function b0(Q){let Z=QQ(Q),$=P(Z,"db.sqlite"),Y=$Z($);if(Y&&gQ.has($))return{ok:!0,created:!1,migrated:!1};try{f(Z,{recursive:!0});let{provisionDb:J}=await QZ().then(() => eQ),V=await J(u0(Q));return gQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{execSync as MZ,spawn as y0}from"child_process";import{mkdirSync as L0,openSync as k0,readFileSync as _0,writeFileSync as S0}from"fs";import{homedir as h0,platform as vZ}from"os";import{dirname as m0,join as $Q}from"path";import{fileURLToPath as p0}from"url";import{createHash as c0}from"crypto";var jZ=1500,GZ=345600000,s1=1800000,t1=3000;import{mkdirSync as A0,readFileSync as E0,writeFileSync as D0}from"fs";import{join as O0}from"path";var I0=["default","acceptEdits","bypassPermissions","auto"];function xZ(Q){return typeof Q==="string"&&I0.includes(Q)}function PZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function KZ(){return O0(j(),"preferences.json")}function IQ(){try{let Q=JSON.parse(E0(KZ(),"utf8"));return{planApprovalMode:xZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function $2(Q){let Z={...IQ(),...Q};return A0(j(),{recursive:!0}),D0(KZ(),JSON.stringify(Z,null,2)),Z}function NZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
249
|
+
`});var eQ={};JQ(eQ,{provisionDb:()=>K0});import{createClient as z0}from"@libsql/client";import{drizzle as q0}from"drizzle-orm/libsql";import{migrate as X0}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as U0}from"drizzle-orm/migrator";import{dirname as TQ,join as W0}from"path";import{fileURLToPath as B0}from"url";async function i(Q,Z){return(await Q.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[Z]})).rows.length>0}async function x0(Q,Z){let $=await Q.execute(`PRAGMA table_info("${Z}")`);return new Set($.rows.map((Y)=>String(Y.name)))}async function iQ(Q){if(!await i(Q,"__drizzle_migrations"))return 0;let Z=await Q.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number(Z.rows[0]?.n??0)}async function P0(Q){for(let[Z,$]of Object.entries(G0)){if(!await i(Q,Z))continue;let Y=await x0(Q,Z);for(let J of $){if(!Y.has(J))continue;await Q.execute(`UPDATE "${Z}" SET "${J}" = CAST((julianday("${J}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${J}") = 'text'`)}}}async function K0(Q,Z=j0){let $=z0({url:Q});try{await $.execute("PRAGMA journal_mode = WAL;"),await $.execute("PRAGMA foreign_keys = ON;"),await $.execute("PRAGMA busy_timeout = 5000;");let Y=await i($,"__drizzle_migrations"),J=await i($,"Node"),V=!1;if(J&&!Y){let X=U0({migrationsFolder:Z})[0];if(X)await $.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await $.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),V=!0}let q=await iQ($);if(await X0(q0($),{migrationsFolder:Z}),await iQ($)>q)V=!0;return await P0($),{migrated:V}}finally{$.close()}}var H0,j0,G0;var QZ=T(async()=>{H0=TQ(TQ(TQ(B0(import.meta.url)))),j0=process.env.BEACON_MIGRATIONS_DIR||W0(H0,"drizzle"),G0={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});HQ();import{existsSync as sZ}from"fs";import{homedir as tZ}from"os";import{join as r}from"path";function rZ(){return process.env.HOME||process.env.USERPROFILE||tZ()}var o=()=>r(rZ(),".claude"),KQ=()=>r(o(),"skills"),NQ=()=>r(o(),"settings.json"),vQ=()=>r(o(),"CLAUDE.md"),CQ="<!-- beacon:global:start -->",sQ="<!-- beacon:global:end -->";var oZ=L,MQ=[{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 iZ(Q,Z){return p(KQ(),Q,Z)}function tQ(Q){return F(KQ(),Q)}function eZ(Q){return c(KQ(),Q)}function Q0(Q){return k(NQ(),Q)}function Z0(Q){return _(NQ(),Q)}function $0(Q){return S(NQ(),Q)}function Y0(Q){h(vQ(),CQ,sQ,Q)}function rQ(){return g(vQ(),CQ)}function J0(){return m(vQ(),CQ,sQ)}function g1(){let Q={};for(let $ of x)Q[$]=tQ($);let Z={};for(let $ of MQ)Z[$.event]=Z0({event:$.event,command:$.command});return{homeExists:sZ(o()),skills:Q,hooks:Z,claudeMdBlock:rQ()}}async function V0(){let{INIT_SKILL:Q,REFRESH_SKILL:Z,PLAN_SKILL:$}=await Promise.resolve().then(() => (UQ(),XQ)),Y={"beacon-init":Q,"beacon-refresh":Z,"beacon-plan":$},J=[];for(let X of x){if(!tQ(X))J.push(X);iZ(X,Y[X])}let V=0;for(let X of MQ)if(Q0({event:X.event,matcher:X.matcher,command:X.command}))V++;let q=rQ();return Y0(oZ),{skillsAdded:J,hooksAdded:V,claudeMdBlockTouched:!q}}async function oQ(){let Q;try{Q={ok:!0,...await V0()}}catch(Z){Q={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}try{let Z=await Promise.resolve().then(() => (aQ(),nQ));if(Z.codexDetected())Q.codex={ok:!0,...await Z.setupCodexAssets()}}catch(Z){Q.codex={ok:!1,error:Z instanceof Error?Z.message:String(Z),skillsAdded:[],hooksAdded:0,agentsMdBlockTouched:!1,mcp:{added:!1}}}return Q}function F1(){let Q=[];for(let Y of x)if(eZ(Y))Q.push(Y);let Z=0;for(let Y of MQ)if($0(Y))Z++;let $=J0();return{skillsRemoved:Q,hooksRemoved:Z,claudeMdBlockRemoved:$}}import{AsyncLocalStorage as N0}from"async_hooks";import{spawnSync as v0}from"child_process";import{createHash as C0}from"crypto";import{existsSync as $Z,mkdirSync as I,readFileSync as FQ,writeFileSync as uQ}from"fs";import{homedir as YZ}from"os";import{basename as M0,join as P,parse as T0,resolve as ZZ}from"path";function j(){return process.env.BEACON_HOME||P(YZ(),".beacon")}function RQ(){return P(j(),"workspaces.json")}function e(Q){return C0("sha256").update(Q).digest("hex").slice(0,12)}function _1(Q=process.cwd()){let Z=v0("git",["rev-parse","--show-toplevel"],{cwd:Q,stdio:["ignore","pipe","ignore"]});if(Z.status===0){let $=Z.stdout?.toString().trim();if($)return $}return Q}function JZ(Q){let Z=ZZ(Q);return Z!==ZZ(YZ())&&Z!==T0(Z).root}function VZ(){return P(j(),"deleted.json")}function wQ(){try{let Q=JSON.parse(FQ(VZ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function zZ(Q){I(j(),{recursive:!0}),uQ(VZ(),JSON.stringify(Q,null,2))}function qZ(Q){return wQ().includes(Q)}function S1(Q){let Z=wQ();if(!Z.includes(Q))zZ([...Z,Q])}function g0(Q){let Z=wQ();if(Z.includes(Q))zZ(Z.filter(($)=>$!==Q))}function QQ(Q){return P(j(),Q)}function F0(Q){return`file:${P(QQ(Q),"db.sqlite")}`}function b(){try{let Q=JSON.parse(FQ(RQ(),"utf8"));return Array.isArray(Q)?Q:[]}catch{return[]}}function IQ(Q){I(j(),{recursive:!0}),uQ(RQ(),JSON.stringify(Q,null,2))}function u0(){return b().sort((Q,Z)=>Z.lastOpenedAt.localeCompare(Q.lastOpenedAt))}function K(Q){return b().find((Z)=>Z.id===Q)??null}function XZ(Q,Z,$=new Date().toISOString()){if(!JZ(Q))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Q}`);let Y=e(Q);if(qZ(Y))throw Error(`beacon: workspace ${Y} (${Q}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let J=b(),V=J.find((z)=>z.id===Y),q={id:Y,path:Q,name:Z||V?.name||M0(Q),lastOpenedAt:$},X=[q,...J.filter((z)=>z.id!==Y)];return I(QQ(Y),{recursive:!0}),IQ(X),q}function h1(Q,Z){return g0(e(Q)),XZ(Q,Z)}function m1(Q,Z=new Date().toISOString()){let $=b(),Y=$.find((J)=>J.id===Q);if(!Y)return;Y.lastOpenedAt=Z,IQ($)}function p1(Q){if(IQ(b().filter((Z)=>Z.id!==Q)),bQ()===Q)R0(u0()[0]?.id??null)}function UZ(){return P(j(),"active")}function bQ(){try{return FQ(UZ(),"utf8").trim()||null}catch{return null}}function R0(Q){I(j(),{recursive:!0}),uQ(UZ(),Q??"")}function c1(){let Q=bQ();return Q?K(Q):null}function l1(){let Q=I0()??bQ();return Q?K(Q):null}function d1(Q){return K(Q)?.path??null}function n1(){return $Z(RQ())}var WZ="beacon_ws";function BZ(Q,Z){let $=Q.headers.get("cookie");if(!$)return null;for(let Y of $.split(";")){let J=Y.indexOf("=");if(J===-1)continue;if(Y.slice(0,J).trim()===Z)return decodeURIComponent(Y.slice(J+1).trim())}return null}function a1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&K(Z))return Z;let $=BZ(Q,WZ);if($&&K($))return $;return null}var w0="x-beacon-workspace-path";async function s1(Q){let Z=Q.headers.get("x-beacon-workspace");if(Z&&K(Z))return Z;let $=Q.headers.get(w0);if($&&JZ($)&&!qZ(e($))&&(!Z||e($)===Z)){let J=XZ($);return await b0(J.id),J.id}let Y=BZ(Q,WZ);if(Y&&K(Y))return Y;return null}var HZ=new N0;function t1(Q,Z){return Q?HZ.run(Q,Z):Z()}function I0(){return HZ.getStore()??null}var gQ=new Set;function r1(Q){gQ.delete(P(QQ(Q),"db.sqlite"))}async function b0(Q){let Z=QQ(Q),$=P(Z,"db.sqlite"),Y=$Z($);if(Y&&gQ.has($))return{ok:!0,created:!1,migrated:!1};try{I(Z,{recursive:!0});let{provisionDb:J}=await QZ().then(() => eQ),V=await J(F0(Q));return gQ.add($),{ok:!0,created:!Y,migrated:Y&&V.migrated}}catch(J){return{ok:!1,created:!1,migrated:!1,error:J instanceof Error?J.message:String(J)}}}import{connect as f0}from"net";var e1=4319;function A0(Q,Z,$=400){return new Promise((Y)=>{let J=f0({host:Q,port:Z}),V=!1,q=(X)=>{if(V)return;V=!0,J.destroy(),Y(X)};J.once("connect",()=>q(!0)),J.once("error",()=>q(!1)),J.setTimeout($,()=>q(!1))})}async function E0(Q){for(let Z of["127.0.0.1","::1"])if(await A0(Z,Q))return!1;return!0}async function jZ(Q,Z=20){for(let $=Q;$<Q+Z;$++)if(await E0($))return $;return Q}import{execSync as MZ,spawn as _0}from"child_process";import{mkdirSync as S0,openSync as h0,readFileSync as m0,writeFileSync as p0}from"fs";import{homedir as c0,platform as CZ}from"os";import{dirname as l0,join as $Q}from"path";import{fileURLToPath as d0}from"url";import{createHash as n0}from"crypto";var GZ=1500,xZ=345600000,Z2=1800000,$2=3000;import{mkdirSync as O0,readFileSync as y0,writeFileSync as L0}from"fs";import{join as k0}from"path";var D0=["default","acceptEdits","bypassPermissions","auto"];function PZ(Q){return typeof Q==="string"&&D0.includes(Q)}function KZ(Q,Z){let $={behavior:"allow"};if(Q)$.updatedPermissions=[{type:"setMode",mode:Q,destination:"session"}];let Y={hookEventName:"PermissionRequest",decision:$};if(Z?.trim())Y.additionalContext=Z;return{hookSpecificOutput:Y}}function NZ(){return k0(j(),"preferences.json")}function fQ(){try{let Q=JSON.parse(y0(NZ(),"utf8"));return{planApprovalMode:PZ(Q.planApprovalMode)?Q.planApprovalMode:void 0,planApprovalModeConfigured:Q.planApprovalModeConfigured===!0,telemetryUuid:typeof Q.telemetryUuid==="string"?Q.telemetryUuid:void 0,telemetryEnabled:Q.telemetryEnabled===!1?!1:Q.telemetryEnabled===!0?!0:void 0}}catch{return{}}}function U2(Q){let Z={...fQ(),...Q};return O0(j(),{recursive:!0}),L0(NZ(),JSON.stringify(Z,null,2)),Z}function vZ(Q){if(!Q?.length)return"";let Z=Q.map((Y)=>Y.id?` \u2022 ${Y.title} \u2014 id: ${Y.id}`:` \u2022 ${Y.title}`),$=Q.some((Y)=>Y.id);return`
|
|
249
250
|
|
|
250
251
|
This plan created these roadmap feature(s):
|
|
251
252
|
`+Z.join(`
|
|
252
|
-
`)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` with a "+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}var
|
|
253
|
-
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",
|
|
253
|
+
`)+"\n\nWhen the work ships, register them in ONE call: `beacon_describe_feature` with a "+"`features` array \u2014 one entry per feature"+($?", each keyed by the `id` above (no title-matching needed)":"")+", each with the files you touched + a short markdown summary. Do them all in that single "+"batched call so every feature flips to Done \u2014 do NOT register only the umbrella, and do "+"NOT make one call per feature."}var a0=$Q(l0(d0(import.meta.url)),".."),EQ=process.env.BEACON_HOME||$Q(c0(),".beacon"),TZ=$Q(EQ,"server.json"),s0=process.env.PORT||"4319";function t0(Q){try{return process.kill(Q,0),!0}catch{return!1}}function r0(Q){try{return JSON.parse(m0(Q,"utf8"))}catch{return null}}async function gZ(Q){try{return(await fetch(Q)).ok}catch{return!1}}async function o0(Q,Z=60){for(let $=0;$<Z;$++){if(await gZ(Q))return!0;await new Promise((Y)=>setTimeout(Y,500))}return!1}function i0(Q){S0(EQ,{recursive:!0});let Z=h0($Q(EQ,"server.log"),"a"),$={...process.env,PORT:Q,BEACON_NO_OPEN:"1"};delete $.BEACON_REPO,delete $.BEACON_DATA_DIR,delete $.DATABASE_URL;let Y=_0("bun",["run","dev"],{cwd:a0,env:$,detached:!0,stdio:["ignore",Z,Z]});Y.unref();let J={pid:Y.pid??0,port:Q};return p0(TZ,JSON.stringify(J)),J}async function e0(){let Q=r0(TZ);if(Q&&t0(Q.pid)&&await gZ(`http://localhost:${Q.port}/api/workspace`))return Q.port;let Z=String(await jZ(Number(s0))),{port:$}=i0(Z);return await o0(`http://localhost:${$}/api/workspace`),$}function Q1(Q){if(process.env.BEACON_NO_OPEN)return;let Z=CZ()==="darwin"?"open":CZ()==="win32"?"start":"xdg-open";try{MZ(`${Z} "${Q}"`,{stdio:"ignore"})}catch{}}function Z1(){try{return MZ("git rev-parse --show-toplevel",{cwd:process.cwd(),stdio:["ignore","pipe","ignore"]}).toString().trim()}catch{return""}}function $1(Q){return n0("sha256").update(Q).digest("hex").slice(0,12)}async function Y1(){if(process.stdin.isTTY)return null;let Q=[];for await(let $ of process.stdin)Q.push($);let Z=Buffer.concat(Q).toString("utf8").trim();if(!Z)return null;try{return JSON.parse(Z)}catch{return null}}function AQ(Q,Z){return KZ(Q,Z)}function ZQ(Q){return{hookSpecificOutput:{hookEventName:"PermissionRequest",decision:{behavior:"deny",message:Q}}}}function N(Q){process.stdout.write(JSON.stringify(Q)),process.exit(0)}(async()=>{await oQ();let Z=(await Y1())?.tool_input?.plan;if(!Z||!Z.trim())N(AQ());let Y=`http://localhost:${await e0()}`,J=Z1()||process.cwd(),V=$1(J);await fetch(`${Y}/api/workspace/activate?id=${V}`).catch(()=>{});let q=Z.split(`
|
|
254
|
+
`,1)[0]?.replace(/^#+\s*/,"").slice(0,160)||"Plan review",X=await fetch(`${Y}/api/plan`,{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":V},body:JSON.stringify({description:q,markdown:Z})});if(X.status===422){let B=await X.json().catch(()=>({}));N(ZQ(B.error??"Beacon rejected the plan: every roadmap feature needs a category and a priority. Add them and re-present."))}if(!X.ok)N(AQ());if(!await fetch(`${Y}/api/plan/presence`,{headers:{"x-beacon-workspace":V}}).then((B)=>B.json()).then((B)=>!!B?.live).catch(()=>!1)){let B=encodeURIComponent(`/plan?ws=${V}`);Q1(`${Y}/api/workspace/activate?id=${V}&redirect=${B}`)}let W=Date.now()+xZ,M=(B)=>new Promise((YQ)=>setTimeout(YQ,B));while(Date.now()<W){await M(GZ);let B=await fetch(`${Y}/api/plan/verdict`,{headers:{"x-beacon-workspace":V}}).then((YQ)=>YQ.json()).catch(()=>null);if(!B)continue;if(B.kind==="approved")N(AQ(fQ().planApprovalMode,vZ(B.features)));if(B.kind==="discarded")N(ZQ("The user discarded the plan in Beacon. Ask what they want to adjust before re-presenting."));if(B.kind==="feedback")N(ZQ(`The user left feedback on the plan in Beacon (inline comments and/or edits on the /map and /db boards). Revise the plan based on the feedback below, then re-present (call ExitPlanMode again):
|
|
254
255
|
|
|
255
256
|
`+B.feedback))}N(ZQ("Beacon plan review timed out without a verdict. Re-present the plan and ask the user to review it."))})();
|
package/dist/bin/remove.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var g5=Object.defineProperty;var h5=(Z)=>Z;function b5(Z,$){this[Z]=h5.bind(null,$)}var wZ=(Z,$)=>{for(var Q in $)g5(Z,Q,{get:$[Q],enumerable:!0,configurable:!0,set:b5.bind($,Q)})};var K4=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var Y4={};wZ(Y4,{provisionDb:()=>t5});import{createClient as m5}from"@libsql/client";import{drizzle as p5}from"drizzle-orm/libsql";import{migrate as c5}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as l5}from"drizzle-orm/migrator";import{dirname as yZ,join as d5}from"path";import{fileURLToPath as n5}from"url";async function _Z(Z,$){return(await Z.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[$]})).rows.length>0}async function s5(Z,$){let Q=await Z.execute(`PRAGMA table_info("${$}")`);return new Set(Q.rows.map((J)=>String(J.name)))}async function X4(Z){if(!await _Z(Z,"__drizzle_migrations"))return 0;let $=await Z.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number($.rows[0]?.n??0)}async function a5(Z){for(let[$,Q]of Object.entries(i5)){if(!await _Z(Z,$))continue;let J=await s5(Z,$);for(let V of Q){if(!J.has(V))continue;await Z.execute(`UPDATE "${$}" SET "${V}" = CAST((julianday("${V}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${V}") = 'text'`)}}}async function t5(Z,$=o5){let Q=m5({url:Z});try{await Q.execute("PRAGMA journal_mode = WAL;"),await Q.execute("PRAGMA foreign_keys = ON;"),await Q.execute("PRAGMA busy_timeout = 5000;");let J=await _Z(Q,"__drizzle_migrations"),V=await _Z(Q,"Node"),K=!1;if(V&&!J){let X=l5({migrationsFolder:$})[0];if(X)await Q.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Q.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),K=!0}let Y=await X4(Q);if(await c5(p5(Q),{migrationsFolder:$}),await X4(Q)>Y)K=!0;return await a5(Q),{migrated:K}}finally{Q.close()}}var r5,o5,i5;var G4=K4(async()=>{r5=yZ(yZ(yZ(n5(import.meta.url)))),o5=process.env.BEACON_MIGRATIONS_DIR||d5(r5,"drizzle"),i5={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{mkdirSync as d7,renameSync as n7,rmSync as r7,writeFileSync as o7}from"fs";import{dirname as i7}from"path";function s7(Z,$){d7(i7(Z),{recursive:!0});let Q=`${Z}.tmp`;try{o7(Q,$),n7(Q,Z)}catch(J){throw r7(Q,{force:!0}),J}}function a7(Z,$,Q=!1){s7(Z,JSON.stringify($,null,Q?2:void 0))}var q5=()=>{};import{AsyncLocalStorage as e5}from"async_hooks";import{spawnSync as Z6}from"child_process";import{createHash as $6}from"crypto";import{existsSync as j4,mkdirSync as LZ,readFileSync as uZ,writeFileSync as xZ}from"fs";import{homedir as U4}from"os";import{basename as Q6,join as ZZ,parse as J6,resolve as M4}from"path";function a(){return process.env.BEACON_HOME||ZZ(U4(),".beacon")}function gZ(){return ZZ(a(),"workspaces.json")}function QZ(Z){return $6("sha256").update(Z).digest("hex").slice(0,12)}function hZ(Z=process.cwd()){let $=Z6("git",["rev-parse","--show-toplevel"],{cwd:Z,stdio:["ignore","pipe","ignore"]});if($.status===0){let Q=$.stdout?.toString().trim();if(Q)return Q}return Z}function H4(Z){let $=M4(Z);return $!==M4(U4())&&$!==J6($).root}function W4(){return ZZ(a(),"deleted.json")}function bZ(){try{let Z=JSON.parse(uZ(W4(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function L4(Z){LZ(a(),{recursive:!0}),xZ(W4(),JSON.stringify(Z,null,2))}function C4(Z){return bZ().includes(Z)}function B4(Z){let $=bZ();if(!$.includes(Z))L4([...$,Z])}function V6(Z){let $=bZ();if($.includes(Z))L4($.filter((Q)=>Q!==Z))}function n(Z){return ZZ(a(),Z)}function JZ(Z){return`file:${ZZ(n(Z),"db.sqlite")}`}function CZ(){try{let Z=JSON.parse(uZ(gZ(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function mZ(Z){LZ(a(),{recursive:!0}),xZ(gZ(),JSON.stringify(Z,null,2))}function pZ(){return CZ().sort((Z,$)=>$.lastOpenedAt.localeCompare(Z.lastOpenedAt))}function x(Z){return CZ().find(($)=>$.id===Z)??null}function N4(Z,$,Q=new Date().toISOString()){if(!H4(Z))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Z}`);let J=QZ(Z);if(C4(J))throw Error(`beacon: workspace ${J} (${Z}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let V=CZ(),K=V.find((j)=>j.id===J),Y={id:J,path:Z,name:$||K?.name||Q6(Z),lastOpenedAt:Q},X=[Y,...V.filter((j)=>j.id!==J)];return LZ(n(J),{recursive:!0}),mZ(X),Y}function y8(Z,$){return V6(QZ(Z)),N4(Z,$)}function f8(Z,$=new Date().toISOString()){let Q=CZ(),J=Q.find((V)=>V.id===Z);if(!J)return;J.lastOpenedAt=$,mZ(Q)}function q4(Z){if(mZ(CZ().filter(($)=>$.id!==Z)),r()===Z)K6(pZ()[0]?.id??null)}function O4(){return ZZ(a(),"active")}function r(){try{return uZ(O4(),"utf8").trim()||null}catch{return null}}function K6(Z){LZ(a(),{recursive:!0}),xZ(O4(),Z??"")}function X6(){let Z=r();return Z?x(Z):null}function u8(){let Z=DZ()??r();return Z?x(Z):null}function x8(Z){return x(Z)?.path??null}function g8(){return j4(gZ())}var A4="beacon_ws";function _4(Z,$){let Q=Z.headers.get("cookie");if(!Q)return null;for(let J of Q.split(";")){let V=J.indexOf("=");if(V===-1)continue;if(J.slice(0,V).trim()===$)return decodeURIComponent(J.slice(V+1).trim())}return null}function h8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=_4(Z,A4);if(Q&&x(Q))return Q;return null}var Y6="x-beacon-workspace-path";async function b8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=Z.headers.get(Y6);if(Q&&H4(Q)&&!C4(QZ(Q))&&(!$||QZ(Q)===$)){let V=N4(Q);return await cZ(V.id),V.id}let J=_4(Z,A4);if(J&&x(J))return J;return null}var D4=new e5;function G6(Z,$){return Z?D4.run(Z,$):$()}function DZ(){return D4.getStore()??null}var fZ=new Set;function F4(Z){fZ.delete(ZZ(n(Z),"db.sqlite"))}async function cZ(Z){let $=n(Z),Q=ZZ($,"db.sqlite"),J=j4(Q);if(J&&fZ.has(Q))return{ok:!0,created:!1,migrated:!1};try{LZ($,{recursive:!0});let{provisionDb:V}=await G4().then(() => Y4),K=await V(JZ(Z));return fZ.add(Q),{ok:!0,created:!J,migrated:J&&K.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{existsSync as N8,readFileSync as q8}from"fs";import{resolve as w5}from"path";import{rmSync as B8}from"fs";import{drizzle as k6}from"drizzle-orm/libsql";import{createClient as T6}from"@libsql/client";var lZ={};wZ(lZ,{tag:()=>jZ,syncState:()=>s,projectMeta:()=>L6,note:()=>U6,nodeTags:()=>KZ,nodeFile:()=>BZ,node:()=>T,endpointTable:()=>o,endpoint:()=>v,edge:()=>VZ,draftTable:()=>c,draftRelation:()=>XZ,draftColumn:()=>qZ,dbTable:()=>I,dbRelation:()=>l,dbColumn:()=>e,codeFileEdge:()=>u,codeFile:()=>f,bugFlag:()=>NZ,boardAnnotation:()=>H6,appSetting:()=>W6});import{sqliteTable as w,index as k,foreignKey as M6,text as W,integer as z,real as b,uniqueIndex as t,primaryKey as j6}from"drizzle-orm/sqlite-core";import{createId as h}from"@paralleldrive/cuid2";var T=w("Node",{id:W().primaryKey().$defaultFn(()=>h()),view:W().notNull(),kind:W().default("FEATURE").notNull(),cluster:W(),layer:W(),title:W().notNull(),role:W(),plain:W(),status:W().default("PENDING").notNull(),priority:z().default(2).notNull(),progress:z().default(0).notNull(),x:b().default(0).notNull(),y:b().default(0).notNull(),sourceRef:W(),externalId:W(),source:W().default("MANUAL").notNull(),planId:W(),parentId:W(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Node_cluster_idx").on(Z.cluster),k("Node_parentId_idx").on(Z.parentId),k("Node_view_idx").on(Z.view),M6(()=>({columns:[Z.parentId],foreignColumns:[Z.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),BZ=w("NodeFile",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),path:W().notNull()},(Z)=>[t("NodeFile_nodeId_path_key").on(Z.nodeId,Z.path),k("NodeFile_nodeId_idx").on(Z.nodeId)]),jZ=w("Tag",{id:W().primaryKey().$defaultFn(()=>h()),label:W().notNull(),color:W()},(Z)=>[t("Tag_label_key").on(Z.label)]),VZ=w("Edge",{id:W().primaryKey().$defaultFn(()=>h()),fromId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:W().default("DEPENDS").notNull(),label:W(),sourceHandle:W(),targetHandle:W()},(Z)=>[t("Edge_fromId_toId_kind_key").on(Z.fromId,Z.toId,Z.kind),k("Edge_toId_idx").on(Z.toId),k("Edge_fromId_idx").on(Z.fromId)]),KZ=w("_NodeTags",{a:W("A").notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),b:W("B").notNull().references(()=>jZ.id,{onDelete:"cascade",onUpdate:"cascade"})},(Z)=>[t("_NodeTags_AB_unique").on(Z.a,Z.b),k("_NodeTags_B_index").on(Z.b)]),U6=w("Note",{id:W().primaryKey().$defaultFn(()=>h()),title:W().default("Untitled").notNull(),body:W().default("").notNull(),ord:b().default(0).notNull(),pinned:z({mode:"boolean"}).default(!1).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Note_updatedAt_idx").on(Z.updatedAt)]),H6=w("BoardAnnotation",{id:W().primaryKey().$defaultFn(()=>h()),targetKind:W().notNull(),targetId:W().notNull(),columnName:W(),body:W().default("").notNull(),x:b(),y:b(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("BoardAnnotation_target_idx").on(Z.targetId)]),NZ=w("BugFlag",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),by:W().notNull(),note:W().notNull(),resolvedAt:z({mode:"timestamp_ms"}),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[k("BugFlag_nodeId_idx").on(Z.nodeId)]),I=w("DbTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("DbTable_domain_idx").on(Z.domain),t("DbTable_name_key").on(Z.name)]),e=w("DbColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[t("DbColumn_tableId_name_key").on(Z.tableId,Z.name),k("DbColumn_tableId_idx").on(Z.tableId)]),l=w("DbRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DbRelation_toTableId_idx").on(Z.toTableId),k("DbRelation_fromTableId_idx").on(Z.fromTableId)]),v=w("Endpoint",{id:W().primaryKey().$defaultFn(()=>h()),method:W().notNull(),path:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[t("Endpoint_method_path_key").on(Z.method,Z.path),k("Endpoint_domain_idx").on(Z.domain)]),o=w("EndpointTable",{id:W().primaryKey().$defaultFn(()=>h()),endpointId:W().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),access:W().default("read").notNull()},(Z)=>[t("EndpointTable_endpointId_tableId_key").on(Z.endpointId,Z.tableId),k("EndpointTable_tableId_idx").on(Z.tableId)]),c=w("DraftTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[t("DraftTable_name_key").on(Z.name)]),qZ=w("DraftColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[k("DraftColumn_tableId_idx").on(Z.tableId)]),XZ=w("DraftRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DraftRelation_toTableId_idx").on(Z.toTableId),k("DraftRelation_fromTableId_idx").on(Z.fromTableId)]),f=w("CodeFile",{path:W().primaryKey(),root:W(),lang:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),mtimeMs:b(),size:z(),inDegree:z().default(0).notNull(),outDegree:z().default(0).notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=w("CodeFileEdge",{fromPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:z({mode:"boolean"}).default(!1).notNull()},(Z)=>[k("CodeFileEdge_circular_idx").on(Z.circular),k("CodeFileEdge_toPath_idx").on(Z.toPath),k("CodeFileEdge_fromPath_idx").on(Z.fromPath),j6({columns:[Z.fromPath,Z.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),s=w("SyncState",{id:W().primaryKey().default("singleton"),version:z().default(0).notNull(),codeGraphSyncedAt:z({mode:"timestamp_ms"}),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),W6=w("AppSetting",{id:W().primaryKey().default("singleton"),editor:W().default("auto").notNull(),currentFeatureId:W(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),L6=w("ProjectMeta",{id:W().primaryKey().default("singleton"),overview:W(),conventions:W().default("[]").notNull(),hasFrontend:z({mode:"boolean"}),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var dZ={};wZ(dZ,{tagRelations:()=>q6,nodeTagsRelations:()=>O6,nodeRelations:()=>C6,nodeFileRelations:()=>B6,endpointTableRelations:()=>E6,endpointRelations:()=>z6,edgeRelations:()=>A6,draftTableRelations:()=>I6,draftRelationRelations:()=>R6,draftColumnRelations:()=>P6,dbTableRelations:()=>_6,dbRelationRelations:()=>F6,dbColumnRelations:()=>D6,codeFileRelations:()=>S6,codeFileEdgeRelations:()=>v6,bugFlagRelations:()=>N6});import{relations as g}from"drizzle-orm";var C6=g(T,({one:Z,many:$})=>({files:$(BZ),bugFlags:$(NZ),nodeTags:$(KZ),edgesOut:$(VZ,{relationName:"EdgeFrom"}),edgesIn:$(VZ,{relationName:"EdgeTo"}),parent:Z(T,{fields:[T.parentId],references:[T.id],relationName:"NodeTree"}),children:$(T,{relationName:"NodeTree"})})),B6=g(BZ,({one:Z})=>({node:Z(T,{fields:[BZ.nodeId],references:[T.id]})})),N6=g(NZ,({one:Z})=>({node:Z(T,{fields:[NZ.nodeId],references:[T.id]})})),q6=g(jZ,({many:Z})=>({nodeTags:Z(KZ)})),O6=g(KZ,({one:Z})=>({node:Z(T,{fields:[KZ.a],references:[T.id]}),tag:Z(jZ,{fields:[KZ.b],references:[jZ.id]})})),A6=g(VZ,({one:Z})=>({from:Z(T,{fields:[VZ.fromId],references:[T.id],relationName:"EdgeFrom"}),to:Z(T,{fields:[VZ.toId],references:[T.id],relationName:"EdgeTo"})})),_6=g(I,({many:Z})=>({columns:Z(e),fksOut:Z(l,{relationName:"FkFrom"}),fksIn:Z(l,{relationName:"FkTo"}),usages:Z(o)})),D6=g(e,({one:Z})=>({table:Z(I,{fields:[e.tableId],references:[I.id]})})),F6=g(l,({one:Z})=>({fromTable:Z(I,{fields:[l.fromTableId],references:[I.id],relationName:"FkFrom"}),toTable:Z(I,{fields:[l.toTableId],references:[I.id],relationName:"FkTo"})})),z6=g(v,({many:Z})=>({tables:Z(o)})),E6=g(o,({one:Z})=>({endpoint:Z(v,{fields:[o.endpointId],references:[v.id]}),table:Z(I,{fields:[o.tableId],references:[I.id]})})),I6=g(c,({many:Z})=>({columns:Z(qZ),fksOut:Z(XZ,{relationName:"DraftFkFrom"}),fksIn:Z(XZ,{relationName:"DraftFkTo"})})),P6=g(qZ,({one:Z})=>({table:Z(c,{fields:[qZ.tableId],references:[c.id]})})),R6=g(XZ,({one:Z})=>({fromTable:Z(c,{fields:[XZ.fromTableId],references:[c.id],relationName:"DraftFkFrom"}),toTable:Z(c,{fields:[XZ.toTableId],references:[c.id],relationName:"DraftFkTo"})})),S6=g(f,({many:Z})=>({edgesOut:Z(u,{relationName:"CFEFrom"}),edgesIn:Z(u,{relationName:"CFETo"})})),v6=g(u,({one:Z})=>({fromFile:Z(f,{fields:[u.fromPath],references:[f.path],relationName:"CFEFrom"}),toFile:Z(f,{fields:[u.toPath],references:[f.path],relationName:"CFETo"})}));var w6={...lZ,...dZ};function y6(){let Z=process.env.DATABASE_URL;if(Z&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test(Z))return Z;return"file:./dev.db"}var f6=y6();function z4(Z){let $=T6({url:Z});return $.execute("PRAGMA foreign_keys = ON;"),$.execute("PRAGMA busy_timeout = 5000;"),k6($,{schema:w6})}var rZ=globalThis,nZ=rZ.dzDefault??z4(f6);rZ.dzDefault=nZ;var FZ=rZ.dzByUrl??=new Map;function oZ(Z){let $=FZ.get(Z);if(!$)$=z4(Z),FZ.set(Z,$);return $}function E4(Z){let $=FZ.get(Z);FZ.delete(Z);try{$?.$client?.close?.()}catch{}}function u6(){if(process.env.BEACON_REPO)return nZ;let Z=DZ()??r();if(!Z)return nZ;return oZ(JZ(Z))}var m=new Proxy({},{get(Z,$){let Q=u6(),J=Q[$];return typeof J==="function"?J.bind(Q):J}});import{existsSync as W8}from"fs";import{existsSync as R5,readFileSync as Y8,watch as G8}from"fs";import{readFile as P5}from"fs/promises";import{join as AZ,relative as M8,resolve as j8}from"path";import{existsSync as c4,readFileSync as l4}from"fs";import{readdir as W7,readFile as L7,stat as d4}from"fs/promises";import{extname as n4,join as PZ,relative as HZ,resolve as UZ}from"path";import{extname as g4}from"path";import{dirname as x6,resolve as g6}from"path";var iZ=[".ts",".tsx",".js",".jsx",".mjs",".cjs"],h6=[/(?:^|[\n;])\s*(?:import|export)[^'"`\n]{0,4000}?from\s*['"]([^'"`]+)['"]/g,/(?:^|[\n;])\s*import\s*['"]([^'"`]+)['"]/g,/\brequire\(\s*['"]([^'"`]+)['"]\s*\)/g,/\bimport\(\s*['"]([^'"`]+)['"]\s*\)/g];function b6(Z){return Z.split(/[\\/]/).join("/")}function I4(Z,$){if($.has(Z))return Z;for(let Q of iZ){let J=`${Z}${Q}`;if($.has(J))return J}for(let Q of iZ){let J=`${Z}/index${Q}`;if($.has(J))return J}return null}function m6(Z){let $=new Set;for(let Q of h6)for(let J of Z.matchAll(Q))$.add(J[1]);return $}function p6(Z,$,Q,J){if(Z.startsWith(".")){let V=g6("/",x6($),Z),K=b6(V).replace(/^\//,"");return I4(K,Q)}for(let V of J)if(Z.startsWith(V.from)){let K=Z.slice(V.from.length),Y=V.to?`${V.to}/${K}`:K,X=I4(Y,Q);if(X)return X}return null}var P4={id:"ts",extensions:iZ,specifiers:m6,resolve(Z,$,Q){let J=p6(Z,$,Q.fileSet,Q.tsAliases??[]);return J?[J]:[]}};import{dirname as zZ,join as c6,normalize as l6}from"path";var d6=[".py",".pyi"],R4=[/(?:^|[\n;])\s*from\s+(\.*[\w.]*)\s+import\b/g,/(?:^|[\n;])\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/g];function S4(Z,$){for(let Q of[`${Z}.py`,`${Z}/__init__.py`,`${Z}.pyi`])if($.has(Q))return[Q];return[]}function n6(Z){let $=new Set;for(let Q of Z.matchAll(R4[0])){let J=Q[1].trim();if(J)$.add(J)}for(let Q of Z.matchAll(R4[1]))for(let J of Q[1].split(/\s*,\s*/)){let V=J.trim().split(/\s+as\s+/)[0].trim();if(V)$.add(V)}return $}var v4={id:"python",extensions:d6,specifiers:n6,resolve(Z,$,Q){if(Z.startsWith(".")){let Y=Z.length-Z.replace(/^\.+/,"").length,X=Z.slice(Y),j=zZ($);for(let M=1;M<Y;M++)j=zZ(j);let B=X?c6(j,X.replace(/\./g,"/")):j;return S4(l6(B).replace(/\\/g,"/"),Q.fileSet)}let J=Z.replace(/\./g,"/"),V=[],K=zZ($);while(K&&K!=="."&&K!=="/")V.push(K),K=zZ(K);V.push("");for(let Y of V){let X=S4(Y?`${Y}/${J}`:J,Q.fileSet);if(X.length)return X}return[]}};import{dirname as r6}from"path";var o6=[".go"],i6=/(?:^|[\n;])\s*import\s+(?:[\w.]+\s+)?"([^"]+)"/g,s6=/(?:^|[\n;])\s*import\s*\(([\s\S]*?)\)/g,a6=/"([^"]+)"/g;function t6(Z){let $=new Set;for(let Q of Z.matchAll(i6))$.add(Q[1]);for(let Q of Z.matchAll(s6))for(let J of Q[1].matchAll(a6))$.add(J[1]);return $}var k4={id:"go",extensions:o6,resolve(Z,$,Q){let J=Q.goModulePath;if(!J)return[];let V=null;if(Z===J)V="";else if(Z.startsWith(`${J}/`))V=Z.slice(J.length+1);if(V===null)return[];let K=[];for(let Y of Q.fileSet){if(!Y.endsWith(".go"))continue;let X=r6(Y);if(V===""&&X==="."||X===V)K.push(Y)}return K.sort()},specifiers:t6};import{basename as T4,dirname as sZ,join as w4,normalize as y4}from"path";var e6=[".rs"],Z7=/(?:^|[\n;])\s*(?:pub\s+)?mod\s+(\w+)\s*;/g,$7=/(?:^|[\n;])\s*(?:pub\s+)?use\s+([\w:]+)/g;function Q7(Z){let $=Z.split("::").filter((Q)=>Q&&Q!=="*");if(!$.length)return"";if($[0]==="crate")return["crate",...$.slice(1)].join("/");if($[0]==="super")return["..",...$.slice(1)].join("/");if($[0]==="self")return[".",...$.slice(1)].join("/");return $.join("/")}function aZ(Z,$){for(let Q of[`${Z}.rs`,`${Z}/mod.rs`])if($.has(Q))return[Q];return[]}var J7=new Set(["mod.rs","lib.rs","main.rs"]);function V7(Z){let $=new Set;for(let Q of Z.matchAll(Z7))$.add(`./${Q[1]}`);for(let Q of Z.matchAll($7)){let J=Q7(Q[1]);if(J)$.add(J)}return $}var f4={id:"rust",extensions:e6,specifiers:V7,resolve(Z,$,Q){let J=Q.fileSet;if(Z.startsWith("./")||Z.startsWith("../")){let V=Z.replace(/^\.\//,""),K=y4(w4(sZ($),Z)).replace(/\\/g,"/"),Y=aZ(K,J);if(Y.length)return Y;if(Z.startsWith("./")&&!J7.has(T4($))){let X=w4(sZ($),T4($,".rs"),V);if(Y=aZ(y4(X).replace(/\\/g,"/"),J),Y.length)return Y}return[]}if(Z.startsWith("crate/")){let V=$.split("/"),K=V.lastIndexOf("src"),Y=K>=0?V.slice(0,K+1).join("/"):sZ($),X=Z.slice(6).split("/");for(let j of[X.join("/"),X.slice(0,-1).join("/")]){if(!j)continue;let B=aZ(`${Y}/${j}`,J);if(B.length)return B}return[]}return[]}};import{dirname as K7,extname as X7,join as Y7,normalize as G7}from"path";var u4=[".swift",".java",".rb",".kt",".kts",".cs",".php",".scala",".c",".h",".cpp",".hpp",".cc",".hh",".m",".mm",".ex",".exs",".lua",".dart",".vue",".svelte"],M7=[/\b(?:require_relative|require|include|import|use|using|from)\s*\(?\s*['"]([^'"`\n]+)['"]/g,/(?:^|[\n;])\s*import\s+([\w.]+)/g,/(?:^|[\n;])\s*from\s+([\w.]+)\s+import\b/g,/(?:^|[\n;])\s*using\s+([\w.]+)\s*;/g,/(?:^|[\n;])\s*use\s+([\w\\]+)/g,/#\s*include\s*[<"]([^>"\n]+)[>"]/g];function j7(Z){let $=new Set;for(let Q of M7)for(let J of Z.matchAll(Q)){let V=J[1].trim();if(V)$.add(V)}return $}var x4={id:"fallback",extensions:u4,specifiers:j7,resolve(Z,$,Q){let V=[X7($).toLowerCase(),...u4].filter((j,B,M)=>j&&M.indexOf(j)===B),K=Z.includes("/")||Z.includes("\\"),Y=Z.startsWith(".")||K?Z.replace(/\\/g,"/"):Z.replace(/[.:]+/g,"/"),X=[G7(Y7(K7($),Y)).replace(/\\/g,"/"),Y.replace(/^\.\//,"")];for(let j of X){if(Q.fileSet.has(j))return[j];for(let B of V){let M=j.endsWith(B)?j:`${j}${B}`;if(Q.fileSet.has(M))return[M];if(Q.fileSet.has(`${j}/index${B}`))return[`${j}/index${B}`]}}return[]}};var U7=[P4,v4,k4,f4,x4],EZ=new Map;for(let Z of U7)for(let $ of Z.extensions)EZ.set($,Z);var H7={".ts":"ts",".tsx":"ts",".js":"js",".jsx":"js",".mjs":"js",".cjs":"js",".py":"py",".pyi":"py",".go":"go",".rs":"rs",".swift":"swift",".java":"java",".rb":"ruby",".kt":"kotlin",".kts":"kotlin",".cs":"csharp",".php":"php",".scala":"scala",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cc":"cpp",".hh":"cpp",".m":"objc",".mm":"objc",".ex":"elixir",".exs":"elixir",".lua":"lua",".dart":"dart",".vue":"vue",".svelte":"svelte"};function tZ(Z){return EZ.get(g4(Z).toLowerCase())??null}function h4(Z){let $=g4(Z).toLowerCase();if(!EZ.has($))return null;return H7[$]??$.slice(1)}function eZ(){return new Set(EZ.keys())}var r4=new Set(["node_modules",".git",".next","dist","build","__pycache__","target",".venv","venv","env",".turbo","coverage",".beacon",".playwright-mcp","generated","migrations","drizzle","alembic","migrate"]);function C7(Z=5){let $=performance.now();return async()=>{if(performance.now()-$>Z)await new Promise((Q)=>setImmediate(Q)),$=performance.now()}}var B7=()=>Promise.resolve();async function o4(Z,$,Q,J,V){let K;try{K=await W7($,{withFileTypes:!0})}catch{return}for(let Y of K){if(Y.name.startsWith("."))continue;if(r4.has(Y.name))continue;let X=PZ($,Y.name);if(Y.isDirectory()){await o4(Z,X,Q,J,V);continue}if(!Y.isFile())continue;if(Y.name.endsWith(".d.ts"))continue;if(!Q.has(n4(Y.name).toLowerCase()))continue;J.push(HZ(Z,X))}await V()}async function N7(Z,$=B7){let Q=[];return await o4(Z,Z,eZ(),Q,$),Q.map((J)=>J.split(/[\\/]/).join("/")).sort()}function q7(Z){try{return JSON.parse(Z)}catch{}let $=Z.replace(/\/\*[^"]*?\*\//g,"").replace(/(^|[^:"])\/\/.*$/gm,"$1").replace(/,\s*([}\]])/g,"$1");return JSON.parse($)}function b4(Z){return Z.replace(/^\.\/?/,"").replace(/\/$/,"")}function i4(Z){let $=PZ(Z,"tsconfig.json");if(!c4($))return[];let Q;try{Q=q7(l4($,"utf8"))}catch{return[]}let J=Q.compilerOptions?.paths??{},V=b4(Q.compilerOptions?.baseUrl??"."),K=[];for(let[Y,X]of Object.entries(J)){if(!Y.endsWith("/*")||!X.length)continue;let j=X[0];if(!j.endsWith("/*"))continue;let B=Y.slice(0,-1),M=b4(j.slice(0,-1)),L=[V,M].filter(Boolean).join("/");K.push({from:B,to:L})}return K}function IZ(Z){let $=PZ(Z,"go.mod");if(!c4($))return null;try{let Q=/^\s*module\s+(\S+)/m.exec(l4($,"utf8"));return Q?Q[1]:null}catch{return null}}function p(Z){return Z.split(/[\\/]/).join("/")}function s4(Z){if(Z.length===1)return Z[0];let $=Z.map((V)=>p(V).split("/")),Q=$[0],J=0;for(;J<Q.length;J++)if(!$.every((V)=>V[J]===Q[J]))break;return Q.slice(0,J).join("/")||"/"}async function O7(Z,$,Q){let J=(Array.isArray(Z)?Z:[Z]).map((B)=>p(UZ(B))),V=p($?UZ($):J.length===1?J[0]:s4(J)),K=new Map,Y=[];for(let B of J){let M=p(HZ(V,B));for(let L of i4(B))Y.push({from:L.from,to:[M,L.to].filter(Boolean).join("/")});for(let L of await N7(B,Q)){let C=p(PZ(B,L)),q=p(HZ(V,C));if(K.has(q))continue;try{let U=await d4(C);K.set(q,{path:q,abs:C,root:M||null,mtimeMs:U.mtimeMs,size:U.size})}catch{}await Q()}}let X=J.map(IZ).find(Boolean)??IZ(V);return{metas:[...K.values()].sort((B,M)=>B.path.localeCompare(M.path)),ctx:{fileSet:new Set(K.keys()),tsAliases:Y,goModulePath:X}}}var m4=50000;function A7(Z){let $=0;for(let Q=0;Q<Z.length;Q++)if(Z.charCodeAt(Q)===10){if(Q-$>m4)return!0;$=Q+1}return Z.length-$>m4}async function p4(Z){let $=tZ(Z.path);if(!$||Z.size>200000)return new Set;try{let Q=await L7(Z.abs,"utf8");if(A7(Q))return new Set;return $.specifiers(Q)}catch{return new Set}}function a4(Z,$){let Q=(Array.isArray(Z)?Z:[Z]).map((U)=>p(UZ(U))),J=p($?UZ($):Q.length===1?Q[0]:s4(Q)),V=new Map,K=new Map,Y=[],X=null;function j(){Y=[];for(let U of Q){let H=p(HZ(J,U));for(let O of i4(U))Y.push({from:O.from,to:[H,O.to].filter(Boolean).join("/")})}X=Q.map(IZ).find(Boolean)??IZ(J)}function B(U){let H=U.split("/");for(let A=0;A<H.length;A++){let N=H[A];if(!N||N.startsWith("."))return!0;if(A<H.length-1&&r4.has(N))return!0}let O=H[H.length-1];if(O.endsWith(".d.ts"))return!0;return!eZ().has(n4(O).toLowerCase())}function M(U){let H=p(UZ(U));for(let O of Q)if(H===O||H.startsWith(`${O}/`)){let A=H.slice(O.length).replace(/^\/+/,"");if(B(A))return null;return{path:p(HZ(J,H)),root:p(HZ(J,O))||null}}return null}function L(){let U={fileSet:new Set(V.keys()),tsAliases:Y,goModulePath:X},H=[...V.values()].sort((N,G)=>N.path.localeCompare(G.path)),O=[];for(let N of H){let G=tZ(N.path);if(!G)continue;let _=K.get(N.path)??new Set,D=new Set;for(let R of _)for(let y of G.resolve(R,N.path,U)){if(!y||y===N.path||D.has(y))continue;D.add(y),O.push({from:N.path,to:y})}}return{files:H.map((N)=>({path:N.path,lang:h4(N.path),root:N.root,mtimeMs:N.mtimeMs,size:N.size})),edges:O}}async function C(){let U=C7(),{metas:H,ctx:O}=await O7(Z,$,U);V.clear(),K.clear();for(let A of H)await U(),V.set(A.path,A),K.set(A.path,await p4(A));return Y=O.tsAliases??[],X=O.goModulePath??null,L()}async function q(U){let H=p(UZ(U));if(!Q.some((D)=>H===D||H.startsWith(`${D}/`)))return!1;let O=H.split("/").pop()??"";if(O==="tsconfig.json"||O==="go.mod"){let D=H.slice(0,H.length-O.length-1);if(Q.includes(D))return j(),!0;return!1}let A=M(U);if(!A)return!1;let N;try{N=await d4(H)}catch{let D=V.delete(A.path);return K.delete(A.path),D}let G=V.get(A.path);if(G&&G.mtimeMs===N.mtimeMs&&G.size===N.size)return!1;let _={path:A.path,abs:H,root:A.root,mtimeMs:N.mtimeMs,size:N.size};return V.set(A.path,_),K.set(A.path,await p4(_)),!0}return{seed:C,applyChange:q,snapshot:L}}function t4(Z){let $=Object.keys(Z.tableVars),Q=new Map;if(!$.length){for(let Y of Z.routeFiles)Q.set(Y,[]);return Q}let J=new Map;for(let Y of Z.edges){let X=J.get(Y.from)??[];X.push(Y.to),J.set(Y.from,X)}let V=new Map($.map((Y)=>[Y,new RegExp(`(?:query\\.${Y}\\b|\\.from\\(\\s*${Y}\\b)`)])),K=new Map($.map((Y)=>[Y,new RegExp(`(?:insert|update|delete)\\(\\s*${Y}\\b`)]));for(let Y of Z.routeFiles){let X=new Set([Y]),j=[Y];for(let C=0;C<2&&X.size<25;C++){let q=[];for(let U of j)for(let H of J.get(U)??[]){if(X.has(H)||X.size>=25)continue;X.add(H),q.push(H)}j=q}let B=new Set,M=new Set;for(let C of X){let q=Z.content(C);if(!q)continue;for(let U of $){if(!B.has(U)&&V.get(U).test(q))B.add(U);if(!M.has(U)&&K.get(U).test(q))M.add(U)}}let L=[];for(let C of $){let q=B.has(C),U=M.has(C);if(!q&&!U)continue;L.push({table:Z.tableVars[C],access:q&&U?"read-write":U?"write":"read"})}Q.set(Y,L)}return Q}function e4(Z,$){if(/_JSON_OR_JSONB|\bJSONB\b|\bJSON\b/.test(Z))return"jsonb";let Q=Z.match(/\b(GUID|Uuid|UUID|String|Text|DateTime|Date|Time|BigInteger|SmallInteger|Integer|Boolean|Float|Numeric|Decimal|Vector|TSVECTOR|LargeBinary|Enum)\b\s*(\([^)]*\))?/);if(Q){let K=Q[2]??"",Y=K.match(/\d+/)?.[0];switch(Q[1]){case"GUID":case"Uuid":case"UUID":return"uuid";case"String":return Y?`varchar(${Y})`:"varchar";case"Text":return"text";case"DateTime":return/timezone\s*=\s*True/.test(K)?"timestamptz":"timestamp";case"Date":return"date";case"Time":return"time";case"BigInteger":return"bigint";case"SmallInteger":return"smallint";case"Integer":return"integer";case"Boolean":return"boolean";case"Float":return"float";case"Numeric":case"Decimal":return"numeric";case"Vector":return Y?`vector(${Y})`:"vector";case"TSVECTOR":return"tsvector";case"LargeBinary":return"bytea";case"Enum":return"varchar"}}let J=$.replace(/\s*\|\s*None/g,"").trim(),V=J.match(/^Optional\[([\s\S]*)\]$/);if(V)J=V[1].trim();if(/uuid/i.test(J))return"uuid";if(/datetime/i.test(J))return"timestamptz";if(/\bint\b/i.test(J))return"integer";if(/\bbool\b/i.test(J))return"boolean";if(/\bfloat\b/.test(J)&&!/\blist\b/.test(J))return"float";if(/\bdict\b|\blist\b|\bAny\b/.test(J))return"jsonb";return"text"}function RZ(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="(")Q++;else if(Z[J]===")"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function _7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="[")Q++;else if(Z[J]==="]"){if(Q--,Q===0)return Z.slice($+1,J)}return null}function D7(Z,$,Q){let J=Q.match(/__tablename__\s*=\s*["']([^"']+)["']/)?.[1],V=[],K=[],Y=[],X=/(\w+)\s*:\s*Mapped\s*\[/g,j;while(j=X.exec(Q)){let L=j.index+j[0].length-1,C=_7(Q,L);if(C===null)continue;let q=L+C.length+2,U=Q.slice(q).match(/^\s*=\s*(\w+)\s*\(/);if(!U||U[1]!=="mapped_column")continue;Y.push({colName:j[1],pyType:C,argsAt:q+U[0].length-1})}let B=/(\w+)\s*=\s*(mapped_column|Column)\s*\(/g;while(j=B.exec(Q))Y.push({colName:j[1],pyType:"",argsAt:j.index+j[0].length-1});Y.sort((L,C)=>L.argsAt-C.argsAt);let M=new Set;for(let L of Y){if(M.has(L.colName)||L.colName==="__tablename__")continue;M.add(L.colName);let C=RZ(Q,L.argsAt),q=/primary_key\s*=\s*True/.test(C)||void 0,U=/nullable\s*=\s*False/.test(C)?!1:!0,H=C.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(V.push({name:L.colName,type:e4(C,L.pyType),isPk:q,isFk:H?!0:void 0,nullable:U}),H)K.push({column:L.colName,toTable:H[1],toColumn:H[2]})}return{name:Z,bases:$,tableName:J,columns:V,fks:K}}function F7(Z){let $=[],Q=[],J=/\bTable\s*(\()\s*["']([^"']+)["']\s*,/g,V;while(V=J.exec(Z)){let K=V[2],Y=RZ(Z,V.index+V[0].indexOf("("));if(!/\bmetadata\b/.test(Y)||!/\bColumn\s*\(/.test(Y))continue;let X=[],j=/\bColumn\s*\(/g,B;while(B=j.exec(Y)){let M=RZ(Y,B.index+B[0].length-1),L=M.match(/^\s*["'](\w+)["']\s*,/)?.[1];if(!L)continue;let C=/primary_key\s*=\s*True/.test(M)||void 0,q=/nullable\s*=\s*False/.test(M)?!1:!0,U=M.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(X.push({name:L,type:e4(M,""),isPk:C,isFk:U?!0:void 0,nullable:q}),U)Q.push({fromTable:K,fromColumn:L,toTable:U[1],toColumn:U[2]})}if(X.length)$.push({name:K,columns:X})}return{tables:$,relations:Q}}function z7(Z){let $=new Map,Q={tables:[],relations:[]};for(let X of Z){if(!X.path.endsWith(".py"))continue;if(!/mapped_column\s*\(|__tablename__|\bTable\s*\(\s*["']/.test(X.content))continue;let j=F7(X.content);Q.tables.push(...j.tables),Q.relations.push(...j.relations);let B=/^class\s+(\w+)\s*\(([^)]*)\)\s*:/gm,M,L=[];while(M=B.exec(X.content))L.push({name:M[1],bases:M[2].split(",").map((C)=>C.trim().split(/[.[]/)[0]).filter(Boolean),at:M.index});for(let C=0;C<L.length;C++){let q=X.content.slice(L[C].at,L[C+1]?.at??X.content.length),U=D7(L[C].name,L[C].bases,q);$.set(U.name,U)}}if(![...$.values()].some((X)=>X.tableName)&&!Q.tables.length)return{tables:[],relations:[]};let J=(X,j=new Set)=>{if(j.has(X.name))return[];j.add(X.name);let B=[];for(let M of X.bases){let L=$.get(M);if(L&&!L.tableName)B.push(...J(L,j))}return B.push(...X.columns),B},V=[],K=[];for(let X of $.values()){if(!X.tableName)continue;let j=J(X),B=new Map;for(let U of j)if(!B.has(U.name))B.set(U.name,U);let M=[...B.values()],L=(U)=>M.splice(M.findIndex((H)=>H.name===U),1)[0],C=M.some((U)=>U.name==="id")?L("id"):null,q=["created_at","updated_at","deleted_at"].filter((U)=>M.some((H)=>H.name===U)).map((U)=>L(U));V.push({name:X.tableName,columns:[...C?[C]:[],...M,...q]});for(let U of X.fks)K.push({fromTable:X.tableName,fromColumn:U.column,toTable:U.toTable,toColumn:U.toColumn})}let Y=new Set(V.map((X)=>X.name));for(let X of Q.tables)if(!Y.has(X.name))V.push(X);return K.push(...Q.relations.filter((X)=>!Y.has(X.fromTable))),{tables:V,relations:K}}function E7(Z){let $=Z.replace(/[?[\]]/g,"");return{String:"text",Int:"integer",BigInt:"bigint",Float:"float",Decimal:"numeric",Boolean:"boolean",DateTime:"timestamptz",Json:"jsonb",Bytes:"bytea"}[$]??$.toLowerCase()}function I7(Z){let $=[],Q=[];for(let J of Z){if(!J.path.endsWith(".prisma"))continue;let V=/model\s+(\w+)\s*\{([\s\S]*?)\}/g,K;while(K=V.exec(J.content)){let Y=K[1],X=K[2].match(/@@map\(\s*["']([^"']+)["']\s*\)/)?.[1]??Y,j=[];for(let B of K[2].split(`
|
|
4
|
-
`)){let M=B.trim().match(/^(\w+)\s+(\w+(?:\[\])?\??)\s*(.*)$/);if(!M||/^@@/.test(B.trim()))continue;let[,L,C,q]=M,U=/^(String|Int|BigInt|Float|Decimal|Boolean|DateTime|Json|Bytes)(\[\])?\??$/.test(C),H=q.match(/@relation\([^)]*fields:\s*\[(\w+)\][^)]*references:\s*\[(\w+)\]/);if(H)Q.push({fromTable:X,fromColumn:H[1],toTable:C.replace(/[?[\]]/g,""),toColumn:H[2]});if(!U)continue;j.push({name:L,type:E7(C),isPk:/@id\b/.test(q)||void 0,isFk:/@relation\b/.test(q)||void 0,nullable:C.endsWith("?")})}if(j.length)$.push({name:X,columns:j})}}return{tables:$,relations:Q}}function P7(Z,$){if(/mode:\s*["']timestamp/.test($))return"timestamp";if(/mode:\s*["']boolean["']/.test($))return"boolean";if(/mode:\s*["']json["']/.test($))return"jsonb";return Z}function R7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="{")Q++;else if(Z[J]==="}"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function S7(Z){let $=[],Q=/(\w+)\s*:\s*(text|integer|real|blob|numeric|varchar|boolean|timestamp|serial|uuid|json|jsonb)\s*\(/g;for(let K of Z){if(!/\.(ts|tsx|mts|cts)$/.test(K.path))continue;if(!/\b(?:sqliteTable|pgTable|mysqlTable)\s*\(/.test(K.content))continue;let Y=/(?:export\s+)?const\s+(\w+)\s*=\s*(?:sqliteTable|pgTable|mysqlTable)\s*\(\s*["']([^"']+)["']\s*,/g,X;while(X=Y.exec(K.content)){let j=K.content.indexOf("{",X.index+X[0].length);if(j<0)continue;let B=R7(K.content,j),M={varName:X[1],tableName:X[2],columns:[],colByProp:new Map,fks:[]},L=[];Q.lastIndex=0;for(let C of B.matchAll(Q))L.push({prop:C[1],builder:C[2],at:C.index,argOpen:C.index+C[0].length-1});L.forEach((C,q)=>{let U=B.slice(C.at,L[q+1]?.at??B.length),H=RZ(B,C.argOpen),A=H.match(/^\s*["']([^"']+)["']/)?.[1]??C.prop,N=U.match(/\.references\(\s*\(\)\s*=>\s*(\w+)\.(\w+)/);if(M.columns.push({name:A,type:P7(C.builder,H),isPk:/\.primaryKey\(\)/.test(U)||void 0,isFk:N?!0:void 0,nullable:/\.notNull\(\)/.test(U)?!1:!0}),M.colByProp.set(C.prop,A),N)M.fks.push({column:A,toVar:N[1],toProp:N[2]})}),$.push(M)}}if(!$.length)return{tables:[],relations:[]};let J=new Map($.map((K)=>[K.varName,K])),V=[];for(let K of $)for(let Y of K.fks){let X=J.get(Y.toVar);if(!X)continue;V.push({fromTable:K.tableName,fromColumn:Y.column,toTable:X.tableName,toColumn:X.colByProp.get(Y.toProp)??Y.toProp})}return{tables:$.map((K)=>({name:K.tableName,columns:K.columns})),relations:V,tableVars:Object.fromEntries($.map((K)=>[K.varName,K.tableName]))}}function Z5(Z){let $=S7(Z);if($.tables.length)return $;let Q=I7(Z);if(Q.tables.length)return Q;return z7(Z)}var v7=["GET","POST","PUT","PATCH","DELETE"];function k7(Z){let $=Z.match(/(?:^|\/)app\/(.+)\/route\.(?:ts|tsx|js|jsx|mjs)$/);if(!$)return null;let Q=$[1].split("/").filter((J)=>!(J.startsWith("(")&&J.endsWith(")"))).map((J)=>{let V=J.match(/^\[{1,2}(?:\.\.\.)?([^\]]+)\]{1,2}$/);return V?`{${V[1]}}`:J});if(Q[0]!=="api")return null;return`/${Q.join("/")}`}function $5(Z){let $=[];for(let Q of Z){let J=k7(Q.path);if(!J)continue;for(let V of v7)if(new RegExp(`export\\s+(?:async\\s+)?(?:function|const)\\s+${V}\\b`).test(Q.content))$.push({method:V,path:J,uses:[],file:Q.path})}return $.sort((Q,J)=>`${Q.path} ${Q.method}`.localeCompare(`${J.path} ${J.method}`))}var T7=/(^|\/)app\/.*\/route\.(ts|tsx|js|jsx|mjs)$/,w7=/\.(ts|py)$/,y7=/(schema|model)/i;function Z4(Z){if(Z.endsWith(".prisma"))return!0;if(T7.test(Z))return!0;return w7.test(Z)&&y7.test(Z)}function Q5(Z,$=300){return Z.filter(Z4).slice(0,$)}import{z as d}from"zod";import{and as D5,eq as WZ,inArray as J8,notInArray as V8}from"drizzle-orm";import{z as E}from"zod";import{and as t7,eq as kZ,inArray as Q4,notInArray as e7,or as Z8,sql as $8}from"drizzle-orm";var J5=240,V5=50;function K5(Z){for(let $=0;$<Z.length;$++)for(let Q=$+1;Q<Z.length;Q++){let J=Z[$],V=Z[Q];if(J.x<V.x+J5&&J.x+J5>V.x&&J.y<V.y+V5&&J.y+V5>V.y)return!0}return!1}import{eq as f7}from"drizzle-orm";var X5=(Z)=>Z.replace(/\{[^}]*\}/g,"{}");function u7(Z,$){if(Z.method.toUpperCase()!==$.method.toUpperCase())return!1;let Q=X5(Z.path),J=X5($.path);return J===Q||J.endsWith(Q)}async function Y5(Z=m){let[$,Q]=await Promise.all([Z.query.endpoint.findMany({where:(V,{ne:K})=>K(V.source,"INTROSPECTION")}),Z.query.endpoint.findMany({where:(V,{eq:K})=>K(V.source,"INTROSPECTION")})]),J={collapsed:0,mappings:[]};for(let V of $){let K=Q.find((Y)=>u7(V,Y));if(!K)continue;await Z.delete(v).where(f7(v.id,V.id)),J.collapsed++,J.mappings.push({planned:`${V.method} ${V.path}`,code:`${K.method} ${K.path}`})}return J}import{and as G5,inArray as x7,isNull as M5,ne as j5,or as g7}from"drizzle-orm";var h7=new Set(["DONE","CANCELLED","DEPRIORITIZED"]);async function b7(Z){let $=await Z.query.node.findMany({where:(J,{and:V,eq:K,isNotNull:Y})=>V(K(J.view,"ROADMAP"),Y(J.planId)),columns:{planId:!0,status:!0}}),Q=new Map;for(let J of $){let V=J.planId;Q.set(V,(Q.get(V)??!0)&&h7.has(J.status))}return[...Q.entries()].filter(([,J])=>J).map(([J])=>J)}async function U5(Z=m){let $=await b7(Z),Q=(K)=>$.length?g7(M5(K.planId),x7(K.planId,$)):M5(K.planId),J=await Z.delete(I).where(G5(j5(I.source,"INTROSPECTION"),Q(I))).returning({id:I.id}),V=await Z.delete(v).where(G5(j5(v.source,"INTROSPECTION"),Q(v))).returning({id:v.id});return{tables:J.length,endpoints:V.length}}var W5=320;function $Z(Z){return 36+Math.max(0,Z)*30+16}var YZ=60,m7=280,SZ=14,H5=120,OZ=170,p7=2560;var vZ=(Z)=>(Z??"").trim()||"\u2014";function c7(Z,$,Q){let J=new Map;for(let K of Z.uses){if(!$.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}let V=null;for(let[K,Y]of J){if(V===null){V=K;continue}let X=J.get(V);if(Y>X){V=K;continue}if(Y<X)continue;let j=Q?.get(K)??0,B=Q?.get(V)??0;if(j<B)V=K;else if(j===B&&$.get(K).localeCompare($.get(V))<0)V=K}return V}function $4(Z,$){let Q=new Map(Z.map((V)=>[V.id,V.name])),J=new Map;for(let V of $)for(let K of V.uses){if(!Q.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}return new Map($.map((V)=>[V.id,c7(V,Q,J)]))}var l7=(Z,$)=>Z.path.localeCompare($.path)||Z.method.localeCompare($.method)||Z.id.localeCompare($.id);function L5(Z,$){let Q=$4(Z,$),J=new Map,V=[];for(let N of[...$].sort(l7)){let G=Q.get(N.id)??null;if(G){let _=J.get(G);if(_)_.push(N);else J.set(G,[N])}else V.push(N)}let K=(N)=>{let G=J.get(N.id)?.length??0;return $Z(N.columnCount)+(G?SZ+G*YZ:0)+50},Y=Array.from(new Set(Z.map((N)=>vZ(N.domain)))),X=Y.filter((N)=>N!=="\u2014").sort(),j=Y.includes("\u2014")?[...X,"\u2014"]:X,B=[];for(let N of j){let G=Z.filter((S)=>vZ(S.domain)===N).sort((S,P)=>S.name.localeCompare(P.name)),_=G.reduce((S,P)=>S+K(P),0),D=Math.max(1,Math.min(12,G.length,Math.round(Math.sqrt(_/320)))),R=Array(D).fill(0),y=new Map;for(let S of G){let P=0;for(let F=1;F<D;F++)if(R[F]<R[P])P=F;y.set(S.id,{x:P*320,y:R[P]}),R[P]+=K(S)}B.push({d:N,w:D*320,h:Math.max(...R,0),tableLocal:y})}let M=B.reduce((N,G)=>N+(G.w+H5)*(G.h+OZ),0),L=Math.max(p7,Math.round(Math.sqrt(M*2.2))),C=new Map,q=new Map,U=0,H=0,O=0,A=0;for(let N of B){if(U>0&&U+N.w>L)H+=O+OZ,U=0,O=0;let G=Z.filter((_)=>N.tableLocal.has(_.id));for(let _ of G){let D=N.tableLocal.get(_.id),R=U+D.x,y=H+D.y;C.set(_.id,{x:R,y}),(J.get(_.id)??[]).forEach((P,F)=>{q.set(P.id,{x:R,y:y+$Z(_.columnCount)+SZ+F*YZ})})}O=Math.max(O,N.h),A=Math.max(A,H+N.h),U+=N.w+H5}if(V.length){let N=A+OZ,G=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(V.length/2))));V.forEach((_,D)=>{q.set(_.id,{x:D%G*m7,y:N+Math.floor(D/G)*YZ})})}return{tables:C,endpoints:q}}function C5(Z,$,Q){let J=$4($,Q),V=new Map;for(let q of Q){let U=J.get(q.id);if(U)V.set(U,(V.get(U)??0)+1)}let K=(q)=>{let U=V.get(q.id)??0;return q.y+$Z(q.columnCount)+(U?SZ+U*YZ:0)},Y=vZ(Z.domain),X=$.filter((q)=>vZ(q.domain)===Y);if(!X.length){let q=$.length?Math.max(...$.map(K),...Q.map((U)=>U.y+YZ)):0;return{x:0,y:$.length||Q.length?q+OZ:0}}let j=Math.min(...X.map((q)=>q.x)),B=X.map((q)=>Math.max(0,Math.round((q.x-j)/320))),M=Math.min(12,Math.max(...B)+1),L=Array(M).fill(Math.min(...X.map((q)=>q.y)));X.forEach((q,U)=>{let H=Math.min(B[U],M-1);L[H]=Math.max(L[H],K(q)+50)});let C=0;for(let q=1;q<M;q++)if(L[q]<L[C])C=q;return{x:j+C*320,y:L[C]}}function B5(Z,$,Q){let J=$4($,[...Q,Z]),V=J.get(Z.id),K=V?$.find((X)=>X.id===V):void 0;if(K){let X=Q.filter((M)=>J.get(M.id)===K.id),j=K.y+$Z(K.columnCount)+SZ,B=X.length?Math.max(...X.map((M)=>M.y))+YZ:j;return{x:K.x,y:B}}let Y=[...$.map((X)=>X.y+$Z(X.columnCount)),...Q.map((X)=>X.y+YZ)];return{x:0,y:Y.length?Math.max(...Y)+OZ:0}}function N5(Z){let $=W5-20;for(let Q=0;Q<Z.length;Q++)for(let J=Q+1;J<Z.length;J++){let V=Z[Q],K=Z[J],Y=$Z(V.columnCount),X=$Z(K.columnCount);if(V.x<K.x+$&&V.x+$>K.x&&V.y<K.y+X&&V.y+Y>K.y)return!0}return!1}import{eq as O5}from"drizzle-orm";q5();async function A5(Z=m){let[$,Q]=await Promise.all([Z.query.dbTable.findMany({with:{columns:{columns:{id:!0}}},orderBy:(K,{asc:Y})=>Y(K.name)}),Z.query.endpoint.findMany({with:{tables:{columns:{tableId:!0}}}})]),J=L5($.map((K)=>({id:K.id,name:K.name,domain:K.domain,columnCount:K.columns.length})),Q.map((K)=>({id:K.id,method:K.method,path:K.path,uses:K.tables.map((Y)=>({tableId:Y.tableId}))}))),V=0;for(let K of $){let Y=J.tables.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(I).set({x:Y.x,y:Y.y}).where(O5(I.id,K.id)),V++}for(let K of Q){let Y=J.endpoints.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(v).set({x:Y.x,y:Y.y}).where(O5(v.id,K.id)),V++}return V}var Q8=E.object({tables:E.array(E.object({name:E.string().trim().min(1),domain:E.string().nullish(),description:E.string().nullish(),columns:E.array(E.object({name:E.string().trim().min(1),type:E.string().trim().min(1),isPk:E.boolean().optional(),isFk:E.boolean().optional(),nullable:E.boolean().optional(),note:E.string().nullish()})).default([])})).default([]),relations:E.array(E.object({fromTable:E.string(),fromColumn:E.string(),toTable:E.string(),toColumn:E.string(),label:E.string().nullish()})).default([]),endpoints:E.array(E.object({method:E.string().trim().min(1),path:E.string().trim().min(1),domain:E.string().nullish(),description:E.string().nullish(),uses:E.array(E.object({table:E.string(),access:E.string().default("read")})).default([])})).default([])});async function TZ(Z=m){let[$]=await Z.insert(s).values({id:"singleton",version:1}).onConflictDoUpdate({target:s.id,set:{version:$8`${s.version} + 1`}}).returning();return $.version}async function _5(Z,$=m,Q={}){let J=Q8.parse(Z),V=J.tables.length>0,K=J.endpoints.length>0,Y=J.tables.map((G)=>G.name);if(V)await $.delete(I).where(Y.length?t7(kZ(I.source,"INTROSPECTION"),e7(I.name,Y)):kZ(I.source,"INTROSPECTION"));let X=await $.query.dbTable.findMany({columns:{id:!0,name:!0,domain:!0,x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),j=await $.query.endpoint.findMany({columns:{id:!0,method:!0,path:!0,x:!0,y:!0},with:{tables:{columns:{tableId:!0}}}}),B=new Map(X.map((G)=>[G.name,G])),M=X.map((G)=>({id:G.id,name:G.name,domain:G.domain,columnCount:G.columns.length,x:G.x,y:G.y})),L=j.map((G)=>({id:G.id,method:G.method,path:G.path,uses:G.tables.map((_)=>({tableId:_.tableId})),x:G.x,y:G.y})),C=new Map;for(let G of J.tables){if(B.has(G.name))continue;let _=C5({domain:G.domain??null,columnCount:G.columns.length},M,L);C.set(G.name,_),M.push({id:`new:${G.name}`,name:G.name,domain:G.domain??null,columnCount:G.columns.length,..._})}let q=new Map;for(let G of J.tables){let _=B.get(G.name),D=C.get(G.name),R=_?.x??D?.x??0,y=_?.y??D?.y??0,[S]=await $.insert(I).values({name:G.name,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:R,y}).onConflictDoUpdate({target:I.name,set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(q.set(G.name,S.id),await $.delete(e).where(kZ(e.tableId,S.id)),G.columns.length)await $.insert(e).values(G.columns.map((P,F)=>({tableId:S.id,name:P.name,type:P.type,isPk:P.isPk??!1,isFk:P.isFk??!1,nullable:P.nullable??!0,note:P.note??null,ord:F})))}let U=[...q.values()];if(U.length)await $.delete(l).where(Z8(Q4(l.fromTableId,U),Q4(l.toTableId,U)));for(let G of J.relations){let _=q.get(G.fromTable),D=q.get(G.toTable);if(!_||!D)continue;await $.insert(l).values({fromTableId:_,toTableId:D,fromColumn:G.fromColumn,toColumn:G.toColumn,label:G.label??`${G.fromColumn} \u2192 ${G.toTable}.${G.toColumn}`})}let H=new Set(J.endpoints.map((G)=>`${G.method} ${G.path}`));if(K){let _=(await $.query.endpoint.findMany({where:(D,{eq:R})=>R(D.source,"INTROSPECTION")})).filter((D)=>!H.has(`${D.method} ${D.path}`)).map((D)=>D.id);if(_.length)await $.delete(v).where(Q4(v.id,_))}for(let G of M)if(G.id.startsWith("new:"))G.id=q.get(G.name)??G.id;for(let G of J.endpoints){let _=await $.query.endpoint.findFirst({where:(S,{and:P,eq:F})=>P(F(S.method,G.method),F(S.path,G.path))}),D,R;if(_)D=_.x,R=_.y;else{let S={id:`new:${G.method} ${G.path}`,method:G.method,path:G.path,uses:G.uses.map((F)=>({tableId:q.get(F.table)??""})).filter((F)=>F.tableId)},P=B5(S,M,L);D=P.x,R=P.y,L.push({...S,x:D,y:R})}let[y]=await $.insert(v).values({method:G.method,path:G.path,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:D,y:R}).onConflictDoUpdate({target:[v.method,v.path],set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(!Q.partial||G.uses.length>0)await $.delete(o).where(kZ(o.endpointId,y.id));for(let S of G.uses){let P=q.get(S.table)??(await $.query.dbTable.findFirst({where:(F,{eq:MZ})=>MZ(F.name,S.table)}))?.id;if(!P)continue;await $.insert(o).values({endpointId:y.id,tableId:P,access:S.access})}}await Y5($),await U5($);let O=await $.query.dbTable.findMany({where:(G,{eq:_})=>_(G.source,"INTROSPECTION"),columns:{x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),A=await $.select({x:v.x,y:v.y}).from(v);if(N5(O.map((G)=>({x:G.x,y:G.y,columnCount:G.columns.length})))||K5(A))await A5($);let N=await TZ($);return{tables:J.tables.length,relations:J.relations.length,endpoints:J.endpoints.length,version:N}}var F5=d.object({files:d.array(d.object({path:d.string().trim().min(1),root:d.string().nullish(),lang:d.string().nullish(),mtimeMs:d.number().nullish(),size:d.number().nullish()})).default([]),edges:d.array(d.object({from:d.string().trim().min(1),to:d.string().trim().min(1)})).default([])});function z5(Z,$){let Q=new Map;for(let C of Z)Q.set(C,[]);for(let C of $)Q.get(C.from)?.push(C.to);let J=new Map,V=new Map,K=new Set,Y=[],X=new Map,j=[],B=0,M=0;for(let C of Z){if(J.has(C))continue;let q=[{v:C,iter:0}];J.set(C,B),V.set(C,B),B++,Y.push(C),K.add(C);while(q.length){let U=q[q.length-1],H=Q.get(U.v)??[];if(U.iter<H.length){let O=H[U.iter++];if(!J.has(O))J.set(O,B),V.set(O,B),B++,Y.push(O),K.add(O),q.push({v:O,iter:0});else if(K.has(O))V.set(U.v,Math.min(V.get(U.v),J.get(O)))}else{if(V.get(U.v)===J.get(U.v)){let A=0,N;do N=Y.pop(),K.delete(N),X.set(N,M),A++;while(N!==U.v);j.push(A),M++}q.pop();let O=q[q.length-1];if(O)V.set(O.v,Math.min(V.get(O.v),V.get(U.v)))}}}let L=new Set;for(let C of $){let q=X.get(C.from);if(q!==void 0&&q===X.get(C.to)&&j[q]>1)L.add(`${C.from}|${C.to}`)}return L}async function E5(Z,$=m){let Q=F5.parse(Z),J=Q.files.map((L)=>L.path),V=new Set(J),K=Q.edges.filter((L)=>V.has(L.from)&&V.has(L.to)&&L.from!==L.to),Y=z5(J,K),X=new Map,j=new Map;for(let L of K)j.set(L.from,(j.get(L.from)??0)+1),X.set(L.to,(X.get(L.to)??0)+1);await $.delete(f).where(V8(f.path,J));for(let L of Q.files){let C={root:L.root??null,lang:L.lang??null,mtimeMs:L.mtimeMs??null,size:L.size??null,inDegree:X.get(L.path)??0,outDegree:j.get(L.path)??0};await $.insert(f).values({path:L.path,...C}).onConflictDoUpdate({target:f.path,set:C})}await $.delete(u);let B=0;if(K.length)await $.insert(u).values(K.map((L)=>{let C=Y.has(`${L.from}|${L.to}`);if(C)B++;return{fromPath:L.from,toPath:L.to,circular:C}}));let M=await TZ($);return await $.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton")),{files:Q.files.length,edges:K.length,circular:B,version:M}}var K8=(Z,$)=>`${Z}\x00${$}`;function J4(Z){let $=F5.parse(Z),Q=$.files.map((M)=>M.path),J=new Set(Q),V=$.edges.filter((M)=>J.has(M.from)&&J.has(M.to)&&M.from!==M.to),K=z5(Q,V),Y=new Map,X=new Map;for(let M of V)X.set(M.from,(X.get(M.from)??0)+1),Y.set(M.to,(Y.get(M.to)??0)+1);let j=new Map;for(let M of $.files)j.set(M.path,{root:M.root??null,lang:M.lang??null,mtimeMs:M.mtimeMs??null,size:M.size??null,inDegree:Y.get(M.path)??0,outDegree:X.get(M.path)??0});let B=new Map;for(let M of V)B.set(K8(M.from,M.to),{from:M.from,to:M.to,circular:K.has(`${M.from}|${M.to}`)});return{files:j,edges:B}}var X8=(Z,$)=>Z.root===$.root&&Z.lang===$.lang&&Z.mtimeMs===$.mtimeMs&&Z.size===$.size&&Z.inDegree===$.inDegree&&Z.outDegree===$.outDegree;async function I5(Z,$,Q=m){for(let[X,j]of $.files){let B=Z.files.get(X);if(B&&X8(B,j))continue;let M={root:j.root,lang:j.lang,mtimeMs:j.mtimeMs,size:j.size,inDegree:j.inDegree,outDegree:j.outDegree};await Q.insert(f).values({path:X,...M}).onConflictDoUpdate({target:f.path,set:M})}let J=[...Z.files.keys()].filter((X)=>!$.files.has(X));if(J.length)await Q.delete(f).where(J8(f.path,J));for(let[X,j]of Z.edges)if(!$.edges.has(X))await Q.delete(u).where(D5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)));let V=[];for(let[X,j]of $.edges){let B=Z.edges.get(X);if(!B)V.push({fromPath:j.from,toPath:j.to,circular:j.circular});else if(B.circular!==j.circular)await Q.update(u).set({circular:j.circular}).where(D5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)))}if(V.length)await Q.insert(u).values(V);let K=await TZ(Q);await Q.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton"));let Y=0;for(let X of $.edges.values())if(X.circular)Y++;return{files:$.files.size,edges:$.edges.size,circular:Y,version:K}}var U8=/[/\\](node_modules|\.git|\.next|dist|build|__pycache__|target|\.venv|venv|\.beacon|\.playwright-mcp|generated|coverage)[/\\]/;function H8(Z){try{let $=AZ(Z,"beacon.config.json");if(R5($)){let Q=JSON.parse(Y8($,"utf8"));if(Array.isArray(Q.roots)&&Q.roots.length)return Q.roots.map((J)=>j8(Z,J))}}catch{}return[Z]}function S5(Z){let $=H8(Z.path),Q=cZ(Z.id),J=oZ(JZ(Z.id)),V=a4($,Z.path);async function K(){let H=Q5(V.snapshot().files.map((_)=>_.path));for(let _ of $)for(let D of["prisma/schema.prisma","schema.prisma"]){let R=AZ(_,D);if(R5(R))H.push(Y(R))}let O=[];for(let _ of H)try{O.push({path:_,content:await P5(AZ(Z.path,_),"utf8")})}catch{}let A=Z5(O),N=$5(O);if(!A.tables.length&&!N.length)return;if(N.length&&A.tableVars&&Object.keys(A.tableVars).length){let D=V.snapshot().edges,R=new Set(N.map((F)=>F.file)),y=new Map;for(let F of D){let MZ=y.get(F.from)??[];MZ.push(F.to),y.set(F.from,MZ)}for(let F=0;F<2;F++)for(let MZ of[...R])for(let x5 of y.get(MZ)??[])R.add(x5);let S=new Map;for(let F of[...R].slice(0,600))try{S.set(F,await P5(AZ(Z.path,F),"utf8"))}catch{}let P=t4({routeFiles:[...new Set(N.map((F)=>F.file))],edges:D,content:(F)=>S.get(F)??null,tableVars:A.tableVars});for(let F of N)F.uses=P.get(F.file)??[]}let G=await _5({tables:A.tables,relations:A.relations,endpoints:N},J,{partial:!0});console.log(`[beacon-inline] schema synced (${Z.name}): ${G.tables} tables / ${G.endpoints} endpoints`)}function Y(H){return M8(Z.path,H).split(/[\\/]/).join("/")}let X=null,j=!1,B=new Set,M=null,L=!1;async function C(){if(L){q();return}L=!0;try{if(await Q,j)X=null,j=!1;if(X===null){let N=await V.seed(),G=await E5(N,J);X=J4(N),console.log(`[beacon-inline] code-graph synced (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`),await K();return}let H=[...B];B.clear();let O=H.some((N)=>Z4(Y(N))),A=!1;for(let N of H)if(await V.applyChange(N))A=!0;if(A){let N=J4(V.snapshot()),G=await I5(X,N,J);X=N,console.log(`[beacon-inline] code-graph updated (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`)}if(O)await K()}catch(H){console.error(`[beacon-inline] error (${Z.name}):`,H instanceof Error?H.message:H)}finally{L=!1}}function q(){if(M)clearTimeout(M);M=setTimeout(C,600)}let U=[];for(let H of $)try{let O=G8(H,{recursive:!0,persistent:!0},(A,N)=>{if(!N){j=!0,q();return}let G=String(N);if(U8.test(`/${G}`))return;B.add(AZ(H,G)),q()});O.on("error",(A)=>console.error(`[beacon-inline] watcher error (${Z.name}):`,A)),U.push(O)}catch(O){console.error(`[beacon-inline] live watch unavailable for ${H} (${Z.name}):`,O instanceof Error?O.message:O)}return console.log(`[beacon-inline] watching ${Z.name} (${$.join(", ")}) \u2014 initial extract\u2026`),C(),{async stop(){if(M)clearTimeout(M);for(let H of U)H.close()}}}function L8(Z){let $=Z.limit??6,Q=Z.hardCap??12,J=new Map,V=0,K=new Set;function Y(H){let O=J.get(H);if(O)O.seq=++V}function X(H){if(J.has(H.id))return Y(H.id);if(!Z.exists(H.path))return;J.set(H.id,{handle:Z.start(H),seq:++V})}function j(){let H=null,O=1/0;for(let[A,N]of J){if(K.has(A))continue;if(N.seq<O)O=N.seq,H=A}if(H)J.get(H).handle.stop(),J.delete(H)}function B(){let H=Z.list().filter((O)=>Z.exists(O.path)).slice(0,$);K=new Set(H.map((O)=>O.id));for(let O of H)X(O);for(let[O,A]of[...J]){let N=Z.get(O);if(!N||!Z.exists(N.path))A.handle.stop(),J.delete(O)}}function M(H){if(J.has(H))return Y(H);let O=Z.get(H);if(!O||!Z.exists(O.path))return;if(J.size>=Q)j();if(J.size>=Q)return;J.set(H,{handle:Z.start(O),seq:++V})}async function L(H){let O=J.get(H);if(!O)return;J.delete(H),await O.handle.stop()}function C(H){return J.has(H)}function q(){return[...J.keys()]}async function U(){await Promise.all([...J.values()].map((H)=>H.handle.stop())),J.clear()}return{reconcile:B,ensureWatcher:M,stopWatcher:L,isWatching:C,activeIds:q,stopAll:U}}var C8=L8({list:pZ,get:x,exists:W8,start:(Z)=>S5(Z)});async function v5(Z){await C8.stopWatcher(Z)}async function k5(Z){if(!x(Z))return{ok:!1,removed:!1,fallbackId:r(),error:"unknown workspace"};q4(Z),B4(Z),await v5(Z),E4(JZ(Z)),F4(Z);try{B8(n(Z),{recursive:!0,force:!0})}catch($){return{ok:!1,removed:!0,fallbackId:r(),error:$ instanceof Error?$.message:String($)}}return{ok:!0,removed:!0,fallbackId:r()}}var V4=process.argv.slice(3),y5=V4.includes("--yes")||V4.includes("-y"),GZ=V4.find((Z)=>!Z.startsWith("-")),T5=(Z)=>`\x1B[32m\u2713\x1B[0m ${Z}`,f5=(Z)=>`\x1B[2m${Z}\x1B[0m`,u5=(Z)=>`
|
|
3
|
+
var g5=Object.defineProperty;var h5=(Z)=>Z;function b5(Z,$){this[Z]=h5.bind(null,$)}var wZ=(Z,$)=>{for(var Q in $)g5(Z,Q,{get:$[Q],enumerable:!0,configurable:!0,set:b5.bind($,Q)})};var K4=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var Y4={};wZ(Y4,{provisionDb:()=>t5});import{createClient as m5}from"@libsql/client";import{drizzle as p5}from"drizzle-orm/libsql";import{migrate as c5}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as l5}from"drizzle-orm/migrator";import{dirname as yZ,join as d5}from"path";import{fileURLToPath as n5}from"url";async function _Z(Z,$){return(await Z.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[$]})).rows.length>0}async function s5(Z,$){let Q=await Z.execute(`PRAGMA table_info("${$}")`);return new Set(Q.rows.map((J)=>String(J.name)))}async function X4(Z){if(!await _Z(Z,"__drizzle_migrations"))return 0;let $=await Z.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number($.rows[0]?.n??0)}async function a5(Z){for(let[$,Q]of Object.entries(i5)){if(!await _Z(Z,$))continue;let J=await s5(Z,$);for(let V of Q){if(!J.has(V))continue;await Z.execute(`UPDATE "${$}" SET "${V}" = CAST((julianday("${V}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${V}") = 'text'`)}}}async function t5(Z,$=o5){let Q=m5({url:Z});try{await Q.execute("PRAGMA journal_mode = WAL;"),await Q.execute("PRAGMA foreign_keys = ON;"),await Q.execute("PRAGMA busy_timeout = 5000;");let J=await _Z(Q,"__drizzle_migrations"),V=await _Z(Q,"Node"),K=!1;if(V&&!J){let X=l5({migrationsFolder:$})[0];if(X)await Q.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Q.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),K=!0}let Y=await X4(Q);if(await c5(p5(Q),{migrationsFolder:$}),await X4(Q)>Y)K=!0;return await a5(Q),{migrated:K}}finally{Q.close()}}var r5,o5,i5;var G4=K4(async()=>{r5=yZ(yZ(yZ(n5(import.meta.url)))),o5=process.env.BEACON_MIGRATIONS_DIR||d5(r5,"drizzle"),i5={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{mkdirSync as d7,renameSync as n7,rmSync as r7,writeFileSync as o7}from"fs";import{dirname as i7}from"path";function s7(Z,$){d7(i7(Z),{recursive:!0});let Q=`${Z}.tmp`;try{o7(Q,$),n7(Q,Z)}catch(J){throw r7(Q,{force:!0}),J}}function a7(Z,$,Q=!1){s7(Z,JSON.stringify($,null,Q?2:void 0))}var q5=()=>{};import{AsyncLocalStorage as e5}from"async_hooks";import{spawnSync as Z6}from"child_process";import{createHash as $6}from"crypto";import{existsSync as j4,mkdirSync as LZ,readFileSync as uZ,writeFileSync as xZ}from"fs";import{homedir as U4}from"os";import{basename as Q6,join as ZZ,parse as J6,resolve as M4}from"path";function a(){return process.env.BEACON_HOME||ZZ(U4(),".beacon")}function gZ(){return ZZ(a(),"workspaces.json")}function QZ(Z){return $6("sha256").update(Z).digest("hex").slice(0,12)}function hZ(Z=process.cwd()){let $=Z6("git",["rev-parse","--show-toplevel"],{cwd:Z,stdio:["ignore","pipe","ignore"]});if($.status===0){let Q=$.stdout?.toString().trim();if(Q)return Q}return Z}function H4(Z){let $=M4(Z);return $!==M4(U4())&&$!==J6($).root}function W4(){return ZZ(a(),"deleted.json")}function bZ(){try{let Z=JSON.parse(uZ(W4(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function L4(Z){LZ(a(),{recursive:!0}),xZ(W4(),JSON.stringify(Z,null,2))}function C4(Z){return bZ().includes(Z)}function B4(Z){let $=bZ();if(!$.includes(Z))L4([...$,Z])}function V6(Z){let $=bZ();if($.includes(Z))L4($.filter((Q)=>Q!==Z))}function n(Z){return ZZ(a(),Z)}function JZ(Z){return`file:${ZZ(n(Z),"db.sqlite")}`}function CZ(){try{let Z=JSON.parse(uZ(gZ(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function mZ(Z){LZ(a(),{recursive:!0}),xZ(gZ(),JSON.stringify(Z,null,2))}function pZ(){return CZ().sort((Z,$)=>$.lastOpenedAt.localeCompare(Z.lastOpenedAt))}function x(Z){return CZ().find(($)=>$.id===Z)??null}function N4(Z,$,Q=new Date().toISOString()){if(!H4(Z))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Z}`);let J=QZ(Z);if(C4(J))throw Error(`beacon: workspace ${J} (${Z}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let V=CZ(),K=V.find((j)=>j.id===J),Y={id:J,path:Z,name:$||K?.name||Q6(Z),lastOpenedAt:Q},X=[Y,...V.filter((j)=>j.id!==J)];return LZ(n(J),{recursive:!0}),mZ(X),Y}function y8(Z,$){return V6(QZ(Z)),N4(Z,$)}function f8(Z,$=new Date().toISOString()){let Q=CZ(),J=Q.find((V)=>V.id===Z);if(!J)return;J.lastOpenedAt=$,mZ(Q)}function q4(Z){if(mZ(CZ().filter(($)=>$.id!==Z)),r()===Z)K6(pZ()[0]?.id??null)}function O4(){return ZZ(a(),"active")}function r(){try{return uZ(O4(),"utf8").trim()||null}catch{return null}}function K6(Z){LZ(a(),{recursive:!0}),xZ(O4(),Z??"")}function X6(){let Z=r();return Z?x(Z):null}function u8(){let Z=FZ()??r();return Z?x(Z):null}function x8(Z){return x(Z)?.path??null}function g8(){return j4(gZ())}var A4="beacon_ws";function _4(Z,$){let Q=Z.headers.get("cookie");if(!Q)return null;for(let J of Q.split(";")){let V=J.indexOf("=");if(V===-1)continue;if(J.slice(0,V).trim()===$)return decodeURIComponent(J.slice(V+1).trim())}return null}function h8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=_4(Z,A4);if(Q&&x(Q))return Q;return null}var Y6="x-beacon-workspace-path";async function b8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=Z.headers.get(Y6);if(Q&&H4(Q)&&!C4(QZ(Q))&&(!$||QZ(Q)===$)){let V=N4(Q);return await cZ(V.id),V.id}let J=_4(Z,A4);if(J&&x(J))return J;return null}var F4=new e5;function G6(Z,$){return Z?F4.run(Z,$):$()}function FZ(){return F4.getStore()??null}var fZ=new Set;function D4(Z){fZ.delete(ZZ(n(Z),"db.sqlite"))}async function cZ(Z){let $=n(Z),Q=ZZ($,"db.sqlite"),J=j4(Q);if(J&&fZ.has(Q))return{ok:!0,created:!1,migrated:!1};try{LZ($,{recursive:!0});let{provisionDb:V}=await G4().then(() => Y4),K=await V(JZ(Z));return fZ.add(Q),{ok:!0,created:!J,migrated:J&&K.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{existsSync as N8,readFileSync as q8}from"fs";import{resolve as w5}from"path";import{rmSync as B8}from"fs";import{drizzle as k6}from"drizzle-orm/libsql";import{createClient as T6}from"@libsql/client";var lZ={};wZ(lZ,{tag:()=>jZ,syncState:()=>s,projectMeta:()=>L6,note:()=>U6,nodeTags:()=>KZ,nodeFile:()=>BZ,node:()=>T,endpointTable:()=>o,endpoint:()=>v,edge:()=>VZ,draftTable:()=>c,draftRelation:()=>XZ,draftColumn:()=>qZ,dbTable:()=>E,dbRelation:()=>l,dbColumn:()=>e,codeFileEdge:()=>u,codeFile:()=>f,bugFlag:()=>NZ,boardAnnotation:()=>H6,appSetting:()=>W6});import{sqliteTable as w,index as k,foreignKey as M6,text as W,integer as z,real as b,uniqueIndex as t,primaryKey as j6}from"drizzle-orm/sqlite-core";import{createId as h}from"@paralleldrive/cuid2";var T=w("Node",{id:W().primaryKey().$defaultFn(()=>h()),view:W().notNull(),kind:W().default("FEATURE").notNull(),cluster:W(),layer:W(),title:W().notNull(),role:W(),plain:W(),status:W().default("PENDING").notNull(),priority:z().default(2).notNull(),progress:z().default(0).notNull(),x:b().default(0).notNull(),y:b().default(0).notNull(),sourceRef:W(),externalId:W(),source:W().default("MANUAL").notNull(),planId:W(),parentId:W(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Node_cluster_idx").on(Z.cluster),k("Node_parentId_idx").on(Z.parentId),k("Node_view_idx").on(Z.view),M6(()=>({columns:[Z.parentId],foreignColumns:[Z.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),BZ=w("NodeFile",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),path:W().notNull()},(Z)=>[t("NodeFile_nodeId_path_key").on(Z.nodeId,Z.path),k("NodeFile_nodeId_idx").on(Z.nodeId)]),jZ=w("Tag",{id:W().primaryKey().$defaultFn(()=>h()),label:W().notNull(),color:W()},(Z)=>[t("Tag_label_key").on(Z.label)]),VZ=w("Edge",{id:W().primaryKey().$defaultFn(()=>h()),fromId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:W().default("DEPENDS").notNull(),label:W(),sourceHandle:W(),targetHandle:W()},(Z)=>[t("Edge_fromId_toId_kind_key").on(Z.fromId,Z.toId,Z.kind),k("Edge_toId_idx").on(Z.toId),k("Edge_fromId_idx").on(Z.fromId)]),KZ=w("_NodeTags",{a:W("A").notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),b:W("B").notNull().references(()=>jZ.id,{onDelete:"cascade",onUpdate:"cascade"})},(Z)=>[t("_NodeTags_AB_unique").on(Z.a,Z.b),k("_NodeTags_B_index").on(Z.b)]),U6=w("Note",{id:W().primaryKey().$defaultFn(()=>h()),title:W().default("Untitled").notNull(),body:W().default("").notNull(),ord:b().default(0).notNull(),pinned:z({mode:"boolean"}).default(!1).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Note_updatedAt_idx").on(Z.updatedAt)]),H6=w("BoardAnnotation",{id:W().primaryKey().$defaultFn(()=>h()),targetKind:W().notNull(),targetId:W().notNull(),columnName:W(),body:W().default("").notNull(),x:b(),y:b(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("BoardAnnotation_target_idx").on(Z.targetId)]),NZ=w("BugFlag",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),by:W().notNull(),note:W().notNull(),resolvedAt:z({mode:"timestamp_ms"}),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[k("BugFlag_nodeId_idx").on(Z.nodeId)]),E=w("DbTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("DbTable_domain_idx").on(Z.domain),t("DbTable_name_key").on(Z.name)]),e=w("DbColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[t("DbColumn_tableId_name_key").on(Z.tableId,Z.name),k("DbColumn_tableId_idx").on(Z.tableId)]),l=w("DbRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DbRelation_toTableId_idx").on(Z.toTableId),k("DbRelation_fromTableId_idx").on(Z.fromTableId)]),v=w("Endpoint",{id:W().primaryKey().$defaultFn(()=>h()),method:W().notNull(),path:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[t("Endpoint_method_path_key").on(Z.method,Z.path),k("Endpoint_domain_idx").on(Z.domain)]),o=w("EndpointTable",{id:W().primaryKey().$defaultFn(()=>h()),endpointId:W().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),access:W().default("read").notNull()},(Z)=>[t("EndpointTable_endpointId_tableId_key").on(Z.endpointId,Z.tableId),k("EndpointTable_tableId_idx").on(Z.tableId)]),c=w("DraftTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[t("DraftTable_name_key").on(Z.name)]),qZ=w("DraftColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[k("DraftColumn_tableId_idx").on(Z.tableId)]),XZ=w("DraftRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DraftRelation_toTableId_idx").on(Z.toTableId),k("DraftRelation_fromTableId_idx").on(Z.fromTableId)]),f=w("CodeFile",{path:W().primaryKey(),root:W(),lang:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),mtimeMs:b(),size:z(),inDegree:z().default(0).notNull(),outDegree:z().default(0).notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=w("CodeFileEdge",{fromPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:z({mode:"boolean"}).default(!1).notNull()},(Z)=>[k("CodeFileEdge_circular_idx").on(Z.circular),k("CodeFileEdge_toPath_idx").on(Z.toPath),k("CodeFileEdge_fromPath_idx").on(Z.fromPath),j6({columns:[Z.fromPath,Z.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),s=w("SyncState",{id:W().primaryKey().default("singleton"),version:z().default(0).notNull(),codeGraphSyncedAt:z({mode:"timestamp_ms"}),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),W6=w("AppSetting",{id:W().primaryKey().default("singleton"),editor:W().default("auto").notNull(),currentFeatureId:W(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),L6=w("ProjectMeta",{id:W().primaryKey().default("singleton"),overview:W(),conventions:W().default("[]").notNull(),hasFrontend:z({mode:"boolean"}),classificationRoots:W().default("[]").notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var dZ={};wZ(dZ,{tagRelations:()=>q6,nodeTagsRelations:()=>O6,nodeRelations:()=>C6,nodeFileRelations:()=>B6,endpointTableRelations:()=>P6,endpointRelations:()=>z6,edgeRelations:()=>A6,draftTableRelations:()=>E6,draftRelationRelations:()=>R6,draftColumnRelations:()=>I6,dbTableRelations:()=>_6,dbRelationRelations:()=>D6,dbColumnRelations:()=>F6,codeFileRelations:()=>S6,codeFileEdgeRelations:()=>v6,bugFlagRelations:()=>N6});import{relations as g}from"drizzle-orm";var C6=g(T,({one:Z,many:$})=>({files:$(BZ),bugFlags:$(NZ),nodeTags:$(KZ),edgesOut:$(VZ,{relationName:"EdgeFrom"}),edgesIn:$(VZ,{relationName:"EdgeTo"}),parent:Z(T,{fields:[T.parentId],references:[T.id],relationName:"NodeTree"}),children:$(T,{relationName:"NodeTree"})})),B6=g(BZ,({one:Z})=>({node:Z(T,{fields:[BZ.nodeId],references:[T.id]})})),N6=g(NZ,({one:Z})=>({node:Z(T,{fields:[NZ.nodeId],references:[T.id]})})),q6=g(jZ,({many:Z})=>({nodeTags:Z(KZ)})),O6=g(KZ,({one:Z})=>({node:Z(T,{fields:[KZ.a],references:[T.id]}),tag:Z(jZ,{fields:[KZ.b],references:[jZ.id]})})),A6=g(VZ,({one:Z})=>({from:Z(T,{fields:[VZ.fromId],references:[T.id],relationName:"EdgeFrom"}),to:Z(T,{fields:[VZ.toId],references:[T.id],relationName:"EdgeTo"})})),_6=g(E,({many:Z})=>({columns:Z(e),fksOut:Z(l,{relationName:"FkFrom"}),fksIn:Z(l,{relationName:"FkTo"}),usages:Z(o)})),F6=g(e,({one:Z})=>({table:Z(E,{fields:[e.tableId],references:[E.id]})})),D6=g(l,({one:Z})=>({fromTable:Z(E,{fields:[l.fromTableId],references:[E.id],relationName:"FkFrom"}),toTable:Z(E,{fields:[l.toTableId],references:[E.id],relationName:"FkTo"})})),z6=g(v,({many:Z})=>({tables:Z(o)})),P6=g(o,({one:Z})=>({endpoint:Z(v,{fields:[o.endpointId],references:[v.id]}),table:Z(E,{fields:[o.tableId],references:[E.id]})})),E6=g(c,({many:Z})=>({columns:Z(qZ),fksOut:Z(XZ,{relationName:"DraftFkFrom"}),fksIn:Z(XZ,{relationName:"DraftFkTo"})})),I6=g(qZ,({one:Z})=>({table:Z(c,{fields:[qZ.tableId],references:[c.id]})})),R6=g(XZ,({one:Z})=>({fromTable:Z(c,{fields:[XZ.fromTableId],references:[c.id],relationName:"DraftFkFrom"}),toTable:Z(c,{fields:[XZ.toTableId],references:[c.id],relationName:"DraftFkTo"})})),S6=g(f,({many:Z})=>({edgesOut:Z(u,{relationName:"CFEFrom"}),edgesIn:Z(u,{relationName:"CFETo"})})),v6=g(u,({one:Z})=>({fromFile:Z(f,{fields:[u.fromPath],references:[f.path],relationName:"CFEFrom"}),toFile:Z(f,{fields:[u.toPath],references:[f.path],relationName:"CFETo"})}));var w6={...lZ,...dZ};function y6(){let Z=process.env.DATABASE_URL;if(Z&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test(Z))return Z;return"file:./dev.db"}var f6=y6();function z4(Z){let $=T6({url:Z});return $.execute("PRAGMA foreign_keys = ON;"),$.execute("PRAGMA busy_timeout = 5000;"),k6($,{schema:w6})}var rZ=globalThis,nZ=rZ.dzDefault??z4(f6);rZ.dzDefault=nZ;var DZ=rZ.dzByUrl??=new Map;function oZ(Z){let $=DZ.get(Z);if(!$)$=z4(Z),DZ.set(Z,$);return $}function P4(Z){let $=DZ.get(Z);DZ.delete(Z);try{$?.$client?.close?.()}catch{}}function u6(){if(process.env.BEACON_REPO)return nZ;let Z=FZ()??r();if(!Z)return nZ;return oZ(JZ(Z))}var m=new Proxy({},{get(Z,$){let Q=u6(),J=Q[$];return typeof J==="function"?J.bind(Q):J}});import{existsSync as W8}from"fs";import{existsSync as R5,readFileSync as Y8,watch as G8}from"fs";import{readFile as I5}from"fs/promises";import{join as AZ,relative as M8,resolve as j8}from"path";import{existsSync as c4,readFileSync as l4}from"fs";import{readdir as W7,readFile as L7,stat as d4}from"fs/promises";import{extname as n4,join as IZ,relative as HZ,resolve as UZ}from"path";import{extname as g4}from"path";import{dirname as x6,resolve as g6}from"path";var iZ=[".ts",".tsx",".js",".jsx",".mjs",".cjs"],h6=[/(?:^|[\n;])\s*(?:import|export)[^'"`\n]{0,4000}?from\s*['"]([^'"`]+)['"]/g,/(?:^|[\n;])\s*import\s*['"]([^'"`]+)['"]/g,/\brequire\(\s*['"]([^'"`]+)['"]\s*\)/g,/\bimport\(\s*['"]([^'"`]+)['"]\s*\)/g];function b6(Z){return Z.split(/[\\/]/).join("/")}function E4(Z,$){if($.has(Z))return Z;for(let Q of iZ){let J=`${Z}${Q}`;if($.has(J))return J}for(let Q of iZ){let J=`${Z}/index${Q}`;if($.has(J))return J}return null}function m6(Z){let $=new Set;for(let Q of h6)for(let J of Z.matchAll(Q))$.add(J[1]);return $}function p6(Z,$,Q,J){if(Z.startsWith(".")){let V=g6("/",x6($),Z),K=b6(V).replace(/^\//,"");return E4(K,Q)}for(let V of J)if(Z.startsWith(V.from)){let K=Z.slice(V.from.length),Y=V.to?`${V.to}/${K}`:K,X=E4(Y,Q);if(X)return X}return null}var I4={id:"ts",extensions:iZ,specifiers:m6,resolve(Z,$,Q){let J=p6(Z,$,Q.fileSet,Q.tsAliases??[]);return J?[J]:[]}};import{dirname as zZ,join as c6,normalize as l6}from"path";var d6=[".py",".pyi"],R4=[/(?:^|[\n;])\s*from\s+(\.*[\w.]*)\s+import\b/g,/(?:^|[\n;])\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/g];function S4(Z,$){for(let Q of[`${Z}.py`,`${Z}/__init__.py`,`${Z}.pyi`])if($.has(Q))return[Q];return[]}function n6(Z){let $=new Set;for(let Q of Z.matchAll(R4[0])){let J=Q[1].trim();if(J)$.add(J)}for(let Q of Z.matchAll(R4[1]))for(let J of Q[1].split(/\s*,\s*/)){let V=J.trim().split(/\s+as\s+/)[0].trim();if(V)$.add(V)}return $}var v4={id:"python",extensions:d6,specifiers:n6,resolve(Z,$,Q){if(Z.startsWith(".")){let Y=Z.length-Z.replace(/^\.+/,"").length,X=Z.slice(Y),j=zZ($);for(let M=1;M<Y;M++)j=zZ(j);let B=X?c6(j,X.replace(/\./g,"/")):j;return S4(l6(B).replace(/\\/g,"/"),Q.fileSet)}let J=Z.replace(/\./g,"/"),V=[],K=zZ($);while(K&&K!=="."&&K!=="/")V.push(K),K=zZ(K);V.push("");for(let Y of V){let X=S4(Y?`${Y}/${J}`:J,Q.fileSet);if(X.length)return X}return[]}};import{dirname as r6}from"path";var o6=[".go"],i6=/(?:^|[\n;])\s*import\s+(?:[\w.]+\s+)?"([^"]+)"/g,s6=/(?:^|[\n;])\s*import\s*\(([\s\S]*?)\)/g,a6=/"([^"]+)"/g;function t6(Z){let $=new Set;for(let Q of Z.matchAll(i6))$.add(Q[1]);for(let Q of Z.matchAll(s6))for(let J of Q[1].matchAll(a6))$.add(J[1]);return $}var k4={id:"go",extensions:o6,resolve(Z,$,Q){let J=Q.goModulePath;if(!J)return[];let V=null;if(Z===J)V="";else if(Z.startsWith(`${J}/`))V=Z.slice(J.length+1);if(V===null)return[];let K=[];for(let Y of Q.fileSet){if(!Y.endsWith(".go"))continue;let X=r6(Y);if(V===""&&X==="."||X===V)K.push(Y)}return K.sort()},specifiers:t6};import{basename as T4,dirname as sZ,join as w4,normalize as y4}from"path";var e6=[".rs"],Z7=/(?:^|[\n;])\s*(?:pub\s+)?mod\s+(\w+)\s*;/g,$7=/(?:^|[\n;])\s*(?:pub\s+)?use\s+([\w:]+)/g;function Q7(Z){let $=Z.split("::").filter((Q)=>Q&&Q!=="*");if(!$.length)return"";if($[0]==="crate")return["crate",...$.slice(1)].join("/");if($[0]==="super")return["..",...$.slice(1)].join("/");if($[0]==="self")return[".",...$.slice(1)].join("/");return $.join("/")}function aZ(Z,$){for(let Q of[`${Z}.rs`,`${Z}/mod.rs`])if($.has(Q))return[Q];return[]}var J7=new Set(["mod.rs","lib.rs","main.rs"]);function V7(Z){let $=new Set;for(let Q of Z.matchAll(Z7))$.add(`./${Q[1]}`);for(let Q of Z.matchAll($7)){let J=Q7(Q[1]);if(J)$.add(J)}return $}var f4={id:"rust",extensions:e6,specifiers:V7,resolve(Z,$,Q){let J=Q.fileSet;if(Z.startsWith("./")||Z.startsWith("../")){let V=Z.replace(/^\.\//,""),K=y4(w4(sZ($),Z)).replace(/\\/g,"/"),Y=aZ(K,J);if(Y.length)return Y;if(Z.startsWith("./")&&!J7.has(T4($))){let X=w4(sZ($),T4($,".rs"),V);if(Y=aZ(y4(X).replace(/\\/g,"/"),J),Y.length)return Y}return[]}if(Z.startsWith("crate/")){let V=$.split("/"),K=V.lastIndexOf("src"),Y=K>=0?V.slice(0,K+1).join("/"):sZ($),X=Z.slice(6).split("/");for(let j of[X.join("/"),X.slice(0,-1).join("/")]){if(!j)continue;let B=aZ(`${Y}/${j}`,J);if(B.length)return B}return[]}return[]}};import{dirname as K7,extname as X7,join as Y7,normalize as G7}from"path";var u4=[".swift",".java",".rb",".kt",".kts",".cs",".php",".scala",".c",".h",".cpp",".hpp",".cc",".hh",".m",".mm",".ex",".exs",".lua",".dart",".vue",".svelte"],M7=[/\b(?:require_relative|require|include|import|use|using|from)\s*\(?\s*['"]([^'"`\n]+)['"]/g,/(?:^|[\n;])\s*import\s+([\w.]+)/g,/(?:^|[\n;])\s*from\s+([\w.]+)\s+import\b/g,/(?:^|[\n;])\s*using\s+([\w.]+)\s*;/g,/(?:^|[\n;])\s*use\s+([\w\\]+)/g,/#\s*include\s*[<"]([^>"\n]+)[>"]/g];function j7(Z){let $=new Set;for(let Q of M7)for(let J of Z.matchAll(Q)){let V=J[1].trim();if(V)$.add(V)}return $}var x4={id:"fallback",extensions:u4,specifiers:j7,resolve(Z,$,Q){let V=[X7($).toLowerCase(),...u4].filter((j,B,M)=>j&&M.indexOf(j)===B),K=Z.includes("/")||Z.includes("\\"),Y=Z.startsWith(".")||K?Z.replace(/\\/g,"/"):Z.replace(/[.:]+/g,"/"),X=[G7(Y7(K7($),Y)).replace(/\\/g,"/"),Y.replace(/^\.\//,"")];for(let j of X){if(Q.fileSet.has(j))return[j];for(let B of V){let M=j.endsWith(B)?j:`${j}${B}`;if(Q.fileSet.has(M))return[M];if(Q.fileSet.has(`${j}/index${B}`))return[`${j}/index${B}`]}}return[]}};var U7=[I4,v4,k4,f4,x4],PZ=new Map;for(let Z of U7)for(let $ of Z.extensions)PZ.set($,Z);var H7={".ts":"ts",".tsx":"ts",".js":"js",".jsx":"js",".mjs":"js",".cjs":"js",".py":"py",".pyi":"py",".go":"go",".rs":"rs",".swift":"swift",".java":"java",".rb":"ruby",".kt":"kotlin",".kts":"kotlin",".cs":"csharp",".php":"php",".scala":"scala",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cc":"cpp",".hh":"cpp",".m":"objc",".mm":"objc",".ex":"elixir",".exs":"elixir",".lua":"lua",".dart":"dart",".vue":"vue",".svelte":"svelte"};function tZ(Z){return PZ.get(g4(Z).toLowerCase())??null}function h4(Z){let $=g4(Z).toLowerCase();if(!PZ.has($))return null;return H7[$]??$.slice(1)}function eZ(){return new Set(PZ.keys())}var r4=new Set(["node_modules",".git",".next","dist","build","__pycache__","target",".venv","venv","env",".turbo","coverage",".beacon",".playwright-mcp","generated","migrations","drizzle","alembic","migrate"]);function C7(Z=5){let $=performance.now();return async()=>{if(performance.now()-$>Z)await new Promise((Q)=>setImmediate(Q)),$=performance.now()}}var B7=()=>Promise.resolve();async function o4(Z,$,Q,J,V){let K;try{K=await W7($,{withFileTypes:!0})}catch{return}for(let Y of K){if(Y.name.startsWith("."))continue;if(r4.has(Y.name))continue;let X=IZ($,Y.name);if(Y.isDirectory()){await o4(Z,X,Q,J,V);continue}if(!Y.isFile())continue;if(Y.name.endsWith(".d.ts"))continue;if(!Q.has(n4(Y.name).toLowerCase()))continue;J.push(HZ(Z,X))}await V()}async function N7(Z,$=B7){let Q=[];return await o4(Z,Z,eZ(),Q,$),Q.map((J)=>J.split(/[\\/]/).join("/")).sort()}function q7(Z){try{return JSON.parse(Z)}catch{}let $=Z.replace(/\/\*[^"]*?\*\//g,"").replace(/(^|[^:"])\/\/.*$/gm,"$1").replace(/,\s*([}\]])/g,"$1");return JSON.parse($)}function b4(Z){return Z.replace(/^\.\/?/,"").replace(/\/$/,"")}function i4(Z){let $=IZ(Z,"tsconfig.json");if(!c4($))return[];let Q;try{Q=q7(l4($,"utf8"))}catch{return[]}let J=Q.compilerOptions?.paths??{},V=b4(Q.compilerOptions?.baseUrl??"."),K=[];for(let[Y,X]of Object.entries(J)){if(!Y.endsWith("/*")||!X.length)continue;let j=X[0];if(!j.endsWith("/*"))continue;let B=Y.slice(0,-1),M=b4(j.slice(0,-1)),L=[V,M].filter(Boolean).join("/");K.push({from:B,to:L})}return K}function EZ(Z){let $=IZ(Z,"go.mod");if(!c4($))return null;try{let Q=/^\s*module\s+(\S+)/m.exec(l4($,"utf8"));return Q?Q[1]:null}catch{return null}}function p(Z){return Z.split(/[\\/]/).join("/")}function s4(Z){if(Z.length===1)return Z[0];let $=Z.map((V)=>p(V).split("/")),Q=$[0],J=0;for(;J<Q.length;J++)if(!$.every((V)=>V[J]===Q[J]))break;return Q.slice(0,J).join("/")||"/"}async function O7(Z,$,Q){let J=(Array.isArray(Z)?Z:[Z]).map((B)=>p(UZ(B))),V=p($?UZ($):J.length===1?J[0]:s4(J)),K=new Map,Y=[];for(let B of J){let M=p(HZ(V,B));for(let L of i4(B))Y.push({from:L.from,to:[M,L.to].filter(Boolean).join("/")});for(let L of await N7(B,Q)){let C=p(IZ(B,L)),q=p(HZ(V,C));if(K.has(q))continue;try{let U=await d4(C);K.set(q,{path:q,abs:C,root:M||null,mtimeMs:U.mtimeMs,size:U.size})}catch{}await Q()}}let X=J.map(EZ).find(Boolean)??EZ(V);return{metas:[...K.values()].sort((B,M)=>B.path.localeCompare(M.path)),ctx:{fileSet:new Set(K.keys()),tsAliases:Y,goModulePath:X}}}var m4=50000;function A7(Z){let $=0;for(let Q=0;Q<Z.length;Q++)if(Z.charCodeAt(Q)===10){if(Q-$>m4)return!0;$=Q+1}return Z.length-$>m4}async function p4(Z){let $=tZ(Z.path);if(!$||Z.size>200000)return new Set;try{let Q=await L7(Z.abs,"utf8");if(A7(Q))return new Set;return $.specifiers(Q)}catch{return new Set}}function a4(Z,$){let Q=(Array.isArray(Z)?Z:[Z]).map((U)=>p(UZ(U))),J=p($?UZ($):Q.length===1?Q[0]:s4(Q)),V=new Map,K=new Map,Y=[],X=null;function j(){Y=[];for(let U of Q){let H=p(HZ(J,U));for(let O of i4(U))Y.push({from:O.from,to:[H,O.to].filter(Boolean).join("/")})}X=Q.map(EZ).find(Boolean)??EZ(J)}function B(U){let H=U.split("/");for(let A=0;A<H.length;A++){let N=H[A];if(!N||N.startsWith("."))return!0;if(A<H.length-1&&r4.has(N))return!0}let O=H[H.length-1];if(O.endsWith(".d.ts"))return!0;return!eZ().has(n4(O).toLowerCase())}function M(U){let H=p(UZ(U));for(let O of Q)if(H===O||H.startsWith(`${O}/`)){let A=H.slice(O.length).replace(/^\/+/,"");if(B(A))return null;return{path:p(HZ(J,H)),root:p(HZ(J,O))||null}}return null}function L(){let U={fileSet:new Set(V.keys()),tsAliases:Y,goModulePath:X},H=[...V.values()].sort((N,G)=>N.path.localeCompare(G.path)),O=[];for(let N of H){let G=tZ(N.path);if(!G)continue;let _=K.get(N.path)??new Set,F=new Set;for(let R of _)for(let y of G.resolve(R,N.path,U)){if(!y||y===N.path||F.has(y))continue;F.add(y),O.push({from:N.path,to:y})}}return{files:H.map((N)=>({path:N.path,lang:h4(N.path),root:N.root,mtimeMs:N.mtimeMs,size:N.size})),edges:O}}async function C(){let U=C7(),{metas:H,ctx:O}=await O7(Z,$,U);V.clear(),K.clear();for(let A of H)await U(),V.set(A.path,A),K.set(A.path,await p4(A));return Y=O.tsAliases??[],X=O.goModulePath??null,L()}async function q(U){let H=p(UZ(U));if(!Q.some((F)=>H===F||H.startsWith(`${F}/`)))return!1;let O=H.split("/").pop()??"";if(O==="tsconfig.json"||O==="go.mod"){let F=H.slice(0,H.length-O.length-1);if(Q.includes(F))return j(),!0;return!1}let A=M(U);if(!A)return!1;let N;try{N=await d4(H)}catch{let F=V.delete(A.path);return K.delete(A.path),F}let G=V.get(A.path);if(G&&G.mtimeMs===N.mtimeMs&&G.size===N.size)return!1;let _={path:A.path,abs:H,root:A.root,mtimeMs:N.mtimeMs,size:N.size};return V.set(A.path,_),K.set(A.path,await p4(_)),!0}return{seed:C,applyChange:q,snapshot:L}}function t4(Z){let $=Object.keys(Z.tableVars),Q=new Map;if(!$.length){for(let Y of Z.routeFiles)Q.set(Y,[]);return Q}let J=new Map;for(let Y of Z.edges){let X=J.get(Y.from)??[];X.push(Y.to),J.set(Y.from,X)}let V=new Map($.map((Y)=>[Y,new RegExp(`(?:query\\.${Y}\\b|\\.from\\(\\s*${Y}\\b)`)])),K=new Map($.map((Y)=>[Y,new RegExp(`(?:insert|update|delete)\\(\\s*${Y}\\b`)]));for(let Y of Z.routeFiles){let X=new Set([Y]),j=[Y];for(let C=0;C<2&&X.size<25;C++){let q=[];for(let U of j)for(let H of J.get(U)??[]){if(X.has(H)||X.size>=25)continue;X.add(H),q.push(H)}j=q}let B=new Set,M=new Set;for(let C of X){let q=Z.content(C);if(!q)continue;for(let U of $){if(!B.has(U)&&V.get(U).test(q))B.add(U);if(!M.has(U)&&K.get(U).test(q))M.add(U)}}let L=[];for(let C of $){let q=B.has(C),U=M.has(C);if(!q&&!U)continue;L.push({table:Z.tableVars[C],access:q&&U?"read-write":U?"write":"read"})}Q.set(Y,L)}return Q}function e4(Z,$){if(/_JSON_OR_JSONB|\bJSONB\b|\bJSON\b/.test(Z))return"jsonb";let Q=Z.match(/\b(GUID|Uuid|UUID|String|Text|DateTime|Date|Time|BigInteger|SmallInteger|Integer|Boolean|Float|Numeric|Decimal|Vector|TSVECTOR|LargeBinary|Enum)\b\s*(\([^)]*\))?/);if(Q){let K=Q[2]??"",Y=K.match(/\d+/)?.[0];switch(Q[1]){case"GUID":case"Uuid":case"UUID":return"uuid";case"String":return Y?`varchar(${Y})`:"varchar";case"Text":return"text";case"DateTime":return/timezone\s*=\s*True/.test(K)?"timestamptz":"timestamp";case"Date":return"date";case"Time":return"time";case"BigInteger":return"bigint";case"SmallInteger":return"smallint";case"Integer":return"integer";case"Boolean":return"boolean";case"Float":return"float";case"Numeric":case"Decimal":return"numeric";case"Vector":return Y?`vector(${Y})`:"vector";case"TSVECTOR":return"tsvector";case"LargeBinary":return"bytea";case"Enum":return"varchar"}}let J=$.replace(/\s*\|\s*None/g,"").trim(),V=J.match(/^Optional\[([\s\S]*)\]$/);if(V)J=V[1].trim();if(/uuid/i.test(J))return"uuid";if(/datetime/i.test(J))return"timestamptz";if(/\bint\b/i.test(J))return"integer";if(/\bbool\b/i.test(J))return"boolean";if(/\bfloat\b/.test(J)&&!/\blist\b/.test(J))return"float";if(/\bdict\b|\blist\b|\bAny\b/.test(J))return"jsonb";return"text"}function RZ(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="(")Q++;else if(Z[J]===")"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function _7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="[")Q++;else if(Z[J]==="]"){if(Q--,Q===0)return Z.slice($+1,J)}return null}function F7(Z,$,Q){let J=Q.match(/__tablename__\s*=\s*["']([^"']+)["']/)?.[1],V=[],K=[],Y=[],X=/(\w+)\s*:\s*Mapped\s*\[/g,j;while(j=X.exec(Q)){let L=j.index+j[0].length-1,C=_7(Q,L);if(C===null)continue;let q=L+C.length+2,U=Q.slice(q).match(/^\s*=\s*(\w+)\s*\(/);if(!U||U[1]!=="mapped_column")continue;Y.push({colName:j[1],pyType:C,argsAt:q+U[0].length-1})}let B=/(\w+)\s*=\s*(mapped_column|Column)\s*\(/g;while(j=B.exec(Q))Y.push({colName:j[1],pyType:"",argsAt:j.index+j[0].length-1});Y.sort((L,C)=>L.argsAt-C.argsAt);let M=new Set;for(let L of Y){if(M.has(L.colName)||L.colName==="__tablename__")continue;M.add(L.colName);let C=RZ(Q,L.argsAt),q=/primary_key\s*=\s*True/.test(C)||void 0,U=/nullable\s*=\s*False/.test(C)?!1:!0,H=C.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(V.push({name:L.colName,type:e4(C,L.pyType),isPk:q,isFk:H?!0:void 0,nullable:U}),H)K.push({column:L.colName,toTable:H[1],toColumn:H[2]})}return{name:Z,bases:$,tableName:J,columns:V,fks:K}}function D7(Z){let $=[],Q=[],J=/\bTable\s*(\()\s*["']([^"']+)["']\s*,/g,V;while(V=J.exec(Z)){let K=V[2],Y=RZ(Z,V.index+V[0].indexOf("("));if(!/\bmetadata\b/.test(Y)||!/\bColumn\s*\(/.test(Y))continue;let X=[],j=/\bColumn\s*\(/g,B;while(B=j.exec(Y)){let M=RZ(Y,B.index+B[0].length-1),L=M.match(/^\s*["'](\w+)["']\s*,/)?.[1];if(!L)continue;let C=/primary_key\s*=\s*True/.test(M)||void 0,q=/nullable\s*=\s*False/.test(M)?!1:!0,U=M.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(X.push({name:L,type:e4(M,""),isPk:C,isFk:U?!0:void 0,nullable:q}),U)Q.push({fromTable:K,fromColumn:L,toTable:U[1],toColumn:U[2]})}if(X.length)$.push({name:K,columns:X})}return{tables:$,relations:Q}}function z7(Z){let $=new Map,Q={tables:[],relations:[]};for(let X of Z){if(!X.path.endsWith(".py"))continue;if(!/mapped_column\s*\(|__tablename__|\bTable\s*\(\s*["']/.test(X.content))continue;let j=D7(X.content);Q.tables.push(...j.tables),Q.relations.push(...j.relations);let B=/^class\s+(\w+)\s*\(([^)]*)\)\s*:/gm,M,L=[];while(M=B.exec(X.content))L.push({name:M[1],bases:M[2].split(",").map((C)=>C.trim().split(/[.[]/)[0]).filter(Boolean),at:M.index});for(let C=0;C<L.length;C++){let q=X.content.slice(L[C].at,L[C+1]?.at??X.content.length),U=F7(L[C].name,L[C].bases,q);$.set(U.name,U)}}if(![...$.values()].some((X)=>X.tableName)&&!Q.tables.length)return{tables:[],relations:[]};let J=(X,j=new Set)=>{if(j.has(X.name))return[];j.add(X.name);let B=[];for(let M of X.bases){let L=$.get(M);if(L&&!L.tableName)B.push(...J(L,j))}return B.push(...X.columns),B},V=[],K=[];for(let X of $.values()){if(!X.tableName)continue;let j=J(X),B=new Map;for(let U of j)if(!B.has(U.name))B.set(U.name,U);let M=[...B.values()],L=(U)=>M.splice(M.findIndex((H)=>H.name===U),1)[0],C=M.some((U)=>U.name==="id")?L("id"):null,q=["created_at","updated_at","deleted_at"].filter((U)=>M.some((H)=>H.name===U)).map((U)=>L(U));V.push({name:X.tableName,columns:[...C?[C]:[],...M,...q]});for(let U of X.fks)K.push({fromTable:X.tableName,fromColumn:U.column,toTable:U.toTable,toColumn:U.toColumn})}let Y=new Set(V.map((X)=>X.name));for(let X of Q.tables)if(!Y.has(X.name))V.push(X);return K.push(...Q.relations.filter((X)=>!Y.has(X.fromTable))),{tables:V,relations:K}}function P7(Z){let $=Z.replace(/[?[\]]/g,"");return{String:"text",Int:"integer",BigInt:"bigint",Float:"float",Decimal:"numeric",Boolean:"boolean",DateTime:"timestamptz",Json:"jsonb",Bytes:"bytea"}[$]??$.toLowerCase()}function E7(Z){let $=[],Q=[];for(let J of Z){if(!J.path.endsWith(".prisma"))continue;let V=/model\s+(\w+)\s*\{([\s\S]*?)\}/g,K;while(K=V.exec(J.content)){let Y=K[1],X=K[2].match(/@@map\(\s*["']([^"']+)["']\s*\)/)?.[1]??Y,j=[];for(let B of K[2].split(`
|
|
4
|
+
`)){let M=B.trim().match(/^(\w+)\s+(\w+(?:\[\])?\??)\s*(.*)$/);if(!M||/^@@/.test(B.trim()))continue;let[,L,C,q]=M,U=/^(String|Int|BigInt|Float|Decimal|Boolean|DateTime|Json|Bytes)(\[\])?\??$/.test(C),H=q.match(/@relation\([^)]*fields:\s*\[(\w+)\][^)]*references:\s*\[(\w+)\]/);if(H)Q.push({fromTable:X,fromColumn:H[1],toTable:C.replace(/[?[\]]/g,""),toColumn:H[2]});if(!U)continue;j.push({name:L,type:P7(C),isPk:/@id\b/.test(q)||void 0,isFk:/@relation\b/.test(q)||void 0,nullable:C.endsWith("?")})}if(j.length)$.push({name:X,columns:j})}}return{tables:$,relations:Q}}function I7(Z,$){if(/mode:\s*["']timestamp/.test($))return"timestamp";if(/mode:\s*["']boolean["']/.test($))return"boolean";if(/mode:\s*["']json["']/.test($))return"jsonb";return Z}function R7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="{")Q++;else if(Z[J]==="}"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function S7(Z){let $=[],Q=/(\w+)\s*:\s*(text|integer|real|blob|numeric|varchar|boolean|timestamp|serial|uuid|json|jsonb)\s*\(/g;for(let K of Z){if(!/\.(ts|tsx|mts|cts)$/.test(K.path))continue;if(!/\b(?:sqliteTable|pgTable|mysqlTable)\s*\(/.test(K.content))continue;let Y=/(?:export\s+)?const\s+(\w+)\s*=\s*(?:sqliteTable|pgTable|mysqlTable)\s*\(\s*["']([^"']+)["']\s*,/g,X;while(X=Y.exec(K.content)){let j=K.content.indexOf("{",X.index+X[0].length);if(j<0)continue;let B=R7(K.content,j),M={varName:X[1],tableName:X[2],columns:[],colByProp:new Map,fks:[]},L=[];Q.lastIndex=0;for(let C of B.matchAll(Q))L.push({prop:C[1],builder:C[2],at:C.index,argOpen:C.index+C[0].length-1});L.forEach((C,q)=>{let U=B.slice(C.at,L[q+1]?.at??B.length),H=RZ(B,C.argOpen),A=H.match(/^\s*["']([^"']+)["']/)?.[1]??C.prop,N=U.match(/\.references\(\s*\(\)\s*=>\s*(\w+)\.(\w+)/);if(M.columns.push({name:A,type:I7(C.builder,H),isPk:/\.primaryKey\(\)/.test(U)||void 0,isFk:N?!0:void 0,nullable:/\.notNull\(\)/.test(U)?!1:!0}),M.colByProp.set(C.prop,A),N)M.fks.push({column:A,toVar:N[1],toProp:N[2]})}),$.push(M)}}if(!$.length)return{tables:[],relations:[]};let J=new Map($.map((K)=>[K.varName,K])),V=[];for(let K of $)for(let Y of K.fks){let X=J.get(Y.toVar);if(!X)continue;V.push({fromTable:K.tableName,fromColumn:Y.column,toTable:X.tableName,toColumn:X.colByProp.get(Y.toProp)??Y.toProp})}return{tables:$.map((K)=>({name:K.tableName,columns:K.columns})),relations:V,tableVars:Object.fromEntries($.map((K)=>[K.varName,K.tableName]))}}function Z5(Z){let $=S7(Z);if($.tables.length)return $;let Q=E7(Z);if(Q.tables.length)return Q;return z7(Z)}var v7=["GET","POST","PUT","PATCH","DELETE"];function k7(Z){let $=Z.match(/(?:^|\/)app\/(.+)\/route\.(?:ts|tsx|js|jsx|mjs)$/);if(!$)return null;let Q=$[1].split("/").filter((J)=>!(J.startsWith("(")&&J.endsWith(")"))).map((J)=>{let V=J.match(/^\[{1,2}(?:\.\.\.)?([^\]]+)\]{1,2}$/);return V?`{${V[1]}}`:J});if(Q[0]!=="api")return null;return`/${Q.join("/")}`}function $5(Z){let $=[];for(let Q of Z){let J=k7(Q.path);if(!J)continue;for(let V of v7)if(new RegExp(`export\\s+(?:async\\s+)?(?:function|const)\\s+${V}\\b`).test(Q.content))$.push({method:V,path:J,uses:[],file:Q.path})}return $.sort((Q,J)=>`${Q.path} ${Q.method}`.localeCompare(`${J.path} ${J.method}`))}var T7=/(^|\/)app\/.*\/route\.(ts|tsx|js|jsx|mjs)$/,w7=/\.(ts|py)$/,y7=/(schema|model)/i;function Z4(Z){if(Z.endsWith(".prisma"))return!0;if(T7.test(Z))return!0;return w7.test(Z)&&y7.test(Z)}function Q5(Z,$=300){return Z.filter(Z4).slice(0,$)}import{z as d}from"zod";import{and as F5,eq as WZ,inArray as J8,notInArray as V8}from"drizzle-orm";import{z as P}from"zod";import{and as t7,eq as kZ,inArray as Q4,notInArray as e7,or as Z8,sql as $8}from"drizzle-orm";var J5=240,V5=50;function K5(Z){for(let $=0;$<Z.length;$++)for(let Q=$+1;Q<Z.length;Q++){let J=Z[$],V=Z[Q];if(J.x<V.x+J5&&J.x+J5>V.x&&J.y<V.y+V5&&J.y+V5>V.y)return!0}return!1}import{eq as f7}from"drizzle-orm";var X5=(Z)=>Z.replace(/\{[^}]*\}/g,"{}");function u7(Z,$){if(Z.method.toUpperCase()!==$.method.toUpperCase())return!1;let Q=X5(Z.path),J=X5($.path);return J===Q||J.endsWith(Q)}async function Y5(Z=m){let[$,Q]=await Promise.all([Z.query.endpoint.findMany({where:(V,{ne:K})=>K(V.source,"INTROSPECTION")}),Z.query.endpoint.findMany({where:(V,{eq:K})=>K(V.source,"INTROSPECTION")})]),J={collapsed:0,mappings:[]};for(let V of $){let K=Q.find((Y)=>u7(V,Y));if(!K)continue;await Z.delete(v).where(f7(v.id,V.id)),J.collapsed++,J.mappings.push({planned:`${V.method} ${V.path}`,code:`${K.method} ${K.path}`})}return J}import{and as G5,inArray as x7,isNull as M5,ne as j5,or as g7}from"drizzle-orm";var h7=new Set(["DONE","CANCELLED","DEPRIORITIZED"]);async function b7(Z){let $=await Z.query.node.findMany({where:(J,{and:V,eq:K,isNotNull:Y})=>V(K(J.view,"ROADMAP"),Y(J.planId)),columns:{planId:!0,status:!0}}),Q=new Map;for(let J of $){let V=J.planId;Q.set(V,(Q.get(V)??!0)&&h7.has(J.status))}return[...Q.entries()].filter(([,J])=>J).map(([J])=>J)}async function U5(Z=m){let $=await b7(Z),Q=(K)=>$.length?g7(M5(K.planId),x7(K.planId,$)):M5(K.planId),J=await Z.delete(E).where(G5(j5(E.source,"INTROSPECTION"),Q(E))).returning({id:E.id}),V=await Z.delete(v).where(G5(j5(v.source,"INTROSPECTION"),Q(v))).returning({id:v.id});return{tables:J.length,endpoints:V.length}}var W5=320;function $Z(Z){return 36+Math.max(0,Z)*30+16}var YZ=60,m7=280,SZ=14,H5=120,OZ=170,p7=2560;var vZ=(Z)=>(Z??"").trim()||"\u2014";function c7(Z,$,Q){let J=new Map;for(let K of Z.uses){if(!$.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}let V=null;for(let[K,Y]of J){if(V===null){V=K;continue}let X=J.get(V);if(Y>X){V=K;continue}if(Y<X)continue;let j=Q?.get(K)??0,B=Q?.get(V)??0;if(j<B)V=K;else if(j===B&&$.get(K).localeCompare($.get(V))<0)V=K}return V}function $4(Z,$){let Q=new Map(Z.map((V)=>[V.id,V.name])),J=new Map;for(let V of $)for(let K of V.uses){if(!Q.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}return new Map($.map((V)=>[V.id,c7(V,Q,J)]))}var l7=(Z,$)=>Z.path.localeCompare($.path)||Z.method.localeCompare($.method)||Z.id.localeCompare($.id);function L5(Z,$){let Q=$4(Z,$),J=new Map,V=[];for(let N of[...$].sort(l7)){let G=Q.get(N.id)??null;if(G){let _=J.get(G);if(_)_.push(N);else J.set(G,[N])}else V.push(N)}let K=(N)=>{let G=J.get(N.id)?.length??0;return $Z(N.columnCount)+(G?SZ+G*YZ:0)+50},Y=Array.from(new Set(Z.map((N)=>vZ(N.domain)))),X=Y.filter((N)=>N!=="\u2014").sort(),j=Y.includes("\u2014")?[...X,"\u2014"]:X,B=[];for(let N of j){let G=Z.filter((S)=>vZ(S.domain)===N).sort((S,I)=>S.name.localeCompare(I.name)),_=G.reduce((S,I)=>S+K(I),0),F=Math.max(1,Math.min(12,G.length,Math.round(Math.sqrt(_/320)))),R=Array(F).fill(0),y=new Map;for(let S of G){let I=0;for(let D=1;D<F;D++)if(R[D]<R[I])I=D;y.set(S.id,{x:I*320,y:R[I]}),R[I]+=K(S)}B.push({d:N,w:F*320,h:Math.max(...R,0),tableLocal:y})}let M=B.reduce((N,G)=>N+(G.w+H5)*(G.h+OZ),0),L=Math.max(p7,Math.round(Math.sqrt(M*2.2))),C=new Map,q=new Map,U=0,H=0,O=0,A=0;for(let N of B){if(U>0&&U+N.w>L)H+=O+OZ,U=0,O=0;let G=Z.filter((_)=>N.tableLocal.has(_.id));for(let _ of G){let F=N.tableLocal.get(_.id),R=U+F.x,y=H+F.y;C.set(_.id,{x:R,y}),(J.get(_.id)??[]).forEach((I,D)=>{q.set(I.id,{x:R,y:y+$Z(_.columnCount)+SZ+D*YZ})})}O=Math.max(O,N.h),A=Math.max(A,H+N.h),U+=N.w+H5}if(V.length){let N=A+OZ,G=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(V.length/2))));V.forEach((_,F)=>{q.set(_.id,{x:F%G*m7,y:N+Math.floor(F/G)*YZ})})}return{tables:C,endpoints:q}}function C5(Z,$,Q){let J=$4($,Q),V=new Map;for(let q of Q){let U=J.get(q.id);if(U)V.set(U,(V.get(U)??0)+1)}let K=(q)=>{let U=V.get(q.id)??0;return q.y+$Z(q.columnCount)+(U?SZ+U*YZ:0)},Y=vZ(Z.domain),X=$.filter((q)=>vZ(q.domain)===Y);if(!X.length){let q=$.length?Math.max(...$.map(K),...Q.map((U)=>U.y+YZ)):0;return{x:0,y:$.length||Q.length?q+OZ:0}}let j=Math.min(...X.map((q)=>q.x)),B=X.map((q)=>Math.max(0,Math.round((q.x-j)/320))),M=Math.min(12,Math.max(...B)+1),L=Array(M).fill(Math.min(...X.map((q)=>q.y)));X.forEach((q,U)=>{let H=Math.min(B[U],M-1);L[H]=Math.max(L[H],K(q)+50)});let C=0;for(let q=1;q<M;q++)if(L[q]<L[C])C=q;return{x:j+C*320,y:L[C]}}function B5(Z,$,Q){let J=$4($,[...Q,Z]),V=J.get(Z.id),K=V?$.find((X)=>X.id===V):void 0;if(K){let X=Q.filter((M)=>J.get(M.id)===K.id),j=K.y+$Z(K.columnCount)+SZ,B=X.length?Math.max(...X.map((M)=>M.y))+YZ:j;return{x:K.x,y:B}}let Y=[...$.map((X)=>X.y+$Z(X.columnCount)),...Q.map((X)=>X.y+YZ)];return{x:0,y:Y.length?Math.max(...Y)+OZ:0}}function N5(Z){let $=W5-20;for(let Q=0;Q<Z.length;Q++)for(let J=Q+1;J<Z.length;J++){let V=Z[Q],K=Z[J],Y=$Z(V.columnCount),X=$Z(K.columnCount);if(V.x<K.x+$&&V.x+$>K.x&&V.y<K.y+X&&V.y+Y>K.y)return!0}return!1}import{eq as O5}from"drizzle-orm";q5();async function A5(Z=m){let[$,Q]=await Promise.all([Z.query.dbTable.findMany({with:{columns:{columns:{id:!0}}},orderBy:(K,{asc:Y})=>Y(K.name)}),Z.query.endpoint.findMany({with:{tables:{columns:{tableId:!0}}}})]),J=L5($.map((K)=>({id:K.id,name:K.name,domain:K.domain,columnCount:K.columns.length})),Q.map((K)=>({id:K.id,method:K.method,path:K.path,uses:K.tables.map((Y)=>({tableId:Y.tableId}))}))),V=0;for(let K of $){let Y=J.tables.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(E).set({x:Y.x,y:Y.y}).where(O5(E.id,K.id)),V++}for(let K of Q){let Y=J.endpoints.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(v).set({x:Y.x,y:Y.y}).where(O5(v.id,K.id)),V++}return V}var Q8=P.object({tables:P.array(P.object({name:P.string().trim().min(1),domain:P.string().nullish(),description:P.string().nullish(),columns:P.array(P.object({name:P.string().trim().min(1),type:P.string().trim().min(1),isPk:P.boolean().optional(),isFk:P.boolean().optional(),nullable:P.boolean().optional(),note:P.string().nullish()})).default([])})).default([]),relations:P.array(P.object({fromTable:P.string(),fromColumn:P.string(),toTable:P.string(),toColumn:P.string(),label:P.string().nullish()})).default([]),endpoints:P.array(P.object({method:P.string().trim().min(1),path:P.string().trim().min(1),domain:P.string().nullish(),description:P.string().nullish(),uses:P.array(P.object({table:P.string(),access:P.string().default("read")})).default([])})).default([])});async function TZ(Z=m){let[$]=await Z.insert(s).values({id:"singleton",version:1}).onConflictDoUpdate({target:s.id,set:{version:$8`${s.version} + 1`}}).returning();return $.version}async function _5(Z,$=m,Q={}){let J=Q8.parse(Z),V=J.tables.length>0,K=J.endpoints.length>0,Y=J.tables.map((G)=>G.name);if(V)await $.delete(E).where(Y.length?t7(kZ(E.source,"INTROSPECTION"),e7(E.name,Y)):kZ(E.source,"INTROSPECTION"));let X=await $.query.dbTable.findMany({columns:{id:!0,name:!0,domain:!0,x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),j=await $.query.endpoint.findMany({columns:{id:!0,method:!0,path:!0,x:!0,y:!0},with:{tables:{columns:{tableId:!0}}}}),B=new Map(X.map((G)=>[G.name,G])),M=X.map((G)=>({id:G.id,name:G.name,domain:G.domain,columnCount:G.columns.length,x:G.x,y:G.y})),L=j.map((G)=>({id:G.id,method:G.method,path:G.path,uses:G.tables.map((_)=>({tableId:_.tableId})),x:G.x,y:G.y})),C=new Map;for(let G of J.tables){if(B.has(G.name))continue;let _=C5({domain:G.domain??null,columnCount:G.columns.length},M,L);C.set(G.name,_),M.push({id:`new:${G.name}`,name:G.name,domain:G.domain??null,columnCount:G.columns.length,..._})}let q=new Map;for(let G of J.tables){let _=B.get(G.name),F=C.get(G.name),R=_?.x??F?.x??0,y=_?.y??F?.y??0,[S]=await $.insert(E).values({name:G.name,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:R,y}).onConflictDoUpdate({target:E.name,set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(q.set(G.name,S.id),await $.delete(e).where(kZ(e.tableId,S.id)),G.columns.length)await $.insert(e).values(G.columns.map((I,D)=>({tableId:S.id,name:I.name,type:I.type,isPk:I.isPk??!1,isFk:I.isFk??!1,nullable:I.nullable??!0,note:I.note??null,ord:D})))}let U=[...q.values()];if(U.length)await $.delete(l).where(Z8(Q4(l.fromTableId,U),Q4(l.toTableId,U)));for(let G of J.relations){let _=q.get(G.fromTable),F=q.get(G.toTable);if(!_||!F)continue;await $.insert(l).values({fromTableId:_,toTableId:F,fromColumn:G.fromColumn,toColumn:G.toColumn,label:G.label??`${G.fromColumn} \u2192 ${G.toTable}.${G.toColumn}`})}let H=new Set(J.endpoints.map((G)=>`${G.method} ${G.path}`));if(K){let _=(await $.query.endpoint.findMany({where:(F,{eq:R})=>R(F.source,"INTROSPECTION")})).filter((F)=>!H.has(`${F.method} ${F.path}`)).map((F)=>F.id);if(_.length)await $.delete(v).where(Q4(v.id,_))}for(let G of M)if(G.id.startsWith("new:"))G.id=q.get(G.name)??G.id;for(let G of J.endpoints){let _=await $.query.endpoint.findFirst({where:(S,{and:I,eq:D})=>I(D(S.method,G.method),D(S.path,G.path))}),F,R;if(_)F=_.x,R=_.y;else{let S={id:`new:${G.method} ${G.path}`,method:G.method,path:G.path,uses:G.uses.map((D)=>({tableId:q.get(D.table)??""})).filter((D)=>D.tableId)},I=B5(S,M,L);F=I.x,R=I.y,L.push({...S,x:F,y:R})}let[y]=await $.insert(v).values({method:G.method,path:G.path,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:F,y:R}).onConflictDoUpdate({target:[v.method,v.path],set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(!Q.partial||G.uses.length>0)await $.delete(o).where(kZ(o.endpointId,y.id));for(let S of G.uses){let I=q.get(S.table)??(await $.query.dbTable.findFirst({where:(D,{eq:MZ})=>MZ(D.name,S.table)}))?.id;if(!I)continue;await $.insert(o).values({endpointId:y.id,tableId:I,access:S.access})}}await Y5($),await U5($);let O=await $.query.dbTable.findMany({where:(G,{eq:_})=>_(G.source,"INTROSPECTION"),columns:{x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),A=await $.select({x:v.x,y:v.y}).from(v);if(N5(O.map((G)=>({x:G.x,y:G.y,columnCount:G.columns.length})))||K5(A))await A5($);let N=await TZ($);return{tables:J.tables.length,relations:J.relations.length,endpoints:J.endpoints.length,version:N}}var D5=d.object({files:d.array(d.object({path:d.string().trim().min(1),root:d.string().nullish(),lang:d.string().nullish(),mtimeMs:d.number().nullish(),size:d.number().nullish()})).default([]),edges:d.array(d.object({from:d.string().trim().min(1),to:d.string().trim().min(1)})).default([])});function z5(Z,$){let Q=new Map;for(let C of Z)Q.set(C,[]);for(let C of $)Q.get(C.from)?.push(C.to);let J=new Map,V=new Map,K=new Set,Y=[],X=new Map,j=[],B=0,M=0;for(let C of Z){if(J.has(C))continue;let q=[{v:C,iter:0}];J.set(C,B),V.set(C,B),B++,Y.push(C),K.add(C);while(q.length){let U=q[q.length-1],H=Q.get(U.v)??[];if(U.iter<H.length){let O=H[U.iter++];if(!J.has(O))J.set(O,B),V.set(O,B),B++,Y.push(O),K.add(O),q.push({v:O,iter:0});else if(K.has(O))V.set(U.v,Math.min(V.get(U.v),J.get(O)))}else{if(V.get(U.v)===J.get(U.v)){let A=0,N;do N=Y.pop(),K.delete(N),X.set(N,M),A++;while(N!==U.v);j.push(A),M++}q.pop();let O=q[q.length-1];if(O)V.set(O.v,Math.min(V.get(O.v),V.get(U.v)))}}}let L=new Set;for(let C of $){let q=X.get(C.from);if(q!==void 0&&q===X.get(C.to)&&j[q]>1)L.add(`${C.from}|${C.to}`)}return L}async function P5(Z,$=m){let Q=D5.parse(Z),J=Q.files.map((L)=>L.path),V=new Set(J),K=Q.edges.filter((L)=>V.has(L.from)&&V.has(L.to)&&L.from!==L.to),Y=z5(J,K),X=new Map,j=new Map;for(let L of K)j.set(L.from,(j.get(L.from)??0)+1),X.set(L.to,(X.get(L.to)??0)+1);await $.delete(f).where(V8(f.path,J));for(let L of Q.files){let C={root:L.root??null,lang:L.lang??null,mtimeMs:L.mtimeMs??null,size:L.size??null,inDegree:X.get(L.path)??0,outDegree:j.get(L.path)??0};await $.insert(f).values({path:L.path,...C}).onConflictDoUpdate({target:f.path,set:C})}await $.delete(u);let B=0;if(K.length)await $.insert(u).values(K.map((L)=>{let C=Y.has(`${L.from}|${L.to}`);if(C)B++;return{fromPath:L.from,toPath:L.to,circular:C}}));let M=await TZ($);return await $.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton")),{files:Q.files.length,edges:K.length,circular:B,version:M}}var K8=(Z,$)=>`${Z}\x00${$}`;function J4(Z){let $=D5.parse(Z),Q=$.files.map((M)=>M.path),J=new Set(Q),V=$.edges.filter((M)=>J.has(M.from)&&J.has(M.to)&&M.from!==M.to),K=z5(Q,V),Y=new Map,X=new Map;for(let M of V)X.set(M.from,(X.get(M.from)??0)+1),Y.set(M.to,(Y.get(M.to)??0)+1);let j=new Map;for(let M of $.files)j.set(M.path,{root:M.root??null,lang:M.lang??null,mtimeMs:M.mtimeMs??null,size:M.size??null,inDegree:Y.get(M.path)??0,outDegree:X.get(M.path)??0});let B=new Map;for(let M of V)B.set(K8(M.from,M.to),{from:M.from,to:M.to,circular:K.has(`${M.from}|${M.to}`)});return{files:j,edges:B}}var X8=(Z,$)=>Z.root===$.root&&Z.lang===$.lang&&Z.mtimeMs===$.mtimeMs&&Z.size===$.size&&Z.inDegree===$.inDegree&&Z.outDegree===$.outDegree;async function E5(Z,$,Q=m){for(let[X,j]of $.files){let B=Z.files.get(X);if(B&&X8(B,j))continue;let M={root:j.root,lang:j.lang,mtimeMs:j.mtimeMs,size:j.size,inDegree:j.inDegree,outDegree:j.outDegree};await Q.insert(f).values({path:X,...M}).onConflictDoUpdate({target:f.path,set:M})}let J=[...Z.files.keys()].filter((X)=>!$.files.has(X));if(J.length)await Q.delete(f).where(J8(f.path,J));for(let[X,j]of Z.edges)if(!$.edges.has(X))await Q.delete(u).where(F5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)));let V=[];for(let[X,j]of $.edges){let B=Z.edges.get(X);if(!B)V.push({fromPath:j.from,toPath:j.to,circular:j.circular});else if(B.circular!==j.circular)await Q.update(u).set({circular:j.circular}).where(F5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)))}if(V.length)await Q.insert(u).values(V);let K=await TZ(Q);await Q.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton"));let Y=0;for(let X of $.edges.values())if(X.circular)Y++;return{files:$.files.size,edges:$.edges.size,circular:Y,version:K}}var U8=/[/\\](node_modules|\.git|\.next|dist|build|__pycache__|target|\.venv|venv|\.beacon|\.playwright-mcp|generated|coverage)[/\\]/;function H8(Z){try{let $=AZ(Z,"beacon.config.json");if(R5($)){let Q=JSON.parse(Y8($,"utf8"));if(Array.isArray(Q.roots)&&Q.roots.length)return Q.roots.map((J)=>j8(Z,J))}}catch{}return[Z]}function S5(Z){let $=H8(Z.path),Q=cZ(Z.id),J=oZ(JZ(Z.id)),V=a4($,Z.path);async function K(){let H=Q5(V.snapshot().files.map((_)=>_.path));for(let _ of $)for(let F of["prisma/schema.prisma","schema.prisma"]){let R=AZ(_,F);if(R5(R))H.push(Y(R))}let O=[];for(let _ of H)try{O.push({path:_,content:await I5(AZ(Z.path,_),"utf8")})}catch{}let A=Z5(O),N=$5(O);if(!A.tables.length&&!N.length)return;if(N.length&&A.tableVars&&Object.keys(A.tableVars).length){let F=V.snapshot().edges,R=new Set(N.map((D)=>D.file)),y=new Map;for(let D of F){let MZ=y.get(D.from)??[];MZ.push(D.to),y.set(D.from,MZ)}for(let D=0;D<2;D++)for(let MZ of[...R])for(let x5 of y.get(MZ)??[])R.add(x5);let S=new Map;for(let D of[...R].slice(0,600))try{S.set(D,await I5(AZ(Z.path,D),"utf8"))}catch{}let I=t4({routeFiles:[...new Set(N.map((D)=>D.file))],edges:F,content:(D)=>S.get(D)??null,tableVars:A.tableVars});for(let D of N)D.uses=I.get(D.file)??[]}let G=await _5({tables:A.tables,relations:A.relations,endpoints:N},J,{partial:!0});console.log(`[beacon-inline] schema synced (${Z.name}): ${G.tables} tables / ${G.endpoints} endpoints`)}function Y(H){return M8(Z.path,H).split(/[\\/]/).join("/")}let X=null,j=!1,B=new Set,M=null,L=!1;async function C(){if(L){q();return}L=!0;try{if(await Q,j)X=null,j=!1;if(X===null){let N=await V.seed(),G=await P5(N,J);X=J4(N),console.log(`[beacon-inline] code-graph synced (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`),await K();return}let H=[...B];B.clear();let O=H.some((N)=>Z4(Y(N))),A=!1;for(let N of H)if(await V.applyChange(N))A=!0;if(A){let N=J4(V.snapshot()),G=await E5(X,N,J);X=N,console.log(`[beacon-inline] code-graph updated (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`)}if(O)await K()}catch(H){console.error(`[beacon-inline] error (${Z.name}):`,H instanceof Error?H.message:H)}finally{L=!1}}function q(){if(M)clearTimeout(M);M=setTimeout(C,600)}let U=[];for(let H of $)try{let O=G8(H,{recursive:!0,persistent:!0},(A,N)=>{if(!N){j=!0,q();return}let G=String(N);if(U8.test(`/${G}`))return;B.add(AZ(H,G)),q()});O.on("error",(A)=>console.error(`[beacon-inline] watcher error (${Z.name}):`,A)),U.push(O)}catch(O){console.error(`[beacon-inline] live watch unavailable for ${H} (${Z.name}):`,O instanceof Error?O.message:O)}return console.log(`[beacon-inline] watching ${Z.name} (${$.join(", ")}) \u2014 initial extract\u2026`),C(),{async stop(){if(M)clearTimeout(M);for(let H of U)H.close()}}}function L8(Z){let $=Z.limit??6,Q=Z.hardCap??12,J=new Map,V=0,K=new Set;function Y(H){let O=J.get(H);if(O)O.seq=++V}function X(H){if(J.has(H.id))return Y(H.id);if(!Z.exists(H.path))return;J.set(H.id,{handle:Z.start(H),seq:++V})}function j(){let H=null,O=1/0;for(let[A,N]of J){if(K.has(A))continue;if(N.seq<O)O=N.seq,H=A}if(H)J.get(H).handle.stop(),J.delete(H)}function B(){let H=Z.list().filter((O)=>Z.exists(O.path)).slice(0,$);K=new Set(H.map((O)=>O.id));for(let O of H)X(O);for(let[O,A]of[...J]){let N=Z.get(O);if(!N||!Z.exists(N.path))A.handle.stop(),J.delete(O)}}function M(H){if(J.has(H))return Y(H);let O=Z.get(H);if(!O||!Z.exists(O.path))return;if(J.size>=Q)j();if(J.size>=Q)return;J.set(H,{handle:Z.start(O),seq:++V})}async function L(H){let O=J.get(H);if(!O)return;J.delete(H),await O.handle.stop()}function C(H){return J.has(H)}function q(){return[...J.keys()]}async function U(){await Promise.all([...J.values()].map((H)=>H.handle.stop())),J.clear()}return{reconcile:B,ensureWatcher:M,stopWatcher:L,isWatching:C,activeIds:q,stopAll:U}}var C8=L8({list:pZ,get:x,exists:W8,start:(Z)=>S5(Z)});async function v5(Z){await C8.stopWatcher(Z)}async function k5(Z){if(!x(Z))return{ok:!1,removed:!1,fallbackId:r(),error:"unknown workspace"};q4(Z),B4(Z),await v5(Z),P4(JZ(Z)),D4(Z);try{B8(n(Z),{recursive:!0,force:!0})}catch($){return{ok:!1,removed:!0,fallbackId:r(),error:$ instanceof Error?$.message:String($)}}return{ok:!0,removed:!0,fallbackId:r()}}var V4=process.argv.slice(3),y5=V4.includes("--yes")||V4.includes("-y"),GZ=V4.find((Z)=>!Z.startsWith("-")),T5=(Z)=>`\x1B[32m\u2713\x1B[0m ${Z}`,f5=(Z)=>`\x1B[2m${Z}\x1B[0m`,u5=(Z)=>`
|
|
5
5
|
\x1B[1m${Z}\x1B[0m`;function O8(){if(!GZ)return x(QZ(hZ(process.cwd())));if(/^[0-9a-f]{12}$/.test(GZ)){let Z=x(GZ);if(Z)return Z}return x(QZ(hZ(w5(GZ))))}var i=O8();if(!i)console.error(`[beacon] ${GZ??process.cwd()} is not a registered Beacon workspace \u2014 nothing to remove.`),process.exit(1);console.log(u5(y5?"Beacon \xB7 remove workspace":"Beacon \xB7 remove workspace (dry run)"));console.log(` name: ${i.name}${r()===i.id?" (currently active)":""}`);console.log(` repo: ${i.path} ${f5("(untouched \u2014 only Beacon's data is erased)")}`);console.log(` data: ${n(i.id)} ${f5("(deleted)")}`);if(!y5)console.log(u5("Nothing was changed.")),console.log(` Run \x1B[1mbeacon remove${GZ?` ${GZ}`:""} --yes\x1B[0m to apply.
|
|
6
6
|
`),process.exit(0);async function A8(Z){try{let{pid:$,port:Q}=JSON.parse(q8(w5(a(),"server.json"),"utf8"));if(!$||!Q)return!1;return process.kill($,0),(await fetch(`http://localhost:${Q}/api/workspace`,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({id:Z}),signal:AbortSignal.timeout(1e4)})).ok}catch{return!1}}if(await A8(i.id))console.log(` ${T5(`removed ${i.name} (via the running daemon)`)}
|
|
7
7
|
`);else{let Z=await k5(i.id);if(!Z.ok)console.error(`[beacon] remove failed: ${Z.error??"unknown error"}`),process.exit(1);console.log(` ${T5(`removed ${i.name}`)}
|
package/dist/bin/uninstall.js
CHANGED
|
@@ -29,6 +29,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
29
29
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
30
30
|
|
|
31
31
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
32
|
+
- **classificationRoots** (optional): the top-level directories 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 root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
32
33
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
33
34
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
34
35
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -88,7 +89,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
88
89
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
89
90
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
90
91
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
91
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
92
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
92
93
|
|
|
93
94
|
## What you should NOT do
|
|
94
95
|
|
package/dist/lib/assets.js
CHANGED
|
@@ -28,6 +28,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
30
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
31
|
+
- **classificationRoots** (optional): the top-level directories 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 root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
31
32
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
32
33
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
33
34
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -87,7 +88,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
87
88
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
88
89
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
89
90
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
90
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
92
|
|
|
92
93
|
## What you should NOT do
|
|
93
94
|
|