@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
@@ -2,4 +2,4 @@
2
2
  * Test multi-language parser factory
3
3
  */
4
4
  export {};
5
- //# sourceMappingURL=parser-factory.test.d.ts.map
5
+ //# sourceMappingURL=parser-factory.test.d.ts.map
@@ -2,57 +2,69 @@
2
2
  * Test multi-language parser factory
3
3
  */
4
4
  import { describe, it, expect } from 'vitest';
5
- import { ParserFactory, Language, getParser, isFileSupported, getSupportedLanguages, } from '../parsers/parser-factory';
5
+ import {
6
+ ParserFactory,
7
+ Language,
8
+ getParser,
9
+ isFileSupported,
10
+ getSupportedLanguages,
11
+ } from '../parsers/parser-factory';
6
12
  describe('ParserFactory', () => {
7
- it('should return TypeScript parser for .ts files', () => {
8
- const parser = getParser('test.ts');
9
- expect(parser).toBeDefined();
10
- expect(parser?.language).toBe(Language.TypeScript);
11
- });
12
- it('should return TypeScript parser for .tsx files', () => {
13
- const parser = getParser('component.tsx');
14
- expect(parser).toBeDefined();
15
- expect(parser?.language).toBe(Language.TypeScript);
16
- });
17
- it('should return JavaScript parser for .js files', () => {
18
- const parser = getParser('script.js');
19
- expect(parser).toBeDefined();
20
- expect(parser?.language).toBe(Language.TypeScript); // TS parser handles JS too
21
- });
22
- it('should return Python parser for .py files', () => {
23
- const parser = getParser('script.py');
24
- expect(parser).toBeDefined();
25
- expect(parser?.language).toBe(Language.Python);
26
- });
27
- it('should return null for unsupported files', () => {
28
- const parser = getParser('README.md');
29
- expect(parser).toBeNull();
30
- });
31
- it('should correctly identify supported files', () => {
32
- expect(isFileSupported('test.ts')).toBe(true);
33
- expect(isFileSupported('test.py')).toBe(true);
34
- expect(isFileSupported('test.java')).toBe(false); // Not yet implemented
35
- expect(isFileSupported('README.md')).toBe(false);
36
- });
37
- it('should list all supported languages', () => {
38
- const languages = getSupportedLanguages();
39
- expect(languages).toContain(Language.TypeScript);
40
- expect(languages).toContain(Language.Python);
41
- expect(languages.length).toBeGreaterThanOrEqual(2);
42
- });
43
- it('should be case-insensitive for extensions', () => {
44
- expect(getParser('Test.TS')).toBeDefined();
45
- expect(getParser('Test.PY')).toBeDefined();
46
- });
13
+ it('should return TypeScript parser for .ts files', () => {
14
+ const parser = getParser('test.ts');
15
+ expect(parser).toBeDefined();
16
+ expect(parser?.language).toBe(Language.TypeScript);
17
+ });
18
+ it('should return TypeScript parser for .tsx files', () => {
19
+ const parser = getParser('component.tsx');
20
+ expect(parser).toBeDefined();
21
+ expect(parser?.language).toBe(Language.TypeScript);
22
+ });
23
+ it('should return JavaScript parser for .js files', () => {
24
+ const parser = getParser('script.js');
25
+ expect(parser).toBeDefined();
26
+ expect(parser?.language).toBe(Language.TypeScript); // TS parser handles JS too
27
+ });
28
+ it('should return Python parser for .py files', () => {
29
+ const parser = getParser('script.py');
30
+ expect(parser).toBeDefined();
31
+ expect(parser?.language).toBe(Language.Python);
32
+ });
33
+ it('should return null for unsupported files', () => {
34
+ const parser = getParser('README.md');
35
+ expect(parser).toBeNull();
36
+ });
37
+ it('should correctly identify supported files', () => {
38
+ expect(isFileSupported('test.ts')).toBe(true);
39
+ expect(isFileSupported('test.py')).toBe(true);
40
+ expect(isFileSupported('test.java')).toBe(false); // Not yet implemented
41
+ expect(isFileSupported('README.md')).toBe(false);
42
+ });
43
+ it('should list all supported languages', () => {
44
+ const languages = getSupportedLanguages();
45
+ expect(languages).toContain(Language.TypeScript);
46
+ expect(languages).toContain(Language.Python);
47
+ expect(languages.length).toBeGreaterThanOrEqual(2);
48
+ });
49
+ it('should be case-insensitive for extensions', () => {
50
+ expect(getParser('Test.TS')).toBeDefined();
51
+ expect(getParser('Test.PY')).toBeDefined();
52
+ });
47
53
  });
48
54
  describe('Language Detection', () => {
49
- it('should detect language from file path', () => {
50
- const factory = ParserFactory.getInstance();
51
- expect(factory.getLanguageForFile('src/index.ts')).toBe(Language.TypeScript);
52
- expect(factory.getLanguageForFile('src/component.tsx')).toBe(Language.TypeScript);
53
- expect(factory.getLanguageForFile('src/script.js')).toBe(Language.JavaScript);
54
- expect(factory.getLanguageForFile('src/main.py')).toBe(Language.Python);
55
- expect(factory.getLanguageForFile('README.md')).toBeNull();
56
- });
55
+ it('should detect language from file path', () => {
56
+ const factory = ParserFactory.getInstance();
57
+ expect(factory.getLanguageForFile('src/index.ts')).toBe(
58
+ Language.TypeScript
59
+ );
60
+ expect(factory.getLanguageForFile('src/component.tsx')).toBe(
61
+ Language.TypeScript
62
+ );
63
+ expect(factory.getLanguageForFile('src/script.js')).toBe(
64
+ Language.JavaScript
65
+ );
66
+ expect(factory.getLanguageForFile('src/main.py')).toBe(Language.Python);
67
+ expect(factory.getLanguageForFile('README.md')).toBeNull();
68
+ });
57
69
  });
58
- //# sourceMappingURL=parser-factory.test.js.map
70
+ //# sourceMappingURL=parser-factory.test.js.map
@@ -2,4 +2,4 @@
2
2
  * Test Python parser
3
3
  */
4
4
  export {};
5
- //# sourceMappingURL=python-parser.test.d.ts.map
5
+ //# sourceMappingURL=python-parser.test.d.ts.map
@@ -5,83 +5,83 @@ import { describe, it, expect } from 'vitest';
5
5
  import { PythonParser } from '../parsers/python-parser';
6
6
  import { Language } from '../types/language';
7
7
  describe('PythonParser', () => {
8
- const parser = new PythonParser();
9
- it('should have correct language and extensions', () => {
10
- expect(parser.language).toBe(Language.Python);
11
- expect(parser.extensions).toContain('.py');
12
- });
13
- it('should handle .py files', () => {
14
- expect(parser.canHandle('test.py')).toBe(true);
15
- expect(parser.canHandle('Test.PY')).toBe(true);
16
- expect(parser.canHandle('test.ts')).toBe(false);
17
- });
18
- it('should return PEP 8 naming conventions', () => {
19
- const conventions = parser.getNamingConventions();
20
- // Variables and functions should be snake_case
21
- expect(conventions.variablePattern.test('my_variable')).toBe(true);
22
- expect(conventions.variablePattern.test('myVariable')).toBe(false);
23
- expect(conventions.functionPattern.test('my_function')).toBe(true);
24
- // Classes should be PascalCase
25
- expect(conventions.classPattern.test('MyClass')).toBe(true);
26
- expect(conventions.classPattern.test('my_class')).toBe(false);
27
- // Constants should be UPPER_CASE
28
- expect(conventions.constantPattern.test('MY_CONSTANT')).toBe(true);
29
- expect(conventions.constantPattern.test('myConstant')).toBe(false);
30
- // Should have Python special method exceptions
31
- expect(conventions.exceptions).toContain('__init__');
32
- expect(conventions.exceptions).toContain('__str__');
33
- });
34
- describe('Import Extraction', () => {
35
- it('should extract simple imports', () => {
36
- const code = `
8
+ const parser = new PythonParser();
9
+ it('should have correct language and extensions', () => {
10
+ expect(parser.language).toBe(Language.Python);
11
+ expect(parser.extensions).toContain('.py');
12
+ });
13
+ it('should handle .py files', () => {
14
+ expect(parser.canHandle('test.py')).toBe(true);
15
+ expect(parser.canHandle('Test.PY')).toBe(true);
16
+ expect(parser.canHandle('test.ts')).toBe(false);
17
+ });
18
+ it('should return PEP 8 naming conventions', () => {
19
+ const conventions = parser.getNamingConventions();
20
+ // Variables and functions should be snake_case
21
+ expect(conventions.variablePattern.test('my_variable')).toBe(true);
22
+ expect(conventions.variablePattern.test('myVariable')).toBe(false);
23
+ expect(conventions.functionPattern.test('my_function')).toBe(true);
24
+ // Classes should be PascalCase
25
+ expect(conventions.classPattern.test('MyClass')).toBe(true);
26
+ expect(conventions.classPattern.test('my_class')).toBe(false);
27
+ // Constants should be UPPER_CASE
28
+ expect(conventions.constantPattern.test('MY_CONSTANT')).toBe(true);
29
+ expect(conventions.constantPattern.test('myConstant')).toBe(false);
30
+ // Should have Python special method exceptions
31
+ expect(conventions.exceptions).toContain('__init__');
32
+ expect(conventions.exceptions).toContain('__str__');
33
+ });
34
+ describe('Import Extraction', () => {
35
+ it('should extract simple imports', () => {
36
+ const code = `
37
37
  import os
38
38
  import sys
39
39
  import json
40
40
  `;
41
- const result = parser.parse(code, 'test.py');
42
- expect(result.imports).toHaveLength(3);
43
- expect(result.imports[0].source).toBe('os');
44
- expect(result.imports[1].source).toBe('sys');
45
- expect(result.imports[2].source).toBe('json');
46
- });
47
- it('should extract from imports', () => {
48
- const code = `
41
+ const result = parser.parse(code, 'test.py');
42
+ expect(result.imports).toHaveLength(3);
43
+ expect(result.imports[0].source).toBe('os');
44
+ expect(result.imports[1].source).toBe('sys');
45
+ expect(result.imports[2].source).toBe('json');
46
+ });
47
+ it('should extract from imports', () => {
48
+ const code = `
49
49
  from typing import List, Dict, Optional
50
50
  from pathlib import Path
51
51
  `;
52
- const result = parser.parse(code, 'test.py');
53
- expect(result.imports).toHaveLength(2);
54
- const typingImport = result.imports.find(i => i.source === 'typing');
55
- expect(typingImport).toBeDefined();
56
- expect(typingImport?.specifiers).toContain('List');
57
- expect(typingImport?.specifiers).toContain('Dict');
58
- expect(typingImport?.specifiers).toContain('Optional');
59
- const pathlibImport = result.imports.find(i => i.source === 'pathlib');
60
- expect(pathlibImport?.specifiers).toContain('Path');
61
- });
62
- it('should handle wildcard imports', () => {
63
- const code = `from os import *`;
64
- const result = parser.parse(code, 'test.py');
65
- expect(result.imports[0].source).toBe('os');
66
- expect(result.imports[0].specifiers).toContain('*');
67
- });
52
+ const result = parser.parse(code, 'test.py');
53
+ expect(result.imports).toHaveLength(2);
54
+ const typingImport = result.imports.find((i) => i.source === 'typing');
55
+ expect(typingImport).toBeDefined();
56
+ expect(typingImport?.specifiers).toContain('List');
57
+ expect(typingImport?.specifiers).toContain('Dict');
58
+ expect(typingImport?.specifiers).toContain('Optional');
59
+ const pathlibImport = result.imports.find((i) => i.source === 'pathlib');
60
+ expect(pathlibImport?.specifiers).toContain('Path');
61
+ });
62
+ it('should handle wildcard imports', () => {
63
+ const code = `from os import *`;
64
+ const result = parser.parse(code, 'test.py');
65
+ expect(result.imports[0].source).toBe('os');
66
+ expect(result.imports[0].specifiers).toContain('*');
68
67
  });
69
- describe('Export Extraction', () => {
70
- it('should extract module-level functions', () => {
71
- const code = `
68
+ });
69
+ describe('Export Extraction', () => {
70
+ it('should extract module-level functions', () => {
71
+ const code = `
72
72
  def public_function():
73
73
  pass
74
74
 
75
75
  def another_function(arg1, arg2):
76
76
  return arg1 + arg2
77
77
  `;
78
- const result = parser.parse(code, 'test.py');
79
- const funcNames = result.exports.map(e => e.name);
80
- expect(funcNames).toContain('public_function');
81
- expect(funcNames).toContain('another_function');
82
- });
83
- it('should extract classes', () => {
84
- const code = `
78
+ const result = parser.parse(code, 'test.py');
79
+ const funcNames = result.exports.map((e) => e.name);
80
+ expect(funcNames).toContain('public_function');
81
+ expect(funcNames).toContain('another_function');
82
+ });
83
+ it('should extract classes', () => {
84
+ const code = `
85
85
  class MyClass:
86
86
  def __init__(self):
87
87
  self.value = 0
@@ -92,16 +92,18 @@ class MyClass:
92
92
  class AnotherClass:
93
93
  pass
94
94
  `;
95
- const result = parser.parse(code, 'test.py');
96
- const classNames = result.exports.filter(e => e.type === 'class').map(e => e.name);
97
- expect(classNames).toContain('MyClass');
98
- expect(classNames).toContain('AnotherClass');
99
- // Methods should not be exported as separate entities
100
- const methodNames = result.exports.map(e => e.name);
101
- expect(methodNames).not.toContain('method');
102
- });
103
- it('should not export private functions', () => {
104
- const code = `
95
+ const result = parser.parse(code, 'test.py');
96
+ const classNames = result.exports
97
+ .filter((e) => e.type === 'class')
98
+ .map((e) => e.name);
99
+ expect(classNames).toContain('MyClass');
100
+ expect(classNames).toContain('AnotherClass');
101
+ // Methods should not be exported as separate entities
102
+ const methodNames = result.exports.map((e) => e.name);
103
+ expect(methodNames).not.toContain('method');
104
+ });
105
+ it('should not export private functions', () => {
106
+ const code = `
105
107
  def public_function():
106
108
  pass
107
109
 
@@ -111,14 +113,14 @@ def _private_function():
111
113
  def __dunder_function__():
112
114
  pass
113
115
  `;
114
- const result = parser.parse(code, 'test.py');
115
- const funcNames = result.exports.map(e => e.name);
116
- expect(funcNames).toContain('public_function');
117
- expect(funcNames).toContain('__dunder_function__'); // Dunder methods are included
118
- expect(funcNames).not.toContain('_private_function'); // Single underscore excluded
119
- });
120
- it('should extract __all__ exports', () => {
121
- const code = `
116
+ const result = parser.parse(code, 'test.py');
117
+ const funcNames = result.exports.map((e) => e.name);
118
+ expect(funcNames).toContain('public_function');
119
+ expect(funcNames).toContain('__dunder_function__'); // Dunder methods are included
120
+ expect(funcNames).not.toContain('_private_function'); // Single underscore excluded
121
+ });
122
+ it('should extract __all__ exports', () => {
123
+ const code = `
122
124
  __all__ = ['foo', 'bar', 'MyClass']
123
125
 
124
126
  def foo():
@@ -130,22 +132,22 @@ def bar():
130
132
  class MyClass:
131
133
  pass
132
134
  `;
133
- const result = parser.parse(code, 'test.py');
134
- const names = result.exports.map(e => e.name);
135
- expect(names).toContain('foo');
136
- expect(names).toContain('bar');
137
- expect(names).toContain('MyClass');
138
- });
135
+ const result = parser.parse(code, 'test.py');
136
+ const names = result.exports.map((e) => e.name);
137
+ expect(names).toContain('foo');
138
+ expect(names).toContain('bar');
139
+ expect(names).toContain('MyClass');
139
140
  });
140
- it('should include warning about regex-based parsing', () => {
141
- const code = 'import os';
142
- const result = parser.parse(code, 'test.py');
143
- expect(result.warnings).toBeDefined();
144
- expect(result.warnings.length).toBeGreaterThan(0);
145
- expect(result.warnings[0]).toContain('regex-based');
146
- });
147
- it('should parse real-world Python code', () => {
148
- const code = `
141
+ });
142
+ it('should include warning about regex-based parsing', () => {
143
+ const code = 'import os';
144
+ const result = parser.parse(code, 'test.py');
145
+ expect(result.warnings).toBeDefined();
146
+ expect(result.warnings.length).toBeGreaterThan(0);
147
+ expect(result.warnings[0]).toContain('regex-based');
148
+ });
149
+ it('should parse real-world Python code', () => {
150
+ const code = `
149
151
  """
150
152
  A sample Python module
151
153
  """
@@ -176,17 +178,17 @@ def _helper_function():
176
178
 
177
179
  MY_CONSTANT = 42
178
180
  `;
179
- const result = parser.parse(code, 'example.py');
180
- // Check imports
181
- expect(result.imports.length).toBeGreaterThan(0);
182
- const typingImport = result.imports.find(i => i.source === 'typing');
183
- expect(typingImport).toBeDefined();
184
- // Check exports
185
- const exportNames = result.exports.map(e => e.name);
186
- expect(exportNames).toContain('DataProcessor');
187
- expect(exportNames).toContain('process_data');
188
- expect(exportNames).not.toContain('_helper_function');
189
- expect(exportNames).not.toContain('process'); // Method, not module-level
190
- });
181
+ const result = parser.parse(code, 'example.py');
182
+ // Check imports
183
+ expect(result.imports.length).toBeGreaterThan(0);
184
+ const typingImport = result.imports.find((i) => i.source === 'typing');
185
+ expect(typingImport).toBeDefined();
186
+ // Check exports
187
+ const exportNames = result.exports.map((e) => e.name);
188
+ expect(exportNames).toContain('DataProcessor');
189
+ expect(exportNames).toContain('process_data');
190
+ expect(exportNames).not.toContain('_helper_function');
191
+ expect(exportNames).not.toContain('process'); // Method, not module-level
192
+ });
191
193
  });
192
- //# sourceMappingURL=python-parser.test.js.map
194
+ //# sourceMappingURL=python-parser.test.js.map
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=scoring.test.d.ts.map
2
+ //# sourceMappingURL=scoring.test.d.ts.map