foliko 1.0.87 → 1.1.1

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 (259) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +325 -21
  39. package/.agent/data/plugins-state.json +194 -162
  40. package/.agent/data/puppeteer-sessions/undefined.json +6 -0
  41. package/.agent/mcp_config.json +0 -1
  42. package/.agent/mcp_config_updated.json +12 -0
  43. package/.agent/plugins/poster-plugin/README.md +304 -0
  44. package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
  45. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  46. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  47. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
  48. package/.agent/plugins/poster-plugin/index.js +13 -0
  49. package/.agent/plugins/poster-plugin/package.json +28 -0
  50. package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
  51. package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
  52. package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
  53. package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
  54. package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
  55. package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
  56. package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
  57. package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
  58. package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
  59. package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
  60. package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
  61. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
  62. package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
  63. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
  64. package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
  65. package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
  66. package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
  67. package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
  68. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
  69. package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
  70. package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
  71. package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
  72. package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
  73. package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
  74. package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
  75. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
  76. package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
  77. package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
  78. package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
  79. package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
  80. package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
  81. package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
  82. package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
  83. package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
  84. package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
  85. package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
  86. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
  87. package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
  88. package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
  89. package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
  90. package/.agent/plugins/poster-plugin/src/index.js +1658 -0
  91. package/.agent/plugins/poster-plugin/src/presets.js +36 -0
  92. package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
  93. package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
  94. package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
  95. package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
  96. package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
  97. package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
  98. package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
  99. package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
  100. package/.agent/plugins.json +5 -11
  101. package/.agent/rules/GEMINI.md +273 -0
  102. package/.agent/rules/allow-rule.md +77 -0
  103. package/.agent/rules/log-rule.md +83 -0
  104. package/.agent/rules/security-rule.md +93 -0
  105. package/.agent/scripts/auto_preview.py +148 -0
  106. package/.agent/scripts/checklist.py +217 -0
  107. package/.agent/scripts/session_manager.py +120 -0
  108. package/.agent/scripts/verify_all.py +327 -0
  109. package/.agent/sessions/cli_default.json +419 -0
  110. package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
  111. package/.agent/skills/api-patterns/SKILL.md +81 -0
  112. package/.agent/skills/api-patterns/api-style.md +42 -0
  113. package/.agent/skills/api-patterns/auth.md +24 -0
  114. package/.agent/skills/api-patterns/documentation.md +26 -0
  115. package/.agent/skills/api-patterns/graphql.md +41 -0
  116. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  117. package/.agent/skills/api-patterns/response.md +37 -0
  118. package/.agent/skills/api-patterns/rest.md +40 -0
  119. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  120. package/.agent/skills/api-patterns/security-testing.md +122 -0
  121. package/.agent/skills/api-patterns/trpc.md +41 -0
  122. package/.agent/skills/api-patterns/versioning.md +22 -0
  123. package/.agent/skills/app-builder/SKILL.md +75 -0
  124. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  125. package/.agent/skills/app-builder/feature-building.md +53 -0
  126. package/.agent/skills/app-builder/project-detection.md +34 -0
  127. package/.agent/skills/app-builder/scaffolding.md +118 -0
  128. package/.agent/skills/app-builder/tech-stack.md +40 -0
  129. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  130. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  131. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  132. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  133. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  134. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  135. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  136. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  137. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  138. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  139. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  140. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  141. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  142. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  143. package/.agent/skills/architecture/SKILL.md +55 -0
  144. package/.agent/skills/architecture/context-discovery.md +43 -0
  145. package/.agent/skills/architecture/examples.md +94 -0
  146. package/.agent/skills/architecture/pattern-selection.md +68 -0
  147. package/.agent/skills/architecture/patterns-reference.md +50 -0
  148. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  149. package/.agent/skills/clean-code/SKILL.md +201 -0
  150. package/.agent/skills/doc.md +177 -0
  151. package/.agent/skills/frontend-design/SKILL.md +418 -0
  152. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  153. package/.agent/skills/frontend-design/color-system.md +311 -0
  154. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  155. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  156. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  157. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  158. package/.agent/skills/frontend-design/typography-system.md +345 -0
  159. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  160. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  161. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  162. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  163. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  164. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  165. package/.agent/workflows/brainstorm.md +113 -0
  166. package/.agent/workflows/create.md +59 -0
  167. package/.agent/workflows/debug.md +103 -0
  168. package/.agent/workflows/deploy.md +176 -0
  169. package/.agent/workflows/enhance.md +63 -0
  170. package/.agent/workflows/orchestrate.md +237 -0
  171. package/.agent/workflows/plan.md +89 -0
  172. package/.agent/workflows/preview.md +81 -0
  173. package/.agent/workflows/simple-test.md +42 -0
  174. package/.agent/workflows/status.md +86 -0
  175. package/.agent/workflows/structured-orchestrate.md +180 -0
  176. package/.agent/workflows/test.md +144 -0
  177. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  178. package/.claude/settings.local.json +20 -8
  179. package/.env.example +56 -56
  180. package/CLAUDE.md +144 -108
  181. package/README.md +441 -441
  182. package/calc_tokens_weixin.js +81 -0
  183. package/cli/src/commands/chat.js +2 -1
  184. package/docs/CONTEXT_DESIGN.md +1596 -0
  185. package/examples/test-concurrent-chat.js +60 -60
  186. package/foliko-creative-3.png +0 -0
  187. package/foliko-creative-4.png +0 -0
  188. package/foliko-creative-5.png +0 -0
  189. package/package.json +2 -2
  190. package/plugins/default-plugins.js +2 -1
  191. package/plugins/extension-executor-plugin.js +91 -2
  192. package/plugins/file-system-plugin.js +2 -2
  193. package/plugins/memory-plugin.js +984 -0
  194. package/plugins/session-plugin.js +57 -1
  195. package/plugins/weixin-plugin.js +33 -23
  196. package/skills/find-skills/AGENTS.md +162 -162
  197. package/skills/find-skills/SKILL.md +133 -133
  198. package/skills/poster-guide/SKILL.md +1059 -0
  199. package/skills/python-plugin-dev/SKILL.md +238 -238
  200. package/skills/skill-guide/SKILL.md +130 -108
  201. package/src/capabilities/skill-manager.js +99 -0
  202. package/src/core/agent-chat.js +620 -141
  203. package/src/core/agent-context.js +188 -0
  204. package/src/core/agent.js +6 -2
  205. package/src/core/context-manager.js +283 -0
  206. package/src/core/framework.js +264 -3
  207. package/src/core/plugin-manager.js +79 -2
  208. package/src/core/request-context.js +98 -0
  209. package/src/core/session-context.js +341 -0
  210. package/src/core/session-storage.js +274 -0
  211. package/src/executors/mcp-executor.js +2 -2
  212. package/src/utils/index.js +239 -67
  213. package/src/utils/plugin-helpers.js +17 -0
  214. package/story-cover-book-v2.png +0 -0
  215. package/story-cover-japanese-1.png +0 -0
  216. package/story-cover-japanese-2.png +0 -0
  217. package/story-cover-japanese-3.png +0 -0
  218. package/story-cover-moran.png +0 -0
  219. package/undefined.png +0 -0
  220. package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
  221. package/.agent/agents/code-assistant.json +0 -14
  222. package/.agent/agents/email-assistant.json +0 -14
  223. package/.agent/agents/file-assistant.json +0 -15
  224. package/.agent/agents/system-assistant.json +0 -15
  225. package/.agent/agents/web-assistant.json +0 -12
  226. package/.agent/data/ambient/goals.json +0 -50
  227. package/.agent/data/ambient/memories.json +0 -7
  228. package/.agent/data/scheduler/tasks.json +0 -1
  229. package/.agent/package.json +0 -8
  230. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  231. package/.agent/plugins/daytona/README.md +0 -89
  232. package/.agent/plugins/daytona/index.js +0 -377
  233. package/.agent/plugins/daytona/package.json +0 -12
  234. package/.agent/plugins/marknative/README.md +0 -134
  235. package/.agent/plugins/marknative/index.js +0 -228
  236. package/.agent/plugins/marknative/package.json +0 -12
  237. package/.agent/plugins/marknative/update-readme.js +0 -134
  238. package/.agent/plugins/system-info/index.js +0 -387
  239. package/.agent/plugins/system-info/package.json +0 -4
  240. package/.agent/plugins/system-info/test.js +0 -40
  241. package/.agent/plugins/temp-repo/LICENSE +0 -201
  242. package/.agent/plugins/test_plugin.py +0 -304
  243. package/.agent/python-scripts/test_sample.py +0 -24
  244. package/.agent/skills/agent-browser/SKILL.md +0 -311
  245. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  246. package/.agent/skills/sysinfo/SKILL.md +0 -38
  247. package/.agent/skills/sysinfo/system-info.sh +0 -130
  248. package/.agent/skills/workflow/SKILL.md +0 -324
  249. package/.agent/workflows/email-digest.json +0 -50
  250. package/.agent/workflows/file-backup.json +0 -21
  251. package/.agent/workflows/get-ip-notify.json +0 -32
  252. package/.agent/workflows/news-aggregator.json +0 -93
  253. package/.agent/workflows/news-dashboard-v2.json +0 -94
  254. package/.agent/workflows/notification-batch.json +0 -32
  255. package/examples/test-chat-debug.js +0 -102
  256. package/examples/test-chat-result.js +0 -76
  257. package/examples/test-chat-stream-diff.js +0 -63
  258. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
  259. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/package.json +0 -0
@@ -0,0 +1,621 @@
1
+ # Poster Designer Plugin
2
+
3
+ 画报/Banner 图绘制插件 - 基于 Node.js paper.js 实现,支持创建海报、宣传图、banner 图并导出为图片。
4
+
5
+ ## 功能特性
6
+
7
+ ### 预设尺寸
8
+
9
+ - **海报尺寸**: A4海报、方形海报、16:9海报
10
+ - **Banner尺寸**: 网站Banner、电商Banner、移动端Banner、小横幅
11
+ - **社交媒体**: Instagram、Facebook、Twitter 等平台尺寸
12
+ - **宣传图**: 多种常用宣传图尺寸
13
+
14
+ ### 绘图功能
15
+
16
+ - 背景:纯色背景、线性渐变、径向渐变
17
+ - 图形:矩形、圆形/椭圆、线条、多边形
18
+ - 文字:普通文字、艺术文字(描边、渐变、阴影)
19
+ - 图片:添加图片、设为背景
20
+ - 圆角支持:矩形和图片都支持圆角裁剪
21
+
22
+ ### 导出功能
23
+
24
+ - PNG 格式(默认)
25
+ - JPEG 格式(支持质量参数)
26
+ - Base64 编码导出
27
+ - 自动生成文件路径
28
+
29
+ ## 安装
30
+
31
+ ```bash
32
+ npm install poster-designer
33
+ ```
34
+
35
+ ## 使用方法
36
+
37
+ ### 1. 创建画布
38
+
39
+ ```javascript
40
+ // 使用预设尺寸
41
+ create_canvas({ preset: 'poster_square' });
42
+
43
+ // 自定义尺寸
44
+ create_canvas({ width: 1920, height: 1080, background: '#1a1a2e' });
45
+ ```
46
+
47
+ ### 2. 添加背景
48
+
49
+ ```javascript
50
+ // 纯色背景
51
+ add_background({ color: '#1a1a2e' });
52
+
53
+ // 渐变背景
54
+ add_background({
55
+ gradient: {
56
+ type: 'linear',
57
+ colors: ['#ff6b6b', '#4ecdc4'],
58
+ direction: 45,
59
+ },
60
+ });
61
+ ```
62
+
63
+ ### 3. 添加元素
64
+
65
+ ```javascript
66
+ // 矩形
67
+ add_rectangle({
68
+ x: 100,
69
+ y: 100,
70
+ width: 300,
71
+ height: 200,
72
+ fill: '#4ecdc4',
73
+ radius: 20,
74
+ });
75
+
76
+ // 圆形
77
+ add_circle({
78
+ cx: 500,
79
+ cy: 500,
80
+ rx: 100,
81
+ fill: '#ff6b6b',
82
+ });
83
+
84
+ // 文字
85
+ add_text({
86
+ text: 'Hello World',
87
+ x: 100,
88
+ y: 100,
89
+ fontSize: 48,
90
+ color: '#ffffff',
91
+ shadow: {
92
+ color: 'rgba(0,0,0,0.5)',
93
+ blur: 10,
94
+ offsetX: 2,
95
+ offsetY: 2,
96
+ },
97
+ });
98
+
99
+ // 艺术文字
100
+ add_art_text({
101
+ text: 'FOLIKO',
102
+ x: 1000,
103
+ y: 1000,
104
+ fontSize: 120,
105
+ gradient: {
106
+ colors: ['#ff6b6b', '#feca57'],
107
+ direction: 45,
108
+ },
109
+ strokeColor: '#ffffff',
110
+ strokeWidth: 3,
111
+ });
112
+
113
+ // 图片
114
+ add_image({
115
+ src: '/path/to/image.png',
116
+ x: 200,
117
+ y: 200,
118
+ width: 500,
119
+ height: 300,
120
+ rounded: 10,
121
+ });
122
+ ```
123
+
124
+ ### 4. 导出
125
+
126
+ ```javascript
127
+ // 导出为文件
128
+ export_canvas({
129
+ filename: 'my-poster',
130
+ format: 'png',
131
+ outputDir: '/app',
132
+ });
133
+
134
+ // 导出为 Base64
135
+ export_base64({ format: 'png' });
136
+ ```
137
+
138
+ ### 5. 一键生成海报
139
+
140
+ ```javascript
141
+ // 使用预设模板快速生成
142
+ generate_poster({
143
+ template: 'modern', // simple, modern, business, social
144
+ title: 'FOLIKO AI',
145
+ subtitle: '智能助手新体验',
146
+ background: '#1a1a2e',
147
+ accentColor: '#e94560',
148
+ output: 'foliko-poster',
149
+ });
150
+ ```
151
+
152
+ ## 可用工具
153
+
154
+ | 工具名称 | 描述 |
155
+ | ---------------------- | -------------------- |
156
+ | `list_presets` | 列出所有可用尺寸预设 |
157
+ | `create_canvas` | 创建新画布 |
158
+ | `add_background` | 添加背景色/渐变 |
159
+ | `add_rectangle` | 添加矩形 |
160
+ | `add_circle` | 添加圆形/椭圆 |
161
+ | `add_line` | 添加线条 |
162
+ | `add_polygon` | 绘制多边形 |
163
+ | `add_text` | 添加文字 |
164
+ | `add_art_text` | 添加艺术文字 |
165
+ | `add_image` | 添加图片 |
166
+ | `set_background_image` | 设置背景图片 |
167
+ | `export_canvas` | 导出为图片文件 |
168
+ | `export_base64` | 导出为 Base64 |
169
+ | `get_canvas_info` | 获取画布信息 |
170
+ | `clear_canvas` | 清除画布 |
171
+ | `generate_poster` | 一键生成海报 |
172
+
173
+ ## 预设尺寸列表
174
+
175
+ ### 海报
176
+
177
+ | Key | 尺寸 | 名称 |
178
+ | --------------- | --------- | --------------- |
179
+ | `poster_a4` | 2480×3508 | A4海报 (300dpi) |
180
+ | `poster_square` | 2000×2000 | 方形海报 |
181
+ | `poster_16_9` | 1920×1080 | 16:9海报 |
182
+
183
+ ### Banner
184
+
185
+ | Key | 尺寸 | 名称 |
186
+ | ----------------- | -------- | ------------ |
187
+ | `banner_1920x500` | 1920×500 | 网站Banner |
188
+ | `banner_1200x400` | 1200×400 | 电商Banner |
189
+ | `banner_750x300` | 750×300 | 移动端Banner |
190
+ | `banner_468x60` | 468×60 | 小横幅 |
191
+
192
+ ### 社交媒体
193
+
194
+ | Key | 尺寸 | 名称 |
195
+ | ------------------ | --------- | --------------- |
196
+ | `social_instagram` | 1080×1080 | Instagram正方形 |
197
+ | `social_story` | 1080×1920 | Instagram Story |
198
+ | `social_facebook` | 1200×630 | Facebook封面 |
199
+ | `social_twitter` | 1600×900 | Twitter封面 |
200
+
201
+ ### 宣传图
202
+
203
+ | Key | 尺寸 | 名称 |
204
+ | --------------- | ------- | ---------- |
205
+ | `promo_900x500` | 900×500 | 宣传图 |
206
+ | `promo_500x500` | 500×500 | 正方宣传图 |
207
+
208
+ ## 模板示例
209
+
210
+ ### Modern(现代风格)
211
+
212
+ ```
213
+ 特点:几何装饰元素,大标题居中,渐变强调色
214
+ 适用:科技产品、活动宣传
215
+ ```
216
+
217
+ ### Business(商务风格)
218
+
219
+ ```
220
+ 特点:简洁线条,专业配色,稳重排版
221
+ 适用:企业宣传、商务推广
222
+ ```
223
+
224
+ ### Social(社交风格)
225
+
226
+ ```
227
+ 特点:圆形框架,居中头像效果,活力配色
228
+ 适用:社交媒体头像、个人品牌
229
+ ```
230
+
231
+ ### Simple(简约风格)
232
+
233
+ ```
234
+ 特点:纯色背景,大留白,简洁文字
235
+ 适用:极简主义、文艺风格
236
+ ```
237
+
238
+ ## 依赖
239
+
240
+ - `paper.js`: 图片处理
241
+
242
+ ## 许可证
243
+
244
+ MIT License
245
+
246
+ paper.js nodejs使用的例子:
247
+
248
+ ```javascript
249
+ import paper from 'paper';
250
+ import path from 'path';
251
+ import { fileURLToPath } from 'url';
252
+ import fs from 'fs-extra';
253
+ import { createCanvas, registerFont } from 'canvas';
254
+ import { initDefaultFont, registerFontFile } from '../utils/font-manager.js';
255
+ const __filename = fileURLToPath(import.meta.url);
256
+ const __dirname = path.dirname(__filename);
257
+
258
+ initDefaultFont();
259
+ /**
260
+ * 渲染器类 - 使用 Paper.js 渲染
261
+ */
262
+ export class Renderer {
263
+ constructor(config = {}) {
264
+ this.width = config.width || 1920;
265
+ this.height = config.height || 1080;
266
+ this.fps = config.fps || 30;
267
+ this.quality = config.quality || 'high';
268
+ this.canvas = null;
269
+ this.project = null;
270
+ this.paper = null; // Paper.js 实例引用
271
+ this.initialized = false;
272
+ }
273
+
274
+ /**
275
+ * 初始化渲染器
276
+ */
277
+ async init() {
278
+ if (this.initialized) return;
279
+
280
+ // 创建离屏 Canvas(用于最终输出)
281
+ this.canvas = paper.createCanvas(this.width, this.height);
282
+
283
+ // 创建新的 Paper.js Project(实例化)
284
+ // 每个 Renderer 都有自己独立的 project
285
+ this.project = new paper.Project(this.canvas);
286
+
287
+ // 保存 paper 引用(用于访问 Paper.js 的类,如 paper.Point, paper.Path 等)
288
+ this.paper = paper;
289
+
290
+ this.initialized = true;
291
+ }
292
+
293
+ /**
294
+ * 获取 Paper.js 实例(用于传递给元素)
295
+ * @returns {Object} Paper.js 实例对象,包含 project 和 paper 类
296
+ */
297
+ getPaperInstance() {
298
+ return {
299
+ project: this.project,
300
+ paper: this.paper, // 用于访问 Paper.js 的类(Point, Path, Color 等)
301
+ };
302
+ }
303
+
304
+ /**
305
+ * 设置尺寸
306
+ */
307
+ setSize(width, height) {
308
+ this.width = width;
309
+ this.height = height;
310
+ if (this.canvas) {
311
+ this.canvas.width = width;
312
+ this.canvas.height = height;
313
+ }
314
+ if (this.project && this.project.view) {
315
+ this.project.view.viewSize = new this.paper.Size(width, height);
316
+ }
317
+ }
318
+
319
+ /**
320
+ * 清空场景
321
+ */
322
+ clear() {
323
+ // 清空当前 project 的 activeLayer
324
+ if (this.project && this.project.activeLayer) {
325
+ this.project.activeLayer.removeChildren();
326
+ }
327
+ }
328
+
329
+ /**
330
+ * 渲染一帧 - 使用 Paper.js
331
+ * @param {Array} layers - 图层数组
332
+ * @param {number} time - 当前时间(秒)
333
+ * @param {string} backgroundColor - 背景颜色
334
+ */
335
+ async renderFrame(layers, time, backgroundColor = '#000000') {
336
+ if (!this.initialized) {
337
+ await this.init();
338
+ }
339
+
340
+ // 先清空 canvas 的 2D context(确保 canvas 有初始状态)
341
+ const ctx = this.canvas.getContext('2d');
342
+ ctx.fillStyle = backgroundColor;
343
+ ctx.fillRect(0, 0, this.width, this.height);
344
+
345
+ // 清空 Paper.js 场景(复用 project 时只需要清空子元素)
346
+ if (this.project && this.project.activeLayer) {
347
+ this.project.activeLayer.removeChildren();
348
+ }
349
+
350
+ // 绘制背景(使用 Paper.js)
351
+ // 只有当背景不是透明时才绘制
352
+ if (
353
+ backgroundColor &&
354
+ backgroundColor !== 'transparent' &&
355
+ backgroundColor !== 'rgba(0,0,0,0)'
356
+ ) {
357
+ const bgRect = new this.paper.Path.Rectangle({
358
+ rectangle: new this.paper.Rectangle(0, 0, this.width, this.height),
359
+ fillColor: backgroundColor,
360
+ });
361
+ bgRect.sendToBack();
362
+ }
363
+
364
+ // 按 zIndex 排序图层
365
+ const sortedLayers = [...layers].sort((a, b) => a.zIndex - b.zIndex);
366
+
367
+ // 收集所有已渲染的元素
368
+ const renderedElements = [];
369
+
370
+ // 获取 Paper.js 实例(传递给图层和元素)
371
+ const paperInstance = this.getPaperInstance();
372
+
373
+ // 渲染所有图层到 Paper.js
374
+ for (let i = 0; i < sortedLayers.length; i++) {
375
+ const layer = sortedLayers[i];
376
+ if (layer.isActiveAtTime(time)) {
377
+ // 使用 Paper.js 渲染(支持异步)
378
+ // 传递 paperInstance 给图层,图层再传递给元素
379
+ const result = layer.render(this.project.activeLayer, time, paperInstance);
380
+ if (result && typeof result.then === 'function') {
381
+ await result;
382
+ }
383
+
384
+ // 收集图层中已渲染的元素
385
+ if (layer.getRenderedElements && typeof layer.getRenderedElements === 'function') {
386
+ const elements = layer.getRenderedElements();
387
+ renderedElements.push(...elements);
388
+ }
389
+ }
390
+ }
391
+
392
+ // 创建 onFrame 事件对象
393
+ const frameEvent = {
394
+ count: Math.floor(time * this.fps), // 帧计数
395
+ time: time, // 当前时间(秒)
396
+ delta: 1 / this.fps, // 帧间隔(秒)
397
+ };
398
+
399
+ // 触发元素的 onFrame 回调
400
+ for (const element of renderedElements) {
401
+ if (element.onFrame) {
402
+ // 使用元素保存的 _paperItem 引用,并传递 paperInstance
403
+ element._callOnFrame(frameEvent, element._paperItem, paperInstance);
404
+ }
405
+ }
406
+
407
+ // 触发全局的 Paper.js onFrame 事件(如果已注册,用于向后兼容)
408
+ if (this.project.view && typeof this.project.view.onFrame === 'function') {
409
+ try {
410
+ this.project.view.onFrame(frameEvent);
411
+ } catch (e) {
412
+ console.warn('[Renderer] 全局 onFrame 事件触发失败:', e);
413
+ }
414
+ }
415
+
416
+ // 更新视图并绘制到 canvas
417
+ // Paper.js 在 Node.js 环境中需要调用 view.update() 来更新视图
418
+ // 然后使用 view.draw() 将内容绘制到 canvas
419
+ this.project.view.update();
420
+
421
+ // 检查 project 中的项目数量
422
+ const itemCount = this.project.activeLayer.children.length;
423
+ if (itemCount > 0) {
424
+ // 强制绘制
425
+ this.project.view.draw();
426
+ }
427
+
428
+ return this.canvas;
429
+ }
430
+
431
+ /**
432
+ * 将 BGRA 格式转换为 RGBA 格式
433
+ * @param {Buffer} bgraBuffer - BGRA 格式的 Buffer
434
+ * @returns {Buffer} RGBA 格式的 Buffer
435
+ */
436
+ convertBGRAtoRGBA(bgraBuffer) {
437
+ const rgbaBuffer = Buffer.allocUnsafe(bgraBuffer.length);
438
+ // 每 4 个字节为一组:BGRA -> RGBA
439
+ for (let i = 0; i < bgraBuffer.length; i += 4) {
440
+ rgbaBuffer[i] = bgraBuffer[i + 2]; // R = B
441
+ rgbaBuffer[i + 1] = bgraBuffer[i + 1]; // G = G
442
+ rgbaBuffer[i + 2] = bgraBuffer[i]; // B = R
443
+ rgbaBuffer[i + 3] = bgraBuffer[i + 3]; // A = A
444
+ }
445
+ return rgbaBuffer;
446
+ }
447
+
448
+ /**
449
+ * 获取 Canvas 缓冲区
450
+ * @param {string} format - 格式:'raw'(原始 RGBA 数据)或 'png'(PNG 图片)
451
+ * @returns {Buffer|null} Canvas 缓冲区
452
+ */
453
+ getCanvasBuffer(format = 'raw') {
454
+ if (!this.canvas) return null;
455
+
456
+ if (format === 'raw') {
457
+ // 使用 toBuffer('raw') 获取原始数据,性能提升 5-10倍
458
+ // 注意:node-canvas 的 toBuffer('raw') 在不同平台上可能返回不同格式:
459
+ // - Windows: BGRA 格式
460
+ // - Linux/Mac: RGBA 格式
461
+ // FFmpeg 需要 RGBA 格式,所以如果是 BGRA 需要转换
462
+ let buffer = this.canvas.toBuffer('raw');
463
+
464
+ // 验证 buffer 大小是否正确
465
+ const expectedSize = this.width * this.height * 4;
466
+ if (buffer.length !== expectedSize) {
467
+ console.warn(
468
+ `[Renderer] Buffer size mismatch: expected ${expectedSize}, got ${buffer.length}`
469
+ );
470
+ // 如果大小不匹配,回退到 PNG 格式
471
+ return this.canvas.toBuffer('image/png');
472
+ }
473
+
474
+ // 检测平台:Windows 上通常是 BGRA,需要转换为 RGBA
475
+ const platform = process.platform;
476
+ const isWindows = platform === 'win32';
477
+
478
+ if (isWindows) {
479
+ // Windows 上 toBuffer('raw') 返回 BGRA,需要转换为 RGBA
480
+ buffer = this.convertBGRAtoRGBA(buffer);
481
+ }
482
+ // Linux/Mac 上通常是 RGBA,不需要转换
483
+
484
+ return buffer;
485
+ } else {
486
+ // PNG 格式(用于保存帧文件或转场处理)
487
+ return this.canvas.toBuffer('image/png');
488
+ }
489
+ }
490
+
491
+ /**
492
+ * 获取 Canvas
493
+ */
494
+ getCanvas() {
495
+ return this.canvas;
496
+ }
497
+
498
+ /**
499
+ * 导出动画帧序列(类似 paper.view.exportFrames)
500
+ * @param {Array} layers - 图层数组
501
+ * @param {Object} options - 导出选项
502
+ * @param {number} options.amount - 要导出的总帧数
503
+ * @param {string} options.directory - 保存帧的目录
504
+ * @param {number} options.fps - 帧率(默认 30)
505
+ * @param {number} options.startTime - 开始时间(秒,默认 0)
506
+ * @param {number} options.endTime - 结束时间(秒)
507
+ * @param {string} options.backgroundColor - 背景颜色(默认 '#000000')
508
+ * @param {Function} options.onProgress - 进度回调函数 (current, total) => {}
509
+ * @param {Function} options.onComplete - 完成回调函数
510
+ * @returns {Promise<string[]>} 返回所有导出帧的文件路径数组
511
+ */
512
+ async exportFrames(layers, options = {}) {
513
+ const {
514
+ amount,
515
+ directory = './frames',
516
+ fps = this.fps || 30,
517
+ startTime = 0,
518
+ endTime,
519
+ backgroundColor = '#000000',
520
+ onProgress,
521
+ onComplete,
522
+ } = options;
523
+
524
+ if (!this.initialized) {
525
+ await this.init();
526
+ }
527
+
528
+ // 确保目录存在
529
+ await fs.ensureDir(directory);
530
+
531
+ // 计算实际帧数和时间范围
532
+ let totalFrames = amount;
533
+ let actualEndTime = endTime;
534
+
535
+ if (endTime !== undefined) {
536
+ // 如果指定了结束时间,根据帧率计算帧数
537
+ totalFrames = Math.ceil((endTime - startTime) * fps);
538
+ } else if (amount === undefined) {
539
+ // 如果都没有指定,使用默认值
540
+ totalFrames = 30; // 默认 1 秒
541
+ actualEndTime = startTime + 1;
542
+ } else {
543
+ // 如果只指定了帧数,计算结束时间
544
+ actualEndTime = startTime + totalFrames / fps;
545
+ }
546
+
547
+ const framePaths = [];
548
+
549
+ // 按 zIndex 排序图层
550
+ const sortedLayers = [...layers].sort((a, b) => a.zIndex - b.zIndex);
551
+
552
+ for (let frame = 0; frame < totalFrames; frame++) {
553
+ const time = startTime + frame / fps;
554
+ const frameNumber = frame + 1;
555
+
556
+ // 渲染帧
557
+ await this.renderFrame(sortedLayers, time, backgroundColor);
558
+
559
+ // 保存帧
560
+ const framePath = path.join(
561
+ directory,
562
+ `frame_${frameNumber.toString().padStart(4, '0')}.png`
563
+ );
564
+ const buffer = this.getCanvasBuffer();
565
+ await fs.writeFile(framePath, buffer);
566
+ framePaths.push(framePath);
567
+
568
+ // 调用进度回调
569
+ if (onProgress && typeof onProgress === 'function') {
570
+ onProgress(frameNumber, totalFrames);
571
+ }
572
+ }
573
+
574
+ // 调用完成回调
575
+ if (onComplete && typeof onComplete === 'function') {
576
+ onComplete(framePaths);
577
+ }
578
+
579
+ return framePaths;
580
+ }
581
+
582
+ /**
583
+ * 销毁渲染器
584
+ */
585
+ destroy() {
586
+ // 清理 Paper.js 项目
587
+ if (this.project) {
588
+ try {
589
+ this.project.clear();
590
+ // 移除所有图层和项目
591
+ if (this.project.activeLayer) {
592
+ this.project.activeLayer.removeChildren();
593
+ }
594
+ // 移除项目
595
+ if (this.project && this.project.remove) {
596
+ this.project.remove();
597
+ }
598
+ } catch (error) {
599
+ // 忽略清理错误
600
+ }
601
+ }
602
+
603
+ // 清理 Canvas
604
+ if (this.canvas) {
605
+ try {
606
+ // 清空 canvas 内容
607
+ const ctx = this.canvas.getContext('2d');
608
+ if (ctx) {
609
+ ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
610
+ }
611
+ } catch (error) {
612
+ // 忽略清理错误
613
+ }
614
+ this.canvas = null;
615
+ }
616
+
617
+ this.project = null;
618
+ this.initialized = false;
619
+ }
620
+ }
621
+ ```
@@ -1,14 +0,0 @@
1
- {
2
- "name": "code-assistant",
3
- "description": "代码助手 - 专业的编程和代码分析助手",
4
- "instructions": "你是一个专业的代码助手,精通多种编程语言和开发技术。\n\n【核心能力】\n- 代码编写、调试和优化\n- 代码审查和重构建议\n- 多种编程语言支持(Python、JavaScript、TypeScript、Java等)\n- 代码问题诊断和解决\n- 解释复杂代码逻辑\n\n【工作原则】\n- 提供清晰、规范的代码\n- 包含必要的注释说明\n- 考虑代码性能和安全性\n- 遵循最佳实践",
5
- "tools": [
6
- "read_file",
7
- "write_file",
8
- "modify_file",
9
- "search_file",
10
- "python-execute",
11
- "execute_command",
12
- "shell"
13
- ]
14
- }
@@ -1,14 +0,0 @@
1
- {
2
- "name": "email-assistant",
3
- "description": "邮件助手 - 专业的邮件管理助手",
4
- "instructions": "你是一个专业的邮件助手,擅长邮件的读写、筛选和管理。\n\n【核心能力】\n- 读取和回复邮件\n- 发送新邮件(支持附件)\n- 邮件搜索和筛选\n- 邮件摘要生成\n- 批量邮件处理\n\n【工作原则】\n- 保持邮件格式规范\n- 回复内容专业得体\n- 保护隐私信息\n- 及时处理重要邮件",
5
- "tools": [
6
- "email_read",
7
- "email_send",
8
- "email_mark_read",
9
- "email_delete",
10
- "email_unread_count",
11
- "email_configure",
12
- "notification_send"
13
- ]
14
- }
@@ -1,15 +0,0 @@
1
- {
2
- "name": "file-assistant",
3
- "description": "文件助手 - 专业的文件管理和操作助手",
4
- "instructions": "你是一个专业的文件助手,擅长文件操作、目录管理、文件搜索和内容编辑。\n\n【核心能力】\n- 读取、创建、编辑、删除文件和目录\n- 搜索文件内容和文件名称\n- 批量文件操作\n- 文件内容分析和提取\n\n【工作原则】\n- 执行操作前确认路径正确\n- 危险操作(如删除)需要谨慎\n- 保持文件编码一致性\n- 重要文件操作前可创建备份",
5
- "tools": [
6
- "read_file",
7
- "write_file",
8
- "delete_file",
9
- "modify_file",
10
- "search_file",
11
- "read_directory",
12
- "create_directory",
13
- "execute_command"
14
- ]
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "name": "system-assistant",
3
- "description": "系统助手 - 专业的系统信息监控和管理助手",
4
- "instructions": "你是一个专业的系统助手,精通系统信息监控和基础管理。\n\n【核心能力】\n- CPU、内存、磁盘使用情况监控\n- 网络接口信息查询\n- 系统运行状态分析\n- 性能问题诊断\n- 定时监控和报告\n\n【工作原则】\n- 提供清晰的数据展示\n- 发现异常及时提醒\n- 给出合理的优化建议\n- 保护系统安全",
5
- "tools": [
6
- "get_basic_info",
7
- "get_cpu_info",
8
- "get_memory_info",
9
- "get_disk_info",
10
- "get_network_info",
11
- "get_full_system_info",
12
- "notification_send",
13
- "schedule_task"
14
- ]
15
- }
@@ -1,12 +0,0 @@
1
- {
2
- "name": "web-assistant",
3
- "description": "网络助手 - 专业的网络数据获取和处理助手",
4
- "instructions": "你是一个专业的网络助手,精通网络数据获取和处理。\n\n【核心能力】\n- HTTP请求发送(GET/POST/PUT/DELETE等)\n- 网页内容抓取和解析\n- API调用和数据处理\n- JSON/XML数据解析\n- 网络问题诊断\n\n【工作原则】\n- 遵守网站使用协议\n- 合理控制请求频率\n- 数据处理规范\n- 异常情况妥善处理",
5
- "tools": [
6
- "fetch",
7
- "web_request",
8
- "execute_command",
9
- "python-execute",
10
- "notification_send"
11
- ]
12
- }