@aiready/core 0.2.1 → 0.2.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/index.d.mts CHANGED
@@ -30,6 +30,35 @@ interface ScanOptions {
30
30
  exclude?: string[];
31
31
  maxDepth?: number;
32
32
  }
33
+ interface AIReadyConfig {
34
+ scan?: {
35
+ include?: string[];
36
+ exclude?: string[];
37
+ };
38
+ tools?: {
39
+ 'pattern-detect'?: {
40
+ minSimilarity?: number;
41
+ minLines?: number;
42
+ batchSize?: number;
43
+ approx?: boolean;
44
+ minSharedTokens?: number;
45
+ maxCandidatesPerBlock?: number;
46
+ streamResults?: boolean;
47
+ };
48
+ 'context-analyzer'?: {
49
+ maxDepth?: number;
50
+ maxContextBudget?: number;
51
+ minCohesion?: number;
52
+ maxFragmentation?: number;
53
+ focus?: 'fragmentation' | 'cohesion' | 'depth' | 'all';
54
+ includeNodeModules?: boolean;
55
+ };
56
+ };
57
+ output?: {
58
+ format?: 'console' | 'json' | 'html';
59
+ file?: string;
60
+ };
61
+ }
33
62
  interface Report {
34
63
  summary: {
35
64
  totalFiles: number;
@@ -82,4 +111,7 @@ declare function levenshteinDistance(str1: string, str2: string): number;
82
111
  */
83
112
  declare function similarityScore(str1: string, str2: string): number;
84
113
 
85
- export { type ASTNode, type AnalysisResult, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getFileExtension, isSourceFile, levenshteinDistance, parseCode, readFileContent, scanFiles, similarityScore };
114
+ declare function loadConfig(rootDir: string): AIReadyConfig | null;
115
+ declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
116
+
117
+ export { type AIReadyConfig, type ASTNode, type AnalysisResult, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getFileExtension, isSourceFile, levenshteinDistance, loadConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
package/dist/index.d.ts CHANGED
@@ -30,6 +30,35 @@ interface ScanOptions {
30
30
  exclude?: string[];
31
31
  maxDepth?: number;
32
32
  }
33
+ interface AIReadyConfig {
34
+ scan?: {
35
+ include?: string[];
36
+ exclude?: string[];
37
+ };
38
+ tools?: {
39
+ 'pattern-detect'?: {
40
+ minSimilarity?: number;
41
+ minLines?: number;
42
+ batchSize?: number;
43
+ approx?: boolean;
44
+ minSharedTokens?: number;
45
+ maxCandidatesPerBlock?: number;
46
+ streamResults?: boolean;
47
+ };
48
+ 'context-analyzer'?: {
49
+ maxDepth?: number;
50
+ maxContextBudget?: number;
51
+ minCohesion?: number;
52
+ maxFragmentation?: number;
53
+ focus?: 'fragmentation' | 'cohesion' | 'depth' | 'all';
54
+ includeNodeModules?: boolean;
55
+ };
56
+ };
57
+ output?: {
58
+ format?: 'console' | 'json' | 'html';
59
+ file?: string;
60
+ };
61
+ }
33
62
  interface Report {
34
63
  summary: {
35
64
  totalFiles: number;
@@ -82,4 +111,7 @@ declare function levenshteinDistance(str1: string, str2: string): number;
82
111
  */
83
112
  declare function similarityScore(str1: string, str2: string): number;
84
113
 
85
- export { type ASTNode, type AnalysisResult, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getFileExtension, isSourceFile, levenshteinDistance, parseCode, readFileContent, scanFiles, similarityScore };
114
+ declare function loadConfig(rootDir: string): AIReadyConfig | null;
115
+ declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
116
+
117
+ export { type AIReadyConfig, type ASTNode, type AnalysisResult, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getFileExtension, isSourceFile, levenshteinDistance, loadConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
package/dist/index.js CHANGED
@@ -26,6 +26,8 @@ __export(index_exports, {
26
26
  getFileExtension: () => getFileExtension,
27
27
  isSourceFile: () => isSourceFile,
28
28
  levenshteinDistance: () => levenshteinDistance,
29
+ loadConfig: () => loadConfig,
30
+ mergeConfigWithDefaults: () => mergeConfigWithDefaults,
29
31
  parseCode: () => parseCode,
30
32
  readFileContent: () => readFileContent,
31
33
  scanFiles: () => scanFiles,
@@ -37,13 +39,43 @@ module.exports = __toCommonJS(index_exports);
37
39
  var import_glob = require("glob");
38
40
  var import_promises = require("fs/promises");
39
41
  var DEFAULT_EXCLUDE = [
42
+ // Dependencies
40
43
  "**/node_modules/**",
44
+ // Build outputs
41
45
  "**/dist/**",
42
46
  "**/build/**",
43
- "**/.git/**",
47
+ "**/out/**",
48
+ "**/output/**",
49
+ "**/target/**",
50
+ "**/bin/**",
51
+ "**/obj/**",
52
+ // Framework-specific build dirs
53
+ "**/.next/**",
54
+ "**/.nuxt/**",
55
+ "**/.vuepress/**",
56
+ "**/.cache/**",
57
+ "**/.turbo/**",
58
+ // Test and coverage
44
59
  "**/coverage/**",
60
+ "**/.nyc_output/**",
61
+ "**/.jest/**",
62
+ // Version control and IDE
63
+ "**/.git/**",
64
+ "**/.svn/**",
65
+ "**/.hg/**",
66
+ "**/.vscode/**",
67
+ "**/.idea/**",
68
+ "**/*.swp",
69
+ "**/*.swo",
70
+ // Build artifacts and minified files
45
71
  "**/*.min.js",
46
- "**/*.bundle.js"
72
+ "**/*.min.css",
73
+ "**/*.bundle.js",
74
+ "**/*.tsbuildinfo",
75
+ // Logs and temporary files
76
+ "**/logs/**",
77
+ "**/*.log",
78
+ "**/.DS_Store"
47
79
  ];
48
80
  async function scanFiles(options) {
49
81
  const {
@@ -111,6 +143,61 @@ function similarityScore(str1, str2) {
111
143
  const maxLength = Math.max(str1.length, str2.length);
112
144
  return maxLength === 0 ? 1 : 1 - distance / maxLength;
113
145
  }
146
+
147
+ // src/utils/config.ts
148
+ var import_fs = require("fs");
149
+ var import_path = require("path");
150
+ var CONFIG_FILES = [
151
+ "aiready.json",
152
+ "aiready.config.json",
153
+ ".aiready.json",
154
+ ".aireadyrc.json",
155
+ "aiready.config.js",
156
+ ".aireadyrc.js"
157
+ ];
158
+ function loadConfig(rootDir) {
159
+ for (const configFile of CONFIG_FILES) {
160
+ const configPath = (0, import_path.resolve)(rootDir, configFile);
161
+ if ((0, import_fs.existsSync)(configPath)) {
162
+ try {
163
+ let config;
164
+ if (configFile.endsWith(".js")) {
165
+ delete require.cache[require.resolve(configPath)];
166
+ config = require(configPath);
167
+ } else {
168
+ const content = (0, import_fs.readFileSync)(configPath, "utf-8");
169
+ config = JSON.parse(content);
170
+ }
171
+ if (typeof config !== "object" || config === null) {
172
+ throw new Error("Config must be an object");
173
+ }
174
+ return config;
175
+ } catch (error) {
176
+ throw new Error(`Failed to load config from ${configPath}: ${error}`);
177
+ }
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+ function mergeConfigWithDefaults(userConfig, defaults) {
183
+ if (!userConfig) return defaults;
184
+ const result = { ...defaults };
185
+ if (userConfig.scan) {
186
+ if (userConfig.scan.include) result.include = userConfig.scan.include;
187
+ if (userConfig.scan.exclude) result.exclude = userConfig.scan.exclude;
188
+ }
189
+ if (userConfig.tools) {
190
+ for (const [toolName, toolConfig] of Object.entries(userConfig.tools)) {
191
+ if (result[toolName] && typeof toolConfig === "object" && toolConfig !== null) {
192
+ result[toolName] = { ...result[toolName], ...toolConfig };
193
+ }
194
+ }
195
+ }
196
+ if (userConfig.output) {
197
+ result.output = { ...result.output, ...userConfig.output };
198
+ }
199
+ return result;
200
+ }
114
201
  // Annotate the CommonJS export names for ESM import in node:
115
202
  0 && (module.exports = {
116
203
  estimateTokens,
@@ -119,6 +206,8 @@ function similarityScore(str1, str2) {
119
206
  getFileExtension,
120
207
  isSourceFile,
121
208
  levenshteinDistance,
209
+ loadConfig,
210
+ mergeConfigWithDefaults,
122
211
  parseCode,
123
212
  readFileContent,
124
213
  scanFiles,
package/dist/index.mjs CHANGED
@@ -1,14 +1,51 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/utils/file-scanner.ts
2
9
  import { glob } from "glob";
3
10
  import { readFile } from "fs/promises";
4
11
  var DEFAULT_EXCLUDE = [
12
+ // Dependencies
5
13
  "**/node_modules/**",
14
+ // Build outputs
6
15
  "**/dist/**",
7
16
  "**/build/**",
8
- "**/.git/**",
17
+ "**/out/**",
18
+ "**/output/**",
19
+ "**/target/**",
20
+ "**/bin/**",
21
+ "**/obj/**",
22
+ // Framework-specific build dirs
23
+ "**/.next/**",
24
+ "**/.nuxt/**",
25
+ "**/.vuepress/**",
26
+ "**/.cache/**",
27
+ "**/.turbo/**",
28
+ // Test and coverage
9
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
10
41
  "**/*.min.js",
11
- "**/*.bundle.js"
42
+ "**/*.min.css",
43
+ "**/*.bundle.js",
44
+ "**/*.tsbuildinfo",
45
+ // Logs and temporary files
46
+ "**/logs/**",
47
+ "**/*.log",
48
+ "**/.DS_Store"
12
49
  ];
13
50
  async function scanFiles(options) {
14
51
  const {
@@ -76,6 +113,61 @@ function similarityScore(str1, str2) {
76
113
  const maxLength = Math.max(str1.length, str2.length);
77
114
  return maxLength === 0 ? 1 : 1 - distance / maxLength;
78
115
  }
116
+
117
+ // src/utils/config.ts
118
+ import { readFileSync, existsSync } from "fs";
119
+ import { resolve } from "path";
120
+ var CONFIG_FILES = [
121
+ "aiready.json",
122
+ "aiready.config.json",
123
+ ".aiready.json",
124
+ ".aireadyrc.json",
125
+ "aiready.config.js",
126
+ ".aireadyrc.js"
127
+ ];
128
+ function loadConfig(rootDir) {
129
+ for (const configFile of CONFIG_FILES) {
130
+ const configPath = resolve(rootDir, configFile);
131
+ if (existsSync(configPath)) {
132
+ try {
133
+ let config;
134
+ if (configFile.endsWith(".js")) {
135
+ delete __require.cache[__require.resolve(configPath)];
136
+ config = __require(configPath);
137
+ } else {
138
+ const content = readFileSync(configPath, "utf-8");
139
+ config = JSON.parse(content);
140
+ }
141
+ if (typeof config !== "object" || config === null) {
142
+ throw new Error("Config must be an object");
143
+ }
144
+ return config;
145
+ } catch (error) {
146
+ throw new Error(`Failed to load config from ${configPath}: ${error}`);
147
+ }
148
+ }
149
+ }
150
+ return null;
151
+ }
152
+ function mergeConfigWithDefaults(userConfig, defaults) {
153
+ if (!userConfig) return defaults;
154
+ const result = { ...defaults };
155
+ if (userConfig.scan) {
156
+ if (userConfig.scan.include) result.include = userConfig.scan.include;
157
+ if (userConfig.scan.exclude) result.exclude = userConfig.scan.exclude;
158
+ }
159
+ if (userConfig.tools) {
160
+ for (const [toolName, toolConfig] of Object.entries(userConfig.tools)) {
161
+ if (result[toolName] && typeof toolConfig === "object" && toolConfig !== null) {
162
+ result[toolName] = { ...result[toolName], ...toolConfig };
163
+ }
164
+ }
165
+ }
166
+ if (userConfig.output) {
167
+ result.output = { ...result.output, ...userConfig.output };
168
+ }
169
+ return result;
170
+ }
79
171
  export {
80
172
  estimateTokens,
81
173
  extractFunctions,
@@ -83,6 +175,8 @@ export {
83
175
  getFileExtension,
84
176
  isSourceFile,
85
177
  levenshteinDistance,
178
+ loadConfig,
179
+ mergeConfigWithDefaults,
86
180
  parseCode,
87
181
  readFileContent,
88
182
  scanFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",