games-development-ai/contracts/agent-loop/source-project.schema.json
lili 5661e2015f feat(contracts): source-project schema 挖 gamedef V1 子树(保留文件·收敛单 V2)
contracts/agent-loop/source-project.schema.json(A-model keystone 契约,
不可整删):
- 删 $defs/sourceProjectV1(schemaVersion "1.0"、含 gameDefinition 声明式表示)
- 删仅 V1 用的 $defs:entity / component / behavior / scene / rule
- oneOf 由 [V1,V2] 收敛为单 [V2];顶层 + profile/assetSpec description
  去 "1.0 gamedef legacy" / "1.0/2.0 共用" 措辞
- 保留:整个 sourceProjectV2(A-model 多文件代码工件)+ 共用 profile/assetSpec

contracts/api-schemas/studio.yaml:StudioModifyTarget 的 path 字段示例
里 /gameDefinition/scenes/2 → /files/src/game.js(端点/字段结构保留,仅
更新失效示例措辞)。

验证:
- source-project.schema.json 仍合法 JSON(python3 -m json.tool 过),无悬空
  $ref(删的 5 个 def 无别处引用)、无 V1/gameDefinition 残留
- studio.yaml 仍合法 YAML
- 经查无任何测试/运行期校验器加载本 JSON schema 做校验(存储层把
  source_json 当不透明 blob),删 V1 纯文档级、不影响运行期/测试

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 02:27:28 -07:00

62 lines
4.3 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://wanxiang.ai/contracts/agent-loop/source-project.schema.json",
"title": "SourceProject",
"description": "游戏源源项目工件:agents 在固定架构上填的唯一结构化产物;改源不改打包产物(GamePackage 产物 schema 不变)。【schemaVersion 2.0=A-model 多文件代码工件(固定 plumbing + LLM 写的表达性多文件 src/)】。注:1.0 gamedef 声明式表示已随 gamedef 错误路线于 2026-06-21 删除,本 schema 现仅 A-model(2.0)。本 schema 限 Tier0/1 线;tier2 真 Phaser 引擎工程的源项目契约另立一份独立 schema(tier2-source-project.schema.json)、不复用本路。两开发线交汇的 keystone 契约(后端线产出/落库,引擎线消费)。",
"type": "object",
"required": ["schemaVersion"],
"oneOf": [
{ "$ref": "#/$defs/sourceProjectV2" }
],
"$defs": {
"sourceProjectV2": {
"type": "object",
"description": "2.0 A-model:多文件代码工件。固定零表达性 plumbing(entry/main/index) + LLM 写的表达性多文件 src/(core/render/game/host-config/balance/assets)。逃离 gamedef 的 JSON 框死——一切玩法/渲染/数值/wiring 都是真 JS。",
"required": ["schemaVersion", "sourceHash", "profile", "files", "entry", "globalName"],
"additionalProperties": false,
"properties": {
"schemaVersion": { "const": "2.0", "description": "A-model 源工件契约版本" },
"sourceHash": { "type": "string", "pattern": "^[a-f0-9]{64}$", "description": "源(规范化 files)sha256(可寻址/幂等键)" },
"buildInputHash": { "type": "string", "pattern": "^[a-f0-9]{64}$", "description": "sha256(sourceHash + buildProfile);确定性构建缓存命中键" },
"profile": { "$ref": "#/$defs/profile" },
"files": {
"type": "object",
"description": "多文件源:相对路径(相对 game 根)→ 文件文本内容。含 LLM 写的表达性代码(src/{core,render,game,host-config,balance,assets}.js)+ 固定 plumbing(entry.js/src/main.js/index.html)。",
"minProperties": 1,
"propertyNames": { "pattern": "^[A-Za-z0-9_./-]+$" },
"additionalProperties": { "type": "string" }
},
"entry": { "type": "string", "minLength": 1, "description": "esbuild 入口文件相对路径(如 entry.js)" },
"globalName": { "const": "__GameBundle", "description": "iife 全局名:对齐 SAA 九门契约(index 调 __GameBundle.bootGameHost)" },
"plugins": { "type": "array", "items": { "type": "string" }, "description": "本款用到的插件键名(host-config 注入;诊断/审计用)" },
"assets": { "type": "array", "items": { "$ref": "#/$defs/assetSpec" }, "description": "六类资产规格/引用(design assetSpec → asset 节点;A-model 同用此枚举)" },
"config": { "type": "object", "description": "平衡参数(数值/难度/速度)——确定性 modify 改这里免 LLM" }
}
},
"profile": {
"type": "object",
"description": "维度无关三维(否则剧情/TRPG 类绷断,见 execution §10.2/§5.9)",
"required": ["tickModel", "inputModel", "progressModel"],
"additionalProperties": false,
"properties": {
"tickModel": { "enum": ["realtime", "turn-based", "event"], "description": "时间模型:决定适配器是否挂 update 循环" },
"inputModel": { "enum": ["continuous", "discrete-choice", "text-command"] },
"progressModel": { "enum": ["metric", "narrative"], "description": "narrative → 走 narrative-designer-reviewer 质量门(替九门)" }
}
},
"assetSpec": {
"type": "object",
"description": "六类资产规格/引用(对齐 v2 review C5;四处同引同一枚举)",
"required": ["id", "category", "ref"],
"additionalProperties": false,
"properties": {
"id": { "type": "string" },
"category": { "enum": ["sprite", "character", "effect", "scene", "ui", "music"], "description": "六类:图元/角色/特效/场景/界面/音乐" },
"ref": { "type": "string", "description": "平台 assetId/ref 为主" },
"url": { "type": "string", "format": "uri", "description": "只读镜像 URL" },
"provider": { "type": "string", "default": "mmx-cli", "description": "provider 可插拔" }
}
}
}
}