# Prompt — Phase A4.0 Generator follow-up: variant.theme uniform derivation

> **角色**：executor
> **范围**：修 [`figma-sync/generate-docs-figma-members.mjs`](../../../figma-sync/generate-docs-figma-members.mjs) 的 variant.theme 派生逻辑——当前只在 GLOBAL alias 触发时（如 `dark theme → theme`）派生 variant.theme 字段；遗漏 figma axis 名已经是 canonical `theme` 的 identity case（如 Notification 的 `theme=dark/light`）。
>
> ⚠️ **不要 commit / 不要 git add**——dirty 累积到 Phase A4.0 通过后 commit。
> ⚠️ 完成后 **STOP**，按底部"完成报告"格式回报。
> ⚠️ **不扩范围**：只动 `figma-sync/generate-docs-figma-members.mjs` 一个文件 + 重跑生成产物。**不动** types.ts schema、audit、canonical、page、prop-aliases.md、backlog.md。

---

## §0 — Plan owner 已定裁定

### 当前 gap 实证（commit f9ca71c）

| 组件 | figma axis 名 | GLOBAL alias 触发 | variant.theme 字段 | grid filter |
|---|---|---|---|---|
| Notification | `theme` (canonical identity) | ❌ 不触发 | **0/14 variants 缺失** ❌ | 不会 filter（hasThemeVariants=false） |
| Tooltip / CheckBox / Radio / Switch | `dark theme` | ✅ 触发 | 已有 ✓ | 正常 filter |

### Fix 语义

variant.theme 派生**应基于 canonical axis name (post-alias) 是否等于 `'theme'`**，而非"是否触发了 alias"：

| figma axis 名 | post-alias canonical name | variant.theme 来源 |
|---|---|---|
| `dark theme` | `theme`（GLOBAL alias 应用） | `themeValueMap[variant.props.darkTheme]`（如 `on→dark`） |
| `darkTheme` | `theme`（GLOBAL alias 应用） | 同上 |
| **`theme`** | **`theme`（identity，无需 alias）** | **`variant.props.theme` 直接（已是 canonical 值 `dark`/`light`）** |

→ 任何 canonical axis name 等于 `theme` 的组件，每个 variant 都派生 variant.theme 字段。

### 实施细节（plan owner 锁判定逻辑）

generator parse axes 后，对每个 figma axis：

1. 查 prop-aliases.md "项目级 GLOBAL axis alias / 表 A"（已存在 logic）→ 取 canonical axis name
2. **如果 canonical axis name === 'theme'**（无论是 alias 派生 还是 identity）→ 该组件标记 `themeAxis = <figma axis name>`
3. variant.theme 派生：
   - **如果该 axis 有 GLOBAL alias 值映射**（表 B 命中）→ 用映射后的 derived value（现有 path）
   - **否则**（identity case）→ 用 `variant.props[<canonical axis codeProp>]` 直接（新 path）

### 受影响文件清单（实施后预期）

| 文件 | 现状 | Fix 后 | 变化 |
|---|---|---|---|
| `notification.ts` | 14 variants 无 variant.theme | 14 variants 有 `theme: 'dark' \| 'light'` | **新增 14 个字段** |
| `checkbox.ts` / `radio.ts` / `switch.ts` / `tooltip.ts` | variant.theme 已存在 | 无变化（algorithm path 不变） | byte-identical 除 generatedAt |
| 13 个无 theme axis 的 .ts | 不含 variant.theme | 同上 | byte-identical 除 generatedAt |

### Audit re-run 预期变化（commit f9ca71c baseline 对照）

| Page | α verdict 现状 | α verdict 修后 | 性质 |
|---|---|---|---|
| **NotificationPage** | **N/A**（gap：variant.theme 缺失致 hasThemeVariants=false） | **fail**（修后正确：page 未改造，无 site-theme，theme isolation 不可证） | 不是 regression；是**correctness improvement** |
| 其他 17 page | 各自现状 | 不变 | regression check |

⚠️ NotificationPage α=N/A → fail 是**期望事实**——之前 N/A 是 generator gap 掩盖的 bug，修后正确报告。**不是** regression，commit message 要明示。

### 不动

- `figma-data/normalized/docs-figma-members/types.ts`（schema 不变）
- `figma-sync/audit-page-t2-sample.mjs`（audit 算法不动）
- `playground/docs/pages/*.vue`（A4.1+ 范围）
- `src/canonical/*` / `src/components/*`
- `src/design-system/translation/prop-aliases.md`（plan owner 真源不动）
- `docs/internal/backlog.md`

---

## §1 — 必读输入

1. [`figma-sync/generate-docs-figma-members.mjs`](../../../figma-sync/generate-docs-figma-members.mjs) — 现状（commit f9ca71c），fix 起点
2. [`src/design-system/translation/prop-aliases.md`](../../../src/design-system/translation/prop-aliases.md) "项目级 GLOBAL axis alias" 段（**只读**）—— 表 A/B 真源
3. [`figma-data/normalized/components-tokenized/notification__1408_17154.json`](../../../figma-data/normalized/components-tokenized/notification__1408_17154.json) —— 验 figma axis 名是 `theme`
4. [`figma-data/normalized/docs-figma-members/notification.ts`](../../../figma-data/normalized/docs-figma-members/notification.ts) —— 当前缺 variant.theme 实证
5. [`figma-data/normalized/docs-figma-members/tooltip.ts`](../../../figma-data/normalized/docs-figma-members/tooltip.ts) —— alias-driven variant.theme 范式参考
6. 其他 17 个 `figma-data/normalized/docs-figma-members/*.ts` —— regression 对照基线
7. [`docs/internal/t2-sample-audit-report.NotificationPage.md`](../../t2-sample-audit-report.NotificationPage.md) —— 当前 α=N/A 实证

---

## §2 — 任务清单

### 任务 2.1 — 实施 generator fix

按 §0 实施细节加 canonical theme axis identity 路径派生。

具体函数命名 / 实现位置（在 `generate()` 内 axes 阶段还是 variant parse 阶段做 detection）由 executor 提议；plan owner 已锁逻辑语义。

### 任务 2.2 — 跑 generator 全量

```bash
node figma-sync/generate-docs-figma-members.mjs
```

### 任务 2.3 — 验 notification.ts 含 variant.theme

```bash
grep -c "^      theme:" figma-data/normalized/docs-figma-members/notification.ts
# 期望: 14
```

### 任务 2.4 — 17 .ts baseline byte-identical 除 generatedAt

```bash
git diff --stat figma-data/normalized/docs-figma-members/
# 期望: notification.ts 实质 diff（新增 variant.theme），其他 18 .ts 各 2 行 (generatedAt only)
```

任一非 notification.ts 出现非 generatedAt 行 diff → STOP 报告。

### 任务 2.5 — typecheck

```bash
pnpm exec vue-tsc --noEmit
```

预期 0 错误（types.ts schema 兼容 `theme?: 'dark' | 'light'` optional field）。

### 任务 2.6 — 跑 audit 全量

```bash
node figma-sync/audit-page-t2-sample.mjs
```

### 任务 2.7 — 验 audit baseline 与 NotificationPage 修正

```bash
git diff docs/internal/t2-sample-audit-report.NotificationPage.md
# 预期: α 从 verdict='N/A' → verdict='fail'，findings 从 [] → 含 site-theme 不可证 信息

git diff docs/internal/t2-sample-audit-report.BadgePage.md
git diff docs/internal/t2-sample-audit-report.TooltipPage.md
git diff docs/internal/t2-sample-audit-report.<其他 15 page>.md
# 预期: 4 verdict + findings 字面一致除 timestamps
```

任一非 NotificationPage 报告出现非 timestamp 行 diff → STOP 报告。

---

## §3 — 验收清单

- [ ] generator 加 canonical theme axis identity 派生路径
- [ ] notification.ts 14 variants 全部含 `theme: 'dark' | 'light'`
- [ ] 18 个其他 .ts 与 commit f9ca71c byte-identical 除 generatedAt
- [ ] `pnpm exec vue-tsc --noEmit` 0 错误
- [ ] NotificationPage audit α 从 N/A → fail（findings 含 site-theme 不可证类信息）
- [ ] 17 个其他 audit reports 与 baseline 一致除 timestamps
- [ ] generator / audit 函数的非 fix 部分 0 改动
- [ ] types.ts / audit / canonical / page / prop-aliases / backlog **没动**
- [ ] 没 commit / 没 git add

---

## §4 — 完成报告

```
## Phase A4.0 Generator theme identity fix 完成报告

### 改动文件
- figma-sync/generate-docs-figma-members.mjs (+X/-Y, 加 canonical theme identity 派生)
- figma-data/normalized/docs-figma-members/notification.ts (实质 diff: +14 variant.theme 字段)
- 其他 18 .ts (regenerated, 仅 generatedAt 变化)
- 18 audit reports (re-run, NotificationPage α 实质 diff，其他仅 timestamps)

### 实施 hunk
[贴 generator 关键 diff hunk]

### Notification.ts variant.theme 验证
[贴 grep 输出: 14 variants count 实证]

### Baseline regression check
- notification.ts: <实质 diff +14 字段>
- 18 个其他 .ts: <byte-identical 除 generatedAt / 描述>
- NotificationPage audit α: <verdict 'N/A' → 'fail' diff hunk>
- 17 个其他 audit reports: <一致除 timestamps / 描述>

### typecheck
- vue-tsc: 0 错误

### 验收 self-check
- [ ] generator 实施 fix
- [ ] notification.ts 14 variant.theme
- [ ] 18 其他 .ts byte-identical 除 generatedAt
- [ ] NotificationPage α=fail 转换
- [ ] 17 其他 audit reports 一致
- [ ] vue-tsc 0 错
- [ ] 不动 types/audit/canonical/page/prop-aliases/backlog
- [ ] 没 commit

### 未解决项 / blocker
[如有，列出；无则写"无"]

STOP — 等 plan owner 复审 + commit Phase A4.0 fix → 进 A4.1 NotificationPage transform。
```

---

## §5 — 严守约束总览

- ⚠️ **不要 commit / 不要 git add**
- ⚠️ §0 裁定**最终**（fix 语义按 canonical theme axis 检测，alias path / identity path 双触发）
- ⚠️ 仅动 generator 1 文件 + 重跑产物
- ⚠️ NotificationPage α=N/A → fail 是**correctness improvement** 不是 regression
- ⚠️ 18 个其他 .ts byte-identical 除 generatedAt（regression）
- ⚠️ 17 个其他 audit reports 一致除 timestamps（regression）
- ⚠️ 完成 STOP，按 §4 格式回报
