feat(web): F1/F2/F3 前端——拆书入库为规则 / 续写式链选择 / 模板库
- gen:api 纳入 /templates、chain continue_volume、teardown rules ingest 端点 - F1:GeneratorRunner 识别拆书为单对象入库(整 preview 作一条 teardown), ingestTable(BookTeardownResult)=rules,buildIngestRequest 组装 teardown 体, 按 isSingleObjectIngest 隐藏勾选框、改文案「入库为规则」 - F2:ChainStarter 加链类型单选(draft_volume 从头写 / continue_volume 续写), chain_key 作 path 参传给 run(CHAIN_KINDS 对齐后端 SUPPORTED_CHAINS) - F3:模板库页 app/templates + 全局 nav 入口 + TemplatesManager(列/建/删,乐观更新回滚); GeneratorRunner 加 TemplateFiller「从模板填入」(body 填进 brief/text,纯前端) - vitest 覆盖 templates/ingest teardown/templateFillTarget/CHAIN_KINDS 纯逻辑
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import type {
|
||||
OutlineSceneIngestView,
|
||||
TeardownIngestView,
|
||||
ToolIngestRequest,
|
||||
WorldEntityCardView,
|
||||
} from "@/lib/api/types";
|
||||
@@ -63,6 +64,17 @@ function rowToScene(
|
||||
};
|
||||
}
|
||||
|
||||
// 拆书结构化产物 → TeardownIngestView(贴后端 schema;后端再拍平为可读 rules 条目)。
|
||||
// 单对象产物:整个 preview 对象即一条入库项(无逐行勾选)。
|
||||
function rowToTeardown(row: Record<string, unknown>): TeardownIngestView {
|
||||
return {
|
||||
themes: asStringArray(row["themes"]),
|
||||
archetypes: asStringArray(row["archetypes"]),
|
||||
structure: asString(row["structure"]),
|
||||
hooks: asStringArray(row["hooks"]),
|
||||
};
|
||||
}
|
||||
|
||||
export interface IngestBuildInput {
|
||||
outputKind: string;
|
||||
// 作者勾选要入库的预览行(结构化产物原始记录)。
|
||||
@@ -72,6 +84,15 @@ export interface IngestBuildInput {
|
||||
acknowledgeConflicts?: boolean;
|
||||
}
|
||||
|
||||
// 单对象入库的 output_kind:整个 preview 即一条入库项(无逐行勾选)。
|
||||
// 当前仅拆书(结构化结论拍平为 rules)。行式产物(金手指/词条/细纲)不在此列。
|
||||
const SINGLE_OBJECT_INGEST_KINDS = new Set(["BookTeardownResult"]);
|
||||
|
||||
// 该产物是否「单对象入库」(UI 据此隐藏勾选框、改文案、用整个 rawPreview 作唯一行)。
|
||||
export function isSingleObjectIngest(outputKind: string): boolean {
|
||||
return SINGLE_OBJECT_INGEST_KINDS.has(outputKind);
|
||||
}
|
||||
|
||||
// 入库目标表(供 UI 文案 / 判定)。未知 → null(不可入库)。
|
||||
export function ingestTable(outputKind: string): string | null {
|
||||
switch (outputKind) {
|
||||
@@ -80,6 +101,8 @@ export function ingestTable(outputKind: string): string | null {
|
||||
return "world_entities";
|
||||
case "DetailedOutlineResult":
|
||||
return "outline";
|
||||
case "BookTeardownResult":
|
||||
return "rules";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -107,6 +130,12 @@ export function buildIngestRequest(
|
||||
scenes: input.rows.map((row, i) => rowToScene(row, i)),
|
||||
acknowledge_conflicts,
|
||||
};
|
||||
case "BookTeardownResult": {
|
||||
// 单对象产物:取首行(整个拆书结论)作 teardown;无产物 → null。
|
||||
const row = input.rows[0];
|
||||
if (!row) return null;
|
||||
return { teardown: rowToTeardown(row), acknowledge_conflicts };
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user