Files
Genarrative/docs/technical/RPG_WORLD_DRAFT_ATTRIBUTE_SCHEMA_GENERATION_2026-04-26.md
2026-04-28 20:25:37 +08:00

2.5 KiB

RPG 世界草稿属性六维生成 2026-04-26

背景

RPG Agent 生成世界草稿时,前端会把 draftProfile 归一化成 CustomWorldProfile。运行时已经支持 attributeSchema,但 foundation draft 当前没有稳定产出该字段,前端只能根据主题模式回退出固定模板,导致世界页面看到的六个维度更像预设,而不是本次世界草稿的一部分。

落地约束

  • draftProfile.attributeSchema 是世界草稿真相源的一部分,必须随 foundation draft 一起生成并保存。
  • 六维固定使用 axis_aaxis_f 六个系统槽位,但创作、提示词输出、解析后保存的数据只保留每个槽位的 nameslotId 由系统补齐用于数值映射,不要求模型理解或生成额外说明字段。
  • 维度名不得沿用通用旧词:生命、法力、护甲、攻击、防御、力量、敏捷、智力、精神。
  • 若模型遗漏或结构不合规,后端必须生成中文兜底属性体系,不能让前端只靠固定模板补齐。
  • 世界页面的“世界”页签必须展示当前 attributeSchema.slots 的六个名称,作为玩家进入世界前可见的规则信号。

编码方案

  1. packages/shared/src/contracts/rpgAgentDraft.ts

    • 增加 RpgAgentWorldAttributeSchemaRpgAgentWorldAttributeSlot 合同。
    • 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
  • 结果页/世界页展示六个自定义维度名,而非固定的力量、敏捷、智力、精神;页面不展示维度说明、正负信号或用途说明。
  • 缺失或非法模型输出会被后端兜底为合法中文六维。