@zipbul/gildash 0.0.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.ko.md +386 -0
  3. package/README.md +445 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +2736 -0
  6. package/dist/index.js.map +42 -0
  7. package/dist/migrations/0000_soft_revanche.sql +56 -0
  8. package/dist/migrations/meta/0000_snapshot.json +408 -0
  9. package/dist/migrations/meta/_journal.json +13 -0
  10. package/dist/migrations/migrations/0000_soft_revanche.sql +56 -0
  11. package/dist/migrations/migrations/meta/0000_snapshot.json +408 -0
  12. package/dist/migrations/migrations/meta/_journal.json +13 -0
  13. package/dist/src/codeledger.d.ts +103 -0
  14. package/dist/src/common/hasher.d.ts +2 -0
  15. package/dist/src/common/index.d.ts +5 -0
  16. package/dist/src/common/lru-cache.d.ts +10 -0
  17. package/dist/src/common/path-utils.d.ts +2 -0
  18. package/dist/src/common/project-discovery.d.ts +6 -0
  19. package/dist/src/common/tsconfig-resolver.d.ts +6 -0
  20. package/dist/src/errors.d.ts +42 -0
  21. package/dist/src/extractor/calls-extractor.d.ts +3 -0
  22. package/dist/src/extractor/extractor-utils.d.ts +5 -0
  23. package/dist/src/extractor/heritage-extractor.d.ts +3 -0
  24. package/dist/src/extractor/imports-extractor.d.ts +4 -0
  25. package/dist/src/extractor/index.d.ts +7 -0
  26. package/dist/src/extractor/relation-extractor.d.ts +4 -0
  27. package/dist/src/extractor/symbol-extractor.d.ts +3 -0
  28. package/dist/src/extractor/types.d.ts +162 -0
  29. package/dist/src/gildash.d.ts +284 -0
  30. package/dist/src/index.d.ts +8 -0
  31. package/dist/src/indexer/file-indexer.d.ts +27 -0
  32. package/dist/src/indexer/index-coordinator.d.ts +80 -0
  33. package/dist/src/indexer/index.d.ts +8 -0
  34. package/dist/src/indexer/relation-indexer.d.ts +24 -0
  35. package/dist/src/indexer/symbol-indexer.d.ts +29 -0
  36. package/dist/src/parser/ast-utils.d.ts +10 -0
  37. package/dist/src/parser/index.d.ts +6 -0
  38. package/dist/src/parser/jsdoc-parser.d.ts +2 -0
  39. package/dist/src/parser/parse-cache.d.ts +10 -0
  40. package/dist/src/parser/parse-source.d.ts +3 -0
  41. package/dist/src/parser/source-position.d.ts +3 -0
  42. package/dist/src/parser/types.d.ts +16 -0
  43. package/dist/src/search/dependency-graph.d.ts +71 -0
  44. package/dist/src/search/index.d.ts +6 -0
  45. package/dist/src/search/relation-search.d.ts +45 -0
  46. package/dist/src/search/symbol-search.d.ts +76 -0
  47. package/dist/src/store/connection.d.ts +30 -0
  48. package/dist/src/store/index.d.ts +10 -0
  49. package/dist/src/store/repositories/file.repository.d.ts +18 -0
  50. package/dist/src/store/repositories/fts-utils.d.ts +1 -0
  51. package/dist/src/store/repositories/relation.repository.d.ts +29 -0
  52. package/dist/src/store/repositories/symbol.repository.d.ts +46 -0
  53. package/dist/src/store/schema.d.ts +634 -0
  54. package/dist/src/watcher/index.d.ts +3 -0
  55. package/dist/src/watcher/ownership.d.ts +22 -0
  56. package/dist/src/watcher/project-watcher.d.ts +13 -0
  57. package/dist/src/watcher/types.d.ts +11 -0
  58. package/package.json +58 -0
@@ -0,0 +1,16 @@
1
+ import type { Program, Comment, OxcError } from 'oxc-parser';
2
+ export interface SourcePosition {
3
+ line: number;
4
+ column: number;
5
+ }
6
+ export interface SourceSpan {
7
+ start: SourcePosition;
8
+ end: SourcePosition;
9
+ }
10
+ export interface ParsedFile {
11
+ filePath: string;
12
+ program: Program;
13
+ errors: readonly OxcError[];
14
+ comments: readonly Comment[];
15
+ sourceText: string;
16
+ }
@@ -0,0 +1,71 @@
1
+ import type { RelationRecord } from '../store/repositories/relation.repository';
2
+ export interface IDependencyGraphRepo {
3
+ getByType(project: string, type: string): RelationRecord[];
4
+ }
5
+ /**
6
+ * Directed import graph for dependency analysis.
7
+ *
8
+ * Build the graph once with {@link DependencyGraph.build}, then query
9
+ * dependencies, dependents, cycles, and change-impact.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const graph = new DependencyGraph({ relationRepo, project: 'my-app' });
14
+ * graph.build();
15
+ * graph.getDependencies('/src/a.ts'); // files that a.ts imports
16
+ * graph.getDependents('/src/a.ts'); // files that import a.ts
17
+ * graph.hasCycle(); // true if a circular import exists
18
+ * ```
19
+ */
20
+ export declare class DependencyGraph {
21
+ private readonly options;
22
+ private adjacencyList;
23
+ private reverseAdjacencyList;
24
+ constructor(options: {
25
+ relationRepo: IDependencyGraphRepo;
26
+ project: string;
27
+ });
28
+ /**
29
+ * Populate the graph by reading all `imports` relations from the store.
30
+ *
31
+ * Must be called before any query method.
32
+ */
33
+ build(): void;
34
+ /**
35
+ * Return the files that `filePath` directly imports.
36
+ *
37
+ * @param filePath - Absolute file path.
38
+ */
39
+ getDependencies(filePath: string): string[];
40
+ /**
41
+ * Return the files that directly import `filePath`.
42
+ *
43
+ * @param filePath - Absolute file path.
44
+ */
45
+ getDependents(filePath: string): string[];
46
+ /**
47
+ * Return all files that transitively depend on `filePath`
48
+ * (breadth-first reverse walk).
49
+ *
50
+ * @param filePath - Absolute file path.
51
+ */
52
+ getTransitiveDependents(filePath: string): string[];
53
+ /**
54
+ * Detect whether the import graph contains at least one cycle.
55
+ *
56
+ * Uses iterative DFS with a path-tracking set.
57
+ *
58
+ * @returns `true` if a circular dependency exists.
59
+ */
60
+ hasCycle(): boolean;
61
+ /**
62
+ * Compute all files transitively affected by a set of changed files.
63
+ *
64
+ * Combines {@link getTransitiveDependents} for every changed file
65
+ * and de-duplicates the result.
66
+ *
67
+ * @param changedFiles - Absolute paths of files that changed.
68
+ * @returns Paths of all transitively-dependent files.
69
+ */
70
+ getAffectedByChange(changedFiles: string[]): string[];
71
+ }
@@ -0,0 +1,6 @@
1
+ export { symbolSearch } from './symbol-search';
2
+ export type { SymbolSearchQuery, SymbolSearchResult, ISymbolRepo } from './symbol-search';
3
+ export { relationSearch } from './relation-search';
4
+ export type { RelationSearchQuery, IRelationRepo } from './relation-search';
5
+ export { DependencyGraph } from './dependency-graph';
6
+ export type { IDependencyGraphRepo } from './dependency-graph';
@@ -0,0 +1,45 @@
1
+ import type { CodeRelation } from '../extractor/types';
2
+ import type { RelationRecord } from '../store/repositories/relation.repository';
3
+ /**
4
+ * Filters for {@link relationSearch}.
5
+ *
6
+ * All fields are optional. Omitted fields impose no constraint.
7
+ */
8
+ export interface RelationSearchQuery {
9
+ /** Source file path. */
10
+ srcFilePath?: string;
11
+ /** Source symbol name. */
12
+ srcSymbolName?: string;
13
+ /** Destination file path. */
14
+ dstFilePath?: string;
15
+ /** Destination symbol name. */
16
+ dstSymbolName?: string;
17
+ /** Relationship type: `'imports'`, `'calls'`, `'extends'`, or `'implements'`. */
18
+ type?: CodeRelation['type'];
19
+ /** Limit results to this project. */
20
+ project?: string;
21
+ /** Maximum number of results. Defaults to `500`. */
22
+ limit?: number;
23
+ }
24
+ export interface IRelationRepo {
25
+ searchRelations(opts: {
26
+ srcFilePath?: string;
27
+ srcSymbolName?: string;
28
+ dstFilePath?: string;
29
+ dstSymbolName?: string;
30
+ type?: string;
31
+ project?: string;
32
+ limit: number;
33
+ }): RelationRecord[];
34
+ }
35
+ /**
36
+ * Search the relation index using the given query filters.
37
+ *
38
+ * @param options - Relation repository, default project, and search query.
39
+ * @returns An array of {@link CodeRelation} entries matching the query.
40
+ */
41
+ export declare function relationSearch(options: {
42
+ relationRepo: IRelationRepo;
43
+ project?: string;
44
+ query: RelationSearchQuery;
45
+ }): CodeRelation[];
@@ -0,0 +1,76 @@
1
+ import type { SymbolKind } from '../extractor/types';
2
+ import type { SymbolRecord } from '../store/repositories/symbol.repository';
3
+ /**
4
+ * Filters for {@link symbolSearch}.
5
+ *
6
+ * All fields are optional. Omitted fields impose no constraint.
7
+ */
8
+ export interface SymbolSearchQuery {
9
+ /** Full-text search on symbol names (prefix matching). */
10
+ text?: string;
11
+ /** Restrict to a specific {@link SymbolKind}. */
12
+ kind?: SymbolKind;
13
+ /** Restrict to symbols declared in this file path. */
14
+ filePath?: string;
15
+ /** `true` for exported symbols only, `false` for non-exported only. */
16
+ isExported?: boolean;
17
+ /** Limit results to this project. Defaults to the primary project. */
18
+ project?: string;
19
+ /** Maximum number of results. Defaults to `100`. */
20
+ limit?: number;
21
+ }
22
+ /**
23
+ * A single result returned by {@link symbolSearch}.
24
+ */
25
+ export interface SymbolSearchResult {
26
+ /** Database row id. */
27
+ id: number;
28
+ /** Absolute file path containing the symbol. */
29
+ filePath: string;
30
+ /** Kind of the symbol (function, class, variable, etc.). */
31
+ kind: SymbolKind;
32
+ /** Symbol name. */
33
+ name: string;
34
+ /** Source location span (start/end line and column). */
35
+ span: {
36
+ start: {
37
+ line: number;
38
+ column: number;
39
+ };
40
+ end: {
41
+ line: number;
42
+ column: number;
43
+ };
44
+ };
45
+ /** Whether the symbol is exported from its module. */
46
+ isExported: boolean;
47
+ /** Human-readable signature text, if available. */
48
+ signature: string | null;
49
+ /** Content-hash fingerprint for change detection. */
50
+ fingerprint: string | null;
51
+ /** Arbitrary detail fields stored as JSON. */
52
+ detail: Record<string, unknown>;
53
+ }
54
+ export interface ISymbolRepo {
55
+ searchByQuery(opts: {
56
+ ftsQuery?: string;
57
+ kind?: string;
58
+ filePath?: string;
59
+ isExported?: boolean;
60
+ project?: string;
61
+ limit: number;
62
+ }): (SymbolRecord & {
63
+ id: number;
64
+ })[];
65
+ }
66
+ /**
67
+ * Search the symbol index using the given query filters.
68
+ *
69
+ * @param options - Symbol repository, default project, and search query.
70
+ * @returns An array of {@link SymbolSearchResult} entries matching the query.
71
+ */
72
+ export declare function symbolSearch(options: {
73
+ symbolRepo: ISymbolRepo;
74
+ project?: string;
75
+ query: SymbolSearchQuery;
76
+ }): SymbolSearchResult[];
@@ -0,0 +1,30 @@
1
+ import { type BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';
2
+ import * as schema from './schema';
3
+ export interface DbConnectionOptions {
4
+ projectRoot: string;
5
+ }
6
+ export declare class DbConnection {
7
+ private client;
8
+ private drizzle;
9
+ private readonly dbPath;
10
+ private txDepth;
11
+ constructor(opts: DbConnectionOptions);
12
+ get drizzleDb(): BunSQLiteDatabase<typeof schema>;
13
+ open(): void;
14
+ close(): void;
15
+ transaction<T>(fn: (tx: DbConnection) => T): T;
16
+ immediateTransaction<T>(fn: () => T): T;
17
+ query(sql: string): unknown;
18
+ getTableNames(): string[];
19
+ selectOwner(): {
20
+ pid: number;
21
+ heartbeat_at: string;
22
+ } | undefined;
23
+ insertOwner(pid: number): void;
24
+ replaceOwner(pid: number): void;
25
+ touchOwner(pid: number): void;
26
+ deleteOwner(pid: number): void;
27
+ private requireClient;
28
+ private closeClient;
29
+ private isCorruptionError;
30
+ }
@@ -0,0 +1,10 @@
1
+ export { DbConnection } from './connection';
2
+ export type { DbConnectionOptions } from './connection';
3
+ export { FileRepository } from './repositories/file.repository';
4
+ export type { FileRecord } from './repositories/file.repository';
5
+ export { SymbolRepository } from './repositories/symbol.repository';
6
+ export type { SymbolRecord, SearchOptions, SymbolStats } from './repositories/symbol.repository';
7
+ export { RelationRepository } from './repositories/relation.repository';
8
+ export type { RelationRecord } from './repositories/relation.repository';
9
+ export * as schema from './schema';
10
+ export { FTS_SETUP_SQL } from './schema';
@@ -0,0 +1,18 @@
1
+ import type { DbConnection } from '../connection';
2
+ export interface FileRecord {
3
+ project: string;
4
+ filePath: string;
5
+ mtimeMs: number;
6
+ size: number;
7
+ contentHash: string;
8
+ updatedAt: string;
9
+ }
10
+ export declare class FileRepository {
11
+ private readonly db;
12
+ constructor(db: DbConnection);
13
+ getFile(project: string, filePath: string): FileRecord | null;
14
+ upsertFile(record: FileRecord): void;
15
+ getAllFiles(project: string): FileRecord[];
16
+ getFilesMap(project: string): Map<string, FileRecord>;
17
+ deleteFile(project: string, filePath: string): void;
18
+ }
@@ -0,0 +1 @@
1
+ export declare function toFtsPrefixQuery(text: string): string;
@@ -0,0 +1,29 @@
1
+ import type { DbConnection } from '../connection';
2
+ export interface RelationRecord {
3
+ project: string;
4
+ type: string;
5
+ srcFilePath: string;
6
+ srcSymbolName: string | null;
7
+ dstFilePath: string;
8
+ dstSymbolName: string | null;
9
+ metaJson: string | null;
10
+ }
11
+ export declare class RelationRepository {
12
+ private readonly db;
13
+ constructor(db: DbConnection);
14
+ replaceFileRelations(project: string, srcFilePath: string, rels: ReadonlyArray<Partial<RelationRecord>>): void;
15
+ getOutgoing(project: string, srcFilePath: string, srcSymbolName?: string): RelationRecord[];
16
+ getIncoming(project: string, dstFilePath: string): RelationRecord[];
17
+ getByType(project: string, type: string): RelationRecord[];
18
+ deleteFileRelations(project: string, srcFilePath: string): void;
19
+ searchRelations(opts: {
20
+ srcFilePath?: string;
21
+ srcSymbolName?: string;
22
+ dstFilePath?: string;
23
+ dstSymbolName?: string;
24
+ type?: string;
25
+ project?: string;
26
+ limit: number;
27
+ }): RelationRecord[];
28
+ retargetRelations(project: string, oldFile: string, oldSymbol: string | null, newFile: string, newSymbol: string | null): void;
29
+ }
@@ -0,0 +1,46 @@
1
+ import type { DbConnection } from '../connection';
2
+ export interface SymbolRecord {
3
+ project: string;
4
+ filePath: string;
5
+ kind: string;
6
+ name: string;
7
+ startLine: number;
8
+ startColumn: number;
9
+ endLine: number;
10
+ endColumn: number;
11
+ isExported: number;
12
+ signature: string | null;
13
+ fingerprint: string | null;
14
+ detailJson: string | null;
15
+ contentHash: string;
16
+ indexedAt: string;
17
+ }
18
+ export interface SearchOptions {
19
+ kind?: string;
20
+ limit?: number;
21
+ }
22
+ export interface SymbolStats {
23
+ symbolCount: number;
24
+ fileCount: number;
25
+ }
26
+ export declare class SymbolRepository {
27
+ private readonly db;
28
+ constructor(db: DbConnection);
29
+ replaceFileSymbols(project: string, filePath: string, contentHash: string, syms: ReadonlyArray<Partial<SymbolRecord>>): void;
30
+ getFileSymbols(project: string, filePath: string): SymbolRecord[];
31
+ searchByName(project: string, query: string, opts?: SearchOptions): SymbolRecord[];
32
+ searchByKind(project: string, kind: string): SymbolRecord[];
33
+ getStats(project: string): SymbolStats;
34
+ getByFingerprint(project: string, fingerprint: string): SymbolRecord[];
35
+ deleteFileSymbols(project: string, filePath: string): void;
36
+ searchByQuery(opts: {
37
+ ftsQuery?: string;
38
+ kind?: string;
39
+ filePath?: string;
40
+ isExported?: boolean;
41
+ project?: string;
42
+ limit: number;
43
+ }): (SymbolRecord & {
44
+ id: number;
45
+ })[];
46
+ }