@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.
- 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 +325 -103
- package/dist/index.d.ts +325 -103
- package/dist/index.js +307 -324
- package/dist/index.mjs +283 -306
- 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
package/dist/utils/config.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const parent = dirname(currentDir);
|
|
46
|
+
if (parent === currentDir) {
|
|
47
|
+
break; // Reached filesystem root
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
currentDir = parent;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
51
52
|
}
|
|
52
53
|
export function mergeConfigWithDefaults(userConfig, defaults) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (userConfig.scan)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
95
|
+
return readFile(filePath, 'utf-8');
|
|
92
96
|
}
|
|
93
97
|
export function getFileExtension(filePath) {
|
|
94
|
-
|
|
98
|
+
return filePath.split('.').pop() || '';
|
|
95
99
|
}
|
|
96
100
|
export function isSourceFile(filePath) {
|
|
97
|
-
|
|
98
|
-
|
|
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
|
package/dist/utils/metrics.d.ts
CHANGED
package/dist/utils/metrics.js
CHANGED