platform-sourcing-strategy-smoke.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env node
  2. const fs = require('fs');
  3. const os = require('os');
  4. const path = require('path');
  5. const { runTihaoSourcing } = require('../mcp/src/tools/tihao-brief-sourcing-run');
  6. async function main() {
  7. const output = fs.mkdtempSync(path.join(os.tmpdir(), 'tihao-platform-strategy-'));
  8. const result = await runTihaoSourcing({
  9. collectionMode: 'sample',
  10. briefText: [
  11. '客户名称:平台策略测试',
  12. '平台与人数:小红书 4 人,抖音 3 人',
  13. '产品:敏感肌屏障修护精华',
  14. '参考账号:小红书成分党参考账号,抖音生活方式参考账号',
  15. '关键词:敏感肌、屏障修护、真实体验、成分拆解',
  16. '偏好真实体验、成分拆解,不要硬广。'
  17. ].join('\n'),
  18. output
  19. });
  20. assert(result.status === 'ok', 'platform strategy smoke should run ok');
  21. const strategies = result.data.criteria.sourcingStrategy || [];
  22. const xhs = strategies.find(item => item.platform === 'xiaohongshu');
  23. const douyin = strategies.find(item => item.platform === 'douyin');
  24. assert(xhs, 'sourcing strategy should include xiaohongshu');
  25. assert(douyin, 'sourcing strategy should include douyin');
  26. assert(xhs.preferredPath === 'reference_similarity', 'xiaohongshu should prefer reference similarity path');
  27. assert(String(xhs.note || '').includes('蒲公英'), 'xiaohongshu note should mention Pugongying/reference path');
  28. assert(String(xhs.note || '').includes('相似'), 'xiaohongshu note should mention similar account recommendation');
  29. assert(douyin.preferredPath === 'keyword_or_recruitment', 'douyin should use keyword/recruitment path');
  30. assert(String(douyin.note || '').includes('星图'), 'douyin note should mention Xingtu tags as entry only');
  31. assert(String(douyin.note || '').includes('招募'), 'douyin note should mention recruitment fallback');
  32. assert(String(douyin.note || '').includes('不作为适配证明'), 'douyin note should not treat Xingtu tags as fit proof');
  33. const report = fs.readFileSync(path.join(output, 'tihao-sourcing-report.md'), 'utf8');
  34. assert(report.includes('平台找号策略'), 'report should expose platform sourcing strategy');
  35. assert(report.includes('小红书/蒲公英优先使用参考账号相似推荐'), 'report should explain xiaohongshu reference-similarity path');
  36. assert(report.includes('抖音星图标签只作为候选入口'), 'report should explain douyin xingtu limitation');
  37. assert(report.includes('招募补量'), 'report should explain douyin recruitment fallback');
  38. console.log(`platform sourcing strategy smoke ok: ${output}`);
  39. }
  40. function assert(condition, message) {
  41. if (!condition) throw new Error(message);
  42. }
  43. main().catch(error => {
  44. console.error(error && error.stack ? error.stack : String(error));
  45. process.exit(1);
  46. });