12 个视觉参考图库与浏览器无限画布 AI 创作台(5,700+ 素材、中英提示词、多图对比、ComfyUI & MCP)· Visual reference library & infinite-canvas AI studio in the browser
JavaScript ai-artai-try-onchinesecloudflare-pagescomfyuidrawing-referencefashiongeminigpt-imageimage-generationinfinite-canvasmcpmoodboardoutfit-referencepose-referencepromptpwareference-boardseedreamvirtual-try-on
chore: fix Windows offline test compatibility and add daily GitHub patrol workflow
atuizz58724b2cc223
diff --git a/.github/workflows/patrol.yml b/.github/workflows/patrol.ymlnew file mode 100644index 0000000..d384b41--- /dev/null+++ b/.github/workflows/patrol.yml@@ -0,0 +1,53 @@+name: Daily Patrol+on:+ schedule:+ # Runs daily at 02:00 UTC (10:00 CST)+ - cron: '0 2 * * *'+ workflow_dispatch:++permissions:+ contents: read+ issues: read+ pull-requests: read++jobs:+ live-and-community:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-node@v4+ with:+ node-version: 24+ - name: Check live site, proxy, catalogs and image hosts+ run: |+ {+ echo "### Live Site Health"+ echo '```'+ node scripts/patrol-live.mjs+ echo '```'+ } >> "$GITHUB_STEP_SUMMARY"+ - name: Summarize open issues and pull requests+ env:+ GH_TOKEN: ${{ github.token }}+ run: |+ {+ echo "### Open Pull Requests"+ prs=$(gh pr list --state open --limit 20 --json number,title,author,mergeable,updatedAt --jq '.[] | "- #\(.number) \(.title) (@\(.author.login), \(.mergeable), updated \(.updatedAt[:10]))"')+ if [ -n "$prs" ]; then echo "$prs"; else echo "_None_"; fi+ echo ""+ echo "### Open Issues"+ issues=$(gh issue list --state open --limit 20 --json number,title,author,updatedAt --jq '.[] | "- #\(.number) \(.title) (@\(.author.login), updated \(.updatedAt[:10]))"')+ if [ -n "$issues" ]; then echo "$issues"; else echo "_None_"; fi+ } >> "$GITHUB_STEP_SUMMARY"++ offline-guard:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-node@v4+ with:+ node-version: 24+ cache: npm+ - run: npm ci+ - run: npx playwright install --with-deps chromium+ - run: npm run test:offlinediff --git a/AGENTS.md b/AGENTS.mdindex 87b59ba..4f15212 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,6 +1,6 @@# AGENTS.md — 衣姿 PoseWear 开发与交接手册-给接手本项目的开发者 / AI 看的运行手册。用户向说明在 README.md(四语:中/英/日/越),这里只讲怎么开发、构建、测试、部署和避坑。+给接手本项目的开发者 / AI 看的运行手册。用户向说明在 README.md(五语:中/英/日/越/土),这里只讲怎么开发、构建、测试、部署和避坑。## 项目速览@@ -24,7 +24,7 @@| `src/command-palette.js` | 全局 `⌘K` 命令面板(`window.PoseWearCommandPalette`) || `src/board-export.js` | 参考画板高分 PNG 拼贴导出(`window.PoseWearBoardExport`) || `src/references.js` | 浏览器与 MCP 共用选定视角、公开图片地址与复制文本的格式 |-| `src/i18n.js` | 中英日越界面词条与语言切换,`pwUiLocale` 独立于提示词设置 |+| `src/i18n.js` | 中英日越土界面词条与语言切换,`pwUiLocale` 独立于提示词设置 || `src/studio.js` | 工作台选材、提示词、生成与结果;对外接口是 `window.WB` || `src/image-providers.js` | 悬浮及完整工作台共用的生图服务商协议、连接测试和错误解析 || `src/theme.js` | 首屏外观、系统主题与用户选择的同步 |@@ -122,8 +122,8 @@ U=http://127.0.0.1:8902 npm test## 约定-- 默认 UI 文案简体中文,同时维护英文、日文、越南文词条;品牌红 `#ff2442` 点缀、白底干净、**不用黄色/金色**;页面忌文字堆砌。+- 默认 UI 文案简体中文,同时维护英文、日文、越南文、土耳其文词条;品牌红 `#ff2442` 点缀、白底干净、**不用黄色/金色**;页面忌文字堆砌。- 提交:显式列文件路径提交,**不要 `git add -A`**(工作区常有 dist-assets 等大目录未跟踪)。-- 发版:四语 README 版本号与 `CHANGELOG.md` 同步更新,GitHub Release 用 API 建,tag 形如 `v1.4.0`。+- 发版:五语 README 版本号与 `CHANGELOG.md` 同步更新,GitHub Release 用 API 建,tag 形如 `v1.4.0`。- 生产红线:部署、合并 PR、回议题已获维护者长期授权(2026-11-22);新功能/动架构/花钱的事先问维护者。- Web Analytics:代码已支持(`POSEWEAR_WA_TOKEN` 构建注入 + CSP 放行),差 Cloudflare 后台 Pages → posewear → Metrics 开启或给站点令牌,开后验 beacon 上线。diff --git a/scripts/patrol-live.mjs b/scripts/patrol-live.mjsnew file mode 100644index 0000000..ecb85ce--- /dev/null+++ b/scripts/patrol-live.mjs@@ -0,0 +1,87 @@+#!/usr/bin/env node+/**+ * Live site health patrol for PoseWear (used by scheduled GitHub Actions & manual checks).+ * Verifies home page + CSP, /api/proxy CORS preflight, all 12 fingerprinted catalogs,+ * and sample R2 / same-origin / hotlink image availability.+ */++import { catalogIndex, catalogNames, publishedSite, readCatalog } from './catalog-source.mjs';++const SITE = (process.env.POSEWEAR_SITE || publishedSite).replace(/\/?$/, '/');++function assert(cond, msg) {+ if (!cond) throw new Error(msg);+}++async function headOk(url, label) {+ const res = await fetch(url, { method: 'HEAD', signal: AbortSignal.timeout(15000) });+ assert(res.ok, `${label} failed (${res.status}): ${url}`);+ return res.status;+}++async function main() {+ const checks = [];++ // 1. Home page & CSP header+ const homeRes = await fetch(SITE, { signal: AbortSignal.timeout(20000) });+ assert(homeRes.status === 200, `Home returned HTTP ${homeRes.status}`);+ const csp = homeRes.headers.get('content-security-policy') || '';+ assert(csp.includes("img-src") && csp.includes("connect-src"), 'Home response missing CSP img-src/connect-src');+ checks.push(`Home 200 OK (CSP present)`);++ // 2. /api/proxy CORS preflight+ const proxyRes = await fetch(new URL('/api/proxy', SITE), {+ method: 'OPTIONS',+ headers: { Origin: new URL(SITE).origin },+ signal: AbortSignal.timeout(15000),+ });+ assert(proxyRes.status === 204, `/api/proxy OPTIONS returned HTTP ${proxyRes.status} (expected 204)`);+ checks.push(`/api/proxy OPTIONS 204 OK`);++ // 3. Discover and verify all 12 fingerprinted catalogs+ const index = await catalogIndex(SITE);+ const counts = {};+ let samplePoseThumb = null;+ let samplePoseMid = null;+ let sampleHotlink = null;++ for (let i = 0; i < catalogNames.length; i += 4) {+ await Promise.all(catalogNames.slice(i, i + 4).map(async name => {+ const { items } = await readCatalog(index, name);+ assert(items.length > 0, `Catalog ${name} is empty`);+ counts[name] = items.length;+ if (name === 'poses' && items[0]?.angles?.[0]) {+ samplePoseThumb = new URL(items[0].angles[0].t, index.assetHost).href;+ samplePoseMid = new URL(items[0].angles[0].i, index.site).href;+ }+ if (name === 'hair') {+ const ext = items.find(it => typeof it.t === 'string' && it.t.startsWith('https://'));+ if (ext) sampleHotlink = ext.t;+ }+ }));+ }+ const total = Object.values(counts).reduce((a, b) => a + b, 0);+ checks.push(`12 catalogs verified (${total.toLocaleString('en-US')} total entries)`);++ // 4. Sample image delivery across R2, same-origin, and hotlink+ if (samplePoseThumb) {+ await headOk(samplePoseThumb, 'R2 thumbnail');+ checks.push(`R2 thumb 200 OK`);+ }+ if (samplePoseMid) {+ await headOk(samplePoseMid, 'Same-origin mid image');+ checks.push(`Same-origin mid 200 OK`);+ }+ if (sampleHotlink) {+ await headOk(sampleHotlink, 'Hotlink image');+ checks.push(`Hotlink image 200 OK`);+ }++ console.log('PATROL_PASS');+ for (const line of checks) console.log(' -', line);+}++main().catch(err => {+ console.error('PATROL_FAIL:', err.message);+ process.exit(1);+});diff --git a/scripts/preview.mjs b/scripts/preview.mjsindex a27cb63..564bc5a 100644--- a/scripts/preview.mjs+++ b/scripts/preview.mjs@@ -38,12 +38,19 @@ function publishedSnapshot() {snapshot ??= discover().catch(error => { snapshot = undefined; throw error; });return snapshot;}+function streamOut(res, body) {+ const stream = Readable.fromWeb(body);+ // Drop only the aborted response when upstream resets mid-stream instead of crashing the preview process.+ stream.on('error', () => { if (!res.writableEnded) res.destroy(); });+ res.on('error', () => {});+ stream.pipe(res);+}async function remote(res, url, method, successStatus) {const r = await fetch(url, { method });const headers = {};for (const key of ['content-type','cache-control']) if (r.headers.has(key)) headers[key] = r.headers.get(key);res.writeHead(r.ok && successStatus ? successStatus : r.status, headers);- if (r.body) Readable.fromWeb(r.body).pipe(res); else res.end();+ if (r.body) streamOut(res, r.body); else res.end();return r.status;}const server = http.createServer(async (req,res) => {@@ -58,7 +65,7 @@ const server = http.createServer(async (req,res) => {...(req.method==='POST'?{body:Readable.toWeb(req),duplex:'half'}:{})});const reply = await localRequest(engine,request);res.writeHead(reply.status,Object.fromEntries(reply.headers));- if(reply.body) Readable.fromWeb(reply.body).pipe(res); else res.end();+ if(reply.body) streamOut(res, reply.body); else res.end();return;}if (u.pathname === '/api/proxy') {@@ -66,7 +73,7 @@ const server = http.createServer(async (req,res) => {...(req.method === 'POST' ? {body:Readable.toWeb(req),duplex:'half'} : {})});const response = await onRequest({request,env:process.env});res.writeHead(response.status,Object.fromEntries(response.headers));- if (response.body) Readable.fromWeb(response.body).pipe(res); else res.end();+ if (response.body) streamOut(res, response.body); else res.end();return;}if (!['GET','HEAD'].includes(req.method)) return res.writeHead(405).end();diff --git a/tests/build-post-regressions.mjs b/tests/build-post-regressions.mjsindex 8a8c570..ff6dc50 100644--- a/tests/build-post-regressions.mjs+++ b/tests/build-post-regressions.mjs@@ -2,8 +2,20 @@ import { spawnSync } from 'node:child_process';import { fileURLToPath } from 'node:url';const script = fileURLToPath(new URL('./build-post-regressions.py', import.meta.url));-const python = process.env.PYTHON || 'python3';-const result = spawnSync(python, [script], { stdio: 'inherit' });+const env = { ...process.env, PYTHONUTF8: '1', PYTHONIOENCODING: 'utf-8' };++const candidates = process.env.PYTHON+ ? [[process.env.PYTHON, []]]+ : process.platform === 'win32'+ ? [['python', []], ['py', ['-3']], ['python3', []]]+ : [['python3', []], ['python', []]];++let result;+for (const [cmd, prefix] of candidates) {+ result = spawnSync(cmd, [...prefix, script], { stdio: 'inherit', env });+ if (!result.error || result.error.code !== 'ENOENT') break;+}+if (result.error) {console.error(result.error.message);process.exit(1);diff --git a/tests/build-post-regressions.py b/tests/build-post-regressions.pyindex f420cfe..ee59c9c 100644--- a/tests/build-post-regressions.py+++ b/tests/build-post-regressions.py@@ -29,17 +29,17 @@ def _check_static_invariants():# 2. Ensure exec() glue has been eliminated from build.py / post.py / seo.pyfor name in ('build.py', 'post.py', 'seo.py'):- text = (ROOT / name).read_text()+ text = (ROOT / name).read_text(encoding='utf-8')_assert('exec(' not in text, f'{name} must not use exec() glue')# 3. Every local script/stylesheet referenced by src/index.html must be in post.CLIENT_FILES and src/sw.js- index_html = (ROOT / 'src/index.html').read_text()+ index_html = (ROOT / 'src/index.html').read_text(encoding='utf-8')referenced = set(re.findall(r'<script\b[^>]*\bsrc="([^":/]+\.js)"', index_html))referenced |= set(re.findall(r'<link\b[^>]*\brel="stylesheet"[^>]*\bhref="([^":/]+\.css)"', index_html))client_set = set(post.CLIENT_FILES)_assert(referenced == client_set, f'CLIENT_FILES mismatch with src/index.html: missing={referenced - client_set}, extra={client_set - referenced}')- sw_text = (ROOT / 'src/sw.js').read_text()+ sw_text = (ROOT / 'src/sw.js').read_text(encoding='utf-8')sw_precache = set(re.findall(r"'([^']+\.(?:js|css))'", sw_text))_assert(client_set <= sw_precache, f'src/sw.js PRECACHE missing client files: {client_set - sw_precache}')@@ -262,14 +262,14 @@ def _run_pipeline_regression():_assert(not (dist / name).exists(), f'Unhashed file was not removed: {name}')# 3. Compiled app.js matches catalog-source.mjs discovery contracts- app_js = (dist / assets['app.js']).read_text()+ app_js = (dist / assets['app.js']).read_text(encoding='utf-8')_assert("const AH='https://pwimg.0vo.pro/';" in app_js, 'AH asset host injection failed')discovered = set(re.findall(r'["\'](?:/assets/)?([a-z]+)\.[a-f0-9]{10}\.json["\']', app_js))expected_catalogs = {f.removesuffix('.json') for f in post.CATALOG_FILES}_assert(discovered == expected_catalogs, f'app.js catalog discovery mismatch: {expected_catalogs - discovered}')# 4. index.html references all hashed client files, stats, SSR cards, footer index, WA beacon- idx = (dist / 'index.html').read_text()+ idx = (dist / 'index.html').read_text(encoding='utf-8')for name in post.CLIENT_FILES:_assert(f'"/{assets[name]}"' in idx, f'index.html missing hashed reference for {name}')_assert('data-stat="pose" data-n="1" data-na="2"' in idx, 'pose stat counter mismatch')@@ -279,13 +279,13 @@ def _run_pipeline_regression():_assert('data-cf-beacon=\'{"token": "test-wa-token-123"}\'' in idx, 'Web Analytics beacon missing')# 5. Service Worker precache updated with hashed files- sw = (dist / 'sw.js').read_text()+ sw = (dist / 'sw.js').read_text(encoding='utf-8')_assert("'posewear-development'" not in sw, 'sw.js version was not fingerprinted')for name in post.CLIENT_FILES + ['poses.json', 'depths.json']:_assert(f'"/{assets[name]}"' in sw, f'sw.js PRECACHE missing {name}')# 6. _headers CSP allows WA beacon, hotlinks, asset host, and loopback http- headers = (dist / '_headers').read_text()+ headers = (dist / '_headers').read_text(encoding='utf-8')for token in ('https://static.cloudflareinsights.com','https://pwimg.0vo.pro',@@ -329,9 +329,9 @@ def _run_pipeline_regression():# CharaDB hotlink anime outfit must NOT generate static detail page_assert(not (dist / 'anime/cdb_001/index.html').exists(), 'External hotlink anime item leaked into static detail page')- key = (tmp_path / 'indexnow.key').read_text().strip()- _assert((dist / f'{key}.txt').read_text().strip() == key, 'IndexNow key file mismatch')- _assert((tmp_path / 'urls.txt').read_text().strip().splitlines(), 'urls.txt is empty')+ key = (tmp_path / 'indexnow.key').read_text(encoding='utf-8').strip()+ _assert((dist / f'{key}.txt').read_text(encoding='utf-8').strip() == key, 'IndexNow key file mismatch')+ _assert((tmp_path / 'urls.txt').read_text(encoding='utf-8').strip().splitlines(), 'urls.txt is empty')if __name__ == '__main__':diff --git a/tests/reference-regressions.js b/tests/reference-regressions.jsindex 3f72d57..5e56e50 100644--- a/tests/reference-regressions.js+++ b/tests/reference-regressions.js@@ -35,7 +35,7 @@ async function run() {});await page.goto('https://posewear.test/#pose');const card=page.locator('#grid .card').first();- const clipboard=()=>page.evaluate(()=>navigator.clipboard.readText());+ const clipboard=()=>page.evaluate(async()=>(await navigator.clipboard.readText()).replace(/\r\n/g,'\n'));async function copied(button) {await page.evaluate(()=>navigator.clipboard.writeText(''));await button.click();