@craft_eco/craft-mcp 0.1.34-beta.1 → 0.1.34-beta.3

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.
Files changed (407) hide show
  1. package/README.md +8 -8
  2. package/bin/craft-mcp.mjs +28 -2
  3. package/dist-server/game-workflow/art-previews.mjs +71 -0
  4. package/dist-server/game-workflow/bundle-files.mjs +12 -3
  5. package/dist-server/game-workflow/bundle-template.mjs +37 -37
  6. package/dist-server/game-workflow/local-context.mjs +64 -62
  7. package/dist-server/game-workflow/native-context.mjs +18 -5
  8. package/dist-server/game-workflow/project-art-previews.mjs +63 -0
  9. package/dist-server/game-workflow/project-bundles.mjs +97 -21
  10. package/dist-server/game-workflow/project-context.mjs +9 -8
  11. package/dist-server/game-workflow/project-install.mjs +2 -1
  12. package/dist-server/game-workflow/projects.mjs +15 -13
  13. package/dist-server/integrations/config.mjs +41 -18
  14. package/dist-server/integrations/connect.mjs +18 -9
  15. package/dist-server/integrations/connection-handoff.mjs +9 -8
  16. package/dist-server/integrations/dsh-config.mjs +30 -14
  17. package/dist-server/integrations/files.mjs +3 -1
  18. package/dist-server/integrations/fixed-launcher.mjs +1 -0
  19. package/dist-server/integrations/host-config-scope.mjs +4 -3
  20. package/dist-server/integrations/hosts.mjs +3 -1
  21. package/dist-server/integrations/install-source.mjs +44 -0
  22. package/dist-server/integrations/install.mjs +183 -53
  23. package/dist-server/integrations/installation-state.mjs +2 -1
  24. package/dist-server/integrations/instance-skill.mjs +26 -0
  25. package/dist-server/integrations/instance.mjs +29 -0
  26. package/dist-server/integrations/launcher-start.mjs +1 -1
  27. package/dist-server/integrations/login-task-command.mjs +3 -3
  28. package/dist-server/integrations/opencode-config.mjs +13 -6
  29. package/dist-server/integrations/project-setup.mjs +52 -22
  30. package/dist-server/integrations/runtime.mjs +2 -1
  31. package/dist-server/integrations/uninstall.mjs +160 -0
  32. package/dist-server/integrations/updates.mjs +57 -28
  33. package/dist-server/launcher.mjs +18 -2
  34. package/dist-server/mcp/server.mjs +18 -9
  35. package/dist-server/mcp/update-session.mjs +35 -18
  36. package/dist-server/upstream/craft-aigc.mjs +11 -2
  37. package/dist-server/upstream/draft-audit.mjs +52 -6
  38. package/package.json +4 -2
  39. package/resources/context-filter-report.json +1 -1
  40. package/resources/craft-create/SKILL.md +25 -23
  41. package/resources/craft-update/SKILL.md +27 -25
  42. package/resources/targets/claude/js/context-filter-report.json +1 -1
  43. package/resources/targets/claude/js/js/bundle.json +5 -5
  44. package/resources/targets/claude/js/recovery.md +1 -1
  45. package/resources/targets/claude/js/target.json +1 -1
  46. package/resources/targets/claude/js3d/context-filter-report.json +1 -1
  47. package/resources/targets/claude/js3d/js3d/bundle.json +25 -23
  48. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  49. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  50. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  51. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  52. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  53. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  54. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  55. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  56. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  57. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  58. package/resources/targets/claude/js3d/recovery.md +1 -1
  59. package/resources/targets/claude/js3d/target.json +1 -1
  60. package/resources/targets/codebuddy/js/context-filter-report.json +1 -1
  61. package/resources/targets/codebuddy/js/js/bundle.json +5 -5
  62. package/resources/targets/codebuddy/js/recovery.md +1 -1
  63. package/resources/targets/codebuddy/js/target.json +1 -1
  64. package/resources/targets/codebuddy/js3d/context-filter-report.json +1 -1
  65. package/resources/targets/codebuddy/js3d/js3d/bundle.json +25 -23
  66. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  67. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  68. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  69. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  70. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  71. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  72. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  73. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  74. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  75. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  76. package/resources/targets/codebuddy/js3d/recovery.md +1 -1
  77. package/resources/targets/codebuddy/js3d/target.json +1 -1
  78. package/resources/targets/codex/js/context-filter-report.json +1 -1
  79. package/resources/targets/codex/js/js/bundle.json +5 -5
  80. package/resources/targets/codex/js/recovery.md +1 -1
  81. package/resources/targets/codex/js/target.json +1 -1
  82. package/resources/targets/codex/js3d/context-filter-report.json +1 -1
  83. package/resources/targets/codex/js3d/js3d/bundle.json +25 -23
  84. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  85. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  86. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  87. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  88. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  89. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  90. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  91. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  92. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  93. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  94. package/resources/targets/codex/js3d/recovery.md +1 -1
  95. package/resources/targets/codex/js3d/target.json +1 -1
  96. package/resources/targets/comate/js/context-filter-report.json +1 -1
  97. package/resources/targets/comate/js/js/bundle.json +5 -5
  98. package/resources/targets/comate/js/recovery.md +1 -1
  99. package/resources/targets/comate/js/target.json +1 -1
  100. package/resources/targets/comate/js3d/context-filter-report.json +1 -1
  101. package/resources/targets/comate/js3d/js3d/bundle.json +25 -23
  102. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  103. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  104. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  105. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  106. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  107. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  108. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  109. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  110. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  111. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  112. package/resources/targets/comate/js3d/recovery.md +1 -1
  113. package/resources/targets/comate/js3d/target.json +1 -1
  114. package/resources/targets/cursor/js/context-filter-report.json +1 -1
  115. package/resources/targets/cursor/js/js/bundle.json +5 -5
  116. package/resources/targets/cursor/js/recovery.md +1 -1
  117. package/resources/targets/cursor/js/target.json +1 -1
  118. package/resources/targets/cursor/js3d/context-filter-report.json +1 -1
  119. package/resources/targets/cursor/js3d/js3d/bundle.json +25 -23
  120. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  121. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  122. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  123. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  124. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  125. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  126. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  127. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  128. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  129. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  130. package/resources/targets/cursor/js3d/recovery.md +1 -1
  131. package/resources/targets/cursor/js3d/target.json +1 -1
  132. package/resources/targets/dsh/js/context-filter-report.json +1 -1
  133. package/resources/targets/dsh/js/js/bundle.json +5 -5
  134. package/resources/targets/dsh/js/recovery.md +1 -1
  135. package/resources/targets/dsh/js/target.json +1 -1
  136. package/resources/targets/dsh/js3d/context-filter-report.json +1 -1
  137. package/resources/targets/dsh/js3d/js3d/bundle.json +25 -23
  138. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  139. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  140. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  141. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  142. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  143. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  144. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  145. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  146. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  147. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  148. package/resources/targets/dsh/js3d/recovery.md +1 -1
  149. package/resources/targets/dsh/js3d/target.json +1 -1
  150. package/resources/targets/index.json +56 -56
  151. package/resources/targets/kimi/js/context-filter-report.json +1 -1
  152. package/resources/targets/kimi/js/js/bundle.json +5 -5
  153. package/resources/targets/kimi/js/recovery.md +1 -1
  154. package/resources/targets/kimi/js/target.json +1 -1
  155. package/resources/targets/kimi/js3d/context-filter-report.json +1 -1
  156. package/resources/targets/kimi/js3d/js3d/bundle.json +25 -23
  157. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  158. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  159. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  160. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  161. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  162. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  163. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  164. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  165. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  166. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  167. package/resources/targets/kimi/js3d/recovery.md +1 -1
  168. package/resources/targets/kimi/js3d/target.json +1 -1
  169. package/resources/targets/opencode/js/context-filter-report.json +1 -1
  170. package/resources/targets/opencode/js/js/bundle.json +5 -5
  171. package/resources/targets/opencode/js/recovery.md +1 -1
  172. package/resources/targets/opencode/js/target.json +1 -1
  173. package/resources/targets/opencode/js3d/context-filter-report.json +1 -1
  174. package/resources/targets/opencode/js3d/js3d/bundle.json +25 -23
  175. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  176. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  177. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  178. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  179. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  180. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  181. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  182. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  183. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  184. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  185. package/resources/targets/opencode/js3d/recovery.md +1 -1
  186. package/resources/targets/opencode/js3d/target.json +1 -1
  187. package/resources/targets/qoder/js/context-filter-report.json +1 -1
  188. package/resources/targets/qoder/js/js/bundle.json +5 -5
  189. package/resources/targets/qoder/js/recovery.md +1 -1
  190. package/resources/targets/qoder/js/target.json +1 -1
  191. package/resources/targets/qoder/js3d/context-filter-report.json +1 -1
  192. package/resources/targets/qoder/js3d/js3d/bundle.json +25 -23
  193. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  194. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  195. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  196. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  197. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  198. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  199. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  200. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  201. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  202. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  203. package/resources/targets/qoder/js3d/recovery.md +1 -1
  204. package/resources/targets/qoder/js3d/target.json +1 -1
  205. package/resources/targets/qoder-cn/js/context-filter-report.json +1 -1
  206. package/resources/targets/qoder-cn/js/js/bundle.json +5 -5
  207. package/resources/targets/qoder-cn/js/recovery.md +1 -1
  208. package/resources/targets/qoder-cn/js/target.json +1 -1
  209. package/resources/targets/qoder-cn/js3d/context-filter-report.json +1 -1
  210. package/resources/targets/qoder-cn/js3d/js3d/bundle.json +25 -23
  211. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  212. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  213. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  214. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  215. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  216. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  217. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  218. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  219. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  220. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  221. package/resources/targets/qoder-cn/js3d/recovery.md +1 -1
  222. package/resources/targets/qoder-cn/js3d/target.json +1 -1
  223. package/resources/targets/qwen/js/context-filter-report.json +1 -1
  224. package/resources/targets/qwen/js/js/bundle.json +5 -5
  225. package/resources/targets/qwen/js/recovery.md +1 -1
  226. package/resources/targets/qwen/js/target.json +1 -1
  227. package/resources/targets/qwen/js3d/context-filter-report.json +1 -1
  228. package/resources/targets/qwen/js3d/js3d/bundle.json +25 -23
  229. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  230. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  231. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  232. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  233. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  234. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  235. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  236. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  237. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  238. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  239. package/resources/targets/qwen/js3d/recovery.md +1 -1
  240. package/resources/targets/qwen/js3d/target.json +1 -1
  241. package/resources/targets/trae/js/context-filter-report.json +1 -1
  242. package/resources/targets/trae/js/js/bundle.json +5 -5
  243. package/resources/targets/trae/js/recovery.md +1 -1
  244. package/resources/targets/trae/js/target.json +1 -1
  245. package/resources/targets/trae/js3d/context-filter-report.json +1 -1
  246. package/resources/targets/trae/js3d/js3d/bundle.json +25 -23
  247. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  248. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  249. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  250. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  251. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  252. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  253. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  254. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  255. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  256. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  257. package/resources/targets/trae/js3d/recovery.md +1 -1
  258. package/resources/targets/trae/js3d/target.json +1 -1
  259. package/resources/targets/workbuddy/js/context-filter-report.json +1 -1
  260. package/resources/targets/workbuddy/js/js/bundle.json +5 -5
  261. package/resources/targets/workbuddy/js/recovery.md +1 -1
  262. package/resources/targets/workbuddy/js/target.json +1 -1
  263. package/resources/targets/workbuddy/js3d/context-filter-report.json +1 -1
  264. package/resources/targets/workbuddy/js3d/js3d/bundle.json +25 -23
  265. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  266. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  267. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  268. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  269. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  270. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  271. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  272. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  273. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  274. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  275. package/resources/targets/workbuddy/js3d/recovery.md +1 -1
  276. package/resources/targets/workbuddy/js3d/target.json +1 -1
  277. package/resources/targets/zcode/js/context-filter-report.json +1 -1
  278. package/resources/targets/zcode/js/js/bundle.json +5 -5
  279. package/resources/targets/zcode/js/recovery.md +1 -1
  280. package/resources/targets/zcode/js/target.json +1 -1
  281. package/resources/targets/zcode/js3d/context-filter-report.json +1 -1
  282. package/resources/targets/zcode/js3d/js3d/bundle.json +25 -23
  283. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  284. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  285. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  286. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  287. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  288. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  289. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  290. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  291. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  292. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  293. package/resources/targets/zcode/js3d/recovery.md +1 -1
  294. package/resources/targets/zcode/js3d/target.json +1 -1
  295. package/vendor/craft-runtime/SOURCE.json +1 -1
  296. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  297. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  298. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  299. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  300. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  301. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  302. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  303. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  304. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  305. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  306. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  307. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  308. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  309. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  310. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  311. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  312. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  313. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  314. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  315. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  316. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  317. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  318. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  319. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  320. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  321. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  322. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  323. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  324. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  325. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  326. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  327. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  328. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  329. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  330. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  331. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  332. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  333. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  334. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  335. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  336. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  337. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  338. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  339. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  340. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  341. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  342. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  343. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  344. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  345. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  346. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  347. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  348. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  349. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  350. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  351. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  352. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  353. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  354. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  355. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  356. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  357. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  358. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  359. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  360. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  361. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  362. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  363. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  364. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  365. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  366. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  367. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  368. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  369. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  370. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  371. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  372. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  373. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  374. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  375. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  376. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  377. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  378. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  379. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  380. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  381. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  382. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  383. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  384. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  385. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  386. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  387. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  388. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  389. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  390. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  391. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  392. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  393. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  394. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  395. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  396. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  397. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  398. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  399. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  400. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp → shared-art-previews/cartoon-3f9e1acaf11be3a7ffdaac90802f591a9563724e742cc5891284ef1ee8b67ee9.webp} +0 -0
  401. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp → shared-art-previews/comic-77969cf47f2600424b5c64ef20930ba7b7081df3a5640608855913bbb99cea63.webp} +0 -0
  402. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp → shared-art-previews/cozy-e5fcba518afcf147c289b58b94a3532b30d96ab48418cc95efc1f28e9f80a90c.webp} +0 -0
  403. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp → shared-art-previews/cyber-8e6934fed1a42ed08838ac8bfaaf8f1d9b10c29c23c5843895c0791412ad3d2b.webp} +0 -0
  404. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp → shared-art-previews/horror-041ee4c51839b38a71517a4608d94fa64b860cd9d8500e5c6fa983bd00a0e7c7.webp} +0 -0
  405. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp → shared-art-previews/lowpoly-206f350338c6c1a890981e2e35ee9bc600951701d01f2e823a259c5b5c241a08.webp} +0 -0
  406. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp → shared-art-previews/paper-98dff3c4d5d493730af33e38777721c8a6c46c222e8f4d9f3b3c6f0f36fe19d1.webp} +0 -0
  407. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp → shared-art-previews/voxel-2bbe76b02f1f69059ab676eb6e2f89d0a25dd405dcab80acfc2d96f4e483098d.webp} +0 -0
@@ -2,13 +2,16 @@ import path from 'node:path';
2
2
  import { cp, mkdir, mkdtemp, readFile, writeFile, lstat, rename, rm } from 'node:fs/promises';
3
3
  import { safeProjectFile } from './asset-import.mjs';
4
4
  import { loadEngineResource } from './engines.mjs';
5
- import { verifyBundle } from './bundle-files.mjs';
5
+ import { bundleId, verifyBundle } from './bundle-files.mjs';
6
6
  import lockfile from 'proper-lockfile';
7
7
  import { atomicJson } from './request-store.mjs';
8
8
  import { hosts } from '../integrations/hosts.mjs';
9
+ import { compareVersions } from '../integrations/version-policy.mjs';
10
+ import { copyBundleArtPreviews, previewHash } from './art-previews.mjs';
11
+ import { projectArtPreviewsCurrent, retireArtPreviews } from './project-art-previews.mjs';
9
12
  import { isDeepStrictEqual } from 'node:util';
10
13
  import { localContextPath } from './local-context.mjs';
11
- import { contextLayoutSchema, schema4Hosts, nativeContextPath, inspectNativeContext, materializeNativeContext, preflightNativeContext, recoverNativeContext, recoverLegacyNativeContexts, retireLegacyContext, resolveNativeContext } from './native-context.mjs';
14
+ import { contextLayoutSchema, schema4Hosts, nativeContextPath, nativeFileHashes, inspectNativeContext, materializeNativeContext, preflightNativeContext, recoverNativeContext, recoverLegacyNativeContexts, retireLegacyContext, resolveNativeContext } from './native-context.mjs';
12
15
 
13
16
  export const contextLock = '.craft/context-lock.json';
14
17
  export async function readContextLock(project, engine) {
@@ -16,6 +19,10 @@ export async function readContextLock(project, engine) {
16
19
  try { lock = JSON.parse(await readFile(await safeProjectFile(project,contextLock),'utf8')); }
17
20
  catch (error) { if (error.code === 'ENOENT') return null; throw error; }
18
21
  if(lock?.schema>contextLayoutSchema) throw new Error('Project context layout requires a newer Craft runtime; reconnect before preparing');
22
+ if(lock?.art_previews!==undefined) {
23
+ if(!Array.isArray(lock.art_previews) || new Set(lock.art_previews).size!==lock.art_previews.length) throw new Error('Invalid project context lock art previews');
24
+ for(const name of lock.art_previews) previewHash(name);
25
+ }
19
26
  const validEntry = value => value && /^[a-f0-9]{64}$/.test(value.bundle_id) && typeof value.source_revision === 'string' && value.source_revision.length > 0;
20
27
  if (!lock || lock.engine !== engine || (lock.schema === 1 ? !validEntry(lock) : ![2,3,4,contextLayoutSchema].includes(lock.schema) ||
21
28
  !lock.compatibility || typeof lock.compatibility !== 'object' || Array.isArray(lock.compatibility) ||
@@ -32,7 +39,76 @@ export function contextBinding(lock, host, engine) {
32
39
  if (lock.schema === 1) return {status:'bound',...lock,context_host:'legacy'};
33
40
  const entry = lock.contexts[host];
34
41
  return entry ? {status:'bound',schema:lock.schema,engine,context_host:host,...entry,contexts:lock.contexts,...(lock.policy ? {policy:lock.policy} : {})}
35
- : {status:'host_unbound',schema:lock.schema,engine,context_host:host,contexts:lock.contexts,action:'Run craft_game_prepare to attach this host without changing existing host bindings'};
42
+ : {status:'host_unbound',schema:lock.schema,engine,context_host:host,contexts:lock.contexts,action:'Run craft_game_prepare to attach this host and refresh the bound project contexts'};
43
+ }
44
+
45
+ // The release index is small even when each target contains large Skills. Read and
46
+ // verify full distribution bundles only when publishing a target (or using it).
47
+ export async function planContextRelease(resources, bundle, lock, project) {
48
+ const {engine,host}=bundle;
49
+ const index=JSON.parse(await readFile(path.join(resources,'targets/index.json'),'utf8'));
50
+ if(index.schema!==1 || !index.targets) throw new Error('Invalid Craft context release index');
51
+ // Older layouts need the complete set on migration. A current layout retains
52
+ // its explicit bindings and can attach the calling host when first used.
53
+ const bound=lock?.schema===contextLayoutSchema ? new Set([...Object.keys(lock.contexts),host]) : null;
54
+ const targets={}, pendingHosts=[], conflictingHosts=[];
55
+ for(const name of Object.keys(hosts)) {
56
+ if(bound && !bound.has(name)) continue;
57
+ const target=index.targets[name+'/'+engine];
58
+ if(target?.host!==name || target.engine!==engine || !/^[a-f0-9]{64}$/.test(target.bundle_id) || !/^\d+\.\d+\.\d+$/.test(target.version))
59
+ throw new Error('Invalid Craft context release index for '+name+'/'+engine);
60
+ targets[name]=target;
61
+ const previous=lock?.contexts?.[name];
62
+ if(!previous) {
63
+ pendingHosts.push(name);
64
+ continue;
65
+ }
66
+ if(lock.schema<contextLayoutSchema && previous.version===undefined && previous.bundle_id===target.bundle_id) {
67
+ pendingHosts.push(name);
68
+ continue;
69
+ }
70
+ const order=compareVersions(target.version,previous.version);
71
+ const sameBundle=target.bundle_id===previous.bundle_id;
72
+ if(order<0 || (order===0 && !sameBundle) || (order>0 && sameBundle)) conflictingHosts.push(name);
73
+ else if(order>0 || (lock.schema>=4 && lock.active_hosts?.[nativeContextPath(name)]!==name)) pendingHosts.push(name);
74
+ }
75
+ if(targets[host].bundle_id!==bundle.id || targets[host].version!==bundle.version) throw new Error('Installed context bundle differs from the release index for '+host+'/'+engine);
76
+ // Regular status reads stop at the lock and release index. An explicit disk
77
+ // check also catches edited peer files or publication interrupted before lock commit.
78
+ const previews=new Set();
79
+ if(project) {
80
+ const names=Object.keys(targets);
81
+ const manifests=await Promise.all(names.map(async name=>{
82
+ const released=name===host ? bundle : JSON.parse(await readFile(path.join(resources,'targets',name,engine,engine,'bundle.json'),'utf8'));
83
+ if(released.host!==name || released.engine!==engine || released.version!==targets[name].version || released.id!==targets[name].bundle_id || bundleId(released)!==released.id)
84
+ throw new Error('Context bundle differs from the release index for '+name+'/'+engine);
85
+ // Only the verified release declares managed shared assets. A locally
86
+ // edited receipt must never put a user file on the retirement list.
87
+ for(const filename of released.art_previews??[]) {previewHash(filename);previews.add(filename);}
88
+ if(lock?.schema!==contextLayoutSchema || pendingHosts.includes(name) || conflictingHosts.includes(name)) return {released};
89
+ const native=await inspectNativeContext(project,name,engine,{full:true});
90
+ return {released,native};
91
+ }));
92
+ const previewChecks=new Map();
93
+ for(const [i,name] of names.entries()) {
94
+ const {released,native}=manifests[i];
95
+ if(!native) continue;
96
+ const actual=native.manifest;
97
+ if(native.integrity==='valid' && actual.bundle_id===released.id && actual.version===released.version && actual.source_revision===released.source_revision &&
98
+ actual.source_revision===lock.contexts[name].source_revision && isDeepStrictEqual(actual.files,nativeFileHashes(released)) &&
99
+ isDeepStrictEqual(actual.art_previews,released.art_previews) && await projectArtPreviewsCurrent(project,released.art_previews,previewChecks)) continue;
100
+ if(actual && (compareVersions(actual.version,targets[name].version)>0 || (actual.version===targets[name].version && actual.bundle_id!==targets[name].bundle_id))) conflictingHosts.push(name);
101
+ else pendingHosts.push(name);
102
+ }
103
+ }
104
+ let versionStatus='unknown';
105
+ if(lock?.contexts) versionStatus=pendingHosts.length ? 'update_available' : 'matches_installed';
106
+ if(conflictingHosts.length) versionStatus='requires_newer_runtime';
107
+ return {targets,pending_hosts:pendingHosts,conflicting_hosts:conflictingHosts,version_status:versionStatus,previews:[...previews].sort()};
108
+ }
109
+
110
+ export function assertContextRelease(plan) {
111
+ if(plan.conflicting_hosts.length) throw new Error('Installed context is older or has a conflicting version for '+plan.conflicting_hosts.join(', ')+'; reconnect using a compatible Craft runtime');
36
112
  }
37
113
 
38
114
  export async function checkProjectCompatibility(project, bundle) {
@@ -67,6 +143,7 @@ export class ProjectBundles {
67
143
  const from = name.startsWith(projectPrefix) ? path.join(template,name.slice(projectPrefix.length)) : path.join(resources,name);
68
144
  await cp(from,path.join(staging,name),{dereference:false});
69
145
  }
146
+ await copyBundleArtPreviews(resources,staging,bundle);
70
147
  await verifyBundle(staging,engine,bundle.id);
71
148
  try { await rename(staging,target); }
72
149
  catch (error) {
@@ -113,7 +190,7 @@ export class ProjectBundles {
113
190
  try { return await this.bindLocked(project,engine,options); }
114
191
  finally { await release(); }
115
192
  }
116
- async synchronize(project, engine, {allowAttach = false, upgrade_context, context_bundle_id, finalize, guard=async()=>{}} = {}) {
193
+ async synchronize(project, engine, {allowAttach = false, upgrade_context, context_bundle_id, begin, finalize, guard=async()=>{}} = {}) {
117
194
  const file = await safeProjectFile(project,contextLock,true);
118
195
  const release = await lockfile.lock(file,{realpath:false,stale:30000,retries:{retries:20,minTimeout:30,maxTimeout:100}});
119
196
  try {
@@ -131,34 +208,30 @@ export class ProjectBundles {
131
208
  const legacy = await verifyBundle(source.legacyResources,engine,existing.bundle_id);
132
209
  if (legacy.schema !== 1 || legacy.source_revision !== existing.source_revision) throw new Error('Legacy lock cannot select a host-specific context');
133
210
  } else if (existing && !isDeepStrictEqual(existing.compatibility,current.bundle.compatibility)) throw new Error('New context is incompatible with the project; migrate and validate its engine runtime before syncing');
134
- if (previous && previous.bundle_id !== current.bundle.id) {
135
- if (!/^\d+\.\d+\.\d+$/.test(previous.version ?? '')) throw new Error('Invalid previous context version');
136
- const difference = current.bundle.version.split('.').map((n,i)=>Number(n)-Number(previous.version.split('.')[i])).find(n=>n !== 0) ?? 0;
137
- if (difference <= 0) throw new Error('Installed context is older or has a conflicting version; reconnect using the newer Craft runtime');
138
- }
211
+ const plan=await planContextRelease(source.legacyResources,current.bundle,existing,project);
212
+ assertContextRelease(plan);
139
213
  await guard();
214
+ await begin?.();
140
215
  await recoverLegacyNativeContexts(project,existing,guard);
141
216
  const contexts = {}, candidates = new Map();
142
- // Every host has its own directory. Layout migration may need to attach the
143
- // two previously shared Buddy surfaces, but leaves other bound hosts at their
144
- // existing versions. Normal schema-5 prepares update only the selected host.
217
+ // Publish WorkBuddy first when migrating the historically shared Buddy path.
145
218
  for(const host of ['workbuddy',...Object.keys(hosts).filter(host=>host!=='workbuddy')]) {
219
+ const target=plan.targets[host];
220
+ if(!target) continue;
221
+ await recoverNativeContext(project,host,guard);
146
222
  const old=existing?.schema!==1 ? existing?.contexts?.[host] : undefined;
147
223
  const oldPath=existing?.schema>=4 ? nativeContextPath(host,existing.schema) : null;
148
- if(host!==this.host && old && oldPath===nativeContextPath(host) && existing.active_hosts?.[oldPath]===host) {
149
- const actual=existing.schema===contextLayoutSchema ? null : await inspectNativeContext(project,host,engine,{schema:existing.schema});
150
- if(!actual || (actual.manifest?.bundle_id===old.bundle_id && actual.manifest.source_revision===old.source_revision && actual.manifest.version===old.version)) {
224
+ if(host!==this.host && !plan.pending_hosts.includes(host) && old?.bundle_id===target.bundle_id && oldPath===nativeContextPath(host) && existing.active_hosts?.[oldPath]===host) {
225
+ const actual=await inspectNativeContext(project,host,engine,{schema:existing.schema});
226
+ if(actual.manifest?.bundle_id===old.bundle_id && actual.manifest.source_revision===old.source_revision && actual.manifest.version===old.version) {
151
227
  contexts[host]={...old,path:oldPath};
152
228
  continue;
153
229
  }
154
230
  }
155
- const peer=host===this.host ? current : await loadEngineResource(path.join(source.legacyResources,'targets',host,engine),engine,undefined,host);
231
+ const peer=host===this.host ? current : await loadEngineResource(path.join(source.legacyResources,'targets',host,engine),engine,target.bundle_id,host);
232
+ if(peer.bundle.version!==target.version) throw new Error('Installed context version differs from the release index for '+host+'/'+engine);
156
233
  await checkProjectCompatibility(project,peer.bundle);
157
234
  if(!isDeepStrictEqual(peer.bundle.compatibility,current.bundle.compatibility)) throw new Error('Installed host contexts have incompatible engine contracts');
158
- if(old && old.bundle_id!==peer.bundle.id) {
159
- const difference=peer.bundle.version.split('.').map((n,i)=>Number(n)-Number(old.version?.split('.')[i])).find(n=>n!==0)??0;
160
- if(!Number.isFinite(difference)||difference<=0) throw new Error('Installed context is older or has a conflicting version for '+host);
161
- }
162
235
  candidates.set(host,peer);
163
236
  }
164
237
  await guard();
@@ -176,7 +249,6 @@ export class ProjectBundles {
176
249
  const installed={};
177
250
  const legacyBinding=legacyBuddy?.manifest;
178
251
  for(const [host,peer] of candidates) {
179
- await recoverNativeContext(project,host,guard);
180
252
  await preflightNativeContext(project,peer,{legacyBinding:host==='codebuddy' ? legacyBinding : undefined});
181
253
  }
182
254
  // Publish WorkBuddy before repurposing an old WorkBuddy-owned .codebuddy.
@@ -192,6 +264,8 @@ export class ProjectBundles {
192
264
  contexts:orderedContexts,
193
265
  active_hosts:Object.fromEntries(Object.entries(orderedContexts).map(([host,value])=>[value.path,host])),
194
266
  ...(existing?.schema === 1 ? {legacy_binding:existing} : existing?.legacy_binding ? {legacy_binding:existing.legacy_binding} : {})};
267
+ const previews=plan.previews;
268
+ if(previews.length) lock.art_previews=previews;
195
269
  const verifyPublished=async()=>{
196
270
  for(const peer of candidates.values()) await resolveNativeContext(project,peer,lock);
197
271
  };
@@ -201,6 +275,7 @@ export class ProjectBundles {
201
275
  const changed = JSON.stringify(existing)!==JSON.stringify(lock);
202
276
  await guard();
203
277
  await verifyPublished();
278
+ if(existing?.art_previews) await retireArtPreviews(project,existing.art_previews,previews,guard);
204
279
  if (changed) await atomicJson(file,lock);
205
280
  const migrated=[];
206
281
  if(existing?.schema===3) for(const [host,value] of Object.entries(existing.contexts)) {
@@ -208,6 +283,7 @@ export class ProjectBundles {
208
283
  if(backup) migrated.push({host,backup});
209
284
  }
210
285
  const sync = {policy:'follow-installed',location:'project',status:changed || local.materialized ? 'updated' : 'current',
286
+ updated_hosts:Object.keys(installed).filter(host=>installed[host].materialized),
211
287
  version:current.bundle.version,bundle_id:current.bundle.id,directory:local.selected.resources,
212
288
  ...(existing?.schema===4 ? {layout_migration:{from:4,to:contextLayoutSchema,previous_active_hosts:existing.active_hosts}} : {}),
213
289
  ...(previous && previous.bundle_id !== current.bundle.id ? {previous_bundle_id:previous.bundle_id} : {}),...(local.backup ? {backup:local.backup} : {}),...(migrated.length ? {migrated} : {})};
@@ -9,8 +9,9 @@ import { hosts, clientIde, projectSkillPath, hostRecoveryEntry } from '../integr
9
9
  const start = '<!-- craft-mcp:project:start -->';
10
10
  const end = '<!-- craft-mcp:project:end -->';
11
11
  // Independent of engine bundle versions: generated recovery instructions evolve too.
12
- export const entryPolicyVersion = 13;
12
+ export const entryPolicyVersion = 15;
13
13
  const hash = value => createHash('sha256').update(value).digest('hex');
14
+ const instanceGuide = '先读取已有的 `.craft/project-install.json`。若宿主暴露多组 Craft 工具,用各服务的只读 `craft_game_info` 核对工作区是当前项目父目录、平台和渠道符合清单,再按项目名核对绝对路径与引擎。记录唯一匹配的工具命名空间和 server_id;后续制作、上传、检查更新和重连核验沿用该服务。多个服务都匹配时请用户选定,缺少匹配时按项目接入指引处理。';
14
15
  const turnUpdateGuide = '进入 Craft 工作流后,每条用户消息使用新的检查 key。同一轮调用支持 `update_request_key` 的业务工具时传这个 key,工具会顺带检查;本轮仅答疑、编辑本地文件或只用轮询等工具时,补一次只读 `craft_update_check`(request_key=本轮 key,已有工程传 name)。制作时,业务回执的 update_notice 或显式检查返回 update_available=true 且 automatic_update_enabled=true,就用同一 key 调用 `craft_update`(mode=auto,已有工程传 name)。纯查看只检查,未发现更新直接继续。同一目标版本待重连时只提示一次。';
15
16
  const normalizeLines = value => value.replace(/\r\n/g,'\n');
16
17
  const uploadGuide = '上传游戏、更新云端版本或发布时,使用 Craft MCP。纯上传用 `craft_game_check` 的 `purpose="upload"` 构建并冻结源码和 dist,安全检查通过后用 `craft_game_upload` 上传。更新原项目时先用 `craft_game_upload_status({name})` 核对云端绑定,上传传 `expected_appid`。收到 `draft_ready` 后报告版本、appid 和项目链接,由用户进入项目页提审。遇到阻塞时报告工具名和原始错误,改用 Computer Use、GM 或网页编辑器上传须另获用户同意。';
@@ -24,10 +25,10 @@ export function projectContextPaths(project, ide = 'generic', schema = 5) {
24
25
 
25
26
  function recovery(name, engine) {
26
27
  return `Craft 工程名:\`${name}\`;引擎:\`${engine}\`。保持已有引擎与用户源码。\n\n`
27
- + turnUpdateGuide + '\n\n'
28
+ + instanceGuide + '\n\n' + turnUpdateGuide + '\n\n'
28
29
  + '先读 `SPEC/PROGRESS.md` 和已有的 SPEC 设计文件,核对已完成玩法、待办及最近验收;缺少记录时检查源码与工具回执,不根据旧聊天猜测。\n\n'
29
30
  + `继续本工程前调用 \`craft_game_info({"name":"${name}"})\`,核对返回的 project 是当前目录、context_binding.status 为 bound。读取返回的 \`context.workflow\`、\`context.engine.entrypoint\` 和 \`context.engine.skills_index\`;按索引 description 选择技能,相对于 context.engine.directory 读取 entrypoint,再按需读取引用。\n\n`
30
- + `MCP 的 workspace 是游戏父目录,工程位于 \`workspace/${name}\`,不自动跟随宿主当前目录。若不匹配,先在宿主 MCP 设置中将 \`--workspace\` 参数(优先)或 \`CLIENT_WORKSPACE_ROOT\` 指向当前游戏的父目录并重连;不要在错误目录创建同名工程。\n\n`
31
+ + `MCP 的 workspace 是游戏父目录,工程位于 \`workspace/${name}\`,不自动跟随宿主当前目录。若不匹配,先通过项目接入检查确认正确连接,保留其他工作区及其工程。\n\n`
31
32
  + `迁移目录或首次恢复时若提示尚未 prepare,确认 workspace 后调用 \`craft_game_prepare({"name":"${name}","engine":"${engine}","mode":"resume","request_key":"resume-unique-key"})\` 并轮询任务完成;已有合法工程只会被接管,不重置模板。目录更名后使用当前目录名(须符合工具的英文 name 规则)。\n\n`
32
33
  + '项目以 `.craft/context-lock.json` 绑定引擎上下文版本,随项目保存;实际路径每次通过工具查询。缺少绑定时由 prepare 核验后建立,缺包或不兼容时按诊断恢复匹配版本,不删除锁文件来绕过检查。上下文、模板和技能脚本由 Craft 版本包提供,不复制到游戏中;MCP 未连接时先连接项目使用的 Craft 服务。\n\n'
33
34
  + '验收使用 `craft_game_check` → `craft_game_review` → `craft_game_deliver`;宿主按返回命令启动预览,再核对当前快照已运行。构建成功不代表预览自动开启。\n\n'
@@ -91,11 +92,11 @@ function mergeRuleMetadata(original,prefix) {
91
92
  function projectConnectionGuide(host) {
92
93
  const target = host === 'generic' ? '<当前宿主>' : host;
93
94
  return '首次接手或切换 Agent 时,先通过当前宿主实际提供的工具发现能力查找 Craft 工具;工具可能延迟暴露或带命名空间前缀,不能因裸工具名不存在、resources 为空就判断未安装。项目文件和 Skill 可用也不代表 MCP 已连接。\n\n'
94
- + '无论是否已连接,都先读取存在的 `.craft/project-install.json` 并与实际连接核对;实际程序低于 minimum_mcp_version、平台或工作目录不符时先处理接入,不能直接开始制作。\n\n'
95
+ + instanceGuide + ' 实际程序低于 minimum_mcp_version 时先处理版本要求。\n\n'
95
96
  + '若没有可用的 Craft 连接,读取 `.craft/project-install.json`,确认 package_name、minimum_mcp_version、registry、channel、platform 和 engine。使用当前宿主终端执行下面的项目接入检查,将占位值替换为文件中的值及当前游戏绝对目录,并按终端规则引用参数:\n\n'
96
97
  + '```text\nnpx -y --registry "<registry>" "@craft_eco/craft-mcp@<minimum_mcp_version>" project-setup --project "<当前游戏绝对目录>" --ide '+target+'\n```\n\n'
97
98
  + 'TRAE 和国际版 Qoder IDE 的接入命令需加 `--host-config "<宿主 MCP 设置界面打开的配置文件绝对路径>"`;不要猜测配置路径。TRAE CN 另加 `--trae-region cn`,国际版使用 global。已有安装检查、更新及恢复沿用相同路径和地区。\n\n'
98
- + '检查命令只读;仅返回 `missing_installation` 且用户正在请求继续制作时,在同一命令末尾加 `--install`,自动下载并标准安装到当前宿主。所选包必须满足项目最低 MCP 版本;随后按已有更新策略检查渠道。安装包尚未发布或网络/终端权限不可用时报告准确原因;用户提供本地候选包时可用该包的同一 CLI,不降低项目版本。\n\n'
99
+ + '检查命令只读。返回 `instance_required` 或 `multiple_installations` 时请用户选定服务,以 `--instance <服务名>` 重新检查。仅返回 `missing_installation` 且用户正在请求继续制作时,在同一命令末尾加 `--install`;非 stable 渠道新装须由用户明确选择命名实例。所选包必须满足项目最低 MCP 版本;随后按已有更新策略检查渠道。安装包尚未发布或网络/终端权限不可用时报告准确原因;用户提供本地候选包时可用该包的同一 CLI,不降低项目版本。\n\n'
99
100
  + '已有配置被禁用、范围不匹配、旧版或连接失败时按检查结果修复,不当作缺失重复安装,不自行启用用户禁用的服务或覆盖其他工作区/平台。`--workspace` 必须是当前游戏父目录,不跟随默认目录。旧项目缺少安装信息时,先使用已连接且目录/平台明确的 Craft 完成 resume 以补齐;无可靠来源则询问缺失的平台/版本信息,不猜默认环境。\n\n'
100
101
  + '安装回执和 doctor 只证明配置及独立探测。等待宿主实际加载 Craft;需要时提示重连或重启,只有宿主提示信任/登录时由用户处理。连接后必须由当前会话调用 `craft_game_info`,核对实际 version/build_id、host、workspace、platform、project 和原引擎,标准安装确认 active_verified 后再 prepare(resume)。不要使用另一个终端探测代替当前会话验收,不重建已有工程。纯查看不安装或更新,打开文件夹本身不触发安装。\n\n';
101
102
  }
@@ -118,12 +119,12 @@ function recoveryEntries(name, engine, ide = 'generic', isolated = false) {
118
119
  const label = engine === 'js3d' ? '3D / Three.js' : '2D / Phaser';
119
120
  const desiredSkill = `---\nname: craft-project\ndescription: 恢复、修改、验收或预览当前 Craft ${label} 游戏 ${name},通过 Craft MCP 上传游戏、更新云端版本或发布游戏。Resume or upload this existing Craft game.\n---\n\n`
120
121
  + start + '\n# 继续当前 Craft 游戏\n\n'
121
- + '首次接手先读根 AGENTS.md 的接入流程,确认当前宿主及项目安装信息;缺失 MCP 时先检查、按需安装并核验当前会话连接,再调用下面的工具。不要因延迟工具尚未发现而误判未安装。\n\n'
122
+ + '首次接手先读根 AGENTS.md 的接入流程,确认当前宿主及项目安装信息;缺失 Craft MCP 时先检查、按需安装并核验当前会话连接,再调用下面的工具。不要因延迟工具尚未发现而误判未安装。\n\n'
122
123
  + (isolated ? '本入口适用于 '+host+',project-setup 使用 `--ide '+host+'`;当前 Agent 不属于该宿主时按根路由读取自身入口。\n\n' : '')
123
- + `1. 读取项目根 \`AGENTS.md\`,确认工程 \`${name}\` 和引擎 \`${engine}\`。\n`
124
+ + `1. 读取项目根 \`AGENTS.md\`,确认工程 \`${name}\` 和引擎 \`${engine}\`。` + instanceGuide + '\n'
124
125
  + turnUpdateGuide + '\n\n'
125
126
  + (isolated ? '2. 当前连接仍持有本工程有效 work 时沿用 work_id/context_revision。新会话先调用只读 `craft_game_info` 核对项目和工作区。核对实际版本后,尚无有效 work 且可继续时调用 `craft_game_prepare`(mode=resume,同一 request_key)。轮询完成并保留 work_id/context_revision,重新读取本 Skill 相邻的 [引擎入口](../../AGENTS.md)、[恢复说明](../../recovery.md)、[工作流](../../workflow.md) 和 [技能索引](../index.json),按任务读取当前宿主 skills/ 下的正文。\n' : '2. 按根 AGENTS.md 查询 `craft_game_info`,读取返回的引擎入口、工作流与技能索引。\n')
126
- + (isolated ? ' 新版安装后等待下次 MCP 启动或用户重连。确认实际 version、build_id、active_verified 后,prepare(resume) 更新当前宿主、原引擎的上下文和 Skill,再重新读取正文。\n' : '')
127
+ + (isolated ? ' 新版安装后等待下次 MCP 启动或用户重连。确认实际 version、build_id、active_verified 后,prepare(resume) 按游戏原引擎更新各已绑定宿主有变化的官方 Skill。完成后重新读取本宿主的索引和正文。\n' : '')
127
128
  + (isolated ? ' 不主动重载或中断工作;按 connection_handoff 提示用户,先保存进度并 release。只重试明确未开始的 prepare,不重放结果不明的操作。\n' : '')
128
129
  + '3. ' + uploadGuide + (isolated ? ' 按本宿主[上传与发布说明](../../knowledge/Publishing.md)执行。' : '') + '\n'
129
130
  + '4. 纯查看只读现有文件,不 prepare。制作工具带 work_id;需要验收玩法或交付本地预览时再看图、启动预览。等待后台任务结束后调用 craft_game_release(name,work_id)。重试准备复用原 request_key,下一轮制作使用新 key;resume 不安装依赖或重建模板。\n'
@@ -44,11 +44,12 @@ export async function readProjectInstall(project, { required = false } = {}) {
44
44
  return manifest;
45
45
  }
46
46
 
47
- export function assertProjectInstallConnection(manifest, { engine, version, platform, registry, channel }) {
47
+ export function assertProjectInstallConnection(manifest, { engine, version, platform, registry, channel, requireKnownChannel = false }) {
48
48
  if (manifest.engine !== engine) throw new Error('Project installation engine differs from the existing game; keep its original engine');
49
49
  if (compareVersions(version, manifest.minimum_mcp_version) < 0) throw new Error('Project requires Craft MCP >= ' + manifest.minimum_mcp_version + '; the current runtime cannot downgrade its installation contract');
50
50
  if (httpsUrl(platform, { origin: true }) !== manifest.platform) throw new Error('Project installation platform differs from the current Craft connection; reconnect to the project platform before resuming');
51
51
  if (registry !== undefined && httpsUrl(registry) !== manifest.registry) throw new Error('Project installation registry differs from the current Craft installation; preserve the project source and reconnect with its registry');
52
+ if (requireKnownChannel && !channel && manifest.channel !== 'stable') throw new Error('This project requires a verified Craft installation for its configured channel: ' + manifest.channel);
52
53
  if (channel !== undefined && channel !== manifest.channel) throw new Error('Project installation channel differs from the current Craft installation; preserve the project source and reconnect with its channel');
53
54
  }
54
55
 
@@ -8,7 +8,7 @@ import { assetConfig, safeProjectFile } from './asset-import.mjs';
8
8
  import { engineDefinition } from './engines.mjs';
9
9
  import { prepareProjectContext, projectContextPaths } from './project-context.mjs';
10
10
  import { clientIde } from '../integrations/hosts.mjs';
11
- import { ProjectBundles, readContextLock, contextBinding, checkProjectCompatibility } from './project-bundles.mjs';
11
+ import { ProjectBundles, readContextLock, contextBinding, checkProjectCompatibility, planContextRelease, assertContextRelease } from './project-bundles.mjs';
12
12
  import { contextLayoutSchema, inspectNativeContext, nativeContextPath, nativeSelection } from './native-context.mjs';
13
13
  import { inspectContextState, beginContextPreparation, finishContextPreparation } from './context-state.mjs';
14
14
  import { readProjectInstall, planProjectInstall, ensureProjectInstall, projectInstallFile } from './project-install.mjs';
@@ -86,11 +86,9 @@ export class Projects {
86
86
  try {lock=await readContextLock(project,engine);} catch(error) {invalid=error.message;}
87
87
  const binding=invalid ? {status:'invalid',reason:invalid} : contextBinding(lock,this.ide,engine);
88
88
  const entry=lock?.contexts?.[this.ide];
89
- let version_status='unknown';
90
- if(entry) {
91
- const difference=(entry.version??'').split('.').map((n,i)=>Number(n)-Number(installed.bundle.version?.split('.')[i])).find(n=>n!==0)??0;
92
- version_status=entry.bundle_id===installed.bundle.id ? 'matches_installed' : difference>0 ? 'requires_newer_runtime' : difference<0 ? 'update_available' : 'unknown';
93
- }
89
+ let release;
90
+ if(installed.host && !invalid) try {release=await planContextRelease(installed.legacyResources,installed.bundle,lock,full ? project : undefined);} catch(error) {invalid=error.message;}
91
+ const version_status=release?.version_status??'unknown';
94
92
  const layoutSchema=lock?.schema===4 ? 4 : contextLayoutSchema;
95
93
  const native=installed.host ? await inspectNativeContext(project,this.ide,engine,{full,schema:layoutSchema}) : {integrity:'unchecked'};
96
94
  let incompatible;
@@ -103,7 +101,7 @@ export class Projects {
103
101
  if(invalid) preparation={status:'blocked',reason:invalid};
104
102
  else if(incompatible) preparation={status:'blocked',reason:incompatible};
105
103
  else if(installation.status==='blocked') preparation={status:'blocked',reason:installation.reason};
106
- else if(version_status==='requires_newer_runtime') preparation={status:'blocked',reason:'Connect a newer Craft runtime; context cannot be downgraded'};
104
+ else if(version_status==='requires_newer_runtime') preparation={status:'blocked',reason:'Connect a compatible Craft runtime; context cannot be downgraded for '+release.conflicting_hosts.join(', ')};
107
105
  else if(lock?.schema===4 && !['blocked','recovery_required'].includes(state.status)) preparation={status:'migration_required',reason:'context_layout_migration_required',from_schema:4,to_schema:contextLayoutSchema};
108
106
  else if(!['recovery_required','blocked'].includes(state.status) && (version_status!=='matches_installed' || native.integrity==='invalid' || native.integrity==='modified' || (installed.host && lock?.active_hosts?.[nativeContextPath(this.ide)]!==this.ide) || !record)) preparation={status:'required',reason:!record ? 'registration_required' : 'Prepare installed context and recovery entries before editing'};
109
107
  else if(installation.changed && !['recovery_required','blocked'].includes(state.status)) preparation={status:'required',reason:'Project installation information needs preparation'};
@@ -111,7 +109,7 @@ export class Projects {
111
109
  if(!invalid) try {if(JSON.stringify(await readContextLock(project,engine))!==JSON.stringify(lock)) preparation={status:'updating',reason:'Context commit changed during inspection; query again'};} catch {preparation={status:'updating',reason:'Context commit changed during inspection; query again'};}
112
110
  return {name,project,engine,registration_required:!record,context_binding:binding,
113
111
  project_install:{file:projectInstallFile,status:installation.status,...(installation.manifest?{manifest:installation.manifest}:{}),...(installation.reason?{reason:installation.reason}:{})},
114
- version_status,integrity:{status:native.integrity,...(native.reason ? {reason:native.reason} : {})},preparation,
112
+ version_status,...(release?{pending_hosts:release.pending_hosts,conflicting_hosts:release.conflicting_hosts}:{}),integrity:{status:native.integrity,...(native.reason ? {reason:native.reason} : {})},preparation,
115
113
  project_context:{...projectContextPaths(project,this.ide,layoutSchema),...(state.discovery?.skills?.[this.ide] ? {discovery:{native_status:state.discovery.native_status,...state.discovery.skills[this.ide]}} : {})},
116
114
  ...(installed.host ? {context_layout:{schema:lock?.schema??null,target_schema:contextLayoutSchema,status:lock?.schema===4?'migration_required':lock?.schema===contextLayoutSchema?'current':'unbound',directory:nativeContextPath(this.ide,layoutSchema),target_directory:nativeContextPath(this.ide)},
117
115
  context:{...nativeSelection(project,installed,{schema:layoutSchema}).context,target:{host:this.ide,engine,version:entry?.version,bundle_id:entry?.bundle_id}}} : {})};
@@ -165,11 +163,15 @@ export class Projects {
165
163
  const ready=await inspectContextState(project,lock,{full:true});
166
164
  if(ready.status==='blocked') throw new Error(ready.reason);
167
165
  let selected;
168
- if(ready.status==='ready' && !installation.changed) {try {selected=await this.bundles.resolve(project,engine,lock);} catch { /* Explicit prepare repairs or reports the precise compatibility error below. */ }}
169
- if(selected) sync={lock,selected,context_revision:ready.context_revision,project_context:{...projectContextPaths(project,this.ide),...(ready.discovery?.skills?.[this.ide] ? {discovery:{native_status:ready.discovery.native_status,...ready.discovery.skills[this.ide]}} : {})},sync:{policy:'follow-installed',location:'project',status:'current',version:selected.bundle.version,bundle_id:selected.bundle.id,directory:selected.resources}};
166
+ if(ready.status==='ready' && !installation.changed) {
167
+ const source=this.engines[engine];
168
+ const release=await planContextRelease(source.legacyResources,source.bundle,lock,project);
169
+ assertContextRelease(release);
170
+ if(release.version_status==='matches_installed') {try {selected=await this.bundles.resolve(project,engine,lock);} catch { /* Explicit prepare repairs or reports the precise compatibility error below. */ }}
171
+ }
172
+ if(selected) sync={lock,selected,context_revision:ready.context_revision,project_context:{...projectContextPaths(project,this.ide),...(ready.discovery?.skills?.[this.ide] ? {discovery:{native_status:ready.discovery.native_status,...ready.discovery.skills[this.ide]}} : {})},sync:{policy:'follow-installed',location:'project',status:'current',updated_hosts:[],version:selected.bundle.version,bundle_id:selected.bundle.id,directory:selected.resources}};
170
173
  else {
171
- await beginContextPreparation(project,this.ide);
172
- sync=await this.bundles.synchronize(project,engine,{...options,allowAttach:true,guard,finalize:async (lock,verifyPublished)=>{
174
+ sync=await this.bundles.synchronize(project,engine,{...options,allowAttach:true,guard,begin:()=>beginContextPreparation(project,this.ide),finalize:async (lock,verifyPublished)=>{
173
175
  await guard();
174
176
  await saveInstallation();
175
177
  const project_context=await prepareProjectContext(project,name,engine,this.ide,true,guard);
@@ -211,7 +213,7 @@ export async function fingerprint(project) {
211
213
  if (skip.has(entry.name)) continue;
212
214
  const file = path.join(dir,entry.name), key = relative + '/' + entry.name;
213
215
  // Version history is not a game input. The active sync record below is fingerprinted.
214
- if (['/.craft/contexts','/.craft/context-backups'].includes(key)) continue;
216
+ if (['/.craft/contexts','/.craft/context-backups','/.craft/art-previews'].includes(key)) continue;
215
217
  if (entry.isSymbolicLink()) throw new Error('Source symbolic links are not supported: ' + key);
216
218
  if (entry.isDirectory()) { await walk(file,key); continue; }
217
219
  if (!entry.isFile()) throw new Error('Unsupported source file: ' + key);
@@ -1,9 +1,10 @@
1
1
  import { parse, stringify } from 'smol-toml';
2
2
  import { isDeepStrictEqual } from 'node:util';
3
- import { readDshConfig, dshRegistrations, mergeDshConfig } from './dsh-config.mjs';
3
+ import { readDshConfig, dshRegistrations, mergeDshConfig, removeDshConfig } from './dsh-config.mjs';
4
4
  import { hasCraftConnectionIdentity } from './registration-identity.mjs';
5
- import { readJsonc, updateJsoncEntry } from './jsonc-config.mjs';
6
- import { readOpenCodeConfig, openCodeConfig, openCodeRegistrations, mergeOpenCodeConfig } from './opencode-config.mjs';
5
+ import { readJsonc, updateJsonc, updateJsoncEntry } from './jsonc-config.mjs';
6
+ import { readOpenCodeConfig, openCodeConfig, openCodeRegistrations, mergeOpenCodeConfig, removeOpenCodeConfig } from './opencode-config.mjs';
7
+ import { validateServerId } from './instance.mjs';
7
8
 
8
9
  function object(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
9
10
  function serverTable(config, ide) { return ide === 'zcode' ? config.mcp?.servers : config[ide === 'codex' ? 'mcp_servers' : 'mcpServers']; }
@@ -112,11 +113,37 @@ function sections(text) {
112
113
  return found.map((section, i) => ({ ...section, end: found[i + 1]?.start ?? text.length }));
113
114
  }
114
115
 
115
- export function mergeConfig(text, ide, connection, { previousName = 'craft', enable = true } = {}) {
116
- if (ide === 'dsh') return mergeDshConfig(text, connection, { previousName, enable });
117
- if (ide === 'opencode') return mergeOpenCodeConfig(text, connection, { previousName, enable });
116
+ function withoutTomlServer(text, before, previousName) {
117
+ const owned = sections(text).filter(({ keys }) => keys[0] === 'mcp_servers' && keys[1] === previousName);
118
+ if (before.mcp_servers?.[previousName] && !owned.length) throw new Error('Inline/dotted Craft TOML entry: move it to [mcp_servers.' + previousName + '] before editing; config was preserved');
119
+ let kept = '', from = 0;
120
+ for (const section of owned) { kept += text.slice(from, section.start); from = section.end; }
121
+ return kept + text.slice(from);
122
+ }
123
+
124
+ export function removeConfig(text, ide, serverId = 'craft') {
125
+ validateServerId(serverId);
126
+ if (ide === 'dsh') return removeDshConfig(text, serverId);
127
+ if (ide === 'opencode') return removeOpenCodeConfig(text, serverId);
118
128
  const before = readConfig(text, ide), servers = serverTable(before, ide);
119
- if (previousName !== 'craft' && servers?.craft) throw new Error('Craft installation conflicts with an existing craft registration');
129
+ if (!servers || !Object.hasOwn(servers, serverId)) return text;
130
+ const remaining = { ...servers };
131
+ delete remaining[serverId];
132
+ const expected = withServerTable(before, ide, remaining);
133
+ if (ide === 'qwen') return updateJsonc(text, [{ path: ['mcpServers', serverId], value: undefined }]);
134
+ if (ide !== 'codex') return JSON.stringify(expected, null, 2) + '\n';
135
+ const output = withoutTomlServer(text, before, serverId);
136
+ if (!Object.keys(remaining).length && !parse(output).mcp_servers) delete expected.mcp_servers;
137
+ if (!isDeepStrictEqual(parse(output), parse(stringify(expected)))) throw new Error('TOML removal changed unrelated settings; config was preserved');
138
+ return output;
139
+ }
140
+
141
+ export function mergeConfig(text, ide, connection, { serverId = 'craft', previousName = serverId, enable = true } = {}) {
142
+ validateServerId(serverId);
143
+ if (ide === 'dsh') return mergeDshConfig(text, connection, { serverId, previousName, enable });
144
+ if (ide === 'opencode') return mergeOpenCodeConfig(text, connection, { serverId, previousName, enable });
145
+ const before = readConfig(text, ide), servers = serverTable(before, ide);
146
+ if (previousName !== serverId && servers?.[serverId]) throw new Error('Craft installation conflicts with an existing ' + serverId + ' registration');
120
147
  const previous = servers?.[previousName] ?? {};
121
148
  if (!object(previous)) throw new Error('Invalid craft server entry');
122
149
  // Preserve host-specific options and user environment; replace only connection identity.
@@ -128,7 +155,7 @@ export function mergeConfig(text, ide, connection, { previousName = 'craft', ena
128
155
  if (ide === 'claude') { delete next.enabled; delete next.timeoutMs; delete next.startupTimeoutMs; }
129
156
  else {
130
157
  next.enabled = true;
131
- if (ide === 'zcode') { delete next.startupTimeoutMs; next = validateZcodeServer(next, 'craft'); }
158
+ if (ide === 'zcode') { delete next.startupTimeoutMs; next = validateZcodeServer(next, serverId); }
132
159
  else { delete next.type; delete next.timeoutMs; delete next.environment_id; next.transport = 'stdio'; next.executor = 'local'; }
133
160
  }
134
161
  } else if (['qwen', 'qoder', 'qoder-cn', 'comate', 'trae'].includes(ide)) {
@@ -140,22 +167,18 @@ export function mergeConfig(text, ide, connection, { previousName = 'craft', ena
140
167
  if (Object.hasOwn(previous, key)) next[key] = previous[key]; else delete next[key];
141
168
  }
142
169
  const normalizedNext = ide === 'codex' ? parse(stringify({ value: next })).value : next;
143
- if (previousName === 'craft' && isDeepStrictEqual(previous, normalizedNext)) return text;
144
- const nextServers = { ...servers, craft: next };
145
- if (previousName !== 'craft') delete nextServers[previousName];
170
+ if (previousName === serverId && isDeepStrictEqual(previous, normalizedNext)) return text;
171
+ const nextServers = { ...servers, [serverId]: next };
172
+ if (previousName !== serverId) delete nextServers[previousName];
146
173
  const expected = withServerTable(before, ide, nextServers);
147
174
  if (ide === 'qwen') {
148
- const output = updateJsoncEntry(text, ['mcpServers'], 'craft', servers?.[previousName], next, { previousName });
175
+ const output = updateJsoncEntry(text, ['mcpServers'], serverId, servers?.[previousName], next, { previousName });
149
176
  if (!isDeepStrictEqual(readConfig(output, ide), expected)) throw new Error('Qwen merge changed unrelated settings; config was preserved');
150
177
  return output;
151
178
  }
152
179
  if (ide !== 'codex') return JSON.stringify(expected, null, 2) + '\n';
153
- const owned = sections(text).filter(({ keys }) => keys[0] === 'mcp_servers' && keys[1] === previousName);
154
- if (before.mcp_servers?.[previousName] && !owned.length) throw new Error('Inline/dotted craft TOML entry: move it to [mcp_servers.craft] before installing; config was preserved');
155
- let kept = '', from = 0;
156
- for (const section of owned) { kept += text.slice(from, section.start); from = section.end; }
157
- kept += text.slice(from);
158
- const output = kept + (kept.endsWith('\n') || !kept ? '' : '\n') + '\n' + stringify({ mcp_servers: { craft: next } });
180
+ const kept = withoutTomlServer(text, before, previousName);
181
+ const output = kept + (kept.endsWith('\n') || !kept ? '' : '\n') + '\n' + stringify({ mcp_servers: { [serverId]: next } });
159
182
  // This also rejects unsupported inline parent tables without changing the user's file.
160
183
  if (!isDeepStrictEqual(parse(output), parse(stringify(expected)))) throw new Error('TOML merge changed unrelated settings; config was preserved');
161
184
  return output;
@@ -7,29 +7,38 @@ import { optionalFile } from './files.mjs';
7
7
  import { readInstallation } from './installation-state.mjs';
8
8
  import { verifyLauncher } from './fixed-launcher.mjs';
9
9
  import { assertHostConfigScope } from './host-config-scope.mjs';
10
+ import { registrationsForInstance, validateServerId } from './instance.mjs';
11
+ import { assertDshSharedScope } from './dsh-config.mjs';
10
12
 
11
13
  // Optional expert/connector declarations use this resolver, never a second
12
14
  // installer or an unmanaged business runtime. No host settings are written.
13
- export async function installedConnection(ide, { home = os.homedir(), codexHome = process.env.CODEX_HOME, hostOptions = hostEnvironment(), env = process.env } = {}) {
15
+ export async function installedConnection(ide, { home = os.homedir(), codexHome = process.env.CODEX_HOME, hostOptions = hostEnvironment(), env = process.env, serverId = 'craft' } = {}) {
16
+ validateServerId(serverId);
14
17
  const targets = installTargets(ide);
15
18
  if (targets.length !== 1) throw new Error('connect requires exactly one host');
16
- const host = targets[0], paths = hostPaths(home, host, codexHome, hostOptions);
17
- await assertHostConfigScope(paths.config,host,paths.configPeers);
19
+ const host = targets[0], paths = hostPaths(home, host, codexHome, { ...hostOptions, serverId });
20
+ await assertHostConfigScope(paths.config,host,paths.configPeers,serverId);
21
+ assertDshSharedScope(paths,serverId);
18
22
  const registrations = craftRegistrations(await optionalFile(paths.config) ?? '', host);
19
- if (registrations.length !== 1) throw new Error('Run craft-mcp install --ide ' + host + ' first; connect requires one standard Craft installation');
20
- const connection = registrations[0].connection, file = connection.env?.CRAFT_INSTALLATION_FILE;
23
+ const selected = registrationsForInstance(registrations, serverId);
24
+ if (selected.length > 1) throw new Error('Multiple Craft registrations match the selected instance: ' + serverId);
25
+ const connection = selected[0]?.connection;
26
+ if (!connection) throw new Error('Run craft-mcp install --ide ' + host + ' first; the selected Craft installation is missing: ' + serverId);
27
+ const file = connection.env?.CRAFT_INSTALLATION_FILE;
21
28
  const state = await readInstallation(file);
22
- if (state.host !== host || path.resolve(state.config) !== path.resolve(paths.config)) throw new Error('Craft installation belongs to another host scope');
29
+ if (state.host !== host || state.server_id !== serverId || path.relative(state.config, paths.config) !== '' ||
30
+ (connection.env.CRAFT_SERVER_ID ?? 'craft') !== serverId) throw new Error('Craft installation belongs to another host or server scope');
23
31
  if (connection.disabled === true || connection.enabled === false || connection.enable === false) throw new Error('Craft is disabled in the host; enable the existing installation first');
24
32
  await verifyLauncher(state, file, connection);
25
- for (const [key, expected] of Object.entries({ CRAFT_WEB_URL: state.platform, CLIENT_WORKSPACE_ROOT: state.workspace, CRAFT_CLIENT_IDE: host })) {
33
+ for (const [key, expected] of Object.entries({ CRAFT_WEB_URL: state.platform, CLIENT_WORKSPACE_ROOT: state.workspace, CRAFT_CLIENT_IDE: host, CRAFT_SERVER_ID: serverId })) {
34
+ if ((connection.env[key] ?? (key === 'CRAFT_SERVER_ID' ? 'craft' : undefined)) !== expected) throw new Error('Craft registration scope differs from its installation: ' + key);
26
35
  if (env[key] && env[key] !== expected) throw new Error('Craft connector scope differs from the standard installation: ' + key);
27
36
  }
28
37
  return { command: process.execPath, args: [state.launcher.entry, '--workspace', state.workspace], env: { ...env, ...connection.env }, installation: file };
29
38
  }
30
39
 
31
40
  export async function connectInstalledHost(ide, options = {}) {
32
- const connection = await installedConnection(ide, {hostOptions:hostCommandOptions({ide,...options})});
41
+ const connection = await installedConnection(ide, {serverId: options.instance, hostOptions:hostCommandOptions({ide,...options})});
33
42
  const child = spawn(connection.command, connection.args, { env: connection.env, stdio: 'inherit', shell: false, windowsHide: true });
34
43
  const stop = () => child.kill('SIGTERM');
35
44
  process.once('SIGINT', stop); process.once('SIGTERM', stop);
@@ -41,7 +50,7 @@ export async function runConnectCommand(args) {
41
50
  const options={};
42
51
  for(let i=1;i<args.length;i+=2) {
43
52
  const key=args[i]?.replace(/^--/,'');
44
- if(!['--ide','--host-config','--trae-region'].includes(args[i]) || !args[i+1] || Object.hasOwn(options,key)) throw new Error('Use connect --ide <host> [--host-config ABS] [--trae-region global|cn]');
53
+ if(!['--ide','--instance','--host-config','--trae-region'].includes(args[i]) || !args[i+1] || Object.hasOwn(options,key)) throw new Error('Use connect --ide <host> [--instance <server-id>] [--host-config ABS] [--trae-region global|cn]');
45
54
  options[key]=args[i+1];
46
55
  }
47
56
  await connectInstalledHost(options.ide,options);
@@ -1,36 +1,37 @@
1
1
  // The MCP process cannot discover or invoke its parent's control plane. This
2
2
  // contract is consumed by the host agent after the update response completes.
3
3
  import { hostReloadProfile } from './host-reload.mjs';
4
- export function connectionHandoff({ host, target, current, workspace, platform, serverId = 'craft', busy, intent = 'inspect', name, requestKey }) {
4
+ export function connectionHandoff({ host, target, current, workspace, platform, serverId = 'craft', channel, busy, intent = 'inspect', name, requestKey }) {
5
5
  const readOnly = intent === 'inspect';
6
6
  const idle = busy?.can_reconnect;
7
7
  const profile = hostReloadProfile(host);
8
8
  const state = readOnly ? 'inspect_only' : idle === false ? 'wait_for_idle' : idle === true ? 'ready' : 'check_current_connection';
9
- const fallback = [profile.fallback, '只有页面实际提示未信任或授权时才由用户按提示确认;每次更新不一定需要重新信任。'];
9
+ const reconnectHint = serverId === 'craft' ? profile.fallback : profile.fallback.replace(/\bCraft\b/g, serverId);
10
+ const fallback = [reconnectHint, '只有页面实际提示未信任或授权时才由用户按提示确认;每次更新不一定需要重新信任。'];
10
11
  const next = readOnly
11
12
  ? '本次仅检查版本,不安装、不重连。已安装新版将在下一次 MCP 启动或用户重连后生效。'
12
13
  : idle === false
13
14
  ? '新版已安装,当前进程继续使用原版本。先完成活动任务、保存进度并 release;不要为更新中断工作。新版将在下次 MCP 启动或用户重连后加载。'
14
15
  : '新版已安装,当前进程保持原版本。下一次 MCP 启动或用户重连后,通过当前聊天的 craft_game_info 核对实际 version、build_id、active_verified 与宿主范围;无需新建聊天。确认后 prepare(resume) 更新当前项目的上下文和 Skill,再重新读取入口与技能索引。不要主动重载宿主或把安装探测当作当前连接确认。';
15
16
  return {
16
- schema: 2, executor: 'host_agent', host, host_profile: profile, server_id: serverId, intent, state,
17
+ schema: 2, executor: 'host_agent', host, host_profile: { ...profile, fallback: reconnectHint }, server_id: serverId, channel, intent, state,
17
18
  after_response: true,
18
19
  automatic_reload: readOnly ? 'disabled_read_only' : 'user_requested_reconnect',
19
20
  automatic_reload_attempts: 0,
20
21
  strategy: ['wait_for_next_mcp_start_or_user_reconnect', 'verify_current_connection', 'prepare_current_project_context'],
21
22
  capability_source: 'actual_host_tools', capability_availability: 'not_observable_from_mcp',
22
23
  busy: busy ?? null, busy_scope: 'current_connection',
23
- preflight: { tool: 'craft_game_info', require_idle: true, honor_host_control_scope: true, require_control_scope_idle: true,
24
+ preflight: { server_id: serverId, tool: 'craft_game_info', require_idle: true, honor_host_control_scope: true, require_control_scope_idle: true,
24
25
  unknown_control_scope: 'manual_reconnect', if_already_verified: 'continue_without_reload' },
25
- expected: { version: target?.version, build_id: target?.build_id, host, workspace, platform },
26
+ expected: { version: target?.version, build_id: target?.build_id, server_id: serverId, channel, host, workspace, platform },
26
27
  ...(current?.instance_id ? { previous_instance_id: current.instance_id } : {}),
27
- verify: { tool: 'craft_game_info', arguments: name ? { name } : {}, scope: 'current_chat_connection',
28
- required: ['version', 'runtime.version', 'runtime.build_id', 'runtime.instance_id', 'runtime.activation.status', 'host', 'workspace', 'platform'],
28
+ verify: { server_id: serverId, tool: 'craft_game_info', arguments: name ? { name } : {}, scope: 'current_chat_connection',
29
+ required: ['version', 'runtime.version', 'runtime.build_id', 'runtime.instance_id', 'runtime.activation.status', 'server_id', 'channel', 'host', 'workspace', 'platform'],
29
30
  activation_status: 'active_verified', recheck_busy_before_reload: true,
30
31
  after_reload: { max_reads: 10, interval_ms: 500, retry_transient_connection_errors: true, never_repeat_reload: true },
31
32
  require_new_instance: Boolean(current?.instance_id && (current.version !== target?.version || current.build_id !== target?.build_id)),
32
33
  independent_probe_is_not_confirmation: true },
33
34
  retry: { ...(requestKey ? { request_key: requestKey } : {}), only_explicitly_unstarted_prepare: true, never_replay_paid_operations: true },
34
- fallback, next,
35
+ fallback, next: serverId === 'craft' ? next : '本次操作及核验使用 ' + serverId + ' 的工具。' + next,
35
36
  };
36
37
  }