@playcraft/cli 0.1.51 → 0.1.53-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 (400) hide show
  1. package/README.md +62 -3
  2. package/SKILLS_REGISTRY.md +149 -0
  3. package/dist/agent/local-backend.js +1 -1
  4. package/dist/auth/account-activation.js +157 -0
  5. package/dist/auth/messages.js +30 -0
  6. package/dist/cli-root-help.js +2 -0
  7. package/dist/commands/build-all.js +5 -19
  8. package/dist/commands/build-temp.js +26 -0
  9. package/dist/commands/build.js +15 -28
  10. package/dist/commands/create.js +26 -33
  11. package/dist/commands/login.js +84 -42
  12. package/dist/commands/platform-skills.generated.js +19 -0
  13. package/dist/commands/playable.js +53 -0
  14. package/dist/commands/preview-runtime.js +21 -0
  15. package/dist/commands/skills.js +4 -0
  16. package/dist/commands/tools-3d.js +11 -0
  17. package/dist/commands/tools-batch.js +113 -0
  18. package/dist/commands/tools-generation.js +6 -0
  19. package/dist/commands/tools.js +2 -0
  20. package/dist/commands/video.js +122 -0
  21. package/dist/commands/workspace-runtime.js +54 -0
  22. package/dist/commands/workspace.js +40 -0
  23. package/dist/config.js +59 -4
  24. package/dist/index.js +42 -3
  25. package/dist/preview-runtime/distribution.js +77 -0
  26. package/dist/project-skills/builtin-import.js +225 -0
  27. package/dist/project-skills/commands.js +77 -0
  28. package/dist/project-skills/lifecycle.js +28 -0
  29. package/dist/project-skills/local-run.js +112 -0
  30. package/dist/project-skills/local-store.js +221 -0
  31. package/dist/project-skills/messages.js +80 -0
  32. package/dist/project-skills/reconcile.js +62 -0
  33. package/dist/project-skills/remote-cache.js +51 -0
  34. package/dist/project-skills/validation.js +19 -0
  35. package/dist/recording/messages.js +40 -0
  36. package/dist/recording/project-digest.js +85 -0
  37. package/dist/recording/recorder.js +293 -0
  38. package/dist/recording/scenario.js +50 -0
  39. package/dist/remix/clone.js +2 -0
  40. package/dist/remix/init-template.js +2 -0
  41. package/dist/remix/pull.js +2 -0
  42. package/dist/remix/push.js +21 -1
  43. package/dist/skill-registry/client.js +345 -0
  44. package/dist/skill-registry/commands.js +180 -0
  45. package/dist/skill-registry/evaluation-client.js +156 -0
  46. package/dist/skill-registry/evaluation-commands.js +174 -0
  47. package/dist/skill-registry/messages.js +177 -0
  48. package/dist/skill-registry/package.js +275 -0
  49. package/dist/skill-registry/platform-package.js +100 -0
  50. package/dist/utils/agent-api-client.js +210 -30
  51. package/dist/utils/environment-endpoints.js +17 -0
  52. package/dist/utils/error-diagnostics.js +20 -0
  53. package/dist/utils/playcraft-http-client.js +6 -4
  54. package/dist/utils/tool-operation-journal.js +124 -0
  55. package/dist/utils/video-evidence-git.js +81 -0
  56. package/dist/video-replication/client.js +234 -0
  57. package/dist/video-replication/comparison-evidence.js +149 -0
  58. package/dist/video-replication/comparison-files.js +57 -0
  59. package/dist/video-replication/comparison-log.js +72 -0
  60. package/dist/video-replication/comparison-messages.js +104 -0
  61. package/dist/video-replication/comparison-output.js +63 -0
  62. package/dist/video-replication/comparison-preflight.js +66 -0
  63. package/dist/video-replication/comparison.js +230 -0
  64. package/dist/video-replication/diagnostics.js +41 -0
  65. package/dist/video-replication/evidence.js +165 -0
  66. package/dist/video-replication/media.js +112 -0
  67. package/dist/video-replication/messages.js +97 -0
  68. package/dist/workspace/messages.js +67 -0
  69. package/dist/workspace/transfer-client.js +237 -0
  70. package/dist/workspace/transfer-errors.js +48 -0
  71. package/dist/workspace-runtime/batch/content-changes.js +30 -0
  72. package/dist/workspace-runtime/batch/control.js +86 -0
  73. package/dist/workspace-runtime/batch/deliver.js +173 -0
  74. package/dist/workspace-runtime/batch/freeze.js +101 -0
  75. package/dist/workspace-runtime/batch/generate.js +249 -0
  76. package/dist/workspace-runtime/batch/git.js +40 -0
  77. package/dist/workspace-runtime/batch/occupancy.js +8 -0
  78. package/dist/workspace-runtime/batch/policy.js +70 -0
  79. package/dist/workspace-runtime/batch/prepare.js +317 -0
  80. package/dist/workspace-runtime/batch/processes.js +72 -0
  81. package/dist/workspace-runtime/batch/records.js +113 -0
  82. package/dist/workspace-runtime/batch/routes.js +61 -0
  83. package/dist/workspace-runtime/batch/source-candidate.js +86 -0
  84. package/dist/workspace-runtime/batch/source-capture.js +146 -0
  85. package/dist/workspace-runtime/batch/source-failure.js +43 -0
  86. package/dist/workspace-runtime/batch/source-publish.js +130 -0
  87. package/dist/workspace-runtime/codex/app-server.js +1065 -0
  88. package/dist/workspace-runtime/codex/compact.js +46 -0
  89. package/dist/workspace-runtime/codex/config-toml.js +107 -0
  90. package/dist/workspace-runtime/codex/delivery-tools.js +144 -0
  91. package/dist/workspace-runtime/codex/jsonrpc-stdio.js +145 -0
  92. package/dist/workspace-runtime/codex/launcher-client.js +177 -0
  93. package/dist/workspace-runtime/codex/loopback.js +146 -0
  94. package/dist/workspace-runtime/codex/mcp-config.js +39 -0
  95. package/dist/workspace-runtime/codex/model-broker.js +263 -0
  96. package/dist/workspace-runtime/codex/native-adapter.js +9 -0
  97. package/dist/workspace-runtime/codex/permissions.js +79 -0
  98. package/dist/workspace-runtime/codex/thread-image.js +38 -0
  99. package/dist/workspace-runtime/codex/tool-response.js +10 -0
  100. package/dist/workspace-runtime/codex/ui-instructions.js +4 -0
  101. package/dist/workspace-runtime/codex/ui-tools.js +203 -0
  102. package/dist/workspace-runtime/codex/work-mode.js +15 -0
  103. package/dist/workspace-runtime/main.js +10 -0
  104. package/dist/workspace-runtime/persistence/journal.js +365 -0
  105. package/dist/workspace-runtime/persistence/native-subagents.js +162 -0
  106. package/dist/workspace-runtime/persistence/sqlite-client.js +77 -0
  107. package/dist/workspace-runtime/persistence/sqlite-worker.js +1161 -0
  108. package/dist/workspace-runtime/persistence/stopped-execution.js +77 -0
  109. package/dist/workspace-runtime/previews/diagnostics.js +44 -0
  110. package/dist/workspace-runtime/previews/output.js +36 -0
  111. package/dist/workspace-runtime/previews/publish.js +283 -0
  112. package/dist/workspace-runtime/previews/runtime-preview.js +251 -0
  113. package/dist/workspace-runtime/previews/single-file.js +43 -0
  114. package/dist/workspace-runtime/processes/managed-writes.js +69 -0
  115. package/dist/workspace-runtime/serve.js +441 -0
  116. package/dist/workspace-runtime/server/accept-operation.js +61 -0
  117. package/dist/workspace-runtime/server/asset-transfers.js +63 -0
  118. package/dist/workspace-runtime/server/auth.js +21 -0
  119. package/dist/workspace-runtime/server/connectivity.js +211 -0
  120. package/dist/workspace-runtime/server/desktop-host.js +429 -0
  121. package/dist/workspace-runtime/server/desktop-preview-config.js +81 -0
  122. package/dist/workspace-runtime/server/desktop-preview-service.js +157 -0
  123. package/dist/workspace-runtime/server/desktop-preview-static.js +53 -0
  124. package/dist/workspace-runtime/server/desktop-preview.js +189 -0
  125. package/dist/workspace-runtime/server/dispatch.js +1655 -0
  126. package/dist/workspace-runtime/server/endpoints.js +21 -0
  127. package/dist/workspace-runtime/server/execution-group.js +90 -0
  128. package/dist/workspace-runtime/server/http.js +1339 -0
  129. package/dist/workspace-runtime/server/lock.js +53 -0
  130. package/dist/workspace-runtime/server/operation-record.js +33 -0
  131. package/dist/workspace-runtime/server/rfb-watch-gate.js +168 -0
  132. package/dist/workspace-runtime/server/session-restore.js +84 -0
  133. package/dist/workspace-runtime/server/source-uploader.js +138 -0
  134. package/dist/workspace-runtime/server/submit-operation.js +41 -0
  135. package/dist/workspace-runtime/server/terminal-host.js +366 -0
  136. package/dist/workspace-runtime/server/types.js +1 -0
  137. package/dist/workspace-runtime/server/workspace-transfer.js +168 -0
  138. package/dist/workspace-runtime/verify-artifact.js +59 -0
  139. package/dist/workspace-runtime/workspaces/append-only-log.js +62 -0
  140. package/dist/workspace-runtime/workspaces/archive.js +207 -0
  141. package/dist/workspace-runtime/workspaces/artifact-events.js +55 -0
  142. package/dist/workspace-runtime/workspaces/artifact-files.js +199 -0
  143. package/dist/workspace-runtime/workspaces/artifact-receipts.js +89 -0
  144. package/dist/workspace-runtime/workspaces/artifacts.js +282 -0
  145. package/dist/workspace-runtime/workspaces/asset-library-import.js +387 -0
  146. package/dist/workspace-runtime/workspaces/asset-publication-access.js +25 -0
  147. package/dist/workspace-runtime/workspaces/asset-transfer-dependencies.js +81 -0
  148. package/dist/workspace-runtime/workspaces/asset-transfer-publish.js +438 -0
  149. package/dist/workspace-runtime/workspaces/asset-transfer-storage.js +389 -0
  150. package/dist/workspace-runtime/workspaces/attachment-content.js +73 -0
  151. package/dist/workspace-runtime/workspaces/attachments.js +185 -0
  152. package/dist/workspace-runtime/workspaces/batch-commit.js +142 -0
  153. package/dist/workspace-runtime/workspaces/binary-content.js +65 -0
  154. package/dist/workspace-runtime/workspaces/binary-write.js +117 -0
  155. package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
  156. package/dist/workspace-runtime/workspaces/cli-credentials.js +115 -0
  157. package/dist/workspace-runtime/workspaces/composer-context.js +147 -0
  158. package/dist/workspace-runtime/workspaces/context-error.js +2 -0
  159. package/dist/workspace-runtime/workspaces/delivery-build.js +331 -0
  160. package/dist/workspace-runtime/workspaces/delivery-store.js +168 -0
  161. package/dist/workspace-runtime/workspaces/delivery.js +64 -0
  162. package/dist/workspace-runtime/workspaces/dependencies.js +279 -0
  163. package/dist/workspace-runtime/workspaces/developer-command.js +98 -0
  164. package/dist/workspace-runtime/workspaces/directories.js +132 -0
  165. package/dist/workspace-runtime/workspaces/directory-access.js +37 -0
  166. package/dist/workspace-runtime/workspaces/directory-attachments.js +245 -0
  167. package/dist/workspace-runtime/workspaces/directory-create.js +57 -0
  168. package/dist/workspace-runtime/workspaces/directory-maintenance.js +111 -0
  169. package/dist/workspace-runtime/workspaces/directory-mutations.js +238 -0
  170. package/dist/workspace-runtime/workspaces/directory-revisions.js +56 -0
  171. package/dist/workspace-runtime/workspaces/directory-stats.js +49 -0
  172. package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
  173. package/dist/workspace-runtime/workspaces/empty-template.js +42 -0
  174. package/dist/workspace-runtime/workspaces/file-content.js +48 -0
  175. package/dist/workspace-runtime/workspaces/files-search.js +116 -0
  176. package/dist/workspace-runtime/workspaces/files.js +150 -0
  177. package/dist/workspace-runtime/workspaces/git-credential-broker.js +312 -0
  178. package/dist/workspace-runtime/workspaces/git-credential-helper.js +68 -0
  179. package/dist/workspace-runtime/workspaces/git-direct-store.js +155 -0
  180. package/dist/workspace-runtime/workspaces/git.js +670 -0
  181. package/dist/workspace-runtime/workspaces/instructions.js +56 -0
  182. package/dist/workspace-runtime/workspaces/json5-edit.js +313 -0
  183. package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
  184. package/dist/workspace-runtime/workspaces/operation-log.js +23 -0
  185. package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
  186. package/dist/workspace-runtime/workspaces/parameter-agent-inputs.js +97 -0
  187. package/dist/workspace-runtime/workspaces/parameter-agent-protocol.js +40 -0
  188. package/dist/workspace-runtime/workspaces/parameter-agent-store.js +58 -0
  189. package/dist/workspace-runtime/workspaces/parameter-agent.js +284 -0
  190. package/dist/workspace-runtime/workspaces/parameter-assets.js +189 -0
  191. package/dist/workspace-runtime/workspaces/parameters.js +329 -0
  192. package/dist/workspace-runtime/workspaces/prepare.js +278 -0
  193. package/dist/workspace-runtime/workspaces/registry.js +251 -0
  194. package/dist/workspace-runtime/workspaces/remix-references.js +301 -0
  195. package/dist/workspace-runtime/workspaces/revisions.js +31 -0
  196. package/dist/workspace-runtime/workspaces/session-image.js +104 -0
  197. package/dist/workspace-runtime/workspaces/shared-git.js +40 -0
  198. package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +95 -0
  199. package/dist/workspace-runtime/workspaces/skills.js +191 -0
  200. package/dist/workspace-runtime/workspaces/theme-asset-index.js +157 -0
  201. package/dist/workspace-runtime/workspaces/transfer-quota.js +69 -0
  202. package/dist/workspace-runtime/workspaces/transfer.js +471 -0
  203. package/dist/workspace-runtime/workspaces/turn-changes.js +75 -0
  204. package/dist/workspace-runtime/workspaces/video-attachments.js +49 -0
  205. package/package.json +15 -5
  206. package/project-template/.claude/skills/playcraft-replica-validation/SKILL.md +25 -0
  207. package/project-template/.claude/skills/playcraft-replica-validation/references/contracts.md +79 -0
  208. package/project-template/.claude/skills/playcraft-video-understanding/SKILL.md +29 -0
  209. package/project-template/.claude/skills/playcraft-video-understanding/references/contracts.md +37 -0
  210. package/project-template-v2/.claude/agents/artist.md +82 -0
  211. package/project-template-v2/.claude/agents/developer.md +153 -0
  212. package/project-template-v2/.claude/agents/game-designer.md +264 -0
  213. package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
  214. package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
  215. package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
  216. package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
  217. package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
  218. package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
  219. package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
  220. package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
  221. package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
  222. package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
  223. package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
  224. package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  225. package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  226. package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
  227. package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  228. package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
  229. package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
  230. package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  231. package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
  232. package/project-template-v2/.claude/agents/reviewer.md +75 -0
  233. package/project-template-v2/.claude/agents/technical-artist.md +86 -0
  234. package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
  235. package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
  236. package/project-template-v2/.claude/settings.json +33 -0
  237. package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
  238. package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
  239. package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
  240. package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
  241. package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
  242. package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
  243. package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
  244. package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  245. package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
  246. package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  247. package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  248. package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
  249. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  250. package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  251. package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  252. package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +370 -0
  253. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  254. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  255. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +333 -0
  256. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +95 -0
  257. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  258. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +136 -0
  259. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  260. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  261. package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  262. package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +219 -0
  263. package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
  264. package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
  265. package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
  266. package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
  267. package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  268. package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
  269. package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
  270. package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  271. package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  272. package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  273. package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  274. package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
  275. package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  276. package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  277. package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  278. package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
  279. package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
  280. package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
  281. package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  282. package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
  283. package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
  284. package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
  285. package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
  286. package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
  287. package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
  288. package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
  289. package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
  290. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
  291. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
  292. package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
  293. package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
  294. package/project-template-v2/.claude/snapshot.mjs +263 -0
  295. package/project-template-v2/.playcraft/skills.lock.json +152 -0
  296. package/project-template-v2/CLAUDE.md +146 -0
  297. package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
  298. package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
  299. package/project-template-v2/assets/bundles/.gitkeep +0 -0
  300. package/project-template-v2/assets/images/bg/.gitkeep +0 -0
  301. package/project-template-v2/assets/images/reference/.gitkeep +0 -0
  302. package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
  303. package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
  304. package/project-template-v2/assets/images/ui/.gitkeep +0 -0
  305. package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
  306. package/project-template-v2/assets/models/.gitkeep +0 -0
  307. package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
  308. package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
  309. package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
  310. package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
  311. package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
  312. package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
  313. package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
  314. package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
  315. package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
  316. package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
  317. package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
  318. package/project-template-v2/docs/project-state.json +60 -0
  319. package/project-template-v2/docs/project-state.md +72 -0
  320. package/project-template-v2/docs/standards/README.md +225 -0
  321. package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
  322. package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
  323. package/project-template-v2/docs/standards/artifacts/design.md +22 -0
  324. package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
  325. package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
  326. package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
  327. package/project-template-v2/game/index.ts +18 -0
  328. package/project-template-v2/globals.d.ts +51 -0
  329. package/project-template-v2/index.css +34 -0
  330. package/project-template-v2/index.html +18 -0
  331. package/project-template-v2/main.ts +9 -0
  332. package/project-template-v2/package.json +46 -0
  333. package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
  334. package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
  335. package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
  336. package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
  337. package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
  338. package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
  339. package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
  340. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
  341. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
  342. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
  343. package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
  344. package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
  345. package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
  346. package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
  347. package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
  348. package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
  349. package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
  350. package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
  351. package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
  352. package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
  353. package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
  354. package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
  355. package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
  356. package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
  357. package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
  358. package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
  359. package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
  360. package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
  361. package/project-template-v2/skills/playable-record/SKILL.md +140 -0
  362. package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
  363. package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
  364. package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
  365. package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
  366. package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
  367. package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
  368. package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
  369. package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
  370. package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
  371. package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
  372. package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
  373. package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
  374. package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
  375. package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
  376. package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
  377. package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
  378. package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
  379. package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
  380. package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
  381. package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
  382. package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
  383. package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
  384. package/project-template-v2/tsconfig.json +20 -0
  385. package/project-template-v2/vite.config.ts +27 -0
  386. package/project-templates/batch-locks/phaser.yaml +922 -0
  387. package/project-templates/batch-locks/threejs.yaml +978 -0
  388. package/project-templates/empty/AGENTS.md +41 -0
  389. package/project-templates/empty/gitignore +33 -0
  390. package/templates/preview-runtime/v1/README.md +71 -0
  391. package/templates/preview-runtime/v1/build-preview.mjs +1324 -0
  392. package/templates/preview-runtime/v1/manifest.json +17 -0
  393. package/templates/preview-runtime/v1/release-guard.mjs +87 -0
  394. package/templates/preview-runtime/v1/runtime.d.mts +3 -0
  395. package/templates/preview-runtime/v1/runtime.d.ts +3 -0
  396. package/templates/preview-runtime/v1/runtime.mjs +1121 -0
  397. package/templates/preview-runtime/v1/types/adapters.d.ts +26 -0
  398. package/templates/preview-runtime/v1/types/preview.d.ts +23 -0
  399. package/templates/preview-runtime/v1/types/protocol.d.ts +94 -0
  400. package/templates/preview-runtime/v1/types/runtime.d.ts +14 -0
@@ -0,0 +1,254 @@
1
+ /**
2
+ * compare-style.template.mjs
3
+ *
4
+ * 色彩风格一致性定量检查脚本。
5
+ * 用途:TA Micro-Batch Validation 辅助工具,对 AI 补全素材与 Artist 样本做客观色彩比较。
6
+ *
7
+ * 使用方法:
8
+ * cp .claude/skills/playcraft-image-generation/reference/compare-style.template.mjs \
9
+ * ta-workspace/scripts/compare-style.mjs
10
+ * # 修改下方 CONFIG 区域后运行:
11
+ * node ta-workspace/scripts/compare-style.mjs
12
+ *
13
+ * 输出示例:
14
+ * [COMPARE] tile_sample_1.png vs tile_comp_01.png
15
+ * 色相距离(加权): 8.3° → ✅ 优秀(< 15°)
16
+ * 明度差异: 0.06 → ✅ 优秀(< 0.10)
17
+ * 饱和度差异: 0.04 → ✅ 优秀(< 0.10)
18
+ * 综合一致性评分: 4.7 / 5 → ✅ 通过(≥ 3.0)
19
+ *
20
+ * 依赖:@gltf-transform/core(CLI 已内置)、sharp(CLI 已内置)
21
+ * 若 sharp 未全局可用,运行前:npm install sharp --no-save
22
+ */
23
+
24
+ import { execSync } from 'child_process';
25
+ import { existsSync, mkdirSync, appendFileSync } from 'fs';
26
+ import path from 'path';
27
+
28
+ // ─── CONFIG ───────────────────────────────────────────────────────────────────
29
+
30
+ const CONFIG = {
31
+ /** Artist 样本图(风格基准) */
32
+ referenceImage: 'assets/images/tiles/tile_sample_1.png',
33
+
34
+ /** 要检查的 TA 补全素材目录或文件列表 */
35
+ targetDir: 'assets/images/tiles',
36
+
37
+ /** 只检查该目录下的哪些文件(glob 后缀匹配) */
38
+ targetGlob: '.png',
39
+
40
+ /** 排除文件名包含这些关键词的文件(Artist 样本自身) */
41
+ excludeKeywords: ['sample', 'concept', 'selected', 'storyboard'],
42
+
43
+ /** 日志输出路径 */
44
+ logFile: 'ta-workspace/logs/style-compare.log',
45
+
46
+ /** 评分阈值(低于此值输出警告) */
47
+ warnThreshold: 3.0,
48
+ };
49
+
50
+ // ─── HELPERS ──────────────────────────────────────────────────────────────────
51
+
52
+ /**
53
+ * 用 playcraft image info 提取图片的 dominant colors(HSL 列表)
54
+ * 返回格式:[{ h, s, l, weight }](weight 为面积占比估算)
55
+ */
56
+ function extractDominantColors(imagePath) {
57
+ try {
58
+ const raw = execSync(
59
+ `playcraft image info --input "${imagePath}" --json`,
60
+ { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }
61
+ );
62
+ const info = JSON.parse(raw);
63
+
64
+ // playcraft image info 返回 dominantColors 数组:[{ r, g, b, hex, percent }]
65
+ const colors = (info.dominantColors || []).slice(0, 5);
66
+ return colors.map(c => {
67
+ const hsl = rgbToHsl(c.r, c.g, c.b);
68
+ return { ...hsl, weight: (c.percent || 20) / 100 };
69
+ });
70
+ } catch {
71
+ return [];
72
+ }
73
+ }
74
+
75
+ function rgbToHsl(r, g, b) {
76
+ r /= 255; g /= 255; b /= 255;
77
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
78
+ const l = (max + min) / 2;
79
+ if (max === min) return { h: 0, s: 0, l };
80
+ const d = max - min;
81
+ const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
82
+ let h;
83
+ switch (max) {
84
+ case r: h = ((g - b) / d + (g < b ? 6 : 0)) / 6; break;
85
+ case g: h = ((b - r) / d + 2) / 6; break;
86
+ default: h = ((r - g) / d + 4) / 6;
87
+ }
88
+ return { h: h * 360, s, l };
89
+ }
90
+
91
+ /**
92
+ * 计算两组 dominant colors 之间的加权色相距离(°)
93
+ * 色相距离取最短弧(0–180°)
94
+ */
95
+ function weightedHueDist(colorsA, colorsB) {
96
+ if (!colorsA.length || !colorsB.length) return 999;
97
+ let totalDist = 0, totalWeight = 0;
98
+ for (const a of colorsA) {
99
+ // 找 B 中色相最近的颜色
100
+ let minDist = Infinity;
101
+ for (const b of colorsB) {
102
+ const raw = Math.abs(a.h - b.h);
103
+ const dist = raw > 180 ? 360 - raw : raw;
104
+ if (dist < minDist) minDist = dist;
105
+ }
106
+ totalDist += minDist * a.weight;
107
+ totalWeight += a.weight;
108
+ }
109
+ return totalWeight > 0 ? totalDist / totalWeight : 999;
110
+ }
111
+
112
+ /**
113
+ * 计算明度 / 饱和度的加权平均差异(0–1)
114
+ */
115
+ function weightedChannelDiff(colorsA, colorsB, channel) {
116
+ if (!colorsA.length || !colorsB.length) return 1;
117
+ const avgA = colorsA.reduce((s, c) => s + c[channel] * c.weight, 0) /
118
+ colorsA.reduce((s, c) => s + c.weight, 0);
119
+ const avgB = colorsB.reduce((s, c) => s + c[channel] * c.weight, 0) /
120
+ colorsB.reduce((s, c) => s + c.weight, 0);
121
+ return Math.abs(avgA - avgB);
122
+ }
123
+
124
+ /**
125
+ * 综合一致性评分 1–5
126
+ *
127
+ * 评分规则(与 playcraft-style-qa Micro-Batch 标准对齐):
128
+ * 色相距离 < 15° 且 明度/饱和度差 < 0.10 → 5 分
129
+ * 色相距离 < 20° 且 明度/饱和度差 < 0.15 → 4 分
130
+ * 色相距离 < 30° 且 明度/饱和度差 < 0.20 → 3 分(勉强可接受)
131
+ * 色相距离 < 45° 且 明度/饱和度差 < 0.30 → 2 分(需调整)
132
+ * 其他 → 1 分(停止,提问 Artist)
133
+ */
134
+ function calcScore(hueDist, lightDiff, satDiff) {
135
+ const channelOk = Math.max(lightDiff, satDiff);
136
+ if (hueDist < 15 && channelOk < 0.10) return 5;
137
+ if (hueDist < 20 && channelOk < 0.15) return 4;
138
+ if (hueDist < 30 && channelOk < 0.20) return 3;
139
+ if (hueDist < 45 && channelOk < 0.30) return 2;
140
+ return 1;
141
+ }
142
+
143
+ function scoreLabel(score) {
144
+ if (score >= 4) return '✅ 良好';
145
+ if (score >= 3) return '⚠️ 可接受';
146
+ return '❌ 偏差过大,需停止';
147
+ }
148
+
149
+ function hueLabel(dist) {
150
+ if (dist < 15) return '✅ 优秀(< 15°)';
151
+ if (dist < 30) return '⚠️ 偏差(< 30°)';
152
+ return '❌ 严重偏差(≥ 30°)';
153
+ }
154
+
155
+ function channelLabel(diff) {
156
+ if (diff < 0.10) return '✅ 优秀(< 0.10)';
157
+ if (diff < 0.20) return '⚠️ 偏差(< 0.20)';
158
+ return '❌ 严重偏差(≥ 0.20)';
159
+ }
160
+
161
+ // ─── MAIN ─────────────────────────────────────────────────────────────────────
162
+
163
+ async function main() {
164
+ const logDir = path.dirname(CONFIG.logFile);
165
+ if (!existsSync(logDir)) mkdirSync(logDir, { recursive: true });
166
+
167
+ const refPath = CONFIG.referenceImage;
168
+ if (!existsSync(refPath)) {
169
+ console.error(`[ERROR] 参考图不存在: ${refPath}`);
170
+ process.exit(1);
171
+ }
172
+
173
+ console.log(`\n📊 色彩风格一致性检查`);
174
+ console.log(` 参考图: ${refPath}\n`);
175
+
176
+ const refColors = extractDominantColors(refPath);
177
+ if (!refColors.length) {
178
+ console.error('[ERROR] 无法从参考图提取颜色,请确认 playcraft image info 可用');
179
+ process.exit(1);
180
+ }
181
+
182
+ // 收集目标文件
183
+ let targets = [];
184
+ try {
185
+ const { readdirSync } = await import('fs');
186
+ targets = readdirSync(CONFIG.targetDir)
187
+ .filter(f => f.endsWith(CONFIG.targetGlob))
188
+ .filter(f => !CONFIG.excludeKeywords.some(kw => f.includes(kw)))
189
+ .map(f => path.join(CONFIG.targetDir, f));
190
+ } catch {
191
+ console.error(`[ERROR] 无法读取目录: ${CONFIG.targetDir}`);
192
+ process.exit(1);
193
+ }
194
+
195
+ if (!targets.length) {
196
+ console.log(' 未找到需要检查的目标文件');
197
+ return;
198
+ }
199
+
200
+ const results = [];
201
+ let failCount = 0;
202
+
203
+ for (const target of targets) {
204
+ const targetColors = extractDominantColors(target);
205
+ if (!targetColors.length) {
206
+ console.log(` [SKIP] ${path.basename(target)} — 无法提取颜色`);
207
+ continue;
208
+ }
209
+
210
+ const hueDist = weightedHueDist(refColors, targetColors);
211
+ const lightDiff = weightedChannelDiff(refColors, targetColors, 'l');
212
+ const satDiff = weightedChannelDiff(refColors, targetColors, 's');
213
+ const score = calcScore(hueDist, lightDiff, satDiff);
214
+
215
+ if (score < CONFIG.warnThreshold) failCount++;
216
+
217
+ const line = [
218
+ `[COMPARE] ${path.basename(refPath)} vs ${path.basename(target)}`,
219
+ ` 色相距离(加权): ${hueDist.toFixed(1)}° → ${hueLabel(hueDist)}`,
220
+ ` 明度差异: ${lightDiff.toFixed(2)} → ${channelLabel(lightDiff)}`,
221
+ ` 饱和度差异: ${satDiff.toFixed(2)} → ${channelLabel(satDiff)}`,
222
+ ` 综合一致性评分: ${score} / 5 → ${scoreLabel(score)}`,
223
+ '',
224
+ ].join('\n');
225
+
226
+ console.log(line);
227
+ results.push({ file: path.basename(target), score, hueDist, lightDiff, satDiff });
228
+ }
229
+
230
+ // 汇总
231
+ const avgScore = results.reduce((s, r) => s + r.score, 0) / (results.length || 1);
232
+ const summary = [
233
+ `=== 汇总 ===`,
234
+ ` 检查文件数: ${results.length}`,
235
+ ` 平均评分: ${avgScore.toFixed(1)} / 5`,
236
+ ` 低于阈值数: ${failCount}(阈值 ${CONFIG.warnThreshold})`,
237
+ failCount > 0
238
+ ? ` ⚠️ 建议:停止低分文件类型的批量生产,调整生成参数或向 Artist 提问 ICP`
239
+ : ` ✅ 全部通过,可继续批量生产`,
240
+ '',
241
+ ].join('\n');
242
+
243
+ console.log(summary);
244
+
245
+ // 写日志
246
+ const timestamp = new Date().toISOString();
247
+ appendFileSync(CONFIG.logFile, `\n[${timestamp}]\n${results.map(r =>
248
+ `${r.file}: score=${r.score} hue=${r.hueDist.toFixed(1)}° L=${r.lightDiff.toFixed(2)} S=${r.satDiff.toFixed(2)}`
249
+ ).join('\n')}\n${summary}`);
250
+
251
+ if (failCount > 0) process.exit(1);
252
+ }
253
+
254
+ main().catch(e => { console.error(e); process.exit(1); });
@@ -0,0 +1,333 @@
1
+ // ============================================================
2
+ // gen-batch-sprite.template.mjs — 精灵图直出脚本模板
3
+ //
4
+ // 核心原则:一次 API (Application Programming Interface, 应用程序编程接口) 调用生成包含多个元素的
5
+ // 网格精灵图,然后用 sprite-split 切分。比逐个生成效率高 N 倍。
6
+ //
7
+ // 适用场景:
8
+ // - 卡牌(扑克/麻将/游戏卡):一批 13 张以内
9
+ // - 图标集:一批 9-16 张以内
10
+ // - 数字/字母贴图:一批 ≤16 个
11
+ //
12
+ // 使用方式:
13
+ // 1. cp .claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs ta-workspace/scripts/gen-<name>-sprite.mjs
14
+ // 2. 修改下方 CONFIG 和 BATCHES 区域
15
+ // 3. node ta-workspace/scripts/gen-<name>-sprite.mjs
16
+ // ============================================================
17
+
18
+ import { execFileSync } from 'child_process';
19
+ import { existsSync, mkdirSync, appendFileSync, copyFileSync } from 'fs';
20
+
21
+ /**
22
+ * Run the `playcraft` CLI with an argv ARRAY (never a shell string), so prompts
23
+ * and paths containing $(), backticks, quotes, spaces, backslashes, etc. are
24
+ * passed verbatim and cannot be reinterpreted by a shell.
25
+ * - capture:true → returns stdout (utf8); otherwise inherits stdio.
26
+ */
27
+ function playcraft(args, { capture = false, timeout } = {}) {
28
+ return execFileSync('playcraft', args, {
29
+ ...(capture ? { encoding: 'utf8' } : { stdio: 'inherit' }),
30
+ ...(timeout ? { timeout } : {}),
31
+ });
32
+ }
33
+
34
+ // ============ CONFIG — 修改这里 ============
35
+ const CONFIG = {
36
+ /**
37
+ * 使用 list-image-models 核实本次模型;默认示例为 Image 2.5。
38
+ * 用户或制作流程锁定其他模型时填写实际 provider/model。
39
+ * 请求使用命令行默认等待时间,不在脚本中提前杀死仍在运行的请求。
40
+ */
41
+ model: 'iegg-litellm/gpt-image-2.5-sunburst',
42
+
43
+ /**
44
+ * 每批精灵图的列数
45
+ * 行数由 items.length / columns 自动计算。
46
+ * 推荐:每批 ≤16 个元素(如 columns=4 则每批最多 4 行),超过会出现混乱。
47
+ */
48
+ columns: 4,
49
+
50
+ /**
51
+ * 宽高比:根据 columns/rows 比例选择
52
+ * - 1:1 → 4×4 方形网格
53
+ * - 3:2 → 4×3 横向网格(4列3行)
54
+ * - 2:3 → 3×4 纵向网格(3列4行)
55
+ * - 16:9 → 适合宽横向布局
56
+ */
57
+ aspectRatio: '1:1',
58
+
59
+ /** 生成的精灵图输出目录 */
60
+ sheetDir: 'assets/gen/sheets',
61
+ /** sprite-split 切分后的单图输出目录 */
62
+ outputDir: 'assets/images/batch',
63
+
64
+ /**
65
+ * 通用风格描述(追加到每个批次 prompt 末尾)
66
+ *
67
+ * 只填写主体风格与构图,源图背景由下方流程选择。
68
+ * 卡牌白色牌面属于主体,应在 items.desc 中描述并设 removeBg=false。
69
+ */
70
+ style: 'flat 2D illustration, isolated subjects, centered, no shadow',
71
+ /**
72
+ * 最终是否需要透明:true 为独立元素,false 为不透明牌面/场景。
73
+ * automatic:整板由工具交付透明,切分后保留,不重复去背。
74
+ * chroma:保留色幕中间图,切分后逐格去背;仅限主文第 3 节明确选择的流程。
75
+ */
76
+ removeBg: true,
77
+ backgroundMode: 'automatic',
78
+ /** 独立色幕才使用;按主体颜色选择,金/黄/橙/绿用蓝幕,蓝/紫用绿幕。 */
79
+ chromaColor: '#00FF00',
80
+ chromaTolerance: 25,
81
+
82
+ /**
83
+ * 切分单元尺寸(像素)。留空(null)= 自动按精灵图实际像素尺寸 ÷ 网格推导(推荐)。
84
+ * 仅当模型输出的格子并非均匀均分、需要手动指定时才填写。
85
+ * ⚠️ 不要写死 256:4K 精灵图按 256 切分会严重错位。
86
+ */
87
+ cellWidth: null,
88
+ cellHeight: null,
89
+ /** 帧间距(像素),默认 0 */
90
+ padding: 0,
91
+ };
92
+
93
+ // ============ DATA — 分批定义元素 ============
94
+ // 规则:每批 ≤ CONFIG.columns × CONFIG.rows 个元素
95
+ // 每个元素必须有 name(输出文件名)和 desc(精灵图中该格的内容描述)
96
+ const BATCHES = [
97
+ {
98
+ sheetName: 'sheet_batch_1',
99
+ items: [
100
+ { name: 'item_01', desc: '<格 1 内容描述>' },
101
+ { name: 'item_02', desc: '<格 2 内容描述>' },
102
+ { name: 'item_03', desc: '<格 3 内容描述>' },
103
+ { name: 'item_04', desc: '<格 4 内容描述>' },
104
+ // 最多 CONFIG.columns × CONFIG.rows 个
105
+ ],
106
+ },
107
+ {
108
+ sheetName: 'sheet_batch_2',
109
+ items: [
110
+ { name: 'item_05', desc: '<格 5 内容描述>' },
111
+ { name: 'item_06', desc: '<格 6 内容描述>' },
112
+ // ...
113
+ ],
114
+ },
115
+ // 继续添加批次...
116
+ ];
117
+
118
+ // ============ 精灵图 Prompt 构建器 ============
119
+ /**
120
+ * 根据 items 列表构建精灵图网格 prompt
121
+ * 描述网格布局,避免重绘边框或格子标签。
122
+ */
123
+ /**
124
+ * 读取精灵图实际像素尺寸(用于自动推导切分单元尺寸)。
125
+ * 失败返回 null,由调用方决定是否中止该批次。
126
+ */
127
+ function readSheetDims(sheetPath) {
128
+ try {
129
+ const out = playcraft(['image', 'info', '--input', sheetPath, '--json'], { capture: true });
130
+ const meta = JSON.parse(out.slice(out.indexOf('{')));
131
+ if (typeof meta.width === 'number' && typeof meta.height === 'number') {
132
+ return { width: meta.width, height: meta.height };
133
+ }
134
+ } catch {
135
+ // fall through → null
136
+ }
137
+ return null;
138
+ }
139
+
140
+ function buildSpriteSheetPrompt(items, columns, config) {
141
+ const actualRows = Math.ceil(items.length / columns);
142
+ const cellDescs = items.map((item, i) => {
143
+ const col = (i % columns) + 1;
144
+ const row = Math.floor(i / columns) + 1;
145
+ return `[Row${row},Col${col}]: ${item.desc}`;
146
+ }).join('; ');
147
+
148
+ // Image 2.5 由后端组装背景;其他模型首次请求需明确单一干净底色。
149
+ const modelId = config.model.trim().split('/').at(-1);
150
+ const nativeBackground = /^gpt-image-2\.5(?:$|-)/.test(modelId);
151
+ const bgInstruction = !config.removeBg ? '' : config.backgroundMode === 'chroma'
152
+ ? `Each element isolated on a uniform solid ${config.chromaColor} background, no shadow, no gradient background.`
153
+ : nativeBackground ? ''
154
+ : 'Render all foreground elements on a uniform solid pure white background for subsequent background removal. Preserve all elements, text, white details, colors and style.';
155
+
156
+ return [
157
+ `Sprite sheet grid layout, ${columns} columns × ${actualRows} rows.`,
158
+ `Each cell contains one element. Cell contents: ${cellDescs}.`,
159
+ bgInstruction,
160
+ `Grid layout, uniform cell size, equal spacing, elements perfectly centered in each cell.`,
161
+ `No borders between cells, no labels, no numbers on cells.`,
162
+ config.style,
163
+ ].filter(Boolean).join(' ');
164
+ }
165
+
166
+ // ============ LOGIC — 通常不需要修改 ============
167
+
168
+ const LOG_FILE = 'ta-workspace/logs/gen-batch-sprite.log';
169
+ if (!['automatic', 'chroma'].includes(CONFIG.backgroundMode)) {
170
+ throw new Error('backgroundMode must be automatic or chroma.');
171
+ }
172
+ if (CONFIG.backgroundMode === 'chroma' && !/^#[\da-f]{6}$/i.test(CONFIG.chromaColor)) {
173
+ throw new Error('chromaColor must be one six-digit hex color.');
174
+ }
175
+ mkdirSync(CONFIG.sheetDir, { recursive: true });
176
+ mkdirSync(CONFIG.outputDir, { recursive: true });
177
+ mkdirSync('ta-workspace/logs', { recursive: true });
178
+
179
+ function log(msg) {
180
+ const line = `[${new Date().toISOString()}] ${msg}`;
181
+ console.log(line);
182
+ appendFileSync(LOG_FILE, line + '\n');
183
+ }
184
+
185
+ const totalElements = BATCHES.reduce((s, b) => s + b.items.length, 0);
186
+ log(`=== Batch Sprite Generation Start ===`);
187
+ log(`Total: ${BATCHES.length} batches, ${totalElements} elements`);
188
+ log(`Model: ${CONFIG.model}`);
189
+
190
+ let doneBatches = 0, failedBatches = 0;
191
+
192
+ for (let bi = 0; bi < BATCHES.length; bi++) {
193
+ const batch = BATCHES[bi];
194
+ const sheetPath = `${CONFIG.sheetDir}/${batch.sheetName}.png`;
195
+
196
+ // ── Step 1: 生成精灵图(幂等跳过)────────────────────────────────
197
+ if (existsSync(sheetPath)) {
198
+ log(`[SKIP-SHEET] (${bi + 1}/${BATCHES.length}) ${batch.sheetName} already exists`);
199
+ } else {
200
+ log(`[GEN-SHEET ] (${bi + 1}/${BATCHES.length}) Generating ${batch.sheetName} (${batch.items.length} elements)`);
201
+ const prompt = buildSpriteSheetPrompt(batch.items, CONFIG.columns, CONFIG);
202
+
203
+ try {
204
+ playcraft(
205
+ [
206
+ 'tools', 'generate-image',
207
+ '--prompt', prompt,
208
+ '--output', sheetPath,
209
+ '--aspect-ratio', CONFIG.aspectRatio,
210
+ '--image-model', CONFIG.model,
211
+ CONFIG.removeBg && CONFIG.backgroundMode === 'automatic'
212
+ ? '--remove-background' : '--no-remove-background',
213
+ ],
214
+ );
215
+ log(`[OK-SHEET ] ${batch.sheetName}`);
216
+ } catch (e) {
217
+ log(`[FAIL-SHEET] ${batch.sheetName}: ${e.message?.slice(0, 200)}`);
218
+ failedBatches++;
219
+ continue;
220
+ }
221
+ }
222
+
223
+ // ── Step 2: sprite-split 切分精灵图 ──────────────────────────────
224
+ const actualRows = Math.ceil(batch.items.length / CONFIG.columns);
225
+ // 检查第一个切分结果是否已存在(幂等)
226
+ const firstItemPath = `${CONFIG.outputDir}/${batch.items[0]?.name}.png`;
227
+ if (batch.items[0] && existsSync(firstItemPath)) {
228
+ log(`[SKIP-SPLIT] ${batch.sheetName} already split`);
229
+ doneBatches++;
230
+ continue;
231
+ }
232
+
233
+ // 切分单元尺寸:优先用 CONFIG 显式值;否则按精灵图实际像素尺寸 ÷ 网格自动推导。
234
+ // ⚠️ 绝不写死 256——4K 精灵图按 256 切分会严重错位(test11 类事故)。
235
+ const padding = CONFIG.padding ?? 0;
236
+ let cellWidth = CONFIG.cellWidth;
237
+ let cellHeight = CONFIG.cellHeight;
238
+ if (cellWidth == null || cellHeight == null) {
239
+ const dims = readSheetDims(sheetPath);
240
+ if (!dims) {
241
+ log(
242
+ `[FAIL-SPLIT] ${batch.sheetName}: 无法读取精灵图尺寸,请在 CONFIG 显式设置 cellWidth/cellHeight`,
243
+ );
244
+ failedBatches++;
245
+ continue;
246
+ }
247
+ // 去掉帧间距后按网格均分
248
+ cellWidth ??= Math.floor((dims.width - padding * (CONFIG.columns - 1)) / CONFIG.columns);
249
+ cellHeight ??= Math.floor((dims.height - padding * (actualRows - 1)) / actualRows);
250
+ log(
251
+ `[CELL-SIZE ] ${batch.sheetName}: sheet ${dims.width}×${dims.height} → cell ${cellWidth}×${cellHeight} (grid ${CONFIG.columns}×${actualRows}, padding ${padding})`,
252
+ );
253
+ }
254
+ if (!(cellWidth > 0 && cellHeight > 0)) {
255
+ log(`[FAIL-SPLIT] ${batch.sheetName}: 推导出的 cell 尺寸非法 (${cellWidth}×${cellHeight})`);
256
+ failedBatches++;
257
+ continue;
258
+ }
259
+
260
+ log(`[SPLIT ] Splitting ${batch.sheetName} (${CONFIG.columns}×${actualRows}, cell ${cellWidth}×${cellHeight})`);
261
+ const splitDir = `ta-workspace/tmp/${batch.sheetName}`;
262
+
263
+ try {
264
+ playcraft([
265
+ 'image', 'sprite-split',
266
+ '--input', sheetPath,
267
+ '--output-dir', splitDir,
268
+ '--rows', String(actualRows),
269
+ '--columns', String(CONFIG.columns),
270
+ '--frame-width', String(cellWidth),
271
+ '--frame-height', String(cellHeight),
272
+ '--padding', String(padding),
273
+ ]);
274
+ } catch (e) {
275
+ log(`[FAIL-SPLIT] ${batch.sheetName}: ${e.message?.slice(0, 200)}`);
276
+ failedBatches++;
277
+ continue;
278
+ }
279
+
280
+ // ── Step 3: 保留自动透明结果;独立色幕才逐格去背 ────────────────
281
+ // 任何缺帧 / 处理失败都视为该批次失败(FAIL,不是 WARN):一个不完整的
282
+ // 批次绝不能被报成 OK-BATCH,否则下游会拿到缺图的资产集。
283
+ const removeCellBackground = CONFIG.removeBg && CONFIG.backgroundMode === 'chroma';
284
+ log(`[RENAME ] Renaming ${batch.items.length} cells${removeCellBackground ? ' + remove-background' : ''}`);
285
+ let processedOk = 0;
286
+ let batchFailed = false;
287
+ for (let j = 0; j < batch.items.length; j++) {
288
+ const item = batch.items[j];
289
+ const row = Math.floor(j / CONFIG.columns);
290
+ const col = j % CONFIG.columns;
291
+ // sprite-split 默认命名:frame_r{row}_c{col}.png(0-indexed)
292
+ const srcPath = `${splitDir}/frame_r${row}_c${col}.png`;
293
+ const dstPath = `${CONFIG.outputDir}/${item.name}.png`;
294
+
295
+ if (!existsSync(srcPath)) {
296
+ log(`[FAIL-CELL ] Expected cell not found: ${srcPath} (item ${item.name}, index ${j}/${batch.items.length})`);
297
+ batchFailed = true;
298
+ continue;
299
+ }
300
+ try {
301
+ if (removeCellBackground) {
302
+ // 只处理独立色幕,保留常规工具已经交付的透明边缘。
303
+ playcraft([
304
+ 'image', 'remove-background',
305
+ '--input', srcPath,
306
+ '--output', dstPath,
307
+ '--tolerance', String(CONFIG.chromaTolerance),
308
+ ]);
309
+ } else {
310
+ copyFileSync(srcPath, dstPath);
311
+ }
312
+ processedOk++;
313
+ } catch (e) {
314
+ log(`[FAIL-CELL ] Failed to process ${srcPath} → ${dstPath}: ${e.message?.slice(0, 120)}`);
315
+ batchFailed = true;
316
+ }
317
+ }
318
+
319
+ if (batchFailed) {
320
+ log(`[FAIL-BATCH] (${bi + 1}/${BATCHES.length}) ${batch.sheetName} → only ${processedOk}/${batch.items.length} cells OK (see FAIL-CELL above)`);
321
+ failedBatches++;
322
+ } else {
323
+ log(`[OK-BATCH ] (${bi + 1}/${BATCHES.length}) ${batch.sheetName} → ${batch.items.length} files`);
324
+ doneBatches++;
325
+ }
326
+ }
327
+
328
+ log(`\n=== Complete: Done=${doneBatches} Failed=${failedBatches}/${BATCHES.length} batches ===`);
329
+ log(`Output: ${CONFIG.outputDir}`);
330
+ if (failedBatches > 0) {
331
+ log('Re-run to retry failed batches (successful batches will be skipped)');
332
+ process.exit(1);
333
+ }
@@ -0,0 +1,95 @@
1
+ // ============================================================
2
+ // gen-batch.template.mjs — 批量 AI (Artificial Intelligence, 人工智能) 生图脚本模板
3
+ // 用途:从零批量生成一组风格一致的素材(reference-image 模式)
4
+ //
5
+ // 使用方式:
6
+ // 1. cp .claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs ta-workspace/scripts/gen-<name>.mjs
7
+ // 2. 修改下方 CONFIG 和 ITEMS 区域
8
+ // 3. node ta-workspace/scripts/gen-<name>.mjs
9
+ // ============================================================
10
+
11
+ import { execFileSync } from 'child_process';
12
+ import { existsSync, mkdirSync, appendFileSync } from 'fs';
13
+
14
+ // ============ CONFIG — 修改这里 ============
15
+ const CONFIG = {
16
+ /**
17
+ * 生图模型。
18
+ * 先 list-image-models,再填写本次实际模型;普通素材优先 Image 2.5。
19
+ * 用户或制作流程锁定其他模型时保留其选择。
20
+ * 参考图要求模型支持 text+image 或 image→image。
21
+ */
22
+ model: 'iegg-litellm/gpt-image-2.5-sunburst',
23
+ /** 概念图路径(确认过风格的样本,所有后续图的参考来源) */
24
+ referenceImage: 'assets/images/concept/approved_sample.png',
25
+ /** 输出目录 */
26
+ outputDir: 'assets/images/batch',
27
+ /** 图片比例 */
28
+ aspectRatio: '1:1',
29
+ /**
30
+ * 统一风格描述(从 design-brief.md 复制,粘贴到每个 prompt 末尾)
31
+ * 示例:"flat 2D icon, vibrant colors, clean edges, no shadow"
32
+ */
33
+ style: '<从 design-brief 复制的统一风格描述>',
34
+ /** 最终透明设 true;完整场景或不透明牌面设 false。独立色幕使用精灵图模板。 */
35
+ removeBackground: true,
36
+ };
37
+ // ============ DATA — 定义要生成的素材列表 ============
38
+ const ITEMS = [
39
+ { name: 'item_01', desc: '<素材描述 1>' },
40
+ { name: 'item_02', desc: '<素材描述 2>' },
41
+ // 继续添加...
42
+ ];
43
+ // ============ LOGIC — 通常不需要修改 ============
44
+
45
+ const LOG_FILE = 'ta-workspace/logs/gen-batch.log';
46
+ mkdirSync(CONFIG.outputDir, { recursive: true });
47
+ mkdirSync('ta-workspace/logs', { recursive: true });
48
+
49
+ function log(msg) {
50
+ const line = `[${new Date().toISOString()}] ${msg}`;
51
+ console.log(line);
52
+ appendFileSync(LOG_FILE, line + '\n');
53
+ }
54
+
55
+ log(`=== Batch Generation Start ===`);
56
+ log(`Total: ${ITEMS.length} | Model: ${CONFIG.model}`);
57
+
58
+ let done = 0, skipped = 0, failed = 0;
59
+ const failures = [];
60
+
61
+ for (let i = 0; i < ITEMS.length; i++) {
62
+ const item = ITEMS[i];
63
+ const outPath = `${CONFIG.outputDir}/${item.name}.png`;
64
+
65
+ if (existsSync(outPath)) {
66
+ log(`[SKIP] (${i + 1}/${ITEMS.length}) ${item.name}`);
67
+ skipped++;
68
+ continue;
69
+ }
70
+
71
+ log(`[GEN ] (${i + 1}/${ITEMS.length}) ${item.name}`);
72
+
73
+ const nativeBackground = /^gpt-image-2\.5(?:$|-)/.test(CONFIG.model.trim().split('/').at(-1));
74
+ const sourceBackground = CONFIG.removeBackground && !nativeBackground
75
+ ? 'on a uniform solid pure white background for subsequent background removal' : '';
76
+ const prompt = [item.desc, CONFIG.style, sourceBackground].filter(Boolean).join('. ');
77
+ const args = ['tools', 'generate-image', '--prompt', prompt, '--output', outPath,
78
+ '--aspect-ratio', CONFIG.aspectRatio, '--image-model', CONFIG.model,
79
+ CONFIG.removeBackground ? '--remove-background' : '--no-remove-background'];
80
+ if (CONFIG.referenceImage) args.push('--reference-image', CONFIG.referenceImage);
81
+
82
+ try {
83
+ execFileSync('playcraft', args, { stdio: 'inherit' });
84
+ done++;
85
+ log(`[OK ] ${item.name}`);
86
+ } catch (e) {
87
+ log(`[FAIL] ${item.name}: ${e.message?.slice(0, 100)}`);
88
+ failures.push(item.name);
89
+ failed++;
90
+ }
91
+ }
92
+
93
+ log(`\n=== Complete: Done=${done} Skipped=${skipped} Failed=${failed}/${ITEMS.length} ===`);
94
+ if (failures.length > 0) log(`Failed: ${failures.join(', ')}`);
95
+ if (failed > 0) process.exit(1);