@aiready/core 0.23.2 → 0.23.4
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/dist/__tests__/parser-factory.test.d.ts +1 -1
- package/dist/__tests__/parser-factory.test.js +62 -50
- package/dist/__tests__/python-parser.test.d.ts +1 -1
- package/dist/__tests__/python-parser.test.js +111 -109
- package/dist/__tests__/scoring.test.d.ts +1 -1
- package/dist/__tests__/scoring.test.js +193 -176
- package/dist/chunk-3YI4IS3D.mjs +191 -173
- package/dist/chunk-5HIXDC3X.mjs +273 -251
- package/dist/chunk-5V3L53AE.mjs +805 -0
- package/dist/chunk-CKVKHN3G.mjs +228 -211
- package/dist/chunk-COHIBX3Q.mjs +213 -195
- package/dist/chunk-CWRCDSKZ.mjs +91 -82
- package/dist/chunk-D3D3NCRR.mjs +147 -129
- package/dist/chunk-HCFYP7UD.mjs +805 -0
- package/dist/chunk-HFLFBA6F.mjs +79 -72
- package/dist/chunk-HKSARRCD.mjs +66 -58
- package/dist/chunk-JJ5JL5FX.mjs +91 -82
- package/dist/chunk-KDSTXVLQ.mjs +724 -0
- package/dist/chunk-KI7XORTN.mjs +91 -82
- package/dist/chunk-LTMHFNFK.mjs +690 -0
- package/dist/chunk-LTNXTXRI.mjs +228 -211
- package/dist/chunk-M22BXHBR.mjs +805 -0
- package/dist/chunk-MH3A3LX6.mjs +200 -182
- package/dist/chunk-NGHT7JOG.mjs +697 -0
- package/dist/chunk-OQ6IGDXG.mjs +147 -129
- package/dist/chunk-QAFB3HXQ.mjs +181 -165
- package/dist/chunk-QQBKXHLU.mjs +678 -0
- package/dist/chunk-RDHYGES7.mjs +678 -0
- package/dist/chunk-SWTDBVYJ.mjs +228 -213
- package/dist/chunk-UIWL5JQB.mjs +79 -72
- package/dist/chunk-UQGI67WR.mjs +79 -72
- package/dist/chunk-UTZOO4XO.mjs +147 -131
- package/dist/chunk-X4F46I5L.mjs +213 -195
- package/dist/chunk-XKK7YHPX.mjs +204 -186
- package/dist/chunk-YCA4FTEK.mjs +190 -172
- package/dist/chunk-ZSZRRTJM.mjs +719 -0
- package/dist/client-BgmiMoil.d.mts +1344 -0
- package/dist/client-BgmiMoil.d.ts +1344 -0
- package/dist/client-BxGrPuuN.d.mts +1191 -0
- package/dist/client-BxGrPuuN.d.ts +1191 -0
- package/dist/client-D-cn9ydj.d.mts +1136 -0
- package/dist/client-D-cn9ydj.d.ts +1136 -0
- package/dist/client-D9seCH4K.d.mts +1334 -0
- package/dist/client-D9seCH4K.d.ts +1334 -0
- package/dist/client-DIXIh7rw.d.mts +1193 -0
- package/dist/client-DIXIh7rw.d.ts +1193 -0
- package/dist/client-DVHXWOHw.d.mts +1245 -0
- package/dist/client-DVHXWOHw.d.ts +1245 -0
- package/dist/client.d.mts +2 -1098
- package/dist/client.d.ts +2 -1098
- package/dist/client.js +23 -43
- package/dist/client.mjs +3 -25
- package/dist/index.d.mts +329 -107
- package/dist/index.d.ts +329 -107
- package/dist/index.js +329 -340
- package/dist/index.mjs +305 -322
- package/dist/parsers/parser-factory.d.ts +45 -45
- package/dist/parsers/parser-factory.js +86 -84
- package/dist/parsers/python-parser.d.ts +33 -28
- package/dist/parsers/python-parser.js +224 -222
- package/dist/parsers/typescript-parser.d.ts +15 -10
- package/dist/parsers/typescript-parser.js +223 -197
- package/dist/scoring.d.ts +59 -49
- package/dist/scoring.js +129 -127
- package/dist/types/language.d.ts +104 -93
- package/dist/types/language.js +23 -23
- package/dist/types.d.ts +105 -87
- package/dist/types.js +1 -1
- package/dist/utils/ast-parser.d.ts +42 -33
- package/dist/utils/ast-parser.js +159 -162
- package/dist/utils/cli-helpers.d.ts +27 -10
- package/dist/utils/cli-helpers.js +45 -43
- package/dist/utils/config.d.ts +8 -3
- package/dist/utils/config.js +67 -69
- package/dist/utils/file-scanner.d.ts +1 -1
- package/dist/utils/file-scanner.js +80 -76
- package/dist/utils/metrics.d.ts +1 -1
- package/dist/utils/metrics.js +2 -2
- package/package.json +1 -1
|
@@ -9,50 +9,50 @@ import { Language, LanguageParser } from '../types/language';
|
|
|
9
9
|
* Factory for creating and managing language parsers
|
|
10
10
|
*/
|
|
11
11
|
export declare class ParserFactory {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
12
|
+
private static instance;
|
|
13
|
+
private parsers;
|
|
14
|
+
private extensionMap;
|
|
15
|
+
private constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Get singleton instance
|
|
18
|
+
*/
|
|
19
|
+
static getInstance(): ParserFactory;
|
|
20
|
+
/**
|
|
21
|
+
* Register a language parser
|
|
22
|
+
*/
|
|
23
|
+
registerParser(parser: LanguageParser): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get parser for a specific language
|
|
26
|
+
*/
|
|
27
|
+
getParserForLanguage(language: Language): LanguageParser | null;
|
|
28
|
+
/**
|
|
29
|
+
* Get parser for a file based on its extension
|
|
30
|
+
*/
|
|
31
|
+
getParserForFile(filePath: string): LanguageParser | null;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a file is supported
|
|
34
|
+
*/
|
|
35
|
+
isSupported(filePath: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get all registered languages
|
|
38
|
+
*/
|
|
39
|
+
getSupportedLanguages(): Language[];
|
|
40
|
+
/**
|
|
41
|
+
* Get all supported file extensions
|
|
42
|
+
*/
|
|
43
|
+
getSupportedExtensions(): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Get language for a file
|
|
46
|
+
*/
|
|
47
|
+
getLanguageForFile(filePath: string): Language | null;
|
|
48
|
+
/**
|
|
49
|
+
* Extract file extension (with dot)
|
|
50
|
+
*/
|
|
51
|
+
private getFileExtension;
|
|
52
|
+
/**
|
|
53
|
+
* Reset factory (useful for testing)
|
|
54
|
+
*/
|
|
55
|
+
static reset(): void;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* Convenience function to get parser for a file
|
|
@@ -66,4 +66,4 @@ export declare function isFileSupported(filePath: string): boolean;
|
|
|
66
66
|
* Get all supported languages
|
|
67
67
|
*/
|
|
68
68
|
export declare function getSupportedLanguages(): Language[];
|
|
69
|
-
//# sourceMappingURL=parser-factory.d.ts.map
|
|
69
|
+
//# sourceMappingURL=parser-factory.d.ts.map
|
|
@@ -4,111 +4,113 @@
|
|
|
4
4
|
* This factory provides a centralized way to access the appropriate parser
|
|
5
5
|
* for a given file based on its extension.
|
|
6
6
|
*/
|
|
7
|
-
import { LANGUAGE_EXTENSIONS
|
|
7
|
+
import { LANGUAGE_EXTENSIONS } from '../types/language';
|
|
8
8
|
import { TypeScriptParser } from './typescript-parser';
|
|
9
9
|
import { PythonParser } from './python-parser';
|
|
10
10
|
/**
|
|
11
11
|
* Factory for creating and managing language parsers
|
|
12
12
|
*/
|
|
13
13
|
export class ParserFactory {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
constructor() {
|
|
15
|
+
this.parsers = new Map();
|
|
16
|
+
this.extensionMap = new Map(
|
|
17
|
+
Object.entries(LANGUAGE_EXTENSIONS).map(([ext, lang]) => [ext, lang])
|
|
18
|
+
);
|
|
19
|
+
// Register default parsers
|
|
20
|
+
this.registerParser(new TypeScriptParser());
|
|
21
|
+
this.registerParser(new PythonParser());
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get singleton instance
|
|
25
|
+
*/
|
|
26
|
+
static getInstance() {
|
|
27
|
+
if (!ParserFactory.instance) {
|
|
28
|
+
ParserFactory.instance = new ParserFactory();
|
|
20
29
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* Get parser for a file based on its extension
|
|
48
|
-
*/
|
|
49
|
-
getParserForFile(filePath) {
|
|
50
|
-
const ext = this.getFileExtension(filePath);
|
|
51
|
-
const language = this.extensionMap.get(ext);
|
|
52
|
-
if (!language) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return this.parsers.get(language) || null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Check if a file is supported
|
|
59
|
-
*/
|
|
60
|
-
isSupported(filePath) {
|
|
61
|
-
return this.getParserForFile(filePath) !== null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get all registered languages
|
|
65
|
-
*/
|
|
66
|
-
getSupportedLanguages() {
|
|
67
|
-
return Array.from(this.parsers.keys());
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Get all supported file extensions
|
|
71
|
-
*/
|
|
72
|
-
getSupportedExtensions() {
|
|
73
|
-
return Array.from(this.extensionMap.keys());
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get language for a file
|
|
77
|
-
*/
|
|
78
|
-
getLanguageForFile(filePath) {
|
|
79
|
-
const ext = this.getFileExtension(filePath);
|
|
80
|
-
return this.extensionMap.get(ext) || null;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Extract file extension (with dot)
|
|
84
|
-
*/
|
|
85
|
-
getFileExtension(filePath) {
|
|
86
|
-
const match = filePath.match(/\.[^.]+$/);
|
|
87
|
-
return match ? match[0].toLowerCase() : '';
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Reset factory (useful for testing)
|
|
91
|
-
*/
|
|
92
|
-
static reset() {
|
|
93
|
-
ParserFactory.instance = new ParserFactory();
|
|
30
|
+
return ParserFactory.instance;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Register a language parser
|
|
34
|
+
*/
|
|
35
|
+
registerParser(parser) {
|
|
36
|
+
this.parsers.set(parser.language, parser);
|
|
37
|
+
// Map extensions to this parser
|
|
38
|
+
parser.extensions.forEach((ext) => {
|
|
39
|
+
this.extensionMap.set(ext, parser.language);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get parser for a specific language
|
|
44
|
+
*/
|
|
45
|
+
getParserForLanguage(language) {
|
|
46
|
+
return this.parsers.get(language) || null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get parser for a file based on its extension
|
|
50
|
+
*/
|
|
51
|
+
getParserForFile(filePath) {
|
|
52
|
+
const ext = this.getFileExtension(filePath);
|
|
53
|
+
const language = this.extensionMap.get(ext);
|
|
54
|
+
if (!language) {
|
|
55
|
+
return null;
|
|
94
56
|
}
|
|
57
|
+
return this.parsers.get(language) || null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if a file is supported
|
|
61
|
+
*/
|
|
62
|
+
isSupported(filePath) {
|
|
63
|
+
return this.getParserForFile(filePath) !== null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get all registered languages
|
|
67
|
+
*/
|
|
68
|
+
getSupportedLanguages() {
|
|
69
|
+
return Array.from(this.parsers.keys());
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get all supported file extensions
|
|
73
|
+
*/
|
|
74
|
+
getSupportedExtensions() {
|
|
75
|
+
return Array.from(this.extensionMap.keys());
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get language for a file
|
|
79
|
+
*/
|
|
80
|
+
getLanguageForFile(filePath) {
|
|
81
|
+
const ext = this.getFileExtension(filePath);
|
|
82
|
+
return this.extensionMap.get(ext) || null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Extract file extension (with dot)
|
|
86
|
+
*/
|
|
87
|
+
getFileExtension(filePath) {
|
|
88
|
+
const match = filePath.match(/\.[^.]+$/);
|
|
89
|
+
return match ? match[0].toLowerCase() : '';
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reset factory (useful for testing)
|
|
93
|
+
*/
|
|
94
|
+
static reset() {
|
|
95
|
+
ParserFactory.instance = new ParserFactory();
|
|
96
|
+
}
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
97
99
|
* Convenience function to get parser for a file
|
|
98
100
|
*/
|
|
99
101
|
export function getParser(filePath) {
|
|
100
|
-
|
|
102
|
+
return ParserFactory.getInstance().getParserForFile(filePath);
|
|
101
103
|
}
|
|
102
104
|
/**
|
|
103
105
|
* Convenience function to check if file is supported
|
|
104
106
|
*/
|
|
105
107
|
export function isFileSupported(filePath) {
|
|
106
|
-
|
|
108
|
+
return ParserFactory.getInstance().isSupported(filePath);
|
|
107
109
|
}
|
|
108
110
|
/**
|
|
109
111
|
* Get all supported languages
|
|
110
112
|
*/
|
|
111
113
|
export function getSupportedLanguages() {
|
|
112
|
-
|
|
114
|
+
return ParserFactory.getInstance().getSupportedLanguages();
|
|
113
115
|
}
|
|
114
|
-
//# sourceMappingURL=parser-factory.js.map
|
|
116
|
+
//# sourceMappingURL=parser-factory.js.map
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Parses Python files using tree-sitter-python for accurate AST parsing
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Language,
|
|
8
|
+
LanguageParser,
|
|
9
|
+
ParseResult,
|
|
10
|
+
NamingConvention,
|
|
11
|
+
} from '../types/language';
|
|
7
12
|
/**
|
|
8
13
|
* Python Parser implementation
|
|
9
14
|
*
|
|
@@ -12,31 +17,31 @@ import { Language, LanguageParser, ParseResult, NamingConvention } from '../type
|
|
|
12
17
|
* is properly configured.
|
|
13
18
|
*/
|
|
14
19
|
export declare class PythonParser implements LanguageParser {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
readonly language = Language.Python;
|
|
21
|
+
readonly extensions: string[];
|
|
22
|
+
private parser;
|
|
23
|
+
private initialized;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the tree-sitter parser
|
|
26
|
+
* This is async because tree-sitter WASM needs to be loaded
|
|
27
|
+
*/
|
|
28
|
+
initialize(): Promise<void>;
|
|
29
|
+
parse(code: string, filePath: string): ParseResult;
|
|
30
|
+
getNamingConventions(): NamingConvention;
|
|
31
|
+
canHandle(filePath: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Regex-based import extraction (temporary implementation)
|
|
34
|
+
*/
|
|
35
|
+
private extractImportsRegex;
|
|
36
|
+
/**
|
|
37
|
+
* Regex-based export extraction (temporary implementation)
|
|
38
|
+
*
|
|
39
|
+
* Python doesn't have explicit exports like JavaScript.
|
|
40
|
+
* We extract:
|
|
41
|
+
* - Functions defined at module level (def)
|
|
42
|
+
* - Classes defined at module level (class)
|
|
43
|
+
* - Variables in __all__ list
|
|
44
|
+
*/
|
|
45
|
+
private extractExportsRegex;
|
|
41
46
|
}
|
|
42
|
-
//# sourceMappingURL=python-parser.d.ts.map
|
|
47
|
+
//# sourceMappingURL=python-parser.d.ts.map
|