feat(frontend): AI写作三槽——文风 / 剧情需求 / 自定义要求,写章前按需组合

Phase 2(写作工作台重构):把写章指令升级为三槽——文风预设 + 新增剧情需求预设
(打脸反转/章末钩子/高潮/转折/扮猪吃虎,源自 plan §4.2 分类法,tianyayu6/oh-story MIT)
+ 自定义自由文本。三者经 composeDirective 合并为单条 directive→volatile(MVP 纯前端、
零契约、不动 write_craft.md 字节,金标准零回归)。DirectivePanel 拆成文风/剧情两组 chips。
This commit is contained in:
Yaojia Wang
2026-07-07 19:51:19 +02:00
parent 04f4785292
commit 44b0b8a7f0
3 changed files with 91 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { composeDirective, STYLE_PRESETS } from "./directive";
import { composeDirective, PLOT_PRESETS, STYLE_PRESETS } from "./directive";
describe("composeDirective", () => {
it("returns empty string when nothing selected", () => {
@@ -23,4 +23,16 @@ describe("composeDirective", () => {
const lessAi = STYLE_PRESETS.find((p) => p.id === "less-ai")!.text;
expect(composeDirective("", ["nope", "less-ai"])).toBe(lessAi);
});
it("resolves 剧情需求 presets alongside 文风", () => {
const plot = PLOT_PRESETS[0]!;
expect(composeDirective("", [plot.id])).toBe(plot.text);
});
it("orders 文风 presets before 剧情 presets, then free text", () => {
const style = STYLE_PRESETS[0]!;
const plot = PLOT_PRESETS[0]!;
const result = composeDirective("再收紧节奏", [plot.id, style.id]);
expect(result).toBe(`${style.text}${plot.text};再收紧节奏`);
});
});