@cloud411716/fancy-webnovel 4.30.21 → 4.30.22
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
|
@@ -2059,6 +2059,8 @@ function teamText(root, config) {
|
|
|
2059
2059
|
'',
|
|
2060
2060
|
`配置文件:${teamConfigPath(root)}`,
|
|
2061
2061
|
'',
|
|
2062
|
+
'注意:A、B、裁判必须使用不同模型,否则双生成和交叉审查没有意义。',
|
|
2063
|
+
'',
|
|
2062
2064
|
'设置示例:',
|
|
2063
2065
|
' /fancy-material team set a opencode-go glm-5.3',
|
|
2064
2066
|
' /fancy-material team set b opencode-go kimi-k3',
|
|
@@ -2134,6 +2136,12 @@ async function handleTeamCommand(ctx, session, tokens) {
|
|
|
2134
2136
|
].filter(Boolean).join('\n'));
|
|
2135
2137
|
}
|
|
2136
2138
|
const field = key === 'a' ? 'generatorA' : key === 'b' ? 'generatorB' : 'judge';
|
|
2139
|
+
const clash = ['generatorA', 'generatorB', 'judge']
|
|
2140
|
+
.filter((name) => name !== field)
|
|
2141
|
+
.find((name) => config[name] && config[name].provider === provider && config[name].model === model);
|
|
2142
|
+
if (clash) {
|
|
2143
|
+
return notify(session, 'error', `❌ ${provider}/${model} 已被 ${clash} 使用。A、B、裁判必须使用不同模型。`);
|
|
2144
|
+
}
|
|
2137
2145
|
config[field] = { provider, model };
|
|
2138
2146
|
writeTeamConfig(root, config);
|
|
2139
2147
|
return notify(session, 'success', `✅ ${field} 已设为 ${provider}/${model}。`);
|
|
@@ -84,6 +84,21 @@ export function teamConfigProblem(config) {
|
|
|
84
84
|
if (!config.generatorB) missing.push('generatorB');
|
|
85
85
|
if (!config.judge) missing.push('judge');
|
|
86
86
|
if (missing.length) return 'team 模式缺少模型:' + missing.join('、') + '。用 /fancy-material team set 设置。';
|
|
87
|
+
const seen = new Map();
|
|
88
|
+
const duplicates = [];
|
|
89
|
+
for (const [label, route] of [
|
|
90
|
+
['generatorA', config.generatorA],
|
|
91
|
+
['generatorB', config.generatorB],
|
|
92
|
+
['judge', config.judge],
|
|
93
|
+
]) {
|
|
94
|
+
const key = `${route.provider}/${route.model}`;
|
|
95
|
+
if (seen.has(key)) duplicates.push(`${seen.get(key)} 与 ${label} 都是 ${key}`);
|
|
96
|
+
else seen.set(key, label);
|
|
97
|
+
}
|
|
98
|
+
if (duplicates.length) {
|
|
99
|
+
return 'team 模式的三个角色必须使用不同模型:' + duplicates.join(';')
|
|
100
|
+
+ '。同模型会让双生成和交叉审查失去意义。';
|
|
101
|
+
}
|
|
87
102
|
return '';
|
|
88
103
|
}
|
|
89
104
|
|
|
@@ -279,7 +294,11 @@ async function callSubagent({ subagents, parent, prompt, route, label, schema, s
|
|
|
279
294
|
}
|
|
280
295
|
return { ok: true, value: textFromBlocks(result.output) };
|
|
281
296
|
} catch (err) {
|
|
282
|
-
return {
|
|
297
|
+
return {
|
|
298
|
+
ok: false,
|
|
299
|
+
error: err && err.message ? err.message : String(err),
|
|
300
|
+
stack: err && err.stack ? String(err.stack) : '',
|
|
301
|
+
};
|
|
283
302
|
} finally {
|
|
284
303
|
if (timer) clearTimeout(timer);
|
|
285
304
|
try { await activation.dispose(); } catch { /* best effort */ }
|
|
@@ -345,6 +364,7 @@ export async function runTeamBatch({
|
|
|
345
364
|
}
|
|
346
365
|
const problem = teamConfigProblem(team);
|
|
347
366
|
if (problem) return { ok: false, error: problem };
|
|
367
|
+
const parentSignal = signal || new AbortController().signal;
|
|
348
368
|
|
|
349
369
|
const aFile = path.join(runDir, 'team-a.jsonl');
|
|
350
370
|
const bFile = path.join(runDir, 'team-b.jsonl');
|
|
@@ -359,46 +379,57 @@ export async function runTeamBatch({
|
|
|
359
379
|
writePromptFile(promptBFile, appendTeamRole(retargetPrompt(prompt, file, bFile), 'B', bFile, aFile));
|
|
360
380
|
writePromptFile(rubricFile, `${manualBlock || ''}\n\n${TEAM_RUBRIC}`);
|
|
361
381
|
|
|
382
|
+
const metaFile = path.join(runDir, 'team-meta.json');
|
|
383
|
+
const reviewFile = path.join(runDir, 'team-review.json');
|
|
384
|
+
const meta = {
|
|
385
|
+
batchId,
|
|
386
|
+
batchNo,
|
|
387
|
+
startedAt: new Date().toISOString(),
|
|
388
|
+
generatorA: team.generatorA,
|
|
389
|
+
generatorB: team.generatorB,
|
|
390
|
+
judge: team.judge,
|
|
391
|
+
reviewMode: team.reviewMode,
|
|
392
|
+
maxReviewRounds: team.maxReviewRounds,
|
|
393
|
+
maxTotalCalls: Math.max(6, Number(team.maxTotalCalls) || 12),
|
|
394
|
+
phase: 'generate',
|
|
395
|
+
};
|
|
396
|
+
writeJsonFile(metaFile, meta);
|
|
397
|
+
|
|
362
398
|
let calls = 0;
|
|
363
399
|
const maxCalls = Math.max(6, Number(team.maxTotalCalls) || 12);
|
|
364
400
|
const call = async (promptText, route, label, schema) => {
|
|
365
401
|
if (calls >= maxCalls) return { ok: false, error: 'team workflow reached maxTotalCalls' };
|
|
366
402
|
calls += 1;
|
|
367
|
-
return callSubagent({ subagents, parent, prompt: promptText, route, label, schema });
|
|
403
|
+
return callSubagent({ subagents, parent, prompt: promptText, route, label, schema, signal: parentSignal });
|
|
368
404
|
};
|
|
369
405
|
|
|
370
406
|
const [genA, genB] = await Promise.all([
|
|
371
407
|
call(genPrompt(promptAFile, aFile, bFile, 'A'), team.generatorA, 'gen-a'),
|
|
372
408
|
call(genPrompt(promptBFile, bFile, aFile, 'B'), team.generatorB, 'gen-b'),
|
|
373
409
|
]);
|
|
374
|
-
|
|
375
|
-
if (!
|
|
410
|
+
meta.calls = calls;
|
|
411
|
+
if (!genA.ok || !genB.ok) {
|
|
412
|
+
meta.error = !genA.ok ? '生成者 A 失败:' + genA.error : '生成者 B 失败:' + genB.error;
|
|
413
|
+
meta.genA = genA;
|
|
414
|
+
meta.genB = genB;
|
|
415
|
+
writeJsonFile(metaFile, meta);
|
|
416
|
+
return { ok: false, error: meta.error + (genA.stack ? '\n' + genA.stack : '') + (genB.stack ? '\n' + genB.stack : '') };
|
|
417
|
+
}
|
|
376
418
|
for (const [label, candidate] of [['A', aFile], ['B', bFile]]) {
|
|
377
419
|
if (!fs.existsSync(candidate) || fs.statSync(candidate).size === 0) {
|
|
378
|
-
|
|
420
|
+
meta.error = `生成者 ${label} 没有写出文件:${candidate}`;
|
|
421
|
+
writeJsonFile(metaFile, meta);
|
|
422
|
+
return { ok: false, error: meta.error };
|
|
379
423
|
}
|
|
380
424
|
}
|
|
381
425
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const parentSignal = signal || new AbortController().signal;
|
|
426
|
+
meta.phase = 'review';
|
|
427
|
+
writeJsonFile(metaFile, meta);
|
|
385
428
|
let aPassed = false;
|
|
386
429
|
let bPassed = false;
|
|
387
430
|
let round = 0;
|
|
388
431
|
let stopReason = '';
|
|
389
432
|
const history = [];
|
|
390
|
-
const meta = {
|
|
391
|
-
batchId,
|
|
392
|
-
batchNo,
|
|
393
|
-
startedAt: new Date().toISOString(),
|
|
394
|
-
generatorA: team.generatorA,
|
|
395
|
-
generatorB: team.generatorB,
|
|
396
|
-
judge: team.judge,
|
|
397
|
-
reviewMode: team.reviewMode,
|
|
398
|
-
maxReviewRounds: team.maxReviewRounds,
|
|
399
|
-
maxTotalCalls: maxCalls,
|
|
400
|
-
};
|
|
401
|
-
writeJsonFile(metaFile, meta);
|
|
402
433
|
|
|
403
434
|
// Keep one call in reserve for the judge. A full review-response-revision
|
|
404
435
|
// round costs up to six calls, so the budget check happens before each stage.
|
|
@@ -498,6 +529,8 @@ export async function runTeamBatch({
|
|
|
498
529
|
return { ok: false, error };
|
|
499
530
|
}
|
|
500
531
|
|
|
532
|
+
meta.phase = 'judge';
|
|
533
|
+
writeJsonFile(metaFile, meta);
|
|
501
534
|
const judge = await call(
|
|
502
535
|
judgePrompt(round, aPassed, bPassed, history, aFile, bFile, finalFile, rubricFile),
|
|
503
536
|
team.judge,
|
|
@@ -25,7 +25,7 @@ export function helpText() {
|
|
|
25
25
|
/fancy-material continue 沿用上次的世界母体、facet、风格和范围,继续追加素材
|
|
26
26
|
/fancy-material team show 查看双生成 + 交叉审查 + 裁判的配置
|
|
27
27
|
/fancy-material team models [provider] 查看当前可用模型(默认 opencode-go)
|
|
28
|
-
/fancy-material team set a|b|judge <provider> <model>
|
|
28
|
+
/fancy-material team set a|b|judge <provider> <model> 设置生成者/裁判模型(三者必须不同)
|
|
29
29
|
/fancy-material team set rounds <1-10> 设置最多交叉审查轮次(默认 5)
|
|
30
30
|
/fancy-material team set max-calls <6-40> 设置整个 workflow 最多 agent 调用
|
|
31
31
|
/fancy-material team on|off 开/关 Team 模式
|