trybeacon 0.1.38 → 0.1.39
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 +19 -19
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +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/context/route.js +1 -1
- package/.next/server/app/api/ingest/route.js +1 -1
- package/.next/server/app/api/init/route.js +1 -1
- package/.next/server/app/api/plan/approve/route.js +1 -1
- package/.next/server/app/api/project-meta/route.js +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +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_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_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/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_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +1 -1
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +19 -19
- package/.next/server/chunks/1341.js +1 -1
- package/.next/server/chunks/3622.js +1 -1
- package/.next/server/chunks/4378.js +1 -1
- package/.next/server/chunks/7844.js +1 -0
- package/.next/server/chunks/9683.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/1237-9d3991189a7950bf.js +1 -0
- package/.next/static/chunks/app/map/page-0b80331a4e6a28d1.js +1 -0
- package/.next/static/chunks/app/plan/{page-928529a405650444.js → page-6f5b996737bcedc4.js} +1 -1
- package/.next/trace +38 -38
- package/.next/trace-build +1 -1
- package/dist/bin/doctor.js +2 -1
- package/dist/bin/hook.js +2 -1
- package/dist/bin/mcp.js +13 -12
- package/dist/bin/plan.js +2 -1
- package/dist/bin/remove.js +2 -2
- package/dist/bin/uninstall.js +2 -1
- package/dist/lib/assets.js +2 -1
- package/dist/lib/codex-install.js +2 -1
- package/dist/lib/global-install.js +2 -1
- package/drizzle/0007_brainy_george_stacy.sql +1 -0
- package/drizzle/meta/0007_snapshot.json +1773 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +7 -2
- package/.next/server/chunks/2713.js +0 -1
- package/.next/static/chunks/8015-9cd5b2ea19e9aa77.js +0 -1
- package/.next/static/chunks/app/map/page-b51abf8d1c3ec85a.js +0 -1
- /package/.next/static/{sJAp6c61WGwLy0STzGlio → FcKcgfUAfLhrW5iXsBe6p}/_buildManifest.js +0 -0
- /package/.next/static/{sJAp6c61WGwLy0STzGlio → FcKcgfUAfLhrW5iXsBe6p}/_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 wZ=(Z,$)=>{for(var Q in $)g5(Z,Q,{get:$[Q],enumerable:!0,configurable:!0,set:b5.bind($,Q)})};var K4=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var Y4={};wZ(Y4,{provisionDb:()=>t5});import{createClient as m5}from"@libsql/client";import{drizzle as p5}from"drizzle-orm/libsql";import{migrate as c5}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as l5}from"drizzle-orm/migrator";import{dirname as yZ,join as d5}from"path";import{fileURLToPath as n5}from"url";async function _Z(Z,$){return(await Z.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[$]})).rows.length>0}async function s5(Z,$){let Q=await Z.execute(`PRAGMA table_info("${$}")`);return new Set(Q.rows.map((J)=>String(J.name)))}async function X4(Z){if(!await _Z(Z,"__drizzle_migrations"))return 0;let $=await Z.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number($.rows[0]?.n??0)}async function a5(Z){for(let[$,Q]of Object.entries(i5)){if(!await _Z(Z,$))continue;let J=await s5(Z,$);for(let V of Q){if(!J.has(V))continue;await Z.execute(`UPDATE "${$}" SET "${V}" = CAST((julianday("${V}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${V}") = 'text'`)}}}async function t5(Z,$=o5){let Q=m5({url:Z});try{await Q.execute("PRAGMA journal_mode = WAL;"),await Q.execute("PRAGMA foreign_keys = ON;"),await Q.execute("PRAGMA busy_timeout = 5000;");let J=await _Z(Q,"__drizzle_migrations"),V=await _Z(Q,"Node"),K=!1;if(V&&!J){let X=l5({migrationsFolder:$})[0];if(X)await Q.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Q.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),K=!0}let Y=await X4(Q);if(await c5(p5(Q),{migrationsFolder:$}),await X4(Q)>Y)K=!0;return await a5(Q),{migrated:K}}finally{Q.close()}}var r5,o5,i5;var G4=K4(async()=>{r5=yZ(yZ(yZ(n5(import.meta.url)))),o5=process.env.BEACON_MIGRATIONS_DIR||d5(r5,"drizzle"),i5={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{mkdirSync as d7,renameSync as n7,rmSync as r7,writeFileSync as o7}from"fs";import{dirname as i7}from"path";function s7(Z,$){d7(i7(Z),{recursive:!0});let Q=`${Z}.tmp`;try{o7(Q,$),n7(Q,Z)}catch(J){throw r7(Q,{force:!0}),J}}function a7(Z,$,Q=!1){s7(Z,JSON.stringify($,null,Q?2:void 0))}var q5=()=>{};import{AsyncLocalStorage as e5}from"async_hooks";import{spawnSync as Z6}from"child_process";import{createHash as $6}from"crypto";import{existsSync as j4,mkdirSync as LZ,readFileSync as uZ,writeFileSync as xZ}from"fs";import{homedir as U4}from"os";import{basename as Q6,join as ZZ,parse as J6,resolve as M4}from"path";function a(){return process.env.BEACON_HOME||ZZ(U4(),".beacon")}function gZ(){return ZZ(a(),"workspaces.json")}function QZ(Z){return $6("sha256").update(Z).digest("hex").slice(0,12)}function hZ(Z=process.cwd()){let $=Z6("git",["rev-parse","--show-toplevel"],{cwd:Z,stdio:["ignore","pipe","ignore"]});if($.status===0){let Q=$.stdout?.toString().trim();if(Q)return Q}return Z}function H4(Z){let $=M4(Z);return $!==M4(U4())&&$!==J6($).root}function W4(){return ZZ(a(),"deleted.json")}function bZ(){try{let Z=JSON.parse(uZ(W4(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function L4(Z){LZ(a(),{recursive:!0}),xZ(W4(),JSON.stringify(Z,null,2))}function C4(Z){return bZ().includes(Z)}function B4(Z){let $=bZ();if(!$.includes(Z))L4([...$,Z])}function V6(Z){let $=bZ();if($.includes(Z))L4($.filter((Q)=>Q!==Z))}function n(Z){return ZZ(a(),Z)}function JZ(Z){return`file:${ZZ(n(Z),"db.sqlite")}`}function CZ(){try{let Z=JSON.parse(uZ(gZ(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function mZ(Z){LZ(a(),{recursive:!0}),xZ(gZ(),JSON.stringify(Z,null,2))}function pZ(){return CZ().sort((Z,$)=>$.lastOpenedAt.localeCompare(Z.lastOpenedAt))}function x(Z){return CZ().find(($)=>$.id===Z)??null}function N4(Z,$,Q=new Date().toISOString()){if(!H4(Z))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Z}`);let J=QZ(Z);if(C4(J))throw Error(`beacon: workspace ${J} (${Z}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let V=CZ(),K=V.find((j)=>j.id===J),Y={id:J,path:Z,name:$||K?.name||Q6(Z),lastOpenedAt:Q},X=[Y,...V.filter((j)=>j.id!==J)];return LZ(n(J),{recursive:!0}),mZ(X),Y}function y8(Z,$){return V6(QZ(Z)),N4(Z,$)}function f8(Z,$=new Date().toISOString()){let Q=CZ(),J=Q.find((V)=>V.id===Z);if(!J)return;J.lastOpenedAt=$,mZ(Q)}function q4(Z){if(mZ(CZ().filter(($)=>$.id!==Z)),r()===Z)K6(pZ()[0]?.id??null)}function O4(){return ZZ(a(),"active")}function r(){try{return uZ(O4(),"utf8").trim()||null}catch{return null}}function K6(Z){LZ(a(),{recursive:!0}),xZ(O4(),Z??"")}function X6(){let Z=r();return Z?x(Z):null}function u8(){let Z=DZ()??r();return Z?x(Z):null}function x8(Z){return x(Z)?.path??null}function g8(){return j4(gZ())}var A4="beacon_ws";function _4(Z,$){let Q=Z.headers.get("cookie");if(!Q)return null;for(let J of Q.split(";")){let V=J.indexOf("=");if(V===-1)continue;if(J.slice(0,V).trim()===$)return decodeURIComponent(J.slice(V+1).trim())}return null}function h8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=_4(Z,A4);if(Q&&x(Q))return Q;return null}var Y6="x-beacon-workspace-path";async function b8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=Z.headers.get(Y6);if(Q&&H4(Q)&&!C4(QZ(Q))&&(!$||QZ(Q)===$)){let V=N4(Q);return await cZ(V.id),V.id}let J=_4(Z,A4);if(J&&x(J))return J;return null}var D4=new e5;function G6(Z,$){return Z?D4.run(Z,$):$()}function DZ(){return D4.getStore()??null}var fZ=new Set;function F4(Z){fZ.delete(ZZ(n(Z),"db.sqlite"))}async function cZ(Z){let $=n(Z),Q=ZZ($,"db.sqlite"),J=j4(Q);if(J&&fZ.has(Q))return{ok:!0,created:!1,migrated:!1};try{LZ($,{recursive:!0});let{provisionDb:V}=await G4().then(() => Y4),K=await V(JZ(Z));return fZ.add(Q),{ok:!0,created:!J,migrated:J&&K.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{existsSync as N8,readFileSync as q8}from"fs";import{resolve as w5}from"path";import{rmSync as B8}from"fs";import{drizzle as k6}from"drizzle-orm/libsql";import{createClient as T6}from"@libsql/client";var lZ={};wZ(lZ,{tag:()=>jZ,syncState:()=>s,projectMeta:()=>L6,note:()=>U6,nodeTags:()=>KZ,nodeFile:()=>BZ,node:()=>T,endpointTable:()=>o,endpoint:()=>v,edge:()=>VZ,draftTable:()=>c,draftRelation:()=>XZ,draftColumn:()=>qZ,dbTable:()=>I,dbRelation:()=>l,dbColumn:()=>e,codeFileEdge:()=>u,codeFile:()=>f,bugFlag:()=>NZ,boardAnnotation:()=>H6,appSetting:()=>W6});import{sqliteTable as w,index as k,foreignKey as M6,text as W,integer as z,real as b,uniqueIndex as t,primaryKey as j6}from"drizzle-orm/sqlite-core";import{createId as h}from"@paralleldrive/cuid2";var T=w("Node",{id:W().primaryKey().$defaultFn(()=>h()),view:W().notNull(),kind:W().default("FEATURE").notNull(),cluster:W(),layer:W(),title:W().notNull(),role:W(),plain:W(),status:W().default("PENDING").notNull(),priority:z().default(2).notNull(),progress:z().default(0).notNull(),x:b().default(0).notNull(),y:b().default(0).notNull(),sourceRef:W(),externalId:W(),source:W().default("MANUAL").notNull(),planId:W(),parentId:W(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Node_cluster_idx").on(Z.cluster),k("Node_parentId_idx").on(Z.parentId),k("Node_view_idx").on(Z.view),M6(()=>({columns:[Z.parentId],foreignColumns:[Z.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),BZ=w("NodeFile",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),path:W().notNull()},(Z)=>[t("NodeFile_nodeId_path_key").on(Z.nodeId,Z.path),k("NodeFile_nodeId_idx").on(Z.nodeId)]),jZ=w("Tag",{id:W().primaryKey().$defaultFn(()=>h()),label:W().notNull(),color:W()},(Z)=>[t("Tag_label_key").on(Z.label)]),VZ=w("Edge",{id:W().primaryKey().$defaultFn(()=>h()),fromId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:W().default("DEPENDS").notNull(),label:W(),sourceHandle:W(),targetHandle:W()},(Z)=>[t("Edge_fromId_toId_kind_key").on(Z.fromId,Z.toId,Z.kind),k("Edge_toId_idx").on(Z.toId),k("Edge_fromId_idx").on(Z.fromId)]),KZ=w("_NodeTags",{a:W("A").notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),b:W("B").notNull().references(()=>jZ.id,{onDelete:"cascade",onUpdate:"cascade"})},(Z)=>[t("_NodeTags_AB_unique").on(Z.a,Z.b),k("_NodeTags_B_index").on(Z.b)]),U6=w("Note",{id:W().primaryKey().$defaultFn(()=>h()),title:W().default("Untitled").notNull(),body:W().default("").notNull(),ord:b().default(0).notNull(),pinned:z({mode:"boolean"}).default(!1).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Note_updatedAt_idx").on(Z.updatedAt)]),H6=w("BoardAnnotation",{id:W().primaryKey().$defaultFn(()=>h()),targetKind:W().notNull(),targetId:W().notNull(),columnName:W(),body:W().default("").notNull(),x:b(),y:b(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("BoardAnnotation_target_idx").on(Z.targetId)]),NZ=w("BugFlag",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),by:W().notNull(),note:W().notNull(),resolvedAt:z({mode:"timestamp_ms"}),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[k("BugFlag_nodeId_idx").on(Z.nodeId)]),I=w("DbTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("DbTable_domain_idx").on(Z.domain),t("DbTable_name_key").on(Z.name)]),e=w("DbColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[t("DbColumn_tableId_name_key").on(Z.tableId,Z.name),k("DbColumn_tableId_idx").on(Z.tableId)]),l=w("DbRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DbRelation_toTableId_idx").on(Z.toTableId),k("DbRelation_fromTableId_idx").on(Z.fromTableId)]),v=w("Endpoint",{id:W().primaryKey().$defaultFn(()=>h()),method:W().notNull(),path:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[t("Endpoint_method_path_key").on(Z.method,Z.path),k("Endpoint_domain_idx").on(Z.domain)]),o=w("EndpointTable",{id:W().primaryKey().$defaultFn(()=>h()),endpointId:W().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:W().notNull().references(()=>I.id,{onDelete:"cascade",onUpdate:"cascade"}),access:W().default("read").notNull()},(Z)=>[t("EndpointTable_endpointId_tableId_key").on(Z.endpointId,Z.tableId),k("EndpointTable_tableId_idx").on(Z.tableId)]),c=w("DraftTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[t("DraftTable_name_key").on(Z.name)]),qZ=w("DraftColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[k("DraftColumn_tableId_idx").on(Z.tableId)]),XZ=w("DraftRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DraftRelation_toTableId_idx").on(Z.toTableId),k("DraftRelation_fromTableId_idx").on(Z.fromTableId)]),f=w("CodeFile",{path:W().primaryKey(),root:W(),lang:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),mtimeMs:b(),size:z(),inDegree:z().default(0).notNull(),outDegree:z().default(0).notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=w("CodeFileEdge",{fromPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:z({mode:"boolean"}).default(!1).notNull()},(Z)=>[k("CodeFileEdge_circular_idx").on(Z.circular),k("CodeFileEdge_toPath_idx").on(Z.toPath),k("CodeFileEdge_fromPath_idx").on(Z.fromPath),j6({columns:[Z.fromPath,Z.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),s=w("SyncState",{id:W().primaryKey().default("singleton"),version:z().default(0).notNull(),codeGraphSyncedAt:z({mode:"timestamp_ms"}),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),W6=w("AppSetting",{id:W().primaryKey().default("singleton"),editor:W().default("auto").notNull(),currentFeatureId:W(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),L6=w("ProjectMeta",{id:W().primaryKey().default("singleton"),overview:W(),conventions:W().default("[]").notNull(),hasFrontend:z({mode:"boolean"}),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var dZ={};wZ(dZ,{tagRelations:()=>q6,nodeTagsRelations:()=>O6,nodeRelations:()=>C6,nodeFileRelations:()=>B6,endpointTableRelations:()=>E6,endpointRelations:()=>z6,edgeRelations:()=>A6,draftTableRelations:()=>I6,draftRelationRelations:()=>R6,draftColumnRelations:()=>P6,dbTableRelations:()=>_6,dbRelationRelations:()=>F6,dbColumnRelations:()=>D6,codeFileRelations:()=>S6,codeFileEdgeRelations:()=>v6,bugFlagRelations:()=>N6});import{relations as g}from"drizzle-orm";var C6=g(T,({one:Z,many:$})=>({files:$(BZ),bugFlags:$(NZ),nodeTags:$(KZ),edgesOut:$(VZ,{relationName:"EdgeFrom"}),edgesIn:$(VZ,{relationName:"EdgeTo"}),parent:Z(T,{fields:[T.parentId],references:[T.id],relationName:"NodeTree"}),children:$(T,{relationName:"NodeTree"})})),B6=g(BZ,({one:Z})=>({node:Z(T,{fields:[BZ.nodeId],references:[T.id]})})),N6=g(NZ,({one:Z})=>({node:Z(T,{fields:[NZ.nodeId],references:[T.id]})})),q6=g(jZ,({many:Z})=>({nodeTags:Z(KZ)})),O6=g(KZ,({one:Z})=>({node:Z(T,{fields:[KZ.a],references:[T.id]}),tag:Z(jZ,{fields:[KZ.b],references:[jZ.id]})})),A6=g(VZ,({one:Z})=>({from:Z(T,{fields:[VZ.fromId],references:[T.id],relationName:"EdgeFrom"}),to:Z(T,{fields:[VZ.toId],references:[T.id],relationName:"EdgeTo"})})),_6=g(I,({many:Z})=>({columns:Z(e),fksOut:Z(l,{relationName:"FkFrom"}),fksIn:Z(l,{relationName:"FkTo"}),usages:Z(o)})),D6=g(e,({one:Z})=>({table:Z(I,{fields:[e.tableId],references:[I.id]})})),F6=g(l,({one:Z})=>({fromTable:Z(I,{fields:[l.fromTableId],references:[I.id],relationName:"FkFrom"}),toTable:Z(I,{fields:[l.toTableId],references:[I.id],relationName:"FkTo"})})),z6=g(v,({many:Z})=>({tables:Z(o)})),E6=g(o,({one:Z})=>({endpoint:Z(v,{fields:[o.endpointId],references:[v.id]}),table:Z(I,{fields:[o.tableId],references:[I.id]})})),I6=g(c,({many:Z})=>({columns:Z(qZ),fksOut:Z(XZ,{relationName:"DraftFkFrom"}),fksIn:Z(XZ,{relationName:"DraftFkTo"})})),P6=g(qZ,({one:Z})=>({table:Z(c,{fields:[qZ.tableId],references:[c.id]})})),R6=g(XZ,({one:Z})=>({fromTable:Z(c,{fields:[XZ.fromTableId],references:[c.id],relationName:"DraftFkFrom"}),toTable:Z(c,{fields:[XZ.toTableId],references:[c.id],relationName:"DraftFkTo"})})),S6=g(f,({many:Z})=>({edgesOut:Z(u,{relationName:"CFEFrom"}),edgesIn:Z(u,{relationName:"CFETo"})})),v6=g(u,({one:Z})=>({fromFile:Z(f,{fields:[u.fromPath],references:[f.path],relationName:"CFEFrom"}),toFile:Z(f,{fields:[u.toPath],references:[f.path],relationName:"CFETo"})}));var w6={...lZ,...dZ};function y6(){let Z=process.env.DATABASE_URL;if(Z&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test(Z))return Z;return"file:./dev.db"}var f6=y6();function z4(Z){let $=T6({url:Z});return $.execute("PRAGMA foreign_keys = ON;"),$.execute("PRAGMA busy_timeout = 5000;"),k6($,{schema:w6})}var rZ=globalThis,nZ=rZ.dzDefault??z4(f6);rZ.dzDefault=nZ;var FZ=rZ.dzByUrl??=new Map;function oZ(Z){let $=FZ.get(Z);if(!$)$=z4(Z),FZ.set(Z,$);return $}function E4(Z){let $=FZ.get(Z);FZ.delete(Z);try{$?.$client?.close?.()}catch{}}function u6(){if(process.env.BEACON_REPO)return nZ;let Z=DZ()??r();if(!Z)return nZ;return oZ(JZ(Z))}var m=new Proxy({},{get(Z,$){let Q=u6(),J=Q[$];return typeof J==="function"?J.bind(Q):J}});import{existsSync as W8}from"fs";import{existsSync as R5,readFileSync as Y8,watch as G8}from"fs";import{readFile as P5}from"fs/promises";import{join as AZ,relative as M8,resolve as j8}from"path";import{existsSync as c4,readFileSync as l4}from"fs";import{readdir as W7,readFile as L7,stat as d4}from"fs/promises";import{extname as n4,join as PZ,relative as HZ,resolve as UZ}from"path";import{extname as g4}from"path";import{dirname as x6,resolve as g6}from"path";var iZ=[".ts",".tsx",".js",".jsx",".mjs",".cjs"],h6=[/(?:^|[\n;])\s*(?:import|export)[^'"`\n]{0,4000}?from\s*['"]([^'"`]+)['"]/g,/(?:^|[\n;])\s*import\s*['"]([^'"`]+)['"]/g,/\brequire\(\s*['"]([^'"`]+)['"]\s*\)/g,/\bimport\(\s*['"]([^'"`]+)['"]\s*\)/g];function b6(Z){return Z.split(/[\\/]/).join("/")}function I4(Z,$){if($.has(Z))return Z;for(let Q of iZ){let J=`${Z}${Q}`;if($.has(J))return J}for(let Q of iZ){let J=`${Z}/index${Q}`;if($.has(J))return J}return null}function m6(Z){let $=new Set;for(let Q of h6)for(let J of Z.matchAll(Q))$.add(J[1]);return $}function p6(Z,$,Q,J){if(Z.startsWith(".")){let V=g6("/",x6($),Z),K=b6(V).replace(/^\//,"");return I4(K,Q)}for(let V of J)if(Z.startsWith(V.from)){let K=Z.slice(V.from.length),Y=V.to?`${V.to}/${K}`:K,X=I4(Y,Q);if(X)return X}return null}var P4={id:"ts",extensions:iZ,specifiers:m6,resolve(Z,$,Q){let J=p6(Z,$,Q.fileSet,Q.tsAliases??[]);return J?[J]:[]}};import{dirname as zZ,join as c6,normalize as l6}from"path";var d6=[".py",".pyi"],R4=[/(?:^|[\n;])\s*from\s+(\.*[\w.]*)\s+import\b/g,/(?:^|[\n;])\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/g];function S4(Z,$){for(let Q of[`${Z}.py`,`${Z}/__init__.py`,`${Z}.pyi`])if($.has(Q))return[Q];return[]}function n6(Z){let $=new Set;for(let Q of Z.matchAll(R4[0])){let J=Q[1].trim();if(J)$.add(J)}for(let Q of Z.matchAll(R4[1]))for(let J of Q[1].split(/\s*,\s*/)){let V=J.trim().split(/\s+as\s+/)[0].trim();if(V)$.add(V)}return $}var v4={id:"python",extensions:d6,specifiers:n6,resolve(Z,$,Q){if(Z.startsWith(".")){let Y=Z.length-Z.replace(/^\.+/,"").length,X=Z.slice(Y),j=zZ($);for(let M=1;M<Y;M++)j=zZ(j);let B=X?c6(j,X.replace(/\./g,"/")):j;return S4(l6(B).replace(/\\/g,"/"),Q.fileSet)}let J=Z.replace(/\./g,"/"),V=[],K=zZ($);while(K&&K!=="."&&K!=="/")V.push(K),K=zZ(K);V.push("");for(let Y of V){let X=S4(Y?`${Y}/${J}`:J,Q.fileSet);if(X.length)return X}return[]}};import{dirname as r6}from"path";var o6=[".go"],i6=/(?:^|[\n;])\s*import\s+(?:[\w.]+\s+)?"([^"]+)"/g,s6=/(?:^|[\n;])\s*import\s*\(([\s\S]*?)\)/g,a6=/"([^"]+)"/g;function t6(Z){let $=new Set;for(let Q of Z.matchAll(i6))$.add(Q[1]);for(let Q of Z.matchAll(s6))for(let J of Q[1].matchAll(a6))$.add(J[1]);return $}var k4={id:"go",extensions:o6,resolve(Z,$,Q){let J=Q.goModulePath;if(!J)return[];let V=null;if(Z===J)V="";else if(Z.startsWith(`${J}/`))V=Z.slice(J.length+1);if(V===null)return[];let K=[];for(let Y of Q.fileSet){if(!Y.endsWith(".go"))continue;let X=r6(Y);if(V===""&&X==="."||X===V)K.push(Y)}return K.sort()},specifiers:t6};import{basename as T4,dirname as sZ,join as w4,normalize as y4}from"path";var e6=[".rs"],Z7=/(?:^|[\n;])\s*(?:pub\s+)?mod\s+(\w+)\s*;/g,$7=/(?:^|[\n;])\s*(?:pub\s+)?use\s+([\w:]+)/g;function Q7(Z){let $=Z.split("::").filter((Q)=>Q&&Q!=="*");if(!$.length)return"";if($[0]==="crate")return["crate",...$.slice(1)].join("/");if($[0]==="super")return["..",...$.slice(1)].join("/");if($[0]==="self")return[".",...$.slice(1)].join("/");return $.join("/")}function aZ(Z,$){for(let Q of[`${Z}.rs`,`${Z}/mod.rs`])if($.has(Q))return[Q];return[]}var J7=new Set(["mod.rs","lib.rs","main.rs"]);function V7(Z){let $=new Set;for(let Q of Z.matchAll(Z7))$.add(`./${Q[1]}`);for(let Q of Z.matchAll($7)){let J=Q7(Q[1]);if(J)$.add(J)}return $}var f4={id:"rust",extensions:e6,specifiers:V7,resolve(Z,$,Q){let J=Q.fileSet;if(Z.startsWith("./")||Z.startsWith("../")){let V=Z.replace(/^\.\//,""),K=y4(w4(sZ($),Z)).replace(/\\/g,"/"),Y=aZ(K,J);if(Y.length)return Y;if(Z.startsWith("./")&&!J7.has(T4($))){let X=w4(sZ($),T4($,".rs"),V);if(Y=aZ(y4(X).replace(/\\/g,"/"),J),Y.length)return Y}return[]}if(Z.startsWith("crate/")){let V=$.split("/"),K=V.lastIndexOf("src"),Y=K>=0?V.slice(0,K+1).join("/"):sZ($),X=Z.slice(6).split("/");for(let j of[X.join("/"),X.slice(0,-1).join("/")]){if(!j)continue;let B=aZ(`${Y}/${j}`,J);if(B.length)return B}return[]}return[]}};import{dirname as K7,extname as X7,join as Y7,normalize as G7}from"path";var u4=[".swift",".java",".rb",".kt",".kts",".cs",".php",".scala",".c",".h",".cpp",".hpp",".cc",".hh",".m",".mm",".ex",".exs",".lua",".dart",".vue",".svelte"],M7=[/\b(?:require_relative|require|include|import|use|using|from)\s*\(?\s*['"]([^'"`\n]+)['"]/g,/(?:^|[\n;])\s*import\s+([\w.]+)/g,/(?:^|[\n;])\s*from\s+([\w.]+)\s+import\b/g,/(?:^|[\n;])\s*using\s+([\w.]+)\s*;/g,/(?:^|[\n;])\s*use\s+([\w\\]+)/g,/#\s*include\s*[<"]([^>"\n]+)[>"]/g];function j7(Z){let $=new Set;for(let Q of M7)for(let J of Z.matchAll(Q)){let V=J[1].trim();if(V)$.add(V)}return $}var x4={id:"fallback",extensions:u4,specifiers:j7,resolve(Z,$,Q){let V=[X7($).toLowerCase(),...u4].filter((j,B,M)=>j&&M.indexOf(j)===B),K=Z.includes("/")||Z.includes("\\"),Y=Z.startsWith(".")||K?Z.replace(/\\/g,"/"):Z.replace(/[.:]+/g,"/"),X=[G7(Y7(K7($),Y)).replace(/\\/g,"/"),Y.replace(/^\.\//,"")];for(let j of X){if(Q.fileSet.has(j))return[j];for(let B of V){let M=j.endsWith(B)?j:`${j}${B}`;if(Q.fileSet.has(M))return[M];if(Q.fileSet.has(`${j}/index${B}`))return[`${j}/index${B}`]}}return[]}};var U7=[P4,v4,k4,f4,x4],EZ=new Map;for(let Z of U7)for(let $ of Z.extensions)EZ.set($,Z);var H7={".ts":"ts",".tsx":"ts",".js":"js",".jsx":"js",".mjs":"js",".cjs":"js",".py":"py",".pyi":"py",".go":"go",".rs":"rs",".swift":"swift",".java":"java",".rb":"ruby",".kt":"kotlin",".kts":"kotlin",".cs":"csharp",".php":"php",".scala":"scala",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cc":"cpp",".hh":"cpp",".m":"objc",".mm":"objc",".ex":"elixir",".exs":"elixir",".lua":"lua",".dart":"dart",".vue":"vue",".svelte":"svelte"};function tZ(Z){return EZ.get(g4(Z).toLowerCase())??null}function h4(Z){let $=g4(Z).toLowerCase();if(!EZ.has($))return null;return H7[$]??$.slice(1)}function eZ(){return new Set(EZ.keys())}var r4=new Set(["node_modules",".git",".next","dist","build","__pycache__","target",".venv","venv","env",".turbo","coverage",".beacon",".playwright-mcp","generated","migrations","drizzle","alembic","migrate"]);function C7(Z=5){let $=performance.now();return async()=>{if(performance.now()-$>Z)await new Promise((Q)=>setImmediate(Q)),$=performance.now()}}var B7=()=>Promise.resolve();async function o4(Z,$,Q,J,V){let K;try{K=await W7($,{withFileTypes:!0})}catch{return}for(let Y of K){if(Y.name.startsWith("."))continue;if(r4.has(Y.name))continue;let X=PZ($,Y.name);if(Y.isDirectory()){await o4(Z,X,Q,J,V);continue}if(!Y.isFile())continue;if(Y.name.endsWith(".d.ts"))continue;if(!Q.has(n4(Y.name).toLowerCase()))continue;J.push(HZ(Z,X))}await V()}async function N7(Z,$=B7){let Q=[];return await o4(Z,Z,eZ(),Q,$),Q.map((J)=>J.split(/[\\/]/).join("/")).sort()}function q7(Z){try{return JSON.parse(Z)}catch{}let $=Z.replace(/\/\*[^"]*?\*\//g,"").replace(/(^|[^:"])\/\/.*$/gm,"$1").replace(/,\s*([}\]])/g,"$1");return JSON.parse($)}function b4(Z){return Z.replace(/^\.\/?/,"").replace(/\/$/,"")}function i4(Z){let $=PZ(Z,"tsconfig.json");if(!c4($))return[];let Q;try{Q=q7(l4($,"utf8"))}catch{return[]}let J=Q.compilerOptions?.paths??{},V=b4(Q.compilerOptions?.baseUrl??"."),K=[];for(let[Y,X]of Object.entries(J)){if(!Y.endsWith("/*")||!X.length)continue;let j=X[0];if(!j.endsWith("/*"))continue;let B=Y.slice(0,-1),M=b4(j.slice(0,-1)),L=[V,M].filter(Boolean).join("/");K.push({from:B,to:L})}return K}function IZ(Z){let $=PZ(Z,"go.mod");if(!c4($))return null;try{let Q=/^\s*module\s+(\S+)/m.exec(l4($,"utf8"));return Q?Q[1]:null}catch{return null}}function p(Z){return Z.split(/[\\/]/).join("/")}function s4(Z){if(Z.length===1)return Z[0];let $=Z.map((V)=>p(V).split("/")),Q=$[0],J=0;for(;J<Q.length;J++)if(!$.every((V)=>V[J]===Q[J]))break;return Q.slice(0,J).join("/")||"/"}async function O7(Z,$,Q){let J=(Array.isArray(Z)?Z:[Z]).map((B)=>p(UZ(B))),V=p($?UZ($):J.length===1?J[0]:s4(J)),K=new Map,Y=[];for(let B of J){let M=p(HZ(V,B));for(let L of i4(B))Y.push({from:L.from,to:[M,L.to].filter(Boolean).join("/")});for(let L of await N7(B,Q)){let C=p(PZ(B,L)),q=p(HZ(V,C));if(K.has(q))continue;try{let U=await d4(C);K.set(q,{path:q,abs:C,root:M||null,mtimeMs:U.mtimeMs,size:U.size})}catch{}await Q()}}let X=J.map(IZ).find(Boolean)??IZ(V);return{metas:[...K.values()].sort((B,M)=>B.path.localeCompare(M.path)),ctx:{fileSet:new Set(K.keys()),tsAliases:Y,goModulePath:X}}}var m4=50000;function A7(Z){let $=0;for(let Q=0;Q<Z.length;Q++)if(Z.charCodeAt(Q)===10){if(Q-$>m4)return!0;$=Q+1}return Z.length-$>m4}async function p4(Z){let $=tZ(Z.path);if(!$||Z.size>200000)return new Set;try{let Q=await L7(Z.abs,"utf8");if(A7(Q))return new Set;return $.specifiers(Q)}catch{return new Set}}function a4(Z,$){let Q=(Array.isArray(Z)?Z:[Z]).map((U)=>p(UZ(U))),J=p($?UZ($):Q.length===1?Q[0]:s4(Q)),V=new Map,K=new Map,Y=[],X=null;function j(){Y=[];for(let U of Q){let H=p(HZ(J,U));for(let O of i4(U))Y.push({from:O.from,to:[H,O.to].filter(Boolean).join("/")})}X=Q.map(IZ).find(Boolean)??IZ(J)}function B(U){let H=U.split("/");for(let A=0;A<H.length;A++){let N=H[A];if(!N||N.startsWith("."))return!0;if(A<H.length-1&&r4.has(N))return!0}let O=H[H.length-1];if(O.endsWith(".d.ts"))return!0;return!eZ().has(n4(O).toLowerCase())}function M(U){let H=p(UZ(U));for(let O of Q)if(H===O||H.startsWith(`${O}/`)){let A=H.slice(O.length).replace(/^\/+/,"");if(B(A))return null;return{path:p(HZ(J,H)),root:p(HZ(J,O))||null}}return null}function L(){let U={fileSet:new Set(V.keys()),tsAliases:Y,goModulePath:X},H=[...V.values()].sort((N,G)=>N.path.localeCompare(G.path)),O=[];for(let N of H){let G=tZ(N.path);if(!G)continue;let _=K.get(N.path)??new Set,D=new Set;for(let R of _)for(let y of G.resolve(R,N.path,U)){if(!y||y===N.path||D.has(y))continue;D.add(y),O.push({from:N.path,to:y})}}return{files:H.map((N)=>({path:N.path,lang:h4(N.path),root:N.root,mtimeMs:N.mtimeMs,size:N.size})),edges:O}}async function C(){let U=C7(),{metas:H,ctx:O}=await O7(Z,$,U);V.clear(),K.clear();for(let A of H)await U(),V.set(A.path,A),K.set(A.path,await p4(A));return Y=O.tsAliases??[],X=O.goModulePath??null,L()}async function q(U){let H=p(UZ(U));if(!Q.some((D)=>H===D||H.startsWith(`${D}/`)))return!1;let O=H.split("/").pop()??"";if(O==="tsconfig.json"||O==="go.mod"){let D=H.slice(0,H.length-O.length-1);if(Q.includes(D))return j(),!0;return!1}let A=M(U);if(!A)return!1;let N;try{N=await d4(H)}catch{let D=V.delete(A.path);return K.delete(A.path),D}let G=V.get(A.path);if(G&&G.mtimeMs===N.mtimeMs&&G.size===N.size)return!1;let _={path:A.path,abs:H,root:A.root,mtimeMs:N.mtimeMs,size:N.size};return V.set(A.path,_),K.set(A.path,await p4(_)),!0}return{seed:C,applyChange:q,snapshot:L}}function t4(Z){let $=Object.keys(Z.tableVars),Q=new Map;if(!$.length){for(let Y of Z.routeFiles)Q.set(Y,[]);return Q}let J=new Map;for(let Y of Z.edges){let X=J.get(Y.from)??[];X.push(Y.to),J.set(Y.from,X)}let V=new Map($.map((Y)=>[Y,new RegExp(`(?:query\\.${Y}\\b|\\.from\\(\\s*${Y}\\b)`)])),K=new Map($.map((Y)=>[Y,new RegExp(`(?:insert|update|delete)\\(\\s*${Y}\\b`)]));for(let Y of Z.routeFiles){let X=new Set([Y]),j=[Y];for(let C=0;C<2&&X.size<25;C++){let q=[];for(let U of j)for(let H of J.get(U)??[]){if(X.has(H)||X.size>=25)continue;X.add(H),q.push(H)}j=q}let B=new Set,M=new Set;for(let C of X){let q=Z.content(C);if(!q)continue;for(let U of $){if(!B.has(U)&&V.get(U).test(q))B.add(U);if(!M.has(U)&&K.get(U).test(q))M.add(U)}}let L=[];for(let C of $){let q=B.has(C),U=M.has(C);if(!q&&!U)continue;L.push({table:Z.tableVars[C],access:q&&U?"read-write":U?"write":"read"})}Q.set(Y,L)}return Q}function e4(Z,$){if(/_JSON_OR_JSONB|\bJSONB\b|\bJSON\b/.test(Z))return"jsonb";let Q=Z.match(/\b(GUID|Uuid|UUID|String|Text|DateTime|Date|Time|BigInteger|SmallInteger|Integer|Boolean|Float|Numeric|Decimal|Vector|TSVECTOR|LargeBinary|Enum)\b\s*(\([^)]*\))?/);if(Q){let K=Q[2]??"",Y=K.match(/\d+/)?.[0];switch(Q[1]){case"GUID":case"Uuid":case"UUID":return"uuid";case"String":return Y?`varchar(${Y})`:"varchar";case"Text":return"text";case"DateTime":return/timezone\s*=\s*True/.test(K)?"timestamptz":"timestamp";case"Date":return"date";case"Time":return"time";case"BigInteger":return"bigint";case"SmallInteger":return"smallint";case"Integer":return"integer";case"Boolean":return"boolean";case"Float":return"float";case"Numeric":case"Decimal":return"numeric";case"Vector":return Y?`vector(${Y})`:"vector";case"TSVECTOR":return"tsvector";case"LargeBinary":return"bytea";case"Enum":return"varchar"}}let J=$.replace(/\s*\|\s*None/g,"").trim(),V=J.match(/^Optional\[([\s\S]*)\]$/);if(V)J=V[1].trim();if(/uuid/i.test(J))return"uuid";if(/datetime/i.test(J))return"timestamptz";if(/\bint\b/i.test(J))return"integer";if(/\bbool\b/i.test(J))return"boolean";if(/\bfloat\b/.test(J)&&!/\blist\b/.test(J))return"float";if(/\bdict\b|\blist\b|\bAny\b/.test(J))return"jsonb";return"text"}function RZ(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="(")Q++;else if(Z[J]===")"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function _7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="[")Q++;else if(Z[J]==="]"){if(Q--,Q===0)return Z.slice($+1,J)}return null}function D7(Z,$,Q){let J=Q.match(/__tablename__\s*=\s*["']([^"']+)["']/)?.[1],V=[],K=[],Y=[],X=/(\w+)\s*:\s*Mapped\s*\[/g,j;while(j=X.exec(Q)){let L=j.index+j[0].length-1,C=_7(Q,L);if(C===null)continue;let q=L+C.length+2,U=Q.slice(q).match(/^\s*=\s*(\w+)\s*\(/);if(!U||U[1]!=="mapped_column")continue;Y.push({colName:j[1],pyType:C,argsAt:q+U[0].length-1})}let B=/(\w+)\s*=\s*(mapped_column|Column)\s*\(/g;while(j=B.exec(Q))Y.push({colName:j[1],pyType:"",argsAt:j.index+j[0].length-1});Y.sort((L,C)=>L.argsAt-C.argsAt);let M=new Set;for(let L of Y){if(M.has(L.colName)||L.colName==="__tablename__")continue;M.add(L.colName);let C=RZ(Q,L.argsAt),q=/primary_key\s*=\s*True/.test(C)||void 0,U=/nullable\s*=\s*False/.test(C)?!1:!0,H=C.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(V.push({name:L.colName,type:e4(C,L.pyType),isPk:q,isFk:H?!0:void 0,nullable:U}),H)K.push({column:L.colName,toTable:H[1],toColumn:H[2]})}return{name:Z,bases:$,tableName:J,columns:V,fks:K}}function F7(Z){let $=[],Q=[],J=/\bTable\s*(\()\s*["']([^"']+)["']\s*,/g,V;while(V=J.exec(Z)){let K=V[2],Y=RZ(Z,V.index+V[0].indexOf("("));if(!/\bmetadata\b/.test(Y)||!/\bColumn\s*\(/.test(Y))continue;let X=[],j=/\bColumn\s*\(/g,B;while(B=j.exec(Y)){let M=RZ(Y,B.index+B[0].length-1),L=M.match(/^\s*["'](\w+)["']\s*,/)?.[1];if(!L)continue;let C=/primary_key\s*=\s*True/.test(M)||void 0,q=/nullable\s*=\s*False/.test(M)?!1:!0,U=M.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(X.push({name:L,type:e4(M,""),isPk:C,isFk:U?!0:void 0,nullable:q}),U)Q.push({fromTable:K,fromColumn:L,toTable:U[1],toColumn:U[2]})}if(X.length)$.push({name:K,columns:X})}return{tables:$,relations:Q}}function z7(Z){let $=new Map,Q={tables:[],relations:[]};for(let X of Z){if(!X.path.endsWith(".py"))continue;if(!/mapped_column\s*\(|__tablename__|\bTable\s*\(\s*["']/.test(X.content))continue;let j=F7(X.content);Q.tables.push(...j.tables),Q.relations.push(...j.relations);let B=/^class\s+(\w+)\s*\(([^)]*)\)\s*:/gm,M,L=[];while(M=B.exec(X.content))L.push({name:M[1],bases:M[2].split(",").map((C)=>C.trim().split(/[.[]/)[0]).filter(Boolean),at:M.index});for(let C=0;C<L.length;C++){let q=X.content.slice(L[C].at,L[C+1]?.at??X.content.length),U=D7(L[C].name,L[C].bases,q);$.set(U.name,U)}}if(![...$.values()].some((X)=>X.tableName)&&!Q.tables.length)return{tables:[],relations:[]};let J=(X,j=new Set)=>{if(j.has(X.name))return[];j.add(X.name);let B=[];for(let M of X.bases){let L=$.get(M);if(L&&!L.tableName)B.push(...J(L,j))}return B.push(...X.columns),B},V=[],K=[];for(let X of $.values()){if(!X.tableName)continue;let j=J(X),B=new Map;for(let U of j)if(!B.has(U.name))B.set(U.name,U);let M=[...B.values()],L=(U)=>M.splice(M.findIndex((H)=>H.name===U),1)[0],C=M.some((U)=>U.name==="id")?L("id"):null,q=["created_at","updated_at","deleted_at"].filter((U)=>M.some((H)=>H.name===U)).map((U)=>L(U));V.push({name:X.tableName,columns:[...C?[C]:[],...M,...q]});for(let U of X.fks)K.push({fromTable:X.tableName,fromColumn:U.column,toTable:U.toTable,toColumn:U.toColumn})}let Y=new Set(V.map((X)=>X.name));for(let X of Q.tables)if(!Y.has(X.name))V.push(X);return K.push(...Q.relations.filter((X)=>!Y.has(X.fromTable))),{tables:V,relations:K}}function E7(Z){let $=Z.replace(/[?[\]]/g,"");return{String:"text",Int:"integer",BigInt:"bigint",Float:"float",Decimal:"numeric",Boolean:"boolean",DateTime:"timestamptz",Json:"jsonb",Bytes:"bytea"}[$]??$.toLowerCase()}function I7(Z){let $=[],Q=[];for(let J of Z){if(!J.path.endsWith(".prisma"))continue;let V=/model\s+(\w+)\s*\{([\s\S]*?)\}/g,K;while(K=V.exec(J.content)){let Y=K[1],X=K[2].match(/@@map\(\s*["']([^"']+)["']\s*\)/)?.[1]??Y,j=[];for(let B of K[2].split(`
|
|
4
|
-
`)){let M=B.trim().match(/^(\w+)\s+(\w+(?:\[\])?\??)\s*(.*)$/);if(!M||/^@@/.test(B.trim()))continue;let[,L,C,q]=M,U=/^(String|Int|BigInt|Float|Decimal|Boolean|DateTime|Json|Bytes)(\[\])?\??$/.test(C),H=q.match(/@relation\([^)]*fields:\s*\[(\w+)\][^)]*references:\s*\[(\w+)\]/);if(H)Q.push({fromTable:X,fromColumn:H[1],toTable:C.replace(/[?[\]]/g,""),toColumn:H[2]});if(!U)continue;j.push({name:L,type:E7(C),isPk:/@id\b/.test(q)||void 0,isFk:/@relation\b/.test(q)||void 0,nullable:C.endsWith("?")})}if(j.length)$.push({name:X,columns:j})}}return{tables:$,relations:Q}}function P7(Z,$){if(/mode:\s*["']timestamp/.test($))return"timestamp";if(/mode:\s*["']boolean["']/.test($))return"boolean";if(/mode:\s*["']json["']/.test($))return"jsonb";return Z}function R7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="{")Q++;else if(Z[J]==="}"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function S7(Z){let $=[],Q=/(\w+)\s*:\s*(text|integer|real|blob|numeric|varchar|boolean|timestamp|serial|uuid|json|jsonb)\s*\(/g;for(let K of Z){if(!/\.(ts|tsx|mts|cts)$/.test(K.path))continue;if(!/\b(?:sqliteTable|pgTable|mysqlTable)\s*\(/.test(K.content))continue;let Y=/(?:export\s+)?const\s+(\w+)\s*=\s*(?:sqliteTable|pgTable|mysqlTable)\s*\(\s*["']([^"']+)["']\s*,/g,X;while(X=Y.exec(K.content)){let j=K.content.indexOf("{",X.index+X[0].length);if(j<0)continue;let B=R7(K.content,j),M={varName:X[1],tableName:X[2],columns:[],colByProp:new Map,fks:[]},L=[];Q.lastIndex=0;for(let C of B.matchAll(Q))L.push({prop:C[1],builder:C[2],at:C.index,argOpen:C.index+C[0].length-1});L.forEach((C,q)=>{let U=B.slice(C.at,L[q+1]?.at??B.length),H=RZ(B,C.argOpen),A=H.match(/^\s*["']([^"']+)["']/)?.[1]??C.prop,N=U.match(/\.references\(\s*\(\)\s*=>\s*(\w+)\.(\w+)/);if(M.columns.push({name:A,type:P7(C.builder,H),isPk:/\.primaryKey\(\)/.test(U)||void 0,isFk:N?!0:void 0,nullable:/\.notNull\(\)/.test(U)?!1:!0}),M.colByProp.set(C.prop,A),N)M.fks.push({column:A,toVar:N[1],toProp:N[2]})}),$.push(M)}}if(!$.length)return{tables:[],relations:[]};let J=new Map($.map((K)=>[K.varName,K])),V=[];for(let K of $)for(let Y of K.fks){let X=J.get(Y.toVar);if(!X)continue;V.push({fromTable:K.tableName,fromColumn:Y.column,toTable:X.tableName,toColumn:X.colByProp.get(Y.toProp)??Y.toProp})}return{tables:$.map((K)=>({name:K.tableName,columns:K.columns})),relations:V,tableVars:Object.fromEntries($.map((K)=>[K.varName,K.tableName]))}}function Z5(Z){let $=S7(Z);if($.tables.length)return $;let Q=I7(Z);if(Q.tables.length)return Q;return z7(Z)}var v7=["GET","POST","PUT","PATCH","DELETE"];function k7(Z){let $=Z.match(/(?:^|\/)app\/(.+)\/route\.(?:ts|tsx|js|jsx|mjs)$/);if(!$)return null;let Q=$[1].split("/").filter((J)=>!(J.startsWith("(")&&J.endsWith(")"))).map((J)=>{let V=J.match(/^\[{1,2}(?:\.\.\.)?([^\]]+)\]{1,2}$/);return V?`{${V[1]}}`:J});if(Q[0]!=="api")return null;return`/${Q.join("/")}`}function $5(Z){let $=[];for(let Q of Z){let J=k7(Q.path);if(!J)continue;for(let V of v7)if(new RegExp(`export\\s+(?:async\\s+)?(?:function|const)\\s+${V}\\b`).test(Q.content))$.push({method:V,path:J,uses:[],file:Q.path})}return $.sort((Q,J)=>`${Q.path} ${Q.method}`.localeCompare(`${J.path} ${J.method}`))}var T7=/(^|\/)app\/.*\/route\.(ts|tsx|js|jsx|mjs)$/,w7=/\.(ts|py)$/,y7=/(schema|model)/i;function Z4(Z){if(Z.endsWith(".prisma"))return!0;if(T7.test(Z))return!0;return w7.test(Z)&&y7.test(Z)}function Q5(Z,$=300){return Z.filter(Z4).slice(0,$)}import{z as d}from"zod";import{and as D5,eq as WZ,inArray as J8,notInArray as V8}from"drizzle-orm";import{z as E}from"zod";import{and as t7,eq as kZ,inArray as Q4,notInArray as e7,or as Z8,sql as $8}from"drizzle-orm";var J5=240,V5=50;function K5(Z){for(let $=0;$<Z.length;$++)for(let Q=$+1;Q<Z.length;Q++){let J=Z[$],V=Z[Q];if(J.x<V.x+J5&&J.x+J5>V.x&&J.y<V.y+V5&&J.y+V5>V.y)return!0}return!1}import{eq as f7}from"drizzle-orm";var X5=(Z)=>Z.replace(/\{[^}]*\}/g,"{}");function u7(Z,$){if(Z.method.toUpperCase()!==$.method.toUpperCase())return!1;let Q=X5(Z.path),J=X5($.path);return J===Q||J.endsWith(Q)}async function Y5(Z=m){let[$,Q]=await Promise.all([Z.query.endpoint.findMany({where:(V,{ne:K})=>K(V.source,"INTROSPECTION")}),Z.query.endpoint.findMany({where:(V,{eq:K})=>K(V.source,"INTROSPECTION")})]),J={collapsed:0,mappings:[]};for(let V of $){let K=Q.find((Y)=>u7(V,Y));if(!K)continue;await Z.delete(v).where(f7(v.id,V.id)),J.collapsed++,J.mappings.push({planned:`${V.method} ${V.path}`,code:`${K.method} ${K.path}`})}return J}import{and as G5,inArray as x7,isNull as M5,ne as j5,or as g7}from"drizzle-orm";var h7=new Set(["DONE","CANCELLED","DEPRIORITIZED"]);async function b7(Z){let $=await Z.query.node.findMany({where:(J,{and:V,eq:K,isNotNull:Y})=>V(K(J.view,"ROADMAP"),Y(J.planId)),columns:{planId:!0,status:!0}}),Q=new Map;for(let J of $){let V=J.planId;Q.set(V,(Q.get(V)??!0)&&h7.has(J.status))}return[...Q.entries()].filter(([,J])=>J).map(([J])=>J)}async function U5(Z=m){let $=await b7(Z),Q=(K)=>$.length?g7(M5(K.planId),x7(K.planId,$)):M5(K.planId),J=await Z.delete(I).where(G5(j5(I.source,"INTROSPECTION"),Q(I))).returning({id:I.id}),V=await Z.delete(v).where(G5(j5(v.source,"INTROSPECTION"),Q(v))).returning({id:v.id});return{tables:J.length,endpoints:V.length}}var W5=320;function $Z(Z){return 36+Math.max(0,Z)*30+16}var YZ=60,m7=280,SZ=14,H5=120,OZ=170,p7=2560;var vZ=(Z)=>(Z??"").trim()||"\u2014";function c7(Z,$,Q){let J=new Map;for(let K of Z.uses){if(!$.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}let V=null;for(let[K,Y]of J){if(V===null){V=K;continue}let X=J.get(V);if(Y>X){V=K;continue}if(Y<X)continue;let j=Q?.get(K)??0,B=Q?.get(V)??0;if(j<B)V=K;else if(j===B&&$.get(K).localeCompare($.get(V))<0)V=K}return V}function $4(Z,$){let Q=new Map(Z.map((V)=>[V.id,V.name])),J=new Map;for(let V of $)for(let K of V.uses){if(!Q.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}return new Map($.map((V)=>[V.id,c7(V,Q,J)]))}var l7=(Z,$)=>Z.path.localeCompare($.path)||Z.method.localeCompare($.method)||Z.id.localeCompare($.id);function L5(Z,$){let Q=$4(Z,$),J=new Map,V=[];for(let N of[...$].sort(l7)){let G=Q.get(N.id)??null;if(G){let _=J.get(G);if(_)_.push(N);else J.set(G,[N])}else V.push(N)}let K=(N)=>{let G=J.get(N.id)?.length??0;return $Z(N.columnCount)+(G?SZ+G*YZ:0)+50},Y=Array.from(new Set(Z.map((N)=>vZ(N.domain)))),X=Y.filter((N)=>N!=="\u2014").sort(),j=Y.includes("\u2014")?[...X,"\u2014"]:X,B=[];for(let N of j){let G=Z.filter((S)=>vZ(S.domain)===N).sort((S,P)=>S.name.localeCompare(P.name)),_=G.reduce((S,P)=>S+K(P),0),D=Math.max(1,Math.min(12,G.length,Math.round(Math.sqrt(_/320)))),R=Array(D).fill(0),y=new Map;for(let S of G){let P=0;for(let F=1;F<D;F++)if(R[F]<R[P])P=F;y.set(S.id,{x:P*320,y:R[P]}),R[P]+=K(S)}B.push({d:N,w:D*320,h:Math.max(...R,0),tableLocal:y})}let M=B.reduce((N,G)=>N+(G.w+H5)*(G.h+OZ),0),L=Math.max(p7,Math.round(Math.sqrt(M*2.2))),C=new Map,q=new Map,U=0,H=0,O=0,A=0;for(let N of B){if(U>0&&U+N.w>L)H+=O+OZ,U=0,O=0;let G=Z.filter((_)=>N.tableLocal.has(_.id));for(let _ of G){let D=N.tableLocal.get(_.id),R=U+D.x,y=H+D.y;C.set(_.id,{x:R,y}),(J.get(_.id)??[]).forEach((P,F)=>{q.set(P.id,{x:R,y:y+$Z(_.columnCount)+SZ+F*YZ})})}O=Math.max(O,N.h),A=Math.max(A,H+N.h),U+=N.w+H5}if(V.length){let N=A+OZ,G=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(V.length/2))));V.forEach((_,D)=>{q.set(_.id,{x:D%G*m7,y:N+Math.floor(D/G)*YZ})})}return{tables:C,endpoints:q}}function C5(Z,$,Q){let J=$4($,Q),V=new Map;for(let q of Q){let U=J.get(q.id);if(U)V.set(U,(V.get(U)??0)+1)}let K=(q)=>{let U=V.get(q.id)??0;return q.y+$Z(q.columnCount)+(U?SZ+U*YZ:0)},Y=vZ(Z.domain),X=$.filter((q)=>vZ(q.domain)===Y);if(!X.length){let q=$.length?Math.max(...$.map(K),...Q.map((U)=>U.y+YZ)):0;return{x:0,y:$.length||Q.length?q+OZ:0}}let j=Math.min(...X.map((q)=>q.x)),B=X.map((q)=>Math.max(0,Math.round((q.x-j)/320))),M=Math.min(12,Math.max(...B)+1),L=Array(M).fill(Math.min(...X.map((q)=>q.y)));X.forEach((q,U)=>{let H=Math.min(B[U],M-1);L[H]=Math.max(L[H],K(q)+50)});let C=0;for(let q=1;q<M;q++)if(L[q]<L[C])C=q;return{x:j+C*320,y:L[C]}}function B5(Z,$,Q){let J=$4($,[...Q,Z]),V=J.get(Z.id),K=V?$.find((X)=>X.id===V):void 0;if(K){let X=Q.filter((M)=>J.get(M.id)===K.id),j=K.y+$Z(K.columnCount)+SZ,B=X.length?Math.max(...X.map((M)=>M.y))+YZ:j;return{x:K.x,y:B}}let Y=[...$.map((X)=>X.y+$Z(X.columnCount)),...Q.map((X)=>X.y+YZ)];return{x:0,y:Y.length?Math.max(...Y)+OZ:0}}function N5(Z){let $=W5-20;for(let Q=0;Q<Z.length;Q++)for(let J=Q+1;J<Z.length;J++){let V=Z[Q],K=Z[J],Y=$Z(V.columnCount),X=$Z(K.columnCount);if(V.x<K.x+$&&V.x+$>K.x&&V.y<K.y+X&&V.y+Y>K.y)return!0}return!1}import{eq as O5}from"drizzle-orm";q5();async function A5(Z=m){let[$,Q]=await Promise.all([Z.query.dbTable.findMany({with:{columns:{columns:{id:!0}}},orderBy:(K,{asc:Y})=>Y(K.name)}),Z.query.endpoint.findMany({with:{tables:{columns:{tableId:!0}}}})]),J=L5($.map((K)=>({id:K.id,name:K.name,domain:K.domain,columnCount:K.columns.length})),Q.map((K)=>({id:K.id,method:K.method,path:K.path,uses:K.tables.map((Y)=>({tableId:Y.tableId}))}))),V=0;for(let K of $){let Y=J.tables.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(I).set({x:Y.x,y:Y.y}).where(O5(I.id,K.id)),V++}for(let K of Q){let Y=J.endpoints.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(v).set({x:Y.x,y:Y.y}).where(O5(v.id,K.id)),V++}return V}var Q8=E.object({tables:E.array(E.object({name:E.string().trim().min(1),domain:E.string().nullish(),description:E.string().nullish(),columns:E.array(E.object({name:E.string().trim().min(1),type:E.string().trim().min(1),isPk:E.boolean().optional(),isFk:E.boolean().optional(),nullable:E.boolean().optional(),note:E.string().nullish()})).default([])})).default([]),relations:E.array(E.object({fromTable:E.string(),fromColumn:E.string(),toTable:E.string(),toColumn:E.string(),label:E.string().nullish()})).default([]),endpoints:E.array(E.object({method:E.string().trim().min(1),path:E.string().trim().min(1),domain:E.string().nullish(),description:E.string().nullish(),uses:E.array(E.object({table:E.string(),access:E.string().default("read")})).default([])})).default([])});async function TZ(Z=m){let[$]=await Z.insert(s).values({id:"singleton",version:1}).onConflictDoUpdate({target:s.id,set:{version:$8`${s.version} + 1`}}).returning();return $.version}async function _5(Z,$=m,Q={}){let J=Q8.parse(Z),V=J.tables.length>0,K=J.endpoints.length>0,Y=J.tables.map((G)=>G.name);if(V)await $.delete(I).where(Y.length?t7(kZ(I.source,"INTROSPECTION"),e7(I.name,Y)):kZ(I.source,"INTROSPECTION"));let X=await $.query.dbTable.findMany({columns:{id:!0,name:!0,domain:!0,x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),j=await $.query.endpoint.findMany({columns:{id:!0,method:!0,path:!0,x:!0,y:!0},with:{tables:{columns:{tableId:!0}}}}),B=new Map(X.map((G)=>[G.name,G])),M=X.map((G)=>({id:G.id,name:G.name,domain:G.domain,columnCount:G.columns.length,x:G.x,y:G.y})),L=j.map((G)=>({id:G.id,method:G.method,path:G.path,uses:G.tables.map((_)=>({tableId:_.tableId})),x:G.x,y:G.y})),C=new Map;for(let G of J.tables){if(B.has(G.name))continue;let _=C5({domain:G.domain??null,columnCount:G.columns.length},M,L);C.set(G.name,_),M.push({id:`new:${G.name}`,name:G.name,domain:G.domain??null,columnCount:G.columns.length,..._})}let q=new Map;for(let G of J.tables){let _=B.get(G.name),D=C.get(G.name),R=_?.x??D?.x??0,y=_?.y??D?.y??0,[S]=await $.insert(I).values({name:G.name,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:R,y}).onConflictDoUpdate({target:I.name,set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(q.set(G.name,S.id),await $.delete(e).where(kZ(e.tableId,S.id)),G.columns.length)await $.insert(e).values(G.columns.map((P,F)=>({tableId:S.id,name:P.name,type:P.type,isPk:P.isPk??!1,isFk:P.isFk??!1,nullable:P.nullable??!0,note:P.note??null,ord:F})))}let U=[...q.values()];if(U.length)await $.delete(l).where(Z8(Q4(l.fromTableId,U),Q4(l.toTableId,U)));for(let G of J.relations){let _=q.get(G.fromTable),D=q.get(G.toTable);if(!_||!D)continue;await $.insert(l).values({fromTableId:_,toTableId:D,fromColumn:G.fromColumn,toColumn:G.toColumn,label:G.label??`${G.fromColumn} \u2192 ${G.toTable}.${G.toColumn}`})}let H=new Set(J.endpoints.map((G)=>`${G.method} ${G.path}`));if(K){let _=(await $.query.endpoint.findMany({where:(D,{eq:R})=>R(D.source,"INTROSPECTION")})).filter((D)=>!H.has(`${D.method} ${D.path}`)).map((D)=>D.id);if(_.length)await $.delete(v).where(Q4(v.id,_))}for(let G of M)if(G.id.startsWith("new:"))G.id=q.get(G.name)??G.id;for(let G of J.endpoints){let _=await $.query.endpoint.findFirst({where:(S,{and:P,eq:F})=>P(F(S.method,G.method),F(S.path,G.path))}),D,R;if(_)D=_.x,R=_.y;else{let S={id:`new:${G.method} ${G.path}`,method:G.method,path:G.path,uses:G.uses.map((F)=>({tableId:q.get(F.table)??""})).filter((F)=>F.tableId)},P=B5(S,M,L);D=P.x,R=P.y,L.push({...S,x:D,y:R})}let[y]=await $.insert(v).values({method:G.method,path:G.path,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:D,y:R}).onConflictDoUpdate({target:[v.method,v.path],set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(!Q.partial||G.uses.length>0)await $.delete(o).where(kZ(o.endpointId,y.id));for(let S of G.uses){let P=q.get(S.table)??(await $.query.dbTable.findFirst({where:(F,{eq:MZ})=>MZ(F.name,S.table)}))?.id;if(!P)continue;await $.insert(o).values({endpointId:y.id,tableId:P,access:S.access})}}await Y5($),await U5($);let O=await $.query.dbTable.findMany({where:(G,{eq:_})=>_(G.source,"INTROSPECTION"),columns:{x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),A=await $.select({x:v.x,y:v.y}).from(v);if(N5(O.map((G)=>({x:G.x,y:G.y,columnCount:G.columns.length})))||K5(A))await A5($);let N=await TZ($);return{tables:J.tables.length,relations:J.relations.length,endpoints:J.endpoints.length,version:N}}var F5=d.object({files:d.array(d.object({path:d.string().trim().min(1),root:d.string().nullish(),lang:d.string().nullish(),mtimeMs:d.number().nullish(),size:d.number().nullish()})).default([]),edges:d.array(d.object({from:d.string().trim().min(1),to:d.string().trim().min(1)})).default([])});function z5(Z,$){let Q=new Map;for(let C of Z)Q.set(C,[]);for(let C of $)Q.get(C.from)?.push(C.to);let J=new Map,V=new Map,K=new Set,Y=[],X=new Map,j=[],B=0,M=0;for(let C of Z){if(J.has(C))continue;let q=[{v:C,iter:0}];J.set(C,B),V.set(C,B),B++,Y.push(C),K.add(C);while(q.length){let U=q[q.length-1],H=Q.get(U.v)??[];if(U.iter<H.length){let O=H[U.iter++];if(!J.has(O))J.set(O,B),V.set(O,B),B++,Y.push(O),K.add(O),q.push({v:O,iter:0});else if(K.has(O))V.set(U.v,Math.min(V.get(U.v),J.get(O)))}else{if(V.get(U.v)===J.get(U.v)){let A=0,N;do N=Y.pop(),K.delete(N),X.set(N,M),A++;while(N!==U.v);j.push(A),M++}q.pop();let O=q[q.length-1];if(O)V.set(O.v,Math.min(V.get(O.v),V.get(U.v)))}}}let L=new Set;for(let C of $){let q=X.get(C.from);if(q!==void 0&&q===X.get(C.to)&&j[q]>1)L.add(`${C.from}|${C.to}`)}return L}async function E5(Z,$=m){let Q=F5.parse(Z),J=Q.files.map((L)=>L.path),V=new Set(J),K=Q.edges.filter((L)=>V.has(L.from)&&V.has(L.to)&&L.from!==L.to),Y=z5(J,K),X=new Map,j=new Map;for(let L of K)j.set(L.from,(j.get(L.from)??0)+1),X.set(L.to,(X.get(L.to)??0)+1);await $.delete(f).where(V8(f.path,J));for(let L of Q.files){let C={root:L.root??null,lang:L.lang??null,mtimeMs:L.mtimeMs??null,size:L.size??null,inDegree:X.get(L.path)??0,outDegree:j.get(L.path)??0};await $.insert(f).values({path:L.path,...C}).onConflictDoUpdate({target:f.path,set:C})}await $.delete(u);let B=0;if(K.length)await $.insert(u).values(K.map((L)=>{let C=Y.has(`${L.from}|${L.to}`);if(C)B++;return{fromPath:L.from,toPath:L.to,circular:C}}));let M=await TZ($);return await $.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton")),{files:Q.files.length,edges:K.length,circular:B,version:M}}var K8=(Z,$)=>`${Z}\x00${$}`;function J4(Z){let $=F5.parse(Z),Q=$.files.map((M)=>M.path),J=new Set(Q),V=$.edges.filter((M)=>J.has(M.from)&&J.has(M.to)&&M.from!==M.to),K=z5(Q,V),Y=new Map,X=new Map;for(let M of V)X.set(M.from,(X.get(M.from)??0)+1),Y.set(M.to,(Y.get(M.to)??0)+1);let j=new Map;for(let M of $.files)j.set(M.path,{root:M.root??null,lang:M.lang??null,mtimeMs:M.mtimeMs??null,size:M.size??null,inDegree:Y.get(M.path)??0,outDegree:X.get(M.path)??0});let B=new Map;for(let M of V)B.set(K8(M.from,M.to),{from:M.from,to:M.to,circular:K.has(`${M.from}|${M.to}`)});return{files:j,edges:B}}var X8=(Z,$)=>Z.root===$.root&&Z.lang===$.lang&&Z.mtimeMs===$.mtimeMs&&Z.size===$.size&&Z.inDegree===$.inDegree&&Z.outDegree===$.outDegree;async function I5(Z,$,Q=m){for(let[X,j]of $.files){let B=Z.files.get(X);if(B&&X8(B,j))continue;let M={root:j.root,lang:j.lang,mtimeMs:j.mtimeMs,size:j.size,inDegree:j.inDegree,outDegree:j.outDegree};await Q.insert(f).values({path:X,...M}).onConflictDoUpdate({target:f.path,set:M})}let J=[...Z.files.keys()].filter((X)=>!$.files.has(X));if(J.length)await Q.delete(f).where(J8(f.path,J));for(let[X,j]of Z.edges)if(!$.edges.has(X))await Q.delete(u).where(D5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)));let V=[];for(let[X,j]of $.edges){let B=Z.edges.get(X);if(!B)V.push({fromPath:j.from,toPath:j.to,circular:j.circular});else if(B.circular!==j.circular)await Q.update(u).set({circular:j.circular}).where(D5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)))}if(V.length)await Q.insert(u).values(V);let K=await TZ(Q);await Q.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton"));let Y=0;for(let X of $.edges.values())if(X.circular)Y++;return{files:$.files.size,edges:$.edges.size,circular:Y,version:K}}var U8=/[/\\](node_modules|\.git|\.next|dist|build|__pycache__|target|\.venv|venv|\.beacon|\.playwright-mcp|generated|coverage)[/\\]/;function H8(Z){try{let $=AZ(Z,"beacon.config.json");if(R5($)){let Q=JSON.parse(Y8($,"utf8"));if(Array.isArray(Q.roots)&&Q.roots.length)return Q.roots.map((J)=>j8(Z,J))}}catch{}return[Z]}function S5(Z){let $=H8(Z.path),Q=cZ(Z.id),J=oZ(JZ(Z.id)),V=a4($,Z.path);async function K(){let H=Q5(V.snapshot().files.map((_)=>_.path));for(let _ of $)for(let D of["prisma/schema.prisma","schema.prisma"]){let R=AZ(_,D);if(R5(R))H.push(Y(R))}let O=[];for(let _ of H)try{O.push({path:_,content:await P5(AZ(Z.path,_),"utf8")})}catch{}let A=Z5(O),N=$5(O);if(!A.tables.length&&!N.length)return;if(N.length&&A.tableVars&&Object.keys(A.tableVars).length){let D=V.snapshot().edges,R=new Set(N.map((F)=>F.file)),y=new Map;for(let F of D){let MZ=y.get(F.from)??[];MZ.push(F.to),y.set(F.from,MZ)}for(let F=0;F<2;F++)for(let MZ of[...R])for(let x5 of y.get(MZ)??[])R.add(x5);let S=new Map;for(let F of[...R].slice(0,600))try{S.set(F,await P5(AZ(Z.path,F),"utf8"))}catch{}let P=t4({routeFiles:[...new Set(N.map((F)=>F.file))],edges:D,content:(F)=>S.get(F)??null,tableVars:A.tableVars});for(let F of N)F.uses=P.get(F.file)??[]}let G=await _5({tables:A.tables,relations:A.relations,endpoints:N},J,{partial:!0});console.log(`[beacon-inline] schema synced (${Z.name}): ${G.tables} tables / ${G.endpoints} endpoints`)}function Y(H){return M8(Z.path,H).split(/[\\/]/).join("/")}let X=null,j=!1,B=new Set,M=null,L=!1;async function C(){if(L){q();return}L=!0;try{if(await Q,j)X=null,j=!1;if(X===null){let N=await V.seed(),G=await E5(N,J);X=J4(N),console.log(`[beacon-inline] code-graph synced (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`),await K();return}let H=[...B];B.clear();let O=H.some((N)=>Z4(Y(N))),A=!1;for(let N of H)if(await V.applyChange(N))A=!0;if(A){let N=J4(V.snapshot()),G=await I5(X,N,J);X=N,console.log(`[beacon-inline] code-graph updated (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`)}if(O)await K()}catch(H){console.error(`[beacon-inline] error (${Z.name}):`,H instanceof Error?H.message:H)}finally{L=!1}}function q(){if(M)clearTimeout(M);M=setTimeout(C,600)}let U=[];for(let H of $)try{let O=G8(H,{recursive:!0,persistent:!0},(A,N)=>{if(!N){j=!0,q();return}let G=String(N);if(U8.test(`/${G}`))return;B.add(AZ(H,G)),q()});O.on("error",(A)=>console.error(`[beacon-inline] watcher error (${Z.name}):`,A)),U.push(O)}catch(O){console.error(`[beacon-inline] live watch unavailable for ${H} (${Z.name}):`,O instanceof Error?O.message:O)}return console.log(`[beacon-inline] watching ${Z.name} (${$.join(", ")}) \u2014 initial extract\u2026`),C(),{async stop(){if(M)clearTimeout(M);for(let H of U)H.close()}}}function L8(Z){let $=Z.limit??6,Q=Z.hardCap??12,J=new Map,V=0,K=new Set;function Y(H){let O=J.get(H);if(O)O.seq=++V}function X(H){if(J.has(H.id))return Y(H.id);if(!Z.exists(H.path))return;J.set(H.id,{handle:Z.start(H),seq:++V})}function j(){let H=null,O=1/0;for(let[A,N]of J){if(K.has(A))continue;if(N.seq<O)O=N.seq,H=A}if(H)J.get(H).handle.stop(),J.delete(H)}function B(){let H=Z.list().filter((O)=>Z.exists(O.path)).slice(0,$);K=new Set(H.map((O)=>O.id));for(let O of H)X(O);for(let[O,A]of[...J]){let N=Z.get(O);if(!N||!Z.exists(N.path))A.handle.stop(),J.delete(O)}}function M(H){if(J.has(H))return Y(H);let O=Z.get(H);if(!O||!Z.exists(O.path))return;if(J.size>=Q)j();if(J.size>=Q)return;J.set(H,{handle:Z.start(O),seq:++V})}async function L(H){let O=J.get(H);if(!O)return;J.delete(H),await O.handle.stop()}function C(H){return J.has(H)}function q(){return[...J.keys()]}async function U(){await Promise.all([...J.values()].map((H)=>H.handle.stop())),J.clear()}return{reconcile:B,ensureWatcher:M,stopWatcher:L,isWatching:C,activeIds:q,stopAll:U}}var C8=L8({list:pZ,get:x,exists:W8,start:(Z)=>S5(Z)});async function v5(Z){await C8.stopWatcher(Z)}async function k5(Z){if(!x(Z))return{ok:!1,removed:!1,fallbackId:r(),error:"unknown workspace"};q4(Z),B4(Z),await v5(Z),E4(JZ(Z)),F4(Z);try{B8(n(Z),{recursive:!0,force:!0})}catch($){return{ok:!1,removed:!0,fallbackId:r(),error:$ instanceof Error?$.message:String($)}}return{ok:!0,removed:!0,fallbackId:r()}}var V4=process.argv.slice(3),y5=V4.includes("--yes")||V4.includes("-y"),GZ=V4.find((Z)=>!Z.startsWith("-")),T5=(Z)=>`\x1B[32m\u2713\x1B[0m ${Z}`,f5=(Z)=>`\x1B[2m${Z}\x1B[0m`,u5=(Z)=>`
|
|
3
|
+
var g5=Object.defineProperty;var h5=(Z)=>Z;function b5(Z,$){this[Z]=h5.bind(null,$)}var wZ=(Z,$)=>{for(var Q in $)g5(Z,Q,{get:$[Q],enumerable:!0,configurable:!0,set:b5.bind($,Q)})};var K4=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var Y4={};wZ(Y4,{provisionDb:()=>t5});import{createClient as m5}from"@libsql/client";import{drizzle as p5}from"drizzle-orm/libsql";import{migrate as c5}from"drizzle-orm/libsql/migrator";import{readMigrationFiles as l5}from"drizzle-orm/migrator";import{dirname as yZ,join as d5}from"path";import{fileURLToPath as n5}from"url";async function _Z(Z,$){return(await Z.execute({sql:"SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?",args:[$]})).rows.length>0}async function s5(Z,$){let Q=await Z.execute(`PRAGMA table_info("${$}")`);return new Set(Q.rows.map((J)=>String(J.name)))}async function X4(Z){if(!await _Z(Z,"__drizzle_migrations"))return 0;let $=await Z.execute('SELECT count(*) AS n FROM "__drizzle_migrations"');return Number($.rows[0]?.n??0)}async function a5(Z){for(let[$,Q]of Object.entries(i5)){if(!await _Z(Z,$))continue;let J=await s5(Z,$);for(let V of Q){if(!J.has(V))continue;await Z.execute(`UPDATE "${$}" SET "${V}" = CAST((julianday("${V}") - 2440587.5) * 86400000 AS INTEGER) WHERE typeof("${V}") = 'text'`)}}}async function t5(Z,$=o5){let Q=m5({url:Z});try{await Q.execute("PRAGMA journal_mode = WAL;"),await Q.execute("PRAGMA foreign_keys = ON;"),await Q.execute("PRAGMA busy_timeout = 5000;");let J=await _Z(Q,"__drizzle_migrations"),V=await _Z(Q,"Node"),K=!1;if(V&&!J){let X=l5({migrationsFolder:$})[0];if(X)await Q.execute('CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (id SERIAL PRIMARY KEY, hash text NOT NULL, created_at numeric)'),await Q.execute({sql:'INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES (?, ?)',args:[X.hash,X.folderMillis]}),K=!0}let Y=await X4(Q);if(await c5(p5(Q),{migrationsFolder:$}),await X4(Q)>Y)K=!0;return await a5(Q),{migrated:K}}finally{Q.close()}}var r5,o5,i5;var G4=K4(async()=>{r5=yZ(yZ(yZ(n5(import.meta.url)))),o5=process.env.BEACON_MIGRATIONS_DIR||d5(r5,"drizzle"),i5={Node:["createdAt","updatedAt"],Note:["createdAt","updatedAt"],DbTable:["createdAt","updatedAt"],Endpoint:["createdAt","updatedAt"],DraftTable:["createdAt"],SyncState:["codeGraphSyncedAt","updatedAt"],AppSetting:["updatedAt"],ProjectMeta:["updatedAt"],CodeFile:["updatedAt"]}});import{mkdirSync as d7,renameSync as n7,rmSync as r7,writeFileSync as o7}from"fs";import{dirname as i7}from"path";function s7(Z,$){d7(i7(Z),{recursive:!0});let Q=`${Z}.tmp`;try{o7(Q,$),n7(Q,Z)}catch(J){throw r7(Q,{force:!0}),J}}function a7(Z,$,Q=!1){s7(Z,JSON.stringify($,null,Q?2:void 0))}var q5=()=>{};import{AsyncLocalStorage as e5}from"async_hooks";import{spawnSync as Z6}from"child_process";import{createHash as $6}from"crypto";import{existsSync as j4,mkdirSync as LZ,readFileSync as uZ,writeFileSync as xZ}from"fs";import{homedir as U4}from"os";import{basename as Q6,join as ZZ,parse as J6,resolve as M4}from"path";function a(){return process.env.BEACON_HOME||ZZ(U4(),".beacon")}function gZ(){return ZZ(a(),"workspaces.json")}function QZ(Z){return $6("sha256").update(Z).digest("hex").slice(0,12)}function hZ(Z=process.cwd()){let $=Z6("git",["rev-parse","--show-toplevel"],{cwd:Z,stdio:["ignore","pipe","ignore"]});if($.status===0){let Q=$.stdout?.toString().trim();if(Q)return Q}return Z}function H4(Z){let $=M4(Z);return $!==M4(U4())&&$!==J6($).root}function W4(){return ZZ(a(),"deleted.json")}function bZ(){try{let Z=JSON.parse(uZ(W4(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function L4(Z){LZ(a(),{recursive:!0}),xZ(W4(),JSON.stringify(Z,null,2))}function C4(Z){return bZ().includes(Z)}function B4(Z){let $=bZ();if(!$.includes(Z))L4([...$,Z])}function V6(Z){let $=bZ();if($.includes(Z))L4($.filter((Q)=>Q!==Z))}function n(Z){return ZZ(a(),Z)}function JZ(Z){return`file:${ZZ(n(Z),"db.sqlite")}`}function CZ(){try{let Z=JSON.parse(uZ(gZ(),"utf8"));return Array.isArray(Z)?Z:[]}catch{return[]}}function mZ(Z){LZ(a(),{recursive:!0}),xZ(gZ(),JSON.stringify(Z,null,2))}function pZ(){return CZ().sort((Z,$)=>$.lastOpenedAt.localeCompare(Z.lastOpenedAt))}function x(Z){return CZ().find(($)=>$.id===Z)??null}function N4(Z,$,Q=new Date().toISOString()){if(!H4(Z))throw Error(`beacon: refusing to register a non-repo path as a workspace: ${Z}`);let J=QZ(Z);if(C4(J))throw Error(`beacon: workspace ${J} (${Z}) was deleted \u2014 run \`beacon\` or /beacon-init to re-add it`);let V=CZ(),K=V.find((j)=>j.id===J),Y={id:J,path:Z,name:$||K?.name||Q6(Z),lastOpenedAt:Q},X=[Y,...V.filter((j)=>j.id!==J)];return LZ(n(J),{recursive:!0}),mZ(X),Y}function y8(Z,$){return V6(QZ(Z)),N4(Z,$)}function f8(Z,$=new Date().toISOString()){let Q=CZ(),J=Q.find((V)=>V.id===Z);if(!J)return;J.lastOpenedAt=$,mZ(Q)}function q4(Z){if(mZ(CZ().filter(($)=>$.id!==Z)),r()===Z)K6(pZ()[0]?.id??null)}function O4(){return ZZ(a(),"active")}function r(){try{return uZ(O4(),"utf8").trim()||null}catch{return null}}function K6(Z){LZ(a(),{recursive:!0}),xZ(O4(),Z??"")}function X6(){let Z=r();return Z?x(Z):null}function u8(){let Z=FZ()??r();return Z?x(Z):null}function x8(Z){return x(Z)?.path??null}function g8(){return j4(gZ())}var A4="beacon_ws";function _4(Z,$){let Q=Z.headers.get("cookie");if(!Q)return null;for(let J of Q.split(";")){let V=J.indexOf("=");if(V===-1)continue;if(J.slice(0,V).trim()===$)return decodeURIComponent(J.slice(V+1).trim())}return null}function h8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=_4(Z,A4);if(Q&&x(Q))return Q;return null}var Y6="x-beacon-workspace-path";async function b8(Z){let $=Z.headers.get("x-beacon-workspace");if($&&x($))return $;let Q=Z.headers.get(Y6);if(Q&&H4(Q)&&!C4(QZ(Q))&&(!$||QZ(Q)===$)){let V=N4(Q);return await cZ(V.id),V.id}let J=_4(Z,A4);if(J&&x(J))return J;return null}var F4=new e5;function G6(Z,$){return Z?F4.run(Z,$):$()}function FZ(){return F4.getStore()??null}var fZ=new Set;function D4(Z){fZ.delete(ZZ(n(Z),"db.sqlite"))}async function cZ(Z){let $=n(Z),Q=ZZ($,"db.sqlite"),J=j4(Q);if(J&&fZ.has(Q))return{ok:!0,created:!1,migrated:!1};try{LZ($,{recursive:!0});let{provisionDb:V}=await G4().then(() => Y4),K=await V(JZ(Z));return fZ.add(Q),{ok:!0,created:!J,migrated:J&&K.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{existsSync as N8,readFileSync as q8}from"fs";import{resolve as w5}from"path";import{rmSync as B8}from"fs";import{drizzle as k6}from"drizzle-orm/libsql";import{createClient as T6}from"@libsql/client";var lZ={};wZ(lZ,{tag:()=>jZ,syncState:()=>s,projectMeta:()=>L6,note:()=>U6,nodeTags:()=>KZ,nodeFile:()=>BZ,node:()=>T,endpointTable:()=>o,endpoint:()=>v,edge:()=>VZ,draftTable:()=>c,draftRelation:()=>XZ,draftColumn:()=>qZ,dbTable:()=>E,dbRelation:()=>l,dbColumn:()=>e,codeFileEdge:()=>u,codeFile:()=>f,bugFlag:()=>NZ,boardAnnotation:()=>H6,appSetting:()=>W6});import{sqliteTable as w,index as k,foreignKey as M6,text as W,integer as z,real as b,uniqueIndex as t,primaryKey as j6}from"drizzle-orm/sqlite-core";import{createId as h}from"@paralleldrive/cuid2";var T=w("Node",{id:W().primaryKey().$defaultFn(()=>h()),view:W().notNull(),kind:W().default("FEATURE").notNull(),cluster:W(),layer:W(),title:W().notNull(),role:W(),plain:W(),status:W().default("PENDING").notNull(),priority:z().default(2).notNull(),progress:z().default(0).notNull(),x:b().default(0).notNull(),y:b().default(0).notNull(),sourceRef:W(),externalId:W(),source:W().default("MANUAL").notNull(),planId:W(),parentId:W(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Node_cluster_idx").on(Z.cluster),k("Node_parentId_idx").on(Z.parentId),k("Node_view_idx").on(Z.view),M6(()=>({columns:[Z.parentId],foreignColumns:[Z.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),BZ=w("NodeFile",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),path:W().notNull()},(Z)=>[t("NodeFile_nodeId_path_key").on(Z.nodeId,Z.path),k("NodeFile_nodeId_idx").on(Z.nodeId)]),jZ=w("Tag",{id:W().primaryKey().$defaultFn(()=>h()),label:W().notNull(),color:W()},(Z)=>[t("Tag_label_key").on(Z.label)]),VZ=w("Edge",{id:W().primaryKey().$defaultFn(()=>h()),fromId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:W().default("DEPENDS").notNull(),label:W(),sourceHandle:W(),targetHandle:W()},(Z)=>[t("Edge_fromId_toId_kind_key").on(Z.fromId,Z.toId,Z.kind),k("Edge_toId_idx").on(Z.toId),k("Edge_fromId_idx").on(Z.fromId)]),KZ=w("_NodeTags",{a:W("A").notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),b:W("B").notNull().references(()=>jZ.id,{onDelete:"cascade",onUpdate:"cascade"})},(Z)=>[t("_NodeTags_AB_unique").on(Z.a,Z.b),k("_NodeTags_B_index").on(Z.b)]),U6=w("Note",{id:W().primaryKey().$defaultFn(()=>h()),title:W().default("Untitled").notNull(),body:W().default("").notNull(),ord:b().default(0).notNull(),pinned:z({mode:"boolean"}).default(!1).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("Note_updatedAt_idx").on(Z.updatedAt)]),H6=w("BoardAnnotation",{id:W().primaryKey().$defaultFn(()=>h()),targetKind:W().notNull(),targetId:W().notNull(),columnName:W(),body:W().default("").notNull(),x:b(),y:b(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("BoardAnnotation_target_idx").on(Z.targetId)]),NZ=w("BugFlag",{id:W().primaryKey().$defaultFn(()=>h()),nodeId:W().notNull().references(()=>T.id,{onDelete:"cascade",onUpdate:"cascade"}),by:W().notNull(),note:W().notNull(),resolvedAt:z({mode:"timestamp_ms"}),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[k("BugFlag_nodeId_idx").on(Z.nodeId)]),E=w("DbTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[k("DbTable_domain_idx").on(Z.domain),t("DbTable_name_key").on(Z.name)]),e=w("DbColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[t("DbColumn_tableId_name_key").on(Z.tableId,Z.name),k("DbColumn_tableId_idx").on(Z.tableId)]),l=w("DbRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DbRelation_toTableId_idx").on(Z.toTableId),k("DbRelation_fromTableId_idx").on(Z.fromTableId)]),v=w("Endpoint",{id:W().primaryKey().$defaultFn(()=>h()),method:W().notNull(),path:W().notNull(),domain:W(),description:W(),source:W().default("MANUAL").notNull(),planId:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},(Z)=>[t("Endpoint_method_path_key").on(Z.method,Z.path),k("Endpoint_domain_idx").on(Z.domain)]),o=w("EndpointTable",{id:W().primaryKey().$defaultFn(()=>h()),endpointId:W().notNull().references(()=>v.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:W().notNull().references(()=>E.id,{onDelete:"cascade",onUpdate:"cascade"}),access:W().default("read").notNull()},(Z)=>[t("EndpointTable_endpointId_tableId_key").on(Z.endpointId,Z.tableId),k("EndpointTable_tableId_idx").on(Z.tableId)]),c=w("DraftTable",{id:W().primaryKey().$defaultFn(()=>h()),name:W().notNull(),domain:W(),description:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),createdAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},(Z)=>[t("DraftTable_name_key").on(Z.name)]),qZ=w("DraftColumn",{id:W().primaryKey().$defaultFn(()=>h()),tableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),name:W().notNull(),type:W().notNull(),isPk:z({mode:"boolean"}).default(!1).notNull(),isFk:z({mode:"boolean"}).default(!1).notNull(),nullable:z({mode:"boolean"}).default(!0).notNull(),note:W(),ord:z().default(0).notNull()},(Z)=>[k("DraftColumn_tableId_idx").on(Z.tableId)]),XZ=w("DraftRelation",{id:W().primaryKey().$defaultFn(()=>h()),fromTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:W().notNull().references(()=>c.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:W().notNull(),toColumn:W().notNull(),label:W()},(Z)=>[k("DraftRelation_toTableId_idx").on(Z.toTableId),k("DraftRelation_fromTableId_idx").on(Z.fromTableId)]),f=w("CodeFile",{path:W().primaryKey(),root:W(),lang:W(),x:b().default(0).notNull(),y:b().default(0).notNull(),mtimeMs:b(),size:z(),inDegree:z().default(0).notNull(),outDegree:z().default(0).notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=w("CodeFileEdge",{fromPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:W().notNull().references(()=>f.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:z({mode:"boolean"}).default(!1).notNull()},(Z)=>[k("CodeFileEdge_circular_idx").on(Z.circular),k("CodeFileEdge_toPath_idx").on(Z.toPath),k("CodeFileEdge_fromPath_idx").on(Z.fromPath),j6({columns:[Z.fromPath,Z.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),s=w("SyncState",{id:W().primaryKey().default("singleton"),version:z().default(0).notNull(),codeGraphSyncedAt:z({mode:"timestamp_ms"}),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),W6=w("AppSetting",{id:W().primaryKey().default("singleton"),editor:W().default("auto").notNull(),currentFeatureId:W(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),L6=w("ProjectMeta",{id:W().primaryKey().default("singleton"),overview:W(),conventions:W().default("[]").notNull(),hasFrontend:z({mode:"boolean"}),classificationRoots:W().default("[]").notNull(),updatedAt:z({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var dZ={};wZ(dZ,{tagRelations:()=>q6,nodeTagsRelations:()=>O6,nodeRelations:()=>C6,nodeFileRelations:()=>B6,endpointTableRelations:()=>P6,endpointRelations:()=>z6,edgeRelations:()=>A6,draftTableRelations:()=>E6,draftRelationRelations:()=>R6,draftColumnRelations:()=>I6,dbTableRelations:()=>_6,dbRelationRelations:()=>D6,dbColumnRelations:()=>F6,codeFileRelations:()=>S6,codeFileEdgeRelations:()=>v6,bugFlagRelations:()=>N6});import{relations as g}from"drizzle-orm";var C6=g(T,({one:Z,many:$})=>({files:$(BZ),bugFlags:$(NZ),nodeTags:$(KZ),edgesOut:$(VZ,{relationName:"EdgeFrom"}),edgesIn:$(VZ,{relationName:"EdgeTo"}),parent:Z(T,{fields:[T.parentId],references:[T.id],relationName:"NodeTree"}),children:$(T,{relationName:"NodeTree"})})),B6=g(BZ,({one:Z})=>({node:Z(T,{fields:[BZ.nodeId],references:[T.id]})})),N6=g(NZ,({one:Z})=>({node:Z(T,{fields:[NZ.nodeId],references:[T.id]})})),q6=g(jZ,({many:Z})=>({nodeTags:Z(KZ)})),O6=g(KZ,({one:Z})=>({node:Z(T,{fields:[KZ.a],references:[T.id]}),tag:Z(jZ,{fields:[KZ.b],references:[jZ.id]})})),A6=g(VZ,({one:Z})=>({from:Z(T,{fields:[VZ.fromId],references:[T.id],relationName:"EdgeFrom"}),to:Z(T,{fields:[VZ.toId],references:[T.id],relationName:"EdgeTo"})})),_6=g(E,({many:Z})=>({columns:Z(e),fksOut:Z(l,{relationName:"FkFrom"}),fksIn:Z(l,{relationName:"FkTo"}),usages:Z(o)})),F6=g(e,({one:Z})=>({table:Z(E,{fields:[e.tableId],references:[E.id]})})),D6=g(l,({one:Z})=>({fromTable:Z(E,{fields:[l.fromTableId],references:[E.id],relationName:"FkFrom"}),toTable:Z(E,{fields:[l.toTableId],references:[E.id],relationName:"FkTo"})})),z6=g(v,({many:Z})=>({tables:Z(o)})),P6=g(o,({one:Z})=>({endpoint:Z(v,{fields:[o.endpointId],references:[v.id]}),table:Z(E,{fields:[o.tableId],references:[E.id]})})),E6=g(c,({many:Z})=>({columns:Z(qZ),fksOut:Z(XZ,{relationName:"DraftFkFrom"}),fksIn:Z(XZ,{relationName:"DraftFkTo"})})),I6=g(qZ,({one:Z})=>({table:Z(c,{fields:[qZ.tableId],references:[c.id]})})),R6=g(XZ,({one:Z})=>({fromTable:Z(c,{fields:[XZ.fromTableId],references:[c.id],relationName:"DraftFkFrom"}),toTable:Z(c,{fields:[XZ.toTableId],references:[c.id],relationName:"DraftFkTo"})})),S6=g(f,({many:Z})=>({edgesOut:Z(u,{relationName:"CFEFrom"}),edgesIn:Z(u,{relationName:"CFETo"})})),v6=g(u,({one:Z})=>({fromFile:Z(f,{fields:[u.fromPath],references:[f.path],relationName:"CFEFrom"}),toFile:Z(f,{fields:[u.toPath],references:[f.path],relationName:"CFETo"})}));var w6={...lZ,...dZ};function y6(){let Z=process.env.DATABASE_URL;if(Z&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test(Z))return Z;return"file:./dev.db"}var f6=y6();function z4(Z){let $=T6({url:Z});return $.execute("PRAGMA foreign_keys = ON;"),$.execute("PRAGMA busy_timeout = 5000;"),k6($,{schema:w6})}var rZ=globalThis,nZ=rZ.dzDefault??z4(f6);rZ.dzDefault=nZ;var DZ=rZ.dzByUrl??=new Map;function oZ(Z){let $=DZ.get(Z);if(!$)$=z4(Z),DZ.set(Z,$);return $}function P4(Z){let $=DZ.get(Z);DZ.delete(Z);try{$?.$client?.close?.()}catch{}}function u6(){if(process.env.BEACON_REPO)return nZ;let Z=FZ()??r();if(!Z)return nZ;return oZ(JZ(Z))}var m=new Proxy({},{get(Z,$){let Q=u6(),J=Q[$];return typeof J==="function"?J.bind(Q):J}});import{existsSync as W8}from"fs";import{existsSync as R5,readFileSync as Y8,watch as G8}from"fs";import{readFile as I5}from"fs/promises";import{join as AZ,relative as M8,resolve as j8}from"path";import{existsSync as c4,readFileSync as l4}from"fs";import{readdir as W7,readFile as L7,stat as d4}from"fs/promises";import{extname as n4,join as IZ,relative as HZ,resolve as UZ}from"path";import{extname as g4}from"path";import{dirname as x6,resolve as g6}from"path";var iZ=[".ts",".tsx",".js",".jsx",".mjs",".cjs"],h6=[/(?:^|[\n;])\s*(?:import|export)[^'"`\n]{0,4000}?from\s*['"]([^'"`]+)['"]/g,/(?:^|[\n;])\s*import\s*['"]([^'"`]+)['"]/g,/\brequire\(\s*['"]([^'"`]+)['"]\s*\)/g,/\bimport\(\s*['"]([^'"`]+)['"]\s*\)/g];function b6(Z){return Z.split(/[\\/]/).join("/")}function E4(Z,$){if($.has(Z))return Z;for(let Q of iZ){let J=`${Z}${Q}`;if($.has(J))return J}for(let Q of iZ){let J=`${Z}/index${Q}`;if($.has(J))return J}return null}function m6(Z){let $=new Set;for(let Q of h6)for(let J of Z.matchAll(Q))$.add(J[1]);return $}function p6(Z,$,Q,J){if(Z.startsWith(".")){let V=g6("/",x6($),Z),K=b6(V).replace(/^\//,"");return E4(K,Q)}for(let V of J)if(Z.startsWith(V.from)){let K=Z.slice(V.from.length),Y=V.to?`${V.to}/${K}`:K,X=E4(Y,Q);if(X)return X}return null}var I4={id:"ts",extensions:iZ,specifiers:m6,resolve(Z,$,Q){let J=p6(Z,$,Q.fileSet,Q.tsAliases??[]);return J?[J]:[]}};import{dirname as zZ,join as c6,normalize as l6}from"path";var d6=[".py",".pyi"],R4=[/(?:^|[\n;])\s*from\s+(\.*[\w.]*)\s+import\b/g,/(?:^|[\n;])\s*import\s+([\w.]+(?:\s*,\s*[\w.]+)*)/g];function S4(Z,$){for(let Q of[`${Z}.py`,`${Z}/__init__.py`,`${Z}.pyi`])if($.has(Q))return[Q];return[]}function n6(Z){let $=new Set;for(let Q of Z.matchAll(R4[0])){let J=Q[1].trim();if(J)$.add(J)}for(let Q of Z.matchAll(R4[1]))for(let J of Q[1].split(/\s*,\s*/)){let V=J.trim().split(/\s+as\s+/)[0].trim();if(V)$.add(V)}return $}var v4={id:"python",extensions:d6,specifiers:n6,resolve(Z,$,Q){if(Z.startsWith(".")){let Y=Z.length-Z.replace(/^\.+/,"").length,X=Z.slice(Y),j=zZ($);for(let M=1;M<Y;M++)j=zZ(j);let B=X?c6(j,X.replace(/\./g,"/")):j;return S4(l6(B).replace(/\\/g,"/"),Q.fileSet)}let J=Z.replace(/\./g,"/"),V=[],K=zZ($);while(K&&K!=="."&&K!=="/")V.push(K),K=zZ(K);V.push("");for(let Y of V){let X=S4(Y?`${Y}/${J}`:J,Q.fileSet);if(X.length)return X}return[]}};import{dirname as r6}from"path";var o6=[".go"],i6=/(?:^|[\n;])\s*import\s+(?:[\w.]+\s+)?"([^"]+)"/g,s6=/(?:^|[\n;])\s*import\s*\(([\s\S]*?)\)/g,a6=/"([^"]+)"/g;function t6(Z){let $=new Set;for(let Q of Z.matchAll(i6))$.add(Q[1]);for(let Q of Z.matchAll(s6))for(let J of Q[1].matchAll(a6))$.add(J[1]);return $}var k4={id:"go",extensions:o6,resolve(Z,$,Q){let J=Q.goModulePath;if(!J)return[];let V=null;if(Z===J)V="";else if(Z.startsWith(`${J}/`))V=Z.slice(J.length+1);if(V===null)return[];let K=[];for(let Y of Q.fileSet){if(!Y.endsWith(".go"))continue;let X=r6(Y);if(V===""&&X==="."||X===V)K.push(Y)}return K.sort()},specifiers:t6};import{basename as T4,dirname as sZ,join as w4,normalize as y4}from"path";var e6=[".rs"],Z7=/(?:^|[\n;])\s*(?:pub\s+)?mod\s+(\w+)\s*;/g,$7=/(?:^|[\n;])\s*(?:pub\s+)?use\s+([\w:]+)/g;function Q7(Z){let $=Z.split("::").filter((Q)=>Q&&Q!=="*");if(!$.length)return"";if($[0]==="crate")return["crate",...$.slice(1)].join("/");if($[0]==="super")return["..",...$.slice(1)].join("/");if($[0]==="self")return[".",...$.slice(1)].join("/");return $.join("/")}function aZ(Z,$){for(let Q of[`${Z}.rs`,`${Z}/mod.rs`])if($.has(Q))return[Q];return[]}var J7=new Set(["mod.rs","lib.rs","main.rs"]);function V7(Z){let $=new Set;for(let Q of Z.matchAll(Z7))$.add(`./${Q[1]}`);for(let Q of Z.matchAll($7)){let J=Q7(Q[1]);if(J)$.add(J)}return $}var f4={id:"rust",extensions:e6,specifiers:V7,resolve(Z,$,Q){let J=Q.fileSet;if(Z.startsWith("./")||Z.startsWith("../")){let V=Z.replace(/^\.\//,""),K=y4(w4(sZ($),Z)).replace(/\\/g,"/"),Y=aZ(K,J);if(Y.length)return Y;if(Z.startsWith("./")&&!J7.has(T4($))){let X=w4(sZ($),T4($,".rs"),V);if(Y=aZ(y4(X).replace(/\\/g,"/"),J),Y.length)return Y}return[]}if(Z.startsWith("crate/")){let V=$.split("/"),K=V.lastIndexOf("src"),Y=K>=0?V.slice(0,K+1).join("/"):sZ($),X=Z.slice(6).split("/");for(let j of[X.join("/"),X.slice(0,-1).join("/")]){if(!j)continue;let B=aZ(`${Y}/${j}`,J);if(B.length)return B}return[]}return[]}};import{dirname as K7,extname as X7,join as Y7,normalize as G7}from"path";var u4=[".swift",".java",".rb",".kt",".kts",".cs",".php",".scala",".c",".h",".cpp",".hpp",".cc",".hh",".m",".mm",".ex",".exs",".lua",".dart",".vue",".svelte"],M7=[/\b(?:require_relative|require|include|import|use|using|from)\s*\(?\s*['"]([^'"`\n]+)['"]/g,/(?:^|[\n;])\s*import\s+([\w.]+)/g,/(?:^|[\n;])\s*from\s+([\w.]+)\s+import\b/g,/(?:^|[\n;])\s*using\s+([\w.]+)\s*;/g,/(?:^|[\n;])\s*use\s+([\w\\]+)/g,/#\s*include\s*[<"]([^>"\n]+)[>"]/g];function j7(Z){let $=new Set;for(let Q of M7)for(let J of Z.matchAll(Q)){let V=J[1].trim();if(V)$.add(V)}return $}var x4={id:"fallback",extensions:u4,specifiers:j7,resolve(Z,$,Q){let V=[X7($).toLowerCase(),...u4].filter((j,B,M)=>j&&M.indexOf(j)===B),K=Z.includes("/")||Z.includes("\\"),Y=Z.startsWith(".")||K?Z.replace(/\\/g,"/"):Z.replace(/[.:]+/g,"/"),X=[G7(Y7(K7($),Y)).replace(/\\/g,"/"),Y.replace(/^\.\//,"")];for(let j of X){if(Q.fileSet.has(j))return[j];for(let B of V){let M=j.endsWith(B)?j:`${j}${B}`;if(Q.fileSet.has(M))return[M];if(Q.fileSet.has(`${j}/index${B}`))return[`${j}/index${B}`]}}return[]}};var U7=[I4,v4,k4,f4,x4],PZ=new Map;for(let Z of U7)for(let $ of Z.extensions)PZ.set($,Z);var H7={".ts":"ts",".tsx":"ts",".js":"js",".jsx":"js",".mjs":"js",".cjs":"js",".py":"py",".pyi":"py",".go":"go",".rs":"rs",".swift":"swift",".java":"java",".rb":"ruby",".kt":"kotlin",".kts":"kotlin",".cs":"csharp",".php":"php",".scala":"scala",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cc":"cpp",".hh":"cpp",".m":"objc",".mm":"objc",".ex":"elixir",".exs":"elixir",".lua":"lua",".dart":"dart",".vue":"vue",".svelte":"svelte"};function tZ(Z){return PZ.get(g4(Z).toLowerCase())??null}function h4(Z){let $=g4(Z).toLowerCase();if(!PZ.has($))return null;return H7[$]??$.slice(1)}function eZ(){return new Set(PZ.keys())}var r4=new Set(["node_modules",".git",".next","dist","build","__pycache__","target",".venv","venv","env",".turbo","coverage",".beacon",".playwright-mcp","generated","migrations","drizzle","alembic","migrate"]);function C7(Z=5){let $=performance.now();return async()=>{if(performance.now()-$>Z)await new Promise((Q)=>setImmediate(Q)),$=performance.now()}}var B7=()=>Promise.resolve();async function o4(Z,$,Q,J,V){let K;try{K=await W7($,{withFileTypes:!0})}catch{return}for(let Y of K){if(Y.name.startsWith("."))continue;if(r4.has(Y.name))continue;let X=IZ($,Y.name);if(Y.isDirectory()){await o4(Z,X,Q,J,V);continue}if(!Y.isFile())continue;if(Y.name.endsWith(".d.ts"))continue;if(!Q.has(n4(Y.name).toLowerCase()))continue;J.push(HZ(Z,X))}await V()}async function N7(Z,$=B7){let Q=[];return await o4(Z,Z,eZ(),Q,$),Q.map((J)=>J.split(/[\\/]/).join("/")).sort()}function q7(Z){try{return JSON.parse(Z)}catch{}let $=Z.replace(/\/\*[^"]*?\*\//g,"").replace(/(^|[^:"])\/\/.*$/gm,"$1").replace(/,\s*([}\]])/g,"$1");return JSON.parse($)}function b4(Z){return Z.replace(/^\.\/?/,"").replace(/\/$/,"")}function i4(Z){let $=IZ(Z,"tsconfig.json");if(!c4($))return[];let Q;try{Q=q7(l4($,"utf8"))}catch{return[]}let J=Q.compilerOptions?.paths??{},V=b4(Q.compilerOptions?.baseUrl??"."),K=[];for(let[Y,X]of Object.entries(J)){if(!Y.endsWith("/*")||!X.length)continue;let j=X[0];if(!j.endsWith("/*"))continue;let B=Y.slice(0,-1),M=b4(j.slice(0,-1)),L=[V,M].filter(Boolean).join("/");K.push({from:B,to:L})}return K}function EZ(Z){let $=IZ(Z,"go.mod");if(!c4($))return null;try{let Q=/^\s*module\s+(\S+)/m.exec(l4($,"utf8"));return Q?Q[1]:null}catch{return null}}function p(Z){return Z.split(/[\\/]/).join("/")}function s4(Z){if(Z.length===1)return Z[0];let $=Z.map((V)=>p(V).split("/")),Q=$[0],J=0;for(;J<Q.length;J++)if(!$.every((V)=>V[J]===Q[J]))break;return Q.slice(0,J).join("/")||"/"}async function O7(Z,$,Q){let J=(Array.isArray(Z)?Z:[Z]).map((B)=>p(UZ(B))),V=p($?UZ($):J.length===1?J[0]:s4(J)),K=new Map,Y=[];for(let B of J){let M=p(HZ(V,B));for(let L of i4(B))Y.push({from:L.from,to:[M,L.to].filter(Boolean).join("/")});for(let L of await N7(B,Q)){let C=p(IZ(B,L)),q=p(HZ(V,C));if(K.has(q))continue;try{let U=await d4(C);K.set(q,{path:q,abs:C,root:M||null,mtimeMs:U.mtimeMs,size:U.size})}catch{}await Q()}}let X=J.map(EZ).find(Boolean)??EZ(V);return{metas:[...K.values()].sort((B,M)=>B.path.localeCompare(M.path)),ctx:{fileSet:new Set(K.keys()),tsAliases:Y,goModulePath:X}}}var m4=50000;function A7(Z){let $=0;for(let Q=0;Q<Z.length;Q++)if(Z.charCodeAt(Q)===10){if(Q-$>m4)return!0;$=Q+1}return Z.length-$>m4}async function p4(Z){let $=tZ(Z.path);if(!$||Z.size>200000)return new Set;try{let Q=await L7(Z.abs,"utf8");if(A7(Q))return new Set;return $.specifiers(Q)}catch{return new Set}}function a4(Z,$){let Q=(Array.isArray(Z)?Z:[Z]).map((U)=>p(UZ(U))),J=p($?UZ($):Q.length===1?Q[0]:s4(Q)),V=new Map,K=new Map,Y=[],X=null;function j(){Y=[];for(let U of Q){let H=p(HZ(J,U));for(let O of i4(U))Y.push({from:O.from,to:[H,O.to].filter(Boolean).join("/")})}X=Q.map(EZ).find(Boolean)??EZ(J)}function B(U){let H=U.split("/");for(let A=0;A<H.length;A++){let N=H[A];if(!N||N.startsWith("."))return!0;if(A<H.length-1&&r4.has(N))return!0}let O=H[H.length-1];if(O.endsWith(".d.ts"))return!0;return!eZ().has(n4(O).toLowerCase())}function M(U){let H=p(UZ(U));for(let O of Q)if(H===O||H.startsWith(`${O}/`)){let A=H.slice(O.length).replace(/^\/+/,"");if(B(A))return null;return{path:p(HZ(J,H)),root:p(HZ(J,O))||null}}return null}function L(){let U={fileSet:new Set(V.keys()),tsAliases:Y,goModulePath:X},H=[...V.values()].sort((N,G)=>N.path.localeCompare(G.path)),O=[];for(let N of H){let G=tZ(N.path);if(!G)continue;let _=K.get(N.path)??new Set,F=new Set;for(let R of _)for(let y of G.resolve(R,N.path,U)){if(!y||y===N.path||F.has(y))continue;F.add(y),O.push({from:N.path,to:y})}}return{files:H.map((N)=>({path:N.path,lang:h4(N.path),root:N.root,mtimeMs:N.mtimeMs,size:N.size})),edges:O}}async function C(){let U=C7(),{metas:H,ctx:O}=await O7(Z,$,U);V.clear(),K.clear();for(let A of H)await U(),V.set(A.path,A),K.set(A.path,await p4(A));return Y=O.tsAliases??[],X=O.goModulePath??null,L()}async function q(U){let H=p(UZ(U));if(!Q.some((F)=>H===F||H.startsWith(`${F}/`)))return!1;let O=H.split("/").pop()??"";if(O==="tsconfig.json"||O==="go.mod"){let F=H.slice(0,H.length-O.length-1);if(Q.includes(F))return j(),!0;return!1}let A=M(U);if(!A)return!1;let N;try{N=await d4(H)}catch{let F=V.delete(A.path);return K.delete(A.path),F}let G=V.get(A.path);if(G&&G.mtimeMs===N.mtimeMs&&G.size===N.size)return!1;let _={path:A.path,abs:H,root:A.root,mtimeMs:N.mtimeMs,size:N.size};return V.set(A.path,_),K.set(A.path,await p4(_)),!0}return{seed:C,applyChange:q,snapshot:L}}function t4(Z){let $=Object.keys(Z.tableVars),Q=new Map;if(!$.length){for(let Y of Z.routeFiles)Q.set(Y,[]);return Q}let J=new Map;for(let Y of Z.edges){let X=J.get(Y.from)??[];X.push(Y.to),J.set(Y.from,X)}let V=new Map($.map((Y)=>[Y,new RegExp(`(?:query\\.${Y}\\b|\\.from\\(\\s*${Y}\\b)`)])),K=new Map($.map((Y)=>[Y,new RegExp(`(?:insert|update|delete)\\(\\s*${Y}\\b`)]));for(let Y of Z.routeFiles){let X=new Set([Y]),j=[Y];for(let C=0;C<2&&X.size<25;C++){let q=[];for(let U of j)for(let H of J.get(U)??[]){if(X.has(H)||X.size>=25)continue;X.add(H),q.push(H)}j=q}let B=new Set,M=new Set;for(let C of X){let q=Z.content(C);if(!q)continue;for(let U of $){if(!B.has(U)&&V.get(U).test(q))B.add(U);if(!M.has(U)&&K.get(U).test(q))M.add(U)}}let L=[];for(let C of $){let q=B.has(C),U=M.has(C);if(!q&&!U)continue;L.push({table:Z.tableVars[C],access:q&&U?"read-write":U?"write":"read"})}Q.set(Y,L)}return Q}function e4(Z,$){if(/_JSON_OR_JSONB|\bJSONB\b|\bJSON\b/.test(Z))return"jsonb";let Q=Z.match(/\b(GUID|Uuid|UUID|String|Text|DateTime|Date|Time|BigInteger|SmallInteger|Integer|Boolean|Float|Numeric|Decimal|Vector|TSVECTOR|LargeBinary|Enum)\b\s*(\([^)]*\))?/);if(Q){let K=Q[2]??"",Y=K.match(/\d+/)?.[0];switch(Q[1]){case"GUID":case"Uuid":case"UUID":return"uuid";case"String":return Y?`varchar(${Y})`:"varchar";case"Text":return"text";case"DateTime":return/timezone\s*=\s*True/.test(K)?"timestamptz":"timestamp";case"Date":return"date";case"Time":return"time";case"BigInteger":return"bigint";case"SmallInteger":return"smallint";case"Integer":return"integer";case"Boolean":return"boolean";case"Float":return"float";case"Numeric":case"Decimal":return"numeric";case"Vector":return Y?`vector(${Y})`:"vector";case"TSVECTOR":return"tsvector";case"LargeBinary":return"bytea";case"Enum":return"varchar"}}let J=$.replace(/\s*\|\s*None/g,"").trim(),V=J.match(/^Optional\[([\s\S]*)\]$/);if(V)J=V[1].trim();if(/uuid/i.test(J))return"uuid";if(/datetime/i.test(J))return"timestamptz";if(/\bint\b/i.test(J))return"integer";if(/\bbool\b/i.test(J))return"boolean";if(/\bfloat\b/.test(J)&&!/\blist\b/.test(J))return"float";if(/\bdict\b|\blist\b|\bAny\b/.test(J))return"jsonb";return"text"}function RZ(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="(")Q++;else if(Z[J]===")"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function _7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="[")Q++;else if(Z[J]==="]"){if(Q--,Q===0)return Z.slice($+1,J)}return null}function F7(Z,$,Q){let J=Q.match(/__tablename__\s*=\s*["']([^"']+)["']/)?.[1],V=[],K=[],Y=[],X=/(\w+)\s*:\s*Mapped\s*\[/g,j;while(j=X.exec(Q)){let L=j.index+j[0].length-1,C=_7(Q,L);if(C===null)continue;let q=L+C.length+2,U=Q.slice(q).match(/^\s*=\s*(\w+)\s*\(/);if(!U||U[1]!=="mapped_column")continue;Y.push({colName:j[1],pyType:C,argsAt:q+U[0].length-1})}let B=/(\w+)\s*=\s*(mapped_column|Column)\s*\(/g;while(j=B.exec(Q))Y.push({colName:j[1],pyType:"",argsAt:j.index+j[0].length-1});Y.sort((L,C)=>L.argsAt-C.argsAt);let M=new Set;for(let L of Y){if(M.has(L.colName)||L.colName==="__tablename__")continue;M.add(L.colName);let C=RZ(Q,L.argsAt),q=/primary_key\s*=\s*True/.test(C)||void 0,U=/nullable\s*=\s*False/.test(C)?!1:!0,H=C.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(V.push({name:L.colName,type:e4(C,L.pyType),isPk:q,isFk:H?!0:void 0,nullable:U}),H)K.push({column:L.colName,toTable:H[1],toColumn:H[2]})}return{name:Z,bases:$,tableName:J,columns:V,fks:K}}function D7(Z){let $=[],Q=[],J=/\bTable\s*(\()\s*["']([^"']+)["']\s*,/g,V;while(V=J.exec(Z)){let K=V[2],Y=RZ(Z,V.index+V[0].indexOf("("));if(!/\bmetadata\b/.test(Y)||!/\bColumn\s*\(/.test(Y))continue;let X=[],j=/\bColumn\s*\(/g,B;while(B=j.exec(Y)){let M=RZ(Y,B.index+B[0].length-1),L=M.match(/^\s*["'](\w+)["']\s*,/)?.[1];if(!L)continue;let C=/primary_key\s*=\s*True/.test(M)||void 0,q=/nullable\s*=\s*False/.test(M)?!1:!0,U=M.match(/ForeignKey\(\s*["']([^"']+?)\.([^"'.]+)["']/);if(X.push({name:L,type:e4(M,""),isPk:C,isFk:U?!0:void 0,nullable:q}),U)Q.push({fromTable:K,fromColumn:L,toTable:U[1],toColumn:U[2]})}if(X.length)$.push({name:K,columns:X})}return{tables:$,relations:Q}}function z7(Z){let $=new Map,Q={tables:[],relations:[]};for(let X of Z){if(!X.path.endsWith(".py"))continue;if(!/mapped_column\s*\(|__tablename__|\bTable\s*\(\s*["']/.test(X.content))continue;let j=D7(X.content);Q.tables.push(...j.tables),Q.relations.push(...j.relations);let B=/^class\s+(\w+)\s*\(([^)]*)\)\s*:/gm,M,L=[];while(M=B.exec(X.content))L.push({name:M[1],bases:M[2].split(",").map((C)=>C.trim().split(/[.[]/)[0]).filter(Boolean),at:M.index});for(let C=0;C<L.length;C++){let q=X.content.slice(L[C].at,L[C+1]?.at??X.content.length),U=F7(L[C].name,L[C].bases,q);$.set(U.name,U)}}if(![...$.values()].some((X)=>X.tableName)&&!Q.tables.length)return{tables:[],relations:[]};let J=(X,j=new Set)=>{if(j.has(X.name))return[];j.add(X.name);let B=[];for(let M of X.bases){let L=$.get(M);if(L&&!L.tableName)B.push(...J(L,j))}return B.push(...X.columns),B},V=[],K=[];for(let X of $.values()){if(!X.tableName)continue;let j=J(X),B=new Map;for(let U of j)if(!B.has(U.name))B.set(U.name,U);let M=[...B.values()],L=(U)=>M.splice(M.findIndex((H)=>H.name===U),1)[0],C=M.some((U)=>U.name==="id")?L("id"):null,q=["created_at","updated_at","deleted_at"].filter((U)=>M.some((H)=>H.name===U)).map((U)=>L(U));V.push({name:X.tableName,columns:[...C?[C]:[],...M,...q]});for(let U of X.fks)K.push({fromTable:X.tableName,fromColumn:U.column,toTable:U.toTable,toColumn:U.toColumn})}let Y=new Set(V.map((X)=>X.name));for(let X of Q.tables)if(!Y.has(X.name))V.push(X);return K.push(...Q.relations.filter((X)=>!Y.has(X.fromTable))),{tables:V,relations:K}}function P7(Z){let $=Z.replace(/[?[\]]/g,"");return{String:"text",Int:"integer",BigInt:"bigint",Float:"float",Decimal:"numeric",Boolean:"boolean",DateTime:"timestamptz",Json:"jsonb",Bytes:"bytea"}[$]??$.toLowerCase()}function E7(Z){let $=[],Q=[];for(let J of Z){if(!J.path.endsWith(".prisma"))continue;let V=/model\s+(\w+)\s*\{([\s\S]*?)\}/g,K;while(K=V.exec(J.content)){let Y=K[1],X=K[2].match(/@@map\(\s*["']([^"']+)["']\s*\)/)?.[1]??Y,j=[];for(let B of K[2].split(`
|
|
4
|
+
`)){let M=B.trim().match(/^(\w+)\s+(\w+(?:\[\])?\??)\s*(.*)$/);if(!M||/^@@/.test(B.trim()))continue;let[,L,C,q]=M,U=/^(String|Int|BigInt|Float|Decimal|Boolean|DateTime|Json|Bytes)(\[\])?\??$/.test(C),H=q.match(/@relation\([^)]*fields:\s*\[(\w+)\][^)]*references:\s*\[(\w+)\]/);if(H)Q.push({fromTable:X,fromColumn:H[1],toTable:C.replace(/[?[\]]/g,""),toColumn:H[2]});if(!U)continue;j.push({name:L,type:P7(C),isPk:/@id\b/.test(q)||void 0,isFk:/@relation\b/.test(q)||void 0,nullable:C.endsWith("?")})}if(j.length)$.push({name:X,columns:j})}}return{tables:$,relations:Q}}function I7(Z,$){if(/mode:\s*["']timestamp/.test($))return"timestamp";if(/mode:\s*["']boolean["']/.test($))return"boolean";if(/mode:\s*["']json["']/.test($))return"jsonb";return Z}function R7(Z,$){let Q=0;for(let J=$;J<Z.length;J++)if(Z[J]==="{")Q++;else if(Z[J]==="}"){if(Q--,Q===0)return Z.slice($+1,J)}return""}function S7(Z){let $=[],Q=/(\w+)\s*:\s*(text|integer|real|blob|numeric|varchar|boolean|timestamp|serial|uuid|json|jsonb)\s*\(/g;for(let K of Z){if(!/\.(ts|tsx|mts|cts)$/.test(K.path))continue;if(!/\b(?:sqliteTable|pgTable|mysqlTable)\s*\(/.test(K.content))continue;let Y=/(?:export\s+)?const\s+(\w+)\s*=\s*(?:sqliteTable|pgTable|mysqlTable)\s*\(\s*["']([^"']+)["']\s*,/g,X;while(X=Y.exec(K.content)){let j=K.content.indexOf("{",X.index+X[0].length);if(j<0)continue;let B=R7(K.content,j),M={varName:X[1],tableName:X[2],columns:[],colByProp:new Map,fks:[]},L=[];Q.lastIndex=0;for(let C of B.matchAll(Q))L.push({prop:C[1],builder:C[2],at:C.index,argOpen:C.index+C[0].length-1});L.forEach((C,q)=>{let U=B.slice(C.at,L[q+1]?.at??B.length),H=RZ(B,C.argOpen),A=H.match(/^\s*["']([^"']+)["']/)?.[1]??C.prop,N=U.match(/\.references\(\s*\(\)\s*=>\s*(\w+)\.(\w+)/);if(M.columns.push({name:A,type:I7(C.builder,H),isPk:/\.primaryKey\(\)/.test(U)||void 0,isFk:N?!0:void 0,nullable:/\.notNull\(\)/.test(U)?!1:!0}),M.colByProp.set(C.prop,A),N)M.fks.push({column:A,toVar:N[1],toProp:N[2]})}),$.push(M)}}if(!$.length)return{tables:[],relations:[]};let J=new Map($.map((K)=>[K.varName,K])),V=[];for(let K of $)for(let Y of K.fks){let X=J.get(Y.toVar);if(!X)continue;V.push({fromTable:K.tableName,fromColumn:Y.column,toTable:X.tableName,toColumn:X.colByProp.get(Y.toProp)??Y.toProp})}return{tables:$.map((K)=>({name:K.tableName,columns:K.columns})),relations:V,tableVars:Object.fromEntries($.map((K)=>[K.varName,K.tableName]))}}function Z5(Z){let $=S7(Z);if($.tables.length)return $;let Q=E7(Z);if(Q.tables.length)return Q;return z7(Z)}var v7=["GET","POST","PUT","PATCH","DELETE"];function k7(Z){let $=Z.match(/(?:^|\/)app\/(.+)\/route\.(?:ts|tsx|js|jsx|mjs)$/);if(!$)return null;let Q=$[1].split("/").filter((J)=>!(J.startsWith("(")&&J.endsWith(")"))).map((J)=>{let V=J.match(/^\[{1,2}(?:\.\.\.)?([^\]]+)\]{1,2}$/);return V?`{${V[1]}}`:J});if(Q[0]!=="api")return null;return`/${Q.join("/")}`}function $5(Z){let $=[];for(let Q of Z){let J=k7(Q.path);if(!J)continue;for(let V of v7)if(new RegExp(`export\\s+(?:async\\s+)?(?:function|const)\\s+${V}\\b`).test(Q.content))$.push({method:V,path:J,uses:[],file:Q.path})}return $.sort((Q,J)=>`${Q.path} ${Q.method}`.localeCompare(`${J.path} ${J.method}`))}var T7=/(^|\/)app\/.*\/route\.(ts|tsx|js|jsx|mjs)$/,w7=/\.(ts|py)$/,y7=/(schema|model)/i;function Z4(Z){if(Z.endsWith(".prisma"))return!0;if(T7.test(Z))return!0;return w7.test(Z)&&y7.test(Z)}function Q5(Z,$=300){return Z.filter(Z4).slice(0,$)}import{z as d}from"zod";import{and as F5,eq as WZ,inArray as J8,notInArray as V8}from"drizzle-orm";import{z as P}from"zod";import{and as t7,eq as kZ,inArray as Q4,notInArray as e7,or as Z8,sql as $8}from"drizzle-orm";var J5=240,V5=50;function K5(Z){for(let $=0;$<Z.length;$++)for(let Q=$+1;Q<Z.length;Q++){let J=Z[$],V=Z[Q];if(J.x<V.x+J5&&J.x+J5>V.x&&J.y<V.y+V5&&J.y+V5>V.y)return!0}return!1}import{eq as f7}from"drizzle-orm";var X5=(Z)=>Z.replace(/\{[^}]*\}/g,"{}");function u7(Z,$){if(Z.method.toUpperCase()!==$.method.toUpperCase())return!1;let Q=X5(Z.path),J=X5($.path);return J===Q||J.endsWith(Q)}async function Y5(Z=m){let[$,Q]=await Promise.all([Z.query.endpoint.findMany({where:(V,{ne:K})=>K(V.source,"INTROSPECTION")}),Z.query.endpoint.findMany({where:(V,{eq:K})=>K(V.source,"INTROSPECTION")})]),J={collapsed:0,mappings:[]};for(let V of $){let K=Q.find((Y)=>u7(V,Y));if(!K)continue;await Z.delete(v).where(f7(v.id,V.id)),J.collapsed++,J.mappings.push({planned:`${V.method} ${V.path}`,code:`${K.method} ${K.path}`})}return J}import{and as G5,inArray as x7,isNull as M5,ne as j5,or as g7}from"drizzle-orm";var h7=new Set(["DONE","CANCELLED","DEPRIORITIZED"]);async function b7(Z){let $=await Z.query.node.findMany({where:(J,{and:V,eq:K,isNotNull:Y})=>V(K(J.view,"ROADMAP"),Y(J.planId)),columns:{planId:!0,status:!0}}),Q=new Map;for(let J of $){let V=J.planId;Q.set(V,(Q.get(V)??!0)&&h7.has(J.status))}return[...Q.entries()].filter(([,J])=>J).map(([J])=>J)}async function U5(Z=m){let $=await b7(Z),Q=(K)=>$.length?g7(M5(K.planId),x7(K.planId,$)):M5(K.planId),J=await Z.delete(E).where(G5(j5(E.source,"INTROSPECTION"),Q(E))).returning({id:E.id}),V=await Z.delete(v).where(G5(j5(v.source,"INTROSPECTION"),Q(v))).returning({id:v.id});return{tables:J.length,endpoints:V.length}}var W5=320;function $Z(Z){return 36+Math.max(0,Z)*30+16}var YZ=60,m7=280,SZ=14,H5=120,OZ=170,p7=2560;var vZ=(Z)=>(Z??"").trim()||"\u2014";function c7(Z,$,Q){let J=new Map;for(let K of Z.uses){if(!$.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}let V=null;for(let[K,Y]of J){if(V===null){V=K;continue}let X=J.get(V);if(Y>X){V=K;continue}if(Y<X)continue;let j=Q?.get(K)??0,B=Q?.get(V)??0;if(j<B)V=K;else if(j===B&&$.get(K).localeCompare($.get(V))<0)V=K}return V}function $4(Z,$){let Q=new Map(Z.map((V)=>[V.id,V.name])),J=new Map;for(let V of $)for(let K of V.uses){if(!Q.has(K.tableId))continue;J.set(K.tableId,(J.get(K.tableId)??0)+1)}return new Map($.map((V)=>[V.id,c7(V,Q,J)]))}var l7=(Z,$)=>Z.path.localeCompare($.path)||Z.method.localeCompare($.method)||Z.id.localeCompare($.id);function L5(Z,$){let Q=$4(Z,$),J=new Map,V=[];for(let N of[...$].sort(l7)){let G=Q.get(N.id)??null;if(G){let _=J.get(G);if(_)_.push(N);else J.set(G,[N])}else V.push(N)}let K=(N)=>{let G=J.get(N.id)?.length??0;return $Z(N.columnCount)+(G?SZ+G*YZ:0)+50},Y=Array.from(new Set(Z.map((N)=>vZ(N.domain)))),X=Y.filter((N)=>N!=="\u2014").sort(),j=Y.includes("\u2014")?[...X,"\u2014"]:X,B=[];for(let N of j){let G=Z.filter((S)=>vZ(S.domain)===N).sort((S,I)=>S.name.localeCompare(I.name)),_=G.reduce((S,I)=>S+K(I),0),F=Math.max(1,Math.min(12,G.length,Math.round(Math.sqrt(_/320)))),R=Array(F).fill(0),y=new Map;for(let S of G){let I=0;for(let D=1;D<F;D++)if(R[D]<R[I])I=D;y.set(S.id,{x:I*320,y:R[I]}),R[I]+=K(S)}B.push({d:N,w:F*320,h:Math.max(...R,0),tableLocal:y})}let M=B.reduce((N,G)=>N+(G.w+H5)*(G.h+OZ),0),L=Math.max(p7,Math.round(Math.sqrt(M*2.2))),C=new Map,q=new Map,U=0,H=0,O=0,A=0;for(let N of B){if(U>0&&U+N.w>L)H+=O+OZ,U=0,O=0;let G=Z.filter((_)=>N.tableLocal.has(_.id));for(let _ of G){let F=N.tableLocal.get(_.id),R=U+F.x,y=H+F.y;C.set(_.id,{x:R,y}),(J.get(_.id)??[]).forEach((I,D)=>{q.set(I.id,{x:R,y:y+$Z(_.columnCount)+SZ+D*YZ})})}O=Math.max(O,N.h),A=Math.max(A,H+N.h),U+=N.w+H5}if(V.length){let N=A+OZ,G=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(V.length/2))));V.forEach((_,F)=>{q.set(_.id,{x:F%G*m7,y:N+Math.floor(F/G)*YZ})})}return{tables:C,endpoints:q}}function C5(Z,$,Q){let J=$4($,Q),V=new Map;for(let q of Q){let U=J.get(q.id);if(U)V.set(U,(V.get(U)??0)+1)}let K=(q)=>{let U=V.get(q.id)??0;return q.y+$Z(q.columnCount)+(U?SZ+U*YZ:0)},Y=vZ(Z.domain),X=$.filter((q)=>vZ(q.domain)===Y);if(!X.length){let q=$.length?Math.max(...$.map(K),...Q.map((U)=>U.y+YZ)):0;return{x:0,y:$.length||Q.length?q+OZ:0}}let j=Math.min(...X.map((q)=>q.x)),B=X.map((q)=>Math.max(0,Math.round((q.x-j)/320))),M=Math.min(12,Math.max(...B)+1),L=Array(M).fill(Math.min(...X.map((q)=>q.y)));X.forEach((q,U)=>{let H=Math.min(B[U],M-1);L[H]=Math.max(L[H],K(q)+50)});let C=0;for(let q=1;q<M;q++)if(L[q]<L[C])C=q;return{x:j+C*320,y:L[C]}}function B5(Z,$,Q){let J=$4($,[...Q,Z]),V=J.get(Z.id),K=V?$.find((X)=>X.id===V):void 0;if(K){let X=Q.filter((M)=>J.get(M.id)===K.id),j=K.y+$Z(K.columnCount)+SZ,B=X.length?Math.max(...X.map((M)=>M.y))+YZ:j;return{x:K.x,y:B}}let Y=[...$.map((X)=>X.y+$Z(X.columnCount)),...Q.map((X)=>X.y+YZ)];return{x:0,y:Y.length?Math.max(...Y)+OZ:0}}function N5(Z){let $=W5-20;for(let Q=0;Q<Z.length;Q++)for(let J=Q+1;J<Z.length;J++){let V=Z[Q],K=Z[J],Y=$Z(V.columnCount),X=$Z(K.columnCount);if(V.x<K.x+$&&V.x+$>K.x&&V.y<K.y+X&&V.y+Y>K.y)return!0}return!1}import{eq as O5}from"drizzle-orm";q5();async function A5(Z=m){let[$,Q]=await Promise.all([Z.query.dbTable.findMany({with:{columns:{columns:{id:!0}}},orderBy:(K,{asc:Y})=>Y(K.name)}),Z.query.endpoint.findMany({with:{tables:{columns:{tableId:!0}}}})]),J=L5($.map((K)=>({id:K.id,name:K.name,domain:K.domain,columnCount:K.columns.length})),Q.map((K)=>({id:K.id,method:K.method,path:K.path,uses:K.tables.map((Y)=>({tableId:Y.tableId}))}))),V=0;for(let K of $){let Y=J.tables.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(E).set({x:Y.x,y:Y.y}).where(O5(E.id,K.id)),V++}for(let K of Q){let Y=J.endpoints.get(K.id);if(!Y||Math.round(Y.x)===Math.round(K.x)&&Math.round(Y.y)===Math.round(K.y))continue;await Z.update(v).set({x:Y.x,y:Y.y}).where(O5(v.id,K.id)),V++}return V}var Q8=P.object({tables:P.array(P.object({name:P.string().trim().min(1),domain:P.string().nullish(),description:P.string().nullish(),columns:P.array(P.object({name:P.string().trim().min(1),type:P.string().trim().min(1),isPk:P.boolean().optional(),isFk:P.boolean().optional(),nullable:P.boolean().optional(),note:P.string().nullish()})).default([])})).default([]),relations:P.array(P.object({fromTable:P.string(),fromColumn:P.string(),toTable:P.string(),toColumn:P.string(),label:P.string().nullish()})).default([]),endpoints:P.array(P.object({method:P.string().trim().min(1),path:P.string().trim().min(1),domain:P.string().nullish(),description:P.string().nullish(),uses:P.array(P.object({table:P.string(),access:P.string().default("read")})).default([])})).default([])});async function TZ(Z=m){let[$]=await Z.insert(s).values({id:"singleton",version:1}).onConflictDoUpdate({target:s.id,set:{version:$8`${s.version} + 1`}}).returning();return $.version}async function _5(Z,$=m,Q={}){let J=Q8.parse(Z),V=J.tables.length>0,K=J.endpoints.length>0,Y=J.tables.map((G)=>G.name);if(V)await $.delete(E).where(Y.length?t7(kZ(E.source,"INTROSPECTION"),e7(E.name,Y)):kZ(E.source,"INTROSPECTION"));let X=await $.query.dbTable.findMany({columns:{id:!0,name:!0,domain:!0,x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),j=await $.query.endpoint.findMany({columns:{id:!0,method:!0,path:!0,x:!0,y:!0},with:{tables:{columns:{tableId:!0}}}}),B=new Map(X.map((G)=>[G.name,G])),M=X.map((G)=>({id:G.id,name:G.name,domain:G.domain,columnCount:G.columns.length,x:G.x,y:G.y})),L=j.map((G)=>({id:G.id,method:G.method,path:G.path,uses:G.tables.map((_)=>({tableId:_.tableId})),x:G.x,y:G.y})),C=new Map;for(let G of J.tables){if(B.has(G.name))continue;let _=C5({domain:G.domain??null,columnCount:G.columns.length},M,L);C.set(G.name,_),M.push({id:`new:${G.name}`,name:G.name,domain:G.domain??null,columnCount:G.columns.length,..._})}let q=new Map;for(let G of J.tables){let _=B.get(G.name),F=C.get(G.name),R=_?.x??F?.x??0,y=_?.y??F?.y??0,[S]=await $.insert(E).values({name:G.name,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:R,y}).onConflictDoUpdate({target:E.name,set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(q.set(G.name,S.id),await $.delete(e).where(kZ(e.tableId,S.id)),G.columns.length)await $.insert(e).values(G.columns.map((I,D)=>({tableId:S.id,name:I.name,type:I.type,isPk:I.isPk??!1,isFk:I.isFk??!1,nullable:I.nullable??!0,note:I.note??null,ord:D})))}let U=[...q.values()];if(U.length)await $.delete(l).where(Z8(Q4(l.fromTableId,U),Q4(l.toTableId,U)));for(let G of J.relations){let _=q.get(G.fromTable),F=q.get(G.toTable);if(!_||!F)continue;await $.insert(l).values({fromTableId:_,toTableId:F,fromColumn:G.fromColumn,toColumn:G.toColumn,label:G.label??`${G.fromColumn} \u2192 ${G.toTable}.${G.toColumn}`})}let H=new Set(J.endpoints.map((G)=>`${G.method} ${G.path}`));if(K){let _=(await $.query.endpoint.findMany({where:(F,{eq:R})=>R(F.source,"INTROSPECTION")})).filter((F)=>!H.has(`${F.method} ${F.path}`)).map((F)=>F.id);if(_.length)await $.delete(v).where(Q4(v.id,_))}for(let G of M)if(G.id.startsWith("new:"))G.id=q.get(G.name)??G.id;for(let G of J.endpoints){let _=await $.query.endpoint.findFirst({where:(S,{and:I,eq:D})=>I(D(S.method,G.method),D(S.path,G.path))}),F,R;if(_)F=_.x,R=_.y;else{let S={id:`new:${G.method} ${G.path}`,method:G.method,path:G.path,uses:G.uses.map((D)=>({tableId:q.get(D.table)??""})).filter((D)=>D.tableId)},I=B5(S,M,L);F=I.x,R=I.y,L.push({...S,x:F,y:R})}let[y]=await $.insert(v).values({method:G.method,path:G.path,domain:G.domain??null,description:G.description??null,source:"INTROSPECTION",x:F,y:R}).onConflictDoUpdate({target:[v.method,v.path],set:{...G.domain!=null?{domain:G.domain}:{},...G.description!=null?{description:G.description}:{},source:"INTROSPECTION"}}).returning();if(!Q.partial||G.uses.length>0)await $.delete(o).where(kZ(o.endpointId,y.id));for(let S of G.uses){let I=q.get(S.table)??(await $.query.dbTable.findFirst({where:(D,{eq:MZ})=>MZ(D.name,S.table)}))?.id;if(!I)continue;await $.insert(o).values({endpointId:y.id,tableId:I,access:S.access})}}await Y5($),await U5($);let O=await $.query.dbTable.findMany({where:(G,{eq:_})=>_(G.source,"INTROSPECTION"),columns:{x:!0,y:!0},with:{columns:{columns:{id:!0}}}}),A=await $.select({x:v.x,y:v.y}).from(v);if(N5(O.map((G)=>({x:G.x,y:G.y,columnCount:G.columns.length})))||K5(A))await A5($);let N=await TZ($);return{tables:J.tables.length,relations:J.relations.length,endpoints:J.endpoints.length,version:N}}var D5=d.object({files:d.array(d.object({path:d.string().trim().min(1),root:d.string().nullish(),lang:d.string().nullish(),mtimeMs:d.number().nullish(),size:d.number().nullish()})).default([]),edges:d.array(d.object({from:d.string().trim().min(1),to:d.string().trim().min(1)})).default([])});function z5(Z,$){let Q=new Map;for(let C of Z)Q.set(C,[]);for(let C of $)Q.get(C.from)?.push(C.to);let J=new Map,V=new Map,K=new Set,Y=[],X=new Map,j=[],B=0,M=0;for(let C of Z){if(J.has(C))continue;let q=[{v:C,iter:0}];J.set(C,B),V.set(C,B),B++,Y.push(C),K.add(C);while(q.length){let U=q[q.length-1],H=Q.get(U.v)??[];if(U.iter<H.length){let O=H[U.iter++];if(!J.has(O))J.set(O,B),V.set(O,B),B++,Y.push(O),K.add(O),q.push({v:O,iter:0});else if(K.has(O))V.set(U.v,Math.min(V.get(U.v),J.get(O)))}else{if(V.get(U.v)===J.get(U.v)){let A=0,N;do N=Y.pop(),K.delete(N),X.set(N,M),A++;while(N!==U.v);j.push(A),M++}q.pop();let O=q[q.length-1];if(O)V.set(O.v,Math.min(V.get(O.v),V.get(U.v)))}}}let L=new Set;for(let C of $){let q=X.get(C.from);if(q!==void 0&&q===X.get(C.to)&&j[q]>1)L.add(`${C.from}|${C.to}`)}return L}async function P5(Z,$=m){let Q=D5.parse(Z),J=Q.files.map((L)=>L.path),V=new Set(J),K=Q.edges.filter((L)=>V.has(L.from)&&V.has(L.to)&&L.from!==L.to),Y=z5(J,K),X=new Map,j=new Map;for(let L of K)j.set(L.from,(j.get(L.from)??0)+1),X.set(L.to,(X.get(L.to)??0)+1);await $.delete(f).where(V8(f.path,J));for(let L of Q.files){let C={root:L.root??null,lang:L.lang??null,mtimeMs:L.mtimeMs??null,size:L.size??null,inDegree:X.get(L.path)??0,outDegree:j.get(L.path)??0};await $.insert(f).values({path:L.path,...C}).onConflictDoUpdate({target:f.path,set:C})}await $.delete(u);let B=0;if(K.length)await $.insert(u).values(K.map((L)=>{let C=Y.has(`${L.from}|${L.to}`);if(C)B++;return{fromPath:L.from,toPath:L.to,circular:C}}));let M=await TZ($);return await $.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton")),{files:Q.files.length,edges:K.length,circular:B,version:M}}var K8=(Z,$)=>`${Z}\x00${$}`;function J4(Z){let $=D5.parse(Z),Q=$.files.map((M)=>M.path),J=new Set(Q),V=$.edges.filter((M)=>J.has(M.from)&&J.has(M.to)&&M.from!==M.to),K=z5(Q,V),Y=new Map,X=new Map;for(let M of V)X.set(M.from,(X.get(M.from)??0)+1),Y.set(M.to,(Y.get(M.to)??0)+1);let j=new Map;for(let M of $.files)j.set(M.path,{root:M.root??null,lang:M.lang??null,mtimeMs:M.mtimeMs??null,size:M.size??null,inDegree:Y.get(M.path)??0,outDegree:X.get(M.path)??0});let B=new Map;for(let M of V)B.set(K8(M.from,M.to),{from:M.from,to:M.to,circular:K.has(`${M.from}|${M.to}`)});return{files:j,edges:B}}var X8=(Z,$)=>Z.root===$.root&&Z.lang===$.lang&&Z.mtimeMs===$.mtimeMs&&Z.size===$.size&&Z.inDegree===$.inDegree&&Z.outDegree===$.outDegree;async function E5(Z,$,Q=m){for(let[X,j]of $.files){let B=Z.files.get(X);if(B&&X8(B,j))continue;let M={root:j.root,lang:j.lang,mtimeMs:j.mtimeMs,size:j.size,inDegree:j.inDegree,outDegree:j.outDegree};await Q.insert(f).values({path:X,...M}).onConflictDoUpdate({target:f.path,set:M})}let J=[...Z.files.keys()].filter((X)=>!$.files.has(X));if(J.length)await Q.delete(f).where(J8(f.path,J));for(let[X,j]of Z.edges)if(!$.edges.has(X))await Q.delete(u).where(F5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)));let V=[];for(let[X,j]of $.edges){let B=Z.edges.get(X);if(!B)V.push({fromPath:j.from,toPath:j.to,circular:j.circular});else if(B.circular!==j.circular)await Q.update(u).set({circular:j.circular}).where(F5(WZ(u.fromPath,j.from),WZ(u.toPath,j.to)))}if(V.length)await Q.insert(u).values(V);let K=await TZ(Q);await Q.update(s).set({codeGraphSyncedAt:new Date}).where(WZ(s.id,"singleton"));let Y=0;for(let X of $.edges.values())if(X.circular)Y++;return{files:$.files.size,edges:$.edges.size,circular:Y,version:K}}var U8=/[/\\](node_modules|\.git|\.next|dist|build|__pycache__|target|\.venv|venv|\.beacon|\.playwright-mcp|generated|coverage)[/\\]/;function H8(Z){try{let $=AZ(Z,"beacon.config.json");if(R5($)){let Q=JSON.parse(Y8($,"utf8"));if(Array.isArray(Q.roots)&&Q.roots.length)return Q.roots.map((J)=>j8(Z,J))}}catch{}return[Z]}function S5(Z){let $=H8(Z.path),Q=cZ(Z.id),J=oZ(JZ(Z.id)),V=a4($,Z.path);async function K(){let H=Q5(V.snapshot().files.map((_)=>_.path));for(let _ of $)for(let F of["prisma/schema.prisma","schema.prisma"]){let R=AZ(_,F);if(R5(R))H.push(Y(R))}let O=[];for(let _ of H)try{O.push({path:_,content:await I5(AZ(Z.path,_),"utf8")})}catch{}let A=Z5(O),N=$5(O);if(!A.tables.length&&!N.length)return;if(N.length&&A.tableVars&&Object.keys(A.tableVars).length){let F=V.snapshot().edges,R=new Set(N.map((D)=>D.file)),y=new Map;for(let D of F){let MZ=y.get(D.from)??[];MZ.push(D.to),y.set(D.from,MZ)}for(let D=0;D<2;D++)for(let MZ of[...R])for(let x5 of y.get(MZ)??[])R.add(x5);let S=new Map;for(let D of[...R].slice(0,600))try{S.set(D,await I5(AZ(Z.path,D),"utf8"))}catch{}let I=t4({routeFiles:[...new Set(N.map((D)=>D.file))],edges:F,content:(D)=>S.get(D)??null,tableVars:A.tableVars});for(let D of N)D.uses=I.get(D.file)??[]}let G=await _5({tables:A.tables,relations:A.relations,endpoints:N},J,{partial:!0});console.log(`[beacon-inline] schema synced (${Z.name}): ${G.tables} tables / ${G.endpoints} endpoints`)}function Y(H){return M8(Z.path,H).split(/[\\/]/).join("/")}let X=null,j=!1,B=new Set,M=null,L=!1;async function C(){if(L){q();return}L=!0;try{if(await Q,j)X=null,j=!1;if(X===null){let N=await V.seed(),G=await P5(N,J);X=J4(N),console.log(`[beacon-inline] code-graph synced (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`),await K();return}let H=[...B];B.clear();let O=H.some((N)=>Z4(Y(N))),A=!1;for(let N of H)if(await V.applyChange(N))A=!0;if(A){let N=J4(V.snapshot()),G=await E5(X,N,J);X=N,console.log(`[beacon-inline] code-graph updated (${Z.name}): ${G.files} files / ${G.edges} imports${G.circular>0?` (${G.circular} circular)`:""}`)}if(O)await K()}catch(H){console.error(`[beacon-inline] error (${Z.name}):`,H instanceof Error?H.message:H)}finally{L=!1}}function q(){if(M)clearTimeout(M);M=setTimeout(C,600)}let U=[];for(let H of $)try{let O=G8(H,{recursive:!0,persistent:!0},(A,N)=>{if(!N){j=!0,q();return}let G=String(N);if(U8.test(`/${G}`))return;B.add(AZ(H,G)),q()});O.on("error",(A)=>console.error(`[beacon-inline] watcher error (${Z.name}):`,A)),U.push(O)}catch(O){console.error(`[beacon-inline] live watch unavailable for ${H} (${Z.name}):`,O instanceof Error?O.message:O)}return console.log(`[beacon-inline] watching ${Z.name} (${$.join(", ")}) \u2014 initial extract\u2026`),C(),{async stop(){if(M)clearTimeout(M);for(let H of U)H.close()}}}function L8(Z){let $=Z.limit??6,Q=Z.hardCap??12,J=new Map,V=0,K=new Set;function Y(H){let O=J.get(H);if(O)O.seq=++V}function X(H){if(J.has(H.id))return Y(H.id);if(!Z.exists(H.path))return;J.set(H.id,{handle:Z.start(H),seq:++V})}function j(){let H=null,O=1/0;for(let[A,N]of J){if(K.has(A))continue;if(N.seq<O)O=N.seq,H=A}if(H)J.get(H).handle.stop(),J.delete(H)}function B(){let H=Z.list().filter((O)=>Z.exists(O.path)).slice(0,$);K=new Set(H.map((O)=>O.id));for(let O of H)X(O);for(let[O,A]of[...J]){let N=Z.get(O);if(!N||!Z.exists(N.path))A.handle.stop(),J.delete(O)}}function M(H){if(J.has(H))return Y(H);let O=Z.get(H);if(!O||!Z.exists(O.path))return;if(J.size>=Q)j();if(J.size>=Q)return;J.set(H,{handle:Z.start(O),seq:++V})}async function L(H){let O=J.get(H);if(!O)return;J.delete(H),await O.handle.stop()}function C(H){return J.has(H)}function q(){return[...J.keys()]}async function U(){await Promise.all([...J.values()].map((H)=>H.handle.stop())),J.clear()}return{reconcile:B,ensureWatcher:M,stopWatcher:L,isWatching:C,activeIds:q,stopAll:U}}var C8=L8({list:pZ,get:x,exists:W8,start:(Z)=>S5(Z)});async function v5(Z){await C8.stopWatcher(Z)}async function k5(Z){if(!x(Z))return{ok:!1,removed:!1,fallbackId:r(),error:"unknown workspace"};q4(Z),B4(Z),await v5(Z),P4(JZ(Z)),D4(Z);try{B8(n(Z),{recursive:!0,force:!0})}catch($){return{ok:!1,removed:!0,fallbackId:r(),error:$ instanceof Error?$.message:String($)}}return{ok:!0,removed:!0,fallbackId:r()}}var V4=process.argv.slice(3),y5=V4.includes("--yes")||V4.includes("-y"),GZ=V4.find((Z)=>!Z.startsWith("-")),T5=(Z)=>`\x1B[32m\u2713\x1B[0m ${Z}`,f5=(Z)=>`\x1B[2m${Z}\x1B[0m`,u5=(Z)=>`
|
|
5
5
|
\x1B[1m${Z}\x1B[0m`;function O8(){if(!GZ)return x(QZ(hZ(process.cwd())));if(/^[0-9a-f]{12}$/.test(GZ)){let Z=x(GZ);if(Z)return Z}return x(QZ(hZ(w5(GZ))))}var i=O8();if(!i)console.error(`[beacon] ${GZ??process.cwd()} is not a registered Beacon workspace \u2014 nothing to remove.`),process.exit(1);console.log(u5(y5?"Beacon \xB7 remove workspace":"Beacon \xB7 remove workspace (dry run)"));console.log(` name: ${i.name}${r()===i.id?" (currently active)":""}`);console.log(` repo: ${i.path} ${f5("(untouched \u2014 only Beacon's data is erased)")}`);console.log(` data: ${n(i.id)} ${f5("(deleted)")}`);if(!y5)console.log(u5("Nothing was changed.")),console.log(` Run \x1B[1mbeacon remove${GZ?` ${GZ}`:""} --yes\x1B[0m to apply.
|
|
6
6
|
`),process.exit(0);async function A8(Z){try{let{pid:$,port:Q}=JSON.parse(q8(w5(a(),"server.json"),"utf8"));if(!$||!Q)return!1;return process.kill($,0),(await fetch(`http://localhost:${Q}/api/workspace`,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({id:Z}),signal:AbortSignal.timeout(1e4)})).ok}catch{return!1}}if(await A8(i.id))console.log(` ${T5(`removed ${i.name} (via the running daemon)`)}
|
|
7
7
|
`);else{let Z=await k5(i.id);if(!Z.ok)console.error(`[beacon] remove failed: ${Z.error??"unknown error"}`),process.exit(1);console.log(` ${T5(`removed ${i.name}`)}
|
package/dist/bin/uninstall.js
CHANGED
|
@@ -29,6 +29,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
29
29
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
30
30
|
|
|
31
31
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
32
|
+
- **classificationRoots** (optional): the top-level directories whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. \`["frontend", "backend/app"]\`. The canvas groups files ONE level below each root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
32
33
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
33
34
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
34
35
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -88,7 +89,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
88
89
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
89
90
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
90
91
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
91
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
92
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
92
93
|
|
|
93
94
|
## What you should NOT do
|
|
94
95
|
|
package/dist/lib/assets.js
CHANGED
|
@@ -28,6 +28,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
30
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
31
|
+
- **classificationRoots** (optional): the top-level directories whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. \`["frontend", "backend/app"]\`. The canvas groups files ONE level below each root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
31
32
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
32
33
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
33
34
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -87,7 +88,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
87
88
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
88
89
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
89
90
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
90
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
92
|
|
|
92
93
|
## What you should NOT do
|
|
93
94
|
|
|
@@ -28,6 +28,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
30
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
31
|
+
- **classificationRoots** (optional): the top-level directories whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. \`["frontend", "backend/app"]\`. The canvas groups files ONE level below each root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
31
32
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
32
33
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
33
34
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -87,7 +88,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
87
88
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
88
89
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
89
90
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
90
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
92
|
|
|
92
93
|
## What you should NOT do
|
|
93
94
|
|
|
@@ -28,6 +28,7 @@ The user already has Beacon running. You're going to map this repository's archi
|
|
|
28
28
|
A single \`beacon_init_persist\` MCP tool call with:
|
|
29
29
|
|
|
30
30
|
- **hasFrontend**: \`true\` or \`false\` \u2014 does this repo have a frontend surface (UI code)? You just read the repo, so you know. Set it explicitly; it gates the frontend/backend \`layer\` distinction on the boards (a pure-backend repo never shows it).
|
|
31
|
+
- **classificationRoots** (optional): the top-level directories whose immediate children are the meaningful groups on the Files canvas \u2014 e.g. \`["frontend", "backend/app"]\`. The canvas groups files ONE level below each root (so \`frontend\` \u2192 \`frontend/components\`, \`frontend/app\`, \u2026). Pick the dir sitting directly ABOVE the real package dirs \u2014 use \`frontend/src\` if there's a \`src/\` wrapper. List both sides of a monorepo so neither collapses into one flat blob. Not every dir \u2014 just where grouping should START. Omit it for a simple single-root repo; the canvas falls back to automatic grouping.
|
|
31
32
|
- **components**: 8\u201325 main building blocks of this codebase. NOT every file. Group them by \`domain\` (short UPPERCASE: AUTH, API, DATA, UI, JOBS, INFRA, BILLING, SEARCH, \u2026). For each: a one-line technical \`role\`, a one-sentence plain-language \`plain\`, the few \`files\` that implement it (repo-relative), \`depends\` listing other component titles it relies on \u2014 and, when \`hasFrontend\` is true, \`layer\` (\`"frontend" | "backend" | "fullstack"\`). Use the dependency graph you can see in the source \u2014 files that import each other heavily usually belong together. If you spot a bug or something worth investigating while reading a component's code, add \`bugs: [{ note }]\` to that component \u2014 it renders as a bug flag on the node (attributed to the agent). Only flag what you actually saw in the code; don't speculate.
|
|
32
33
|
- **roadmap**: 3\u20136 BROAD strategic directions. Big-picture themes only \u2014 "Harden auth & security", "Add observability", "Scale the data layer", "Pay down test-coverage debt". NOT detailed tasks. NOT file-level. Each gets a short title and one-line \`why\`. If one of them is a concrete BUG to fix (something broken you saw in the code), add \`kind: "BUG"\` so it renders as a typed bug card. When \`hasFrontend\` is true, give each a \`layer\` too (\`"frontend" | "backend" | "fullstack"\`).
|
|
33
34
|
- **overview**: one paragraph describing what this project is and its stack. This lands in AGENTS.md as the project intro.
|
|
@@ -87,7 +88,7 @@ The one caveat: if the user manually edited an INIT-source node on the canvas (e
|
|
|
87
88
|
- **~ changed**: COMPONENT_X (role expanded to cover Y)
|
|
88
89
|
- **schema**: + 2 new tables (TableA, TableB); + 3 new endpoints; \u2212 1 deprecated endpoint
|
|
89
90
|
No need to wait for confirmation \u2014 just show the diff so the user sees what's about to land.
|
|
90
|
-
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
|
+
5. **Call \`beacon_init_persist\`** ONCE with the refreshed full analysis (same shape as init: \`components\`, \`roadmap\`, \`overview\`, \`conventions\`, \`snapshot\`, \`hasFrontend\` \u2014 re-assert it, the stack may have changed; and \`classificationRoots\` if the Files-canvas grouping needs to change, e.g. a new top-level dir like \`mobile/\` \u2014 OMIT it to keep the existing roots, don't pass \`[]\` unless you mean to clear them). It replaces all init-source nodes and regenerates \`AGENTS.md\`. Bug flags already on a component survive the refresh (they're carried over by title); add \`bugs: [{ note }]\` for anything NEW you found worth investigating \u2014 identical open flags are not duplicated.
|
|
91
92
|
|
|
92
93
|
## What you should NOT do
|
|
93
94
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `ProjectMeta` ADD `classificationRoots` text DEFAULT '[]' NOT NULL;
|