@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,112 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, open, rename, unlink } from 'node:fs/promises';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { isWorkspaceArtifactOutputPath, workspaceArtifactReceiptSchema } from '@playcraft/common/cloud-workspace/runtime';
|
|
6
|
+
import { artifactDirectory, artifactFormat, relativeArtifactPath, snapshotArtifactBundle } from './artifact-files.js';
|
|
7
|
+
import { shareWorkspaceAssetDirectory } from './asset-publication-access.js';
|
|
8
|
+
import { excludeFromGit } from './dependencies.js';
|
|
9
|
+
export const ARTIFACT_RECEIPTS_DIRECTORY = '.playcraft/artifact-receipts';
|
|
10
|
+
export const artifactReceiptSchema = workspaceArtifactReceiptSchema;
|
|
11
|
+
export async function generatedWorkspace(cwd) {
|
|
12
|
+
for (let root = resolve(cwd);; root = dirname(root)) {
|
|
13
|
+
const file = join(root, '.playcraft/workspace-context.json');
|
|
14
|
+
try {
|
|
15
|
+
const handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
16
|
+
try {
|
|
17
|
+
if ((await handle.stat()).size > 8192)
|
|
18
|
+
throw new Error('invalid_workspace_context');
|
|
19
|
+
const value = JSON.parse(await handle.readFile('utf8'));
|
|
20
|
+
if (value.schemaVersion !== 'playcraft.workspace-context.v1' || typeof value.workspaceId !== 'string')
|
|
21
|
+
throw new Error('invalid_workspace_context');
|
|
22
|
+
return { root, workspaceId: value.workspaceId };
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
await handle.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error.code !== 'ENOENT')
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
if (dirname(root) === root)
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The receipt tree is written by the development identity and read by the controller. A directory
|
|
38
|
+
* the other identity created cannot be re-shaped here; its owner repairs it on the next write and
|
|
39
|
+
* readers keep working from whatever already carries the shared bits.
|
|
40
|
+
*/
|
|
41
|
+
async function shareArtifactDirectory(root, directory) {
|
|
42
|
+
try {
|
|
43
|
+
await shareWorkspaceAssetDirectory(root, directory);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const code = error.code;
|
|
47
|
+
if (code !== 'EACCES' && code !== 'EPERM')
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Preserve final outputs before another command overwrites them; intermediate project assets are not registered. */
|
|
52
|
+
export async function captureGeneratedArtifact(output, tool, metadata = {}, cwd = process.cwd(), expectedDigest, origin) {
|
|
53
|
+
const context = await generatedWorkspace(cwd);
|
|
54
|
+
if (!context)
|
|
55
|
+
return;
|
|
56
|
+
const absolute = resolve(cwd, output);
|
|
57
|
+
let path;
|
|
58
|
+
try {
|
|
59
|
+
path = relativeArtifactPath(context.root, absolute);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!isWorkspaceArtifactOutputPath(path) || !artifactFormat(path))
|
|
65
|
+
return;
|
|
66
|
+
const receipts = await artifactDirectory(context.root, ARTIFACT_RECEIPTS_DIRECTORY);
|
|
67
|
+
const objects = await artifactDirectory(context.root, `${ARTIFACT_RECEIPTS_DIRECTORY}/objects`);
|
|
68
|
+
// Generations are written as the development identity while the controller scans this tree.
|
|
69
|
+
await shareArtifactDirectory(context.root, receipts);
|
|
70
|
+
await shareArtifactDirectory(context.root, objects);
|
|
71
|
+
const thumbnailPath = metadata.thumbnailPath ? relativeArtifactPath(context.root, resolve(cwd, metadata.thumbnailPath)) : undefined;
|
|
72
|
+
const files = await snapshotArtifactBundle(context.root, path, objects, thumbnailPath);
|
|
73
|
+
if (expectedDigest && files.find(file => file.role === 'primary')?.sha256 !== expectedDigest)
|
|
74
|
+
throw new Error('artifact_file_changed');
|
|
75
|
+
const receipt = artifactReceiptSchema.parse({
|
|
76
|
+
id: randomUUID(), workspaceId: context.workspaceId, path,
|
|
77
|
+
source: { kind: 'generated', tool, generatedAt: new Date().toISOString(),
|
|
78
|
+
...(origin?.sessionId ? { sessionId: origin.sessionId } : {}), ...(origin?.operationId ? { operationId: origin.operationId } : {}) }, files,
|
|
79
|
+
...(metadata.width ? { width: metadata.width } : {}), ...(metadata.height ? { height: metadata.height } : {}),
|
|
80
|
+
...(metadata.duration !== undefined ? { duration: metadata.duration } : {}),
|
|
81
|
+
});
|
|
82
|
+
const temporary = join(receipts, `${receipt.id}.tmp`);
|
|
83
|
+
const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o660);
|
|
84
|
+
try {
|
|
85
|
+
await handle.chmod(0o660);
|
|
86
|
+
await handle.writeFile(`${JSON.stringify(receipt)}\n`);
|
|
87
|
+
await handle.sync();
|
|
88
|
+
await handle.close();
|
|
89
|
+
await rename(temporary, join(receipts, `${receipt.id}.json`));
|
|
90
|
+
// The workspace checkpoint retains these receipts; they are not source files or exported assets.
|
|
91
|
+
await excludeFromGit(context.root, `/${ARTIFACT_RECEIPTS_DIRECTORY}/`);
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
await handle.close();
|
|
95
|
+
await unlink(temporary).catch(error => { if (error.code !== 'ENOENT')
|
|
96
|
+
throw error; });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export async function readArtifactReceipt(path) {
|
|
100
|
+
if (!(await lstat(path)).isFile())
|
|
101
|
+
throw new Error('invalid_artifact_receipt');
|
|
102
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
103
|
+
try {
|
|
104
|
+
const stat = await handle.stat();
|
|
105
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size > 1024 * 1024)
|
|
106
|
+
throw new Error('invalid_artifact_receipt');
|
|
107
|
+
return artifactReceiptSchema.parse(JSON.parse(await handle.readFile('utf8')));
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await handle.close();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,380 @@
|
|
|
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
|
+
import { validateWorkspacePlayable } from '../previews/finalize.js';
|
|
10
|
+
import { PREVIEW_HTML_MAX_BYTES, WORKSPACE_PLAYABLE_OUTPUT_PATH } from '@playcraft/common/cloud-workspace/runtime';
|
|
11
|
+
const serial = new Map();
|
|
12
|
+
function digest(text) { return createHash('sha256').update(text).digest('hex'); }
|
|
13
|
+
function artifactId(workspaceId, path) { return `artifact_${digest(`${workspaceId}\0${path}`).slice(0, 40)}`; }
|
|
14
|
+
function outputArtifacts(artifacts) {
|
|
15
|
+
return artifacts.flatMap(artifact => {
|
|
16
|
+
const versions = artifact.versions.filter(isWorkspaceArtifactOutputVersion);
|
|
17
|
+
if (!versions.length)
|
|
18
|
+
return [];
|
|
19
|
+
const current = versions.find(version => version.id === artifact.currentVersionId)
|
|
20
|
+
?? versions.reduce((latest, version) => version.createdAt > latest.createdAt ? version : latest);
|
|
21
|
+
return [{ ...artifact, versions, currentVersionId: current.id, updatedAt: current.createdAt }];
|
|
22
|
+
}).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.id.localeCompare(b.id));
|
|
23
|
+
}
|
|
24
|
+
/** Catalogs and immutable bytes are control-owned, outside the mutable checkout. */
|
|
25
|
+
export class WorkspaceArtifactStore {
|
|
26
|
+
stateDir;
|
|
27
|
+
workspaceId;
|
|
28
|
+
directoryName;
|
|
29
|
+
constructor(stateDir, workspaceId, directoryName = 'basic') {
|
|
30
|
+
this.stateDir = stateDir;
|
|
31
|
+
this.workspaceId = workspaceId;
|
|
32
|
+
this.directoryName = directoryName;
|
|
33
|
+
if (!/^(basic|remix-[a-z0-9][a-z0-9-]{3,63})$/.test(directoryName))
|
|
34
|
+
throw new Error('invalid_workspace_directory');
|
|
35
|
+
}
|
|
36
|
+
get scopeId() { return this.directoryName === 'basic' ? this.workspaceId : `${this.workspaceId}:${this.directoryName}`; }
|
|
37
|
+
async directory() {
|
|
38
|
+
await mkdir(this.stateDir, { recursive: true, mode: 0o700 });
|
|
39
|
+
return artifactDirectory(this.stateDir, `artifacts/${digest(this.scopeId)}`);
|
|
40
|
+
}
|
|
41
|
+
async read(directory) {
|
|
42
|
+
const handle = await open(join(directory, 'catalog.json'), constants.O_RDONLY | constants.O_NOFOLLOW).catch(error => {
|
|
43
|
+
if (error.code === 'ENOENT')
|
|
44
|
+
return undefined;
|
|
45
|
+
throw error;
|
|
46
|
+
});
|
|
47
|
+
if (!handle)
|
|
48
|
+
return { artifacts: [], scannedAt: new Date().toISOString(), receipts: [], observations: {} };
|
|
49
|
+
try {
|
|
50
|
+
const stat = await handle.stat();
|
|
51
|
+
if (!stat.isFile() || stat.size > 32 * 1024 * 1024)
|
|
52
|
+
throw new Error('artifact_catalog_invalid');
|
|
53
|
+
const { receipts, observations = {}, playable, ...body } = JSON.parse(await handle.readFile('utf8'));
|
|
54
|
+
if (!Array.isArray(receipts) || receipts.some(id => typeof id !== 'string'))
|
|
55
|
+
throw new Error('artifact_catalog_invalid');
|
|
56
|
+
if (playable && (!Array.isArray(playable.pending) || playable.pending.some(value => typeof value !== 'string')
|
|
57
|
+
|| playable.rejectedDigest !== undefined && !/^[a-f0-9]{64}$/.test(playable.rejectedDigest)))
|
|
58
|
+
throw new Error('artifact_catalog_invalid');
|
|
59
|
+
return { ...workspaceArtifactListSchema.parse(body), receipts, observations, ...(playable ? { playable } : {}) };
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
await handle.close();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async write(directory, catalog) {
|
|
66
|
+
const temporary = join(directory, `${randomUUID()}.tmp`);
|
|
67
|
+
const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
68
|
+
try {
|
|
69
|
+
await handle.writeFile(JSON.stringify(catalog));
|
|
70
|
+
await handle.sync();
|
|
71
|
+
await handle.close();
|
|
72
|
+
await rename(temporary, join(directory, 'catalog.json'));
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await handle.close();
|
|
76
|
+
await unlink(temporary).catch(error => { if (error.code !== 'ENOENT')
|
|
77
|
+
throw error; });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async discover(root, source = { kind: 'discovered' }, sourcePaths = [], playable = {}) {
|
|
81
|
+
const key = `${this.stateDir}\0${this.scopeId}`;
|
|
82
|
+
const previous = serial.get(key) ?? Promise.resolve();
|
|
83
|
+
const task = previous.catch(() => undefined).then(() => this.scan(root, source, sourcePaths, playable));
|
|
84
|
+
serial.set(key, task);
|
|
85
|
+
try {
|
|
86
|
+
return await task;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
if (serial.get(key) === task)
|
|
90
|
+
serial.delete(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async list() {
|
|
94
|
+
const catalog = await this.read(await this.directory());
|
|
95
|
+
return workspaceArtifactListSchema.parse({ artifacts: outputArtifacts(catalog.artifacts), scannedAt: catalog.scannedAt });
|
|
96
|
+
}
|
|
97
|
+
async rejectedPlayable(bytes) {
|
|
98
|
+
return (await this.read(await this.directory())).playable?.rejectedDigest === createHash('sha256').update(bytes).digest('hex');
|
|
99
|
+
}
|
|
100
|
+
async hasPendingPlayableExecution(executionId) {
|
|
101
|
+
return (await this.read(await this.directory())).playable?.pending.some(id => id.split('/').length > 2 && id !== executionId) ?? false;
|
|
102
|
+
}
|
|
103
|
+
async isCurrentPlayable(bytes) {
|
|
104
|
+
const catalog = await this.read(await this.directory());
|
|
105
|
+
const artifact = catalog.artifacts.find(item => item.kind === 'playable' && item.versions.some(version => version.path === WORKSPACE_PLAYABLE_OUTPUT_PATH));
|
|
106
|
+
return artifact?.versions.find(item => item.id === artifact.currentVersionId)?.sha256 === createHash('sha256').update(bytes).digest('hex');
|
|
107
|
+
}
|
|
108
|
+
async scan(root, source, sourcePaths, playable) {
|
|
109
|
+
const directory = await this.directory();
|
|
110
|
+
const objects = await artifactDirectory(directory, 'objects');
|
|
111
|
+
const catalog = await this.read(directory);
|
|
112
|
+
const original = JSON.stringify(outputArtifacts(catalog.artifacts));
|
|
113
|
+
const gate = catalog.playable ??= { pending: [] };
|
|
114
|
+
if (playable.mode === 'skip' || playable.mode === 'failure')
|
|
115
|
+
gate.initialized = true;
|
|
116
|
+
if (playable.executionId) {
|
|
117
|
+
gate.pending = gate.pending.filter(id => id !== playable.executionId && (playable.mode === 'hold' || !id.startsWith(`${playable.executionId}/`)));
|
|
118
|
+
if (playable.mode === 'hold')
|
|
119
|
+
gate.pending.push(playable.executionId);
|
|
120
|
+
}
|
|
121
|
+
const receipts = await this.receipts(root, catalog);
|
|
122
|
+
for (const receipt of receipts) {
|
|
123
|
+
try {
|
|
124
|
+
for (const file of receipt.files) {
|
|
125
|
+
const copied = await snapshotArtifactFile(root, `${ARTIFACT_RECEIPTS_DIRECTORY}/objects/${file.sha256}`, objects);
|
|
126
|
+
if (copied.sha256 !== file.sha256 || copied.size !== file.size)
|
|
127
|
+
throw new Error('artifact_receipt_digest_mismatch');
|
|
128
|
+
}
|
|
129
|
+
const primary = receipt.files.find(file => file.role === 'primary' && file.path === receipt.path);
|
|
130
|
+
if (!primary || !artifactFormat(receipt.path))
|
|
131
|
+
continue;
|
|
132
|
+
const version = {
|
|
133
|
+
id: `version_${receipt.id}`, createdAt: receipt.source.generatedAt ?? new Date().toISOString(),
|
|
134
|
+
path: receipt.path, mimeType: primary.mimeType, size: primary.size, sha256: primary.sha256,
|
|
135
|
+
files: receipt.files, source: receipt.source,
|
|
136
|
+
...(receipt.width ? { width: receipt.width } : {}), ...(receipt.height ? { height: receipt.height } : {}),
|
|
137
|
+
...(receipt.duration !== undefined ? { duration: receipt.duration } : {}),
|
|
138
|
+
};
|
|
139
|
+
const kind = await this.versionKind(objects, version);
|
|
140
|
+
await this.add(catalog, version, kind, objects);
|
|
141
|
+
if (kind === 'playable') {
|
|
142
|
+
gate.rejectedDigest = undefined;
|
|
143
|
+
gate.initialized = true;
|
|
144
|
+
}
|
|
145
|
+
catalog.receipts.push(receipt.id);
|
|
146
|
+
}
|
|
147
|
+
catch { /* An incomplete receipt stays pending; the next scan retries its original bytes. */ }
|
|
148
|
+
}
|
|
149
|
+
const candidates = await discoverPaths(root);
|
|
150
|
+
// Models are inspected before images so their explicitly referenced textures stay under the model.
|
|
151
|
+
candidates.sort((a, b) => Number(artifactFormat(b)?.[0] === 'model') - Number(artifactFormat(a)?.[0] === 'model') || a.localeCompare(b));
|
|
152
|
+
const visible = outputArtifacts(catalog.artifacts);
|
|
153
|
+
const members = new Set(visible.flatMap(artifact => artifact.versions.flatMap(version => version.files.filter(file => file.role !== 'primary').map(file => file.path))));
|
|
154
|
+
for (const path of candidates) {
|
|
155
|
+
if (members.has(path))
|
|
156
|
+
continue;
|
|
157
|
+
if (path === WORKSPACE_PLAYABLE_OUTPUT_PATH && ['hold', 'skip'].includes(playable.mode ?? ''))
|
|
158
|
+
continue;
|
|
159
|
+
if (path === WORKSPACE_PLAYABLE_OUTPUT_PATH && gate.initialized && !['success', 'failure'].includes(playable.mode ?? ''))
|
|
160
|
+
continue;
|
|
161
|
+
try {
|
|
162
|
+
const current = visible.find(artifact => artifact.id === artifactId(this.scopeId, path));
|
|
163
|
+
const version = current?.versions.find(entry => entry.id === current.currentVersionId);
|
|
164
|
+
const knownWrite = sourcePaths.includes(path) && Boolean(source.operationId) && version?.source.operationId !== source.operationId;
|
|
165
|
+
const observation = catalog.observations[path];
|
|
166
|
+
if (!knownWrite && version && (path !== WORKSPACE_PLAYABLE_OUTPUT_PATH || current?.kind === 'playable')
|
|
167
|
+
&& observation?.versionId === version.id && observation.signature === await fileSignature(root, version.files.map(file => file.path)))
|
|
168
|
+
continue;
|
|
169
|
+
const thumbnail = version?.files.find(file => file.role === 'thumbnail');
|
|
170
|
+
const thumbnailPath = thumbnail && await lstat(join(root, thumbnail.path)).then(stat => stat.isFile(), () => false) ? thumbnail.path : undefined;
|
|
171
|
+
const paths = [path, ...await artifactResources(root, path), ...(thumbnailPath ? [thumbnailPath] : [])];
|
|
172
|
+
const signature = await fileSignature(root, paths);
|
|
173
|
+
const files = await snapshotArtifactBundle(root, path, objects, thumbnailPath);
|
|
174
|
+
if (signature !== await fileSignature(root, files.map(file => file.path)))
|
|
175
|
+
continue;
|
|
176
|
+
for (const file of files)
|
|
177
|
+
if (file.role !== 'primary')
|
|
178
|
+
members.add(file.path);
|
|
179
|
+
if (!knownWrite && version && (path !== WORKSPACE_PLAYABLE_OUTPUT_PATH || current?.kind === 'playable')
|
|
180
|
+
&& artifactBundleDigest(version.files) === artifactBundleDigest(files)) {
|
|
181
|
+
catalog.observations[path] = { signature, versionId: version.id };
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const primary = files[0];
|
|
185
|
+
if (path === WORKSPACE_PLAYABLE_OUTPUT_PATH) {
|
|
186
|
+
if (playable.mode === 'failure') {
|
|
187
|
+
gate.rejectedDigest = primary.sha256;
|
|
188
|
+
gate.initialized = true;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (playable.mode === 'success'
|
|
192
|
+
? gate.pending.some(id => id.split('/').length > 2)
|
|
193
|
+
: gate.pending.length > 0)
|
|
194
|
+
continue;
|
|
195
|
+
if (gate.rejectedDigest === primary.sha256 && !playable.force)
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const next = {
|
|
199
|
+
id: `version_${knownWrite ? source.operationId : randomUUID()}`, createdAt: new Date().toISOString(),
|
|
200
|
+
path, mimeType: primary.mimeType, size: primary.size, sha256: primary.sha256, files,
|
|
201
|
+
source: sourcePaths.includes(path) ? source : { kind: 'discovered' },
|
|
202
|
+
...await this.dimensions(objects, primary),
|
|
203
|
+
};
|
|
204
|
+
const kind = await this.versionKind(objects, next);
|
|
205
|
+
await this.add(catalog, next, kind, objects);
|
|
206
|
+
if (kind === 'playable') {
|
|
207
|
+
gate.rejectedDigest = undefined;
|
|
208
|
+
gate.initialized = true;
|
|
209
|
+
}
|
|
210
|
+
catalog.observations[path] = { signature, versionId: next.id };
|
|
211
|
+
}
|
|
212
|
+
catch { /* Files being written or temporarily missing are retried, never published as complete. */ }
|
|
213
|
+
}
|
|
214
|
+
catalog.artifacts = catalog.artifacts.filter(artifact => {
|
|
215
|
+
const current = artifact.versions.find(version => version.id === artifact.currentVersionId);
|
|
216
|
+
return !isWorkspaceArtifactOutputVersion(current) || current.source.kind !== 'discovered' || !members.has(current.path);
|
|
217
|
+
});
|
|
218
|
+
catalog.artifacts.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.id.localeCompare(b.id));
|
|
219
|
+
catalog.scannedAt = new Date().toISOString();
|
|
220
|
+
const list = workspaceArtifactListSchema.parse({ artifacts: outputArtifacts(catalog.artifacts), scannedAt: catalog.scannedAt });
|
|
221
|
+
await this.write(directory, catalog);
|
|
222
|
+
return { list, changed: original !== JSON.stringify(list.artifacts) };
|
|
223
|
+
}
|
|
224
|
+
async versionKind(objects, version) {
|
|
225
|
+
if (version.path !== WORKSPACE_PLAYABLE_OUTPUT_PATH)
|
|
226
|
+
return artifactFormat(version.path)[0];
|
|
227
|
+
if (version.files.length !== 1)
|
|
228
|
+
throw new Error('preview_not_single_file');
|
|
229
|
+
const primary = version.files[0];
|
|
230
|
+
const file = await open(join(objects, primary.sha256), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
231
|
+
try {
|
|
232
|
+
const stat = await file.stat();
|
|
233
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size > PREVIEW_HTML_MAX_BYTES)
|
|
234
|
+
throw new Error('preview_not_single_file');
|
|
235
|
+
const bytes = await file.readFile();
|
|
236
|
+
if (bytes.length !== primary.size || createHash('sha256').update(bytes).digest('hex') !== primary.sha256)
|
|
237
|
+
throw new Error('artifact_snapshot_invalid');
|
|
238
|
+
validateWorkspacePlayable(bytes);
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
await file.close();
|
|
242
|
+
}
|
|
243
|
+
return 'playable';
|
|
244
|
+
}
|
|
245
|
+
async add(catalog, version, kind, objects) {
|
|
246
|
+
const id = artifactId(this.scopeId, version.path);
|
|
247
|
+
let artifact = catalog.artifacts.find(item => item.id === id);
|
|
248
|
+
if (!artifact) {
|
|
249
|
+
artifact = { id, kind, name: basename(version.path), currentVersionId: version.id, updatedAt: version.createdAt, versions: [] };
|
|
250
|
+
catalog.artifacts.push(artifact);
|
|
251
|
+
}
|
|
252
|
+
if (kind === 'playable' && artifact.kind !== 'playable') {
|
|
253
|
+
const valid = await Promise.all(artifact.versions.map(async (item) => {
|
|
254
|
+
try {
|
|
255
|
+
return await this.versionKind(objects, item) === 'playable' ? item : undefined;
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
artifact.versions = valid.filter((item) => Boolean(item));
|
|
262
|
+
}
|
|
263
|
+
artifact.kind = kind;
|
|
264
|
+
if (this.directoryName !== 'basic')
|
|
265
|
+
version.directoryName = this.directoryName;
|
|
266
|
+
const current = artifact.versions.find(item => item.id === artifact.currentVersionId);
|
|
267
|
+
if (kind === 'playable' && current && artifactBundleDigest(current.files) === artifactBundleDigest(version.files))
|
|
268
|
+
return;
|
|
269
|
+
if (!artifact.versions.some(item => item.id === version.id)) {
|
|
270
|
+
// Display ordering is monotonic; the original generation time stays in source.generatedAt.
|
|
271
|
+
const latest = Math.max(0, ...artifact.versions.map(item => Date.parse(item.createdAt)));
|
|
272
|
+
version.createdAt = new Date(Math.max(Date.parse(version.createdAt), latest + 1)).toISOString();
|
|
273
|
+
artifact.versions.unshift(version);
|
|
274
|
+
}
|
|
275
|
+
artifact.currentVersionId = version.id;
|
|
276
|
+
artifact.updatedAt = version.createdAt;
|
|
277
|
+
}
|
|
278
|
+
async receipts(root, catalog) {
|
|
279
|
+
let directory;
|
|
280
|
+
try {
|
|
281
|
+
const target = join(root, ARTIFACT_RECEIPTS_DIRECTORY);
|
|
282
|
+
if (!(await lstat(target)).isDirectory())
|
|
283
|
+
return [];
|
|
284
|
+
directory = await artifactDirectory(root, ARTIFACT_RECEIPTS_DIRECTORY);
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
const seen = new Set(catalog.receipts), receipts = [];
|
|
290
|
+
// A receipt tree the current identity cannot read is skipped rather than failing the scan.
|
|
291
|
+
const names = await readdir(directory).catch(() => []);
|
|
292
|
+
for (const name of names) {
|
|
293
|
+
if (!/^[a-f0-9-]{36}\.json$/.test(name) || seen.has(name.slice(0, -5)))
|
|
294
|
+
continue;
|
|
295
|
+
try {
|
|
296
|
+
const receipt = await readArtifactReceipt(join(directory, name));
|
|
297
|
+
if (receipt.workspaceId === this.workspaceId && `${receipt.id}.json` === name && isWorkspaceArtifactOutputVersion(receipt))
|
|
298
|
+
receipts.push(receipt);
|
|
299
|
+
}
|
|
300
|
+
catch { /* Malformed output metadata is never trusted as a completed artifact. */ }
|
|
301
|
+
}
|
|
302
|
+
return receipts.sort((a, b) => (a.source.generatedAt ?? '').localeCompare(b.source.generatedAt ?? '') || a.id.localeCompare(b.id));
|
|
303
|
+
}
|
|
304
|
+
async dimensions(objects, file) {
|
|
305
|
+
if (!file.mimeType.startsWith('image/') || file.mimeType === 'image/svg+xml')
|
|
306
|
+
return {};
|
|
307
|
+
try {
|
|
308
|
+
const metadata = await sharp(join(objects, file.sha256), { limitInputPixels: 100_000_000 }).metadata();
|
|
309
|
+
return { ...(metadata.width ? { width: metadata.width } : {}), ...(metadata.height ? { height: metadata.height } : {}) };
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return {};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async content(input) {
|
|
316
|
+
const query = workspaceArtifactContentQuerySchema.parse(input);
|
|
317
|
+
const directory = await this.directory(), catalog = await this.read(directory);
|
|
318
|
+
const artifact = catalog.artifacts.find(item => item.id === query.artifactId);
|
|
319
|
+
const version = artifact?.versions.find(item => item.id === query.versionId && isWorkspaceArtifactOutputVersion(item));
|
|
320
|
+
const file = version?.files.find(item => item.path === (query.path ?? version.path));
|
|
321
|
+
if (!file)
|
|
322
|
+
throw new Error('artifact_not_found');
|
|
323
|
+
if (query.offset > file.size)
|
|
324
|
+
throw new Error('artifact_range_invalid');
|
|
325
|
+
const handle = await open(join(directory, 'objects', file.sha256), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
326
|
+
try {
|
|
327
|
+
const stat = await handle.stat();
|
|
328
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size !== file.size)
|
|
329
|
+
throw new Error('artifact_snapshot_invalid');
|
|
330
|
+
const bytes = Buffer.alloc(Math.min(query.length, file.size - query.offset));
|
|
331
|
+
let read = 0;
|
|
332
|
+
while (read < bytes.length) {
|
|
333
|
+
const part = await handle.read(bytes, read, bytes.length - read, query.offset + read);
|
|
334
|
+
if (!part.bytesRead)
|
|
335
|
+
throw new Error('artifact_snapshot_invalid');
|
|
336
|
+
read += part.bytesRead;
|
|
337
|
+
}
|
|
338
|
+
return { content: bytes.toString('base64'), mimeType: file.mimeType, totalBytes: file.size, offset: query.offset, sha256: file.sha256 };
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
await handle.close();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
async function fileSignature(root, paths) {
|
|
346
|
+
const records = [];
|
|
347
|
+
for (const path of [...new Set(paths)].sort()) {
|
|
348
|
+
const stat = await lstat(await artifactPath(root, path));
|
|
349
|
+
if (!stat.isFile() || stat.nlink !== 1)
|
|
350
|
+
throw new Error('artifact_file_unavailable');
|
|
351
|
+
records.push([path, stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs]);
|
|
352
|
+
}
|
|
353
|
+
return JSON.stringify(records);
|
|
354
|
+
}
|
|
355
|
+
async function discoverPaths(root, directory = WORKSPACE_ARTIFACT_OUTPUT_DIRECTORY, result = []) {
|
|
356
|
+
if (directory !== WORKSPACE_ARTIFACT_OUTPUT_DIRECTORY && !isWorkspaceArtifactOutputPath(directory))
|
|
357
|
+
throw new Error('invalid_artifact_path');
|
|
358
|
+
let target;
|
|
359
|
+
try {
|
|
360
|
+
target = await artifactPath(root, directory);
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
if (error.code === 'ENOENT')
|
|
364
|
+
return result;
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
if (!(await lstat(target)).isDirectory())
|
|
368
|
+
throw new Error('invalid_artifact_directory');
|
|
369
|
+
for (const entry of await readdir(target, { withFileTypes: true })) {
|
|
370
|
+
if (entry.name.startsWith('.') || entry.isSymbolicLink())
|
|
371
|
+
continue;
|
|
372
|
+
const path = `${directory}/${entry.name}`;
|
|
373
|
+
if (entry.isDirectory()) {
|
|
374
|
+
await discoverPaths(root, path, result);
|
|
375
|
+
}
|
|
376
|
+
else if (entry.isFile() && artifactFormat(path))
|
|
377
|
+
result.push(path);
|
|
378
|
+
}
|
|
379
|
+
return result;
|
|
380
|
+
}
|