@aiready/core 0.21.4 → 0.21.9
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-3YI4IS3D.mjs +583 -0
- package/dist/client.d.mts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +2 -1
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +56 -52
- package/dist/index.d.ts +56 -52
- package/dist/index.js +101 -92
- package/dist/index.mjs +97 -90
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
getToolWeight,
|
|
37
37
|
normalizeToolName,
|
|
38
38
|
parseWeightString
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-3YI4IS3D.mjs";
|
|
40
40
|
|
|
41
41
|
// src/types/contract.ts
|
|
42
42
|
function validateSpokeOutput(toolName, output) {
|
|
@@ -375,6 +375,94 @@ function isSourceFile(filePath) {
|
|
|
375
375
|
return ["ts", "tsx", "js", "jsx", "py", "java", "go", "rs"].includes(ext);
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
// src/utils/cli-helpers.ts
|
|
379
|
+
import { writeFileSync, mkdirSync, existsSync as existsSync2 } from "fs";
|
|
380
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
381
|
+
function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()) {
|
|
382
|
+
let outputPath;
|
|
383
|
+
if (userPath) {
|
|
384
|
+
outputPath = userPath;
|
|
385
|
+
} else {
|
|
386
|
+
const aireadyDir = join2(workingDir, ".aiready");
|
|
387
|
+
outputPath = join2(aireadyDir, defaultFilename);
|
|
388
|
+
}
|
|
389
|
+
const parentDir = dirname2(outputPath);
|
|
390
|
+
if (!existsSync2(parentDir)) {
|
|
391
|
+
mkdirSync(parentDir, { recursive: true });
|
|
392
|
+
}
|
|
393
|
+
return outputPath;
|
|
394
|
+
}
|
|
395
|
+
async function loadMergedConfig(directory, defaults, cliOptions) {
|
|
396
|
+
const config = await loadConfig(directory);
|
|
397
|
+
const mergedConfig = mergeConfigWithDefaults(config, defaults);
|
|
398
|
+
const result = {
|
|
399
|
+
...mergedConfig,
|
|
400
|
+
...cliOptions,
|
|
401
|
+
rootDir: directory
|
|
402
|
+
};
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
405
|
+
function handleJSONOutput(data, outputFile, successMessage) {
|
|
406
|
+
if (outputFile) {
|
|
407
|
+
const dir = dirname2(outputFile);
|
|
408
|
+
if (!existsSync2(dir)) {
|
|
409
|
+
mkdirSync(dir, { recursive: true });
|
|
410
|
+
}
|
|
411
|
+
writeFileSync(outputFile, JSON.stringify(data, null, 2));
|
|
412
|
+
console.log(successMessage || `\u2705 Results saved to ${outputFile}`);
|
|
413
|
+
} else {
|
|
414
|
+
console.log(JSON.stringify(data, null, 2));
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function handleCLIError(error, commandName) {
|
|
418
|
+
console.error(`\u274C ${commandName} failed:`, error);
|
|
419
|
+
process.exit(1);
|
|
420
|
+
}
|
|
421
|
+
function getElapsedTime(startTime) {
|
|
422
|
+
return ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
423
|
+
}
|
|
424
|
+
function getScoreBar(val) {
|
|
425
|
+
return "\u2588".repeat(Math.round(val / 10)).padEnd(10, "\u2591");
|
|
426
|
+
}
|
|
427
|
+
function getSafetyIcon(rating) {
|
|
428
|
+
switch (rating) {
|
|
429
|
+
case "safe":
|
|
430
|
+
return "\u2705";
|
|
431
|
+
case "moderate-risk":
|
|
432
|
+
return "\u26A0\uFE0F ";
|
|
433
|
+
case "high-risk":
|
|
434
|
+
return "\u{1F534}";
|
|
435
|
+
case "blind-risk":
|
|
436
|
+
return "\u{1F480}";
|
|
437
|
+
default:
|
|
438
|
+
return "\u2753";
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
function emitProgress(processed, total, toolId, message, onProgress, throttleCount = 50) {
|
|
442
|
+
if (!onProgress) return;
|
|
443
|
+
if (processed % throttleCount === 0 || processed === total) {
|
|
444
|
+
onProgress(processed, total, `${message} (${processed}/${total})`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function getSeverityColor(severity, chalk) {
|
|
448
|
+
switch (severity.toLowerCase()) {
|
|
449
|
+
case "critical":
|
|
450
|
+
case "high-risk":
|
|
451
|
+
case "blind-risk":
|
|
452
|
+
return chalk.red;
|
|
453
|
+
case "major":
|
|
454
|
+
case "moderate-risk":
|
|
455
|
+
return chalk.yellow;
|
|
456
|
+
case "minor":
|
|
457
|
+
case "safe":
|
|
458
|
+
return chalk.green;
|
|
459
|
+
case "info":
|
|
460
|
+
return chalk.blue;
|
|
461
|
+
default:
|
|
462
|
+
return chalk.white;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
378
466
|
// src/utils/ast-parser.ts
|
|
379
467
|
import { parse } from "@typescript-eslint/typescript-estree";
|
|
380
468
|
function parseFileExports(code, filePath) {
|
|
@@ -555,8 +643,8 @@ function estimateTokens(text) {
|
|
|
555
643
|
}
|
|
556
644
|
|
|
557
645
|
// src/utils/config.ts
|
|
558
|
-
import { readFileSync, existsSync as
|
|
559
|
-
import { join as
|
|
646
|
+
import { readFileSync, existsSync as existsSync3 } from "fs";
|
|
647
|
+
import { join as join3, resolve, dirname as dirname3 } from "path";
|
|
560
648
|
import { pathToFileURL } from "url";
|
|
561
649
|
var CONFIG_FILES = [
|
|
562
650
|
"aiready.json",
|
|
@@ -570,8 +658,8 @@ async function loadConfig(rootDir) {
|
|
|
570
658
|
let currentDir = resolve(rootDir);
|
|
571
659
|
while (true) {
|
|
572
660
|
for (const configFile of CONFIG_FILES) {
|
|
573
|
-
const configPath =
|
|
574
|
-
if (
|
|
661
|
+
const configPath = join3(currentDir, configFile);
|
|
662
|
+
if (existsSync3(configPath)) {
|
|
575
663
|
try {
|
|
576
664
|
let config;
|
|
577
665
|
if (configFile.endsWith(".js")) {
|
|
@@ -599,7 +687,7 @@ async function loadConfig(rootDir) {
|
|
|
599
687
|
}
|
|
600
688
|
}
|
|
601
689
|
}
|
|
602
|
-
const parent =
|
|
690
|
+
const parent = dirname3(currentDir);
|
|
603
691
|
if (parent === currentDir) {
|
|
604
692
|
break;
|
|
605
693
|
}
|
|
@@ -630,88 +718,6 @@ function mergeConfigWithDefaults(userConfig, defaults) {
|
|
|
630
718
|
return result;
|
|
631
719
|
}
|
|
632
720
|
|
|
633
|
-
// src/utils/cli-helpers.ts
|
|
634
|
-
import { writeFileSync, mkdirSync, existsSync as existsSync3 } from "fs";
|
|
635
|
-
import { join as join3, dirname as dirname3 } from "path";
|
|
636
|
-
function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()) {
|
|
637
|
-
let outputPath;
|
|
638
|
-
if (userPath) {
|
|
639
|
-
outputPath = userPath;
|
|
640
|
-
} else {
|
|
641
|
-
const aireadyDir = join3(workingDir, ".aiready");
|
|
642
|
-
outputPath = join3(aireadyDir, defaultFilename);
|
|
643
|
-
}
|
|
644
|
-
const parentDir = dirname3(outputPath);
|
|
645
|
-
if (!existsSync3(parentDir)) {
|
|
646
|
-
mkdirSync(parentDir, { recursive: true });
|
|
647
|
-
}
|
|
648
|
-
return outputPath;
|
|
649
|
-
}
|
|
650
|
-
async function loadMergedConfig(directory, defaults, cliOptions) {
|
|
651
|
-
const config = await loadConfig(directory);
|
|
652
|
-
const mergedConfig = mergeConfigWithDefaults(config, defaults);
|
|
653
|
-
const result = {
|
|
654
|
-
...mergedConfig,
|
|
655
|
-
...cliOptions,
|
|
656
|
-
rootDir: directory
|
|
657
|
-
};
|
|
658
|
-
return result;
|
|
659
|
-
}
|
|
660
|
-
function handleJSONOutput(data, outputFile, successMessage) {
|
|
661
|
-
if (outputFile) {
|
|
662
|
-
const dir = dirname3(outputFile);
|
|
663
|
-
if (!existsSync3(dir)) {
|
|
664
|
-
mkdirSync(dir, { recursive: true });
|
|
665
|
-
}
|
|
666
|
-
writeFileSync(outputFile, JSON.stringify(data, null, 2));
|
|
667
|
-
console.log(successMessage || `\u2705 Results saved to ${outputFile}`);
|
|
668
|
-
} else {
|
|
669
|
-
console.log(JSON.stringify(data, null, 2));
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
function handleCLIError(error, commandName) {
|
|
673
|
-
console.error(`\u274C ${commandName} failed:`, error);
|
|
674
|
-
process.exit(1);
|
|
675
|
-
}
|
|
676
|
-
function getElapsedTime(startTime) {
|
|
677
|
-
return ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
678
|
-
}
|
|
679
|
-
function getScoreBar(val) {
|
|
680
|
-
return "\u2588".repeat(Math.round(val / 10)).padEnd(10, "\u2591");
|
|
681
|
-
}
|
|
682
|
-
function getSafetyIcon(rating) {
|
|
683
|
-
switch (rating) {
|
|
684
|
-
case "safe":
|
|
685
|
-
return "\u2705";
|
|
686
|
-
case "moderate-risk":
|
|
687
|
-
return "\u26A0\uFE0F ";
|
|
688
|
-
case "high-risk":
|
|
689
|
-
return "\u{1F534}";
|
|
690
|
-
case "blind-risk":
|
|
691
|
-
return "\u{1F480}";
|
|
692
|
-
default:
|
|
693
|
-
return "\u2753";
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
function getSeverityColor(severity, chalk) {
|
|
697
|
-
switch (severity.toLowerCase()) {
|
|
698
|
-
case "critical":
|
|
699
|
-
case "high-risk":
|
|
700
|
-
case "blind-risk":
|
|
701
|
-
return chalk.red;
|
|
702
|
-
case "major":
|
|
703
|
-
case "moderate-risk":
|
|
704
|
-
return chalk.yellow;
|
|
705
|
-
case "minor":
|
|
706
|
-
case "safe":
|
|
707
|
-
return chalk.green;
|
|
708
|
-
case "info":
|
|
709
|
-
return chalk.blue;
|
|
710
|
-
default:
|
|
711
|
-
return chalk.white;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
721
|
// src/business/pricing-models.ts
|
|
716
722
|
var MODEL_PRICING_PRESETS = {
|
|
717
723
|
"gpt-5.3": {
|
|
@@ -2296,8 +2302,8 @@ function calculateChangeAmplification(params) {
|
|
|
2296
2302
|
const maxAmplification = hotspots[0].amplificationFactor;
|
|
2297
2303
|
const avgAmplification = hotspots.reduce((sum, h) => sum + h.amplificationFactor, 0) / hotspots.length;
|
|
2298
2304
|
const avgPenalty = Math.log2(avgAmplification + 1) * 15;
|
|
2299
|
-
const maxPenalty = maxAmplification > 30 ? (maxAmplification -
|
|
2300
|
-
const score = Math.max(
|
|
2305
|
+
const maxPenalty = maxAmplification > 30 ? Math.log10(maxAmplification - 29) * 30 : 0;
|
|
2306
|
+
const score = Math.max(5, Math.min(100, 100 - avgPenalty - maxPenalty));
|
|
2301
2307
|
let rating = "isolated";
|
|
2302
2308
|
if (score < 40) rating = "explosive";
|
|
2303
2309
|
else if (score < 70) rating = "amplified";
|
|
@@ -2667,6 +2673,7 @@ export {
|
|
|
2667
2673
|
calculateTestabilityIndex,
|
|
2668
2674
|
calculateTokenBudget,
|
|
2669
2675
|
clearHistory,
|
|
2676
|
+
emitProgress,
|
|
2670
2677
|
estimateCostFromBudget,
|
|
2671
2678
|
estimateTokens,
|
|
2672
2679
|
exportHistory,
|