cortico-world-imggen 0.4.0 → 0.4.2

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,16 @@
8
8
  > 思路移植自 [dsh-image-studio](https://github.com/aa1355721445-lgtm/dsh-image-studio)(本地参考库 + 关键词 + 发图策略),
9
9
  > 但按 Cortico 的 World 契约重写:没有 DSH 的宿主 API,所以调度、发图、管理页面都是自己实现的。
10
10
 
11
+ ## 0.4.1 更新
12
+
13
+ - **后端档案(profiles)**:把「后端 + 接口 + 模型 + key」存成一组,切换时整组生效。
14
+ `imggen_comfy` 新增 `profiles` / `useProfile` / `saveProfile`;工作室页面状态栏多了「档案」下拉。
15
+ 云端和本地各自的接口、模型、工作流不再互相污染。
16
+ - **key 跟着档案走**:档案的 key 存在 `imggen-secret.json` 的 `profiles` 里,不进配置文件(避免配置文件被贴进群里带走 key)。
17
+ 优先级:档案 key > 配置里手填 > secret 全局 key > .env 变量。
18
+ - **网络错误说人话**:以前只有 `fetch failed`,现在会写明 ENOTFOUND(DNS)/ ECONNRESET(连接被重置)/ UND_ERR_CONNECT_TIMEOUT(超时)/ 证书问题等底层原因。
19
+ - 存档案不再自动激活(连续保存多个档案不会把当前档案顶掉)。
20
+
11
21
  ## 0.4.0 更新
12
22
 
13
23
  - **双后端**:云端接口 / 本机 ComfyUI(8188)。工作室页面顶部一键切换,桌宠也能用 `imggen_comfy set backend=local|cloud` 自己切。
package/describe.json CHANGED
@@ -2,28 +2,28 @@
2
2
  "tools": [
3
3
  {
4
4
  "name": "imggen_draw",
5
- "description": "画一张图存本地并发 QQ。prompt 只写画面;神态/动作/镜头/光线用关键词。人物/服饰/场景/道具填库里的名字;to 抄消息 meta 里的 conv。回执有路径、尺寸、参考图和发送结果;「生成失败」开头不算成功。本地出图需等几十秒到两分钟。",
5
+ "description": "画一张图,存本地并发 QQ。prompt 只写画面;神态/动作/镜头/光线用关键词;人物/服饰/场景/道具填库里的名字。to 抄消息 meta 里的 conv。回执含路径、尺寸和发送结果;「生成失败」不算成功。本地约 30 秒~2 分钟。",
6
6
  "parameters": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
10
  "prompt": {
11
11
  "type": "string",
12
- "description": "画面:谁在做什么、在哪、什么风格。一到两句;本地模式写英文 tag。"
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",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "situation": {
40
40
  "type": "string",
41
- "description": "情境关键词"
41
+ "description": "情境关键词(定整体场合)"
42
42
  },
43
43
  "expression": {
44
44
  "type": "string",
@@ -91,6 +91,52 @@
91
91
  "en": "Draws an image using the reference library, saves it and sends it to QQ."
92
92
  }
93
93
  },
94
+ {
95
+ "name": "imggen_redraw",
96
+ "description": "以图改图:拿一张已有的图当底图,按 prompt 重绘。file 填 imggen_list 的文件名或绝对路径,不填用最新一张。denoise 越小越贴近原图(0.3 只是微调细节,0.7 改动很大),默认 0.55。底图的构图和人物位置会保留,只有画面内容按 prompt 变。只有本地 ComfyUI 支持,云端会拒绝。",
97
+ "parameters": {
98
+ "type": "object",
99
+ "additionalProperties": false,
100
+ "properties": {
101
+ "file": {
102
+ "type": "string",
103
+ "description": "底图文件名或绝对路径;不填=最新一张"
104
+ },
105
+ "prompt": {
106
+ "type": "string",
107
+ "description": "改完要变成什么样,写英文 tag 更稳"
108
+ },
109
+ "denoise": {
110
+ "type": "number",
111
+ "minimum": 0.1,
112
+ "maximum": 0.95,
113
+ "description": "重绘幅度,默认 0.55"
114
+ },
115
+ "to": {
116
+ "type": "string",
117
+ "description": "group:<群号> / private:<QQ号>"
118
+ },
119
+ "caption": {
120
+ "type": "string",
121
+ "description": "跟图一起说的话"
122
+ },
123
+ "send": {
124
+ "type": "boolean",
125
+ "description": "false = 只存不发"
126
+ }
127
+ },
128
+ "required": [
129
+ "prompt"
130
+ ]
131
+ },
132
+ "tags": [
133
+ "act"
134
+ ],
135
+ "summary": {
136
+ "zh": "拿一张已有的图当底图改图(图生图)。",
137
+ "en": "Redraws an existing image with a prompt (img2img)."
138
+ }
139
+ },
94
140
  {
95
141
  "name": "imggen_send",
96
142
  "description": "把生成过的图再发一次(不重新生成、不花钱)。file 填 imggen_list 给的文件名,不填发最新一张。对方说「再发一次」时用它,别重新画。",
@@ -258,19 +304,27 @@
258
304
  },
259
305
  {
260
306
  "name": "imggen_comfy",
261
- "description": "本地 ComfyUI 的设置:status 看当前用哪个 LoRA / 工作流,list 列出可选的 LoRA 文件,set 改成别的(backend 选 local/cloud;lora 传文件名、空串表示不挂;workflow 传 API 格式 JSON 的路径或文件名、空串表示内置)。切到 local 后是纯提示词模式:要自己写完整英文提示词,别用参考库。对方说「换个画风」「用 XX LoRA」「换成我的工作流」时用它。",
307
+ "description": "本地设置:status 看状态,list 列可用 LoRA / 工作流(按架构分组),set 改(backend=local|cloud;model=本地模型架构名;lora=文件名,空串不挂;workflow=路径或文件名,空串用内置)。profiles / useProfile / saveProfile 管后端档案。换画风、换 LoRA、快速试几张用它。",
262
308
  "parameters": {
263
309
  "type": "object",
264
310
  "additionalProperties": false,
265
311
  "properties": {
312
+ "q": {
313
+ "type": "string",
314
+ "description": "list 时按关键词过滤 LoRA / 工作流名"
315
+ },
266
316
  "action": {
267
317
  "type": "string",
268
318
  "enum": [
269
319
  "status",
270
320
  "list",
271
- "set"
321
+ "set",
322
+ "profiles",
323
+ "useProfile",
324
+ "saveProfile",
325
+ "restart"
272
326
  ],
273
- "description": "要做的事"
327
+ "description": "status 看状态;list 列 LoRA/工作流;set 改后端/模型/LoRA/工作流;profiles 列档案;useProfile 切档案;saveProfile 存档案"
274
328
  },
275
329
  "backend": {
276
330
  "type": "string",
@@ -280,6 +334,14 @@
280
334
  ],
281
335
  "description": "set:local/cloud"
282
336
  },
337
+ "model": {
338
+ "type": "string",
339
+ "enum": [
340
+ "krea2",
341
+ "anima"
342
+ ],
343
+ "description": "set:本地模型架构(本机装的那几个;不确定先 status)"
344
+ },
283
345
  "lora": {
284
346
  "type": "string",
285
347
  "description": "set:角色 LoRA 文件名,空=不挂"
@@ -287,6 +349,14 @@
287
349
  "workflow": {
288
350
  "type": "string",
289
351
  "description": "set:工作流文件名,空=内置"
352
+ },
353
+ "profile": {
354
+ "type": "string",
355
+ "description": "useProfile/saveProfile:档案名"
356
+ },
357
+ "apiKey": {
358
+ "type": "string",
359
+ "description": "saveProfile:顺手把这个档案的 key 存下来(可选)"
290
360
  }
291
361
  },
292
362
  "required": [
package/icon.png ADDED
Binary file
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "cortico-world-imggen",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
- "description": "Coopanion World:本地参考库 + 关键词的生图工作室,支持云端接口与本机 ComfyUI 双后端,桌宠自己画图并发到 QQ。",
5
+ "description": "生图工具包:给桌宠画她现在的样子(做饭、出门买菜、按描述换造型),支持云端口与本机 ComfyUI,可与其他插件联动。",
6
6
  "license": "MIT",
7
7
  "main": "./src/definition.ts",
8
8
  "exports": {
@@ -12,9 +12,13 @@
12
12
  "files": [
13
13
  "src",
14
14
  "scripts",
15
+ "icon.png",
15
16
  "describe.json",
16
17
  "README.md",
17
- "发布说明-0.4.0.md"
18
+ "发布说明-0.4.0.md",
19
+ "发布说明-0.4.1.md",
20
+ "发布说明-0.4.2.md",
21
+ "更新公告-0.4.2.md"
18
22
  ],
19
23
  "engines": {
20
24
  "node": ">=22"
@@ -34,7 +38,7 @@
34
38
  "cortico": {
35
39
  "kind": "world",
36
40
  "api": 6,
37
- "displayName": "生图工作室",
41
+ "displayName": "鱼的生图包",
38
42
  "describe": "describe.json",
39
43
  "tags": [
40
44
  "im",
@@ -48,16 +52,22 @@
48
52
  ],
49
53
  "locales": {
50
54
  "zh": {
51
- "displayName": "生图工作室",
52
- "description": "带本地参考库(人物/服饰/场景/道具)和关键词(情境/神态/动作/镜头/光线)的生图能力:Coo 挑参考图、拼提示词、出图后直接发到 QQ。支持云端接口与本机 ComfyUI 双后端,工作室页面一键切换;本地可指定角色 LoRA 与工作流模板(人物 LoRA + 画风/姿势工作流自由搭配),并有后台出图(不卡对话)、纯提示词模式、卡住自动重提。"
55
+ "displayName": "鱼的生图包",
56
+ "description": "给你的大肥鱼加上生图工具包,随时随地展示她现在的样子,例如正在做饭,或者依你描述造型,出门买菜,可与其他插件联动。支持本地参考库(人物/服饰/场景/道具)与关键词词表,云端接口与本机 ComfyUI 双后端,人物 LoRA 与画风/姿势工作流自由搭配,出图直接发到 QQ,后台出图不卡对话。"
53
57
  },
54
58
  "en": {
55
- "displayName": "Image studio",
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."
59
+ "displayName": "Fish's Image Pack",
60
+ "description": "Image generation with a local reference library and keyword presets, sending results straight to QQ. Dual backend (cloud API or local ComfyUI) with backend profiles: backend + endpoint + model + key switch as one group. Character LoRA pairs with any style/pose workflow; background drawing keeps chat responsive."
57
61
  }
58
- }
62
+ },
63
+ "icon": "icon.png"
59
64
  },
60
65
  "dependencies": {},
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/cormini/cortico-world-imggen.git"
69
+ },
70
+ "homepage": "https://github.com/cormini/cortico-world-imggen#readme",
61
71
  "scripts": {
62
72
  "describe": "node --experimental-transform-types --no-warnings scripts/gen-describe.mjs",
63
73
  "test": "node --experimental-transform-types --no-warnings scripts/test-providers.mjs",
@@ -0,0 +1,57 @@
1
+ // Anima base v1.0 vs turbo v1.1 对比 + 高清模板验证
2
+ import { writeFileSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const WF = 'H:/AI/ComfyUI/workflows';
7
+ const PROMPT = [
8
+ 'masterpiece, best quality, 1girl, solo, deep blue gradient long hair, whale fin ears, white lace maid headdress,',
9
+ 'navy maid dress with white whale apron, white thighhighs, barefoot, sitting on a navy whale cushion,',
10
+ 'hugging knees, night study room, wooden desk, pink white mechanical keyboard, black monitor,',
11
+ 'rainy window with city lights, warm desk lamp, detailed background, anime style',
12
+ ].join(' ');
13
+
14
+ const NEG = 'lowres, worst quality, bad anatomy, extra legs, bad hands, missing fingers, watermark, text';
15
+
16
+ const base = {
17
+ ...DEFAULTS,
18
+ requestStyle: 'comfyui',
19
+ comfyUrl: 'http://127.0.0.1:8188',
20
+ comfyWorkflowDir: WF,
21
+ comfyNegative: NEG,
22
+ comfyLora: '',
23
+ };
24
+
25
+ const cases = [
26
+ { tag: 'turbo-12步', wf: WF + '/Anima-快速试构图-API.json', w: 1280, h: 720, steps: 12, cfg: 1, sampler: 'euler', sched: 'simple' },
27
+ { tag: 'base-30步', wf: WF + '/Anima-底图正式版-API.json', w: 1280, h: 720, steps: 30, cfg: 5.5, sampler: 'euler_ancestral', sched: 'simple' },
28
+ { tag: 'base高清-放大2x', wf: WF + '/Anima-高清放大-API.json', w: 1280, h: 720, steps: 30, cfg: 5.5, sampler: 'euler_ancestral', sched: 'simple' },
29
+ ];
30
+
31
+ for (const c of cases) {
32
+ const cfg = normalizeConfig({
33
+ ...base,
34
+ comfyArch: 'anima',
35
+ comfyWorkflow: c.wf,
36
+ comfySteps: c.steps,
37
+ comfyCfg: c.cfg,
38
+ comfySampler: c.sampler,
39
+ comfyScheduler: c.sched,
40
+ });
41
+ const t0 = Date.now();
42
+ try {
43
+ const imgs = await generateImages({
44
+ cfg,
45
+ key: '',
46
+ prompt: PROMPT,
47
+ size: `${c.w} x ${c.h}`.replace(/\s/g, ''),
48
+ count: 1,
49
+ refs: [],
50
+ });
51
+ const out = `H:\\deepseek工作区\\.tmp\\ab-${c.tag}.png`;
52
+ writeFileSync(out, imgs[0].bytes);
53
+ console.log(`✅ ${c.tag} ${((Date.now() - t0) / 1000).toFixed(1)}s ${(imgs[0].bytes.length / 1024).toFixed(0)}KB → ${out}`);
54
+ } catch (e) {
55
+ console.log(`❌ ${c.tag} ${String(e.message).slice(0, 200)}`);
56
+ }
57
+ }
@@ -0,0 +1,54 @@
1
+ // A) S1 光效 LoRA 三个强度 B) AddMicroDetails 作为默认画质 LoRA 的三个强度 + 无 LoRA 基线
2
+ import { writeFileSync, mkdirSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const OUT = 'H:\\大肥鱼桌宠\\生图文件\\Anima-LoRA测试-第二轮';
7
+ mkdirSync(OUT, { recursive: true });
8
+
9
+ const BASE = 'masterpiece, best quality, 1girl, solo, silver hair, blue eyes, white dress, sitting by the window, rainy night city lights, detailed background, anime style';
10
+ const NEG = 'lowres, worst quality, bad anatomy, bad hands, extra fingers, watermark, text';
11
+ const SEED = 20261117;
12
+
13
+ const CASES = [
14
+ { tag: '00-无LoRA基线', lora: '', strength: 0, prompt: BASE },
15
+ { tag: '01-细节045', lora: 'AddMicroDetails_Anima_v2.safetensors', strength: 0.45, prompt: 'addmicrodetails, ' + BASE },
16
+ { tag: '02-细节055', lora: 'AddMicroDetails_Anima_v2.safetensors', strength: 0.55, prompt: 'addmicrodetails, ' + BASE },
17
+ { tag: '03-细节070', lora: 'AddMicroDetails_Anima_v2.safetensors', strength: 0.7, prompt: 'addmicrodetails, ' + BASE },
18
+ { tag: '04-S1光效040', lora: 'S1_Dramatic Lighting Anima_V2.safetensors', strength: 0.4, prompt: BASE },
19
+ { tag: '05-S1光效055', lora: 'S1_Dramatic Lighting Anima_V2.safetensors', strength: 0.55, prompt: BASE },
20
+ { tag: '06-S1光效070', lora: 'S1_Dramatic Lighting Anima_V2.safetensors', strength: 0.7, prompt: BASE },
21
+ ];
22
+
23
+ for (const c of CASES) {
24
+ const cfg = normalizeConfig({
25
+ ...DEFAULTS,
26
+ requestStyle: 'comfyui',
27
+ comfyUrl: 'http://127.0.0.1:8188',
28
+ comfyArch: 'anima',
29
+ comfyWorkflow: 'H:/AI/ComfyUI/workflows/Anima-底图正式版-API.json',
30
+ comfyLora: c.lora,
31
+ comfyLoraStrength: c.strength || 0.9,
32
+ comfyNegative: NEG,
33
+ comfySteps: 30,
34
+ comfyCfg: 5.5,
35
+ comfySampler: 'euler_ancestral',
36
+ comfyScheduler: 'simple',
37
+ });
38
+ const t0 = Date.now();
39
+ try {
40
+ const imgs = await generateImages({
41
+ cfg,
42
+ key: '',
43
+ prompt: c.prompt,
44
+ size: '1024x576',
45
+ count: 1,
46
+ refs: [],
47
+ // 固定种子以便对比
48
+ });
49
+ writeFileSync(`${OUT}\\${c.tag}.png`, imgs[0].bytes);
50
+ console.log(`✅ ${c.tag} ${((Date.now() - t0) / 1000).toFixed(1)}s`);
51
+ } catch (e) {
52
+ console.log(`❌ ${c.tag} ${String(e.message).slice(0, 160)}`);
53
+ }
54
+ }
@@ -0,0 +1,81 @@
1
+ // 6 个 Anima LoRA 逐个测,同一段提示词、同一个种子
2
+ import { writeFileSync, mkdirSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const OUT = 'H:\\大肥鱼桌宠\\生图文件\\Anima-LoRA测试';
7
+ mkdirSync(OUT, { recursive: true });
8
+
9
+ const BASE_PROMPT = 'masterpiece, best quality, 1girl, solo, silver hair, blue eyes, white dress, sitting by the window, rainy night city lights, detailed background, anime style';
10
+ const NEG = 'lowres, worst quality, bad anatomy, bad hands, extra fingers, watermark, text';
11
+
12
+ // 触发词来自各 LoRA 的训练元数据
13
+ const CASES = [
14
+ {
15
+ lora: 'AddMicroDetails_Anima_v2.safetensors',
16
+ trigger: 'addmicrodetails',
17
+ strength: 0.7,
18
+ note: '细节增强(trigger: addmicrodetails)',
19
+ },
20
+ {
21
+ lora: 'EnchantingEyesAnima.safetensors',
22
+ trigger: 'enchanting eyes',
23
+ strength: 0.85,
24
+ note: '眼睛增强(trigger: enchanting eyes)',
25
+ },
26
+ {
27
+ lora: 'Niji_semi_realism_v5.safetensors',
28
+ trigger: '',
29
+ strength: 0.8,
30
+ note: '半写实画风(无触发词)',
31
+ },
32
+ {
33
+ lora: 'S1_Dramatic Lighting Anima_V2.safetensors',
34
+ trigger: '',
35
+ strength: 0.8,
36
+ note: '戏剧光效(无触发词)',
37
+ },
38
+ {
39
+ lora: 'aigrilsV1.0.safetensors',
40
+ trigger: 'aigirls',
41
+ strength: 0.85,
42
+ note: 'AI 娘角色(trigger: aigirls)',
43
+ },
44
+ {
45
+ lora: 'nijireol-lora2k-nb22-comfy.safetensors',
46
+ trigger: '',
47
+ strength: 0.8,
48
+ note: 'LyCORIS 画风(无元数据)',
49
+ },
50
+ ];
51
+
52
+ const SEED = 20261117;
53
+
54
+ for (const c of CASES) {
55
+ const prompt = c.trigger ? `${c.trigger}, ${BASE_PROMPT}` : BASE_PROMPT;
56
+ const cfg = normalizeConfig({
57
+ ...DEFAULTS,
58
+ requestStyle: 'comfyui',
59
+ comfyUrl: 'http://127.0.0.1:8188',
60
+ comfyArch: 'anima',
61
+ comfyWorkflow: 'H:/AI/ComfyUI/workflows/Anima-LoRA测试-API.json',
62
+ comfyLora: c.lora,
63
+ comfyLoraStrength: c.strength,
64
+ comfyNegative: NEG,
65
+ comfySteps: 24,
66
+ comfyCfg: 5,
67
+ comfySampler: 'euler_ancestral',
68
+ comfyScheduler: 'simple',
69
+ });
70
+
71
+ const t0 = Date.now();
72
+ try {
73
+ const imgs = await generateImages({ cfg, key: '', prompt, size: '1024x576', count: 1, refs: [] });
74
+ const safe = c.lora.replace(/[^\w\-]+/g, '_').replace(/_safetensors$/, '');
75
+ const out = `${OUT}\\${safe}.png`;
76
+ writeFileSync(out, imgs[0].bytes);
77
+ console.log(`✅ ${c.note} ${((Date.now() - t0) / 1000).toFixed(1)}s → ${safe}.png`);
78
+ } catch (e) {
79
+ console.log(`❌ ${c.note} ${String(e.message).slice(0, 160)}`);
80
+ }
81
+ }
@@ -0,0 +1,41 @@
1
+ // 删除 turbo 后复测三个 Anima 模板
2
+ import { writeFileSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig, listComfyWorkflowsDetailed } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const WF = 'H:/AI/ComfyUI/workflows';
7
+ console.log('=== 模板架构判定 ===');
8
+ for (const w of listComfyWorkflowsDetailed(WF)) console.log(` ${w.arch.padEnd(7)} ${w.name}`);
9
+
10
+ const PROMPT = 'masterpiece, best quality, 1girl, solo, silver hair, blue eyes, white dress, standing on a rooftop, city lights at night, rainy, anime style';
11
+ const NEG = 'lowres, worst quality, bad anatomy, bad hands, watermark';
12
+
13
+ const cases = [
14
+ { tag: '快速18步', wf: 'Anima-快速版-API.json', steps: 18, cfg: 4 },
15
+ { tag: '底图30步', wf: 'Anima-底图正式版-API.json', steps: 30, cfg: 5.5 },
16
+ { tag: '高清放大', wf: 'Anima-高清放大-API.json', steps: 30, cfg: 5.5 },
17
+ ];
18
+
19
+ for (const c of cases) {
20
+ const cfg = normalizeConfig({
21
+ ...DEFAULTS,
22
+ requestStyle: 'comfyui',
23
+ comfyUrl: 'http://127.0.0.1:8188',
24
+ comfyArch: 'anima',
25
+ comfyWorkflow: WF + '/' + c.wf,
26
+ comfyNegative: NEG,
27
+ comfySteps: c.steps,
28
+ comfyCfg: c.cfg,
29
+ comfySampler: 'euler_ancestral',
30
+ comfyScheduler: 'simple',
31
+ comfyLora: '',
32
+ });
33
+ const t0 = Date.now();
34
+ try {
35
+ const imgs = await generateImages({ cfg, key: '', prompt: PROMPT, size: '1280x720', count: 1, refs: [] });
36
+ writeFileSync(`H:\\deepseek工作区\\.tmp\\after-del-${c.tag}.png`, imgs[0].bytes);
37
+ console.log(`✅ ${c.tag} ${((Date.now() - t0) / 1000).toFixed(1)}s ${(imgs[0].bytes.length / 1024).toFixed(0)}KB`);
38
+ } catch (e) {
39
+ console.log(`❌ ${c.tag} ${String(e.message).slice(0, 180)}`);
40
+ }
41
+ }
@@ -0,0 +1,48 @@
1
+ // 用扩展自己的代码,分别用 krea2 / anima 出图,验证切换是否真的生效
2
+ import { writeFileSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const base = {
7
+ ...DEFAULTS,
8
+ requestStyle: 'comfyui',
9
+ comfyUrl: 'http://127.0.0.1:8188',
10
+ comfyLora: 'xiaolian_v3.safetensors',
11
+ comfyLoraStrength: 0.9,
12
+ comfyWorkflow: 'H:/AI/ComfyUI/workflows/Krea2-眯眯眼小涟-API.json',
13
+ comfyNegative: 'lowres, bad hands, watermark',
14
+ size: '1536x864',
15
+ };
16
+
17
+ const CASE = [
18
+ {
19
+ arch: 'krea2',
20
+ prompt: 'xiaolian, 1girl, sitting on the floor, hugging knees, white maid dress, night study room, rainy window, warm lamp light',
21
+ note: 'Krea2(带 LoRA + 眯眯眼工作流)',
22
+ },
23
+ {
24
+ arch: 'anima',
25
+ prompt: 'masterpiece, best quality, 1girl, solo, blue hair, long hair, white maid dress, sitting on the floor, hugging knees, night, rainy window, warm lamp light, anime style',
26
+ note: 'Anima(无 LoRA、无模板)',
27
+ },
28
+ ];
29
+
30
+ for (const c of CASE) {
31
+ const cfg = normalizeConfig({ ...base, comfyArch: c.arch });
32
+ const t0 = Date.now();
33
+ try {
34
+ const imgs = await generateImages({
35
+ cfg,
36
+ key: '',
37
+ prompt: c.prompt,
38
+ size: '1536x864',
39
+ count: 1,
40
+ refs: [],
41
+ });
42
+ const out = `H:\\deepseek工作区\\.tmp\\arch-${c.arch}.png`;
43
+ writeFileSync(out, imgs[0].bytes);
44
+ console.log(`✅ ${c.note} ${((Date.now() - t0) / 1000).toFixed(1)}s → ${out}`);
45
+ } catch (e) {
46
+ console.log(`❌ ${c.note} ${String(e.message).slice(0, 200)}`);
47
+ }
48
+ }
@@ -0,0 +1,18 @@
1
+ // 验证 1) 协议端自动跟随 2) 降级可用 3) 配置项齐全
2
+ import { DEFAULTS, normalizeConfig } from '../src/config.ts';
3
+
4
+ const cfg = normalizeConfig({
5
+ ...DEFAULTS,
6
+ requestStyle: 'comfyui',
7
+ comfyUrl: 'http://127.0.0.1:8188',
8
+ onebotHttpUrl: 'http://127.0.0.1:3000', // 故意填错的旧端口
9
+ snowlumaConfigDir: 'H:/肥鱼机器人/QQ Agent/resources/app/snowluma/config',
10
+ onebotAutoDiscover: true,
11
+ });
12
+
13
+ console.log('配置项:');
14
+ console.log(' onebotAutoDiscover =', cfg.onebotAutoDiscover);
15
+ console.log(' snowlumaConfigDir =', cfg.snowlumaConfigDir);
16
+ console.log(' fallbackToCloud =', cfg.fallbackToCloud);
17
+ console.log(' comfyDownscaleOnStall=', cfg.comfyDownscaleOnStall);
18
+ console.log(' 手填的 onebotHttpUrl =', cfg.onebotHttpUrl, '(应该被自动覆盖成 3002)');
@@ -0,0 +1,34 @@
1
+ // 直接测 providers.ts 的图生图分支:走真实 ComfyUI
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const SRC = 'H:\\大肥鱼桌宠\\壁纸\\wp-fin-20261172.png';
7
+ const cfg = normalizeConfig({
8
+ ...DEFAULTS,
9
+ requestStyle: 'comfyui',
10
+ comfyUrl: 'http://127.0.0.1:8188',
11
+ comfyLora: 'xiaolian_v3.safetensors',
12
+ comfyLoraStrength: 0.9,
13
+ comfyWorkflow: '',
14
+ comfyNegative: '低质量, 模糊, 畸形的手',
15
+ });
16
+
17
+ const bytes = readFileSync(SRC);
18
+ console.log('底图:', SRC, (bytes.length / 1024).toFixed(0) + 'KB');
19
+
20
+ const t0 = Date.now();
21
+ const imgs = await generateImages({
22
+ cfg,
23
+ key: '',
24
+ prompt: '深夜书房,蓝发少女坐在鲸鱼沙发上,女仆装,雨窗暖灯,细节更精致',
25
+ size: '1536x864',
26
+ count: 1,
27
+ refs: [],
28
+ initImage: { bytes, filename: 'probe.png' },
29
+ denoise: 0.45,
30
+ });
31
+
32
+ const out = 'H:\\deepseek工作区\\.tmp\\ext-redraw.png';
33
+ writeFileSync(out, imgs[0].bytes);
34
+ console.log('✅ 扩展代码路径成功', ((Date.now() - t0) / 1000).toFixed(0) + 's', (imgs[0].bytes.length / 1024).toFixed(0) + 'KB →', out);
@@ -0,0 +1,52 @@
1
+ // 验证「模板按架构放行」:Anima 模板要能用,Krea2 模式选它要报错
2
+ import { writeFileSync } from 'node:fs';
3
+ import { DEFAULTS, normalizeConfig, listComfyWorkflowsDetailed } from '../src/config.ts';
4
+ import { generateImages } from '../src/providers.ts';
5
+
6
+ const WF_DIR = 'H:/AI/ComfyUI/workflows';
7
+ console.log('=== 目录里的模板与判定 ===');
8
+ for (const w of listComfyWorkflowsDetailed(WF_DIR)) console.log(` ${w.arch.padEnd(7)} ${w.name}`);
9
+
10
+ const base = {
11
+ ...DEFAULTS,
12
+ requestStyle: 'comfyui',
13
+ comfyUrl: 'http://127.0.0.1:8188',
14
+ comfyWorkflowDir: WF_DIR,
15
+ comfyNegative: 'lowres, worst quality, bad anatomy, watermark',
16
+ size: '1280x720',
17
+ comfySteps: 10,
18
+ comfyCfg: 1,
19
+ };
20
+
21
+ const ANIMA_TPL = WF_DIR + '/Anima-快速试构图-API.json';
22
+ const KREA_TPL = WF_DIR + '/Krea2-BArtstyle-API.json';
23
+ const PROMPT = 'masterpiece, best quality, 1girl, solo, blue hair, white maid dress, sitting on floor, rainy window at night, warm lamp, anime style';
24
+
25
+ console.log('\n=== A. anima + Anima 模板(应该成功)===');
26
+ try {
27
+ const cfg = normalizeConfig({ ...base, comfyArch: 'anima', comfyWorkflow: ANIMA_TPL, comfyLora: '' });
28
+ const t0 = Date.now();
29
+ const imgs = await generateImages({ cfg, key: '', prompt: PROMPT, size: '1280x720', count: 1, refs: [] });
30
+ writeFileSync('H:\\deepseek工作区\\.tmp\\tpl-anima.png', imgs[0].bytes);
31
+ console.log(` ✅ ${((Date.now() - t0) / 1000).toFixed(1)}s → .tmp\\tpl-anima.png`);
32
+ } catch (e) {
33
+ console.log(' ❌ ' + String(e.message).slice(0, 220));
34
+ }
35
+
36
+ console.log('\n=== B. krea2 + Anima 模板(应该被拦下)===');
37
+ try {
38
+ const cfg = normalizeConfig({ ...base, comfyArch: 'krea2', comfyWorkflow: ANIMA_TPL, comfyLora: 'xiaolian_v3.safetensors' });
39
+ await generateImages({ cfg, key: '', prompt: PROMPT, size: '1280x720', count: 1, refs: [] });
40
+ console.log(' ⚠️ 没被拦住(应该报错才对)');
41
+ } catch (e) {
42
+ console.log(' ✅ 拦住了:' + String(e.message).slice(0, 200));
43
+ }
44
+
45
+ console.log('\n=== C. anima + Krea2 模板(应该被拦下)===');
46
+ try {
47
+ const cfg = normalizeConfig({ ...base, comfyArch: 'anima', comfyWorkflow: KREA_TPL, comfyLora: '' });
48
+ await generateImages({ cfg, key: '', prompt: PROMPT, size: '1280x720', count: 1, refs: [] });
49
+ console.log(' ⚠️ 没被拦住(应该报错才对)');
50
+ } catch (e) {
51
+ console.log(' ✅ 拦住了:' + String(e.message).slice(0, 200));
52
+ }