Conversation
🦋 Changeset detectedLatest commit: 92d40f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
- Add "AI" before "agent readiness" in changeset and docs for clarity - Replace <pre> block with fenced code block in score.md - Add security scheme coverage to metrics documentation - Remove resolveIfRef helper, replace with resolveNode that falls back to the original node when resolution fails - Refactor to use walkDocument visitor approach (matching stats command pattern) instead of manually iterating the document tree - Use resolveDocument + normalizeVisitors + walkDocument from openapi-core for proper $ref resolution and spec-format extensibility - Update index.test.ts to mock the new walk infrastructure Made-with: Cursor
79078d6 to
0e328aa
Compare
Co-authored-by: Jacek Łękawa <164185257+JLekawa@users.noreply.github.com>
tatomyr
left a comment
There was a problem hiding this comment.
Left a couple of comments. I haven'd fully reviewed the scoring and collectors though as it takes time.
packages/cli/src/commands/score/__tests__/document-metrics.test.ts
Outdated
Show resolved
Hide resolved
tatomyr
left a comment
There was a problem hiding this comment.
I found some dead code. Please check if it's needed and remove if not. Also, I'm not sure what tests to review as many appear to only test that dead code, so let's handle that first.
| @@ -0,0 +1,82 @@ | |||
| import { | |||
There was a problem hiding this comment.
Is it code or tests? It code, then it should be outside the __tests__ folder.
There was a problem hiding this comment.
This code doesn't seems to be used anywhere except in tests. Please consider removing it and the tests.
| } | ||
|
|
||
| export function resetSchemaWalkState(s: SchemaWalkState): void { | ||
| s.depth = -1; |
There was a problem hiding this comment.
What does the negative depth mean?
| import { parseYaml } from '@redocly/openapi-core'; | ||
| import { outdent } from 'outdent'; | ||
|
|
||
| import { collectDocumentMetrics } from './collect-metrics.js'; | ||
|
|
||
| function yaml(source: string): Record<string, unknown> { | ||
| return parseYaml(source) as Record<string, unknown>; | ||
| } |
There was a problem hiding this comment.
| import { parseYaml } from '@redocly/openapi-core'; | |
| import { outdent } from 'outdent'; | |
| import { collectDocumentMetrics } from './collect-metrics.js'; | |
| function yaml(source: string): Record<string, unknown> { | |
| return parseYaml(source) as Record<string, unknown>; | |
| } | |
| import { parseYaml as yaml } from '@redocly/openapi-core'; | |
| import { outdent } from 'outdent'; | |
| import { collectDocumentMetrics } from './collect-metrics.js'; |
No need in this wrapper.
| workflowDepths: new Map(), | ||
| }; | ||
|
|
||
| function getStylishOutput(result: ScoreResult = RESULT): string { |
There was a problem hiding this comment.
It's a bad pattern to use default parameters in tests. They should be as explicit as possible.
What/Why/How?
What: Adds a new score command to Redocly CLI that analyzes OpenAPI 3.x descriptions and produces two composite scores: Integration Simplicity (0-100, how easy is this API to integrate) and Agent Readiness (0-100, how usable is this API by AI agents/LLM tooling).
Why: API producers currently lack a quick, deterministic way to assess how developer-friendly or AI-agent-friendly their API descriptions are. The existing stats command counts structural elements but doesn't evaluate quality signals like documentation coverage, example presence, schema complexity, or error response structure. This command fills that gap with actionable, explainable scores.
How: The implementation follows the same pattern as the
statscommand (bundle+analyze), with a clean separation between metric collection and score calculation:collectors/): Walks the bundled document, resolving internal $refs, to gather per-operation raw metrics (parameter counts, schema depth, polymorphism, description/constraint/example coverage, structured error responses, workflow dependency depth via shared schema refs).scoring.ts): Pure functions that normalize raw metrics into subscores and compute weighted composite scores. Thresholds and weights are configurable constants. anyOf is penalized more heavily than oneOf/allOf; discriminator presence improves the agent readiness polymorphism clarity subscore.hotspots.ts): Identifies the operations with the most issues, sorted by number of reasons, with human-readable explanations.--format=stylish(default, with color bar charts) and--format=json(machine-readable for CI/dashboards).Reference
Related to API governance and developer experience tooling. No existing issue -- this is a new feature.
Testing
$refresolution, polymorphism counting (oneOf/anyOf/allOf), constraint detection (including const), example coverage scoring,anyOfpenalty multiplier,discriminatorimpact on agent readiness, deterministic output, and score range validation.tsc --noEmit), all existing tests continue to pass.Screenshots (optional)
Stylish output for Redocly Cafe:
Check yourself
Security