foliko 1.0.86 → 1.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.
Files changed (104) hide show
  1. package/.agent/data/default.json +3 -4310
  2. package/.agent/data/plugins-state.json +34 -1
  3. package/.agent/mcp_config.json +0 -1
  4. package/.agent/memory/core.md +1 -0
  5. package/.agent/memory/project/mnn93ogy-ypjn27.md +9 -0
  6. package/.agent/memory/project/mnn98fqy-5nhc1u.md +25 -0
  7. package/.agent/memory/user/mnm67t9m-x8rekk.md +9 -0
  8. package/.agent/memory/user/mnn5mmqh-w6aktx.md +11 -0
  9. package/.agent/memory/user/mnnbfhhn-dk1bd1.md +22 -0
  10. package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
  11. package/.agent/plugins/marknative/index.js +2 -7
  12. package/.agent/plugins/poster-plugin/README.md +304 -0
  13. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  14. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  15. 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
  16. package/.agent/plugins/poster-plugin/index.js +13 -0
  17. package/.agent/plugins/poster-plugin/package.json +28 -0
  18. package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
  19. package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
  20. package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
  21. package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
  22. package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
  23. package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
  24. package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
  25. package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
  26. package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
  27. package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
  28. package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
  29. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
  30. package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
  31. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
  32. package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
  33. package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
  34. package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
  35. package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
  36. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
  37. package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
  38. package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
  39. package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
  40. package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
  41. package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
  42. package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
  43. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
  44. package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
  45. package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
  46. package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
  47. package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
  48. package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
  49. package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
  50. package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
  51. package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
  52. package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
  53. package/.agent/plugins/poster-plugin/src/elements/polygon.js +32 -0
  54. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
  55. package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
  56. package/.agent/plugins/poster-plugin/src/elements/text.js +38 -0
  57. package/.agent/plugins/poster-plugin/src/fonts.js +118 -0
  58. package/.agent/plugins/poster-plugin/src/index.js +1659 -0
  59. package/.agent/plugins/poster-plugin/src/presets.js +36 -0
  60. package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
  61. package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
  62. package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
  63. package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
  64. package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
  65. package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
  66. package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
  67. package/.agent/sessions/cli_default.json +24265 -0
  68. package/.agent/weixin.json +6 -0
  69. package/.claude/settings.local.json +176 -171
  70. package/CLAUDE.md +144 -108
  71. package/docs/CONTEXT_DESIGN.md +1596 -0
  72. package/examples/test-concurrent-chat.js +60 -0
  73. package/examples/test-long-chat.js +77 -0
  74. package/examples/test-session-chat.js +93 -0
  75. package/output/beef-love-poster.png +0 -0
  76. package/package.json +2 -2
  77. package/plugins/default-plugins.js +2 -1
  78. package/plugins/extension-executor-plugin.js +11 -0
  79. package/plugins/memory-plugin.js +984 -0
  80. package/plugins/session-plugin.js +78 -1
  81. package/plugins/weixin-plugin.js +24 -22
  82. package/skills/poster-guide/SKILL.md +743 -0
  83. package/skills/python-plugin-dev/SKILL.md +238 -238
  84. package/skills/skill-guide/SKILL.md +130 -108
  85. package/src/capabilities/skill-manager.js +99 -0
  86. package/src/core/agent-chat.js +627 -180
  87. package/src/core/agent-context.js +188 -0
  88. package/src/core/agent.js +9 -63
  89. package/src/core/context-manager.js +283 -0
  90. package/src/core/framework.js +264 -3
  91. package/src/core/plugin-manager.js +79 -2
  92. package/src/core/request-context.js +98 -0
  93. package/src/core/session-context.js +341 -0
  94. package/src/core/session-storage.js +274 -0
  95. package/src/executors/mcp-executor.js +2 -2
  96. package/src/utils/index.js +239 -67
  97. package/src/utils/plugin-helpers.js +17 -0
  98. package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
  99. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  100. package/.agent/plugins/temp-repo/LICENSE +0 -201
  101. package/.agent/plugins/temp-repo/puppeteer-plugin/README.md +0 -147
  102. package/.agent/plugins/temp-repo/puppeteer-plugin/index.js +0 -1418
  103. package/.agent/plugins/temp-repo/puppeteer-plugin/package.json +0 -9
  104. package/.agent/plugins/test_plugin.py +0 -304
@@ -182,7 +182,10 @@
182
182
  "maxHistoryLength": 150,
183
183
  "autoCleanup": true,
184
184
  "cleanupInterval": 300000,
185
- "persistToStorage": true
185
+ "persistToStorage": true,
186
+ "onSessionStart": null,
187
+ "onSessionEnd": null,
188
+ "onSessionCreated": null
186
189
  }
187
190
  },
188
191
  "shell-executor": {
@@ -252,5 +255,35 @@
252
255
  "marknative": {
253
256
  "enabled": true,
254
257
  "config": {}
258
+ },
259
+ "poster-designer": {
260
+ "enabled": true,
261
+ "config": {}
262
+ },
263
+ "memory": {
264
+ "enabled": true,
265
+ "config": {
266
+ "memoryDir": ".agent/memory",
267
+ "autoExtract": true,
268
+ "extractOnTopics": [
269
+ "provider",
270
+ "preference",
271
+ "setting",
272
+ "user"
273
+ ],
274
+ "maxCoreMemory": 4000
275
+ }
276
+ },
277
+ "session-memory": {
278
+ "enabled": true,
279
+ "config": {
280
+ "memoryDir": ".agent/memory",
281
+ "maxCoreMemory": 4000,
282
+ "maxRecallResults": 5
283
+ }
284
+ },
285
+ "poster": {
286
+ "enabled": true,
287
+ "config": {}
255
288
  }
256
289
  }
@@ -1,5 +1,4 @@
1
1
  {
2
2
  "mcpServers": {
3
-
4
3
  }
5
4
  }
@@ -0,0 +1 @@
1
+ 测试数据 - 姓名: 李四, 职业: 工程师, 城市: 北京, 兴趣: 编程
@@ -0,0 +1,9 @@
1
+ ---
2
+ id: "mnn93ogy-ypjn27"
3
+ name: "Foliko AI Agent Platform"
4
+ type: "project"
5
+ project: "foliko"
6
+ tags: [foliko, ai-agent, poster, design]
7
+ created: "2026-04-06"
8
+ ---
9
+ Foliko 是一个 AI Agent 平台项目,位于 D:\Code\vb-agent 目录。用户正在测试不同的海报设计风格,目前已经测试了 simple、business、social 和 modern 四种模板样式。这表明用户在为项目选择合适的视觉设计风格。后续可以使用此记忆来理解用户的设计偏好,或在类似项目中提供风格建议。
@@ -0,0 +1,25 @@
1
+ ---
2
+ id: "mnn98fqy-5nhc1u"
3
+ name: "Foliko AI 海报设计规范"
4
+ type: "project"
5
+ project: "Foliko"
6
+ tags: [海报设计, AI, 品牌视觉, 项目展示]
7
+ created: "2026-04-06"
8
+ ---
9
+ Foliko 是一个 AI 项目,slogan 是「AI 驱动的创意灵感和效率工具」。为 Foliko 制作海报的设计经验:
10
+
11
+ **设计原则**:
12
+ - 视觉层次:大标题 > 副标题 > 核心特性 > 行动号召
13
+ - 色彩搭配:深色背景 + 霓虹渐变(科技感),蓝色代表科技/信任,绿色代表创新
14
+ - 留白:保持简洁,不要过于拥挤
15
+ - 对比:使用深色背景+亮色文字产生强烈对比
16
+ - 品牌识别:保持 Foliko 的品牌色
17
+
18
+ **成功实践**:
19
+ - 使用渐变标题突出品牌名
20
+ - 添加装饰性几何元素(圆、线条、发光点)增强科技感
21
+ - 卡片式展示核心功能
22
+ - 英文 + 中文双语展示增强国际感
23
+ - 暗底亮字是有效的视觉策略
24
+
25
+ **How to apply**: 在后续海报生成中,应优先使用深色背景、渐变品牌色、科技感装饰元素,聚焦核心功能展示,保持简洁有力的视觉层次。
@@ -0,0 +1,9 @@
1
+ ---
2
+ id: "mnm67t9m-x8rekk"
3
+ name: "用户偏好-蓝色"
4
+ type: "user"
5
+ project: "null"
6
+ tags: [偏好, 颜色]
7
+ created: "2026-04-05"
8
+ ---
9
+ 用户最喜欢的颜色是蓝色。下次设计海报或相关内容时可以优先使用蓝色系配色。
@@ -0,0 +1,11 @@
1
+ ---
2
+ id: "mnn5mmqh-w6aktx"
3
+ name: "用户偏好"
4
+ type: "user"
5
+ project: "null"
6
+ tags: [偏好, 兴趣爱好]
7
+ created: "2026-04-06"
8
+ ---
9
+ 用户喜好:
10
+ - 颜色:蓝色
11
+ - 食物:牛肉
@@ -0,0 +1,22 @@
1
+ ---
2
+ id: "mnnbfhhn-dk1bd1"
3
+ name: "何建成"
4
+ type: "user"
5
+ project: "null"
6
+ tags: []
7
+ created: "2026-04-06"
8
+ ---
9
+ 用户姓名:何建成
10
+
11
+ 项目:Foliko - 简约的插件化 Agent 框架
12
+ 工作目录:D:\Code\vb-agent
13
+
14
+ 已发布插件:poster-plugin
15
+
16
+ 创建的海报:
17
+ - foliko-poster.png (1080x1080)
18
+ - foliko-twitter-cover.png (1500x500)
19
+ - foliko-instagram-story.png (1080x1920)
20
+ - foliko-japanese-minimal.png (1080x1350)
21
+ - zen-card-japanese.png (800x1100)
22
+ - foliko-final-poster.png
@@ -7,7 +7,7 @@ module.exports = function (Plugin) {
7
7
  constructor(config = {}) {
8
8
  super();
9
9
  this.name = 'marknative';
10
- this.version = '1.0.0';
10
+ this.version = '1.0.1';
11
11
  this.description = 'Markdown 转图片插件 - 将 Markdown 转换为 PNG/SVG';
12
12
  this.priority = 10;
13
13
  this.marknative = null;
@@ -18,12 +18,7 @@ module.exports = function (Plugin) {
18
18
  if (this.checked) return;
19
19
  this.checked = true;
20
20
 
21
- try {
22
- this.marknative = require('marknative');
23
- } catch (error) {
24
- this.marknative = null;
25
- console.error('MarkNative 加载失败:', error.message);
26
- }
21
+ this.marknative = await import('marknative');
27
22
  }
28
23
 
29
24
  tools = {
@@ -0,0 +1,304 @@
1
+ # Poster Plugin - 海报制作插件
2
+
3
+ 基于 Paper.js 的海报/Banner 设计插件,支持**组件化**海报生成。
4
+
5
+ ## 功能特性
6
+
7
+ - **预设尺寸**:20+ 常用尺寸(海报、Banner、社交媒体)
8
+ - **基础元素**:矩形、圆形、线条、多边形、图片、文字、艺术文字、图片框
9
+ - **布局组件**:分栏布局、网格布局
10
+ - **装饰组件**:星形、箭头、环形进度条、标签、图表、水印、表格
11
+ - **高级组件**:卡片、徽章、CTA按钮、特性展示、特性网格、分隔线、头像、进度条、评分、引用、统计卡、标签云、步骤条、时间线、列表项、通知
12
+ - **组件化生成**:通过 JSON 配置一次性生成完整海报
13
+ - **模板系统**:modern、business、social、simple、tech、gradient 六种预设模板
14
+
15
+ ## 工具列表(共 35 个组件)
16
+
17
+ ### 画布管理
18
+ | 工具 | 描述 |
19
+ |------|------|
20
+ | `list_poster_presets` | 列出所有预设尺寸 |
21
+ | `create_poster_canvas` | 创建新画布 |
22
+ | `get_poster_canvas_info` | 获取画布信息 |
23
+ | `clear_poster_canvas` | 清除画布 |
24
+ | `export_poster_canvas` | 导出为 PNG 文件 |
25
+ | `export_poster_svg` | 导出为 SVG 矢量图 |
26
+ | `export_poster_base64` | 导出为 Base64 |
27
+
28
+ ### 基础元素 (10)
29
+ | 工具 | 描述 |
30
+ |------|------|
31
+ | `add_poster_background` | 添加纯色/渐变背景 |
32
+ | `add_poster_rectangle` | 添加矩形 |
33
+ | `add_poster_circle` | 添加圆形/椭圆 |
34
+ | `add_poster_line` | 添加线条 |
35
+ | `add_poster_polygon` | 添加多边形 |
36
+ | `add_poster_text` | 添加文字 |
37
+ | `add_poster_art_text` | 添加艺术文字(渐变/描边) |
38
+ | `add_poster_image` | 添加图片 |
39
+ | `add_poster_svg` | 添加 SVG 矢量图 |
40
+ | `add_poster_image_frame` | 添加图片框(带装饰边框) |
41
+
42
+ ### 布局组件 (2)
43
+ | 工具 | 描述 |
44
+ |------|------|
45
+ | `add_poster_columns` | 分栏布局(左右分栏、多栏) |
46
+ | `add_poster_grid` | 网格布局(任意行列) |
47
+
48
+ ### 装饰组件 (7)
49
+ | 工具 | 描述 |
50
+ |------|------|
51
+ | `add_poster_star` | 星形/多角形装饰 |
52
+ | `add_poster_arrow` | 箭头指示 |
53
+ | `add_poster_progress_circle` | 环形进度条 |
54
+ | `add_poster_chip` | 小型标签 |
55
+ | `add_poster_chart` | 图表(柱状图、饼图) |
56
+ | `add_poster_watermark` | 水印文字 |
57
+ | `add_poster_table` | 数据表格 |
58
+
59
+ ### 高级组件 (16)
60
+ | 工具 | 描述 |
61
+ |------|------|
62
+ | `add_poster_card` | 卡片组件 |
63
+ | `add_poster_badge` | 徽章/标签 |
64
+ | `add_poster_cta` | CTA 行动号召按钮 |
65
+ | `add_poster_feature` | 特性展示块 |
66
+ | `add_poster_feature_grid` | 特性网格布局 |
67
+ | `add_poster_divider` | 分隔线 |
68
+ | `add_poster_avatar` | 用户头像 |
69
+ | `add_poster_progress` | 线性进度条 |
70
+ | `add_poster_rating` | 星级评分 |
71
+ | `add_poster_quote` | 引用块 |
72
+ | `add_poster_stat_card` | 统计卡片 |
73
+ | `add_poster_tag_cloud` | 标签云 |
74
+ | `add_poster_stepper` | 步骤指示器 |
75
+ | `add_poster_timeline` | 时间线 |
76
+ | `add_poster_list_item` | 列表项 |
77
+ | `add_poster_notification` | 通知提示 |
78
+
79
+ ### 组件化生成 & 模板
80
+ | 工具 | 描述 |
81
+ |------|------|
82
+ | `compose_poster` | 使用组件配置生成海报 |
83
+ | `list_poster_components` | 列出可用组件类型 |
84
+ | `generate_poster` | 一键生成海报(6种模板) |
85
+ | `list_poster_templates` | 列出可用模板 |
86
+
87
+ ## 预设尺寸
88
+
89
+ | Key | 尺寸 | 名称 |
90
+ |-----|------|------|
91
+ | `poster_a4` | 2480×3508 | A4海报 (300dpi) |
92
+ | `poster_square` | 2000×2000 | 方形海报 |
93
+ | `poster_16_9` | 1920×1080 | 16:9海报 |
94
+ | `poster_9_16` | 1080×1920 | 9:16竖版海报 |
95
+ | `banner_1920x500` | 1920×500 | 网站Banner |
96
+ | `banner_twitter` | 1500×500 | Twitter封面 |
97
+ | `social_instagram` | 1080×1080 | Instagram正方形 |
98
+ | `social_story` | 1080×1920 | Instagram Story |
99
+ | `social_facebook` | 1200×630 | Facebook封面 |
100
+ | `social_linkedin` | 1200×627 | LinkedIn封面 |
101
+ | `social_youtube` | 2560×1440 | YouTube封面 |
102
+
103
+ ## 使用示例
104
+
105
+ ### 1. 组件化生成(推荐)
106
+
107
+ ```javascript
108
+ compose_poster({
109
+ components: [
110
+ // 背景
111
+ { type: 'background', color: '#1a1a2e' },
112
+
113
+ // 装饰圆形
114
+ { type: 'circle', cx: 1600, cy: 200, rx: 200, fill: '#00d9ff', opacity: 0.3 },
115
+
116
+ // 星形装饰
117
+ { type: 'star', cx: 200, cy: 200, points: 5, outerRadius: 60, fill: '#fbbf24' },
118
+
119
+ // 主标题
120
+ { type: 'artText', text: 'VB-Agent', x: 960, y: 400, fontSize: 120,
121
+ gradient: { colors: ['#00d9ff', '#00ff88'] } },
122
+
123
+ // 环形进度条
124
+ { type: 'progressCircle', cx: 400, cy: 600, radius: 80, value: 85,
125
+ strokeWidth: 15, fillColor: '#3b82f6', showLabel: true },
126
+ { type: 'progressCircle', cx: 700, cy: 600, radius: 80, value: 92,
127
+ strokeWidth: 15, fillColor: '#10b981', showLabel: true },
128
+
129
+ // 图表
130
+ { type: 'chart', type: 'bar', x: 1100, y: 450, width: 400, height: 250,
131
+ data: [
132
+ { label: '一月', value: 120, color: '#3b82f6' },
133
+ { label: '二月', value: 90, color: '#10b981' },
134
+ { label: '三月', value: 150, color: '#f59e0b' }
135
+ ],
136
+ showLabels: true, showValues: true },
137
+
138
+ // 数据表格
139
+ { type: 'table', x: 100, y: 700, width: 800,
140
+ columns: [
141
+ { title: '功能', width: 300, align: 'left' },
142
+ { title: '状态', width: 200 },
143
+ { title: '价格', width: 150 }
144
+ ],
145
+ rows: [
146
+ ['智能对话', '可用', '免费'],
147
+ ['图片生成', '可用', '$29'],
148
+ ['代码助手', 'Beta', '免费']
149
+ ],
150
+ headerBg: '#1e293b', headerColor: '#ffffff', striped: true },
151
+
152
+ // 标签
153
+ { type: 'chip', x: 400, y: 850, text: 'AI驱动', background: '#3b82f6', color: '#ffffff' },
154
+ { type: 'chip', x: 550, y: 850, text: '开源', background: '#10b981', color: '#ffffff' },
155
+
156
+ // 水印
157
+ { type: 'watermark', text: 'VB-Agent', cx: 960, cy: 1000, fontSize: 200,
158
+ color: 'rgba(255,255,255,0.03)', rotation: -15 },
159
+
160
+ // CTA 按钮
161
+ { type: 'cta', x: 960, y: 950, text: '立即体验 →',
162
+ background: '#00d9ff', color: '#0a0a0f', fontSize: 24, radius: 30 }
163
+ ]
164
+ })
165
+ export_poster_canvas({ filename: 'my-poster', outputDir: '.' })
166
+ ```
167
+
168
+ ### 2. 基础使用
169
+
170
+ ```javascript
171
+ // 创建画布
172
+ create_poster_canvas({ preset: 'poster_square', background: '#1a1a2e' })
173
+
174
+ // 添加元素
175
+ add_poster_circle({ cx: 500, cy: 500, rx: 100, fill: '#00d9ff' })
176
+ add_poster_text({ text: 'Hello Foliko', x: 500, y: 600, fontSize: 48, color: '#ffffff', align: 'center' })
177
+
178
+ // 导出
179
+ export_poster_canvas({ filename: 'my-poster' })
180
+ ```
181
+
182
+ ## 新增组件详解
183
+
184
+ ### 星形 (star)
185
+ ```javascript
186
+ add_poster_star({
187
+ cx: 200, cy: 200, // 中心坐标
188
+ points: 5, // 星形点数
189
+ outerRadius: 60, // 外半径
190
+ fill: '#fbbf24', // 填充颜色
191
+ rotation: 0 // 旋转角度
192
+ })
193
+ ```
194
+
195
+ ### 环形进度条 (progressCircle)
196
+ ```javascript
197
+ add_poster_progress_circle({
198
+ cx: 200, cy: 200, // 圆心坐标
199
+ radius: 80, // 圆环半径
200
+ value: 75, // 进度值 0-100
201
+ strokeWidth: 15, // 环宽度
202
+ trackColor: '#e5e7eb', // 轨道颜色
203
+ fillColor: '#3b82f6', // 进度颜色
204
+ backgroundColor: '#ffffff', // 背景填充
205
+ showLabel: true // 显示百分比
206
+ })
207
+ ```
208
+
209
+ ### 图表 (chart)
210
+ ```javascript
211
+ // 柱状图
212
+ add_poster_chart({
213
+ type: 'bar', // bar 或 pie
214
+ x: 100, y: 300,
215
+ width: 500, height: 250,
216
+ data: [
217
+ { label: '一月', value: 120, color: '#3b82f6' },
218
+ { label: '二月', value: 90, color: '#10b981' }
219
+ ],
220
+ showLabels: true,
221
+ showValues: true
222
+ })
223
+
224
+ // 饼图
225
+ add_poster_chart({
226
+ type: 'pie',
227
+ x: 700, y: 300,
228
+ width: 250, height: 250,
229
+ data: [
230
+ { label: 'A', value: 45, color: '#3b82f6' },
231
+ { label: 'B', value: 35, color: '#10b981' },
232
+ { label: 'C', value: 20, color: '#f59e0b' }
233
+ ],
234
+ showLabels: true
235
+ })
236
+ ```
237
+
238
+ ### 表格 (table)
239
+ ```javascript
240
+ add_poster_table({
241
+ x: 100, y: 400,
242
+ width: 800,
243
+ columns: [
244
+ { title: '功能', width: 300, align: 'left' },
245
+ { title: '状态', width: 200 }
246
+ ],
247
+ rows: [
248
+ ['智能对话', '可用'],
249
+ ['代码助手', 'Beta']
250
+ ],
251
+ headerBg: '#1e293b',
252
+ headerColor: '#ffffff',
253
+ striped: true
254
+ })
255
+ ```
256
+
257
+ ### 标签 (chip)
258
+ ```javascript
259
+ add_poster_chip({
260
+ x: 200, y: 300,
261
+ text: 'NEW', // 标签文字
262
+ background: '#ef4444', // 背景色
263
+ color: '#ffffff', // 文字颜色
264
+ fontSize: 14,
265
+ radius: 16, // 圆角
266
+ icon: '⭐' // 前置图标(可选)
267
+ })
268
+ ```
269
+
270
+ ## 项目结构
271
+
272
+ ```
273
+ poster-plugin/
274
+ ├── index.js # 插件入口
275
+ ├── package.json # 包配置
276
+ ├── README.md # 文档
277
+ ├── src/
278
+ │ ├── index.js # 主模块
279
+ │ ├── canvas.js # 画布管理器
280
+ │ ├── presets.js # 预设尺寸
281
+ │ ├── fonts.js # 字体管理
282
+ │ ├── composer.js # 组件化生成器
283
+ │ ├── elements/ # 基础元素
284
+ │ ├── components/ # 高级组件
285
+ │ └── templates/ # 模板
286
+ └── fonts/ # 字体文件
287
+ ```
288
+
289
+ ## 更新日志
290
+
291
+ ### v1.2.0
292
+ - 新增布局组件:columns(分栏)、grid(网格)
293
+ - 新增装饰组件:star(星形)、arrow(箭头)、progressCircle(环形进度条)
294
+ - 新增 chip(标签)、chart(图表)、watermark(水印)、table(表格)
295
+ - 新增 imageFrame(图片框)
296
+ - 组件总数达到 **35 个**
297
+ - 模板新增 tech(科技)、gradient(渐变)
298
+ - 修复环形进度条绘制逻辑
299
+
300
+ ### v1.1.0
301
+ - 重构为模块化架构
302
+ - 新增组件化海报生成(compose_poster)
303
+ - 新增高级组件:card, badge, cta, feature, featureGrid, divider
304
+ - 新增组件:avatar, progress, rating, quote, statCard, tagCloud, stepper, timeline, listItem, notification
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Poster Plugin - 海报制作插件
3
+ *
4
+ * 模块化架构,支持组件化海报生成
5
+ *
6
+ * 使用方法:
7
+ * 1. 基础元素:add_poster_rectangle, add_poster_circle, add_poster_text 等
8
+ * 2. 高级组件:add_poster_card, add_poster_badge, add_poster_cta 等
9
+ * 3. 组件化生成:compose_poster - 通过配置 JSON 一次性生成海报
10
+ * 4. 模板生成:generate_poster - 一键使用预设模板
11
+ */
12
+
13
+ module.exports = require('./src/index.js')
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "poster-plugin",
3
+ "version": "1.2.0",
4
+ "description": "海报/Banner 设计插件 - 基于 Paper.js 实现,支持 35 个组件",
5
+ "main": "index.js",
6
+ "dependencies": {
7
+ "canvas": "^3.2.0",
8
+ "fontkit": "^2.0.4",
9
+ "jsdom": "^16.2.2",
10
+ "paper": "^0.12.18"
11
+ },
12
+ "overrides": {
13
+ "canvas": "^3.2.0"
14
+ },
15
+ "resolutions": {
16
+ "**/canvas": "^3.2.0"
17
+ },
18
+ "author": "",
19
+ "license": "MIT",
20
+ "keywords": [
21
+ "poster",
22
+ "banner",
23
+ "design",
24
+ "canvas",
25
+ "paper.js",
26
+ "foliko"
27
+ ]
28
+ }
@@ -0,0 +1,161 @@
1
+ /**
2
+ * 画布管理模块
3
+ */
4
+
5
+ const paper = require('paper')
6
+ const PRESETS = require('./presets')
7
+
8
+ /**
9
+ * 画布管理器类
10
+ */
11
+ class CanvasManager {
12
+ constructor() {
13
+ this._canvas = null
14
+ this._project = null
15
+ this._paper = null
16
+ this._width = 0
17
+ this._height = 0
18
+ }
19
+
20
+ /**
21
+ * 创建画布
22
+ */
23
+ create({ preset, width, height, background }) {
24
+ let w, h
25
+
26
+ if (preset) {
27
+ const presetConfig = PRESETS[preset]
28
+ if (!presetConfig) {
29
+ throw new Error(`Unknown preset: ${preset}. Available: ${Object.keys(PRESETS).join(', ')}`)
30
+ }
31
+ w = presetConfig.width
32
+ h = presetConfig.height
33
+ } else if (width && height) {
34
+ w = width
35
+ h = height
36
+ } else {
37
+ throw new Error('Must provide preset or width/height')
38
+ }
39
+
40
+ this._canvas = paper.createCanvas(w, h)
41
+ this._project = new paper.Project(this._canvas)
42
+ // 确保活动层存在
43
+ if (!paper.project || !paper.project.activeLayer) {
44
+ paper.setup(this._canvas)
45
+ }
46
+ this._paper = paper
47
+ this._width = w
48
+ this._height = h
49
+
50
+ // 添加背景
51
+ if (background) {
52
+ const bg = new paper.Path.Rectangle({
53
+ point: [0, 0],
54
+ size: [w, h],
55
+ fillColor: background,
56
+ })
57
+ bg.sendToBack()
58
+ }
59
+
60
+ return {
61
+ width: w,
62
+ height: h,
63
+ preset: preset || 'custom',
64
+ background: background || null,
65
+ }
66
+ }
67
+
68
+ /**
69
+ * 获取画布
70
+ */
71
+ getCanvas() {
72
+ return this._canvas
73
+ }
74
+
75
+ /**
76
+ * 获取 Paper.js 项目
77
+ */
78
+ getProject() {
79
+ return this._project
80
+ }
81
+
82
+ /**
83
+ * 获取画布尺寸
84
+ */
85
+ getSize() {
86
+ return { width: this._width, height: this._height }
87
+ }
88
+
89
+ /**
90
+ * 获取中心点
91
+ */
92
+ getCenter() {
93
+ return { x: this._width / 2, y: this._height / 2 }
94
+ }
95
+
96
+ /**
97
+ * 清除画布
98
+ */
99
+ clear() {
100
+ if (this._project) {
101
+ this._project.activeLayer.removeChildren()
102
+ }
103
+ }
104
+
105
+ /**
106
+ * 获取元素数量
107
+ */
108
+ getElementCount() {
109
+ return this._project ? this._project.activeLayer.children.length : 0
110
+ }
111
+
112
+ /**
113
+ * 导出为 Buffer
114
+ */
115
+ toBuffer(format = 'png', quality) {
116
+ if (!this._canvas) {
117
+ throw new Error('No canvas created')
118
+ }
119
+
120
+ this._project.view.update()
121
+ this._project.view.draw()
122
+
123
+ const mimeType = format === 'jpg' ? 'image/jpeg' : 'image/png'
124
+ return this._canvas.toBuffer(mimeType, quality)
125
+ }
126
+
127
+ /**
128
+ * 导出为 Base64
129
+ */
130
+ toBase64(format = 'png', quality) {
131
+ if (!this._canvas) {
132
+ throw new Error('No canvas created')
133
+ }
134
+
135
+ this._project.view.update()
136
+ this._project.view.draw()
137
+
138
+ const mimeType = format === 'jpg' ? 'image/jpeg' : 'image/png'
139
+ return this._canvas.toDataURL(mimeType, quality)
140
+ }
141
+
142
+ /**
143
+ * 检查画布是否已创建
144
+ */
145
+ isCreated() {
146
+ return this._canvas !== null
147
+ }
148
+
149
+ /**
150
+ * 重置画布
151
+ */
152
+ reset() {
153
+ this._canvas = null
154
+ this._project = null
155
+ this._paper = null
156
+ this._width = 0
157
+ this._height = 0
158
+ }
159
+ }
160
+
161
+ module.exports = CanvasManager