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:
Yaojia Wang
2026-06-23 20:29:48 +02:00
parent 5d8e619408
commit 1a402f5ccc
18 changed files with 869 additions and 19 deletions

View File

@@ -377,6 +377,50 @@ export interface paths {
patch?: never;
trace?: never;
};
"/templates": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/**
* List Templates
* @description 列出当前用户stub的模板。
*/
get: operations["list_templates_templates_get"];
put?: never;
/**
* Create Template
* @description 新建模板201。title/body 空 → FastAPI 422schema `min_length=1`)。
*/
post: operations["create_template_templates_post"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/templates/{template_id}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post?: never;
/**
* Delete Template
* @description 删除模板204。不存在 → 404 NOT_FOUND。
*/
delete: operations["delete_template_templates__template_id__delete"];
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/projects/{project_id}/world/generate": {
parameters: {
query?: never;
@@ -1719,6 +1763,78 @@ export interface components {
*/
job_id: string;
};
/**
* TeardownIngestView
* @description 拆书入库产物(贴 ww_agents.BookTeardownResult落 rules 表。F1。
*/
TeardownIngestView: {
/**
* Themes
* @description 核心主题/立意清单
*/
themes?: string[];
/**
* Archetypes
* @description 人物原型/角色模板清单
*/
archetypes?: string[];
/**
* Structure
* @description 叙事结构概述
* @default
*/
structure: string;
/**
* Hooks
* @description 抓人钩子/爽点套路清单
*/
hooks?: string[];
};
/**
* TemplateCreateRequest
* @description POST /templates新建一条提示词模板。
*/
TemplateCreateRequest: {
/**
* Title
* @description 模板标题
*/
title: string;
/**
* Body
* @description 模板正文(一键填入生成器的 brief/text
*/
body: string;
/**
* Category
* @description 可选分类
*/
category?: string | null;
/**
* Tool Key
* @description 可选关联生成器NULL=通用)
*/
tool_key?: string | null;
};
/**
* TemplateResponse
* @description 模板视图(列出/创建后回显snake_case
*/
TemplateResponse: {
/**
* Id
* Format: uuid
*/
id: string;
/** Title */
title: string;
/** Body */
body: string;
/** Category */
category?: string | null;
/** Tool Key */
tool_key?: string | null;
};
/**
* TestConnectionRequest
* @description POST /test最小探测请求。
@@ -1861,7 +1977,8 @@ export interface components {
*
* 仅声明了 `ingest` 的工具可用。按入库表取用对应字段:
* - world_entities金手指/词条)→ `world_entities`(贴 WorldEntityCardViewtype/name/rules
* - outline细纲→ `chapter_no` + `scenes`(贴 OutlineSceneIngestView
* - outline细纲→ `chapter_no` + `scenes`(贴 OutlineSceneIngestView
* - rules拆书→ `teardown`(贴 TeardownIngestViewthemes/archetypes/structure/hooks
* `acknowledge_conflicts`:作者已查看并接受 continuity 预检冲突时置 true 放行(仿 accept gate
*/
ToolIngestRequest: {
@@ -1880,6 +1997,8 @@ export interface components {
* @description outline 入库的场景行(细纲)
*/
scenes?: components["schemas"]["OutlineSceneIngestView"][];
/** @description rules 入库的拆书结论F1拍平为可读规则条目 */
teardown?: components["schemas"]["TeardownIngestView"] | null;
/**
* Acknowledge Conflicts
* @description 作者已知悉并接受 continuity 冲突 → 放行入库
@@ -2866,6 +2985,88 @@ export interface operations {
};
};
};
list_templates_templates_get: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Successful Response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["TemplateResponse"][];
};
};
};
};
create_template_templates_post: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["TemplateCreateRequest"];
};
};
responses: {
/** @description Successful Response */
201: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["TemplateResponse"];
};
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
delete_template_templates__template_id__delete: {
parameters: {
query?: never;
header?: never;
path: {
template_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Successful Response */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
generate_world_projects__project_id__world_generate_post: {
parameters: {
query?: never;