@devflow-tools/plugin-css 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,eAAO,MAAM,SAAS,EAAE,aAmIvB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const cssPlugin = {
|
|
2
|
+
meta: {
|
|
3
|
+
name: "css",
|
|
4
|
+
version: "0.1.0",
|
|
5
|
+
description: "CSS 专家 — 布局调试、响应式审查、BEM 规范、性能优化",
|
|
6
|
+
icon: "🎨",
|
|
7
|
+
tags: ["frontend", "css", "scss", "responsive", "layout"],
|
|
8
|
+
},
|
|
9
|
+
knowledge: {
|
|
10
|
+
sources: [
|
|
11
|
+
{
|
|
12
|
+
name: "mdn-css",
|
|
13
|
+
urls: [
|
|
14
|
+
"https://developer.mozilla.org/en-US/docs/Web/CSS",
|
|
15
|
+
"https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout",
|
|
16
|
+
"https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout",
|
|
17
|
+
],
|
|
18
|
+
pluginName: "css",
|
|
19
|
+
version: "2024",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
memory: {
|
|
24
|
+
project: {
|
|
25
|
+
stack: ["CSS3", "SCSS", "CSS Modules", "PostCSS"],
|
|
26
|
+
conventions: [
|
|
27
|
+
{ key: "naming", value: "使用 BEM 命名规范(Block__Element--Modifier)", source: "manual", confidence: 0.9 },
|
|
28
|
+
{ key: "layout", value: "优先使用 Flexbox + Grid 布局,避免 float", source: "manual", confidence: 0.9 },
|
|
29
|
+
{ key: "responsive", value: "移动优先,断点 768px / 1024px / 1280px", source: "manual", confidence: 0.8 },
|
|
30
|
+
{ key: "variables", value: "使用 CSS 变量管理主题色和间距", source: "manual", confidence: 0.85 },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
global: [
|
|
34
|
+
{
|
|
35
|
+
id: "css:layout-strategies",
|
|
36
|
+
source: "css",
|
|
37
|
+
title: "CSS 布局策略",
|
|
38
|
+
content: "Flexbox 用于一维布局(导航栏、列表)。Grid 用于二维布局(页面骨架、仪表盘)。避免 float。gap 替代 margin 间隔。minmax() 和 auto-fit 实现自适应网格。",
|
|
39
|
+
embedding: [],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "css:bem-naming",
|
|
43
|
+
source: "css",
|
|
44
|
+
title: "BEM 命名规范",
|
|
45
|
+
content: "Block(块):独立组件如 .card。Element(元素):__ 连接如 .card__title。Modifier(修饰符):-- 连接如 .card--featured。",
|
|
46
|
+
embedding: [],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "css:responsive-patterns",
|
|
50
|
+
source: "css",
|
|
51
|
+
title: "响应式设计模式",
|
|
52
|
+
content: "移动优先:基础样式给移动端,@media min-width 给更大屏幕。clamp() 实现流体排版。容器查询 @container 用于组件级响应。避免固定宽度,使用 max-width + 百分比。",
|
|
53
|
+
embedding: [],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "css:performance",
|
|
57
|
+
source: "css",
|
|
58
|
+
title: "CSS 性能优化",
|
|
59
|
+
content: "避免复杂选择器(深层嵌套)。避免 reflow 触发(频繁改 width/height/top/left)。使用 will-change 提示浏览器优化。CSS containment 限制重排范围。减少 @import 使用。",
|
|
60
|
+
embedding: [],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
workflow: {
|
|
65
|
+
steps: [],
|
|
66
|
+
templates: [
|
|
67
|
+
{
|
|
68
|
+
name: "layout-debug",
|
|
69
|
+
description: "布局调试:检查元素定位 → 弹性/网格属性 → 修复",
|
|
70
|
+
version: "1.0.0",
|
|
71
|
+
steps: [
|
|
72
|
+
{ id: "inspect-element", description: "定位布局异常元素(DevTools 检查盒模型)", type: "simple", timeout: 5000 },
|
|
73
|
+
{ id: "check-box-model", description: "检查盒模型(width/height/padding/border/margin)", type: "simple", depends: ["inspect-element"], timeout: 10000 },
|
|
74
|
+
{ id: "check-positioning", description: "检查定位方式(static/relative/absolute/fixed/sticky)", type: "simple", depends: ["inspect-element"], timeout: 10000 },
|
|
75
|
+
{ id: "check-flex-grid", description: "检查 Flexbox/Grid 容器和子项属性", type: "simple", depends: ["inspect-element"], timeout: 10000 },
|
|
76
|
+
{ id: "check-z-index", description: "检查 z-index 和层叠上下文", type: "simple", depends: ["check-positioning"], timeout: 5000 },
|
|
77
|
+
{ id: "search-docs", description: "搜索 MDN CSS 文档中的相关属性", type: "simple", timeout: 10000 },
|
|
78
|
+
{ id: "generate-fix", description: "生成布局修复方案", type: "llm", depends: ["check-box-model", "check-flex-grid", "check-z-index", "search-docs"], timeout: 15000 },
|
|
79
|
+
{ id: "verify-layout", description: "截图对比验证修复效果", type: "simple", depends: ["generate-fix"], timeout: 10000 },
|
|
80
|
+
],
|
|
81
|
+
triggers: [{ type: "cli", command: "debug:layout" }],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "responsive-audit",
|
|
85
|
+
description: "响应式审查:断点检查 → 媒体查询 → 流体方案",
|
|
86
|
+
version: "1.0.0",
|
|
87
|
+
steps: [
|
|
88
|
+
{ id: "scan-breakpoints", description: "扫描项目中所有 @media 断点", type: "simple", timeout: 10000 },
|
|
89
|
+
{ id: "check-consistency", description: "检查断点是否统一(避免 767/768/769 混用)", type: "simple", depends: ["scan-breakpoints"], timeout: 10000 },
|
|
90
|
+
{ id: "check-mobile-first", description: "检查是否移动优先(min-width 而非 max-width)", type: "simple", depends: ["scan-breakpoints"], timeout: 5000 },
|
|
91
|
+
{ id: "find-hardcoded-widths", description: "查找硬编码宽度(固定 px 而非百分比/flex)", type: "simple", timeout: 10000 },
|
|
92
|
+
{ id: "suggest-fluid", description: "建议流体方案(clamp/min/max 替代固定值)", type: "llm", depends: ["check-consistency", "find-hardcoded-widths"], timeout: 15000 },
|
|
93
|
+
{ id: "apply-fixes", description: "应用响应式修复", type: "llm", depends: ["suggest-fluid"], timeout: 20000 },
|
|
94
|
+
{ id: "verify-responsive", description: "多视口截图验证", type: "simple", depends: ["apply-fixes"], timeout: 15000 },
|
|
95
|
+
],
|
|
96
|
+
triggers: [{ type: "cli", command: "audit:responsive" }],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "bem-review",
|
|
100
|
+
description: "BEM 命名审查:扫描类名 → 规范检查 → 修复建议",
|
|
101
|
+
version: "1.0.0",
|
|
102
|
+
steps: [
|
|
103
|
+
{ id: "scan-classnames", description: "扫描项目所有 CSS 类名", type: "simple", timeout: 10000 },
|
|
104
|
+
{ id: "check-bem-compliance", description: "检查是否遵循 BEM 规范", type: "simple", depends: ["scan-classnames"], timeout: 10000 },
|
|
105
|
+
{ id: "find-deep-nesting", description: "查找深层嵌套选择器(> 3 级)", type: "simple", depends: ["scan-classnames"], timeout: 5000 },
|
|
106
|
+
{ id: "find-utility-override", description: "查找 !important 和样式覆盖", type: "simple", depends: ["scan-classnames"], timeout: 5000 },
|
|
107
|
+
{ id: "generate-report", description: "生成 BEM 合规报告", type: "llm", depends: ["check-bem-compliance", "find-deep-nesting", "find-utility-override"], timeout: 15000 },
|
|
108
|
+
{ id: "refactor-names", description: "重构不符合 BEM 的类名", type: "llm", depends: ["generate-report"], timeout: 20000 },
|
|
109
|
+
],
|
|
110
|
+
triggers: [{ type: "cli", command: "review:bem" }],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
prompt: {
|
|
115
|
+
system: "你是一个 CSS 专家。使用现代布局方案(Flexbox/Grid),遵循 BEM 命名,移动优先响应式设计。遇到问题先查 MDN 文档。",
|
|
116
|
+
rules: [
|
|
117
|
+
"使用 BEM 命名规范",
|
|
118
|
+
"优先使用 Flexbox 和 Grid 布局",
|
|
119
|
+
"移动优先响应式设计",
|
|
120
|
+
"使用 CSS 变量管理主题",
|
|
121
|
+
"避免 !important 和深层嵌套",
|
|
122
|
+
"使用 rem/em 做相对单位",
|
|
123
|
+
"不确定属性行为时先查 MDN 文档确认",
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
tools: [],
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAkB;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,iCAAiC;QAC9C,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC;KAC1D;IAED,SAAS,EAAE;QACT,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE;oBACJ,kDAAkD;oBAClD,0EAA0E;oBAC1E,kEAAkE;iBACnE;gBACD,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,MAAM;aAChB;SACF;KACF;IAED,MAAM,EAAE;QACN,OAAO,EAAE;YACP,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC;YACjD,WAAW,EAAE;gBACX,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,uCAAuC,EAAE,MAAM,EAAE,QAAiB,EAAE,UAAU,EAAE,GAAG,EAAE;gBAC7G,EAAE,GAAG,EAAE,QA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+
"name": "@devflow-tools/plugin-css",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -b",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@devflow-tools/sdk": "*"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.5.0",
|
|
24
|
+
"vitest": "^2.0.0"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"gitHead": "4cede97fc7fc673f929427fac169acab100ca8ed"
|
|
30
|
+
}
|