cortico-world-imggen 0.3.3 → 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 +53 -0
- package/describe.json +102 -32
- package/package.json +6 -5
- package/scripts/smoke.mjs +3 -3
- package/scripts/test-studio.mjs +21 -0
- package/src/ENV_PROMPT.md +33 -39
- package/src/backend.ts +49 -0
- package/src/config.ts +402 -204
- package/src/library.ts +11 -4
- package/src/providers.ts +286 -0
- package/src/studio/server.ts +70 -0
- package/src/studio/studio.html +272 -21
- package/src/tools.ts +74 -45
- package/src/world.ts +313 -8
- package//345/217/221/345/270/203/350/257/264/346/230/216-0.4.0.md +147 -0
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
|
- **四个工具**
|
|
@@ -218,3 +234,40 @@ ONEBOT_TOKEN=<协议端 token> IMGGEN_KEY=<key> IMGGEN_REFS="D:\a.png;D:\b.png"
|
|
|
218
234
|
- 65535 的任务超时后不会自动取回,需要重新生成(不会重复扣费那条路没做)。
|
|
219
235
|
- 工作室页面的「生成」只出图、不发 QQ。
|
|
220
236
|
- 接口不支持参考图时(比如 Kolors),要么把「参考图发送方式」改成 `none`,要么换支持图生图的模型。
|
|
237
|
+
|
|
238
|
+
## 更新日志
|
|
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
|
+
|
|
245
|
+
### 0.3.4
|
|
246
|
+
|
|
247
|
+
- 工作室生成页体验:
|
|
248
|
+
- 常用尺寸一键选(方图 / 头像 / 横屏 / 大横屏 / 手机壁纸 / 21:9)
|
|
249
|
+
- 生成时显示已用秒数,可随时取消
|
|
250
|
+
- 出图后可「再画一张」「存进参考库」「下载」「复制路径」
|
|
251
|
+
- 表单参数存在浏览器本地,刷新/重开页面还在
|
|
252
|
+
- Ctrl+Enter(macOS 为 Cmd+Enter)直接生成
|
|
253
|
+
- 上下文开销:新增「库清单详细度」配置(full / alias / name),默认只列「名字+别名」,库变大时不再线性撑大前缀;`imggen_draw` 与 `imggen_library` 的参数说明去重压缩。本机实测固定开销 2,494 → 2,052 tok(约 -18%)。
|
|
254
|
+
- 修复:`normalizeConfig` 漏拷贝 `libraryDetail`,导致三档切换无效(永远按 alias 渲染)。
|
|
255
|
+
- 兼容性:工具名、参数名、返回结构均未破坏,只做新增与说明压缩。
|
|
256
|
+
|
|
257
|
+
### 0.3.3
|
|
258
|
+
|
|
259
|
+
- 新增 `outfitByContext`(情境穿搭)的写入:`imggen_library` 的 `add` / `update`、工作室页面的「情境穿搭」输入框、`/api/library/add` 与 `/api/library/update` 三个入口都能配,落盘为标准 `entry.json` 字段。
|
|
260
|
+
- `imggen_library` 的 `list` 与 `get` 开始带出「默认服饰」「情境穿搭」;没配就不输出,输出体积不变。
|
|
261
|
+
- 环境提示词新增与「一桌菜」(cortico-world-feast)的联动:让她发图前先查 `feast_life_now`,穿着与场景按日程写。
|
|
262
|
+
- 修复:工作室页面编辑条目时「情境穿搭」不回显。
|
|
263
|
+
|
|
264
|
+
### 0.3.2
|
|
265
|
+
|
|
266
|
+
- 请求体固定发 watermark: false,去掉火山 Seedream 默认盖的「AI生成」水印。
|
|
267
|
+
- 新增工作室「设置」页,API Key 保存到本机 imggen-secret.json,页面只显示尾号。
|
|
268
|
+
- 接口地址支持短名(rk / dashscope / siliconflow / openai),尺寸分隔符按服务商自动转换。
|
|
269
|
+
- 参考图缓存、429/5xx 自动重试、工作室端口兜底。
|
|
270
|
+
|
|
271
|
+
### 0.3.0
|
|
272
|
+
|
|
273
|
+
- 首个公开版本。
|
package/describe.json
CHANGED
|
@@ -2,81 +2,81 @@
|
|
|
2
2
|
"tools": [
|
|
3
3
|
{
|
|
4
4
|
"name": "imggen_draw",
|
|
5
|
-
"description": "
|
|
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": "
|
|
61
|
+
"description": "尺寸,如 1024x1024"
|
|
62
62
|
},
|
|
63
63
|
"count": {
|
|
64
64
|
"type": "integer",
|
|
65
65
|
"minimum": 1,
|
|
66
66
|
"maximum": 4,
|
|
67
|
-
"description": "
|
|
67
|
+
"description": "张数,默认 1"
|
|
68
68
|
},
|
|
69
69
|
"to": {
|
|
70
70
|
"type": "string",
|
|
71
|
-
"description": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
178
|
+
"description": "条目名"
|
|
179
179
|
},
|
|
180
180
|
"description": {
|
|
181
181
|
"type": "string",
|
|
182
|
-
"description": "
|
|
182
|
+
"description": "外观,只写长相/设计"
|
|
183
183
|
},
|
|
184
184
|
"aliases": {
|
|
185
185
|
"type": "array",
|
|
186
186
|
"items": {
|
|
187
187
|
"type": "string"
|
|
188
188
|
},
|
|
189
|
-
"description": "
|
|
189
|
+
"description": "别名"
|
|
190
190
|
},
|
|
191
191
|
"tags": {
|
|
192
192
|
"type": "array",
|
|
193
193
|
"items": {
|
|
194
194
|
"type": "string"
|
|
195
195
|
},
|
|
196
|
-
"description": "
|
|
196
|
+
"description": "标签"
|
|
197
197
|
},
|
|
198
198
|
"persona": {
|
|
199
199
|
"type": "string",
|
|
200
|
-
"description": "
|
|
200
|
+
"description": "人设,不外发"
|
|
201
201
|
},
|
|
202
202
|
"expressions": {
|
|
203
203
|
"type": "string",
|
|
204
|
-
"description": "
|
|
204
|
+
"description": "神态特点"
|
|
205
205
|
},
|
|
206
206
|
"defaultOutfit": {
|
|
207
207
|
"type": "string",
|
|
208
|
-
"description": "
|
|
208
|
+
"description": "默认服饰名"
|
|
209
209
|
},
|
|
210
210
|
"outfitByContext": {
|
|
211
211
|
"type": "object",
|
|
212
212
|
"additionalProperties": {
|
|
213
213
|
"type": "string"
|
|
214
214
|
},
|
|
215
|
-
"description": "
|
|
215
|
+
"description": "情境→服饰,如 {\"睡前\":\"睡衣\"}"
|
|
216
216
|
},
|
|
217
217
|
"file": {
|
|
218
218
|
"type": "string",
|
|
219
|
-
"description": "
|
|
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
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Coopanion World:本地参考库 +
|
|
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
|
|
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
|
|
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 ===
|
|
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 ===
|
|
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装配冒烟:全部通过(
|
|
144
|
+
console.log('\n装配冒烟:全部通过(6 个工具 / 8 个提示词变量 / 库增删改查 / 工作室页面)');
|
package/scripts/test-studio.mjs
CHANGED
|
@@ -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
|
-
|
|
3
|
+
你能自己画图,画好的图**直接发到 QQ**;别在 `qq_send` 里贴 `[图片:…]`。
|
|
4
4
|
|
|
5
5
|
- 模型:{{imggen.model}}
|
|
6
|
+
- **后端**:{{imggen.backend}} ← 决定用哪套提示词写法,先看这一行
|
|
6
7
|
- 状态:{{imggen.status}}
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
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
|
-
|
|
18
|
+
## 两套写法(按上面的「后端」选)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
**云端接口**:填 `characters` / `outfits` / `scene` / `props`,参考图会真的发过去,保住长相。
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
**本地 ComfyUI**:这些**别填**(吃不到参考图,只会被忽略)。`prompt` 自己写完整英文 tag,逗号分隔:
|
|
22
23
|
|
|
23
|
-
|
|
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
|
-
|
|
32
|
+
## 参考库
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
- 人物有默认服饰时不用填 `outfits`,会自动按「人物情境穿搭 > 情境默认 > 场景默认 > 人物默认」搭配。
|
|
33
|
-
- 想换姿势就换 `pose`,别在 `prompt` 里重复写「坐着」「站着」——重复写会打架。
|
|
34
|
-
- 词表里没有的词也能填,会原样当描写用,但优先用词表里的名字。
|
|
34
|
+
{{imggen.library}}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
名字可以直接填进对应参数,**别编库里没有的**(会提示「库里没找到」,那项白填)。不确定就 `imggen_library` 的 `list` / `get`。
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
## 关键词
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
- 差:「画个可爱的」——出来一定跑偏。
|
|
40
|
+
{{imggen.keywords}}
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
`situation` 决定整体场合(自带场景/服饰/光线);`expression` / `pose` / `shot` 决定这一张。别在 `prompt` 里重复写姿势,会打架。
|
|
43
|
+
|
|
44
|
+
## prompt
|
|
45
|
+
|
|
46
|
+
只写画面本身:谁在做什么、在哪、什么风格。一到两句,写具体。风格要求(水彩、像素、赛博朋克)就照写。
|
|
44
47
|
|
|
45
48
|
## 参数
|
|
46
49
|
|
|
47
|
-
- `characters
|
|
48
|
-
- `to
|
|
49
|
-
-
|
|
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
|
-
|
|
56
|
+
图已经发出去了,用 `qq_send` 随口一句就行(「画好啦,看看像不像」)。别复述 prompt、别报尺寸路径、别写系统腔。
|
|
55
57
|
|
|
56
58
|
## 出错
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
回执里的「库里没找到」「词表里没找到」是提醒你下次填对,不用向对方复述。
|
|
60
|
+
回执以「生成失败」「没发出去」开头 ≠ 成功,如实说,别重复生成同一张。常见原因:Key 没配、余额不足、提示词风控、接口不支持参考图(设置里 `refMode` 改 `none`)。转述给对方自己处理。回执里的「库里没找到」「词表里没找到」只是提醒,不用复述。
|
|
61
61
|
|
|
62
62
|
## 再发一次
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## 往库里加东西
|
|
67
|
-
|
|
68
|
-
对方发来一张图说「记住这个角色」「这是她的设定」,或者描述一个人物让你记住:
|
|
64
|
+
对方说「再发一次」用 `imggen_send`(不花钱),别重新画。文件名不确定先 `imggen_list`。
|
|
69
65
|
|
|
70
|
-
|
|
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
|
+
}
|