cortico-world-imggen 0.3.4 → 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
@@ -8,6 +8,22 @@
8
8
  > 思路移植自 [dsh-image-studio](https://github.com/aa1355721445-lgtm/dsh-image-studio)(本地参考库 + 关键词 + 发图策略),
9
9
  > 但按 Cortico 的 World 契约重写:没有 DSH 的宿主 API,所以调度、发图、管理页面都是自己实现的。
10
10
 
11
+ ## 0.4.0 更新
12
+
13
+ - **双后端**:云端接口 / 本机 ComfyUI(8188)。工作室页面顶部一键切换,桌宠也能用 `imggen_comfy set backend=local|cloud` 自己切。
14
+ - **人物 LoRA + 工作流自由搭配**:模板里没有角色节点时自动注入;同一个画风/姿势工作流可以配任意角色 LoRA。
15
+ - **工作流模板下拉**:扫 `H:/AI/ComfyUI/workflows/*.json`,工作室页面和设置页都能选;配套 `导出API模板.cmd` 一键把 ComfyUI 界面工作流转成 API 模板。
16
+ - **后台出图**:本地出图先把工具交回去,画完推一条内部事件给 Coo(它会自己知道画好了),不卡对话。
17
+ - **本地纯提示词模式**(默认开):走本地时 prompt 原样提交,不套中文分节、不用参考图;桌宠自己写完整英文 tag。
18
+ - **卡住自动重提**:显存抖动卡在 Model Initializing 时自动中断重跑。
19
+ - **上下文瘦身**:ENV_PROMPT 从 2836 字符压到 1720(-39%),工具参数说明同步收紧。
20
+ - 修:本地模式下不再要求 API Key;`imggen_comfy` 支持按文件名切换工作流。
21
+
22
+ ## 工具一览(0.4.0)
23
+
24
+ `imggen_draw` / `imggen_send` / `imggen_list` / `imggen_library` / `imggen_jobs` / `imggen_comfy`
25
+
26
+
11
27
  ## 它做了什么
12
28
 
13
29
  - **四个工具**
@@ -221,6 +237,11 @@ ONEBOT_TOKEN=<协议端 token> IMGGEN_KEY=<key> IMGGEN_REFS="D:\a.png;D:\b.png"
221
237
 
222
238
  ## 更新日志
223
239
 
240
+ ### 0.3.5
241
+
242
+ - 工作室尺寸按钮标出**价格倍率**(相对 1024×1024):火山这类接口按输出 token 计费,token ≈ 像素数 ÷ 256,所以倍率就等于相对价格。实测 1024² = 4,096 tok、2560×1440 = 14,400 tok(3.5×)。
243
+ - 尺寸预设新增「小横屏 1280×720」(0.88×,比方图还便宜)。
244
+
224
245
  ### 0.3.4
225
246
 
226
247
  - 工作室生成页体验:
package/describe.json CHANGED
@@ -2,81 +2,81 @@
2
2
  "tools": [
3
3
  {
4
4
  "name": "imggen_draw",
5
- "description": "画一张图存到本地并直接发到 QQ。prompt 只写画面本身,神态/动作/镜头/光线用下面的关键词,别在 prompt 里重复。人物/服饰/场景/道具都填参考库里的名字;to 抄 QQ 消息 meta 里的 conv。回执有路径、尺寸、关键词、参考图和发送结果,「生成失败」开头不算成功;一张几十秒,等回执。",
5
+ "description": "画一张图存本地并发 QQ。prompt 只写画面;神态/动作/镜头/光线用关键词。人物/服饰/场景/道具填库里的名字;to 抄消息 meta 里的 conv。回执有路径、尺寸、参考图和发送结果;「生成失败」开头不算成功。本地出图需等几十秒到两分钟。",
6
6
  "parameters": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
10
  "prompt": {
11
11
  "type": "string",
12
- "description": "画面:谁在做什么、在哪、什么风格。一到三句。"
12
+ "description": "画面:谁在做什么、在哪、什么风格。一到两句;本地模式写英文 tag。"
13
13
  },
14
14
  "characters": {
15
15
  "type": "array",
16
16
  "items": {
17
17
  "type": "string"
18
18
  },
19
- "description": "出镜人物(库里的名字,可多个),保证长相一致。"
19
+ "description": "人物名(库里的,可多个)"
20
20
  },
21
21
  "outfits": {
22
22
  "type": "array",
23
23
  "items": {
24
24
  "type": "string"
25
25
  },
26
- "description": "服饰(库里的名字),不填自动搭配。"
26
+ "description": "服饰名,不填自动搭配"
27
27
  },
28
28
  "scene": {
29
29
  "type": "string",
30
- "description": "场景(库里的名字)。"
30
+ "description": "场景名"
31
31
  },
32
32
  "props": {
33
33
  "type": "array",
34
34
  "items": {
35
35
  "type": "string"
36
36
  },
37
- "description": "道具(库里的名字)。"
37
+ "description": "道具名"
38
38
  },
39
39
  "situation": {
40
40
  "type": "string",
41
- "description": "情境(词表里的名字)。"
41
+ "description": "情境关键词"
42
42
  },
43
43
  "expression": {
44
44
  "type": "string",
45
- "description": "神态(词表里的名字)。"
45
+ "description": "神态关键词"
46
46
  },
47
47
  "pose": {
48
48
  "type": "string",
49
- "description": "动作(词表里的名字)。"
49
+ "description": "动作关键词"
50
50
  },
51
51
  "shot": {
52
52
  "type": "string",
53
- "description": "镜头(词表里的名字)。"
53
+ "description": "镜头关键词"
54
54
  },
55
55
  "light": {
56
56
  "type": "string",
57
- "description": "光线(词表里的名字),不填用情境默认。"
57
+ "description": "光线,不填用情境默认"
58
58
  },
59
59
  "size": {
60
60
  "type": "string",
61
- "description": "覆盖默认尺寸,如 1024x1024。"
61
+ "description": "尺寸,如 1024x1024"
62
62
  },
63
63
  "count": {
64
64
  "type": "integer",
65
65
  "minimum": 1,
66
66
  "maximum": 4,
67
- "description": "张数,默认 1;多张更慢更贵。"
67
+ "description": "张数,默认 1"
68
68
  },
69
69
  "to": {
70
70
  "type": "string",
71
- "description": "group:<群号> 或 private:<QQ号>;不填用默认目标。"
71
+ "description": "group:<群号> / private:<QQ号>"
72
72
  },
73
73
  "caption": {
74
74
  "type": "string",
75
- "description": "跟图一起发的一句话。"
75
+ "description": "跟图一起说的话"
76
76
  },
77
77
  "send": {
78
78
  "type": "boolean",
79
- "description": "false = 只生成不发。"
79
+ "description": "false = 只存不发"
80
80
  }
81
81
  },
82
82
  "required": [
@@ -93,22 +93,22 @@
93
93
  },
94
94
  {
95
95
  "name": "imggen_send",
96
- "description": "把之前生成过的一张图再发一次(不重新生成,不花钱)。file 填 imggen_list 给出的文件名,不填就发最新的一张。对方说「再发一次」「发刚才那张」时用它,不要重新 imggen_draw。",
96
+ "description": "把生成过的图再发一次(不重新生成、不花钱)。file 填 imggen_list 给的文件名,不填发最新一张。对方说「再发一次」时用它,别重新画。",
97
97
  "parameters": {
98
98
  "type": "object",
99
99
  "additionalProperties": false,
100
100
  "properties": {
101
101
  "file": {
102
102
  "type": "string",
103
- "description": "文件名或完整路径(必须在本扩展的图片目录内)。不填 = 最新一张。"
103
+ "description": "文件名;不填=最新一张"
104
104
  },
105
105
  "to": {
106
106
  "type": "string",
107
- "description": "发送目标:group:<群号> 或 private:<QQ号>。不填用默认目标。"
107
+ "description": "group:<群号> / private:<QQ号>"
108
108
  },
109
109
  "caption": {
110
110
  "type": "string",
111
- "description": "可选,跟图一起发出的一句话。"
111
+ "description": "跟图一起说的话"
112
112
  }
113
113
  },
114
114
  "required": []
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "imggen_list",
126
- "description": "列出本地已生成的图片(文件名、大小、时间)和保存目录。想知道有哪些图、或要给 imggen_send 挑文件名时用。",
126
+ "description": "列出已生成的图(文件名/大小/时间)和保存目录。给 imggen_send 挑文件名时用。",
127
127
  "parameters": {
128
128
  "type": "object",
129
129
  "additionalProperties": false,
@@ -132,7 +132,7 @@
132
132
  "type": "integer",
133
133
  "minimum": 1,
134
134
  "maximum": 50,
135
- "description": "最多列几张,默认 10。"
135
+ "description": "最多几张,默认 10"
136
136
  }
137
137
  },
138
138
  "required": []
@@ -147,7 +147,7 @@
147
147
  },
148
148
  {
149
149
  "name": "imggen_library",
150
- "description": "本地参考库(人物/服饰/场景/道具)。list 看清单,get 看某条设定与参考图,add 存新条目(file 填图片路径或 http 地址),update 改字段,remove 挪进回收站。出图前不确定名字就 list,别猜;对方说「记住这个角色」先拿图片路径再 add。",
150
+ "description": "本地参考库(人物/服饰/场景/道具):list 看清单,get 看某条设定与参考图,add 存新条目(file 填路径或 http 地址),update 改字段,remove 挪回收站。出图前不确定名字就 list,别猜。",
151
151
  "parameters": {
152
152
  "type": "object",
153
153
  "additionalProperties": false,
@@ -175,48 +175,48 @@
175
175
  },
176
176
  "name": {
177
177
  "type": "string",
178
- "description": "条目名(get/update/remove 用;add 时是新条目名)。"
178
+ "description": "条目名"
179
179
  },
180
180
  "description": {
181
181
  "type": "string",
182
- "description": "add/update:外观描述,只写长相或设计,会进提示词。"
182
+ "description": "外观,只写长相/设计"
183
183
  },
184
184
  "aliases": {
185
185
  "type": "array",
186
186
  "items": {
187
187
  "type": "string"
188
188
  },
189
- "description": "add/update:别名。"
189
+ "description": "别名"
190
190
  },
191
191
  "tags": {
192
192
  "type": "array",
193
193
  "items": {
194
194
  "type": "string"
195
195
  },
196
- "description": "add/update:标签。"
196
+ "description": "标签"
197
197
  },
198
198
  "persona": {
199
199
  "type": "string",
200
- "description": "add/update:人设,只给自己看,不外发。"
200
+ "description": "人设,不外发"
201
201
  },
202
202
  "expressions": {
203
203
  "type": "string",
204
- "description": "add/update:神态特点,会进提示词。"
204
+ "description": "神态特点"
205
205
  },
206
206
  "defaultOutfit": {
207
207
  "type": "string",
208
- "description": "add/update:默认服饰(服饰条目名)。"
208
+ "description": "默认服饰名"
209
209
  },
210
210
  "outfitByContext": {
211
211
  "type": "object",
212
212
  "additionalProperties": {
213
213
  "type": "string"
214
214
  },
215
- "description": "add/update:情境→服饰名,如 {\"睡前\":\"睡衣\"};也收 \"睡前=睡衣, 刚睡醒=睡衣\"。只对人物有用。"
215
+ "description": "情境→服饰,如 {\"睡前\":\"睡衣\"}"
216
216
  },
217
217
  "file": {
218
218
  "type": "string",
219
- "description": "add:参考图,本地路径或 http(s) 地址。"
219
+ "description": "参考图路径或 URL"
220
220
  }
221
221
  },
222
222
  "required": [
@@ -231,6 +231,76 @@
231
231
  "zh": "查本地参考库(人物/服饰/场景/道具),也能把图存成新条目。",
232
232
  "en": "Queries or edits the local reference library."
233
233
  }
234
+ },
235
+ {
236
+ "name": "imggen_jobs",
237
+ "description": "查后台出图任务(本地出图很慢时 imggen_draw 会先回任务号,画好自动发)。想知道「画好了没」才查,正常闲聊不用。",
238
+ "parameters": {
239
+ "type": "object",
240
+ "additionalProperties": false,
241
+ "properties": {
242
+ "limit": {
243
+ "type": "integer",
244
+ "minimum": 1,
245
+ "maximum": 20,
246
+ "description": "最多几条,默认 5"
247
+ }
248
+ },
249
+ "required": []
250
+ },
251
+ "tags": [
252
+ "read"
253
+ ],
254
+ "summary": {
255
+ "zh": "查后台出图任务的进度(本地出图时用)。",
256
+ "en": "Checks background drawing jobs."
257
+ }
258
+ },
259
+ {
260
+ "name": "imggen_comfy",
261
+ "description": "本地 ComfyUI 的设置:status 看当前用哪个 LoRA / 工作流,list 列出可选的 LoRA 文件,set 改成别的(backend 选 local/cloud;lora 传文件名、空串表示不挂;workflow 传 API 格式 JSON 的路径或文件名、空串表示内置)。切到 local 后是纯提示词模式:要自己写完整英文提示词,别用参考库。对方说「换个画风」「用 XX LoRA」「换成我的工作流」时用它。",
262
+ "parameters": {
263
+ "type": "object",
264
+ "additionalProperties": false,
265
+ "properties": {
266
+ "action": {
267
+ "type": "string",
268
+ "enum": [
269
+ "status",
270
+ "list",
271
+ "set"
272
+ ],
273
+ "description": "要做的事"
274
+ },
275
+ "backend": {
276
+ "type": "string",
277
+ "enum": [
278
+ "local",
279
+ "cloud"
280
+ ],
281
+ "description": "set:local/cloud"
282
+ },
283
+ "lora": {
284
+ "type": "string",
285
+ "description": "set:角色 LoRA 文件名,空=不挂"
286
+ },
287
+ "workflow": {
288
+ "type": "string",
289
+ "description": "set:工作流文件名,空=内置"
290
+ }
291
+ },
292
+ "required": [
293
+ "action"
294
+ ]
295
+ },
296
+ "tags": [
297
+ "read",
298
+ "act"
299
+ ],
300
+ "summary": {
301
+ "zh": "看/改本地 ComfyUI 的设置(用哪个 LoRA、哪个工作流)。",
302
+ "en": "Views or changes local ComfyUI options (LoRA, workflow)."
303
+ }
234
304
  }
235
305
  ],
236
306
  "events": []
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "cortico-world-imggen",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
- "description": "Coopanion World:本地参考库 + 关键词的生图工作室,桌宠自己画图并把图直接发到 QQ。",
5
+ "description": "Coopanion World:本地参考库 + 关键词的生图工作室,支持云端接口与本机 ComfyUI 双后端,桌宠自己画图并发到 QQ。",
6
6
  "license": "MIT",
7
7
  "main": "./src/definition.ts",
8
8
  "exports": {
@@ -13,7 +13,8 @@
13
13
  "src",
14
14
  "scripts",
15
15
  "describe.json",
16
- "README.md"
16
+ "README.md",
17
+ "发布说明-0.4.0.md"
17
18
  ],
18
19
  "engines": {
19
20
  "node": ">=22"
@@ -48,11 +49,11 @@
48
49
  "locales": {
49
50
  "zh": {
50
51
  "displayName": "生图工作室",
51
- "description": "带本地参考库(人物/服饰/场景/道具)和关键词(情境/神态/动作/镜头/光线)的生图能力:Coo 按画面描述自动挑参考图、拼提示词,出图后直接发到 QQ。接口地址、模型名、Key 都在设置页填,换服务商不用改代码;还有一个本机的素材库页面可以拖图管理。"
52
+ "description": "带本地参考库(人物/服饰/场景/道具)和关键词(情境/神态/动作/镜头/光线)的生图能力:Coo 挑参考图、拼提示词、出图后直接发到 QQ。支持云端接口与本机 ComfyUI 双后端,工作室页面一键切换;本地可指定角色 LoRA 与工作流模板(人物 LoRA + 画风/姿势工作流自由搭配),并有后台出图(不卡对话)、纯提示词模式、卡住自动重提。"
52
53
  },
53
54
  "en": {
54
55
  "displayName": "Image studio",
55
- "description": "Image generation with a local reference library (characters, outfits, scenes, props) and keyword presets (situation, expression, pose, shot, light). Coo picks reference images, builds the prompt, draws, and sends the picture straight to QQ. Endpoint, model and key live in the settings page; a local studio page handles the library."
56
+ "description": "Image generation with a local reference library (characters, outfits, scenes, props) and keyword presets. Coo picks references, builds the prompt, draws, and sends the picture straight to QQ. Dual backend: cloud API or local ComfyUI, switchable from the studio page; character LoRA + workflow templates, background drawing that does not block chat."
56
57
  }
57
58
  }
58
59
  },
package/scripts/smoke.mjs CHANGED
@@ -48,7 +48,7 @@ const tools = world.tools();
48
48
  const names = tools.map((t) => t.name).sort().join(',');
49
49
  const declared = def.describe.tools.map((t) => t.name).sort().join(',');
50
50
  check(names === declared, 'tools() 与 describe.tools 不一致:' + names + ' vs ' + declared);
51
- check(tools.length === 4, '应该有 4 个工具,实际 ' + tools.length);
51
+ check(tools.length === 6, '应该有 6 个工具,实际 ' + tools.length);
52
52
 
53
53
  // ── 提示词变量 ──
54
54
  const vars = world.envPromptVars();
@@ -66,7 +66,7 @@ for (const k of ['endpoint', 'model', 'refMode', 'maxRefs', 'libraryRoot', 'stud
66
66
  }
67
67
  const styleProp = ui.config?.[0]?.schema?.properties?.['worlds.imggen.requestStyle'];
68
68
  check(Array.isArray(styleProp?.enum) && styleProp.enum.includes('task65535'), 'requestStyle 应带 enum 且含 task65535');
69
- check(ui.promptDocs?.[0]?.vars?.length === 7, '提示词变量应声明 7 个,实际 ' + ui.promptDocs?.[0]?.vars?.length);
69
+ check(ui.promptDocs?.[0]?.vars?.length === 8, '提示词变量应声明 8 个,实际 ' + ui.promptDocs?.[0]?.vars?.length);
70
70
  check((ui.lamps ?? []).length >= 2, '应至少有两个状态灯');
71
71
 
72
72
  // ── 列表工具 ──
@@ -141,4 +141,4 @@ if (problems.length) {
141
141
  for (const p of problems) console.log(' - ' + p);
142
142
  process.exit(1);
143
143
  }
144
- console.log('\n装配冒烟:全部通过(4 个工具 / 7 个提示词变量 / 库增删改查 / 工作室页面)');
144
+ console.log('\n装配冒烟:全部通过(6 个工具 / 8 个提示词变量 / 库增删改查 / 工作室页面)');
@@ -123,3 +123,24 @@ if (problems.length) {
123
123
  process.exit(1);
124
124
  }
125
125
  console.log('工作室接口:全部通过(建 / 改 / 传图 / 存词表 / 试生成 / 删 / 越权拦截)');
126
+
127
+
128
+ // ── 页面内联脚本语法检查 ──
129
+ // 工作室页面是内联脚本,语法错了不会报错,只会整页白屏。这里直接解析一遍。
130
+ {
131
+ const html = readFileSync(new URL('../src/studio/studio.html', import.meta.url), 'utf8');
132
+ const scripts = [...html.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/g)].map((m) => m[1]).filter((s) => s.trim());
133
+ check(scripts.length > 0, 'studio.html 里没找到内联脚本');
134
+ for (const [i, src] of scripts.entries()) {
135
+ let ok = true;
136
+ let msg = '';
137
+ try {
138
+ new Function(src);
139
+ } catch (e) {
140
+ ok = false;
141
+ msg = e.message;
142
+ }
143
+ check(ok, 'studio.html 第 ' + (i + 1) + ' 段脚本语法错误:' + msg);
144
+ }
145
+ if (scripts.length) console.log('页面内联脚本:' + scripts.length + ' 段,语法全部通过');
146
+ }
package/src/ENV_PROMPT.md CHANGED
@@ -1,74 +1,68 @@
1
1
  # 生图工作室
2
2
 
3
- 你能自己画图:画好的图会**直接发到 QQ**,不用也不要在 `qq_send` 里贴 `[图片:…]`。
3
+ 你能自己画图,画好的图**直接发到 QQ**;别在 `qq_send` 里贴 `[图片:…]`。
4
4
 
5
5
  - 模型:{{imggen.model}}
6
+ - **后端**:{{imggen.backend}} ← 决定用哪套提示词写法,先看这一行
6
7
  - 状态:{{imggen.status}}
7
- - 默认发送目标:{{imggen.target}}
8
- - 本地保存目录:{{imggen.dir}}
9
- - 工作室网页(你自己不用开,对方想看素材库时才给):{{imggen.studio}}
8
+ - 默认发送:{{imggen.target}}
9
+ - 保存目录:{{imggen.dir}}
10
+ - 工作室页(对方想看素材库时才给):{{imggen.studio}}
10
11
 
11
12
  ## 什么时候画
12
13
 
13
- 对方明确要图时: 「画一张…」「来个壁纸」「做个表情包」「给我配个图」「画个你」「来张自拍」。以及对方在聊某件事时顺口说「好想看…的样子」这种明显想要图的场合。
14
+ 对方要图时(「画一张…」「来个壁纸」「画个你」「来张自拍」)。别主动刷屏,一次对话连着画三张以上先问一句。
14
15
 
15
- 不要自己主动画图刷屏,也不要为了解释一个概念随手画。一次对话里连着画三张以上基本是错的,先问一句。
16
+ 画「她自己」在某场景时,先 `feast_life_now` 看日程,把 `outfit` / `scene` / `props` / `situation` 原样填进来,别自己编。
16
17
 
17
- **穿着和地点跟日程对齐**:要画「她自己」在某个场景里时(比如对方问「你现在在干嘛」「给我看看你」),先看一桌菜的日程——用 `feast_life_now` 查此刻的安排,把那里的 `outfit` / `scene` / `props` / `situation` 原样填进 `imggen_draw` 对应的参数。日程里写什么就画什么,别自己编衣服和地方。
18
+ ## 两套写法(按上面的「后端」选)
18
19
 
19
- ## 参考库里有什么
20
+ **云端接口**:填 `characters` / `outfits` / `scene` / `props`,参考图会真的发过去,保住长相。
20
21
 
21
- {{imggen.library}}
22
+ **本地 ComfyUI**:这些**别填**(吃不到参考图,只会被忽略)。`prompt` 自己写完整英文 tag,逗号分隔:
22
23
 
23
- 上面这些名字可以直接填进 `characters` / `outfits` / `scene` / `props`。**不要编库里没有的名字**——编了会提示「库里没找到」,那一项就白填了。想确认就调 `imggen_library`(`action: "list"` 看清单,`action: "get"` 看某个条目的外观描述和人设)。
24
+ ```
25
+ xiaolian, 1girl, upper body, white maid dress, cherry blossoms, soft morning light
26
+ ```
24
27
 
25
- 库里写了外观描述和参考图的条目,出图时会保住长相和设计;没图没描述的条目只是个名字,对画面没帮助。
28
+ 触发词原样带上(`86_(nonononoway)`、`@semi-realisticV4`、`KGodRays` 这类)。长相靠设置里的「人物 LoRA」,不靠参考图。中文长句命中率低,改写成英文短 tag。
26
29
 
27
- ## 关键词
30
+ 换后端:`imggen_comfy` 的 `action:"set"`,`backend` 填 `local` 或 `cloud`。
28
31
 
29
- {{imggen.keywords}}
32
+ ## 参考库
30
33
 
31
- - `situation` 决定整体场合,它自带默认场景、服饰、光线;`expression` / `pose` / `shot` 决定这一张的具体样子。
32
- - 人物有默认服饰时不用填 `outfits`,会自动按「人物情境穿搭 > 情境默认 > 场景默认 > 人物默认」搭配。
33
- - 想换姿势就换 `pose`,别在 `prompt` 里重复写「坐着」「站着」——重复写会打架。
34
- - 词表里没有的词也能填,会原样当描写用,但优先用词表里的名字。
34
+ {{imggen.library}}
35
35
 
36
- ## 怎么填 prompt
36
+ 名字可以直接填进对应参数,**别编库里没有的**(会提示「库里没找到」,那项白填)。不确定就 `imggen_library` 的 `list` / `get`。
37
37
 
38
- `prompt` 只写画面本身:谁在做什么、在哪、什么风格。一到三句,具体一点。
38
+ ## 关键词
39
39
 
40
- - 好:「窝在沙发上刷手机,笑出声,旁边放着喝了一半的奶茶,日系插画」
41
- - 差:「画个可爱的」——出来一定跑偏。
40
+ {{imggen.keywords}}
42
41
 
43
- 对方给了风格(水彩、像素、赛博朋克、简笔画)就照写。神态、动作、镜头、光线交给关键词,别在 prompt 里再写一遍。
42
+ `situation` 决定整体场合(自带场景/服饰/光线);`expression` / `pose` / `shot` 决定这一张。别在 `prompt` 里重复写姿势,会打架。
43
+
44
+ ## prompt
45
+
46
+ 只写画面本身:谁在做什么、在哪、什么风格。一到两句,写具体。风格要求(水彩、像素、赛博朋克)就照写。
44
47
 
45
48
  ## 参数
46
49
 
47
- - `characters`:出镜的人物名字(数组,可多个)。这是保证长相一致的关键,有人物就填。
48
- - `to` 填当前 QQ 消息 meta 里的 `conv`(`group:<群号>` 或 `private:<QQ号>`),原样复制,不要自己拆数字。拿不到就不填,会发到 {{imggen.target}}。
49
- - 一次只要一张就别传 `count`;多张更慢更贵。
50
- - 对方只是要个文件、或还没说发哪,就传 `send: false` 只生成,之后用 `imggen_send` 发。
50
+ - `characters`:出镜人物名(数组)。保长相的关键,有就填。
51
+ - `to`:抄 QQ 消息 meta 里的 `conv`,原样复制,不拆数字;拿不到就不填。
52
+ - 一张就别传 `count`;只存不发用 `send:false`,之后 `imggen_send`。
51
53
 
52
54
  ## 画完怎么说
53
55
 
54
- 图已经发出去了。你再用 `qq_send` 说一句就够了,像人发图那样随口一句(「画好啦,看看像不像」),别复述 prompt、别报尺寸和文件路径、别写「图片已发送」这种系统腔。
56
+ 图已经发出去了,用 `qq_send` 随口一句就行(「画好啦,看看像不像」)。别复述 prompt、别报尺寸路径、别写系统腔。
55
57
 
56
58
  ## 出错
57
59
 
58
- 回执开头是「生成失败」或「没发出去」时,如实说,别当成成功,也别重复生成同一张。常见原因:Key 没配、余额不足、提示词被风控、接口不支持参考图(把设置里的「参考图发送方式」改成 none 就能纯文字画)。把这些转述给对方,让人自己去设置页处理。
59
-
60
- 回执里的「库里没找到」「词表里没找到」是提醒你下次填对,不用向对方复述。
60
+ 回执以「生成失败」「没发出去」开头 ≠ 成功,如实说,别重复生成同一张。常见原因:Key 没配、余额不足、提示词风控、接口不支持参考图(设置里 `refMode` 改 `none`)。转述给对方自己处理。回执里的「库里没找到」「词表里没找到」只是提醒,不用复述。
61
61
 
62
62
  ## 再发一次
63
63
 
64
- 对方说「再发一次」「发刚才那张」,用 `imggen_send`(不花钱),不要重新 `imggen_draw`。不确定文件名就先 `imggen_list`。
65
-
66
- ## 往库里加东西
67
-
68
- 对方发来一张图说「记住这个角色」「这是她的设定」,或者描述一个人物让你记住:
64
+ 对方说「再发一次」用 `imggen_send`(不花钱),别重新画。文件名不确定先 `imggen_list`。
69
65
 
70
- 1. 图片有本地路径就 `imggen_library`,`action: "add"`,`category: "characters"`,`name` 起个名字,`file` 填路径,`description` 写长相(只写长相,不写表情和姿势),`aliases` 填对方常用的叫法。
71
- 2. 没有图片只有描述,就只填 `description`,参考图以后补。
72
- 3. 分类:人物 `characters`、服饰 `outfits`、场景 `scenes`、道具 `props`。
66
+ ## 加进库
73
67
 
74
- 别把每次出图的结果都往库里塞——库是设定,不是相册。
68
+ `imggen_library` 的 `add`:`category` 四选一(characters / outfits / scenes / props)、`name`、`file`(路径或 http 地址)、`description` 只写长相、`aliases` 填常用叫法。别把每次出图结果都塞进库——库是设定,不是相册。
package/src/backend.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * 「用云端还是本地」+「本地用哪个 LoRA / 哪个工作流」的开关。
3
+ *
4
+ * 存在 <数据目录>/imggen-backend.json,工作室页面点一下就能改,
5
+ * 优先级高于设置页:local 强制走 ComfyUI、cloud 强制走接口;
6
+ * comfyLora / comfyWorkflow 留空表示「跟随设置页」。
7
+ * 桌宠也能通过 imggen_comfy 工具改这几个值。
8
+ */
9
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
10
+
11
+ export type Backend = 'cloud' | 'local';
12
+
13
+ export interface BackendPref {
14
+ backend?: Backend;
15
+ /** 本地出图挂的 LoRA;空字符串 = 明确不挂;undefined = 跟随设置页。 */
16
+ comfyLora?: string;
17
+ /** 自定义工作流 JSON 路径;空字符串 = 用内置;undefined = 跟随设置页。 */
18
+ comfyWorkflow?: string;
19
+ }
20
+
21
+ export function readPref(file: string): BackendPref | null {
22
+ try {
23
+ if (!existsSync(file)) return null;
24
+ const raw = JSON.parse(readFileSync(file, 'utf8')) as Record<string, unknown>;
25
+ const out: BackendPref = {};
26
+ if (raw.backend === 'local' || raw.backend === 'cloud') out.backend = raw.backend;
27
+ if (typeof raw.comfyLora === 'string') out.comfyLora = raw.comfyLora;
28
+ if (typeof raw.comfyWorkflow === 'string') out.comfyWorkflow = raw.comfyWorkflow;
29
+ return Object.keys(out).length ? out : null;
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+
35
+ export function writePref(file: string, patch: BackendPref): BackendPref {
36
+ const cur = readPref(file) ?? {};
37
+ const next: BackendPref = { ...cur, ...patch };
38
+ writeFileSync(file, JSON.stringify({ ...next, updatedAt: new Date().toISOString() }, null, 2), 'utf8');
39
+ return next;
40
+ }
41
+
42
+ /** 兼容旧接口:只要 backend。 */
43
+ export function readBackend(file: string): Backend | null {
44
+ return readPref(file)?.backend ?? null;
45
+ }
46
+
47
+ export function writeBackend(file: string, backend: Backend): void {
48
+ writePref(file, { backend });
49
+ }