diff --git a/docs/rule-fixture/2026-11-19/index.html b/docs/rule-fixture/2026-11-19/index.html new file mode 100644 index 0000000..9a7474a --- /dev/null +++ b/docs/rule-fixture/2026-11-19/index.html @@ -0,0 +1,122 @@ + + + + +规则样张 + + + +
+

规则样张

+
+
+ 宽度 +
+ 缩放 +
+
+
+ + + diff --git a/docs/rule-fixture/2026-11-19/m1-list.html b/docs/rule-fixture/2026-11-19/m1-list.html new file mode 100644 index 0000000..53ee9eb --- /dev/null +++ b/docs/rule-fixture/2026-11-19/m1-list.html @@ -0,0 +1,359 @@ + + + + + +学习任务 + + + + +
+
+

学习任务

+

+
+ +
+

+ + + + +
+
+
+ +
+ +
+ + + + diff --git a/docs/rule-fixture/2026-11-19/m2-session.html b/docs/rule-fixture/2026-11-19/m2-session.html new file mode 100644 index 0000000..90aabec --- /dev/null +++ b/docs/rule-fixture/2026-11-19/m2-session.html @@ -0,0 +1,395 @@ + + + + + +学习会话 · LPT + + + + +

学习会话

+ +
+
+ 剩余 + 17:56 +
+ + +
+ +
+
+ + + + +
+ + + +
+

本次已记 3 条知识碎片

+ + +
+
+ +
+ +
+ + + + diff --git a/docs/rule-fixture/2026-11-19/shots/m1-list.png b/docs/rule-fixture/2026-11-19/shots/m1-list.png new file mode 100644 index 0000000..0843203 Binary files /dev/null and b/docs/rule-fixture/2026-11-19/shots/m1-list.png differ diff --git a/docs/rule-fixture/2026-11-19/shots/m2-session.png b/docs/rule-fixture/2026-11-19/shots/m2-session.png new file mode 100644 index 0000000..b28a174 Binary files /dev/null and b/docs/rule-fixture/2026-11-19/shots/m2-session.png differ diff --git a/docs/rule-fixture/2026-11-19/shots/w1-list.png b/docs/rule-fixture/2026-11-19/shots/w1-list.png new file mode 100644 index 0000000..c03d2bb Binary files /dev/null and b/docs/rule-fixture/2026-11-19/shots/w1-list.png differ diff --git a/docs/rule-fixture/2026-11-19/shots/w2-form.png b/docs/rule-fixture/2026-11-19/shots/w2-form.png new file mode 100644 index 0000000..0706930 Binary files /dev/null and b/docs/rule-fixture/2026-11-19/shots/w2-form.png differ diff --git a/docs/rule-fixture/2026-11-19/verdict.md b/docs/rule-fixture/2026-11-19/verdict.md new file mode 100644 index 0000000..a35817e --- /dev/null +++ b/docs/rule-fixture/2026-11-19/verdict.md @@ -0,0 +1,22 @@ +# 规则样张判定 2026-11-19 + +- 规则版本:提交 `1a81ddc`(分支 `dev`) +- 规则文件未提交改动:`design-principles.md` `design-system.md` `code-standards.md` `ui-review-checklist.md` 有未提交修改;`responsive.md` 为未跟踪新文件 +- 生成方式:四个无上下文子代理并行 +- 样张:`w1-list` `w2-form` `m1-list` `m2-session`,截图在 `shots/` + +## 哪儿能用 + +<一句话。这一版整体能不能直接拿去当设计参考:能用到什么程度。> + +## 哪儿别扭 + +<规则写了但没管住的地方。每条写:哪一份页面、哪个位置、哪条规则没管住。> + +## 规则没管到 + +<页面这么做了、规则里没提的地方。每条写:现象、该补进哪份规则文件。这一段是本次的核心产出。> + +## 处理 + +<当场补规则 / 记进 OPTIMIZATION_BACKLOG.md / 不改。每条一行。> diff --git a/docs/rule-fixture/2026-11-19/w1-list.html b/docs/rule-fixture/2026-11-19/w1-list.html new file mode 100644 index 0000000..2b049f2 --- /dev/null +++ b/docs/rule-fixture/2026-11-19/w1-list.html @@ -0,0 +1,370 @@ + + + + + + +学习任务 · 规则样张 + + + + +
+
+

学习任务

+ +
+ +

+ +
+
+

共 12 个任务

+
+ + 第 1 / 2 页 + +
+
+ + +
+ + + + + + +
+ +
+
+ 样张状态 + + + + +
+
+ + + + diff --git a/docs/rule-fixture/2026-11-19/w2-form.html b/docs/rule-fixture/2026-11-19/w2-form.html new file mode 100644 index 0000000..f045290 --- /dev/null +++ b/docs/rule-fixture/2026-11-19/w2-form.html @@ -0,0 +1,361 @@ + + + + + + +新建任务 + + + +
+
+

新建任务

+
+ +
+
+
+ + + +
+ +
+ + +

可以写很长。写清范围、想达到的程度,以及你已经会什么。

+ +
+ +
+ + + +

回车加一个标签,之后可以按标签筛任务。

+
+ + + + +
+ + +
+
+
+ + +
+ + + + + + diff --git a/docs/rule-fixture/README.md b/docs/rule-fixture/README.md new file mode 100644 index 0000000..3186722 --- /dev/null +++ b/docs/rule-fixture/README.md @@ -0,0 +1,11 @@ +# 规则样张 + +`rule-fixture` 技能的产出目录。 + +- 一次运行一个日期目录:四份静态页面 + `shots/` 截图 + `verdict.md` 判定。 +- 打开方式:`cd lpt-fe/docs/rule-fixture/<日期>` 后 `python3 -m http.server 5171`,浏览器开 `http://localhost:5171`;或直接双击该目录的 `index.html`。 +- 只保留最近三次,更早的删掉;历史看 git。 +- **样张不是实现范本**:它只反映生成那天的规则,页面长相不代表产品该长什么样,也不要复制进 `src/` 或加路由。 +- 判定只由人写,写在 `verdict.md` 的「规则没管到」里;那是下一次改规则的输入。 + +用法见 `lpt-fe/.agents/skills/rule-fixture/SKILL.md`。 diff --git a/package.json b/package.json index fa3472a..5e46b60 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "test:watch": "vitest", "test:coverage": "vitest run --coverage", "test:e2e": "npx playwright test", - "test:e2e:ui": "playwright test --ui" + "test:e2e:ui": "playwright test --ui", + "lint:ui": "node scripts/lint-ui.mjs" }, "dependencies": { "async-validator": "^4.2.5", diff --git a/scripts/lint-ui.mjs b/scripts/lint-ui.mjs new file mode 100644 index 0000000..9e75f0f --- /dev/null +++ b/scripts/lint-ui.mjs @@ -0,0 +1,85 @@ +#!/usr/bin/env node +/** + * 设计规则的可执行部分(design-system.md / code-standards.md / design-principles.md)。 + * + * 四条检查,任一命中即退出码 1: + * 1. 组件里的颜色字面量(main.css 之外,白名单只有 MindMapViewer 的导图调色板) + * 2. transition: all + * 3. 模板里写死的颜色(:color="'#…'" 这类) + * 4. 界面旧名「残片」(现行名:知识碎片) + * + * 只在 src/ 下扫描;白名单的取值登记在 design-system.md 的「颜色白名单」一节。 + */ +import { readdirSync, readFileSync, statSync } from 'node:fs'; +import { join, relative } from 'node:path'; + +const ROOT = process.cwd(); +const SRC = join(ROOT, 'src'); +const HEX_ALLOWLIST = new Set(['components/MindMapViewer.vue']); +const SOURCE_EXT = new Set(['.vue', '.ts', '.css']); +const OLD_NAME = '残片'; + +const walk = (dir) => { + const files = []; + for (const entry of readdirSync(dir)) { + const full = join(dir, entry); + if (statSync(full).isDirectory()) files.push(...walk(full)); + else files.push(full); + } + return files; +}; + +const files = walk(SRC).filter((file) => [...SOURCE_EXT].some((ext) => file.endsWith(ext))); +const violations = []; +const report = (file, line, rule, detail) => { + violations.push({ file: relative(ROOT, file), line, rule, detail }); +}; + +for (const file of files) { + const rel = relative(SRC, file).split('\\').join('/'); + const content = readFileSync(file, 'utf8'); + const lines = content.split('\n'); + const isVue = file.endsWith('.vue'); + const isMainCss = rel === 'assets/main.css'; + + if (isVue) { + const templateColors = [ + /:[\w-]+\s*=\s*"[^"]*#[0-9a-fA-F]{3,8}/g, + /:[\w-]+\s*=\s*'[^']*#[0-9a-fA-F]{3,8}/g, + ]; + for (const templateColor of templateColors) { + for (const match of content.matchAll(templateColor)) { + const line = content.slice(0, match.index).split('\n').length; + report(file, line, 'no-template-color', '模板绑定里写死颜色,改成按状态给 class'); + } + } + } + + lines.forEach((line, index) => { + const lineNumber = index + 1; + + if (isVue && !HEX_ALLOWLIST.has(rel)) { + const hex = line.match(/#[0-9a-fA-F]{3,8}\b/); + if (hex) report(file, lineNumber, 'no-hex', `组件里写颜色字面量 ${hex[0]},改用 var(--x)`); + } + + if (!isMainCss && /transition\s*:\s*all\b/i.test(line)) { + report(file, lineNumber, 'no-transition-all', 'transition: all 会把无关属性一起动画,显式列出属性'); + } + + if (line.includes(OLD_NAME)) { + report(file, lineNumber, 'no-old-name', `旧名「${OLD_NAME}」不得出现在代码与界面,现行名是「知识碎片」`); + } + }); +} + +if (violations.length) { + console.error(`ui-lint: ${violations.length} 处违反设计规则\n`); + for (const { file, line, rule, detail } of violations) { + console.error(` ${file}:${line} [${rule}] ${detail}`); + } + console.error('\n规则依据:.agents/roles/design-system.md、code-standards.md、design-principles.md'); + process.exit(1); +} + +console.log(`ui-lint: ${files.length} 个文件通过(颜色字面量 / transition: all / 模板颜色 / 旧名)`);