This commit is contained in:
2026-04-26 16:50:53 +08:00
parent ea33413187
commit 705a2d3dd8
30 changed files with 1537 additions and 570 deletions

View File

@@ -0,0 +1,37 @@
# RPG 世界草稿属性六维生成 2026-04-26
## 背景
RPG Agent 生成世界草稿时,前端会把 `draftProfile` 归一化成 `CustomWorldProfile`。运行时已经支持 `attributeSchema`,但 foundation draft 当前没有稳定产出该字段,前端只能根据主题模式回退出固定模板,导致世界页面看到的六个维度更像预设,而不是本次世界草稿的一部分。
## 落地约束
- `draftProfile.attributeSchema` 是世界草稿真相源的一部分,必须随 foundation draft 一起生成并保存。
- 六维固定使用 `axis_a``axis_f` 六个槽位,但 `schemaName`、每个槽位 `name` 和说明必须贴合本次世界设定。
- 维度名不得沿用通用旧词:生命、法力、护甲、攻击、防御、力量、敏捷、智力、精神。
- 若模型遗漏或结构不合规,后端必须生成中文兜底属性体系,不能让前端只靠固定模板补齐。
- 世界页面的“世界”页签必须展示当前 `attributeSchema.slots` 的六个名称,作为玩家进入世界前可见的规则信号。
## 编码方案
1. `packages/shared/src/contracts/rpgAgentDraft.ts`
- 增加 `RpgAgentWorldAttributeSchema``RpgAgentWorldAttributeSlot` 合同。
- `RpgAgentFoundationDraftProfile` 增加 `attributeSchema` 字段。
2. `server-rs/crates/api-server/src/prompt/foundation_draft.rs`
- framework 阶段要求模型输出 `attributeSchema`
- 修复提示也必须保留 `attributeSchema`,避免 JSON repair 丢字段。
3. `server-rs/crates/api-server/src/custom_world_foundation_draft.rs`
- `normalize_framework_shape()` 归一化 `attributeSchema`
- `build_foundation_draft_profile_from_framework()` 将归一化后的 `attributeSchema` 写入 `draftProfile`
- 新增兜底生成器,基于世界名、基调、目标、冲突和种子文本生成六个中文维度。
4. `src/components/CustomWorldEntityCatalog.tsx`
- 在世界页签增加“角色维度”区域,直接渲染 `profile.attributeSchema.slots` 的六个名称。
## 验收
- 新生成的 RPG 世界草稿 JSON 顶层包含 `attributeSchema.slots.length === 6`
- 结果页/世界页展示六个自定义维度名,而非固定的力量、敏捷、智力、精神。
- 缺失或非法模型输出会被后端兜底为合法中文六维。