@aiready/core 0.9.20 → 0.9.23

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
@@ -1,33 +1,19 @@
1
- // src/types/language.ts
2
- var Language = /* @__PURE__ */ ((Language3) => {
3
- Language3["TypeScript"] = "typescript";
4
- Language3["JavaScript"] = "javascript";
5
- Language3["Python"] = "python";
6
- Language3["Java"] = "java";
7
- Language3["Go"] = "go";
8
- Language3["Rust"] = "rust";
9
- Language3["CSharp"] = "csharp";
10
- return Language3;
11
- })(Language || {});
12
- var LANGUAGE_EXTENSIONS = {
13
- ".ts": "typescript" /* TypeScript */,
14
- ".tsx": "typescript" /* TypeScript */,
15
- ".js": "javascript" /* JavaScript */,
16
- ".jsx": "javascript" /* JavaScript */,
17
- ".py": "python" /* Python */,
18
- ".java": "java" /* Java */,
19
- ".go": "go" /* Go */,
20
- ".rs": "rust" /* Rust */,
21
- ".cs": "csharp" /* CSharp */
22
- };
23
- var ParseError = class extends Error {
24
- constructor(message, filePath, loc) {
25
- super(message);
26
- this.filePath = filePath;
27
- this.loc = loc;
28
- this.name = "ParseError";
29
- }
30
- };
1
+ import {
2
+ DEFAULT_TOOL_WEIGHTS,
3
+ LANGUAGE_EXTENSIONS,
4
+ Language,
5
+ ParseError,
6
+ TOOL_NAME_MAP,
7
+ calculateOverallScore,
8
+ formatScore,
9
+ formatToolScore,
10
+ generateHTML,
11
+ getRating,
12
+ getRatingDisplay,
13
+ getToolWeight,
14
+ normalizeToolName,
15
+ parseWeightString
16
+ } from "./chunk-HKSARRCD.mjs";
31
17
 
32
18
  // src/utils/file-scanner.ts
33
19
  import { glob } from "glob";
@@ -410,150 +396,6 @@ function getElapsedTime(startTime) {
410
396
  return ((Date.now() - startTime) / 1e3).toFixed(2);
411
397
  }
412
398
 
413
- // src/scoring.ts
414
- var DEFAULT_TOOL_WEIGHTS = {
415
- "pattern-detect": 40,
416
- "context-analyzer": 35,
417
- "consistency": 25,
418
- "doc-drift": 20,
419
- "deps": 15
420
- };
421
- var TOOL_NAME_MAP = {
422
- "patterns": "pattern-detect",
423
- "context": "context-analyzer",
424
- "consistency": "consistency",
425
- "doc-drift": "doc-drift",
426
- "deps": "deps"
427
- };
428
- function normalizeToolName(shortName) {
429
- return TOOL_NAME_MAP[shortName] || shortName;
430
- }
431
- function getToolWeight(toolName, toolConfig, cliOverride) {
432
- if (cliOverride !== void 0) {
433
- return cliOverride;
434
- }
435
- if (toolConfig?.scoreWeight !== void 0) {
436
- return toolConfig.scoreWeight;
437
- }
438
- return DEFAULT_TOOL_WEIGHTS[toolName] || 10;
439
- }
440
- function parseWeightString(weightStr) {
441
- const weights = /* @__PURE__ */ new Map();
442
- if (!weightStr) {
443
- return weights;
444
- }
445
- const pairs = weightStr.split(",");
446
- for (const pair of pairs) {
447
- const [toolShortName, weightStr2] = pair.split(":");
448
- if (toolShortName && weightStr2) {
449
- const toolName = normalizeToolName(toolShortName.trim());
450
- const weight = parseInt(weightStr2.trim(), 10);
451
- if (!isNaN(weight) && weight > 0) {
452
- weights.set(toolName, weight);
453
- }
454
- }
455
- }
456
- return weights;
457
- }
458
- function calculateOverallScore(toolOutputs, config, cliWeights) {
459
- if (toolOutputs.size === 0) {
460
- throw new Error("No tool outputs provided for scoring");
461
- }
462
- const weights = /* @__PURE__ */ new Map();
463
- for (const [toolName] of toolOutputs.entries()) {
464
- const cliWeight = cliWeights?.get(toolName);
465
- const configWeight = config?.tools?.[toolName]?.scoreWeight;
466
- const weight = cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 10;
467
- weights.set(toolName, weight);
468
- }
469
- let weightedSum = 0;
470
- let totalWeight = 0;
471
- const breakdown = [];
472
- const toolsUsed = [];
473
- const calculationWeights = {};
474
- for (const [toolName, output] of toolOutputs.entries()) {
475
- const weight = weights.get(toolName) || 10;
476
- const weightedScore = output.score * weight;
477
- weightedSum += weightedScore;
478
- totalWeight += weight;
479
- toolsUsed.push(toolName);
480
- calculationWeights[toolName] = weight;
481
- breakdown.push(output);
482
- }
483
- const overall = Math.round(weightedSum / totalWeight);
484
- const rating = getRating(overall);
485
- const formulaParts = Array.from(toolOutputs.entries()).map(([name, output]) => {
486
- const w = weights.get(name) || 10;
487
- return `(${output.score} \xD7 ${w})`;
488
- });
489
- const formulaStr = `[${formulaParts.join(" + ")}] / ${totalWeight} = ${overall}`;
490
- return {
491
- overall,
492
- rating,
493
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
494
- toolsUsed,
495
- breakdown,
496
- calculation: {
497
- formula: formulaStr,
498
- weights: calculationWeights,
499
- normalized: formulaStr
500
- }
501
- };
502
- }
503
- function getRating(score) {
504
- if (score >= 90) return "Excellent";
505
- if (score >= 75) return "Good";
506
- if (score >= 60) return "Fair";
507
- if (score >= 40) return "Needs Work";
508
- return "Critical";
509
- }
510
- function getRatingDisplay(rating) {
511
- switch (rating) {
512
- case "Excellent":
513
- return { emoji: "\u2705", color: "green" };
514
- case "Good":
515
- return { emoji: "\u{1F44D}", color: "blue" };
516
- case "Fair":
517
- return { emoji: "\u26A0\uFE0F", color: "yellow" };
518
- case "Needs Work":
519
- return { emoji: "\u{1F528}", color: "orange" };
520
- case "Critical":
521
- return { emoji: "\u274C", color: "red" };
522
- }
523
- }
524
- function formatScore(result) {
525
- const { emoji, color } = getRatingDisplay(result.rating);
526
- return `${result.overall}/100 (${result.rating}) ${emoji}`;
527
- }
528
- function formatToolScore(output) {
529
- let result = ` Score: ${output.score}/100
530
-
531
- `;
532
- if (output.factors && output.factors.length > 0) {
533
- result += ` Factors:
534
- `;
535
- output.factors.forEach((factor) => {
536
- const impactSign = factor.impact > 0 ? "+" : "";
537
- result += ` \u2022 ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}
538
- `;
539
- });
540
- result += "\n";
541
- }
542
- if (output.recommendations && output.recommendations.length > 0) {
543
- result += ` Recommendations:
544
- `;
545
- output.recommendations.forEach((rec, i) => {
546
- const priorityIcon = rec.priority === "high" ? "\u{1F534}" : rec.priority === "medium" ? "\u{1F7E1}" : "\u{1F535}";
547
- result += ` ${i + 1}. ${priorityIcon} ${rec.action}
548
- `;
549
- result += ` Impact: +${rec.estimatedImpact} points
550
-
551
- `;
552
- });
553
- }
554
- return result;
555
- }
556
-
557
399
  // src/parsers/typescript-parser.ts
558
400
  import { parse as parse2 } from "@typescript-eslint/typescript-estree";
559
401
  var TypeScriptParser = class {
@@ -1050,6 +892,7 @@ export {
1050
892
  extractImports,
1051
893
  formatScore,
1052
894
  formatToolScore,
895
+ generateHTML,
1053
896
  getElapsedTime,
1054
897
  getFileExtension,
1055
898
  getParser,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.9.20",
3
+ "version": "0.9.23",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -10,6 +10,11 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "require": "./dist/index.js",
12
12
  "import": "./dist/index.mjs"
13
+ },
14
+ "./client": {
15
+ "types": "./dist/client.d.ts",
16
+ "require": "./dist/client.js",
17
+ "import": "./dist/client.mjs"
13
18
  }
14
19
  },
15
20
  "keywords": [
@@ -45,8 +50,8 @@
45
50
  "typescript": "^5.9.3"
46
51
  },
47
52
  "scripts": {
48
- "build": "tsup src/index.ts --format cjs,esm --dts",
49
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
53
+ "build": "tsup src/index.ts src/client.ts --format cjs,esm --dts",
54
+ "dev": "tsup src/index.ts src/client.ts --format cjs,esm --dts --watch",
50
55
  "lint": "eslint src",
51
56
  "clean": "rm -rf dist",
52
57
  "release": "pnpm build && pnpm publish --no-git-checks"