Skip to content

feat: 🚧 machine-readable component contracts (twins) generated from source - #5167

Draft
sorensensig wants to merge 6 commits into
digdir:test-ai-registryfrom
sorensensig:feat/ai-twin-generator
Draft

feat: 🚧 machine-readable component contracts (twins) generated from source#5167
sorensensig wants to merge 6 commits into
digdir:test-ai-registryfrom
sorensensig:feat/ai-twin-generator

Conversation

@sorensensig

@sorensensig sorensensig commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

First PR of the stack proposed in #5166 (AI-readiness). It adds:

  • scripts/generate-twins.mjs and a pnpm generate:twins script
  • one JSON contract ("twin") per documented component export: real import name, emitted class and data attributes, design tokens, JSDoc summary
  • an llms.txt index so agents can discover every contract from one file
  • a JSDoc block on the Suggestion export, the only documented component that was missing one
  • 90 component twins generate from today's source

The generator only writes down what it can read from the source code, so re-running it always matches the code. Rules that live only in the documentation (accessibility, composition, when to use what) are left empty on purpose: the generator never guesses them. They arrive in the next PR of the stack, where every such rule is backed by a verbatim quote from the docs.

Design note: this PR adds registry to .gitignore on purpose. The twins are derived output, like a build artifact: committing them would let them drift from the source they are generated from, and would add ~90 JSON files of churn to every component PR. The plan in the stack is to generate them at docs-site build time (the llms.txt PR). What does need review, the authored rules, arrives as committed source data in the next PR. Say so if repo convention prefers committed artifacts and we will flip it.

🚧 Draft on purpose: opened early per CONTRIBUTING's suggestion so the work is visible; not ready for merge until the stack's shape is agreed on #5166.

Checks

  • I have read the contribution guidelines
  • I have added a changeset (run pnpm changeset if relevant): not relevant, repo scripts and one JSDoc comment only

🤖 Generated with Claude Code

Adds scripts/generate-twins.mjs: one JSON contract per documented component
export (real import name, emitted class and data attributes, design tokens,
JSDoc summary), plus an llms.txt index for agent discovery. Extracted fields
regenerate from source and cannot drift; documentation-prose fields (a11y,
composition, relations) are stubbed as authored, never invented.

Output (./registry) is gitignored pending a decision on committed-vs-build-time
generation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: edea3a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

…gistry

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mimarz
mimarz changed the base branch from main to test-ai-registry August 13, 2026 12:00
sorensensig and others added 3 commits August 13, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant