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 { emptyDecisions, setNote, setVerdict } from "@/lib/review/decisions";
|
||||
import type { JobView } from "@/lib/jobs/job";
|
||||
import {
|
||||
buildResumeRequest,
|
||||
CHAIN_KINDS,
|
||||
chainPhase,
|
||||
chainResultView,
|
||||
} from "./chain";
|
||||
@@ -110,3 +111,19 @@ describe("buildResumeRequest", () => {
|
||||
expect(buildResumeRequest([])).toEqual({ decisions: [] });
|
||||
});
|
||||
});
|
||||
|
||||
describe("CHAIN_KINDS", () => {
|
||||
it("exposes both built-in chain kinds aligned with backend SUPPORTED_CHAINS", () => {
|
||||
expect(CHAIN_KINDS.map((k) => k.key)).toEqual([
|
||||
"draft_volume",
|
||||
"continue_volume",
|
||||
]);
|
||||
});
|
||||
|
||||
it("gives each kind a non-empty label and description", () => {
|
||||
for (const kind of CHAIN_KINDS) {
|
||||
expect(kind.label.length).toBeGreaterThan(0);
|
||||
expect(kind.description.length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,29 @@ import type { ChainResumeRequest } from "@/lib/api/types";
|
||||
import type { JobView, PollStatus } from "@/lib/jobs/job";
|
||||
import { buildAcceptRequest, type DecisionDraft } from "@/lib/review/decisions";
|
||||
|
||||
// 内置链类型(对齐后端 SUPPORTED_CHAINS):draft_volume=从 start 章按记忆量产;
|
||||
// continue_volume=续写式(每章以上一章 accepted 正文末尾作前文引子,比纯 digest 更顺)。
|
||||
export type ChainKind = "draft_volume" | "continue_volume";
|
||||
|
||||
export interface ChainKindOption {
|
||||
key: ChainKind;
|
||||
label: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const CHAIN_KINDS: readonly ChainKindOption[] = [
|
||||
{
|
||||
key: "draft_volume",
|
||||
label: "从头写",
|
||||
description: "按记忆与大纲量产,每章独立写。",
|
||||
},
|
||||
{
|
||||
key: "continue_volume",
|
||||
label: "续写",
|
||||
description: "每章以上一章已验收正文末尾作前文引子,承接更顺。",
|
||||
},
|
||||
];
|
||||
|
||||
// 链 job result 的视图模型(与后端 `_chain_result` 字段对齐:chain_key/written/completed/
|
||||
// awaiting_chapter)。token/正文绝不入 result(不变量 #5 / chain §5),故此处只有进度元数据。
|
||||
export interface ChainResultView {
|
||||
|
||||
Reference in New Issue
Block a user