@playcraft/cli 0.1.54 → 0.1.55-beta

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 (453) hide show
  1. package/README.md +83 -15
  2. package/SKILLS_REGISTRY.md +149 -0
  3. package/dist/agent/local-backend.js +1 -1
  4. package/dist/assets/client.js +157 -0
  5. package/dist/assets/messages.js +48 -0
  6. package/dist/auth/account-activation.js +157 -0
  7. package/dist/auth/messages.js +30 -0
  8. package/dist/cli-root-help.js +4 -0
  9. package/dist/commands/assets.js +123 -0
  10. package/dist/commands/build-all.js +5 -19
  11. package/dist/commands/build-temp.js +26 -0
  12. package/dist/commands/build.js +15 -28
  13. package/dist/commands/create.js +26 -33
  14. package/dist/commands/image-layer-messages.js +37 -0
  15. package/dist/commands/image-layer-tools.js +185 -0
  16. package/dist/commands/image.js +2 -73
  17. package/dist/commands/library-messages.js +46 -0
  18. package/dist/commands/library.js +130 -0
  19. package/dist/commands/login.js +84 -42
  20. package/dist/commands/platform-skills.generated.js +19 -0
  21. package/dist/commands/playable.js +53 -0
  22. package/dist/commands/preview-runtime.js +21 -0
  23. package/dist/commands/skills.js +4 -0
  24. package/dist/commands/tools-3d.js +11 -0
  25. package/dist/commands/tools-batch.js +113 -0
  26. package/dist/commands/tools-generation.js +6 -0
  27. package/dist/commands/tools.js +2 -0
  28. package/dist/commands/video.js +122 -0
  29. package/dist/commands/workspace-runtime.js +54 -0
  30. package/dist/commands/workspace.js +40 -0
  31. package/dist/config.js +59 -4
  32. package/dist/index.js +47 -3
  33. package/dist/preview-runtime/distribution.js +77 -0
  34. package/dist/project-skills/builtin-import.js +225 -0
  35. package/dist/project-skills/commands.js +77 -0
  36. package/dist/project-skills/lifecycle.js +28 -0
  37. package/dist/project-skills/local-run.js +112 -0
  38. package/dist/project-skills/local-store.js +221 -0
  39. package/dist/project-skills/messages.js +80 -0
  40. package/dist/project-skills/reconcile.js +62 -0
  41. package/dist/project-skills/remote-cache.js +51 -0
  42. package/dist/project-skills/validation.js +19 -0
  43. package/dist/recording/messages.js +40 -0
  44. package/dist/recording/project-digest.js +85 -0
  45. package/dist/recording/recorder.js +293 -0
  46. package/dist/recording/scenario.js +50 -0
  47. package/dist/remix/clone.js +2 -0
  48. package/dist/remix/init-template.js +2 -0
  49. package/dist/remix/pull.js +2 -0
  50. package/dist/remix/push.js +21 -1
  51. package/dist/skill-registry/client.js +345 -0
  52. package/dist/skill-registry/commands.js +180 -0
  53. package/dist/skill-registry/evaluation-client.js +156 -0
  54. package/dist/skill-registry/evaluation-commands.js +174 -0
  55. package/dist/skill-registry/messages.js +177 -0
  56. package/dist/skill-registry/package.js +275 -0
  57. package/dist/skill-registry/platform-package.js +100 -0
  58. package/dist/utils/agent-api-client.js +245 -30
  59. package/dist/utils/environment-endpoints.js +17 -0
  60. package/dist/utils/error-diagnostics.js +20 -0
  61. package/dist/utils/playcraft-http-client.js +6 -4
  62. package/dist/utils/tool-operation-journal.js +124 -0
  63. package/dist/utils/video-evidence-git.js +81 -0
  64. package/dist/video-replication/client.js +234 -0
  65. package/dist/video-replication/comparison-evidence.js +149 -0
  66. package/dist/video-replication/comparison-files.js +57 -0
  67. package/dist/video-replication/comparison-log.js +72 -0
  68. package/dist/video-replication/comparison-messages.js +104 -0
  69. package/dist/video-replication/comparison-output.js +63 -0
  70. package/dist/video-replication/comparison-preflight.js +66 -0
  71. package/dist/video-replication/comparison.js +230 -0
  72. package/dist/video-replication/diagnostics.js +41 -0
  73. package/dist/video-replication/evidence.js +165 -0
  74. package/dist/video-replication/media.js +112 -0
  75. package/dist/video-replication/messages.js +97 -0
  76. package/dist/workspace/messages.js +67 -0
  77. package/dist/workspace/transfer-client.js +237 -0
  78. package/dist/workspace/transfer-errors.js +48 -0
  79. package/dist/workspace-runtime/batch/content-changes.js +30 -0
  80. package/dist/workspace-runtime/batch/control.js +86 -0
  81. package/dist/workspace-runtime/batch/deliver.js +173 -0
  82. package/dist/workspace-runtime/batch/freeze.js +101 -0
  83. package/dist/workspace-runtime/batch/generate.js +249 -0
  84. package/dist/workspace-runtime/batch/git.js +40 -0
  85. package/dist/workspace-runtime/batch/occupancy.js +8 -0
  86. package/dist/workspace-runtime/batch/policy.js +70 -0
  87. package/dist/workspace-runtime/batch/prepare.js +317 -0
  88. package/dist/workspace-runtime/batch/processes.js +72 -0
  89. package/dist/workspace-runtime/batch/records.js +113 -0
  90. package/dist/workspace-runtime/batch/routes.js +61 -0
  91. package/dist/workspace-runtime/batch/source-candidate.js +86 -0
  92. package/dist/workspace-runtime/batch/source-capture.js +146 -0
  93. package/dist/workspace-runtime/batch/source-failure.js +43 -0
  94. package/dist/workspace-runtime/batch/source-publish.js +130 -0
  95. package/dist/workspace-runtime/codex/app-server.js +1065 -0
  96. package/dist/workspace-runtime/codex/compact.js +46 -0
  97. package/dist/workspace-runtime/codex/config-toml.js +107 -0
  98. package/dist/workspace-runtime/codex/delivery-tools.js +144 -0
  99. package/dist/workspace-runtime/codex/jsonrpc-stdio.js +145 -0
  100. package/dist/workspace-runtime/codex/launcher-client.js +177 -0
  101. package/dist/workspace-runtime/codex/loopback.js +146 -0
  102. package/dist/workspace-runtime/codex/mcp-config.js +39 -0
  103. package/dist/workspace-runtime/codex/model-broker.js +263 -0
  104. package/dist/workspace-runtime/codex/native-adapter.js +9 -0
  105. package/dist/workspace-runtime/codex/permissions.js +79 -0
  106. package/dist/workspace-runtime/codex/thread-image.js +38 -0
  107. package/dist/workspace-runtime/codex/tool-response.js +10 -0
  108. package/dist/workspace-runtime/codex/ui-instructions.js +4 -0
  109. package/dist/workspace-runtime/codex/ui-tools.js +203 -0
  110. package/dist/workspace-runtime/codex/work-mode.js +15 -0
  111. package/dist/workspace-runtime/main.js +10 -0
  112. package/dist/workspace-runtime/persistence/journal.js +365 -0
  113. package/dist/workspace-runtime/persistence/native-subagents.js +162 -0
  114. package/dist/workspace-runtime/persistence/sqlite-client.js +77 -0
  115. package/dist/workspace-runtime/persistence/sqlite-worker.js +1161 -0
  116. package/dist/workspace-runtime/persistence/stopped-execution.js +77 -0
  117. package/dist/workspace-runtime/previews/diagnostics.js +44 -0
  118. package/dist/workspace-runtime/previews/output.js +36 -0
  119. package/dist/workspace-runtime/previews/publish.js +283 -0
  120. package/dist/workspace-runtime/previews/runtime-preview.js +251 -0
  121. package/dist/workspace-runtime/previews/single-file.js +43 -0
  122. package/dist/workspace-runtime/processes/managed-writes.js +69 -0
  123. package/dist/workspace-runtime/serve.js +441 -0
  124. package/dist/workspace-runtime/server/accept-operation.js +61 -0
  125. package/dist/workspace-runtime/server/asset-transfers.js +63 -0
  126. package/dist/workspace-runtime/server/auth.js +21 -0
  127. package/dist/workspace-runtime/server/connectivity.js +211 -0
  128. package/dist/workspace-runtime/server/desktop-host.js +429 -0
  129. package/dist/workspace-runtime/server/desktop-preview-config.js +81 -0
  130. package/dist/workspace-runtime/server/desktop-preview-service.js +157 -0
  131. package/dist/workspace-runtime/server/desktop-preview-static.js +53 -0
  132. package/dist/workspace-runtime/server/desktop-preview.js +189 -0
  133. package/dist/workspace-runtime/server/dispatch.js +1655 -0
  134. package/dist/workspace-runtime/server/endpoints.js +21 -0
  135. package/dist/workspace-runtime/server/execution-group.js +90 -0
  136. package/dist/workspace-runtime/server/http.js +1363 -0
  137. package/dist/workspace-runtime/server/lock.js +53 -0
  138. package/dist/workspace-runtime/server/operation-record.js +33 -0
  139. package/dist/workspace-runtime/server/rfb-watch-gate.js +168 -0
  140. package/dist/workspace-runtime/server/session-restore.js +84 -0
  141. package/dist/workspace-runtime/server/source-uploader.js +138 -0
  142. package/dist/workspace-runtime/server/submit-operation.js +41 -0
  143. package/dist/workspace-runtime/server/terminal-host.js +366 -0
  144. package/dist/workspace-runtime/server/types.js +1 -0
  145. package/dist/workspace-runtime/server/workspace-transfer.js +168 -0
  146. package/dist/workspace-runtime/verify-artifact.js +59 -0
  147. package/dist/workspace-runtime/workspaces/append-only-log.js +62 -0
  148. package/dist/workspace-runtime/workspaces/archive.js +207 -0
  149. package/dist/workspace-runtime/workspaces/artifact-events.js +55 -0
  150. package/dist/workspace-runtime/workspaces/artifact-files.js +199 -0
  151. package/dist/workspace-runtime/workspaces/artifact-receipts.js +89 -0
  152. package/dist/workspace-runtime/workspaces/artifacts.js +282 -0
  153. package/dist/workspace-runtime/workspaces/asset-library-import.js +387 -0
  154. package/dist/workspace-runtime/workspaces/asset-publication-access.js +25 -0
  155. package/dist/workspace-runtime/workspaces/asset-transfer-dependencies.js +81 -0
  156. package/dist/workspace-runtime/workspaces/asset-transfer-publish.js +438 -0
  157. package/dist/workspace-runtime/workspaces/asset-transfer-storage.js +389 -0
  158. package/dist/workspace-runtime/workspaces/attachment-content.js +73 -0
  159. package/dist/workspace-runtime/workspaces/attachments.js +185 -0
  160. package/dist/workspace-runtime/workspaces/batch-commit.js +142 -0
  161. package/dist/workspace-runtime/workspaces/binary-content.js +65 -0
  162. package/dist/workspace-runtime/workspaces/binary-write.js +117 -0
  163. package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
  164. package/dist/workspace-runtime/workspaces/cli-credentials.js +115 -0
  165. package/dist/workspace-runtime/workspaces/composer-context.js +147 -0
  166. package/dist/workspace-runtime/workspaces/context-error.js +2 -0
  167. package/dist/workspace-runtime/workspaces/delivery-build.js +331 -0
  168. package/dist/workspace-runtime/workspaces/delivery-store.js +168 -0
  169. package/dist/workspace-runtime/workspaces/delivery.js +64 -0
  170. package/dist/workspace-runtime/workspaces/dependencies.js +279 -0
  171. package/dist/workspace-runtime/workspaces/developer-command.js +98 -0
  172. package/dist/workspace-runtime/workspaces/directories.js +135 -0
  173. package/dist/workspace-runtime/workspaces/directory-access.js +37 -0
  174. package/dist/workspace-runtime/workspaces/directory-attachments.js +245 -0
  175. package/dist/workspace-runtime/workspaces/directory-create.js +57 -0
  176. package/dist/workspace-runtime/workspaces/directory-maintenance.js +111 -0
  177. package/dist/workspace-runtime/workspaces/directory-mutations.js +238 -0
  178. package/dist/workspace-runtime/workspaces/directory-revisions.js +56 -0
  179. package/dist/workspace-runtime/workspaces/directory-stats.js +49 -0
  180. package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
  181. package/dist/workspace-runtime/workspaces/empty-template.js +43 -0
  182. package/dist/workspace-runtime/workspaces/file-content.js +48 -0
  183. package/dist/workspace-runtime/workspaces/files-search.js +116 -0
  184. package/dist/workspace-runtime/workspaces/files.js +150 -0
  185. package/dist/workspace-runtime/workspaces/git-credential-broker.js +312 -0
  186. package/dist/workspace-runtime/workspaces/git-credential-helper.js +68 -0
  187. package/dist/workspace-runtime/workspaces/git-direct-store.js +155 -0
  188. package/dist/workspace-runtime/workspaces/git.js +670 -0
  189. package/dist/workspace-runtime/workspaces/instructions.js +56 -0
  190. package/dist/workspace-runtime/workspaces/json5-edit.js +313 -0
  191. package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
  192. package/dist/workspace-runtime/workspaces/operation-log.js +23 -0
  193. package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
  194. package/dist/workspace-runtime/workspaces/parameter-agent-inputs.js +97 -0
  195. package/dist/workspace-runtime/workspaces/parameter-agent-protocol.js +40 -0
  196. package/dist/workspace-runtime/workspaces/parameter-agent-store.js +58 -0
  197. package/dist/workspace-runtime/workspaces/parameter-agent.js +284 -0
  198. package/dist/workspace-runtime/workspaces/parameter-assets.js +189 -0
  199. package/dist/workspace-runtime/workspaces/parameters.js +329 -0
  200. package/dist/workspace-runtime/workspaces/prepare.js +284 -0
  201. package/dist/workspace-runtime/workspaces/registry.js +251 -0
  202. package/dist/workspace-runtime/workspaces/remix-references.js +301 -0
  203. package/dist/workspace-runtime/workspaces/revisions.js +31 -0
  204. package/dist/workspace-runtime/workspaces/session-image.js +104 -0
  205. package/dist/workspace-runtime/workspaces/shared-git.js +40 -0
  206. package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +95 -0
  207. package/dist/workspace-runtime/workspaces/skills.js +191 -0
  208. package/dist/workspace-runtime/workspaces/theme-asset-index.js +157 -0
  209. package/dist/workspace-runtime/workspaces/transfer-quota.js +69 -0
  210. package/dist/workspace-runtime/workspaces/transfer.js +471 -0
  211. package/dist/workspace-runtime/workspaces/turn-changes.js +75 -0
  212. package/dist/workspace-runtime/workspaces/video-attachments.js +49 -0
  213. package/dist/workspace-runtime/workspaces/worktree-attachments.js +74 -0
  214. package/dist/workspace-runtime/workspaces/worktree-checkout.js +67 -0
  215. package/dist/workspace-runtime/workspaces/worktrees.js +73 -0
  216. package/package.json +16 -5
  217. package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
  218. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
  219. package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
  220. package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
  221. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
  222. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
  223. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
  224. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
  225. package/project-template/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
  226. package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
  227. package/project-template/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
  228. package/project-template/.claude/skills/playcraft-replica-validation/SKILL.md +25 -0
  229. package/project-template/.claude/skills/playcraft-replica-validation/references/contracts.md +79 -0
  230. package/project-template/.claude/skills/playcraft-video-understanding/SKILL.md +29 -0
  231. package/project-template/.claude/skills/playcraft-video-understanding/references/contracts.md +37 -0
  232. package/project-template/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
  233. package/project-template/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
  234. package/project-template-v2/.claude/agents/artist.md +82 -0
  235. package/project-template-v2/.claude/agents/developer.md +153 -0
  236. package/project-template-v2/.claude/agents/game-designer.md +264 -0
  237. package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
  238. package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
  239. package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
  240. package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
  241. package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
  242. package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
  243. package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
  244. package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
  245. package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
  246. package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
  247. package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
  248. package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  249. package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  250. package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
  251. package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  252. package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
  253. package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
  254. package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  255. package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
  256. package/project-template-v2/.claude/agents/reviewer.md +75 -0
  257. package/project-template-v2/.claude/agents/technical-artist.md +86 -0
  258. package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
  259. package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
  260. package/project-template-v2/.claude/settings.json +33 -0
  261. package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
  262. package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
  263. package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
  264. package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
  265. package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
  266. package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
  267. package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
  268. package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  269. package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
  270. package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  271. package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  272. package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
  273. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +307 -0
  274. package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  275. package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  276. package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +401 -0
  277. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  278. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  279. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +333 -0
  280. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +95 -0
  281. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  282. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +136 -0
  283. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  284. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
  285. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  286. package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  287. package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +244 -0
  288. package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
  289. package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
  290. package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
  291. package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
  292. package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  293. package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
  294. package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
  295. package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  296. package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  297. package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  298. package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  299. package/project-template-v2/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
  300. package/project-template-v2/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
  301. package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
  302. package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  303. package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  304. package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  305. package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
  306. package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
  307. package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
  308. package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  309. package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
  310. package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
  311. package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
  312. package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
  313. package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
  314. package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
  315. package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
  316. package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
  317. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
  318. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
  319. package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
  320. package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
  321. package/project-template-v2/.claude/snapshot.mjs +263 -0
  322. package/project-template-v2/.playcraft/skills.lock.json +152 -0
  323. package/project-template-v2/CLAUDE.md +146 -0
  324. package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
  325. package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
  326. package/project-template-v2/assets/bundles/.gitkeep +0 -0
  327. package/project-template-v2/assets/images/bg/.gitkeep +0 -0
  328. package/project-template-v2/assets/images/reference/.gitkeep +0 -0
  329. package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
  330. package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
  331. package/project-template-v2/assets/images/ui/.gitkeep +0 -0
  332. package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
  333. package/project-template-v2/assets/models/.gitkeep +0 -0
  334. package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
  335. package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
  336. package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
  337. package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
  338. package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
  339. package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
  340. package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
  341. package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
  342. package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
  343. package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
  344. package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
  345. package/project-template-v2/docs/project-state.json +60 -0
  346. package/project-template-v2/docs/project-state.md +72 -0
  347. package/project-template-v2/docs/standards/README.md +225 -0
  348. package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
  349. package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
  350. package/project-template-v2/docs/standards/artifacts/design.md +22 -0
  351. package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
  352. package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
  353. package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
  354. package/project-template-v2/game/index.ts +18 -0
  355. package/project-template-v2/globals.d.ts +51 -0
  356. package/project-template-v2/index.css +34 -0
  357. package/project-template-v2/index.html +18 -0
  358. package/project-template-v2/main.ts +9 -0
  359. package/project-template-v2/package.json +46 -0
  360. package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
  361. package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
  362. package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
  363. package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
  364. package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
  365. package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
  366. package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
  367. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
  368. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
  369. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
  370. package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
  371. package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
  372. package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
  373. package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
  374. package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
  375. package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
  376. package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
  377. package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
  378. package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
  379. package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
  380. package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
  381. package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
  382. package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
  383. package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
  384. package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
  385. package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
  386. package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
  387. package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
  388. package/project-template-v2/skills/playable-record/SKILL.md +140 -0
  389. package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
  390. package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
  391. package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
  392. package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
  393. package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
  394. package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
  395. package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
  396. package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
  397. package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
  398. package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
  399. package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
  400. package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
  401. package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
  402. package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
  403. package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
  404. package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
  405. package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
  406. package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
  407. package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
  408. package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
  409. package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
  410. package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
  411. package/project-template-v2/tsconfig.json +20 -0
  412. package/project-template-v2/vite.config.ts +27 -0
  413. package/project-templates/batch-locks/phaser.yaml +922 -0
  414. package/project-templates/batch-locks/threejs.yaml +978 -0
  415. package/project-templates/empty/AGENTS.md +53 -0
  416. package/project-templates/empty/gitignore +33 -0
  417. package/project-templates/phaser/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
  418. package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
  419. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
  420. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
  421. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
  422. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
  423. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
  424. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
  425. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
  426. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
  427. package/project-templates/phaser/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
  428. package/project-templates/phaser/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
  429. package/project-templates/phaser/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
  430. package/project-templates/threejs/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
  431. package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
  432. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
  433. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
  434. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
  435. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
  436. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
  437. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
  438. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
  439. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
  440. package/project-templates/threejs/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
  441. package/project-templates/threejs/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
  442. package/project-templates/threejs/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
  443. package/templates/preview-runtime/v1/README.md +71 -0
  444. package/templates/preview-runtime/v1/build-preview.mjs +1324 -0
  445. package/templates/preview-runtime/v1/manifest.json +17 -0
  446. package/templates/preview-runtime/v1/release-guard.mjs +87 -0
  447. package/templates/preview-runtime/v1/runtime.d.mts +3 -0
  448. package/templates/preview-runtime/v1/runtime.d.ts +3 -0
  449. package/templates/preview-runtime/v1/runtime.mjs +1121 -0
  450. package/templates/preview-runtime/v1/types/adapters.d.ts +26 -0
  451. package/templates/preview-runtime/v1/types/preview.d.ts +23 -0
  452. package/templates/preview-runtime/v1/types/protocol.d.ts +94 -0
  453. package/templates/preview-runtime/v1/types/runtime.d.ts +14 -0
@@ -0,0 +1,401 @@
1
+ ---
2
+ name: playcraft-image-generation
3
+ description: Use when generating or replacing playable images, reusing shared visual assets, or managing durable image tasks. AI (Artificial Intelligence, 人工智能) 图片生成与替换指南,保持参考图、背景要求、目标尺寸和交付文件一致。
4
+ triggers: 生成图片,generate image,选模型,model selection,reference image,参考图,风格一致,图生图,文生图,AI生图,图片质量,模型选择,500错误,模型失败,generate-image,list-image-models,ta-workspace,batch,批量,脚本,nodejs,edit模型,变体,绿幕,去背景,透明PNG,prompt,提示词,prompt套路,提示词技巧
5
+ compatibility: agent,opencode
6
+ version: 1.1.2
7
+ surfaces:
8
+ - sandbox-agent
9
+ ---
10
+
11
+ # PlayCraft AI 图片生成指南
12
+
13
+ ## 0. 开始前必读
14
+
15
+ 工作素材和脚本保存在当前工程,素材通常写 `assets/` 或当前主题目录;最终交付导出到工程根目录 `dist/`。云工作区的素材检索和持久化任务使用下列入口;任务请求文件和回执保存在 `dist/` 外。
16
+
17
+ ### 素材复用与可恢复生成
18
+
19
+ ```bash
20
+ # 需要复用已有图片时,按名称、路径和标签查找共享素材
21
+ playcraft library search "角色" --type texture --json
22
+ playcraft library get <assetId> --json
23
+ playcraft library files <assetId> --json
24
+ playcraft library download <assetId> --output ./assets/library-character
25
+
26
+ # 需要持久任务、精灵图或帧动画时,提交工作区任务
27
+ playcraft assets estimate --request image-request.json
28
+ playcraft assets generate --request image-request.json --client-request-id <stable-request-id>
29
+ playcraft assets get <taskId>
30
+ playcraft assets wait <taskId> --timeout 1800
31
+ playcraft assets download <taskId> --output ./assets/generated-character
32
+ ```
33
+
34
+ `image-request.json` 使用 JSON (JavaScript Object Notation, 数据交换格式),例如 `{"kind":"image","prompt":"A cheerful game character","removeBackground":true}`。请求中的透明背景开关由下文交付约束决定;素材替换需要读取字段参考图和规格时,继续使用下文的 `tools image-context` 与 `tools generate-image`。这两条入口没有可互换的参数表。
35
+
36
+ 任务命令从 `.playcraft/workspace-context.json` 推断当前工作区和工程目录;在工程外运行时传 `--workspace <workspaceId> --directory basic`,或实际变体目录。提交结果不确定时复用同一个 `--client-request-id` 与原请求;已有任务编号后通过 `get` / `wait` 恢复。等待超时以状态码 75 退出,任务仍可查询。精灵图和动画必须下载完整包并保留相对路径;`download` 保存文件不代表平台已确认采纳。
37
+
38
+ 普通单图生成和替换使用本技能下方的直接工具与命令;素材库检索、生成任务保存到素材库、动画草稿及版本的详细流程见当前可用的 `playcraft-workspace-assets` 技能。下载目标必须尚不存在。
39
+
40
+ 替换现有素材时先读取目标字段的 schema 配置(resolution、ratio、prompt、remove_background、reference_image)及当前素材。全新素材按用户需求确定尺寸、格式和输出路径,不假定所有素材都是透明 PNG (Portable Network Graphics, 便携式网络图形)。
41
+
42
+ 项目没有素材 schema 时,从目标素材的尺寸、格式和用户需求确定交付规格;参考图只提供内容和风格,不改变目标画布。不要套用其他游戏的字段、路径或尺寸。
43
+
44
+ 替换现有素材时传 `targetAssetPath`(命令行为 `--target-asset`):工具在生成前自动读取字段的 reference_image、当前素材、尺寸、格式、fit_mode、remove_background 与 padding_color。字段没有参考图时使用当前素材;读取失败立即停止,不丢弃参考图后继续生成。显式 referenceImagePath / --reference-image 可以覆盖默认参考图;用户明确要求无参考生成时才设 useTargetReference=false / --no-target-reference,交付约束仍保留。查看图片或在对话中选中素材不等于传入参考图。仅调整风格时保留原有文字、构图和用途;用户要求重新命名或重做构图时再改变。
45
+
46
+ 生图前运行模型发现命令,核实当前账号可用的模型与透明输出能力:
47
+
48
+ ```bash
49
+ playcraft tools list-image-models
50
+ ```
51
+
52
+ 输出示例:
53
+
54
+ ```
55
+ MODEL CAPABILITY ALPHA PROVIDERS
56
+ gpt-image-2.5-sunburst text+image yes iegg-litellm
57
+ gpt-image-2.5-flare text+image yes iegg-litellm
58
+ gemini-3.1-flash-image-preview text+image no 2 (google, iegg-litellm)
59
+ hy-image-v3.0 text+image no 1 (tencent-cloud)
60
+ flux-kontext-pro text+image no 1 (302)
61
+ qwen-image-edit-max image→image no 1 (mulerouter)
62
+ ...
63
+ ```
64
+
65
+ **列说明**:
66
+
67
+ - `CAPABILITY`:`text→image` 仅文生图 / `image→image` 仅图生图 / `text+image` 两者均支持
68
+ - `ALPHA`:`yes` = 支持原生透明输出;`no` = 透明素材才需要另行去背(见第 3 节)
69
+ - `PROVIDERS`:支持该模型的 provider 数量,多个 provider 时后端按优先级自动 fallback(顺序尝试,首个成功即返回)
70
+
71
+ **Prompt 套路速查**:[reference/prompt-cookbook.md](reference/prompt-cookbook.md)
72
+
73
+ ---
74
+
75
+ ## 1. 模型选择决策树
76
+
77
+ ```
78
+ 需要生图?
79
+ ├─ 用户指定了模型,或制作流程已锁定模型?
80
+ │ └─ 使用指定模型;失败时报告原因,不静默更换
81
+ │
82
+ ├─ 普通图片生成 / 现有素材替换 / 含文字 Logo?
83
+ │ └─ 优先 iegg-litellm/gpt-image-2.5-sunburst;不可用时选择清单中的 Image 2.5 并报告实际模型
84
+ │
85
+ ├─ 需要 --reference-image(风格一致性批量生产)?
86
+ │ └─ 必须选 CAPABILITY = text+image 或 image→image 的模型
87
+ │
88
+ ├─ 同类元素批量生成(<=16 个)?
89
+ │ └─ 精灵图直出策略(见进阶参考)
90
+ │
91
+ ├─ 结构相似的变体集(换花色/换数字/换颜色)?
92
+ │ └─ Edit 模型工作流(见进阶参考)
93
+ │
94
+ └─ 不确定?
95
+ └─ 使用平台默认模型;透明素材优先清单中 ALPHA=yes 的模型
96
+ ```
97
+
98
+ ### 主要模型特性
99
+
100
+ | 模型 | 特点与优势 | 最佳场景 | 速度 | 注意事项 |
101
+ | ---------------------------------- | ------------------------------------------------------------------ | ---------------------------------------- | -------------- | ----------------------------------------------------------------- |
102
+ | **gpt-image-2.5-sunburst / flare** | 当前普通生图与素材替换的优先模型,支持参考图及原生透明输出 | Logo、角色、图标、透明素材替换 | 以实际调用为准 | 使用模型清单中的 provider/model;检查返回的实际模型和透明验证结果 |
103
+ | **gpt-image-2** | 兼容已有项目和明确指定 provider 的制作流程 | 已锁定模型的概念图、故事板、精灵图 | 以实际调用为准 | 普通素材默认优先 Image 2.5;能力和可用 provider 以模型清单为准 |
104
+ | **gemini-3.1-flash-image-preview** | 速度快、色彩鲜艳、构图清晰、最稳定不易报错、reference-image 理解好 | 快速迭代、扁平卡通、明亮休闲风、超时回退 | 快(<30s) | 精细细节和文字不如 gpt-image-2 |
105
+ | **hy-image-v3.0** | 亚洲审美偏向、角色设计好、Q版/IP风格擅长 | 中国风、Q版角色、IP 形象 | 中等 | 西方写实风格表现一般 |
106
+ | **flux-kontext-pro** | 艺术感强、风格独特、手绘质感好 | 艺术插画、手绘风、独特画风探索 | 中等 | 网格理解弱,不适合精灵图 |
107
+ | **nano-banana-2** | 最快、适合简单图形探索 | 简洁图标、平面设计、快速草稿 | 极快 | 中文字符不可靠、细节少 |
108
+ | **qwen-image-edit-max** | 图生图编辑能力强、局部修改精确 | 换花色/换数字/换颜色等结构相似变体 | 中等 | CAPABILITY=image→image,必须传 reference-image |
109
+ | **wan2.6-image** | 风格迁移能力好 | 将参考图风格应用到新内容 | 中等 | CAPABILITY=image→image,必须传 reference-image |
110
+
111
+ ### 选型口诀
112
+
113
+ - 普通素材 / 含文字 / 透明元素 → 可用的 `gpt-image-2.5-sunburst`,其次 Image 2.5 系列
114
+ - 已锁定的故事板或制作流程 → 沿用该流程指定模型,见下方 MC 专用规则
115
+ - 中国风 / Q版 / 亚洲审美 → `hy-image-v3.0`
116
+ - 艺术/手绘探索 → `flux-kontext-pro`
117
+ - 纯 edit 变体 → `qwen-image-edit-max`
118
+ - 模型失败 → 先检查返回错误;不要把原生透明失败自动改成 Gemini 白底生成
119
+
120
+ ### 为什么精灵图直出是首选批量策略?
121
+
122
+ 精灵图直出(一次 API 调用生成一张包含 N 个元素的网格图,再 sprite-split 切分)优于逐个生成,原因有三:
123
+
124
+ 1. **成本**:一次 API 调用可包含 4-16 个元素,而逐个生成 N 个元素需要 N 次调用,成本和耗时线性增长。
125
+ 2. **风格一致性**:同一张图中的所有元素共享相同的生成上下文,天然保证色调、线条、阴影风格统一,避免逐个生成时每张图风格漂移的问题。
126
+ 3. **无逐元素偏差**:逐个生成时即使用相同 prompt,模型每次采样结果都不同,元素之间会出现肉眼可见的不一致;精灵图在一次推理中完成,消除了这种 per-element drift。
127
+
128
+ 详细策略与代码示例见进阶参考。
129
+
130
+ ---
131
+
132
+ ## 2. 核心命令
133
+
134
+ ### 沙箱对话中的直接工具
135
+
136
+ 当前对话注册了 `playcraft-generate-image` 时,直接调用它。根据本次目标素材填写参数,不固定游戏名、素材类别、参考路径、尺寸或比例:
137
+
138
+ | 参数 | 本次取值 |
139
+ | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
140
+ | `prompt` | 目标字段与用户要求的主体、风格、文字、构图或状态;完整场景可描述背景内容,透明交付通过背景开关表达 |
141
+ | `targetAssetPath` | 被替换的现有素材路径;自动加载该字段参考图和全部交付约束,避免与素材弹窗行为不一致 |
142
+ | `imageModelRef` | 普通生图可省略,由后端优先选择可用 Image 2.5;用户明确指定、字段配置或制作流程已锁定时传指定模型 |
143
+ | `referenceImagePath` | 已确认可读的项目相对参考路径;优先字段 `reference_image`,其次当前素材,新素材无参考时可省略 |
144
+ | `additionalReferenceImagePaths` | 确有多个参考时传入其他可读路径,顺序与用途明确 |
145
+ | `aspectRatio` | 新素材的构图比例;现有素材由 targetAssetPath 读取字段比例和尺寸 |
146
+ | `width` / `height` | 新素材的成对像素尺寸;有 targetAssetPath 时字段尺寸优先 |
147
+ | `outputFormat` / `fitMode` / `paddingColor` | 新素材的格式、适配方式和补边颜色;有 targetAssetPath 时读取目标约束 |
148
+ | `background` | **必填**。根据完整对话上下文和字段配置选择;仅用户或字段明确要求背景时选择 `opaque`,其余选择 `transparent`,不能仅按素材用途决定;Remix 未明确要求时选择 `transparent` |
149
+ | `outputPath` | 后端完成交付处理后的最终预览文件路径,沿用项目工作目录约定,视觉验收后写回实际主题引用 |
150
+
151
+ 背景、角色、道具、按钮、文字、发光状态、序列帧等各自遵守项目字段配置。成组状态或动画帧还需保持对象、风格、锚点与尺寸一致,不把单张静态图当成完整序列帧替换。
152
+
153
+ `background: transparent` 表示需要通过验证的透明素材,不表示必须执行一次本地去背。背景优先级为字段明确规则 → 对话模型的结构化选择。每次调用前由当前 Agent 结合完整对话判断,不依赖生图提示词关键词或旧图片的不透明状态;“不需要背景”“不要保留背景”选择 `transparent`。后端直接执行选择并校验成品,只有旧调用省略背景选择时才沿用提示词推断兼容路径,不额外请求一次对话模型。保存实际 provider/model、参考图数量、请求编号、尝试次数与透明验证结论;模型清单里的默认星号不能证明本次实际使用的模型。
154
+
155
+ 常规生图工具的透明交付通过必填 `background: transparent`(命令行为 `--background transparent`)表达;保留背景选择 `opaque`。字段配置仍为最高约束。`prompt` 保留主体、文字、风格、构图及透明玻璃、水泡等材质;源图背景按实际模型处理:
156
+
157
+ | 模型 / 流程 | 源图背景说明 |
158
+ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
159
+ | Image 2.5 | 后端组装原生透明指令及必要的恢复请求,交付顺序见下文。调用方不追加透明、白底或色幕后缀。 |
160
+ | 明确选用的其他模型 | 后端首次请求保留调用方提示词,不会自动补白底。要求透明交付时,追加单一 `on a uniform solid pure white background for subsequent background removal`,同时传透明交付开关;不要混入透明或色幕要求。 |
161
+ | 独立色幕制作 | 仅在第 3 节的适用条件下使用;保留色幕中间图,切分后独立去背,最终仍需透明验收。 |
162
+
163
+ Image 2.5 的透明文生图无需参考图。生成全新素材时省略 targetAssetPath;没有参考图时直接文生图,用户提供参考图时显式传入,按用户要求传背景开关。替换现有素材时传目标路径以读取参考图和交付规格。要求透明输出时使用 PNG 或 WebP;没有格式配置的旧 .jpg 素材生成透明预览时改用 PNG。
164
+
165
+ 透明交付由后端完成,有参考图与无参考图采用相同规则,按入口区分:
166
+
167
+ - **Remix 项目对话**:先直接生成透明图;透明验证不合格时只生成一张干净纯色原图,再把它交给支持透明编辑的模型去底;模型编辑报错或结果不合格,才对同一张纯色原图执行本地去背。模型不支持透明编辑时直接进入本地兜底。不使用失败的编辑结果做本地输入,不为本地兜底重新生成纯色图,也不在 Agent 层额外重复去背。
168
+ - **其他生图入口**:保留原生透明优先、必要时本地去背及最终验收的原有行为,不套用 Remix 的额外模型编辑步骤。
169
+
170
+ 首次生成阶段最多尝试两次供应商请求;Remix 仅在收到不合格图片后保留恢复次数:一次纯色源图生成,每张源图一次模型编辑。单图正常最多三次模型请求,若首次供应商请求失败则最多四次;批量恢复最多为首次阶段两次加一次纯色源图批量请求、每张一次编辑。本地后处理不增加模型请求数。其他 Agent 生图入口的模型、供应商与重新生成合计仍最多尝试两次;命令行默认没有额外重试。
171
+
172
+ 返回 `transparencySource=native`、`model-edit` 或 `background-removal`,分别表示原生透明、模型去底或本地去背。对话中的 `Image preview:` 地址保存的是后端最终成品,并独立于可编辑的沙箱文件;不要把恢复过程中的纯色原图展示为最终成品。自动检查只能判断透明通道、非空前景及画入的棋盘格等问题,不能代替文字、主体完整性、孔洞及深浅背景下的视觉验收。最终仍失败时报告请求编号与失败阶段并停止,不自行换模型、关闭透明要求或把透明补边当作成功。
173
+
174
+ 未注册直接工具时使用下方 CLI (Command-Line Interface, 命令行工具) 入口。若返回 `Business tool protocol unavailable (501); no operation was sent`,本次没有发出生图请求:修复入口或使用已注册的直接工具,不要通过换模型反复重试。
175
+
176
+ ### 现有素材替换
177
+
178
+ 先用 `playcraft tools image-context --asset-path <现有素材路径>` 查看本地解析结果;新命令不存在时更新已固定版本的命令行工具,不能跳过上下文继续生成。
179
+
180
+ ```bash
181
+ playcraft tools generate-image \
182
+ --target-asset "$TARGET_ASSET_PATH" \
183
+ --prompt "$IMAGE_PROMPT" \
184
+ --background "$BACKGROUND_MODE" \
185
+ --output "$PREVIEW_OUTPUT_PATH"
186
+ ```
187
+
188
+ 变量填写本次素材路径、用户生成要求与工作目录中的预览路径;`BACKGROUND_MODE` 由当前对话 Agent 明确选择 `transparent` 或 `opaque`,每次生图都传入。此入口自动传递该素材的参考图和交付约束;验证通过后再应用到目标主题。新素材没有目标文件时才手动传 `--width` / `--height`、`--output-format`、`--fit-mode`、`--padding-color`。旧脚本的 `--remove-background` / `--no-remove-background` 继续兼容,新 Agent 调用统一使用 `--background`。
189
+
190
+ ### 文生图(text-to-image)
191
+
192
+ ```bash
193
+ playcraft tools generate-image \
194
+ --prompt "A golden sword icon, flat 2D vector style, centered composition" \
195
+ --background transparent \
196
+ --output assets/images/sword.png \
197
+ --aspect-ratio 1:1 \
198
+ --image-size 4K \
199
+ --image-model iegg-litellm/gpt-image-2.5-sunburst
200
+ ```
201
+
202
+ ### 图生图(image-to-image / reference-image)
203
+
204
+ ```bash
205
+ playcraft tools generate-image \
206
+ --prompt "A similar style silver shield icon, same art direction" \
207
+ --background transparent \
208
+ --output assets/images/shield.png \
209
+ --reference-image assets/images/sword.png \
210
+ --aspect-ratio 1:1 \
211
+ --image-size 4K \
212
+ --image-model iegg-litellm/gpt-image-2.5-sunburst
213
+ ```
214
+
215
+ ### 参数说明
216
+
217
+ | 参数 | 值 | 说明 |
218
+ | ---------------------- | ----------------------------------------- | ------------------------------------------------------- |
219
+ | `--background` | `transparent` / `opaque` | Agent 调用必填,由完整对话上下文决定;字段约束优先 |
220
+ | `--aspect-ratio` | `1:1` / **`45:16`** / `16:9` / `9:16` / … | **Master Composite(5×9:16 横排)用 `45:16`** |
221
+ | `--width` / `--height` | 像素整数(成对) | MC 推荐 **`3600×1280`** 或 **`4096×1455`** |
222
+ | `--image-size` | `1K` / `2K` / `4K` | 控制分辨率级别。实际像素取决于模型+比例的组合(见下表) |
223
+
224
+ **`--image-size` 对 gpt-image-2 的落盘尺寸**(MuleRouter 请求 `size=auto`,由后端 letterbox 到目标像素):
225
+
226
+ | aspectRatio | 1K | 2K | 4K |
227
+ | ----------------------------- | --------- | ------------- | ------------- |
228
+ | 1:1 | 1024x1024 | 2048x2048 | 2048x2048 |
229
+ | **45:16** (5×9:16 故事板横排) | 2048x728 | **3600x1280** | **4096x1455** |
230
+ | 16:9 | 2048x1152 | 2048x1152 | 3840x2160 |
231
+ | 9:16 | 2160x3840 | 2160x3840 | 2160x3840 |
232
+ | 3:2 / 4:3 | 1536x1024 | 1536x1024 | 1536x1024 |
233
+ | 21:9 | 2048x1152 | 3840x2160 | 3840x2160 |
234
+
235
+ > **IEGG LiteLLM** 在 fallback 链中排第一,但 Azure gpt-image 最大约 1536px 宽 — 达不到 5×9:16 横排。故事板请用 **`mulerouter/gpt-image-2`**(跳过 litellm)+ `--width 3600 --height 1280`(或 4096×1455)。
236
+
237
+ ### Master Composite(MC)模型白名单
238
+
239
+ Artist 生成 MC 时**不得**套用上方通用决策树里的 gemini / flux / hy-image 等——MC 只允许:
240
+
241
+ | 允许 | 禁止(MC) |
242
+ | -------------------------- | --------------------------------------------------- |
243
+ | `mulerouter/gpt-image-2` | `gemini-*`、`flux-*`、`hy-image-*`、`wan*`、`qwen*` |
244
+ | `mulerouter/nano-banana-2` | 裸 `gpt-image-2`(会走 iegg-litellm 压扁五格) |
245
+
246
+ 故事板的提示词与尺寸依据本节规格和当前工程的制作要求。ASR 双板 `--image-model` 须与已选 MC **完全一致**。
247
+
248
+ **Phase 1(概念图)**:纯文生图,`--image-size 4K` + MC 白名单内模型。
249
+ **Phase 2(批量生产)**:必须带 `--reference-image` 指向 Phase 1 确认的概念图,同一批次使用**相同模型 + 相同 reference image + 相同 image-size**。
250
+
251
+ ### --reference-image 路径支持
252
+
253
+ - 本地绝对路径:`/path/to/ref.png`
254
+ - 相对路径(相对 CWD):`assets/images/ref.png`
255
+ - HTTP(S) URL(CLI 自动下载):`"https://images.unsplash.com/photo-xxx"`
256
+ - 多张参考图(重复选项,最多 8 张)
257
+ - 混合本地文件 + URL
258
+ - `search-image` 返回的 `downloadUrl` 可直接使用
259
+
260
+ ### 常用辅助命令
261
+
262
+ ```bash
263
+ # 去背景(绿幕建议 tolerance=25;默认白背景可用 15)
264
+ playcraft image remove-background --input in.png --output out.png --tolerance 25
265
+
266
+ # 缩放
267
+ playcraft image resize --input in.png --output out.png --width 128 --height 128
268
+
269
+ # 精灵图切分
270
+ playcraft image sprite-split \
271
+ --input sheet.png --output-dir frames/ \
272
+ --rows 2 --columns 4 \
273
+ --frame-width <总宽/4> --frame-height <总高/2>
274
+
275
+ # 合并精灵图
276
+ playcraft image sprite-sheet \
277
+ --input-dir processed/ --output bundle \
278
+ --columns 8 --background white
279
+ ```
280
+
281
+ ---
282
+
283
+ ## 3. 背景处理决策树
284
+
285
+ > **核心原则**:先读取字段明确约束,再结合完整对话判断用户是否明确要求背景;没有明确要求时默认透明,不能按素材类别推断为不透明。常规工具按第 2 节的模型规则准备源图并由后端验收,独立色幕流程才选择色幕颜色,交付后做深浅背景验证。
286
+
287
+ ```
288
+ 最终素材的背景要求是什么?
289
+ │
290
+ ├─ 字段有明确背景约束?
291
+ │ └─ 严格遵守字段要求:remove_background=true → transparent;false → opaque
292
+ │
293
+ ├─ 字段无明确约束,且用户明确要求保留背景/完整场景?
294
+ │ ├─ background=opaque / --background opaque,交付整张不透明图片
295
+ │ └─ 满幅场景 prompt 加 "full bleed, edge to edge, no vignette, no fade"
296
+ │
297
+ └─ 字段无明确约束,且用户未明确要求背景?
298
+ └─ background=transparent / --background transparent(包括卡牌、棋子和面板)
299
+ ├─ 白色牌面、边框与文字属于前景,必须保留,只移除本体外的画布背景
300
+ ├─ 常规工具 → 按模型准备源图背景(第 2 节)→ 原生透明或去背 → 最终透明验收
301
+ └─ 已明确选择独立色幕制作流程?
302
+ └─ 中间图 background=opaque → 单一色幕 → 切分后独立去背 → 深浅背景验证
303
+ ```
304
+
305
+ ### 为什么需要色幕策略?
306
+
307
+ 只有用户或已锁定的制作流程明确选择独立色幕制作,且所选模型不支持原生透明时才采用该流程;仅指定其他模型并不等于选择色幕。下方色幕矩阵和后缀表仅用于该流程与 ASR (Asset State Reference, 资产状态参考板),不能用作 Image 2.5 失败后的自动回退。原生透明图验证通过后直接处理尺寸,不再重复去背;发光、半透明边缘和白色前景应保留。白色背景与白色物体会让 floodfill 混淆边界。`playcraft image remove-background` 默认使用本地 floodfill,不应描述为必然调用后端去背模型。
308
+
309
+ 色幕**中间图**使用 `background: opaque` / `--background opaque`,让生成工具保留指定色幕,再独立去背;这不改变最终素材的透明交付要求。替换现有透明字段时,先用 `image-context` 读取参考图和交付规格,生成中间图时省略 `targetAssetPath` / `--target-asset`,显式传入已读取的参考图、尺寸与格式。字段的 `remove_background=true` 优先于调用开关,绑定该字段会提前触发自动去背;`--no-target-reference` 也不会解除字段约束。色幕去背及最终验收通过后再应用到目标字段。
310
+
311
+ ### 最终文件验证
312
+
313
+ - 按字段 resolution 处理尺寸,透明前景用 `--fit contain`,确认执行的工具使用透明补边;旧版工具可能补入不透明黑色。验证不通过时更新工具或显式使用透明背景缩放。
314
+ - 按实际资源扩展名编码,不把 PNG 内容写进其他格式的文件,也不擅自改变主题引用。
315
+ - 去背、缩放、转格式后都检查透明通道与边缘,并分别在深色和浅色背景上预览。允许素材自身的黑色描边,拒绝额外黑色矩形补边或误删的发光效果。
316
+ - 达到项目的文件大小限制后再覆盖目标文件。同一 Logo 的多个尺寸从同一张母图导出,避免重复生成导致风格漂移。
317
+
318
+ ### 色幕选型矩阵(Color Conflict Avoidance)
319
+
320
+ > ⚠️ **不要默认全用绿幕!** 金色素材 + 绿幕 = 绿色与金色色相接近,floodfill 会在边缘残留绿色,或误删金色像素。
321
+
322
+ | 素材主色调 | ❌ 禁用 | ✅ 推荐 | 原因 |
323
+ | --------------------- | ------- | ---------------- | ------------------------------------------ |
324
+ | 金色/黄色/橙色/琥珀色 | 绿幕 | **蓝幕 #0000FF** | 金色与绿色色相接近(黄绿区),边缘残留绿色 |
325
+ | 绿色/翠绿/青色 | 绿幕 | **蓝幕 #0000FF** | 同色系,无法区分边界 |
326
+ | 蓝色/靛蓝/紫色 | 蓝幕 | **绿幕 #00FF00** | 同色系冲突 |
327
+ | 红色/粉色/白色/黑色 | — | 绿幕或蓝幕均可 | 与两者色相距离都大 |
328
+ | 多色/彩虹 | — | **品红 #FF00FF** | 品红在自然素材中最少出现(最后手段) |
329
+
330
+ ### Prompt 后缀速查表
331
+
332
+ 下表的色幕后缀只用于已明确选择的独立色幕流程。卡牌、面板等最终交付仍按上方决策树选择;`skipRemoveBg` 只表示是否跳过独立去背步骤,不能据此把最终交付改为不透明。
333
+
334
+ | 素材类型 | prompt 建议后缀 | 后处理 | skipRemoveBg |
335
+ | --------------------------- | ------------------------------------------------------------------ | ------------------------------------------- | ----------------------- |
336
+ | 独立元素(需透明,非金色) | `"on solid bright green #00FF00 background, isolated, centered"` | remove-background (tolerance 25) → 深色验证 | `false` |
337
+ | 独立元素(金/黄/橙/绿色) | `"on solid bright blue #0000FF background, isolated, centered"` | remove-background (tolerance 25) → 深色验证 | `false` |
338
+ | 独立元素(多色/彩虹) | `"on solid bright magenta #FF00FF background, isolated, centered"` | remove-background (tolerance 20) → 深色验证 | `false` |
339
+ | VFX 特效(发光/粒子) | `"on solid bright blue #0000FF background, isolated, centered"` | remove-background (tolerance 25) → 逐帧验证 | `false` |
340
+ | 卡牌/棋子(矩形本体) | `"flat 2D, white card face, no shadow, clean edges"` | 默认透明画布,保留牌面;透明已验收后 resize | 仅透明已验收后为 `true` |
341
+ | UI 按钮/面板 | `"flat UI element, no shadow, clean edges"` | 默认透明画布;透明已验收后 trim + resize | 仅透明已验收后为 `true` |
342
+ | 用户/字段明确要求的场景背景 | `"full scene, full bleed, edge to edge, no vignette, no fade"` | 不透明交付 → resize → 四角全覆盖检查 | `true` |
343
+
344
+ ### 去背景后必做:深色背景渲证
345
+
346
+ > 每个需要透明的资产,去背景后**必须**在深色背景上叠合验证。这一步是防止白底/色幕残留/黑块的最后防线。
347
+
348
+ ```bash
349
+ playcraft image overlay \
350
+ --base ta-workspace/tmp/dark_verify_bg.png \
351
+ --overlay <processed>.png \
352
+ --output ta-workspace/tmp/verify_<name>.png \
353
+ --gravity center
354
+ # 目视检查:无白边、无色幕残留色、无黑色不透明块、边缘干净
355
+ ```
356
+
357
+ **不通过时的修复**:检查实际模型、源图背景和去背参数,保留原始图与失败回执;按下方进阶参考的错误恢复策略处理。透明验收仍失败时报告具体阶段并停止,不交付未通过的文件。
358
+
359
+ ---
360
+
361
+ ## 3.1 ASR 专用分支(Artist · ring 3 build)
362
+
363
+ > 先核对当前工程素材状态表中的槽位、状态和交付尺寸。ASR 是制作期参考板,不是 runtime 透明资产。
364
+
365
+ | 阶段 | Artist | TA |
366
+ | ----------------- | ------------------------------------- | ----------------------------- |
367
+ | ASR 整图 | **opaque**(灰底或统一色幕)— 正常 | — |
368
+ | ASR 格内元素 | **isolated** + 按色幕矩阵选 cell 背景 | `crop` 后 `remove-background` |
369
+ | remove-background | **禁止** — Artist 不做 | production Wave 2 |
370
+
371
+ **Artist ASR prompt 要点**:
372
+
373
+ 1. Sheet canvas:`solid flat #808080` 或整板统一绿幕(非渐变)
374
+ 生成整板时传 `--background opaque`,保留格子布局和色幕供后续裁切。
375
+ 2. 每格:`ONE isolated element, centered, NO white box, NO scene, NO ground shadow`
376
+ 3. 金/橙/黄/绿元素格 → cell 背景 `#0000FF`;蓝/紫 → `#00FF00`
377
+ 4. 生成后**目视**格内可抠性 — 不要求 `channels=4`(那是 TA 后处理产物)
378
+
379
+ ---
380
+
381
+ ## 4. 脚本决策
382
+
383
+ - **<=5 个文件** → 直接使用 CLI 命令
384
+ - **>5 个文件** → 编写 Node.js 脚本放入 `ta-workspace/scripts/`。脚本模板见 `reference/` 目录;使用本次选定的模型与参考图,不直接沿用脚本中旧的默认模型。
385
+
386
+ 复制模板时,`SKILL_DIR` 表示本次实际加载的 `SKILL.md` 所在目录,由技能加载回执确定。将示例中的该变量设为真实目录后再运行;项目安装与冻结安装的目录可能不同。
387
+
388
+ ---
389
+
390
+ ## 5. 进阶参考
391
+
392
+ 需要以下进阶内容时,查阅 [`reference/ta-image-generation-detail.md`](reference/ta-image-generation-detail.md):
393
+
394
+ | 主题 | 说明 |
395
+ | --------------------- | ---------------------------------------------------------------- |
396
+ | 精灵图直出策略 | 按选定模型生成网格图 + sprite-split 切分;自动透明与独立色幕示例 |
397
+ | Edit 模型工作流 | 基图 → edit 变体(换花色/换数字/换颜色),prompt 写法 |
398
+ | 错误恢复表 | 各类错误现象、原因、立即行动;模型回退顺序 |
399
+ | Provider 回退链 | gpt-image-2 三 provider 互为回退 + 非 gpt-image-2 稳定回退 |
400
+ | 批量生成最佳实践 | 单张验证、Node.js 脚本推荐、脚本模板使用 |
401
+ | ta-workspace 脚本驱动 | 为什么用 Node.js、目录约定、脚本模板一览表 |
@@ -0,0 +1,123 @@
1
+ // ============================================================
2
+ // build-sprite-sheet.template.mjs — 精灵图合并 + 验证脚本模板
3
+ // 用途:将处理好的图片目录合并为精灵图(PNG + JSON 元数据)
4
+ //
5
+ // 使用方式:
6
+ // 1. cp "$SKILL_DIR/reference/build-sprite-sheet.template.mjs" ta-workspace/scripts/build-<name>-atlas.mjs
7
+ // 2. 修改下方 CONFIG 区域
8
+ // 3. 如需控制帧顺序,填写 ORDERED_NAMES 数组(留空则按文件名排序)
9
+ // 4. node ta-workspace/scripts/build-<name>-atlas.mjs
10
+ // ============================================================
11
+
12
+ import { execSync } from 'child_process';
13
+ import { existsSync, readFileSync, readdirSync, mkdirSync, appendFileSync } from 'fs';
14
+ import { join, extname } from 'path';
15
+
16
+ // ============ CONFIG — 修改这里 ============
17
+ const CONFIG = {
18
+ /** 处理好的图片目录(process-batch 的输出目录) */
19
+ processedDir: 'assets/images/processed',
20
+ /** 输出文件路径(不含扩展名,会生成 .png 和 .json 两个文件) */
21
+ outputBase: 'assets/bundles/atlas',
22
+ /** 每行帧数 */
23
+ columns: 8,
24
+ /** 帧间距(像素) */
25
+ padding: 2,
26
+ /**
27
+ * 精灵图背景色
28
+ * - 'transparent'(默认):透明背景
29
+ * - 'white' / 'black' / '#RRGGBB':固定背景色
30
+ * 某些引擎(如 PlayCanvas)处理透明精灵图时可能显示为黑色,此时用 'white' 更安全
31
+ */
32
+ background: 'transparent',
33
+ /** 文件名排序方式:'name'(字母序)或 'custom'(使用 ORDERED_NAMES) */
34
+ sort: 'name',
35
+ };
36
+
37
+ /**
38
+ * 自定义帧顺序(CONFIG.sort = 'custom' 时生效)
39
+ * 填写不含扩展名的文件名,按期望顺序排列
40
+ * 示例(扑克牌):['spades_A', 'spades_2', 'spades_3', ...]
41
+ */
42
+ const ORDERED_NAMES = [
43
+ // 填写文件名(不含扩展名)...
44
+ ];
45
+ // ============ LOGIC — 通常不需要修改 ============
46
+
47
+ const LOG_FILE = 'ta-workspace/logs/build-sprite-sheet.log';
48
+ mkdirSync('ta-workspace/logs', { recursive: true });
49
+
50
+ function log(msg) {
51
+ const line = `[${new Date().toISOString()}] ${msg}`;
52
+ console.log(line);
53
+ appendFileSync(LOG_FILE, line + '\n');
54
+ }
55
+
56
+ // 收集输入文件
57
+ let inputFiles;
58
+ if (CONFIG.sort === 'custom' && ORDERED_NAMES.length > 0) {
59
+ // 自定义顺序:按 ORDERED_NAMES 排列,找不到的文件跳过并警告
60
+ inputFiles = [];
61
+ for (const name of ORDERED_NAMES) {
62
+ const candidates = ['.png', '.jpg', '.webp'].map(ext => join(CONFIG.processedDir, `${name}${ext}`));
63
+ const found = candidates.find(p => existsSync(p));
64
+ if (found) {
65
+ inputFiles.push(found);
66
+ } else {
67
+ log(`[WARN] Ordered file not found: ${name} (skipping)`);
68
+ }
69
+ }
70
+ } else {
71
+ // 文件名排序
72
+ inputFiles = readdirSync(CONFIG.processedDir)
73
+ .filter(f => ['.png', '.jpg', '.webp'].includes(extname(f).toLowerCase()))
74
+ .sort()
75
+ .map(f => join(CONFIG.processedDir, f));
76
+ }
77
+
78
+ if (inputFiles.length === 0) {
79
+ log('ERROR: No input files found in ' + CONFIG.processedDir);
80
+ process.exit(1);
81
+ }
82
+
83
+ log(`=== Build Sprite Sheet Start ===`);
84
+ log(`Frames: ${inputFiles.length} | Columns: ${CONFIG.columns} | Padding: ${CONFIG.padding} | BG: ${CONFIG.background}`);
85
+
86
+ // 构建 --inputs 参数列表
87
+ const inputsArg = inputFiles.map(p => `"${p}"`).join(' ');
88
+
89
+ const cmd =
90
+ `playcraft image sprite-sheet` +
91
+ ` --inputs ${inputsArg}` +
92
+ ` --output "${CONFIG.outputBase}"` +
93
+ ` --columns ${CONFIG.columns}` +
94
+ ` --padding ${CONFIG.padding}` +
95
+ (CONFIG.background !== 'transparent' ? ` --background "${CONFIG.background}"` : '');
96
+
97
+ log(`Running: playcraft image sprite-sheet ... --output ${CONFIG.outputBase}`);
98
+
99
+ try {
100
+ execSync(cmd, { stdio: 'inherit' });
101
+ } catch (e) {
102
+ log(`ERROR: sprite-sheet command failed: ${e.message}`);
103
+ process.exit(1);
104
+ }
105
+
106
+ // 验证输出
107
+ const pngPath = `${CONFIG.outputBase}.png`;
108
+ const jsonPath = `${CONFIG.outputBase}.json`;
109
+
110
+ if (!existsSync(pngPath) || !existsSync(jsonPath)) {
111
+ log('ERROR: Output files missing! Expected ' + pngPath + ' and ' + jsonPath);
112
+ process.exit(1);
113
+ }
114
+
115
+ const meta = JSON.parse(readFileSync(jsonPath, 'utf-8'));
116
+ const frameCount = Object.keys(meta.frames ?? {}).length;
117
+
118
+ log(`\n=== Sprite Sheet Built ===`);
119
+ log(` Frames : ${frameCount}`);
120
+ log(` PNG : ${pngPath}`);
121
+ log(` JSON : ${jsonPath}`);
122
+ log(` Columns : ${CONFIG.columns}`);
123
+ log(` Rows : ${Math.ceil(frameCount / CONFIG.columns)}`);