@aiready/core 0.23.5 → 0.23.7

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 (111) hide show
  1. package/dist/{client-D-cn9ydj.d.mts → client-BrIMPk89.d.mts} +94 -16
  2. package/dist/{client-D-cn9ydj.d.ts → client-BrIMPk89.d.ts} +94 -16
  3. package/dist/client-C5BuGX4F.d.mts +1205 -0
  4. package/dist/client-C5BuGX4F.d.ts +1205 -0
  5. package/dist/{client-BF9NjhE8.d.mts → client-CKcjnPXt.d.mts} +1 -0
  6. package/dist/{client-BF9NjhE8.d.ts → client-CKcjnPXt.d.ts} +1 -0
  7. package/dist/client.d.mts +1 -1
  8. package/dist/client.d.ts +1 -1
  9. package/dist/index.d.mts +464 -134
  10. package/dist/index.d.ts +464 -134
  11. package/dist/index.js +211 -47
  12. package/dist/index.mjs +211 -44
  13. package/package.json +1 -1
  14. package/dist/__tests__/parser-factory.test.d.ts +0 -5
  15. package/dist/__tests__/parser-factory.test.d.ts.map +0 -1
  16. package/dist/__tests__/parser-factory.test.js +0 -70
  17. package/dist/__tests__/parser-factory.test.js.map +0 -1
  18. package/dist/__tests__/python-parser.test.d.ts +0 -5
  19. package/dist/__tests__/python-parser.test.d.ts.map +0 -1
  20. package/dist/__tests__/python-parser.test.js +0 -194
  21. package/dist/__tests__/python-parser.test.js.map +0 -1
  22. package/dist/__tests__/scoring.test.d.ts +0 -2
  23. package/dist/__tests__/scoring.test.d.ts.map +0 -1
  24. package/dist/__tests__/scoring.test.js +0 -197
  25. package/dist/__tests__/scoring.test.js.map +0 -1
  26. package/dist/chunk-3YI4IS3D.mjs +0 -601
  27. package/dist/chunk-5HIXDC3X.mjs +0 -716
  28. package/dist/chunk-5V3L53AE.mjs +0 -805
  29. package/dist/chunk-CKVKHN3G.mjs +0 -660
  30. package/dist/chunk-COHIBX3Q.mjs +0 -635
  31. package/dist/chunk-CWRCDSKZ.mjs +0 -417
  32. package/dist/chunk-D3D3NCRR.mjs +0 -556
  33. package/dist/chunk-HCFYP7UD.mjs +0 -805
  34. package/dist/chunk-HFLFBA6F.mjs +0 -417
  35. package/dist/chunk-HKSARRCD.mjs +0 -365
  36. package/dist/chunk-JJ5JL5FX.mjs +0 -417
  37. package/dist/chunk-KDSTXVLQ.mjs +0 -724
  38. package/dist/chunk-KI7XORTN.mjs +0 -417
  39. package/dist/chunk-LTMHFNFK.mjs +0 -690
  40. package/dist/chunk-LTNXTXRI.mjs +0 -659
  41. package/dist/chunk-M22BXHBR.mjs +0 -805
  42. package/dist/chunk-MH3A3LX6.mjs +0 -615
  43. package/dist/chunk-NGHT7JOG.mjs +0 -697
  44. package/dist/chunk-OQ6IGDXG.mjs +0 -553
  45. package/dist/chunk-QAFB3HXQ.mjs +0 -590
  46. package/dist/chunk-QQBKXHLU.mjs +0 -678
  47. package/dist/chunk-RDHYGES7.mjs +0 -678
  48. package/dist/chunk-SWTDBVYJ.mjs +0 -660
  49. package/dist/chunk-UIWL5JQB.mjs +0 -417
  50. package/dist/chunk-UQGI67WR.mjs +0 -417
  51. package/dist/chunk-UTZOO4XO.mjs +0 -553
  52. package/dist/chunk-X4F46I5L.mjs +0 -635
  53. package/dist/chunk-XKK7YHPX.mjs +0 -619
  54. package/dist/chunk-YCA4FTEK.mjs +0 -600
  55. package/dist/chunk-ZSZRRTJM.mjs +0 -719
  56. package/dist/client-BgmiMoil.d.mts +0 -1344
  57. package/dist/client-BgmiMoil.d.ts +0 -1344
  58. package/dist/client-BxGrPuuN.d.mts +0 -1191
  59. package/dist/client-BxGrPuuN.d.ts +0 -1191
  60. package/dist/client-D9seCH4K.d.mts +0 -1334
  61. package/dist/client-D9seCH4K.d.ts +0 -1334
  62. package/dist/client-DIXIh7rw.d.mts +0 -1193
  63. package/dist/client-DIXIh7rw.d.ts +0 -1193
  64. package/dist/client-DVHXWOHw.d.mts +0 -1245
  65. package/dist/client-DVHXWOHw.d.ts +0 -1245
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js.map +0 -1
  68. package/dist/parsers/parser-factory.d.ts +0 -69
  69. package/dist/parsers/parser-factory.d.ts.map +0 -1
  70. package/dist/parsers/parser-factory.js +0 -116
  71. package/dist/parsers/parser-factory.js.map +0 -1
  72. package/dist/parsers/python-parser.d.ts +0 -47
  73. package/dist/parsers/python-parser.d.ts.map +0 -1
  74. package/dist/parsers/python-parser.js +0 -243
  75. package/dist/parsers/python-parser.js.map +0 -1
  76. package/dist/parsers/typescript-parser.d.ts +0 -22
  77. package/dist/parsers/typescript-parser.d.ts.map +0 -1
  78. package/dist/parsers/typescript-parser.js +0 -242
  79. package/dist/parsers/typescript-parser.js.map +0 -1
  80. package/dist/scoring.d.ts +0 -120
  81. package/dist/scoring.d.ts.map +0 -1
  82. package/dist/scoring.js +0 -197
  83. package/dist/scoring.js.map +0 -1
  84. package/dist/types/language.d.ts +0 -172
  85. package/dist/types/language.d.ts.map +0 -1
  86. package/dist/types/language.js +0 -45
  87. package/dist/types/language.js.map +0 -1
  88. package/dist/types.d.ts +0 -122
  89. package/dist/types.d.ts.map +0 -1
  90. package/dist/types.js +0 -2
  91. package/dist/types.js.map +0 -1
  92. package/dist/utils/ast-parser.d.ts +0 -59
  93. package/dist/utils/ast-parser.d.ts.map +0 -1
  94. package/dist/utils/ast-parser.js +0 -213
  95. package/dist/utils/ast-parser.js.map +0 -1
  96. package/dist/utils/cli-helpers.d.ts +0 -54
  97. package/dist/utils/cli-helpers.d.ts.map +0 -1
  98. package/dist/utils/cli-helpers.js +0 -78
  99. package/dist/utils/cli-helpers.js.map +0 -1
  100. package/dist/utils/config.d.ts +0 -9
  101. package/dist/utils/config.d.ts.map +0 -1
  102. package/dist/utils/config.js +0 -80
  103. package/dist/utils/config.js.map +0 -1
  104. package/dist/utils/file-scanner.d.ts +0 -16
  105. package/dist/utils/file-scanner.d.ts.map +0 -1
  106. package/dist/utils/file-scanner.js +0 -104
  107. package/dist/utils/file-scanner.js.map +0 -1
  108. package/dist/utils/metrics.d.ts +0 -6
  109. package/dist/utils/metrics.d.ts.map +0 -1
  110. package/dist/utils/metrics.js +0 -8
  111. package/dist/utils/metrics.js.map +0 -1
package/dist/index.mjs CHANGED
@@ -464,7 +464,7 @@ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()
464
464
  if (statSync(workingDir).isFile()) {
465
465
  baseDir = dirname2(workingDir);
466
466
  }
467
- } catch (e) {
467
+ } catch {
468
468
  }
469
469
  const aireadyDir = join2(baseDir, ".aiready");
470
470
  outputPath = join2(aireadyDir, defaultFilename);
@@ -636,8 +636,8 @@ function findLatestScanReport(scanReportsDir, reportFilePrefix) {
636
636
  return idB - idA;
637
637
  });
638
638
  return join2(scanReportsDir, reportFiles[0]);
639
- } catch (e) {
640
- console.error("Error while finding latest scan report:", e);
639
+ } catch {
640
+ console.error("Error while finding latest scan report");
641
641
  return null;
642
642
  }
643
643
  }
@@ -702,7 +702,19 @@ function createProvider(config) {
702
702
  };
703
703
  }
704
704
 
705
- // src/utils/ast-parser.ts
705
+ // src/utils/similarity-utils.ts
706
+ function calculateImportSimilarity(export1, export2) {
707
+ if (export1.imports.length === 0 && export2.imports.length === 0) {
708
+ return 1;
709
+ }
710
+ const set1 = new Set(export1.imports);
711
+ const set2 = new Set(export2.imports);
712
+ const intersection = new Set([...set1].filter((x) => set2.has(x)));
713
+ const union = /* @__PURE__ */ new Set([...set1, ...set2]);
714
+ return intersection.size / union.size;
715
+ }
716
+
717
+ // src/utils/dependency-analyzer.ts
706
718
  import { parse as parse2 } from "@typescript-eslint/typescript-estree";
707
719
 
708
720
  // src/parsers/typescript-parser.ts
@@ -732,7 +744,7 @@ var TypeScriptParser = class {
732
744
  hasSideEffects: false
733
745
  };
734
746
  const start = node.range?.[0] ?? 0;
735
- const preceding = code.slice(Math.max(0, start - 200), start);
747
+ const preceding = code.slice(Math.max(0, start - 1e3), start);
736
748
  const jsdocMatches = Array.from(
737
749
  preceding.matchAll(/\/\*\*([\s\S]*?)\*\//g)
738
750
  );
@@ -741,9 +753,24 @@ var TypeScriptParser = class {
741
753
  const matchEndIndex = (lastMatch.index || 0) + lastMatch[0].length;
742
754
  const between = preceding.slice(matchEndIndex);
743
755
  if (/^\s*$/.test(between)) {
756
+ const precedingStartOffset = Math.max(0, start - 1e3);
757
+ const absoluteStartOffset = precedingStartOffset + (lastMatch.index || 0);
758
+ const absoluteEndOffset = precedingStartOffset + matchEndIndex;
759
+ const codeBeforeStart = code.slice(0, absoluteStartOffset);
760
+ const startLines = codeBeforeStart.split("\n");
761
+ const startLine = startLines.length;
762
+ const startColumn = startLines[startLines.length - 1].length;
763
+ const codeBeforeEnd = code.slice(0, absoluteEndOffset);
764
+ const endLines = codeBeforeEnd.split("\n");
765
+ const endLine = endLines.length;
766
+ const endColumn = endLines[endLines.length - 1].length;
744
767
  metadata.documentation = {
745
768
  content: lastMatch[1].replace(/^\s*\*+/gm, "").trim(),
746
- type: "jsdoc"
769
+ type: "jsdoc",
770
+ loc: {
771
+ start: { line: startLine, column: startColumn },
772
+ end: { line: endLine, column: endColumn }
773
+ }
747
774
  };
748
775
  }
749
776
  }
@@ -1052,37 +1079,60 @@ function analyzeNodeMetadata(node, code, options) {
1052
1079
  let prev = node.previousSibling || null;
1053
1080
  while (prev && /comment/i.test(prev.type)) {
1054
1081
  const text = prev.text || "";
1082
+ const loc = {
1083
+ start: {
1084
+ line: prev.startPosition.row + 1,
1085
+ column: prev.startPosition.column
1086
+ },
1087
+ end: {
1088
+ line: prev.endPosition.row + 1,
1089
+ column: prev.endPosition.column
1090
+ }
1091
+ };
1055
1092
  if (text.trim().startsWith("/**") || text.trim().startsWith("/*")) {
1056
1093
  metadata.documentation = {
1057
1094
  content: text.replace(/^[/*]+|[/*]+$/g, "").trim(),
1058
- type: "comment"
1095
+ type: "comment",
1096
+ loc
1059
1097
  };
1060
1098
  break;
1061
1099
  }
1062
1100
  if (text.trim().startsWith("///")) {
1063
1101
  metadata.documentation = {
1064
1102
  content: text.replace(/^\/\/\//, "").trim(),
1065
- type: "xml-doc"
1103
+ type: "xml-doc",
1104
+ loc
1066
1105
  };
1067
1106
  break;
1068
1107
  }
1069
1108
  if (text.trim().startsWith("//")) {
1070
1109
  metadata.documentation = {
1071
1110
  content: text.replace(/^\/\//, "").trim(),
1072
- type: "comment"
1111
+ type: "comment",
1112
+ loc
1073
1113
  };
1074
1114
  break;
1075
1115
  }
1076
1116
  prev = prev.previousSibling;
1077
1117
  }
1078
- if (node.type === "function_definition") {
1118
+ if (node.type === "function_definition" || node.type === "class_definition") {
1079
1119
  const body2 = node.childForFieldName ? node.childForFieldName("body") : node.children.find((c) => c.type === "block");
1080
1120
  if (body2 && body2.children.length > 0) {
1081
1121
  const firstStmt = body2.children[0];
1082
1122
  if (firstStmt.type === "expression_statement" && firstStmt.firstChild?.type === "string") {
1083
1123
  metadata.documentation = {
1084
1124
  content: firstStmt.firstChild.text.replace(/['"`]/g, "").trim(),
1085
- type: "docstring"
1125
+ type: "docstring",
1126
+ loc: {
1127
+ start: {
1128
+ line: firstStmt.startPosition.row + 1,
1129
+ column: firstStmt.startPosition.column
1130
+ },
1131
+ end: {
1132
+ line: firstStmt.endPosition.row + 1,
1133
+ column: firstStmt.endPosition.column
1134
+ }
1135
+ }
1086
1136
  };
1087
1137
  }
1088
1138
  }
@@ -1289,11 +1339,24 @@ var PythonParser = class extends BaseLanguageParser {
1289
1339
  getParserName() {
1290
1340
  return "python";
1291
1341
  }
1342
+ /**
1343
+ * Analyze metadata for a Python node (purity, side effects).
1344
+ *
1345
+ * @param node - Tree-sitter node to analyze.
1346
+ * @param code - Source code for context.
1347
+ * @returns Partial ExportInfo containing discovered metadata.
1348
+ */
1292
1349
  analyzeMetadata(node, code) {
1293
1350
  return analyzeNodeMetadata(node, code, {
1294
1351
  sideEffectSignatures: ["print(", "input(", "open("]
1295
1352
  });
1296
1353
  }
1354
+ /**
1355
+ * Extract import information using AST walk.
1356
+ *
1357
+ * @param rootNode - Root node of the Python AST.
1358
+ * @returns Array of discovered ImportInfo objects.
1359
+ */
1297
1360
  extractImportsAST(rootNode) {
1298
1361
  const imports = [];
1299
1362
  const processImportNode = (node) => {
@@ -1375,6 +1438,13 @@ var PythonParser = class extends BaseLanguageParser {
1375
1438
  }
1376
1439
  return imports;
1377
1440
  }
1441
+ /**
1442
+ * Extract export information using AST walk.
1443
+ *
1444
+ * @param rootNode - Root node of the Python AST.
1445
+ * @param code - Source code for documentation extraction.
1446
+ * @returns Array of discovered ExportInfo objects.
1447
+ */
1378
1448
  extractExportsAST(rootNode, code) {
1379
1449
  const exports = [];
1380
1450
  for (const node of rootNode.children) {
@@ -1453,6 +1523,12 @@ var PythonParser = class extends BaseLanguageParser {
1453
1523
  }
1454
1524
  return exports;
1455
1525
  }
1526
+ /**
1527
+ * Extract parameter names from a function definition node.
1528
+ *
1529
+ * @param node - Function definition node.
1530
+ * @returns Array of parameter name strings.
1531
+ */
1456
1532
  extractParameters(node) {
1457
1533
  const paramsNode = node.childForFieldName("parameters");
1458
1534
  if (!paramsNode) return [];
@@ -1466,6 +1542,13 @@ var PythonParser = class extends BaseLanguageParser {
1466
1542
  return "unknown";
1467
1543
  });
1468
1544
  }
1545
+ /**
1546
+ * Fallback regex-based parsing when tree-sitter is unavailable.
1547
+ *
1548
+ * @param code - Source code content.
1549
+ * @param filePath - Path to the file being parsed.
1550
+ * @returns Consolidated ParseResult.
1551
+ */
1469
1552
  parseRegex(code, filePath) {
1470
1553
  try {
1471
1554
  const imports = this.extractImportsRegex(code, filePath);
@@ -1739,6 +1822,13 @@ var JavaParser = class extends BaseLanguageParser {
1739
1822
  getParserName() {
1740
1823
  return "java";
1741
1824
  }
1825
+ /**
1826
+ * Analyze metadata for a Java node (purity, side effects).
1827
+ *
1828
+ * @param node - Tree-sitter node to analyze.
1829
+ * @param code - Source code for context.
1830
+ * @returns Partial ExportInfo containing discovered metadata.
1831
+ */
1742
1832
  analyzeMetadata(node, code) {
1743
1833
  return analyzeGeneralMetadata(node, code, {
1744
1834
  sideEffectSignatures: [
@@ -1818,6 +1908,12 @@ var JavaParser = class extends BaseLanguageParser {
1818
1908
  warnings: ["Parser falling back to regex-based analysis"]
1819
1909
  };
1820
1910
  }
1911
+ /**
1912
+ * Extract import information using AST walk.
1913
+ *
1914
+ * @param rootNode - Root node of the Java AST.
1915
+ * @returns Array of discovered ImportInfo objects.
1916
+ */
1821
1917
  extractImportsAST(rootNode) {
1822
1918
  const imports = [];
1823
1919
  for (const node of rootNode.children) {
@@ -1851,6 +1947,13 @@ var JavaParser = class extends BaseLanguageParser {
1851
1947
  }
1852
1948
  return imports;
1853
1949
  }
1950
+ /**
1951
+ * Extract export information (classes, interfaces, methods) using AST walk.
1952
+ *
1953
+ * @param rootNode - Root node of the Java AST.
1954
+ * @param code - Source code for documentation extraction.
1955
+ * @returns Array of discovered ExportInfo objects.
1956
+ */
1854
1957
  extractExportsAST(rootNode, code) {
1855
1958
  const exports = [];
1856
1959
  for (const node of rootNode.children) {
@@ -1881,11 +1984,25 @@ var JavaParser = class extends BaseLanguageParser {
1881
1984
  }
1882
1985
  return exports;
1883
1986
  }
1987
+ /**
1988
+ * Extract modifiers (visibility, static, etc.) from a node.
1989
+ *
1990
+ * @param node - AST node to extract modifiers from.
1991
+ * @returns Array of modifier strings.
1992
+ */
1884
1993
  getModifiers(node) {
1885
1994
  const modifiersNode = node.children.find((c) => c.type === "modifiers");
1886
1995
  if (!modifiersNode) return [];
1887
1996
  return modifiersNode.children.map((c) => c.text);
1888
1997
  }
1998
+ /**
1999
+ * Extract methods and nested exports from a class or interface body.
2000
+ *
2001
+ * @param parentNode - Class or interface declaration node.
2002
+ * @param parentName - Name of the parent class/interface.
2003
+ * @param exports - Array to collect discovered exports into.
2004
+ * @param code - Source code for context.
2005
+ */
1889
2006
  extractSubExports(parentNode, parentName, exports, code) {
1890
2007
  const bodyNode = parentNode.children.find((c) => c.type === "class_body");
1891
2008
  if (!bodyNode) return;
@@ -1944,11 +2061,24 @@ var CSharpParser = class extends BaseLanguageParser {
1944
2061
  getParserName() {
1945
2062
  return "c_sharp";
1946
2063
  }
2064
+ /**
2065
+ * Analyze metadata for a C# node (purity, side effects).
2066
+ *
2067
+ * @param node - Tree-sitter node to analyze.
2068
+ * @param code - Source code for context.
2069
+ * @returns Partial ExportInfo containing discovered metadata.
2070
+ */
1947
2071
  analyzeMetadata(node, code) {
1948
2072
  return analyzeGeneralMetadata(node, code, {
1949
2073
  sideEffectSignatures: ["Console.Write", "File.Write", "Logging."]
1950
2074
  });
1951
2075
  }
2076
+ /**
2077
+ * Fallback regex-based parsing when tree-sitter is unavailable.
2078
+ *
2079
+ * @param code - Source code content.
2080
+ * @returns Consolidated ParseResult.
2081
+ */
1952
2082
  parseRegex(code) {
1953
2083
  const lines = code.split("\n");
1954
2084
  const exports = [];
@@ -2010,6 +2140,12 @@ var CSharpParser = class extends BaseLanguageParser {
2010
2140
  warnings: ["Parser falling back to regex-based analysis"]
2011
2141
  };
2012
2142
  }
2143
+ /**
2144
+ * Extract import information (usings) using AST walk.
2145
+ *
2146
+ * @param rootNode - Root node of the C# AST.
2147
+ * @returns Array of discovered ImportInfo objects.
2148
+ */
2013
2149
  extractImportsAST(rootNode) {
2014
2150
  const imports = [];
2015
2151
  const findUsings = (node) => {
@@ -2043,6 +2179,14 @@ var CSharpParser = class extends BaseLanguageParser {
2043
2179
  findUsings(rootNode);
2044
2180
  return imports;
2045
2181
  }
2182
+ /**
2183
+ * Extract export information (classes, methods, properties) using AST walk.
2184
+ * Handles nested namespaces and classes.
2185
+ *
2186
+ * @param rootNode - Root node of the C# AST.
2187
+ * @param code - Source code for documentation extraction.
2188
+ * @returns Array of discovered ExportInfo objects.
2189
+ */
2046
2190
  extractExportsAST(rootNode, code) {
2047
2191
  const exports = [];
2048
2192
  const traverse = (node, currentNamespace, currentClass) => {
@@ -2154,11 +2298,24 @@ var GoParser = class extends BaseLanguageParser {
2154
2298
  getParserName() {
2155
2299
  return "go";
2156
2300
  }
2301
+ /**
2302
+ * Analyze metadata for a Go node (purity, side effects).
2303
+ *
2304
+ * @param node - Tree-sitter node to analyze.
2305
+ * @param code - Source code for context.
2306
+ * @returns Partial ExportInfo containing discovered metadata.
2307
+ */
2157
2308
  analyzeMetadata(node, code) {
2158
2309
  return analyzeGeneralMetadata(node, code, {
2159
2310
  sideEffectSignatures: ["<-", "fmt.Print", "fmt.Fprintf", "os.Exit"]
2160
2311
  });
2161
2312
  }
2313
+ /**
2314
+ * Fallback regex-based parsing when tree-sitter is unavailable.
2315
+ *
2316
+ * @param code - Source code content.
2317
+ * @returns Consolidated ParseResult.
2318
+ */
2162
2319
  parseRegex(code) {
2163
2320
  const lines = code.split("\n");
2164
2321
  const exports = [];
@@ -2236,6 +2393,12 @@ var GoParser = class extends BaseLanguageParser {
2236
2393
  warnings: ["Parser falling back to regex-based analysis"]
2237
2394
  };
2238
2395
  }
2396
+ /**
2397
+ * Extract import information using AST walk.
2398
+ *
2399
+ * @param rootNode - Root node of the Go AST.
2400
+ * @returns Array of discovered ImportInfo objects.
2401
+ */
2239
2402
  extractImportsAST(rootNode) {
2240
2403
  const imports = [];
2241
2404
  const findImports = (node) => {
@@ -2269,6 +2432,13 @@ var GoParser = class extends BaseLanguageParser {
2269
2432
  findImports(rootNode);
2270
2433
  return imports;
2271
2434
  }
2435
+ /**
2436
+ * Extract export information (functions, types, vars) using AST walk.
2437
+ *
2438
+ * @param rootNode - Root node of the Go AST.
2439
+ * @param code - Source code for documentation extraction.
2440
+ * @returns Array of discovered ExportInfo objects.
2441
+ */
2272
2442
  extractExportsAST(rootNode, code) {
2273
2443
  const exports = [];
2274
2444
  const isExported = (name) => {
@@ -2625,7 +2795,7 @@ function extractTypeReferences(node) {
2625
2795
  return Array.from(types);
2626
2796
  }
2627
2797
 
2628
- // src/utils/ast-parser.ts
2798
+ // src/utils/dependency-analyzer.ts
2629
2799
  function parseFileExports(code, filePath) {
2630
2800
  const parser = getParser(filePath);
2631
2801
  if (parser && parser.language !== "typescript" /* TypeScript */ && parser.language !== "javascript" /* JavaScript */) {
@@ -2667,29 +2837,6 @@ function parseFileExports(code, filePath) {
2667
2837
  return { exports: [], imports: [] };
2668
2838
  }
2669
2839
  }
2670
- function calculateImportSimilarity(export1, export2) {
2671
- if (export1.imports.length === 0 && export2.imports.length === 0) {
2672
- return 1;
2673
- }
2674
- const set1 = new Set(export1.imports);
2675
- const set2 = new Set(export2.imports);
2676
- const intersection = new Set([...set1].filter((x) => set2.has(x)));
2677
- const union = /* @__PURE__ */ new Set([...set1, ...set2]);
2678
- return intersection.size / union.size;
2679
- }
2680
- function parseCode(_code, _language) {
2681
- void _code;
2682
- void _language;
2683
- return null;
2684
- }
2685
- function extractFunctions(_ast) {
2686
- void _ast;
2687
- return [];
2688
- }
2689
- function extractImports(_ast) {
2690
- void _ast;
2691
- return [];
2692
- }
2693
2840
 
2694
2841
  // src/utils/metrics.ts
2695
2842
  function estimateTokens(text) {
@@ -3794,14 +3941,32 @@ function calculateDocDrift(params) {
3794
3941
  uncommentedExports,
3795
3942
  totalExports,
3796
3943
  outdatedComments,
3797
- undocumentedComplexity
3944
+ undocumentedComplexity,
3945
+ actualDrift
3798
3946
  } = params;
3799
3947
  const uncommentedRatio = totalExports > 0 ? uncommentedExports / totalExports : 0;
3800
- const outdatedRisk = Math.min(100, outdatedComments * 15);
3801
- const uncommentedRisk = Math.min(100, uncommentedRatio * 100);
3802
- const complexityRisk = Math.min(100, undocumentedComplexity * 10);
3948
+ const outdatedRatio = totalExports > 0 ? outdatedComments / totalExports : 0;
3949
+ const complexityRatio = totalExports > 0 ? undocumentedComplexity / totalExports : 0;
3950
+ const driftRatio = totalExports > 0 ? actualDrift / totalExports : 0;
3951
+ const DRIFT_THRESHOLD = 0.2;
3952
+ const OUTDATED_THRESHOLD = 0.4;
3953
+ const COMPLEXITY_THRESHOLD = 0.2;
3954
+ const UNCOMMENTED_THRESHOLD = 0.8;
3955
+ const driftRisk = Math.min(100, driftRatio / DRIFT_THRESHOLD * 100);
3956
+ const outdatedRisk = Math.min(
3957
+ 100,
3958
+ outdatedRatio / OUTDATED_THRESHOLD * 100
3959
+ );
3960
+ const complexityRisk = Math.min(
3961
+ 100,
3962
+ complexityRatio / COMPLEXITY_THRESHOLD * 100
3963
+ );
3964
+ const uncommentedRisk = Math.min(
3965
+ 100,
3966
+ uncommentedRatio / UNCOMMENTED_THRESHOLD * 100
3967
+ );
3803
3968
  const risk = Math.round(
3804
- outdatedRisk * 0.6 + uncommentedRisk * 0.2 + complexityRisk * 0.2
3969
+ driftRisk * 0.4 + complexityRisk * 0.3 + outdatedRisk * 0.2 + uncommentedRisk * 0.1
3805
3970
  );
3806
3971
  const finalRisk = Math.min(100, Math.max(0, risk));
3807
3972
  const score = totalExports > 0 ? 100 - finalRisk : 100;
@@ -3813,6 +3978,10 @@ function calculateDocDrift(params) {
3813
3978
  else if (score >= 40) rating = "high";
3814
3979
  else rating = "severe";
3815
3980
  const recommendations = [];
3981
+ if (actualDrift > 0)
3982
+ recommendations.push(
3983
+ `Review ${actualDrift} functions where code was changed after documentation was last updated.`
3984
+ );
3816
3985
  if (outdatedComments > 0)
3817
3986
  recommendations.push(
3818
3987
  `Update or remove ${outdatedComments} outdated comments that contradict the code.`
@@ -3831,7 +4000,8 @@ function calculateDocDrift(params) {
3831
4000
  dimensions: {
3832
4001
  uncommentedExports,
3833
4002
  outdatedComments,
3834
- undocumentedComplexity
4003
+ undocumentedComplexity,
4004
+ actualDrift
3835
4005
  },
3836
4006
  recommendations
3837
4007
  };
@@ -4326,8 +4496,6 @@ export {
4326
4496
  estimateCostFromBudget,
4327
4497
  estimateTokens,
4328
4498
  exportHistory,
4329
- extractFunctions,
4330
- extractImports,
4331
4499
  findLatestReport,
4332
4500
  findLatestScanReport,
4333
4501
  formatAcceptanceRate,
@@ -4373,7 +4541,6 @@ export {
4373
4541
  loadScoreHistory,
4374
4542
  mergeConfigWithDefaults,
4375
4543
  normalizeToolName,
4376
- parseCode,
4377
4544
  parseFileExports,
4378
4545
  parseWeightString,
4379
4546
  predictAcceptanceRate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.23.5",
3
+ "version": "0.23.7",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,5 +0,0 @@
1
- /**
2
- * Test multi-language parser factory
3
- */
4
- export {};
5
- //# sourceMappingURL=parser-factory.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-factory.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/parser-factory.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,70 +0,0 @@
1
- /**
2
- * Test multi-language parser factory
3
- */
4
- import { describe, it, expect } from 'vitest';
5
- import {
6
- ParserFactory,
7
- Language,
8
- getParser,
9
- isFileSupported,
10
- getSupportedLanguages,
11
- } from '../parsers/parser-factory';
12
- describe('ParserFactory', () => {
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
- });
53
- });
54
- describe('Language Detection', () => {
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
- });
69
- });
70
- //# sourceMappingURL=parser-factory.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-factory.test.js","sourceRoot":"","sources":["../../src/__tests__/parser-factory.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,eAAe,EACf,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QACpC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EA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AAU,CAAC,CAAC;QAC9E,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACxE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Test Python parser
3
- */
4
- export {};
5
- //# sourceMappingURL=python-parser.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"python-parser.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/python-parser.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}