@aiready/core 0.5.0 → 0.5.2

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/README.md CHANGED
@@ -44,20 +44,7 @@ const tokenCount = estimateTokens(code);
44
44
  console.log(`Estimated tokens: ${tokenCount}`);
45
45
  ```
46
46
 
47
- ### Similarity Detection
48
47
 
49
- ```typescript
50
- import { similarityScore, levenshteinDistance } from '@aiready/core';
51
-
52
- const code1 = 'function handleUser(user) { ... }';
53
- const code2 = 'function handlePost(post) { ... }';
54
-
55
- const similarity = similarityScore(code1, code2);
56
- console.log(`Similarity: ${(similarity * 100).toFixed(1)}%`);
57
-
58
- const distance = levenshteinDistance(code1, code2);
59
- console.log(`Edit distance: ${distance}`);
60
- ```
61
48
 
62
49
  ### TypeScript Types
63
50
 
@@ -104,8 +91,6 @@ const result: AnalysisResult = {
104
91
  ### Metrics
105
92
 
106
93
  - **`estimateTokens(text: string): number`** - Estimate token count (~4 chars = 1 token)
107
- - **`levenshteinDistance(str1: string, str2: string): number`** - Calculate edit distance
108
- - **`similarityScore(str1: string, str2: string): number`** - Calculate similarity (0-1)
109
94
 
110
95
  ### AST Parsing
111
96
 
@@ -128,4 +113,4 @@ MIT - See [LICENSE](./LICENSE)
128
113
 
129
114
  ---
130
115
 
131
- **Part of the [AIReady](https://github.com/aiready) toolkit** | [Documentation](https://aiready.dev) | [GitHub](https://github.com/caopengau/aiready-core)
116
+ **Part of the [AIReady](https://github.com/caopengau/aiready) toolkit** | Docs: see the monorepo [README](https://github.com/caopengau/aiready#readme) | Status: website not live yet
package/dist/index.d.mts CHANGED
@@ -103,15 +103,6 @@ declare function extractImports(ast: ASTNode): string[];
103
103
  * ~1 token ≈ 4 characters for code
104
104
  */
105
105
  declare function estimateTokens(text: string): number;
106
- /**
107
- * Calculate Levenshtein distance between two strings
108
- * Useful for similarity detection
109
- */
110
- declare function levenshteinDistance(str1: string, str2: string): number;
111
- /**
112
- * Calculate similarity score (0-1) between two strings
113
- */
114
- declare function similarityScore(str1: string, str2: string): number;
115
106
 
116
107
  declare function loadConfig(rootDir: string): AIReadyConfig | null;
117
108
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
@@ -144,4 +135,4 @@ declare function handleCLIError(error: unknown, commandName: string): never;
144
135
  */
145
136
  declare function getElapsedTime(startTime: number): string;
146
137
 
147
- export { type AIReadyConfig, type ASTNode, type AnalysisResult, type CLIOptions, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, handleCLIError, handleJSONOutput, isSourceFile, levenshteinDistance, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
138
+ export { type AIReadyConfig, type ASTNode, type AnalysisResult, type CLIOptions, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, handleCLIError, handleJSONOutput, isSourceFile, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles };
package/dist/index.d.ts CHANGED
@@ -103,15 +103,6 @@ declare function extractImports(ast: ASTNode): string[];
103
103
  * ~1 token ≈ 4 characters for code
104
104
  */
105
105
  declare function estimateTokens(text: string): number;
106
- /**
107
- * Calculate Levenshtein distance between two strings
108
- * Useful for similarity detection
109
- */
110
- declare function levenshteinDistance(str1: string, str2: string): number;
111
- /**
112
- * Calculate similarity score (0-1) between two strings
113
- */
114
- declare function similarityScore(str1: string, str2: string): number;
115
106
 
116
107
  declare function loadConfig(rootDir: string): AIReadyConfig | null;
117
108
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
@@ -144,4 +135,4 @@ declare function handleCLIError(error: unknown, commandName: string): never;
144
135
  */
145
136
  declare function getElapsedTime(startTime: number): string;
146
137
 
147
- export { type AIReadyConfig, type ASTNode, type AnalysisResult, type CLIOptions, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, handleCLIError, handleJSONOutput, isSourceFile, levenshteinDistance, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
138
+ export { type AIReadyConfig, type ASTNode, type AnalysisResult, type CLIOptions, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, handleCLIError, handleJSONOutput, isSourceFile, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles };
package/dist/index.js CHANGED
@@ -28,14 +28,12 @@ __export(index_exports, {
28
28
  handleCLIError: () => handleCLIError,
29
29
  handleJSONOutput: () => handleJSONOutput,
30
30
  isSourceFile: () => isSourceFile,
31
- levenshteinDistance: () => levenshteinDistance,
32
31
  loadConfig: () => loadConfig,
33
32
  loadMergedConfig: () => loadMergedConfig,
34
33
  mergeConfigWithDefaults: () => mergeConfigWithDefaults,
35
34
  parseCode: () => parseCode,
36
35
  readFileContent: () => readFileContent,
37
- scanFiles: () => scanFiles,
38
- similarityScore: () => similarityScore
36
+ scanFiles: () => scanFiles
39
37
  });
40
38
  module.exports = __toCommonJS(index_exports);
41
39
 
@@ -121,33 +119,6 @@ function extractImports(ast) {
121
119
  function estimateTokens(text) {
122
120
  return Math.ceil(text.length / 4);
123
121
  }
124
- function levenshteinDistance(str1, str2) {
125
- const len1 = str1.length;
126
- const len2 = str2.length;
127
- const matrix = [];
128
- for (let i = 0; i <= len1; i++) {
129
- matrix[i] = [i];
130
- }
131
- for (let j = 0; j <= len2; j++) {
132
- matrix[0][j] = j;
133
- }
134
- for (let i = 1; i <= len1; i++) {
135
- for (let j = 1; j <= len2; j++) {
136
- const cost = str1[i - 1] === str2[j - 1] ? 0 : 1;
137
- matrix[i][j] = Math.min(
138
- matrix[i - 1][j] + 1,
139
- matrix[i][j - 1] + 1,
140
- matrix[i - 1][j - 1] + cost
141
- );
142
- }
143
- }
144
- return matrix[len1][len2];
145
- }
146
- function similarityScore(str1, str2) {
147
- const distance = levenshteinDistance(str1, str2);
148
- const maxLength = Math.max(str1.length, str2.length);
149
- return maxLength === 0 ? 1 : 1 - distance / maxLength;
150
- }
151
122
 
152
123
  // src/utils/config.ts
153
124
  var import_fs = require("fs");
@@ -252,12 +223,10 @@ function getElapsedTime(startTime) {
252
223
  handleCLIError,
253
224
  handleJSONOutput,
254
225
  isSourceFile,
255
- levenshteinDistance,
256
226
  loadConfig,
257
227
  loadMergedConfig,
258
228
  mergeConfigWithDefaults,
259
229
  parseCode,
260
230
  readFileContent,
261
- scanFiles,
262
- similarityScore
231
+ scanFiles
263
232
  });
package/dist/index.mjs CHANGED
@@ -87,33 +87,6 @@ function extractImports(ast) {
87
87
  function estimateTokens(text) {
88
88
  return Math.ceil(text.length / 4);
89
89
  }
90
- function levenshteinDistance(str1, str2) {
91
- const len1 = str1.length;
92
- const len2 = str2.length;
93
- const matrix = [];
94
- for (let i = 0; i <= len1; i++) {
95
- matrix[i] = [i];
96
- }
97
- for (let j = 0; j <= len2; j++) {
98
- matrix[0][j] = j;
99
- }
100
- for (let i = 1; i <= len1; i++) {
101
- for (let j = 1; j <= len2; j++) {
102
- const cost = str1[i - 1] === str2[j - 1] ? 0 : 1;
103
- matrix[i][j] = Math.min(
104
- matrix[i - 1][j] + 1,
105
- matrix[i][j - 1] + 1,
106
- matrix[i - 1][j - 1] + cost
107
- );
108
- }
109
- }
110
- return matrix[len1][len2];
111
- }
112
- function similarityScore(str1, str2) {
113
- const distance = levenshteinDistance(str1, str2);
114
- const maxLength = Math.max(str1.length, str2.length);
115
- return maxLength === 0 ? 1 : 1 - distance / maxLength;
116
- }
117
90
 
118
91
  // src/utils/config.ts
119
92
  import { readFileSync, existsSync } from "fs";
@@ -217,12 +190,10 @@ export {
217
190
  handleCLIError,
218
191
  handleJSONOutput,
219
192
  isSourceFile,
220
- levenshteinDistance,
221
193
  loadConfig,
222
194
  loadMergedConfig,
223
195
  mergeConfigWithDefaults,
224
196
  parseCode,
225
197
  readFileContent,
226
- scanFiles,
227
- similarityScore
198
+ scanFiles
228
199
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",