@playcraft/cli 0.1.42 → 0.1.43-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 (378) 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 +87 -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/codex/app-server.js +1040 -0
  72. package/dist/workspace-runtime/codex/compact.js +46 -0
  73. package/dist/workspace-runtime/codex/config-toml.js +107 -0
  74. package/dist/workspace-runtime/codex/jsonrpc-stdio.js +145 -0
  75. package/dist/workspace-runtime/codex/launcher-client.js +177 -0
  76. package/dist/workspace-runtime/codex/loopback.js +146 -0
  77. package/dist/workspace-runtime/codex/mcp-config.js +39 -0
  78. package/dist/workspace-runtime/codex/model-broker.js +263 -0
  79. package/dist/workspace-runtime/codex/native-adapter.js +9 -0
  80. package/dist/workspace-runtime/codex/permissions.js +70 -0
  81. package/dist/workspace-runtime/codex/thread-image.js +38 -0
  82. package/dist/workspace-runtime/codex/ui-instructions.js +4 -0
  83. package/dist/workspace-runtime/codex/ui-tools.js +186 -0
  84. package/dist/workspace-runtime/codex/work-mode.js +15 -0
  85. package/dist/workspace-runtime/main.js +10 -0
  86. package/dist/workspace-runtime/persistence/journal.js +365 -0
  87. package/dist/workspace-runtime/persistence/native-subagents.js +162 -0
  88. package/dist/workspace-runtime/persistence/sqlite-client.js +77 -0
  89. package/dist/workspace-runtime/persistence/sqlite-worker.js +1161 -0
  90. package/dist/workspace-runtime/persistence/stopped-execution.js +77 -0
  91. package/dist/workspace-runtime/previews/output.js +36 -0
  92. package/dist/workspace-runtime/previews/publish.js +262 -0
  93. package/dist/workspace-runtime/previews/single-file.js +43 -0
  94. package/dist/workspace-runtime/processes/managed-writes.js +69 -0
  95. package/dist/workspace-runtime/production/content-changes.js +36 -0
  96. package/dist/workspace-runtime/production/contracts.js +19 -0
  97. package/dist/workspace-runtime/production/controller.js +225 -0
  98. package/dist/workspace-runtime/production/dependencies.js +60 -0
  99. package/dist/workspace-runtime/production/native.js +239 -0
  100. package/dist/workspace-runtime/production/processes.js +102 -0
  101. package/dist/workspace-runtime/production/save-command.js +35 -0
  102. package/dist/workspace-runtime/production/source-archive.js +137 -0
  103. package/dist/workspace-runtime/production/source-copy.js +92 -0
  104. package/dist/workspace-runtime/production/stages.js +354 -0
  105. package/dist/workspace-runtime/production/storage.js +75 -0
  106. package/dist/workspace-runtime/serve.js +281 -0
  107. package/dist/workspace-runtime/server/auth.js +21 -0
  108. package/dist/workspace-runtime/server/connectivity.js +201 -0
  109. package/dist/workspace-runtime/server/desktop-host.js +429 -0
  110. package/dist/workspace-runtime/server/desktop-preview-config.js +81 -0
  111. package/dist/workspace-runtime/server/desktop-preview-service.js +157 -0
  112. package/dist/workspace-runtime/server/desktop-preview-static.js +53 -0
  113. package/dist/workspace-runtime/server/desktop-preview.js +189 -0
  114. package/dist/workspace-runtime/server/dispatch.js +1335 -0
  115. package/dist/workspace-runtime/server/endpoints.js +21 -0
  116. package/dist/workspace-runtime/server/execution-group.js +90 -0
  117. package/dist/workspace-runtime/server/http.js +1291 -0
  118. package/dist/workspace-runtime/server/lock.js +53 -0
  119. package/dist/workspace-runtime/server/rfb-watch-gate.js +168 -0
  120. package/dist/workspace-runtime/server/session-restore.js +84 -0
  121. package/dist/workspace-runtime/server/source-uploader.js +138 -0
  122. package/dist/workspace-runtime/server/terminal-host.js +366 -0
  123. package/dist/workspace-runtime/server/types.js +1 -0
  124. package/dist/workspace-runtime/server/workspace-transfer.js +168 -0
  125. package/dist/workspace-runtime/workspaces/archive.js +207 -0
  126. package/dist/workspace-runtime/workspaces/artifact-events.js +55 -0
  127. package/dist/workspace-runtime/workspaces/artifact-files.js +199 -0
  128. package/dist/workspace-runtime/workspaces/artifact-receipts.js +89 -0
  129. package/dist/workspace-runtime/workspaces/artifacts.js +282 -0
  130. package/dist/workspace-runtime/workspaces/asset-library-import.js +366 -0
  131. package/dist/workspace-runtime/workspaces/attachment-content.js +73 -0
  132. package/dist/workspace-runtime/workspaces/attachments.js +185 -0
  133. package/dist/workspace-runtime/workspaces/batch-commit.js +142 -0
  134. package/dist/workspace-runtime/workspaces/binary-content.js +65 -0
  135. package/dist/workspace-runtime/workspaces/binary-write.js +112 -0
  136. package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
  137. package/dist/workspace-runtime/workspaces/cli-credentials.js +111 -0
  138. package/dist/workspace-runtime/workspaces/composer-context.js +147 -0
  139. package/dist/workspace-runtime/workspaces/context-error.js +2 -0
  140. package/dist/workspace-runtime/workspaces/dependencies.js +264 -0
  141. package/dist/workspace-runtime/workspaces/developer-command.js +64 -0
  142. package/dist/workspace-runtime/workspaces/directories.js +137 -0
  143. package/dist/workspace-runtime/workspaces/directory-access.js +37 -0
  144. package/dist/workspace-runtime/workspaces/directory-attachments.js +245 -0
  145. package/dist/workspace-runtime/workspaces/directory-create.js +57 -0
  146. package/dist/workspace-runtime/workspaces/directory-maintenance.js +111 -0
  147. package/dist/workspace-runtime/workspaces/directory-stats.js +49 -0
  148. package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
  149. package/dist/workspace-runtime/workspaces/empty-template.js +42 -0
  150. package/dist/workspace-runtime/workspaces/file-content.js +48 -0
  151. package/dist/workspace-runtime/workspaces/files-search.js +116 -0
  152. package/dist/workspace-runtime/workspaces/files.js +150 -0
  153. package/dist/workspace-runtime/workspaces/git-credential-broker.js +312 -0
  154. package/dist/workspace-runtime/workspaces/git-credential-helper.js +68 -0
  155. package/dist/workspace-runtime/workspaces/git-direct-store.js +155 -0
  156. package/dist/workspace-runtime/workspaces/git.js +670 -0
  157. package/dist/workspace-runtime/workspaces/instructions.js +56 -0
  158. package/dist/workspace-runtime/workspaces/json5-edit.js +170 -0
  159. package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
  160. package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
  161. package/dist/workspace-runtime/workspaces/parameters.js +272 -0
  162. package/dist/workspace-runtime/workspaces/prepare.js +278 -0
  163. package/dist/workspace-runtime/workspaces/registry.js +251 -0
  164. package/dist/workspace-runtime/workspaces/remix-references.js +301 -0
  165. package/dist/workspace-runtime/workspaces/revisions.js +31 -0
  166. package/dist/workspace-runtime/workspaces/session-image.js +104 -0
  167. package/dist/workspace-runtime/workspaces/shared-git.js +40 -0
  168. package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +95 -0
  169. package/dist/workspace-runtime/workspaces/skills.js +191 -0
  170. package/dist/workspace-runtime/workspaces/transfer-quota.js +69 -0
  171. package/dist/workspace-runtime/workspaces/transfer.js +471 -0
  172. package/dist/workspace-runtime/workspaces/turn-changes.js +75 -0
  173. package/dist/workspace-runtime/workspaces/video-attachments.js +49 -0
  174. package/package.json +15 -5
  175. package/project-template/.claude/agents/refs/ta-image-generation-detail.md +123 -67
  176. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
  177. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
  178. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
  179. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
  180. package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
  181. package/project-template/.claude/skills/playcraft-replica-validation/SKILL.md +25 -0
  182. package/project-template/.claude/skills/playcraft-replica-validation/references/contracts.md +79 -0
  183. package/project-template/.claude/skills/playcraft-video-understanding/SKILL.md +29 -0
  184. package/project-template/.claude/skills/playcraft-video-understanding/references/contracts.md +37 -0
  185. package/project-template-v2/.claude/agents/artist.md +82 -0
  186. package/project-template-v2/.claude/agents/developer.md +153 -0
  187. package/project-template-v2/.claude/agents/game-designer.md +264 -0
  188. package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
  189. package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
  190. package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
  191. package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
  192. package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
  193. package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
  194. package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
  195. package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
  196. package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
  197. package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
  198. package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
  199. package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  200. package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  201. package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
  202. package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  203. package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
  204. package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
  205. package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  206. package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
  207. package/project-template-v2/.claude/agents/reviewer.md +75 -0
  208. package/project-template-v2/.claude/agents/technical-artist.md +86 -0
  209. package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
  210. package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
  211. package/project-template-v2/.claude/settings.json +33 -0
  212. package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
  213. package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
  214. package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
  215. package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
  216. package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
  217. package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
  218. package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
  219. package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  220. package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
  221. package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  222. package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  223. package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
  224. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  225. package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  226. package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  227. package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +298 -0
  228. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  229. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  230. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +324 -0
  231. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  232. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  233. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  234. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  235. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  236. package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  237. package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +219 -0
  238. package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
  239. package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
  240. package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
  241. package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
  242. package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  243. package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
  244. package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
  245. package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  246. package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  247. package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  248. package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  249. package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
  250. package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  251. package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  252. package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  253. package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
  254. package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
  255. package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
  256. package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  257. package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
  258. package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
  259. package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
  260. package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
  261. package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
  262. package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
  263. package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
  264. package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
  265. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
  266. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
  267. package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
  268. package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
  269. package/project-template-v2/.claude/snapshot.mjs +263 -0
  270. package/project-template-v2/.playcraft/skills.lock.json +152 -0
  271. package/project-template-v2/CLAUDE.md +146 -0
  272. package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
  273. package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
  274. package/project-template-v2/assets/bundles/.gitkeep +0 -0
  275. package/project-template-v2/assets/images/bg/.gitkeep +0 -0
  276. package/project-template-v2/assets/images/reference/.gitkeep +0 -0
  277. package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
  278. package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
  279. package/project-template-v2/assets/images/ui/.gitkeep +0 -0
  280. package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
  281. package/project-template-v2/assets/models/.gitkeep +0 -0
  282. package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
  283. package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
  284. package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
  285. package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
  286. package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
  287. package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
  288. package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
  289. package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
  290. package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
  291. package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
  292. package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
  293. package/project-template-v2/docs/project-state.json +60 -0
  294. package/project-template-v2/docs/project-state.md +72 -0
  295. package/project-template-v2/docs/standards/README.md +225 -0
  296. package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
  297. package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
  298. package/project-template-v2/docs/standards/artifacts/design.md +22 -0
  299. package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
  300. package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
  301. package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
  302. package/project-template-v2/game/index.ts +18 -0
  303. package/project-template-v2/globals.d.ts +51 -0
  304. package/project-template-v2/index.css +34 -0
  305. package/project-template-v2/index.html +18 -0
  306. package/project-template-v2/main.ts +9 -0
  307. package/project-template-v2/package.json +46 -0
  308. package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
  309. package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
  310. package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
  311. package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
  312. package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
  313. package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
  314. package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
  315. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
  316. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
  317. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
  318. package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
  319. package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
  320. package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
  321. package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
  322. package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
  323. package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
  324. package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
  325. package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
  326. package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
  327. package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
  328. package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
  329. package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
  330. package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
  331. package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
  332. package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
  333. package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
  334. package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
  335. package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
  336. package/project-template-v2/skills/playable-record/SKILL.md +140 -0
  337. package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
  338. package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
  339. package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
  340. package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
  341. package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
  342. package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
  343. package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
  344. package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
  345. package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
  346. package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
  347. package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
  348. package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
  349. package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
  350. package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
  351. package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
  352. package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
  353. package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
  354. package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
  355. package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
  356. package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
  357. package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
  358. package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
  359. package/project-template-v2/tsconfig.json +20 -0
  360. package/project-template-v2/vite.config.ts +27 -0
  361. package/project-templates/batch-locks/phaser.yaml +922 -0
  362. package/project-templates/batch-locks/threejs.yaml +978 -0
  363. package/project-templates/empty/AGENTS.md +41 -0
  364. package/project-templates/empty/gitignore +33 -0
  365. package/project-templates/phaser/.claude/agents/refs/ta-image-generation-detail.md +59 -59
  366. package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
  367. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
  368. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
  369. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
  370. package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
  371. package/project-templates/threejs/.claude/agents/refs/ta-image-generation-detail.md +59 -59
  372. package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
  373. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
  374. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
  375. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
  376. package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
  377. package/dist/commands/tools-image-context.js +0 -29
  378. package/dist/utils/image-asset-context.js +0 -228
@@ -0,0 +1,31 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { constants } from 'node:fs';
3
+ import { open } from 'node:fs/promises';
4
+ import { WORKSPACE_VIDEO_ATTACHMENT_MAX_BYTES } from '@playcraft/common/cloud-workspace/runtime';
5
+ export async function sampleDiskFile(path) {
6
+ const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
7
+ try {
8
+ const before = await handle.stat();
9
+ if (!before.isFile() || before.size > WORKSPACE_VIDEO_ATTACHMENT_MAX_BYTES)
10
+ throw new Error('snapshot_body_missing');
11
+ const digest = createHash('sha256');
12
+ const chunk = Buffer.allocUnsafe(64 * 1024);
13
+ let position = 0;
14
+ for (;;) {
15
+ const { bytesRead } = await handle.read(chunk, 0, chunk.length, position);
16
+ if (!bytesRead)
17
+ break;
18
+ digest.update(chunk.subarray(0, bytesRead));
19
+ position += bytesRead;
20
+ if (position > WORKSPACE_VIDEO_ATTACHMENT_MAX_BYTES)
21
+ throw new Error('snapshot_body_missing');
22
+ }
23
+ const after = await handle.stat();
24
+ if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || position !== before.size)
25
+ throw new Error('snapshot_body_missing');
26
+ return { hash: digest.digest('hex'), size: position, mode: before.mode & 0o777, modifiedAt: before.mtime.toISOString() };
27
+ }
28
+ finally {
29
+ await handle.close();
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ import { cp, mkdir } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { resolveCliPackageRoot } from '../../scaffold/compose.js';
4
+ import { importBuiltinProjectSkills } from '../../project-skills/builtin-import.js';
5
+ import { createHash } from 'node:crypto';
6
+ import { canonicalProjectSkillsJson } from '@playcraft/common/project-skills';
7
+ import { syncLocalProjectSkills } from '../../project-skills/local-store.js';
8
+ import { selectOptionalPlatformSkills } from './optional-platform-skills.js';
9
+ export const EMPTY_WORKSPACE_REPOSITORY_SKILLS = [
10
+ 'playcraft-skill-recommender',
11
+ 'playcraft-image-generation',
12
+ 'playcraft-audio-generation',
13
+ 'playcraft-image-processing',
14
+ 'playcraft-build-optimizer',
15
+ ];
16
+ export const EMPTY_WORKSPACE_PLATFORM_SKILLS = ['playcraft-video-understanding', 'playcraft-replica-validation'];
17
+ export const EMPTY_WORKSPACE_DEFAULT_SKILLS = [...EMPTY_WORKSPACE_REPOSITORY_SKILLS, ...EMPTY_WORKSPACE_PLATFORM_SKILLS];
18
+ /** Only called in a new, unpublished staging directory; existing workspaces are never scaffolded. */
19
+ export async function scaffoldEmptyWorkspace(root, skillCache, access) {
20
+ const selected = await selectOptionalPlatformSkills([...EMPTY_WORKSPACE_PLATFORM_SKILLS], access);
21
+ const cliRoot = resolveCliPackageRoot();
22
+ const template = join(cliRoot, 'project-templates', 'empty');
23
+ for (const [source, target] of [
24
+ ['gitignore', '.gitignore'],
25
+ ['AGENTS.md', 'AGENTS.md'],
26
+ ]) {
27
+ await cp(join(template, source), join(root, target), { force: false, errorOnExist: true });
28
+ }
29
+ const skills = join(root, '.agents', 'skills');
30
+ await mkdir(skills, { recursive: true });
31
+ for (const name of EMPTY_WORKSPACE_REPOSITORY_SKILLS) {
32
+ await cp(join(cliRoot, 'project-template', '.claude', 'skills', name), join(skills, name), {
33
+ recursive: true,
34
+ force: false,
35
+ errorOnExist: true,
36
+ });
37
+ }
38
+ const snapshot = await syncLocalProjectSkills(root, skillCache);
39
+ if (selected)
40
+ await importBuiltinProjectSkills(root, { names: [...EMPTY_WORKSPACE_PLATFORM_SKILLS], expectedDeclarationHash: snapshot.lock.declarationHash,
41
+ expectedLockHash: createHash('sha256').update(canonicalProjectSkillsJson(snapshot.lock)).digest('hex') }, skillCache, access, selected, true);
42
+ }
@@ -0,0 +1,48 @@
1
+ import { constants } from 'node:fs';
2
+ import { lstat, open } from 'node:fs/promises';
3
+ import { basename, extname } from 'node:path';
4
+ import { workspaceRelativePathSchema } from '@playcraft/common/cloud-workspace/runtime';
5
+ import { artifactMime, artifactPath } from './artifact-files.js';
6
+ import { serveOpenedWorkspaceContent } from './binary-content.js';
7
+ import { InvalidWorkspacePathError, resolveWorkspaceFile } from './files.js';
8
+ const additionalMediaTypes = {
9
+ '.aac': 'audio/aac', '.opus': 'audio/ogg', '.oga': 'audio/ogg', '.aif': 'audio/aiff', '.aiff': 'audio/aiff',
10
+ '.bmp': 'image/bmp', '.ico': 'image/vnd.microsoft.icon', '.heic': 'image/heic', '.heif': 'image/heif',
11
+ '.tif': 'image/tiff', '.tiff': 'image/tiff',
12
+ };
13
+ export async function serveWorkspaceFileContent(root, path, request, response) {
14
+ let handle;
15
+ let size;
16
+ try {
17
+ if (!workspaceRelativePathSchema.safeParse(path).success)
18
+ throw new InvalidWorkspacePathError(path);
19
+ // Check every component before resolving, so missing files cannot create parent directories.
20
+ await artifactPath(root, path);
21
+ const target = await resolveWorkspaceFile(root, path);
22
+ handle = await open(target, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
23
+ const stat = await handle.stat();
24
+ if (!stat.isFile() || stat.nlink !== 1)
25
+ throw new Error('file_not_found');
26
+ // Bind the open handle to the authorized file even if a parent changed during open.
27
+ const verified = await artifactPath(root, path);
28
+ const current = await lstat(verified);
29
+ if (!current.isFile() || current.nlink !== 1 || current.dev !== stat.dev || current.ino !== stat.ino)
30
+ throw new InvalidWorkspacePathError(path);
31
+ size = stat.size;
32
+ }
33
+ catch (error) {
34
+ await handle?.close();
35
+ const code = error?.code;
36
+ const invalid = error instanceof InvalidWorkspacePathError || (error instanceof Error && error.message === 'invalid_artifact_path');
37
+ const denied = code === 'EACCES' || code === 'EPERM';
38
+ response.writeHead(invalid ? 400 : denied ? 403 : 404, { 'content-type': 'application/json', 'cache-control': 'no-store' });
39
+ response.end(JSON.stringify({ error: invalid ? 'invalid_workspace_path' : denied ? 'workspace_permission_denied' : 'file_not_found' }));
40
+ return;
41
+ }
42
+ await serveOpenedWorkspaceContent({
43
+ handle,
44
+ name: basename(path),
45
+ mimeType: additionalMediaTypes[extname(path).toLowerCase()] ?? artifactMime(path),
46
+ size,
47
+ }, request, response);
48
+ }
@@ -0,0 +1,116 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstat, opendir, realpath } from 'node:fs/promises';
3
+ import { join, relative, sep } from 'node:path';
4
+ import { workspaceFileSearchQuerySchema, workspaceRelativePathSchema, } from '@playcraft/common/cloud-workspace/runtime';
5
+ const SKIP_DIRECTORIES = new Set(['.git', 'node_modules', '.playcraft', '.next', 'dist', 'build', 'coverage', '.turbo']);
6
+ const SCAN_PAGE_ENTRIES = 1000;
7
+ export class InvalidWorkspaceSearchError extends Error {
8
+ code;
9
+ constructor(code = 'invalid_workspace_search') {
10
+ super(code);
11
+ this.code = code;
12
+ this.name = 'InvalidWorkspaceSearchError';
13
+ }
14
+ }
15
+ /** Enumerates names only. The cursor is scoped to the resolved checkout and query, never to a caller supplied path. */
16
+ export async function searchWorkspaceFiles(root, query, options = {}) {
17
+ const parsed = workspaceFileSearchQuerySchema.safeParse(query);
18
+ if (!parsed.success)
19
+ throw new InvalidWorkspaceSearchError();
20
+ options.signal?.throwIfAborted();
21
+ const rootReal = await realpath(root);
22
+ const needle = parsed.data.query.toLocaleLowerCase();
23
+ const scope = createHash('sha256').update(rootReal).update('\0').update(needle).digest('hex');
24
+ const start = decodeCursor(parsed.data.cursor, scope);
25
+ const files = [];
26
+ let offset = 0;
27
+ for await (const path of walk(rootReal, rootReal, options.signal)) {
28
+ options.signal?.throwIfAborted();
29
+ offset += 1;
30
+ if (offset <= start)
31
+ continue;
32
+ if (path && path.toLocaleLowerCase().includes(needle)) {
33
+ const target = join(rootReal, ...path.split('/'));
34
+ const info = await lstat(target).catch(ignoreUnavailable);
35
+ const targetReal = info?.isFile() && !info.isSymbolicLink() ? await realpath(target).catch(ignoreUnavailable) : undefined;
36
+ if (targetReal && inside(rootReal, targetReal))
37
+ files.push({ path });
38
+ }
39
+ if (files.length >= parsed.data.limit || offset - start >= SCAN_PAGE_ENTRIES) {
40
+ return { files, truncated: true, nextCursor: encodeCursor(scope, offset) };
41
+ }
42
+ }
43
+ return { files, truncated: false };
44
+ }
45
+ async function* walk(root, current, signal) {
46
+ signal?.throwIfAborted();
47
+ const currentInfo = await lstat(current).catch(ignoreUnavailable);
48
+ if (!currentInfo?.isDirectory() || currentInfo.isSymbolicLink())
49
+ return;
50
+ const resolved = await realpath(current).catch(ignoreUnavailable);
51
+ if (!resolved || !inside(root, resolved))
52
+ return;
53
+ const directory = await opendir(resolved).catch(ignoreUnavailable);
54
+ if (!directory)
55
+ return;
56
+ // Recheck after opening: a concurrently replaced directory must not reveal another checkout's paths.
57
+ const openedPath = await realpath(current).catch(ignoreUnavailable);
58
+ if (openedPath !== resolved || !inside(root, openedPath)) {
59
+ await directory.close();
60
+ return;
61
+ }
62
+ for await (const entry of directory) {
63
+ signal?.throwIfAborted();
64
+ if (['.git', 'node_modules', '.playcraft'].includes(entry.name)) {
65
+ yield undefined;
66
+ continue;
67
+ }
68
+ const child = join(resolved, entry.name);
69
+ const path = relative(root, child).split(sep).join('/');
70
+ if (!workspaceRelativePathSchema.safeParse(path).success) {
71
+ yield undefined;
72
+ continue;
73
+ }
74
+ if (entry.isDirectory()) {
75
+ yield undefined;
76
+ if (!SKIP_DIRECTORIES.has(entry.name))
77
+ yield* walk(root, child, signal);
78
+ continue;
79
+ }
80
+ if (!entry.isFile()) {
81
+ yield undefined;
82
+ continue;
83
+ }
84
+ yield path;
85
+ }
86
+ }
87
+ function inside(root, path) {
88
+ const value = relative(root, path);
89
+ return value === '' || (value !== '..' && !value.startsWith(`..${sep}`) && !value.startsWith(sep));
90
+ }
91
+ function ignoreUnavailable(error) {
92
+ if (['ENOENT', 'ENOTDIR', 'EACCES'].includes(error.code ?? ''))
93
+ return undefined;
94
+ throw error;
95
+ }
96
+ function encodeCursor(scope, offset) {
97
+ return Buffer.from(JSON.stringify({ v: 1, scope, offset })).toString('base64url');
98
+ }
99
+ function decodeCursor(cursor, scope) {
100
+ if (!cursor)
101
+ return 0;
102
+ try {
103
+ if (!/^[A-Za-z0-9_-]+$/.test(cursor))
104
+ throw new Error();
105
+ const value = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
106
+ if (typeof value !== 'object' || value === null)
107
+ throw new Error();
108
+ const { v, scope: suppliedScope, offset } = value;
109
+ if (v !== 1 || suppliedScope !== scope || typeof offset !== 'number' || !Number.isSafeInteger(offset) || offset < 0)
110
+ throw new Error();
111
+ return offset;
112
+ }
113
+ catch {
114
+ throw new InvalidWorkspaceSearchError('invalid_workspace_search_cursor');
115
+ }
116
+ }
@@ -0,0 +1,150 @@
1
+ import { lstat, mkdir, readdir, readFile, realpath, writeFile } from 'node:fs/promises';
2
+ import { createHash } from 'node:crypto';
3
+ import { dirname, join, relative, resolve, sep } from 'node:path';
4
+ import { hashWorkspaceFileContent, workspaceFileContentSchema, workspaceFileListSchema, workspaceRelativePathSchema, } from '@playcraft/common/cloud-workspace/runtime';
5
+ import { sampleDiskFile } from './disk-snapshot.js';
6
+ const SKIP_DIRECTORY_NAMES = new Set(['.git', 'node_modules', '.playcraft-temp']);
7
+ const LARGE_FILE_STREAM_THRESHOLD = 8 * 1024 * 1024;
8
+ export class InvalidWorkspacePathError extends Error {
9
+ code = 'invalid_workspace_path';
10
+ constructor(path) {
11
+ super(path);
12
+ this.name = 'InvalidWorkspacePathError';
13
+ }
14
+ }
15
+ export async function ensureWorkspaceRoot(root) {
16
+ await mkdir(root, { recursive: true, mode: 0o700 });
17
+ return realpath(root);
18
+ }
19
+ export async function resolveWorkspaceFile(root, relativePath) {
20
+ const parsed = workspaceRelativePathSchema.safeParse(relativePath);
21
+ if (!parsed.success)
22
+ throw new InvalidWorkspacePathError(relativePath);
23
+ const rootReal = await ensureWorkspaceRoot(root);
24
+ const target = resolve(rootReal, ...parsed.data.split('/'));
25
+ assertInsideRoot(rootReal, target);
26
+ try {
27
+ const existing = await realpath(target);
28
+ assertInsideRoot(rootReal, existing);
29
+ return existing;
30
+ }
31
+ catch (error) {
32
+ if (error.code !== 'ENOENT')
33
+ throw error;
34
+ await assertParentInsideRoot(rootReal, dirname(target));
35
+ return target;
36
+ }
37
+ }
38
+ export async function writeWorkspaceFile(root, relativePath, content) {
39
+ const target = await resolveWorkspaceFile(root, relativePath);
40
+ await mkdir(dirname(target), { recursive: true, mode: 0o700 });
41
+ const bytes = Buffer.from(content, 'utf8');
42
+ await writeFile(target, bytes, { mode: 0o600 });
43
+ return { path: relativePath, contentHash: hashWorkspaceFileContent(content), size: bytes.byteLength };
44
+ }
45
+ export async function readWorkspaceFile(root, relativePath, revisions) {
46
+ const target = await resolveWorkspaceFile(root, relativePath);
47
+ const content = await readFile(target, 'utf8');
48
+ const contentHash = hashWorkspaceFileContent(content);
49
+ return workspaceFileContentSchema.parse({
50
+ path: relativePath,
51
+ revision: revisions[relativePath]?.revision ?? 0,
52
+ contentHash,
53
+ content,
54
+ });
55
+ }
56
+ export async function listWorkspaceFiles(root, revisions) {
57
+ const rootReal = await ensureWorkspaceRoot(root);
58
+ const files = [];
59
+ const directories = new Set();
60
+ const unreadablePaths = new Set();
61
+ for (const relativePath of await walkWorkspaceFiles(rootReal, rootReal, unreadablePaths, directories)) {
62
+ const target = join(rootReal, ...relativePath.split('/'));
63
+ try {
64
+ const stat = await lstat(target);
65
+ if (stat.size > LARGE_FILE_STREAM_THRESHOLD) {
66
+ const sampled = await sampleDiskFile(target);
67
+ files.push({ path: relativePath, revision: revisions[relativePath]?.revision ?? 0, contentHash: sampled.hash, size: sampled.size, modifiedAt: sampled.modifiedAt });
68
+ continue;
69
+ }
70
+ const content = await readFile(target);
71
+ const after = await lstat(target);
72
+ if (stat.ino !== after.ino || stat.size !== after.size || stat.mtimeMs !== after.mtimeMs || stat.ctimeMs !== after.ctimeMs || content.length !== after.size) {
73
+ const sampled = await sampleDiskFile(target);
74
+ files.push({ path: relativePath, revision: revisions[relativePath]?.revision ?? 0, contentHash: sampled.hash, size: sampled.size, modifiedAt: sampled.modifiedAt });
75
+ continue;
76
+ }
77
+ files.push({
78
+ path: relativePath,
79
+ revision: revisions[relativePath]?.revision ?? 0,
80
+ contentHash: createHash('sha256').update(content).digest('hex'),
81
+ size: content.byteLength,
82
+ modifiedAt: after.mtime.toISOString(),
83
+ });
84
+ }
85
+ catch (error) {
86
+ if (!isPermissionDenied(error))
87
+ throw error;
88
+ unreadablePaths.add(relativePath);
89
+ }
90
+ }
91
+ files.sort((left, right) => left.path.localeCompare(right.path));
92
+ return workspaceFileListSchema.parse({ files, directories: [...directories].sort(), ...(unreadablePaths.size ? { unreadablePaths: [...unreadablePaths].sort() } : {}) });
93
+ }
94
+ async function walkWorkspaceFiles(rootReal, current, unreadablePaths, directories) {
95
+ const entries = await readdir(current, { withFileTypes: true });
96
+ const paths = [];
97
+ for (const entry of entries) {
98
+ const child = join(current, entry.name);
99
+ try {
100
+ if (entry.isDirectory()) {
101
+ if (SKIP_DIRECTORY_NAMES.has(entry.name) || entry.name === '.' || entry.name === '..')
102
+ continue;
103
+ const childReal = await realpath(child);
104
+ assertInsideRoot(rootReal, childReal);
105
+ const children = await walkWorkspaceFiles(rootReal, childReal, unreadablePaths, directories);
106
+ directories.add(toPosixRelative(rootReal, childReal));
107
+ paths.push(...children);
108
+ continue;
109
+ }
110
+ if (!entry.isFile() || entry.name === '.gitkeep')
111
+ continue;
112
+ const childReal = await realpath(child);
113
+ assertInsideRoot(rootReal, childReal);
114
+ paths.push(toPosixRelative(rootReal, childReal));
115
+ }
116
+ catch (error) {
117
+ if (!isPermissionDenied(error))
118
+ throw error;
119
+ unreadablePaths.add(toPosixRelative(rootReal, child));
120
+ }
121
+ }
122
+ return paths;
123
+ }
124
+ function isPermissionDenied(error) {
125
+ return ['EACCES', 'EPERM'].includes(String(error?.code));
126
+ }
127
+ async function assertParentInsideRoot(rootReal, parent) {
128
+ if (parent === rootReal)
129
+ return;
130
+ try {
131
+ const parentReal = await realpath(parent);
132
+ assertInsideRoot(rootReal, parentReal);
133
+ }
134
+ catch (error) {
135
+ if (error.code !== 'ENOENT')
136
+ throw error;
137
+ await mkdir(parent, { recursive: true, mode: 0o700 });
138
+ const parentReal = await realpath(parent);
139
+ assertInsideRoot(rootReal, parentReal);
140
+ }
141
+ }
142
+ function assertInsideRoot(rootReal, target) {
143
+ const rel = relative(rootReal, target);
144
+ if (rel === '' || rel.startsWith(`..${sep}`) || rel === '..' || rel.startsWith('..')) {
145
+ throw new InvalidWorkspacePathError(target);
146
+ }
147
+ }
148
+ function toPosixRelative(rootReal, target) {
149
+ return relative(rootReal, target).split(sep).join('/');
150
+ }