@aiready/core 0.23.3 → 0.23.5

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.mjs CHANGED
@@ -13,7 +13,12 @@ import {
13
13
  IssueTypeSchema,
14
14
  LANGUAGE_EXTENSIONS,
15
15
  Language,
16
+ LeadSchema,
17
+ LeadSource,
18
+ LeadSourceSchema,
19
+ LeadSubmissionSchema,
16
20
  LocationSchema,
21
+ ManagedAccountSchema,
17
22
  MetricsSchema,
18
23
  ModelTier,
19
24
  ModelTierSchema,
@@ -44,7 +49,7 @@ import {
44
49
  getToolWeight,
45
50
  normalizeToolName,
46
51
  parseWeightString
47
- } from "./chunk-NGHT7JOG.mjs";
52
+ } from "./chunk-Q55AMEFV.mjs";
48
53
 
49
54
  // src/types/contract.ts
50
55
  function validateSpokeOutput(toolName, output) {
@@ -304,7 +309,7 @@ async function scanFiles(options) {
304
309
  try {
305
310
  const txt = await readFile(ignoreFilePath, "utf-8");
306
311
  ignoreFromFile = txt.split(/\r?\n/).map((s) => s.trim()).filter(Boolean).filter((l) => !l.startsWith("#")).filter((l) => !l.startsWith("!"));
307
- } catch (e) {
312
+ } catch {
308
313
  ignoreFromFile = [];
309
314
  }
310
315
  }
@@ -358,7 +363,7 @@ async function scanFiles(options) {
358
363
  return !ig.ignores(rel);
359
364
  });
360
365
  return filtered;
361
- } catch (e) {
366
+ } catch {
362
367
  return files;
363
368
  }
364
369
  }
@@ -366,14 +371,14 @@ async function scanFiles(options) {
366
371
  }
367
372
  async function scanEntries(options) {
368
373
  const files = await scanFiles(options);
369
- const { rootDir, include = ["**/*"], exclude, includeTests } = options;
374
+ const { rootDir, exclude, includeTests } = options;
370
375
  const ignoreFilePath = join(rootDir || ".", ".aireadyignore");
371
376
  let ignoreFromFile = [];
372
377
  if (existsSync(ignoreFilePath)) {
373
378
  try {
374
379
  const txt = await readFile(ignoreFilePath, "utf-8");
375
380
  ignoreFromFile = txt.split(/\r?\n/).map((s) => s.trim()).filter(Boolean).filter((l) => !l.startsWith("#")).filter((l) => !l.startsWith("!"));
376
- } catch (e) {
381
+ } catch {
377
382
  ignoreFromFile = [];
378
383
  }
379
384
  }
@@ -454,7 +459,14 @@ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()
454
459
  if (userPath) {
455
460
  outputPath = userPath;
456
461
  } else {
457
- const aireadyDir = join2(workingDir, ".aiready");
462
+ let baseDir = workingDir;
463
+ try {
464
+ if (statSync(workingDir).isFile()) {
465
+ baseDir = dirname2(workingDir);
466
+ }
467
+ } catch (e) {
468
+ }
469
+ const aireadyDir = join2(baseDir, ".aiready");
458
470
  outputPath = join2(aireadyDir, defaultFilename);
459
471
  }
460
472
  const parentDir = dirname2(outputPath);
@@ -1174,7 +1186,7 @@ function findFileRecursively(dir, fileName, depth) {
1174
1186
  if (found) return found;
1175
1187
  }
1176
1188
  }
1177
- } catch (err) {
1189
+ } catch {
1178
1190
  }
1179
1191
  return null;
1180
1192
  }
@@ -1208,7 +1220,7 @@ async function setupParser(language) {
1208
1220
  const Lang = await Parser.Language.load(wasmPath);
1209
1221
  parser.setLanguage(Lang);
1210
1222
  return parser;
1211
- } catch (error) {
1223
+ } catch {
1212
1224
  return null;
1213
1225
  }
1214
1226
  }
@@ -1231,7 +1243,8 @@ var BaseLanguageParser = class {
1231
1243
  console.warn(`Failed to initialize ${this.language} parser:`, error);
1232
1244
  }
1233
1245
  }
1234
- async getAST(code, filePath) {
1246
+ async getAST(code, _filePath) {
1247
+ void _filePath;
1235
1248
  if (!this.initialized) await this.initialize();
1236
1249
  if (!this.parser) return null;
1237
1250
  return this.parser.parse(code);
@@ -1466,10 +1479,11 @@ var PythonParser = class extends BaseLanguageParser {
1466
1479
  ]
1467
1480
  };
1468
1481
  } catch (error) {
1469
- throw new ParseError(
1470
- `Failed to parse Python file ${filePath}: ${error.message}`,
1471
- filePath
1482
+ const wrapper = new Error(
1483
+ `Failed to parse Python file ${filePath}: ${error.message}`
1472
1484
  );
1485
+ wrapper.cause = error;
1486
+ throw wrapper;
1473
1487
  }
1474
1488
  }
1475
1489
  getNamingConventions() {
@@ -1500,6 +1514,7 @@ var PythonParser = class extends BaseLanguageParser {
1500
1514
  return filePath.toLowerCase().endsWith(".py");
1501
1515
  }
1502
1516
  extractImportsRegex(code, _filePath) {
1517
+ void _filePath;
1503
1518
  const imports = [];
1504
1519
  const lines = code.split("\n");
1505
1520
  const importRegex = /^\s*import\s+([a-zA-Z0-9_., ]+)/;
@@ -1550,6 +1565,7 @@ var PythonParser = class extends BaseLanguageParser {
1550
1565
  return imports;
1551
1566
  }
1552
1567
  extractExportsRegex(code, _filePath) {
1568
+ void _filePath;
1553
1569
  const exports = [];
1554
1570
  const lines = code.split("\n");
1555
1571
  const funcRegex = /^def\s+([a-zA-Z0-9_]+)\s*\(/;
@@ -1733,7 +1749,7 @@ var JavaParser = class extends BaseLanguageParser {
1733
1749
  ]
1734
1750
  });
1735
1751
  }
1736
- parseRegex(code, filePath) {
1752
+ parseRegex(code) {
1737
1753
  const lines = code.split("\n");
1738
1754
  const exports = [];
1739
1755
  const imports = [];
@@ -1807,10 +1823,8 @@ var JavaParser = class extends BaseLanguageParser {
1807
1823
  for (const node of rootNode.children) {
1808
1824
  if (node.type === "import_declaration") {
1809
1825
  const sourceArr = [];
1810
- let isStatic = false;
1811
1826
  let isWildcard = false;
1812
1827
  for (const child of node.children) {
1813
- if (child.type === "static") isStatic = true;
1814
1828
  if (child.type === "scoped_identifier" || child.type === "identifier") {
1815
1829
  sourceArr.push(child.text);
1816
1830
  }
@@ -1935,7 +1949,7 @@ var CSharpParser = class extends BaseLanguageParser {
1935
1949
  sideEffectSignatures: ["Console.Write", "File.Write", "Logging."]
1936
1950
  });
1937
1951
  }
1938
- parseRegex(code, filePath) {
1952
+ parseRegex(code) {
1939
1953
  const lines = code.split("\n");
1940
1954
  const exports = [];
1941
1955
  const imports = [];
@@ -2145,7 +2159,7 @@ var GoParser = class extends BaseLanguageParser {
2145
2159
  sideEffectSignatures: ["<-", "fmt.Print", "fmt.Fprintf", "os.Exit"]
2146
2160
  });
2147
2161
  }
2148
- parseRegex(code, filePath) {
2162
+ parseRegex(code) {
2149
2163
  const lines = code.split("\n");
2150
2164
  const exports = [];
2151
2165
  const imports = [];
@@ -2635,7 +2649,7 @@ function parseFileExports(code, filePath) {
2635
2649
  isTypeOnly: i.isTypeOnly || false
2636
2650
  }))
2637
2651
  };
2638
- } catch (e) {
2652
+ } catch {
2639
2653
  return { exports: [], imports: [] };
2640
2654
  }
2641
2655
  }
@@ -2649,7 +2663,7 @@ function parseFileExports(code, filePath) {
2649
2663
  const imports = extractFileImports(ast);
2650
2664
  const exports = extractExportsWithDependencies(ast, imports);
2651
2665
  return { exports, imports };
2652
- } catch (error) {
2666
+ } catch {
2653
2667
  return { exports: [], imports: [] };
2654
2668
  }
2655
2669
  }
@@ -2663,13 +2677,17 @@ function calculateImportSimilarity(export1, export2) {
2663
2677
  const union = /* @__PURE__ */ new Set([...set1, ...set2]);
2664
2678
  return intersection.size / union.size;
2665
2679
  }
2666
- function parseCode(code, language) {
2680
+ function parseCode(_code, _language) {
2681
+ void _code;
2682
+ void _language;
2667
2683
  return null;
2668
2684
  }
2669
- function extractFunctions(ast) {
2685
+ function extractFunctions(_ast) {
2686
+ void _ast;
2670
2687
  return [];
2671
2688
  }
2672
- function extractImports(ast) {
2689
+ function extractImports(_ast) {
2690
+ void _ast;
2673
2691
  return [];
2674
2692
  }
2675
2693
 
@@ -3779,18 +3797,20 @@ function calculateDocDrift(params) {
3779
3797
  undocumentedComplexity
3780
3798
  } = params;
3781
3799
  const uncommentedRatio = totalExports > 0 ? uncommentedExports / totalExports : 0;
3782
- const outdatedScore = Math.min(100, outdatedComments * 15);
3783
- const uncommentedScore = Math.min(100, uncommentedRatio * 100);
3784
- const complexityScore = Math.min(100, undocumentedComplexity * 10);
3785
- const score = Math.round(
3786
- outdatedScore * 0.6 + uncommentedScore * 0.2 + complexityScore * 0.2
3800
+ const outdatedRisk = Math.min(100, outdatedComments * 15);
3801
+ const uncommentedRisk = Math.min(100, uncommentedRatio * 100);
3802
+ const complexityRisk = Math.min(100, undocumentedComplexity * 10);
3803
+ const risk = Math.round(
3804
+ outdatedRisk * 0.6 + uncommentedRisk * 0.2 + complexityRisk * 0.2
3787
3805
  );
3788
- const finalScore = Math.min(100, Math.max(0, score));
3806
+ const finalRisk = Math.min(100, Math.max(0, risk));
3807
+ const score = totalExports > 0 ? 100 - finalRisk : 100;
3789
3808
  let rating;
3790
- if (finalScore < 10) rating = "minimal";
3791
- else if (finalScore < 30) rating = "low";
3792
- else if (finalScore < 60) rating = "moderate";
3793
- else if (finalScore < 85) rating = "high";
3809
+ if (score >= 90)
3810
+ rating = "minimal";
3811
+ else if (score >= 75) rating = "low";
3812
+ else if (score >= 60) rating = "moderate";
3813
+ else if (score >= 40) rating = "high";
3794
3814
  else rating = "severe";
3795
3815
  const recommendations = [];
3796
3816
  if (outdatedComments > 0)
@@ -3806,7 +3826,7 @@ function calculateDocDrift(params) {
3806
3826
  `Explain the business logic for ${undocumentedComplexity} highly complex functions.`
3807
3827
  );
3808
3828
  return {
3809
- score: finalScore,
3829
+ score,
3810
3830
  rating,
3811
3831
  dimensions: {
3812
3832
  uncommentedExports,
@@ -4244,8 +4264,13 @@ export {
4244
4264
  JavaParser,
4245
4265
  LANGUAGE_EXTENSIONS,
4246
4266
  Language,
4267
+ LeadSchema,
4268
+ LeadSource,
4269
+ LeadSourceSchema,
4270
+ LeadSubmissionSchema,
4247
4271
  LocationSchema,
4248
4272
  MODEL_PRICING_PRESETS,
4273
+ ManagedAccountSchema,
4249
4274
  MetricsSchema,
4250
4275
  ModelTier,
4251
4276
  ModelTierSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.23.3",
3
+ "version": "0.23.5",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",