@devflow-tools/plugin-tailwind 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.
@@ -0,0 +1,3 @@
1
+ import type { DevFlowPlugin } from "@devflow-tools/sdk";
2
+ export declare const tailwindPlugin: DevFlowPlugin;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,cAAc,EAAE,aAgI5B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,125 @@
1
+ export const tailwindPlugin = {
2
+ meta: {
3
+ name: "tailwind",
4
+ version: "0.1.0",
5
+ description: "Tailwind 专家 — 响应式设计、主题定制、Purge 检查、Utility 审查",
6
+ icon: "🌊",
7
+ tags: ["frontend", "css", "tailwind", "utility-first", "responsive"],
8
+ },
9
+ knowledge: {
10
+ sources: [
11
+ {
12
+ name: "tailwind-docs",
13
+ urls: [
14
+ "https://tailwindcss.com/docs",
15
+ "https://tailwindcss.com/docs/configuration",
16
+ "https://tailwindcss.com/docs/customizing-colors",
17
+ ],
18
+ pluginName: "tailwind",
19
+ version: "3.4.0",
20
+ },
21
+ ],
22
+ },
23
+ memory: {
24
+ project: {
25
+ stack: ["Tailwind CSS 3", "PostCSS", "autoprefixer"],
26
+ conventions: [
27
+ { key: "styling", value: "优先使用 Tailwind utility classes,避免自定义 CSS", source: "manual", confidence: 0.9 },
28
+ { key: "responsive", value: "使用 sm:/md:/lg:/xl:/2xl: 断点前缀", source: "manual", confidence: 0.9 },
29
+ { key: "theme", value: "自定义颜色和间距通过 tailwind.config.ts", source: "manual", confidence: 0.85 },
30
+ { key: "dark-mode", value: "使用 dark: 前缀和 class 策略实现暗色模式", source: "manual", confidence: 0.8 },
31
+ ],
32
+ },
33
+ global: [
34
+ {
35
+ id: "tailwind:utility-first",
36
+ source: "tailwind",
37
+ title: "Utility-First 设计理念",
38
+ content: "直接在 HTML 中使用预定义的 utility class 构建界面。优点:无需命名 CSS 类,样式不会级联,体积通过 PurgeCSS 优化。复杂样式抽取为 @apply 指令。",
39
+ embedding: [],
40
+ },
41
+ {
42
+ id: "tailwind:responsive",
43
+ source: "tailwind",
44
+ title: "响应式设计断点",
45
+ content: "Tailwind 默认断点:sm(640px)、md(768px)、lg(1024px)、xl(1280px)、2xl(1536px)。移动优先:unprefixed class 作用于小屏。",
46
+ embedding: [],
47
+ },
48
+ {
49
+ id: "tailwind:theme-customization",
50
+ source: "tailwind",
51
+ title: "主题定制方法",
52
+ content: "tailwind.config.ts 中 extend 字段扩展默认主题。colors、spacing、fontSize 通过 extend 追加。使用 CSS 变量配合 theme() 函数实现动态主题。",
53
+ embedding: [],
54
+ },
55
+ {
56
+ id: "tailwind:performance",
57
+ source: "tailwind",
58
+ title: "Tailwind 性能优化",
59
+ content: "content 路径精确匹配避免扫描无关文件。safelist 只包含动态类名。使用 @layer 管理样式优先级。避免 @apply 过度使用。生产构建自动移除未使用样式。",
60
+ embedding: [],
61
+ },
62
+ ],
63
+ },
64
+ workflow: {
65
+ steps: [],
66
+ templates: [
67
+ {
68
+ name: "new-component",
69
+ description: "新建 Tailwind 组件:语义结构 → 样式 → 响应式 → 暗色模式",
70
+ version: "1.0.0",
71
+ steps: [
72
+ { id: "design-structure", description: "设计组件语义结构(HTML + ARIA)", type: "llm", timeout: 10000 },
73
+ { id: "apply-base-styles", description: "应用基础样式(spacing、typography、colors 从 theme)", type: "llm", depends: ["design-structure"], timeout: 15000 },
74
+ { id: "add-responsive", description: "添加响应式前缀(sm/md/lg/xl/2xl)", type: "llm", depends: ["apply-base-styles"], timeout: 10000 },
75
+ { id: "add-dark-mode", description: "添加 dark: 前缀暗色模式样式", type: "llm", depends: ["apply-base-styles"], timeout: 10000 },
76
+ { id: "add-interactive", description: "添加交互状态(hover/focus/active/disabled)", type: "llm", depends: ["apply-base-styles"], timeout: 10000 },
77
+ { id: "review-classes", description: "审查 class 列表(有无自定义 CSS 可替换为 utility)", type: "simple", depends: ["add-responsive", "add-dark-mode", "add-interactive"], timeout: 10000 },
78
+ { id: "check-purge-safelist", description: "确认动态 class 在 safelist 中", type: "simple", depends: ["review-classes"], timeout: 5000 },
79
+ ],
80
+ triggers: [{ type: "cli", command: "new:component" }, { type: "mcp", tool: "new_component" }],
81
+ },
82
+ {
83
+ name: "utility-audit",
84
+ description: "Utility 审查:清除自定义 CSS → 统一为 Tailwind utility",
85
+ version: "1.0.0",
86
+ steps: [
87
+ { id: "scan-custom-css", description: "扫描项目中的自定义 CSS 和 @apply 指令", type: "simple", timeout: 10000 },
88
+ { id: "match-utility", description: "匹配每个自定义样式到对应的 Tailwind utility", type: "llm", depends: ["scan-custom-css"], timeout: 15000 },
89
+ { id: "detect-deprecated", description: "检测已弃用的 Tailwind class(如 flex-shrink-0 → shrink-0)", type: "simple", depends: ["scan-custom-css"], timeout: 10000 },
90
+ { id: "check-arbitrary-values", description: "审查任意值 [300px] 是否应提取为 theme", type: "simple", depends: ["scan-custom-css"], timeout: 10000 },
91
+ { id: "replace-custom", description: "用 Tailwind utility 替换自定义 CSS", type: "llm", depends: ["match-utility"], timeout: 20000 },
92
+ { id: "build-verify", description: "构建验证(确认 PurgeCSS 正确生成)", type: "simple", depends: ["replace-custom"], timeout: 15000 },
93
+ ],
94
+ triggers: [{ type: "cli", command: "audit:utility" }],
95
+ },
96
+ {
97
+ name: "theme-migrate",
98
+ description: "主题迁移:分析现有设计 → 提取 Design Token → 生成配置",
99
+ version: "1.0.0",
100
+ steps: [
101
+ { id: "extract-tokens", description: "从现有代码/设计稿提取颜色、间距、字体", type: "simple", timeout: 10000 },
102
+ { id: "categorize-tokens", description: "分类 Design Token(color/size/typography/shadow)", type: "llm", depends: ["extract-tokens"], timeout: 10000 },
103
+ { id: "generate-config", description: "生成 tailwind.config.ts 配置", type: "llm", depends: ["categorize-tokens"], timeout: 10000 },
104
+ { id: "replace-hardcoded", description: "替换代码中的硬编码颜色/尺寸为 Tailwind class", type: "llm", depends: ["generate-config"], timeout: 20000 },
105
+ { id: "visual-regression", description: "视觉回归测试确认外观一致", type: "simple", depends: ["replace-hardcoded"], timeout: 30000 },
106
+ ],
107
+ triggers: [{ type: "cli", command: "migrate:theme" }],
108
+ },
109
+ ],
110
+ },
111
+ prompt: {
112
+ system: "你是一个 Tailwind CSS 专家。使用 utility-first 方法构建界面。遇到问题先查 Tailwind 官方文档。",
113
+ rules: [
114
+ "优先使用 Tailwind utility classes,避免自定义 CSS",
115
+ "使用 Tailwind 响应式断点(sm/md/lg/xl/2xl)",
116
+ "颜色和间距从 theme 配置中引用",
117
+ "复杂样式使用 @apply 抽取",
118
+ "使用 class 策略实现暗色模式",
119
+ "避免内联 style 和自定义 CSS",
120
+ "不确定 class 名称时先查 Tailwind 官方文档",
121
+ ],
122
+ },
123
+ tools: [],
124
+ };
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,8CAA8C;QAC3D,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,CAAC;KACrE;IAED,SAAS,EAAE;QACT,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;oBACJ,8BAA8B;oBAC9B,4CAA4C;oBAC5C,iDAAiD;iBAClD;gBACD,UAAU,EAAE,UAAU;gBACtB,OAAO,EAAE,OAAO;aACjB;SACF;KACF;IAED,MAAM,EAAE;QACN,OAAO,EAAE;YACP,KAAK,EAAE,CAAC,gBAAgB,EAAE,SAAS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EAAE,qBAAqB,EAAE,IAAI,EAAE,QAAiB,EAAE,OAAO,EAAE,KAAK,EAAE;oBACrG,EAAE,EAAE,EAAE,mBAAmB,EAAE,WAAW,EAAE,+CAA+C,EAAE,IAAI,EAAE,KAAc,EAAE,OAAO,EAAE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;oBAC5J,EAAE,EAAE,EAAE,iBAAiB,EAAE,WAAW,EAAE,0BAA0B,EAAE,IAAI,EAAE,KAAc,EAAE,OAAO,EAAE,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;oBACxI,EAAE,EAAE,EAAE,mBAAmB,EAAE,WAAW,EAAE,gCAAgC,EAAE,IAAI,EAAE,KAAc,EAAE,OAAO,EAAE,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;oBAC9I,EAAE,EAAE,EAAE,mBAAmB,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,QAAiB,EAAE,OAAO,EAAE,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;iBAClI;gBACD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAc,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;aAC/D;SACF;KACF;IAED,MAAM,EAAE;QACN,MAAM,EAAE,oEAAoE;QAC5E,KAAK,EAAE;YACL,yCAAyC;YACzC,oCAAoC;YACpC,oBAAoB;YACpB,kBAAkB;YAClB,mBAAmB;YACnB,qBAAqB;YACrB,+BAA+B;SAChC;KACF;IAED,KAAK,EAAE,EAAE;CACV,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@devflow-tools/plugin-tailwind",
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
+ }