From 99eaa8c66a3134b81fae8126ae4a0740ccfa4c1a Mon Sep 17 00:00:00 2001 From: zhangxiang Date: Thu, 3 Dec 2026 22:56:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(landing):=20=E7=9D=BF=E8=A7=86=20landing?= =?UTF-8?q?=20=E7=94=B1=E6=9C=AC=E4=BB=93=E7=BB=9F=E4=B8=80=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E2=80=94=E2=80=94=E6=BA=90=E7=A0=81=E5=AD=90=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=8C=96=20+=20=E5=9B=9B=E9=81=93=E9=97=A8=E7=A6=81?= =?UTF-8?q?=E7=A7=BB=E6=A4=8D=20+=20=E5=A5=91=E7=BA=A6=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 承接 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。 --- .gitea/PULL_REQUEST_TEMPLATE.md | 2 +- .gitignore | 7 +- .lintstagedrc.json | 3 + CLAUDE.md => AGENTS.md | 307 +++++++++++- CONTEXT.md | 3 +- Jenkinsfile | 6 + README.md | 7 +- docs/acceptance/qa-tracker.md | 115 +++++ docs/adr/0014-product-independent-sites.md | 14 +- docs/deployment.md | 48 ++ docs/development/quality-gates.md | 2 +- docs/landing.md | 262 +++++++++++ ...26-12-03-product-independent-sites-plan.md | 409 ++++++++++++++++ docs/testing.md | 2 +- docs/troubleshooting.md | 2 +- e2e/landing/a11y.spec.ts | 433 +++++++++++++++++ e2e/landing/demo.spec.ts | 216 +++++++++ e2e/landing/layout.spec.ts | 240 ++++++++++ e2e/landing/motion.spec.ts | 193 ++++++++ e2e/playwright.landing.config.ts | 72 +++ eslint.config.mjs | 7 + next.config.mjs | 30 +- package.json | 3 +- public/{ => novavis}/assets/favicon.png | Bin .../assets/novavis-logo-icon.png | Bin public/{ => novavis}/css/style.css | 0 public/{ => novavis}/images/logos/apple.svg | 0 public/{ => novavis}/images/logos/kylin.png | Bin .../{ => novavis}/images/logos/uos-symbol.svg | 0 public/{ => novavis}/images/logos/windows.svg | 0 public/{ => novavis}/js/main.js | 12 +- scripts/landing/landing-audit.py | 439 ++++++++++++++++++ scripts/landing/landing-demo-verify.py | 247 ++++++++++ .../selfcheck/fixture-failing-landing.html | 31 ++ scripts/landing/verify-landing-layout.py | 305 ++++++++++++ scripts/landing/verify-landing-motion.py | 226 +++++++++ src/app/api/v1/contact/route.test.ts | 155 +++++++ src/app/api/v1/contact/route.ts | 154 ++++++ 38 files changed, 3904 insertions(+), 48 deletions(-) rename CLAUDE.md => AGENTS.md (60%) create mode 100644 docs/landing.md create mode 100644 docs/plans/2026-12-03-product-independent-sites-plan.md create mode 100644 e2e/landing/a11y.spec.ts create mode 100644 e2e/landing/demo.spec.ts create mode 100644 e2e/landing/layout.spec.ts create mode 100644 e2e/landing/motion.spec.ts create mode 100644 e2e/playwright.landing.config.ts rename public/{ => novavis}/assets/favicon.png (100%) rename public/{ => novavis}/assets/novavis-logo-icon.png (100%) rename public/{ => novavis}/css/style.css (100%) rename public/{ => novavis}/images/logos/apple.svg (100%) rename public/{ => novavis}/images/logos/kylin.png (100%) rename public/{ => novavis}/images/logos/uos-symbol.svg (100%) rename public/{ => novavis}/images/logos/windows.svg (100%) rename public/{ => novavis}/js/main.js (99%) create mode 100644 scripts/landing/landing-audit.py create mode 100644 scripts/landing/landing-demo-verify.py create mode 100644 scripts/landing/selfcheck/fixture-failing-landing.html create mode 100644 scripts/landing/verify-landing-layout.py create mode 100644 scripts/landing/verify-landing-motion.py create mode 100644 src/app/api/v1/contact/route.test.ts create mode 100644 src/app/api/v1/contact/route.ts diff --git a/.gitea/PULL_REQUEST_TEMPLATE.md b/.gitea/PULL_REQUEST_TEMPLATE.md index 892245fc..a2701b68 100644 --- a/.gitea/PULL_REQUEST_TEMPLATE.md +++ b/.gitea/PULL_REQUEST_TEMPLATE.md @@ -47,7 +47,7 @@ - [ ] `npm run check:contrast` 与 `npm run check:headings` 通过(WCAG 2.1 AA) - [ ] `npm run lighthouse` 满足 `lhci` 断言(性能/CSP/可访问性预算未回退) - [ ] `npm run test:security:headers` 通过(若改动涉及响应头、CSP 或部署配置) -- [ ] 文档已同步:`README.md` / `CONTEXT.md` / `CLAUDE.md` / `DESIGN.md` / `PRODUCT.md` 及 `docs/` 下受影响文件;代码注释给出决策佐证来源 +- [ ] 文档已同步:`README.md` / `CONTEXT.md` / `AGENTS.md` / `DESIGN.md` / `PRODUCT.md` 及 `docs/` 下受影响文件;代码注释给出决策佐证来源 - [ ] 提交信息符合 Conventional Commits,且每个 commit 是可独立评审的垂直切片 - [ ] 破坏性/共享状态动作(seed 重跑、DB 写入、force push、合并、删分支、部署)已单独取得授权,未夹带在常规变更里 diff --git a/.gitignore b/.gitignore index 4dbbedc9..b9eab5ba 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,9 @@ playwright-traces/ # E2E test results e2e/test-results/ +# landing 门禁(`npm run test:landing`)的独立 outputDir:配置在 +# e2e/playwright.landing.config.ts,与主 config 分开以免两次运行的 trace 互相覆盖。 +e2e/test-results-landing/ e2e/playwright-report/ e2e/allure-results/ e2e/allure-report/ @@ -313,7 +316,9 @@ findings.md # Git will track them because they are not in test-results/ or allure-results/ # AGENTS -AGENTS.md +# 2026-12-03:AGENTS.md 转为**受版本跟踪的唯一 agent 文档**(对齐 novavis-desktop: +# 该仓只有 AGENTS.md、无 CLAUDE.md)。此前这里忽略它,导致仓库里唯一受跟踪的 agent +# 文档反而是 CLAUDE.md —— 与 desktop 口径相反,且新人 clone 后拿不到工作流指南。 # dogfood dogfood-output*/ diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 3cfebc9b..f0d7449d 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,5 +1,8 @@ { "!(public)/**/*.{js,jsx,ts,tsx}": [ "eslint --fix" + ], + "public/novavis/js/**/*.js": [ + "eslint --fix" ] } diff --git a/CLAUDE.md b/AGENTS.md similarity index 60% rename from CLAUDE.md rename to AGENTS.md index 32e7eb15..11f411d2 100644 --- a/CLAUDE.md +++ b/AGENTS.md @@ -1,8 +1,245 @@ -# CLAUDE.md +# Novalon Website 开发工作流指南 -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. +本文件定义 AI 代理与开发者在参与本项目时应遵循的标准工作流。核心目标是**在需求清晰、文档一致、测试覆盖的前提下交付可验证的代码变更**。 -## Common Commands +## 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 # 改写历史后仅用 --force-with-lease,禁裸 --force +bash scripts/check-pr-checklist.sh # 未通过不得创建 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 @@ -58,6 +295,7 @@ 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`), @@ -96,7 +334,7 @@ npm run check:axe # 双引擎(chromium/firefox)×双主题(light/da # 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 + check:visual + test:e2e:fast + test:security:headers +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/) @@ -106,9 +344,9 @@ npm run db:seed # Seed the dev database npm run db:reset # Reset database with migrations ``` -## Architecture +### Architecture -### Tech Stack +#### 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`) @@ -117,15 +355,15 @@ npm run db:reset # Reset database with migrations - **shadcn/ui** pattern (Radix UI + class-variance-authority + tailwind-merge) - **Prisma** with SQLite for backend data (admin, auth, CMS) -### Path Alias +#### Path Alias `@/` maps to `src/` — configured in both `tsconfig.json` (`paths`) and `jest.config.js` (`moduleNameMapper`). -### TypeScript Strictness +#### 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) +#### Route Structure (App Router) ``` src/app/ ├── layout.tsx # Root layout: fonts, metadata, theme, analytics, SEO schemas @@ -154,10 +392,10 @@ src/app/ └── fonts/ # Local font files (Geist Sans/Mono) ``` -### Archiving Convention +#### 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 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): @@ -171,13 +409,13 @@ Dark mode uses the `data-theme="dark"` HTML attribute (not Tailwind's `dark:` cl - `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 +#### 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 +#### 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 @@ -189,7 +427,7 @@ The detail components implementing this live in `src/components/detail/`: - `solution-value.tsx`, `service-value.tsx` (type-specific L2 variants) - `detail-cross-recommend.tsx` (cross-links between products↔solutions↔services) -### CMS Content Architecture +#### 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 @@ -199,7 +437,7 @@ The detail components implementing this live in `src/components/detail/`: 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 +#### 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 @@ -212,7 +450,7 @@ All visual tokens are defined as **CSS custom properties** in `src/app/globals.c - **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 +#### 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) @@ -224,7 +462,7 @@ The **Consulting Professional** aesthetic (inspired by Accenture + Bain) is the **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 +#### 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 @@ -236,16 +474,16 @@ Most structured marketing content is still `src/lib/constants/` TypeScript const 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) +#### 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) +#### 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 +#### Component Organization ``` src/components/ ├── ui/ # Base: Button, Card, Input, Badge, ScrollReveal, AnimatedCounter, etc. @@ -260,11 +498,11 @@ src/components/ ``` > 口径核对(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 +#### 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 `` devtools indicator (MutationObserver on `document`, because `documentElement` is still null at document start). The indicator's shadow-DOM `