@playcraft/cli 0.1.42 → 0.1.44-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 (390) 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/image.js +2 -6
  12. package/dist/commands/login.js +84 -42
  13. package/dist/commands/platform-skills.generated.js +19 -0
  14. package/dist/commands/playable.js +53 -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 +105 -0
  18. package/dist/commands/tools-generation.js +69 -137
  19. package/dist/commands/tools-utils.js +0 -12
  20. package/dist/commands/tools.js +2 -2
  21. package/dist/commands/video.js +122 -0
  22. package/dist/commands/workspace-runtime.js +54 -0
  23. package/dist/commands/workspace.js +40 -0
  24. package/dist/config.js +59 -4
  25. package/dist/index.js +40 -3
  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 +233 -0
  70. package/dist/workspace/transfer-errors.js +48 -0
  71. package/dist/workspace-runtime/batch/control.js +80 -0
  72. package/dist/workspace-runtime/batch/deliver.js +150 -0
  73. package/dist/workspace-runtime/batch/freeze.js +102 -0
  74. package/dist/workspace-runtime/batch/generate.js +205 -0
  75. package/dist/workspace-runtime/batch/git.js +40 -0
  76. package/dist/workspace-runtime/batch/occupancy.js +8 -0
  77. package/dist/workspace-runtime/batch/policy.js +70 -0
  78. package/dist/workspace-runtime/batch/prepare.js +202 -0
  79. package/dist/workspace-runtime/batch/processes.js +72 -0
  80. package/dist/workspace-runtime/batch/records.js +113 -0
  81. package/dist/workspace-runtime/batch/routes.js +58 -0
  82. package/dist/workspace-runtime/batch/source-capture.js +159 -0
  83. package/dist/workspace-runtime/codex/app-server.js +1040 -0
  84. package/dist/workspace-runtime/codex/compact.js +46 -0
  85. package/dist/workspace-runtime/codex/config-toml.js +107 -0
  86. package/dist/workspace-runtime/codex/jsonrpc-stdio.js +145 -0
  87. package/dist/workspace-runtime/codex/launcher-client.js +177 -0
  88. package/dist/workspace-runtime/codex/loopback.js +146 -0
  89. package/dist/workspace-runtime/codex/mcp-config.js +39 -0
  90. package/dist/workspace-runtime/codex/model-broker.js +263 -0
  91. package/dist/workspace-runtime/codex/native-adapter.js +9 -0
  92. package/dist/workspace-runtime/codex/permissions.js +79 -0
  93. package/dist/workspace-runtime/codex/thread-image.js +38 -0
  94. package/dist/workspace-runtime/codex/ui-instructions.js +4 -0
  95. package/dist/workspace-runtime/codex/ui-tools.js +186 -0
  96. package/dist/workspace-runtime/codex/work-mode.js +15 -0
  97. package/dist/workspace-runtime/main.js +10 -0
  98. package/dist/workspace-runtime/persistence/journal.js +365 -0
  99. package/dist/workspace-runtime/persistence/native-subagents.js +162 -0
  100. package/dist/workspace-runtime/persistence/sqlite-client.js +77 -0
  101. package/dist/workspace-runtime/persistence/sqlite-worker.js +1161 -0
  102. package/dist/workspace-runtime/persistence/stopped-execution.js +77 -0
  103. package/dist/workspace-runtime/previews/output.js +36 -0
  104. package/dist/workspace-runtime/previews/publish.js +262 -0
  105. package/dist/workspace-runtime/previews/single-file.js +43 -0
  106. package/dist/workspace-runtime/processes/managed-writes.js +69 -0
  107. package/dist/workspace-runtime/production/content-changes.js +36 -0
  108. package/dist/workspace-runtime/production/contracts.js +19 -0
  109. package/dist/workspace-runtime/production/controller.js +228 -0
  110. package/dist/workspace-runtime/production/dependencies.js +60 -0
  111. package/dist/workspace-runtime/production/native.js +239 -0
  112. package/dist/workspace-runtime/production/processes.js +102 -0
  113. package/dist/workspace-runtime/production/save-command.js +35 -0
  114. package/dist/workspace-runtime/production/source-archive.js +137 -0
  115. package/dist/workspace-runtime/production/source-copy.js +92 -0
  116. package/dist/workspace-runtime/production/stages.js +354 -0
  117. package/dist/workspace-runtime/production/storage.js +75 -0
  118. package/dist/workspace-runtime/serve.js +283 -0
  119. package/dist/workspace-runtime/server/auth.js +21 -0
  120. package/dist/workspace-runtime/server/connectivity.js +209 -0
  121. package/dist/workspace-runtime/server/desktop-host.js +429 -0
  122. package/dist/workspace-runtime/server/desktop-preview-config.js +81 -0
  123. package/dist/workspace-runtime/server/desktop-preview-service.js +157 -0
  124. package/dist/workspace-runtime/server/desktop-preview-static.js +53 -0
  125. package/dist/workspace-runtime/server/desktop-preview.js +189 -0
  126. package/dist/workspace-runtime/server/dispatch.js +1339 -0
  127. package/dist/workspace-runtime/server/endpoints.js +21 -0
  128. package/dist/workspace-runtime/server/execution-group.js +90 -0
  129. package/dist/workspace-runtime/server/http.js +1297 -0
  130. package/dist/workspace-runtime/server/lock.js +53 -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/terminal-host.js +366 -0
  135. package/dist/workspace-runtime/server/types.js +1 -0
  136. package/dist/workspace-runtime/server/workspace-transfer.js +168 -0
  137. package/dist/workspace-runtime/workspaces/archive.js +207 -0
  138. package/dist/workspace-runtime/workspaces/artifact-events.js +55 -0
  139. package/dist/workspace-runtime/workspaces/artifact-files.js +199 -0
  140. package/dist/workspace-runtime/workspaces/artifact-receipts.js +89 -0
  141. package/dist/workspace-runtime/workspaces/artifacts.js +282 -0
  142. package/dist/workspace-runtime/workspaces/asset-library-import.js +366 -0
  143. package/dist/workspace-runtime/workspaces/attachment-content.js +73 -0
  144. package/dist/workspace-runtime/workspaces/attachments.js +185 -0
  145. package/dist/workspace-runtime/workspaces/batch-commit.js +142 -0
  146. package/dist/workspace-runtime/workspaces/binary-content.js +65 -0
  147. package/dist/workspace-runtime/workspaces/binary-write.js +112 -0
  148. package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
  149. package/dist/workspace-runtime/workspaces/cli-credentials.js +111 -0
  150. package/dist/workspace-runtime/workspaces/composer-context.js +147 -0
  151. package/dist/workspace-runtime/workspaces/context-error.js +2 -0
  152. package/dist/workspace-runtime/workspaces/dependencies.js +264 -0
  153. package/dist/workspace-runtime/workspaces/developer-command.js +64 -0
  154. package/dist/workspace-runtime/workspaces/directories.js +137 -0
  155. package/dist/workspace-runtime/workspaces/directory-access.js +37 -0
  156. package/dist/workspace-runtime/workspaces/directory-attachments.js +245 -0
  157. package/dist/workspace-runtime/workspaces/directory-create.js +57 -0
  158. package/dist/workspace-runtime/workspaces/directory-maintenance.js +111 -0
  159. package/dist/workspace-runtime/workspaces/directory-stats.js +49 -0
  160. package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
  161. package/dist/workspace-runtime/workspaces/empty-template.js +42 -0
  162. package/dist/workspace-runtime/workspaces/file-content.js +48 -0
  163. package/dist/workspace-runtime/workspaces/files-search.js +116 -0
  164. package/dist/workspace-runtime/workspaces/files.js +150 -0
  165. package/dist/workspace-runtime/workspaces/git-credential-broker.js +312 -0
  166. package/dist/workspace-runtime/workspaces/git-credential-helper.js +68 -0
  167. package/dist/workspace-runtime/workspaces/git-direct-store.js +155 -0
  168. package/dist/workspace-runtime/workspaces/git.js +670 -0
  169. package/dist/workspace-runtime/workspaces/instructions.js +56 -0
  170. package/dist/workspace-runtime/workspaces/json5-edit.js +170 -0
  171. package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
  172. package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
  173. package/dist/workspace-runtime/workspaces/parameters.js +272 -0
  174. package/dist/workspace-runtime/workspaces/prepare.js +278 -0
  175. package/dist/workspace-runtime/workspaces/registry.js +251 -0
  176. package/dist/workspace-runtime/workspaces/remix-references.js +301 -0
  177. package/dist/workspace-runtime/workspaces/revisions.js +31 -0
  178. package/dist/workspace-runtime/workspaces/session-image.js +104 -0
  179. package/dist/workspace-runtime/workspaces/shared-git.js +40 -0
  180. package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +95 -0
  181. package/dist/workspace-runtime/workspaces/skills.js +191 -0
  182. package/dist/workspace-runtime/workspaces/transfer-quota.js +69 -0
  183. package/dist/workspace-runtime/workspaces/transfer.js +471 -0
  184. package/dist/workspace-runtime/workspaces/turn-changes.js +75 -0
  185. package/dist/workspace-runtime/workspaces/video-attachments.js +49 -0
  186. package/package.json +15 -5
  187. package/project-template/.claude/agents/refs/ta-image-generation-detail.md +123 -67
  188. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
  189. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
  190. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
  191. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
  192. package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
  193. package/project-template/.claude/skills/playcraft-replica-validation/SKILL.md +25 -0
  194. package/project-template/.claude/skills/playcraft-replica-validation/references/contracts.md +79 -0
  195. package/project-template/.claude/skills/playcraft-video-understanding/SKILL.md +29 -0
  196. package/project-template/.claude/skills/playcraft-video-understanding/references/contracts.md +37 -0
  197. package/project-template-v2/.claude/agents/artist.md +82 -0
  198. package/project-template-v2/.claude/agents/developer.md +153 -0
  199. package/project-template-v2/.claude/agents/game-designer.md +264 -0
  200. package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
  201. package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
  202. package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
  203. package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
  204. package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
  205. package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
  206. package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
  207. package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
  208. package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
  209. package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
  210. package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
  211. package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  212. package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  213. package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
  214. package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  215. package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
  216. package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
  217. package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  218. package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
  219. package/project-template-v2/.claude/agents/reviewer.md +75 -0
  220. package/project-template-v2/.claude/agents/technical-artist.md +86 -0
  221. package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
  222. package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
  223. package/project-template-v2/.claude/settings.json +33 -0
  224. package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
  225. package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
  226. package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
  227. package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
  228. package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
  229. package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
  230. package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
  231. package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  232. package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
  233. package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  234. package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  235. package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
  236. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  237. package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  238. package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  239. package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +298 -0
  240. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  241. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  242. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +324 -0
  243. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  244. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  245. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  246. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  247. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  248. package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  249. package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +219 -0
  250. package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
  251. package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
  252. package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
  253. package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
  254. package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  255. package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
  256. package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
  257. package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  258. package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  259. package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  260. package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  261. package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
  262. package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  263. package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  264. package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  265. package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
  266. package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
  267. package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
  268. package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  269. package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
  270. package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
  271. package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
  272. package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
  273. package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
  274. package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
  275. package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
  276. package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
  277. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
  278. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
  279. package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
  280. package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
  281. package/project-template-v2/.claude/snapshot.mjs +263 -0
  282. package/project-template-v2/.playcraft/skills.lock.json +152 -0
  283. package/project-template-v2/CLAUDE.md +146 -0
  284. package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
  285. package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
  286. package/project-template-v2/assets/bundles/.gitkeep +0 -0
  287. package/project-template-v2/assets/images/bg/.gitkeep +0 -0
  288. package/project-template-v2/assets/images/reference/.gitkeep +0 -0
  289. package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
  290. package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
  291. package/project-template-v2/assets/images/ui/.gitkeep +0 -0
  292. package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
  293. package/project-template-v2/assets/models/.gitkeep +0 -0
  294. package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
  295. package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
  296. package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
  297. package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
  298. package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
  299. package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
  300. package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
  301. package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
  302. package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
  303. package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
  304. package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
  305. package/project-template-v2/docs/project-state.json +60 -0
  306. package/project-template-v2/docs/project-state.md +72 -0
  307. package/project-template-v2/docs/standards/README.md +225 -0
  308. package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
  309. package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
  310. package/project-template-v2/docs/standards/artifacts/design.md +22 -0
  311. package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
  312. package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
  313. package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
  314. package/project-template-v2/game/index.ts +18 -0
  315. package/project-template-v2/globals.d.ts +51 -0
  316. package/project-template-v2/index.css +34 -0
  317. package/project-template-v2/index.html +18 -0
  318. package/project-template-v2/main.ts +9 -0
  319. package/project-template-v2/package.json +46 -0
  320. package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
  321. package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
  322. package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
  323. package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
  324. package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
  325. package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
  326. package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
  327. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
  328. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
  329. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
  330. package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
  331. package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
  332. package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
  333. package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
  334. package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
  335. package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
  336. package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
  337. package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
  338. package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
  339. package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
  340. package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
  341. package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
  342. package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
  343. package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
  344. package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
  345. package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
  346. package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
  347. package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
  348. package/project-template-v2/skills/playable-record/SKILL.md +140 -0
  349. package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
  350. package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
  351. package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
  352. package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
  353. package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
  354. package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
  355. package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
  356. package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
  357. package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
  358. package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
  359. package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
  360. package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
  361. package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
  362. package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
  363. package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
  364. package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
  365. package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
  366. package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
  367. package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
  368. package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
  369. package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
  370. package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
  371. package/project-template-v2/tsconfig.json +20 -0
  372. package/project-template-v2/vite.config.ts +27 -0
  373. package/project-templates/batch-locks/phaser.yaml +922 -0
  374. package/project-templates/batch-locks/threejs.yaml +978 -0
  375. package/project-templates/empty/AGENTS.md +41 -0
  376. package/project-templates/empty/gitignore +33 -0
  377. package/project-templates/phaser/.claude/agents/refs/ta-image-generation-detail.md +59 -59
  378. package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
  379. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
  380. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
  381. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
  382. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
  383. package/project-templates/threejs/.claude/agents/refs/ta-image-generation-detail.md +59 -59
  384. package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
  385. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
  386. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
  387. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
  388. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
  389. package/dist/commands/tools-image-context.js +0 -29
  390. package/dist/utils/image-asset-context.js +0 -228
@@ -0,0 +1,324 @@
1
+ // ============================================================
2
+ // gen-batch-sprite.template.mjs — gpt-image-2 精灵图直出脚本模板
3
+ //
4
+ // 核心原则:让 gpt-image-2 一次 API 调用直接生成包含多个元素的
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
+ * 精灵图直出模型:永远用 gpt-image-2(图像理解 + 布局能力最强)
38
+ * mulerouter 质量更高(建议作为主模型),iegg 更快(备用)
39
+ * 注意:精灵图生成比单图慢,通常需要 90-150s,timeout 设 240 以上
40
+ */
41
+ model: 'mulerouter/gpt-image-2',
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
+ * style: 'flat 2D illustration, isolated on solid bright green #00FF00 background, centered, no shadow'
69
+ * removeBg: true (切分后逐帧去背景)
70
+ *
71
+ * 元素本身就是矩形(卡牌/棋子/UI 面板)→ 白底策略:
72
+ * style: 'flat 2D, white background, no shadow, no drop shadow, clean edges'
73
+ * removeBg: false
74
+ */
75
+ style: 'flat 2D illustration, isolated on solid bright green #00FF00 background, centered, no shadow',
76
+ /**
77
+ * 切分后是否对每帧执行 remove-background(绿幕去背景)
78
+ * true → 独立元素(需透明通道):remove-background --tolerance 25
79
+ * false → 卡牌/UI 面板等矩形元素:直接 resize,不去背景
80
+ */
81
+ removeBg: true,
82
+
83
+ /**
84
+ * 切分单元尺寸(像素)。留空(null)= 自动按精灵图实际像素尺寸 ÷ 网格推导(推荐)。
85
+ * 仅当模型输出的格子并非均匀均分、需要手动指定时才填写。
86
+ * ⚠️ 不要写死 256:4K 精灵图按 256 切分会严重错位。
87
+ */
88
+ cellWidth: null,
89
+ cellHeight: null,
90
+ /** 帧间距(像素),默认 0 */
91
+ padding: 0,
92
+ };
93
+
94
+ // ============ DATA — 分批定义元素 ============
95
+ // 规则:每批 ≤ CONFIG.columns × CONFIG.rows 个元素
96
+ // 每个元素必须有 name(输出文件名)和 desc(精灵图中该格的内容描述)
97
+ const BATCHES = [
98
+ {
99
+ sheetName: 'sheet_batch_1',
100
+ items: [
101
+ { name: 'item_01', desc: '<格 1 内容描述>' },
102
+ { name: 'item_02', desc: '<格 2 内容描述>' },
103
+ { name: 'item_03', desc: '<格 3 内容描述>' },
104
+ { name: 'item_04', desc: '<格 4 内容描述>' },
105
+ // 最多 CONFIG.columns × CONFIG.rows 个
106
+ ],
107
+ },
108
+ {
109
+ sheetName: 'sheet_batch_2',
110
+ items: [
111
+ { name: 'item_05', desc: '<格 5 内容描述>' },
112
+ { name: 'item_06', desc: '<格 6 内容描述>' },
113
+ // ...
114
+ ],
115
+ },
116
+ // 继续添加批次...
117
+ ];
118
+
119
+ // ============ 精灵图 Prompt 构建器 ============
120
+ /**
121
+ * 根据 items 列表构建精灵图网格 prompt
122
+ * 关键词组合让 gpt-image-2 理解"网格布局"意图
123
+ */
124
+ /**
125
+ * 读取精灵图实际像素尺寸(用于自动推导切分单元尺寸)。
126
+ * 失败返回 null,由调用方决定是否中止该批次。
127
+ */
128
+ function readSheetDims(sheetPath) {
129
+ try {
130
+ const out = playcraft(['image', 'info', '--input', sheetPath, '--json'], { capture: true });
131
+ const meta = JSON.parse(out.slice(out.indexOf('{')));
132
+ if (typeof meta.width === 'number' && typeof meta.height === 'number') {
133
+ return { width: meta.width, height: meta.height };
134
+ }
135
+ } catch {
136
+ // fall through → null
137
+ }
138
+ return null;
139
+ }
140
+
141
+ function buildSpriteSheetPrompt(items, columns, style, removeBg) {
142
+ const actualRows = Math.ceil(items.length / columns);
143
+ const cellDescs = items.map((item, i) => {
144
+ const col = (i % columns) + 1;
145
+ const row = Math.floor(i / columns) + 1;
146
+ return `[Row${row},Col${col}]: ${item.desc}`;
147
+ }).join('; ');
148
+
149
+ // 绿幕模式强制在 prompt 里明确背景色,避免模型用白底
150
+ const bgInstruction = removeBg
151
+ ? 'Each element isolated on solid bright green #00FF00 background, no shadow, no gradient background.'
152
+ : 'Each element on clean white background.';
153
+
154
+ return [
155
+ `Sprite sheet grid layout, ${columns} columns × ${actualRows} rows.`,
156
+ `Each cell contains one element. Cell contents: ${cellDescs}.`,
157
+ bgInstruction,
158
+ `Grid layout, uniform cell size, equal spacing, elements perfectly centered in each cell.`,
159
+ `No borders between cells, no labels, no numbers on cells.`,
160
+ style,
161
+ ].join(' ');
162
+ }
163
+
164
+ // ============ LOGIC — 通常不需要修改 ============
165
+
166
+ const LOG_FILE = 'ta-workspace/logs/gen-batch-sprite.log';
167
+ mkdirSync(CONFIG.sheetDir, { recursive: true });
168
+ mkdirSync(CONFIG.outputDir, { recursive: true });
169
+ mkdirSync('ta-workspace/logs', { recursive: true });
170
+
171
+ function log(msg) {
172
+ const line = `[${new Date().toISOString()}] ${msg}`;
173
+ console.log(line);
174
+ appendFileSync(LOG_FILE, line + '\n');
175
+ }
176
+
177
+ const totalElements = BATCHES.reduce((s, b) => s + b.items.length, 0);
178
+ log(`=== Batch Sprite Generation Start ===`);
179
+ log(`Total: ${BATCHES.length} batches, ${totalElements} elements`);
180
+ log(`Model: ${CONFIG.model}`);
181
+
182
+ let doneBatches = 0, failedBatches = 0;
183
+
184
+ for (let bi = 0; bi < BATCHES.length; bi++) {
185
+ const batch = BATCHES[bi];
186
+ const sheetPath = `${CONFIG.sheetDir}/${batch.sheetName}.png`;
187
+
188
+ // ── Step 1: 生成精灵图(幂等跳过)────────────────────────────────
189
+ if (existsSync(sheetPath)) {
190
+ log(`[SKIP-SHEET] (${bi + 1}/${BATCHES.length}) ${batch.sheetName} already exists`);
191
+ } else {
192
+ log(`[GEN-SHEET ] (${bi + 1}/${BATCHES.length}) Generating ${batch.sheetName} (${batch.items.length} elements)`);
193
+ const prompt = buildSpriteSheetPrompt(batch.items, CONFIG.columns, CONFIG.style, CONFIG.removeBg);
194
+
195
+ try {
196
+ playcraft(
197
+ [
198
+ 'tools', 'generate-image',
199
+ '--prompt', prompt,
200
+ '--output', sheetPath,
201
+ '--aspect-ratio', CONFIG.aspectRatio,
202
+ '--image-model', CONFIG.model,
203
+ '--timeout', '240',
204
+ ],
205
+ { timeout: 300_000 },
206
+ );
207
+ log(`[OK-SHEET ] ${batch.sheetName}`);
208
+ } catch (e) {
209
+ log(`[FAIL-SHEET] ${batch.sheetName}: ${e.message?.slice(0, 200)}`);
210
+ failedBatches++;
211
+ continue;
212
+ }
213
+ }
214
+
215
+ // ── Step 2: sprite-split 切分精灵图 ──────────────────────────────
216
+ const actualRows = Math.ceil(batch.items.length / CONFIG.columns);
217
+ // 检查第一个切分结果是否已存在(幂等)
218
+ const firstItemPath = `${CONFIG.outputDir}/${batch.items[0]?.name}.png`;
219
+ if (batch.items[0] && existsSync(firstItemPath)) {
220
+ log(`[SKIP-SPLIT] ${batch.sheetName} already split`);
221
+ doneBatches++;
222
+ continue;
223
+ }
224
+
225
+ // 切分单元尺寸:优先用 CONFIG 显式值;否则按精灵图实际像素尺寸 ÷ 网格自动推导。
226
+ // ⚠️ 绝不写死 256——4K 精灵图按 256 切分会严重错位(test11 类事故)。
227
+ const padding = CONFIG.padding ?? 0;
228
+ let cellWidth = CONFIG.cellWidth;
229
+ let cellHeight = CONFIG.cellHeight;
230
+ if (cellWidth == null || cellHeight == null) {
231
+ const dims = readSheetDims(sheetPath);
232
+ if (!dims) {
233
+ log(
234
+ `[FAIL-SPLIT] ${batch.sheetName}: 无法读取精灵图尺寸,请在 CONFIG 显式设置 cellWidth/cellHeight`,
235
+ );
236
+ failedBatches++;
237
+ continue;
238
+ }
239
+ // 去掉帧间距后按网格均分
240
+ cellWidth ??= Math.floor((dims.width - padding * (CONFIG.columns - 1)) / CONFIG.columns);
241
+ cellHeight ??= Math.floor((dims.height - padding * (actualRows - 1)) / actualRows);
242
+ log(
243
+ `[CELL-SIZE ] ${batch.sheetName}: sheet ${dims.width}×${dims.height} → cell ${cellWidth}×${cellHeight} (grid ${CONFIG.columns}×${actualRows}, padding ${padding})`,
244
+ );
245
+ }
246
+ if (!(cellWidth > 0 && cellHeight > 0)) {
247
+ log(`[FAIL-SPLIT] ${batch.sheetName}: 推导出的 cell 尺寸非法 (${cellWidth}×${cellHeight})`);
248
+ failedBatches++;
249
+ continue;
250
+ }
251
+
252
+ log(`[SPLIT ] Splitting ${batch.sheetName} (${CONFIG.columns}×${actualRows}, cell ${cellWidth}×${cellHeight})`);
253
+ const splitDir = `ta-workspace/tmp/${batch.sheetName}`;
254
+
255
+ try {
256
+ playcraft([
257
+ 'image', 'sprite-split',
258
+ '--input', sheetPath,
259
+ '--output-dir', splitDir,
260
+ '--rows', String(actualRows),
261
+ '--columns', String(CONFIG.columns),
262
+ '--frame-width', String(cellWidth),
263
+ '--frame-height', String(cellHeight),
264
+ '--padding', String(padding),
265
+ ]);
266
+ } catch (e) {
267
+ log(`[FAIL-SPLIT] ${batch.sheetName}: ${e.message?.slice(0, 200)}`);
268
+ failedBatches++;
269
+ continue;
270
+ }
271
+
272
+ // ── Step 3: 重命名(+可选绿幕去背景)切分结果到最终位置 ─────────
273
+ // 任何缺帧 / 处理失败都视为该批次失败(FAIL,不是 WARN):一个不完整的
274
+ // 批次绝不能被报成 OK-BATCH,否则下游会拿到缺图的资产集。
275
+ log(`[RENAME ] Renaming ${batch.items.length} cells${CONFIG.removeBg ? ' + remove-background' : ''}`);
276
+ let processedOk = 0;
277
+ let batchFailed = false;
278
+ for (let j = 0; j < batch.items.length; j++) {
279
+ const item = batch.items[j];
280
+ const row = Math.floor(j / CONFIG.columns);
281
+ const col = j % CONFIG.columns;
282
+ // sprite-split 默认命名:frame_r{row}_c{col}.png(0-indexed)
283
+ const srcPath = `${splitDir}/frame_r${row}_c${col}.png`;
284
+ const dstPath = `${CONFIG.outputDir}/${item.name}.png`;
285
+
286
+ if (!existsSync(srcPath)) {
287
+ log(`[FAIL-CELL ] Expected cell not found: ${srcPath} (item ${item.name}, index ${j}/${batch.items.length})`);
288
+ batchFailed = true;
289
+ continue;
290
+ }
291
+ try {
292
+ if (CONFIG.removeBg) {
293
+ // 绿幕去背景(tolerance 25 适合纯绿色 #00FF00 背景)
294
+ playcraft([
295
+ 'image', 'remove-background',
296
+ '--input', srcPath,
297
+ '--output', dstPath,
298
+ '--tolerance', '25',
299
+ ]);
300
+ } else {
301
+ copyFileSync(srcPath, dstPath);
302
+ }
303
+ processedOk++;
304
+ } catch (e) {
305
+ log(`[FAIL-CELL ] Failed to process ${srcPath} → ${dstPath}: ${e.message?.slice(0, 120)}`);
306
+ batchFailed = true;
307
+ }
308
+ }
309
+
310
+ if (batchFailed) {
311
+ log(`[FAIL-BATCH] (${bi + 1}/${BATCHES.length}) ${batch.sheetName} → only ${processedOk}/${batch.items.length} cells OK (see FAIL-CELL above)`);
312
+ failedBatches++;
313
+ } else {
314
+ log(`[OK-BATCH ] (${bi + 1}/${BATCHES.length}) ${batch.sheetName} → ${batch.items.length} files`);
315
+ doneBatches++;
316
+ }
317
+ }
318
+
319
+ log(`\n=== Complete: Done=${doneBatches} Failed=${failedBatches}/${BATCHES.length} batches ===`);
320
+ log(`Output: ${CONFIG.outputDir}`);
321
+ if (failedBatches > 0) {
322
+ log('Re-run to retry failed batches (successful batches will be skipped)');
323
+ process.exit(1);
324
+ }
@@ -0,0 +1,97 @@
1
+ // ============================================================
2
+ // gen-batch.template.mjs — 批量 AI 生图脚本模板
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 { execSync } from 'child_process';
12
+ import { existsSync, mkdirSync, appendFileSync } from 'fs';
13
+
14
+ // ============ CONFIG — 修改这里 ============
15
+ const CONFIG = {
16
+ /**
17
+ * 生图模型。
18
+ * - Phase 1 概念图(追求质量):用 gpt-image-2
19
+ * model: 'iegg-litellm/gpt-image-2'
20
+ * - Phase 2 批量(reference-image 一致性):用 google/,更稳定
21
+ * model: 'google/gemini-3.1-flash-image-preview'
22
+ *
23
+ * 后端按优先级自动 fallback 多个 provider,无需手动指定 provider。
24
+ * text+image CAPABILITY 的模型才支持 --reference-image
25
+ */
26
+ model: 'google/gemini-3.1-flash-image-preview',
27
+ /** 概念图路径(确认过风格的样本,所有后续图的参考来源) */
28
+ referenceImage: 'assets/images/concept/approved_sample.png',
29
+ /** 输出目录 */
30
+ outputDir: 'assets/images/batch',
31
+ /** 图片比例 */
32
+ aspectRatio: '1:1',
33
+ /**
34
+ * 统一风格描述(从 design-brief.md 复制,粘贴到每个 prompt 末尾)
35
+ * 示例:"flat 2D icon, vibrant colors, clean edges, white background, no shadow"
36
+ */
37
+ style: '<从 design-brief 复制的统一风格描述>',
38
+ };
39
+ // ============ DATA — 定义要生成的素材列表 ============
40
+ const ITEMS = [
41
+ { name: 'item_01', desc: '<素材描述 1>' },
42
+ { name: 'item_02', desc: '<素材描述 2>' },
43
+ // 继续添加...
44
+ ];
45
+ // ============ LOGIC — 通常不需要修改 ============
46
+
47
+ const LOG_FILE = 'ta-workspace/logs/gen-batch.log';
48
+ mkdirSync(CONFIG.outputDir, { recursive: true });
49
+ mkdirSync('ta-workspace/logs', { recursive: true });
50
+
51
+ function log(msg) {
52
+ const line = `[${new Date().toISOString()}] ${msg}`;
53
+ console.log(line);
54
+ appendFileSync(LOG_FILE, line + '\n');
55
+ }
56
+
57
+ log(`=== Batch Generation Start ===`);
58
+ log(`Total: ${ITEMS.length} | Model: ${CONFIG.model}`);
59
+
60
+ let done = 0, skipped = 0, failed = 0;
61
+ const failures = [];
62
+
63
+ for (let i = 0; i < ITEMS.length; i++) {
64
+ const item = ITEMS[i];
65
+ const outPath = `${CONFIG.outputDir}/${item.name}.png`;
66
+
67
+ if (existsSync(outPath)) {
68
+ log(`[SKIP] (${i + 1}/${ITEMS.length}) ${item.name}`);
69
+ skipped++;
70
+ continue;
71
+ }
72
+
73
+ log(`[GEN ] (${i + 1}/${ITEMS.length}) ${item.name}`);
74
+
75
+ const promptEscaped = `${item.desc}. ${CONFIG.style}`.replace(/"/g, '\\"');
76
+ const cmd =
77
+ `playcraft tools generate-image` +
78
+ ` --prompt "${promptEscaped}"` +
79
+ ` --output "${outPath}"` +
80
+ ` --aspect-ratio ${CONFIG.aspectRatio}` +
81
+ ` --reference-image "${CONFIG.referenceImage}"` +
82
+ ` --image-model "${CONFIG.model}"`;
83
+
84
+ try {
85
+ execSync(cmd, { stdio: 'inherit', timeout: 120_000 });
86
+ done++;
87
+ log(`[OK ] ${item.name}`);
88
+ } catch (e) {
89
+ log(`[FAIL] ${item.name}: ${e.message?.slice(0, 100)}`);
90
+ failures.push(item.name);
91
+ failed++;
92
+ }
93
+ }
94
+
95
+ log(`\n=== Complete: Done=${done} Skipped=${skipped} Failed=${failed}/${ITEMS.length} ===`);
96
+ if (failures.length > 0) log(`Failed: ${failures.join(', ')}`);
97
+ if (failed > 0) process.exit(1);
@@ -0,0 +1,118 @@
1
+ // ============================================================
2
+ // gen-edit-variants.template.mjs — 基图 + Edit 模型生成变体脚本模板
3
+ // 用途:先用高质量模型生成 1 张完美基图,再用 edit 模型批量修改出一组变体
4
+ //
5
+ // 适用场景:结构相同、只改局部的变体集合
6
+ // - 扑克牌(换花色/换数字)
7
+ // - 棋子系列(换颜色/换图案)
8
+ // - 图标集(换内容符号)
9
+ //
10
+ // 使用方式:
11
+ // 1. cp .claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs ta-workspace/scripts/gen-<name>-variants.mjs
12
+ // 2. Phase 1:先手动生成基图(见下方说明),存为 CONFIG.baseImage 路径
13
+ // 3. 填写 CONFIG 和 VARIANTS,然后 node ta-workspace/scripts/gen-<name>-variants.mjs
14
+ //
15
+ // Edit 模型决策(按优先级):
16
+ // 1. mulerouter/qwen-image-edit-max — 纯 edit,局部修改能力最强
17
+ // 2. mulerouter/gpt-image-2 — 有图走 /edit 端点,质量高
18
+ // 3. mulerouter/wan2.6-image — 图生图,回退选项
19
+ // ============================================================
20
+
21
+ import { execSync } from 'child_process';
22
+ import { existsSync, mkdirSync, appendFileSync } from 'fs';
23
+
24
+ // ============ CONFIG — 修改这里 ============
25
+ const CONFIG = {
26
+ /**
27
+ * Phase 1 基图路径(必须已存在)
28
+ * 生成基图的命令示例(gpt-image-2 质量最高,双 provider 回退):
29
+ * playcraft tools generate-image \
30
+ * --prompt "A playing card: Ace of Spades. [完整风格描述]" \
31
+ * --output assets/images/cards/base_ace_spades.png \
32
+ * --aspect-ratio 3:4 \
33
+ * --image-model iegg-litellm/gpt-image-2
34
+ */
35
+ baseImage: 'assets/images/cards/base_ace_spades.png',
36
+ /** Edit 模型(qwen-image-edit-max 局部修改能力最强) */
37
+ editModel: 'mulerouter/qwen-image-edit-max',
38
+ /** 输出目录 */
39
+ outputDir: 'assets/images/cards',
40
+ /** 图片比例(建议与基图相同) */
41
+ aspectRatio: '3:4',
42
+ };
43
+ // ============ DATA — 定义要生成的变体列表 ============
44
+ // editPrompt 应该描述"修改指令"而不是"完整重新描述"
45
+ // 好的写法:'Change the rank symbol from A to 2, show two spade symbols in center'
46
+ // 差的写法:'A playing card with two spade symbols...'(这是重新生成,不是编辑)
47
+ const VARIANTS = [
48
+ {
49
+ name: 'spades_2',
50
+ editPrompt: 'Change the rank symbol from A to 2. Show two spade suit symbols in center.',
51
+ },
52
+ {
53
+ name: 'spades_3',
54
+ editPrompt: 'Change the rank symbol from A to 3. Show three spade suit symbols in center.',
55
+ },
56
+ // 继续添加变体...
57
+ ];
58
+ // ============ LOGIC — 通常不需要修改 ============
59
+
60
+ const LOG_FILE = 'ta-workspace/logs/gen-edit-variants.log';
61
+ mkdirSync(CONFIG.outputDir, { recursive: true });
62
+ mkdirSync('ta-workspace/logs', { recursive: true });
63
+
64
+ function log(msg) {
65
+ const line = `[${new Date().toISOString()}] ${msg}`;
66
+ console.log(line);
67
+ appendFileSync(LOG_FILE, line + '\n');
68
+ }
69
+
70
+ // 检查基图
71
+ if (!existsSync(CONFIG.baseImage)) {
72
+ log(`ERROR: Base image not found: ${CONFIG.baseImage}`);
73
+ log(`Please generate the base image first (Phase 1), then run this script.`);
74
+ process.exit(1);
75
+ }
76
+
77
+ log(`=== Edit Variants Start ===`);
78
+ log(`Base: ${CONFIG.baseImage} | Model: ${CONFIG.editModel}`);
79
+ log(`Total variants: ${VARIANTS.length}`);
80
+
81
+ let done = 0, skipped = 0, failed = 0;
82
+ const failures = [];
83
+
84
+ for (let i = 0; i < VARIANTS.length; i++) {
85
+ const variant = VARIANTS[i];
86
+ const outPath = `${CONFIG.outputDir}/${variant.name}.png`;
87
+
88
+ if (existsSync(outPath)) {
89
+ log(`[SKIP] (${i + 1}/${VARIANTS.length}) ${variant.name}`);
90
+ skipped++;
91
+ continue;
92
+ }
93
+
94
+ log(`[EDIT] (${i + 1}/${VARIANTS.length}) ${variant.name}: ${variant.editPrompt.slice(0, 60)}...`);
95
+
96
+ const promptEscaped = variant.editPrompt.replace(/"/g, '\\"');
97
+ const cmd =
98
+ `playcraft tools generate-image` +
99
+ ` --prompt "${promptEscaped}"` +
100
+ ` --output "${outPath}"` +
101
+ ` --aspect-ratio ${CONFIG.aspectRatio}` +
102
+ ` --reference-image "${CONFIG.baseImage}"` +
103
+ ` --image-model "${CONFIG.editModel}"`;
104
+
105
+ try {
106
+ execSync(cmd, { stdio: 'inherit', timeout: 120_000 });
107
+ done++;
108
+ log(`[OK ] ${variant.name}`);
109
+ } catch (e) {
110
+ log(`[FAIL] ${variant.name}: ${e.message?.slice(0, 100)}`);
111
+ failures.push(variant.name);
112
+ failed++;
113
+ }
114
+ }
115
+
116
+ log(`\n=== Complete: Done=${done} Skipped=${skipped} Failed=${failed}/${VARIANTS.length} ===`);
117
+ if (failures.length > 0) log(`Failed: ${failures.join(', ')}`);
118
+ if (failed > 0) process.exit(1);
@@ -0,0 +1,137 @@
1
+ // ============================================================
2
+ // process-batch.template.mjs — 批量图片处理脚本模板
3
+ // 用途:对一批图片执行去背景 / trim + resize + 验证
4
+ //
5
+ // 使用方式:
6
+ // 1. cp .claude/skills/playcraft-image-generation/reference/process-batch.template.mjs ta-workspace/scripts/process-<name>.mjs
7
+ // 2. 修改下方 CONFIG 区域(特别是 SKIP_REMOVE_BG 选项)
8
+ // 3. node ta-workspace/scripts/process-<name>.mjs
9
+ //
10
+ // 背景处理决策(修改 CONFIG.skipRemoveBg 前请阅读):
11
+ // - 独立元素(角色/道具/图标)需透明背景 → skipRemoveBg = false(默认)
12
+ // 建议生图时 prompt 加 "on solid bright green #00FF00 background, isolated"
13
+ // - 卡牌/棋子/UI面板(矩形本体不需透明)→ skipRemoveBg = true
14
+ // 生图时 prompt 加 "flat 2D, no shadow, no 3D effect, clean edges"
15
+ // ============================================================
16
+
17
+ import { execSync } from 'child_process';
18
+ import { readdirSync, existsSync, mkdirSync, appendFileSync, unlinkSync } from 'fs';
19
+ import { join, basename, extname } from 'path';
20
+
21
+ // ============ CONFIG — 修改这里 ============
22
+ const CONFIG = {
23
+ /** 输入目录(gen-batch 的输出目录) */
24
+ inputDir: 'assets/images/batch',
25
+ /** 输出目录 */
26
+ outputDir: 'assets/images/processed',
27
+ /** 临时文件目录(去背景中间结果) */
28
+ tmpDir: 'ta-workspace/tmp',
29
+ /** 目标宽度(像素) */
30
+ targetW: 128,
31
+ /** 目标高度(像素) */
32
+ targetH: 128,
33
+ /**
34
+ * 跳过去背景步骤
35
+ * - false(默认):执行 remove-background(绿幕素材/独立元素)
36
+ * - true:跳过,只做 trim + resize(卡牌/棋子等矩形本体素材)
37
+ */
38
+ skipRemoveBg: false,
39
+ /**
40
+ * floodfill 容差(0–255)
41
+ * 绿幕背景建议 25;默认白背景可用 15
42
+ * 仅在 skipRemoveBg = false 时生效
43
+ */
44
+ removeBgTolerance: 25,
45
+ /** resize 时的 fit 模式:contain / cover / fill / inside / outside */
46
+ resizeFit: 'contain',
47
+ };
48
+ // ============ LOGIC — 通常不需要修改 ============
49
+
50
+ const LOG_FILE = 'ta-workspace/logs/process-batch.log';
51
+ mkdirSync(CONFIG.outputDir, { recursive: true });
52
+ mkdirSync(CONFIG.tmpDir, { recursive: true });
53
+ mkdirSync('ta-workspace/logs', { recursive: true });
54
+
55
+ function log(msg) {
56
+ const line = `[${new Date().toISOString()}] ${msg}`;
57
+ console.log(line);
58
+ appendFileSync(LOG_FILE, line + '\n');
59
+ }
60
+
61
+ const SUPPORTED_EXTS = new Set(['.png', '.jpg', '.jpeg', '.webp']);
62
+ const files = readdirSync(CONFIG.inputDir)
63
+ .filter(f => SUPPORTED_EXTS.has(extname(f).toLowerCase()))
64
+ .sort()
65
+ .map(f => join(CONFIG.inputDir, f));
66
+
67
+ log(`=== Batch Processing Start ===`);
68
+ log(`Files: ${files.length} | skipRemoveBg: ${CONFIG.skipRemoveBg} | Target: ${CONFIG.targetW}x${CONFIG.targetH}`);
69
+
70
+ let done = 0, skipped = 0, failed = 0;
71
+ const failures = [];
72
+
73
+ for (let i = 0; i < files.length; i++) {
74
+ const inputPath = files[i];
75
+ const name = basename(inputPath, extname(inputPath));
76
+ const outPath = join(CONFIG.outputDir, `${name}.png`);
77
+
78
+ if (existsSync(outPath)) {
79
+ log(`[SKIP] (${i + 1}/${files.length}) ${name}`);
80
+ skipped++;
81
+ continue;
82
+ }
83
+
84
+ log(`[PROC] (${i + 1}/${files.length}) ${name}`);
85
+
86
+ try {
87
+ if (CONFIG.skipRemoveBg) {
88
+ // 卡牌/棋子等矩形本体:直接 resize(不需要去背景)
89
+ execSync(
90
+ `playcraft image resize` +
91
+ ` --input "${inputPath}"` +
92
+ ` --output "${outPath}"` +
93
+ ` --width ${CONFIG.targetW}` +
94
+ ` --height ${CONFIG.targetH}` +
95
+ ` --fit ${CONFIG.resizeFit}`,
96
+ { stdio: 'inherit' },
97
+ );
98
+ } else {
99
+ // 独立元素:先去背景,再 resize
100
+ const tmpNobg = join(CONFIG.tmpDir, `${name}_nobg.png`);
101
+
102
+ // 步骤 1:去背景(绿幕 tolerance=25 效果最好)
103
+ execSync(
104
+ `playcraft image remove-background` +
105
+ ` --input "${inputPath}"` +
106
+ ` --output "${tmpNobg}"` +
107
+ ` --tolerance ${CONFIG.removeBgTolerance}`,
108
+ { stdio: 'inherit' },
109
+ );
110
+
111
+ // 步骤 2:resize 到目标尺寸
112
+ execSync(
113
+ `playcraft image resize` +
114
+ ` --input "${tmpNobg}"` +
115
+ ` --output "${outPath}"` +
116
+ ` --width ${CONFIG.targetW}` +
117
+ ` --height ${CONFIG.targetH}` +
118
+ ` --fit ${CONFIG.resizeFit}`,
119
+ { stdio: 'inherit' },
120
+ );
121
+
122
+ // 清理临时文件
123
+ if (existsSync(tmpNobg)) unlinkSync(tmpNobg);
124
+ }
125
+
126
+ log(`[OK ] ${name}`);
127
+ done++;
128
+ } catch (e) {
129
+ log(`[FAIL] ${name}: ${e.message?.slice(0, 100)}`);
130
+ failures.push(name);
131
+ failed++;
132
+ }
133
+ }
134
+
135
+ log(`\n=== Complete: Done=${done} Skipped=${skipped} Failed=${failed}/${files.length} ===`);
136
+ if (failures.length > 0) log(`Failed: ${failures.join(', ')}`);
137
+ if (failed > 0) process.exit(1);