@wildshard/sdk 0.0.1 → 0.2.3
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/GUIDE.md +790 -0
- package/README.md +13 -5
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +365 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
boolean,
|
|
4
|
+
nullable,
|
|
5
|
+
number,
|
|
6
|
+
object,
|
|
7
|
+
optional,
|
|
8
|
+
safeParse,
|
|
9
|
+
string,
|
|
10
|
+
tuple,
|
|
11
|
+
} from 'valibot'
|
|
12
|
+
|
|
13
|
+
// `wildshard delete <slug>` (meta SHARD-DELETE DEL10, J307, J310): the
|
|
14
|
+
// owner's two calls back to back. Start (`POST /api/shards/:slug/delete`)
|
|
15
|
+
// answers a confirm token, good for 10 minutes, and a summary whose `note`
|
|
16
|
+
// says whether a signed release still plays the shard (DEL8); the author
|
|
17
|
+
// reads it and types the slug; finalize (`…/delete/finalize {confirm}`)
|
|
18
|
+
// spends the token. A typed slug that is not the slug finalizes nothing,
|
|
19
|
+
// and `yes` (`--yes`, for scripts) skips the typing. Both calls send the
|
|
20
|
+
// account key as `Authorization: Bearer`; the key and the token are never
|
|
21
|
+
// printed.
|
|
22
|
+
|
|
23
|
+
const OK = 200
|
|
24
|
+
const CONFLICT = 409
|
|
25
|
+
const SHORT_HASH = 8
|
|
26
|
+
const FIRST = 0
|
|
27
|
+
|
|
28
|
+
const ErrorSchema = object({ error: string() })
|
|
29
|
+
const VersionSchema = object({ version: string(), hash: string() })
|
|
30
|
+
const PointerSchema = object({ channel: string() })
|
|
31
|
+
const CellSchema = array(number())
|
|
32
|
+
const FreedSchema = tuple([number(), number()])
|
|
33
|
+
const PlacedSchema = object({ channel: string(), cells: array(CellSchema) })
|
|
34
|
+
|
|
35
|
+
const SummarySchema = object({
|
|
36
|
+
deleted: optional(boolean()),
|
|
37
|
+
versions: array(VersionSchema),
|
|
38
|
+
channels: array(PointerSchema),
|
|
39
|
+
grid: optional(array(PlacedSchema)),
|
|
40
|
+
note: optional(string()),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const StartSchema = object({
|
|
44
|
+
confirm: string(),
|
|
45
|
+
expiresAt: string(),
|
|
46
|
+
summary: SummarySchema,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const ChannelsSchema = array(string())
|
|
50
|
+
|
|
51
|
+
const FinalizeSchema = object({
|
|
52
|
+
deletedAt: string(),
|
|
53
|
+
channels: ChannelsSchema,
|
|
54
|
+
placements: ChannelsSchema,
|
|
55
|
+
/** The channels whose grid cells named the slug (api-server SA31). */
|
|
56
|
+
cells: optional(ChannelsSchema),
|
|
57
|
+
/** The slug's own grid cell, freed for the next new slug; null: it held none (SA31). */
|
|
58
|
+
freed: optional(nullable(FreedSchema)),
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
/** What finalize did, as the API answers it. */
|
|
62
|
+
type Finalized = Readonly<{
|
|
63
|
+
deletedAt: string
|
|
64
|
+
channels: readonly string[]
|
|
65
|
+
placements: readonly string[]
|
|
66
|
+
cells?: readonly string[] | undefined
|
|
67
|
+
freed?: readonly [number, number] | null | undefined
|
|
68
|
+
}>
|
|
69
|
+
|
|
70
|
+
type Started = Readonly<{
|
|
71
|
+
confirm: string
|
|
72
|
+
expiresAt: string
|
|
73
|
+
summary: Readonly<{
|
|
74
|
+
deleted?: boolean | undefined
|
|
75
|
+
versions: readonly Readonly<{ version: string; hash: string }>[]
|
|
76
|
+
channels: readonly Readonly<{ channel: string }>[]
|
|
77
|
+
grid?: readonly Placed[] | undefined
|
|
78
|
+
note?: string | undefined
|
|
79
|
+
}>
|
|
80
|
+
}>
|
|
81
|
+
|
|
82
|
+
type Placed = Readonly<{
|
|
83
|
+
channel: string
|
|
84
|
+
cells: readonly (readonly number[])[]
|
|
85
|
+
}>
|
|
86
|
+
|
|
87
|
+
interface DeleteOptions {
|
|
88
|
+
/** The api-server origin. */
|
|
89
|
+
readonly server: string
|
|
90
|
+
/** The owner's `wsk_` key. */
|
|
91
|
+
readonly apiKey: string
|
|
92
|
+
readonly slug: string
|
|
93
|
+
/** Skip the typed slug (`--yes`). */
|
|
94
|
+
readonly yes: boolean
|
|
95
|
+
/** Print the prompt and read one typed line; undefined when none comes. */
|
|
96
|
+
readonly ask: (prompt: string) => Promise<string | undefined>
|
|
97
|
+
readonly report: (line: string) => void
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function jsonOf(text: string): unknown {
|
|
101
|
+
try {
|
|
102
|
+
const value: unknown = JSON.parse(text)
|
|
103
|
+
return value
|
|
104
|
+
} catch {
|
|
105
|
+
return undefined
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function reasonOf(body: unknown): string {
|
|
110
|
+
const parsed = safeParse(ErrorSchema, body)
|
|
111
|
+
return parsed.success ? parsed.output.error : 'not an api-server reply'
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** One delete call: its status and parsed body. */
|
|
115
|
+
async function call(
|
|
116
|
+
options: DeleteOptions,
|
|
117
|
+
route: string,
|
|
118
|
+
body?: unknown,
|
|
119
|
+
): Promise<Readonly<{ status: number; body: unknown }>> {
|
|
120
|
+
const slug = encodeURIComponent(options.slug)
|
|
121
|
+
const reply = await fetch(
|
|
122
|
+
new URL(`/api/shards/${slug}/${route}`, options.server),
|
|
123
|
+
{
|
|
124
|
+
method: 'POST',
|
|
125
|
+
headers: {
|
|
126
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
127
|
+
'content-type': 'application/json',
|
|
128
|
+
},
|
|
129
|
+
body: JSON.stringify(body ?? {}),
|
|
130
|
+
},
|
|
131
|
+
)
|
|
132
|
+
return { status: reply.status, body: jsonOf(await reply.text()) }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function startDelete(options: DeleteOptions): Promise<Started> {
|
|
136
|
+
const reply = await call(options, 'delete')
|
|
137
|
+
const parsed = safeParse(StartSchema, reply.body)
|
|
138
|
+
if (reply.status !== OK || !parsed.success) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`delete ${options.slug}: start answered ${String(reply.status)}: ${reasonOf(reply.body)}`,
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
return parsed.output
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function listed(names: readonly string[]): string {
|
|
147
|
+
return names.length === FIRST ? 'none' : names.join(', ')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Each grid cell placing the slug: `staging [2, 3]`. */
|
|
151
|
+
function gridCells(grid: readonly Placed[] | undefined): readonly string[] {
|
|
152
|
+
return (grid ?? []).flatMap((row: Placed): string[] =>
|
|
153
|
+
row.cells.map(
|
|
154
|
+
(cell: readonly number[]): string =>
|
|
155
|
+
`${row.channel} [${cell.join(', ')}]`,
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** What start found, in the author's words. */
|
|
161
|
+
function summaryLines(slug: string, started: Started): readonly string[] {
|
|
162
|
+
const { summary } = started
|
|
163
|
+
const versions = summary.versions.map(
|
|
164
|
+
(row: Readonly<{ version: string; hash: string }>): string =>
|
|
165
|
+
`${row.version} ${row.hash.slice(FIRST, SHORT_HASH)}`,
|
|
166
|
+
)
|
|
167
|
+
const channels = summary.channels.map(
|
|
168
|
+
(row: Readonly<{ channel: string }>): string => row.channel,
|
|
169
|
+
)
|
|
170
|
+
return [
|
|
171
|
+
`delete ${slug}: ${String(versions.length)} versions (${listed(versions)})`,
|
|
172
|
+
`channels pointing at it: ${listed(channels)}`,
|
|
173
|
+
`grid cells placing it: ${listed(gridCells(summary.grid))}`,
|
|
174
|
+
...(summary.note === undefined ? [] : [summary.note]),
|
|
175
|
+
...(summary.deleted === true
|
|
176
|
+
? [`${slug} is deleted already: finalize changes nothing`]
|
|
177
|
+
: []),
|
|
178
|
+
`the confirm token lasts until ${started.expiresAt} (10 minutes)`,
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** What finalize did, in the author's words; the last line says deleted. */
|
|
183
|
+
function doneLines(slug: string, done: Finalized): readonly string[] {
|
|
184
|
+
const cells =
|
|
185
|
+
done.cells === undefined
|
|
186
|
+
? ''
|
|
187
|
+
: `; grid cells dropped on: ${listed(done.cells)}`
|
|
188
|
+
const freed =
|
|
189
|
+
done.freed === undefined
|
|
190
|
+
? ''
|
|
191
|
+
: `; grid cell freed: ${done.freed === null ? 'none' : `[${done.freed.join(', ')}]`}`
|
|
192
|
+
return [
|
|
193
|
+
`pointers dropped on: ${listed(done.channels)}; solo placements dropped on: ${listed(done.placements)}${cells}${freed}`,
|
|
194
|
+
`deleted ${slug} at ${done.deletedAt}: hidden from the catalogue and every grid`,
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function finalizeDelete(
|
|
199
|
+
options: DeleteOptions,
|
|
200
|
+
confirm: string,
|
|
201
|
+
): Promise<readonly string[]> {
|
|
202
|
+
const { slug } = options
|
|
203
|
+
const reply = await call(options, 'delete/finalize', { confirm })
|
|
204
|
+
const parsed = safeParse(FinalizeSchema, reply.body)
|
|
205
|
+
const reason = reasonOf(reply.body)
|
|
206
|
+
if (reply.status === CONFLICT && reason.includes('confirm token')) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`delete ${slug}: finalize answered 409: ${reason}. Nothing was deleted; start again with wildshard delete ${slug}`,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
if (reply.status !== OK || !parsed.success) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
`delete ${slug}: finalize answered ${String(reply.status)}: ${reason}`,
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
return doneLines(slug, parsed.output)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Why the author's answer does not confirm the delete, if it doesn't. */
|
|
220
|
+
async function notConfirmed(
|
|
221
|
+
options: DeleteOptions,
|
|
222
|
+
): Promise<string | undefined> {
|
|
223
|
+
const { slug } = options
|
|
224
|
+
if (options.yes) {
|
|
225
|
+
return undefined
|
|
226
|
+
}
|
|
227
|
+
const typed = await options.ask(
|
|
228
|
+
`type ${slug} to delete it (anything else keeps it): `,
|
|
229
|
+
)
|
|
230
|
+
if (typed?.trim() === slug) {
|
|
231
|
+
return undefined
|
|
232
|
+
}
|
|
233
|
+
const what = typed === undefined ? 'nothing' : `"${typed.trim()}"`
|
|
234
|
+
return `delete ${slug} not confirmed: you typed ${what}, not ${slug}, so nothing was deleted`
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Start, show the summary, take the typed slug (unless `yes`), finalize.
|
|
239
|
+
* Undefined once deleted, or why nothing was deleted.
|
|
240
|
+
*/
|
|
241
|
+
async function deleteShard(
|
|
242
|
+
options: DeleteOptions,
|
|
243
|
+
): Promise<string | undefined> {
|
|
244
|
+
const started = await startDelete(options)
|
|
245
|
+
for (const line of summaryLines(options.slug, started)) {
|
|
246
|
+
options.report(line)
|
|
247
|
+
}
|
|
248
|
+
const refused = await notConfirmed(options)
|
|
249
|
+
if (refused !== undefined) {
|
|
250
|
+
return refused
|
|
251
|
+
}
|
|
252
|
+
for (const line of await finalizeDelete(options, started.confirm)) {
|
|
253
|
+
options.report(line)
|
|
254
|
+
}
|
|
255
|
+
return undefined
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export { type DeleteOptions, deleteShard }
|
package/src/cli/help.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { DEFAULT_BROTLI_LEVEL } from './upload/compress.ts'
|
|
2
|
+
|
|
3
|
+
// SHARD-AUTHORING SA2 (J317): every verb's help in the glossary's words (meta
|
|
4
|
+
// docs/architecture/README.md § Glossary): shard source, shard file, build
|
|
5
|
+
// (which bakes), check, hero, prepare, upload, channel, flip. Never product,
|
|
6
|
+
// publish (for an upload), promote, cook, head or tarball; `pack` only as the
|
|
7
|
+
// deprecated alias below. Flag names stay as they are, retired word or not:
|
|
8
|
+
// renaming one breaks scripts. help.test.ts greps every verb's help for the
|
|
9
|
+
// retired words. bin/wildshard.mjs prints `wildshard <verb> --help` from here.
|
|
10
|
+
|
|
11
|
+
const LEVEL = String(DEFAULT_BROTLI_LEVEL)
|
|
12
|
+
|
|
13
|
+
/** The deprecated alias's whole entry: the one place help may say pack. */
|
|
14
|
+
const PACK_ALIAS = `pack <folder> [--out <file>]
|
|
15
|
+
Deprecated alias: wildshard build <folder> [file]`
|
|
16
|
+
|
|
17
|
+
/** Each verb's entry: its usage lines, then what it does, indented. */
|
|
18
|
+
const VERBS: Readonly<Record<string, string>> = {
|
|
19
|
+
new: `new <dir> [slug] [--template sdk|blender] [--empty]
|
|
20
|
+
Start a shard repo in <dir>, a folder that does not
|
|
21
|
+
exist yet, with its shard source at src/ (slug: the
|
|
22
|
+
folder's name unless given). --template sdk (the
|
|
23
|
+
default) copies the reference world; --template
|
|
24
|
+
blender copies the hand-written Blender template
|
|
25
|
+
(a shard file folder, no code). --empty writes a
|
|
26
|
+
bare shard source instead`,
|
|
27
|
+
dev: `dev <source> [port]
|
|
28
|
+
Serve the shard source on localhost (port 0, the
|
|
29
|
+
default, picks a free one) and build it again on
|
|
30
|
+
every edit`,
|
|
31
|
+
check: `check <source> [folder] [--json]
|
|
32
|
+
Lint, build, validate, prove (with the shard
|
|
33
|
+
source's proof.json) and read the report card, then
|
|
34
|
+
give one verdict. --json prints only the verdict
|
|
35
|
+
document: { version, verdict, project, output, ms,
|
|
36
|
+
steps: [{ name, status, ms, note? }], refusals:
|
|
37
|
+
[{ step, rule, message, fix, guide, file? }],
|
|
38
|
+
warnings: [the same] }. Every refusal names its
|
|
39
|
+
rule, a fix and its GUIDE.md section. A warning (an
|
|
40
|
+
unprepared draft) does not fail the verdict. Exits 1
|
|
41
|
+
on fail`,
|
|
42
|
+
hero: `hero <source> --base <served-build-url>
|
|
43
|
+
Capture the shard's hero (thumb, portrait,
|
|
44
|
+
landscape) in headless Chromium from a served build
|
|
45
|
+
of this candidate, and stamp hero.json with its
|
|
46
|
+
content
|
|
47
|
+
hero <source> --stamp-existing
|
|
48
|
+
No capture: stamp the hero images already in the
|
|
49
|
+
shard source as current. WARNING: use it ONLY when
|
|
50
|
+
those images show the current content; a wrong
|
|
51
|
+
stamp hides a stale hero from the cut`,
|
|
52
|
+
upload: `upload <file> --channel staging|prod [--server <url>]
|
|
53
|
+
[--level <n>] [--version <X.Y.Z>] [--commit <sha>] [--no-place]
|
|
54
|
+
Check a shard file (an unprepared draft, sdk 0.2,
|
|
55
|
+
is refused before anything is sent), compress it
|
|
56
|
+
(Brotli level <n>, default ${LEVEL}), sign it with the
|
|
57
|
+
creator key and upload it to the API. The channel
|
|
58
|
+
is required: staging flips the preview and staging
|
|
59
|
+
pointers, prod flips all three (production too).
|
|
60
|
+
Sends the shard source version (default: the shard
|
|
61
|
+
source's package.json version), the shard source
|
|
62
|
+
commit (default: the checked-out commit of a clean
|
|
63
|
+
tree) and the sdk, engine and shard-format releases
|
|
64
|
+
it was built with. Refuses a hero unchanged since
|
|
65
|
+
the shard's newest upload (run hero first). Prints
|
|
66
|
+
the API's version, format version and migrations,
|
|
67
|
+
then the grid: the shard's cell ("placed at (0,3)
|
|
68
|
+
on preview, staging"), "grid full, not placed",
|
|
69
|
+
"not placed (--no-place)", or "no new cell" while
|
|
70
|
+
the API's placement is off or past the shard's
|
|
71
|
+
first upload; then the /slug/<slug> link on each
|
|
72
|
+
channel the upload moved (that page is not built
|
|
73
|
+
yet). --no-place takes no grid cell, for a proof
|
|
74
|
+
upload. Only a shard's first upload takes a cell,
|
|
75
|
+
so one uploaded with --no-place never gets one; on
|
|
76
|
+
a later upload --no-place leaves the grid as it
|
|
77
|
+
was, so a prod upload adds no production cell.
|
|
78
|
+
Sends your account key (WILDSHARD_API_KEY, else
|
|
79
|
+
the file wildshard account saved; with neither it
|
|
80
|
+
refuses before anything is sent). Reads
|
|
81
|
+
WILDSHARD_API_URL when --server is absent,
|
|
82
|
+
WILDSHARD_CREATOR_PRIVATE_KEY, and
|
|
83
|
+
VERCEL_AUTOMATION_BYPASS_SECRET for a protected
|
|
84
|
+
preview`,
|
|
85
|
+
account: `account <email> [--server <url>] [--force]
|
|
86
|
+
Make your Wildshard account (no mail is sent) and
|
|
87
|
+
save its key to ~/.config/wildshard/sharddev-key
|
|
88
|
+
(mode 600) for upload to send. The API shows a key
|
|
89
|
+
once: an email that has an account is refused, and
|
|
90
|
+
a lost key needs an operator reset. A saved key is
|
|
91
|
+
never replaced without --force. Reads
|
|
92
|
+
WILDSHARD_API_URL when --server is absent`,
|
|
93
|
+
whoami: `whoami [--server <url>]
|
|
94
|
+
Print where upload's account key comes from
|
|
95
|
+
(WILDSHARD_API_KEY, else the key file) and its
|
|
96
|
+
first characters, never the whole key, then the
|
|
97
|
+
key's account: its email and how many slugs it
|
|
98
|
+
owns. Reads WILDSHARD_API_URL when --server is
|
|
99
|
+
absent`,
|
|
100
|
+
delete: `delete <slug> [--yes] [--server <url>]
|
|
101
|
+
Delete your shard: it leaves the catalogue, every
|
|
102
|
+
channel and the grid at once. Prints what it would
|
|
103
|
+
delete (its versions, the channels pointing at it,
|
|
104
|
+
and whether a signed release still plays it until
|
|
105
|
+
its next release), then asks you to type the slug;
|
|
106
|
+
anything else deletes nothing. The confirmation
|
|
107
|
+
lasts 10 minutes. --yes skips typing, for scripts.
|
|
108
|
+
Sends your account key, as upload does; only the
|
|
109
|
+
key that uploaded the shard deletes it. Reads
|
|
110
|
+
WILDSHARD_API_URL when --server is absent`,
|
|
111
|
+
build: `build <source> [folder] [--shardfile-only | --folder-only]
|
|
112
|
+
[--no-placeholders] [--output=<slug>]
|
|
113
|
+
Build the shard source: bake it into a shard file
|
|
114
|
+
folder (default <source>/public/shardfiles/<slug>),
|
|
115
|
+
then write the shard file <slug>.shardfile beside
|
|
116
|
+
it and run shard-format's checks on it. Refuses a
|
|
117
|
+
shard whose captured hero is older than its content
|
|
118
|
+
(hero.json) and prints the audio rules. What it
|
|
119
|
+
writes is a draft (sdk 0.2): it warns that the API
|
|
120
|
+
and upload refuse a draft until prepare makes it
|
|
121
|
+
sdk 0.3. --shardfile-only skips the web client;
|
|
122
|
+
--folder-only also skips the shard file
|
|
123
|
+
build <folder> [file]
|
|
124
|
+
Write the shard file of a built shard file folder
|
|
125
|
+
(default <slug>.shardfile beside it), with the same
|
|
126
|
+
checks
|
|
127
|
+
build <source> --behaviour-only [--check]
|
|
128
|
+
Build only the shard source's native behaviour
|
|
129
|
+
outputs; --check refuses stale ones and writes
|
|
130
|
+
nothing`,
|
|
131
|
+
prepare: `prepare <folder> --base <exact-preview-url>
|
|
132
|
+
Record the shard file folder in phone WebKit against
|
|
133
|
+
an exact engine preview and write its author
|
|
134
|
+
preparation (the fence, the fence policy and the
|
|
135
|
+
recorded programs): the draft becomes sdk 0.3, the
|
|
136
|
+
only kind upload sends. Then write its shard file
|
|
137
|
+
with build <folder>`,
|
|
138
|
+
validate: `validate <source | folder | shard.json>
|
|
139
|
+
Validate a shard source, or a built shard file
|
|
140
|
+
folder with shard-format's checks, and run it
|
|
141
|
+
headlessly against its budgets`,
|
|
142
|
+
prove: `prove <source | folder | shard.json> <proof.json>
|
|
143
|
+
Play the proof tape headlessly and print what
|
|
144
|
+
happened as JSON`,
|
|
145
|
+
synth: `synth <source>
|
|
146
|
+
Run shard.config.ts's scene and identity exports in
|
|
147
|
+
Node and write the scene they describe as data`,
|
|
148
|
+
schema: `schema [list|shardfile|<root>] [JSON-pointer]
|
|
149
|
+
Print the JSON Schema of shard.json (\`shardfile\`) or
|
|
150
|
+
of one section (<root>), or of the part at a JSON
|
|
151
|
+
pointer; list names every root`,
|
|
152
|
+
serve: `serve [--port <n>] Start the sharddev server on localhost`,
|
|
153
|
+
'build-shards': `build-shards [--shard=<slug>[,<slug>]] [--reuse]
|
|
154
|
+
Build every shard source under src/shards into its
|
|
155
|
+
shard file folders (one per output) under out/.
|
|
156
|
+
--shard builds only those outputs; --reuse keeps a
|
|
157
|
+
folder whose inputs are unchanged`,
|
|
158
|
+
pack: PACK_ALIAS,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Indent every line of a verb's entry for the full help. */
|
|
162
|
+
function indented(entry: string): string {
|
|
163
|
+
return entry
|
|
164
|
+
.split('\n')
|
|
165
|
+
.map((line: string): string => (line.startsWith(' ') ? line : ` ${line}`))
|
|
166
|
+
.join('\n')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const USAGE = `Usage: wildshard <command> [options]
|
|
170
|
+
|
|
171
|
+
The loop: new, dev, check, hero, upload. A shard source builds a shard file;
|
|
172
|
+
upload sends it to the API for a channel.
|
|
173
|
+
|
|
174
|
+
Commands:
|
|
175
|
+
${Object.values(VERBS)
|
|
176
|
+
.map((entry: string): string => indented(entry))
|
|
177
|
+
.join('\n')}
|
|
178
|
+
|
|
179
|
+
Options:
|
|
180
|
+
--version Print the sdk, engine, shard-format and three
|
|
181
|
+
versions (after upload: the shard source version)
|
|
182
|
+
--help Print this help (after a command: that command's)
|
|
183
|
+
|
|
184
|
+
Also installed as \`sharddev\`. wildshard help <command> prints one command.
|
|
185
|
+
`
|
|
186
|
+
|
|
187
|
+
/** The verbs help knows, in the order the full help lists them. */
|
|
188
|
+
const HELP_VERBS: readonly string[] = Object.keys(VERBS)
|
|
189
|
+
|
|
190
|
+
/** One verb's help, or undefined for a verb help does not know. */
|
|
191
|
+
function verbHelp(verb: string): string | undefined {
|
|
192
|
+
const entry = Object.hasOwn(VERBS, verb) ? VERBS[verb] : undefined
|
|
193
|
+
return entry === undefined ? undefined : `Usage: wildshard ${entry}\n`
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { HELP_VERBS, PACK_ALIAS, USAGE, verbHelp }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { access } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
MANIFEST,
|
|
6
|
+
NONE,
|
|
7
|
+
STAMP,
|
|
8
|
+
heroSlotFiles,
|
|
9
|
+
heroState,
|
|
10
|
+
isMissing,
|
|
11
|
+
readJson,
|
|
12
|
+
writeHeroStamp,
|
|
13
|
+
} from './stamp.ts'
|
|
14
|
+
|
|
15
|
+
// `wildshard hero <shard> --stamp-existing`: a shard repo gains the hero check
|
|
16
|
+
// (stamp.ts) when it bumps its sharddev pin, with curated heroes and no stamp.
|
|
17
|
+
// Recapturing from the spawn view would put a plain shot over good art, so
|
|
18
|
+
// this stamps the files already there, with no capture. Only right when those
|
|
19
|
+
// images show the current content. A stamp whose content no longer matches is
|
|
20
|
+
// refused: there the world has moved past the picture, and only a capture fixes
|
|
21
|
+
// it.
|
|
22
|
+
|
|
23
|
+
const ADOPTED =
|
|
24
|
+
'stamp-existing: the hero files already in the shard, adopted without a capture'
|
|
25
|
+
|
|
26
|
+
interface Adopted {
|
|
27
|
+
/** False when the stamp was already current and nothing was written. */
|
|
28
|
+
readonly written: boolean
|
|
29
|
+
readonly content: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function exists(file: string): Promise<boolean> {
|
|
33
|
+
try {
|
|
34
|
+
await access(file)
|
|
35
|
+
return true
|
|
36
|
+
} catch (error: unknown) {
|
|
37
|
+
if (isMissing(error)) {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
throw error
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Refuse a generated card or a card file that is not on disk. */
|
|
45
|
+
async function assertCardFiles(shard: string): Promise<void> {
|
|
46
|
+
const files = Object.entries(await heroSlotFiles(shard))
|
|
47
|
+
if (files.length === NONE) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`${path.join(shard, MANIFEST)}: the card is generated (data: urls), so there are no hero files to stamp`,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
const present = await Promise.all(
|
|
53
|
+
files.map(
|
|
54
|
+
async ([, file]: readonly [string, string]): Promise<boolean> =>
|
|
55
|
+
await exists(file),
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
const gone = files.filter(
|
|
59
|
+
(_entry: unknown, at: number): boolean => present[at] !== true,
|
|
60
|
+
)
|
|
61
|
+
if (gone.length > NONE) {
|
|
62
|
+
const named = gone.map(
|
|
63
|
+
([slot, file]: readonly [string, string]): string =>
|
|
64
|
+
`card.${slot} (${path.relative(shard, file).split(path.sep).join('/')})`,
|
|
65
|
+
)
|
|
66
|
+
throw new Error(`${named.join(', ')} not there; nothing stamped`)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Refuse a hero.json that does not parse: it may declare a camera. */
|
|
71
|
+
async function assertStampReadable(shard: string): Promise<void> {
|
|
72
|
+
try {
|
|
73
|
+
await readJson(path.join(shard, STAMP))
|
|
74
|
+
} catch (error: unknown) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`${path.join(shard, STAMP)} does not parse; fix it by hand, nothing stamped`,
|
|
77
|
+
{ cause: error },
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Stamp the hero files on disk as showing the content now, keeping a
|
|
84
|
+
* declared camera. Only an unstamped hero, or hand-swapped hero files over
|
|
85
|
+
* unchanged content, is stamped; a current stamp is left alone.
|
|
86
|
+
*/
|
|
87
|
+
async function stampExistingHero(shard: string): Promise<Adopted> {
|
|
88
|
+
await assertCardFiles(shard)
|
|
89
|
+
await assertStampReadable(shard)
|
|
90
|
+
const hero = await heroState(shard)
|
|
91
|
+
if (hero.state === 'fresh') {
|
|
92
|
+
return { written: false, content: hero.content }
|
|
93
|
+
}
|
|
94
|
+
if (hero.stamped !== undefined && hero.stamped !== hero.content) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`the hero of ${path.basename(shard)} was stamped for other content (captured ${hero.captured ?? 'at an unknown time'}); the world has changed since, so only a capture fixes it, nothing stamped`,
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
const stamp = await writeHeroStamp(shard, { base: ADOPTED })
|
|
100
|
+
return { written: true, content: stamp.content }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { stampExistingHero }
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { readdir } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
MANIFEST,
|
|
6
|
+
NONE,
|
|
7
|
+
STAMP,
|
|
8
|
+
UNKNOWN_TIME,
|
|
9
|
+
cardHashes,
|
|
10
|
+
heroState,
|
|
11
|
+
readJson,
|
|
12
|
+
} from './stamp.ts'
|
|
13
|
+
|
|
14
|
+
import type { HeroState } from './stamp.ts'
|
|
15
|
+
|
|
16
|
+
// The cut's hero check (`wildshard build`, as it writes the shard file, SA3): see stamp.ts for what the stamp
|
|
17
|
+
// records. Jake, 2026-11-12 17:14 Cancún: "you have to update the hero
|
|
18
|
+
// images for the templates."
|
|
19
|
+
|
|
20
|
+
const CAPTURE = 'pnpm exec wildshard hero'
|
|
21
|
+
|
|
22
|
+
/** The shard source as the author names it: `src` in a single-shard repo (J317), else `src/shards/<name>`. */
|
|
23
|
+
function sourceOperand(shard: string): string {
|
|
24
|
+
return path.basename(shard) === 'src'
|
|
25
|
+
? 'src'
|
|
26
|
+
: `src/shards/${path.basename(shard)}`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The capture command a refusal names, run from the shard project root. */
|
|
30
|
+
function captureCommand(shard: string): string {
|
|
31
|
+
return `${CAPTURE} ${sourceOperand(shard)} --base <served-build-url>`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The no-capture stamp, for hero files that already show this content. */
|
|
35
|
+
function stampExistingCommand(shard: string): string {
|
|
36
|
+
return `${CAPTURE} ${sourceOperand(shard)} --stamp-existing`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The source shard folder of a product built at `<root>/out/<name>`. */
|
|
40
|
+
function sourceShard(product: string): string {
|
|
41
|
+
const resolved = path.resolve(product)
|
|
42
|
+
const root = path.dirname(path.dirname(resolved))
|
|
43
|
+
return path.join(root, 'src', 'shards', path.basename(resolved))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Every file name in the product, without its extension: blobs are named by hash. */
|
|
47
|
+
async function productHashes(product: string): Promise<ReadonlySet<string>> {
|
|
48
|
+
const entries = await readdir(product, { recursive: true })
|
|
49
|
+
return new Set(entries.map((entry: string): string => path.parse(entry).name))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Refuse a product built before the stamped hero was captured. */
|
|
53
|
+
async function assertProductCarries(
|
|
54
|
+
product: string,
|
|
55
|
+
shard: string,
|
|
56
|
+
): Promise<void> {
|
|
57
|
+
const card = await cardHashes(shard)
|
|
58
|
+
const held = await productHashes(product)
|
|
59
|
+
const missing = Object.keys(card).filter(
|
|
60
|
+
(name: string): boolean => !held.has(card[name] ?? ''),
|
|
61
|
+
)
|
|
62
|
+
if (missing.length > NONE) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`the shard file folder ${product} does not carry the captured hero (${missing.join(', ')}); it was built before the capture: rebuild it (pnpm build:shards), then build its shard file`,
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Why a hero that is neither fresh nor generated stops the cut, and the fix. */
|
|
70
|
+
function refusal(shard: string, hero: HeroState): string {
|
|
71
|
+
const name = path.basename(shard)
|
|
72
|
+
const capture = `serve this candidate in an engine build, then capture it: ${captureCommand(shard)}`
|
|
73
|
+
const adopt = `; or, only if the images already there show this content, stamp them with no capture: ${stampExistingCommand(shard)}`
|
|
74
|
+
if (hero.state === 'unstamped') {
|
|
75
|
+
return `the hero of ${name} has no ${STAMP} stamp, so nothing says it shows this content; ${capture}${adopt}`
|
|
76
|
+
}
|
|
77
|
+
const captured = hero.captured ?? UNKNOWN_TIME
|
|
78
|
+
return hero.stamped === hero.content
|
|
79
|
+
? `the hero files of ${name} are not the ones stamped (captured ${captured}), though the content is unchanged; ${capture}${adopt}`
|
|
80
|
+
: `the hero of ${name} is older than its content (captured ${captured}); ${capture}`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The cut's check. A built product lives at `<root>/out/<name>` and its
|
|
85
|
+
* source at `<root>/src/shards/<name>`. Throws for a stale or unstamped
|
|
86
|
+
* hero; reports and passes a generated card or a product with no source.
|
|
87
|
+
*/
|
|
88
|
+
async function assertHeroCurrent(
|
|
89
|
+
product: string,
|
|
90
|
+
report: (line: string) => void,
|
|
91
|
+
source?: string,
|
|
92
|
+
): Promise<void> {
|
|
93
|
+
// SA3: `build` names the project it built; a bare folder is read by layout.
|
|
94
|
+
const shard = source ?? sourceShard(product)
|
|
95
|
+
if ((await readJson(path.join(shard, MANIFEST))) === undefined) {
|
|
96
|
+
report(`hero: no source shard with a ${MANIFEST} at ${shard}; not checked`)
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
const hero = await heroState(shard)
|
|
100
|
+
if (hero.state === 'fresh') {
|
|
101
|
+
await assertProductCarries(product, shard)
|
|
102
|
+
report(`hero: current (captured ${hero.captured ?? UNKNOWN_TIME})`)
|
|
103
|
+
} else if (hero.state === 'generated') {
|
|
104
|
+
report(
|
|
105
|
+
`hero: generated card, no captured hero; capture one: ${captureCommand(shard)}`,
|
|
106
|
+
)
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error(refusal(shard, hero))
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { assertHeroCurrent }
|