@zipbul/gildash 0.17.1 → 0.17.2

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  var q1=Object.defineProperty;var S1=(_)=>_;function T1(_,$){this[_]=S1.bind(null,$)}var R1=(_,$)=>{for(var J in $)q1(_,J,{get:$[J],enumerable:!0,configurable:!0,set:T1.bind($,J)})};var P$=import.meta.require;import{isErr as m_}from"@zipbul/result";import F_ from"path";import{existsSync as aJ}from"fs";import{err as f$,isErr as v1}from"@zipbul/result";import{Database as b1}from"bun:sqlite";import{mkdirSync as y1,unlinkSync as n$,existsSync as m$}from"fs";import{dirname as P1,join as x$}from"path";import{drizzle as f1}from"drizzle-orm/bun-sqlite";import{migrate as n1}from"drizzle-orm/bun-sqlite/migrator";class V extends Error{type;constructor(_,$,J){super($,J);this.type=_;this.name="GildashError"}}var L_=".gildash",h_="gildash.db";var Y$={};R1(Y$,{watcherOwner:()=>E1,symbols:()=>x,symbolChangelog:()=>Q_,relations:()=>G,files:()=>__,annotations:()=>Z_});import{sql as k1}from"drizzle-orm";import{sqliteTable as A_,text as b,integer as e,real as F1,index as z_,primaryKey as G1,foreignKey as W$,check as j1}from"drizzle-orm/sqlite-core";var __=A_("files",{project:b("project").notNull(),filePath:b("file_path").notNull(),mtimeMs:F1("mtime_ms").notNull(),size:e("size").notNull(),contentHash:b("content_hash").notNull(),updatedAt:b("updated_at").notNull(),lineCount:e("line_count")},(_)=>[G1({columns:[_.project,_.filePath]})]),x=A_("symbols",{id:e("id").primaryKey({autoIncrement:!0}),project:b("project").notNull(),filePath:b("file_path").notNull(),kind:b("kind").notNull(),name:b("name").notNull(),startLine:e("start_line").notNull(),startColumn:e("start_column").notNull(),endLine:e("end_line").notNull(),endColumn:e("end_column").notNull(),isExported:e("is_exported").notNull().default(0),signature:b("signature"),fingerprint:b("fingerprint"),detailJson:b("detail_json"),contentHash:b("content_hash").notNull(),indexedAt:b("indexed_at").notNull(),resolvedType:b("resolved_type"),structuralFingerprint:b("structural_fingerprint")},(_)=>[z_("idx_symbols_project_file").on(_.project,_.filePath),z_("idx_symbols_project_kind").on(_.project,_.kind),z_("idx_symbols_project_name").on(_.project,_.name),z_("idx_symbols_fingerprint").on(_.project,_.fingerprint),W$({columns:[_.project,_.filePath],foreignColumns:[__.project,__.filePath]}).onDelete("cascade")]),G=A_("relations",{id:e("id").primaryKey({autoIncrement:!0}),project:b("project").notNull(),type:b("type").notNull(),srcFilePath:b("src_file_path").notNull(),srcSymbolName:b("src_symbol_name"),dstProject:b("dst_project"),dstFilePath:b("dst_file_path"),dstSymbolName:b("dst_symbol_name"),metaJson:b("meta_json"),specifier:b("specifier"),isExternal:e("is_external").notNull().default(0)},(_)=>[z_("idx_relations_src").on(_.project,_.srcFilePath),z_("idx_relations_dst").on(_.dstProject,_.dstFilePath),z_("idx_relations_type").on(_.project,_.type),z_("idx_relations_project_type_src").on(_.project,_.type,_.srcFilePath),z_("idx_relations_specifier").on(_.project,_.specifier),W$({columns:[_.project,_.srcFilePath],foreignColumns:[__.project,__.filePath]}).onDelete("cascade")]),Z_=A_("annotations",{id:e("id").primaryKey({autoIncrement:!0}),project:b("project").notNull(),filePath:b("file_path").notNull(),tag:b("tag").notNull(),value:b("value").notNull().default(""),source:b("source").notNull(),symbolName:b("symbol_name"),startLine:e("start_line").notNull(),startColumn:e("start_column").notNull(),endLine:e("end_line").notNull(),endColumn:e("end_column").notNull(),indexedAt:b("indexed_at").notNull()},(_)=>[z_("idx_annotations_project_file").on(_.project,_.filePath),z_("idx_annotations_project_tag").on(_.project,_.tag),z_("idx_annotations_project_symbol").on(_.project,_.symbolName),W$({columns:[_.project,_.filePath],foreignColumns:[__.project,__.filePath]}).onDelete("cascade")]),Q_=A_("symbol_changelog",{id:e("id").primaryKey({autoIncrement:!0}),project:b("project").notNull(),changeType:b("change_type").notNull(),symbolName:b("symbol_name").notNull(),symbolKind:b("symbol_kind").notNull(),filePath:b("file_path").notNull(),oldName:b("old_name"),oldFilePath:b("old_file_path"),fingerprint:b("fingerprint"),changedAt:b("changed_at").notNull(),isFullIndex:e("is_full_index").notNull().default(0),indexRunId:b("index_run_id").notNull()},(_)=>[z_("idx_changelog_project_changed_at").on(_.project,_.changedAt),z_("idx_changelog_project_name").on(_.project,_.symbolName),z_("idx_changelog_project_run").on(_.project,_.indexRunId)]),E1=A_("watcher_owner",{id:e("id").primaryKey(),pid:e("pid").notNull(),startedAt:b("started_at").notNull(),heartbeatAt:b("heartbeat_at").notNull(),instanceId:b("instance_id")},(_)=>[j1("watcher_owner_singleton",k1`${_.id} = 1`)]);class Z${client=null;drizzle=null;dbPath;txDepth=0;constructor(_){this.dbPath=x$(_.projectRoot,L_,h_)}get drizzleDb(){if(!this.drizzle)throw Error("Database is not open. Call open() first.");return this.drizzle}open(){try{y1(P1(this.dbPath),{recursive:!0}),this.client=new b1(this.dbPath),this.client.run("PRAGMA journal_mode = WAL"),this.client.run("PRAGMA foreign_keys = OFF"),this.client.run("PRAGMA busy_timeout = 5000"),this.drizzle=f1(this.client,{schema:Y$}),n1(this.drizzle,{migrationsFolder:x$(import.meta.dirname,"migrations")});let _=this.client.prepare("PRAGMA foreign_key_check").all();if(_.length>0)throw Error(`FK integrity violation after migration: ${JSON.stringify(_.slice(0,5))}`);this.client.run("PRAGMA foreign_keys = ON"),this.registerRegexpUdf(this.client)}catch(_){if(this.isCorruptionError(_)&&m$(this.dbPath)){this.closeClient(),n$(this.dbPath);for(let J of["-wal","-shm"]){let Q=this.dbPath+J;if(m$(Q))n$(Q)}let $=this.open();if(v1($))return f$(new V("store",`Failed to recover database at ${this.dbPath}`,{cause:$.data}));return $}return f$(new V("store",`Failed to open database at ${this.dbPath}`,{cause:_}))}}close(){this.closeClient(),this.drizzle=null}transaction(_){let $=this.requireClient();if(this.txDepth===0){this.txDepth++;try{return $.transaction(()=>_(this))()}finally{this.txDepth--}}let J=`sp_${this.txDepth++}`;$.run(`SAVEPOINT "${J}"`);try{let Q=_(this);return $.run(`RELEASE SAVEPOINT "${J}"`),Q}catch(Q){throw $.run(`ROLLBACK TO SAVEPOINT "${J}"`),$.run(`RELEASE SAVEPOINT "${J}"`),Q}finally{this.txDepth--}}immediateTransaction(_){let $=this.requireClient();this.txDepth++,$.run("BEGIN IMMEDIATE");try{let J=_();return $.run("COMMIT"),J}catch(J){throw $.run("ROLLBACK"),J}finally{this.txDepth--}}getTableNames(){return this.requireClient().query("SELECT name FROM sqlite_master WHERE type = 'table'").all().map(($)=>$.name)}selectOwner(){return this.requireClient().prepare("SELECT pid, heartbeat_at, instance_id FROM watcher_owner WHERE id = 1").get()??void 0}insertOwner(_,$){let J=new Date().toISOString();this.requireClient().prepare("INSERT INTO watcher_owner (id, pid, started_at, heartbeat_at, instance_id) VALUES (1, ?, ?, ?, ?)").run(_,J,J,$??null)}replaceOwner(_,$){let J=new Date().toISOString();this.requireClient().prepare("INSERT OR REPLACE INTO watcher_owner (id, pid, started_at, heartbeat_at, instance_id) VALUES (1, ?, ?, ?, ?)").run(_,J,J,$??null)}touchOwner(_){let $=new Date().toISOString();this.requireClient().prepare("UPDATE watcher_owner SET heartbeat_at = ? WHERE id = 1 AND pid = ?").run($,_)}deleteOwner(_){this.requireClient().prepare("DELETE FROM watcher_owner WHERE id = 1 AND pid = ?").run(_)}registerRegexpUdf(_){let $=_;if(typeof $.function!=="function")return;$.function.call(_,"regexp",(J,Q)=>{try{return new RegExp(J).test(Q)?1:0}catch{return 0}})}requireClient(){if(!this.client)throw Error("Database is not open. Call open() first.");return this.client}closeClient(){if(this.client)this.client.close(),this.client=null}isCorruptionError(_){if(!(_ instanceof Error))return!1;let $=_.message.toLowerCase();return $.includes("malformed")||$.includes("corrupt")||$.includes("not a database")||$.includes("disk i/o error")||$.includes("sqlite_corrupt")}}import{eq as G_,and as h$}from"drizzle-orm";class X${db;constructor(_){this.db=_}getFile(_,$){return this.db.drizzleDb.select().from(__).where(h$(G_(__.project,_),G_(__.filePath,$))).get()??null}upsertFile(_){this.db.drizzleDb.insert(__).values({project:_.project,filePath:_.filePath,mtimeMs:_.mtimeMs,size:_.size,contentHash:_.contentHash,updatedAt:_.updatedAt,lineCount:_.lineCount??null}).onConflictDoUpdate({target:[__.project,__.filePath],set:{mtimeMs:_.mtimeMs,size:_.size,contentHash:_.contentHash,updatedAt:_.updatedAt,lineCount:_.lineCount??null}}).run()}getAllFiles(_){return this.db.drizzleDb.select().from(__).where(G_(__.project,_)).all()}getFilesMap(_){let $=this.getAllFiles(_),J=new Map;for(let Q of $)J.set(Q.filePath,Q);return J}deleteFile(_,$){this.db.drizzleDb.delete(__).where(h$(G_(__.project,_),G_(__.filePath,$))).run()}}import{eq as $_,and as B_,sql as p_,count as m1}from"drizzle-orm";function g_(_){return _.replaceAll("\x00","").trim().split(/\s+/).map(($)=>$.trim()).filter(($)=>$.length>0).map(($)=>`"${$.replaceAll('"','""')}"*`).join(" ")}var p$=50;class O${db;constructor(_){this.db=_}replaceFileSymbols(_,$,J,Q){if(this.db.drizzleDb.delete(x).where(B_($_(x.project,_),$_(x.filePath,$))).run(),!Q.length)return;let z=new Date().toISOString(),Y=Q.map((Z)=>({project:_,filePath:$,kind:Z.kind??"unknown",name:Z.name??"",startLine:Z.startLine??0,startColumn:Z.startColumn??0,endLine:Z.endLine??0,endColumn:Z.endColumn??0,isExported:Z.isExported??0,signature:Z.signature??null,fingerprint:Z.fingerprint??null,detailJson:Z.detailJson??null,contentHash:J,indexedAt:Z.indexedAt??z,resolvedType:Z.resolvedType??null,structuralFingerprint:Z.structuralFingerprint??null}));for(let Z=0;Z<Y.length;Z+=p$)this.db.drizzleDb.insert(x).values(Y.slice(Z,Z+p$)).run()}getFileSymbols(_,$){return this.db.drizzleDb.select().from(x).where(B_($_(x.project,_),$_(x.filePath,$))).all()}searchByName(_,$,J={}){let Q=J.limit??50,z=g_($);if(!z)return[];return this.db.drizzleDb.select().from(x).where(B_(p_`${x.id} IN (SELECT rowid FROM symbols_fts WHERE symbols_fts MATCH ${z})`,$_(x.project,_),J.kind?$_(x.kind,J.kind):void 0)).orderBy(x.name).limit(Q).all()}searchByKind(_,$){return this.db.drizzleDb.select().from(x).where(B_($_(x.project,_),$_(x.kind,$))).orderBy(x.name).all()}getStats(_){let $=this.db.drizzleDb.select({symbolCount:m1(),fileCount:p_`COUNT(DISTINCT ${x.filePath})`}).from(x).where($_(x.project,_)).get();return{symbolCount:$?.symbolCount??0,fileCount:$?.fileCount??0}}getByFingerprint(_,$){return this.db.drizzleDb.select().from(x).where(B_($_(x.project,_),$_(x.fingerprint,$))).all()}deleteFileSymbols(_,$){this.db.drizzleDb.delete(x).where(B_($_(x.project,_),$_(x.filePath,$))).run()}searchByQuery(_){let $=this.db.drizzleDb.select().from(x).where(B_(_.ftsQuery?p_`${x.id} IN (SELECT rowid FROM symbols_fts WHERE symbols_fts MATCH ${_.ftsQuery})`:void 0,_.exactName?$_(x.name,_.exactName):void 0,_.project!==void 0?$_(x.project,_.project):void 0,_.kind?$_(x.kind,_.kind):void 0,_.filePath!==void 0?$_(x.filePath,_.filePath):void 0,_.isExported!==void 0?$_(x.isExported,_.isExported?1:0):void 0,_.decorator?p_`${x.id} IN (SELECT s.id FROM symbols s, json_each(s.detail_json, '$.decorators') je WHERE json_extract(je.value, '$.name') = ${_.decorator})`:void 0,_.resolvedType!==void 0?$_(x.resolvedType,_.resolvedType):void 0)).orderBy(x.name);if(!_.regex)return(_.limit!==void 0?$.limit(_.limit):$).all();let J;try{J=new RegExp(_.regex)}catch{throw new V("validation",`Invalid regex pattern: ${_.regex}`)}if(_.limit===void 0)return $.all().filter((Y)=>J.test(Y.name));let Q=[];for(let z of[5,20,100]){let Y=_.limit*z,Z=$.limit(Y).all();if(Q=Z.filter((W)=>J.test(W.name)),Q.length>=_.limit||Z.length<Y)return Q.slice(0,_.limit)}return Q.slice(0,_.limit)}}import{eq as a,and as V_,isNull as i$,or as x1}from"drizzle-orm";var j_={project:G.project,type:G.type,srcFilePath:G.srcFilePath,srcSymbolName:G.srcSymbolName,dstProject:G.dstProject,dstFilePath:G.dstFilePath,dstSymbolName:G.dstSymbolName,metaJson:G.metaJson,specifier:G.specifier,isExternal:G.isExternal};class V${db;constructor(_){this.db=_}replaceFileRelations(_,$,J){this.db.transaction((Q)=>{if(Q.drizzleDb.delete(G).where(V_(a(G.project,_),a(G.srcFilePath,$))).run(),!J.length)return;for(let z of J)Q.drizzleDb.insert(G).values({project:_,type:z.type??"unknown",srcFilePath:z.srcFilePath??$,srcSymbolName:z.srcSymbolName??null,dstProject:z.dstProject??(z.dstFilePath!=null?_:null),dstFilePath:z.dstFilePath??null,dstSymbolName:z.dstSymbolName??null,metaJson:z.metaJson??null,specifier:z.specifier??null,isExternal:z.isExternal??0}).run()})}getOutgoing(_,$,J){if(J!==void 0)return this.db.drizzleDb.select(j_).from(G).where(V_(a(G.project,_),a(G.srcFilePath,$),x1(a(G.srcSymbolName,J),i$(G.srcSymbolName)))).all();return this.db.drizzleDb.select(j_).from(G).where(V_(a(G.project,_),a(G.srcFilePath,$))).all()}getIncoming(_){let{dstProject:$,dstFilePath:J}=_;return this.db.drizzleDb.select(j_).from(G).where(V_(a(G.dstProject,$),a(G.dstFilePath,J))).all()}getByType(_,$){return this.db.drizzleDb.select(j_).from(G).where(V_(a(G.project,_),a(G.type,$))).all()}deleteFileRelations(_,$){this.db.drizzleDb.delete(G).where(V_(a(G.project,_),a(G.srcFilePath,$))).run()}deleteIncomingRelations(_,$){this.db.drizzleDb.delete(G).where(V_(a(G.dstProject,_),a(G.dstFilePath,$))).run()}searchRelations(_){let $=this.db.drizzleDb.select(j_).from(G).where(V_(_.project!==void 0?a(G.project,_.project):void 0,_.srcFilePath!==void 0?a(G.srcFilePath,_.srcFilePath):void 0,_.srcSymbolName!==void 0?a(G.srcSymbolName,_.srcSymbolName):void 0,_.dstProject!==void 0?a(G.dstProject,_.dstProject):void 0,_.dstFilePath!==void 0?a(G.dstFilePath,_.dstFilePath):void 0,_.dstSymbolName!==void 0?a(G.dstSymbolName,_.dstSymbolName):void 0,_.type!==void 0?a(G.type,_.type):void 0,_.specifier!==void 0?a(G.specifier,_.specifier):void 0,_.isExternal!==void 0?a(G.isExternal,_.isExternal?1:0):void 0));return(_.limit!==void 0?$.limit(_.limit):$).all()}retargetRelations(_){let{dstProject:$,oldFile:J,oldSymbol:Q,newFile:z,newSymbol:Y,newDstProject:Z}=_,W=Q===null?V_(a(G.dstProject,$),a(G.dstFilePath,J),i$(G.dstSymbolName)):V_(a(G.dstProject,$),a(G.dstFilePath,J),a(G.dstSymbolName,Q)),X={dstFilePath:z,dstSymbolName:Y};if(Z!==void 0)X.dstProject=Z;this.db.drizzleDb.update(G).set(X).where(W).run()}}import{err as l$}from"@zipbul/result";import{subscribe as h1}from"@parcel/watcher";import U$ from"path";import d$ from"path";function Y_(_){return _.replaceAll("\\","/")}function E_(_,$){return Y_(d$.relative(_,$))}function q_(_,$){return Y_(d$.resolve(_,$))}var p1=["**/.git/**",`**/${L_}/**`,"**/dist/**","**/node_modules/**"],i1=new Set(["package.json","tsconfig.json"]);function d1(_){if(_==="update")return"change";if(_==="create")return"create";return"delete"}class H${#_;#$;#J;#z;#Q;#Y;constructor(_,$=h1,J=console){this.#$=_.projectRoot,this.#J=[...p1,..._.ignorePatterns??[]],this.#z=new Set((_.extensions??[".ts",".mts",".cts"]).map((Q)=>Q.toLowerCase())),this.#Q=$,this.#Y=J}async start(_){try{this.#_=await this.#Q(this.#$,($,J)=>{if($){this.#Y.error(new V("watcher","Callback error",{cause:$}));return}try{for(let Q of J){let z=Y_(U$.relative(this.#$,Q.path));if(z.startsWith(".."))continue;let Y=U$.basename(z),Z=U$.extname(z).toLowerCase();if(!i1.has(Y)&&!this.#z.has(Z))continue;if(z.endsWith(".d.ts"))continue;_({eventType:d1(Q.type),filePath:z})}}catch(Q){this.#Y.error(new V("watcher","Callback error",{cause:Q}))}},{ignore:this.#J})}catch($){return l$(new V("watcher","Failed to subscribe watcher",{cause:$}))}}async close(){if(!this.#_)return;try{await this.#_.unsubscribe(),this.#_=void 0}catch(_){return l$(new V("watcher","Failed to close watcher",{cause:_}))}}}import M$ from"path";import{promises as l1}from"fs";var c1=["**/node_modules/**","**/.git/**",`**/${L_}/**`,"**/dist/**"];async function i_(_){let $=[];for await(let J of l1.glob("**/package.json",{cwd:_,exclude:c1})){let Q=Y_(M$.dirname(J)),z=M$.join(_,J),Y=await Bun.file(z).json(),Z=typeof Y?.name==="string"&&Y.name.length>0?Y.name:M$.basename(Q==="."?_:Q);$.push({dir:Q,project:Z})}return $.sort((J,Q)=>Q.dir.length-J.dir.length),$}function t(_,$,J="default"){let Q=Y_(_);for(let z of $){if(z.dir===".")return z.project;if(Q===z.dir||Q.startsWith(`${z.dir}/`))return z.project}return J}import v_ from"path";var w_=new Map;async function a1(_){let $=Bun.file(_);if(!await $.exists())return null;try{let J=await $.text(),Q=Bun.JSONC.parse(J);return typeof Q==="object"&&Q!==null?Q:null}catch{return null}}function s1(_,$){if($.startsWith(".")){let J=v_.resolve(_,$);return J.endsWith(".json")?J:J+".json"}return v_.resolve(_,"node_modules",$)}async function c$(_,$=5){if($<=0)return null;let J=await a1(_);if(!J)return null;let Q=J.extends;if(typeof Q!=="string"||!Q)return J;let z=s1(v_.dirname(_),Q),Y=await c$(z,$-1);if(!Y)return J;let Z=typeof Y.compilerOptions==="object"&&Y.compilerOptions!==null?Y.compilerOptions:{},W=typeof J.compilerOptions==="object"&&J.compilerOptions!==null?J.compilerOptions:{};return{...Y,...J,compilerOptions:{...Z,...W}}}async function b_(_){if(w_.has(_))return w_.get(_)??null;let $=v_.join(_,"tsconfig.json"),J=await c$($);if(!J)return w_.set(_,null),null;let Q=typeof J.compilerOptions==="object"&&J.compilerOptions!==null?J.compilerOptions:null;if(!Q)return w_.set(_,null),null;let z=typeof Q.baseUrl==="string"?Q.baseUrl:null,Y=typeof Q.paths==="object"&&Q.paths!==null?Q.paths:null;if(!z&&!Y)return w_.set(_,null),null;let Z=z?v_.resolve(_,z):_,W=new Map;if(Y)for(let[U,O]of Object.entries(Y)){if(!Array.isArray(O))continue;let H=O.filter((L)=>typeof L==="string");W.set(U,H)}let X={baseUrl:Z,paths:W};return w_.set(_,X),X}function d_(_){if(_){w_.delete(_);return}w_.clear()}function O_(_){let $=Bun.hash.xxHash64(_);return BigInt.asUintN(64,BigInt($)).toString(16).padStart(16,"0")}import{isErr as Q0}from"@zipbul/result";import{err as r1}from"@zipbul/result";import{parseSync as o1}from"oxc-parser";function y_(_,$,J,Q=o1){try{let z={preserveParens:!1,...J},Y=Q(_,$,z);return{filePath:_,program:Y.program,errors:Y.errors,comments:Y.comments,sourceText:$,module:Y.module}}catch(z){return r1(new V("parse",`Failed to parse file: ${_}`,{cause:z}))}}import{promises as t1}from"fs";import{join as e1}from"path";async function a$(_){let{projectRoot:$,extensions:J,ignorePatterns:Q,fileRepo:z}=_,Y=z.getFilesMap(),Z=new Set,W=[],X=[],U=Q.map((H)=>new Bun.Glob(H));for await(let H of t1.glob("**/*",{cwd:$})){let L=Y_(H);if(!J.some((f)=>L.endsWith(f)))continue;if(L.startsWith("node_modules/")||L.includes("/node_modules/"))continue;if(U.some((f)=>f.match(L)))continue;Z.add(L);let D=e1($,L),K=Bun.file(D),{size:B,lastModified:T}=K,k=Y.get(L);if(!k){let f=await K.text(),o=O_(f);W.push({filePath:L,contentHash:o,mtimeMs:T,size:B});continue}if(k.mtimeMs===T&&k.size===B){X.push({filePath:L,contentHash:k.contentHash,mtimeMs:T,size:B});continue}let P=await K.text(),j=O_(P);if(j===k.contentHash)X.push({filePath:L,contentHash:j,mtimeMs:T,size:B});else W.push({filePath:L,contentHash:j,mtimeMs:T,size:B})}let O=[];for(let H of Y.keys())if(!Z.has(H))O.push(H);return{changed:W,unchanged:X,deleted:O}}function P_(_){let $=[0];for(let J=0;J<_.length;J++)if(_[J]===`
3
- `)$.push(J+1);return $}function X_(_,$){let J=0,Q=_.length-1;while(J<Q){let z=J+Q+1>>1;if(_[z]<=$)J=z;else Q=z-1}return{line:J+1,column:$-_[J]}}import{err as _J}from"@zipbul/result";import{parse as $J}from"comment-parser";function l_(_){try{let $=_.trim();if($.startsWith("/**"))$=$.slice(3);if($.endsWith("*/"))$=$.slice(0,-2);let Q=$J(`/** ${$} */`)[0]??{description:"",tags:[]};return{description:(Q.description??"").trim(),tags:(Q.tags??[]).map((z)=>({tag:z.tag??"",name:z.name??"",type:z.type??"",description:z.description??"",optional:z.optional??!1,...z.default!==void 0?{default:z.default}:{}}))}}catch($){return _J(new V("parse","Failed to parse JSDoc comment",{cause:$}))}}import{isErr as JJ}from"@zipbul/result";function c_(_){if("name"in _&&typeof _.name==="string")return _.name;if("value"in _&&typeof _.value==="string")return _.value;return"unknown"}function S_(_){if(_.type==="Identifier")return[{name:_.name,start:_.start,end:_.end}];if(_.type==="ObjectPattern"){let $=[];for(let J of _.properties)if(J.type==="RestElement")$.push(...S_(J.argument));else $.push(...S_(J.value));return $}if(_.type==="ArrayPattern"){let $=[];for(let J of _.elements){if(!J)continue;if(J.type==="RestElement")$.push(...S_(J.argument));else $.push(...S_(J))}return $}if(_.type==="AssignmentPattern")return S_(_.left);return[]}function T_(_){let{program:$,sourceText:J,comments:Q}=_,z=P_(J),Y=Q.filter((w)=>w.type==="Block"&&w.value.startsWith("*")).sort((w,A)=>w.end-A.end),Z=$.body.map((w)=>w.start).sort((w,A)=>w-A);function W(w,A){return{start:X_(z,w),end:X_(z,A)}}function X(w){let A=0,I=Y.length-1,u=-1;while(A<=I){let q=A+I>>>1;if(Y[q].end<=w)u=q,A=q+1;else I=q-1}if(u<0)return;let N=Y[u];A=0,I=Z.length-1;while(A<=I){let q=A+I>>>1,F=Z[q];if(F<=N.end)A=q+1;else if(F>=w)I=q-1;else return}return`/*${N.value}*/`}function U(w){if(!w)return;let A="typeAnnotation"in w&&w.typeAnnotation?w.typeAnnotation:w;return J.slice(A.start,A.end)}function O(w){if(!w||w.length===0)return[];return w.map((A)=>{let I=A.expression;if(I.type==="CallExpression"){let u=I,N=u.callee,q="name"in N&&typeof N.name==="string"?N.name:("property"in N)&&N.property&&typeof N.property.name==="string"?N.property.name:"unknown",F=u.arguments.map((E)=>J.slice(E.start,E.end));return{name:q,arguments:F.length>0?F:void 0}}if(I.type==="Identifier")return{name:I.name??"unknown"};return{name:J.slice(I.start,I.end)}})}function H(w){if(w.type==="TSParameterProperty"){let I=w;return L(I.parameter,I.parameter.decorators)}if(w.type==="RestElement"){let I=w,u=I.argument,q=`...${"name"in u&&typeof u.name==="string"?u.name:"unknown"}`,F=I.typeAnnotation,E=F?U(F):void 0,i={name:q,isOptional:!1};if(E)i.type=E;return i}let A=w;return L(A,A.decorators)}function L(w,A){if(w.type==="AssignmentPattern"){let{left:i,right:l}=w,s="name"in i&&typeof i.name==="string"?i.name:"unknown",M="typeAnnotation"in i?i.typeAnnotation:null,C=M?U(M):void 0,S=J.slice(l.start,l.end),R="decorators"in i&&Array.isArray(i.decorators)?i.decorators:[],m=O(R),g={name:s,isOptional:!0,defaultValue:S};if(C)g.type=C;if(m.length>0)g.decorators=m;return g}let I="name"in w&&typeof w.name==="string"?w.name:("pattern"in w)&&w.pattern&&typeof w.pattern.name==="string"?w.pattern.name:"unknown",u=!!(("optional"in w)&&w.optional),N="typeAnnotation"in w?w.typeAnnotation:null,q=N?U(N):void 0,F=O(A??[]),E={name:I,isOptional:u};if(q)E.type=q;if(F.length>0)E.decorators=F;return E}function D(w,A){let I=[];if(A?.async)I.push("async");if(w.static)I.push("static");if(w.abstract)I.push("abstract");if(w.readonly)I.push("readonly");if(w.override)I.push("override");if(w.declare)I.push("declare");if(w.const)I.push("const");let u=w.accessibility;if(u==="private")I.push("private");else if(u==="protected")I.push("protected");else if(u==="public")I.push("public");return I}function K(w){if(!w)return;let A=w.params.flatMap((I)=>{let u=I.name.name;return u?[u]:[]});return A.length>0?A:void 0}function B(w){let A=[];if(w.superClass){let u=J.slice(w.superClass.start,w.superClass.end);A.push({kind:"extends",name:u})}let I=w.implements??[];for(let u of I){let N=u.expression,q=J.slice(N.start,N.end);A.push({kind:"implements",name:q})}return A}function T(w){let A=[],I=w.extends;for(let u of I){let N=u.expression,q=J.slice(N.start,N.end);A.push({kind:"extends",name:q})}return A}function k(w){let A=[];for(let I of w)if(I.type==="MethodDefinition"||I.type==="TSAbstractMethodDefinition"){let u=I,N=c_(u.key),q=u.value,F=u.kind,E=F==="constructor"?"constructor":F==="get"?"getter":F==="set"?"setter":"method",i=D(u,q);if(I.type==="TSAbstractMethodDefinition"&&!i.includes("abstract"))i.push("abstract");let l=q.params.map(H),s=U(q.returnType),M={kind:"method",name:N,span:W(I.start,I.end),isExported:!1,methodKind:E,modifiers:i,parameters:l.length>0?l:void 0,returnType:s};A.push(M)}else if(I.type==="PropertyDefinition"||I.type==="TSAbstractPropertyDefinition"){let u=I,N=c_(u.key),q=D(u);if(I.type==="TSAbstractPropertyDefinition"&&!q.includes("abstract"))q.push("abstract");let F={kind:"property",name:N,span:W(I.start,I.end),isExported:!1,modifiers:q};A.push(F)}return A}function P(w){let A=[];for(let I of w)if(I.type==="TSMethodSignature"){let u=I,N=c_(u.key),q=u.params.map(H),F=U(u.returnType);A.push({kind:"method",name:N,span:W(I.start,I.end),isExported:!1,modifiers:[],methodKind:"method",parameters:q.length>0?q:void 0,returnType:F})}else if(I.type==="TSPropertySignature"){let u=I,N=c_(u.key),q=U(u.typeAnnotation),F={kind:"property",name:N,span:W(I.start,I.end),isExported:!1,modifiers:u.readonly?["readonly"]:[],returnType:q};A.push(F)}return A}function j(w,A){let I=w.type;if(I==="FunctionDeclaration"||I==="FunctionExpression"||I==="TSDeclareFunction"||I==="TSEmptyBodyFunctionExpression"){let u=w,N=u.id?.name??"default",q=u.params.map(H),F=U(u.returnType),E=D(u,u),i=O(u.decorators??[]),l=K(u.typeParameters),s={kind:"function",name:N,span:W(w.start,w.end),isExported:A,modifiers:E,parameters:q.length>0?q:void 0,returnType:F,decorators:i.length>0?i:void 0};if(l&&l.length>0)s.typeParameters=l;return s}if(I==="ClassDeclaration"||I==="ClassExpression"){let u=w,N=u.id?.name??"default",q=B(u),F=k(u.body.body),E=O(u.decorators),i=D(u),l=K(u.typeParameters),s={kind:"class",name:N,span:W(w.start,w.end),isExported:A,modifiers:i,heritage:q.length>0?q:void 0,members:F.length>0?F:void 0,decorators:E.length>0?E:void 0};if(l&&l.length>0)s.typeParameters=l;return s}if(I==="VariableDeclaration"){let u=w,N=[];for(let q of u.declarations){let{id:F,init:E}=q;if(F.type==="ObjectPattern"||F.type==="ArrayPattern"){let S=S_(F);for(let R of S)N.push({kind:"variable",name:R.name,span:W(R.start,R.end),isExported:A,modifiers:[]});continue}let i="name"in F&&typeof F.name==="string"?F.name:"unknown",l="variable",s,M;if(E){if(E.type==="FunctionExpression"||E.type==="ArrowFunctionExpression"){l="function";let S=E;s=S.params.map(H),M=U(S.returnType)}}let C=[];N.push({kind:l,name:i,span:W(q.start,q.end),isExported:A,modifiers:C,parameters:s,returnType:M})}if(N.length===0)return null;if(N.length===1)return N[0];return N}if(I==="TSTypeAliasDeclaration")return{kind:"type",name:w.id.name,span:W(w.start,w.end),isExported:A,modifiers:[]};if(I==="TSInterfaceDeclaration"){let u=w,N=u.id.name,q=T(u),F=P(u.body.body),E=K(u.typeParameters),i={kind:"interface",name:N,span:W(w.start,w.end),isExported:A,modifiers:[],heritage:q.length>0?q:void 0,members:F.length>0?F:void 0};if(E&&E.length>0)i.typeParameters=E;return i}if(I==="TSEnumDeclaration"){let u=w,N=u.id.name,q=D(u),E=u.body.members.map((i)=>{let l=i.id;return{kind:"property",name:"name"in l&&typeof l.name==="string"?l.name:("value"in l)&&typeof l.value==="string"?l.value:"unknown",span:W(i.start,i.end),isExported:!1,modifiers:[]}});return{kind:"enum",name:N,span:W(w.start,w.end),isExported:A,modifiers:q,members:E.length>0?E:void 0}}if(I==="TSModuleDeclaration"){let u=w,N=u.id.name??u.id.value??"unknown",q=D(u);return{kind:"namespace",name:N,span:W(w.start,w.end),isExported:A,modifiers:q}}return null}let f=[],o=new Set;for(let w of $.body){let A=null,I=w;if(I.type==="ExportNamedDeclaration"){let N=I;if(N.declaration){if(A=j(N.declaration,!0),A&&!Array.isArray(A))A.span=W(N.start,N.end)}else if(!N.source&&N.specifiers)for(let q of N.specifiers){let F=q.local,E="name"in F?F.name:F.value;if(E)o.add(E)}}else if(I.type==="ExportDefaultDeclaration"){let N=I,q=N.declaration;if(q){if(A=j(q,!0),A&&!Array.isArray(A))A.name="id"in q&&q.id&&typeof q.id.name==="string"?q.id.name:"default",A.isExported=!0,A.span=W(N.start,N.end);else if(!A&&"type"in q&&q.type==="Identifier"){let F=q.name;if(F)o.add(F)}}}else{let N=I.type;if(N==="FunctionDeclaration"||N==="TSDeclareFunction"||N==="ClassDeclaration"||N==="VariableDeclaration"||N==="TSTypeAliasDeclaration"||N==="TSInterfaceDeclaration"||N==="TSEnumDeclaration"||N==="TSModuleDeclaration")A=j(I,!1)}let u=Array.isArray(A)?A:A?[A]:[];for(let N of u){let q=w.start,F=X(q);if(F){let E=l_(F);if(!JJ(E))N.jsDoc=E}f.push(N)}}if(o.size>0){for(let w of f)if(!w.isExported&&o.has(w.name))w.isExported=!0}return f}function QJ(_){if(_.kind==="function"||_.kind==="method"){let $=_.parameters?.length??0,J=_.modifiers.includes("async")?1:0;return`params:${$}|async:${J}`}return null}function zJ(_){let $={};if(_.jsDoc)$.jsDoc=_.jsDoc;if(_.kind==="function"||_.kind==="method"){if(_.parameters!==void 0)$.parameters=_.parameters;if(_.returnType!==void 0)$.returnType=_.returnType}if(_.heritage?.length)$.heritage=_.heritage;if(_.decorators?.length)$.decorators=_.decorators;if(_.typeParameters?.length)$.typeParameters=_.typeParameters;if(_.modifiers?.length)$.modifiers=_.modifiers;if(_.members?.length)$.members=_.members.map((J)=>{let Q=J.modifiers.find((z)=>z==="private"||z==="protected"||z==="public");return{name:J.name,kind:J.methodKind??J.kind,type:J.returnType,visibility:Q,isStatic:J.modifiers.includes("static")||void 0,isReadonly:J.modifiers.includes("readonly")||void 0}});return Object.keys($).length>0?JSON.stringify($):null}function WJ(_){let $=[_.kind];if(_.modifiers.length)$.push(`mod:${[..._.modifiers].sort().join(",")}`);if(_.typeParameters?.length)$.push(`tp:${_.typeParameters.length}`);if(_.heritage?.length){let J=[..._.heritage].sort((Q,z)=>Q.name.localeCompare(z.name)).map((Q)=>`${Q.kind}:${Q.name}`).join(",");$.push(`her:${J}`)}if(_.decorators?.length)$.push(`dec:${[..._.decorators].map((J)=>J.name).sort().join(",")}`);if(_.methodKind)$.push(`mk:${_.methodKind}`);if(_.parameters)$.push(`p:${_.parameters.length}`);if(_.returnType)$.push(`rt:${_.returnType}`);if(_.members?.length){let J=_.members.map((Q)=>`${Q.kind}:${Q.modifiers.join(",")}:${Q.parameters?.length??""}:${Q.returnType??""}`).sort().join(";");$.push(`mem:${_.members.length}:${O_(J)}`)}return O_($.join("|"))}function s$(_,$,J,Q,z){let Y=QJ(_),Z=O_(`${$}|${_.kind}|${Y??""}`),W=WJ(_);return{project:J,filePath:Q,kind:_.kind,name:$,startLine:_.span.start.line,startColumn:_.span.start.column,endLine:_.span.end.line,endColumn:_.span.end.column,isExported:_.isExported?1:0,signature:Y,fingerprint:Z,detailJson:zJ(_),contentHash:z,indexedAt:new Date().toISOString(),structuralFingerprint:W}}function K$(_){let{parsed:$,project:J,filePath:Q,contentHash:z,symbolRepo:Y}=_,Z=T_($),W=[];for(let X of Z){W.push(s$(X,X.name,J,Q,z));for(let U of X.members??[])W.push(s$(U,`${X.name}.${U.name}`,J,Q,z))}Y.replaceFileSymbols(J,Q,z,W)}import{resolve as L$,dirname as YJ,extname as ZJ}from"path";function D_(_,$,J){let Q=(z)=>{let Y=ZJ(z);if(Y==="")return[z+".ts",z+".d.ts",z+"/index.ts",z+"/index.d.ts",z+".mts",z+"/index.mts",z+".cts",z+"/index.cts"];if(Y===".js")return[z.slice(0,-3)+".ts"];if(Y===".mjs")return[z.slice(0,-4)+".mts"];if(Y===".cjs")return[z.slice(0,-4)+".cts"];return[z]};if($.startsWith(".")){let z=Y_(L$(YJ(_),$));return Q(z)}if(J)for(let[z,Y]of J.paths){if(Y.length===0)continue;let Z=z.indexOf("*");if(Z===-1){if($===z){let W=[];for(let X of Y)W.push(...Q(Y_(L$(J.baseUrl,X))));return W}}else{let W=z.slice(0,Z),X=z.slice(Z+1);if($.startsWith(W)&&(X===""||$.endsWith(X))){let U=$.slice(W.length,X===""?void 0:$.length-X.length),O=[];for(let H of Y)O.push(...Q(Y_(L$(J.baseUrl,H.replace("*",U)))));return O}}}return[]}function r$(_,$,J,Q=D_){let z=new Map,Y=_.body??[];for(let Z of Y){if(Z.type!=="ImportDeclaration")continue;let W=Z.source?.value??"",X=Q($,W,J);if(X.length===0)continue;let U=X[0],O=Z.specifiers??[];for(let H of O)switch(H.type){case"ImportSpecifier":z.set(H.local.name,{path:U,importedName:H.imported.name});break;case"ImportDefaultSpecifier":z.set(H.local.name,{path:U,importedName:"default"});break;case"ImportNamespaceSpecifier":z.set(H.local.name,{path:U,importedName:"*"});break}}return z}import{Visitor as XJ}from"oxc-parser";function a_(_){return"name"in _&&typeof _.name==="string"?_.name:("value"in _)&&typeof _.value==="string"?_.value:"unknown"}function OJ(_){return!_.startsWith(".")&&!_.startsWith("/")}function I_(_,$,J,Q){let z=Q(_,$,J),Y=z.length>0?z[0]:null,Z=Y===null&&OJ($);return{resolved:Y,isExternal:Z}}function VJ(_,$,J,Q,z){for(let Y of _.staticImports){let Z=Y.moduleRequest.value,{resolved:W,isExternal:X}=I_($,Z,J,Q),U=W===null?{dstFilePath:null,specifier:Z}:{dstFilePath:W};if(Y.entries.length===0){let O={};if(X)O.isExternal=!0;if(W===null&&!X)O.isUnresolved=!0;z.push({type:"imports",srcFilePath:$,srcSymbolName:null,...U,dstSymbolName:null,...Object.keys(O).length>0?{metaJson:JSON.stringify(O)}:{}});continue}for(let O of Y.entries){let H=O.isType,L={};if(H)L.isType=!0;if(X)L.isExternal=!0;if(W===null&&!X)L.isUnresolved=!0;let D,K,B=O.importName.kind;if(B==="Default")D="default",K=O.localName.value;else if(B==="NamespaceObject")D="*",K=O.localName.value,L.importKind="namespace";else D=O.importName.name??"unknown",K=O.localName.value;z.push({type:H?"type-references":"imports",srcFilePath:$,srcSymbolName:K,...U,dstSymbolName:D,...Object.keys(L).length>0?{metaJson:JSON.stringify(L)}:{}})}}}function UJ(_,$,J,Q,z){let Y=new Map;for(let Z of _.staticImports)for(let W of Z.entries)Y.set(W.localName.value,Z.moduleRequest.value);for(let Z of _.staticExports)for(let W of Z.entries){let X=null;if(W.moduleRequest)X=W.moduleRequest.value;else if(W.localName.name)X=Y.get(W.localName.name)??null;if(!X)continue;let{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.exportName.name??"default",L=W.exportName.kind,D=W.localName.name??W.importName.name??H,K=W.isType,B={isReExport:!0};if(L==="None");else B.specifiers=[{local:D,exported:H}];if(K)B.isType=!0;if(O)B.isExternal=!0;if(U===null&&!O)B.isUnresolved=!0;let T=null,k=W.importName.kind;if(k==="All"||k==="AllButDefault"){if(L==="Name"&&H)T=H,B.namespaceAlias=H}z.push({type:K?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:T,metaJson:JSON.stringify(B),...U===null?{specifier:X}:{}})}}function HJ(_,$,J,Q,z){for(let Y of _.body){let Z=Y;if(Z.type==="ImportDeclaration"){let W=Z,X=W.source.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.importKind==="type",L=W.specifiers,D=U===null?{dstFilePath:null,specifier:X}:{dstFilePath:U};if(L.length===0){let K={};if(H)K.isType=!0;if(O)K.isExternal=!0;if(U===null&&!O)K.isUnresolved=!0;z.push({type:H?"type-references":"imports",srcFilePath:$,srcSymbolName:null,...D,dstSymbolName:null,...Object.keys(K).length>0?{metaJson:JSON.stringify(K)}:{}})}else for(let K of L){let B=K.type,T=H||B==="ImportSpecifier"&&K.importKind==="type",k={};if(T)k.isType=!0;if(O)k.isExternal=!0;if(U===null&&!O)k.isUnresolved=!0;let P,j;if(B==="ImportDefaultSpecifier")P="default",j=K.local.name;else if(B==="ImportNamespaceSpecifier")P="*",j=K.local.name,k.importKind="namespace";else P=a_(K.imported),j=K.local.name;z.push({type:T?"type-references":"imports",srcFilePath:$,srcSymbolName:j,...D,dstSymbolName:P,...Object.keys(k).length>0?{metaJson:JSON.stringify(k)}:{}})}continue}if(Z.type==="ExportAllDeclaration"){let W=Z,X=W.source.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.exportKind==="type",L=W.exported,D=L?a_(L):null,K={isReExport:!0};if(H)K.isType=!0;if(O)K.isExternal=!0;if(U===null&&!O)K.isUnresolved=!0;if(D)K.namespaceAlias=D;z.push({type:H?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:D,metaJson:JSON.stringify(K),...U===null?{specifier:X}:{}});continue}if(Z.type==="ExportNamedDeclaration"){let W=Z;if(!W.source)continue;let X=W.source.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.exportKind==="type",L=W.specifiers??[];for(let D of L){let K=H||D.exportKind==="type",B=a_(D.local),T=a_(D.exported),k={isReExport:!0,specifiers:[{local:B,exported:T}]};if(K)k.isType=!0;if(O)k.isExternal=!0;if(U===null&&!O)k.isUnresolved=!0;z.push({type:K?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:null,metaJson:JSON.stringify(k),...U===null?{specifier:X}:{}})}}}}function MJ(_,$,J,Q,z){new XJ({ImportExpression(Z){let W=Z.source;if(W.type!=="Literal"||typeof W.value!=="string")return;let X=W.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H={isDynamic:!0};if(O)H.isExternal=!0;if(U===null&&!O)H.isUnresolved=!0;z.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:null,metaJson:JSON.stringify(H),...U===null?{specifier:X}:{}})},CallExpression(Z){let W=Z.callee,X=!1;if(W.type==="Identifier"&&W.name==="require");else if(W.type==="MemberExpression"&&!W.computed){let B=W,T=B.object,k=B.property;if(T.type==="Identifier"&&T.name==="require"&&k.name==="resolve")X=!0;else return}else return;let U=Z.arguments;if(U.length===0)return;let O=U[0];if(O.type!=="Literal"||typeof O.value!=="string")return;let H=O.value,{resolved:L,isExternal:D}=I_($,H,J,Q),K={isRequire:!0};if(X)K.isRequireResolve=!0;if(D)K.isExternal=!0;if(L===null&&!D)K.isUnresolved=!0;z.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:L,dstSymbolName:null,metaJson:JSON.stringify(K),...L===null?{specifier:H}:{}})}}).visit(_)}function o$(_,$,J,Q=D_,z){let Y=[];if(z)VJ(z,$,J,Q,Y),UJ(z,$,J,Q,Y);else HJ(_,$,J,Q,Y);return MJ(_,$,J,Q,Y),Y}import{walk as KJ}from"oxc-walker";function R_(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let $=_;if($.type==="Identifier"){let J=$.name;return{root:J,parts:[],full:J}}if($.type==="ThisExpression")return{root:"this",parts:[],full:"this"};if($.type==="Super")return{root:"super",parts:[],full:"super"};if($.type==="MemberExpression"){let J=[],Q=$;while(Q.type==="MemberExpression"){let Z=Q.property;if(!Z||typeof Z.name!=="string")return null;J.push(Z.name),Q=Q.object}let z;if(Q.type==="Identifier")z=Q.name;else if(Q.type==="ThisExpression")z="this";else if(Q.type==="Super")z="super";else return null;J.reverse();let Y=[z,...J].join(".");return{root:z,parts:J,full:Y}}return null}function t$(_,$,J){let Q=[],z=[],Y=[];function Z(){if(z.length>0)return z[z.length-1]??null;return null}function W(O){if(!O)return null;let H=J.get(O.root);if(O.parts.length===0){if(H)return{dstFilePath:H.path,dstSymbolName:H.importedName,resolution:"import"};return{dstFilePath:$,dstSymbolName:O.root,resolution:"local"}}else{if(H&&H.importedName==="*"){let L=O.parts[O.parts.length-1];return{dstFilePath:H.path,dstSymbolName:L,resolution:"namespace"}}return{dstFilePath:$,dstSymbolName:O.full,resolution:"local-member"}}}function X(O,H){let L=R_(O.callee),D=W(L);if(D){let K=Z(),B={};if(H)B.isNew=!0;if(K===null)B.scope="module";Q.push({type:"calls",srcFilePath:$,srcSymbolName:K,dstFilePath:D.dstFilePath,dstSymbolName:D.dstSymbolName,...Object.keys(B).length>0?{metaJson:JSON.stringify(B)}:{}})}}function U(O,H){if(O.type==="FunctionDeclaration"){z.push(O.id?.name??"anonymous");return}if(O.type==="FunctionExpression"||O.type==="ArrowFunctionExpression"){if(H?.type==="VariableDeclarator"){let K=H.id,B=K.type==="Identifier"?K.name:"anonymous";z.push(B);return}if(H?.type==="MethodDefinition"||H?.type==="TSAbstractMethodDefinition"){let K=H.key,B=Y[Y.length-1]??"",T="name"in K?K.name:"anonymous",k=B?`${B}.${T}`:T;z.push(k);return}let L=Z(),D=L?`${L}.<anonymous>`:"<anonymous>";z.push(D)}}return KJ(_,{enter(O,H){if(O.type==="ClassDeclaration"||O.type==="ClassExpression"){Y.push(O.id?.name??"AnonymousClass");return}if(O.type==="FunctionDeclaration"||O.type==="FunctionExpression"||O.type==="ArrowFunctionExpression"){U(O,H);return}if(O.type==="CallExpression"){X(O,!1);return}if(O.type==="NewExpression"){X(O,!0);return}},leave(O){if(O.type==="ClassDeclaration"||O.type==="ClassExpression"){Y.pop();return}if(O.type==="FunctionDeclaration"||O.type==="FunctionExpression"||O.type==="ArrowFunctionExpression"){z.pop();return}}}),Q}import{Visitor as LJ}from"oxc-parser";function e$(_,$,J){let Q=[];function z(Z){let W=Z.id?.name??"AnonymousClass";if(Z.superClass){let U=R_(Z.superClass);if(U){let O=w$(U,$,J);Q.push({type:"extends",srcFilePath:$,srcSymbolName:W,...O})}}let X=Z.implements??[];for(let U of X){let O=R_(U.expression);if(!O)continue;let H=w$(O,$,J);Q.push({type:"implements",srcFilePath:$,srcSymbolName:W,...H})}}return new LJ({TSInterfaceDeclaration(Z){let W=Z.id.name??"AnonymousInterface",X=Z.extends;for(let U of X){let O=R_(U.expression);if(!O)continue;let H=w$(O,$,J);Q.push({type:"extends",srcFilePath:$,srcSymbolName:W,...H})}},ClassDeclaration(Z){z(Z)},ClassExpression(Z){z(Z)}}).visit(_),Q}function w$(_,$,J){let Q=J.get(_.root);if(Q){if(Q.importedName==="*"){let z=_.parts[_.parts.length-1]??_.root;return{dstFilePath:Q.path,dstSymbolName:z,metaJson:JSON.stringify({isNamespaceImport:!0})}}return{dstFilePath:Q.path,dstSymbolName:_.parts.length>0?_.full:Q.importedName}}return{dstFilePath:$,dstSymbolName:_.full,metaJson:JSON.stringify({isLocal:!0})}}function s_(_,$,J,Q=D_,z){let Y=r$(_,$,J,Q),Z=o$(_,$,J,Q,z),W=t$(_,$,Y),X=e$(_,$,Y);return[...Z,...W,...X]}function B$(_){let{ast:$,project:J,filePath:Q,relationRepo:z,projectRoot:Y,tsconfigPaths:Z,knownFiles:W,boundaries:X,module:U}=_,O=q_(Y,Q),L=s_($,O,Z,W?(K,B,T)=>{let k=D_(K,B,T);for(let P of k){let j=E_(Y,P);if(X){let f=t(j,X);if(W.has(`${f}::${j}`))return[P]}else if(W.has(`${J}::${j}`))return[P]}return[]}:void 0,U),D=[];for(let K of L){if(K.dstFilePath===null){let P=E_(Y,K.srcFilePath),j;if(K.metaJson)try{j=JSON.parse(K.metaJson)}catch{}let f=j?.isExternal===!0;D.push({project:J,type:K.type,srcFilePath:P,srcSymbolName:K.srcSymbolName??null,dstProject:null,dstFilePath:null,dstSymbolName:K.dstSymbolName??null,metaJson:K.metaJson??null,specifier:K.specifier??null,isExternal:f?1:0});continue}let B=E_(Y,K.dstFilePath);if(B.startsWith(".."))continue;let T=E_(Y,K.srcFilePath),k=X?t(B,X):J;D.push({project:J,type:K.type,srcFilePath:T,srcSymbolName:K.srcSymbolName??null,dstProject:k,dstFilePath:B,dstSymbolName:K.dstSymbolName??null,metaJson:K.metaJson??null,specifier:K.specifier??null,isExternal:0})}return z.replaceFileRelations(J,Q,D),D.length}import{isErr as wJ}from"@zipbul/result";var _0=/(?:^|\s)@([a-zA-Z][\w-]*\w|[a-zA-Z])\s*(.*)$/m;function BJ(_){let $=T_(_),J=[];for(let Q of $){J.push({name:Q.name,startLine:Q.span.start.line});for(let z of Q.members??[])J.push({name:`${Q.name}.${z.name}`,startLine:z.span.start.line})}return J.sort((Q,z)=>Q.startLine-z.startLine),J}function D$(_,$,J){let Q=0,z=_.length-1;while(Q<=z){let Y=Q+z>>1;if(_[Y].startLine<=$)Q=Y+1;else z=Y-1}if(Q<_.length){let Y=_[Q];if(Y.startLine-$<=J)return Y.name}return null}function r_(_,$,J){let Q=X_(_,$),z=X_(_,J);return{start:Q,end:z}}function $0(_){let{comments:$,sourceText:J}=_;if(!$.length)return[];let Q=P_(J),z=BJ(_),Y=[],Z=[...$].sort((X,U)=>X.start-U.start),W=null;for(let X of Z)if(X.type==="Block"&&X.value.startsWith("*")){W=null;let U=`/*${X.value}*/`,O=l_(U);if(wJ(O))continue;let H=O;if(!H.tags?.length)continue;let L=X_(Q,X.end),D=D$(z,L.line,3),K=J.slice(X.start,X.end);for(let B of H.tags){let T=[B.name,B.description].filter(Boolean).join(" "),k=`@${B.tag}`,P=K.indexOf(k),j;if(P>=0){let f=X.start+P,o=J.indexOf(`
3
+ `)$.push(J+1);return $}function X_(_,$){let J=0,Q=_.length-1;while(J<Q){let z=J+Q+1>>1;if(_[z]<=$)J=z;else Q=z-1}return{line:J+1,column:$-_[J]}}import{err as _J}from"@zipbul/result";import{parse as $J}from"comment-parser";function l_(_){try{let $=_.trim();if($.startsWith("/**"))$=$.slice(3);if($.endsWith("*/"))$=$.slice(0,-2);let Q=$J(`/** ${$} */`)[0]??{description:"",tags:[]};return{description:(Q.description??"").trim(),tags:(Q.tags??[]).map((z)=>({tag:z.tag??"",name:z.name??"",type:z.type??"",description:z.description??"",optional:z.optional??!1,...z.default!==void 0?{default:z.default}:{}}))}}catch($){return _J(new V("parse","Failed to parse JSDoc comment",{cause:$}))}}import{isErr as JJ}from"@zipbul/result";function c_(_){if("name"in _&&typeof _.name==="string")return _.name;if("value"in _&&typeof _.value==="string")return _.value;return"unknown"}function S_(_){if(_.type==="Identifier")return[{name:_.name,start:_.start,end:_.end}];if(_.type==="ObjectPattern"){let $=[];for(let J of _.properties)if(J.type==="RestElement")$.push(...S_(J.argument));else $.push(...S_(J.value));return $}if(_.type==="ArrayPattern"){let $=[];for(let J of _.elements){if(!J)continue;if(J.type==="RestElement")$.push(...S_(J.argument));else $.push(...S_(J))}return $}if(_.type==="AssignmentPattern")return S_(_.left);return[]}function T_(_){let{program:$,sourceText:J,comments:Q}=_,z=P_(J),Y=Q.filter((w)=>w.type==="Block"&&w.value.startsWith("*")).sort((w,A)=>w.end-A.end),Z=$.body.map((w)=>w.start).sort((w,A)=>w-A);function W(w,A){return{start:X_(z,w),end:X_(z,A)}}function X(w){let A=0,I=Y.length-1,u=-1;while(A<=I){let q=A+I>>>1;if(Y[q].end<=w)u=q,A=q+1;else I=q-1}if(u<0)return;let N=Y[u];A=0,I=Z.length-1;while(A<=I){let q=A+I>>>1,F=Z[q];if(F<=N.end)A=q+1;else if(F>=w)I=q-1;else return}return`/*${N.value}*/`}function U(w){if(!w)return;let A="typeAnnotation"in w&&w.typeAnnotation?w.typeAnnotation:w;return J.slice(A.start,A.end)}function O(w){if(!w||w.length===0)return[];return w.map((A)=>{let I=A.expression;if(I.type==="CallExpression"){let u=I,N=u.callee,q="name"in N&&typeof N.name==="string"?N.name:("property"in N)&&N.property&&typeof N.property.name==="string"?N.property.name:"unknown",F=u.arguments.map((E)=>J.slice(E.start,E.end));return{name:q,arguments:F.length>0?F:void 0}}if(I.type==="Identifier")return{name:I.name??"unknown"};return{name:J.slice(I.start,I.end)}})}function H(w){if(w.type==="TSParameterProperty"){let I=w;return L(I.parameter,I.parameter.decorators)}if(w.type==="RestElement"){let I=w,u=I.argument,q=`...${"name"in u&&typeof u.name==="string"?u.name:"unknown"}`,F=I.typeAnnotation,E=F?U(F):void 0,i={name:q,isOptional:!1};if(E)i.type=E;return i}let A=w;return L(A,A.decorators)}function L(w,A){if(w.type==="AssignmentPattern"){let{left:i,right:l}=w,s="name"in i&&typeof i.name==="string"?i.name:"unknown",M="typeAnnotation"in i?i.typeAnnotation:null,C=M?U(M):void 0,S=J.slice(l.start,l.end),R="decorators"in i&&Array.isArray(i.decorators)?i.decorators:[],m=O(R),g={name:s,isOptional:!0,defaultValue:S};if(C)g.type=C;if(m.length>0)g.decorators=m;return g}let I="name"in w&&typeof w.name==="string"?w.name:("pattern"in w)&&w.pattern&&typeof w.pattern.name==="string"?w.pattern.name:"unknown",u=!!(("optional"in w)&&w.optional),N="typeAnnotation"in w?w.typeAnnotation:null,q=N?U(N):void 0,F=O(A??[]),E={name:I,isOptional:u};if(q)E.type=q;if(F.length>0)E.decorators=F;return E}function D(w,A){let I=[];if(A?.async)I.push("async");if(w.static)I.push("static");if(w.abstract)I.push("abstract");if(w.readonly)I.push("readonly");if(w.override)I.push("override");if(w.declare)I.push("declare");if(w.const)I.push("const");let u=w.accessibility;if(u==="private")I.push("private");else if(u==="protected")I.push("protected");else if(u==="public")I.push("public");return I}function K(w){if(!w)return;let A=w.params.flatMap((I)=>{let u=I.name.name;return u?[u]:[]});return A.length>0?A:void 0}function B(w){let A=[];if(w.superClass){let u=J.slice(w.superClass.start,w.superClass.end);A.push({kind:"extends",name:u})}let I=w.implements??[];for(let u of I){let N=u.expression,q=J.slice(N.start,N.end);A.push({kind:"implements",name:q})}return A}function T(w){let A=[],I=w.extends;for(let u of I){let N=u.expression,q=J.slice(N.start,N.end);A.push({kind:"extends",name:q})}return A}function k(w){let A=[];for(let I of w)if(I.type==="MethodDefinition"||I.type==="TSAbstractMethodDefinition"){let u=I,N=c_(u.key),q=u.value,F=u.kind,E=F==="constructor"?"constructor":F==="get"?"getter":F==="set"?"setter":"method",i=D(u,q);if(I.type==="TSAbstractMethodDefinition"&&!i.includes("abstract"))i.push("abstract");let l=q.params.map(H),s=U(q.returnType),M={kind:"method",name:N,span:W(I.start,I.end),isExported:!1,methodKind:E,modifiers:i,parameters:l.length>0?l:void 0,returnType:s};A.push(M)}else if(I.type==="PropertyDefinition"||I.type==="TSAbstractPropertyDefinition"){let u=I,N=c_(u.key),q=D(u);if(I.type==="TSAbstractPropertyDefinition"&&!q.includes("abstract"))q.push("abstract");let F={kind:"property",name:N,span:W(I.start,I.end),isExported:!1,modifiers:q};A.push(F)}return A}function P(w){let A=[];for(let I of w)if(I.type==="TSMethodSignature"){let u=I,N=c_(u.key),q=u.params.map(H),F=U(u.returnType);A.push({kind:"method",name:N,span:W(I.start,I.end),isExported:!1,modifiers:[],methodKind:"method",parameters:q.length>0?q:void 0,returnType:F})}else if(I.type==="TSPropertySignature"){let u=I,N=c_(u.key),q=U(u.typeAnnotation),F={kind:"property",name:N,span:W(I.start,I.end),isExported:!1,modifiers:u.readonly?["readonly"]:[],returnType:q};A.push(F)}return A}function j(w,A){let I=w.type;if(I==="FunctionDeclaration"||I==="FunctionExpression"||I==="TSDeclareFunction"||I==="TSEmptyBodyFunctionExpression"){let u=w,N=u.id?.name??"default",q=u.params.map(H),F=U(u.returnType),E=D(u,u),i=O(u.decorators??[]),l=K(u.typeParameters),s={kind:"function",name:N,span:W(w.start,w.end),isExported:A,modifiers:E,parameters:q.length>0?q:void 0,returnType:F,decorators:i.length>0?i:void 0};if(l&&l.length>0)s.typeParameters=l;return s}if(I==="ClassDeclaration"||I==="ClassExpression"){let u=w,N=u.id?.name??"default",q=B(u),F=k(u.body.body),E=O(u.decorators),i=D(u),l=K(u.typeParameters),s={kind:"class",name:N,span:W(w.start,w.end),isExported:A,modifiers:i,heritage:q.length>0?q:void 0,members:F.length>0?F:void 0,decorators:E.length>0?E:void 0};if(l&&l.length>0)s.typeParameters=l;return s}if(I==="VariableDeclaration"){let u=w,N=[];for(let q of u.declarations){let{id:F,init:E}=q;if(F.type==="ObjectPattern"||F.type==="ArrayPattern"){let S=S_(F);for(let R of S)N.push({kind:"variable",name:R.name,span:W(R.start,R.end),isExported:A,modifiers:[]});continue}let i="name"in F&&typeof F.name==="string"?F.name:"unknown",l="variable",s,M;if(E){if(E.type==="FunctionExpression"||E.type==="ArrowFunctionExpression"){l="function";let S=E;s=S.params.map(H),M=U(S.returnType)}}let C=[];N.push({kind:l,name:i,span:W(q.start,q.end),isExported:A,modifiers:C,parameters:s,returnType:M})}if(N.length===0)return null;if(N.length===1)return N[0];return N}if(I==="TSTypeAliasDeclaration")return{kind:"type",name:w.id.name,span:W(w.start,w.end),isExported:A,modifiers:[]};if(I==="TSInterfaceDeclaration"){let u=w,N=u.id.name,q=T(u),F=P(u.body.body),E=K(u.typeParameters),i={kind:"interface",name:N,span:W(w.start,w.end),isExported:A,modifiers:[],heritage:q.length>0?q:void 0,members:F.length>0?F:void 0};if(E&&E.length>0)i.typeParameters=E;return i}if(I==="TSEnumDeclaration"){let u=w,N=u.id.name,q=D(u),E=u.body.members.map((i)=>{let l=i.id;return{kind:"property",name:"name"in l&&typeof l.name==="string"?l.name:("value"in l)&&typeof l.value==="string"?l.value:"unknown",span:W(i.start,i.end),isExported:!1,modifiers:[]}});return{kind:"enum",name:N,span:W(w.start,w.end),isExported:A,modifiers:q,members:E.length>0?E:void 0}}if(I==="TSModuleDeclaration"){let u=w,N=u.id.name??u.id.value??"unknown",q=D(u);return{kind:"namespace",name:N,span:W(w.start,w.end),isExported:A,modifiers:q}}return null}let f=[],o=new Set;for(let w of $.body){let A=null,I=w;if(I.type==="ExportNamedDeclaration"){let N=I;if(N.declaration){if(A=j(N.declaration,!0),A&&!Array.isArray(A))A.span=W(N.start,N.end)}else if(!N.source&&N.specifiers)for(let q of N.specifiers){let F=q.local,E="name"in F?F.name:F.value;if(E)o.add(E)}}else if(I.type==="ExportDefaultDeclaration"){let N=I,q=N.declaration;if(q){if(A=j(q,!0),A&&!Array.isArray(A))A.name="id"in q&&q.id&&typeof q.id.name==="string"?q.id.name:"default",A.isExported=!0,A.span=W(N.start,N.end);else if(!A&&"type"in q&&q.type==="Identifier"){let F=q.name;if(F)o.add(F)}}}else{let N=I.type;if(N==="FunctionDeclaration"||N==="TSDeclareFunction"||N==="ClassDeclaration"||N==="VariableDeclaration"||N==="TSTypeAliasDeclaration"||N==="TSInterfaceDeclaration"||N==="TSEnumDeclaration"||N==="TSModuleDeclaration")A=j(I,!1)}let u=Array.isArray(A)?A:A?[A]:[];for(let N of u){let q=w.start,F=X(q);if(F){let E=l_(F);if(!JJ(E))N.jsDoc=E}f.push(N)}}if(o.size>0){for(let w of f)if(!w.isExported&&o.has(w.name))w.isExported=!0}return f}function QJ(_){if(_.kind==="function"||_.kind==="method"){let $=_.parameters?.length??0,J=_.modifiers.includes("async")?1:0;return`params:${$}|async:${J}`}return null}function zJ(_){let $={};if(_.jsDoc)$.jsDoc=_.jsDoc;if(_.kind==="function"||_.kind==="method"){if(_.parameters!==void 0)$.parameters=_.parameters;if(_.returnType!==void 0)$.returnType=_.returnType}if(_.heritage?.length)$.heritage=_.heritage;if(_.decorators?.length)$.decorators=_.decorators;if(_.typeParameters?.length)$.typeParameters=_.typeParameters;if(_.modifiers?.length)$.modifiers=_.modifiers;if(_.members?.length)$.members=_.members.map((J)=>{let Q=J.modifiers.find((z)=>z==="private"||z==="protected"||z==="public");return{name:J.name,kind:J.methodKind??J.kind,type:J.returnType,visibility:Q,isStatic:J.modifiers.includes("static")||void 0,isReadonly:J.modifiers.includes("readonly")||void 0}});return Object.keys($).length>0?JSON.stringify($):null}function WJ(_){let $=[_.kind];if(_.modifiers.length)$.push(`mod:${[..._.modifiers].sort().join(",")}`);if(_.typeParameters?.length)$.push(`tp:${_.typeParameters.length}`);if(_.heritage?.length){let J=[..._.heritage].sort((Q,z)=>Q.name.localeCompare(z.name)).map((Q)=>`${Q.kind}:${Q.name}`).join(",");$.push(`her:${J}`)}if(_.decorators?.length)$.push(`dec:${[..._.decorators].map((J)=>J.name).sort().join(",")}`);if(_.methodKind)$.push(`mk:${_.methodKind}`);if(_.parameters)$.push(`p:${_.parameters.length}`);if(_.returnType)$.push(`rt:${_.returnType}`);if(_.members?.length){let J=_.members.map((Q)=>`${Q.kind}:${Q.modifiers.join(",")}:${Q.parameters?.length??""}:${Q.returnType??""}`).sort().join(";");$.push(`mem:${_.members.length}:${O_(J)}`)}return O_($.join("|"))}function s$(_,$,J,Q,z){let Y=QJ(_),Z=O_(`${$}|${_.kind}|${Y??""}`),W=WJ(_);return{project:J,filePath:Q,kind:_.kind,name:$,startLine:_.span.start.line,startColumn:_.span.start.column,endLine:_.span.end.line,endColumn:_.span.end.column,isExported:_.isExported?1:0,signature:Y,fingerprint:Z,detailJson:zJ(_),contentHash:z,indexedAt:new Date().toISOString(),structuralFingerprint:W}}function K$(_){let{parsed:$,project:J,filePath:Q,contentHash:z,symbolRepo:Y}=_,Z=T_($),W=[];for(let X of Z){W.push(s$(X,X.name,J,Q,z));for(let U of X.members??[])W.push(s$(U,`${X.name}.${U.name}`,J,Q,z))}Y.replaceFileSymbols(J,Q,z,W)}import{resolve as L$,dirname as YJ,extname as ZJ}from"path";function D_(_,$,J){let Q=(z)=>{let Y=ZJ(z);if(Y===".js")return[z.slice(0,-3)+".ts"];if(Y===".mjs")return[z.slice(0,-4)+".mts"];if(Y===".cjs")return[z.slice(0,-4)+".cts"];if(Y===".ts"||Y===".mts"||Y===".cts"||Y===".d.ts")return[z];return[z+".ts",z+".d.ts",z+"/index.ts",z+"/index.d.ts",z+".mts",z+"/index.mts",z+".cts",z+"/index.cts"]};if($.startsWith(".")){let z=Y_(L$(YJ(_),$));return Q(z)}if(J)for(let[z,Y]of J.paths){if(Y.length===0)continue;let Z=z.indexOf("*");if(Z===-1){if($===z){let W=[];for(let X of Y)W.push(...Q(Y_(L$(J.baseUrl,X))));return W}}else{let W=z.slice(0,Z),X=z.slice(Z+1);if($.startsWith(W)&&(X===""||$.endsWith(X))){let U=$.slice(W.length,X===""?void 0:$.length-X.length),O=[];for(let H of Y)O.push(...Q(Y_(L$(J.baseUrl,H.replace("*",U)))));return O}}}return[]}function r$(_,$,J,Q=D_){let z=new Map,Y=_.body??[];for(let Z of Y){if(Z.type!=="ImportDeclaration")continue;let W=Z.source?.value??"",X=Q($,W,J);if(X.length===0)continue;let U=X[0],O=Z.specifiers??[];for(let H of O)switch(H.type){case"ImportSpecifier":z.set(H.local.name,{path:U,importedName:H.imported.name});break;case"ImportDefaultSpecifier":z.set(H.local.name,{path:U,importedName:"default"});break;case"ImportNamespaceSpecifier":z.set(H.local.name,{path:U,importedName:"*"});break}}return z}import{Visitor as XJ}from"oxc-parser";function a_(_){return"name"in _&&typeof _.name==="string"?_.name:("value"in _)&&typeof _.value==="string"?_.value:"unknown"}function OJ(_){return!_.startsWith(".")&&!_.startsWith("/")}function I_(_,$,J,Q){let z=Q(_,$,J),Y=z.length>0?z[0]:null,Z=Y===null&&OJ($);return{resolved:Y,isExternal:Z}}function VJ(_,$,J,Q,z){for(let Y of _.staticImports){let Z=Y.moduleRequest.value,{resolved:W,isExternal:X}=I_($,Z,J,Q),U=W===null?{dstFilePath:null,specifier:Z}:{dstFilePath:W};if(Y.entries.length===0){let O={};if(X)O.isExternal=!0;if(W===null&&!X)O.isUnresolved=!0;z.push({type:"imports",srcFilePath:$,srcSymbolName:null,...U,dstSymbolName:null,...Object.keys(O).length>0?{metaJson:JSON.stringify(O)}:{}});continue}for(let O of Y.entries){let H=O.isType,L={};if(H)L.isType=!0;if(X)L.isExternal=!0;if(W===null&&!X)L.isUnresolved=!0;let D,K,B=O.importName.kind;if(B==="Default")D="default",K=O.localName.value;else if(B==="NamespaceObject")D="*",K=O.localName.value,L.importKind="namespace";else D=O.importName.name??"unknown",K=O.localName.value;z.push({type:H?"type-references":"imports",srcFilePath:$,srcSymbolName:K,...U,dstSymbolName:D,...Object.keys(L).length>0?{metaJson:JSON.stringify(L)}:{}})}}}function UJ(_,$,J,Q,z){let Y=new Map;for(let Z of _.staticImports)for(let W of Z.entries)Y.set(W.localName.value,Z.moduleRequest.value);for(let Z of _.staticExports)for(let W of Z.entries){let X=null;if(W.moduleRequest)X=W.moduleRequest.value;else if(W.localName.name)X=Y.get(W.localName.name)??null;if(!X)continue;let{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.exportName.name??"default",L=W.exportName.kind,D=W.localName.name??W.importName.name??H,K=W.isType,B={isReExport:!0};if(L==="None");else B.specifiers=[{local:D,exported:H}];if(K)B.isType=!0;if(O)B.isExternal=!0;if(U===null&&!O)B.isUnresolved=!0;let T=null,k=W.importName.kind;if(k==="All"||k==="AllButDefault"){if(L==="Name"&&H)T=H,B.namespaceAlias=H}z.push({type:K?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:T,metaJson:JSON.stringify(B),...U===null?{specifier:X}:{}})}}function HJ(_,$,J,Q,z){for(let Y of _.body){let Z=Y;if(Z.type==="ImportDeclaration"){let W=Z,X=W.source.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.importKind==="type",L=W.specifiers,D=U===null?{dstFilePath:null,specifier:X}:{dstFilePath:U};if(L.length===0){let K={};if(H)K.isType=!0;if(O)K.isExternal=!0;if(U===null&&!O)K.isUnresolved=!0;z.push({type:H?"type-references":"imports",srcFilePath:$,srcSymbolName:null,...D,dstSymbolName:null,...Object.keys(K).length>0?{metaJson:JSON.stringify(K)}:{}})}else for(let K of L){let B=K.type,T=H||B==="ImportSpecifier"&&K.importKind==="type",k={};if(T)k.isType=!0;if(O)k.isExternal=!0;if(U===null&&!O)k.isUnresolved=!0;let P,j;if(B==="ImportDefaultSpecifier")P="default",j=K.local.name;else if(B==="ImportNamespaceSpecifier")P="*",j=K.local.name,k.importKind="namespace";else P=a_(K.imported),j=K.local.name;z.push({type:T?"type-references":"imports",srcFilePath:$,srcSymbolName:j,...D,dstSymbolName:P,...Object.keys(k).length>0?{metaJson:JSON.stringify(k)}:{}})}continue}if(Z.type==="ExportAllDeclaration"){let W=Z,X=W.source.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.exportKind==="type",L=W.exported,D=L?a_(L):null,K={isReExport:!0};if(H)K.isType=!0;if(O)K.isExternal=!0;if(U===null&&!O)K.isUnresolved=!0;if(D)K.namespaceAlias=D;z.push({type:H?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:D,metaJson:JSON.stringify(K),...U===null?{specifier:X}:{}});continue}if(Z.type==="ExportNamedDeclaration"){let W=Z;if(!W.source)continue;let X=W.source.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H=W.exportKind==="type",L=W.specifiers??[];for(let D of L){let K=H||D.exportKind==="type",B=a_(D.local),T=a_(D.exported),k={isReExport:!0,specifiers:[{local:B,exported:T}]};if(K)k.isType=!0;if(O)k.isExternal=!0;if(U===null&&!O)k.isUnresolved=!0;z.push({type:K?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:null,metaJson:JSON.stringify(k),...U===null?{specifier:X}:{}})}}}}function MJ(_,$,J,Q,z){new XJ({ImportExpression(Z){let W=Z.source;if(W.type!=="Literal"||typeof W.value!=="string")return;let X=W.value,{resolved:U,isExternal:O}=I_($,X,J,Q),H={isDynamic:!0};if(O)H.isExternal=!0;if(U===null&&!O)H.isUnresolved=!0;z.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:U,dstSymbolName:null,metaJson:JSON.stringify(H),...U===null?{specifier:X}:{}})},CallExpression(Z){let W=Z.callee,X=!1;if(W.type==="Identifier"&&W.name==="require");else if(W.type==="MemberExpression"&&!W.computed){let B=W,T=B.object,k=B.property;if(T.type==="Identifier"&&T.name==="require"&&k.name==="resolve")X=!0;else return}else return;let U=Z.arguments;if(U.length===0)return;let O=U[0];if(O.type!=="Literal"||typeof O.value!=="string")return;let H=O.value,{resolved:L,isExternal:D}=I_($,H,J,Q),K={isRequire:!0};if(X)K.isRequireResolve=!0;if(D)K.isExternal=!0;if(L===null&&!D)K.isUnresolved=!0;z.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:L,dstSymbolName:null,metaJson:JSON.stringify(K),...L===null?{specifier:H}:{}})}}).visit(_)}function o$(_,$,J,Q=D_,z){let Y=[];if(z)VJ(z,$,J,Q,Y),UJ(z,$,J,Q,Y);else HJ(_,$,J,Q,Y);return MJ(_,$,J,Q,Y),Y}import{walk as KJ}from"oxc-walker";function R_(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let $=_;if($.type==="Identifier"){let J=$.name;return{root:J,parts:[],full:J}}if($.type==="ThisExpression")return{root:"this",parts:[],full:"this"};if($.type==="Super")return{root:"super",parts:[],full:"super"};if($.type==="MemberExpression"){let J=[],Q=$;while(Q.type==="MemberExpression"){let Z=Q.property;if(!Z||typeof Z.name!=="string")return null;J.push(Z.name),Q=Q.object}let z;if(Q.type==="Identifier")z=Q.name;else if(Q.type==="ThisExpression")z="this";else if(Q.type==="Super")z="super";else return null;J.reverse();let Y=[z,...J].join(".");return{root:z,parts:J,full:Y}}return null}function t$(_,$,J){let Q=[],z=[],Y=[];function Z(){if(z.length>0)return z[z.length-1]??null;return null}function W(O){if(!O)return null;let H=J.get(O.root);if(O.parts.length===0){if(H)return{dstFilePath:H.path,dstSymbolName:H.importedName,resolution:"import"};return{dstFilePath:$,dstSymbolName:O.root,resolution:"local"}}else{if(H&&H.importedName==="*"){let L=O.parts[O.parts.length-1];return{dstFilePath:H.path,dstSymbolName:L,resolution:"namespace"}}return{dstFilePath:$,dstSymbolName:O.full,resolution:"local-member"}}}function X(O,H){let L=R_(O.callee),D=W(L);if(D){let K=Z(),B={};if(H)B.isNew=!0;if(K===null)B.scope="module";Q.push({type:"calls",srcFilePath:$,srcSymbolName:K,dstFilePath:D.dstFilePath,dstSymbolName:D.dstSymbolName,...Object.keys(B).length>0?{metaJson:JSON.stringify(B)}:{}})}}function U(O,H){if(O.type==="FunctionDeclaration"){z.push(O.id?.name??"anonymous");return}if(O.type==="FunctionExpression"||O.type==="ArrowFunctionExpression"){if(H?.type==="VariableDeclarator"){let K=H.id,B=K.type==="Identifier"?K.name:"anonymous";z.push(B);return}if(H?.type==="MethodDefinition"||H?.type==="TSAbstractMethodDefinition"){let K=H.key,B=Y[Y.length-1]??"",T="name"in K?K.name:"anonymous",k=B?`${B}.${T}`:T;z.push(k);return}let L=Z(),D=L?`${L}.<anonymous>`:"<anonymous>";z.push(D)}}return KJ(_,{enter(O,H){if(O.type==="ClassDeclaration"||O.type==="ClassExpression"){Y.push(O.id?.name??"AnonymousClass");return}if(O.type==="FunctionDeclaration"||O.type==="FunctionExpression"||O.type==="ArrowFunctionExpression"){U(O,H);return}if(O.type==="CallExpression"){X(O,!1);return}if(O.type==="NewExpression"){X(O,!0);return}},leave(O){if(O.type==="ClassDeclaration"||O.type==="ClassExpression"){Y.pop();return}if(O.type==="FunctionDeclaration"||O.type==="FunctionExpression"||O.type==="ArrowFunctionExpression"){z.pop();return}}}),Q}import{Visitor as LJ}from"oxc-parser";function e$(_,$,J){let Q=[];function z(Z){let W=Z.id?.name??"AnonymousClass";if(Z.superClass){let U=R_(Z.superClass);if(U){let O=w$(U,$,J);Q.push({type:"extends",srcFilePath:$,srcSymbolName:W,...O})}}let X=Z.implements??[];for(let U of X){let O=R_(U.expression);if(!O)continue;let H=w$(O,$,J);Q.push({type:"implements",srcFilePath:$,srcSymbolName:W,...H})}}return new LJ({TSInterfaceDeclaration(Z){let W=Z.id.name??"AnonymousInterface",X=Z.extends;for(let U of X){let O=R_(U.expression);if(!O)continue;let H=w$(O,$,J);Q.push({type:"extends",srcFilePath:$,srcSymbolName:W,...H})}},ClassDeclaration(Z){z(Z)},ClassExpression(Z){z(Z)}}).visit(_),Q}function w$(_,$,J){let Q=J.get(_.root);if(Q){if(Q.importedName==="*"){let z=_.parts[_.parts.length-1]??_.root;return{dstFilePath:Q.path,dstSymbolName:z,metaJson:JSON.stringify({isNamespaceImport:!0})}}return{dstFilePath:Q.path,dstSymbolName:_.parts.length>0?_.full:Q.importedName}}return{dstFilePath:$,dstSymbolName:_.full,metaJson:JSON.stringify({isLocal:!0})}}function s_(_,$,J,Q=D_,z){let Y=r$(_,$,J,Q),Z=o$(_,$,J,Q,z),W=t$(_,$,Y),X=e$(_,$,Y);return[...Z,...W,...X]}function B$(_){let{ast:$,project:J,filePath:Q,relationRepo:z,projectRoot:Y,tsconfigPaths:Z,knownFiles:W,boundaries:X,module:U}=_,O=q_(Y,Q),L=s_($,O,Z,W?(K,B,T)=>{let k=D_(K,B,T);for(let P of k){let j=E_(Y,P);if(X){let f=t(j,X);if(W.has(`${f}::${j}`))return[P]}else if(W.has(`${J}::${j}`))return[P]}return[]}:void 0,U),D=[];for(let K of L){if(K.dstFilePath===null){let P=E_(Y,K.srcFilePath),j;if(K.metaJson)try{j=JSON.parse(K.metaJson)}catch{}let f=j?.isExternal===!0;D.push({project:J,type:K.type,srcFilePath:P,srcSymbolName:K.srcSymbolName??null,dstProject:null,dstFilePath:null,dstSymbolName:K.dstSymbolName??null,metaJson:K.metaJson??null,specifier:K.specifier??null,isExternal:f?1:0});continue}let B=E_(Y,K.dstFilePath);if(B.startsWith(".."))continue;let T=E_(Y,K.srcFilePath),k=X?t(B,X):J;D.push({project:J,type:K.type,srcFilePath:T,srcSymbolName:K.srcSymbolName??null,dstProject:k,dstFilePath:B,dstSymbolName:K.dstSymbolName??null,metaJson:K.metaJson??null,specifier:K.specifier??null,isExternal:0})}return z.replaceFileRelations(J,Q,D),D.length}import{isErr as wJ}from"@zipbul/result";var _0=/(?:^|\s)@([a-zA-Z][\w-]*\w|[a-zA-Z])\s*(.*)$/m;function BJ(_){let $=T_(_),J=[];for(let Q of $){J.push({name:Q.name,startLine:Q.span.start.line});for(let z of Q.members??[])J.push({name:`${Q.name}.${z.name}`,startLine:z.span.start.line})}return J.sort((Q,z)=>Q.startLine-z.startLine),J}function D$(_,$,J){let Q=0,z=_.length-1;while(Q<=z){let Y=Q+z>>1;if(_[Y].startLine<=$)Q=Y+1;else z=Y-1}if(Q<_.length){let Y=_[Q];if(Y.startLine-$<=J)return Y.name}return null}function r_(_,$,J){let Q=X_(_,$),z=X_(_,J);return{start:Q,end:z}}function $0(_){let{comments:$,sourceText:J}=_;if(!$.length)return[];let Q=P_(J),z=BJ(_),Y=[],Z=[...$].sort((X,U)=>X.start-U.start),W=null;for(let X of Z)if(X.type==="Block"&&X.value.startsWith("*")){W=null;let U=`/*${X.value}*/`,O=l_(U);if(wJ(O))continue;let H=O;if(!H.tags?.length)continue;let L=X_(Q,X.end),D=D$(z,L.line,3),K=J.slice(X.start,X.end);for(let B of H.tags){let T=[B.name,B.description].filter(Boolean).join(" "),k=`@${B.tag}`,P=K.indexOf(k),j;if(P>=0){let f=X.start+P,o=J.indexOf(`
4
4
  `,f),w=o>=0?Math.min(o,X.end):X.end;j=r_(Q,f,w)}else j=r_(Q,X.start,X.end);Y.push({tag:B.tag,value:T,source:"jsdoc",span:j,symbolName:D})}}else if(X.type==="Block"){W=null;let U=X.value.split(`
5
5
  `),O=0;for(let H of U){let L=H.replace(/^\s*\*?\s?/,""),D=_0.exec(L);if(D){let K=D[1],B=D[2]?.trim()??"",T=`@${K}`,k=H.indexOf(T),P=X.start+2+O+(k>=0?k:0),j=X.start+2+O+H.length,f=r_(Q,P,j),o=X_(Q,X.end),w=D$(z,o.line,3);Y.push({tag:K,value:B,source:"block",span:f,symbolName:w})}O+=H.length+1}}else{let U=X.value,O=_0.exec(U),H=X_(Q,X.start),L=X_(Q,X.end);if(O){let D=O[1],K=O[2]?.trim()??"",B=`@${D}`,T=U.indexOf(B),k=X.start+2+(T>=0?T:0),P=r_(Q,k,X.end),j=D$(z,L.line,3),f={tag:D,value:K,source:"line",span:P,symbolName:j};Y.push(f),W={annotation:f,endLine:L.line}}else if(W&&H.line===W.endLine+1){let D=U.trim();if(D)W.annotation.value+=" "+D,W.annotation.span.end=X_(Q,X.end),W.endLine=L.line}else W=null}return Y}function I$(_){let{parsed:$,project:J,filePath:Q,annotationRepo:z}=_,Y=$0($);if(z.deleteFileAnnotations(J,Q),!Y.length)return 0;let Z=new Date().toISOString(),W=Y.map((X)=>({project:J,filePath:Q,tag:X.tag,value:X.value,source:X.source,symbolName:X.symbolName,startLine:X.span.start.line,startColumn:X.span.start.column,endLine:X.span.end.line,endColumn:X.span.end.column,indexedAt:Z}));return z.insertBatch(J,Q,W),Y.length}function J0(_,$){let J=[],Q=[],z=[];for(let[O,H]of $)if(!_.has(O))J.push({name:H.name,filePath:H.filePath,kind:H.kind,fingerprint:H.fingerprint});for(let[O,H]of _)if(!$.has(O))Q.push({name:H.name,filePath:H.filePath,kind:H.kind,fingerprint:H.fingerprint});if(!J.length||!Q.length)return{renamed:z,added:J,removed:Q};let Y=new Map,Z=new Map;for(let O of J){let H=Y.get(O.filePath)??[];H.push(O),Y.set(O.filePath,H)}for(let O of Q){let H=Z.get(O.filePath)??[];H.push(O),Z.set(O.filePath,H)}let W=new Set,X=new Set;for(let[O,H]of Y){let L=Z.get(O);if(!L)continue;for(let D of new Set(H.map((K)=>K.kind))){let K=H.filter((j)=>j.kind===D&&!W.has(j)),B=L.filter((j)=>j.kind===D&&!X.has(j));if(!K.length||!B.length)continue;let T=(j,f)=>{return f.get(`${j.filePath}::${j.name}`)?.structuralFingerprint??null},k=(j,f)=>{return f.get(`${j.filePath}::${j.name}`)?.startLine??0},P=new Map;for(let j of B){let f=T(j,_);if(!f)continue;let o=P.get(f)??[];o.push(j),P.set(f,o)}for(let j of K){if(W.has(j))continue;let f=T(j,$);if(!f)continue;let o=P.get(f);if(!o)continue;let w=o.filter((I)=>!X.has(I));if(!w.length)continue;let A=w[0];if(w.length>1){let I=k(j,$),u=Math.abs(k(A,_)-I);for(let N=1;N<w.length;N++){let q=Math.abs(k(w[N],_)-I);if(q<u)u=q,A=w[N]}}z.push({oldName:A.name,newName:j.name,filePath:O,kind:D}),W.add(j),X.add(A)}}}let U=z.filter((O)=>!O.oldName.includes("."));for(let O of U){let H=`${O.oldName}.`,L=`${O.newName}.`,D=Q.filter((B)=>B.filePath===O.filePath&&B.name.startsWith(H)&&!X.has(B)),K=J.filter((B)=>B.filePath===O.filePath&&B.name.startsWith(L)&&!W.has(B));for(let B of D){let T=B.name.slice(H.length),k=K.find((P)=>P.name.slice(L.length)===T);if(k)z.push({oldName:B.name,newName:k.name,filePath:O.filePath,kind:B.kind}),W.add(k),X.add(B)}}return{renamed:z,added:J.filter((O)=>!W.has(O)),removed:Q.filter((O)=>!X.has(O))}}var DJ=100,z0=50;class C${opts;logger;callbacks=new Set;indexingLock=!1;pendingEvents=[];debounceTimer=null;currentIndexing=null;pendingFullIndex=!1;pendingFullIndexWaiters=[];tsconfigPathsRaw;boundariesRefresh=null;lastPruneAt=0;constructor(_){this.opts=_,this.logger=_.logger??console,this.tsconfigPathsRaw=b_(_.projectRoot)}get tsconfigPaths(){return this.tsconfigPathsRaw}fullIndex(){return this.startIndex(void 0,!0)}incrementalIndex(_){return this.startIndex(_,!1)}onIndexed(_){return this.callbacks.add(_),()=>this.callbacks.delete(_)}handleWatcherEvent(_){if(_.filePath.endsWith("tsconfig.json")){d_(this.opts.projectRoot),this.tsconfigPathsRaw=b_(this.opts.projectRoot),this.fullIndex().catch(($)=>{this.logger.error("[IndexCoordinator] fullIndex failed after tsconfig change:",$)});return}if(_.filePath.endsWith("package.json")){let $=this.opts.discoverProjectsFn??i_;this.boundariesRefresh=$(this.opts.projectRoot).then((J)=>{this.opts.boundaries=J,this.opts.onBoundariesChanged?.(J)}),this.fullIndex().catch((J)=>{this.logger.error("[IndexCoordinator] fullIndex failed after package.json change:",J)});return}if(this.pendingEvents.push(_),this.debounceTimer===null)this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.flushPending()},DJ)}async shutdown(){if(this.debounceTimer!==null)clearTimeout(this.debounceTimer),this.debounceTimer=null;if(this.currentIndexing)await this.currentIndexing}startIndex(_,$){if(this.indexingLock){if($)return this.pendingFullIndex=!0,new Promise((Q,z)=>{this.pendingFullIndexWaiters.push({resolve:Q,reject:z})});return this.currentIndexing}this.indexingLock=!0;let J=this.doIndex(_,$).then((Q)=>{return this.fireCallbacks(Q),Q}).finally(()=>{if(this.indexingLock=!1,this.currentIndexing=null,this.pendingFullIndex){this.pendingFullIndex=!1;let Q=this.pendingFullIndexWaiters.splice(0);this.startIndex(void 0,!0).then((z)=>{for(let Y of Q)Y.resolve(z)}).catch((z)=>{for(let Y of Q)Y.reject(z)})}else if(this.pendingEvents.length>0){let Q=this.pendingEvents.splice(0);this.startIndex(Q,!1).catch((z)=>this.logger.error("[IndexCoordinator] incremental drain error",z))}});return this.currentIndexing=J,J}async doIndex(_,$){let J=Date.now(),{fileRepo:Q,symbolRepo:z,relationRepo:Y,dbConnection:Z}=this.opts;if(this.boundariesRefresh)await this.boundariesRefresh,this.boundariesRefresh=null;let W,X;if(_!==void 0)W=_.filter((M)=>M.eventType==="create"||M.eventType==="change").map((M)=>({filePath:M.filePath,contentHash:"",mtimeMs:0,size:0})),X=_.filter((M)=>M.eventType==="delete").map((M)=>M.filePath);else{let M=new Map;for(let S of this.opts.boundaries)for(let[R,m]of Q.getFilesMap(S.project))M.set(R,m);let C=await a$({projectRoot:this.opts.projectRoot,extensions:this.opts.extensions,ignorePatterns:this.opts.ignorePatterns,fileRepo:{getFilesMap:()=>M}});W=C.changed,X=C.deleted}let U=await this.tsconfigPathsRaw??void 0,O=new Map;for(let M of X){let C=t(M,this.opts.boundaries),S=z.getFileSymbols(C,M);O.set(M,S)}let H=crypto.randomUUID(),L=new Map,D=new Map,K=(M)=>({name:M.name,filePath:M.filePath,kind:M.kind,fingerprint:M.fingerprint,structuralFingerprint:M.structuralFingerprint??null,startLine:M.startLine,isExported:M.isExported??0});if($)for(let M of this.opts.boundaries)for(let C of Q.getAllFiles(M.project))for(let S of z.getFileSymbols(M.project,C.filePath))L.set(`${S.filePath}::${S.name}`,K(S));else{for(let M of W){let C=t(M.filePath,this.opts.boundaries);for(let S of z.getFileSymbols(C,M.filePath))L.set(`${S.filePath}::${S.name}`,K(S))}for(let[,M]of O)for(let C of M)L.set(`${C.filePath}::${C.name}`,K(C))}let B=(M)=>`${M.type}|${M.srcFilePath}|${M.dstFilePath??""}|${M.srcSymbolName??""}|${M.dstSymbolName??""}|${O_(M.metaJson??"")}`,T=new Map;if($)for(let M of this.opts.boundaries)for(let C of Q.getAllFiles(M.project))for(let S of Y.getOutgoing(M.project,C.filePath))T.set(B(S),S);else{for(let M of W){let C=t(M.filePath,this.opts.boundaries);for(let S of Y.getOutgoing(C,M.filePath))T.set(B(S),S)}for(let M of X){let C=t(M,this.opts.boundaries);for(let S of Y.getOutgoing(C,M))T.set(B(S),S)}}let{annotationRepo:k,changelogRepo:P}=this.opts,j=()=>{for(let M of X){let C=t(M,this.opts.boundaries);if(z.deleteFileSymbols(C,M),Y.deleteFileRelations(C,M),Y.deleteIncomingRelations(C,M),k)k.deleteFileAnnotations(C,M);Q.deleteFile(C,M)}},f=0,o=async()=>{let{projectRoot:M,boundaries:C}=this.opts,{parseCache:S}=this.opts,R=0,m=0,g=0,n=[],v=[];for(let y of W)try{let c=q_(M,y.filePath),K_=Bun.file(c),N_=await K_.text(),b$=y.contentHash||O_(N_),y$=t(y.filePath,C);Q.upsertFile({project:y$,filePath:y.filePath,mtimeMs:K_.lastModified,size:K_.size,contentHash:b$,updatedAt:new Date().toISOString(),lineCount:N_.split(`
6
6
  `).length});let z$=(this.opts.parseSourceFn??y_)(c,N_);if(Q0(z$))throw z$.data;let g1=z$;v.push({filePath:y.filePath,text:N_,contentHash:b$,parsed:g1,project:y$})}catch(c){this.logger.error(`[IndexCoordinator] Failed to prepare ${y.filePath}:`,c),n.push(y.filePath)}let p=new Set;for(let y of C)for(let[c]of Q.getFilesMap(y.project))p.add(`${y.project}::${c}`);return Z.transaction(()=>{for(let y of v){if(K$({parsed:y.parsed,project:y.project,filePath:y.filePath,contentHash:y.contentHash,symbolRepo:z}),m+=B$({ast:y.parsed.program,project:y.project,filePath:y.filePath,relationRepo:Y,projectRoot:M,tsconfigPaths:U,knownFiles:p,boundaries:C,module:y.parsed.module}),k)g+=I$({parsed:y.parsed,project:y.project,filePath:y.filePath,annotationRepo:k});S.set(y.filePath,y.parsed),R+=z.getFileSymbols(y.project,y.filePath).length}}),{symbols:R,relations:m,annotations:g,failedFiles:n}},w=0,A=0,I=[];if($){let{projectRoot:M,boundaries:C}=this.opts,{parseCache:S}=this.opts,R=[];for(let g=0;g<W.length;g+=z0){let n=W.slice(g,g+z0),v=await Promise.allSettled(n.map(async(p)=>{let y=q_(M,p.filePath),c=Bun.file(y),K_=await c.text(),N_=p.contentHash||O_(K_);return{filePath:p.filePath,text:K_,contentHash:N_,mtimeMs:c.lastModified,size:c.size}}));for(let p=0;p<v.length;p++){let y=v[p];if(y.status==="fulfilled")R.push(y.value);else this.logger.error("[IndexCoordinator] Failed to pre-read file:",y.reason),I.push(n[p].filePath)}}let m=[];Z.transaction(()=>{for(let v of R){let p=t(v.filePath,C);Q.deleteFile(p,v.filePath)}for(let v of X){let p=t(v,C);if(z.deleteFileSymbols(p,v),Y.deleteFileRelations(p,v),Y.deleteIncomingRelations(p,v),k)k.deleteFileAnnotations(p,v);Q.deleteFile(p,v)}for(let v of R){let p=t(v.filePath,C);Q.upsertFile({project:p,filePath:v.filePath,mtimeMs:v.mtimeMs,size:v.size,contentHash:v.contentHash,updatedAt:new Date().toISOString(),lineCount:v.text.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipbul/gildash",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "TypeScript code indexing and dependency graph engine for Bun",
5
5
  "license": "MIT",
6
6
  "repository": {