#!/usr/bin/env node const { buildGoalStrategy, detectGoal, SUGGESTION_RULES } = require('../mcp/src/features/tihao-sourcing/goal-strategy'); const { buildComplianceCheck, detectComplianceRisks, BANNED_WORD_REPLACEMENTS, PLATFORM_RULES, SAFE_WORDS } = require('../mcp/src/features/tihao-sourcing/compliance-rules'); const { enrichCriteriaWithExperience } = require('../mcp/src/features/tihao-sourcing/experience-rules'); function main() { // 投放目标识别 assert(detectGoal('需要找博主做种草转化,带货成交') === 'seed_conversion', '应识别种草转化'); assert(detectGoal('品牌曝光,提升知名度,破圈传播') === 'brand_exposure', '应识别品牌曝光'); assert(detectGoal('搜索引流,卡小蓝词,关键词沉淀') === 'search_drain', '应识别搜索引流'); assert(detectGoal('大促活动冲量,同城本地铺量') === 'campaign_volume', '应识别活动冲量'); // 1.5 倍提号规则 const strategy = buildGoalStrategy({ rawText: '种草转化', targetCount: 10 }); assert(strategy.goalLabel === '种草转化', '目标中文标签应正确'); assert(strategy.suggestionCount === 15, '10 位需求应提 15 位(1.5 倍)'); assert(strategy.suggestionRules.length === 3, '应有 3 条提号规则'); assert(SUGGESTION_RULES.some(rule => rule.id === 'suggest-1.5x'), '应有 1.5 倍提号规则'); assert(SUGGESTION_RULES.some(rule => rule.id === 'style-match-80'), '应有 80% 风格匹配规则'); // 合规词检测 const risks = detectComplianceRisks('这个产品美白祛痘效果第一,是平替神器'); const banned = risks.map(item => item.banned); assert(banned.includes('美白'), '应检出美白'); assert(banned.includes('祛痘'), '应检出祛痘'); assert(banned.includes('第一'), '应检出第一'); assert(BANNED_WORD_REPLACEMENTS.some(item => item.banned === '美白' && item.safe.includes('提亮肤色')), '美白应替换为提亮肤色'); // 合规检查结构 const compliance = buildComplianceCheck({ rawText: '美白产品', platforms: ['xiaohongshu', 'douyin'] }); assert(compliance.bannedHits.length >= 1, '应检出美白高危词'); assert(compliance.platformRules.length === 2, '两个平台特规'); assert(compliance.safeWords.length > 0 && SAFE_WORDS.includes('皮肤屏障'), '应有安全词库'); assert(PLATFORM_RULES.douyin && PLATFORM_RULES.xiaohongshu && PLATFORM_RULES.bilibili, '三个平台特规齐全'); // 接入 experience-rules const enriched = enrichCriteriaWithExperience({ rawText: '美白种草转化,目标10位', targetCount: 10, platforms: ['xiaohongshu'], keywords: ['美白'] }); assert(enriched.goalStrategy && enriched.goalStrategy.goalLabel, '应输出 goalStrategy'); assert(enriched.compliance && enriched.compliance.bannedWordReplacements, '应输出 compliance'); console.log(JSON.stringify({ ok: true, goalStrategies: Object.keys(require('../mcp/src/features/tihao-sourcing/goal-strategy').GOAL_STRATEGIES).length, suggestionRuleCount: SUGGESTION_RULES.length, bannedWordCount: BANNED_WORD_REPLACEMENTS.length, platformRuleCount: Object.keys(PLATFORM_RULES).length, safeWordCount: SAFE_WORDS.length }, null, 2)); } function assert(condition, message) { if (!condition) throw new Error(message); } if (require.main === module) main();