api-config.json 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. {
  2. "name": "html-report-generator",
  3. "displayName": "HTML竞品分析报告生成器",
  4. "description": "整合所有前置Skill输出,AI生成REPORT_DATA JSON,注入report_template.html模板,输出完整可渲染的13屏HTML VOC分析报告",
  5. "category": "synthesis",
  6. "version": "2.1.0",
  7. "type": "analysis",
  8. "templateRef": "workflows/templates/report_template.html",
  9. "parameters": {
  10. "industryName": {
  11. "type": "string",
  12. "required": true,
  13. "description": "行业名称,如「香薰家居」「宠物用品」「母婴护理」"
  14. },
  15. "coverBrandEnglish": {
  16. "type": "string",
  17. "required": true,
  18. "description": "封面英文品牌标识,如「HOME FRAGRANCE」「PET CARE」"
  19. },
  20. "reportDate": {
  21. "type": "string",
  22. "required": true,
  23. "description": "报告日期,格式 'YYYY年MM月'"
  24. },
  25. "categoryLandscape": {
  26. "type": "object",
  27. "required": true,
  28. "description": "synthesis/category-landscape 输出(市场全景数据)"
  29. },
  30. "competitorData": {
  31. "type": "object",
  32. "required": true,
  33. "description": "competitor-analysis 汇总输出(竞品发现+对比+定价+追踪)"
  34. },
  35. "reviewAnalysis": {
  36. "type": "object",
  37. "required": true,
  38. "description": "review-analysis 汇总输出(痛点+亮点+情感+关键词云)"
  39. },
  40. "socialVocData": {
  41. "type": "object",
  42. "required": false,
  43. "description": "social-voc 汇总输出(TikTok+Instagram趋势数据)"
  44. },
  45. "userPersona": {
  46. "type": "object",
  47. "required": false,
  48. "description": "synthesis/user-persona 输出"
  49. },
  50. "strategyData": {
  51. "type": "object",
  52. "required": false,
  53. "description": "短/中/长期策略建议,可从voc-proposal输出中提取或手动补充"
  54. }
  55. },
  56. "pipeline": [
  57. {
  58. "step": 1,
  59. "name": "提取模板变量",
  60. "type": "compute",
  61. "logic": "extractTemplateVars(inputs)",
  62. "algorithm": {
  63. "placeholders": {
  64. "industryName": "直接取 inputs.industryName",
  65. "coverBrandEnglish": "直接取 inputs.coverBrandEnglish",
  66. "reportDate": "直接取 inputs.reportDate",
  67. "totalReviews": "从 reviewAnalysis.stats.totalReviews 提取,格式化为 '1,500条'",
  68. "categoryCount": "从 categoryLandscape.topBrands 或 categories 数组长度提取",
  69. "competitorCount": "从 competitorData.competitors 数组长度提取",
  70. "competitorNames": "从 competitorData.competitors 数组提取 brand 字段,逗号分隔"
  71. }
  72. },
  73. "output": "templateVars"
  74. },
  75. {
  76. "step": 2,
  77. "name": "AI生成REPORT_DATA JSON",
  78. "type": "ai",
  79. "logic": "generateReportData(categoryLandscape, competitorData, reviewAnalysis, socialVocData, userPersona, strategyData, templateVars)",
  80. "aiConfig": {
  81. "systemPrompt": "你是跨境电商数据分析专家。请严格按照指定JSON Schema生成REPORT_DATA对象,用于注入HTML幻灯片报告模板。只输出纯JSON,不要有任何注释或额外文字。",
  82. "userPromptTemplate": "请根据以下分析数据生成完整的REPORT_DATA JSON对象:\n\n行业: ${industryName}\n品牌: ${coverBrandEnglish}\n\n【市场全景数据】\n${categoryLandscapeJson}\n\n【竞品数据】\n${competitorDataJson}\n\n【VOC评论分析】\n${reviewAnalysisJson}\n\n【社媒数据】\n${socialVocDataJson}\n\n【用户画像】\n${userPersonaJson}\n\n【策略建议】\n${strategyDataJson}\n\n请严格按照以下Schema生成REPORT_DATA:\n- metrics: 6个核心KPI指标卡片 [{value数字, prefix, suffix, label, sub}]\n- coreFindings: 5条核心发现 [{text, highlight, highlightClass}] highlightClass选'text-sage'(正向)/'text-rose'(负向)/'text-gold'(关键)\n- coreValues: 5条核心价值 [string]\n- categories: 各品类市场数据 [{name,weeklySales,weeklyRevenue,avgPrice,brands,growth,chinaRatio,highlight(bool),revenueNum(数字),growthNum(数字)}]\n- competitors: 竞品卡片数据 [{name,positioning,positionBadge('badge-gold'/'badge-sage'/'badge-rose'/'badge-blue'),priceRange,igFollowers,tiktokFollowers,skuNote,strategyNote,pros,cons,radarData:[5个0-100分值]}]\n- vocAnalysis: {totalReviews,painPoints:[{icon(emoji),name,pct(1-35),gradient('linear-gradient(90deg,...)'),quote}],highlights:[{name,pct(1-100),color('#...')}],scenes:[{name,pct}]}\n- categoryMatrix: [{name,marketSize,growth,socialHeat,competition,chinaRatio,recommendation,badgeClass}]\n- tiktokHeat: [{name(#话题名),plays(数字)}]\n- seasonalNotes: [{icon(emoji),title,desc}]\n- strategy: {shortTerm:[{title,desc}],midTerm:[{title,desc}],longTerm:[{title,desc}]} 每期3-4条\n- vocPriorities: [{text,badgeClass}] 6-8条VOC驱动的优化优先级\n- conclusion: {topCategory:{emoji,title,name,desc},socialDividend:{emoji,title,name,desc},differentiator:{title,subtitle,desc},keyActions:[{emoji,title,desc}]} keyActions 恰好3条",
  83. "outputFormat": "{\"metrics\":[],\"coreFindings\":[],\"coreValues\":[],\"categories\":[],\"competitors\":[],\"vocAnalysis\":{},\"categoryMatrix\":[],\"tiktokHeat\":[],\"seasonalNotes\":[],\"strategy\":{},\"vocPriorities\":[],\"conclusion\":{}}",
  84. "temperature": 0.3,
  85. "maxTokens": 12000,
  86. "promptPattern": "system约束JSON-only输出 + user按模块注入真实数据 + outputFormat示例引导结构"
  87. },
  88. "output": "reportDataJson"
  89. },
  90. {
  91. "step": 3,
  92. "name": "填充模板生成HTML",
  93. "type": "compute",
  94. "logic": "injectIntoTemplate(reportDataJson, templateVars, templateRef)",
  95. "algorithm": {
  96. "templateLoad": "读取 templateRef 路径的 report_template.html 文件内容",
  97. "placeholderReplace": "将模板中所有 {{key}} 替换为 templateVars[key] 对应的值",
  98. "dataInjection": "将 {{REPORT_DATA_JSON}} 替换为 JSON.stringify(reportDataJson, null, 2)",
  99. "output": "完整HTML字符串,可直接写入 .html 文件并在浏览器打开"
  100. },
  101. "output": "htmlContent"
  102. },
  103. {
  104. "step": 4,
  105. "name": "生成报告统计",
  106. "type": "compute",
  107. "logic": "buildReportStats(reportDataJson, templateVars)",
  108. "algorithm": {
  109. "totalSlides": "固定9屏(封面/目录/执行摘要/市场全景/竞品对标/用户VOC/线索清单/执行策略/总结展望)",
  110. "dataCompleteness": "检查reportDataJson各字段非空率,计算0-100数据完整度",
  111. "generatedAt": "生成时间戳 ISO 8601"
  112. },
  113. "output": "reportStats"
  114. }
  115. ],
  116. "response": {
  117. "type": "object",
  118. "properties": {
  119. "htmlContent": {
  120. "type": "string",
  121. "description": "完整HTML字符串,可直接写入 .html 文件在浏览器打开"
  122. },
  123. "reportDataJson": {
  124. "type": "object",
  125. "description": "生成的 REPORT_DATA JSON 对象(可调试复查)",
  126. "properties": {
  127. "metrics": {
  128. "type": "array"
  129. },
  130. "coreFindings": {
  131. "type": "array"
  132. },
  133. "categories": {
  134. "type": "array"
  135. },
  136. "competitors": {
  137. "type": "array"
  138. },
  139. "vocAnalysis": {
  140. "type": "object"
  141. },
  142. "categoryMatrix": {
  143. "type": "array"
  144. },
  145. "strategy": {
  146. "type": "object"
  147. },
  148. "conclusion": {
  149. "type": "object"
  150. }
  151. }
  152. },
  153. "templateVars": {
  154. "type": "object",
  155. "description": "填充后的 {{placeholder}} 变量表",
  156. "properties": {
  157. "industryName": {
  158. "type": "string"
  159. },
  160. "coverBrandEnglish": {
  161. "type": "string"
  162. },
  163. "totalReviews": {
  164. "type": "string"
  165. },
  166. "categoryCount": {
  167. "type": "string"
  168. },
  169. "competitorCount": {
  170. "type": "string"
  171. },
  172. "competitorNames": {
  173. "type": "string"
  174. },
  175. "reportDate": {
  176. "type": "string"
  177. }
  178. }
  179. },
  180. "reportStats": {
  181. "type": "object",
  182. "description": "报告生成统计",
  183. "properties": {
  184. "totalSlides": {
  185. "type": "integer"
  186. },
  187. "dataCompleteness": {
  188. "type": "number",
  189. "description": "0-100数据完整度百分比"
  190. },
  191. "generatedAt": {
  192. "type": "string",
  193. "description": "生成时间戳"
  194. }
  195. }
  196. }
  197. }
  198. },
  199. "timeout": 300000,
  200. "retry": {
  201. "maxAttempts": 2,
  202. "delay": 3000,
  203. "backoffMultiplier": 2
  204. },
  205. "tokenConfig": {
  206. "type": "bearer",
  207. "configFile": "~/.openclaw/voc-credentials.json",
  208. "tokenField": "vocToken",
  209. "resolutionOrder": [
  210. "configFile"
  211. ],
  212. "apigId": "7HwdQZk55B",
  213. "paymentUrlResolution": {
  214. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  215. "steps": [
  216. "1. 从 voc-credentials.json 获取当前 session token",
  217. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  218. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  219. "4. 将该URL展示给用户,引导扫码支付"
  220. ],
  221. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  222. "userResolveHeaders": {
  223. "X-Parse-Application-Id": "ncloudmaster",
  224. "X-Parse-Session-Token": "{vocToken}"
  225. },
  226. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  227. "paymentParams": {
  228. "user": "{resolvedUserId}",
  229. "apigid": "7HwdQZk55B",
  230. "fun_id": "HOkkX72PMF"
  231. },
  232. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  233. },
  234. "onMissing": {
  235. "action": "showPaymentQR",
  236. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  237. "title": "扫码开通 VOC-AI 数据服务",
  238. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  239. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  240. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  241. },
  242. "onBalanceInsufficient": {
  243. "action": "resolveUserThenShowPayment",
  244. "title": "VOC-AI Token 余额不足,请扫码充值",
  245. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  246. }
  247. },
  248. "errorHandling": {
  249. "balanceInsufficient": {
  250. "conditions": [
  251. {
  252. "responseField": "code",
  253. "operator": "in",
  254. "value": [
  255. -2,
  256. -3,
  257. -10,
  258. 402,
  259. 429
  260. ]
  261. },
  262. {
  263. "responseField": "msg",
  264. "operator": "contains",
  265. "value": [
  266. "余额不足",
  267. "insufficient",
  268. "balance",
  269. "quota",
  270. "没有开通",
  271. "权限或余额"
  272. ]
  273. },
  274. {
  275. "responseField": "mess",
  276. "operator": "contains",
  277. "value": [
  278. "余额不足",
  279. "insufficient",
  280. "balance",
  281. "quota",
  282. "没有开通",
  283. "权限或余额"
  284. ]
  285. },
  286. {
  287. "responseField": "message",
  288. "operator": "contains",
  289. "value": [
  290. "余额不足",
  291. "insufficient",
  292. "balance",
  293. "没有开通",
  294. "权限或余额"
  295. ]
  296. }
  297. ],
  298. "matchMode": "any",
  299. "trigger": "tokenConfig.onBalanceInsufficient"
  300. },
  301. "unauthorized": {
  302. "conditions": [
  303. {
  304. "responseField": "code",
  305. "operator": "in",
  306. "value": [
  307. 401,
  308. 403
  309. ]
  310. },
  311. {
  312. "responseField": "msg",
  313. "operator": "contains",
  314. "value": [
  315. "unauthorized",
  316. "token",
  317. "invalid",
  318. "auth"
  319. ]
  320. }
  321. ],
  322. "matchMode": "any",
  323. "trigger": "tokenConfig.onMissing"
  324. }
  325. }
  326. }