@aiready/core 0.23.2 → 0.23.3

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 (79) hide show
  1. package/dist/__tests__/parser-factory.test.d.ts +1 -1
  2. package/dist/__tests__/parser-factory.test.js +62 -50
  3. package/dist/__tests__/python-parser.test.d.ts +1 -1
  4. package/dist/__tests__/python-parser.test.js +111 -109
  5. package/dist/__tests__/scoring.test.d.ts +1 -1
  6. package/dist/__tests__/scoring.test.js +193 -176
  7. package/dist/chunk-3YI4IS3D.mjs +191 -173
  8. package/dist/chunk-5HIXDC3X.mjs +273 -251
  9. package/dist/chunk-5V3L53AE.mjs +805 -0
  10. package/dist/chunk-CKVKHN3G.mjs +228 -211
  11. package/dist/chunk-COHIBX3Q.mjs +213 -195
  12. package/dist/chunk-CWRCDSKZ.mjs +91 -82
  13. package/dist/chunk-D3D3NCRR.mjs +147 -129
  14. package/dist/chunk-HCFYP7UD.mjs +805 -0
  15. package/dist/chunk-HFLFBA6F.mjs +79 -72
  16. package/dist/chunk-HKSARRCD.mjs +66 -58
  17. package/dist/chunk-JJ5JL5FX.mjs +91 -82
  18. package/dist/chunk-KDSTXVLQ.mjs +724 -0
  19. package/dist/chunk-KI7XORTN.mjs +91 -82
  20. package/dist/chunk-LTMHFNFK.mjs +690 -0
  21. package/dist/chunk-LTNXTXRI.mjs +228 -211
  22. package/dist/chunk-M22BXHBR.mjs +805 -0
  23. package/dist/chunk-MH3A3LX6.mjs +200 -182
  24. package/dist/chunk-NGHT7JOG.mjs +697 -0
  25. package/dist/chunk-OQ6IGDXG.mjs +147 -129
  26. package/dist/chunk-QAFB3HXQ.mjs +181 -165
  27. package/dist/chunk-QQBKXHLU.mjs +678 -0
  28. package/dist/chunk-RDHYGES7.mjs +678 -0
  29. package/dist/chunk-SWTDBVYJ.mjs +228 -213
  30. package/dist/chunk-UIWL5JQB.mjs +79 -72
  31. package/dist/chunk-UQGI67WR.mjs +79 -72
  32. package/dist/chunk-UTZOO4XO.mjs +147 -131
  33. package/dist/chunk-X4F46I5L.mjs +213 -195
  34. package/dist/chunk-XKK7YHPX.mjs +204 -186
  35. package/dist/chunk-YCA4FTEK.mjs +190 -172
  36. package/dist/chunk-ZSZRRTJM.mjs +719 -0
  37. package/dist/client-BgmiMoil.d.mts +1344 -0
  38. package/dist/client-BgmiMoil.d.ts +1344 -0
  39. package/dist/client-BxGrPuuN.d.mts +1191 -0
  40. package/dist/client-BxGrPuuN.d.ts +1191 -0
  41. package/dist/client-D-cn9ydj.d.mts +1136 -0
  42. package/dist/client-D-cn9ydj.d.ts +1136 -0
  43. package/dist/client-D9seCH4K.d.mts +1334 -0
  44. package/dist/client-D9seCH4K.d.ts +1334 -0
  45. package/dist/client-DIXIh7rw.d.mts +1193 -0
  46. package/dist/client-DIXIh7rw.d.ts +1193 -0
  47. package/dist/client-DVHXWOHw.d.mts +1245 -0
  48. package/dist/client-DVHXWOHw.d.ts +1245 -0
  49. package/dist/client.d.mts +2 -1098
  50. package/dist/client.d.ts +2 -1098
  51. package/dist/client.js +23 -43
  52. package/dist/client.mjs +3 -25
  53. package/dist/index.d.mts +325 -103
  54. package/dist/index.d.ts +325 -103
  55. package/dist/index.js +307 -324
  56. package/dist/index.mjs +283 -306
  57. package/dist/parsers/parser-factory.d.ts +45 -45
  58. package/dist/parsers/parser-factory.js +86 -84
  59. package/dist/parsers/python-parser.d.ts +33 -28
  60. package/dist/parsers/python-parser.js +224 -222
  61. package/dist/parsers/typescript-parser.d.ts +15 -10
  62. package/dist/parsers/typescript-parser.js +223 -197
  63. package/dist/scoring.d.ts +59 -49
  64. package/dist/scoring.js +129 -127
  65. package/dist/types/language.d.ts +104 -93
  66. package/dist/types/language.js +23 -23
  67. package/dist/types.d.ts +105 -87
  68. package/dist/types.js +1 -1
  69. package/dist/utils/ast-parser.d.ts +42 -33
  70. package/dist/utils/ast-parser.js +159 -162
  71. package/dist/utils/cli-helpers.d.ts +27 -10
  72. package/dist/utils/cli-helpers.js +45 -43
  73. package/dist/utils/config.d.ts +8 -3
  74. package/dist/utils/config.js +67 -69
  75. package/dist/utils/file-scanner.d.ts +1 -1
  76. package/dist/utils/file-scanner.js +80 -76
  77. package/dist/utils/metrics.d.ts +1 -1
  78. package/dist/utils/metrics.js +2 -2
  79. package/package.json +1 -1
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Parses Python files using tree-sitter-python for accurate AST parsing
5
5
  */
6
- import { Language, ParseError, } from '../types/language';
6
+ import { Language, ParseError } from '../types/language';
7
7
  /**
8
8
  * Python Parser implementation
9
9
  *
@@ -12,230 +12,232 @@ import { Language, ParseError, } from '../types/language';
12
12
  * is properly configured.
13
13
  */
14
14
  export class PythonParser {
15
- constructor() {
16
- this.language = Language.Python;
17
- this.extensions = ['.py'];
18
- this.parser = null;
19
- this.initialized = false;
15
+ constructor() {
16
+ this.language = Language.Python;
17
+ this.extensions = ['.py'];
18
+ this.parser = null;
19
+ this.initialized = false;
20
+ }
21
+ /**
22
+ * Initialize the tree-sitter parser
23
+ * This is async because tree-sitter WASM needs to be loaded
24
+ */
25
+ async initialize() {
26
+ if (this.initialized) return;
27
+ try {
28
+ // TODO: Initialize tree-sitter-python
29
+ // const Parser = await import('web-tree-sitter');
30
+ // await Parser.init();
31
+ // this.parser = new Parser();
32
+ // const Python = await Parser.Language.load('tree-sitter-python.wasm');
33
+ // this.parser.setLanguage(Python);
34
+ this.initialized = true;
35
+ } catch (error) {
36
+ throw new Error(`Failed to initialize Python parser: ${error.message}`);
20
37
  }
21
- /**
22
- * Initialize the tree-sitter parser
23
- * This is async because tree-sitter WASM needs to be loaded
24
- */
25
- async initialize() {
26
- if (this.initialized)
27
- return;
28
- try {
29
- // TODO: Initialize tree-sitter-python
30
- // const Parser = await import('web-tree-sitter');
31
- // await Parser.init();
32
- // this.parser = new Parser();
33
- // const Python = await Parser.Language.load('tree-sitter-python.wasm');
34
- // this.parser.setLanguage(Python);
35
- this.initialized = true;
36
- }
37
- catch (error) {
38
- throw new Error(`Failed to initialize Python parser: ${error.message}`);
39
- }
38
+ }
39
+ parse(code, filePath) {
40
+ // TODO: Implement when tree-sitter is configured
41
+ // For now, return a basic parse with regex-based extraction
42
+ try {
43
+ const imports = this.extractImportsRegex(code, filePath);
44
+ const exports = this.extractExportsRegex(code, filePath);
45
+ return {
46
+ exports,
47
+ imports,
48
+ language: Language.Python,
49
+ warnings: [
50
+ 'Python parsing is currently using regex-based extraction. Tree-sitter support coming soon.',
51
+ ],
52
+ };
53
+ } catch (error) {
54
+ throw new ParseError(
55
+ `Failed to parse Python file ${filePath}: ${error.message}`,
56
+ filePath
57
+ );
40
58
  }
41
- parse(code, filePath) {
42
- // TODO: Implement when tree-sitter is configured
43
- // For now, return a basic parse with regex-based extraction
44
- try {
45
- const imports = this.extractImportsRegex(code, filePath);
46
- const exports = this.extractExportsRegex(code, filePath);
47
- return {
48
- exports,
49
- imports,
50
- language: Language.Python,
51
- warnings: ['Python parsing is currently using regex-based extraction. Tree-sitter support coming soon.'],
52
- };
53
- }
54
- catch (error) {
55
- throw new ParseError(`Failed to parse Python file ${filePath}: ${error.message}`, filePath);
59
+ }
60
+ getNamingConventions() {
61
+ // PEP 8 naming conventions
62
+ return {
63
+ // snake_case for variables and functions
64
+ variablePattern: /^[a-z_][a-z0-9_]*$/,
65
+ functionPattern: /^[a-z_][a-z0-9_]*$/,
66
+ // PascalCase for classes
67
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
68
+ // UPPER_CASE for constants
69
+ constantPattern: /^[A-Z][A-Z0-9_]*$/,
70
+ // Python special methods and common exceptions
71
+ exceptions: [
72
+ '__init__',
73
+ '__str__',
74
+ '__repr__',
75
+ '__name__',
76
+ '__main__',
77
+ '__file__',
78
+ '__doc__',
79
+ '__all__',
80
+ '__version__',
81
+ '__author__',
82
+ '__dict__',
83
+ '__class__',
84
+ '__module__',
85
+ '__bases__',
86
+ ],
87
+ };
88
+ }
89
+ canHandle(filePath) {
90
+ return filePath.toLowerCase().endsWith('.py');
91
+ }
92
+ /**
93
+ * Regex-based import extraction (temporary implementation)
94
+ */
95
+ extractImportsRegex(code, filePath) {
96
+ const imports = [];
97
+ const lines = code.split('\n');
98
+ // Match: import module
99
+ // Match: import module as alias
100
+ // Match: from module import name
101
+ // Match: from module import name1, name2
102
+ // Match: from module import *
103
+ const importRegex = /^\s*import\s+([a-zA-Z0-9_., ]+)/;
104
+ const fromImportRegex = /^\s*from\s+([a-zA-Z0-9_.]+)\s+import\s+(.+)/;
105
+ lines.forEach((line, idx) => {
106
+ // Skip comments
107
+ if (line.trim().startsWith('#')) return;
108
+ // Handle "import module"
109
+ const importMatch = line.match(importRegex);
110
+ if (importMatch) {
111
+ const modules = importMatch[1]
112
+ .split(',')
113
+ .map((m) => m.trim().split(' as ')[0]);
114
+ modules.forEach((module) => {
115
+ imports.push({
116
+ source: module,
117
+ specifiers: [module],
118
+ loc: {
119
+ start: { line: idx + 1, column: 0 },
120
+ end: { line: idx + 1, column: line.length },
121
+ },
122
+ });
123
+ });
124
+ return;
125
+ }
126
+ // Handle "from module import ..."
127
+ const fromMatch = line.match(fromImportRegex);
128
+ if (fromMatch) {
129
+ const module = fromMatch[1];
130
+ const imports_str = fromMatch[2];
131
+ // Handle "from module import *"
132
+ if (imports_str.trim() === '*') {
133
+ imports.push({
134
+ source: module,
135
+ specifiers: ['*'],
136
+ loc: {
137
+ start: { line: idx + 1, column: 0 },
138
+ end: { line: idx + 1, column: line.length },
139
+ },
140
+ });
141
+ return;
56
142
  }
57
- }
58
- getNamingConventions() {
59
- // PEP 8 naming conventions
60
- return {
61
- // snake_case for variables and functions
62
- variablePattern: /^[a-z_][a-z0-9_]*$/,
63
- functionPattern: /^[a-z_][a-z0-9_]*$/,
64
- // PascalCase for classes
65
- classPattern: /^[A-Z][a-zA-Z0-9]*$/,
66
- // UPPER_CASE for constants
67
- constantPattern: /^[A-Z][A-Z0-9_]*$/,
68
- // Python special methods and common exceptions
69
- exceptions: [
70
- '__init__',
71
- '__str__',
72
- '__repr__',
73
- '__name__',
74
- '__main__',
75
- '__file__',
76
- '__doc__',
77
- '__all__',
78
- '__version__',
79
- '__author__',
80
- '__dict__',
81
- '__class__',
82
- '__module__',
83
- '__bases__',
84
- ],
85
- };
86
- }
87
- canHandle(filePath) {
88
- return filePath.toLowerCase().endsWith('.py');
89
- }
90
- /**
91
- * Regex-based import extraction (temporary implementation)
92
- */
93
- extractImportsRegex(code, filePath) {
94
- const imports = [];
95
- const lines = code.split('\n');
96
- // Match: import module
97
- // Match: import module as alias
98
- // Match: from module import name
99
- // Match: from module import name1, name2
100
- // Match: from module import *
101
- const importRegex = /^\s*import\s+([a-zA-Z0-9_., ]+)/;
102
- const fromImportRegex = /^\s*from\s+([a-zA-Z0-9_.]+)\s+import\s+(.+)/;
103
- lines.forEach((line, idx) => {
104
- // Skip comments
105
- if (line.trim().startsWith('#'))
106
- return;
107
- // Handle "import module"
108
- const importMatch = line.match(importRegex);
109
- if (importMatch) {
110
- const modules = importMatch[1].split(',').map(m => m.trim().split(' as ')[0]);
111
- modules.forEach(module => {
112
- imports.push({
113
- source: module,
114
- specifiers: [module],
115
- loc: {
116
- start: { line: idx + 1, column: 0 },
117
- end: { line: idx + 1, column: line.length },
118
- },
119
- });
120
- });
121
- return;
122
- }
123
- // Handle "from module import ..."
124
- const fromMatch = line.match(fromImportRegex);
125
- if (fromMatch) {
126
- const module = fromMatch[1];
127
- const imports_str = fromMatch[2];
128
- // Handle "from module import *"
129
- if (imports_str.trim() === '*') {
130
- imports.push({
131
- source: module,
132
- specifiers: ['*'],
133
- loc: {
134
- start: { line: idx + 1, column: 0 },
135
- end: { line: idx + 1, column: line.length },
136
- },
137
- });
138
- return;
139
- }
140
- // Handle "from module import name1, name2"
141
- const specifiers = imports_str
142
- .split(',')
143
- .map(s => s.trim().split(' as ')[0]);
144
- imports.push({
145
- source: module,
146
- specifiers,
147
- loc: {
148
- start: { line: idx + 1, column: 0 },
149
- end: { line: idx + 1, column: line.length },
150
- },
151
- });
152
- }
143
+ // Handle "from module import name1, name2"
144
+ const specifiers = imports_str
145
+ .split(',')
146
+ .map((s) => s.trim().split(' as ')[0]);
147
+ imports.push({
148
+ source: module,
149
+ specifiers,
150
+ loc: {
151
+ start: { line: idx + 1, column: 0 },
152
+ end: { line: idx + 1, column: line.length },
153
+ },
153
154
  });
154
- return imports;
155
- }
156
- /**
157
- * Regex-based export extraction (temporary implementation)
158
- *
159
- * Python doesn't have explicit exports like JavaScript.
160
- * We extract:
161
- * - Functions defined at module level (def)
162
- * - Classes defined at module level (class)
163
- * - Variables in __all__ list
164
- */
165
- extractExportsRegex(code, filePath) {
166
- const exports = [];
167
- const lines = code.split('\n');
168
- // Extract functions: def function_name(
169
- const functionRegex = /^def\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/;
170
- // Extract classes: class ClassName
171
- const classRegex = /^class\s+([a-zA-Z_][a-zA-Z0-9_]*)/;
172
- // Extract from __all__
173
- const allRegex = /__all__\s*=\s*\[([^\]]+)\]/;
174
- let inClass = false;
175
- let classIndent = 0;
176
- lines.forEach((line, idx) => {
177
- const indent = line.search(/\S/);
178
- // Track if we're inside a class (for filtering out methods)
179
- if (line.match(classRegex)) {
180
- inClass = true;
181
- classIndent = indent;
182
- }
183
- else if (inClass && indent <= classIndent && line.trim()) {
184
- inClass = false;
185
- }
186
- // Skip if inside a class (methods are not module-level exports)
187
- if (inClass) {
188
- // But do extract the class itself
189
- const classMatch = line.match(classRegex);
190
- if (classMatch) {
191
- exports.push({
192
- name: classMatch[1],
193
- type: 'class',
194
- loc: {
195
- start: { line: idx + 1, column: indent },
196
- end: { line: idx + 1, column: line.length },
197
- },
198
- });
199
- }
200
- return;
201
- }
202
- // Extract functions (only at module level)
203
- const funcMatch = line.match(functionRegex);
204
- if (funcMatch && indent === 0) {
205
- const name = funcMatch[1];
206
- // Skip private functions (starting with _) unless in __all__
207
- if (!name.startsWith('_') || name.startsWith('__')) {
208
- exports.push({
209
- name,
210
- type: 'function',
211
- loc: {
212
- start: { line: idx + 1, column: 0 },
213
- end: { line: idx + 1, column: line.length },
214
- },
215
- });
216
- }
217
- }
218
- // Extract from __all__
219
- const allMatch = line.match(allRegex);
220
- if (allMatch) {
221
- const names = allMatch[1]
222
- .split(',')
223
- .map(n => n.trim().replace(/['"]/g, ''));
224
- names.forEach(name => {
225
- if (name && !exports.find(e => e.name === name)) {
226
- exports.push({
227
- name,
228
- type: 'variable',
229
- loc: {
230
- start: { line: idx + 1, column: 0 },
231
- end: { line: idx + 1, column: line.length },
232
- },
233
- });
234
- }
235
- });
236
- }
155
+ }
156
+ });
157
+ return imports;
158
+ }
159
+ /**
160
+ * Regex-based export extraction (temporary implementation)
161
+ *
162
+ * Python doesn't have explicit exports like JavaScript.
163
+ * We extract:
164
+ * - Functions defined at module level (def)
165
+ * - Classes defined at module level (class)
166
+ * - Variables in __all__ list
167
+ */
168
+ extractExportsRegex(code, filePath) {
169
+ const exports = [];
170
+ const lines = code.split('\n');
171
+ // Extract functions: def function_name(
172
+ const functionRegex = /^def\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/;
173
+ // Extract classes: class ClassName
174
+ const classRegex = /^class\s+([a-zA-Z_][a-zA-Z0-9_]*)/;
175
+ // Extract from __all__
176
+ const allRegex = /__all__\s*=\s*\[([^\]]+)\]/;
177
+ let inClass = false;
178
+ let classIndent = 0;
179
+ lines.forEach((line, idx) => {
180
+ const indent = line.search(/\S/);
181
+ // Track if we're inside a class (for filtering out methods)
182
+ if (line.match(classRegex)) {
183
+ inClass = true;
184
+ classIndent = indent;
185
+ } else if (inClass && indent <= classIndent && line.trim()) {
186
+ inClass = false;
187
+ }
188
+ // Skip if inside a class (methods are not module-level exports)
189
+ if (inClass) {
190
+ // But do extract the class itself
191
+ const classMatch = line.match(classRegex);
192
+ if (classMatch) {
193
+ exports.push({
194
+ name: classMatch[1],
195
+ type: 'class',
196
+ loc: {
197
+ start: { line: idx + 1, column: indent },
198
+ end: { line: idx + 1, column: line.length },
199
+ },
200
+ });
201
+ }
202
+ return;
203
+ }
204
+ // Extract functions (only at module level)
205
+ const funcMatch = line.match(functionRegex);
206
+ if (funcMatch && indent === 0) {
207
+ const name = funcMatch[1];
208
+ // Skip private functions (starting with _) unless in __all__
209
+ if (!name.startsWith('_') || name.startsWith('__')) {
210
+ exports.push({
211
+ name,
212
+ type: 'function',
213
+ loc: {
214
+ start: { line: idx + 1, column: 0 },
215
+ end: { line: idx + 1, column: line.length },
216
+ },
217
+ });
218
+ }
219
+ }
220
+ // Extract from __all__
221
+ const allMatch = line.match(allRegex);
222
+ if (allMatch) {
223
+ const names = allMatch[1]
224
+ .split(',')
225
+ .map((n) => n.trim().replace(/['"]/g, ''));
226
+ names.forEach((name) => {
227
+ if (name && !exports.find((e) => e.name === name)) {
228
+ exports.push({
229
+ name,
230
+ type: 'variable',
231
+ loc: {
232
+ start: { line: idx + 1, column: 0 },
233
+ end: { line: idx + 1, column: line.length },
234
+ },
235
+ });
236
+ }
237
237
  });
238
- return exports;
239
- }
238
+ }
239
+ });
240
+ return exports;
241
+ }
240
242
  }
241
- //# sourceMappingURL=python-parser.js.map
243
+ //# sourceMappingURL=python-parser.js.map
@@ -3,15 +3,20 @@
3
3
  *
4
4
  * Parses TypeScript and JavaScript files using @typescript-eslint/typescript-estree
5
5
  */
6
- import { Language, LanguageParser, ParseResult, NamingConvention } from '../types/language';
6
+ import {
7
+ Language,
8
+ LanguageParser,
9
+ ParseResult,
10
+ NamingConvention,
11
+ } from '../types/language';
7
12
  export declare class TypeScriptParser implements LanguageParser {
8
- readonly language = Language.TypeScript;
9
- readonly extensions: string[];
10
- parse(code: string, filePath: string): ParseResult;
11
- getNamingConventions(): NamingConvention;
12
- canHandle(filePath: string): boolean;
13
- private extractImports;
14
- private extractExports;
15
- private extractFromDeclaration;
13
+ readonly language = Language.TypeScript;
14
+ readonly extensions: string[];
15
+ parse(code: string, filePath: string): ParseResult;
16
+ getNamingConventions(): NamingConvention;
17
+ canHandle(filePath: string): boolean;
18
+ private extractImports;
19
+ private extractExports;
20
+ private extractFromDeclaration;
16
21
  }
17
- //# sourceMappingURL=typescript-parser.d.ts.map
22
+ //# sourceMappingURL=typescript-parser.d.ts.map