@zipbul/gildash 0.26.0 → 0.26.1
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/README.ko.md +63 -9
- package/README.md +156 -28
- package/dist/index.js +1 -1
- package/dist/src/extractor/types.d.ts +20 -1
- package/dist/src/search/relation-search.d.ts +8 -1
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -260,7 +260,8 @@ try {
|
|
|
260
260
|
| `hasCycle(project?)` | `Promise<boolean>` | 순환 의존성 감지 |
|
|
261
261
|
| `getCyclePaths(project?, opts?)` | `Promise<string[][]>` | 모든 순환 경로 (Tarjan SCC + Johnson's). `opts.maxCycles`로 개수 제한 가능. |
|
|
262
262
|
| `getImportGraph(project?)` | `Promise<Map>` | 전체 인접 리스트 |
|
|
263
|
-
| `getTransitiveDependencies(filePath)` | `Promise<string[]>` | 전방 전이적 BFS |
|
|
263
|
+
| `getTransitiveDependencies(filePath)` | `Promise<string[]>` | 전방 전이적 BFS (이 파일이 의존하는 파일들) |
|
|
264
|
+
| `getTransitiveDependents(filePath)` | `Promise<string[]>` | 역방향 전이적 BFS (이 파일에 의존하는 파일들) |
|
|
264
265
|
|
|
265
266
|
### 분석
|
|
266
267
|
|
|
@@ -277,12 +278,40 @@ try {
|
|
|
277
278
|
|
|
278
279
|
`semantic: true`로 열어야 사용 가능.
|
|
279
280
|
|
|
281
|
+
#### 심볼 이름 기반
|
|
282
|
+
|
|
280
283
|
| 메서드 | 반환 타입 | 설명 |
|
|
281
284
|
|--------|-----------|------|
|
|
282
285
|
| `getResolvedType(name, filePath)` | `ResolvedType \| null` | tsc TypeChecker로 resolved type 조회 |
|
|
283
286
|
| `getSemanticReferences(name, filePath)` | `SemanticReference[]` | 심볼의 모든 참조 위치 |
|
|
284
287
|
| `getImplementations(name, filePath)` | `Implementation[]` | 인터페이스/추상 클래스 구현체 |
|
|
285
288
|
| `getSemanticModuleInterface(filePath)` | `SemanticModuleInterface` | 모듈 export 목록 + resolved type |
|
|
289
|
+
| `isTypeAssignableTo(opts)` | `boolean` | 두 심볼 타입 간 할당 가능성 |
|
|
290
|
+
| `isTypeAssignableToType(opts)` | `boolean` | 심볼 타입을 임의 타입 문자열에 할당 가능한지 |
|
|
291
|
+
|
|
292
|
+
#### 라인/컬럼 또는 바이트 위치 기반
|
|
293
|
+
|
|
294
|
+
| 메서드 | 반환 타입 | 설명 |
|
|
295
|
+
|--------|-----------|------|
|
|
296
|
+
| `getResolvedTypeAt(filePath, line, column)` | `ResolvedType \| null` | 라인/컬럼 위치의 resolved type |
|
|
297
|
+
| `isTypeAssignableToAt(opts)` | `boolean` | 두 라인/컬럼 위치 간 할당 가능성 |
|
|
298
|
+
| `getResolvedTypeAtPosition(filePath, position)` | `ResolvedType \| null` | 바이트 위치의 resolved type |
|
|
299
|
+
| `getResolvedTypesAtPositions(filePath, positions)` | `Map<number, ResolvedType>` | 여러 위치의 resolved type 일괄 조회 |
|
|
300
|
+
| `getSemanticReferencesAtPosition(filePath, position)` | `SemanticReference[]` | 바이트 위치 심볼의 참조 |
|
|
301
|
+
| `getImplementationsAtPosition(filePath, position)` | `Implementation[]` | 바이트 위치 심볼의 구현체 |
|
|
302
|
+
| `isTypeAssignableToAtPosition(opts)` | `boolean` | 두 바이트 위치 간 할당 가능성 |
|
|
303
|
+
| `isTypeAssignableToTypeAtPositions(opts)` | `boolean` | 위치 → 임의 타입 문자열 할당 가능성 |
|
|
304
|
+
|
|
305
|
+
#### 파일 단위 / 유틸 / 진단
|
|
306
|
+
|
|
307
|
+
| 메서드 | 반환 타입 | 설명 |
|
|
308
|
+
|--------|-----------|------|
|
|
309
|
+
| `getFileTypes(filePath)` | `Map<number, ResolvedType>` | 파일 내 모든 심볼의 resolved type |
|
|
310
|
+
| `getSymbolNode(filePath, position)` | `SymbolNode \| null` | 위치의 심볼 그래프 노드 |
|
|
311
|
+
| `getBaseTypes(filePath, position)` | `ResolvedType[] \| null` | 위치 심볼의 직접 베이스 타입들 |
|
|
312
|
+
| `lineColumnToPosition(filePath, line, column)` | `number \| null` | 라인/컬럼 → 바이트 오프셋 변환 |
|
|
313
|
+
| `findNamePosition(filePath, declarationPos, name)` | `number \| null` | 선언 내 식별자의 바이트 위치 탐색 |
|
|
314
|
+
| `getSemanticDiagnostics(filePath, opts?)` | `SemanticDiagnostic[]` | 파일의 tsc 진단 |
|
|
286
315
|
|
|
287
316
|
`getFullSymbol()`은 semantic 활성 시 자동으로 `resolvedType` 필드를 보강합니다.
|
|
288
317
|
`searchSymbols({ resolvedType })`로 resolved type 문자열 기반 필터링이 가능합니다.
|
|
@@ -331,23 +360,37 @@ interface SymbolSearchQuery {
|
|
|
331
360
|
filePath?: string; // 파일 경로 필터
|
|
332
361
|
isExported?: boolean; // export 여부
|
|
333
362
|
project?: string; // 프로젝트 이름
|
|
334
|
-
limit?: number; //
|
|
363
|
+
limit?: number; // 미지정 시 limit 미적용 (전체 결과)
|
|
335
364
|
decorator?: string; // 데코레이터 이름 필터
|
|
336
365
|
regex?: string; // 정규식 패턴 필터
|
|
366
|
+
resolvedType?: string; // 시맨틱 레이어 필터 (`semantic: true` 필요)
|
|
337
367
|
}
|
|
338
368
|
|
|
339
369
|
interface CodeRelation {
|
|
340
370
|
type: 'imports' | 'type-references' | 're-exports' | 'calls' | 'extends' | 'implements';
|
|
341
371
|
srcFilePath: string;
|
|
342
372
|
srcSymbolName: string | null;
|
|
343
|
-
|
|
373
|
+
/** 외부 패키지 / 미해상 import 의 경우 `null`. */
|
|
374
|
+
dstFilePath: string | null;
|
|
344
375
|
dstSymbolName: string | null;
|
|
345
376
|
meta?: Record<string, unknown>;
|
|
377
|
+
/**
|
|
378
|
+
* 소스에 적힌 모듈 specifier 원문(`'./foo'`, `'@zipbul/core'`, `'lodash'`).
|
|
379
|
+
* 모듈 source 가 있는 모든 관계(`'imports'`, `'re-exports'`, `'type-references'`,
|
|
380
|
+
* 동적 `import()`, `require()`)에서 `dstFilePath` 해상 여부와 무관하게 항상 보존.
|
|
381
|
+
* `'calls'` / `'extends'` / `'implements'` 관계에서만 부재.
|
|
382
|
+
*/
|
|
383
|
+
specifier?: string;
|
|
346
384
|
}
|
|
347
385
|
|
|
348
|
-
/** 목적지 프로젝트
|
|
349
|
-
interface StoredCodeRelation extends CodeRelation {
|
|
350
|
-
|
|
386
|
+
/** 목적지 프로젝트 식별자와 외부 플래그가 추가된 CodeRelation. */
|
|
387
|
+
interface StoredCodeRelation extends Omit<CodeRelation, 'specifier'> {
|
|
388
|
+
/** 목적지 프로젝트, 또는 cross-project / 미해상 시 `null`. */
|
|
389
|
+
dstProject: string | null;
|
|
390
|
+
/** 외부 패키지(bare specifier) 여부. */
|
|
391
|
+
isExternal: boolean;
|
|
392
|
+
/** 원문 specifier (`CodeRelation.specifier` 참고); `'calls'` / `'extends'` / `'implements'` 에서만 `null`. */
|
|
393
|
+
specifier: string | null;
|
|
351
394
|
}
|
|
352
395
|
|
|
353
396
|
interface IndexResult {
|
|
@@ -355,14 +398,25 @@ interface IndexResult {
|
|
|
355
398
|
removedFiles: number;
|
|
356
399
|
totalSymbols: number;
|
|
357
400
|
totalRelations: number;
|
|
401
|
+
totalAnnotations: number;
|
|
358
402
|
durationMs: number;
|
|
359
403
|
changedFiles: string[];
|
|
360
404
|
deletedFiles: string[];
|
|
361
405
|
failedFiles: string[];
|
|
406
|
+
/** 이전 인덱스 상태 대비 심볼 단위 diff. */
|
|
362
407
|
changedSymbols: {
|
|
363
|
-
added: Array<{ name: string; filePath: string; kind: string }>;
|
|
364
|
-
modified: Array<{ name: string; filePath: string; kind: string }>;
|
|
365
|
-
removed: Array<{ name: string; filePath: string; kind: string }>;
|
|
408
|
+
added: Array<{ name: string; filePath: string; kind: string; isExported: boolean }>;
|
|
409
|
+
modified: Array<{ name: string; filePath: string; kind: string; isExported: boolean }>;
|
|
410
|
+
removed: Array<{ name: string; filePath: string; kind: string; isExported: boolean }>;
|
|
411
|
+
};
|
|
412
|
+
/** 이름이 바뀐 심볼 (구조적 fingerprint 매칭). */
|
|
413
|
+
renamedSymbols: Array<{ oldName: string; newName: string; filePath: string; kind: string; isExported: boolean }>;
|
|
414
|
+
/** 다른 파일로 이동한 심볼 (incremental 만; fingerprint 매칭). */
|
|
415
|
+
movedSymbols: Array<{ name: string; oldFilePath: string; newFilePath: string; kind: string; isExported: boolean }>;
|
|
416
|
+
/** 이전 인덱스 상태 대비 관계 단위 diff. */
|
|
417
|
+
changedRelations: {
|
|
418
|
+
added: Array<{ type: string; srcFilePath: string; dstFilePath: string | null; srcSymbolName: string | null; dstSymbolName: string | null; dstProject: string | null; metaJson: string | null }>;
|
|
419
|
+
removed: Array<{ type: string; srcFilePath: string; dstFilePath: string | null; srcSymbolName: string | null; dstSymbolName: string | null; dstProject: string | null; metaJson: string | null }>;
|
|
366
420
|
};
|
|
367
421
|
}
|
|
368
422
|
|
package/README.md
CHANGED
|
@@ -300,7 +300,8 @@ Returns `Promise<Gildash>`. Throws `GildashError` on failure.
|
|
|
300
300
|
| `hasCycle(project?)` | `Promise<boolean>` | Circular dependency check |
|
|
301
301
|
| `getCyclePaths(project?, opts?)` | `Promise<string[][]>` | All cycle paths (Tarjan SCC + Johnson's). `opts.maxCycles` limits results. |
|
|
302
302
|
| `getImportGraph(project?)` | `Promise<Map>` | Full adjacency list |
|
|
303
|
-
| `getTransitiveDependencies(filePath)` | `Promise<string[]>` | Forward transitive BFS |
|
|
303
|
+
| `getTransitiveDependencies(filePath)` | `Promise<string[]>` | Forward transitive BFS (files this depends on) |
|
|
304
|
+
| `getTransitiveDependents(filePath)` | `Promise<string[]>` | Reverse transitive BFS (files that depend on this) |
|
|
304
305
|
|
|
305
306
|
### Analysis
|
|
306
307
|
|
|
@@ -330,12 +331,40 @@ Returns `Promise<Gildash>`. Throws `GildashError` on failure.
|
|
|
330
331
|
|
|
331
332
|
Requires `semantic: true` at open time.
|
|
332
333
|
|
|
334
|
+
#### By symbol name
|
|
335
|
+
|
|
333
336
|
| Method | Returns | Description |
|
|
334
337
|
|--------|---------|-------------|
|
|
335
338
|
| `getResolvedType(name, filePath)` | `ResolvedType \| null` | Resolved type via tsc TypeChecker |
|
|
336
339
|
| `getSemanticReferences(name, filePath)` | `SemanticReference[]` | All references to a symbol |
|
|
337
340
|
| `getImplementations(name, filePath)` | `Implementation[]` | Interface / abstract class implementations |
|
|
338
341
|
| `getSemanticModuleInterface(filePath)` | `SemanticModuleInterface` | Module exports with resolved types |
|
|
342
|
+
| `isTypeAssignableTo(opts)` | `boolean` | Whether one symbol's type is assignable to another's |
|
|
343
|
+
| `isTypeAssignableToType(opts)` | `boolean` | Whether a symbol's type is assignable to an arbitrary type string |
|
|
344
|
+
|
|
345
|
+
#### By line/column or byte position
|
|
346
|
+
|
|
347
|
+
| Method | Returns | Description |
|
|
348
|
+
|--------|---------|-------------|
|
|
349
|
+
| `getResolvedTypeAt(filePath, line, column)` | `ResolvedType \| null` | Resolved type at a line/column |
|
|
350
|
+
| `isTypeAssignableToAt(opts)` | `boolean` | Assignability check between two line/column positions |
|
|
351
|
+
| `getResolvedTypeAtPosition(filePath, position)` | `ResolvedType \| null` | Resolved type at a byte position |
|
|
352
|
+
| `getResolvedTypesAtPositions(filePath, positions)` | `Map<number, ResolvedType>` | Batch type lookup across positions |
|
|
353
|
+
| `getSemanticReferencesAtPosition(filePath, position)` | `SemanticReference[]` | References to the symbol at a position |
|
|
354
|
+
| `getImplementationsAtPosition(filePath, position)` | `Implementation[]` | Implementations of the symbol at a position |
|
|
355
|
+
| `isTypeAssignableToAtPosition(opts)` | `boolean` | Assignability check between two byte positions |
|
|
356
|
+
| `isTypeAssignableToTypeAtPositions(opts)` | `boolean` | Assignability check from a position to an arbitrary type string |
|
|
357
|
+
|
|
358
|
+
#### File-level / utilities / diagnostics
|
|
359
|
+
|
|
360
|
+
| Method | Returns | Description |
|
|
361
|
+
|--------|---------|-------------|
|
|
362
|
+
| `getFileTypes(filePath)` | `Map<number, ResolvedType>` | All resolved types for symbols in a file |
|
|
363
|
+
| `getSymbolNode(filePath, position)` | `SymbolNode \| null` | Underlying symbol-graph node at a position |
|
|
364
|
+
| `getBaseTypes(filePath, position)` | `ResolvedType[] \| null` | Direct base types of the symbol at a position |
|
|
365
|
+
| `lineColumnToPosition(filePath, line, column)` | `number \| null` | Convert line/column to byte offset |
|
|
366
|
+
| `findNamePosition(filePath, declarationPos, name)` | `number \| null` | Locate an identifier's byte offset within a declaration |
|
|
367
|
+
| `getSemanticDiagnostics(filePath, opts?)` | `SemanticDiagnostic[]` | tsc diagnostics for a file |
|
|
339
368
|
|
|
340
369
|
`getFullSymbol()` automatically enriches the result with a `resolvedType` field when semantic is enabled.
|
|
341
370
|
`searchSymbols({ resolvedType })` filters symbols by their resolved type string.
|
|
@@ -378,70 +407,131 @@ Requires `semantic: true` at open time.
|
|
|
378
407
|
interface SymbolSearchQuery {
|
|
379
408
|
text?: string; // FTS5 full-text query
|
|
380
409
|
exact?: boolean; // exact name match (not prefix)
|
|
381
|
-
kind?: SymbolKind; // 'function' | 'method' | 'class' | 'variable' | 'type' | 'interface' | 'enum' | 'property'
|
|
410
|
+
kind?: SymbolKind; // 'function' | 'method' | 'class' | 'variable' | 'type' | 'interface' | 'enum' | 'namespace' | 'property'
|
|
382
411
|
filePath?: string;
|
|
383
412
|
isExported?: boolean;
|
|
384
413
|
project?: string;
|
|
385
|
-
limit?: number; //
|
|
414
|
+
limit?: number; // when omitted, no limit is applied
|
|
386
415
|
decorator?: string; // e.g. 'Injectable'
|
|
387
416
|
regex?: string; // regex applied to symbol name
|
|
417
|
+
resolvedType?: string; // semantic-layer filter; requires `semantic: true`
|
|
388
418
|
}
|
|
389
419
|
|
|
390
420
|
interface SymbolSearchResult {
|
|
391
421
|
id: number;
|
|
392
422
|
filePath: string;
|
|
393
423
|
kind: SymbolKind;
|
|
394
|
-
name: string;
|
|
424
|
+
name: string; // qualified for members, e.g. "ClassName.methodName"
|
|
425
|
+
memberName: string | null; // unqualified member name, or null for top-level
|
|
395
426
|
span: { start: { line: number; column: number }; end: { line: number; column: number } };
|
|
396
427
|
isExported: boolean;
|
|
397
428
|
signature: string | null;
|
|
398
429
|
fingerprint: string | null;
|
|
399
|
-
detail:
|
|
430
|
+
detail: SymbolDetail; // typed; see below
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
interface SymbolDetail {
|
|
434
|
+
parameters?: Parameter[];
|
|
435
|
+
returnType?: string;
|
|
436
|
+
heritage?: Array<{ kind: 'extends' | 'implements'; name: string; typeArguments?: string[] }>;
|
|
437
|
+
decorators?: Decorator[];
|
|
438
|
+
typeParameters?: string[];
|
|
439
|
+
modifiers?: Modifier[];
|
|
440
|
+
initializer?: ExpressionValue;
|
|
441
|
+
members?: Array<{
|
|
442
|
+
name: string;
|
|
443
|
+
kind: string;
|
|
444
|
+
type?: string;
|
|
445
|
+
visibility?: string;
|
|
446
|
+
isStatic?: boolean;
|
|
447
|
+
isReadonly?: boolean;
|
|
448
|
+
initializer?: ExpressionValue;
|
|
449
|
+
decorators?: Decorator[];
|
|
450
|
+
}>;
|
|
451
|
+
jsDoc?: JsDocBlock;
|
|
400
452
|
}
|
|
401
453
|
|
|
454
|
+
interface Parameter {
|
|
455
|
+
name: string;
|
|
456
|
+
type?: string; // type annotation as source text
|
|
457
|
+
typeImportSource?: string; // import specifier when the type is imported
|
|
458
|
+
isOptional: boolean;
|
|
459
|
+
defaultValue?: string;
|
|
460
|
+
decorators?: Decorator[];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
interface Decorator {
|
|
464
|
+
name: string;
|
|
465
|
+
arguments?: ExpressionValue[]; // structured decorator call arguments
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
type Modifier =
|
|
469
|
+
| 'async' | 'static' | 'abstract' | 'readonly'
|
|
470
|
+
| 'private' | 'protected' | 'public'
|
|
471
|
+
| 'override' | 'declare' | 'const'
|
|
472
|
+
| 'accessor'; // TC39 auto-accessor
|
|
473
|
+
|
|
402
474
|
interface RelationSearchQuery {
|
|
403
475
|
srcFilePath?: string;
|
|
404
476
|
srcSymbolName?: string;
|
|
405
477
|
dstFilePath?: string;
|
|
406
478
|
dstSymbolName?: string;
|
|
407
|
-
dstProject?: string;
|
|
479
|
+
dstProject?: string; // filter by destination project
|
|
480
|
+
/** Glob (Bun.Glob) for source file path; mutually exclusive with srcFilePath. */
|
|
481
|
+
srcFilePathPattern?: string;
|
|
482
|
+
/** Glob (Bun.Glob) for destination file path; mutually exclusive with dstFilePath. */
|
|
483
|
+
dstFilePathPattern?: string;
|
|
408
484
|
type?: 'imports' | 'type-references' | 're-exports' | 'calls' | 'extends' | 'implements';
|
|
409
485
|
project?: string;
|
|
410
|
-
|
|
486
|
+
/** Filter by raw import specifier (e.g. `'./foo'`, `'lodash'`). */
|
|
487
|
+
specifier?: string;
|
|
488
|
+
/** Filter by external (bare specifier) flag. */
|
|
489
|
+
isExternal?: boolean;
|
|
490
|
+
limit?: number; // when omitted, no limit is applied
|
|
411
491
|
}
|
|
412
492
|
|
|
413
493
|
interface CodeRelation {
|
|
414
494
|
type: 'imports' | 'type-references' | 're-exports' | 'calls' | 'extends' | 'implements';
|
|
415
495
|
srcFilePath: string;
|
|
416
496
|
srcSymbolName: string | null;
|
|
417
|
-
|
|
497
|
+
/** `null` when the import target could not be resolved (external package, missing file). */
|
|
498
|
+
dstFilePath: string | null;
|
|
418
499
|
dstSymbolName: string | null;
|
|
419
500
|
metaJson?: string;
|
|
420
501
|
meta?: Record<string, unknown>; // auto-parsed from metaJson
|
|
502
|
+
/**
|
|
503
|
+
* Verbatim module specifier text as written in the source (`'./foo'`,
|
|
504
|
+
* `'@zipbul/core'`, `'lodash'`). Always present on module-source-bearing
|
|
505
|
+
* relations (`'imports'`, `'re-exports'`, `'type-references'`, dynamic
|
|
506
|
+
* `import()`, `require()`) regardless of `dstFilePath` resolution.
|
|
507
|
+
* Absent on `'calls'` / `'extends'` / `'implements'`.
|
|
508
|
+
*/
|
|
509
|
+
specifier?: string;
|
|
421
510
|
}
|
|
422
511
|
|
|
423
|
-
/** CodeRelation enriched with
|
|
424
|
-
interface StoredCodeRelation extends CodeRelation {
|
|
425
|
-
|
|
512
|
+
/** CodeRelation enriched with destination-project identifier and external flag. */
|
|
513
|
+
interface StoredCodeRelation extends Omit<CodeRelation, 'specifier'> {
|
|
514
|
+
/** Destination project, or `null` for cross-project / unresolved relations. */
|
|
515
|
+
dstProject: string | null;
|
|
516
|
+
/** Whether the relation targets an external (bare-specifier) package. */
|
|
517
|
+
isExternal: boolean;
|
|
518
|
+
/** Verbatim source specifier (see {@link CodeRelation.specifier}); `null` only on `'calls'` / `'extends'` / `'implements'`. */
|
|
519
|
+
specifier: string | null;
|
|
426
520
|
}
|
|
427
521
|
|
|
428
522
|
// ── Analysis ────────────────────────────────────────────────────────────
|
|
429
523
|
|
|
430
524
|
interface FullSymbol extends SymbolSearchResult {
|
|
431
|
-
members?:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
type?: string;
|
|
435
|
-
visibility?: string;
|
|
436
|
-
isStatic?: boolean;
|
|
437
|
-
isReadonly?: boolean;
|
|
438
|
-
}>;
|
|
439
|
-
jsDoc?: string;
|
|
440
|
-
parameters?: string;
|
|
525
|
+
members?: SymbolDetail['members'];
|
|
526
|
+
jsDoc?: JsDocBlock;
|
|
527
|
+
parameters?: Parameter[];
|
|
441
528
|
returnType?: string;
|
|
442
|
-
heritage?:
|
|
443
|
-
decorators?:
|
|
444
|
-
typeParameters?: string;
|
|
529
|
+
heritage?: SymbolDetail['heritage'];
|
|
530
|
+
decorators?: Decorator[];
|
|
531
|
+
typeParameters?: string[];
|
|
532
|
+
initializer?: ExpressionValue;
|
|
533
|
+
/** Resolved type from the Semantic Layer (available when `semantic: true`). */
|
|
534
|
+
resolvedType?: ResolvedType;
|
|
445
535
|
}
|
|
446
536
|
|
|
447
537
|
interface FileStats {
|
|
@@ -511,10 +601,48 @@ interface IndexResult {
|
|
|
511
601
|
changedFiles: string[];
|
|
512
602
|
deletedFiles: string[];
|
|
513
603
|
failedFiles: string[];
|
|
604
|
+
/** Symbol-level diff against previous index state. */
|
|
514
605
|
changedSymbols: {
|
|
515
|
-
added: Array<{ name: string; filePath: string; kind: string }>;
|
|
516
|
-
modified: Array<{ name: string; filePath: string; kind: string }>;
|
|
517
|
-
removed: Array<{ name: string; filePath: string; kind: string }>;
|
|
606
|
+
added: Array<{ name: string; filePath: string; kind: string; isExported: boolean }>;
|
|
607
|
+
modified: Array<{ name: string; filePath: string; kind: string; isExported: boolean }>;
|
|
608
|
+
removed: Array<{ name: string; filePath: string; kind: string; isExported: boolean }>;
|
|
609
|
+
};
|
|
610
|
+
/** Symbols renamed (matched via structural fingerprint). */
|
|
611
|
+
renamedSymbols: Array<{
|
|
612
|
+
oldName: string;
|
|
613
|
+
newName: string;
|
|
614
|
+
filePath: string;
|
|
615
|
+
kind: string;
|
|
616
|
+
isExported: boolean;
|
|
617
|
+
}>;
|
|
618
|
+
/** Symbols that moved to a different file (incremental only; matched via fingerprint). */
|
|
619
|
+
movedSymbols: Array<{
|
|
620
|
+
name: string;
|
|
621
|
+
oldFilePath: string;
|
|
622
|
+
newFilePath: string;
|
|
623
|
+
kind: string;
|
|
624
|
+
isExported: boolean;
|
|
625
|
+
}>;
|
|
626
|
+
/** Relation-level diff against previous index state. */
|
|
627
|
+
changedRelations: {
|
|
628
|
+
added: Array<{
|
|
629
|
+
type: string;
|
|
630
|
+
srcFilePath: string;
|
|
631
|
+
dstFilePath: string | null;
|
|
632
|
+
srcSymbolName: string | null;
|
|
633
|
+
dstSymbolName: string | null;
|
|
634
|
+
dstProject: string | null;
|
|
635
|
+
metaJson: string | null;
|
|
636
|
+
}>;
|
|
637
|
+
removed: Array<{
|
|
638
|
+
type: string;
|
|
639
|
+
srcFilePath: string;
|
|
640
|
+
dstFilePath: string | null;
|
|
641
|
+
srcSymbolName: string | null;
|
|
642
|
+
dstSymbolName: string | null;
|
|
643
|
+
dstProject: string | null;
|
|
644
|
+
metaJson: string | null;
|
|
645
|
+
}>;
|
|
518
646
|
};
|
|
519
647
|
}
|
|
520
648
|
|
|
@@ -537,7 +665,7 @@ interface AnnotationSearchQuery {
|
|
|
537
665
|
symbolName?: string;
|
|
538
666
|
source?: 'jsdoc' | 'line' | 'block';
|
|
539
667
|
project?: string;
|
|
540
|
-
limit?: number; //
|
|
668
|
+
limit?: number; // when omitted, no limit is applied
|
|
541
669
|
}
|
|
542
670
|
|
|
543
671
|
interface AnnotationSearchResult {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var F$=Object.defineProperty;var g$=(_)=>_;function j$(_,$){this[_]=g$.bind(null,$)}var k$=(_,$)=>{for(var Q in $)F$(_,Q,{get:$[Q],enumerable:!0,configurable:!0,set:j$.bind($,Q)})};var x0=import.meta.require;import{isErr as p_}from"@zipbul/result";import v_ from"path";import{existsSync as JJ}from"fs";import{err as h0,isErr as f$}from"@zipbul/result";import{Database as y$}from"bun:sqlite";import{mkdirSync as x$,unlinkSync as n0,existsSync as m0}from"fs";import{dirname as h$,join as d0}from"path";import{drizzle as n$}from"drizzle-orm/bun-sqlite";import{migrate as m$}from"drizzle-orm/bun-sqlite/migrator";class O extends Error{type;constructor(_,$,Q){super($,Q);this.type=_;this.name="GildashError"}}var I_=".gildash",l_="gildash.db";var V0={};k$(V0,{watcherOwner:()=>P$,symbols:()=>f,symbolChangelog:()=>t,relations:()=>k,files:()=>s,annotations:()=>z_});import{sql as u$}from"drizzle-orm";import{sqliteTable as G_,text as b,integer as a,real as E$,index as $_,primaryKey as v$,foreignKey as X0,check as b$}from"drizzle-orm/sqlite-core";var s=G_("files",{project:b("project").notNull(),filePath:b("file_path").notNull(),mtimeMs:E$("mtime_ms").notNull(),size:a("size").notNull(),contentHash:b("content_hash").notNull(),updatedAt:b("updated_at").notNull(),lineCount:a("line_count")},(_)=>[v$({columns:[_.project,_.filePath]})]),f=G_("symbols",{id:a("id").primaryKey({autoIncrement:!0}),project:b("project").notNull(),filePath:b("file_path").notNull(),kind:b("kind").notNull(),name:b("name").notNull(),startLine:a("start_line").notNull(),startColumn:a("start_column").notNull(),endLine:a("end_line").notNull(),endColumn:a("end_column").notNull(),isExported:a("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")},(_)=>[$_("idx_symbols_project_file").on(_.project,_.filePath),$_("idx_symbols_project_kind").on(_.project,_.kind),$_("idx_symbols_project_name").on(_.project,_.name),$_("idx_symbols_fingerprint").on(_.project,_.fingerprint),X0({columns:[_.project,_.filePath],foreignColumns:[s.project,s.filePath]}).onDelete("cascade")]),k=G_("relations",{id:a("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:a("is_external").notNull().default(0)},(_)=>[$_("idx_relations_src").on(_.project,_.srcFilePath),$_("idx_relations_dst").on(_.dstProject,_.dstFilePath),$_("idx_relations_type").on(_.project,_.type),$_("idx_relations_project_type_src").on(_.project,_.type,_.srcFilePath),$_("idx_relations_specifier").on(_.project,_.specifier),X0({columns:[_.project,_.srcFilePath],foreignColumns:[s.project,s.filePath]}).onDelete("cascade")]),z_=G_("annotations",{id:a("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:a("start_line").notNull(),startColumn:a("start_column").notNull(),endLine:a("end_line").notNull(),endColumn:a("end_column").notNull(),indexedAt:b("indexed_at").notNull()},(_)=>[$_("idx_annotations_project_file").on(_.project,_.filePath),$_("idx_annotations_project_tag").on(_.project,_.tag),$_("idx_annotations_project_symbol").on(_.project,_.symbolName),X0({columns:[_.project,_.filePath],foreignColumns:[s.project,s.filePath]}).onDelete("cascade")]),t=G_("symbol_changelog",{id:a("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:a("is_full_index").notNull().default(0),indexRunId:b("index_run_id").notNull()},(_)=>[$_("idx_changelog_project_changed_at").on(_.project,_.changedAt),$_("idx_changelog_project_name").on(_.project,_.symbolName),$_("idx_changelog_project_run").on(_.project,_.indexRunId)]),P$=G_("watcher_owner",{id:a("id").primaryKey(),pid:a("pid").notNull(),startedAt:b("started_at").notNull(),heartbeatAt:b("heartbeat_at").notNull(),instanceId:b("instance_id")},(_)=>[b$("watcher_owner_singleton",u$`${_.id} = 1`)]);class U0{client=null;drizzle=null;dbPath;txDepth=0;constructor(_){this.dbPath=d0(_.projectRoot,I_,l_)}get drizzleDb(){if(!this.drizzle)throw Error("Database is not open. Call open() first.");return this.drizzle}open(){try{x$(h$(this.dbPath),{recursive:!0}),this.client=new y$(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=n$(this.client,{schema:V0}),m$(this.drizzle,{migrationsFolder:d0(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(_)&&m0(this.dbPath)){this.closeClient(),n0(this.dbPath);for(let Q of["-wal","-shm"]){let J=this.dbPath+Q;if(m0(J))n0(J)}let $=this.open();if(f$($))return h0(new O("store",`Failed to recover database at ${this.dbPath}`,{cause:$.data}));return $}return h0(new O("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 Q=`sp_${this.txDepth++}`;$.run(`SAVEPOINT "${Q}"`);try{let J=_(this);return $.run(`RELEASE SAVEPOINT "${Q}"`),J}catch(J){throw $.run(`ROLLBACK TO SAVEPOINT "${Q}"`),$.run(`RELEASE SAVEPOINT "${Q}"`),J}finally{this.txDepth--}}immediateTransaction(_){let $=this.requireClient();this.txDepth++,$.run("BEGIN IMMEDIATE");try{let Q=_();return $.run("COMMIT"),Q}catch(Q){throw $.run("ROLLBACK"),Q}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 Q=new Date().toISOString();this.requireClient().prepare("INSERT INTO watcher_owner (id, pid, started_at, heartbeat_at, instance_id) VALUES (1, ?, ?, ?, ?)").run(_,Q,Q,$??null)}replaceOwner(_,$){let Q=new Date().toISOString();this.requireClient().prepare("INSERT OR REPLACE INTO watcher_owner (id, pid, started_at, heartbeat_at, instance_id) VALUES (1, ?, ?, ?, ?)").run(_,Q,Q,$??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",(Q,J)=>{try{return new RegExp(Q).test(J)?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 b_,and as p0}from"drizzle-orm";class O0{db;constructor(_){this.db=_}getFile(_,$){return this.db.drizzleDb.select().from(s).where(p0(b_(s.project,_),b_(s.filePath,$))).get()??null}upsertFile(_){this.db.drizzleDb.insert(s).values({project:_.project,filePath:_.filePath,mtimeMs:_.mtimeMs,size:_.size,contentHash:_.contentHash,updatedAt:_.updatedAt,lineCount:_.lineCount??null}).onConflictDoUpdate({target:[s.project,s.filePath],set:{mtimeMs:_.mtimeMs,size:_.size,contentHash:_.contentHash,updatedAt:_.updatedAt,lineCount:_.lineCount??null}}).run()}getAllFiles(_){return this.db.drizzleDb.select().from(s).where(b_(s.project,_)).all()}getFilesMap(_){let $=this.getAllFiles(_),Q=new Map;for(let J of $)Q.set(J.filePath,J);return Q}deleteFile(_,$){this.db.drizzleDb.delete(s).where(p0(b_(s.project,_),b_(s.filePath,$))).run()}}import{eq as r,and as A_,sql as c_,count as d$}from"drizzle-orm";function F_(_){return _.replaceAll("\x00","").trim().split(/\s+/).map(($)=>$.trim()).filter(($)=>$.length>0).map(($)=>`"${$.replaceAll('"','""')}"*`).join(" ")}var i0=50;class H0{db;constructor(_){this.db=_}replaceFileSymbols(_,$,Q,J){if(this.db.drizzleDb.delete(f).where(A_(r(f.project,_),r(f.filePath,$))).run(),!J.length)return;let W=new Date().toISOString(),z=J.map((Y)=>({project:_,filePath:$,kind:Y.kind??"unknown",name:Y.name??"",startLine:Y.startLine??0,startColumn:Y.startColumn??0,endLine:Y.endLine??0,endColumn:Y.endColumn??0,isExported:Y.isExported??0,signature:Y.signature??null,fingerprint:Y.fingerprint??null,detailJson:Y.detailJson??null,contentHash:Q,indexedAt:Y.indexedAt??W,resolvedType:Y.resolvedType??null,structuralFingerprint:Y.structuralFingerprint??null}));for(let Y=0;Y<z.length;Y+=i0)this.db.drizzleDb.insert(f).values(z.slice(Y,Y+i0)).run()}getFileSymbols(_,$){return this.db.drizzleDb.select().from(f).where(A_(r(f.project,_),r(f.filePath,$))).all()}searchByName(_,$,Q={}){let J=Q.limit??50,W=F_($);if(!W)return[];return this.db.drizzleDb.select().from(f).where(A_(c_`${f.id} IN (SELECT rowid FROM symbols_fts WHERE symbols_fts MATCH ${W})`,r(f.project,_),Q.kind?r(f.kind,Q.kind):void 0)).orderBy(f.name).limit(J).all()}searchByKind(_,$){return this.db.drizzleDb.select().from(f).where(A_(r(f.project,_),r(f.kind,$))).orderBy(f.name).all()}getStats(_){let $=this.db.drizzleDb.select({symbolCount:d$(),fileCount:c_`COUNT(DISTINCT ${f.filePath})`}).from(f).where(r(f.project,_)).get();return{symbolCount:$?.symbolCount??0,fileCount:$?.fileCount??0}}getByFingerprint(_,$){return this.db.drizzleDb.select().from(f).where(A_(r(f.project,_),r(f.fingerprint,$))).all()}deleteFileSymbols(_,$){this.db.drizzleDb.delete(f).where(A_(r(f.project,_),r(f.filePath,$))).run()}searchByQuery(_){let $=this.db.drizzleDb.select().from(f).where(A_(_.ftsQuery?c_`${f.id} IN (SELECT rowid FROM symbols_fts WHERE symbols_fts MATCH ${_.ftsQuery})`:void 0,_.exactName?r(f.name,_.exactName):void 0,_.project!==void 0?r(f.project,_.project):void 0,_.kind?r(f.kind,_.kind):void 0,_.filePath!==void 0?r(f.filePath,_.filePath):void 0,_.isExported!==void 0?r(f.isExported,_.isExported?1:0):void 0,_.decorator?c_`${f.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?r(f.resolvedType,_.resolvedType):void 0)).orderBy(f.name);if(!_.regex)return(_.limit!==void 0?$.limit(_.limit):$).all();let Q;try{Q=new RegExp(_.regex)}catch{throw new O("validation",`Invalid regex pattern: ${_.regex}`)}if(_.limit===void 0)return $.all().filter((z)=>Q.test(z.name));let J=[];for(let W of[5,20,100]){let z=_.limit*W,Y=$.limit(z).all();if(J=Y.filter((Z)=>Q.test(Z.name)),J.length>=_.limit||Y.length<z)return J.slice(0,_.limit)}return J.slice(0,_.limit)}}import{eq as h,and as H_,isNull as l0,or as p$}from"drizzle-orm";var P_={project:k.project,type:k.type,srcFilePath:k.srcFilePath,srcSymbolName:k.srcSymbolName,dstProject:k.dstProject,dstFilePath:k.dstFilePath,dstSymbolName:k.dstSymbolName,metaJson:k.metaJson,specifier:k.specifier,isExternal:k.isExternal};class M0{db;constructor(_){this.db=_}replaceFileRelations(_,$,Q){this.db.transaction((J)=>{if(J.drizzleDb.delete(k).where(H_(h(k.project,_),h(k.srcFilePath,$))).run(),!Q.length)return;for(let W of Q)J.drizzleDb.insert(k).values({project:_,type:W.type??"unknown",srcFilePath:W.srcFilePath??$,srcSymbolName:W.srcSymbolName??null,dstProject:W.dstProject??(W.dstFilePath!=null?_:null),dstFilePath:W.dstFilePath??null,dstSymbolName:W.dstSymbolName??null,metaJson:W.metaJson??null,specifier:W.specifier??null,isExternal:W.isExternal??0}).run()})}getOutgoing(_,$,Q){if(Q!==void 0)return this.db.drizzleDb.select(P_).from(k).where(H_(h(k.project,_),h(k.srcFilePath,$),p$(h(k.srcSymbolName,Q),l0(k.srcSymbolName)))).all();return this.db.drizzleDb.select(P_).from(k).where(H_(h(k.project,_),h(k.srcFilePath,$))).all()}getIncoming(_){let{dstProject:$,dstFilePath:Q}=_;return this.db.drizzleDb.select(P_).from(k).where(H_(h(k.dstProject,$),h(k.dstFilePath,Q))).all()}getByType(_,$){return this.db.drizzleDb.select(P_).from(k).where(H_(h(k.project,_),h(k.type,$))).all()}deleteFileRelations(_,$){this.db.drizzleDb.delete(k).where(H_(h(k.project,_),h(k.srcFilePath,$))).run()}deleteIncomingRelations(_,$){this.db.drizzleDb.delete(k).where(H_(h(k.dstProject,_),h(k.dstFilePath,$))).run()}searchRelations(_){let $=this.db.drizzleDb.select(P_).from(k).where(H_(_.project!==void 0?h(k.project,_.project):void 0,_.srcFilePath!==void 0?h(k.srcFilePath,_.srcFilePath):void 0,_.srcSymbolName!==void 0?h(k.srcSymbolName,_.srcSymbolName):void 0,_.dstProject!==void 0?h(k.dstProject,_.dstProject):void 0,_.dstFilePath!==void 0?h(k.dstFilePath,_.dstFilePath):void 0,_.dstSymbolName!==void 0?h(k.dstSymbolName,_.dstSymbolName):void 0,_.type!==void 0?h(k.type,_.type):void 0,_.specifier!==void 0?h(k.specifier,_.specifier):void 0,_.isExternal!==void 0?h(k.isExternal,_.isExternal?1:0):void 0));return(_.limit!==void 0?$.limit(_.limit):$).all()}retargetRelations(_){let{dstProject:$,oldFile:Q,oldSymbol:J,newFile:W,newSymbol:z,newDstProject:Y}=_,Z=J===null?H_(h(k.dstProject,$),h(k.dstFilePath,Q),l0(k.dstSymbolName)):H_(h(k.dstProject,$),h(k.dstFilePath,Q),h(k.dstSymbolName,J)),X={dstFilePath:W,dstSymbolName:z};if(Y!==void 0)X.dstProject=Y;this.db.drizzleDb.update(k).set(X).where(Z).run()}}import{err as a0}from"@zipbul/result";import{subscribe as i$}from"@parcel/watcher";import K0 from"path";import c0 from"path";function Q_(_){return _.replaceAll("\\","/")}function f_(_,$){return Q_(c0.relative(_,$))}function g_(_,$){return Q_(c0.resolve(_,$))}var l$=["**/.git/**",`**/${I_}/**`,"**/dist/**","**/node_modules/**"],c$=new Set(["package.json","tsconfig.json"]);function a$(_){if(_==="update")return"change";if(_==="create")return"create";return"delete"}class L0{#_;#$;#Q;#Z;#W;#z;constructor(_,$=i$,Q=console){this.#$=_.projectRoot,this.#Q=[...l$,..._.ignorePatterns??[]],this.#Z=new Set((_.extensions??[".ts",".mts",".cts"]).map((J)=>J.toLowerCase())),this.#W=$,this.#z=Q}async start(_){try{this.#_=await this.#W(this.#$,($,Q)=>{if($){this.#z.error(new O("watcher","Callback error",{cause:$}));return}try{for(let J of Q){let W=Q_(K0.relative(this.#$,J.path));if(W.startsWith(".."))continue;let z=K0.basename(W),Y=K0.extname(W).toLowerCase();if(!c$.has(z)&&!this.#Z.has(Y))continue;if(W.endsWith(".d.ts"))continue;_({eventType:a$(J.type),filePath:W})}}catch(J){this.#z.error(new O("watcher","Callback error",{cause:J}))}},{ignore:this.#Q})}catch($){return a0(new O("watcher","Failed to subscribe watcher",{cause:$}))}}async close(){if(!this.#_)return;try{await this.#_.unsubscribe(),this.#_=void 0}catch(_){return a0(new O("watcher","Failed to close watcher",{cause:_}))}}}import B0 from"path";var s$=["**/node_modules/**","**/.git/**",`**/${I_}/**`,"**/dist/**"],r$=s$.map((_)=>new Bun.Glob(_));function o$(_){return new Bun.Glob("**/package.json").scan({cwd:_,followSymlinks:!1})}async function a_(_,$=o$){let Q=[];for await(let J of $(_)){let W=Q_(J);if(r$.some((K)=>K.match(W)))continue;let z=Q_(B0.dirname(J)),Y=B0.join(_,J),Z=await Bun.file(Y).json(),X=typeof Z?.name==="string"&&Z.name.length>0?Z.name:B0.basename(z==="."?_:z);Q.push({dir:z,project:X})}return Q.sort((J,W)=>W.dir.length-J.dir.length),Q}function l(_,$,Q="default"){let J=Q_(_);for(let W of $){if(W.dir===".")return W.project;if(J===W.dir||J.startsWith(`${W.dir}/`))return W.project}return Q}import y_ from"path";var C_=new Map;async function t$(_){let $=Bun.file(_);if(!await $.exists())return null;try{let Q=await $.text(),J=Bun.JSONC.parse(Q);return typeof J==="object"&&J!==null?J:null}catch{return null}}function e$(_,$){if($.startsWith(".")){let Q=y_.resolve(_,$);return Q.endsWith(".json")?Q:Q+".json"}return y_.resolve(_,"node_modules",$)}async function s0(_,$=5){if($<=0)return null;let Q=await t$(_);if(!Q)return null;let J=Q.extends;if(typeof J!=="string"||!J)return Q;let W=e$(y_.dirname(_),J),z=await s0(W,$-1);if(!z)return Q;let Y=typeof z.compilerOptions==="object"&&z.compilerOptions!==null?z.compilerOptions:{},Z=typeof Q.compilerOptions==="object"&&Q.compilerOptions!==null?Q.compilerOptions:{};return{...z,...Q,compilerOptions:{...Y,...Z}}}async function x_(_){if(C_.has(_))return C_.get(_)??null;let $=y_.join(_,"tsconfig.json"),Q=await s0($);if(!Q)return C_.set(_,null),null;let J=typeof Q.compilerOptions==="object"&&Q.compilerOptions!==null?Q.compilerOptions:null;if(!J)return C_.set(_,null),null;let W=typeof J.baseUrl==="string"?J.baseUrl:null,z=typeof J.paths==="object"&&J.paths!==null?J.paths:null;if(!W&&!z)return C_.set(_,null),null;let Y=W?y_.resolve(_,W):_,Z=new Map;if(z)for(let[K,U]of Object.entries(z)){if(!Array.isArray(U))continue;let L=U.filter((C)=>typeof C==="string");Z.set(K,L)}let X={baseUrl:Y,paths:Z};return C_.set(_,X),X}function s_(_){if(_){C_.delete(_);return}C_.clear()}function U_(_){let $=Bun.hash.xxHash64(_);return BigInt.asUintN(64,BigInt($)).toString(16).padStart(16,"0")}import{isErr as z1}from"@zipbul/result";import{err as _Q}from"@zipbul/result";import{parseSync as $Q}from"oxc-parser";function j_(_,$,Q,J=$Q){try{let W={preserveParens:!1,...Q},z=J(_,$,W);return{filePath:_,program:z.program,errors:z.errors,comments:z.comments,sourceText:$,module:z.module}}catch(W){return _Q(new O("parse",`Failed to parse file: ${_}`,{cause:W}))}}import{join as QQ}from"path";function JQ(_,$){let Q=$.length===1?`**/*${$[0]}`:`**/*{${$.join(",")}}`;return new Bun.Glob(Q).scan({cwd:_,followSymlinks:!1})}async function r0(_){let{projectRoot:$,extensions:Q,ignorePatterns:J,fileRepo:W,scanFilesFn:z=JQ}=_,Y=W.getFilesMap(),Z=new Set,X=[],K=[],U=J.map((C)=>new Bun.Glob(C));for await(let C of z($,Q)){let q=Q_(C);if(!Q.some((d)=>q.endsWith(d)))continue;if(q.startsWith("node_modules/")||q.includes("/node_modules/"))continue;if(U.some((d)=>d.match(q)))continue;Z.add(q);let w=QQ($,q),S=Bun.file(w),{size:F,lastModified:G}=S,E=Y.get(q);if(!E){let d=await S.text(),p=U_(d);X.push({filePath:q,contentHash:p,mtimeMs:G,size:F});continue}if(E.mtimeMs===G&&E.size===F){K.push({filePath:q,contentHash:E.contentHash,mtimeMs:G,size:F});continue}let u=await S.text(),y=U_(u);if(y===E.contentHash)K.push({filePath:q,contentHash:y,mtimeMs:G,size:F});else X.push({filePath:q,contentHash:y,mtimeMs:G,size:F})}let L=[];for(let C of Y.keys())if(!Z.has(C))L.push(C);return{changed:X,unchanged:K,deleted:L}}function h_(_){let $=[0];for(let Q=0;Q<_.length;Q++)if(_[Q]===`
|
|
3
|
-
`)$.push(Q+1);return $}function V_(_,$){let Q=0,J=_.length-1;while(Q<J){let W=Q+J+1>>1;if(_[W]<=$)Q=W;else J=W-1}return{line:Q+1,column:$-_[Q]}}import{err as WQ}from"@zipbul/result";import{parse as zQ}from"comment-parser";function r_(_){try{let $=_.trim();if($.startsWith("/**"))$=$.slice(3);if($.endsWith("*/"))$=$.slice(0,-2);let J=zQ(`/** ${$} */`)[0]??{description:"",tags:[]};return{description:(J.description??"").trim(),tags:(J.tags??[]).map((W)=>({tag:W.tag??"",name:W.name??"",type:W.type??"",description:W.description??"",optional:W.optional??!1,...W.default!==void 0?{default:W.default}:{}}))}}catch($){return WQ(new O("parse","Failed to parse JSDoc comment",{cause:$}))}}import{isErr as ZQ}from"@zipbul/result";function YQ(_){if("name"in _&&typeof _.name==="string")return _.name;if("value"in _){let $=_.value;if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="bigint"||typeof $==="boolean")return String($)}return"unknown"}function k_(_){if(_.type==="Identifier")return[{name:_.name,start:_.start,end:_.end}];if(_.type==="ObjectPattern"){let $=[];for(let Q of _.properties)if(Q.type==="RestElement")$.push(...k_(Q.argument));else $.push(...k_(Q.value));return $}if(_.type==="ArrayPattern"){let $=[];for(let Q of _.elements){if(!Q)continue;if(Q.type==="RestElement")$.push(...k_(Q.argument));else $.push(...k_(Q))}return $}if(_.type==="AssignmentPattern")return k_(_.left);return[]}function XQ(_){let $=new Map;for(let Q of _.module.staticImports){let J=Q.moduleRequest.value;for(let W of Q.entries){let z=W.localName.value,Y=W.importName.kind==="Name"?W.importName.name:void 0,Z={specifier:J};if(Y&&Y!==z)Z.originalName=Y;$.set(z,Z)}}return $}function N_(_){let{program:$,sourceText:Q,comments:J}=_,W=h_(Q),z=XQ(_),Y=J.filter((I)=>I.type==="Block"&&I.value.startsWith("*")).sort((I,N)=>I.end-N.end),Z=$.body.map((I)=>I.start).sort((I,N)=>I-N);function X(I,N){return G(I,N)}function K(I,N,V){if(I.type==="PrivateIdentifier")return{kind:"private"};if(!N&&I.type==="Identifier")return;return X(I,V)}function U(I,N){if(N)return Q.slice(I.start,I.end);if(I.type==="PrivateIdentifier")return`#${I.name}`;return YQ(I)}function L(I,N,V){let H=I;if(!N&&H.type==="Identifier")return{kind:"string",value:H.name};return X(I,V)}function C(I,N){return{start:V_(W,I),end:V_(W,N)}}function q(I){let N=0,V=Y.length-1,H=-1;while(N<=V){let B=N+V>>>1;if(Y[B].end<=I)H=B,N=B+1;else V=B-1}if(H<0)return;let M=Y[H];N=0,V=Z.length-1;while(N<=V){let B=N+V>>>1,A=Z[B];if(A<=M.end)N=B+1;else if(A>=I)V=B-1;else return}return`/*${M.value}*/`}function w(I){if(!I)return;let N="typeAnnotation"in I&&I.typeAnnotation?I.typeAnnotation:I;return Q.slice(N.start,N.end)}let S=8;function F(I){if(I.type==="Identifier")return z.get(I.name);if(I.type==="MemberExpression"){let N=I.object;if(N.type==="Identifier")return z.get(N.name)}return}function G(I,N=0){let V=I;if(N>=S)return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)};let H=V.type;if(H==="Literal"){let M=V.value;if(typeof M==="bigint")return{kind:"bigint",value:typeof V.bigint==="string"?V.bigint:M.toString()};if(typeof V.regex==="object"&&V.regex!==null)return{kind:"regex",value:Q.slice(V.start,V.end)};if(M===null)return{kind:"null",value:null};if(typeof M==="string")return{kind:"string",value:M};if(typeof M==="number")return{kind:"number",value:M};if(typeof M==="boolean")return{kind:"boolean",value:M};return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}if(H==="Identifier"){let M=V.name;if(M==="undefined")return{kind:"undefined",value:null};let B=z.get(M),A={kind:"identifier",name:M};if(B){if(A.importSource=B.specifier,B.originalName)A.originalName=B.originalName}return A}if(H==="MemberExpression"){if(V.computed){let g=V.property;if(g.type==="Literal"&&typeof g.value==="string"){let j=V.object,v=Q.slice(j.start,j.end),m=j.type==="Identifier"?j.name:void 0,__=m?z.get(m):void 0,X_={kind:"member",object:v,property:g.value};if(__)X_.importSource=__.specifier;return X_}return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}let M=V.object,B=Q.slice(M.start,M.end),A=V.property.name??Q.slice(V.property.start,V.property.end),D=M.type==="Identifier"?M.name:void 0,T=D?z.get(D):void 0,R={kind:"member",object:B,property:A};if(T)R.importSource=T.specifier;return R}if(H==="CallExpression"){let M=V.callee,B=Q.slice(M.start,M.end),D=(V.arguments??[]).map((g)=>G(g,N+1)),T=F(M),R={kind:"call",callee:B,arguments:D};if(T)R.importSource=T.specifier;return R}if(H==="NewExpression"){let M=V.callee,B=Q.slice(M.start,M.end),D=(V.arguments??[]).map((g)=>G(g,N+1)),T=F(M),R={kind:"new",callee:B,arguments:D};if(T)R.importSource=T.specifier;return R}if(H==="ObjectExpression"){let M=V.properties??[],B=[];for(let A of M){if(A.type==="SpreadElement"){let m=A.argument;B.push({kind:"spread",argument:G(m,N+1)});continue}let D=A.key,T=A.computed===!0,R=A.value,g=A.shorthand||void 0,v={kind:"property",key:L(D,T,N+1),value:G(R,N+1)};if(g)v.shorthand=!0;B.push(v)}return{kind:"object",properties:B}}if(H==="ArrayExpression")return{kind:"array",elements:(V.elements??[]).map((A)=>{if(!A)return{kind:"undefined",value:null};return G(A,N+1)})};if(H==="SpreadElement"){let M=V.argument;return{kind:"spread",argument:G(M,N+1)}}if(H==="ArrowFunctionExpression"||H==="FunctionExpression"){let B=V.params.map(u),A={kind:"function",sourceText:Q.slice(V.start,V.end)};if(B.length>0)A.parameters=B;return A}if(H==="TemplateLiteral"||H==="TaggedTemplateExpression")return{kind:"template",sourceText:Q.slice(V.start,V.end)};if(H==="UnaryExpression"){let{operator:M,argument:B}=V;if(M==="-"&&B.type==="Literal"&&typeof B.value==="number")return{kind:"number",value:-B.value};if(M==="void")return{kind:"undefined",value:null};return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}if(H==="TSAsExpression"||H==="TSSatisfiesExpression"||H==="TSNonNullExpression"||H==="TSTypeAssertion"||H==="TSInstantiationExpression"||H==="ParenthesizedExpression"||H==="ChainExpression"){let M=V.expression;if(M)return G(M,N)}return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}function E(I){if(!I||I.length===0)return[];return I.map((N)=>{let V=N.expression;if(V.type==="CallExpression"){let H=V,M=H.callee,B="name"in M&&typeof M.name==="string"?M.name:("property"in M)&&M.property&&typeof M.property.name==="string"?M.property.name:"unknown",A=H.arguments.map((D)=>G(D));return{name:B,arguments:A.length>0?A:void 0}}if(V.type==="Identifier")return{name:V.name??"unknown"};return{name:Q.slice(V.start,V.end)}})}function u(I){if(I.type==="TSParameterProperty"){let V=I;return d(V.parameter,V.decorators)}if(I.type==="RestElement"){let V=I,H=V.argument,B=`...${"name"in H&&typeof H.name==="string"?H.name:"unknown"}`,A=V.typeAnnotation,D=A?w(A):void 0,T={name:B,isOptional:!1};if(D)T.type=D;return T}let N=I;return d(N,N.decorators)}function y(I){if(!I)return;let N="typeAnnotation"in I&&I.typeAnnotation?I.typeAnnotation:null;if(!N)return;let H=N.typeName?.name;if(!H)return;return z.get(H)?.specifier}function d(I,N){if(I.type==="AssignmentPattern"){let{left:R,right:g}=I,j="name"in R&&typeof R.name==="string"?R.name:"unknown",v="typeAnnotation"in R?R.typeAnnotation:null,m=v?w(v):void 0,__=y(v),X_=Q.slice(g.start,g.end),K_="decorators"in R&&Array.isArray(R.decorators)?R.decorators:[],Y0=E(K_),D_={name:j,isOptional:!0,defaultValue:X_};if(m)D_.type=m;if(__)D_.typeImportSource=__;if(Y0.length>0)D_.decorators=Y0;return D_}let V="name"in I&&typeof I.name==="string"?I.name:("pattern"in I)&&I.pattern&&typeof I.pattern.name==="string"?I.pattern.name:"unknown",H=!!(("optional"in I)&&I.optional),M="typeAnnotation"in I?I.typeAnnotation:null,B=M?w(M):void 0,A=y(M),D=E(N??[]),T={name:V,isOptional:H};if(B)T.type=B;if(A)T.typeImportSource=A;if(D.length>0)T.decorators=D;return T}function p(I,N){let V=[];if(N?.async)V.push("async");if(I.static)V.push("static");if(I.abstract)V.push("abstract");if(I.readonly)V.push("readonly");if(I.override)V.push("override");if(I.declare)V.push("declare");if(I.const)V.push("const");let H=I.accessibility;if(H==="private")V.push("private");else if(H==="protected")V.push("protected");else if(H==="public")V.push("public");return V}function J_(I){if(!I)return;let N=I.params.flatMap((V)=>{let H=V.name.name;return H?[H]:[]});return N.length>0?N:void 0}function Z_(I){let N=[];if(I.superClass){let H=Q.slice(I.superClass.start,I.superClass.end);N.push({kind:"extends",name:H})}let V=I.implements??[];for(let H of V){let M=H.expression,B=Q.slice(M.start,M.end);N.push({kind:"implements",name:B})}return N}function O_(I){let N=[],V=I.extends;for(let H of V){let M=H.expression,B=Q.slice(M.start,M.end);N.push({kind:"extends",name:B})}return N}function Y_(I){let N=[];for(let V of I)if(V.type==="MethodDefinition"||V.type==="TSAbstractMethodDefinition"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=H.value,D=H.kind,T=D==="constructor"?"constructor":D==="get"?"getter":D==="set"?"setter":"method",R=p(H,A);if(V.type==="TSAbstractMethodDefinition"&&!R.includes("abstract"))R.push("abstract");let g=A.params.map(u),j=w(A.returnType),v=E(H.decorators??[]),m={kind:"method",name:M,span:C(V.start,V.end),isExported:!1,methodKind:T,modifiers:R,parameters:g.length>0?g:void 0,returnType:j};if(B)m.key=B;if(v.length>0)m.decorators=v;N.push(m)}else if(V.type==="PropertyDefinition"||V.type==="TSAbstractPropertyDefinition"||V.type==="AccessorProperty"||V.type==="TSAbstractAccessorProperty"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=p(H);if(V.type==="TSAbstractPropertyDefinition"||V.type==="TSAbstractAccessorProperty"){if(!A.includes("abstract"))A.push("abstract")}if(V.type==="AccessorProperty"||V.type==="TSAbstractAccessorProperty")A.push("accessor");let D=w(H.typeAnnotation),T=H.value,R=T?G(T):void 0,g=E(H.decorators??[]),j={kind:"property",name:M,span:C(V.start,V.end),isExported:!1,modifiers:A,returnType:D,initializer:R};if(B)j.key=B;if(g.length>0)j.decorators=g;N.push(j)}return N}function W_(I){let N=[];for(let V of I)if(V.type==="TSMethodSignature"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=H.params.map(u),D=w(H.returnType),T={kind:"method",name:M,span:C(V.start,V.end),isExported:!1,modifiers:[],methodKind:"method",parameters:A.length>0?A:void 0,returnType:D};if(B)T.key=B;N.push(T)}else if(V.type==="TSPropertySignature"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=w(H.typeAnnotation),D={kind:"property",name:M,span:C(V.start,V.end),isExported:!1,modifiers:H.readonly?["readonly"]:[],returnType:A};if(B)D.key=B;N.push(D)}return N}function i(I,N){let V=I.type;if(V==="FunctionDeclaration"||V==="FunctionExpression"||V==="TSDeclareFunction"||V==="TSEmptyBodyFunctionExpression"){let H=I,M=H.id?.name??"default",B=H.params.map(u),A=w(H.returnType),D=p(H,H),T=E(H.decorators??[]),R=J_(H.typeParameters),g={kind:"function",name:M,span:C(I.start,I.end),isExported:N,modifiers:D,parameters:B.length>0?B:void 0,returnType:A,decorators:T.length>0?T:void 0};if(R&&R.length>0)g.typeParameters=R;return g}if(V==="ClassDeclaration"||V==="ClassExpression"){let H=I,M=H.id?.name??"default",B=Z_(H),A=Y_(H.body.body),D=E(H.decorators),T=p(H),R=J_(H.typeParameters),g={kind:"class",name:M,span:C(I.start,I.end),isExported:N,modifiers:T,heritage:B.length>0?B:void 0,members:A.length>0?A:void 0,decorators:D.length>0?D:void 0};if(R&&R.length>0)g.typeParameters=R;return g}if(V==="VariableDeclaration"){let H=I,M=[];for(let B of H.declarations){let{id:A,init:D}=B;if(A.type==="ObjectPattern"||A.type==="ArrayPattern"){let X_=k_(A);for(let K_ of X_)M.push({kind:"variable",name:K_.name,span:C(K_.start,K_.end),isExported:N,modifiers:[]});continue}let T="name"in A&&typeof A.name==="string"?A.name:"unknown",R="variable",g,j,v;if(D)if(D.type==="FunctionExpression"||D.type==="ArrowFunctionExpression"){R="function";let X_=D;g=X_.params.map(u),j=w(X_.returnType)}else v=G(D);let m=[],__={kind:R,name:T,span:C(B.start,B.end),isExported:N,modifiers:m,parameters:g,returnType:j};if(v)__.initializer=v;M.push(__)}if(M.length===0)return null;if(M.length===1)return M[0];return M}if(V==="TSTypeAliasDeclaration")return{kind:"type",name:I.id.name,span:C(I.start,I.end),isExported:N,modifiers:[]};if(V==="TSInterfaceDeclaration"){let H=I,M=H.id.name,B=O_(H),A=W_(H.body.body),D=J_(H.typeParameters),T={kind:"interface",name:M,span:C(I.start,I.end),isExported:N,modifiers:[],heritage:B.length>0?B:void 0,members:A.length>0?A:void 0};if(D&&D.length>0)T.typeParameters=D;return T}if(V==="TSEnumDeclaration"){let H=I,M=H.id.name,B=p(H),D=H.body.members.map((T)=>{let R=T.id,g=R.type!=="Identifier",j="name"in R&&typeof R.name==="string"?R.name:("value"in R)&&typeof R.value==="string"?R.value:"unknown",v=T.initializer?G(T.initializer):void 0,m={kind:"property",name:j,span:C(T.start,T.end),isExported:!1,modifiers:[]};if(g)m.key=X(R,0);if(v)m.initializer=v;return m});return{kind:"enum",name:M,span:C(I.start,I.end),isExported:N,modifiers:B,members:D.length>0?D:void 0}}if(V==="TSModuleDeclaration"){let H=I,M=H.id.name??H.id.value??"unknown",B=p(H),A=[];if(H.body?.type==="TSModuleBlock")for(let D of H.body.body??[]){if(D.type!=="ExportNamedDeclaration")continue;let T=D.declaration;if(!T)continue;let R=i(T,!1);if(R)if(Array.isArray(R))A.push(...R);else A.push(R)}return{kind:"namespace",name:M,span:C(I.start,I.end),isExported:N,modifiers:B,members:A.length>0?A:void 0}}return null}let c=[],w_=new Set;for(let I of $.body){let N=null,V=I;if(V.type==="ExportNamedDeclaration"){let M=V;if(M.declaration){if(N=i(M.declaration,!0),N&&!Array.isArray(N))N.span=C(M.start,M.end)}else if(!M.source&&M.specifiers)for(let B of M.specifiers){let A=B.local,D="name"in A?A.name:A.value;if(D)w_.add(D)}}else if(V.type==="ExportDefaultDeclaration"){let M=V,B=M.declaration;if(B){if(N=i(B,!0),N&&!Array.isArray(N))N.name="id"in B&&B.id&&typeof B.id.name==="string"?B.id.name:"default",N.isExported=!0,N.span=C(M.start,M.end);else if(!N&&"type"in B&&B.type==="Identifier"){let A=B.name;if(A)w_.add(A)}}}else{let M=V.type;if(M==="FunctionDeclaration"||M==="TSDeclareFunction"||M==="ClassDeclaration"||M==="VariableDeclaration"||M==="TSTypeAliasDeclaration"||M==="TSInterfaceDeclaration"||M==="TSEnumDeclaration"||M==="TSModuleDeclaration")N=i(V,!1)}let H=Array.isArray(N)?N:N?[N]:[];for(let M of H){let B=I.start,A=q(B);if(A){let D=r_(A);if(!ZQ(D))M.jsDoc=D}c.push(M)}}if(w_.size>0){for(let I of c)if(!I.isExported&&w_.has(I.name))I.isExported=!0}return c}function o_(_){if(_===null||typeof _!=="object")return JSON.stringify(_);if(Array.isArray(_))return`[${_.map(o_).join(",")}]`;let $=_;return`{${Object.keys($).sort().map((J)=>`${JSON.stringify(J)}:${o_($[J])}`).join(",")}}`}function VQ(_){if(_.kind==="function"||_.kind==="method"){let $=_.parameters?.length??0,Q=_.modifiers.includes("async")?1:0;return`params:${$}|async:${Q}`}return null}function UQ(_){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(_.initializer)$.initializer=_.initializer;if(_.key)$.key=_.key;if(_.members?.length)$.members=_.members.map((Q)=>{let J=Q.modifiers.find((z)=>z==="private"||z==="protected"||z==="public"),W={name:Q.name,kind:Q.methodKind??Q.kind,type:Q.returnType,visibility:J,isStatic:Q.modifiers.includes("static")||void 0,isReadonly:Q.modifiers.includes("readonly")||void 0,isAccessor:Q.modifiers.includes("accessor")||void 0};if(Q.key)W.key=Q.key;if(Q.initializer)W.initializer=Q.initializer;if(Q.decorators?.length)W.decorators=Q.decorators;return W});return Object.keys($).length>0?JSON.stringify($):null}function OQ(_){let $=[_.kind];if(_.modifiers.length)$.push(`mod:${[..._.modifiers].sort().join(",")}`);if(_.typeParameters?.length)$.push(`tp:${_.typeParameters.length}`);if(_.heritage?.length){let Q=[..._.heritage].sort((J,W)=>J.name.localeCompare(W.name)).map((J)=>`${J.kind}:${J.name}`).join(",");$.push(`her:${Q}`)}if(_.decorators?.length)$.push(`dec:${[..._.decorators].map((Q)=>Q.name).sort().join(",")}`);if(_.methodKind)$.push(`mk:${_.methodKind}`);if(_.parameters)$.push(`p:${_.parameters.length}`);if(_.returnType)$.push(`rt:${_.returnType}`);if(_.key)$.push(`k:${o_(_.key)}`);if(_.members?.length){let Q=_.members.map((J)=>`${J.kind}:${J.modifiers.join(",")}:${J.parameters?.length??""}:${J.returnType??""}:${J.key?o_(J.key):""}`).sort().join(";");$.push(`mem:${_.members.length}:${U_(Q)}`)}return U_($.join("|"))}function o0(_,$,Q,J,W){let z=VQ(_),Y=U_(`${$}|${_.kind}|${z??""}`),Z=OQ(_);return{project:Q,filePath:J,kind:_.kind,name:$,startLine:_.span.start.line,startColumn:_.span.start.column,endLine:_.span.end.line,endColumn:_.span.end.column,isExported:_.isExported?1:0,signature:z,fingerprint:Y,detailJson:UQ(_),contentHash:W,indexedAt:new Date().toISOString(),structuralFingerprint:Z}}function w0(_){let{parsed:$,project:Q,filePath:J,contentHash:W,symbolRepo:z}=_,Y=N_($),Z=[];for(let X of Y){Z.push(o0(X,X.name,Q,J,W));for(let K of X.members??[])Z.push(o0(K,`${X.name}.${K.name}`,Q,J,W))}z.replaceFileSymbols(Q,J,W,Z)}import{resolve as D0,dirname as HQ,extname as MQ}from"path";function q_(_,$,Q){let J=(W)=>{let z=MQ(W);if(z===".js")return[W.slice(0,-3)+".ts"];if(z===".mjs")return[W.slice(0,-4)+".mts"];if(z===".cjs")return[W.slice(0,-4)+".cts"];if(z===".ts"||z===".mts"||z===".cts"||z===".d.ts")return[W];return[W+".ts",W+".d.ts",W+"/index.ts",W+"/index.d.ts",W+".mts",W+"/index.mts",W+".cts",W+"/index.cts"]};if($.startsWith(".")){let W=Q_(D0(HQ(_),$));return J(W)}if(Q)for(let[W,z]of Q.paths){if(z.length===0)continue;let Y=W.indexOf("*");if(Y===-1){if($===W){let Z=[];for(let X of z)Z.push(...J(Q_(D0(Q.baseUrl,X))));return Z}}else{let Z=W.slice(0,Y),X=W.slice(Y+1);if($.startsWith(Z)&&(X===""||$.endsWith(X))){let K=$.slice(Z.length,X===""?void 0:$.length-X.length),U=[];for(let L of z)U.push(...J(Q_(D0(Q.baseUrl,L.replace("*",K)))));return U}}}return[]}function t0(_,$,Q,J=q_){let W=new Map,z=_.body??[];for(let Y of z){if(Y.type!=="ImportDeclaration")continue;let Z=Y.source?.value??"",X=J($,Z,Q);if(X.length===0)continue;let K=X[0],U=Y.specifiers??[];for(let L of U)switch(L.type){case"ImportSpecifier":W.set(L.local.name,{path:K,importedName:L.imported.name});break;case"ImportDefaultSpecifier":W.set(L.local.name,{path:K,importedName:"default"});break;case"ImportNamespaceSpecifier":W.set(L.local.name,{path:K,importedName:"*"});break}}return W}import{Visitor as KQ}from"oxc-parser";function t_(_){return"name"in _&&typeof _.name==="string"?_.name:("value"in _)&&typeof _.value==="string"?_.value:"unknown"}function LQ(_){return!_.startsWith(".")&&!_.startsWith("/")}function R_(_,$,Q,J){let W=J(_,$,Q),z=W.length>0?W[0]:null,Y=z===null&&LQ($);return{resolved:z,isExternal:Y}}function BQ(_,$,Q,J,W){for(let z of _.staticImports){let Y=z.moduleRequest.value,{resolved:Z,isExternal:X}=R_($,Y,Q,J),K=Z===null?{dstFilePath:null,specifier:Y}:{dstFilePath:Z};if(z.entries.length===0){let U={};if(X)U.isExternal=!0;if(Z===null&&!X)U.isUnresolved=!0;W.push({type:"imports",srcFilePath:$,srcSymbolName:null,...K,dstSymbolName:null,...Object.keys(U).length>0?{metaJson:JSON.stringify(U)}:{}});continue}for(let U of z.entries){let L=U.isType,C={};if(L)C.isType=!0;if(X)C.isExternal=!0;if(Z===null&&!X)C.isUnresolved=!0;let q,w,S=U.importName.kind;if(S==="Default")q="default",w=U.localName.value;else if(S==="NamespaceObject")q="*",w=U.localName.value,C.importKind="namespace";else q=U.importName.name??"unknown",w=U.localName.value;W.push({type:L?"type-references":"imports",srcFilePath:$,srcSymbolName:w,...K,dstSymbolName:q,...Object.keys(C).length>0?{metaJson:JSON.stringify(C)}:{}})}}}function wQ(_,$,Q,J,W){let z=new Map;for(let Y of _.staticImports)for(let Z of Y.entries)z.set(Z.localName.value,Y.moduleRequest.value);for(let Y of _.staticExports)for(let Z of Y.entries){let X=null;if(Z.moduleRequest)X=Z.moduleRequest.value;else if(Z.localName.name)X=z.get(Z.localName.name)??null;if(!X)continue;let{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.exportName.name??"default",C=Z.exportName.kind,q=Z.localName.name??Z.importName.name??L,w=Z.isType,S={isReExport:!0};if(C==="None");else S.specifiers=[{local:q,exported:L}];if(w)S.isType=!0;if(U)S.isExternal=!0;if(K===null&&!U)S.isUnresolved=!0;let F=null,G=null,E=Z.importName.kind;if(E==="All"||E==="AllButDefault"){if(C==="Name"&&L)G=L,S.namespaceAlias=L}else G=q,F=L;W.push({type:w?"type-references":"re-exports",srcFilePath:$,srcSymbolName:F,dstFilePath:K,dstSymbolName:G,metaJson:JSON.stringify(S),...K===null?{specifier:X}:{}})}}function DQ(_,$,Q,J,W){for(let z of _.body){let Y=z;if(Y.type==="ImportDeclaration"){let Z=Y,X=Z.source.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.importKind==="type",C=Z.specifiers,q=K===null?{dstFilePath:null,specifier:X}:{dstFilePath:K};if(C.length===0){let w={};if(L)w.isType=!0;if(U)w.isExternal=!0;if(K===null&&!U)w.isUnresolved=!0;W.push({type:L?"type-references":"imports",srcFilePath:$,srcSymbolName:null,...q,dstSymbolName:null,...Object.keys(w).length>0?{metaJson:JSON.stringify(w)}:{}})}else for(let w of C){let S=w.type,F=L||S==="ImportSpecifier"&&w.importKind==="type",G={};if(F)G.isType=!0;if(U)G.isExternal=!0;if(K===null&&!U)G.isUnresolved=!0;let E,u;if(S==="ImportDefaultSpecifier")E="default",u=w.local.name;else if(S==="ImportNamespaceSpecifier")E="*",u=w.local.name,G.importKind="namespace";else E=t_(w.imported),u=w.local.name;W.push({type:F?"type-references":"imports",srcFilePath:$,srcSymbolName:u,...q,dstSymbolName:E,...Object.keys(G).length>0?{metaJson:JSON.stringify(G)}:{}})}continue}if(Y.type==="ExportAllDeclaration"){let Z=Y,X=Z.source.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.exportKind==="type",C=Z.exported,q=C?t_(C):null,w={isReExport:!0};if(L)w.isType=!0;if(U)w.isExternal=!0;if(K===null&&!U)w.isUnresolved=!0;if(q)w.namespaceAlias=q;W.push({type:L?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:K,dstSymbolName:q,metaJson:JSON.stringify(w),...K===null?{specifier:X}:{}});continue}if(Y.type==="ExportNamedDeclaration"){let Z=Y;if(!Z.source)continue;let X=Z.source.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.exportKind==="type",C=Z.specifiers??[];for(let q of C){let w=L||q.exportKind==="type",S=t_(q.local),F=t_(q.exported),G={isReExport:!0,specifiers:[{local:S,exported:F}]};if(w)G.isType=!0;if(U)G.isExternal=!0;if(K===null&&!U)G.isUnresolved=!0;W.push({type:w?"type-references":"re-exports",srcFilePath:$,srcSymbolName:F,dstFilePath:K,dstSymbolName:S,metaJson:JSON.stringify(G),...K===null?{specifier:X}:{}})}}}}function IQ(_,$,Q,J,W){new KQ({ImportExpression(Y){let Z=Y.source;if(Z.type!=="Literal"||typeof Z.value!=="string")return;let X=Z.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L={isDynamic:!0};if(U)L.isExternal=!0;if(K===null&&!U)L.isUnresolved=!0;W.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:K,dstSymbolName:null,metaJson:JSON.stringify(L),...K===null?{specifier:X}:{}})},CallExpression(Y){let Z=Y.callee,X=!1;if(Z.type==="Identifier"&&Z.name==="require");else if(Z.type==="MemberExpression"&&!Z.computed){let S=Z,F=S.object,G=S.property;if(F.type==="Identifier"&&F.name==="require"&&G.name==="resolve")X=!0;else return}else return;let K=Y.arguments;if(K.length===0)return;let U=K[0];if(U.type!=="Literal"||typeof U.value!=="string")return;let L=U.value,{resolved:C,isExternal:q}=R_($,L,Q,J),w={isRequire:!0};if(X)w.isRequireResolve=!0;if(q)w.isExternal=!0;if(C===null&&!q)w.isUnresolved=!0;W.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:C,dstSymbolName:null,metaJson:JSON.stringify(w),...C===null?{specifier:L}:{}})}}).visit(_)}function e0(_,$,Q,J=q_,W){let z=[];if(W)BQ(W,$,Q,J,z),wQ(W,$,Q,J,z);else DQ(_,$,Q,J,z);return IQ(_,$,Q,J,z),z}import{walk as CQ}from"oxc-walker";function u_(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let $=_;if($.type==="Identifier"){let Q=$.name;return{root:Q,parts:[],full:Q}}if($.type==="ThisExpression")return{root:"this",parts:[],full:"this"};if($.type==="Super")return{root:"super",parts:[],full:"super"};if($.type==="MemberExpression"){let Q=[],J=$;while(J.type==="MemberExpression"){let Y=J.property;if(!Y||typeof Y.name!=="string")return null;Q.push(Y.name),J=J.object}let W;if(J.type==="Identifier")W=J.name;else if(J.type==="ThisExpression")W="this";else if(J.type==="Super")W="super";else return null;Q.reverse();let z=[W,...Q].join(".");return{root:W,parts:Q,full:z}}return null}function _1(_,$,Q){let J=[],W=[],z=[];function Y(){if(W.length>0)return W[W.length-1]??null;return null}function Z(U){if(!U)return null;let L=Q.get(U.root);if(U.parts.length===0){if(L)return{dstFilePath:L.path,dstSymbolName:L.importedName,resolution:"import"};return{dstFilePath:$,dstSymbolName:U.root,resolution:"local"}}else{if(L&&L.importedName==="*"){let C=U.parts[U.parts.length-1];return{dstFilePath:L.path,dstSymbolName:C,resolution:"namespace"}}return{dstFilePath:$,dstSymbolName:U.full,resolution:"local-member"}}}function X(U,L){let C=u_(U.callee),q=Z(C);if(q){let w=Y(),S={};if(L)S.isNew=!0;if(w===null)S.scope="module";J.push({type:"calls",srcFilePath:$,srcSymbolName:w,dstFilePath:q.dstFilePath,dstSymbolName:q.dstSymbolName,...Object.keys(S).length>0?{metaJson:JSON.stringify(S)}:{}})}}function K(U,L){if(U.type==="FunctionDeclaration"){W.push(U.id?.name??"anonymous");return}if(U.type==="FunctionExpression"||U.type==="ArrowFunctionExpression"){if(L?.type==="VariableDeclarator"){let w=L.id,S=w.type==="Identifier"?w.name:"anonymous";W.push(S);return}if(L?.type==="MethodDefinition"||L?.type==="TSAbstractMethodDefinition"){let w=L.key,S=z[z.length-1]??"",F="name"in w?w.name:"anonymous",G=S?`${S}.${F}`:F;W.push(G);return}let C=Y(),q=C?`${C}.<anonymous>`:"<anonymous>";W.push(q)}}return CQ(_,{enter(U,L){if(U.type==="ClassDeclaration"||U.type==="ClassExpression"){z.push(U.id?.name??"AnonymousClass");return}if(U.type==="FunctionDeclaration"||U.type==="FunctionExpression"||U.type==="ArrowFunctionExpression"){K(U,L);return}if(U.type==="CallExpression"){X(U,!1);return}if(U.type==="NewExpression"){X(U,!0);return}},leave(U){if(U.type==="ClassDeclaration"||U.type==="ClassExpression"){z.pop();return}if(U.type==="FunctionDeclaration"||U.type==="FunctionExpression"||U.type==="ArrowFunctionExpression"){W.pop();return}}}),J}import{Visitor as AQ}from"oxc-parser";function $1(_,$,Q){let J=[];function W(Y){let Z=Y.id?.name??"AnonymousClass";if(Y.superClass){let K=u_(Y.superClass);if(K){let U=I0(K,$,Q);J.push({type:"extends",srcFilePath:$,srcSymbolName:Z,...U})}}let X=Y.implements??[];for(let K of X){let U=u_(K.expression);if(!U)continue;let L=I0(U,$,Q);J.push({type:"implements",srcFilePath:$,srcSymbolName:Z,...L})}}return new AQ({TSInterfaceDeclaration(Y){let Z=Y.id.name??"AnonymousInterface",X=Y.extends;for(let K of X){let U=u_(K.expression);if(!U)continue;let L=I0(U,$,Q);J.push({type:"extends",srcFilePath:$,srcSymbolName:Z,...L})}},ClassDeclaration(Y){W(Y)},ClassExpression(Y){W(Y)}}).visit(_),J}function I0(_,$,Q){let J=Q.get(_.root);if(J){if(J.importedName==="*"){let W=_.parts[_.parts.length-1]??_.root;return{dstFilePath:J.path,dstSymbolName:W,metaJson:JSON.stringify({isNamespaceImport:!0})}}return{dstFilePath:J.path,dstSymbolName:_.parts.length>0?_.full:J.importedName}}return{dstFilePath:$,dstSymbolName:_.full,metaJson:JSON.stringify({isLocal:!0})}}function n_(_,$,Q,J=q_,W){let z=t0(_,$,Q,J),Y=e0(_,$,Q,J,W),Z=_1(_,$,z),X=$1(_,$,z);return[...Y,...Z,...X]}function C0(_){let{ast:$,project:Q,filePath:J,relationRepo:W,projectRoot:z,tsconfigPaths:Y,knownFiles:Z,boundaries:X,module:K}=_,U=g_(z,J),C=n_($,U,Y,Z?(w,S,F)=>{let G=q_(w,S,F);for(let E of G){let u=f_(z,E);if(X){let y=l(u,X);if(Z.has(`${y}::${u}`))return[E]}else if(Z.has(`${Q}::${u}`))return[E]}return[]}:void 0,K),q=[];for(let w of C){if(w.dstFilePath===null){let E=f_(z,w.srcFilePath),u;if(w.metaJson)try{u=JSON.parse(w.metaJson)}catch{}let y=u?.isExternal===!0;q.push({project:Q,type:w.type,srcFilePath:E,srcSymbolName:w.srcSymbolName??null,dstProject:null,dstFilePath:null,dstSymbolName:w.dstSymbolName??null,metaJson:w.metaJson??null,specifier:w.specifier??null,isExternal:y?1:0});continue}let S=f_(z,w.dstFilePath);if(S.startsWith(".."))continue;let F=f_(z,w.srcFilePath),G=X?l(S,X):Q;q.push({project:Q,type:w.type,srcFilePath:F,srcSymbolName:w.srcSymbolName??null,dstProject:G,dstFilePath:S,dstSymbolName:w.dstSymbolName??null,metaJson:w.metaJson??null,specifier:w.specifier??null,isExternal:0})}return W.replaceFileRelations(Q,J,q),q.length}import{isErr as NQ}from"@zipbul/result";var Q1=/(?:^|\s)@([a-zA-Z][\w-]*\w|[a-zA-Z])\s*(.*)$/m;function qQ(_){let $=N_(_),Q=[];for(let J of $){Q.push({name:J.name,startLine:J.span.start.line});for(let W of J.members??[])Q.push({name:`${J.name}.${W.name}`,startLine:W.span.start.line})}return Q.sort((J,W)=>J.startLine-W.startLine),Q}function A0(_,$,Q){let J=0,W=_.length-1;while(J<=W){let z=J+W>>1;if(_[z].startLine<=$)J=z+1;else W=z-1}if(J<_.length){let z=_[J];if(z.startLine-$<=Q)return z.name}return null}function e_(_,$,Q){let J=V_(_,$),W=V_(_,Q);return{start:J,end:W}}function J1(_){let{comments:$,sourceText:Q}=_;if(!$.length)return[];let J=h_(Q),W=qQ(_),z=[],Y=[...$].sort((X,K)=>X.start-K.start),Z=null;for(let X of Y)if(X.type==="Block"&&X.value.startsWith("*")){Z=null;let K=`/*${X.value}*/`,U=r_(K);if(NQ(U))continue;let L=U;if(!L.tags?.length)continue;let C=V_(J,X.end),q=A0(W,C.line,3),w=Q.slice(X.start,X.end);for(let S of L.tags){let F=[S.name,S.description].filter(Boolean).join(" "),G=`@${S.tag}`,E=w.indexOf(G),u;if(E>=0){let y=X.start+E,d=Q.indexOf(`
|
|
3
|
+
`)$.push(Q+1);return $}function V_(_,$){let Q=0,J=_.length-1;while(Q<J){let W=Q+J+1>>1;if(_[W]<=$)Q=W;else J=W-1}return{line:Q+1,column:$-_[Q]}}import{err as WQ}from"@zipbul/result";import{parse as zQ}from"comment-parser";function r_(_){try{let $=_.trim();if($.startsWith("/**"))$=$.slice(3);if($.endsWith("*/"))$=$.slice(0,-2);let J=zQ(`/** ${$} */`)[0]??{description:"",tags:[]};return{description:(J.description??"").trim(),tags:(J.tags??[]).map((W)=>({tag:W.tag??"",name:W.name??"",type:W.type??"",description:W.description??"",optional:W.optional??!1,...W.default!==void 0?{default:W.default}:{}}))}}catch($){return WQ(new O("parse","Failed to parse JSDoc comment",{cause:$}))}}import{isErr as ZQ}from"@zipbul/result";function YQ(_){if("name"in _&&typeof _.name==="string")return _.name;if("value"in _){let $=_.value;if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="bigint"||typeof $==="boolean")return String($)}return"unknown"}function k_(_){if(_.type==="Identifier")return[{name:_.name,start:_.start,end:_.end}];if(_.type==="ObjectPattern"){let $=[];for(let Q of _.properties)if(Q.type==="RestElement")$.push(...k_(Q.argument));else $.push(...k_(Q.value));return $}if(_.type==="ArrayPattern"){let $=[];for(let Q of _.elements){if(!Q)continue;if(Q.type==="RestElement")$.push(...k_(Q.argument));else $.push(...k_(Q))}return $}if(_.type==="AssignmentPattern")return k_(_.left);return[]}function XQ(_){let $=new Map;for(let Q of _.module.staticImports){let J=Q.moduleRequest.value;for(let W of Q.entries){let z=W.localName.value,Y=W.importName.kind==="Name"?W.importName.name:void 0,Z={specifier:J};if(Y&&Y!==z)Z.originalName=Y;$.set(z,Z)}}return $}function N_(_){let{program:$,sourceText:Q,comments:J}=_,W=h_(Q),z=XQ(_),Y=J.filter((I)=>I.type==="Block"&&I.value.startsWith("*")).sort((I,N)=>I.end-N.end),Z=$.body.map((I)=>I.start).sort((I,N)=>I-N);function X(I,N){return G(I,N)}function K(I,N,V){if(I.type==="PrivateIdentifier")return{kind:"private"};if(!N&&I.type==="Identifier")return;return X(I,V)}function U(I,N){if(N)return Q.slice(I.start,I.end);if(I.type==="PrivateIdentifier")return`#${I.name}`;return YQ(I)}function L(I,N,V){let H=I;if(!N&&H.type==="Identifier")return{kind:"string",value:H.name};return X(I,V)}function C(I,N){return{start:V_(W,I),end:V_(W,N)}}function q(I){let N=0,V=Y.length-1,H=-1;while(N<=V){let B=N+V>>>1;if(Y[B].end<=I)H=B,N=B+1;else V=B-1}if(H<0)return;let M=Y[H];N=0,V=Z.length-1;while(N<=V){let B=N+V>>>1,A=Z[B];if(A<=M.end)N=B+1;else if(A>=I)V=B-1;else return}return`/*${M.value}*/`}function w(I){if(!I)return;let N="typeAnnotation"in I&&I.typeAnnotation?I.typeAnnotation:I;return Q.slice(N.start,N.end)}let S=8;function F(I){if(I.type==="Identifier")return z.get(I.name);if(I.type==="MemberExpression"){let N=I.object;if(N.type==="Identifier")return z.get(N.name)}return}function G(I,N=0){let V=I;if(N>=S)return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)};let H=V.type;if(H==="Literal"){let M=V.value;if(typeof M==="bigint")return{kind:"bigint",value:typeof V.bigint==="string"?V.bigint:M.toString()};if(typeof V.regex==="object"&&V.regex!==null)return{kind:"regex",value:Q.slice(V.start,V.end)};if(M===null)return{kind:"null",value:null};if(typeof M==="string")return{kind:"string",value:M};if(typeof M==="number")return{kind:"number",value:M};if(typeof M==="boolean")return{kind:"boolean",value:M};return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}if(H==="Identifier"){let M=V.name;if(M==="undefined")return{kind:"undefined",value:null};let B=z.get(M),A={kind:"identifier",name:M};if(B){if(A.importSource=B.specifier,B.originalName)A.originalName=B.originalName}return A}if(H==="MemberExpression"){if(V.computed){let g=V.property;if(g.type==="Literal"&&typeof g.value==="string"){let j=V.object,v=Q.slice(j.start,j.end),m=j.type==="Identifier"?j.name:void 0,__=m?z.get(m):void 0,X_={kind:"member",object:v,property:g.value};if(__)X_.importSource=__.specifier;return X_}return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}let M=V.object,B=Q.slice(M.start,M.end),A=V.property.name??Q.slice(V.property.start,V.property.end),D=M.type==="Identifier"?M.name:void 0,T=D?z.get(D):void 0,R={kind:"member",object:B,property:A};if(T)R.importSource=T.specifier;return R}if(H==="CallExpression"){let M=V.callee,B=Q.slice(M.start,M.end),D=(V.arguments??[]).map((g)=>G(g,N+1)),T=F(M),R={kind:"call",callee:B,arguments:D};if(T)R.importSource=T.specifier;return R}if(H==="NewExpression"){let M=V.callee,B=Q.slice(M.start,M.end),D=(V.arguments??[]).map((g)=>G(g,N+1)),T=F(M),R={kind:"new",callee:B,arguments:D};if(T)R.importSource=T.specifier;return R}if(H==="ObjectExpression"){let M=V.properties??[],B=[];for(let A of M){if(A.type==="SpreadElement"){let m=A.argument;B.push({kind:"spread",argument:G(m,N+1)});continue}let D=A.key,T=A.computed===!0,R=A.value,g=A.shorthand||void 0,v={kind:"property",key:L(D,T,N+1),value:G(R,N+1)};if(g)v.shorthand=!0;B.push(v)}return{kind:"object",properties:B}}if(H==="ArrayExpression")return{kind:"array",elements:(V.elements??[]).map((A)=>{if(!A)return{kind:"undefined",value:null};return G(A,N+1)})};if(H==="SpreadElement"){let M=V.argument;return{kind:"spread",argument:G(M,N+1)}}if(H==="ArrowFunctionExpression"||H==="FunctionExpression"){let B=V.params.map(u),A={kind:"function",sourceText:Q.slice(V.start,V.end)};if(B.length>0)A.parameters=B;return A}if(H==="TemplateLiteral"||H==="TaggedTemplateExpression")return{kind:"template",sourceText:Q.slice(V.start,V.end)};if(H==="UnaryExpression"){let{operator:M,argument:B}=V;if(M==="-"&&B.type==="Literal"&&typeof B.value==="number")return{kind:"number",value:-B.value};if(M==="void")return{kind:"undefined",value:null};return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}if(H==="TSAsExpression"||H==="TSSatisfiesExpression"||H==="TSNonNullExpression"||H==="TSTypeAssertion"||H==="TSInstantiationExpression"||H==="ParenthesizedExpression"||H==="ChainExpression"){let M=V.expression;if(M)return G(M,N)}return{kind:"unresolvable",sourceText:Q.slice(V.start,V.end)}}function E(I){if(!I||I.length===0)return[];return I.map((N)=>{let V=N.expression;if(V.type==="CallExpression"){let H=V,M=H.callee,B="name"in M&&typeof M.name==="string"?M.name:("property"in M)&&M.property&&typeof M.property.name==="string"?M.property.name:"unknown",A=H.arguments.map((D)=>G(D));return{name:B,arguments:A.length>0?A:void 0}}if(V.type==="Identifier")return{name:V.name??"unknown"};return{name:Q.slice(V.start,V.end)}})}function u(I){if(I.type==="TSParameterProperty"){let V=I;return d(V.parameter,V.decorators)}if(I.type==="RestElement"){let V=I,H=V.argument,B=`...${"name"in H&&typeof H.name==="string"?H.name:"unknown"}`,A=V.typeAnnotation,D=A?w(A):void 0,T={name:B,isOptional:!1};if(D)T.type=D;return T}let N=I;return d(N,N.decorators)}function y(I){if(!I)return;let N="typeAnnotation"in I&&I.typeAnnotation?I.typeAnnotation:null;if(!N)return;let H=N.typeName?.name;if(!H)return;return z.get(H)?.specifier}function d(I,N){if(I.type==="AssignmentPattern"){let{left:R,right:g}=I,j="name"in R&&typeof R.name==="string"?R.name:"unknown",v="typeAnnotation"in R?R.typeAnnotation:null,m=v?w(v):void 0,__=y(v),X_=Q.slice(g.start,g.end),K_="decorators"in R&&Array.isArray(R.decorators)?R.decorators:[],Y0=E(K_),D_={name:j,isOptional:!0,defaultValue:X_};if(m)D_.type=m;if(__)D_.typeImportSource=__;if(Y0.length>0)D_.decorators=Y0;return D_}let V="name"in I&&typeof I.name==="string"?I.name:("pattern"in I)&&I.pattern&&typeof I.pattern.name==="string"?I.pattern.name:"unknown",H=!!(("optional"in I)&&I.optional),M="typeAnnotation"in I?I.typeAnnotation:null,B=M?w(M):void 0,A=y(M),D=E(N??[]),T={name:V,isOptional:H};if(B)T.type=B;if(A)T.typeImportSource=A;if(D.length>0)T.decorators=D;return T}function p(I,N){let V=[];if(N?.async)V.push("async");if(I.static)V.push("static");if(I.abstract)V.push("abstract");if(I.readonly)V.push("readonly");if(I.override)V.push("override");if(I.declare)V.push("declare");if(I.const)V.push("const");let H=I.accessibility;if(H==="private")V.push("private");else if(H==="protected")V.push("protected");else if(H==="public")V.push("public");return V}function J_(I){if(!I)return;let N=I.params.flatMap((V)=>{let H=V.name.name;return H?[H]:[]});return N.length>0?N:void 0}function Z_(I){let N=[];if(I.superClass){let H=Q.slice(I.superClass.start,I.superClass.end);N.push({kind:"extends",name:H})}let V=I.implements??[];for(let H of V){let M=H.expression,B=Q.slice(M.start,M.end);N.push({kind:"implements",name:B})}return N}function O_(I){let N=[],V=I.extends;for(let H of V){let M=H.expression,B=Q.slice(M.start,M.end);N.push({kind:"extends",name:B})}return N}function Y_(I){let N=[];for(let V of I)if(V.type==="MethodDefinition"||V.type==="TSAbstractMethodDefinition"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=H.value,D=H.kind,T=D==="constructor"?"constructor":D==="get"?"getter":D==="set"?"setter":"method",R=p(H,A);if(V.type==="TSAbstractMethodDefinition"&&!R.includes("abstract"))R.push("abstract");let g=A.params.map(u),j=w(A.returnType),v=E(H.decorators??[]),m={kind:"method",name:M,span:C(V.start,V.end),isExported:!1,methodKind:T,modifiers:R,parameters:g.length>0?g:void 0,returnType:j};if(B)m.key=B;if(v.length>0)m.decorators=v;N.push(m)}else if(V.type==="PropertyDefinition"||V.type==="TSAbstractPropertyDefinition"||V.type==="AccessorProperty"||V.type==="TSAbstractAccessorProperty"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=p(H);if(V.type==="TSAbstractPropertyDefinition"||V.type==="TSAbstractAccessorProperty"){if(!A.includes("abstract"))A.push("abstract")}if(V.type==="AccessorProperty"||V.type==="TSAbstractAccessorProperty")A.push("accessor");let D=w(H.typeAnnotation),T=H.value,R=T?G(T):void 0,g=E(H.decorators??[]),j={kind:"property",name:M,span:C(V.start,V.end),isExported:!1,modifiers:A,returnType:D,initializer:R};if(B)j.key=B;if(g.length>0)j.decorators=g;N.push(j)}return N}function W_(I){let N=[];for(let V of I)if(V.type==="TSMethodSignature"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=H.params.map(u),D=w(H.returnType),T={kind:"method",name:M,span:C(V.start,V.end),isExported:!1,modifiers:[],methodKind:"method",parameters:A.length>0?A:void 0,returnType:D};if(B)T.key=B;N.push(T)}else if(V.type==="TSPropertySignature"){let H=V,M=U(H.key,H.computed),B=K(H.key,H.computed,0),A=w(H.typeAnnotation),D={kind:"property",name:M,span:C(V.start,V.end),isExported:!1,modifiers:H.readonly?["readonly"]:[],returnType:A};if(B)D.key=B;N.push(D)}return N}function i(I,N){let V=I.type;if(V==="FunctionDeclaration"||V==="FunctionExpression"||V==="TSDeclareFunction"||V==="TSEmptyBodyFunctionExpression"){let H=I,M=H.id?.name??"default",B=H.params.map(u),A=w(H.returnType),D=p(H,H),T=E(H.decorators??[]),R=J_(H.typeParameters),g={kind:"function",name:M,span:C(I.start,I.end),isExported:N,modifiers:D,parameters:B.length>0?B:void 0,returnType:A,decorators:T.length>0?T:void 0};if(R&&R.length>0)g.typeParameters=R;return g}if(V==="ClassDeclaration"||V==="ClassExpression"){let H=I,M=H.id?.name??"default",B=Z_(H),A=Y_(H.body.body),D=E(H.decorators),T=p(H),R=J_(H.typeParameters),g={kind:"class",name:M,span:C(I.start,I.end),isExported:N,modifiers:T,heritage:B.length>0?B:void 0,members:A.length>0?A:void 0,decorators:D.length>0?D:void 0};if(R&&R.length>0)g.typeParameters=R;return g}if(V==="VariableDeclaration"){let H=I,M=[];for(let B of H.declarations){let{id:A,init:D}=B;if(A.type==="ObjectPattern"||A.type==="ArrayPattern"){let X_=k_(A);for(let K_ of X_)M.push({kind:"variable",name:K_.name,span:C(K_.start,K_.end),isExported:N,modifiers:[]});continue}let T="name"in A&&typeof A.name==="string"?A.name:"unknown",R="variable",g,j,v;if(D)if(D.type==="FunctionExpression"||D.type==="ArrowFunctionExpression"){R="function";let X_=D;g=X_.params.map(u),j=w(X_.returnType)}else v=G(D);let m=[],__={kind:R,name:T,span:C(B.start,B.end),isExported:N,modifiers:m,parameters:g,returnType:j};if(v)__.initializer=v;M.push(__)}if(M.length===0)return null;if(M.length===1)return M[0];return M}if(V==="TSTypeAliasDeclaration")return{kind:"type",name:I.id.name,span:C(I.start,I.end),isExported:N,modifiers:[]};if(V==="TSInterfaceDeclaration"){let H=I,M=H.id.name,B=O_(H),A=W_(H.body.body),D=J_(H.typeParameters),T={kind:"interface",name:M,span:C(I.start,I.end),isExported:N,modifiers:[],heritage:B.length>0?B:void 0,members:A.length>0?A:void 0};if(D&&D.length>0)T.typeParameters=D;return T}if(V==="TSEnumDeclaration"){let H=I,M=H.id.name,B=p(H),D=H.body.members.map((T)=>{let R=T.id,g=R.type!=="Identifier",j="name"in R&&typeof R.name==="string"?R.name:("value"in R)&&typeof R.value==="string"?R.value:"unknown",v=T.initializer?G(T.initializer):void 0,m={kind:"property",name:j,span:C(T.start,T.end),isExported:!1,modifiers:[]};if(g)m.key=X(R,0);if(v)m.initializer=v;return m});return{kind:"enum",name:M,span:C(I.start,I.end),isExported:N,modifiers:B,members:D.length>0?D:void 0}}if(V==="TSModuleDeclaration"){let H=I,M=H.id.name??H.id.value??"unknown",B=p(H),A=[];if(H.body?.type==="TSModuleBlock")for(let D of H.body.body??[]){if(D.type!=="ExportNamedDeclaration")continue;let T=D.declaration;if(!T)continue;let R=i(T,!1);if(R)if(Array.isArray(R))A.push(...R);else A.push(R)}return{kind:"namespace",name:M,span:C(I.start,I.end),isExported:N,modifiers:B,members:A.length>0?A:void 0}}return null}let c=[],w_=new Set;for(let I of $.body){let N=null,V=I;if(V.type==="ExportNamedDeclaration"){let M=V;if(M.declaration){if(N=i(M.declaration,!0),N&&!Array.isArray(N))N.span=C(M.start,M.end)}else if(!M.source&&M.specifiers)for(let B of M.specifiers){let A=B.local,D="name"in A?A.name:A.value;if(D)w_.add(D)}}else if(V.type==="ExportDefaultDeclaration"){let M=V,B=M.declaration;if(B){if(N=i(B,!0),N&&!Array.isArray(N))N.name="id"in B&&B.id&&typeof B.id.name==="string"?B.id.name:"default",N.isExported=!0,N.span=C(M.start,M.end);else if(!N&&"type"in B&&B.type==="Identifier"){let A=B.name;if(A)w_.add(A)}}}else{let M=V.type;if(M==="FunctionDeclaration"||M==="TSDeclareFunction"||M==="ClassDeclaration"||M==="VariableDeclaration"||M==="TSTypeAliasDeclaration"||M==="TSInterfaceDeclaration"||M==="TSEnumDeclaration"||M==="TSModuleDeclaration")N=i(V,!1)}let H=Array.isArray(N)?N:N?[N]:[];for(let M of H){let B=I.start,A=q(B);if(A){let D=r_(A);if(!ZQ(D))M.jsDoc=D}c.push(M)}}if(w_.size>0){for(let I of c)if(!I.isExported&&w_.has(I.name))I.isExported=!0}return c}function o_(_){if(_===null||typeof _!=="object")return JSON.stringify(_);if(Array.isArray(_))return`[${_.map(o_).join(",")}]`;let $=_;return`{${Object.keys($).sort().map((J)=>`${JSON.stringify(J)}:${o_($[J])}`).join(",")}}`}function VQ(_){if(_.kind==="function"||_.kind==="method"){let $=_.parameters?.length??0,Q=_.modifiers.includes("async")?1:0;return`params:${$}|async:${Q}`}return null}function UQ(_){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(_.initializer)$.initializer=_.initializer;if(_.key)$.key=_.key;if(_.members?.length)$.members=_.members.map((Q)=>{let J=Q.modifiers.find((z)=>z==="private"||z==="protected"||z==="public"),W={name:Q.name,kind:Q.methodKind??Q.kind,type:Q.returnType,visibility:J,isStatic:Q.modifiers.includes("static")||void 0,isReadonly:Q.modifiers.includes("readonly")||void 0,isAccessor:Q.modifiers.includes("accessor")||void 0};if(Q.key)W.key=Q.key;if(Q.initializer)W.initializer=Q.initializer;if(Q.decorators?.length)W.decorators=Q.decorators;return W});return Object.keys($).length>0?JSON.stringify($):null}function OQ(_){let $=[_.kind];if(_.modifiers.length)$.push(`mod:${[..._.modifiers].sort().join(",")}`);if(_.typeParameters?.length)$.push(`tp:${_.typeParameters.length}`);if(_.heritage?.length){let Q=[..._.heritage].sort((J,W)=>J.name.localeCompare(W.name)).map((J)=>`${J.kind}:${J.name}`).join(",");$.push(`her:${Q}`)}if(_.decorators?.length)$.push(`dec:${[..._.decorators].map((Q)=>Q.name).sort().join(",")}`);if(_.methodKind)$.push(`mk:${_.methodKind}`);if(_.parameters)$.push(`p:${_.parameters.length}`);if(_.returnType)$.push(`rt:${_.returnType}`);if(_.key)$.push(`k:${o_(_.key)}`);if(_.members?.length){let Q=_.members.map((J)=>`${J.kind}:${J.modifiers.join(",")}:${J.parameters?.length??""}:${J.returnType??""}:${J.key?o_(J.key):""}`).sort().join(";");$.push(`mem:${_.members.length}:${U_(Q)}`)}return U_($.join("|"))}function o0(_,$,Q,J,W){let z=VQ(_),Y=U_(`${$}|${_.kind}|${z??""}`),Z=OQ(_);return{project:Q,filePath:J,kind:_.kind,name:$,startLine:_.span.start.line,startColumn:_.span.start.column,endLine:_.span.end.line,endColumn:_.span.end.column,isExported:_.isExported?1:0,signature:z,fingerprint:Y,detailJson:UQ(_),contentHash:W,indexedAt:new Date().toISOString(),structuralFingerprint:Z}}function w0(_){let{parsed:$,project:Q,filePath:J,contentHash:W,symbolRepo:z}=_,Y=N_($),Z=[];for(let X of Y){Z.push(o0(X,X.name,Q,J,W));for(let K of X.members??[])Z.push(o0(K,`${X.name}.${K.name}`,Q,J,W))}z.replaceFileSymbols(Q,J,W,Z)}import{resolve as D0,dirname as HQ,extname as MQ}from"path";function q_(_,$,Q){let J=(W)=>{let z=MQ(W);if(z===".js")return[W.slice(0,-3)+".ts"];if(z===".mjs")return[W.slice(0,-4)+".mts"];if(z===".cjs")return[W.slice(0,-4)+".cts"];if(z===".ts"||z===".mts"||z===".cts"||z===".d.ts")return[W];return[W+".ts",W+".d.ts",W+"/index.ts",W+"/index.d.ts",W+".mts",W+"/index.mts",W+".cts",W+"/index.cts"]};if($.startsWith(".")){let W=Q_(D0(HQ(_),$));return J(W)}if(Q)for(let[W,z]of Q.paths){if(z.length===0)continue;let Y=W.indexOf("*");if(Y===-1){if($===W){let Z=[];for(let X of z)Z.push(...J(Q_(D0(Q.baseUrl,X))));return Z}}else{let Z=W.slice(0,Y),X=W.slice(Y+1);if($.startsWith(Z)&&(X===""||$.endsWith(X))){let K=$.slice(Z.length,X===""?void 0:$.length-X.length),U=[];for(let L of z)U.push(...J(Q_(D0(Q.baseUrl,L.replace("*",K)))));return U}}}return[]}function t0(_,$,Q,J=q_){let W=new Map,z=_.body??[];for(let Y of z){if(Y.type!=="ImportDeclaration")continue;let Z=Y.source?.value??"",X=J($,Z,Q);if(X.length===0)continue;let K=X[0],U=Y.specifiers??[];for(let L of U)switch(L.type){case"ImportSpecifier":W.set(L.local.name,{path:K,importedName:L.imported.name});break;case"ImportDefaultSpecifier":W.set(L.local.name,{path:K,importedName:"default"});break;case"ImportNamespaceSpecifier":W.set(L.local.name,{path:K,importedName:"*"});break}}return W}import{Visitor as KQ}from"oxc-parser";function t_(_){return"name"in _&&typeof _.name==="string"?_.name:("value"in _)&&typeof _.value==="string"?_.value:"unknown"}function LQ(_){return!_.startsWith(".")&&!_.startsWith("/")}function R_(_,$,Q,J){let W=J(_,$,Q),z=W.length>0?W[0]:null,Y=z===null&&LQ($);return{resolved:z,isExternal:Y}}function BQ(_,$,Q,J,W){for(let z of _.staticImports){let Y=z.moduleRequest.value,{resolved:Z,isExternal:X}=R_($,Y,Q,J),K={dstFilePath:Z,specifier:Y};if(z.entries.length===0){let U={};if(X)U.isExternal=!0;if(Z===null&&!X)U.isUnresolved=!0;W.push({type:"imports",srcFilePath:$,srcSymbolName:null,...K,dstSymbolName:null,...Object.keys(U).length>0?{metaJson:JSON.stringify(U)}:{}});continue}for(let U of z.entries){let L=U.isType,C={};if(L)C.isType=!0;if(X)C.isExternal=!0;if(Z===null&&!X)C.isUnresolved=!0;let q,w,S=U.importName.kind;if(S==="Default")q="default",w=U.localName.value;else if(S==="NamespaceObject")q="*",w=U.localName.value,C.importKind="namespace";else q=U.importName.name??"unknown",w=U.localName.value;W.push({type:L?"type-references":"imports",srcFilePath:$,srcSymbolName:w,...K,dstSymbolName:q,...Object.keys(C).length>0?{metaJson:JSON.stringify(C)}:{}})}}}function wQ(_,$,Q,J,W){let z=new Map;for(let Y of _.staticImports)for(let Z of Y.entries)z.set(Z.localName.value,Y.moduleRequest.value);for(let Y of _.staticExports)for(let Z of Y.entries){let X=null;if(Z.moduleRequest)X=Z.moduleRequest.value;else if(Z.localName.name)X=z.get(Z.localName.name)??null;if(!X)continue;let{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.exportName.name??"default",C=Z.exportName.kind,q=Z.localName.name??Z.importName.name??L,w=Z.isType,S={isReExport:!0};if(C==="None");else S.specifiers=[{local:q,exported:L}];if(w)S.isType=!0;if(U)S.isExternal=!0;if(K===null&&!U)S.isUnresolved=!0;let F=null,G=null,E=Z.importName.kind;if(E==="All"||E==="AllButDefault"){if(C==="Name"&&L)G=L,S.namespaceAlias=L}else G=q,F=L;W.push({type:w?"type-references":"re-exports",srcFilePath:$,srcSymbolName:F,dstFilePath:K,dstSymbolName:G,specifier:X,metaJson:JSON.stringify(S)})}}function DQ(_,$,Q,J,W){for(let z of _.body){let Y=z;if(Y.type==="ImportDeclaration"){let Z=Y,X=Z.source.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.importKind==="type",C=Z.specifiers,q={dstFilePath:K,specifier:X};if(C.length===0){let w={};if(L)w.isType=!0;if(U)w.isExternal=!0;if(K===null&&!U)w.isUnresolved=!0;W.push({type:L?"type-references":"imports",srcFilePath:$,srcSymbolName:null,...q,dstSymbolName:null,...Object.keys(w).length>0?{metaJson:JSON.stringify(w)}:{}})}else for(let w of C){let S=w.type,F=L||S==="ImportSpecifier"&&w.importKind==="type",G={};if(F)G.isType=!0;if(U)G.isExternal=!0;if(K===null&&!U)G.isUnresolved=!0;let E,u;if(S==="ImportDefaultSpecifier")E="default",u=w.local.name;else if(S==="ImportNamespaceSpecifier")E="*",u=w.local.name,G.importKind="namespace";else E=t_(w.imported),u=w.local.name;W.push({type:F?"type-references":"imports",srcFilePath:$,srcSymbolName:u,...q,dstSymbolName:E,...Object.keys(G).length>0?{metaJson:JSON.stringify(G)}:{}})}continue}if(Y.type==="ExportAllDeclaration"){let Z=Y,X=Z.source.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.exportKind==="type",C=Z.exported,q=C?t_(C):null,w={isReExport:!0};if(L)w.isType=!0;if(U)w.isExternal=!0;if(K===null&&!U)w.isUnresolved=!0;if(q)w.namespaceAlias=q;W.push({type:L?"type-references":"re-exports",srcFilePath:$,srcSymbolName:null,dstFilePath:K,dstSymbolName:q,specifier:X,metaJson:JSON.stringify(w)});continue}if(Y.type==="ExportNamedDeclaration"){let Z=Y;if(!Z.source)continue;let X=Z.source.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L=Z.exportKind==="type",C=Z.specifiers??[];for(let q of C){let w=L||q.exportKind==="type",S=t_(q.local),F=t_(q.exported),G={isReExport:!0,specifiers:[{local:S,exported:F}]};if(w)G.isType=!0;if(U)G.isExternal=!0;if(K===null&&!U)G.isUnresolved=!0;W.push({type:w?"type-references":"re-exports",srcFilePath:$,srcSymbolName:F,dstFilePath:K,dstSymbolName:S,specifier:X,metaJson:JSON.stringify(G)})}}}}function IQ(_,$,Q,J,W){new KQ({ImportExpression(Y){let Z=Y.source;if(Z.type!=="Literal"||typeof Z.value!=="string")return;let X=Z.value,{resolved:K,isExternal:U}=R_($,X,Q,J),L={isDynamic:!0};if(U)L.isExternal=!0;if(K===null&&!U)L.isUnresolved=!0;W.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:K,dstSymbolName:null,specifier:X,metaJson:JSON.stringify(L)})},CallExpression(Y){let Z=Y.callee,X=!1;if(Z.type==="Identifier"&&Z.name==="require");else if(Z.type==="MemberExpression"&&!Z.computed){let S=Z,F=S.object,G=S.property;if(F.type==="Identifier"&&F.name==="require"&&G.name==="resolve")X=!0;else return}else return;let K=Y.arguments;if(K.length===0)return;let U=K[0];if(U.type!=="Literal"||typeof U.value!=="string")return;let L=U.value,{resolved:C,isExternal:q}=R_($,L,Q,J),w={isRequire:!0};if(X)w.isRequireResolve=!0;if(q)w.isExternal=!0;if(C===null&&!q)w.isUnresolved=!0;W.push({type:"imports",srcFilePath:$,srcSymbolName:null,dstFilePath:C,dstSymbolName:null,specifier:L,metaJson:JSON.stringify(w)})}}).visit(_)}function e0(_,$,Q,J=q_,W){let z=[];if(W)BQ(W,$,Q,J,z),wQ(W,$,Q,J,z);else DQ(_,$,Q,J,z);return IQ(_,$,Q,J,z),z}import{walk as CQ}from"oxc-walker";function u_(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let $=_;if($.type==="Identifier"){let Q=$.name;return{root:Q,parts:[],full:Q}}if($.type==="ThisExpression")return{root:"this",parts:[],full:"this"};if($.type==="Super")return{root:"super",parts:[],full:"super"};if($.type==="MemberExpression"){let Q=[],J=$;while(J.type==="MemberExpression"){let Y=J.property;if(!Y||typeof Y.name!=="string")return null;Q.push(Y.name),J=J.object}let W;if(J.type==="Identifier")W=J.name;else if(J.type==="ThisExpression")W="this";else if(J.type==="Super")W="super";else return null;Q.reverse();let z=[W,...Q].join(".");return{root:W,parts:Q,full:z}}return null}function _1(_,$,Q){let J=[],W=[],z=[];function Y(){if(W.length>0)return W[W.length-1]??null;return null}function Z(U){if(!U)return null;let L=Q.get(U.root);if(U.parts.length===0){if(L)return{dstFilePath:L.path,dstSymbolName:L.importedName,resolution:"import"};return{dstFilePath:$,dstSymbolName:U.root,resolution:"local"}}else{if(L&&L.importedName==="*"){let C=U.parts[U.parts.length-1];return{dstFilePath:L.path,dstSymbolName:C,resolution:"namespace"}}return{dstFilePath:$,dstSymbolName:U.full,resolution:"local-member"}}}function X(U,L){let C=u_(U.callee),q=Z(C);if(q){let w=Y(),S={};if(L)S.isNew=!0;if(w===null)S.scope="module";J.push({type:"calls",srcFilePath:$,srcSymbolName:w,dstFilePath:q.dstFilePath,dstSymbolName:q.dstSymbolName,...Object.keys(S).length>0?{metaJson:JSON.stringify(S)}:{}})}}function K(U,L){if(U.type==="FunctionDeclaration"){W.push(U.id?.name??"anonymous");return}if(U.type==="FunctionExpression"||U.type==="ArrowFunctionExpression"){if(L?.type==="VariableDeclarator"){let w=L.id,S=w.type==="Identifier"?w.name:"anonymous";W.push(S);return}if(L?.type==="MethodDefinition"||L?.type==="TSAbstractMethodDefinition"){let w=L.key,S=z[z.length-1]??"",F="name"in w?w.name:"anonymous",G=S?`${S}.${F}`:F;W.push(G);return}let C=Y(),q=C?`${C}.<anonymous>`:"<anonymous>";W.push(q)}}return CQ(_,{enter(U,L){if(U.type==="ClassDeclaration"||U.type==="ClassExpression"){z.push(U.id?.name??"AnonymousClass");return}if(U.type==="FunctionDeclaration"||U.type==="FunctionExpression"||U.type==="ArrowFunctionExpression"){K(U,L);return}if(U.type==="CallExpression"){X(U,!1);return}if(U.type==="NewExpression"){X(U,!0);return}},leave(U){if(U.type==="ClassDeclaration"||U.type==="ClassExpression"){z.pop();return}if(U.type==="FunctionDeclaration"||U.type==="FunctionExpression"||U.type==="ArrowFunctionExpression"){W.pop();return}}}),J}import{Visitor as AQ}from"oxc-parser";function $1(_,$,Q){let J=[];function W(Y){let Z=Y.id?.name??"AnonymousClass";if(Y.superClass){let K=u_(Y.superClass);if(K){let U=I0(K,$,Q);J.push({type:"extends",srcFilePath:$,srcSymbolName:Z,...U})}}let X=Y.implements??[];for(let K of X){let U=u_(K.expression);if(!U)continue;let L=I0(U,$,Q);J.push({type:"implements",srcFilePath:$,srcSymbolName:Z,...L})}}return new AQ({TSInterfaceDeclaration(Y){let Z=Y.id.name??"AnonymousInterface",X=Y.extends;for(let K of X){let U=u_(K.expression);if(!U)continue;let L=I0(U,$,Q);J.push({type:"extends",srcFilePath:$,srcSymbolName:Z,...L})}},ClassDeclaration(Y){W(Y)},ClassExpression(Y){W(Y)}}).visit(_),J}function I0(_,$,Q){let J=Q.get(_.root);if(J){if(J.importedName==="*"){let W=_.parts[_.parts.length-1]??_.root;return{dstFilePath:J.path,dstSymbolName:W,metaJson:JSON.stringify({isNamespaceImport:!0})}}return{dstFilePath:J.path,dstSymbolName:_.parts.length>0?_.full:J.importedName}}return{dstFilePath:$,dstSymbolName:_.full,metaJson:JSON.stringify({isLocal:!0})}}function n_(_,$,Q,J=q_,W){let z=t0(_,$,Q,J),Y=e0(_,$,Q,J,W),Z=_1(_,$,z),X=$1(_,$,z);return[...Y,...Z,...X]}function C0(_){let{ast:$,project:Q,filePath:J,relationRepo:W,projectRoot:z,tsconfigPaths:Y,knownFiles:Z,boundaries:X,module:K}=_,U=g_(z,J),C=n_($,U,Y,Z?(w,S,F)=>{let G=q_(w,S,F);for(let E of G){let u=f_(z,E);if(X){let y=l(u,X);if(Z.has(`${y}::${u}`))return[E]}else if(Z.has(`${Q}::${u}`))return[E]}return[]}:void 0,K),q=[];for(let w of C){if(w.dstFilePath===null){let E=f_(z,w.srcFilePath),u;if(w.metaJson)try{u=JSON.parse(w.metaJson)}catch{}let y=u?.isExternal===!0;q.push({project:Q,type:w.type,srcFilePath:E,srcSymbolName:w.srcSymbolName??null,dstProject:null,dstFilePath:null,dstSymbolName:w.dstSymbolName??null,metaJson:w.metaJson??null,specifier:w.specifier??null,isExternal:y?1:0});continue}let S=f_(z,w.dstFilePath);if(S.startsWith(".."))continue;let F=f_(z,w.srcFilePath),G=X?l(S,X):Q;q.push({project:Q,type:w.type,srcFilePath:F,srcSymbolName:w.srcSymbolName??null,dstProject:G,dstFilePath:S,dstSymbolName:w.dstSymbolName??null,metaJson:w.metaJson??null,specifier:w.specifier??null,isExternal:0})}return W.replaceFileRelations(Q,J,q),q.length}import{isErr as NQ}from"@zipbul/result";var Q1=/(?:^|\s)@([a-zA-Z][\w-]*\w|[a-zA-Z])\s*(.*)$/m;function qQ(_){let $=N_(_),Q=[];for(let J of $){Q.push({name:J.name,startLine:J.span.start.line});for(let W of J.members??[])Q.push({name:`${J.name}.${W.name}`,startLine:W.span.start.line})}return Q.sort((J,W)=>J.startLine-W.startLine),Q}function A0(_,$,Q){let J=0,W=_.length-1;while(J<=W){let z=J+W>>1;if(_[z].startLine<=$)J=z+1;else W=z-1}if(J<_.length){let z=_[J];if(z.startLine-$<=Q)return z.name}return null}function e_(_,$,Q){let J=V_(_,$),W=V_(_,Q);return{start:J,end:W}}function J1(_){let{comments:$,sourceText:Q}=_;if(!$.length)return[];let J=h_(Q),W=qQ(_),z=[],Y=[...$].sort((X,K)=>X.start-K.start),Z=null;for(let X of Y)if(X.type==="Block"&&X.value.startsWith("*")){Z=null;let K=`/*${X.value}*/`,U=r_(K);if(NQ(U))continue;let L=U;if(!L.tags?.length)continue;let C=V_(J,X.end),q=A0(W,C.line,3),w=Q.slice(X.start,X.end);for(let S of L.tags){let F=[S.name,S.description].filter(Boolean).join(" "),G=`@${S.tag}`,E=w.indexOf(G),u;if(E>=0){let y=X.start+E,d=Q.indexOf(`
|
|
4
4
|
`,y),p=d>=0?Math.min(d,X.end):X.end;u=e_(J,y,p)}else u=e_(J,X.start,X.end);z.push({tag:S.tag,value:F,source:"jsdoc",span:u,symbolName:q})}}else if(X.type==="Block"){Z=null;let K=X.value.split(`
|
|
5
5
|
`),U=0;for(let L of K){let C=L.replace(/^\s*\*?\s?/,""),q=Q1.exec(C);if(q){let w=q[1],S=q[2]?.trim()??"",F=`@${w}`,G=L.indexOf(F),E=X.start+2+U+(G>=0?G:0),u=X.start+2+U+L.length,y=e_(J,E,u),d=V_(J,X.end),p=A0(W,d.line,3);z.push({tag:w,value:S,source:"block",span:y,symbolName:p})}U+=L.length+1}}else{let K=X.value,U=Q1.exec(K),L=V_(J,X.start),C=V_(J,X.end);if(U){let q=U[1],w=U[2]?.trim()??"",S=`@${q}`,F=K.indexOf(S),G=X.start+2+(F>=0?F:0),E=e_(J,G,X.end),u=A0(W,C.line,3),y={tag:q,value:w,source:"line",span:E,symbolName:u};z.push(y),Z={annotation:y,endLine:C.line}}else if(Z&&L.line===Z.endLine+1){let q=K.trim();if(q)Z.annotation.value+=" "+q,Z.annotation.span.end=V_(J,X.end),Z.endLine=C.line}else Z=null}return z}function N0(_){let{parsed:$,project:Q,filePath:J,annotationRepo:W}=_,z=J1($);if(W.deleteFileAnnotations(Q,J),!z.length)return 0;let Y=new Date().toISOString(),Z=z.map((X)=>({project:Q,filePath:J,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:Y}));return W.insertBatch(Q,J,Z),z.length}function W1(_,$){let Q=[],J=[],W=[];for(let[U,L]of $)if(!_.has(U))Q.push({name:L.name,filePath:L.filePath,kind:L.kind,fingerprint:L.fingerprint});for(let[U,L]of _)if(!$.has(U))J.push({name:L.name,filePath:L.filePath,kind:L.kind,fingerprint:L.fingerprint});if(!Q.length||!J.length)return{renamed:W,added:Q,removed:J};let z=new Map,Y=new Map;for(let U of Q){let L=z.get(U.filePath)??[];L.push(U),z.set(U.filePath,L)}for(let U of J){let L=Y.get(U.filePath)??[];L.push(U),Y.set(U.filePath,L)}let Z=new Set,X=new Set;for(let[U,L]of z){let C=Y.get(U);if(!C)continue;for(let q of new Set(L.map((w)=>w.kind))){let w=L.filter((u)=>u.kind===q&&!Z.has(u)),S=C.filter((u)=>u.kind===q&&!X.has(u));if(!w.length||!S.length)continue;let F=(u,y)=>{return y.get(`${u.filePath}::${u.name}`)?.structuralFingerprint??null},G=(u,y)=>{return y.get(`${u.filePath}::${u.name}`)?.startLine??0},E=new Map;for(let u of S){let y=F(u,_);if(!y)continue;let d=E.get(y)??[];d.push(u),E.set(y,d)}for(let u of w){if(Z.has(u))continue;let y=F(u,$);if(!y)continue;let d=E.get(y);if(!d)continue;let p=d.filter((Z_)=>!X.has(Z_));if(!p.length)continue;let J_=p[0];if(p.length>1){let Z_=G(u,$),O_=Math.abs(G(J_,_)-Z_);for(let Y_=1;Y_<p.length;Y_++){let W_=Math.abs(G(p[Y_],_)-Z_);if(W_<O_)O_=W_,J_=p[Y_]}}W.push({oldName:J_.name,newName:u.name,filePath:U,kind:q}),Z.add(u),X.add(J_)}}}let K=W.filter((U)=>!U.oldName.includes("."));for(let U of K){let L=`${U.oldName}.`,C=`${U.newName}.`,q=J.filter((S)=>S.filePath===U.filePath&&S.name.startsWith(L)&&!X.has(S)),w=Q.filter((S)=>S.filePath===U.filePath&&S.name.startsWith(C)&&!Z.has(S));for(let S of q){let F=S.name.slice(L.length),G=w.find((E)=>E.name.slice(C.length)===F);if(G)W.push({oldName:S.name,newName:G.name,filePath:U.filePath,kind:S.kind}),Z.add(G),X.add(S)}}return{renamed:W,added:Q.filter((U)=>!Z.has(U)),removed:J.filter((U)=>!X.has(U))}}var RQ=100,Z1=50;class q0{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=x_(_.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")){s_(this.opts.projectRoot),this.tsconfigPathsRaw=x_(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??a_;this.boundariesRefresh=$(this.opts.projectRoot).then((Q)=>{this.opts.boundaries=Q,this.opts.onBoundariesChanged?.(Q)}),this.fullIndex().catch((Q)=>{this.logger.error("[IndexCoordinator] fullIndex failed after package.json change:",Q)});return}if(this.pendingEvents.push(_),this.debounceTimer===null)this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.flushPending()},RQ)}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((J,W)=>{this.pendingFullIndexWaiters.push({resolve:J,reject:W})});return this.currentIndexing}this.indexingLock=!0;let Q=this.doIndex(_,$).then((J)=>{return this.fireCallbacks(J),J}).finally(()=>{if(this.indexingLock=!1,this.currentIndexing=null,this.pendingFullIndex){this.pendingFullIndex=!1;let J=this.pendingFullIndexWaiters.splice(0);this.startIndex(void 0,!0).then((W)=>{for(let z of J)z.resolve(W)}).catch((W)=>{for(let z of J)z.reject(W)})}else if(this.pendingEvents.length>0){let J=this.pendingEvents.splice(0);this.startIndex(J,!1).catch((W)=>this.logger.error("[IndexCoordinator] incremental drain error",W))}});return this.currentIndexing=Q,Q}async doIndex(_,$){let Q=Date.now(),{fileRepo:J,symbolRepo:W,relationRepo:z,dbConnection:Y}=this.opts;if(this.boundariesRefresh)await this.boundariesRefresh,this.boundariesRefresh=null;let Z,X;if(_!==void 0)Z=_.filter((V)=>V.eventType==="create"||V.eventType==="change").map((V)=>({filePath:V.filePath,contentHash:"",mtimeMs:0,size:0})),X=_.filter((V)=>V.eventType==="delete").map((V)=>V.filePath);else{let V=new Map;for(let M of this.opts.boundaries)for(let[B,A]of J.getFilesMap(M.project))V.set(B,A);let H=await r0({projectRoot:this.opts.projectRoot,extensions:this.opts.extensions,ignorePatterns:this.opts.ignorePatterns,fileRepo:{getFilesMap:()=>V}});Z=H.changed,X=H.deleted}let K=await this.tsconfigPathsRaw??void 0,U=new Map;for(let V of X){let H=l(V,this.opts.boundaries),M=W.getFileSymbols(H,V);U.set(V,M)}let L=crypto.randomUUID(),C=new Map,q=new Map,w=(V)=>({name:V.name,filePath:V.filePath,kind:V.kind,fingerprint:V.fingerprint,structuralFingerprint:V.structuralFingerprint??null,startLine:V.startLine,isExported:V.isExported??0});if($)for(let V of this.opts.boundaries)for(let H of J.getAllFiles(V.project))for(let M of W.getFileSymbols(V.project,H.filePath))C.set(`${M.filePath}::${M.name}`,w(M));else{for(let V of Z){let H=l(V.filePath,this.opts.boundaries);for(let M of W.getFileSymbols(H,V.filePath))C.set(`${M.filePath}::${M.name}`,w(M))}for(let[,V]of U)for(let H of V)C.set(`${H.filePath}::${H.name}`,w(H))}let S=(V)=>`${V.type}|${V.srcFilePath}|${V.dstFilePath??""}|${V.srcSymbolName??""}|${V.dstSymbolName??""}|${U_(V.metaJson??"")}`,F=new Map;if($)for(let V of this.opts.boundaries)for(let H of J.getAllFiles(V.project))for(let M of z.getOutgoing(V.project,H.filePath))F.set(S(M),M);else{for(let V of Z){let H=l(V.filePath,this.opts.boundaries);for(let M of z.getOutgoing(H,V.filePath))F.set(S(M),M)}for(let V of X){let H=l(V,this.opts.boundaries);for(let M of z.getOutgoing(H,V))F.set(S(M),M)}}let{annotationRepo:G,changelogRepo:E}=this.opts,u=()=>{for(let V of X){let H=l(V,this.opts.boundaries);if(W.deleteFileSymbols(H,V),z.deleteFileRelations(H,V),z.deleteIncomingRelations(H,V),G)G.deleteFileAnnotations(H,V);J.deleteFile(H,V)}},y=0,d=async()=>{let{projectRoot:V,boundaries:H}=this.opts,{parseCache:M}=this.opts,B=0,A=0,D=0,T=[],R=[];for(let j of Z)try{let v=g_(V,j.filePath),m=Bun.file(v),__=await m.text(),X_=j.contentHash||U_(__),K_=l(j.filePath,H);J.upsertFile({project:K_,filePath:j.filePath,mtimeMs:m.lastModified,size:m.size,contentHash:X_,updatedAt:new Date().toISOString(),lineCount:__.split(`
|
|
6
6
|
`).length});let D_=(this.opts.parseSourceFn??j_)(v,__);if(z1(D_))throw D_.data;let G$=D_;R.push({filePath:j.filePath,text:__,contentHash:X_,parsed:G$,project:K_})}catch(v){this.logger.error(`[IndexCoordinator] Failed to prepare ${j.filePath}:`,v),T.push(j.filePath)}let g=new Set;for(let j of H)for(let[v]of J.getFilesMap(j.project))g.add(`${j.project}::${v}`);return Y.transaction(()=>{for(let j of R){if(w0({parsed:j.parsed,project:j.project,filePath:j.filePath,contentHash:j.contentHash,symbolRepo:W}),A+=C0({ast:j.parsed.program,project:j.project,filePath:j.filePath,relationRepo:z,projectRoot:V,tsconfigPaths:K,knownFiles:g,boundaries:H,module:j.parsed.module}),G)D+=N0({parsed:j.parsed,project:j.project,filePath:j.filePath,annotationRepo:G});M.set(j.filePath,j.parsed),B+=W.getFileSymbols(j.project,j.filePath).length}}),{symbols:B,relations:A,annotations:D,failedFiles:T}},p=0,J_=0,Z_=[];if($){let{projectRoot:V,boundaries:H}=this.opts,{parseCache:M}=this.opts,B=[];for(let D=0;D<Z.length;D+=Z1){let T=Z.slice(D,D+Z1),R=await Promise.allSettled(T.map(async(g)=>{let j=g_(V,g.filePath),v=Bun.file(j),m=await v.text(),__=g.contentHash||U_(m);return{filePath:g.filePath,text:m,contentHash:__,mtimeMs:v.lastModified,size:v.size}}));for(let g=0;g<R.length;g++){let j=R[g];if(j.status==="fulfilled")B.push(j.value);else this.logger.error("[IndexCoordinator] Failed to pre-read file:",j.reason),Z_.push(T[g].filePath)}}let A=[];Y.transaction(()=>{for(let R of B){let g=l(R.filePath,H);J.deleteFile(g,R.filePath)}for(let R of X){let g=l(R,H);if(W.deleteFileSymbols(g,R),z.deleteFileRelations(g,R),z.deleteIncomingRelations(g,R),G)G.deleteFileAnnotations(g,R);J.deleteFile(g,R)}for(let R of B){let g=l(R.filePath,H);J.upsertFile({project:g,filePath:R.filePath,mtimeMs:R.mtimeMs,size:R.size,contentHash:R.contentHash,updatedAt:new Date().toISOString(),lineCount:R.text.split(`
|
|
@@ -319,7 +319,26 @@ export interface CodeRelation {
|
|
|
319
319
|
metaJson?: string;
|
|
320
320
|
/** Parsed metadata object derived from `metaJson`. */
|
|
321
321
|
meta?: Record<string, unknown>;
|
|
322
|
-
/**
|
|
322
|
+
/**
|
|
323
|
+
* Verbatim module specifier text as written in the source — `'./foo'`,
|
|
324
|
+
* `'@zipbul/core'`, `'lodash'`, etc. Always present on any
|
|
325
|
+
* module-source-bearing relation: `'imports'`, `'re-exports'`,
|
|
326
|
+
* `'type-references'` (any typed import or typed re-export — including
|
|
327
|
+
* bare re-exports cross-referenced through an existing typed import),
|
|
328
|
+
* dynamic `import(...)`, and `require(...)`. Preserved regardless of
|
|
329
|
+
* whether `dstFilePath` was successfully resolved, so consumers can
|
|
330
|
+
* reconstruct the original import form without reverse-engineering
|
|
331
|
+
* tsconfig paths, package `exports` maps, or relative-path normalization.
|
|
332
|
+
*
|
|
333
|
+
* For bare re-exports (`export { x };`) where `x` was previously imported,
|
|
334
|
+
* the relation cross-references the originating import statement and
|
|
335
|
+
* `specifier` carries that import's source text. Bare re-exports that
|
|
336
|
+
* cannot be cross-referenced are *not emitted* as relations at all
|
|
337
|
+
* (rather than emitted with `specifier` absent).
|
|
338
|
+
*
|
|
339
|
+
* Absent only on relations with no associated module source — `'calls'`,
|
|
340
|
+
* `'extends'`, `'implements'`.
|
|
341
|
+
*/
|
|
323
342
|
specifier?: string;
|
|
324
343
|
}
|
|
325
344
|
export type AnnotationSource = 'jsdoc' | 'line' | 'block';
|
|
@@ -8,7 +8,14 @@ export interface StoredCodeRelation extends Omit<CodeRelation, 'specifier'> {
|
|
|
8
8
|
dstProject: string | null;
|
|
9
9
|
/** Whether this relation targets an external (bare specifier) package. */
|
|
10
10
|
isExternal: boolean;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Verbatim module specifier text as written in the source — `'./foo'`,
|
|
13
|
+
* `'@zipbul/core'`, `'lodash'`, etc. Preserved regardless of whether
|
|
14
|
+
* the import was successfully resolved to a file. `null` only on
|
|
15
|
+
* relations with no associated module source (`'calls'`, `'extends'`,
|
|
16
|
+
* `'implements'`). See {@link CodeRelation.specifier} for the full
|
|
17
|
+
* contract.
|
|
18
|
+
*/
|
|
12
19
|
specifier: string | null;
|
|
13
20
|
}
|
|
14
21
|
/**
|