Skip to content

feat: detect duplicate transition/animation declarations in CSS audit#70

Merged
nujovich merged 2 commits into
nujovich:mainfrom
fracergu:feat/detect-motion-transitions
Jun 18, 2026
Merged

feat: detect duplicate transition/animation declarations in CSS audit#70
nujovich merged 2 commits into
nujovich:mainfrom
fracergu:feat/detect-motion-transitions

Conversation

@fracergu

Copy link
Copy Markdown
Contributor

Summary

Add a motion audit step that scans transition and animation declarations in CSS, normalizes durations to milliseconds and easings to canonical keywords, clusters near-duplicates, and proposes semantic token scales for durations and easings.

Closes #28

Changes (7 files, +428 lines)

Types — lib/types.ts

  • Added MotionDurationSample interface (value, normalizedMs, usageCount, contexts)
  • Added MotionEasingSample interface (value, normalizedKeyword, usageCount, contexts)
  • Added MotionAudit interface (durations: { found, suggestedScale }, easings: { found, suggestedScale }, duplicateDeclarations)
  • Extended AuditReport with motion: MotionAudit
  • Extended UserDecisions with motion: { durations, easings }
  • Extended TypographyTokens with motion: { durations, easings }

Audit prompt — lib/prompts.mjs

  • buildAuditPrompt: Added STEP 5 — MOTION
    • Scans transition, transition-duration, transition-timing-function, animation-duration, animation-timing-function
    • Normalizes durations to ms (0.2s200ms)
    • Maps cubic-bezier values to canonical keywords (cubic-bezier(0.4,0,0.2,1)ease-in-out-standard)
    • Counts duplicateDeclarations (functionally identical motion declarations)
    • Suggests duration scale: instant/fast/base/slow/slower/crawl
    • Suggests easing scale: standard/emphasized/decelerate/accelerate/linear
  • Added +1 to chaos score if motion.duplicateDeclarations > 5
  • Renumbered: CHAOS SCORE → 6, SUMMARY → 7, BRAND → 8
  • Updated JSON example with motion field

Resolve prompt — lib/prompts.mjs

  • Added rules for decisions.motion.durations and decisions.motion.easings with CSS validation and fallback extraction
  • Updated DSTokens example with motion field

CLI — bin/mint-ds.mjs

  • defaultDecisions() now passes motion: { durations, easings } from audit
  • Chaos summary line now includes motion duration count

UI — components/AuditView.tsx

  • Added Motion section between Spacing and CTA
  • Duration and easing chips with usage counts
  • Suggested scale grids for durations and easings
  • Amber warning callout when duplicateDeclarations > 0
  • handleResolve now passes motion in decisions

Example — examples/frankenstein/styles.css

  • Added realistic motion CSS block (same transition written 8 different ways, mixed ms/s, keywords vs cubic-bezier, shorthand vs longhand)

Tests

  • prompts.test.mjs: Updated step count (7→8), added "motion" to JSON fields test, added duplicateDeclarations to chaos score test, new MOTION step test, new resolve prompt motion test
  • playground-cache.test.ts: Updated AUDIT, TOKENS, DECISIONS fixtures with motion field

Testing

All 98 tests pass. Typecheck and lint clean.

DeepSeek V4 Flash integration test (temporary, reverted)

Ran the full pipeline against DeepSeek V4 Flash with the frankenstein example (including the new motion CSS):

Metric Result
Audit ✅ chaos 7/10
Durations detected 14 (normalized ms/s correctly)
Easings detected 9 (canonical keywords mapped correctly)
Duplicate declarations 10
Suggested duration scale fast:150ms, base:200ms, slow:300ms, slower:500ms, crawl:1000ms
Suggested easing scale standard, emphasized, decelerate, accelerate, linear
Resolve → tokens ✅ motion.durations + motion.easings in generated tokens

All DeepSeek provider changes were reverted after testing — nothing committed.

Checklist

  • npx tsc --noEmit passes with no errors
  • npm run lint passes
  • npm test passes (98/98)
  • Tested with real CSS input through the full audit → tokens → export flow
  • No new Spanish strings — all user-facing text is English
  • No hardcoded colors or values that should be CSS variables

Add motion audit step that scans transition and animation
declarations, normalizes durations to ms and easings to
canonical keywords, clusters near-duplicates, and proposes
semantic token scales for durations and easings.

- Add MotionAudit, MotionDurationSample, MotionEasingSample
  types to lib/types.ts
- Extend AuditReport with motion field
- Extend UserDecisions with motion.durations/easings
- Extend TypographyTokens with motion.durations/easings
- Add STEP 5 (MOTION) to buildAuditPrompt with duration
  normalization, easing canonical mapping, duplicate counting,
  and suggested scales
- Add +1 to chaos score if motion.duplicateDeclarations > 5
- Renumber steps: CHAOS SCORE→6, SUMMARY→7, BRAND→8
- Update buildResolvePrompt with motion token rules
- Update defaultDecisions in CLI to pass motion from audit
- Add Motion section to AuditView with duration/easing chips,
  suggested scale grids, and duplicate warning callout
- Add realistic motion CSS to frankenstein example
- Add tests for MOTION step, chaos score, and resolve prompt

Closes nujovich#28

@nujovich nujovich left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review (harness)

Thanks for this PR — adding motion detection is a great extension to the audit pipeline. The implementation is clean and the test coverage is thorough.

Before merge, please address:

  1. Export-format parity: motion was added to DSTokens but no export generators were updated. Please verify that all 11 export targets produce clean output when motion tokens are present, and add at least one test that exercises an export target with motion data.

  2. Optional motion in types: AuditReport.motion is non-optional, but all call sites guard with ?.. Consider making it motion?: MotionAudit in the type to match runtime reality, or drop the optional chaining and initialize it to an empty default everywhere.

Minor: the frankenstein example CSS has Spanish comments (consistent with the file's existing voice, so not blocking). The README table and pipeline diagram should be updated to mention the new motion dimension.

See the full review draft for line-level findings.

Comment thread lib/types.ts
Comment thread examples/frankenstein/styles.css
…update

- Make AuditReport.motion optional (motion?: MotionAudit) to match
  runtime usage with optional chaining at all call sites
- Add motion token instructions to all 13 export prompt templates
  so LLM-generated exports include transition/easing tokens
- Add test verifying export prompt includes motion data when present
- Update README: audit step mentions motion detection, add Motion row
  to the 'What Mint sees' table
@nujovich nujovich merged commit 5f87694 into nujovich:main Jun 18, 2026
1 check passed
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.

[Feature]: Detect duplicate transition / animation declarations

2 participants