@playcraft/cli 0.1.42 → 0.1.44-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -3
- package/SKILLS_REGISTRY.md +149 -0
- package/dist/agent/local-backend.js +1 -1
- package/dist/auth/account-activation.js +157 -0
- package/dist/auth/messages.js +30 -0
- package/dist/cli-root-help.js +2 -0
- package/dist/commands/build-all.js +5 -19
- package/dist/commands/build-temp.js +26 -0
- package/dist/commands/build.js +15 -28
- package/dist/commands/create.js +26 -33
- package/dist/commands/image.js +2 -6
- 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/skills.js +4 -0
- package/dist/commands/tools-3d.js +11 -0
- package/dist/commands/tools-batch.js +105 -0
- package/dist/commands/tools-generation.js +69 -137
- package/dist/commands/tools-utils.js +0 -12
- package/dist/commands/tools.js +2 -2
- 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 +40 -3
- 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 +210 -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 +233 -0
- package/dist/workspace/transfer-errors.js +48 -0
- package/dist/workspace-runtime/batch/control.js +80 -0
- package/dist/workspace-runtime/batch/deliver.js +150 -0
- package/dist/workspace-runtime/batch/freeze.js +102 -0
- package/dist/workspace-runtime/batch/generate.js +205 -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 +202 -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 +58 -0
- package/dist/workspace-runtime/batch/source-capture.js +159 -0
- package/dist/workspace-runtime/codex/app-server.js +1040 -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/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/ui-instructions.js +4 -0
- package/dist/workspace-runtime/codex/ui-tools.js +186 -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/output.js +36 -0
- package/dist/workspace-runtime/previews/publish.js +262 -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/production/content-changes.js +36 -0
- package/dist/workspace-runtime/production/contracts.js +19 -0
- package/dist/workspace-runtime/production/controller.js +228 -0
- package/dist/workspace-runtime/production/dependencies.js +60 -0
- package/dist/workspace-runtime/production/native.js +239 -0
- package/dist/workspace-runtime/production/processes.js +102 -0
- package/dist/workspace-runtime/production/save-command.js +35 -0
- package/dist/workspace-runtime/production/source-archive.js +137 -0
- package/dist/workspace-runtime/production/source-copy.js +92 -0
- package/dist/workspace-runtime/production/stages.js +354 -0
- package/dist/workspace-runtime/production/storage.js +75 -0
- package/dist/workspace-runtime/serve.js +283 -0
- package/dist/workspace-runtime/server/auth.js +21 -0
- package/dist/workspace-runtime/server/connectivity.js +209 -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 +1339 -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 +1297 -0
- package/dist/workspace-runtime/server/lock.js +53 -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/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/workspaces/archive.js +207 -0
- package/dist/workspace-runtime/workspaces/artifact-events.js +55 -0
- package/dist/workspace-runtime/workspaces/artifact-files.js +199 -0
- package/dist/workspace-runtime/workspaces/artifact-receipts.js +89 -0
- package/dist/workspace-runtime/workspaces/artifacts.js +282 -0
- package/dist/workspace-runtime/workspaces/asset-library-import.js +366 -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 +112 -0
- package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
- package/dist/workspace-runtime/workspaces/cli-credentials.js +111 -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/dependencies.js +264 -0
- package/dist/workspace-runtime/workspaces/developer-command.js +64 -0
- package/dist/workspace-runtime/workspaces/directories.js +137 -0
- package/dist/workspace-runtime/workspaces/directory-access.js +37 -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-stats.js +49 -0
- package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
- package/dist/workspace-runtime/workspaces/empty-template.js +42 -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 +670 -0
- package/dist/workspace-runtime/workspaces/instructions.js +56 -0
- package/dist/workspace-runtime/workspaces/json5-edit.js +170 -0
- package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
- package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
- package/dist/workspace-runtime/workspaces/parameters.js +272 -0
- package/dist/workspace-runtime/workspaces/prepare.js +278 -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/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/package.json +15 -5
- package/project-template/.claude/agents/refs/ta-image-generation-detail.md +123 -67
- package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
- package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
- package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
- 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-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 +280 -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 +298 -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 +324 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -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 +137 -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/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 +219 -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/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 +41 -0
- package/project-templates/empty/gitignore +33 -0
- package/project-templates/phaser/.claude/agents/refs/ta-image-generation-detail.md +59 -59
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
- package/project-templates/threejs/.claude/agents/refs/ta-image-generation-detail.md +59 -59
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +63 -135
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +33 -42
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +20 -18
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +7 -6
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +39 -39
- package/dist/commands/tools-image-context.js +0 -29
- package/dist/utils/image-asset-context.js +0 -228
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, mkdir, open, readdir, rename, unlink } from 'node:fs/promises';
|
|
4
|
+
import { basename, join } from 'node:path';
|
|
5
|
+
import sharp from 'sharp';
|
|
6
|
+
import { WORKSPACE_ARTIFACT_OUTPUT_DIRECTORY, isWorkspaceArtifactOutputPath, isWorkspaceArtifactOutputVersion, workspaceArtifactContentQuerySchema, workspaceArtifactListSchema, } from '@playcraft/common/cloud-workspace/runtime';
|
|
7
|
+
import { artifactBundleDigest, artifactDirectory, artifactFormat, artifactPath, artifactResources, snapshotArtifactBundle, snapshotArtifactFile } from './artifact-files.js';
|
|
8
|
+
import { ARTIFACT_RECEIPTS_DIRECTORY, readArtifactReceipt } from './artifact-receipts.js';
|
|
9
|
+
const serial = new Map();
|
|
10
|
+
function digest(text) { return createHash('sha256').update(text).digest('hex'); }
|
|
11
|
+
function artifactId(workspaceId, path) { return `artifact_${digest(`${workspaceId}\0${path}`).slice(0, 40)}`; }
|
|
12
|
+
function outputArtifacts(artifacts) {
|
|
13
|
+
return artifacts.flatMap(artifact => {
|
|
14
|
+
const versions = artifact.versions.filter(isWorkspaceArtifactOutputVersion);
|
|
15
|
+
if (!versions.length)
|
|
16
|
+
return [];
|
|
17
|
+
const current = versions.find(version => version.id === artifact.currentVersionId)
|
|
18
|
+
?? versions.reduce((latest, version) => version.createdAt > latest.createdAt ? version : latest);
|
|
19
|
+
return [{ ...artifact, versions, currentVersionId: current.id, updatedAt: current.createdAt }];
|
|
20
|
+
}).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.id.localeCompare(b.id));
|
|
21
|
+
}
|
|
22
|
+
/** Catalogs and immutable bytes are control-owned, outside the mutable checkout. */
|
|
23
|
+
export class WorkspaceArtifactStore {
|
|
24
|
+
stateDir;
|
|
25
|
+
workspaceId;
|
|
26
|
+
constructor(stateDir, workspaceId) {
|
|
27
|
+
this.stateDir = stateDir;
|
|
28
|
+
this.workspaceId = workspaceId;
|
|
29
|
+
}
|
|
30
|
+
async directory() {
|
|
31
|
+
await mkdir(this.stateDir, { recursive: true, mode: 0o700 });
|
|
32
|
+
return artifactDirectory(this.stateDir, `artifacts/${digest(this.workspaceId)}`);
|
|
33
|
+
}
|
|
34
|
+
async read(directory) {
|
|
35
|
+
const handle = await open(join(directory, 'catalog.json'), constants.O_RDONLY | constants.O_NOFOLLOW).catch(error => {
|
|
36
|
+
if (error.code === 'ENOENT')
|
|
37
|
+
return undefined;
|
|
38
|
+
throw error;
|
|
39
|
+
});
|
|
40
|
+
if (!handle)
|
|
41
|
+
return { artifacts: [], scannedAt: new Date().toISOString(), receipts: [], observations: {} };
|
|
42
|
+
try {
|
|
43
|
+
const stat = await handle.stat();
|
|
44
|
+
if (!stat.isFile() || stat.size > 32 * 1024 * 1024)
|
|
45
|
+
throw new Error('artifact_catalog_invalid');
|
|
46
|
+
const { receipts, observations = {}, ...body } = JSON.parse(await handle.readFile('utf8'));
|
|
47
|
+
if (!Array.isArray(receipts) || receipts.some(id => typeof id !== 'string'))
|
|
48
|
+
throw new Error('artifact_catalog_invalid');
|
|
49
|
+
return { ...workspaceArtifactListSchema.parse(body), receipts, observations };
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
await handle.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async write(directory, catalog) {
|
|
56
|
+
const temporary = join(directory, `${randomUUID()}.tmp`);
|
|
57
|
+
const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
58
|
+
try {
|
|
59
|
+
await handle.writeFile(JSON.stringify(catalog));
|
|
60
|
+
await handle.sync();
|
|
61
|
+
await handle.close();
|
|
62
|
+
await rename(temporary, join(directory, 'catalog.json'));
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await handle.close();
|
|
66
|
+
await unlink(temporary).catch(error => { if (error.code !== 'ENOENT')
|
|
67
|
+
throw error; });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async discover(root, source = { kind: 'discovered' }, sourcePaths = []) {
|
|
71
|
+
const key = `${this.stateDir}\0${this.workspaceId}`;
|
|
72
|
+
const previous = serial.get(key) ?? Promise.resolve();
|
|
73
|
+
const task = previous.catch(() => undefined).then(() => this.scan(root, source, sourcePaths));
|
|
74
|
+
serial.set(key, task);
|
|
75
|
+
try {
|
|
76
|
+
return await task;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
if (serial.get(key) === task)
|
|
80
|
+
serial.delete(key);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async list() {
|
|
84
|
+
const catalog = await this.read(await this.directory());
|
|
85
|
+
return workspaceArtifactListSchema.parse({ artifacts: outputArtifacts(catalog.artifacts), scannedAt: catalog.scannedAt });
|
|
86
|
+
}
|
|
87
|
+
async scan(root, source, sourcePaths) {
|
|
88
|
+
const directory = await this.directory();
|
|
89
|
+
const objects = await artifactDirectory(directory, 'objects');
|
|
90
|
+
const catalog = await this.read(directory);
|
|
91
|
+
const original = JSON.stringify(outputArtifacts(catalog.artifacts));
|
|
92
|
+
const receipts = await this.receipts(root, catalog);
|
|
93
|
+
for (const receipt of receipts) {
|
|
94
|
+
try {
|
|
95
|
+
for (const file of receipt.files) {
|
|
96
|
+
const copied = await snapshotArtifactFile(root, `${ARTIFACT_RECEIPTS_DIRECTORY}/objects/${file.sha256}`, objects);
|
|
97
|
+
if (copied.sha256 !== file.sha256 || copied.size !== file.size)
|
|
98
|
+
throw new Error('artifact_receipt_digest_mismatch');
|
|
99
|
+
}
|
|
100
|
+
const primary = receipt.files.find(file => file.role === 'primary' && file.path === receipt.path);
|
|
101
|
+
if (!primary || !artifactFormat(receipt.path))
|
|
102
|
+
continue;
|
|
103
|
+
const version = {
|
|
104
|
+
id: `version_${receipt.id}`, createdAt: receipt.source.generatedAt ?? new Date().toISOString(),
|
|
105
|
+
path: receipt.path, mimeType: primary.mimeType, size: primary.size, sha256: primary.sha256,
|
|
106
|
+
files: receipt.files, source: receipt.source,
|
|
107
|
+
...(receipt.width ? { width: receipt.width } : {}), ...(receipt.height ? { height: receipt.height } : {}),
|
|
108
|
+
...(receipt.duration !== undefined ? { duration: receipt.duration } : {}),
|
|
109
|
+
};
|
|
110
|
+
this.add(catalog, version);
|
|
111
|
+
catalog.receipts.push(receipt.id);
|
|
112
|
+
}
|
|
113
|
+
catch { /* An incomplete receipt stays pending; the next scan retries its original bytes. */ }
|
|
114
|
+
}
|
|
115
|
+
const candidates = await discoverPaths(root);
|
|
116
|
+
// Models are inspected before images so their explicitly referenced textures stay under the model.
|
|
117
|
+
candidates.sort((a, b) => Number(artifactFormat(b)?.[0] === 'model') - Number(artifactFormat(a)?.[0] === 'model') || a.localeCompare(b));
|
|
118
|
+
const visible = outputArtifacts(catalog.artifacts);
|
|
119
|
+
const members = new Set(visible.flatMap(artifact => artifact.versions.flatMap(version => version.files.filter(file => file.role !== 'primary').map(file => file.path))));
|
|
120
|
+
for (const path of candidates) {
|
|
121
|
+
if (members.has(path))
|
|
122
|
+
continue;
|
|
123
|
+
try {
|
|
124
|
+
const current = visible.find(artifact => artifact.id === artifactId(this.workspaceId, path));
|
|
125
|
+
const version = current?.versions.find(entry => entry.id === current.currentVersionId);
|
|
126
|
+
const knownWrite = sourcePaths.includes(path) && Boolean(source.operationId) && version?.source.operationId !== source.operationId;
|
|
127
|
+
const observation = catalog.observations[path];
|
|
128
|
+
if (!knownWrite && version && observation?.versionId === version.id && observation.signature === await fileSignature(root, version.files.map(file => file.path)))
|
|
129
|
+
continue;
|
|
130
|
+
const thumbnail = version?.files.find(file => file.role === 'thumbnail');
|
|
131
|
+
const thumbnailPath = thumbnail && await lstat(join(root, thumbnail.path)).then(stat => stat.isFile(), () => false) ? thumbnail.path : undefined;
|
|
132
|
+
const paths = [path, ...await artifactResources(root, path), ...(thumbnailPath ? [thumbnailPath] : [])];
|
|
133
|
+
const signature = await fileSignature(root, paths);
|
|
134
|
+
const files = await snapshotArtifactBundle(root, path, objects, thumbnailPath);
|
|
135
|
+
if (signature !== await fileSignature(root, files.map(file => file.path)))
|
|
136
|
+
continue;
|
|
137
|
+
for (const file of files)
|
|
138
|
+
if (file.role !== 'primary')
|
|
139
|
+
members.add(file.path);
|
|
140
|
+
if (!knownWrite && version && artifactBundleDigest(version.files) === artifactBundleDigest(files)) {
|
|
141
|
+
catalog.observations[path] = { signature, versionId: version.id };
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const primary = files[0];
|
|
145
|
+
const next = {
|
|
146
|
+
id: `version_${knownWrite ? source.operationId : randomUUID()}`, createdAt: new Date().toISOString(),
|
|
147
|
+
path, mimeType: primary.mimeType, size: primary.size, sha256: primary.sha256, files,
|
|
148
|
+
source: sourcePaths.includes(path) ? source : { kind: 'discovered' },
|
|
149
|
+
...await this.dimensions(objects, primary),
|
|
150
|
+
};
|
|
151
|
+
this.add(catalog, next);
|
|
152
|
+
catalog.observations[path] = { signature, versionId: next.id };
|
|
153
|
+
}
|
|
154
|
+
catch { /* Files being written or temporarily missing are retried, never published as complete. */ }
|
|
155
|
+
}
|
|
156
|
+
catalog.artifacts = catalog.artifacts.filter(artifact => {
|
|
157
|
+
const current = artifact.versions.find(version => version.id === artifact.currentVersionId);
|
|
158
|
+
return !isWorkspaceArtifactOutputVersion(current) || current.source.kind !== 'discovered' || !members.has(current.path);
|
|
159
|
+
});
|
|
160
|
+
catalog.artifacts.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.id.localeCompare(b.id));
|
|
161
|
+
catalog.scannedAt = new Date().toISOString();
|
|
162
|
+
const list = workspaceArtifactListSchema.parse({ artifacts: outputArtifacts(catalog.artifacts), scannedAt: catalog.scannedAt });
|
|
163
|
+
await this.write(directory, catalog);
|
|
164
|
+
return { list, changed: original !== JSON.stringify(list.artifacts) };
|
|
165
|
+
}
|
|
166
|
+
add(catalog, version) {
|
|
167
|
+
const id = artifactId(this.workspaceId, version.path);
|
|
168
|
+
let artifact = catalog.artifacts.find(item => item.id === id);
|
|
169
|
+
if (!artifact) {
|
|
170
|
+
artifact = { id, kind: artifactFormat(version.path)[0], name: basename(version.path), currentVersionId: version.id, updatedAt: version.createdAt, versions: [] };
|
|
171
|
+
catalog.artifacts.push(artifact);
|
|
172
|
+
}
|
|
173
|
+
if (!artifact.versions.some(item => item.id === version.id)) {
|
|
174
|
+
// Display ordering is monotonic; the original generation time stays in source.generatedAt.
|
|
175
|
+
const latest = Math.max(0, ...artifact.versions.map(item => Date.parse(item.createdAt)));
|
|
176
|
+
version.createdAt = new Date(Math.max(Date.parse(version.createdAt), latest + 1)).toISOString();
|
|
177
|
+
artifact.versions.unshift(version);
|
|
178
|
+
}
|
|
179
|
+
artifact.currentVersionId = version.id;
|
|
180
|
+
artifact.updatedAt = version.createdAt;
|
|
181
|
+
}
|
|
182
|
+
async receipts(root, catalog) {
|
|
183
|
+
let directory;
|
|
184
|
+
try {
|
|
185
|
+
const target = join(root, ARTIFACT_RECEIPTS_DIRECTORY);
|
|
186
|
+
if (!(await lstat(target)).isDirectory())
|
|
187
|
+
return [];
|
|
188
|
+
directory = await artifactDirectory(root, ARTIFACT_RECEIPTS_DIRECTORY);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
const seen = new Set(catalog.receipts), receipts = [];
|
|
194
|
+
for (const name of await readdir(directory)) {
|
|
195
|
+
if (!/^[a-f0-9-]{36}\.json$/.test(name) || seen.has(name.slice(0, -5)))
|
|
196
|
+
continue;
|
|
197
|
+
try {
|
|
198
|
+
const receipt = await readArtifactReceipt(join(directory, name));
|
|
199
|
+
if (receipt.workspaceId === this.workspaceId && `${receipt.id}.json` === name && isWorkspaceArtifactOutputVersion(receipt))
|
|
200
|
+
receipts.push(receipt);
|
|
201
|
+
}
|
|
202
|
+
catch { /* Malformed output metadata is never trusted as a completed artifact. */ }
|
|
203
|
+
}
|
|
204
|
+
return receipts.sort((a, b) => (a.source.generatedAt ?? '').localeCompare(b.source.generatedAt ?? '') || a.id.localeCompare(b.id));
|
|
205
|
+
}
|
|
206
|
+
async dimensions(objects, file) {
|
|
207
|
+
if (!file.mimeType.startsWith('image/') || file.mimeType === 'image/svg+xml')
|
|
208
|
+
return {};
|
|
209
|
+
try {
|
|
210
|
+
const metadata = await sharp(join(objects, file.sha256), { limitInputPixels: 100_000_000 }).metadata();
|
|
211
|
+
return { ...(metadata.width ? { width: metadata.width } : {}), ...(metadata.height ? { height: metadata.height } : {}) };
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return {};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async content(input) {
|
|
218
|
+
const query = workspaceArtifactContentQuerySchema.parse(input);
|
|
219
|
+
const directory = await this.directory(), catalog = await this.read(directory);
|
|
220
|
+
const artifact = catalog.artifacts.find(item => item.id === query.artifactId);
|
|
221
|
+
const version = artifact?.versions.find(item => item.id === query.versionId && isWorkspaceArtifactOutputVersion(item));
|
|
222
|
+
const file = version?.files.find(item => item.path === (query.path ?? version.path));
|
|
223
|
+
if (!file)
|
|
224
|
+
throw new Error('artifact_not_found');
|
|
225
|
+
if (query.offset > file.size)
|
|
226
|
+
throw new Error('artifact_range_invalid');
|
|
227
|
+
const handle = await open(join(directory, 'objects', file.sha256), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
228
|
+
try {
|
|
229
|
+
const stat = await handle.stat();
|
|
230
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size !== file.size)
|
|
231
|
+
throw new Error('artifact_snapshot_invalid');
|
|
232
|
+
const bytes = Buffer.alloc(Math.min(query.length, file.size - query.offset));
|
|
233
|
+
let read = 0;
|
|
234
|
+
while (read < bytes.length) {
|
|
235
|
+
const part = await handle.read(bytes, read, bytes.length - read, query.offset + read);
|
|
236
|
+
if (!part.bytesRead)
|
|
237
|
+
throw new Error('artifact_snapshot_invalid');
|
|
238
|
+
read += part.bytesRead;
|
|
239
|
+
}
|
|
240
|
+
return { content: bytes.toString('base64'), mimeType: file.mimeType, totalBytes: file.size, offset: query.offset, sha256: file.sha256 };
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
await handle.close();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async function fileSignature(root, paths) {
|
|
248
|
+
const records = [];
|
|
249
|
+
for (const path of [...new Set(paths)].sort()) {
|
|
250
|
+
const stat = await lstat(await artifactPath(root, path));
|
|
251
|
+
if (!stat.isFile() || stat.nlink !== 1)
|
|
252
|
+
throw new Error('artifact_file_unavailable');
|
|
253
|
+
records.push([path, stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs]);
|
|
254
|
+
}
|
|
255
|
+
return JSON.stringify(records);
|
|
256
|
+
}
|
|
257
|
+
async function discoverPaths(root, directory = WORKSPACE_ARTIFACT_OUTPUT_DIRECTORY, result = []) {
|
|
258
|
+
if (directory !== WORKSPACE_ARTIFACT_OUTPUT_DIRECTORY && !isWorkspaceArtifactOutputPath(directory))
|
|
259
|
+
throw new Error('invalid_artifact_path');
|
|
260
|
+
let target;
|
|
261
|
+
try {
|
|
262
|
+
target = await artifactPath(root, directory);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
if (error.code === 'ENOENT')
|
|
266
|
+
return result;
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
if (!(await lstat(target)).isDirectory())
|
|
270
|
+
throw new Error('invalid_artifact_directory');
|
|
271
|
+
for (const entry of await readdir(target, { withFileTypes: true })) {
|
|
272
|
+
if (entry.name.startsWith('.') || entry.isSymbolicLink())
|
|
273
|
+
continue;
|
|
274
|
+
const path = `${directory}/${entry.name}`;
|
|
275
|
+
if (entry.isDirectory()) {
|
|
276
|
+
await discoverPaths(root, path, result);
|
|
277
|
+
}
|
|
278
|
+
else if (entry.isFile() && artifactFormat(path))
|
|
279
|
+
result.push(path);
|
|
280
|
+
}
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, mkdir, mkdtemp, open, readdir, realpath, rename, rm, rmdir } from 'node:fs/promises';
|
|
4
|
+
import { basename, dirname, extname, join, relative } from 'node:path';
|
|
5
|
+
import { BINARY_WORKSPACE_FILE_MAX_BYTES, WORKSPACE_LIBRARY_ATTACHMENT_MAX_BYTES, WORKSPACE_LIBRARY_ATTACHMENT_MAX_FILES, workspaceAssetLibraryImportPayloadSchema, workspaceAssetLibraryImportResultSchema, workspaceAssetLibraryImportTransportSchema, workspaceRelativePathSchema, } from '@playcraft/common/cloud-workspace/runtime';
|
|
6
|
+
import { observeWorkspaceBinaryFile, writeWorkspaceBinaryFile } from './binary-write.js';
|
|
7
|
+
const RESERVED = new Set(['.git', 'node_modules', '.playcraft-temp', '.tmp']);
|
|
8
|
+
const digest = (value) => createHash('sha256').update(value).digest('hex');
|
|
9
|
+
const missing = (error) => error?.code === 'ENOENT';
|
|
10
|
+
export class AssetLibraryImportError extends Error {
|
|
11
|
+
constructor(code) { super(code); this.name = 'AssetLibraryImportError'; }
|
|
12
|
+
}
|
|
13
|
+
function validPath(path) {
|
|
14
|
+
if (!workspaceRelativePathSchema.safeParse(path).success || path.split('/').some(part => RESERVED.has(part)))
|
|
15
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
async function safeDirectory(root, path, create = false) {
|
|
19
|
+
const rootStat = await lstat(root);
|
|
20
|
+
if (!rootStat.isDirectory() || rootStat.isSymbolicLink() || await realpath(root) !== root)
|
|
21
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
22
|
+
let current = root;
|
|
23
|
+
for (const part of path.split('/').filter(Boolean)) {
|
|
24
|
+
current = join(current, part);
|
|
25
|
+
if (create)
|
|
26
|
+
await mkdir(current, { mode: 0o700 }).catch((error) => {
|
|
27
|
+
if (error.code !== 'EEXIST')
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
const stat = await lstat(current);
|
|
31
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || await realpath(current) !== current)
|
|
32
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
33
|
+
}
|
|
34
|
+
return current;
|
|
35
|
+
}
|
|
36
|
+
async function statTarget(root, path) {
|
|
37
|
+
try {
|
|
38
|
+
await safeDirectory(root, dirname(path) === '.' ? '' : dirname(path));
|
|
39
|
+
return await lstat(join(root, path));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (missing(error))
|
|
43
|
+
return undefined;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function validateAsset(asset) {
|
|
48
|
+
let size = 0;
|
|
49
|
+
for (const file of asset.files) {
|
|
50
|
+
validPath(file.path);
|
|
51
|
+
const bytes = Buffer.from(file.content, 'base64');
|
|
52
|
+
if (bytes.toString('base64') !== file.content || digest(bytes) !== file.sha256)
|
|
53
|
+
throw new AssetLibraryImportError('library_asset_changed');
|
|
54
|
+
if (bytes.length > BINARY_WORKSPACE_FILE_MAX_BYTES)
|
|
55
|
+
throw new AssetLibraryImportError('binary_file_too_large');
|
|
56
|
+
size += bytes.length;
|
|
57
|
+
}
|
|
58
|
+
if (size > WORKSPACE_LIBRARY_ATTACHMENT_MAX_BYTES)
|
|
59
|
+
throw new AssetLibraryImportError('library_asset_too_large');
|
|
60
|
+
const files = asset.files.map(file => [file.path, file.sha256]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
61
|
+
if (digest(JSON.stringify(files)) !== asset.contentHash)
|
|
62
|
+
throw new AssetLibraryImportError('library_asset_changed');
|
|
63
|
+
}
|
|
64
|
+
async function directorySnapshot(root) {
|
|
65
|
+
const rootStat = await lstat(root);
|
|
66
|
+
if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
|
|
67
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
68
|
+
const contents = [];
|
|
69
|
+
let bytes = 0;
|
|
70
|
+
const visit = async (relative = '') => {
|
|
71
|
+
for (const entry of await readdir(join(root, relative), { withFileTypes: true })) {
|
|
72
|
+
const path = relative ? `${relative}/${entry.name}` : entry.name;
|
|
73
|
+
validPath(path);
|
|
74
|
+
if (entry.isSymbolicLink())
|
|
75
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
76
|
+
if (entry.isDirectory()) {
|
|
77
|
+
contents.push([`${path}/`, '']);
|
|
78
|
+
await safeDirectory(root, path);
|
|
79
|
+
await visit(path);
|
|
80
|
+
}
|
|
81
|
+
else if (entry.isFile()) {
|
|
82
|
+
const file = await observeWorkspaceBinaryFile(root, path);
|
|
83
|
+
if (!file)
|
|
84
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
85
|
+
bytes += file.size;
|
|
86
|
+
contents.push([path, file.contentHash]);
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
90
|
+
if (contents.length > WORKSPACE_LIBRARY_ATTACHMENT_MAX_FILES * 2 || bytes > WORKSPACE_LIBRARY_ATTACHMENT_MAX_BYTES)
|
|
91
|
+
throw new AssetLibraryImportError('library_asset_too_large');
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
await safeDirectory(root, '');
|
|
95
|
+
await visit();
|
|
96
|
+
return digest(JSON.stringify(contents.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)));
|
|
97
|
+
}
|
|
98
|
+
async function syncDirectory(path) {
|
|
99
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
100
|
+
try {
|
|
101
|
+
await handle.sync();
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
await handle.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function saveTransaction(root, transaction, value) {
|
|
108
|
+
await safeDirectory(root, relative(root, transaction));
|
|
109
|
+
const temporary = join(transaction, 'manifest.next');
|
|
110
|
+
const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | constants.O_NOFOLLOW, 0o600);
|
|
111
|
+
try {
|
|
112
|
+
await handle.writeFile(JSON.stringify(value));
|
|
113
|
+
await handle.sync();
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
await handle.close();
|
|
117
|
+
}
|
|
118
|
+
await rename(temporary, join(transaction, 'manifest.json'));
|
|
119
|
+
await syncDirectory(transaction);
|
|
120
|
+
}
|
|
121
|
+
async function removeTransaction(root, transaction) {
|
|
122
|
+
await safeDirectory(root, relative(root, transaction));
|
|
123
|
+
await rm(transaction, { recursive: true, force: true });
|
|
124
|
+
}
|
|
125
|
+
async function readTransaction(root, transaction) {
|
|
126
|
+
await safeDirectory(root, relative(root, transaction));
|
|
127
|
+
const handle = await open(join(transaction, 'manifest.json'), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
128
|
+
try {
|
|
129
|
+
const stat = await handle.stat();
|
|
130
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size > 1024 * 1024)
|
|
131
|
+
throw new AssetLibraryImportError('invalid_library_import');
|
|
132
|
+
const value = JSON.parse(await handle.readFile('utf8'));
|
|
133
|
+
if (!value || value.version !== 1 || typeof value.target !== 'string'
|
|
134
|
+
|| !['prepared', 'backed_up', 'reserved', 'published'].includes(value.phase)
|
|
135
|
+
|| !(value.originalHash === null || /^[a-f0-9]{64}$/.test(value.originalHash))
|
|
136
|
+
|| !/^[a-f0-9]{64}$/.test(value.incomingHash))
|
|
137
|
+
throw new AssetLibraryImportError('invalid_library_import');
|
|
138
|
+
validPath(value.target);
|
|
139
|
+
if ((value.operationId !== undefined || value.assetId !== undefined || value.paths !== undefined)
|
|
140
|
+
&& (typeof value.operationId !== 'string' || !value.operationId || value.operationId.length > 128
|
|
141
|
+
|| typeof value.assetId !== 'string' || !value.assetId || value.assetId.length > 128
|
|
142
|
+
|| !Array.isArray(value.paths) || !value.paths.length || value.paths.length > WORKSPACE_LIBRARY_ATTACHMENT_MAX_FILES
|
|
143
|
+
|| value.paths.some(path => typeof path !== 'string' || !path.startsWith(`${value.target}/`) || !workspaceRelativePathSchema.safeParse(path).success)))
|
|
144
|
+
throw new AssetLibraryImportError('invalid_library_import');
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
await handle.close();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Restore interrupted replacements before serving files; ambiguous states retain every backup. */
|
|
152
|
+
export async function recoverInterruptedLibraryImports(root) {
|
|
153
|
+
const rootReal = await realpath(root);
|
|
154
|
+
const result = { recovered: [], pending: [], published: [] };
|
|
155
|
+
let scratch;
|
|
156
|
+
try {
|
|
157
|
+
scratch = await safeDirectory(rootReal, '.playcraft-temp');
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (missing(error))
|
|
161
|
+
return result;
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
for (const entry of await readdir(scratch, { withFileTypes: true })) {
|
|
165
|
+
if (!entry.isDirectory() || !entry.name.startsWith('library-import-'))
|
|
166
|
+
continue;
|
|
167
|
+
const transaction = join(scratch, entry.name);
|
|
168
|
+
try {
|
|
169
|
+
const manifest = await readTransaction(rootReal, transaction);
|
|
170
|
+
const target = join(rootReal, manifest.target);
|
|
171
|
+
const parent = dirname(manifest.target) === '.' ? '' : dirname(manifest.target);
|
|
172
|
+
await safeDirectory(rootReal, parent, true);
|
|
173
|
+
const current = await statTarget(rootReal, manifest.target);
|
|
174
|
+
const backup = await lstat(join(transaction, 'previous')).catch(error => { if (missing(error))
|
|
175
|
+
return undefined; throw error; });
|
|
176
|
+
const incoming = await lstat(join(transaction, 'incoming')).catch(error => { if (missing(error))
|
|
177
|
+
return undefined; throw error; });
|
|
178
|
+
if (backup && (!backup.isDirectory() || backup.isSymbolicLink()))
|
|
179
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
180
|
+
if (current?.isDirectory() && !current.isSymbolicLink() && !incoming
|
|
181
|
+
&& await directorySnapshot(target) === manifest.incomingHash) {
|
|
182
|
+
if (manifest.operationId && manifest.assetId && manifest.paths)
|
|
183
|
+
result.published.push({ operationId: manifest.operationId, assetId: manifest.assetId, paths: manifest.paths });
|
|
184
|
+
await removeTransaction(rootReal, transaction);
|
|
185
|
+
result.recovered.push(manifest.target);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (backup) {
|
|
189
|
+
if (current) {
|
|
190
|
+
if (!current.isDirectory() || current.isSymbolicLink() || (await readdir(target)).length)
|
|
191
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
192
|
+
if (manifest.reservation && (current.ino !== manifest.reservation.ino || current.dev !== manifest.reservation.dev))
|
|
193
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
194
|
+
await safeDirectory(rootReal, parent);
|
|
195
|
+
await rmdir(target);
|
|
196
|
+
}
|
|
197
|
+
await safeDirectory(rootReal, parent);
|
|
198
|
+
await safeDirectory(rootReal, relative(rootReal, transaction));
|
|
199
|
+
await rename(join(transaction, 'previous'), target);
|
|
200
|
+
await syncDirectory(dirname(target));
|
|
201
|
+
await removeTransaction(rootReal, transaction);
|
|
202
|
+
result.recovered.push(manifest.target);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (manifest.originalHash !== null && !current)
|
|
206
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
207
|
+
await removeTransaction(rootReal, transaction);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
result.pending.push(relative(rootReal, transaction));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
async function publishBundle(root, target, asset, replace, assertCurrent, operationId) {
|
|
216
|
+
const parent = dirname(target) === '.' ? '' : dirname(target);
|
|
217
|
+
await safeDirectory(root, parent, true);
|
|
218
|
+
const previous = await statTarget(root, target);
|
|
219
|
+
if (previous && (!replace || !previous.isDirectory() || previous.isSymbolicLink()))
|
|
220
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
221
|
+
const originalHash = previous ? await directorySnapshot(join(root, target)) : undefined;
|
|
222
|
+
const scratch = await safeDirectory(root, '.playcraft-temp', true);
|
|
223
|
+
const transaction = await mkdtemp(join(scratch, 'library-import-'));
|
|
224
|
+
const staged = join(transaction, 'incoming'), backup = join(transaction, 'previous');
|
|
225
|
+
await mkdir(staged, { mode: 0o700 });
|
|
226
|
+
let moved = false, published = false, preserve = false;
|
|
227
|
+
let reservation;
|
|
228
|
+
try {
|
|
229
|
+
for (const file of asset.files) {
|
|
230
|
+
await writeWorkspaceBinaryFile(staged, { path: file.path, contentBase64: file.content, expectedContentHash: null });
|
|
231
|
+
}
|
|
232
|
+
const manifest = { version: 1, target, phase: 'prepared', originalHash: originalHash ?? null,
|
|
233
|
+
incomingHash: await directorySnapshot(staged), ...(operationId ? { operationId, assetId: asset.assetId,
|
|
234
|
+
paths: asset.files.map(file => `${target}/${file.path}`) } : {}) };
|
|
235
|
+
await saveTransaction(root, transaction, manifest);
|
|
236
|
+
await assertCurrent();
|
|
237
|
+
await safeDirectory(root, parent);
|
|
238
|
+
const current = await statTarget(root, target);
|
|
239
|
+
if (previous) {
|
|
240
|
+
if (!current || current.ino !== previous.ino || current.dev !== previous.dev || !current.isDirectory()
|
|
241
|
+
|| await directorySnapshot(join(root, target)) !== originalHash)
|
|
242
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
243
|
+
await rename(join(root, target), backup);
|
|
244
|
+
moved = true;
|
|
245
|
+
preserve = true;
|
|
246
|
+
await syncDirectory(join(root, parent));
|
|
247
|
+
await saveTransaction(root, transaction, { ...manifest, phase: 'backed_up' });
|
|
248
|
+
if (await directorySnapshot(backup) !== originalHash)
|
|
249
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
250
|
+
}
|
|
251
|
+
else if (current)
|
|
252
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
253
|
+
await mkdir(join(root, target), { mode: 0o700 });
|
|
254
|
+
reservation = await lstat(join(root, target));
|
|
255
|
+
await saveTransaction(root, transaction, { ...manifest, phase: 'reserved', reservation: { dev: reservation.dev, ino: reservation.ino } });
|
|
256
|
+
await assertCurrent();
|
|
257
|
+
await safeDirectory(root, parent);
|
|
258
|
+
await safeDirectory(root, relative(root, transaction));
|
|
259
|
+
const verified = await lstat(join(root, target));
|
|
260
|
+
if (!verified.isDirectory() || verified.isSymbolicLink() || verified.ino !== reservation.ino || verified.dev !== reservation.dev)
|
|
261
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
262
|
+
await rename(staged, join(root, target));
|
|
263
|
+
published = true;
|
|
264
|
+
preserve = Boolean(operationId);
|
|
265
|
+
await syncDirectory(join(root, parent));
|
|
266
|
+
await saveTransaction(root, transaction, { ...manifest, phase: 'published' });
|
|
267
|
+
return operationId ? transaction : undefined;
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
if (!published && reservation) {
|
|
271
|
+
const current = await statTarget(root, target);
|
|
272
|
+
if (current?.ino === reservation.ino && current.dev === reservation.dev)
|
|
273
|
+
await rmdir(join(root, target)).catch(() => undefined);
|
|
274
|
+
}
|
|
275
|
+
if (moved && !published) {
|
|
276
|
+
preserve = true;
|
|
277
|
+
if (!await statTarget(root, target)) {
|
|
278
|
+
await rename(backup, join(root, target));
|
|
279
|
+
preserve = false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
throw error;
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
// A concurrent replacement can prevent rollback; keep the original bytes for recovery.
|
|
286
|
+
if (!preserve)
|
|
287
|
+
await removeTransaction(root, transaction).catch(() => undefined);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
export async function importWorkspaceLibraryAssets(root, selection, snapshot, assertCurrent = async () => undefined, options = {}) {
|
|
291
|
+
const payload = workspaceAssetLibraryImportPayloadSchema.parse(selection);
|
|
292
|
+
const transport = workspaceAssetLibraryImportTransportSchema.parse(snapshot);
|
|
293
|
+
const exported = new Map(transport.assets.map(asset => [asset.assetId, asset]));
|
|
294
|
+
const received = new Set([...exported.keys(), ...transport.failures.map(failure => failure.assetId)]);
|
|
295
|
+
if (payload.assetIds.length !== received.size || payload.assetIds.some(id => !received.has(id)))
|
|
296
|
+
throw new AssetLibraryImportError('invalid_library_import');
|
|
297
|
+
if (payload.targetDirectory)
|
|
298
|
+
validPath(payload.targetDirectory);
|
|
299
|
+
const rootReal = await realpath(root);
|
|
300
|
+
await safeDirectory(rootReal, payload.targetDirectory, true);
|
|
301
|
+
const result = { paths: [], skippedPaths: [], failures: [...transport.failures] };
|
|
302
|
+
const processed = new Set(transport.failures.map(failure => failure.assetId));
|
|
303
|
+
const progress = () => options.onProgress?.({ ...result, failures: [...result.failures,
|
|
304
|
+
...payload.assetIds.filter(id => !processed.has(id)).map(assetId => ({ assetId, error: 'asset_library_import_interrupted' }))] });
|
|
305
|
+
await progress();
|
|
306
|
+
for (const assetId of payload.assetIds) {
|
|
307
|
+
const asset = exported.get(assetId);
|
|
308
|
+
if (!asset)
|
|
309
|
+
continue;
|
|
310
|
+
let publishedTransaction;
|
|
311
|
+
try {
|
|
312
|
+
validateAsset(asset);
|
|
313
|
+
await assertCurrent();
|
|
314
|
+
const originalName = asset.kind === 'bundle'
|
|
315
|
+
? asset.name.replace(/\.(?:prefab|aiaudio|aiimage|aiconfig|aigameplay)$/i, '')
|
|
316
|
+
: basename(asset.files[0].path);
|
|
317
|
+
validPath(originalName);
|
|
318
|
+
if (originalName.includes('/'))
|
|
319
|
+
throw new AssetLibraryImportError('invalid_library_import_path');
|
|
320
|
+
let name = originalName;
|
|
321
|
+
let target = validPath([payload.targetDirectory, name].filter(Boolean).join('/'));
|
|
322
|
+
let existing = await statTarget(rootReal, target);
|
|
323
|
+
if (existing && payload.collision === 'skip') {
|
|
324
|
+
result.skippedPaths.push(target);
|
|
325
|
+
processed.add(assetId);
|
|
326
|
+
await progress();
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (payload.collision === 'rename') {
|
|
330
|
+
const extension = asset.kind === 'bundle' ? '' : extname(originalName);
|
|
331
|
+
const stem = originalName.slice(0, originalName.length - extension.length);
|
|
332
|
+
for (let suffix = 1; existing; suffix++) {
|
|
333
|
+
if (suffix > 10_000)
|
|
334
|
+
throw new AssetLibraryImportError('content_conflict');
|
|
335
|
+
name = `${stem} (${suffix})${extension}`;
|
|
336
|
+
target = validPath([payload.targetDirectory, name].filter(Boolean).join('/'));
|
|
337
|
+
existing = await statTarget(rootReal, target);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (asset.kind === 'bundle') {
|
|
341
|
+
const paths = asset.files.map(file => validPath(`${target}/${file.path}`));
|
|
342
|
+
publishedTransaction = await publishBundle(rootReal, target, asset, payload.collision === 'replace', assertCurrent, options.operationId);
|
|
343
|
+
result.paths.push(...paths);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
const observed = existing ? await observeWorkspaceBinaryFile(rootReal, target) : undefined;
|
|
347
|
+
await assertCurrent();
|
|
348
|
+
await writeWorkspaceBinaryFile(rootReal, { path: target, contentBase64: asset.files[0].content,
|
|
349
|
+
expectedContentHash: observed?.contentHash ?? null });
|
|
350
|
+
result.paths.push(target);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
const code = error instanceof AssetLibraryImportError ? error.message
|
|
355
|
+
: error?.code === 'content_conflict' ? 'content_conflict'
|
|
356
|
+
: ['EACCES', 'EPERM'].includes(String(error?.code)) ? 'workspace_permission_denied'
|
|
357
|
+
: 'asset_library_import_failed';
|
|
358
|
+
result.failures.push({ assetId, error: code });
|
|
359
|
+
}
|
|
360
|
+
processed.add(assetId);
|
|
361
|
+
await progress();
|
|
362
|
+
if (publishedTransaction)
|
|
363
|
+
await removeTransaction(rootReal, publishedTransaction).catch(() => undefined);
|
|
364
|
+
}
|
|
365
|
+
return workspaceAssetLibraryImportResultSchema.parse(result);
|
|
366
|
+
}
|