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

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 (360) hide show
  1. package/README.md +21 -8
  2. package/bin/craft-mcp.mjs +1 -1
  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 +2 -0
  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 +3 -3
  11. package/dist-server/game-workflow/projects.mjs +15 -13
  12. package/dist-server/integrations/files.mjs +3 -1
  13. package/dist-server/integrations/install-source.mjs +44 -0
  14. package/dist-server/integrations/install.mjs +87 -23
  15. package/dist-server/integrations/project-setup.mjs +6 -4
  16. package/dist-server/integrations/updates.mjs +15 -4
  17. package/dist-server/mcp/server.mjs +5 -4
  18. package/dist-server/mcp/update-session.mjs +26 -12
  19. package/dist-server/upstream/craft-aigc.mjs +11 -2
  20. package/dist-server/upstream/draft-audit.mjs +52 -6
  21. package/package.json +1 -1
  22. package/resources/craft-create/SKILL.md +1 -1
  23. package/resources/craft-update/SKILL.md +1 -1
  24. package/resources/targets/claude/js/js/bundle.json +5 -5
  25. package/resources/targets/claude/js/recovery.md +1 -1
  26. package/resources/targets/claude/js/target.json +1 -1
  27. package/resources/targets/claude/js3d/js3d/bundle.json +25 -23
  28. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  29. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  30. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  31. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  32. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  33. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  34. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  35. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  36. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  37. package/resources/targets/claude/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  38. package/resources/targets/claude/js3d/recovery.md +1 -1
  39. package/resources/targets/claude/js3d/target.json +1 -1
  40. package/resources/targets/codebuddy/js/js/bundle.json +5 -5
  41. package/resources/targets/codebuddy/js/recovery.md +1 -1
  42. package/resources/targets/codebuddy/js/target.json +1 -1
  43. package/resources/targets/codebuddy/js3d/js3d/bundle.json +25 -23
  44. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  45. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  46. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  47. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  48. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  49. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  50. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  51. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  52. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  53. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  54. package/resources/targets/codebuddy/js3d/recovery.md +1 -1
  55. package/resources/targets/codebuddy/js3d/target.json +1 -1
  56. package/resources/targets/codex/js/js/bundle.json +5 -5
  57. package/resources/targets/codex/js/recovery.md +1 -1
  58. package/resources/targets/codex/js/target.json +1 -1
  59. package/resources/targets/codex/js3d/js3d/bundle.json +25 -23
  60. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  61. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  62. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  63. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  64. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  65. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  66. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  67. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  68. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  69. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  70. package/resources/targets/codex/js3d/recovery.md +1 -1
  71. package/resources/targets/codex/js3d/target.json +1 -1
  72. package/resources/targets/comate/js/js/bundle.json +5 -5
  73. package/resources/targets/comate/js/recovery.md +1 -1
  74. package/resources/targets/comate/js/target.json +1 -1
  75. package/resources/targets/comate/js3d/js3d/bundle.json +25 -23
  76. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  77. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  78. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  79. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  80. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  81. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  82. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  83. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  84. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  85. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  86. package/resources/targets/comate/js3d/recovery.md +1 -1
  87. package/resources/targets/comate/js3d/target.json +1 -1
  88. package/resources/targets/cursor/js/js/bundle.json +5 -5
  89. package/resources/targets/cursor/js/recovery.md +1 -1
  90. package/resources/targets/cursor/js/target.json +1 -1
  91. package/resources/targets/cursor/js3d/js3d/bundle.json +25 -23
  92. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  93. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  94. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  95. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  96. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  97. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  98. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  99. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  100. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  101. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  102. package/resources/targets/cursor/js3d/recovery.md +1 -1
  103. package/resources/targets/cursor/js3d/target.json +1 -1
  104. package/resources/targets/dsh/js/js/bundle.json +5 -5
  105. package/resources/targets/dsh/js/recovery.md +1 -1
  106. package/resources/targets/dsh/js/target.json +1 -1
  107. package/resources/targets/dsh/js3d/js3d/bundle.json +25 -23
  108. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  109. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  110. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  111. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  112. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  113. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  114. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  115. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  116. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  117. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  118. package/resources/targets/dsh/js3d/recovery.md +1 -1
  119. package/resources/targets/dsh/js3d/target.json +1 -1
  120. package/resources/targets/index.json +56 -56
  121. package/resources/targets/kimi/js/js/bundle.json +5 -5
  122. package/resources/targets/kimi/js/recovery.md +1 -1
  123. package/resources/targets/kimi/js/target.json +1 -1
  124. package/resources/targets/kimi/js3d/js3d/bundle.json +25 -23
  125. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  126. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  127. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  128. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  129. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  130. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  131. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  132. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  133. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  134. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  135. package/resources/targets/kimi/js3d/recovery.md +1 -1
  136. package/resources/targets/kimi/js3d/target.json +1 -1
  137. package/resources/targets/opencode/js/js/bundle.json +5 -5
  138. package/resources/targets/opencode/js/recovery.md +1 -1
  139. package/resources/targets/opencode/js/target.json +1 -1
  140. package/resources/targets/opencode/js3d/js3d/bundle.json +25 -23
  141. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  142. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  143. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  144. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  145. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  146. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  147. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  148. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  149. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  150. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  151. package/resources/targets/opencode/js3d/recovery.md +1 -1
  152. package/resources/targets/opencode/js3d/target.json +1 -1
  153. package/resources/targets/qoder/js/js/bundle.json +5 -5
  154. package/resources/targets/qoder/js/recovery.md +1 -1
  155. package/resources/targets/qoder/js/target.json +1 -1
  156. package/resources/targets/qoder/js3d/js3d/bundle.json +25 -23
  157. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  158. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  159. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  160. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  161. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  162. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  163. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  164. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  165. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  166. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  167. package/resources/targets/qoder/js3d/recovery.md +1 -1
  168. package/resources/targets/qoder/js3d/target.json +1 -1
  169. package/resources/targets/qoder-cn/js/js/bundle.json +5 -5
  170. package/resources/targets/qoder-cn/js/recovery.md +1 -1
  171. package/resources/targets/qoder-cn/js/target.json +1 -1
  172. package/resources/targets/qoder-cn/js3d/js3d/bundle.json +25 -23
  173. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  174. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  175. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  176. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  177. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  178. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  179. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  180. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  181. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  182. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  183. package/resources/targets/qoder-cn/js3d/recovery.md +1 -1
  184. package/resources/targets/qoder-cn/js3d/target.json +1 -1
  185. package/resources/targets/qwen/js/js/bundle.json +5 -5
  186. package/resources/targets/qwen/js/recovery.md +1 -1
  187. package/resources/targets/qwen/js/target.json +1 -1
  188. package/resources/targets/qwen/js3d/js3d/bundle.json +25 -23
  189. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  190. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  191. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  192. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  193. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  194. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  195. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  196. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  197. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  198. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  199. package/resources/targets/qwen/js3d/recovery.md +1 -1
  200. package/resources/targets/qwen/js3d/target.json +1 -1
  201. package/resources/targets/trae/js/js/bundle.json +5 -5
  202. package/resources/targets/trae/js/recovery.md +1 -1
  203. package/resources/targets/trae/js/target.json +1 -1
  204. package/resources/targets/trae/js3d/js3d/bundle.json +25 -23
  205. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  206. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  207. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  208. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  209. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  210. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  211. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  212. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  213. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  214. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  215. package/resources/targets/trae/js3d/recovery.md +1 -1
  216. package/resources/targets/trae/js3d/target.json +1 -1
  217. package/resources/targets/workbuddy/js/js/bundle.json +5 -5
  218. package/resources/targets/workbuddy/js/recovery.md +1 -1
  219. package/resources/targets/workbuddy/js/target.json +1 -1
  220. package/resources/targets/workbuddy/js3d/js3d/bundle.json +25 -23
  221. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  222. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  223. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  224. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  225. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  226. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  227. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  228. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  229. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  230. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  231. package/resources/targets/workbuddy/js3d/recovery.md +1 -1
  232. package/resources/targets/workbuddy/js3d/target.json +1 -1
  233. package/resources/targets/zcode/js/js/bundle.json +5 -5
  234. package/resources/targets/zcode/js/recovery.md +1 -1
  235. package/resources/targets/zcode/js/target.json +1 -1
  236. package/resources/targets/zcode/js3d/js3d/bundle.json +25 -23
  237. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/SKILL.md +1 -1
  238. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/sources.md +1 -1
  239. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/cartoon.md +1 -1
  240. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/comic.md +1 -1
  241. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/cozy.md +1 -1
  242. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/cyber.md +1 -1
  243. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/horror.md +1 -1
  244. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/lowpoly.md +1 -1
  245. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/paper.md +1 -1
  246. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/references/styles/voxel.md +1 -1
  247. package/resources/targets/zcode/js3d/recovery.md +1 -1
  248. package/resources/targets/zcode/js3d/target.json +1 -1
  249. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  250. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  251. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  252. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  253. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  254. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  255. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  256. package/resources/targets/codebuddy/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  257. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  258. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  259. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  260. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  261. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  262. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  263. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  264. package/resources/targets/codex/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  265. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  266. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  267. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  268. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  269. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  270. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  271. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  272. package/resources/targets/comate/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  273. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  274. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  275. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  276. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  277. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  278. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  279. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  280. package/resources/targets/cursor/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  281. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  282. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  283. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  284. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  285. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  286. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  287. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  288. package/resources/targets/dsh/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  289. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  290. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  291. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  292. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  293. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  294. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  295. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  296. package/resources/targets/kimi/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  297. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  298. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  299. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  300. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  301. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  302. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  303. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  304. package/resources/targets/opencode/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  305. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  306. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  307. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  308. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  309. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  310. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  311. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  312. package/resources/targets/qoder/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  313. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  314. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  315. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  316. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  317. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  318. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  319. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  320. package/resources/targets/qoder-cn/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  321. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  322. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  323. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  324. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  325. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  326. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  327. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  328. package/resources/targets/qwen/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  329. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  330. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  331. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  332. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  333. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  334. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  335. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  336. package/resources/targets/trae/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  337. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  338. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  339. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  340. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  341. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  342. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  343. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  344. package/resources/targets/workbuddy/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  345. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp +0 -0
  346. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp +0 -0
  347. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp +0 -0
  348. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp +0 -0
  349. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp +0 -0
  350. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp +0 -0
  351. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp +0 -0
  352. package/resources/targets/zcode/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp +0 -0
  353. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/cartoon.webp → shared-art-previews/cartoon-3f9e1acaf11be3a7ffdaac90802f591a9563724e742cc5891284ef1ee8b67ee9.webp} +0 -0
  354. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/comic.webp → shared-art-previews/comic-77969cf47f2600424b5c64ef20930ba7b7081df3a5640608855913bbb99cea63.webp} +0 -0
  355. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/cozy.webp → shared-art-previews/cozy-e5fcba518afcf147c289b58b94a3532b30d96ab48418cc95efc1f28e9f80a90c.webp} +0 -0
  356. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/cyber.webp → shared-art-previews/cyber-8e6934fed1a42ed08838ac8bfaaf8f1d9b10c29c23c5843895c0791412ad3d2b.webp} +0 -0
  357. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/horror.webp → shared-art-previews/horror-041ee4c51839b38a71517a4608d94fa64b860cd9d8500e5c6fa983bd00a0e7c7.webp} +0 -0
  358. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/lowpoly.webp → shared-art-previews/lowpoly-206f350338c6c1a890981e2e35ee9bc600951701d01f2e823a259c5b5c241a08.webp} +0 -0
  359. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/paper.webp → shared-art-previews/paper-98dff3c4d5d493730af33e38777721c8a6c46c222e8f4d9f3b3c6f0f36fe19d1.webp} +0 -0
  360. /package/resources/{targets/claude/js3d/js3d/context/skills/game-art-style/assets/previews/voxel.webp → shared-art-previews/voxel-2bbe76b02f1f69059ab676eb6e2f89d0a25dd405dcab80acfc2d96f4e483098d.webp} +0 -0
package/README.md CHANGED
@@ -8,18 +8,31 @@ Craft MCP 是面向支持本地 stdio MCP 的 AI IDE 的游戏制作服务,例
8
8
 
9
9
  ### 按宿主安装(推荐)
10
10
 
11
- 显式选择当前宿主;只有同时接入时才用逗号列出多个宿主。安装完整 MCP 程序包、固定启动入口及全局 craft-create、craft-update Skill,保留已有平台和工作区。默认启用 stable 渠道自动检查和安装;新版在下次 MCP 启动或用户重连后加载。
11
+ 选择当前宿主;只有同时接入时才用逗号列出多个宿主。安装完整 MCP 程序包、固定启动入口及全局 craft-create、craft-update Skill,保留已有平台和工作区。
12
+
13
+ 保留原命令中 guide 之前的全部内容,把 guide 换为 install --ide <当前宿主>。用户明确指定渠道时,追加 --channel <目标标签>,由执行本次 guide 的 CLI 下载并核验目标包。比如用新版管理 CLI 给已装 beta 的 WorkBuddy 切换到 ue-test,只需把 guide 换为 install --ide workbuddy --channel ue-test。即使 ue-test 指向旧包,仍由本次管理 CLI 完成安装。
14
+
15
+ 用户直接用 @标签 运行本版 guide 并要求安装该渠道时,保留原 @标签,并传同名 --channel。直接执行尚未包含此功能的旧包时,guide 和 install 均按该包版本工作。
16
+
17
+ ```sh
18
+ # 原命令使用 @ue-test guide,目标也是 ue-test
19
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@ue-test install --ide workbuddy --channel ue-test
20
+ ```
21
+
22
+ 已有安装切换到用户指定的其他渠道时,目标版本可以低于原渠道版本。同渠道安装和自动更新保留防降级。用户只给了具体版本时保留该版本。用户只写包名且未指定渠道时,install 也只写包名,省略 --channel。已有安装继续跟踪原渠道,首次安装默认跟踪 stable。
12
23
 
13
24
  ```sh
14
- # 在 Codex 中安装
15
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.1 install --ide codex
16
- # 在 WorkBuddy 中安装
17
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.1 install --ide workbuddy
25
+ # 用户只写包名,在 WorkBuddy 中安装
26
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp install --ide workbuddy
27
+ # 指定当前包版本,在 Codex 中安装
28
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.2 install --ide codex
29
+ # 指定当前包版本,在 WorkBuddy 中安装
30
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.2 install --ide workbuddy
18
31
  ```
19
32
 
20
- 其他宿主将 --ide 改为 cursor、codebuddy、claude、dsh、zcode、kimi、trae、qoder-cn、qoder、comate、opencode 或 qwen。TRAE 与国际版 Qoder IDE 还须 --host-config <宿主设置中打开的 MCP 配置绝对路径>;TRAE CN 加 --trae-region cn,国际版默认 global。这两个选项也适用于 doctor/check/update/connect/project-setup,可由 CRAFT_HOST_CONFIG、CRAFT_TRAE_REGION 环境变量提供。kimi 指当前 Kimi Code CLI,不写旧 Python Kimi CLI 的 ~/.kimi。可用 --workspace <绝对游戏父目录> 和 --platform <HTTPS origin> 指定目录与平台;未提供时保留现有配置,新安装默认 ~/CraftGames 和本包平台。安装不创建游戏、不修改信任权限;低版本或同版不同构建不会覆盖现有新版。
33
+ 其他宿主将 --ide 改为 cursor、codebuddy、claude、dsh、zcode、kimi、trae、qoder-cn、qoder、comate、opencode 或 qwen。TRAE 与国际版 Qoder IDE 还须 --host-config <宿主设置中打开的 MCP 配置绝对路径>;TRAE CN 加 --trae-region cn,国际版默认 global。这两个选项也适用于 doctor/check/update/connect/project-setup,可由 CRAFT_HOST_CONFIG、CRAFT_TRAE_REGION 环境变量提供。kimi 指当前 Kimi Code CLI,不写旧 Python Kimi CLI 的 ~/.kimi。可用 --workspace <绝对游戏父目录> 和 --platform <HTTPS origin> 指定目录与平台;未提供时保留现有配置,新安装默认 ~/CraftGames 和本包平台。安装不创建游戏、不修改信任权限。
21
34
 
22
- Codex 配置 ~/.codex/config.toml(设置 CODEX_HOME 时使用其 config.toml),全局 Skill 在 ~/.agents/skills;WorkBuddy 配置 ~/.workbuddy/mcp.json,全局 Skill 在 ~/.workbuddy/skills。CodeBuddy 使用 ~/.codebuddy/.mcp.json 与 ~/.codebuddy/skills,已有旧 MCP 配置按官方优先级沿用。初次安装后完成宿主连接与信任,再调用当前连接的 craft_game_info 核对 runtime 和 update.activation。doctor --ide <当前宿主> 仅验证独立探测和文件,不证明当前聊天已切版或发现 Skill。
35
+ Codex 配置 ~/.codex/config.toml(设置 CODEX_HOME 时使用其 config.toml),全局 Skill 在 ~/.agents/skills;WorkBuddy 配置 ~/.workbuddy/mcp.json,全局 Skill 在 ~/.workbuddy/skills。CodeBuddy 使用 ~/.codebuddy/.mcp.json 与 ~/.codebuddy/skills,已有旧 MCP 配置按官方优先级沿用。安装或切换渠道后,在下次启动或重连时调用当前聊天的 craft_game_info,核对 update.source.channel、运行版本、build_id 和 active_verified。doctor --ide <当前宿主> 仅验证独立探测和文件,不证明当前聊天已切版或发现 Skill。
23
36
 
24
37
  Claude Code 使用 ~/.claude.json 与 ~/.claude/skills;DSH 使用 ~/.dsh/cordis.patch.yml 与 ~/.dsh/skills;ZCode 使用 ~/.zcode/cli/config.json 的 mcp.servers 和 ~/.zcode/skills;Kimi Code CLI 使用 ~/.kimi-code/mcp.json 与 ~/.kimi-code/skills。DSH 配置是 YAML 插件 patch,ZCode 不是 mcpServers。对应目录覆盖通过 CLAUDE_CONFIG_DIR、DSH_HOME、KIMI_CODE_HOME 指定。不要把不同宿主的配置格式互换。
25
38
 
@@ -32,7 +45,7 @@ Claude Code 使用 ~/.claude.json 与 ~/.claude/skills;DSH 使用 ~/.dsh/cordi
32
45
  执行本包 guide,根据当前宿主调用上面的标准 install。十四种宿主使用同一安装流程,无需选择连接模式。当前进程不会因安装新版而切换版本;固定入口在下次启动时读取已安装目标。
33
46
 
34
47
  ```sh
35
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.1 guide
48
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp guide
36
49
  ```
37
50
 
38
51
  专家和连接器只通过 connect --ide workbuddy 解析标准安装并启动同一受管入口,首次使用也须先执行标准 install。connect 不安装程序、不改宿主配置、不创建游戏;安装缺失、禁用或平台/工作区不一致时明确失败。不要用无参数 npx 直接启动业务包来替代标准安装。未适配宿主的原始 stdio 调试不包含自动更新和 Skill 安装。
package/bin/craft-mcp.mjs CHANGED
@@ -37,7 +37,7 @@ if (args.length === 0 || (args.length === 2 && args[0] === '--workspace' && path
37
37
  } else if (args.length === 1 && ['--help', '-h', 'help'].includes(args[0])) {
38
38
  process.stdout.write('Windows local login: craft-mcp login-task --setup|--remove --ide workbuddy [--host-config <absolute MCP config file>]\n');
39
39
  process.stdout.write('Windows game preview: craft-mcp preview-task --setup|--remove --ide workbuddy [--host-config <absolute MCP config file>]\n');
40
- process.stdout.write('Usage: craft-mcp [--workspace <absolute games directory>|guide|--help]\n craft-mcp install --ide <host[,host]> [--workspace <absolute games directory>] [--platform <HTTPS origin>] [--registry <HTTPS registry>] [--channel <npm tag>] [--updates auto|off]\n craft-mcp project-setup --project <absolute game directory> --ide <host> [--install]\n craft-mcp connect --ide <host>\n craft-mcp doctor --ide <host[,host]>\n craft-mcp check --ide <host[,host]>\n craft-mcp update --ide <host[,host]>\nHosts: codex, workbuddy, codebuddy, cursor, claude, dsh, zcode, kimi, trae, qoder-cn, qoder, comate, opencode, qwen.\nHost options: --host-config <absolute MCP config file> (one host only); --trae-region global|cn. TRAE and Qoder IDE require the path opened by their settings UI. Environment equivalents: CRAFT_HOST_CONFIG, CRAFT_TRAE_REGION.\n\nNo arguments: start the stdio MCP server from this package.\n--workspace: override CLIENT_WORKSPACE_ROOT; games are created under <workspace>/<name>.\nDefault workspace: ~/CraftGames. The host current directory is not used.\nguide: print AI IDE installation instructions and exit.\ninstall: install this package, verify it, merge selected host configurations and install managed Skills. Preserve existing workspace/platform and update policy; new installations use a fixed next-start launcher and automatic stable-channel installation.\nconnect: start the existing standard installation; never installs or rewrites host settings.\ncheck: inspect the configured npm channel without installing a new runtime.\nupdate: install a verified newer compatible runtime and update the host configuration, including when automatic updates are off. The current process stays on its original package. Load the target at the next MCP start or user-requested reconnect, verify its identity, then prepare the current project to update context and Skills.\nproject-setup: inspect portable project installation requirements and the selected host; --install installs only a missing registration. Verify the current host connection before resuming.\ndoctor: verify configured files and candidate MCP in an isolated process; does not confirm the current host connection.\n');
40
+ process.stdout.write('Usage: craft-mcp [--workspace <absolute games directory>|guide|--help]\n craft-mcp install --ide <host[,host]> [--workspace <absolute games directory>] [--platform <HTTPS origin>] [--registry <HTTPS registry>] [--channel <npm tag>] [--updates auto|off]\n craft-mcp project-setup --project <absolute game directory> --ide <host> [--install]\n craft-mcp connect --ide <host>\n craft-mcp doctor --ide <host[,host]>\n craft-mcp check --ide <host[,host]>\n craft-mcp update --ide <host[,host]>\nHosts: codex, workbuddy, codebuddy, cursor, claude, dsh, zcode, kimi, trae, qoder-cn, qoder, comate, opencode, qwen.\nHost options: --host-config <absolute MCP config file> (one host only); --trae-region global|cn. TRAE and Qoder IDE require the path opened by their settings UI. Environment equivalents: CRAFT_HOST_CONFIG, CRAFT_TRAE_REGION.\n\nNo arguments: start the stdio MCP server from this package.\n--workspace: override CLIENT_WORKSPACE_ROOT; games are created under <workspace>/<name>.\nDefault workspace: ~/CraftGames. The host current directory is not used.\nguide: print AI IDE installation instructions and exit.\ninstall: install and verify Craft, merge selected host configurations and install managed Skills. Omit --channel to retain the existing channel (stable on first install). An explicitly different --channel selects its tagged package even if its version is lower. Reinstalling the same channel and automatic updates retain downgrade protection. Preserve the workspace, platform and update policy; new installations enable automatic updates.\nconnect: start the existing standard installation; never installs or rewrites host settings.\ncheck: inspect the configured npm channel without installing a new runtime.\nupdate: install a verified newer compatible runtime and update the host configuration, including when automatic updates are off. The current process stays on its original package. Load the target at the next MCP start or user-requested reconnect, verify its identity, then prepare the current project to update context and Skills.\nproject-setup: inspect portable project installation requirements and the selected host; --install installs only a missing registration. Verify the current host connection before resuming.\ndoctor: verify configured files and candidate MCP in an isolated process; does not confirm the current host connection.\n');
41
41
  } else {
42
42
  process.stderr.write('Unknown command or extra arguments. Use craft-mcp --help.\n');
43
43
  process.exitCode = 1;
@@ -0,0 +1,71 @@
1
+ import path from 'node:path';
2
+ import { createHash } from 'node:crypto';
3
+ import { mkdir, readFile, writeFile, lstat } from 'node:fs/promises';
4
+ import { resolveBundleTemplate, sharedTemplatePath } from './bundle-template.mjs';
5
+
6
+ export const archiveArtPreviews = 'shared-art-previews';
7
+ export const projectArtPreviews = '.craft/art-previews';
8
+
9
+ export function previewHash(name) {
10
+ const match = typeof name === 'string' && /^[a-z][a-z0-9-]*-([a-f0-9]{64})\.webp$/.exec(name);
11
+ if (!match) throw new Error('Invalid Craft preview file name: '+name);
12
+ return match[1];
13
+ }
14
+
15
+ export function checkArtPreview(name, bytes) {
16
+ if (createHash('sha256').update(bytes).digest('hex') !== previewHash(name)) throw new Error('Craft preview checksum mismatch: '+name);
17
+ }
18
+
19
+ // Skill Markdown carries the final game-relative link verbatim. Only this
20
+ // content-addressed destination can cross the boundary of a native host tree.
21
+ export function artPreviewLink(file, target) {
22
+ if (!target.includes('.craft/art-previews/')) return;
23
+ const parts = file.replaceAll('\\','/').split('/');
24
+ const skills = parts.lastIndexOf('skills'), name = path.posix.basename(target);
25
+ previewHash(name);
26
+ const expected = path.posix.relative(path.posix.dirname(['host',...parts.slice(skills)].join('/')),projectArtPreviews+'/'+name);
27
+ if (skills < 0 || target !== expected) throw new Error('Invalid project-relative Craft preview link: '+target);
28
+ return name;
29
+ }
30
+
31
+ export function collectArtPreviews(file, bytes, names) {
32
+ if (!file.endsWith('.md') || !bytes.includes('.craft/art-previews/')) return;
33
+ for (const [,target] of bytes.toString('utf8').matchAll(/\[[^\]\n]*\]\(([^)\n]+)\)/g)) {
34
+ const name = artPreviewLink(file,target);
35
+ if (name) names.add(name);
36
+ }
37
+ }
38
+
39
+ export function bundleArtPreviewDirectory(root, engine, host, template) {
40
+ const target = path.resolve(root), hostRoot = path.dirname(target), targets = path.dirname(hostRoot);
41
+ const resources = path.dirname(targets);
42
+ // A standalone --out may happen to end in targets/<host>/<engine>. Only a
43
+ // verified shared distribution template opts into the sibling resource pool.
44
+ const shared = template && host && path.basename(target) === engine && path.basename(hostRoot) === host &&
45
+ path.basename(targets) === 'targets' && path.resolve(template) === path.join(resources,sharedTemplatePath(engine));
46
+ return path.join(shared ? resources : root,archiveArtPreviews);
47
+ }
48
+
49
+ export async function readArtPreview(directory,name) {
50
+ previewHash(name);
51
+ const file=path.join(directory,name);
52
+ if (!(await lstat(directory)).isDirectory() || !(await lstat(file)).isFile()) throw new Error('Craft preview must be a regular file: '+name);
53
+ const bytes = await readFile(file);
54
+ checkArtPreview(name,bytes);
55
+ return bytes;
56
+ }
57
+
58
+ export async function copyArtPreview(source,destination,name) {
59
+ const bytes = await readArtPreview(source,name);
60
+ await mkdir(destination,{recursive:true});
61
+ try {await writeFile(path.join(destination,name),bytes,{flag:'wx'});}
62
+ catch (error) {if (error.code !== 'EEXIST') throw error; await readArtPreview(destination,name);}
63
+ }
64
+
65
+ export async function copyBundleArtPreviews(source,destination,bundle) {
66
+ if (!bundle.art_previews?.length) return;
67
+ const template = await resolveBundleTemplate(source,bundle.engine,bundle.host);
68
+ for (const name of bundle.art_previews ?? []) {
69
+ await copyArtPreview(bundleArtPreviewDirectory(source,bundle.engine,bundle.host,template),path.join(destination,archiveArtPreviews),name);
70
+ }
71
+ }
@@ -3,6 +3,7 @@ import { lstat, readdir, readFile } from 'node:fs/promises';
3
3
  import { createHash } from 'node:crypto';
4
4
  import { hosts } from '../integrations/hosts.mjs';
5
5
  import { resolveBundleTemplate } from './bundle-template.mjs';
6
+ import { bundleArtPreviewDirectory, collectArtPreviews, readArtPreview } from './art-previews.mjs';
6
7
 
7
8
  export const bundleContracts = Object.freeze({ export:1, skills:1, mcp:1, sdk_lifecycle:1 });
8
9
  export const digest = value => createHash('sha256').update(value).digest('hex');
@@ -13,7 +14,7 @@ export function bundleId(manifest) {
13
14
 
14
15
  // Hash the complete engine payload, including executable skills, hooks and template.
15
16
  // Common workflow and the selected engine guide travel with each version as well.
16
- export async function bundleFiles(root, engine, target = false, contextOnly = false, template = path.join(root,engine,'project')) {
17
+ export async function bundleFiles(root, engine, target = false, contextOnly = false, template = path.join(root,engine,'project'), previews = new Set()) {
17
18
  if (!['js','js3d'].includes(engine)) throw new Error('Unsupported bundle engine');
18
19
  const files = {};
19
20
  async function visit(relative, file = path.join(root,relative)) {
@@ -21,7 +22,11 @@ export async function bundleFiles(root, engine, target = false, contextOnly = fa
21
22
  if (stat.isSymbolicLink()) throw new Error('Context bundle contains a link: ' + relative);
22
23
  if (stat.isDirectory()) {
23
24
  for (const name of (await readdir(file)).sort()) await visit(relative + '/' + name,path.join(file,name));
24
- } else if (stat.isFile()) files[relative] = digest(await readFile(file));
25
+ } else if (stat.isFile()) {
26
+ const bytes = await readFile(file);
27
+ files[relative] = digest(bytes);
28
+ if (target && relative.startsWith(engine+'/context/skills/')) collectArtPreviews(relative,bytes,previews);
29
+ }
25
30
  else throw new Error('Invalid context bundle file: ' + relative);
26
31
  }
27
32
  if ((await lstat(root)).isSymbolicLink() || (await lstat(path.join(root,engine))).isSymbolicLink() ||
@@ -48,7 +53,11 @@ export async function verifyBundle(root, engine, expectedId, {contextOnly = fals
48
53
  if (!Object.hasOwn(hosts,manifest.host) || target.host !== manifest.host || target.engine !== engine || target.version !== manifest.version) throw new Error('Context target identity mismatch');
49
54
  }
50
55
  const template = contextOnly ? undefined : await resolveBundleTemplate(root,engine,manifest.schema === 2 ? manifest.host : undefined);
51
- const actual = await bundleFiles(root,engine,manifest.schema === 2,contextOnly,template);
56
+ const previews = new Set();
57
+ const actual = await bundleFiles(root,engine,manifest.schema === 2,contextOnly,template,previews);
58
+ const ordered = [...previews].sort();
59
+ if (JSON.stringify(manifest.art_previews ?? []) !== JSON.stringify(ordered)) throw new Error('Context bundle art preview bindings differ: '+engine);
60
+ for (const name of ordered) await readArtPreview(bundleArtPreviewDirectory(root,engine,manifest.host,template),name);
52
61
  const expected = contextOnly ? Object.fromEntries(Object.entries(manifest.files).filter(([name])=>!name.startsWith(engine+'/project/'))) : manifest.files;
53
62
  if (JSON.stringify(actual) !== JSON.stringify(expected)) throw new Error('Context bundle integrity check failed: ' + engine);
54
63
  return manifest;
@@ -1,37 +1,37 @@
1
- import path from 'node:path';
2
- import { lstat, readFile } from 'node:fs/promises';
3
-
4
- export const sharedTemplateIndex = 'templates/index.json';
5
-
6
- export function sharedTemplatePath(engine) {
7
- if (!['js', 'js3d'].includes(engine)) throw new Error('Unsupported bundle engine');
8
- return `templates/${engine}/project`;
9
- }
10
-
11
- export function assertSharedTemplateIndex(index) {
12
- if (index?.schema !== 1) throw new Error('Invalid shared template layout index');
13
- }
14
-
15
- async function statIfPresent(file) {
16
- try { return await lstat(file); }
17
- catch (error) { if (error.code !== 'ENOENT') throw error; }
18
- }
19
-
20
- export async function resolveBundleTemplate(root, engine, host) {
21
- const inline = path.join(root, engine, 'project');
22
- const target = path.resolve(root);
23
- const hostRoot = path.dirname(target);
24
- const targets = path.dirname(hostRoot);
25
- // Legacy resources, cached bundles and standalone targets have their own template.
26
- if (!host || path.basename(target) !== engine || path.basename(hostRoot) !== host || path.basename(targets) !== 'targets') return inline;
27
- const resources = path.dirname(targets);
28
- const index = path.join(resources, sharedTemplateIndex);
29
- const stat = await statIfPresent(index);
30
- if (!stat) return inline;
31
- if (!stat.isFile() || !(await lstat(path.dirname(index))).isDirectory()) throw new Error('Invalid shared template layout index');
32
- assertSharedTemplateIndex(JSON.parse(await readFile(index, 'utf8')));
33
- if (await statIfPresent(inline)) throw new Error('Shared template target also contains an inline template');
34
- const template = path.join(resources, sharedTemplatePath(engine));
35
- if (!(await lstat(path.dirname(template))).isDirectory()) throw new Error('Invalid shared template directory');
36
- return template;
37
- }
1
+ import path from 'node:path';
2
+ import { lstat, readFile } from 'node:fs/promises';
3
+
4
+ export const sharedTemplateIndex = 'templates/index.json';
5
+
6
+ export function sharedTemplatePath(engine) {
7
+ if (!['js', 'js3d'].includes(engine)) throw new Error('Unsupported bundle engine');
8
+ return `templates/${engine}/project`;
9
+ }
10
+
11
+ export function assertSharedTemplateIndex(index) {
12
+ if (index?.schema !== 1) throw new Error('Invalid shared template layout index');
13
+ }
14
+
15
+ async function statIfPresent(file) {
16
+ try { return await lstat(file); }
17
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
18
+ }
19
+
20
+ export async function resolveBundleTemplate(root, engine, host) {
21
+ const inline = path.join(root, engine, 'project');
22
+ const target = path.resolve(root);
23
+ const hostRoot = path.dirname(target);
24
+ const targets = path.dirname(hostRoot);
25
+ // Legacy resources, cached bundles and standalone targets have their own template.
26
+ if (!host || path.basename(target) !== engine || path.basename(hostRoot) !== host || path.basename(targets) !== 'targets') return inline;
27
+ const resources = path.dirname(targets);
28
+ const index = path.join(resources, sharedTemplateIndex);
29
+ const stat = await statIfPresent(index);
30
+ if (!stat) return inline;
31
+ if (!stat.isFile() || !(await lstat(path.dirname(index))).isDirectory()) throw new Error('Invalid shared template layout index');
32
+ assertSharedTemplateIndex(JSON.parse(await readFile(index, 'utf8')));
33
+ if (await statIfPresent(inline)) throw new Error('Shared template target also contains an inline template');
34
+ const template = path.join(resources, sharedTemplatePath(engine));
35
+ if (!(await lstat(path.dirname(template))).isDirectory()) throw new Error('Invalid shared template directory');
36
+ return template;
37
+ }
@@ -4,6 +4,7 @@ import { randomUUID } from 'node:crypto';
4
4
  import { safeProjectFile } from './asset-import.mjs';
5
5
  import { verifyBundle } from './bundle-files.mjs';
6
6
  import { loadEngineResource } from './engines.mjs';
7
+ import { copyBundleArtPreviews } from './art-previews.mjs';
7
8
 
8
9
  export const localContextPath = (host,engine,id)=>`.craft/contexts/${host}/${engine}/${id}`;
9
10
 
@@ -49,6 +50,7 @@ export async function materializeContext(project, current, previous) {
49
50
  const output = await safeProjectFile(staging,name,true);
50
51
  await writeFile(output,await readFile(path.join(resources,name)),{flag:'wx'});
51
52
  }
53
+ await copyBundleArtPreviews(resources,staging,bundle);
52
54
  await verifyBundle(staging,engine,bundle.id,{contextOnly:true});
53
55
  if (present) {
54
56
  const backups = await directory(project,`.craft/context-backups/${host}/${engine}`);
@@ -6,6 +6,7 @@ import { safeProjectFile } from './asset-import.mjs';
6
6
  import { digest } from './bundle-files.mjs';
7
7
  import { hosts } from '../integrations/hosts.mjs';
8
8
  import { atomicJson } from './request-store.mjs';
9
+ import { projectArtPreviewsCurrent, prepareArtPreviews } from './project-art-previews.mjs';
9
10
 
10
11
  export const contextLayoutSchema = 5;
11
12
  // Schema 4 used one physical Buddy directory. Never validate a historical lock
@@ -80,16 +81,22 @@ export async function resolveNativeContext(project,current,lock) {
80
81
  const binding=lock?.contexts?.[current.host];
81
82
  if(lock?.schema!==contextLayoutSchema || binding?.bundle_id!==current.bundle.id || lock.active_hosts?.[nativeContextPath(current.host)]!==current.host) throw new Error('Project context requires preparation with the installed host runtime; run craft_game_prepare mode=resume');
82
83
  const checked=await inspectNativeContext(project,current.host,current.engine,{full:true});
83
- const expected=Object.fromEntries(Object.entries(current.bundle.files).flatMap(([name,hash])=>{
84
- const file=nativeContextFile(name,current.engine); return file ? [[file,hash]] : [];
85
- }));
84
+ const expected=nativeFileHashes(current.bundle);
86
85
  if(checked.integrity!=='valid' || checked.manifest.bundle_id!==binding.bundle_id || checked.manifest.source_revision!==binding.source_revision || !isDeepStrictEqual(checked.manifest.files,expected)) throw new Error('Project context integrity check failed: '+(checked.reason??'binding or manifest mismatch')+'; run craft_game_prepare mode=resume');
86
+ if(!isDeepStrictEqual(checked.manifest.art_previews,current.bundle.art_previews) || !await projectArtPreviewsCurrent(project,current.bundle.art_previews)) throw new Error('Project art previews require restoration; run craft_game_prepare mode=resume');
87
87
  const selected=nativeSelection(project,current);
88
88
  selected.context.hosts=Object.fromEntries(Object.entries(lock.active_hosts).map(([directory,host])=>[host,path.join(project,directory)]));
89
89
  selected.context.user_rules=path.join(project,'.craft/user-rules.md');
90
90
  return selected;
91
91
  }
92
92
 
93
+ export function nativeFileHashes(bundle) {
94
+ return Object.fromEntries(Object.entries(bundle.files).flatMap(([name,hash])=>{
95
+ const file=nativeContextFile(name,bundle.engine);
96
+ return file ? [[file,hash]] : [];
97
+ }));
98
+ }
99
+
93
100
  function validFileMap(value) {
94
101
  return value && typeof value==='object' && !Array.isArray(value) && Object.entries(value).every(([name,hash])=>
95
102
  typeof hash==='string' && /^[a-f0-9]{64}$/.test(hash) && name && !path.isAbsolute(name) &&
@@ -172,8 +179,12 @@ async function recoverNativeContextAt(project,relative,guard) {
172
179
  const raw=await optional(journalFile);
173
180
  if(!raw) return;
174
181
  const job=JSON.parse(raw);
182
+ const backupHost=/^\.craft\/context-backups\/([a-z-]+)\/[a-f0-9-]{36}$/.exec(job.backup)?.[1];
183
+ // Schema 4 recorded WorkBuddy backups under its own ID for the shared .codebuddy directory.
184
+ const ownsBackup=backupHost && Object.hasOwn(hosts,backupHost) &&
185
+ (nativeContextPath(backupHost)===relative || schema4Paths[backupHost]===relative);
175
186
  if(job.target!==relative || !/^\.craft\/context-staging\/[a-f0-9-]{36}$/.test(job.staging) ||
176
- !/^\.craft\/context-backups\/[a-z]+\/[a-f0-9-]{36}$/.test(job.backup) || !/^[a-f0-9]{64}$/.test(job.bundle)) throw new Error('Invalid native context transaction');
187
+ !ownsBackup || !/^[a-f0-9]{64}$/.test(job.bundle)) throw new Error('Invalid native context transaction');
177
188
  if(job.schema===2) {
178
189
  await publishFiles(project,job,guard);
179
190
  await guard(); await rm(journalFile);
@@ -242,11 +253,13 @@ export async function materializeNativeContext(project,current,guard=async()=>{}
242
253
  const bytes=await readFile(path.join(resources,name));
243
254
  payload.set(output,bytes); files[output]=digest(bytes);
244
255
  }
245
- const manifest={schema:1,host,engine,version:bundle.version,bundle_id:bundle.id,source_revision:bundle.source_revision,files};
256
+ const manifest={schema:1,host,engine,version:bundle.version,bundle_id:bundle.id,source_revision:bundle.source_revision,
257
+ ...(bundle.art_previews ? {art_previews:bundle.art_previews} : {}),files};
246
258
  const manifestBytes=Buffer.from(JSON.stringify(manifest,null,2)+'\n');
247
259
  for(const name of payload.keys()) if(before[name] && !owned?.files[name]) throw new Error('Unmanaged project context file at '+relative+'/'+name+'; preserve or relocate it before retrying');
248
260
  const complete=owned && isDeepStrictEqual(owned,manifest) && Object.entries(files).every(([name,hash])=>before[name]===hash);
249
261
  const selected=nativeSelection(project,current);
262
+ await prepareArtPreviews(project,current,guard);
250
263
  if(complete) return {selected,relative,materialized:!!recovered,...recovered};
251
264
  const token=randomUUID(), stagingRelative='.craft/context-staging/'+token, backupRelative='.craft/context-backups/'+host+'/'+token;
252
265
  const staging=await directory(project,stagingRelative), backup=await directory(project,backupRelative);
@@ -0,0 +1,63 @@
1
+ import { readFile, writeFile, rename, rm } from 'node:fs/promises';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { digest } from './bundle-files.mjs';
4
+ import { safeProjectFile } from './asset-import.mjs';
5
+ import { previewHash, projectArtPreviews, bundleArtPreviewDirectory, readArtPreview } from './art-previews.mjs';
6
+
7
+ async function projectPreviewBytes(project,name) {
8
+ previewHash(name);
9
+ try {return await readFile(await safeProjectFile(project,projectArtPreviews+'/'+name));}
10
+ catch (error) {if (error.code !== 'ENOENT') throw error; return null;}
11
+ }
12
+
13
+ export async function projectArtPreviewsCurrent(project,names,checks=new Map()) {
14
+ for (const name of names ?? []) {
15
+ if (!checks.has(name)) checks.set(name,projectPreviewBytes(project,name).then(bytes=>bytes !== null && digest(bytes) === previewHash(name)));
16
+ if (!await checks.get(name)) return false;
17
+ }
18
+ return true;
19
+ }
20
+
21
+ // Keep the old lock until retirement finishes. An interrupted migration can
22
+ // retry: an already archived file is absent, and unrelated files are untouched.
23
+ export async function retireArtPreviews(project,previous,current,guard) {
24
+ const active = new Set(current);
25
+ for (const name of previous) {
26
+ if (active.has(name)) continue;
27
+ await guard();
28
+ const bytes = await projectPreviewBytes(project,name);
29
+ if (bytes === null || digest(bytes) !== previewHash(name)) continue;
30
+ const file = await safeProjectFile(project,projectArtPreviews+'/'+name);
31
+ const backup = await safeProjectFile(project,'.craft/context-backups/art-previews/'+randomUUID()+'/'+name,true);
32
+ await rename(file,backup);
33
+ }
34
+ }
35
+
36
+ export async function prepareArtPreviews(project,current,guard) {
37
+ for (const name of current.bundle.art_previews ?? []) {
38
+ const original = await projectPreviewBytes(project,name);
39
+ if (original !== null && digest(original) === previewHash(name)) continue;
40
+ const bytes = await readArtPreview(bundleArtPreviewDirectory(current.resources,current.engine,current.host,current.template),name);
41
+ await guard();
42
+ // This namespace is reserved for immutable, digest-named reference images.
43
+ // Preserve unexpected local content before repairing its official counterpart.
44
+ const token = randomUUID(), relative = projectArtPreviews+'/'+name;
45
+ if (original !== null) {
46
+ const backup = await safeProjectFile(project,'.craft/context-backups/art-previews/'+token+'/'+name,true);
47
+ await writeFile(backup,original,{flag:'wx'});
48
+ }
49
+ const destination = await safeProjectFile(project,relative,true);
50
+ // Prepare owns the project lock. Reuse its private staging slot on retry
51
+ // so a terminated writer cannot strand a partial image in the asset pool.
52
+ const temporary = await safeProjectFile(project,'.craft/context-staging/art-previews/'+name+'.tmp',true);
53
+ await rm(temporary,{force:true});
54
+ try {
55
+ await writeFile(temporary,bytes,{flag:'wx'});
56
+ await guard();
57
+ const latest = await projectPreviewBytes(project,name);
58
+ if (latest !== null && digest(latest) === previewHash(name)) continue;
59
+ if (latest === null ? original !== null : !original?.equals(latest)) throw new Error('Project art preview changed during restoration: '+name);
60
+ await rename(temporary,destination);
61
+ } finally {await rm(temporary,{force:true});}
62
+ }
63
+ }
@@ -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} : {})};