| 123456789101112131415161718192021222324 |
- import fs from 'node:fs';
- import crypto from 'node:crypto';
- import { renderReportHtml } from '../../skills/ksf-workshop-runtime/scripts/render-report-html.mjs';
- const out = 'docs/report-quality-html-20261111';
- const raw = JSON.parse(fs.readFileSync('docs/workshop-argument-quality-20261111/example-fixture.json', 'utf8'));
- const artifact = raw.artifact[0], sourceById = Object.fromEntries(raw.source.map(s => [s.objectId, s]));
- const report = structuredClone(artifact.report);
- report.subtitle += ' · 本地版式演示,沿用已有案例材料,未开展新调研或新入库';
- for (const entry of Object.values(report.evidence)) for (const quote of entry.quotes || []) {
- const source = sourceById[quote.sourceId || entry.sourceId];
- if (source?.sourceUrl && !quote.ref.includes(source.sourceUrl)) quote.ref += '; ' + source.sourceUrl;
- }
- const task = { title: artifact.title, stageCode: 'S5', version: 1, dataMode: 'sample', report,
- pendingQuestions: ['是否保留原三味组合为比较基准?现有材料不足以直接改为固定两味组合。', '需验证的是购买选择和组合取舍;本示例没有实际选择实验,不能声称已确认方案。'] };
- fs.writeFileSync(out + '/preview-task.json', JSON.stringify(task, null, 2) + '\n');
- const html = renderReportHtml(task);
- fs.writeFileSync(out + '/报告版式预览.html', html);
- const file = { id: 'preview-html-file', name: '报告版式预览.html', contentType: 'text/html', sizeBytes: Buffer.byteLength(html),
- sha256: crypto.createHash('sha256').update(html).digest('hex'),
- url: 'https://kangshifu.fmode.cn/api/functions?path=%2Fksf%2Ffile&artifactId=' + artifact.objectId + '&fileId=preview-html-file' };
- // Fixture endpoint is intercepted only by the browser test. It is not a published attachment.
- artifact.report = { ...report, attachments: [file] };
- fs.writeFileSync(out + '/browser-fixture.json', JSON.stringify(raw, null, 2) + '\n');
- console.log(JSON.stringify({ html: out + '/报告版式预览.html', source: '既有案例材料', productionWrites: 0 }));
|