@clawdao/limschain-agent 0.5.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/.env.example +41 -0
- package/CHANGELOG.md +223 -0
- package/Dockerfile +50 -0
- package/LICENSE +21 -0
- package/README.md +627 -0
- package/bin/lims-mcp.mjs +101 -0
- package/bin/lims.mjs +1639 -0
- package/docs/MARKETPLACE-GUIDELINES.md +99 -0
- package/docs/clawdao-mcp-listing.md +308 -0
- package/docs/clawdao-mcp-setup.md +294 -0
- package/docs/ddn-hub-postType-issue.md +54 -0
- package/docs/deploy-http.md +192 -0
- package/docs/install-mcp.md +268 -0
- package/docs/limschain-migration-and-readme-backfill.md +212 -0
- package/docs/marketplace-readmes/clawdao-video-factory.md +49 -0
- package/docs/node-free-install.md +196 -0
- package/docs/release-notes/v1.0.30-short.md +63 -0
- package/docs/site-design-studio-api.md +162 -0
- package/lib/articles.mjs +397 -0
- package/lib/client.mjs +588 -0
- package/lib/courses.mjs +169 -0
- package/lib/dao.mjs +195 -0
- package/lib/env.mjs +32 -0
- package/lib/feedback.mjs +68 -0
- package/lib/http-server.mjs +257 -0
- package/lib/marketplace-readme-path.mjs +17 -0
- package/lib/marketplace.mjs +273 -0
- package/lib/materials.mjs +260 -0
- package/lib/mcp-server.mjs +334 -0
- package/lib/site.mjs +471 -0
- package/lib/versions.mjs +904 -0
- package/mcp-listing.http.json +25 -0
- package/mcp-listing.json +34 -0
- package/package.json +77 -0
- package/scripts/build-binary.mjs +104 -0
- package/scripts/build-site-dashboard.mjs +52 -0
- package/scripts/collect-site-articles.mjs +432 -0
- package/scripts/export-ddn-env.mjs +107 -0
- package/scripts/fetch-article-stats.mjs +212 -0
- package/scripts/pack-and-verify.mjs +111 -0
- package/scripts/publisher.mjs +255 -0
- package/scripts/sync-marketplace-readme.mjs +380 -0
- package/scripts/tool-set.mjs +48 -0
- package/scripts/verify-binary.mjs +115 -0
- package/scripts/verify-clawdao-bridge.mjs +41 -0
- package/scripts/verify-e2e.mjs +176 -0
- package/scripts/verify-http-mcp.mjs +94 -0
- package/scripts/verify-listing-sync.mjs +90 -0
- package/scripts/verify-marketplace-readme.mjs +266 -0
- package/scripts/verify-mcp-handshake.mjs +98 -0
- package/scripts/verify-news-publish.mjs +257 -0
- package/scripts/verify-npx-install.mjs +171 -0
- package/scripts/verify-site-dashboard.mjs +87 -0
- package/scripts/verify-site-layout.mjs +194 -0
- package/tests/client-auth.test.mjs +159 -0
- package/tests/dao-profile.test.mjs +126 -0
- package/tests/marketplace-readme-path.test.mjs +16 -0
- package/tests/mcp-server.test.mjs +187 -0
- package/tests/member-submission.test.mjs +150 -0
- package/tests/official-listing.test.mjs +52 -0
- package/tests/smoke.mjs +262 -0
- package/tests/sync-marketplace-readme.test.mjs +50 -0
- package/tests/tool-set.test.mjs +54 -0
- package/tests/versions-sync-dryrun.test.mjs +315 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* scripts/verify-mcp-handshake.mjs
|
|
4
|
+
*
|
|
5
|
+
* 复现 ClawDao sidecar `clawdao-mcp-bridge` 的 stdio 握手,验证:
|
|
6
|
+
* 1. 用「只有 PATH/HOME」的受限 env 也能起来(bridge 就是这么 spawn 的)
|
|
7
|
+
* 2. initialize + tools/list 成功,且工具数与 bin/lims-mcp.mjs 一致
|
|
8
|
+
* 3. .env 能被子进程按自身路径读到(不受 cwd 影响)
|
|
9
|
+
*
|
|
10
|
+
* 用法:node scripts/verify-mcp-handshake.mjs
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from 'node:child_process';
|
|
13
|
+
import { dirname, resolve } from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { describeToolSetDiff } from './tool-set.mjs';
|
|
16
|
+
|
|
17
|
+
const repo = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const NODE = process.execPath;
|
|
19
|
+
const SERVER = resolve(repo, 'bin/lims-mcp.mjs');
|
|
20
|
+
|
|
21
|
+
// 与 clawdao-mcp-bridge 的 env 完全一致
|
|
22
|
+
const env = { PATH: '/usr/bin:/bin:/usr/sbin:/sbin', HOME: process.env.HOME };
|
|
23
|
+
// cwd 故意设成别的目录,验证 .env 按自身路径定位
|
|
24
|
+
const cwd = '/';
|
|
25
|
+
|
|
26
|
+
const child = spawn(NODE, [SERVER], { env, cwd, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
27
|
+
|
|
28
|
+
let buf = '';
|
|
29
|
+
const pending = new Map();
|
|
30
|
+
child.stdout.on('data', (d) => {
|
|
31
|
+
buf += d.toString();
|
|
32
|
+
let idx;
|
|
33
|
+
while ((idx = buf.indexOf('\n')) >= 0) {
|
|
34
|
+
const line = buf.slice(0, idx).trim();
|
|
35
|
+
buf = buf.slice(idx + 1);
|
|
36
|
+
if (!line) continue;
|
|
37
|
+
let msg;
|
|
38
|
+
try { msg = JSON.parse(line); } catch { continue; }
|
|
39
|
+
const h = pending.get(msg.id);
|
|
40
|
+
if (h) { pending.delete(msg.id); h(msg); }
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
child.stderr.on('data', (d) => process.stderr.write(`[server stderr] ${d}`));
|
|
44
|
+
|
|
45
|
+
let nextId = 1;
|
|
46
|
+
function request(method, params) {
|
|
47
|
+
const id = nextId++;
|
|
48
|
+
return new Promise((res, rej) => {
|
|
49
|
+
const timer = setTimeout(() => rej(new Error(`${method} timeout`)), 15000);
|
|
50
|
+
pending.set(id, (msg) => { clearTimeout(timer); res(msg); });
|
|
51
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function fail(msg) {
|
|
56
|
+
console.error(`FAIL: ${msg}`);
|
|
57
|
+
child.kill();
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const init = await request('initialize', {
|
|
62
|
+
protocolVersion: '2024-11-05',
|
|
63
|
+
capabilities: {},
|
|
64
|
+
clientInfo: { name: 'clawdao-bridge-sim', version: '0.0.1' },
|
|
65
|
+
});
|
|
66
|
+
if (init.error) fail(`initialize error: ${JSON.stringify(init.error)}`);
|
|
67
|
+
console.log(`initialize OK · server=${init.result?.serverInfo?.name} v${init.result?.serverInfo?.version}`);
|
|
68
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
|
|
69
|
+
|
|
70
|
+
const list = await request('tools/list', {});
|
|
71
|
+
if (list.error) fail(`tools/list error: ${JSON.stringify(list.error)}`);
|
|
72
|
+
const tools = list.result?.tools ?? [];
|
|
73
|
+
console.log(`tools/list OK · ${tools.length} 个工具`);
|
|
74
|
+
console.log(tools.map((t) => ` - ${t.name}${t.annotations?.readOnlyHint ? ' (readOnly)' : ''}`).join('\n'));
|
|
75
|
+
|
|
76
|
+
// 冒烟一次只读调用:lims_health
|
|
77
|
+
const health = await request('tools/call', { name: 'lims_health', arguments: {} });
|
|
78
|
+
if (health.error) fail(`tools/call error: ${JSON.stringify(health.error)}`);
|
|
79
|
+
const text = health.result?.content?.find((c) => c.type === 'text')?.text ?? '';
|
|
80
|
+
const snap = JSON.parse(text);
|
|
81
|
+
const rt = snap.runtime ?? {};
|
|
82
|
+
console.log(
|
|
83
|
+
'lims_health · baseUrl=%s hasAuthToken=%s hasDaoId=%s platformScope=%s daoId=%s…',
|
|
84
|
+
rt.baseUrl,
|
|
85
|
+
rt.hasAuthToken,
|
|
86
|
+
rt.hasDaoId,
|
|
87
|
+
rt.platformScope,
|
|
88
|
+
String(rt.daoId ?? '').slice(0, 4),
|
|
89
|
+
);
|
|
90
|
+
if (!rt.hasAuthToken || !rt.hasDaoId) {
|
|
91
|
+
fail('lims_health 显示 .env 未被读到(hasAuthToken/hasDaoId 为 false)');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const toolSetProblem = describeToolSetDiff(tools);
|
|
95
|
+
if (toolSetProblem) fail(toolSetProblem);
|
|
96
|
+
console.log(`\nPASS: 受限 env 下 ${tools.length} 个工具全部可用,.env 从 / 作为 cwd 也能读到`);
|
|
97
|
+
child.kill();
|
|
98
|
+
process.exit(0);
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 资讯发布后的公开端回读校验(全程不携带 token)
|
|
4
|
+
*
|
|
5
|
+
* 用途:资讯发布后确认「官网上真的能看到」,而不是只看管理端返回 ok。
|
|
6
|
+
* - 公开 API:/api/v1/posts/:id、/api/v1/cms/public/posts/:id、/api/v1/cms/public/posts/by-slug
|
|
7
|
+
* - 状态机:status=published / compliance=approved / visibility=published / postType=news
|
|
8
|
+
* ★ compliance 必须是 approved:租户侧 publish 只改 status,公开 slug 路由
|
|
9
|
+
* (/api/v1/cms/public/posts/by-slug)与官网内容中心列表都要求已过审,
|
|
10
|
+
* 否则文章页会一直停在「加载中」。
|
|
11
|
+
* - 封面:URL HEAD 200 + 公开 slug 接口回传同一封面
|
|
12
|
+
* - 正文:与稿件逐字一致(仅去掉与标题重复的首行 H1)
|
|
13
|
+
* - 术语与敏感信息黑名单扫描(0 命中)
|
|
14
|
+
* - 渲染层(headless Chrome + CDP):
|
|
15
|
+
* F1-F6 官网文章详情页;F7-F9 官网内容中心列表页(封面图渲染处)
|
|
16
|
+
*
|
|
17
|
+
* 用法: node scripts/verify-news-publish.mjs <postId> <manuscript.md>
|
|
18
|
+
* 退出码: 0 = 全部通过;1 = 有未通过项
|
|
19
|
+
* 产物: outputs/releases/publish-news-verification.log
|
|
20
|
+
*/
|
|
21
|
+
import { readFileSync, writeFileSync, mkdirSync, mkdtempSync, rmSync, existsSync } from 'node:fs';
|
|
22
|
+
import { spawn } from 'child_process';
|
|
23
|
+
import { tmpdir } from 'node:os';
|
|
24
|
+
import { join } from 'path';
|
|
25
|
+
|
|
26
|
+
const BASE = process.env.DDN_HUB_BASE_URL || 'https://limschain.com';
|
|
27
|
+
const [postId, mdPath] = process.argv.slice(2);
|
|
28
|
+
|
|
29
|
+
const BLACKLIST = [
|
|
30
|
+
'token', '密钥', '秘钥', 'api key', 'apikey', 'secret', 'password', '口令', 'bearer', 'authorization',
|
|
31
|
+
'function', 'async', 'await', 'callback', 'promise', 'refactor', 'middleware', 'controller',
|
|
32
|
+
'useState', 'useEffect', 'props', 'hook', '组件', '函数', '方法名', 'api 接口',
|
|
33
|
+
'npm ', 'yarn ', 'pnpm ', 'git ', 'node ', 'curl ', 'bash ', 'shell', '命令行', '终端', '脚本',
|
|
34
|
+
'node_modules', 'package.json', 'eslint', 'webpack', 'vite', 'docker',
|
|
35
|
+
'egg-validate', 'egg.js', 'umi', 'mdxrenderer', 'cdp', 'devtools', 'headless',
|
|
36
|
+
'postgres', 'mysql', 'sqlite', 'redis', 'mongodb', 'nginx',
|
|
37
|
+
'http://', 'https://api', 'api/v1', 'restful', 'graphql', 'webhook', 'json', 'yaml', 'markdown', 'html',
|
|
38
|
+
'http ', 'https ', 'url ', 'endpoint', 'sdk', 'openapi', 'swagger',
|
|
39
|
+
'prompt', 'tokenizer', 'embedding', 'rag', 'llm', 'gpt',
|
|
40
|
+
'.mjs', '.js', '.ts', '.tsx', '.jsx', '.json', '.yaml', '.yml', '.env', '/usr/', '/home/', 'src/', 'lib/',
|
|
41
|
+
'outputs/', 'scripts/', 'bin/', 'github.com', 'gitee.com',
|
|
42
|
+
'ddn-hub', 'ddn-ubl', 'lims-chain', 'clawdao-limschain', 'x-platform-scope',
|
|
43
|
+
'dao_id', 'daoid', 'base_url', 'auth_token', 'coverimage', 'posttype', 'contentmarkdown',
|
|
44
|
+
'mock', 'stub', '单元测试', '压测', 'qps',
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const log = [];
|
|
48
|
+
const say = (s) => { console.log(s); log.push(s); };
|
|
49
|
+
const checks = [];
|
|
50
|
+
const check = (name, pass, detail) => { checks.push({ name, pass, detail }); say(`${pass ? '✅' : '❌'} ${name}${detail ? ' — ' + detail : ''}`); };
|
|
51
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
52
|
+
|
|
53
|
+
const scan = (text) => {
|
|
54
|
+
const lower = String(text).toLowerCase();
|
|
55
|
+
const hits = [];
|
|
56
|
+
for (const w of BLACKLIST) {
|
|
57
|
+
const i = lower.indexOf(w.toLowerCase());
|
|
58
|
+
if (i >= 0) hits.push({ w, ctx: String(text).slice(Math.max(0, i - 30), i + 40).replace(/\s+/g, ' ') });
|
|
59
|
+
}
|
|
60
|
+
return hits;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
say('══════════════════════════════════════════════════════════════');
|
|
64
|
+
say(' 亿检链资讯发布 · 公开端回读校验');
|
|
65
|
+
say(` 文章 ID: ${postId} | 稿件: ${mdPath}`);
|
|
66
|
+
say(` 时间: ${new Date().toISOString()}`);
|
|
67
|
+
say('══════════════════════════════════════════════════════════════\n');
|
|
68
|
+
|
|
69
|
+
// ---------- A. 公开 API ----------
|
|
70
|
+
say('── A. 公开端接口回读(不携带 token)──');
|
|
71
|
+
|
|
72
|
+
const rPosts = await fetch(`${BASE}/api/v1/posts/${postId}`);
|
|
73
|
+
const postsBody = await rPosts.json();
|
|
74
|
+
const post = postsBody?.data || {};
|
|
75
|
+
say(`GET ${BASE}/api/v1/posts/${postId} → HTTP ${rPosts.status}, msg=${postsBody?.msg || ''}`);
|
|
76
|
+
check('A1 公开 API 可取到文章', rPosts.ok && post.id === Number(postId), `id=${post.id}`);
|
|
77
|
+
|
|
78
|
+
const rCms = await fetch(`${BASE}/api/v1/cms/public/posts/${postId}`);
|
|
79
|
+
const cmsBody = await rCms.json();
|
|
80
|
+
const cmsData = cmsBody?.data || {};
|
|
81
|
+
say(`GET ${BASE}/api/v1/cms/public/posts/${postId} → HTTP ${rCms.status}, msg=${cmsBody?.msg || ''}`);
|
|
82
|
+
check('A2 公开 CMS 接口可取到文章', rCms.ok && cmsData.publishedPostId === Number(postId), `publishedPostId=${cmsData.publishedPostId}`);
|
|
83
|
+
|
|
84
|
+
const slug = post.slug;
|
|
85
|
+
const rSlug = await fetch(`${BASE}/api/v1/cms/public/posts/by-slug?slug=${encodeURIComponent(slug)}&categorySlug=news`);
|
|
86
|
+
const slugBody = await rSlug.json();
|
|
87
|
+
const slugData = slugBody?.data || {};
|
|
88
|
+
say(`GET ${BASE}/api/v1/cms/public/posts/by-slug?slug=${slug}&categorySlug=news → HTTP ${rSlug.status}, msg=${slugBody?.msg || ''}`);
|
|
89
|
+
check('A3 公开按 slug 路由可取到文章(官网文章页依赖此接口)', rSlug.ok && slugData.publishedPostId === Number(postId), `publishedPostId=${slugData.publishedPostId}`);
|
|
90
|
+
|
|
91
|
+
// ---------- B. 状态机 ----------
|
|
92
|
+
say('\n── B. 发布状态机 ──');
|
|
93
|
+
check('B1 status = published', post.status === 'published', `status=${post.status}`);
|
|
94
|
+
check('B2 visibilityStatus = published', post.visibilityStatus === 'published', `visibility=${post.visibilityStatus}`);
|
|
95
|
+
check('B3 complianceStatus = approved(公开 slug 路由与官网列表依赖)', post.complianceStatus === 'approved', `compliance=${post.complianceStatus}`);
|
|
96
|
+
check('B4 postType = news(资讯)', post.postType === 'news', `postType=${post.postType}`);
|
|
97
|
+
|
|
98
|
+
// ---------- C. 封面 ----------
|
|
99
|
+
say('\n── C. 封面图 ──');
|
|
100
|
+
const cover = post.coverImage;
|
|
101
|
+
if (cover) {
|
|
102
|
+
const h = await fetch(cover, { method: 'HEAD' });
|
|
103
|
+
say(`HEAD ${cover} → HTTP ${h.status}`);
|
|
104
|
+
check('C1 封面 URL HEAD 200', h.status === 200, `type=${h.headers.get('content-type')}, size=${h.headers.get('content-length')} bytes`);
|
|
105
|
+
check('C2 公开 slug 接口返回同一封面', slugData.coverUrl === cover, `coverUrl=${slugData.coverUrl}`);
|
|
106
|
+
} else {
|
|
107
|
+
check('C1 封面 URL HEAD 200', false, 'coverImage 为空');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ---------- D. 正文一致性 ----------
|
|
111
|
+
say('\n── D. 正文与稿件一致性 ──');
|
|
112
|
+
const md = readFileSync(mdPath, 'utf-8');
|
|
113
|
+
const mdHead = md.match(/^# (.+)$/m)?.[1]?.trim();
|
|
114
|
+
const mdBody = md.replace(/^# .+\n+/m, '').replace(/^(?:> .+\n)+\n*/m, '');
|
|
115
|
+
const pubContent = String(post.content || '');
|
|
116
|
+
const pubMd = String(post.contentMarkdown || '');
|
|
117
|
+
const slugContent = String(slugData.renderInput?.content || '');
|
|
118
|
+
|
|
119
|
+
check('D1 公开端标题 = 稿件 H1 标题', post.title === mdHead, `title="${post.title}"`);
|
|
120
|
+
check('D2 content 与稿件逐字一致(仅去掉与标题重复的首行 H1)', pubContent === mdBody, `len(pub)=${pubContent.length} len(md)=${mdBody.length}`);
|
|
121
|
+
check('D3 contentMarkdown 与 content 完全一致', pubMd === pubContent, `len(mdField)=${pubMd.length}`);
|
|
122
|
+
check('D4 公开 slug 接口正文与 content 一致', slugContent === pubContent, `len(slugRender)=${slugContent.length}`);
|
|
123
|
+
check('D5 正文未被插入多余说明文字', !pubContent.includes('完整 markdown 见'), '无 publisher 占位说明文字');
|
|
124
|
+
check('D6 正文首行非 H1(不与标题重复展示)', !pubContent.startsWith('# '), '首行非 H1');
|
|
125
|
+
|
|
126
|
+
// ---------- E. 术语 / 敏感信息扫描 ----------
|
|
127
|
+
say('\n── E. 术语与敏感信息黑名单扫描 ──');
|
|
128
|
+
for (const [label, text] of [
|
|
129
|
+
['公开 content', pubContent],
|
|
130
|
+
['公开 contentMarkdown', pubMd],
|
|
131
|
+
['公开 slug 渲染正文', slugContent],
|
|
132
|
+
['公开摘要 description', String(post.description || '')],
|
|
133
|
+
]) {
|
|
134
|
+
const hits = scan(text);
|
|
135
|
+
check(`E1 ${label} 黑名单命中 = 0`, hits.length === 0, hits.length ? JSON.stringify(hits) : `0 命中 / ${String(text).length} 字符`);
|
|
136
|
+
}
|
|
137
|
+
check('E2 标题不含敏感信息', scan(String(post.title || '')).length === 0, '0 命中');
|
|
138
|
+
|
|
139
|
+
// ---------- F. 渲染层(headless Chrome) ----------
|
|
140
|
+
say('\n── F. 渲染层校验(headless Chrome + CDP)──');
|
|
141
|
+
const CHROME_CANDIDATES = [
|
|
142
|
+
process.env.CHROME_PATH,
|
|
143
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
144
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium',
|
|
145
|
+
'/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
|
146
|
+
'/usr/bin/google-chrome',
|
|
147
|
+
'/usr/bin/chromium',
|
|
148
|
+
].filter(Boolean);
|
|
149
|
+
const chrome = CHROME_CANDIDATES.find((p) => existsSync(p));
|
|
150
|
+
|
|
151
|
+
/** 打开页面并返回 { href, title, text, imgs } */
|
|
152
|
+
const renderPage = async (url, waitMs = 11000) => {
|
|
153
|
+
const profileDir = mkdtempSync(join(tmpdir(), 'lims-verify-'));
|
|
154
|
+
const port = 9300 + Math.floor(Math.random() * 500);
|
|
155
|
+
const child = spawn(chrome, ['--headless=new', '--disable-gpu', '--hide-scrollbars', '--no-first-run',
|
|
156
|
+
`--remote-debugging-port=${port}`, `--user-data-dir=${profileDir}`, 'about:blank'], { stdio: 'ignore' });
|
|
157
|
+
try {
|
|
158
|
+
let ready = false;
|
|
159
|
+
for (let i = 0; i < 60 && !ready; i++) {
|
|
160
|
+
try { const v = await fetch(`http://127.0.0.1:${port}/json/version`); ready = v.ok; } catch { /* retry */ }
|
|
161
|
+
if (!ready) await sleep(250);
|
|
162
|
+
}
|
|
163
|
+
if (!ready) throw new Error('Chrome 调试端口未就绪');
|
|
164
|
+
|
|
165
|
+
const targets = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json();
|
|
166
|
+
const page = targets.find((t) => t.type === 'page');
|
|
167
|
+
const ws = new WebSocket(page.webSocketDebuggerUrl);
|
|
168
|
+
let msgId = 0;
|
|
169
|
+
const pending = new Map();
|
|
170
|
+
ws.addEventListener('message', (e) => {
|
|
171
|
+
const m = JSON.parse(e.data);
|
|
172
|
+
if (m.id && pending.has(m.id)) { pending.get(m.id)(m.result); pending.delete(m.id); }
|
|
173
|
+
});
|
|
174
|
+
await new Promise((res, rej) => { ws.addEventListener('open', res, { once: true }); ws.addEventListener('error', rej, { once: true }); });
|
|
175
|
+
const send = (method, params = {}) => new Promise((res) => { const mid = ++msgId; pending.set(mid, res); ws.send(JSON.stringify({ id: mid, method, params })); });
|
|
176
|
+
|
|
177
|
+
await send('Page.enable');
|
|
178
|
+
await send('Emulation.setDeviceMetricsOverride', { width: 1440, height: 1200, deviceScaleFactor: 1, mobile: false });
|
|
179
|
+
await send('Page.navigate', { url });
|
|
180
|
+
await sleep(waitMs);
|
|
181
|
+
await send('Runtime.evaluate', { expression: `window.scrollTo(0, document.body.scrollHeight); 'ok'` });
|
|
182
|
+
await sleep(2000);
|
|
183
|
+
const { result } = await send('Runtime.evaluate', {
|
|
184
|
+
returnByValue: true,
|
|
185
|
+
expression: `(() => ({
|
|
186
|
+
href: location.href,
|
|
187
|
+
docTitle: document.title,
|
|
188
|
+
text: document.body.innerText || '',
|
|
189
|
+
imgs: [...document.images].map(i => ({ src: i.currentSrc || i.src || '', ok: i.naturalWidth > 0, w: i.naturalWidth, h: i.naturalHeight, visible: !!(i.offsetWidth || i.offsetHeight) })),
|
|
190
|
+
}))()`,
|
|
191
|
+
});
|
|
192
|
+
ws.close();
|
|
193
|
+
return result?.value || {};
|
|
194
|
+
} finally {
|
|
195
|
+
child.kill('SIGKILL');
|
|
196
|
+
try { rmSync(profileDir, { recursive: true, force: true }); } catch { /* ignore */ }
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (!chrome) {
|
|
201
|
+
check('F 渲染层校验', false, '未找到 Chrome/Chromium,跳过');
|
|
202
|
+
} else {
|
|
203
|
+
// F1-F6:官网文章详情页
|
|
204
|
+
try {
|
|
205
|
+
const detail = await renderPage(`${BASE}/posts/${postId}`);
|
|
206
|
+
const pageText = String(detail.text || '');
|
|
207
|
+
say(`渲染 URL: ${BASE}/posts/${postId} → 跳转后 ${detail.href}(document.title = ${detail.docTitle})`);
|
|
208
|
+
check('F1 渲染页跳转到公开文章路由', String(detail.href || '').includes(`/article/news/${slug}`), `href=${detail.href}`);
|
|
209
|
+
check('F2 页面渲染出标题', pageText.includes(post.title), pageText.includes(post.title) ? '标题可见' : '标题未渲染');
|
|
210
|
+
check('F3 页面无「加载中」占位(内容已加载)', !pageText.includes('加载中'), pageText.includes('加载中') ? '仍显示加载中' : '已加载');
|
|
211
|
+
check('F5 正文关键段落可见', pageText.includes('定时任务终于有人接'), pageText.includes('定时任务终于有人接') ? '正文已渲染' : '正文未渲染');
|
|
212
|
+
const pageHits = scan(pageText);
|
|
213
|
+
check('F6 详情页可见文本黑名单命中 = 0', pageHits.length === 0, pageHits.length ? JSON.stringify(pageHits.slice(0, 5)) : `0 命中 / ${pageText.length} 字符`);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
check('F1-F6 详情页渲染校验', false, e.message);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// F7-F8:官网内容中心列表页(封面图实际渲染位置)
|
|
219
|
+
try {
|
|
220
|
+
const list = await renderPage(`${BASE}/daos/club/post-list`);
|
|
221
|
+
const listText = String(list.text || '');
|
|
222
|
+
say(`渲染 URL: ${BASE}/daos/club/post-list(document.title = ${list.docTitle})`);
|
|
223
|
+
const coverImg = (list.imgs || []).find((i) => i.src === cover);
|
|
224
|
+
check('F7 官网内容中心列表页渲染出封面图且加载成功', Boolean(coverImg?.ok && coverImg?.visible),
|
|
225
|
+
coverImg ? `naturalWidth=${coverImg.w} naturalHeight=${coverImg.h}, visible=${coverImg.visible}` : '页面未找到该封面图');
|
|
226
|
+
check('F8 官网内容中心列表页出现该资讯标题与摘要', listText.includes(post.title) && listText.includes(String(post.description || '').slice(0, 20)),
|
|
227
|
+
listText.includes(post.title) ? '标题+摘要可见' : '标题未出现');
|
|
228
|
+
// 只扫描本篇资讯自己的卡片文本(列表页还包含历史文章的摘要,不在本次发布范围内)
|
|
229
|
+
const cardStart = listText.indexOf(post.title);
|
|
230
|
+
const cardText = cardStart >= 0 ? listText.slice(cardStart, cardStart + 400) : '';
|
|
231
|
+
const listHits = scan(cardText);
|
|
232
|
+
check('F9 本篇资讯卡片可见文本黑名单命中 = 0', listHits.length === 0, listHits.length ? JSON.stringify(listHits.slice(0, 5)) : `0 命中 / ${cardText.length} 字符`);
|
|
233
|
+
const legacyHits = scan(listText);
|
|
234
|
+
say(` (列表页全量文本命中 ${legacyHits.length} 处,均来自本次发布之前的历史文章摘要:${[...new Set(legacyHits.map((h) => h.w))].join('、') || '无'})`);
|
|
235
|
+
} catch (e) {
|
|
236
|
+
check('F7-F9 官网内容中心列表页校验', false, e.message);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
say('注:umi 站「文章详情页 / 创意广场列表」模板本身不渲染 coverImage(历史文章 180 同样不渲染),');
|
|
240
|
+
say(' 封面在官网 DAO 站点内容中心(/daos/club/post-list)正常渲染,已于 F7 验证。');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ---------- 汇总 ----------
|
|
244
|
+
say('\n══════════════════════════════════════════════════════════════');
|
|
245
|
+
say(` 公开链接: ${BASE}/posts/${postId}`);
|
|
246
|
+
say(` 文章页: ${BASE}/article/news/${slug}`);
|
|
247
|
+
say(` 官网内容中心: ${BASE}/daos/club/post-list`);
|
|
248
|
+
say(` 封面 URL: ${cover}`);
|
|
249
|
+
say(` 失败项: ${checks.filter((c) => !c.pass).length} / ${checks.length}`);
|
|
250
|
+
say('══════════════════════════════════════════════════════════════');
|
|
251
|
+
|
|
252
|
+
mkdirSync('outputs/releases', { recursive: true });
|
|
253
|
+
writeFileSync('outputs/releases/publish-news-verification.log', log.join('\n') + '\n');
|
|
254
|
+
console.log(`\n日志已写入: outputs/releases/publish-news-verification.log`);
|
|
255
|
+
|
|
256
|
+
const failed = checks.filter((c) => !c.pass);
|
|
257
|
+
process.exit(failed.length === 0 ? 0 : 1);
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* scripts/verify-npx-install.mjs
|
|
4
|
+
*
|
|
5
|
+
* 验证「按 ClawDao 官方 MCP 列表的方式安装」这条路径真的能跑通:
|
|
6
|
+
*
|
|
7
|
+
* command = npx
|
|
8
|
+
* defaultArgs = ["-y", "@clawdao/limschain-agent"]
|
|
9
|
+
*
|
|
10
|
+
* 也就是说:用户机器上**没有 clone 仓库、没有 npm install、没有 .env**,
|
|
11
|
+
* 只有 npx + 一个 token 环境变量 —— MCP 必须能起来并列出与源码一致的工具集。
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ registry 模式下装的是**已发布版本**:若线上版本落后于本仓源码,
|
|
14
|
+
* 工具集比对会红 —— 这正是「发布物过期」的信号,别去改期望值迁就它。
|
|
15
|
+
*
|
|
16
|
+
* 两种模式:
|
|
17
|
+
* node scripts/verify-npx-install.mjs # 走 npm registry(需已发布)
|
|
18
|
+
* node scripts/verify-npx-install.mjs --tarball ./x.tgz # 离线:装本地 tarball 再跑
|
|
19
|
+
*
|
|
20
|
+
* 复刻了 ClawDao sidecar 的三个关键约束:
|
|
21
|
+
* 1. 子进程 env 只有 { PATH, HOME } + MCP 注入的变量(bridge 只透传这两个)
|
|
22
|
+
* 2. PATH 是「图形界面启动」的残缺 PATH —— 这里按 shell-path.ts 的规则补齐
|
|
23
|
+
* (追加 ~/.local/bin、~/.bun/bin、/opt/homebrew/bin、nvm 最新版本…)
|
|
24
|
+
* 3. cwd = '/' —— 证明不依赖仓库目录
|
|
25
|
+
*/
|
|
26
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
27
|
+
import { existsSync, mkdtempSync, readdirSync, rmSync } from 'node:fs';
|
|
28
|
+
import { homedir, tmpdir } from 'node:os';
|
|
29
|
+
import { delimiter, join, resolve } from 'node:path';
|
|
30
|
+
import { describeToolSetDiff } from './tool-set.mjs';
|
|
31
|
+
|
|
32
|
+
const PKG = '@clawdao/limschain-agent';
|
|
33
|
+
// ⚠️ scoped 包安装后,node_modules/.bin/ 里出现的是 **bin 键**(不带 scope 前缀),
|
|
34
|
+
// 不是 scoped 包名 —— 见 docs/clawdao-mcp-listing.md §4。
|
|
35
|
+
const BIN = 'limschain-agent';
|
|
36
|
+
|
|
37
|
+
const argv = process.argv.slice(2);
|
|
38
|
+
const tarballIdx = argv.indexOf('--tarball');
|
|
39
|
+
const tarball = tarballIdx >= 0 ? resolve(argv[tarballIdx + 1] ?? '') : '';
|
|
40
|
+
|
|
41
|
+
/** 按 ClawDao shell-path.ts 的规则补齐 GUI 启动时的残缺 PATH */
|
|
42
|
+
function enrichedPath() {
|
|
43
|
+
const home = homedir();
|
|
44
|
+
const dirs = ['/usr/bin', '/bin', '/usr/sbin', '/sbin'];
|
|
45
|
+
const push = (p) => { if (p && existsSync(p) && !dirs.includes(p)) dirs.push(p); };
|
|
46
|
+
push(join(home, '.bun', 'bin'));
|
|
47
|
+
push(join(home, '.local', 'bin'));
|
|
48
|
+
push(join(home, '.npm-global', 'bin'));
|
|
49
|
+
push(join(home, '.volta', 'bin'));
|
|
50
|
+
if (process.platform === 'darwin') {
|
|
51
|
+
push('/opt/homebrew/bin');
|
|
52
|
+
push('/opt/homebrew/sbin');
|
|
53
|
+
push('/usr/local/bin');
|
|
54
|
+
}
|
|
55
|
+
const nvmBase = process.env.NVM_DIR || join(home, '.nvm');
|
|
56
|
+
const versionsDir = join(nvmBase, 'versions', 'node');
|
|
57
|
+
if (existsSync(versionsDir)) {
|
|
58
|
+
const versions = readdirSync(versionsDir).filter((n) => /^v?\d/.test(n)).sort();
|
|
59
|
+
const latest = versions[versions.length - 1];
|
|
60
|
+
if (latest) push(join(versionsDir, latest, 'bin'));
|
|
61
|
+
}
|
|
62
|
+
return dirs.join(delimiter);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 与 clawdao-mcp-bridge 完全一致的最小 env
|
|
66
|
+
const env = { PATH: enrichedPath(), HOME: process.env.HOME };
|
|
67
|
+
const cwd = '/';
|
|
68
|
+
|
|
69
|
+
/** 决定「怎么把 MCP server 拉起来」 */
|
|
70
|
+
let command;
|
|
71
|
+
let args;
|
|
72
|
+
let cleanup = () => {};
|
|
73
|
+
|
|
74
|
+
if (tarball) {
|
|
75
|
+
// 离线模式:把 tarball 装进临时目录,只用 node_modules/.bin 里的入口
|
|
76
|
+
const prefix = mkdtempSync(join(tmpdir(), 'lims-npx-'));
|
|
77
|
+
cleanup = () => { try { rmSync(prefix, { recursive: true, force: true }); } catch { /* ignore */ } };
|
|
78
|
+
console.log(`模式: --tarball(离线,安装到临时目录 ${prefix})`);
|
|
79
|
+
const install = spawnSync('npm', ['install', '--prefix', prefix, '--no-audit', '--no-fund', tarball], {
|
|
80
|
+
env: { ...process.env }, stdio: 'inherit',
|
|
81
|
+
});
|
|
82
|
+
if (install.status !== 0) {
|
|
83
|
+
console.error('FAIL: npm install 失败');
|
|
84
|
+
cleanup();
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
command = join(prefix, 'node_modules', '.bin', BIN);
|
|
88
|
+
args = [];
|
|
89
|
+
console.log(`启动: ${command}(等价于 npx -y ${PKG})`);
|
|
90
|
+
} else {
|
|
91
|
+
console.log('模式: npm registry(等价于 ClawDao 官方列表的 npx -y <pkg>)');
|
|
92
|
+
command = 'npx';
|
|
93
|
+
args = ['-y', PKG];
|
|
94
|
+
console.log(`启动: ${command} ${args.join(' ')}`);
|
|
95
|
+
}
|
|
96
|
+
console.log(` PATH = ${env.PATH}`);
|
|
97
|
+
console.log(` cwd = ${cwd}\n`);
|
|
98
|
+
|
|
99
|
+
const child = spawn(command, args, { env, cwd, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
100
|
+
|
|
101
|
+
let buf = '';
|
|
102
|
+
const pending = new Map();
|
|
103
|
+
child.stdout.on('data', (d) => {
|
|
104
|
+
buf += d.toString();
|
|
105
|
+
let idx;
|
|
106
|
+
while ((idx = buf.indexOf('\n')) >= 0) {
|
|
107
|
+
const line = buf.slice(0, idx).trim();
|
|
108
|
+
buf = buf.slice(idx + 1);
|
|
109
|
+
if (!line) continue;
|
|
110
|
+
let msg;
|
|
111
|
+
try { msg = JSON.parse(line); } catch { continue; }
|
|
112
|
+
const h = pending.get(msg.id);
|
|
113
|
+
if (h) { pending.delete(msg.id); h(msg); }
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
child.stderr.on('data', (d) => process.stderr.write(`[server stderr] ${d}`));
|
|
117
|
+
|
|
118
|
+
let nextId = 1;
|
|
119
|
+
function request(method, params) {
|
|
120
|
+
const id = nextId++;
|
|
121
|
+
return new Promise((res, rej) => {
|
|
122
|
+
const timer = setTimeout(() => rej(new Error(`${method} timeout`)), 60000);
|
|
123
|
+
pending.set(id, (msg) => { clearTimeout(timer); res(msg); });
|
|
124
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function fail(msg) {
|
|
129
|
+
console.error(`\nFAIL: ${msg}`);
|
|
130
|
+
child.kill();
|
|
131
|
+
cleanup();
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let init;
|
|
136
|
+
try {
|
|
137
|
+
init = await request('initialize', {
|
|
138
|
+
protocolVersion: '2024-11-05',
|
|
139
|
+
capabilities: {},
|
|
140
|
+
clientInfo: { name: 'npx-install-sim', version: '0.0.1' },
|
|
141
|
+
});
|
|
142
|
+
} catch (e) {
|
|
143
|
+
fail(`initialize 超时/失败:${e.message}`);
|
|
144
|
+
}
|
|
145
|
+
if (init.error) fail(`initialize error: ${JSON.stringify(init.error)}`);
|
|
146
|
+
console.log(`initialize OK · server=${init.result?.serverInfo?.name} v${init.result?.serverInfo?.version}`);
|
|
147
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
|
|
148
|
+
|
|
149
|
+
const list = await request('tools/list', {});
|
|
150
|
+
if (list.error) fail(`tools/list error: ${JSON.stringify(list.error)}`);
|
|
151
|
+
const tools = list.result?.tools ?? [];
|
|
152
|
+
console.log(`tools/list OK · ${tools.length} 个工具`);
|
|
153
|
+
const toolSetProblem = describeToolSetDiff(tools);
|
|
154
|
+
if (toolSetProblem) fail(toolSetProblem);
|
|
155
|
+
|
|
156
|
+
// 凭证检查:安装路径下没有 .env,token 只能来自环境变量
|
|
157
|
+
const health = await request('tools/call', { name: 'lims_health', arguments: {} });
|
|
158
|
+
const text = health.result?.content?.find((c) => c.type === 'text')?.text ?? '';
|
|
159
|
+
const rt = JSON.parse(text).runtime ?? {};
|
|
160
|
+
console.log(
|
|
161
|
+
'lims_health · baseUrl=%s hasAuthToken=%s hasDaoId=%s',
|
|
162
|
+
rt.baseUrl,
|
|
163
|
+
rt.hasAuthToken,
|
|
164
|
+
rt.hasDaoId,
|
|
165
|
+
);
|
|
166
|
+
console.log(' ⇒ 期望 hasAuthToken=false(安装路径没有 .env,token 必须走环境变量注入)');
|
|
167
|
+
|
|
168
|
+
console.log(`\nPASS: 安装路径在「无仓库 / 无 .env / 受限 env」下可正常握手并列出 ${tools.length} 个工具`);
|
|
169
|
+
child.kill();
|
|
170
|
+
cleanup();
|
|
171
|
+
process.exit(0);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 大屏验收:用 headless Chrome 真跑一遍 dashboard/site-articles/index.html,
|
|
4
|
+
* 从页面自检块(#selfcheck → window.__DASH_REPORT__)回读渲染结果,
|
|
5
|
+
* 与 outputs/site-articles-stats.json 逐项对照,并检查无 JS 报错 / 无滚动条 / 无内容被裁切。
|
|
6
|
+
*
|
|
7
|
+
* 用法: node scripts/verify-site-dashboard.mjs
|
|
8
|
+
* CHROME=/path/to/chrome node scripts/verify-site-dashboard.mjs
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
11
|
+
import { execFileSync } from 'node:child_process';
|
|
12
|
+
import { resolve, dirname } from 'node:path';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
|
|
15
|
+
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
16
|
+
const HTML = resolve(ROOT, 'dashboard/site-articles/index.html');
|
|
17
|
+
const STATS = resolve(ROOT, 'outputs/site-articles-stats.json');
|
|
18
|
+
|
|
19
|
+
const CANDIDATES = [
|
|
20
|
+
process.env.CHROME,
|
|
21
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
22
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium',
|
|
23
|
+
'/usr/bin/google-chrome',
|
|
24
|
+
'/usr/bin/chromium',
|
|
25
|
+
'/usr/bin/chromium-browser',
|
|
26
|
+
].filter(Boolean);
|
|
27
|
+
const CHROME = CANDIDATES.find((p) => existsSync(p));
|
|
28
|
+
if (!CHROME) {
|
|
29
|
+
console.error('未找到 Chrome/Chromium,无法做 headless 验收。可用 CHROME=/path/to/chrome 指定。');
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
if (!existsSync(HTML)) {
|
|
33
|
+
console.error(`缺少 ${HTML},先跑 node scripts/build-site-dashboard.mjs`);
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stats = JSON.parse(readFileSync(STATS, 'utf-8'));
|
|
38
|
+
|
|
39
|
+
const dumpDom = (size) => execFileSync(CHROME, [
|
|
40
|
+
'--headless=new', '--disable-gpu', '--no-sandbox', '--hide-scrollbars',
|
|
41
|
+
`--window-size=${size}`, '--virtual-time-budget=4000', '--dump-dom',
|
|
42
|
+
`file://${HTML}`,
|
|
43
|
+
], { encoding: 'utf-8', maxBuffer: 40 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
44
|
+
|
|
45
|
+
const parseReport = (dom) => {
|
|
46
|
+
const m = dom.match(/<div id="selfcheck">([\s\S]*?)<\/div>/);
|
|
47
|
+
if (!m) throw new Error('页面未产出自检块(可能 JS 未执行)');
|
|
48
|
+
return JSON.parse(m[1].trim().replace(/"/g, '"').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const results = [];
|
|
52
|
+
let failed = 0;
|
|
53
|
+
const check = (name, actual, expected) => {
|
|
54
|
+
const ok = JSON.stringify(actual) === JSON.stringify(expected);
|
|
55
|
+
if (!ok) failed += 1;
|
|
56
|
+
results.push({ item: name, expected: JSON.stringify(expected), actual: JSON.stringify(actual), ok });
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
for (const size of ['1920,1080', '1600,900', '1366,768']) {
|
|
60
|
+
const report = parseReport(dumpDom(size));
|
|
61
|
+
const tag = `@${size}`;
|
|
62
|
+
check(`${tag} JS 无报错`, report.errors, []);
|
|
63
|
+
check(`${tag} KPI 文章总数`, report.kpiTotal, stats.total);
|
|
64
|
+
check(`${tag} KPI 已发布`, report.kpiPublished, stats.kpi.published);
|
|
65
|
+
check(`${tag} KPI 待过审`, report.kpiPending, stats.kpi.pendingReview);
|
|
66
|
+
check(`${tag} 环形图分片合计`, report.donutSum, stats.total);
|
|
67
|
+
check(`${tag} 明细表合计`, report.tableSum, stats.total);
|
|
68
|
+
check(`${tag} 月度趋势合计(近12月)`, report.trendSum,
|
|
69
|
+
stats.trendPublished.reduce((a, b) => a + b.count, 0));
|
|
70
|
+
check(`${tag} 趋势首月`, report.trendFirst,
|
|
71
|
+
`${stats.trendPublished[0].month}:${stats.trendPublished[0].count}`);
|
|
72
|
+
check(`${tag} 趋势末月`, report.trendLast,
|
|
73
|
+
`${stats.trendPublished[stats.trendPublished.length - 1].month}:${stats.trendPublished[stats.trendPublished.length - 1].count}`);
|
|
74
|
+
check(`${tag} KPI 卡片数`, report.rows, 5);
|
|
75
|
+
check(`${tag} 无文档滚动条`, report.layout.hasScrollbar, false);
|
|
76
|
+
check(`${tag} 无容器裁切`, report.layout.clampedContainers, []);
|
|
77
|
+
check(`${tag} 无文字横向溢出`, report.layout.overflowTextNodes, 0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const w = (s, n) => String(s).padEnd(n);
|
|
81
|
+
console.log(`${w('检查项', 34)}${w('期望', 26)}${w('实际', 26)}结果`);
|
|
82
|
+
for (const r of results) {
|
|
83
|
+
console.log(`${w(r.item, 34)}${w(r.expected, 26)}${w(r.actual, 26)}${r.ok ? 'PASS' : 'FAIL'}`);
|
|
84
|
+
}
|
|
85
|
+
console.log(`\n${results.length - failed}/${results.length} 通过${failed ? `,${failed} 项失败` : ''}`);
|
|
86
|
+
console.log(`HTML: ${HTML}`);
|
|
87
|
+
process.exit(failed ? 1 : 0);
|