@cloud411716/fancy-webnovel 4.27.2 → 4.27.3
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
|
@@ -316,13 +316,6 @@ function retryPrompt(target, detail) {
|
|
|
316
316
|
].join('\n');
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
export function expectedItemCount(title) {
|
|
320
|
-
const match = String(title || '').match(/(\d+)\s*\+?\s*(?:个|种|条)/);
|
|
321
|
-
if (!match) return 0;
|
|
322
|
-
const count = Number(match[1]);
|
|
323
|
-
return Number.isFinite(count) && count >= 5 ? count : 0;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
319
|
const CJK_RE = /[\u3400-\u9fff\uf900-\ufaff]/;
|
|
327
320
|
|
|
328
321
|
/**
|
|
@@ -346,28 +339,6 @@ export function kindLanguageProblem(file) {
|
|
|
346
339
|
+ '不要写 color_word、person_appearance 这类英文内部标识。请改写后重新写入同一个文件。';
|
|
347
340
|
}
|
|
348
341
|
|
|
349
|
-
/**
|
|
350
|
-
* 清单类作品(标题里写“100个/100种”)必须按条目数量逐条提取,
|
|
351
|
-
* 并额外产出 10 条同 kind + 同 subkind 的扩写素材。
|
|
352
|
-
* 只有格式校验不够:模型可能只提炼了 20 条创作句,却完全漏掉原清单。
|
|
353
|
-
*/
|
|
354
|
-
export function coverageProblem(file, title) {
|
|
355
|
-
const expected = expectedItemCount(title);
|
|
356
|
-
if (!expected) return '';
|
|
357
|
-
const required = expected + 10;
|
|
358
|
-
let records;
|
|
359
|
-
try {
|
|
360
|
-
records = readJsonl(file);
|
|
361
|
-
} catch {
|
|
362
|
-
return '';
|
|
363
|
-
}
|
|
364
|
-
if (records.length >= required) return '';
|
|
365
|
-
return '作品标题写着 ' + expected + ' 条清单,加上同 kind + 同 subkind 的 10 条扩写素材,'
|
|
366
|
-
+ '至少应有 ' + required + ' 条,但当前只有 ' + records.length
|
|
367
|
-
+ ' 条。清单类内容必须逐条输出:name 保留原文条目,不要只提炼一部分或改写成意象句;'
|
|
368
|
-
+ '补全原始条目和 10 条扩写素材后,重新写入同一个文件。';
|
|
369
|
-
}
|
|
370
|
-
|
|
371
342
|
function parseFirstJsonObject(text) {
|
|
372
343
|
let cleaned = String(text || '').replace(/^\uFEFF/, '').trim();
|
|
373
344
|
cleaned = cleaned
|
|
@@ -522,7 +493,7 @@ async function detectCapabilities(ctx, invocation, session, taskList, root, runD
|
|
|
522
493
|
return { ok: false, error: 'LLM 没有返回可解析的能力自检结果' };
|
|
523
494
|
}
|
|
524
495
|
|
|
525
|
-
async function finalizeMaterialFile({ root, target,
|
|
496
|
+
async function finalizeMaterialFile({ root, target, materialTools }) {
|
|
526
497
|
const skip = readSkipMarker(target);
|
|
527
498
|
if (skip) {
|
|
528
499
|
return {
|
|
@@ -542,8 +513,6 @@ async function finalizeMaterialFile({ root, target, title, materialTools }) {
|
|
|
542
513
|
if (!checked.ok) return { ok: false, detail: checked.detail };
|
|
543
514
|
const kindProblem = kindLanguageProblem(target);
|
|
544
515
|
if (kindProblem) return { ok: false, detail: kindProblem };
|
|
545
|
-
const coverage = coverageProblem(target, title);
|
|
546
|
-
if (coverage) return { ok: false, detail: coverage };
|
|
547
516
|
try {
|
|
548
517
|
const result = await importOtherMaterials(root, target);
|
|
549
518
|
return { ok: true, ...result };
|
|
@@ -553,7 +522,7 @@ async function finalizeMaterialFile({ root, target, title, materialTools }) {
|
|
|
553
522
|
}
|
|
554
523
|
|
|
555
524
|
async function analyzeMaterials(ctx, invocation, session, {
|
|
556
|
-
root, prompt, target,
|
|
525
|
+
root, prompt, target, materialTools, taskList,
|
|
557
526
|
}) {
|
|
558
527
|
const waitForTurn = makeWaitForTurn(invocation, {
|
|
559
528
|
timeoutMs: ANALYSIS_TIMEOUT_MS,
|
|
@@ -594,7 +563,7 @@ async function analyzeMaterials(ctx, invocation, session, {
|
|
|
594
563
|
continue;
|
|
595
564
|
}
|
|
596
565
|
|
|
597
|
-
const finalized = await finalizeMaterialFile({ root, target,
|
|
566
|
+
const finalized = await finalizeMaterialFile({ root, target, materialTools });
|
|
598
567
|
if (finalized.ok) return finalized;
|
|
599
568
|
if (finalized.error) return finalized;
|
|
600
569
|
detail = finalized.detail;
|
|
@@ -618,7 +587,6 @@ async function analyzeNote(ctx, invocation, session, {
|
|
|
618
587
|
root,
|
|
619
588
|
prompt,
|
|
620
589
|
target,
|
|
621
|
-
title: note.title,
|
|
622
590
|
materialTools,
|
|
623
591
|
taskList,
|
|
624
592
|
});
|
|
@@ -689,7 +657,6 @@ async function analyzeVideo(ctx, invocation, session, {
|
|
|
689
657
|
root,
|
|
690
658
|
prompt,
|
|
691
659
|
target,
|
|
692
|
-
title: video.title,
|
|
693
660
|
materialTools,
|
|
694
661
|
taskList,
|
|
695
662
|
});
|
|
@@ -710,7 +677,6 @@ async function analyzeArticle(ctx, invocation, session, {
|
|
|
710
677
|
root,
|
|
711
678
|
prompt,
|
|
712
679
|
target: target,
|
|
713
|
-
title: article.title,
|
|
714
680
|
materialTools,
|
|
715
681
|
taskList,
|
|
716
682
|
});
|
|
@@ -1090,7 +1056,6 @@ async function runCrawl(ctx, invocation, session, taskList) {
|
|
|
1090
1056
|
analyzed = await finalizeMaterialFile({
|
|
1091
1057
|
root,
|
|
1092
1058
|
target: job.target,
|
|
1093
|
-
title: job.title,
|
|
1094
1059
|
materialTools,
|
|
1095
1060
|
});
|
|
1096
1061
|
}
|