+
{footer}
)}
diff --git a/docs/superpowers/plans/2026-09-30-modernist-design-system-restyle.md b/docs/superpowers/plans/2026-09-30-modernist-design-system-restyle.md
index 05fb6fe..79651b3 100644
--- a/docs/superpowers/plans/2026-09-30-modernist-design-system-restyle.md
+++ b/docs/superpowers/plans/2026-09-30-modernist-design-system-restyle.md
@@ -366,7 +366,6 @@ Create `tests/scripts/modernist-codemod.test.ts`:
```ts
import { describe, it, expect } from 'vitest'
-// @ts-expect-error plain .mjs script without types
import { transformSource } from '../../scripts/modernist-codemod.mjs'
const t = (s: string): string => transformSource(s)
@@ -450,8 +449,9 @@ function transformClassAttr(attr) {
out = out.replace(/(? q + body.trim().replace(/ {2,}/g, ' ') + q)
+ out = out.replace(/^(className=\{`)\s+/, '$1').replace(/\s+(`\})$/, '$1')
out = out.replace(/ {2,}/g, ' ')
- out = out.replace(/(["'`])\s+/g, '$1').replace(/\s+(["'`])/g, '$1')
return out
}
@@ -489,7 +489,7 @@ function main() {
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
```
-Note on the whitespace cleanup: the `(["'`])\s+` replacement trims spaces just inside quotes of every class attribute, which is safe because class lists never need leading or trailing space.
+Note on the whitespace cleanup: only string-literal bodies and the attribute's outer backtick delimiters are trimmed, so spaces around `?` and `:` inside `${...}` survive.
- [ ] **Step 4: Run the tests to verify they pass**
@@ -1592,7 +1592,6 @@ Create `tests/scripts/check-design-gates.test.ts`:
```ts
import { describe, it, expect } from 'vitest'
-// @ts-expect-error plain .mjs script without types
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
const rules = (src: string, file = 'components/x.tsx'): string[] =>
diff --git a/scripts/modernist-codemod.mjs b/scripts/modernist-codemod.mjs
new file mode 100644
index 0000000..9351852
--- /dev/null
+++ b/scripts/modernist-codemod.mjs
@@ -0,0 +1,55 @@
+import { readdirSync, readFileSync, writeFileSync, statSync } from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const CLASS_ATTR =
+ /className=(?:"[^"]*"|'[^']*'|\{"[^"]*"\}|\{'[^']*'\}|\{`(?:[^`\\]|\\.)*`\})/g
+
+const ROUNDED =
+ /(? q + body.trim().replace(/ {2,}/g, ' ') + q)
+ out = out.replace(/^(className=\{`)\s+/, '$1').replace(/\s+(`\})$/, '$1')
+ out = out.replace(/ {2,}/g, ' ')
+ return out
+}
+
+export function transformSource(src) {
+ const next = src.replace(CLASS_ATTR, transformClassAttr)
+ return next.replace(/ className=(?:""|''|\{""\}|\{''\}|\{``\})/g, '')
+}
+
+function walk(dir, files = []) {
+ for (const name of readdirSync(dir)) {
+ const full = path.join(dir, name)
+ if (statSync(full).isDirectory()) walk(full, files)
+ else if (full.endsWith('.tsx')) files.push(full)
+ }
+ return files
+}
+
+function main() {
+ const dry = process.argv.includes('--dry')
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
+ let changed = 0
+ for (const dir of ['app', 'components']) {
+ for (const file of walk(path.join(root, dir))) {
+ const before = readFileSync(file, 'utf8')
+ const after = transformSource(before)
+ if (after !== before) {
+ changed++
+ if (!dry) writeFileSync(file, after)
+ }
+ }
+ }
+ console.log(`${dry ? 'would change' : 'changed'} ${changed} files`)
+}
+
+if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main()
diff --git a/tests/scripts/modernist-codemod.test.ts b/tests/scripts/modernist-codemod.test.ts
new file mode 100644
index 0000000..ad84bbf
--- /dev/null
+++ b/tests/scripts/modernist-codemod.test.ts
@@ -0,0 +1,55 @@
+import { describe, it, expect } from 'vitest'
+import { transformSource } from '../../scripts/modernist-codemod.mjs'
+
+const t = (s: string): string => transformSource(s)
+
+describe('modernist codemod', () => {
+ it('removes rounded-* sizes but keeps rounded-full', () => {
+ expect(t('
')).toBe('
')
+ expect(t('
')).toBe('
')
+ expect(t('
')).toBe('
')
+ })
+
+ it('removes variant-prefixed rounded classes whole', () => {
+ expect(t('
')).toBe('
')
+ })
+
+ it('swaps bg-white for bg-surface, keeping variants and opacity', () => {
+ expect(t('
')).toBe('
')
+ expect(t('
')).toBe('
')
+ })
+
+ it('swaps light gray borders and dividers for the divider token', () => {
+ expect(t('
')).toBe('
')
+ expect(t('
')).toBe('
')
+ })
+
+ it('leaves dark gray borders alone', () => {
+ expect(t('
')).toBe('
')
+ })
+
+ it('swaps heavy shadows for shadow-lg', () => {
+ expect(t('
')).toBe('
')
+ expect(t('
')).toBe('
')
+ expect(t('
')).toBe('
')
+ })
+
+ it('handles template literals with conditionals', () => {
+ const src = '
'
+ expect(t(src)).toBe('
')
+ })
+
+ it('drops a className that becomes empty', () => {
+ expect(t('
')).toBe('
')
+ })
+
+ it('does not touch text outside className', () => {
+ const src = '
The corners are rounded and bg-white is a word.
'
+ expect(t(src)).toBe(src)
+ })
+
+ it('is idempotent', () => {
+ const once = t('
')
+ expect(t(once)).toBe(once)
+ })
+})