@qihuang02/world-book-mcp 0.0.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/README.md +187 -0
- package/dist/core/capability-matrix.d.ts +17 -0
- package/dist/core/capability-matrix.js +133 -0
- package/dist/core/capability-matrix.js.map +1 -0
- package/dist/core/chapter-extraction.d.ts +12 -0
- package/dist/core/chapter-extraction.js +65 -0
- package/dist/core/chapter-extraction.js.map +1 -0
- package/dist/core/character-card-builder.d.ts +76 -0
- package/dist/core/character-card-builder.js +112 -0
- package/dist/core/character-card-builder.js.map +1 -0
- package/dist/core/character-card-query.d.ts +5 -0
- package/dist/core/character-card-query.js +30 -0
- package/dist/core/character-card-query.js.map +1 -0
- package/dist/core/character-card-validator.d.ts +17 -0
- package/dist/core/character-card-validator.js +42 -0
- package/dist/core/character-card-validator.js.map +1 -0
- package/dist/core/character-templates.d.ts +29 -0
- package/dist/core/character-templates.js +60 -0
- package/dist/core/character-templates.js.map +1 -0
- package/dist/core/clarification.d.ts +24 -0
- package/dist/core/clarification.js +433 -0
- package/dist/core/clarification.js.map +1 -0
- package/dist/core/config-explainer.d.ts +2 -0
- package/dist/core/config-explainer.js +44 -0
- package/dist/core/config-explainer.js.map +1 -0
- package/dist/core/content-lint.d.ts +15 -0
- package/dist/core/content-lint.js +90 -0
- package/dist/core/content-lint.js.map +1 -0
- package/dist/core/decision-prompts.d.ts +45 -0
- package/dist/core/decision-prompts.js +93 -0
- package/dist/core/decision-prompts.js.map +1 -0
- package/dist/core/delivery-checklist.d.ts +21 -0
- package/dist/core/delivery-checklist.js +63 -0
- package/dist/core/delivery-checklist.js.map +1 -0
- package/dist/core/derivative-outline.d.ts +19 -0
- package/dist/core/derivative-outline.js +107 -0
- package/dist/core/derivative-outline.js.map +1 -0
- package/dist/core/draft-template.d.ts +2 -0
- package/dist/core/draft-template.js +19 -0
- package/dist/core/draft-template.js.map +1 -0
- package/dist/core/draft-update.d.ts +5 -0
- package/dist/core/draft-update.js +34 -0
- package/dist/core/draft-update.js.map +1 -0
- package/dist/core/ejs-entries.d.ts +5 -0
- package/dist/core/ejs-entries.js +22 -0
- package/dist/core/ejs-entries.js.map +1 -0
- package/dist/core/ejs-phase-plan.d.ts +27 -0
- package/dist/core/ejs-phase-plan.js +77 -0
- package/dist/core/ejs-phase-plan.js.map +1 -0
- package/dist/core/ejs-template.d.ts +10 -0
- package/dist/core/ejs-template.js +70 -0
- package/dist/core/ejs-template.js.map +1 -0
- package/dist/core/ejs-validator.d.ts +18 -0
- package/dist/core/ejs-validator.js +60 -0
- package/dist/core/ejs-validator.js.map +1 -0
- package/dist/core/entry-planner.d.ts +8 -0
- package/dist/core/entry-planner.js +79 -0
- package/dist/core/entry-planner.js.map +1 -0
- package/dist/core/entry-templates.d.ts +7 -0
- package/dist/core/entry-templates.js +66 -0
- package/dist/core/entry-templates.js.map +1 -0
- package/dist/core/extraction-outline.d.ts +2 -0
- package/dist/core/extraction-outline.js +46 -0
- package/dist/core/extraction-outline.js.map +1 -0
- package/dist/core/final-review.d.ts +13 -0
- package/dist/core/final-review.js +80 -0
- package/dist/core/final-review.js.map +1 -0
- package/dist/core/greeting-validator.d.ts +17 -0
- package/dist/core/greeting-validator.js +79 -0
- package/dist/core/greeting-validator.js.map +1 -0
- package/dist/core/html-beautify-assets.d.ts +6 -0
- package/dist/core/html-beautify-assets.js +59 -0
- package/dist/core/html-beautify-assets.js.map +1 -0
- package/dist/core/html-beautify-template.d.ts +8 -0
- package/dist/core/html-beautify-template.js +46 -0
- package/dist/core/html-beautify-template.js.map +1 -0
- package/dist/core/html-beautify-validator.d.ts +21 -0
- package/dist/core/html-beautify-validator.js +66 -0
- package/dist/core/html-beautify-validator.js.map +1 -0
- package/dist/core/html-regex-pair.d.ts +18 -0
- package/dist/core/html-regex-pair.js +77 -0
- package/dist/core/html-regex-pair.js.map +1 -0
- package/dist/core/item-entry-validator.d.ts +10 -0
- package/dist/core/item-entry-validator.js +27 -0
- package/dist/core/item-entry-validator.js.map +1 -0
- package/dist/core/mvu-assets.d.ts +44 -0
- package/dist/core/mvu-assets.js +140 -0
- package/dist/core/mvu-assets.js.map +1 -0
- package/dist/core/mvu-template.d.ts +8 -0
- package/dist/core/mvu-template.js +45 -0
- package/dist/core/mvu-template.js.map +1 -0
- package/dist/core/mvu-validator.d.ts +18 -0
- package/dist/core/mvu-validator.js +75 -0
- package/dist/core/mvu-validator.js.map +1 -0
- package/dist/core/position-map.d.ts +5 -0
- package/dist/core/position-map.js +27 -0
- package/dist/core/position-map.js.map +1 -0
- package/dist/core/project-lint.d.ts +15 -0
- package/dist/core/project-lint.js +54 -0
- package/dist/core/project-lint.js.map +1 -0
- package/dist/core/regex-validator.d.ts +13 -0
- package/dist/core/regex-validator.js +41 -0
- package/dist/core/regex-validator.js.map +1 -0
- package/dist/core/style-extraction.d.ts +12 -0
- package/dist/core/style-extraction.js +87 -0
- package/dist/core/style-extraction.js.map +1 -0
- package/dist/core/task-classifier.d.ts +17 -0
- package/dist/core/task-classifier.js +107 -0
- package/dist/core/task-classifier.js.map +1 -0
- package/dist/core/tool-usage-guide.d.ts +13 -0
- package/dist/core/tool-usage-guide.js +198 -0
- package/dist/core/tool-usage-guide.js.map +1 -0
- package/dist/core/workflow.d.ts +12 -0
- package/dist/core/workflow.js +129 -0
- package/dist/core/workflow.js.map +1 -0
- package/dist/core/worldbook-builder.d.ts +6 -0
- package/dist/core/worldbook-builder.js +60 -0
- package/dist/core/worldbook-builder.js.map +1 -0
- package/dist/core/worldbook-importer.d.ts +7 -0
- package/dist/core/worldbook-importer.js +50 -0
- package/dist/core/worldbook-importer.js.map +1 -0
- package/dist/core/worldbook-patch.d.ts +23 -0
- package/dist/core/worldbook-patch.js +100 -0
- package/dist/core/worldbook-patch.js.map +1 -0
- package/dist/core/worldbook-planning.d.ts +41 -0
- package/dist/core/worldbook-planning.js +74 -0
- package/dist/core/worldbook-planning.js.map +1 -0
- package/dist/core/worldbook-query.d.ts +7 -0
- package/dist/core/worldbook-query.js +58 -0
- package/dist/core/worldbook-query.js.map +1 -0
- package/dist/core/worldbook-validator.d.ts +19 -0
- package/dist/core/worldbook-validator.js +116 -0
- package/dist/core/worldbook-validator.js.map +1 -0
- package/dist/core/worldbuilding.d.ts +80 -0
- package/dist/core/worldbuilding.js +134 -0
- package/dist/core/worldbuilding.js.map +1 -0
- package/dist/core/writing-optimization-report.d.ts +19 -0
- package/dist/core/writing-optimization-report.js +25 -0
- package/dist/core/writing-optimization-report.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/register.d.ts +2 -0
- package/dist/prompts/register.js +37 -0
- package/dist/prompts/register.js.map +1 -0
- package/dist/resources/usage-resources.d.ts +2 -0
- package/dist/resources/usage-resources.js +15 -0
- package/dist/resources/usage-resources.js.map +1 -0
- package/dist/schemas/chapter-outline.d.ts +28 -0
- package/dist/schemas/chapter-outline.js +17 -0
- package/dist/schemas/chapter-outline.js.map +1 -0
- package/dist/schemas/character-card.d.ts +124 -0
- package/dist/schemas/character-card.js +49 -0
- package/dist/schemas/character-card.js.map +1 -0
- package/dist/schemas/decision.d.ts +50 -0
- package/dist/schemas/decision.js +37 -0
- package/dist/schemas/decision.js.map +1 -0
- package/dist/schemas/derivative-outline.d.ts +204 -0
- package/dist/schemas/derivative-outline.js +55 -0
- package/dist/schemas/derivative-outline.js.map +1 -0
- package/dist/schemas/ejs.d.ts +189 -0
- package/dist/schemas/ejs.js +40 -0
- package/dist/schemas/ejs.js.map +1 -0
- package/dist/schemas/extraction.d.ts +219 -0
- package/dist/schemas/extraction.js +51 -0
- package/dist/schemas/extraction.js.map +1 -0
- package/dist/schemas/html-beautify.d.ts +159 -0
- package/dist/schemas/html-beautify.js +42 -0
- package/dist/schemas/html-beautify.js.map +1 -0
- package/dist/schemas/mvu.d.ts +60 -0
- package/dist/schemas/mvu.js +30 -0
- package/dist/schemas/mvu.js.map +1 -0
- package/dist/schemas/project.d.ts +579 -0
- package/dist/schemas/project.js +50 -0
- package/dist/schemas/project.js.map +1 -0
- package/dist/schemas/research.d.ts +56 -0
- package/dist/schemas/research.js +21 -0
- package/dist/schemas/research.js.map +1 -0
- package/dist/schemas/sillytavern-worldbook.d.ts +104 -0
- package/dist/schemas/sillytavern-worldbook.js +55 -0
- package/dist/schemas/sillytavern-worldbook.js.map +1 -0
- package/dist/schemas/source.d.ts +40 -0
- package/dist/schemas/source.js +20 -0
- package/dist/schemas/source.js.map +1 -0
- package/dist/schemas/style-profile.d.ts +35 -0
- package/dist/schemas/style-profile.js +16 -0
- package/dist/schemas/style-profile.js.map +1 -0
- package/dist/schemas/worldbook-draft.d.ts +236 -0
- package/dist/schemas/worldbook-draft.js +89 -0
- package/dist/schemas/worldbook-draft.js.map +1 -0
- package/dist/schemas/worldbook-patch.d.ts +423 -0
- package/dist/schemas/worldbook-patch.js +78 -0
- package/dist/schemas/worldbook-patch.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +15 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/path-policy.d.ts +13 -0
- package/dist/storage/path-policy.js +44 -0
- package/dist/storage/path-policy.js.map +1 -0
- package/dist/storage/project-store.d.ts +8 -0
- package/dist/storage/project-store.js +113 -0
- package/dist/storage/project-store.js.map +1 -0
- package/dist/tools/character-card-tools.d.ts +2 -0
- package/dist/tools/character-card-tools.js +118 -0
- package/dist/tools/character-card-tools.js.map +1 -0
- package/dist/tools/decision-tools.d.ts +2 -0
- package/dist/tools/decision-tools.js +55 -0
- package/dist/tools/decision-tools.js.map +1 -0
- package/dist/tools/extraction-tools.d.ts +2 -0
- package/dist/tools/extraction-tools.js +57 -0
- package/dist/tools/extraction-tools.js.map +1 -0
- package/dist/tools/helpers.d.ts +9 -0
- package/dist/tools/helpers.js +14 -0
- package/dist/tools/helpers.js.map +1 -0
- package/dist/tools/lint-review-tools.d.ts +2 -0
- package/dist/tools/lint-review-tools.js +30 -0
- package/dist/tools/lint-review-tools.js.map +1 -0
- package/dist/tools/mvu-html-ejs-tools.d.ts +2 -0
- package/dist/tools/mvu-html-ejs-tools.js +153 -0
- package/dist/tools/mvu-html-ejs-tools.js.map +1 -0
- package/dist/tools/project-tools.d.ts +2 -0
- package/dist/tools/project-tools.js +39 -0
- package/dist/tools/project-tools.js.map +1 -0
- package/dist/tools/register.d.ts +2 -0
- package/dist/tools/register.js +23 -0
- package/dist/tools/register.js.map +1 -0
- package/dist/tools/style-chapter-tools.d.ts +2 -0
- package/dist/tools/style-chapter-tools.js +40 -0
- package/dist/tools/style-chapter-tools.js.map +1 -0
- package/dist/tools/workflow-tools.d.ts +2 -0
- package/dist/tools/workflow-tools.js +60 -0
- package/dist/tools/workflow-tools.js.map +1 -0
- package/dist/tools/worldbook-tools.d.ts +2 -0
- package/dist/tools/worldbook-tools.js +180 -0
- package/dist/tools/worldbook-tools.js.map +1 -0
- package/dist/tools/worldbuilding-tools.d.ts +2 -0
- package/dist/tools/worldbuilding-tools.js +40 -0
- package/dist/tools/worldbuilding-tools.js.map +1 -0
- package/dist/utils/ids.d.ts +2 -0
- package/dist/utils/ids.js +8 -0
- package/dist/utils/ids.js.map +1 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { safeJsonParse } from "../utils/json.js";
|
|
3
|
+
import { resolveReadableCardPath } from "../storage/path-policy.js";
|
|
4
|
+
export async function queryCharacterCard(input) {
|
|
5
|
+
const resolvedPath = resolveReadableCardPath(input.path);
|
|
6
|
+
const card = safeJsonParse(await fs.readFile(resolvedPath, "utf8"));
|
|
7
|
+
switch (input.mode) {
|
|
8
|
+
case "summary":
|
|
9
|
+
return {
|
|
10
|
+
name: card.data?.name ?? card.name,
|
|
11
|
+
spec: card.spec,
|
|
12
|
+
spec_version: card.spec_version,
|
|
13
|
+
greeting_count: 1 + (card.data?.alternate_greetings?.length ?? 0),
|
|
14
|
+
worldbook_name: card.data?.character_book?.name,
|
|
15
|
+
worldbook_entry_count: card.data?.character_book?.entries?.length ?? 0,
|
|
16
|
+
tags: card.data?.tags ?? card.tags ?? [],
|
|
17
|
+
};
|
|
18
|
+
case "worldbook_entries":
|
|
19
|
+
return {
|
|
20
|
+
name: card.data?.name ?? card.name,
|
|
21
|
+
entries: card.data?.character_book?.entries ?? [],
|
|
22
|
+
};
|
|
23
|
+
case "greetings":
|
|
24
|
+
return {
|
|
25
|
+
first_mes: card.data?.first_mes ?? card.first_mes,
|
|
26
|
+
alternate_greetings: card.data?.alternate_greetings ?? [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=character-card-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-card-query.js","sourceRoot":"","sources":["../../src/core/character-card-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAqD;IAC5F,MAAM,YAAY,GAAG,uBAAuB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,aAAa,CAAM,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAEzE,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI;gBAClC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,cAAc,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC,CAAC;gBACjE,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI;gBAC/C,qBAAqB,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;gBACtE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE;aACzC,CAAC;QACJ,KAAK,mBAAmB;YACtB,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI;gBAClC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,IAAI,EAAE;aAClD,CAAC;QACJ,KAAK,WAAW;YACd,OAAO;gBACL,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,IAAI,IAAI,CAAC,SAAS;gBACjD,mBAAmB,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,IAAI,EAAE;aAC1D,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CharacterCardConfig } from "../schemas/character-card.js";
|
|
2
|
+
import type { WorldbookDraftEntry } from "../schemas/worldbook-draft.js";
|
|
3
|
+
import { type ValidationIssue } from "./worldbook-validator.js";
|
|
4
|
+
export interface CharacterCardValidationResult {
|
|
5
|
+
valid: boolean;
|
|
6
|
+
errors: ValidationIssue[];
|
|
7
|
+
warnings: ValidationIssue[];
|
|
8
|
+
summary: {
|
|
9
|
+
worldbook_entry_count: number;
|
|
10
|
+
greeting_count: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function validateCharacterCardConfig(input: {
|
|
14
|
+
config: CharacterCardConfig;
|
|
15
|
+
draft?: WorldbookDraftEntry[];
|
|
16
|
+
mvuEnabled?: boolean;
|
|
17
|
+
}): CharacterCardValidationResult;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { validateGreetings } from "./greeting-validator.js";
|
|
2
|
+
import { validateWorldbookDraft } from "./worldbook-validator.js";
|
|
3
|
+
export function validateCharacterCardConfig(input) {
|
|
4
|
+
const errors = [];
|
|
5
|
+
const warnings = [];
|
|
6
|
+
const { config, draft } = input;
|
|
7
|
+
if (!config.card.name.trim()) {
|
|
8
|
+
errors.push({ field: "card.name", severity: "error", message: "角色卡 name 必填" });
|
|
9
|
+
}
|
|
10
|
+
if (!config.card.first_mes.trim()) {
|
|
11
|
+
errors.push({ field: "card.first_mes", severity: "error", message: "角色卡 first_mes 必填" });
|
|
12
|
+
}
|
|
13
|
+
if (config.card.description.trim()) {
|
|
14
|
+
warnings.push({ field: "card.description", severity: "warning", message: "当前规范建议 description 为空,角色信息放入世界书条目" });
|
|
15
|
+
}
|
|
16
|
+
const greetingValidation = validateGreetings({ config, mvu_enabled: input.mvuEnabled });
|
|
17
|
+
errors.push(...greetingValidation.errors);
|
|
18
|
+
warnings.push(...greetingValidation.warnings);
|
|
19
|
+
if (config.worldbook.source === "project_draft") {
|
|
20
|
+
if (!draft) {
|
|
21
|
+
errors.push({ field: "worldbook.source", severity: "error", message: "worldbook.source=project_draft 时项目必须有 draft" });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const worldbookValidation = validateWorldbookDraft(draft);
|
|
25
|
+
errors.push(...worldbookValidation.errors.map((issue) => ({ ...issue, field: `worldbook.${issue.field ?? "unknown"}` })));
|
|
26
|
+
warnings.push(...worldbookValidation.warnings.map((issue) => ({ ...issue, field: `worldbook.${issue.field ?? "unknown"}` })));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
warnings.push({ field: "worldbook.source", severity: "warning", message: "未嵌入世界书,角色信息可能不足" });
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
valid: errors.length === 0,
|
|
34
|
+
errors,
|
|
35
|
+
warnings,
|
|
36
|
+
summary: {
|
|
37
|
+
worldbook_entry_count: config.worldbook.source === "project_draft" ? draft?.length ?? 0 : 0,
|
|
38
|
+
greeting_count: 1 + config.card.alternate_greetings.length,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=character-card-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-card-validator.js","sourceRoot":"","sources":["../../src/core/character-card-validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAwB,MAAM,0BAA0B,CAAC;AAYxF,MAAM,UAAU,2BAA2B,CAAC,KAI3C;IACC,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEhC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC3F,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;QACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,mCAAmC,EAAE,CAAC,CAAC;IAClH,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AAC;QAC1B,MAAM;QACN,QAAQ;QACR,OAAO,EAAE;YACP,qBAAqB,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3F,cAAc,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM;SAC3D;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ValidationIssue } from "./worldbook-validator.js";
|
|
2
|
+
export declare function createCharacterBasicEntryTemplate(input?: {
|
|
3
|
+
character_name?: string;
|
|
4
|
+
}): {
|
|
5
|
+
template: string;
|
|
6
|
+
rules: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function createCharacterPersonalityEntryTemplate(input?: {
|
|
9
|
+
character_name?: string;
|
|
10
|
+
}): {
|
|
11
|
+
template: string;
|
|
12
|
+
rules: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare function validateCharacterEntryStructure(input: {
|
|
15
|
+
content: string;
|
|
16
|
+
kind: "basic" | "personality";
|
|
17
|
+
}): {
|
|
18
|
+
valid: boolean;
|
|
19
|
+
errors: ValidationIssue[];
|
|
20
|
+
warnings: ValidationIssue[];
|
|
21
|
+
};
|
|
22
|
+
export declare function validateCharacterAppearanceDistinctiveness(content: string): {
|
|
23
|
+
valid: boolean;
|
|
24
|
+
errors: ValidationIssue[];
|
|
25
|
+
warnings: ValidationIssue[];
|
|
26
|
+
summary: {
|
|
27
|
+
issue_count: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const UNIVERSAL_BEAUTY_TERMS = ["精致", "白皙", "好看", "美丽", "漂亮", "优雅", "温婉", "亭亭玉立"];
|
|
2
|
+
const DEFAULT_APPEARANCE_PATTERNS = [/中国人.*黑发黑眼/, /日本人.*黑发/, /18岁.*年轻/, /精灵.*尖耳/];
|
|
3
|
+
export function createCharacterBasicEntryTemplate(input = {}) {
|
|
4
|
+
const name = input.character_name ?? "角色名";
|
|
5
|
+
return {
|
|
6
|
+
template: `<character>\nname: ${name}\nname_en: \nage: \ngender: \nnicknames: []\nappearance:\n height: \n hair: \n eyes: \n skin: \n build: \n clothing:\n daily: \n distinguishing: \nbackground: |\n \nabilities:\n - name: \n acquisition: \n effects:\n - \nrelationships:\n - name: "{{user}}"\n detail: \n</character>`,
|
|
7
|
+
rules: ["不要写 personality 字段", "外貌只写差异特征", "背景只写改变角色的关键事件", "关系写具体互动方式,不写抽象形容"],
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function createCharacterPersonalityEntryTemplate(input = {}) {
|
|
11
|
+
const name = input.character_name ?? "角色名";
|
|
12
|
+
return {
|
|
13
|
+
template: `<personality>\nname: ${name}\ncore_drive: \ntraits:\n - 特征——行为依据\nlikes: \ndislikes: \nhabits: \nhidden_self:\n - \n</personality>`,
|
|
14
|
+
rules: ["性格必须独立成条", "traits 每条都要有行为依据", "不要只写温柔/善良/冷酷等标签"],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function validateCharacterEntryStructure(input) {
|
|
18
|
+
const errors = [];
|
|
19
|
+
const warnings = [];
|
|
20
|
+
const content = input.content;
|
|
21
|
+
if (input.kind === "basic") {
|
|
22
|
+
if (!/^\s*<character>[\s\S]*<\/character>\s*$/.test(content))
|
|
23
|
+
errors.push({ field: "content", severity: "error", message: "基础人设条目必须使用 <character> 包裹" });
|
|
24
|
+
if (/personality|性格特征|core_drive|核心驱动力/i.test(content))
|
|
25
|
+
errors.push({ field: "content", severity: "error", message: "基础人设条目不应混入性格内容,应拆到独立 personality 条目" });
|
|
26
|
+
if (!/relationships:|关系/.test(content))
|
|
27
|
+
warnings.push({ field: "relationships", severity: "warning", message: "建议包含关系设定,并用具体画面描述" });
|
|
28
|
+
warnings.push(...appearanceWarnings(content));
|
|
29
|
+
if (/感情深厚|好朋友|关系很好|羁绊很深/.test(content))
|
|
30
|
+
warnings.push({ field: "relationships", severity: "warning", message: "关系描写疑似抽象形容,建议改为具体事件和互动方式" });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (!/^\s*<personality>[\s\S]*<\/personality>\s*$/.test(content))
|
|
34
|
+
errors.push({ field: "content", severity: "error", message: "性格条目必须使用 <personality> 包裹" });
|
|
35
|
+
if (!/core_drive|核心驱动力/.test(content))
|
|
36
|
+
warnings.push({ field: "core_drive", severity: "warning", message: "性格条目建议包含核心驱动力" });
|
|
37
|
+
if (/温柔\s*$|善良\s*$|冷酷\s*$|强大\s*$/m.test(content))
|
|
38
|
+
warnings.push({ field: "traits", severity: "warning", message: "性格特征需要行为依据,不应只有标签" });
|
|
39
|
+
}
|
|
40
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
41
|
+
}
|
|
42
|
+
export function validateCharacterAppearanceDistinctiveness(content) {
|
|
43
|
+
const warnings = appearanceWarnings(content);
|
|
44
|
+
return { valid: true, errors: [], warnings, summary: { issue_count: warnings.length } };
|
|
45
|
+
}
|
|
46
|
+
function appearanceWarnings(content) {
|
|
47
|
+
const warnings = [];
|
|
48
|
+
for (const term of UNIVERSAL_BEAUTY_TERMS) {
|
|
49
|
+
if (content.includes(term))
|
|
50
|
+
warnings.push({ field: "appearance", severity: "warning", message: `外貌含万能修饰词:${term}`, suggestion: "改为可识别的差异特征" });
|
|
51
|
+
}
|
|
52
|
+
for (const pattern of DEFAULT_APPEARANCE_PATTERNS) {
|
|
53
|
+
if (pattern.test(content))
|
|
54
|
+
warnings.push({ field: "appearance", severity: "warning", message: "外貌疑似写入 AI 默认认知特征", suggestion: "默认特征不写,只写差异点" });
|
|
55
|
+
}
|
|
56
|
+
if (/如|像|仿佛|宛如/.test(content) && /眼|眸|肤|发|声音|声线/.test(content))
|
|
57
|
+
warnings.push({ field: "appearance", severity: "warning", message: "外貌疑似使用意象比喻,建议改为白描特征" });
|
|
58
|
+
return warnings;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=character-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-templates.js","sourceRoot":"","sources":["../../src/core/character-templates.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAClF,MAAM,2BAA2B,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAElF,MAAM,UAAU,iCAAiC,CAAC,QAAqC,EAAE;IACvF,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC;IAC3C,OAAO;QACL,QAAQ,EAAE,sBAAsB,IAAI,qTAAqT;QACzV,KAAK,EAAE,CAAC,oBAAoB,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,CAAC;KAC/E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uCAAuC,CAAC,QAAqC,EAAE;IAC7F,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC;IAC3C,OAAO;QACL,QAAQ,EAAE,wBAAwB,IAAI,0GAA0G;QAChJ,KAAK,EAAE,CAAC,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;KAC3D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAyD;IACvG,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAE9B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,yCAAyC,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SuggestedDecision } from "../schemas/decision.js";
|
|
2
|
+
import { type TaskClassificationInput, type TaskClassificationResult, type WorldbookTaskClass } from "./task-classifier.js";
|
|
3
|
+
export interface ClarificationStageInput {
|
|
4
|
+
request?: string;
|
|
5
|
+
task_type?: WorldbookTaskClass;
|
|
6
|
+
wants_character_card?: boolean;
|
|
7
|
+
wants_mvu?: boolean;
|
|
8
|
+
wants_html?: boolean;
|
|
9
|
+
wants_ejs?: boolean;
|
|
10
|
+
stage?: "intake" | "post_classification";
|
|
11
|
+
}
|
|
12
|
+
export interface ClarificationResult {
|
|
13
|
+
task_type: WorldbookTaskClass;
|
|
14
|
+
needs_clarification: boolean;
|
|
15
|
+
suggested_decisions: SuggestedDecision[];
|
|
16
|
+
notes: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface ClassifyWithClarificationResult extends TaskClassificationResult, ClarificationResult {
|
|
19
|
+
recommended_next_tool?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function detectClarificationNeeds(input: ClarificationStageInput): ClarificationResult;
|
|
22
|
+
export declare function classifyWorldbookTaskWithClarification(input: TaskClassificationInput): ClassifyWithClarificationResult;
|
|
23
|
+
export declare function buildCardTypeDecision(): SuggestedDecision;
|
|
24
|
+
export declare function buildWorldbuildingTypeDecision(): SuggestedDecision;
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { classifyWorldbookTask } from "./task-classifier.js";
|
|
2
|
+
const ORIGIN_TYPE_DECISION = (sourceTool) => ({
|
|
3
|
+
id: "origin_type",
|
|
4
|
+
question: "请确认这次任务是原创还是二创?",
|
|
5
|
+
options: [
|
|
6
|
+
{ value: "original", label: "原创", description: "无原作素材,由用户提供创意" },
|
|
7
|
+
{ value: "derivative", label: "二创", description: "基于已有小说/游戏/网页等素材进行改编或提取" },
|
|
8
|
+
{ value: "mixed", label: "混合", description: "原创为主,借鉴部分已有素材" },
|
|
9
|
+
],
|
|
10
|
+
allow_custom: false,
|
|
11
|
+
multiple: false,
|
|
12
|
+
source_tool: sourceTool,
|
|
13
|
+
});
|
|
14
|
+
const TOGGLE_OPTIONS = [
|
|
15
|
+
{ value: "yes", label: "是" },
|
|
16
|
+
{ value: "no", label: "否" },
|
|
17
|
+
];
|
|
18
|
+
export function detectClarificationNeeds(input) {
|
|
19
|
+
const classification = classifyWorldbookTask({ request: input.request ?? "", wants_character_card: input.wants_character_card, wants_mvu: input.wants_mvu, wants_html: input.wants_html, wants_ejs: input.wants_ejs });
|
|
20
|
+
const taskType = input.task_type ?? classification.task_type;
|
|
21
|
+
const request = (input.request ?? "").toLowerCase();
|
|
22
|
+
const decisions = [];
|
|
23
|
+
if (input.stage !== "post_classification" && needsOriginClarification(taskType, request)) {
|
|
24
|
+
decisions.push(ORIGIN_TYPE_DECISION(taskTypeToTool(taskType)));
|
|
25
|
+
}
|
|
26
|
+
for (const decision of decisionsFor(taskType, input, request)) {
|
|
27
|
+
decisions.push(decision);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
task_type: taskType,
|
|
31
|
+
needs_clarification: decisions.length > 0,
|
|
32
|
+
suggested_decisions: decisions,
|
|
33
|
+
notes: notesFor(taskType, input, request, decisions.length > 0),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function classifyWorldbookTaskWithClarification(input) {
|
|
37
|
+
const classification = classifyWorldbookTask(input);
|
|
38
|
+
const clarification = detectClarificationNeeds({ request: input.request, task_type: classification.task_type, wants_character_card: input.wants_character_card, wants_mvu: input.wants_mvu, wants_html: input.wants_html, wants_ejs: input.wants_ejs, stage: "intake" });
|
|
39
|
+
return {
|
|
40
|
+
...classification,
|
|
41
|
+
...clarification,
|
|
42
|
+
recommended_next_tool: clarification.needs_clarification ? "request_user_decision" : recommendedAfterClassify(classification.task_type),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function decisionsFor(taskType, input, request) {
|
|
46
|
+
switch (taskType) {
|
|
47
|
+
case "original_character_card":
|
|
48
|
+
return originalCharacterCardDecisions(input, request);
|
|
49
|
+
case "derivative_extraction":
|
|
50
|
+
return derivativeDecisions(input, request);
|
|
51
|
+
case "worldbuilding_only":
|
|
52
|
+
return worldbuildingOnlyDecisions(request);
|
|
53
|
+
case "item_ability_equipment":
|
|
54
|
+
return itemDecisions(request);
|
|
55
|
+
case "style_extraction":
|
|
56
|
+
return styleDecisions(request);
|
|
57
|
+
case "chapter_extraction":
|
|
58
|
+
return chapterDecisions(request);
|
|
59
|
+
case "modify_existing":
|
|
60
|
+
return modifyExistingDecisions(request);
|
|
61
|
+
case "query_existing":
|
|
62
|
+
return [];
|
|
63
|
+
case "mvu_zod":
|
|
64
|
+
return mvuDecisions(input);
|
|
65
|
+
case "ejs_dynamic":
|
|
66
|
+
return ejsDecisions(input);
|
|
67
|
+
case "html_beautify":
|
|
68
|
+
return htmlDecisions(input);
|
|
69
|
+
case "content_lint":
|
|
70
|
+
return contentLintDecisions();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function originalCharacterCardDecisions(input, request) {
|
|
74
|
+
const decisions = [];
|
|
75
|
+
decisions.push({
|
|
76
|
+
id: "card_type",
|
|
77
|
+
question: "请确认卡型(决定蓝绿灯策略)",
|
|
78
|
+
options: [
|
|
79
|
+
{ value: "single_character_card", label: "单角色卡", description: "1 个核心角色,所有拆分条目蓝灯", is_recommended: true },
|
|
80
|
+
{ value: "multi_character_card", label: "多角色卡", description: "2+ 核心角色,速览蓝灯/详情绿灯" },
|
|
81
|
+
{ value: "worldbook_only", label: "纯世界书", description: "无角色卡承载,由系统/EJS 驱动" },
|
|
82
|
+
],
|
|
83
|
+
allow_custom: false,
|
|
84
|
+
multiple: false,
|
|
85
|
+
source_tool: "classify_worldbook_card_type",
|
|
86
|
+
});
|
|
87
|
+
decisions.push({
|
|
88
|
+
id: "worldbuilding_type",
|
|
89
|
+
question: "请确认世界观类型 A/B/C",
|
|
90
|
+
options: [
|
|
91
|
+
{ value: "A_realistic_background", label: "A 真实背景", description: "现代/历史现实舞台,只补必要细节" },
|
|
92
|
+
{ value: "B_small_world", label: "B 小世界", description: "学校、宅邸、小镇等封闭舞台" },
|
|
93
|
+
{ value: "C_large_world", label: "C 大世界", description: "架空大陆、奇幻/科幻文明" },
|
|
94
|
+
],
|
|
95
|
+
allow_custom: false,
|
|
96
|
+
multiple: false,
|
|
97
|
+
source_tool: "classify_worldbuilding_type",
|
|
98
|
+
});
|
|
99
|
+
if (input.wants_mvu === undefined && !/\bmvu\b|状态变量|好感度|变量系统/.test(request)) {
|
|
100
|
+
decisions.push(toggleDecision("wants_mvu", "是否启用 MVU/ZOD 变量系统?", "create_mvu_schema_template"));
|
|
101
|
+
}
|
|
102
|
+
if (input.wants_ejs === undefined && !/\bejs\b|多阶段|动态条目|getwi/.test(request)) {
|
|
103
|
+
decisions.push(toggleDecision("wants_ejs", "是否启用 EJS 动态内容?(依赖 MVU)", "create_ejs_template"));
|
|
104
|
+
}
|
|
105
|
+
if (input.wants_html === undefined && !/html|状态栏|美化|前端/.test(request)) {
|
|
106
|
+
decisions.push(toggleDecision("wants_html", "是否启用 HTML 状态栏 / 前端美化?", "create_html_beautify_template"));
|
|
107
|
+
}
|
|
108
|
+
return decisions;
|
|
109
|
+
}
|
|
110
|
+
function derivativeDecisions(_input, request) {
|
|
111
|
+
const decisions = [];
|
|
112
|
+
if (!/小说|游戏|wiki|百科|网页|搜索|文本|资料/.test(request)) {
|
|
113
|
+
decisions.push({
|
|
114
|
+
id: "source_kind",
|
|
115
|
+
question: "请确认素材类型",
|
|
116
|
+
options: [
|
|
117
|
+
{ value: "novel", label: "小说" },
|
|
118
|
+
{ value: "game", label: "游戏" },
|
|
119
|
+
{ value: "wiki", label: "wiki/百科" },
|
|
120
|
+
{ value: "web_research", label: "网络搜索摘要" },
|
|
121
|
+
{ value: "mixed", label: "多源混合" },
|
|
122
|
+
],
|
|
123
|
+
allow_custom: false,
|
|
124
|
+
multiple: false,
|
|
125
|
+
source_tool: "create_derivative_extraction_template",
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
decisions.push({
|
|
129
|
+
id: "extraction_focus",
|
|
130
|
+
question: "请确认要提取哪些维度",
|
|
131
|
+
options: [
|
|
132
|
+
{ value: "characters", label: "角色", is_recommended: true },
|
|
133
|
+
{ value: "world", label: "世界观" },
|
|
134
|
+
{ value: "items", label: "物品/能力" },
|
|
135
|
+
{ value: "events", label: "事件" },
|
|
136
|
+
{ value: "style", label: "文风" },
|
|
137
|
+
{ value: "chapters", label: "章节" },
|
|
138
|
+
],
|
|
139
|
+
allow_custom: false,
|
|
140
|
+
multiple: true,
|
|
141
|
+
source_tool: "create_derivative_extraction_template",
|
|
142
|
+
});
|
|
143
|
+
return decisions;
|
|
144
|
+
}
|
|
145
|
+
function worldbuildingOnlyDecisions(request) {
|
|
146
|
+
const decisions = [
|
|
147
|
+
{
|
|
148
|
+
id: "worldbuilding_type",
|
|
149
|
+
question: "请确认世界观类型 A/B/C",
|
|
150
|
+
options: [
|
|
151
|
+
{ value: "A_realistic_background", label: "A 真实背景" },
|
|
152
|
+
{ value: "B_small_world", label: "B 小世界" },
|
|
153
|
+
{ value: "C_large_world", label: "C 大世界" },
|
|
154
|
+
],
|
|
155
|
+
allow_custom: false,
|
|
156
|
+
multiple: false,
|
|
157
|
+
source_tool: "classify_worldbuilding_type",
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
if (!/单角色|多角色|纯世界|系统驱动/.test(request)) {
|
|
161
|
+
decisions.push({
|
|
162
|
+
id: "card_type",
|
|
163
|
+
question: "世界观最终是否要承载角色卡?",
|
|
164
|
+
options: [
|
|
165
|
+
{ value: "worldbook_only", label: "纯世界书", is_recommended: true },
|
|
166
|
+
{ value: "single_character_card", label: "单角色卡" },
|
|
167
|
+
{ value: "multi_character_card", label: "多角色卡" },
|
|
168
|
+
],
|
|
169
|
+
allow_custom: false,
|
|
170
|
+
multiple: false,
|
|
171
|
+
source_tool: "classify_worldbook_card_type",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return decisions;
|
|
175
|
+
}
|
|
176
|
+
function itemDecisions(_request) {
|
|
177
|
+
return [{
|
|
178
|
+
id: "item_kind",
|
|
179
|
+
question: "请确认条目类别(可多选)",
|
|
180
|
+
options: [
|
|
181
|
+
{ value: "clothing", label: "服装" },
|
|
182
|
+
{ value: "special_item", label: "特殊道具" },
|
|
183
|
+
{ value: "weapon", label: "武器" },
|
|
184
|
+
{ value: "ability", label: "能力" },
|
|
185
|
+
{ value: "equipment", label: "装备" },
|
|
186
|
+
{ value: "generic", label: "通用物品" },
|
|
187
|
+
],
|
|
188
|
+
allow_custom: false,
|
|
189
|
+
multiple: true,
|
|
190
|
+
source_tool: "validate_item_entry",
|
|
191
|
+
}];
|
|
192
|
+
}
|
|
193
|
+
function styleDecisions(_request) {
|
|
194
|
+
return [
|
|
195
|
+
{
|
|
196
|
+
id: "style_source_kind",
|
|
197
|
+
question: "文风来自原作素材还是用户自创?",
|
|
198
|
+
options: [
|
|
199
|
+
{ value: "from_text", label: "原作文本提取" },
|
|
200
|
+
{ value: "from_web_research", label: "网页搜索摘要" },
|
|
201
|
+
{ value: "user_defined", label: "用户自创规则" },
|
|
202
|
+
],
|
|
203
|
+
allow_custom: false,
|
|
204
|
+
multiple: false,
|
|
205
|
+
source_tool: "create_style_extraction_template",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: "style_purpose",
|
|
209
|
+
question: "文风目的",
|
|
210
|
+
options: [
|
|
211
|
+
{ value: "imitate", label: "模仿原作" },
|
|
212
|
+
{ value: "new_rules", label: "自创规则" },
|
|
213
|
+
{ value: "mixed", label: "模仿 + 补强" },
|
|
214
|
+
],
|
|
215
|
+
allow_custom: false,
|
|
216
|
+
multiple: false,
|
|
217
|
+
source_tool: "create_style_extraction_template",
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
function chapterDecisions(_request) {
|
|
222
|
+
return [
|
|
223
|
+
{
|
|
224
|
+
id: "chapter_count_hint",
|
|
225
|
+
question: "请粗略估计章节数量",
|
|
226
|
+
options: [
|
|
227
|
+
{ value: "1-3", label: "1-3" },
|
|
228
|
+
{ value: "4-10", label: "4-10" },
|
|
229
|
+
{ value: "10-30", label: "10-30" },
|
|
230
|
+
{ value: "30+", label: "30 以上" },
|
|
231
|
+
],
|
|
232
|
+
allow_custom: true,
|
|
233
|
+
multiple: false,
|
|
234
|
+
source_tool: "create_chapter_extraction_template",
|
|
235
|
+
},
|
|
236
|
+
toggleDecision("need_line_index", "是否需要为每章标注原文行号?", "submit_derivative_extraction_outline"),
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
function modifyExistingDecisions(_request) {
|
|
240
|
+
return [
|
|
241
|
+
{
|
|
242
|
+
id: "modification_kind",
|
|
243
|
+
question: "请确认修改类型(可多选)",
|
|
244
|
+
options: [
|
|
245
|
+
{ value: "add_entry", label: "新增条目" },
|
|
246
|
+
{ value: "update_entry", label: "更新条目" },
|
|
247
|
+
{ value: "delete_entry", label: "删除条目" },
|
|
248
|
+
{ value: "reorder_entry", label: "调整顺序" },
|
|
249
|
+
{ value: "toggle_entry", label: "启用/禁用" },
|
|
250
|
+
],
|
|
251
|
+
allow_custom: false,
|
|
252
|
+
multiple: true,
|
|
253
|
+
source_tool: "create_worldbook_patch",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: "worldbook_path",
|
|
257
|
+
question: "请提供已有世界书 JSON 文件路径(output 下的相对或绝对路径)",
|
|
258
|
+
options: [],
|
|
259
|
+
allow_custom: true,
|
|
260
|
+
multiple: false,
|
|
261
|
+
source_tool: "import_worldbook_json",
|
|
262
|
+
},
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
function mvuDecisions(input) {
|
|
266
|
+
const decisions = [{
|
|
267
|
+
id: "mvu_character_names",
|
|
268
|
+
question: "请输入需要追踪变量的角色名(用英文逗号分隔)",
|
|
269
|
+
options: [],
|
|
270
|
+
allow_custom: true,
|
|
271
|
+
multiple: false,
|
|
272
|
+
source_tool: "create_mvu_schema_template",
|
|
273
|
+
}];
|
|
274
|
+
if (input.wants_html === undefined) {
|
|
275
|
+
decisions.push(toggleDecision("wants_statusbar", "是否同时配置 HTML 状态栏?", "create_html_beautify_template"));
|
|
276
|
+
}
|
|
277
|
+
return decisions;
|
|
278
|
+
}
|
|
279
|
+
function ejsDecisions(input) {
|
|
280
|
+
const decisions = [];
|
|
281
|
+
if (!input.wants_mvu) {
|
|
282
|
+
decisions.push(toggleDecision("mvu_already_enabled", "EJS 依赖 MVU,请确认 MVU 是否已经启用?", "validate_mvu_config"));
|
|
283
|
+
}
|
|
284
|
+
decisions.push({
|
|
285
|
+
id: "ejs_template_type",
|
|
286
|
+
question: "请确认 EJS 模板类型",
|
|
287
|
+
options: [
|
|
288
|
+
{ value: "phase_profile", label: "阶段人设", is_recommended: true },
|
|
289
|
+
{ value: "palette", label: "调色盘" },
|
|
290
|
+
{ value: "custom", label: "自定义" },
|
|
291
|
+
],
|
|
292
|
+
allow_custom: false,
|
|
293
|
+
multiple: false,
|
|
294
|
+
source_tool: "create_ejs_template",
|
|
295
|
+
});
|
|
296
|
+
return decisions;
|
|
297
|
+
}
|
|
298
|
+
function htmlDecisions(input) {
|
|
299
|
+
const decisions = [{
|
|
300
|
+
id: "html_target",
|
|
301
|
+
question: "请确认 HTML 美化目标",
|
|
302
|
+
options: [
|
|
303
|
+
{ value: "statusbar", label: "状态栏" },
|
|
304
|
+
{ value: "global", label: "全局美化" },
|
|
305
|
+
{ value: "both", label: "状态栏 + 全局" },
|
|
306
|
+
{ value: "start_picker", label: "开场选择器" },
|
|
307
|
+
],
|
|
308
|
+
allow_custom: false,
|
|
309
|
+
multiple: false,
|
|
310
|
+
source_tool: "create_html_beautify_template",
|
|
311
|
+
}];
|
|
312
|
+
if (input.wants_mvu === undefined) {
|
|
313
|
+
decisions.push(toggleDecision("wants_mvu_pairing", "是否需要与 MVU 状态变量联动?", "create_mvu_schema_template"));
|
|
314
|
+
}
|
|
315
|
+
return decisions;
|
|
316
|
+
}
|
|
317
|
+
function contentLintDecisions() {
|
|
318
|
+
return [{
|
|
319
|
+
id: "lint_scope",
|
|
320
|
+
question: "请确认禁词扫描范围",
|
|
321
|
+
options: [
|
|
322
|
+
{ value: "single_text", label: "单段文本" },
|
|
323
|
+
{ value: "project_all", label: "整个 project 产物", is_recommended: true },
|
|
324
|
+
{ value: "single_entry", label: "单条目" },
|
|
325
|
+
],
|
|
326
|
+
allow_custom: true,
|
|
327
|
+
multiple: false,
|
|
328
|
+
source_tool: "create_writing_optimization_report",
|
|
329
|
+
}];
|
|
330
|
+
}
|
|
331
|
+
function notesFor(taskType, input, _request, hasDecisions) {
|
|
332
|
+
const notes = [];
|
|
333
|
+
if (hasDecisions)
|
|
334
|
+
notes.push("用户描述存在歧义,建议依次调用 request_user_decision 后再继续工作流");
|
|
335
|
+
if (taskType === "ejs_dynamic" && !input.wants_mvu)
|
|
336
|
+
notes.push("EJS 必须先启用 MVU");
|
|
337
|
+
if (taskType === "html_beautify")
|
|
338
|
+
notes.push("HTML 美化资产最终需要通过角色卡或独立 regex 脚本承载");
|
|
339
|
+
return notes;
|
|
340
|
+
}
|
|
341
|
+
function recommendedAfterClassify(taskType) {
|
|
342
|
+
switch (taskType) {
|
|
343
|
+
case "derivative_extraction":
|
|
344
|
+
return "create_derivative_extraction_template";
|
|
345
|
+
case "worldbuilding_only":
|
|
346
|
+
case "original_character_card":
|
|
347
|
+
return "create_worldbuilding_outline";
|
|
348
|
+
case "item_ability_equipment":
|
|
349
|
+
return "validate_item_entry";
|
|
350
|
+
case "style_extraction":
|
|
351
|
+
return "create_style_extraction_template";
|
|
352
|
+
case "chapter_extraction":
|
|
353
|
+
return "create_chapter_extraction_template";
|
|
354
|
+
case "modify_existing":
|
|
355
|
+
return "import_worldbook_json";
|
|
356
|
+
case "query_existing":
|
|
357
|
+
return "query_worldbook";
|
|
358
|
+
case "mvu_zod":
|
|
359
|
+
return "create_mvu_schema_template";
|
|
360
|
+
case "ejs_dynamic":
|
|
361
|
+
return "create_ejs_template";
|
|
362
|
+
case "html_beautify":
|
|
363
|
+
return "create_html_beautify_template";
|
|
364
|
+
case "content_lint":
|
|
365
|
+
return "create_writing_optimization_report";
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function needsOriginClarification(taskType, request) {
|
|
369
|
+
if (["mvu_zod", "ejs_dynamic", "html_beautify", "content_lint", "modify_existing", "query_existing"].includes(taskType))
|
|
370
|
+
return false;
|
|
371
|
+
if (/原创|原创设定|自创|完全原创/.test(request))
|
|
372
|
+
return false;
|
|
373
|
+
if (/二创|同人|原作|提取|根据.*(?:小说|文本|游戏|网页|资料)/.test(request))
|
|
374
|
+
return false;
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
function taskTypeToTool(taskType) {
|
|
378
|
+
switch (taskType) {
|
|
379
|
+
case "original_character_card":
|
|
380
|
+
return "classify_worldbook_card_type";
|
|
381
|
+
case "derivative_extraction":
|
|
382
|
+
return "create_derivative_extraction_template";
|
|
383
|
+
case "worldbuilding_only":
|
|
384
|
+
return "classify_worldbuilding_type";
|
|
385
|
+
case "style_extraction":
|
|
386
|
+
return "create_style_extraction_template";
|
|
387
|
+
case "chapter_extraction":
|
|
388
|
+
return "create_chapter_extraction_template";
|
|
389
|
+
case "item_ability_equipment":
|
|
390
|
+
return "validate_item_entry";
|
|
391
|
+
default:
|
|
392
|
+
return "classify_worldbook_task";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function toggleDecision(id, question, sourceTool) {
|
|
396
|
+
return {
|
|
397
|
+
id,
|
|
398
|
+
question,
|
|
399
|
+
options: TOGGLE_OPTIONS,
|
|
400
|
+
allow_custom: false,
|
|
401
|
+
multiple: false,
|
|
402
|
+
source_tool: sourceTool,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
export function buildCardTypeDecision() {
|
|
406
|
+
return {
|
|
407
|
+
id: "card_type",
|
|
408
|
+
question: "请确认卡型(决定蓝绿灯策略)",
|
|
409
|
+
options: [
|
|
410
|
+
{ value: "single_character_card", label: "单角色卡", description: "1 个核心角色,所有拆分条目蓝灯", is_recommended: true },
|
|
411
|
+
{ value: "multi_character_card", label: "多角色卡", description: "2+ 核心角色,速览蓝灯/详情绿灯" },
|
|
412
|
+
{ value: "worldbook_only", label: "纯世界书", description: "无角色卡承载,由系统/EJS 驱动" },
|
|
413
|
+
],
|
|
414
|
+
allow_custom: false,
|
|
415
|
+
multiple: false,
|
|
416
|
+
source_tool: "classify_worldbook_card_type",
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
export function buildWorldbuildingTypeDecision() {
|
|
420
|
+
return {
|
|
421
|
+
id: "worldbuilding_type",
|
|
422
|
+
question: "请确认世界观类型 A/B/C",
|
|
423
|
+
options: [
|
|
424
|
+
{ value: "A_realistic_background", label: "A 真实背景", description: "现代/历史现实舞台,只补必要细节" },
|
|
425
|
+
{ value: "B_small_world", label: "B 小世界", description: "学校、宅邸、小镇等封闭舞台" },
|
|
426
|
+
{ value: "C_large_world", label: "C 大世界", description: "架空大陆、奇幻/科幻文明" },
|
|
427
|
+
],
|
|
428
|
+
allow_custom: false,
|
|
429
|
+
multiple: false,
|
|
430
|
+
source_tool: "classify_worldbuilding_type",
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
//# sourceMappingURL=clarification.js.map
|