trdr-ds-install 1.9.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +1 -1
  2. package/plugins/trdr-design-system/skills/trdr-ds/SKILL.md +168 -2914
  3. package/plugins/trdr-design-system/skills/trdr-ds/data/components/abas.json +36 -0
  4. package/plugins/trdr-design-system/skills/trdr-ds/data/components/badge.json +139 -0
  5. package/plugins/trdr-design-system/skills/trdr-ds/data/components/boleta.json +121 -0
  6. package/plugins/trdr-design-system/skills/trdr-ds/data/components/button.json +166 -0
  7. package/plugins/trdr-design-system/skills/trdr-ds/data/components/card.json +55 -0
  8. package/plugins/trdr-design-system/skills/trdr-ds/data/components/checkbox.json +82 -0
  9. package/plugins/trdr-design-system/skills/trdr-ds/data/components/combo-input.json +79 -0
  10. package/plugins/trdr-design-system/skills/trdr-ds/data/components/copy-button.json +88 -0
  11. package/plugins/trdr-design-system/skills/trdr-ds/data/components/dropdown.json +94 -0
  12. package/plugins/trdr-design-system/skills/trdr-ds/data/components/floating-menu.json +151 -0
  13. package/plugins/trdr-design-system/skills/trdr-ds/data/components/header.json +141 -0
  14. package/plugins/trdr-design-system/skills/trdr-ds/data/components/janela.json +245 -0
  15. package/plugins/trdr-design-system/skills/trdr-ds/data/components/news-card.json +124 -0
  16. package/plugins/trdr-design-system/skills/trdr-ds/data/components/radio-button.json +97 -0
  17. package/plugins/trdr-design-system/skills/trdr-ds/data/components/search-input.json +69 -0
  18. package/plugins/trdr-design-system/skills/trdr-ds/data/components/segmented-control.json +60 -0
  19. package/plugins/trdr-design-system/skills/trdr-ds/data/components/sidebar.json +109 -0
  20. package/plugins/trdr-design-system/skills/trdr-ds/data/components/stat-card.json +90 -0
  21. package/plugins/trdr-design-system/skills/trdr-ds/data/components/sub-menu-item.json +45 -0
  22. package/plugins/trdr-design-system/skills/trdr-ds/data/components/switch.json +89 -0
  23. package/plugins/trdr-design-system/skills/trdr-ds/data/components/tabela-cotacoes.json +91 -0
  24. package/plugins/trdr-design-system/skills/trdr-ds/data/components/tabela-ordens.json +81 -0
  25. package/plugins/trdr-design-system/skills/trdr-ds/data/components/table.json +119 -0
  26. package/plugins/trdr-design-system/skills/trdr-ds/data/components/text-input.json +159 -0
  27. package/plugins/trdr-design-system/skills/trdr-ds/data/components/tooltip.json +88 -0
  28. package/plugins/trdr-design-system/skills/trdr-ds/data/index.json +262 -0
  29. package/plugins/trdr-design-system/skills/trdr-ds/data/mappings.json +183 -0
  30. package/plugins/trdr-design-system/skills/trdr-ds/modes/report.md +139 -0
  31. package/plugins/trdr-design-system/skills/trdr-ds/modes/resume.md +46 -0
  32. package/plugins/trdr-design-system/skills/trdr-ds/modes/rollback.md +55 -0
  33. package/plugins/trdr-design-system/skills/trdr-ds/modes/status.md +37 -0
  34. package/plugins/trdr-design-system/skills/trdr-ds/modes/sync.md +48 -0
  35. package/plugins/trdr-design-system/skills/trdr-ds/phases/analyze.md +305 -0
  36. package/plugins/trdr-design-system/skills/trdr-ds/phases/components.md +204 -0
  37. package/plugins/trdr-design-system/skills/trdr-ds/phases/final.md +209 -0
  38. package/plugins/trdr-design-system/skills/trdr-ds/phases/foundation.md +195 -0
  39. package/plugins/trdr-design-system/skills/trdr-ds/phases/violations.md +183 -0
  40. package/plugins/trdr-design-system/skills/trdr-ds/templates/claude-md.md +88 -0
  41. package/plugins/trdr-design-system/skills/trdr-ds/templates/ds-analysis.md +88 -0
  42. package/plugins/trdr-design-system/skills/trdr-ds/templates/ds-migration.md +59 -0
  43. package/plugins/trdr-design-system/skills/trdr-ds/templates/ds-progress.md +57 -0
  44. package/plugins/trdr-design-system/skills/trdr-ds/templates/sprint-plan.md +68 -0
@@ -2,3001 +2,257 @@
2
2
  name: trdr-ds
3
3
  description: Applies the TRDR Design System to any project. Runs a multi-phase workflow - first analyzes the project and saves DS_ANALYSIS.md, then executes implementation in 4 checkpointed sub-phases (Foundation → Violations → Components → Final), each saving progress to DS_PROGRESS.md and resumable at any time. Trigger when developer mentions "apply design system", "implement TRDR DS", "add TRDR tokens", "design system setup", "migrar design system", "aplicar design system", or invokes /trdr-ds.
4
4
  user-invocable: true
5
- argument-hint: "[analyze|apply|foundation|violations|components|final|resume|status|sync|batch N|rollback]"
5
+ argument-hint: "[analyze|apply|foundation|violations|components|final|resume|status|sync|batch N|rollback|report]"
6
6
  allowed-tools: [Read, Glob, Grep, Edit, Write, Bash, WebFetch]
7
7
  ---
8
8
 
9
- **Skill version:** 1.9.0
9
+ **Skill version:** 2.0.0
10
10
  **npm package:** trdr-ds-install
11
11
 
12
- You are implementing the **TRDR Design System** in a developer's project. The Design Hub is the single source of truth and lives at **https://trdr.mrocontent.com.br**.
12
+ # TRDR Design System Skill Router
13
13
 
14
- This skill ships with two **offline-first snapshots** of the Hub:
14
+ You are implementing the **TRDR Design System** in a developer's project. The Design Hub is the single source of truth: **https://trdr.mrocontent.com.br**.
15
15
 
16
- - `references/tokens.css`all TRDR CSS variables (dark + light mode), copied verbatim from the Hub
17
- - `data/components.json` — full component catalog (implemented + stubs), with code blocks for everything `implemented: true` and `dependencies` array listing sub-component slugs used by compound components
16
+ ## ArchitectureProgressive Loading
18
17
 
19
- The snapshots are kept in sync by the skill's maintainer via `npm run sync` in the `trdr-plugins` repo. **Always prefer the local snapshot.** Only fetch from the Hub when the user explicitly asks for the latest (`--latest` argument or `sync` mode).
18
+ This skill is split into multiple files to prevent context overload. **NEVER read all files at once.** Load ONLY the file needed for the current step.
20
19
 
21
- Execute in multiple checkpointed phases: **PHASE 1: ANALYZE (saves DS_ANALYSIS.md) → PHASE 2: EXECUTE in 4 sub-phases (only after approval)**. Each sub-phase reads from saved files and stops for confirmation — preventing context overload and hallucinations.
22
-
23
- ---
24
-
25
- ## Argument behaviour
26
-
27
- | Arg | Behaviour |
28
- |-----|-----------|
29
- | `analyze` *(default when none given)* | Run Phase 1 only — scan project, save `DS_ANALYSIS.md` + `SPRINT_PLAN.md`, present plan. Do not modify any project file |
30
- | `apply` | Run Phase 1 + Phase 2 (all 4 sub-phases, with STOP between each) |
31
- | `foundation` | Run Sub-fase A only — create tokens.css, components.css, CLAUDE.md, @imports. Requires DS_ANALYSIS.md |
32
- | `violations` | Run Sub-fase B only — process next pending violation batch. Requires DS_ANALYSIS.md + DS_PROGRESS.md |
33
- | `components` | Run Sub-fase C only — apply DS component classes. Requires DS_ANALYSIS.md + DS_PROGRESS.md |
34
- | `final` | Run Sub-fase D only — fix logos + generate DS_MIGRATION.md. Requires DS_PROGRESS.md |
35
- | `resume` | Read `SPRINT_PLAN.md` + `DS_PROGRESS.md`, find the next pending sprint, and execute it. Designed for use after `/clear` or in a new conversation — each sprint is self-contained |
36
- | `status` | Read `SPRINT_PLAN.md` + `DS_PROGRESS.md` and display sprint progress table — no files modified |
37
- | `batch [N]` | Override default violation batch size (default: 5 files/batch) |
38
- | `sync` | Re-fetch `https://trdr.mrocontent.com.br/components.json` and `https://trdr.mrocontent.com.br/tokens.css`, overwrite `data/components.json` and `references/tokens.css` in the skill directory, report the diff. No project changes. |
39
- | `rollback` | Read `DS_PROGRESS.md` to find the backup branch, reset working branch to that state, remove DS artifacts. Requires `DS_PROGRESS.md` with a `Backup branch:` entry |
40
- | `--latest` *(modifier on `analyze` or `apply`)* | Same as `sync` first, then continue normally |
41
-
42
- ---
43
-
44
- ## PHASE 1: ANALYSIS (default behaviour on invocation)
45
-
46
- Scan the project and produce a structured migration plan. Do NOT modify any project files yet.
47
-
48
- ### Step 0 — Check for skill updates, then detect previous progress
49
-
50
- **Version check (runs on every invocation):**
51
-
52
- Run this command silently via Bash:
53
- ```bash
54
- npm show trdr-ds-install version 2>/dev/null
55
- ```
56
-
57
- Compare the result with the **Skill version** constant at the top of this file.
58
-
59
- - If the command fails or returns empty (no internet / npm unavailable): skip silently, continue.
60
- - If registry version == local version: skip silently, continue.
61
- - If registry version > local version:
62
- ```
63
- 🔄 Nova versão da skill disponível: trdr-ds-install@[registry-version] (instalada: 1.9.0)
64
-
65
- Responda:
66
- - `"atualizar"` / `"update"` — instalar a nova versão agora (requer reiniciar /trdr-ds após)
67
- - `"continuar"` / `"skip"` — usar a versão atual desta sessão
68
- ```
69
- **STOP.** Wait for reply.
70
-
71
- If reply is `"atualizar"` / `"update"`:
72
- - Run Bash: `npx trdr-ds-install@latest`
73
- - Output:
74
- ```
75
- ✅ Skill atualizada para trdr-ds-install@[registry-version].
76
- Use /trdr-ds novamente para continuar com a versão mais recente.
77
- ```
78
- - STOP. Do not continue with the current (old) instructions.
79
-
80
- **After version check, detect previous progress:**
81
-
82
- Check if `DS_PROGRESS.md` exists at the project root.
83
-
84
- **If found AND `Status:` line is NOT `COMPLETE`:**
85
- ```
86
- ⚠️ Previous TRDR DS migration found (status: [IN_PROGRESS/PAUSED]).
87
-
88
- Reply with:
89
- - `"resume"` — continue from last checkpoint (Batch [N])
90
- - `"restart"` — discard progress and run a fresh analysis
91
- - `"status"` — see a progress summary without modifying anything
92
- ```
93
- **STOP HERE. Wait for the developer's reply.**
94
-
95
- **If found AND `Status: COMPLETE`:**
96
- Inform the dev that a previous migration was already completed (show date). Offer to re-run analysis to detect new files added since then. Continue only if the dev explicitly says so.
97
-
98
- **If not found:** Continue normally to Step 1.
99
-
100
- ### Step 1 — Detect framework and styling mode
101
-
102
- Read `package.json` at the project root. Identify:
103
- - Framework: Next.js (version), React (CRA/Vite), Vue/Nuxt, plain HTML, other
104
- - Language: TypeScript or JavaScript
105
- - Styling: CSS Modules, Tailwind, CSS-in-JS, plain CSS, SCSS
106
-
107
- **Determine `stylingMode`** — used in Steps 5, 6, 6.6 and 6.7 to generate the correct syntax for each framework:
108
-
109
- | stylingMode | Detection | How DS classes are applied |
110
- |-------------|-----------|---------------------------|
111
- | `plain-css` | No `tailwind.config.*`, no `*.module.css`, no CSS-in-JS dep | `class="trdr-btn"` in HTML attributes |
112
- | `css-modules` | `*.module.css` files present | `composes: trdr-btn from global` in module file, `className={styles.btn}` in JSX |
113
- | `tailwind` | `tailwind.config.*` present | `className="trdr-btn"` alongside Tailwind utilities |
114
- | `css-in-js` | `styled-components` or `@emotion/*` in package.json (WITHOUT `@mui/material`) | Insert token vars inside template literals / `theme` objects |
115
- | `mui` | `@mui/material` in package.json (v5+) | Theme-level integration: `createTheme()` palette/typography/shape use `var(--token)`, component `styleOverrides` use DS tokens, `sx` props migrated to token values |
116
-
117
- Save `stylingMode` — it must be referenced throughout Phase 2 wherever the output format differs by framework.
118
-
119
- **MUI detection priority:**
120
- If `package.json` contains `@mui/material` (any version >= 5):
121
- - Set `stylingMode: 'mui'` — do NOT fall through to `css-in-js` even if `@emotion/react` or `@emotion/styled` are present (they are MUI transitive dependencies, not direct CSS-in-JS usage)
122
- - Record `muiVersion` from package.json (e.g., `7.3.9`)
123
- - Detect MUI theme file: Glob for `**/theme.ts`, `**/theme.js`, `**/theme/index.ts`, `**/theme/index.js`, `**/theme/*.ts`, `**/createTheme*`, `**/muiTheme*` (exclude node_modules)
124
- - Record `themeFilePath` — the primary theme entry point (the file containing `createTheme()`)
125
- - Detect if project uses `ThemeProvider` in the app root: Grep for `<ThemeProvider` or `<MuiThemeProvider` in layout/app entry files
126
- - Record `hasThemeProvider: boolean`
127
-
128
- **MUI + Tailwind simultaneously:**
129
- If `package.json` contains BOTH `@mui/material` AND `tailwindcss`:
130
- - Set `stylingMode: 'mui'` (MUI dominant for component styling)
131
- - Set `hasTailwind: true` — Tailwind utilities may coexist for layout
132
- - In Step 3, scan BOTH theme files AND `tailwind.config.*` for violations
133
-
134
- **Dual stylingMode — tailwind + styled-components simultaneously:**
135
- If `package.json` contains BOTH `tailwindcss` AND `styled-components` (or `@emotion/*`):
136
- - Set `stylingMode: 'tailwind'` (dominant — utility classes in className)
137
- - Set `hasStyledComponents: true` to activate additional scan
138
- - In Step 3, add a styled-components scan alongside the normal CSS scan:
139
- - Pattern in `*.tsx, *.ts, *.jsx, *.js`: `` styled\.\w+`[^`]*(?:#[0-9A-Fa-f]{3,8}|font-family|rgba\()[^`]*` ``
140
- - For each template literal matched: run A, B, F violation checks against its content (even though it's not a `.css` file)
141
- - Fix: replace hardcoded values inside template literals with CSS var tokens:
142
- `background: #00A8CC` → `background: var(--action-brand-default);`
143
- `font-family: 'Inter'` → `font-family: var(--font-secondary);`
144
- - Document in `CLAUDE.md` of the project: "This project uses styled-components AND Tailwind. New components: prefer Tailwind + DS classes. Existing styled-components: use DS tokens via CSS vars in template literals."
145
-
146
- ### Step 2 — Map style structure
147
-
148
- Search for all style files:
149
- ```
150
- Glob: ["**/*.css", "**/*.scss"] — exclude node_modules, .next, dist, build, out
151
- ```
152
-
153
- Identify:
154
- - Main global CSS file (globals.css, main.css, index.css, app.css, styles.css)
155
- - Whether CSS custom properties already exist (look for `:root {`)
156
- - Potential conflicts with TRDR prefixes: `--bg-`, `--content-`, `--action-`, `--surface-`, `--border-`, `--spacing-`, `--radius-`
157
- - Whether fonts (JetBrains Mono, Inter, Roboto Mono) are already loaded
158
-
159
- Determine the best directory for new CSS files:
160
- - Next.js with `src/`: → `src/styles/`
161
- - Next.js without `src/`: → `styles/`
162
- - React CRA/Vite with `src/`: → `src/styles/` or `src/assets/`
163
- - Plain HTML: → `css/` or `styles/`
164
-
165
- **For `tailwind` stylingMode — additional scan:**
166
- Read `tailwind.config.js` (or `tailwind.config.ts`) and check `theme.colors` and `theme.extend.colors`:
167
- - If any color value is a hardcoded `#hex` that matches a TRDR DS token, flag it
168
- - Add `tailwind.config.js` to "FILES TO MODIFY" in the plan
169
- - Fix during Sub-fase B: replace each `'#hex'` with `'var(--semantic-token)'`
170
- - Example: `brand: '#00A8CC'` → `brand: 'var(--content-brand)'`
171
- - This allows Tailwind classes like `text-brand` to use the DS token automatically
172
-
173
- **For `mui` stylingMode — additional scan:**
174
- Read all theme files found during detection. Identify:
175
- - `createTheme()` call location and structure
176
- - `palette` object: list all hardcoded `#hex` values and their semantic role (primary, secondary, error, warning, success, info, background, text)
177
- - `typography` object: list all hardcoded `font-family`, `fontSize`, `fontWeight` values
178
- - `shape` object: list all hardcoded `borderRadius` values
179
- - `components` object: list all component `styleOverrides` with hardcoded values
180
- - Whether `cssVariables: true` is already passed to `createTheme()` (MUI v6+ CSS variables mode)
181
- - Whether project uses MUI's `sx` prop extensively: Grep for `sx=\{\{` in `*.tsx, *.jsx` — count distinct files
182
- - `styled(MuiComponent)` calls: Grep for `styled\([A-Z]\w+\)` in `*.tsx, *.ts, *.jsx, *.js` — count distinct files
183
- - Custom theme augmentation: `declare module '@mui/material/styles'` in `*.d.ts` files
184
-
185
- Add theme files and all files with `sx` / `styled(Mui*)` to "FILES TO MODIFY" in the plan.
186
-
187
- ### Step 3 — Find violations
188
-
189
- Search for TRDR rule violations across all source files (*.css, *.scss, *.tsx, *.jsx, *.ts, *.js, *.vue, *.html):
190
-
191
- **A — Hardcoded colors** (should be CSS vars):
192
- Search pattern: `#[0-9A-Fa-f]{3,8}` in CSS/SCSS files; `#[0-9A-Fa-f]{3,8}` in component files within style props or className strings.
193
-
194
- **Special case — SVG attribute colors** (`stroke=`, `fill=`, `stop-color=` in HTML/JSX/Vue):
195
- When `#hex` is found inside an SVG attribute (not a CSS property), the fix is different — CSS variables do NOT work in SVG attributes. Instead:
196
- - If the SVG is a simple icon with a single solid color → replace with `stroke="currentColor"` / `fill="currentColor"` and control color via a CSS class (e.g., `.icon-brand { color: var(--content-brand); }`)
197
- - If the SVG has multiple distinct colors (multi-tone icon) → it should be replaced as a Category J violation (inline SVG → icon library)
198
- - Do NOT write `stroke="var(--token)"` — it is invalid in HTML SVG attributes
199
-
200
- Track SVG attribute color violations separately as **A\*** in DS_ANALYSIS.md with the note "SVG attribute — requires currentColor + CSS class approach, not var()."
201
-
202
- **B — Hardcoded font-family** (should be var(--font-primary/secondary/mono)):
203
- Search: `font-family.*Inter|font-family.*JetBrains Mono|font-family.*Space Grotesk|font-family.*Roboto Mono`
204
-
205
- **Note — JSX camelCase:** In React/Next.js files, font-family appears as `fontFamily` inside `style={{}}` objects. These are NOT detected by Category B (which scans CSS). They are captured by Category I (inline styles with `font` keyword). Do NOT double-count them in Category B; address them in Category I fix instead.
206
-
207
- **C — Hardcoded px spacing** (should be var(--spacing-*)):
208
- Search: `(margin|padding|gap):\s*\d+px` in CSS/SCSS
209
-
210
- **D — Primitive token usage** (should be semantic):
211
- Search: `var\(--color-|var\(--space-` in CSS/SCSS/component files
212
-
213
- Also search for **custom CSS variable definitions with primitive naming** in `:root {}` blocks:
214
- - Pattern: `--color-[a-z]|--space-[0-9]|--font-size-[0-9]` inside `:root {`
215
- - Flag as: "Custom CSS variable using primitive-style name: `--color-brand`. This duplicates DS token naming. Remove and replace all `var(--color-brand)` usages with the appropriate semantic token."
216
- - Do NOT auto-remove — flag for manual review in DS_MIGRATION.md
217
-
218
- **E — Missing tokens.css**:
219
- Check if `tokens.css` already exists in the project and if it's imported in the global CSS.
220
-
221
- **F — Hardcoded rgba colors** (should use DS semantic tokens or be flagged):
222
- Search: `rgba\(` in CSS/SCSS/HTML files (excluding node_modules, vendor)
223
-
224
- **G — Custom gradients (non-TRDR)** (should use var(--gradient-*) tokens):
225
- Search: `linear-gradient|radial-gradient` in CSS/SCSS/HTML files
226
- Flag any gradient that doesn't reference a TRDR gradient token (`var(--gradient-*)`)
227
-
228
- **Gradients with hex stops:** Compare against TRDR gradient token approximate values:
229
- - `--gradient-bg-hero` ≈ `linear-gradient(180deg, #0E0E0E 0%, #141519 100%)`
230
- - `--gradient-bg-surface` ≈ `linear-gradient(180deg, #141519 0%, #0E0E0E 100%)`
231
- - `--gradient-brand` ≈ `linear-gradient(90deg, #00A8CC 0%, #00D4FF 100%)`
232
- If a gradient closely matches one of these: replace with `var(--gradient-name)`.
233
- If no match: flag in DS_MIGRATION.md as "Custom gradient — no DS token available."
234
- Non-DS colors in gradient stops (e.g. `#0a1520`) are also A violations — flag separately.
235
-
236
- **Gradients with rgba stops:** When gradient stops use `rgba()` instead of hex:
237
- 1. Extract the base color from each rgba stop and identify it in the TRDR color mapping table.
238
- 2. If the base color has a DS token: recommend `rgba(var(--token-rgb), opacity)` if the DS exposes RGB variables, otherwise flag in DS_MIGRATION.md.
239
- 3. **Fade-to-transparent** pattern (e.g. `rgba(0,212,255,0.04) 0%, transparent 100%`):
240
- - This is a glow/haze effect. Very unlikely to have a DS token.
241
- - Flag as: "Glow effect gradient — no DS token. Consider converting to `box-shadow: 0 0 Xpx var(--token)` or remove if purely decorative."
242
- 4. **Overlay gradient** (e.g. `rgba(255,204,64,0.1) 0%, rgba(255,204,64,0.05) 100%`):
243
- - Flag as: "Tinted overlay gradient — no DS equivalent. Map rgba base color to token; keep gradient as-is or convert to a solid rgba with semantic token."
244
-
245
- **H — Hardcoded font-size in px** (should use .trdr-h* / .trdr-body-* text style classes):
246
- Search: `font-size:\s*\d+px` in CSS/SCSS files (skip tokens.css itself)
247
-
248
- **I — Inline styles with design properties** (should be CSS classes with tokens):
249
-
250
- **I.1 — JSX/HTML style attribute** (standard inline styles):
251
- Search in `*.html, *.tsx, *.jsx, *.vue, *.svelte`:
252
- - HTML/Vue: `style="[^"]*(?:color|background|font|padding|margin|gap|border)[^"]*"`
253
- - React/JSX: `style=\{\{[^}]*(?:color|background|font|padding|margin|gap|border)[^}]*\}\}`
254
- - Vue binding: `:style="\{[^}]*(?:color|background|font|padding|margin|gap|border)[^}]*\}"`
255
-
256
- Do NOT flag (these are acceptable exceptions):
257
- - `background-image: url(...)` — dynamic image URL from data
258
- - `style="--custom-prop: value"` — CSS custom property passing a dynamic value to CSS (e.g. `style="--card-delay:0.1s"`)
259
- - `style={{ '--custom-prop': value }}` — same in JSX
260
-
261
- **I.2 — Dynamic DOM style assignment** (imperative JS manipulation, NOT covered by I.1):
262
- Search in `*.tsx, *.jsx, *.js, *.ts`:
263
- - Pattern: `\.style\.[a-zA-Z]+\s*=\s*['"]`
264
- - Example: `e.currentTarget.style.background = 'rgba(255,255,255,0.03)'`
265
- - Example: `ref.current.style.color = '#00D4FF'`
266
-
267
- This pattern is common in hover handlers (`onMouseEnter/onMouseLeave`) and imperative animations. The assigned value is a hardcoded design value that must be replaced.
268
-
269
- **I.2 fix procedure:**
270
-
271
- *CASE 1 — onMouseEnter/onMouseLeave hover effect:*
272
- This is the most common case. Convert to a CSS `:hover` rule:
273
- ```css
274
- /* Before: onMouseEnter sets background imperatively */
275
- .item { transition: background 0.15s; }
276
- .item:hover { background: var(--surface-hover); }
277
- ```
278
- Remove the `onMouseEnter` and `onMouseLeave` handlers. Add `className="item"` to the element.
279
-
280
- *CASE 2 — State-driven imperative style (non-hover):*
281
- If the DOM assignment is driven by JS logic beyond simple hover, replace the hardcoded value only:
282
- ```tsx
283
- // Before
284
- el.style.background = 'rgba(255,255,255,0.03)';
285
- // After
286
- el.style.background = 'var(--surface-hover)';
287
- ```
288
- Document in DS_PROGRESS.md as "I.2 fix — dynamic style value replaced with token."
289
-
290
- PRIORITY: Always prefer CASE 1 (CSS pseudo-class) — it's more performant and idiomatic than CASE 2.
291
-
292
- **J — SVG icons inline** (should use an icon library):
293
- Search in `*.html, *.tsx, *.jsx, *.vue`:
294
- - Pattern: `<svg` in source files (NOT in logo files, NOT in `node_modules/`, `references/`, `assets/icons/`)
295
- - Do NOT flag: `<svg` in known logo files (those with the official TRDR fingerprint)
296
- - Count distinct files with inline SVGs, not total occurrences
297
-
298
- **Severity sub-classification:**
299
- - **J.high**: `<svg>` with hardcoded `stroke="#hex"` or `fill="#hex"` — both a J and A* violation; replace with icon library ASAP
300
- - **J.medium**: `<svg>` with dynamic JSX fill/stroke expression (e.g. `fill={isActive ? 'currentColor' : 'none'}`) — no hex hardcoded, but state-driven SVG attribute that must be preserved during migration; replace with icon library using conditional CSS class
301
- - **J.low**: `<svg>` using ONLY `currentColor` / `inherit` (no hardcoded colors) — still prefer icon library, but lower priority; note in plan: "SVG uses currentColor (color is CSS-controlled). Migration to Material Icons recommended but non-urgent."
302
-
303
- **J.medium fix procedure — dynamic SVG attributes:**
304
- When an SVG has `fill={condition ? 'currentColor' : 'none'}` or `stroke={value}` (JSX expression):
305
- 1. Identify the two visual states (filled/outlined, active/inactive)
306
- 2. Create CSS classes for each state:
307
- ```css
308
- .icon-star { color: var(--content-tertiary); }
309
- .icon-star.active { color: var(--context-trading-signal); }
310
- ```
311
- 3. Replace the SVG with a Material Icon (or equivalent DS icon) using a conditional className:
312
- ```tsx
313
- <span className={`material-icons icon-star ${isWatching ? 'active' : ''}`}>star</span>
314
- ```
315
- 4. The `fill`/`stroke` logic is handled entirely by CSS — never pass state to icon attributes.
316
-
317
- **K — Logo missing or incorrect in HTML/JSX** (should use official logo-trdr.svg):
318
- Search in `*.html, *.tsx, *.jsx, *.vue` using **two separate Grep calls** (the combined pattern is unreliable in ripgrep):
319
-
320
- Call 1 — Non-official img logo (HTML):
321
- - Pattern: `src="[^"]*logo(?!-trdr)[^"]*"` — img/Image with logo in the src value itself (covers JSX where src is first attribute)
322
- - Secondary: `<img[^>]*(?:logo|brand|mark)[^>]*src="(?!.*logo-trdr)[^"]*"` — catches cases where logo/brand/mark appears in alt= or class= before src=
323
-
324
- Call 1b — Next.js `<Image>` component (Next.js projects only):
325
- - Pattern: `<Image[^>]*src="[^"]*logo(?!-trdr)[^"]*"` — next/image component with non-official logo
326
- - Also flag `<Image[^>]*src=\{[^}]*logo(?!Trdr)[^}]*\}` for dynamic src with variable name not matching logoTrdr
327
-
328
- Call 2 — Text span as logo (use this pattern, NOT the combined version):
329
- - Pattern: `>\s*TRDR\s*<` — finds any element with text content "TRDR"
330
- - Then check if the surrounding element is `<span>` or `<div>` (not `<img alt="TRDR">`)
331
- - Simpler alternative: `class="[^"]*logo[^"]*"` + check if no `<img` tag on the same line
332
-
333
- Call 3 — Wrong logo import:
334
- - Pattern: `import\s+\w+\s+from\s+['"][^'"]*logo(?!-trdr)[^'"]*['"]` — logo import that isn't logo-trdr
335
-
336
- Do NOT flag: `logo-trdr.svg` references — those are correct.
337
-
338
- **Note:** The pattern `<span[^>]*>[^<]*TRDR[^<]*</span>` is known to fail in ripgrep — do NOT use it.
339
-
340
- **L — Hardcoded values in MUI theme** (only when `stylingMode === 'mui'`):
341
- Search in theme files (`**/theme/**/*.ts`, `**/theme/**/*.js`, `**/theme.ts`, `**/theme.js`, `**/createTheme*`, `**/muiTheme*`):
342
-
343
- L.1 — palette hardcoded colors:
344
- - Pattern: `(?:main|light|dark|contrastText|paper|default):\s*['"]#[0-9A-Fa-f]{3,8}['"]`
345
- - Also: `primary:|secondary:|error:|warning:|success:|info:|background:|text:` objects with nested hex values
346
- - Fix: replace with `'var(--semantic-token)'` using the color mapping table
347
-
348
- L.2 — typography hardcoded values:
349
- - Pattern: `fontFamily:\s*['"][^'"]*Inter|fontFamily:\s*['"][^'"]*JetBrains|fontSize:\s*\d+` inside typography object
350
- - Fix: replace with `'var(--font-*)'` tokens
351
-
352
- L.3 — shape hardcoded radius:
353
- - Pattern: `borderRadius:\s*\d+` inside shape object or component styleOverrides
354
- - Fix: replace with numeric value from DS radius mapping
355
-
356
- L.4 — component styleOverrides hardcoded values:
357
- - Search inside `components:` > `Mui*` > `styleOverrides` for any `#hex`, `Npx` (spacing/radius), `font-family`
358
- - Fix: replace with appropriate `var(--token)`
359
-
360
- **M — Hardcoded values in MUI sx props** (only when `stylingMode === 'mui'`):
361
- Search in all component files (`*.tsx, *.jsx`):
362
- - Pattern: `sx=\{\{` then scan content for `#[0-9A-Fa-f]{3,8}`, `(?:padding|margin|gap):\s*['"]?\d+(?:px)?`, `fontFamily:`, `fontSize:\s*\d+`, `borderRadius:\s*\d+`
363
- - Also detect hardcoded values inside nested pseudo-selectors (`'&:hover'`, `'& .MuiXxx'`)
364
- - Fix: replace hardcoded values with `'var(--token)'`
365
-
366
- **N — Hardcoded values in styled(MuiComponent) calls** (only when `stylingMode === 'mui'`):
367
- Search in all component files (`*.tsx, *.jsx, *.ts, *.js`):
368
- - Pattern: `styled\([A-Z]\w+\)` — then scan the styled block for `#hex`, hardcoded `fontFamily`, `fontSize`, `borderRadius`, spacing px values
369
- - Fix: replace hardcoded values with `'var(--token)'`
370
-
371
- **MUI violation categories L, M, N are ONLY scanned when `stylingMode === 'mui'`** — they do not apply to other modes.
372
-
373
- Track:
374
- - `total_violations` = sum of all A–K occurrences (+ L, M, N when MUI)
375
- - `total_files_with_violations` = count of unique files with ≥ 1 violation
376
- - `violations_by_folder` = map of `{ folder: string, files: string[], count: number }[]` grouped by first-level folder inside `src/` (or project root if no `src/`)
377
-
378
- ### Step 3.5 — Detect component replacement candidates
379
-
380
- Scan the project for UI patterns that indicate elements replaceable by TRDR implemented components.
381
-
382
- **Scope:** `*.tsx, *.jsx, *.ts, *.js, *.html, *.vue` — exclude `node_modules/, .next/, dist/, build/, out/`.
383
-
384
- Use Grep (not Bash grep) to search for the patterns below. Group patterns from the same slug into a single call.
385
-
386
- **Pattern table per TRDR implemented component:**
387
-
388
- | Slug | Search patterns |
389
- |------|----------------|
390
- | `button` | `<button`, `<Button`, `type="submit"`, `type="button"`, `role="button"` |
391
- | `text-input` | `<input`, `<TextInput`, `<textarea`, `type="text"`, `type="email"`, `type="password"`, `type="search"` |
392
- | `checkbox` | `type="checkbox"`, `<Checkbox`, `\.checkbox` |
393
- | `radio-button` | `type="radio"`, `<RadioButton`, `<Radio[^B]` |
394
- | `switch` | `<Switch`, `role="switch"`, `\.toggle`, `\.switch` |
395
- | `dropdown` | `<select`, `<Select`, `<Dropdown`, `role="listbox"`, `role="combobox"` |
396
- | `combo-input` | `<ComboInput`, `combo.{0,10}input` |
397
- | `tooltip` | `<Tooltip`, `role="tooltip"`, `data-tooltip` |
398
- | `abas` | `<Tabs`, `role="tablist"`, `role="tab"`, `\.tabs` |
399
- | `segmented-control` | `<SegmentedControl`, `\.segmented`, `segment.{0,15}control` |
400
- | `sub-menu-item` | `<MenuItem`, `<SubMenu`, `\.menu-item`, `\.submenu` |
401
- | `card` | `<Card`, `\.card`, `<article` |
402
- | `boleta` | `<Boleta`, `boleta` |
403
- | `janela` | `<Janela`, `trading.{0,10}window` |
404
- | `tabela-cotacoes` | `<TabelaCotacoes`, `.quotes-table`, `.price-list`, `<table` with price/ticker/cotacao columns |
405
- | `tabela-ordens` | `<TabelaOrdens`, `.orders-table`, `.order-list`, `<table` with order/position columns |
406
- | `floating-menu` | `<FloatingMenu`, `.floating-menu`, `position:absolute` + `z-index` + list pattern |
407
- | `news-card` | `<NewsCard`, `.news-card`, `.article-card`, `<article` with image + title + date pattern |
408
- | `header` | `<Header`, `<header`, `.header`, `.navbar`, `<nav` at top-level page position |
409
- | `badge` | `<Badge`, `.badge`, `.tag`, `.chip`, `.label-status`, `<span` with short status-like text |
410
-
411
- **Rules:**
412
- - For each slug, count the distinct files that matched (not total lines) — one file counts as one occurrence.
413
- - Discard matches in test files (`*.test.*`, `*.spec.*`) — those don't count as UI usage.
414
- - Store results as a list of `{ slug, files: ["path:line", ...] }` — used in Step 5 and Phase 2 Step 6.
415
- - If a slug has zero matches, omit it from the replacement candidates list.
416
- - `title=""` attribute is too noisy — do NOT use it for tooltip detection; prefer `<Tooltip` / `role="tooltip"` / `data-tooltip`.
417
-
418
- **Also scan for CSS custom classes that re-implement DS components** (common in plain-HTML projects):
419
-
420
- | DS Component | CSS pattern to detect | Signal |
421
- |---|---|---|
422
- | Button | `.btn`, `.button`, `[class*="btn"]`, `[class*="button"]` in CSS with `cursor:pointer` | Likely button reimplementation |
423
- | Text Input | `.input`, `.text-field`, `.search-bar` in CSS with `border` + `padding` | Likely input reimplementation |
424
- | Segment Control | `.tab`, `.segment`, `.lang-selector` in CSS with `display:flex` + `border-radius` | Likely segmented reimplementation |
425
-
426
- For each match, add to `replacementCandidates[]` with a `customCssClass` field noting the project's class name, so Phase 2 Step 6 can add DS classes to those elements.
427
-
428
- **MUI component detection (only when `stylingMode === 'mui'`):**
429
-
430
- When `stylingMode === 'mui'`, the component candidate scan shifts focus. Instead of searching for HTML tags to replace with DS classes, search for MUI components that need theme-level DS token integration:
431
-
432
- | DS Slug | MUI Component patterns |
433
- |---------|----------------------|
434
- | `button` | `<Button`, `<IconButton`, `<LoadingButton`, `<Fab` |
435
- | `text-input` | `<TextField`, `<Input`, `<OutlinedInput`, `<FilledInput` |
436
- | `checkbox` | `<Checkbox`, `<FormControlLabel` with checkbox |
437
- | `radio-button` | `<Radio`, `<RadioGroup` |
438
- | `switch` | `<Switch` (MUI) |
439
- | `dropdown` | `<Select`, `<Autocomplete`, `<NativeSelect` |
440
- | `tooltip` | `<Tooltip` (MUI) |
441
- | `abas` | `<Tabs`, `<Tab` (MUI) |
442
- | `card` | `<Card`, `<CardContent`, `<CardActions`, `<CardMedia` |
443
- | `badge` | `<Badge`, `<Chip` (MUI) |
444
- | `header` | `<AppBar`, `<Toolbar` |
445
- | `modal` | `<Dialog`, `<Modal`, `<DialogTitle`, `<DialogContent` |
446
-
447
- For MUI projects, the purpose of detecting these components is NOT to replace them (they stay as MUI components), but to know WHICH MUI theme `components.MuiXxx.styleOverrides` entries to generate in Sub-fase C.
448
-
449
- Store results in the same `replacementCandidates[]` structure — the `slug` and `files` fields are used, but classification follows MUI-specific rules (see Step 3.5b).
450
-
451
- **Output:** `replacementCandidates[]` — passed to Step 3.5b, Step 5 template and Phase 2 Step 6.
452
-
453
- ### Step 3.5b — Capture structural context for each candidate
454
-
455
- For each file:line match found in Step 3.5, read the surrounding context (10 lines before and after the match) and classify the replacement complexity:
456
-
457
- | Classification | Criteria | Phase 2 action |
458
- |---|---|---|
459
- | `simple` | Element has only text content. No event handlers (`onClick`, `onChange`, etc.), no conditional rendering (`{condition && ...}`, ternary), no dynamic props beyond basic HTML attributes (`id`, `name`, `class`, `placeholder`, `type`) | Full DS component replacement — swap the element entirely with the DS component structure, adapting content |
460
- | `complex-preservable` | Element has event handlers, data bindings (`value={state}`, `checked={state}`), refs, or conditional rendering, BUT the DOM structure maps cleanly to a DS component | Apply DS structure + classes, preserving ALL handlers, bindings, and conditional logic |
461
- | `complex-manual` | Element has deeply nested custom logic, multiple conditional branches affecting structure, dynamically generated children, or domain-specific behavior that doesn't map to any DS component pattern | Flag for manual review in DS_MIGRATION.md — do NOT auto-modify |
462
-
463
- **MUI classification rules (only when `stylingMode === 'mui'`):**
464
-
465
- When `stylingMode === 'mui'`, use these classifications instead of the table above:
466
-
467
- | Classification | Criteria | Phase 2 action |
468
- |---|---|---|
469
- | `theme-override` | Standard MUI component usage — the component should receive DS tokens via theme `components.MuiXxx.styleOverrides` | Generate/update styleOverrides in theme file (Sub-fase C) |
470
- | `sx-migration` | Component has `sx={{...}}` with hardcoded design values (colors, fonts, radius) | Replace hardcoded sx values with `'var(--token)'` (Sub-fase B/C) |
471
- | `styled-migration` | Component uses `styled(MuiComponent)` with hardcoded values | Replace values inside styled() call with `'var(--token)'` (Sub-fase B/C) |
472
- | `complex-manual` | Deeply customized MUI component with renderProp, slots API, complex theme augmentation, or `sx` with dynamic calculations | Flag for manual review in DS_MIGRATION.md |
473
-
474
- All detected MUI components default to `theme-override`. Add `sx-migration` or `styled-migration` only for individual instances that also have inline hardcoded values.
475
-
476
- **For each candidate, store:**
477
- ```json
478
- {
479
- "slug": "button",
480
- "file": "src/components/Hero.tsx",
481
- "line": 42,
482
- "classification": "simple",
483
- "existingContent": "Get Started",
484
- "existingHandlers": [],
485
- "existingClasses": "btn-primary hero-cta",
486
- "existingProps": [],
487
- "suggestedDsVariant": "trdr-btn-primary"
488
- }
489
- ```
490
-
491
- **Variant detection rules (by signals in existing code):**
492
-
493
- | Existing pattern signals | Suggested DS variant |
494
- |---|---|
495
- | `.btn-primary`, `.cta`, `type="submit"`, prominent/brand color (cyan, blue) | `trdr-btn-primary` |
496
- | `.btn-secondary`, `.btn-cancel`, muted/gray color | `trdr-btn-secondary` |
497
- | `.btn-outline`, `.btn-ghost`, transparent background + border | `trdr-btn-ghost` |
498
- | `.btn-danger`, `.btn-delete`, red/orange/destructive color | `trdr-btn-destructive` |
499
- | `.btn-link`, `<a>` styled as button, no border/bg | `trdr-btn-link` |
500
- | `type="text"`, `type="email"`, `type="password"`, `type="search"`, `<textarea>` | `trdr-text-input` |
501
- | `type="checkbox"` | `trdr-checkbox` |
502
- | `type="radio"` | `trdr-radio-button` |
503
- | `role="switch"`, `.toggle`, `.switch` | `trdr-switch` |
504
- | `<select>`, `role="listbox"` | `trdr-dropdown` |
505
- | `role="tablist"`, `.tabs` | `trdr-abas` or `trdr-segment-control` |
506
- | `.badge` + green/success color | `trdr-badge-success` |
507
- | `.badge` + blue/brand color | `trdr-badge-brand` |
508
- | `.badge` + yellow/warning color | `trdr-badge-warning` |
509
- | `.badge` + neutral/gray color | `trdr-badge-neutral` |
510
- | `<Tooltip>`, `role="tooltip"`, `data-tooltip` | `trdr-tooltip` |
511
-
512
- **Output:** Updated `replacementCandidates[]` — each entry now includes `classification`, `existingContent`, `existingHandlers`, `existingProps`, and `suggestedDsVariant`.
513
-
514
- ### Step 3.6 — Logo audit
515
-
516
- Glob for logo files across the project:
517
-
518
- ```
519
- Patterns: ["**/logo*.svg", "**/*trdr*.svg", "**/brand*.svg", "**/icon-trdr*.svg"]
520
- Exclude: node_modules/, .next/, dist/, build/, out/, references/
521
- ```
522
-
523
- The official TRDR logo fingerprint (both must be present):
524
- - `viewBox="0 0 105 41"` — exact dimensions of the reference logo
525
- - `fill="#00D4FF"` — brand cyan used in the symbol paths
526
-
527
- For each found SVG file:
528
- 1. Read its content.
529
- 2. Check for both fingerprint markers.
530
- 3. Classify:
531
- - ✅ **CORRECT** — contains both markers → already the official logo
532
- - ❌ **WRONG** — SVG file exists but doesn't match (different viewBox, colors, or both)
533
- - ⚠️ **UNKNOWN** — binary or unusually formatted SVG, can't determine
534
-
535
- Store result as `logoAudit = { correct: string[], wrong: string[], unknown: string[] }`.
536
-
537
- If no logo files are found at all, check if a `public/` directory exists at the project root — flag it as a suggested location to add the logo.
538
-
539
- Include logo findings in the migration plan (Step 5 below).
540
-
541
- ### Step 4 — Load component catalog (offline-first)
542
-
543
- Read the local snapshot from the skill directory:
544
-
545
- ```
546
- Read: <skill-dir>/data/components.json
547
- ```
548
-
549
- Where `<skill-dir>` is either `~/.claude/skills/trdr-ds/` or `<project>/.claude/skills/trdr-ds/`. Try both.
550
-
551
- Expected JSON shape:
552
- ```json
553
- {
554
- "version": "1.0",
555
- "generatedAt": "2026-05-08T...",
556
- "total": 60,
557
- "implemented": 13,
558
- "categories": { "formulario": "Formulário / Controles", ... },
559
- "components": [
560
- {
561
- "slug": "button", "name": "Button", "figmaId": "1318:749",
562
- "category": "formulario", "description": "...",
563
- "implemented": true,
564
- "props": [...], "dimensions": [...], "tokens": [...],
565
- "code": { "html": "...", "css": "...", "react": "...", "prompt": "..." }
566
- },
567
- {
568
- "slug": "modal", "name": "Modal", "figmaId": "...",
569
- "category": "modal", "description": "...",
570
- "implemented": false,
571
- "tokens": [{ "property": "background", "token": "--surface-secondary", "value": "#222" }, ...]
572
- }
573
- ]
574
- }
575
- ```
576
-
577
- If `--latest` was passed (or argument is `sync`), first fetch the canonical JSON:
578
- ```
579
- WebFetch: https://trdr.mrocontent.com.br/components.json
580
- ```
581
- And overwrite `data/components.json` in the skill directory before continuing.
582
-
583
- If both the local snapshot and the Hub fail → STOP with:
584
- > ❌ Could not load TRDR component catalog (local snapshot missing AND Hub unreachable). Aborting. Run `npm run sync` in the trdr-plugins repo to refresh the snapshot.
585
-
586
- Use the loaded data throughout the rest of the workflow. Track:
587
- - `implementedSlugs` = list of `c.slug` where `c.implemented === true`
588
- - `stubSlugs` = list of `c.slug` where `c.implemented !== true`
589
-
590
- ### Step 5 — Present the migration plan and STOP
591
-
592
- Output the following report and **do not proceed** until the developer explicitly approves.
593
-
594
- All projects use the same checkpointed 4-sub-phase execution regardless of size. This prevents context overload and hallucinations for any project, small or large.
595
-
596
- ```markdown
597
- ## TRDR Design System — Migration Plan
598
-
599
- ### Project: [framework] | [language] | [styling approach]
600
- ### Catalog: TRDR DS v[version] (generated [generatedAt])
601
- ### Coverage: [implemented]/[total] components implemented
602
-
603
- ---
604
-
605
- ### Conformance score: [X]% compliant
606
- (Percentage of style files with zero hardcoded violations)
607
-
608
- ---
609
-
610
- ### FILES TO CREATE:
611
- - [ ] `[detected-styles-dir]/tokens.css` — TRDR CSS custom properties (dark + light mode)
612
- - [ ] `[detected-styles-dir]/components.css` — TRDR utility classes (.trdr-btn, .trdr-card, etc.)
613
- - [ ] `CLAUDE.md` (project root) — design system rules for Claude Code
614
- - [ ] `MISSING_COMPONENTS.md` (only if stubs are referenced) — pending implementations
615
-
616
- ### FILES TO MODIFY:
617
- - [ ] `[global-css-file]` — add @import for tokens.css and components.css
618
- [list each file with violations, e.g.:]
619
- - [ ] `src/components/Button.css` — 3 violations (hardcoded colors: #00A8CC, #0E0E0E, #FFFFFF)
620
- - [ ] `src/app/globals.css` — 2 violations (font-family: Inter)
621
-
622
- ### VIOLATIONS FOUND:
623
- | Category | Count | Example |
624
- |----------|-------|---------|
625
- | A — Hardcoded colors | N | `color: #00A8CC` in Button.css:14 |
626
- | B — Hardcoded fonts | N | `font-family: Inter` in globals.css:8 |
627
- | C — Hardcoded spacing | N | `padding: 16px` in Card.css:22 |
628
- | D — Primitive token use | N | `var(--color-blue-600)` in Badge.css:31 |
629
- | E — Missing tokens.css | N | not imported in globals.css |
630
- | F — Hardcoded rgba | N | `background: rgba(0,0,0,.3)` in card.css:88 |
631
- | G — Custom gradients | N | `linear-gradient(135deg, #FF6B6B...)` in header:24 |
632
- | H — Hardcoded font-size | N | `font-size: 22px` in card.css:99 |
633
- | I — Inline styles | N | `style="color:#00D4FF"` in index.html:312 |
634
- | J — SVG icons inline | N | `<svg>` in index.html (search, close, play icons) |
635
- | K — Logo incorrect/missing | N | `<span>TRDR</span>` used as logo in index.html:45 |
636
-
637
- ### TRDR COMPONENTS — IMPLEMENTATION PLAN:
638
- (Candidatos detectados no Step 3.5 — com classificação de complexidade)
639
-
640
- #### Simple swaps (substituição completa pelo componente DS):
641
- | Componente | Variante DS | Arquivo | Conteúdo atual |
642
- |------------|------------|---------|----------------|
643
- [For each candidate where classification === 'simple':]
644
- | [c.name] | [suggestedDsVariant] | [file:line] | "[existingContent]" |
645
-
646
- #### Complex-preservable (estrutura DS + lógica preservada):
647
- | Componente | Arquivo | Handlers/Props preservados |
648
- |------------|---------|----------------------------|
649
- [For each candidate where classification === 'complex-preservable':]
650
- | [c.name] | [file:line] | [existingHandlers], [existingProps] |
651
-
652
- #### Manual review (complexidade alta — sem modificação automática):
653
- | Componente | Arquivo | Motivo |
654
- |------------|---------|--------|
655
- [For each candidate where classification === 'complex-manual':]
656
- | [c.name] | [file:line] | [reason] |
657
-
658
- > **Simple:** substituição completa, conteúdo adaptado do projeto.
659
- > **Complex-preservable:** estrutura DS aplicada, toda lógica (handlers, bindings, conditionals) preservada.
660
- > **Manual:** flagged em DS_MIGRATION.md para revisão pelo desenvolvedor.
661
-
662
- #### Stubs e catálogo:
663
- | Componente | Status no catálogo | Arquivos detectados |
664
- |------------|--------------------|---------------------|
665
- [For each entry in replacementCandidates[], look up the slug in the loaded catalog:]
666
- [If c.implemented === true:]
667
- | [c.name] | ✅ implementado | [list of file:line from Step 3.5] |
668
- [If c.implemented === false:]
669
- | [c.name] | ⚠️ stub (figmaId [c.figmaId]) | [list of file:line] — receberá banner comment |
670
- [If replacementCandidates is empty:]
671
- | — | Nenhum candidato detectado | — |
672
-
673
- > **Implementados:** o CSS estará em `components.css` após a Fase 2, **E** as classes DS serão aplicadas diretamente nos elementos HTML/JSX/Vue durante o Step 6 — não é necessária nenhuma ação manual.
674
- > **Stubs:** receberão banner comment com tokens recomendados + entrada em `MISSING_COMPONENTS.md`.
675
-
676
- [If `stylingMode === 'mui'`:]
677
-
678
- ### MUI THEME INTEGRATION PLAN:
679
- | Area | Current state | Action |
680
- |------|--------------|--------|
681
- | palette | [N] hardcoded hex values | Replace with `var(--token)` references |
682
- | typography | [N] hardcoded font values | Map to DS font tokens |
683
- | shape | borderRadius: [value] | Map to DS radius token |
684
- | components | [N] MUI components detected | Generate/update styleOverrides with DS tokens |
685
- | sx props | [N] files with hardcoded sx values | Migrate to token references |
686
- | styled() | [N] styled(MuiComponent) calls | Migrate to token references |
687
-
688
- **Theme file:** `[themeFilePath]`
689
- **MUI version:** [muiVersion]
690
- **CSS Variables mode:** [yes/no — if no, will be recommended for MUI v6+]
691
- **ThemeProvider:** [found at file:line / not found — will need manual setup]
692
-
693
- > **Note:** MUI projects receive DS tokens via the theme object. Sub-fase A creates `tokens.css` AND updates the MUI theme to reference those tokens via `var()`. Sub-fase C generates `styleOverrides` for each detected MUI component instead of swapping HTML tags.
694
-
695
- ### SCOPE ESTIMATE: [Small / Medium / Large]
696
- Small = <10 violations | Medium = 10–50 | Large = 50+
697
-
698
- ### ⚙️ EXECUTION MODE
699
- Phase 2 runs in **4 sub-phases with checkpoints** — always, regardless of project size.
700
- Sub-fase B (violations) processes **5 files/batch** to prevent context overload.
701
-
702
- ~[ceil(total_files_with_violations/5)] violation batches estimated.
703
- Progress saved to `DS_PROGRESS.md` — resumable anytime with `/trdr-ds resume`.
704
-
705
- To change batch size: reply with `"Apply, batch 10"` or `"Apply, batch 3"`.
706
-
707
- ### LOGOS:
708
- [If logoAudit.correct.length > 0:]
709
- | ✅ [file] | Official TRDR logo — no action needed |
710
-
711
- [If logoAudit.wrong.length > 0:]
712
- | ❌ [file] | Wrong logo — will be replaced with the official TRDR logo |
713
-
714
- [If logoAudit.unknown.length > 0:]
715
- | ⚠️ [file] | Could not verify — manual check recommended |
716
-
717
- [If no logo files found AND public/ exists:]
718
- > ℹ️ No logo file detected. The official TRDR logo will be copied to `public/logo-trdr.svg`.
719
-
720
- [If no logo files found AND no public/ exists:]
721
- > ℹ️ No logo file detected. Specify a path to add the official TRDR logo, or skip.
722
-
723
- ### WHAT WILL NOT BE TOUCHED:
724
- - Correct TRDR logo files (already match the official reference)
725
- - Images, fonts, non-SVG assets
726
- - node_modules/, .next/, dist/, build/, out/
727
- - Third-party library files
728
- - Any file you explicitly exclude
729
-
730
- ---
731
-
732
- **Reply with one of:**
733
- - `"Apply"` or `"Executar"` — proceed with everything above
734
- - `"Apply, batch [N]"` — proceed with custom violation batch size (default: 5)
735
- - `"Apply, skip [file or directory]"` — proceed but exclude specific paths
736
- - `"Only tokens"` — only create tokens.css, components.css, and CLAUDE.md (no violation fixes)
737
- - `"Change [detail]"` — adjust a specific part of the plan before executing
738
- - `"Sync first"` — pull the latest catalog from the Hub before applying
739
- ```
740
-
741
- ### Step 5.5 — Write DS_ANALYSIS.md (MANDATORY before stopping)
742
-
743
- Before presenting the plan to the developer and before any STOP, write `DS_ANALYSIS.md` to the **project root** with the complete analysis captured in Steps 1–4. This file is the context anchor for all Phase 2 sub-phases — they will read it instead of relying on conversation history.
744
-
745
- ```markdown
746
- # TRDR DS — Analysis
747
- Generated: [ISO datetime]
748
- Skill version: [X.Y.Z]
749
-
750
- ## Project
751
- Framework: [next.js|react|vue|html]
752
- Language: [ts|js]
753
- Styling: [css-modules|tailwind|plain-css|css-in-js|mui]
754
- Global CSS file: [path]
755
- Styles dir: [detected-styles-dir]
756
- [If stylingMode === 'mui':]
757
- MUI version: [muiVersion]
758
- Theme file: [themeFilePath]
759
- Has ThemeProvider: [yes/no]
760
- MUI CSS Variables mode: [yes/no]
761
- Files with sx props: [count]
762
- Files with styled(Mui*): [count]
763
-
764
- ## Violations Summary
765
- Total violations: [total_violations]
766
- Total files with violations: [total_files_with_violations]
767
-
768
- ### By Category
769
- | Cat | Type | Count | Files |
770
- |-----|------|-------|-------|
771
- | A | Hardcoded colors | N | file1.css, file2.jsx |
772
- | B | Hardcoded font-family | N | ... |
773
- | C | Hardcoded px spacing | N | ... |
774
- | D | Primitive token use | N | ... |
775
- | E | Missing tokens.css | N | ... |
776
- | F | Hardcoded rgba | N | ... |
777
- | G | Custom gradients | N | ... |
778
- | H | Hardcoded font-size | N | ... |
779
- | I | Inline styles | N | ... |
780
- | J | SVG icons inline | N | ... |
781
- | K | Logo incorrect/missing | N | ... |
782
- [If stylingMode === 'mui':]
783
- | L | MUI theme hardcoded values | N | theme.ts |
784
- | M | MUI sx prop hardcoded values | N | Component1.tsx, Component2.tsx |
785
- | N | styled(MuiComponent) hardcoded values | N | StyledButton.tsx |
786
-
787
- ### By File
788
- [For each file with violations:]
789
- #### [file path]
790
- - A: [value] (line [N]), [value] (line [N])
791
- - C: [value] (line [N])
792
- - I: [value] (line [N])
793
- [list all violations with line numbers]
794
-
795
- ## Component Replacement Candidates
796
-
797
- ### Simple swaps (full DS component replacement)
798
- [For each candidate where classification === 'simple':]
799
- | Component | DS Variant | File | Existing Content |
800
- |-----------|-----------|------|------------------|
801
- | [c.name] | [suggestedDsVariant] | [file:line] | "[existingContent]" |
802
-
803
- ### Complex-preservable (DS structure + preserved logic)
804
- [For each candidate where classification === 'complex-preservable':]
805
- | Component | File | Handlers/Props Preserved |
806
- |-----------|------|--------------------------|
807
- | [c.name] | [file:line] | [existingHandlers], [existingProps] |
808
-
809
- ### Manual review required
810
- [For each candidate where classification === 'complex-manual':]
811
- | Component | File | Reason |
812
- |-----------|------|--------|
813
- | [c.name] | [file:line] | [brief description of why it's complex] |
814
-
815
- ### Stubs (not yet implemented in DS)
816
- [For each candidate where c.implemented === false:]
817
- - [slug]: [file:line] — ⚠️ stub (figmaId: [c.figmaId])
818
-
819
- ### Dependency Graph
820
- [For each candidate with non-empty dependencies in components.json:]
821
- | Compound Component | Dependencies (install first) |
822
- |--------------------|----------------------------|
823
- | [c.name] | [c.dependencies.join(', ')] |
824
-
825
- [If no compound components among candidates:]
826
- > All candidates are atomic — no dependency ordering needed.
827
-
828
- ## Logo Audit
829
- [For each file in logoAudit.correct:] - [path] — ✅ CORRECT
830
- [For each file in logoAudit.wrong:] - [path] — ❌ WRONG (will be replaced)
831
- [For each file in logoAudit.unknown:] - [path] — ⚠️ UNKNOWN
832
-
833
- ## Execution Plan
834
- Batch size: [N] (default 5)
835
- [Group files by folder, max batch_size files per batch:]
836
- ### Batch 1 — [folder/] ([N] files)
837
- - [file1]
838
- - [file2]
839
- ### Batch 2 — [folder/] ([N] files)
840
- - ...
841
- ```
842
-
843
- ### Step 5.6 — Generate SPRINT_PLAN.md
844
-
845
- After writing `DS_ANALYSIS.md`, generate `SPRINT_PLAN.md` at the project root. This file breaks the entire migration into **self-contained sprints** — each sprint can be executed in an independent conversation with a clean context window.
846
-
847
- **Sprint sizing rules:**
848
- - Each sprint should process at most **15 files** (keeps context comfortable even for complex files)
849
- - Group files by **folder** (natural boundary — violations in the same folder share CSS patterns)
850
- - If a folder has >15 files, split into sub-sprints (e.g., `Sprint 3a`, `Sprint 3b`)
851
- - Foundation, Components, and Final are each their own sprint (regardless of file count)
852
-
853
- **Generate the plan:**
854
-
855
- ```markdown
856
- # TRDR DS — Sprint Plan
857
- Generated: [ISO datetime]
858
- Project: [project name]
859
- Total sprints: [N]
860
- Estimated context windows: [N] (one per sprint + one for this analysis)
861
-
862
- > Cada sprint é independente. Entre sprints, você pode limpar o contexto (`/clear`) ou iniciar uma nova conversa.
863
- > Para continuar: `/trdr-ds resume`
864
-
865
- ---
866
-
867
- ## Sprint 1 — Foundation
868
- [If stylingMode !== 'mui':]
869
- **Scope:** Create tokens.css, components.css, CLAUDE.md, @import in global CSS
870
- [If stylingMode === 'mui':]
871
- **Scope:** Create tokens.css, components.css, CLAUDE.md, @import in global CSS, AND generate/update MUI theme with DS token references (palette, typography, shape)
872
- **Sub-fase:** A
873
- **Files to create:** 3 (tokens.css, components.css, CLAUDE.md)
874
- [If stylingMode === 'mui':]
875
- **Files to modify:** 2 (global CSS, [themeFilePath])
876
- [else:]
877
- **Files to modify:** 1 (global CSS)
878
- **Status:** PENDING
879
-
880
- ---
881
-
882
- ## Sprint 2 — Violations: [first-folder/]
883
- **Scope:** Fix [N] violations in [M] files
884
- **Sub-fase:** B
885
- **Files:** [list each file path]
886
- **Violation count:** [N] (A:[n], B:[n], C:[n], ...)
887
- **Status:** PENDING
888
-
889
- ---
890
-
891
- ## Sprint 3 — Violations: [second-folder/]
892
- **Scope:** Fix [N] violations in [M] files
893
- **Sub-fase:** B
894
- **Files:** [list each file path]
895
- **Violation count:** [N]
896
- **Status:** PENDING
897
-
898
- ---
899
-
900
- [... repeat for each folder/batch ...]
901
-
902
- ---
903
-
904
- ## Sprint [N-1] — Components
905
- [If stylingMode !== 'mui':]
906
- **Scope:** Implement DS components ([S] simple, [P] complex-preservable, [M] manual review)
907
- **Candidates:** [total]
908
- **Install order:** [topological order from dependency graph — atomics first, then compounds]
909
- [If stylingMode === 'mui':]
910
- **Scope:** Generate MUI theme component styleOverrides for [N] detected MUI components, migrate [M] sx prop violations
911
- **Candidates:** [total MUI components]
912
- **Sub-fase:** C
913
- **Status:** PENDING
914
-
915
- ---
916
-
917
- ## Sprint [N] — Final
918
- **Scope:** Replace logos, replace SVG icons with Material Icons (size-preserved), generate DS_MIGRATION.md
919
- **Sub-fase:** D
920
- **Status:** PENDING
921
- ```
922
-
923
- **Sprint naming convention:**
924
- - Foundation sprints: `Sprint 1 — Foundation`
925
- - Violation sprints: `Sprint N — Violations: [folder/]`
926
- - If folder split: `Sprint Na — Violations: [folder/] (part 1 of 2)`
927
- - Component sprint: `Sprint N — Components`
928
- - Final sprint: `Sprint N — Final`
929
-
930
- After writing `SPRINT_PLAN.md`, update the output to include the sprint summary:
931
-
932
- ```
933
- ✅ DS_ANALYSIS.md e SPRINT_PLAN.md salvos.
934
-
935
- 📋 Sprint Plan: [N] sprints planejados
936
- Sprint 1: Foundation (4 arquivos)
937
- Sprint 2-[M]: Violations ([total_files] arquivos em [folders] pastas)
938
- Sprint [M+1]: Components ([candidates] candidatos)
939
- Sprint [N]: Final (logos + ícones + DS_MIGRATION.md)
940
-
941
- Cada sprint é independente — entre sprints, limpe o contexto com /clear.
942
- Para continuar de qualquer ponto: /trdr-ds resume
943
-
944
- Responda 'Apply' para iniciar o Sprint 1.
945
- ```
946
-
947
- **STOP HERE. Wait for explicit developer approval before Phase 2.**
948
-
949
- ---
950
-
951
- ## PHASE 2: EXECUTION (only after explicit approval)
952
-
953
- Parse the developer's reply:
954
- - Extract batch size override from `"Apply, batch N"` → use N; otherwise default to **5**.
955
- - Extract skip paths from `"Apply, skip [path]"` → exclude those from violation processing.
956
- - `"Only tokens"` → skip Sub-fases B and C (no violation fixes, no component banners).
957
-
958
- ### Sprint execution model
959
-
960
- Each sprint is a **self-contained unit of work** designed to fit comfortably in a single context window. The developer can `/clear` or start a new conversation between sprints and resume with `/trdr-ds resume`.
961
-
962
- **Context rule (critical):** At the start of EVERY sprint, before doing anything else:
963
- 1. Read `SPRINT_PLAN.md` from the project root — find the current sprint (first with `Status: PENDING` or `Status: IN_PROGRESS`)
964
- 2. Read `DS_ANALYSIS.md` from the project root — but ONLY the sections relevant to the current sprint's scope (e.g., for a violation sprint, only read the `§ By File` entries for the files listed in that sprint)
965
- 3. Read `DS_PROGRESS.md` from the project root — this is the canonical source of progress state
966
-
967
- **Never read the entire DS_ANALYSIS.md at once for large projects.** Only read the sections needed for the current sprint. This prevents context overflow.
968
-
969
- Never rely on conversation memory for violation counts, file paths, batch assignments, or framework detection. Always re-read from files.
970
-
971
- **Sprint lifecycle:**
972
- 1. Read state files (SPRINT_PLAN.md + relevant sections of DS_ANALYSIS.md + DS_PROGRESS.md)
973
- 2. Update SPRINT_PLAN.md: set current sprint `Status: IN_PROGRESS`
974
- 3. Execute the sprint's scope (Foundation / Violations for specific files / Components / Final)
975
- 4. Update DS_PROGRESS.md with results
976
- 5. Update SPRINT_PLAN.md: set current sprint `Status: ✅ COMPLETE`
977
- 6. Output sprint summary with next sprint info
978
- 7. **STOP** — wait for developer to continue or `/clear` + `/trdr-ds resume`
979
-
980
- **End-of-sprint output (MANDATORY after every sprint):**
981
- ```
982
- ✅ Sprint [N] completo — [sprint name]
983
- [Brief summary of what was done: files modified, violations fixed, components applied, etc.]
984
-
985
- 📋 Progresso: [done]/[total] sprints ([percentage]%)
986
- Próximo: Sprint [N+1] — [next sprint name]
987
-
988
- → Você pode limpar o contexto agora: /clear
989
- → Para continuar: /trdr-ds resume
990
- → Para ver status completo: /trdr-ds status
991
- ```
992
-
993
- Report progress after each major step within a sprint.
994
-
995
- ### Step 0 — Initialize checkpoint
996
-
997
- **Create `DS_PROGRESS.md` at the project root** (always — no size threshold):
998
-
999
- ```markdown
1000
- # TRDR DS Migration — Progress
1001
- Started: [ISO datetime]
1002
- Project: [project name from package.json]
1003
- Batch size: [N]
1004
- Status: IN_PROGRESS
1005
- Backup branch: [branch-name or NONE]
1006
- Original branch: [branch-name]
1007
- Sprint plan: SPRINT_PLAN.md
1008
- Current sprint: 1
1009
-
1010
- ## Sub-fase A: Foundation — PENDING
1011
- - [ ] tokens.css
1012
- - [ ] components.css
1013
- - [ ] CLAUDE.md
1014
- - [ ] @import no CSS global
1015
-
1016
- ## Sub-fase B: Violations — PENDING
1017
- Total de arquivos com violações: [total_files_with_violations]
1018
- Total de violações: [total_violations]
1019
- Total de lotes: [N]
1020
-
1021
- [For each batch from DS_ANALYSIS.md § Execution Plan:]
1022
- ### Lote 1 — [folder/] ([N] arquivos) — PENDING
1023
- ### Lote 2 — [folder/] ([N] arquivos) — PENDING
1024
- ...
1025
- ### Lote [n] — raiz ([N] arquivos) — PENDING
1026
-
1027
- ## Sub-fase C: Components — PENDING
1028
- Install order: [topological — atomics first, then compounds by dependency]
1029
- [list component replacement candidates from DS_ANALYSIS.md]
1030
-
1031
- ## Sub-fase D: Final — PENDING
1032
- - [ ] logos incorretos substituídos
1033
- - [ ] DS_MIGRATION.md gerado
1034
-
1035
- ## Padrões Sem Token (revisão manual)
1036
- [empty — filled during execution]
1037
- ```
1038
-
1039
- ### Step 0.5 — Git backup (safety net)
1040
-
1041
- Before modifying any project file, create a git backup so the entire migration can be rolled back.
1042
-
1043
- **Step 0.5a — Check git status:**
1044
-
1045
- Run via Bash:
1046
- ```bash
1047
- git rev-parse --is-inside-work-tree 2>/dev/null
1048
- ```
1049
-
1050
- **If NOT a git repo:**
1051
- ```
1052
- ⚠️ Este projeto não tem repositório git. Um backup automático não é possível sem git.
1053
-
1054
- Responda:
1055
- - "git init" — inicializar repositório git e criar backup antes de continuar
1056
- - "continuar sem backup" — prosseguir sem safety net (irreversível)
1057
- ```
1058
- **STOP. Wait for reply.**
1059
-
1060
- If reply is `"git init"`:
1061
- 1. Run: `git init`
1062
- 2. Run: `git add -A && git commit -m "Initial commit (before TRDR DS migration)"`
1063
- 3. Continue to Step 0.5b.
1064
-
1065
- If reply is `"continuar sem backup"`:
1066
- - Update `DS_PROGRESS.md`: set `Backup branch: NONE (user opted out)`
1067
- - Skip to Sub-fase A.
1068
-
1069
- **If IS a git repo:** Continue to Step 0.5b.
1070
-
1071
- **Step 0.5b — Check for existing backup branch:**
1072
-
1073
- Run via Bash:
1074
- ```bash
1075
- git branch --list "trdr-ds/backup-*"
1076
- ```
1077
-
1078
- If one or more `trdr-ds/backup-*` branches exist:
1079
- ```
1080
- ⚠️ Backup branch(es) encontrado(s) de execução anterior:
1081
- [list each branch name]
1082
-
1083
- Responda:
1084
- - "manter" — criar novo backup com timestamp diferente (mantém os anteriores)
1085
- - "substituir" — apagar o backup anterior e criar um novo
1086
- ```
1087
- **STOP. Wait for reply.**
1088
-
1089
- If `"substituir"`: delete all existing `trdr-ds/backup-*` branches via `git branch -D [name]` for each.
1090
-
1091
- **Step 0.5c — Create the backup branch:**
1092
-
1093
- 1. Record the current branch name:
1094
- ```bash
1095
- git branch --show-current
1096
- ```
1097
- Save as `originalBranch`. If in detached HEAD state (empty output), save the commit hash via `git rev-parse HEAD` instead.
1098
-
1099
- 2. Generate timestamp branch name: `trdr-ds/backup-{YYYY-MM-DD-HHmmss}` (use current local time).
1100
-
1101
- 3. Check for uncommitted changes:
1102
- ```bash
1103
- git status --porcelain
1104
- ```
1105
- If output is non-empty (uncommitted changes exist):
1106
- ```bash
1107
- git stash push -m "trdr-ds-pre-migration-stash"
1108
- ```
1109
-
1110
- 4. Create the backup branch from current HEAD:
1111
- ```bash
1112
- git branch trdr-ds/backup-{timestamp}
1113
- ```
1114
-
1115
- 5. If stash was created in step 3, pop it back:
1116
- ```bash
1117
- git stash pop
1118
- ```
1119
-
1120
- 6. Update `DS_PROGRESS.md`:
1121
- ```
1122
- Backup branch: trdr-ds/backup-{timestamp}
1123
- Original branch: {originalBranch}
1124
- ```
1125
-
1126
- 7. Output:
1127
- ```
1128
- ✅ Backup criado: branch `trdr-ds/backup-{timestamp}`
1129
- Para desfazer toda a migração a qualquer momento: `/trdr-ds rollback`
1130
- ```
1131
-
1132
- ---
1133
-
1134
- ## Sub-fase A: Foundation
1135
-
1136
- > **Before starting:** Read `DS_ANALYSIS.md` and `DS_PROGRESS.md` from the project root.
1137
-
1138
- Update `DS_PROGRESS.md`: set `Sub-fase A: Foundation — IN_PROGRESS`.
1139
-
1140
- ### Step 1 — Create tokens.css
1141
-
1142
- Copy the local snapshot verbatim:
1143
-
1144
- ```
1145
- Read: <skill-dir>/references/tokens.css
1146
- Write: <project>/<detected-styles-dir>/tokens.css
1147
- ```
1148
-
1149
- Do NOT regenerate the file. Do NOT inline tokens from any other source. The snapshot is authoritative.
1150
-
1151
- If `references/tokens.css` is missing in the skill directory:
1152
- 1. Try `WebFetch: https://trdr.mrocontent.com.br/tokens.css`, save it to the skill dir, then proceed.
1153
- 2. If the Hub is also unreachable → STOP with error message asking the maintainer to run `npm run sync`.
1154
-
1155
- Update `DS_PROGRESS.md`:
1156
- ```
1157
- - [x] tokens.css — [path]/tokens.css
1158
- ```
1159
-
1160
- ### Step 2 — Create components.css
1161
-
1162
- Build `components.css` by concatenating the `.code.css` block of every implemented component plus the typography utility classes.
1163
-
1164
- ```
1165
- For each c in components where c.implemented === true:
1166
- append c.code.css to components.css (with a "/* === <c.name> === */" header)
1167
- ```
1168
-
1169
- After all component CSS blocks, append the text style utility classes:
1170
-
1171
- ```css
1172
- /* ==========================================================================
1173
- TRDR Design System — Text Style Utility Classes
1174
- ========================================================================== */
1175
-
1176
- /* Headings — var(--font-primary) = JetBrains Mono */
1177
- .trdr-h1 { font-family: var(--font-primary); font-size: 80px; font-weight: 500; line-height: 1.1; }
1178
- .trdr-h2 { font-family: var(--font-primary); font-size: 56px; font-weight: 500; line-height: 1.1; }
1179
- .trdr-h3 { font-family: var(--font-primary); font-size: 46px; font-weight: 700; line-height: 1.15; }
1180
- .trdr-h4 { font-family: var(--font-primary); font-size: 38px; font-weight: 500; line-height: 1.15; }
1181
- .trdr-h5 { font-family: var(--font-primary); font-size: 32px; font-weight: 500; line-height: 1.2; }
1182
- .trdr-h6 { font-family: var(--font-primary); font-size: 26px; font-weight: 500; line-height: 1.2; }
1183
- .trdr-h7 { font-family: var(--font-secondary); font-size: 22px; font-weight: 600; line-height: 1.3; }
1184
-
1185
- /* Body — var(--font-secondary) = Inter */
1186
- .trdr-body-b1 { font-family: var(--font-secondary); font-size: 18px; font-weight: 400; line-height: 1.6; }
1187
- .trdr-body-b2 { font-family: var(--font-secondary); font-size: 16px; font-weight: 500; line-height: 1.5; }
1188
- .trdr-body-b3 { font-family: var(--font-secondary); font-size: 14px; font-weight: 400; line-height: 1.5; }
1189
- .trdr-body-b4 { font-family: var(--font-secondary); font-size: 12px; font-weight: 500; line-height: 1.4; letter-spacing: 0.2px; }
1190
- .trdr-body-b5 { font-family: var(--font-secondary); font-size: 10px; font-weight: 400; line-height: 1.4; }
1191
- .trdr-body-aux { font-family: var(--font-secondary); font-size: 12px; font-weight: 400; line-height: 1.4; letter-spacing: 0.24px; }
1192
-
1193
- /* Labels — var(--font-secondary) = Inter */
1194
- .trdr-label-lg { font-family: var(--font-secondary); font-size: 16px; font-weight: 600; line-height: 1.4; }
1195
- .trdr-label-l2 { font-family: var(--font-secondary); font-size: 16px; font-weight: 600; line-height: 1.4; }
1196
- .trdr-label-l3 { font-family: var(--font-secondary); font-size: 14px; font-weight: 600; line-height: 1.4; }
1197
-
1198
- /* Mono — var(--font-mono) = Roboto Mono */
1199
- .trdr-mono { font-family: var(--font-mono); font-size: 12px; font-weight: 400; line-height: 1.4; letter-spacing: 0.04em; }
1200
- ```
1201
-
1202
- Update `DS_PROGRESS.md`:
1203
- ```
1204
- - [x] components.css — [path]/components.css
1205
- ```
1206
-
1207
- ### Step 3 — Update global CSS
1208
-
1209
- Find the main global CSS file (globals.css, main.css, index.css, app.css) and add at the very top:
1210
-
1211
- ```css
1212
- @import './tokens.css';
1213
- @import './components.css';
1214
- ```
1215
-
1216
- Adjust the relative path if tokens.css is in a subdirectory.
1217
-
1218
- If the project already imports a different design system's variables and there are naming conflicts, warn the developer before proceeding.
1219
-
1220
- Update `DS_PROGRESS.md`:
1221
- ```
1222
- - [x] @import — [global-css-file]
1223
- ```
1224
-
1225
- ### Step 4 — Create CLAUDE.md
1226
-
1227
- Create `CLAUDE.md` at the project root, populated dynamically from the catalog:
1228
-
1229
- - The list of "Pre-built component classes" must be generated from the loaded JSON's `implementedSlugs` and their CSS class prefixes (parse the first `.trdr-<prefix>` from each `c.code.css`).
1230
- - The list of "Pending stubs" should mention the count of stubs and link to MISSING_COMPONENTS.md if generated.
1231
-
1232
- Template (replace `[…]` with actual values):
1233
-
1234
- ```markdown
1235
- # [Project Name] — Context for Claude Code
1236
-
1237
- ## Design System
1238
- This project uses the TRDR Design System.
1239
- Reference Hub: https://trdr.mrocontent.com.br
1240
- Local catalog: TRDR DS v[catalog-version] ([implemented]/[total] components)
1241
-
1242
- ## Absolute Rules (never break these)
1243
- 1. NEVER use primitive tokens directly (--color-*, --space-*) — always use semantic tokens
1244
- 2. Backgrounds: --bg-primary (#0E0E0E), --bg-secondary (#141519), --bg-tertiary (#1A1A1A)
1245
- 3. Text: --content-primary (white), --content-secondary (#E8E8E8), --content-tertiary (#A4A4A4)
1246
- 4. Primary CTA: --action-brand-inverse-default (#005266) for filled buttons
1247
- 5. Fonts: --font-primary = JetBrains Mono (headings) | --font-secondary = Inter (body) | --font-mono = Roboto Mono (numbers)
1248
- 6. Spacing: always var(--spacing-xs/sm/md/lg/xl/2xl/3xl) — never hardcoded px
1249
- 7. Border radius: always var(--radius-sm/md/lg/full) — never hardcoded px
1250
- 8. Text styles: use .trdr-h1/.../h7, .trdr-body-b1/.../b5, .trdr-label-l2/l3 — never raw font-size px
1251
- 9. No colors outside the DS anywhere — rgba(), inline gradients, hardcoded hex all require a semantic token. No exceptions.
1252
-
1253
- ## Token files
1254
- - Tokens: [detected-path]/tokens.css
1255
- - Components: [detected-path]/components.css
1256
-
1257
- ## Quick reference — most used tokens
1258
- | Token | CSS Variable | Value |
1259
- |-------|-------------|-------|
1260
- | Background | --bg-primary | #0E0E0E |
1261
- | Surface | --surface-secondary | #222222 |
1262
- | Text primary | --content-primary | #FFFFFF |
1263
- | Text secondary | --content-tertiary | #A4A4A4 |
1264
- | Brand (text/icon) | --content-brand | #00A8CC |
1265
- | Primary button | --action-brand-inverse-default | #005266 |
1266
- | Border | --border-default | #4A4A4A |
1267
- | Focus ring | --border-focus | #00D4FF |
1268
- | Success | --content-success | #4FE290 |
1269
- | Error | --content-error | #F34F45 |
1270
- | Warning | --content-warning | #FFCC40 |
1271
-
1272
- ## Implemented components
1273
- [Generate from catalog: list each implemented component as a row "slug — figmaId — Hub URL"]
1274
-
1275
- ## Pending components (stubs)
1276
- [N] components in the catalog have no canonical code yet. When using one of these, the skill applies tokens and a banner comment, then logs the gap in MISSING_COMPONENTS.md. See https://trdr.mrocontent.com.br/componentes for status.
1277
-
1278
- ## Layer hierarchy
1279
- bg.primary (base) → bg.secondary/tertiary (content areas) → surface.* (cards, panels)
1280
- → interactive components → overlays/modals/tooltips
1281
-
1282
- ## Inline Styles
1283
- - **NUNCA** usar `style=""` ou `style={{}}` com propriedades de design (color, background, font, padding, margin, border)
1284
- - Exceção aceita: `background-image: url(...)` para URLs de imagem dinâmicas de dados externos
1285
- - Exceção aceita: `style="--css-var: valor"` para passar valores dinâmicos ao CSS (ex: `style="--card-delay:0.1s"`)
1286
- - Para `animation-delay` calculado: use `style="--delay: Xs"` + CSS `animation-delay: var(--delay, 0s)`
1287
- - Todos os outros valores de design devem vir de classes CSS com tokens TRDR
1288
-
1289
- ## Ícones
1290
- - HTML/Vue: `<span class="material-icons mi-sm">nome</span>` via Google Fonts CDN
1291
- - React: `<NomeIcon />` via @mui/icons-material
1292
- - Cor: SEMPRE via classe CSS com token DS (`.icon-brand`, `.icon-success`, `.icon-dim`, etc.)
1293
- - Tamanho: `.mi-2xs` (12px), `.mi-xs` (14px), `.mi-sm` (16px), default (20px), `.mi-lg` (24px), `.mi-xl` (28px), `.mi-2xl` (32px)
1294
- - Para tamanhos não padrão: `style="font-size:Npx"` (aceito APENAS para font-size de ícones, nunca para cor)
1295
- - **NUNCA** usar `<svg>` inline para ícones
1296
- - **NUNCA** usar `style=""` para cor de ícones
1297
-
1298
- ## Logo
1299
- - HTML: `<img src="logo-trdr.svg" alt="TRDR" height="24">`
1300
- - Next.js: `<Image src="/logo-trdr.svg" alt="TRDR" width={105} height={41} />`
1301
- - Vue: `<img src="/logo-trdr.svg" alt="TRDR" :height="24">`
1302
- - Inline SVG: usar o conteúdo de `references/logo-trdr.svg` (viewBox="0 0 105 41", fill="#00D4FF")
1303
- - **NUNCA** usar texto ("TRDR" em `<span>`) como logo
1304
- - **NUNCA** usar outro arquivo SVG que não seja logo-trdr.svg
1305
-
1306
- [If `stylingMode === 'mui'`, add this section to CLAUDE.md:]
1307
-
1308
- ## MUI Theme Integration
1309
- This project uses Material UI with TRDR DS tokens integrated via the theme.
1310
-
1311
- ### Rules
1312
- 1. NEVER hardcode colors in palette, sx props, or styleOverrides — always use `var(--token)`
1313
- 2. Theme file (`[themeFilePath]`) is the single source for MUI component styling — do not override via individual sx props unless necessary for one-off layout adjustments
1314
- 3. When adding new MUI components: check if a styleOverride exists in the theme's `components` section. If not, add one using DS tokens.
1315
- 4. sx props: acceptable for layout (padding, margin, display, flex) using DS spacing tokens. NOT acceptable for colors, fonts, or borders with hardcoded values.
1316
- 5. styled(MuiComponent): use `'var(--token)'` for all design values
1317
- 6. Typography: use MUI variants (h1-h6, body1, body2, etc.) — they are mapped to TRDR DS text styles in the theme
1318
- 7. tokens.css is the source of truth — the MUI theme references tokens via `var(--token)` strings
1319
- ```
1320
-
1321
- Update `DS_PROGRESS.md`:
1322
- ```
1323
- - [x] CLAUDE.md — CLAUDE.md
1324
- ```
1325
-
1326
- ### Step 5 — Generate/update MUI theme with DS tokens (only when `stylingMode === 'mui'`)
1327
-
1328
- This step creates the bridge between `tokens.css` (CSS variables source of truth) and MUI's theme system. MUI components read from the theme object, so tokens must be explicitly referenced there via `var()`.
1329
-
1330
- **Step 5a — Ensure tokens.css is imported:**
1331
- The `@import './tokens.css'` added in Step 3 makes CSS variables available to MUI's Emotion runtime. This is sufficient — Emotion styles CAN reference `var(--token)` in string values.
1332
-
1333
- **Step 5b — Create or update the MUI theme file:**
1334
-
1335
- If `themeFilePath` exists: READ the entire existing theme file. Preserve all non-DS customizations (breakpoints, transitions, zIndex, custom component logic, defaultProps, variants).
1336
-
1337
- If `themeFilePath` does NOT exist: Create a new theme file at `src/theme.ts` (or `src/theme/index.ts` if a `theme/` directory exists).
1338
-
1339
- Generate/update the theme with DS token references:
1340
-
1341
- ```typescript
1342
- import { createTheme } from '@mui/material/styles';
1343
-
1344
- const theme = createTheme({
1345
- // cssVariables: true, — recommended for MUI v6+ (enables native CSS variable support)
1346
- palette: {
1347
- mode: 'dark',
1348
- primary: {
1349
- main: 'var(--action-brand-default)', // #00D4FF
1350
- dark: 'var(--action-brand-active)', // #007D99
1351
- contrastText: 'var(--content-inverse)', // #1A1A1A
1352
- },
1353
- secondary: {
1354
- main: 'var(--action-secondary-default)', // #4A4A4A
1355
- dark: 'var(--action-secondary-active)', // #A4A4A4
1356
- contrastText: 'var(--content-primary)', // #FFFFFF
1357
- },
1358
- error: {
1359
- main: 'var(--content-error)', // #F34F45
1360
- },
1361
- warning: {
1362
- main: 'var(--content-warning)', // #FFCC40
1363
- },
1364
- success: {
1365
- main: 'var(--content-success)', // #4FE290
1366
- },
1367
- info: {
1368
- main: 'var(--content-info)', // #CCFDFF
1369
- },
1370
- background: {
1371
- default: 'var(--bg-primary)', // #0E0E0E
1372
- paper: 'var(--bg-secondary)', // #141519
1373
- },
1374
- text: {
1375
- primary: 'var(--content-primary)', // #FFFFFF
1376
- secondary: 'var(--content-secondary)', // #E8E8E8
1377
- disabled: 'var(--content-disabled)', // #4A4A4A
1378
- },
1379
- divider: 'var(--border-default)', // #4A4A4A
1380
- action: {
1381
- hover: 'var(--surface-hover, rgba(255,255,255,0.08))',
1382
- selected: 'var(--surface-brand)',
1383
- disabled: 'var(--content-disabled)',
1384
- disabledBackground: 'var(--surface-disabled)',
1385
- },
1386
- },
1387
- typography: {
1388
- fontFamily: 'var(--font-secondary)', // Inter
1389
- h1: { fontFamily: 'var(--font-primary)', fontSize: 80, fontWeight: 500, lineHeight: 1.1 },
1390
- h2: { fontFamily: 'var(--font-primary)', fontSize: 56, fontWeight: 500, lineHeight: 1.1 },
1391
- h3: { fontFamily: 'var(--font-primary)', fontSize: 46, fontWeight: 700, lineHeight: 1.15 },
1392
- h4: { fontFamily: 'var(--font-primary)', fontSize: 38, fontWeight: 500, lineHeight: 1.15 },
1393
- h5: { fontFamily: 'var(--font-primary)', fontSize: 32, fontWeight: 500, lineHeight: 1.2 },
1394
- h6: { fontFamily: 'var(--font-primary)', fontSize: 26, fontWeight: 500, lineHeight: 1.2 },
1395
- subtitle1: { fontFamily: 'var(--font-secondary)', fontSize: 22, fontWeight: 600, lineHeight: 1.3 },
1396
- body1: { fontFamily: 'var(--font-secondary)', fontSize: 16, fontWeight: 400, lineHeight: 1.5 },
1397
- body2: { fontFamily: 'var(--font-secondary)', fontSize: 14, fontWeight: 400, lineHeight: 1.5 },
1398
- caption: { fontFamily: 'var(--font-secondary)', fontSize: 12, fontWeight: 400, lineHeight: 1.4 },
1399
- overline: { fontFamily: 'var(--font-secondary)', fontSize: 10, fontWeight: 400, lineHeight: 1.4 },
1400
- button: { fontFamily: 'var(--font-secondary)', fontWeight: 600, textTransform: 'none' as const },
1401
- },
1402
- shape: {
1403
- borderRadius: 8, // --radius-md = 8px — MUI shape.borderRadius must be numeric
1404
- },
1405
- components: {
1406
- // styleOverrides are generated in Sub-fase C
1407
- },
1408
- });
1409
-
1410
- export default theme;
1411
- ```
1412
-
1413
- **MUI palette role → DS token mapping table:**
1414
-
1415
- | MUI palette key | DS token | Hex reference |
1416
- |---|---|---|
1417
- | `palette.primary.main` | `var(--action-brand-default)` | #00D4FF |
1418
- | `palette.primary.dark` | `var(--action-brand-active)` | #007D99 |
1419
- | `palette.primary.contrastText` | `var(--content-inverse)` | #1A1A1A |
1420
- | `palette.secondary.main` | `var(--action-secondary-default)` | #4A4A4A |
1421
- | `palette.secondary.dark` | `var(--action-secondary-active)` | #A4A4A4 |
1422
- | `palette.error.main` | `var(--content-error)` | #F34F45 |
1423
- | `palette.warning.main` | `var(--content-warning)` | #FFCC40 |
1424
- | `palette.success.main` | `var(--content-success)` | #4FE290 |
1425
- | `palette.info.main` | `var(--content-info)` | #CCFDFF |
1426
- | `palette.background.default` | `var(--bg-primary)` | #0E0E0E |
1427
- | `palette.background.paper` | `var(--bg-secondary)` | #141519 |
1428
- | `palette.text.primary` | `var(--content-primary)` | #FFFFFF |
1429
- | `palette.text.secondary` | `var(--content-secondary)` | #E8E8E8 |
1430
- | `palette.text.disabled` | `var(--content-disabled)` | #4A4A4A |
1431
- | `palette.divider` | `var(--border-default)` | #4A4A4A |
1432
-
1433
- **MUI typography variant → DS token mapping table:**
1434
-
1435
- | MUI variant | DS equivalent | Font family token |
1436
- |---|---|---|
1437
- | `h1` | `.trdr-h1` | `var(--font-primary)` — 80px/500 |
1438
- | `h2` | `.trdr-h2` | `var(--font-primary)` — 56px/500 |
1439
- | `h3` | `.trdr-h3` | `var(--font-primary)` — 46px/700 |
1440
- | `h4` | `.trdr-h4` | `var(--font-primary)` — 38px/500 |
1441
- | `h5` | `.trdr-h5` | `var(--font-primary)` — 32px/500 |
1442
- | `h6` | `.trdr-h6` | `var(--font-primary)` — 26px/500 |
1443
- | `subtitle1` | `.trdr-h7` | `var(--font-secondary)` — 22px/600 |
1444
- | `body1` | `.trdr-body-b2` | `var(--font-secondary)` — 16px/500 |
1445
- | `body2` | `.trdr-body-b3` | `var(--font-secondary)` — 14px/400 |
1446
- | `caption` | `.trdr-body-b4` | `var(--font-secondary)` — 12px/500 |
1447
- | `overline` | `.trdr-body-b5` | `var(--font-secondary)` — 10px/400 |
1448
- | `button` | `.trdr-label-l3` | `var(--font-secondary)` — 14px/600 |
1449
-
1450
- **MUI shape/radius → DS token mapping table:**
1451
-
1452
- | Value (px) | DS token (for CSS) | MUI shape (numeric) |
1453
- |---|---|---|
1454
- | `0` | `var(--radius-none)` | `0` |
1455
- | `2` | `var(--radius-xs)` | `2` |
1456
- | `4` | `var(--radius-sm)` | `4` |
1457
- | `8` | `var(--radius-md)` | `8` |
1458
- | `12` | — (no DS token) | `12` |
1459
- | `16` | `var(--radius-lg)` | `16` |
1460
- | `20` | `var(--radius-xl)` | `20` |
1461
- | `9999` | `var(--radius-full)` | `9999` |
1462
-
1463
- **Important MUI + CSS var() caveat:**
1464
- MUI accepts string values for palette colors. `'var(--token)'` works for rendering in MUI v5+. However, MUI internally uses `palette.primary.main` for color calculations (alpha, lighten, darken). When `main` is a `var()` string, those calculations produce invalid CSS.
1465
-
1466
- **Solution by MUI version:**
1467
- - **MUI v6+**: Add `cssVariables: true` to `createTheme()` — MUI handles CSS variables natively, calculations work
1468
- - **MUI v5 / v7 without cssVariables mode**: Provide `main`, `light`, `dark`, and `contrastText` ALL explicitly using DS tokens. Do NOT rely on MUI's auto-generated `light`/`dark` variants. Document this caveat in `CLAUDE.md` and `DS_MIGRATION.md`.
1469
-
1470
- **Step 5c — Update DS_PROGRESS.md:**
1471
- ```
1472
- - [x] MUI theme — [themeFilePath] (palette, typography, shape with DS tokens)
1473
- ```
1474
-
1475
- Update `DS_PROGRESS.md`: set `Sub-fase A: Foundation — ✅ COMPLETE`.
1476
-
1477
- Output:
1478
- ```
1479
- [If stylingMode === 'mui':]
1480
- ✅ Sub-fase A completa — tokens.css, components.css, CLAUDE.md, @import e MUI theme criados/atualizados.
1481
-
1482
- [else:]
1483
- ✅ Sub-fase A completa — tokens.css, components.css, CLAUDE.md e @import criados.
1484
-
1485
- Próximo: Sub-fase B — Violations ([total_files_with_violations] arquivos em [N] lotes de até [batch_size] cada)
1486
- Responda:
1487
- - "continuar" / "continue" — iniciar Sub-fase B
1488
- - "parar" / "stop" — salvar progresso e parar aqui
1489
- ```
1490
-
1491
- **STOP HERE. Wait for developer reply before starting Sub-fase B.**
1492
-
1493
- ---
1494
-
1495
- ## Sub-fase B: Violations
1496
-
1497
- > **Before starting:** Read `DS_ANALYSIS.md` (§ By File and § Execution Plan) and `DS_PROGRESS.md` (§ Sub-fase B) from the project root.
1498
-
1499
- Update `DS_PROGRESS.md`: set `Sub-fase B: Violations — IN_PROGRESS`.
1500
-
1501
- ### Step 5 — Migrate violations
1502
-
1503
- Process one batch at a time, always with a STOP between batches. Batch assignments come from `DS_ANALYSIS.md` § Execution Plan. Maximum [batch_size] files per batch (default: 5).
1504
-
1505
- For each batch listed as PENDING in `DS_PROGRESS.md` § Sub-fase B:
1506
-
1507
- 1. Update `DS_PROGRESS.md` — change batch status to `IN_PROGRESS`
1508
- 2. For each file in the batch:
1509
- - Apply all applicable violation fixes (see mapping tables below)
1510
- - Count violations fixed
1511
- 3. Update `DS_PROGRESS.md` — change batch status to `COMPLETED`:
1512
- ```
1513
- ### Lote [N] — [folder/] ([N] arquivos) — COMPLETED
1514
- Violações corrigidas: [N] | Arquivos: [N]/[N]
1515
- ```
1516
- Add any unfixable patterns to the "Padrões Sem Token" section of `DS_PROGRESS.md`.
1517
- 4. Output batch summary:
1518
- ```
1519
- ✅ Lote [N] concluído — [folder/] ([N] arquivos, [N] violações corrigidas)
1520
- Progresso geral: [done]/[total] lotes | [total_fixed] violações corrigidas
1521
- ```
1522
- 5. If more batches are PENDING:
1523
-
1524
- **STOP HERE.** Output:
1525
- ```
1526
- Próximo: **Lote [N+1] — [folder/]** ([N] arquivos)
1527
- Responda:
1528
- - "continuar" / "continue" — processar próximo lote
1529
- - "pular [pasta]" — skip this folder and go to the next batch
1530
- - "parar" / "stop" — save progress and stop here (resume later with `/trdr-ds resume`)
1531
- - "tudo" / "all" — process all remaining batches without pausing
1532
- ```
1533
- **Wait for developer reply.**
1534
-
1535
- If reply is `"tudo"` / `"all"`: process all remaining batches without pausing (update DS_PROGRESS.md after each).
1536
- If reply is `"pular [pasta]"`: mark that batch as SKIPPED in DS_PROGRESS.md and move to the next.
1537
- If reply is `"parar"`: set `Status: PAUSED` in DS_PROGRESS.md. STOP. Do not proceed to Step 6 or 7.
1538
-
1539
- 6. After ALL batches are COMPLETED (or skipped):
1540
-
1541
- Update `DS_PROGRESS.md`: set `Sub-fase B: Violations — ✅ COMPLETE`.
1542
-
1543
- Output:
1544
- ```
1545
- ✅ Sub-fase B completa — [total_violations_fixed] violações corrigidas em [total_files_with_violations] arquivos.
1546
-
1547
- Próximo: Sub-fase C — Components ([N] candidatos a substituição)
1548
- Responda:
1549
- - "continuar" / "continue" — iniciar Sub-fase C
1550
- - "parar" / "stop" — salvar progresso e parar aqui
1551
- ```
1552
-
1553
- **STOP HERE. Wait for developer reply before starting Sub-fase C.**
1554
-
1555
- ---
1556
-
1557
- **Violation mapping tables (used in Step 5):**
1558
-
1559
- **Color mapping (hardcoded → semantic):**
1560
- | Hardcoded value | Context | Replace with |
1561
- |----------------|---------|-------------|
1562
- | `#0E0E0E` | background | `var(--bg-primary)` |
1563
- | `#141519` | background | `var(--bg-secondary)` |
1564
- | `#1A1A1A` | background/surface | `var(--bg-tertiary)` or `var(--surface-tertiary)` |
1565
- | `#222222` | surface/border | `var(--surface-secondary)` or `var(--border-subtle)` |
1566
- | `#4A4A4A` | surface/border | `var(--surface-primary)` or `var(--border-default)` |
1567
- | `#FFFFFF` | text/bg | `var(--content-primary)` or `var(--bg-inverse)` |
1568
- | `#E8E8E8` | text | `var(--content-secondary)` |
1569
- | `#A4A4A4` | text | `var(--content-tertiary)` |
1570
- | `#00A8CC` | action/text brand | `var(--action-brand-default)` or `var(--content-brand)` |
1571
- | `#005266` | button bg CTA | `var(--action-brand-inverse-default)` |
1572
- | `#00D4FF` | focus/info | `var(--border-focus)` or `var(--content-info)` |
1573
- | `#F34F45` | error/trading | `var(--content-error)` or `var(--context-trading-down)` |
1574
- | `#4FE290` | success/trading | `var(--content-success)` or `var(--context-trading-up)` |
1575
- | `#FFCC40` | warning | `var(--content-warning)` |
1576
- | `#F57C00` | destructive | `var(--action-destructive-default)` |
1577
-
1578
- **Font mapping:**
1579
- | Hardcoded | Replace with |
1580
- |-----------|-------------|
1581
- | `font-family: 'Inter'` or `font-family: 'Inter', -apple-system, ...` | `font-family: var(--font-secondary)` |
1582
- | `font-family: 'JetBrains Mono'` or `font-family: 'JetBrains Mono', monospace` | `font-family: var(--font-primary)` |
1583
- | `font-family: 'Space Grotesk'` | `font-family: var(--font-primary)` |
1584
- | `font-family: 'Roboto Mono'` or `font-family: 'Roboto Mono', monospace` | `font-family: var(--font-mono)` |
1585
-
1586
- **Note:** System font fallbacks (`-apple-system`, `BlinkMacSystemFont`, `sans-serif`) are removed when replacing with a DS token. The token's value in tokens.css already defines the complete font stack including fallbacks — no manual fallback needed.
1587
-
1588
- **Spacing mapping:**
1589
- | Hardcoded | Replace with |
1590
- |-----------|-------------|
1591
- | `4px` | `var(--spacing-xs)` |
1592
- | `8px` | `var(--spacing-sm)` |
1593
- | `12px` | `var(--spacing-md)` |
1594
- | `16px` | `var(--spacing-lg)` |
1595
- | `20px` | `var(--spacing-xl)` |
1596
- | `24px` | `var(--spacing-2xl)` |
1597
- | `32px` | `var(--spacing-3xl)` |
1598
- | `0` / `0px` | Keep as `0` (no token needed) |
1599
- | Any other value (48px, 64px, 96px, etc.) | **Keep the value as-is** — no DS token exists for it. Flag in DS_MIGRATION.md as "Custom spacing value: [Npx] in [file:line] — consider refactoring or proposing a new token in the Hub." Do NOT invent a `--spacing-4xl` or similar that doesn't exist in tokens.css. |
1600
-
1601
- **Multi-value spacing shorthands** (`padding: 16px 32px`, `margin: 12px 0 8px`):
1602
- - Replace each value independently using the mapping above
1603
- - Example: `padding: 16px 32px` → `padding: var(--spacing-lg) var(--spacing-3xl)`
1604
- - Example: `margin: 12px 0 8px` → `margin: var(--spacing-md) 0 var(--spacing-sm)`
1605
- - If one value has no token: replace only the mappable ones; keep the others as-is and flag
1606
-
1607
- **MUI sx spacing shorthand mapping** (only when `stylingMode === 'mui'`):
1608
-
1609
- When fixing violations in MUI `sx` props, MUI uses a numeric spacing multiplier (default 8px base). Use this mapping:
1610
-
1611
- | sx prop | MUI value | Pixels | DS token (for string replacement) |
1612
- |---|---|---|---|
1613
- | `p`, `m`, `gap`, etc. | `0.5` | 4px | `'var(--spacing-xs)'` |
1614
- | `p`, `m`, `gap`, etc. | `1` | 8px | `'var(--spacing-sm)'` |
1615
- | `p`, `m`, `gap`, etc. | `1.5` | 12px | `'var(--spacing-md)'` |
1616
- | `p`, `m`, `gap`, etc. | `2` | 16px | `'var(--spacing-lg)'` |
1617
- | `p`, `m`, `gap`, etc. | `2.5` | 20px | `'var(--spacing-xl)'` |
1618
- | `p`, `m`, `gap`, etc. | `3` | 24px | `'var(--spacing-2xl)'` |
1619
- | `p`, `m`, `gap`, etc. | `4` | 32px | `'var(--spacing-3xl)'` |
1620
-
1621
- Prefer keeping MUI numeric scale when the project consistently uses it (`p: 2`, `m: 1`). Only use `'var(--spacing-*)'` string replacement when the sx value uses hardcoded px string (e.g., `padding: '16px'` instead of `p: 2`).
1622
-
1623
- **MUI-specific violation processing** (only when `stylingMode === 'mui'`):
1624
-
1625
- In addition to standard A-K violations in CSS/JSX files, process these MUI-specific violations during batch processing:
1626
-
1627
- - **Category L** (theme file): Read the theme file. For each hardcoded `#hex`, font-family, fontSize, or borderRadius value, look up in the mapping tables and replace with `'var(--token)'`. If no DS token match exists, flag in DS_MIGRATION.md.
1628
- - **Category M** (sx props): For each file with `sx={{}}` containing hardcoded values, replace colors with `'var(--token)'`, spacing with token or MUI scale, fonts with `'var(--font-*)'`, radius with `'var(--radius-*)'`.
1629
- - **Category N** (styled() calls): For each `styled(MuiComponent)()` call with hardcoded values, replace with `'var(--token)'` in the style object.
1630
-
1631
- Theme files (Category L) should be processed in the FIRST violation batch, before component files, so that theme-level tokens are in place before scanning individual components.
1632
-
1633
- **Ambiguous colors:** Use property context to decide — `background-color` → bg/surface token, `color` → content token, `border-color` → border token, `accent-color` → action token.
1634
-
1635
- **Tailwind arbitrary value colors** (only when `stylingMode: tailwind`):
1636
-
1637
- Detect in `*.tsx, *.jsx, *.html, *.vue`:
1638
- - Pattern: `(?:bg|text|border|ring|from|to|via|outline|fill|stroke)-\[#[0-9A-Fa-f]{3,8}\]`
1639
- - Also detect `hover:`, `focus:`, `active:`, `dark:` prefixed variants
1640
-
1641
- Fix strategy — apply in order of preference:
1642
-
1643
- 1. **DS class exists for element role → Opção A (DS class):**
1644
- Replace the arbitrary Tailwind classes with the DS class, keeping non-color utilities:
1645
- ```jsx
1646
- // Before
1647
- className="bg-[#005266] text-white px-4 py-2 rounded cursor-pointer"
1648
- // After
1649
- className="trdr-btn trdr-btn-primary px-4 rounded"
1650
- ```
1651
-
1652
- 2. **No DS class, but color maps to DS token → Opção B (CSS var arbitrary):**
1653
- ```jsx
1654
- // Before
1655
- className="bg-[#1A1A1A] border border-[#222222]"
1656
- // After
1657
- className="bg-[var(--bg-tertiary)] border border-[var(--border-subtle)]"
1658
- ```
1659
- Token mapping (use same color → semantic table as CSS):
1660
- - `bg-[#0E0E0E]` → `bg-[var(--bg-primary)]`
1661
- - `bg-[#141519]` → `bg-[var(--bg-secondary)]`
1662
- - `bg-[#1A1A1A]` → `bg-[var(--bg-tertiary)]`
1663
- - `text-[#FFFFFF]` → `text-[var(--content-primary)]`
1664
- - `text-[#A4A4A4]` → `text-[var(--content-tertiary)]`
1665
- - `border-[#222222]` → `border-[var(--border-subtle)]`
1666
- - `border-[#4A4A4A]` → `border-[var(--border-default)]`
1667
- - `focus:border-[#00D4FF]` → `focus:border-[var(--border-focus)]`
1668
- - `text-[#4FE290]` → `text-[var(--context-trading-up)]`
1669
- - `text-[#F34F45]` → `text-[var(--context-trading-down)]`
1670
-
1671
- 3. **Color has no DS token (e.g. `hover:bg-[#3DD980]`, `hover:bg-[#E03D3A]`):**
1672
- - Flag in DS_MIGRATION.md: "Custom hover color `#hex` — no DS token equivalent"
1673
- - Suggestion: replace with CSS hover effect: `hover:[filter:brightness(1.15)]` or use a utility class
1674
- - Do NOT invent a token or leave the hardcoded color silently
1675
-
1676
- **`accent-color` property:** Controls native checkbox/radio/range styling.
1677
- - `accent-color: #00A8CC` → `accent-color: var(--action-brand-default)`
1678
- - `accent-color: #4FE290` → `accent-color: var(--content-success)`
1679
-
1680
- **rgba() mapping:**
1681
- | Hardcoded pattern | Context | Replace with |
1682
- |-------------------|---------|-------------|
1683
- | `rgba(0,0,0,*)` | box-shadow | No TRDR shadow token exists → flag in DS_PROGRESS.md / DS_MIGRATION.md as "Missing shadow token" |
1684
- | `rgba(255,255,255,0.03–0.08)` | border / subtle divider | `var(--border-subtle)` if token exists, otherwise flag |
1685
- | `rgba(255,255,255,0.10–0.20)` | hover/hover overlay | `var(--surface-hover)` if token exists, otherwise flag |
1686
- | `rgba(255,255,255,.29)` approx | overlay/backdrop | `var(--bg-overlay)` |
1687
- | `rgba(255,255,255,*)` other | overlay | flag |
1688
- | `rgba(0,212,255,*)` | focus glow/shadow | No alpha token exists for `--border-focus` → flag as "Missing focus-alpha token" |
1689
- | `rgba(0,168,204,*)` | brand alpha bg | Use `var(--surface-brand)` if available, otherwise flag |
1690
- | `rgba(79,226,144,*)` | success alpha bg | Use `var(--surface-success)` if available, otherwise flag |
1691
- | `rgba(243,79,69,*)` | error alpha bg | Use `var(--surface-error)` if available, otherwise flag |
1692
- | `rgba(255,204,64,*)` | warning alpha bg | Use `var(--surface-warning)` if available, otherwise flag |
1693
- | Any other `rgba(N,N,N,*)` | various | Map to nearest semantic alpha token (--surface-brand, --surface-info, --action-*-alpha, etc.) or flag |
1694
-
1695
- **Gradient mapping:**
1696
-
1697
- Known TRDR gradient token values (use to match):
1698
- | Token | Approximate value |
1699
- |-------|------------------|
1700
- | `--gradient-text-brand` | `linear-gradient(90deg, var(--content-brand), var(--border-focus))` — cyan to bright-cyan, horizontal |
1701
- | `--gradient-bg-hero` | `linear-gradient(180deg, var(--bg-secondary), var(--bg-primary))` — dark vertical fade |
1702
- | `--gradient-bg-fade` | `linear-gradient(180deg, var(--bg-tertiary) 0%, transparent 100%)` — surface to transparent |
1703
-
1704
- | Pattern | Replace with |
1705
- |---------|-------------|
1706
- | Gradient whose colors map to `--content-brand` + `--border-focus` (horizontal) | `var(--gradient-text-brand)` |
1707
- | Gradient whose colors map to `--bg-secondary` → `--bg-primary` (vertical fade) | `var(--gradient-bg-hero)` |
1708
- | Gradient whose colors map to `--bg-tertiary` → transparent | `var(--gradient-bg-fade)` |
1709
- | Gradient using only TRDR bg colors but not matching any token above | Flag — add comment `/* gradient-bg-custom: consider adding to Hub */` |
1710
- | `linear-gradient(...)` using any non-DS colors | Flag — developer must decide: remove, replace with TRDR gradient token, or add new token to Hub |
1711
- | Gradient inside SVG data URI embedded in CSS | Flag |
1712
-
1713
- **Font-size mapping (bidirectional — CSS + HTML/JSX/Vue):**
1714
-
1715
- **Exception for global selectors:** If `font-size: Npx` is inside a `body {}`, `html {}`, `:root {}`, or `* {}` rule:
1716
- - **Remove the `font-size` property entirely** — do NOT add a DS class to the element
1717
- - Document in DS_MIGRATION.md: "Global font-size reset removed — TRDR DS typography classes manage sizes per-element"
1718
- - Do NOT apply DS text class to `<body>` or `<html>` tags
1719
-
1720
- When a CSS class has a `font-size` that maps to a DS text style, the fix is **two-part**:
1721
-
1722
- **Part 1 — In the CSS file**: remove the properties already provided by the DS class:
1723
- - Remove: `font-family`, `font-size`, `font-weight`, `line-height` (the DS class provides these)
1724
- - Keep: `color`, `margin`, `padding`, `text-transform`, `letter-spacing` (project-specific overrides)
1725
-
1726
- **Part 2 — In the HTML/JSX/Vue file**: add the DS class to the element that uses that CSS class:
1727
-
1728
- | stylingMode | How to add |
1729
- |-------------|-----------|
1730
- | `plain-css` / `tailwind` | `<h1 class="hero-title trdr-h2">` |
1731
- | React/Next.js | `<h1 className="hero-title trdr-h2">` |
1732
- | Vue | `<h1 class="hero-title trdr-h2">` or `:class="['hero-title', 'trdr-h2']"` |
1733
- | `css-modules` | Add `composes: trdr-h2 from global;` inside `.hero-title` in the `.module.css` |
1734
-
1735
- **CSS Modules local composition:** If a class uses `composes: AnotherClass` (without `from global`), it inherits styles from that class within the same file. When fixing:
1736
- - Add `composes: trdr-X from global` to the **base class** (AnotherClass)
1737
- - Do NOT add `composes: trdr-X from global` to the **inheriting class** — it inherits the token transitively
1738
- - Example: `.select { composes: input; }` — add `composes: trdr-text-input from global` only to `.input`, not to `.select`
1739
- - Adding `composes: trdr-X from global` to both would apply DS styles twice, causing doubled specificity
1740
-
1741
- **font-size → DS class table:**
1742
- | font-size | DS Class | Notes |
1743
- |-----------|----------|-------|
1744
- | `80px` | `.trdr-h1` | JetBrains Mono 500 |
1745
- | `56px` | `.trdr-h2` | JetBrains Mono 500 |
1746
- | `46px` | `.trdr-h3` | JetBrains Mono 700 |
1747
- | `38px` | `.trdr-h4` | JetBrains Mono 500 |
1748
- | `32px` | `.trdr-h5` | JetBrains Mono 500 |
1749
- | `26px` | `.trdr-h6` | JetBrains Mono 500 |
1750
- | `22px` | `.trdr-h7` | Inter 600 |
1751
- | `18px` | `.trdr-body-b1` | Inter 400 |
1752
- | `16px` | `.trdr-body-b2` or `.trdr-label-l2` | check font-weight: 400→b2, 600→l2 |
1753
- | `14px` | `.trdr-body-b3` or `.trdr-label-l3` | check font-weight: 400→b3, 600→l3 |
1754
- | `12px` | `.trdr-body-b4` or `.trdr-body-aux` | check letter-spacing: 0.2px→b4, 0.24px→aux |
1755
- | `10px` | `.trdr-body-b5` | Inter 400 |
1756
- | other px | nearest DS class below the value | flag in DS_MIGRATION.md |
1757
- | `font-family: var(--font-mono)` (any size) | `.trdr-mono` | Roboto Mono 400 |
1758
-
1759
- **IMPORTANT:** Always scan for the HTML element that uses the CSS class and add the DS class there. Do not only fix the CSS — the element in HTML/JSX/Vue must also receive the DS class so the typography takes effect immediately, before any cascading.
1760
-
1761
- **Do NOT replace:**
1762
- - Hex values inside binary image files (PNG, JPG, GIF)
1763
- - SVG external files — flag them but do not auto-edit
1764
- - Values in commented-out code
1765
-
1766
- **All other values MUST be replaced or flagged.** No exceptions for "decorative" gradients, shadows, or overlays.
1767
-
1768
- ---
1769
-
1770
- ## Sub-fase C: Components
1771
-
1772
- > **Before starting:** Read `DS_ANALYSIS.md` (§ Component Replacement Candidates) and `DS_PROGRESS.md` (§ Sub-fase C) from the project root.
1773
- > Also read `data/components.json` from the skill directory to have all component code blocks available.
1774
-
1775
- Update `DS_PROGRESS.md`: set `Sub-fase C: Components — IN_PROGRESS`.
1776
-
1777
- **If `stylingMode === 'mui'`: skip directly to Step 6-MUI below.** MUI projects do NOT use Pass 1/2/3 (HTML tag replacement). All visual changes come from MUI theme styleOverrides + sx prop migration.
1778
-
1779
- ### Step 6-MUI — Generate MUI component styleOverrides (only when `stylingMode === 'mui'`)
1780
-
1781
- #### Step 6-MUI.0 — DS slug to MUI component mapping
1782
-
1783
- | DS Component (slug) | MUI Component | Theme key |
1784
- |---|---|---|
1785
- | `button` | Button, IconButton, LoadingButton | `MuiButton`, `MuiIconButton`, `MuiLoadingButton` |
1786
- | `text-input` | TextField, OutlinedInput, FilledInput | `MuiTextField`, `MuiOutlinedInput` |
1787
- | `checkbox` | Checkbox | `MuiCheckbox` |
1788
- | `radio-button` | Radio | `MuiRadio` |
1789
- | `switch` | Switch | `MuiSwitch` |
1790
- | `dropdown` | Select, Autocomplete | `MuiSelect`, `MuiAutocomplete` |
1791
- | `tooltip` | Tooltip | `MuiTooltip` |
1792
- | `abas` | Tabs, Tab | `MuiTabs`, `MuiTab` |
1793
- | `card` | Card, CardContent, CardActions | `MuiCard`, `MuiCardContent` |
1794
- | `badge` | Badge, Chip | `MuiBadge`, `MuiChip` |
1795
- | `header` | AppBar, Toolbar | `MuiAppBar`, `MuiToolbar` |
1796
- | `modal` | Dialog, DialogTitle, DialogContent | `MuiDialog`, `MuiDialogTitle`, `MuiDialogContent` |
1797
-
1798
- #### Step 6-MUI.1 — Generate styleOverrides block
1799
-
1800
- For each MUI component detected in `replacementCandidates[]`:
1801
-
1802
- 1. Read the corresponding DS component from `data/components.json` — look up by slug.
1803
- 2. Extract the visual properties (colors, spacing, typography, border-radius) from its `code.css` block.
1804
- 3. Translate each CSS property into a MUI `styleOverrides` entry using DS tokens.
1805
-
1806
- **Reference template for common MUI components:**
1807
-
1808
- ```typescript
1809
- components: {
1810
- MuiButton: {
1811
- styleOverrides: {
1812
- root: {
1813
- fontFamily: 'var(--font-secondary)',
1814
- fontWeight: 600,
1815
- textTransform: 'none' as const,
1816
- borderRadius: 'var(--radius-sm)',
1817
- transition: 'all 0.15s ease',
1818
- '&:focus-visible': {
1819
- outline: '2px solid var(--border-focus)',
1820
- outlineOffset: '2px',
1821
- },
1822
- },
1823
- containedPrimary: {
1824
- backgroundColor: 'var(--action-brand-inverse-default)',
1825
- color: 'var(--content-primary)',
1826
- '&:hover': { backgroundColor: 'var(--action-brand-inverse-hover)' },
1827
- '&:active': { backgroundColor: 'var(--action-brand-inverse-active)' },
1828
- '&.Mui-disabled': {
1829
- backgroundColor: 'var(--action-brand-inverse-disabled)',
1830
- color: 'var(--content-disabled)',
1831
- },
1832
- },
1833
- outlinedPrimary: {
1834
- borderColor: 'var(--action-brand-default)',
1835
- color: 'var(--action-brand-default)',
1836
- '&:hover': {
1837
- borderColor: 'var(--action-brand-hover)',
1838
- backgroundColor: 'var(--action-brand-alpha)',
1839
- },
1840
- },
1841
- textPrimary: {
1842
- color: 'var(--action-brand-default)',
1843
- '&:hover': { backgroundColor: 'var(--action-brand-alpha)' },
1844
- },
1845
- },
1846
- },
1847
- MuiTextField: {
1848
- styleOverrides: {
1849
- root: {
1850
- '& .MuiOutlinedInput-root': {
1851
- fontFamily: 'var(--font-secondary)',
1852
- fontSize: 14,
1853
- color: 'var(--content-primary)',
1854
- '& fieldset': { borderColor: 'var(--border-default)' },
1855
- '&:hover fieldset': { borderColor: 'var(--border-strong)' },
1856
- '&.Mui-focused fieldset': { borderColor: 'var(--border-focus)' },
1857
- '&.Mui-error fieldset': { borderColor: 'var(--content-error)' },
1858
- },
1859
- '& .MuiInputLabel-root': {
1860
- color: 'var(--content-tertiary)',
1861
- fontFamily: 'var(--font-secondary)',
1862
- '&.Mui-focused': { color: 'var(--content-brand)' },
1863
- },
1864
- },
1865
- },
1866
- },
1867
- MuiCard: {
1868
- styleOverrides: {
1869
- root: {
1870
- backgroundColor: 'var(--bg-secondary)',
1871
- borderRadius: 'var(--radius-md)',
1872
- border: '1px solid var(--border-subtle)',
1873
- },
1874
- },
1875
- },
1876
- MuiTooltip: {
1877
- styleOverrides: {
1878
- tooltip: {
1879
- backgroundColor: 'var(--bg-inverse)',
1880
- color: 'var(--content-inverse)',
1881
- fontFamily: 'var(--font-secondary)',
1882
- fontSize: 12,
1883
- borderRadius: 'var(--radius-sm)',
1884
- },
1885
- arrow: { color: 'var(--bg-inverse)' },
1886
- },
1887
- },
1888
- MuiSwitch: {
1889
- styleOverrides: {
1890
- root: { width: 44, height: 24, padding: 0 },
1891
- switchBase: {
1892
- padding: 4,
1893
- '&.Mui-checked': {
1894
- color: 'var(--content-primary)',
1895
- '& + .MuiSwitch-track': {
1896
- backgroundColor: 'var(--action-brand-default)',
1897
- opacity: 1,
1898
- },
1899
- },
1900
- },
1901
- track: {
1902
- borderRadius: 'var(--radius-full)',
1903
- backgroundColor: 'var(--surface-primary)',
1904
- opacity: 1,
1905
- },
1906
- thumb: { width: 16, height: 16 },
1907
- },
1908
- },
1909
- MuiCheckbox: {
1910
- styleOverrides: {
1911
- root: {
1912
- color: 'var(--border-default)',
1913
- '&.Mui-checked': { color: 'var(--action-brand-default)' },
1914
- '&.Mui-disabled': { color: 'var(--content-disabled)' },
1915
- },
1916
- },
1917
- },
1918
- MuiRadio: {
1919
- styleOverrides: {
1920
- root: {
1921
- color: 'var(--border-default)',
1922
- '&.Mui-checked': { color: 'var(--action-brand-default)' },
1923
- },
1924
- },
1925
- },
1926
- MuiTabs: {
1927
- styleOverrides: {
1928
- indicator: { backgroundColor: 'var(--action-brand-default)' },
1929
- },
1930
- },
1931
- MuiTab: {
1932
- styleOverrides: {
1933
- root: {
1934
- fontFamily: 'var(--font-secondary)',
1935
- fontWeight: 600,
1936
- textTransform: 'none',
1937
- color: 'var(--content-tertiary)',
1938
- '&.Mui-selected': { color: 'var(--content-brand)' },
1939
- },
1940
- },
1941
- },
1942
- MuiChip: {
1943
- styleOverrides: {
1944
- root: {
1945
- fontFamily: 'var(--font-secondary)',
1946
- borderRadius: 'var(--radius-sm)',
1947
- },
1948
- colorPrimary: {
1949
- backgroundColor: 'var(--surface-brand)',
1950
- color: 'var(--content-brand)',
1951
- },
1952
- colorSuccess: {
1953
- backgroundColor: 'var(--surface-success)',
1954
- color: 'var(--content-success)',
1955
- },
1956
- colorWarning: {
1957
- backgroundColor: 'var(--surface-warning)',
1958
- color: 'var(--content-warning)',
1959
- },
1960
- colorError: {
1961
- backgroundColor: 'var(--surface-error)',
1962
- color: 'var(--content-error)',
1963
- },
1964
- },
1965
- },
1966
- MuiDialog: {
1967
- styleOverrides: {
1968
- paper: {
1969
- backgroundColor: 'var(--bg-secondary)',
1970
- borderRadius: 'var(--radius-md)',
1971
- border: '1px solid var(--border-subtle)',
1972
- },
1973
- },
1974
- },
1975
- MuiAppBar: {
1976
- styleOverrides: {
1977
- root: {
1978
- backgroundColor: 'var(--bg-secondary)',
1979
- borderBottom: '1px solid var(--border-subtle)',
1980
- boxShadow: 'none',
1981
- },
1982
- },
1983
- },
1984
- MuiSelect: {
1985
- styleOverrides: {
1986
- root: {
1987
- fontFamily: 'var(--font-secondary)',
1988
- fontSize: 14,
1989
- },
1990
- },
1991
- },
1992
- },
1993
- ```
1994
-
1995
- **IMPORTANT:** This template is a REFERENCE. For each project:
1996
- 1. Only include `MuiXxx` entries for components actually detected in `replacementCandidates[]`
1997
- 2. Read the DS component's `code.css` for accurate token values — the template above covers the most common tokens, but individual components may have specific values
1998
- 3. If the DS component has variants (e.g., button primary/secondary/ghost), map each to the appropriate MUI variant prop or className
1999
-
2000
- #### Step 6-MUI.2 — Insert styleOverrides into theme file
2001
-
2002
- Read the existing theme file (`themeFilePath`). Find the `components: {}` block (or create it if absent). Merge the generated styleOverrides:
2003
-
2004
- - If a `MuiXxx` key already exists in the theme: **MERGE** the DS overrides into the existing overrides, preserving any project-specific customizations that do not conflict with DS tokens
2005
- - If a `MuiXxx` key does NOT exist: ADD the DS override block
2006
- - **NEVER** overwrite project-specific `defaultProps`, `variants`, or slot customizations
2007
-
2008
- #### Step 6-MUI.3 — Process individual sx prop violations
2009
-
2010
- For components with `sx-migration` classification in `replacementCandidates[]`:
2011
-
2012
- 1. Read each sx prop with hardcoded values
2013
- 2. Replace with token references:
2014
- ```tsx
2015
- // Before
2016
- <Box sx={{ backgroundColor: '#141519', padding: '16px', borderRadius: '8px' }}>
2017
- // After
2018
- <Box sx={{ backgroundColor: 'var(--bg-secondary)', padding: 'var(--spacing-lg)', borderRadius: 'var(--radius-md)' }}>
2019
- ```
2020
- 3. If the sx prop becomes empty after migration (all values now come from theme), consider removing it
2021
- 4. Preserve all layout-related sx values (display, flex, grid, position) as-is
2022
-
2023
- #### Step 6-MUI.4 — Process styled(MuiComponent) violations
2024
-
2025
- For components with `styled-migration` classification:
2026
-
2027
- 1. Replace hardcoded values inside `styled()` calls with `'var(--token)'`
2028
- 2. Preserve all theme-based logic (`theme.breakpoints`, `theme.palette.*` references, `theme.spacing()`)
2029
- 3. If the styled() call uses `({ theme }) =>` destructuring: theme references will now pull from the updated theme with DS tokens — this is correct and expected
2030
-
2031
- #### Step 6-MUI.5 — Skip HTML tag replacement
2032
-
2033
- Do NOT run Pass 1/2/3 (HTML tag replacement) for MUI projects. Jump directly to updating DS_PROGRESS.md after completing Steps 6-MUI.1 through 6-MUI.4.
2034
-
2035
- Document in `DS_PROGRESS.md` each styleOverride generated and each sx prop migrated:
2036
- ```
2037
- ## Sub-fase C: Components — ✅ COMPLETE
2038
- - [x] MuiButton — styleOverrides (containedPrimary, outlinedPrimary, textPrimary)
2039
- - [x] MuiTextField — styleOverrides (root, label, fieldset states)
2040
- - [x] MuiCard — styleOverrides (root)
2041
- - [x] sx migrations: [N] files, [M] values replaced
2042
- - [x] styled() migrations: [N] files
2043
- ```
2044
-
2045
- Output:
2046
20
  ```
2047
- ✅ Sub-fase C completa — [N] MUI component styleOverrides gerados, [M] sx props migrados.
2048
-
2049
- Próximo: Sub-fase D — Final (logos, ícones, DS_MIGRATION.md)
2050
- Responda:
2051
- - "continuar" / "continue" iniciar Sub-fase D
2052
- - "parar" / "stop" salvar progresso e parar aqui
21
+ trdr-ds/
22
+ ├── SKILL.md ← YOU ARE HERE (router + sprint orchestration)
23
+ ├── phases/
24
+ │ ├── analyze.md ← Phase 1: scan project, find violations, plan sprints
25
+ │ ├── foundation.md ← Sub-fase A: tokens.css, components.css, CLAUDE.md, imports
26
+ │ ├── violations.md ← Sub-fase B: fix violations batch-by-batch
27
+ │ ├── components.md ← Sub-fase C: apply DS component classes
28
+ │ └── final.md ← Sub-fase D: logos, icons, inline styles, DS_MIGRATION.md
29
+ ├── modes/
30
+ │ ├── resume.md ← Resume from last checkpoint
31
+ │ ├── status.md ← Show sprint progress
32
+ │ ├── rollback.md ← Undo entire migration
33
+ │ ├── report.md ← Generate & send bug report
34
+ │ └── sync.md ← Re-fetch Hub snapshots
35
+ ├── data/
36
+ │ ├── components/ ← One JSON file per component (button.json, checkbox.json, ...)
37
+ │ ├── index.json ← Component catalog index (slugs, names, categories, implemented flag)
38
+ │ └── mappings.json ← Color/font/spacing/rgba/gradient mapping tables
39
+ ├── references/
40
+ │ ├── tokens.css ← All TRDR CSS variables (dark + light mode)
41
+ │ ├── rules.md ← 12 absolute rules
42
+ │ └── logo-trdr.svg ← Official TRDR logo
43
+ └── templates/
44
+ ├── ds-analysis.md ← Template for DS_ANALYSIS.md
45
+ ├── ds-progress.md ← Template for DS_PROGRESS.md
46
+ ├── sprint-plan.md ← Template for SPRINT_PLAN.md
47
+ ├── claude-md.md ← Template for project CLAUDE.md
48
+ └── ds-migration.md ← Template for DS_MIGRATION.md
2053
49
  ```
2054
50
 
2055
- **STOP HERE. Wait for developer reply before starting Sub-fase D.**
2056
-
2057
- ---
2058
-
2059
- **For non-MUI projects (`stylingMode !== 'mui'`), continue with the standard Step 6 below:**
2060
-
2061
- ### Step 6 — Implement DS components in project files
2062
-
2063
- #### Step 6.0 — Resolve dependency order
2064
-
2065
- Components in `data/components.json` may have a `dependencies` array listing slugs of sub-components they use (e.g., `boleta` depends on `["segmented-control", "text-input", "checkbox", "button", "dropdown"]`). Before processing candidates:
2066
-
2067
- 1. Read the `dependencies` field of every candidate component from `data/components.json`.
2068
- 2. Build a topological order: **atomic components** (empty `dependencies`) first, then **compound components** (non-empty `dependencies`) sorted so that each component's dependencies appear before it.
2069
- 3. Process candidates in this order across all three passes below. Within the same pass, respect the topological order.
2070
-
2071
- This ensures that when a compound component's code block imports a sub-component (e.g., `import Badge from './Badge'`), the sub-component's DS class is already installed in the project.
2072
-
2073
- If a dependency is NOT in the candidate list (i.e., no existing element in the project matched that atomic component), skip it — the compound component's code block will still reference the DS class, and the sub-component can be added later.
2074
-
2075
- ---
2076
-
2077
- Process candidates in three passes (respecting the dependency order above):
2078
- 1. **Pass 1** — Simple replacements (full DS component swap)
2079
- 2. **Pass 2** — Complex-preservable (DS structure + logic preservation)
2080
- 3. **Pass 3** — Manual review flagging (no auto-modification)
2081
-
2082
- ---
2083
-
2084
- #### Step 6 — Pass 1: Simple replacements
2085
-
2086
- For each candidate classified as `simple` in DS_ANALYSIS.md:
2087
-
2088
- 1. **Load the DS component code** from `data/components.json` — look up the component by slug and read `c.code.html` (for plain-css/tailwind projects) or `c.code.react` (for React/Next.js projects) or adapt for Vue.
2089
-
2090
- 2. **Adapt the content** — the DS component's code block has placeholder content (e.g., "Confirmar", "Badge"). Replace placeholders with the ACTUAL content from the project:
2091
- - Button text: extract the text content from the existing `<button>` element
2092
- - Input placeholder: extract the existing `placeholder` attribute
2093
- - Label text: extract the existing label/text node
2094
- - Badge text: extract the existing text content
2095
- - Preserve `id`, `name`, `data-*`, `aria-*` attributes from the original element
2096
-
2097
- 3. **Select the correct variant** using `suggestedDsVariant` from DS_ANALYSIS.md.
51
+ ## Offline-first Snapshots
2098
52
 
2099
- 4. **Replace the element in the source file** — examples by component:
53
+ - `references/tokens.css` all TRDR CSS variables, copied from Hub
54
+ - `data/components/` — individual component files with code blocks
55
+ - `data/index.json` — catalog index (lightweight, always loaded)
2100
56
 
2101
- **Buttons (slug: `button`):**
2102
- ```html
2103
- <!-- BEFORE -->
2104
- <button class="btn-primary hero-cta">Get Started</button>
2105
- <!-- AFTER -->
2106
- <button class="trdr-btn trdr-btn-primary">Get Started</button>
2107
- ```
2108
- - Remove custom CSS classes that duplicate DS styles (background, padding, height, font, border, border-radius, cursor, transition)
2109
- - Keep classes used for layout/positioning (margin, width, grid placement)
2110
- - Keep `id`, `name`, `type`, `data-*`, `aria-*` attributes
2111
-
2112
- **Text inputs (slug: `text-input`):**
2113
- ```html
2114
- <!-- BEFORE -->
2115
- <input type="text" class="search-bar" placeholder="Search...">
2116
- <!-- AFTER -->
2117
- <input type="text" class="trdr-text-input" placeholder="Search...">
2118
- ```
2119
- - If the existing input has a wrapper with icon (search icon + input), restructure to match DS anatomy:
2120
- ```html
2121
- <div class="trdr-text-input-wrapper">
2122
- <span class="material-icons mi-sm icon-muted">search</span>
2123
- <input type="text" class="trdr-text-input" placeholder="Search...">
2124
- </div>
2125
- ```
2126
-
2127
- **Checkboxes (slug: `checkbox`):**
2128
- ```html
2129
- <!-- BEFORE -->
2130
- <input type="checkbox" id="terms"> <label for="terms">Accept terms</label>
2131
- <!-- AFTER -->
2132
- <label class="trdr-checkbox">
2133
- <input type="checkbox" id="terms" />
2134
- <span class="trdr-checkbox-box"></span>
2135
- <span>Accept terms</span>
2136
- </label>
2137
- ```
2138
- - DS checkbox requires a specific DOM structure (label > input + box-span + text-span)
2139
- - Preserve `id`, `name`, `checked`, `disabled` attributes from the original input
2140
-
2141
- **Radio buttons (slug: `radio-button`):**
2142
- Similar to checkbox — restructure to DS anatomy while preserving `name`, `value`, `checked`.
2143
-
2144
- **Switches (slug: `switch`):**
2145
- ```html
2146
- <!-- BEFORE -->
2147
- <div class="toggle"><input type="checkbox"></div>
2148
- <!-- AFTER -->
2149
- <button class="trdr-switch" role="switch" aria-checked="false">
2150
- <span class="trdr-switch-track"><span class="trdr-switch-knob"></span></span>
2151
- <span>Label text</span>
2152
- </button>
2153
- ```
2154
-
2155
- **Dropdowns (slug: `dropdown`):**
2156
- ```html
2157
- <!-- BEFORE -->
2158
- <select class="lang-selector"><option>PT</option><option>EN</option></select>
2159
- <!-- AFTER -->
2160
- <select class="trdr-dropdown"><option>PT</option><option>EN</option></select>
2161
- ```
2162
- - Preserve all `<option>` children, `name`, `id`, `value` attributes
2163
-
2164
- **Badges (slug: `badge`):**
2165
- ```html
2166
- <!-- BEFORE -->
2167
- <span class="badge badge-success">Active</span>
2168
- <!-- AFTER -->
2169
- <span class="trdr-badge trdr-badge-success">Active</span>
2170
- ```
2171
- - Detect variant from existing color/class: green/success → `trdr-badge-success`, blue/brand → `trdr-badge-brand`, etc.
2172
-
2173
- **Segmented controls / tabs (slug: `segmented-control`, `abas`):**
2174
- ```html
2175
- <!-- BEFORE -->
2176
- <div class="tabs">
2177
- <button class="tab active">Tab 1</button>
2178
- <button class="tab">Tab 2</button>
2179
- </div>
2180
- <!-- AFTER -->
2181
- <div class="trdr-segment-control">
2182
- <button class="trdr-segment trdr-segment-active">Tab 1</button>
2183
- <button class="trdr-segment trdr-segment-inactive">Tab 2</button>
2184
- </div>
2185
- ```
2186
-
2187
- **Tooltips (slug: `tooltip`):**
2188
- - If `title=""` attribute: remove `title`, add DS tooltip structure around the element
2189
- - If `data-tooltip=""`: adapt to DS tooltip pattern
2190
- - Preserve the tooltip content text
2191
-
2192
- 5. **Icons inside replaced components:** When the original element contained an inline SVG icon (e.g., Button with search icon), replace that SVG immediately with a Material Icon `<span>` using the correct size class from Step 6.6c-2 rules. Do NOT leave inline SVGs inside new DS component structures — this is an exception to "SVG replacement happens in Sub-fase D."
2193
-
2194
- 6. **Clean up redundant CSS** — for each replaced element's custom class, remove properties now provided by DS:
2195
- - Remove: `height`, `padding`, `font-family`, `font-size`, `font-weight`, `border`, `border-radius`, `background`, `color`, `cursor`, `transition`, `display`, `align-items`, `justify-content`
2196
- - Keep: `width`, `min-width`, `gap`, position-specific props, state overrides, layout props (margin, grid-area)
2197
-
2198
- 7. **Document in DS_PROGRESS.md** each replacement:
2199
- ```
2200
- - [x] button: src/Hero.tsx:42 — "Get Started" → trdr-btn-primary (simple swap)
2201
- ```
57
+ Snapshots synced via `npm run sync` in trdr-plugins repo. **Always prefer local snapshots.** Only fetch from Hub when user passes `--latest` or runs `sync`.
2202
58
 
2203
59
  ---
2204
60
 
2205
- #### Step 6 — Pass 2: Complex-preservable replacements
2206
-
2207
- For each candidate classified as `complex-preservable` in DS_ANALYSIS.md:
2208
-
2209
- 1. **Read the full element context** — read the file and identify all:
2210
- - Event handlers: `onClick`, `onChange`, `onSubmit`, `onKeyDown`, `onFocus`, `onBlur`, etc.
2211
- - Conditional rendering: ternary expressions, `&&` conditionals
2212
- - Dynamic props: `className={...}`, `style={...}`, spread props `{...rest}`
2213
- - Data bindings: `value={state}`, `checked={state}`, `ref={ref}`
2214
-
2215
- 2. **Apply DS structure while preserving all logic, using one of two strategies:**
2216
-
2217
- **Strategy A — Class addition (when existing DOM structure is compatible with DS):**
2218
- The element's DOM structure is close enough to the DS component. Add DS classes and remove conflicting custom CSS.
2219
- ```tsx
2220
- // BEFORE
2221
- <button
2222
- className={`btn ${isActive ? 'btn-active' : ''}`}
2223
- onClick={handleClick}
2224
- disabled={isLoading}
2225
- >
2226
- {isLoading ? 'Loading...' : 'Submit'}
2227
- </button>
2228
-
2229
- // AFTER — DS classes added, handlers/bindings preserved
2230
- <button
2231
- className={`trdr-btn trdr-btn-primary ${isActive ? 'btn-active' : ''}`}
2232
- onClick={handleClick}
2233
- disabled={isLoading}
2234
- >
2235
- {isLoading ? 'Loading...' : 'Submit'}
2236
- </button>
2237
- ```
61
+ ## Argument Routing
2238
62
 
2239
- **Strategy B Structure wrap (when DS component requires different DOM structure):**
2240
- The element needs DS DOM structure but has logic that must stay.
2241
- ```tsx
2242
- // BEFORE checkbox with complex state
2243
- <div className="filter-option">
2244
- <input
2245
- type="checkbox"
2246
- id={`filter-${id}`}
2247
- checked={filters.includes(id)}
2248
- onChange={() => toggleFilter(id)}
2249
- />
2250
- <label htmlFor={`filter-${id}`}>{label}</label>
2251
- </div>
63
+ | Arg | Action | File to Read |
64
+ |-----|--------|-------------|
65
+ | *(none)* / `analyze` | Scan project, generate plan | `phases/analyze.md` |
66
+ | `apply` | Analyze + execute all phases | `phases/analyze.md` → then route per sprint |
67
+ | `foundation` | Sub-fase A only | `phases/foundation.md` |
68
+ | `violations` | Sub-fase B only | `phases/violations.md` |
69
+ | `components` | Sub-fase C only | `phases/components.md` |
70
+ | `final` | Sub-fase D only | `phases/final.md` |
71
+ | `resume` | Continue from checkpoint | `modes/resume.md` |
72
+ | `status` | Show progress table | `modes/status.md` |
73
+ | `sync` | Re-fetch Hub data | `modes/sync.md` |
74
+ | `rollback` | Undo migration | `modes/rollback.md` |
75
+ | `report` | Send bug report | `modes/report.md` |
76
+ | `batch N` | Override batch size | Set batch_size=N, then route as `apply` |
77
+ | `--latest` | Sync first, then continue | Run `modes/sync.md` first, then route normally |
2252
78
 
2253
- // AFTER — DS checkbox structure, ALL logic preserved
2254
- <label className="trdr-checkbox">
2255
- <input
2256
- type="checkbox"
2257
- id={`filter-${id}`}
2258
- checked={filters.includes(id)}
2259
- onChange={() => toggleFilter(id)}
2260
- />
2261
- <span className="trdr-checkbox-box"></span>
2262
- <span>{label}</span>
2263
- </label>
2264
- ```
79
+ **Routing procedure:**
2265
80
 
2266
- 3. **NEVER remove or alter any of the following** (absolute rule):
2267
- - `onClick`, `onChange`, `onSubmit`, `onKeyDown`, `onFocus`, `onBlur` handlers
2268
- - `ref=`, `key=` props
2269
- - `disabled={condition}`, `checked={condition}`, `value={state}` bindings
2270
- - Conditional rendering (`{condition && ...}`, `{condition ? ... : ...}`)
2271
- - Spread props (`{...rest}`, `{...props}`)
2272
- - `id`, `name`, `data-*`, `aria-*` attributes
2273
- - Custom `className` parts used in JS selectors (`querySelector`, `classList.toggle`)
2274
-
2275
- 4. **For dynamically-toggled classes** (e.g., `classList.toggle('active')`):
2276
- - Map the custom state class to a DS state class
2277
- - Update ALL `classList.toggle/add/remove` calls to also toggle the DS class
2278
- - Example: `el.classList.toggle('active')` → also add `el.classList.toggle('trdr-segment-active')`
2279
-
2280
- 5. **Clean up redundant CSS** — same rules as Pass 1 step 6.
2281
-
2282
- 6. **Document in DS_PROGRESS.md:**
2283
- ```
2284
- - [x] checkbox: src/Filters.tsx:88 — preserved: onChange, checked binding → trdr-checkbox (complex-preservable, Strategy B)
2285
- ```
81
+ 1. Parse the argument from the user's invocation
82
+ 2. Run the version check (Step 0 below)
83
+ 3. Read **ONLY** the file indicated in the table above
84
+ 4. Execute the instructions in that file
85
+ 5. When a phase completes and the next phase should run, read the NEXT file — never preload
2286
86
 
2287
87
  ---
2288
88
 
2289
- #### Step 6Pass 3: Manual review flagging
2290
-
2291
- For each candidate classified as `complex-manual` in DS_ANALYSIS.md:
2292
-
2293
- 1. **Do NOT modify** the source file's component structure.
2294
-
2295
- 2. **Add a TODO comment** in the source file above the element:
2296
- ```
2297
- <!-- TODO: TRDR DS — replace with [c.name] component. See DS_MIGRATION.md for details. -->
2298
- ```
2299
- For React/JSX:
2300
- ```
2301
- {/* TODO: TRDR DS — replace with [c.name] component. See DS_MIGRATION.md for details. */}
2302
- ```
2303
-
2304
- 3. **Add an entry to `DS_MIGRATION.md`** under `## Manual component review`:
2305
- ```markdown
2306
- ### [file:line] — [c.name]
2307
- - **Reason:** [brief description of complexity]
2308
- - **Existing structure:** [brief DOM outline]
2309
- - **Suggested DS component:** [slug] ([variant])
2310
- - **Suggested approach:** Strategy A (class addition) / Strategy B (structure wrap) / custom adaptation
2311
- - **Handlers to preserve:** [list of event handlers found]
2312
- - **Dynamic props:** [list of dynamic bindings]
2313
- ```
2314
-
2315
- ---
89
+ ## Step 0Version Check (runs on EVERY invocation)
2316
90
 
2317
- #### Step 6 — Stubs and unmapped patterns
91
+ ```bash
92
+ npm show trdr-ds-install version 2>/dev/null
93
+ ```
2318
94
 
2319
- **If `c.implemented === false`** (stub — not yet implemented in DS):
2320
- - Add this banner comment above the affected element in the source file:
95
+ - If fails or empty: skip silently
96
+ - If registry == local (2.0.0): skip silently
97
+ - If registry > local:
2321
98
  ```
2322
- /* TRDR DS <c.name> (figmaId: <c.figmaId>) */
2323
- /* Implementação canônica pendente. Consulte https://trdr.mrocontent.com.br/componentes/<c.slug> */
2324
- /* Tokens recomendados: <list c.tokens[].token> */
99
+ Nova versao da skill disponivel: trdr-ds-install@[registry] (instalada: 2.0.0)
100
+
101
+ - "atualizar" / "update" instalar agora (requer reiniciar /trdr-ds)
102
+ - "continuar" / "skip" — usar versao atual
2325
103
  ```
2326
- - Append an entry to `MISSING_COMPONENTS.md`:
2327
- ```markdown
2328
- ## <c.name>
2329
- - Slug: `<c.slug>` | figmaId: `<c.figmaId>` | Category: `<c.category>`
2330
- - Found in: <list of file:line>
2331
- - Description: <c.description>
2332
- - Recommended tokens: <c.tokens[]>
2333
- - Status: ⚠️ stub — code blocks pending
2334
- ```
2335
-
2336
- **If no slug matches** the detected pattern:
2337
- - Flag the pattern in `MISSING_COMPONENTS.md` under "Unmapped patterns" with the file location and a one-line description of the UI need.
2338
-
2339
- **Do NOT replace domain-specific components** (course cards, lesson rows, trading panels, etc.) — document them as "sem equivalente DS".
2340
-
2341
- ---
2342
-
2343
- #### Step 6 — Final: Update progress
2344
-
2345
- Update `DS_PROGRESS.md`: set `Sub-fase C: Components — ✅ COMPLETE` and add summary:
2346
- ```
2347
- ### Componentes DS Aplicados
2348
- Simple swaps: [S]
2349
- Complex-preservable: [P]
2350
- Manual review: [M] (see DS_MIGRATION.md)
2351
- Stubs: [T]
2352
- Total: [S+P+M+T] candidates processed
2353
-
2354
- [List each replacement with its classification]
2355
- ```
2356
-
2357
- Output:
2358
- ```
2359
- ✅ Sub-fase C completa — [N] componentes DS implementados ([S] simple, [P] complex-preservable), [M] flagged para revisão manual, [T] stubs marcados.
2360
-
2361
- Próximo: Sub-fase D — Final (logos + ícones + DS_MIGRATION.md)
2362
- Responda:
2363
- - "continuar" / "continue" — finalizar migração
2364
- - "parar" / "stop" — salvar progresso e parar aqui
2365
- ```
2366
-
2367
- **STOP HERE. Wait for developer reply before starting Sub-fase D.**
2368
-
2369
- ---
2370
-
2371
- ## Sub-fase D: Final
2372
-
2373
- > **Before starting:** Read `DS_ANALYSIS.md` (§ Logo Audit) and `DS_PROGRESS.md` from the project root.
2374
-
2375
- Update `DS_PROGRESS.md`: set `Sub-fase D: Final — IN_PROGRESS`.
2376
-
2377
- ### Step 6.5 — Replace wrong logos and fix logo usage in HTML/JSX
2378
-
2379
- **Step 6.5a — Replace the SVG file on disk:**
2380
-
2381
- Load the official TRDR logo from the skill directory:
2382
- ```
2383
- Read: <skill-dir>/references/logo-trdr.svg
2384
- ```
2385
-
2386
- Where `<skill-dir>` is `~/.claude/skills/trdr-ds/` or `<project>/.claude/skills/trdr-ds/`. Try both.
2387
-
2388
- If `references/logo-trdr.svg` is missing from the skill directory → STOP with:
2389
- > ❌ Logo reference missing. Run `npx trdr-ds-install@latest` to restore it.
2390
-
2391
- For each file in `logoAudit.wrong`:
2392
- - Overwrite the file in place with the official logo content (same path, same filename).
2393
- - Report: `✅ Replaced [path] with official TRDR logo (105×41px, #00D4FF)`
2394
-
2395
- If no logo files were found AND `public/` exists at the project root:
2396
- - Write the official logo to `public/logo-trdr.svg`.
2397
- - Report: `✅ Added official TRDR logo → public/logo-trdr.svg`
2398
-
2399
- If no logo files found AND no `public/` exists:
2400
- - Log in DS_MIGRATION.md under "Manual steps": "Add logo-trdr.svg to your assets directory. Reference: <skill-dir>/references/logo-trdr.svg"
2401
-
2402
- **Never modify correct logos** (`logoAudit.correct`) — they already match the official reference.
104
+ STOP. Wait for reply.
105
+ If update: run `npx trdr-ds-install@latest`, output success, STOP.
2403
106
 
2404
107
  ---
2405
108
 
2406
- **Step 6.5b Fix logo usage in HTML/JSX/Vue (Category K violations):**
109
+ ## Sprint Orchestration (Critical for Context Management)
2407
110
 
2408
- After the SVG is on disk, scan for incorrect logo usage in HTML/JSX/Vue files and replace by framework:
111
+ ### The Problem
112
+ Large projects generate hundreds of violations across dozens of files. Processing everything in a single context window causes hallucination, missed mappings, and incomplete work.
2409
113
 
2410
- **Plain HTML:**
2411
- - `<span [class]>TRDR</span>` used as logo → `<img src="logo-trdr.svg" alt="TRDR" height="[N]">` (preserve the original height or use 24px default)
2412
- - `<img src="[any-non-official-logo]">` update `src` to `"logo-trdr.svg"`
2413
- - Remove any `style=""` attribute from the logo element after replacement
114
+ ### The Solution: Sprints
115
+ Every migration is split into **self-contained sprints** (defined in `SPRINT_PLAN.md`). Each sprint:
116
+ - Processes at most **15 files**
117
+ - Has a single clear scope (one phase or one folder of violations)
118
+ - Reads state from files, NEVER from conversation memory
119
+ - Saves all progress to `DS_PROGRESS.md`
120
+ - Ends with a STOP checkpoint
2414
121
 
2415
- **React / Next.js:**
2416
- - `import Logo from './[non-official-logo]'` → `import LogoTrdr from './logo-trdr.svg'` (or from `@/public/logo-trdr.svg`)
2417
- - `<Image src="[non-official]" />` → `<Image src="/logo-trdr.svg" alt="TRDR" />`
2418
- - `<span>TRDR</span>` in a logo context → `<Image src="/logo-trdr.svg" alt="TRDR" height={24} width={105} />`
2419
- - Remove `style={{...}}` from the logo element after replacement
122
+ ### Context Clearing Protocol
2420
123
 
2421
- **Vue / Nuxt:**
2422
- - `:src="[non-official-logo-var]"` → update to `"/logo-trdr.svg"` (static string)
2423
- - `<span>TRDR</span>` → `<img src="/logo-trdr.svg" alt="TRDR" :height="24" />`
124
+ **After every sprint, output this block:**
2424
125
 
2425
- Update `DS_PROGRESS.md`:
2426
- ```
2427
- - [x] logos incorretos substituídos — [N] SVG replaced, [M] HTML usages fixed, [P] already correct
2428
126
  ```
127
+ --- SPRINT [N] COMPLETO ---
2429
128
 
2430
- ### Step 6.6 Replace inline SVG icons with icon library (Category J violations)
2431
-
2432
- If Category J detected inline `<svg>` elements that are not the TRDR logo:
2433
-
2434
- **Step 6.6a — Detect and install icon library by framework:**
2435
-
2436
- | Framework | Library | Detection | Action if missing |
2437
- |-----------|---------|-----------|-------------------|
2438
- | Plain HTML | Material Icons (CDN) | Check `<link>` in `<head>` for `fonts.googleapis.com/icon` | Add CDN link to `<head>` |
2439
- | React/Next.js | @mui/icons-material | Check `package.json` | Suggest: `npm install @mui/icons-material` — do not install automatically |
2440
- | Vue | via CDN or vue-material-icons | Check `<link>` in template/index.html | Add CDN link |
2441
-
2442
- For plain HTML and Vue (CDN approach), add to `<head>`:
2443
- ```html
2444
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
2445
- ```
129
+ [Brief summary of what was done]
2446
130
 
2447
- **Step 6.6b Add icon CSS helpers (plain HTML / Vue CDN only):**
131
+ Progresso: [done]/[total] sprints ([percentage]%)
132
+ Proximo: Sprint [N+1] — [name]
2448
133
 
2449
- Add to the project's main CSS:
2450
- ```css
2451
- /* Material Icons helpers — TRDR DS */
2452
- .material-icons {
2453
- font-size: 20px; /* default = mi-md */
2454
- display: inline-flex;
2455
- align-items: center;
2456
- color: inherit;
2457
- user-select: none;
2458
- }
2459
- .mi-2xs { font-size: 12px; } /* very small indicators */
2460
- .mi-xs { font-size: 14px; } /* compact UI */
2461
- .mi-sm { font-size: 16px; } /* small icons */
2462
- /* .mi-md — 20px — default, no class needed */
2463
- .mi-lg { font-size: 24px; } /* standard Material Design size */
2464
- .mi-xl { font-size: 28px; } /* larger icons */
2465
- .mi-2xl { font-size: 32px; } /* hero/feature icons */
2466
- ```
134
+ IMPORTANTE: Para melhor resultado no proximo sprint,
135
+ limpe o contexto agora com /clear e depois execute:
136
+ /trdr-ds resume
2467
137
 
2468
- **Step 6.6c Add icon color classes** (do NOT use inline style for icon color — create CSS classes instead):
2469
- ```css
2470
- .icon-brand { color: var(--content-brand); }
2471
- .icon-success { color: var(--context-trading-up); }
2472
- .icon-error { color: var(--content-error); }
2473
- .icon-warning { color: var(--content-warning); }
2474
- .icon-dim { color: var(--content-disabled); }
2475
- .icon-muted { color: var(--content-tertiary); }
138
+ Isto libera a janela de contexto e evita alucinacoes.
139
+ Se preferir continuar sem limpar: "continuar"
2476
140
  ```
2477
141
 
2478
- **Step 6.6c-2 Measure original SVG dimensions before replacement:**
2479
-
2480
- For EACH inline `<svg>` element that will be replaced, determine the original rendered size:
2481
-
2482
- 1. **Read the SVG's explicit size** — check for `width` and `height` attributes:
2483
- ```html
2484
- <svg width="24" height="24" ...> → originalSize = 24
2485
- <svg width="16" height="16" ...> → originalSize = 16
2486
- ```
2487
- Use the `width` attribute value (icons are typically square). If `width` and `height` differ, use the larger value.
2488
-
2489
- 2. **If no width/height attributes** — check the `viewBox`:
2490
- ```html
2491
- <svg viewBox="0 0 24 24" ...> → originalSize = 24 (4th value = viewBox height)
2492
- ```
2493
-
2494
- 3. **If no explicit size and no viewBox** — check CSS for the SVG's container:
2495
- - Look for the SVG's parent element class or the SVG's own class
2496
- - Search CSS files for `width`, `height`, or `font-size` applied to that selector
2497
- - Example: `.icon { width: 18px; height: 18px; }` → originalSize = 18
2498
-
2499
- 4. **If still undetermined** — assume 20px (the DS default) and add a comment:
2500
- ```html
2501
- <!-- TODO: verify icon size — original SVG had no explicit dimensions -->
2502
- ```
2503
-
2504
- 5. **Map originalSize to the correct size class/style:**
142
+ **STOP. Wait for developer reply.**
2505
143
 
2506
- | Original SVG size | Replacement class/style | Notes |
2507
- |---|---|---|
2508
- | 12px | `.mi-2xs` | Very small indicator |
2509
- | 14px | `.mi-xs` | Compact UI |
2510
- | 16px | `.mi-sm` | Small icons |
2511
- | 18px | `style="font-size:18px"` | Between sm and md — no standard class |
2512
- | 20px | *(none — default)* | No class needed |
2513
- | 22px | `style="font-size:22px"` | Between md and lg — no standard class |
2514
- | 24px | `.mi-lg` | Standard Material Design size |
2515
- | 28px | `.mi-xl` | Larger icons |
2516
- | 32px | `.mi-2xl` | Hero/feature icons |
2517
- | Any other Npx | `style="font-size:Npx"` | Exact size preservation |
144
+ - If developer says "continuar": proceed to next sprint (warn that quality may degrade)
145
+ - If developer clears context and runs `/trdr-ds resume`: the resume mode reads all state from files
2518
146
 
2519
- **Priority:** Use a size class if one matches exactly. Only use inline `font-size` for non-standard sizes. NEVER use inline `style="color:..."` — color is ALWAYS via CSS class (Rule 11).
147
+ ### Sprint State Files
2520
148
 
2521
- **Step 6.6d Map SVG content to icon names:**
149
+ Three files at the project root serve as the "database" for the migration:
2522
150
 
2523
- Analyze the SVG path/shape content to identify the icon:
2524
- | SVG shape/content | Material Icon name |
2525
- |---|---|
2526
- | Circle + diagonal line (magnifying glass) | `search` |
2527
- | X / diagonal paths (close) | `close` |
2528
- | Left arrow / chevron | `chevron_left` or `arrow_back` |
2529
- | Right arrow / chevron | `chevron_right` or `arrow_forward` |
2530
- | Triangle play | `play_arrow` |
2531
- | Square stop | `stop` |
2532
- | Padlock | `lock` |
2533
- | Checkmark | `check` |
2534
- | Star | `star` |
2535
- | Three horizontal lines (hamburger) | `menu` |
2536
- | Plus sign | `add` |
2537
- | Warning triangle | `warning` |
2538
- | Info circle | `info` |
2539
- | Bell | `notifications` |
2540
- | User/person | `person` |
2541
- | Gear/cog | `settings` |
2542
- | Trash | `delete` |
2543
- | Pencil/edit | `edit` |
151
+ | File | Purpose | When to Read |
152
+ |------|---------|-------------|
153
+ | `DS_ANALYSIS.md` | Full analysis (violations, candidates, logo audit) | At sprint start — read ONLY the section relevant to current sprint |
154
+ | `SPRINT_PLAN.md` | Sprint definitions and status | At sprint start — find current sprint |
155
+ | `DS_PROGRESS.md` | Execution log, batch status, overall progress | At sprint start and after every action |
2544
156
 
2545
- For SVG icons that cannot be mapped automatically: leave a `<!-- TODO: replace with Material Icon: [description] -->` comment and document in DS_MIGRATION.md.
157
+ **NEVER read the entire DS_ANALYSIS.md at once for large projects.** Only read the section needed for the current sprint.
2546
158
 
2547
- **Step 6.6e Replace by framework (with size preservation):**
2548
-
2549
- Use the `originalSize` measured in Step 6.6c-2 to select the correct size class or inline font-size.
2550
-
2551
- | Framework | Standard size (has class) | Non-standard size (no class) |
2552
- |-----------|--------------------------|------------------------------|
2553
- | Plain HTML | `<span class="material-icons {sizeClass}">icon_name</span>` | `<span class="material-icons" style="font-size:{N}px">icon_name</span>` |
2554
- | React (CDN) | `<span className="material-icons {sizeClass}">icon_name</span>` | `<span className="material-icons" style={{fontSize:{N}}}>icon_name</span>` |
2555
- | React (@mui) | `<IconName sx={{ fontSize: {originalSize} }} />` (omit `sx` if 24px — @mui default) | Same — @mui always uses `sx.fontSize` |
2556
- | Vue (CDN) | `<span class="material-icons {sizeClass}">icon_name</span>` | `<span class="material-icons" style="font-size:{N}px">icon_name</span>` |
2557
-
2558
- **Examples with size + color combined:**
2559
- ```html
2560
- <!-- Original: 16×16 search icon with brand color -->
2561
- <svg width="16" height="16"><path d="M..." stroke="#00A8CC"/></svg>
2562
- <!-- Replacement: class mi-sm (16px) + class icon-brand -->
2563
- <span class="material-icons mi-sm icon-brand">search</span>
2564
-
2565
- <!-- Original: 24×24 close icon, neutral color (currentColor) -->
2566
- <svg width="24" height="24"><path d="M..." stroke="currentColor"/></svg>
2567
- <!-- Replacement: class mi-lg (24px), no color class (inherits) -->
2568
- <span class="material-icons mi-lg">close</span>
2569
-
2570
- <!-- Original: 20×20 icon (default size) -->
2571
- <svg width="20" height="20" viewBox="0 0 20 20"><path d="M..."/></svg>
2572
- <!-- Replacement: no size class needed (20px is default) -->
2573
- <span class="material-icons">settings</span>
2574
-
2575
- <!-- Original: 18×18 icon (non-standard size) -->
2576
- <svg width="18" height="18" viewBox="0 0 18 18"><path d="M..."/></svg>
2577
- <!-- Replacement: inline font-size for non-standard size -->
2578
- <span class="material-icons" style="font-size:18px">settings</span>
2579
-
2580
- <!-- React @mui — 16px icon with brand color -->
2581
- <SearchIcon className="icon-brand" sx={{ fontSize: 16 }} />
2582
- ```
159
+ ### Sprint Lifecycle (EVERY sprint follows this)
2583
160
 
2584
- **Color of icon**ALWAYS via class, NEVER inline style:
2585
- ```html
2586
- <!-- Correct -->
2587
- <span class="material-icons mi-xs icon-success">check</span>
2588
- <!-- Wrong never do this -->
2589
- <span class="material-icons" style="color: var(--context-trading-up)">check</span>
2590
- ```
161
+ 1. Read `SPRINT_PLAN.md`find current sprint (first PENDING or IN_PROGRESS)
162
+ 2. Read relevant section of `DS_ANALYSIS.md`
163
+ 3. Read `DS_PROGRESS.md` for current state
164
+ 4. Update SPRINT_PLAN.md: set current sprint `Status: IN_PROGRESS`
165
+ 5. Read the phase file for this sprint's sub-fase (from `phases/`)
166
+ 6. Execute the sprint's scope
167
+ 7. Update DS_PROGRESS.md with results
168
+ 8. Update SPRINT_PLAN.md: set current sprint `Status: COMPLETE`
169
+ 9. Output sprint summary with context clearing protocol
170
+ 10. **STOP**
2591
171
 
2592
172
  ---
2593
173
 
2594
- ### Step 6.7 — Eliminate inline styles (Category I violations)
2595
-
2596
- For each `style=""` / `style={{}}` violation detected in Category I:
2597
-
2598
- **Decision tree:**
2599
-
2600
- 1. **Dynamic image URL** → keep as-is (acceptable exception):
2601
- ```html
2602
- style="background-image: url('data/image.jpg')" ✅ keep
2603
- ```
2604
-
2605
- 2. **CSS custom property for dynamic value** → keep as-is (acceptable pattern):
2606
- ```html
2607
- style="--card-delay: 0.1s" ✅ keep
2608
- style={{ '--delay': animDelay }} ✅ keep
2609
- ```
2610
-
2611
- 3. **`animation-delay` with calculated value** → convert to CSS custom property:
2612
- ```html
2613
- <!-- Before -->
2614
- style="animation-delay: 0.15s"
2615
- <!-- After -->
2616
- style="--delay: 0.15s"
2617
- ```
2618
- Then add to CSS: `animation-delay: var(--delay, 0s);`
2619
-
2620
- 4. **`background-size` / `background-position` alongside `background-image`** → move to CSS:
2621
- ```css
2622
- /* Add selector that matches elements with background-image inline style */
2623
- .element[style*="background-image"] { background-size: cover; background-position: center; }
2624
- ```
2625
-
2626
- 5. **Design token value as inline style** → create a CSS class:
2627
- | Inline style | Action |
2628
- |---|---|
2629
- | `style="color: #hex"` | Create `.text-[name] { color: var(--semantic-token); }` and add class |
2630
- | `style="background: #hex"` | Create `.bg-[name] { background: var(--semantic-token); }` and add class |
2631
- | `style="font-family: X"` | Remove (handled by typography DS class from Step 5F) |
2632
- | `style="padding: Npx"` | Create `.p-[name] { padding: var(--spacing-*); }` or use existing utility |
174
+ ## Component Loading Protocol
2633
175
 
2634
- **By framework:**
176
+ Components are stored as individual JSON files in `data/components/`.
2635
177
 
2636
- Plain HTML:
2637
- ```html
2638
- <!-- Before -->
2639
- <span style="color: var(--teal)">TRDR</span>
2640
- <!-- After -->
2641
- <span class="text-brand">TRDR</span>
2642
- <!-- + CSS: .text-brand { color: var(--content-brand); } -->
178
+ **To load a component:**
2643
179
  ```
2644
-
2645
- React/Next.js:
2646
- ```jsx
2647
- // Before
2648
- <span style={{ color: '#00D4FF' }}>TRDR</span>
2649
- // After
2650
- <span className="text-brand">TRDR</span>
2651
- // + CSS: .text-brand { color: var(--content-brand); }
2652
- ```
2653
-
2654
- Vue:
2655
- ```html
2656
- <!-- Before -->
2657
- <span :style="{ color: brandColor }">TRDR</span>
2658
- <!-- After — if value is always the brand token -->
2659
- <span class="text-brand">TRDR</span>
2660
- <!-- Keep :style only if the value is truly dynamic (changes at runtime based on data) -->
2661
- ```
2662
-
2663
- **Conditional / ternary values in `style={{}}`** (common in React):
2664
- When a style value is a ternary expression or computed value:
2665
- ```jsx
2666
- // Before — conditional style object
2667
- style={{
2668
- background: isActive ? '#4A4A4A' : 'transparent',
2669
- color: isActive ? '#FFFFFF' : '#A4A4A4',
2670
- }}
2671
- // After — state classes
2672
- className={isActive ? 'tab-active' : 'tab-inactive'}
2673
- // + CSS:
2674
- // .tab-active { background: var(--surface-primary); color: var(--content-primary); }
2675
- // .tab-inactive { background: transparent; color: var(--content-tertiary); }
180
+ Read: <skill-dir>/data/components/<slug>.json
2676
181
  ```
2677
- Steps:
2678
- 1. Identify the boolean condition controlling the state
2679
- 2. Create two CSS classes (active/inactive) with semantic token values
2680
- 3. Replace `style={{...}}` with `className={condition ? 'active-class' : 'inactive-class'}`
2681
- 4. Keep all business logic intact — only change how styles are applied
2682
- 5. Document in DS_PROGRESS.md: "Ternary style at [file:line] converted to state classes"
2683
182
 
2684
- **Special: trading up/down ternary** — when the two values are `#4FE290`/`#F34F45` (or any trading up/down pair):
2685
- ```css
2686
- /* Use context.trading tokens, NOT content.success/error */
2687
- .price-up { color: var(--context-trading-up); }
2688
- .price-down { color: var(--context-trading-down); }
2689
- /* WRONG: .price-up { color: var(--content-success); } — success is for non-trading contexts */
183
+ **To get the catalog index (lightweight):**
2690
184
  ```
2691
-
2692
- **Add new utility classes to the project's main CSS** (not to components.css or tokens.css — those are skill-managed):
2693
- Group new classes in a clearly labelled block at the bottom of the project's CSS, e.g.:
2694
- ```css
2695
- /* === Project utilities (added by TRDR DS migration) === */
2696
- .text-brand { color: var(--content-brand); }
2697
- .icon-brand { color: var(--content-brand); }
2698
- /* ... */
185
+ Read: <skill-dir>/data/index.json
2699
186
  ```
2700
187
 
2701
- **MUI sx prop migration (only when `stylingMode === 'mui'`):**
2702
-
2703
- MUI's `sx` prop is the idiomatic way to style MUI components. Unlike inline `style={{}}`, `sx` props should NOT be eliminated — they should be migrated to use DS tokens.
2704
-
2705
- **Decision tree for MUI `sx` props:**
188
+ The index contains slug, name, category, implemented flag, and dependencies for ALL components — but NO code blocks. Code blocks are loaded on demand from individual files.
2706
189
 
2707
- 1. **Value already uses theme reference** (`theme.palette.primary.main`, `theme.spacing(2)`) → keep as-is (theme was updated with DS tokens in Sub-fase A)
190
+ **When building components.css (Sub-fase A):**
191
+ 1. Read `data/index.json` to get list of implemented slugs
192
+ 2. For EACH implemented slug, read `data/components/<slug>.json` and extract `code.css`
193
+ 3. Concatenate all CSS blocks
2708
194
 
2709
- 2. **Hardcoded color** replace with token:
2710
- ```tsx
2711
- // Before
2712
- sx={{ color: '#00A8CC' }}
2713
- // After
2714
- sx={{ color: 'var(--content-brand)' }}
2715
- ```
2716
-
2717
- 3. **Hardcoded spacing with string px** → replace with token:
2718
- ```tsx
2719
- // Before
2720
- sx={{ padding: '16px', gap: '8px' }}
2721
- // After
2722
- sx={{ padding: 'var(--spacing-lg)', gap: 'var(--spacing-sm)' }}
2723
- ```
2724
-
2725
- 4. **Hardcoded fontFamily** → remove (theme typography handles this globally)
2726
-
2727
- 5. **Hardcoded borderRadius** → replace with token:
2728
- ```tsx
2729
- // Before
2730
- sx={{ borderRadius: '12px' }}
2731
- // After
2732
- sx={{ borderRadius: 'var(--radius-md)' }}
2733
- ```
2734
-
2735
- 6. **Conditional sx values** → replace both branches:
2736
- ```tsx
2737
- // Before
2738
- sx={{ color: isActive ? '#00D4FF' : '#A4A4A4' }}
2739
- // After
2740
- sx={{ color: isActive ? 'var(--content-brand)' : 'var(--content-tertiary)' }}
2741
- ```
2742
-
2743
- 7. **Layout-only sx** (display, flex, grid, position, width, height) → keep as-is (not DS concern)
2744
-
2745
- Do NOT convert `sx` props to CSS classes — `sx` is idiomatic MUI and is acceptable when using DS tokens.
2746
-
2747
- ---
2748
-
2749
- ### Step 7 — Generate DS_MIGRATION.md
2750
-
2751
- Create `DS_MIGRATION.md` at the project root:
2752
-
2753
- ```markdown
2754
- # TRDR Design System — Migration Log
2755
- Applied: [date]
2756
- Catalog: TRDR DS v[catalog-version] ([implemented]/[total] components, generated [generatedAt])
2757
- Hub: https://trdr.mrocontent.com.br
2758
-
2759
- ## What was applied
2760
- - ✅ [path]/tokens.css — TRDR CSS custom properties (snapshot v[catalog-version])
2761
- - ✅ [path]/components.css — [implemented] component utility class blocks + typography
2762
- - ✅ CLAUDE.md — design system rules for Claude Code
2763
- - ✅ [N] violations fixed in [M] files
2764
- - ✅ [global-css] updated with @import
2765
- - ⚠️ [S] stub components flagged in MISSING_COMPONENTS.md (if any)
2766
- - ✅ Migrated in [N] batches across 4 sub-phases — see DS_PROGRESS.md for details
2767
-
2768
- ## Files modified
2769
- [List each file and what changed]
2770
-
2771
- ## Violations fixed
2772
- [List by category with file:line references]
2773
-
2774
- ## Manual steps required
2775
- - [ ] **Fonts**: Ensure JetBrains Mono, Inter, and Roboto Mono are loaded
2776
- - Next.js: use `next/font/google` in layout.tsx (`JetBrains_Mono`, `Inter`, `Roboto_Mono`)
2777
- - Others: add Google Fonts `<link>` in HTML head
2778
- - [ ] **Dark/light mode**: tokens.css uses [data-theme="light"] for overrides — add `data-theme="light"` to `<html>` to activate light mode
2779
- - [ ] **Trading UI**: If this project has price/position displays, verify context.trading.* tokens are applied (see Hub: /tokens/semanticos)
2780
- - [ ] **Stubs**: Review MISSING_COMPONENTS.md and decide whether to wait for canonical implementation in the Hub or hand-roll using the listed tokens
2781
- - [ ] **Skipped files**: [list any files excluded from migration]
2782
-
2783
- [If `stylingMode === 'mui'`, add these additional manual steps:]
2784
- - [ ] **MUI CSS Variables mode**: If MUI version >= 6, add `cssVariables: true` to `createTheme()` for native CSS variable support. Without it, MUI's internal color calculations (alpha, lighten, darken) may produce invalid CSS when palette values are `var()` strings.
2785
- - [ ] **MUI palette auto-generation**: Verify that `primary.light`, `primary.dark`, and `primary.contrastText` are all explicitly set with DS tokens. MUI auto-generates these from `main`, which fails when `main` is a `var()` string.
2786
- - [ ] **MUI theme composition**: If the project composes themes across multiple files (`createTheme()` + `deepmerge`), verify that DS token references are preserved in the final merged theme.
2787
- - [ ] **MUI component slots**: Complex MUI components (DataGrid, DatePicker, Autocomplete) have many internal slots not covered by the standard styleOverrides. Review these manually if used in the project.
2788
- - [ ] **sx props audit**: Run a quick grep for `sx=\{\{.*#[0-9A-Fa-f]` to verify no hardcoded hex values remain in sx props.
2789
-
2790
- ## Missing DS tokens (flagged — no semantic token available)
2791
- | Pattern | File | Suggestion |
2792
- |---------|------|-----------|
2793
- | `box-shadow: rgba(0,0,0,*)` | [file:line] | Request shadow token in Hub |
2794
- | `linear-gradient(...)` non-TRDR | [file:line] | Request gradient token or remove |
2795
-
2796
- ## Stub components encountered (See MISSING_COMPONENTS.md)
2797
- [List each stub slug + figmaId that was referenced in the project]
2798
-
2799
- ## Design System Reference
2800
- - Hub: https://trdr.mrocontent.com.br
2801
- - JSON catalog: https://trdr.mrocontent.com.br/components.json
2802
- - Tokens: https://trdr.mrocontent.com.br/tokens/semanticos
2803
- - Components: https://trdr.mrocontent.com.br/componentes
2804
- - Rules: https://trdr.mrocontent.com.br/para-ia
2805
- ```
2806
-
2807
- After writing DS_MIGRATION.md, update `DS_PROGRESS.md`:
2808
- ```
2809
- Sub-fase D: Final — ✅ COMPLETE
2810
- Status: COMPLETE
2811
- Completed: [ISO datetime]
2812
- ```
195
+ **When applying components (Sub-fase C):**
196
+ 1. Read `data/index.json` to find candidates
197
+ 2. For EACH candidate being processed, read its individual component file
198
+ 3. Process ONE component at a time, then move to the next
2813
199
 
2814
200
  ---
2815
201
 
2816
- ## EXECUTION SUMMARY
2817
-
2818
- After all steps are complete, output:
202
+ ## Mapping Tables Protocol
2819
203
 
2820
- ```
2821
- ✅ TRDR Design System applied
2822
-
2823
- Created:
2824
- • [path]/tokens.css (snapshot v[catalog-version], dark + light mode)
2825
- • [path]/components.css ([implemented] component classes + typography)
2826
- • CLAUDE.md (design system context for Claude Code)
2827
- • DS_ANALYSIS.md (analysis snapshot)
2828
- • DS_PROGRESS.md (migration log — status: COMPLETE)
2829
- • DS_MIGRATION.md (migration log + manual checklist)
2830
- • MISSING_COMPONENTS.md ([S] stubs flagged) — only if applicable
204
+ Violation mapping tables (color→token, font→token, spacing→token, etc.) are in `data/mappings.json`.
2831
205
 
2832
- Modified:
2833
- • [global-css] — @import added
2834
- • [N] files — [X] violations replaced with semantic tokens
2835
-
2836
- Catalog: TRDR DS v[catalog-version] ([implemented]/[total] components)
2837
- Hub: https://trdr.mrocontent.com.br
2838
- → Check DS_MIGRATION.md for manual steps
2839
- → Stubs not yet canonical: see MISSING_COMPONENTS.md
2840
- → Backup branch: `trdr-ds/backup-{timestamp}` — para desfazer: `/trdr-ds rollback`
2841
- → Para remover o backup após validar: `git branch -D trdr-ds/backup-{timestamp}`
2842
- ```
206
+ **Load ONLY during Sub-fase B (violations).** Do NOT preload during analysis or other phases.
2843
207
 
2844
208
  ---
2845
209
 
2846
- ## RESUME MODE (when invoked with `resume` argument)
2847
-
2848
- This is the primary way to continue a migration across multiple context windows. Each `/trdr-ds resume` picks up the next pending sprint.
2849
-
2850
- 1. Look for `SPRINT_PLAN.md` and `DS_PROGRESS.md` at the project root.
2851
- - If neither found: output `❌ No previous migration found. Run /trdr-ds to start a new one.`
2852
- - If `DS_PROGRESS.md` has `Status: COMPLETE`: output `✅ Migration already complete (finished [date]). Run /trdr-ds to check for new violations.`
2853
-
2854
- 2. Read `SPRINT_PLAN.md`. Find the first sprint with `Status: PENDING` or `Status: IN_PROGRESS`.
2855
- - If all sprints are `✅ COMPLETE`: mark migration as COMPLETE in DS_PROGRESS.md and output summary.
2856
-
2857
- 3. Read `DS_PROGRESS.md` to understand overall state.
210
+ ## Developer Dissatisfaction Detection
2858
211
 
2859
- 4. Read **only the relevant section** of `DS_ANALYSIS.md` for the current sprint:
2860
- - Foundation sprint: read `§ Project` section only
2861
- - Violation sprint: read `§ By File` entries ONLY for the files listed in that sprint's scope
2862
- - Components sprint: read `§ Component Replacement Candidates`
2863
- - Final sprint: read `§ Logo Audit`
212
+ At every STOP checkpoint, if the developer expresses the implementation didn't work, trigger report mode. Match patterns (case-insensitive):
2864
213
 
2865
- 5. Output a resume summary:
2866
- ```
2867
- Resumindo migração TRDR DS [project name]
214
+ | PT | EN |
215
+ |----|-----|
216
+ | "nao funcionou" | "didn't work" |
217
+ | "nao deu certo" | "it's broken" |
218
+ | "deu errado" | "went wrong" |
219
+ | "ficou errado" | "messed up" |
220
+ | "quebrou" | "broke" |
221
+ | "nao aplicou" | "didn't apply" |
222
+ | "nao ta certo" | "not right" |
223
+ | "ta errado" | "it's wrong" |
224
+ | "report" | "bug report" |
2868
225
 
2869
- 📋 Sprint Plan: [done]/[total] sprints completos ([percentage]%)
2870
-
2871
- [For each sprint in SPRINT_PLAN.md:]
2872
- Sprint 1 Foundation ✅
2873
- Sprint 2 — Violations: src/components/ ✅
2874
- Sprint 3 — Violations: src/pages/ 🔄 ← retomando aqui
2875
- Sprint 4 — Violations: src/app/ ⏳
2876
- Sprint 5 — Components ⏳
2877
- Sprint 6 — Final ⏳
2878
-
2879
- Retomando: **Sprint [N] — [name]**
2880
- Escopo: [sprint scope description]
2881
- ```
2882
-
2883
- 6. Execute the current sprint following the sprint lifecycle (read → execute → save → STOP).
2884
- All context is read from `SPRINT_PLAN.md` + `DS_ANALYSIS.md` (relevant section only) + `DS_PROGRESS.md` — never from conversation history.
226
+ When detected:
227
+ 1. Acknowledge feedback
228
+ 2. Read `modes/report.md` and execute report mode
229
+ 3. After report, offer: rollback / continuar / parar
2885
230
 
2886
231
  ---
2887
232
 
2888
- ## STATUS MODE (when invoked with `status` argument)
2889
-
2890
- 1. Look for `SPRINT_PLAN.md` and `DS_PROGRESS.md` at the project root.
2891
- - If neither found: output `No migration in progress. Run /trdr-ds to start.`
2892
-
2893
- 2. Read `SPRINT_PLAN.md` and `DS_PROGRESS.md` — do NOT modify any files. Output:
233
+ ## Phase Flow (for `apply` argument)
2894
234
 
2895
235
  ```
2896
- ## TRDR DS Migration Status
2897
-
2898
- Project: [name] | Started: [date] | Status: [IN_PROGRESS/PAUSED/COMPLETE]
2899
- Backup: [branch name or NONE]
2900
-
2901
- ### Sprint Progress
2902
- | Sprint | Scope | Files | Violations | Status |
2903
- |--------|-------|-------|------------|--------|
2904
- | 1 | Foundation | 4 | — | ✅ |
2905
- | 2 | Violations: src/components/ | 12 | 34 | ✅ |
2906
- | 3 | Violations: src/pages/ | 8 | 21 | 🔄 IN_PROGRESS |
2907
- | 4 | Violations: src/app/ | 15 | 45 | ⏳ PENDING |
2908
- | 5 | Violations: src/styles/ | 6 | 18 | ⏳ PENDING |
2909
- | 6 | Components | [N] candidates | — | ⏳ PENDING |
2910
- | 7 | Final | logos + icons | — | ⏳ PENDING |
2911
-
2912
- ### Summary
2913
- Sprints completos: [done]/[total] ([percentage]%)
2914
- Violações corrigidas: [fixed]/[total_violations]
2915
- Componentes aplicados: [applied]/[total_candidates]
2916
-
2917
- ### Next Action
2918
- → Sprint [N]: [name] — `/trdr-ds resume`
2919
- → Para desfazer tudo: `/trdr-ds rollback`
236
+ analyze.md STOP (wait approval)
237
+ ↓ "Apply"
238
+ foundation.md STOP
239
+ "continuar"
240
+ violations.md → STOP (per batch)
241
+ all batches done
242
+ components.md STOP
243
+ ↓ "continuar"
244
+ final.md DONE
2920
245
  ```
2921
246
 
2922
- ---
2923
-
2924
- ## SYNC MODE (when invoked as `/trdr-ds sync`)
2925
-
2926
- 1. WebFetch `https://trdr.mrocontent.com.br/components.json` save as `<skill-dir>/data/components.json`
2927
- 2. WebFetch `https://trdr.mrocontent.com.br/tokens.css` → save as `<skill-dir>/references/tokens.css`
2928
- 3. Compare new vs previous (if a previous version exists). Report:
2929
- - New components: [list slugs]
2930
- - Newly implemented: [list slugs that flipped from stub → implemented]
2931
- - Removed: [list slugs no longer in catalog]
2932
- 4. No project files are touched.
2933
-
2934
- If either fetch fails, report which one and exit. Do NOT touch the snapshot if the response is malformed (e.g., missing `components` array).
2935
-
2936
- ---
2937
-
2938
- ## ROLLBACK MODE (when invoked as `/trdr-ds rollback`)
2939
-
2940
- 1. Look for `DS_PROGRESS.md` at the project root.
2941
- - If not found: output `❌ Nenhuma migração encontrada. Nada para reverter.` and STOP.
2942
- - If `Backup branch:` line is `NONE (user opted out)`: output `❌ Nenhum backup foi criado (você optou por continuar sem backup durante a migração). Rollback manual necessário.` and STOP.
2943
-
2944
- 2. Read the `Backup branch:` value from `DS_PROGRESS.md`. Save as `backupBranch`.
2945
- Read the `Original branch:` value. Save as `originalBranch`.
2946
-
2947
- 3. Verify the backup branch still exists:
2948
- ```bash
2949
- git rev-parse --verify {backupBranch} 2>/dev/null
2950
- ```
2951
- If it doesn't exist: output `❌ Branch de backup \`{backupBranch}\` não encontrado. Pode ter sido apagado manualmente.` and STOP.
2952
-
2953
- 4. Confirm with the user:
2954
- ```
2955
- ⚠️ ROLLBACK: Isto vai reverter TODAS as alterações feitas pela migração TRDR DS.
2956
-
2957
- Backup branch: {backupBranch}
2958
- Branch atual: {currentBranch}
2959
- Status da migração: {status from DS_PROGRESS.md}
2960
-
2961
- Todos os arquivos modificados pela migração serão restaurados ao estado do backup.
2962
- Arquivos DS criados (DS_ANALYSIS.md, DS_PROGRESS.md, DS_MIGRATION.md, MISSING_COMPONENTS.md, CLAUDE.md, tokens.css, components.css) serão revertidos ou removidos.
2963
-
2964
- Responda:
2965
- - "confirmar" — executar rollback
2966
- - "cancelar" — abortar
2967
- ```
2968
- **STOP. Wait for reply.**
2969
-
2970
- 5. If `"cancelar"`: output `Rollback cancelado.` and STOP.
2971
-
2972
- 6. If `"confirmar"`, execute the rollback:
2973
-
2974
- a. Ensure we're on the original branch:
2975
- ```bash
2976
- git checkout {originalBranch}
2977
- ```
2978
-
2979
- b. Reset the working tree to the backup state:
2980
- ```bash
2981
- git reset --hard {backupBranch}
2982
- ```
2983
-
2984
- 7. Output:
2985
- ```
2986
- ✅ Rollback completo.
2987
-
2988
- Branch `{originalBranch}` restaurado ao estado de `{backupBranch}`.
2989
- Todos os arquivos modificados pela migração foram revertidos.
2990
-
2991
- O backup branch `{backupBranch}` ainda existe. Para removê-lo:
2992
- git branch -D {backupBranch}
2993
- ```
247
+ Each arrow is a STOP checkpoint. Between any two checkpoints, the developer can:
248
+ - `/clear` + `/trdr-ds resume` — clean context, continue
249
+ - "parar" save progress, stop
250
+ - "rollback" — undo everything
251
+ - "report" send bug report
2994
252
 
2995
253
  ---
2996
254
 
2997
- ## LIVE HUB REFERENCE (canonical fallback)
2998
-
2999
- When the developer asks about a component, token, or rule that is not in the local snapshot, fetch from the Hub:
255
+ ## Live Hub Reference (canonical fallback)
3000
256
 
3001
257
  | Need | URL |
3002
258
  |------|-----|
@@ -3007,5 +263,3 @@ When the developer asks about a component, token, or rule that is not in the loc
3007
263
  | All components | https://trdr.mrocontent.com.br/componentes |
3008
264
  | Rules & CLAUDE.md template | https://trdr.mrocontent.com.br/para-ia |
3009
265
  | Full design spec | https://trdr.mrocontent.com.br/design-md |
3010
-
3011
- The Hub is the single source of truth. The local snapshot is the offline mirror. When in doubt, refresh the snapshot via `/trdr-ds sync`.