@aiready/core 0.21.21 → 0.22.1
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/chunk-5HIXDC3X.mjs +694 -0
- package/dist/client.d.mts +19 -3
- package/dist/client.d.ts +19 -3
- package/dist/client.js +54 -3
- package/dist/client.mjs +5 -1
- package/dist/index.d.mts +27 -2
- package/dist/index.d.ts +27 -2
- package/dist/index.js +120 -9
- package/dist/index.mjs +68 -7
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
ParseError,
|
|
21
21
|
ReadinessRating,
|
|
22
22
|
RecommendationPriority,
|
|
23
|
+
SCORING_PROFILES,
|
|
23
24
|
SIZE_ADJUSTED_THRESHOLDS,
|
|
25
|
+
ScoringProfile,
|
|
24
26
|
Severity,
|
|
25
27
|
SeveritySchema,
|
|
26
28
|
SpokeOutputSchema,
|
|
@@ -41,7 +43,7 @@ import {
|
|
|
41
43
|
getToolWeight,
|
|
42
44
|
normalizeToolName,
|
|
43
45
|
parseWeightString
|
|
44
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-5HIXDC3X.mjs";
|
|
45
47
|
|
|
46
48
|
// src/types/contract.ts
|
|
47
49
|
function validateSpokeOutput(toolName, output) {
|
|
@@ -3300,6 +3302,8 @@ function calculateAiSignalClarity(params) {
|
|
|
3300
3302
|
deepCallbacks,
|
|
3301
3303
|
ambiguousNames,
|
|
3302
3304
|
undocumentedExports,
|
|
3305
|
+
largeFiles = 0,
|
|
3306
|
+
// Default to 0 to prevent NaN
|
|
3303
3307
|
totalSymbols,
|
|
3304
3308
|
totalExports
|
|
3305
3309
|
} = params;
|
|
@@ -3316,28 +3320,35 @@ function calculateAiSignalClarity(params) {
|
|
|
3316
3320
|
const overloadSignal = {
|
|
3317
3321
|
name: "Symbol Overloading",
|
|
3318
3322
|
count: overloadedSymbols,
|
|
3319
|
-
riskContribution: Math.round(Math.min(1, overloadRatio) * 100 * 0.
|
|
3323
|
+
riskContribution: Math.round(Math.min(1, overloadRatio) * 100 * 0.2),
|
|
3320
3324
|
description: `${overloadedSymbols} overloaded symbols \u2014 AI picks wrong signature`
|
|
3321
3325
|
};
|
|
3326
|
+
const largeFileSignal = {
|
|
3327
|
+
name: "Large Files",
|
|
3328
|
+
count: largeFiles,
|
|
3329
|
+
riskContribution: Math.round(Math.min(5, largeFiles) * 5),
|
|
3330
|
+
// up to 25 points
|
|
3331
|
+
description: `${largeFiles} large files \u2014 pushing AI context limits`
|
|
3332
|
+
};
|
|
3322
3333
|
const magicRatio = magicLiterals / Math.max(1, totalSymbols * 2);
|
|
3323
3334
|
const magicSignal = {
|
|
3324
3335
|
name: "Magic Literals",
|
|
3325
3336
|
count: magicLiterals,
|
|
3326
|
-
riskContribution: Math.round(Math.min(1, magicRatio) * 100 * 0.
|
|
3337
|
+
riskContribution: Math.round(Math.min(1, magicRatio) * 100 * 0.15),
|
|
3327
3338
|
description: `${magicLiterals} unnamed constants \u2014 AI invents wrong values`
|
|
3328
3339
|
};
|
|
3329
3340
|
const trapRatio = booleanTraps / Math.max(1, totalSymbols);
|
|
3330
3341
|
const trapSignal = {
|
|
3331
3342
|
name: "Boolean Traps",
|
|
3332
3343
|
count: booleanTraps,
|
|
3333
|
-
riskContribution: Math.round(Math.min(1, trapRatio) * 100 * 0.
|
|
3344
|
+
riskContribution: Math.round(Math.min(1, trapRatio) * 100 * 0.15),
|
|
3334
3345
|
description: `${booleanTraps} boolean trap parameters \u2014 AI inverts intent`
|
|
3335
3346
|
};
|
|
3336
3347
|
const sideEffectRatio = implicitSideEffects / Math.max(1, totalExports);
|
|
3337
3348
|
const sideEffectSignal = {
|
|
3338
3349
|
name: "Implicit Side Effects",
|
|
3339
3350
|
count: implicitSideEffects,
|
|
3340
|
-
riskContribution: Math.round(Math.min(1, sideEffectRatio) * 100 * 0.
|
|
3351
|
+
riskContribution: Math.round(Math.min(1, sideEffectRatio) * 100 * 0.1),
|
|
3341
3352
|
description: `${implicitSideEffects} functions with implicit side effects \u2014 AI misses contracts`
|
|
3342
3353
|
};
|
|
3343
3354
|
const callbackRatio = deepCallbacks / Math.max(1, totalSymbols * 0.1);
|
|
@@ -3351,18 +3362,19 @@ function calculateAiSignalClarity(params) {
|
|
|
3351
3362
|
const ambiguousSignal = {
|
|
3352
3363
|
name: "Ambiguous Names",
|
|
3353
3364
|
count: ambiguousNames,
|
|
3354
|
-
riskContribution: Math.round(Math.min(1, ambiguousRatio) * 100 * 0.
|
|
3365
|
+
riskContribution: Math.round(Math.min(1, ambiguousRatio) * 100 * 0.05),
|
|
3355
3366
|
description: `${ambiguousNames} non-descriptive identifiers \u2014 AI guesses wrong intent`
|
|
3356
3367
|
};
|
|
3357
3368
|
const undocRatio = undocumentedExports / Math.max(1, totalExports);
|
|
3358
3369
|
const undocSignal = {
|
|
3359
3370
|
name: "Undocumented Exports",
|
|
3360
3371
|
count: undocumentedExports,
|
|
3361
|
-
riskContribution: Math.round(Math.min(1, undocRatio) * 100 * 0.
|
|
3372
|
+
riskContribution: Math.round(Math.min(1, undocRatio) * 100 * 0.05),
|
|
3362
3373
|
description: `${undocumentedExports} public functions without docs \u2014 AI fabricates behavior`
|
|
3363
3374
|
};
|
|
3364
3375
|
const signals = [
|
|
3365
3376
|
overloadSignal,
|
|
3377
|
+
largeFileSignal,
|
|
3366
3378
|
magicSignal,
|
|
3367
3379
|
trapSignal,
|
|
3368
3380
|
sideEffectSignal,
|
|
@@ -3385,6 +3397,10 @@ function calculateAiSignalClarity(params) {
|
|
|
3385
3397
|
);
|
|
3386
3398
|
const topRisk = topSignal.riskContribution > 0 ? topSignal.description : "No significant issues detected";
|
|
3387
3399
|
const recommendations = [];
|
|
3400
|
+
if (largeFileSignal.riskContribution > 5)
|
|
3401
|
+
recommendations.push(
|
|
3402
|
+
`Split ${largeFiles} large files (> 500 lines) into smaller, single-responsibility modules`
|
|
3403
|
+
);
|
|
3388
3404
|
if (overloadSignal.riskContribution > 5)
|
|
3389
3405
|
recommendations.push(
|
|
3390
3406
|
`Rename ${overloadedSymbols} overloaded symbols to unique, intent-revealing names`
|
|
@@ -4020,6 +4036,46 @@ function getRepoMetadata(directory) {
|
|
|
4020
4036
|
}
|
|
4021
4037
|
return metadata;
|
|
4022
4038
|
}
|
|
4039
|
+
|
|
4040
|
+
// src/utils/github-utils.ts
|
|
4041
|
+
function emitAnnotation(params) {
|
|
4042
|
+
const { level, file, line, col, title, message } = params;
|
|
4043
|
+
const parts = [];
|
|
4044
|
+
if (file) parts.push(`file=${file}`);
|
|
4045
|
+
if (line) parts.push(`line=${line}`);
|
|
4046
|
+
if (col) parts.push(`col=${col}`);
|
|
4047
|
+
if (title) parts.push(`title=${title}`);
|
|
4048
|
+
const metadata = parts.length > 0 ? ` ${parts.join(",")}` : "";
|
|
4049
|
+
console.log(`::${level}${metadata}::${message.replace(/\n/g, "%0A")}`);
|
|
4050
|
+
}
|
|
4051
|
+
function severityToAnnotationLevel(severity) {
|
|
4052
|
+
switch (severity.toLowerCase()) {
|
|
4053
|
+
case "critical":
|
|
4054
|
+
case "high-risk":
|
|
4055
|
+
case "blind-risk":
|
|
4056
|
+
return "error";
|
|
4057
|
+
case "major":
|
|
4058
|
+
case "moderate-risk":
|
|
4059
|
+
return "warning";
|
|
4060
|
+
case "minor":
|
|
4061
|
+
case "info":
|
|
4062
|
+
case "safe":
|
|
4063
|
+
default:
|
|
4064
|
+
return "notice";
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
function emitIssuesAsAnnotations(issues) {
|
|
4068
|
+
issues.forEach((issue) => {
|
|
4069
|
+
emitAnnotation({
|
|
4070
|
+
level: severityToAnnotationLevel(issue.severity || "info"),
|
|
4071
|
+
file: issue.file || issue.fileName || "",
|
|
4072
|
+
line: issue.line || issue.location?.start?.line,
|
|
4073
|
+
col: issue.column || issue.location?.start?.column,
|
|
4074
|
+
title: `${issue.tool || "AIReady"}: ${issue.type || "Issue"}`,
|
|
4075
|
+
message: issue.message || issue.description || "No description provided"
|
|
4076
|
+
});
|
|
4077
|
+
});
|
|
4078
|
+
}
|
|
4023
4079
|
export {
|
|
4024
4080
|
AnalysisResultSchema,
|
|
4025
4081
|
AnalysisStatus,
|
|
@@ -4050,8 +4106,10 @@ export {
|
|
|
4050
4106
|
PythonParser,
|
|
4051
4107
|
ReadinessRating,
|
|
4052
4108
|
RecommendationPriority,
|
|
4109
|
+
SCORING_PROFILES,
|
|
4053
4110
|
SEVERITY_TIME_ESTIMATES,
|
|
4054
4111
|
SIZE_ADJUSTED_THRESHOLDS,
|
|
4112
|
+
ScoringProfile,
|
|
4055
4113
|
Severity,
|
|
4056
4114
|
SeveritySchema,
|
|
4057
4115
|
SpokeOutputSchema,
|
|
@@ -4086,6 +4144,8 @@ export {
|
|
|
4086
4144
|
calculateTestabilityIndex,
|
|
4087
4145
|
calculateTokenBudget,
|
|
4088
4146
|
clearHistory,
|
|
4147
|
+
emitAnnotation,
|
|
4148
|
+
emitIssuesAsAnnotations,
|
|
4089
4149
|
emitProgress,
|
|
4090
4150
|
estimateCostFromBudget,
|
|
4091
4151
|
estimateTokens,
|
|
@@ -4139,6 +4199,7 @@ export {
|
|
|
4139
4199
|
scanEntries,
|
|
4140
4200
|
scanFiles,
|
|
4141
4201
|
setupParser,
|
|
4202
|
+
severityToAnnotationLevel,
|
|
4142
4203
|
validateSpokeOutput,
|
|
4143
4204
|
validateWithSchema
|
|
4144
4205
|
};
|