@playcraft/cli 0.1.54 → 0.1.56-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.
- package/README.md +83 -15
- package/SKILLS_REGISTRY.md +149 -0
- package/dist/agent/local-backend.js +1 -1
- package/dist/assets/client.js +157 -0
- package/dist/assets/messages.js +48 -0
- package/dist/auth/account-activation.js +157 -0
- package/dist/auth/messages.js +30 -0
- package/dist/cli-root-help.js +4 -0
- package/dist/commands/assets.js +123 -0
- package/dist/commands/build-all.js +5 -19
- package/dist/commands/build-temp.js +26 -0
- package/dist/commands/build.js +53 -28
- package/dist/commands/create.js +26 -33
- package/dist/commands/image-layer-messages.js +37 -0
- package/dist/commands/image-layer-tools.js +185 -0
- package/dist/commands/image.js +2 -73
- package/dist/commands/library-messages.js +46 -0
- package/dist/commands/library.js +130 -0
- package/dist/commands/login.js +84 -42
- package/dist/commands/platform-skills.generated.js +19 -0
- package/dist/commands/playable.js +53 -0
- package/dist/commands/preview-runtime.js +21 -0
- package/dist/commands/skills.js +4 -0
- package/dist/commands/tools-3d.js +11 -0
- package/dist/commands/tools-batch.js +113 -0
- package/dist/commands/tools-generation.js +6 -0
- package/dist/commands/tools.js +2 -0
- package/dist/commands/video.js +122 -0
- package/dist/commands/workspace-runtime.js +54 -0
- package/dist/commands/workspace.js +40 -0
- package/dist/config.js +59 -4
- package/dist/index.js +47 -3
- package/dist/preview-runtime/distribution.js +77 -0
- package/dist/project-skills/builtin-import.js +225 -0
- package/dist/project-skills/commands.js +77 -0
- package/dist/project-skills/lifecycle.js +28 -0
- package/dist/project-skills/local-run.js +112 -0
- package/dist/project-skills/local-store.js +221 -0
- package/dist/project-skills/messages.js +80 -0
- package/dist/project-skills/reconcile.js +62 -0
- package/dist/project-skills/remote-cache.js +51 -0
- package/dist/project-skills/validation.js +19 -0
- package/dist/recording/messages.js +40 -0
- package/dist/recording/project-digest.js +85 -0
- package/dist/recording/recorder.js +293 -0
- package/dist/recording/scenario.js +50 -0
- package/dist/remix/clone.js +2 -0
- package/dist/remix/init-template.js +2 -0
- package/dist/remix/pull.js +2 -0
- package/dist/remix/push.js +21 -1
- package/dist/skill-registry/client.js +345 -0
- package/dist/skill-registry/commands.js +180 -0
- package/dist/skill-registry/evaluation-client.js +156 -0
- package/dist/skill-registry/evaluation-commands.js +174 -0
- package/dist/skill-registry/messages.js +177 -0
- package/dist/skill-registry/package.js +275 -0
- package/dist/skill-registry/platform-package.js +100 -0
- package/dist/utils/agent-api-client.js +245 -30
- package/dist/utils/environment-endpoints.js +17 -0
- package/dist/utils/error-diagnostics.js +20 -0
- package/dist/utils/playcraft-http-client.js +6 -4
- package/dist/utils/tool-operation-journal.js +124 -0
- package/dist/utils/video-evidence-git.js +81 -0
- package/dist/video-replication/client.js +234 -0
- package/dist/video-replication/comparison-evidence.js +149 -0
- package/dist/video-replication/comparison-files.js +57 -0
- package/dist/video-replication/comparison-log.js +72 -0
- package/dist/video-replication/comparison-messages.js +104 -0
- package/dist/video-replication/comparison-output.js +63 -0
- package/dist/video-replication/comparison-preflight.js +66 -0
- package/dist/video-replication/comparison.js +230 -0
- package/dist/video-replication/diagnostics.js +41 -0
- package/dist/video-replication/evidence.js +165 -0
- package/dist/video-replication/media.js +112 -0
- package/dist/video-replication/messages.js +97 -0
- package/dist/workspace/messages.js +67 -0
- package/dist/workspace/transfer-client.js +237 -0
- package/dist/workspace/transfer-errors.js +48 -0
- package/dist/workspace-runtime/batch/content-changes.js +30 -0
- package/dist/workspace-runtime/batch/control.js +86 -0
- package/dist/workspace-runtime/batch/deliver.js +173 -0
- package/dist/workspace-runtime/batch/freeze.js +101 -0
- package/dist/workspace-runtime/batch/generate.js +249 -0
- package/dist/workspace-runtime/batch/git.js +40 -0
- package/dist/workspace-runtime/batch/occupancy.js +8 -0
- package/dist/workspace-runtime/batch/policy.js +70 -0
- package/dist/workspace-runtime/batch/prepare.js +317 -0
- package/dist/workspace-runtime/batch/processes.js +72 -0
- package/dist/workspace-runtime/batch/records.js +113 -0
- package/dist/workspace-runtime/batch/routes.js +61 -0
- package/dist/workspace-runtime/batch/source-candidate.js +86 -0
- package/dist/workspace-runtime/batch/source-capture.js +146 -0
- package/dist/workspace-runtime/batch/source-failure.js +43 -0
- package/dist/workspace-runtime/batch/source-publish.js +130 -0
- package/dist/workspace-runtime/codex/app-server.js +1065 -0
- package/dist/workspace-runtime/codex/compact.js +46 -0
- package/dist/workspace-runtime/codex/config-toml.js +107 -0
- package/dist/workspace-runtime/codex/delivery-tools.js +144 -0
- package/dist/workspace-runtime/codex/jsonrpc-stdio.js +145 -0
- package/dist/workspace-runtime/codex/launcher-client.js +177 -0
- package/dist/workspace-runtime/codex/loopback.js +146 -0
- package/dist/workspace-runtime/codex/mcp-config.js +39 -0
- package/dist/workspace-runtime/codex/model-broker.js +263 -0
- package/dist/workspace-runtime/codex/native-adapter.js +9 -0
- package/dist/workspace-runtime/codex/permissions.js +79 -0
- package/dist/workspace-runtime/codex/thread-image.js +38 -0
- package/dist/workspace-runtime/codex/tool-response.js +10 -0
- package/dist/workspace-runtime/codex/ui-instructions.js +4 -0
- package/dist/workspace-runtime/codex/ui-tools.js +203 -0
- package/dist/workspace-runtime/codex/work-mode.js +15 -0
- package/dist/workspace-runtime/main.js +10 -0
- package/dist/workspace-runtime/persistence/journal.js +365 -0
- package/dist/workspace-runtime/persistence/native-subagents.js +162 -0
- package/dist/workspace-runtime/persistence/sqlite-client.js +77 -0
- package/dist/workspace-runtime/persistence/sqlite-worker.js +1161 -0
- package/dist/workspace-runtime/persistence/stopped-execution.js +77 -0
- package/dist/workspace-runtime/previews/diagnostics.js +44 -0
- package/dist/workspace-runtime/previews/finalize.js +64 -0
- package/dist/workspace-runtime/previews/output.js +36 -0
- package/dist/workspace-runtime/previews/publish.js +306 -0
- package/dist/workspace-runtime/previews/runtime-preview.js +251 -0
- package/dist/workspace-runtime/previews/single-file.js +43 -0
- package/dist/workspace-runtime/processes/managed-writes.js +69 -0
- package/dist/workspace-runtime/serve.js +441 -0
- package/dist/workspace-runtime/server/accept-operation.js +61 -0
- package/dist/workspace-runtime/server/asset-transfers.js +63 -0
- package/dist/workspace-runtime/server/auth.js +21 -0
- package/dist/workspace-runtime/server/connectivity.js +211 -0
- package/dist/workspace-runtime/server/desktop-host.js +429 -0
- package/dist/workspace-runtime/server/desktop-preview-config.js +81 -0
- package/dist/workspace-runtime/server/desktop-preview-service.js +157 -0
- package/dist/workspace-runtime/server/desktop-preview-static.js +53 -0
- package/dist/workspace-runtime/server/desktop-preview.js +189 -0
- package/dist/workspace-runtime/server/dispatch.js +1655 -0
- package/dist/workspace-runtime/server/endpoints.js +21 -0
- package/dist/workspace-runtime/server/execution-group.js +90 -0
- package/dist/workspace-runtime/server/http.js +1363 -0
- package/dist/workspace-runtime/server/lock.js +53 -0
- package/dist/workspace-runtime/server/operation-record.js +33 -0
- package/dist/workspace-runtime/server/rfb-watch-gate.js +168 -0
- package/dist/workspace-runtime/server/session-restore.js +84 -0
- package/dist/workspace-runtime/server/source-uploader.js +138 -0
- package/dist/workspace-runtime/server/submit-operation.js +41 -0
- package/dist/workspace-runtime/server/terminal-host.js +366 -0
- package/dist/workspace-runtime/server/types.js +1 -0
- package/dist/workspace-runtime/server/workspace-transfer.js +168 -0
- package/dist/workspace-runtime/verify-artifact.js +59 -0
- package/dist/workspace-runtime/workspaces/append-only-log.js +62 -0
- package/dist/workspace-runtime/workspaces/archive.js +207 -0
- package/dist/workspace-runtime/workspaces/artifact-events.js +168 -0
- package/dist/workspace-runtime/workspaces/artifact-files.js +201 -0
- package/dist/workspace-runtime/workspaces/artifact-receipts.js +112 -0
- package/dist/workspace-runtime/workspaces/artifacts.js +380 -0
- package/dist/workspace-runtime/workspaces/asset-library-import.js +387 -0
- package/dist/workspace-runtime/workspaces/asset-publication-access.js +29 -0
- package/dist/workspace-runtime/workspaces/asset-transfer-dependencies.js +81 -0
- package/dist/workspace-runtime/workspaces/asset-transfer-publish.js +438 -0
- package/dist/workspace-runtime/workspaces/asset-transfer-storage.js +389 -0
- package/dist/workspace-runtime/workspaces/attachment-content.js +73 -0
- package/dist/workspace-runtime/workspaces/attachments.js +185 -0
- package/dist/workspace-runtime/workspaces/batch-commit.js +142 -0
- package/dist/workspace-runtime/workspaces/binary-content.js +65 -0
- package/dist/workspace-runtime/workspaces/binary-write.js +117 -0
- package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
- package/dist/workspace-runtime/workspaces/cli-credentials.js +115 -0
- package/dist/workspace-runtime/workspaces/composer-context.js +147 -0
- package/dist/workspace-runtime/workspaces/context-error.js +2 -0
- package/dist/workspace-runtime/workspaces/delivery-build.js +421 -0
- package/dist/workspace-runtime/workspaces/delivery-store.js +168 -0
- package/dist/workspace-runtime/workspaces/delivery.js +64 -0
- package/dist/workspace-runtime/workspaces/dependencies.js +279 -0
- package/dist/workspace-runtime/workspaces/developer-command.js +98 -0
- package/dist/workspace-runtime/workspaces/directories.js +135 -0
- package/dist/workspace-runtime/workspaces/directory-access.js +50 -0
- package/dist/workspace-runtime/workspaces/directory-attachments.js +245 -0
- package/dist/workspace-runtime/workspaces/directory-create.js +57 -0
- package/dist/workspace-runtime/workspaces/directory-maintenance.js +111 -0
- package/dist/workspace-runtime/workspaces/directory-mutations.js +238 -0
- package/dist/workspace-runtime/workspaces/directory-revisions.js +56 -0
- package/dist/workspace-runtime/workspaces/directory-stats.js +49 -0
- package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
- package/dist/workspace-runtime/workspaces/empty-template.js +43 -0
- package/dist/workspace-runtime/workspaces/file-content.js +48 -0
- package/dist/workspace-runtime/workspaces/files-search.js +116 -0
- package/dist/workspace-runtime/workspaces/files.js +150 -0
- package/dist/workspace-runtime/workspaces/git-credential-broker.js +312 -0
- package/dist/workspace-runtime/workspaces/git-credential-helper.js +68 -0
- package/dist/workspace-runtime/workspaces/git-direct-store.js +155 -0
- package/dist/workspace-runtime/workspaces/git.js +683 -0
- package/dist/workspace-runtime/workspaces/instructions.js +56 -0
- package/dist/workspace-runtime/workspaces/json5-edit.js +313 -0
- package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
- package/dist/workspace-runtime/workspaces/operation-log.js +23 -0
- package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
- package/dist/workspace-runtime/workspaces/parameter-agent-inputs.js +97 -0
- package/dist/workspace-runtime/workspaces/parameter-agent-protocol.js +40 -0
- package/dist/workspace-runtime/workspaces/parameter-agent-store.js +58 -0
- package/dist/workspace-runtime/workspaces/parameter-agent.js +284 -0
- package/dist/workspace-runtime/workspaces/parameter-assets.js +212 -0
- package/dist/workspace-runtime/workspaces/parameters.js +369 -0
- package/dist/workspace-runtime/workspaces/prepare.js +284 -0
- package/dist/workspace-runtime/workspaces/registry.js +251 -0
- package/dist/workspace-runtime/workspaces/remix-references.js +301 -0
- package/dist/workspace-runtime/workspaces/revisions.js +31 -0
- package/dist/workspace-runtime/workspaces/session-image.js +104 -0
- package/dist/workspace-runtime/workspaces/shared-git.js +40 -0
- package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +95 -0
- package/dist/workspace-runtime/workspaces/skills.js +191 -0
- package/dist/workspace-runtime/workspaces/theme-asset-index.js +267 -0
- package/dist/workspace-runtime/workspaces/transfer-quota.js +69 -0
- package/dist/workspace-runtime/workspaces/transfer.js +471 -0
- package/dist/workspace-runtime/workspaces/turn-changes.js +75 -0
- package/dist/workspace-runtime/workspaces/video-attachments.js +49 -0
- package/dist/workspace-runtime/workspaces/worktree-attachments.js +74 -0
- package/dist/workspace-runtime/workspaces/worktree-checkout.js +67 -0
- package/dist/workspace-runtime/workspaces/worktrees.js +73 -0
- package/package.json +16 -5
- package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
- package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
- package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
- package/project-template/.claude/skills/playcraft-replica-validation/SKILL.md +25 -0
- package/project-template/.claude/skills/playcraft-replica-validation/references/contracts.md +79 -0
- package/project-template/.claude/skills/playcraft-video-understanding/SKILL.md +29 -0
- package/project-template/.claude/skills/playcraft-video-understanding/references/contracts.md +37 -0
- package/project-template/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-template/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/project-template-v2/.claude/agents/artist.md +82 -0
- package/project-template-v2/.claude/agents/developer.md +153 -0
- package/project-template-v2/.claude/agents/game-designer.md +264 -0
- package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
- package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
- package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
- package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
- package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
- package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
- package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
- package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
- package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
- package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
- package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
- package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
- package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
- package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
- package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
- package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
- package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
- package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
- package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
- package/project-template-v2/.claude/agents/reviewer.md +75 -0
- package/project-template-v2/.claude/agents/technical-artist.md +86 -0
- package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
- package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
- package/project-template-v2/.claude/settings.json +33 -0
- package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
- package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
- package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
- package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
- package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
- package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +307 -0
- package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
- package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +401 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +333 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +95 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +136 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
- package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
- package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +244 -0
- package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
- package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
- package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
- package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
- package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
- package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
- package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
- package/project-template-v2/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-template-v2/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
- package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
- package/project-template-v2/.claude/snapshot.mjs +263 -0
- package/project-template-v2/.playcraft/skills.lock.json +152 -0
- package/project-template-v2/CLAUDE.md +146 -0
- package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
- package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
- package/project-template-v2/assets/bundles/.gitkeep +0 -0
- package/project-template-v2/assets/images/bg/.gitkeep +0 -0
- package/project-template-v2/assets/images/reference/.gitkeep +0 -0
- package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
- package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
- package/project-template-v2/assets/images/ui/.gitkeep +0 -0
- package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
- package/project-template-v2/assets/models/.gitkeep +0 -0
- package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
- package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
- package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
- package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
- package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
- package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
- package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
- package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
- package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
- package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
- package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
- package/project-template-v2/docs/project-state.json +60 -0
- package/project-template-v2/docs/project-state.md +72 -0
- package/project-template-v2/docs/standards/README.md +225 -0
- package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
- package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
- package/project-template-v2/docs/standards/artifacts/design.md +22 -0
- package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
- package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
- package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
- package/project-template-v2/game/index.ts +18 -0
- package/project-template-v2/globals.d.ts +51 -0
- package/project-template-v2/index.css +34 -0
- package/project-template-v2/index.html +18 -0
- package/project-template-v2/main.ts +9 -0
- package/project-template-v2/package.json +46 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
- package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
- package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
- package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
- package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
- package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
- package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
- package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
- package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
- package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
- package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
- package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
- package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
- package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
- package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
- package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
- package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
- package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
- package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
- package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
- package/project-template-v2/skills/playable-record/SKILL.md +140 -0
- package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
- package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
- package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
- package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
- package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
- package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
- package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
- package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
- package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
- package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
- package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
- package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
- package/project-template-v2/tsconfig.json +20 -0
- package/project-template-v2/vite.config.ts +27 -0
- package/project-templates/batch-locks/phaser.yaml +922 -0
- package/project-templates/batch-locks/threejs.yaml +978 -0
- package/project-templates/empty/AGENTS.md +53 -0
- package/project-templates/empty/gitignore +33 -0
- package/project-templates/phaser/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
- package/project-templates/phaser/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-templates/phaser/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/project-templates/threejs/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
- package/project-templates/threejs/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-templates/threejs/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/templates/preview-runtime/v1/README.md +79 -0
- package/templates/preview-runtime/v1/build-preview.mjs +1324 -0
- package/templates/preview-runtime/v1/manifest.json +17 -0
- package/templates/preview-runtime/v1/release-guard.mjs +87 -0
- package/templates/preview-runtime/v1/runtime.d.mts +3 -0
- package/templates/preview-runtime/v1/runtime.d.ts +3 -0
- package/templates/preview-runtime/v1/runtime.mjs +1312 -0
- package/templates/preview-runtime/v1/types/adapters.d.ts +28 -0
- package/templates/preview-runtime/v1/types/preview.d.ts +24 -0
- package/templates/preview-runtime/v1/types/protocol.d.ts +131 -0
- package/templates/preview-runtime/v1/types/runtime.d.ts +14 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { link, lstat, mkdir, open, readdir, realpath, rename, rm, rmdir, unlink } from 'node:fs/promises';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { ASSET_TRANSFER_CHUNK_BYTES, assetBundleSavePayloadSchema, assetBundleReceiptSchema, isAssetBundleReceiptForManifest, } from '@playcraft/common/cloud-workspace/runtime';
|
|
6
|
+
import { AssetTransferError, assetTransferMissing, hashAssetTransferFile, safeAssetTransferDirectory, saveAssetTransfer, syncAssetTransferDirectory, withAssetTransfer, } from './asset-transfer-storage.js';
|
|
7
|
+
import { validateAssetTransferDependencies } from './asset-transfer-dependencies.js';
|
|
8
|
+
import { shareWorkspaceAssetDirectory, shareWorkspaceAssetFile } from './asset-publication-access.js';
|
|
9
|
+
const same = (left, right) => left.dev === right.dev && left.ino === right.ino
|
|
10
|
+
&& left.size === right.size && left.contentHash === right.contentHash;
|
|
11
|
+
async function targetFile(transfer, path) {
|
|
12
|
+
try {
|
|
13
|
+
await safeAssetTransferDirectory(transfer.root, dirname(path) === '.' ? '' : dirname(path));
|
|
14
|
+
return await hashAssetTransferFile(join(transfer.root, path));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (assetTransferMissing(error))
|
|
18
|
+
return undefined;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function privateFile(transfer, directory, index) {
|
|
23
|
+
try {
|
|
24
|
+
await safeAssetTransferDirectory(transfer.directory, directory);
|
|
25
|
+
return await hashAssetTransferFile(join(transfer.directory, directory, String(index)), undefined, true);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (assetTransferMissing(error))
|
|
29
|
+
return undefined;
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function assertSource(transfer, file) {
|
|
34
|
+
if (file.source && (await targetFile(transfer, file.source.path))?.contentHash !== file.source.contentHash)
|
|
35
|
+
throw new AssetTransferError('source_content_conflict');
|
|
36
|
+
}
|
|
37
|
+
async function assemble(transfer) {
|
|
38
|
+
await safeAssetTransferDirectory(transfer.directory, 'chunks', true);
|
|
39
|
+
await safeAssetTransferDirectory(transfer.directory, 'incoming', true);
|
|
40
|
+
const staged = [];
|
|
41
|
+
for (const [index, file] of transfer.record.manifest.files.entries()) {
|
|
42
|
+
const destination = join(transfer.directory, 'incoming', String(index));
|
|
43
|
+
const output = await open(destination, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
44
|
+
const hash = createHash('sha256');
|
|
45
|
+
try {
|
|
46
|
+
for (const [chunkIndex, expected] of file.chunkHashes.entries()) {
|
|
47
|
+
let input;
|
|
48
|
+
try {
|
|
49
|
+
input = await open(join(transfer.directory, 'chunks', `${index}-${chunkIndex}`), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (assetTransferMissing(error))
|
|
53
|
+
throw new AssetTransferError('asset_transfer_incomplete');
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const stat = await input.stat();
|
|
58
|
+
const size = Math.min(ASSET_TRANSFER_CHUNK_BYTES, file.size - chunkIndex * ASSET_TRANSFER_CHUNK_BYTES);
|
|
59
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size !== size)
|
|
60
|
+
throw new AssetTransferError('asset_transfer_chunk_mismatch');
|
|
61
|
+
const bytes = await input.readFile();
|
|
62
|
+
if (bytes.length !== size || createHash('sha256').update(bytes).digest('hex') !== expected)
|
|
63
|
+
throw new AssetTransferError('asset_transfer_chunk_mismatch');
|
|
64
|
+
hash.update(bytes);
|
|
65
|
+
await output.writeFile(bytes);
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await input.close();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
await shareWorkspaceAssetFile(transfer.root, output);
|
|
72
|
+
await output.sync();
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await output.close();
|
|
76
|
+
}
|
|
77
|
+
const contentHash = hash.digest('hex');
|
|
78
|
+
if (file.contentHash && file.contentHash !== contentHash)
|
|
79
|
+
throw new AssetTransferError('asset_transfer_content_mismatch');
|
|
80
|
+
const sampled = await hashAssetTransferFile(destination);
|
|
81
|
+
if (sampled.size !== file.size || sampled.contentHash !== contentHash)
|
|
82
|
+
throw new AssetTransferError('asset_transfer_content_mismatch');
|
|
83
|
+
staged.push(sampled);
|
|
84
|
+
}
|
|
85
|
+
return staged;
|
|
86
|
+
}
|
|
87
|
+
function validatePublication(transfer) {
|
|
88
|
+
const publication = transfer.record.publication;
|
|
89
|
+
if (!publication || publication.manifestHash !== transfer.record.manifestHash
|
|
90
|
+
|| typeof publication.operationId !== 'string' || !publication.operationId || publication.operationId.length > 128
|
|
91
|
+
|| !Array.isArray(publication.files) || publication.files.length !== transfer.record.manifest.files.length
|
|
92
|
+
|| !Array.isArray(publication.directories))
|
|
93
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
94
|
+
for (const file of publication.files)
|
|
95
|
+
for (const identity of [file.staged, file.previous].filter(Boolean)) {
|
|
96
|
+
if (!identity || !Number.isSafeInteger(identity.dev) || !Number.isSafeInteger(identity.ino) || !Number.isSafeInteger(identity.size)
|
|
97
|
+
|| !/^[a-f0-9]{64}$/.test(identity.contentHash))
|
|
98
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
99
|
+
}
|
|
100
|
+
for (const directory of publication.directories) {
|
|
101
|
+
if (typeof directory.path !== 'string' || !Number.isSafeInteger(directory.dev) || !Number.isSafeInteger(directory.ino)
|
|
102
|
+
|| ![...transfer.record.manifest.files.map(file => file.path), ...(transfer.record.manifest.directories ?? [])]
|
|
103
|
+
.some(path => path === directory.path || path.startsWith(directory.path + '/')))
|
|
104
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
105
|
+
}
|
|
106
|
+
if (publication.markers?.some(marker => !Number.isSafeInteger(marker.dev) || !Number.isSafeInteger(marker.ino)
|
|
107
|
+
|| !transfer.record.manifest.directories?.includes(marker.path)))
|
|
108
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
109
|
+
return publication;
|
|
110
|
+
}
|
|
111
|
+
async function createDirectories(transfer, path) {
|
|
112
|
+
const publication = validatePublication(transfer);
|
|
113
|
+
let directory = '';
|
|
114
|
+
for (const part of path.split('/').filter(Boolean)) {
|
|
115
|
+
directory = [directory, part].filter(Boolean).join('/');
|
|
116
|
+
try {
|
|
117
|
+
await safeAssetTransferDirectory(transfer.root, directory);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (!assetTransferMissing(error))
|
|
121
|
+
throw error;
|
|
122
|
+
await safeAssetTransferDirectory(transfer.root, dirname(directory) === '.' ? '' : dirname(directory));
|
|
123
|
+
await mkdir(join(transfer.root, directory), { mode: 0o700 });
|
|
124
|
+
await shareWorkspaceAssetDirectory(transfer.root, join(transfer.root, directory));
|
|
125
|
+
const stat = await lstat(await safeAssetTransferDirectory(transfer.root, directory));
|
|
126
|
+
publication.directories.push({ path: directory, dev: stat.dev, ino: stat.ino });
|
|
127
|
+
await saveAssetTransfer(transfer);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function cleanPublicationFiles(transfer, completed = false) {
|
|
132
|
+
for (const name of completed ? ['chunks', 'incoming', 'previous'] : ['incoming', 'previous']) {
|
|
133
|
+
try {
|
|
134
|
+
await safeAssetTransferDirectory(transfer.directory, name);
|
|
135
|
+
await rm(join(transfer.directory, name), { recursive: true });
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (!assetTransferMissing(error))
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function ensureDirectoryMarkers(transfer) {
|
|
144
|
+
const publication = validatePublication(transfer);
|
|
145
|
+
for (const path of transfer.record.manifest.directories ?? []) {
|
|
146
|
+
const parent = await safeAssetTransferDirectory(transfer.root, path);
|
|
147
|
+
const marker = join(parent, '.gitkeep');
|
|
148
|
+
try {
|
|
149
|
+
const handle = await open(marker, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
150
|
+
try {
|
|
151
|
+
await shareWorkspaceAssetFile(transfer.root, handle);
|
|
152
|
+
await handle.sync();
|
|
153
|
+
const stat = await handle.stat();
|
|
154
|
+
(publication.markers ??= []).push({ path, dev: stat.dev, ino: stat.ino });
|
|
155
|
+
await saveAssetTransfer(transfer);
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
await handle.close();
|
|
159
|
+
}
|
|
160
|
+
await syncAssetTransferDirectory(parent);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error.code !== 'EEXIST')
|
|
164
|
+
throw error;
|
|
165
|
+
const stat = await lstat(marker);
|
|
166
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1)
|
|
167
|
+
throw new AssetTransferError('content_conflict');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function assertCompletedTargets(transfer) {
|
|
172
|
+
if (!isAssetBundleReceiptForManifest(transfer.record.manifest, transfer.record.manifestHash, transfer.record.receipt))
|
|
173
|
+
throw new AssetTransferError('asset_transfer_content_mismatch');
|
|
174
|
+
for (const [index, file] of transfer.record.manifest.files.entries()) {
|
|
175
|
+
await safeAssetTransferDirectory(transfer.root, dirname(file.path) === '.' ? '' : dirname(file.path));
|
|
176
|
+
const current = await hashAssetTransferFile(join(transfer.root, file.path), undefined, false, file.chunkHashes);
|
|
177
|
+
const saved = transfer.record.receipt.files[index];
|
|
178
|
+
if (saved.path !== file.path || current.size !== file.size || current.contentHash !== saved.contentHash)
|
|
179
|
+
throw new AssetTransferError('asset_transfer_content_mismatch');
|
|
180
|
+
}
|
|
181
|
+
for (const directory of transfer.record.manifest.directories ?? [])
|
|
182
|
+
await safeAssetTransferDirectory(transfer.root, directory);
|
|
183
|
+
}
|
|
184
|
+
async function finishPublication(transfer) {
|
|
185
|
+
const publication = validatePublication(transfer);
|
|
186
|
+
const files = [];
|
|
187
|
+
for (const [index, file] of transfer.record.manifest.files.entries()) {
|
|
188
|
+
await safeAssetTransferDirectory(transfer.root, dirname(file.path) === '.' ? '' : dirname(file.path));
|
|
189
|
+
const current = await hashAssetTransferFile(join(transfer.root, file.path), undefined, false, file.chunkHashes);
|
|
190
|
+
if (!current || !same(current, publication.files[index].staged))
|
|
191
|
+
throw new AssetTransferError('content_conflict');
|
|
192
|
+
files.push({ path: file.path, size: current.size, contentHash: current.contentHash });
|
|
193
|
+
}
|
|
194
|
+
await ensureDirectoryMarkers(transfer);
|
|
195
|
+
const receipt = assetBundleReceiptSchema.parse({ transferId: transfer.record.manifest.transferId,
|
|
196
|
+
manifestHash: transfer.record.manifestHash, files,
|
|
197
|
+
...(transfer.record.manifest.directories ? { directories: transfer.record.manifest.directories } : {}) });
|
|
198
|
+
if (!isAssetBundleReceiptForManifest(transfer.record.manifest, transfer.record.manifestHash, receipt))
|
|
199
|
+
throw new AssetTransferError('asset_transfer_content_mismatch');
|
|
200
|
+
transfer.record.status = 'completed';
|
|
201
|
+
transfer.record.receipt = receipt;
|
|
202
|
+
await saveAssetTransfer(transfer);
|
|
203
|
+
await cleanPublicationFiles(transfer, true).catch(() => undefined);
|
|
204
|
+
return receipt;
|
|
205
|
+
}
|
|
206
|
+
/** Complete only this journal's exclusive link/unlink pairs left behind by a crash. */
|
|
207
|
+
async function normalizePublicationAliases(transfer) {
|
|
208
|
+
const publication = validatePublication(transfer);
|
|
209
|
+
for (const [index, file] of transfer.record.manifest.files.entries()) {
|
|
210
|
+
const parent = dirname(file.path) === '.' ? '' : dirname(file.path);
|
|
211
|
+
try {
|
|
212
|
+
await safeAssetTransferDirectory(transfer.root, parent);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (assetTransferMissing(error))
|
|
216
|
+
continue;
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
const target = join(transfer.root, file.path);
|
|
220
|
+
const targetStat = await lstat(target).catch(error => { if (assetTransferMissing(error))
|
|
221
|
+
return undefined; throw error; });
|
|
222
|
+
if (!targetStat || targetStat.nlink === 1)
|
|
223
|
+
continue;
|
|
224
|
+
if (!targetStat.isFile() || targetStat.isSymbolicLink() || targetStat.nlink !== 2)
|
|
225
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
226
|
+
let normalized = false;
|
|
227
|
+
for (const [directory, expected] of [['incoming', publication.files[index].staged], ['previous', publication.files[index].previous]]) {
|
|
228
|
+
if (!expected || targetStat.dev !== expected.dev || targetStat.ino !== expected.ino)
|
|
229
|
+
continue;
|
|
230
|
+
try {
|
|
231
|
+
await safeAssetTransferDirectory(transfer.directory, directory);
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (assetTransferMissing(error))
|
|
235
|
+
continue;
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
const alias = join(transfer.directory, directory, String(index));
|
|
239
|
+
const aliasStat = await lstat(alias).catch(error => { if (assetTransferMissing(error))
|
|
240
|
+
return undefined; throw error; });
|
|
241
|
+
if (!aliasStat || !aliasStat.isFile() || aliasStat.isSymbolicLink() || aliasStat.nlink !== 2
|
|
242
|
+
|| aliasStat.dev !== expected.dev || aliasStat.ino !== expected.ino)
|
|
243
|
+
continue;
|
|
244
|
+
const observed = await hashAssetTransferFile(target, undefined, true);
|
|
245
|
+
if (!same(observed, expected))
|
|
246
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
247
|
+
// Recheck both names immediately before unlinking the known private alias.
|
|
248
|
+
const [current, privateAlias] = await Promise.all([lstat(target), lstat(alias)]);
|
|
249
|
+
if (current.dev !== expected.dev || current.ino !== expected.ino || current.nlink !== 2
|
|
250
|
+
|| privateAlias.dev !== expected.dev || privateAlias.ino !== expected.ino || privateAlias.nlink !== 2)
|
|
251
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
252
|
+
await unlink(alias);
|
|
253
|
+
await syncAssetTransferDirectory(join(transfer.directory, directory));
|
|
254
|
+
normalized = true;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
if (!normalized)
|
|
258
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/** Roll back only files still owned by this publication; preserve concurrent external edits and backups. */
|
|
262
|
+
async function rollbackPublication(transfer) {
|
|
263
|
+
await normalizePublicationAliases(transfer);
|
|
264
|
+
const publication = validatePublication(transfer);
|
|
265
|
+
let conflict = false;
|
|
266
|
+
for (let index = publication.files.length - 1; index >= 0; index--) {
|
|
267
|
+
const file = transfer.record.manifest.files[index], expected = publication.files[index];
|
|
268
|
+
try {
|
|
269
|
+
const current = await targetFile(transfer, file.path);
|
|
270
|
+
const backup = await privateFile(transfer, 'previous', index);
|
|
271
|
+
if (backup) {
|
|
272
|
+
if (!expected.previous || !same(backup, expected.previous)) {
|
|
273
|
+
conflict = true;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (current) {
|
|
277
|
+
if (!same(current, expected.staged)) {
|
|
278
|
+
conflict = true;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
await unlink(join(transfer.root, file.path));
|
|
282
|
+
}
|
|
283
|
+
await safeAssetTransferDirectory(transfer.root, dirname(file.path) === '.' ? '' : dirname(file.path));
|
|
284
|
+
await link(join(transfer.directory, 'previous', String(index)), join(transfer.root, file.path));
|
|
285
|
+
await unlink(join(transfer.directory, 'previous', String(index)));
|
|
286
|
+
await syncAssetTransferDirectory(join(transfer.root, dirname(file.path)));
|
|
287
|
+
}
|
|
288
|
+
else if (current && same(current, expected.staged)) {
|
|
289
|
+
if (expected.previous) {
|
|
290
|
+
conflict = true;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
await unlink(join(transfer.root, file.path));
|
|
294
|
+
}
|
|
295
|
+
else if (expected.previous && (!current || !same(current, expected.previous)))
|
|
296
|
+
conflict = true;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
conflict = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (conflict)
|
|
303
|
+
throw new AssetTransferError('asset_transfer_recovery_required');
|
|
304
|
+
for (const marker of publication.markers ?? []) {
|
|
305
|
+
try {
|
|
306
|
+
const parent = await safeAssetTransferDirectory(transfer.root, marker.path);
|
|
307
|
+
const path = join(parent, '.gitkeep'), stat = await lstat(path);
|
|
308
|
+
if (stat.dev === marker.dev && stat.ino === marker.ino && stat.isFile() && stat.nlink === 1 && stat.size === 0)
|
|
309
|
+
await unlink(path);
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
if (!assetTransferMissing(error))
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
for (const directory of [...publication.directories].reverse()) {
|
|
317
|
+
try {
|
|
318
|
+
const target = await safeAssetTransferDirectory(transfer.root, directory.path);
|
|
319
|
+
const stat = await lstat(target);
|
|
320
|
+
if (stat.dev === directory.dev && stat.ino === directory.ino)
|
|
321
|
+
await rmdir(target);
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
if (!assetTransferMissing(error) && !['ENOTEMPTY', 'EEXIST'].includes(String(error.code)))
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
transfer.record.status = 'uploading';
|
|
329
|
+
delete transfer.record.publication;
|
|
330
|
+
delete transfer.record.receipt;
|
|
331
|
+
await saveAssetTransfer(transfer);
|
|
332
|
+
await cleanPublicationFiles(transfer);
|
|
333
|
+
}
|
|
334
|
+
export async function recoverAssetTransfer(transfer) {
|
|
335
|
+
if (transfer.record.status === 'completed') {
|
|
336
|
+
await assertCompletedTargets(transfer);
|
|
337
|
+
await cleanPublicationFiles(transfer, true);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (transfer.record.status !== 'publishing')
|
|
341
|
+
return;
|
|
342
|
+
await normalizePublicationAliases(transfer);
|
|
343
|
+
try {
|
|
344
|
+
await finishPublication(transfer);
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
await rollbackPublication(transfer);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
export async function publishAssetTransfer(root, scope, input, options) {
|
|
351
|
+
const payload = assetBundleSavePayloadSchema.parse(input);
|
|
352
|
+
return withAssetTransfer(root, scope, payload.transferId, async (transfer) => {
|
|
353
|
+
if (transfer.record.manifestHash !== payload.manifestHash)
|
|
354
|
+
throw new AssetTransferError('asset_transfer_manifest_conflict');
|
|
355
|
+
options.onManifest?.(transfer.record.manifest);
|
|
356
|
+
await recoverAssetTransfer(transfer);
|
|
357
|
+
if (transfer.record.status === 'completed')
|
|
358
|
+
return transfer.record.receipt;
|
|
359
|
+
await options.assertCurrent?.();
|
|
360
|
+
await cleanPublicationFiles(transfer);
|
|
361
|
+
let staged;
|
|
362
|
+
try {
|
|
363
|
+
staged = await assemble(transfer);
|
|
364
|
+
await validateAssetTransferDependencies(transfer);
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
await cleanPublicationFiles(transfer);
|
|
368
|
+
throw error;
|
|
369
|
+
}
|
|
370
|
+
const previous = [];
|
|
371
|
+
for (const file of transfer.record.manifest.files) {
|
|
372
|
+
const observed = await targetFile(transfer, file.path);
|
|
373
|
+
if ((observed?.contentHash ?? null) !== file.expectedContentHash)
|
|
374
|
+
throw new AssetTransferError('content_conflict');
|
|
375
|
+
await assertSource(transfer, file);
|
|
376
|
+
await options.assertRevision?.(file, observed);
|
|
377
|
+
previous.push(observed);
|
|
378
|
+
}
|
|
379
|
+
transfer.record.status = 'publishing';
|
|
380
|
+
transfer.record.publication = { operationId: options.operationId, manifestHash: payload.manifestHash,
|
|
381
|
+
files: staged.map((identity, index) => ({ staged: identity, ...(previous[index] ? { previous: previous[index] } : {}) })), directories: [] };
|
|
382
|
+
await saveAssetTransfer(transfer);
|
|
383
|
+
try {
|
|
384
|
+
await safeAssetTransferDirectory(transfer.directory, 'previous', true);
|
|
385
|
+
for (const directory of transfer.record.manifest.directories ?? [])
|
|
386
|
+
await createDirectories(transfer, directory);
|
|
387
|
+
for (const [index, file] of transfer.record.manifest.files.entries()) {
|
|
388
|
+
await options.assertCurrent?.();
|
|
389
|
+
await createDirectories(transfer, dirname(file.path) === '.' ? '' : dirname(file.path));
|
|
390
|
+
const current = await targetFile(transfer, file.path);
|
|
391
|
+
if (previous[index] ? !current || !same(current, previous[index]) : current)
|
|
392
|
+
throw new AssetTransferError('content_conflict');
|
|
393
|
+
await assertSource(transfer, file);
|
|
394
|
+
if (current) {
|
|
395
|
+
await rename(join(transfer.root, file.path), join(transfer.directory, 'previous', String(index)));
|
|
396
|
+
const backup = await privateFile(transfer, 'previous', index);
|
|
397
|
+
if (!backup || !same(backup, current))
|
|
398
|
+
throw new AssetTransferError('content_conflict');
|
|
399
|
+
await syncAssetTransferDirectory(join(transfer.directory, 'previous'));
|
|
400
|
+
}
|
|
401
|
+
await safeAssetTransferDirectory(transfer.root, dirname(file.path) === '.' ? '' : dirname(file.path));
|
|
402
|
+
// Creating the destination with link refuses a concurrently-created file instead of overwriting it.
|
|
403
|
+
await link(join(transfer.directory, 'incoming', String(index)), join(transfer.root, file.path));
|
|
404
|
+
await unlink(join(transfer.directory, 'incoming', String(index)));
|
|
405
|
+
await syncAssetTransferDirectory(join(transfer.root, dirname(file.path)));
|
|
406
|
+
await options.onPublishedFile?.(index);
|
|
407
|
+
}
|
|
408
|
+
await options.assertCurrent?.();
|
|
409
|
+
return await finishPublication(transfer);
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
await rollbackPublication(transfer);
|
|
413
|
+
throw error;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
export async function recoverAssetTransfers(root, scope) {
|
|
418
|
+
const recovered = [];
|
|
419
|
+
let directory;
|
|
420
|
+
try {
|
|
421
|
+
directory = await safeAssetTransferDirectory(await realpath(root), '.playcraft-temp/asset-transfers');
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
if (assetTransferMissing(error))
|
|
425
|
+
return recovered;
|
|
426
|
+
throw error;
|
|
427
|
+
}
|
|
428
|
+
for (const item of await readdir(directory, { withFileTypes: true })) {
|
|
429
|
+
if (!item.isDirectory() || !/^[a-f0-9-]{36}$/i.test(item.name))
|
|
430
|
+
continue;
|
|
431
|
+
await withAssetTransfer(root, scope, item.name, async (transfer) => {
|
|
432
|
+
await recoverAssetTransfer(transfer);
|
|
433
|
+
if (transfer.record.status === 'completed' && transfer.record.publication?.operationId)
|
|
434
|
+
recovered.push({ operationId: transfer.record.publication.operationId, receipt: transfer.record.receipt, manifest: transfer.record.manifest });
|
|
435
|
+
}).catch(() => undefined);
|
|
436
|
+
}
|
|
437
|
+
return recovered;
|
|
438
|
+
}
|