trybeacon 0.1.34 → 0.1.35
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 +11 -10
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +6 -0
- package/.next/server/app/_global-error/page.js +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +2 -2
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/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/position/route.js.nft.json +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/edges/route.js.nft.json +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/init/route.js.nft.json +1 -1
- package/.next/server/app/api/map/describe/route.js +2 -2
- package/.next/server/app/api/map/describe/route.js.nft.json +1 -1
- package/.next/server/app/api/map/files/route.js +1 -1
- package/.next/server/app/api/map/files/route.js.nft.json +1 -1
- package/.next/server/app/api/map/finish/route.js +1 -1
- package/.next/server/app/api/map/finish/route.js.nft.json +1 -1
- package/.next/server/app/api/map/route.js +1 -1
- package/.next/server/app/api/map/route.js.nft.json +1 -1
- package/.next/server/app/api/map/start/route.js +1 -1
- package/.next/server/app/api/map/start/route.js.nft.json +1 -1
- package/.next/server/app/api/map/touch-active/route.js +1 -1
- package/.next/server/app/api/map/touch-active/route.js.nft.json +1 -1
- package/.next/server/app/api/nodes/[id]/position/route.js +1 -1
- package/.next/server/app/api/nodes/[id]/position/route.js.nft.json +1 -1
- package/.next/server/app/api/nodes/[id]/route.js +1 -1
- package/.next/server/app/api/nodes/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/nodes/positions/route.js +1 -1
- package/.next/server/app/api/nodes/positions/route.js.nft.json +1 -1
- package/.next/server/app/api/nodes/route.js +1 -1
- package/.next/server/app/api/nodes/route.js.nft.json +1 -1
- package/.next/server/app/api/nodes/subtasks/route.js +1 -1
- package/.next/server/app/api/nodes/subtasks/route.js.nft.json +1 -1
- package/.next/server/app/api/notes/[id]/route.js +1 -1
- package/.next/server/app/api/notes/route.js +1 -1
- package/.next/server/app/api/open/route.js +1 -1
- package/.next/server/app/api/plan/annotations/route.js +3 -3
- package/.next/server/app/api/plan/approve/route.js +2 -2
- package/.next/server/app/api/plan/history/route.js +1 -1
- package/.next/server/app/api/plan/markdown/route.js +1 -1
- package/.next/server/app/api/plan/markdown/route.js.nft.json +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/route.js.nft.json +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 -0
- package/.next/server/app/api/project-meta/route.js.nft.json +1 -0
- package/.next/server/app/api/project-meta/route_client-reference-manifest.js +1 -0
- 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/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 +1 -1
- package/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page.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 +1 -1
- package/.next/server/app/feedback.segments/_full.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page.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 +1 -1
- package/.next/server/app/help.segments/_full.segment.rsc +1 -1
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +1 -1
- package/.next/server/app/help.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/map/page.js +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.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 +11 -10
- package/.next/server/chunks/1130.js +1 -0
- package/.next/server/chunks/1341.js +1 -0
- package/.next/server/chunks/249.js +1 -1
- package/.next/server/chunks/{4274.js → 3269.js} +2 -2
- package/.next/server/chunks/3622.js +1 -0
- package/.next/server/chunks/4378.js +1 -1
- package/.next/server/chunks/7154.js +1 -0
- package/.next/server/chunks/9313.js +3 -3
- package/.next/server/chunks/9683.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware.js +3 -3
- 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/1551-c19a41da7732c31e.js +1 -0
- package/.next/static/chunks/{1202-dfeac8ec49693586.js → 6955-c21412b6dcd86d80.js} +1 -1
- package/.next/static/chunks/app/_global-error/page-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/board-layout/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/code-graph/position/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/code-graph/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/context/feature/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/context/file/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/context/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/arrange/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/backfill-access/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/position/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/prune-planned/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/relations/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/db/tables/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/draft/approve/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/draft/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/draft/status/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/edges/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/edges/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/endpoints/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/entities/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/feedback/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/feedback/[id]/vote/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/feedback/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/ingest/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/init/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/map/describe/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/map/files/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/map/finish/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/map/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/map/start/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/map/touch-active/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/position/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/nodes/positions/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/nodes/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/nodes/subtasks/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/notes/[id]/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/notes/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/open/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/annotations/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/approve/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/history/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/markdown/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/presence/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/plan/verdict/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/preferences/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/project-meta/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/reset/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/stream/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/version/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/workspace/activate/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/api/workspace/route-68515a67eece5248.js +1 -0
- package/.next/static/chunks/app/map/{page-f3aa9e2ca859e0a1.js → page-8417d6e5dc33e7fb.js} +1 -1
- package/.next/static/chunks/app/plan/{page-056303390782b974.js → page-af54cdc9fb6058a3.js} +1 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-68515a67eece5248.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-68515a67eece5248.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-68515a67eece5248.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-68515a67eece5248.js +1 -0
- package/.next/static/p7RuAgL_wa-K9PsrN1Js0/_buildManifest.js +1 -0
- package/.next/trace +38 -38
- package/.next/trace-build +1 -1
- package/.next/types/app/api/{plan → project-meta}/route.ts +3 -3
- package/.next/types/routes.d.ts +2 -1
- package/.next/types/validator.ts +9 -0
- package/dist/bin/beacon.js +5 -5
- package/dist/bin/doctor.js +6 -3
- package/dist/bin/hook.js +6 -3
- package/dist/bin/mcp.js +35 -32
- package/dist/bin/plan.js +6 -3
- package/dist/bin/remove.js +2 -2
- package/dist/bin/uninstall.js +6 -3
- package/dist/lib/assets.js +6 -3
- package/dist/lib/codex-install.js +6 -3
- package/dist/lib/global-install.js +6 -3
- package/drizzle/0006_optimal_chronomancer.sql +2 -0
- package/drizzle/meta/0006_snapshot.json +1765 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/.next/server/chunks/7266.js +0 -1
- package/.next/server/chunks/7373.js +0 -1
- package/.next/static/OgbjxEMZfqIJgM1cAQ4cs/_buildManifest.js +0 -1
- package/.next/static/chunks/6764-ff2754e69d33be8a.js +0 -1
- package/.next/static/chunks/app/_global-error/page-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/board-layout/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/code-graph/position/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/code-graph/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/context/feature/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/context/file/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/context/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/arrange/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/backfill-access/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/position/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/prune-planned/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/relations/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/db/tables/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/draft/approve/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/draft/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/draft/status/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/edges/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/edges/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/endpoints/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/entities/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/feedback/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/feedback/[id]/vote/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/feedback/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/ingest/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/init/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/map/describe/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/map/files/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/map/finish/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/map/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/map/start/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/map/touch-active/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/position/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/nodes/positions/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/nodes/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/nodes/subtasks/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/notes/[id]/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/notes/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/open/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/annotations/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/approve/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/history/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/markdown/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/presence/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/plan/verdict/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/preferences/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/reset/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/stream/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/version/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/workspace/activate/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/app/api/workspace/route-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-4cdc03c65547f289.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-4cdc03c65547f289.js +0 -1
- /package/.next/static/{OgbjxEMZfqIJgM1cAQ4cs → p7RuAgL_wa-K9PsrN1Js0}/_ssgManifest.js +0 -0
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 TZ=(Z,$)=>{for(var Q in $)g5(Z,Q,{get:$[Q],enumerable:!0,configurable:!0,set:b5.bind($,Q)})};var V4=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var X4={};TZ(X4,{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 wZ,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 K4(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 K4(Q);if(await c5(p5(Q),{migrationsFolder:$}),await K4(Q)>Y)K=!0;return await a5(Q),{migrated:K}}finally{Q.close()}}var r5,o5,i5;var Y4=V4(async()=>{r5=wZ(wZ(wZ(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 h$(Z,$){d7(i7(Z),{recursive:!0});let Q=`${Z}.tmp`;try{o7(Q,$),n7(Q,Z)}catch(J){throw r7(Q,{force:!0}),J}}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 M4,mkdirSync as LZ,readFileSync as fZ,writeFileSync as uZ}from"fs";import{homedir as j4}from"os";import{basename as Q6,join as ZZ,parse as J6,resolve as G4}from"path";function a(){return process.env.BEACON_HOME||ZZ(j4(),".beacon")}function xZ(){return ZZ(a(),"workspaces.json")}function QZ(Z){return $6("sha256").update(Z).digest("hex").slice(0,12)}function gZ(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 U4(Z){let $=G4(Z);return $!==G4(j4())&&$!==J6($).root}function H4(){return ZZ(a(),"deleted.json")}function hZ(){try{let Z=JSON.parse(fZ(H4(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function W4(Z){LZ(a(),{recursive:!0}),uZ(H4(),JSON.stringify(Z,null,2))}function L4(Z){return hZ().includes(Z)}function C4(Z){let $=hZ();if(!$.includes(Z))W4([...$,Z])}function V6(Z){let $=hZ();if($.includes(Z))W4($.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(fZ(xZ(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function bZ(Z){LZ(a(),{recursive:!0}),uZ(xZ(),JSON.stringify(Z,null,2))}function mZ(){return CZ().sort((Z,$)=>$.lastOpenedAt.localeCompare(Z.lastOpenedAt))}function x(Z){return CZ().find(($)=>$.id===Z)??null}function B4(Z,$,Q=new Date().toISOString()){if(!U4(Z))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Z}`);let J=QZ(Z);if(L4(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((H)=>H.id===J),Y={id:J,path:Z,name:$||K?.name||Q6(Z),lastOpenedAt:Q},X=[Y,...V.filter((H)=>H.id!==J)];return LZ(n(J),{recursive:!0}),bZ(X),Y}function T8(Z,$){return V6(QZ(Z)),B4(Z,$)}function w8(Z,$=new Date().toISOString()){let Q=CZ(),J=Q.find((V)=>V.id===Z);if(!J)return;J.lastOpenedAt=$,bZ(Q)}function N4(Z){if(bZ(CZ().filter(($)=>$.id!==Z)),r()===Z)K6(mZ()[0]?.id??null)}function q4(){return ZZ(a(),"active")}function r(){try{return fZ(q4(),"utf8").trim()||null}catch{return null}}function K6(Z){LZ(a(),{recursive:!0}),uZ(q4(),Z??"")}function X6(){let Z=r();return Z?x(Z):null}function y8(){let Z=FZ()??r();return Z?x(Z):null}function f8(Z){return x(Z)?.path??null}function u8(){return M4(xZ())}var O4="beacon_ws";function A4(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 x8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=A4(Z,O4);if(Q&&x(Q))return Q;return null}var Y6="x-beacon-workspace-path";async function g8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=Z.headers.get(Y6);if(Q&&U4(Q)&&!L4(QZ(Q))&&(!$||QZ(Q)===$)){let V=B4(Q);return await pZ(V.id),V.id}let J=A4(Z,O4);if(J&&x(J))return J;return null}var _4=new e5;function G6(Z,$){return Z?_4.run(Z,$):$()}function FZ(){return _4.getStore()??null}var yZ=new Set;function F4(Z){yZ.delete(ZZ(n(Z),"db.sqlite"))}async function pZ(Z){let $=n(Z),Q=ZZ($,"db.sqlite"),J=M4(Q);if(J&&yZ.has(Q))return{ok:!0,created:!1,migrated:!1};try{LZ($,{recursive:!0});let{provisionDb:V}=await Y4().then(() => X4),K=await V(JZ(Z));return yZ.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 C8,readFileSync as B8}from"fs";import{resolve as w5}from"path";import{rmSync as L8}from"fs";import{drizzle as k6}from"drizzle-orm/libsql";import{createClient as T6}from"@libsql/client";var cZ={};TZ(cZ,{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:()=>P,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 C,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:C().primaryKey().$defaultFn(()=>h()),view:C().notNull(),kind:C().default("FEATURE").notNull(),cluster:C(),title:C().notNull(),role:C(),plain:C(),status:C().default("PENDING").notNull(),priority:z().default(2).notNull(),progress:z().default(0).notNull(),x:b().default(0).notNull(),y:b().default(0).notNull(),sourceRef:C(),externalId:C(),source:C().default("MANUAL").notNull(),planId:C(),parentId:C(),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:C().primaryKey().$defaultFn(()=>h()),nodeId:C().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),path:C().notNull()},(Z)=>[t("NodeFile_nodeId_path_key").on(Z.nodeId,Z.path),k("NodeFile_nodeId_idx").on(Z.nodeId)]),jZ=w("Tag",{id:C().primaryKey().$defaultFn(()=>h()),label:C().notNull(),color:C()},(Z)=>[t("Tag_label_key").on(Z.label)]),VZ=w("Edge",{id:C().primaryKey().$defaultFn(()=>h()),fromId:C().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:C().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:C().default("DEPENDS").notNull(),label:C(),sourceHandle:C(),targetHandle:C()},(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:C("A").notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),b:C("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:C().primaryKey().$defaultFn(()=>h()),title:C().default("Untitled").notNull(),body:C().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:C().primaryKey().$defaultFn(()=>h()),targetKind:C().notNull(),targetId:C().notNull(),columnName:C(),body:C().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:C().primaryKey().$defaultFn(()=>h()),nodeId:C().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),by:C().notNull(),note:C().notNull(),resolvedAt:z({mode:"timestamp_ms"}),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[k("BugFlag_nodeId_idx").on(Z.nodeId)]),P=w("DbTable",{id:C().primaryKey().$defaultFn(()=>h()),name:C().notNull(),domain:C(),description:C(),source:C().default("MANUAL").notNull(),planId:C(),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:C().primaryKey().$defaultFn(()=>h()),tableId:C().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),name:C().notNull(),type:C().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:C(),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:C().primaryKey().$defaultFn(()=>h()),fromTableId:C().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:C().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:C().notNull(),toColumn:C().notNull(),label:C()},(Z)=>[k("DbRelation_toTableId_idx").on(Z.toTableId),k("DbRelation_fromTableId_idx").on(Z.fromTableId)]),v=w("Endpoint",{id:C().primaryKey().$defaultFn(()=>h()),method:C().notNull(),path:C().notNull(),domain:C(),description:C(),source:C().default("MANUAL").notNull(),planId:C(),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:C().primaryKey().$defaultFn(()=>h()),endpointId:C().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:C().notNull().references(()=>P.id,{onDelete:"cascade",onUpdate:"cascade"}),access:C().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:C().primaryKey().$defaultFn(()=>h()),name:C().notNull(),domain:C(),description:C(),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:C().primaryKey().$defaultFn(()=>h()),tableId:C().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),name:C().notNull(),type:C().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:C(),ord:z().default(0).notNull()},(Z)=>[k("DraftColumn_tableId_idx").on(Z.tableId)]),XZ=w("DraftRelation",{id:C().primaryKey().$defaultFn(()=>h()),fromTableId:C().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:C().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:C().notNull(),toColumn:C().notNull(),label:C()},(Z)=>[k("DraftRelation_toTableId_idx").on(Z.toTableId),k("DraftRelation_fromTableId_idx").on(Z.fromTableId)]),f=w("CodeFile",{path:C().primaryKey(),root:C(),lang:C(),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:C().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:C().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:C().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:C().primaryKey().default("singleton"),editor:C().default("auto").notNull(),currentFeatureId:C(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),L6=w("ProjectMeta",{id:C().primaryKey().default("singleton"),overview:C(),conventions:C().default("[]").notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var lZ={};TZ(lZ,{tagRelations:()=>q6,nodeTagsRelations:()=>O6,nodeRelations:()=>C6,nodeFileRelations:()=>B6,endpointTableRelations:()=>E6,endpointRelations:()=>z6,edgeRelations:()=>A6,draftTableRelations:()=>P6,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(P,({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(P,{fields:[e.tableId],references:[P.id]})})),D6=g(l,({one:Z})=>({fromTable:Z(P,{fields:[l.fromTableId],references:[P.id],relationName:"FkFrom"}),toTable:Z(P,{fields:[l.toTableId],references:[P.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(P,{fields:[o.tableId],references:[P.id]})})),P6=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={...cZ,...lZ};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 D4(Z){let $=T6({url:Z});return $.execute("PRAGMA foreign_keys = ON;"),$.execute("PRAGMA busy_timeout = 5000;"),k6($,{schema:w6})}var nZ=globalThis,dZ=nZ.dzDefault??D4(f6);nZ.dzDefault=dZ;var DZ=nZ.dzByUrl??=new Map;function rZ(Z){let $=DZ.get(Z);if(!$)$=D4(Z),DZ.set(Z,$);return $}function z4(Z){let $=DZ.get(Z);DZ.delete(Z);try{$?.$client?.close?.()}catch{}}function u6(){if(process.env.BEACON_REPO)return dZ;let Z=FZ()??r();if(!Z)return dZ;return rZ(JZ(Z))}var m=new Proxy({},{get(Z,$){let Q=u6(),J=Q[$];return typeof J==="function"?J.bind(Q):J}});import{existsSync as U8}from"fs";import{existsSync as R5,readFileSync as K8,watch as X8}from"fs";import{readFile as I5}from"fs/promises";import{join as AZ,relative as Y8,resolve as G8}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 oZ=[".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 oZ){let J=`${Z}${Q}`;if($.has(J))return J}for(let Q of oZ){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 P4={id:"ts",extensions:oZ,specifiers:m6,resolve(Z,$,Q){let J=p6(Z,$,Q.fileSet,Q.tsAliases??[]);return J?[J]:[]}};import{dirname as I4,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 J=Z.length-Z.replace(/^\.+/,"").length,V=Z.slice(J),K=I4($);for(let X=1;X<J;X++)K=I4(K);let Y=V?c6(K,V.replace(/\./g,"/")):K;return S4(l6(Y).replace(/\\/g,"/"),Q.fileSet)}return S4(Z.replace(/\./g,"/"),Q.fileSet)}};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 iZ,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 sZ(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(iZ($),Z)).replace(/\\/g,"/"),Y=sZ(K,J);if(Y.length)return Y;if(Z.startsWith("./")&&!J7.has(T4($))){let X=w4(iZ($),T4($,".rs"),V);if(Y=sZ(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("/"):iZ($),X=Z.slice(6).split("/");for(let H of[X.join("/"),X.slice(0,-1).join("/")]){if(!H)continue;let B=sZ(`${Y}/${H}`,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((H,B,M)=>H&&M.indexOf(H)===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 H of X){if(Q.fileSet.has(H))return[H];for(let B of V){let M=H.endsWith(B)?H:`${H}${B}`;if(Q.fileSet.has(M))return[M];if(Q.fileSet.has(`${H}/index${B}`))return[`${H}/index${B}`]}}return[]}};var U7=[P4,v4,k4,f4,x4],zZ=new Map;for(let Z of U7)for(let $ of Z.extensions)zZ.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 aZ(Z){return zZ.get(g4(Z).toLowerCase())??null}function h4(Z){let $=g4(Z).toLowerCase();if(!zZ.has($))return null;return H7[$]??$.slice(1)}function tZ(){return new Set(zZ.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,tZ(),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 H=X[0];if(!H.endsWith("/*"))continue;let B=Y.slice(0,-1),M=b4(H.slice(0,-1)),W=[V,M].filter(Boolean).join("/");K.push({from:B,to:W})}return K}function EZ(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 W of i4(B))Y.push({from:W.from,to:[M,W.to].filter(Boolean).join("/")});for(let W of await N7(B,Q)){let L=p(PZ(B,W)),q=p(HZ(V,L));if(K.has(q))continue;try{let j=await d4(L);K.set(q,{path:q,abs:L,root:M||null,mtimeMs:j.mtimeMs,size:j.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 $=aZ(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((j)=>p(UZ(j))),J=p($?UZ($):Q.length===1?Q[0]:s4(Q)),V=new Map,K=new Map,Y=[],X=null;function H(){Y=[];for(let j of Q){let U=p(HZ(J,j));for(let O of i4(j))Y.push({from:O.from,to:[U,O.to].filter(Boolean).join("/")})}X=Q.map(EZ).find(Boolean)??EZ(J)}function B(j){let U=j.split("/");for(let A=0;A<U.length;A++){let N=U[A];if(!N||N.startsWith("."))return!0;if(A<U.length-1&&r4.has(N))return!0}let O=U[U.length-1];if(O.endsWith(".d.ts"))return!0;return!tZ().has(n4(O).toLowerCase())}function M(j){let U=p(UZ(j));for(let O of Q)if(U===O||U.startsWith(`${O}/`)){let A=U.slice(O.length).replace(/^\/+/,"");if(B(A))return null;return{path:p(HZ(J,U)),root:p(HZ(J,O))||null}}return null}function W(){let j={fileSet:new Set(V.keys()),tsAliases:Y,goModulePath:X},U=[...V.values()].sort((N,G)=>N.path.localeCompare(G.path)),O=[];for(let N of U){let G=aZ(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,j)){if(!y||y===N.path||F.has(y))continue;F.add(y),O.push({from:N.path,to:y})}}return{files:U.map((N)=>({path:N.path,lang:h4(N.path),root:N.root,mtimeMs:N.mtimeMs,size:N.size})),edges:O}}async function L(){let j=C7(),{metas:U,ctx:O}=await O7(Z,$,j);V.clear(),K.clear();for(let A of U)await j(),V.set(A.path,A),K.set(A.path,await p4(A));return Y=O.tsAliases??[],X=O.goModulePath??null,W()}async function q(j){let U=p(UZ(j));if(!Q.some((F)=>U===F||U.startsWith(`${F}/`)))return!1;let O=U.split("/").pop()??"";if(O==="tsconfig.json"||O==="go.mod"){let F=U.slice(0,U.length-O.length-1);if(Q.includes(F))return H(),!0;return!1}let A=M(j);if(!A)return!1;let N;try{N=await d4(U)}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:U,root:A.root,mtimeMs:N.mtimeMs,size:N.size};return V.set(A.path,_),K.set(A.path,await p4(_)),!0}return{seed:L,applyChange:q,snapshot:W}}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]),H=[Y];for(let L=0;L<2&&X.size<25;L++){let q=[];for(let j of H)for(let U of J.get(j)??[]){if(X.has(U)||X.size>=25)continue;X.add(U),q.push(U)}H=q}let B=new Set,M=new Set;for(let L of X){let q=Z.content(L);if(!q)continue;for(let j of $){if(!B.has(j)&&V.get(j).test(q))B.add(j);if(!M.has(j)&&K.get(j).test(q))M.add(j)}}let W=[];for(let L of $){let q=B.has(L),j=M.has(L);if(!q&&!j)continue;W.push({table:Z.tableVars[L],access:q&&j?"read-write":j?"write":"read"})}Q.set(Y,W)}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 IZ(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,H;while(H=X.exec(Q)){let W=H.index+H[0].length-1,L=_7(Q,W);if(L===null)continue;let q=W+L.length+2,j=Q.slice(q).match(/^\s*=\s*(\w+)\s*\(/);if(!j||j[1]!=="mapped_column")continue;Y.push({colName:H[1],pyType:L,argsAt:q+j[0].length-1})}let B=/(\w+)\s*=\s*(mapped_column|Column)\s*\(/g;while(H=B.exec(Q))Y.push({colName:H[1],pyType:"",argsAt:H.index+H[0].length-1});Y.sort((W,L)=>W.argsAt-L.argsAt);let M=new Set;for(let W of Y){if(M.has(W.colName)||W.colName==="__tablename__")continue;M.add(W.colName);let L=IZ(Q,W.argsAt),q=/primary_key\s*=\s*True/.test(L)||void 0,j=/nullable\s*=\s*False/.test(L)?!1:!0,U=L.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(V.push({name:W.colName,type:e4(L,W.pyType),isPk:q,isFk:U?!0:void 0,nullable:j}),U)K.push({column:W.colName,toTable:U[1],toColumn:U[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=IZ(Z,V.index+V[0].indexOf("("));if(!/\bmetadata\b/.test(Y)||!/\bColumn\s*\(/.test(Y))continue;let X=[],H=/\bColumn\s*\(/g,B;while(B=H.exec(Y)){let M=IZ(Y,B.index+B[0].length-1),W=M.match(/^\s*["'](\w+)["']\s*,/)?.[1];if(!W)continue;let L=/primary_key\s*=\s*True/.test(M)||void 0,q=/nullable\s*=\s*False/.test(M)?!1:!0,j=M.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(X.push({name:W,type:e4(M,""),isPk:L,isFk:j?!0:void 0,nullable:q}),j)Q.push({fromTable:K,fromColumn:W,toTable:j[1],toColumn:j[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 H=D7(X.content);Q.tables.push(...H.tables),Q.relations.push(...H.relations);let B=/^class\s+(\w+)\s*\(([^)]*)\)\s*:/gm,M,W=[];while(M=B.exec(X.content))W.push({name:M[1],bases:M[2].split(",").map((L)=>L.trim().split(/[.[]/)[0]).filter(Boolean),at:M.index});for(let L=0;L<W.length;L++){let q=X.content.slice(W[L].at,W[L+1]?.at??X.content.length),j=F7(W[L].name,W[L].bases,q);$.set(j.name,j)}}if(![...$.values()].some((X)=>X.tableName)&&!Q.tables.length)return{tables:[],relations:[]};let J=(X,H=new Set)=>{if(H.has(X.name))return[];H.add(X.name);let B=[];for(let M of X.bases){let W=$.get(M);if(W&&!W.tableName)B.push(...J(W,H))}return B.push(...X.columns),B},V=[],K=[];for(let X of $.values()){if(!X.tableName)continue;let H=J(X),B=new Map;for(let j of H)if(!B.has(j.name))B.set(j.name,j);let M=[...B.values()],W=(j)=>M.splice(M.findIndex((U)=>U.name===j),1)[0],L=M.some((j)=>j.name==="id")?W("id"):null,q=["created_at","updated_at","deleted_at"].filter((j)=>M.some((U)=>U.name===j)).map((j)=>W(j));V.push({name:X.tableName,columns:[...L?[L]:[],...M,...q]});for(let j of X.fks)K.push({fromTable:X.tableName,fromColumn:j.column,toTable:j.toTable,toColumn:j.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 P7(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,H=[];for(let B of K[2].split(`
|
|
4
|
-
`)){let M=B.trim().match(/^(\w+)\s+(\w+(?:\[\])?\??)\s*(.*)$/);if(!M||/^@@/.test(B.trim()))continue;let[,W,L,q]=M,j=/^(String|Int|BigInt|Float|Decimal|Boolean|DateTime|Json|Bytes)(\[\])?\??$/.test(L),U=q.match(/@relation\([^)]*fields:\s*\[(\w+)\][^)]*references:\s*\[(\w+)\]/);if(U)Q.push({fromTable:X,fromColumn:U[1],toTable:L.replace(/[?[\]]/g,""),toColumn:U[2]});if(!j)continue;H.push({name:W,type:E7(L),isPk:/@id\b/.test(q)||void 0,isFk:/@relation\b/.test(q)||void 0,nullable:L.endsWith("?")})}if(H.length)$.push({name:X,columns:H})}}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 H=K.content.indexOf("{",X.index+X[0].length);if(H<0)continue;let B=R7(K.content,H),M={varName:X[1],tableName:X[2],columns:[],colByProp:new Map,fks:[]},W=[];Q.lastIndex=0;for(let L of B.matchAll(Q))W.push({prop:L[1],builder:L[2],at:L.index,argOpen:L.index+L[0].length-1});W.forEach((L,q)=>{let j=B.slice(L.at,W[q+1]?.at??B.length),U=IZ(B,L.argOpen),A=U.match(/^\s*["']([^"']+)["']/)?.[1]??L.prop,N=j.match(/\.references\(\s*\(\)\s*=>\s*(\w+)\.(\w+)/);if(M.columns.push({name:A,type:I7(L.builder,U),isPk:/\.primaryKey\(\)/.test(j)||void 0,isFk:N?!0:void 0,nullable:/\.notNull\(\)/.test(j)?!1:!0}),M.colByProp.set(L.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=P7(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 eZ(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(eZ).slice(0,$)}import{z as d}from"zod";import{and as F5,eq as WZ,inArray as $8,notInArray as Q8}from"drizzle-orm";import{z as E}from"zod";import{and as s7,eq as vZ,inArray as $4,notInArray as a7,or as t7,sql as e7}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(P).where(G5(j5(P.source,"INTROSPECTION"),Q(P))).returning({id:P.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,RZ=14,H5=120,OZ=170,p7=2560;var SZ=(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 H=Q?.get(K)??0,B=Q?.get(V)??0;if(H<B)V=K;else if(H===B&&$.get(K).localeCompare($.get(V))<0)V=K}return V}function Z4(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=Z4(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?RZ+G*YZ:0)+50},Y=Array.from(new Set(Z.map((N)=>SZ(N.domain)))),X=Y.filter((N)=>N!=="\u2014").sort(),H=Y.includes("\u2014")?[...X,"\u2014"]:X,B=[];for(let N of H){let G=Z.filter((S)=>SZ(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),W=Math.max(p7,Math.round(Math.sqrt(M*2.2))),L=new Map,q=new Map,j=0,U=0,O=0,A=0;for(let N of B){if(j>0&&j+N.w>W)U+=O+OZ,j=0,O=0;let G=Z.filter((_)=>N.tableLocal.has(_.id));for(let _ of G){let F=N.tableLocal.get(_.id),R=j+F.x,y=U+F.y;L.set(_.id,{x:R,y}),(J.get(_.id)??[]).forEach((I,D)=>{q.set(I.id,{x:R,y:y+$Z(_.columnCount)+RZ+D*YZ})})}O=Math.max(O,N.h),A=Math.max(A,U+N.h),j+=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:L,endpoints:q}}function C5(Z,$,Q){let J=Z4($,Q),V=new Map;for(let q of Q){let j=J.get(q.id);if(j)V.set(j,(V.get(j)??0)+1)}let K=(q)=>{let j=V.get(q.id)??0;return q.y+$Z(q.columnCount)+(j?RZ+j*YZ:0)},Y=SZ(Z.domain),X=$.filter((q)=>SZ(q.domain)===Y);if(!X.length){let q=$.length?Math.max(...$.map(K),...Q.map((j)=>j.y+YZ)):0;return{x:0,y:$.length||Q.length?q+OZ:0}}let H=Math.min(...X.map((q)=>q.x)),B=X.map((q)=>Math.max(0,Math.round((q.x-H)/320))),M=Math.min(12,Math.max(...B)+1),W=Array(M).fill(Math.min(...X.map((q)=>q.y)));X.forEach((q,j)=>{let U=Math.min(B[j],M-1);W[U]=Math.max(W[U],K(q)+50)});let L=0;for(let q=1;q<M;q++)if(W[q]<W[L])L=q;return{x:H+L*320,y:W[L]}}function B5(Z,$,Q){let J=Z4($,[...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),H=K.y+$Z(K.columnCount)+RZ,B=X.length?Math.max(...X.map((M)=>M.y))+YZ:H;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(P).set({x:Y.x,y:Y.y}).where(O5(P.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 Z8=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 kZ(Z=m){let[$]=await Z.insert(s).values({id:"singleton",version:1}).onConflictDoUpdate({target:s.id,set:{version:e7`${s.version} + 1`}}).returning();return $.version}async function _5(Z,$=m,Q={}){let J=Z8.parse(Z),V=J.tables.length>0,K=J.endpoints.length>0,Y=J.tables.map((G)=>G.name);if(V)await $.delete(P).where(Y.length?s7(vZ(P.source,"INTROSPECTION"),a7(P.name,Y)):vZ(P.source,"INTROSPECTION"));let X=await $.query.dbTable.findMany({columns:{id:!0,name:!0,domain:!0,x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),H=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})),W=H.map((G)=>({id:G.id,method:G.method,path:G.path,uses:G.tables.map((_)=>({tableId:_.tableId})),x:G.x,y:G.y})),L=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,W);L.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=L.get(G.name),R=_?.x??F?.x??0,y=_?.y??F?.y??0,[S]=await $.insert(P).values({name:G.name,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:R,y}).onConflictDoUpdate({target:P.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(vZ(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 j=[...q.values()];if(j.length)await $.delete(l).where(t7($4(l.fromTableId,j),$4(l.toTableId,j)));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 U=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)=>!U.has(`${F.method} ${F.path}`)).map((F)=>F.id);if(_.length)await $.delete(v).where($4(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,W);F=I.x,R=I.y,W.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(vZ(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 kZ($);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 L of Z)Q.set(L,[]);for(let L of $)Q.get(L.from)?.push(L.to);let J=new Map,V=new Map,K=new Set,Y=[],X=new Map,H=[],B=0,M=0;for(let L of Z){if(J.has(L))continue;let q=[{v:L,iter:0}];J.set(L,B),V.set(L,B),B++,Y.push(L),K.add(L);while(q.length){let j=q[q.length-1],U=Q.get(j.v)??[];if(j.iter<U.length){let O=U[j.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(j.v,Math.min(V.get(j.v),J.get(O)))}else{if(V.get(j.v)===J.get(j.v)){let A=0,N;do N=Y.pop(),K.delete(N),X.set(N,M),A++;while(N!==j.v);H.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(j.v)))}}}let W=new Set;for(let L of $){let q=X.get(L.from);if(q!==void 0&&q===X.get(L.to)&&H[q]>1)W.add(`${L.from}|${L.to}`)}return W}async function E5(Z,$=m){let Q=D5.parse(Z),J=Q.files.map((W)=>W.path),V=new Set(J),K=Q.edges.filter((W)=>V.has(W.from)&&V.has(W.to)&&W.from!==W.to),Y=z5(J,K),X=new Map,H=new Map;for(let W of K)H.set(W.from,(H.get(W.from)??0)+1),X.set(W.to,(X.get(W.to)??0)+1);await $.delete(f).where(Q8(f.path,J));for(let W of Q.files){let L={root:W.root??null,lang:W.lang??null,mtimeMs:W.mtimeMs??null,size:W.size??null,inDegree:X.get(W.path)??0,outDegree:H.get(W.path)??0};await $.insert(f).values({path:W.path,...L}).onConflictDoUpdate({target:f.path,set:L})}await $.delete(u);let B=0;if(K.length)await $.insert(u).values(K.map((W)=>{let L=Y.has(`${W.from}|${W.to}`);if(L)B++;return{fromPath:W.from,toPath:W.to,circular:L}}));let M=await kZ($);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 J8=(Z,$)=>`${Z}\x00${$}`;function Q4(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 H=new Map;for(let M of $.files)H.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(J8(M.from,M.to),{from:M.from,to:M.to,circular:K.has(`${M.from}|${M.to}`)});return{files:H,edges:B}}var V8=(Z,$)=>Z.root===$.root&&Z.lang===$.lang&&Z.mtimeMs===$.mtimeMs&&Z.size===$.size&&Z.inDegree===$.inDegree&&Z.outDegree===$.outDegree;async function P5(Z,$,Q=m){for(let[X,H]of $.files){let B=Z.files.get(X);if(B&&V8(B,H))continue;let M={root:H.root,lang:H.lang,mtimeMs:H.mtimeMs,size:H.size,inDegree:H.inDegree,outDegree:H.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($8(f.path,J));for(let[X,H]of Z.edges)if(!$.edges.has(X))await Q.delete(u).where(F5(WZ(u.fromPath,H.from),WZ(u.toPath,H.to)));let V=[];for(let[X,H]of $.edges){let B=Z.edges.get(X);if(!B)V.push({fromPath:H.from,toPath:H.to,circular:H.circular});else if(B.circular!==H.circular)await Q.update(u).set({circular:H.circular}).where(F5(WZ(u.fromPath,H.from),WZ(u.toPath,H.to)))}if(V.length)await Q.insert(u).values(V);let K=await kZ(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 M8=/[/\\](node_modules|\.git|\.next|dist|build|__pycache__|target|\.venv|venv|\.beacon|\.playwright-mcp|generated|coverage)[/\\]/;function j8(Z){try{let $=AZ(Z,"beacon.config.json");if(R5($)){let Q=JSON.parse(K8($,"utf8"));if(Array.isArray(Q.roots)&&Q.roots.length)return Q.roots.map((J)=>G8(Z,J))}}catch{}return[Z]}function S5(Z){let $=j8(Z.path),Q=pZ(Z.id),J=rZ(JZ(Z.id)),V=a4($,Z.path);async function K(){let U=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))U.push(Y(R))}let O=[];for(let _ of U)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(U){return Y8(Z.path,U).split(/[\\/]/).join("/")}let X=null,H=!1,B=new Set,M=null,W=!1;async function L(){if(W){q();return}W=!0;try{if(await Q,H)X=null,H=!1;if(X===null){let N=await V.seed(),G=await E5(N,J);X=Q4(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 U=[...B];B.clear();let O=U.some((N)=>eZ(Y(N))),A=!1;for(let N of U)if(await V.applyChange(N))A=!0;if(A){let N=Q4(V.snapshot()),G=await P5(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(U){console.error(`[beacon-inline] error (${Z.name}):`,U instanceof Error?U.message:U)}finally{W=!1}}function q(){if(M)clearTimeout(M);M=setTimeout(L,600)}let j=[];for(let U of $)try{let O=X8(U,{recursive:!0,persistent:!0},(A,N)=>{if(!N){H=!0,q();return}let G=String(N);if(M8.test(`/${G}`))return;B.add(AZ(U,G)),q()});O.on("error",(A)=>console.error(`[beacon-inline] watcher error (${Z.name}):`,A)),j.push(O)}catch(O){console.error(`[beacon-inline] live watch unavailable for ${U} (${Z.name}):`,O instanceof Error?O.message:O)}return console.log(`[beacon-inline] watching ${Z.name} (${$.join(", ")}) \u2014 initial extract\u2026`),L(),{async stop(){if(M)clearTimeout(M);for(let U of j)U.close()}}}function H8(Z){let $=Z.limit??6,Q=Z.hardCap??12,J=new Map,V=0,K=new Set;function Y(U){let O=J.get(U);if(O)O.seq=++V}function X(U){if(J.has(U.id))return Y(U.id);if(!Z.exists(U.path))return;J.set(U.id,{handle:Z.start(U),seq:++V})}function H(){let U=null,O=1/0;for(let[A,N]of J){if(K.has(A))continue;if(N.seq<O)O=N.seq,U=A}if(U)J.get(U).handle.stop(),J.delete(U)}function B(){let U=Z.list().filter((O)=>Z.exists(O.path)).slice(0,$);K=new Set(U.map((O)=>O.id));for(let O of U)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(U){if(J.has(U))return Y(U);let O=Z.get(U);if(!O||!Z.exists(O.path))return;if(J.size>=Q)H();if(J.size>=Q)return;J.set(U,{handle:Z.start(O),seq:++V})}async function W(U){let O=J.get(U);if(!O)return;J.delete(U),await O.handle.stop()}function L(U){return J.has(U)}function q(){return[...J.keys()]}async function j(){await Promise.all([...J.values()].map((U)=>U.handle.stop())),J.clear()}return{reconcile:B,ensureWatcher:M,stopWatcher:W,isWatching:L,activeIds:q,stopAll:j}}var W8=H8({list:mZ,get:x,exists:U8,start:(Z)=>S5(Z)});async function v5(Z){await W8.stopWatcher(Z)}async function k5(Z){if(!x(Z))return{ok:!1,removed:!1,fallbackId:r(),error:"unknown workspace"};N4(Z),C4(Z),await v5(Z),z4(JZ(Z)),F4(Z);try{L8(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 J4=process.argv.slice(3),y5=J4.includes("--yes")||J4.includes("-y"),GZ=J4.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 TZ=(Z,$)=>{for(var Q in $)g5(Z,Q,{get:$[Q],enumerable:!0,configurable:!0,set:b5.bind($,Q)})};var V4=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var X4={};TZ(X4,{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 wZ,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 K4(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 K4(Q);if(await c5(p5(Q),{migrationsFolder:$}),await K4(Q)>Y)K=!0;return await a5(Q),{migrated:K}}finally{Q.close()}}var r5,o5,i5;var Y4=V4(async()=>{r5=wZ(wZ(wZ(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 h$(Z,$){d7(i7(Z),{recursive:!0});let Q=`${Z}.tmp`;try{o7(Q,$),n7(Q,Z)}catch(J){throw r7(Q,{force:!0}),J}}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 M4,mkdirSync as LZ,readFileSync as fZ,writeFileSync as uZ}from"fs";import{homedir as j4}from"os";import{basename as Q6,join as ZZ,parse as J6,resolve as G4}from"path";function a(){return process.env.BEACON_HOME||ZZ(j4(),".beacon")}function xZ(){return ZZ(a(),"workspaces.json")}function QZ(Z){return $6("sha256").update(Z).digest("hex").slice(0,12)}function gZ(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 U4(Z){let $=G4(Z);return $!==G4(j4())&&$!==J6($).root}function H4(){return ZZ(a(),"deleted.json")}function hZ(){try{let Z=JSON.parse(fZ(H4(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function W4(Z){LZ(a(),{recursive:!0}),uZ(H4(),JSON.stringify(Z,null,2))}function L4(Z){return hZ().includes(Z)}function C4(Z){let $=hZ();if(!$.includes(Z))W4([...$,Z])}function V6(Z){let $=hZ();if($.includes(Z))W4($.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(fZ(xZ(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function bZ(Z){LZ(a(),{recursive:!0}),uZ(xZ(),JSON.stringify(Z,null,2))}function mZ(){return CZ().sort((Z,$)=>$.lastOpenedAt.localeCompare(Z.lastOpenedAt))}function x(Z){return CZ().find(($)=>$.id===Z)??null}function B4(Z,$,Q=new Date().toISOString()){if(!U4(Z))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Z}`);let J=QZ(Z);if(L4(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((H)=>H.id===J),Y={id:J,path:Z,name:$||K?.name||Q6(Z),lastOpenedAt:Q},X=[Y,...V.filter((H)=>H.id!==J)];return LZ(n(J),{recursive:!0}),bZ(X),Y}function T8(Z,$){return V6(QZ(Z)),B4(Z,$)}function w8(Z,$=new Date().toISOString()){let Q=CZ(),J=Q.find((V)=>V.id===Z);if(!J)return;J.lastOpenedAt=$,bZ(Q)}function N4(Z){if(bZ(CZ().filter(($)=>$.id!==Z)),r()===Z)K6(mZ()[0]?.id??null)}function q4(){return ZZ(a(),"active")}function r(){try{return fZ(q4(),"utf8").trim()||null}catch{return null}}function K6(Z){LZ(a(),{recursive:!0}),uZ(q4(),Z??"")}function X6(){let Z=r();return Z?x(Z):null}function y8(){let Z=DZ()??r();return Z?x(Z):null}function f8(Z){return x(Z)?.path??null}function u8(){return M4(xZ())}var O4="beacon_ws";function A4(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 x8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=A4(Z,O4);if(Q&&x(Q))return Q;return null}var Y6="x-beacon-workspace-path";async function g8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=Z.headers.get(Y6);if(Q&&U4(Q)&&!L4(QZ(Q))&&(!$||QZ(Q)===$)){let V=B4(Q);return await pZ(V.id),V.id}let J=A4(Z,O4);if(J&&x(J))return J;return null}var _4=new e5;function G6(Z,$){return Z?_4.run(Z,$):$()}function DZ(){return _4.getStore()??null}var yZ=new Set;function D4(Z){yZ.delete(ZZ(n(Z),"db.sqlite"))}async function pZ(Z){let $=n(Z),Q=ZZ($,"db.sqlite"),J=M4(Q);if(J&&yZ.has(Q))return{ok:!0,created:!1,migrated:!1};try{LZ($,{recursive:!0});let{provisionDb:V}=await Y4().then(() => X4),K=await V(JZ(Z));return yZ.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 C8,readFileSync as B8}from"fs";import{resolve as w5}from"path";import{rmSync as L8}from"fs";import{drizzle as k6}from"drizzle-orm/libsql";import{createClient as T6}from"@libsql/client";var cZ={};TZ(cZ,{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 lZ={};TZ(lZ,{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={...cZ,...lZ};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 F4(Z){let $=T6({url:Z});return $.execute("PRAGMA foreign_keys = ON;"),$.execute("PRAGMA busy_timeout = 5000;"),k6($,{schema:w6})}var nZ=globalThis,dZ=nZ.dzDefault??F4(f6);nZ.dzDefault=dZ;var FZ=nZ.dzByUrl??=new Map;function rZ(Z){let $=FZ.get(Z);if(!$)$=F4(Z),FZ.set(Z,$);return $}function z4(Z){let $=FZ.get(Z);FZ.delete(Z);try{$?.$client?.close?.()}catch{}}function u6(){if(process.env.BEACON_REPO)return dZ;let Z=DZ()??r();if(!Z)return dZ;return rZ(JZ(Z))}var m=new Proxy({},{get(Z,$){let Q=u6(),J=Q[$];return typeof J==="function"?J.bind(Q):J}});import{existsSync as U8}from"fs";import{existsSync as R5,readFileSync as K8,watch as X8}from"fs";import{readFile as P5}from"fs/promises";import{join as AZ,relative as Y8,resolve as G8}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 oZ=[".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 oZ){let J=`${Z}${Q}`;if($.has(J))return J}for(let Q of oZ){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:oZ,specifiers:m6,resolve(Z,$,Q){let J=p6(Z,$,Q.fileSet,Q.tsAliases??[]);return J?[J]:[]}};import{dirname as P4,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 J=Z.length-Z.replace(/^\.+/,"").length,V=Z.slice(J),K=P4($);for(let X=1;X<J;X++)K=P4(K);let Y=V?c6(K,V.replace(/\./g,"/")):K;return S4(l6(Y).replace(/\\/g,"/"),Q.fileSet)}return S4(Z.replace(/\./g,"/"),Q.fileSet)}};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 iZ,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 sZ(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(iZ($),Z)).replace(/\\/g,"/"),Y=sZ(K,J);if(Y.length)return Y;if(Z.startsWith("./")&&!J7.has(T4($))){let X=w4(iZ($),T4($,".rs"),V);if(Y=sZ(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("/"):iZ($),X=Z.slice(6).split("/");for(let H of[X.join("/"),X.slice(0,-1).join("/")]){if(!H)continue;let B=sZ(`${Y}/${H}`,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((H,B,M)=>H&&M.indexOf(H)===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 H of X){if(Q.fileSet.has(H))return[H];for(let B of V){let M=H.endsWith(B)?H:`${H}${B}`;if(Q.fileSet.has(M))return[M];if(Q.fileSet.has(`${H}/index${B}`))return[`${H}/index${B}`]}}return[]}};var U7=[I4,v4,k4,f4,x4],zZ=new Map;for(let Z of U7)for(let $ of Z.extensions)zZ.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 aZ(Z){return zZ.get(g4(Z).toLowerCase())??null}function h4(Z){let $=g4(Z).toLowerCase();if(!zZ.has($))return null;return H7[$]??$.slice(1)}function tZ(){return new Set(zZ.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,tZ(),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 H=X[0];if(!H.endsWith("/*"))continue;let B=Y.slice(0,-1),M=b4(H.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 j=await d4(C);K.set(q,{path:q,abs:C,root:M||null,mtimeMs:j.mtimeMs,size:j.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 $=aZ(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((j)=>p(UZ(j))),J=p($?UZ($):Q.length===1?Q[0]:s4(Q)),V=new Map,K=new Map,Y=[],X=null;function H(){Y=[];for(let j of Q){let U=p(HZ(J,j));for(let O of i4(j))Y.push({from:O.from,to:[U,O.to].filter(Boolean).join("/")})}X=Q.map(EZ).find(Boolean)??EZ(J)}function B(j){let U=j.split("/");for(let A=0;A<U.length;A++){let N=U[A];if(!N||N.startsWith("."))return!0;if(A<U.length-1&&r4.has(N))return!0}let O=U[U.length-1];if(O.endsWith(".d.ts"))return!0;return!tZ().has(n4(O).toLowerCase())}function M(j){let U=p(UZ(j));for(let O of Q)if(U===O||U.startsWith(`${O}/`)){let A=U.slice(O.length).replace(/^\/+/,"");if(B(A))return null;return{path:p(HZ(J,U)),root:p(HZ(J,O))||null}}return null}function L(){let j={fileSet:new Set(V.keys()),tsAliases:Y,goModulePath:X},U=[...V.values()].sort((N,G)=>N.path.localeCompare(G.path)),O=[];for(let N of U){let G=aZ(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,j)){if(!y||y===N.path||D.has(y))continue;D.add(y),O.push({from:N.path,to:y})}}return{files:U.map((N)=>({path:N.path,lang:h4(N.path),root:N.root,mtimeMs:N.mtimeMs,size:N.size})),edges:O}}async function C(){let j=C7(),{metas:U,ctx:O}=await O7(Z,$,j);V.clear(),K.clear();for(let A of U)await j(),V.set(A.path,A),K.set(A.path,await p4(A));return Y=O.tsAliases??[],X=O.goModulePath??null,L()}async function q(j){let U=p(UZ(j));if(!Q.some((D)=>U===D||U.startsWith(`${D}/`)))return!1;let O=U.split("/").pop()??"";if(O==="tsconfig.json"||O==="go.mod"){let D=U.slice(0,U.length-O.length-1);if(Q.includes(D))return H(),!0;return!1}let A=M(j);if(!A)return!1;let N;try{N=await d4(U)}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:U,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]),H=[Y];for(let C=0;C<2&&X.size<25;C++){let q=[];for(let j of H)for(let U of J.get(j)??[]){if(X.has(U)||X.size>=25)continue;X.add(U),q.push(U)}H=q}let B=new Set,M=new Set;for(let C of X){let q=Z.content(C);if(!q)continue;for(let j of $){if(!B.has(j)&&V.get(j).test(q))B.add(j);if(!M.has(j)&&K.get(j).test(q))M.add(j)}}let L=[];for(let C of $){let q=B.has(C),j=M.has(C);if(!q&&!j)continue;L.push({table:Z.tableVars[C],access:q&&j?"read-write":j?"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 PZ(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,H;while(H=X.exec(Q)){let L=H.index+H[0].length-1,C=_7(Q,L);if(C===null)continue;let q=L+C.length+2,j=Q.slice(q).match(/^\s*=\s*(\w+)\s*\(/);if(!j||j[1]!=="mapped_column")continue;Y.push({colName:H[1],pyType:C,argsAt:q+j[0].length-1})}let B=/(\w+)\s*=\s*(mapped_column|Column)\s*\(/g;while(H=B.exec(Q))Y.push({colName:H[1],pyType:"",argsAt:H.index+H[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=PZ(Q,L.argsAt),q=/primary_key\s*=\s*True/.test(C)||void 0,j=/nullable\s*=\s*False/.test(C)?!1:!0,U=C.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(V.push({name:L.colName,type:e4(C,L.pyType),isPk:q,isFk:U?!0:void 0,nullable:j}),U)K.push({column:L.colName,toTable:U[1],toColumn:U[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=PZ(Z,V.index+V[0].indexOf("("));if(!/\bmetadata\b/.test(Y)||!/\bColumn\s*\(/.test(Y))continue;let X=[],H=/\bColumn\s*\(/g,B;while(B=H.exec(Y)){let M=PZ(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,j=M.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(X.push({name:L,type:e4(M,""),isPk:C,isFk:j?!0:void 0,nullable:q}),j)Q.push({fromTable:K,fromColumn:L,toTable:j[1],toColumn:j[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 H=F7(X.content);Q.tables.push(...H.tables),Q.relations.push(...H.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),j=D7(L[C].name,L[C].bases,q);$.set(j.name,j)}}if(![...$.values()].some((X)=>X.tableName)&&!Q.tables.length)return{tables:[],relations:[]};let J=(X,H=new Set)=>{if(H.has(X.name))return[];H.add(X.name);let B=[];for(let M of X.bases){let L=$.get(M);if(L&&!L.tableName)B.push(...J(L,H))}return B.push(...X.columns),B},V=[],K=[];for(let X of $.values()){if(!X.tableName)continue;let H=J(X),B=new Map;for(let j of H)if(!B.has(j.name))B.set(j.name,j);let M=[...B.values()],L=(j)=>M.splice(M.findIndex((U)=>U.name===j),1)[0],C=M.some((j)=>j.name==="id")?L("id"):null,q=["created_at","updated_at","deleted_at"].filter((j)=>M.some((U)=>U.name===j)).map((j)=>L(j));V.push({name:X.tableName,columns:[...C?[C]:[],...M,...q]});for(let j of X.fks)K.push({fromTable:X.tableName,fromColumn:j.column,toTable:j.toTable,toColumn:j.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,H=[];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,j=/^(String|Int|BigInt|Float|Decimal|Boolean|DateTime|Json|Bytes)(\[\])?\??$/.test(C),U=q.match(/@relation\([^)]*fields:\s*\[(\w+)\][^)]*references:\s*\[(\w+)\]/);if(U)Q.push({fromTable:X,fromColumn:U[1],toTable:C.replace(/[?[\]]/g,""),toColumn:U[2]});if(!j)continue;H.push({name:L,type:E7(C),isPk:/@id\b/.test(q)||void 0,isFk:/@relation\b/.test(q)||void 0,nullable:C.endsWith("?")})}if(H.length)$.push({name:X,columns:H})}}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 H=K.content.indexOf("{",X.index+X[0].length);if(H<0)continue;let B=R7(K.content,H),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 j=B.slice(C.at,L[q+1]?.at??B.length),U=PZ(B,C.argOpen),A=U.match(/^\s*["']([^"']+)["']/)?.[1]??C.prop,N=j.match(/\.references\(\s*\(\)\s*=>\s*(\w+)\.(\w+)/);if(M.columns.push({name:A,type:P7(C.builder,U),isPk:/\.primaryKey\(\)/.test(j)||void 0,isFk:N?!0:void 0,nullable:/\.notNull\(\)/.test(j)?!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 eZ(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(eZ).slice(0,$)}import{z as d}from"zod";import{and as D5,eq as WZ,inArray as $8,notInArray as Q8}from"drizzle-orm";import{z as E}from"zod";import{and as s7,eq as vZ,inArray as $4,notInArray as a7,or as t7,sql as e7}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,RZ=14,H5=120,OZ=170,p7=2560;var SZ=(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 H=Q?.get(K)??0,B=Q?.get(V)??0;if(H<B)V=K;else if(H===B&&$.get(K).localeCompare($.get(V))<0)V=K}return V}function Z4(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=Z4(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?RZ+G*YZ:0)+50},Y=Array.from(new Set(Z.map((N)=>SZ(N.domain)))),X=Y.filter((N)=>N!=="\u2014").sort(),H=Y.includes("\u2014")?[...X,"\u2014"]:X,B=[];for(let N of H){let G=Z.filter((S)=>SZ(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,j=0,U=0,O=0,A=0;for(let N of B){if(j>0&&j+N.w>L)U+=O+OZ,j=0,O=0;let G=Z.filter((_)=>N.tableLocal.has(_.id));for(let _ of G){let D=N.tableLocal.get(_.id),R=j+D.x,y=U+D.y;C.set(_.id,{x:R,y}),(J.get(_.id)??[]).forEach((P,F)=>{q.set(P.id,{x:R,y:y+$Z(_.columnCount)+RZ+F*YZ})})}O=Math.max(O,N.h),A=Math.max(A,U+N.h),j+=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=Z4($,Q),V=new Map;for(let q of Q){let j=J.get(q.id);if(j)V.set(j,(V.get(j)??0)+1)}let K=(q)=>{let j=V.get(q.id)??0;return q.y+$Z(q.columnCount)+(j?RZ+j*YZ:0)},Y=SZ(Z.domain),X=$.filter((q)=>SZ(q.domain)===Y);if(!X.length){let q=$.length?Math.max(...$.map(K),...Q.map((j)=>j.y+YZ)):0;return{x:0,y:$.length||Q.length?q+OZ:0}}let H=Math.min(...X.map((q)=>q.x)),B=X.map((q)=>Math.max(0,Math.round((q.x-H)/320))),M=Math.min(12,Math.max(...B)+1),L=Array(M).fill(Math.min(...X.map((q)=>q.y)));X.forEach((q,j)=>{let U=Math.min(B[j],M-1);L[U]=Math.max(L[U],K(q)+50)});let C=0;for(let q=1;q<M;q++)if(L[q]<L[C])C=q;return{x:H+C*320,y:L[C]}}function B5(Z,$,Q){let J=Z4($,[...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),H=K.y+$Z(K.columnCount)+RZ,B=X.length?Math.max(...X.map((M)=>M.y))+YZ:H;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 Z8=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 kZ(Z=m){let[$]=await Z.insert(s).values({id:"singleton",version:1}).onConflictDoUpdate({target:s.id,set:{version:e7`${s.version} + 1`}}).returning();return $.version}async function _5(Z,$=m,Q={}){let J=Z8.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?s7(vZ(I.source,"INTROSPECTION"),a7(I.name,Y)):vZ(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}}}}),H=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=H.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(vZ(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 j=[...q.values()];if(j.length)await $.delete(l).where(t7($4(l.fromTableId,j),$4(l.toTableId,j)));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 U=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)=>!U.has(`${D.method} ${D.path}`)).map((D)=>D.id);if(_.length)await $.delete(v).where($4(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(vZ(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 kZ($);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,H=[],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 j=q[q.length-1],U=Q.get(j.v)??[];if(j.iter<U.length){let O=U[j.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(j.v,Math.min(V.get(j.v),J.get(O)))}else{if(V.get(j.v)===J.get(j.v)){let A=0,N;do N=Y.pop(),K.delete(N),X.set(N,M),A++;while(N!==j.v);H.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(j.v)))}}}let L=new Set;for(let C of $){let q=X.get(C.from);if(q!==void 0&&q===X.get(C.to)&&H[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,H=new Map;for(let L of K)H.set(L.from,(H.get(L.from)??0)+1),X.set(L.to,(X.get(L.to)??0)+1);await $.delete(f).where(Q8(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:H.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 kZ($);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 J8=(Z,$)=>`${Z}\x00${$}`;function Q4(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 H=new Map;for(let M of $.files)H.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(J8(M.from,M.to),{from:M.from,to:M.to,circular:K.has(`${M.from}|${M.to}`)});return{files:H,edges:B}}var V8=(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,H]of $.files){let B=Z.files.get(X);if(B&&V8(B,H))continue;let M={root:H.root,lang:H.lang,mtimeMs:H.mtimeMs,size:H.size,inDegree:H.inDegree,outDegree:H.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($8(f.path,J));for(let[X,H]of Z.edges)if(!$.edges.has(X))await Q.delete(u).where(D5(WZ(u.fromPath,H.from),WZ(u.toPath,H.to)));let V=[];for(let[X,H]of $.edges){let B=Z.edges.get(X);if(!B)V.push({fromPath:H.from,toPath:H.to,circular:H.circular});else if(B.circular!==H.circular)await Q.update(u).set({circular:H.circular}).where(D5(WZ(u.fromPath,H.from),WZ(u.toPath,H.to)))}if(V.length)await Q.insert(u).values(V);let K=await kZ(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 M8=/[/\\](node_modules|\.git|\.next|dist|build|__pycache__|target|\.venv|venv|\.beacon|\.playwright-mcp|generated|coverage)[/\\]/;function j8(Z){try{let $=AZ(Z,"beacon.config.json");if(R5($)){let Q=JSON.parse(K8($,"utf8"));if(Array.isArray(Q.roots)&&Q.roots.length)return Q.roots.map((J)=>G8(Z,J))}}catch{}return[Z]}function S5(Z){let $=j8(Z.path),Q=pZ(Z.id),J=rZ(JZ(Z.id)),V=a4($,Z.path);async function K(){let U=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))U.push(Y(R))}let O=[];for(let _ of U)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(U){return Y8(Z.path,U).split(/[\\/]/).join("/")}let X=null,H=!1,B=new Set,M=null,L=!1;async function C(){if(L){q();return}L=!0;try{if(await Q,H)X=null,H=!1;if(X===null){let N=await V.seed(),G=await E5(N,J);X=Q4(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 U=[...B];B.clear();let O=U.some((N)=>eZ(Y(N))),A=!1;for(let N of U)if(await V.applyChange(N))A=!0;if(A){let N=Q4(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(U){console.error(`[beacon-inline] error (${Z.name}):`,U instanceof Error?U.message:U)}finally{L=!1}}function q(){if(M)clearTimeout(M);M=setTimeout(C,600)}let j=[];for(let U of $)try{let O=X8(U,{recursive:!0,persistent:!0},(A,N)=>{if(!N){H=!0,q();return}let G=String(N);if(M8.test(`/${G}`))return;B.add(AZ(U,G)),q()});O.on("error",(A)=>console.error(`[beacon-inline] watcher error (${Z.name}):`,A)),j.push(O)}catch(O){console.error(`[beacon-inline] live watch unavailable for ${U} (${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 U of j)U.close()}}}function H8(Z){let $=Z.limit??6,Q=Z.hardCap??12,J=new Map,V=0,K=new Set;function Y(U){let O=J.get(U);if(O)O.seq=++V}function X(U){if(J.has(U.id))return Y(U.id);if(!Z.exists(U.path))return;J.set(U.id,{handle:Z.start(U),seq:++V})}function H(){let U=null,O=1/0;for(let[A,N]of J){if(K.has(A))continue;if(N.seq<O)O=N.seq,U=A}if(U)J.get(U).handle.stop(),J.delete(U)}function B(){let U=Z.list().filter((O)=>Z.exists(O.path)).slice(0,$);K=new Set(U.map((O)=>O.id));for(let O of U)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(U){if(J.has(U))return Y(U);let O=Z.get(U);if(!O||!Z.exists(O.path))return;if(J.size>=Q)H();if(J.size>=Q)return;J.set(U,{handle:Z.start(O),seq:++V})}async function L(U){let O=J.get(U);if(!O)return;J.delete(U),await O.handle.stop()}function C(U){return J.has(U)}function q(){return[...J.keys()]}async function j(){await Promise.all([...J.values()].map((U)=>U.handle.stop())),J.clear()}return{reconcile:B,ensureWatcher:M,stopWatcher:L,isWatching:C,activeIds:q,stopAll:j}}var W8=H8({list:mZ,get:x,exists:U8,start:(Z)=>S5(Z)});async function v5(Z){await W8.stopWatcher(Z)}async function k5(Z){if(!x(Z))return{ok:!1,removed:!1,fallbackId:r(),error:"unknown workspace"};N4(Z),C4(Z),await v5(Z),z4(JZ(Z)),D4(Z);try{L8(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 J4=process.argv.slice(3),y5=J4.includes("--yes")||J4.includes("-y"),GZ=J4.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 N8(){if(!GZ)return x(QZ(gZ(process.cwd())));if(/^[0-9a-f]{12}$/.test(GZ)){let Z=x(GZ);if(Z)return Z}return x(QZ(gZ(w5(GZ))))}var i=N8();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 q8(Z){try{let{pid:$,port:Q}=JSON.parse(B8(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 q8(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
|
@@ -28,8 +28,9 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
28
28
|
|
|
29
29
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
30
30
|
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
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
|
+
- **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
|
+
- **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.
|
|
34
35
|
- **conventions**: 3\u20138 concrete rules a contributor MUST follow \u2014 build/test commands, where code goes, patterns, things easy to get wrong. Infer from actual files, not assumptions.
|
|
35
36
|
- **snapshot** (optional but encouraged): \`{ tables, relations, endpoints }\` for the existing database. If the project uses Prisma, read \`prisma/schema.prisma\`. If SQLAlchemy, read the model files. If Django, read \`models.py\`. If you find no obvious schema source, skip the snapshot \u2014 don't fabricate.
|
|
@@ -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\`). 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). 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
|
|
|
@@ -166,6 +167,8 @@ When listing endpoints, give each \`uses: [{ table, access }]\` so the endpoint\
|
|
|
166
167
|
|
|
167
168
|
EVERY feature MUST carry \`category\` (e.g. AUTH | SEARCH | DATA | INTEL | BILLING | \u2026; \`cluster\` is accepted as an alias) and \`priority\` (0 = P0 critical, 1 = P1 high, 2 = P2 medium, 3 = P3 low). Beacon REJECTS a plan whose features omit either \u2014 \`beacon_propose_plan\` returns the list of what's missing, and an ExitPlanMode \`\`\`beacon block is denied \u2014 so set both on every feature instead of relying on defaults.
|
|
168
169
|
|
|
170
|
+
When the workspace HAS A FRONTEND (Beacon knows \u2014 the agent set \`hasFrontend\` at init, or frontend files were detected), every feature must ALSO carry \`layer\`: \`"frontend" | "backend" | "fullstack"\` \u2014 which side of the stack the work lands on. Plans omitting it are REJECTED the same way category/priority are. It works on every surface that creates roadmap cards (\`beacon_propose_plan\`, the \`\`\`beacon block, \`beacon_start_feature\`, \`beacon_add_subtasks\` \u2014 sub-tasks default to the parent's layer) and on architecture components (\`beacon_describe_feature\` / \`beacon_init_persist\`). In a pure-backend repo, never set it \u2014 the boards don't show it there.
|
|
171
|
+
|
|
169
172
|
REUSE before you create. Call \`beacon_map\` to see the features + categories that already exist. Beacon HARD-BLOCKS a feature that duplicates an existing one (it returns the existing feature to use instead) and one created without a category \u2014 so don't re-create work that's already on the board, and reuse an existing category rather than a near-synonym. \`category\` is the ONLY domain field. \`front\` (in \`beacon_start_feature\`) nests a feature UNDER an existing parent feature \u2014 it is NOT a domain tag; a \`front\` that matches no real feature is rejected.
|
|
170
173
|
|
|
171
174
|
When listing features, give each \`dependsOn: ["Other feature title", \u2026]\` for any feature that must ship after another in the same plan. Beacon draws these as "depends on" links so the roadmap shows the dependency chain instead of loose, disconnected cards.
|
package/dist/lib/assets.js
CHANGED
|
@@ -27,8 +27,9 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
27
27
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
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
|
+
- **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
|
+
- **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"\`).
|
|
32
33
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
33
34
|
- **conventions**: 3\u20138 concrete rules a contributor MUST follow \u2014 build/test commands, where code goes, patterns, things easy to get wrong. Infer from actual files, not assumptions.
|
|
34
35
|
- **snapshot** (optional but encouraged): \`{ tables, relations, endpoints }\` for the existing database. If the project uses Prisma, read \`prisma/schema.prisma\`. If SQLAlchemy, read the model files. If Django, read \`models.py\`. If you find no obvious schema source, skip the snapshot \u2014 don't fabricate.
|
|
@@ -86,7 +87,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
86
87
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
87
88
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
88
89
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
89
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`). 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.
|
|
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.
|
|
90
91
|
|
|
91
92
|
## What you should NOT do
|
|
92
93
|
|
|
@@ -165,6 +166,8 @@ When listing endpoints, give each \`uses: [{ table, access }]\` so the endpoint\
|
|
|
165
166
|
|
|
166
167
|
EVERY feature MUST carry \`category\` (e.g. AUTH | SEARCH | DATA | INTEL | BILLING | \u2026; \`cluster\` is accepted as an alias) and \`priority\` (0 = P0 critical, 1 = P1 high, 2 = P2 medium, 3 = P3 low). Beacon REJECTS a plan whose features omit either \u2014 \`beacon_propose_plan\` returns the list of what's missing, and an ExitPlanMode \`\`\`beacon block is denied \u2014 so set both on every feature instead of relying on defaults.
|
|
167
168
|
|
|
169
|
+
When the workspace HAS A FRONTEND (Beacon knows \u2014 the agent set \`hasFrontend\` at init, or frontend files were detected), every feature must ALSO carry \`layer\`: \`"frontend" | "backend" | "fullstack"\` \u2014 which side of the stack the work lands on. Plans omitting it are REJECTED the same way category/priority are. It works on every surface that creates roadmap cards (\`beacon_propose_plan\`, the \`\`\`beacon block, \`beacon_start_feature\`, \`beacon_add_subtasks\` \u2014 sub-tasks default to the parent's layer) and on architecture components (\`beacon_describe_feature\` / \`beacon_init_persist\`). In a pure-backend repo, never set it \u2014 the boards don't show it there.
|
|
170
|
+
|
|
168
171
|
REUSE before you create. Call \`beacon_map\` to see the features + categories that already exist. Beacon HARD-BLOCKS a feature that duplicates an existing one (it returns the existing feature to use instead) and one created without a category \u2014 so don't re-create work that's already on the board, and reuse an existing category rather than a near-synonym. \`category\` is the ONLY domain field. \`front\` (in \`beacon_start_feature\`) nests a feature UNDER an existing parent feature \u2014 it is NOT a domain tag; a \`front\` that matches no real feature is rejected.
|
|
169
172
|
|
|
170
173
|
When listing features, give each \`dependsOn: ["Other feature title", \u2026]\` for any feature that must ship after another in the same plan. Beacon draws these as "depends on" links so the roadmap shows the dependency chain instead of loose, disconnected cards.
|
|
@@ -27,8 +27,9 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
27
27
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
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
|
+
- **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
|
+
- **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"\`).
|
|
32
33
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
33
34
|
- **conventions**: 3\u20138 concrete rules a contributor MUST follow \u2014 build/test commands, where code goes, patterns, things easy to get wrong. Infer from actual files, not assumptions.
|
|
34
35
|
- **snapshot** (optional but encouraged): \`{ tables, relations, endpoints }\` for the existing database. If the project uses Prisma, read \`prisma/schema.prisma\`. If SQLAlchemy, read the model files. If Django, read \`models.py\`. If you find no obvious schema source, skip the snapshot \u2014 don't fabricate.
|
|
@@ -86,7 +87,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
86
87
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
87
88
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
88
89
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
89
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`). 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.
|
|
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.
|
|
90
91
|
|
|
91
92
|
## What you should NOT do
|
|
92
93
|
|
|
@@ -165,6 +166,8 @@ When listing endpoints, give each \`uses: [{ table, access }]\` so the endpoint\
|
|
|
165
166
|
|
|
166
167
|
EVERY feature MUST carry \`category\` (e.g. AUTH | SEARCH | DATA | INTEL | BILLING | \u2026; \`cluster\` is accepted as an alias) and \`priority\` (0 = P0 critical, 1 = P1 high, 2 = P2 medium, 3 = P3 low). Beacon REJECTS a plan whose features omit either \u2014 \`beacon_propose_plan\` returns the list of what's missing, and an ExitPlanMode \`\`\`beacon block is denied \u2014 so set both on every feature instead of relying on defaults.
|
|
167
168
|
|
|
169
|
+
When the workspace HAS A FRONTEND (Beacon knows \u2014 the agent set \`hasFrontend\` at init, or frontend files were detected), every feature must ALSO carry \`layer\`: \`"frontend" | "backend" | "fullstack"\` \u2014 which side of the stack the work lands on. Plans omitting it are REJECTED the same way category/priority are. It works on every surface that creates roadmap cards (\`beacon_propose_plan\`, the \`\`\`beacon block, \`beacon_start_feature\`, \`beacon_add_subtasks\` \u2014 sub-tasks default to the parent's layer) and on architecture components (\`beacon_describe_feature\` / \`beacon_init_persist\`). In a pure-backend repo, never set it \u2014 the boards don't show it there.
|
|
170
|
+
|
|
168
171
|
REUSE before you create. Call \`beacon_map\` to see the features + categories that already exist. Beacon HARD-BLOCKS a feature that duplicates an existing one (it returns the existing feature to use instead) and one created without a category \u2014 so don't re-create work that's already on the board, and reuse an existing category rather than a near-synonym. \`category\` is the ONLY domain field. \`front\` (in \`beacon_start_feature\`) nests a feature UNDER an existing parent feature \u2014 it is NOT a domain tag; a \`front\` that matches no real feature is rejected.
|
|
169
172
|
|
|
170
173
|
When listing features, give each \`dependsOn: ["Other feature title", \u2026]\` for any feature that must ship after another in the same plan. Beacon draws these as "depends on" links so the roadmap shows the dependency chain instead of loose, disconnected cards.
|
|
@@ -27,8 +27,9 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
27
27
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
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
|
+
- **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
|
+
- **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"\`).
|
|
32
33
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
33
34
|
- **conventions**: 3\u20138 concrete rules a contributor MUST follow \u2014 build/test commands, where code goes, patterns, things easy to get wrong. Infer from actual files, not assumptions.
|
|
34
35
|
- **snapshot** (optional but encouraged): \`{ tables, relations, endpoints }\` for the existing database. If the project uses Prisma, read \`prisma/schema.prisma\`. If SQLAlchemy, read the model files. If Django, read \`models.py\`. If you find no obvious schema source, skip the snapshot \u2014 don't fabricate.
|
|
@@ -86,7 +87,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
86
87
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
87
88
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
88
89
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
89
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`). 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.
|
|
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.
|
|
90
91
|
|
|
91
92
|
## What you should NOT do
|
|
92
93
|
|
|
@@ -165,6 +166,8 @@ When listing endpoints, give each \`uses: [{ table, access }]\` so the endpoint\
|
|
|
165
166
|
|
|
166
167
|
EVERY feature MUST carry \`category\` (e.g. AUTH | SEARCH | DATA | INTEL | BILLING | \u2026; \`cluster\` is accepted as an alias) and \`priority\` (0 = P0 critical, 1 = P1 high, 2 = P2 medium, 3 = P3 low). Beacon REJECTS a plan whose features omit either \u2014 \`beacon_propose_plan\` returns the list of what's missing, and an ExitPlanMode \`\`\`beacon block is denied \u2014 so set both on every feature instead of relying on defaults.
|
|
167
168
|
|
|
169
|
+
When the workspace HAS A FRONTEND (Beacon knows \u2014 the agent set \`hasFrontend\` at init, or frontend files were detected), every feature must ALSO carry \`layer\`: \`"frontend" | "backend" | "fullstack"\` \u2014 which side of the stack the work lands on. Plans omitting it are REJECTED the same way category/priority are. It works on every surface that creates roadmap cards (\`beacon_propose_plan\`, the \`\`\`beacon block, \`beacon_start_feature\`, \`beacon_add_subtasks\` \u2014 sub-tasks default to the parent's layer) and on architecture components (\`beacon_describe_feature\` / \`beacon_init_persist\`). In a pure-backend repo, never set it \u2014 the boards don't show it there.
|
|
170
|
+
|
|
168
171
|
REUSE before you create. Call \`beacon_map\` to see the features + categories that already exist. Beacon HARD-BLOCKS a feature that duplicates an existing one (it returns the existing feature to use instead) and one created without a category \u2014 so don't re-create work that's already on the board, and reuse an existing category rather than a near-synonym. \`category\` is the ONLY domain field. \`front\` (in \`beacon_start_feature\`) nests a feature UNDER an existing parent feature \u2014 it is NOT a domain tag; a \`front\` that matches no real feature is rejected.
|
|
169
172
|
|
|
170
173
|
When listing features, give each \`dependsOn: ["Other feature title", \u2026]\` for any feature that must ship after another in the same plan. Beacon draws these as "depends on" links so the roadmap shows the dependency chain instead of loose, disconnected cards.
|