dsh-qqbot-muu 0.1.15 → 0.1.21
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/CHANGELOG.md +168 -85
- package/client/qqbot-settings.js +13401 -12024
- package/config/modules.json +212 -0
- package/dist/channel-tools.js +21 -10
- package/dist/config.d.ts +14 -0
- package/dist/config.js +573 -449
- package/dist/features/contextless-store.js +247 -247
- package/dist/features/contextless-trim.js +455 -34
- package/dist/features/four-source.js +338 -336
- package/dist/features/group-join-request.js +289 -287
- package/dist/features/local-models.js +1494 -0
- package/dist/features/rotate-summarizer.js +438 -0
- package/dist/features/scenario-detect.js +321 -0
- package/dist/features/scheduler.js +8 -1
- package/dist/features/session-rotate.js +499 -0
- package/dist/features/session-title.js +199 -0
- package/dist/features/style-layer.js +501 -0
- package/dist/features/thinking-log.js +71 -69
- package/dist/gateway/bootstrap.js +1704 -1388
- package/dist/gateway/data-root.js +77 -3
- package/dist/gateway/middleware-setup.js +6 -3
- package/dist/index.js +4 -2
- package/dist/model/settings-reader.js +193 -102
- package/dist/session/session-manager.js +1730 -1587
- package/dist/shared/paths.js +128 -0
- package/dist/shared/settings-io.js +79 -0
- package/dist/transport/inbound.js +20 -1
- package/dist/transport/outbound.js +56 -4
- package/docs/RELEASE_CHECKLIST.md +24 -2
- package/dshqqbot/.qqbot-extensions/hooks/interview-panel.mjs +41 -1
- package/dshqqbot/.qqbot-extensions/inbound/00-vision.mjs +111 -0
- package/dshqqbot/.qqbot-extensions/inbound/aa-memory-recall.mjs +802 -689
- package/dshqqbot/.qqbot-extensions/inbound/ac-image-see.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/inbound/az-feedback.mjs +113 -115
- package/dshqqbot/.qqbot-extensions/inbound/local-answer.mjs +689 -568
- package/dshqqbot/.qqbot-extensions/lib/.pet-form.json +1 -1
- package/dshqqbot/.qqbot-extensions/lib/draw-core.mjs +238 -7
- package/dshqqbot/.qqbot-extensions/lib/local-llm.mjs +455 -394
- package/dshqqbot/.qqbot-extensions/lib/memory-agent.mjs +930 -928
- package/dshqqbot/.qqbot-extensions/lib/memory-core.mjs +537 -537
- package/dshqqbot/.qqbot-extensions/lib/memory-db.mjs +2476 -2245
- package/dshqqbot/.qqbot-extensions/lib/memory-hippo.mjs +18 -0
- package/dshqqbot/.qqbot-extensions/lib/memory.mjs +191 -186
- package/dshqqbot/.qqbot-extensions/lib/plugin-dir.mjs +14 -4
- package/dshqqbot/.qqbot-extensions/lib/scope-util.mjs +84 -0
- package/dshqqbot/.qqbot-extensions/lib/vision.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/outbound/aa-sanitize.mjs +158 -154
- package/dshqqbot/.qqbot-extensions/outbound/ac-media-fix.mjs +5 -1
- package/dshqqbot/.qqbot-extensions/outbound/memory-agent.mjs +121 -130
- package/dshqqbot/.qqbot-extensions/outbound/split-reply.mjs +18 -2
- package/dshqqbot/.qqbot-extensions/outbound/turn-memory.mjs +92 -101
- package/dshqqbot/.qqbot-extensions/tools/draw.mjs +22 -1
- package/dshqqbot/.qqbot-extensions/tools/memory.mjs +178 -120
- package/dshqqbot/.qqbot-extensions/tools/pet_card.mjs +3 -2
- package/dshqqbot/.qqbot-extensions/tools/storyboard.mjs +3 -1
- package/dshqqbot/.qqbot-extensions/vendor/abogus/test-abogus.mjs +128 -126
- package/package.json +119 -111
- package/scripts/__pycache__/fan-mode.cpython-311.pyc +0 -0
- package/scripts/__pycache__/memory-audit.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-ip-sync.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-whitelist.cpython-311.pyc +0 -0
- package/scripts/_add_maintenance_cfg.py +20 -0
- package/scripts/_bench_keeplease.sh +10 -0
- package/scripts/_dbg_purge.py +15 -0
- package/scripts/_elev.sh +6 -0
- package/scripts/_fix_all_admin.cmd +16 -0
- package/scripts/_livecheck-image.mjs +33 -0
- package/scripts/_livecheck-llm.mjs +34 -0
- package/scripts/_livecheck-tts.mjs +37 -0
- package/scripts/_patch_curve.py +88 -0
- package/scripts/_patch_fan_thermal.py +24 -0
- package/scripts/_tag_tmp.py +13 -0
- package/scripts/adb-broker-client.mjs +87 -0
- package/scripts/adb-broker.mjs +205 -0
- package/scripts/ai-mode.cmd +6 -0
- package/scripts/ai-mode.py +387 -0
- package/scripts/ai-toolkit.py +607 -0
- package/scripts/apply-fan-gpu45.py +51 -0
- package/scripts/bench-fans.py +515 -0
- package/scripts/bench-load-direct.py +63 -0
- package/scripts/boot-tasks-hidden.vbs +20 -0
- package/scripts/boot-tasks.cmd +277 -0
- package/scripts/chat-archive/__pycache__/build-sft-v4.cpython-311.pyc +0 -0
- package/scripts/chat-archive/__pycache__/build-sft.cpython-311.pyc +0 -0
- package/scripts/chat-archive/build-sft-v4.py +566 -0
- package/scripts/chat-archive/build-sft.py +390 -0
- package/scripts/chat-archive/eval-sft.py +155 -0
- package/scripts/chat-archive/extract-memory.py +143 -0
- package/scripts/chat-archive/inventory.py +182 -0
- package/scripts/chat-archive/merge-sft.py +114 -0
- package/scripts/chat-archive/qce-pull.py +217 -0
- package/scripts/chat-archive/qqheader.py +110 -0
- package/scripts/chat-archive/qqkey2.py +113 -0
- package/scripts/chat-archive/qqprobe.py +153 -0
- package/scripts/chat-archive/screen-collect.py +163 -0
- package/scripts/chat-archive/sqlcipher_probe.py +444 -0
- package/scripts/comfy_gen.py +209 -0
- package/scripts/compose-video.py +168 -0
- package/scripts/dl_models.py +45 -0
- package/scripts/draw-now.cmd +18 -0
- package/scripts/dsh-instance-guard.mjs +20 -2
- package/scripts/elev-extra.cmd +25 -0
- package/scripts/episode.py +529 -0
- package/scripts/fan-curve.py +218 -0
- package/scripts/fan-guard.cmd +8 -0
- package/scripts/fan-mode.py +380 -0
- package/scripts/fan_manual_safe.py +33 -0
- package/scripts/fan_restore_manual.py +46 -0
- package/scripts/fc_curves.py +359 -0
- package/scripts/fix-fan-and-timers.cmd +39 -0
- package/scripts/fix_admin_all.py +94 -0
- package/scripts/flows.mjs +224 -0
- package/scripts/gateway.cmd +126 -0
- package/scripts/gen-image.py +420 -0
- package/scripts/gen-video.py +186 -0
- package/scripts/git-askpass.cmd +2 -2
- package/scripts/gpu-mode.py +195 -0
- package/scripts/hw-profile.py +175 -0
- package/scripts/install-schedule.cmd +37 -0
- package/scripts/install-watch.cmd +29 -0
- package/scripts/matte-cutout.py +106 -0
- package/scripts/media-enhance.py +402 -0
- package/scripts/memory-audit.py +581 -0
- package/scripts/migrate-scope.mjs +140 -139
- package/scripts/model-registry.py +519 -0
- package/scripts/openid-audit.mjs +219 -0
- package/scripts/pull-gguf.py +127 -0
- package/scripts/purge-standby.py +151 -0
- package/scripts/qq-connect-login.py +133 -0
- package/scripts/qq-ip-sync-hidden.vbs +5 -0
- package/scripts/qq-ip-sync.py +300 -0
- package/scripts/qq-login-once.cmd +20 -0
- package/scripts/qq-login-qr.py +72 -0
- package/scripts/qq-whitelist-fix.cmd +27 -0
- package/scripts/qq-whitelist-login.cmd +26 -0
- package/scripts/qq-whitelist.cmd +12 -0
- package/scripts/qq-whitelist.py +1452 -0
- package/scripts/quality-compare.py +134 -0
- package/scripts/release-all.mjs +636 -430
- package/scripts/release-check.mjs +244 -226
- package/scripts/resume-coder.cmd +38 -0
- package/scripts/secure-room/index.html +334 -0
- package/scripts/secure-room/server.py +582 -0
- package/scripts/security-check.mjs +164 -0
- package/scripts/selftest-local-llm.mjs +20 -0
- package/scripts/selftest-local-models.mjs +754 -0
- package/scripts/selftest-rotate-style.mjs +308 -0
- package/scripts/shutdown-s5-optional.cmd +21 -0
- package/scripts/sleep-2325.cmd +75 -0
- package/scripts/start-comfyui.cmd +5 -0
- package/scripts/start-strata.cmd +17 -0
- package/scripts/start-strata.vbs +11 -0
- package/scripts/start-watch-hidden.vbs +3 -0
- package/scripts/stickers/auto-tag.mjs +161 -0
- package/scripts/storage.mjs +236 -0
- package/scripts/sync-plugin-copies.mjs +98 -23
- package/scripts/tests/test-qq-whitelist.py +192 -0
- package/scripts/train/__pycache__/train-lora.cpython-311.pyc +0 -0
- package/scripts/train/gguf-quantize.py +92 -0
- package/scripts/train/gguf-to-hf.py +112 -0
- package/scripts/train/merge-lora.py +51 -0
- package/scripts/train/probe-mirrors.sh +12 -0
- package/scripts/train/probe-mirrors2.sh +20 -0
- package/scripts/train/setup-wsl.sh +23 -0
- package/scripts/train/setup-wsl2.sh +25 -0
- package/scripts/train/setup-wsl3.sh +22 -0
- package/scripts/train/setup-wsl4.sh +22 -0
- package/scripts/train/train-lora.py +319 -0
- package/scripts/vram-free.py +104 -0
- package/scripts/wechat-full-pull.mjs +1 -1
- package/settings-host.js +1047 -12
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* flows.mjs — qqbot 的「流程归一」入口(2026-11-29)
|
|
4
|
+
*
|
|
5
|
+
* 为什么要有它:插件版本、生图、桌宠皮肤、环境自检原来散在十几个人肉步骤里
|
|
6
|
+
* (改 package.json → 改 CHANGELOG → release:check → sync-plugin-copies → 手动重启),
|
|
7
|
+
* 漏一步就是「重启了却没生效」「副本里的注册表是空的」这类问题。这里把每个流程收成一条命令。
|
|
8
|
+
*
|
|
9
|
+
* 用法:
|
|
10
|
+
* node scripts/flows.mjs list
|
|
11
|
+
* node scripts/flows.mjs doctor # 兼容性自检(不写任何文件)
|
|
12
|
+
* node scripts/flows.mjs version patch|minor|major
|
|
13
|
+
* node scripts/flows.mjs sync # = scripts/sync-plugin-copies.mjs
|
|
14
|
+
* node scripts/flows.mjs pet --count 4 # 用本地生图做桌宠皮肤候选(img2img 保角色)
|
|
15
|
+
*
|
|
16
|
+
* 约定:所有产出落 out/<kind>/<yyyy-MM>/ 或 out/pet-skins/<yyyy-MM-dd>/;
|
|
17
|
+
* 模型清单唯一来源是 config/models.registry.json(scripts/model-registry.py --write)。
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync, statSync } from 'node:fs'
|
|
20
|
+
import { dirname, join, basename } from 'node:path'
|
|
21
|
+
import { spawnSync } from 'node:child_process'
|
|
22
|
+
import { fileURLToPath } from 'node:url'
|
|
23
|
+
|
|
24
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
25
|
+
const PY = process.env.QQBOT_PY || 'E:\\Anaconda\\envs\\ai25\\python.exe'
|
|
26
|
+
|
|
27
|
+
function run(cmd, args, opts = {}) {
|
|
28
|
+
const r = spawnSync(cmd, args, { cwd: ROOT, stdio: 'inherit', windowsHide: false, ...opts })
|
|
29
|
+
return r.status === 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readJson(p) {
|
|
33
|
+
try { return JSON.parse(String(readFileSync(p, 'utf8')).replace(/^\uFEFF/, '')) } catch { return null }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function fmtMB(n) {
|
|
37
|
+
const b = Number(n || 0)
|
|
38
|
+
return b >= 1024 * 1024 ? (b / 1024 / 1024).toFixed(0) + 'MB' : Math.max(1, Math.round(b / 1024)) + 'KB'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── doctor:兼容性 / 安装态自检 ────────────────────────────────────────────
|
|
42
|
+
function doctor() {
|
|
43
|
+
const rows = []
|
|
44
|
+
const ok = (name, pass, detail) => rows.push({ name, pass: !!pass, detail: detail || '' })
|
|
45
|
+
|
|
46
|
+
// 1) 注册表存在、且不是空表(空表就是「面板里一个模型都没有」的直接原因)
|
|
47
|
+
const regPath = join(ROOT, 'config', 'models.registry.json')
|
|
48
|
+
const reg = readJson(regPath)
|
|
49
|
+
const n = (reg && Array.isArray(reg.models)) ? reg.models.length : 0
|
|
50
|
+
ok('模型注册表非空', n > 0, n ? `${n} 个模型 · ${reg.total_gb || '?'}GB · root=${reg.root || '?'}` : 'config/models.registry.json 缺失或 models 为空 —— 跑 python scripts/model-registry.py --write')
|
|
51
|
+
|
|
52
|
+
// 2) 注册表 root 必须指向真有 .models 的那一层(副本里没有 .models 就是空表的元凶)
|
|
53
|
+
const realModels = existsSync(join(ROOT, '.models'))
|
|
54
|
+
ok('仓库根有 .models', realModels, realModels ? join(ROOT, '.models') : '找不到 .models —— 这台机器还没放模型,属于正常但模型相关功能不可用')
|
|
55
|
+
|
|
56
|
+
// 3) 模块注册表可解析、id 唯一
|
|
57
|
+
const mods = readJson(join(ROOT, 'config', 'modules.json'))
|
|
58
|
+
const ids = mods && Array.isArray(mods.modules) ? mods.modules.map((m) => m.id) : []
|
|
59
|
+
ok('模块注册表可解析', !!mods && ids.length > 0, `${ids.length} 个模块 / ${(mods && mods.groups || []).length} 组`)
|
|
60
|
+
ok('模块 id 唯一', new Set(ids).size === ids.length, new Set(ids).size === ids.length ? '' : '有重复 id,浮窗标签会串')
|
|
61
|
+
|
|
62
|
+
// 4) 代码语法(失败的插件会让宿主整块白屏)
|
|
63
|
+
for (const f of ['settings-host.js', 'client/qqbot-settings.js', 'entry.js']) {
|
|
64
|
+
const p = join(ROOT, f)
|
|
65
|
+
if (!existsSync(p)) { ok(`语法 ${f}`, false, '文件不存在'); continue }
|
|
66
|
+
const r = spawnSync(process.execPath, ['--check', p], { windowsHide: true })
|
|
67
|
+
ok(`语法 ${f}`, r.status === 0, r.status === 0 ? '' : String(r.stderr || '').slice(0, 200))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 5) DSH 安装副本里的注册表不能是空表(旧版本 sync 漏了这一份)
|
|
71
|
+
const prof = join(process.env.APPDATA || '', 'dsh-desktop', 'harness', 'profiles', 'web', 'node_modules', '.pnpm')
|
|
72
|
+
try {
|
|
73
|
+
const hit = readdirSync(prof).filter((x) => x.startsWith('dsh-qqbot-muu@')).sort().pop()
|
|
74
|
+
if (hit) {
|
|
75
|
+
const copyReg = join(prof, hit, 'node_modules', 'dsh-qqbot-muu', 'config', 'models.registry.json')
|
|
76
|
+
const st = existsSync(copyReg) ? statSync(copyReg) : null
|
|
77
|
+
const cj = st ? readJson(copyReg) : null
|
|
78
|
+
const cn = (cj && Array.isArray(cj.models)) ? cj.models.length : 0
|
|
79
|
+
ok('安装副本注册表', cn > 0, st ? `${cn} 个模型 · ${fmtMB(st.size)}` : '副本里没有 config/models.registry.json(跑 node scripts/flows.mjs sync)')
|
|
80
|
+
} else ok('安装副本注册表', true, '没检测到 DSH web profile(可能不是本机运行)')
|
|
81
|
+
} catch { ok('安装副本注册表', true, '跳过(读不到 profile 目录)') }
|
|
82
|
+
|
|
83
|
+
// 6) 产出目录约定
|
|
84
|
+
for (const d of ['out/image', 'out/video', 'out/audio', 'out/pet-skins']) {
|
|
85
|
+
ok(`产出目录 ${d}`, existsSync(join(ROOT, d)), existsSync(join(ROOT, d)) ? '' : '还没建(第一次产出会自动建)')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 7) 过程性文件分区表(2026-11-30):所有缓存/临时目录必须在这里登记,才会被 clean 管到
|
|
89
|
+
const store = readJson(join(ROOT, 'config', 'storage.json'))
|
|
90
|
+
const sad = (store && Array.isArray(store.areas)) ? store.areas : []
|
|
91
|
+
const badArea = sad.filter((a) => !a.id || !a.name || (!a.globs && !a.osTemp) || typeof a.autoClean !== 'boolean')
|
|
92
|
+
ok('存储分区表可用', sad.length > 0 && badArea.length === 0,
|
|
93
|
+
sad.length ? `${sad.length} 个分区(${sad.filter((a) => a.autoClean).length} 个可自动清理)` : 'config/storage.json 缺失或无效')
|
|
94
|
+
ok('安全审计脚本就位', existsSync(join(ROOT, 'scripts', 'security-check.mjs')), 'node scripts/security-check.mjs')
|
|
95
|
+
|
|
96
|
+
const bad = rows.filter((r) => !r.pass)
|
|
97
|
+
console.log('\n=== qqbot doctor ===\n')
|
|
98
|
+
for (const r of rows) console.log(`${r.pass ? '✓' : '✗'} ${r.name}${r.detail ? ' — ' + r.detail : ''}`)
|
|
99
|
+
console.log(`\n${rows.length - bad.length}/${rows.length} 通过${bad.length ? `,${bad.length} 项需要处理` : ''}\n`)
|
|
100
|
+
return bad.length ? 1 : 0
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ── version:版本号 + CHANGELOG 一起改(漏一处就会出现「版本没变但代码变了」)──
|
|
104
|
+
function version(kind) {
|
|
105
|
+
const pkgPath = join(ROOT, 'package.json')
|
|
106
|
+
const pkg = readJson(pkgPath)
|
|
107
|
+
if (!pkg) { console.error('读不到 package.json'); return 1 }
|
|
108
|
+
const cur = String(pkg.version || '0.0.0').split('.').map((x) => parseInt(x, 10) || 0)
|
|
109
|
+
const next = cur.slice()
|
|
110
|
+
if (kind === 'major') { next[0] += 1; next[1] = 0; next[2] = 0 }
|
|
111
|
+
else if (kind === 'minor') { next[1] += 1; next[2] = 0 }
|
|
112
|
+
else if (kind === 'patch') next[2] += 1
|
|
113
|
+
else { console.error('用法: node scripts/flows.mjs version patch|minor|major'); return 1 }
|
|
114
|
+
const from = cur.join('.')
|
|
115
|
+
const to = next.join('.')
|
|
116
|
+
pkg.version = to
|
|
117
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
|
|
118
|
+
|
|
119
|
+
const clPath = join(ROOT, 'CHANGELOG.md')
|
|
120
|
+
const today = new Date().toISOString().slice(0, 10)
|
|
121
|
+
let head = ''
|
|
122
|
+
try { head = String(readFileSync(clPath, 'utf8')) } catch { /* 没有就新建 */ }
|
|
123
|
+
if (!head) head = '# 更新日志\n'
|
|
124
|
+
// 插在第一个二级标题之前(保留之前的全部历史)
|
|
125
|
+
const idx = head.indexOf('\n## ')
|
|
126
|
+
const entry = `\n## ${to} — ${today}\n\n### 改了什么\n- (在这里写 1~3 条人话)\n\n### 兼容性\n- 旧配置缺字段 → 按内置默认值;旧接口保留;副本缺失的注册表自动回落。\n`
|
|
127
|
+
const out = idx >= 0 ? head.slice(0, idx) + entry + head.slice(idx) : head + entry
|
|
128
|
+
writeFileSync(clPath, out, 'utf8')
|
|
129
|
+
|
|
130
|
+
console.log(`✓ 版本 ${from} → ${to}(package.json + CHANGELOG.md 已更新)`)
|
|
131
|
+
console.log('下一步:① 填 CHANGELOG 的三条人话 ② node scripts/release-check.mjs ③ node scripts/flows.mjs sync ④ 重启 DSH')
|
|
132
|
+
return 0
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ── pet:桌宠皮肤候选(img2img 保角色,只换衣服/质感)──────────────────────
|
|
136
|
+
const PET_OUTFITS = [
|
|
137
|
+
{ id: 'deepsea-gown', name: '深海夜礼服', prompt: 'elegant deep-sea navy evening gown with bioluminescent trim, pearl accents, translucent flowing fabric' },
|
|
138
|
+
{ id: 'sakura-kimono', name: '樱花和风', prompt: 'pink sakura kimono with cherry blossom pattern, soft ribbon obi, small hair ornament' },
|
|
139
|
+
{ id: 'moonlight', name: '月光白裙', prompt: 'pure white moonlight dress with silver embroidery, soft cool rim light, gentle glow' },
|
|
140
|
+
{ id: 'star-witch', name: '星海巫女', prompt: 'starry witch outfit, deep blue cloak with golden stars, small pointed hat, glowing constellation patterns' },
|
|
141
|
+
{ id: 'sailor', name: '水手服', prompt: 'navy and white sailor uniform, red neckerchief, crisp clean folds' },
|
|
142
|
+
{ id: 'winter', name: '冬日毛绒', prompt: 'fluffy winter coat with hood, soft cream scarf, warm knit texture' },
|
|
143
|
+
]
|
|
144
|
+
const PET_BASE_PROMPT = '1girl, chibi anime mascot, whale girl, long blue hair with aqua gradient, small whale tail, big expressive eyes, full body standing, facing viewer, soft cel shading, clean line art, plain simple background, high detail, keep the same face and pose as the reference'
|
|
145
|
+
|
|
146
|
+
function pet(argv) {
|
|
147
|
+
const get = (k, d) => { const i = argv.indexOf('--' + k); return i >= 0 ? argv[i + 1] : d }
|
|
148
|
+
const count = Math.max(1, Math.min(6, Number(get('count', 2)) || 2))
|
|
149
|
+
const model = String(get('model', 'krea'))
|
|
150
|
+
const denoise = String(get('denoise', '0.55'))
|
|
151
|
+
const base = String(get('init', join(ROOT, 'assets', 'char', 'pose', 'idle.png')))
|
|
152
|
+
const only = String(get('outfit', ''))
|
|
153
|
+
const many = String(get('outfits', '')).split(',').map((x) => x.trim()).filter(Boolean)
|
|
154
|
+
const noMatte = argv.includes('--no-matte')
|
|
155
|
+
let list = PET_OUTFITS
|
|
156
|
+
if (many.length) list = PET_OUTFITS.filter((x) => many.includes(x.id))
|
|
157
|
+
else if (only) list = PET_OUTFITS.filter((x) => x.id === only)
|
|
158
|
+
list = list.slice(0, count)
|
|
159
|
+
const day = new Date().toISOString().slice(0, 10)
|
|
160
|
+
const outDir = join(ROOT, 'out', 'pet-skins', day)
|
|
161
|
+
mkdirSync(outDir, { recursive: true })
|
|
162
|
+
const toolkit = join(ROOT, 'scripts', 'ai-toolkit.py')
|
|
163
|
+
const matte = join(ROOT, 'scripts', 'matte-cutout.py')
|
|
164
|
+
const report = []
|
|
165
|
+
for (const o of list) {
|
|
166
|
+
const raw = join(outDir, `${o.id}-raw.png`)
|
|
167
|
+
const out = join(outDir, `${o.id}.png`)
|
|
168
|
+
console.log(`\n▶ ${o.name} (${o.id}) → ${out}`)
|
|
169
|
+
const r = spawnSync(PY, [toolkit, 'image', '--model', model, '--init', base, '--denoise', denoise,
|
|
170
|
+
'-p', `${PET_BASE_PROMPT}, wearing ${o.prompt}`, '-o', raw, '--start', '--json'],
|
|
171
|
+
{ cwd: ROOT, encoding: 'utf8', windowsHide: true, timeout: 1800000, maxBuffer: 8 * 1024 * 1024 })
|
|
172
|
+
const line = String(r.stdout || '').trim().split('\n').filter(Boolean).pop() || ''
|
|
173
|
+
let data = null
|
|
174
|
+
try { data = JSON.parse(line) } catch { /* 不是 JSON 就把原始尾巴写进报告 */ }
|
|
175
|
+
const okOne = !!(data && data.ok && (data.files || []).length)
|
|
176
|
+
let matteInfo = null
|
|
177
|
+
if (okOne && !noMatte) {
|
|
178
|
+
// 生图背景是纯色(黑/白),桌宠要透明 —— 统一在这里抠掉,边缘羽化 1px
|
|
179
|
+
const m = spawnSync(PY, [matte, (data.files && data.files[0]) || raw, out], { cwd: ROOT, encoding: 'utf8', windowsHide: true, timeout: 300000 })
|
|
180
|
+
const mline = String(m.stdout || '').trim()
|
|
181
|
+
matteInfo = { ok: m.status === 0, log: mline.slice(0, 300) }
|
|
182
|
+
console.log(matteInfo.ok ? `✓ 抠图完成 ${mline.slice(0, 120)}` : `✗ 抠图失败:${mline.slice(0, 200)}`)
|
|
183
|
+
}
|
|
184
|
+
report.push({
|
|
185
|
+
...o, file: okOne && (noMatte || (matteInfo && matteInfo.ok)) ? (noMatte ? ((data.files && data.files[0]) || raw) : out) : '',
|
|
186
|
+
ok: okOne && (noMatte || !!(matteInfo && matteInfo.ok)), model, denoise, seconds: (data && data.seconds) || 0,
|
|
187
|
+
raw: okOne ? '' : line.slice(0, 400), matte: matteInfo,
|
|
188
|
+
})
|
|
189
|
+
console.log(okOne ? `✓ ${o.name} 出图完成(${(data.seconds || 0)}s)` : `✗ ${o.name} 失败:${line.slice(0, 300)}`)
|
|
190
|
+
}
|
|
191
|
+
const reportPath = join(outDir, 'report.json')
|
|
192
|
+
writeFileSync(reportPath, JSON.stringify({ day, base, model, denoise, items: report }, null, 2), 'utf8')
|
|
193
|
+
const okN = report.filter((x) => x.ok).length
|
|
194
|
+
console.log(`\n${okN}/${report.length} 张成功 · 报告 ${reportPath}`)
|
|
195
|
+
console.log('人工择优后:把选中的图复制到 assets/pet-outfits/xiaolan/<outfit>/pose/ 并在 manifest.json 里加一条 outfit。')
|
|
196
|
+
return okN === report.length ? 0 : 1
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function help() {
|
|
200
|
+
console.log(`qqbot flows
|
|
201
|
+
|
|
202
|
+
node scripts/flows.mjs list
|
|
203
|
+
node scripts/flows.mjs doctor
|
|
204
|
+
node scripts/flows.mjs version patch|minor|major
|
|
205
|
+
node scripts/flows.mjs sync
|
|
206
|
+
node scripts/flows.mjs security # 安全 / 隐私审计(发布流程第 1 步,也会被 release-all 调用)
|
|
207
|
+
node scripts/flows.mjs storage list|stats # 过程性文件分区表 / 占用
|
|
208
|
+
node scripts/flows.mjs clean [--area vision,tmp] [--older-than 3] [--dry-run]
|
|
209
|
+
node scripts/flows.mjs pet --count 2 [--model krea] [--denoise 0.55] [--outfit sakura-kimono]
|
|
210
|
+
`)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const [cmd, ...rest] = process.argv.slice(2)
|
|
214
|
+
let code = 0
|
|
215
|
+
if (cmd === 'doctor') code = doctor()
|
|
216
|
+
else if (cmd === 'version') code = version(rest[0])
|
|
217
|
+
else if (cmd === 'sync') code = run(process.execPath, [join(ROOT, 'scripts', 'sync-plugin-copies.mjs')]) ? 0 : 1
|
|
218
|
+
else if (cmd === 'security') code = run(process.execPath, [join(ROOT, 'scripts', 'security-check.mjs'), ...rest]) ? 0 : 1
|
|
219
|
+
else if (cmd === 'storage') code = run(process.execPath, [join(ROOT, 'scripts', 'storage.mjs'), rest[0] || 'list', ...rest.slice(1)]) ? 0 : 1
|
|
220
|
+
else if (cmd === 'clean') code = run(process.execPath, [join(ROOT, 'scripts', 'storage.mjs'), 'clean', ...rest]) ? 0 : 1
|
|
221
|
+
else if (cmd === 'pet') code = pet(rest)
|
|
222
|
+
else if (cmd === 'list' || !cmd) help()
|
|
223
|
+
else { console.error('未知流程: ' + cmd); help(); code = 1 }
|
|
224
|
+
process.exitCode = code
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
chcp 65001 >nul
|
|
3
|
+
setlocal EnableExtensions EnableDelayedExpansion
|
|
4
|
+
set "ROOT=F:\qqbot\services\gateway"
|
|
5
|
+
set "PY=E:\Anaconda\envs\ai25\python.exe"
|
|
6
|
+
set "OUT=F:\qqbot\logs\gateway.out.log"
|
|
7
|
+
set "PIDFILE=%ROOT%\gateway.pid"
|
|
8
|
+
set "BASE=http://127.0.0.1:8090"
|
|
9
|
+
|
|
10
|
+
if /I "%~1"=="start" goto :start
|
|
11
|
+
if /I "%~1"=="stop" goto :stop
|
|
12
|
+
if /I "%~1"=="restart" goto :restart
|
|
13
|
+
if /I "%~1"=="status" goto :status
|
|
14
|
+
if /I "%~1"=="panel-url" goto :panel
|
|
15
|
+
if /I "%~1"=="panel" goto :panel
|
|
16
|
+
if /I "%~1"=="log" goto :log
|
|
17
|
+
goto :usage
|
|
18
|
+
|
|
19
|
+
:start
|
|
20
|
+
call :probe
|
|
21
|
+
if not errorlevel 1 (
|
|
22
|
+
echo [gateway] �Ѿ������У�%BASE%
|
|
23
|
+
call :status
|
|
24
|
+
exit /b 0
|
|
25
|
+
)
|
|
26
|
+
if not exist "%ROOT%\app.py" (
|
|
27
|
+
echo [gateway] �Ҳ��� %ROOT%\app.py
|
|
28
|
+
exit /b 1
|
|
29
|
+
)
|
|
30
|
+
if not exist "F:\qqbot\logs" mkdir "F:\qqbot\logs"
|
|
31
|
+
echo [gateway] ������...
|
|
32
|
+
start "" /b "%PY%" "%ROOT%\app.py" >>"%OUT%" 2>&1
|
|
33
|
+
set /a tries=0
|
|
34
|
+
:waitloop
|
|
35
|
+
set /a tries+=1
|
|
36
|
+
%SystemRoot%\System32\ping.exe -n 2 127.0.0.1 >nul
|
|
37
|
+
call :probe
|
|
38
|
+
if not errorlevel 1 goto :started
|
|
39
|
+
if %tries% GEQ 20 (
|
|
40
|
+
echo [gateway] ����ʧ�ܣ������־��
|
|
41
|
+
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Command "Get-Content -Tail 25 '%OUT%'"
|
|
42
|
+
exit /b 1
|
|
43
|
+
)
|
|
44
|
+
goto :waitloop
|
|
45
|
+
:started
|
|
46
|
+
echo [gateway] ��������
|
|
47
|
+
call :status
|
|
48
|
+
exit /b 0
|
|
49
|
+
|
|
50
|
+
:stop
|
|
51
|
+
call :probe
|
|
52
|
+
if errorlevel 1 (
|
|
53
|
+
echo [gateway] û�������С�
|
|
54
|
+
goto :cleanpid
|
|
55
|
+
)
|
|
56
|
+
if exist "%PIDFILE%" (
|
|
57
|
+
set "GPID="
|
|
58
|
+
for /f "usebackq delims=" %%g in ("%PIDFILE%") do set "GPID=%%g"
|
|
59
|
+
if defined GPID taskkill /F /PID !GPID! >nul 2>&1
|
|
60
|
+
)
|
|
61
|
+
%SystemRoot%\System32\ping.exe -n 2 127.0.0.1 >nul
|
|
62
|
+
call :probe
|
|
63
|
+
if not errorlevel 1 (
|
|
64
|
+
echo [gateway] �� pid ûͣ�����İ��˿� 8090 ����...
|
|
65
|
+
for /f "tokens=5" %%p in ('netstat -ano ^| findstr /c:":8090 " ^| findstr /i "LISTENING"') do (
|
|
66
|
+
taskkill /F /PID %%p >nul 2>&1
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
%SystemRoot%\System32\ping.exe -n 2 127.0.0.1 >nul
|
|
70
|
+
call :probe
|
|
71
|
+
if not errorlevel 1 (
|
|
72
|
+
echo [gateway] ֹͣʧ�ܣ����ֶ���� 8090 �˿ڡ�
|
|
73
|
+
exit /b 1
|
|
74
|
+
)
|
|
75
|
+
echo [gateway] ��ֹͣ��
|
|
76
|
+
:cleanpid
|
|
77
|
+
if exist "%PIDFILE%" del /q "%PIDFILE%" >nul 2>&1
|
|
78
|
+
exit /b 0
|
|
79
|
+
|
|
80
|
+
:restart
|
|
81
|
+
call :stop
|
|
82
|
+
%SystemRoot%\System32\ping.exe -n 2 127.0.0.1 >nul
|
|
83
|
+
goto :start
|
|
84
|
+
|
|
85
|
+
:status
|
|
86
|
+
call :probe
|
|
87
|
+
if errorlevel 1 (
|
|
88
|
+
echo [gateway] ״̬��δ���� ^(%BASE% ����Ӧ^)
|
|
89
|
+
exit /b 3
|
|
90
|
+
)
|
|
91
|
+
echo [gateway] ״̬�������� %BASE%
|
|
92
|
+
curl.exe -s --max-time 5 "%BASE%/healthz"
|
|
93
|
+
echo.
|
|
94
|
+
exit /b 0
|
|
95
|
+
|
|
96
|
+
:panel
|
|
97
|
+
call :probe
|
|
98
|
+
if errorlevel 1 (
|
|
99
|
+
echo [gateway] ��û��������ִ�У�%~nx0 start
|
|
100
|
+
exit /b 3
|
|
101
|
+
)
|
|
102
|
+
start "" "%BASE%/"
|
|
103
|
+
echo [gateway] �Ѵ���壺%BASE%/
|
|
104
|
+
exit /b 0
|
|
105
|
+
|
|
106
|
+
:log
|
|
107
|
+
if exist "F:\qqbot\logs\gateway.log" (
|
|
108
|
+
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Command "Get-Content -Tail 30 -Encoding UTF8 'F:\qqbot\logs\gateway.log'"
|
|
109
|
+
) else (
|
|
110
|
+
echo ��û��������־��
|
|
111
|
+
)
|
|
112
|
+
exit /b 0
|
|
113
|
+
|
|
114
|
+
:probe
|
|
115
|
+
curl.exe -s -o nul --max-time 2 "%BASE%/healthz"
|
|
116
|
+
exit /b %errorlevel%
|
|
117
|
+
|
|
118
|
+
:usage
|
|
119
|
+
echo �÷���%~nx0 {start^|stop^|restart^|status^|panel-url^|log}
|
|
120
|
+
echo start �������� ^(127.0.0.1:8090^)
|
|
121
|
+
echo stop ֹͣ����
|
|
122
|
+
echo restart ����
|
|
123
|
+
echo status ������״̬ ^(JSON^)
|
|
124
|
+
echo panel-url ��Ĭ������������
|
|
125
|
+
echo log ����� 30 ��������־
|
|
126
|
+
exit /b 1
|