@aiready/core 0.24.16 → 0.24.19
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-3NEZ5M7Y.mjs +892 -0
- package/dist/chunk-GQMKSUA4.mjs +888 -0
- package/dist/chunk-MOM3IXCA.mjs +307 -0
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +6 -2
- package/dist/client/index.mjs +1 -1
- package/dist/index-CcP12wb-.d.mts +1307 -0
- package/dist/index-CcP12wb-.d.ts +1307 -0
- package/dist/index-c5MKV8s5.d.mts +1309 -0
- package/dist/index-c5MKV8s5.d.ts +1309 -0
- package/dist/index-slasaNzr.d.mts +1309 -0
- package/dist/index-slasaNzr.d.ts +1309 -0
- package/dist/index.d.mts +159 -3
- package/dist/index.d.ts +159 -3
- package/dist/index.js +204 -6
- package/dist/index.mjs +190 -7
- package/dist/typescript-parser-FOUPHVFI.mjs +7 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -361,7 +361,10 @@ var init_typescript_parser = __esm({
|
|
|
361
361
|
if (sn.type === "FunctionDeclaration" || sn.type === "MethodDefinition") {
|
|
362
362
|
const body = sn.type === "MethodDefinition" ? sn.value.body : sn.body;
|
|
363
363
|
if (body && body.type === "BlockStatement") {
|
|
364
|
-
const bodyContent = JSON.stringify(
|
|
364
|
+
const bodyContent = JSON.stringify(
|
|
365
|
+
body,
|
|
366
|
+
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
367
|
+
);
|
|
365
368
|
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"name":"fs"') || bodyContent.includes('"name":"fetch"') || bodyContent.includes('"name":"axios"')) {
|
|
366
369
|
return false;
|
|
367
370
|
}
|
|
@@ -2033,6 +2036,8 @@ __export(index_exports, {
|
|
|
2033
2036
|
DEFAULT_COST_CONFIG: () => DEFAULT_COST_CONFIG,
|
|
2034
2037
|
DEFAULT_EXCLUDE: () => DEFAULT_EXCLUDE,
|
|
2035
2038
|
DEFAULT_TOOL_WEIGHTS: () => DEFAULT_TOOL_WEIGHTS,
|
|
2039
|
+
DIContainer: () => DIContainer,
|
|
2040
|
+
DI_TOKENS: () => DI_TOKENS,
|
|
2036
2041
|
FRIENDLY_TOOL_NAMES: () => FRIENDLY_TOOL_NAMES,
|
|
2037
2042
|
GLOBAL_INFRA_OPTIONS: () => GLOBAL_INFRA_OPTIONS,
|
|
2038
2043
|
GLOBAL_SCAN_OPTIONS: () => GLOBAL_SCAN_OPTIONS,
|
|
@@ -2104,9 +2109,11 @@ __export(index_exports, {
|
|
|
2104
2109
|
calculateTestabilityIndex: () => calculateTestabilityIndex,
|
|
2105
2110
|
calculateTokenBudget: () => calculateTokenBudget,
|
|
2106
2111
|
clearHistory: () => clearHistory,
|
|
2112
|
+
createErrorResponse: () => createErrorResponse,
|
|
2107
2113
|
createProvider: () => createProvider,
|
|
2108
2114
|
createStandardCommand: () => createStandardCommand,
|
|
2109
2115
|
createStandardProgressCallback: () => createStandardProgressCallback,
|
|
2116
|
+
defaultImplementations: () => defaultImplementations,
|
|
2110
2117
|
detectTestFramework: () => detectTestFramework,
|
|
2111
2118
|
displayStandardConsoleReport: () => displayStandardConsoleReport,
|
|
2112
2119
|
emitAnnotation: () => emitAnnotation,
|
|
@@ -2139,6 +2146,7 @@ __export(index_exports, {
|
|
|
2139
2146
|
generateTable: () => generateTable,
|
|
2140
2147
|
generateValueChain: () => generateValueChain,
|
|
2141
2148
|
getElapsedTime: () => getElapsedTime,
|
|
2149
|
+
getErrorMessage: () => getErrorMessage,
|
|
2142
2150
|
getFileCommitTimestamps: () => getFileCommitTimestamps,
|
|
2143
2151
|
getFileExtension: () => getFileExtension,
|
|
2144
2152
|
getFilesByPattern: () => getFilesByPattern,
|
|
@@ -2172,6 +2180,7 @@ __export(index_exports, {
|
|
|
2172
2180
|
getToolEmoji: () => getToolEmoji,
|
|
2173
2181
|
getToolWeight: () => getToolWeight,
|
|
2174
2182
|
getWasmPath: () => getWasmPath,
|
|
2183
|
+
globalContainer: () => globalContainer,
|
|
2175
2184
|
groupIssuesByFile: () => groupIssuesByFile,
|
|
2176
2185
|
handleCLIError: () => handleCLIError,
|
|
2177
2186
|
handleJSONOutput: () => handleJSONOutput,
|
|
@@ -2209,8 +2218,10 @@ __export(index_exports, {
|
|
|
2209
2218
|
scanFiles: () => scanFiles,
|
|
2210
2219
|
setupParser: () => setupParser,
|
|
2211
2220
|
severityToAnnotationLevel: () => severityToAnnotationLevel,
|
|
2221
|
+
toErrorMessage: () => toErrorMessage,
|
|
2212
2222
|
validateSpokeOutput: () => validateSpokeOutput,
|
|
2213
2223
|
validateWithSchema: () => validateWithSchema,
|
|
2224
|
+
withErrorHandling: () => withErrorHandling,
|
|
2214
2225
|
wrapInCard: () => wrapInCard
|
|
2215
2226
|
});
|
|
2216
2227
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -2471,7 +2482,7 @@ var ManagedAccountSchema = import_zod7.z.object({
|
|
|
2471
2482
|
accountId: import_zod7.z.string(),
|
|
2472
2483
|
// AWS Account ID
|
|
2473
2484
|
userId: import_zod7.z.string(),
|
|
2474
|
-
// Owner (
|
|
2485
|
+
// Owner (team@getaiready.dev)
|
|
2475
2486
|
stripeSubscriptionId: import_zod7.z.string(),
|
|
2476
2487
|
// AI Token Management
|
|
2477
2488
|
tokenStrategy: import_zod7.z.enum(["managed", "byok"]).default("managed"),
|
|
@@ -2965,6 +2976,7 @@ function getFileExtension(filePath) {
|
|
|
2965
2976
|
return filePath.split(".").pop() || "";
|
|
2966
2977
|
}
|
|
2967
2978
|
function isSourceFile(filePath) {
|
|
2979
|
+
if (filePath.endsWith(".d.ts")) return false;
|
|
2968
2980
|
const ext = getFileExtension(filePath);
|
|
2969
2981
|
return ["ts", "tsx", "js", "jsx", "py", "java", "go", "rs"].includes(ext);
|
|
2970
2982
|
}
|
|
@@ -3821,6 +3833,7 @@ function mergeConfigWithDefaults(userConfig, defaults) {
|
|
|
3821
3833
|
if (userConfig.scan) {
|
|
3822
3834
|
if (userConfig.scan.include) mergedConfig.include = userConfig.scan.include;
|
|
3823
3835
|
if (userConfig.scan.exclude) mergedConfig.exclude = userConfig.scan.exclude;
|
|
3836
|
+
if (userConfig.scan.tools) mergedConfig.tools = userConfig.scan.tools;
|
|
3824
3837
|
}
|
|
3825
3838
|
if (userConfig.threshold !== void 0)
|
|
3826
3839
|
mergedConfig.threshold = userConfig.threshold;
|
|
@@ -3843,6 +3856,12 @@ function mergeConfigWithDefaults(userConfig, defaults) {
|
|
|
3843
3856
|
...userConfig.output
|
|
3844
3857
|
};
|
|
3845
3858
|
}
|
|
3859
|
+
if (userConfig.scoring) {
|
|
3860
|
+
mergedConfig.scoring = {
|
|
3861
|
+
...mergedConfig.scoring,
|
|
3862
|
+
...userConfig.scoring
|
|
3863
|
+
};
|
|
3864
|
+
}
|
|
3846
3865
|
return mergedConfig;
|
|
3847
3866
|
}
|
|
3848
3867
|
|
|
@@ -4372,7 +4391,11 @@ var DEFAULT_TOOL_WEIGHTS = {
|
|
|
4372
4391
|
["doc-drift" /* DocDrift */]: 8,
|
|
4373
4392
|
["dependency-health" /* DependencyHealth */]: 6,
|
|
4374
4393
|
["change-amplification" /* ChangeAmplification */]: 8,
|
|
4375
|
-
["contract-enforcement" /* ContractEnforcement */]: 10
|
|
4394
|
+
["contract-enforcement" /* ContractEnforcement */]: 10,
|
|
4395
|
+
["cognitive-load" /* CognitiveLoad */]: 8,
|
|
4396
|
+
["pattern-entropy" /* PatternEntropy */]: 8,
|
|
4397
|
+
["concept-cohesion" /* ConceptCohesion */]: 10,
|
|
4398
|
+
["semantic-distance" /* SemanticDistance */]: 10
|
|
4376
4399
|
};
|
|
4377
4400
|
var TOOL_NAME_MAP = {
|
|
4378
4401
|
patterns: "pattern-detect" /* PatternDetect */,
|
|
@@ -6056,12 +6079,18 @@ function isLikelyEntryPoint(filePath) {
|
|
|
6056
6079
|
"main",
|
|
6057
6080
|
"bin",
|
|
6058
6081
|
"index",
|
|
6059
|
-
// often used as entry point
|
|
6060
6082
|
"run",
|
|
6061
6083
|
"serve",
|
|
6062
6084
|
"start",
|
|
6063
6085
|
"boot",
|
|
6064
|
-
"init"
|
|
6086
|
+
"init",
|
|
6087
|
+
"parser",
|
|
6088
|
+
"config",
|
|
6089
|
+
"setup",
|
|
6090
|
+
"adapter",
|
|
6091
|
+
"provider",
|
|
6092
|
+
"handler",
|
|
6093
|
+
"vending"
|
|
6065
6094
|
];
|
|
6066
6095
|
const nameWithoutExt = lowerBasename.replace(
|
|
6067
6096
|
/\.(ts|js|tsx|jsx|mjs|cjs)$/,
|
|
@@ -6072,7 +6101,14 @@ function isLikelyEntryPoint(filePath) {
|
|
|
6072
6101
|
)) {
|
|
6073
6102
|
return true;
|
|
6074
6103
|
}
|
|
6075
|
-
const cliDirPatterns = [
|
|
6104
|
+
const cliDirPatterns = [
|
|
6105
|
+
"/bin/",
|
|
6106
|
+
"/cli/",
|
|
6107
|
+
"/cmd/",
|
|
6108
|
+
"/commands/",
|
|
6109
|
+
"/apps/",
|
|
6110
|
+
"/functions/"
|
|
6111
|
+
];
|
|
6076
6112
|
if (cliDirPatterns.some((p) => filePath.includes(p))) {
|
|
6077
6113
|
return true;
|
|
6078
6114
|
}
|
|
@@ -6206,6 +6242,123 @@ function calculateTestabilityIndex(params) {
|
|
|
6206
6242
|
};
|
|
6207
6243
|
}
|
|
6208
6244
|
|
|
6245
|
+
// src/utils/di-container.ts
|
|
6246
|
+
var DIContainer = class _DIContainer {
|
|
6247
|
+
constructor() {
|
|
6248
|
+
this.registrations = /* @__PURE__ */ new Map();
|
|
6249
|
+
this.singletons = /* @__PURE__ */ new Map();
|
|
6250
|
+
}
|
|
6251
|
+
/**
|
|
6252
|
+
* Register a dependency with a factory function.
|
|
6253
|
+
*
|
|
6254
|
+
* @param token - Unique identifier for the dependency
|
|
6255
|
+
* @param factory - Factory function that creates the dependency
|
|
6256
|
+
* @param singleton - If true, the same instance is returned on each resolve (default: true)
|
|
6257
|
+
*/
|
|
6258
|
+
register(token, factory, singleton = true) {
|
|
6259
|
+
this.registrations.set(token, { factory, singleton });
|
|
6260
|
+
}
|
|
6261
|
+
/**
|
|
6262
|
+
* Register an existing instance as a singleton.
|
|
6263
|
+
*
|
|
6264
|
+
* @param token - Unique identifier for the dependency
|
|
6265
|
+
* @param instance - The instance to register
|
|
6266
|
+
*/
|
|
6267
|
+
registerInstance(token, instance) {
|
|
6268
|
+
this.registrations.set(token, { factory: () => instance, singleton: true });
|
|
6269
|
+
this.singletons.set(token, instance);
|
|
6270
|
+
}
|
|
6271
|
+
/**
|
|
6272
|
+
* Resolve a dependency by its token.
|
|
6273
|
+
*
|
|
6274
|
+
* @param token - The token to resolve
|
|
6275
|
+
* @returns The resolved dependency
|
|
6276
|
+
* @throws Error if token is not registered
|
|
6277
|
+
*/
|
|
6278
|
+
resolve(token) {
|
|
6279
|
+
const registration = this.registrations.get(token);
|
|
6280
|
+
if (!registration) {
|
|
6281
|
+
throw new Error(`DI: No registration found for token: ${String(token)}`);
|
|
6282
|
+
}
|
|
6283
|
+
if (registration.singleton) {
|
|
6284
|
+
if (!this.singletons.has(token)) {
|
|
6285
|
+
this.singletons.set(token, registration.factory());
|
|
6286
|
+
}
|
|
6287
|
+
return this.singletons.get(token);
|
|
6288
|
+
}
|
|
6289
|
+
return registration.factory();
|
|
6290
|
+
}
|
|
6291
|
+
/**
|
|
6292
|
+
* Check if a token is registered.
|
|
6293
|
+
*/
|
|
6294
|
+
has(token) {
|
|
6295
|
+
return this.registrations.has(token);
|
|
6296
|
+
}
|
|
6297
|
+
/**
|
|
6298
|
+
* Clear all registrations and singletons.
|
|
6299
|
+
*/
|
|
6300
|
+
clear() {
|
|
6301
|
+
this.registrations.clear();
|
|
6302
|
+
this.singletons.clear();
|
|
6303
|
+
}
|
|
6304
|
+
/**
|
|
6305
|
+
* Create a child container that inherits registrations from parent.
|
|
6306
|
+
* Child can override parent registrations without affecting parent.
|
|
6307
|
+
*/
|
|
6308
|
+
createChild() {
|
|
6309
|
+
const child = new _DIContainer();
|
|
6310
|
+
for (const [token, registration] of this.registrations) {
|
|
6311
|
+
child.registrations.set(token, registration);
|
|
6312
|
+
}
|
|
6313
|
+
for (const [token, instance] of this.singletons) {
|
|
6314
|
+
child.singletons.set(token, instance);
|
|
6315
|
+
}
|
|
6316
|
+
return child;
|
|
6317
|
+
}
|
|
6318
|
+
};
|
|
6319
|
+
var DI_TOKENS = {
|
|
6320
|
+
/** File system operations (fs/promises compatible) */
|
|
6321
|
+
FileSystem: /* @__PURE__ */ Symbol("FileSystem"),
|
|
6322
|
+
/** Logger instance */
|
|
6323
|
+
Logger: /* @__PURE__ */ Symbol("Logger"),
|
|
6324
|
+
/** AST parser factory */
|
|
6325
|
+
ParserFactory: /* @__PURE__ */ Symbol("ParserFactory"),
|
|
6326
|
+
/** Configuration provider */
|
|
6327
|
+
ConfigProvider: /* @__PURE__ */ Symbol("ConfigProvider"),
|
|
6328
|
+
/** Metrics collector */
|
|
6329
|
+
MetricsCollector: /* @__PURE__ */ Symbol("MetricsCollector")
|
|
6330
|
+
};
|
|
6331
|
+
var defaultImplementations = {
|
|
6332
|
+
/** Console-based logger (production default) */
|
|
6333
|
+
consoleLogger: () => ({
|
|
6334
|
+
info: (msg, meta) => console.log(`[INFO] ${msg}`, meta || ""),
|
|
6335
|
+
warn: (msg, meta) => console.warn(`[WARN] ${msg}`, meta || ""),
|
|
6336
|
+
error: (msg, meta) => console.error(`[ERROR] ${msg}`, meta || ""),
|
|
6337
|
+
debug: (msg, meta) => console.debug(`[DEBUG] ${msg}`, meta || "")
|
|
6338
|
+
}),
|
|
6339
|
+
/** No-op logger (test default) */
|
|
6340
|
+
noopLogger: () => ({
|
|
6341
|
+
info: () => {
|
|
6342
|
+
},
|
|
6343
|
+
warn: () => {
|
|
6344
|
+
},
|
|
6345
|
+
error: () => {
|
|
6346
|
+
},
|
|
6347
|
+
debug: () => {
|
|
6348
|
+
}
|
|
6349
|
+
}),
|
|
6350
|
+
/** In-memory config provider (test default) */
|
|
6351
|
+
memoryConfig: (initial) => {
|
|
6352
|
+
const store = new Map(Object.entries(initial || {}));
|
|
6353
|
+
return {
|
|
6354
|
+
get: (key, defaultValue) => store.get(key) ?? defaultValue,
|
|
6355
|
+
set: (key, value) => store.set(key, value),
|
|
6356
|
+
has: (key) => store.has(key)
|
|
6357
|
+
};
|
|
6358
|
+
}
|
|
6359
|
+
};
|
|
6360
|
+
var globalContainer = new DIContainer();
|
|
6361
|
+
|
|
6209
6362
|
// src/metrics/doc-drift.ts
|
|
6210
6363
|
function calculateDocDrift(params) {
|
|
6211
6364
|
const {
|
|
@@ -6698,6 +6851,43 @@ function isBuildArtifact(filePath) {
|
|
|
6698
6851
|
const lower = filePath.toLowerCase();
|
|
6699
6852
|
return lower.includes("/node_modules/") || lower.includes("/dist/") || lower.includes("/build/") || lower.includes("/out/") || lower.includes("/.next/") || lower.includes("/target/") || lower.includes("/bin/");
|
|
6700
6853
|
}
|
|
6854
|
+
|
|
6855
|
+
// src/utils/error-utils.ts
|
|
6856
|
+
function getErrorMessage(error) {
|
|
6857
|
+
if (error instanceof Error) {
|
|
6858
|
+
return error.message;
|
|
6859
|
+
}
|
|
6860
|
+
if (typeof error === "string") {
|
|
6861
|
+
return error;
|
|
6862
|
+
}
|
|
6863
|
+
return String(error);
|
|
6864
|
+
}
|
|
6865
|
+
function toErrorMessage(error, fallback = "Unknown error") {
|
|
6866
|
+
if (error instanceof Error) {
|
|
6867
|
+
return error.message;
|
|
6868
|
+
}
|
|
6869
|
+
if (typeof error === "string" && error.length > 0) {
|
|
6870
|
+
return error;
|
|
6871
|
+
}
|
|
6872
|
+
return fallback;
|
|
6873
|
+
}
|
|
6874
|
+
function createErrorResponse(message, status, details) {
|
|
6875
|
+
return {
|
|
6876
|
+
error: message,
|
|
6877
|
+
status,
|
|
6878
|
+
...details !== void 0 && { details }
|
|
6879
|
+
};
|
|
6880
|
+
}
|
|
6881
|
+
async function withErrorHandling(operation, context) {
|
|
6882
|
+
try {
|
|
6883
|
+
const data = await operation();
|
|
6884
|
+
return { success: true, data };
|
|
6885
|
+
} catch (error) {
|
|
6886
|
+
const message = getErrorMessage(error);
|
|
6887
|
+
const contextPrefix = context ? `${context}: ` : "";
|
|
6888
|
+
return { success: false, error: `${contextPrefix}${message}` };
|
|
6889
|
+
}
|
|
6890
|
+
}
|
|
6701
6891
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6702
6892
|
0 && (module.exports = {
|
|
6703
6893
|
AIReadyConfigSchema,
|
|
@@ -6710,6 +6900,8 @@ function isBuildArtifact(filePath) {
|
|
|
6710
6900
|
DEFAULT_COST_CONFIG,
|
|
6711
6901
|
DEFAULT_EXCLUDE,
|
|
6712
6902
|
DEFAULT_TOOL_WEIGHTS,
|
|
6903
|
+
DIContainer,
|
|
6904
|
+
DI_TOKENS,
|
|
6713
6905
|
FRIENDLY_TOOL_NAMES,
|
|
6714
6906
|
GLOBAL_INFRA_OPTIONS,
|
|
6715
6907
|
GLOBAL_SCAN_OPTIONS,
|
|
@@ -6781,9 +6973,11 @@ function isBuildArtifact(filePath) {
|
|
|
6781
6973
|
calculateTestabilityIndex,
|
|
6782
6974
|
calculateTokenBudget,
|
|
6783
6975
|
clearHistory,
|
|
6976
|
+
createErrorResponse,
|
|
6784
6977
|
createProvider,
|
|
6785
6978
|
createStandardCommand,
|
|
6786
6979
|
createStandardProgressCallback,
|
|
6980
|
+
defaultImplementations,
|
|
6787
6981
|
detectTestFramework,
|
|
6788
6982
|
displayStandardConsoleReport,
|
|
6789
6983
|
emitAnnotation,
|
|
@@ -6816,6 +7010,7 @@ function isBuildArtifact(filePath) {
|
|
|
6816
7010
|
generateTable,
|
|
6817
7011
|
generateValueChain,
|
|
6818
7012
|
getElapsedTime,
|
|
7013
|
+
getErrorMessage,
|
|
6819
7014
|
getFileCommitTimestamps,
|
|
6820
7015
|
getFileExtension,
|
|
6821
7016
|
getFilesByPattern,
|
|
@@ -6849,6 +7044,7 @@ function isBuildArtifact(filePath) {
|
|
|
6849
7044
|
getToolEmoji,
|
|
6850
7045
|
getToolWeight,
|
|
6851
7046
|
getWasmPath,
|
|
7047
|
+
globalContainer,
|
|
6852
7048
|
groupIssuesByFile,
|
|
6853
7049
|
handleCLIError,
|
|
6854
7050
|
handleJSONOutput,
|
|
@@ -6886,7 +7082,9 @@ function isBuildArtifact(filePath) {
|
|
|
6886
7082
|
scanFiles,
|
|
6887
7083
|
setupParser,
|
|
6888
7084
|
severityToAnnotationLevel,
|
|
7085
|
+
toErrorMessage,
|
|
6889
7086
|
validateSpokeOutput,
|
|
6890
7087
|
validateWithSchema,
|
|
7088
|
+
withErrorHandling,
|
|
6891
7089
|
wrapInCard
|
|
6892
7090
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -52,10 +52,10 @@ import {
|
|
|
52
52
|
getToolWeight,
|
|
53
53
|
normalizeToolName,
|
|
54
54
|
parseWeightString
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-3NEZ5M7Y.mjs";
|
|
56
56
|
import {
|
|
57
57
|
TypeScriptParser
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-MOM3IXCA.mjs";
|
|
59
59
|
import {
|
|
60
60
|
PythonParser
|
|
61
61
|
} from "./chunk-QY5YG2AZ.mjs";
|
|
@@ -518,6 +518,7 @@ function getFileExtension(filePath) {
|
|
|
518
518
|
return filePath.split(".").pop() || "";
|
|
519
519
|
}
|
|
520
520
|
function isSourceFile(filePath) {
|
|
521
|
+
if (filePath.endsWith(".d.ts")) return false;
|
|
521
522
|
const ext = getFileExtension(filePath);
|
|
522
523
|
return ["ts", "tsx", "js", "jsx", "py", "java", "go", "rs"].includes(ext);
|
|
523
524
|
}
|
|
@@ -922,11 +923,11 @@ var ParserFactory = class _ParserFactory {
|
|
|
922
923
|
Object.entries(LANGUAGE_EXTENSIONS).map(([ext, lang]) => [ext, lang])
|
|
923
924
|
);
|
|
924
925
|
this.registerLazyParser("typescript" /* TypeScript */, async () => {
|
|
925
|
-
const { TypeScriptParser: TypeScriptParser2 } = await import("./typescript-parser-
|
|
926
|
+
const { TypeScriptParser: TypeScriptParser2 } = await import("./typescript-parser-FOUPHVFI.mjs");
|
|
926
927
|
return new TypeScriptParser2();
|
|
927
928
|
});
|
|
928
929
|
this.registerLazyParser("javascript" /* JavaScript */, async () => {
|
|
929
|
-
const { TypeScriptParser: TypeScriptParser2 } = await import("./typescript-parser-
|
|
930
|
+
const { TypeScriptParser: TypeScriptParser2 } = await import("./typescript-parser-FOUPHVFI.mjs");
|
|
930
931
|
return new TypeScriptParser2();
|
|
931
932
|
});
|
|
932
933
|
this.registerLazyParser("python" /* Python */, async () => {
|
|
@@ -1376,6 +1377,7 @@ function mergeConfigWithDefaults(userConfig, defaults) {
|
|
|
1376
1377
|
if (userConfig.scan) {
|
|
1377
1378
|
if (userConfig.scan.include) mergedConfig.include = userConfig.scan.include;
|
|
1378
1379
|
if (userConfig.scan.exclude) mergedConfig.exclude = userConfig.scan.exclude;
|
|
1380
|
+
if (userConfig.scan.tools) mergedConfig.tools = userConfig.scan.tools;
|
|
1379
1381
|
}
|
|
1380
1382
|
if (userConfig.threshold !== void 0)
|
|
1381
1383
|
mergedConfig.threshold = userConfig.threshold;
|
|
@@ -1398,6 +1400,12 @@ function mergeConfigWithDefaults(userConfig, defaults) {
|
|
|
1398
1400
|
...userConfig.output
|
|
1399
1401
|
};
|
|
1400
1402
|
}
|
|
1403
|
+
if (userConfig.scoring) {
|
|
1404
|
+
mergedConfig.scoring = {
|
|
1405
|
+
...mergedConfig.scoring,
|
|
1406
|
+
...userConfig.scoring
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1401
1409
|
return mergedConfig;
|
|
1402
1410
|
}
|
|
1403
1411
|
|
|
@@ -3079,12 +3087,18 @@ function isLikelyEntryPoint(filePath) {
|
|
|
3079
3087
|
"main",
|
|
3080
3088
|
"bin",
|
|
3081
3089
|
"index",
|
|
3082
|
-
// often used as entry point
|
|
3083
3090
|
"run",
|
|
3084
3091
|
"serve",
|
|
3085
3092
|
"start",
|
|
3086
3093
|
"boot",
|
|
3087
|
-
"init"
|
|
3094
|
+
"init",
|
|
3095
|
+
"parser",
|
|
3096
|
+
"config",
|
|
3097
|
+
"setup",
|
|
3098
|
+
"adapter",
|
|
3099
|
+
"provider",
|
|
3100
|
+
"handler",
|
|
3101
|
+
"vending"
|
|
3088
3102
|
];
|
|
3089
3103
|
const nameWithoutExt = lowerBasename.replace(
|
|
3090
3104
|
/\.(ts|js|tsx|jsx|mjs|cjs)$/,
|
|
@@ -3095,7 +3109,14 @@ function isLikelyEntryPoint(filePath) {
|
|
|
3095
3109
|
)) {
|
|
3096
3110
|
return true;
|
|
3097
3111
|
}
|
|
3098
|
-
const cliDirPatterns = [
|
|
3112
|
+
const cliDirPatterns = [
|
|
3113
|
+
"/bin/",
|
|
3114
|
+
"/cli/",
|
|
3115
|
+
"/cmd/",
|
|
3116
|
+
"/commands/",
|
|
3117
|
+
"/apps/",
|
|
3118
|
+
"/functions/"
|
|
3119
|
+
];
|
|
3099
3120
|
if (cliDirPatterns.some((p) => filePath.includes(p))) {
|
|
3100
3121
|
return true;
|
|
3101
3122
|
}
|
|
@@ -3229,6 +3250,123 @@ function calculateTestabilityIndex(params) {
|
|
|
3229
3250
|
};
|
|
3230
3251
|
}
|
|
3231
3252
|
|
|
3253
|
+
// src/utils/di-container.ts
|
|
3254
|
+
var DIContainer = class _DIContainer {
|
|
3255
|
+
constructor() {
|
|
3256
|
+
this.registrations = /* @__PURE__ */ new Map();
|
|
3257
|
+
this.singletons = /* @__PURE__ */ new Map();
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* Register a dependency with a factory function.
|
|
3261
|
+
*
|
|
3262
|
+
* @param token - Unique identifier for the dependency
|
|
3263
|
+
* @param factory - Factory function that creates the dependency
|
|
3264
|
+
* @param singleton - If true, the same instance is returned on each resolve (default: true)
|
|
3265
|
+
*/
|
|
3266
|
+
register(token, factory, singleton = true) {
|
|
3267
|
+
this.registrations.set(token, { factory, singleton });
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* Register an existing instance as a singleton.
|
|
3271
|
+
*
|
|
3272
|
+
* @param token - Unique identifier for the dependency
|
|
3273
|
+
* @param instance - The instance to register
|
|
3274
|
+
*/
|
|
3275
|
+
registerInstance(token, instance) {
|
|
3276
|
+
this.registrations.set(token, { factory: () => instance, singleton: true });
|
|
3277
|
+
this.singletons.set(token, instance);
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Resolve a dependency by its token.
|
|
3281
|
+
*
|
|
3282
|
+
* @param token - The token to resolve
|
|
3283
|
+
* @returns The resolved dependency
|
|
3284
|
+
* @throws Error if token is not registered
|
|
3285
|
+
*/
|
|
3286
|
+
resolve(token) {
|
|
3287
|
+
const registration = this.registrations.get(token);
|
|
3288
|
+
if (!registration) {
|
|
3289
|
+
throw new Error(`DI: No registration found for token: ${String(token)}`);
|
|
3290
|
+
}
|
|
3291
|
+
if (registration.singleton) {
|
|
3292
|
+
if (!this.singletons.has(token)) {
|
|
3293
|
+
this.singletons.set(token, registration.factory());
|
|
3294
|
+
}
|
|
3295
|
+
return this.singletons.get(token);
|
|
3296
|
+
}
|
|
3297
|
+
return registration.factory();
|
|
3298
|
+
}
|
|
3299
|
+
/**
|
|
3300
|
+
* Check if a token is registered.
|
|
3301
|
+
*/
|
|
3302
|
+
has(token) {
|
|
3303
|
+
return this.registrations.has(token);
|
|
3304
|
+
}
|
|
3305
|
+
/**
|
|
3306
|
+
* Clear all registrations and singletons.
|
|
3307
|
+
*/
|
|
3308
|
+
clear() {
|
|
3309
|
+
this.registrations.clear();
|
|
3310
|
+
this.singletons.clear();
|
|
3311
|
+
}
|
|
3312
|
+
/**
|
|
3313
|
+
* Create a child container that inherits registrations from parent.
|
|
3314
|
+
* Child can override parent registrations without affecting parent.
|
|
3315
|
+
*/
|
|
3316
|
+
createChild() {
|
|
3317
|
+
const child = new _DIContainer();
|
|
3318
|
+
for (const [token, registration] of this.registrations) {
|
|
3319
|
+
child.registrations.set(token, registration);
|
|
3320
|
+
}
|
|
3321
|
+
for (const [token, instance] of this.singletons) {
|
|
3322
|
+
child.singletons.set(token, instance);
|
|
3323
|
+
}
|
|
3324
|
+
return child;
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
var DI_TOKENS = {
|
|
3328
|
+
/** File system operations (fs/promises compatible) */
|
|
3329
|
+
FileSystem: /* @__PURE__ */ Symbol("FileSystem"),
|
|
3330
|
+
/** Logger instance */
|
|
3331
|
+
Logger: /* @__PURE__ */ Symbol("Logger"),
|
|
3332
|
+
/** AST parser factory */
|
|
3333
|
+
ParserFactory: /* @__PURE__ */ Symbol("ParserFactory"),
|
|
3334
|
+
/** Configuration provider */
|
|
3335
|
+
ConfigProvider: /* @__PURE__ */ Symbol("ConfigProvider"),
|
|
3336
|
+
/** Metrics collector */
|
|
3337
|
+
MetricsCollector: /* @__PURE__ */ Symbol("MetricsCollector")
|
|
3338
|
+
};
|
|
3339
|
+
var defaultImplementations = {
|
|
3340
|
+
/** Console-based logger (production default) */
|
|
3341
|
+
consoleLogger: () => ({
|
|
3342
|
+
info: (msg, meta) => console.log(`[INFO] ${msg}`, meta || ""),
|
|
3343
|
+
warn: (msg, meta) => console.warn(`[WARN] ${msg}`, meta || ""),
|
|
3344
|
+
error: (msg, meta) => console.error(`[ERROR] ${msg}`, meta || ""),
|
|
3345
|
+
debug: (msg, meta) => console.debug(`[DEBUG] ${msg}`, meta || "")
|
|
3346
|
+
}),
|
|
3347
|
+
/** No-op logger (test default) */
|
|
3348
|
+
noopLogger: () => ({
|
|
3349
|
+
info: () => {
|
|
3350
|
+
},
|
|
3351
|
+
warn: () => {
|
|
3352
|
+
},
|
|
3353
|
+
error: () => {
|
|
3354
|
+
},
|
|
3355
|
+
debug: () => {
|
|
3356
|
+
}
|
|
3357
|
+
}),
|
|
3358
|
+
/** In-memory config provider (test default) */
|
|
3359
|
+
memoryConfig: (initial) => {
|
|
3360
|
+
const store = new Map(Object.entries(initial || {}));
|
|
3361
|
+
return {
|
|
3362
|
+
get: (key, defaultValue) => store.get(key) ?? defaultValue,
|
|
3363
|
+
set: (key, value) => store.set(key, value),
|
|
3364
|
+
has: (key) => store.has(key)
|
|
3365
|
+
};
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3368
|
+
var globalContainer = new DIContainer();
|
|
3369
|
+
|
|
3232
3370
|
// src/metrics/doc-drift.ts
|
|
3233
3371
|
function calculateDocDrift(params) {
|
|
3234
3372
|
const {
|
|
@@ -3721,6 +3859,43 @@ function isBuildArtifact(filePath) {
|
|
|
3721
3859
|
const lower = filePath.toLowerCase();
|
|
3722
3860
|
return lower.includes("/node_modules/") || lower.includes("/dist/") || lower.includes("/build/") || lower.includes("/out/") || lower.includes("/.next/") || lower.includes("/target/") || lower.includes("/bin/");
|
|
3723
3861
|
}
|
|
3862
|
+
|
|
3863
|
+
// src/utils/error-utils.ts
|
|
3864
|
+
function getErrorMessage(error) {
|
|
3865
|
+
if (error instanceof Error) {
|
|
3866
|
+
return error.message;
|
|
3867
|
+
}
|
|
3868
|
+
if (typeof error === "string") {
|
|
3869
|
+
return error;
|
|
3870
|
+
}
|
|
3871
|
+
return String(error);
|
|
3872
|
+
}
|
|
3873
|
+
function toErrorMessage(error, fallback = "Unknown error") {
|
|
3874
|
+
if (error instanceof Error) {
|
|
3875
|
+
return error.message;
|
|
3876
|
+
}
|
|
3877
|
+
if (typeof error === "string" && error.length > 0) {
|
|
3878
|
+
return error;
|
|
3879
|
+
}
|
|
3880
|
+
return fallback;
|
|
3881
|
+
}
|
|
3882
|
+
function createErrorResponse(message, status, details) {
|
|
3883
|
+
return {
|
|
3884
|
+
error: message,
|
|
3885
|
+
status,
|
|
3886
|
+
...details !== void 0 && { details }
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
async function withErrorHandling(operation, context) {
|
|
3890
|
+
try {
|
|
3891
|
+
const data = await operation();
|
|
3892
|
+
return { success: true, data };
|
|
3893
|
+
} catch (error) {
|
|
3894
|
+
const message = getErrorMessage(error);
|
|
3895
|
+
const contextPrefix = context ? `${context}: ` : "";
|
|
3896
|
+
return { success: false, error: `${contextPrefix}${message}` };
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3724
3899
|
export {
|
|
3725
3900
|
AIReadyConfigSchema,
|
|
3726
3901
|
AnalysisResultSchema,
|
|
@@ -3732,6 +3907,8 @@ export {
|
|
|
3732
3907
|
DEFAULT_COST_CONFIG,
|
|
3733
3908
|
DEFAULT_EXCLUDE,
|
|
3734
3909
|
DEFAULT_TOOL_WEIGHTS,
|
|
3910
|
+
DIContainer,
|
|
3911
|
+
DI_TOKENS,
|
|
3735
3912
|
FRIENDLY_TOOL_NAMES,
|
|
3736
3913
|
GLOBAL_INFRA_OPTIONS,
|
|
3737
3914
|
GLOBAL_SCAN_OPTIONS,
|
|
@@ -3803,9 +3980,11 @@ export {
|
|
|
3803
3980
|
calculateTestabilityIndex,
|
|
3804
3981
|
calculateTokenBudget,
|
|
3805
3982
|
clearHistory,
|
|
3983
|
+
createErrorResponse,
|
|
3806
3984
|
createProvider,
|
|
3807
3985
|
createStandardCommand,
|
|
3808
3986
|
createStandardProgressCallback,
|
|
3987
|
+
defaultImplementations,
|
|
3809
3988
|
detectTestFramework,
|
|
3810
3989
|
displayStandardConsoleReport,
|
|
3811
3990
|
emitAnnotation,
|
|
@@ -3838,6 +4017,7 @@ export {
|
|
|
3838
4017
|
generateTable,
|
|
3839
4018
|
generateValueChain,
|
|
3840
4019
|
getElapsedTime,
|
|
4020
|
+
getErrorMessage,
|
|
3841
4021
|
getFileCommitTimestamps,
|
|
3842
4022
|
getFileExtension,
|
|
3843
4023
|
getFilesByPattern,
|
|
@@ -3871,6 +4051,7 @@ export {
|
|
|
3871
4051
|
getToolEmoji,
|
|
3872
4052
|
getToolWeight,
|
|
3873
4053
|
getWasmPath,
|
|
4054
|
+
globalContainer,
|
|
3874
4055
|
groupIssuesByFile,
|
|
3875
4056
|
handleCLIError,
|
|
3876
4057
|
handleJSONOutput,
|
|
@@ -3908,7 +4089,9 @@ export {
|
|
|
3908
4089
|
scanFiles,
|
|
3909
4090
|
setupParser,
|
|
3910
4091
|
severityToAnnotationLevel,
|
|
4092
|
+
toErrorMessage,
|
|
3911
4093
|
validateSpokeOutput,
|
|
3912
4094
|
validateWithSchema,
|
|
4095
|
+
withErrorHandling,
|
|
3913
4096
|
wrapInCard
|
|
3914
4097
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/core",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.19",
|
|
4
4
|
"description": "Shared utilities for AIReady analysis tools",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"clean": "rm -rf dist",
|
|
66
66
|
"release": "pnpm build && pnpm publish --no-git-checks",
|
|
67
67
|
"type-check": "tsc --noEmit",
|
|
68
|
-
"format-check": "prettier --check . --ignore-path ../../.prettierignore"
|
|
68
|
+
"format-check": "prettier --check . --ignore-path ../../.prettierignore",
|
|
69
|
+
"format": "prettier --write . --ignore-path ../../.prettierignore",
|
|
70
|
+
"lint:fix": "eslint . --fix"
|
|
69
71
|
}
|
|
70
72
|
}
|