build script for rules - single source of truth#204
Open
build script for rules - single source of truth#204
Conversation
- Refactor PROSE in event-trigger-rule.mjs: base + overrides pattern eliminates duplication, unifies minor wording inconsistencies - Move fillGuidance/compositeOperations prose from effects.yaml into full-lean.mjs (YAML for structured data, not prose) - Unify render() signature to (data, fragments) across all templates - Import capitalize helper in full-lean.mjs instead of inlining - Add --check flag to build-rules.mjs for CI freshness verification without modifying the working tree - Remove unused aliasOf entries from triggers.yaml - Add _content/fragments/ to .prettierignore (section markers are build pipeline syntax) - Apply Prettier formatting to all source files Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a build pipeline for
packages/interact/rules/that replaces manually-maintained markdown rule files with a structured source layer — YAML data + markdown fragments + JavaScript templates — eliminating content duplication and establishing a single source of truth.Architecture
Three source layers feed the build:
_content/data/) — YAML definitions for all 9 triggers (field names pulled from actual TS types), effect metadata (presets, easings, ranges, composites), and package metadata._content/fragments/) — ~12 reusable markdown fragments (FOUC prevention, element resolution, pitfalls, quick-start, etc.) with<!-- #section -->markers for granular inclusion at different detail levels._content/templates/) —.mjsfiles exportingrender()functions that receive data + fragments and return complete markdown strings. One template per output file (or trigger family).The build script (
scripts/build-rules.mjs) loads YAML, parses fragment sections, calls each template, and writes the 7 output.mdfiles torules/.Output files
event-trigger-rule.mjsclick.md,hover.mdviewenter-rule.mjsviewenter.mdviewprogress-rule.mjsviewprogress.mdpointermove-rule.mjspointermove.mdfull-lean.mjsfull-lean.mdintegration.mjsintegration.mdTypo fixes included
These existing issues are fixed as a natural consequence of single-source templating:
[EFFECT_DEFINTION]→[EFFECT_DEFINITION]in click/hover/viewenter sequence blockshitAea→hitAreain pointermove.md centering sectionUsage
Checklist
Additional Notes
js-yamlas a devDependency (already available as transitive dep)build:rulesscript topackage.jsonrules/*.mdfiles are committed so the npm package always includes them; CI can verify freshness withbuild:rules && git diff --exit-code rules/