@bovinphang/frontend-craft 2.6.0 → 2.7.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.
Files changed (110) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +38 -1
  4. package/CHANGELOG.zh-CN.md +37 -1
  5. package/README.md +10 -6
  6. package/README.openclaw.md +3 -1
  7. package/README.openclaw.zh-CN.md +3 -1
  8. package/README.zh-CN.md +10 -6
  9. package/agents/fec-typescript-reviewer.md +1 -1
  10. package/docs/example-prompts.md +81 -69
  11. package/docs/ja-JP/README.md +56 -52
  12. package/docs/ko-KR/README.md +45 -41
  13. package/docs/project-structure.md +8 -4
  14. package/docs/superpowers/plans/2026-05-29-fec-debug.md +491 -0
  15. package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +340 -0
  16. package/docs/zh-CN/example-prompts.md +81 -69
  17. package/docs/zh-CN/project-structure.md +8 -4
  18. package/docs/zh-TW/README.md +33 -29
  19. package/openclaw.plugin.json +1 -1
  20. package/package.json +3 -3
  21. package/skills/eval_queries.json +154 -56
  22. package/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  23. package/skills/fec-code-review/SKILL.md +1 -1
  24. package/skills/fec-drawio-studio/SKILL.md +69 -0
  25. package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  26. package/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  27. package/skills/fec-drawio-studio/data/shape-index.json.gz +0 -0
  28. package/skills/fec-drawio-studio/references/data-residency.md +27 -0
  29. package/skills/fec-drawio-studio/references/diagram-patterns.md +41 -0
  30. package/skills/fec-drawio-studio/references/layout-and-export.md +57 -0
  31. package/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  32. package/skills/fec-drawio-studio/references/xml-and-mermaid.md +54 -0
  33. package/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  34. package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +143 -0
  35. package/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  36. package/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  37. package/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  38. package/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  39. package/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  40. package/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  41. package/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  42. package/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  43. package/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  44. package/skills/fec-drawio-studio/scripts/shape-query.mjs +81 -0
  45. package/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  46. package/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  47. package/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  48. package/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  49. package/skills/fec-drawio-studio/styles/schema.json +112 -0
  50. package/skills/fec-e2e-testing/SKILL.md +3 -1
  51. package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  52. package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  53. package/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  54. package/skills/fec-image-generation/SKILL.md +56 -0
  55. package/skills/fec-image-generation/references/artifact-routing.md +80 -0
  56. package/skills/fec-image-generation/references/diagram-workflows.md +43 -0
  57. package/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
  58. package/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
  59. package/skills/fec-implement-from-design/SKILL.md +7 -0
  60. package/skills/fec-legacy-to-modern-migration/SKILL.md +24 -168
  61. package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  62. package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  63. package/skills/fec-motion-interaction/SKILL.md +7 -0
  64. package/skills/fec-nextjs-project-standard/SKILL.md +7 -1
  65. package/skills/fec-performance-optimization/SKILL.md +5 -1
  66. package/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  67. package/skills/fec-performance-optimization/references/report-template.md +6 -0
  68. package/skills/fec-react-project-standard/SKILL.md +11 -3
  69. package/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  70. package/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  71. package/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  72. package/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  73. package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +11 -0
  74. package/skills/fec-source-driven-development/SKILL.md +26 -0
  75. package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +5 -1
  76. package/skills/fec-typescript-project-standard/SKILL.md +54 -0
  77. package/skills/{fec-typescript-type-safety → fec-typescript-project-standard}/references/type-safety-patterns.md +1 -1
  78. package/skills/{fec-typescript-type-safety/SKILL.md → fec-typescript-project-standard/references/type-safety.md} +1 -10
  79. package/skills/fec-ui-design/SKILL.md +26 -8
  80. package/skills/fec-ui-design/data/style-archetypes.json +40 -0
  81. package/skills/fec-ui-design/data/ux-quality-rules.json +35 -0
  82. package/skills/fec-ui-design/references/design-intelligence.md +66 -6
  83. package/skills/fec-ui-design/references/pre-delivery-checklist.md +6 -0
  84. package/skills/fec-ui-design/scripts/design-system.mjs +119 -1
  85. package/skills/fec-vue3-project-standard/SKILL.md +11 -2
  86. package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +163 -0
  87. package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  88. package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +177 -0
  89. package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  90. package/skills/fec-web-video-presentation/SKILL.md +61 -0
  91. package/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  92. package/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  93. package/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  94. package/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  95. package/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  96. package/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  97. package/skills/metadata.json +340 -164
  98. package/skills/relations.json +116 -25
  99. package/templates/shared/rules/fec-ci-cd.md +20 -108
  100. package/templates/shared/rules/fec-design-system.md +47 -223
  101. package/templates/shared/rules/fec-error-handling.md +35 -179
  102. package/templates/shared/rules/fec-i18n.md +43 -91
  103. package/templates/shared/rules/fec-refactoring.md +4 -0
  104. package/templates/shared/rules/fec-rendering-patterns.md +28 -171
  105. package/templates/shared/rules/fec-responsive-design.md +34 -211
  106. package/templates/shared/rules/fec-state-management.md +41 -144
  107. package/templates/shared/rules/fec-typescript.md +47 -290
  108. package/skills/fec-e2e-testing/references/e2e-advanced.md +0 -176
  109. package/skills/fec-react-project-standard/references/react-project-details.md +0 -642
  110. package/skills/fec-vue3-project-standard/references/vue3-project-details.md +0 -547
@@ -0,0 +1,112 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/Agents365-ai/drawio-skill/styles/schema.json",
4
+ "title": "drawio-skill preset",
5
+ "type": "object",
6
+ "required": ["name", "version", "palette", "roles", "shapes", "font", "edges"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "$schema": { "type": "string" },
10
+ "name": { "type": "string", "pattern": "^[a-z0-9][a-z0-9_-]*$" },
11
+ "version": { "type": "integer", "const": 1 },
12
+ "default": { "type": "boolean" },
13
+ "confidence": { "type": "string", "enum": ["low", "medium", "high"] },
14
+ "source": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "properties": {
18
+ "type": { "type": "string", "enum": ["xml", "image", "built-in", "hand-authored"] },
19
+ "path": { "type": "string" },
20
+ "extracted_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" }
21
+ }
22
+ },
23
+ "palette": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["primary", "success", "warning", "accent", "danger", "neutral", "secondary"],
27
+ "properties": {
28
+ "primary": { "$ref": "#/$defs/colorPair" },
29
+ "success": { "$ref": "#/$defs/colorPair" },
30
+ "warning": { "$ref": "#/$defs/colorPair" },
31
+ "accent": { "$ref": "#/$defs/colorPair" },
32
+ "danger": { "$ref": "#/$defs/colorPair" },
33
+ "neutral": { "$ref": "#/$defs/colorPair" },
34
+ "secondary": { "$ref": "#/$defs/colorPair" }
35
+ }
36
+ },
37
+ "roles": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "service": { "$ref": "#/$defs/slotName" },
42
+ "database": { "$ref": "#/$defs/slotName" },
43
+ "queue": { "$ref": "#/$defs/slotName" },
44
+ "gateway": { "$ref": "#/$defs/slotName" },
45
+ "error": { "$ref": "#/$defs/slotName" },
46
+ "external": { "$ref": "#/$defs/slotName" },
47
+ "security": { "$ref": "#/$defs/slotName" }
48
+ }
49
+ },
50
+ "shapes": {
51
+ "type": "object",
52
+ "additionalProperties": { "type": "string" },
53
+ "properties": {
54
+ "service": { "type": "string" },
55
+ "database": { "type": "string" },
56
+ "queue": { "type": "string" },
57
+ "decision": { "type": "string" },
58
+ "external": { "type": "string" },
59
+ "container": { "type": "string" }
60
+ }
61
+ },
62
+ "font": {
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "required": ["fontFamily", "fontSize"],
66
+ "properties": {
67
+ "fontFamily": { "type": "string" },
68
+ "fontSize": { "type": "integer", "minimum": 8, "maximum": 36 },
69
+ "titleFontSize": { "type": "integer", "minimum": 8, "maximum": 48 },
70
+ "titleBold": { "type": "boolean" }
71
+ }
72
+ },
73
+ "edges": {
74
+ "type": "object",
75
+ "additionalProperties": false,
76
+ "required": ["style", "arrow"],
77
+ "properties": {
78
+ "style": { "type": "string" },
79
+ "arrow": { "type": "string" },
80
+ "dashedFor": { "type": "array", "items": { "type": "string" } }
81
+ }
82
+ },
83
+ "extras": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "properties": {
87
+ "sketch": { "type": "boolean" },
88
+ "globalStrokeWidth": { "type": "number", "minimum": 0.5, "maximum": 6 }
89
+ }
90
+ }
91
+ },
92
+ "$defs": {
93
+ "colorPair": {
94
+ "oneOf": [
95
+ { "type": "null" },
96
+ {
97
+ "type": "object",
98
+ "additionalProperties": false,
99
+ "required": ["fillColor", "strokeColor"],
100
+ "properties": {
101
+ "fillColor": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
102
+ "strokeColor": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" }
103
+ }
104
+ }
105
+ ]
106
+ },
107
+ "slotName": {
108
+ "type": "string",
109
+ "enum": ["primary", "success", "warning", "accent", "danger", "neutral", "secondary"]
110
+ }
111
+ }
112
+ }
@@ -23,7 +23,9 @@ description: Use when creating, maintaining, debugging, or reviewing real-browse
23
23
  ## 详细参考
24
24
 
25
25
  - 需要目录结构、Page Object、spec 组织、配置、flaky 调试和产物示例时,加载 [references/playwright-patterns.md](references/playwright-patterns.md)。
26
- - 需要 CI 示例、Markdown 报告模板、Web3/钱包流程、高风险金融流程或视觉回归配置时,加载 [references/e2e-advanced.md](references/e2e-advanced.md)。
26
+ - 需要 CI 示例和 Markdown 报告模板时,加载 [references/e2e-ci-reporting.md](references/e2e-ci-reporting.md)。
27
+ - 需要 Web3/钱包流程或高风险金融流程时,加载 [references/e2e-special-scenarios.md](references/e2e-special-scenarios.md)。
28
+ - 需要跨页面截图或视觉回归配置时,加载 [references/e2e-visual-regression.md](references/e2e-visual-regression.md)。
27
29
 
28
30
  ## Constraints
29
31
 
@@ -0,0 +1,62 @@
1
+ # E2E CI 与报告
2
+
3
+ ## CI 集成(示例)
4
+
5
+ ```yaml
6
+ # .github/workflows/e2e.yml
7
+ name: E2E Tests
8
+ on: [push, pull_request]
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ - run: npm ci
19
+ - run: npx playwright install --with-deps
20
+ - run: npx playwright test
21
+ env:
22
+ CI: true
23
+ BASE_URL: ${{ vars.STAGING_URL }}
24
+ - uses: actions/upload-artifact@v4
25
+ if: always()
26
+ with:
27
+ name: playwright-report
28
+ path: playwright-report/
29
+ retention-days: 30
30
+ ```
31
+
32
+ Cypress:固定 `CYPRESS_baseUrl` 或配置文件中的 `baseUrl`,失败截图/视频同样建议上传 artifact。
33
+
34
+ ## E2E 报告模板(Markdown)
35
+
36
+ 输出或归档测试报告时可采用下列结构,便于复盘:
37
+
38
+ ```markdown
39
+ # E2E 测试报告
40
+
41
+ **日期:** YYYY-MM-DD HH:mm
42
+ **耗时:** X 分 Y 秒
43
+ **结果:** 通过 / 失败
44
+
45
+ ## 摘要
46
+
47
+ - 总计 X | 通过 Y | 失败 Z | 不稳定/跳过 说明
48
+
49
+ ## 失败用例
50
+
51
+ ### 用例名
52
+
53
+ - **文件:** `tests/e2e/xxx.spec.ts:行号`
54
+ - **错误:** 简述断言或超时信息
55
+ - **截图/Trace:** 路径或 artifact 名称
56
+ - **建议修复:** 可执行结论
57
+
58
+ ## 产物
59
+
60
+ - HTML 报告:`playwright-report/index.html`
61
+ - Trace / 视频 / 截图:CI artifact 或本地 `test-results/`
62
+ ```
@@ -0,0 +1,52 @@
1
+ # E2E 特殊场景
2
+
3
+ ## Web3 / 钱包注入(Playwright)
4
+
5
+ 在 **`page.goto` 之前**通过 `context.addInitScript` 注入 mock,避免依赖真实插件:
6
+
7
+ ```typescript
8
+ test("连接钱包", async ({ page, context }) => {
9
+ await context.addInitScript(() => {
10
+ (window as unknown as { ethereum?: unknown }).ethereum = {
11
+ isMetaMask: true,
12
+ request: async ({ method }: { method: string }) => {
13
+ if (method === "eth_requestAccounts")
14
+ return ["0x1234567890123456789012345678901234567890"];
15
+ if (method === "eth_chainId") return "0x1";
16
+ return null;
17
+ },
18
+ };
19
+ });
20
+
21
+ await page.goto("/");
22
+ await page.getByTestId("connect-wallet").click();
23
+ await expect(page.getByTestId("wallet-address")).toContainText("0x1234");
24
+ });
25
+ ```
26
+
27
+ 链 ID、账户列表与业务契约保持一致即可。
28
+
29
+ ## 金融或高风险操作
30
+
31
+ - **禁止**在真实生产环境执行真实资金操作;使用 **staging、mock 或 `test.skip`**。
32
+ - 断言**预览金额、成功态**与**关键接口 200** 后再结束用例,超时给足(如链上确认场景)。
33
+
34
+ ```typescript
35
+ test("下单预览与成功态", async ({ page }) => {
36
+ test.skip(process.env.NODE_ENV === "production", "生产环境跳过真实交易");
37
+
38
+ await page.goto("/markets/demo");
39
+ await page.getByTestId("position-yes").click();
40
+ await page.getByTestId("trade-amount").fill("1.0");
41
+
42
+ const preview = page.getByTestId("trade-preview");
43
+ await expect(preview).toContainText("1.0");
44
+
45
+ await page.getByTestId("confirm-trade").click();
46
+ await page.waitForResponse(
47
+ (resp) => resp.url().includes("/api/trade") && resp.status() === 200,
48
+ { timeout: 30_000 },
49
+ );
50
+ await expect(page.getByTestId("trade-success")).toBeVisible();
51
+ });
52
+ ```
@@ -0,0 +1,60 @@
1
+ # E2E 视觉回归测试
2
+
3
+ 通过截图快照对比检测非预期的 UI 变化。适用于 CSS 重构、设计 Token 更新、组件改版等场景。
4
+
5
+ ## 基础用法
6
+
7
+ ```typescript
8
+ import { test, expect } from "@playwright/test";
9
+
10
+ test("首页布局与基线一致", async ({ page }) => {
11
+ await page.goto("/");
12
+ await page.waitForLoadState("networkidle");
13
+
14
+ // 全页截图对比 - 首次运行自动生成基线
15
+ await expect(page).toHaveScreenshot("homepage-full.png", {
16
+ fullPage: true,
17
+ maxDiffPixels: 100, // 允许的轻微像素差异(抗锯齿等)
18
+ });
19
+ });
20
+
21
+ test("按钮组件视觉一致", async ({ page }) => {
22
+ await page.goto("/components/buttons");
23
+ const submitButton = page.getByTestId("submit-button");
24
+ await expect(submitButton).toHaveScreenshot("submit-button.png");
25
+ });
26
+ ```
27
+
28
+ ## 屏蔽动态内容
29
+
30
+ 时间、随机 ID、第三方广告等动态元素会导致误报,使用 `mask` 屏蔽:
31
+
32
+ ```typescript
33
+ await expect(page).toHaveScreenshot("dashboard.png", {
34
+ mask: [
35
+ page.locator(".live-clock"),
36
+ page.locator(".random-id"),
37
+ page.locator(".ad-banner"),
38
+ ],
39
+ });
40
+ ```
41
+
42
+ ## 禁用动画
43
+
44
+ CSS 动画会导致截图不一致,注入样式禁用动画后再截图:
45
+
46
+ ```typescript
47
+ await page.addStyleTag({
48
+ content:
49
+ "*, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }",
50
+ });
51
+ await expect(page).toHaveScreenshot("animated-page.png");
52
+ ```
53
+
54
+ ## 基线管理
55
+
56
+ - **首次运行**: `npx playwright test` 失败但自动生成基线到 `tests/` 目录
57
+ - **更新基线**: UI 有意变更时 `npx playwright test --update-snapshots`
58
+ - **CI 一致性**: 基线必须在与 CI 相同的 OS(Linux/Ubuntu)上生成,字体渲染在 macOS 与 Linux 间存在差异
59
+ - **多浏览器**: 每个 project 独立生成基线(Chromium/Firefox/WebKit 渲染结果不同)
60
+ - **基线文件**: 纳入 `.gitignore` 或 Git LFS 管理,避免仓库膨胀
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: fec-image-generation
3
+ description: Use when generating or editing diagrams, charts, visual assets, posters, UI mockups, product images, infographics, academic figures, comics, avatars, storyboards, brand boards, or image-edit workflows, especially when exported PNGs need visual QA and bounded self-repair. Prefer deterministic Mermaid/SVG/HTML/canvas sources for text-heavy diagrams; do not use for ordinary UI polish without generated imagery. Chinese triggers include 图片生成, 图像编辑, 图表生成, 架构图, ER 图, UML, 序列图, 海报, UI 样机, 产品图, 信息图, 学术图, 漫画, 头像, 分镜, 品牌板, PNG 自检, 自动修复.
4
+ ---
5
+
6
+ # 图片生成与图表工作流
7
+
8
+ ## Purpose
9
+
10
+ 生成或编辑图表、视觉资产和图片工作流,并对导出的 PNG 做可复查的自检与修复迭代。
11
+
12
+ ## Procedure
13
+
14
+ 1. 判断产物类型
15
+ - 文本、结构和连线准确性优先时,用 Mermaid、SVG、HTML/CSS、canvas 或图表库生成可编辑源,再导出 PNG。
16
+ - 审美、质感、照片、插画、漫画、产品图或品牌氛围优先时,用图片生成或编辑工具,再把最终资产保存到项目或报告目录。
17
+
18
+ 2. 明确输入与约束
19
+ - 收集受众、用途、尺寸、语言、必须出现的文本、品牌限制、可编辑源格式、导出格式和禁用元素。
20
+ - 对海报、UI 样机、品牌板和产品图,先写出一行视觉读取:目标用户、场景、可信感来源、主视觉锚点。
21
+
22
+ 3. 选择生成路线
23
+ - ER 图、UML 类图、序列图、技术架构图、ML/深度学习、流程图等,优先按 [diagram-workflows.md](references/diagram-workflows.md) 建立结构化源。
24
+ - 海报、UI 样机、产品图、信息图、学术图、漫画、头像、分镜、品牌板和图像编辑,按 [artifact-routing.md](references/artifact-routing.md) 选择生成、编辑或混合路线。
25
+
26
+ 4. 导出并自检 PNG
27
+ - 每次交付前都读取导出的 PNG,检查主体是否真实渲染、文字是否截断、连线是否堆叠、节点是否重叠。
28
+ - 有布局 manifest 时运行:
29
+ ```bash
30
+ node skills/fec-image-generation/scripts/png-qa.mjs --png output.png --manifest layout.json --format markdown
31
+ ```
32
+ - 没有 manifest 时仍运行 PNG 基础检查:
33
+ ```bash
34
+ node skills/fec-image-generation/scripts/png-qa.mjs --png output.png --format json
35
+ ```
36
+
37
+ 5. 自动修复循环
38
+ - 默认最多 2 轮;用户明确要求时可提高到 5 轮软上限。
39
+ - 修复对象是源文件、prompt、布局参数或导出尺寸,不直接破坏性修改 PNG 像素。
40
+ - 按 [png-qa-autofix.md](references/png-qa-autofix.md) 把问题转成具体修复:增大画布、换行、移动节点、分层连线、调整 padding 或重导出。
41
+
42
+ 6. 交付记录
43
+ - 说明最终源文件、PNG 路径、生成路线、QA 轮次、发现并修复的问题、仍需人工确认的文字或品牌风险。
44
+
45
+ ## Constraints
46
+
47
+ - 文本密集图不要只靠位图模型生成;必须保留可编辑结构化源。
48
+ - 不把截图、假数据或占位图当成最终产品图,除非用户明确要求概念稿。
49
+ - 不直接覆盖原图;编辑工作流默认输出新文件。
50
+ - 不为追求美观牺牲可读标签、连线归属、图例、坐标轴和可访问替代说明。
51
+ - PNG helper 只做检测和建议;修复必须回到源、prompt 或布局参数。
52
+ - 自检结果不能替代人工确认专有名词、公式、论文图注、品牌规范和合规信息。
53
+
54
+ ## Expected Output
55
+
56
+ 产出可编辑源、最终 PNG 或编辑后图片,并附带生成路线与 QA 结果。图表应结构清晰、标签不截断、连线不混乱;视觉资产应匹配用途、尺寸、品牌语气和交付路径。
@@ -0,0 +1,80 @@
1
+ # Artifact Routing
2
+
3
+ ## Mode selection
4
+
5
+ Choose the execution mode before writing a prompt:
6
+
7
+ | Mode | Use when | Behavior |
8
+ | ---- | -------- | -------- |
9
+ | Deterministic source | Text, labels, charts, connectors, or exact geometry must be correct | Build Mermaid, SVG, HTML/CSS, canvas, plotting, or design-tool source first, then export PNG. |
10
+ | Host-native image tool | The task needs raster aesthetics, illustration, product mood, photo-like output, or image editing and the current environment has an image tool | Write a structured prompt and call the host image tool. Save or report the prompt when future edits are likely. |
11
+ | Prompt-only advisor | No image tool is available or the user only wants a prompt | Produce the final prompt, usage notes, and verification checklist. Do not imply an image was generated. |
12
+ | Hybrid | Exact text or UI structure plus generated imagery are both needed | Generate supporting imagery, then compose final text/layout in SVG, HTML, canvas, or a design tool. |
13
+
14
+ Do not introduce local image API scripts, provider-specific environment variables, or OpenAI-compatible gateway assumptions as part of this workflow. If a project already owns such a pipeline, treat it as a host tool and keep prompts provider-neutral.
15
+
16
+ ## Route by output
17
+
18
+ | Output | Preferred route | Notes |
19
+ | ------ | --------------- | ----- |
20
+ | Poster / ad creative | Image generation, then optional layout polish in HTML/SVG or design tool | Lock exact copy before generation; recompose text outside the bitmap when accuracy matters. |
21
+ | UI mockup | HTML/CSS or design-tool mockup first; raster generation only for mood or hero references | Keep controls readable and avoid fake product states in final handoff. |
22
+ | Product image | Image generation or edit with reference constraints | Preserve brand, perspective, material, and lighting; do not overwrite original assets. |
23
+ | Infographic | Structured SVG/HTML/canvas for text and charts; generated illustrations only as supporting media | Export PNG after layout QA. |
24
+ | Academic figure | Deterministic plotting, SVG, Mermaid, LaTeX, or canvas | Accuracy beats style; keep source reproducible. |
25
+ | Comic / storyboard | Image generation with panel manifest | Track panel count, exact captions, characters, scene continuity, and reading order. |
26
+ | Avatar | Image generation or edit | Ask only when identity, style, or usage rights are ambiguous. |
27
+ | Brand board | Mixed route: generated imagery, palette/type/layout board in HTML/SVG | Record palette roles, typography mood, imagery rules, and avoid-list. |
28
+ | Image edit | Edit target plus explicit invariants | Preserve requested identity, composition, text, object, lighting, or background constraints. |
29
+
30
+ ## Visual asset categories
31
+
32
+ Use these categories to pick prompt detail and verification focus:
33
+
34
+ - Product and commerce: product image, packaging, lifestyle scene, marketplace board.
35
+ - UI and interface: app mockup, chat scene, dashboard view, landing hero, social post.
36
+ - Technical and academic: architecture, sequence, state, ER, method figure, graphical abstract.
37
+ - Narrative and brand: poster, campaign key visual, storyboard, comic, avatar, mascot, brand board.
38
+ - Information design: infographic, map, comparison, step-by-step guide, KPI board.
39
+ - Editing: background replacement, object removal, local replacement, retouching, portrait edit.
40
+
41
+ If the category is text-heavy or diagram-heavy, prefer a deterministic source or hybrid route.
42
+
43
+ ## Prompt contract
44
+
45
+ Use this compact structure when calling an image tool:
46
+
47
+ ```text
48
+ Asset type:
49
+ Use:
50
+ Canvas / aspect ratio:
51
+ Audience:
52
+ Required text:
53
+ Subject:
54
+ Composition:
55
+ Style / brand tone:
56
+ Reference assets:
57
+ Must preserve:
58
+ Avoid:
59
+ Output:
60
+ ```
61
+
62
+ For exact text, prefer adding text in SVG/HTML/design source after image generation. If text must be inside generated imagery, keep it short and verify manually.
63
+
64
+ For image edits, add:
65
+
66
+ ```text
67
+ Source image:
68
+ Edit region:
69
+ Invariants:
70
+ Replacement:
71
+ Lighting / perspective:
72
+ ```
73
+
74
+ ## Handoff checklist
75
+
76
+ - Final image path is inside the workspace when the asset is project-bound.
77
+ - Source or prompt is saved when future edits are likely.
78
+ - Exact text, diagram labels, chart values, citations, and brand marks are manually checked.
79
+ - Generated variants that were rejected are not referenced by code or docs.
80
+ - If no image was generated, the final answer clearly states prompt-only mode.
@@ -0,0 +1,43 @@
1
+ # Diagram Workflows
2
+
3
+ ## Source selection
4
+
5
+ | Diagram type | Preferred source | QA focus |
6
+ | ------------ | ---------------- | -------- |
7
+ | ER diagram | Mermaid ER, DBML, Graphviz, SVG | Cardinality labels, table names, key fields, crossing relations. |
8
+ | UML class | Mermaid class, PlantUML, Graphviz | Inheritance direction, method/property wrapping, package grouping. |
9
+ | Sequence | Mermaid sequence, PlantUML | Lifeline order, activation spans, async/return arrows, message text. |
10
+ | Technical architecture | Mermaid flowchart, C4/Structurizr, SVG/HTML | Layer grouping, trust boundaries, data flow direction, legends. |
11
+ | ML / deep learning | SVG/HTML/canvas | Tensor shapes, layer order, branch joins, repeated blocks, annotations. |
12
+ | Flowchart | Mermaid flowchart, SVG | Decision labels, terminal states, loop-back readability, connector spacing. |
13
+
14
+ ## Minimum source manifest
15
+
16
+ When the rendering path allows it, save a layout manifest next to the PNG:
17
+
18
+ ```json
19
+ {
20
+ "canvas": { "width": 1280, "height": 720 },
21
+ "boxes": [
22
+ { "id": "api", "x": 80, "y": 120, "width": 220, "height": 96, "label": "API Gateway" }
23
+ ],
24
+ "connectors": [
25
+ { "id": "api-db", "from": "api", "to": "db", "points": [[300, 168], [560, 168]] }
26
+ ]
27
+ }
28
+ ```
29
+
30
+ Coordinates are PNG pixel coordinates after export. Boxes should cover visible label/node bounds, not just the center point.
31
+
32
+ ## Diagram repair playbook
33
+
34
+ - **Overlapping nodes:** increase rank/column spacing, split clusters, or move low-priority annotations into a legend.
35
+ - **Truncated labels:** widen the node, add manual line breaks, reduce label length, or increase export scale.
36
+ - **Connector through labels:** add waypoints, route orthogonally around boxes, or move labels above the segment.
37
+ - **Connector stacking:** separate parallel edges with different waypoints or bundle them with a shared labeled bus.
38
+ - **Edge clipping:** increase outer padding or export viewBox/canvas size.
39
+ - **Unreadable dense graph:** split into overview plus detail diagrams instead of shrinking everything.
40
+
41
+ ## Export guidance
42
+
43
+ Prefer exporting at 2x scale for raster PNGs, then downsample only if text remains crisp. Keep the editable source committed or attached wherever future diagram changes are expected.
@@ -0,0 +1,30 @@
1
+ # PNG QA And Autofix
2
+
3
+ ## Loop
4
+
5
+ 1. Export PNG from the editable source or image workflow.
6
+ 2. Inspect the PNG visually.
7
+ 3. Run `png-qa.mjs` with a manifest when available.
8
+ 4. Convert each issue into source, prompt, or layout changes.
9
+ 5. Repeat for 2 rounds by default, up to 5 when the user asks for more repair attempts.
10
+
11
+ ## Issue mapping
12
+
13
+ | Issue | Repair |
14
+ | ----- | ------ |
15
+ | `blank-image` | Check export target, renderer errors, hidden layers, transparent fill, or failed image generation. |
16
+ | `edge-clipping` | Add canvas padding, expand SVG viewBox, reduce subject scale, or export a larger frame. |
17
+ | `box-overlap` | Increase spacing, reflow to grid/layers, split clusters, or shorten labels. |
18
+ | `box-out-of-bounds` | Move the node inside canvas or increase canvas dimensions. |
19
+ | `label-overflow` | Wrap text, widen the box, reduce copy, or increase font/container size together. |
20
+ | `connector-through-label` | Add waypoints around boxes, move labels, or use orthogonal routing. |
21
+ | `connector-stacking` | Offset parallel connectors or replace repeated lines with a labeled grouped path. |
22
+ | `manifest-canvas-mismatch` | Regenerate the manifest from final export dimensions. |
23
+
24
+ ## Manifest quality
25
+
26
+ The helper can only reason about overlaps and connectors when the manifest coordinates match the exported PNG. If the manifest is stale, repair the manifest first, then rerun QA.
27
+
28
+ ## Reporting
29
+
30
+ Report the number of QA rounds and the final issue list. If issues remain because the source renderer cannot expose layout coordinates, say which checks were image-only and which require manual visual review.