html-migration-validator
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "html-migration-validator" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-c9cf7a7056b826c23ce130a8a2a4dff0653860e2e47e26589f6a34dfa3b2477d. Verify the upstream source and version against https://skillhub.cn/skills/user_3cd0c9e2/html-migration-validator before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
HTML dashboard migration validator: validates the data, UI, and chart reliability of DeepBI sandbox HTML dashboards by automatically running a five-step pipeline when triggered—lint → probe → check-sql → data comparison → chart standards—and repairs any failures found.
Introduction source: third_party · user_3cd0c9e2 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: html-migration-validator
slug: html-migration-validator
displayName: HTML 迁移验证器
version: 1.0.0
description: 验证 DeepBI 沙箱 HTML 看板的可靠性(数据+UI+图表)。触发时自动执行 5 步验证流水线:lint→probe→check-sql→数据对比→图表规范,发现不达标立即修复。HTML Migration Validator
触发规则
当用户请求以下任意操作时,立即加载并执行此 skill:
- 验证/检查/对比某个 HTML 看板
- 确认 HTML 和 Console 数据是否一致
- 排查"数据不显示"/"数据不一致"/"白屏"/"Binder Error"等问题
- 找出页面为什么不渲染/图表为什么形状不同
核心事实(必须记住)
| 事实 | 含义 |
|---|---|
| HTML 查的是 Parquet 快照,不是 PostgreSQL 原表 | 数据最多 4h 延迟,对比前必须 sync |
| 执行引擎是 DuckDB,不是 PostgreSQL | SQL 语法按 DuckDB 写(INTERVAL '7 days',不是 INTERVAL '7' DAY) |
dataset_NNN 是表名占位符 |
推荐discoverD() 用 getFolderTree() 动态发现 name→id;变空间自动适配 |
| querySql 返回纯 POJO 数组 | r[0].col / r.map() 直接用;列元数据在不可枚举 r.columns。禁止 r.rows[0](旧格式已废弃) |
| SDK 4 命名空间 | deepbi.data(查询) / deepbi.space(空间) / deepbi.files(文件树) / deepbi.user(用户)。白名单已覆盖只读方法,无弹窗。DTBridge/快照/manifest 已移除 |
| Console 端查原始表(PostgreSQL) | HTML 对齐 Console 必须考虑快照延迟+时区差异 |
| 时区依赖容器环境 | 真实环境 DuckDB 可能是 PRC(UTC+8),本地是 UTC。必须用--api-base https://dev-deepbi.woa.com 验证 |
| 所有图表必须用 ECharts | 禁止 Canvas 2D / Chart.js / SVG 手绘(铁律 E5) |
| ECharts 更新用 setOption | 已有实例用_c.setOption(opt, true) 增量更新,禁止 dispose+init(产生闪烁) |
| SDK 轮询等待 | SDK 由父页面异步注入(非<head> 脚本),必须用 waitForSDK() 轮询(100ms×100=10s);禁止 sdkOK() 一次性检查 |
| D 使用规范 | var D;(不初始化 {}),if(!D) 判断未发现,访问属性用 if(D&&D.users) 先判空;discoverD() 只在 load() 入口调 |
| 二级加载架构 | load() 全量(周期切换+首次)/ quickLoad() 轻量(搜索/过滤/排序/翻页只调 loadUsers+render,跳过骨架屏+分析数据) |
| loading 作用域匹配原则 | loading 视觉范围 = 数据更新范围。哪块数据变了只 loading 哪块,不动的不遮不闪。卡片独立查 = 各自 loading;表格查 = 表格 loading;图表查 = 图表变淡 |
| 骨架屏仅首次显示 | if (!hasData) renderSkeleton();切换时保留现有内容 + 最小 loading 反馈 |
| 禁止 alert()/confirm() | sandbox iframe 不允许模态弹窗,必须用自定义 DOM toast 替代(见 pitfalls.md) |
| Console API 是验证基准 | 用户在 Console 页面看到的数据 = API 返回值。HTML 数据必须对齐 API。当 API 和 PostgreSQL 不一致时需排查(可能部署版本差异),不能直接判定 HTML 错误 |
数据链路与验证角色
PostgreSQL 原始表 ← 底层数据源(查 API 为什么异常时使用)
│
├── Console API ← ★ 验证基准(用户在 Console 页面看到的数据 = API 返回值)
│ HTML 数据必须对齐这个
│
├── Parquet 快照 ← HTML 页面实际查询的数据源
│ ↑
│ querySql → DuckDB → COS ← HTML 实际走的链路
│
└── Console 前端 ← UI 卡片标题/布局的权威来源(非数据值)
| 角色 | 谁 | 用途 |
|---|---|---|
| 验证基准 | Console API | HTML 数据的对比目标(用户看的) |
| 排查工具 | PostgreSQL | 当 Parquet=API 不一致时,判断是谁的问题 |
| 页面数据源 | Parquet | HTML 实际查询的表 |
| UI 权威 | Console 源码 | 卡片标题、布局、指标定义 |
验证原则:
- 基准 = Console API(用户在 Console 页面看到的就是 API 返回的数据,HTML 必须对齐它)
- PostgreSQL = 排查工具(当 HTML=Parquet≠API 时,查 PG 判断是 API bug 还是快照问题)
- 如果 Parquet 和 PG 都一致但 API 返回不同 → API/部署问题,非 HTML bug
调用此 Skill 时的自动化流水线
加载后立即按顺序执行以下 6 步。每步发现问题必须修复后才能继续下一步。最后输出完整迁移报告。
第 1 步:静态代码扫描 (lint)
python .codebuddy/skills/html-migration-validator/scripts/validate_html.py lint --html <page>.html
检查规则:ERROR 必须修,WARN 建议修。
- E5-canvas-chart / J1-unquoted-color / H1-alert / S1-interval-day / E2-type-area → ERROR
- 其余 → WARN
⚠️ JS 语法检验(第 1 步必经,防白屏):lint 后必须验证 <script> 内 JavaScript 能被解析。
node -e "var fs=require('fs'); var h=fs.readFileSync('<page>.html','utf8'); var m=h.match(/<script>([\s\S]*?)<\/script>/); new Function(m[1])"
- ✅ 无输出 = 通过
- ❌
SyntaxError/Invalid token→ 阻塞上线,必须修复后才能进入下一步
已知陷阱:replace_in_file 工具可能将 " 误写为 \"(hex 5c22)。遇到此问题用 python3 -c "data=data.replace(b'\\\\\"', b'\"')" 字节修复。
第 2 步:列真实性验证 (probe)
python .codebuddy/skills/html-migration-validator/scripts/validate_html.py probe \
--space-id 366 --datasets <IDs> --api-base https://dev-deepbi.woa.com
第 3 步:SQL 可执行性 + D 变量覆盖 (check-sql)
python .codebuddy/skills/html-migration-validator/scripts/validate_html.py check-sql \
--space-id 366 --html <page>.html --api-base https://dev-deepbi.woa.com
第 4 步:数据一致性验证 (compare / compare-rows)
同之前,用 --sync-first --repeat 3。不支持嵌套 API 时走三级 PostgreSQL 仲裁。
COUNT 差异根因排查(JOIN 重复行)
当 HTML 和 Console 的 count 数量差异很大时(如 95 vs 194),不一定是快照延迟,先排查 LEFT JOIN 导致的行重复:
模式: FROM jobs j LEFT JOIN datasets d ON d.source_id = ds.id — 如果 data_sources 和 datasets 是一对多关系(一个数据源→多个数据集),LEFT JOIN 会把每行 job 复制 N 份。
检测方法:
# 查 SQL 中 LEFT JOIN 到的表是否一对多
python -c "
SELECT ref_id, COUNT(*) FROM datasets WHERE source_id IN (
SELECT ref_id FROM jobs WHERE status='failed' AND topic IN ('data_sync_report','data_sync_database')
) GROUP BY ref_id HAVING COUNT(*) > 1
"
修复(HTML 端): 用子查询代替 LEFT JOIN
-- ❌ 旧:LEFT JOIN 会导致重复行
SELECT j.*, d.name FROM jobs j LEFT JOIN datasets d ON d.source_id = j.ref_id
-- ✅ 新:子查询取第一个 dataset_name
SELECT j.*, (SELECT d.name FROM datasets d WHERE d.source_id = j.ref_id LIMIT 1)
FROM jobs j
真实的 Console 后端也有这个 bug! ops_datasets_service.py:get_sync_failures 中 base 查询的 LEFT JOIN 导致 count 从 95 膨胀到 194。
第 5 步:功能对齐检查(★ 新增 - 防止功能缺失)
这是之前 skill 的盲区——数据对了不代表功能完整。 必须逐项检查 HTML 是否实现了 Console 的全部功能:
A. 查询数量对齐:
- 统计 HTML 中
querySql()/q()调用次数 - 对比 Console 后端
ops_*_service.py中各方法发起的查询次数 - HTML 查询数 < Console → 功能缺失,补全
B. 分页对齐:
- Console API 返回
{total, items}且有?page=&page_size=参数 → HTML 必须有分页 - 检查 HTML 是否包含
LIMIT ... OFFSET和分页 UI(上/下一页按钮 + 总数显示)
C. 筛选/排序对齐:
- Console 有 period 选择器(7d/30d/90d)→ HTML 必须有同步的选择器
- Console 表格列支持排序(可点击表头)→ HTML 必须支持
D. 子视图/抽屉对齐:
- Console 有详情抽屉(点击行展开)→ HTML 必须有对应的子视图
- Console 有子 tab(如热门排行/同步健康/分布分析)→ HTML 必须有相同 tab
E. 图表类型对齐:
- Console 用 ECharts 面积图 → HTML 必须同类型
- Console 用饼图(实心/环形)→ HTML 必须一致
操作: 逐项对比 Console 前端源码 (*OpsPage.tsx) 和 HTML,缺失功能立即补全。
第 6 步:图表渲染规范验证 (chart audit)
同之前:禁止 Canvas 2D(E5 铁律)、ECharts 规范、JS↔ECharts 数据契约。
★ 最终迁移报告
每次 Skill 执行完成后,必须输出以下格式的报告。绿色=已通过,红色=未通过需修复。
═════════════════════════════════════════
DeepBI HTML 迁移报告
页面: <page>.html | 空间: 366 | 环境: dev-deepbi.woa.com
═════════════════════════════════════════
【1. 代码规范】 lint
✅ ERROR 0 / WARN 0
【2. 列真实性】 probe
✅ 所有引用的列在 Parquet 中存在
【3. SQL 可执行】 check-sql
✅ N 条 SQL 全部执行通过
【4. 数据一致性】 compare / compare-rows
✅ 全部指标与 Console API 一致(tolerance=N)
❌ <指标名>: 差异=N → 已触发 sync(task=N)
【5. 功能对齐】 feature parity
✅ 查询数量: HTML=N vs Console=N
✅ 分页: 已实现 (page_size=20, total=xxx)
✅ 筛选: period 选择器同步
✅ 子视图: 热门排行/同步健康/分布分析/数据源健康 4 tab 齐全
❌ 缺失功能: <描述> → 已补充
【6. 图表规范】 chart audit
✅ ECharts 渲染 (非 Canvas)
✅ smooth + areaStyle + dispose
═════════════════════════════════════════
迁移结论: ✅ 完全通过 (6/6) / ⚠️ N 项待修复
═════════════════════════════════════════
附录
DuckDB 语法速查
| ❌ 错误 | ✅ 正确 |
|---|---|
INTERVAL '30' DAY |
INTERVAL '30 days' |
CURRENT_DATE |
NOW() |
DATE(created_at) |
DATE(created_at AT TIME ZONE 'UTC') |
防幻觉三原则
--sync-first— 对比前强制同步所有涉及数据集--repeat 3— 3 轮指纹一致才算稳定- 只有稳定 +
|HTML-Console| ≤ tolerance才算一致
compare-rows 失败 → 三级验证
- 两路直查(sql + API)
- PostgreSQL 仲裁(
datetime.now(UTC)作为 since) - 三向结论:HTML=API=PG ✅ / HTML=PG≠API → 非 HTML bug / HTML≠PG=API → HTML bug
Config 规范
{D.xxx}占位符 +--html自动替换console_api用相对路径datasets含所有 JOIN 表
ECharts 标准模板
// 1. 动态加载(全局一次)
var _echartsLoaded = false;
function loadECharts(cb) {
if (typeof echarts !== 'undefined') { cb(); return; }
if (_echartsLoaded) {
var t = setInterval(function () {
if (typeof echarts !== 'undefined') { clearInterval(t); cb(); }
}, 100);
return;
}
_echartsLoaded = true;
var s = document.createElement('script');
s.src = 'https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js';
s.onload = cb; document.head.appendChild(s);
}
// 2. 渲染(切 tab/period 时 dispose 旧实例再 init)
var _chart = null;
function drawChart(data) {
var el = document.getElementById('chartId'); // <div id="chartId">
if (!el || !data || !data.length) return;
loadECharts(function () {
if (_chart) { try { _chart.dispose(); } catch (e) { } _chart = null; }
_chart = echarts.init(el);
_chart.setOption({
tooltip: { trigger: 'axis', backgroundColor: '#fff', borderColor: '#e2e8e0',
borderWidth: 1, borderRadius: 6, textStyle: { color: '#3f3f46', fontSize: 12 } },
legend: { data: ['系列名'], bottom: 0, left: 'center',
textStyle: { fontSize: 12, color: '#71717a' }, icon: 'roundRect',
itemWidth: 12, itemHeight: 8, itemGap: 16 },
grid: { top: 20, right: 20, bottom: 60, left: 44 },
xAxis: { type: 'category', data: dates, axisTick: { show: false },
axisLine: { lineStyle: { color: '#e2e8e0' } },
axisLabel: { fontSize: 11, color: '#94a3b8', margin: 12 } },
yAxis: { type: 'value', axisTick: { show: false }, axisLine: { show: false },
splitLine: { lineStyle: { color: '#f4f4f5', type: 'dashed' } },
axisLabel: { fontSize: 11, color: '#94a3b8' } },
series: [{ name: '系列名', type: 'line', data: values, smooth: true,
lineStyle: { width: 2, color: '#059669' },
itemStyle: { color: '#059669' },
areaStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1,
colorStops: [{ offset: 0, color: 'rgba(5,150,105,0.15)' },
{ offset: 1, color: 'rgba(5,150,105,0.01)' }] } },
symbol: 'circle', symbolSize: 6 }]
});
});
}
// 3. 渲染后调用:setTimeout(function(){ drawChart(data); }, 50);
附录
Dataset ID 映射表
| 变量名 | ID | 源表 | 用途 |
|---|---|---|---|
D.spaces |
4774 | spaces | 空间管理 |
D.datasets |
4776 | datasets | 资产总览 |
D.conversations |
4775 | conversations | 对话管理 |
D.jobs |
4777 | jobs | 任务同步监控 |
D.data_sources |
4779 | data_sources | 数据源管理 |
D.space_members |
4780 | space_members | 空间成员 |
D.spaceFiles |
4782 | files | 文件内容(HTML 看板本身) |
D.messages |
4783 | messages | 消息记录 |
D.users |
4773 | users | 用户管理 |
D.user_login_logs |
4784 | user_login_logs | 登录趋势 |
⚠️ D.jobs(4777) 和 D.space_members(4780) 容易混淆,用
--html自动解析禁止硬编码。
DuckDB 语法速查
| ❌ 错误 | ✅ 正确 |
|---|---|
INTERVAL '30' DAY |
INTERVAL '30 days' |
CURRENT_DATE |
NOW() |
DATE(created_at) |
DATE(created_at AT TIME ZONE 'UTC') |
WHERE >= DATE(NOW()...) |
>= NOW() - INTERVAL '1 days' |
SQL 注入防护
用户输入拼入 SQL 时必须转义:keyword.replace(/'/g, "''")
q() 标准模式(token 过期自动重试)
async function q(s, retry) {
try { return await window.deepbi.data.querySql(s); }
catch (e) {
var msg = String(e.message || e);
if (!retry && (msg.includes('token') || msg.includes('令牌') || msg.includes('过期')
|| msg.includes('invalid') || msg.includes('unauthorized') || msg.includes('401'))) {
await new Promise(function (r) { setTimeout(r, 500); });
return await q(s, true);
}
throw e;
}
}
快速操作参考
# 手动触发数据集同步
python .codebuddy/skills/html-migration-validator/scripts/validate_html.py sync --space-id 366 --datasets jobs --api-base https://dev-deepbi.woa.com
# 执行单条 SQL(调试)
python .codebuddy/skills/html-migration-validator/scripts/validate_html.py sql --space-id 366 --api-base https://dev-deepbi.woa.com --query "SELECT COUNT(*) FROM dataset_4777"
# 同步 HTML 到线上(单个文件)
python .codebuddy/skills/html-migration-validator/scripts/sync-to-space.py apps/web/src/features/sandbox/preview/<page>.html --space-id 366 --api-base https://dev-deepbi.woa.com
# 批量同步所有 HTML
python .codebuddy/skills/html-migration-validator/scripts/sync-to-space.py --all --space-id 366 --api-base https://dev-deepbi.woa.com
# 同步 HTML 文件树 VFS 节点
python .codebuddy/skills/html-migration-validator/scripts/validate_html.py sync --space-id 366 --datasets files --api-base https://dev-deepbi.woa.com
Skill 脚本清单
| 脚本 | 用途 |
|---|---|
scripts/validate_html.py |
核心验证器:audit/lint/probe/check-sql/compare/compare-rows/sync/sql/discover |
scripts/sync-to-space.py |
将本地 HTML 同步到空间(L2 + files 快照) |
同步前铁律:必须过第 1 步 lint + JS 语法检验。JS 语法错误会导致线上白屏(
SyntaxError),且用户端无有效报错提示。
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决DeepBI HTML看板迁移中的数据一致性、UI对齐、图表规范等核心痛点
- 提供端到端自动化验证流水线,显著提升迁移质量和效率
- 覆盖静态扫描、SQL验证、数据对比、功能对齐等完整场景
Highlights
- 触发词精准覆盖验证、检查、排查等核心场景
- 边界清晰,覆盖多种用户表达变体
Highlights
- 6步验证流水线结构清晰,每步有明确出口条件
- 包含完整附录和快速操作参考,文档完整度高
Highlights
- 工具来源明确,参数规范正确
- 覆盖JS语法检验、token过期重试等主要异常场景
- 提供同步前铁律等防护机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Read local files
Limit access to selected files or the project directory. Avoid unrelated private records, secrets and configuration files.
Mentioned in main document · lines 86
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- cdn.jsdelivr.net
- dev-deepbi.woa.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.