@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,396 @@
|
|
|
1
|
+
// DEV-SPEED DS12 (J221, J240): `node scripts/worktree.mjs new <slug>` makes a plan worktree at
|
|
2
|
+
// <canonical>/.worktrees/<slug> on plan/<slug> from origin/main, ready to work in and land from.
|
|
3
|
+
//
|
|
4
|
+
// 1. a short per-repo setup lock, then `git fetch origin main`, a fast-forward of the canonical checkout's main when
|
|
5
|
+
// it is clean and only behind (followMain: never a reset), and `git worktree add --no-checkout`;
|
|
6
|
+
// 2. the tracked tree: a file whose blob and mode match a clean regular file of the canonical checkout, with no
|
|
7
|
+
// checkout conversion (filter, eol, text, ident, encoding), is an APFS clone of it (copy-on-write, no new
|
|
8
|
+
// blocks); every clone is then hashed raw against its blob and mode-checked, and a mismatch is deleted; git
|
|
9
|
+
// writes the rest; `git status` must then be clean and the hooks live, or setup takes its worktree back;
|
|
10
|
+
// 3. `pnpm install --frozen-lockfile --offline`: pnpm's store, cloned, not downloaded;
|
|
11
|
+
// 4. `pnpm pins` when the repo has that script (shard products from ~/.cache/wildshard/pins);
|
|
12
|
+
// 5. names the herdr pane (inside herdr only) and prints the land steps.
|
|
13
|
+
// Before step 1 adds anything, meta REPO-DISK DK9 (Q41): it refuses when the repo's volume has under MIN_FREE_GIB
|
|
14
|
+
// free or the repo already has MAX_WORKTREES live worktrees under .worktrees/, and names the oldest parked one.
|
|
15
|
+
// WS_WORKTREE_FREE_GIB stands in for the measured free GiB (tests); setting it is a deliberate override.
|
|
16
|
+
//
|
|
17
|
+
// Never copied: .env*, tmp/, .review/, .cache/, browser profiles, leases, ports, push proofs; the worktree gets
|
|
18
|
+
// only tracked files and its own install. Each step's seconds go to <worktree>/tmp/worktree-setup.json and, with
|
|
19
|
+
// WS_LANE_NAME set, one line in ~/.cache/wildshard/lane-receipts.log. Removal is DS13's reaper: `reap`
|
|
20
|
+
// (scripts/worktree-reap.mjs) removes landed, clean, idle worktrees with their branches, local and on origin.
|
|
21
|
+
import {execFileSync,spawn,spawnSync} from 'node:child_process';
|
|
22
|
+
import {randomBytes} from 'node:crypto';
|
|
23
|
+
import {appendFileSync,existsSync,linkSync,lstatSync,mkdirSync,readFileSync,realpathSync,rmSync,statSync,statfsSync,unlinkSync,writeFileSync} from 'node:fs';
|
|
24
|
+
import {homedir} from 'node:os';
|
|
25
|
+
import {basename,dirname,join,resolve} from 'node:path';
|
|
26
|
+
import {pathToFileURL} from 'node:url';
|
|
27
|
+
import {WORKTREES} from './worktree-ignore.mjs';
|
|
28
|
+
import {lastActivity,linkedWorktrees,onMain,parseReapArgs,reap} from './worktree-reap.mjs';
|
|
29
|
+
|
|
30
|
+
export const SLUG=/^[a-z0-9][a-z0-9._-]{0,63}$/u;
|
|
31
|
+
const REGULAR=/^100(?:644|755)$/u;
|
|
32
|
+
/** The hooks a commit and a push must run, when the repo tracks them. */
|
|
33
|
+
const HOOKS=['pre-commit','commit-msg','pre-push'];
|
|
34
|
+
/** A lock older than this is abandoned whatever its pid says (pids are reused); the locked part takes seconds. */
|
|
35
|
+
const STALE_MS=10*60_000;
|
|
36
|
+
// fclonefileat(2) per file, one process for the whole tree: Node's COPYFILE_FICLONE makes a full copy on macOS
|
|
37
|
+
// (measured: ATTR_CMNEXT_PRIVATESIZE equals the file size) and COPYFILE_FICLONE_FORCE fails with ENOSYS. Each source
|
|
38
|
+
// is opened without following a final symlink and must be a regular file, so a path swapped for a directory or a
|
|
39
|
+
// link is never cloned; every clone is hashed afterwards anyway. Reads source/target pairs, NUL-separated, on stdin.
|
|
40
|
+
const CLONEFILE=`import ctypes, os, stat, sys
|
|
41
|
+
libc = ctypes.CDLL(None, use_errno=True)
|
|
42
|
+
libc.fclonefileat.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint32]
|
|
43
|
+
AT_FDCWD = -2
|
|
44
|
+
parts = sys.stdin.buffer.read().split(b'\\0')[:-1]
|
|
45
|
+
for source, target in zip(parts[0::2], parts[1::2]):
|
|
46
|
+
fd = os.open(source, os.O_RDONLY | os.O_NOFOLLOW)
|
|
47
|
+
try:
|
|
48
|
+
if not stat.S_ISREG(os.fstat(fd).st_mode):
|
|
49
|
+
sys.exit(f'{source.decode()}: not a regular file')
|
|
50
|
+
if libc.fclonefileat(fd, AT_FDCWD, target, 0) != 0:
|
|
51
|
+
sys.exit(f'{target.decode()}: {os.strerror(ctypes.get_errno())}')
|
|
52
|
+
finally:
|
|
53
|
+
os.close(fd)`;
|
|
54
|
+
const USAGE='usage: node scripts/worktree.mjs new <slug> [--no-install] [--no-pins] [--no-herdr] [--no-clone]\n node scripts/worktree.mjs reap [--dry-run] [--grace=HOURS] [--no-remote]';
|
|
55
|
+
|
|
56
|
+
class StopError extends Error{name='StopError';}
|
|
57
|
+
|
|
58
|
+
/** @param {string} cwd @param {string[]} args @param {string} [input] */
|
|
59
|
+
const git=(cwd,args,input)=>execFileSync('git',args,{cwd,encoding:'utf8',input,stdio:['pipe','pipe','pipe'],maxBuffer:256<<20});
|
|
60
|
+
/** @param {string} cwd @param {string[]} args */
|
|
61
|
+
const tryGit=(cwd,args)=>spawnSync('git',args,{cwd,encoding:'utf8',maxBuffer:256<<20});
|
|
62
|
+
const nul=(/** @type {string} */ text)=>text.split('\0').filter(Boolean);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* GVS G10 (J230): run a store install only while no pnpm store prune runs. This install is announced in
|
|
66
|
+
* `store-users/` before it checks the prune's reservation (an exclusive flock its pnpm child inherits), and the prune
|
|
67
|
+
* takes that lock before it scans, so one of the two always sees the other (meta scripts/prune-store.sh). Paths can
|
|
68
|
+
* be moved for tests.
|
|
69
|
+
* @template T @param {NodeJS.ProcessEnv} env @param {string} what @param {() => T} fn @returns {T}
|
|
70
|
+
*/
|
|
71
|
+
export function withStoreUse(env,what,fn){
|
|
72
|
+
const users=env.WS_STORE_USERS??join(homedir(),'.cache/wildshard/store-users');
|
|
73
|
+
const reservation=env.WS_STORE_RESERVATION??join(homedir(),'.cache/wildshard/store-maintenance.lock');
|
|
74
|
+
mkdirSync(users,{recursive:true});
|
|
75
|
+
const mine=join(users,`${process.pid}.json`);
|
|
76
|
+
writeFileSync(mine,JSON.stringify({pid:process.pid,what,at:Date.now()}));
|
|
77
|
+
try{
|
|
78
|
+
// The prune holds an exclusive flock that its pnpm child inherits; Node has no flock, so Python probes it.
|
|
79
|
+
const probe=spawnSync('python3',['-c','import fcntl,sys\ntry:\n f=open(sys.argv[1],"rb")\nexcept OSError:\n sys.exit(0)\ntry:\n fcntl.flock(f,fcntl.LOCK_SH|fcntl.LOCK_NB)\nexcept BlockingIOError:\n sys.exit(3)\n',reservation],{encoding:'utf8'});
|
|
80
|
+
if(probe.status===3)throw new Error('worktree: a pnpm store prune is running (meta make prune); run this again when it ends');
|
|
81
|
+
if(probe.status!==0)throw new Error(`worktree: could not check the store prune reservation (${probe.error?.message??probe.stderr.trim()})`);
|
|
82
|
+
return fn();
|
|
83
|
+
}finally{rmSync(mine,{force:true});}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Meta REPO-DISK DK9 (DEV-SPEED Q41): at most this many live plan worktrees per repo. */
|
|
87
|
+
export const MAX_WORKTREES=6;
|
|
88
|
+
/** Meta REPO-DISK DK9: refuse a new worktree when the repo's volume has less free than this, in GiB. */
|
|
89
|
+
export const MIN_FREE_GIB=60;
|
|
90
|
+
|
|
91
|
+
/** Free GiB on the volume holding `path`; WS_WORKTREE_FREE_GIB fakes it (tests). @param {string} path @param {NodeJS.ProcessEnv} env */
|
|
92
|
+
export function freeGib(path,env){
|
|
93
|
+
const faked=env.WS_WORKTREE_FREE_GIB;
|
|
94
|
+
if(faked!==undefined&&faked!==''){
|
|
95
|
+
const value=Number(faked);
|
|
96
|
+
if(!Number.isFinite(value)||value<0)throw new StopError(`WS_WORKTREE_FREE_GIB=${faked} is not a number of GiB`);
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
const volume=statfsSync(path);
|
|
100
|
+
return Number(volume.bavail)*Number(volume.bsize)/2**30;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* DK9: why `worktree new` must not add another worktree here, or '' when it may. Live means a registered worktree
|
|
105
|
+
* whose folder exists under <canonical>/.worktrees/. A refusal names the oldest parked one (on plan/<slug>, landed:
|
|
106
|
+
* its tip on origin/main, and clean), by its last Git activity, and the reap command that frees it.
|
|
107
|
+
* @param {string} canonical @param {NodeJS.ProcessEnv} env @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
export function capRefusal(canonical,env){
|
|
110
|
+
const roots=new Set([join(canonical,WORKTREES),join(realpathSync(canonical),WORKTREES)]);
|
|
111
|
+
const live=linkedWorktrees(canonical).filter(tree=>roots.has(dirname(resolve(tree.path)))&&existsSync(tree.path));
|
|
112
|
+
const free=freeGib(canonical,env);
|
|
113
|
+
const full=live.length>=MAX_WORKTREES,low=free<MIN_FREE_GIB;
|
|
114
|
+
if(!full&&!low)return '';
|
|
115
|
+
const why=[
|
|
116
|
+
...(full?[`${basename(canonical)} already has ${String(live.length)} live worktrees under ${WORKTREES}/ (cap ${String(MAX_WORKTREES)})`]:[]),
|
|
117
|
+
...(low?[`only ${free.toFixed(1)} GiB free on the volume of ${canonical} (floor ${String(MIN_FREE_GIB)} GiB)`]:[]),
|
|
118
|
+
].join(', and ');
|
|
119
|
+
const parked=live.flatMap(tree=>{
|
|
120
|
+
const slug=basename(tree.path);
|
|
121
|
+
if(tree.branch!==`refs/heads/plan/${slug}`||!onMain(canonical,tree.head))return [];
|
|
122
|
+
// Activity first, and a status that takes no optional lock: a plain `git status` may rewrite the index and so
|
|
123
|
+
// make every worktree look active now.
|
|
124
|
+
const at=lastActivity(tree.path,git(tree.path,['rev-parse','--absolute-git-dir']).trim());
|
|
125
|
+
const dirty=spawnSync('git',['--no-optional-locks','status','--porcelain','--untracked-files=all'],{cwd:tree.path,encoding:'utf8',maxBuffer:64<<20});
|
|
126
|
+
if(dirty.status!==0||dirty.stdout.trim()!=='')return [];
|
|
127
|
+
return [{slug,at}];
|
|
128
|
+
}).sort((a,b)=>a.at-b.at);
|
|
129
|
+
const oldest=parked[0];
|
|
130
|
+
const hint=oldest===undefined
|
|
131
|
+
?`none of them is parked (landed on origin/main and clean): land one, or remove one by hand`
|
|
132
|
+
:`the oldest parked worktree is ${WORKTREES}/${oldest.slug} (landed, clean, idle ${((Date.now()-oldest.at)/3_600_000).toFixed(1)} h); \`node scripts/worktree.mjs reap\` frees it once idle 24 h with no process inside, or land and remove one by hand`;
|
|
133
|
+
return `${why}; ${hint}`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** @param {string[]} argv */
|
|
137
|
+
export function parseArgs(argv){
|
|
138
|
+
const [command,slug,...rest]=argv;
|
|
139
|
+
if(command!=='new'||slug===undefined)throw new StopError(USAGE);
|
|
140
|
+
if(!SLUG.test(slug))throw new StopError(`slug "${slug}" must match ${SLUG.source}`);
|
|
141
|
+
const flags=new Set(['--no-install','--no-pins','--no-herdr','--no-clone']);
|
|
142
|
+
const unknown=rest.filter(arg=>!flags.has(arg));
|
|
143
|
+
if(unknown.length>0)throw new StopError(`unknown option ${unknown.join(' ')}\n${USAGE}`);
|
|
144
|
+
return {slug,install:!rest.includes('--no-install'),pins:!rest.includes('--no-pins'),herdr:!rest.includes('--no-herdr'),clone:!rest.includes('--no-clone')};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The canonical checkout of the repo `cwd` is in: the main worktree, never a linked one. @param {string} cwd */
|
|
148
|
+
export function canonicalRoot(cwd){
|
|
149
|
+
const common=resolve(cwd,git(cwd,['rev-parse','--git-common-dir']).trim());
|
|
150
|
+
if(basename(common)!=='.git')throw new StopError(`${common} is not a checkout's .git (a bare repository has no canonical tree)`);
|
|
151
|
+
return dirname(common);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** `git ls-files -s -z` as path -> "<mode> <oid>". @param {string} cwd */
|
|
155
|
+
function stagedBlobs(cwd){
|
|
156
|
+
/** @type {Map<string,string>} */const blobs=new Map();
|
|
157
|
+
for(const row of nul(git(cwd,['ls-files','-s','-z']))){
|
|
158
|
+
const match=/^(\d{6}) ([0-9a-f]{40,64}) 0\t(.+)$/su.exec(row);
|
|
159
|
+
if(match!==null)blobs.set(match[3]??'',`${match[1]} ${match[2]}`);
|
|
160
|
+
}
|
|
161
|
+
return blobs;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Paths whose checkout would not write the raw blob, from the target's own attributes: a filter, an eol, a
|
|
165
|
+
* working-tree encoding, ident expansion, or text conversion when the config asks for CRLF.
|
|
166
|
+
* @param {string} tree @param {string[]} paths @returns {Set<string>} */
|
|
167
|
+
function convertedPaths(tree,paths){
|
|
168
|
+
const converted=new Set();
|
|
169
|
+
if(paths.length===0)return converted;
|
|
170
|
+
// --type=bool reads yes/1/TRUE as true; `input` is not a bool and converts nothing on checkout.
|
|
171
|
+
const crlf=tryGit(tree,['config','--type=bool','core.autocrlf']).stdout.trim()==='true'||tryGit(tree,['config','core.eol']).stdout.trim().toLowerCase()==='crlf';
|
|
172
|
+
const rows=nul(git(tree,['check-attr','--cached','-z','--stdin','filter','eol','text','ident','working-tree-encoding'],`${paths.join('\0')}\0`));
|
|
173
|
+
for(let index=0;index+2<rows.length;index+=3){
|
|
174
|
+
const path=rows[index]??'',attribute=rows[index+1],value=rows[index+2];
|
|
175
|
+
const plain=value==='unspecified'||value==='unset'||(attribute==='text'&&!crlf);
|
|
176
|
+
if(!plain||(attribute==='text'&&crlf&&value!=='unset'))converted.add(path);
|
|
177
|
+
}
|
|
178
|
+
return converted;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Clone into `tree` each tracked file the canonical checkout holds clean with the same blob and mode, then keep only
|
|
182
|
+
* clones whose raw bytes hash to their blob and whose mode matches. @param {string} canonical @param {string} tree
|
|
183
|
+
* @returns {number} files kept */
|
|
184
|
+
function cloneTrackedFiles(canonical,tree){
|
|
185
|
+
const source=stagedBlobs(canonical),target=stagedBlobs(tree);
|
|
186
|
+
// Hidden edits count as dirty: modified, deleted, staged, assume-unchanged (lowercase tag) or skip-worktree (S).
|
|
187
|
+
const dirty=new Set(nul(git(canonical,['ls-files','-z','--modified','--deleted'])));
|
|
188
|
+
for(const path of nul(git(canonical,['diff','--cached','--name-only','-z'])))dirty.add(path);
|
|
189
|
+
for(const row of nul(git(canonical,['ls-files','-z','-v'])))if(/^(?:[a-z]|S) /u.test(row))dirty.add(row.slice(2));
|
|
190
|
+
const candidates=[...target].filter(([path,blob])=>source.get(path)===blob&&!dirty.has(path)&®ULAR.test(blob.slice(0,6))).map(([path])=>path);
|
|
191
|
+
const converted=convertedPaths(tree,candidates);
|
|
192
|
+
/** @type {string[]} */const cloned=[];
|
|
193
|
+
/** @type {string[]} */const pairs=[];
|
|
194
|
+
for(const path of candidates){
|
|
195
|
+
// hash-object --stdin-paths is line-based: a name with a newline is left to git.
|
|
196
|
+
if(converted.has(path)||path.includes('\n'))continue;
|
|
197
|
+
try{if(!lstatSync(join(canonical,path)).isFile())continue;}catch{continue;}
|
|
198
|
+
mkdirSync(dirname(join(tree,path)),{recursive:true});
|
|
199
|
+
pairs.push(join(canonical,path),join(tree,path));
|
|
200
|
+
cloned.push(path);
|
|
201
|
+
}
|
|
202
|
+
if(pairs.length===0)return 0;
|
|
203
|
+
const result=spawnSync('python3',['-I','-c',CLONEFILE],{input:`${pairs.join('\0')}\0`,encoding:'utf8',maxBuffer:64<<20});
|
|
204
|
+
if(result.status!==0)process.stderr.write(`worktree: clone stopped early (${result.stderr.trim()===''?result.error?.message??'failed':result.stderr.trim()}); git writes the rest\n`);
|
|
205
|
+
// The raw bytes of every clone hash to its blob, and its mode is the index's; anything else is deleted for git.
|
|
206
|
+
// If the check itself fails, no clone is trusted: all of them go, and git writes every file.
|
|
207
|
+
let kept=0;
|
|
208
|
+
try{
|
|
209
|
+
const present=cloned.filter(path=>existsSync(join(tree,path)));
|
|
210
|
+
const hashes=present.length===0?[]:git(tree,['hash-object','--no-filters','--stdin-paths'],`${present.join('\n')}\n`).trim().split('\n');
|
|
211
|
+
if(hashes.length!==present.length)throw new Error(`hash-object returned ${String(hashes.length)} hashes for ${String(present.length)} files`);
|
|
212
|
+
present.forEach((path,index)=>{
|
|
213
|
+
const [mode,oid]=(target.get(path)??'').split(' '),stat=lstatSync(join(tree,path));
|
|
214
|
+
if(hashes[index]===oid&&stat.isFile()&&((stat.mode&0o100)!==0)===(mode==='100755'))kept++;
|
|
215
|
+
else rmSync(join(tree,path),{force:true});
|
|
216
|
+
});
|
|
217
|
+
}catch(error){
|
|
218
|
+
for(const path of cloned)rmSync(join(tree,path),{force:true});
|
|
219
|
+
process.stderr.write(`worktree: clone check failed (${error instanceof Error?error.message:String(error)}); git writes every file\n`);
|
|
220
|
+
return 0;
|
|
221
|
+
}
|
|
222
|
+
return kept;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Git states in which moving HEAD would break an operation someone is part way through. */
|
|
226
|
+
const BUSY_GIT=['index.lock','MERGE_HEAD','CHERRY_PICK_HEAD','REVERT_HEAD','BISECT_LOG','rebase-merge','rebase-apply','sequencer'];
|
|
227
|
+
|
|
228
|
+
/** Keep the canonical checkout on origin/main (Jake, 2026-11-10: "If the main checkout of the engine is stale, we
|
|
229
|
+
* definitely need to get it up to date"). A plain fast-forward when it is on main, clean and behind: no tracked edit,
|
|
230
|
+
* nothing staged, no commit origin/main lacks, and no merge, rebase, am, cherry-pick, revert, bisect or index lock in
|
|
231
|
+
* progress. `git merge --ff-only` itself refuses a dirty tree or diverged history, never overwrites an ignored or
|
|
232
|
+
* untracked file and never autostashes. A terminal or dev server sitting in the folder doesn't stop it (coordinator,
|
|
233
|
+
* 2026-11-11: that check skipped every land, mostly for stale preview servers). Anything else is one line saying why
|
|
234
|
+
* it was left alone, never a reset.
|
|
235
|
+
* @param {string} canonical @param {string} base origin/main @returns {string} what it did, for the step line */
|
|
236
|
+
export function followMain(canonical,base){
|
|
237
|
+
const branch=tryGit(canonical,['symbolic-ref','--quiet','HEAD']).stdout.trim();
|
|
238
|
+
if(branch!=='refs/heads/main')return `canonical not on main (${branch===''?'detached':branch}); left alone`;
|
|
239
|
+
const head=git(canonical,['rev-parse','HEAD']).trim();
|
|
240
|
+
if(head===base)return 'canonical main current';
|
|
241
|
+
const [ahead='0',behind='0']=git(canonical,['rev-list','--left-right','--count',`${head}...${base}`]).trim().split(/\s+/u);
|
|
242
|
+
if(ahead!=='0')return `CANONICAL MAIN DIVERGED: ${ahead} ahead, ${behind} behind origin/main; left alone, tell the coordinator`;
|
|
243
|
+
const leave=(/** @type {string} */ why)=>`canonical main ${behind} behind; ${why}; left alone`;
|
|
244
|
+
if(git(canonical,['status','--porcelain','--untracked-files=no']).trim()!=='')return leave('tracked edits');
|
|
245
|
+
const busy=BUSY_GIT.find(name=>existsSync(resolve(canonical,git(canonical,['rev-parse','--git-path',name]).trim())));
|
|
246
|
+
if(busy!==undefined)return leave(`git ${busy} in progress`);
|
|
247
|
+
// Last look right before the merge (J206 review): merge --ff-only would happily move another branch's HEAD.
|
|
248
|
+
if(tryGit(canonical,['symbolic-ref','--quiet','HEAD']).stdout.trim()!=='refs/heads/main'||git(canonical,['rev-parse','HEAD']).trim()!==head)return leave('HEAD moved during the check');
|
|
249
|
+
const merged=tryGit(canonical,['merge','--ff-only','--no-autostash','--no-overwrite-ignore','--quiet',base]);
|
|
250
|
+
if(merged.status!==0&&git(canonical,['rev-parse','HEAD']).trim()!==head)return `CANONICAL MAIN NEEDS A LOOK: the fast-forward failed after HEAD moved (${merged.stderr.trim().split('\n')[0]})`;
|
|
251
|
+
return merged.status===0?`canonical main fast-forwarded ${behind} commit(s)`:leave(`fast-forward refused (${merged.stderr.trim().split('\n')[0]})`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** The repo's hooks must be live in the worktree: core.hooksPath inside it, and each tracked hook executable there.
|
|
255
|
+
* @param {string} tree */
|
|
256
|
+
function checkHooks(tree){
|
|
257
|
+
const configured=tryGit(tree,['config','core.hooksPath']).stdout.trim();
|
|
258
|
+
const tracked=new Set(nul(git(tree,['ls-files','-z','--','.githooks'])));
|
|
259
|
+
if(tracked.size===0&&configured==='')return;
|
|
260
|
+
if(configured==='')throw new StopError(`core.hooksPath is unset but the repo tracks .githooks/; run git config core.hooksPath .githooks in the canonical checkout`);
|
|
261
|
+
const directory=resolve(tree,configured);
|
|
262
|
+
if(!directory.startsWith(`${tree}/`))throw new StopError(`core.hooksPath ${configured} resolves outside the worktree (${directory})`);
|
|
263
|
+
for(const hook of HOOKS){
|
|
264
|
+
const path=join(directory,hook);
|
|
265
|
+
if(!tracked.has(`.githooks/${hook}`))continue;
|
|
266
|
+
let mode=0;
|
|
267
|
+
try{mode=statSync(path).mode;}catch{/* Missing: refused below. */}
|
|
268
|
+
if((mode&0o111)===0)throw new StopError(`hook ${hook} is missing or not executable at ${path}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** A short per-repo setup lock in the shared Git dir. It is created with its owner already in it (a hard link of a
|
|
273
|
+
* written file) and released only by its owner. An abandoned lock is never taken over automatically, because no
|
|
274
|
+
* takeover is race-free without a process-held lock: the refusal names it and the command that clears it.
|
|
275
|
+
* @param {string} common @returns {() => void} */
|
|
276
|
+
function lock(common){
|
|
277
|
+
const path=join(common,'wildshard-worktree-setup.lock'),token=`${process.pid} ${Date.now()} ${randomBytes(6).toString('hex')}`;
|
|
278
|
+
const draft=`${path}.${randomBytes(6).toString('hex')}`;
|
|
279
|
+
writeFileSync(draft,token);
|
|
280
|
+
try{
|
|
281
|
+
linkSync(draft,path);
|
|
282
|
+
return ()=>{try{if(readFileSync(path,'utf8')===token)unlinkSync(path);}catch{/* Already gone. */}};
|
|
283
|
+
}catch(error){
|
|
284
|
+
if(!(error instanceof Error)||!('code' in error)||error.code!=='EEXIST')throw error;
|
|
285
|
+
let held='';
|
|
286
|
+
try{held=readFileSync(path,'utf8');}catch{/* Released meanwhile. */}
|
|
287
|
+
const [pid,since]=held.split(' ').map(Number);
|
|
288
|
+
let alive=false;
|
|
289
|
+
try{if(pid!==undefined&&Number.isInteger(pid)&&pid>0){process.kill(pid,0);alive=true;}}catch{/* The holder is gone. */}
|
|
290
|
+
const age=since===undefined||!Number.isFinite(since)?'unknown':`${String(Math.round((Date.now()-since)/1000))} s`;
|
|
291
|
+
if(alive&&since!==undefined&&Date.now()-since<STALE_MS)throw new StopError(`another worktree setup (pid ${String(pid)}, ${age}) holds ${path}; retry when it finishes`);
|
|
292
|
+
throw new StopError(`${path} looks abandoned (pid ${String(pid)} ${alive?'reused':'gone'}, age ${age}); if no worktree setup is running, rm ${path} and retry`);
|
|
293
|
+
}finally{unlinkSync(draft);}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** @param {string} cwd @param {string} command @param {string[]} args @param {NodeJS.ProcessEnv} env */
|
|
297
|
+
function run(cwd,command,args,env){
|
|
298
|
+
const result=spawnSync(command,args,{cwd,env,stdio:['ignore','inherit','inherit']});
|
|
299
|
+
if(result.error!==undefined)throw new StopError(`${command} ${args.join(' ')}: ${result.error.message}`);
|
|
300
|
+
if(result.status!==0)throw new StopError(`${command} ${args.join(' ')} exited ${String(result.status)}`);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** @param {string[]} argv @param {string} [cwd] @param {NodeJS.ProcessEnv} [env] @returns {number} */
|
|
304
|
+
export function worktreeNew(argv,cwd=process.cwd(),env=process.env){
|
|
305
|
+
const options=parseArgs(argv),canonical=canonicalRoot(cwd),common=join(canonical,'.git');
|
|
306
|
+
const relative=`${WORKTREES}/${options.slug}`,tree=join(canonical,relative),branch=`plan/${options.slug}`;
|
|
307
|
+
/** @type {{step:string,seconds:number,detail?:string}[]} */const steps=[];
|
|
308
|
+
const began=performance.now();
|
|
309
|
+
/** @param {string} step @param {() => (string|void)} work */
|
|
310
|
+
const timed=(step,work)=>{
|
|
311
|
+
const started=performance.now(),detail=work();
|
|
312
|
+
steps.push({step,seconds:Number(((performance.now()-started)/1000).toFixed(2)),...(typeof detail==='string'?{detail}:{})});
|
|
313
|
+
process.stdout.write(`worktree ${step.padEnd(8)} ${(steps.at(-1)?.seconds??0).toFixed(1)} s${typeof detail==='string'?` ${detail}`:''}\n`);
|
|
314
|
+
};
|
|
315
|
+
const unlock=lock(common);
|
|
316
|
+
let base='';
|
|
317
|
+
try{
|
|
318
|
+
if(existsSync(tree))throw new StopError(`${relative} already exists; work there, or pick another slug`);
|
|
319
|
+
if(tryGit(canonical,['rev-parse','--verify','--quiet',`refs/heads/${branch}`]).status===0)throw new StopError(`branch ${branch} already exists; delete it or pick another slug`);
|
|
320
|
+
timed('fetch',()=>{git(canonical,['fetch','--quiet','origin','main']);base=git(canonical,['rev-parse','origin/main']).trim();return `origin/main ${base.slice(0,10)}; ${followMain(canonical,base)}`;});
|
|
321
|
+
// DK9: after the fetch, so "landed" reads the current origin/main; before anything is added.
|
|
322
|
+
const refused=capRefusal(canonical,env);
|
|
323
|
+
if(refused!=='')throw new StopError(refused);
|
|
324
|
+
// Git refuses `-b` for a branch that appeared since the check, before anything here owns one.
|
|
325
|
+
timed('add',()=>{git(canonical,['worktree','add','--quiet','--no-checkout','-b',branch,relative,base]);});
|
|
326
|
+
try{
|
|
327
|
+
timed('checkout',()=>{
|
|
328
|
+
git(tree,['reset','--quiet']);
|
|
329
|
+
let cloned=0;
|
|
330
|
+
if(options.clone&&process.platform==='darwin'){
|
|
331
|
+
try{cloned=cloneTrackedFiles(canonical,tree);}
|
|
332
|
+
catch(error){process.stderr.write(`worktree: clone reuse skipped (${error instanceof Error?error.message:String(error)}); git writes every file\n`);}
|
|
333
|
+
}
|
|
334
|
+
// Git writes every tracked file the clone did not place (and symlinks); it never overwrites a verified clone.
|
|
335
|
+
const missing=[...stagedBlobs(tree).keys()].filter(path=>{try{lstatSync(join(tree,path));return false;}catch{return true;}});
|
|
336
|
+
const written=spawnSync('git',['checkout-index','--stdin','-z'],{cwd:tree,input:missing.map(path=>`${path}\0`).join(''),encoding:'utf8',maxBuffer:64<<20});
|
|
337
|
+
if(written.status!==0)throw new StopError(`git checkout-index: ${written.stderr.trim()}`);
|
|
338
|
+
tryGit(tree,['update-index','-q','--refresh']);
|
|
339
|
+
const stray=git(tree,['status','--porcelain','--untracked-files=no']).trim();
|
|
340
|
+
if(stray!=='')throw new StopError(`${relative} is not clean after checkout:\n${stray.split('\n').slice(0,10).join('\n')}`);
|
|
341
|
+
checkHooks(tree);
|
|
342
|
+
return `${cloned} of ${stagedBlobs(tree).size} tracked files cloned from the canonical checkout`;
|
|
343
|
+
});
|
|
344
|
+
}catch(error){
|
|
345
|
+
// Take back only what this setup made: its worktree, and its branch while it still points at the base.
|
|
346
|
+
tryGit(canonical,['worktree','remove','--force',relative]);
|
|
347
|
+
tryGit(canonical,['update-ref','-d',`refs/heads/${branch}`,base]);
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}finally{unlock();}
|
|
351
|
+
const manifest=join(tree,'package.json');
|
|
352
|
+
const scripts=existsSync(manifest)?/** @type {{scripts?:Record<string,string>}} */(JSON.parse(readFileSync(manifest,'utf8'))).scripts??{}:{};
|
|
353
|
+
const childEnv=Object.fromEntries(Object.entries(env).filter(([key])=>!key.startsWith('GIT_')));
|
|
354
|
+
if(options.install&&existsSync(manifest))timed('install',()=>withStoreUse(env,'worktree install',()=>run(tree,'pnpm',['install','--frozen-lockfile','--offline'],childEnv)));
|
|
355
|
+
if(options.pins&&scripts.pins!==undefined)timed('pins',()=>run(tree,'pnpm',['--silent','pins'],childEnv));
|
|
356
|
+
if(options.herdr&&env.HERDR_ENV==='1'&&env.HERDR_PANE_ID!==undefined&&env.HERDR_PANE_ID!==''){
|
|
357
|
+
const named=spawnSync('herdr',['pane','rename',env.HERDR_PANE_ID,`${basename(canonical)} ${branch}`],{encoding:'utf8'});
|
|
358
|
+
if(named.status!==0)process.stderr.write(`worktree: herdr pane not renamed (${named.error?.message??named.stderr.trim()})\n`);
|
|
359
|
+
}
|
|
360
|
+
// LAND-SIMPLIFY LS2: local readers use main's last measured test seconds; refresh a missing or day-old table in the
|
|
361
|
+
// background (scripts/test-timings.mjs fetch). It never holds up the worktree, and a failure only leaves the defaults.
|
|
362
|
+
if(!env.CI&&env.WS_TIMINGS_FETCH!=='0'&&existsSync(join(tree,'scripts/test-timings.mjs'))){
|
|
363
|
+
try{spawn(process.execPath,['scripts/test-timings.mjs','fetch','--if-stale'],{cwd:tree,env:childEnv,detached:true,stdio:'ignore'}).unref();}
|
|
364
|
+
catch(error){process.stderr.write(`worktree: timings refresh not started (${error instanceof Error?error.message:String(error)})\n`);}
|
|
365
|
+
}
|
|
366
|
+
const total=Number(((performance.now()-began)/1000).toFixed(2));
|
|
367
|
+
const record={slug:options.slug,branch,base,tree,total,steps,finished:new Date().toISOString()};
|
|
368
|
+
mkdirSync(join(tree,'tmp'),{recursive:true});
|
|
369
|
+
writeFileSync(join(tree,'tmp/worktree-setup.json'),`${JSON.stringify(record,null,2)}\n`);
|
|
370
|
+
const lane=/^[a-z][a-z0-9_-]*$/u.test(env.WS_LANE_NAME??'')?String(env.WS_LANE_NAME):'';
|
|
371
|
+
if(lane!==''){
|
|
372
|
+
const file=resolve(env.WS_LANE_RECEIPTS??join(homedir(),'.cache/wildshard/lane-receipts.log'));
|
|
373
|
+
try{mkdirSync(dirname(file),{recursive:true});appendFileSync(file,`${new Date().toISOString().slice(11,16)} UTC ${lane} worktree new ${basename(canonical)}/${relative} on ${branch} from ${base.slice(0,10)} in ${total.toFixed(1)} s (${steps.map(row=>`${row.step} ${row.seconds.toFixed(1)}`).join(', ')})\n`);}
|
|
374
|
+
catch(error){process.stderr.write(`worktree receipt unavailable: ${String(error)}\n`);}
|
|
375
|
+
}
|
|
376
|
+
const name=lane===''?'<lane>':lane;
|
|
377
|
+
process.stdout.write(`\nworktree ready in ${total.toFixed(1)} s: ${tree} on ${branch}\n\nLand (J240):\n cd ${tree}\n # commit by pathspec as usual; the hooks allow commits here on ${branch}\n WS_LANE_NAME=${name} node scripts/land.mjs\n # it pushes ${branch}, waits for its hosted CI (land.config.json workflows), rebases and fast-forwards main;\n # check its receipt in ~/.cache/wildshard/lane-receipts.log. Force only your own plan/* branch\n # after a rebase (--force-with-lease), never main.\n`);
|
|
378
|
+
return 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if(process.argv[1]!==undefined&&import.meta.url===pathToFileURL(resolve(process.argv[1])).href){
|
|
382
|
+
const argv=process.argv.slice(2);
|
|
383
|
+
try{
|
|
384
|
+
if(argv[0]==='reap'){
|
|
385
|
+
let options;
|
|
386
|
+
try{options=parseReapArgs(argv.slice(1));}catch(error){throw new StopError(error instanceof Error?error.message:String(error));}
|
|
387
|
+
process.exitCode=reap(canonicalRoot(process.cwd()),options,process.env,line=>{process.stdout.write(`${line}\n`);});
|
|
388
|
+
}
|
|
389
|
+
else process.exitCode=worktreeNew(argv);
|
|
390
|
+
}
|
|
391
|
+
catch(error){
|
|
392
|
+
if(!(error instanceof StopError))throw error;
|
|
393
|
+
process.stderr.write(`worktree STOP ${error.message}\n`);
|
|
394
|
+
process.exitCode=1;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# T6's helper (E406): World Explorer views of a shard through the harness params
|
|
3
|
+
# (`chunk`, `explore=world`, `cam`), one PNG per camera, into the round's art folder. Pair it with spec-map.py for the plan
|
|
4
|
+
# map (a vertical shard's overhead view shows roofs, not floors).
|
|
5
|
+
#
|
|
6
|
+
# scripts/browser-lane.sh wait
|
|
7
|
+
# bash scripts/worldclaw/capture-front.sh <slug> <build url> <out dir> <cams.json>
|
|
8
|
+
#
|
|
9
|
+
# cams.json: [{ "name": "view-a-spawn", "w": 402, "h": 874, "cam": "x,y,z,yaw,pitch" }, …] — metres, the engine's yaw and
|
|
10
|
+
# pitch in radians (yaw = −heading°; a shard's mockupCameras.ts says how its own cameras map). 402 × 874 is the phone's
|
|
11
|
+
# portrait frame (Jake's iPhone, AGENTS.md); a map view may be square. Serve a build first (scripts/serve-build.sh); the
|
|
12
|
+
# browser is muted and closed at the end (AGENTS.md: the browser lane).
|
|
13
|
+
set -euo pipefail
|
|
14
|
+
slug="$1"; url="$2"; out="$3"; cams="$4"
|
|
15
|
+
mkdir -p "$out"
|
|
16
|
+
session="front-$slug"
|
|
17
|
+
# a shard boots and streams its world before the first frame is final (~60–120 s headless, AGENTS.md ▸ Mockups)
|
|
18
|
+
settle="${SETTLE_S:-75}"
|
|
19
|
+
n=$(node -e "console.log(JSON.parse(require('fs').readFileSync(process.argv[1],'utf8')).length)" "$cams")
|
|
20
|
+
for ((i = 0; i < n; i++)); do
|
|
21
|
+
read -r name w h cam < <(node -e "const c=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'))[+process.argv[2]];console.log(c.name,c.w,c.h,c.cam)" "$cams" "$i")
|
|
22
|
+
agent-browser --session "$session" set viewport "$w" "$h" >/dev/null
|
|
23
|
+
agent-browser --session "$session" open "${url}?chunk=${slug}&explore=world&cam=${cam}&mute=1&skipintro" >/dev/null
|
|
24
|
+
sleep "$settle"
|
|
25
|
+
agent-browser --session "$session" screenshot "$out/$name.png" >/dev/null
|
|
26
|
+
echo "capture-front: $out/$name.png"
|
|
27
|
+
done
|
|
28
|
+
agent-browser --session "$session" close >/dev/null
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# <Shard name> · design.md
|
|
2
|
+
|
|
3
|
+
<!-- T1's human twin (WORLDCLAW-SHARD T1, R15, D87). Copy to src/shards/<slug>/design/design.md. The prose sections are for
|
|
4
|
+
people; the ```json worldclaw block at the end is for the checks (spec-check, twin-check) and must agree with spec.json
|
|
5
|
+
id for id. design.md owns intent and Jake's words; spec.json owns the numbers. A WorldClaw run is `"scope": "full"`
|
|
6
|
+
with a `run`; a director's single stage on a shipped shard (§S, D91) writes `"scope": "slice"` and no `run`. -->
|
|
7
|
+
|
|
8
|
+
## Vision (P1, Jake, verbatim)
|
|
9
|
+
"<the sentence>"
|
|
10
|
+
|
|
11
|
+
## The pitch (P2)
|
|
12
|
+
<one paragraph> · **Pillars:** moment · session · return · **Verb:** … · **Weapon:** … · **Roster:** … · **Boss:** … ·
|
|
13
|
+
**Look:** <the style bible's name> (`style-bible.md`).
|
|
14
|
+
|
|
15
|
+
## Places
|
|
16
|
+
| id | Place | Role | Beat |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| <id> | <name> | <role> | <what happens here> |
|
|
19
|
+
|
|
20
|
+
## Happenings
|
|
21
|
+
- **<name>** (signal: <what the player sees or hears>; seen from <places>).
|
|
22
|
+
|
|
23
|
+
## The critical path and routes
|
|
24
|
+
<the golden path as place ids> · the routes as typed legs (walk, climb, sled, rope …).
|
|
25
|
+
|
|
26
|
+
## The quest
|
|
27
|
+
| # | Step | Where | Why / what | Gets | Mechanics |
|
|
28
|
+
|---|---|---|---|---|---|
|
|
29
|
+
|
|
30
|
+
## The session slice (P9)
|
|
31
|
+
<place ids in play order, with the time it takes>
|
|
32
|
+
|
|
33
|
+
## §run (06 §10.7)
|
|
34
|
+
- mode: guided | zero-shot · until: P<n> (the bound, if any) · P0's answers
|
|
35
|
+
- step: P<n> (the machine block's `run.stage`: one value, written together) · waitingOn: jake | codex-quota (with its time) · resentAt · next: …
|
|
36
|
+
- stop: continue | done | blocked | quota(<reset>) (set before a session exits)
|
|
37
|
+
- the pending board and question · queued commands
|
|
38
|
+
- the last build SHA · the live page's URL · the frames folder
|
|
39
|
+
|
|
40
|
+
## Verdict log
|
|
41
|
+
- P<n>: "<Jake's words, verbatim>" (ask id).
|
|
42
|
+
|
|
43
|
+
## The checkpoints (§2b; one entry per pinned place)
|
|
44
|
+
- <place>: the accepted camera, the assets, the gate evidence, the rejected variants, the next place.
|
|
45
|
+
|
|
46
|
+
```json worldclaw
|
|
47
|
+
{
|
|
48
|
+
"slug": "<slug>",
|
|
49
|
+
"scope": "full",
|
|
50
|
+
"places": [{ "id": "<id>", "role": "spawn", "name": "<name>", "beat": "<beat>" }],
|
|
51
|
+
"happenings": [],
|
|
52
|
+
"npcs": [],
|
|
53
|
+
"enemyZones": [],
|
|
54
|
+
"elites": [],
|
|
55
|
+
"boss": null,
|
|
56
|
+
"quest": [],
|
|
57
|
+
"routes": [],
|
|
58
|
+
"gates": ["N", "E", "S", "W"],
|
|
59
|
+
"slice": [],
|
|
60
|
+
"run": { "mode": "guided", "stage": "P0" }
|
|
61
|
+
}
|
|
62
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""T6's helper (E406), the plan map: a shard's spec.json drawn as a plan (places as discs with
|
|
3
|
+
their role and height, routes as typed legs, gates), for shards whose overhead capture shows roofs, not floors (a vertical
|
|
4
|
+
city). Usage: python3 scripts/worldclaw/spec-map.py <spec.json> <out.png> [<design.md>]
|
|
5
|
+
Coordinates: x east, z south (north up); the frame fits the places and routes with a margin of one place radius."""
|
|
6
|
+
import json
|
|
7
|
+
import math
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
12
|
+
|
|
13
|
+
ROLE_COLOR = {'spawn': (242, 166, 64), 'hub': (143, 227, 255), 'landmark': (255, 214, 102), 'vista': (185, 140, 255),
|
|
14
|
+
'traversal': (95, 224, 160), 'boss': (255, 107, 107), 'secret': (200, 200, 200)}
|
|
15
|
+
LEG_COLOR = {'walk': (232, 241, 245), 'stair': (95, 224, 160), 'grapple': (255, 107, 107), 'sled': (90, 225, 200),
|
|
16
|
+
'rope': (242, 166, 64), 'climb': (255, 214, 102)}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def font(size):
|
|
20
|
+
for f in ('/System/Library/Fonts/Menlo.ttc', '/System/Library/Fonts/Supplemental/Arial.ttf'):
|
|
21
|
+
try:
|
|
22
|
+
return ImageFont.truetype(f, size)
|
|
23
|
+
except OSError:
|
|
24
|
+
continue
|
|
25
|
+
return ImageFont.load_default()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def main():
|
|
29
|
+
spec = json.load(open(sys.argv[1]))
|
|
30
|
+
out = sys.argv[2]
|
|
31
|
+
names = {}
|
|
32
|
+
if len(sys.argv) > 3:
|
|
33
|
+
m = re.search(r'```json worldclaw\n([\s\S]*?)\n```', open(sys.argv[3]).read())
|
|
34
|
+
if m:
|
|
35
|
+
names = {p['id']: p['name'] for p in json.loads(m.group(1))['places']}
|
|
36
|
+
pts = [(p['x'], p['z']) for p in spec['places']]
|
|
37
|
+
for r in spec['routes']:
|
|
38
|
+
for leg in r['legs']:
|
|
39
|
+
pts += [tuple(q) for q in leg['pts']]
|
|
40
|
+
pad = max([p['r'] for p in spec['places']] + [10])
|
|
41
|
+
x0, x1 = min(p[0] for p in pts) - pad, max(p[0] for p in pts) + pad
|
|
42
|
+
z0, z1 = min(p[1] for p in pts) - pad, max(p[1] for p in pts) + pad
|
|
43
|
+
W = 1600
|
|
44
|
+
scale = W / max(x1 - x0, z1 - z0)
|
|
45
|
+
H = int((z1 - z0) * scale) + 160
|
|
46
|
+
img = Image.new('RGB', (W, H), (8, 18, 27))
|
|
47
|
+
d = ImageDraw.Draw(img)
|
|
48
|
+
P = lambda x, z: ((x - x0) * scale, (z - z0) * scale + 80)
|
|
49
|
+
# a 10 m grid
|
|
50
|
+
step = 10
|
|
51
|
+
for gx in range(int(math.floor(x0 / step)) * step, int(x1) + step, step):
|
|
52
|
+
d.line([P(gx, z0), P(gx, z1)], fill=(18, 32, 44), width=1)
|
|
53
|
+
for gz in range(int(math.floor(z0 / step)) * step, int(z1) + step, step):
|
|
54
|
+
d.line([P(x0, gz), P(x1, gz)], fill=(18, 32, 44), width=1)
|
|
55
|
+
for p in spec['places']:
|
|
56
|
+
cx, cy = P(p['x'], p['z'])
|
|
57
|
+
r = p['r'] * scale
|
|
58
|
+
col = ROLE_COLOR.get(p['role'], (143, 227, 255))
|
|
59
|
+
d.ellipse([cx - r, cy - r, cx + r, cy + r], outline=col, width=3)
|
|
60
|
+
for r in spec['routes']:
|
|
61
|
+
for leg in r['legs']:
|
|
62
|
+
d.line([P(*q) for q in leg['pts']], fill=LEG_COLOR.get(leg['mode'], (232, 241, 245)), width=5)
|
|
63
|
+
f, fs = font(26), font(19)
|
|
64
|
+
stacked = {}
|
|
65
|
+
for p in spec['places']:
|
|
66
|
+
cx, cy = P(p['x'], p['z'])
|
|
67
|
+
# places at one spot (a vertical city's levels) stack their labels instead of overprinting
|
|
68
|
+
key = (round(cx / 40), round(cy / 40))
|
|
69
|
+
dy = stacked.get(key, 0) * 56
|
|
70
|
+
stacked[key] = stacked.get(key, 0) + 1
|
|
71
|
+
col = ROLE_COLOR.get(p['role'], (143, 227, 255))
|
|
72
|
+
d.ellipse([cx - 7, cy - 7, cx + 7, cy + 7], fill=col)
|
|
73
|
+
label = names.get(p['id'], p['id'])
|
|
74
|
+
y = f" +{p['y']:g} m" if 'y' in p else ''
|
|
75
|
+
d.text((cx + 12, cy - 14 + dy), label.upper(), fill=(232, 241, 245), font=f)
|
|
76
|
+
d.text((cx + 12, cy + 14 + dy), f"{p['role']}{y}", fill=col, font=fs)
|
|
77
|
+
d.text((24, 22), f"{spec['slug'].upper()} · PLAN FROM spec.json (x east, z south, north up)", fill=(143, 227, 255), font=f)
|
|
78
|
+
# the scale bar: 20 m
|
|
79
|
+
bx, by = 24, H - 40
|
|
80
|
+
d.line([(bx, by), (bx + 20 * scale, by)], fill=(232, 241, 245), width=4)
|
|
81
|
+
d.text((bx + 20 * scale + 10, by - 14), '20 m', fill=(232, 241, 245), font=fs)
|
|
82
|
+
lx = W - 520
|
|
83
|
+
for i, (mode, col) in enumerate(LEG_COLOR.items()):
|
|
84
|
+
if any(leg['mode'] == mode for r in spec['routes'] for leg in r['legs']):
|
|
85
|
+
d.line([(lx, by - i * 26), (lx + 40, by - i * 26)], fill=col, width=5)
|
|
86
|
+
d.text((lx + 50, by - i * 26 - 12), mode, fill=col, font=fs)
|
|
87
|
+
img.save(out)
|
|
88
|
+
print(out, img.size)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == '__main__':
|
|
92
|
+
main()
|