@eduardo-afonso/codebase-intelligence 0.1.0
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.md +147 -0
- package/README.pt-BR.md +147 -0
- package/dist/analysis/DependencyAnalyzer.d.ts +8 -0
- package/dist/analysis/DependencyAnalyzer.d.ts.map +1 -0
- package/dist/analysis/DependencyAnalyzer.js +13 -0
- package/dist/analysis/DependencyAnalyzer.js.map +1 -0
- package/dist/analysis/ImpactAnalyzer.d.ts +25 -0
- package/dist/analysis/ImpactAnalyzer.d.ts.map +1 -0
- package/dist/analysis/ImpactAnalyzer.js +41 -0
- package/dist/analysis/ImpactAnalyzer.js.map +1 -0
- package/dist/cli/Watcher.d.ts +40 -0
- package/dist/cli/Watcher.d.ts.map +1 -0
- package/dist/cli/Watcher.js +80 -0
- package/dist/cli/Watcher.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +243 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/AnalysisCache.d.ts +43 -0
- package/dist/core/AnalysisCache.d.ts.map +1 -0
- package/dist/core/AnalysisCache.js +120 -0
- package/dist/core/AnalysisCache.js.map +1 -0
- package/dist/core/Codebase.d.ts +39 -0
- package/dist/core/Codebase.d.ts.map +1 -0
- package/dist/core/Codebase.js +122 -0
- package/dist/core/Codebase.js.map +1 -0
- package/dist/core/errors.d.ts +15 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +29 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/interfaces.d.ts +6 -0
- package/dist/core/interfaces.d.ts.map +1 -0
- package/dist/core/interfaces.js +2 -0
- package/dist/core/interfaces.js.map +1 -0
- package/dist/core/types.d.ts +29 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/discovery/FileScanner.d.ts +13 -0
- package/dist/discovery/FileScanner.d.ts.map +1 -0
- package/dist/discovery/FileScanner.js +55 -0
- package/dist/discovery/FileScanner.js.map +1 -0
- package/dist/discovery/IgnoreMatcher.d.ts +11 -0
- package/dist/discovery/IgnoreMatcher.d.ts.map +1 -0
- package/dist/discovery/IgnoreMatcher.js +30 -0
- package/dist/discovery/IgnoreMatcher.js.map +1 -0
- package/dist/discovery/ProjectDetector.d.ts +17 -0
- package/dist/discovery/ProjectDetector.d.ts.map +1 -0
- package/dist/discovery/ProjectDetector.js +82 -0
- package/dist/discovery/ProjectDetector.js.map +1 -0
- package/dist/graph/DependencyGraph.d.ts +48 -0
- package/dist/graph/DependencyGraph.d.ts.map +1 -0
- package/dist/graph/DependencyGraph.js +114 -0
- package/dist/graph/DependencyGraph.js.map +1 -0
- package/dist/graph/GraphBuilder.d.ts +11 -0
- package/dist/graph/GraphBuilder.d.ts.map +1 -0
- package/dist/graph/GraphBuilder.js +22 -0
- package/dist/graph/GraphBuilder.js.map +1 -0
- package/dist/index/FileIndex.d.ts +12 -0
- package/dist/index/FileIndex.d.ts.map +1 -0
- package/dist/index/FileIndex.js +26 -0
- package/dist/index/FileIndex.js.map +1 -0
- package/dist/index/SymbolIndex.d.ts +18 -0
- package/dist/index/SymbolIndex.d.ts.map +1 -0
- package/dist/index/SymbolIndex.js +40 -0
- package/dist/index/SymbolIndex.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/Parser.d.ts +3 -0
- package/dist/parsers/Parser.d.ts.map +1 -0
- package/dist/parsers/Parser.js +2 -0
- package/dist/parsers/Parser.js.map +1 -0
- package/dist/parsers/ParserRegistry.d.ts +7 -0
- package/dist/parsers/ParserRegistry.d.ts.map +1 -0
- package/dist/parsers/ParserRegistry.js +10 -0
- package/dist/parsers/ParserRegistry.js.map +1 -0
- package/dist/parsers/typescript/TypeScriptParser.d.ts +9 -0
- package/dist/parsers/typescript/TypeScriptParser.d.ts.map +1 -0
- package/dist/parsers/typescript/TypeScriptParser.js +134 -0
- package/dist/parsers/typescript/TypeScriptParser.js.map +1 -0
- package/dist/search/CodeSearch.d.ts +20 -0
- package/dist/search/CodeSearch.d.ts.map +1 -0
- package/dist/search/CodeSearch.js +54 -0
- package/dist/search/CodeSearch.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACd,QAAQ;IAApC,YAA4B,QAAgB;QAC1C,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;wBADX,QAAQ;QAElC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,KAAK;IACP,QAAQ;IAA0B,aAAa;IAA3E,YAA4B,QAAgB,EAAkB,aAA8B;QAC1F,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;wBADjB,QAAQ;6BAA0B,aAAa;QAEzE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACtB,cAAc;IAA0B,UAAU;IAA9E,YAA4B,cAAsB,EAAkB,UAAkB;QACpF,KAAK,CAAC,iCAAiC,cAAc,gBAAgB,UAAU,EAAE,CAAC,CAAC;8BADzD,cAAc;0BAA0B,UAAU;QAE5E,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type SupportedLanguage = 'typescript' | 'javascript' | 'json';
|
|
2
|
+
export type SymbolKind = 'class' | 'interface' | 'function' | 'method' | 'variable' | 'typeAlias';
|
|
3
|
+
export type DependencyType = 'import' | 'extends' | 'implements' | 'unresolved';
|
|
4
|
+
export interface CodebaseFile {
|
|
5
|
+
path: string;
|
|
6
|
+
relativePath: string;
|
|
7
|
+
language: SupportedLanguage;
|
|
8
|
+
size: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CodeSymbol {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
kind: SymbolKind;
|
|
14
|
+
file: string;
|
|
15
|
+
startLine: number;
|
|
16
|
+
endLine: number;
|
|
17
|
+
parentId?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CodeDependency {
|
|
20
|
+
source: string;
|
|
21
|
+
target: string;
|
|
22
|
+
type: DependencyType;
|
|
23
|
+
}
|
|
24
|
+
export interface ParsedFile {
|
|
25
|
+
file: CodebaseFile;
|
|
26
|
+
symbols: CodeSymbol[];
|
|
27
|
+
dependencies: CodeDependency[];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAElG,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,YAAY,CAAC;AAEhF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CodebaseFile } from '../core/types.js';
|
|
2
|
+
import type { IgnoreMatcherOptions } from './IgnoreMatcher.js';
|
|
3
|
+
export interface FileScannerOptions extends IgnoreMatcherOptions {
|
|
4
|
+
cwd: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class FileScanner {
|
|
7
|
+
private ignoreMatcher;
|
|
8
|
+
private cwd;
|
|
9
|
+
constructor(options: FileScannerOptions);
|
|
10
|
+
scan(): Promise<CodebaseFile[]>;
|
|
11
|
+
private determineLanguage;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=FileScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileScanner.d.ts","sourceRoot":"","sources":["../../src/discovery/FileScanner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,GAAG,EAAE,MAAM,CAAC;CACb;AAaD,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,GAAG,CAAS;IAEpB,YAAY,OAAO,EAAE,kBAAkB,EAGtC;IAEY,IAAI,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAyB3C;IAED,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import fg from 'fast-glob';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs/promises';
|
|
4
|
+
import { IgnoreMatcher } from './IgnoreMatcher.js';
|
|
5
|
+
const RELEVANT_PATTERNS = [
|
|
6
|
+
'**/*.ts',
|
|
7
|
+
'**/*.tsx',
|
|
8
|
+
'**/*.js',
|
|
9
|
+
'**/*.jsx',
|
|
10
|
+
'**/*.mjs',
|
|
11
|
+
'**/*.cjs',
|
|
12
|
+
'**/package.json',
|
|
13
|
+
'**/tsconfig.json'
|
|
14
|
+
];
|
|
15
|
+
export class FileScanner {
|
|
16
|
+
ignoreMatcher;
|
|
17
|
+
cwd;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.cwd = options.cwd;
|
|
20
|
+
this.ignoreMatcher = new IgnoreMatcher(options);
|
|
21
|
+
}
|
|
22
|
+
async scan() {
|
|
23
|
+
const ignores = this.ignoreMatcher.getGlobIgnores();
|
|
24
|
+
const entries = await fg(RELEVANT_PATTERNS, {
|
|
25
|
+
cwd: this.cwd,
|
|
26
|
+
ignore: ignores,
|
|
27
|
+
absolute: true,
|
|
28
|
+
stats: true,
|
|
29
|
+
dot: true
|
|
30
|
+
});
|
|
31
|
+
const codebaseFiles = [];
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
if (!entry.stats)
|
|
34
|
+
continue;
|
|
35
|
+
codebaseFiles.push({
|
|
36
|
+
path: entry.path,
|
|
37
|
+
relativePath: path.relative(this.cwd, entry.path).replace(/\\/g, '/'),
|
|
38
|
+
language: this.determineLanguage(entry.path),
|
|
39
|
+
size: entry.stats.size
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return codebaseFiles;
|
|
43
|
+
}
|
|
44
|
+
determineLanguage(filePath) {
|
|
45
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
46
|
+
if (ext === '.ts' || ext === '.tsx')
|
|
47
|
+
return 'typescript';
|
|
48
|
+
if (ext === '.js' || ext === '.jsx' || ext === '.mjs' || ext === '.cjs')
|
|
49
|
+
return 'javascript';
|
|
50
|
+
if (ext === '.json')
|
|
51
|
+
return 'json';
|
|
52
|
+
return 'typescript'; // fallback
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=FileScanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileScanner.js","sourceRoot":"","sources":["../../src/discovery/FileScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnD,MAAM,iBAAiB,GAAG;IACxB,SAAS;IACT,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,iBAAiB;IACjB,kBAAkB;CACnB,CAAC;AAEF,MAAM,OAAO,WAAW;IACd,aAAa,CAAgB;IAC7B,GAAG,CAAS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AAK,MAAM,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,YAAY,CAAC;QAC7F,IAAI,GAAG,KAAK,OAAO;YAAE,OAAO,MAAM,CAAC;QACnC,OAAO,YAAY,CAAC,CAAC,WAAW;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IgnoreMatcherOptions {
|
|
2
|
+
extraIgnores?: string[];
|
|
3
|
+
disableDefaultIgnores?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_IGNORES: string[];
|
|
6
|
+
export declare class IgnoreMatcher {
|
|
7
|
+
private ignores;
|
|
8
|
+
constructor(options?: IgnoreMatcherOptions);
|
|
9
|
+
getGlobIgnores(): string[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IgnoreMatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IgnoreMatcher.d.ts","sourceRoot":"","sources":["../../src/discovery/IgnoreMatcher.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,eAAe,UAa3B,CAAC;AAEF,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAW;IAE1B,YAAY,OAAO,GAAE,oBAAyB,EAQ7C;IAEM,cAAc,IAAI,MAAM,EAAE,CAEhC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const DEFAULT_IGNORES = [
|
|
2
|
+
'**/node_modules/**',
|
|
3
|
+
'**/.git/**',
|
|
4
|
+
'**/dist/**',
|
|
5
|
+
'**/build/**',
|
|
6
|
+
'**/coverage/**',
|
|
7
|
+
'**/.next/**',
|
|
8
|
+
'**/.expo/**',
|
|
9
|
+
'**/out/**',
|
|
10
|
+
'**/target/**',
|
|
11
|
+
'**/.env*',
|
|
12
|
+
'**/*.tmp',
|
|
13
|
+
'**/*.temp'
|
|
14
|
+
];
|
|
15
|
+
export class IgnoreMatcher {
|
|
16
|
+
ignores;
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this.ignores = [];
|
|
19
|
+
if (!options.disableDefaultIgnores) {
|
|
20
|
+
this.ignores.push(...DEFAULT_IGNORES);
|
|
21
|
+
}
|
|
22
|
+
if (options.extraIgnores) {
|
|
23
|
+
this.ignores.push(...options.extraIgnores);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
getGlobIgnores() {
|
|
27
|
+
return this.ignores;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=IgnoreMatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IgnoreMatcher.js","sourceRoot":"","sources":["../../src/discovery/IgnoreMatcher.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,oBAAoB;IACpB,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,WAAW;IACX,cAAc;IACd,UAAU;IACV,UAAU;IACV,WAAW;CACZ,CAAC;AAEF,MAAM,OAAO,aAAa;IAChB,OAAO,CAAW;IAE1B,YAAY,OAAO,GAAyB,EAAE;QAC5C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CodebaseFile } from '../core/types.js';
|
|
2
|
+
export interface ProjectInfo {
|
|
3
|
+
languages: string[];
|
|
4
|
+
frameworks: string[];
|
|
5
|
+
packageManager: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ProjectDetector {
|
|
8
|
+
private cwd;
|
|
9
|
+
private files;
|
|
10
|
+
constructor(cwd: string, files: CodebaseFile[]);
|
|
11
|
+
detect(): Promise<ProjectInfo>;
|
|
12
|
+
private detectLanguages;
|
|
13
|
+
private readPackageJson;
|
|
14
|
+
private detectFrameworks;
|
|
15
|
+
private detectPackageManager;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ProjectDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectDetector.d.ts","sourceRoot":"","sources":["../../src/discovery/ProjectDetector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,GAAG;IAAU,OAAO,CAAC,KAAK;IAA9C,YAAoB,GAAG,EAAE,MAAM,EAAU,KAAK,EAAE,YAAY,EAAE,EAAI;IAErD,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,CAW1C;IAED,OAAO,CAAC,eAAe;YAST,eAAe;IAY7B,OAAO,CAAC,gBAAgB;YAoBV,oBAAoB;CAgBnC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
export class ProjectDetector {
|
|
4
|
+
cwd;
|
|
5
|
+
files;
|
|
6
|
+
constructor(cwd, files) {
|
|
7
|
+
this.cwd = cwd;
|
|
8
|
+
this.files = files;
|
|
9
|
+
}
|
|
10
|
+
async detect() {
|
|
11
|
+
const languages = this.detectLanguages();
|
|
12
|
+
const packageJsonContent = await this.readPackageJson();
|
|
13
|
+
const frameworks = this.detectFrameworks(packageJsonContent);
|
|
14
|
+
const packageManager = await this.detectPackageManager();
|
|
15
|
+
return {
|
|
16
|
+
languages,
|
|
17
|
+
frameworks,
|
|
18
|
+
packageManager
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
detectLanguages() {
|
|
22
|
+
const hasTs = this.files.some(f => f.relativePath === 'tsconfig.json' || f.language === 'typescript');
|
|
23
|
+
const hasJs = this.files.some(f => f.language === 'javascript');
|
|
24
|
+
if (hasTs)
|
|
25
|
+
return ['typescript'];
|
|
26
|
+
if (hasJs)
|
|
27
|
+
return ['javascript'];
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
async readPackageJson() {
|
|
31
|
+
const pkgFile = this.files.find(f => f.relativePath === 'package.json');
|
|
32
|
+
if (!pkgFile)
|
|
33
|
+
return null;
|
|
34
|
+
try {
|
|
35
|
+
const content = await fs.readFile(pkgFile.path, 'utf-8');
|
|
36
|
+
return JSON.parse(content);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
detectFrameworks(packageJson) {
|
|
43
|
+
const frameworks = new Set();
|
|
44
|
+
// Dependencies check
|
|
45
|
+
const deps = { ...(packageJson?.dependencies || {}), ...(packageJson?.devDependencies || {}) };
|
|
46
|
+
if (deps['react'])
|
|
47
|
+
frameworks.add('react');
|
|
48
|
+
if (deps['next'])
|
|
49
|
+
frameworks.add('nextjs');
|
|
50
|
+
if (deps['@nestjs/core'])
|
|
51
|
+
frameworks.add('nestjs');
|
|
52
|
+
// Config files check
|
|
53
|
+
for (const file of this.files) {
|
|
54
|
+
if (file.relativePath.startsWith('next.config.'))
|
|
55
|
+
frameworks.add('nextjs');
|
|
56
|
+
if (file.relativePath.startsWith('vite.config.'))
|
|
57
|
+
frameworks.add('vite');
|
|
58
|
+
if (file.relativePath === 'nest-cli.json')
|
|
59
|
+
frameworks.add('nestjs');
|
|
60
|
+
}
|
|
61
|
+
return Array.from(frameworks);
|
|
62
|
+
}
|
|
63
|
+
async detectPackageManager() {
|
|
64
|
+
const checkFile = async (filename) => {
|
|
65
|
+
try {
|
|
66
|
+
await fs.access(path.join(this.cwd, filename));
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
if (await checkFile('yarn.lock'))
|
|
74
|
+
return 'yarn';
|
|
75
|
+
if (await checkFile('pnpm-lock.yaml'))
|
|
76
|
+
return 'pnpm';
|
|
77
|
+
if (await checkFile('package-lock.json'))
|
|
78
|
+
return 'npm';
|
|
79
|
+
return 'npm'; // Default
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=ProjectDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectDetector.js","sourceRoot":"","sources":["../../src/discovery/ProjectDetector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AASlC,MAAM,OAAO,eAAe;IACN,GAAG;IAAkB,KAAK;IAA9C,YAAoB,GAAW,EAAU,KAAqB;mBAA1C,GAAG;qBAAkB,KAAK;IAAmB,CAAC;IAE3D,KAAK,CAAC,MAAM;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACzC,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QAC7D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAEzD,OAAO;YACL,SAAS;YACT,UAAU;YACV,c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|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface GraphEdge {
|
|
2
|
+
source: string;
|
|
3
|
+
target: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Directed dependency graph that works with generic string IDs.
|
|
8
|
+
* - dependenciesOf(id): direct outgoing edges (what `id` depends on)
|
|
9
|
+
* - dependentsOf(id): direct incoming edges (what depends on `id`)
|
|
10
|
+
* - For indirect traversal, use traverseBFS / collectReachable.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DependencyGraph {
|
|
13
|
+
/** outgoing: node → nodes it depends on */
|
|
14
|
+
private outgoing;
|
|
15
|
+
/** incoming: node → nodes that depend on it */
|
|
16
|
+
private incoming;
|
|
17
|
+
/** edge metadata indexed by `source→target` */
|
|
18
|
+
private edges;
|
|
19
|
+
addNode(id: string): void;
|
|
20
|
+
removeNode(id: string): void;
|
|
21
|
+
hasNode(id: string): boolean;
|
|
22
|
+
nodes(): string[];
|
|
23
|
+
addEdge(source: string, target: string, type?: string): void;
|
|
24
|
+
removeEdge(source: string, target: string): void;
|
|
25
|
+
getEdge(source: string, target: string): GraphEdge | undefined;
|
|
26
|
+
/** Direct dependencies of `id` (what `id` imports/extends/implements). */
|
|
27
|
+
dependenciesOf(id: string): string[];
|
|
28
|
+
/** Direct dependents of `id` (files that import `id`). */
|
|
29
|
+
dependentsOf(id: string): string[];
|
|
30
|
+
/** All direct neighbours: both dependencies and dependents. */
|
|
31
|
+
neighbors(id: string): string[];
|
|
32
|
+
/**
|
|
33
|
+
* BFS starting from `startId` following `direction`:
|
|
34
|
+
* - 'outgoing': traverse dependencies (what startId depends on)
|
|
35
|
+
* - 'incoming': traverse dependents (who depends on startId)
|
|
36
|
+
* Returns all reachable IDs, excluding the start node itself.
|
|
37
|
+
*/
|
|
38
|
+
traverseBFS(startId: string, direction: 'outgoing' | 'incoming'): string[];
|
|
39
|
+
/**
|
|
40
|
+
* All transitive dependencies (files that `id` depends on, directly or indirectly).
|
|
41
|
+
*/
|
|
42
|
+
allDependenciesOf(id: string): string[];
|
|
43
|
+
/**
|
|
44
|
+
* All transitive dependents (files that depend on `id`, directly or indirectly).
|
|
45
|
+
*/
|
|
46
|
+
allDependentsOf(id: string): string[];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=DependencyGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyGraph.d.ts","sourceRoot":"","sources":["../../src/graph/DependencyGraph.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,2CAA2C;IAC3C,OAAO,CAAC,QAAQ,CAAkC;IAClD,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAkC;IAClD,+CAA+C;IAC/C,OAAO,CAAC,KAAK,CAAgC;IAItC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAG/B;IAEM,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAalC;IAEM,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAElC;IAEM,KAAK,IAAI,MAAM,EAAE,CAEvB;IAIM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAQlE;IAEM,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAItD;IAEM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEpE;IAID,0EAA0E;IACnE,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1C;IAED,0DAA0D;IACnD,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAExC;IAED,+DAA+D;IACxD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAIrC;IAID;;;;;OAKG;IACI,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,EAAE,CAsBhF;IAED;;OAEG;IACI,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7C;IAED;;OAEG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAE3C;CACF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directed dependency graph that works with generic string IDs.
|
|
3
|
+
* - dependenciesOf(id): direct outgoing edges (what `id` depends on)
|
|
4
|
+
* - dependentsOf(id): direct incoming edges (what depends on `id`)
|
|
5
|
+
* - For indirect traversal, use traverseBFS / collectReachable.
|
|
6
|
+
*/
|
|
7
|
+
export class DependencyGraph {
|
|
8
|
+
/** outgoing: node → nodes it depends on */
|
|
9
|
+
outgoing = new Map();
|
|
10
|
+
/** incoming: node → nodes that depend on it */
|
|
11
|
+
incoming = new Map();
|
|
12
|
+
/** edge metadata indexed by `source→target` */
|
|
13
|
+
edges = new Map();
|
|
14
|
+
// ---- Node operations ------------------------------------------------
|
|
15
|
+
addNode(id) {
|
|
16
|
+
if (!this.outgoing.has(id))
|
|
17
|
+
this.outgoing.set(id, new Set());
|
|
18
|
+
if (!this.incoming.has(id))
|
|
19
|
+
this.incoming.set(id, new Set());
|
|
20
|
+
}
|
|
21
|
+
removeNode(id) {
|
|
22
|
+
// Remove all outgoing edges first
|
|
23
|
+
for (const target of this.outgoing.get(id) ?? []) {
|
|
24
|
+
this.incoming.get(target)?.delete(id);
|
|
25
|
+
this.edges.delete(`${id}→${target}`);
|
|
26
|
+
}
|
|
27
|
+
// Remove all incoming edges
|
|
28
|
+
for (const source of this.incoming.get(id) ?? []) {
|
|
29
|
+
this.outgoing.get(source)?.delete(id);
|
|
30
|
+
this.edges.delete(`${source}→${id}`);
|
|
31
|
+
}
|
|
32
|
+
this.outgoing.delete(id);
|
|
33
|
+
this.incoming.delete(id);
|
|
34
|
+
}
|
|
35
|
+
hasNode(id) {
|
|
36
|
+
return this.outgoing.has(id);
|
|
37
|
+
}
|
|
38
|
+
nodes() {
|
|
39
|
+
return Array.from(this.outgoing.keys());
|
|
40
|
+
}
|
|
41
|
+
// ---- Edge operations ------------------------------------------------
|
|
42
|
+
addEdge(source, target, type) {
|
|
43
|
+
this.addNode(source);
|
|
44
|
+
this.addNode(target);
|
|
45
|
+
this.outgoing.get(source).add(target);
|
|
46
|
+
this.incoming.get(target).add(source);
|
|
47
|
+
const edge = { source, target };
|
|
48
|
+
if (type)
|
|
49
|
+
edge.type = type;
|
|
50
|
+
this.edges.set(`${source}→${target}`, edge);
|
|
51
|
+
}
|
|
52
|
+
removeEdge(source, target) {
|
|
53
|
+
this.outgoing.get(source)?.delete(target);
|
|
54
|
+
this.incoming.get(target)?.delete(source);
|
|
55
|
+
this.edges.delete(`${source}→${target}`);
|
|
56
|
+
}
|
|
57
|
+
getEdge(source, target) {
|
|
58
|
+
return this.edges.get(`${source}→${target}`);
|
|
59
|
+
}
|
|
60
|
+
// ---- Query ----------------------------------------------------------
|
|
61
|
+
/** Direct dependencies of `id` (what `id` imports/extends/implements). */
|
|
62
|
+
dependenciesOf(id) {
|
|
63
|
+
return Array.from(this.outgoing.get(id) ?? []);
|
|
64
|
+
}
|
|
65
|
+
/** Direct dependents of `id` (files that import `id`). */
|
|
66
|
+
dependentsOf(id) {
|
|
67
|
+
return Array.from(this.incoming.get(id) ?? []);
|
|
68
|
+
}
|
|
69
|
+
/** All direct neighbours: both dependencies and dependents. */
|
|
70
|
+
neighbors(id) {
|
|
71
|
+
const deps = this.outgoing.get(id) ?? new Set();
|
|
72
|
+
const revDeps = this.incoming.get(id) ?? new Set();
|
|
73
|
+
return Array.from(new Set([...deps, ...revDeps]));
|
|
74
|
+
}
|
|
75
|
+
// ---- Traversal ------------------------------------------------------
|
|
76
|
+
/**
|
|
77
|
+
* BFS starting from `startId` following `direction`:
|
|
78
|
+
* - 'outgoing': traverse dependencies (what startId depends on)
|
|
79
|
+
* - 'incoming': traverse dependents (who depends on startId)
|
|
80
|
+
* Returns all reachable IDs, excluding the start node itself.
|
|
81
|
+
*/
|
|
82
|
+
traverseBFS(startId, direction) {
|
|
83
|
+
const visited = new Set();
|
|
84
|
+
const queue = [startId];
|
|
85
|
+
visited.add(startId);
|
|
86
|
+
while (queue.length > 0) {
|
|
87
|
+
const current = queue.shift();
|
|
88
|
+
const adjacents = direction === 'outgoing'
|
|
89
|
+
? this.outgoing.get(current) ?? new Set()
|
|
90
|
+
: this.incoming.get(current) ?? new Set();
|
|
91
|
+
for (const adj of adjacents) {
|
|
92
|
+
if (!visited.has(adj)) {
|
|
93
|
+
visited.add(adj);
|
|
94
|
+
queue.push(adj);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
visited.delete(startId);
|
|
99
|
+
return Array.from(visited);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* All transitive dependencies (files that `id` depends on, directly or indirectly).
|
|
103
|
+
*/
|
|
104
|
+
allDependenciesOf(id) {
|
|
105
|
+
return this.traverseBFS(id, 'outgoing');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* All transitive dependents (files that depend on `id`, directly or indirectly).
|
|
109
|
+
*/
|
|
110
|
+
allDependentsOf(id) {
|
|
111
|
+
return this.traverseBFS(id, 'incoming');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=DependencyGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyGraph.js","sourceRoot":"","sources":["../../src/graph/DependencyGraph.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAC1B,2CAA2C;I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AAE;gBACzC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;YAE9C,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;gBAC5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACjB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,iBAAiB,CAAC,EAAU;QACjC,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,EAAU;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CodeDependency } from '../core/types.js';
|
|
2
|
+
import { DependencyGraph } from './DependencyGraph.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a DependencyGraph from a list of CodeDependency objects.
|
|
5
|
+
* Unresolved dependencies are explicitly skipped as graph edges —
|
|
6
|
+
* they are not valid file-to-file relationships.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GraphBuilder {
|
|
9
|
+
build(dependencies: CodeDependency[]): DependencyGraph;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=GraphBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphBuilder.d.ts","sourceRoot":"","sources":["../../src/graph/GraphBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;GAIG;AACH,qBAAa,YAAY;IAChB,KAAK,CAAC,YAAY,EAAE,cAAc,EAAE,GAAG,eAAe,CAe5D;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DependencyGraph } from './DependencyGraph.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a DependencyGraph from a list of CodeDependency objects.
|
|
4
|
+
* Unresolved dependencies are explicitly skipped as graph edges —
|
|
5
|
+
* they are not valid file-to-file relationships.
|
|
6
|
+
*/
|
|
7
|
+
export class GraphBuilder {
|
|
8
|
+
build(dependencies) {
|
|
9
|
+
const graph = new DependencyGraph();
|
|
10
|
+
for (const dep of dependencies) {
|
|
11
|
+
if (dep.type === 'unresolved') {
|
|
12
|
+
// Register source node so it appears in the graph, but don't
|
|
13
|
+
// create an edge to an unknown/invented target.
|
|
14
|
+
graph.addNode(dep.source);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
graph.addEdge(dep.source, dep.target, dep.type);
|
|
18
|
+
}
|
|
19
|
+
return graph;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=GraphBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphBuilder.js","sourceRoot":"","sources":["../../src/graph/GraphBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAChB,KAAK,CAAC,YAA8B;QACzC,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QAEpC,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC9B,6DAA6D;gBAC7D,gDAAgD;gBAChD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC1B,SAAS;YACX,CAAC;YAED,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CodebaseFile } from '../core/types.js';
|
|
2
|
+
export declare class FileIndex {
|
|
3
|
+
private byPath;
|
|
4
|
+
private byRelativePath;
|
|
5
|
+
add(file: CodebaseFile): void;
|
|
6
|
+
addAll(files: CodebaseFile[]): void;
|
|
7
|
+
getByPath(path: string): CodebaseFile | undefined;
|
|
8
|
+
getByRelativePath(relativePath: string): CodebaseFile | undefined;
|
|
9
|
+
all(): CodebaseFile[];
|
|
10
|
+
size(): number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=FileIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileIndex.d.ts","sourceRoot":"","sources":["../../src/index/FileIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,cAAc,CAAmC;IAElD,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAGnC;IAEM,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,CAIzC;IAEM,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEvD;IAEM,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEvE;IAEM,GAAG,IAAI,YAAY,EAAE,CAE3B;IAEM,IAAI,IAAI,MAAM,CAEpB;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class FileIndex {
|
|
2
|
+
byPath = new Map();
|
|
3
|
+
byRelativePath = new Map();
|
|
4
|
+
add(file) {
|
|
5
|
+
this.byPath.set(file.path, file);
|
|
6
|
+
this.byRelativePath.set(file.relativePath, file);
|
|
7
|
+
}
|
|
8
|
+
addAll(files) {
|
|
9
|
+
for (const file of files) {
|
|
10
|
+
this.add(file);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
getByPath(path) {
|
|
14
|
+
return this.byPath.get(path);
|
|
15
|
+
}
|
|
16
|
+
getByRelativePath(relativePath) {
|
|
17
|
+
return this.byRelativePath.get(relativePath);
|
|
18
|
+
}
|
|
19
|
+
all() {
|
|
20
|
+
return Array.from(this.byPath.values());
|
|
21
|
+
}
|
|
22
|
+
size() {
|
|
23
|
+
return this.byPath.size;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=FileIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileIndex.js","sourceRoot":"","sources":["../../src/index/FileIndex.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,SAAS;IACZ,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IACzC,cAAc,GAAG,IAAI,GAAG,EAAwB,CAAC;IAElD,GAAG,CAAC,IAAkB;QAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAEM,MAAM,CAAC,KAAqB;QACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAEM,SAAS,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAEM,iBAAiB,CAAC,YAAoB;QAC3C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAEM,GAAG;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CodeSymbol, SymbolKind } from '../core/types.js';
|
|
2
|
+
export interface SymbolQuery {
|
|
3
|
+
name?: string;
|
|
4
|
+
kind?: SymbolKind;
|
|
5
|
+
file?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class SymbolIndex {
|
|
8
|
+
private byName;
|
|
9
|
+
private byFile;
|
|
10
|
+
private all;
|
|
11
|
+
add(symbol: CodeSymbol): void;
|
|
12
|
+
addAll(symbols: CodeSymbol[]): void;
|
|
13
|
+
findSymbol(name: string): CodeSymbol | undefined;
|
|
14
|
+
findSymbols(query: SymbolQuery): CodeSymbol[];
|
|
15
|
+
findByFile(file: string): CodeSymbol[];
|
|
16
|
+
size(): number;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=SymbolIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SymbolIndex.d.ts","sourceRoot":"","sources":["../../src/index/SymbolIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,GAAG,CAAoB;IAExB,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAUnC;IAEM,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAIzC;IAEM,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEtD;IAEM,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,EAAE,CAOnD;IAEM,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAE5C;IAEM,IAAI,IAAI,MAAM,CAEpB;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class SymbolIndex {
|
|
2
|
+
byName = new Map();
|
|
3
|
+
byFile = new Map();
|
|
4
|
+
all = [];
|
|
5
|
+
add(symbol) {
|
|
6
|
+
this.all.push(symbol);
|
|
7
|
+
const byNameList = this.byName.get(symbol.name) ?? [];
|
|
8
|
+
byNameList.push(symbol);
|
|
9
|
+
this.byName.set(symbol.name, byNameList);
|
|
10
|
+
const byFileList = this.byFile.get(symbol.file) ?? [];
|
|
11
|
+
byFileList.push(symbol);
|
|
12
|
+
this.byFile.set(symbol.file, byFileList);
|
|
13
|
+
}
|
|
14
|
+
addAll(symbols) {
|
|
15
|
+
for (const symbol of symbols) {
|
|
16
|
+
this.add(symbol);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
findSymbol(name) {
|
|
20
|
+
return this.byName.get(name)?.[0];
|
|
21
|
+
}
|
|
22
|
+
findSymbols(query) {
|
|
23
|
+
return this.all.filter(symbol => {
|
|
24
|
+
if (query.name !== undefined && symbol.name !== query.name)
|
|
25
|
+
return false;
|
|
26
|
+
if (query.kind !== undefined && symbol.kind !== query.kind)
|
|
27
|
+
return false;
|
|
28
|
+
if (query.file !== undefined && symbol.file !== query.file)
|
|
29
|
+
return false;
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
findByFile(file) {
|
|
34
|
+
return this.byFile.get(file) ?? [];
|
|
35
|
+
}
|
|
36
|
+
size() {
|
|
37
|
+
return this.all.length;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=SymbolIndex.js.map
|