Skip to content

[Do Not Merge]feat(docs): add docs.llm.md MVP generator for 1st-gen components - #6396

Open
blunteshwar wants to merge 10 commits into
mainfrom
MVP-gen1-llm
Open

blunteshwar wants to merge 10 commits into
mainfrom
MVP-gen1-llm

Conversation

@blunteshwar

Copy link
Copy Markdown
Contributor

Description

Ships the end-to-end MVP slice from the docs.llm.md RFC (SWC-2277): a deterministic generator that derives an LLM-consumable markdown file from each 1st-gen component README, plus generated output for the 5 MVP components.

The generator is script-only — no LLM in the loop. Same input always yields the same output, so files can be regenerated and diffed in CI to detect drift from the README.

What it does

Reads 1st-gen/packages/<name>/README.md, applies deterministic chrome-stripping, and writes 1st-gen/packages/<name>/docs.llm.md:

  1. Drop NPM / Bundlephobia / Stackblitz shield badge lines
  2. Drop <sp-tabs> / <sp-tab> / <sp-tab-panel> Storybook wrappers (inner demos kept)
  3. Normalize live-demo fences (```html demo, demo ignore, demo open) to plain ```html
  4. Collapse 3+ blank-line runs, trim

It prepends a small metadata frontmatter block: component, tag (derived from the README side-effect import), package, source, generated (ISO timestamp), generator.

New scripts

  • yarn generate:llm-docs — write docs.llm.md (all MVP components, or pass specific names)
  • yarn generate:llm-docs:check — drift gate for CI; timestamp-insensitive, exits non-zero when on-disk files are stale

Motivation and context

The RFC (wiki 3854270520) proposes shipping one LLM-friendly markdown file per component, derived mechanically from the existing documentation source of truth (README for 1st-gen). This PR proves the pipeline end-to-end on a 5-component slice before committing to the full generator + 69-component backfill, de-risking the RFC's architectural choices against real output.

Related issue(s)

  • SWC-2277 (MVP), epic SWC-2203

MVP components

button, picker, menu, action-button, dialog — chosen to stress different generator edge cases: simple, near-duplicate, slotted, composition-heavy, and overlay + a11y-heavy.

Scope note for reviewers

This deterministic transform produces chrome-stripped README + frontmatter. It does not synthesize the richer curated format (When-NOT-to-use, Common-LLM-mistakes, S1→S2 tables) seen in earlier hand-authored examples — that content cannot be derived from a README alone. Extracting structured frontmatter (sizes/variants/slots) is a deliberate follow-up if the RFC wants it. The full generator (SWC-2204) must later produce byte-equivalent output to these files (modulo timestamp).

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed the Accessibility Practices for this feature.
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Manual review test cases

  • Generator produces expected output

    1. Run yarn generate:llm-docs
    2. Expect 5 docs.llm.md files written under 1st-gen/packages/{button,picker,menu,action-button,dialog}/
    3. Confirm no <sp-tab, html demo, or img.shields.io residue remains
  • Drift gate works

    1. Edit one component README, then run yarn generate:llm-docs:check
    2. Expect non-zero exit with a DRIFT message
    3. Run yarn generate:llm-docs, re-run check, expect "up to date"

Accessibility testing checklist

  • Keyboard (required)

    • No focusable parts: this PR adds a build-time generator script and generated markdown files only. No runtime component or DOM is introduced. Confirm no regressions in surrounding examples.
  • Screen reader (required)

    • Not applicable to generated markdown / build tooling. No roles, names, or live regions are added to any shipped component.

🤖 Generated with Claude Code

Ship the end-to-end MVP slice from the docs.llm.md RFC (SWC-2277): a
deterministic generator that derives an LLM-consumable markdown file from
each 1st-gen component README, plus generated output for the 5 MVP
components (button, picker, menu, action-button, dialog).

The transform is script-only (no LLM in the loop). It strips Storybook and
docs-site chrome from the README — shield badges, sp-tabs/sp-tab/sp-tab-panel
wrappers, `demo` code-fence modifiers — collapses blank-line runs, and
prepends a small metadata frontmatter block (component, tag, package, source,
generated timestamp, generator). Same input always yields the same output, so
files can be regenerated and diffed in CI to detect drift from the README.

New scripts:
- yarn generate:llm-docs        write docs.llm.md (all MVP, or named components)
- yarn generate:llm-docs:check  drift gate for CI (timestamp-insensitive)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@blunteshwar
blunteshwar requested a review from a team as a code owner June 11, 2026 15:22
@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ca50869

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

This PR includes changesets to release 84 packages
Name Type
@spectrum-web-components/llm-docs Minor
@spectrum-web-components/accordion Minor
@spectrum-web-components/action-bar Minor
@spectrum-web-components/action-button Minor
@spectrum-web-components/action-group Minor
@spectrum-web-components/action-menu Minor
@spectrum-web-components/alert-banner Minor
@spectrum-web-components/alert-dialog Minor
@spectrum-web-components/asset Minor
@spectrum-web-components/avatar Minor
@spectrum-web-components/badge Minor
@spectrum-web-components/breadcrumbs Minor
@spectrum-web-components/button-group Minor
@spectrum-web-components/button Minor
@spectrum-web-components/card Minor
@spectrum-web-components/checkbox Minor
@spectrum-web-components/clear-button Minor
@spectrum-web-components/close-button Minor
@spectrum-web-components/coachmark Minor
@spectrum-web-components/color-area Minor
@spectrum-web-components/color-field Minor
@spectrum-web-components/color-handle Minor
@spectrum-web-components/color-loupe Minor
@spectrum-web-components/color-slider Minor
@spectrum-web-components/color-wheel Minor
@spectrum-web-components/combobox Minor
@spectrum-web-components/contextual-help Minor
@spectrum-web-components/dialog Minor
@spectrum-web-components/divider Minor
@spectrum-web-components/dropzone Minor
@spectrum-web-components/field-group Minor
@spectrum-web-components/field-label Minor
@spectrum-web-components/help-text Minor
@spectrum-web-components/icon Minor
@spectrum-web-components/icons-ui Minor
@spectrum-web-components/icons-workflow Minor
@spectrum-web-components/icons Minor
@spectrum-web-components/iconset Minor
@spectrum-web-components/illustrated-message Minor
@spectrum-web-components/infield-button Minor
@spectrum-web-components/link Minor
@spectrum-web-components/menu Minor
@spectrum-web-components/meter Minor
@spectrum-web-components/modal Minor
@spectrum-web-components/number-field Minor
@spectrum-web-components/overlay Minor
@spectrum-web-components/picker-button Minor
@spectrum-web-components/picker Minor
@spectrum-web-components/popover Minor
@spectrum-web-components/progress-bar Minor
@spectrum-web-components/progress-circle Minor
@spectrum-web-components/radio Minor
@spectrum-web-components/search Minor
@spectrum-web-components/sidenav Minor
@spectrum-web-components/slider Minor
@spectrum-web-components/split-view Minor
@spectrum-web-components/status-light Minor
@spectrum-web-components/swatch Minor
@spectrum-web-components/switch Minor
@spectrum-web-components/table Minor
@spectrum-web-components/tabs Minor
@spectrum-web-components/tags Minor
@spectrum-web-components/textfield Minor
@spectrum-web-components/thumbnail Minor
@spectrum-web-components/toast Minor
@spectrum-web-components/tooltip Minor
@spectrum-web-components/top-nav Minor
@spectrum-web-components/tray Minor
@spectrum-web-components/underlay Minor
@spectrum-web-components/custom-vars-viewer Minor
@spectrum-web-components/story-decorator Minor
@spectrum-web-components/vrt-compare Minor
@spectrum-web-components/base Minor
@spectrum-web-components/bundle Minor
@spectrum-web-components/grid Minor
@spectrum-web-components/opacity-checkerboard Minor
@spectrum-web-components/reactive-controllers Minor
@spectrum-web-components/shared Minor
@spectrum-web-components/styles Minor
@spectrum-web-components/theme Minor
@spectrum-web-components/truncated Minor
@spectrum-web-components/eslint-plugin Minor
@spectrum-web-components/stylelint-header-plugin Minor
documentation Patch

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

@blunteshwar
blunteshwar marked this pull request as draft June 11, 2026 15:25
@blunteshwar blunteshwar changed the title feat(docs): add docs.llm.md MVP generator for 1st-gen components [Do Not Merge]feat(docs): add docs.llm.md MVP generator for 1st-gen components Jun 11, 2026
@pfulton pfulton added the do-not-merge NO MERGE-Y! label Jun 12, 2026
@blunteshwar
blunteshwar marked this pull request as ready for review June 17, 2026 10:37
blunteshwar and others added 8 commits June 17, 2026 16:21
…docs package

Extend the docs.llm.md generator from the 5-component MVP to every Spectrum 1
component, and add the optional aggregate package that bundles them.

Generator changes (scripts/generate-llm-docs.mjs):
- Auto-discover components: any 1st-gen package whose README registers a
  custom element via a `@spectrum-web-components/{name}/sp-*.js` side-effect
  import. Icon-set and tooling packages are skipped. 62 components found.
- Default run now generates the full set; `--mvp` restricts to the original 5
  and named arguments still scope to specific components.
- Each component is written from one generated string to two locations so they
  stay byte-identical: the per-component `docs.llm.md` beside the README and the
  aggregate `{component}.llm.md` in the new package.
- `--check` verifies both copies and the aggregate README, ignoring the
  generated timestamp.

New package (@spectrum-web-components/llm-docs):
- Lives at 1st-gen/projects/llm-docs so yarn constraints does not treat it as a
  component workspace (which would force a src entry point). It is still a
  published workspace via the @spectrum-web-components/* fixed changeset group.
- Ships one {component}.llm.md per component plus a generated index README.
- Optional install for AI assistants and build-time tools that want the docs as
  plain markdown, kept out of the per-component tarballs to keep them lean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…utput

Two issues surfaced when scaling the generator to all 62 gen1 components:

- The chrome-stripping rules ran on every line, including inside fenced code
  blocks. For most components `<sp-tabs>` / `<sp-tab>` / `<sp-tab-panel>` are
  Storybook layout chrome, but for the Tabs component itself they are the literal
  example markup, so its demos were gutted to empty code fences. Chrome rules now
  run only outside fenced code blocks; fenced content is preserved verbatim. Any
  block left empty after stripping is dropped.

- Generated markdown is a build artifact, but Prettier reformatted it on commit,
  which broke `yarn generate:llm-docs:check`. The per-component `docs.llm.md`,
  the aggregate `*.llm.md`, and the aggregate README are now in .prettierignore,
  so the generator output stays canonical and the drift check is authoritative.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a `lint:llm-docs` step that runs the generator's `--check` drift gate, and
include it in the root `lint` chain. CI now fails when a component README has
changed without its `docs.llm.md` and aggregate copy being regenerated, keeping
the source of truth and the generated files in sync.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Keep package.json and README.md visible at the llm-docs package root instead of
burying them among 62 markdown files. The aggregate `{component}.llm.md` files
now live in 1st-gen/projects/llm-docs/src/; the generated index README links
into src/ and the package `files` field publishes src/*.llm.md. The
per-component docs.llm.md beside each README is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a skill that grounds UI work in the @spectrum-web-components/llm-docs
package. On invocation it ensures the docs are available (already installed, the
local monorepo copy, or a fresh devDependency install via the detected package
manager), reads the authoritative per-component docs, and builds with Spectrum
Web Components only, using real tags, imports, attributes, and variant values
instead of guessed ones.

- SKILL.md: mindset, when/when-not, the ensure -> read -> build -> verify
  workflow, fallbacks (docs-site mirror, component README) for when the package
  cannot be installed, and a common-name to component lookup table.
- scripts/ensure-llm-docs.mjs: resolves the docs directory (node_modules, then
  monorepo, then install), lists documented components, and prints the path to
  requested component docs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…utput

The `generated:` ISO timestamp in each file's frontmatter changed on every run,
so regenerating produced a 124-file diff of pure noise and the `--check` gate had
to special-case it. Remove the timestamp: generation is now fully deterministic,
the same README always yields byte-identical output, regenerations stay out of
the git diff, and the drift check is a plain equality test. Provenance is still
captured by `source:` and `generator:` in the frontmatter and by git history.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a skill that grounds UI work in the @spectrum-web-components/llm-docs
package. On invocation it ensures the docs are available (already installed, the
local monorepo copy, or a fresh devDependency install via the detected package
manager), reads the authoritative per-component docs, and builds with Spectrum
Web Components only, using real tags, imports, attributes, and variant values
instead of guessed ones.

- SKILL.md: mindset, when/when-not, the ensure -> read -> build -> verify
  workflow, fallbacks (docs-site mirror, component README) for when the package
  cannot be installed, and a common-name to component lookup table.
- scripts/ensure-llm-docs.mjs: resolves the docs directory (node_modules, then
  monorepo, then install), lists documented components, and prints the path to
  requested component docs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Annotate generate-llm-docs.mjs and the skill's ensure-llm-docs.mjs line by line
so the chrome-stripping rules, fence handling, drift check, package-manager
detection, and docs resolution are self-explanatory. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge NO MERGE-Y!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants