| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #!/usr/bin/env node
- const fs = require('fs');
- const os = require('os');
- const path = require('path');
- const { auditRecords, loadRecords } = require('./historical-dataset-audit');
- function main() {
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tihao-history-audit-'));
- writeJson(path.join(dir, 'dha.json'), sample({
- id: 'dha-history',
- category: '母婴',
- selectedName: '营养师妈妈',
- rejectedName: '婚礼布置号'
- }));
- writeJson(path.join(dir, 'skincare.json'), sample({
- id: 'skincare-history',
- category: '护肤',
- selectedName: '敏感肌成分党',
- rejectedName: '泛美妆硬广号'
- }));
- writeJson(path.join(dir, 'home.json'), sample({
- id: 'home-history',
- category: '家清',
- selectedName: '真实家居清洁实验室',
- rejectedName: '装修设计号'
- }));
- const summary = auditRecords({ inputPath: dir, records: loadRecords(dir), minBriefs: 3 });
- assert(summary.acceptance.readyForLongRun, 'complete history dataset should be ready for long run');
- assert(summary.acceptance.readyForCustomerEffectProof, 'complete history dataset should be ready for customer effect proof');
- assert(summary.briefCount === 3, 'should count history briefs');
- assert(summary.withCustomerDecision === 3, 'should count customer decision coverage');
- assert(summary.withRejectionReason === 3, 'should count rejection reason coverage');
- assert(summary.withManualSupplementBaseline === 3, 'should count manual supplement baseline coverage');
- const missingBaselineDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tihao-history-audit-missing-baseline-'));
- writeJson(path.join(missingBaselineDir, 'missing-baseline.json'), sample({
- id: 'missing-baseline',
- category: '护肤',
- selectedName: '敏感肌记录者',
- rejectedName: '硬广导购号',
- includeManualSupplementBaseline: false
- }));
- const missingBaselineSummary = auditRecords({ inputPath: missingBaselineDir, records: loadRecords(missingBaselineDir), minBriefs: 1 });
- assert(missingBaselineSummary.acceptance.readyForLongRun, 'missing manual supplement baseline should not block basic long-run readiness');
- assert(!missingBaselineSummary.acceptance.readyForCustomerEffectProof, 'missing manual supplement baseline should block customer effect proof');
- console.log(`historical dataset audit smoke ok: ${dir}`);
- }
- function sample({ id, category, selectedName, rejectedName, includeManualSupplementBaseline = true }) {
- return {
- id,
- name: id,
- category,
- ...(includeManualSupplementBaseline ? { manualSupplementBaseline: 6 } : {}),
- briefText: `${category} 品类真实历史 Brief,包含预算、平台、参考账号和排除项。`,
- referenceLinks: [{ url: 'https://example.com/reference-video', platform: 'xiaohongshu', contentType: 'video' }],
- manualFinalList: [
- { platform: '小红书', creatorName: selectedName, profileUrl: `https://example.com/${id}/a`, manualReviewLabel: '可直接发客户', customerDecision: '客户选中' },
- { platform: '小红书', creatorName: rejectedName, profileUrl: `https://example.com/${id}/b`, manualReviewLabel: '跑偏', customerDecision: '客户拒绝', rejectReason: '内容方向偏离 Brief' }
- ],
- customerFeedback: [
- { creatorName: selectedName, finalDecision: '客户选中', reason: '客户认可调性和内容结构' },
- { creatorName: rejectedName, finalDecision: '客户拒绝', rejectReason: '跑偏,不能承接本次 Brief' }
- ]
- };
- }
- function writeJson(file, value) {
- fs.writeFileSync(file, JSON.stringify(value, null, 2), 'utf8');
- }
- function assert(condition, message) {
- if (!condition) throw new Error(message);
- }
- if (require.main === module) main();
|