@redocly/cli 2.28.1 → 2.29.1

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.
Files changed (53) hide show
  1. package/lib/commands/score/collect-metrics.d.ts +17 -0
  2. package/lib/commands/score/collect-metrics.d.ts.map +1 -0
  3. package/lib/commands/score/collect-metrics.js +195 -0
  4. package/lib/commands/score/collect-metrics.js.map +1 -0
  5. package/lib/commands/score/collectors/dependency-graph.d.ts +9 -0
  6. package/lib/commands/score/collectors/dependency-graph.d.ts.map +1 -0
  7. package/lib/commands/score/collectors/dependency-graph.js +61 -0
  8. package/lib/commands/score/collectors/dependency-graph.js.map +1 -0
  9. package/lib/commands/score/collectors/document-metrics.d.ts +69 -0
  10. package/lib/commands/score/collectors/document-metrics.d.ts.map +1 -0
  11. package/lib/commands/score/collectors/document-metrics.js +343 -0
  12. package/lib/commands/score/collectors/document-metrics.js.map +1 -0
  13. package/lib/commands/score/constants.d.ts +4 -0
  14. package/lib/commands/score/constants.d.ts.map +1 -0
  15. package/lib/commands/score/constants.js +47 -0
  16. package/lib/commands/score/constants.js.map +1 -0
  17. package/lib/commands/score/formatters/json.d.ts +3 -0
  18. package/lib/commands/score/formatters/json.d.ts.map +1 -0
  19. package/lib/commands/score/formatters/json.js +20 -0
  20. package/lib/commands/score/formatters/json.js.map +1 -0
  21. package/lib/commands/score/formatters/stylish.d.ts +4 -0
  22. package/lib/commands/score/formatters/stylish.d.ts.map +1 -0
  23. package/lib/commands/score/formatters/stylish.js +235 -0
  24. package/lib/commands/score/formatters/stylish.js.map +1 -0
  25. package/lib/commands/score/hotspots.d.ts +3 -0
  26. package/lib/commands/score/hotspots.d.ts.map +1 -0
  27. package/lib/commands/score/hotspots.js +70 -0
  28. package/lib/commands/score/hotspots.js.map +1 -0
  29. package/lib/commands/score/index.d.ts +11 -0
  30. package/lib/commands/score/index.d.ts.map +1 -0
  31. package/lib/commands/score/index.js +69 -0
  32. package/lib/commands/score/index.js.map +1 -0
  33. package/lib/commands/score/scoring.d.ts +14 -0
  34. package/lib/commands/score/scoring.d.ts.map +1 -0
  35. package/lib/commands/score/scoring.js +136 -0
  36. package/lib/commands/score/scoring.js.map +1 -0
  37. package/lib/commands/score/types.d.ts +119 -0
  38. package/lib/commands/score/types.d.ts.map +1 -0
  39. package/lib/commands/score/types.js +2 -0
  40. package/lib/commands/score/types.js.map +1 -0
  41. package/lib/commands/score/utils.d.ts +2 -0
  42. package/lib/commands/score/utils.d.ts.map +1 -0
  43. package/lib/commands/score/utils.js +8 -0
  44. package/lib/commands/score/utils.js.map +1 -0
  45. package/lib/index.js +28 -0
  46. package/lib/index.js.map +1 -1
  47. package/lib/reunite/api/api-client.js +2 -2
  48. package/lib/reunite/api/api-client.js.map +1 -1
  49. package/lib/utils/constants.d.ts +1 -0
  50. package/lib/utils/constants.d.ts.map +1 -1
  51. package/lib/utils/constants.js +1 -0
  52. package/lib/utils/constants.js.map +1 -1
  53. package/package.json +3 -3
@@ -0,0 +1,235 @@
1
+ import { logger } from '@redocly/openapi-core';
2
+ import { bold, cyan, green, red, white, yellow } from 'colorette';
3
+ import { median } from '../utils.js';
4
+ export function printScoreStylish(result, operationDetails = false) {
5
+ printScores(result);
6
+ printSubscores(result);
7
+ printRawMetricsSummary(result);
8
+ if (operationDetails)
9
+ printOperationDetails(result);
10
+ printHotspots(result);
11
+ }
12
+ function scoreColor(score) {
13
+ if (score >= 80)
14
+ return green;
15
+ if (score >= 50)
16
+ return yellow;
17
+ return red;
18
+ }
19
+ function formatScore(score) {
20
+ return scoreColor(score)(bold(score.toFixed(1)));
21
+ }
22
+ function out(str) {
23
+ logger.output(str + '\n');
24
+ }
25
+ function printScores(result) {
26
+ out('');
27
+ out(bold(white(' Scores')));
28
+ out('');
29
+ out(` Agent Readiness: ${formatScore(result.agentReadiness)}/100`);
30
+ out('');
31
+ }
32
+ function printSubscores(result) {
33
+ out(bold(white(' Subscores')));
34
+ out('');
35
+ const s = result.subscores;
36
+ printSubscore('Parameter Simplicity', s.parameterSimplicity);
37
+ printSubscore('Schema Simplicity', s.schemaSimplicity);
38
+ printSubscore('Documentation Quality', s.documentationQuality);
39
+ printSubscore('Constraint Clarity', s.constraintClarity);
40
+ printSubscore('Example Coverage', s.exampleCoverage);
41
+ printSubscore('Error Clarity', s.errorClarity);
42
+ printSubscore('Dependency Clarity', s.dependencyClarity);
43
+ printSubscore('Identifier Clarity', s.identifierClarity);
44
+ printSubscore('Polymorphism Clarity', s.polymorphismClarity);
45
+ printSubscore('Discoverability', result.discoverability);
46
+ out('');
47
+ }
48
+ function printSubscore(label, value) {
49
+ const pct = Math.round(value * 100);
50
+ const bar = buildBar(value);
51
+ out(` ${label.padEnd(24)} ${bar} ${scoreColor(pct)(pct + '%')}`);
52
+ }
53
+ function buildBar(fraction) {
54
+ const width = 20;
55
+ const filled = Math.round(fraction * width);
56
+ return cyan('[' + '\u2588'.repeat(filled) + '\u2591'.repeat(width - filled) + ']');
57
+ }
58
+ function printRawMetricsSummary(result) {
59
+ out(bold(white(' Raw Metrics Summary')));
60
+ out('');
61
+ out(` Total operations: ${result.rawMetrics.operationCount}`);
62
+ if (result.rawMetrics.operationCount === 0) {
63
+ out('');
64
+ return;
65
+ }
66
+ const params = [];
67
+ const depths = [];
68
+ const polys = [];
69
+ const props = [];
70
+ let opsWithReqExample = 0;
71
+ let opsWithResExample = 0;
72
+ let opsWithDescription = 0;
73
+ for (const m of result.rawMetrics.operations.values()) {
74
+ params.push(m.parameterCount);
75
+ depths.push(Math.max(m.maxRequestSchemaDepth, m.maxResponseSchemaDepth));
76
+ polys.push(m.polymorphismCount);
77
+ props.push(m.totalSchemaProperties);
78
+ if (m.requestExamplePresent)
79
+ opsWithReqExample++;
80
+ if (m.responseExamplePresent)
81
+ opsWithResExample++;
82
+ if (m.operationDescriptionPresent)
83
+ opsWithDescription++;
84
+ }
85
+ const n = result.rawMetrics.operationCount;
86
+ function statLine(label, values) {
87
+ const sum = values.reduce((s, v) => s + v, 0);
88
+ const avg = (sum / n).toFixed(1);
89
+ const med = median(values).toFixed(1);
90
+ const min = Math.min(...values);
91
+ const max = Math.max(...values);
92
+ out(` ${label.padEnd(26)} avg ${avg.padStart(6)} median ${med.padStart(6)} min ${String(min).padStart(5)} max ${String(max).padStart(5)}`);
93
+ }
94
+ statLine('Parameters/operation:', params);
95
+ statLine('Schema depth:', depths);
96
+ statLine('Polymorphism/operation:', polys);
97
+ statLine('Properties/operation:', props);
98
+ out(` Operations with request examples: ${opsWithReqExample}/${n} (${fmtPct(opsWithReqExample, n)})`);
99
+ out(` Operations with response examples: ${opsWithResExample}/${n} (${fmtPct(opsWithResExample, n)})`);
100
+ out(` Operations with description: ${opsWithDescription}/${n} (${fmtPct(opsWithDescription, n)})`);
101
+ out('');
102
+ }
103
+ function fmtPct(num, denom) {
104
+ return denom > 0 ? `${Math.round((num / denom) * 100)}%` : 'N/A';
105
+ }
106
+ function printOperationDetails(result) {
107
+ out(bold(white(' Per-Operation Metrics')));
108
+ out('');
109
+ const header = ' ' +
110
+ 'Operation'.padEnd(50) +
111
+ 'Props'.padStart(7) +
112
+ 'Poly'.padStart(7) +
113
+ 'Depth'.padStart(7) +
114
+ 'Params'.padStart(8) +
115
+ 'Constr'.padStart(8);
116
+ out(cyan(header));
117
+ out(cyan(' ' + '─'.repeat(header.length - 2)));
118
+ const entries = [...result.rawMetrics.operations.entries()].sort(([, a], [, b]) => b.totalSchemaProperties - a.totalSchemaProperties);
119
+ for (const [, m] of entries) {
120
+ const label = (m.operationId ?? `${m.method.toUpperCase()} ${m.path}`).slice(0, 48);
121
+ const depth = Math.max(m.maxRequestSchemaDepth, m.maxResponseSchemaDepth);
122
+ const line = ' ' +
123
+ label.padEnd(50) +
124
+ String(m.totalSchemaProperties).padStart(7) +
125
+ String(m.polymorphismCount).padStart(7) +
126
+ String(depth).padStart(7) +
127
+ String(m.parameterCount).padStart(8) +
128
+ String(m.constraintCount).padStart(8);
129
+ out(line);
130
+ }
131
+ out('');
132
+ }
133
+ export function printDebugOperation(operationId, logs) {
134
+ out('');
135
+ out(bold(white(` Debug: ${operationId} schema breakdown`)));
136
+ out('');
137
+ if (logs.length === 0) {
138
+ out(yellow(` No schemas found for operation "${operationId}".`));
139
+ out(yellow(' Make sure the value matches an operationId or "METHOD /path" exactly.'));
140
+ out('');
141
+ return;
142
+ }
143
+ for (const log of logs) {
144
+ out(bold(cyan(` ${log.context}`)));
145
+ out(cyan(' ' + '─'.repeat(70)));
146
+ const refGroups = new Map();
147
+ for (const entry of log.entries) {
148
+ const key = entry.ref ?? `(inline depth ${entry.depth})`;
149
+ const group = refGroups.get(key);
150
+ if (group) {
151
+ group.count++;
152
+ group.totalProps += entry.propertyNames.length;
153
+ for (const n of entry.propertyNames) {
154
+ if (!group.propNames.includes(n))
155
+ group.propNames.push(n);
156
+ }
157
+ }
158
+ else {
159
+ refGroups.set(key, {
160
+ count: 1,
161
+ totalProps: entry.propertyNames.length,
162
+ propNames: [...entry.propertyNames],
163
+ });
164
+ }
165
+ }
166
+ for (const entry of log.entries) {
167
+ const label = entry.ref ?? '(inline)';
168
+ const depthPad = ' '.repeat(Math.min(entry.depth, 6));
169
+ const propCount = entry.propertyNames.length;
170
+ let line = ` ${depthPad}${label}`;
171
+ if (propCount > 0) {
172
+ line += ` (${propCount} properties)`;
173
+ }
174
+ const polyParts = [];
175
+ if (entry.polymorphism.oneOf)
176
+ polyParts.push(`oneOf:${entry.polymorphism.oneOf}`);
177
+ if (entry.polymorphism.anyOf)
178
+ polyParts.push(`anyOf:${entry.polymorphism.anyOf}`);
179
+ if (entry.polymorphism.allOf)
180
+ polyParts.push(`allOf:${entry.polymorphism.allOf}`);
181
+ if (polyParts.length > 0) {
182
+ line += ` [${polyParts.join(', ')}]`;
183
+ }
184
+ if (entry.constraintCount > 0) {
185
+ line += ` {${entry.constraintCount} constraints}`;
186
+ }
187
+ out(line);
188
+ if (propCount > 0 && propCount <= 20) {
189
+ out(` ${depthPad} properties: ${entry.propertyNames.join(', ')}`);
190
+ }
191
+ else if (propCount > 20) {
192
+ const preview = entry.propertyNames.slice(0, 15).join(', ');
193
+ out(` ${depthPad} properties: ${preview}, ... +${propCount - 15} more`);
194
+ }
195
+ }
196
+ out('');
197
+ out(` Totals: ${log.totalProperties} properties, ` +
198
+ `${log.totalPolymorphism} polymorphism items, ` +
199
+ `${log.totalConstraints} constraints, ` +
200
+ `max depth ${log.maxDepth}`);
201
+ const topRefs = [...refGroups.entries()]
202
+ .filter(([, v]) => v.totalProps > 0)
203
+ .sort(([, a], [, b]) => b.totalProps - a.totalProps)
204
+ .slice(0, 10);
205
+ if (topRefs.length > 0) {
206
+ out('');
207
+ out(bold(' Top schemas by property count:'));
208
+ for (const [ref, data] of topRefs) {
209
+ out(` ${ref}: ${data.totalProps} properties`);
210
+ }
211
+ }
212
+ out('');
213
+ }
214
+ }
215
+ function printHotspots(result) {
216
+ if (result.hotspots.length === 0) {
217
+ out(bold(white(' No hotspot operations found.')));
218
+ out('');
219
+ return;
220
+ }
221
+ out(bold(white(` Top ${result.hotspots.length} Hotspot Operations`)));
222
+ out('');
223
+ for (const hotspot of result.hotspots) {
224
+ const label = hotspot.operationId
225
+ ? `${hotspot.method.toUpperCase()} ${hotspot.path} (${hotspot.operationId})`
226
+ : `${hotspot.method.toUpperCase()} ${hotspot.path}`;
227
+ out(bold(` ${label}`));
228
+ out(` Agent Readiness: ${formatScore(hotspot.agentReadinessScore)}`);
229
+ for (const reason of hotspot.reasons) {
230
+ out(yellow(` - ${reason}`));
231
+ }
232
+ out('');
233
+ }
234
+ }
235
+ //# sourceMappingURL=stylish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stylish.js","sourceRoot":"","sources":["../../../../src/commands/score/formatters/stylish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,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EAAE,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DocumentMetrics, HotspotOperation, OperationScores, ScoringConstants } from './types.js';
2
+ export declare function selectTopHotspots(documentMetrics: DocumentMetrics, operationScores: Map<string, OperationScores>, dependencyDepths: Map<string, number>, constants?: ScoringConstants): HotspotOperation[];
3
+ //# sourceMappingURL=hotspots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hotspots.d.ts","sourceRoot":"","sources":["../../../src/commands/score/hotspots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEhB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC7C,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,SAAS,GAAE,gBAA4C,GACtD,gBAAgB,EAAE,CAyBpB"}
@@ -0,0 +1,70 @@
1
+ import { DEFAULT_SCORING_CONSTANTS } from './constants.js';
2
+ export function selectTopHotspots(documentMetrics, operationScores, dependencyDepths, constants = DEFAULT_SCORING_CONSTANTS) {
3
+ const entries = [];
4
+ for (const [key, scores] of operationScores) {
5
+ const metrics = documentMetrics.operations.get(key);
6
+ if (!metrics)
7
+ continue;
8
+ const reasons = getHotspotReasons(metrics, dependencyDepths.get(key) ?? 0, constants);
9
+ if (reasons.length === 0)
10
+ continue;
11
+ entries.push({
12
+ path: metrics.path,
13
+ method: metrics.method,
14
+ operationId: metrics.operationId,
15
+ agentReadinessScore: scores.agentReadiness,
16
+ reasons,
17
+ });
18
+ }
19
+ entries.sort((a, b) => {
20
+ if (a.reasons.length !== b.reasons.length)
21
+ return b.reasons.length - a.reasons.length;
22
+ return a.agentReadinessScore - b.agentReadinessScore;
23
+ });
24
+ return entries.slice(0, constants.hotspotLimit);
25
+ }
26
+ function getHotspotReasons(metrics, dependencyDepth, constants) {
27
+ const { thresholds } = constants;
28
+ const reasons = [];
29
+ if (metrics.parameterCount > thresholds.maxParamsGood) {
30
+ reasons.push(`High parameter count (${metrics.parameterCount})`);
31
+ }
32
+ const maxDepth = Math.max(metrics.maxRequestSchemaDepth, metrics.maxResponseSchemaDepth);
33
+ if (maxDepth > thresholds.maxDepthGood) {
34
+ reasons.push(`Deep schema nesting (depth ${maxDepth})`);
35
+ }
36
+ if (metrics.anyOfCount > 0 && !metrics.hasDiscriminator) {
37
+ reasons.push(`Polymorphism (anyOf) without discriminator (${metrics.anyOfCount} anyOf)`);
38
+ }
39
+ else if (metrics.polymorphismCount > thresholds.maxPolymorphismGood) {
40
+ reasons.push(`High polymorphism count (${metrics.polymorphismCount})`);
41
+ }
42
+ const missingReqExample = metrics.requestBodyPresent && !metrics.requestExamplePresent;
43
+ const missingResExample = !metrics.responseExamplePresent;
44
+ if (missingReqExample && missingResExample) {
45
+ reasons.push('Missing request and response examples');
46
+ }
47
+ else if (missingReqExample) {
48
+ reasons.push('Missing request body examples');
49
+ }
50
+ else if (missingResExample) {
51
+ reasons.push('Missing response examples');
52
+ }
53
+ if (metrics.totalErrorResponses > 0 && metrics.structuredErrorResponseCount === 0) {
54
+ reasons.push('No structured error responses (4xx/5xx)');
55
+ }
56
+ if (!metrics.operationDescriptionPresent) {
57
+ reasons.push('Missing operation description');
58
+ }
59
+ if (metrics.parameterCount > 0 && metrics.paramsWithDescription === 0) {
60
+ reasons.push('No parameter descriptions');
61
+ }
62
+ if (dependencyDepth > thresholds.maxDependencyDepthGood) {
63
+ reasons.push(`High dependency depth (${dependencyDepth})`);
64
+ }
65
+ if (metrics.ambiguousIdentifierCount > thresholds.maxAmbiguousGood) {
66
+ reasons.push(`Ambiguous identifiers (${metrics.ambiguousIdentifierCount})`);
67
+ }
68
+ return reasons;
69
+ }
70
+ //# sourceMappingURL=hotspots.js.map
@@ -0,0 +1 @@
1
+ {"version":3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C;SAAM,IAAI,iBAAiB,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,OAAO,CAAC,mBAAmB,GAAG,CAAC,IAAI,OAAO,CAAC,4BAA4B,KAAK,CAAC,EAAE,CAAC;QAClF,OAAO,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,OAAO,CAAC,cAAc,GAAG,CAAC,IAAI,OAAO,CAAC,qBAAqB,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,eAAe,GAAG,UAAU,CAAC,sBAAsB,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,0BAA0B,eAAe,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,CAAC,wBAAwB,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,0BAA0B,OAAO,CAAC,wBAAwB,GAAG,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type OutputFormat } from '@redocly/openapi-core';
2
+ import type { VerifyConfigOptions } from '../../types.js';
3
+ import type { CommandArgs } from '../../wrapper.js';
4
+ export type ScoreArgv = {
5
+ api?: string;
6
+ format: OutputFormat;
7
+ 'operation-details'?: boolean;
8
+ 'debug-operation-id'?: string;
9
+ } & VerifyConfigOptions;
10
+ export declare function handleScore({ argv, config, collectSpecData }: CommandArgs<ScoreArgv>): Promise<undefined>;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/score/index.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAcpD,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,mBAAmB,CAAC;AAExB,wBAAsB,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,WAAW,CAAC,SAAS,CAAC,sBA0D1F"}
@@ -0,0 +1,69 @@
1
+ import { normalizeTypes, BaseResolver, resolveDocument, detectSpec, getMajorSpecVersion, getTypes, bundle, logger, } from '@redocly/openapi-core';
2
+ import * as colors from 'colorette';
3
+ import { performance } from 'perf_hooks';
4
+ import { exitWithError } from '../../utils/error.js';
5
+ import { getFallbackApisOrExit, printExecutionTime } from '../../utils/miscellaneous.js';
6
+ import { collectMetrics } from './collect-metrics.js';
7
+ import { computeDependencyDepths } from './collectors/dependency-graph.js';
8
+ import { printScoreJson } from './formatters/json.js';
9
+ import { printDebugOperation, printScoreStylish } from './formatters/stylish.js';
10
+ import { selectTopHotspots } from './hotspots.js';
11
+ import { aggregateSubscores, computeAllOperationScores, computeDiscoverability, computeDocumentScores, } from './scoring.js';
12
+ export async function handleScore({ argv, config, collectSpecData }) {
13
+ const [{ path }] = await getFallbackApisOrExit(argv.api ? [argv.api] : [], config);
14
+ const externalRefResolver = new BaseResolver(config.resolve);
15
+ const { bundle: document } = await bundle({ config, ref: path });
16
+ collectSpecData?.(document.parsed);
17
+ const specVersion = detectSpec(document.parsed);
18
+ if (getMajorSpecVersion(specVersion) !== 'oas3') {
19
+ return exitWithError(`The score command currently supports only OpenAPI 3.x. Detected: ${specVersion}`);
20
+ }
21
+ const startedAt = performance.now();
22
+ const types = normalizeTypes(config.extendTypes(getTypes(specVersion), specVersion), config);
23
+ const resolvedRefMap = await resolveDocument({
24
+ rootDocument: document,
25
+ rootType: types.Root,
26
+ externalRefResolver,
27
+ });
28
+ const debugOpId = argv['debug-operation-id'];
29
+ // Non-default scoring constants must be passed both to collectMetrics and computeAllOperationScores.
30
+ const { metrics: rawMetrics, debugLogs } = collectMetrics({
31
+ document,
32
+ types,
33
+ resolvedRefMap,
34
+ ctx: { problems: [], specVersion, config, visitorsData: {} },
35
+ debugOperationId: debugOpId,
36
+ });
37
+ const dependencyDepths = computeDependencyDepths(rawMetrics.operations);
38
+ const operationScores = computeAllOperationScores(rawMetrics, dependencyDepths);
39
+ const discoverability = computeDiscoverability(rawMetrics.operationCount);
40
+ const { agentReadiness } = computeDocumentScores(operationScores, discoverability);
41
+ const hotspots = selectTopHotspots(rawMetrics, operationScores, dependencyDepths);
42
+ const result = {
43
+ agentReadiness,
44
+ discoverability,
45
+ subscores: aggregateSubscores(operationScores),
46
+ rawMetrics,
47
+ hotspots,
48
+ operationScores,
49
+ dependencyDepths,
50
+ };
51
+ printScore(result, path, startedAt, argv.format, !!argv['operation-details'], debugOpId ? { operationId: debugOpId, logs: debugLogs } : undefined);
52
+ }
53
+ function printScore(result, api, startedAt, format, operationDetails, debugData) {
54
+ logger.info(`Document: ${colors.magenta(api)} score:\n`);
55
+ switch (format) {
56
+ case 'json':
57
+ printScoreJson(result);
58
+ break;
59
+ case 'stylish':
60
+ default:
61
+ printScoreStylish(result, operationDetails);
62
+ break;
63
+ }
64
+ if (debugData) {
65
+ printDebugOperation(debugData.operationId, debugData.logs);
66
+ }
67
+ printExecutionTime('score', startedAt, api);
68
+ }
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/score/index.ts"],"names":[],"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MAAM,MAAM,GAAgB;QAC1B,cAAc;QACd,eAAe;QACf,SAAS,EAAE,kBAAkB,CAAC,eAAe,CAAC;QAC9C,UAAU;QACV,QAAQ;QACR,eAAe;QACf,gBAAgB;KACjB,CAAC;IAEF,UAAU,CACR,MAAM,EACN,IAAI,EACJ,SAAS,EACT,IAAI,CAAC,MAAM,EACX,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAC3B,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CACpE,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAmB,EACnB,GAAW,EACX,SAAiB,EACjB,MAAc,EACd,gBAAyB,EACzB,SAA8D;IAE9D,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEzD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,cAAc,CAAC,MAAM,CAAC,CAAC;YACvB,MAAM;QACR,KAAK,SAAS,CAAC;QACf;YACE,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;YAC5C,MAAM;IACV,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,mBAAmB,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { DocumentMetrics, OperationMetrics, OperationScores, ScoringConstants, Subscores } from './types.js';
2
+ export declare function computeOperationSubscores(metrics: OperationMetrics, dependencyDepth: number, constants?: ScoringConstants): Subscores;
3
+ export declare function computeAgentReadiness(subscores: Subscores, constants?: ScoringConstants): number;
4
+ export declare function computeAllOperationScores(documentMetrics: DocumentMetrics, dependencyDepths: Map<string, number>, constants?: ScoringConstants): Map<string, OperationScores>;
5
+ export declare function computeDiscoverability(operationCount: number, constants?: ScoringConstants): number;
6
+ export declare function computeDocumentScores(operationScores: Map<string, OperationScores>, discoverability: number, constants?: ScoringConstants): {
7
+ agentReadiness: number;
8
+ };
9
+ /** Shared by metric collection (media-type rollup) and subscore computation. */
10
+ export declare function effectivePolymorphismFromCounts(polymorphismCount: number, anyOfCount: number, anyOfMultiplier: number): number;
11
+ export declare function aggregateSubscores(operationScores: Map<string, {
12
+ subscores: Subscores;
13
+ }>): Subscores;
14
+ //# sourceMappingURL=scoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../../src/commands/score/scoring.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACV,MAAM,YAAY,CAAC;AAGpB,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gBAAgB,EACzB,eAAe,EAAE,MAAM,EACvB,SAAS,GAAE,gBAA4C,GACtD,SAAS,CA2DX;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,EACpB,SAAS,GAAE,gBAA4C,GACtD,MAAM,CAaR;AAED,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,SAAS,GAAE,gBAA4C,GACtD,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAc9B;AAED,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,SAAS,GAAE,gBAA4C,GACtD,MAAM,CAER;AAED,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC7C,eAAe,EAAE,MAAM,EACvB,SAAS,GAAE,gBAA4C,GACtD;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAgB5B;AAED,gFAAgF;AAChF,wBAAgB,+BAA+B,CAC7C,iBAAiB,EAAE,MAAM,EACzB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,GACtB,MAAM,CAGR;AAcD,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC,GACrD,SAAS,CAqCX"}
@@ -0,0 +1,136 @@
1
+ import { DEFAULT_SCORING_CONSTANTS } from './constants.js';
2
+ import { median } from './utils.js';
3
+ export function computeOperationSubscores(metrics, dependencyDepth, constants = DEFAULT_SCORING_CONSTANTS) {
4
+ const { thresholds, weights } = constants;
5
+ const parameterSimplicity = clamp01(1 - metrics.parameterCount / (thresholds.maxParamsGood * 2));
6
+ const maxDepth = Math.max(metrics.maxRequestSchemaDepth, metrics.maxResponseSchemaDepth);
7
+ const depthPenalty = maxDepth / (thresholds.maxDepthGood * 2);
8
+ const polyPenalty = effectivePolymorphism(metrics, weights.anyOfPenaltyMultiplier) /
9
+ (thresholds.maxPolymorphismGood * 3);
10
+ const schemaSimplicity = clamp01(1 - depthPenalty - polyPenalty);
11
+ const descCount = (metrics.operationDescriptionPresent ? 1 : 0) +
12
+ metrics.paramsWithDescription +
13
+ metrics.schemaPropertiesWithDescription;
14
+ const descTotal = 1 + metrics.parameterCount + metrics.totalSchemaProperties;
15
+ const documentationQuality = descTotal > 0 ? clamp01(descCount / descTotal) : 1;
16
+ const constraintClarity = metrics.totalSchemaProperties > 0
17
+ ? clamp01(metrics.constraintCount / metrics.totalSchemaProperties)
18
+ : 1;
19
+ const examplePoints = (metrics.requestExamplePresent ? 1 : 0) + (metrics.responseExamplePresent ? 1 : 0);
20
+ const exampleTotal = (metrics.requestBodyPresent ? 1 : 0) + 1;
21
+ const exampleCoverage = clamp01(examplePoints / exampleTotal);
22
+ const errorClarity = metrics.totalErrorResponses > 0
23
+ ? clamp01(metrics.structuredErrorResponseCount / metrics.totalErrorResponses)
24
+ : 1;
25
+ const dependencyClarity = clamp01(1 - dependencyDepth / (thresholds.maxDependencyDepthGood * 2));
26
+ const identifierClarity = clamp01(1 - metrics.ambiguousIdentifierCount / Math.max(thresholds.maxAmbiguousGood + 3, 1));
27
+ const polyScore = effectivePolymorphism(metrics, weights.anyOfPenaltyMultiplier);
28
+ const polymorphismClarity = polyScore === 0
29
+ ? 1
30
+ : metrics.hasDiscriminator
31
+ ? clamp01(1 - polyScore / (thresholds.maxPolymorphismGood * 4))
32
+ : clamp01(1 - polyScore / (thresholds.maxPolymorphismGood * 2));
33
+ return {
34
+ parameterSimplicity,
35
+ schemaSimplicity,
36
+ documentationQuality,
37
+ constraintClarity,
38
+ exampleCoverage,
39
+ errorClarity,
40
+ dependencyClarity,
41
+ identifierClarity,
42
+ polymorphismClarity,
43
+ };
44
+ }
45
+ export function computeAgentReadiness(subscores, constants = DEFAULT_SCORING_CONSTANTS) {
46
+ const w = constants.weights;
47
+ const raw = subscores.parameterSimplicity * w.parameterSimplicity +
48
+ subscores.schemaSimplicity * w.schemaSimplicity +
49
+ subscores.documentationQuality * w.documentationQuality +
50
+ subscores.constraintClarity * w.constraintClarity +
51
+ subscores.exampleCoverage * w.exampleCoverage +
52
+ subscores.errorClarity * w.errorClarity +
53
+ subscores.dependencyClarity * w.dependencyClarity +
54
+ subscores.identifierClarity * w.identifierClarity +
55
+ subscores.polymorphismClarity * w.polymorphismClarity;
56
+ return round(clamp01(raw) * 100);
57
+ }
58
+ export function computeAllOperationScores(documentMetrics, dependencyDepths, constants = DEFAULT_SCORING_CONSTANTS) {
59
+ const result = new Map();
60
+ for (const [key, metrics] of documentMetrics.operations) {
61
+ const depth = dependencyDepths.get(key) ?? 0;
62
+ const subscores = computeOperationSubscores(metrics, depth, constants);
63
+ result.set(key, {
64
+ agentReadiness: computeAgentReadiness(subscores, constants),
65
+ subscores,
66
+ });
67
+ }
68
+ return result;
69
+ }
70
+ export function computeDiscoverability(operationCount, constants = DEFAULT_SCORING_CONSTANTS) {
71
+ return clamp01(1 - operationCount / constants.thresholds.maxOperationsForDiscoverability);
72
+ }
73
+ export function computeDocumentScores(operationScores, discoverability, constants = DEFAULT_SCORING_CONSTANTS) {
74
+ if (operationScores.size === 0) {
75
+ return { agentReadiness: 100 };
76
+ }
77
+ const scores = [];
78
+ for (const s of operationScores.values()) {
79
+ scores.push(s.agentReadiness);
80
+ }
81
+ const w = constants.weights.discoverabilityWeight;
82
+ const discPct = discoverability * 100;
83
+ return {
84
+ agentReadiness: round(median(scores) * (1 - w) + discPct * w),
85
+ };
86
+ }
87
+ /** Shared by metric collection (media-type rollup) and subscore computation. */
88
+ export function effectivePolymorphismFromCounts(polymorphismCount, anyOfCount, anyOfMultiplier) {
89
+ const otherPoly = polymorphismCount - anyOfCount;
90
+ return otherPoly + anyOfCount * anyOfMultiplier;
91
+ }
92
+ function effectivePolymorphism(metrics, anyOfMultiplier) {
93
+ return effectivePolymorphismFromCounts(metrics.polymorphismCount, metrics.anyOfCount, anyOfMultiplier);
94
+ }
95
+ function clamp01(value) {
96
+ return Math.max(0, Math.min(1, value));
97
+ }
98
+ export function aggregateSubscores(operationScores) {
99
+ const n = operationScores.size || 1;
100
+ const result = {
101
+ parameterSimplicity: 0,
102
+ schemaSimplicity: 0,
103
+ documentationQuality: 0,
104
+ constraintClarity: 0,
105
+ exampleCoverage: 0,
106
+ errorClarity: 0,
107
+ dependencyClarity: 0,
108
+ identifierClarity: 0,
109
+ polymorphismClarity: 0,
110
+ };
111
+ for (const scores of operationScores.values()) {
112
+ result.parameterSimplicity += scores.subscores.parameterSimplicity;
113
+ result.schemaSimplicity += scores.subscores.schemaSimplicity;
114
+ result.documentationQuality += scores.subscores.documentationQuality;
115
+ result.constraintClarity += scores.subscores.constraintClarity;
116
+ result.exampleCoverage += scores.subscores.exampleCoverage;
117
+ result.errorClarity += scores.subscores.errorClarity;
118
+ result.dependencyClarity += scores.subscores.dependencyClarity;
119
+ result.identifierClarity += scores.subscores.identifierClarity;
120
+ result.polymorphismClarity += scores.subscores.polymorphismClarity;
121
+ }
122
+ result.parameterSimplicity /= n;
123
+ result.schemaSimplicity /= n;
124
+ result.documentationQuality /= n;
125
+ result.constraintClarity /= n;
126
+ result.exampleCoverage /= n;
127
+ result.errorClarity /= n;
128
+ result.dependencyClarity /= n;
129
+ result.identifierClarity /= n;
130
+ result.polymorphismClarity /= n;
131
+ return result;
132
+ }
133
+ function round(value) {
134
+ return Math.round(value * 10) / 10;
135
+ }
136
+ //# sourceMappingURL=scoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../../src/commands/score/scoring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQ3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,UAAU,yBAAyB,CACvC,OAAyB,EACzB,eAAuB,EACvB,YAA8B,yBAAyB;IAEvD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;IAE1C,MAAM,mBAAmB,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,GAAG,CAAC,UAAU,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC;IAEjG,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,QAAQ,GAAG,CAAC,UAAU,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IAC9D,MAAM,WAAW,GACf,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC;QAC9D,CAAC,UAAU,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;IACvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,CAAC,CAAC;IAEjE,MAAM,SAAS,GACb,CAAC,OAAO,CAAC,2BAA2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