@aiready/core 0.23.1 → 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 -1094
  50. package/dist/client.d.ts +2 -1094
  51. package/dist/client.js +23 -43
  52. package/dist/client.mjs +3 -25
  53. package/dist/index.d.mts +380 -108
  54. package/dist/index.d.ts +380 -108
  55. package/dist/index.js +609 -445
  56. package/dist/index.mjs +587 -429
  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 +2 -2
@@ -2,81 +2,79 @@ import { readFileSync, existsSync } from 'fs';
2
2
  import { join, resolve, dirname } from 'path';
3
3
  import { pathToFileURL } from 'url';
4
4
  const CONFIG_FILES = [
5
- 'aiready.json',
6
- 'aiready.config.json',
7
- '.aiready.json',
8
- '.aireadyrc.json',
9
- 'aiready.config.js',
10
- '.aireadyrc.js'
5
+ 'aiready.json',
6
+ 'aiready.config.json',
7
+ '.aiready.json',
8
+ '.aireadyrc.json',
9
+ 'aiready.config.js',
10
+ '.aireadyrc.js',
11
11
  ];
12
12
  export async function loadConfig(rootDir) {
13
- // Search upwards from the provided directory to find the nearest config
14
- let currentDir = resolve(rootDir);
15
- while (true) {
16
- for (const configFile of CONFIG_FILES) {
17
- const configPath = join(currentDir, configFile);
18
- if (existsSync(configPath)) {
19
- try {
20
- let config;
21
- if (configFile.endsWith('.js')) {
22
- // For JS files, use dynamic ES import
23
- const fileUrl = pathToFileURL(configPath).href;
24
- const module = await import(`${fileUrl}?t=${Date.now()}`);
25
- config = module.default || module;
26
- }
27
- else {
28
- // For JSON files, parse them
29
- const content = readFileSync(configPath, 'utf-8');
30
- config = JSON.parse(content);
31
- }
32
- // Basic validation
33
- if (typeof config !== 'object' || config === null) {
34
- throw new Error('Config must be an object');
35
- }
36
- return config;
37
- }
38
- catch (error) {
39
- const errorMessage = error instanceof Error ? error.message : String(error);
40
- throw new Error(`Failed to load config from ${configPath}: ${errorMessage}`);
41
- }
42
- }
13
+ // Search upwards from the provided directory to find the nearest config
14
+ let currentDir = resolve(rootDir);
15
+ while (true) {
16
+ for (const configFile of CONFIG_FILES) {
17
+ const configPath = join(currentDir, configFile);
18
+ if (existsSync(configPath)) {
19
+ try {
20
+ let config;
21
+ if (configFile.endsWith('.js')) {
22
+ // For JS files, use dynamic ES import
23
+ const fileUrl = pathToFileURL(configPath).href;
24
+ const module = await import(`${fileUrl}?t=${Date.now()}`);
25
+ config = module.default || module;
26
+ } else {
27
+ // For JSON files, parse them
28
+ const content = readFileSync(configPath, 'utf-8');
29
+ config = JSON.parse(content);
30
+ }
31
+ // Basic validation
32
+ if (typeof config !== 'object' || config === null) {
33
+ throw new Error('Config must be an object');
34
+ }
35
+ return config;
36
+ } catch (error) {
37
+ const errorMessage =
38
+ error instanceof Error ? error.message : String(error);
39
+ throw new Error(
40
+ `Failed to load config from ${configPath}: ${errorMessage}`
41
+ );
43
42
  }
44
- const parent = dirname(currentDir);
45
- if (parent === currentDir) {
46
- break; // Reached filesystem root
47
- }
48
- currentDir = parent;
43
+ }
44
+ }
45
+ const parent = dirname(currentDir);
46
+ if (parent === currentDir) {
47
+ break; // Reached filesystem root
49
48
  }
50
- return null;
49
+ currentDir = parent;
50
+ }
51
+ return null;
51
52
  }
52
53
  export function mergeConfigWithDefaults(userConfig, defaults) {
53
- if (!userConfig)
54
- return defaults;
55
- const result = { ...defaults };
56
- // Merge scan options
57
- if (userConfig.scan) {
58
- if (userConfig.scan.include)
59
- result.include = userConfig.scan.include;
60
- if (userConfig.scan.exclude)
61
- result.exclude = userConfig.scan.exclude;
62
- }
63
- // Merge tool-specific options
64
- if (userConfig.tools) {
65
- for (const [toolName, toolConfig] of Object.entries(userConfig.tools)) {
66
- if (typeof toolConfig === 'object' && toolConfig !== null) {
67
- // For pattern-detect and context-analyzer tools, merge options directly into result
68
- if (toolName === 'pattern-detect' || toolName === 'context-analyzer') {
69
- Object.assign(result, toolConfig);
70
- }
71
- // Add other tool configs under their names for future use
72
- result[toolName] = { ...result[toolName], ...toolConfig };
73
- }
54
+ if (!userConfig) return defaults;
55
+ const result = { ...defaults };
56
+ // Merge scan options
57
+ if (userConfig.scan) {
58
+ if (userConfig.scan.include) result.include = userConfig.scan.include;
59
+ if (userConfig.scan.exclude) result.exclude = userConfig.scan.exclude;
60
+ }
61
+ // Merge tool-specific options
62
+ if (userConfig.tools) {
63
+ for (const [toolName, toolConfig] of Object.entries(userConfig.tools)) {
64
+ if (typeof toolConfig === 'object' && toolConfig !== null) {
65
+ // For pattern-detect and context-analyzer tools, merge options directly into result
66
+ if (toolName === 'pattern-detect' || toolName === 'context-analyzer') {
67
+ Object.assign(result, toolConfig);
74
68
  }
69
+ // Add other tool configs under their names for future use
70
+ result[toolName] = { ...result[toolName], ...toolConfig };
71
+ }
75
72
  }
76
- // Merge output preferences
77
- if (userConfig.output) {
78
- result.output = { ...result.output, ...userConfig.output };
79
- }
80
- return result;
73
+ }
74
+ // Merge output preferences
75
+ if (userConfig.output) {
76
+ result.output = { ...result.output, ...userConfig.output };
77
+ }
78
+ return result;
81
79
  }
82
- //# sourceMappingURL=config.js.map
80
+ //# sourceMappingURL=config.js.map
@@ -13,4 +13,4 @@ export declare function scanFiles(options: ScanOptions): Promise<string[]>;
13
13
  export declare function readFileContent(filePath: string): Promise<string>;
14
14
  export declare function getFileExtension(filePath: string): string;
15
15
  export declare function isSourceFile(filePath: string): boolean;
16
- //# sourceMappingURL=file-scanner.d.ts.map
16
+ //# sourceMappingURL=file-scanner.d.ts.map
@@ -3,49 +3,49 @@ import { readFile } from 'fs/promises';
3
3
  import { existsSync } from 'fs';
4
4
  import { join } from 'path';
5
5
  export const DEFAULT_EXCLUDE = [
6
- // Dependencies
7
- '**/node_modules/**',
8
- // Build outputs
9
- '**/dist/**',
10
- '**/build/**',
11
- '**/out/**',
12
- '**/output/**',
13
- '**/target/**',
14
- '**/bin/**',
15
- '**/obj/**',
16
- '**/cdk.out/**',
17
- // Framework-specific build dirs
18
- '**/.next/**',
19
- '**/.nuxt/**',
20
- '**/.vuepress/**',
21
- '**/.cache/**',
22
- '**/.turbo/**',
23
- // Test files and coverage
24
- '**/*.test.*',
25
- '**/*.spec.*',
26
- '**/__tests__/**',
27
- '**/test/**',
28
- '**/tests/**',
29
- '**/coverage/**',
30
- '**/.nyc_output/**',
31
- '**/.jest/**',
32
- // Version control and IDE
33
- '**/.git/**',
34
- '**/.svn/**',
35
- '**/.hg/**',
36
- '**/.vscode/**',
37
- '**/.idea/**',
38
- '**/*.swp',
39
- '**/*.swo',
40
- // Build artifacts and minified files
41
- '**/*.min.js',
42
- '**/*.min.css',
43
- '**/*.bundle.js',
44
- '**/*.tsbuildinfo',
45
- // Logs and temporary files
46
- '**/logs/**',
47
- '**/*.log',
48
- '**/.DS_Store',
6
+ // Dependencies
7
+ '**/node_modules/**',
8
+ // Build outputs
9
+ '**/dist/**',
10
+ '**/build/**',
11
+ '**/out/**',
12
+ '**/output/**',
13
+ '**/target/**',
14
+ '**/bin/**',
15
+ '**/obj/**',
16
+ '**/cdk.out/**',
17
+ // Framework-specific build dirs
18
+ '**/.next/**',
19
+ '**/.nuxt/**',
20
+ '**/.vuepress/**',
21
+ '**/.cache/**',
22
+ '**/.turbo/**',
23
+ // Test files and coverage
24
+ '**/*.test.*',
25
+ '**/*.spec.*',
26
+ '**/__tests__/**',
27
+ '**/test/**',
28
+ '**/tests/**',
29
+ '**/coverage/**',
30
+ '**/.nyc_output/**',
31
+ '**/.jest/**',
32
+ // Version control and IDE
33
+ '**/.git/**',
34
+ '**/.svn/**',
35
+ '**/.hg/**',
36
+ '**/.vscode/**',
37
+ '**/.idea/**',
38
+ '**/*.swp',
39
+ '**/*.swo',
40
+ // Build artifacts and minified files
41
+ '**/*.min.js',
42
+ '**/*.min.css',
43
+ '**/*.bundle.js',
44
+ '**/*.tsbuildinfo',
45
+ // Logs and temporary files
46
+ '**/logs/**',
47
+ '**/*.log',
48
+ '**/.DS_Store',
49
49
  ];
50
50
  /**
51
51
  * Scan files in a directory using glob patterns
@@ -57,44 +57,48 @@ export const DEFAULT_EXCLUDE = [
57
57
  * @returns Array of absolute file paths matching the patterns
58
58
  */
59
59
  export async function scanFiles(options) {
60
- const { rootDir, include = ['**/*.{ts,tsx,js,jsx,py,java,go,rs,cs}'], // Multi-language support
61
- exclude, } = options;
62
- // Always merge user excludes with defaults to ensure critical paths like
63
- // cdk.out, node_modules, build dirs are excluded
64
- // Load .aireadyignore from repository root if present and merge
65
- const ignoreFilePath = join(rootDir || '.', '.aireadyignore');
66
- let ignoreFromFile = [];
67
- if (existsSync(ignoreFilePath)) {
68
- try {
69
- const txt = await readFile(ignoreFilePath, 'utf-8');
70
- ignoreFromFile = txt
71
- .split(/\r?\n/)
72
- .map(s => s.trim())
73
- .filter(Boolean)
74
- .filter(l => !l.startsWith('#'))
75
- .filter(l => !l.startsWith('!')); // ignore negations for now
76
- }
77
- catch (e) {
78
- // noop - fall back to defaults if file can't be read
79
- ignoreFromFile = [];
80
- }
60
+ const {
61
+ rootDir,
62
+ include = ['**/*.{ts,tsx,js,jsx,py,java,go,rs,cs}'], // Multi-language support
63
+ exclude,
64
+ } = options;
65
+ // Always merge user excludes with defaults to ensure critical paths like
66
+ // cdk.out, node_modules, build dirs are excluded
67
+ // Load .aireadyignore from repository root if present and merge
68
+ const ignoreFilePath = join(rootDir || '.', '.aireadyignore');
69
+ let ignoreFromFile = [];
70
+ if (existsSync(ignoreFilePath)) {
71
+ try {
72
+ const txt = await readFile(ignoreFilePath, 'utf-8');
73
+ ignoreFromFile = txt
74
+ .split(/\r?\n/)
75
+ .map((s) => s.trim())
76
+ .filter(Boolean)
77
+ .filter((l) => !l.startsWith('#'))
78
+ .filter((l) => !l.startsWith('!')); // ignore negations for now
79
+ } catch (e) {
80
+ // noop - fall back to defaults if file can't be read
81
+ ignoreFromFile = [];
81
82
  }
82
- const finalExclude = [...new Set([...(exclude || []), ...ignoreFromFile, ...DEFAULT_EXCLUDE])];
83
- const files = await glob(include, {
84
- cwd: rootDir,
85
- ignore: finalExclude,
86
- absolute: true,
87
- });
88
- return files;
83
+ }
84
+ const finalExclude = [
85
+ ...new Set([...(exclude || []), ...ignoreFromFile, ...DEFAULT_EXCLUDE]),
86
+ ];
87
+ const files = await glob(include, {
88
+ cwd: rootDir,
89
+ ignore: finalExclude,
90
+ absolute: true,
91
+ });
92
+ return files;
89
93
  }
90
94
  export async function readFileContent(filePath) {
91
- return readFile(filePath, 'utf-8');
95
+ return readFile(filePath, 'utf-8');
92
96
  }
93
97
  export function getFileExtension(filePath) {
94
- return filePath.split('.').pop() || '';
98
+ return filePath.split('.').pop() || '';
95
99
  }
96
100
  export function isSourceFile(filePath) {
97
- const ext = getFileExtension(filePath);
98
- return ['ts', 'tsx', 'js', 'jsx', 'py', 'java', 'go', 'rs'].includes(ext);
101
+ const ext = getFileExtension(filePath);
102
+ return ['ts', 'tsx', 'js', 'jsx', 'py', 'java', 'go', 'rs'].includes(ext);
99
103
  }
100
- //# sourceMappingURL=file-scanner.js.map
104
+ //# sourceMappingURL=file-scanner.js.map
@@ -3,4 +3,4 @@
3
3
  * ~1 token ≈ 4 characters for code
4
4
  */
5
5
  export declare function estimateTokens(text: string): number;
6
- //# sourceMappingURL=metrics.d.ts.map
6
+ //# sourceMappingURL=metrics.d.ts.map
@@ -3,6 +3,6 @@
3
3
  * ~1 token ≈ 4 characters for code
4
4
  */
5
5
  export function estimateTokens(text) {
6
- return Math.ceil(text.length / 4);
6
+ return Math.ceil(text.length / 4);
7
7
  }
8
- //# sourceMappingURL=metrics.js.map
8
+ //# sourceMappingURL=metrics.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.23.1",
3
+ "version": "0.23.3",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -59,7 +59,7 @@
59
59
  "scripts": {
60
60
  "build": "tsup src/index.ts src/client.ts --format cjs,esm --dts",
61
61
  "dev": "tsup src/index.ts src/client.ts --format cjs,esm --watch",
62
- "test": "vitest run",
62
+ "test": "vitest run --hookTimeout=30000",
63
63
  "lint": "eslint src",
64
64
  "clean": "rm -rf dist",
65
65
  "release": "pnpm build && pnpm publish --no-git-checks"