@aiready/core 0.24.15 → 0.24.18

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
@@ -52,7 +52,7 @@ import {
52
52
  getToolWeight,
53
53
  normalizeToolName,
54
54
  parseWeightString
55
- } from "./chunk-LRM26BOB.mjs";
55
+ } from "./chunk-GQMKSUA4.mjs";
56
56
  import {
57
57
  TypeScriptParser
58
58
  } from "./chunk-OT6FOHL4.mjs";
@@ -1376,6 +1376,7 @@ function mergeConfigWithDefaults(userConfig, defaults) {
1376
1376
  if (userConfig.scan) {
1377
1377
  if (userConfig.scan.include) mergedConfig.include = userConfig.scan.include;
1378
1378
  if (userConfig.scan.exclude) mergedConfig.exclude = userConfig.scan.exclude;
1379
+ if (userConfig.scan.tools) mergedConfig.tools = userConfig.scan.tools;
1379
1380
  }
1380
1381
  if (userConfig.threshold !== void 0)
1381
1382
  mergedConfig.threshold = userConfig.threshold;
@@ -1398,6 +1399,12 @@ function mergeConfigWithDefaults(userConfig, defaults) {
1398
1399
  ...userConfig.output
1399
1400
  };
1400
1401
  }
1402
+ if (userConfig.scoring) {
1403
+ mergedConfig.scoring = {
1404
+ ...mergedConfig.scoring,
1405
+ ...userConfig.scoring
1406
+ };
1407
+ }
1401
1408
  return mergedConfig;
1402
1409
  }
1403
1410
 
@@ -3229,6 +3236,123 @@ function calculateTestabilityIndex(params) {
3229
3236
  };
3230
3237
  }
3231
3238
 
3239
+ // src/utils/di-container.ts
3240
+ var DIContainer = class _DIContainer {
3241
+ constructor() {
3242
+ this.registrations = /* @__PURE__ */ new Map();
3243
+ this.singletons = /* @__PURE__ */ new Map();
3244
+ }
3245
+ /**
3246
+ * Register a dependency with a factory function.
3247
+ *
3248
+ * @param token - Unique identifier for the dependency
3249
+ * @param factory - Factory function that creates the dependency
3250
+ * @param singleton - If true, the same instance is returned on each resolve (default: true)
3251
+ */
3252
+ register(token, factory, singleton = true) {
3253
+ this.registrations.set(token, { factory, singleton });
3254
+ }
3255
+ /**
3256
+ * Register an existing instance as a singleton.
3257
+ *
3258
+ * @param token - Unique identifier for the dependency
3259
+ * @param instance - The instance to register
3260
+ */
3261
+ registerInstance(token, instance) {
3262
+ this.registrations.set(token, { factory: () => instance, singleton: true });
3263
+ this.singletons.set(token, instance);
3264
+ }
3265
+ /**
3266
+ * Resolve a dependency by its token.
3267
+ *
3268
+ * @param token - The token to resolve
3269
+ * @returns The resolved dependency
3270
+ * @throws Error if token is not registered
3271
+ */
3272
+ resolve(token) {
3273
+ const registration = this.registrations.get(token);
3274
+ if (!registration) {
3275
+ throw new Error(`DI: No registration found for token: ${String(token)}`);
3276
+ }
3277
+ if (registration.singleton) {
3278
+ if (!this.singletons.has(token)) {
3279
+ this.singletons.set(token, registration.factory());
3280
+ }
3281
+ return this.singletons.get(token);
3282
+ }
3283
+ return registration.factory();
3284
+ }
3285
+ /**
3286
+ * Check if a token is registered.
3287
+ */
3288
+ has(token) {
3289
+ return this.registrations.has(token);
3290
+ }
3291
+ /**
3292
+ * Clear all registrations and singletons.
3293
+ */
3294
+ clear() {
3295
+ this.registrations.clear();
3296
+ this.singletons.clear();
3297
+ }
3298
+ /**
3299
+ * Create a child container that inherits registrations from parent.
3300
+ * Child can override parent registrations without affecting parent.
3301
+ */
3302
+ createChild() {
3303
+ const child = new _DIContainer();
3304
+ for (const [token, registration] of this.registrations) {
3305
+ child.registrations.set(token, registration);
3306
+ }
3307
+ for (const [token, instance] of this.singletons) {
3308
+ child.singletons.set(token, instance);
3309
+ }
3310
+ return child;
3311
+ }
3312
+ };
3313
+ var DI_TOKENS = {
3314
+ /** File system operations (fs/promises compatible) */
3315
+ FileSystem: /* @__PURE__ */ Symbol("FileSystem"),
3316
+ /** Logger instance */
3317
+ Logger: /* @__PURE__ */ Symbol("Logger"),
3318
+ /** AST parser factory */
3319
+ ParserFactory: /* @__PURE__ */ Symbol("ParserFactory"),
3320
+ /** Configuration provider */
3321
+ ConfigProvider: /* @__PURE__ */ Symbol("ConfigProvider"),
3322
+ /** Metrics collector */
3323
+ MetricsCollector: /* @__PURE__ */ Symbol("MetricsCollector")
3324
+ };
3325
+ var defaultImplementations = {
3326
+ /** Console-based logger (production default) */
3327
+ consoleLogger: () => ({
3328
+ info: (msg, meta) => console.log(`[INFO] ${msg}`, meta || ""),
3329
+ warn: (msg, meta) => console.warn(`[WARN] ${msg}`, meta || ""),
3330
+ error: (msg, meta) => console.error(`[ERROR] ${msg}`, meta || ""),
3331
+ debug: (msg, meta) => console.debug(`[DEBUG] ${msg}`, meta || "")
3332
+ }),
3333
+ /** No-op logger (test default) */
3334
+ noopLogger: () => ({
3335
+ info: () => {
3336
+ },
3337
+ warn: () => {
3338
+ },
3339
+ error: () => {
3340
+ },
3341
+ debug: () => {
3342
+ }
3343
+ }),
3344
+ /** In-memory config provider (test default) */
3345
+ memoryConfig: (initial) => {
3346
+ const store = new Map(Object.entries(initial || {}));
3347
+ return {
3348
+ get: (key, defaultValue) => store.get(key) ?? defaultValue,
3349
+ set: (key, value) => store.set(key, value),
3350
+ has: (key) => store.has(key)
3351
+ };
3352
+ }
3353
+ };
3354
+ var globalContainer = new DIContainer();
3355
+
3232
3356
  // src/metrics/doc-drift.ts
3233
3357
  function calculateDocDrift(params) {
3234
3358
  const {
@@ -3721,6 +3845,43 @@ function isBuildArtifact(filePath) {
3721
3845
  const lower = filePath.toLowerCase();
3722
3846
  return lower.includes("/node_modules/") || lower.includes("/dist/") || lower.includes("/build/") || lower.includes("/out/") || lower.includes("/.next/") || lower.includes("/target/") || lower.includes("/bin/");
3723
3847
  }
3848
+
3849
+ // src/utils/error-utils.ts
3850
+ function getErrorMessage(error) {
3851
+ if (error instanceof Error) {
3852
+ return error.message;
3853
+ }
3854
+ if (typeof error === "string") {
3855
+ return error;
3856
+ }
3857
+ return String(error);
3858
+ }
3859
+ function toErrorMessage(error, fallback = "Unknown error") {
3860
+ if (error instanceof Error) {
3861
+ return error.message;
3862
+ }
3863
+ if (typeof error === "string" && error.length > 0) {
3864
+ return error;
3865
+ }
3866
+ return fallback;
3867
+ }
3868
+ function createErrorResponse(message, status, details) {
3869
+ return {
3870
+ error: message,
3871
+ status,
3872
+ ...details !== void 0 && { details }
3873
+ };
3874
+ }
3875
+ async function withErrorHandling(operation, context) {
3876
+ try {
3877
+ const data = await operation();
3878
+ return { success: true, data };
3879
+ } catch (error) {
3880
+ const message = getErrorMessage(error);
3881
+ const contextPrefix = context ? `${context}: ` : "";
3882
+ return { success: false, error: `${contextPrefix}${message}` };
3883
+ }
3884
+ }
3724
3885
  export {
3725
3886
  AIReadyConfigSchema,
3726
3887
  AnalysisResultSchema,
@@ -3732,6 +3893,8 @@ export {
3732
3893
  DEFAULT_COST_CONFIG,
3733
3894
  DEFAULT_EXCLUDE,
3734
3895
  DEFAULT_TOOL_WEIGHTS,
3896
+ DIContainer,
3897
+ DI_TOKENS,
3735
3898
  FRIENDLY_TOOL_NAMES,
3736
3899
  GLOBAL_INFRA_OPTIONS,
3737
3900
  GLOBAL_SCAN_OPTIONS,
@@ -3803,9 +3966,11 @@ export {
3803
3966
  calculateTestabilityIndex,
3804
3967
  calculateTokenBudget,
3805
3968
  clearHistory,
3969
+ createErrorResponse,
3806
3970
  createProvider,
3807
3971
  createStandardCommand,
3808
3972
  createStandardProgressCallback,
3973
+ defaultImplementations,
3809
3974
  detectTestFramework,
3810
3975
  displayStandardConsoleReport,
3811
3976
  emitAnnotation,
@@ -3838,6 +4003,7 @@ export {
3838
4003
  generateTable,
3839
4004
  generateValueChain,
3840
4005
  getElapsedTime,
4006
+ getErrorMessage,
3841
4007
  getFileCommitTimestamps,
3842
4008
  getFileExtension,
3843
4009
  getFilesByPattern,
@@ -3871,6 +4037,7 @@ export {
3871
4037
  getToolEmoji,
3872
4038
  getToolWeight,
3873
4039
  getWasmPath,
4040
+ globalContainer,
3874
4041
  groupIssuesByFile,
3875
4042
  handleCLIError,
3876
4043
  handleJSONOutput,
@@ -3908,7 +4075,9 @@ export {
3908
4075
  scanFiles,
3909
4076
  setupParser,
3910
4077
  severityToAnnotationLevel,
4078
+ toErrorMessage,
3911
4079
  validateSpokeOutput,
3912
4080
  validateWithSchema,
4081
+ withErrorHandling,
3913
4082
  wrapInCard
3914
4083
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.24.15",
3
+ "version": "0.24.18",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -26,11 +26,11 @@
26
26
  "license": "MIT",
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "https://github.com/caopengau/aiready-core.git"
29
+ "url": "https://github.com/getaiready/aiready-core.git"
30
30
  },
31
- "homepage": "https://github.com/caopengau/aiready-core",
31
+ "homepage": "https://github.com/getaiready/aiready-core",
32
32
  "bugs": {
33
- "url": "https://github.com/caopengau/aiready-core/issues"
33
+ "url": "https://github.com/getaiready/aiready-core/issues"
34
34
  },
35
35
  "files": [
36
36
  "dist",