@craft_eco/craft-mcp 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -55
- package/bin/craft-mcp.mjs +4 -1
- package/dist-server/game-workflow/check.mjs +3 -2
- package/dist-server/game-workflow/context-state.mjs +67 -67
- package/dist-server/game-workflow/draft-archive.mjs +147 -2
- package/dist-server/game-workflow/draft-upload-identity.mjs +11 -0
- package/dist-server/game-workflow/draft-uploads.mjs +105 -60
- package/dist-server/game-workflow/local-context.mjs +62 -62
- package/dist-server/game-workflow/native-context.mjs +289 -289
- package/dist-server/game-workflow/project-bundles.mjs +246 -246
- package/dist-server/game-workflow/project-context.mjs +8 -8
- package/dist-server/game-workflow/projects.mjs +6 -4
- package/dist-server/game-workflow/tasks.mjs +1 -1
- package/dist-server/game-workflow/work-scope.mjs +7 -7
- package/dist-server/integrations/config.mjs +145 -145
- package/dist-server/integrations/connect.mjs +36 -0
- package/dist-server/integrations/connection-handoff.mjs +36 -42
- package/dist-server/integrations/dsh-config.mjs +182 -182
- package/dist-server/integrations/files.mjs +54 -54
- package/dist-server/integrations/fixed-launcher.mjs +31 -0
- package/dist-server/integrations/host-reload.mjs +19 -0
- package/dist-server/integrations/hosts.mjs +55 -55
- package/dist-server/integrations/install.mjs +223 -205
- package/dist-server/integrations/installation-state.mjs +84 -84
- package/dist-server/integrations/launcher-start.mjs +52 -0
- package/dist-server/integrations/npm-diagnostics.mjs +32 -0
- package/dist-server/integrations/runtime-gc.mjs +191 -188
- package/dist-server/integrations/runtime-identity.mjs +22 -0
- package/dist-server/integrations/runtime.mjs +111 -126
- package/dist-server/integrations/updates.mjs +258 -225
- package/dist-server/integrations/version-policy.mjs +32 -32
- package/dist-server/launcher.mjs +1845 -0
- package/dist-server/mcp/control-panel.mjs +8 -23
- package/dist-server/mcp/server.mjs +31 -80
- package/dist-server/mcp/update-session.mjs +107 -92
- package/dist-server/upstream/craft-aigc.mjs +43 -16
- package/dist-server/upstream/draft-source.mjs +29 -0
- package/package.json +3 -2
- package/resources/context-filter-report.json +1 -1
- package/resources/craft-create/SKILL.md +19 -19
- package/resources/craft-update/SKILL.md +9 -11
- package/resources/targets/claude/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/claude/js/context-filter-report.json +1 -1
- package/resources/targets/claude/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/claude/js/js/bundle.json +7 -7
- package/resources/targets/claude/js/recovery.md +5 -1
- package/resources/targets/claude/js/target.json +1 -1
- package/resources/targets/claude/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/claude/js3d/context-filter-report.json +1 -1
- package/resources/targets/claude/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/claude/js3d/js3d/bundle.json +7 -7
- package/resources/targets/claude/js3d/recovery.md +5 -1
- package/resources/targets/claude/js3d/target.json +1 -1
- package/resources/targets/codebuddy/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/codebuddy/js/context-filter-report.json +1 -1
- package/resources/targets/codebuddy/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codebuddy/js/js/bundle.json +7 -7
- package/resources/targets/codebuddy/js/recovery.md +5 -1
- package/resources/targets/codebuddy/js/target.json +1 -1
- package/resources/targets/codebuddy/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/codebuddy/js3d/context-filter-report.json +1 -1
- package/resources/targets/codebuddy/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codebuddy/js3d/js3d/bundle.json +7 -7
- package/resources/targets/codebuddy/js3d/recovery.md +5 -1
- package/resources/targets/codebuddy/js3d/target.json +1 -1
- package/resources/targets/codex/js/bootstrap/SKILL.md +2 -4
- package/resources/targets/codex/js/context-filter-report.json +1 -1
- package/resources/targets/codex/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codex/js/js/bundle.json +7 -7
- package/resources/targets/codex/js/recovery.md +3 -3
- package/resources/targets/codex/js/target.json +1 -1
- package/resources/targets/codex/js3d/bootstrap/SKILL.md +2 -4
- package/resources/targets/codex/js3d/context-filter-report.json +1 -1
- package/resources/targets/codex/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codex/js3d/js3d/bundle.json +7 -7
- package/resources/targets/codex/js3d/recovery.md +3 -3
- package/resources/targets/codex/js3d/target.json +1 -1
- package/resources/targets/cursor/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/cursor/js/context-filter-report.json +1 -1
- package/resources/targets/cursor/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/cursor/js/js/bundle.json +7 -7
- package/resources/targets/cursor/js/recovery.md +5 -1
- package/resources/targets/cursor/js/target.json +1 -1
- package/resources/targets/cursor/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/cursor/js3d/context-filter-report.json +1 -1
- package/resources/targets/cursor/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/cursor/js3d/js3d/bundle.json +7 -7
- package/resources/targets/cursor/js3d/recovery.md +5 -1
- package/resources/targets/cursor/js3d/target.json +1 -1
- package/resources/targets/dsh/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/dsh/js/context-filter-report.json +1 -1
- package/resources/targets/dsh/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/dsh/js/js/bundle.json +7 -7
- package/resources/targets/dsh/js/recovery.md +5 -1
- package/resources/targets/dsh/js/target.json +1 -1
- package/resources/targets/dsh/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/dsh/js3d/context-filter-report.json +1 -1
- package/resources/targets/dsh/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/dsh/js3d/js3d/bundle.json +7 -7
- package/resources/targets/dsh/js3d/recovery.md +5 -1
- package/resources/targets/dsh/js3d/target.json +1 -1
- package/resources/targets/index.json +32 -32
- package/resources/targets/kimi/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/kimi/js/context-filter-report.json +1 -1
- package/resources/targets/kimi/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/kimi/js/js/bundle.json +7 -7
- package/resources/targets/kimi/js/recovery.md +5 -1
- package/resources/targets/kimi/js/target.json +1 -1
- package/resources/targets/kimi/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/kimi/js3d/context-filter-report.json +1 -1
- package/resources/targets/kimi/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/kimi/js3d/js3d/bundle.json +7 -7
- package/resources/targets/kimi/js3d/recovery.md +5 -1
- package/resources/targets/kimi/js3d/target.json +1 -1
- package/resources/targets/workbuddy/js/bootstrap/SKILL.md +22 -24
- package/resources/targets/workbuddy/js/context-filter-report.json +1 -1
- package/resources/targets/workbuddy/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/workbuddy/js/js/bundle.json +8 -8
- package/resources/targets/workbuddy/js/js/context/AGENTS.md +29 -29
- package/resources/targets/workbuddy/js/recovery.md +19 -19
- package/resources/targets/workbuddy/js/target.json +1 -1
- package/resources/targets/workbuddy/js3d/bootstrap/SKILL.md +22 -24
- package/resources/targets/workbuddy/js3d/context-filter-report.json +1 -1
- package/resources/targets/workbuddy/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/workbuddy/js3d/js3d/bundle.json +8 -8
- package/resources/targets/workbuddy/js3d/js3d/context/AGENTS.md +30 -30
- package/resources/targets/workbuddy/js3d/recovery.md +19 -19
- package/resources/targets/workbuddy/js3d/target.json +1 -1
- package/resources/targets/zcode/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/zcode/js/context-filter-report.json +1 -1
- package/resources/targets/zcode/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/zcode/js/js/bundle.json +7 -7
- package/resources/targets/zcode/js/recovery.md +5 -1
- package/resources/targets/zcode/js/target.json +1 -1
- package/resources/targets/zcode/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/zcode/js3d/context-filter-report.json +1 -1
- package/resources/targets/zcode/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/zcode/js3d/js3d/bundle.json +7 -7
- package/resources/targets/zcode/js3d/recovery.md +5 -1
- package/resources/targets/zcode/js3d/target.json +1 -1
- package/vendor/craft-runtime/SOURCE.json +4 -4
- package/vendor/craft-runtime/package.json +1 -1
- package/dist-server/game-workflow/publication-materials.mjs +0 -92
- package/dist-server/game-workflow/publications.mjs +0 -168
- package/dist-server/game-workflow/publish-capture-worker.mjs +0 -57
- package/dist-server/game-workflow/publish-capture.mjs +0 -75
- package/dist-server/mcp/publication-page.html +0 -86
- package/dist-server/mcp/publication-page.mjs +0 -375
- package/dist-server/mcp/publication-preview.mjs +0 -63
- package/dist-server/mcp/publication-tools.mjs +0 -22
- package/dist-server/mcp/publish-panel.mjs +0 -210
- package/dist-server/upstream/publication-transport.mjs +0 -101
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"config": "context-filters.json",
|
|
4
|
-
"config_sha256": "
|
|
4
|
+
"config_sha256": "8eeef2b88f93dbf9ce4f1c7229bd01fdd93d76c75dce43f03b2649d418084763",
|
|
5
5
|
"exclude": [
|
|
6
6
|
"contexts/*/js/skills/aigc-generate/**",
|
|
7
7
|
"contexts/*/js/skills/asset-search/**",
|
|
@@ -26,25 +26,17 @@ prepare 会维护项目根 `AGENTS.md` 的 Craft 段,并为已选择的宿主
|
|
|
26
26
|
项目事实放在 SPEC 设计文档与 `SPEC/PROGRESS.md`;prepare 只在进度文件缺失时建立初始记录,不替换已有内容。开始工作先读取这些记录并核对源码;完成开发、验收或遇到阻塞后更新玩法、操作、已完成/待办、关键文件、验收任务与下一步。新会话据此恢复,不依赖上一轮聊天或宿主个人记忆。只读请求不写进度。
|
|
27
27
|
|
|
28
28
|
1. **先读引擎说明,再制作游戏。** 新建时仅展示 2D / Phaser(js)和 3D / Three.js(js3d)。沿用用户明确选择;尚未明确时按玩法推荐并收集选择,用户授权代选时直接决定并说明。选定后调用 `craft_game_info(engine)`;继续游戏用 `craft_game_info(name)` 获取已保存的引擎,不重新选择。开始设计、编码或修改前完整读取 `context.engine.entrypoint`,其余参考文档按需加载。
|
|
29
|
-
2. 调用 `craft_game_prepare`:新建传 `mode:"create"`、engine 和新的 request_key;继续已有工程传 `mode:"resume"`,沿用 name 和引擎。重试复用同一 request_key,已结束或中断的制作使用新的 key。轮询成功后保存 work_id 和 context_revision
|
|
29
|
+
2. 调用 `craft_game_prepare`:新建传 `mode:"create"`、engine 和新的 request_key;继续已有工程传 `mode:"resume"`,沿用 name 和引擎。重试复用同一 request_key,已结束或中断的制作使用新的 key。轮询成功后保存 work_id 和 context_revision,再读取本地上下文并使用宿主文件工具编辑工程。素材、验收、预览、取消及上传工具均传入此 work_id。期间不重新同步上下文;同一 work_id 的 prepare 只验证并复用当前结果。遇到 CRAFT_PROJECT_IN_USE 时可只读查询,须等原任务释放后再制作,不绕过占用锁写文件。保留模板依赖、runtime、Vite、预览接线和配置结构。
|
|
30
30
|
3. 按需求实现场景、玩法和真实输入交互;需要领域操作时,按当前技能索引的 description 选择并读取适用技能。资源地址及可调参数放入项目配置,由实际消费者读取并按引擎规则加载。配置有值不代表资源已被使用,必要资源就绪后再进入玩法。
|
|
31
31
|
4. 调用 `craft_game_check` 执行引擎收尾、构建和浏览器采集。依次提供 `loop`、`settlement`、`restart` 三步,每步包含 action、expected 和真实玩法断言。
|
|
32
32
|
5. gate.passed 后调用 `craft_game_review`,逐一查看初始、主循环、结算、重开四张截图,检查素材、构图、比例、文字、遮挡、透明边缘和玩法反馈;有问题就修复并重验。浏览器或截图不可用时报告未验证。
|
|
33
|
-
6. 玩法和视觉均通过后,调用 `craft_game_deliver(task_id,visual_passed:true,visual_notes)`,填写实际观察。返回 awaiting_host_start 时,由 AI IDE 使用后台终端执行 `start.script` 并保持该任务运行;这是持续服务命令,不等待终端退出才查询状态。Craft 不启动预览。轮询 `craft_game_info(name).preview`,直到 running=true 且 snapshot 与此次交付一致,打开返回 URL 确认画布能启动后才交付链接;直接打开源码 index.html 不能替代预览。预览可能被宿主或系统回收;失效时查看 start.logs,重跑启动命令并验证,用 `craft_preview_stop(name)` 停止。源码或构建产物变化后重新检查、交付。
|
|
33
|
+
6. 玩法和视觉均通过后,调用 `craft_game_deliver(task_id,visual_passed:true,visual_notes,work_id)`,填写实际观察。返回 awaiting_host_start 时,由 AI IDE 使用后台终端执行 `start.script` 并保持该任务运行;这是持续服务命令,不等待终端退出才查询状态。Craft 不启动预览。轮询 `craft_game_info(name).preview`,直到 running=true 且 snapshot 与此次交付一致,打开返回 URL 确认画布能启动后才交付链接;直接打开源码 index.html 不能替代预览。预览可能被宿主或系统回收;失效时查看 start.logs,重跑启动命令并验证,用 `craft_preview_stop(name,work_id)` 停止。源码或构建产物变化后重新检查、交付。
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
用户要求上传或发布时,先完成本地检查与看图。上传前明确告知用户:“本次上传会以本地源码和 dist 新增云端版本,并将它设为当前版本;不会合并或保留 Web 侧尚未同步到本地的修改。原有历史版本仍保留,可在 Web 回退。”默认调用 `craft_game_upload(name,check_task_id,work_id,upload_mode:"current_project")`,同一工程、账号和平台沿用绑定的 appid,首次未绑定时创建项目。
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
仅当用户明确要求“新建项目”或“上传为新项目”时,传 `upload_mode:"new_project"`,并为这次操作生成唯一 `request_key`。这会创建新 appid,成功后自动切换本地绑定;后续默认上传进入新项目,原项目及其历史保留。新建云端项目不需要重建本地工程。
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
随后调用 `craft_game_publish_review(name,publication_id)`,向用户展示完整文案、封面、截图、目标版本、是否开放二创,以及图片上传后为公开 URL 的事实。取得用户对本次 `revision` 的明确确认后,才调用 `craft_game_publish_submit(name,publication_id,revision,confirmed:true)`。材料变化须重新准备、看图和确认;准备完成不表示获得了提交授权。
|
|
42
|
-
|
|
43
|
-
提交任务完成只表示已发起审核。用 `craft_game_publish_status(name,publication_id)` 查询,保留原 ID 恢复超时;只有当前版本 `share_completed` 且返回匹配的 `public_url` 才报告发布成功。审核失败展示原因并修改后重新准备;审核未启用、缺材料或仍在等待时不冒充通过。公开发布能力以当前服务返回的开关和审核状态为准。
|
|
44
|
-
|
|
45
|
-
若状态返回 `finalization_retry_required:true`,审核已经通过但最终存储收尾需要重试;复用原 publication_id、revision 和既有确认调用 submit,只恢复同一份已审材料的收尾,不重新准备或另发审核。
|
|
46
|
-
|
|
47
|
-
已公开的同一版本只支持原 publication_id 的幂等重试。修改已公开作品的文案或图片时,重新检查并上传新版本(保留 appid),再准备和确认新材料;旧线上版本在新版本审核期间保持不变。外部包只有 dist,不包含可编辑源码,`open_to_recreate` 必须为 false。
|
|
39
|
+
使用 `craft_task_status` 等待,或用 `craft_game_upload_status` 查询;中断、重试和状态查询必须复用原 `check_task_id`、`upload_mode` 和 `request_key`,不能为重试生成新 key。修改源码后重新检查;同一检查结果再次新建项目时,仅在用户明确提出新操作后使用新 key。收到 `draft_ready` 后,向用户报告后端实际返回的版本号 `v{version_number}`、appid 和可点击的 `project_url`,不要推算版本号或将上传说成已发布。源码和 dist 分别上传并绑定同一版本,源码保持私有;用户在 Craft 网页试玩、填写材料并提交发布。
|
|
48
40
|
|
|
49
41
|
## 引擎参考上下文
|
|
50
42
|
|
|
@@ -69,8 +61,12 @@ prepare 会维护项目根 `AGENTS.md` 的 Craft 段,并为已选择的宿主
|
|
|
69
61
|
]
|
|
70
62
|
```
|
|
71
63
|
|
|
72
|
-
支持本地 2D/Phaser、3D/Three.js
|
|
64
|
+
支持本地 2D/Phaser、3D/Three.js、工程检查、本地预览和私有版本上传。目录校验不构成同 UID 的 OS 沙箱;禁止读取宿主私有状态或修改安装包。
|
|
73
65
|
|
|
74
66
|
## 结束与交接
|
|
75
67
|
|
|
76
|
-
|
|
68
|
+
完成或暂停编辑时,等待后台任务结束,更新 `SPEC/PROGRESS.md` 并调用 `craft_game_release(name,work_id)`;释放不关闭 MCP、不停止只读预览。新会话先 info 核对项目,再 craft_update_check(name,request_key) 只读检查版本。继续制作前发现 update_available=true 且 automatic_update_enabled=true 时,自动 craft_update(name,mode=auto,request_key) 安装兼容新版;prepare 自身也检查,与前置检查复用 request_key。
|
|
69
|
+
|
|
70
|
+
新版安装后,当前 MCP 进程继续使用原版本;在下次启动或用户重连后加载新版,不主动重载或结束工作。重连前完成后台任务、记录进度并 release。重连后用当前聊天的 craft_game_info 核对实际 version、build_id、active_verified 和 host/workspace/platform;安装回执或独立探测不能代替核验。只对明确未开始的 prepare 复用 request_key,不重放结果不明的操作。
|
|
71
|
+
|
|
72
|
+
新版运行后,prepare(resume) 同步当前宿主及原引擎的兼容上下文和 Skill,保留源码、用户规则与进度。当前 work 内保持原版本和 context_revision,更新只在准备阶段发生。同步后重读入口、技能索引和所需正文;原生 Skill 发现结果单独核对。纯查看不 prepare、不更新项目。
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schema": 2,
|
|
3
3
|
"engine": "js3d",
|
|
4
4
|
"host": "zcode",
|
|
5
|
-
"version": "1.0.
|
|
6
|
-
"source_revision": "sha256:
|
|
5
|
+
"version": "1.0.6",
|
|
6
|
+
"source_revision": "sha256:77705c9e29431cf1c176d8b7eaa6ac967537cc2398f0f02d7a6cb39da4ae219d",
|
|
7
7
|
"contracts": {
|
|
8
8
|
"export": 1,
|
|
9
9
|
"skills": 1,
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"js3d/project/tsconfig.json": "ff460bbe00552390594da800297aa4d1bcd0c21e07ebe2794d7fc94cf5debd58",
|
|
99
99
|
"js3d/project/unified_data_control_config.json": "713e928403c10e069dc2d43b74da0a5ca4323f616ee84917d7df8f2e9bc48b21",
|
|
100
100
|
"js3d/project/vite.config.ts": "3446dbee391e5c15aa3fa1770cadf16c4214d11715881784ed879c2f317d9f8f",
|
|
101
|
-
"craft-game-maker/SKILL.md": "
|
|
101
|
+
"craft-game-maker/SKILL.md": "e6c425a7747d809da53c4be8720fbb5b4bebe704ad891565edfa4968128ac83b",
|
|
102
102
|
"craft-game-maker/js3d.md": "30463613fbfb1bcdd0999debc1b1584b111b621fd4d26bf4ce72a51678616c34",
|
|
103
|
-
"target.json": "
|
|
104
|
-
"bootstrap/SKILL.md": "
|
|
105
|
-
"recovery.md": "
|
|
103
|
+
"target.json": "43c30681ade072d97ecf399741b74dd70014a18db8ab4bafb3316a094ee94c3a",
|
|
104
|
+
"bootstrap/SKILL.md": "503227f9f7135eea4c381b77ec344cf796fad438ba9e6f95339d47c1e3cb3ec8",
|
|
105
|
+
"recovery.md": "87726297bfbdca50a6fd9c75bea635ced123d2dda24942197cb78ca9348237d8"
|
|
106
106
|
},
|
|
107
|
-
"id": "
|
|
107
|
+
"id": "7a2346b49e7044542958619213e7bd5b4f24d14c174a232386f4a26aa7e379a1"
|
|
108
108
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# 恢复当前 ZCode / 3D / Three.js 游戏
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
新会话首次处理本项目时,用 `craft_game_info(name)` 核对目录,再自动调用只读 `craft_update_check(name,request_key)`。继续制作且 update_available=true、automatic_update_enabled=true 时,调用 `craft_update(name,mode:"auto",request_key)` 安装兼容新版。纯查看不安装;检查、安装及 prepare 复用同一 request_key,prepare 也会兜底检查。
|
|
4
|
+
|
|
5
|
+
新版安装后,当前 MCP 进程继续使用原版本;在下次启动或用户重连后加载新版,不主动重载或结束工作。重连前完成后台任务、记录进度并 release。重连后用当前聊天的 craft_game_info 核对实际 version、build_id、active_verified 和 host/workspace/platform;安装回执或独立探测不能代替核验。只对明确未开始的 prepare 复用 request_key,不重放结果不明的操作。
|
|
6
|
+
|
|
7
|
+
新版确认后调用 `craft_game_prepare(name,mode:"resume",request_key)`,更新当前宿主、原引擎的上下文正文、技能索引、受管 Skill 和恢复入口。轮询完成后重新读取入口、索引和所需正文;磁盘更新不代表模型已采用新内容。
|
|
4
8
|
|
|
5
9
|
本套资料安装在项目 `.zcode/`。请在该游戏项目目录开启会话,从 `AGENTS.md` 和项目 `craft-project` Skill 恢复。使用本宿主目录下的 `AGENTS.md`、`workflow.md`、`guide.md`、`knowledge/` 和 `skills/`,按任务选择领域 Skill,无需从缓存或版本目录查找正文。
|
|
6
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"kind": "craft-local-runtime",
|
|
4
|
-
"profile_version": "1.
|
|
4
|
+
"profile_version": "1.2.0",
|
|
5
5
|
"builder": {
|
|
6
6
|
"name": "esbuild",
|
|
7
7
|
"version": "0.27.7"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"commit": "48ef7264f54dd2868aca98822493f074ccea6e7b",
|
|
26
26
|
"snapshot_sha256": "e2ab885cc08613dbef8631b7cd1daa0b6ca13ccfb9defb47d0cf60f7ad07e332"
|
|
27
27
|
},
|
|
28
|
-
"profile_sha256": "
|
|
28
|
+
"profile_sha256": "e1762c932e45c2b62860bf40d40521c536b550e5a6a52aa45e5e02c983669cbc",
|
|
29
29
|
"inputs": {
|
|
30
30
|
"vendor/agent-cli/dist/src/protocol/messages/errors.gen.js": "532600441cf85d41f645ff637efce263dca2b1cd91c308d54572f33f4b7883e4",
|
|
31
31
|
"vendor/agent-cli/dist/src/protocol/link/envelope.js": "5bbaeb11b3fa78494f019808d828fb9d547c60d61579daae79f6977bdff50d5e",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vendor/agent-cli/dist/src/context/template-seed.js": "e816945896c5ed3f0ee1ed9b9375e1b94fa13dd1d00d84b70596e02ac93666b9",
|
|
49
49
|
"vendor/agent-cli/dist/src/context/template-refresh.js": "bead4ae074929d100e5653ac131faa23b2fa80526602663567e7e69aa0d760cd",
|
|
50
50
|
"vendor/agent-cli/dist/src/context/template-sync.js": "37f7e6be88234757f73dea7c01ca94c66434207508c38a002dd5165bc5190af0",
|
|
51
|
-
"sdk/finalize-game-context.mjs": "
|
|
51
|
+
"sdk/finalize-game-context.mjs": "743f18b58c35e2995744f8e5fb6adff7402d6a5d290ddd4f5eb250c48af06980",
|
|
52
52
|
"vendor/agent-cli/dist/src/component/isolated-launcher.js": "05a5ccf310d5d54560779396020442a7374a6bbec2a1b77231b0ba670c5cee15",
|
|
53
53
|
"vendor/agent-cli/dist/src/component/proxied-fetch.js": "7d2f81d904409e9872bb4786d13d92cc9686dd94b3d81698a93593937689e15b",
|
|
54
54
|
"vendor/agent-cli/dist/src/component/isolated-preload.js": "f508888d0e1c81c371227a3375be6ea658497a3f9ae5038eee48a8e041bdb734"
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"isolated-launcher.js": "e29f878445a81ab5b3c2855c4a1741f78992a42bb95b2cddc8a18e5bb9634584",
|
|
59
59
|
"isolated-preload.js": "7fd2caa820191e5c0dc188db71d500e2854650198795fd088e90a2438326d625",
|
|
60
60
|
"NOTICE.md": "b0211e04bc1e6a5d54976ca72fb50b462eb2aae581e11f4992ab511fccfb9afe",
|
|
61
|
-
"package.json": "
|
|
61
|
+
"package.json": "de47a8df9940bb87a45ca833aa9d2f1df120b9c34dcb6d788a47d48fed169835"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { constants } from 'node:fs';
|
|
3
|
-
import { open, mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { createHash } from 'node:crypto';
|
|
5
|
-
import { boundedBody } from '../upstream/craft-aigc.mjs';
|
|
6
|
-
import { safeProjectFile } from './asset-import.mjs';
|
|
7
|
-
import { imageExtension } from './asset-formats.mjs';
|
|
8
|
-
import { digest } from './request-store.mjs';
|
|
9
|
-
|
|
10
|
-
const text = (value, max, label) => {
|
|
11
|
-
if (typeof value !== 'string' || !value.trim() || [...value].length > max || /[\x00-\x08\x0b\x0c\x0e-\x1f]/.test(value)) throw new Error(`Invalid publication ${label}`);
|
|
12
|
-
return value.trim();
|
|
13
|
-
};
|
|
14
|
-
const imageLimit = 2 * 1024 * 1024;
|
|
15
|
-
|
|
16
|
-
export function publicationMaterials(input) {
|
|
17
|
-
const allowed = ['game_name','instructions','game_type','art_styles','play_tags','open_to_recreate','cover_path','cover_image_source'];
|
|
18
|
-
if (!input || Array.isArray(input) || typeof input !== 'object' || Object.keys(input).some(key=>!allowed.includes(key))) throw new Error('Invalid publication materials');
|
|
19
|
-
const result = { game_name:text(input.game_name,40,'game_name'), instructions:text(input.instructions,8000,'instructions'),game_type:text(input.game_type,100,'game_type') };
|
|
20
|
-
for (const key of ['art_styles','play_tags']) {
|
|
21
|
-
const values = input[key] ?? [];
|
|
22
|
-
if (!Array.isArray(values) || values.length > 12) throw new Error('Invalid publication tags');
|
|
23
|
-
result[key] = [...new Set(values.map(value=>text(value,50,key)))];
|
|
24
|
-
}
|
|
25
|
-
if (Buffer.byteLength(JSON.stringify({ game_type:result.game_type,art_styles:result.art_styles,play_tags:result.play_tags })) > 1900) throw new Error('Publication tags exceed the platform limit');
|
|
26
|
-
if (input.open_to_recreate !== undefined && typeof input.open_to_recreate !== 'boolean') throw new Error('Choose open_to_recreate explicitly as a boolean');
|
|
27
|
-
if (input.open_to_recreate === true) throw new Error('External dist-only versions do not include editable sources; open_to_recreate must be false');
|
|
28
|
-
result.open_to_recreate = input.open_to_recreate ?? false;
|
|
29
|
-
if (input.cover_image_source !== undefined && ![1,2].includes(input.cover_image_source)) throw new Error('Invalid cover image source');
|
|
30
|
-
result.cover_image_source = input.cover_image_source ?? 2;
|
|
31
|
-
if (input.cover_path !== undefined) {
|
|
32
|
-
const value = text(input.cover_path,512,'cover_path');
|
|
33
|
-
if (path.isAbsolute(value) || /[\\:\x00]/.test(value) || value.split('/').some(part=>!part || part.startsWith('.'))) throw new Error('Cover must be a project-relative PNG/JPEG');
|
|
34
|
-
result.cover_path = value;
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function readMaterial(root, relative, expected) {
|
|
40
|
-
const file = await safeProjectFile(root,relative);
|
|
41
|
-
const handle = await open(file,constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
42
|
-
let data;
|
|
43
|
-
try {
|
|
44
|
-
const stat = await handle.stat();
|
|
45
|
-
if (!stat.isFile() || stat.size < 1 || stat.size > imageLimit) throw new Error('Publication images must be at most 2 MiB');
|
|
46
|
-
data = await handle.readFile();
|
|
47
|
-
if (data.length !== stat.size) throw new Error('Publication image changed while reading');
|
|
48
|
-
} finally { await handle.close(); }
|
|
49
|
-
const image = inspectImage(data);
|
|
50
|
-
if (expected && (image.sha256 !== expected.sha256 || image.bytes !== expected.bytes ||
|
|
51
|
-
(expected.extension !== undefined && image.extension !== expected.extension))) throw new Error('Publication material changed; prepare and confirm it again');
|
|
52
|
-
return image;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function inspectImage(data) {
|
|
56
|
-
const extension = imageExtension(data);
|
|
57
|
-
if (!['png','jpg'].includes(extension)) throw new Error('Publication images must be PNG or JPEG');
|
|
58
|
-
return { data,extension,sha256:createHash('sha256').update(data).digest('hex'),bytes:data.length };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function readPublishedCover(url, signal) {
|
|
62
|
-
try {
|
|
63
|
-
const response = await fetch(url,{ redirect:'error',credentials:'omit',
|
|
64
|
-
signal:AbortSignal.any([signal,AbortSignal.timeout(15000)]) });
|
|
65
|
-
if (!response.ok) {
|
|
66
|
-
await response.body?.cancel();
|
|
67
|
-
throw new Error('Publication cover download failed');
|
|
68
|
-
}
|
|
69
|
-
return inspectImage(await boundedBody(response,imageLimit));
|
|
70
|
-
} catch {
|
|
71
|
-
signal.throwIfAborted();
|
|
72
|
-
throw new Error('无法读取上次发布的封面。请上传新封面,或取消沿用以使用本次试玩截图。');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export async function writeMaterial(directory, name, purpose, image) {
|
|
77
|
-
await mkdir(directory,{ recursive:true,mode:0o700 });
|
|
78
|
-
const filename = `${name}.${image.extension}`;
|
|
79
|
-
await writeFile(path.join(directory,filename),image.data,{ flag:'wx',mode:0o600 });
|
|
80
|
-
return { file:filename,purpose,sha256:image.sha256,bytes:image.bytes,extension:image.extension };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export async function copyMaterial(root, relative, directory, name, purpose, expected) {
|
|
84
|
-
return writeMaterial(directory,name,purpose,await readMaterial(root,relative,expected));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function publicationRevision(record) {
|
|
88
|
-
return digest({ request_id:record.request_id,workspace:record.workspace,name:record.name,owner:record.owner,platform:record.platform,
|
|
89
|
-
check_task_id:record.check_task_id,conversation_id:record.conversation_id,version_id:record.version_id,
|
|
90
|
-
external_manifest_sha256:record.external_manifest_sha256,archive_sha256:record.archive_sha256,
|
|
91
|
-
materials:record.materials,images:record.images,playtest_seconds:record.playtest_seconds });
|
|
92
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { guardWork } from './work-scope.mjs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { mkdir } from 'node:fs/promises';
|
|
5
|
-
import { capturePublishMaterial } from './publish-capture.mjs';
|
|
6
|
-
import { publicationMaterials, copyMaterial, readMaterial, readPublishedCover, writeMaterial, publicationRevision } from './publication-materials.mjs';
|
|
7
|
-
|
|
8
|
-
function view(record, remote) {
|
|
9
|
-
const matched = remote?.client_request_id === record.request_id;
|
|
10
|
-
const published = matched && remote.state === 'share_completed' && Boolean(remote.public_url);
|
|
11
|
-
return { publication_id:record.request_id,name:record.name,check_task_id:record.check_task_id,
|
|
12
|
-
conversation_id:record.conversation_id,version_id:record.version_id,revision:record.revision,
|
|
13
|
-
state:remote ? matched ? remote.state : remote.state === 'not_submitted' ? record.state : 'different_publication' : record.state,
|
|
14
|
-
published, ...(published ? { public_url:remote.public_url } : {}),status_reason:matched ? remote.status_reason : undefined,
|
|
15
|
-
finalization_retry_required:matched && remote.finalization_retry_required === true,
|
|
16
|
-
materials:record.materials,playtest_seconds:record.playtest_seconds,
|
|
17
|
-
display_screenshot_count:record.images.filter(image=>image.purpose === 'screenshot').length,
|
|
18
|
-
audit_screenshot_count:record.images.filter(image=>image.purpose === 'audit-shot').length,
|
|
19
|
-
material_visibility:'public_on_upload', confirmation_required:record.state === 'awaiting_confirmation',
|
|
20
|
-
next:published ? 'The requested version is published.' : matched && remote.finalization_retry_required
|
|
21
|
-
? 'Retry craft_game_publish_submit with this same publication_id and confirmed revision. Only the already approved publication finalization is retried; do not prepare or re-audit new materials.' : record.state === 'awaiting_confirmation'
|
|
22
|
-
? 'Call craft_game_publish_review, show the exact metadata and images to the user, and obtain confirmation for this revision before submitting.'
|
|
23
|
-
: 'Keep this publication_id. Query craft_game_publish_status; do not create another submission after a timeout.' };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class Publications {
|
|
27
|
-
constructor(platform, store, drafts, evidence, capture = capturePublishMaterial) {
|
|
28
|
-
Object.assign(this,{ platform,store,drafts,evidence,capture });
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async #record(name, id, owner) {
|
|
32
|
-
const record = await this.store.read(id);
|
|
33
|
-
if (this.platform.account().user_id !== owner || record.name !== name || record.owner !== owner || record.platform !== this.platform.base || record.revision !== publicationRevision(record)) {
|
|
34
|
-
throw new Error('Publication belongs to a different project, account, platform or material revision');
|
|
35
|
-
}
|
|
36
|
-
return record;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
#directory(record) { return path.join(this.store.directory,record.request_id); }
|
|
40
|
-
|
|
41
|
-
async previous(check, owner, signal) {
|
|
42
|
-
const conversation_id = await this.drafts.publicationTarget(check,owner);
|
|
43
|
-
if (!conversation_id) return;
|
|
44
|
-
const previous = await this.platform.publicationSession(owner)('previous',{ conversation_id },signal);
|
|
45
|
-
if (previous?.cover_url && new URL(previous.cover_url).origin !== await this.platform.assetOrigin()) delete previous.cover_url;
|
|
46
|
-
return previous;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async prepare(check, project, input, owner, signal, stagedCover, previousCover) {
|
|
50
|
-
const materials = publicationMaterials(input);
|
|
51
|
-
if (stagedCover && materials.cover_path) throw new Error('Choose one publication cover source');
|
|
52
|
-
const source = await this.drafts.publicationSource(check.name,check.task_id,owner,signal);
|
|
53
|
-
if (source.state !== 'draft_ready' || !/^[0-9a-f]{64}$/.test(source.external_manifest_sha256 ?? '')) throw new Error('Upload this checked build with craft_game_upload before preparing publication; the Web runtime must return its manifest SHA');
|
|
54
|
-
const existing = await this.platform.publicationSession(owner)('status',{ version_id:source.version_id },signal);
|
|
55
|
-
if (existing.state !== 'not_submitted' && (existing.conversation_id !== source.conversation_id || existing.external_manifest_sha256 !== source.external_manifest_sha256)) throw new Error('Publication status differs from the uploaded build');
|
|
56
|
-
if (existing.state === 'share_completed') throw new Error('This version is already published. Run a new game check and upload a new version under the same appid before changing its publication materials. Reuse the original publication_id only for an identical retry.');
|
|
57
|
-
if (['sharing','share_repacking'].includes(existing.state)) throw new Error('This version already has a review in progress; query the original publication_id before preparing another submission');
|
|
58
|
-
let reusedCover;
|
|
59
|
-
if (previousCover && !stagedCover && !materials.cover_path) {
|
|
60
|
-
if (previousCover.conversation_id !== source.conversation_id || previousCover.version_id === source.version_id ||
|
|
61
|
-
new URL(previousCover.cover_url).origin !== await this.platform.assetOrigin()) throw new Error('上次发布的封面与当前项目或版本不匹配,请刷新进度后重试。');
|
|
62
|
-
reusedCover = await readPublishedCover(previousCover.cover_url,signal);
|
|
63
|
-
materials.cover_image_source = previousCover.cover_image_source;
|
|
64
|
-
}
|
|
65
|
-
const capture = await this.capture(check,this.evidence,signal);
|
|
66
|
-
if (capture.archive_sha256 !== source.archive_sha256 || !Number.isInteger(capture.playtest_seconds) || capture.playtest_seconds < 30 ||
|
|
67
|
-
!Array.isArray(capture.screenshots) || capture.screenshots.length < 1 || capture.screenshots.length > 5 ||
|
|
68
|
-
!Array.isArray(capture.audit_screenshots) || capture.audit_screenshots.length < 3 || capture.audit_screenshots.length > 30) throw new Error('Publication capture does not match the uploaded frozen build');
|
|
69
|
-
const id = randomUUID(), directory = path.join(this.store.directory,id);
|
|
70
|
-
await mkdir(directory,{ mode:0o700 });
|
|
71
|
-
const images = [];
|
|
72
|
-
if (stagedCover) images.push(await copyMaterial(stagedCover.directory,stagedCover.file,directory,'cover','cover',stagedCover));
|
|
73
|
-
else if (materials.cover_path) images.push(await copyMaterial(project,materials.cover_path,directory,'cover','cover'));
|
|
74
|
-
else if (reusedCover) images.push(await writeMaterial(directory,'cover','cover',reusedCover));
|
|
75
|
-
else {
|
|
76
|
-
const file = capture.screenshots[0];
|
|
77
|
-
images.push(await copyMaterial(path.dirname(file),path.basename(file),directory,'cover','cover',capture.screenshot_files?.[0]));
|
|
78
|
-
}
|
|
79
|
-
for (const [purpose,files,metadata] of [['screenshot',capture.screenshots,capture.screenshot_files],['audit-shot',capture.audit_screenshots,capture.audit_screenshot_files]]) {
|
|
80
|
-
const seen = new Set();
|
|
81
|
-
for (const [index,file] of files.entries()) {
|
|
82
|
-
signal.throwIfAborted();
|
|
83
|
-
// Capture paths are produced inside the private evidence directory by our browser worker.
|
|
84
|
-
const relative = path.relative(this.evidence,file);
|
|
85
|
-
if (relative === '..' || relative.startsWith('..' + path.sep) || path.isAbsolute(relative)) throw new Error('Capture image escaped private evidence');
|
|
86
|
-
const source = await readMaterial(path.dirname(file),path.basename(file),metadata?.[index]);
|
|
87
|
-
if (purpose === 'screenshot' && seen.has(source.sha256)) continue;
|
|
88
|
-
seen.add(source.sha256);
|
|
89
|
-
images.push(await copyMaterial(path.dirname(file),path.basename(file),directory,`${purpose}-${index}`,purpose,source));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
delete materials.cover_path;
|
|
93
|
-
signal.throwIfAborted();
|
|
94
|
-
if (this.platform.account().user_id !== owner) throw new Error('Craft account changed');
|
|
95
|
-
const record = await this.store.create({ request_id:id,name:check.name,owner,platform:this.platform.base,engine:check.result.engine,
|
|
96
|
-
check_task_id:check.task_id,conversation_id:source.conversation_id,version_id:source.version_id,
|
|
97
|
-
external_manifest_sha256:source.external_manifest_sha256,archive_sha256:source.archive_sha256,
|
|
98
|
-
materials,images,playtest_seconds:capture.playtest_seconds,capture_receipt:capture.receipt_path,state:'awaiting_confirmation' });
|
|
99
|
-
record.revision = publicationRevision(record);
|
|
100
|
-
await this.store.save(record);
|
|
101
|
-
return view(record);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async review(name, id, owner) {
|
|
105
|
-
const record = await this.#record(name,id,owner), content = [];
|
|
106
|
-
for (const image of record.images) {
|
|
107
|
-
const data = await readMaterial(this.#directory(record),image.file,image);
|
|
108
|
-
if (image.purpose !== 'audit-shot') content.push({ type:'image',mimeType:data.extension === 'png' ? 'image/png' : 'image/jpeg',data:data.data.toString('base64') });
|
|
109
|
-
}
|
|
110
|
-
record.reviewed_revision = record.revision;
|
|
111
|
-
await this.store.save(record);
|
|
112
|
-
if (this.platform.account().user_id !== owner) throw new Error('Craft account changed during publication review');
|
|
113
|
-
return { content:[{ type:'text',text:JSON.stringify({ ...view(record),review:'Show these final materials to the user. Confirm the exact revision, game version, public image uploads and open_to_recreate choice before submitting to ACE.' }) },...content] };
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async #status(record, request, signal) {
|
|
117
|
-
const remote = await request('status',{ version_id:record.version_id },signal);
|
|
118
|
-
if (remote.state !== 'not_submitted' && (remote.version_id !== record.version_id || remote.conversation_id !== record.conversation_id ||
|
|
119
|
-
remote.external_manifest_sha256 !== record.external_manifest_sha256)) throw new Error('Publication status changed its project or build manifest');
|
|
120
|
-
return remote;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async submit(name, id, revision, confirmed, owner, signal) {
|
|
124
|
-
const record = await this.#record(name,id,owner);
|
|
125
|
-
if (confirmed !== true || revision !== record.revision || record.reviewed_revision !== revision) throw new Error('Review the publication images and obtain user confirmation for this exact revision before submitting');
|
|
126
|
-
const request = this.platform.publicationSession(owner);
|
|
127
|
-
const previous = await this.#status(record,request,signal);
|
|
128
|
-
if (previous.client_request_id === record.request_id && previous.state !== 'external_draft') {
|
|
129
|
-
if (!previous.finalization_retry_required) return view(record,previous);
|
|
130
|
-
if (!record.share_input) throw new Error('The original immutable submission payload is required to retry finalization');
|
|
131
|
-
await guardWork();
|
|
132
|
-
await request('submit',{ input:record.share_input },signal);
|
|
133
|
-
record.state = 'submitted';
|
|
134
|
-
await this.store.save(record);
|
|
135
|
-
return view(record,await this.#status(record,request,signal));
|
|
136
|
-
}
|
|
137
|
-
record.image_receipts ??= {};
|
|
138
|
-
for (const image of record.images) {
|
|
139
|
-
signal.throwIfAborted();
|
|
140
|
-
const data = await readMaterial(this.#directory(record),image.file,image);
|
|
141
|
-
await guardWork();
|
|
142
|
-
const receipt = await request('image',{ image:data,purpose:image.purpose,conversation_id:record.conversation_id,
|
|
143
|
-
version_id:record.version_id,external_manifest_sha256:record.external_manifest_sha256 },signal);
|
|
144
|
-
if (receipt.sha256 !== image.sha256 || receipt.bytes !== image.bytes ||
|
|
145
|
-
(record.image_receipts[image.file] && record.image_receipts[image.file].cover_url !== receipt.cover_url)) throw new Error('Platform changed an immutable publication image receipt');
|
|
146
|
-
record.image_receipts[image.file] = receipt;
|
|
147
|
-
await this.store.save(record);
|
|
148
|
-
}
|
|
149
|
-
const urls = purpose=>record.images.filter(image=>image.purpose === purpose).map(image=>record.image_receipts[image.file].cover_url);
|
|
150
|
-
const input = { client_request_id:record.request_id,conversation_id:record.conversation_id,version_id:record.version_id,
|
|
151
|
-
external_manifest_sha256:record.external_manifest_sha256,...record.materials,
|
|
152
|
-
cover_image_url:urls('cover')[0],screenshots:urls('screenshot'),audit_screenshot_urls:urls('audit-shot'),playtest_seconds:record.playtest_seconds };
|
|
153
|
-
if (record.share_input && JSON.stringify(record.share_input) !== JSON.stringify(input)) throw new Error('Publication submission changed after confirmation');
|
|
154
|
-
record.share_input = input; record.state = 'submitting';
|
|
155
|
-
await this.store.save(record);
|
|
156
|
-
await guardWork();
|
|
157
|
-
await request('submit',{ input },signal);
|
|
158
|
-
record.state = 'submitted';
|
|
159
|
-
await this.store.save(record);
|
|
160
|
-
return view(record,await this.#status(record,request,signal));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async status(name, id, owner, signal) {
|
|
164
|
-
const record = await this.#record(name,id,owner);
|
|
165
|
-
if (record.state === 'awaiting_confirmation') return view(record);
|
|
166
|
-
return view(record,await this.#status(record,this.platform.publicationSession(owner),signal));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { lstat, readFile } from 'node:fs/promises';
|
|
4
|
-
import { pathToFileURL } from 'node:url';
|
|
5
|
-
import { performance } from 'node:perf_hooks';
|
|
6
|
-
import { checkedDraftArchive } from './draft-archive.mjs';
|
|
7
|
-
import { atomicJson } from './request-store.mjs';
|
|
8
|
-
import { evaluateCapture, validateSteps } from './check.mjs';
|
|
9
|
-
|
|
10
|
-
const [runnerFile, requestFile] = process.argv.slice(2);
|
|
11
|
-
const request = JSON.parse(await readFile(requestFile,'utf8'));
|
|
12
|
-
validateSteps(request.steps);
|
|
13
|
-
const signal = new AbortController().signal;
|
|
14
|
-
const before = await checkedDraftArchive(request.evidence,request.snapshot_id,request.artifacts,signal);
|
|
15
|
-
if (before.sha256 !== request.archive_sha256) throw new Error('Frozen build changed before publish capture');
|
|
16
|
-
const { captureGame } = await import(pathToFileURL(runnerFile).href);
|
|
17
|
-
const directory = path.dirname(requestFile), snapshot = path.dirname(directory);
|
|
18
|
-
const steps = [request.steps[0], ...Array.from({ length:5 },()=>({ action:'wait',ms:6000,
|
|
19
|
-
expected:'The real game remains running during the publish playtest' })), ...request.steps.slice(1)];
|
|
20
|
-
const capture = { build:'passed',engine:request.engine,shots:[],errors:[],unverified:[] };
|
|
21
|
-
const started = performance.now();
|
|
22
|
-
await captureGame(snapshot,directory,{ engine:request.engine,steps,capture_gameplay_probe:true,
|
|
23
|
-
limits:{ browser_deadline_ms:180000,screenshot_timeout_ms:10000,max_steps:8 } },capture,path.join(snapshot,'dist'));
|
|
24
|
-
const elapsed = performance.now() - started;
|
|
25
|
-
await atomicJson(path.join(directory,'capture.json'),capture);
|
|
26
|
-
if (capture.shots.length !== 9 || elapsed < 30000) throw new Error('Publish playtest did not complete the real 30-second capture');
|
|
27
|
-
const selected = [capture.shots[0],capture.shots[1],capture.shots[7],capture.shots[8]];
|
|
28
|
-
const gate = evaluateCapture({ ...capture,shots:selected },request.steps,request.engine);
|
|
29
|
-
if (!gate.passed) throw new Error('Publish playtest failed: ' + gate.issues.join('; ').slice(0,1000));
|
|
30
|
-
let frames = -1;
|
|
31
|
-
const images = [];
|
|
32
|
-
for (const shot of capture.shots) {
|
|
33
|
-
const probe = shot.gameplay_probe;
|
|
34
|
-
if (probe?.ready !== true || probe.engine !== request.engine || !Number.isFinite(probe.frameCount) || probe.frameCount <= frames) {
|
|
35
|
-
throw new Error('Publish playtest stopped rendering or its game probe changed');
|
|
36
|
-
}
|
|
37
|
-
frames = probe.frameCount;
|
|
38
|
-
if (!/^shot-[0-8]\.jpg$/.test(shot.file)) throw new Error('Invalid captured screenshot name');
|
|
39
|
-
const file = path.join(directory,shot.file), stat = await lstat(file);
|
|
40
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.size < 4 || stat.size > 2 * 1024 * 1024) throw new Error('Publish screenshot exceeds the upload size limit');
|
|
41
|
-
const data = await readFile(file);
|
|
42
|
-
if (data[0] !== 0xff || data[1] !== 0xd8 || data[2] !== 0xff) throw new Error('Publish screenshot is not a JPEG');
|
|
43
|
-
images.push({ path:file,bytes:data.length,sha256:createHash('sha256').update(data).digest('hex'),mime:'image/jpeg',
|
|
44
|
-
captured_at_ms:stat.mtimeMs,frame_count:frames });
|
|
45
|
-
}
|
|
46
|
-
// File times measure the observed browser interval between the real first and
|
|
47
|
-
// final screenshots. Five completed six-second waits also enforce a monotonic
|
|
48
|
-
// minimum, independent of launch/cleanup time or clock adjustments.
|
|
49
|
-
const playtime = images.at(-1).captured_at_ms - images[0].captured_at_ms;
|
|
50
|
-
if (playtime < 30000) throw new Error('Publish screenshots do not cover 30 seconds of real gameplay');
|
|
51
|
-
const after = await checkedDraftArchive(request.evidence,request.snapshot_id,request.artifacts,signal);
|
|
52
|
-
if (after.sha256 !== before.sha256) throw new Error('Frozen build changed during publish capture');
|
|
53
|
-
await atomicJson(path.join(directory,'receipt.json'),{ schema:1,check_task_id:request.check_task_id,
|
|
54
|
-
snapshot_id:request.snapshot_id,engine:request.engine,archive_sha256:before.sha256,
|
|
55
|
-
playtest_seconds:Math.floor(playtime / 1000),playtest_ms:playtime,capture_elapsed_ms:Math.round(elapsed),minimum_wait_ms:30000,
|
|
56
|
-
screenshots:[images[0],images[1],images[7],images[8]],audit_screenshots:images,
|
|
57
|
-
completed_at:new Date().toISOString() });
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { randomUUID, createHash } from 'node:crypto';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { lstat, mkdir, readFile, realpath } from 'node:fs/promises';
|
|
5
|
-
import { prepareBrowserEnvironment, runProcess } from '#craft-sdk';
|
|
6
|
-
import { checkedDraftArchive } from './draft-archive.mjs';
|
|
7
|
-
import { atomicJson } from './request-store.mjs';
|
|
8
|
-
import { engineDefinition } from './engines.mjs';
|
|
9
|
-
import { validateSteps } from './check.mjs';
|
|
10
|
-
|
|
11
|
-
const environmentKeys = new Set(['PATH','HOME','USERPROFILE','APPDATA','LOCALAPPDATA','SYSTEMROOT','WINDIR',
|
|
12
|
-
'COMSPEC','TEMP','TMP','TMPDIR','XDG_CACHE_HOME','NODE_PATH','PLAYWRIGHT_PACKAGE_ROOT',
|
|
13
|
-
'PLAYWRIGHT_BROWSERS_PATH','CRAFT_BROWSER_EXECUTABLE','CRAFT_RUNTIME_POLICY']);
|
|
14
|
-
|
|
15
|
-
// The SDK browser preparer merges the parent environment. Undefined overrides
|
|
16
|
-
// deliberately erase every other inherited key, including unknown credentials.
|
|
17
|
-
export function publishCaptureEnvironment(source = process.env) {
|
|
18
|
-
return Object.fromEntries(Object.entries(source).map(([key,value])=>[key,environmentKeys.has(key.toUpperCase()) ? value : undefined]));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function ordinaryJson(file, maximum = 256 * 1024) {
|
|
22
|
-
const stat = await lstat(file);
|
|
23
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > maximum) throw new Error('Invalid publish capture record');
|
|
24
|
-
return JSON.parse(await readFile(file,'utf8'));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function checkedImage(image, directory) {
|
|
28
|
-
if (!image || typeof image.path !== 'string' || path.dirname(image.path) !== directory ||
|
|
29
|
-
!/^shot-[0-8]\.jpg$/.test(path.basename(image.path))) throw new Error('Invalid publish screenshot path');
|
|
30
|
-
const stat = await lstat(image.path);
|
|
31
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.size < 4 || stat.size > 2 * 1024 * 1024) throw new Error('Invalid publish screenshot size');
|
|
32
|
-
const data = await readFile(image.path);
|
|
33
|
-
if (data[0] !== 0xff || data[1] !== 0xd8 || data[2] !== 0xff ||
|
|
34
|
-
data.length !== image.bytes || createHash('sha256').update(data).digest('hex') !== image.sha256) throw new Error('Publish screenshot changed');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function capturePublishMaterial(check, evidence, signal) {
|
|
38
|
-
signal.throwIfAborted();
|
|
39
|
-
const result = check?.result;
|
|
40
|
-
if (check?.kind !== 'check' || check.status !== 'completed' || !result?.gate?.passed ||
|
|
41
|
-
!/^[0-9a-f-]{36}$/.test(check.task_id)) throw new Error('A completed passing game check is required for publish capture');
|
|
42
|
-
engineDefinition(result.engine);
|
|
43
|
-
const archive = await checkedDraftArchive(evidence,result.snapshot_id,result.artifacts,signal);
|
|
44
|
-
const evidenceRoot = await realpath(evidence), snapshot = path.join(evidenceRoot,result.snapshot_id);
|
|
45
|
-
const original = await ordinaryJson(path.join(snapshot,'request.json'));
|
|
46
|
-
if (original.engine !== result.engine) throw new Error('Publish capture engine differs from its check');
|
|
47
|
-
validateSteps(original.steps);
|
|
48
|
-
const directory = path.join(snapshot,'publish-' + randomUUID());
|
|
49
|
-
await mkdir(directory,{ mode:0o700 });
|
|
50
|
-
const requestFile = path.join(directory,'request.json');
|
|
51
|
-
await atomicJson(requestFile,{ check_task_id:check.task_id, snapshot_id:result.snapshot_id, engine:result.engine,
|
|
52
|
-
evidence:evidenceRoot, artifacts:result.artifacts, archive_sha256:archive.sha256, steps:original.steps });
|
|
53
|
-
const safe = publishCaptureEnvironment();
|
|
54
|
-
const browser = await prepareBrowserEnvironment({ cwd:snapshot,env:safe,signal });
|
|
55
|
-
const env = Object.fromEntries(Object.entries({ ...safe,...browser }).filter(([,value])=>value !== undefined));
|
|
56
|
-
const resources = process.env.CRAFT_MCP_RESOURCES_DIR || fileURLToPath(new URL('../../resources/',import.meta.url));
|
|
57
|
-
const runner = path.join(resources,'game_visual_qa.mjs');
|
|
58
|
-
const run = await runProcess(process.execPath,[fileURLToPath(new URL('./publish-capture-worker.mjs',import.meta.url)),runner,requestFile],{
|
|
59
|
-
cwd:snapshot,env,signal,timeoutMs:200000,
|
|
60
|
-
});
|
|
61
|
-
signal.throwIfAborted();
|
|
62
|
-
if (run.exitCode !== 0 || run.timedOut || run.aborted) throw new Error('Publish playtest capture failed: ' + (run.stderr || run.stdout).slice(-1500));
|
|
63
|
-
const receipt = await ordinaryJson(path.join(directory,'receipt.json'));
|
|
64
|
-
if (receipt.check_task_id !== check.task_id || receipt.snapshot_id !== result.snapshot_id ||
|
|
65
|
-
receipt.engine !== result.engine || receipt.archive_sha256 !== archive.sha256 ||
|
|
66
|
-
!Number.isFinite(receipt.playtest_seconds) || receipt.playtest_seconds < 30 ||
|
|
67
|
-
!Array.isArray(receipt.screenshots) || receipt.screenshots.length !== 4 ||
|
|
68
|
-
!Array.isArray(receipt.audit_screenshots) || receipt.audit_screenshots.length !== 9) throw new Error('Invalid publish capture receipt');
|
|
69
|
-
for (const image of [...receipt.screenshots,...receipt.audit_screenshots]) await checkedImage(image,directory);
|
|
70
|
-
const after = await checkedDraftArchive(evidenceRoot,result.snapshot_id,result.artifacts,signal);
|
|
71
|
-
if (after.sha256 !== archive.sha256) throw new Error('Frozen build changed during publish capture');
|
|
72
|
-
return { ...receipt, screenshot_files:receipt.screenshots,audit_screenshot_files:receipt.audit_screenshots,
|
|
73
|
-
screenshots:receipt.screenshots.map(image=>image.path),audit_screenshots:receipt.audit_screenshots.map(image=>image.path),
|
|
74
|
-
receipt_path:path.join(directory,'receipt.json') };
|
|
75
|
-
}
|