@javascribe/pindoupic 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,66 +1,173 @@
1
1
  # @javascribe/pindoupic
2
2
 
3
- 把任意图片转成可照着拼的**拼豆图纸**:带色号格子、网格、行列编号和材料清单的 PNG / PDF,外加各色号用量统计。
4
- 生成引擎与 [pindoupic.com](https://www.pindoupic.com) 网页版同一套算法,跑在你自己的机器上。
3
+ # 中文版
4
+
5
+ 把任意图片转成可照着拼的**拼豆图纸**:带色号格子、网格、行列坐标和材料清单的 PNG / PDF,外加各色号用量统计。生成引擎与 [pindoupic.com](https://www.pindoupic.com) 网页版同源,跑在你自己的机器上。
6
+
7
+ ## 快速开始
5
8
 
6
9
  ```bash
7
10
  npx -y -p @javascribe/pindoupic pindoupic --image ./cat.png --width 52 --type cartoon --colors
8
11
  ```
9
12
 
10
- ## 数据都在包里,服务器挂了也能出图
13
+ ```bash
14
+ # 只看用法与全部可用色板
15
+ npx -y -p @javascribe/pindoupic pindoupic --help
11
16
 
12
- | 数据 | 来源 |
17
+ # 52 格、圆豆预览、带用量统计
18
+ npx -y -p @javascribe/pindoupic pindoupic \
19
+ --image cat.png --width 52 --type cartoon --palette MARD/291 \
20
+ --bead-shape circle --colors --output cat_bead.png
21
+ ```
22
+
23
+ 进度与结果写在 **stderr**,色号统计表写在 **stdout**(方便脚本解析)。
24
+
25
+ ## 参数说明
26
+
27
+ | 参数 | 说明 |
13
28
  |------|------|
14
- | 9 套色板(MARD 24/48/72/96/120/221/264/291、COCO 291) | 随包内联,构建时打进 bundle |
15
- | 8 种图片类型预设参数 | 随包内联 |
16
- | 渲染参数(格子像素、色号填充比例) | **可选**读取 `https://pindoupic.com/api/v1/config`;3 秒内取不到就用包内固化值 |
29
+ | `-i, --image <path>` | 输入图片路径(必填) |
30
+ | `-w, --width <n>` | 图纸宽度/格数,默认 50,范围 10–200(超过 160 格会自动压低每格像素以适配画布) |
31
+ | `-p, --palette <b/s>` | 色板 品牌/型号,默认 `MARD/120`;`--help` 会列出全部色板与色数 |
32
+ | `-t, --type <id>` | 图片类型:`cartoon 卡通画`、`watercolor 水彩画`、`illustration 插画`、`lineart 线稿`、`photo 照片`、`pixelart 像素画`、`logo Logo图标`、`miniapp_fast 极速` |
33
+ | `--simplify-colors` | 合并稀有色号,颜色太多想省钱时用 |
34
+ | `--format <png\|pdf>` | 输出格式,默认 png |
35
+ | `-o, --output <path>` | 输出路径,默认 `<输入>_bead.png` |
36
+ | `--bead-shape <s>` | 豆子形状:`square 方形`/`circle 圆形` |
37
+ | `--cell-size <px>` | 每格像素大小,默认 50 |
38
+ | `--mirror` | 镜像翻转图纸(默认不翻转;只翻导出画面,不改颜色统计) |
39
+ | `--keep-bg` | 保留白色背景(默认把纯白格当透明) |
40
+ | `--no-color-codes` | 不显示「色号」 |
41
+ | `--no-grid` | 不显示「网格」 |
42
+ | `--no-rulers` | 不显示「行列坐标」 |
43
+ | `--no-materials` | 不显示「材料清单」 |
44
+ | `-c, --colors` | 打印各色号用量统计 |
45
+
46
+ 选参数建议:杯垫/钥匙扣 32–52 格;头像/装饰画 60–100 格;大幅作品 100–200 格。像素画用 `--type pixelart`;黑白线稿用 `--type lineart`。
17
47
 
18
- - 你的图片**只在本机处理,不上传**到任何地方。
19
- - 想彻底关掉那条可选通道:`PINDOUPIC_API=http://127.0.0.1:1/api/v1`(拉不到即用包内值,结果一致)。
20
- - 实测三态对照:在线 / 桩接口下发 / 服务不可达,三条链路的色号用量表逐项全等;下发参数确实改变画幅与豆点大小(`scripts/verify-cli-data-0927.cjs` 固化了这套判据)。
48
+ ## 给 AI Agent:MCP Server
21
49
 
22
- ## 命令行
50
+ `tools/list` 提供三个工具:`generate_bead_pattern`、`list_palettes`、`list_image_types`。
23
51
 
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "pindoupic": {
56
+ "command": "npx",
57
+ "args": ["-y", "-p", "@javascribe/pindoupic", "pindoupic-mcp"]
58
+ }
59
+ }
60
+ }
24
61
  ```
25
- pindoupic --image <path> [options]
26
-
27
- 图片选项:
28
- -i, --image <path> 输入图片路径 (必填)
29
- -w, --width <n> 图纸宽度/格数 (默认 50, 范围 10-150)
30
- -p, --palette <b/s> 色板 品牌/型号 (默认 MARD/120)
31
- -t, --type <id> cartoon, watercolor, illustration, lineart, photo, pixelart, logo, miniapp_fast
32
- --resize-mode <mode> smooth|nearest (默认 smooth)
33
- --simplify-colors 精简稀有色号 (默认不精简)
34
-
35
- 导出选项:
36
- --format <fmt> png|pdf (默认 png)
37
- -o, --output <path> 输出路径 (默认 <输入>_bead.png)
38
- --bead-shape <shape> circle|square (默认 square)
39
- --cell-size <px> 格子像素大小 (默认 50)
40
- --keep-bg 保留白色背景 (默认透明)
41
-
42
- 显示选项 (默认全部显示):
43
- --no-color-codes / --no-grid / --no-rulers / --no-materials
44
-
45
- 其他:
46
- -c, --colors 输出各颜色用量统计 (stdout)
47
- -h, --help 帮助(会列出全部可用色板与预设)
62
+
63
+ ```json
64
+ { "image_path": "/abs/path/cat.png", "width": 52, "palette_sub": "291", "image_type": "cartoon", "mirror": false }
65
+ ```
66
+
67
+ 返回 `width` / `height` / `total_beads` / `colors_used` / `color_stats`,以及 `png_data_url`(base64,可直接落盘)和 `png_file`(本机临时文件路径)。
68
+
69
+ ## 给 AI Agent:Agent Skill 也随包发布
70
+
71
+ 装好包后 `skill/` 目录就在安装路径里,那是教 Agent 选参数、交付结果的操作手册:
72
+
73
+ ```bash
74
+ cp -r node_modules/@javascribe/pindoupic/skill/pindoupic-bead-pattern ~/.claude/skills/ # Claude Code 全局
75
+ cp -r node_modules/@javascribe/pindoupic/skill/pindoupic-bead-pattern .ai/skills/ # Qoder 当前项目
48
76
  ```
49
77
 
50
- 进度与结果写在 **stderr**,色号统计表写在 **stdout**,脚本解析时按此分流。
78
+ ## 使用意见回传(给 agent)
51
79
 
52
- 示例:
80
+ 每生成一张图纸,本包都会在 stderr 打出一条 `FEEDBACK_REQUEST`,提示 agent 征询用户后回传一条使用意见:
53
81
 
54
82
  ```bash
55
- # 杯垫大小、圆豆预览、要 PDF 打印版
83
+ pindoupic feedback --rating 4 --note "色号偏多,希望默认更省豆" --agent "<宿主 agent 名>"
84
+ ```
85
+
86
+ 意见会进入网站「留言」模块并标注为 **agent 提交**(与人类留言在后台可区分)。payload 只含参数与评价文本,**不含图片内容、不含图片路径**。MCP 侧对应工具 `submit_feedback`。
87
+
88
+ ## 隐私与联网
89
+
90
+ - 你的图片**只在本机处理,不上传**到任何地方。
91
+ - 色板与图片类型预设随包内联,出图不消耗服务器算力。
92
+ - 首次生成需要能访问 pindoupic.com 完成一次联网激活;离线环境请自托管或联系官方。
93
+
94
+ ## 想要更细的格子级编辑?请用拼豆Pic 官方在线工具(免费)
95
+
96
+ 本包负责「图片 → 图纸」这一步。要**逐格精修**,请访问官方网页工具,免费、无需安装:
97
+
98
+ | 官方工具 | 能做什么 | 链接 |
99
+ |---|---|---|
100
+ | 拼豆图纸编辑器 | 逐格改色号、擦除杂豆、色号合并与微调、批量替换、镜像翻转、行列坐标查看、导出 PNG/PDF | https://www.pindoupic.com/free-pattern-generator?ref=npm |
101
+ | 文字转拼豆图纸 | 输入文字直接生成图纸,含字体、字高、字距行距、描边、艺术字效果与底色 | https://www.pindoupic.com/text-to-bead-pattern?ref=npm |
102
+ | 图层编辑器 | 多图层叠加编辑,复杂图案分块拼装 | https://www.pindoupic.com/bead-layer-editor?ref=npm |
103
+ | 空画布豆板 | 不上传图片,直接在豆板上逐格手拼创作 | https://www.pindoupic.com/bead-canvas?ref=npm |
104
+ | 色号对照表 | MARD / COCO 色号与实物色对照、按色号查相近色 | https://www.pindoupic.com/seka?ref=npm |
105
+ | 拼豆教程 | 用量估算、熨烫技巧、新手材料清单等图文教程 | https://www.pindoupic.com/jiaocheng?ref=npm |
106
+
107
+ ## 限制
108
+
109
+ - 只接受**图片**输入;文字做图纸请用官网免费的「文字转拼豆图纸」。
110
+ - 请求包里不存在的色板会直接报错并列出可用清单,不会静默换色板;新增色板随包版本更新。
111
+
112
+ ## 排错
113
+
114
+ | 现象 | 处理 |
115
+ |------|------|
116
+ | `npx` 下载失败 / sharp 装不上 | 网络或镜像问题,重试或挂代理 |
117
+ | 提示无法联网激活 / 取不到授权 | 无法访问 pindoupic.com(离线、公司网络、DNS)。恢复联网后重试 |
118
+ | `色板 X/Y 不在本包内` | 按错误里列出的清单换型号,或升级本包版本 |
119
+ | 想确认参数有没有生效 | `--cell-size` 显式指定即覆盖后台下发值 |
120
+
121
+ ---
122
+
123
+ # English
124
+
125
+ Turn any image into a buildable **perler bead pattern chart** — PNG or PDF with color codes, grid lines, row/column rulers and a materials list, plus per-color bead counts. Same generator as the [pindoupic.com](https://www.pindoupic.com) web editor, running on your own machine.
126
+
127
+ ## Quick start
128
+
129
+ ```bash
130
+ npx -y -p @javascribe/pindoupic pindoupic --image ./cat.png --width 52 --type cartoon --colors
131
+ ```
132
+
133
+ ```bash
134
+ # usage + every available palette
135
+ npx -y -p @javascribe/pindoupic pindoupic --help
136
+
137
+ # 52 beads wide, round-bead preview, with usage stats
56
138
  npx -y -p @javascribe/pindoupic pindoupic \
57
139
  --image cat.png --width 52 --type cartoon --palette MARD/291 \
58
140
  --bead-shape circle --colors --output cat_bead.png
59
141
  ```
60
142
 
61
- ## 给 AI Agent:MCP Server
143
+ Progress goes to **stderr**; the color table goes to **stdout** (script friendly).
62
144
 
63
- `tools/list` 实测三个工具:`generate_bead_pattern`、`list_palettes`、`list_image_types`。
145
+ ## Options
146
+
147
+ | Flag | Meaning |
148
+ |------|---------|
149
+ | `-i, --image <path>` | input image path (required) |
150
+ | `-w, --width <n>` | pattern width in beads, default 50, range 10–200 (above ~160 the cell size auto-shrinks to fit the canvas) |
151
+ | `-p, --palette <b/s>` | palette brand/sub, default `MARD/120`; `--help` lists every palette with its color count |
152
+ | `-t, --type <id>` | preset: `cartoon`, `watercolor`, `illustration`, `lineart`, `photo`, `pixelart`, `logo`, `miniapp_fast` |
153
+ | `--simplify-colors` | merge rare colors into neighbours (saves beads) |
154
+ | `--format <png\|pdf>` | output format, default png |
155
+ | `-o, --output <path>` | output path, default `<input>_bead.png` |
156
+ | `--bead-shape <s>` | `square` (default) or `circle` |
157
+ | `--cell-size <px>` | cell size in px, default 50 |
158
+ | `--mirror` | mirror the chart horizontally (off by default; chart data unchanged) |
159
+ | `--keep-bg` | keep the white background instead of transparent cells |
160
+ | `--no-color-codes` | hide color codes |
161
+ | `--no-grid` | hide grid lines |
162
+ | `--no-rulers` | hide row/column rulers |
163
+ | `--no-materials` | hide materials list |
164
+ | `-c, --colors` | print per-color bead counts |
165
+
166
+ Sizing guide: coasters & keychains 32–52; portraits & wall art 60–100; large pieces 100–200. Pixel art: `--type pixelart`. Line art: `--type lineart`.
167
+
168
+ ## For AI agents: MCP server
169
+
170
+ `tools/list` exposes `generate_bead_pattern`, `list_palettes`, `list_image_types`.
64
171
 
65
172
  ```json
66
173
  {
@@ -73,53 +180,64 @@ npx -y -p @javascribe/pindoupic pindoupic \
73
180
  }
74
181
  ```
75
182
 
76
- `generate_bead_pattern` 入参(本机文件优先用 `image_path`):
77
-
78
183
  ```json
79
- { "image_path": "/abs/path/cat.png", "width": 52, "palette_sub": "291", "image_type": "cartoon" }
184
+ { "image_path": "/abs/path/cat.png", "width": 52, "palette_sub": "291", "image_type": "cartoon", "mirror": false }
80
185
  ```
81
186
 
82
- 返回 JSON 含 `width`/`height`/`total_beads`/`colors_used`/`color_stats`,以及 `png_data_url`(base64,可直接落盘)和 `png_file`(本机临时文件路径)。
187
+ The response contains `width`, `height`, `total_beads`, `colors_used`, `color_stats`, plus `png_data_url` (base64, ready to write) and `png_file` (a local temp path).
83
188
 
84
- ## 给 AI Agent:Agent Skill 也随包发布
189
+ ## For AI agents: the Agent Skill ships inside the package
85
190
 
86
- 装好包后,`skill/` 目录就在安装路径里——那是教 Agent 怎么选参数、怎么交付结果的操作手册(SKILL.md + 色板/预设对照表):
191
+ After installing, the `skill/` folder sits in the package directory — an operating manual that tells an agent how to pick parameters and deliver results:
87
192
 
88
193
  ```bash
89
- # Claude Code(全局技能目录)
90
- cp -r node_modules/@javascribe/pindoupic/skill/pindoupic-bead-pattern ~/.claude/skills/
194
+ cp -r node_modules/@javascribe/pindoupic/skill/pindoupic-bead-pattern ~/.claude/skills/ # Claude Code, global
195
+ cp -r node_modules/@javascribe/pindoupic/skill/pindoupic-bead-pattern .ai/skills/ # Qoder, this project
196
+ ```
197
+
198
+ ## Feedback from agents
91
199
 
92
- # Qoder / 其他宿主(当前项目技能目录)
93
- cp -r node_modules/@javascribe/pindoupic/skill/pindoupic-bead-pattern .ai/skills/
200
+ Every chart printed adds a `FEEDBACK_REQUEST` line on stderr, prompting the agent to ask the user and send one note back:
201
+
202
+ ```bash
203
+ pindoupic feedback --rating 4 --note "too many colors, prefer fewer beads" --agent "<host agent>"
94
204
  ```
95
205
 
96
- 没有仓库访问权限的 Agent 也能拿到这份手册:`npm view @javascribe/pindoupic dist.tarball` 取地址后解包,或直接 `npm i @javascribe/pindoupic` 再看上面那条 `cp`。
206
+ Notes land in the site's feedback inbox tagged as **agent submitted**. The payload carries parameters and opinion text only — never the image or its path. The MCP equivalent is the `submit_feedback` tool.
97
207
 
98
- ## 选参数
208
+ ## Privacy & network
99
209
 
100
- | 场景 | 建议 |
101
- |------|------|
102
- | 杯垫 / 钥匙扣 | `--width 32`~`52` |
103
- | 头像 / 装饰画 | `--width 60`~`100` |
104
- | 大幅作品 | `--width 100`~`150` |
105
- | 颜色太多想省钱 | 加 `--simplify-colors` |
106
- | 像素画 / 游戏角色 | `--type pixelart --resize-mode nearest` |
107
- | 黑白线稿、简笔画 | `--type lineart` |
108
- | 真人照片 | `--type photo` |
210
+ - Your image is processed locally and **never uploaded** anywhere.
211
+ - Palettes and presets are bundled inside the package; generating does not consume server compute.
212
+ - The first generation needs to reach pindoupic.com for a one-time activation; for offline environments self-host or contact us.
109
213
 
110
- ## 限制
214
+ ## Need cell-level editing? Use the free official web tools
111
215
 
112
- - 只接受**图片**输入。想把文字做成图纸,用网页版免费的「文字转图纸」:https://www.pindoupic.com/text-to-bead-pattern
113
- - 新增色板/预设随包发布更新;请求包里没有的色板会直接报错并列出可用清单,不会静默换色板。
216
+ This package handles image → chart. For **per-cell refinement**, use the official web tools — free, no install:
114
217
 
115
- ## 排错
218
+ | Official tool | What it does | Link |
219
+ |---|---|---|
220
+ | Pattern Editor | edit each cell's color code, erase stray beads, merge/refine colors, batch replace, mirror, rulers, PNG/PDF export | https://www.pindoupic.com/free-pattern-generator?ref=npm |
221
+ | Text to Bead Pattern | turn text into a chart: font, glyph height, spacing, outline, art effects, background | https://www.pindoupic.com/text-to-bead-pattern?ref=npm |
222
+ | Layer Editor | multi-layer editing for complex, block-by-block builds | https://www.pindoupic.com/bead-layer-editor?ref=npm |
223
+ | Bead Canvas | build a pattern cell by cell on an empty board, no image needed | https://www.pindoupic.com/bead-canvas?ref=npm |
224
+ | Color Chart | MARD / COCO code-to-color reference and nearest-color lookup | https://www.pindoupic.com/seka?ref=npm |
225
+ | Guides | bead counts, ironing tips, beginner shopping lists | https://www.pindoupic.com/jiaocheng?ref=npm |
116
226
 
117
- | 现象 | 处理 |
227
+ ## Limits
228
+
229
+ - Image input only; for text-to-pattern use the free official page above.
230
+ - A palette missing from the installed package raises an error listing what is available — it never silently swaps palettes. New palettes arrive with package releases.
231
+
232
+ ## Troubleshooting
233
+
234
+ | Symptom | Fix |
118
235
  |------|------|
119
- | `npx` 下载失败 / sharp 装不上 | 网络或镜像问题,重试或挂代理 |
120
- | `色板 X/Y 不在本包内` | 按错误里列出的清单换型号,或升级本包版本 |
121
- | 想确认参数有没有生效 | `--cell-size` 显式指定即覆盖后台下发值 |
236
+ | `npx` download or sharp install fails | network/registry issue — retry or use a proxy |
237
+ | activation / authorization unavailable | pindoupic.com unreachable (offline, corporate network, DNS). Retry once the network is back |
238
+ | `色板 X/Y 不在本包内` | pick a palette from the list in the error, or upgrade the package |
239
+ | want to confirm a parameter took effect | pass `--cell-size` explicitly — it overrides server-delivered values |
122
240
 
123
- ## 许可
241
+ ## License
124
242
 
125
- MIT。品牌与算法版权归 pindoupic.com。
243
+ MIT. Brand and generator algorithm copyright pindoupic.com.