feat(web): AI 立项方案生成+预填(种子门控 + 按字段接受)

向导阶段(project 未建)一键推演结构化书级蓝图预填立项向导。

- 新 SPEC project_plan_spec(analyst 档,纯预览 reads/writes=())+ schema
  ProjectPlanResult(书名候选 + 时空背景/叙事结构/故事核心/结局设计/基调,
  全字段默认值守解析韧性)+ 注册 SCHEMA_CATALOG;计数三处 21→22 + regen golden。
- 端点 POST /skills/project-plan/generate(不带 project 前缀,绕开 toolbox 404):
  请求体序列化向导草稿为 project_context,复用 build_brief_context + run_generator;
  种子门控(缺 genre/logline→422);请求 schema 加 max_length 上界。
- run_generator/_build_request 的 project_id 放宽 uuid.UUID|None(向导无 project)。
- 前端 wizard.ts 加 mapPlanResultToWizardForm(错配字段折进 premise 不静默丢)+
  applyPlanPatch(仅回填空字段、保护已编辑)+ useProjectPlan hook + PlanAssistant。
This commit is contained in:
Yaojia Wang
2026-07-06 16:26:08 +02:00
parent 821ace5989
commit 02d19019f6
22 changed files with 1187 additions and 9 deletions

View File

@@ -560,6 +560,29 @@ export interface paths {
patch?: never;
trace?: never;
};
"/skills/project-plan/generate": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* Generate Project Plan
* @description 生成结构化立项方案预览向导阶段project 未建,不入库)。
*
* **不带 project 前缀**——绕开 toolbox 的 `project_repo.get→404`(立项前无 project
* **种子门控**:缺 genre 或 logline → 422空向导不出方案防 slop。无凭据 → 503。
*/
post: operations["generate_project_plan_skills_project_plan_generate_post"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/skills/toolbox": {
parameters: {
query?: never;
@@ -1533,6 +1556,114 @@ export interface components {
/** Projects */
projects?: components["schemas"]["ProjectResponse"][];
};
/**
* ProjectPlanGenerateRequest
* @description POST /skills/project-plan/generate向导草稿种子不带 project 前缀,立项前 project 未建)。
*
* **种子门控**`genre` + `logline` 为必给种子(端点校验非空,否则 422——空向导不出方案
* 防 slop。其余字段有则贴合、无则不臆造序列化进 project_context仿 `_project_context`)。
* 全字段带 `max_length` 上界CR-H9`brief` = 作者一句话方向(可空)。
*/
ProjectPlanGenerateRequest: {
/**
* Genre
* @description 题材(种子)
*/
genre?: string | null;
/**
* Logline
* @description 一句话故事(种子)
*/
logline?: string | null;
/**
* Title
* @description 暂定书名(可空)
*/
title?: string | null;
/**
* Premise
* @description 立意(可空)
*/
premise?: string | null;
/**
* Theme
* @description 主题(可空)
*/
theme?: string | null;
/**
* Structure
* @description 故事结构(可空)
*/
structure?: string | null;
/**
* Tone
* @description 基调(可空)
*/
tone?: string | null;
/**
* Ending Type
* @description 结局取向(可空)
*/
ending_type?: string | null;
/**
* Narrative Pov
* @description 叙事视角(可空)
*/
narrative_pov?: string | null;
/**
* Selling Points
* @description 核心卖点(可空)
*/
selling_points?: string[];
/**
* Brief
* @description 作者一句话方向/需求(可空)
*/
brief?: string | null;
};
/**
* ProjectPlanView
* @description 立项方案生成结果(贴 ww_agents.ProjectPlanResult结构化预览不入库
*
* 全字段有默认值(守解析韧性)——前端按字段回填立项向导,只填非空交集、不覆盖作者已编辑值。
*/
ProjectPlanView: {
/**
* Title Candidates
* @description 书名候选清单
*/
title_candidates?: string[];
/**
* Setting
* @description 时空背景
* @default
*/
setting: string;
/**
* Narrative Structure
* @description 叙事结构
* @default
*/
narrative_structure: string;
/**
* Story Core
* @description 故事核心
* @default
*/
story_core: string;
/**
* Ending Design
* @description 结局设计
* @default
*/
ending_design: string;
/**
* Tone
* @description 基调
* @default
*/
tone: string;
};
/**
* ProjectResponse
* @description 项目视图(创建/列表/详情共用)。
@@ -3360,6 +3491,39 @@ export interface operations {
};
};
};
generate_project_plan_skills_project_plan_generate_post: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["ProjectPlanGenerateRequest"];
};
};
responses: {
/** @description Successful Response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ProjectPlanView"];
};
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
list_toolbox_skills_toolbox_get: {
parameters: {
query?: never;

View File

@@ -4,6 +4,10 @@ import type { components } from "./schema";
export type ProjectResponse = components["schemas"]["ProjectResponse"];
export type ProjectCreateRequest = components["schemas"]["ProjectCreateRequest"];
export type ProjectListResponse = components["schemas"]["ProjectListResponse"];
// AI 立项方案生成(灵感⑤):向导阶段 project 未建,种子门控 + 结构化预览回填向导。
export type ProjectPlanGenerateRequest =
components["schemas"]["ProjectPlanGenerateRequest"];
export type ProjectPlanView = components["schemas"]["ProjectPlanView"];
export type DraftSaveRequest = components["schemas"]["DraftSaveRequest"];
export type DraftResponse = components["schemas"]["DraftResponse"];
// GET .../draft 读端点含正文供工作台重访时重载编辑器404→空编辑器