@cloud411716/fancy-webnovel 4.28.0 → 4.29.1
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/docs/material-library/README.md +50 -52
- package/docs/material-library/prompt.md +10 -7
- package/docs/workspace-mcp.md +4 -3
- package/package.json +1 -1
- package/plugins/fancy-material/index.js +661 -194
- package/plugins/fancy-material/inventory.js +10 -8
- package/plugins/fancy-material/prompts/world-mother.md +81 -0
- package/plugins/fancy-material/templates.js +46 -24
- package/plugins/fancy-material/world.js +613 -0
- package/plugins/fancy-topic/index.js +39 -18
- package/plugins/fancy-topic/prompts/02-setup-prompt.md +44 -25
- package/plugins/fancy-topic/scripts/save-minimal-topic.js +1 -1
- package/plugins/fancy-topic/templates.js +33 -19
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 两条路径:
|
|
5
5
|
* A 探索模式 /fancy-topic [参数] trim 后为空 → 选平台/选文件/LLM 评分
|
|
6
|
-
* B
|
|
6
|
+
* B 定稿模式 /fancy-topic setup 验收 fancy-material 素材 → 1+2 方案 → 原子写盘 → phase=topic_done
|
|
7
7
|
*
|
|
8
8
|
* 不论哪条路径,都先检查 .fancy-deployed 存在且 phase ∈ {scanned, topic_done}。
|
|
9
9
|
*/
|
|
@@ -22,6 +22,7 @@ import { resolveWorkspace } from '#workspace';
|
|
|
22
22
|
import { topic } from './templates.js';
|
|
23
23
|
import { deployMaterialTools } from '../fancy-material/tool-deploy.js';
|
|
24
24
|
import { countByKind } from '../fancy-material/inventory.js';
|
|
25
|
+
import { readMaterialFlow } from '../fancy-material/world.js';
|
|
25
26
|
|
|
26
27
|
export const inject = ['commands', 'userQuestions', 'tools'];
|
|
27
28
|
|
|
@@ -462,10 +463,17 @@ async function pathExplore(ctx, session, invocation, signal, projectRoot, tasks)
|
|
|
462
463
|
// ---------------------------------------------------------------------------
|
|
463
464
|
|
|
464
465
|
async function pathSetup(ctx, session, invocation, signal, projectRoot, tasks) {
|
|
465
|
-
const
|
|
466
|
+
const flow = readMaterialFlow(projectRoot);
|
|
467
|
+
const suggestion = readSuggestion(projectRoot) || flow?.source?.suggestion_snapshot || null;
|
|
466
468
|
if (!suggestion) {
|
|
467
469
|
return notify(session, 'error', topic.notify({ type: 'no_suggestion' }));
|
|
468
470
|
}
|
|
471
|
+
if (!flow || !flow.world) {
|
|
472
|
+
return notify(session, 'error', topic.notify({
|
|
473
|
+
type: 'no_material_flow',
|
|
474
|
+
worldTitle: flow?.world?.title || '',
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
469
477
|
if (!existsSync(join(projectRoot, '.fancy', 'workspace.json'))) {
|
|
470
478
|
return notify(session, 'error', topic.notify({ type: 'material_not_initialized' }));
|
|
471
479
|
}
|
|
@@ -488,25 +496,37 @@ async function pathSetup(ctx, session, invocation, signal, projectRoot, tasks) {
|
|
|
488
496
|
}
|
|
489
497
|
|
|
490
498
|
tasks.advance(1);
|
|
491
|
-
//
|
|
499
|
+
// 素材验收:setup 只消费已经由 fancy-material 生成并落库的素材。
|
|
500
|
+
// 题材用 flow 里用户实际选择的原子题材做交集查询,避免 suggestion.genre
|
|
501
|
+
// 是平台复合词(悬疑脑洞)而素材实际写成(悬疑/脑洞)时查不到。
|
|
502
|
+
const genres = Array.isArray(flow.facets?.genres) ? flow.facets.genres.filter(Boolean) : [];
|
|
492
503
|
let counts = {};
|
|
493
504
|
try {
|
|
494
|
-
counts = await countByKind(projectRoot,
|
|
505
|
+
counts = await countByKind(projectRoot, genres);
|
|
495
506
|
} catch { /* 查询失败时继续,让提示词里的查询给出具体错误 */ }
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
507
|
+
const coverage = {
|
|
508
|
+
genres,
|
|
509
|
+
ability: ABILITY_KINDS.map((kind) => ({ kind, count: Number(counts[kind]) || 0 })),
|
|
510
|
+
plot: PLOT_KINDS.map((kind) => ({ kind, count: Number(counts[kind]) || 0 })),
|
|
511
|
+
};
|
|
512
|
+
const missing = [...coverage.ability, ...coverage.plot]
|
|
513
|
+
.filter((item) => !item.count)
|
|
514
|
+
.map((item) => item.kind);
|
|
515
|
+
if (missing.length) {
|
|
499
516
|
return notify(session, 'error', topic.notify({
|
|
500
|
-
type: '
|
|
501
|
-
genre: suggestion.genre,
|
|
502
|
-
|
|
503
|
-
|
|
517
|
+
type: 'material_incomplete',
|
|
518
|
+
genre: flow.topic_genre || suggestion.genre,
|
|
519
|
+
worldTitle: flow.world.title || '',
|
|
520
|
+
missing,
|
|
521
|
+
genres,
|
|
504
522
|
}));
|
|
505
523
|
}
|
|
506
524
|
|
|
507
525
|
tasks.advance(2);
|
|
508
526
|
const prompt = topic.setupPrompt({
|
|
509
527
|
suggestion,
|
|
528
|
+
flow,
|
|
529
|
+
coverage,
|
|
510
530
|
queryScript: tools.queryScript,
|
|
511
531
|
workspace: projectRoot,
|
|
512
532
|
});
|
|
@@ -525,21 +545,22 @@ async function pathSetup(ctx, session, invocation, signal, projectRoot, tasks) {
|
|
|
525
545
|
err: (follow && follow.error) || '提示词投递失败',
|
|
526
546
|
}));
|
|
527
547
|
}
|
|
528
|
-
//
|
|
529
|
-
//
|
|
548
|
+
// fire-and-forget:命令立即返回,LLM 在下一个 turn 读取世界母体和素材,
|
|
549
|
+
// 给出 1 个推荐定稿 + 2 个备选,等用户确认后再调用 finalize。
|
|
530
550
|
tasks.detachUntilTurnEnd(invocation, (t) => {
|
|
531
551
|
t.advance(3);
|
|
532
552
|
});
|
|
533
553
|
return notify(session, 'success', topic.notify({
|
|
534
554
|
type: 'setup_started',
|
|
535
|
-
genre: suggestion.genre,
|
|
555
|
+
genre: flow.topic_genre || suggestion.genre,
|
|
556
|
+
worldTitle: flow.world.title || '',
|
|
536
557
|
}));
|
|
537
558
|
}
|
|
538
559
|
|
|
539
560
|
/**
|
|
540
561
|
* 注册 fancy_topic_finalize 工具。
|
|
541
562
|
*
|
|
542
|
-
* LLM
|
|
563
|
+
* LLM 在用户确认基于素材的定稿方案后调用:
|
|
543
564
|
* - 校验最小 topic(genre + ability 6 kinds + plot 7 kinds)
|
|
544
565
|
* - 原子写入 _novel_topic.json
|
|
545
566
|
* - 推进 phase
|
|
@@ -557,7 +578,7 @@ async function registerFinalizeTool(ctx) {
|
|
|
557
578
|
const str = (description) => ({ type: 'string', description });
|
|
558
579
|
ctx.tools.register(defineTool({
|
|
559
580
|
name: 'fancy_topic_finalize',
|
|
560
|
-
description: '
|
|
581
|
+
description: '用户明确确认基于素材的定稿方案后,将 genre + 能力组 6 个 kind + 剧情与脑洞组 7 个 kind 写入 _novel_topic.json,并创建/更新项目库。不要在讨论阶段调用。',
|
|
561
582
|
parameters: {
|
|
562
583
|
title: str('选中方案的标题,用作项目名'),
|
|
563
584
|
genre: str('题材'),
|
|
@@ -659,8 +680,8 @@ function topicTaskTitles(invocation) {
|
|
|
659
680
|
if (raw === 'setup') {
|
|
660
681
|
return [
|
|
661
682
|
'检查工作区与 phase',
|
|
662
|
-
'
|
|
663
|
-
'生成
|
|
683
|
+
'读取世界母体与素材覆盖',
|
|
684
|
+
'生成 1 个推荐定稿 + 2 个备选',
|
|
664
685
|
'等待用户确认方案',
|
|
665
686
|
];
|
|
666
687
|
}
|
|
@@ -1,23 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 素材验收与选题定稿 · ${GENRE}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
这是 `/fancy-material` 之后的**定稿**阶段,不是从零生成选题方案。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
用户已经在 `/fancy-material` 里选好 facet 和世界母体,并生成了素材。你的任务是:
|
|
6
|
+
**只使用真实落库的素材**,给出 1 个推荐定稿 + 2 个备选,等用户确认后写入 `_novel_topic.json`。
|
|
7
|
+
|
|
8
|
+
## 一、输入
|
|
9
|
+
|
|
10
|
+
工作区:`${WORKSPACE}`
|
|
11
|
+
|
|
12
|
+
选题建议:
|
|
6
13
|
|
|
7
14
|
```json
|
|
8
15
|
${SUGGESTION_JSON}
|
|
9
16
|
```
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
当前世界母体与本次选择(`flow.json`):
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
```json
|
|
21
|
+
${FLOW_JSON}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
素材覆盖检查:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
${COVERAGE_JSON}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
题材交集:${GENRE_FILTERS}
|
|
31
|
+
|
|
32
|
+
## 二、查询真实素材
|
|
14
33
|
|
|
15
34
|
查询脚本:`${QUERY_SCRIPT}`
|
|
16
35
|
|
|
17
|
-
|
|
36
|
+
命令模板:
|
|
18
37
|
|
|
19
38
|
```bash
|
|
20
|
-
node '${QUERY_SCRIPT}' --workspace '${WORKSPACE}' --genre '${
|
|
39
|
+
node '${QUERY_SCRIPT}' --workspace '${WORKSPACE}' --genre '${QUERY_GENRE}' --kind <kind> --limit 50 --json
|
|
21
40
|
```
|
|
22
41
|
|
|
23
42
|
需要查询的 kind:
|
|
@@ -28,21 +47,20 @@ node '${QUERY_SCRIPT}' --workspace '${WORKSPACE}' --genre '${GENRE}' --kind <kin
|
|
|
28
47
|
规则:
|
|
29
48
|
|
|
30
49
|
1. 每个 kind 至少查询一次;用 `--json` 读取结果。
|
|
31
|
-
2.
|
|
32
|
-
3.
|
|
33
|
-
4.
|
|
34
|
-
5.
|
|
50
|
+
2. **只使用素材库里真实存在的素材**;不要编造素材名、能力名或剧情。
|
|
51
|
+
3. 题材是交集:本次选择是 `${GENRE_FILTERS}`。可以用其中任意一个题材查询,但选中的素材必须同时满足 `flow.json` 里的全部题材、场景、情绪、情节、身份、关系约束。
|
|
52
|
+
4. 如果某个 kind 查不到结果,可以去掉 `--genre` 再查一次,但只能用真实素材;仍然没有就停下来告诉用户,不要编。
|
|
53
|
+
5. 同一层 facet 多选是 AND,不是 OR。不要把只满足一个条件的素材硬拼成方案。
|
|
35
54
|
6. 不要修改、删除 `.fancy-tools/fancy-material/` 下的脚本。
|
|
36
55
|
|
|
37
|
-
## 三、生成
|
|
56
|
+
## 三、生成 1 个推荐定稿 + 2 个备选
|
|
38
57
|
|
|
39
|
-
|
|
58
|
+
三个方案都必须建立在同一世界母体和真实素材上,差异落在:
|
|
40
59
|
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
- 目标读者/情绪价值不同
|
|
60
|
+
- 能力机制/代价/限制的组合;
|
|
61
|
+
- 核心冲突;
|
|
62
|
+
- 反转或爽点;
|
|
63
|
+
- 情绪价值。
|
|
46
64
|
|
|
47
65
|
每个方案包含:
|
|
48
66
|
|
|
@@ -73,17 +91,18 @@ node '${QUERY_SCRIPT}' --workspace '${WORKSPACE}' --genre '${GENRE}' --kind <kin
|
|
|
73
91
|
|
|
74
92
|
要求:
|
|
75
93
|
|
|
76
|
-
-
|
|
94
|
+
- 推荐方案必须最贴合 `direction_title` 和 `positioning`,但不能把定位里的职业/机构词直接当素材名。
|
|
95
|
+
- 每个 kind 一条最终文案;如果组合了多条真实素材,用 `;` 连接,并保持因果自洽。
|
|
77
96
|
- 每条文案要具体、可写,不要写“很强”“很神秘”这类空话。
|
|
78
|
-
-
|
|
97
|
+
- 三个方案必须能明显区分,不能只换名字。
|
|
79
98
|
- `title` 要能概括方案差异,不要带“方案 N:”前缀。
|
|
80
99
|
|
|
81
100
|
## 四、展示与讨论
|
|
82
101
|
|
|
83
|
-
1.
|
|
84
|
-
2.
|
|
85
|
-
3.
|
|
86
|
-
4.
|
|
102
|
+
1. 先用一张表展示:类型(推荐/备选)、标题、一句话差异、能力机制关键词、核心冲突关键词。
|
|
103
|
+
2. 再逐个展开 `ability` 和 `plot`,方便用户比较。
|
|
104
|
+
3. 明确告诉用户:可以改能力代价、换核心冲突、调整反转或爽点;修改时只改对应方案。
|
|
105
|
+
4. 如果用户说素材不够,不要硬凑;告诉用户运行 `/fancy-material continue`,沿用当前世界母体补素材。
|
|
87
106
|
|
|
88
107
|
## 五、确认与写入
|
|
89
108
|
|
|
@@ -104,7 +123,7 @@ fancy_topic_finalize
|
|
|
104
123
|
|
|
105
124
|
- 已写入 `_novel_topic.json`
|
|
106
125
|
- 已创建/更新项目
|
|
107
|
-
- 下一步可以运行 `/fancy-
|
|
126
|
+
- 下一步可以运行 `/fancy-build scale` 构建故事
|
|
108
127
|
|
|
109
128
|
在用户确认之前:
|
|
110
129
|
|
|
@@ -390,11 +390,19 @@ export const topic = {
|
|
|
390
390
|
* @param {string} args.queryScript - 已部署的素材查询脚本绝对路径
|
|
391
391
|
* @param {string} args.workspace - 工作区绝对路径
|
|
392
392
|
*/
|
|
393
|
-
setupPrompt({ suggestion, queryScript, workspace }) {
|
|
394
|
-
const genre = suggestion?.genre || '';
|
|
393
|
+
setupPrompt({ suggestion, flow = null, coverage = null, queryScript, workspace }) {
|
|
394
|
+
const genre = flow?.topic_genre || suggestion?.genre || '';
|
|
395
|
+
const genres = Array.isArray(flow?.facets?.genres) && flow.facets.genres.length
|
|
396
|
+
? flow.facets.genres
|
|
397
|
+
: (genre ? [genre] : []);
|
|
395
398
|
return renderSetupPrompt({
|
|
396
399
|
GENRE: genre,
|
|
400
|
+
QUERY_GENRE: genres[0] || genre || '',
|
|
401
|
+
GENRE_FILTERS: genres.map(g => `\`${g}\``).join('、') || '(未限制)',
|
|
402
|
+
WORLD_TITLE: flow?.world?.title || '',
|
|
397
403
|
SUGGESTION_JSON: JSON.stringify(suggestion || {}, null, 2),
|
|
404
|
+
FLOW_JSON: JSON.stringify(flow || {}, null, 2),
|
|
405
|
+
COVERAGE_JSON: JSON.stringify(coverage || {}, null, 2),
|
|
398
406
|
ABILITY_KINDS: ABILITY_KINDS.map(k => `\`${k}\``).join('、'),
|
|
399
407
|
PLOT_KINDS: PLOT_KINDS.map(k => `\`${k}\``).join('、'),
|
|
400
408
|
QUERY_SCRIPT: queryScript || '',
|
|
@@ -405,22 +413,22 @@ export const topic = {
|
|
|
405
413
|
/**
|
|
406
414
|
* 通知模板(左侧消息栏)
|
|
407
415
|
*/
|
|
408
|
-
notify({ type, platform, phase, decisionFile, blockCount, fieldCount, missing, err, projectRoot, extra, available, notes, file, reasons, arg, direction, genre, suggestionPath,
|
|
416
|
+
notify({ type, platform, phase, decisionFile, blockCount, fieldCount, missing, err, projectRoot, extra, available, notes, file, reasons, arg, direction, genre, suggestionPath, worldTitle, genres }) {
|
|
409
417
|
switch (type) {
|
|
410
418
|
case 'help':
|
|
411
419
|
return `📝 选题 用法
|
|
412
420
|
|
|
413
421
|
/fancy-topic 选择 decision 文件、平台和候选方向,写入 _novel_topic_suggestion.json
|
|
414
|
-
/fancy-topic setup
|
|
422
|
+
/fancy-topic setup 在 fancy-material 之后验收素材,生成 1 个推荐定稿 + 2 个备选,确认后写入 _novel_topic.json
|
|
415
423
|
/fancy-topic help 显示本帮助
|
|
416
424
|
|
|
417
|
-
|
|
425
|
+
作用:先定方向,再用世界母体生成素材,最后按素材验收定稿。`;
|
|
418
426
|
|
|
419
427
|
case 'invalid_argument':
|
|
420
428
|
return `❌ 参数无效:${arg || '(空)'}\n`
|
|
421
429
|
+ '/fancy-topic 支持以下用法:\n'
|
|
422
430
|
+ '- /fancy-topic:选择 decision 文件、平台和候选方向,写入 _novel_topic_suggestion.json;\n'
|
|
423
|
-
+ '- /fancy-topic setup
|
|
431
|
+
+ '- /fancy-topic setup:在 fancy-material 之后验收素材,生成 1 个推荐定稿 + 2 个备选,确认后写入 _novel_topic.json;\n'
|
|
424
432
|
+ '- /fancy-topic help:查看本命令帮助。';
|
|
425
433
|
|
|
426
434
|
case 'cancelled':
|
|
@@ -505,7 +513,7 @@ export const topic = {
|
|
|
505
513
|
`🎯 方向:${direction || ''}\n` +
|
|
506
514
|
`🏷️ 题材:${genre || ''}\n` +
|
|
507
515
|
`📁 文件:${suggestionPath || '_novel_topic_suggestion.json'}\n` +
|
|
508
|
-
'下一步:运行 /fancy-topic setup
|
|
516
|
+
'下一步:运行 /fancy-material 选择世界母体并生成素材;素材足够后再运行 /fancy-topic setup 定稿。';
|
|
509
517
|
|
|
510
518
|
case 'path_a_done': {
|
|
511
519
|
const noteText = (notes && notes.length)
|
|
@@ -516,7 +524,7 @@ export const topic = {
|
|
|
516
524
|
`📚 平台:${platform || ''}\n` +
|
|
517
525
|
`📁 参考:${decisionFile || ''}` +
|
|
518
526
|
noteText + '\n' +
|
|
519
|
-
`💡 LLM 将在对话中给出 6 维评分与 ${TOPIC_FIELDS.length}
|
|
527
|
+
`💡 LLM 将在对话中给出 6 维评分与 ${TOPIC_FIELDS.length} 个字段建议。确定方向后,请运行 /fancy-material 生成素材;素材足够后再运行 /fancy-topic setup 定稿。`
|
|
520
528
|
);
|
|
521
529
|
}
|
|
522
530
|
|
|
@@ -526,21 +534,27 @@ export const topic = {
|
|
|
526
534
|
case 'material_not_initialized':
|
|
527
535
|
return '⚠️ 当前工作区还没有初始化素材库。\n请先运行 /fancy-bootstrap 初始化工作区,或运行 /fancy-material init 补齐素材库 schema。';
|
|
528
536
|
|
|
529
|
-
case '
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
537
|
+
case 'no_material_flow':
|
|
538
|
+
return '⚠️ 还没有可验收的世界母体。\n' +
|
|
539
|
+
'请先运行 /fancy-material,选择 facet 和世界母体,生成至少一轮素材;\n' +
|
|
540
|
+
'素材不够可以多次运行 /fancy-material continue 追加,然后再运行 /fancy-topic setup。';
|
|
541
|
+
|
|
542
|
+
case 'material_incomplete': {
|
|
543
|
+
const list = Array.isArray(missing) ? missing : [];
|
|
544
|
+
const genreText = Array.isArray(genres) && genres.length ? genres.join('、') : (genre || '未限制');
|
|
545
|
+
return `⚠️ 世界母体「${worldTitle || '未命名'}」的素材还不够定稿。\n` +
|
|
546
|
+
`题材交集:${genreText}\n` +
|
|
547
|
+
`缺少这些 kind:${list.join('、') || '未知'}\n` +
|
|
548
|
+
'不会凭空编造素材。请运行:\n' +
|
|
549
|
+
' /fancy-material continue\n' +
|
|
550
|
+
'沿用同一世界母体,选择「能力 + 剧情与脑洞」范围补齐后,再运行 /fancy-topic setup。';
|
|
538
551
|
}
|
|
539
552
|
|
|
540
553
|
case 'setup_started':
|
|
541
|
-
return `✅
|
|
554
|
+
return `✅ 已把素材验收/定稿任务交给 LLM\n` +
|
|
555
|
+
`🌍 世界母体:${worldTitle || '未命名'}\n` +
|
|
542
556
|
`🏷️ 题材:${genre || ''}\n` +
|
|
543
|
-
'LLM
|
|
557
|
+
'LLM 会读取世界母体和真实素材,给出 1 个推荐定稿 + 2 个备选。你可以直接和它讨论;确认后它会调用 fancy_topic_finalize 写入 `_novel_topic.json`。';
|
|
544
558
|
|
|
545
559
|
case 'setup_prompt_failed':
|
|
546
560
|
return '❌ 向 LLM 发送 setup 提示词失败:' + (err || '未知错误');
|