@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.
@@ -0,0 +1,307 @@
1
+ import {
2
+ ParseError
3
+ } from "./chunk-U3IY2CFC.mjs";
4
+
5
+ // src/parsers/typescript-parser.ts
6
+ import { parse } from "@typescript-eslint/typescript-estree";
7
+ var TypeScriptParser = class {
8
+ constructor() {
9
+ this.language = "typescript" /* TypeScript */;
10
+ this.extensions = [".ts", ".tsx", ".js", ".jsx"];
11
+ }
12
+ async initialize() {
13
+ }
14
+ canHandle(filePath) {
15
+ return this.extensions.some((ext) => filePath.endsWith(ext));
16
+ }
17
+ async getAST(code, filePath) {
18
+ try {
19
+ return parse(code, {
20
+ filePath,
21
+ loc: true,
22
+ range: true,
23
+ tokens: true,
24
+ comment: true,
25
+ jsx: filePath.endsWith("x")
26
+ });
27
+ } catch (error) {
28
+ const err = error;
29
+ throw new ParseError(err.message || "Unknown error", filePath, {
30
+ line: err.lineNumber || 1,
31
+ column: err.column || 0
32
+ });
33
+ }
34
+ }
35
+ parse(code, filePath) {
36
+ try {
37
+ const ast = parse(code, {
38
+ filePath,
39
+ loc: true,
40
+ range: true,
41
+ tokens: true,
42
+ comment: true,
43
+ jsx: filePath.endsWith("x")
44
+ });
45
+ const imports = this.extractImports(ast);
46
+ const exports = this.extractExports(ast, code, filePath);
47
+ return {
48
+ exports,
49
+ imports,
50
+ language: this.language
51
+ };
52
+ } catch (error) {
53
+ throw new ParseError(error.message, filePath, {
54
+ line: error.lineNumber || 1,
55
+ column: error.column || 0
56
+ });
57
+ }
58
+ }
59
+ getNamingConventions() {
60
+ return {
61
+ variablePattern: /^[a-z][a-zA-Z0-9]*$/,
62
+ functionPattern: /^[a-z][a-zA-Z0-9]*$/,
63
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
64
+ constantPattern: /^[A-Z][A-Z0-9_]*$/,
65
+ typePattern: /^[A-Z][a-zA-Z0-9]*$/,
66
+ interfacePattern: /^I?[A-Z][a-zA-Z0-9]*$/
67
+ };
68
+ }
69
+ analyzeMetadata(node, code) {
70
+ if (!code) return {};
71
+ return {
72
+ isPure: this.isLikelyPure(node),
73
+ hasSideEffects: !this.isLikelyPure(node)
74
+ };
75
+ }
76
+ extractImports(ast) {
77
+ const imports = [];
78
+ for (const node of ast.body) {
79
+ if (node.type === "ImportDeclaration") {
80
+ const specifiers = [];
81
+ let isTypeOnly = false;
82
+ if (node.importKind === "type") {
83
+ isTypeOnly = true;
84
+ }
85
+ for (const spec of node.specifiers) {
86
+ if (spec.type === "ImportSpecifier") {
87
+ const imported = spec.imported;
88
+ const name = imported.type === "Identifier" ? imported.name : imported.value;
89
+ specifiers.push(name);
90
+ } else if (spec.type === "ImportDefaultSpecifier") {
91
+ specifiers.push("default");
92
+ } else if (spec.type === "ImportNamespaceSpecifier") {
93
+ specifiers.push("*");
94
+ }
95
+ }
96
+ imports.push({
97
+ source: node.source.value,
98
+ specifiers,
99
+ isTypeOnly,
100
+ loc: node.loc ? {
101
+ start: {
102
+ line: node.loc.start.line,
103
+ column: node.loc.start.column
104
+ },
105
+ end: { line: node.loc.end.line, column: node.loc.end.column }
106
+ } : void 0
107
+ });
108
+ }
109
+ }
110
+ return imports;
111
+ }
112
+ extractExports(ast, code, filePath) {
113
+ const exports = [];
114
+ for (const node of ast.body) {
115
+ if (node.type === "ExportNamedDeclaration") {
116
+ if (node.declaration) {
117
+ const declaration = node.declaration;
118
+ if ((declaration.type === "FunctionDeclaration" || declaration.type === "TSDeclareFunction") && declaration.id) {
119
+ exports.push(
120
+ this.createExport(
121
+ declaration.id.name,
122
+ "function",
123
+ node,
124
+ // Pass the outer ExportNamedDeclaration
125
+ code,
126
+ filePath
127
+ )
128
+ );
129
+ } else if (declaration.type === "ClassDeclaration" && declaration.id) {
130
+ exports.push(
131
+ this.createExport(
132
+ declaration.id.name,
133
+ "class",
134
+ node,
135
+ // Pass the outer ExportNamedDeclaration
136
+ code,
137
+ filePath
138
+ )
139
+ );
140
+ } else if (declaration.type === "TSTypeAliasDeclaration") {
141
+ exports.push(
142
+ this.createExport(
143
+ declaration.id.name,
144
+ "type",
145
+ node,
146
+ // Pass the outer ExportNamedDeclaration
147
+ code,
148
+ filePath
149
+ )
150
+ );
151
+ } else if (declaration.type === "TSInterfaceDeclaration") {
152
+ exports.push(
153
+ this.createExport(
154
+ declaration.id.name,
155
+ "interface",
156
+ node,
157
+ // Pass the outer ExportNamedDeclaration
158
+ code,
159
+ filePath
160
+ )
161
+ );
162
+ } else if (declaration.type === "VariableDeclaration") {
163
+ for (const decl of declaration.declarations) {
164
+ if (decl.id.type === "Identifier") {
165
+ exports.push(
166
+ this.createExport(
167
+ decl.id.name,
168
+ "const",
169
+ node,
170
+ code,
171
+ filePath,
172
+ decl.init
173
+ )
174
+ );
175
+ }
176
+ }
177
+ }
178
+ }
179
+ } else if (node.type === "ExportDefaultDeclaration") {
180
+ exports.push(
181
+ this.createExport("default", "default", node, code, filePath)
182
+ );
183
+ }
184
+ }
185
+ return exports;
186
+ }
187
+ createExport(name, type, node, code, filePath, initializer) {
188
+ const documentation = this.extractDocumentation(node, code);
189
+ let methodCount;
190
+ let propertyCount;
191
+ let parameters;
192
+ let isPrimitive = false;
193
+ let isTyped = false;
194
+ if (initializer) {
195
+ if (initializer.type === "Literal" || initializer.type === "TemplateLiteral" && initializer.expressions.length === 0) {
196
+ isPrimitive = true;
197
+ }
198
+ }
199
+ let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
200
+ if (!structNode) structNode = node;
201
+ if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
202
+ if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
203
+ isTyped = true;
204
+ } else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
205
+ const func = structNode;
206
+ const hasReturnType = !!func.returnType;
207
+ const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
208
+ isTyped = hasReturnType && allParamsTyped;
209
+ } else if (structNode.type === "VariableDeclaration") {
210
+ const variable = structNode;
211
+ isTyped = variable.declarations.every(
212
+ (d) => !!d.id.typeAnnotation || !!d.init
213
+ );
214
+ } else if (structNode.type === "ClassDeclaration") {
215
+ isTyped = true;
216
+ }
217
+ } else if (filePath.endsWith(".js") || filePath.endsWith(".jsx")) {
218
+ isTyped = false;
219
+ }
220
+ if (structNode.type === "ClassDeclaration" || structNode.type === "TSInterfaceDeclaration") {
221
+ const body = structNode.type === "ClassDeclaration" ? structNode.body.body : structNode.body.body;
222
+ methodCount = body.filter(
223
+ (m) => m.type === "MethodDefinition" || m.type === "TSMethodSignature"
224
+ ).length;
225
+ propertyCount = body.filter(
226
+ (m) => m.type === "PropertyDefinition" || m.type === "TSPropertySignature"
227
+ ).length;
228
+ if (structNode.type === "ClassDeclaration") {
229
+ const constructor = body.find(
230
+ (m) => m.type === "MethodDefinition" && m.kind === "constructor"
231
+ );
232
+ if (constructor && constructor.value && constructor.value.params) {
233
+ parameters = constructor.value.params.map((p) => {
234
+ if (p.type === "Identifier") return p.name;
235
+ if (p.type === "TSParameterProperty" && p.parameter.type === "Identifier") {
236
+ return p.parameter.name;
237
+ }
238
+ return void 0;
239
+ }).filter((p) => !!p);
240
+ }
241
+ }
242
+ }
243
+ if (!parameters && (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition")) {
244
+ const funcNode = structNode.type === "MethodDefinition" ? structNode.value : structNode;
245
+ if (funcNode && funcNode.params) {
246
+ parameters = funcNode.params.map((p) => {
247
+ if (p.type === "Identifier") return p.name;
248
+ return void 0;
249
+ }).filter((p) => !!p);
250
+ }
251
+ }
252
+ return {
253
+ name,
254
+ type,
255
+ isPrimitive,
256
+ loc: node.loc ? {
257
+ start: { line: node.loc.start.line, column: node.loc.start.column },
258
+ end: { line: node.loc.end.line, column: node.loc.end.column }
259
+ } : void 0,
260
+ documentation,
261
+ methodCount,
262
+ propertyCount,
263
+ parameters,
264
+ isPure: this.isLikelyPure(node),
265
+ hasSideEffects: !this.isLikelyPure(node),
266
+ isTyped
267
+ };
268
+ }
269
+ extractDocumentation(node, code) {
270
+ if (node.range) {
271
+ const start = node.range[0];
272
+ const precedingCode = code.substring(0, start);
273
+ const jsdocMatch = precedingCode.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
274
+ if (jsdocMatch) {
275
+ return {
276
+ content: jsdocMatch[1].trim(),
277
+ type: "jsdoc"
278
+ };
279
+ }
280
+ }
281
+ return void 0;
282
+ }
283
+ isLikelyPure(node) {
284
+ const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
285
+ if (!sn) return false;
286
+ if (sn.type === "VariableDeclaration" && sn.kind === "const") return true;
287
+ if (sn.type === "FunctionDeclaration" || sn.type === "MethodDefinition") {
288
+ const body = sn.type === "MethodDefinition" ? sn.value.body : sn.body;
289
+ if (body && body.type === "BlockStatement") {
290
+ const bodyContent = JSON.stringify(
291
+ body,
292
+ (_, v) => typeof v === "bigint" ? v.toString() : v
293
+ );
294
+ if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"name":"fs"') || bodyContent.includes('"name":"fetch"') || bodyContent.includes('"name":"axios"')) {
295
+ return false;
296
+ }
297
+ return true;
298
+ }
299
+ return true;
300
+ }
301
+ return false;
302
+ }
303
+ };
304
+
305
+ export {
306
+ TypeScriptParser
307
+ };
@@ -1,2 +1,2 @@
1
- export { e as AIReadyConfig, o as AIReadyConfigSchema, i as AcceptancePrediction, A as AnalysisResult, q as AnalysisResultSchema, r as AnalysisStatus, s as AnalysisStatusSchema, aN as BaseGraphLink, aO as BaseGraphNode, B as BusinessMetrics, t as COMMON_FINE_TUNING_OPTIONS, u as CONTEXT_TIER_THRESHOLDS, v as CommonASTNode, j as ComprehensionDifficulty, w as Config, C as CostConfig, D as DEFAULT_TOOL_WEIGHTS, n as ExportInfo, x as FRIENDLY_TOOL_NAMES, y as FileContent, G as GLOBAL_INFRA_OPTIONS, z as GLOBAL_SCAN_OPTIONS, H as GraphData, J as GraphEdge, K as GraphIssueSeverity, O as GraphMetadata, Q as GraphNode, I as Issue, R as IssueOverlay, U as IssueSchema, V as IssueType, W as IssueTypeSchema, X as LANGUAGE_EXTENSIONS, L as Language, Y as LanguageConfig, l as LanguageParser, Z as Lead, _ as LeadSchema, $ as LeadSource, a0 as LeadSourceSchema, a1 as LeadSubmission, a2 as LeadSubmissionSchema, a3 as Location, a4 as LocationSchema, M as Metrics, a7 as MetricsSchema, g as ModelContextTier, a8 as ModelTier, a9 as ModelTierSchema, N as NamingConvention, aa as ParseError, m as ParseResult, ab as ParseStatistics, P as ProductivityImpact, ad as RecommendationPriority, ae as SCORING_PROFILES, af as SIZE_ADJUSTED_THRESHOLDS, S as ScanOptions, ag as ScanResult, ah as ScoringConfig, ai as ScoringProfile, aj as ScoringResult, c as Severity, ak as SeveritySchema, c as SeverityType, al as SourceLocation, am as SourceRange, a as SpokeOutput, an as SpokeOutputSchema, ao as SpokeSummary, ap as SpokeSummarySchema, aq as TOOL_NAME_MAP, f as TechnicalValueChain, k as TechnicalValueChainSummary, h as TokenBudget, T as ToolName, ar as ToolNameSchema, d as ToolOptions, as as ToolOutput, b as ToolScoringOutput, at as UnifiedReport, au as UnifiedReportSchema, av as calculateOverallScore, aw as formatScore, ax as formatToolScore, ay as generateHTML, aA as getProjectSizeTier, aB as getRating, aC as getRatingDisplay, aG as getRatingSlug, aH as getRatingWithContext, aI as getRecommendedThreshold, aK as getToolWeight, aL as normalizeToolName, aM as parseWeightString } from '../index-DGbarGnr.mjs';
1
+ export { e as AIReadyConfig, o as AIReadyConfigSchema, i as AcceptancePrediction, A as AnalysisResult, q as AnalysisResultSchema, r as AnalysisStatus, s as AnalysisStatusSchema, aN as BaseGraphLink, aO as BaseGraphNode, B as BusinessMetrics, t as COMMON_FINE_TUNING_OPTIONS, u as CONTEXT_TIER_THRESHOLDS, v as CommonASTNode, j as ComprehensionDifficulty, w as Config, C as CostConfig, D as DEFAULT_TOOL_WEIGHTS, n as ExportInfo, x as FRIENDLY_TOOL_NAMES, y as FileContent, G as GLOBAL_INFRA_OPTIONS, z as GLOBAL_SCAN_OPTIONS, H as GraphData, J as GraphEdge, K as GraphIssueSeverity, O as GraphMetadata, Q as GraphNode, I as Issue, R as IssueOverlay, U as IssueSchema, V as IssueType, W as IssueTypeSchema, X as LANGUAGE_EXTENSIONS, L as Language, Y as LanguageConfig, l as LanguageParser, Z as Lead, _ as LeadSchema, $ as LeadSource, a0 as LeadSourceSchema, a1 as LeadSubmission, a2 as LeadSubmissionSchema, a3 as Location, a4 as LocationSchema, M as Metrics, a7 as MetricsSchema, g as ModelContextTier, a8 as ModelTier, a9 as ModelTierSchema, N as NamingConvention, aa as ParseError, m as ParseResult, ab as ParseStatistics, P as ProductivityImpact, ad as RecommendationPriority, ae as SCORING_PROFILES, af as SIZE_ADJUSTED_THRESHOLDS, S as ScanOptions, ag as ScanResult, ah as ScoringConfig, ai as ScoringProfile, aj as ScoringResult, c as Severity, ak as SeveritySchema, c as SeverityType, al as SourceLocation, am as SourceRange, a as SpokeOutput, an as SpokeOutputSchema, ao as SpokeSummary, ap as SpokeSummarySchema, aq as TOOL_NAME_MAP, f as TechnicalValueChain, k as TechnicalValueChainSummary, h as TokenBudget, T as ToolName, ar as ToolNameSchema, d as ToolOptions, as as ToolOutput, b as ToolScoringOutput, at as UnifiedReport, au as UnifiedReportSchema, av as calculateOverallScore, aw as formatScore, ax as formatToolScore, ay as generateHTML, aA as getProjectSizeTier, aB as getRating, aC as getRatingDisplay, aG as getRatingSlug, aH as getRatingWithContext, aI as getRecommendedThreshold, aK as getToolWeight, aL as normalizeToolName, aM as parseWeightString } from '../index-c5MKV8s5.mjs';
2
2
  import 'zod';
@@ -1,2 +1,2 @@
1
- export { e as AIReadyConfig, o as AIReadyConfigSchema, i as AcceptancePrediction, A as AnalysisResult, q as AnalysisResultSchema, r as AnalysisStatus, s as AnalysisStatusSchema, aN as BaseGraphLink, aO as BaseGraphNode, B as BusinessMetrics, t as COMMON_FINE_TUNING_OPTIONS, u as CONTEXT_TIER_THRESHOLDS, v as CommonASTNode, j as ComprehensionDifficulty, w as Config, C as CostConfig, D as DEFAULT_TOOL_WEIGHTS, n as ExportInfo, x as FRIENDLY_TOOL_NAMES, y as FileContent, G as GLOBAL_INFRA_OPTIONS, z as GLOBAL_SCAN_OPTIONS, H as GraphData, J as GraphEdge, K as GraphIssueSeverity, O as GraphMetadata, Q as GraphNode, I as Issue, R as IssueOverlay, U as IssueSchema, V as IssueType, W as IssueTypeSchema, X as LANGUAGE_EXTENSIONS, L as Language, Y as LanguageConfig, l as LanguageParser, Z as Lead, _ as LeadSchema, $ as LeadSource, a0 as LeadSourceSchema, a1 as LeadSubmission, a2 as LeadSubmissionSchema, a3 as Location, a4 as LocationSchema, M as Metrics, a7 as MetricsSchema, g as ModelContextTier, a8 as ModelTier, a9 as ModelTierSchema, N as NamingConvention, aa as ParseError, m as ParseResult, ab as ParseStatistics, P as ProductivityImpact, ad as RecommendationPriority, ae as SCORING_PROFILES, af as SIZE_ADJUSTED_THRESHOLDS, S as ScanOptions, ag as ScanResult, ah as ScoringConfig, ai as ScoringProfile, aj as ScoringResult, c as Severity, ak as SeveritySchema, c as SeverityType, al as SourceLocation, am as SourceRange, a as SpokeOutput, an as SpokeOutputSchema, ao as SpokeSummary, ap as SpokeSummarySchema, aq as TOOL_NAME_MAP, f as TechnicalValueChain, k as TechnicalValueChainSummary, h as TokenBudget, T as ToolName, ar as ToolNameSchema, d as ToolOptions, as as ToolOutput, b as ToolScoringOutput, at as UnifiedReport, au as UnifiedReportSchema, av as calculateOverallScore, aw as formatScore, ax as formatToolScore, ay as generateHTML, aA as getProjectSizeTier, aB as getRating, aC as getRatingDisplay, aG as getRatingSlug, aH as getRatingWithContext, aI as getRecommendedThreshold, aK as getToolWeight, aL as normalizeToolName, aM as parseWeightString } from '../index-DGbarGnr.js';
1
+ export { e as AIReadyConfig, o as AIReadyConfigSchema, i as AcceptancePrediction, A as AnalysisResult, q as AnalysisResultSchema, r as AnalysisStatus, s as AnalysisStatusSchema, aN as BaseGraphLink, aO as BaseGraphNode, B as BusinessMetrics, t as COMMON_FINE_TUNING_OPTIONS, u as CONTEXT_TIER_THRESHOLDS, v as CommonASTNode, j as ComprehensionDifficulty, w as Config, C as CostConfig, D as DEFAULT_TOOL_WEIGHTS, n as ExportInfo, x as FRIENDLY_TOOL_NAMES, y as FileContent, G as GLOBAL_INFRA_OPTIONS, z as GLOBAL_SCAN_OPTIONS, H as GraphData, J as GraphEdge, K as GraphIssueSeverity, O as GraphMetadata, Q as GraphNode, I as Issue, R as IssueOverlay, U as IssueSchema, V as IssueType, W as IssueTypeSchema, X as LANGUAGE_EXTENSIONS, L as Language, Y as LanguageConfig, l as LanguageParser, Z as Lead, _ as LeadSchema, $ as LeadSource, a0 as LeadSourceSchema, a1 as LeadSubmission, a2 as LeadSubmissionSchema, a3 as Location, a4 as LocationSchema, M as Metrics, a7 as MetricsSchema, g as ModelContextTier, a8 as ModelTier, a9 as ModelTierSchema, N as NamingConvention, aa as ParseError, m as ParseResult, ab as ParseStatistics, P as ProductivityImpact, ad as RecommendationPriority, ae as SCORING_PROFILES, af as SIZE_ADJUSTED_THRESHOLDS, S as ScanOptions, ag as ScanResult, ah as ScoringConfig, ai as ScoringProfile, aj as ScoringResult, c as Severity, ak as SeveritySchema, c as SeverityType, al as SourceLocation, am as SourceRange, a as SpokeOutput, an as SpokeOutputSchema, ao as SpokeSummary, ap as SpokeSummarySchema, aq as TOOL_NAME_MAP, f as TechnicalValueChain, k as TechnicalValueChainSummary, h as TokenBudget, T as ToolName, ar as ToolNameSchema, d as ToolOptions, as as ToolOutput, b as ToolScoringOutput, at as UnifiedReport, au as UnifiedReportSchema, av as calculateOverallScore, aw as formatScore, ax as formatToolScore, ay as generateHTML, aA as getProjectSizeTier, aB as getRating, aC as getRatingDisplay, aG as getRatingSlug, aH as getRatingWithContext, aI as getRecommendedThreshold, aK as getToolWeight, aL as normalizeToolName, aM as parseWeightString } from '../index-c5MKV8s5.js';
2
2
  import 'zod';
@@ -328,7 +328,7 @@ var ManagedAccountSchema = import_zod7.z.object({
328
328
  accountId: import_zod7.z.string(),
329
329
  // AWS Account ID
330
330
  userId: import_zod7.z.string(),
331
- // Owner (caopengau@gmail.com)
331
+ // Owner (team@getaiready.dev)
332
332
  stripeSubscriptionId: import_zod7.z.string(),
333
333
  // AI Token Management
334
334
  tokenStrategy: import_zod7.z.enum(["managed", "byok"]).default("managed"),
@@ -504,7 +504,11 @@ var DEFAULT_TOOL_WEIGHTS = {
504
504
  ["doc-drift" /* DocDrift */]: 8,
505
505
  ["dependency-health" /* DependencyHealth */]: 6,
506
506
  ["change-amplification" /* ChangeAmplification */]: 8,
507
- ["contract-enforcement" /* ContractEnforcement */]: 10
507
+ ["contract-enforcement" /* ContractEnforcement */]: 10,
508
+ ["cognitive-load" /* CognitiveLoad */]: 8,
509
+ ["pattern-entropy" /* PatternEntropy */]: 8,
510
+ ["concept-cohesion" /* ConceptCohesion */]: 10,
511
+ ["semantic-distance" /* SemanticDistance */]: 10
508
512
  };
509
513
  var TOOL_NAME_MAP = {
510
514
  patterns: "pattern-detect" /* PatternDetect */,
@@ -45,7 +45,7 @@ import {
45
45
  getToolWeight,
46
46
  normalizeToolName,
47
47
  parseWeightString
48
- } from "../chunk-LRM26BOB.mjs";
48
+ } from "../chunk-3NEZ5M7Y.mjs";
49
49
  import {
50
50
  LANGUAGE_EXTENSIONS,
51
51
  Language,