chore: add generated AI component index for /next - #5079
Conversation
|
@claude review |
|
Claude finished @pomfrida's task in 1m 42s —— View job Code Review — AI Component Index
Nice, focused utility. The script is well-documented, the extraction logic is sensible, and the generated table is exactly the kind of single-file ground truth that saves an agent from re-walking ✅ The CodeQL finding is already resolvedThe "incomplete string escaping" alert is addressed by commit e3aa9df: function escapePipe(str) {
if (!str) return str
return str.replace(/\\/g, '\\\\').replace(/\|/g, '\\|')
}The order is correct — backslashes are doubled before pipes are escaped, so an input pipe doesn't get a stray-doubled backslash. Since Suggestions (non-blocking)1. AGENTS.md change is broader than the PR description suggests. The body says "one-paragraph pointer in the EDS 2.0 overview block," but the diff also rewrites the entire Conventional Commits section (removes the "scope is usually omitted" rationale, restructures the scopes list). That may be an intended sync, or it may be diff noise from the branch lacking a merge base with 2. Props referenced via a base type are silently dropped. 3. No 4. 5. Staleness. A committed generated file can drift when someone adds a component without running Things done well
No blocking issues. The escaping fix is correct; suggestions 1 (confirm AGENTS.md scope) and 2 (document/handle base-type props) are the ones I'd act on before merge. |
e3aa9df to
dd49db7
Compare
Generates documentation/AI-COMPONENT-INDEX.md listing every /next component with props, sub-components, and asChild support. Gives AI coding assistants a stable ground-truth reference instead of re-walking the source tree each session. Wired into `prebuild` so `pnpm run build` keeps it fresh; ad-hoc regeneration via `pnpm run generate:component-index`. Closes #4890
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
dd49db7 to
39cb71b
Compare
Summary
Generates
documentation/AI-COMPONENT-INDEX.md— a single-file ground-truth reference listing every/nextcomponent (name, JSDoc description, EDS-defined props, compound sub-components,asChildsupport, status). AI coding assistants can consult one file instead of re-walkingpackages/eds-core-react/src/components/next/every session.Closes #4890.
What's in the change
scripts/generate-component-index.js— Node script (usests-morph, promoted to direct devDep) that parses the top-levelnext/index.tsbarrel and extracts metadata from each component's.tsx+.types.ts. Supports--check, which regenerates in memory and exits 1 if the committed file is stale, naming the affected components.documentation/AI-COMPONENT-INDEX.md— generated output (committed, like a snapshot). 23 components today.package.json— addspnpm run generate:component-index; chains intoprebuildso a rootpnpm run buildkeeps it fresh..github/workflows/checks.yaml— runsgenerate:component-index --checkbefore the build step (prebuild would mask a stale committed file), on both PRs and pushes to main.documentationadded to the sparsecheckout_pathsso the committed file is visible in CI.AGENTS.md— one-paragraph pointer in the EDS 2.0 overview block.BUILDING_EDS_2_COMPONENTS.md,.claude/rules/eds-component.md, and the three scaffolding entry points (/new-component, Copilotnew-componentprompt, OpenCodeeds-componentagent) now direct agents to check the index before scaffolding.Design notes
documentation/AI-COMPONENT-INDEX.md(matches existing docs structure;AGENTS.mdlinks to it from the root).ts-morphAST. Skips intersected HTML attributes and React-conventional props (children,className,style,ref,key) so the props list shows the EDS API surface only. Known limitation (documented in the file): props from referenced local type aliases or union types are not expanded — no component uses those patterns today.--checkstep in the Checks workflow fails any PR that changes the/nextAPI surface without regenerating the index. Note:pnpm run build:core-reactdoes NOT regenerate (pre-hooks only fire for the exact script namebuild) — the CI gate is the enforcement, not the prebuild hook.Field.Label,Dialog.Header) detected via theCompound<Name>type alias pattern. Standalone exports likeMenuItemget their own row (not folded underMenu).forwardRefdeclaration (also tries<Name>Component/<Name>Rootfor compound components), with<Name>Propsas fallback. Only Icon has a JSDoc today; the rest fall back to—. Future improvement: add JSDoc to more component files.Review follow-up (Claude review, 24 June)
--checkgate; drift was demonstrated in practice (Dialog merged to main without an index update).Test plan
pnpm run generate:component-indexproducesdocumentation/AI-COMPONENT-INDEX.mdwith 23 components--checkexits 0 when fresh; exits 1 naming affected components when a row is removed or tampered withpnpm run lint scripts/generate-component-index.jspassesDialog.Header, Dialog.Title, Dialog.Content, Dialog.Actions; MenuItem is its own row; Button and Link showasChild ✓Check AI component index freshnessstep passes in the Checks workflow on this PR