Files
novalon-website/AGENTS.md
zhangxiang 99eaa8c66a feat(landing): 睿视 landing 由本仓统一管理——源码子目录化 + 四道门禁移植 + 契约路由
承接 ADR-0014 §4「第二等产品镜像起必须子目录化 + rewrites 前缀映射并回溯睿视」。
上一轮(2026-12-02)只搬了字节,源码落在 public/ 根命名空间;本轮把源码、门禁、
发布职责一并收进本仓,authority 侧退役对应产物。

源码与 URL 契约:
- public/novavis/{index.html,css,js,assets,images/logos} 一棵树自成一体
- index.html 引用保持站点级绝对路径(/css /js /assets /images/logos)不变。
  因为同一份字节要服务两个落点:官网镜像 novalon.cn/novavis/,以及独立子域
  novavis.p.novalon.cn/(页面在根路径)。改绝对路径会把子域首页变成 /novavis/
- 故用 4 条 prefix rewrite 把根命名空间映射进子目录,而非改写 HTML

四道门禁(从 authority 的四个 python 脚本移植为 Playwright,已并入 test:all):
- e2e/landing/{layout,motion,demo,a11y}.spec.ts + 独立 config(单引擎单 project 串行)
- layout:几何与焦点 / motion:js-grow 渐进生长与 reduced-motion 直达终态
- demo:首屏剧本四步 + 徽标一一对应 + 无 JS 降级四层真实可见性
- a11y:结构与全量对比度(同色无条件阻断)+ axe critical/serious=0
- 实测 13 passed / EXIT=0(1.4m)

补一个映射期暴露的真缺陷:landing 的 main.js 固定 POST /api/v1/contact 且只认
code===200,而本仓只有 /api/contact(formData + 必填 subject),镜像侧转化路径
一直 404。新增 src/app/api/v1/contact/route.ts 按 authority 契约响应(JSON +
{code:200}),而非改前端去适配本仓——改前端等于把适配成本转嫁给子域,且会让
两个落点的成功判据不一致。9 个单测覆盖校验、限流、上游失败不透传 5xx。

文档与配置同步:CLAUDE.md → AGENTS.md(单文档真源)、docs/landing.md、
docs/deployment.md §八、ADR-0014、qa-tracker §32、README 与 quality-gates 脚本表、
Jenkinsfile 落地「♿ 可访问性门禁」阶段的 landing 四道门禁、eslint 忽略
.next-dev-live 构建产物目录(未忽略时 eslint . 会扫出 21195 errors)。

门禁:tsc 0 / eslint 0 / jest app/api/v1 9/9 / test:landing 13 passed。
2026-12-03 22:56:17 +08:00

547 lines
52 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Novalon Website 开发工作流指南
本文件定义 AI 代理与开发者在参与本项目时应遵循的标准工作流。核心目标是**在需求清晰、文档一致、测试覆盖的前提下交付可验证的代码变更**。
## 1. 工作流总览
新功能或复杂变更按以下流水线执行:
```
/入口判断
↓
/grill-with-docs → 需求梳理:在项目语境中通过结构化问答形成文档化共识
↓
/context7 → 官方实践:涉及第三方库 / 框架 / API 时查询官方文档与最佳实践
↓
/to-prd → 需求文档化:将澄清后的需求综合为结构化 PRD (必须包含 mermaid 架构/数据流/时序图)
↓
/to-issues → 任务拆解:按 tracer-bullet 垂直切片将 PRD 拆为独立 Issues
↓
/tdd → TDD 实现:RED-GREEN-REFACTOR 循环逐个实现
↓
/systematic-debugging → 系统调试:遇到 bug 时收集症状→形成假设→验证→修复根因
↓
/verification → 验证门禁:类型检查、Lint、单元测试、E2E、可访问性、Lighthouse
↓
/文档同步 → 更新 README.md / CONTEXT.md / AGENTS.md 及受影响的设计文档
```
## 2. 入口判断
### 2.1 必须使用
- 新功能开发
- 跨模块变更(如同时修改组件、API、测试)
- 涉及数据模型 / API 变更
- 设计 DNA、HSI 架构、四层叙事模型相关的页面重构
### 2.2 建议使用
- 需求不清晰的变更
- 需要多人协作的功能
- 涉及第三方库升级或替换
- 性能优化、可访问性改进等横向改造
### 2.3 可跳过
- 单行修复
- 文档更新(仍需满足「文档同步」要求)
- 配置变更
- 明显的拼写 / 类型错误
## 3. 核心原则
| 原则 | 含义 |
|------|------|
| **不跳步** | 不要在需求不清晰时直接编码(跳过 grill-with-docs)。 |
| **不猜测** | PRD 未形成共识前,不进行任务拆解。 |
| **不偷懒** | TDD 循环中必须先写失败测试再看实现。 |
| **不掩饰** | 遇到 bug 时先诊断根因再修复,不要随机尝试。 |
| **零编造** | 禁止凭空创造 API / 数据结构 / 未经验证的配置。所有产出必须有至少一个可信来源支撑。 |
| **文档同步** | 任何变更必须同步更新相关文档(注释、README.md、CONTEXT.md、AGENTS.md、docs/ 下受影响文件)。 |
| **交叉验证** | 关键决策须从至少两个独立可信源(官方文档 + 既有代码库模式 / 设计规范)比对求证。 |
| **双归零** | 任何错误立即暂停,执行技术归零(定位机理、复现、修复)与管理归零(追溯流程漏洞、更新检查清单)。 |
## 4. 阶段详解
### 4.1 /grill-with-docs — 需求梳理
**目标**:将模糊需求转化为基于项目共享语言的文档化共识。
**必须引用**:
- [CONTEXT.md](CONTEXT.md) — 领域术语表与关键决策
- [AGENTS.md](AGENTS.md) §9 — 命令速查与架构(原 CLAUDE.md 正文,已并入)
- [README.md](README.md) — 项目规划与进度
**输出**:
- 更新后的 `CONTEXT.md`(若引入新术语或变更决策)
- 问题清单与决策记录
**关键问题**:
1. 变更属于哪种页面类型?(首页 / Hub / Spoke / Independent / 详情页)
2. 是否涉及四层叙事模型(Hero → 价值 → 信任 → CTA)调整?
3. 是否引入新的设计令牌、动画或第三方依赖?
4. 是否需要同步更新跨页面链接(产品 ↔ 方案 ↔ 服务)?
### 4.2 /context7 — 官方实践
**目标**:在涉及第三方库 / 框架 / API 时,获取官方文档与最佳实践。
**触发条件**:
- 使用新依赖(如 Radix UI、Framer Motion、Zod、Prisma 的新特性)
- Next.js App Router、React Server Components、API Routes 相关变更
- Tailwind CSS、shadcn/ui 组件模式变更
**输出**:
- 引用来源清单
- 关键 API 用法示例
- 与项目现有模式的差异说明
### 4.3 /to-prd — 需求文档化
**目标**:将澄清后的需求综合为结构化 PRD。
**PRD 必须包含**:
- 背景与目标
- 范围与不在范围内
- 用户故事或验收标准
- 受影响的页面 / 组件 / API / 数据模型
- 设计约束(品牌红、动效四原则、Mobile First、standalone 混合渲染下「API/ISR 需 Node 运行时、图片 unoptimized」等)
- 风险与依赖
- 验证方式
### 4.4 /to-issues — 任务拆解
**目标**:按 tracer-bullet 垂直切片将 PRD 拆为独立可追踪的 Issues。
**切片原则**:
- 每个 Issue 可独立开发、独立测试、独立交付
- 优先完成一条端到端 tracer-bullet(如一个页面的 Hero → 价值 → 信任 → CTA)
- 标注优先级、依赖关系、信源与验证命令
### 4.5 /tdd — TDD 实现
**目标**:RED-GREEN-REFACTOR 循环逐个实现。
**适用层级**:
- 单元测试:工具函数、Hooks、CMS 渲染器、组件行为
- E2E 测试:关键用户路径(导航、表单、Hero 区域可见性)
- 视觉回归:涉及 UI 样式调整的变更
**纪律**:
1. 先写 failing test
2. 用最简单实现让测试通过
3. 重构并确保测试仍通过
### 4.6 /systematic-debugging — 系统调试
**目标**:遇到 bug、测试失败或异常行为时,先诊断根因再修复。
**流程**:
1. 收集症状(日志、截图、复现步骤)
2. 形成假设
3. 最小化验证
4. 修复根因
5. 补充回归测试
## 5. 质量门禁
变更提交前必须通过以下检查:
| 检查项 | 命令 | 通过标准 |
|--------|------|---------|
| 类型检查 | `npm run type-check` | 无类型错误 |
| 代码风格 | `npm run lint` | 0 error(warning 不判红;**实测 105 条**,2026-09-23 最终树复测):55 `no-console`、25 `@typescript-eslint/no-explicit-any`、12 `react-hooks/set-state-in-effect`、10 `@next/next/no-img-element`、1 `@next/next/no-sync-scripts`、1 `@next/next/no-html-link-for-pages`、1 `Unused eslint-disable directive`(死抑制)。分项相加 = 105,口径自洽。**2026-10-08 本树复测**:`npm run lint` EXIT=0、**0 error / 104 warning**(`npm run type-check` 同 EXIT=0)⇒ 本行 105 为 2026-09-23 历史读数,现行权威位在 `docs/development/quality-gates.md`,引用计数须附复算命令 |
| 单元测试 | `npm run test:unit` | 全部通过 |
| 单元覆盖率 | `npm run test:coverage` | 阈值单一真源为 [config/test/jest.config.js](config/test/jest.config.js) 的 `coverageThreshold`(根 `jest.config.js` 仅转发):global 门限 branches 82 / functions 75 / lines 75 / statements 75,**2026-09-23 收尾树复测 134 套件 / 1697 例全通过,EXIT=0,0 条阈值告警**;global 实测 **stmts 85.59 / branch 87.5 / funcs 80.67 / lines 85.59**(目录级:`components/content` 100×4、`components/sections` 72.77/90.79/73.8/72.77、`lib/cms` 91.93/92.77/92.68/91.93)。⚠ global 实测已高于门限 5.6–12.5 个点,棘轮当前偏松,上调须作为独立动作 |
| E2E 测试 | `npm run test` | 全部通过。**但默认 webServer 是 `npm run dev`,16 个 `@critical` GA4 用例(TC-GA4-001..004 × 4 project)在这一轮里是 skipped 而不是 passed**——`NEXT_PUBLIC_GA_MEASUREMENT_ID` 只存在于 `.env.production`,dev 下 `GoogleAnalytics.tsx` 提前返回 null,用例内 `test.skip` 触发(证据 `docs/acceptance/2026-09-21-gates/skipped-tests-final-tree.json`:28 skipped 中该组恰为 16)。故 `npm run test` 绿 **不等于** GA4 覆盖已验证 |
| E2E 测试(产物目标) | `npm run test:e2e:prod` | `E2E_TARGET=production` → harness 新起 `node dist/standalone/server.js`(**不是** `npm run start`;standalone 下 `next start` 不受支持)。那 16 个 GA4 用例只在这里真正断言(2026-09-23 实测:`@smoke\|@critical\|@journey` 排除 2 个写库 spec 后 **92 例通过 / 0 skipped / EXIT=0**)。⚠ **生产响应头不在该 grep 集合里**——它在 `@security`(`security-headers.spec.ts`)下,别把两者混为一谈。**须先自行 `npm run build`(harness 不代跑),且 `postbuild` 须已装配 `dist/static` + `public`** |
| 视觉回归 | `npm run test:visual:all -- --update-snapshots=none`(**只读比对**,不写参照;缺省不带 `--update-snapshots=none` 时 Playwright 会**静默创建**缺失基线) | ⚠ **2026-09-23 最终树实测 EXIT=1,21 失败 / 104 通过,其中 0 例是像素不符**。红因全部是测试装配缺陷(记为 N-15,见 `docs/acceptance/2026-09-23-gates/final-verdict.md` §3 与 `docs/lessons-learned.md` §5.29):10 例基线文件从不存在(`/products/erp-upgrade`、`/about/brand` × 5 project)、10 例死在选择器(`[class*="card"]` 零匹配;`input[type="text"]` 的 `.first()` 命中按设计隐藏的**反垃圾蜜罐**字段)、1 例移动端窄视口按钮不可见。**判读必须分层**:现存参照层面 104 例全绿(含 `/contact` 全页)⇒ 本轮修复无视觉外溢;装配层面转绿需 §5.1 的基线写授权 + 修 N-15 选择器,二者缺一不可。另注:磁盘上 85 张基线 PNG 相对 HEAD 处于 modified(2026-09-22 重生成、未提交),故"绿"依赖未提交状态。**2026-10-08 复核更正**:`git ls-files e2e/visual-snapshots` 现取为 **107 张、全部已入库且工作树干净**,「85 张未提交」不成立(同 `docs/lessons-learned.md:505`),本行原文仅作 2026-09-23 当时的叙述保留。**2026-10-08 同日再更(AUTH-D3 已闭合)**:写入 38 张(25 新 + 13 覆盖,逐张读图追认)后独立只读复跑 **125 passed / 0 failed / EXIT=0**,参照现取 **132 张**(5 project 各 26 + `manual-acceptance/` 2)⇒ 本行的 21 失败 / 104 通过 / 94-31 系列读数全部作废,改以 `docs/acceptance/qa-tracker.md` §9 与 `docs/acceptance/2026-10-08-baselines/attribution.md` 为准。另更正机制描述:**裸 `--update-snapshots`(带旗标不带值)取 `changed`** 而非 `missing`(`node_modules/playwright/lib/program.js:202` 的 `preset`),只写缺失/不符、不重写通过项;「静默创建缺失基线」对应的是**完全不带该旗标**时的缺省 `missing`(`common/index.js:584`)。 |
| 可访问性 | `npm run check:a11y`(= `check:contrast` + `check:headings` + `check:brand-token`) | WCAG AA 通过;`check:a11y` 已并入 `npm run test:all` |
| Landing 门禁 | `npm run test:landing` | 四道门禁(`e2e/landing/{layout,motion,demo,a11y}.spec.ts`,2026-12-03 从 `novavis-authority` 的四个 python 脚本移植):布局几何与焦点 / 渐进生长与 reduced-motion / 首屏剧本与无 JS 降级(四层真实可见性 + 徽标一一对应)/ 结构与全量对比度(同色无条件阻断 + axe critical/serious=0)。**已并入 `test:all`**;独立 config `e2e/playwright.landing.config.ts`(单引擎单 project,串行)。口径与判别性取证见 [docs/landing.md](docs/landing.md) §3 |
| 全量门禁 | `npm run test:all` | type-check + **check:package-keys** + **type-check:e2e** + lint + test:coverage + test:integration:real + check:a11y + **test:landing** + **check:visual** + test:e2e:fast + test:security:headers。⚠ 以 `package.json` 的 `scripts.test:all` 为唯一真源;本行曾漏记后三项,导致 `check:visual` 恒红期间「`test:all` 全绿」的宣称无法被核对(2026-11-26 补齐) |
| 真库集成层 | `npm run test:integration:real` | `config/test/jest.integration.config.js` → `tests-integration/*.itest.ts`,一次性临时 SQLite(`/tmp/novalon-itest.db`),teardown 以 inode+size+mtime 守卫 `prisma/dev.db` 未被写入。原 `test:integration`(跑 mock 版 `src/app/api/**` 路由单测)已改名 `test:integration:mocked`,A-8 的「命名误导」由此收口 |
| 性能 | `npm run lighthouse` | 满足 lhci 断言 |
> ✅ **2026-09-23 最终树数字已回填**:type-check EXIT=0(0 error)、lint EXIT=0(0 error / 105 warning)、`test:coverage` EXIT=0(134 套件 / 1697 例,global 85.56/86.86/80.59/85.56)。本轮另把 **axe 全站节点计数**与 **Lighthouse** 在**装配后的 standalone 产物**上跑通:axe `PASSED=true`(`chromium|firefox × light|dark` 各 34 页,`bgMismatch=0`、`contrastNodes=0`、`violationNodes=0`),Lighthouse 27 次运行断言全通过、**a11y 9/9 URL 均为 100**、对比度与 `aria-required-children` 失败节点 **0**(上一轮为 92-97 分 + 10 个失败节点)。前提是先修掉 N-9:standalone 产物不含 `dist/static`,此前两条门禁是在全站 CSS 404 的裸 HTML 上出数的。另修掉 N-11:`/contact` 的 CSP 违规源自 Zod 的 eval 能力探测,以 `z.config({ jitless: true })` 消除后 Lighthouse best-practices 由「8/9 齐平 + `/contact` 96」变为 **9/9 均为 100**。完整证据、未闭环项与待授权清单见 `docs/acceptance/2026-09-23-gates/final-verdict.md`;另见 `docs/acceptance/2026-09-21-gates/final-tree-results.md` 与 `CONTEXT.md` 决策表末尾新增行。
>
> **axe 节点计数门禁已于本轮落地**(2026-09-23 复核):`check:axe:routes` / `check:axe` 现指向真实存在的 `scripts/accessibility/{crawl-routes,axe-node-count}.mjs`(由 `docs/acceptance/2026-09-21-axe/` 平移而来),判定升级为**退出码** 0 通过 / 1 判红 / 2 清单缺失或 0 条;CI 在 `Jenkinsfile`「♿♿ 全站 axe 节点计数」阶段(仅 `main`)用 `node dist/standalone/server.js` 在专用端口 3100 跑,路由清单 = sitemap ∪ 预渲染产物 ∪ BFS。两条仍**不在** `test:all` 内,本地需手动跑。详见 `docs/testing.md` ⑤ 节与 `docs/development/quality-gates.md` §5。
> 提交信息须符合 Conventional Commits 规范,详见 [docs/development/quality-gates.md](docs/development/quality-gates.md)。
### 5.1 提交流程(PR-First,2026-09-20 对齐 novavis §27)
`dev`/`main` 一律经功能分支 + PR 合入,执行顺序固定:**同步 dev → rebase → push → PR 门禁 → rebase 合并**。
```bash
git fetch origin dev && git rebase origin/dev # ⚠️ 以 origin/dev 为准,本地 dev 可能陈旧
git push -u origin <feature-branch> # 改写历史后仅用 --force-with-lease,禁裸 --force
bash scripts/check-pr-checklist.sh <PR描述文件> # 未通过不得创建 PR
```
- PR 模板:[.gitea/PULL_REQUEST_TEMPLATE.md](.gitea/PULL_REQUEST_TEMPLATE.md);功能分支合并方式选 Gitea 的 **Rebase**(保持线性历史),不选 merge commit。
- 门禁校验模板三节完整(全链路检查 / 测试分层检查 / 质量门禁)+ checklist 子项 ≥ 20 + 描述文件所有子项已勾选。不适用项**仍须勾选**并注明 `N/A:理由`。
- 破坏性/共享状态动作(seed 重跑、DB 写入、force push、合并、删分支、部署)须单独取得授权,不夹带在常规变更里。
## 6. 文档同步清单
任何非单行变更都必须评估并同步更新以下文档:
- [ ] [README.md](README.md) — 规划、进度、技术栈、脚本
- [ ] [CONTEXT.md](CONTEXT.md) — 新增或变更的术语、决策
- [ ] [AGENTS.md](AGENTS.md) §9 — 新命令、架构变化、约束更新
- [ ] 受影响的设计 / 测试 / 部署文档(`docs/` 目录)
- [ ] 代码注释(说明关键决策的佐证来源)
## 7. 循环控制与错误处理
### 7.1 循环检测
若连续步骤出现以下情况,判定为循环风险:
- 输出内容实质性重复(语义相同,仅措辞变化)
- 引用的信源或推理路径与前一步完全相同,且未引入新信息
- 结论已包含在上一轮已知结论集中
### 7.2 退出流程
一旦检测到循环:
1. 立即停止当前推理链,不回退至更早步骤重试。
2. 提取当前已验证的稳定结论。
3. 生成终结性输出,标题为「基于交叉验证的最终结论」。
4. 列出未解决的歧义(不超过 2 条)。
5. 严禁在终结输出后再追加「进一步思考」或「另一种可能」。
### 7.3 双归零
任何错误立即暂停:
- **技术归零**:定位机理、复现、修复。
- **管理归零**:追溯流程漏洞、更新检查清单(如本文件或 `docs/lessons-learned.md`)。
## 8. 关键约束速查
| 约束 | 来源 |
|------|------|
| 渲染模式为 `output: 'standalone'` 混合渲染(`output: 'export'` 已移除并被 standalone 取代):营销页预渲染/ISR,`/api/*` 与 `/admin/*` 需 Node 运行时 | `next.config.mjs:85`、本文件 §9 `Build Output` |
| 静态资源走 Nginx + CDN,`images.unoptimized: true` 是部署形态的要求(无 Node 接管 `/_next/image` 时改回 `false` 会导致图片全量 404) | `next.config.mjs:8-14` |
| `next start`(= `npm run start`/`preview`)在 standalone 下会打 `"next start" does not work with "output: standalone"` 警告;受支持启动方式是 `node dist/standalone/server.js` | `node_modules/next/dist/server/next.js`、本文件 §9 `Build Output` |
| **standalone 产物不自带静态资源**:`next build` 只产出 `dist/standalone/{server.js,dist/server}`,`dist/static` 与 `public` 必须拷入 `dist/standalone/dist/static`、`dist/standalone/public`(镜像由 `Dockerfile:53-57` 的 `COPY` 完成)。本地/CI 直跑 `node dist/standalone/server.js` 前必须执行 `npm run build`(`postbuild` 钩子自动拷贝),否则全站 CSS/JS 404,`check:axe` 会以 `bgMismatch` 报红而 **Lighthouse 仍错误地 exit 0**。复验时换端口——残留 server 会给出修复前的假 404 | `Dockerfile:5-9,53-57`、`docs/acceptance/2026-09-23-gates/final-verdict.md` N-9 |
| 默认 E2E 打 dev server;GA4 与生产头只在 `npm run test:e2e:prod` 下真正断言 | `e2e/playwright.config.ts:130` |
| 品牌红 `#C41E3A` 每页 ≥ 3 处触达点,面积 ≤ 10% | `CONTEXT.md` |
| 动效时长**按类别分档**(AGENTS.md 早期把三档压成一句「180–280ms」,与 `CONTEXT.md:76` 冲突 ⇒ 已按原文改正):入场 **180–280ms**(`--transition-fast`…`--transition-normal`)、hover **150ms**、反馈 **100ms**;且**禁止超过 700ms 的入场动效**(`CONTEXT.md:82`)。缓动统一 `ease-ink` [0.22, 1, 0.36, 1] | `CONTEXT.md` §动效设计四原则 |
| 所有字体使用本地文件,禁止外部字体 CDN | 项目记忆 |
| `experimental.webpackBuildWorker` 必须禁用 | 项目记忆 |
| 组件旧版本归档到 `_archive/`,排除 TypeScript 编译 | 本文件 §9 `Archiving Convention` |
## 9. 命令速查与架构(原 CLAUDE.md 正文,2026-12-03 并入)
> 本节内容原在 `CLAUDE.md`。按 `novavis-desktop` 的口径(该仓只有 `AGENTS.md` 一份 agent 文档、`git ls-files` 无 `CLAUDE.md`),本仓 2026-12-03 收敛为单文档:`AGENTS.md` 是唯一真源,`CLAUDE.md` 已删除。历史文档里对 `CLAUDE.md` 的引用一律改指本文件对应小节。
### Common Commands
```bash
# Development
npm run dev # Start dev server on port 3000
npm run dev:clean # Clean .next/dist then start dev server
# Build & Preview
npm run build # Build production files to dist/
npm run build:clean # Clean then build
npm run start # next start -p 3000 — serve the built output
npm run preview # ALIAS of `start` (identical `next start -p 3000`); it is NOT `npx serve`
# 说明(2026-09-23 文档同步轮核实):`next start` 与 `output: 'standalone'` 组合下 Next 16 会打印
# `"next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js"
# instead.`(实测见 `docs/acceptance/2026-09-21-gates/ga4-production-run.txt`;抛出点
# `node_modules/next/dist/server/next.js` 的 `getServer()`)。它是 **warn 而非 throw**——服务照常起来,
# 但走的是不受支持的降级路径,所以门禁脚本正逐步脱离 `next start`:`test:e2e:prod` 已改为直接
# `node dist/standalone/server.js`(`e2e/playwright.config.ts:132-135`);`check:headings` 也已脱离
# `next start` —— `scripts/utils/check-heading-hierarchy.ts:55-66` 现为「存在 dist/standalone/server.js 就直接
# 起 standalone(注入 HOSTNAME/PORT/NODE_ENV),仅当产物缺失才回退 `npm run preview` 并打印告警」,
# 见验收报告 N-24③。至此门禁脚本不再依赖不受支持的 `next start` 路径。
# standalone 的受支持启动方式是 `node dist/standalone/server.js`,且服务启动前 `public/`
# 与 `dist/static` 必须已在 standalone 根目录下(server.js 启动时缓存静态索引,缺资源会让
# /_next/static/** 全 404)。**这一步由 `package.json:9` 的 `postbuild` 自动完成**(`npm run build`
# 结尾 `rm -rf` + `cp -R dist/static → dist/standalone/dist/static`、`cp -R public → dist/standalone/public`),
# 所以正常路径下"先 build 再起 standalone"即可,不必手工拷;仅当产物来自别处或要复用旧 dist 时才参照
# `Jenkinsfile:353-355`(axe 阶段复用上一阶段产物时的同套拷贝)与 `scripts/deploy.sh:162-175`
# (发布侧把 `public/` 与 `dist/static → dist/_next/static` 同步进 Nginx 站点根)。npm 侧没有包一层的启动脚本。
# Deploy (统一发布脚本)
./scripts/deploy.sh build # 构建静态产物
./scripts/deploy.sh deploy # 构建并发布到生产服务器
./scripts/deploy.sh deploy --skip-build # 使用现有 dist/ 直接发布
./scripts/deploy.sh rollback # 回滚到最近一次远程备份
./scripts/deploy.sh status # 查看生产环境发布状态
# Linting & Type Checking
npm run lint # ESLint flat config at repo root (`eslint.config.mjs`; `config/lint/.eslintrc.json` no longer exists)
npm run type-check # tsc --noEmit
npm run type-check:e2e # tsc --noEmit -p e2e/tsconfig.json(DEC-N6:e2e/** 不在根 tsconfig 内,
# 重复声明类错误只有这条能静态抓到)
npm run check:package-keys # JSON 重复键守卫(按父路径+键名;0 无重复 / 1 判红 / 2 未能度量,
# --selftest 三条各测一维)。背景:重复键被后者静默覆盖,不报错也不判红
# E2E Testing (Playwright)
npm run test # 全链路 E2E:先 test:functional(4 功能 project),再 test:visual:all(5 视觉 project),串行以免写库用例与截图并发污染基线
npm run test:functional # 仅功能 project(chromium / chromium-mobile / firefox / webkit)
npm run test:e2e # Same as test:functional
npm run test:smoke # Only @smoke-tagged tests
npm run test:e2e:prod # @smoke+@critical+@journey 打构建产物(E2E_TARGET=production → node dist/standalone/server.js,CI 门禁)
npm run test:e2e:write-db # 写库型 11 例(cms-workflow 3 + user-journey 8):目标库是 /tmp 一次性 SQLite,prisma/dev.db 全程不被写
npm run test:visual # Visual regression (Desktop Chrome)
npm run test:visual:all # Visual regression (all projects)
npm run test:visual:update # Update visual snapshots
npx playwright test --grep "test name" # Run a single E2E test by name
npm run test:landing # Landing 四道门禁(layout/motion/demo/a11y);独立 config,单引擎串行;已并入 test:all
# ⚠ E2E 目标口径(默认跑的是 dev server,不是产物)
# `npm run test` / `test:functional` 的 webServer 是 `npm run dev`(`e2e/playwright.config.ts:132-135`),
# 因此 **16 个 @critical GA4 用例(TC-GA4-001..004 × 4 project)在这一轮里是 skipped,不是 passed**:
# `NEXT_PUBLIC_GA_MEASUREMENT_ID` 只写在 `.env.production`,dev 读不到 → `GoogleAnalytics.tsx:81,119`
# 提前 return null → 用例内 `test.skip(measurementId === null, …)` 触发。证据:
# `docs/acceptance/2026-09-21-gates/skipped-tests-final-tree.json`(28 skipped 中该组恰为 16)。
# 它们真正断言的唯一入口是 `npm run test:e2e:prod`(`E2E_TARGET=production` → 直接
# `HOSTNAME=localhost PORT=3000 node dist/standalone/server.js`,非 `next start`;须先 `npm run build`
# 并把 `dist/static` + `public` 并入 standalone 根目录,见 Build & Preview 段的装配口径),
# 见同目录 `ga4-production-run.txt` 的 4 passed。故「`npm run test` 全绿」不等于 GA4 覆盖已验证。
# Unit Testing (Jest)
npm run test:unit # Run all unit tests
npm run test:coverage # Coverage report(阈值以 jest.config.js 的 coverageThreshold 为准;根配置 re-export config/test/jest.config.js 以免双份漂移)
npx jest --testPathPattern="button" # Run a single test file matching pattern
# Quality Checks
npm run check:a11y # 可访问性静态门禁伞(= check:contrast + check:headings + check:brand-token,已并入 test:all)
npm run check:contrast # 令牌对比度审计(读 globals.css 令牌表,浅色+暗色双主题、含 alpha 组,缺令牌即红)
npm run check:headings # 标题层级审计(有 dist/standalone/server.js 时直起 standalone;产物缺失才回退 `npm run preview` 并打印告警 —— scripts/utils/check-heading-hierarchy.ts:52-67)
npm run check:brand-token # 品牌红文字必须走 text-brand-ink* 令牌(DESIGN.md 双通道红规则)
npm run check:motion # 动效契约门禁(N-29 收口):R1 令牌档位(instant 100ms / fast·normal 180–280ms,CONTEXT.md:76)、
# R2 时长 ≤700ms(CSS 声明、framer transition 对象的 duration、Tailwind duration-* 类、tailwind.config 的 animation;
# infinite 循环与 *-delay 豁免)、R3 transition 时长必须走 var(--transition-*)、
# R4 写死的 cubic-bezier 必须属于令牌层 --ease-*(允许集合从 CSS 解析,不硬编码)且 --ease-ink==[0.22,1,0.36,1]。
# 退出码 0 干净 / 1 违规 / 2 未能度量(空扫描、缺令牌文件)—— 空扫描不读作干净。
# ⚠ 当前树 23 处违规(EXIT=1),故**尚未**并入 check:a11y,详见 docs/development/quality-gates.md §5.1
npm run check:motion:test # 上述门禁的自证伪测试(19 例,双向:合规夹具判 0 + 违规夹具判对应规则红);
# 测试在 scripts/ 下,jest 默认 roots 只含 src,故该脚本显式传 --roots
npm run check:axe:routes # 全站路由清单(sitemap ∪ 预渲染产物 ∪ 站内链接 BFS)→ /tmp/axe-routes.xml
# 同样需要 :3100 的生产服务(SEED 默认取 ${BASE}/sitemap.xml)
npm run check:axe # 双引擎(chromium/firefox)×双主题(light/dark)逐页 axe 节点计数 + 三条规则级
# 规则(autocomplete-valid/presentation-role-conflict/svg-img-alt)的分母断言;
# 退出码 0 通过 / 1 判红 / 2 清单缺失或 0 条(假绿熔断)。证据落
# docs/acceptance/2026-09-21-axe/axe-evidence.json。需一个生产服务在 :3100:
# PORT=3100 HOSTNAME=127.0.0.1 node dist/standalone/server.js(先拷 dist/static 与 public,见上文)
# CI 侧由 Jenkinsfile「♿♿ 全站 axe 节点计数」阶段(仅 main)自动串起
npm run test:all # type-check + check:package-keys + type-check:e2e + lint + test:coverage + test:integration:real + check:a11y + test:landing + check:visual + test:e2e:fast + test:security:headers
npm run test:e2e:prod # E2E_TARGET=production(构建产物目标);harness **不代跑构建**,须先 `npm run build`
# (standalone 根目录的 dist/static + public 由 postbuild 自动装配,见上文)
npm run lighthouse # Lighthouse CI(配置 config/test/lighthouserc.json;axe critical/serious 逐条 minScore:1;inspector-issues 亦判红——CSP/弃用类问题只走 DevTools issue 通道,errors-in-console 与 0.9 分类阈值都看不见它;报告落 lighthouse-reports/)
# Database (Prisma + SQLite)
npm run db:seed # Seed the dev database
npm run db:reset # Reset database with migrations
```
### Architecture
#### Tech Stack
- **Next.js 16.3**(App Router)混合渲染 — SSG/ISR 静态页 + API routes;`output: 'standalone'`(`next.config.mjs:44`)、`distDir: 'dist'`(`:46`)。standalone 入口是 `node dist/standalone/server.js`,需另拷 `dist/static` 与 `public`;`npm run start`(= `next start`)在 standalone 下只算不受支持的降级路径,见下文 Build Output
- **中间件命名为 `proxy.ts`**(Next 16 起 `middleware.ts` 更名);其 matcher 排除 `/api/*`,因此每个 API 路由必须自行做鉴权
- **React 18**, **TypeScript 5** (strict mode with `noUncheckedIndexedAccess`)
- **Tailwind CSS 3** with design tokens exposed as CSS custom properties (all tokenized via `var()` references in `tailwind.config.js`)
- **Framer Motion** for animations, **Lucide React** for icons, **Zod** for validation
- **shadcn/ui** pattern (Radix UI + class-variance-authority + tailwind-merge)
- **Prisma** with SQLite for backend data (admin, auth, CMS)
#### Path Alias
`@/` maps to `src/` — configured in both `tsconfig.json` (`paths`) and `jest.config.js` (`moduleNameMapper`).
#### TypeScript Strictness
Beyond `strict: true`, the project enables:
- `noUncheckedIndexedAccess: true` — array/object index access returns `T | undefined`, requiring null checks. This is a significant constraint to be aware of when writing code.
- `noImplicitReturns`, `noFallthroughCasesInSwitch`, `noUnusedLocals`, `noUnusedParameters`
#### Route Structure (App Router)
```
src/app/
├── layout.tsx # Root layout: fonts, metadata, theme, analytics, SEO schemas
├── (marketing)/ # Route group — all public marketing pages
│ ├── layout.tsx # Shared: Header + Footer + PageTransition + ErrorBoundary
│ ├── page.tsx # Home: server component, CMS zones via `lib/cms/data-server` → `home-content-v15.tsx`
│ ├── about/ # About page (client.tsx)
│ ├── news/ # News list + [slug] detail
│ ├── contact/ # Contact form
│ ├── products/ # Products hub (HSI model)
│ │ ├── page.tsx # Product listing (enterprise suites + standalone)
│ │ ├── [id]/ # Product detail (four-layer narrative)
│ │ ├── standalone/[id]/ # Standalone product detail
│ │ ├── erp-upgrade/ # Specific product landing pages
│ │ └── erp-upgrade-v3/
│ ├── services/ # Services list + [id] detail
│ ├── solutions/ # Solutions list + [id] detail (cross-references products)
│ ├── cases/ # Case studies
│ └── team/ # Team page
├── api/
│ ├── admin/ # Admin API
│ ├── auth/ # Authentication API
│ ├── cms/ # CMS API routes (draft mode, revalidation)
│ └── contact/ # Contact form submission
├── privacy/, terms/ # Legal pages
└── fonts/ # Local font files (Geist Sans/Mono)
```
#### Archiving Convention
When replacing a page or component with a new version, move the old one to an `_archive/` subdirectory (e.g., `src/app/(marketing)/_archive/` for old homepage iterations). The archive is excluded from TypeScript compilation via `tsconfig.json`.
#### Dark Mode
Dark mode uses the `data-theme="dark"` HTML attribute (not Tailwind's `dark:` class). Tailwind is configured with `darkMode: ['variant', '[data-theme="dark"] &']` — use the **variant** form, not `['selector', ...]`, because the selector form is accepted by the config but JIT emits zero `dark:` rules under Turbopack + Next.js 16.
**Three-state preference model** (`src/lib/theme.ts` is the single source of truth):
| Stored value (`localStorage['novalon-theme']`) | Meaning |
|---|---|
| `'light'` / `'dark'` | Explicit user choice — always wins over the OS |
| `'system'` / absent | Follow OS `prefers-color-scheme` (**default for new visitors**) |
- `src/app/layout.tsx` has an inline `<script>` in `<head>` that resolves the preference and sets `data-theme` **before first paint** (FOUC prevention). It must stay semantically in sync with `src/lib/theme.ts` — change both together.
- `src/components/theme/theme-toggle.tsx` cycles `跟随系统 → 浅色 → 深色`. It listens to `matchMedia('(prefers-color-scheme: dark)')` for live OS changes (only effective in the `system` state) and to `storage` events for cross-tab sync.
- `html[data-theme]` is an **output** of preference resolution — never read it back as the user's preference, or the `system` state collapses into `dark` on dark-OS machines and the cycle deadlocks.
#### HSI Information Architecture
The site follows a **Hub-Spoke-Independent** model (see `CONTEXT.md` and ADR-0002):
- **Hub**: `/products` — product catalog, split into "企业套装" (6 enterprise products) and "专业产品" (standalone)
- **Spoke**: `/solutions` — industry scenarios, each recommending product combinations from the Hub
- **Independent**: Standalone products in the specialized zone have their own narrative path
#### Four-Layer Narrative Model
Every detail page (product/service/solution/standalone) follows the same four-layer structure:
1. **L1 Hero**: Emotional entry with visual, title, value prop, status badge
2. **L2 Value Rationale**: Product-specific — features/benefits for products, pain-points→architecture for solutions, challenges→results for services
3. **L3 Trust Proof**: Case studies, data proofs, certifications, testimonials (currently stubbed — company is pre-launch)
4. **L4 CTA Conversion**: Primary action + secondary action + cross-recommendations
The detail components implementing this live in `src/components/detail/`:
- `detail-hero.tsx`, `detail-product-value.tsx`, `detail-trust-section.tsx`, `detail-cta-section.tsx`
- `solution-value.tsx`, `service-value.tsx` (type-specific L2 variants)
- `detail-cross-recommend.tsx` (cross-links between products↔solutions↔services)
#### CMS Content Architecture
`src/lib/cms/` is a **real, server-side CMS layer over Prisma** — there is no mock layer and no client-side CMS SDK (the historical names `mock-home.ts`, `ContentZoneRenderer.tsx`, `component-registry.ts`, `src/components/cms/` do not exist in the tree; do not look for them):
- `types.ts` — `FieldType`/`FieldDefinition`, `ContentModel`, `ContentStatus`, `ContentItem`, `ContentZone`, `ThemeConfig` definitions
- `content-types.ts` — `CONTENT_TYPE_CONFIGS` + `registerAllContentTypes()`: the per-model field schemas the admin form and the validator both read
- `data-server.ts` — the read path: `getPublishedItems` (`:37`), `getPublishedItemBySlug` (`:48`), `getPageZones` (`:70`), `getZone` (`:85`), `getHomePageCopy` (`:171`), each wrapped in React `cache` so a render pass hits the DB once
- `workflow.ts` / `validate-content-data.ts` / `notifications.ts` — status state machine, field validation, in-app notifications (status changes only through `workflow.ts`; see `docs/cms/api-contract.md` §10.5)
- `index.ts` — re-exports the types plus `CONTENT_TYPE_CONFIGS`
The homepage is `src/app/(marketing)/page.tsx` (server component, `export const revalidate = 3600` at `:5`): it resolves the home zones with `getResolvedHomeZones()` (`:8`) and, when the CMS has nothing configured, falls back to per-model `getPublishedItems(...)` calls (`:23-29`); the markup lives in `home-content-v15.tsx`. Earlier documents calling it `home-content-cms.tsx` are stale.
#### Design Token System
All visual tokens are defined as **CSS custom properties** in `src/app/globals.css` (`:root` block) and mapped into Tailwind's config via `var()` references:
- **Colors**: `--color-ink` (deep charcoal #0A0E14), `--color-brand` (vermilion #C41E3A), accent colors for service-coding (blue, teal, amber, purple), functional colors (success, warning, error, info), dark-section overrides
- **Typography**: `--font-size-*`, `--line-height-*`, `--letter-spacing-*` all mapped to Tailwind's `fontSize`/`lineHeight`/`letterSpacing` scales
- **Spacing, radius, shadows** all tokenized through CSS variables
- **Transitions**: `--transition-fast/normal/slow`, `--ease-ink` (cubic-bezier), `--ease-sharp`(`--ease-spring*` 死令牌已于 2026-09-19 polish 删除)
- **Dark mode**: `data-theme="dark"` attribute (set via inline script before paint to prevent flash); flipped by the `[data-theme='dark']` override block in `globals.css`, which only re-maps CSS variables — components do not restyle per element
- **Opacity**: use theme tokens (`bg-brand/20`, `border-ink/30`) — they resolve through `rgb(var(--x-rgb) / <alpha-value>)`. The arbitrary-value form `bg-[var(--color-brand)]/20` is **accepted by the parser but emits no CSS** (Tailwind v3 cannot apply an alpha modifier to a plain-hex custom property; see `tailwind.config.js:12-15`), so it fails silently. Verify any "is this style live?" claim against the compiled stylesheet, not against the source class list.
- **Two-channel red**: `--color-brand` (#C41E3A) is for surfaces only and does not flip in dark mode; text must use `text-brand-ink` (flips to #F87171). Enforced by `scripts/utils/check-brand-text-token.ts` on the text channel.
- **Hover / translucent states are unguarded**: axe skips `:hover` and `check:contrast` only asserts declared token *pairs*, so a hover background nobody noticed was dead becomes a live AA failure the moment you fix it. Composite it yourself — a semi-transparent layer **replaces** the element's own base color: `alpha*brand + (1-alpha)*pageBg`; at 20% that yields 4.18:1 against `text-brand-ink` in light theme (fail), at the `brand-soft` 12% token 4.80:1 (pass).
- **Motion tokens are gated, and the gate is currently RED**: `scripts/utils/check-motion-constraints.ts` (`npm run check:motion`, 配套 `npm run check:motion:test`) enforces the `CONTEXT.md` §动效设计四原则 bands (entrance 180–280ms, ≤700ms ceiling, durations must flow through `--transition-*` tokens, bezier allow-list **parsed from the CSS `--ease-*` tokens** — `--ease-out` is an alias of `ease-ink`, and the token layer deliberately carries 5 further curves). It is deliberately **not** part of `check:a11y`: the tree measures 23 violations / 13 files, so wiring it in would make the aggregate permanently red. `scripts/**` is eslint-ignored, so adding it did not move the lint baseline.
#### Design DNA Framework
The site follows a three-dimensional design system (see `CONTEXT.md`):
- **Dimension 1 — Design System**: Quantifiable tokens (colors, typography, spacing, radius, shadows, motion, components)
- **Dimension 2 — Design Style**: Qualitative perception (atmosphere, visual language, composition, imagery, brand tone)
- **Dimension 3 — Visual Effects**: Scroll animations, micro-interactions, parallax, SVG effects
The **Consulting Professional** aesthetic (inspired by Accenture + Bain) is the primary skeleton. **Ink cultural elements** (水墨) are secondary decorations limited to ≤6 locations (logo, dividers, transition animations, footer texture).
**Brand red (#C41E3A) usage rule**: Every page must have ≥3 brand-red touchpoints. It must never be used as paragraph text color, as a large background, or alongside accent colors in the same card. Area ≤10%. Exception: full-bleed dark-red statement/CTA blocks use the separate `crimson-veil` (#8B1530) token — see DESIGN.md「Crimson Veil」(rule clarified 2026-09-19 critique to resolve this apparent contradiction).
**Motion design**: Animations are purposeful (not decorative). Durations come from tokens, **not** from a free-form "150-300ms" range — that phrasing conflicted with `CONTEXT.md`「动效设计四原则」and is replaced by its three tiers: **入场 180–280ms**(`--transition-fast: 180ms` … `--transition-normal: 280ms`,`src/app/globals.css:264-265`)· **hover 150ms** · **反馈 100ms**;`--transition-slow: 450ms` / `--transition-slower: 700ms` 只用于揭示型动效。`ease-ink` `[0.22, 1, 0.36, 1]`(`globals.css:280`)为默认缓动,children stagger 30-60ms、Section 间 stagger 100-150ms。No continuous looping animations except `pulse-soft` for skeletons. No spring easings for content entry(spring 仅用于按钮按压反馈). **No entry animations >700ms.** Note that `duration-300` 一类的 Tailwind 预设时长绕过令牌、且 300ms 不属任何档位(残留清点见 `CONTEXT.md`「duration-300 → 动效令牌」行,该项 in flight,勿引用其计数)。
#### Data Layer
Most structured marketing content is still `src/lib/constants/` TypeScript constants, and the pages render from them; on top of that, published CMS items now override specific slots — the home page's hero/services/cases/stats/news data comes from `lib/cms/data-server` (Prisma) and only falls back to constants when the CMS has nothing configured (`src/app/(marketing)/page.tsx:8-36`), and per-section copy comes from `getHomePageCopy()` with in-component fallbacks. "Marketing content has no database" is therefore no longer true:
- `products.ts` — 6 enterprise products (ERP, CRM, CMS, BI, SDS, OA) + standalone products (NovaVis)
- `services.ts`, `solutions.ts` — Service and solution definitions
- `cases.ts` — Case studies with industry filtering
- `navigation.ts` — Nav structure + mega dropdown data
- `company.ts`, `stats.ts`, `team.ts`, `news.ts`, `methodology.ts`
- `hero-themes.ts` — Per-product hero visual theme variants
- `cross-references.ts` — Cross-links between products/solutions/services
Each product/solution/service implements the `Product`/`Solution`/`Service` interface which includes `caseStudies[]`, `dataProofs[]`, `certifications[]`, etc. for the four-layer narrative.
#### Backend Layer (Prisma + API Routes)
The project has a backend layer for admin/auth/CMS functionality:
- **Prisma** with SQLite (`prisma/dev.db`) for admin user data, auth, and CMS content management
- API routes at `src/app/api/admin/`, `auth/`, `cms/`, `contact/`
- The marketing read path and the admin write path share this backend: pages fetch published items through `src/lib/cms/data-server.ts`, while `api/admin/*` writes drafts and `api/cms/*` (`draft/enable`, `draft/disable`, `revalidate`) handles preview cache invalidation
#### Error Monitoring (Sentry)
`@sentry/nextjs@10` is wired through `src/instrumentation.ts` (server/edge, incl. `onRequestError`) and `src/instrumentation-client.ts` (client init + `onRouterTransitionStart`); `next.config.mjs` exports `withSentryConfig(nextConfig)`. **This Next 16 build defaults to Turbopack, which never loads the root `sentry.client.config.ts`** — client init therefore lives in `instrumentation-client.ts`, and the old file is kept as an empty stub solely to prevent a double `Sentry.init` on the `--webpack` path. Everything is gated on `NEXT_PUBLIC_SENTRY_DSN`: absent it, `Sentry.init` is skipped, both hooks no-op, **and the CSP is byte-identical** (`connect-src`/`worker-src` only gain the DSN's `protocol//host` when a valid DSN is present, `next.config.mjs:17-26`). Verify "is this inert?" by building without a DSN and diffing the emitted header, not by reading the source.
#### Component Organization
```
src/components/
├── ui/ # Base: Button, Card, Input, Badge, ScrollReveal, AnimatedCounter, etc.
├── layout/ # Header, Footer, MobileTabBar, Breadcrumb, MegaDropdown(MobileMenu 已删除,抽屉内置于 Header)
├── sections/ # Page section components: HeroSectionV2, ServiceGrid, CTASection, etc.
├── detail/ # Four-layer narrative: DetailHero, ProductValueSection, DetailTrustSection, etc.
├── content/ # 仅 sections.tsx(+ 同名 .test.tsx)
├── admin/ # admin-layout.tsx、auth-context.tsx(React Context 在此,不在 src/contexts/)
├── theme/ # theme-toggle.tsx
├── seo/ # Structured data (OrganizationSchema, WebsiteSchema, etc.)
└── analytics/ # GA4, error tracking, cookie consent, scroll depth, outbound links
```
> 口径核对(2026-09-23,验收 N-33「不存在的目录」一项):`cms/`、`providers/`、`effects/` 三个目录在工作树与 `git ls-tree -r HEAD` 中**均不存在**,旧图里的对应条目是残留。`ContentRenderer` / `SectionRenderer` / `FieldRenderer` 三个标识符在 `src/**/*.{ts,tsx}` 中零命中,CMS 区块渲染实际由 `src/components/content/sections.tsx` + `src/lib/cms/` 承担;`effects/` 一族已在提交 `37296b5`(2026-05-10)删除,见 `CONTEXT.md`「特效组件」。
#### Testing Setup
- **Jest** (unit): Tests alongside source in `src/**/*.test.{ts,tsx}`, coverage **thresholds** live in `config/test/jest.config.js` (global 75% stmts/lines/funcs, 82% branches) and are the single source of truth — root `jest.config.js` only re-exports it, never duplicate thresholds. **Measured values are recorded in exactly one place: `docs/development/quality-gates.md` §3** (2026-09-23 本树复跑:134 suites / 1697 tests / EXIT=0);该文件顶部注释里的百分比是滞后快照,引用前先复跑。Uses `@/` path alias and ts-jest with `jsx: 'react-jsx'` transform (since tsconfig uses `'preserve'`). Run single tests with `npx jest --testPathPattern="component-name"`.
- **Playwright** (E2E): Tests in `e2e/`, config in `e2e/playwright.config.ts` — run from `cd e2e` (`npm run test` does this). webServer is `HOSTNAME=localhost PORT=3000 node dist/standalone/server.js` when `E2E_TARGET=production` (`e2e/playwright.config.ts:132-135` — build artifacts, real security headers; CI gate uses `npm run test:e2e:prod`, and `npm run build` + the `dist/static` / `public` copies must already exist because the harness never builds) and `npm run dev` otherwise; `reuseExistingServer` is disabled for production targets, so a busy :3000 aborts the run. Functional projects: chromium, chromium-mobile (iPhone 14, 390×844), firefox, webkit — plus 5 visual-regression projects at desktop/tablet/mobile breakpoints; snapshots in `e2e/visual-snapshots/`. `mobile-*.spec.ts` must pin their own viewport because they also execute under the desktop projects. Touch-target gate lives in `e2e/touch-targets.ts` (AA SC 2.5.8 ≥24px hard, AAA SC 2.5.5 44px advisory). Visual snapshots are server-target independent — every spec imports `test` from `e2e/fixtures.ts`, whose `context` fixture injects an init script that removes the `next dev`-only `<nextjs-portal>` devtools indicator (MutationObserver on `document`, because `documentElement` is still null at document start). The indicator's shadow-DOM `<footer class="error-overlay-footer">` is pierced by Playwright's CSS engine and made `locator('footer')` resolve to 2 elements (56 failures). `devIndicators: false` is *not* a fix here — measured: the CSP-blocked-`eval` dev error keeps the overlay mounted, so the portal survives; don't reintroduce that env gate. `visual-regression.spec.ts` additionally pins the cookie-consent state via `addInitScript` (constant timestamp) because the banner renders on a 2 s timer and the `visual-firefox-desktop` / `visual-webkit-desktop` projects use an empty storage state — without the pin, slower engines photograph the banner into the first viewport and faster ones don't (34 engine-specific failures). Client-component interactions must call `expectHydrated()` from `e2e/hydrated.ts` before hover/click — SSR HTML is visible ~1.7 s before React attaches handlers, and pointer events in that window are dropped without replay. Hover-driven UI additionally needs `expect(...).toPass()` re-driving the pointer, because a single `hover()` can land mid-layout-transition and `mouseenter` never re-fires. Run single tests with `npx playwright test --grep "test name"`.
#### Build Output
The project builds to `dist/` (`distDir` in `next.config.mjs:46`) with **`output: 'standalone'`** (`next.config.mjs:44`) — this is a hybrid render model, *not* a static export (`output: 'export'` was dropped and the project has since moved on to standalone; `CONTEXT.md`「生产部署模式」records the 2026-08 switch). Concretely:
- **Prerendered/ISR**: the marketing pages, `privacy`, `terms`, `sitemap.ts`, `robots.ts`.
- **Runtime-backed**: `src/app/api/**` (20 route files — `admin/*`, `auth/*`, `cms/*`, `contact`), the `admin/` pages, and any ISR revalidation source. `proxy.ts` matchers exclude `/api/*`, so each API route authenticates itself.
- **Serving**: Nginx keeps a *disk copy* of the client static assets (`/_next/static/` with `try_files … @nextjs`, `nginx-static-production.conf:151-157`) plus `/uploads/` hardening, and proxies `/api/` (`:213`), `/admin` (`:226`) and everything else (`location /` `:238-240`, `@nextjs` `:249`) to the `nextjs_app` upstream running `dist/standalone/server.js`. Page HTML no longer has a static-file fast path — it was removed on purpose (`nginx-static-production.conf:20-25`), so "nginx serves the pages from `dist/`" is no longer true. `assetPrefix` is driven by `CDN_DOMAIN`. Container build is `Dockerfile.prod` + `docker-compose.server.yml`.
- **Images are unoptimized** (`next.config.mjs:48-61`, value at `:58`) because distribution goes through Nginx + CDN, and flipping it to `false` would require every environment to have a Node runtime taking over `/_next/image` (otherwise every image 404s). The reason is *deployment topology*, not a static-export limitation.
- **Boot command**: `npm run start` / `npm run preview` both run `next start -p 3000`, which Next 16 warns "does not work with output: standalone" (warning only — see the Build & Preview note above). The supported server is `dist/standalone/server.js`; `public/` and `dist/static` are copied into the standalone root **automatically by `package.json:9` 的 `postbuild`**,所以 `npm run build` 之后直接 `node dist/standalone/server.js` 即可。该启动方式仍没有包成 npm script —— CI 在 `Jenkinsfile:353-355` 复用产物时重做同套拷贝,发布侧由 `scripts/deploy.sh:162-175` 把 `public/` 与 `dist/static → dist/_next/static` 同步进 Nginx 站点根。
#### Commit Convention
Uses Conventional Commits with commitlint (`@commitlint/config-conventional`). Husky + lint-staged enforces linting on pre-commit.
#### Submission Flow (PR-First)
`dev`/`main` are only reached via feature branch + PR: sync `origin/dev` → rebase → push → PR gate → merge by **Rebase** (linear history, no merge commit).
`bash scripts/check-pr-checklist.sh <pr-description-file>` must pass before opening a PR — it verifies `.gitea/PULL_REQUEST_TEMPLATE.md` has the three required sections (全链路检查 / 测试分层检查 / 质量门禁) with ≥20 checklist items, and that every item in the PR body is checked (mark irrelevant ones as `N/A:<reason>`).
Rebase rewrites hashes: an already-pushed branch may only be updated with `--force-with-lease`. Always rebase onto `origin/dev`, never a possibly-stale local `dev`.
#### Component Versioning History
The project has gone through multiple design iterations. Older component versions:
- `components/detail-v2/` — previous iteration (deleted per git status, migration to `detail/` completed)
- `components/detail-v3/` — another iteration (deleted, same reason)
- `home-content-v2.tsx` through `home-content-v11.tsx` — archived homepage iterations in `(marketing)/_archive/`
- The current canonical components are in `components/detail/` and `home-content-cms.tsx`
## 10. 相关资源
- [CONTEXT.md](CONTEXT.md) — 领域术语与关键决策
- [AGENTS.md](AGENTS.md) §9 — 开发命令与架构指南(本文件,单文档真源)
- [README.md](README.md) — 项目概览与进度
- [docs/development/quality-gates.md](docs/development/quality-gates.md) — 质量门禁详情
- [docs/testing.md](docs/testing.md) — 测试策略与指南
- [docs/lessons-learned.md](docs/lessons-learned.md) — 跨任务经验教训
<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
<!-- END:nextjs-agent-rules -->