cdk-insights 0.6.0 → 0.7.0

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/cli/entry.js CHANGED
@@ -94105,6 +94105,7 @@ var runAnalysis = async ({
94105
94105
  failOnCritical,
94106
94106
  tier,
94107
94107
  noCache = false,
94108
+ allowOveruse = false,
94108
94109
  cache: cache3,
94109
94110
  quotaValidation
94110
94111
  }) => {
@@ -94122,6 +94123,25 @@ var runAnalysis = async ({
94122
94123
  services: services || ["All services"],
94123
94124
  output: output || "table"
94124
94125
  });
94126
+ if (quotaValidation && !quotaValidation.quota.isTrial && quotaValidation.canRunAIAnalysis && allowOveruse) {
94127
+ const alreadyExceeded = quotaValidation.quota.currentResourcesAnalyzed >= quotaValidation.quota.maxResources;
94128
+ const wouldExceed = quotaValidation.quota.wouldExceed;
94129
+ if (alreadyExceeded) {
94130
+ terminal.warning(
94131
+ `\u26A0\uFE0F You have exceeded your paid allowance (${quotaValidation.quota.currentResourcesAnalyzed}/${quotaValidation.quota.maxResources} resources analyzed).`
94132
+ );
94133
+ terminal.warning(
94134
+ " Proceeding with AI analysis as --allow-overuse is enabled. Extra usage will be charged."
94135
+ );
94136
+ } else if (wouldExceed) {
94137
+ terminal.warning(
94138
+ `\u26A0\uFE0F This analysis will exceed your paid allowance (${quotaValidation.quota.currentResourcesAnalyzed}/${quotaValidation.quota.maxResources} resources analyzed).`
94139
+ );
94140
+ terminal.warning(
94141
+ " Proceeding with AI analysis as --allow-overuse is enabled. Extra usage will be charged."
94142
+ );
94143
+ }
94144
+ }
94125
94145
  const manifest = loadManifest("cdk.out");
94126
94146
  const constructRegistry = await withErrorHandling(
94127
94147
  () => loadConstructMetadata(listAvailableConstructs()),
@@ -94415,8 +94435,21 @@ var validateEnhancedLicenseQuota = async (request) => {
94415
94435
  canProceed = false;
94416
94436
  canRunStaticAnalysis = true;
94417
94437
  canRunAIAnalysis = false;
94418
- reason = `AI-powered analysis would exceed trial limit. You have analyzed ${currentResources2}/${maxResources2} resources and are requesting ${request.requestedResources} more.`;
94438
+ const overuseNote = request.allowOveruse ? " Note: --allow-overuse does not apply to trial licenses which have a hard usage limit." : "";
94439
+ reason = `AI-powered analysis would exceed trial limit. You have analyzed ${currentResources2}/${maxResources2} resources and are requesting ${request.requestedResources} more.${overuseNote}`;
94419
94440
  upgradePath = "https://cdkinsights.dev/pricing";
94441
+ } else if (wouldExceed2 && !isTrial2) {
94442
+ if (request.allowOveruse) {
94443
+ canProceed = true;
94444
+ canRunStaticAnalysis = true;
94445
+ canRunAIAnalysis = true;
94446
+ reason = `You have exceeded your paid allowance (${currentResources2}/${maxResources2} resources). Proceeding with AI analysis as --allow-overuse is enabled. Extra usage will be charged.`;
94447
+ } else {
94448
+ canProceed = true;
94449
+ canRunStaticAnalysis = true;
94450
+ canRunAIAnalysis = false;
94451
+ reason = `AI analysis would exceed your paid allowance (${currentResources2}/${maxResources2} resources). Extra usage will be charged. Use --allow-overuse to proceed with AI analysis.`;
94452
+ }
94420
94453
  } else if (isTrial2 && currentResources2 >= hardStopThreshold && request.requestedResources > 10) {
94421
94454
  canProceed = false;
94422
94455
  canRunStaticAnalysis = true;
@@ -94597,6 +94630,7 @@ var DEFAULT_CONFIG = {
94597
94630
  reset: false,
94598
94631
  github: false,
94599
94632
  noCache: false,
94633
+ allowOveruse: false,
94600
94634
  cache: {
94601
94635
  enabled: true,
94602
94636
  ttl: 5 * 60 * 1e3,
@@ -94707,6 +94741,10 @@ var mergeConfigWithArgs = (config2, cliArgs) => {
94707
94741
  reset: cliArgs.reset ?? DEFAULT_CONFIG.reset,
94708
94742
  github: cliArgs.github ?? DEFAULT_CONFIG.github,
94709
94743
  noCache: cliArgs.noCache ?? DEFAULT_CONFIG.noCache,
94744
+ allowOveruse: validateBoolean(
94745
+ cliArgs.allowOveruse ?? config2.allowOveruse,
94746
+ DEFAULT_CONFIG.allowOveruse
94747
+ ),
94710
94748
  cache: validateCacheConfig(
94711
94749
  cliArgs.cache ?? config2.cache ?? DEFAULT_CONFIG.cache
94712
94750
  )
@@ -94725,6 +94763,7 @@ var DEFAULT_CONFIG2 = {
94725
94763
  ruleFilter: [],
94726
94764
  failOnCritical: true,
94727
94765
  noCache: false,
94766
+ allowOveruse: false,
94728
94767
  cache: {
94729
94768
  enabled: true,
94730
94769
  ttl: 5 * 60 * 1e3,
@@ -94775,6 +94814,9 @@ var validateConfig = (config2) => {
94775
94814
  if (typeof raw.noCache === "boolean") {
94776
94815
  validated.noCache = raw.noCache;
94777
94816
  }
94817
+ if (typeof raw.allowOveruse === "boolean") {
94818
+ validated.allowOveruse = raw.allowOveruse;
94819
+ }
94778
94820
  if (raw.cache && typeof raw.cache === "object" && !Array.isArray(raw.cache)) {
94779
94821
  const cacheConfig = raw.cache;
94780
94822
  validated.cache = { ...DEFAULT_CONFIG2.cache };
@@ -95004,7 +95046,6 @@ async function runStackAnalysis(finalConfig, fingerprint, authToken, licenseInfo
95004
95046
  let canRunAIAnalysis = true;
95005
95047
  if (licenseKey) {
95006
95048
  terminal.info("\u{1F50D} Checking license quota...");
95007
- console.log("licenseInfo", licenseInfo);
95008
95049
  const isTrial = licenseInfo.licenseType === "TRIAL" || licenseInfo.status === "TRIAL";
95009
95050
  const currentResources = licenseInfo.totalResourcesAnalyzed || 0;
95010
95051
  const maxResources = licenseInfo.trialUsageLimit || licenseInfo.maxUsage || 200;
@@ -95041,6 +95082,7 @@ async function runStackAnalysis(finalConfig, fingerprint, authToken, licenseInfo
95041
95082
  quotaValidation = await validateEnhancedLicenseQuota({
95042
95083
  licenseKey,
95043
95084
  requestedResources: estimatedResources,
95085
+ allowOveruse: finalConfig.allowOveruse,
95044
95086
  usageData,
95045
95087
  licenseInfo
95046
95088
  });
@@ -95146,6 +95188,7 @@ async function runStackAnalysis(finalConfig, fingerprint, authToken, licenseInfo
95146
95188
  quotaValidation: quotaValidation || null,
95147
95189
  // Pass quota validation info to control analysis phases
95148
95190
  noCache: finalConfig.noCache || false,
95191
+ allowOveruse: finalConfig.allowOveruse || false,
95149
95192
  onAuthRefresh
95150
95193
  };
95151
95194
  return await runAnalysis(analysisConfig);
@@ -95199,6 +95242,10 @@ var analyzeCommand = {
95199
95242
  describe: "Disable cache and force fresh analysis",
95200
95243
  type: "boolean",
95201
95244
  default: false
95245
+ }).option("allowOveruse", {
95246
+ describe: "Allow AI analysis even when exceeding paid allowance (extra usage will be charged)",
95247
+ type: "boolean",
95248
+ default: false
95202
95249
  }),
95203
95250
  handler: async (argv) => {
95204
95251
  try {
@@ -95560,6 +95607,13 @@ var CONFIG_FIELDS = {
95560
95607
  examples: ["true", "false"],
95561
95608
  validation: "Must be true or false"
95562
95609
  },
95610
+ allowOveruse: {
95611
+ type: "boolean",
95612
+ default: false,
95613
+ description: "Allow AI analysis to proceed even when it will exceed paid allowance (extra usage will be charged)",
95614
+ examples: ["true", "false"],
95615
+ validation: "Must be true or false"
95616
+ },
95563
95617
  cache: {
95564
95618
  type: "object",
95565
95619
  default: { enabled: true, ttl: 3e5, maxSize: 1e3 },
@@ -95881,6 +95935,7 @@ var createHelpTable = () => {
95881
95935
  ["--fail-on-critical", "Exit with code 1 if critical issues found"],
95882
95936
  ["--rule-filter", "Filter findings by rule IDs or categories"],
95883
95937
  ["--no-cache", "Disable cache and force fresh analysis"],
95938
+ ["--allow-overuse", "Allow AI analysis even when exceeding paid allowance (extra usage charged)"],
95884
95939
  ["", ""]
95885
95940
  );
95886
95941
  helpTable.push(
@@ -95922,6 +95977,7 @@ var configCommand = {
95922
95977
  "ruleFilter",
95923
95978
  "failOnCritical",
95924
95979
  "noCache",
95980
+ "allowOveruse",
95925
95981
  "cache"
95926
95982
  ],
95927
95983
  describe: "Configuration field to set"
@@ -95949,6 +96005,7 @@ var configCommand = {
95949
96005
  "ruleFilter",
95950
96006
  "failOnCritical",
95951
96007
  "noCache",
96008
+ "allowOveruse",
95952
96009
  "cache"
95953
96010
  ],
95954
96011
  describe: "Configuration field to remove"
@@ -17,6 +17,7 @@ export interface AnalyzeCommandArgs {
17
17
  summaryOnly?: boolean;
18
18
  synth?: boolean;
19
19
  noCache?: boolean;
20
+ allowOveruse?: boolean;
20
21
  cache?: {
21
22
  enabled?: boolean;
22
23
  ttl?: number;
@@ -35,6 +36,7 @@ export interface UserConfig {
35
36
  synth?: boolean;
36
37
  ruleFilter?: string[];
37
38
  noCache?: boolean;
39
+ allowOveruse?: boolean;
38
40
  cache?: {
39
41
  enabled?: boolean;
40
42
  ttl?: number;
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ type QuotaValidation = {
16
16
  isTrial: boolean;
17
17
  currentResourcesAnalyzed: number;
18
18
  maxResources: number;
19
+ wouldExceed?: boolean;
19
20
  };
20
21
  };
21
22
  interface RunAnalysisTypes {
@@ -34,6 +35,7 @@ interface RunAnalysisTypes {
34
35
  failOnCritical?: boolean;
35
36
  tier?: Tier;
36
37
  noCache?: boolean;
38
+ allowOveruse?: boolean;
37
39
  cache?: CacheConfig;
38
40
  quotaValidation?: QuotaValidation;
39
41
  }
@@ -42,7 +44,7 @@ interface RunAnalysisTypes {
42
44
  * Main analysis entry
43
45
  * ---------------------------------------
44
46
  */
45
- export declare const runAnalysis: ({ stacks, inlineFindings, pathToLogicalId, output, recommendationMapPerStack, withIssue, services, ruleFilter, authToken, fingerprint, failOnCritical, tier, noCache, cache, quotaValidation, }: RunAnalysisTypes) => Promise<{
47
+ export declare const runAnalysis: ({ stacks, inlineFindings, pathToLogicalId, output, recommendationMapPerStack, withIssue, services, ruleFilter, authToken, fingerprint, failOnCritical, tier, noCache, allowOveruse, cache, quotaValidation, }: RunAnalysisTypes) => Promise<{
46
48
  recommendationMaps: Record<string, IssueGroup>;
47
49
  hasCriticalIssues: boolean;
48
50
  }>;
package/dist/index.js CHANGED
@@ -60463,6 +60463,7 @@ var runAnalysis = async ({
60463
60463
  failOnCritical,
60464
60464
  tier,
60465
60465
  noCache = false,
60466
+ allowOveruse = false,
60466
60467
  cache: cache3,
60467
60468
  quotaValidation
60468
60469
  }) => {
@@ -60480,6 +60481,25 @@ var runAnalysis = async ({
60480
60481
  services: services || ["All services"],
60481
60482
  output: output || "table"
60482
60483
  });
60484
+ if (quotaValidation && !quotaValidation.quota.isTrial && quotaValidation.canRunAIAnalysis && allowOveruse) {
60485
+ const alreadyExceeded = quotaValidation.quota.currentResourcesAnalyzed >= quotaValidation.quota.maxResources;
60486
+ const wouldExceed = quotaValidation.quota.wouldExceed;
60487
+ if (alreadyExceeded) {
60488
+ terminal2.warning(
60489
+ `\u26A0\uFE0F You have exceeded your paid allowance (${quotaValidation.quota.currentResourcesAnalyzed}/${quotaValidation.quota.maxResources} resources analyzed).`
60490
+ );
60491
+ terminal2.warning(
60492
+ " Proceeding with AI analysis as --allow-overuse is enabled. Extra usage will be charged."
60493
+ );
60494
+ } else if (wouldExceed) {
60495
+ terminal2.warning(
60496
+ `\u26A0\uFE0F This analysis will exceed your paid allowance (${quotaValidation.quota.currentResourcesAnalyzed}/${quotaValidation.quota.maxResources} resources analyzed).`
60497
+ );
60498
+ terminal2.warning(
60499
+ " Proceeding with AI analysis as --allow-overuse is enabled. Extra usage will be charged."
60500
+ );
60501
+ }
60502
+ }
60483
60503
  const manifest = loadManifest("cdk.out");
60484
60504
  const constructRegistry = await withErrorHandling(
60485
60505
  () => loadConstructMetadata(listAvailableConstructs()),
@@ -1,6 +1,7 @@
1
1
  export interface EnhancedQuotaValidationRequest {
2
2
  licenseKey: string;
3
3
  requestedResources: number;
4
+ allowOveruse?: boolean;
4
5
  usageData?: {
5
6
  totalTokens: number;
6
7
  totalResourcesAnalyzed: number;
@@ -16,4 +16,4 @@ export interface QuotaValidationResult {
16
16
  reason?: string;
17
17
  upgradePath?: string;
18
18
  }
19
- export declare const validateLicenseQuota: (licenseKey: string, requestedResources: number) => Promise<QuotaValidationResult>;
19
+ export declare const validateLicenseQuota: (licenseKey: string, requestedResources: number, allowOveruse?: boolean) => Promise<QuotaValidationResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdk-insights",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "AWS CDK security and cost analysis tool with AI-powered insights",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",