@cloud411716/fancy-webnovel 0.1.28 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "type": "module",
5
5
  "main": "plugins/fancy-bootstrap/index.js",
6
6
  "exports": {
@@ -275,13 +275,48 @@ async function applyScan(ctx) {
275
275
  ? (result.error.message || JSON.stringify(result.error))
276
276
  : String(result.error || '未知错误');
277
277
  notifyScan(session, '❌ 采集失败:' + errMsg);
278
- } else {
279
- let files = [];
280
- try { files = JSON.parse(result.output).files || []; } catch (_) {}
281
- const fileList = files.length > 0 ? '\n\n📁 生成文件:\n' + files.map(f => ' - ' + f).join('\n') : '';
282
- notifyScan(session, `✅ ${platformLabel(platform)}(${length === 'long' ? '长篇' : '短篇'})采集完成${fileList}\n\n如需扫其他平台,请再次调用 /fancy-scan`);
278
+ return { kind: 'success', text: '' };
283
279
  }
284
280
 
281
+ // Step 7: 解析 receipt,发送分析任务给 LLM
282
+ let receipt;
283
+ try { receipt = JSON.parse(result.output); } catch (_) {
284
+ notifyScan(session, '❌ 采集结果解析失败');
285
+ return { kind: 'success', text: '' };
286
+ }
287
+
288
+ const files = receipt.scan_files || [];
289
+ const reportFile = receipt.report_file || '';
290
+ const topicFile = receipt.topic_decision || '';
291
+ const fileList = files.map(f => '- ' + f.replace(projectRoot + '/', '')).join('\n');
292
+
293
+ // Step 8-9: 通知 LLM 执行分析
294
+ notifyScan(session,
295
+ `📊 采集完成,正在将数据交给 LLM 进行分析...\n` +
296
+ `📁 生成文件:\n${fileList}\n` +
297
+ `📄 报告:${reportFile.replace(projectRoot + '/', '')}\n` +
298
+ `💡 分析报告将写入:${topicFile.replace(projectRoot + '/', '')}`
299
+ );
300
+
301
+ // 发消息给 LLM,让它读取原始文件并生成分析
302
+ const analysisPrompt =
303
+ `## 扫榜数据分析任务\n\n` +
304
+ `平台:${PLATFORM_CN[platform] || platform}(${length === 'long' ? '长篇' : '短篇'})\n` +
305
+ `时间:${receipt.date || ''}\n\n` +
306
+ `已生成的文件:\n${fileList}\n\n` +
307
+ `请执行以下步骤:\n` +
308
+ `1. 读取上述生成的原始数据文件(扫榜结果目录下的 .md 文件)\n` +
309
+ `2. 分析爆款书籍的题材、卖点、节奏、人设等特征\n` +
310
+ `3. 生成扫榜报告(包含:市场趋势、热门题材分析、用户画像、竞争度评估)\n` +
311
+ `4. 给出 3-5 个可行的选题方向建议\n` +
312
+ `5. 将完整分析报告追加写入:${topicFile}\n\n` +
313
+ `报告要求:\n- 客观分析数据,不臆测\n- 选题建议要有差异化竞争力\n- 报告语言:中文`;
314
+
315
+ invocation.agent.followup({
316
+ content: [{ type: 'text', text: analysisPrompt }],
317
+ source: { kind: 'user' }
318
+ });
319
+
285
320
  return { kind: 'success', text: '' };
286
321
  }
287
322
  });
@@ -431,6 +431,17 @@ async function main() {
431
431
  const reportFile = generateReport(platform, length, mdFiles, scanDir);
432
432
  appendTopicDecision(platform, length, reportFile, scanDir);
433
433
 
434
+ // Step 6: 收集原始数据
435
+ const rawData = {};
436
+ for (const f of scanFiles) {
437
+ try {
438
+ const name = f.replace(/^.*\//, '').replace(/\.md$/, '');
439
+ rawData[name] = { path: f, content: '' };
440
+ const { readFileSync } = await import('fs');
441
+ rawData[name].content = readFileSync(f, 'utf-8');
442
+ } catch (_) {}
443
+ }
444
+
434
445
  const receipt = {
435
446
  ok: true,
436
447
  operation: 'scan',
@@ -440,6 +451,7 @@ async function main() {
440
451
  scan_files: scanFiles,
441
452
  report_file: reportFile,
442
453
  topic_decision: join(scanDir, `topic_decision_${today}.md`),
454
+ raw_data: rawData,
443
455
  summary: `${PLATFORM_CN[platform]}(${length})采集完成,共 ${scanFiles.length} 个文件`,
444
456
  };
445
457